~ubuntu-branches/debian/sid/gcc-4.8/sid

« back to all changes in this revision

Viewing changes to .svn/pristine/8b/8b74c5605dea9f32591df259a611f7e904c941dc.svn-base

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-12-19 19:48:34 UTC
  • Revision ID: package-import@ubuntu.com-20141219194834-4dz1q7rrn5pad823
Tags: 4.8.4-1
* GCC 4.8.4 release.
  - Fix PR target/61407 (darwin), PR middle-end/58624 (ice),
    PR sanitizer/64265 (wrong code).
* Require recent binutils to pass go test failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# DP: Changes from the ibm/gcc-4_8-branch (20140113)
 
2
 
 
3
LANG=C svn diff svn://gcc.gnu.org/svn/gcc/branches/gcc-4_8-branch@206579 \
 
4
    svn://gcc.gnu.org/svn/gcc/branches/ibm/gcc-4_8-branch@206581 \
 
5
 | filterdiff --remove-timestamps --addoldprefix=a/src/ --addnewprefix=b/src/
 
6
 
 
7
--- a/src/libitm/configure
 
8
+++ b/src/libitm/configure
 
9
@@ -7270,7 +7270,7 @@
 
10
   rm -rf conftest*
 
11
   ;;
 
12
 
 
13
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
14
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
15
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
16
   # Find out which ABI we are using.
 
17
   echo 'int i;' > conftest.$ac_ext
 
18
@@ -7295,7 +7295,10 @@
 
19
                ;;
 
20
            esac
 
21
            ;;
 
22
-         ppc64-*linux*|powerpc64-*linux*)
 
23
+         powerpc64le-*linux*)
 
24
+           LD="${LD-ld} -m elf32lppclinux"
 
25
+           ;;
 
26
+         powerpc64-*linux*)
 
27
            LD="${LD-ld} -m elf32ppclinux"
 
28
            ;;
 
29
          s390x-*linux*)
 
30
@@ -7314,7 +7317,10 @@
 
31
          x86_64-*linux*)
 
32
            LD="${LD-ld} -m elf_x86_64"
 
33
            ;;
 
34
-         ppc*-*linux*|powerpc*-*linux*)
 
35
+         powerpcle-*linux*)
 
36
+           LD="${LD-ld} -m elf64lppc"
 
37
+           ;;
 
38
+         powerpc-*linux*)
 
39
            LD="${LD-ld} -m elf64ppc"
 
40
            ;;
 
41
          s390*-*linux*|s390*-*tpf*)
 
42
@@ -11779,7 +11785,7 @@
 
43
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
44
   lt_status=$lt_dlunknown
 
45
   cat > conftest.$ac_ext <<_LT_EOF
 
46
-#line 11782 "configure"
 
47
+#line 11788 "configure"
 
48
 #include "confdefs.h"
 
49
 
 
50
 #if HAVE_DLFCN_H
 
51
@@ -11885,7 +11891,7 @@
 
52
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
53
   lt_status=$lt_dlunknown
 
54
   cat > conftest.$ac_ext <<_LT_EOF
 
55
-#line 11888 "configure"
 
56
+#line 11894 "configure"
 
57
 #include "confdefs.h"
 
58
 
 
59
 #if HAVE_DLFCN_H
 
60
@@ -17401,7 +17407,44 @@
 
61
 esac
 
62
 LIBITM_CHECK_AS_HTM
 
63
 
 
64
+case "${target_cpu}" in
 
65
+powerpc*)
 
66
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the assembler supports HTM" >&5
 
67
+$as_echo_n "checking if the assembler supports HTM... " >&6; }
 
68
+if test "${libitm_cv_as_htm+set}" = set; then :
 
69
+  $as_echo_n "(cached) " >&6
 
70
+else
 
71
 
 
72
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 
73
+/* end confdefs.h.  */
 
74
+
 
75
+int
 
76
+main ()
 
77
+{
 
78
+asm("tbegin. 0; tend. 0");
 
79
+  ;
 
80
+  return 0;
 
81
+}
 
82
+_ACEOF
 
83
+if ac_fn_c_try_compile "$LINENO"; then :
 
84
+  libitm_cv_as_htm=yes
 
85
+else
 
86
+  libitm_cv_as_htm=no
 
87
+fi
 
88
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
89
+
 
90
+fi
 
91
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libitm_cv_as_htm" >&5
 
92
+$as_echo "$libitm_cv_as_htm" >&6; }
 
93
+  if test x$libitm_cv_as_htm = xyes; then
 
94
+
 
95
+$as_echo "#define HAVE_AS_HTM 1" >>confdefs.h
 
96
+
 
97
+  fi
 
98
+  ;;
 
99
+esac
 
100
+
 
101
+
 
102
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether weak refs work like ELF" >&5
 
103
 $as_echo_n "checking whether weak refs work like ELF... " >&6; }
 
104
 if test "${ac_cv_have_elf_style_weakref+set}" = set; then :
 
105
--- a/src/libitm/ChangeLog.ibm
 
106
+++ b/src/libitm/ChangeLog.ibm
 
107
@@ -0,0 +1,31 @@
 
108
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
109
+
 
110
+       Backport from mainline r204808:
 
111
+
 
112
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
113
+
 
114
+       * config/powerpc/sjlj.S [__powerpc64__ && _CALL_ELF == 2]:
 
115
+       (FUNC): Define ELFv2 variant.
 
116
+       (END): Likewise.
 
117
+       (HIDDEN): Likewise.
 
118
+       (CALL): Likewise.
 
119
+       (BASE): Likewise.
 
120
+       (LR_SAVE): Likewise.
 
121
+
 
122
+2013-07-15  Peter Bergner  <bergner@vnet.ibm.com>
 
123
+
 
124
+       Backport from mainline
 
125
+       2013-07-15  Peter Bergner  <bergner@vnet.ibm.com>
 
126
+
 
127
+        * acinclude.m4 (LIBITM_CHECK_AS_HTM): New.
 
128
+        * configure.ac: Use it.
 
129
+       (AC_CHECK_HEADERS): Check for sys/auxv.h.
 
130
+       (AC_CHECK_FUNCS): Check for getauxval.
 
131
+        * config.h.in, configure: Rebuild.
 
132
+       * configure.tgt (target_cpu): Add -mhtm to XCFLAGS.
 
133
+       * config/powerpc/target.h: Include sys/auxv.h and htmintrin.h.
 
134
+       (USE_HTM_FASTPATH): Define.
 
135
+       (_TBEGIN_STARTED, _TBEGIN_INDETERMINATE, _TBEGIN_PERSISTENT,
 
136
+       _HTM_RETRIES) New macros.
 
137
+       (htm_abort, htm_abort_should_retry, htm_available, htm_begin, htm_init,
 
138
+       htm_begin_success, htm_commit, htm_transaction_active): New functions.
 
139
--- a/src/libitm/configure.tgt
 
140
+++ b/src/libitm/configure.tgt
 
141
@@ -47,7 +47,10 @@
 
142
 # work out any special compilation flags as necessary.
 
143
 case "${target_cpu}" in
 
144
   alpha*)              ARCH=alpha ;;
 
145
-  rs6000 | powerpc*)   ARCH=powerpc ;;
 
146
+  rs6000 | powerpc*)
 
147
+       XCFLAGS="${XCFLAGS} -mhtm"
 
148
+       ARCH=powerpc
 
149
+       ;;
 
150
 
 
151
   arm*)                ARCH=arm ;;
 
152
 
 
153
--- a/src/libitm/config/powerpc/sjlj.S
 
154
+++ b/src/libitm/config/powerpc/sjlj.S
 
155
@@ -26,8 +26,27 @@
 
156
 
 
157
 #include "asmcfi.h"
 
158
 
 
159
-#if defined(__powerpc64__) && defined(__ELF__)
 
160
+#if defined(__powerpc64__) && _CALL_ELF == 2
 
161
 .macro FUNC name
 
162
+        .globl  \name
 
163
+        .type   \name, @function
 
164
+\name:
 
165
+0:     addis 2,12,(.TOC.-0b)@ha
 
166
+       addi 2,2,(.TOC.-0b)@l
 
167
+       .localentry \name, . - \name
 
168
+.endm
 
169
+.macro END name
 
170
+       .size   \name, . - \name
 
171
+.endm
 
172
+.macro HIDDEN name
 
173
+       .hidden \name
 
174
+.endm
 
175
+.macro CALL name
 
176
+       bl      \name
 
177
+       nop
 
178
+.endm
 
179
+#elif defined(__powerpc64__) && defined(__ELF__)
 
180
+.macro FUNC name
 
181
         .globl  \name, .\name
 
182
         .section ".opd","aw"
 
183
         .align  3
 
184
@@ -117,6 +136,9 @@
 
185
 #if defined(_CALL_AIXDESC)
 
186
 # define BASE          6*WS
 
187
 # define LR_SAVE       2*WS
 
188
+#elif _CALL_ELF == 2
 
189
+# define BASE          6*WS
 
190
+# define LR_SAVE       2*WS
 
191
 #elif defined(_CALL_SYSV)
 
192
 # define BASE          2*WS
 
193
 # define LR_SAVE       1*WS
 
194
--- a/src/libitm/config/powerpc/target.h
 
195
+++ b/src/libitm/config/powerpc/target.h
 
196
@@ -22,6 +22,10 @@
 
197
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
198
    <http://www.gnu.org/licenses/>.  */
 
199
 
 
200
+#ifdef HAVE_SYS_AUXV_H
 
201
+#include <sys/auxv.h>
 
202
+#endif
 
203
+
 
204
 namespace GTM HIDDEN {
 
205
 
 
206
 typedef int v128 __attribute__((vector_size(16), may_alias, aligned(16)));
 
207
@@ -55,4 +59,82 @@
 
208
   __asm volatile ("" : : : "memory");
 
209
 }
 
210
 
 
211
+// Use HTM if it is supported by the system.
 
212
+// See gtm_thread::begin_transaction for how these functions are used.
 
213
+#if defined (__linux__) \
 
214
+    && defined (HAVE_AS_HTM) \
 
215
+    && defined (HAVE_GETAUXVAL) \
 
216
+    && defined (AT_HWCAP2) \
 
217
+    && defined (PPC_FEATURE2_HAS_HTM)
 
218
+
 
219
+#include <htmintrin.h>
 
220
+
 
221
+#define USE_HTM_FASTPATH
 
222
+
 
223
+#define _TBEGIN_STARTED       0
 
224
+#define _TBEGIN_INDETERMINATE 1
 
225
+#define _TBEGIN_PERSISTENT    2
 
226
+
 
227
+/* Number of retries for transient failures.  */
 
228
+#define _HTM_RETRIES 10
 
229
+
 
230
+static inline bool
 
231
+htm_available (void)
 
232
+{
 
233
+  return (getauxval (AT_HWCAP2) & PPC_FEATURE2_HAS_HTM) ? true : false;
 
234
+}
 
235
+
 
236
+static inline uint32_t
 
237
+htm_init (void)
 
238
+{
 
239
+  // Maximum number of times we try to execute a transaction
 
240
+  // as a HW transaction.
 
241
+  return htm_available () ? _HTM_RETRIES : 0;
 
242
+}
 
243
+
 
244
+static inline uint32_t
 
245
+htm_begin (void)
 
246
+{
 
247
+  if (__builtin_expect (__builtin_tbegin (0), 1))
 
248
+    return _TBEGIN_STARTED;
 
249
+
 
250
+  if (_TEXASRU_FAILURE_PERSISTENT (__builtin_get_texasru ()))
 
251
+    return _TBEGIN_PERSISTENT;
 
252
+
 
253
+  return _TBEGIN_INDETERMINATE;
 
254
+}
 
255
+
 
256
+static inline bool
 
257
+htm_begin_success (uint32_t begin_ret)
 
258
+{
 
259
+  return begin_ret == _TBEGIN_STARTED;
 
260
+}
 
261
+
 
262
+static inline void
 
263
+htm_commit (void)
 
264
+{
 
265
+  __builtin_tend (0);
 
266
+}
 
267
+
 
268
+static inline void
 
269
+htm_abort (void)
 
270
+{
 
271
+  __builtin_tabort (0);
 
272
+}
 
273
+
 
274
+static inline bool
 
275
+htm_abort_should_retry (uint32_t begin_ret)
 
276
+{
 
277
+  return begin_ret != _TBEGIN_PERSISTENT;
 
278
+}
 
279
+
 
280
+/* Returns true iff a hardware transaction is currently being executed.  */
 
281
+static inline bool
 
282
+htm_transaction_active (void)
 
283
+{
 
284
+  return (_HTM_STATE (__builtin_ttest ()) == _HTM_TRANSACTIONAL);
 
285
+}
 
286
+
 
287
+#endif
 
288
+
 
289
 } // namespace GTM
 
290
--- a/src/libitm/acinclude.m4
 
291
+++ b/src/libitm/acinclude.m4
 
292
@@ -134,6 +134,20 @@
 
293
   ;;
 
294
 esac])
 
295
 
 
296
+dnl Check if as supports HTM instructions.
 
297
+AC_DEFUN([LIBITM_CHECK_AS_HTM], [
 
298
+case "${target_cpu}" in
 
299
+powerpc*)
 
300
+  AC_CACHE_CHECK([if the assembler supports HTM], libitm_cv_as_htm, [
 
301
+    AC_TRY_COMPILE([], [asm("tbegin. 0; tend. 0");],
 
302
+                  [libitm_cv_as_htm=yes], [libitm_cv_as_htm=no])
 
303
+  ])
 
304
+  if test x$libitm_cv_as_htm = xyes; then
 
305
+    AC_DEFINE(HAVE_AS_HTM, 1, [Define to 1 if the assembler supports HTM.])
 
306
+  fi
 
307
+  ;;
 
308
+esac])
 
309
+
 
310
 sinclude(../libtool.m4)
 
311
 dnl The lines below arrange for aclocal not to bring an installed
 
312
 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
 
313
--- a/src/libtool.m4
 
314
+++ b/src/libtool.m4
 
315
@@ -1220,7 +1220,7 @@
 
316
   rm -rf conftest*
 
317
   ;;
 
318
 
 
319
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
320
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
321
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
322
   # Find out which ABI we are using.
 
323
   echo 'int i;' > conftest.$ac_ext
 
324
@@ -1241,7 +1241,10 @@
 
325
                ;;
 
326
            esac
 
327
            ;;
 
328
-         ppc64-*linux*|powerpc64-*linux*)
 
329
+         powerpc64le-*linux*)
 
330
+           LD="${LD-ld} -m elf32lppclinux"
 
331
+           ;;
 
332
+         powerpc64-*linux*)
 
333
            LD="${LD-ld} -m elf32ppclinux"
 
334
            ;;
 
335
          s390x-*linux*)
 
336
@@ -1260,7 +1263,10 @@
 
337
          x86_64-*linux*)
 
338
            LD="${LD-ld} -m elf_x86_64"
 
339
            ;;
 
340
-         ppc*-*linux*|powerpc*-*linux*)
 
341
+         powerpcle-*linux*)
 
342
+           LD="${LD-ld} -m elf64lppc"
 
343
+           ;;
 
344
+         powerpc-*linux*)
 
345
            LD="${LD-ld} -m elf64ppc"
 
346
            ;;
 
347
          s390*-*linux*|s390*-*tpf*)
 
348
--- a/src/libgomp/configure
 
349
+++ b/src/libgomp/configure
 
350
@@ -6580,7 +6580,7 @@
 
351
   rm -rf conftest*
 
352
   ;;
 
353
 
 
354
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
355
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
356
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
357
   # Find out which ABI we are using.
 
358
   echo 'int i;' > conftest.$ac_ext
 
359
@@ -6605,7 +6605,10 @@
 
360
                ;;
 
361
            esac
 
362
            ;;
 
363
-         ppc64-*linux*|powerpc64-*linux*)
 
364
+         powerpc64le-*linux*)
 
365
+           LD="${LD-ld} -m elf32lppclinux"
 
366
+           ;;
 
367
+         powerpc64-*linux*)
 
368
            LD="${LD-ld} -m elf32ppclinux"
 
369
            ;;
 
370
          s390x-*linux*)
 
371
@@ -6624,7 +6627,10 @@
 
372
          x86_64-*linux*)
 
373
            LD="${LD-ld} -m elf_x86_64"
 
374
            ;;
 
375
-         ppc*-*linux*|powerpc*-*linux*)
 
376
+         powerpcle-*linux*)
 
377
+           LD="${LD-ld} -m elf64lppc"
 
378
+           ;;
 
379
+         powerpc-*linux*)
 
380
            LD="${LD-ld} -m elf64ppc"
 
381
            ;;
 
382
          s390*-*linux*|s390*-*tpf*)
 
383
@@ -11088,7 +11094,7 @@
 
384
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
385
   lt_status=$lt_dlunknown
 
386
   cat > conftest.$ac_ext <<_LT_EOF
 
387
-#line 11091 "configure"
 
388
+#line 11097 "configure"
 
389
 #include "confdefs.h"
 
390
 
 
391
 #if HAVE_DLFCN_H
 
392
@@ -11194,7 +11200,7 @@
 
393
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
394
   lt_status=$lt_dlunknown
 
395
   cat > conftest.$ac_ext <<_LT_EOF
 
396
-#line 11197 "configure"
 
397
+#line 11203 "configure"
 
398
 #include "confdefs.h"
 
399
 
 
400
 #if HAVE_DLFCN_H
 
401
--- a/src/libquadmath/configure
 
402
+++ b/src/libquadmath/configure
 
403
@@ -6248,7 +6248,7 @@
 
404
   rm -rf conftest*
 
405
   ;;
 
406
 
 
407
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
408
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
409
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
410
   # Find out which ABI we are using.
 
411
   echo 'int i;' > conftest.$ac_ext
 
412
@@ -6273,7 +6273,10 @@
 
413
                ;;
 
414
            esac
 
415
            ;;
 
416
-         ppc64-*linux*|powerpc64-*linux*)
 
417
+         powerpc64le-*linux*)
 
418
+           LD="${LD-ld} -m elf32lppclinux"
 
419
+           ;;
 
420
+         powerpc64-*linux*)
 
421
            LD="${LD-ld} -m elf32ppclinux"
 
422
            ;;
 
423
          s390x-*linux*)
 
424
@@ -6292,7 +6295,10 @@
 
425
          x86_64-*linux*)
 
426
            LD="${LD-ld} -m elf_x86_64"
 
427
            ;;
 
428
-         ppc*-*linux*|powerpc*-*linux*)
 
429
+         powerpcle-*linux*)
 
430
+           LD="${LD-ld} -m elf64lppc"
 
431
+           ;;
 
432
+         powerpc-*linux*)
 
433
            LD="${LD-ld} -m elf64ppc"
 
434
            ;;
 
435
          s390*-*linux*|s390*-*tpf*)
 
436
@@ -10521,7 +10527,7 @@
 
437
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
438
   lt_status=$lt_dlunknown
 
439
   cat > conftest.$ac_ext <<_LT_EOF
 
440
-#line 10524 "configure"
 
441
+#line 10530 "configure"
 
442
 #include "confdefs.h"
 
443
 
 
444
 #if HAVE_DLFCN_H
 
445
@@ -10627,7 +10633,7 @@
 
446
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
447
   lt_status=$lt_dlunknown
 
448
   cat > conftest.$ac_ext <<_LT_EOF
 
449
-#line 10630 "configure"
 
450
+#line 10636 "configure"
 
451
 #include "confdefs.h"
 
452
 
 
453
 #if HAVE_DLFCN_H
 
454
--- a/src/libsanitizer/configure
 
455
+++ b/src/libsanitizer/configure
 
456
@@ -6604,7 +6604,7 @@
 
457
   rm -rf conftest*
 
458
   ;;
 
459
 
 
460
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
461
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
462
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
463
   # Find out which ABI we are using.
 
464
   echo 'int i;' > conftest.$ac_ext
 
465
@@ -6629,7 +6629,10 @@
 
466
                ;;
 
467
            esac
 
468
            ;;
 
469
-         ppc64-*linux*|powerpc64-*linux*)
 
470
+         powerpc64le-*linux*)
 
471
+           LD="${LD-ld} -m elf32lppclinux"
 
472
+           ;;
 
473
+         powerpc64-*linux*)
 
474
            LD="${LD-ld} -m elf32ppclinux"
 
475
            ;;
 
476
          s390x-*linux*)
 
477
@@ -6648,7 +6651,10 @@
 
478
          x86_64-*linux*)
 
479
            LD="${LD-ld} -m elf_x86_64"
 
480
            ;;
 
481
-         ppc*-*linux*|powerpc*-*linux*)
 
482
+         powerpcle-*linux*)
 
483
+           LD="${LD-ld} -m elf64lppc"
 
484
+           ;;
 
485
+         powerpc-*linux*)
 
486
            LD="${LD-ld} -m elf64ppc"
 
487
            ;;
 
488
          s390*-*linux*|s390*-*tpf*)
 
489
@@ -11111,7 +11117,7 @@
 
490
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
491
   lt_status=$lt_dlunknown
 
492
   cat > conftest.$ac_ext <<_LT_EOF
 
493
-#line 11114 "configure"
 
494
+#line 11120 "configure"
 
495
 #include "confdefs.h"
 
496
 
 
497
 #if HAVE_DLFCN_H
 
498
@@ -11217,7 +11223,7 @@
 
499
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
500
   lt_status=$lt_dlunknown
 
501
   cat > conftest.$ac_ext <<_LT_EOF
 
502
-#line 11220 "configure"
 
503
+#line 11226 "configure"
 
504
 #include "confdefs.h"
 
505
 
 
506
 #if HAVE_DLFCN_H
 
507
--- a/src/zlib/configure
 
508
+++ b/src/zlib/configure
 
509
@@ -5853,7 +5853,7 @@
 
510
   rm -rf conftest*
 
511
   ;;
 
512
 
 
513
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
514
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
515
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
516
   # Find out which ABI we are using.
 
517
   echo 'int i;' > conftest.$ac_ext
 
518
@@ -5878,7 +5878,10 @@
 
519
                ;;
 
520
            esac
 
521
            ;;
 
522
-         ppc64-*linux*|powerpc64-*linux*)
 
523
+         powerpc64le-*linux*)
 
524
+           LD="${LD-ld} -m elf32lppclinux"
 
525
+           ;;
 
526
+         powerpc64-*linux*)
 
527
            LD="${LD-ld} -m elf32ppclinux"
 
528
            ;;
 
529
          s390x-*linux*)
 
530
@@ -5897,7 +5900,10 @@
 
531
          x86_64-*linux*)
 
532
            LD="${LD-ld} -m elf_x86_64"
 
533
            ;;
 
534
-         ppc*-*linux*|powerpc*-*linux*)
 
535
+         powerpcle-*linux*)
 
536
+           LD="${LD-ld} -m elf64lppc"
 
537
+           ;;
 
538
+         powerpc-*linux*)
 
539
            LD="${LD-ld} -m elf64ppc"
 
540
            ;;
 
541
          s390*-*linux*|s390*-*tpf*)
 
542
@@ -10394,7 +10400,7 @@
 
543
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
544
   lt_status=$lt_dlunknown
 
545
   cat > conftest.$ac_ext <<_LT_EOF
 
546
-#line 10397 "configure"
 
547
+#line 10403 "configure"
 
548
 #include "confdefs.h"
 
549
 
 
550
 #if HAVE_DLFCN_H
 
551
@@ -10500,7 +10506,7 @@
 
552
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
553
   lt_status=$lt_dlunknown
 
554
   cat > conftest.$ac_ext <<_LT_EOF
 
555
-#line 10503 "configure"
 
556
+#line 10509 "configure"
 
557
 #include "confdefs.h"
 
558
 
 
559
 #if HAVE_DLFCN_H
 
560
--- a/src/libstdc++-v3/configure
 
561
+++ b/src/libstdc++-v3/configure
 
562
@@ -7111,7 +7111,7 @@
 
563
   rm -rf conftest*
 
564
   ;;
 
565
 
 
566
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
567
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
568
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
569
   # Find out which ABI we are using.
 
570
   echo 'int i;' > conftest.$ac_ext
 
571
@@ -7136,7 +7136,10 @@
 
572
                ;;
 
573
            esac
 
574
            ;;
 
575
-         ppc64-*linux*|powerpc64-*linux*)
 
576
+         powerpc64le-*linux*)
 
577
+           LD="${LD-ld} -m elf32lppclinux"
 
578
+           ;;
 
579
+         powerpc64-*linux*)
 
580
            LD="${LD-ld} -m elf32ppclinux"
 
581
            ;;
 
582
          s390x-*linux*)
 
583
@@ -7155,7 +7158,10 @@
 
584
          x86_64-*linux*)
 
585
            LD="${LD-ld} -m elf_x86_64"
 
586
            ;;
 
587
-         ppc*-*linux*|powerpc*-*linux*)
 
588
+         powerpcle-*linux*)
 
589
+           LD="${LD-ld} -m elf64lppc"
 
590
+           ;;
 
591
+         powerpc-*linux*)
 
592
            LD="${LD-ld} -m elf64ppc"
 
593
            ;;
 
594
          s390*-*linux*|s390*-*tpf*)
 
595
@@ -11513,7 +11519,7 @@
 
596
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
597
   lt_status=$lt_dlunknown
 
598
   cat > conftest.$ac_ext <<_LT_EOF
 
599
-#line 11516 "configure"
 
600
+#line 11522 "configure"
 
601
 #include "confdefs.h"
 
602
 
 
603
 #if HAVE_DLFCN_H
 
604
@@ -11619,7 +11625,7 @@
 
605
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
606
   lt_status=$lt_dlunknown
 
607
   cat > conftest.$ac_ext <<_LT_EOF
 
608
-#line 11622 "configure"
 
609
+#line 11628 "configure"
 
610
 #include "confdefs.h"
 
611
 
 
612
 #if HAVE_DLFCN_H
 
613
@@ -15033,7 +15039,7 @@
 
614
     #
 
615
     # Fake what AC_TRY_COMPILE does.  XXX Look at redoing this new-style.
 
616
     cat > conftest.$ac_ext << EOF
 
617
-#line 15036 "configure"
 
618
+#line 15042 "configure"
 
619
 struct S { ~S(); };
 
620
 void bar();
 
621
 void foo()
 
622
@@ -15383,7 +15389,7 @@
 
623
   # Fake what AC_TRY_COMPILE does.
 
624
 
 
625
     cat > conftest.$ac_ext << EOF
 
626
-#line 15386 "configure"
 
627
+#line 15392 "configure"
 
628
 int main()
 
629
 {
 
630
   typedef bool atomic_type;
 
631
@@ -15418,7 +15424,7 @@
 
632
     rm -f conftest*
 
633
 
 
634
     cat > conftest.$ac_ext << EOF
 
635
-#line 15421 "configure"
 
636
+#line 15427 "configure"
 
637
 int main()
 
638
 {
 
639
   typedef short atomic_type;
 
640
@@ -15453,7 +15459,7 @@
 
641
     rm -f conftest*
 
642
 
 
643
     cat > conftest.$ac_ext << EOF
 
644
-#line 15456 "configure"
 
645
+#line 15462 "configure"
 
646
 int main()
 
647
 {
 
648
   // NB: _Atomic_word not necessarily int.
 
649
@@ -15489,7 +15495,7 @@
 
650
     rm -f conftest*
 
651
 
 
652
     cat > conftest.$ac_ext << EOF
 
653
-#line 15492 "configure"
 
654
+#line 15498 "configure"
 
655
 int main()
 
656
 {
 
657
   typedef long long atomic_type;
 
658
@@ -15568,7 +15574,7 @@
 
659
   # unnecessary for this test.
 
660
 
 
661
     cat > conftest.$ac_ext << EOF
 
662
-#line 15571 "configure"
 
663
+#line 15577 "configure"
 
664
 int main()
 
665
 {
 
666
   _Decimal32 d1;
 
667
@@ -15610,7 +15616,7 @@
 
668
   # unnecessary for this test.
 
669
 
 
670
     cat > conftest.$ac_ext << EOF
 
671
-#line 15613 "configure"
 
672
+#line 15619 "configure"
 
673
 template<typename T1, typename T2>
 
674
   struct same
 
675
   { typedef T2 type; };
 
676
@@ -15644,7 +15650,7 @@
 
677
     rm -f conftest*
 
678
 
 
679
     cat > conftest.$ac_ext << EOF
 
680
-#line 15647 "configure"
 
681
+#line 15653 "configure"
 
682
 template<typename T1, typename T2>
 
683
   struct same
 
684
   { typedef T2 type; };
 
685
--- a/src/libstdc++-v3/scripts/extract_symvers.in
 
686
+++ b/src/libstdc++-v3/scripts/extract_symvers.in
 
687
@@ -53,6 +53,7 @@
 
688
   # present on Solaris.
 
689
   ${readelf} ${lib} |\
 
690
   sed -e 's/ \[<other>: [A-Fa-f0-9]*\] //' -e '/\.dynsym/,/^$/p;d' |\
 
691
+  sed -e 's/ \[<localentry>: [0-9]*\] //' |\
 
692
   egrep -v ' (LOCAL|UND) ' |\
 
693
   egrep -v ' (_DYNAMIC|_GLOBAL_OFFSET_TABLE_|_PROCEDURE_LINKAGE_TABLE_|_edata|_end|_etext)$' |\
 
694
   sed -e 's/ <processor specific>: / <processor_specific>:_/g' |\
 
695
--- a/src/libstdc++-v3/ChangeLog.ibm
 
696
+++ b/src/libstdc++-v3/ChangeLog.ibm
 
697
@@ -0,0 +1,19 @@
 
698
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
699
+
 
700
+       Backport from mainline r204808:
 
701
+
 
702
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
703
+
 
704
+       * scripts/extract_symvers.in: Ignore <localentry: > fields
 
705
+       in readelf --symbols output.
 
706
+
 
707
+2013-08-04  Peter Bergner  <bergner@vnet.ibm.com>
 
708
+
 
709
+        Backport from mainline
 
710
+       2013-08-01  Fabien Chêne  <fabien@gcc.gnu.org>
 
711
+
 
712
+       PR c++/54537
 
713
+       * include/tr1/cmath: Remove pow(double,double) overload, remove a
 
714
+       duplicated comment about DR 550. Add a comment to explain the issue.
 
715
+       * testsuite/tr1/8_c_compatibility/cmath/pow_cmath.cc: New.
 
716
+
 
717
--- a/src/libstdc++-v3/include/tr1/cmath
 
718
+++ b/src/libstdc++-v3/include/tr1/cmath
 
719
@@ -846,10 +846,6 @@
 
720
     nexttoward(_Tp __x, long double __y)
 
721
     { return __builtin_nexttoward(__x, __y); }
 
722
 
 
723
-  // DR 550. What should the return type of pow(float,int) be?
 
724
-  // NB: C++0x and TR1 != C++03.
 
725
-  //   using std::pow;
 
726
-
 
727
   inline float
 
728
   remainder(float __x, float __y)
 
729
   { return __builtin_remainderf(__x, __y); }
 
730
@@ -985,10 +981,19 @@
 
731
 
 
732
   // DR 550. What should the return type of pow(float,int) be?
 
733
   // NB: C++0x and TR1 != C++03.
 
734
-  inline double
 
735
-  pow(double __x, double __y)
 
736
-  { return std::pow(__x, __y); }
 
737
 
 
738
+  // The std::tr1::pow(double, double) overload cannot be provided
 
739
+  // here, because it would clash with ::pow(double,double) declared
 
740
+  // in <math.h>, if <tr1/math.h> is included at the same time (raised
 
741
+  // by the fix of PR c++/54537). It is not possible either to use the
 
742
+  // using-declaration 'using ::pow;' here, because if the user code
 
743
+  // has a 'using std::pow;', it would bring the pow(*,int) averloads
 
744
+  // in the tr1 namespace, which is undesirable. Consequently, the
 
745
+  // solution is to forward std::tr1::pow(double,double) to
 
746
+  // std::pow(double,double) via the templatized version below. See
 
747
+  // the discussion about this issue here:
 
748
+  // http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01278.html
 
749
+
 
750
   inline float
 
751
   pow(float __x, float __y)
 
752
   { return std::pow(__x, __y); }
 
753
--- a/src/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/pow_cmath.cc
 
754
+++ b/src/libstdc++-v3/testsuite/tr1/8_c_compatibility/cmath/pow_cmath.cc
 
755
@@ -0,0 +1,33 @@
 
756
+// { dg-do compile }
 
757
+
 
758
+// Copyright (C) 2013 Free Software Foundation, Inc.
 
759
+//
 
760
+// This file is part of the GNU ISO C++ Library.  This library is free
 
761
+// software; you can redistribute it and/or modify it under the
 
762
+// terms of the GNU General Public License as published by the
 
763
+// Free Software Foundation; either version 3, or (at your option)
 
764
+// any later version.
 
765
+
 
766
+// This library is distributed in the hope that it will be useful,
 
767
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
768
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
769
+// GNU General Public License for more details.
 
770
+
 
771
+// You should have received a copy of the GNU General Public License along
 
772
+// with this library; see the file COPYING3.  If not see
 
773
+// <http://www.gnu.org/licenses/>.
 
774
+
 
775
+#include <cmath>
 
776
+using std::pow;
 
777
+#include <tr1/cmath>
 
778
+#include <testsuite_tr1.h>
 
779
+
 
780
+void 
 
781
+test01()
 
782
+{
 
783
+  using namespace __gnu_test;
 
784
+
 
785
+  float x = 2080703.375F;
 
786
+  check_ret_type<float>(std::pow(x, 2));
 
787
+  check_ret_type<double>(std::tr1::pow(x, 2));
 
788
+}
 
789
--- a/src/libmudflap/configure
 
790
+++ b/src/libmudflap/configure
 
791
@@ -6377,7 +6377,7 @@
 
792
   rm -rf conftest*
 
793
   ;;
 
794
 
 
795
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
796
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
797
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
798
   # Find out which ABI we are using.
 
799
   echo 'int i;' > conftest.$ac_ext
 
800
@@ -6402,7 +6402,10 @@
 
801
                ;;
 
802
            esac
 
803
            ;;
 
804
-         ppc64-*linux*|powerpc64-*linux*)
 
805
+         powerpc64le-*linux*)
 
806
+           LD="${LD-ld} -m elf32lppclinux"
 
807
+           ;;
 
808
+         powerpc64-*linux*)
 
809
            LD="${LD-ld} -m elf32ppclinux"
 
810
            ;;
 
811
          s390x-*linux*)
 
812
@@ -6421,7 +6424,10 @@
 
813
          x86_64-*linux*)
 
814
            LD="${LD-ld} -m elf_x86_64"
 
815
            ;;
 
816
-         ppc*-*linux*|powerpc*-*linux*)
 
817
+         powerpcle-*linux*)
 
818
+           LD="${LD-ld} -m elf64lppc"
 
819
+           ;;
 
820
+         powerpc-*linux*)
 
821
            LD="${LD-ld} -m elf64ppc"
 
822
            ;;
 
823
          s390*-*linux*|s390*-*tpf*)
 
824
@@ -10615,7 +10621,7 @@
 
825
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
826
   lt_status=$lt_dlunknown
 
827
   cat > conftest.$ac_ext <<_LT_EOF
 
828
-#line 10618 "configure"
 
829
+#line 10624 "configure"
 
830
 #include "confdefs.h"
 
831
 
 
832
 #if HAVE_DLFCN_H
 
833
@@ -10721,7 +10727,7 @@
 
834
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
835
   lt_status=$lt_dlunknown
 
836
   cat > conftest.$ac_ext <<_LT_EOF
 
837
-#line 10724 "configure"
 
838
+#line 10730 "configure"
 
839
 #include "confdefs.h"
 
840
 
 
841
 #if HAVE_DLFCN_H
 
842
--- a/src/boehm-gc/configure
 
843
+++ b/src/boehm-gc/configure
 
844
@@ -6770,7 +6770,7 @@
 
845
   rm -rf conftest*
 
846
   ;;
 
847
 
 
848
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
849
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
850
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
851
   # Find out which ABI we are using.
 
852
   echo 'int i;' > conftest.$ac_ext
 
853
@@ -6795,7 +6795,10 @@
 
854
                ;;
 
855
            esac
 
856
            ;;
 
857
-         ppc64-*linux*|powerpc64-*linux*)
 
858
+         powerpc64le-*linux*)
 
859
+           LD="${LD-ld} -m elf32lppclinux"
 
860
+           ;;
 
861
+         powerpc64-*linux*)
 
862
            LD="${LD-ld} -m elf32ppclinux"
 
863
            ;;
 
864
          s390x-*linux*)
 
865
@@ -6814,7 +6817,10 @@
 
866
          x86_64-*linux*)
 
867
            LD="${LD-ld} -m elf_x86_64"
 
868
            ;;
 
869
-         ppc*-*linux*|powerpc*-*linux*)
 
870
+         powerpcle-*linux*)
 
871
+           LD="${LD-ld} -m elf64lppc"
 
872
+           ;;
 
873
+         powerpc-*linux*)
 
874
            LD="${LD-ld} -m elf64ppc"
 
875
            ;;
 
876
          s390*-*linux*|s390*-*tpf*)
 
877
@@ -11312,7 +11318,7 @@
 
878
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
879
   lt_status=$lt_dlunknown
 
880
   cat > conftest.$ac_ext <<_LT_EOF
 
881
-#line 11315 "configure"
 
882
+#line 11321 "configure"
 
883
 #include "confdefs.h"
 
884
 
 
885
 #if HAVE_DLFCN_H
 
886
@@ -11418,7 +11424,7 @@
 
887
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
888
   lt_status=$lt_dlunknown
 
889
   cat > conftest.$ac_ext <<_LT_EOF
 
890
-#line 11421 "configure"
 
891
+#line 11427 "configure"
 
892
 #include "confdefs.h"
 
893
 
 
894
 #if HAVE_DLFCN_H
 
895
--- a/src/lto-plugin/configure
 
896
+++ b/src/lto-plugin/configure
 
897
@@ -6044,7 +6044,7 @@
 
898
   rm -rf conftest*
 
899
   ;;
 
900
 
 
901
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
902
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
903
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
904
   # Find out which ABI we are using.
 
905
   echo 'int i;' > conftest.$ac_ext
 
906
@@ -6069,7 +6069,10 @@
 
907
                ;;
 
908
            esac
 
909
            ;;
 
910
-         ppc64-*linux*|powerpc64-*linux*)
 
911
+         powerpc64le-*linux*)
 
912
+           LD="${LD-ld} -m elf32lppclinux"
 
913
+           ;;
 
914
+         powerpc64-*linux*)
 
915
            LD="${LD-ld} -m elf32ppclinux"
 
916
            ;;
 
917
          s390x-*linux*)
 
918
@@ -6088,7 +6091,10 @@
 
919
          x86_64-*linux*)
 
920
            LD="${LD-ld} -m elf_x86_64"
 
921
            ;;
 
922
-         ppc*-*linux*|powerpc*-*linux*)
 
923
+         powerpcle-*linux*)
 
924
+           LD="${LD-ld} -m elf64lppc"
 
925
+           ;;
 
926
+         powerpc-*linux*)
 
927
            LD="${LD-ld} -m elf64ppc"
 
928
            ;;
 
929
          s390*-*linux*|s390*-*tpf*)
 
930
@@ -10552,7 +10558,7 @@
 
931
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
932
   lt_status=$lt_dlunknown
 
933
   cat > conftest.$ac_ext <<_LT_EOF
 
934
-#line 10555 "configure"
 
935
+#line 10561 "configure"
 
936
 #include "confdefs.h"
 
937
 
 
938
 #if HAVE_DLFCN_H
 
939
@@ -10658,7 +10664,7 @@
 
940
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
941
   lt_status=$lt_dlunknown
 
942
   cat > conftest.$ac_ext <<_LT_EOF
 
943
-#line 10661 "configure"
 
944
+#line 10667 "configure"
 
945
 #include "confdefs.h"
 
946
 
 
947
 #if HAVE_DLFCN_H
 
948
--- a/src/libatomic/configure
 
949
+++ b/src/libatomic/configure
 
950
@@ -6505,7 +6505,7 @@
 
951
   rm -rf conftest*
 
952
   ;;
 
953
 
 
954
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
955
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
956
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
957
   # Find out which ABI we are using.
 
958
   echo 'int i;' > conftest.$ac_ext
 
959
@@ -6530,7 +6530,10 @@
 
960
                ;;
 
961
            esac
 
962
            ;;
 
963
-         ppc64-*linux*|powerpc64-*linux*)
 
964
+         powerpc64le-*linux*)
 
965
+           LD="${LD-ld} -m elf32lppclinux"
 
966
+           ;;
 
967
+         powerpc64-*linux*)
 
968
            LD="${LD-ld} -m elf32ppclinux"
 
969
            ;;
 
970
          s390x-*linux*)
 
971
@@ -6549,7 +6552,10 @@
 
972
          x86_64-*linux*)
 
973
            LD="${LD-ld} -m elf_x86_64"
 
974
            ;;
 
975
-         ppc*-*linux*|powerpc*-*linux*)
 
976
+         powerpcle-*linux*)
 
977
+           LD="${LD-ld} -m elf64lppc"
 
978
+           ;;
 
979
+         powerpc-*linux*)
 
980
            LD="${LD-ld} -m elf64ppc"
 
981
            ;;
 
982
          s390*-*linux*|s390*-*tpf*)
 
983
@@ -11013,7 +11019,7 @@
 
984
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
985
   lt_status=$lt_dlunknown
 
986
   cat > conftest.$ac_ext <<_LT_EOF
 
987
-#line 11016 "configure"
 
988
+#line 11022 "configure"
 
989
 #include "confdefs.h"
 
990
 
 
991
 #if HAVE_DLFCN_H
 
992
@@ -11119,7 +11125,7 @@
 
993
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
994
   lt_status=$lt_dlunknown
 
995
   cat > conftest.$ac_ext <<_LT_EOF
 
996
-#line 11122 "configure"
 
997
+#line 11128 "configure"
 
998
 #include "confdefs.h"
 
999
 
 
1000
 #if HAVE_DLFCN_H
 
1001
--- a/src/libbacktrace/configure
 
1002
+++ b/src/libbacktrace/configure
 
1003
@@ -6842,7 +6842,7 @@
 
1004
   rm -rf conftest*
 
1005
   ;;
 
1006
 
 
1007
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
1008
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
1009
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
1010
   # Find out which ABI we are using.
 
1011
   echo 'int i;' > conftest.$ac_ext
 
1012
@@ -6867,7 +6867,10 @@
 
1013
                ;;
 
1014
            esac
 
1015
            ;;
 
1016
-         ppc64-*linux*|powerpc64-*linux*)
 
1017
+         powerpc64le-*linux*)
 
1018
+           LD="${LD-ld} -m elf32lppclinux"
 
1019
+           ;;
 
1020
+         powerpc64-*linux*)
 
1021
            LD="${LD-ld} -m elf32ppclinux"
 
1022
            ;;
 
1023
          s390x-*linux*)
 
1024
@@ -6886,7 +6889,10 @@
 
1025
          x86_64-*linux*)
 
1026
            LD="${LD-ld} -m elf_x86_64"
 
1027
            ;;
 
1028
-         ppc*-*linux*|powerpc*-*linux*)
 
1029
+         powerpcle-*linux*)
 
1030
+           LD="${LD-ld} -m elf64lppc"
 
1031
+           ;;
 
1032
+         powerpc-*linux*)
 
1033
            LD="${LD-ld} -m elf64ppc"
 
1034
            ;;
 
1035
          s390*-*linux*|s390*-*tpf*)
 
1036
@@ -11081,7 +11087,7 @@
 
1037
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
1038
   lt_status=$lt_dlunknown
 
1039
   cat > conftest.$ac_ext <<_LT_EOF
 
1040
-#line 11084 "configure"
 
1041
+#line 11090 "configure"
 
1042
 #include "confdefs.h"
 
1043
 
 
1044
 #if HAVE_DLFCN_H
 
1045
@@ -11187,7 +11193,7 @@
 
1046
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
1047
   lt_status=$lt_dlunknown
 
1048
   cat > conftest.$ac_ext <<_LT_EOF
 
1049
-#line 11190 "configure"
 
1050
+#line 11196 "configure"
 
1051
 #include "confdefs.h"
 
1052
 
 
1053
 #if HAVE_DLFCN_H
 
1054
--- a/src/libjava/libltdl/configure
 
1055
+++ b/src/libjava/libltdl/configure
 
1056
@@ -4806,7 +4806,7 @@
 
1057
   rm -rf conftest*
 
1058
   ;;
 
1059
 
 
1060
-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
 
1061
+x86_64-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
 
1062
   # Find out which ABI we are using.
 
1063
   echo 'int i;' > conftest.$ac_ext
 
1064
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
 
1065
@@ -4820,7 +4820,10 @@
 
1066
         x86_64-*linux*)
 
1067
           LD="${LD-ld} -m elf_i386"
 
1068
           ;;
 
1069
-        ppc64-*linux*|powerpc64-*linux*)
 
1070
+        powerpc64le-*linux*)
 
1071
+          LD="${LD-ld} -m elf32lppclinux"
 
1072
+          ;;
 
1073
+        powerpc64-*linux*)
 
1074
           LD="${LD-ld} -m elf32ppclinux"
 
1075
           ;;
 
1076
         s390x-*linux*)
 
1077
@@ -4836,7 +4839,10 @@
 
1078
         x86_64-*linux*)
 
1079
           LD="${LD-ld} -m elf_x86_64"
 
1080
           ;;
 
1081
-        ppc*-*linux*|powerpc*-*linux*)
 
1082
+        powerpcle-*linux*)
 
1083
+          LD="${LD-ld} -m elf64lppc"
 
1084
+          ;;
 
1085
+        powerpc-*linux*)
 
1086
           LD="${LD-ld} -m elf64ppc"
 
1087
           ;;
 
1088
         s390*-*linux*)
 
1089
@@ -6456,11 +6462,11 @@
 
1090
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
 
1091
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
 
1092
    -e 's:$: $lt_compiler_flag:'`
 
1093
-   (eval echo "\"\$as_me:6459: $lt_compile\"" >&5)
 
1094
+   (eval echo "\"\$as_me:6465: $lt_compile\"" >&5)
 
1095
    (eval "$lt_compile" 2>conftest.err)
 
1096
    ac_status=$?
 
1097
    cat conftest.err >&5
 
1098
-   echo "$as_me:6463: \$? = $ac_status" >&5
 
1099
+   echo "$as_me:6469: \$? = $ac_status" >&5
 
1100
    if (exit $ac_status) && test -s "$ac_outfile"; then
 
1101
      # The compiler can only warn and ignore the option if not recognized
 
1102
      # So say no if there are warnings other than the usual output.
 
1103
@@ -6718,11 +6724,11 @@
 
1104
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
 
1105
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
 
1106
    -e 's:$: $lt_compiler_flag:'`
 
1107
-   (eval echo "\"\$as_me:6721: $lt_compile\"" >&5)
 
1108
+   (eval echo "\"\$as_me:6727: $lt_compile\"" >&5)
 
1109
    (eval "$lt_compile" 2>conftest.err)
 
1110
    ac_status=$?
 
1111
    cat conftest.err >&5
 
1112
-   echo "$as_me:6725: \$? = $ac_status" >&5
 
1113
+   echo "$as_me:6731: \$? = $ac_status" >&5
 
1114
    if (exit $ac_status) && test -s "$ac_outfile"; then
 
1115
      # The compiler can only warn and ignore the option if not recognized
 
1116
      # So say no if there are warnings other than the usual output.
 
1117
@@ -6780,11 +6786,11 @@
 
1118
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
 
1119
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
 
1120
    -e 's:$: $lt_compiler_flag:'`
 
1121
-   (eval echo "\"\$as_me:6783: $lt_compile\"" >&5)
 
1122
+   (eval echo "\"\$as_me:6789: $lt_compile\"" >&5)
 
1123
    (eval "$lt_compile" 2>out/conftest.err)
 
1124
    ac_status=$?
 
1125
    cat out/conftest.err >&5
 
1126
-   echo "$as_me:6787: \$? = $ac_status" >&5
 
1127
+   echo "$as_me:6793: \$? = $ac_status" >&5
 
1128
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
 
1129
    then
 
1130
      # The compiler can only warn and ignore the option if not recognized
 
1131
@@ -8099,7 +8105,7 @@
 
1132
   libsuff=
 
1133
   case "$host_cpu" in
 
1134
   x86_64*|s390x*|powerpc64*)
 
1135
-    echo '#line 8102 "configure"' > conftest.$ac_ext
 
1136
+    echo '#line 8108 "configure"' > conftest.$ac_ext
 
1137
     if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
 
1138
   (eval $ac_compile) 2>&5
 
1139
   ac_status=$?
 
1140
@@ -8652,7 +8658,7 @@
 
1141
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
1142
   lt_status=$lt_dlunknown
 
1143
   cat > conftest.$ac_ext <<EOF
 
1144
-#line 8655 "configure"
 
1145
+#line 8661 "configure"
 
1146
 #include "confdefs.h"
 
1147
 
 
1148
 #if HAVE_DLFCN_H
 
1149
@@ -8750,7 +8756,7 @@
 
1150
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
1151
   lt_status=$lt_dlunknown
 
1152
   cat > conftest.$ac_ext <<EOF
 
1153
-#line 8753 "configure"
 
1154
+#line 8759 "configure"
 
1155
 #include "confdefs.h"
 
1156
 
 
1157
 #if HAVE_DLFCN_H
 
1158
@@ -10591,7 +10597,7 @@
 
1159
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
1160
   lt_status=$lt_dlunknown
 
1161
   cat > conftest.$ac_ext <<EOF
 
1162
-#line 10594 "configure"
 
1163
+#line 10600 "configure"
 
1164
 #include "confdefs.h"
 
1165
 
 
1166
 #if HAVE_DLFCN_H
 
1167
--- a/src/libjava/libltdl/acinclude.m4
 
1168
+++ b/src/libjava/libltdl/acinclude.m4
 
1169
@@ -519,7 +519,7 @@
 
1170
   rm -rf conftest*
 
1171
   ;;
 
1172
 
 
1173
-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
 
1174
+x86_64-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
 
1175
   # Find out which ABI we are using.
 
1176
   echo 'int i;' > conftest.$ac_ext
 
1177
   if AC_TRY_EVAL(ac_compile); then
 
1178
@@ -529,7 +529,10 @@
 
1179
         x86_64-*linux*)
 
1180
           LD="${LD-ld} -m elf_i386"
 
1181
           ;;
 
1182
-        ppc64-*linux*|powerpc64-*linux*)
 
1183
+        powerpc64le-*linux*)
 
1184
+          LD="${LD-ld} -m elf32lppclinux"
 
1185
+          ;;
 
1186
+        powerpc64-*linux*)
 
1187
           LD="${LD-ld} -m elf32ppclinux"
 
1188
           ;;
 
1189
         s390x-*linux*)
 
1190
@@ -545,7 +548,10 @@
 
1191
         x86_64-*linux*)
 
1192
           LD="${LD-ld} -m elf_x86_64"
 
1193
           ;;
 
1194
-        ppc*-*linux*|powerpc*-*linux*)
 
1195
+        powerpcle-*linux*)
 
1196
+          LD="${LD-ld} -m elf64lppc"
 
1197
+          ;;
 
1198
+        powerpc-*linux*)
 
1199
           LD="${LD-ld} -m elf64ppc"
 
1200
           ;;
 
1201
         s390*-*linux*)
 
1202
--- a/src/libjava/classpath/configure
 
1203
+++ b/src/libjava/classpath/configure
 
1204
@@ -7577,7 +7577,7 @@
 
1205
   rm -rf conftest*
 
1206
   ;;
 
1207
 
 
1208
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
1209
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
1210
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
1211
   # Find out which ABI we are using.
 
1212
   echo 'int i;' > conftest.$ac_ext
 
1213
@@ -7602,7 +7602,10 @@
 
1214
                ;;
 
1215
            esac
 
1216
            ;;
 
1217
-         ppc64-*linux*|powerpc64-*linux*)
 
1218
+         powerpc64le-*linux*)
 
1219
+           LD="${LD-ld} -m elf32lppclinux"
 
1220
+           ;;
 
1221
+         powerpc64-*linux*)
 
1222
            LD="${LD-ld} -m elf32ppclinux"
 
1223
            ;;
 
1224
          s390x-*linux*)
 
1225
@@ -7621,7 +7624,10 @@
 
1226
          x86_64-*linux*)
 
1227
            LD="${LD-ld} -m elf_x86_64"
 
1228
            ;;
 
1229
-         ppc*-*linux*|powerpc*-*linux*)
 
1230
+         powerpcle-*linux*)
 
1231
+           LD="${LD-ld} -m elf64lppc"
 
1232
+           ;;
 
1233
+         powerpc-*linux*)
 
1234
            LD="${LD-ld} -m elf64ppc"
 
1235
            ;;
 
1236
          s390*-*linux*|s390*-*tpf*)
 
1237
@@ -11820,7 +11826,7 @@
 
1238
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
1239
   lt_status=$lt_dlunknown
 
1240
   cat > conftest.$ac_ext <<_LT_EOF
 
1241
-#line 11823 "configure"
 
1242
+#line 11829 "configure"
 
1243
 #include "confdefs.h"
 
1244
 
 
1245
 #if HAVE_DLFCN_H
 
1246
@@ -11926,7 +11932,7 @@
 
1247
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
1248
   lt_status=$lt_dlunknown
 
1249
   cat > conftest.$ac_ext <<_LT_EOF
 
1250
-#line 11929 "configure"
 
1251
+#line 11935 "configure"
 
1252
 #include "confdefs.h"
 
1253
 
 
1254
 #if HAVE_DLFCN_H
 
1255
@@ -25300,7 +25306,7 @@
 
1256
 JAVA_TEST=Object.java
 
1257
 CLASS_TEST=Object.class
 
1258
 cat << \EOF > $JAVA_TEST
 
1259
-/* #line 25303 "configure" */
 
1260
+/* #line 25309 "configure" */
 
1261
 package java.lang;
 
1262
 
 
1263
 public class Object
 
1264
@@ -25393,7 +25399,7 @@
 
1265
 if uudecode$EXEEXT Test.uue; then
 
1266
         ac_cv_prog_uudecode_base64=yes
 
1267
 else
 
1268
-        echo "configure: 25396: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
 
1269
+        echo "configure: 25402: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
 
1270
         echo "configure: failed file was:" >&5
 
1271
         cat Test.uue >&5
 
1272
         ac_cv_prog_uudecode_base64=no
 
1273
@@ -25421,7 +25427,7 @@
 
1274
 CLASS_TEST=Test.class
 
1275
 TEST=Test
 
1276
 cat << \EOF > $JAVA_TEST
 
1277
-/* [#]line 25424 "configure" */
 
1278
+/* [#]line 25430 "configure" */
 
1279
 public class Test {
 
1280
 public static void main (String args[]) {
 
1281
         System.exit (0);
 
1282
@@ -25629,7 +25635,7 @@
 
1283
   JAVA_TEST=Test.java
 
1284
   CLASS_TEST=Test.class
 
1285
   cat << \EOF > $JAVA_TEST
 
1286
-  /* #line 25632 "configure" */
 
1287
+  /* #line 25638 "configure" */
 
1288
   public class Test
 
1289
   {
 
1290
     public static void main(String args)
 
1291
--- a/src/libjava/configure
 
1292
+++ b/src/libjava/configure
 
1293
@@ -8842,7 +8842,7 @@
 
1294
   rm -rf conftest*
 
1295
   ;;
 
1296
 
 
1297
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
1298
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
1299
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
1300
   # Find out which ABI we are using.
 
1301
   echo 'int i;' > conftest.$ac_ext
 
1302
@@ -8867,7 +8867,10 @@
 
1303
                ;;
 
1304
            esac
 
1305
            ;;
 
1306
-         ppc64-*linux*|powerpc64-*linux*)
 
1307
+         powerpc64le-*linux*)
 
1308
+           LD="${LD-ld} -m elf32lppclinux"
 
1309
+           ;;
 
1310
+         powerpc64-*linux*)
 
1311
            LD="${LD-ld} -m elf32ppclinux"
 
1312
            ;;
 
1313
          s390x-*linux*)
 
1314
@@ -8886,7 +8889,10 @@
 
1315
          x86_64-*linux*)
 
1316
            LD="${LD-ld} -m elf_x86_64"
 
1317
            ;;
 
1318
-         ppc*-*linux*|powerpc*-*linux*)
 
1319
+         powerpcle-*linux*)
 
1320
+           LD="${LD-ld} -m elf64lppc"
 
1321
+           ;;
 
1322
+         powerpc-*linux*)
 
1323
            LD="${LD-ld} -m elf64ppc"
 
1324
            ;;
 
1325
          s390*-*linux*|s390*-*tpf*)
 
1326
@@ -13382,7 +13388,7 @@
 
1327
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
1328
   lt_status=$lt_dlunknown
 
1329
   cat > conftest.$ac_ext <<_LT_EOF
 
1330
-#line 13385 "configure"
 
1331
+#line 13391 "configure"
 
1332
 #include "confdefs.h"
 
1333
 
 
1334
 #if HAVE_DLFCN_H
 
1335
@@ -13488,7 +13494,7 @@
 
1336
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
1337
   lt_status=$lt_dlunknown
 
1338
   cat > conftest.$ac_ext <<_LT_EOF
 
1339
-#line 13491 "configure"
 
1340
+#line 13497 "configure"
 
1341
 #include "confdefs.h"
 
1342
 
 
1343
 #if HAVE_DLFCN_H
 
1344
@@ -19483,7 +19489,7 @@
 
1345
   enableval=$enable_sjlj_exceptions; :
 
1346
 else
 
1347
   cat > conftest.$ac_ext << EOF
 
1348
-#line 19486 "configure"
 
1349
+#line 19492 "configure"
 
1350
 struct S { ~S(); };
 
1351
 void bar();
 
1352
 void foo()
 
1353
--- a/src/libgcc/config/rs6000/tramp.S
 
1354
+++ b/src/libgcc/config/rs6000/tramp.S
 
1355
@@ -116,4 +116,70 @@
 
1356
 
 
1357
 #endif
 
1358
 
 
1359
+#elif _CALL_ELF == 2
 
1360
+       .type   trampoline_initial,@object
 
1361
+       .align  3
 
1362
+trampoline_initial:
 
1363
+       ld      r11,.Lchain(r12)
 
1364
+       ld      r12,.Lfunc(r12)
 
1365
+       mtctr   r12
 
1366
+       bctr
 
1367
+.Lfunc = .-trampoline_initial
 
1368
+       .quad   0                       /* will be replaced with function address */
 
1369
+.Lchain = .-trampoline_initial
 
1370
+       .quad   0                       /* will be replaced with static chain */
 
1371
+
 
1372
+trampoline_size = .-trampoline_initial
 
1373
+       .size   trampoline_initial,trampoline_size
 
1374
+
 
1375
+
 
1376
+/* R3 = stack address to store trampoline */
 
1377
+/* R4 = length of trampoline area */
 
1378
+/* R5 = function address */
 
1379
+/* R6 = static chain */
 
1380
+
 
1381
+       .pushsection ".toc","aw"
 
1382
+.LC0:
 
1383
+       .quad   trampoline_initial-8
 
1384
+       .popsection
 
1385
+
 
1386
+FUNC_START(__trampoline_setup)
 
1387
+       addis 7,2,.LC0@toc@ha
 
1388
+       ld 7,.LC0@toc@l(7)      /* trampoline address -8 */
 
1389
+
 
1390
+       li      r8,trampoline_size      /* verify that the trampoline is big enough */
 
1391
+       cmpw    cr1,r8,r4
 
1392
+       srwi    r4,r4,3         /* # doublewords to move */
 
1393
+       addi    r9,r3,-8        /* adjust pointer for stdu */
 
1394
+       mtctr   r4
 
1395
+       blt     cr1,.Labort
 
1396
+
 
1397
+       /* Copy the instructions to the stack */
 
1398
+.Lmove:
 
1399
+       ldu     r10,8(r7)
 
1400
+       stdu    r10,8(r9)
 
1401
+       bdnz    .Lmove
 
1402
+
 
1403
+       /* Store correct function and static chain */
 
1404
+       std     r5,.Lfunc(r3)
 
1405
+       std     r6,.Lchain(r3)
 
1406
+
 
1407
+       /* Now flush both caches */
 
1408
+       mtctr   r4
 
1409
+.Lcache:
 
1410
+       icbi    0,r3
 
1411
+       dcbf    0,r3
 
1412
+       addi    r3,r3,8
 
1413
+       bdnz    .Lcache
 
1414
+
 
1415
+       /* Finally synchronize things & return */
 
1416
+       sync
 
1417
+       isync
 
1418
+       blr
 
1419
+
 
1420
+.Labort:
 
1421
+       bl      JUMP_TARGET(abort)
 
1422
+       nop
 
1423
+FUNC_END(__trampoline_setup)
 
1424
+
 
1425
 #endif
 
1426
--- a/src/libgcc/config/rs6000/linux-unwind.h
 
1427
+++ b/src/libgcc/config/rs6000/linux-unwind.h
 
1428
@@ -24,9 +24,19 @@
 
1429
 
 
1430
 #define R_LR           65
 
1431
 #define R_CR2          70
 
1432
+#define R_CR3          71
 
1433
+#define R_CR4          72
 
1434
 #define R_VR0          77
 
1435
 #define R_VRSAVE       109
 
1436
 
 
1437
+#ifdef __powerpc64__
 
1438
+#if _CALL_ELF == 2
 
1439
+#define TOC_SAVE_SLOT  24
 
1440
+#else
 
1441
+#define TOC_SAVE_SLOT  40
 
1442
+#endif
 
1443
+#endif
 
1444
+
 
1445
 struct gcc_vregs
 
1446
 {
 
1447
   __attribute__ ((vector_size (16))) int vr[32];
 
1448
@@ -107,6 +117,8 @@
 
1449
     }
 
1450
   else if (pc[1] == 0x380000AC)
 
1451
     {
 
1452
+#if _CALL_ELF != 2
 
1453
+      /* These old kernel versions never supported ELFv2.  */
 
1454
       /* This works for 2.4 kernels, but not for 2.6 kernels with vdso
 
1455
         because pc isn't pointing into the stack.  Can be removed when
 
1456
         no one is running 2.4.19 or 2.4.20, the first two ppc64
 
1457
@@ -121,6 +133,7 @@
 
1458
       if ((long) frame24->puc != -21 * 8)
 
1459
        return frame24->puc->regs;
 
1460
       else
 
1461
+#endif
 
1462
        {
 
1463
          /* This works for 2.4.21 and later kernels.  */
 
1464
          struct rt_sigframe {
 
1465
@@ -185,6 +198,7 @@
 
1466
 {
 
1467
   struct gcc_regs *regs = get_regs (context);
 
1468
   struct gcc_vregs *vregs;
 
1469
+  long cr_offset;
 
1470
   long new_cfa;
 
1471
   int i;
 
1472
 
 
1473
@@ -206,11 +220,21 @@
 
1474
       fs->regs.reg[i].loc.offset = (long) &regs->gpr[i] - new_cfa;
 
1475
     }
 
1476
 
 
1477
+  /* The CR is saved in the low 32 bits of regs->ccr.  */
 
1478
+  cr_offset = (long) &regs->ccr - new_cfa;
 
1479
+#ifndef __LITTLE_ENDIAN__
 
1480
+  cr_offset += sizeof (long) - 4;
 
1481
+#endif
 
1482
+  /* In the ELFv1 ABI, CR2 stands in for the whole CR.  */
 
1483
   fs->regs.reg[R_CR2].how = REG_SAVED_OFFSET;
 
1484
-  /* CR? regs are always 32-bit and PPC is big-endian, so in 64-bit
 
1485
-     libgcc loc.offset needs to point to the low 32 bits of regs->ccr.  */
 
1486
-  fs->regs.reg[R_CR2].loc.offset = (long) &regs->ccr - new_cfa
 
1487
-                                  + sizeof (long) - 4;
 
1488
+  fs->regs.reg[R_CR2].loc.offset = cr_offset;
 
1489
+#if _CALL_ELF == 2
 
1490
+  /* In the ELFv2 ABI, every CR field has a separate CFI entry.  */
 
1491
+  fs->regs.reg[R_CR3].how = REG_SAVED_OFFSET;
 
1492
+  fs->regs.reg[R_CR3].loc.offset = cr_offset;
 
1493
+  fs->regs.reg[R_CR4].how = REG_SAVED_OFFSET;
 
1494
+  fs->regs.reg[R_CR4].loc.offset = cr_offset;
 
1495
+#endif
 
1496
 
 
1497
   fs->regs.reg[R_LR].how = REG_SAVED_OFFSET;
 
1498
   fs->regs.reg[R_LR].loc.offset = (long) &regs->link - new_cfa;
 
1499
@@ -294,9 +318,13 @@
 
1500
         figure out if it was saved.  The big problem here is that the
 
1501
         code that does the save/restore is generated by the linker, so
 
1502
         we have no good way to determine at compile time what to do.  */
 
1503
-      if (pc[0] == 0xF8410028
 
1504
+      if (pc[0] == 0xF8410000 + TOC_SAVE_SLOT
 
1505
+#if _CALL_ELF != 2
 
1506
+         /* The ELFv2 linker never generates the old PLT stub form.  */
 
1507
          || ((pc[0] & 0xFFFF0000) == 0x3D820000
 
1508
-             && pc[1] == 0xF8410028))
 
1509
+             && pc[1] == 0xF8410000 + TOC_SAVE_SLOT)
 
1510
+#endif
 
1511
+         )
 
1512
        {
 
1513
          /* We are in a plt call stub or r2 adjusting long branch stub,
 
1514
             before r2 has been saved.  Keep REG_UNSAVED.  */
 
1515
@@ -305,18 +333,21 @@
 
1516
        {
 
1517
          unsigned int *insn
 
1518
            = (unsigned int *) _Unwind_GetGR (context, R_LR);
 
1519
-         if (insn && *insn == 0xE8410028)
 
1520
-           _Unwind_SetGRPtr (context, 2, context->cfa + 40);
 
1521
+         if (insn && *insn == 0xE8410000 + TOC_SAVE_SLOT)
 
1522
+           _Unwind_SetGRPtr (context, 2, context->cfa + TOC_SAVE_SLOT);
 
1523
+#if _CALL_ELF != 2
 
1524
+         /* ELFv2 does not use this function pointer call sequence.  */
 
1525
          else if (pc[0] == 0x4E800421
 
1526
-                  && pc[1] == 0xE8410028)
 
1527
+                  && pc[1] == 0xE8410000 + TOC_SAVE_SLOT)
 
1528
            {
 
1529
              /* We are at the bctrl instruction in a call via function
 
1530
                 pointer.  gcc always emits the load of the new R2 just
 
1531
                 before the bctrl so this is the first and only place
 
1532
                 we need to use the stored R2.  */
 
1533
              _Unwind_Word sp = _Unwind_GetGR (context, 1);
 
1534
-             _Unwind_SetGRPtr (context, 2, (void *)(sp + 40));
 
1535
+             _Unwind_SetGRPtr (context, 2, (void *)(sp + TOC_SAVE_SLOT));
 
1536
            }
 
1537
+#endif
 
1538
        }
 
1539
     }
 
1540
 #endif
 
1541
--- a/src/libgcc/ChangeLog.ibm
 
1542
+++ b/src/libgcc/ChangeLog.ibm
 
1543
@@ -0,0 +1,38 @@
 
1544
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
1545
+
 
1546
+       Backport from mainline r204808:
 
1547
+
 
1548
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
1549
+                   Alan Modra  <amodra@gmail.com>
 
1550
+
 
1551
+       * config/rs6000/linux-unwind.h (TOC_SAVE_SLOT): Define.
 
1552
+       (frob_update_context): Use it.
 
1553
+
 
1554
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
1555
+                   Alan Modra  <amodra@gmail.com>
 
1556
+
 
1557
+       * config/rs6000/tramp.S [__powerpc64__ && _CALL_ELF == 2]:
 
1558
+       (trampoline_initial): Provide ELFv2 variant.
 
1559
+       (__trampoline_setup): Likewise.
 
1560
+
 
1561
+       * config/rs6000/linux-unwind.h (frob_update_context): Do not
 
1562
+       check for AIX indirect function call sequence if _CALL_ELF == 2.
 
1563
+
 
1564
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
1565
+                   Alan Modra  <amodra@gmail.com>
 
1566
+
 
1567
+       * config/rs6000/linux-unwind.h (get_regs): Do not support
 
1568
+       old kernel versions if _CALL_ELF == 2.
 
1569
+       (frob_update_context): Do not support PLT stub variants only
 
1570
+       generated by old linkers if _CALL_ELF == 2.
 
1571
+
 
1572
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
1573
+
 
1574
+       Backport from mainline r204800:
 
1575
+
 
1576
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
1577
+                   Alan Modra  <amodra@gmail.com>
 
1578
+
 
1579
+       * config/rs6000/linux-unwind.h (ppc_fallback_frame_state): Correct
 
1580
+       location of CR save area for 64-bit little-endian systems.
 
1581
+
 
1582
--- a/src/config.guess
 
1583
+++ b/src/config.guess
 
1584
@@ -1,10 +1,8 @@
 
1585
 #! /bin/sh
 
1586
 # Attempt to guess a canonical system name.
 
1587
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 
1588
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
 
1589
-#   2011, 2012, 2013 Free Software Foundation, Inc.
 
1590
+#   Copyright 1992-2013 Free Software Foundation, Inc.
 
1591
 
 
1592
-timestamp='2012-12-30'
 
1593
+timestamp='2013-06-10'
 
1594
 
 
1595
 # This file is free software; you can redistribute it and/or modify it
 
1596
 # under the terms of the GNU General Public License as published by
 
1597
@@ -52,9 +50,7 @@
 
1598
 GNU config.guess ($timestamp)
 
1599
 
 
1600
 Originally written by Per Bothner.
 
1601
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
 
1602
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
 
1603
-2012, 2013 Free Software Foundation, Inc.
 
1604
+Copyright 1992-2013 Free Software Foundation, Inc.
 
1605
 
 
1606
 This is free software; see the source for copying conditions.  There is NO
 
1607
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
 
1608
@@ -136,6 +132,27 @@
 
1609
 UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
 
1610
 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
 
1611
 
 
1612
+case "${UNAME_SYSTEM}" in
 
1613
+Linux|GNU|GNU/*)
 
1614
+       # If the system lacks a compiler, then just pick glibc.
 
1615
+       # We could probably try harder.
 
1616
+       LIBC=gnu
 
1617
+
 
1618
+       eval $set_cc_for_build
 
1619
+       cat <<-EOF > $dummy.c
 
1620
+       #include <features.h>
 
1621
+       #if defined(__UCLIBC__)
 
1622
+       LIBC=uclibc
 
1623
+       #elif defined(__dietlibc__)
 
1624
+       LIBC=dietlibc
 
1625
+       #else
 
1626
+       LIBC=gnu
 
1627
+       #endif
 
1628
+       EOF
 
1629
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
 
1630
+       ;;
 
1631
+esac
 
1632
+
 
1633
 # Note: order is significant - the case branches are not exclusive.
 
1634
 
 
1635
 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 
1636
@@ -857,21 +874,21 @@
 
1637
        exit ;;
 
1638
     *:GNU:*:*)
 
1639
        # the GNU system
 
1640
-       echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
 
1641
+       echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
 
1642
        exit ;;
 
1643
     *:GNU/*:*:*)
 
1644
        # other systems with GNU libc and userland
 
1645
-       echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
 
1646
+       echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
 
1647
        exit ;;
 
1648
     i*86:Minix:*:*)
 
1649
        echo ${UNAME_MACHINE}-pc-minix
 
1650
        exit ;;
 
1651
     aarch64:Linux:*:*)
 
1652
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
 
1653
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1654
        exit ;;
 
1655
     aarch64_be:Linux:*:*)
 
1656
        UNAME_MACHINE=aarch64_be
 
1657
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
 
1658
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1659
        exit ;;
 
1660
     alpha:Linux:*:*)
 
1661
        case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
 
1662
@@ -884,59 +901,54 @@
 
1663
          EV68*) UNAME_MACHINE=alphaev68 ;;
 
1664
        esac
 
1665
        objdump --private-headers /bin/sh | grep -q ld.so.1
 
1666
-       if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
 
1667
-       echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
 
1668
+       if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
 
1669
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1670
        exit ;;
 
1671
+    arc:Linux:*:* | arceb:Linux:*:*)
 
1672
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1673
+       exit ;;
 
1674
     arm*:Linux:*:*)
 
1675
        eval $set_cc_for_build
 
1676
        if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
 
1677
            | grep -q __ARM_EABI__
 
1678
        then
 
1679
-           echo ${UNAME_MACHINE}-unknown-linux-gnu
 
1680
+           echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1681
        else
 
1682
            if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
 
1683
                | grep -q __ARM_PCS_VFP
 
1684
            then
 
1685
-               echo ${UNAME_MACHINE}-unknown-linux-gnueabi
 
1686
+               echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
 
1687
            else
 
1688
-               echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
 
1689
+               echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
 
1690
            fi
 
1691
        fi
 
1692
        exit ;;
 
1693
     avr32*:Linux:*:*)
 
1694
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
 
1695
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1696
        exit ;;
 
1697
     cris:Linux:*:*)
 
1698
-       echo ${UNAME_MACHINE}-axis-linux-gnu
 
1699
+       echo ${UNAME_MACHINE}-axis-linux-${LIBC}
 
1700
        exit ;;
 
1701
     crisv32:Linux:*:*)
 
1702
-       echo ${UNAME_MACHINE}-axis-linux-gnu
 
1703
+       echo ${UNAME_MACHINE}-axis-linux-${LIBC}
 
1704
        exit ;;
 
1705
     frv:Linux:*:*)
 
1706
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
 
1707
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1708
        exit ;;
 
1709
     hexagon:Linux:*:*)
 
1710
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
 
1711
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1712
        exit ;;
 
1713
     i*86:Linux:*:*)
 
1714
-       LIBC=gnu
 
1715
-       eval $set_cc_for_build
 
1716
-       sed 's/^        //' << EOF >$dummy.c
 
1717
-       #ifdef __dietlibc__
 
1718
-       LIBC=dietlibc
 
1719
-       #endif
 
1720
-EOF
 
1721
-       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
 
1722
-       echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
 
1723
+       echo ${UNAME_MACHINE}-pc-linux-${LIBC}
 
1724
        exit ;;
 
1725
     ia64:Linux:*:*)
 
1726
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
 
1727
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1728
        exit ;;
 
1729
     m32r*:Linux:*:*)
 
1730
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
 
1731
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1732
        exit ;;
 
1733
     m68*:Linux:*:*)
 
1734
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
 
1735
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1736
        exit ;;
 
1737
     mips:Linux:*:* | mips64:Linux:*:*)
 
1738
        eval $set_cc_for_build
 
1739
@@ -955,54 +967,63 @@
 
1740
        #endif
 
1741
 EOF
 
1742
        eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
 
1743
-       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
 
1744
+       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
 
1745
        ;;
 
1746
+    or1k:Linux:*:*)
 
1747
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1748
+       exit ;;
 
1749
     or32:Linux:*:*)
 
1750
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
 
1751
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1752
        exit ;;
 
1753
     padre:Linux:*:*)
 
1754
-       echo sparc-unknown-linux-gnu
 
1755
+       echo sparc-unknown-linux-${LIBC}
 
1756
        exit ;;
 
1757
     parisc64:Linux:*:* | hppa64:Linux:*:*)
 
1758
-       echo hppa64-unknown-linux-gnu
 
1759
+       echo hppa64-unknown-linux-${LIBC}
 
1760
        exit ;;
 
1761
     parisc:Linux:*:* | hppa:Linux:*:*)
 
1762
        # Look for CPU level
 
1763
        case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
 
1764
-         PA7*) echo hppa1.1-unknown-linux-gnu ;;
 
1765
-         PA8*) echo hppa2.0-unknown-linux-gnu ;;
 
1766
-         *)    echo hppa-unknown-linux-gnu ;;
 
1767
+         PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
 
1768
+         PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
 
1769
+         *)    echo hppa-unknown-linux-${LIBC} ;;
 
1770
        esac
 
1771
        exit ;;
 
1772
     ppc64:Linux:*:*)
 
1773
-       echo powerpc64-unknown-linux-gnu
 
1774
+       echo powerpc64-unknown-linux-${LIBC}
 
1775
        exit ;;
 
1776
     ppc:Linux:*:*)
 
1777
-       echo powerpc-unknown-linux-gnu
 
1778
+       echo powerpc-unknown-linux-${LIBC}
 
1779
        exit ;;
 
1780
+    ppc64le:Linux:*:*)
 
1781
+       echo powerpc64le-unknown-linux-${LIBC}
 
1782
+       exit ;;
 
1783
+    ppcle:Linux:*:*)
 
1784
+       echo powerpcle-unknown-linux-${LIBC}
 
1785
+       exit ;;
 
1786
     s390:Linux:*:* | s390x:Linux:*:*)
 
1787
-       echo ${UNAME_MACHINE}-ibm-linux
 
1788
+       echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
 
1789
        exit ;;
 
1790
     sh64*:Linux:*:*)
 
1791
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
 
1792
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1793
        exit ;;
 
1794
     sh*:Linux:*:*)
 
1795
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
 
1796
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1797
        exit ;;
 
1798
     sparc:Linux:*:* | sparc64:Linux:*:*)
 
1799
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
 
1800
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1801
        exit ;;
 
1802
     tile*:Linux:*:*)
 
1803
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
 
1804
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1805
        exit ;;
 
1806
     vax:Linux:*:*)
 
1807
-       echo ${UNAME_MACHINE}-dec-linux-gnu
 
1808
+       echo ${UNAME_MACHINE}-dec-linux-${LIBC}
 
1809
        exit ;;
 
1810
     x86_64:Linux:*:*)
 
1811
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
 
1812
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1813
        exit ;;
 
1814
     xtensa*:Linux:*:*)
 
1815
-       echo ${UNAME_MACHINE}-unknown-linux-gnu
 
1816
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
 
1817
        exit ;;
 
1818
     i*86:DYNIX/ptx:4*:*)
 
1819
        # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
 
1820
@@ -1235,19 +1256,21 @@
 
1821
        exit ;;
 
1822
     *:Darwin:*:*)
 
1823
        UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
 
1824
-       case $UNAME_PROCESSOR in
 
1825
-           i386)
 
1826
-               eval $set_cc_for_build
 
1827
-               if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
 
1828
-                 if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
 
1829
-                     (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
 
1830
-                     grep IS_64BIT_ARCH >/dev/null
 
1831
-                 then
 
1832
-                     UNAME_PROCESSOR="x86_64"
 
1833
-                 fi
 
1834
-               fi ;;
 
1835
-           unknown) UNAME_PROCESSOR=powerpc ;;
 
1836
-       esac
 
1837
+       eval $set_cc_for_build
 
1838
+       if test "$UNAME_PROCESSOR" = unknown ; then
 
1839
+           UNAME_PROCESSOR=powerpc
 
1840
+       fi
 
1841
+       if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
 
1842
+           if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
 
1843
+               (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
 
1844
+               grep IS_64BIT_ARCH >/dev/null
 
1845
+           then
 
1846
+               case $UNAME_PROCESSOR in
 
1847
+                   i386) UNAME_PROCESSOR=x86_64 ;;
 
1848
+                   powerpc) UNAME_PROCESSOR=powerpc64 ;;
 
1849
+               esac
 
1850
+           fi
 
1851
+       fi
 
1852
        echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
 
1853
        exit ;;
 
1854
     *:procnto*:*:* | *:QNX:[0123456789]*:*)
 
1855
--- a/src/gcc/configure
 
1856
+++ b/src/gcc/configure
 
1857
@@ -13589,7 +13589,7 @@
 
1858
   rm -rf conftest*
 
1859
   ;;
 
1860
 
 
1861
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
1862
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
1863
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
1864
   # Find out which ABI we are using.
 
1865
   echo 'int i;' > conftest.$ac_ext
 
1866
@@ -13614,7 +13614,10 @@
 
1867
                ;;
 
1868
            esac
 
1869
            ;;
 
1870
-         ppc64-*linux*|powerpc64-*linux*)
 
1871
+         powerpc64le-*linux*)
 
1872
+           LD="${LD-ld} -m elf32lppclinux"
 
1873
+           ;;
 
1874
+         powerpc64-*linux*)
 
1875
            LD="${LD-ld} -m elf32ppclinux"
 
1876
            ;;
 
1877
          s390x-*linux*)
 
1878
@@ -13633,7 +13636,10 @@
 
1879
          x86_64-*linux*)
 
1880
            LD="${LD-ld} -m elf_x86_64"
 
1881
            ;;
 
1882
-         ppc*-*linux*|powerpc*-*linux*)
 
1883
+         powerpcle-*linux*)
 
1884
+           LD="${LD-ld} -m elf64lppc"
 
1885
+           ;;
 
1886
+         powerpc-*linux*)
 
1887
            LD="${LD-ld} -m elf64ppc"
 
1888
            ;;
 
1889
          s390*-*linux*|s390*-*tpf*)
 
1890
@@ -17827,7 +17833,7 @@
 
1891
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
1892
   lt_status=$lt_dlunknown
 
1893
   cat > conftest.$ac_ext <<_LT_EOF
 
1894
-#line 17830 "configure"
 
1895
+#line 17836 "configure"
 
1896
 #include "confdefs.h"
 
1897
 
 
1898
 #if HAVE_DLFCN_H
 
1899
@@ -17933,7 +17939,7 @@
 
1900
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
1901
   lt_status=$lt_dlunknown
 
1902
   cat > conftest.$ac_ext <<_LT_EOF
 
1903
-#line 17936 "configure"
 
1904
+#line 17942 "configure"
 
1905
 #include "confdefs.h"
 
1906
 
 
1907
 #if HAVE_DLFCN_H
 
1908
--- a/src/gcc/builtins.c
 
1909
+++ b/src/gcc/builtins.c
 
1910
@@ -5850,6 +5850,9 @@
 
1911
   switch (fcode)
 
1912
     {
 
1913
     CASE_FLT_FN (BUILT_IN_FABS):
 
1914
+    case BUILT_IN_FABSD32:
 
1915
+    case BUILT_IN_FABSD64:
 
1916
+    case BUILT_IN_FABSD128:
 
1917
       target = expand_builtin_fabs (exp, target, subtarget);
 
1918
       if (target)
 
1919
        return target;
 
1920
@@ -10302,6 +10305,9 @@
 
1921
       return fold_builtin_strlen (loc, type, arg0);
 
1922
 
 
1923
     CASE_FLT_FN (BUILT_IN_FABS):
 
1924
+    case BUILT_IN_FABSD32:
 
1925
+    case BUILT_IN_FABSD64:
 
1926
+    case BUILT_IN_FABSD128:
 
1927
       return fold_builtin_fabs (loc, arg0, type);
 
1928
 
 
1929
     case BUILT_IN_ABS:
 
1930
--- a/src/gcc/testsuite/gcc.target/powerpc/ppc-target-2.c
 
1931
+++ b/src/gcc/testsuite/gcc.target/powerpc/ppc-target-2.c
 
1932
@@ -5,8 +5,7 @@
 
1933
 /* { dg-final { scan-assembler-times "fabs" 3 } } */
 
1934
 /* { dg-final { scan-assembler-times "fnabs" 3 } } */
 
1935
 /* { dg-final { scan-assembler-times "fsel" 3 } } */
 
1936
-/* { dg-final { scan-assembler-times "fcpsgn" 3 } } */
 
1937
-/* { dg-final { scan-assembler-times "xscpsgndp" 1 } } */
 
1938
+/* { dg-final { scan-assembler-times "fcpsgn\|xscpsgndp" 4 } } */
 
1939
 
 
1940
 /* fabs/fnabs/fsel */
 
1941
 double normal1 (double a, double b) { return __builtin_copysign (a, b); }
 
1942
--- a/src/gcc/testsuite/gcc.target/powerpc/p8vector-builtin-1.c
 
1943
+++ b/src/gcc/testsuite/gcc.target/powerpc/p8vector-builtin-1.c
 
1944
@@ -0,0 +1,65 @@
 
1945
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
1946
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
1947
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
1948
+/* { dg-options "-mcpu=power8 -O2 -ftree-vectorize -fvect-cost-model -fno-unroll-loops -fno-unroll-all-loops" } */
 
1949
+
 
1950
+#ifndef TYPE
 
1951
+#define TYPE long long
 
1952
+#endif
 
1953
+
 
1954
+#ifndef SIGN_TYPE
 
1955
+#define SIGN_TYPE signed TYPE
 
1956
+#endif
 
1957
+
 
1958
+#ifndef UNS_TYPE
 
1959
+#define UNS_TYPE unsigned TYPE
 
1960
+#endif
 
1961
+
 
1962
+typedef vector SIGN_TYPE v_sign;
 
1963
+typedef vector UNS_TYPE  v_uns;
 
1964
+
 
1965
+v_sign sign_add (v_sign a, v_sign b)
 
1966
+{
 
1967
+  return a + b;
 
1968
+}
 
1969
+
 
1970
+v_sign sign_sub (v_sign a, v_sign b)
 
1971
+{
 
1972
+  return a - b;
 
1973
+}
 
1974
+
 
1975
+v_sign sign_shift_left (v_sign a, v_sign b)
 
1976
+{
 
1977
+  return a << b;
 
1978
+}
 
1979
+
 
1980
+v_sign sign_shift_right (v_sign a, v_sign b)
 
1981
+{
 
1982
+  return a >> b;
 
1983
+}
 
1984
+
 
1985
+v_uns uns_add (v_uns a, v_uns b)
 
1986
+{
 
1987
+  return a + b;
 
1988
+}
 
1989
+
 
1990
+v_uns uns_sub (v_uns a, v_uns b)
 
1991
+{
 
1992
+  return a - b;
 
1993
+}
 
1994
+
 
1995
+v_uns uns_shift_left (v_uns a, v_uns b)
 
1996
+{
 
1997
+  return a << b;
 
1998
+}
 
1999
+
 
2000
+v_uns uns_shift_right (v_uns a, v_uns b)
 
2001
+{
 
2002
+  return a >> b;
 
2003
+}
 
2004
+
 
2005
+/* { dg-final { scan-assembler-times "vaddudm" 2 } } */
 
2006
+/* { dg-final { scan-assembler-times "vsubudm" 2 } } */
 
2007
+/* { dg-final { scan-assembler-times "vsld"    2 } } */
 
2008
+/* { dg-final { scan-assembler-times "vsrad"   1 } } */
 
2009
+/* { dg-final { scan-assembler-times "vsrd"    1 } } */
 
2010
--- a/src/gcc/testsuite/gcc.target/powerpc/p8vector-vectorize-1.c
 
2011
+++ b/src/gcc/testsuite/gcc.target/powerpc/p8vector-vectorize-1.c
 
2012
@@ -0,0 +1,200 @@
 
2013
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
2014
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
2015
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
2016
+/* { dg-options "-mcpu=power8 -O2 -ftree-vectorize -fvect-cost-model -fno-unroll-loops -fno-unroll-all-loops" } */
 
2017
+
 
2018
+#ifndef SIZE
 
2019
+#define SIZE 1024
 
2020
+#endif
 
2021
+
 
2022
+#ifndef ALIGN
 
2023
+#define ALIGN 32
 
2024
+#endif
 
2025
+
 
2026
+#ifndef TYPE
 
2027
+#define TYPE long long
 
2028
+#endif
 
2029
+
 
2030
+#ifndef SIGN_TYPE
 
2031
+#define SIGN_TYPE signed TYPE
 
2032
+#endif
 
2033
+
 
2034
+#ifndef UNS_TYPE
 
2035
+#define UNS_TYPE unsigned TYPE
 
2036
+#endif
 
2037
+
 
2038
+#define ALIGN_ATTR __attribute__((__aligned__(ALIGN)))
 
2039
+
 
2040
+SIGN_TYPE      sa[SIZE] ALIGN_ATTR;
 
2041
+SIGN_TYPE      sb[SIZE] ALIGN_ATTR;
 
2042
+SIGN_TYPE      sc[SIZE] ALIGN_ATTR;
 
2043
+
 
2044
+UNS_TYPE       ua[SIZE] ALIGN_ATTR;
 
2045
+UNS_TYPE       ub[SIZE] ALIGN_ATTR;
 
2046
+UNS_TYPE       uc[SIZE] ALIGN_ATTR;
 
2047
+
 
2048
+void
 
2049
+sign_add (void)
 
2050
+{
 
2051
+  unsigned long i;
 
2052
+
 
2053
+  for (i = 0; i < SIZE; i++)
 
2054
+    sa[i] = sb[i] + sc[i];
 
2055
+}
 
2056
+
 
2057
+void
 
2058
+sign_sub (void)
 
2059
+{
 
2060
+  unsigned long i;
 
2061
+
 
2062
+  for (i = 0; i < SIZE; i++)
 
2063
+    sa[i] = sb[i] - sc[i];
 
2064
+}
 
2065
+
 
2066
+void
 
2067
+sign_shift_left (void)
 
2068
+{
 
2069
+  unsigned long i;
 
2070
+
 
2071
+  for (i = 0; i < SIZE; i++)
 
2072
+    sa[i] = sb[i] << sc[i];
 
2073
+}
 
2074
+
 
2075
+void
 
2076
+sign_shift_right (void)
 
2077
+{
 
2078
+  unsigned long i;
 
2079
+
 
2080
+  for (i = 0; i < SIZE; i++)
 
2081
+    sa[i] = sb[i] >> sc[i];
 
2082
+}
 
2083
+
 
2084
+void
 
2085
+sign_max (void)
 
2086
+{
 
2087
+  unsigned long i;
 
2088
+
 
2089
+  for (i = 0; i < SIZE; i++)
 
2090
+    sa[i] = (sb[i] > sc[i]) ? sb[i] : sc[i];
 
2091
+}
 
2092
+
 
2093
+void
 
2094
+sign_min (void)
 
2095
+{
 
2096
+  unsigned long i;
 
2097
+
 
2098
+  for (i = 0; i < SIZE; i++)
 
2099
+    sa[i] = (sb[i] < sc[i]) ? sb[i] : sc[i];
 
2100
+}
 
2101
+
 
2102
+void
 
2103
+sign_abs (void)
 
2104
+{
 
2105
+  unsigned long i;
 
2106
+
 
2107
+  for (i = 0; i < SIZE; i++)
 
2108
+    sa[i] = (sb[i] < 0) ? -sb[i] : sb[i];      /* xor, vsubudm, vmaxsd.  */
 
2109
+}
 
2110
+
 
2111
+void
 
2112
+sign_eq (SIGN_TYPE val1, SIGN_TYPE val2)
 
2113
+{
 
2114
+  unsigned long i;
 
2115
+
 
2116
+  for (i = 0; i < SIZE; i++)
 
2117
+    sa[i] = (sb[i] == sc[i]) ? val1 : val2;
 
2118
+}
 
2119
+
 
2120
+void
 
2121
+sign_lt (SIGN_TYPE val1, SIGN_TYPE val2)
 
2122
+{
 
2123
+  unsigned long i;
 
2124
+
 
2125
+  for (i = 0; i < SIZE; i++)
 
2126
+    sa[i] = (sb[i] < sc[i]) ? val1 : val2;
 
2127
+}
 
2128
+
 
2129
+void
 
2130
+uns_add (void)
 
2131
+{
 
2132
+  unsigned long i;
 
2133
+
 
2134
+  for (i = 0; i < SIZE; i++)
 
2135
+    ua[i] = ub[i] + uc[i];
 
2136
+}
 
2137
+
 
2138
+void
 
2139
+uns_sub (void)
 
2140
+{
 
2141
+  unsigned long i;
 
2142
+
 
2143
+  for (i = 0; i < SIZE; i++)
 
2144
+    ua[i] = ub[i] - uc[i];
 
2145
+}
 
2146
+
 
2147
+void
 
2148
+uns_shift_left (void)
 
2149
+{
 
2150
+  unsigned long i;
 
2151
+
 
2152
+  for (i = 0; i < SIZE; i++)
 
2153
+    ua[i] = ub[i] << uc[i];
 
2154
+}
 
2155
+
 
2156
+void
 
2157
+uns_shift_right (void)
 
2158
+{
 
2159
+  unsigned long i;
 
2160
+
 
2161
+  for (i = 0; i < SIZE; i++)
 
2162
+    ua[i] = ub[i] >> uc[i];
 
2163
+}
 
2164
+
 
2165
+void
 
2166
+uns_max (void)
 
2167
+{
 
2168
+  unsigned long i;
 
2169
+
 
2170
+  for (i = 0; i < SIZE; i++)
 
2171
+    ua[i] = (ub[i] > uc[i]) ? ub[i] : uc[i];
 
2172
+}
 
2173
+
 
2174
+void
 
2175
+uns_min (void)
 
2176
+{
 
2177
+  unsigned long i;
 
2178
+
 
2179
+  for (i = 0; i < SIZE; i++)
 
2180
+    ua[i] = (ub[i] < uc[i]) ? ub[i] : uc[i];
 
2181
+}
 
2182
+
 
2183
+void
 
2184
+uns_eq (UNS_TYPE val1, UNS_TYPE val2)
 
2185
+{
 
2186
+  unsigned long i;
 
2187
+
 
2188
+  for (i = 0; i < SIZE; i++)
 
2189
+    ua[i] = (ub[i] == uc[i]) ? val1 : val2;
 
2190
+}
 
2191
+
 
2192
+void
 
2193
+uns_lt (UNS_TYPE val1, UNS_TYPE val2)
 
2194
+{
 
2195
+  unsigned long i;
 
2196
+
 
2197
+  for (i = 0; i < SIZE; i++)
 
2198
+    ua[i] = (ub[i] < uc[i]) ? val1 : val2;
 
2199
+}
 
2200
+
 
2201
+/* { dg-final { scan-assembler-times "\[\t \]vaddudm\[\t \]"  2 } } */
 
2202
+/* { dg-final { scan-assembler-times "\[\t \]vsubudm\[\t \]"  3 } } */
 
2203
+/* { dg-final { scan-assembler-times "\[\t \]vmaxsd\[\t \]"   2 } } */
 
2204
+/* { dg-final { scan-assembler-times "\[\t \]vmaxud\[\t \]"   1 } } */
 
2205
+/* { dg-final { scan-assembler-times "\[\t \]vminsd\[\t \]"   1 } } */
 
2206
+/* { dg-final { scan-assembler-times "\[\t \]vminud\[\t \]"   1 } } */
 
2207
+/* { dg-final { scan-assembler-times "\[\t \]vsld\[\t \]"     2 } } */
 
2208
+/* { dg-final { scan-assembler-times "\[\t \]vsrad\[\t \]"    1 } } */
 
2209
+/* { dg-final { scan-assembler-times "\[\t \]vsrd\[\t \]"     1 } } */
 
2210
+/* { dg-final { scan-assembler-times "\[\t \]vcmpequd\[\t \]" 2 } } */
 
2211
+/* { dg-final { scan-assembler-times "\[\t \]vcmpgtsd\[\t \]" 1 } } */
 
2212
+/* { dg-final { scan-assembler-times "\[\t \]vcmpgtud\[\t \]" 1 } } */
 
2213
--- a/src/gcc/testsuite/gcc.target/powerpc/pr57744.c
 
2214
+++ b/src/gcc/testsuite/gcc.target/powerpc/pr57744.c
 
2215
@@ -0,0 +1,39 @@
 
2216
+/* { dg-do run { target { powerpc*-*-* && lp64 } } } */
 
2217
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
2218
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
2219
+/* { dg-options "-mcpu=power8 -O3" } */
 
2220
+
 
2221
+void abort (void);
 
2222
+
 
2223
+typedef unsigned U_16 __attribute__((mode(TI)));
 
2224
+
 
2225
+extern int libat_compare_exchange_16 (U_16 *, U_16 *, U_16, int, int)
 
2226
+  __attribute__((__noinline__));
 
2227
+
 
2228
+/* PR 57744: lqarx/stqcx needs even/odd register pairs.  The assembler will
 
2229
+   complain if the compiler gets an odd/even register pair.  Create a function
 
2230
+   which has the 16 byte compare and exchange instructions, but don't actually
 
2231
+   execute it, so that we can detect these failures on older machines. */
 
2232
+
 
2233
+int
 
2234
+libat_compare_exchange_16 (U_16 *mptr, U_16 *eptr, U_16 newval,
 
2235
+         int smodel, int fmodel __attribute__((unused)))
 
2236
+{
 
2237
+  if (((smodel) == 0))
 
2238
+    return __atomic_compare_exchange_n (mptr, eptr, newval, 0, 0, 0);
 
2239
+  else if (((smodel) != 5))
 
2240
+    return __atomic_compare_exchange_n (mptr, eptr, newval, 0, 4, 0);
 
2241
+  else
 
2242
+    return __atomic_compare_exchange_n (mptr, eptr, newval, 0, 5, 0);
 
2243
+}
 
2244
+
 
2245
+U_16 a = 1, b = 1, c = -2;
 
2246
+volatile int do_test = 0;
 
2247
+
 
2248
+int main (void)
 
2249
+{
 
2250
+  if (do_test && !libat_compare_exchange_16 (&a, &b, c, 0, 0))
 
2251
+    abort ();
 
2252
+
 
2253
+  return 0;
 
2254
+}
 
2255
--- a/src/gcc/testsuite/gcc.target/powerpc/recip-1.c
 
2256
+++ b/src/gcc/testsuite/gcc.target/powerpc/recip-1.c
 
2257
@@ -3,8 +3,8 @@
 
2258
 /* { dg-options "-O2 -mrecip -ffast-math -mcpu=power6" } */
 
2259
 /* { dg-final { scan-assembler-times "frsqrte" 2 } } */
 
2260
 /* { dg-final { scan-assembler-times "fmsub" 2 } } */
 
2261
-/* { dg-final { scan-assembler-times "fmul" 8 } } */
 
2262
-/* { dg-final { scan-assembler-times "fnmsub" 4 } } */
 
2263
+/* { dg-final { scan-assembler-times "fmul" 6 } } */
 
2264
+/* { dg-final { scan-assembler-times "fnmsub" 3 } } */
 
2265
 
 
2266
 double
 
2267
 rsqrt_d (double a)
 
2268
--- a/src/gcc/testsuite/gcc.target/powerpc/darwin-longlong.c
 
2269
+++ b/src/gcc/testsuite/gcc.target/powerpc/darwin-longlong.c
 
2270
@@ -11,7 +11,11 @@
 
2271
     int  i[2];
 
2272
   } ud;
 
2273
   ud.ll = in;
 
2274
+#ifdef __LITTLE_ENDIAN__
 
2275
+  return ud.i[1];
 
2276
+#else
 
2277
   return ud.i[0];
 
2278
+#endif
 
2279
 }
 
2280
 
 
2281
 int main()
 
2282
--- a/src/gcc/testsuite/gcc.target/powerpc/bool2-p8.c
 
2283
+++ b/src/gcc/testsuite/gcc.target/powerpc/bool2-p8.c
 
2284
@@ -0,0 +1,32 @@
 
2285
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
2286
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
2287
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
2288
+/* { dg-options "-O2 -mcpu=power8" } */
 
2289
+/* { dg-final { scan-assembler-not "\[ \t\]and "     } } */
 
2290
+/* { dg-final { scan-assembler-not "\[ \t\]or "      } } */
 
2291
+/* { dg-final { scan-assembler-not "\[ \t\]xor "     } } */
 
2292
+/* { dg-final { scan-assembler-not "\[ \t\]nor "     } } */
 
2293
+/* { dg-final { scan-assembler-not "\[ \t\]eqv "     } } */
 
2294
+/* { dg-final { scan-assembler-not "\[ \t\]andc "    } } */
 
2295
+/* { dg-final { scan-assembler-not "\[ \t\]orc "     } } */
 
2296
+/* { dg-final { scan-assembler-not "\[ \t\]nand "    } } */
 
2297
+/* { dg-final { scan-assembler-not "\[ \t\]vand "    } } */
 
2298
+/* { dg-final { scan-assembler-not "\[ \t\]vandc "   } } */
 
2299
+/* { dg-final { scan-assembler-not "\[ \t\]vor "     } } */
 
2300
+/* { dg-final { scan-assembler-not "\[ \t\]vxor "    } } */
 
2301
+/* { dg-final { scan-assembler-not "\[ \t\]vnor "    } } */
 
2302
+/* { dg-final { scan-assembler     "\[ \t\]xxland "  } } */
 
2303
+/* { dg-final { scan-assembler     "\[ \t\]xxlor "   } } */
 
2304
+/* { dg-final { scan-assembler     "\[ \t\]xxlxor "  } } */
 
2305
+/* { dg-final { scan-assembler     "\[ \t\]xxlnor "  } } */
 
2306
+/* { dg-final { scan-assembler     "\[ \t\]xxlandc " } } */
 
2307
+/* { dg-final { scan-assembler     "\[ \t\]xxleqv "  } } */
 
2308
+/* { dg-final { scan-assembler     "\[ \t\]xxlorc "  } } */
 
2309
+/* { dg-final { scan-assembler     "\[ \t\]xxlnand " } } */
 
2310
+
 
2311
+#ifndef TYPE
 
2312
+typedef int v4si __attribute__ ((vector_size (16)));
 
2313
+#define TYPE v4si
 
2314
+#endif
 
2315
+
 
2316
+#include "bool2.h"
 
2317
--- a/src/gcc/testsuite/gcc.target/powerpc/mmfpgpr.c
 
2318
+++ b/src/gcc/testsuite/gcc.target/powerpc/mmfpgpr.c
 
2319
@@ -0,0 +1,22 @@
 
2320
+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 
2321
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
2322
+/* { dg-require-effective-target powerpc_vsx_ok } */
 
2323
+/* { dg-options "-O2 -mcpu=power6x -mmfpgpr" } */
 
2324
+/* { dg-final { scan-assembler "mffgpr" } } */
 
2325
+/* { dg-final { scan-assembler "mftgpr" } } */
 
2326
+
 
2327
+/* Test that we generate the instructions to move between the GPR and FPR
 
2328
+   registers under power6x.  */
 
2329
+
 
2330
+extern long return_long (void);
 
2331
+extern double return_double (void);
 
2332
+
 
2333
+double return_double2 (void)
 
2334
+{
 
2335
+  return (double) return_long ();
 
2336
+}
 
2337
+
 
2338
+long return_long2 (void)
 
2339
+{
 
2340
+  return (long) return_double ();
 
2341
+}
 
2342
--- a/src/gcc/testsuite/gcc.target/powerpc/direct-move-vint1.c
 
2343
+++ b/src/gcc/testsuite/gcc.target/powerpc/direct-move-vint1.c
 
2344
@@ -0,0 +1,14 @@
 
2345
+/* { dg-do compile { target { powerpc*-*-linux* && lp64 } } } */
 
2346
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
2347
+/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
 
2348
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
2349
+/* { dg-options "-mcpu=power8 -O2" } */
 
2350
+/* { dg-final { scan-assembler "mtvsrd" } } */
 
2351
+/* { dg-final { scan-assembler "mfvsrd" } } */
 
2352
+
 
2353
+/* Check code generation for direct move for vector types.  */
 
2354
+
 
2355
+#define TYPE vector int
 
2356
+#define VSX_REG_ATTR "wa"
 
2357
+
 
2358
+#include "direct-move.h"
 
2359
--- a/src/gcc/testsuite/gcc.target/powerpc/bool2-av.c
 
2360
+++ b/src/gcc/testsuite/gcc.target/powerpc/bool2-av.c
 
2361
@@ -0,0 +1,32 @@
 
2362
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
2363
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
2364
+/* { dg-require-effective-target powerpc_altivec_ok } */
 
2365
+/* { dg-options "-O2 -mcpu=power6 -maltivec" } */
 
2366
+/* { dg-final { scan-assembler-not "\[ \t\]and "     } } */
 
2367
+/* { dg-final { scan-assembler-not "\[ \t\]or "      } } */
 
2368
+/* { dg-final { scan-assembler-not "\[ \t\]xor "     } } */
 
2369
+/* { dg-final { scan-assembler-not "\[ \t\]nor "     } } */
 
2370
+/* { dg-final { scan-assembler-not "\[ \t\]andc "    } } */
 
2371
+/* { dg-final { scan-assembler-not "\[ \t\]eqv "     } } */
 
2372
+/* { dg-final { scan-assembler-not "\[ \t\]orc "     } } */
 
2373
+/* { dg-final { scan-assembler-not "\[ \t\]nand "    } } */
 
2374
+/* { dg-final { scan-assembler     "\[ \t\]vand "    } } */
 
2375
+/* { dg-final { scan-assembler     "\[ \t\]vandc "   } } */
 
2376
+/* { dg-final { scan-assembler     "\[ \t\]vor "     } } */
 
2377
+/* { dg-final { scan-assembler     "\[ \t\]vxor "    } } */
 
2378
+/* { dg-final { scan-assembler     "\[ \t\]vnor "    } } */
 
2379
+/* { dg-final { scan-assembler-not "\[ \t\]xxland "  } } */
 
2380
+/* { dg-final { scan-assembler-not "\[ \t\]xxlor "   } } */
 
2381
+/* { dg-final { scan-assembler-not "\[ \t\]xxlxor "  } } */
 
2382
+/* { dg-final { scan-assembler-not "\[ \t\]xxlnor "  } } */
 
2383
+/* { dg-final { scan-assembler-not "\[ \t\]xxlandc " } } */
 
2384
+/* { dg-final { scan-assembler-not "\[ \t\]xxleqv "  } } */
 
2385
+/* { dg-final { scan-assembler-not "\[ \t\]xxlorc "  } } */
 
2386
+/* { dg-final { scan-assembler-not "\[ \t\]xxlnand " } } */
 
2387
+
 
2388
+#ifndef TYPE
 
2389
+typedef int v4si __attribute__ ((vector_size (16)));
 
2390
+#define TYPE v4si
 
2391
+#endif
 
2392
+
 
2393
+#include "bool2.h"
 
2394
--- a/src/gcc/testsuite/gcc.target/powerpc/pr43154.c
 
2395
+++ b/src/gcc/testsuite/gcc.target/powerpc/pr43154.c
 
2396
@@ -1,5 +1,6 @@
 
2397
 /* { dg-do compile { target { powerpc*-*-* } } } */
 
2398
 /* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
2399
+/* { dg-skip-if "" { powerpc*le-*-* } { "*" } { "" } } */
 
2400
 /* { dg-require-effective-target powerpc_vsx_ok } */
 
2401
 /* { dg-options "-O2 -mcpu=power7" } */
 
2402
 
 
2403
--- a/src/gcc/testsuite/gcc.target/powerpc/pr59054.c
 
2404
+++ b/src/gcc/testsuite/gcc.target/powerpc/pr59054.c
 
2405
@@ -0,0 +1,9 @@
 
2406
+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 
2407
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
2408
+/* { dg-require-effective-target powerpc_vsx_ok } */
 
2409
+/* { dg-options "-mcpu=power7 -O0 -m64" } */
 
2410
+
 
2411
+long foo (void) { return 0; }
 
2412
+
 
2413
+/* { dg-final { scan-assembler-not "xxlor" } } */
 
2414
+/* { dg-final { scan-assembler-not "stfd" } } */
 
2415
--- a/src/gcc/testsuite/gcc.target/powerpc/p8vector-builtin-2.c
 
2416
+++ b/src/gcc/testsuite/gcc.target/powerpc/p8vector-builtin-2.c
 
2417
@@ -0,0 +1,204 @@
 
2418
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
2419
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
2420
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
2421
+/* { dg-options "-mcpu=power8 -O2 -ftree-vectorize -fvect-cost-model -fno-unroll-loops -fno-unroll-all-loops" } */
 
2422
+
 
2423
+#include <altivec.h>
 
2424
+
 
2425
+typedef vector long long               v_sign;
 
2426
+typedef vector unsigned long long      v_uns;
 
2427
+typedef vector bool long long          v_bool;
 
2428
+
 
2429
+v_sign sign_add_1 (v_sign a, v_sign b)
 
2430
+{
 
2431
+  return __builtin_altivec_vaddudm (a, b);
 
2432
+}
 
2433
+
 
2434
+v_sign sign_add_2 (v_sign a, v_sign b)
 
2435
+{
 
2436
+  return vec_add (a, b);
 
2437
+}
 
2438
+
 
2439
+v_sign sign_add_3 (v_sign a, v_sign b)
 
2440
+{
 
2441
+  return vec_vaddudm (a, b);
 
2442
+}
 
2443
+
 
2444
+v_sign sign_sub_1 (v_sign a, v_sign b)
 
2445
+{
 
2446
+  return __builtin_altivec_vsubudm (a, b);
 
2447
+}
 
2448
+
 
2449
+v_sign sign_sub_2 (v_sign a, v_sign b)
 
2450
+{
 
2451
+  return vec_sub (a, b);
 
2452
+}
 
2453
+
 
2454
+
 
2455
+v_sign sign_sub_3 (v_sign a, v_sign b)
 
2456
+{
 
2457
+  return vec_vsubudm (a, b);
 
2458
+}
 
2459
+
 
2460
+v_sign sign_min_1 (v_sign a, v_sign b)
 
2461
+{
 
2462
+  return __builtin_altivec_vminsd (a, b);
 
2463
+}
 
2464
+
 
2465
+v_sign sign_min_2 (v_sign a, v_sign b)
 
2466
+{
 
2467
+  return vec_min (a, b);
 
2468
+}
 
2469
+
 
2470
+v_sign sign_min_3 (v_sign a, v_sign b)
 
2471
+{
 
2472
+  return vec_vminsd (a, b);
 
2473
+}
 
2474
+
 
2475
+v_sign sign_max_1 (v_sign a, v_sign b)
 
2476
+{
 
2477
+  return __builtin_altivec_vmaxsd (a, b);
 
2478
+}
 
2479
+
 
2480
+v_sign sign_max_2 (v_sign a, v_sign b)
 
2481
+{
 
2482
+  return vec_max (a, b);
 
2483
+}
 
2484
+
 
2485
+v_sign sign_max_3 (v_sign a, v_sign b)
 
2486
+{
 
2487
+  return vec_vmaxsd (a, b);
 
2488
+}
 
2489
+
 
2490
+v_sign sign_abs (v_sign a)
 
2491
+{
 
2492
+  return vec_abs (a);          /* xor, vsubudm, vmaxsd.  */
 
2493
+}
 
2494
+
 
2495
+v_bool sign_eq (v_sign a, v_sign b)
 
2496
+{
 
2497
+  return vec_cmpeq (a, b);
 
2498
+}
 
2499
+
 
2500
+v_bool sign_lt (v_sign a, v_sign b)
 
2501
+{
 
2502
+  return vec_cmplt (a, b);
 
2503
+}
 
2504
+
 
2505
+v_uns uns_add_2 (v_uns a, v_uns b)
 
2506
+{
 
2507
+  return vec_add (a, b);
 
2508
+}
 
2509
+
 
2510
+v_uns uns_add_3 (v_uns a, v_uns b)
 
2511
+{
 
2512
+  return vec_vaddudm (a, b);
 
2513
+}
 
2514
+
 
2515
+v_uns uns_sub_2 (v_uns a, v_uns b)
 
2516
+{
 
2517
+  return vec_sub (a, b);
 
2518
+}
 
2519
+
 
2520
+v_uns uns_sub_3 (v_uns a, v_uns b)
 
2521
+{
 
2522
+  return vec_vsubudm (a, b);
 
2523
+}
 
2524
+
 
2525
+v_uns uns_min_2 (v_uns a, v_uns b)
 
2526
+{
 
2527
+  return vec_min (a, b);
 
2528
+}
 
2529
+
 
2530
+v_uns uns_min_3 (v_uns a, v_uns b)
 
2531
+{
 
2532
+  return vec_vminud (a, b);
 
2533
+}
 
2534
+
 
2535
+v_uns uns_max_2 (v_uns a, v_uns b)
 
2536
+{
 
2537
+  return vec_max (a, b);
 
2538
+}
 
2539
+
 
2540
+v_uns uns_max_3 (v_uns a, v_uns b)
 
2541
+{
 
2542
+  return vec_vmaxud (a, b);
 
2543
+}
 
2544
+
 
2545
+v_bool uns_eq (v_uns a, v_uns b)
 
2546
+{
 
2547
+  return vec_cmpeq (a, b);
 
2548
+}
 
2549
+
 
2550
+v_bool uns_lt (v_uns a, v_uns b)
 
2551
+{
 
2552
+  return vec_cmplt (a, b);
 
2553
+}
 
2554
+
 
2555
+v_sign sign_rl_1 (v_sign a, v_sign b)
 
2556
+{
 
2557
+  return __builtin_altivec_vrld (a, b);
 
2558
+}
 
2559
+
 
2560
+v_sign sign_rl_2 (v_sign a, v_uns b)
 
2561
+{
 
2562
+  return vec_rl (a, b);
 
2563
+}
 
2564
+
 
2565
+v_uns uns_rl_2 (v_uns a, v_uns b)
 
2566
+{
 
2567
+  return vec_rl (a, b);
 
2568
+}
 
2569
+
 
2570
+v_sign sign_sl_1 (v_sign a, v_sign b)
 
2571
+{
 
2572
+  return __builtin_altivec_vsld (a, b);
 
2573
+}
 
2574
+
 
2575
+v_sign sign_sl_2 (v_sign a, v_uns b)
 
2576
+{
 
2577
+  return vec_sl (a, b);
 
2578
+}
 
2579
+
 
2580
+v_sign sign_sl_3 (v_sign a, v_uns b)
 
2581
+{
 
2582
+  return vec_vsld (a, b);
 
2583
+}
 
2584
+
 
2585
+v_uns uns_sl_2 (v_uns a, v_uns b)
 
2586
+{
 
2587
+  return vec_sl (a, b);
 
2588
+}
 
2589
+
 
2590
+v_uns uns_sl_3 (v_uns a, v_uns b)
 
2591
+{
 
2592
+  return vec_vsld (a, b);
 
2593
+}
 
2594
+
 
2595
+v_sign sign_sra_1 (v_sign a, v_sign b)
 
2596
+{
 
2597
+  return __builtin_altivec_vsrad (a, b);
 
2598
+}
 
2599
+
 
2600
+v_sign sign_sra_2 (v_sign a, v_uns b)
 
2601
+{
 
2602
+  return vec_sra (a, b);
 
2603
+}
 
2604
+
 
2605
+v_sign sign_sra_3 (v_sign a, v_uns b)
 
2606
+{
 
2607
+  return vec_vsrad (a, b);
 
2608
+}
 
2609
+
 
2610
+/* { dg-final { scan-assembler-times "vaddudm"         5 } } */
 
2611
+/* { dg-final { scan-assembler-times "vsubudm"         6 } } */
 
2612
+/* { dg-final { scan-assembler-times "vmaxsd"          4 } } */
 
2613
+/* { dg-final { scan-assembler-times "vminsd"          3 } } */
 
2614
+/* { dg-final { scan-assembler-times "vmaxud"          2 } } */
 
2615
+/* { dg-final { scan-assembler-times "vminud"          2 } } */
 
2616
+/* { dg-final { scan-assembler-times "vcmpequd" 2 } } */
 
2617
+/* { dg-final { scan-assembler-times "vcmpgtsd" 1 } } */
 
2618
+/* { dg-final { scan-assembler-times "vcmpgtud" 1 } } */
 
2619
+/* { dg-final { scan-assembler-times "vrld"     3 } } */
 
2620
+/* { dg-final { scan-assembler-times "vsld"     5 } } */
 
2621
+/* { dg-final { scan-assembler-times "vsrad"    3 } } */
 
2622
--- a/src/gcc/testsuite/gcc.target/powerpc/p8vector-vectorize-2.c
 
2623
+++ b/src/gcc/testsuite/gcc.target/powerpc/p8vector-vectorize-2.c
 
2624
@@ -0,0 +1,30 @@
 
2625
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
2626
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
2627
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
2628
+/* { dg-options "-mcpu=power8 -O2 -ftree-vectorize -fvect-cost-model" } */
 
2629
+
 
2630
+#include <stddef.h>
 
2631
+
 
2632
+#ifndef SIZE
 
2633
+#define SIZE 1024
 
2634
+#endif
 
2635
+
 
2636
+#ifndef ALIGN
 
2637
+#define ALIGN 32
 
2638
+#endif
 
2639
+
 
2640
+#define ALIGN_ATTR __attribute__((__aligned__(ALIGN)))
 
2641
+
 
2642
+long long sign_ll[SIZE]        ALIGN_ATTR;
 
2643
+int      sign_i [SIZE] ALIGN_ATTR;
 
2644
+
 
2645
+void copy_int_to_long_long (void)
 
2646
+{
 
2647
+  size_t i;
 
2648
+
 
2649
+  for (i = 0; i < SIZE; i++)
 
2650
+    sign_ll[i] = sign_i[i];
 
2651
+}
 
2652
+
 
2653
+/* { dg-final { scan-assembler "vupkhsw" } } */
 
2654
+/* { dg-final { scan-assembler "vupklsw" } } */
 
2655
--- a/src/gcc/testsuite/gcc.target/powerpc/altivec-perm-3.c
 
2656
+++ b/src/gcc/testsuite/gcc.target/powerpc/altivec-perm-3.c
 
2657
@@ -0,0 +1,23 @@
 
2658
+/* { dg-do compile } */
 
2659
+/* { dg-require-effective-target powerpc_altivec_ok } */
 
2660
+/* { dg-skip-if "" { powerpc*le-*-* } { "*" } { "" } } */
 
2661
+/* { dg-options "-O -maltivec -mno-vsx" } */
 
2662
+
 
2663
+typedef unsigned char V __attribute__((vector_size(16)));
 
2664
+
 
2665
+V p2(V x, V y)
 
2666
+{
 
2667
+  return __builtin_shuffle(x, y,
 
2668
+       (V){ 1,  3,  5,  7,  9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31 });
 
2669
+
 
2670
+}
 
2671
+
 
2672
+V p4(V x, V y)
 
2673
+{
 
2674
+  return __builtin_shuffle(x, y,
 
2675
+       (V){ 2,  3,  6,  7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31 });
 
2676
+}
 
2677
+
 
2678
+/* { dg-final { scan-assembler-not "vperm" } } */
 
2679
+/* { dg-final { scan-assembler "vpkuhum" } } */
 
2680
+/* { dg-final { scan-assembler "vpkuwum" } } */
 
2681
--- a/src/gcc/testsuite/gcc.target/powerpc/pr58673-1.c
 
2682
+++ b/src/gcc/testsuite/gcc.target/powerpc/pr58673-1.c
 
2683
@@ -0,0 +1,78 @@
 
2684
+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 
2685
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
2686
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
2687
+/* { dg-options "-mcpu=power8 -m64 -O1" } */
 
2688
+
 
2689
+enum typecode
 
2690
+{
 
2691
+  QIcode, QUcode, HIcode, HUcode, SIcode, SUcode, DIcode, DUcode, SFcode,
 
2692
+    DFcode, XFcode, Pcode, Tcode, LAST_AND_UNUSED_TYPECODE
 
2693
+};
 
2694
+enum bytecode_opcode
 
2695
+{
 
2696
+  neverneverland, drop, duplicate, over, setstackSI, adjstackSI, constQI,
 
2697
+    constHI, constSI, constDI, constSF, constDF, constXF, constP, loadQI,
 
2698
+    loadHI, loadSI, loadDI, loadSF, loadDF, loadXF, loadP, storeQI, storeHI,
 
2699
+    storeSI, storeDI, storeSF, storeDF, storeXF, storeP, storeBLK, clearBLK,
 
2700
+    addconstPSI, newlocalSI, localP, argP, convertQIHI, convertHISI,
 
2701
+    convertSIDI, convertQISI, convertQUHU, convertHUSU, convertSUDU,
 
2702
+    convertQUSU, convertSFDF, convertDFXF, convertHIQI, convertSIHI,
 
2703
+    convertDISI, convertSIQI, convertSUQU, convertDFSF, convertXFDF,
 
2704
+    convertSISF, convertSIDF, convertSIXF, convertSUSF, convertSUDF,
 
2705
+    convertSUXF, convertDISF, convertDIDF, convertDIXF, convertDUSF,
 
2706
+    convertDUDF, convertDUXF, convertSFSI, convertDFSI, convertXFSI,
 
2707
+    convertSFSU, convertDFSU, convertXFSU, convertSFDI, convertDFDI,
 
2708
+    convertXFDI, convertSFDU, convertDFDU, convertXFDU, convertPSI,
 
2709
+    convertSIP, convertSIT, convertDIT, convertSFT, convertDFT, convertXFT,
 
2710
+    convertPT, zxloadBI, sxloadBI, sstoreBI, addSI, addDI, addSF, addDF,
 
2711
+    addXF, addPSI, subSI, subDI, subSF, subDF, subXF, subPP, mulSI, mulDI,
 
2712
+    mulSU, mulDU, mulSF, mulDF, mulXF, divSI, divDI, divSU, divDU, divSF,
 
2713
+    divDF, divXF, modSI, modDI, modSU, modDU, andSI, andDI, iorSI, iorDI,
 
2714
+    xorSI, xorDI, lshiftSI, lshiftSU, lshiftDI, lshiftDU, rshiftSI, rshiftSU,
 
2715
+    rshiftDI, rshiftDU, ltSI, ltSU, ltDI, ltDU, ltSF, ltDF, ltXF, ltP, leSI,
 
2716
+    leSU, leDI, leDU, leSF, leDF, leXF, leP, geSI, geSU, geDI, geDU, geSF,
 
2717
+    geDF, geXF, geP, gtSI, gtSU, gtDI, gtDU, gtSF, gtDF, gtXF, gtP, eqSI,
 
2718
+    eqDI, eqSF, eqDF, eqXF, eqP, neSI, neDI, neSF, neDF, neXF, neP, negSI,
 
2719
+    negDI, negSF, negDF, negXF, notSI, notDI, notT, predecQI, predecHI,
 
2720
+    predecSI, predecDI, predecP, predecSF, predecDF, predecXF, predecBI,
 
2721
+    preincQI, preincHI, preincSI, preincDI, preincP, preincSF, preincDF,
 
2722
+    preincXF, preincBI, postdecQI, postdecHI, postdecSI, postdecDI, postdecP,
 
2723
+    postdecSF, postdecDF, postdecXF, postdecBI, postincQI, postincHI,
 
2724
+    postincSI, postincDI, postincP, postincSF, postincDF, postincXF,
 
2725
+    postincBI, xjumpif, xjumpifnot, jump, jumpP, caseSI, caseSU, caseDI,
 
2726
+    caseDU, call, returnP, ret, linenote, LAST_AND_UNUSED_OPCODE
 
2727
+};
 
2728
+struct binary_operator
 
2729
+{
 
2730
+  enum bytecode_opcode opcode;
 
2731
+  enum typecode arg0;
 
2732
+};
 
2733
+static struct conversion_recipe
 
2734
+{
 
2735
+  unsigned char *opcodes;
 
2736
+  int cost;
 
2737
+}
 
2738
+conversion_recipe[((int) LAST_AND_UNUSED_TYPECODE)][((int)
 
2739
+                                                    LAST_AND_UNUSED_TYPECODE)];
 
2740
+static struct conversion_recipe
 
2741
+deduce_conversion (from, to)
 
2742
+     enum typecode from, to;
 
2743
+{
 
2744
+  (conversion_recipe[(int) from][(int) to].
 
2745
+   opcodes ? 0 : (conversion_recipe[(int) from][(int) to] =
 
2746
+                 deduce_conversion (from, to), 0));
 
2747
+}
 
2748
+
 
2749
+void
 
2750
+bc_expand_binary_operation (optab, resulttype, arg0, arg1)
 
2751
+     struct binary_operator optab[];
 
2752
+{
 
2753
+  int i, besti, cost, bestcost;
 
2754
+  enum typecode resultcode, arg0code;
 
2755
+  for (i = 0; optab[i].opcode != -1; ++i)
 
2756
+    {
 
2757
+      (conversion_recipe[(int) arg0code][(int) optab[i].arg0].
 
2758
+       opcodes ? 0 : (conversion_recipe[(int) arg0code][(int) optab[i].arg0] =
 
2759
+                     deduce_conversion (arg0code, optab[i].arg0), 0));
 
2760
+    }
 
2761
+}
 
2762
--- a/src/gcc/testsuite/gcc.target/powerpc/no-r11-1.c
 
2763
+++ b/src/gcc/testsuite/gcc.target/powerpc/no-r11-1.c
 
2764
@@ -1,5 +1,6 @@
 
2765
 /* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 
2766
 /* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */
 
2767
+/* { dg-skip-if "" { powerpc_elfv2 } { "*" } { "" } } */
 
2768
 /* { dg-options "-O2 -mno-pointers-to-nested-functions" } */
 
2769
 
 
2770
 int
 
2771
--- a/src/gcc/testsuite/gcc.target/powerpc/p8vector-fp.c
 
2772
+++ b/src/gcc/testsuite/gcc.target/powerpc/p8vector-fp.c
 
2773
@@ -0,0 +1,139 @@
 
2774
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
2775
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
2776
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
2777
+/* { dg-options "-mcpu=power8 -O2 -mupper-regs-df -mupper-regs-sf -fno-math-errno" } */
 
2778
+
 
2779
+float abs_sf (float *p)
 
2780
+{
 
2781
+  float f = *p;
 
2782
+  __asm__ ("# reg %x0" : "+v" (f));
 
2783
+  return __builtin_fabsf (f);
 
2784
+}
 
2785
+
 
2786
+float nabs_sf (float *p)
 
2787
+{
 
2788
+  float f = *p;
 
2789
+  __asm__ ("# reg %x0" : "+v" (f));
 
2790
+  return - __builtin_fabsf (f);
 
2791
+}
 
2792
+
 
2793
+float neg_sf (float *p)
 
2794
+{
 
2795
+  float f = *p;
 
2796
+  __asm__ ("# reg %x0" : "+v" (f));
 
2797
+  return - f;
 
2798
+}
 
2799
+
 
2800
+float add_sf (float *p, float *q)
 
2801
+{
 
2802
+  float f1 = *p;
 
2803
+  float f2 = *q;
 
2804
+  __asm__ ("# reg %x0, %x1" : "+v" (f1), "+v" (f2));
 
2805
+  return f1 + f2;
 
2806
+}
 
2807
+
 
2808
+float sub_sf (float *p, float *q)
 
2809
+{
 
2810
+  float f1 = *p;
 
2811
+  float f2 = *q;
 
2812
+  __asm__ ("# reg %x0, %x1" : "+v" (f1), "+v" (f2));
 
2813
+  return f1 - f2;
 
2814
+}
 
2815
+
 
2816
+float mul_sf (float *p, float *q)
 
2817
+{
 
2818
+  float f1 = *p;
 
2819
+  float f2 = *q;
 
2820
+  __asm__ ("# reg %x0, %x1" : "+v" (f1), "+v" (f2));
 
2821
+  return f1 * f2;
 
2822
+}
 
2823
+
 
2824
+float div_sf (float *p, float *q)
 
2825
+{
 
2826
+  float f1 = *p;
 
2827
+  float f2 = *q;
 
2828
+  __asm__ ("# reg %x0, %x1" : "+v" (f1), "+v" (f2));
 
2829
+  return f1 / f2;
 
2830
+}
 
2831
+
 
2832
+float sqrt_sf (float *p)
 
2833
+{
 
2834
+  float f = *p;
 
2835
+  __asm__ ("# reg %x0" : "+v" (f));
 
2836
+  return __builtin_sqrtf (f);
 
2837
+}
 
2838
+
 
2839
+
 
2840
+double abs_df (double *p)
 
2841
+{
 
2842
+  double d = *p;
 
2843
+  __asm__ ("# reg %x0" : "+v" (d));
 
2844
+  return __builtin_fabs (d);
 
2845
+}
 
2846
+
 
2847
+double nabs_df (double *p)
 
2848
+{
 
2849
+  double d = *p;
 
2850
+  __asm__ ("# reg %x0" : "+v" (d));
 
2851
+  return - __builtin_fabs (d);
 
2852
+}
 
2853
+
 
2854
+double neg_df (double *p)
 
2855
+{
 
2856
+  double d = *p;
 
2857
+  __asm__ ("# reg %x0" : "+v" (d));
 
2858
+  return - d;
 
2859
+}
 
2860
+
 
2861
+double add_df (double *p, double *q)
 
2862
+{
 
2863
+  double d1 = *p;
 
2864
+  double d2 = *q;
 
2865
+  __asm__ ("# reg %x0, %x1" : "+v" (d1), "+v" (d2));
 
2866
+  return d1 + d2;
 
2867
+}
 
2868
+
 
2869
+double sub_df (double *p, double *q)
 
2870
+{
 
2871
+  double d1 = *p;
 
2872
+  double d2 = *q;
 
2873
+  __asm__ ("# reg %x0, %x1" : "+v" (d1), "+v" (d2));
 
2874
+  return d1 - d2;
 
2875
+}
 
2876
+
 
2877
+double mul_df (double *p, double *q)
 
2878
+{
 
2879
+  double d1 = *p;
 
2880
+  double d2 = *q;
 
2881
+  __asm__ ("# reg %x0, %x1" : "+v" (d1), "+v" (d2));
 
2882
+  return d1 * d2;
 
2883
+}
 
2884
+
 
2885
+double div_df (double *p, double *q)
 
2886
+{
 
2887
+  double d1 = *p;
 
2888
+  double d2 = *q;
 
2889
+  __asm__ ("# reg %x0, %x1" : "+v" (d1), "+v" (d2));
 
2890
+  return d1 / d2;
 
2891
+}
 
2892
+
 
2893
+double sqrt_df (float *p)
 
2894
+{
 
2895
+  double d = *p;
 
2896
+  __asm__ ("# reg %x0" : "+v" (d));
 
2897
+  return __builtin_sqrt (d);
 
2898
+}
 
2899
+
 
2900
+/* { dg-final { scan-assembler "xsabsdp"  } } */
 
2901
+/* { dg-final { scan-assembler "xsadddp"  } } */
 
2902
+/* { dg-final { scan-assembler "xsaddsp"  } } */
 
2903
+/* { dg-final { scan-assembler "xsdivdp"  } } */
 
2904
+/* { dg-final { scan-assembler "xsdivsp"  } } */
 
2905
+/* { dg-final { scan-assembler "xsmuldp"  } } */
 
2906
+/* { dg-final { scan-assembler "xsmulsp"  } } */
 
2907
+/* { dg-final { scan-assembler "xsnabsdp" } } */
 
2908
+/* { dg-final { scan-assembler "xsnegdp"  } } */
 
2909
+/* { dg-final { scan-assembler "xssqrtdp" } } */
 
2910
+/* { dg-final { scan-assembler "xssqrtsp" } } */
 
2911
+/* { dg-final { scan-assembler "xssubdp"  } } */
 
2912
+/* { dg-final { scan-assembler "xssubsp"  } } */
 
2913
--- a/src/gcc/testsuite/gcc.target/powerpc/direct-move-vint2.c
 
2914
+++ b/src/gcc/testsuite/gcc.target/powerpc/direct-move-vint2.c
 
2915
@@ -0,0 +1,13 @@
 
2916
+/* { dg-do run { target { powerpc*-*-linux* && lp64 } } } */
 
2917
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
2918
+/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
 
2919
+/* { dg-require-effective-target p8vector_hw } */
 
2920
+/* { dg-options "-mcpu=power8 -O2" } */
 
2921
+
 
2922
+/* Check whether we get the right bits for direct move at runtime.  */
 
2923
+
 
2924
+#define TYPE vector int
 
2925
+#define DO_MAIN
 
2926
+#define VSX_REG_ATTR "wa"
 
2927
+
 
2928
+#include "direct-move.h"
 
2929
--- a/src/gcc/testsuite/gcc.target/powerpc/bool3-p7.c
 
2930
+++ b/src/gcc/testsuite/gcc.target/powerpc/bool3-p7.c
 
2931
@@ -0,0 +1,37 @@
 
2932
+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 
2933
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
2934
+/* { dg-require-effective-target powerpc_vsx_ok } */
 
2935
+/* { dg-options "-O2 -mcpu=power7" } */
 
2936
+/* { dg-final { scan-assembler    "\[ \t\]and "     } } */
 
2937
+/* { dg-final { scan-assembler    "\[ \t\]or "      } } */
 
2938
+/* { dg-final { scan-assembler    "\[ \t\]xor "     } } */
 
2939
+/* { dg-final { scan-assembler    "\[ \t\]nor "     } } */
 
2940
+/* { dg-final { scan-assembler    "\[ \t\]andc "    } } */
 
2941
+/* { dg-final { scan-assembler-not "\[ \t\]vand "    } } */
 
2942
+/* { dg-final { scan-assembler-not "\[ \t\]vandc "   } } */
 
2943
+/* { dg-final { scan-assembler-not "\[ \t\]vor "     } } */
 
2944
+/* { dg-final { scan-assembler-not "\[ \t\]vxor "    } } */
 
2945
+/* { dg-final { scan-assembler-not "\[ \t\]vnor "    } } */
 
2946
+/* { dg-final { scan-assembler-not "\[ \t\]xxland "  } } */
 
2947
+/* { dg-final { scan-assembler-not "\[ \t\]xxlor "   } } */
 
2948
+/* { dg-final { scan-assembler-not "\[ \t\]xxlxor "  } } */
 
2949
+/* { dg-final { scan-assembler-not "\[ \t\]xxlnor "  } } */
 
2950
+/* { dg-final { scan-assembler-not "\[ \t\]xxlandc " } } */
 
2951
+/* { dg-final { scan-assembler-not "\[ \t\]xxleqv "  } } */
 
2952
+/* { dg-final { scan-assembler-not "\[ \t\]xxlorc "  } } */
 
2953
+/* { dg-final { scan-assembler-not "\[ \t\]xxlnand " } } */
 
2954
+
 
2955
+/* On power7, for 128-bit types, ORC/ANDC/EQV might not show up, since the
 
2956
+   vector unit doesn't support these, so the appropriate combine patterns may
 
2957
+   not be generated.  */
 
2958
+
 
2959
+#ifndef TYPE
 
2960
+#ifdef _ARCH_PPC64
 
2961
+#define TYPE __int128_t
 
2962
+#else
 
2963
+typedef int v4si __attribute__ ((vector_size (16)));
 
2964
+#define TYPE v4si
 
2965
+#endif
 
2966
+#endif
 
2967
+
 
2968
+#include "bool3.h"
 
2969
--- a/src/gcc/testsuite/gcc.target/powerpc/p8vector-builtin-3.c
 
2970
+++ b/src/gcc/testsuite/gcc.target/powerpc/p8vector-builtin-3.c
 
2971
@@ -0,0 +1,104 @@
 
2972
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
2973
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
2974
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
2975
+/* { dg-options "-mcpu=power8 -O3 -ftree-vectorize -fvect-cost-model" } */
 
2976
+
 
2977
+#include <altivec.h>
 
2978
+
 
2979
+typedef vector long long               vll_sign;
 
2980
+typedef vector unsigned long long      vll_uns;
 
2981
+typedef vector bool long long          vll_bool;
 
2982
+
 
2983
+typedef vector int                     vi_sign;
 
2984
+typedef vector unsigned int            vi_uns;
 
2985
+typedef vector bool int                        vi_bool;
 
2986
+
 
2987
+typedef vector short                   vs_sign;
 
2988
+typedef vector unsigned short          vs_uns;
 
2989
+typedef vector bool short              vs_bool;
 
2990
+
 
2991
+typedef vector signed char             vc_sign;
 
2992
+typedef vector unsigned char           vc_uns;
 
2993
+typedef vector bool char               vc_bool;
 
2994
+
 
2995
+
 
2996
+vi_sign vi_pack_1 (vll_sign a, vll_sign b)
 
2997
+{
 
2998
+  return __builtin_altivec_vpkudum (a, b);
 
2999
+}
 
3000
+
 
3001
+vi_sign vi_pack_2 (vll_sign a, vll_sign b)
 
3002
+{
 
3003
+  return vec_pack (a, b);
 
3004
+}
 
3005
+
 
3006
+vi_sign vi_pack_3 (vll_sign a, vll_sign b)
 
3007
+{
 
3008
+  return vec_vpkudum (a, b);
 
3009
+}
 
3010
+
 
3011
+vs_sign vs_pack_1 (vi_sign a, vi_sign b)
 
3012
+{
 
3013
+  return __builtin_altivec_vpkuwum (a, b);
 
3014
+}
 
3015
+
 
3016
+vs_sign vs_pack_2 (vi_sign a, vi_sign b)
 
3017
+{
 
3018
+  return vec_pack (a, b);
 
3019
+}
 
3020
+
 
3021
+vs_sign vs_pack_3 (vi_sign a, vi_sign b)
 
3022
+{
 
3023
+  return vec_vpkuwum (a, b);
 
3024
+}
 
3025
+
 
3026
+vc_sign vc_pack_1 (vs_sign a, vs_sign b)
 
3027
+{
 
3028
+  return __builtin_altivec_vpkuhum (a, b);
 
3029
+}
 
3030
+
 
3031
+vc_sign vc_pack_2 (vs_sign a, vs_sign b)
 
3032
+{
 
3033
+  return vec_pack (a, b);
 
3034
+}
 
3035
+
 
3036
+vc_sign vc_pack_3 (vs_sign a, vs_sign b)
 
3037
+{
 
3038
+  return vec_vpkuhum (a, b);
 
3039
+}
 
3040
+
 
3041
+vll_sign vll_unpack_hi_1 (vi_sign a)
 
3042
+{
 
3043
+  return __builtin_altivec_vupkhsw (a);
 
3044
+}
 
3045
+
 
3046
+vll_sign vll_unpack_hi_2 (vi_sign a)
 
3047
+{
 
3048
+  return vec_unpackh (a);
 
3049
+}
 
3050
+
 
3051
+vll_sign vll_unpack_hi_3 (vi_sign a)
 
3052
+{
 
3053
+  return __builtin_vec_vupkhsw (a);
 
3054
+}
 
3055
+
 
3056
+vll_sign vll_unpack_lo_1 (vi_sign a)
 
3057
+{
 
3058
+  return vec_vupklsw (a);
 
3059
+}
 
3060
+
 
3061
+vll_sign vll_unpack_lo_2 (vi_sign a)
 
3062
+{
 
3063
+  return vec_unpackl (a);
 
3064
+}
 
3065
+
 
3066
+vll_sign vll_unpack_lo_3 (vi_sign a)
 
3067
+{
 
3068
+  return vec_vupklsw (a);
 
3069
+}
 
3070
+
 
3071
+/* { dg-final { scan-assembler-times "vpkudum" 3 } } */
 
3072
+/* { dg-final { scan-assembler-times "vpkuwum" 3 } } */
 
3073
+/* { dg-final { scan-assembler-times "vpkuhum" 3 } } */
 
3074
+/* { dg-final { scan-assembler-times "vupklsw" 3 } } */
 
3075
+/* { dg-final { scan-assembler-times "vupkhsw" 3 } } */
 
3076
--- a/src/gcc/testsuite/gcc.target/powerpc/p8vector-vectorize-3.c
 
3077
+++ b/src/gcc/testsuite/gcc.target/powerpc/p8vector-vectorize-3.c
 
3078
@@ -0,0 +1,29 @@
 
3079
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
3080
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
3081
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
3082
+/* { dg-options "-mcpu=power8 -O2 -ftree-vectorize -fvect-cost-model" } */
 
3083
+
 
3084
+#include <stddef.h>
 
3085
+
 
3086
+#ifndef SIZE
 
3087
+#define SIZE 1024
 
3088
+#endif
 
3089
+
 
3090
+#ifndef ALIGN
 
3091
+#define ALIGN 32
 
3092
+#endif
 
3093
+
 
3094
+#define ALIGN_ATTR __attribute__((__aligned__(ALIGN)))
 
3095
+
 
3096
+long long sign_ll[SIZE]        ALIGN_ATTR;
 
3097
+int      sign_i [SIZE] ALIGN_ATTR;
 
3098
+
 
3099
+void copy_long_long_to_int (void)
 
3100
+{
 
3101
+  size_t i;
 
3102
+
 
3103
+  for (i = 0; i < SIZE; i++)
 
3104
+    sign_i[i] = sign_ll[i];
 
3105
+}
 
3106
+
 
3107
+/* { dg-final { scan-assembler "vpkudum" } } */
 
3108
--- a/src/gcc/testsuite/gcc.target/powerpc/direct-move.h
 
3109
+++ b/src/gcc/testsuite/gcc.target/powerpc/direct-move.h
 
3110
@@ -0,0 +1,187 @@
 
3111
+/* Test functions for direct move support.  */
 
3112
+
 
3113
+
 
3114
+#ifndef VSX_REG_ATTR
 
3115
+#define VSX_REG_ATTR "wa"
 
3116
+#endif
 
3117
+
 
3118
+void __attribute__((__noinline__))
 
3119
+copy (TYPE *a, TYPE *b)
 
3120
+{
 
3121
+  *b = *a;
 
3122
+}
 
3123
+
 
3124
+#ifndef NO_GPR
 
3125
+void __attribute__((__noinline__))
 
3126
+load_gpr (TYPE *a, TYPE *b)
 
3127
+{
 
3128
+  TYPE c = *a;
 
3129
+  __asm__ ("# gpr, reg = %0" : "+b" (c));
 
3130
+  *b = c;
 
3131
+}
 
3132
+#endif
 
3133
+
 
3134
+#ifndef NO_FPR
 
3135
+void __attribute__((__noinline__))
 
3136
+load_fpr (TYPE *a, TYPE *b)
 
3137
+{
 
3138
+  TYPE c = *a;
 
3139
+  __asm__ ("# fpr, reg = %0" : "+d" (c));
 
3140
+  *b = c;
 
3141
+}
 
3142
+#endif
 
3143
+
 
3144
+#ifndef NO_ALTIVEC
 
3145
+void __attribute__((__noinline__))
 
3146
+load_altivec (TYPE *a, TYPE *b)
 
3147
+{
 
3148
+  TYPE c = *a;
 
3149
+  __asm__ ("# altivec, reg = %0" : "+v" (c));
 
3150
+  *b = c;
 
3151
+}
 
3152
+#endif
 
3153
+
 
3154
+#ifndef NO_VSX
 
3155
+void __attribute__((__noinline__))
 
3156
+load_vsx (TYPE *a, TYPE *b)
 
3157
+{
 
3158
+  TYPE c = *a;
 
3159
+  __asm__ ("# vsx, reg = %x0" : "+" VSX_REG_ATTR (c));
 
3160
+  *b = c;
 
3161
+}
 
3162
+#endif
 
3163
+
 
3164
+#ifndef NO_GPR_TO_VSX
 
3165
+void __attribute__((__noinline__))
 
3166
+load_gpr_to_vsx (TYPE *a, TYPE *b)
 
3167
+{
 
3168
+  TYPE c = *a;
 
3169
+  TYPE d;
 
3170
+  __asm__ ("# gpr, reg = %0" : "+b" (c));
 
3171
+  d = c;
 
3172
+  __asm__ ("# vsx, reg = %x0" : "+" VSX_REG_ATTR (d));
 
3173
+  *b = d;
 
3174
+}
 
3175
+#endif
 
3176
+
 
3177
+#ifndef NO_VSX_TO_GPR
 
3178
+void __attribute__((__noinline__))
 
3179
+load_vsx_to_gpr (TYPE *a, TYPE *b)
 
3180
+{
 
3181
+  TYPE c = *a;
 
3182
+  TYPE d;
 
3183
+  __asm__ ("# vsx, reg = %x0" : "+" VSX_REG_ATTR (c));
 
3184
+  d = c;
 
3185
+  __asm__ ("# gpr, reg = %0" : "+b" (d));
 
3186
+  *b = d;
 
3187
+}
 
3188
+#endif
 
3189
+
 
3190
+#ifdef DO_MAIN
 
3191
+typedef void (fn_type (TYPE *, TYPE *));
 
3192
+
 
3193
+struct test_struct {
 
3194
+  fn_type *func;
 
3195
+  const char *name;
 
3196
+};
 
3197
+
 
3198
+const struct test_struct test_functions[] = {
 
3199
+  { copy,              "copy"            },
 
3200
+#ifndef NO_GPR
 
3201
+  { load_gpr,          "load_gpr"        },
 
3202
+#endif
 
3203
+#ifndef NO_FPR
 
3204
+  { load_fpr,          "load_fpr"        },
 
3205
+#endif
 
3206
+#ifndef NO_ALTIVEC
 
3207
+  { load_altivec,      "load_altivec"    },
 
3208
+#endif
 
3209
+#ifndef NO_VSX
 
3210
+  { load_vsx,          "load_vsx"        },
 
3211
+#endif
 
3212
+#ifndef NO_GPR_TO_VSX
 
3213
+  { load_gpr_to_vsx,   "load_gpr_to_vsx" },
 
3214
+#endif
 
3215
+#ifndef NO_VSX_TO_GPR
 
3216
+  { load_vsx_to_gpr,   "load_vsx_to_gpr" },
 
3217
+#endif
 
3218
+};
 
3219
+
 
3220
+/* Test a given value for each of the functions.  */
 
3221
+void __attribute__((__noinline__))
 
3222
+test_value (TYPE a)
 
3223
+{
 
3224
+  size_t i;
 
3225
+
 
3226
+  for (i = 0; i < sizeof (test_functions) / sizeof (test_functions[0]); i++)
 
3227
+    {
 
3228
+      TYPE b;
 
3229
+
 
3230
+      test_functions[i].func (&a, &b);
 
3231
+      if (memcmp ((void *)&a, (void *)&b, sizeof (TYPE)) != 0)
 
3232
+       abort ();
 
3233
+    }
 
3234
+}
 
3235
+
 
3236
+/* Main program.  */
 
3237
+int
 
3238
+main (void)
 
3239
+{
 
3240
+  size_t i;
 
3241
+  long j;
 
3242
+  union {
 
3243
+    TYPE value;
 
3244
+    unsigned char bytes[sizeof (TYPE)];
 
3245
+  } u;
 
3246
+
 
3247
+#if IS_INT
 
3248
+  TYPE value = (TYPE)-5;
 
3249
+  for (i = 0; i < 12; i++)
 
3250
+    {
 
3251
+      test_value (value);
 
3252
+      value++;
 
3253
+    }
 
3254
+
 
3255
+  for (i = 0; i < 8*sizeof (TYPE); i++)
 
3256
+    test_value (((TYPE)1) << i);
 
3257
+
 
3258
+#elif IS_UNS
 
3259
+  TYPE value = (TYPE)0;
 
3260
+  for (i = 0; i < 10; i++)
 
3261
+    {
 
3262
+      test_value (value);
 
3263
+      test_value (~ value);
 
3264
+      value++;
 
3265
+    }
 
3266
+
 
3267
+  for (i = 0; i < 8*sizeof (TYPE); i++)
 
3268
+    test_value (((TYPE)1) << i);
 
3269
+
 
3270
+#elif IS_FLOAT
 
3271
+  TYPE value = (TYPE)-5;
 
3272
+  for (i = 0; i < 12; i++)
 
3273
+    {
 
3274
+      test_value (value);
 
3275
+      value++;
 
3276
+    }
 
3277
+
 
3278
+  test_value ((TYPE)3.1415926535);
 
3279
+  test_value ((TYPE)1.23456);
 
3280
+  test_value ((TYPE)(-0.0));
 
3281
+  test_value ((TYPE)NAN);
 
3282
+  test_value ((TYPE)+INFINITY);
 
3283
+  test_value ((TYPE)-INFINITY);
 
3284
+#else
 
3285
+
 
3286
+  for (j = 0; j < 10; j++)
 
3287
+    {
 
3288
+      for (i = 0; i < sizeof (TYPE); i++)
 
3289
+       u.bytes[i] = (unsigned char) (random () >> 4);
 
3290
+
 
3291
+      test_value (u.value);
 
3292
+    }
 
3293
+#endif
 
3294
+
 
3295
+  return 0;
 
3296
+}
 
3297
+#endif
 
3298
--- a/src/gcc/testsuite/gcc.target/powerpc/sd-vsx.c
 
3299
+++ b/src/gcc/testsuite/gcc.target/powerpc/sd-vsx.c
 
3300
@@ -0,0 +1,20 @@
 
3301
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
3302
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
3303
+/* { dg-require-effective-target powerpc_vsx_ok } */
 
3304
+/* { dg-options "-O2 -mcpu=power7 -mhard-dfp" } */
 
3305
+/* { dg-final { scan-assembler-times "lfiwzx" 2 } } */
 
3306
+/* { dg-final { scan-assembler-times "stfiwx" 1 } } */
 
3307
+/* { dg-final { scan-assembler-not   "lfd"      } } */
 
3308
+/* { dg-final { scan-assembler-not   "stfd"     } } */
 
3309
+/* { dg-final { scan-assembler-times "dctdp"  2 } } */
 
3310
+/* { dg-final { scan-assembler-times "dadd"   1 } } */
 
3311
+/* { dg-final { scan-assembler-times "drsp"   1 } } */
 
3312
+
 
3313
+/* Test that power7 can directly load/store SDmode variables without using a
 
3314
+   bounce buffer.  */
 
3315
+_Decimal32 a;
 
3316
+
 
3317
+void inc_dec32 (void)
 
3318
+{
 
3319
+  a += (_Decimal32) 1.0;
 
3320
+}
 
3321
--- a/src/gcc/testsuite/gcc.target/powerpc/pr58673-2.c
 
3322
+++ b/src/gcc/testsuite/gcc.target/powerpc/pr58673-2.c
 
3323
@@ -0,0 +1,217 @@
 
3324
+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 
3325
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
3326
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
3327
+/* { dg-options "-mcpu=power8 -O3 -m64 -funroll-loops" } */
 
3328
+
 
3329
+#include <stddef.h>
 
3330
+#include <stdlib.h>
 
3331
+#include <math.h>
 
3332
+#include <string.h>
 
3333
+
 
3334
+typedef long unsigned int size_t;
 
3335
+typedef struct _IO_FILE FILE;
 
3336
+typedef float real;
 
3337
+typedef real rvec[3];
 
3338
+typedef real matrix[3][3];
 
3339
+typedef real tensor[3][3];
 
3340
+enum
 
3341
+{
 
3342
+  F_BONDS, F_G96BONDS, F_MORSE, F_CUBICBONDS, F_CONNBONDS, F_HARMONIC,
 
3343
+    F_ANGLES, F_G96ANGLES, F_PDIHS, F_RBDIHS, F_IDIHS, F_LJ14, F_COUL14, F_LJ,
 
3344
+    F_BHAM, F_LJLR, F_DISPCORR, F_SR, F_LR, F_WPOL, F_POSRES, F_DISRES,
 
3345
+    F_DISRESVIOL, F_ORIRES, F_ORIRESDEV, F_ANGRES, F_ANGRESZ, F_SHAKE,
 
3346
+    F_SHAKENC, F_SETTLE, F_DUMMY2, F_DUMMY3, F_DUMMY3FD, F_DUMMY3FAD,
 
3347
+    F_DUMMY3OUT, F_DUMMY4FD, F_EQM, F_EPOT, F_EKIN, F_ETOT, F_TEMP, F_PRES,
 
3348
+    F_DVDL, F_DVDLKIN, F_NRE
 
3349
+};
 
3350
+typedef union
 
3351
+{
 
3352
+  struct
 
3353
+  {
 
3354
+  }
 
3355
+  bham;
 
3356
+  struct
 
3357
+  {
 
3358
+    real rA, krA, rB, krB;
 
3359
+  }
 
3360
+  harmonic;
 
3361
+}
 
3362
+t_iparams;
 
3363
+typedef struct
 
3364
+{
 
3365
+  t_iparams *iparams;
 
3366
+}
 
3367
+t_idef;
 
3368
+typedef struct
 
3369
+{
 
3370
+}
 
3371
+t_inputrec;
 
3372
+typedef struct
 
3373
+{
 
3374
+}
 
3375
+t_commrec;
 
3376
+typedef struct
 
3377
+{
 
3378
+}
 
3379
+t_forcerec;
 
3380
+typedef struct
 
3381
+{
 
3382
+}
 
3383
+t_mdatoms;
 
3384
+typedef struct
 
3385
+{
 
3386
+}
 
3387
+t_filenm;
 
3388
+enum
 
3389
+{
 
3390
+  eoPres, eoEpot, eoVir, eoDist, eoMu, eoForce, eoFx, eoFy, eoFz, eoPx, eoPy,
 
3391
+    eoPz, eoPolarizability, eoDipole, eoObsNR, eoMemory =
 
3392
+    eoObsNR, eoInter, eoUseVirial, eoNR
 
3393
+};
 
3394
+extern char *eoNames[eoNR];
 
3395
+typedef struct
 
3396
+{
 
3397
+  int bPrint;
 
3398
+}
 
3399
+t_coupl_LJ;
 
3400
+typedef struct
 
3401
+{
 
3402
+  int eObs;
 
3403
+  t_iparams xi;
 
3404
+}
 
3405
+t_coupl_iparams;
 
3406
+typedef struct
 
3407
+{
 
3408
+  real act_value[eoObsNR];
 
3409
+  real av_value[eoObsNR];
 
3410
+  real ref_value[eoObsNR];
 
3411
+  int bObsUsed[eoObsNR];
 
3412
+  int nLJ, nBU, nQ, nIP;
 
3413
+  t_coupl_LJ *tcLJ;
 
3414
+}
 
3415
+t_coupl_rec;
 
3416
+static void
 
3417
+pr_ff (t_coupl_rec * tcr, real time, t_idef * idef, t_commrec * cr, int nfile,
 
3418
+       t_filenm fnm[])
 
3419
+{
 
3420
+  static FILE *prop;
 
3421
+  static FILE **out = ((void *) 0);
 
3422
+  static FILE **qq = ((void *) 0);
 
3423
+  static FILE **ip = ((void *) 0);
 
3424
+  char buf[256];
 
3425
+  char *leg[] = {
 
3426
+    "C12", "C6"
 
3427
+  };
 
3428
+  char **raleg;
 
3429
+  int i, j, index;
 
3430
+  if ((prop == ((void *) 0)) && (out == ((void *) 0)) && (qq == ((void *) 0))
 
3431
+      && (ip == ((void *) 0)))
 
3432
+    {
 
3433
+      for (i = j = 0; (i < eoObsNR); i++)
 
3434
+       {
 
3435
+         if (tcr->bObsUsed[i])
 
3436
+           {
 
3437
+             raleg[j++] =
 
3438
+               (__extension__
 
3439
+                (__builtin_constant_p (eoNames[i])
 
3440
+                 && ((size_t) (const void *) ((eoNames[i]) + 1) -
 
3441
+                     (size_t) (const void *) (eoNames[i]) ==
 
3442
+                     1) ? (((const char *) (eoNames[i]))[0] ==
 
3443
+                           '\0' ? (char *) calloc ((size_t) 1,
 
3444
+                                                   (size_t) 1) : (
 
3445
+                                                                          {
 
3446
+                                                                          size_t
 
3447
+                                                                          __len
 
3448
+                                                                          =
 
3449
+                                                                          strlen
 
3450
+                                                                          (eoNames
 
3451
+                                                                           [i])
 
3452
+                                                                          +
 
3453
+                                                                          1;
 
3454
+                                                                          char
 
3455
+                                                                          *__retval
 
3456
+                                                                          =
 
3457
+                                                                          (char
 
3458
+                                                                           *)
 
3459
+                                                                          malloc
 
3460
+                                                                          (__len);
 
3461
+                                                                          __retval;}
 
3462
+           )):     __strdup (eoNames[i])));
 
3463
+             raleg[j++] =
 
3464
+               (__extension__
 
3465
+                (__builtin_constant_p (buf)
 
3466
+                 && ((size_t) (const void *) ((buf) + 1) -
 
3467
+                     (size_t) (const void *) (buf) ==
 
3468
+                     1) ? (((const char *) (buf))[0] ==
 
3469
+                           '\0' ? (char *) calloc ((size_t) 1,
 
3470
+                                                   (size_t) 1) : (
 
3471
+                                                                          {
 
3472
+                                                                          size_t
 
3473
+                                                                          __len
 
3474
+                                                                          =
 
3475
+                                                                          strlen
 
3476
+                                                                          (buf)
 
3477
+                                                                          +
 
3478
+                                                                          1;
 
3479
+                                                                          char
 
3480
+                                                                          *__retval
 
3481
+                                                                          =
 
3482
+                                                                          (char
 
3483
+                                                                           *)
 
3484
+                                                                          malloc
 
3485
+                                                                          (__len);
 
3486
+                                                                          __retval;}
 
3487
+           )):     __strdup (buf)));
 
3488
+           }
 
3489
+       }
 
3490
+      if (tcr->nLJ)
 
3491
+       {
 
3492
+         for (i = 0; (i < tcr->nLJ); i++)
 
3493
+           {
 
3494
+             if (tcr->tcLJ[i].bPrint)
 
3495
+               {
 
3496
+                 xvgr_legend (out[i], (sizeof (leg) / sizeof ((leg)[0])),
 
3497
+                              leg);
 
3498
+               }
 
3499
+           }
 
3500
+       }
 
3501
+    }
 
3502
+}
 
3503
+
 
3504
+void
 
3505
+do_coupling (FILE * log, int nfile, t_filenm fnm[], t_coupl_rec * tcr, real t,
 
3506
+            int step, real ener[], t_forcerec * fr, t_inputrec * ir,
 
3507
+            int bMaster, t_mdatoms * md, t_idef * idef, real mu_aver,
 
3508
+            int nmols, t_commrec * cr, matrix box, tensor virial,
 
3509
+            tensor pres, rvec mu_tot, rvec x[], rvec f[], int bDoIt)
 
3510
+{
 
3511
+  int i, j, ati, atj, atnr2, type, ftype;
 
3512
+  real deviation[eoObsNR], prdev[eoObsNR], epot0, dist, rmsf;
 
3513
+  real ff6, ff12, ffa, ffb, ffc, ffq, factor, dt, mu_ind;
 
3514
+  int bTest, bPrint;
 
3515
+  t_coupl_iparams *tip;
 
3516
+  if (bPrint)
 
3517
+    {
 
3518
+      pr_ff (tcr, t, idef, cr, nfile, fnm);
 
3519
+    }
 
3520
+  for (i = 0; (i < eoObsNR); i++)
 
3521
+    {
 
3522
+      deviation[i] =
 
3523
+       calc_deviation (tcr->av_value[i], tcr->act_value[i],
 
3524
+                       tcr->ref_value[i]);
 
3525
+      prdev[i] = tcr->ref_value[i] - tcr->act_value[i];
 
3526
+    }
 
3527
+  if (bPrint)
 
3528
+    pr_dev (tcr, t, prdev, cr, nfile, fnm);
 
3529
+  for (i = 0; (i < atnr2); i++)
 
3530
+    {
 
3531
+      factor = dt * deviation[tip->eObs];
 
3532
+      switch (ftype)
 
3533
+       {
 
3534
+       case F_BONDS:
 
3535
+         if (fabs (tip->xi.harmonic.krA) > 1.2e-38)
 
3536
+           idef->iparams[type].harmonic.krA *=
 
3537
+             (1 + factor / tip->xi.harmonic.krA);
 
3538
+       }
 
3539
+    }
 
3540
+}
 
3541
--- a/src/gcc/testsuite/gcc.target/powerpc/atomic-p7.c
 
3542
+++ b/src/gcc/testsuite/gcc.target/powerpc/atomic-p7.c
 
3543
@@ -0,0 +1,207 @@
 
3544
+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 
3545
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
3546
+/* { dg-require-effective-target powerpc_vsx_ok } */
 
3547
+/* { dg-options "-mcpu=power7 -O2" } */
 
3548
+/* { dg-final { scan-assembler-not "lbarx" } } */
 
3549
+/* { dg-final { scan-assembler-not "lharx" } } */
 
3550
+/* { dg-final { scan-assembler-times "lwarx" 18 } } */
 
3551
+/* { dg-final { scan-assembler-times "ldarx" 6 } } */
 
3552
+/* { dg-final { scan-assembler-not "lqarx" } } */
 
3553
+/* { dg-final { scan-assembler-not "stbcx" } } */
 
3554
+/* { dg-final { scan-assembler-not "sthcx" } } */
 
3555
+/* { dg-final { scan-assembler-times "stwcx" 18 } } */
 
3556
+/* { dg-final { scan-assembler-times "stdcx" 6 } } */
 
3557
+/* { dg-final { scan-assembler-not "stqcx" } } */
 
3558
+/* { dg-final { scan-assembler-times "bl __atomic" 6 } } */
 
3559
+/* { dg-final { scan-assembler-times "isync" 12 } } */
 
3560
+/* { dg-final { scan-assembler-times "lwsync" 8 } } */
 
3561
+/* { dg-final { scan-assembler-not "mtvsrd" } } */
 
3562
+/* { dg-final { scan-assembler-not "mtvsrwa" } } */
 
3563
+/* { dg-final { scan-assembler-not "mtvsrwz" } } */
 
3564
+/* { dg-final { scan-assembler-not "mfvsrd" } } */
 
3565
+/* { dg-final { scan-assembler-not "mfvsrwz" } } */
 
3566
+
 
3567
+/* Test for the byte atomic operations on power8 using lbarx/stbcx.  */
 
3568
+char
 
3569
+char_fetch_add_relaxed (char *ptr, int value)
 
3570
+{
 
3571
+  return __atomic_fetch_add (ptr, value, __ATOMIC_RELAXED);
 
3572
+}
 
3573
+
 
3574
+char
 
3575
+char_fetch_sub_consume (char *ptr, int value)
 
3576
+{
 
3577
+  return __atomic_fetch_sub (ptr, value, __ATOMIC_CONSUME);
 
3578
+}
 
3579
+
 
3580
+char
 
3581
+char_fetch_and_acquire (char *ptr, int value)
 
3582
+{
 
3583
+  return __atomic_fetch_and (ptr, value, __ATOMIC_ACQUIRE);
 
3584
+}
 
3585
+
 
3586
+char
 
3587
+char_fetch_ior_release (char *ptr, int value)
 
3588
+{
 
3589
+  return __atomic_fetch_or (ptr, value, __ATOMIC_RELEASE);
 
3590
+}
 
3591
+
 
3592
+char
 
3593
+char_fetch_xor_acq_rel (char *ptr, int value)
 
3594
+{
 
3595
+  return __atomic_fetch_xor (ptr, value, __ATOMIC_ACQ_REL);
 
3596
+}
 
3597
+
 
3598
+char
 
3599
+char_fetch_nand_seq_cst (char *ptr, int value)
 
3600
+{
 
3601
+  return __atomic_fetch_nand (ptr, value, __ATOMIC_SEQ_CST);
 
3602
+}
 
3603
+
 
3604
+/* Test for the half word atomic operations on power8 using lharx/sthcx.  */
 
3605
+short
 
3606
+short_fetch_add_relaxed (short *ptr, int value)
 
3607
+{
 
3608
+  return __atomic_fetch_add (ptr, value, __ATOMIC_RELAXED);
 
3609
+}
 
3610
+
 
3611
+short
 
3612
+short_fetch_sub_consume (short *ptr, int value)
 
3613
+{
 
3614
+  return __atomic_fetch_sub (ptr, value, __ATOMIC_CONSUME);
 
3615
+}
 
3616
+
 
3617
+short
 
3618
+short_fetch_and_acquire (short *ptr, int value)
 
3619
+{
 
3620
+  return __atomic_fetch_and (ptr, value, __ATOMIC_ACQUIRE);
 
3621
+}
 
3622
+
 
3623
+short
 
3624
+short_fetch_ior_release (short *ptr, int value)
 
3625
+{
 
3626
+  return __atomic_fetch_or (ptr, value, __ATOMIC_RELEASE);
 
3627
+}
 
3628
+
 
3629
+short
 
3630
+short_fetch_xor_acq_rel (short *ptr, int value)
 
3631
+{
 
3632
+  return __atomic_fetch_xor (ptr, value, __ATOMIC_ACQ_REL);
 
3633
+}
 
3634
+
 
3635
+short
 
3636
+short_fetch_nand_seq_cst (short *ptr, int value)
 
3637
+{
 
3638
+  return __atomic_fetch_nand (ptr, value, __ATOMIC_SEQ_CST);
 
3639
+}
 
3640
+
 
3641
+/* Test for the word atomic operations on power8 using lwarx/stwcx.  */
 
3642
+int
 
3643
+int_fetch_add_relaxed (int *ptr, int value)
 
3644
+{
 
3645
+  return __atomic_fetch_add (ptr, value, __ATOMIC_RELAXED);
 
3646
+}
 
3647
+
 
3648
+int
 
3649
+int_fetch_sub_consume (int *ptr, int value)
 
3650
+{
 
3651
+  return __atomic_fetch_sub (ptr, value, __ATOMIC_CONSUME);
 
3652
+}
 
3653
+
 
3654
+int
 
3655
+int_fetch_and_acquire (int *ptr, int value)
 
3656
+{
 
3657
+  return __atomic_fetch_and (ptr, value, __ATOMIC_ACQUIRE);
 
3658
+}
 
3659
+
 
3660
+int
 
3661
+int_fetch_ior_release (int *ptr, int value)
 
3662
+{
 
3663
+  return __atomic_fetch_or (ptr, value, __ATOMIC_RELEASE);
 
3664
+}
 
3665
+
 
3666
+int
 
3667
+int_fetch_xor_acq_rel (int *ptr, int value)
 
3668
+{
 
3669
+  return __atomic_fetch_xor (ptr, value, __ATOMIC_ACQ_REL);
 
3670
+}
 
3671
+
 
3672
+int
 
3673
+int_fetch_nand_seq_cst (int *ptr, int value)
 
3674
+{
 
3675
+  return __atomic_fetch_nand (ptr, value, __ATOMIC_SEQ_CST);
 
3676
+}
 
3677
+
 
3678
+/* Test for the double word atomic operations on power8 using ldarx/stdcx.  */
 
3679
+long
 
3680
+long_fetch_add_relaxed (long *ptr, long value)
 
3681
+{
 
3682
+  return __atomic_fetch_add (ptr, value, __ATOMIC_RELAXED);
 
3683
+}
 
3684
+
 
3685
+long
 
3686
+long_fetch_sub_consume (long *ptr, long value)
 
3687
+{
 
3688
+  return __atomic_fetch_sub (ptr, value, __ATOMIC_CONSUME);
 
3689
+}
 
3690
+
 
3691
+long
 
3692
+long_fetch_and_acquire (long *ptr, long value)
 
3693
+{
 
3694
+  return __atomic_fetch_and (ptr, value, __ATOMIC_ACQUIRE);
 
3695
+}
 
3696
+
 
3697
+long
 
3698
+long_fetch_ior_release (long *ptr, long value)
 
3699
+{
 
3700
+  return __atomic_fetch_or (ptr, value, __ATOMIC_RELEASE);
 
3701
+}
 
3702
+
 
3703
+long
 
3704
+long_fetch_xor_acq_rel (long *ptr, long value)
 
3705
+{
 
3706
+  return __atomic_fetch_xor (ptr, value, __ATOMIC_ACQ_REL);
 
3707
+}
 
3708
+
 
3709
+long
 
3710
+long_fetch_nand_seq_cst (long *ptr, long value)
 
3711
+{
 
3712
+  return __atomic_fetch_nand (ptr, value, __ATOMIC_SEQ_CST);
 
3713
+}
 
3714
+
 
3715
+/* Test for the quad word atomic operations on power8 using ldarx/stdcx.  */
 
3716
+__int128_t
 
3717
+quad_fetch_add_relaxed (__int128_t *ptr, __int128_t value)
 
3718
+{
 
3719
+  return __atomic_fetch_add (ptr, value, __ATOMIC_RELAXED);
 
3720
+}
 
3721
+
 
3722
+__int128_t
 
3723
+quad_fetch_sub_consume (__int128_t *ptr, __int128_t value)
 
3724
+{
 
3725
+  return __atomic_fetch_sub (ptr, value, __ATOMIC_CONSUME);
 
3726
+}
 
3727
+
 
3728
+__int128_t
 
3729
+quad_fetch_and_acquire (__int128_t *ptr, __int128_t value)
 
3730
+{
 
3731
+  return __atomic_fetch_and (ptr, value, __ATOMIC_ACQUIRE);
 
3732
+}
 
3733
+
 
3734
+__int128_t
 
3735
+quad_fetch_ior_release (__int128_t *ptr, __int128_t value)
 
3736
+{
 
3737
+  return __atomic_fetch_or (ptr, value, __ATOMIC_RELEASE);
 
3738
+}
 
3739
+
 
3740
+__int128_t
 
3741
+quad_fetch_xor_acq_rel (__int128_t *ptr, __int128_t value)
 
3742
+{
 
3743
+  return __atomic_fetch_xor (ptr, value, __ATOMIC_ACQ_REL);
 
3744
+}
 
3745
+
 
3746
+__int128_t
 
3747
+quad_fetch_nand_seq_cst (__int128_t *ptr, __int128_t value)
 
3748
+{
 
3749
+  return __atomic_fetch_nand (ptr, value, __ATOMIC_SEQ_CST);
 
3750
+}
 
3751
--- a/src/gcc/testsuite/gcc.target/powerpc/recip-3.c
 
3752
+++ b/src/gcc/testsuite/gcc.target/powerpc/recip-3.c
 
3753
@@ -1,14 +1,14 @@
 
3754
 /* { dg-do compile { target { { powerpc*-*-* } && { ! powerpc*-apple-darwin* } } } } */
 
3755
 /* { dg-require-effective-target powerpc_fprs } */
 
3756
 /* { dg-options "-O2 -mrecip -ffast-math -mcpu=power7" } */
 
3757
-/* { dg-final { scan-assembler-times "xsrsqrtedp" 1 } } */
 
3758
+/* { dg-final { scan-assembler-times "xsrsqrtedp\|frsqrte\ " 1 } } */
 
3759
 /* { dg-final { scan-assembler-times "xsmsub.dp\|fmsub\ " 1 } } */
 
3760
-/* { dg-final { scan-assembler-times "xsmuldp" 4 } } */
 
3761
+/* { dg-final { scan-assembler-times "xsmuldp\|fmul\ " 4 } } */
 
3762
 /* { dg-final { scan-assembler-times "xsnmsub.dp\|fnmsub\ " 2 } } */
 
3763
-/* { dg-final { scan-assembler-times "frsqrtes" 1 } } */
 
3764
-/* { dg-final { scan-assembler-times "fmsubs" 1 } } */
 
3765
-/* { dg-final { scan-assembler-times "fmuls" 4 } } */
 
3766
-/* { dg-final { scan-assembler-times "fnmsubs" 2 } } */
 
3767
+/* { dg-final { scan-assembler-times "xsrsqrtesp\|frsqrtes" 1 } } */
 
3768
+/* { dg-final { scan-assembler-times "xsmsub.sp\|fmsubs" 1 } } */
 
3769
+/* { dg-final { scan-assembler-times "xsmulsp\|fmuls" 2 } } */
 
3770
+/* { dg-final { scan-assembler-times "xsnmsub.sp\|fnmsubs" 1 } } */
 
3771
 
 
3772
 double
 
3773
 rsqrt_d (double a)
 
3774
--- a/src/gcc/testsuite/gcc.target/powerpc/no-r11-2.c
 
3775
+++ b/src/gcc/testsuite/gcc.target/powerpc/no-r11-2.c
 
3776
@@ -1,5 +1,6 @@
 
3777
 /* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 
3778
 /* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */
 
3779
+/* { dg-skip-if "" { powerpc_elfv2 } { "*" } { "" } } */
 
3780
 /* { dg-options "-O2 -mpointers-to-nested-functions" } */
 
3781
 
 
3782
 int
 
3783
--- a/src/gcc/testsuite/gcc.target/powerpc/p8vector-ldst.c
 
3784
+++ b/src/gcc/testsuite/gcc.target/powerpc/p8vector-ldst.c
 
3785
@@ -0,0 +1,42 @@
 
3786
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
3787
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
3788
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
3789
+/* { dg-options "-mcpu=power8 -O2 -mupper-regs-df -mupper-regs-sf" } */
 
3790
+
 
3791
+float load_sf (float *p)
 
3792
+{
 
3793
+  float f = *p;
 
3794
+  __asm__ ("# reg %x0" : "+v" (f));
 
3795
+  return f;
 
3796
+}
 
3797
+
 
3798
+double load_df (double *p)
 
3799
+{
 
3800
+  double d = *p;
 
3801
+  __asm__ ("# reg %x0" : "+v" (d));
 
3802
+  return d;
 
3803
+}
 
3804
+
 
3805
+double load_dfsf (float *p)
 
3806
+{
 
3807
+  double d = (double) *p;
 
3808
+  __asm__ ("# reg %x0" : "+v" (d));
 
3809
+  return d;
 
3810
+}
 
3811
+
 
3812
+void store_sf (float *p, float f)
 
3813
+{
 
3814
+  __asm__ ("# reg %x0" : "+v" (f));
 
3815
+  *p = f;
 
3816
+}
 
3817
+
 
3818
+void store_df (double *p, double d)
 
3819
+{
 
3820
+  __asm__ ("# reg %x0" : "+v" (d));
 
3821
+  *p = d;
 
3822
+}
 
3823
+
 
3824
+/* { dg-final { scan-assembler "lxsspx"  } } */
 
3825
+/* { dg-final { scan-assembler "lxsdx"   } } */
 
3826
+/* { dg-final { scan-assembler "stxsspx" } } */
 
3827
+/* { dg-final { scan-assembler "stxsdx"  } } */
 
3828
--- a/src/gcc/testsuite/gcc.target/powerpc/bool3-p8.c
 
3829
+++ b/src/gcc/testsuite/gcc.target/powerpc/bool3-p8.c
 
3830
@@ -0,0 +1,36 @@
 
3831
+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 
3832
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
3833
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
3834
+/* { dg-options "-O2 -mcpu=power8" } */
 
3835
+/* { dg-final { scan-assembler    "\[ \t\]and "     } } */
 
3836
+/* { dg-final { scan-assembler    "\[ \t\]or "      } } */
 
3837
+/* { dg-final { scan-assembler    "\[ \t\]xor "     } } */
 
3838
+/* { dg-final { scan-assembler    "\[ \t\]nor "     } } */
 
3839
+/* { dg-final { scan-assembler    "\[ \t\]andc "    } } */
 
3840
+/* { dg-final { scan-assembler    "\[ \t\]eqv "     } } */
 
3841
+/* { dg-final { scan-assembler    "\[ \t\]orc "     } } */
 
3842
+/* { dg-final { scan-assembler    "\[ \t\]nand "    } } */
 
3843
+/* { dg-final { scan-assembler-not "\[ \t\]vand "    } } */
 
3844
+/* { dg-final { scan-assembler-not "\[ \t\]vandc "   } } */
 
3845
+/* { dg-final { scan-assembler-not "\[ \t\]vor "     } } */
 
3846
+/* { dg-final { scan-assembler-not "\[ \t\]vxor "    } } */
 
3847
+/* { dg-final { scan-assembler-not "\[ \t\]vnor "    } } */
 
3848
+/* { dg-final { scan-assembler-not "\[ \t\]xxland "  } } */
 
3849
+/* { dg-final { scan-assembler-not "\[ \t\]xxlor "   } } */
 
3850
+/* { dg-final { scan-assembler-not "\[ \t\]xxlxor "  } } */
 
3851
+/* { dg-final { scan-assembler-not "\[ \t\]xxlnor "  } } */
 
3852
+/* { dg-final { scan-assembler-not "\[ \t\]xxlandc " } } */
 
3853
+/* { dg-final { scan-assembler-not "\[ \t\]xxleqv "  } } */
 
3854
+/* { dg-final { scan-assembler-not "\[ \t\]xxlorc "  } } */
 
3855
+/* { dg-final { scan-assembler-not "\[ \t\]xxlnand " } } */
 
3856
+
 
3857
+#ifndef TYPE
 
3858
+#ifdef _ARCH_PPC64
 
3859
+#define TYPE __int128_t
 
3860
+#else
 
3861
+typedef int v4si __attribute__ ((vector_size (16)));
 
3862
+#define TYPE v4si
 
3863
+#endif
 
3864
+#endif
 
3865
+
 
3866
+#include "bool3.h"
 
3867
--- a/src/gcc/testsuite/gcc.target/powerpc/htm-xl-intrin-1.c
 
3868
+++ b/src/gcc/testsuite/gcc.target/powerpc/htm-xl-intrin-1.c
 
3869
@@ -0,0 +1,32 @@
 
3870
+/* This checks the availability of the XL compiler intrinsics for
 
3871
+   transactional execution with the expected prototypes.  */
 
3872
+
 
3873
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
3874
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
3875
+/* { dg-require-effective-target powerpc_htm_ok } */
 
3876
+/* { dg-options "-O2 -mhtm" } */
 
3877
+
 
3878
+#include <htmxlintrin.h>
 
3879
+
 
3880
+void
 
3881
+foo (void *TM_buff, long *result, unsigned char *code)
 
3882
+{
 
3883
+  *result++ = __TM_simple_begin ();
 
3884
+  *result++ = __TM_begin (TM_buff);
 
3885
+  *result++ = __TM_end ();
 
3886
+  __TM_abort ();
 
3887
+  __TM_named_abort (*code);
 
3888
+  __TM_resume ();
 
3889
+  __TM_suspend ();
 
3890
+  *result++ = __TM_is_user_abort (TM_buff);
 
3891
+  *result++ = __TM_is_named_user_abort (TM_buff, code);
 
3892
+  *result++ = __TM_is_illegal (TM_buff);
 
3893
+  *result++ = __TM_is_footprint_exceeded (TM_buff);
 
3894
+  *result++ = __TM_nesting_depth (TM_buff);
 
3895
+  *result++ = __TM_is_nested_too_deep (TM_buff);
 
3896
+  *result++ = __TM_is_conflict (TM_buff);
 
3897
+  *result++ = __TM_is_failure_persistent (TM_buff);
 
3898
+  *result++ = __TM_failure_address (TM_buff);
 
3899
+  *result++ = __TM_failure_code (TM_buff);
 
3900
+}
 
3901
+
 
3902
--- a/src/gcc/testsuite/gcc.target/powerpc/p8vector-builtin-4.c
 
3903
+++ b/src/gcc/testsuite/gcc.target/powerpc/p8vector-builtin-4.c
 
3904
@@ -0,0 +1,249 @@
 
3905
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
3906
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
3907
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
3908
+/* { dg-options "-mcpu=power8 -O3 -ftree-vectorize -fvect-cost-model" } */
 
3909
+
 
3910
+#include <altivec.h>
 
3911
+
 
3912
+typedef vector long long               vll_sign;
 
3913
+typedef vector unsigned long long      vll_uns;
 
3914
+typedef vector bool long long          vll_bool;
 
3915
+
 
3916
+typedef vector int                     vi_sign;
 
3917
+typedef vector unsigned int            vi_uns;
 
3918
+typedef vector bool int                        vi_bool;
 
3919
+
 
3920
+typedef vector short                   vs_sign;
 
3921
+typedef vector unsigned short          vs_uns;
 
3922
+typedef vector bool short              vs_bool;
 
3923
+
 
3924
+typedef vector signed char             vc_sign;
 
3925
+typedef vector unsigned char           vc_uns;
 
3926
+typedef vector bool char               vc_bool;
 
3927
+
 
3928
+vll_sign vll_clz_1 (vll_sign a)
 
3929
+{
 
3930
+  return __builtin_altivec_vclzd (a);
 
3931
+}
 
3932
+
 
3933
+vll_sign vll_clz_2 (vll_sign a)
 
3934
+{
 
3935
+  return vec_vclz (a);
 
3936
+}
 
3937
+
 
3938
+vll_sign vll_clz_3 (vll_sign a)
 
3939
+{
 
3940
+  return vec_vclzd (a);
 
3941
+}
 
3942
+
 
3943
+vll_uns vll_clz_4 (vll_uns a)
 
3944
+{
 
3945
+  return vec_vclz (a);
 
3946
+}
 
3947
+
 
3948
+vll_uns vll_clz_5 (vll_uns a)
 
3949
+{
 
3950
+  return vec_vclzd (a);
 
3951
+}
 
3952
+
 
3953
+vi_sign vi_clz_1 (vi_sign a)
 
3954
+{
 
3955
+  return __builtin_altivec_vclzw (a);
 
3956
+}
 
3957
+
 
3958
+vi_sign vi_clz_2 (vi_sign a)
 
3959
+{
 
3960
+  return vec_vclz (a);
 
3961
+}
 
3962
+
 
3963
+vi_sign vi_clz_3 (vi_sign a)
 
3964
+{
 
3965
+  return vec_vclzw (a);
 
3966
+}
 
3967
+
 
3968
+vi_uns vi_clz_4 (vi_uns a)
 
3969
+{
 
3970
+  return vec_vclz (a);
 
3971
+}
 
3972
+
 
3973
+vi_uns vi_clz_5 (vi_uns a)
 
3974
+{
 
3975
+  return vec_vclzw (a);
 
3976
+}
 
3977
+
 
3978
+vs_sign vs_clz_1 (vs_sign a)
 
3979
+{
 
3980
+  return __builtin_altivec_vclzh (a);
 
3981
+}
 
3982
+
 
3983
+vs_sign vs_clz_2 (vs_sign a)
 
3984
+{
 
3985
+  return vec_vclz (a);
 
3986
+}
 
3987
+
 
3988
+vs_sign vs_clz_3 (vs_sign a)
 
3989
+{
 
3990
+  return vec_vclzh (a);
 
3991
+}
 
3992
+
 
3993
+vs_uns vs_clz_4 (vs_uns a)
 
3994
+{
 
3995
+  return vec_vclz (a);
 
3996
+}
 
3997
+
 
3998
+vs_uns vs_clz_5 (vs_uns a)
 
3999
+{
 
4000
+  return vec_vclzh (a);
 
4001
+}
 
4002
+
 
4003
+vc_sign vc_clz_1 (vc_sign a)
 
4004
+{
 
4005
+  return __builtin_altivec_vclzb (a);
 
4006
+}
 
4007
+
 
4008
+vc_sign vc_clz_2 (vc_sign a)
 
4009
+{
 
4010
+  return vec_vclz (a);
 
4011
+}
 
4012
+
 
4013
+vc_sign vc_clz_3 (vc_sign a)
 
4014
+{
 
4015
+  return vec_vclzb (a);
 
4016
+}
 
4017
+
 
4018
+vc_uns vc_clz_4 (vc_uns a)
 
4019
+{
 
4020
+  return vec_vclz (a);
 
4021
+}
 
4022
+
 
4023
+vc_uns vc_clz_5 (vc_uns a)
 
4024
+{
 
4025
+  return vec_vclzb (a);
 
4026
+}
 
4027
+
 
4028
+vll_sign vll_popcnt_1 (vll_sign a)
 
4029
+{
 
4030
+  return __builtin_altivec_vpopcntd (a);
 
4031
+}
 
4032
+
 
4033
+vll_sign vll_popcnt_2 (vll_sign a)
 
4034
+{
 
4035
+  return vec_vpopcnt (a);
 
4036
+}
 
4037
+
 
4038
+vll_sign vll_popcnt_3 (vll_sign a)
 
4039
+{
 
4040
+  return vec_vpopcntd (a);
 
4041
+}
 
4042
+
 
4043
+vll_uns vll_popcnt_4 (vll_uns a)
 
4044
+{
 
4045
+  return vec_vpopcnt (a);
 
4046
+}
 
4047
+
 
4048
+vll_uns vll_popcnt_5 (vll_uns a)
 
4049
+{
 
4050
+  return vec_vpopcntd (a);
 
4051
+}
 
4052
+
 
4053
+vi_sign vi_popcnt_1 (vi_sign a)
 
4054
+{
 
4055
+  return __builtin_altivec_vpopcntw (a);
 
4056
+}
 
4057
+
 
4058
+vi_sign vi_popcnt_2 (vi_sign a)
 
4059
+{
 
4060
+  return vec_vpopcnt (a);
 
4061
+}
 
4062
+
 
4063
+vi_sign vi_popcnt_3 (vi_sign a)
 
4064
+{
 
4065
+  return vec_vpopcntw (a);
 
4066
+}
 
4067
+
 
4068
+vi_uns vi_popcnt_4 (vi_uns a)
 
4069
+{
 
4070
+  return vec_vpopcnt (a);
 
4071
+}
 
4072
+
 
4073
+vi_uns vi_popcnt_5 (vi_uns a)
 
4074
+{
 
4075
+  return vec_vpopcntw (a);
 
4076
+}
 
4077
+
 
4078
+vs_sign vs_popcnt_1 (vs_sign a)
 
4079
+{
 
4080
+  return __builtin_altivec_vpopcnth (a);
 
4081
+}
 
4082
+
 
4083
+vs_sign vs_popcnt_2 (vs_sign a)
 
4084
+{
 
4085
+  return vec_vpopcnt (a);
 
4086
+}
 
4087
+
 
4088
+vs_sign vs_popcnt_3 (vs_sign a)
 
4089
+{
 
4090
+  return vec_vpopcnth (a);
 
4091
+}
 
4092
+
 
4093
+vs_uns vs_popcnt_4 (vs_uns a)
 
4094
+{
 
4095
+  return vec_vpopcnt (a);
 
4096
+}
 
4097
+
 
4098
+vs_uns vs_popcnt_5 (vs_uns a)
 
4099
+{
 
4100
+  return vec_vpopcnth (a);
 
4101
+}
 
4102
+
 
4103
+vc_sign vc_popcnt_1 (vc_sign a)
 
4104
+{
 
4105
+  return __builtin_altivec_vpopcntb (a);
 
4106
+}
 
4107
+
 
4108
+vc_sign vc_popcnt_2 (vc_sign a)
 
4109
+{
 
4110
+  return vec_vpopcnt (a);
 
4111
+}
 
4112
+
 
4113
+vc_sign vc_popcnt_3 (vc_sign a)
 
4114
+{
 
4115
+  return vec_vpopcntb (a);
 
4116
+}
 
4117
+
 
4118
+vc_uns vc_popcnt_4 (vc_uns a)
 
4119
+{
 
4120
+  return vec_vpopcnt (a);
 
4121
+}
 
4122
+
 
4123
+vc_uns vc_popcnt_5 (vc_uns a)
 
4124
+{
 
4125
+  return vec_vpopcntb (a);
 
4126
+}
 
4127
+
 
4128
+vc_uns vc_gbb_1 (vc_uns a)
 
4129
+{
 
4130
+  return __builtin_altivec_vgbbd (a);
 
4131
+}
 
4132
+
 
4133
+vc_sign vc_gbb_2 (vc_sign a)
 
4134
+{
 
4135
+  return vec_vgbbd (a);
 
4136
+}
 
4137
+
 
4138
+vc_uns vc_gbb_3 (vc_uns a)
 
4139
+{
 
4140
+  return vec_vgbbd (a);
 
4141
+}
 
4142
+
 
4143
+/* { dg-final { scan-assembler-times "vclzd"   5 } } */
 
4144
+/* { dg-final { scan-assembler-times "vclzw"   5 } } */
 
4145
+/* { dg-final { scan-assembler-times "vclzh"   5 } } */
 
4146
+/* { dg-final { scan-assembler-times "vclzb"   5 } } */
 
4147
+
 
4148
+/* { dg-final { scan-assembler-times "vpopcntd" 5 } } */
 
4149
+/* { dg-final { scan-assembler-times "vpopcntw" 5 } } */
 
4150
+/* { dg-final { scan-assembler-times "vpopcnth" 5 } } */
 
4151
+/* { dg-final { scan-assembler-times "vpopcntb" 5 } } */
 
4152
+
 
4153
+/* { dg-final { scan-assembler-times "vgbbd"    3 } } */
 
4154
--- a/src/gcc/testsuite/gcc.target/powerpc/bool3-av.c
 
4155
+++ b/src/gcc/testsuite/gcc.target/powerpc/bool3-av.c
 
4156
@@ -0,0 +1,37 @@
 
4157
+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 
4158
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
4159
+/* { dg-require-effective-target powerpc_altivec_ok } */
 
4160
+/* { dg-options "-O2 -mcpu=power6 -mabi=altivec -maltivec -mno-vsx" } */
 
4161
+/* { dg-final { scan-assembler    "\[ \t\]and "     } } */
 
4162
+/* { dg-final { scan-assembler    "\[ \t\]or "      } } */
 
4163
+/* { dg-final { scan-assembler    "\[ \t\]xor "     } } */
 
4164
+/* { dg-final { scan-assembler    "\[ \t\]nor "     } } */
 
4165
+/* { dg-final { scan-assembler    "\[ \t\]andc "    } } */
 
4166
+/* { dg-final { scan-assembler-not "\[ \t\]vand "    } } */
 
4167
+/* { dg-final { scan-assembler-not "\[ \t\]vandc "   } } */
 
4168
+/* { dg-final { scan-assembler-not "\[ \t\]vor "     } } */
 
4169
+/* { dg-final { scan-assembler-not "\[ \t\]vxor "    } } */
 
4170
+/* { dg-final { scan-assembler-not "\[ \t\]vnor "    } } */
 
4171
+/* { dg-final { scan-assembler-not "\[ \t\]xxland "  } } */
 
4172
+/* { dg-final { scan-assembler-not "\[ \t\]xxlor "   } } */
 
4173
+/* { dg-final { scan-assembler-not "\[ \t\]xxlxor "  } } */
 
4174
+/* { dg-final { scan-assembler-not "\[ \t\]xxlnor "  } } */
 
4175
+/* { dg-final { scan-assembler-not "\[ \t\]xxlandc " } } */
 
4176
+/* { dg-final { scan-assembler-not "\[ \t\]xxleqv "  } } */
 
4177
+/* { dg-final { scan-assembler-not "\[ \t\]xxlorc "  } } */
 
4178
+/* { dg-final { scan-assembler-not "\[ \t\]xxlnand " } } */
 
4179
+
 
4180
+/* On altivec, for 128-bit types, ORC/ANDC/EQV might not show up, since the
 
4181
+   vector unit doesn't support these, so the appropriate combine patterns may
 
4182
+   not be generated.  */
 
4183
+
 
4184
+#ifndef TYPE
 
4185
+#ifdef _ARCH_PPC64
 
4186
+#define TYPE __int128_t
 
4187
+#else
 
4188
+typedef int v4si __attribute__ ((vector_size (16)));
 
4189
+#define TYPE v4si
 
4190
+#endif
 
4191
+#endif
 
4192
+
 
4193
+#include "bool3.h"
 
4194
--- a/src/gcc/testsuite/gcc.target/powerpc/p8vector-vectorize-4.c
 
4195
+++ b/src/gcc/testsuite/gcc.target/powerpc/p8vector-vectorize-4.c
 
4196
@@ -0,0 +1,69 @@
 
4197
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
4198
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
4199
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
4200
+/* { dg-options "-mcpu=power8 -O2 -ftree-vectorize -fvect-cost-model -fno-unroll-loops -fno-unroll-all-loops" } */
 
4201
+
 
4202
+#ifndef SIZE
 
4203
+#define SIZE 1024
 
4204
+#endif
 
4205
+
 
4206
+#ifndef ALIGN
 
4207
+#define ALIGN 32
 
4208
+#endif
 
4209
+
 
4210
+#define ALIGN_ATTR __attribute__((__aligned__(ALIGN)))
 
4211
+
 
4212
+#define DO_BUILTIN(PREFIX, TYPE, CLZ, POPCNT)                          \
 
4213
+TYPE PREFIX ## _a[SIZE] ALIGN_ATTR;                                    \
 
4214
+TYPE PREFIX ## _b[SIZE] ALIGN_ATTR;                                    \
 
4215
+                                                                       \
 
4216
+void                                                                   \
 
4217
+PREFIX ## _clz (void)                                                  \
 
4218
+{                                                                      \
 
4219
+  unsigned long i;                                                     \
 
4220
+                                                                       \
 
4221
+  for (i = 0; i < SIZE; i++)                                           \
 
4222
+    PREFIX ## _a[i] = CLZ (PREFIX ## _b[i]);                           \
 
4223
+}                                                                      \
 
4224
+                                                                       \
 
4225
+void                                                                   \
 
4226
+PREFIX ## _popcnt (void)                                               \
 
4227
+{                                                                      \
 
4228
+  unsigned long i;                                                     \
 
4229
+                                                                       \
 
4230
+  for (i = 0; i < SIZE; i++)                                           \
 
4231
+    PREFIX ## _a[i] = POPCNT (PREFIX ## _b[i]);                                \
 
4232
+}
 
4233
+
 
4234
+#if !defined(DO_LONG_LONG) && !defined(DO_LONG) && !defined(DO_INT) && !defined(DO_SHORT) && !defined(DO_CHAR)
 
4235
+#define DO_INT 1
 
4236
+#endif
 
4237
+
 
4238
+#if DO_LONG_LONG
 
4239
+/* At the moment, only int is auto vectorized.  */
 
4240
+DO_BUILTIN (sll, long long,            __builtin_clzll, __builtin_popcountll)
 
4241
+DO_BUILTIN (ull, unsigned long long,   __builtin_clzll, __builtin_popcountll)
 
4242
+#endif
 
4243
+
 
4244
+#if defined(_ARCH_PPC64) && DO_LONG
 
4245
+DO_BUILTIN (sl,  long,                 __builtin_clzl,  __builtin_popcountl)
 
4246
+DO_BUILTIN (ul,  unsigned long,                __builtin_clzl,  __builtin_popcountl)
 
4247
+#endif
 
4248
+
 
4249
+#if DO_INT
 
4250
+DO_BUILTIN (si,  int,                  __builtin_clz,   __builtin_popcount)
 
4251
+DO_BUILTIN (ui,  unsigned int,         __builtin_clz,   __builtin_popcount)
 
4252
+#endif
 
4253
+
 
4254
+#if DO_SHORT
 
4255
+DO_BUILTIN (ss,  short,                        __builtin_clz,   __builtin_popcount)
 
4256
+DO_BUILTIN (us,  unsigned short,       __builtin_clz,   __builtin_popcount)
 
4257
+#endif
 
4258
+
 
4259
+#if DO_CHAR
 
4260
+DO_BUILTIN (sc,  signed char,          __builtin_clz,   __builtin_popcount)
 
4261
+DO_BUILTIN (uc,  unsigned char,                __builtin_clz,   __builtin_popcount)
 
4262
+#endif
 
4263
+
 
4264
+/* { dg-final { scan-assembler-times "vclzw"     2 } } */
 
4265
+/* { dg-final { scan-assembler-times "vpopcntw"  2 } } */
 
4266
--- a/src/gcc/testsuite/gcc.target/powerpc/pr57949-1.c
 
4267
+++ b/src/gcc/testsuite/gcc.target/powerpc/pr57949-1.c
 
4268
@@ -0,0 +1,20 @@
 
4269
+/* { dg-do compile { target { powerpc64*-*-* && lp64 } } } */
 
4270
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
4271
+/* { dg-skip-if "" { powerpc_elfv2 } { "*" } { "" } } */
 
4272
+/* { dg-options "-O2 -mcpu=power7 -mno-compat-align-parm" } */
 
4273
+
 
4274
+/* Verify that vs is 16-byte aligned with -mcompat-align-parm.  */
 
4275
+
 
4276
+typedef float v4sf __attribute__ ((vector_size (16)));
 
4277
+struct s { long m; v4sf v; };
 
4278
+long n;
 
4279
+v4sf ve;
 
4280
+
 
4281
+void pr57949 (long d1, long d2, long d3, long d4, long d5, long d6,
 
4282
+             long d7, long d8, long d9, struct s vs) {
 
4283
+  n = vs.m;
 
4284
+  ve = vs.v;
 
4285
+}
 
4286
+
 
4287
+/* { dg-final { scan-assembler "li \.\*,144" } } */
 
4288
+/* { dg-final { scan-assembler "ld \.\*,128\\(1\\)" } } */
 
4289
--- a/src/gcc/testsuite/gcc.target/powerpc/atomic-p8.c
 
4290
+++ b/src/gcc/testsuite/gcc.target/powerpc/atomic-p8.c
 
4291
@@ -0,0 +1,237 @@
 
4292
+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 
4293
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
4294
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
4295
+/* { dg-options "-mcpu=power8 -O2" } */
 
4296
+/* { dg-final { scan-assembler-times "lbarx" 7 } } */
 
4297
+/* { dg-final { scan-assembler-times "lharx" 7 } } */
 
4298
+/* { dg-final { scan-assembler-times "lwarx" 7 } } */
 
4299
+/* { dg-final { scan-assembler-times "ldarx" 7 } } */
 
4300
+/* { dg-final { scan-assembler-times "lqarx" 7 } } */
 
4301
+/* { dg-final { scan-assembler-times "stbcx" 7 } } */
 
4302
+/* { dg-final { scan-assembler-times "sthcx" 7 } } */
 
4303
+/* { dg-final { scan-assembler-times "stwcx" 7 } } */
 
4304
+/* { dg-final { scan-assembler-times "stdcx" 7 } } */
 
4305
+/* { dg-final { scan-assembler-times "stqcx" 7 } } */
 
4306
+/* { dg-final { scan-assembler-not "bl __atomic" } } */
 
4307
+/* { dg-final { scan-assembler-times "isync" 20 } } */
 
4308
+/* { dg-final { scan-assembler-times "lwsync" 10 } } */
 
4309
+/* { dg-final { scan-assembler-not "mtvsrd" } } */
 
4310
+/* { dg-final { scan-assembler-not "mtvsrwa" } } */
 
4311
+/* { dg-final { scan-assembler-not "mtvsrwz" } } */
 
4312
+/* { dg-final { scan-assembler-not "mfvsrd" } } */
 
4313
+/* { dg-final { scan-assembler-not "mfvsrwz" } } */
 
4314
+
 
4315
+/* Test for the byte atomic operations on power8 using lbarx/stbcx.  */
 
4316
+char
 
4317
+char_fetch_add_relaxed (char *ptr, int value)
 
4318
+{
 
4319
+  return __atomic_fetch_add (ptr, value, __ATOMIC_RELAXED);
 
4320
+}
 
4321
+
 
4322
+char
 
4323
+char_fetch_sub_consume (char *ptr, int value)
 
4324
+{
 
4325
+  return __atomic_fetch_sub (ptr, value, __ATOMIC_CONSUME);
 
4326
+}
 
4327
+
 
4328
+char
 
4329
+char_fetch_and_acquire (char *ptr, int value)
 
4330
+{
 
4331
+  return __atomic_fetch_and (ptr, value, __ATOMIC_ACQUIRE);
 
4332
+}
 
4333
+
 
4334
+char
 
4335
+char_fetch_ior_release (char *ptr, int value)
 
4336
+{
 
4337
+  return __atomic_fetch_or (ptr, value, __ATOMIC_RELEASE);
 
4338
+}
 
4339
+
 
4340
+char
 
4341
+char_fetch_xor_acq_rel (char *ptr, int value)
 
4342
+{
 
4343
+  return __atomic_fetch_xor (ptr, value, __ATOMIC_ACQ_REL);
 
4344
+}
 
4345
+
 
4346
+char
 
4347
+char_fetch_nand_seq_cst (char *ptr, int value)
 
4348
+{
 
4349
+  return __atomic_fetch_nand (ptr, value, __ATOMIC_SEQ_CST);
 
4350
+}
 
4351
+
 
4352
+void
 
4353
+char_val_compare_and_swap (char *p, int i, int j, char *q)
 
4354
+{
 
4355
+  *q = __sync_val_compare_and_swap (p, i, j);
 
4356
+}
 
4357
+
 
4358
+/* Test for the half word atomic operations on power8 using lharx/sthcx.  */
 
4359
+short
 
4360
+short_fetch_add_relaxed (short *ptr, int value)
 
4361
+{
 
4362
+  return __atomic_fetch_add (ptr, value, __ATOMIC_RELAXED);
 
4363
+}
 
4364
+
 
4365
+short
 
4366
+short_fetch_sub_consume (short *ptr, int value)
 
4367
+{
 
4368
+  return __atomic_fetch_sub (ptr, value, __ATOMIC_CONSUME);
 
4369
+}
 
4370
+
 
4371
+short
 
4372
+short_fetch_and_acquire (short *ptr, int value)
 
4373
+{
 
4374
+  return __atomic_fetch_and (ptr, value, __ATOMIC_ACQUIRE);
 
4375
+}
 
4376
+
 
4377
+short
 
4378
+short_fetch_ior_release (short *ptr, int value)
 
4379
+{
 
4380
+  return __atomic_fetch_or (ptr, value, __ATOMIC_RELEASE);
 
4381
+}
 
4382
+
 
4383
+short
 
4384
+short_fetch_xor_acq_rel (short *ptr, int value)
 
4385
+{
 
4386
+  return __atomic_fetch_xor (ptr, value, __ATOMIC_ACQ_REL);
 
4387
+}
 
4388
+
 
4389
+short
 
4390
+short_fetch_nand_seq_cst (short *ptr, int value)
 
4391
+{
 
4392
+  return __atomic_fetch_nand (ptr, value, __ATOMIC_SEQ_CST);
 
4393
+}
 
4394
+
 
4395
+void
 
4396
+short_val_compare_and_swap (short *p, int i, int j, short *q)
 
4397
+{
 
4398
+  *q = __sync_val_compare_and_swap (p, i, j);
 
4399
+}
 
4400
+
 
4401
+/* Test for the word atomic operations on power8 using lwarx/stwcx.  */
 
4402
+int
 
4403
+int_fetch_add_relaxed (int *ptr, int value)
 
4404
+{
 
4405
+  return __atomic_fetch_add (ptr, value, __ATOMIC_RELAXED);
 
4406
+}
 
4407
+
 
4408
+int
 
4409
+int_fetch_sub_consume (int *ptr, int value)
 
4410
+{
 
4411
+  return __atomic_fetch_sub (ptr, value, __ATOMIC_CONSUME);
 
4412
+}
 
4413
+
 
4414
+int
 
4415
+int_fetch_and_acquire (int *ptr, int value)
 
4416
+{
 
4417
+  return __atomic_fetch_and (ptr, value, __ATOMIC_ACQUIRE);
 
4418
+}
 
4419
+
 
4420
+int
 
4421
+int_fetch_ior_release (int *ptr, int value)
 
4422
+{
 
4423
+  return __atomic_fetch_or (ptr, value, __ATOMIC_RELEASE);
 
4424
+}
 
4425
+
 
4426
+int
 
4427
+int_fetch_xor_acq_rel (int *ptr, int value)
 
4428
+{
 
4429
+  return __atomic_fetch_xor (ptr, value, __ATOMIC_ACQ_REL);
 
4430
+}
 
4431
+
 
4432
+int
 
4433
+int_fetch_nand_seq_cst (int *ptr, int value)
 
4434
+{
 
4435
+  return __atomic_fetch_nand (ptr, value, __ATOMIC_SEQ_CST);
 
4436
+}
 
4437
+
 
4438
+void
 
4439
+int_val_compare_and_swap (int *p, int i, int j, int *q)
 
4440
+{
 
4441
+  *q = __sync_val_compare_and_swap (p, i, j);
 
4442
+}
 
4443
+
 
4444
+/* Test for the double word atomic operations on power8 using ldarx/stdcx.  */
 
4445
+long
 
4446
+long_fetch_add_relaxed (long *ptr, long value)
 
4447
+{
 
4448
+  return __atomic_fetch_add (ptr, value, __ATOMIC_RELAXED);
 
4449
+}
 
4450
+
 
4451
+long
 
4452
+long_fetch_sub_consume (long *ptr, long value)
 
4453
+{
 
4454
+  return __atomic_fetch_sub (ptr, value, __ATOMIC_CONSUME);
 
4455
+}
 
4456
+
 
4457
+long
 
4458
+long_fetch_and_acquire (long *ptr, long value)
 
4459
+{
 
4460
+  return __atomic_fetch_and (ptr, value, __ATOMIC_ACQUIRE);
 
4461
+}
 
4462
+
 
4463
+long
 
4464
+long_fetch_ior_release (long *ptr, long value)
 
4465
+{
 
4466
+  return __atomic_fetch_or (ptr, value, __ATOMIC_RELEASE);
 
4467
+}
 
4468
+
 
4469
+long
 
4470
+long_fetch_xor_acq_rel (long *ptr, long value)
 
4471
+{
 
4472
+  return __atomic_fetch_xor (ptr, value, __ATOMIC_ACQ_REL);
 
4473
+}
 
4474
+
 
4475
+long
 
4476
+long_fetch_nand_seq_cst (long *ptr, long value)
 
4477
+{
 
4478
+  return __atomic_fetch_nand (ptr, value, __ATOMIC_SEQ_CST);
 
4479
+}
 
4480
+
 
4481
+void
 
4482
+long_val_compare_and_swap (long *p, long i, long j, long *q)
 
4483
+{
 
4484
+  *q = __sync_val_compare_and_swap (p, i, j);
 
4485
+}
 
4486
+
 
4487
+/* Test for the quad word atomic operations on power8 using ldarx/stdcx.  */
 
4488
+__int128_t
 
4489
+quad_fetch_add_relaxed (__int128_t *ptr, __int128_t value)
 
4490
+{
 
4491
+  return __atomic_fetch_add (ptr, value, __ATOMIC_RELAXED);
 
4492
+}
 
4493
+
 
4494
+__int128_t
 
4495
+quad_fetch_sub_consume (__int128_t *ptr, __int128_t value)
 
4496
+{
 
4497
+  return __atomic_fetch_sub (ptr, value, __ATOMIC_CONSUME);
 
4498
+}
 
4499
+
 
4500
+__int128_t
 
4501
+quad_fetch_and_acquire (__int128_t *ptr, __int128_t value)
 
4502
+{
 
4503
+  return __atomic_fetch_and (ptr, value, __ATOMIC_ACQUIRE);
 
4504
+}
 
4505
+
 
4506
+__int128_t
 
4507
+quad_fetch_ior_release (__int128_t *ptr, __int128_t value)
 
4508
+{
 
4509
+  return __atomic_fetch_or (ptr, value, __ATOMIC_RELEASE);
 
4510
+}
 
4511
+
 
4512
+__int128_t
 
4513
+quad_fetch_xor_acq_rel (__int128_t *ptr, __int128_t value)
 
4514
+{
 
4515
+  return __atomic_fetch_xor (ptr, value, __ATOMIC_ACQ_REL);
 
4516
+}
 
4517
+
 
4518
+__int128_t
 
4519
+quad_fetch_nand_seq_cst (__int128_t *ptr, __int128_t value)
 
4520
+{
 
4521
+  return __atomic_fetch_nand (ptr, value, __ATOMIC_SEQ_CST);
 
4522
+}
 
4523
+
 
4524
+void
 
4525
+quad_val_compare_and_swap (__int128_t *p, __int128_t i, __int128_t j, __int128_t *q)
 
4526
+{
 
4527
+  *q = __sync_val_compare_and_swap (p, i, j);
 
4528
+}
 
4529
--- a/src/gcc/testsuite/gcc.target/powerpc/sd-pwr6.c
 
4530
+++ b/src/gcc/testsuite/gcc.target/powerpc/sd-pwr6.c
 
4531
@@ -0,0 +1,19 @@
 
4532
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
4533
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
4534
+/* { dg-require-effective-target powerpc_vsx_ok } */
 
4535
+/* { dg-options "-O2 -mcpu=power6 -mhard-dfp" } */
 
4536
+/* { dg-final { scan-assembler-not   "lfiwzx"   } } */
 
4537
+/* { dg-final { scan-assembler-times "lfd"    2 } } */
 
4538
+/* { dg-final { scan-assembler-times "dctdp"  2 } } */
 
4539
+/* { dg-final { scan-assembler-times "dadd"   1 } } */
 
4540
+/* { dg-final { scan-assembler-times "drsp"   1 } } */
 
4541
+
 
4542
+/* Test that for power6 we need to use a bounce buffer on the stack to load
 
4543
+   SDmode variables because the power6 does not have a way to directly load
 
4544
+   32-bit values from memory.  */
 
4545
+_Decimal32 a;
 
4546
+
 
4547
+void inc_dec32 (void)
 
4548
+{
 
4549
+  a += (_Decimal32) 1.0;
 
4550
+}
 
4551
--- a/src/gcc/testsuite/gcc.target/powerpc/recip-4.c
 
4552
+++ b/src/gcc/testsuite/gcc.target/powerpc/recip-4.c
 
4553
@@ -7,8 +7,8 @@
 
4554
 /* { dg-final { scan-assembler-times "xvnmsub.dp" 2 } } */
 
4555
 /* { dg-final { scan-assembler-times "xvrsqrtesp" 1 } } */
 
4556
 /* { dg-final { scan-assembler-times "xvmsub.sp" 1 } } */
 
4557
-/* { dg-final { scan-assembler-times "xvmulsp" 4 } } */
 
4558
-/* { dg-final { scan-assembler-times "xvnmsub.sp" 2 } } */
 
4559
+/* { dg-final { scan-assembler-times "xvmulsp" 2 } } */
 
4560
+/* { dg-final { scan-assembler-times "xvnmsub.sp" 1 } } */
 
4561
 
 
4562
 #define SIZE 1024
 
4563
 
 
4564
--- a/src/gcc/testsuite/gcc.target/powerpc/no-r11-3.c
 
4565
+++ b/src/gcc/testsuite/gcc.target/powerpc/no-r11-3.c
 
4566
@@ -1,5 +1,6 @@
 
4567
 /* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 
4568
 /* { dg-skip-if "" { *-*-darwin* } { "*" } { "" } } */
 
4569
+/* { dg-skip-if "" { powerpc_elfv2 } { "*" } { "" } } */
 
4570
 /* { dg-options "-O2 -mno-pointers-to-nested-functions" } */
 
4571
 
 
4572
 extern void ext_call (int (func) (void));
 
4573
--- a/src/gcc/testsuite/gcc.target/powerpc/crypto-builtin-1.c
 
4574
+++ b/src/gcc/testsuite/gcc.target/powerpc/crypto-builtin-1.c
 
4575
@@ -0,0 +1,130 @@
 
4576
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
4577
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
4578
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
4579
+/* { dg-options "-mcpu=power8 -O2 -ftree-vectorize -fvect-cost-model -fno-unroll-loops -fno-unroll-all-loops" } */
 
4580
+
 
4581
+typedef vector unsigned long long      crypto_t;
 
4582
+typedef vector unsigned long long      v2di_t;
 
4583
+typedef vector unsigned int            v4si_t;
 
4584
+typedef vector unsigned short          v8hi_t;
 
4585
+typedef vector unsigned char           v16qi_t;
 
4586
+
 
4587
+crypto_t crpyto1 (crypto_t a)
 
4588
+{
 
4589
+  return __builtin_crypto_vsbox (a);
 
4590
+}
 
4591
+
 
4592
+crypto_t crypto2 (crypto_t a, crypto_t b)
 
4593
+{
 
4594
+  return __builtin_crypto_vcipher (a, b);
 
4595
+}
 
4596
+
 
4597
+crypto_t crypto3 (crypto_t a, crypto_t b)
 
4598
+{
 
4599
+  return __builtin_crypto_vcipherlast (a, b);
 
4600
+}
 
4601
+
 
4602
+crypto_t crypto4 (crypto_t a, crypto_t b)
 
4603
+{
 
4604
+  return __builtin_crypto_vncipher (a, b);
 
4605
+}
 
4606
+
 
4607
+crypto_t crypto5 (crypto_t a, crypto_t b)
 
4608
+{
 
4609
+  return __builtin_crypto_vncipherlast (a, b);
 
4610
+}
 
4611
+
 
4612
+v16qi_t crypto6a (v16qi_t a, v16qi_t b, v16qi_t c)
 
4613
+{
 
4614
+  return __builtin_crypto_vpermxor (a, b, c);
 
4615
+}
 
4616
+
 
4617
+v8hi_t crypto6b (v8hi_t a, v8hi_t b, v8hi_t c)
 
4618
+{
 
4619
+  return __builtin_crypto_vpermxor (a, b, c);
 
4620
+}
 
4621
+
 
4622
+v4si_t crypto6c (v4si_t a, v4si_t b, v4si_t c)
 
4623
+{
 
4624
+  return __builtin_crypto_vpermxor (a, b, c);
 
4625
+}
 
4626
+
 
4627
+v2di_t crypto6d (v2di_t a, v2di_t b, v2di_t c)
 
4628
+{
 
4629
+  return __builtin_crypto_vpermxor (a, b, c);
 
4630
+}
 
4631
+
 
4632
+v16qi_t crypto7a (v16qi_t a, v16qi_t b)
 
4633
+{
 
4634
+  return __builtin_crypto_vpmsumb (a, b);
 
4635
+}
 
4636
+
 
4637
+v16qi_t crypto7b (v16qi_t a, v16qi_t b)
 
4638
+{
 
4639
+  return __builtin_crypto_vpmsum (a, b);
 
4640
+}
 
4641
+
 
4642
+v8hi_t crypto7c (v8hi_t a, v8hi_t b)
 
4643
+{
 
4644
+  return __builtin_crypto_vpmsumh (a, b);
 
4645
+}
 
4646
+
 
4647
+v8hi_t crypto7d (v8hi_t a, v8hi_t b)
 
4648
+{
 
4649
+  return __builtin_crypto_vpmsum (a, b);
 
4650
+}
 
4651
+
 
4652
+v4si_t crypto7e (v4si_t a, v4si_t b)
 
4653
+{
 
4654
+  return __builtin_crypto_vpmsumw (a, b);
 
4655
+}
 
4656
+
 
4657
+v4si_t crypto7f (v4si_t a, v4si_t b)
 
4658
+{
 
4659
+  return __builtin_crypto_vpmsum (a, b);
 
4660
+}
 
4661
+
 
4662
+v2di_t crypto7g (v2di_t a, v2di_t b)
 
4663
+{
 
4664
+  return __builtin_crypto_vpmsumd (a, b);
 
4665
+}
 
4666
+
 
4667
+v2di_t crypto7h (v2di_t a, v2di_t b)
 
4668
+{
 
4669
+  return __builtin_crypto_vpmsum (a, b);
 
4670
+}
 
4671
+
 
4672
+v2di_t crypto8a (v2di_t a)
 
4673
+{
 
4674
+  return __builtin_crypto_vshasigmad (a, 0, 8);
 
4675
+}
 
4676
+
 
4677
+v2di_t crypto8b (v2di_t a)
 
4678
+{
 
4679
+  return __builtin_crypto_vshasigma (a, 0, 8);
 
4680
+}
 
4681
+
 
4682
+v4si_t crypto8c (v4si_t a)
 
4683
+{
 
4684
+  return __builtin_crypto_vshasigmaw (a, 1, 15);
 
4685
+}
 
4686
+
 
4687
+v4si_t crypto8d (v4si_t a)
 
4688
+{
 
4689
+  return __builtin_crypto_vshasigma (a, 1, 15);
 
4690
+}
 
4691
+
 
4692
+/* Note space is used after the instruction so that vcipherlast does not match
 
4693
+   vcipher.  */
 
4694
+/* { dg-final { scan-assembler-times "vcipher "      1 } } */
 
4695
+/* { dg-final { scan-assembler-times "vcipherlast "  1 } } */
 
4696
+/* { dg-final { scan-assembler-times "vncipher "     1 } } */
 
4697
+/* { dg-final { scan-assembler-times "vncipherlast " 1 } } */
 
4698
+/* { dg-final { scan-assembler-times "vpermxor "     4 } } */
 
4699
+/* { dg-final { scan-assembler-times "vpmsumb "      2 } } */
 
4700
+/* { dg-final { scan-assembler-times "vpmsumd "      2 } } */
 
4701
+/* { dg-final { scan-assembler-times "vpmsumh "      2 } } */
 
4702
+/* { dg-final { scan-assembler-times "vpmsumw "      2 } } */
 
4703
+/* { dg-final { scan-assembler-times "vsbox "        1 } } */
 
4704
+/* { dg-final { scan-assembler-times "vshasigmad "   2 } } */
 
4705
+/* { dg-final { scan-assembler-times "vshasigmaw "   2 } } */
 
4706
--- a/src/gcc/testsuite/gcc.target/powerpc/pr42747.c
 
4707
+++ b/src/gcc/testsuite/gcc.target/powerpc/pr42747.c
 
4708
@@ -5,4 +5,4 @@
 
4709
 
 
4710
 double foo (double x) { return __builtin_sqrt (x); }
 
4711
 
 
4712
-/* { dg-final { scan-assembler "xssqrtdp" } } */
 
4713
+/* { dg-final { scan-assembler "xssqrtdp\|fsqrt" } } */
 
4714
--- a/src/gcc/testsuite/gcc.target/powerpc/dfp-dd-2.c
 
4715
+++ b/src/gcc/testsuite/gcc.target/powerpc/dfp-dd-2.c
 
4716
@@ -0,0 +1,26 @@
 
4717
+/* Test generation of DFP instructions for POWER6.  */
 
4718
+/* { dg-do compile { target { powerpc*-*-linux* && powerpc_fprs } } } */
 
4719
+/* { dg-options "-std=gnu99 -O1 -mcpu=power6" } */
 
4720
+
 
4721
+/* { dg-final { scan-assembler-times "fneg" 1 } } */
 
4722
+/* { dg-final { scan-assembler-times "fabs" 1 } } */
 
4723
+/* { dg-final { scan-assembler-times "fnabs" 1 } } */
 
4724
+/* { dg-final { scan-assembler-times "fmr" 0 } } */
 
4725
+
 
4726
+_Decimal64
 
4727
+func1 (_Decimal64 a, _Decimal64 b)
 
4728
+{
 
4729
+  return -b;
 
4730
+}
 
4731
+
 
4732
+_Decimal64
 
4733
+func2 (_Decimal64 a, _Decimal64 b)
 
4734
+{
 
4735
+  return __builtin_fabsd64 (b);
 
4736
+}
 
4737
+
 
4738
+_Decimal64
 
4739
+func3 (_Decimal64 a, _Decimal64 b)
 
4740
+{
 
4741
+  return - __builtin_fabsd64 (b);
 
4742
+}
 
4743
--- a/src/gcc/testsuite/gcc.target/powerpc/direct-move-float1.c
 
4744
+++ b/src/gcc/testsuite/gcc.target/powerpc/direct-move-float1.c
 
4745
@@ -0,0 +1,18 @@
 
4746
+/* { dg-do compile { target { powerpc*-*-linux* && lp64 } } } */
 
4747
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
4748
+/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
 
4749
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
4750
+/* { dg-options "-mcpu=power8 -O2" } */
 
4751
+/* { dg-final { scan-assembler "mtvsrd" } } */
 
4752
+/* { dg-final { scan-assembler "mfvsrd" } } */
 
4753
+/* { dg-final { scan-assembler "xscvdpspn" } } */
 
4754
+/* { dg-final { scan-assembler "xscvspdpn" } } */
 
4755
+
 
4756
+/* Check code generation for direct move for float types.  */
 
4757
+
 
4758
+#define TYPE float
 
4759
+#define IS_FLOAT 1
 
4760
+#define NO_ALTIVEC 1
 
4761
+#define VSX_REG_ATTR "ww"
 
4762
+
 
4763
+#include "direct-move.h"
 
4764
--- a/src/gcc/testsuite/gcc.target/powerpc/dfp-td-2.c
 
4765
+++ b/src/gcc/testsuite/gcc.target/powerpc/dfp-td-2.c
 
4766
@@ -0,0 +1,29 @@
 
4767
+/* Test generation of DFP instructions for POWER6.  */
 
4768
+/* { dg-do compile { target { powerpc*-*-linux* && powerpc_fprs } } } */
 
4769
+/* { dg-options "-std=gnu99 -O1 -mcpu=power6" } */
 
4770
+
 
4771
+/* { dg-final { scan-assembler-times "fneg" 1 } } */
 
4772
+/* { dg-final { scan-assembler-times "fabs" 1 } } */
 
4773
+/* { dg-final { scan-assembler-times "fnabs" 1 } } */
 
4774
+/* { dg-final { scan-assembler-times "fmr" 0 } } */
 
4775
+
 
4776
+/* These tests verify we only generate fneg, fabs and fnabs
 
4777
+   instructions and no fmr's since these are done in place.  */
 
4778
+
 
4779
+_Decimal128
 
4780
+func1 (_Decimal128 a)
 
4781
+{
 
4782
+  return -a;
 
4783
+}
 
4784
+
 
4785
+_Decimal128
 
4786
+func2 (_Decimal128 a)
 
4787
+{
 
4788
+  return __builtin_fabsd128 (a);
 
4789
+}
 
4790
+
 
4791
+_Decimal128
 
4792
+func3 (_Decimal128 a)
 
4793
+{
 
4794
+  return - __builtin_fabsd128 (a);
 
4795
+}
 
4796
--- a/src/gcc/testsuite/gcc.target/powerpc/p8vector-builtin-5.c
 
4797
+++ b/src/gcc/testsuite/gcc.target/powerpc/p8vector-builtin-5.c
 
4798
@@ -0,0 +1,105 @@
 
4799
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
4800
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
4801
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
4802
+/* { dg-options "-mcpu=power8 -O2 -ftree-vectorize -fvect-cost-model -fno-unroll-loops -fno-unroll-all-loops" } */
 
4803
+
 
4804
+#include <altivec.h>
 
4805
+
 
4806
+#ifndef SIZE
 
4807
+#define SIZE 1024
 
4808
+#endif
 
4809
+
 
4810
+#ifndef ALIGN
 
4811
+#define ALIGN 32
 
4812
+#endif
 
4813
+
 
4814
+#ifndef ATTR_ALIGN
 
4815
+#define ATTR_ALIGN __attribute__((__aligned__(ALIGN)))
 
4816
+#endif
 
4817
+
 
4818
+#define DOIT(TYPE, PREFIX)                                             \
 
4819
+TYPE PREFIX ## _eqv_builtin (TYPE a, TYPE b)                           \
 
4820
+{                                                                      \
 
4821
+  return vec_eqv (a, b);                                               \
 
4822
+}                                                                      \
 
4823
+                                                                       \
 
4824
+TYPE PREFIX ## _eqv_arith (TYPE a, TYPE b)                             \
 
4825
+{                                                                      \
 
4826
+  return ~(a ^ b);                                                     \
 
4827
+}                                                                      \
 
4828
+                                                                       \
 
4829
+TYPE PREFIX ## _nand_builtin (TYPE a, TYPE b)                          \
 
4830
+{                                                                      \
 
4831
+  return vec_nand (a, b);                                              \
 
4832
+}                                                                      \
 
4833
+                                                                       \
 
4834
+TYPE PREFIX ## _nand_arith1 (TYPE a, TYPE b)                           \
 
4835
+{                                                                      \
 
4836
+  return ~(a & b);                                                     \
 
4837
+}                                                                      \
 
4838
+                                                                       \
 
4839
+TYPE PREFIX ## _nand_arith2 (TYPE a, TYPE b)                           \
 
4840
+{                                                                      \
 
4841
+  return (~a) | (~b);                                                  \
 
4842
+}                                                                      \
 
4843
+                                                                       \
 
4844
+TYPE PREFIX ## _orc_builtin (TYPE a, TYPE b)                           \
 
4845
+{                                                                      \
 
4846
+  return vec_orc (a, b);                                               \
 
4847
+}                                                                      \
 
4848
+                                                                       \
 
4849
+TYPE PREFIX ## _orc_arith1 (TYPE a, TYPE b)                            \
 
4850
+{                                                                      \
 
4851
+  return (~ a) | b;                                                    \
 
4852
+}                                                                      \
 
4853
+                                                                       \
 
4854
+TYPE PREFIX ## _orc_arith2 (TYPE a, TYPE b)                            \
 
4855
+{                                                                      \
 
4856
+  return a | (~ b);                                                    \
 
4857
+}
 
4858
+
 
4859
+#define DOIT_FLOAT(TYPE, PREFIX)                                       \
 
4860
+TYPE PREFIX ## _eqv_builtin (TYPE a, TYPE b)                           \
 
4861
+{                                                                      \
 
4862
+  return vec_eqv (a, b);                                               \
 
4863
+}                                                                      \
 
4864
+                                                                       \
 
4865
+TYPE PREFIX ## _nand_builtin (TYPE a, TYPE b)                          \
 
4866
+{                                                                      \
 
4867
+  return vec_nand (a, b);                                              \
 
4868
+}                                                                      \
 
4869
+                                                                       \
 
4870
+TYPE PREFIX ## _orc_builtin (TYPE a, TYPE b)                           \
 
4871
+{                                                                      \
 
4872
+  return vec_orc (a, b);                                               \
 
4873
+}
 
4874
+
 
4875
+typedef vector signed char             sign_char_vec;
 
4876
+typedef vector short                   sign_short_vec;
 
4877
+typedef vector int                     sign_int_vec;
 
4878
+typedef vector long long               sign_llong_vec;
 
4879
+
 
4880
+typedef vector unsigned char           uns_char_vec;
 
4881
+typedef vector unsigned short          uns_short_vec;
 
4882
+typedef vector unsigned int            uns_int_vec;
 
4883
+typedef vector unsigned long long      uns_llong_vec;
 
4884
+
 
4885
+typedef vector float                   float_vec;
 
4886
+typedef vector double                  double_vec;
 
4887
+
 
4888
+DOIT(sign_char_vec,    sign_char)
 
4889
+DOIT(sign_short_vec,   sign_short)
 
4890
+DOIT(sign_int_vec,     sign_int)
 
4891
+DOIT(sign_llong_vec,   sign_llong)
 
4892
+
 
4893
+DOIT(uns_char_vec,     uns_char)
 
4894
+DOIT(uns_short_vec,    uns_short)
 
4895
+DOIT(uns_int_vec,      uns_int)
 
4896
+DOIT(uns_llong_vec,    uns_llong)
 
4897
+
 
4898
+DOIT_FLOAT(float_vec,  float)
 
4899
+DOIT_FLOAT(double_vec, double)
 
4900
+
 
4901
+/* { dg-final { scan-assembler-times "xxleqv"  18 } } */
 
4902
+/* { dg-final { scan-assembler-times "xxlnand" 26 } } */
 
4903
+/* { dg-final { scan-assembler-times "xxlorc"  26 } } */
 
4904
--- a/src/gcc/testsuite/gcc.target/powerpc/p8vector-vectorize-5.c
 
4905
+++ b/src/gcc/testsuite/gcc.target/powerpc/p8vector-vectorize-5.c
 
4906
@@ -0,0 +1,87 @@
 
4907
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
4908
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
4909
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
4910
+/* { dg-options "-mcpu=power8 -O2 -ftree-vectorize -fvect-cost-model -fno-unroll-loops -fno-unroll-all-loops" } */
 
4911
+
 
4912
+#ifndef SIZE
 
4913
+#define SIZE 1024
 
4914
+#endif
 
4915
+
 
4916
+#ifndef ALIGN
 
4917
+#define ALIGN 32
 
4918
+#endif
 
4919
+
 
4920
+#ifndef ATTR_ALIGN
 
4921
+#define ATTR_ALIGN __attribute__((__aligned__(ALIGN)))
 
4922
+#endif
 
4923
+
 
4924
+#ifndef TYPE
 
4925
+#define TYPE unsigned int
 
4926
+#endif
 
4927
+
 
4928
+TYPE in1  [SIZE] ATTR_ALIGN;
 
4929
+TYPE in2  [SIZE] ATTR_ALIGN;
 
4930
+TYPE eqv  [SIZE] ATTR_ALIGN;
 
4931
+TYPE nand1[SIZE] ATTR_ALIGN;
 
4932
+TYPE nand2[SIZE] ATTR_ALIGN;
 
4933
+TYPE orc1 [SIZE] ATTR_ALIGN;
 
4934
+TYPE orc2 [SIZE] ATTR_ALIGN;
 
4935
+
 
4936
+void
 
4937
+do_eqv (void)
 
4938
+{
 
4939
+  unsigned long i;
 
4940
+
 
4941
+  for (i = 0; i < SIZE; i++)
 
4942
+    {
 
4943
+      eqv[i] = ~(in1[i] ^ in2[i]);
 
4944
+    }
 
4945
+}
 
4946
+
 
4947
+void
 
4948
+do_nand1 (void)
 
4949
+{
 
4950
+  unsigned long i;
 
4951
+
 
4952
+  for (i = 0; i < SIZE; i++)
 
4953
+    {
 
4954
+      nand1[i] = ~(in1[i] & in2[i]);
 
4955
+    }
 
4956
+}
 
4957
+
 
4958
+void
 
4959
+do_nand2 (void)
 
4960
+{
 
4961
+  unsigned long i;
 
4962
+
 
4963
+  for (i = 0; i < SIZE; i++)
 
4964
+    {
 
4965
+      nand2[i] = (~in1[i]) | (~in2[i]);
 
4966
+    }
 
4967
+}
 
4968
+
 
4969
+void
 
4970
+do_orc1 (void)
 
4971
+{
 
4972
+  unsigned long i;
 
4973
+
 
4974
+  for (i = 0; i < SIZE; i++)
 
4975
+    {
 
4976
+      orc1[i] = (~in1[i]) | in2[i];
 
4977
+    }
 
4978
+}
 
4979
+
 
4980
+void
 
4981
+do_orc2 (void)
 
4982
+{
 
4983
+  unsigned long i;
 
4984
+
 
4985
+  for (i = 0; i < SIZE; i++)
 
4986
+    {
 
4987
+      orc1[i] = in1[i] | (~in2[i]);
 
4988
+    }
 
4989
+}
 
4990
+
 
4991
+/* { dg-final { scan-assembler-times "xxleqv"  1 } } */
 
4992
+/* { dg-final { scan-assembler-times "xxlnand" 2 } } */
 
4993
+/* { dg-final { scan-assembler-times "xxlorc"  2 } } */
 
4994
--- a/src/gcc/testsuite/gcc.target/powerpc/pr57949-2.c
 
4995
+++ b/src/gcc/testsuite/gcc.target/powerpc/pr57949-2.c
 
4996
@@ -0,0 +1,20 @@
 
4997
+/* { dg-do compile { target { powerpc64*-*-* && lp64 } } } */
 
4998
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
4999
+/* { dg-skip-if "" { powerpc_elfv2 } { "*" } { "" } } */
 
5000
+/* { dg-options "-O2 -mcpu=power7" } */
 
5001
+
 
5002
+/* Verify that vs is not 16-byte aligned in the absence of -mno-compat-align-parm.  */
 
5003
+
 
5004
+typedef float v4sf __attribute__ ((vector_size (16)));
 
5005
+struct s { long m; v4sf v; };
 
5006
+long n;
 
5007
+v4sf ve;
 
5008
+
 
5009
+void pr57949 (long d1, long d2, long d3, long d4, long d5, long d6,
 
5010
+             long d7, long d8, long d9, struct s vs) {
 
5011
+  n = vs.m;
 
5012
+  ve = vs.v;
 
5013
+}
 
5014
+
 
5015
+/* { dg-final { scan-assembler "ld .\*,136\\(1\\)" } } */
 
5016
+/* { dg-final { scan-assembler "ld .\*,120\\(1\\)" } } */
 
5017
--- a/src/gcc/testsuite/gcc.target/powerpc/recip-5.c
 
5018
+++ b/src/gcc/testsuite/gcc.target/powerpc/recip-5.c
 
5019
@@ -4,8 +4,16 @@
 
5020
 /* { dg-options "-O3 -ftree-vectorize -mrecip=all -ffast-math -mcpu=power7 -fno-unroll-loops" } */
 
5021
 /* { dg-final { scan-assembler-times "xvredp" 4 } } */
 
5022
 /* { dg-final { scan-assembler-times "xvresp" 5 } } */
 
5023
-/* { dg-final { scan-assembler-times "xsredp" 2 } } */
 
5024
-/* { dg-final { scan-assembler-times "fres" 2 } } */
 
5025
+/* { dg-final { scan-assembler-times "xsredp\|fre\ " 2 } } */
 
5026
+/* { dg-final { scan-assembler-times "xsresp\|fres" 2 } } */
 
5027
+/* { dg-final { scan-assembler-times "xsmulsp\|fmuls" 2 } } */
 
5028
+/* { dg-final { scan-assembler-times "xsnmsub.sp\|fnmsubs" 2 } } */
 
5029
+/* { dg-final { scan-assembler-times "xsmuldp\|fmul\ " 2 } } */
 
5030
+/* { dg-final { scan-assembler-times "xsnmsub.dp\|fnmsub\ " 4 } } */
 
5031
+/* { dg-final { scan-assembler-times "xvmulsp" 7 } } */
 
5032
+/* { dg-final { scan-assembler-times "xvnmsub.sp" 5 } } */
 
5033
+/* { dg-final { scan-assembler-times "xvmuldp" 6 } } */
 
5034
+/* { dg-final { scan-assembler-times "xvnmsub.dp" 8 } } */
 
5035
 
 
5036
 #include <altivec.h>
 
5037
 
 
5038
--- a/src/gcc/testsuite/gcc.target/powerpc/ppc64-abi-1.c
 
5039
+++ b/src/gcc/testsuite/gcc.target/powerpc/ppc64-abi-1.c
 
5040
@@ -89,8 +89,10 @@
 
5041
   long a1;
 
5042
   long a2;
 
5043
   long a3;
 
5044
+#if _CALL_ELF != 2
 
5045
   long a4;
 
5046
   long a5;
 
5047
+#endif
 
5048
   parm_t slot[100];
 
5049
 } stack_frame_t;
 
5050
 
 
5051
--- a/src/gcc/testsuite/gcc.target/powerpc/direct-move-float2.c
 
5052
+++ b/src/gcc/testsuite/gcc.target/powerpc/direct-move-float2.c
 
5053
@@ -0,0 +1,15 @@
 
5054
+/* { dg-do run { target { powerpc*-*-linux* && lp64 } } } */
 
5055
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
5056
+/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
 
5057
+/* { dg-require-effective-target p8vector_hw } */
 
5058
+/* { dg-options "-mcpu=power8 -O2" } */
 
5059
+
 
5060
+/* Check whether we get the right bits for direct move at runtime.  */
 
5061
+
 
5062
+#define TYPE float
 
5063
+#define IS_FLOAT 1
 
5064
+#define NO_ALTIVEC 1
 
5065
+#define DO_MAIN
 
5066
+#define VSX_REG_ATTR "ww"
 
5067
+
 
5068
+#include "direct-move.h"
 
5069
--- a/src/gcc/testsuite/gcc.target/powerpc/direct-move-double1.c
 
5070
+++ b/src/gcc/testsuite/gcc.target/powerpc/direct-move-double1.c
 
5071
@@ -0,0 +1,16 @@
 
5072
+/* { dg-do compile { target { powerpc*-*-linux* && lp64 } } } */
 
5073
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
5074
+/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
 
5075
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
5076
+/* { dg-options "-mcpu=power8 -O2" } */
 
5077
+/* { dg-final { scan-assembler "mtvsrd" } } */
 
5078
+/* { dg-final { scan-assembler "mfvsrd" } } */
 
5079
+
 
5080
+/* Check code generation for direct move for double types.  */
 
5081
+
 
5082
+#define TYPE double
 
5083
+#define IS_FLOAT 1
 
5084
+#define NO_ALTIVEC 1
 
5085
+#define VSX_REG_ATTR "ws"
 
5086
+
 
5087
+#include "direct-move.h"
 
5088
--- a/src/gcc/testsuite/gcc.target/powerpc/dfp-td-3.c
 
5089
+++ b/src/gcc/testsuite/gcc.target/powerpc/dfp-td-3.c
 
5090
@@ -0,0 +1,29 @@
 
5091
+/* Test generation of DFP instructions for POWER6.  */
 
5092
+/* { dg-do compile { target { powerpc*-*-linux* && powerpc_fprs } } } */
 
5093
+/* { dg-options "-std=gnu99 -O1 -mcpu=power6" } */
 
5094
+
 
5095
+/* { dg-final { scan-assembler-times "fneg" 1 } } */
 
5096
+/* { dg-final { scan-assembler-times "fabs" 1 } } */
 
5097
+/* { dg-final { scan-assembler-times "fnabs" 1 } } */
 
5098
+/* { dg-final { scan-assembler-times "fmr" 3 } } */
 
5099
+
 
5100
+/* These tests verify we generate fneg, fabs and fnabs and
 
5101
+   associated fmr's since these are not done in place.  */
 
5102
+
 
5103
+_Decimal128
 
5104
+func1 (_Decimal128 a, _Decimal128 b)
 
5105
+{
 
5106
+  return -b;
 
5107
+}
 
5108
+
 
5109
+_Decimal128
 
5110
+func2 (_Decimal128 a, _Decimal128 b)
 
5111
+{
 
5112
+  return __builtin_fabsd128 (b);
 
5113
+}
 
5114
+
 
5115
+_Decimal128
 
5116
+func3 (_Decimal128 a, _Decimal128 b)
 
5117
+{
 
5118
+  return - __builtin_fabsd128 (b);
 
5119
+}
 
5120
--- a/src/gcc/testsuite/gcc.target/powerpc/p8vector-builtin-6.c
 
5121
+++ b/src/gcc/testsuite/gcc.target/powerpc/p8vector-builtin-6.c
 
5122
@@ -0,0 +1,10 @@
 
5123
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
5124
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
5125
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
5126
+/* { dg-options "-mcpu=power8 -O2" } */
 
5127
+
 
5128
+vector float dbl_to_float_p8 (double x) { return __builtin_vsx_xscvdpspn (x); }
 
5129
+double float_to_dbl_p8 (vector float x) { return __builtin_vsx_xscvspdpn (x); }
 
5130
+
 
5131
+/* { dg-final { scan-assembler "xscvdpspn" } } */
 
5132
+/* { dg-final { scan-assembler "xscvspdpn" } } */
 
5133
--- a/src/gcc/testsuite/gcc.target/powerpc/vsx-builtin-3.c
 
5134
+++ b/src/gcc/testsuite/gcc.target/powerpc/vsx-builtin-3.c
 
5135
@@ -16,9 +16,9 @@
 
5136
 /* { dg-final { scan-assembler "xvrspiz" } } */
 
5137
 /* { dg-final { scan-assembler "xsrdpi" } } */
 
5138
 /* { dg-final { scan-assembler "xsrdpic" } } */
 
5139
-/* { dg-final { scan-assembler "xsrdpim" } } */
 
5140
-/* { dg-final { scan-assembler "xsrdpip" } } */
 
5141
-/* { dg-final { scan-assembler "xsrdpiz" } } */
 
5142
+/* { dg-final { scan-assembler "xsrdpim\|frim" } } */
 
5143
+/* { dg-final { scan-assembler "xsrdpip\|frip" } } */
 
5144
+/* { dg-final { scan-assembler "xsrdpiz\|friz" } } */
 
5145
 /* { dg-final { scan-assembler "xsmaxdp" } } */
 
5146
 /* { dg-final { scan-assembler "xsmindp" } } */
 
5147
 /* { dg-final { scan-assembler "xxland" } } */
 
5148
--- a/src/gcc/testsuite/gcc.target/powerpc/htm-builtin-1.c
 
5149
+++ b/src/gcc/testsuite/gcc.target/powerpc/htm-builtin-1.c
 
5150
@@ -0,0 +1,51 @@
 
5151
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
5152
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
5153
+/* { dg-require-effective-target powerpc_htm_ok } */
 
5154
+/* { dg-options "-O2 -mhtm" } */
 
5155
+
 
5156
+/* { dg-final { scan-assembler-times "tbegin\\." 1 } } */
 
5157
+/* { dg-final { scan-assembler-times "tend\\." 2 } } */
 
5158
+/* { dg-final { scan-assembler-times "tabort\\." 2 } } */
 
5159
+/* { dg-final { scan-assembler-times "tabortdc\\." 1 } } */
 
5160
+/* { dg-final { scan-assembler-times "tabortdci\\." 1 } } */
 
5161
+/* { dg-final { scan-assembler-times "tabortwc\\." 1 } } */
 
5162
+/* { dg-final { scan-assembler-times "tabortwci\\." 2 } } */
 
5163
+/* { dg-final { scan-assembler-times "tcheck\\." 1 } } */
 
5164
+/* { dg-final { scan-assembler-times "trechkpt\\." 1 } } */
 
5165
+/* { dg-final { scan-assembler-times "treclaim\\." 1 } } */
 
5166
+/* { dg-final { scan-assembler-times "tsr\\." 3 } } */
 
5167
+/* { dg-final { scan-assembler-times "mfspr" 4 } } */
 
5168
+/* { dg-final { scan-assembler-times "mtspr" 4 } } */
 
5169
+
 
5170
+void use_builtins (long *p, char code, long *a, long *b)
 
5171
+{
 
5172
+  p[0] = __builtin_tbegin (0);
 
5173
+  p[1] = __builtin_tend (0);
 
5174
+  p[2] = __builtin_tendall ();
 
5175
+  p[3] = __builtin_tabort (0);
 
5176
+  p[4] = __builtin_tabort (code);
 
5177
+
 
5178
+  p[5] = __builtin_tabortdc (0xf, a[5], b[5]);
 
5179
+  p[6] = __builtin_tabortdci (0xf, a[6], 13);
 
5180
+  p[7] = __builtin_tabortwc (0xf, a[7], b[7]);
 
5181
+  p[8] = __builtin_tabortwci (0xf, a[8], 13);
 
5182
+
 
5183
+  p[9] = __builtin_tcheck (5);
 
5184
+  p[10] = __builtin_trechkpt ();
 
5185
+  p[11] = __builtin_treclaim (0);
 
5186
+  p[12] = __builtin_tresume ();
 
5187
+  p[13] = __builtin_tsuspend ();
 
5188
+  p[14] = __builtin_tsr (0);
 
5189
+  p[15] = __builtin_ttest (); /* This expands to a tabortwci.  */
 
5190
+
 
5191
+
 
5192
+  p[16] = __builtin_get_texasr ();
 
5193
+  p[17] = __builtin_get_texasru ();
 
5194
+  p[18] = __builtin_get_tfhar ();
 
5195
+  p[19] = __builtin_get_tfiar ();
 
5196
+
 
5197
+  __builtin_set_texasr (a[20]);
 
5198
+  __builtin_set_texasru (a[21]);
 
5199
+  __builtin_set_tfhar (a[22]);
 
5200
+  __builtin_set_tfiar (a[23]);
 
5201
+}
 
5202
--- a/src/gcc/testsuite/gcc.target/powerpc/bool.c
 
5203
+++ b/src/gcc/testsuite/gcc.target/powerpc/bool.c
 
5204
@@ -0,0 +1,14 @@
 
5205
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
5206
+/* { dg-options "-O2" } */
 
5207
+/* { dg-final { scan-assembler "eqv" } } */
 
5208
+/* { dg-final { scan-assembler "nand" } } */
 
5209
+/* { dg-final { scan-assembler "nor" } } */
 
5210
+
 
5211
+#ifndef TYPE
 
5212
+#define TYPE unsigned long
 
5213
+#endif
 
5214
+
 
5215
+TYPE op1 (TYPE a, TYPE b) { return ~(a ^ b); } /* eqv */
 
5216
+TYPE op2 (TYPE a, TYPE b) { return ~(a & b); } /* nand */
 
5217
+TYPE op3 (TYPE a, TYPE b) { return ~(a | b); } /* nor */
 
5218
+
 
5219
--- a/src/gcc/testsuite/gcc.target/powerpc/bool2-p5.c
 
5220
+++ b/src/gcc/testsuite/gcc.target/powerpc/bool2-p5.c
 
5221
@@ -0,0 +1,32 @@
 
5222
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
5223
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
5224
+/* { dg-require-effective-target powerpc_altivec_ok } */
 
5225
+/* { dg-options "-O2 -mcpu=power5 -mabi=altivec -mno-altivec -mno-vsx" } */
 
5226
+/* { dg-final { scan-assembler    "\[ \t\]and "     } } */
 
5227
+/* { dg-final { scan-assembler    "\[ \t\]or "      } } */
 
5228
+/* { dg-final { scan-assembler    "\[ \t\]xor "     } } */
 
5229
+/* { dg-final { scan-assembler    "\[ \t\]nor "     } } */
 
5230
+/* { dg-final { scan-assembler    "\[ \t\]andc "    } } */
 
5231
+/* { dg-final { scan-assembler    "\[ \t\]eqv "     } } */
 
5232
+/* { dg-final { scan-assembler    "\[ \t\]orc "     } } */
 
5233
+/* { dg-final { scan-assembler    "\[ \t\]nand "    } } */
 
5234
+/* { dg-final { scan-assembler-not "\[ \t\]vand "    } } */
 
5235
+/* { dg-final { scan-assembler-not "\[ \t\]vandc "   } } */
 
5236
+/* { dg-final { scan-assembler-not "\[ \t\]vor "     } } */
 
5237
+/* { dg-final { scan-assembler-not "\[ \t\]vxor "    } } */
 
5238
+/* { dg-final { scan-assembler-not "\[ \t\]vnor "    } } */
 
5239
+/* { dg-final { scan-assembler-not "\[ \t\]xxland "  } } */
 
5240
+/* { dg-final { scan-assembler-not "\[ \t\]xxlor "   } } */
 
5241
+/* { dg-final { scan-assembler-not "\[ \t\]xxlxor "  } } */
 
5242
+/* { dg-final { scan-assembler-not "\[ \t\]xxlnor "  } } */
 
5243
+/* { dg-final { scan-assembler-not "\[ \t\]xxlandc " } } */
 
5244
+/* { dg-final { scan-assembler-not "\[ \t\]xxleqv "  } } */
 
5245
+/* { dg-final { scan-assembler-not "\[ \t\]xxlorc "  } } */
 
5246
+/* { dg-final { scan-assembler-not "\[ \t\]xxlnand " } } */
 
5247
+
 
5248
+#ifndef TYPE
 
5249
+typedef int v4si __attribute__ ((vector_size (16)));
 
5250
+#define TYPE v4si
 
5251
+#endif
 
5252
+
 
5253
+#include "bool2.h"
 
5254
--- a/src/gcc/testsuite/gcc.target/powerpc/fusion.c
 
5255
+++ b/src/gcc/testsuite/gcc.target/powerpc/fusion.c
 
5256
@@ -0,0 +1,24 @@
 
5257
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
5258
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
5259
+/* { dg-skip-if "" { powerpc*le-*-* } { "*" } { "" } } */
 
5260
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
5261
+/* { dg-options "-mcpu=power7 -mtune=power8 -O3" } */
 
5262
+
 
5263
+#define LARGE 0x12345
 
5264
+
 
5265
+int fusion_uchar (unsigned char *p){ return p[LARGE]; }
 
5266
+int fusion_schar (signed char *p){ return p[LARGE]; }
 
5267
+int fusion_ushort (unsigned short *p){ return p[LARGE]; }
 
5268
+int fusion_short (short *p){ return p[LARGE]; }
 
5269
+int fusion_int (int *p){ return p[LARGE]; }
 
5270
+unsigned fusion_uns (unsigned *p){ return p[LARGE]; }
 
5271
+
 
5272
+vector double fusion_vector (vector double *p) { return p[2]; }
 
5273
+
 
5274
+/* { dg-final { scan-assembler-times "gpr load fusion"    6 } } */
 
5275
+/* { dg-final { scan-assembler-times "vector load fusion" 1 } } */
 
5276
+/* { dg-final { scan-assembler-times "lbz"                2 } } */
 
5277
+/* { dg-final { scan-assembler-times "extsb"              1 } } */
 
5278
+/* { dg-final { scan-assembler-times "lhz"                2 } } */
 
5279
+/* { dg-final { scan-assembler-times "extsh"              1 } } */
 
5280
+/* { dg-final { scan-assembler-times "lwz"                2 } } */
 
5281
--- a/src/gcc/testsuite/gcc.target/powerpc/ppc64-abi-2.c
 
5282
+++ b/src/gcc/testsuite/gcc.target/powerpc/ppc64-abi-2.c
 
5283
@@ -107,8 +107,10 @@
 
5284
   long a1;
 
5285
   long a2;
 
5286
   long a3;
 
5287
+#if _CALL_ELF != 2
 
5288
   long a4;
 
5289
   long a5;
 
5290
+#endif
 
5291
   parm_t slot[100];
 
5292
 } stack_frame_t;
 
5293
 
 
5294
@@ -119,6 +121,12 @@
 
5295
   vector int v;
 
5296
 } vector_int_t;
 
5297
 
 
5298
+#ifdef __LITTLE_ENDIAN__
 
5299
+#define MAKE_SLOT(x, y) ((long)x | ((long)y << 32))
 
5300
+#else
 
5301
+#define MAKE_SLOT(x, y) ((long)y | ((long)x << 32))
 
5302
+#endif
 
5303
+
 
5304
 /* Paramter passing.
 
5305
    s : gpr 3
 
5306
    v : vpr 2
 
5307
@@ -226,8 +234,8 @@
 
5308
   sp = __builtin_frame_address(0);
 
5309
   sp = sp->backchain;
 
5310
   
 
5311
-  if (sp->slot[2].l != 0x100000002ULL
 
5312
-      || sp->slot[4].l != 0x500000006ULL)
 
5313
+  if (sp->slot[2].l != MAKE_SLOT (1, 2)
 
5314
+      || sp->slot[4].l !=  MAKE_SLOT (5, 6))
 
5315
     abort();
 
5316
 }
 
5317
 
 
5318
@@ -268,8 +276,8 @@
 
5319
   sp = __builtin_frame_address(0);
 
5320
   sp = sp->backchain;
 
5321
   
 
5322
-  if (sp->slot[4].l != 0x100000002ULL
 
5323
-      || sp->slot[6].l != 0x500000006ULL)
 
5324
+  if (sp->slot[4].l != MAKE_SLOT (1, 2)
 
5325
+      || sp->slot[6].l !=  MAKE_SLOT (5, 6))
 
5326
     abort();
 
5327
 }
 
5328
 
 
5329
@@ -296,8 +304,8 @@
 
5330
   sp = __builtin_frame_address(0);
 
5331
   sp = sp->backchain;
 
5332
   
 
5333
-  if (sp->slot[4].l != 0x100000002ULL
 
5334
-      || sp->slot[6].l != 0x500000006ULL)
 
5335
+  if (sp->slot[4].l != MAKE_SLOT (1, 2)
 
5336
+      || sp->slot[6].l !=  MAKE_SLOT (5, 6))
 
5337
     abort();
 
5338
 }
 
5339
 
 
5340
--- a/src/gcc/testsuite/gcc.target/powerpc/direct-move-long1.c
 
5341
+++ b/src/gcc/testsuite/gcc.target/powerpc/direct-move-long1.c
 
5342
@@ -0,0 +1,16 @@
 
5343
+/* { dg-do compile { target { powerpc*-*-linux* && lp64 } } } */
 
5344
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
5345
+/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
 
5346
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
5347
+/* { dg-options "-mcpu=power8 -O2" } */
 
5348
+/* { dg-final { scan-assembler "mtvsrd" } } */
 
5349
+/* { dg-final { scan-assembler "mfvsrd" } } */
 
5350
+
 
5351
+/* Check code generation for direct move for long types.  */
 
5352
+
 
5353
+#define TYPE long
 
5354
+#define IS_INT 1
 
5355
+#define NO_ALTIVEC 1
 
5356
+#define VSX_REG_ATTR "d"
 
5357
+
 
5358
+#include "direct-move.h"
 
5359
--- a/src/gcc/testsuite/gcc.target/powerpc/direct-move-double2.c
 
5360
+++ b/src/gcc/testsuite/gcc.target/powerpc/direct-move-double2.c
 
5361
@@ -0,0 +1,15 @@
 
5362
+/* { dg-do run { target { powerpc*-*-linux* && lp64 } } } */
 
5363
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
5364
+/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
 
5365
+/* { dg-require-effective-target p8vector_hw } */
 
5366
+/* { dg-options "-mcpu=power8 -O2" } */
 
5367
+
 
5368
+/* Check whether we get the right bits for direct move at runtime.  */
 
5369
+
 
5370
+#define TYPE double
 
5371
+#define IS_FLOAT 1
 
5372
+#define NO_ALTIVEC 1
 
5373
+#define DO_MAIN
 
5374
+#define VSX_REG_ATTR "ws"
 
5375
+
 
5376
+#include "direct-move.h"
 
5377
--- a/src/gcc/testsuite/gcc.target/powerpc/p8vector-builtin-7.c
 
5378
+++ b/src/gcc/testsuite/gcc.target/powerpc/p8vector-builtin-7.c
 
5379
@@ -0,0 +1,32 @@
 
5380
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
5381
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
5382
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 
5383
+/* { dg-options "-mcpu=power8 -O2" } */
 
5384
+
 
5385
+#include <altivec.h>
 
5386
+
 
5387
+typedef vector int             v_sign;
 
5388
+typedef vector unsigned int    v_uns;
 
5389
+
 
5390
+v_sign even_sign (v_sign a, v_sign b)
 
5391
+{
 
5392
+  return vec_vmrgew (a, b);
 
5393
+}
 
5394
+
 
5395
+v_uns even_uns (v_uns a, v_uns b)
 
5396
+{
 
5397
+  return vec_vmrgew (a, b);
 
5398
+}
 
5399
+
 
5400
+v_sign odd_sign (v_sign a, v_sign b)
 
5401
+{
 
5402
+  return vec_vmrgow (a, b);
 
5403
+}
 
5404
+
 
5405
+v_uns odd_uns (v_uns a, v_uns b)
 
5406
+{
 
5407
+  return vec_vmrgow (a, b);
 
5408
+}
 
5409
+
 
5410
+/* { dg-final { scan-assembler-times "vmrgew" 2 } } */
 
5411
+/* { dg-final { scan-assembler-times "vmrgow" 2 } } */
 
5412
--- a/src/gcc/testsuite/gcc.target/powerpc/bool2.h
 
5413
+++ b/src/gcc/testsuite/gcc.target/powerpc/bool2.h
 
5414
@@ -0,0 +1,29 @@
 
5415
+/* Test various logical operations.  */
 
5416
+
 
5417
+TYPE arg1 (TYPE p, TYPE q) { return p & q; }           /* AND  */
 
5418
+TYPE arg2 (TYPE p, TYPE q) { return p | q; }           /* OR   */
 
5419
+TYPE arg3 (TYPE p, TYPE q) { return p ^ q; }           /* XOR  */
 
5420
+TYPE arg4 (TYPE p)        { return ~ p; }              /* NOR  */
 
5421
+TYPE arg5 (TYPE p, TYPE q) { return ~(p & q); }                /* NAND */
 
5422
+TYPE arg6 (TYPE p, TYPE q) { return ~(p | q); }                /* NOR  */
 
5423
+TYPE arg7 (TYPE p, TYPE q) { return ~(p ^ q); }                /* EQV  */
 
5424
+TYPE arg8 (TYPE p, TYPE q) { return (~p) & q; }                /* ANDC */
 
5425
+TYPE arg9 (TYPE p, TYPE q) { return (~p) | q; }                /* ORC  */
 
5426
+TYPE arg10(TYPE p, TYPE q) { return (~p) ^ q; }                /* EQV  */
 
5427
+TYPE arg11(TYPE p, TYPE q) { return p & (~q); }                /* ANDC */
 
5428
+TYPE arg12(TYPE p, TYPE q) { return p | (~q); }                /* ORC  */
 
5429
+TYPE arg13(TYPE p, TYPE q) { return p ^ (~q); }                /* EQV  */
 
5430
+
 
5431
+void ptr1 (TYPE *p) { p[0] = p[1] & p[2]; }            /* AND  */
 
5432
+void ptr2 (TYPE *p) { p[0] = p[1] | p[2]; }            /* OR   */
 
5433
+void ptr3 (TYPE *p) { p[0] = p[1] ^ p[2]; }            /* XOR  */
 
5434
+void ptr4 (TYPE *p) { p[0] = ~p[1]; }                  /* NOR  */
 
5435
+void ptr5 (TYPE *p) { p[0] = ~(p[1] & p[2]); }         /* NAND */
 
5436
+void ptr6 (TYPE *p) { p[0] = ~(p[1] | p[2]); }         /* NOR  */
 
5437
+void ptr7 (TYPE *p) { p[0] = ~(p[1] ^ p[2]); }         /* EQV  */
 
5438
+void ptr8 (TYPE *p) { p[0] = ~(p[1]) & p[2]; }         /* ANDC */
 
5439
+void ptr9 (TYPE *p) { p[0] = (~p[1]) | p[2]; }         /* ORC  */
 
5440
+void ptr10(TYPE *p) { p[0] = (~p[1]) ^ p[2]; }         /* EQV  */
 
5441
+void ptr11(TYPE *p) { p[0] = p[1] & (~p[2]); }         /* ANDC */
 
5442
+void ptr12(TYPE *p) { p[0] = p[1] | (~p[2]); }         /* ORC  */
 
5443
+void ptr13(TYPE *p) { p[0] = p[1] ^ (~p[2]); }         /* EQV  */
 
5444
--- a/src/gcc/testsuite/gcc.target/powerpc/pr48258-1.c
 
5445
+++ b/src/gcc/testsuite/gcc.target/powerpc/pr48258-1.c
 
5446
@@ -1,5 +1,6 @@
 
5447
 /* { dg-do compile } */
 
5448
 /* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
5449
+/* { dg-skip-if "" { powerpc*le-*-* } { "*" } { "" } } */
 
5450
 /* { dg-require-effective-target powerpc_vsx_ok } */
 
5451
 /* { dg-options "-O3 -mcpu=power7 -mabi=altivec -ffast-math -fno-unroll-loops" } */
 
5452
 /* { dg-final { scan-assembler-times "xvaddsp" 3 } } */
 
5453
--- a/src/gcc/testsuite/gcc.target/powerpc/ppc64-abi-dfp-1.c
 
5454
+++ b/src/gcc/testsuite/gcc.target/powerpc/ppc64-abi-dfp-1.c
 
5455
@@ -33,15 +33,27 @@
 
5456
 
 
5457
 
 
5458
 /* Wrapper to save the GPRs and FPRs and then jump to the real function.  */
 
5459
+#if _CALL_ELF != 2
 
5460
+#define FUNC_START(NAME)                                               \
 
5461
+       "\t.globl\t" NAME "\n\t"                                        \
 
5462
+         ".section \".opd\",\"aw\"\n\t"                                        \
 
5463
+         ".align 3\n"                                                  \
 
5464
+         NAME ":\n\t"                                                  \
 
5465
+         ".quad .L." NAME ",.TOC.@tocbase,0\n\t"                       \
 
5466
+         ".text\n\t"                                                   \
 
5467
+         ".type " NAME ", @function\n"                                 \
 
5468
+         ".L." NAME ":\n\t"
 
5469
+#else
 
5470
+#define FUNC_START(NAME)                                               \
 
5471
+       "\t.globl\t" NAME "\n\t"                                        \
 
5472
+         ".text\n\t"                                                   \
 
5473
+         NAME ":\n"                                                    \
 
5474
+       "0:\taddis 2,12,(.TOC.-0b)@ha\n\t"                              \
 
5475
+       "addi 2,2,(.TOC.-0b)@l\n\t"                                     \
 
5476
+       ".localentry " NAME ",.-" NAME "\n\t"
 
5477
+#endif
 
5478
 #define WRAPPER(NAME)                                                  \
 
5479
-__asm__ ("\t.globl\t" #NAME "_asm\n\t"                                 \
 
5480
-        ".section \".opd\",\"aw\"\n\t"                                 \
 
5481
-        ".align 3\n"                                                   \
 
5482
-        #NAME "_asm:\n\t"                                              \
 
5483
-        ".quad .L." #NAME "_asm,.TOC.@tocbase,0\n\t"                   \
 
5484
-        ".text\n\t"                                                    \
 
5485
-        ".type " #NAME "_asm, @function\n"                             \
 
5486
-        ".L." #NAME "_asm:\n\t"                                        \
 
5487
+__asm__ (FUNC_START (#NAME "_asm")                                     \
 
5488
         "ld 11,gparms@got(2)\n\t"                                      \
 
5489
         "std 3,0(11)\n\t"                                              \
 
5490
         "std 4,8(11)\n\t"                                              \
 
5491
@@ -75,8 +87,10 @@
 
5492
   long a1;
 
5493
   long a2;
 
5494
   long a3;
 
5495
+#if _CALL_ELF != 2
 
5496
   long a4;
 
5497
   long a5;
 
5498
+#endif
 
5499
   unsigned long slot[100];
 
5500
 } stack_frame_t;
 
5501
 
 
5502
--- a/src/gcc/testsuite/gcc.target/powerpc/direct-move-long2.c
 
5503
+++ b/src/gcc/testsuite/gcc.target/powerpc/direct-move-long2.c
 
5504
@@ -0,0 +1,15 @@
 
5505
+/* { dg-do run { target { powerpc*-*-linux* && lp64 } } } */
 
5506
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
5507
+/* { dg-skip-if "" { powerpc*-*-*spe* } { "*" } { "" } } */
 
5508
+/* { dg-require-effective-target p8vector_hw } */
 
5509
+/* { dg-options "-mcpu=power8 -O2" } */
 
5510
+
 
5511
+/* Check whether we get the right bits for direct move at runtime.  */
 
5512
+
 
5513
+#define TYPE long
 
5514
+#define IS_INT 1
 
5515
+#define NO_ALTIVEC 1
 
5516
+#define DO_MAIN
 
5517
+#define VSX_REG_ATTR "d"
 
5518
+
 
5519
+#include "direct-move.h"
 
5520
--- a/src/gcc/testsuite/gcc.target/powerpc/vsx-float0.c
 
5521
+++ b/src/gcc/testsuite/gcc.target/powerpc/vsx-float0.c
 
5522
@@ -0,0 +1,16 @@
 
5523
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
5524
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
5525
+/* { dg-require-effective-target powerpc_vsx_ok } */
 
5526
+/* { dg-options "-O2 -mcpu=power7" } */
 
5527
+/* { dg-final { scan-assembler "xxlxor" } } */
 
5528
+
 
5529
+/* Test that we generate xxlor to clear a SFmode register.  */
 
5530
+
 
5531
+float sum (float *p, unsigned long n)
 
5532
+{
 
5533
+  float sum = 0.0f;    /* generate xxlxor instead of load */
 
5534
+  while (n-- > 0)
 
5535
+    sum += *p++;
 
5536
+
 
5537
+  return sum;
 
5538
+}
 
5539
--- a/src/gcc/testsuite/gcc.target/powerpc/ppc-target-1.c
 
5540
+++ b/src/gcc/testsuite/gcc.target/powerpc/ppc-target-1.c
 
5541
@@ -5,8 +5,7 @@
 
5542
 /* { dg-final { scan-assembler-times "fabs" 3 } } */
 
5543
 /* { dg-final { scan-assembler-times "fnabs" 3 } } */
 
5544
 /* { dg-final { scan-assembler-times "fsel" 3 } } */
 
5545
-/* { dg-final { scan-assembler-times "fcpsgn" 3 } } */
 
5546
-/* { dg-final { scan-assembler-times "xscpsgndp" 1 } } */
 
5547
+/* { dg-final { scan-assembler-times "fcpsgn\|xscpsgndp" 4 } } */
 
5548
 
 
5549
 double normal1 (double, double);
 
5550
 double power5  (double, double) __attribute__((__target__("cpu=power5")));
 
5551
--- a/src/gcc/testsuite/gcc.target/powerpc/bool3.h
 
5552
+++ b/src/gcc/testsuite/gcc.target/powerpc/bool3.h
 
5553
@@ -0,0 +1,186 @@
 
5554
+/* Test forcing 128-bit logical types into GPR registers.  */
 
5555
+
 
5556
+#if defined(NO_ASM)
 
5557
+#define FORCE_REG1(X)
 
5558
+#define FORCE_REG2(X,Y)
 
5559
+
 
5560
+#else
 
5561
+#if defined(USE_ALTIVEC)
 
5562
+#define REG_CLASS "+v"
 
5563
+#define PRINT_REG1 "# altivec reg %0"
 
5564
+#define PRINT_REG2 "# altivec reg %0, %1"
 
5565
+
 
5566
+#elif defined(USE_FPR)
 
5567
+#define REG_CLASS "+d"
 
5568
+#define PRINT_REG1 "# fpr reg %0"
 
5569
+#define PRINT_REG2 "# fpr reg %0, %1"
 
5570
+
 
5571
+#elif defined(USE_VSX)
 
5572
+#define REG_CLASS "+wa"
 
5573
+#define PRINT_REG1 "# vsx reg %x0"
 
5574
+#define PRINT_REG2 "# vsx reg %x0, %x1"
 
5575
+
 
5576
+#else
 
5577
+#define REG_CLASS "+r"
 
5578
+#define PRINT_REG1 "# gpr reg %0"
 
5579
+#define PRINT_REG2 "# gpr reg %0, %1"
 
5580
+#endif
 
5581
+
 
5582
+#define FORCE_REG1(X) __asm__ (PRINT_REG1 : REG_CLASS (X))
 
5583
+#define FORCE_REG2(X,Y) __asm__ (PRINT_REG2 : REG_CLASS (X), REG_CLASS (Y))
 
5584
+#endif
 
5585
+
 
5586
+void ptr1 (TYPE *p)
 
5587
+{
 
5588
+  TYPE a = p[1];
 
5589
+  TYPE b = p[2];
 
5590
+  TYPE c;
 
5591
+
 
5592
+  FORCE_REG2 (a, b);
 
5593
+  c = a & b;                                   /* AND */
 
5594
+  FORCE_REG1 (c);
 
5595
+  p[0] = c;
 
5596
+}
 
5597
+
 
5598
+void ptr2 (TYPE *p)
 
5599
+{
 
5600
+  TYPE a = p[1];
 
5601
+  TYPE b = p[2];
 
5602
+  TYPE c;
 
5603
+
 
5604
+  FORCE_REG2 (a, b);
 
5605
+  c = a | b;                                   /* OR */
 
5606
+  FORCE_REG1 (c);
 
5607
+  p[0] = c;
 
5608
+}
 
5609
+
 
5610
+void ptr3 (TYPE *p)
 
5611
+{
 
5612
+  TYPE a = p[1];
 
5613
+  TYPE b = p[2];
 
5614
+  TYPE c;
 
5615
+
 
5616
+  FORCE_REG2 (a, b);
 
5617
+  c = a ^ b;                                   /* XOR */
 
5618
+  FORCE_REG1 (c);
 
5619
+  p[0] = c;
 
5620
+}
 
5621
+
 
5622
+void ptr4 (TYPE *p)
 
5623
+{
 
5624
+  TYPE a = p[1];
 
5625
+  TYPE b;
 
5626
+
 
5627
+  FORCE_REG1 (a);
 
5628
+  b = ~a;                                      /* NOR */
 
5629
+  FORCE_REG1 (b);
 
5630
+  p[0] = b;
 
5631
+}
 
5632
+
 
5633
+void ptr5 (TYPE *p)
 
5634
+{
 
5635
+  TYPE a = p[1];
 
5636
+  TYPE b = p[2];
 
5637
+  TYPE c;
 
5638
+
 
5639
+  FORCE_REG2 (a, b);
 
5640
+  c = ~(a & b);                                           /* NAND */
 
5641
+  FORCE_REG1 (c);
 
5642
+  p[0] = c;
 
5643
+}
 
5644
+
 
5645
+void ptr6 (TYPE *p)
 
5646
+{
 
5647
+  TYPE a = p[1];
 
5648
+  TYPE b = p[2];
 
5649
+  TYPE c;
 
5650
+
 
5651
+  FORCE_REG2 (a, b);
 
5652
+  c = ~(a | b);                                           /* AND */
 
5653
+  FORCE_REG1 (c);
 
5654
+  p[0] = c;
 
5655
+}
 
5656
+
 
5657
+void ptr7 (TYPE *p)
 
5658
+{
 
5659
+  TYPE a = p[1];
 
5660
+  TYPE b = p[2];
 
5661
+  TYPE c;
 
5662
+
 
5663
+  FORCE_REG2 (a, b);
 
5664
+  c = ~(a ^ b);                                           /* EQV */
 
5665
+  FORCE_REG1 (c);
 
5666
+  p[0] = c;
 
5667
+}
 
5668
+
 
5669
+void ptr8 (TYPE *p)
 
5670
+{
 
5671
+  TYPE a = p[1];
 
5672
+  TYPE b = p[2];
 
5673
+  TYPE c;
 
5674
+
 
5675
+  FORCE_REG2 (a, b);
 
5676
+  c = (~a) & b;                                           /* ANDC */
 
5677
+  FORCE_REG1 (c);
 
5678
+  p[0] = c;
 
5679
+}
 
5680
+
 
5681
+void ptr9 (TYPE *p)
 
5682
+{
 
5683
+  TYPE a = p[1];
 
5684
+  TYPE b = p[2];
 
5685
+  TYPE c;
 
5686
+
 
5687
+  FORCE_REG2 (a, b);
 
5688
+  c = (~a) | b;                                           /* ORC */
 
5689
+  FORCE_REG1 (c);
 
5690
+  p[0] = c;
 
5691
+}
 
5692
+
 
5693
+void ptr10 (TYPE *p)
 
5694
+{
 
5695
+  TYPE a = p[1];
 
5696
+  TYPE b = p[2];
 
5697
+  TYPE c;
 
5698
+
 
5699
+  FORCE_REG2 (a, b);
 
5700
+  c = (~a) ^ b;                                           /* EQV */
 
5701
+  FORCE_REG1 (c);
 
5702
+  p[0] = c;
 
5703
+}
 
5704
+
 
5705
+void ptr11 (TYPE *p)
 
5706
+{
 
5707
+  TYPE a = p[1];
 
5708
+  TYPE b = p[2];
 
5709
+  TYPE c;
 
5710
+
 
5711
+  FORCE_REG2 (a, b);
 
5712
+  c = a & (~b);                                           /* ANDC */
 
5713
+  FORCE_REG1 (c);
 
5714
+  p[0] = c;
 
5715
+}
 
5716
+
 
5717
+void ptr12 (TYPE *p)
 
5718
+{
 
5719
+  TYPE a = p[1];
 
5720
+  TYPE b = p[2];
 
5721
+  TYPE c;
 
5722
+
 
5723
+  FORCE_REG2 (a, b);
 
5724
+  c = a | (~b);                                           /* ORC */
 
5725
+  FORCE_REG1 (c);
 
5726
+  p[0] = c;
 
5727
+}
 
5728
+
 
5729
+void ptr13 (TYPE *p)
 
5730
+{
 
5731
+  TYPE a = p[1];
 
5732
+  TYPE b = p[2];
 
5733
+  TYPE c;
 
5734
+
 
5735
+  FORCE_REG2 (a, b);
 
5736
+  c = a ^ (~b);                                           /* AND */
 
5737
+  FORCE_REG1 (c);
 
5738
+  p[0] = c;
 
5739
+}
 
5740
--- a/src/gcc/testsuite/gcc.target/powerpc/altivec-perm-1.c
 
5741
+++ b/src/gcc/testsuite/gcc.target/powerpc/altivec-perm-1.c
 
5742
@@ -19,19 +19,6 @@
 
5743
   return __builtin_shuffle(x, (V){ 4,5,6,7, 4,5,6,7, 4,5,6,7, 4,5,6,7, });
 
5744
 }
 
5745
 
 
5746
-V p2(V x, V y)
 
5747
-{
 
5748
-  return __builtin_shuffle(x, y,
 
5749
-       (V){ 1,  3,  5,  7,  9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31 });
 
5750
-
 
5751
-}
 
5752
-
 
5753
-V p4(V x, V y)
 
5754
-{
 
5755
-  return __builtin_shuffle(x, y,
 
5756
-       (V){ 2,  3,  6,  7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31 });
 
5757
-}
 
5758
-
 
5759
 V h1(V x, V y)
 
5760
 {
 
5761
   return __builtin_shuffle(x, y,
 
5762
@@ -72,5 +59,3 @@
 
5763
 /* { dg-final { scan-assembler "vspltb" } } */
 
5764
 /* { dg-final { scan-assembler "vsplth" } } */
 
5765
 /* { dg-final { scan-assembler "vspltw" } } */
 
5766
-/* { dg-final { scan-assembler "vpkuhum" } } */
 
5767
-/* { dg-final { scan-assembler "vpkuwum" } } */
 
5768
--- a/src/gcc/testsuite/gcc.target/powerpc/bool2-p7.c
 
5769
+++ b/src/gcc/testsuite/gcc.target/powerpc/bool2-p7.c
 
5770
@@ -0,0 +1,31 @@
 
5771
+/* { dg-do compile { target { powerpc*-*-* } } } */
 
5772
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 
5773
+/* { dg-require-effective-target powerpc_vsx_ok } */
 
5774
+/* { dg-options "-O2 -mcpu=power7" } */
 
5775
+/* { dg-final { scan-assembler-not "\[ \t\]and "     } } */
 
5776
+/* { dg-final { scan-assembler-not "\[ \t\]or "      } } */
 
5777
+/* { dg-final { scan-assembler-not "\[ \t\]xor "     } } */
 
5778
+/* { dg-final { scan-assembler-not "\[ \t\]nor "     } } */
 
5779
+/* { dg-final { scan-assembler-not "\[ \t\]eqv "     } } */
 
5780
+/* { dg-final { scan-assembler-not "\[ \t\]andc "    } } */
 
5781
+/* { dg-final { scan-assembler-not "\[ \t\]orc "     } } */
 
5782
+/* { dg-final { scan-assembler-not "\[ \t\]nand "    } } */
 
5783
+/* { dg-final { scan-assembler-not "\[ \t\]vand "    } } */
 
5784
+/* { dg-final { scan-assembler-not "\[ \t\]vor "     } } */
 
5785
+/* { dg-final { scan-assembler-not "\[ \t\]vxor "    } } */
 
5786
+/* { dg-final { scan-assembler-not "\[ \t\]vnor "    } } */
 
5787
+/* { dg-final { scan-assembler     "\[ \t\]xxland "  } } */
 
5788
+/* { dg-final { scan-assembler     "\[ \t\]xxlor "   } } */
 
5789
+/* { dg-final { scan-assembler     "\[ \t\]xxlxor "  } } */
 
5790
+/* { dg-final { scan-assembler     "\[ \t\]xxlnor "  } } */
 
5791
+/* { dg-final { scan-assembler     "\[ \t\]xxlandc " } } */
 
5792
+/* { dg-final { scan-assembler-not "\[ \t\]xxleqv "  } } */
 
5793
+/* { dg-final { scan-assembler-not "\[ \t\]xxlorc "  } } */
 
5794
+/* { dg-final { scan-assembler-not "\[ \t\]xxlnand " } } */
 
5795
+
 
5796
+#ifndef TYPE
 
5797
+typedef int v4si __attribute__ ((vector_size (16)));
 
5798
+#define TYPE v4si
 
5799
+#endif
 
5800
+
 
5801
+#include "bool2.h"
 
5802
--- a/src/gcc/testsuite/ChangeLog.ibm
 
5803
+++ b/src/gcc/testsuite/ChangeLog.ibm
 
5804
@@ -0,0 +1,404 @@
 
5805
+2013-12-03  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
5806
+
 
5807
+       Backport from mainline r205638
 
5808
+       2013-12-03  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
5809
+
 
5810
+       * gcc.dg/vect/costmodel/ppc/costmodel-slp-34.c: Skip for little
 
5811
+       endian.
 
5812
+
 
5813
+2013-11-27  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
5814
+
 
5815
+       Backport from mainline r205464
 
5816
+       2013-11-27  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
5817
+
 
5818
+       * gfortran.dg/nan_7.f90: Disable for little endian PowerPC.
 
5819
+
 
5820
+2013-11-22  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
5821
+
 
5822
+       Backport from mainline
 
5823
+       2013-11-22  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
5824
+
 
5825
+       PR target/59054
 
5826
+       * gcc.target/powerpc/direct-move.h (VSX_REG_ATTR): Allow test to
 
5827
+       specify an appropriate register class for VSX operations.
 
5828
+       (load_vsx): Use it.
 
5829
+       (load_gpr_to_vsx): Likewise.
 
5830
+       (load_vsx_to_gpr): Likewise.
 
5831
+       * gcc.target/powerpc/direct-move-vint1.c: Use an appropriate
 
5832
+       register class for VSX registers that the type can handle.  Remove
 
5833
+       checks for explicit number of instructions generated, just check
 
5834
+       if the instruction is generated.
 
5835
+       * gcc.target/powerpc/direct-move-vint2.c: Likewise.
 
5836
+       * gcc.target/powerpc/direct-move-float1.c: Likewise.
 
5837
+       * gcc.target/powerpc/direct-move-float2.c: Likewise.
 
5838
+       * gcc.target/powerpc/direct-move-double1.c: Likewise.
 
5839
+       * gcc.target/powerpc/direct-move-double2.c: Likewise.
 
5840
+       * gcc.target/powerpc/direct-move-long1.c: Likewise.
 
5841
+       * gcc.target/powerpc/direct-move-long2.c: Likewise.
 
5842
+
 
5843
+       * gcc.target/powerpc/bool3-av.c: Limit to 64-bit mode for now.
 
5844
+       * gcc.target/powerpc/bool3-p7.c: Likewise.
 
5845
+       * gcc.target/powerpc/bool3-p8.c: Likewise.
 
5846
+
 
5847
+       * gcc.target/powerpc/p8vector-ldst.c: Just check that the
 
5848
+       appropriate instructions are generated, don't check the count.
 
5849
+
 
5850
+       2013-11-12  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
5851
+
 
5852
+       PR target/59054
 
5853
+       * gcc.target/powerpc/pr59054.c: New test.
 
5854
+
 
5855
+2013-11-20  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
5856
+
 
5857
+       Backport from mainline r205146
 
5858
+       2013-11-20  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
5859
+
 
5860
+       * gcc.target/powerpc/pr48258-1.c: Skip for little endian.
 
5861
+
 
5862
+2013-11-20  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
5863
+
 
5864
+       Backport from mainline r205106:
 
5865
+
 
5866
+       2013-11-20  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
5867
+
 
5868
+       * gcc.target/powerpc/darwin-longlong.c (msw): Make endian-safe.
 
5869
+
 
5870
+2013-11-19  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
5871
+
 
5872
+       Backport from mainline r205046:
 
5873
+
 
5874
+       2013-11-19  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
5875
+
 
5876
+       * gcc.target/powerpc/ppc64-abi-2.c (MAKE_SLOT): New macro to
 
5877
+       construct parameter slot value in endian-independent way.
 
5878
+       (fcevv, fciievv, fcvevv): Use it.
 
5879
+
 
5880
+2013-11-15  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
5881
+
 
5882
+       Backport from mainline r204862
 
5883
+       2013-11-15  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
5884
+
 
5885
+       * gcc.dg/vmx/3b-15.c: Revise for little endian.
 
5886
+
 
5887
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
5888
+
 
5889
+       Backport from mainline r204808:
 
5890
+
 
5891
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
5892
+
 
5893
+       * gcc.target/powerpc/ppc64-abi-1.c (stack_frame_t): Remove
 
5894
+       compiler and linker field if _CALL_ELF == 2.
 
5895
+       * gcc.target/powerpc/ppc64-abi-2.c (stack_frame_t): Likewise.
 
5896
+       * gcc.target/powerpc/ppc64-abi-dfp-1.c (stack_frame_t): Likewise.
 
5897
+       * gcc.dg/stack-usage-1.c (SIZE): Update value for _CALL_ELF == 2.
 
5898
+
 
5899
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
5900
+
 
5901
+       * gcc.target/powerpc/ppc64-abi-dfp-1.c (FUNC_START): New macro.
 
5902
+       (WRAPPER): Use it.
 
5903
+       * gcc.target/powerpc/no-r11-1.c: Skip on powerpc_elfv2.
 
5904
+       * gcc.target/powerpc/no-r11-2.c: Skip on powerpc_elfv2.
 
5905
+       * gcc.target/powerpc/no-r11-3.c: Skip on powerpc_elfv2.
 
5906
+
 
5907
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
5908
+
 
5909
+       * lib/target-supports.exp (check_effective_target_powerpc_elfv2):
 
5910
+       New function.
 
5911
+       * gcc.target/powerpc/pr57949-1.c: Disable for powerpc_elfv2.
 
5912
+       * gcc.target/powerpc/pr57949-2.c: Likewise.
 
5913
+
 
5914
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
5915
+
 
5916
+       Backport from mainline r204799:
 
5917
+
 
5918
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
5919
+
 
5920
+       * g++.dg/eh/ppc64-sighandle-cr.C: New test.
 
5921
+
 
5922
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
5923
+
 
5924
+       Backport from mainline r201750.
 
5925
+       Note: Default setting of -mcompat-align-parm inverted!
 
5926
+
 
5927
+       2013-08-14  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
5928
+
 
5929
+       PR target/57949
 
5930
+       * gcc.target/powerpc/pr57949-1.c: New.
 
5931
+       * gcc.target/powerpc/pr57949-2.c: New.
 
5932
+
 
5933
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
5934
+
 
5935
+       Backport from mainline r201040 and r201929:
 
5936
+
 
5937
+       2013-08-22  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
5938
+
 
5939
+       * gcc.target/powerpc/pr57744.c: Declare abort.
 
5940
+
 
5941
+       2013-07-18  Pat Haugen  <pthaugen@us.ibm.com>
 
5942
+
 
5943
+       * gcc.target/powerpc/pr57744.c: Fix typo.
 
5944
+
 
5945
+2013-11-10  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
5946
+
 
5947
+       Backport from mainline r204321
 
5948
+       2013-11-02  Bill Schmidt  <wschmidt@vnet.linux.ibm.com>
 
5949
+
 
5950
+       * gcc.dg/vmx/vec-set.c: New.
 
5951
+
 
5952
+2013-11-10  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
5953
+
 
5954
+       Backport from mainline r204138
 
5955
+       2013-10-28  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
5956
+
 
5957
+       * gcc.dg/vmx/gcc-bug-i.c: Add little endian variant.
 
5958
+       * gcc.dg/vmx/eg-5.c: Likewise.
 
5959
+
 
5960
+2013-11-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
5961
+
 
5962
+       Backport from mainline r203930
 
5963
+       2013-10-22  Bill Schmidt  <wschmidt@vnet.ibm.com>
 
5964
+
 
5965
+       * gcc.target/powerpc/altivec-perm-1.c: Move the two vector pack
 
5966
+       tests into...
 
5967
+       * gcc.target/powerpc/altivec-perm-3.c: ...this new test, which is
 
5968
+       restricted to big-endian targets.
 
5969
+
 
5970
+2013-11-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
5971
+
 
5972
+       Backport from mainline r203246
 
5973
+       2013-10-07  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
5974
+
 
5975
+       * gcc.target/powerpc/pr43154.c: Skip for ppc64 little endian.
 
5976
+       * gcc.target/powerpc/fusion.c: Likewise.
 
5977
+
 
5978
+2013-10-21  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
5979
+
 
5980
+       Backport from mainline
 
5981
+       2013-04-05  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
5982
+
 
5983
+       PR target/56843
 
5984
+       * gcc.target/powerpc/recip-1.c: Modify expected output.
 
5985
+       * gcc.target/powerpc/recip-3.c: Likewise.
 
5986
+       * gcc.target/powerpc/recip-4.c: Likewise.
 
5987
+       * gcc.target/powerpc/recip-5.c: Add expected output for iterations.
 
5988
+
 
5989
+2013-10-17  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
5990
+
 
5991
+       Back port from mainline
 
5992
+       2013-10-03  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
5993
+
 
5994
+       * gcc.target/powerpc/p8vector-fp.c: New test for floating point
 
5995
+       scalar operations when using -mupper-regs-sf and -mupper-regs-df.
 
5996
+       * gcc.target/powerpc/ppc-target-1.c: Update tests to allow either
 
5997
+       VSX scalar operations or the traditional floating point form of
 
5998
+       the instruction.
 
5999
+       * gcc.target/powerpc/ppc-target-2.c: Likewise.
 
6000
+       * gcc.target/powerpc/recip-3.c: Likewise.
 
6001
+       * gcc.target/powerpc/recip-5.c: Likewise.
 
6002
+       * gcc.target/powerpc/pr72747.c: Likewise.
 
6003
+       * gcc.target/powerpc/vsx-builtin-3.c: Likewise.
 
6004
+
 
6005
+       Back port from mainline
 
6006
+       2013-09-27  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6007
+
 
6008
+       * gcc.target/powerpc/p8vector-ldst.c: New test for -mupper-regs-sf
 
6009
+       and -mupper-regs-df.
 
6010
+
 
6011
+       Back port from mainline
 
6012
+       2013-10-17  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6013
+
 
6014
+       PR target/58673
 
6015
+       * gcc.target/powerpc/pr58673-1.c: New file to test whether
 
6016
+       -mquad-word + -mno-vsx-timode causes errors.
 
6017
+       * gcc.target/powerpc/pr58673-2.c: Likewise.
 
6018
+
 
6019
+2013-08-19  Peter Bergner  <bergner@vnet.ibm.com>
 
6020
+
 
6021
+       Back port from mainline
 
6022
+       2013-08-19  Peter Bergner  <bergner@vnet.ibm.com>
 
6023
+
 
6024
+       * gcc.target/powerpc/dfp-dd-2.c: New test.
 
6025
+       * gcc.target/powerpc/dfp-td-2.c: Likewise.
 
6026
+       * gcc.target/powerpc/dfp-td-3.c: Likewise.
 
6027
+
 
6028
+2013-08-16  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6029
+
 
6030
+       Backport from trunk.
 
6031
+       2013-07-23  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6032
+
 
6033
+       * gcc.target/powerpc/bool2.h: New file, test the code generation
 
6034
+       of logical operations for power5, altivec, power7, and power8 systems.
 
6035
+       * gcc.target/powerpc/bool2-p5.c: Likewise.
 
6036
+       * gcc.target/powerpc/bool2-av.c: Likewise.
 
6037
+       * gcc.target/powerpc/bool2-p7.c: Likewise.
 
6038
+       * gcc.target/powerpc/bool2-p8.c: Likewise.
 
6039
+       * gcc.target/powerpc/bool3.h: Likewise.
 
6040
+       * gcc.target/powerpc/bool3-av.c: Likewise.
 
6041
+       * gcc.target/powerpc/bool2-p7.c: Likewise.
 
6042
+       * gcc.target/powerpc/bool2-p8.c: Likewise.
 
6043
+
 
6044
+2013-08-16  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6045
+
 
6046
+       Backport from trunk.
 
6047
+       2013-07-31  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6048
+
 
6049
+       * gcc.target/powerpc/fusion.c: New file, test power8 fusion support.
 
6050
+
 
6051
+2013-08-05  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6052
+
 
6053
+       Back port from mainline:
 
6054
+       2013-06-06  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6055
+                   Pat Haugen <pthaugen@us.ibm.com>
 
6056
+                   Peter Bergner <bergner@vnet.ibm.com>
 
6057
+
 
6058
+       * lib/target-supports.exp (check_p8vector_hw_available) Add power8
 
6059
+       support.
 
6060
+       (check_effective_target_powerpc_p8vector_ok): Likewise.
 
6061
+       (is-effective-target): Likewise.
 
6062
+       (check_vect_support_and_set_flags): Likewise.
 
6063
+
 
6064
+2013-08-04  Peter Bergner  <bergner@vnet.ibm.com>
 
6065
+
 
6066
+       Back port from mainline
 
6067
+       2013-08-01  Fabien Chêne  <fabien@gcc.gnu.org>
 
6068
+                   Peter Bergner  <bergner@vnet.ibm.com>
 
6069
+
 
6070
+       PR c++/54537
 
6071
+       * g++.dg/overload/using3.C: New.
 
6072
+       * g++.dg/overload/using2.C: Adjust.
 
6073
+       * g++.dg/lookup/using9.C: Likewise.
 
6074
+
 
6075
+2013-07-31  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6076
+
 
6077
+       Back port from mainline
 
6078
+       2013-07-31  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6079
+
 
6080
+       * gcc.target/powerpc/fusion.c: New file, test power8 fusion
 
6081
+       support.
 
6082
+
 
6083
+2013-07-15  Peter Bergner  <bergner@vnet.ibm.com>
 
6084
+
 
6085
+       Back port from mainline
 
6086
+       2013-07-15  Peter Bergner  <bergner@vnet.ibm.com>
 
6087
+
 
6088
+        * lib/target-supports.exp (check_effective_target_powerpc_htm_ok): New
 
6089
+        function to test if HTM is available.
 
6090
+       * gcc.target/powerpc/htm-xl-intrin-1.c: New test.
 
6091
+       * gcc.target/powerpc/htm-builtin-1.c: New test.
 
6092
+
 
6093
+2013-06-28  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6094
+
 
6095
+       Back port from the trunk
 
6096
+       2013-06-28  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6097
+
 
6098
+       PR target/57744
 
6099
+       * gcc.target/powerpc/pr57744.c: New test to make sure lqarx and
 
6100
+       stqcx. get even registers.
 
6101
+
 
6102
+2013-06-12  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6103
+
 
6104
+       Back port from the trunk
 
6105
+
 
6106
+       2013-06-12  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6107
+                   Pat Haugen <pthaugen@us.ibm.com>
 
6108
+                   Peter Bergner <bergner@vnet.ibm.com>
 
6109
+
 
6110
+       * gcc.target/powerpc/atomic-p7.c: New file, add tests for atomic
 
6111
+       load/store instructions on power7, power8.
 
6112
+       * gcc.target/powerpc/atomic-p8.c: Likewise.
 
6113
+
 
6114
+2013-06-11  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6115
+
 
6116
+       Back port from the trunk
 
6117
+
 
6118
+       2013-06-11  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6119
+                   Pat Haugen <pthaugen@us.ibm.com>
 
6120
+                   Peter Bergner <bergner@vnet.ibm.com>
 
6121
+
 
6122
+       * gcc.target/powerpc/atomic-p7.c: New file, add tests for atomic
 
6123
+       load/store instructions on power7, power8.
 
6124
+       * gcc.target/powerpc/atomic-p8.c: Likewise.
 
6125
+
 
6126
+       Back port from the trunk
 
6127
+
 
6128
+       2013-06-10  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6129
+                   Pat Haugen <pthaugen@us.ibm.com>
 
6130
+                   Peter Bergner <bergner@vnet.ibm.com>
 
6131
+
 
6132
+       * gcc.target/powerpc/direct-move-vint1.c: New tests for power8
 
6133
+       direct move instructions.
 
6134
+       * gcc.target/powerpc/direct-move-vint2.c: Likewise.
 
6135
+       * gcc.target/powerpc/direct-move.h: Likewise.
 
6136
+       * gcc.target/powerpc/direct-move-float1.c: Likewise.
 
6137
+       * gcc.target/powerpc/direct-move-float2.c: Likewise.
 
6138
+       * gcc.target/powerpc/direct-move-double1.c: Likewise.
 
6139
+       * gcc.target/powerpc/direct-move-double2.c: Likewise.
 
6140
+       * gcc.target/powerpc/direct-move-long1.c: Likewise.
 
6141
+       * gcc.target/powerpc/direct-move-long2.c: Likewise.
 
6142
+
 
6143
+2013-06-06  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6144
+
 
6145
+       Backport from the trunk
 
6146
+
 
6147
+       2013-06-06  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6148
+                   Pat Haugen <pthaugen@us.ibm.com>
 
6149
+                   Peter Bergner <bergner@vnet.ibm.com>
 
6150
+
 
6151
+       * gcc.target/powerpc/p8vector-builtin-1.c: New test to test
 
6152
+       power8 builtin functions.
 
6153
+       * gcc/testsuite/gcc.target/powerpc/p8vector-builtin-2.c: Likewise.
 
6154
+       * gcc/testsuite/gcc.target/powerpc/p8vector-builtin-3.c: Likewise.
 
6155
+       * gcc/testsuite/gcc.target/powerpc/p8vector-builtin-4.c: Likewise.
 
6156
+       * gcc/testsuite/gcc.target/powerpc/p8vector-builtin-5.c: Likewise.
 
6157
+       * gcc/testsuite/gcc.target/powerpc/p8vector-builtin-6.c: Likewise.
 
6158
+       * gcc/testsuite/gcc.target/powerpc/p8vector-builtin-7.c: Likewise.
 
6159
+       * gcc/testsuite/gcc.target/powerpc/p8vector-vectorize-1.c: New
 
6160
+       tests to test power8 auto-vectorization.
 
6161
+       * gcc/testsuite/gcc.target/powerpc/p8vector-vectorize-2.c: Likewise.
 
6162
+       * gcc/testsuite/gcc.target/powerpc/p8vector-vectorize-3.c: Likewise.
 
6163
+       * gcc/testsuite/gcc.target/powerpc/p8vector-vectorize-4.c: Likewise.
 
6164
+       * gcc/testsuite/gcc.target/powerpc/p8vector-vectorize-5.c: Likewise.
 
6165
+
 
6166
+       * gcc.target/powerpc/crypto-builtin-1.c: Use effective target
 
6167
+       powerpc_p8vector_ok instead of powerpc_vsx_ok.
 
6168
+
 
6169
+       * gcc.target/powerpc/bool.c: New file, add eqv, nand, nor tests.
 
6170
+
 
6171
+       * lib/target-supports.exp (check_p8vector_hw_available) Add power8
 
6172
+       support.
 
6173
+       (check_effective_target_powerpc_p8vector_ok): Likewise.
 
6174
+       (is-effective-target): Likewise.
 
6175
+       (check_vect_support_and_set_flags): Likewise.
 
6176
+
 
6177
+2013-06-06  Peter Bergner  <bergner@vnet.ibm.com>
 
6178
+
 
6179
+       Backport from trunk
 
6180
+
 
6181
+       2013-05-22  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6182
+                   Pat Haugen <pthaugen@us.ibm.com>
 
6183
+                   Peter Bergner <bergner@vnet.ibm.com>
 
6184
+
 
6185
+       * gcc.target/powerpc/crypto-builtin-1.c: New file, test for power8
 
6186
+       crypto builtins.
 
6187
+
 
6188
+2013-05-06  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6189
+
 
6190
+       Backport from trunk
 
6191
+       2013-05-03  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6192
+
 
6193
+       PR target/57150
 
6194
+       * gcc.target/powerpc/pr57150.c: New file.
 
6195
+
 
6196
+2013-03-20  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6197
+
 
6198
+       Backport from mainline
 
6199
+       2013-03-20  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6200
+
 
6201
+       * gcc.target/powerpc/mmfpgpr.c: New test.
 
6202
+       * gcc.target/powerpc/sd-vsx.c: Likewise.
 
6203
+       * gcc.target/powerpc/sd-pwr6.c: Likewise.
 
6204
+       * gcc.target/powerpc/vsx-float0.c: Likewise.
 
6205
+
 
6206
+2013-03-20  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6207
+
 
6208
+       Clone branch from gcc-4_8-branch, subversion id 196835.
 
6209
--- a/src/gcc/testsuite/lib/target-supports.exp
 
6210
+++ b/src/gcc/testsuite/lib/target-supports.exp
 
6211
@@ -1311,6 +1311,32 @@
 
6212
     return 0
 
6213
 }
 
6214
 
 
6215
+# Return 1 if the target supports executing power8 vector instructions, 0
 
6216
+# otherwise.  Cache the result.
 
6217
+
 
6218
+proc check_p8vector_hw_available { } {
 
6219
+    return [check_cached_effective_target p8vector_hw_available {
 
6220
+       # Some simulators are known to not support VSX/power8 instructions.
 
6221
+       # For now, disable on Darwin
 
6222
+       if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
 
6223
+           expr 0
 
6224
+       } else {
 
6225
+           set options "-mpower8-vector"
 
6226
+           check_runtime_nocache p8vector_hw_available {
 
6227
+               int main()
 
6228
+               {
 
6229
+               #ifdef __MACH__
 
6230
+                 asm volatile ("xxlorc vs0,vs0,vs0");
 
6231
+               #else
 
6232
+                 asm volatile ("xxlorc 0,0,0");
 
6233
+               #endif
 
6234
+                 return 0;
 
6235
+               }
 
6236
+           } $options
 
6237
+       }
 
6238
+    }]
 
6239
+}
 
6240
+
 
6241
 # Return 1 if the target supports executing VSX instructions, 0
 
6242
 # otherwise.  Cache the result.
 
6243
 
 
6244
@@ -2672,6 +2698,33 @@
 
6245
     }
 
6246
 }
 
6247
 
 
6248
+# Return 1 if this is a PowerPC target supporting -mpower8-vector
 
6249
+
 
6250
+proc check_effective_target_powerpc_p8vector_ok { } {
 
6251
+    if { ([istarget powerpc*-*-*]
 
6252
+         && ![istarget powerpc-*-linux*paired*])
 
6253
+        || [istarget rs6000-*-*] } {
 
6254
+       # AltiVec is not supported on AIX before 5.3.
 
6255
+       if { [istarget powerpc*-*-aix4*]
 
6256
+            || [istarget powerpc*-*-aix5.1*] 
 
6257
+            || [istarget powerpc*-*-aix5.2*] } {
 
6258
+           return 0
 
6259
+       }
 
6260
+       return [check_no_compiler_messages powerpc_p8vector_ok object {
 
6261
+           int main (void) {
 
6262
+#ifdef __MACH__
 
6263
+               asm volatile ("xxlorc vs0,vs0,vs0");
 
6264
+#else
 
6265
+               asm volatile ("xxlorc 0,0,0");
 
6266
+#endif
 
6267
+               return 0;
 
6268
+           }
 
6269
+       } "-mpower8-vector"]
 
6270
+    } else {
 
6271
+       return 0
 
6272
+    }
 
6273
+}
 
6274
+
 
6275
 # Return 1 if this is a PowerPC target supporting -mvsx
 
6276
 
 
6277
 proc check_effective_target_powerpc_vsx_ok { } {
 
6278
@@ -2699,6 +2752,27 @@
 
6279
     }
 
6280
 }
 
6281
 
 
6282
+# Return 1 if this is a PowerPC target supporting -mhtm
 
6283
+
 
6284
+proc check_effective_target_powerpc_htm_ok { } {
 
6285
+    if { ([istarget powerpc*-*-*]
 
6286
+         && ![istarget powerpc-*-linux*paired*])
 
6287
+        || [istarget rs6000-*-*] } {
 
6288
+       # HTM is not supported on AIX yet.
 
6289
+       if { [istarget powerpc*-*-aix*] } {
 
6290
+           return 0
 
6291
+       }
 
6292
+       return [check_no_compiler_messages powerpc_htm_ok object {
 
6293
+           int main (void) {
 
6294
+               asm volatile ("tbegin. 0");
 
6295
+               return 0;
 
6296
+           }
 
6297
+       } "-mhtm"]
 
6298
+    } else {
 
6299
+       return 0
 
6300
+    }
 
6301
+}
 
6302
+
 
6303
 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
 
6304
 
 
6305
 proc check_effective_target_powerpc_ppu_ok { } {
 
6306
@@ -2794,6 +2868,22 @@
 
6307
     }
 
6308
 }
 
6309
 
 
6310
+# Return 1 if this is a PowerPC target using the ELFv2 ABI.
 
6311
+
 
6312
+proc check_effective_target_powerpc_elfv2 { } {
 
6313
+    if { [istarget powerpc*-*-*] } {
 
6314
+       return [check_no_compiler_messages powerpc_elfv2 object {
 
6315
+           #if _CALL_ELF != 2
 
6316
+           #error not ELF v2 ABI
 
6317
+           #else
 
6318
+           int dummy;
 
6319
+           #endif
 
6320
+       }]
 
6321
+    } else {
 
6322
+       return 0
 
6323
+    }
 
6324
+}
 
6325
+
 
6326
 # Return 1 if this is a SPU target with a toolchain that
 
6327
 # supports automatic overlay generation.
 
6328
 
 
6329
@@ -4499,6 +4589,7 @@
 
6330
        switch $arg {
 
6331
          "vmx_hw"         { set selected [check_vmx_hw_available] }
 
6332
          "vsx_hw"         { set selected [check_vsx_hw_available] }
 
6333
+         "p8vector_hw"    { set selected [check_p8vector_hw_available] }
 
6334
          "ppc_recip_hw"   { set selected [check_ppc_recip_hw_available] }
 
6335
          "named_sections" { set selected [check_named_sections_available] }
 
6336
          "gc_sections"    { set selected [check_gc_sections_available] }
 
6337
@@ -4520,6 +4611,7 @@
 
6338
        switch $arg {
 
6339
          "vmx_hw"         { return 1 }
 
6340
          "vsx_hw"         { return 1 }
 
6341
+         "p8vector_hw"    { return 1 }
 
6342
          "ppc_recip_hw"   { return 1 }
 
6343
          "named_sections" { return 1 }
 
6344
          "gc_sections"    { return 1 }
 
6345
@@ -5077,7 +5169,9 @@
 
6346
         }
 
6347
 
 
6348
         lappend DEFAULT_VECTCFLAGS "-maltivec"
 
6349
-        if [check_vsx_hw_available] {
 
6350
+        if [check_p8vector_hw_available] {
 
6351
+            lappend DEFAULT_VECTCFLAGS "-mpower8-vector" "-mno-allow-movmisalign"
 
6352
+        } elseif [check_vsx_hw_available] {
 
6353
             lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
 
6354
         }
 
6355
 
 
6356
--- a/src/gcc/testsuite/gfortran.dg/nan_7.f90
 
6357
+++ b/src/gcc/testsuite/gfortran.dg/nan_7.f90
 
6358
@@ -2,6 +2,7 @@
 
6359
 ! { dg-options "-fno-range-check" }
 
6360
 ! { dg-require-effective-target fortran_real_16 }
 
6361
 ! { dg-require-effective-target fortran_integer_16 }
 
6362
+! { dg-skip-if "" { "powerpc*le-*-*" } { "*" } { "" } }
 
6363
 ! PR47293 NAN not correctly read
 
6364
 character(len=200) :: str
 
6365
 real(16) :: r
 
6366
--- a/src/gcc/testsuite/gcc.dg/vmx/3b-15.c
 
6367
+++ b/src/gcc/testsuite/gcc.dg/vmx/3b-15.c
 
6368
@@ -3,7 +3,11 @@
 
6369
 vector unsigned char
 
6370
 f (vector unsigned char a, vector unsigned char b, vector unsigned char c)
 
6371
 {
 
6372
+#ifdef __BIG_ENDIAN__
 
6373
   return vec_perm(a,b,c); 
 
6374
+#else
 
6375
+  return vec_perm(b,a,c);
 
6376
+#endif
 
6377
 }
 
6378
 
 
6379
 static void test()
 
6380
@@ -12,8 +16,13 @@
 
6381
                                            8,9,10,11,12,13,14,15}),
 
6382
                     ((vector unsigned char){70,71,72,73,74,75,76,77,
 
6383
                                            78,79,80,81,82,83,84,85}),
 
6384
+#ifdef __BIG_ENDIAN__
 
6385
                     ((vector unsigned char){0x1,0x14,0x18,0x10,0x16,0x15,0x19,0x1a,
 
6386
                                            0x1c,0x1c,0x1c,0x12,0x8,0x1d,0x1b,0xe})),
 
6387
+#else
 
6388
+                     ((vector unsigned char){0x1e,0xb,0x7,0xf,0x9,0xa,0x6,0x5,
 
6389
+                                            0x3,0x3,0x3,0xd,0x17,0x2,0x4,0x11})),
 
6390
+#endif
 
6391
                   ((vector unsigned char){1,74,78,70,76,75,79,80,82,82,82,72,8,83,81,14})),
 
6392
        "f");
 
6393
 }
 
6394
--- a/src/gcc/testsuite/gcc.dg/vmx/vec-set.c
 
6395
+++ b/src/gcc/testsuite/gcc.dg/vmx/vec-set.c
 
6396
@@ -0,0 +1,14 @@
 
6397
+#include "harness.h"
 
6398
+
 
6399
+vector short
 
6400
+vec_set (short m)
 
6401
+{
 
6402
+  return (vector short){m, 0, 0, 0, 0, 0, 0, 0};
 
6403
+}
 
6404
+
 
6405
+static void test()
 
6406
+{
 
6407
+  check (vec_all_eq (vec_set (7),
 
6408
+                    ((vector short){7, 0, 0, 0, 0, 0, 0, 0})),
 
6409
+        "vec_set");
 
6410
+}
 
6411
--- a/src/gcc/testsuite/gcc.dg/vmx/gcc-bug-i.c
 
6412
+++ b/src/gcc/testsuite/gcc.dg/vmx/gcc-bug-i.c
 
6413
@@ -13,12 +13,27 @@
 
6414
 #define DO_INLINE __attribute__ ((always_inline))
 
6415
 #define DONT_INLINE __attribute__ ((noinline))
 
6416
 
 
6417
+#ifdef __LITTLE_ENDIAN__
 
6418
+static inline DO_INLINE int inline_me(vector signed short data)
 
6419
+{
 
6420
+  union {vector signed short v; signed short s[8];} u;
 
6421
+  signed short x;
 
6422
+  unsigned char x1, x2;
 
6423
+
 
6424
+  u.v = data;
 
6425
+  x = u.s[7];
 
6426
+  x1 = (x >> 8) & 0xff;
 
6427
+  x2 = x & 0xff;
 
6428
+  return ((x2 << 8) | x1);
 
6429
+}
 
6430
+#else
 
6431
 static inline DO_INLINE int inline_me(vector signed short data) 
 
6432
 {
 
6433
   union {vector signed short v; signed short s[8];} u;
 
6434
   u.v = data;
 
6435
   return u.s[7];
 
6436
 }
 
6437
+#endif
 
6438
 
 
6439
 static DONT_INLINE int foo(vector signed short data)
 
6440
 {
 
6441
--- a/src/gcc/testsuite/gcc.dg/vmx/eg-5.c
 
6442
+++ b/src/gcc/testsuite/gcc.dg/vmx/eg-5.c
 
6443
@@ -7,10 +7,17 @@
 
6444
   /* Set result to a vector of f32 0's */
 
6445
   vector float result = ((vector float){0.,0.,0.,0.});
 
6446
 
 
6447
+#ifdef __LITTLE_ENDIAN__
 
6448
+  result  = vec_madd (c0, vec_splat (v, 3), result);
 
6449
+  result  = vec_madd (c1, vec_splat (v, 2), result);
 
6450
+  result  = vec_madd (c2, vec_splat (v, 1), result);
 
6451
+  result  = vec_madd (c3, vec_splat (v, 0), result);
 
6452
+#else
 
6453
   result  = vec_madd (c0, vec_splat (v, 0), result);
 
6454
   result  = vec_madd (c1, vec_splat (v, 1), result);
 
6455
   result  = vec_madd (c2, vec_splat (v, 2), result);
 
6456
   result  = vec_madd (c3, vec_splat (v, 3), result);
 
6457
+#endif
 
6458
 
 
6459
   return result;
 
6460
 }
 
6461
--- a/src/gcc/testsuite/gcc.dg/stack-usage-1.c
 
6462
+++ b/src/gcc/testsuite/gcc.dg/stack-usage-1.c
 
6463
@@ -38,7 +38,11 @@
 
6464
 #  endif
 
6465
 #elif defined (__powerpc64__) || defined (__ppc64__) || defined (__POWERPC64__) \
 
6466
       || defined (__PPC64__)
 
6467
-#  define SIZE 180
 
6468
+#  if _CALL_ELF == 2
 
6469
+#     define SIZE 208
 
6470
+#  else
 
6471
+#     define SIZE 180
 
6472
+#  endif
 
6473
 #elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) \
 
6474
       || defined (__POWERPC__) || defined (PPC) || defined (_IBMR2)
 
6475
 #  if defined (__ALTIVEC__)
 
6476
--- a/src/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-slp-34.c
 
6477
+++ b/src/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-slp-34.c
 
6478
@@ -1,4 +1,5 @@
 
6479
 /* { dg-require-effective-target vect_int } */
 
6480
+/* { dg-skip-if "cost too high" { powerpc*le-*-* } { "*" } { "" } } */
 
6481
 
 
6482
 #include <stdarg.h>
 
6483
 #include "../../tree-vect.h"
 
6484
--- a/src/gcc/testsuite/g++.dg/lookup/using9.C
 
6485
+++ b/src/gcc/testsuite/g++.dg/lookup/using9.C
 
6486
@@ -21,11 +21,11 @@
 
6487
   f('h');
 
6488
   f(1);         // { dg-error "ambiguous" }
 
6489
   // { dg-message "candidate" "candidate note" { target *-*-* } 22 }
 
6490
-  void f(int);  // { dg-error "previous using declaration" }
 
6491
+  void f(int);  // { dg-error "previous declaration" }
 
6492
 }
 
6493
 
 
6494
 void m()
 
6495
 {
 
6496
   void f(int);
 
6497
-  using B::f;   // { dg-error "already declared" }
 
6498
+  using B::f;   // { dg-error "previous declaration" }
 
6499
 }
 
6500
--- a/src/gcc/testsuite/g++.dg/eh/ppc64-sighandle-cr.C
 
6501
+++ b/src/gcc/testsuite/g++.dg/eh/ppc64-sighandle-cr.C
 
6502
@@ -0,0 +1,54 @@
 
6503
+// { dg-do run { target { powerpc64*-*-linux* } } }
 
6504
+// { dg-options "-fexceptions -fnon-call-exceptions" }
 
6505
+
 
6506
+#include <signal.h>
 
6507
+#include <stdlib.h>
 
6508
+#include <fenv.h>
 
6509
+
 
6510
+#define SET_CR(R,V) __asm__ __volatile__ ("mtcrf %0,%1" : : "n" (1<<(7-R)), "r" (V<<(4*(7-R))) : "cr" #R)
 
6511
+#define GET_CR(R) ({ int tmp; __asm__ __volatile__ ("mfcr %0" : "=r" (tmp)); (tmp >> 4*(7-R)) & 15; })
 
6512
+
 
6513
+void sighandler (int signo, siginfo_t * si, void * uc)
 
6514
+{
 
6515
+  SET_CR(2, 3);
 
6516
+  SET_CR(3, 2);
 
6517
+  SET_CR(4, 1);
 
6518
+
 
6519
+  throw 0;
 
6520
+}
 
6521
+
 
6522
+float test (float a, float b) __attribute__ ((__noinline__));
 
6523
+float test (float a, float b)
 
6524
+{
 
6525
+  float x;
 
6526
+  asm ("mtcrf %1,%2" : "=f" (x) : "n" (1 << (7-3)), "r" (0), "0" (b) : "cr3");
 
6527
+  return a / x;
 
6528
+}
 
6529
+
 
6530
+int main ()
 
6531
+{
 
6532
+  struct sigaction sa;
 
6533
+  int status;
 
6534
+
 
6535
+  sa.sa_sigaction = sighandler;
 
6536
+  sa.sa_flags = SA_SIGINFO;
 
6537
+
 
6538
+  status = sigaction (SIGFPE, & sa, NULL);
 
6539
+
 
6540
+  feenableexcept (FE_DIVBYZERO);
 
6541
+
 
6542
+  SET_CR(2, 6);
 
6543
+  SET_CR(3, 9);
 
6544
+  SET_CR(4, 12);
 
6545
+
 
6546
+  try {
 
6547
+    test (1, 0);
 
6548
+  }
 
6549
+  catch (...) {
 
6550
+    return GET_CR(2) != 6 || GET_CR(3) != 9 || GET_CR(4) != 12;
 
6551
+  }
 
6552
+
 
6553
+  return 1;
 
6554
+}
 
6555
+
 
6556
+
 
6557
--- a/src/gcc/testsuite/g++.dg/overload/using3.C
 
6558
+++ b/src/gcc/testsuite/g++.dg/overload/using3.C
 
6559
@@ -0,0 +1,16 @@
 
6560
+// { dg-do compile }
 
6561
+
 
6562
+namespace a
 
6563
+{
 
6564
+  void f(int);
 
6565
+}
 
6566
+
 
6567
+namespace b
 
6568
+{
 
6569
+  void f(int); // { dg-message "previous" }
 
6570
+  void g()
 
6571
+  {
 
6572
+    f (3);
 
6573
+  }
 
6574
+  using a::f; // { dg-error "conflicts" }
 
6575
+}
 
6576
--- a/src/gcc/testsuite/g++.dg/overload/using2.C
 
6577
+++ b/src/gcc/testsuite/g++.dg/overload/using2.C
 
6578
@@ -45,7 +45,7 @@
 
6579
   extern "C" void exit (int) throw ();
 
6580
   extern "C" void *malloc (__SIZE_TYPE__) throw () __attribute__((malloc));
 
6581
 
 
6582
-  void abort (void) throw ();
 
6583
+  void abort (void) throw (); // { dg-message "previous" }
 
6584
   void _exit (int) throw (); // { dg-error "conflicts" "conflicts" }
 
6585
                              // { dg-message "void _exit" "_exit" { target *-*-* } 49 }
 
6586
 
 
6587
@@ -54,14 +54,14 @@
 
6588
                            // { dg-message "void C1" "C1" { target *-*-* } 53 }
 
6589
 
 
6590
   extern "C" void c2 (void) throw ();
 
6591
-  void C2 (void) throw ();
 
6592
+  void C2 (void) throw (); // { dg-message "previous" }
 
6593
 
 
6594
   int C3 (int) throw ();
 
6595
 
 
6596
 using std::malloc;
 
6597
-using std::abort; // { dg-error "already declared" }
 
6598
+using std::abort; // { dg-error "conflicts" }
 
6599
 using std::c2;
 
6600
-using std::C2; // { dg-error "already declared" }
 
6601
+using std::C2; // { dg-error "conflicts" }
 
6602
 
 
6603
 using std::c3; using other::c3;
 
6604
 using std::C3; using other::C3;
 
6605
--- a/src/gcc/cp/ChangeLog.ibm
 
6606
+++ b/src/gcc/cp/ChangeLog.ibm
 
6607
@@ -0,0 +1,11 @@
 
6608
+2013-08-04  Peter Bergner  <bergner@vnet.ibm.com>
 
6609
+
 
6610
+       Back port from mainline
 
6611
+       2013-08-01  Fabien Chêne  <fabien@gcc.gnu.org>
 
6612
+
 
6613
+       PR c++/54537
 
6614
+       * cp-tree.h: Check OVL_USED with OVERLOAD_CHECK.
 
6615
+       * name-lookup.c (do_nonmember_using_decl): Make sure we have an
 
6616
+       OVERLOAD before calling OVL_USED. Call diagnose_name_conflict
 
6617
+       instead of issuing an error without mentioning the conflicting
 
6618
+       declaration.
 
6619
--- a/src/gcc/cp/cp-tree.h
 
6620
+++ b/src/gcc/cp/cp-tree.h
 
6621
@@ -331,7 +331,7 @@
 
6622
 /* If set, this was imported in a using declaration.
 
6623
    This is not to confuse with being used somewhere, which
 
6624
    is not important for this node.  */
 
6625
-#define OVL_USED(NODE)         TREE_USED (NODE)
 
6626
+#define OVL_USED(NODE)         TREE_USED (OVERLOAD_CHECK (NODE))
 
6627
 /* If set, this OVERLOAD was created for argument-dependent lookup
 
6628
    and can be freed afterward.  */
 
6629
 #define OVL_ARG_DEPENDENT(NODE) TREE_LANG_FLAG_0 (OVERLOAD_CHECK (NODE))
 
6630
--- a/src/gcc/cp/name-lookup.c
 
6631
+++ b/src/gcc/cp/name-lookup.c
 
6632
@@ -2268,8 +2268,7 @@
 
6633
                  && compparms (TYPE_ARG_TYPES (TREE_TYPE (fn)),
 
6634
                                TYPE_ARG_TYPES (TREE_TYPE (decl)))
 
6635
                  && ! decls_match (fn, decl))
 
6636
-               error ("%q#D conflicts with previous using declaration %q#D",
 
6637
-                      decl, fn);
 
6638
+               diagnose_name_conflict (decl, fn);
 
6639
 
 
6640
              dup = duplicate_decls (decl, fn, is_friend);
 
6641
              /* If DECL was a redeclaration of FN -- even an invalid
 
6642
@@ -2501,7 +2500,7 @@
 
6643
                  if (new_fn == old_fn)
 
6644
                    /* The function already exists in the current namespace.  */
 
6645
                    break;
 
6646
-                 else if (OVL_USED (tmp1))
 
6647
+                 else if (TREE_CODE (tmp1) == OVERLOAD && OVL_USED (tmp1))
 
6648
                    continue; /* this is a using decl */
 
6649
                  else if (compparms (TYPE_ARG_TYPES (TREE_TYPE (new_fn)),
 
6650
                                      TYPE_ARG_TYPES (TREE_TYPE (old_fn))))
 
6651
@@ -2516,7 +2515,7 @@
 
6652
                        break;
 
6653
                      else
 
6654
                        {
 
6655
-                         error ("%qD is already declared in this scope", name);
 
6656
+                         diagnose_name_conflict (new_fn, old_fn);
 
6657
                          break;
 
6658
                        }
 
6659
                    }
 
6660
--- a/src/gcc/builtins.def
 
6661
+++ b/src/gcc/builtins.def
 
6662
@@ -252,6 +252,9 @@
 
6663
 DEF_LIB_BUILTIN        (BUILT_IN_FABS, "fabs", BT_FN_DOUBLE_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
 
6664
 DEF_C99_C90RES_BUILTIN (BUILT_IN_FABSF, "fabsf", BT_FN_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST)
 
6665
 DEF_C99_C90RES_BUILTIN (BUILT_IN_FABSL, "fabsl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
 
6666
+DEF_GCC_BUILTIN        (BUILT_IN_FABSD32, "fabsd32", BT_FN_DFLOAT32_DFLOAT32, ATTR_CONST_NOTHROW_LEAF_LIST)
 
6667
+DEF_GCC_BUILTIN        (BUILT_IN_FABSD64, "fabsd64", BT_FN_DFLOAT64_DFLOAT64, ATTR_CONST_NOTHROW_LEAF_LIST)
 
6668
+DEF_GCC_BUILTIN        (BUILT_IN_FABSD128, "fabsd128", BT_FN_DFLOAT128_DFLOAT128, ATTR_CONST_NOTHROW_LEAF_LIST)
 
6669
 DEF_C99_BUILTIN        (BUILT_IN_FDIM, "fdim", BT_FN_DOUBLE_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
 
6670
 DEF_C99_BUILTIN        (BUILT_IN_FDIMF, "fdimf", BT_FN_FLOAT_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO)
 
6671
 DEF_C99_BUILTIN        (BUILT_IN_FDIML, "fdiml", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
 
6672
--- a/src/gcc/expr.h
 
6673
+++ b/src/gcc/expr.h
 
6674
@@ -521,8 +521,8 @@
 
6675
                          rtx, int);
 
6676
 #endif
 
6677
 
 
6678
-extern void locate_and_pad_parm (enum machine_mode, tree, int, int, tree,
 
6679
-                                struct args_size *,
 
6680
+extern void locate_and_pad_parm (enum machine_mode, tree, int, int, int,
 
6681
+                                tree, struct args_size *,
 
6682
                                 struct locate_and_pad_arg_data *);
 
6683
 
 
6684
 /* Return the CODE_LABEL rtx for a LABEL_DECL, creating it if necessary.  */
 
6685
--- a/src/gcc/function.c
 
6686
+++ b/src/gcc/function.c
 
6687
@@ -2507,6 +2507,7 @@
 
6688
     }
 
6689
 
 
6690
   locate_and_pad_parm (data->promoted_mode, data->passed_type, in_regs,
 
6691
+                      all->reg_parm_stack_space,
 
6692
                       entry_parm ? data->partial : 0, current_function_decl,
 
6693
                       &all->stack_args_size, &data->locate);
 
6694
 
 
6695
@@ -3485,11 +3486,7 @@
 
6696
   /* Adjust function incoming argument size for alignment and
 
6697
      minimum length.  */
 
6698
 
 
6699
-#ifdef REG_PARM_STACK_SPACE
 
6700
-  crtl->args.size = MAX (crtl->args.size,
 
6701
-                                   REG_PARM_STACK_SPACE (fndecl));
 
6702
-#endif
 
6703
-
 
6704
+  crtl->args.size = MAX (crtl->args.size, all.reg_parm_stack_space);
 
6705
   crtl->args.size = CEIL_ROUND (crtl->args.size,
 
6706
                                           PARM_BOUNDARY / BITS_PER_UNIT);
 
6707
 
 
6708
@@ -3693,6 +3690,9 @@
 
6709
    IN_REGS is nonzero if the argument will be passed in registers.  It will
 
6710
    never be set if REG_PARM_STACK_SPACE is not defined.
 
6711
 
 
6712
+   REG_PARM_STACK_SPACE is the number of bytes of stack space reserved
 
6713
+   for arguments which are passed in registers.
 
6714
+
 
6715
    FNDECL is the function in which the argument was defined.
 
6716
 
 
6717
    There are two types of rounding that are done.  The first, controlled by
 
6718
@@ -3713,19 +3713,16 @@
 
6719
 
 
6720
 void
 
6721
 locate_and_pad_parm (enum machine_mode passed_mode, tree type, int in_regs,
 
6722
-                    int partial, tree fndecl ATTRIBUTE_UNUSED,
 
6723
+                    int reg_parm_stack_space, int partial,
 
6724
+                    tree fndecl ATTRIBUTE_UNUSED,
 
6725
                     struct args_size *initial_offset_ptr,
 
6726
                     struct locate_and_pad_arg_data *locate)
 
6727
 {
 
6728
   tree sizetree;
 
6729
   enum direction where_pad;
 
6730
   unsigned int boundary, round_boundary;
 
6731
-  int reg_parm_stack_space = 0;
 
6732
   int part_size_in_regs;
 
6733
 
 
6734
-#ifdef REG_PARM_STACK_SPACE
 
6735
-  reg_parm_stack_space = REG_PARM_STACK_SPACE (fndecl);
 
6736
-
 
6737
   /* If we have found a stack parm before we reach the end of the
 
6738
      area reserved for registers, skip that area.  */
 
6739
   if (! in_regs)
 
6740
@@ -3743,7 +3740,6 @@
 
6741
            initial_offset_ptr->constant = reg_parm_stack_space;
 
6742
        }
 
6743
     }
 
6744
-#endif /* REG_PARM_STACK_SPACE */
 
6745
 
 
6746
   part_size_in_regs = (reg_parm_stack_space == 0 ? partial : 0);
 
6747
 
 
6748
@@ -3806,11 +3802,7 @@
 
6749
 
 
6750
   locate->slot_offset.constant += part_size_in_regs;
 
6751
 
 
6752
-  if (!in_regs
 
6753
-#ifdef REG_PARM_STACK_SPACE
 
6754
-      || REG_PARM_STACK_SPACE (fndecl) > 0
 
6755
-#endif
 
6756
-     )
 
6757
+  if (!in_regs || reg_parm_stack_space > 0)
 
6758
     pad_to_arg_alignment (&locate->slot_offset, boundary,
 
6759
                          &locate->alignment_pad);
 
6760
 
 
6761
@@ -3830,11 +3822,7 @@
 
6762
     pad_below (&locate->offset, passed_mode, sizetree);
 
6763
 
 
6764
 #else /* !ARGS_GROW_DOWNWARD */
 
6765
-  if (!in_regs
 
6766
-#ifdef REG_PARM_STACK_SPACE
 
6767
-      || REG_PARM_STACK_SPACE (fndecl) > 0
 
6768
-#endif
 
6769
-      )
 
6770
+  if (!in_regs || reg_parm_stack_space > 0)
 
6771
     pad_to_arg_alignment (initial_offset_ptr, boundary,
 
6772
                          &locate->alignment_pad);
 
6773
   locate->slot_offset = *initial_offset_ptr;
 
6774
@@ -5093,6 +5081,7 @@
 
6775
             amount.  BLKmode results are handled using the group load/store
 
6776
             machinery.  */
 
6777
          if (TYPE_MODE (TREE_TYPE (decl_result)) != BLKmode
 
6778
+             && REG_P (real_decl_rtl)
 
6779
              && targetm.calls.return_in_msb (TREE_TYPE (decl_result)))
 
6780
            {
 
6781
              emit_move_insn (gen_rtx_REG (GET_MODE (decl_rtl),
 
6782
--- a/src/gcc/ChangeLog.ibm
 
6783
+++ b/src/gcc/ChangeLog.ibm
 
6784
@@ -0,0 +1,2453 @@
 
6785
+2014-01-13  Peter Bergner  <bergner@vnet.ibm.com>
 
6786
+
 
6787
+       Merge up to 206579.
 
6788
+       * REVISION: Update subversion id.
 
6789
+
 
6790
+2014-01-08  Peter Bergner  <bergner@vnet.ibm.com>
 
6791
+
 
6792
+       Merge up to 206404.
 
6793
+       * REVISION: Update subversion id.
 
6794
+
 
6795
+2013-12-10  Peter Bergner  <bergner@vnet.ibm.com>
 
6796
+
 
6797
+       Merge up to 205847.
 
6798
+       * REVISION: Update subversion id.
 
6799
+
 
6800
+2013-12-03  Peter Bergner  <bergner@vnet.ibm.com>
 
6801
+
 
6802
+       Backport from mainline
 
6803
+       2013-12-03  Peter Bergner  <bergner@vnet.ibm.com>
 
6804
+
 
6805
+       * config/rs6000/htmintrin.h (_TEXASR_INSTRUCTION_FETCH_CONFLICT): Fix
 
6806
+       typo in macro name.
 
6807
+       (_TEXASRU_INSTRUCTION_FETCH_CONFLICT): Likewise.
 
6808
+
 
6809
+2013-11-24  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
6810
+
 
6811
+       Backport from mainline r205333
 
6812
+       2013-11-24  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
6813
+
 
6814
+       * config/rs6000/rs6000.c (rs6000_expand_vec_perm_const_1): Correct
 
6815
+       for little endian.
 
6816
+
 
6817
+2013-11-23  Alan Modra  <amodra@gmail.com>
 
6818
+
 
6819
+       Apply mainline r205299.
 
6820
+       * config/rs6000/vsx.md (fusion peepholes): Disable when !TARGET_VSX.
 
6821
+
 
6822
+2013-11-22  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6823
+
 
6824
+       Backport from mainline
 
6825
+       2013-11-12  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
6826
+
 
6827
+       PR target/59054
 
6828
+       * config/rs6000/rs6000.md (movdi_internal32): Eliminate
 
6829
+       constraints that would allow DImode into the traditional Altivec
 
6830
+       registers, but cause undesirable code generation when loading 0 as
 
6831
+       a constant.
 
6832
+       (movdi_internal64): Likewise.
 
6833
+       (cmp<mode>_fpr): Do not use %x for CR register output.
 
6834
+       (extendsfdf2_fpr): Fix constraints when -mallow-upper-df and
 
6835
+       -mallow-upper-sf debug switches are used.
 
6836
+
 
6837
+2013-11-21  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
6838
+
 
6839
+       Backport from mainline r205241
 
6840
+       2013-11-21  Bill Schmidt  <wschmidt@vnet.ibm.com>
 
6841
+
 
6842
+       * config/rs6000/vector.md (vec_pack_trunc_v2df): Revert previous
 
6843
+       little endian change.
 
6844
+       (vec_pack_sfix_trunc_v2df): Likewise.
 
6845
+       (vec_pack_ufix_trunc_v2df): Likewise.
 
6846
+       * config/rs6000/rs6000.c (rs6000_expand_interleave): Correct
 
6847
+       double checking of endianness.
 
6848
+
 
6849
+2013-11-21  Peter Bergner  <bergner@vnet.ibm.com>
 
6850
+
 
6851
+       Backport from mainline r205233.
 
6852
+       2013-11-21  Peter Bergner  <bergner@vnet.ibm.com>
 
6853
+
 
6854
+       * doc/extend.texi: Document htm builtins.
 
6855
+
 
6856
+2013-11-20  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
6857
+
 
6858
+       Backport from mainline r205146
 
6859
+       2013-11-20  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
6860
+
 
6861
+       * config/rs6000/vsx.md (vsx_set_<mode>): Adjust for little endian.
 
6862
+       (vsx_extract_<mode>): Likewise.
 
6863
+       (*vsx_extract_<mode>_one_le): New LE variant on
 
6864
+       *vsx_extract_<mode>_zero.
 
6865
+       (vsx_extract_v4sf): Adjust for little endian.
 
6866
+
 
6867
+2013-11-20  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
6868
+
 
6869
+       Backport from mainline r205123:
 
6870
+
 
6871
+       2013-11-20  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
6872
+
 
6873
+       * config/rs6000/rs6000.c (rs6000_cannot_change_mode_class): Do not
 
6874
+       allow subregs of TDmode in FPRs of smaller size in little-endian.
 
6875
+       (rs6000_split_multireg_move): When splitting an access to TDmode
 
6876
+       in FPRs, do not use simplify_gen_subreg.
 
6877
+
 
6878
+2013-11-19  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
6879
+
 
6880
+       Backport from mainline r205080
 
6881
+       2013-11-19  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
6882
+
 
6883
+       * config/rs6000/rs6000.c (altivec_expand_vec_perm_const): Adjust
 
6884
+       V16QI vector splat case for little endian.
 
6885
+
 
6886
+2013-11-20  Alan Modra  <amodra@gmail.com>
 
6887
+
 
6888
+       Apply mainline r205060.
 
6889
+       * config/rs6000/sysv4.h (CC1_ENDIAN_LITTLE_SPEC): Define as empty.
 
6890
+       * config/rs6000/rs6000.c (rs6000_option_override_internal): Default
 
6891
+       to strict alignment on older processors when little-endian.
 
6892
+       * config/rs6000/linux64.h (PROCESSOR_DEFAULT64): Default to power8
 
6893
+       for ELFv2.
 
6894
+
 
6895
+2013-11-19  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
6896
+
 
6897
+       Backport from mainline r205045:
 
6898
+
 
6899
+       2013-11-19  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
6900
+
 
6901
+       * config/rs6000/vector.md ("mov<mode>"): Do not call
 
6902
+       rs6000_emit_le_vsx_move to move into or out of GPRs.
 
6903
+       * config/rs6000/rs6000.c (rs6000_emit_le_vsx_move): Assert
 
6904
+       source and destination are not GPR hard regs.
 
6905
+
 
6906
+2013-11-18  Peter Bergner  <bergner@vnet.ibm.com>
 
6907
+
 
6908
+       Merge up to 204974.
 
6909
+       * REVISION: Update subversion id.
 
6910
+
 
6911
+2013-11-17  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
6912
+
 
6913
+       Backport from mainline r204927:
 
6914
+
 
6915
+       2013-11-17  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
6916
+
 
6917
+       * config/rs6000/rs6000.c (rs6000_emit_move): Use low word of
 
6918
+       sdmode_stack_slot also in little-endian mode.
 
6919
+
 
6920
+2013-11-17  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
6921
+
 
6922
+       Backport from mainline r204920
 
6923
+       2011-11-17  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
6924
+
 
6925
+       * config/rs6000/rs6000.c (rs6000_frame_related): Add split_reg
 
6926
+       parameter and use it in REG_FRAME_RELATED_EXPR note.
 
6927
+       (emit_frame_save): Call rs6000_frame_related with extra NULL_RTX
 
6928
+       parameter.
 
6929
+       (rs6000_emit_prologue): Likewise, but for little endian VSX
 
6930
+       stores, pass the source register of the store instead.
 
6931
+
 
6932
+2013-11-15  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
6933
+
 
6934
+       Backport from mainline r204862
 
6935
+       2013-11-15  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
6936
+
 
6937
+       * config/rs6000/altivec.md (UNSPEC_VPERM_X, UNSPEC_VPERM_UNS_X):
 
6938
+       Remove.
 
6939
+       (altivec_vperm_<mode>): Revert earlier little endian change.
 
6940
+       (*altivec_vperm_<mode>_internal): Remove.
 
6941
+       (altivec_vperm_<mode>_uns): Revert earlier little endian change.
 
6942
+       (*altivec_vperm_<mode>_uns_internal): Remove.
 
6943
+       * config/rs6000/vector.md (vec_realign_load_<mode>): Revise
 
6944
+       commentary.
 
6945
+
 
6946
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
6947
+
 
6948
+       Backport from mainline r204842:
 
6949
+
 
6950
+       2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
6951
+
 
6952
+       * doc/invoke.texi (-mabi=elfv1, -mabi=elfv2): Document.
 
6953
+
 
6954
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
6955
+
 
6956
+       Backport from mainline r204809:
 
6957
+
 
6958
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
6959
+
 
6960
+       * config/rs6000/sysv4le.h (LINUX64_DEFAULT_ABI_ELFv2): Define.
 
6961
+
 
6962
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
6963
+
 
6964
+       Backport from mainline r204808:
 
6965
+
 
6966
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
6967
+                   Alan Modra  <amodra@gmail.com>
 
6968
+
 
6969
+       * config/rs6000/rs6000.h (RS6000_SAVE_AREA): Handle ABI_ELFv2.
 
6970
+       (RS6000_SAVE_TOC): Remove.
 
6971
+       (RS6000_TOC_SAVE_SLOT): New macro.
 
6972
+       * config/rs6000/rs6000.c (rs6000_parm_offset): New function.
 
6973
+       (rs6000_parm_start): Use it.
 
6974
+       (rs6000_function_arg_advance_1): Likewise.
 
6975
+       (rs6000_emit_prologue): Use RS6000_TOC_SAVE_SLOT.
 
6976
+       (rs6000_emit_epilogue): Likewise.
 
6977
+       (rs6000_call_aix): Likewise.
 
6978
+       (rs6000_output_function_prologue): Do not save/restore r11
 
6979
+       around calling _mcount for ABI_ELFv2.
 
6980
+
 
6981
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
6982
+                   Alan Modra  <amodra@gmail.com>
 
6983
+
 
6984
+       * config/rs6000/rs6000-protos.h (rs6000_reg_parm_stack_space):
 
6985
+       Add prototype.
 
6986
+       * config/rs6000/rs6000.h (RS6000_REG_SAVE): Remove.
 
6987
+       (REG_PARM_STACK_SPACE): Call rs6000_reg_parm_stack_space.
 
6988
+       * config/rs6000/rs6000.c (rs6000_parm_needs_stack): New function.
 
6989
+       (rs6000_function_parms_need_stack): Likewise.
 
6990
+       (rs6000_reg_parm_stack_space): Likewise.
 
6991
+       (rs6000_function_arg): Do not replace BLKmode by Pmode when
 
6992
+       returning a register argument.
 
6993
+
 
6994
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
6995
+                   Michael Gschwind  <mkg@us.ibm.com>
 
6996
+
 
6997
+       * config/rs6000/rs6000.h (FP_ARG_MAX_RETURN): New macro.
 
6998
+       (ALTIVEC_ARG_MAX_RETURN): Likewise.
 
6999
+       (FUNCTION_VALUE_REGNO_P): Use them.
 
7000
+       * config/rs6000/rs6000.c (TARGET_RETURN_IN_MSB): Define.
 
7001
+       (rs6000_return_in_msb): New function.
 
7002
+       (rs6000_return_in_memory): Handle ELFv2 homogeneous aggregates.
 
7003
+       Handle aggregates of up to 16 bytes for ELFv2.
 
7004
+       (rs6000_function_value): Handle ELFv2 homogeneous aggregates.
 
7005
+
 
7006
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7007
+                   Michael Gschwind  <mkg@us.ibm.com>
 
7008
+
 
7009
+       * config/rs6000/rs6000.h (AGGR_ARG_NUM_REG): Define.
 
7010
+       * config/rs6000/rs6000.c (rs6000_aggregate_candidate): New function.
 
7011
+       (rs6000_discover_homogeneous_aggregate): Likewise.
 
7012
+       (rs6000_function_arg_boundary): Handle homogeneous aggregates.
 
7013
+       (rs6000_function_arg_advance_1): Likewise.
 
7014
+       (rs6000_function_arg): Likewise.
 
7015
+       (rs6000_arg_partial_bytes): Likewise.
 
7016
+       (rs6000_psave_function_arg): Handle BLKmode arguments.
 
7017
+
 
7018
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7019
+                   Michael Gschwind  <mkg@us.ibm.com>
 
7020
+
 
7021
+       * config/rs6000/rs6000.h (AGGR_ARG_NUM_REG): Define.
 
7022
+       * config/rs6000/rs6000.c (rs6000_aggregate_candidate): New function.
 
7023
+       (rs6000_discover_homogeneous_aggregate): Likewise.
 
7024
+       (rs6000_function_arg_boundary): Handle homogeneous aggregates.
 
7025
+       (rs6000_function_arg_advance_1): Likewise.
 
7026
+       (rs6000_function_arg): Likewise.
 
7027
+       (rs6000_arg_partial_bytes): Likewise.
 
7028
+       (rs6000_psave_function_arg): Handle BLKmode arguments.
 
7029
+
 
7030
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7031
+
 
7032
+       * config/rs6000/rs6000.c (machine_function): New member
 
7033
+       r2_setup_needed.
 
7034
+       (rs6000_emit_prologue): Set r2_setup_needed if necessary.
 
7035
+       (rs6000_output_mi_thunk): Set r2_setup_needed.
 
7036
+       (rs6000_output_function_prologue): Output global entry point
 
7037
+       prologue and local entry point marker if needed for ABI_ELFv2.
 
7038
+       Output -mprofile-kernel code here.
 
7039
+       (output_function_profiler): Do not output -mprofile-kernel
 
7040
+       code here; moved to rs6000_output_function_prologue.
 
7041
+       (rs6000_file_start): Output ".abiversion 2" for ABI_ELFv2.
 
7042
+
 
7043
+       (rs6000_emit_move): Do not handle dot symbols for ABI_ELFv2.
 
7044
+       (rs6000_output_function_entry): Likewise.
 
7045
+       (rs6000_assemble_integer): Likewise.
 
7046
+       (rs6000_elf_encode_section_info): Likewise.
 
7047
+       (rs6000_elf_declare_function_name): Do not create dot symbols
 
7048
+       or .opd section for ABI_ELFv2.
 
7049
+
 
7050
+       (rs6000_trampoline_size): Update for ABI_ELFv2 trampolines.
 
7051
+       (rs6000_trampoline_init): Likewise.
 
7052
+       (rs6000_elf_file_end): Call file_end_indicate_exec_stack
 
7053
+       for ABI_ELFv2.
 
7054
+
 
7055
+       (rs6000_call_aix): Handle ELFv2 indirect calls.  Do not check
 
7056
+       for function descriptors in ABI_ELFv2.
 
7057
+
 
7058
+       * config/rs6000/rs6000.md ("*call_indirect_aix<mode>"): Support
 
7059
+       on ABI_AIX only, not ABI_ELFv2.
 
7060
+       ("*call_value_indirect_aix<mode>"): Likewise.
 
7061
+       ("*call_indirect_elfv2<mode>"): New pattern.
 
7062
+       ("*call_value_indirect_elfv2<mode>"): Likewise.
 
7063
+
 
7064
+       * config/rs6000/predicates.md ("symbol_ref_operand"): Do not
 
7065
+       check for function descriptors in ABI_ELFv2.
 
7066
+       ("current_file_function_operand"): Likewise.
 
7067
+
 
7068
+       * config/rs6000/ppc-asm.h [__powerpc64__ && _CALL_ELF == 2]:
 
7069
+       (toc): Undefine.
 
7070
+       (FUNC_NAME): Define ELFv2 variant.
 
7071
+       (JUMP_TARGET): Likewise.
 
7072
+       (FUNC_START): Likewise.
 
7073
+       (HIDDEN_FUNC): Likewise.
 
7074
+       (FUNC_END): Likeiwse.
 
7075
+
 
7076
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7077
+
 
7078
+       * config.gcc [powerpc*-*-* | rs6000-*-*]: Support --with-abi=elfv1
 
7079
+       and --with-abi=elfv2.
 
7080
+       * config/rs6000/option-defaults.h (OPTION_DEFAULT_SPECS): Add "abi".
 
7081
+       * config/rs6000/rs6000.opt (mabi=elfv1): New option.
 
7082
+       (mabi=elfv2): Likewise.
 
7083
+       * config/rs6000/rs6000-opts.h (enum rs6000_abi): Add ABI_ELFv2.
 
7084
+       * config/rs6000/linux64.h (DEFAULT_ABI): Do not hard-code to AIX_ABI
 
7085
+       if !RS6000_BI_ARCH.
 
7086
+       (ELFv2_ABI_CHECK): New macro.
 
7087
+       (SUBSUBTARGET_OVERRIDE_OPTIONS): Use it to decide whether to set
 
7088
+       rs6000_current_abi to ABI_AIX or ABI_ELFv2.
 
7089
+       (GLIBC_DYNAMIC_LINKER64): Support ELFv2 ld.so version.
 
7090
+       * config/rs6000/rs6000-c.c (rs6000_cpu_cpp_builtins): Predefine
 
7091
+       _CALL_ELF and __STRUCT_PARM_ALIGN__ if appropriate.
 
7092
+
 
7093
+       * config/rs6000/rs6000.c (rs6000_debug_reg_global): Handle ABI_ELFv2.
 
7094
+       (debug_stack_info): Likewise.
 
7095
+       (rs6000_file_start): Treat ABI_ELFv2 the same as ABI_AIX.
 
7096
+       (rs6000_legitimize_tls_address): Likewise.
 
7097
+       (rs6000_conditional_register_usage): Likewise.
 
7098
+       (rs6000_emit_move): Likewise.
 
7099
+       (init_cumulative_args): Likewise.
 
7100
+       (rs6000_function_arg_advance_1): Likewise.
 
7101
+       (rs6000_function_arg): Likewise.
 
7102
+       (rs6000_arg_partial_bytes): Likewise.
 
7103
+       (rs6000_output_function_entry): Likewise.
 
7104
+       (rs6000_assemble_integer): Likewise.
 
7105
+       (rs6000_savres_strategy): Likewise.
 
7106
+       (rs6000_stack_info): Likewise.
 
7107
+       (rs6000_function_ok_for_sibcall): Likewise.
 
7108
+       (rs6000_emit_load_toc_table): Likewise.
 
7109
+       (rs6000_savres_routine_name): Likewise.
 
7110
+       (ptr_regno_for_savres): Likewise.
 
7111
+       (rs6000_emit_prologue): Likewise.
 
7112
+       (rs6000_emit_epilogue): Likewise.
 
7113
+       (rs6000_output_function_epilogue): Likewise.
 
7114
+       (output_profile_hook): Likewise.
 
7115
+       (output_function_profiler): Likewise.
 
7116
+       (rs6000_trampoline_size): Likewise.
 
7117
+       (rs6000_trampoline_init): Likewise.
 
7118
+       (rs6000_elf_output_toc_section_asm_op): Likewise.
 
7119
+       (rs6000_elf_encode_section_info): Likewise.
 
7120
+       (rs6000_elf_reloc_rw_mask): Likewise.
 
7121
+       (rs6000_elf_declare_function_name): Likewise.
 
7122
+       (rs6000_function_arg_boundary): Treat ABI_ELFv2 the same as ABI_AIX,
 
7123
+       except that rs6000_compat_align_parm is always assumed false.
 
7124
+       (rs6000_gimplify_va_arg): Likewise.
 
7125
+       (rs6000_call_aix): Update comment.
 
7126
+       (rs6000_sibcall_aix): Likewise.
 
7127
+       * config/rs6000/rs6000.md ("tls_gd_aix<TLSmode:tls_abi_suffix>"):
 
7128
+       Treat ABI_ELFv2 the same as ABI_AIX.
 
7129
+       ("*tls_gd_call_aix<TLSmode:tls_abi_suffix>"): Likewise.
 
7130
+       ("tls_ld_aix<TLSmode:tls_abi_suffix>"): Likewise.
 
7131
+       ("*tls_ld_call_aix<TLSmode:tls_abi_suffix>"): Likewise.
 
7132
+       ("load_toc_aix_si"): Likewise.
 
7133
+       ("load_toc_aix_di"): Likewise.
 
7134
+       ("call"): Likewise.
 
7135
+       ("call_value"): Likewise.
 
7136
+       ("*call_local_aix<mode>"): Likewise.
 
7137
+       ("*call_value_local_aix<mode>"): Likewise.
 
7138
+       ("*call_nonlocal_aix<mode>"): Likewise.
 
7139
+       ("*call_value_nonlocal_aix<mode>"): Likewise.
 
7140
+       ("*call_indirect_aix<mode>"): Likewise.
 
7141
+       ("*call_value_indirect_aix<mode>"): Likewise.
 
7142
+       ("sibcall"): Likewise.
 
7143
+       ("sibcall_value"): Likewise.
 
7144
+       ("*sibcall_aix<mode>"): Likewise.
 
7145
+       ("*sibcall_value_aix<mode>"): Likewise.
 
7146
+       * config/rs6000/predicates.md ("symbol_ref_operand"): Likewise.
 
7147
+       ("current_file_function_operand"): Likewise.
 
7148
+
 
7149
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7150
+
 
7151
+       Backport from mainline r204807:
 
7152
+
 
7153
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7154
+
 
7155
+       * config/rs6000/rs6000.c (rs6000_arg_partial_bytes): Simplify logic
 
7156
+       by making use of the fact that for vector / floating point arguments
 
7157
+       passed both in VRs/FPRs and in the fixed parameter area, the partial
 
7158
+       bytes mechanism is in fact not used.
 
7159
+
 
7160
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7161
+
 
7162
+       Backport from mainline r204806:
 
7163
+
 
7164
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7165
+
 
7166
+       * config/rs6000/rs6000.c (rs6000_psave_function_arg): New function.
 
7167
+       (rs6000_finish_function_arg): Likewise.
 
7168
+       (rs6000_function_arg): Use rs6000_psave_function_arg and
 
7169
+       rs6000_finish_function_arg to handle both vector and floating
 
7170
+       point arguments that are also passed in GPRs / the stack.
 
7171
+
 
7172
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7173
+
 
7174
+       Backport from mainline r204805:
 
7175
+
 
7176
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7177
+
 
7178
+       * config/rs6000/rs6000.c (USE_FP_FOR_ARG_P): Remove TYPE argument.
 
7179
+       (USE_ALTIVEC_FOR_ARG_P): Likewise.
 
7180
+       (rs6000_darwin64_record_arg_advance_recurse): Update uses.
 
7181
+       (rs6000_function_arg_advance_1):Likewise.
 
7182
+       (rs6000_darwin64_record_arg_recurse): Likewise.
 
7183
+       (rs6000_function_arg): Likewise.
 
7184
+       (rs6000_arg_partial_bytes): Likewise.
 
7185
+
 
7186
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7187
+
 
7188
+       Backport from mainline r204804:
 
7189
+
 
7190
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7191
+
 
7192
+       * config/rs6000/rs6000.c (rs6000_option_override_internal): Replace
 
7193
+       "DEFAULT_ABI != ABI_AIX" test by testing for ABI_V4 or ABI_DARWIN.
 
7194
+       (rs6000_savres_strategy): Likewise.
 
7195
+       (rs6000_return_addr): Likewise.
 
7196
+       (rs6000_emit_load_toc_table): Replace "DEFAULT_ABI != ABI_AIX" by
 
7197
+       testing for ABI_V4 (since ABI_DARWIN is impossible here).
 
7198
+       (rs6000_emit_prologue): Likewise.
 
7199
+       (legitimate_lo_sum_address_p): Simplify DEFAULT_ABI test.
 
7200
+       (rs6000_elf_declare_function_name): Remove duplicated test.
 
7201
+       * config/rs6000/rs6000.md ("load_toc_v4_PIC_1"): Explicitly test
 
7202
+       for ABI_V4 (instead of "DEFAULT_ABI != ABI_AIX" test).
 
7203
+       ("load_toc_v4_PIC_1_normal"): Likewise.
 
7204
+       ("load_toc_v4_PIC_1_476"): Likewise.
 
7205
+       ("load_toc_v4_PIC_1b"): Likewise.
 
7206
+       ("load_toc_v4_PIC_1b_normal"): Likewise.
 
7207
+       ("load_toc_v4_PIC_1b_476"): Likewise.
 
7208
+       ("load_toc_v4_PIC_2"): Likewise.
 
7209
+       ("load_toc_v4_PIC_3b"): Likewise.
 
7210
+       ("load_toc_v4_PIC_3c"): Likewise.
 
7211
+       * config/rs6000/rs6000.h (RS6000_REG_SAVE): Simplify DEFAULT_ABI test.
 
7212
+       (RS6000_SAVE_AREA): Likewise.
 
7213
+       (FP_ARG_MAX_REG): Likewise.
 
7214
+       (RETURN_ADDRESS_OFFSET): Likewise.
 
7215
+       * config/rs6000/sysv.h (TARGET_TOC): Test for ABI_V4 instead
 
7216
+       of ABI_AIX.
 
7217
+       (SUBTARGET_OVERRIDE_OPTIONS): Likewise.
 
7218
+       (MINIMAL_TOC_SECTION_ASM_OP): Likewise.
 
7219
+
 
7220
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7221
+
 
7222
+       Backport from mainline r204803:
 
7223
+
 
7224
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7225
+
 
7226
+       * config/rs6000/rs6000.c (rs6000_call_indirect_aix): Rename to ...
 
7227
+       (rs6000_call_aix): ... this.  Handle both direct and indirect calls.
 
7228
+       Create call insn directly instead of via various gen_... routines.
 
7229
+       Mention special registers used by the call in CALL_INSN_FUNCTION_USAGE.
 
7230
+       (rs6000_sibcall_aix): New function.
 
7231
+       * config/rs6000/rs6000.md (TOC_SAVE_OFFSET_32BIT): Remove.
 
7232
+       (TOC_SAVE_OFFSET_64BIT): Likewise.
 
7233
+       (AIX_FUNC_DESC_TOC_32BIT): Likewise.
 
7234
+       (AIX_FUNC_DESC_TOC_64BIT): Likewise.
 
7235
+       (AIX_FUNC_DESC_SC_32BIT): Likewise.
 
7236
+       (AIX_FUNC_DESC_SC_64BIT): Likewise.
 
7237
+       ("call" expander): Call rs6000_call_aix.
 
7238
+       ("call_value" expander): Likewise.
 
7239
+       ("call_indirect_aix<ptrsize>"): Replace this pattern ...
 
7240
+       ("call_indirect_aix<ptrsize>_nor11"): ... and this pattern ...
 
7241
+       ("*call_indirect_aix<mode>"): ... by this insn pattern.
 
7242
+       ("call_value_indirect_aix<ptrsize>"): Replace this pattern ...
 
7243
+       ("call_value_indirect_aix<ptrsize>_nor11"): ... and this pattern ...
 
7244
+       ("*call_value_indirect_aix<mode>"): ... by this insn pattern.
 
7245
+       ("*call_nonlocal_aix32", "*call_nonlocal_aix64"): Replace by ...
 
7246
+       ("*call_nonlocal_aix<mode>"): ... this pattern.
 
7247
+       ("*call_value_nonlocal_aix32", "*call_value_nonlocal_aix64"): Replace
 
7248
+       ("*call_value_nonlocal_aix<mode>"): ... by this pattern.
 
7249
+       ("*call_local_aix<mode>"): New insn pattern.
 
7250
+       ("*call_value_local_aix<mode>"): Likewise.
 
7251
+       ("sibcall" expander): Call rs6000_sibcall_aix.
 
7252
+       ("sibcall_value" expander): Likewise.  Move earlier in file.
 
7253
+       ("*sibcall_nonlocal_aix<mode>"): Replace by ...
 
7254
+       ("*sibcall_aix<mode>"): ... this pattern.
 
7255
+       ("*sibcall_value_nonlocal_aix<mode>"): Replace by ...
 
7256
+       ("*sibcall_value_aix<mode>"): ... this pattern.
 
7257
+       * config/rs6000/rs6000-protos.h (rs6000_call_indirect_aix): Remove.
 
7258
+       (rs6000_call_aix): Add prototype.
 
7259
+       (rs6000_sibcall_aix): Likewise.
 
7260
+
 
7261
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7262
+
 
7263
+       Backport from mainline r204799:
 
7264
+
 
7265
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7266
+
 
7267
+       * config/rs6000/rs6000.c (rs6000_emit_prologue): Do not place a
 
7268
+       RTX_FRAME_RELATED_P marker on the UNSPEC_MOVESI_FROM_CR insn.
 
7269
+       Instead, add USEs of all modified call-saved CR fields to the
 
7270
+       insn storing the result to the stack slot, and provide an
 
7271
+       appropriate REG_FRAME_RELATED_EXPR for that insn.
 
7272
+       * config/rs6000/rs6000.md ("*crsave"): New insn pattern.
 
7273
+       * config/rs6000/predicates.md ("crsave_operation"): New predicate.
 
7274
+
 
7275
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7276
+
 
7277
+       Backport from mainline r204798:
 
7278
+
 
7279
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7280
+                   Alan Modra  <amodra@gmail.com>
 
7281
+
 
7282
+       * function.c (assign_parms): Use all.reg_parm_stack_space instead
 
7283
+       of re-evaluating REG_PARM_STACK_SPACE target macro.
 
7284
+       (locate_and_pad_parm): New parameter REG_PARM_STACK_SPACE.  Use it
 
7285
+       instead of evaluating target macro REG_PARM_STACK_SPACE every time.
 
7286
+       (assign_parm_find_entry_rtl): Update call.
 
7287
+       * calls.c (initialize_argument_information): Update call.
 
7288
+       (emit_library_call_value_1): Likewise.
 
7289
+       * expr.h (locate_and_pad_parm): Update prototype.
 
7290
+
 
7291
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7292
+
 
7293
+       Backport from mainline r204797:
 
7294
+
 
7295
+       2013-11-14  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7296
+
 
7297
+       * calls.c (store_unaligned_arguments_into_pseudos): Skip PARALLEL
 
7298
+       arguments.
 
7299
+
 
7300
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7301
+
 
7302
+       Backport from mainline r197003:
 
7303
+
 
7304
+       2013-03-23  Eric Botcazou  <ebotcazou@adacore.com>
 
7305
+
 
7306
+       * calls.c (expand_call): Add missing guard to code handling return
 
7307
+       of non-BLKmode structures in MSB.
 
7308
+       * function.c (expand_function_end): Likewise.
 
7309
+
 
7310
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
7311
+
 
7312
+       Backport from mainline r201750.
 
7313
+       Note: Default setting of -mcompat-align-parm inverted!
 
7314
+
 
7315
+       2013-08-14  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7316
+
 
7317
+       PR target/57949
 
7318
+       * doc/invoke.texi: Add documentation of mcompat-align-parm
 
7319
+       option.
 
7320
+       * config/rs6000/rs6000.opt: Add mcompat-align-parm option.
 
7321
+       * config/rs6000/rs6000.c (rs6000_function_arg_boundary): For AIX
 
7322
+       and Linux, correct BLKmode alignment when 128-bit alignment is
 
7323
+       required and compatibility flag is not set.
 
7324
+       (rs6000_gimplify_va_arg): For AIX and Linux, honor specified
 
7325
+       alignment for zero-size arguments when compatibility flag is not
 
7326
+       set.
 
7327
+
 
7328
+2013-11-12  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7329
+
 
7330
+       * configure: Regenerate.
 
7331
+
 
7332
+2013-11-10  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7333
+
 
7334
+       Backport from mainline r204441
 
7335
+       2013-11-05  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7336
+
 
7337
+       * config/rs6000/rs6000.c (rs6000_option_override_internal):
 
7338
+       Remove restriction against use of VSX instructions when generating
 
7339
+       code for little endian mode.
 
7340
+
 
7341
+2013-11-10  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7342
+
 
7343
+       Backport from mainline r204440
 
7344
+       2013-11-05  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7345
+
 
7346
+       * config/rs6000/altivec.md (mulv4si3): Ensure we generate vmulouh
 
7347
+       for both big and little endian.
 
7348
+       (mulv8hi3): Swap input operands for merge high and merge low
 
7349
+       instructions for little endian.
 
7350
+
 
7351
+2013-11-10  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7352
+
 
7353
+       Backport from mainline r204439
 
7354
+       2013-11-05  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7355
+
 
7356
+       * config/rs6000/altivec.md (vec_widen_umult_even_v16qi): Change
 
7357
+       define_insn to define_expand that uses even patterns for big
 
7358
+       endian and odd patterns for little endian.
 
7359
+       (vec_widen_smult_even_v16qi): Likewise.
 
7360
+       (vec_widen_umult_even_v8hi): Likewise.
 
7361
+       (vec_widen_smult_even_v8hi): Likewise.
 
7362
+       (vec_widen_umult_odd_v16qi): Likewise.
 
7363
+       (vec_widen_smult_odd_v16qi): Likewise.
 
7364
+       (vec_widen_umult_odd_v8hi): Likewise.
 
7365
+       (vec_widen_smult_odd_v8hi): Likewise.
 
7366
+       (altivec_vmuleub): New define_insn.
 
7367
+       (altivec_vmuloub): Likewise.
 
7368
+       (altivec_vmulesb): Likewise.
 
7369
+       (altivec_vmulosb): Likewise.
 
7370
+       (altivec_vmuleuh): Likewise.
 
7371
+       (altivec_vmulouh): Likewise.
 
7372
+       (altivec_vmulesh): Likewise.
 
7373
+       (altivec_vmulosh): Likewise.
 
7374
+
 
7375
+2013-11-10  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7376
+
 
7377
+       Backport from mainline r204395
 
7378
+       2013-11-05  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7379
+
 
7380
+       * config/rs6000/vector.md (vec_pack_sfix_trunc_v2df): Adjust for
 
7381
+       little endian.
 
7382
+       (vec_pack_ufix_trunc_v2df): Likewise.
 
7383
+
 
7384
+2013-11-10  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7385
+
 
7386
+       Backport from mainline r204363
 
7387
+       2013-11-04  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7388
+
 
7389
+       * config/rs6000/altivec.md (vec_widen_umult_hi_v16qi): Swap
 
7390
+       arguments to merge instruction for little endian.
 
7391
+       (vec_widen_umult_lo_v16qi): Likewise.
 
7392
+       (vec_widen_smult_hi_v16qi): Likewise.
 
7393
+       (vec_widen_smult_lo_v16qi): Likewise.
 
7394
+       (vec_widen_umult_hi_v8hi): Likewise.
 
7395
+       (vec_widen_umult_lo_v8hi): Likewise.
 
7396
+       (vec_widen_smult_hi_v8hi): Likewise.
 
7397
+       (vec_widen_smult_lo_v8hi): Likewise.
 
7398
+
 
7399
+2013-11-10  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7400
+
 
7401
+       Backport from mainline r204350
 
7402
+       2013-11-04  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7403
+
 
7404
+       * config/rs6000/vsx.md (*vsx_le_perm_store_<mode> for VSX_D):
 
7405
+       Replace the define_insn_and_split with a define_insn and two
 
7406
+       define_splits, with the split after reload re-permuting the source
 
7407
+       register to its original value.
 
7408
+       (*vsx_le_perm_store_<mode> for VSX_W): Likewise.
 
7409
+       (*vsx_le_perm_store_v8hi): Likewise.
 
7410
+       (*vsx_le_perm_store_v16qi): Likewise.
 
7411
+
 
7412
+2013-11-10  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7413
+
 
7414
+       Backport from mainline r204321
 
7415
+       2013-11-04  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7416
+
 
7417
+       * config/rs6000/vector.md (vec_pack_trunc_v2df):  Adjust for
 
7418
+       little endian.
 
7419
+
 
7420
+2013-11-10  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7421
+
 
7422
+       Backport from mainline r204321
 
7423
+       2013-11-02  Bill Schmidt  <wschmidt@vnet.linux.ibm.com>
 
7424
+
 
7425
+       * config/rs6000/rs6000.c (rs6000_expand_vector_set): Adjust for
 
7426
+       little endian.
 
7427
+
 
7428
+2013-11-10  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7429
+
 
7430
+       Backport from mainline r203980
 
7431
+       2013-10-23  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7432
+
 
7433
+       * config/rs6000/altivec.md (mulv8hi3): Adjust for little endian.
 
7434
+
 
7435
+2013-11-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7436
+
 
7437
+       Backport from mainline r203930
 
7438
+       2013-10-22  Bill Schmidt  <wschmidt@vnet.ibm.com>
 
7439
+
 
7440
+       * config/rs6000/rs6000.c (altivec_expand_vec_perm_const): Reverse
 
7441
+       meaning of merge-high and merge-low masks for little endian; avoid
 
7442
+       use of vector-pack masks for little endian for mismatched modes.
 
7443
+
 
7444
+2013-11-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7445
+
 
7446
+       Backport from mainline r203877
 
7447
+       2013-10-20  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7448
+
 
7449
+       * config/rs6000/altivec.md (vec_unpacku_hi_v16qi): Adjust for
 
7450
+       little endian.
 
7451
+       (vec_unpacku_hi_v8hi): Likewise.
 
7452
+       (vec_unpacku_lo_v16qi): Likewise.
 
7453
+       (vec_unpacku_lo_v8hi): Likewise.
 
7454
+
 
7455
+2013-11-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7456
+
 
7457
+       Backport from mainline r203863
 
7458
+       2013-10-19  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7459
+
 
7460
+       * config/rs6000/rs6000.c (vspltis_constant): Make sure we check
 
7461
+       all elements for both endian flavors.
 
7462
+
 
7463
+2013-11-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7464
+
 
7465
+       Backport from mainline r203714
 
7466
+       2013-10-16  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7467
+
 
7468
+       * gcc/config/rs6000/vector.md (vec_unpacks_hi_v4sf): Correct for
 
7469
+       endianness.
 
7470
+       (vec_unpacks_lo_v4sf): Likewise.
 
7471
+       (vec_unpacks_float_hi_v4si): Likewise.
 
7472
+       (vec_unpacks_float_lo_v4si): Likewise.
 
7473
+       (vec_unpacku_float_hi_v4si): Likewise.
 
7474
+       (vec_unpacku_float_lo_v4si): Likewise.
 
7475
+
 
7476
+2013-11-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7477
+
 
7478
+       Backport from mainline r203713
 
7479
+       2013-10-16  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7480
+
 
7481
+       * config/rs6000/vsx.md (vsx_concat_<mode>): Adjust output for LE.
 
7482
+       (vsx_concat_v2sf): Likewise.
 
7483
+
 
7484
+2013-11-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7485
+
 
7486
+       Backport from mainline r203458
 
7487
+       2013-10-11  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7488
+
 
7489
+       * config/rs6000/vsx.md (*vsx_le_perm_load_v2di): Generalize to
 
7490
+       handle vector float as well.
 
7491
+       (*vsx_le_perm_load_v4si): Likewise.
 
7492
+       (*vsx_le_perm_store_v2di): Likewise.
 
7493
+       (*vsx_le_perm_store_v4si): Likewise.
 
7494
+
 
7495
+2013-11-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7496
+
 
7497
+       Backport from mainline r203457
 
7498
+       2013-10-11  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7499
+
 
7500
+       * config/rs6000/vector.md (vec_realign_load<mode>): Generate vperm
 
7501
+       directly to circumvent subtract from splat{31} workaround.
 
7502
+       * config/rs6000/rs6000-protos.h (altivec_expand_vec_perm_le): New
 
7503
+       prototype.
 
7504
+       * config/rs6000/rs6000.c (altivec_expand_vec_perm_le): New.
 
7505
+       * config/rs6000/altivec.md (define_c_enum "unspec"): Add
 
7506
+       UNSPEC_VPERM_X and UNSPEC_VPERM_UNS_X.
 
7507
+       (altivec_vperm_<mode>): Convert to define_insn_and_split to
 
7508
+       separate big and little endian logic.
 
7509
+       (*altivec_vperm_<mode>_internal): New define_insn.
 
7510
+       (altivec_vperm_<mode>_uns): Convert to define_insn_and_split to
 
7511
+       separate big and little endian logic.
 
7512
+       (*altivec_vperm_<mode>_uns_internal): New define_insn.
 
7513
+       (vec_permv16qi): Add little endian logic.
 
7514
+
 
7515
+2013-11-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7516
+
 
7517
+       Backport from mainline r203247
 
7518
+       2013-10-07  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7519
+
 
7520
+       * config/rs6000/rs6000.c (altivec_expand_vec_perm_const_le): New.
 
7521
+       (altivec_expand_vec_perm_const): Call it.
 
7522
+
 
7523
+2013-11-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7524
+
 
7525
+       Backport from mainline r203246
 
7526
+       2013-10-07  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7527
+
 
7528
+       * config/rs6000/vector.md (mov<mode>): Emit permuted move
 
7529
+       sequences for LE VSX loads and stores at expand time.
 
7530
+       * config/rs6000/rs6000-protos.h (rs6000_emit_le_vsx_move): New
 
7531
+       prototype.
 
7532
+       * config/rs6000/rs6000.c (rs6000_const_vec): New.
 
7533
+       (rs6000_gen_le_vsx_permute): New.
 
7534
+       (rs6000_gen_le_vsx_load): New.
 
7535
+       (rs6000_gen_le_vsx_store): New.
 
7536
+       (rs6000_gen_le_vsx_move): New.
 
7537
+       * config/rs6000/vsx.md (*vsx_le_perm_load_v2di): New.
 
7538
+       (*vsx_le_perm_load_v4si): New.
 
7539
+       (*vsx_le_perm_load_v8hi): New.
 
7540
+       (*vsx_le_perm_load_v16qi): New.
 
7541
+       (*vsx_le_perm_store_v2di): New.
 
7542
+       (*vsx_le_perm_store_v4si): New.
 
7543
+       (*vsx_le_perm_store_v8hi): New.
 
7544
+       (*vsx_le_perm_store_v16qi): New.
 
7545
+       (*vsx_xxpermdi2_le_<mode>): New.
 
7546
+       (*vsx_xxpermdi4_le_<mode>): New.
 
7547
+       (*vsx_xxpermdi8_le_V8HI): New.
 
7548
+       (*vsx_xxpermdi16_le_V16QI): New.
 
7549
+       (*vsx_lxvd2x2_le_<mode>): New.
 
7550
+       (*vsx_lxvd2x4_le_<mode>): New.
 
7551
+       (*vsx_lxvd2x8_le_V8HI): New.
 
7552
+       (*vsx_lxvd2x16_le_V16QI): New.
 
7553
+       (*vsx_stxvd2x2_le_<mode>): New.
 
7554
+       (*vsx_stxvd2x4_le_<mode>): New.
 
7555
+       (*vsx_stxvd2x8_le_V8HI): New.
 
7556
+       (*vsx_stxvd2x16_le_V16QI): New.
 
7557
+
 
7558
+2013-11-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7559
+
 
7560
+       Backport from mainline r201235
 
7561
+       2013-07-24  Bill Schmidt  <wschmidt@linux.ibm.com>
 
7562
+                   Anton Blanchard <anton@au1.ibm.com>
 
7563
+
 
7564
+       * config/rs6000/altivec.md (altivec_vpkpx): Handle little endian.
 
7565
+       (altivec_vpks<VI_char>ss): Likewise.
 
7566
+       (altivec_vpks<VI_char>us): Likewise.
 
7567
+       (altivec_vpku<VI_char>us): Likewise.
 
7568
+       (altivec_vpku<VI_char>um): Likewise.
 
7569
+
 
7570
+2013-11-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7571
+
 
7572
+       Backport from mainline r201208
 
7573
+       2013-07-24  Bill Schmidt  <wschmidt@vnet.linux.ibm.com>
 
7574
+                   Anton Blanchard <anton@au1.ibm.com>
 
7575
+
 
7576
+       * config/rs6000/vector.md (vec_realign_load_<mode>): Reorder input
 
7577
+       operands to vperm for little endian.
 
7578
+       * config/rs6000/rs6000.c (rs6000_expand_builtin): Use lvsr instead
 
7579
+       of lvsl to create the control mask for a vperm for little endian.
 
7580
+
 
7581
+2013-11-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7582
+
 
7583
+       Backport from mainline r201195
 
7584
+       2013-07-23  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7585
+                   Anton Blanchard <anton@au1.ibm.com>
 
7586
+
 
7587
+       * config/rs6000/rs6000.c (altivec_expand_vec_perm_const): Reverse
 
7588
+       two operands for little-endian.
 
7589
+
 
7590
+2013-11-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7591
+
 
7592
+       Backport from mainline r201193
 
7593
+       2013-07-23  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7594
+                   Anton Blanchard <anton@au1.ibm.com>
 
7595
+
 
7596
+       * config/rs6000/rs6000.c (altivec_expand_vec_perm_const): Correct
 
7597
+       selection of field for vector splat in little endian mode.
 
7598
+
 
7599
+2013-11-08  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7600
+
 
7601
+       Backport from mainline r201149
 
7602
+       2013-07-22  Bill Schmidt  <wschmidt@vnet.linux.ibm.com>
 
7603
+                   Anton Blanchard <anton@au1.ibm.com>
 
7604
+
 
7605
+       * config/rs6000/rs6000.c (rs6000_expand_vector_init): Fix
 
7606
+       endianness when selecting field to splat.
 
7607
+
 
7608
+2013-10-21  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7609
+
 
7610
+       Backport from mainline
 
7611
+       2013-04-05  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
7612
+
 
7613
+       PR target/56843
 
7614
+       * config/rs6000/rs6000.c (rs6000_emit_swdiv_high_precision): Remove.
 
7615
+       (rs6000_emit_swdiv_low_precision): Remove.
 
7616
+       (rs6000_emit_swdiv): Rewrite to handle between one and four
 
7617
+       iterations of Newton-Raphson generally; modify required number of
 
7618
+       iterations for some cases.
 
7619
+       * config/rs6000/rs6000.h (RS6000_RECIP_HIGH_PRECISION_P): Remove.
 
7620
+
 
7621
+2013-10-17  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
7622
+
 
7623
+       Backport from mainline
 
7624
+       2013-10-17  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
7625
+
 
7626
+       * config/rs6000/rs6000.c (enum rs6000_reload_reg_type): Add new
 
7627
+       fields to the reg_addr array that describes the valid addressing
 
7628
+       mode for any register, general purpose registers, floating point
 
7629
+       registers, and Altivec registers.
 
7630
+       (FIRST_RELOAD_REG_CLASS): Likewise.
 
7631
+       (LAST_RELOAD_REG_CLASS): Likewise.
 
7632
+       (struct reload_reg_map_type): Likewise.
 
7633
+       (reload_reg_map_type): Likewise.
 
7634
+       (RELOAD_REG_VALID): Likewise.
 
7635
+       (RELOAD_REG_MULTIPLE): Likewise.
 
7636
+       (RELOAD_REG_INDEXED): Likewise.
 
7637
+       (RELOAD_REG_OFFSET): Likewise.
 
7638
+       (RELOAD_REG_PRE_INCDEC): Likewise.
 
7639
+       (RELOAD_REG_PRE_MODIFY): Likewise.
 
7640
+       (reg_addr): Likewise.
 
7641
+       (mode_supports_pre_incdec_p): New helper functions to say whether
 
7642
+       a given mode supports PRE_INC, PRE_DEC, and PRE_MODIFY.
 
7643
+       (mode_supports_pre_modify_p): Likewise.
 
7644
+       (rs6000_debug_vector_unit): Rearrange the -mdebug=reg output to
 
7645
+       print the valid address mode bits for each mode.
 
7646
+       (rs6000_debug_print_mode): Likewise.
 
7647
+       (rs6000_debug_reg_global): Likewise.
 
7648
+       (rs6000_setup_reg_addr_masks): New function to set up the address
 
7649
+       mask bits for each type.
 
7650
+       (rs6000_init_hard_regno_mode_ok): Use memset to clear arrays.
 
7651
+       Call rs6000_setup_reg_addr_masks to set up the address mask bits.
 
7652
+       (rs6000_legitimate_address_p): Use mode_supports_pre_incdec_p and
 
7653
+       mode_supports_pre_modify_p to determine if PRE_INC, PRE_DEC, and
 
7654
+       PRE_MODIFY are supported.
 
7655
+       (rs6000_output_move_128bit): Change to use {src,dest}_vmx_p for altivec
 
7656
+       registers, instead of {src,dest}_av_p.
 
7657
+       (rs6000_print_options_internal): Tweak the debug output slightly.
 
7658
+
 
7659
+       Backport from mainline
 
7660
+       2013-10-03  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
7661
+
 
7662
+       * config/rs6000/rs6000-builtin.def (XSRDPIM): Use floatdf2,
 
7663
+       ceildf2, btruncdf2, instead of vsx_* name.
 
7664
+
 
7665
+       * config/rs6000/vsx.md (vsx_add<mode>3): Change arithmetic
 
7666
+       iterators to only do V2DF and V4SF here.  Move the DF code to
 
7667
+       rs6000.md where it is combined with SF mode.  Replace <VSv> with
 
7668
+       just 'v' since only vector operations are handled with these insns
 
7669
+       after moving the DF support to rs6000.md.
 
7670
+       (vsx_sub<mode>3): Likewise.
 
7671
+       (vsx_mul<mode>3): Likewise.
 
7672
+       (vsx_div<mode>3): Likewise.
 
7673
+       (vsx_fre<mode>2): Likewise.
 
7674
+       (vsx_neg<mode>2): Likewise.
 
7675
+       (vsx_abs<mode>2): Likewise.
 
7676
+       (vsx_nabs<mode>2): Likewise.
 
7677
+       (vsx_smax<mode>3): Likewise.
 
7678
+       (vsx_smin<mode>3): Likewise.
 
7679
+       (vsx_sqrt<mode>2): Likewise.
 
7680
+       (vsx_rsqrte<mode>2): Likewise.
 
7681
+       (vsx_fms<mode>4): Likewise.
 
7682
+       (vsx_nfma<mode>4): Likewise.
 
7683
+       (vsx_copysign<mode>3): Likewise.
 
7684
+       (vsx_btrunc<mode>2): Likewise.
 
7685
+       (vsx_floor<mode>2): Likewise.
 
7686
+       (vsx_ceil<mode>2): Likewise.
 
7687
+       (vsx_smaxsf3): Delete scalar ops that were moved to rs6000.md.
 
7688
+       (vsx_sminsf3): Likewise.
 
7689
+       (vsx_fmadf4): Likewise.
 
7690
+       (vsx_fmsdf4): Likewise.
 
7691
+       (vsx_nfmadf4): Likewise.
 
7692
+       (vsx_nfmsdf4): Likewise.
 
7693
+       (vsx_cmpdf_internal1): Likewise.
 
7694
+
 
7695
+       * config/rs6000/rs6000.h (TARGET_SF_SPE): Define macros to make it
 
7696
+       simpler to select whether a target has SPE or traditional floating
 
7697
+       point support in iterators.
 
7698
+       (TARGET_DF_SPE): Likewise.
 
7699
+       (TARGET_SF_FPR): Likewise.
 
7700
+       (TARGET_DF_FPR): Likewise.
 
7701
+       (TARGET_SF_INSN): Macros to say whether floating point support
 
7702
+       exists for a given operation for expanders.
 
7703
+       (TARGET_DF_INSN): Likewise.
 
7704
+
 
7705
+       * config/rs6000/rs6000.c (Ftrad): New mode attributes to allow
 
7706
+       combining of SF/DF mode operations, using both traditional and VSX
 
7707
+       registers.
 
7708
+       (Fvsx): Likewise.
 
7709
+       (Ff): Likewise.
 
7710
+       (Fv): Likewise.
 
7711
+       (Fs): Likewise.
 
7712
+       (Ffre): Likewise.
 
7713
+       (FFRE): Likewise.
 
7714
+       (abs<mode>2): Combine SF/DF modes using traditional floating point
 
7715
+       instructions.  Add support for using the upper DF registers with
 
7716
+       VSX support, and SF registers with power8-vector support.  Update
 
7717
+       expanders for operations supported by both the SPE and traditional
 
7718
+       floating point units.
 
7719
+       (abs<mode>2_fpr): Likewise.
 
7720
+       (nabs<mode>2): Likewise.
 
7721
+       (nabs<mode>2_fpr): Likewise.
 
7722
+       (neg<mode>2): Likewise.
 
7723
+       (neg<mode>2_fpr): Likewise.
 
7724
+       (add<mode>3): Likewise.
 
7725
+       (add<mode>3_fpr): Likewise.
 
7726
+       (sub<mode>3): Likewise.
 
7727
+       (sub<mode>3_fpr): Likewise.
 
7728
+       (mul<mode>3): Likewise.
 
7729
+       (mul<mode>3_fpr): Likewise.
 
7730
+       (div<mode>3): Likewise.
 
7731
+       (div<mode>3_fpr): Likewise.
 
7732
+       (sqrt<mode>3): Likewise.
 
7733
+       (sqrt<mode>3_fpr): Likewise.
 
7734
+       (fre<Fs>): Likewise.
 
7735
+       (rsqrt<mode>2): Likewise.
 
7736
+       (cmp<mode>_fpr): Likewise.
 
7737
+       (smax<mode>3): Likewise.
 
7738
+       (smin<mode>3): Likewise.
 
7739
+       (smax<mode>3_vsx): Likewise.
 
7740
+       (smin<mode>3_vsx): Likewise.
 
7741
+       (negsf2): Delete SF operations that are merged with DF.
 
7742
+       (abssf2): Likewise.
 
7743
+       (addsf3): Likewise.
 
7744
+       (subsf3): Likewise.
 
7745
+       (mulsf3): Likewise.
 
7746
+       (divsf3): Likewise.
 
7747
+       (fres): Likewise.
 
7748
+       (fmasf4_fpr): Likewise.
 
7749
+       (fmssf4_fpr): Likewise.
 
7750
+       (nfmasf4_fpr): Likewise.
 
7751
+       (nfmssf4_fpr): Likewise.
 
7752
+       (sqrtsf2): Likewise.
 
7753
+       (rsqrtsf_internal1): Likewise.
 
7754
+       (smaxsf3): Likewise.
 
7755
+       (sminsf3): Likewise.
 
7756
+       (cmpsf_internal1): Likewise.
 
7757
+       (copysign<mode>3_fcpsgn): Add VSX/power8-vector support.
 
7758
+       (negdf2): Delete DF operations that are merged with SF.
 
7759
+       (absdf2): Likewise.
 
7760
+       (nabsdf2): Likewise.
 
7761
+       (adddf3): Likewise.
 
7762
+       (subdf3): Likewise.
 
7763
+       (muldf3): Likewise.
 
7764
+       (divdf3): Likewise.
 
7765
+       (fred): Likewise.
 
7766
+       (rsqrtdf_internal1): Likewise.
 
7767
+       (fmadf4_fpr): Likewise.
 
7768
+       (fmsdf4_fpr): Likewise.
 
7769
+       (nfmadf4_fpr): Likewise.
 
7770
+       (nfmsdf4_fpr): Likewise.
 
7771
+       (sqrtdf2): Likewise.
 
7772
+       (smaxdf3): Likewise.
 
7773
+       (smindf3): Likewise.
 
7774
+       (cmpdf_internal1): Likewise.
 
7775
+       (lrint<mode>di2): Use TARGET_<MODE>_FPR macro.
 
7776
+       (btrunc<mode>2): Delete separate expander, and combine with the
 
7777
+       insn and add VSX instruction support.  Use TARGET_<MODE>_FPR.
 
7778
+       (btrunc<mode>2_fpr): Likewise.
 
7779
+       (ceil<mode>2): Likewise.
 
7780
+       (ceil<mode>2_fpr): Likewise.
 
7781
+       (floor<mode>2): Likewise.
 
7782
+       (floor<mode>2_fpr): Likewise.
 
7783
+       (fma<mode>4_fpr): Combine SF and DF fused multiply/add support.
 
7784
+       Add support for using the upper registers with VSX and
 
7785
+       power8-vector.  Move insns to be closer to the define_expands. On
 
7786
+       VSX systems, prefer the traditional form of FMA over the VSX
 
7787
+       version, since the traditional form allows the target not to
 
7788
+       overlap with the inputs.
 
7789
+       (fms<mode>4_fpr): Likewise.
 
7790
+       (nfma<mode>4_fpr): Likewise.
 
7791
+       (nfms<mode>4_fpr): Likewise.
 
7792
+
 
7793
+       Backport from mainline
 
7794
+       2013-09-27  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
7795
+
 
7796
+       * config/rs6000/rs6000.c (rs6000_hard_regno_mode_ok): Allow
 
7797
+       DFmode, DImode, and SFmode in the upper VSX registers based on the
 
7798
+       -mupper-regs-{df,sf} flags.  Fix wu constraint to be ALTIVEC_REGS
 
7799
+       if -mpower8-vector.  Combine -mvsx-timode handling with the rest
 
7800
+       of the VSX register handling.
 
7801
+
 
7802
+       * config/rs6000/rs6000.md (f32_lv): Use %x0 for VSX regsters.
 
7803
+       (f32_sv): Likewise.
 
7804
+       (zero_extendsidi2_lfiwzx): Add support for loading into the
 
7805
+       Altivec registers with -mpower8-vector.  Use wu/wv constraints to
 
7806
+       only do VSX memory options on Altivec registers.
 
7807
+       (extendsidi2_lfiwax): Likewise.
 
7808
+       (extendsfdf2_fpr): Likewise.
 
7809
+       (mov<mode>_hardfloat, SF/SD modes): Likewise.
 
7810
+       (mov<mode>_hardfloat32, DF/DD modes): Likewise.
 
7811
+       (mov<mode>_hardfloat64, DF/DD modes): Likewise.
 
7812
+       (movdi_internal64): Likewise.
 
7813
+
 
7814
+       Backport from mainline
 
7815
+       2013-09-23  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
7816
+
 
7817
+       * config/rs6000/rs6000.c (rs6000_vector_reload): Delete, combine
 
7818
+       reload helper function arrays into a single array reg_addr.
 
7819
+       (reload_fpr_gpr): Likewise.
 
7820
+       (reload_gpr_vsx): Likewise.
 
7821
+       (reload_vsx_gpr): Likewise.
 
7822
+       (struct rs6000_reg_addr): Likewise.
 
7823
+       (reg_addr): Likewise.
 
7824
+       (rs6000_debug_reg_global): Change rs6000_vector_reload,
 
7825
+       reload_fpr_gpr, reload_gpr_vsx, reload_vsx_gpr uses to reg_addr.
 
7826
+       (rs6000_init_hard_regno_mode_ok): Likewise.
 
7827
+       (rs6000_secondary_reload_direct_move): Likewise.
 
7828
+       (rs6000_secondary_reload): Likewise.
 
7829
+
 
7830
+       * config/rs6000/rs6000.h (enum r6000_reg_class_enum): Add new
 
7831
+       constraints: wu, ww, and wy.  Repurpose wv constraint added during
 
7832
+       power8 changes.  Put wg constraint in alphabetical order.
 
7833
+
 
7834
+       * config/rs6000/rs6000.opt (-mvsx-scalar-float): New debug switch
 
7835
+       for future work to add ISA 2.07 VSX single precision support.
 
7836
+       (-mvsx-scalar-double): Change default from -1 to 1, update
 
7837
+       documentation comment.
 
7838
+       (-mvsx-scalar-memory): Rename debug switch to -mupper-regs-df.
 
7839
+       (-mupper-regs-df): New debug switch to control whether DF values
 
7840
+       can go in the traditional Altivec registers.
 
7841
+       (-mupper-regs-sf): New debug switch to control whether SF values
 
7842
+       can go in the traditional Altivec registers.
 
7843
+
 
7844
+       * config/rs6000/rs6000.c (rs6000_debug_reg_global): Print wu, ww,
 
7845
+       and wy constraints.
 
7846
+       (rs6000_init_hard_regno_mode_ok): Use ssize_t instead of int for
 
7847
+       loop variables.  Rename -mvsx-scalar-memory to -mupper-regs-df.
 
7848
+       Add new constraints, wu/ww/wy.  Repurpose wv constraint.
 
7849
+       (rs6000_debug_legitimate_address_p): Print if we are running
 
7850
+       before, during, or after reload.
 
7851
+       (rs6000_secondary_reload): Add a comment.
 
7852
+       (rs6000_opt_masks): Add -mupper-regs-df, -mupper-regs-sf.
 
7853
+
 
7854
+       * config/rs6000/constraints.md (wa constraint): Sort w<x>
 
7855
+       constraints.  Update documentation string.
 
7856
+       (wd constraint): Likewise.
 
7857
+       (wf constraint): Likewise.
 
7858
+       (wg constraint): Likewise.
 
7859
+       (wn constraint): Likewise.
 
7860
+       (ws constraint): Likewise.
 
7861
+       (wt constraint): Likewise.
 
7862
+       (wx constraint): Likewise.
 
7863
+       (wz constraint): Likewise.
 
7864
+       (wu constraint): New constraint for ISA 2.07 SFmode scalar
 
7865
+       instructions.
 
7866
+       (ww constraint): Likewise.
 
7867
+       (wy constraint): Likewise.
 
7868
+       (wv constraint): Repurpose ISA 2.07 constraint that did not use in
 
7869
+       the previous submissions.
 
7870
+       * doc/md.texi (PowerPC and IBM RS6000): Likewise.
 
7871
+
 
7872
+       Backport from mainline
 
7873
+       2013-10-17  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
7874
+
 
7875
+       PR target/58673
 
7876
+       * config/rs6000/rs6000.c (rs6000_legitimate_address_p): Only
 
7877
+       restrict TImode addresses to single indirect registers if both
 
7878
+       -mquad-memory and -mvsx-timode are used.
 
7879
+       (rs6000_output_move_128bit): Use quad_load_store_p to determine if
 
7880
+       we should emit load/store quad.  Remove using %y for quad memory
 
7881
+       addresses.
 
7882
+
 
7883
+       * config/rs6000/rs6000.md (mov<mode>_ppc64, TI/PTImode): Add
 
7884
+       constraints to allow load/store quad on machines where TImode is
 
7885
+       not allowed in VSX registers.  Use 'n' instead of 'F' constraint
 
7886
+       for TImode to load integer constants.
 
7887
+
 
7888
+2013-10-02  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
7889
+
 
7890
+       Backport from mainline
 
7891
+       2013-10-02  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
7892
+
 
7893
+       PR target/58587
 
7894
+       * config/rs6000/rs6000-cpus.def (ISA_2_6_MASKS_SERVER): Turn off
 
7895
+       setting -mvsx-timode by default until the underlying problem is
 
7896
+       fixed.
 
7897
+       (RS6000_CPU, power7 defaults): Likewise.
 
7898
+
 
7899
+2013-08-19  Peter Bergner  <bergner@vnet.ibm.com>
 
7900
+
 
7901
+       Backport from mainline
 
7902
+       2013-08-19  Peter Bergner  <bergner@vnet.ibm.com>
 
7903
+                   Jakub Jelinek  <jakub@redhat.com>
 
7904
+
 
7905
+       * builtins.def (BUILT_IN_FABSD32): New DFP ABS builtin.
 
7906
+       (BUILT_IN_FABSD64): Likewise.
 
7907
+       (BUILT_IN_FABSD128): Likewise.
 
7908
+       * builtins.c (expand_builtin): Add support for
 
7909
+       new DFP ABS builtins.
 
7910
+       (fold_builtin_1): Likewise.
 
7911
+       * config/rs6000/dfp.md
 
7912
+       (*negtd2_fpr): Handle
 
7913
+       non-overlapping destination
 
7914
+       and source operands.
 
7915
+       (*abstd2_fpr):
 
7916
+       Likewise.
 
7917
+       (*nabstd2_fpr):
 
7918
+       Likewise.
 
7919
+
 
7920
+2013-08-16  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
7921
+
 
7922
+       Backport from trunk
 
7923
+       2013-08-16  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
7924
+
 
7925
+       PR target/58160
 
7926
+       * config/rs6000/predicates.md (fusion_gpr_mem_load): Allow the
 
7927
+       memory rtx to contain ZERO_EXTEND and SIGN_EXTEND.
 
7928
+
 
7929
+       * config/rs6000/rs6000-protos.h (fusion_gpr_load_p): Pass operands
 
7930
+       array instead of each individual operand as a separate argument.
 
7931
+       (emit_fusion_gpr_load): Likewise.
 
7932
+       (expand_fusion_gpr_load): Add new function declaration.
 
7933
+
 
7934
+       * config/rs6000/rs6000.c (fusion_gpr_load_p): Change the calling
 
7935
+       signature to have the operands passed as an array, instead of as
 
7936
+       separate arguments.  Allow ZERO_EXTEND to be in the memory
 
7937
+       address, and also SIGN_EXTEND if -mpower8-fusion-sign.  Do not
 
7938
+       depend on the register live/dead flags when peepholes are run.
 
7939
+       (expand_fusion_gpr_load): New function to be called from the
 
7940
+       peephole2 pass, to change the register that addis sets to be the
 
7941
+       target register.
 
7942
+       (emit_fusion_gpr_load): Change the calling signature to have the
 
7943
+       operands passed as an array, instead of as separate arguments.
 
7944
+       Allow ZERO_EXTEND to be in the memory address, and also
 
7945
+       SIGN_EXTEND if -mpower8-fusion-sign.
 
7946
+
 
7947
+       * config/rs6000/rs6000.md (UNSPEC_FUSION_GPR): Delete unused
 
7948
+       unspec enumeration.
 
7949
+       (power8 fusion peephole/peephole2): Rework the fusion peepholes to
 
7950
+       adjust the register addis loads up in the peephole2 pass.  Do not
 
7951
+       depend on the register live/dead state when the peephole pass is
 
7952
+       done.
 
7953
+
 
7954
+       Backport from trunk
 
7955
+       2013-07-23  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
7956
+
 
7957
+       * config/rs6000/vector.md (xor<mode>3): Move 128-bit boolean
 
7958
+       expanders to rs6000.md.
 
7959
+       (ior<mode>3): Likewise.
 
7960
+       (and<mode>3): Likewise.
 
7961
+       (one_cmpl<mode>2): Likewise.
 
7962
+       (nor<mode>3): Likewise.
 
7963
+       (andc<mode>3): Likewise.
 
7964
+       (eqv<mode>3): Likewise.
 
7965
+       (nand<mode>3): Likewise.
 
7966
+       (orc<mode>3): Likewise.
 
7967
+
 
7968
+       * config/rs6000/rs6000-protos.h (rs6000_split_logical): New
 
7969
+       declaration.
 
7970
+
 
7971
+       * config/rs6000/rs6000.c (rs6000_split_logical_inner): Add support
 
7972
+       to split multi-word logical operations.
 
7973
+       (rs6000_split_logical_di): Likewise.
 
7974
+       (rs6000_split_logical): Likewise.
 
7975
+
 
7976
+       * config/rs6000/vsx.md (VSX_L2): Delete, no longer used.
 
7977
+       (vsx_and<mode>3_32bit): Move 128-bit logical insns to rs6000.md,
 
7978
+       and allow TImode operations in 32-bit.
 
7979
+       (vsx_and<mode>3_64bit): Likewise.
 
7980
+       (vsx_ior<mode>3_32bit): Likewise.
 
7981
+       (vsx_ior<mode>3_64bit): Likewise.
 
7982
+       (vsx_xor<mode>3_32bit): Likewise.
 
7983
+       (vsx_xor<mode>3_64bit): Likewise.
 
7984
+       (vsx_one_cmpl<mode>2_32bit): Likewise.
 
7985
+       (vsx_one_cmpl<mode>2_64bit): Likewise.
 
7986
+       (vsx_nor<mode>3_32bit): Likewise.
 
7987
+       (vsx_nor<mode>3_64bit): Likewise.
 
7988
+       (vsx_andc<mode>3_32bit): Likewise.
 
7989
+       (vsx_andc<mode>3_64bit): Likewise.
 
7990
+       (vsx_eqv<mode>3_32bit): Likewise.
 
7991
+       (vsx_eqv<mode>3_64bit): Likewise.
 
7992
+       (vsx_nand<mode>3_32bit): Likewise.
 
7993
+       (vsx_nand<mode>3_64bit): Likewise.
 
7994
+       (vsx_orc<mode>3_32bit): Likewise.
 
7995
+       (vsx_orc<mode>3_64bit): Likewise.
 
7996
+
 
7997
+       * config/rs6000/rs6000.h (VLOGICAL_REGNO_P): Always allow vector
 
7998
+       logical types in GPRs.
 
7999
+
 
8000
+       * config/rs6000/altivec.md (altivec_and<mode>3): Move 128-bit
 
8001
+       logical insns to rs6000.md, and allow TImode operations in
 
8002
+       32-bit.
 
8003
+       (altivec_ior<mode>3): Likewise.
 
8004
+       (altivec_xor<mode>3): Likewise.
 
8005
+       (altivec_one_cmpl<mode>2): Likewise.
 
8006
+       (altivec_nor<mode>3): Likewise.
 
8007
+       (altivec_andc<mode>3): Likewise.
 
8008
+
 
8009
+       * config/rs6000/rs6000.md (BOOL_128): New mode iterators and mode
 
8010
+       attributes for moving the 128-bit logical operations into
 
8011
+       rs6000.md.
 
8012
+       (BOOL_REGS_OUTPUT): Likewise.
 
8013
+       (BOOL_REGS_OP1): Likewise.
 
8014
+       (BOOL_REGS_OP2): Likewise.
 
8015
+       (BOOL_REGS_UNARY): Likewise.
 
8016
+       (BOOL_REGS_AND_CR0): Likewise.
 
8017
+       (one_cmpl<mode>2): Add support for DI logical operations on
 
8018
+       32-bit, splitting the operations to 32-bit.
 
8019
+       (anddi3): Likewise.
 
8020
+       (iordi3): Likewise.
 
8021
+       (xordi3): Likewise.
 
8022
+       (and<mode>3, 128-bit types): Rewrite 2013-06-06 logical operator
 
8023
+       changes to combine the 32/64-bit code, allow logical operations on
 
8024
+       TI mode in 32-bit, and to use similar match_operator patterns like
 
8025
+       scalar mode uses.  Combine the Altivec and VSX code for logical
 
8026
+       operations, and move it here.
 
8027
+       (ior<mode>3, 128-bit types): Likewise.
 
8028
+       (xor<mode>3, 128-bit types): Likewise.
 
8029
+       (one_cmpl<mode>3, 128-bit types): Likewise.
 
8030
+       (nor<mode>3, 128-bit types): Likewise.
 
8031
+       (andc<mode>3, 128-bit types): Likewise.
 
8032
+       (eqv<mode>3, 128-bit types): Likewise.
 
8033
+       (nand<mode>3, 128-bit types): Likewise.
 
8034
+       (orc<mode>3, 128-bit types): Likewise.
 
8035
+       (and<mode>3_internal): Likewise.
 
8036
+       (bool<mode>3_internal): Likewise.
 
8037
+       (boolc<mode>3_internal1): Likewise.
 
8038
+       (boolc<mode>3_internal2): Likewise.
 
8039
+       (boolcc<mode>3_internal1): Likewise.
 
8040
+       (boolcc<mode>3_internal2): Likewise.
 
8041
+       (eqv<mode>3_internal1): Likewise.
 
8042
+       (eqv<mode>3_internal2): Likewise.
 
8043
+       (one_cmpl1<mode>3_internal): Likewise.
 
8044
+
 
8045
+2013-07-31  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8046
+
 
8047
+       Backport from mainline
 
8048
+       2013-07-31  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8049
+
 
8050
+       * config/rs6000/predicates.md (fusion_gpr_addis): New predicates
 
8051
+       to support power8 load fusion.
 
8052
+       (fusion_gpr_mem_load): Likewise.
 
8053
+
 
8054
+       * config/rs6000/rs6000-modes.def (PTImode): Update a comment.
 
8055
+
 
8056
+       * config/rs6000/rs6000-protos.h (fusion_gpr_load_p): New
 
8057
+       declarations for power8 load fusion.
 
8058
+       (emit_fusion_gpr_load): Likewise.
 
8059
+
 
8060
+       * config/rs6000/rs6000.c (rs6000_option_override_internal): If
 
8061
+       tuning for power8, turn on fusion mode by default.  Turn on sign
 
8062
+       extending fusion mode if normal fusion mode is on, and we are at
 
8063
+       -O2 or -O3.
 
8064
+       (fusion_gpr_load_p): New function, return true if we can fuse an
 
8065
+       addis instruction with a dependent load to a GPR.
 
8066
+       (emit_fusion_gpr_load): Emit the instructions for power8 load
 
8067
+       fusion to GPRs.
 
8068
+
 
8069
+       * config/rs6000/vsx.md (VSX_M2): New iterator for fusion
 
8070
+       peepholes.
 
8071
+       (VSX load fusion peepholes): New peepholes to fuse together an
 
8072
+       addi instruction with a VSX load instruction.
 
8073
+
 
8074
+       * config/rs6000/rs6000.md (GPR load fusion peepholes): New
 
8075
+       peepholes to fuse an addis instruction with a load to a GPR base
 
8076
+       register.  If we are supporting sign extending fusions, convert
 
8077
+       sign extending loads to zero extending loads and add an explicit
 
8078
+       sign extension.
 
8079
+
 
8080
+2013-07-19  Pat Haugen <pthaugen@us.ibm.com>
 
8081
+
 
8082
+       Backport from mainline
 
8083
+       2013-07-18  Pat Haugen <pthaugen@us.ibm.com>
 
8084
+
 
8085
+       * config/rs6000/rs6000.c (rs6000_option_override_internal): Adjust flag
 
8086
+       interaction for new Power8 flags and VSX.
 
8087
+
 
8088
+2013-07-17  Peter Bergner  <bergner@vnet.ibm.com>
 
8089
+
 
8090
+       Backport from mainline
 
8091
+       2013-07-17  Iain Sandoe  <iain@codesourcery.com>
 
8092
+
 
8093
+       * config/rs6000/darwin.h (REGISTER_NAMES): Add HTM registers.
 
8094
+
 
8095
+2013-07-16  Peter Bergner  <bergner@vnet.ibm.com>
 
8096
+
 
8097
+       Merge up to 200989.
 
8098
+       * REVISION: Update subversion id.
 
8099
+
 
8100
+2013-07-16  Peter Bergner  <bergner@vnet.ibm.com>
 
8101
+
 
8102
+       Backport from mainline
 
8103
+       2013-07-16  Peter Bergner <bergner@vnet.ibm.com>
 
8104
+
 
8105
+       * config/rs6000/rs6000.c (rs6000_option_override_internal): Do not
 
8106
+       enable extra ISA flags with TARGET_HTM.
 
8107
+
 
8108
+       2013-07-16  Jakub Jelinek  <jakub@redhat.com>
 
8109
+                   Peter Bergner  <bergner@vnet.ibm.com>
 
8110
+
 
8111
+       * config/rs6000/rs6000.h (FIRST_PSEUDO_REGISTERS): Mention HTM
 
8112
+       registers in the comment.
 
8113
+       (DWARF_FRAME_REGISTERS): Subtract also the 3 HTM registers.
 
8114
+       (DWARF_REG_TO_UNWIND_COLUMN): Use DWARF_FRAME_REGISTERS
 
8115
+       rather than FIRST_PSEUDO_REGISTERS.
 
8116
+
 
8117
+2013-07-15  Peter Bergner  <bergner@vnet.ibm.com>
 
8118
+
 
8119
+       Backport from mainline
 
8120
+       2013-07-15  Peter Bergner  <bergner@vnet.ibm.com>
 
8121
+
 
8122
+       * config.gcc (powerpc*-*-*): Install htmintrin.h and htmxlintrin.h.
 
8123
+       * config/rs6000/t-rs6000 (MD_INCLUDES): Add htm.md.
 
8124
+       * config/rs6000/rs6000.opt: Add -mhtm option.
 
8125
+       * config/rs6000/rs6000-cpus.def (POWERPC_MASKS): Add OPTION_MASK_HTM.
 
8126
+       (ISA_2_7_MASKS_SERVER): Add OPTION_MASK_HTM.
 
8127
+       * config/rs6000/rs6000-c.c (rs6000_target_modify_macros): Define
 
8128
+       __HTM__ if the HTM instructions are available.
 
8129
+       * config/rs6000/predicates.md (u3bit_cint_operand, u10bit_cint_operand,
 
8130
+       htm_spr_reg_operand): New define_predicates.
 
8131
+       * config/rs6000/rs6000.md (define_attr "type"): Add htm.
 
8132
+       (TFHAR_REGNO, TFIAR_REGNO, TEXASR_REGNO): New define_constants.
 
8133
+       Include htm.md.
 
8134
+       * config/rs6000/rs6000-builtin.def (BU_HTM_0, BU_HTM_1, BU_HTM_2,
 
8135
+       BU_HTM_3, BU_HTM_SPR0, BU_HTM_SPR1): Add support macros for defining
 
8136
+       HTM builtin functions.
 
8137
+       * config/rs6000/rs6000.c (RS6000_BUILTIN_H): New macro.
 
8138
+       (rs6000_reg_names, alt_reg_names): Add HTM SPR register names.
 
8139
+       (rs6000_init_hard_regno_mode_ok): Add support for HTM instructions.
 
8140
+       (rs6000_builtin_mask_calculate): Likewise.
 
8141
+       (rs6000_option_override_internal): Likewise.
 
8142
+       (bdesc_htm): Add new HTM builtin support.
 
8143
+       (htm_spr_num): New function.
 
8144
+       (htm_spr_regno): Likewise.
 
8145
+       (rs6000_htm_spr_icode): Likewise.
 
8146
+       (htm_expand_builtin): Likewise.
 
8147
+       (htm_init_builtins): Likewise.
 
8148
+       (rs6000_expand_builtin): Add support for HTM builtin functions.
 
8149
+       (rs6000_init_builtins): Likewise.
 
8150
+       (rs6000_invalid_builtin, rs6000_opt_mask): Add support for -mhtm option.
 
8151
+       * config/rs6000/rs6000.h (ASM_CPU_SPEC): Add support for -mhtm.
 
8152
+       (TARGET_HTM, MASK_HTM): Define macros.
 
8153
+       (FIRST_PSEUDO_REGISTER): Adjust for new HTM SPR registers.
 
8154
+       (FIXED_REGISTERS): Likewise.
 
8155
+       (CALL_USED_REGISTERS): Likewise.
 
8156
+       (CALL_REALLY_USED_REGISTERS): Likewise.
 
8157
+       (REG_ALLOC_ORDER): Likewise.
 
8158
+       (enum reg_class): Likewise.
 
8159
+       (REG_CLASS_NAMES): Likewise.
 
8160
+       (REG_CLASS_CONTENTS): Likewise.
 
8161
+       (REGISTER_NAMES): Likewise.
 
8162
+       (ADDITIONAL_REGISTER_NAMES): Likewise.
 
8163
+       (RS6000_BTC_SPR, RS6000_BTC_VOID, RS6000_BTC_32BIT, RS6000_BTC_64BIT,
 
8164
+       RS6000_BTC_MISC_MASK, RS6000_BTM_HTM): New macros.
 
8165
+       (RS6000_BTM_COMMON): Add RS6000_BTM_HTM.
 
8166
+       * config/rs6000/htm.md: New file.
 
8167
+       * config/rs6000/htmintrin.h: New file.
 
8168
+       * config/rs6000/htmxlintrin.h: New file.
 
8169
+
 
8170
+2013-06-28  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8171
+
 
8172
+       Back port from the trunk
 
8173
+       2013-06-28  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8174
+
 
8175
+       PR target/57744
 
8176
+       * config/rs6000/rs6000.h (MODES_TIEABLE_P): Do not allow PTImode
 
8177
+       to tie with any other modes.  Eliminate Altivec vector mode tests,
 
8178
+       since these are a subset of ALTIVEC or VSX vector modes.  Simplify
 
8179
+       code, to return 0 if testing MODE2 for a condition, if we've
 
8180
+       already tested MODE1 for the same condition.
 
8181
+
 
8182
+2013-06-28  Pat Haugen <pthaugen@us.ibm.com>
 
8183
+
 
8184
+       * config/rs6000/rs6000.md (define_insn ""): Fix insn type.
 
8185
+
 
8186
+2013-06-26  Pat Haugen <pthaugen@us.ibm.com>
 
8187
+
 
8188
+       Back port from the trunk
 
8189
+       2013-06-26  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8190
+                   Pat Haugen <pthaugen@us.ibm.com>
 
8191
+                   Peter Bergner <bergner@vnet.ibm.com>
 
8192
+
 
8193
+       * config/rs6000/power8.md: New.
 
8194
+       * config/rs6000/rs6000-cpus.def (RS6000_CPU table): Adjust processor
 
8195
+       setting for power8 entry.
 
8196
+       * config/rs6000/t-rs6000 (MD_INCLUDES): Add power8.md.
 
8197
+       * config/rs6000/rs6000.c (is_microcoded_insn, is_cracked_insn): Adjust
 
8198
+       test for Power4/Power5 only.
 
8199
+       (insn_must_be_first_in_group, insn_must_be_last_in_group): Add Power8
 
8200
+       support.
 
8201
+       (force_new_group): Adjust comment.
 
8202
+       * config/rs6000/rs6000.md: Include power8.md.
 
8203
+
 
8204
+2013-06-14  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8205
+
 
8206
+       Back port from the trunk
 
8207
+       2013-06-14  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8208
+
 
8209
+       PR target/57615
 
8210
+       * config/rs6000/rs6000.md (mov<mode>_ppc64): Call
 
8211
+       rs6000_output_move_128bit to handle emitting quad memory
 
8212
+       operations.  Set attribute length to 8 bytes.
 
8213
+
 
8214
+2013-06-13  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8215
+
 
8216
+       Back port from the trunk
 
8217
+       2013-06-13  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8218
+
 
8219
+       * config/rs6000/rs6000.c (rs6000_option_override_internal): Move
 
8220
+       test for clearing quad memory on 32-bit later.
 
8221
+
 
8222
+2013-06-12  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8223
+
 
8224
+       Back port from the trunk
 
8225
+
 
8226
+       Backport from mainline
 
8227
+       2013-06-12  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8228
+                   Pat Haugen <pthaugen@us.ibm.com>
 
8229
+                   Peter Bergner <bergner@vnet.ibm.com>
 
8230
+
 
8231
+       * config/rs6000/rs6000.c (emit_load_locked): Add support for
 
8232
+       power8 byte, half-word, and quad-word atomic instructions.
 
8233
+       (emit_store_conditional): Likewise.
 
8234
+       (rs6000_expand_atomic_compare_and_swap): Likewise.
 
8235
+       (rs6000_expand_atomic_op): Likewise.
 
8236
+
 
8237
+       * config/rs6000/sync.md (larx): Add new modes for power8.
 
8238
+       (stcx): Likewise.
 
8239
+       (AINT): New mode iterator to include TImode as well as normal
 
8240
+       integer modes on power8.
 
8241
+       (fetchop_pred): Use int_reg_operand instead of gpc_reg_operand so
 
8242
+       that VSX registers are not considered.  Use AINT mode iterator
 
8243
+       instead of INT1 to allow inclusion of quad word atomic operations
 
8244
+       on power8.
 
8245
+       (load_locked<mode>): Likewise.
 
8246
+       (store_conditional<mode>): Likewise.
 
8247
+       (atomic_compare_and_swap<mode>): Likewise.
 
8248
+       (atomic_exchange<mode>): Likewise.
 
8249
+       (atomic_nand<mode>): Likewise.
 
8250
+       (atomic_fetch_<fetchop_name><mode>): Likewise.
 
8251
+       (atomic_nand_fetch<mode>): Likewise.
 
8252
+       (mem_thread_fence): Use gen_loadsync_<mode> instead of enumerating
 
8253
+       each type.
 
8254
+       (ATOMIC): On power8, add QImode, HImode modes.
 
8255
+       (load_locked<QHI:mode>_si): Varients of load_locked for QI/HI
 
8256
+       modes that promote to SImode.
 
8257
+       (load_lockedti): Convert TImode arguments to PTImode, so that we
 
8258
+       get a guaranteed even/odd register pair.
 
8259
+       (load_lockedpti): Likewise.
 
8260
+       (store_conditionalti): Likewise.
 
8261
+       (store_conditionalpti): Likewise.
 
8262
+
 
8263
+       * config/rs6000/rs6000.md (QHI): New mode iterator for power8
 
8264
+       atomic load/store instructions.
 
8265
+       (HSI): Likewise.
 
8266
+
 
8267
+2013-06-11  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8268
+
 
8269
+       Back port from the trunk
 
8270
+
 
8271
+       2013-06-11  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8272
+                   Pat Haugen <pthaugen@us.ibm.com>
 
8273
+                   Peter Bergner <bergner@vnet.ibm.com>
 
8274
+
 
8275
+       * config/rs6000/rs6000.c (emit_load_locked): Add support for
 
8276
+       power8 byte, half-word, and quad-word atomic instructions.
 
8277
+       (emit_store_conditional): Likewise.
 
8278
+       (rs6000_expand_atomic_compare_and_swap): Likewise.
 
8279
+       (rs6000_expand_atomic_op): Likewise.
 
8280
+
 
8281
+       * config/rs6000/sync.md (larx): Add new modes for power8.
 
8282
+       (stcx): Likewise.
 
8283
+       (AINT): New mode iterator to include TImode as well as normal
 
8284
+       integer modes on power8.
 
8285
+       (fetchop_pred): Use int_reg_operand instead of gpc_reg_operand so
 
8286
+       that VSX registers are not considered.  Use AINT mode iterator
 
8287
+       instead of INT1 to allow inclusion of quad word atomic operations
 
8288
+       on power8.
 
8289
+       (load_locked<mode>): Likewise.
 
8290
+       (store_conditional<mode>): Likewise.
 
8291
+       (atomic_compare_and_swap<mode>): Likewise.
 
8292
+       (atomic_exchange<mode>): Likewise.
 
8293
+       (atomic_nand<mode>): Likewise.
 
8294
+       (atomic_fetch_<fetchop_name><mode>): Likewise.
 
8295
+       (atomic_nand_fetch<mode>): Likewise.
 
8296
+       (mem_thread_fence): Use gen_loadsync_<mode> instead of enumerating
 
8297
+       each type.
 
8298
+       (ATOMIC): On power8, add QImode, HImode modes.
 
8299
+       (load_locked<QHI:mode>_si): Varients of load_locked for QI/HI
 
8300
+       modes that promote to SImode.
 
8301
+       (load_lockedti): Convert TImode arguments to PTImode, so that we
 
8302
+       get a guaranteed even/odd register pair.
 
8303
+       (load_lockedpti): Likewise.
 
8304
+       (store_conditionalti): Likewise.
 
8305
+       (store_conditionalpti): Likewise.
 
8306
+
 
8307
+       * config/rs6000/rs6000.md (QHI): New mode iterator for power8
 
8308
+       atomic load/store instructions.
 
8309
+       (HSI): Likewise.
 
8310
+
 
8311
+       PR target/57589
 
8312
+       * config/rs6000/driver-rs6000.c (elf_platform): Make buffer static
 
8313
+       to allow returning address to AT_PLATFORM name.
 
8314
+
 
8315
+       Back port from the trunk
 
8316
+
 
8317
+       2013-06-10  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8318
+                   Pat Haugen <pthaugen@us.ibm.com>
 
8319
+                   Peter Bergner <bergner@vnet.ibm.com>
 
8320
+
 
8321
+       * config/rs6000/vector.md (GPR move splitter): Do not split moves
 
8322
+       of vectors in GPRS if they are direct moves or quad word load or
 
8323
+       store moves.
 
8324
+
 
8325
+       * config/rs6000/rs6000-protos.h (rs6000_output_move_128bit): Add
 
8326
+       declaration.
 
8327
+       (direct_move_p): Likewise.
 
8328
+       (quad_load_store_p): Likewise.
 
8329
+
 
8330
+       * config/rs6000/rs6000.c (enum rs6000_reg_type): Simplify register
 
8331
+       classes into bins based on the physical register type.
 
8332
+       (reg_class_to_reg_type): Likewise.
 
8333
+       (IS_STD_REG_TYPE): Likewise.
 
8334
+       (IS_FP_VECT_REG_TYPE): Likewise.
 
8335
+       (reload_fpr_gpr): Arrays to determine what insn to use if we can
 
8336
+       use direct move instructions.
 
8337
+       (reload_gpr_vsx): Likewise.
 
8338
+       (reload_vsx_gpr): Likewise.
 
8339
+       (rs6000_init_hard_regno_mode_ok): Precalculate the register type
 
8340
+       information that is a simplification of register classes.  Also
 
8341
+       precalculate direct move reload helpers.
 
8342
+       (direct_move_p): New function to return true if the operation can
 
8343
+       be done as a direct move instruciton.
 
8344
+       (quad_load_store_p): New function to return true if the operation
 
8345
+       is a quad memory operation.
 
8346
+       (rs6000_legitimize_address): If quad memory, only allow register
 
8347
+       indirect for TImode addresses.
 
8348
+       (rs6000_legitimate_address_p): Likewise.
 
8349
+       (enum reload_reg_type): Delete, replace with rs6000_reg_type.
 
8350
+       (rs6000_reload_register_type): Likewise.
 
8351
+       (register_to_reg_type): Return register type.
 
8352
+       (rs6000_secondary_reload_simple_move): New helper function for
 
8353
+       secondary reload and secondary memory needed to identify anything
 
8354
+       that is a simple move, and does not need reloading.
 
8355
+       (rs6000_secondary_reload_direct_move): New helper function for
 
8356
+       secondary reload to identify cases that can be done with several
 
8357
+       instructions via the direct move instructions.
 
8358
+       (rs6000_secondary_reload_move): New helper function for secondary
 
8359
+       reload to identify moves between register types that can be done.
 
8360
+       (rs6000_secondary_reload): Add support for quad memory operations
 
8361
+       and for direct move.
 
8362
+       (rs6000_secondary_memory_needed): Likewise.
 
8363
+       (rs6000_debug_secondary_memory_needed): Change argument names.
 
8364
+       (rs6000_output_move_128bit): New function to return the move to
 
8365
+       use for 128-bit moves, including knowing about the various
 
8366
+       limitations of quad memory operations.
 
8367
+
 
8368
+       * config/rs6000/vsx.md (vsx_mov<mode>): Add support for quad
 
8369
+       memory operations.  call rs6000_output_move_128bit for the actual
 
8370
+       instruciton(s) to generate.
 
8371
+       (vsx_movti_64bit): Likewise.
 
8372
+
 
8373
+       * config/rs6000/rs6000.md (UNSPEC_P8V_FMRGOW): New unspec values.
 
8374
+       (UNSPEC_P8V_MTVSRWZ): Likewise.
 
8375
+       (UNSPEC_P8V_RELOAD_FROM_GPR): Likewise.
 
8376
+       (UNSPEC_P8V_MTVSRD): Likewise.
 
8377
+       (UNSPEC_P8V_XXPERMDI): Likewise.
 
8378
+       (UNSPEC_P8V_RELOAD_FROM_VSX): Likewise.
 
8379
+       (UNSPEC_FUSION_GPR): Likewise.
 
8380
+       (FMOVE128_GPR): New iterator for direct move.
 
8381
+       (f32_lv): New mode attribute for load/store of SFmode/SDmode
 
8382
+       values.
 
8383
+       (f32_sv): Likewise.
 
8384
+       (f32_dm): Likewise.
 
8385
+       (zero_extend<mode>di2_internal1): Add support for power8 32-bit
 
8386
+       loads and direct move instructions.
 
8387
+       (zero_extendsidi2_lfiwzx): Likewise.
 
8388
+       (extendsidi2_lfiwax): Likewise.
 
8389
+       (extendsidi2_nocell): Likewise.
 
8390
+       (floatsi<mode>2_lfiwax): Likewise.
 
8391
+       (lfiwax): Likewise.
 
8392
+       (floatunssi<mode>2_lfiwzx): Likewise.
 
8393
+       (lfiwzx): Likewise.
 
8394
+       (fix_trunc<mode>_stfiwx): Likewise.
 
8395
+       (fixuns_trunc<mode>_stfiwx): Likewise.
 
8396
+       (mov<mode>_hardfloat, 32-bit floating point): Likewise.
 
8397
+       (mov<move>_hardfloat64, 64-bit floating point): Likewise.
 
8398
+       (parity<mode>2_cmpb): Set length/type attr.
 
8399
+       (unnamed shift right patterns, mov<mode>_internal2): Change type attr
 
8400
+       for 'mr.' to fast_compare.
 
8401
+       (bpermd_<mode>): Change type attr to popcnt.
 
8402
+       (p8_fmrgow_<mode>): New insns for power8 direct move support.
 
8403
+       (p8_mtvsrwz_1): Likewise.
 
8404
+       (p8_mtvsrwz_2): Likewise.
 
8405
+       (reload_fpr_from_gpr<mode>): Likewise.
 
8406
+       (p8_mtvsrd_1): Likewise.
 
8407
+       (p8_mtvsrd_2): Likewise.
 
8408
+       (p8_xxpermdi_<mode>): Likewise.
 
8409
+       (reload_vsx_from_gpr<mode>): Likewise.
 
8410
+       (reload_vsx_from_gprsf): Likewise.
 
8411
+       (p8_mfvsrd_3_<mode>): LIkewise.
 
8412
+       (reload_gpr_from_vsx<mode>): Likewise.
 
8413
+       (reload_gpr_from_vsxsf): Likewise.
 
8414
+       (p8_mfvsrd_4_disf): Likewise.
 
8415
+       (multi-word GPR splits): Do not split direct moves or quad memory
 
8416
+       operations.
 
8417
+
 
8418
+2013-06-06  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8419
+
 
8420
+       Backport from the trunk
 
8421
+
 
8422
+       2013-06-06  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8423
+                   Pat Haugen <pthaugen@us.ibm.com>
 
8424
+                   Peter Bergner <bergner@vnet.ibm.com>
 
8425
+
 
8426
+       * doc/extend.texi (PowerPC AltiVec/VSX Built-in Functions):
 
8427
+       Document new power8 builtins.
 
8428
+
 
8429
+       * config/rs6000/vector.md (and<mode>3): Add a clobber/scratch of a
 
8430
+       condition code register, to allow 128-bit logical operations to be
 
8431
+       done in the VSX or GPR registers.
 
8432
+       (nor<mode>3): Use the canonical form for nor.
 
8433
+       (eqv<mode>3): Add expanders for power8 xxleqv, xxlnand, xxlorc,
 
8434
+       vclz*, and vpopcnt* vector instructions.
 
8435
+       (nand<mode>3): Likewise.
 
8436
+       (orc<mode>3): Likewise.
 
8437
+       (clz<mode>2): LIkewise.
 
8438
+       (popcount<mode>2): Likewise.
 
8439
+
 
8440
+       * config/rs6000/predicates.md (int_reg_operand): Rework tests so
 
8441
+       that only the GPRs are recognized.
 
8442
+
 
8443
+       * config/rs6000/rs6000-c.c (altivec_overloaded_builtins): Add
 
8444
+       support for new power8 builtins.
 
8445
+
 
8446
+       * config/rs6000/rs6000-builtin.def (xscvspdpn): Add new power8
 
8447
+       builtin functions.
 
8448
+       (xscvdpspn): Likewise.
 
8449
+       (vclz): Likewise.
 
8450
+       (vclzb): Likewise.
 
8451
+       (vclzh): Likewise.
 
8452
+       (vclzw): Likewise.
 
8453
+       (vclzd): Likewise.
 
8454
+       (vpopcnt): Likewise.
 
8455
+       (vpopcntb): Likewise.
 
8456
+       (vpopcnth): Likewise.
 
8457
+       (vpopcntw): Likewise.
 
8458
+       (vpopcntd): Likewise.
 
8459
+       (vgbbd): Likewise.
 
8460
+       (vmrgew): Likewise.
 
8461
+       (vmrgow): Likewise.
 
8462
+       (eqv): Likewise.
 
8463
+       (eqv_v16qi3): Likewise.
 
8464
+       (eqv_v8hi3): Likewise.
 
8465
+       (eqv_v4si3): Likewise.
 
8466
+       (eqv_v2di3): Likewise.
 
8467
+       (eqv_v4sf3): Likewise.
 
8468
+       (eqv_v2df3): Likewise.
 
8469
+       (nand): Likewise.
 
8470
+       (nand_v16qi3): Likewise.
 
8471
+       (nand_v8hi3): Likewise.
 
8472
+       (nand_v4si3): Likewise.
 
8473
+       (nand_v2di3): Likewise.
 
8474
+       (nand_v4sf3): Likewise.
 
8475
+       (nand_v2df3): Likewise.
 
8476
+       (orc): Likewise.
 
8477
+       (orc_v16qi3): Likewise.
 
8478
+       (orc_v8hi3): Likewise.
 
8479
+       (orc_v4si3): Likewise.
 
8480
+       (orc_v2di3): Likewise.
 
8481
+       (orc_v4sf3): Likewise.
 
8482
+       (orc_v2df3): Likewise.
 
8483
+
 
8484
+       * config/rs6000/rs6000.c (rs6000_option_override_internal): Only
 
8485
+       allow power8 quad mode in 64-bit.
 
8486
+       (rs6000_builtin_vectorized_function): Add support to vectorize
 
8487
+       ISA 2.07 count leading zeros, population count builtins.
 
8488
+       (rs6000_expand_vector_init): On ISA 2.07 use xscvdpspn to form
 
8489
+       V4SF vectors instead of xscvdpsp to avoid IEEE related traps.
 
8490
+       (builtin_function_type): Add vgbbd builtin function which takes an
 
8491
+       unsigned argument.
 
8492
+       (altivec_expand_vec_perm_const): Add support for new power8 merge
 
8493
+       instructions.
 
8494
+
 
8495
+       * config/rs6000/vsx.md (VSX_L2): New iterator for 128-bit types,
 
8496
+       that does not include TImdoe for use with 32-bit.
 
8497
+       (UNSPEC_VSX_CVSPDPN): Support for power8 xscvdpspn and xscvspdpn
 
8498
+       instructions.
 
8499
+       (UNSPEC_VSX_CVDPSPN): Likewise.
 
8500
+       (vsx_xscvdpspn): Likewise.
 
8501
+       (vsx_xscvspdpn): Likewise.
 
8502
+       (vsx_xscvdpspn_scalar): Likewise.
 
8503
+       (vsx_xscvspdpn_directmove): Likewise.
 
8504
+       (vsx_and<mode>3): Split logical operations into 32-bit and
 
8505
+       64-bit. Add support to do logical operations on TImode as well as
 
8506
+       VSX vector types.  Allow logical operations to be done in either
 
8507
+       VSX registers or in general purpose registers in 64-bit mode.  Add
 
8508
+       splitters if GPRs were used. For AND, add clobber of CCmode to
 
8509
+       allow use of ANDI on GPRs.  Rewrite nor to use the canonical RTL
 
8510
+       encoding.
 
8511
+       (vsx_and<mode>3_32bit): Likewise.
 
8512
+       (vsx_and<mode>3_64bit): Likewise.
 
8513
+       (vsx_ior<mode>3): Likewise.
 
8514
+       (vsx_ior<mode>3_32bit): Likewise.
 
8515
+       (vsx_ior<mode>3_64bit): Likewise.
 
8516
+       (vsx_xor<mode>3): Likewise.
 
8517
+       (vsx_xor<mode>3_32bit): Likewise.
 
8518
+       (vsx_xor<mode>3_64bit): Likewise.
 
8519
+       (vsx_one_cmpl<mode>2): Likewise.
 
8520
+       (vsx_one_cmpl<mode>2_32bit): Likewise.
 
8521
+       (vsx_one_cmpl<mode>2_64bit): Likewise.
 
8522
+       (vsx_nor<mode>3): Likewise.
 
8523
+       (vsx_nor<mode>3_32bit): Likewise.
 
8524
+       (vsx_nor<mode>3_64bit): Likewise.
 
8525
+       (vsx_andc<mode>3): Likewise.
 
8526
+       (vsx_andc<mode>3_32bit): Likewise.
 
8527
+       (vsx_andc<mode>3_64bit): Likewise.
 
8528
+       (vsx_eqv<mode>3_32bit): Add support for power8 xxleqv, xxlnand,
 
8529
+       and xxlorc instructions.
 
8530
+       (vsx_eqv<mode>3_64bit): Likewise.
 
8531
+       (vsx_nand<mode>3_32bit): Likewise.
 
8532
+       (vsx_nand<mode>3_64bit): Likewise.
 
8533
+       (vsx_orc<mode>3_32bit): Likewise.
 
8534
+       (vsx_orc<mode>3_64bit): Likewise.
 
8535
+
 
8536
+       * config/rs6000/rs6000.h (VLOGICAL_REGNO_P): Update comment.
 
8537
+
 
8538
+       * config/rs6000/altivec.md (UNSPEC_VGBBD): Add power8 vgbbd
 
8539
+       instruction.
 
8540
+       (p8_vmrgew): Add power8 vmrgew and vmrgow instructions.
 
8541
+       (p8_vmrgow): Likewise.
 
8542
+       (altivec_and<mode>3): Add clobber of CCmode to allow AND using
 
8543
+       GPRs to be split under VSX.
 
8544
+       (p8v_clz<mode>2): Add power8 count leading zero support.
 
8545
+       (p8v_popcount<mode>2): Add power8 population count support.
 
8546
+       (p8v_vgbbd): Add power8 gather bits by bytes by doubleword
 
8547
+       support.
 
8548
+
 
8549
+       * config/rs6000/rs6000.md (eqv<mode>3): Add support for powerp eqv
 
8550
+       instruction.
 
8551
+
 
8552
+       * config/rs6000/altivec.h (vec_eqv): Add defines to export power8
 
8553
+       builtin functions.
 
8554
+       (vec_nand): Likewise.
 
8555
+       (vec_vclz): Likewise.
 
8556
+       (vec_vclzb): Likewise.
 
8557
+       (vec_vclzd): Likewise.
 
8558
+       (vec_vclzh): Likewise.
 
8559
+       (vec_vclzw): Likewise.
 
8560
+       (vec_vgbbd): Likewise.
 
8561
+       (vec_vmrgew): Likewise.
 
8562
+       (vec_vmrgow): Likewise.
 
8563
+       (vec_vpopcnt): Likewise.
 
8564
+       (vec_vpopcntb): Likewise.
 
8565
+       (vec_vpopcntd): Likewise.
 
8566
+       (vec_vpopcnth): Likewise.
 
8567
+       (vec_vpopcntw): Likewise.
 
8568
+
 
8569
+2013-06-06  Peter Bergner  <bergner@vnet.ibm.com>
 
8570
+
 
8571
+       Merge up to 199753.
 
8572
+       * REVISION: Update subversion id.
 
8573
+
 
8574
+2013-06-06  Peter Bergner  <bergner@vnet.ibm.com>
 
8575
+
 
8576
+       Backport from trunk
 
8577
+
 
8578
+       2013-05-29  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8579
+                   Pat Haugen <pthaugen@us.ibm.com>
 
8580
+                   Peter Bergner <bergner@vnet.ibm.com>
 
8581
+
 
8582
+       * config/rs6000/vector.md (VEC_I): Add support for new power8 V2DI
 
8583
+       instructions.
 
8584
+       (VEC_A): Likewise.
 
8585
+       (VEC_C): Likewise.
 
8586
+       (vrotl<mode>3): Likewise.
 
8587
+       (vashl<mode>3): Likewise.
 
8588
+       (vlshr<mode>3): Likewise.
 
8589
+       (vashr<mode>3): Likewise.
 
8590
+
 
8591
+       * config/rs6000/rs6000-c.c (altivec_overloaded_builtins): Add
 
8592
+       support for power8 V2DI builtins.
 
8593
+
 
8594
+       * config/rs6000/rs6000-builtin.def (abs_v2di): Add support for
 
8595
+       power8 V2DI builtins.
 
8596
+       (vupkhsw): Likewise.
 
8597
+       (vupklsw): Likewise.
 
8598
+       (vaddudm): Likewise.
 
8599
+       (vminsd): Likewise.
 
8600
+       (vmaxsd): Likewise.
 
8601
+       (vminud): Likewise.
 
8602
+       (vmaxud): Likewise.
 
8603
+       (vpkudum): Likewise.
 
8604
+       (vpksdss): Likewise.
 
8605
+       (vpkudus): Likewise.
 
8606
+       (vpksdus): Likewise.
 
8607
+       (vrld): Likewise.
 
8608
+       (vsld): Likewise.
 
8609
+       (vsrd): Likewise.
 
8610
+       (vsrad): Likewise.
 
8611
+       (vsubudm): Likewise.
 
8612
+       (vcmpequd): Likewise.
 
8613
+       (vcmpgtsd): Likewise.
 
8614
+       (vcmpgtud): Likewise.
 
8615
+       (vcmpequd_p): Likewise.
 
8616
+       (vcmpgtsd_p): Likewise.
 
8617
+       (vcmpgtud_p): Likewise.
 
8618
+       (vupkhsw): Likewise.
 
8619
+       (vupklsw): Likewise.
 
8620
+       (vaddudm): Likewise.
 
8621
+       (vmaxsd): Likewise.
 
8622
+       (vmaxud): Likewise.
 
8623
+       (vminsd): Likewise.
 
8624
+       (vminud): Likewise.
 
8625
+       (vpksdss): Likewise.
 
8626
+       (vpksdus): Likewise.
 
8627
+       (vpkudum): Likewise.
 
8628
+       (vpkudus): Likewise.
 
8629
+       (vrld): Likewise.
 
8630
+       (vsld): Likewise.
 
8631
+       (vsrad): Likewise.
 
8632
+       (vsrd): Likewise.
 
8633
+       (vsubudm): Likewise.
 
8634
+
 
8635
+       * config/rs6000/rs6000.c (rs6000_init_hard_regno_mode_ok): Add
 
8636
+       support for power8 V2DI instructions.
 
8637
+
 
8638
+       * config/rs6000/altivec.md (UNSPEC_VPKUHUM): Add support for
 
8639
+       power8 V2DI instructions.  Combine pack and unpack insns to use an
 
8640
+       iterator for each mode.  Check whether a particular mode supports
 
8641
+       Altivec instructions instead of just checking TARGET_ALTIVEC.
 
8642
+       (UNSPEC_VPKUWUM): Likewise.
 
8643
+       (UNSPEC_VPKSHSS): Likewise.
 
8644
+       (UNSPEC_VPKSWSS): Likewise.
 
8645
+       (UNSPEC_VPKUHUS): Likewise.
 
8646
+       (UNSPEC_VPKSHUS): Likewise.
 
8647
+       (UNSPEC_VPKUWUS): Likewise.
 
8648
+       (UNSPEC_VPKSWUS): Likewise.
 
8649
+       (UNSPEC_VPACK_SIGN_SIGN_SAT): Likewise.
 
8650
+       (UNSPEC_VPACK_SIGN_UNS_SAT): Likewise.
 
8651
+       (UNSPEC_VPACK_UNS_UNS_SAT): Likewise.
 
8652
+       (UNSPEC_VPACK_UNS_UNS_MOD): Likewise.
 
8653
+       (UNSPEC_VUPKHSB): Likewise.
 
8654
+       (UNSPEC_VUNPACK_HI_SIGN): Likewise.
 
8655
+       (UNSPEC_VUNPACK_LO_SIGN): Likewise.
 
8656
+       (UNSPEC_VUPKHSH): Likewise.
 
8657
+       (UNSPEC_VUPKLSB): Likewise.
 
8658
+       (UNSPEC_VUPKLSH): Likewise.
 
8659
+       (VI2): Likewise.
 
8660
+       (VI_char): Likewise.
 
8661
+       (VI_scalar): Likewise.
 
8662
+       (VI_unit): Likewise.
 
8663
+       (VP): Likewise.
 
8664
+       (VP_small): Likewise.
 
8665
+       (VP_small_lc): Likewise.
 
8666
+       (VU_char): Likewise.
 
8667
+       (add<mode>3): Likewise.
 
8668
+       (altivec_vaddcuw): Likewise.
 
8669
+       (altivec_vaddu<VI_char>s): Likewise.
 
8670
+       (altivec_vadds<VI_char>s): Likewise.
 
8671
+       (sub<mode>3): Likewise.
 
8672
+       (altivec_vsubcuw): Likewise.
 
8673
+       (altivec_vsubu<VI_char>s): Likewise.
 
8674
+       (altivec_vsubs<VI_char>s): Likewise.
 
8675
+       (altivec_vavgs<VI_char>): Likewise.
 
8676
+       (altivec_vcmpbfp): Likewise.
 
8677
+       (altivec_eq<mode>): Likewise.
 
8678
+       (altivec_gt<mode>): Likewise.
 
8679
+       (altivec_gtu<mode>): Likewise.
 
8680
+       (umax<mode>3): Likewise.
 
8681
+       (smax<mode>3): Likewise.
 
8682
+       (umin<mode>3): Likewise.
 
8683
+       (smin<mode>3): Likewise.
 
8684
+       (altivec_vpkuhum): Likewise.
 
8685
+       (altivec_vpkuwum): Likewise.
 
8686
+       (altivec_vpkshss): Likewise.
 
8687
+       (altivec_vpkswss): Likewise.
 
8688
+       (altivec_vpkuhus): Likewise.
 
8689
+       (altivec_vpkshus): Likewise.
 
8690
+       (altivec_vpkuwus): Likewise.
 
8691
+       (altivec_vpkswus): Likewise.
 
8692
+       (altivec_vpks<VI_char>ss): Likewise.
 
8693
+       (altivec_vpks<VI_char>us): Likewise.
 
8694
+       (altivec_vpku<VI_char>us): Likewise.
 
8695
+       (altivec_vpku<VI_char>um): Likewise.
 
8696
+       (altivec_vrl<VI_char>): Likewise.
 
8697
+       (altivec_vsl<VI_char>): Likewise.
 
8698
+       (altivec_vsr<VI_char>): Likewise.
 
8699
+       (altivec_vsra<VI_char>): Likewise.
 
8700
+       (altivec_vsldoi_<mode>): Likewise.
 
8701
+       (altivec_vupkhsb): Likewise.
 
8702
+       (altivec_vupkhs<VU_char>): Likewise.
 
8703
+       (altivec_vupkls<VU_char>): Likewise.
 
8704
+       (altivec_vupkhsh): Likewise.
 
8705
+       (altivec_vupklsb): Likewise.
 
8706
+       (altivec_vupklsh): Likewise.
 
8707
+       (altivec_vcmpequ<VI_char>_p): Likewise.
 
8708
+       (altivec_vcmpgts<VI_char>_p): Likewise.
 
8709
+       (altivec_vcmpgtu<VI_char>_p): Likewise.
 
8710
+       (abs<mode>2): Likewise.
 
8711
+       (vec_unpacks_hi_v16qi): Likewise.
 
8712
+       (vec_unpacks_hi_v8hi): Likewise.
 
8713
+       (vec_unpacks_lo_v16qi): Likewise.
 
8714
+       (vec_unpacks_hi_<VP_small_lc>): Likewise.
 
8715
+       (vec_unpacks_lo_v8hi): Likewise.
 
8716
+       (vec_unpacks_lo_<VP_small_lc>): Likewise.
 
8717
+       (vec_pack_trunc_v8h): Likewise.
 
8718
+       (vec_pack_trunc_v4si): Likewise.
 
8719
+       (vec_pack_trunc_<mode>): Likewise.
 
8720
+
 
8721
+       * config/rs6000/altivec.h (vec_vaddudm): Add defines for power8
 
8722
+       V2DI builtins.
 
8723
+       (vec_vmaxsd): Likewise.
 
8724
+       (vec_vmaxud): Likewise.
 
8725
+       (vec_vminsd): Likewise.
 
8726
+       (vec_vminud): Likewise.
 
8727
+       (vec_vpksdss): Likewise.
 
8728
+       (vec_vpksdus): Likewise.
 
8729
+       (vec_vpkudum): Likewise.
 
8730
+       (vec_vpkudus): Likewise.
 
8731
+       (vec_vrld): Likewise.
 
8732
+       (vec_vsld): Likewise.
 
8733
+       (vec_vsrad): Likewise.
 
8734
+       (vec_vsrd): Likewise.
 
8735
+       (vec_vsubudm): Likewise.
 
8736
+       (vec_vupkhsw): Likewise.
 
8737
+       (vec_vupklsw): Likewise.
 
8738
+
 
8739
+       2013-05-22  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8740
+                   Pat Haugen <pthaugen@us.ibm.com>
 
8741
+                   Peter Bergner <bergner@vnet.ibm.com>
 
8742
+
 
8743
+       * doc/extend.texi (PowerPC AltiVec/VSX Built-in Functions): Add
 
8744
+       documentation for the power8 crypto builtins.
 
8745
+
 
8746
+       * config/rs6000/t-rs6000 (MD_INCLUDES): Add crypto.md.
 
8747
+
 
8748
+       * config/rs6000/rs6000-builtin.def (BU_P8V_AV_1): Add support
 
8749
+       macros for defining power8 builtin functions.
 
8750
+       (BU_P8V_AV_2): Likewise.
 
8751
+       (BU_P8V_AV_P): Likewise.
 
8752
+       (BU_P8V_VSX_1): Likewise.
 
8753
+       (BU_P8V_OVERLOAD_1): Likewise.
 
8754
+       (BU_P8V_OVERLOAD_2): Likewise.
 
8755
+       (BU_CRYPTO_1): Likewise.
 
8756
+       (BU_CRYPTO_2): Likewise.
 
8757
+       (BU_CRYPTO_3): Likewise.
 
8758
+       (BU_CRYPTO_OVERLOAD_1): Likewise.
 
8759
+       (BU_CRYPTO_OVERLOAD_2): Likewise.
 
8760
+       (XSCVSPDP): Fix typo, point to the correct instruction.
 
8761
+       (VCIPHER): Add power8 crypto builtins.
 
8762
+       (VCIPHERLAST): Likewise.
 
8763
+       (VNCIPHER): Likewise.
 
8764
+       (VNCIPHERLAST): Likewise.
 
8765
+       (VPMSUMB): Likewise.
 
8766
+       (VPMSUMH): Likewise.
 
8767
+       (VPMSUMW): Likewise.
 
8768
+       (VPERMXOR_V2DI): Likewise.
 
8769
+       (VPERMXOR_V4SI: Likewise.
 
8770
+       (VPERMXOR_V8HI: Likewise.
 
8771
+       (VPERMXOR_V16QI: Likewise.
 
8772
+       (VSHASIGMAW): Likewise.
 
8773
+       (VSHASIGMAD): Likewise.
 
8774
+       (VPMSUM): Likewise.
 
8775
+       (VPERMXOR): Likewise.
 
8776
+       (VSHASIGMA): Likewise.
 
8777
+
 
8778
+       * config/rs6000/rs6000-c.c (rs6000_target_modify_macros): Define
 
8779
+       __CRYPTO__ if the crypto instructions are available.
 
8780
+       (altivec_overloaded_builtins): Add support for overloaded power8
 
8781
+       builtins.
 
8782
+
 
8783
+       * config/rs6000/rs6000.c (rs6000_expand_ternop_builtin): Add
 
8784
+       support for power8 crypto builtins.
 
8785
+       (builtin_function_type): Likewise.
 
8786
+       (altivec_init_builtins): Add support for builtins that take vector
 
8787
+       long long (V2DI) arguments.
 
8788
+
 
8789
+       * config/rs6000/crypto.md: New file, define power8 crypto
 
8790
+       instructions.
 
8791
+
 
8792
+       2013-05-22  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8793
+                   Pat Haugen <pthaugen@us.ibm.com>
 
8794
+                   Peter Bergner <bergner@vnet.ibm.com>
 
8795
+
 
8796
+       * doc/invoke.texi (Option Summary): Add power8 options.
 
8797
+       (RS/6000 and PowerPC Options): Likewise.
 
8798
+
 
8799
+       * doc/md.texi (PowerPC and IBM RS6000 constraints): Update to use
 
8800
+       constraints.md instead of rs6000.h.  Reorder w* constraints.  Add
 
8801
+       wm, wn, wr documentation.
 
8802
+
 
8803
+       * gcc/config/rs6000/constraints.md (wm): New constraint for VSX
 
8804
+       registers if direct move instructions are enabled.
 
8805
+       (wn): New constraint for no registers.
 
8806
+       (wq): New constraint for quad word even GPR registers.
 
8807
+       (wr): New constraint if 64-bit instructions are enabled.
 
8808
+       (wv): New constraint if power8 vector instructions are enabled.
 
8809
+       (wQ): New constraint for quad word memory locations.
 
8810
+
 
8811
+       * gcc/config/rs6000/predicates.md (const_0_to_15_operand): New
 
8812
+       constraint for 0..15 for crypto instructions.
 
8813
+       (gpc_reg_operand): If VSX allow registers in VSX registers as well
 
8814
+       as GPR and floating point registers.
 
8815
+       (int_reg_operand): New predicate to match only GPR registers.
 
8816
+       (base_reg_operand): New predicate to match base registers.
 
8817
+       (quad_int_reg_operand): New predicate to match even GPR registers
 
8818
+       for quad memory operations.
 
8819
+       (vsx_reg_or_cint_operand): New predicate to allow vector logical
 
8820
+       operations in both GPR and VSX registers.
 
8821
+       (quad_memory_operand): New predicate for quad memory operations.
 
8822
+       (reg_or_indexed_operand): New predicate for direct move support.
 
8823
+
 
8824
+       * gcc/config/rs6000/rs6000-cpus.def (ISA_2_5_MASKS_EMBEDDED):
 
8825
+       Inherit from ISA_2_4_MASKS, not ISA_2_2_MASKS.
 
8826
+       (ISA_2_7_MASKS_SERVER): New mask for ISA 2.07 (i.e. power8).
 
8827
+       (POWERPC_MASKS): Add power8 options.
 
8828
+       (power8 cpu): Use ISA_2_7_MASKS_SERVER instead of specifying the
 
8829
+       various options.
 
8830
+
 
8831
+       * gcc/config/rs6000/rs6000-c.c (rs6000_target_modify_macros):
 
8832
+       Define _ARCH_PWR8 and __POWER8_VECTOR__ for power8.
 
8833
+
 
8834
+       * gcc/config/rs6000/rs6000.opt (-mvsx-timode): Add documentation.
 
8835
+       (-mpower8-fusion): New power8 options.
 
8836
+       (-mpower8-fusion-sign): Likewise.
 
8837
+       (-mpower8-vector): Likewise.
 
8838
+       (-mcrypto): Likewise.
 
8839
+       (-mdirect-move): Likewise.
 
8840
+       (-mquad-memory): Likewise.
 
8841
+
 
8842
+       * gcc/config/rs6000/rs6000.c (power8_cost): Initial definition for
 
8843
+       power8.
 
8844
+       (rs6000_hard_regno_mode_ok): Make PTImode only match even GPR
 
8845
+       registers.
 
8846
+       (rs6000_debug_reg_print): Print the base register class if
 
8847
+       -mdebug=reg.
 
8848
+       (rs6000_debug_vector_unit): Add p8_vector.
 
8849
+       (rs6000_debug_reg_global): If -mdebug=reg, print power8 constraint
 
8850
+       definitions.  Also print fusion state.
 
8851
+       (rs6000_init_hard_regno_mode_ok): Set up power8 constraints.
 
8852
+       (rs6000_builtin_mask_calculate): Add power8 builtin support.
 
8853
+       (rs6000_option_override_internal): Add support for power8.
 
8854
+       (rs6000_common_init_builtins): Add debugging for skipped builtins
 
8855
+       if -mdebug=builtin.
 
8856
+       (rs6000_adjust_cost): Add power8 support.
 
8857
+       (rs6000_issue_rate): Likewise.
 
8858
+       (insn_must_be_first_in_group): Likewise.
 
8859
+       (insn_must_be_last_in_group): Likewise.
 
8860
+       (force_new_group): Likewise.
 
8861
+       (rs6000_register_move_cost): Likewise.
 
8862
+       (rs6000_opt_masks): Likewise.
 
8863
+
 
8864
+       * config/rs6000/rs6000.h (ASM_CPU_POWER8_SPEC): If we don't have a
 
8865
+       power8 capable assembler, default to power7 options.
 
8866
+       (TARGET_DIRECT_MOVE): Likewise.
 
8867
+       (TARGET_CRYPTO): Likewise.
 
8868
+       (TARGET_P8_VECTOR): Likewise.
 
8869
+       (VECTOR_UNIT_P8_VECTOR_P): Define power8 vector support.
 
8870
+       (VECTOR_UNIT_VSX_OR_P8_VECTOR_P): Likewise.
 
8871
+       (VECTOR_MEM_P8_VECTOR_P): Likewise.
 
8872
+       (VECTOR_MEM_VSX_OR_P8_VECTOR_P): Likewise.
 
8873
+       (VECTOR_MEM_ALTIVEC_OR_VSX_P): Likewise.
 
8874
+       (TARGET_XSCVDPSPN): Likewise.
 
8875
+       (TARGET_XSCVSPDPN): Likewsie.
 
8876
+       (TARGET_SYNC_HI_QI): Likewise.
 
8877
+       (TARGET_SYNC_TI): Likewise.
 
8878
+       (MASK_CRYPTO): Likewise.
 
8879
+       (MASK_DIRECT_MOVE): Likewise.
 
8880
+       (MASK_P8_FUSION): Likewise.
 
8881
+       (MASK_P8_VECTOR): Likewise.
 
8882
+       (REG_ALLOC_ORDER): Move fr13 to be lower in priority so that the
 
8883
+       TFmode temporary used by some of the direct move instructions to
 
8884
+       get two FP temporary registers does not force creation of a stack
 
8885
+       frame.
 
8886
+       (VLOGICAL_REGNO_P): Allow vector logical operations in GPRs.
 
8887
+       (MODES_TIEABLE_P): Move the VSX tests above the Altivec tests so
 
8888
+       that any VSX registers are tieable, even if they are also an
 
8889
+       Altivec vector mode.
 
8890
+       (r6000_reg_class_enum): Add wm, wr, wv constraints.
 
8891
+       (RS6000_BTM_P8_VECTOR): Power8 builtin support.
 
8892
+       (RS6000_BTM_CRYPTO): Likewise.
 
8893
+       (RS6000_BTM_COMMON): Likewise.
 
8894
+
 
8895
+       * config/rs6000/rs6000.md (cpu attribute): Add power8.
 
8896
+       * config/rs6000/rs6000-opts.h (PROCESSOR_POWER8): Likewise.
 
8897
+       (enum rs6000_vector): Add power8 vector support.
 
8898
+
 
8899
+2013-05-06  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8900
+
 
8901
+       Merge up to 198656.
 
8902
+       * REVISION: Update subversion id.
 
8903
+
 
8904
+       Backport from trunk
 
8905
+       2013-05-03  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8906
+
 
8907
+       PR target/57150
 
8908
+       * config/rs6000/rs6000.h (HARD_REGNO_CALLER_SAVE_MODE): Use DFmode
 
8909
+       to save TFmode registers and DImode to save TImode registers for
 
8910
+       caller save operations.
 
8911
+       (HARD_REGNO_CALL_PART_CLOBBERED): TFmode and TDmode do not need to
 
8912
+       mark being partially clobbered since they only use the first
 
8913
+       double word.
 
8914
+
 
8915
+       * config/rs6000/rs6000.c (rs6000_init_hard_regno_mode_ok): TFmode
 
8916
+       and TDmode only use the upper 64-bits of each VSX register.
 
8917
+
 
8918
+2013-04-09  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8919
+
 
8920
+       Merge up to 197642.
 
8921
+       * REVISION: Update subversion id.
 
8922
+
 
8923
+2013-03-20  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8924
+
 
8925
+       Backport from mainline
 
8926
+       2013-03-20  Pat Haugen <pthaugen@us.ibm.com>
 
8927
+
 
8928
+       * config/rs6000/predicates.md (indexed_address, update_address_mem
 
8929
+       update_indexed_address_mem): New predicates.
 
8930
+       * config/rs6000/vsx.md (vsx_extract_<mode>_zero): Set correct "type"
 
8931
+       attribute for load/store instructions.
 
8932
+       * config/rs6000/dfp.md (movsd_store): Likewise.
 
8933
+       (movsd_load): Likewise.
 
8934
+       * config/rs6000/rs6000.md (zero_extend<mode>di2_internal1): Likewise.
 
8935
+       (unnamed HI->DI extend define_insn): Likewise.
 
8936
+       (unnamed SI->DI extend define_insn): Likewise.
 
8937
+       (unnamed QI->SI extend define_insn): Likewise.
 
8938
+       (unnamed QI->HI extend define_insn): Likewise.
 
8939
+       (unnamed HI->SI extend define_insn): Likewise.
 
8940
+       (unnamed HI->SI extend define_insn): Likewise.
 
8941
+       (extendsfdf2_fpr): Likewise.
 
8942
+       (movsi_internal1): Likewise.
 
8943
+       (movsi_internal1_single): Likewise.
 
8944
+       (movhi_internal): Likewise.
 
8945
+       (movqi_internal): Likewise.
 
8946
+       (movcc_internal1): Correct mnemonic for stw insn. Set correct "type"
 
8947
+       attribute for load/store instructions.
 
8948
+       (mov<mode>_hardfloat): Set correct "type" attribute for load/store
 
8949
+       instructions.
 
8950
+       (mov<mode>_softfloat): Likewise.
 
8951
+       (mov<mode>_hardfloat32): Likewise.
 
8952
+       (mov<mode>_hardfloat64): Likewise.
 
8953
+       (mov<mode>_softfloat64): Likewise.
 
8954
+       (movdi_internal32): Likewise.
 
8955
+       (movdi_internal64): Likewise.
 
8956
+       (probe_stack_<mode>): Likewise.
 
8957
+
 
8958
+       Backport from mainline
 
8959
+       2013-03-20  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
8960
+
 
8961
+       * config/rs6000/vector.md (VEC_R): Add 32-bit integer, binary
 
8962
+       floating point, and decimal floating point to reload iterator.
 
8963
+
 
8964
+       * config/rs6000/constraints.md (wl constraint): New constraints to
 
8965
+       return FLOAT_REGS if certain options are used to reduce the number
 
8966
+       of separate patterns that exist in the file.
 
8967
+       (wx constraint): Likewise.
 
8968
+       (wz constraint): Likewise.
 
8969
+
 
8970
+       * config/rs6000/rs6000.c (rs6000_debug_reg_global): If
 
8971
+       -mdebug=reg, print wg, wl, wx, and wz constraints.
 
8972
+       (rs6000_init_hard_regno_mode_ok): Initialize new constraints.
 
8973
+       Initialize the reload functions for 64-bit binary/decimal floating
 
8974
+       point types.
 
8975
+       (reg_offset_addressing_ok_p): If we are on a power7 or later, use
 
8976
+       LFIWZX and STFIWX to load/store 32-bit decimal types, and don't
 
8977
+       create the buffer on the stack to overcome not having a 32-bit
 
8978
+       load and store.
 
8979
+       (rs6000_emit_move): Likewise.
 
8980
+       (rs6000_secondary_memory_needed_rtx): Likewise.
 
8981
+       (rs6000_alloc_sdmode_stack_slot): Likewise.
 
8982
+       (rs6000_preferred_reload_class): On VSX, we can create SFmode 0.0f
 
8983
+       via xxlxor, just like DFmode 0.0.
 
8984
+
 
8985
+       * config/rs6000/rs6000.h (TARGET_NO_SDMODE_STACK): New macro,
 
8986
+       define as 1 if we are running on a power7 or newer.
 
8987
+       (enum r6000_reg_class_enum): Add new constraints.
 
8988
+
 
8989
+       * config/rs6000/dfp.md (movsd): Delete, combine with binary
 
8990
+       floating point moves in rs6000.md.  Combine power6x (mfpgpr) moves
 
8991
+       with other moves by using conditional constraits (wg).  Use LFIWZX
 
8992
+       and STFIWX for loading SDmode on power7.  Use xxlxor to create
 
8993
+       0.0f.
 
8994
+       (movsd splitter): Likewise.
 
8995
+       (movsd_hardfloat): Likewise.
 
8996
+       (movsd_softfloat): Likewise.
 
8997
+
 
8998
+       * config/rs6000/rs6000.md (FMOVE32): New iterators to combine
 
8999
+       binary and decimal floating point moves.
 
9000
+       (fmove_ok): New attributes to combine binary and decimal floating
 
9001
+       point moves, and to combine power6x (mfpgpr) moves along normal
 
9002
+       floating moves.
 
9003
+       (real_value_to_target): Likewise.
 
9004
+       (f32_lr): Likewise.
 
9005
+       (f32_lm): Likewise.
 
9006
+       (f32_li): Likewise.
 
9007
+       (f32_sr): Likewise.
 
9008
+       (f32_sm): Likewise.
 
9009
+       (f32_si): Likewise.
 
9010
+       (movsf): Combine binary and decimal floating point moves.  Combine
 
9011
+       power6x (mfpgpr) moves with other moves by using conditional
 
9012
+       constraits (wg).  Use LFIWZX and STFIWX for loading SDmode on
 
9013
+       power7.
 
9014
+       (mov<mode> for SFmode/SDmode); Likewise.
 
9015
+       (SFmode/SDmode splitters): Likewise.
 
9016
+       (movsf_hardfloat): Likewise.
 
9017
+       (mov<mode>_hardfloat for SFmode/SDmode): Likewise.
 
9018
+       (movsf_softfloat): Likewise.
 
9019
+       (mov<mode>_softfloat for SFmode/SDmode): Likewise.
 
9020
+
 
9021
+       * doc/md.texi (PowerPC and IBM RS6000 constraints): Document wl,
 
9022
+       wx and wz constraints.
 
9023
+
 
9024
+       * config/rs6000/constraints.md (wg constraint): New constraint to
 
9025
+       return FLOAT_REGS if -mmfpgpr (power6x) was used.
 
9026
+
 
9027
+       * config/rs6000/rs6000.h (enum r6000_reg_class_enum): Add wg
 
9028
+       constraint.
 
9029
+
 
9030
+       * config/rs6000/rs6000.c (rs6000_debug_reg_global): If
 
9031
+       -mdebug=reg, print wg, wl, wx, and wz constraints.
 
9032
+       (rs6000_init_hard_regno_mode_ok): Initialize new constraints.
 
9033
+       Initialize the reload functions for 64-bit binary/decimal floating
 
9034
+       point types.
 
9035
+       (reg_offset_addressing_ok_p): If we are on a power7 or later, use
 
9036
+       LFIWZX and STFIWX to load/store 32-bit decimal types, and don't
 
9037
+       create the buffer on the stack to overcome not having a 32-bit
 
9038
+       load and store.
 
9039
+       (rs6000_emit_move): Likewise.
 
9040
+       (rs6000_secondary_memory_needed_rtx): Likewise.
 
9041
+       (rs6000_alloc_sdmode_stack_slot): Likewise.
 
9042
+       (rs6000_preferred_reload_class): On VSX, we can create SFmode 0.0f
 
9043
+       via xxlxor, just like DFmode 0.0.
 
9044
+
 
9045
+
 
9046
+       * config/rs6000/dfp.md (movdd): Delete, combine with binary
 
9047
+       floating point moves in rs6000.md.  Combine power6x (mfpgpr) moves
 
9048
+       with other moves by using conditional constraits (wg).  Use LFIWZX
 
9049
+       and STFIWX for loading SDmode on power7.
 
9050
+       (movdd splitters): Likewise.
 
9051
+       (movdd_hardfloat32): Likewise.
 
9052
+       (movdd_softfloat32): Likewise.
 
9053
+       (movdd_hardfloat64_mfpgpr): Likewise.
 
9054
+       (movdd_hardfloat64): Likewise.
 
9055
+       (movdd_softfloat64): Likewise.
 
9056
+
 
9057
+       * config/rs6000/rs6000.md (FMOVE64): New iterators to combine
 
9058
+       64-bit binary and decimal floating point moves.
 
9059
+       (FMOVE64X): Likewise.
 
9060
+       (movdf): Combine 64-bit binary and decimal floating point moves.
 
9061
+       Combine power6x (mfpgpr) moves with other moves by using
 
9062
+       conditional constraits (wg).
 
9063
+       (mov<mode> for DFmode/DDmode): Likewise.
 
9064
+       (DFmode/DDmode splitters): Likewise.
 
9065
+       (movdf_hardfloat32): Likewise.
 
9066
+       (mov<mode>_hardfloat32 for DFmode/DDmode): Likewise.
 
9067
+       (movdf_softfloat32): Likewise.
 
9068
+       (movdf_hardfloat64_mfpgpr): Likewise.
 
9069
+       (movdf_hardfloat64): Likewise.
 
9070
+       (mov<mode>_hardfloat64 for DFmode/DDmode): Likewise.
 
9071
+       (movdf_softfloat64): Likewise.
 
9072
+       (mov<mode>_softfloat64 for DFmode/DDmode): Likewise.
 
9073
+       (reload_<mode>_load): Move to later in the file so they aren't in
 
9074
+       the middle of the floating point move insns.
 
9075
+       (reload_<mode>_store): Likewise.
 
9076
+
 
9077
+       * doc/md.texi (PowerPC and IBM RS6000 constraints): Document wg
 
9078
+       constraint.
 
9079
+
 
9080
+       * config/rs6000/rs6000.c (rs6000_debug_reg_global): Print out wg
 
9081
+       constraint if -mdebug=reg.
 
9082
+       (rs6000_initi_hard_regno_mode_ok): Enable wg constraint if
 
9083
+       -mfpgpr.  Enable using dd reload support if needed.
 
9084
+
 
9085
+       * config/rs6000/dfp.md (movtd): Delete, combine with 128-bit
 
9086
+       binary and decimal floating point moves in rs6000.md.
 
9087
+       (movtd_internal): Likewise.
 
9088
+
 
9089
+       * config/rs6000/rs6000.md (FMOVE128): Combine 128-bit binary and
 
9090
+       decimal floating point moves.
 
9091
+       (movtf): Likewise.
 
9092
+       (movtf_internal): Likewise.
 
9093
+       (mov<mode>_internal, TDmode/TFmode): Likewise.
 
9094
+       (movtf_softfloat): Likewise.
 
9095
+       (mov<mode>_softfloat, TDmode/TFmode): Likewise.
 
9096
+
 
9097
+       * config/rs6000/rs6000.md (movdi_mfpgpr): Delete, combine with
 
9098
+       movdi_internal64, using wg constraint for move direct operations.
 
9099
+       (movdi_internal64): Likewise.
 
9100
+
 
9101
+       * config/rs6000/rs6000.c (rs6000_debug_reg_global): Print
 
9102
+       MODES_TIEABLE_P for selected modes.  Print the numerical value of
 
9103
+       the various virtual registers. Use GPR/FPR first/last values,
 
9104
+       instead of hard coding the register numbers.  Print which modes
 
9105
+       have reload functions registered.
 
9106
+       (rs6000_option_override_internal): If -mdebug=reg, trace the
 
9107
+       options settings before/after setting cpu, target and subtarget
 
9108
+       settings.
 
9109
+       (rs6000_secondary_reload_trace): Improve the RTL dump for
 
9110
+       -mdebug=addr and for secondary reload failures in
 
9111
+       rs6000_secondary_reload_inner.
 
9112
+       (rs6000_secondary_reload_fail): Likewise.
 
9113
+       (rs6000_secondary_reload_inner): Likewise.
 
9114
+
 
9115
+       * config/rs6000/rs6000.md (FIRST_GPR_REGNO): Add convenience
 
9116
+       macros for first/last GPR and FPR registers.
 
9117
+       (LAST_GPR_REGNO): Likewise.
 
9118
+       (FIRST_FPR_REGNO): Likewise.
 
9119
+       (LAST_FPR_REGNO): Likewise.
 
9120
+
 
9121
+       * config/rs6000/vector.md (mul<mode>3): Use the combined macro
 
9122
+       VECTOR_UNIT_ALTIVEC_OR_VSX_P instead of separate calls to
 
9123
+       VECTOR_UNIT_ALTIVEC_P and VECTOR_UNIT_VSX_P.
 
9124
+       (vcond<mode><mode>): Likewise.
 
9125
+       (vcondu<mode><mode>): Likewise.
 
9126
+       (vector_gtu<mode>): Likewise.
 
9127
+       (vector_gte<mode>): Likewise.
 
9128
+       (xor<mode>3): Don't allow logical operations on TImode in 32-bit
 
9129
+       to prevent the compiler from converting DImode operations to
 
9130
+       TImode.
 
9131
+       (ior<mode>3): Likewise.
 
9132
+       (and<mode>3): Likewise.
 
9133
+       (one_cmpl<mode>2): Likewise.
 
9134
+       (nor<mode>3): Likewise.
 
9135
+       (andc<mode>3): Likewise.
 
9136
+
 
9137
+       * config/rs6000/constraints.md (wt constraint): New constraint
 
9138
+       that returns VSX_REGS if TImode is allowed in VSX registers.
 
9139
+
 
9140
+       * config/rs6000/predicates.md (easy_fp_constant): 0.0f is an easy
 
9141
+       constant under VSX.
 
9142
+
 
9143
+       * config/rs6000/rs6000-modes.def (PTImode): Define, PTImode is
 
9144
+       similar to TImode, but it is restricted to being in the GPRs.
 
9145
+
 
9146
+       * config/rs6000/rs6000.opt (-mvsx-timode): New switch to allow
 
9147
+       TImode to occupy a single VSX register.
 
9148
+
 
9149
+       * config/rs6000/rs6000-cpus.def (ISA_2_6_MASKS_SERVER): Default to
 
9150
+       -mvsx-timode for power7/power8.
 
9151
+       (power7 cpu): Likewise.
 
9152
+       (power8 cpu): Likewise.
 
9153
+
 
9154
+       * config/rs6000/rs6000.c (rs6000_hard_regno_nregs_internal): Make
 
9155
+       sure that TFmode/TDmode take up two registers if they are ever
 
9156
+       allowed in the upper VSX registers.
 
9157
+       (rs6000_hard_regno_mode_ok): If -mvsx-timode, allow TImode in VSX
 
9158
+       registers.
 
9159
+       (rs6000_init_hard_regno_mode_ok): Likewise.
 
9160
+       (rs6000_debug_reg_global): Add debugging for PTImode and wt
 
9161
+       constraint.  Print if LRA is turned on.
 
9162
+       (rs6000_option_override_internal): Give an error if -mvsx-timode
 
9163
+       and VSX is not enabled.
 
9164
+       (invalid_e500_subreg): Handle PTImode, restricting it to GPRs.  If
 
9165
+       -mvsx-timode, restrict TImode to reg+reg addressing, and PTImode
 
9166
+       to reg+offset addressing.  Use PTImode when checking offset
 
9167
+       addresses for validity.
 
9168
+       (reg_offset_addressing_ok_p): Likewise.
 
9169
+       (rs6000_legitimate_offset_address_p): Likewise.
 
9170
+       (rs6000_legitimize_address): Likewise.
 
9171
+       (rs6000_legitimize_reload_address): Likewise.
 
9172
+       (rs6000_legitimate_address_p): Likewise.
 
9173
+       (rs6000_eliminate_indexed_memrefs): Likewise.
 
9174
+       (rs6000_emit_move): Likewise.
 
9175
+       (rs6000_secondary_reload): Likewise.
 
9176
+       (rs6000_secondary_reload_inner): Handle PTImode.  Allow 64-bit
 
9177
+       reloads to fpr registers to continue to use reg+offset addressing,
 
9178
+       but 64-bit reloads to altivec registers need reg+reg addressing.
 
9179
+       Drop test for PRE_MODIFY, since VSX loads/stores no longer support
 
9180
+       it.  Treat LO_SUM like a PLUS operation.
 
9181
+       (rs6000_secondary_reload_class): If type is 64-bit, prefer to use
 
9182
+       FLOAT_REGS instead of VSX_RGS to allow use of reg+offset
 
9183
+       addressing.
 
9184
+       (rs6000_cannot_change_mode_class): Do not allow TImode in VSX
 
9185
+       registers to share a register with a smaller sized type, since VSX
 
9186
+       puts scalars in the upper 64-bits.
 
9187
+       (print_operand): Add support for PTImode.
 
9188
+       (rs6000_register_move_cost): Use VECTOR_MEM_VSX_P instead of
 
9189
+       VECTOR_UNIT_VSX_P to catch types that can be loaded in VSX
 
9190
+       registers, but don't have arithmetic support.
 
9191
+       (rs6000_memory_move_cost): Add test for VSX.
 
9192
+       (rs6000_opt_masks): Add -mvsx-timode.
 
9193
+
 
9194
+       * config/rs6000/vsx.md (VSm): Change to use 64-bit aligned moves
 
9195
+       for TImode.
 
9196
+       (VSs): Likewise.
 
9197
+       (VSr): Use wt constraint for TImode.
 
9198
+       (VSv): Drop TImode support.
 
9199
+       (vsx_movti): Delete, replace with versions for 32-bit and 64-bit.
 
9200
+       (vsx_movti_64bit): Likewise.
 
9201
+       (vsx_movti_32bit): Likewise.
 
9202
+       (vec_store_<mode>): Use VSX iterator instead of vector iterator.
 
9203
+       (vsx_and<mode>3): Delete use of '?' constraint on inputs, just put
 
9204
+       one '?' on the appropriate output constraint.  Do not allow TImode
 
9205
+       logical operations on 32-bit systems.
 
9206
+       (vsx_ior<mode>3): Likewise.
 
9207
+       (vsx_xor<mode>3): Likewise.
 
9208
+       (vsx_one_cmpl<mode>2): Likewise.
 
9209
+       (vsx_nor<mode>3): Likewise.
 
9210
+       (vsx_andc<mode>3): Likewise.
 
9211
+       (vsx_concat_<mode>): Likewise.
 
9212
+       (vsx_xxpermdi_<mode>): Fix thinko for non V2DF/V2DI modes.
 
9213
+
 
9214
+       * config/rs6000/rs6000.h (MASK_VSX_TIMODE): Map from
 
9215
+       OPTION_MASK_VSX_TIMODE.
 
9216
+       (enum rs6000_reg_class_enum): Add RS6000_CONSTRAINT_wt.
 
9217
+       (STACK_SAVEAREA_MODE): Use PTImode instead of TImode.
 
9218
+
 
9219
+       * config/rs6000/rs6000.md (INT mode attribute): Add PTImode.
 
9220
+       (TI2 iterator): New iterator for TImode, PTImode.
 
9221
+       (wd mode attribute): Add values for vector types.
 
9222
+       (movti_string): Replace TI move operations with operations for
 
9223
+       TImode and PTImode.  Add support for TImode being allowed in VSX
 
9224
+       registers.
 
9225
+       (mov<mode>_string, TImode/PTImode): Likewise.
 
9226
+       (movti_ppc64): Likewise.
 
9227
+       (mov<mode>_ppc64, TImode/PTImode): Likewise.
 
9228
+       (TI mode splitters): Likewise.
 
9229
+
 
9230
+       * doc/md.texi (PowerPC and IBM RS6000 constraints): Document wt
 
9231
+       constraint.
 
9232
+
 
9233
+2013-03-20  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
9234
+
 
9235
+       Clone branch from gcc-4_8-branch, subversion id 196835.
 
9236
+       * REVISION: New file, track subversion id.
 
9237
+
 
9238
--- a/src/gcc/calls.c
 
9239
+++ b/src/gcc/calls.c
 
9240
@@ -983,6 +983,7 @@
 
9241
 
 
9242
   for (i = 0; i < num_actuals; i++)
 
9243
     if (args[i].reg != 0 && ! args[i].pass_on_stack
 
9244
+       && GET_CODE (args[i].reg) != PARALLEL
 
9245
        && args[i].mode == BLKmode
 
9246
        && MEM_P (args[i].value)
 
9247
        && (MEM_ALIGN (args[i].value)
 
9248
@@ -1327,6 +1328,7 @@
 
9249
 #else
 
9250
                             args[i].reg != 0,
 
9251
 #endif
 
9252
+                            reg_parm_stack_space,
 
9253
                             args[i].pass_on_stack ? 0 : args[i].partial,
 
9254
                             fndecl, args_size, &args[i].locate);
 
9255
 #ifdef BLOCK_REG_PADDING
 
9256
@@ -3171,7 +3173,9 @@
 
9257
         group load/store machinery below.  */
 
9258
       if (!structure_value_addr
 
9259
          && !pcc_struct_value
 
9260
+         && TYPE_MODE (rettype) != VOIDmode
 
9261
          && TYPE_MODE (rettype) != BLKmode
 
9262
+         && REG_P (valreg)
 
9263
          && targetm.calls.return_in_msb (rettype))
 
9264
        {
 
9265
          if (shift_return_value (TYPE_MODE (rettype), false, valreg))
 
9266
@@ -3734,7 +3738,8 @@
 
9267
 #else
 
9268
                           argvec[count].reg != 0,
 
9269
 #endif
 
9270
-                          0, NULL_TREE, &args_size, &argvec[count].locate);
 
9271
+                          reg_parm_stack_space, 0,
 
9272
+                          NULL_TREE, &args_size, &argvec[count].locate);
 
9273
 
 
9274
       if (argvec[count].reg == 0 || argvec[count].partial != 0
 
9275
          || reg_parm_stack_space > 0)
 
9276
@@ -3821,7 +3826,7 @@
 
9277
 #else
 
9278
                               argvec[count].reg != 0,
 
9279
 #endif
 
9280
-                              argvec[count].partial,
 
9281
+                              reg_parm_stack_space, argvec[count].partial,
 
9282
                               NULL_TREE, &args_size, &argvec[count].locate);
 
9283
          args_size.constant += argvec[count].locate.size.constant;
 
9284
          gcc_assert (!argvec[count].locate.size.var);
 
9285
--- a/src/gcc/config.gcc
 
9286
+++ b/src/gcc/config.gcc
 
9287
@@ -420,7 +420,7 @@
 
9288
         ;;
 
9289
 powerpc*-*-*)
 
9290
        cpu_type=rs6000
 
9291
-       extra_headers="ppc-asm.h altivec.h spe.h ppu_intrinsics.h paired.h spu2vmx.h vec_types.h si2vmx.h"
 
9292
+       extra_headers="ppc-asm.h altivec.h spe.h ppu_intrinsics.h paired.h spu2vmx.h vec_types.h si2vmx.h htmintrin.h htmxlintrin.h"
 
9293
        need_64bit_hwint=yes
 
9294
        case x$with_cpu in
 
9295
            xpowerpc64|xdefault64|x6[23]0|x970|xG5|xpower[345678]|xpower6x|xrs64a|xcell|xa2|xe500mc64|xe5500|Xe6500)
 
9296
@@ -3509,7 +3509,7 @@
 
9297
                ;;
 
9298
 
 
9299
        powerpc*-*-* | rs6000-*-*)
 
9300
-               supported_defaults="cpu cpu_32 cpu_64 float tune tune_32 tune_64"
 
9301
+               supported_defaults="abi cpu cpu_32 cpu_64 float tune tune_32 tune_64"
 
9302
 
 
9303
                for which in cpu cpu_32 cpu_64 tune tune_32 tune_64; do
 
9304
                        eval "val=\$with_$which"
 
9305
@@ -3546,6 +3546,16 @@
 
9306
                                ;;
 
9307
                        esac
 
9308
                done
 
9309
+
 
9310
+               case "$with_abi" in
 
9311
+               "" | elfv1 | elfv2 )
 
9312
+                       #OK
 
9313
+                       ;;
 
9314
+               *)
 
9315
+                       echo "Unknown ABI used in --with-abi=$with_abi"
 
9316
+                       exit 1
 
9317
+                       ;;
 
9318
+               esac
 
9319
                ;;
 
9320
 
 
9321
        s390*-*-*)
 
9322
--- a/src/gcc/config/rs6000/power8.md
 
9323
+++ b/src/gcc/config/rs6000/power8.md
 
9324
@@ -0,0 +1,373 @@
 
9325
+;; Scheduling description for IBM POWER8 processor.
 
9326
+;; Copyright (C) 2013 Free Software Foundation, Inc.
 
9327
+;;
 
9328
+;; Contributed by Pat Haugen (pthaugen@us.ibm.com).
 
9329
+
 
9330
+;; This file is part of GCC.
 
9331
+;;
 
9332
+;; GCC is free software; you can redistribute it and/or modify it
 
9333
+;; under the terms of the GNU General Public License as published
 
9334
+;; by the Free Software Foundation; either version 3, or (at your
 
9335
+;; option) any later version.
 
9336
+;;
 
9337
+;; GCC is distributed in the hope that it will be useful, but WITHOUT
 
9338
+;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 
9339
+;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
 
9340
+;; License for more details.
 
9341
+;;
 
9342
+;; You should have received a copy of the GNU General Public License
 
9343
+;; along with GCC; see the file COPYING3.  If not see
 
9344
+;; <http://www.gnu.org/licenses/>.
 
9345
+
 
9346
+(define_automaton "power8fxu,power8lsu,power8vsu,power8misc")
 
9347
+
 
9348
+(define_cpu_unit "fxu0_power8,fxu1_power8" "power8fxu")
 
9349
+(define_cpu_unit "lu0_power8,lu1_power8" "power8lsu")
 
9350
+(define_cpu_unit "lsu0_power8,lsu1_power8" "power8lsu")
 
9351
+(define_cpu_unit "vsu0_power8,vsu1_power8" "power8vsu")
 
9352
+(define_cpu_unit "bpu_power8,cru_power8" "power8misc")
 
9353
+(define_cpu_unit "du0_power8,du1_power8,du2_power8,du3_power8,du4_power8,\
 
9354
+                 du5_power8,du6_power8"  "power8misc")
 
9355
+
 
9356
+
 
9357
+; Dispatch group reservations
 
9358
+(define_reservation "DU_any_power8"
 
9359
+                   "du0_power8|du1_power8|du2_power8|du3_power8|du4_power8|\
 
9360
+                    du5_power8")
 
9361
+
 
9362
+; 2-way Cracked instructions go in slots 0-1
 
9363
+;   (can also have a second in slots 3-4 if insns are adjacent)
 
9364
+(define_reservation "DU_cracked_power8"
 
9365
+                   "du0_power8+du1_power8")
 
9366
+
 
9367
+; Insns that are first in group
 
9368
+(define_reservation "DU_first_power8"
 
9369
+                   "du0_power8")
 
9370
+
 
9371
+; Insns that are first and last in group
 
9372
+(define_reservation "DU_both_power8"
 
9373
+                   "du0_power8+du1_power8+du2_power8+du3_power8+du4_power8+\
 
9374
+                    du5_power8+du6_power8")
 
9375
+
 
9376
+; Dispatch slots are allocated in order conforming to program order.
 
9377
+(absence_set "du0_power8" "du1_power8,du2_power8,du3_power8,du4_power8,\
 
9378
+             du5_power8,du6_power8")
 
9379
+(absence_set "du1_power8" "du2_power8,du3_power8,du4_power8,du5_power8,\
 
9380
+             du6_power8")
 
9381
+(absence_set "du2_power8" "du3_power8,du4_power8,du5_power8,du6_power8")
 
9382
+(absence_set "du3_power8" "du4_power8,du5_power8,du6_power8")
 
9383
+(absence_set "du4_power8" "du5_power8,du6_power8")
 
9384
+(absence_set "du5_power8" "du6_power8")
 
9385
+
 
9386
+
 
9387
+; Execution unit reservations
 
9388
+(define_reservation "FXU_power8"
 
9389
+                    "fxu0_power8|fxu1_power8")
 
9390
+
 
9391
+(define_reservation "LU_power8"
 
9392
+                    "lu0_power8|lu1_power8")
 
9393
+
 
9394
+(define_reservation "LSU_power8"
 
9395
+                    "lsu0_power8|lsu1_power8")
 
9396
+
 
9397
+(define_reservation "LU_or_LSU_power8"
 
9398
+                    "lu0_power8|lu1_power8|lsu0_power8|lsu1_power8")
 
9399
+
 
9400
+(define_reservation "VSU_power8"
 
9401
+                    "vsu0_power8|vsu1_power8")
 
9402
+
 
9403
+
 
9404
+; LS Unit
 
9405
+(define_insn_reservation "power8-load" 3
 
9406
+  (and (eq_attr "type" "load")
 
9407
+       (eq_attr "cpu" "power8"))
 
9408
+  "DU_any_power8,LU_or_LSU_power8")
 
9409
+
 
9410
+(define_insn_reservation "power8-load-update" 3
 
9411
+  (and (eq_attr "type" "load_u,load_ux")
 
9412
+       (eq_attr "cpu" "power8"))
 
9413
+  "DU_cracked_power8,LU_or_LSU_power8+FXU_power8")
 
9414
+
 
9415
+(define_insn_reservation "power8-load-ext" 3
 
9416
+  (and (eq_attr "type" "load_ext")
 
9417
+       (eq_attr "cpu" "power8"))
 
9418
+  "DU_cracked_power8,LU_or_LSU_power8,FXU_power8")
 
9419
+
 
9420
+(define_insn_reservation "power8-load-ext-update" 3
 
9421
+  (and (eq_attr "type" "load_ext_u,load_ext_ux")
 
9422
+       (eq_attr "cpu" "power8"))
 
9423
+  "DU_both_power8,LU_or_LSU_power8+FXU_power8,FXU_power8")
 
9424
+
 
9425
+(define_insn_reservation "power8-fpload" 5
 
9426
+  (and (eq_attr "type" "fpload,vecload")
 
9427
+       (eq_attr "cpu" "power8"))
 
9428
+  "DU_any_power8,LU_power8")
 
9429
+
 
9430
+(define_insn_reservation "power8-fpload-update" 5
 
9431
+  (and (eq_attr "type" "fpload_u,fpload_ux")
 
9432
+       (eq_attr "cpu" "power8"))
 
9433
+  "DU_cracked_power8,LU_power8+FXU_power8")
 
9434
+
 
9435
+(define_insn_reservation "power8-store" 5 ; store-forwarding latency
 
9436
+  (and (eq_attr "type" "store,store_u")
 
9437
+       (eq_attr "cpu" "power8"))
 
9438
+  "DU_any_power8,LSU_power8+LU_power8")
 
9439
+
 
9440
+(define_insn_reservation "power8-store-update-indexed" 5
 
9441
+  (and (eq_attr "type" "store_ux")
 
9442
+       (eq_attr "cpu" "power8"))
 
9443
+  "DU_cracked_power8,LSU_power8+LU_power8")
 
9444
+
 
9445
+(define_insn_reservation "power8-fpstore" 5
 
9446
+  (and (eq_attr "type" "fpstore")
 
9447
+       (eq_attr "cpu" "power8"))
 
9448
+  "DU_any_power8,LSU_power8+VSU_power8")
 
9449
+
 
9450
+(define_insn_reservation "power8-fpstore-update" 5
 
9451
+  (and (eq_attr "type" "fpstore_u,fpstore_ux")
 
9452
+       (eq_attr "cpu" "power8"))
 
9453
+  "DU_any_power8,LSU_power8+VSU_power8")
 
9454
+
 
9455
+(define_insn_reservation "power8-vecstore" 5
 
9456
+  (and (eq_attr "type" "vecstore")
 
9457
+       (eq_attr "cpu" "power8"))
 
9458
+  "DU_cracked_power8,LSU_power8+VSU_power8")
 
9459
+
 
9460
+(define_insn_reservation "power8-larx" 3
 
9461
+  (and (eq_attr "type" "load_l")
 
9462
+       (eq_attr "cpu" "power8"))
 
9463
+  "DU_both_power8,LU_or_LSU_power8")
 
9464
+
 
9465
+(define_insn_reservation "power8-stcx" 10
 
9466
+  (and (eq_attr "type" "store_c")
 
9467
+       (eq_attr "cpu" "power8"))
 
9468
+  "DU_both_power8,LSU_power8+LU_power8")
 
9469
+
 
9470
+(define_insn_reservation "power8-sync" 1
 
9471
+  (and (eq_attr "type" "sync,isync")
 
9472
+       (eq_attr "cpu" "power8"))
 
9473
+  "DU_both_power8,LSU_power8")
 
9474
+
 
9475
+
 
9476
+; FX Unit
 
9477
+(define_insn_reservation "power8-1cyc" 1
 
9478
+  (and (eq_attr "type" "integer,insert_word,insert_dword,shift,trap,\
 
9479
+                        var_shift_rotate,exts,isel")
 
9480
+       (eq_attr "cpu" "power8"))
 
9481
+  "DU_any_power8,FXU_power8")
 
9482
+
 
9483
+; Extra cycle to LU/LSU
 
9484
+(define_bypass 2 "power8-1cyc"
 
9485
+                "power8-load*,power8-fpload*,power8-store*,power8-fpstore*,\
 
9486
+                 power8-vecstore,power8-larx,power8-stcx")
 
9487
+;               "power8-load,power8-load-update,power8-load-ext,\
 
9488
+;                power8-load-ext-update,power8-fpload,power8-fpload-update,\
 
9489
+;                power8-store,power8-store-update,power8-store-update-indexed,\
 
9490
+;                power8-fpstore,power8-fpstore-update,power8-vecstore,\
 
9491
+;                power8-larx,power8-stcx")
 
9492
+
 
9493
+(define_insn_reservation "power8-2cyc" 2
 
9494
+  (and (eq_attr "type" "cntlz,popcnt")
 
9495
+       (eq_attr "cpu" "power8"))
 
9496
+  "DU_any_power8,FXU_power8")
 
9497
+
 
9498
+(define_insn_reservation "power8-two" 2
 
9499
+  (and (eq_attr "type" "two")
 
9500
+       (eq_attr "cpu" "power8"))
 
9501
+  "DU_any_power8+DU_any_power8,FXU_power8,FXU_power8")
 
9502
+
 
9503
+(define_insn_reservation "power8-three" 3
 
9504
+  (and (eq_attr "type" "three")
 
9505
+       (eq_attr "cpu" "power8"))
 
9506
+  "DU_any_power8+DU_any_power8+DU_any_power8,FXU_power8,FXU_power8,FXU_power8")
 
9507
+
 
9508
+; cmp - Normal compare insns
 
9509
+(define_insn_reservation "power8-cmp" 2
 
9510
+  (and (eq_attr "type" "cmp")
 
9511
+       (eq_attr "cpu" "power8"))
 
9512
+  "DU_any_power8,FXU_power8")
 
9513
+
 
9514
+; fast_compare : add./and./nor./etc
 
9515
+(define_insn_reservation "power8-fast-compare" 2
 
9516
+  (and (eq_attr "type" "fast_compare")
 
9517
+       (eq_attr "cpu" "power8"))
 
9518
+  "DU_any_power8,FXU_power8")
 
9519
+
 
9520
+; compare : rldicl./exts./etc
 
9521
+; delayed_compare : rlwinm./slwi./etc
 
9522
+; var_delayed_compare : rlwnm./slw./etc
 
9523
+(define_insn_reservation "power8-compare" 2
 
9524
+  (and (eq_attr "type" "compare,delayed_compare,var_delayed_compare")
 
9525
+       (eq_attr "cpu" "power8"))
 
9526
+  "DU_cracked_power8,FXU_power8,FXU_power8")
 
9527
+
 
9528
+; Extra cycle to LU/LSU
 
9529
+(define_bypass 3 "power8-fast-compare,power8-compare"
 
9530
+                "power8-load*,power8-fpload*,power8-store*,power8-fpstore*,\
 
9531
+                 power8-vecstore,power8-larx,power8-stcx")
 
9532
+
 
9533
+; 5 cycle CR latency 
 
9534
+(define_bypass 5 "power8-fast-compare,power8-compare"
 
9535
+                "power8-crlogical,power8-mfcr,power8-mfcrf,power8-branch")
 
9536
+
 
9537
+(define_insn_reservation "power8-mul" 4
 
9538
+  (and (eq_attr "type" "imul,imul2,imul3,lmul")
 
9539
+       (eq_attr "cpu" "power8"))
 
9540
+  "DU_any_power8,FXU_power8")
 
9541
+
 
9542
+(define_insn_reservation "power8-mul-compare" 4
 
9543
+  (and (eq_attr "type" "imul_compare,lmul_compare")
 
9544
+       (eq_attr "cpu" "power8"))
 
9545
+  "DU_cracked_power8,FXU_power8")
 
9546
+
 
9547
+; Extra cycle to LU/LSU
 
9548
+(define_bypass 5 "power8-mul,power8-mul-compare"
 
9549
+                "power8-load*,power8-fpload*,power8-store*,power8-fpstore*,\
 
9550
+                 power8-vecstore,power8-larx,power8-stcx")
 
9551
+
 
9552
+; 7 cycle CR latency 
 
9553
+(define_bypass 7 "power8-mul,power8-mul-compare"
 
9554
+                "power8-crlogical,power8-mfcr,power8-mfcrf,power8-branch")
 
9555
+
 
9556
+; FXU divides are not pipelined
 
9557
+(define_insn_reservation "power8-idiv" 37
 
9558
+  (and (eq_attr "type" "idiv")
 
9559
+       (eq_attr "cpu" "power8"))
 
9560
+  "DU_any_power8,fxu0_power8*37|fxu1_power8*37")
 
9561
+
 
9562
+(define_insn_reservation "power8-ldiv" 68
 
9563
+  (and (eq_attr "type" "ldiv")
 
9564
+       (eq_attr "cpu" "power8"))
 
9565
+  "DU_any_power8,fxu0_power8*68|fxu1_power8*68")
 
9566
+
 
9567
+(define_insn_reservation "power8-mtjmpr" 5
 
9568
+  (and (eq_attr "type" "mtjmpr")
 
9569
+       (eq_attr "cpu" "power8"))
 
9570
+  "DU_first_power8,FXU_power8")
 
9571
+
 
9572
+; Should differentiate between 1 cr field and > 1 since mtocrf is not microcode
 
9573
+(define_insn_reservation "power8-mtcr" 3
 
9574
+  (and (eq_attr "type" "mtcr")
 
9575
+       (eq_attr "cpu" "power8"))
 
9576
+  "DU_both_power8,FXU_power8")
 
9577
+
 
9578
+
 
9579
+; CR Unit
 
9580
+(define_insn_reservation "power8-mfjmpr" 5
 
9581
+  (and (eq_attr "type" "mfjmpr")
 
9582
+       (eq_attr "cpu" "power8"))
 
9583
+  "DU_first_power8,cru_power8+FXU_power8")
 
9584
+
 
9585
+(define_insn_reservation "power8-crlogical" 3
 
9586
+  (and (eq_attr "type" "cr_logical,delayed_cr")
 
9587
+       (eq_attr "cpu" "power8"))
 
9588
+  "DU_first_power8,cru_power8")
 
9589
+
 
9590
+(define_insn_reservation "power8-mfcr" 5
 
9591
+  (and (eq_attr "type" "mfcr")
 
9592
+       (eq_attr "cpu" "power8"))
 
9593
+  "DU_both_power8,cru_power8")
 
9594
+
 
9595
+(define_insn_reservation "power8-mfcrf" 3
 
9596
+  (and (eq_attr "type" "mfcrf")
 
9597
+       (eq_attr "cpu" "power8"))
 
9598
+  "DU_first_power8,cru_power8")
 
9599
+
 
9600
+
 
9601
+; BR Unit
 
9602
+; Branches take dispatch slot 7, but reserve any remaining prior slots to
 
9603
+; prevent other insns from grabbing them once this is assigned.
 
9604
+(define_insn_reservation "power8-branch" 3
 
9605
+  (and (eq_attr "type" "jmpreg,branch")
 
9606
+       (eq_attr "cpu" "power8"))
 
9607
+  "(du6_power8\
 
9608
+   |du5_power8+du6_power8\
 
9609
+   |du4_power8+du5_power8+du6_power8\
 
9610
+   |du3_power8+du4_power8+du5_power8+du6_power8\
 
9611
+   |du2_power8+du3_power8+du4_power8+du5_power8+du6_power8\
 
9612
+   |du1_power8+du2_power8+du3_power8+du4_power8+du5_power8+du6_power8\
 
9613
+   |du0_power8+du1_power8+du2_power8+du3_power8+du4_power8+du5_power8+\
 
9614
+    du6_power8),bpu_power8")
 
9615
+
 
9616
+; Branch updating LR/CTR feeding mf[lr|ctr]
 
9617
+(define_bypass 4 "power8-branch" "power8-mfjmpr")
 
9618
+
 
9619
+
 
9620
+; VS Unit (includes FP/VSX/VMX/DFP/Crypto)
 
9621
+(define_insn_reservation "power8-fp" 6
 
9622
+  (and (eq_attr "type" "fp,dmul")
 
9623
+       (eq_attr "cpu" "power8"))
 
9624
+  "DU_any_power8,VSU_power8")
 
9625
+
 
9626
+; Additional 3 cycles for any CR result
 
9627
+(define_bypass 9 "power8-fp" "power8-crlogical,power8-mfcr*,power8-branch")
 
9628
+
 
9629
+(define_insn_reservation "power8-fpcompare" 8
 
9630
+  (and (eq_attr "type" "fpcompare")
 
9631
+       (eq_attr "cpu" "power8"))
 
9632
+  "DU_any_power8,VSU_power8")
 
9633
+
 
9634
+(define_insn_reservation "power8-sdiv" 27
 
9635
+  (and (eq_attr "type" "sdiv")
 
9636
+       (eq_attr "cpu" "power8"))
 
9637
+  "DU_any_power8,VSU_power8")
 
9638
+
 
9639
+(define_insn_reservation "power8-ddiv" 33
 
9640
+  (and (eq_attr "type" "ddiv")
 
9641
+       (eq_attr "cpu" "power8"))
 
9642
+  "DU_any_power8,VSU_power8")
 
9643
+
 
9644
+(define_insn_reservation "power8-sqrt" 32
 
9645
+  (and (eq_attr "type" "ssqrt")
 
9646
+       (eq_attr "cpu" "power8"))
 
9647
+  "DU_any_power8,VSU_power8")
 
9648
+
 
9649
+(define_insn_reservation "power8-dsqrt" 44
 
9650
+  (and (eq_attr "type" "dsqrt")
 
9651
+       (eq_attr "cpu" "power8"))
 
9652
+  "DU_any_power8,VSU_power8")
 
9653
+
 
9654
+(define_insn_reservation "power8-vecsimple" 2
 
9655
+  (and (eq_attr "type" "vecperm,vecsimple,veccmp")
 
9656
+       (eq_attr "cpu" "power8"))
 
9657
+  "DU_any_power8,VSU_power8")
 
9658
+
 
9659
+(define_insn_reservation "power8-vecnormal" 6
 
9660
+  (and (eq_attr "type" "vecfloat,vecdouble")
 
9661
+       (eq_attr "cpu" "power8"))
 
9662
+  "DU_any_power8,VSU_power8")
 
9663
+
 
9664
+(define_bypass 7 "power8-vecnormal"
 
9665
+                "power8-vecsimple,power8-veccomplex,power8-fpstore*,\
 
9666
+                 power8-vecstore")
 
9667
+
 
9668
+(define_insn_reservation "power8-veccomplex" 7
 
9669
+  (and (eq_attr "type" "veccomplex")
 
9670
+       (eq_attr "cpu" "power8"))
 
9671
+  "DU_any_power8,VSU_power8")
 
9672
+
 
9673
+(define_insn_reservation "power8-vecfdiv" 25
 
9674
+  (and (eq_attr "type" "vecfdiv")
 
9675
+       (eq_attr "cpu" "power8"))
 
9676
+  "DU_any_power8,VSU_power8")
 
9677
+
 
9678
+(define_insn_reservation "power8-vecdiv" 31
 
9679
+  (and (eq_attr "type" "vecdiv")
 
9680
+       (eq_attr "cpu" "power8"))
 
9681
+  "DU_any_power8,VSU_power8")
 
9682
+
 
9683
+(define_insn_reservation "power8-mffgpr" 5
 
9684
+  (and (eq_attr "type" "mffgpr")
 
9685
+       (eq_attr "cpu" "power8"))
 
9686
+  "DU_any_power8,VSU_power8")
 
9687
+
 
9688
+(define_insn_reservation "power8-mftgpr" 6
 
9689
+  (and (eq_attr "type" "mftgpr")
 
9690
+       (eq_attr "cpu" "power8"))
 
9691
+  "DU_any_power8,VSU_power8")
 
9692
+
 
9693
+(define_insn_reservation "power8-crypto" 7
 
9694
+  (and (eq_attr "type" "crypto")
 
9695
+       (eq_attr "cpu" "power8"))
 
9696
+  "DU_any_power8,VSU_power8")
 
9697
+
 
9698
--- a/src/gcc/config/rs6000/vector.md
 
9699
+++ b/src/gcc/config/rs6000/vector.md
 
9700
@@ -24,13 +24,13 @@
 
9701
 
 
9702
 
 
9703
 ;; Vector int modes
 
9704
-(define_mode_iterator VEC_I [V16QI V8HI V4SI])
 
9705
+(define_mode_iterator VEC_I [V16QI V8HI V4SI V2DI])
 
9706
 
 
9707
 ;; Vector float modes
 
9708
 (define_mode_iterator VEC_F [V4SF V2DF])
 
9709
 
 
9710
 ;; Vector arithmetic modes
 
9711
-(define_mode_iterator VEC_A [V16QI V8HI V4SI V4SF V2DF])
 
9712
+(define_mode_iterator VEC_A [V16QI V8HI V4SI V2DI V4SF V2DF])
 
9713
 
 
9714
 ;; Vector modes that need alginment via permutes
 
9715
 (define_mode_iterator VEC_K [V16QI V8HI V4SI V4SF])
 
9716
@@ -45,7 +45,7 @@
 
9717
 (define_mode_iterator VEC_N [V4SI V4SF V2DI V2DF])
 
9718
 
 
9719
 ;; Vector comparison modes
 
9720
-(define_mode_iterator VEC_C [V16QI V8HI V4SI V4SF V2DF])
 
9721
+(define_mode_iterator VEC_C [V16QI V8HI V4SI V2DI V4SF V2DF])
 
9722
 
 
9723
 ;; Vector init/extract modes
 
9724
 (define_mode_iterator VEC_E [V16QI V8HI V4SI V2DI V4SF V2DF])
 
9725
@@ -54,7 +54,7 @@
 
9726
 (define_mode_iterator VEC_64 [V2DI V2DF])
 
9727
 
 
9728
 ;; Vector reload iterator
 
9729
-(define_mode_iterator VEC_R [V16QI V8HI V4SI V2DI V4SF V2DF DF TI])
 
9730
+(define_mode_iterator VEC_R [V16QI V8HI V4SI V2DI V4SF V2DF SF SD SI DF DD DI TI])
 
9731
 
 
9732
 ;; Base type from vector mode
 
9733
 (define_mode_attr VEC_base [(V16QI "QI")
 
9734
@@ -88,7 +88,8 @@
 
9735
                                 (smax "smax")])
 
9736
 
 
9737
 
 
9738
-;; Vector move instructions.
 
9739
+;; Vector move instructions.  Little-endian VSX loads and stores require
 
9740
+;; special handling to circumvent "element endianness."
 
9741
 (define_expand "mov<mode>"
 
9742
   [(set (match_operand:VEC_M 0 "nonimmediate_operand" "")
 
9743
        (match_operand:VEC_M 1 "any_operand" ""))]
 
9744
@@ -104,6 +105,16 @@
 
9745
               && !vlogical_operand (operands[1], <MODE>mode))
 
9746
        operands[1] = force_reg (<MODE>mode, operands[1]);
 
9747
     }
 
9748
+  if (!BYTES_BIG_ENDIAN
 
9749
+      && VECTOR_MEM_VSX_P (<MODE>mode)
 
9750
+      && <MODE>mode != TImode
 
9751
+      && !gpr_or_gpr_p (operands[0], operands[1])
 
9752
+      && (memory_operand (operands[0], <MODE>mode)
 
9753
+          ^ memory_operand (operands[1], <MODE>mode)))
 
9754
+    {
 
9755
+      rs6000_emit_le_vsx_move (operands[0], operands[1], <MODE>mode);
 
9756
+      DONE;
 
9757
+    }
 
9758
 })
 
9759
 
 
9760
 ;; Generic vector floating point load/store instructions.  These will match
 
9761
@@ -126,7 +137,9 @@
 
9762
         (match_operand:VEC_L 1 "input_operand" ""))]
 
9763
   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)
 
9764
    && reload_completed
 
9765
-   && gpr_or_gpr_p (operands[0], operands[1])"
 
9766
+   && gpr_or_gpr_p (operands[0], operands[1])
 
9767
+   && !direct_move_p (operands[0], operands[1])
 
9768
+   && !quad_load_store_p (operands[0], operands[1])"
 
9769
   [(pc)]
 
9770
 {
 
9771
   rs6000_split_multireg_move (operands[0], operands[1]);
 
9772
@@ -249,7 +262,7 @@
 
9773
   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
 
9774
        (mult:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")
 
9775
                    (match_operand:VEC_F 2 "vfloat_operand" "")))]
 
9776
-  "VECTOR_UNIT_VSX_P (<MODE>mode) || VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
 
9777
+  "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
 
9778
 {
 
9779
   if (<MODE>mode == V4SFmode && VECTOR_UNIT_ALTIVEC_P (<MODE>mode))
 
9780
     {
 
9781
@@ -395,7 +408,7 @@
 
9782
                          (match_operand:VEC_I 5 "vint_operand" "")])
 
9783
         (match_operand:VEC_I 1 "vint_operand" "")
 
9784
         (match_operand:VEC_I 2 "vint_operand" "")))]
 
9785
-  "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
 
9786
+  "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
 
9787
   "
 
9788
 {
 
9789
   if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
 
9790
@@ -451,7 +464,7 @@
 
9791
                          (match_operand:VEC_I 5 "vint_operand" "")])
 
9792
         (match_operand:VEC_I 1 "vint_operand" "")
 
9793
         (match_operand:VEC_I 2 "vint_operand" "")))]
 
9794
-  "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
 
9795
+  "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
 
9796
   "
 
9797
 {
 
9798
   if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
 
9799
@@ -505,14 +518,14 @@
 
9800
   [(set (match_operand:VEC_I 0 "vint_operand" "")
 
9801
        (gtu:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
 
9802
                   (match_operand:VEC_I 2 "vint_operand" "")))]
 
9803
-  "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
 
9804
+  "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
 
9805
   "")
 
9806
 
 
9807
 (define_expand "vector_geu<mode>"
 
9808
   [(set (match_operand:VEC_I 0 "vint_operand" "")
 
9809
        (geu:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
 
9810
                   (match_operand:VEC_I 2 "vint_operand" "")))]
 
9811
-  "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
 
9812
+  "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
 
9813
   "")
 
9814
 
 
9815
 (define_insn_and_split "*vector_uneq<mode>"
 
9816
@@ -708,48 +721,19 @@
 
9817
   "")
 
9818
 
 
9819
 
 
9820
-;; Vector logical instructions
 
9821
-(define_expand "xor<mode>3"
 
9822
-  [(set (match_operand:VEC_L 0 "vlogical_operand" "")
 
9823
-        (xor:VEC_L (match_operand:VEC_L 1 "vlogical_operand" "")
 
9824
-                  (match_operand:VEC_L 2 "vlogical_operand" "")))]
 
9825
-  "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
 
9826
-  "")
 
9827
+;; Vector count leading zeros
 
9828
+(define_expand "clz<mode>2"
 
9829
+  [(set (match_operand:VEC_I 0 "register_operand" "")
 
9830
+       (clz:VEC_I (match_operand:VEC_I 1 "register_operand" "")))]
 
9831
+  "TARGET_P8_VECTOR")
 
9832
 
 
9833
-(define_expand "ior<mode>3"
 
9834
-  [(set (match_operand:VEC_L 0 "vlogical_operand" "")
 
9835
-        (ior:VEC_L (match_operand:VEC_L 1 "vlogical_operand" "")
 
9836
-                  (match_operand:VEC_L 2 "vlogical_operand" "")))]
 
9837
-  "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
 
9838
-  "")
 
9839
+;; Vector population count
 
9840
+(define_expand "popcount<mode>2"
 
9841
+  [(set (match_operand:VEC_I 0 "register_operand" "")
 
9842
+        (popcount:VEC_I (match_operand:VEC_I 1 "register_operand" "")))]
 
9843
+  "TARGET_P8_VECTOR")
 
9844
 
 
9845
-(define_expand "and<mode>3"
 
9846
-  [(set (match_operand:VEC_L 0 "vlogical_operand" "")
 
9847
-        (and:VEC_L (match_operand:VEC_L 1 "vlogical_operand" "")
 
9848
-                  (match_operand:VEC_L 2 "vlogical_operand" "")))]
 
9849
-  "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
 
9850
-  "")
 
9851
-
 
9852
-(define_expand "one_cmpl<mode>2"
 
9853
-  [(set (match_operand:VEC_L 0 "vlogical_operand" "")
 
9854
-        (not:VEC_L (match_operand:VEC_L 1 "vlogical_operand" "")))]
 
9855
-  "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
 
9856
-  "")
 
9857
-
 
9858
-(define_expand "nor<mode>3"
 
9859
-  [(set (match_operand:VEC_L 0 "vlogical_operand" "")
 
9860
-        (not:VEC_L (ior:VEC_L (match_operand:VEC_L 1 "vlogical_operand" "")
 
9861
-                             (match_operand:VEC_L 2 "vlogical_operand" ""))))]
 
9862
-  "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
 
9863
-  "")
 
9864
-
 
9865
-(define_expand "andc<mode>3"
 
9866
-  [(set (match_operand:VEC_L 0 "vlogical_operand" "")
 
9867
-        (and:VEC_L (not:VEC_L (match_operand:VEC_L 2 "vlogical_operand" ""))
 
9868
-                  (match_operand:VEC_L 1 "vlogical_operand" "")))]
 
9869
-  "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
 
9870
-  "")
 
9871
-
 
9872
+
 
9873
 ;; Same size conversions
 
9874
 (define_expand "float<VEC_int><mode>2"
 
9875
   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
 
9876
@@ -889,7 +873,7 @@
 
9877
 {
 
9878
   rtx reg = gen_reg_rtx (V4SFmode);
 
9879
 
 
9880
-  rs6000_expand_interleave (reg, operands[1], operands[1], true);
 
9881
+  rs6000_expand_interleave (reg, operands[1], operands[1], BYTES_BIG_ENDIAN);
 
9882
   emit_insn (gen_vsx_xvcvspdp (operands[0], reg));
 
9883
   DONE;
 
9884
 })
 
9885
@@ -901,7 +885,7 @@
 
9886
 {
 
9887
   rtx reg = gen_reg_rtx (V4SFmode);
 
9888
 
 
9889
-  rs6000_expand_interleave (reg, operands[1], operands[1], false);
 
9890
+  rs6000_expand_interleave (reg, operands[1], operands[1], !BYTES_BIG_ENDIAN);
 
9891
   emit_insn (gen_vsx_xvcvspdp (operands[0], reg));
 
9892
   DONE;
 
9893
 })
 
9894
@@ -913,7 +897,7 @@
 
9895
 {
 
9896
   rtx reg = gen_reg_rtx (V4SImode);
 
9897
 
 
9898
-  rs6000_expand_interleave (reg, operands[1], operands[1], true);
 
9899
+  rs6000_expand_interleave (reg, operands[1], operands[1], BYTES_BIG_ENDIAN);
 
9900
   emit_insn (gen_vsx_xvcvsxwdp (operands[0], reg));
 
9901
   DONE;
 
9902
 })
 
9903
@@ -925,7 +909,7 @@
 
9904
 {
 
9905
   rtx reg = gen_reg_rtx (V4SImode);
 
9906
 
 
9907
-  rs6000_expand_interleave (reg, operands[1], operands[1], false);
 
9908
+  rs6000_expand_interleave (reg, operands[1], operands[1], !BYTES_BIG_ENDIAN);
 
9909
   emit_insn (gen_vsx_xvcvsxwdp (operands[0], reg));
 
9910
   DONE;
 
9911
 })
 
9912
@@ -937,7 +921,7 @@
 
9913
 {
 
9914
   rtx reg = gen_reg_rtx (V4SImode);
 
9915
 
 
9916
-  rs6000_expand_interleave (reg, operands[1], operands[1], true);
 
9917
+  rs6000_expand_interleave (reg, operands[1], operands[1], BYTES_BIG_ENDIAN);
 
9918
   emit_insn (gen_vsx_xvcvuxwdp (operands[0], reg));
 
9919
   DONE;
 
9920
 })
 
9921
@@ -949,7 +933,7 @@
 
9922
 {
 
9923
   rtx reg = gen_reg_rtx (V4SImode);
 
9924
 
 
9925
-  rs6000_expand_interleave (reg, operands[1], operands[1], false);
 
9926
+  rs6000_expand_interleave (reg, operands[1], operands[1], !BYTES_BIG_ENDIAN);
 
9927
   emit_insn (gen_vsx_xvcvuxwdp (operands[0], reg));
 
9928
   DONE;
 
9929
 })
 
9930
@@ -963,8 +947,19 @@
 
9931
    (match_operand:V16QI 3 "vlogical_operand" "")]
 
9932
   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
 
9933
 {
 
9934
-  emit_insn (gen_altivec_vperm_<mode> (operands[0], operands[1], operands[2],
 
9935
-                                      operands[3]));
 
9936
+  if (BYTES_BIG_ENDIAN)
 
9937
+    emit_insn (gen_altivec_vperm_<mode> (operands[0], operands[1],
 
9938
+                                        operands[2], operands[3]));
 
9939
+  else
 
9940
+    {
 
9941
+      /* We have changed lvsr to lvsl, so to complete the transformation
 
9942
+         of vperm for LE, we must swap the inputs.  */
 
9943
+      rtx unspec = gen_rtx_UNSPEC (<MODE>mode,
 
9944
+                                   gen_rtvec (3, operands[2],
 
9945
+                                              operands[1], operands[3]),
 
9946
+                                   UNSPEC_VPERM);
 
9947
+      emit_move_insn (operands[0], unspec);
 
9948
+    }
 
9949
   DONE;
 
9950
 })
 
9951
 
 
9952
@@ -1064,7 +1059,7 @@
 
9953
   [(set (match_operand:VEC_I 0 "vint_operand" "")
 
9954
        (rotate:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
 
9955
                      (match_operand:VEC_I 2 "vint_operand" "")))]
 
9956
-  "TARGET_ALTIVEC"
 
9957
+  "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
 
9958
   "")
 
9959
 
 
9960
 ;; Expanders for arithmetic shift left on each vector element
 
9961
@@ -1072,7 +1067,7 @@
 
9962
   [(set (match_operand:VEC_I 0 "vint_operand" "")
 
9963
        (ashift:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
 
9964
                      (match_operand:VEC_I 2 "vint_operand" "")))]
 
9965
-  "TARGET_ALTIVEC"
 
9966
+  "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
 
9967
   "")
 
9968
 
 
9969
 ;; Expanders for logical shift right on each vector element
 
9970
@@ -1080,7 +1075,7 @@
 
9971
   [(set (match_operand:VEC_I 0 "vint_operand" "")
 
9972
        (lshiftrt:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
 
9973
                        (match_operand:VEC_I 2 "vint_operand" "")))]
 
9974
-  "TARGET_ALTIVEC"
 
9975
+  "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
 
9976
   "")
 
9977
 
 
9978
 ;; Expanders for arithmetic shift right on each vector element
 
9979
@@ -1088,7 +1083,7 @@
 
9980
   [(set (match_operand:VEC_I 0 "vint_operand" "")
 
9981
        (ashiftrt:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
 
9982
                        (match_operand:VEC_I 2 "vint_operand" "")))]
 
9983
-  "TARGET_ALTIVEC"
 
9984
+  "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
 
9985
   "")
 
9986
 
 
9987
 ;; Vector reduction expanders for VSX
 
9988
--- a/src/gcc/config/rs6000/constraints.md
 
9989
+++ b/src/gcc/config/rs6000/constraints.md
 
9990
@@ -52,22 +52,62 @@
 
9991
   "@internal")
 
9992
 
 
9993
 ;; Use w as a prefix to add VSX modes
 
9994
-;; vector double (V2DF)
 
9995
+;; any VSX register
 
9996
+(define_register_constraint "wa" "rs6000_constraints[RS6000_CONSTRAINT_wa]"
 
9997
+  "Any VSX register if the -mvsx option was used or NO_REGS.")
 
9998
+
 
9999
 (define_register_constraint "wd" "rs6000_constraints[RS6000_CONSTRAINT_wd]"
 
10000
-  "@internal")
 
10001
+  "VSX vector register to hold vector double data or NO_REGS.")
 
10002
 
 
10003
-;; vector float (V4SF)
 
10004
 (define_register_constraint "wf" "rs6000_constraints[RS6000_CONSTRAINT_wf]"
 
10005
-  "@internal")
 
10006
+  "VSX vector register to hold vector float data or NO_REGS.")
 
10007
 
 
10008
-;; scalar double (DF)
 
10009
+(define_register_constraint "wg" "rs6000_constraints[RS6000_CONSTRAINT_wg]"
 
10010
+  "If -mmfpgpr was used, a floating point register or NO_REGS.")
 
10011
+
 
10012
+(define_register_constraint "wl" "rs6000_constraints[RS6000_CONSTRAINT_wl]"
 
10013
+  "Floating point register if the LFIWAX instruction is enabled or NO_REGS.")
 
10014
+
 
10015
+(define_register_constraint "wm" "rs6000_constraints[RS6000_CONSTRAINT_wm]"
 
10016
+  "VSX register if direct move instructions are enabled, or NO_REGS.")
 
10017
+
 
10018
+;; NO_REGs register constraint, used to merge mov{sd,sf}, since movsd can use
 
10019
+;; direct move directly, and movsf can't to move between the register sets.
 
10020
+;; There is a mode_attr that resolves to wm for SDmode and wn for SFmode
 
10021
+(define_register_constraint "wn" "NO_REGS" "No register (NO_REGS).")
 
10022
+
 
10023
+(define_register_constraint "wr" "rs6000_constraints[RS6000_CONSTRAINT_wr]"
 
10024
+  "General purpose register if 64-bit instructions are enabled or NO_REGS.")
 
10025
+
 
10026
 (define_register_constraint "ws" "rs6000_constraints[RS6000_CONSTRAINT_ws]"
 
10027
-  "@internal")
 
10028
+  "VSX vector register to hold scalar double values or NO_REGS.")
 
10029
 
 
10030
-;; any VSX register
 
10031
-(define_register_constraint "wa" "rs6000_constraints[RS6000_CONSTRAINT_wa]"
 
10032
-  "@internal")
 
10033
+(define_register_constraint "wt" "rs6000_constraints[RS6000_CONSTRAINT_wt]"
 
10034
+  "VSX vector register to hold 128 bit integer or NO_REGS.")
 
10035
 
 
10036
+(define_register_constraint "wu" "rs6000_constraints[RS6000_CONSTRAINT_wu]"
 
10037
+  "Altivec register to use for float/32-bit int loads/stores  or NO_REGS.")
 
10038
+
 
10039
+(define_register_constraint "wv" "rs6000_constraints[RS6000_CONSTRAINT_wv]"
 
10040
+  "Altivec register to use for double loads/stores  or NO_REGS.")
 
10041
+
 
10042
+(define_register_constraint "ww" "rs6000_constraints[RS6000_CONSTRAINT_ww]"
 
10043
+  "FP or VSX register to perform float operations under -mvsx or NO_REGS.")
 
10044
+
 
10045
+(define_register_constraint "wx" "rs6000_constraints[RS6000_CONSTRAINT_wx]"
 
10046
+  "Floating point register if the STFIWX instruction is enabled or NO_REGS.")
 
10047
+
 
10048
+(define_register_constraint "wy" "rs6000_constraints[RS6000_CONSTRAINT_wy]"
 
10049
+  "VSX vector register to hold scalar float values or NO_REGS.")
 
10050
+
 
10051
+(define_register_constraint "wz" "rs6000_constraints[RS6000_CONSTRAINT_wz]"
 
10052
+  "Floating point register if the LFIWZX instruction is enabled or NO_REGS.")
 
10053
+
 
10054
+;; Lq/stq validates the address for load/store quad
 
10055
+(define_memory_constraint "wQ"
 
10056
+  "Memory operand suitable for the load/store quad instructions"
 
10057
+  (match_operand 0 "quad_memory_operand"))
 
10058
+
 
10059
 ;; Altivec style load/store that ignores the bottom bits of the address
 
10060
 (define_memory_constraint "wZ"
 
10061
   "Indexed or indirect memory operand, ignoring the bottom 4 bits"
 
10062
--- a/src/gcc/config/rs6000/predicates.md
 
10063
+++ b/src/gcc/config/rs6000/predicates.md
 
10064
@@ -124,6 +124,11 @@
 
10065
   (and (match_code "const_int")
 
10066
        (match_test "INTVAL (op) >= -16 && INTVAL (op) <= 15")))
 
10067
 
 
10068
+;; Return 1 if op is a unsigned 3-bit constant integer.
 
10069
+(define_predicate "u3bit_cint_operand"
 
10070
+  (and (match_code "const_int")
 
10071
+       (match_test "INTVAL (op) >= 0 && INTVAL (op) <= 7")))
 
10072
+
 
10073
 ;; Return 1 if op is a unsigned 5-bit constant integer.
 
10074
 (define_predicate "u5bit_cint_operand"
 
10075
   (and (match_code "const_int")
 
10076
@@ -135,6 +140,11 @@
 
10077
   (and (match_code "const_int")
 
10078
        (match_test "INTVAL (op) >= -128 && INTVAL (op) <= 127")))
 
10079
 
 
10080
+;; Return 1 if op is a unsigned 10-bit constant integer.
 
10081
+(define_predicate "u10bit_cint_operand"
 
10082
+  (and (match_code "const_int")
 
10083
+       (match_test "INTVAL (op) >= 0 && INTVAL (op) <= 1023")))
 
10084
+
 
10085
 ;; Return 1 if op is a constant integer that can fit in a D field.
 
10086
 (define_predicate "short_cint_operand"
 
10087
   (and (match_code "const_int")
 
10088
@@ -166,6 +176,11 @@
 
10089
   (and (match_code "const_int")
 
10090
        (match_test "IN_RANGE (INTVAL (op), 2, 3)")))
 
10091
 
 
10092
+;; Match op = 0..15
 
10093
+(define_predicate "const_0_to_15_operand"
 
10094
+  (and (match_code "const_int")
 
10095
+       (match_test "IN_RANGE (INTVAL (op), 0, 15)")))
 
10096
+
 
10097
 ;; Return 1 if op is a register that is not special.
 
10098
 (define_predicate "gpc_reg_operand"
 
10099
   (match_operand 0 "register_operand")
 
10100
@@ -182,9 +197,95 @@
 
10101
   if (REGNO (op) >= ARG_POINTER_REGNUM && !CA_REGNO_P (REGNO (op)))
 
10102
     return 1;
 
10103
 
 
10104
+  if (TARGET_VSX && VSX_REGNO_P (REGNO (op)))
 
10105
+    return 1;
 
10106
+
 
10107
   return INT_REGNO_P (REGNO (op)) || FP_REGNO_P (REGNO (op));
 
10108
 })
 
10109
 
 
10110
+;; Return 1 if op is a general purpose register.  Unlike gpc_reg_operand, don't
 
10111
+;; allow floating point or vector registers.
 
10112
+(define_predicate "int_reg_operand"
 
10113
+  (match_operand 0 "register_operand")
 
10114
+{
 
10115
+  if ((TARGET_E500_DOUBLE || TARGET_SPE) && invalid_e500_subreg (op, mode))
 
10116
+    return 0;
 
10117
+
 
10118
+  if (GET_CODE (op) == SUBREG)
 
10119
+    op = SUBREG_REG (op);
 
10120
+
 
10121
+  if (!REG_P (op))
 
10122
+    return 0;
 
10123
+
 
10124
+  if (REGNO (op) >= FIRST_PSEUDO_REGISTER)
 
10125
+    return 1;
 
10126
+
 
10127
+  return INT_REGNO_P (REGNO (op));
 
10128
+})
 
10129
+
 
10130
+;; Like int_reg_operand, but only return true for base registers
 
10131
+(define_predicate "base_reg_operand"
 
10132
+  (match_operand 0 "int_reg_operand")
 
10133
+{
 
10134
+  if (GET_CODE (op) == SUBREG)
 
10135
+    op = SUBREG_REG (op);
 
10136
+
 
10137
+  if (!REG_P (op))
 
10138
+    return 0;
 
10139
+
 
10140
+  return (REGNO (op) != FIRST_GPR_REGNO);
 
10141
+})
 
10142
+
 
10143
+;; Return 1 if op is a HTM specific SPR register.
 
10144
+(define_predicate "htm_spr_reg_operand"
 
10145
+  (match_operand 0 "register_operand")
 
10146
+{
 
10147
+  if (!TARGET_HTM)
 
10148
+    return 0;
 
10149
+
 
10150
+  if (GET_CODE (op) == SUBREG)
 
10151
+    op = SUBREG_REG (op);
 
10152
+
 
10153
+  if (!REG_P (op))
 
10154
+    return 0;
 
10155
+
 
10156
+  switch (REGNO (op))
 
10157
+    {
 
10158
+      case TFHAR_REGNO:
 
10159
+      case TFIAR_REGNO:
 
10160
+      case TEXASR_REGNO:
 
10161
+       return 1;
 
10162
+      default:
 
10163
+       break;
 
10164
+    }
 
10165
+  
 
10166
+  /* Unknown SPR.  */
 
10167
+  return 0;
 
10168
+})
 
10169
+
 
10170
+;; Return 1 if op is a general purpose register that is an even register
 
10171
+;; which suitable for a load/store quad operation
 
10172
+(define_predicate "quad_int_reg_operand"
 
10173
+  (match_operand 0 "register_operand")
 
10174
+{
 
10175
+  HOST_WIDE_INT r;
 
10176
+
 
10177
+  if (!TARGET_QUAD_MEMORY)
 
10178
+    return 0;
 
10179
+
 
10180
+  if (GET_CODE (op) == SUBREG)
 
10181
+    op = SUBREG_REG (op);
 
10182
+
 
10183
+  if (!REG_P (op))
 
10184
+    return 0;
 
10185
+
 
10186
+  r = REGNO (op);
 
10187
+  if (r >= FIRST_PSEUDO_REGISTER)
 
10188
+    return 1;
 
10189
+
 
10190
+  return (INT_REGNO_P (r) && ((r & 1) == 0));
 
10191
+})
 
10192
+
 
10193
 ;; Return 1 if op is a register that is a condition register field.
 
10194
 (define_predicate "cc_reg_operand"
 
10195
   (match_operand 0 "register_operand")
 
10196
@@ -315,6 +416,11 @@
 
10197
                   && CONST_DOUBLE_HIGH (op) == 0")
 
10198
       (match_operand 0 "gpc_reg_operand"))))
 
10199
 
 
10200
+;; Like reg_or_logical_cint_operand, but allow vsx registers
 
10201
+(define_predicate "vsx_reg_or_cint_operand"
 
10202
+  (ior (match_operand 0 "vsx_register_operand")
 
10203
+       (match_operand 0 "reg_or_logical_cint_operand")))
 
10204
+
 
10205
 ;; Return 1 if operand is a CONST_DOUBLE that can be set in a register
 
10206
 ;; with no more than one instruction per word.
 
10207
 (define_predicate "easy_fp_constant"
 
10208
@@ -333,6 +439,11 @@
 
10209
       && mode != DImode)
 
10210
     return 1;
 
10211
 
 
10212
+  /* The constant 0.0 is easy under VSX.  */
 
10213
+  if ((mode == SFmode || mode == DFmode || mode == SDmode || mode == DDmode)
 
10214
+      && VECTOR_UNIT_VSX_P (DFmode) && op == CONST0_RTX (mode))
 
10215
+    return 1;
 
10216
+
 
10217
   if (DECIMAL_FLOAT_MODE_P (mode))
 
10218
     return 0;
 
10219
 
 
10220
@@ -521,6 +632,54 @@
 
10221
   (and (match_operand 0 "memory_operand")
 
10222
        (match_test "offsettable_nonstrict_memref_p (op)")))
 
10223
 
 
10224
+;; Return 1 if the operand is suitable for load/store quad memory.
 
10225
+(define_predicate "quad_memory_operand"
 
10226
+  (match_code "mem")
 
10227
+{
 
10228
+  rtx addr, op0, op1;
 
10229
+  int ret;
 
10230
+
 
10231
+  if (!TARGET_QUAD_MEMORY)
 
10232
+    ret = 0;
 
10233
+
 
10234
+  else if (!memory_operand (op, mode))
 
10235
+    ret = 0;
 
10236
+
 
10237
+  else if (GET_MODE_SIZE (GET_MODE (op)) != 16)
 
10238
+    ret = 0;
 
10239
+
 
10240
+  else if (MEM_ALIGN (op) < 128)
 
10241
+    ret = 0;
 
10242
+
 
10243
+  else
 
10244
+    {
 
10245
+      addr = XEXP (op, 0);
 
10246
+      if (int_reg_operand (addr, Pmode))
 
10247
+       ret = 1;
 
10248
+
 
10249
+      else if (GET_CODE (addr) != PLUS)
 
10250
+       ret = 0;
 
10251
+
 
10252
+      else
 
10253
+       {
 
10254
+         op0 = XEXP (addr, 0);
 
10255
+         op1 = XEXP (addr, 1);
 
10256
+         ret = (int_reg_operand (op0, Pmode)
 
10257
+                && GET_CODE (op1) == CONST_INT
 
10258
+                && IN_RANGE (INTVAL (op1), -32768, 32767)
 
10259
+                && (INTVAL (op1) & 15) == 0);
 
10260
+       }
 
10261
+    }
 
10262
+
 
10263
+  if (TARGET_DEBUG_ADDR)
 
10264
+    {
 
10265
+      fprintf (stderr, "\nquad_memory_operand, ret = %s\n", ret ? "true" : "false");
 
10266
+      debug_rtx (op);
 
10267
+    }
 
10268
+
 
10269
+  return ret;
 
10270
+})
 
10271
+
 
10272
 ;; Return 1 if the operand is an indexed or indirect memory operand.
 
10273
 (define_predicate "indexed_or_indirect_operand"
 
10274
   (match_code "mem")
 
10275
@@ -535,6 +694,19 @@
 
10276
   return indexed_or_indirect_address (op, mode);
 
10277
 })
 
10278
 
 
10279
+;; Like indexed_or_indirect_operand, but also allow a GPR register if direct
 
10280
+;; moves are supported.
 
10281
+(define_predicate "reg_or_indexed_operand"
 
10282
+  (match_code "mem,reg")
 
10283
+{
 
10284
+  if (MEM_P (op))
 
10285
+    return indexed_or_indirect_operand (op, mode);
 
10286
+  else if (TARGET_DIRECT_MOVE)
 
10287
+    return register_operand (op, mode);
 
10288
+  return
 
10289
+    0;
 
10290
+})
 
10291
+
 
10292
 ;; Return 1 if the operand is an indexed or indirect memory operand with an
 
10293
 ;; AND -16 in it, used to recognize when we need to switch to Altivec loads
 
10294
 ;; to realign loops instead of VSX (altivec silently ignores the bottom bits,
 
10295
@@ -560,6 +732,28 @@
 
10296
                        && REG_P (XEXP (op, 1)))")
 
10297
        (match_operand 0 "address_operand")))
 
10298
 
 
10299
+;; Return 1 if the operand is an index-form address.
 
10300
+(define_special_predicate "indexed_address"
 
10301
+  (match_test "(GET_CODE (op) == PLUS
 
10302
+               && REG_P (XEXP (op, 0))
 
10303
+               && REG_P (XEXP (op, 1)))"))
 
10304
+
 
10305
+;; Return 1 if the operand is a MEM with an update-form address. This may
 
10306
+;; also include update-indexed form.
 
10307
+(define_special_predicate "update_address_mem"
 
10308
+  (match_test "(MEM_P (op)
 
10309
+               && (GET_CODE (XEXP (op, 0)) == PRE_INC
 
10310
+                   || GET_CODE (XEXP (op, 0)) == PRE_DEC
 
10311
+                   || GET_CODE (XEXP (op, 0)) == PRE_MODIFY))"))
 
10312
+
 
10313
+;; Return 1 if the operand is a MEM with an update-indexed-form address. Note
 
10314
+;; that PRE_INC/PRE_DEC will always be non-indexed (i.e. non X-form) since the
 
10315
+;; increment is based on the mode size and will therefor always be a const.
 
10316
+(define_special_predicate "update_indexed_address_mem"
 
10317
+  (match_test "(MEM_P (op)
 
10318
+               && GET_CODE (XEXP (op, 0)) == PRE_MODIFY
 
10319
+               && indexed_address (XEXP (XEXP (op, 0), 1), mode))"))
 
10320
+
 
10321
 ;; Used for the destination of the fix_truncdfsi2 expander.
 
10322
 ;; If stfiwx will be used, the result goes to memory; otherwise,
 
10323
 ;; we're going to emit a store and a load of a subreg, so the dest is a
 
10324
@@ -883,7 +1077,8 @@
 
10325
   (and (match_code "symbol_ref")
 
10326
        (match_test "(DEFAULT_ABI != ABI_AIX || SYMBOL_REF_FUNCTION_P (op))
 
10327
                    && ((SYMBOL_REF_LOCAL_P (op)
 
10328
-                        && (DEFAULT_ABI != ABI_AIX
 
10329
+                        && ((DEFAULT_ABI != ABI_AIX
 
10330
+                             && DEFAULT_ABI != ABI_ELFv2)
 
10331
                             || !SYMBOL_REF_EXTERNAL_P (op)))
 
10332
                        || (op == XEXP (DECL_RTL (current_function_decl),
 
10333
                                                  0)))")))
 
10334
@@ -1364,6 +1559,26 @@
 
10335
   return 1;
 
10336
 })
 
10337
 
 
10338
+;; Return 1 if OP is valid for crsave insn, known to be a PARALLEL.
 
10339
+(define_predicate "crsave_operation"
 
10340
+  (match_code "parallel")
 
10341
+{
 
10342
+  int count = XVECLEN (op, 0);
 
10343
+  int i;
 
10344
+
 
10345
+  for (i = 1; i < count; i++)
 
10346
+    {
 
10347
+      rtx exp = XVECEXP (op, 0, i);
 
10348
+
 
10349
+      if (GET_CODE (exp) != USE
 
10350
+         || GET_CODE (XEXP (exp, 0)) != REG
 
10351
+         || GET_MODE (XEXP (exp, 0)) != CCmode
 
10352
+         || ! CR_REGNO_P (REGNO (XEXP (exp, 0))))
 
10353
+       return 0;
 
10354
+    }
 
10355
+  return 1;
 
10356
+})
 
10357
+
 
10358
 ;; Return 1 if OP is valid for lmw insn, known to be a PARALLEL.
 
10359
 (define_predicate "lmw_operation"
 
10360
   (match_code "parallel")
 
10361
@@ -1534,3 +1749,99 @@
 
10362
 
 
10363
   return GET_CODE (op) == UNSPEC && XINT (op, 1) == UNSPEC_TOCREL;
 
10364
 })
 
10365
+
 
10366
+;; Match the first insn (addis) in fusing the combination of addis and loads to
 
10367
+;; GPR registers on power8.
 
10368
+(define_predicate "fusion_gpr_addis"
 
10369
+  (match_code "const_int,high,plus")
 
10370
+{
 
10371
+  HOST_WIDE_INT value;
 
10372
+  rtx int_const;
 
10373
+
 
10374
+  if (GET_CODE (op) == HIGH)
 
10375
+    return 1;
 
10376
+
 
10377
+  if (CONST_INT_P (op))
 
10378
+    int_const = op;
 
10379
+
 
10380
+  else if (GET_CODE (op) == PLUS
 
10381
+          && base_reg_operand (XEXP (op, 0), Pmode)
 
10382
+          && CONST_INT_P (XEXP (op, 1)))
 
10383
+    int_const = XEXP (op, 1);
 
10384
+
 
10385
+  else
 
10386
+    return 0;
 
10387
+
 
10388
+  /* Power8 currently will only do the fusion if the top 11 bits of the addis
 
10389
+     value are all 1's or 0's.  */
 
10390
+  value = INTVAL (int_const);
 
10391
+  if ((value & (HOST_WIDE_INT)0xffff) != 0)
 
10392
+    return 0;
 
10393
+
 
10394
+  if ((value & (HOST_WIDE_INT)0xffff0000) == 0)
 
10395
+    return 0;
 
10396
+
 
10397
+  return (IN_RANGE (value >> 16, -32, 31));
 
10398
+})
 
10399
+
 
10400
+;; Match the second insn (lbz, lhz, lwz, ld) in fusing the combination of addis
 
10401
+;; and loads to GPR registers on power8.
 
10402
+(define_predicate "fusion_gpr_mem_load"
 
10403
+  (match_code "mem,sign_extend,zero_extend")
 
10404
+{
 
10405
+  rtx addr;
 
10406
+
 
10407
+  /* Handle sign/zero extend.  */
 
10408
+  if (GET_CODE (op) == ZERO_EXTEND
 
10409
+      || (TARGET_P8_FUSION_SIGN && GET_CODE (op) == SIGN_EXTEND))
 
10410
+    {
 
10411
+      op = XEXP (op, 0);
 
10412
+      mode = GET_MODE (op);
 
10413
+    }
 
10414
+
 
10415
+  if (!MEM_P (op))
 
10416
+    return 0;
 
10417
+
 
10418
+  switch (mode)
 
10419
+    {
 
10420
+    case QImode:
 
10421
+    case HImode:
 
10422
+    case SImode:
 
10423
+      break;
 
10424
+
 
10425
+    case DImode:
 
10426
+      if (!TARGET_POWERPC64)
 
10427
+       return 0;
 
10428
+      break;
 
10429
+
 
10430
+    default:
 
10431
+      return 0;
 
10432
+    }
 
10433
+
 
10434
+  addr = XEXP (op, 0);
 
10435
+  if (GET_CODE (addr) == PLUS)
 
10436
+    {
 
10437
+      rtx base = XEXP (addr, 0);
 
10438
+      rtx offset = XEXP (addr, 1);
 
10439
+
 
10440
+      return (base_reg_operand (base, GET_MODE (base))
 
10441
+             && satisfies_constraint_I (offset));
 
10442
+    }
 
10443
+
 
10444
+  else if (GET_CODE (addr) == LO_SUM)
 
10445
+    {
 
10446
+      rtx base = XEXP (addr, 0);
 
10447
+      rtx offset = XEXP (addr, 1);
 
10448
+
 
10449
+      if (!base_reg_operand (base, GET_MODE (base)))
 
10450
+       return 0;
 
10451
+
 
10452
+      else if (TARGET_XCOFF || (TARGET_ELF && TARGET_POWERPC64))
 
10453
+       return small_toc_ref (offset, GET_MODE (offset));
 
10454
+
 
10455
+      else if (TARGET_ELF && !TARGET_POWERPC64)
 
10456
+       return CONSTANT_P (offset);
 
10457
+    }
 
10458
+
 
10459
+  return 0;
 
10460
+})
 
10461
--- a/src/gcc/config/rs6000/ppc-asm.h
 
10462
+++ b/src/gcc/config/rs6000/ppc-asm.h
 
10463
@@ -256,7 +256,30 @@
 
10464
  * the real function with one or two leading periods respectively.
 
10465
  */
 
10466
 
 
10467
-#if defined (__powerpc64__)
 
10468
+#if defined(__powerpc64__) && _CALL_ELF == 2
 
10469
+
 
10470
+/* Defining "toc" above breaks @toc in assembler code.  */
 
10471
+#undef toc
 
10472
+
 
10473
+#define FUNC_NAME(name) GLUE(__USER_LABEL_PREFIX__,name)
 
10474
+#define JUMP_TARGET(name) FUNC_NAME(name)
 
10475
+#define FUNC_START(name) \
 
10476
+       .type FUNC_NAME(name),@function; \
 
10477
+       .globl FUNC_NAME(name); \
 
10478
+FUNC_NAME(name): \
 
10479
+0:     addis 2,12,(.TOC.-0b)@ha; \
 
10480
+       addi 2,2,(.TOC.-0b)@l; \
 
10481
+       .localentry FUNC_NAME(name),.-FUNC_NAME(name)
 
10482
+
 
10483
+#define HIDDEN_FUNC(name) \
 
10484
+  FUNC_START(name) \
 
10485
+  .hidden FUNC_NAME(name);
 
10486
+
 
10487
+#define FUNC_END(name) \
 
10488
+       .size FUNC_NAME(name),.-FUNC_NAME(name)
 
10489
+
 
10490
+#elif defined (__powerpc64__)
 
10491
+
 
10492
 #define FUNC_NAME(name) GLUE(.,name)
 
10493
 #define JUMP_TARGET(name) FUNC_NAME(name)
 
10494
 #define FUNC_START(name) \
 
10495
--- a/src/gcc/config/rs6000/htm.md
 
10496
+++ b/src/gcc/config/rs6000/htm.md
 
10497
@@ -0,0 +1,366 @@
 
10498
+;; Hardware Transactional Memory (HTM) patterns.
 
10499
+;; Copyright (C) 2013 Free Software Foundation, Inc.
 
10500
+;; Contributed by Peter Bergner <bergner@vnet.ibm.com>.
 
10501
+
 
10502
+;; This file is part of GCC.
 
10503
+
 
10504
+;; GCC is free software; you can redistribute it and/or modify it
 
10505
+;; under the terms of the GNU General Public License as published
 
10506
+;; by the Free Software Foundation; either version 3, or (at your
 
10507
+;; option) any later version.
 
10508
+
 
10509
+;; GCC is distributed in the hope that it will be useful, but WITHOUT
 
10510
+;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 
10511
+;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
 
10512
+;; License for more details.
 
10513
+
 
10514
+;; You should have received a copy of the GNU General Public License
 
10515
+;; along with GCC; see the file COPYING3.  If not see
 
10516
+;; <http://www.gnu.org/licenses/>.
 
10517
+
 
10518
+(define_constants
 
10519
+  [(TFHAR_SPR          128)
 
10520
+   (TFIAR_SPR          129)
 
10521
+   (TEXASR_SPR         130)
 
10522
+   (TEXASRU_SPR                131)
 
10523
+   (MAX_HTM_OPERANDS   4)
 
10524
+  ])
 
10525
+
 
10526
+;;
 
10527
+;; UNSPEC_VOLATILE usage
 
10528
+;;
 
10529
+
 
10530
+(define_c_enum "unspecv"
 
10531
+  [UNSPECV_HTM_TABORT
 
10532
+   UNSPECV_HTM_TABORTDC
 
10533
+   UNSPECV_HTM_TABORTDCI
 
10534
+   UNSPECV_HTM_TABORTWC
 
10535
+   UNSPECV_HTM_TABORTWCI
 
10536
+   UNSPECV_HTM_TBEGIN
 
10537
+   UNSPECV_HTM_TCHECK
 
10538
+   UNSPECV_HTM_TEND
 
10539
+   UNSPECV_HTM_TRECHKPT
 
10540
+   UNSPECV_HTM_TRECLAIM
 
10541
+   UNSPECV_HTM_TSR
 
10542
+   UNSPECV_HTM_MFSPR
 
10543
+   UNSPECV_HTM_MTSPR
 
10544
+  ])
 
10545
+
 
10546
+
 
10547
+(define_expand "tabort"
 
10548
+  [(set (match_dup 2)
 
10549
+       (unspec_volatile:CC [(match_operand:SI 1 "int_reg_operand" "")]
 
10550
+                           UNSPECV_HTM_TABORT))
 
10551
+   (set (match_dup 3)
 
10552
+       (eq:SI (match_dup 2)
 
10553
+              (const_int 0)))
 
10554
+   (set (match_operand:SI 0 "int_reg_operand" "")
 
10555
+       (minus:SI (const_int 1) (match_dup 3)))]
 
10556
+  "TARGET_HTM"
 
10557
+{
 
10558
+  operands[2] = gen_rtx_REG (CCmode, CR0_REGNO);
 
10559
+  operands[3] = gen_reg_rtx (SImode);
 
10560
+})
 
10561
+
 
10562
+(define_insn "*tabort_internal"
 
10563
+  [(set (match_operand:CC 1 "cc_reg_operand" "=x")
 
10564
+       (unspec_volatile:CC [(match_operand:SI 0 "int_reg_operand" "r")]
 
10565
+                           UNSPECV_HTM_TABORT))]
 
10566
+  "TARGET_HTM"
 
10567
+  "tabort. %0"
 
10568
+  [(set_attr "type" "htm")
 
10569
+   (set_attr "length" "4")])
 
10570
+
 
10571
+(define_expand "tabortdc"
 
10572
+  [(set (match_dup 4)
 
10573
+       (unspec_volatile:CC [(match_operand 1 "u5bit_cint_operand" "n")
 
10574
+                            (match_operand:SI 2 "gpc_reg_operand" "r")
 
10575
+                            (match_operand:SI 3 "gpc_reg_operand" "r")]
 
10576
+                           UNSPECV_HTM_TABORTDC))
 
10577
+   (set (match_dup 5)
 
10578
+       (eq:SI (match_dup 4)
 
10579
+              (const_int 0)))
 
10580
+   (set (match_operand:SI 0 "int_reg_operand" "")
 
10581
+       (minus:SI (const_int 1) (match_dup 5)))]
 
10582
+  "TARGET_HTM"
 
10583
+{
 
10584
+  operands[4] = gen_rtx_REG (CCmode, CR0_REGNO);
 
10585
+  operands[5] = gen_reg_rtx (SImode);
 
10586
+})
 
10587
+
 
10588
+(define_insn "*tabortdc_internal"
 
10589
+  [(set (match_operand:CC 3 "cc_reg_operand" "=x")
 
10590
+       (unspec_volatile:CC [(match_operand 0 "u5bit_cint_operand" "n")
 
10591
+                            (match_operand:SI 1 "gpc_reg_operand" "r")
 
10592
+                            (match_operand:SI 2 "gpc_reg_operand" "r")]
 
10593
+                           UNSPECV_HTM_TABORTDC))]
 
10594
+  "TARGET_HTM"
 
10595
+  "tabortdc. %0,%1,%2"
 
10596
+  [(set_attr "type" "htm")
 
10597
+   (set_attr "length" "4")])
 
10598
+
 
10599
+(define_expand "tabortdci"
 
10600
+  [(set (match_dup 4)
 
10601
+       (unspec_volatile:CC [(match_operand 1 "u5bit_cint_operand" "n")
 
10602
+                            (match_operand:SI 2 "gpc_reg_operand" "r")
 
10603
+                            (match_operand 3 "s5bit_cint_operand" "n")]
 
10604
+                           UNSPECV_HTM_TABORTDCI))
 
10605
+   (set (match_dup 5)
 
10606
+       (eq:SI (match_dup 4)
 
10607
+              (const_int 0)))
 
10608
+   (set (match_operand:SI 0 "int_reg_operand" "")
 
10609
+       (minus:SI (const_int 1) (match_dup 5)))]
 
10610
+  "TARGET_HTM"
 
10611
+{
 
10612
+  operands[4] = gen_rtx_REG (CCmode, CR0_REGNO);
 
10613
+  operands[5] = gen_reg_rtx (SImode);
 
10614
+})
 
10615
+
 
10616
+(define_insn "*tabortdci_internal"
 
10617
+  [(set (match_operand:CC 3 "cc_reg_operand" "=x")
 
10618
+       (unspec_volatile:CC [(match_operand 0 "u5bit_cint_operand" "n")
 
10619
+                            (match_operand:SI 1 "gpc_reg_operand" "r")
 
10620
+                            (match_operand 2 "s5bit_cint_operand" "n")]
 
10621
+                           UNSPECV_HTM_TABORTDCI))]
 
10622
+  "TARGET_HTM"
 
10623
+  "tabortdci. %0,%1,%2"
 
10624
+  [(set_attr "type" "htm")
 
10625
+   (set_attr "length" "4")])
 
10626
+
 
10627
+(define_expand "tabortwc"
 
10628
+  [(set (match_dup 4)
 
10629
+       (unspec_volatile:CC [(match_operand 1 "u5bit_cint_operand" "n")
 
10630
+                            (match_operand:SI 2 "gpc_reg_operand" "r")
 
10631
+                            (match_operand:SI 3 "gpc_reg_operand" "r")]
 
10632
+                           UNSPECV_HTM_TABORTWC))
 
10633
+   (set (match_dup 5)
 
10634
+       (eq:SI (match_dup 4)
 
10635
+              (const_int 0)))
 
10636
+   (set (match_operand:SI 0 "int_reg_operand" "")
 
10637
+       (minus:SI (const_int 1) (match_dup 5)))]
 
10638
+  "TARGET_HTM"
 
10639
+{
 
10640
+  operands[4] = gen_rtx_REG (CCmode, CR0_REGNO);
 
10641
+  operands[5] = gen_reg_rtx (SImode);
 
10642
+})
 
10643
+
 
10644
+(define_insn "*tabortwc_internal"
 
10645
+  [(set (match_operand:CC 3 "cc_reg_operand" "=x")
 
10646
+       (unspec_volatile:CC [(match_operand 0 "u5bit_cint_operand" "n")
 
10647
+                            (match_operand:SI 1 "gpc_reg_operand" "r")
 
10648
+                            (match_operand:SI 2 "gpc_reg_operand" "r")]
 
10649
+                           UNSPECV_HTM_TABORTWC))]
 
10650
+  "TARGET_HTM"
 
10651
+  "tabortwc. %0,%1,%2"
 
10652
+  [(set_attr "type" "htm")
 
10653
+   (set_attr "length" "4")])
 
10654
+
 
10655
+(define_expand "tabortwci"
 
10656
+  [(set (match_dup 4)
 
10657
+       (unspec_volatile:CC [(match_operand 1 "u5bit_cint_operand" "n")
 
10658
+                            (match_operand:SI 2 "gpc_reg_operand" "r")
 
10659
+                            (match_operand 3 "s5bit_cint_operand" "n")]
 
10660
+                           UNSPECV_HTM_TABORTWCI))
 
10661
+   (set (match_dup 5)
 
10662
+       (eq:SI (match_dup 4)
 
10663
+              (const_int 0)))
 
10664
+   (set (match_operand:SI 0 "int_reg_operand" "")
 
10665
+       (minus:SI (const_int 1) (match_dup 5)))]
 
10666
+  "TARGET_HTM"
 
10667
+{
 
10668
+  operands[4] = gen_rtx_REG (CCmode, CR0_REGNO);
 
10669
+  operands[5] = gen_reg_rtx (SImode);
 
10670
+})
 
10671
+
 
10672
+(define_expand "ttest"
 
10673
+  [(set (match_dup 1)
 
10674
+       (unspec_volatile:CC [(const_int 0)
 
10675
+                            (reg:SI 0)
 
10676
+                            (const_int 0)]
 
10677
+                           UNSPECV_HTM_TABORTWCI))
 
10678
+   (set (subreg:CC (match_dup 2) 0) (match_dup 1))
 
10679
+   (set (match_dup 3) (lshiftrt:SI (match_dup 2) (const_int 24)))
 
10680
+   (parallel [(set (match_operand:SI 0 "int_reg_operand" "")
 
10681
+                  (and:SI (match_dup 3) (const_int 15)))
 
10682
+              (clobber (scratch:CC))])]
 
10683
+  "TARGET_HTM"
 
10684
+{
 
10685
+  operands[1] = gen_rtx_REG (CCmode, CR0_REGNO);
 
10686
+  operands[2] = gen_reg_rtx (SImode);
 
10687
+  operands[3] = gen_reg_rtx (SImode);
 
10688
+})
 
10689
+
 
10690
+(define_insn "*tabortwci_internal"
 
10691
+  [(set (match_operand:CC 3 "cc_reg_operand" "=x")
 
10692
+       (unspec_volatile:CC [(match_operand 0 "u5bit_cint_operand" "n")
 
10693
+                            (match_operand:SI 1 "gpc_reg_operand" "r")
 
10694
+                            (match_operand 2 "s5bit_cint_operand" "n")]
 
10695
+                           UNSPECV_HTM_TABORTWCI))]
 
10696
+  "TARGET_HTM"
 
10697
+  "tabortwci. %0,%1,%2"
 
10698
+  [(set_attr "type" "htm")
 
10699
+   (set_attr "length" "4")])
 
10700
+
 
10701
+(define_expand "tbegin"
 
10702
+  [(set (match_dup 2)
 
10703
+       (unspec_volatile:CC [(match_operand 1 "const_0_to_1_operand" "n")]
 
10704
+                           UNSPECV_HTM_TBEGIN))
 
10705
+   (set (match_dup 3)
 
10706
+       (eq:SI (match_dup 2)
 
10707
+              (const_int 0)))
 
10708
+   (set (match_operand:SI 0 "int_reg_operand" "")
 
10709
+       (minus:SI (const_int 1) (match_dup 3)))]
 
10710
+  "TARGET_HTM"
 
10711
+{
 
10712
+  operands[2] = gen_rtx_REG (CCmode, CR0_REGNO);
 
10713
+  operands[3] = gen_reg_rtx (SImode);
 
10714
+})
 
10715
+
 
10716
+(define_insn "*tbegin_internal"
 
10717
+  [(set (match_operand:CC 1 "cc_reg_operand" "=x")
 
10718
+       (unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
 
10719
+                           UNSPECV_HTM_TBEGIN))]
 
10720
+  "TARGET_HTM"
 
10721
+  "tbegin. %0"
 
10722
+  [(set_attr "type" "htm")
 
10723
+   (set_attr "length" "4")])
 
10724
+
 
10725
+(define_expand "tcheck"
 
10726
+  [(set (match_dup 2)
 
10727
+       (unspec_volatile:CC [(match_operand 1 "u3bit_cint_operand" "n")]
 
10728
+                           UNSPECV_HTM_TCHECK))
 
10729
+   (set (match_dup 3)
 
10730
+       (eq:SI (match_dup 2)
 
10731
+              (const_int 0)))
 
10732
+   (set (match_operand:SI 0 "int_reg_operand" "")
 
10733
+       (minus:SI (const_int 1) (match_dup 3)))]
 
10734
+  "TARGET_HTM"
 
10735
+{
 
10736
+  operands[2] = gen_rtx_REG (CCmode, CR0_REGNO);
 
10737
+  operands[3] = gen_reg_rtx (SImode);
 
10738
+})
 
10739
+
 
10740
+(define_insn "*tcheck_internal"
 
10741
+  [(set (match_operand:CC 1 "cc_reg_operand" "=x")
 
10742
+       (unspec_volatile:CC [(match_operand 0 "u3bit_cint_operand" "n")]
 
10743
+                           UNSPECV_HTM_TCHECK))]
 
10744
+  "TARGET_HTM"
 
10745
+  "tcheck. %0"
 
10746
+  [(set_attr "type" "htm")
 
10747
+   (set_attr "length" "4")])
 
10748
+
 
10749
+(define_expand "tend"
 
10750
+  [(set (match_dup 2)
 
10751
+       (unspec_volatile:CC [(match_operand 1 "const_0_to_1_operand" "n")]
 
10752
+                           UNSPECV_HTM_TEND))
 
10753
+   (set (match_dup 3)
 
10754
+       (eq:SI (match_dup 2)
 
10755
+              (const_int 0)))
 
10756
+   (set (match_operand:SI 0 "int_reg_operand" "")
 
10757
+       (minus:SI (const_int 1) (match_dup 3)))]
 
10758
+  "TARGET_HTM"
 
10759
+{
 
10760
+  operands[2] = gen_rtx_REG (CCmode, CR0_REGNO);
 
10761
+  operands[3] = gen_reg_rtx (SImode);
 
10762
+})
 
10763
+
 
10764
+(define_insn "*tend_internal"
 
10765
+  [(set (match_operand:CC 1 "cc_reg_operand" "=x")
 
10766
+       (unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
 
10767
+                           UNSPECV_HTM_TEND))]
 
10768
+  "TARGET_HTM"
 
10769
+  "tend. %0"
 
10770
+  [(set_attr "type" "htm")
 
10771
+   (set_attr "length" "4")])
 
10772
+
 
10773
+(define_expand "trechkpt"
 
10774
+  [(set (match_dup 1)
 
10775
+       (unspec_volatile:CC [(const_int 0)]
 
10776
+                           UNSPECV_HTM_TRECHKPT))
 
10777
+   (set (match_dup 2)
 
10778
+       (eq:SI (match_dup 1)
 
10779
+              (const_int 0)))
 
10780
+   (set (match_operand:SI 0 "int_reg_operand" "")
 
10781
+       (minus:SI (const_int 1) (match_dup 2)))]
 
10782
+  "TARGET_HTM"
 
10783
+{
 
10784
+  operands[1] = gen_rtx_REG (CCmode, CR0_REGNO);
 
10785
+  operands[2] = gen_reg_rtx (SImode);
 
10786
+})
 
10787
+
 
10788
+(define_insn "*trechkpt_internal"
 
10789
+  [(set (match_operand:CC 0 "cc_reg_operand" "=x")
 
10790
+       (unspec_volatile:CC [(const_int 0)]
 
10791
+                           UNSPECV_HTM_TRECHKPT))]
 
10792
+  "TARGET_HTM"
 
10793
+  "trechkpt."
 
10794
+  [(set_attr "type" "htm")
 
10795
+   (set_attr "length" "4")])
 
10796
+
 
10797
+(define_expand "treclaim"
 
10798
+  [(set (match_dup 2)
 
10799
+       (unspec_volatile:CC [(match_operand:SI 1 "gpc_reg_operand" "r")]
 
10800
+                           UNSPECV_HTM_TRECLAIM))
 
10801
+   (set (match_dup 3)
 
10802
+       (eq:SI (match_dup 2)
 
10803
+              (const_int 0)))
 
10804
+   (set (match_operand:SI 0 "int_reg_operand" "")
 
10805
+       (minus:SI (const_int 1) (match_dup 3)))]
 
10806
+  "TARGET_HTM"
 
10807
+{
 
10808
+  operands[2] = gen_rtx_REG (CCmode, CR0_REGNO);
 
10809
+  operands[3] = gen_reg_rtx (SImode);
 
10810
+})
 
10811
+
 
10812
+(define_insn "*treclaim_internal"
 
10813
+  [(set (match_operand:CC 1 "cc_reg_operand" "=x")
 
10814
+       (unspec_volatile:CC [(match_operand:SI 0 "gpc_reg_operand" "r")]
 
10815
+                           UNSPECV_HTM_TRECLAIM))]
 
10816
+  "TARGET_HTM"
 
10817
+  "treclaim. %0"
 
10818
+  [(set_attr "type" "htm")
 
10819
+   (set_attr "length" "4")])
 
10820
+
 
10821
+(define_expand "tsr"
 
10822
+  [(set (match_dup 2)
 
10823
+       (unspec_volatile:CC [(match_operand 1 "const_0_to_1_operand" "n")]
 
10824
+                           UNSPECV_HTM_TSR))
 
10825
+   (set (match_dup 3)
 
10826
+       (eq:SI (match_dup 2)
 
10827
+              (const_int 0)))
 
10828
+   (set (match_operand:SI 0 "int_reg_operand" "")
 
10829
+       (minus:SI (const_int 1) (match_dup 3)))]
 
10830
+  "TARGET_HTM"
 
10831
+{
 
10832
+  operands[2] = gen_rtx_REG (CCmode, CR0_REGNO);
 
10833
+  operands[3] = gen_reg_rtx (SImode);
 
10834
+})
 
10835
+
 
10836
+(define_insn "*tsr_internal"
 
10837
+  [(set (match_operand:CC 1 "cc_reg_operand" "=x")
 
10838
+       (unspec_volatile:CC [(match_operand 0 "const_0_to_1_operand" "n")]
 
10839
+                           UNSPECV_HTM_TSR))]
 
10840
+  "TARGET_HTM"
 
10841
+  "tsr. %0"
 
10842
+  [(set_attr "type" "htm")
 
10843
+   (set_attr "length" "4")])
 
10844
+
 
10845
+(define_insn "htm_mfspr_<mode>"
 
10846
+  [(set (match_operand:P 0 "gpc_reg_operand" "=r")
 
10847
+        (unspec_volatile:P [(match_operand 1 "u10bit_cint_operand" "n")
 
10848
+                           (match_operand:P 2 "htm_spr_reg_operand" "")]
 
10849
+                          UNSPECV_HTM_MFSPR))]
 
10850
+  "TARGET_HTM"
 
10851
+  "mfspr %0,%1";
 
10852
+  [(set_attr "type" "htm")
 
10853
+   (set_attr "length" "4")])
 
10854
+
 
10855
+(define_insn "htm_mtspr_<mode>"
 
10856
+  [(set (match_operand:P 2 "htm_spr_reg_operand" "")
 
10857
+        (unspec_volatile:P [(match_operand:P 0 "gpc_reg_operand" "r")
 
10858
+                           (match_operand 1 "u10bit_cint_operand" "n")]
 
10859
+                           UNSPECV_HTM_MTSPR))]
 
10860
+  "TARGET_HTM"
 
10861
+  "mtspr %1,%0";
 
10862
+  [(set_attr "type" "htm")
 
10863
+   (set_attr "length" "4")])
 
10864
--- a/src/gcc/config/rs6000/rs6000-modes.def
 
10865
+++ b/src/gcc/config/rs6000/rs6000-modes.def
 
10866
@@ -41,3 +41,8 @@
 
10867
 VECTOR_MODES (FLOAT, 8);      /*             V4HF V2SF */
 
10868
 VECTOR_MODES (FLOAT, 16);     /*       V8HF  V4SF V2DF */
 
10869
 VECTOR_MODES (FLOAT, 32);     /*       V16HF V8SF V4DF */
 
10870
+
 
10871
+/* Replacement for TImode that only is allowed in GPRs.  We also use PTImode
 
10872
+   for quad memory atomic operations to force getting an even/odd register
 
10873
+   combination.  */
 
10874
+PARTIAL_INT_MODE (TI);
 
10875
--- a/src/gcc/config/rs6000/rs6000-cpus.def
 
10876
+++ b/src/gcc/config/rs6000/rs6000-cpus.def
 
10877
@@ -28,7 +28,7 @@
 
10878
      ALTIVEC, since in general it isn't a win on power6.  In ISA 2.04, fsel,
 
10879
      fre, fsqrt, etc. were no longer documented as optional.  Group masks by
 
10880
      server and embedded. */
 
10881
-#define ISA_2_5_MASKS_EMBEDDED (ISA_2_2_MASKS                          \
 
10882
+#define ISA_2_5_MASKS_EMBEDDED (ISA_2_4_MASKS                          \
 
10883
                                 | OPTION_MASK_CMPB                     \
 
10884
                                 | OPTION_MASK_RECIP_PRECISION          \
 
10885
                                 | OPTION_MASK_PPC_GFXOPT               \
 
10886
@@ -38,12 +38,23 @@
 
10887
 
 
10888
   /* For ISA 2.06, don't add ISEL, since in general it isn't a win, but
 
10889
      altivec is a win so enable it.  */
 
10890
+  /* OPTION_MASK_VSX_TIMODE should be set, but disable it for now until
 
10891
+     PR 58587 is fixed.  */
 
10892
 #define ISA_2_6_MASKS_EMBEDDED (ISA_2_5_MASKS_EMBEDDED | OPTION_MASK_POPCNTD)
 
10893
 #define ISA_2_6_MASKS_SERVER   (ISA_2_5_MASKS_SERVER                   \
 
10894
                                 | OPTION_MASK_POPCNTD                  \
 
10895
                                 | OPTION_MASK_ALTIVEC                  \
 
10896
                                 | OPTION_MASK_VSX)
 
10897
 
 
10898
+/* For now, don't provide an embedded version of ISA 2.07.  */
 
10899
+#define ISA_2_7_MASKS_SERVER   (ISA_2_6_MASKS_SERVER                   \
 
10900
+                                | OPTION_MASK_P8_FUSION                \
 
10901
+                                | OPTION_MASK_P8_VECTOR                \
 
10902
+                                | OPTION_MASK_CRYPTO                   \
 
10903
+                                | OPTION_MASK_DIRECT_MOVE              \
 
10904
+                                | OPTION_MASK_HTM                      \
 
10905
+                                | OPTION_MASK_QUAD_MEMORY)
 
10906
+
 
10907
 #define POWERPC_7400_MASK      (OPTION_MASK_PPC_GFXOPT | OPTION_MASK_ALTIVEC)
 
10908
 
 
10909
 /* Deal with ports that do not have -mstrict-align.  */
 
10910
@@ -60,23 +71,30 @@
 
10911
 /* Mask of all options to set the default isa flags based on -mcpu=<xxx>.  */
 
10912
 #define POWERPC_MASKS          (OPTION_MASK_ALTIVEC                    \
 
10913
                                 | OPTION_MASK_CMPB                     \
 
10914
+                                | OPTION_MASK_CRYPTO                   \
 
10915
                                 | OPTION_MASK_DFP                      \
 
10916
+                                | OPTION_MASK_DIRECT_MOVE              \
 
10917
                                 | OPTION_MASK_DLMZB                    \
 
10918
                                 | OPTION_MASK_FPRND                    \
 
10919
+                                | OPTION_MASK_HTM                      \
 
10920
                                 | OPTION_MASK_ISEL                     \
 
10921
                                 | OPTION_MASK_MFCRF                    \
 
10922
                                 | OPTION_MASK_MFPGPR                   \
 
10923
                                 | OPTION_MASK_MULHW                    \
 
10924
                                 | OPTION_MASK_NO_UPDATE                \
 
10925
+                                | OPTION_MASK_P8_FUSION                \
 
10926
+                                | OPTION_MASK_P8_VECTOR                \
 
10927
                                 | OPTION_MASK_POPCNTB                  \
 
10928
                                 | OPTION_MASK_POPCNTD                  \
 
10929
                                 | OPTION_MASK_POWERPC64                \
 
10930
                                 | OPTION_MASK_PPC_GFXOPT               \
 
10931
                                 | OPTION_MASK_PPC_GPOPT                \
 
10932
+                                | OPTION_MASK_QUAD_MEMORY              \
 
10933
                                 | OPTION_MASK_RECIP_PRECISION          \
 
10934
                                 | OPTION_MASK_SOFT_FLOAT               \
 
10935
                                 | OPTION_MASK_STRICT_ALIGN_OPTIONAL    \
 
10936
-                                | OPTION_MASK_VSX)
 
10937
+                                | OPTION_MASK_VSX                      \
 
10938
+                                | OPTION_MASK_VSX_TIMODE)
 
10939
 
 
10940
 #endif
 
10941
 
 
10942
@@ -166,10 +184,7 @@
 
10943
            POWERPC_7400_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_MFCRF
 
10944
            | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP | MASK_POPCNTD
 
10945
            | MASK_VSX | MASK_RECIP_PRECISION)
 
10946
-RS6000_CPU ("power8", PROCESSOR_POWER7,   /* Don't add MASK_ISEL by default */
 
10947
-           POWERPC_7400_MASK | MASK_POWERPC64 | MASK_PPC_GPOPT | MASK_MFCRF
 
10948
-           | MASK_POPCNTB | MASK_FPRND | MASK_CMPB | MASK_DFP | MASK_POPCNTD
 
10949
-           | MASK_VSX | MASK_RECIP_PRECISION)
 
10950
+RS6000_CPU ("power8", PROCESSOR_POWER8, MASK_POWERPC64 | ISA_2_7_MASKS_SERVER)
 
10951
 RS6000_CPU ("powerpc", PROCESSOR_POWERPC, 0)
 
10952
 RS6000_CPU ("powerpc64", PROCESSOR_POWERPC64, MASK_PPC_GFXOPT | MASK_POWERPC64)
 
10953
 RS6000_CPU ("rs64", PROCESSOR_RS64A, MASK_PPC_GFXOPT | MASK_POWERPC64)
 
10954
--- a/src/gcc/config/rs6000/htmintrin.h
 
10955
+++ b/src/gcc/config/rs6000/htmintrin.h
 
10956
@@ -0,0 +1,131 @@
 
10957
+/* Hardware Transactional Memory (HTM) intrinsics.
 
10958
+   Copyright (C) 2013 Free Software Foundation, Inc.
 
10959
+   Contributed by Peter Bergner <bergner@vnet.ibm.com>.
 
10960
+
 
10961
+   This file is free software; you can redistribute it and/or modify it under
 
10962
+   the terms of the GNU General Public License as published by the Free
 
10963
+   Software Foundation; either version 3 of the License, or (at your option)
 
10964
+   any later version.
 
10965
+
 
10966
+   This file is distributed in the hope that it will be useful, but WITHOUT
 
10967
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
10968
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
10969
+   for more details.
 
10970
+
 
10971
+   Under Section 7 of GPL version 3, you are granted additional
 
10972
+   permissions described in the GCC Runtime Library Exception, version
 
10973
+   3.1, as published by the Free Software Foundation.
 
10974
+
 
10975
+   You should have received a copy of the GNU General Public License and
 
10976
+   a copy of the GCC Runtime Library Exception along with this program;
 
10977
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
10978
+   <http://www.gnu.org/licenses/>.  */
 
10979
+
 
10980
+#ifndef __HTM__
 
10981
+# error "HTM instruction set not enabled"
 
10982
+#endif /* __HTM__ */
 
10983
+
 
10984
+#ifndef _HTMINTRIN_H
 
10985
+#define _HTMINTRIN_H
 
10986
+
 
10987
+#include <stdint.h>
 
10988
+
 
10989
+typedef uint64_t texasr_t;
 
10990
+typedef uint32_t texasru_t;
 
10991
+typedef uint32_t texasrl_t;
 
10992
+typedef uintptr_t tfiar_t;
 
10993
+typedef uintptr_t tfhar_t;
 
10994
+
 
10995
+#define _HTM_STATE(CR0) ((CR0 >> 1) & 0x3)
 
10996
+#define _HTM_NONTRANSACTIONAL 0x0
 
10997
+#define _HTM_SUSPENDED        0x1
 
10998
+#define _HTM_TRANSACTIONAL    0x2
 
10999
+
 
11000
+/* The following macros use the IBM bit numbering for BITNUM
 
11001
+   as used in the ISA documentation.  */
 
11002
+
 
11003
+#define _TEXASR_EXTRACT_BITS(TEXASR,BITNUM,SIZE) \
 
11004
+  (((TEXASR) >> (63-(BITNUM))) & ((1<<(SIZE))-1))
 
11005
+#define _TEXASRU_EXTRACT_BITS(TEXASR,BITNUM,SIZE) \
 
11006
+  (((TEXASR) >> (31-(BITNUM))) & ((1<<(SIZE))-1))
 
11007
+
 
11008
+#define _TEXASR_FAILURE_CODE(TEXASR) \
 
11009
+  _TEXASR_EXTRACT_BITS(TEXASR, 7, 8)
 
11010
+#define _TEXASRU_FAILURE_CODE(TEXASRU) \
 
11011
+  _TEXASRU_EXTRACT_BITS(TEXASRU, 7, 8)
 
11012
+
 
11013
+#define _TEXASR_FAILURE_PERSISTENT(TEXASR) \
 
11014
+  _TEXASR_EXTRACT_BITS(TEXASR, 7, 1)
 
11015
+#define _TEXASRU_FAILURE_PERSISTENT(TEXASRU) \
 
11016
+  _TEXASRU_EXTRACT_BITS(TEXASRU, 7, 1)
 
11017
+
 
11018
+#define _TEXASR_DISALLOWED(TEXASR) \
 
11019
+  _TEXASR_EXTRACT_BITS(TEXASR, 8, 1)
 
11020
+#define _TEXASRU_DISALLOWED(TEXASRU) \
 
11021
+  _TEXASRU_EXTRACT_BITS(TEXASRU, 8, 1)
 
11022
+
 
11023
+#define _TEXASR_NESTING_OVERFLOW(TEXASR) \
 
11024
+  _TEXASR_EXTRACT_BITS(TEXASR, 9, 1)
 
11025
+#define _TEXASRU_NESTING_OVERFLOW(TEXASRU) \
 
11026
+  _TEXASRU_EXTRACT_BITS(TEXASRU, 9, 1)
 
11027
+
 
11028
+#define _TEXASR_FOOTPRINT_OVERFLOW(TEXASR) \
 
11029
+  _TEXASR_EXTRACT_BITS(TEXASR, 10, 1)
 
11030
+#define _TEXASRU_FOOTPRINT_OVERFLOW(TEXASRU) \
 
11031
+  _TEXASRU_EXTRACT_BITS(TEXASRU, 10, 1)
 
11032
+
 
11033
+#define _TEXASR_SELF_INDUCED_CONFLICT(TEXASR) \
 
11034
+  _TEXASR_EXTRACT_BITS(TEXASR, 11, 1)
 
11035
+#define _TEXASRU_SELF_INDUCED_CONFLICT(TEXASRU) \
 
11036
+  _TEXASRU_EXTRACT_BITS(TEXASRU, 11, 1)
 
11037
+
 
11038
+#define _TEXASR_NON_TRANSACTIONAL_CONFLICT(TEXASR) \
 
11039
+  _TEXASR_EXTRACT_BITS(TEXASR, 12, 1)
 
11040
+#define _TEXASRU_NON_TRANSACTIONAL_CONFLICT(TEXASRU) \
 
11041
+  _TEXASRU_EXTRACT_BITS(TEXASRU, 12, 1)
 
11042
+
 
11043
+#define _TEXASR_TRANSACTION_CONFLICT(TEXASR) \
 
11044
+  _TEXASR_EXTRACT_BITS(TEXASR, 13, 1)
 
11045
+#define _TEXASRU_TRANSACTION_CONFLICT(TEXASRU) \
 
11046
+  _TEXASRU_EXTRACT_BITS(TEXASRU, 13, 1)
 
11047
+
 
11048
+#define _TEXASR_TRANSLATION_INVALIDATION_CONFLICT(TEXASR) \
 
11049
+  _TEXASR_EXTRACT_BITS(TEXASR, 14, 1)
 
11050
+#define _TEXASRU_TRANSLATION_INVALIDATION_CONFLICT(TEXASRU) \
 
11051
+  _TEXASRU_EXTRACT_BITS(TEXASRU, 14, 1)
 
11052
+
 
11053
+#define _TEXASR_IMPLEMENTAION_SPECIFIC(TEXASR) \
 
11054
+  _TEXASR_EXTRACT_BITS(TEXASR, 15, 1)
 
11055
+#define _TEXASRU_IMPLEMENTAION_SPECIFIC(TEXASRU) \
 
11056
+  _TEXASRU_EXTRACT_BITS(TEXASRU, 15, 1)
 
11057
+
 
11058
+#define _TEXASR_INSTRUCTION_FETCH_CONFLICT(TEXASR) \
 
11059
+  _TEXASR_EXTRACT_BITS(TEXASR, 16, 1)
 
11060
+#define _TEXASRU_INSTRUCTION_FETCH_CONFLICT(TEXASRU) \
 
11061
+  _TEXASRU_EXTRACT_BITS(TEXASRU, 16, 1)
 
11062
+
 
11063
+#define _TEXASR_ABORT(TEXASR) \
 
11064
+  _TEXASR_EXTRACT_BITS(TEXASR, 31, 1)
 
11065
+#define _TEXASRU_ABORT(TEXASRU) \
 
11066
+  _TEXASRU_EXTRACT_BITS(TEXASRU, 31, 1)
 
11067
+
 
11068
+
 
11069
+#define _TEXASR_SUSPENDED(TEXASR) \
 
11070
+  _TEXASR_EXTRACT_BITS(TEXASR, 32, 1)
 
11071
+
 
11072
+#define _TEXASR_PRIVILEGE(TEXASR) \
 
11073
+  _TEXASR_EXTRACT_BITS(TEXASR, 35, 2)
 
11074
+
 
11075
+#define _TEXASR_FAILURE_SUMMARY(TEXASR) \
 
11076
+  _TEXASR_EXTRACT_BITS(TEXASR, 36, 1)
 
11077
+
 
11078
+#define _TEXASR_TFIAR_EXACT(TEXASR) \
 
11079
+  _TEXASR_EXTRACT_BITS(TEXASR, 37, 1)
 
11080
+
 
11081
+#define _TEXASR_ROT(TEXASR) \
 
11082
+  _TEXASR_EXTRACT_BITS(TEXASR, 38, 1)
 
11083
+
 
11084
+#define _TEXASR_TRANSACTION_LEVEL(TEXASR) \
 
11085
+  _TEXASR_EXTRACT_BITS(TEXASR, 63, 12)
 
11086
+
 
11087
+#endif /* _HTMINTRIN_H */
 
11088
--- a/src/gcc/config/rs6000/rs6000-protos.h
 
11089
+++ b/src/gcc/config/rs6000/rs6000-protos.h
 
11090
@@ -50,11 +50,13 @@
 
11091
 extern rtx find_addr_reg (rtx);
 
11092
 extern rtx gen_easy_altivec_constant (rtx);
 
11093
 extern const char *output_vec_const_move (rtx *);
 
11094
+extern const char *rs6000_output_move_128bit (rtx *);
 
11095
 extern void rs6000_expand_vector_init (rtx, rtx);
 
11096
 extern void paired_expand_vector_init (rtx, rtx);
 
11097
 extern void rs6000_expand_vector_set (rtx, rtx, int);
 
11098
 extern void rs6000_expand_vector_extract (rtx, rtx, int);
 
11099
 extern bool altivec_expand_vec_perm_const (rtx op[4]);
 
11100
+extern void altivec_expand_vec_perm_le (rtx op[4]);
 
11101
 extern bool rs6000_expand_vec_perm_const (rtx op[4]);
 
11102
 extern void rs6000_expand_extract_even (rtx, rtx, rtx);
 
11103
 extern void rs6000_expand_interleave (rtx, rtx, rtx, bool);
 
11104
@@ -70,6 +72,11 @@
 
11105
 extern int registers_ok_for_quad_peep (rtx, rtx);
 
11106
 extern int mems_ok_for_quad_peep (rtx, rtx);
 
11107
 extern bool gpr_or_gpr_p (rtx, rtx);
 
11108
+extern bool direct_move_p (rtx, rtx);
 
11109
+extern bool quad_load_store_p (rtx, rtx);
 
11110
+extern bool fusion_gpr_load_p (rtx *, bool);
 
11111
+extern void expand_fusion_gpr_load (rtx *);
 
11112
+extern const char *emit_fusion_gpr_load (rtx *);
 
11113
 extern enum reg_class (*rs6000_preferred_reload_class_ptr) (rtx,
 
11114
                                                            enum reg_class);
 
11115
 extern enum reg_class (*rs6000_secondary_reload_class_ptr) (enum reg_class,
 
11116
@@ -116,6 +123,7 @@
 
11117
 extern void rs6000_fatal_bad_address (rtx);
 
11118
 extern rtx create_TOC_reference (rtx, rtx);
 
11119
 extern void rs6000_split_multireg_move (rtx, rtx);
 
11120
+extern void rs6000_emit_le_vsx_move (rtx, rtx, enum machine_mode);
 
11121
 extern void rs6000_emit_move (rtx, rtx, enum machine_mode);
 
11122
 extern rtx rs6000_secondary_memory_needed_rtx (enum machine_mode);
 
11123
 extern rtx (*rs6000_legitimize_reload_address_ptr) (rtx, enum machine_mode,
 
11124
@@ -135,6 +143,7 @@
 
11125
 extern rtx rs6000_address_for_altivec (rtx);
 
11126
 extern rtx rs6000_allocate_stack_temp (enum machine_mode, bool, bool);
 
11127
 extern int rs6000_loop_align (rtx);
 
11128
+extern void rs6000_split_logical (rtx [], enum rtx_code, bool, bool, bool, rtx);
 
11129
 #endif /* RTX_CODE */
 
11130
 
 
11131
 #ifdef TREE_CODE
 
11132
@@ -146,6 +155,7 @@
 
11133
 extern rtx rs6000_libcall_value (enum machine_mode);
 
11134
 extern rtx rs6000_va_arg (tree, tree);
 
11135
 extern int function_ok_for_sibcall (tree);
 
11136
+extern int rs6000_reg_parm_stack_space (tree);
 
11137
 extern void rs6000_elf_declare_function_name (FILE *, const char *, tree);
 
11138
 extern bool rs6000_elf_in_small_data_p (const_tree);
 
11139
 #ifdef ARGS_SIZE_RTX
 
11140
@@ -170,7 +180,8 @@
 
11141
 extern void rs6000_emit_epilogue (int);
 
11142
 extern void rs6000_emit_eh_reg_restore (rtx, rtx);
 
11143
 extern const char * output_isel (rtx *);
 
11144
-extern void rs6000_call_indirect_aix (rtx, rtx, rtx);
 
11145
+extern void rs6000_call_aix (rtx, rtx, rtx, rtx);
 
11146
+extern void rs6000_sibcall_aix (rtx, rtx, rtx, rtx);
 
11147
 extern void rs6000_aix_asm_output_dwarf_table_ref (char *);
 
11148
 extern void get_ppc476_thunk_name (char name[32]);
 
11149
 extern bool rs6000_overloaded_builtin_p (enum rs6000_builtins);
 
11150
--- a/src/gcc/config/rs6000/t-rs6000
 
11151
+++ b/src/gcc/config/rs6000/t-rs6000
 
11152
@@ -60,6 +60,7 @@
 
11153
        $(srcdir)/config/rs6000/power5.md \
 
11154
        $(srcdir)/config/rs6000/power6.md \
 
11155
        $(srcdir)/config/rs6000/power7.md \
 
11156
+       $(srcdir)/config/rs6000/power8.md \
 
11157
        $(srcdir)/config/rs6000/cell.md \
 
11158
        $(srcdir)/config/rs6000/xfpu.md \
 
11159
        $(srcdir)/config/rs6000/a2.md \
 
11160
@@ -70,6 +71,8 @@
 
11161
        $(srcdir)/config/rs6000/vector.md \
 
11162
        $(srcdir)/config/rs6000/vsx.md \
 
11163
        $(srcdir)/config/rs6000/altivec.md \
 
11164
+       $(srcdir)/config/rs6000/crypto.md \
 
11165
+       $(srcdir)/config/rs6000/htm.md \
 
11166
        $(srcdir)/config/rs6000/spe.md \
 
11167
        $(srcdir)/config/rs6000/dfp.md \
 
11168
        $(srcdir)/config/rs6000/paired.md
 
11169
--- a/src/gcc/config/rs6000/htmxlintrin.h
 
11170
+++ b/src/gcc/config/rs6000/htmxlintrin.h
 
11171
@@ -0,0 +1,208 @@
 
11172
+/* XL compiler Hardware Transactional Memory (HTM) execution intrinsics.
 
11173
+   Copyright (C) 2013 Free Software Foundation, Inc.
 
11174
+   Contributed by Peter Bergner <bergner@vnet.ibm.com>.
 
11175
+
 
11176
+   This file is free software; you can redistribute it and/or modify it under
 
11177
+   the terms of the GNU General Public License as published by the Free
 
11178
+   Software Foundation; either version 3 of the License, or (at your option)
 
11179
+   any later version.
 
11180
+
 
11181
+   This file is distributed in the hope that it will be useful, but WITHOUT
 
11182
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
11183
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
11184
+   for more details.
 
11185
+
 
11186
+   Under Section 7 of GPL version 3, you are granted additional
 
11187
+   permissions described in the GCC Runtime Library Exception, version
 
11188
+   3.1, as published by the Free Software Foundation.
 
11189
+
 
11190
+   You should have received a copy of the GNU General Public License and
 
11191
+   a copy of the GCC Runtime Library Exception along with this program;
 
11192
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
11193
+   <http://www.gnu.org/licenses/>.  */
 
11194
+
 
11195
+#ifndef __HTM__
 
11196
+# error "HTM instruction set not enabled"
 
11197
+#endif /* __HTM__ */
 
11198
+
 
11199
+#ifndef _HTMXLINTRIN_H
 
11200
+#define _HTMXLINTRIN_H
 
11201
+
 
11202
+#include <stdint.h>
 
11203
+#include <htmintrin.h>
 
11204
+
 
11205
+#ifdef __cplusplus
 
11206
+extern "C" {
 
11207
+#endif
 
11208
+
 
11209
+#define _TEXASR_PTR(TM_BUF) \
 
11210
+  ((texasr_t *)((TM_BUF)+0))
 
11211
+#define _TEXASRU_PTR(TM_BUF) \
 
11212
+  ((texasru_t *)((TM_BUF)+0))
 
11213
+#define _TEXASRL_PTR(TM_BUF) \
 
11214
+  ((texasrl_t *)((TM_BUF)+4))
 
11215
+#define _TFIAR_PTR(TM_BUF) \
 
11216
+  ((tfiar_t *)((TM_BUF)+8))
 
11217
+
 
11218
+typedef char TM_buff_type[16];
 
11219
+
 
11220
+extern __inline long
 
11221
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 
11222
+__TM_simple_begin (void)
 
11223
+{
 
11224
+  if (__builtin_expect (__builtin_tbegin (0), 1))
 
11225
+    return 1;
 
11226
+  return 0;
 
11227
+}
 
11228
+
 
11229
+extern __inline long
 
11230
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 
11231
+__TM_begin (void* const TM_buff)
 
11232
+{
 
11233
+  *_TEXASRL_PTR (TM_buff) = 0;
 
11234
+  if (__builtin_expect (__builtin_tbegin (0), 1))
 
11235
+    return 1;
 
11236
+#ifdef __powerpc64__
 
11237
+  *_TEXASR_PTR (TM_buff) = __builtin_get_texasr ();
 
11238
+#else
 
11239
+  *_TEXASRU_PTR (TM_buff) = __builtin_get_texasru ();
 
11240
+  *_TEXASRL_PTR (TM_buff) = __builtin_get_texasr ();
 
11241
+#endif
 
11242
+  *_TFIAR_PTR (TM_buff) = __builtin_get_tfiar ();
 
11243
+  return 0;
 
11244
+}
 
11245
+
 
11246
+extern __inline long
 
11247
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 
11248
+__TM_end (void)
 
11249
+{
 
11250
+  if (__builtin_expect (__builtin_tend (0), 1))
 
11251
+    return 1;
 
11252
+  return 0;
 
11253
+}
 
11254
+
 
11255
+extern __inline void
 
11256
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 
11257
+__TM_abort (void)
 
11258
+{
 
11259
+  __builtin_tabort (0);
 
11260
+}
 
11261
+
 
11262
+extern __inline void
 
11263
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 
11264
+__TM_named_abort (unsigned char const code)
 
11265
+{
 
11266
+  __builtin_tabort (code);
 
11267
+}
 
11268
+
 
11269
+extern __inline void
 
11270
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 
11271
+__TM_resume (void)
 
11272
+{
 
11273
+  __builtin_tresume ();
 
11274
+}
 
11275
+
 
11276
+extern __inline void
 
11277
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 
11278
+__TM_suspend (void)
 
11279
+{
 
11280
+  __builtin_tsuspend ();
 
11281
+}
 
11282
+
 
11283
+extern __inline long
 
11284
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 
11285
+__TM_is_user_abort (void* const TM_buff)
 
11286
+{
 
11287
+  texasru_t texasru = *_TEXASRU_PTR (TM_buff);
 
11288
+  return _TEXASRU_ABORT (texasru);
 
11289
+}
 
11290
+
 
11291
+extern __inline long
 
11292
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 
11293
+__TM_is_named_user_abort (void* const TM_buff, unsigned char *code)
 
11294
+{
 
11295
+  texasru_t texasru = *_TEXASRU_PTR (TM_buff);
 
11296
+
 
11297
+  *code = _TEXASRU_FAILURE_CODE (texasru);
 
11298
+  return _TEXASRU_ABORT (texasru);
 
11299
+}
 
11300
+
 
11301
+extern __inline long
 
11302
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 
11303
+__TM_is_illegal (void* const TM_buff)
 
11304
+{
 
11305
+  texasru_t texasru = *_TEXASRU_PTR (TM_buff);
 
11306
+  return _TEXASRU_DISALLOWED (texasru);
 
11307
+}
 
11308
+
 
11309
+extern __inline long
 
11310
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 
11311
+__TM_is_footprint_exceeded (void* const TM_buff)
 
11312
+{
 
11313
+  texasru_t texasru = *_TEXASRU_PTR (TM_buff);
 
11314
+  return _TEXASRU_FOOTPRINT_OVERFLOW (texasru);
 
11315
+}
 
11316
+
 
11317
+extern __inline long
 
11318
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 
11319
+__TM_nesting_depth (void* const TM_buff)
 
11320
+{
 
11321
+  texasrl_t texasrl;
 
11322
+
 
11323
+  if (_HTM_STATE (__builtin_ttest ()) == _HTM_NONTRANSACTIONAL)
 
11324
+    {
 
11325
+      texasrl = *_TEXASRL_PTR (TM_buff);
 
11326
+      if (!_TEXASR_FAILURE_SUMMARY (texasrl))
 
11327
+        texasrl = 0;
 
11328
+    }
 
11329
+  else
 
11330
+    texasrl = (texasrl_t) __builtin_get_texasr ();
 
11331
+
 
11332
+  return _TEXASR_TRANSACTION_LEVEL (texasrl);
 
11333
+}
 
11334
+
 
11335
+extern __inline long
 
11336
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 
11337
+__TM_is_nested_too_deep(void* const TM_buff)
 
11338
+{
 
11339
+  texasru_t texasru = *_TEXASRU_PTR (TM_buff);
 
11340
+  return _TEXASRU_NESTING_OVERFLOW (texasru);
 
11341
+}
 
11342
+
 
11343
+extern __inline long
 
11344
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 
11345
+__TM_is_conflict(void* const TM_buff)
 
11346
+{
 
11347
+  texasru_t texasru = *_TEXASRU_PTR (TM_buff);
 
11348
+  /* Return TEXASR bits 11 (Self-Induced Conflict) through
 
11349
+     14 (Translation Invalidation Conflict).  */
 
11350
+  return (_TEXASRU_EXTRACT_BITS (texasru, 14, 4)) ? 1 : 0;
 
11351
+}
 
11352
+
 
11353
+extern __inline long
 
11354
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 
11355
+__TM_is_failure_persistent(void* const TM_buff)
 
11356
+{
 
11357
+  texasru_t texasru = *_TEXASRU_PTR (TM_buff);
 
11358
+  return _TEXASRU_FAILURE_PERSISTENT (texasru);
 
11359
+}
 
11360
+
 
11361
+extern __inline long
 
11362
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 
11363
+__TM_failure_address(void* const TM_buff)
 
11364
+{
 
11365
+  return *_TFIAR_PTR (TM_buff);
 
11366
+}
 
11367
+
 
11368
+extern __inline long long
 
11369
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 
11370
+__TM_failure_code(void* const TM_buff)
 
11371
+{
 
11372
+  return *_TEXASR_PTR (TM_buff);
 
11373
+}
 
11374
+
 
11375
+#ifdef __cplusplus
 
11376
+}
 
11377
+#endif
 
11378
+
 
11379
+#endif /* _HTMXLINTRIN_H */
 
11380
--- a/src/gcc/config/rs6000/rs6000-builtin.def
 
11381
+++ b/src/gcc/config/rs6000/rs6000-builtin.def
 
11382
@@ -30,7 +30,8 @@
 
11383
    RS6000_BUILTIN_A -- ABS builtins
 
11384
    RS6000_BUILTIN_D -- DST builtins
 
11385
    RS6000_BUILTIN_E -- SPE EVSEL builtins.
 
11386
-   RS6000_BUILTIN_P -- Altivec and VSX predicate builtins
 
11387
+   RS6000_BUILTIN_H -- HTM builtins
 
11388
+   RS6000_BUILTIN_P -- Altivec, VSX, ISA 2.07 vector predicate builtins
 
11389
    RS6000_BUILTIN_Q -- Paired floating point VSX predicate builtins
 
11390
    RS6000_BUILTIN_S -- SPE predicate builtins
 
11391
    RS6000_BUILTIN_X -- special builtins
 
11392
@@ -66,6 +67,10 @@
 
11393
   #error "RS6000_BUILTIN_E is not defined."
 
11394
 #endif
 
11395
 
 
11396
+#ifndef RS6000_BUILTIN_H
 
11397
+  #error "RS6000_BUILTIN_H is not defined."
 
11398
+#endif
 
11399
+
 
11400
 #ifndef RS6000_BUILTIN_P
 
11401
   #error "RS6000_BUILTIN_P is not defined."
 
11402
 #endif
 
11403
@@ -301,6 +306,158 @@
 
11404
                     | RS6000_BTC_SPECIAL),                             \
 
11405
                    CODE_FOR_nothing)                   /* ICODE */
 
11406
 
 
11407
+/* ISA 2.07 (power8) vector convenience macros.  */
 
11408
+/* For the instructions that are encoded as altivec instructions use
 
11409
+   __builtin_altivec_ as the builtin name.  */
 
11410
+#define BU_P8V_AV_1(ENUM, NAME, ATTR, ICODE)                           \
 
11411
+  RS6000_BUILTIN_1 (P8V_BUILTIN_ ## ENUM,              /* ENUM */      \
 
11412
+                   "__builtin_altivec_" NAME,          /* NAME */      \
 
11413
+                   RS6000_BTM_P8_VECTOR,               /* MASK */      \
 
11414
+                   (RS6000_BTC_ ## ATTR                /* ATTR */      \
 
11415
+                    | RS6000_BTC_UNARY),                               \
 
11416
+                   CODE_FOR_ ## ICODE)                 /* ICODE */
 
11417
+
 
11418
+#define BU_P8V_AV_2(ENUM, NAME, ATTR, ICODE)                           \
 
11419
+  RS6000_BUILTIN_2 (P8V_BUILTIN_ ## ENUM,              /* ENUM */      \
 
11420
+                   "__builtin_altivec_" NAME,          /* NAME */      \
 
11421
+                   RS6000_BTM_P8_VECTOR,               /* MASK */      \
 
11422
+                   (RS6000_BTC_ ## ATTR                /* ATTR */      \
 
11423
+                    | RS6000_BTC_BINARY),                              \
 
11424
+                   CODE_FOR_ ## ICODE)                 /* ICODE */
 
11425
+
 
11426
+#define BU_P8V_AV_P(ENUM, NAME, ATTR, ICODE)                           \
 
11427
+  RS6000_BUILTIN_P (P8V_BUILTIN_ ## ENUM,              /* ENUM */      \
 
11428
+                   "__builtin_altivec_" NAME,          /* NAME */      \
 
11429
+                   RS6000_BTM_P8_VECTOR,               /* MASK */      \
 
11430
+                   (RS6000_BTC_ ## ATTR                /* ATTR */      \
 
11431
+                    | RS6000_BTC_PREDICATE),                           \
 
11432
+                   CODE_FOR_ ## ICODE)                 /* ICODE */
 
11433
+
 
11434
+/* For the instructions encoded as VSX instructions use __builtin_vsx as the
 
11435
+   builtin name.  */
 
11436
+#define BU_P8V_VSX_1(ENUM, NAME, ATTR, ICODE)                          \
 
11437
+  RS6000_BUILTIN_1 (P8V_BUILTIN_ ## ENUM,              /* ENUM */      \
 
11438
+                   "__builtin_vsx_" NAME,              /* NAME */      \
 
11439
+                   RS6000_BTM_P8_VECTOR,               /* MASK */      \
 
11440
+                   (RS6000_BTC_ ## ATTR                /* ATTR */      \
 
11441
+                    | RS6000_BTC_UNARY),                               \
 
11442
+                   CODE_FOR_ ## ICODE)                 /* ICODE */
 
11443
+
 
11444
+#define BU_P8V_OVERLOAD_1(ENUM, NAME)                                  \
 
11445
+  RS6000_BUILTIN_1 (P8V_BUILTIN_VEC_ ## ENUM,          /* ENUM */      \
 
11446
+                   "__builtin_vec_" NAME,              /* NAME */      \
 
11447
+                   RS6000_BTM_P8_VECTOR,               /* MASK */      \
 
11448
+                   (RS6000_BTC_OVERLOADED              /* ATTR */      \
 
11449
+                    | RS6000_BTC_UNARY),                               \
 
11450
+                   CODE_FOR_nothing)                   /* ICODE */
 
11451
+
 
11452
+#define BU_P8V_OVERLOAD_2(ENUM, NAME)                                  \
 
11453
+  RS6000_BUILTIN_2 (P8V_BUILTIN_VEC_ ## ENUM,          /* ENUM */      \
 
11454
+                   "__builtin_vec_" NAME,              /* NAME */      \
 
11455
+                   RS6000_BTM_P8_VECTOR,               /* MASK */      \
 
11456
+                   (RS6000_BTC_OVERLOADED              /* ATTR */      \
 
11457
+                    | RS6000_BTC_BINARY),                              \
 
11458
+                   CODE_FOR_nothing)                   /* ICODE */
 
11459
+
 
11460
+/* Crypto convenience macros.  */
 
11461
+#define BU_CRYPTO_1(ENUM, NAME, ATTR, ICODE)                           \
 
11462
+  RS6000_BUILTIN_1 (CRYPTO_BUILTIN_ ## ENUM,           /* ENUM */      \
 
11463
+                   "__builtin_crypto_" NAME,           /* NAME */      \
 
11464
+                   RS6000_BTM_CRYPTO,                  /* MASK */      \
 
11465
+                   (RS6000_BTC_ ## ATTR                /* ATTR */      \
 
11466
+                    | RS6000_BTC_UNARY),                               \
 
11467
+                   CODE_FOR_ ## ICODE)                 /* ICODE */
 
11468
+
 
11469
+#define BU_CRYPTO_2(ENUM, NAME, ATTR, ICODE)                           \
 
11470
+  RS6000_BUILTIN_2 (CRYPTO_BUILTIN_ ## ENUM,           /* ENUM */      \
 
11471
+                   "__builtin_crypto_" NAME,           /* NAME */      \
 
11472
+                   RS6000_BTM_CRYPTO,                  /* MASK */      \
 
11473
+                   (RS6000_BTC_ ## ATTR                /* ATTR */      \
 
11474
+                    | RS6000_BTC_BINARY),                              \
 
11475
+                   CODE_FOR_ ## ICODE)                 /* ICODE */
 
11476
+
 
11477
+#define BU_CRYPTO_3(ENUM, NAME, ATTR, ICODE)                           \
 
11478
+  RS6000_BUILTIN_3 (CRYPTO_BUILTIN_ ## ENUM,           /* ENUM */      \
 
11479
+                   "__builtin_crypto_" NAME,           /* NAME */      \
 
11480
+                   RS6000_BTM_CRYPTO,                  /* MASK */      \
 
11481
+                   (RS6000_BTC_ ## ATTR                /* ATTR */      \
 
11482
+                    | RS6000_BTC_TERNARY),                             \
 
11483
+                   CODE_FOR_ ## ICODE)                 /* ICODE */
 
11484
+
 
11485
+#define BU_CRYPTO_OVERLOAD_1(ENUM, NAME)                               \
 
11486
+  RS6000_BUILTIN_1 (CRYPTO_BUILTIN_ ## ENUM,           /* ENUM */      \
 
11487
+                   "__builtin_crypto_" NAME,           /* NAME */      \
 
11488
+                   RS6000_BTM_CRYPTO,                  /* MASK */      \
 
11489
+                   (RS6000_BTC_OVERLOADED              /* ATTR */      \
 
11490
+                    | RS6000_BTC_UNARY),                               \
 
11491
+                   CODE_FOR_nothing)                   /* ICODE */
 
11492
+
 
11493
+#define BU_CRYPTO_OVERLOAD_2(ENUM, NAME)                               \
 
11494
+  RS6000_BUILTIN_2 (CRYPTO_BUILTIN_ ## ENUM,           /* ENUM */      \
 
11495
+                   "__builtin_crypto_" NAME,           /* NAME */      \
 
11496
+                   RS6000_BTM_CRYPTO,                  /* MASK */      \
 
11497
+                   (RS6000_BTC_OVERLOADED              /* ATTR */      \
 
11498
+                    | RS6000_BTC_BINARY),                              \
 
11499
+                   CODE_FOR_nothing)                   /* ICODE */
 
11500
+
 
11501
+#define BU_CRYPTO_OVERLOAD_3(ENUM, NAME)                               \
 
11502
+  RS6000_BUILTIN_3 (CRYPTO_BUILTIN_ ## ENUM,           /* ENUM */      \
 
11503
+                   "__builtin_crypto_" NAME,           /* NAME */      \
 
11504
+                   RS6000_BTM_CRYPTO,                  /* MASK */      \
 
11505
+                   (RS6000_BTC_OVERLOADED              /* ATTR */      \
 
11506
+                    | RS6000_BTC_TERNARY),                             \
 
11507
+                   CODE_FOR_nothing)                   /* ICODE */
 
11508
+
 
11509
+/* HTM convenience macros.  */
 
11510
+#define BU_HTM_0(ENUM, NAME, ATTR, ICODE)                              \
 
11511
+  RS6000_BUILTIN_H (HTM_BUILTIN_ ## ENUM,              /* ENUM */      \
 
11512
+                   "__builtin_" NAME,                  /* NAME */      \
 
11513
+                   RS6000_BTM_HTM,                     /* MASK */      \
 
11514
+                   RS6000_BTC_ ## ATTR,                /* ATTR */      \
 
11515
+                   CODE_FOR_ ## ICODE)                 /* ICODE */
 
11516
+
 
11517
+#define BU_HTM_1(ENUM, NAME, ATTR, ICODE)                              \
 
11518
+  RS6000_BUILTIN_H (HTM_BUILTIN_ ## ENUM,              /* ENUM */      \
 
11519
+                   "__builtin_" NAME,                  /* NAME */      \
 
11520
+                   RS6000_BTM_HTM,                     /* MASK */      \
 
11521
+                   (RS6000_BTC_ ## ATTR                /* ATTR */      \
 
11522
+                    | RS6000_BTC_UNARY),                               \
 
11523
+                   CODE_FOR_ ## ICODE)                 /* ICODE */
 
11524
+
 
11525
+#define BU_HTM_2(ENUM, NAME, ATTR, ICODE)                              \
 
11526
+  RS6000_BUILTIN_H (HTM_BUILTIN_ ## ENUM,              /* ENUM */      \
 
11527
+                   "__builtin_" NAME,                  /* NAME */      \
 
11528
+                   RS6000_BTM_HTM,                     /* MASK */      \
 
11529
+                   (RS6000_BTC_ ## ATTR                /* ATTR */      \
 
11530
+                    | RS6000_BTC_BINARY),                              \
 
11531
+                   CODE_FOR_ ## ICODE)                 /* ICODE */
 
11532
+
 
11533
+#define BU_HTM_3(ENUM, NAME, ATTR, ICODE)                              \
 
11534
+  RS6000_BUILTIN_H (HTM_BUILTIN_ ## ENUM,              /* ENUM */      \
 
11535
+                   "__builtin_" NAME,                  /* NAME */      \
 
11536
+                   RS6000_BTM_HTM,                     /* MASK */      \
 
11537
+                   (RS6000_BTC_ ## ATTR                /* ATTR */      \
 
11538
+                    | RS6000_BTC_TERNARY),                             \
 
11539
+                   CODE_FOR_ ## ICODE)                 /* ICODE */
 
11540
+
 
11541
+#define BU_HTM_SPR0(ENUM, NAME, ATTR, ICODE)                           \
 
11542
+  RS6000_BUILTIN_H (HTM_BUILTIN_ ## ENUM,              /* ENUM */      \
 
11543
+                   "__builtin_" NAME,                  /* NAME */      \
 
11544
+                   RS6000_BTM_HTM,                     /* MASK */      \
 
11545
+                   (RS6000_BTC_ ## ATTR                /* ATTR */      \
 
11546
+                    | RS6000_BTC_SPR),                                 \
 
11547
+                   CODE_FOR_ ## ICODE)                 /* ICODE */
 
11548
+
 
11549
+#define BU_HTM_SPR1(ENUM, NAME, ATTR, ICODE)                           \
 
11550
+  RS6000_BUILTIN_H (HTM_BUILTIN_ ## ENUM,              /* ENUM */      \
 
11551
+                   "__builtin_" NAME,                  /* NAME */      \
 
11552
+                   RS6000_BTM_HTM,                     /* MASK */      \
 
11553
+                   (RS6000_BTC_ ## ATTR                /* ATTR */      \
 
11554
+                    | RS6000_BTC_UNARY                                 \
 
11555
+                    | RS6000_BTC_SPR                                   \
 
11556
+                    | RS6000_BTC_VOID),                                \
 
11557
+                   CODE_FOR_ ## ICODE)                 /* ICODE */
 
11558
+
 
11559
 /* SPE convenience macros.  */
 
11560
 #define BU_SPE_1(ENUM, NAME, ATTR, ICODE)                              \
 
11561
   RS6000_BUILTIN_1 (SPE_BUILTIN_ ## ENUM,              /* ENUM */      \
 
11562
@@ -1012,7 +1169,7 @@
 
11563
 BU_VSX_1 (XVRESP,            "xvresp",         CONST,  vsx_frev4sf2)
 
11564
 
 
11565
 BU_VSX_1 (XSCVDPSP,          "xscvdpsp",       CONST,  vsx_xscvdpsp)
 
11566
-BU_VSX_1 (XSCVSPDP,          "xscvspdp",       CONST,  vsx_xscvdpsp)
 
11567
+BU_VSX_1 (XSCVSPDP,          "xscvspdp",       CONST,  vsx_xscvspdp)
 
11568
 BU_VSX_1 (XVCVDPSP,          "xvcvdpsp",       CONST,  vsx_xvcvdpsp)
 
11569
 BU_VSX_1 (XVCVSPDP,          "xvcvspdp",       CONST,  vsx_xvcvspdp)
 
11570
 BU_VSX_1 (XSTSQRTDP_FE,              "xstsqrtdp_fe",   CONST,  vsx_tsqrtdf2_fe)
 
11571
@@ -1052,9 +1209,9 @@
 
11572
 
 
11573
 BU_VSX_1 (XSRDPI,            "xsrdpi",         CONST,  vsx_xsrdpi)
 
11574
 BU_VSX_1 (XSRDPIC,           "xsrdpic",        CONST,  vsx_xsrdpic)
 
11575
-BU_VSX_1 (XSRDPIM,           "xsrdpim",        CONST,  vsx_floordf2)
 
11576
-BU_VSX_1 (XSRDPIP,           "xsrdpip",        CONST,  vsx_ceildf2)
 
11577
-BU_VSX_1 (XSRDPIZ,           "xsrdpiz",        CONST,  vsx_btruncdf2)
 
11578
+BU_VSX_1 (XSRDPIM,           "xsrdpim",        CONST,  floordf2)
 
11579
+BU_VSX_1 (XSRDPIP,           "xsrdpip",        CONST,  ceildf2)
 
11580
+BU_VSX_1 (XSRDPIZ,           "xsrdpiz",        CONST,  btruncdf2)
 
11581
 
 
11582
 /* VSX predicate functions.  */
 
11583
 BU_VSX_P (XVCMPEQSP_P,       "xvcmpeqsp_p",    CONST,  vector_eq_v4sf_p)
 
11584
@@ -1132,6 +1289,166 @@
 
11585
 BU_VSX_OVERLOAD_X (LD,      "ld")
 
11586
 BU_VSX_OVERLOAD_X (ST,      "st")
 
11587
 
 
11588
+/* 1 argument VSX instructions added in ISA 2.07.  */
 
11589
+BU_P8V_VSX_1 (XSCVSPDPN,      "xscvspdpn",     CONST,  vsx_xscvspdpn)
 
11590
+BU_P8V_VSX_1 (XSCVDPSPN,      "xscvdpspn",     CONST,  vsx_xscvdpspn)
 
11591
+
 
11592
+/* 1 argument altivec instructions added in ISA 2.07.  */
 
11593
+BU_P8V_AV_1 (ABS_V2DI,       "abs_v2di",       CONST,  absv2di2)
 
11594
+BU_P8V_AV_1 (VUPKHSW,        "vupkhsw",        CONST,  altivec_vupkhsw)
 
11595
+BU_P8V_AV_1 (VUPKLSW,        "vupklsw",        CONST,  altivec_vupklsw)
 
11596
+BU_P8V_AV_1 (VCLZB,          "vclzb",          CONST,  clzv16qi2)
 
11597
+BU_P8V_AV_1 (VCLZH,          "vclzh",          CONST,  clzv8hi2)
 
11598
+BU_P8V_AV_1 (VCLZW,          "vclzw",          CONST,  clzv4si2)
 
11599
+BU_P8V_AV_1 (VCLZD,          "vclzd",          CONST,  clzv2di2)
 
11600
+BU_P8V_AV_1 (VPOPCNTB,       "vpopcntb",       CONST,  popcountv16qi2)
 
11601
+BU_P8V_AV_1 (VPOPCNTH,       "vpopcnth",       CONST,  popcountv8hi2)
 
11602
+BU_P8V_AV_1 (VPOPCNTW,       "vpopcntw",       CONST,  popcountv4si2)
 
11603
+BU_P8V_AV_1 (VPOPCNTD,       "vpopcntd",       CONST,  popcountv2di2)
 
11604
+BU_P8V_AV_1 (VGBBD,          "vgbbd",          CONST,  p8v_vgbbd)
 
11605
+
 
11606
+/* 2 argument altivec instructions added in ISA 2.07.  */
 
11607
+BU_P8V_AV_2 (VADDUDM,          "vaddudm",      CONST,  addv2di3)
 
11608
+BU_P8V_AV_2 (VMINSD,           "vminsd",       CONST,  sminv2di3)
 
11609
+BU_P8V_AV_2 (VMAXSD,           "vmaxsd",       CONST,  smaxv2di3)
 
11610
+BU_P8V_AV_2 (VMINUD,           "vminud",       CONST,  uminv2di3)
 
11611
+BU_P8V_AV_2 (VMAXUD,           "vmaxud",       CONST,  umaxv2di3)
 
11612
+BU_P8V_AV_2 (VMRGEW,           "vmrgew",       CONST,  p8_vmrgew)
 
11613
+BU_P8V_AV_2 (VMRGOW,           "vmrgow",       CONST,  p8_vmrgow)
 
11614
+BU_P8V_AV_2 (VPKUDUM,          "vpkudum",      CONST,  altivec_vpkudum)
 
11615
+BU_P8V_AV_2 (VPKSDSS,          "vpksdss",      CONST,  altivec_vpksdss)
 
11616
+BU_P8V_AV_2 (VPKUDUS,          "vpkudus",      CONST,  altivec_vpkudus)
 
11617
+BU_P8V_AV_2 (VPKSDUS,          "vpksdus",      CONST,  altivec_vpkswus)
 
11618
+BU_P8V_AV_2 (VRLD,             "vrld",         CONST,  vrotlv2di3)
 
11619
+BU_P8V_AV_2 (VSLD,             "vsld",         CONST,  vashlv2di3)
 
11620
+BU_P8V_AV_2 (VSRD,             "vsrd",         CONST,  vlshrv2di3)
 
11621
+BU_P8V_AV_2 (VSRAD,            "vsrad",        CONST,  vashrv2di3)
 
11622
+BU_P8V_AV_2 (VSUBUDM,          "vsubudm",      CONST,  subv2di3)
 
11623
+
 
11624
+BU_P8V_AV_2 (EQV_V16QI,                "eqv_v16qi",    CONST,  eqvv16qi3)
 
11625
+BU_P8V_AV_2 (EQV_V8HI,         "eqv_v8hi",     CONST,  eqvv8hi3)
 
11626
+BU_P8V_AV_2 (EQV_V4SI,         "eqv_v4si",     CONST,  eqvv4si3)
 
11627
+BU_P8V_AV_2 (EQV_V2DI,         "eqv_v2di",     CONST,  eqvv2di3)
 
11628
+BU_P8V_AV_2 (EQV_V4SF,         "eqv_v4sf",     CONST,  eqvv4sf3)
 
11629
+BU_P8V_AV_2 (EQV_V2DF,         "eqv_v2df",     CONST,  eqvv2df3)
 
11630
+
 
11631
+BU_P8V_AV_2 (NAND_V16QI,       "nand_v16qi",   CONST,  nandv16qi3)
 
11632
+BU_P8V_AV_2 (NAND_V8HI,                "nand_v8hi",    CONST,  nandv8hi3)
 
11633
+BU_P8V_AV_2 (NAND_V4SI,                "nand_v4si",    CONST,  nandv4si3)
 
11634
+BU_P8V_AV_2 (NAND_V2DI,                "nand_v2di",    CONST,  nandv2di3)
 
11635
+BU_P8V_AV_2 (NAND_V4SF,                "nand_v4sf",    CONST,  nandv4sf3)
 
11636
+BU_P8V_AV_2 (NAND_V2DF,                "nand_v2df",    CONST,  nandv2df3)
 
11637
+
 
11638
+BU_P8V_AV_2 (ORC_V16QI,                "orc_v16qi",    CONST,  orcv16qi3)
 
11639
+BU_P8V_AV_2 (ORC_V8HI,         "orc_v8hi",     CONST,  orcv8hi3)
 
11640
+BU_P8V_AV_2 (ORC_V4SI,         "orc_v4si",     CONST,  orcv4si3)
 
11641
+BU_P8V_AV_2 (ORC_V2DI,         "orc_v2di",     CONST,  orcv2di3)
 
11642
+BU_P8V_AV_2 (ORC_V4SF,         "orc_v4sf",     CONST,  orcv4sf3)
 
11643
+BU_P8V_AV_2 (ORC_V2DF,         "orc_v2df",     CONST,  orcv2df3)
 
11644
+
 
11645
+/* Vector comparison instructions added in ISA 2.07.  */
 
11646
+BU_P8V_AV_2 (VCMPEQUD,         "vcmpequd",     CONST,  vector_eqv2di)
 
11647
+BU_P8V_AV_2 (VCMPGTSD,         "vcmpgtsd",     CONST,  vector_gtv2di)
 
11648
+BU_P8V_AV_2 (VCMPGTUD,         "vcmpgtud",     CONST,  vector_gtuv2di)
 
11649
+
 
11650
+/* Vector comparison predicate instructions added in ISA 2.07.  */
 
11651
+BU_P8V_AV_P (VCMPEQUD_P,       "vcmpequd_p",   CONST,  vector_eq_v2di_p)
 
11652
+BU_P8V_AV_P (VCMPGTSD_P,       "vcmpgtsd_p",   CONST,  vector_gt_v2di_p)
 
11653
+BU_P8V_AV_P (VCMPGTUD_P,       "vcmpgtud_p",   CONST,  vector_gtu_v2di_p)
 
11654
+
 
11655
+/* ISA 2.07 vector overloaded 1 argument functions.  */
 
11656
+BU_P8V_OVERLOAD_1 (VUPKHSW,    "vupkhsw")
 
11657
+BU_P8V_OVERLOAD_1 (VUPKLSW,    "vupklsw")
 
11658
+BU_P8V_OVERLOAD_1 (VCLZ,       "vclz")
 
11659
+BU_P8V_OVERLOAD_1 (VCLZB,      "vclzb")
 
11660
+BU_P8V_OVERLOAD_1 (VCLZH,      "vclzh")
 
11661
+BU_P8V_OVERLOAD_1 (VCLZW,      "vclzw")
 
11662
+BU_P8V_OVERLOAD_1 (VCLZD,      "vclzd")
 
11663
+BU_P8V_OVERLOAD_1 (VPOPCNT,    "vpopcnt")
 
11664
+BU_P8V_OVERLOAD_1 (VPOPCNTB,   "vpopcntb")
 
11665
+BU_P8V_OVERLOAD_1 (VPOPCNTH,   "vpopcnth")
 
11666
+BU_P8V_OVERLOAD_1 (VPOPCNTW,   "vpopcntw")
 
11667
+BU_P8V_OVERLOAD_1 (VPOPCNTD,   "vpopcntd")
 
11668
+BU_P8V_OVERLOAD_1 (VGBBD,      "vgbbd")
 
11669
+
 
11670
+/* ISA 2.07 vector overloaded 2 argument functions.  */
 
11671
+BU_P8V_OVERLOAD_2 (EQV,                "eqv")
 
11672
+BU_P8V_OVERLOAD_2 (NAND,       "nand")
 
11673
+BU_P8V_OVERLOAD_2 (ORC,                "orc")
 
11674
+BU_P8V_OVERLOAD_2 (VADDUDM,    "vaddudm")
 
11675
+BU_P8V_OVERLOAD_2 (VMAXSD,     "vmaxsd")
 
11676
+BU_P8V_OVERLOAD_2 (VMAXUD,     "vmaxud")
 
11677
+BU_P8V_OVERLOAD_2 (VMINSD,     "vminsd")
 
11678
+BU_P8V_OVERLOAD_2 (VMINUD,     "vminud")
 
11679
+BU_P8V_OVERLOAD_2 (VMRGEW,     "vmrgew")
 
11680
+BU_P8V_OVERLOAD_2 (VMRGOW,     "vmrgow")
 
11681
+BU_P8V_OVERLOAD_2 (VPKSDSS,    "vpksdss")
 
11682
+BU_P8V_OVERLOAD_2 (VPKSDUS,    "vpksdus")
 
11683
+BU_P8V_OVERLOAD_2 (VPKUDUM,    "vpkudum")
 
11684
+BU_P8V_OVERLOAD_2 (VPKUDUS,    "vpkudus")
 
11685
+BU_P8V_OVERLOAD_2 (VRLD,       "vrld")
 
11686
+BU_P8V_OVERLOAD_2 (VSLD,       "vsld")
 
11687
+BU_P8V_OVERLOAD_2 (VSRAD,      "vsrad")
 
11688
+BU_P8V_OVERLOAD_2 (VSRD,       "vsrd")
 
11689
+BU_P8V_OVERLOAD_2 (VSUBUDM,    "vsubudm")
 
11690
+
 
11691
+
 
11692
+/* 1 argument crypto functions.  */
 
11693
+BU_CRYPTO_1 (VSBOX,            "vsbox",          CONST, crypto_vsbox)
 
11694
+
 
11695
+/* 2 argument crypto functions.  */
 
11696
+BU_CRYPTO_2 (VCIPHER,          "vcipher",        CONST, crypto_vcipher)
 
11697
+BU_CRYPTO_2 (VCIPHERLAST,      "vcipherlast",    CONST, crypto_vcipherlast)
 
11698
+BU_CRYPTO_2 (VNCIPHER,         "vncipher",       CONST, crypto_vncipher)
 
11699
+BU_CRYPTO_2 (VNCIPHERLAST,     "vncipherlast",   CONST, crypto_vncipherlast)
 
11700
+BU_CRYPTO_2 (VPMSUMB,          "vpmsumb",        CONST, crypto_vpmsumb)
 
11701
+BU_CRYPTO_2 (VPMSUMH,          "vpmsumh",        CONST, crypto_vpmsumh)
 
11702
+BU_CRYPTO_2 (VPMSUMW,          "vpmsumw",        CONST, crypto_vpmsumw)
 
11703
+BU_CRYPTO_2 (VPMSUMD,          "vpmsumd",        CONST, crypto_vpmsumd)
 
11704
+
 
11705
+/* 3 argument crypto functions.  */
 
11706
+BU_CRYPTO_3 (VPERMXOR_V2DI,    "vpermxor_v2di",  CONST, crypto_vpermxor_v2di)
 
11707
+BU_CRYPTO_3 (VPERMXOR_V4SI,    "vpermxor_v4si",  CONST, crypto_vpermxor_v4si)
 
11708
+BU_CRYPTO_3 (VPERMXOR_V8HI,    "vpermxor_v8hi",  CONST, crypto_vpermxor_v8hi)
 
11709
+BU_CRYPTO_3 (VPERMXOR_V16QI,   "vpermxor_v16qi", CONST, crypto_vpermxor_v16qi)
 
11710
+BU_CRYPTO_3 (VSHASIGMAW,       "vshasigmaw",     CONST, crypto_vshasigmaw)
 
11711
+BU_CRYPTO_3 (VSHASIGMAD,       "vshasigmad",     CONST, crypto_vshasigmad)
 
11712
+
 
11713
+/* 2 argument crypto overloaded functions.  */
 
11714
+BU_CRYPTO_OVERLOAD_2 (VPMSUM,   "vpmsum")
 
11715
+
 
11716
+/* 3 argument crypto overloaded functions.  */
 
11717
+BU_CRYPTO_OVERLOAD_3 (VPERMXOR,         "vpermxor")
 
11718
+BU_CRYPTO_OVERLOAD_3 (VSHASIGMA, "vshasigma")
 
11719
+
 
11720
+
 
11721
+/* HTM functions.  */
 
11722
+BU_HTM_1  (TABORT,     "tabort",       MISC,   tabort)
 
11723
+BU_HTM_3  (TABORTDC,   "tabortdc",     MISC,   tabortdc)
 
11724
+BU_HTM_3  (TABORTDCI,  "tabortdci",    MISC,   tabortdci)
 
11725
+BU_HTM_3  (TABORTWC,   "tabortwc",     MISC,   tabortwc)
 
11726
+BU_HTM_3  (TABORTWCI,  "tabortwci",    MISC,   tabortwci)
 
11727
+BU_HTM_1  (TBEGIN,     "tbegin",       MISC,   tbegin)
 
11728
+BU_HTM_1  (TCHECK,     "tcheck",       MISC,   tcheck)
 
11729
+BU_HTM_1  (TEND,       "tend",         MISC,   tend)
 
11730
+BU_HTM_0  (TENDALL,    "tendall",      MISC,   tend)
 
11731
+BU_HTM_0  (TRECHKPT,   "trechkpt",     MISC,   trechkpt)
 
11732
+BU_HTM_1  (TRECLAIM,   "treclaim",     MISC,   treclaim)
 
11733
+BU_HTM_0  (TRESUME,    "tresume",      MISC,   tsr)
 
11734
+BU_HTM_0  (TSUSPEND,   "tsuspend",     MISC,   tsr)
 
11735
+BU_HTM_1  (TSR,                "tsr",          MISC,   tsr)
 
11736
+BU_HTM_0  (TTEST,      "ttest",        MISC,   ttest)
 
11737
+
 
11738
+BU_HTM_SPR0 (GET_TFHAR,                "get_tfhar",    MISC,   nothing)
 
11739
+BU_HTM_SPR1 (SET_TFHAR,                "set_tfhar",    MISC,   nothing)
 
11740
+BU_HTM_SPR0 (GET_TFIAR,                "get_tfiar",    MISC,   nothing)
 
11741
+BU_HTM_SPR1 (SET_TFIAR,                "set_tfiar",    MISC,   nothing)
 
11742
+BU_HTM_SPR0 (GET_TEXASR,       "get_texasr",   MISC,   nothing)
 
11743
+BU_HTM_SPR1 (SET_TEXASR,       "set_texasr",   MISC,   nothing)
 
11744
+BU_HTM_SPR0 (GET_TEXASRU,      "get_texasru",  MISC,   nothing)
 
11745
+BU_HTM_SPR1 (SET_TEXASRU,      "set_texasru",  MISC,   nothing)
 
11746
+
 
11747
+
 
11748
 /* 3 argument paired floating point builtins.  */
 
11749
 BU_PAIRED_3 (MSUB,            "msub",           FP,    fmsv2sf4)
 
11750
 BU_PAIRED_3 (MADD,            "madd",           FP,    fmav2sf4)
 
11751
@@ -1430,10 +1747,10 @@
 
11752
              RS6000_BTC_FP)
 
11753
 
 
11754
 BU_SPECIAL_X (RS6000_BUILTIN_GET_TB, "__builtin_ppc_get_timebase",
 
11755
-            RS6000_BTM_ALWAYS, RS6000_BTC_MISC)
 
11756
+             RS6000_BTM_ALWAYS, RS6000_BTC_MISC)
 
11757
 
 
11758
 BU_SPECIAL_X (RS6000_BUILTIN_MFTB, "__builtin_ppc_mftb",
 
11759
-            RS6000_BTM_ALWAYS, RS6000_BTC_MISC)
 
11760
+             RS6000_BTM_ALWAYS, RS6000_BTC_MISC)
 
11761
 
 
11762
 /* Darwin CfString builtin.  */
 
11763
 BU_SPECIAL_X (RS6000_BUILTIN_CFSTRING, "__builtin_cfstring", RS6000_BTM_ALWAYS,
 
11764
--- a/src/gcc/config/rs6000/rs6000-c.c
 
11765
+++ b/src/gcc/config/rs6000/rs6000-c.c
 
11766
@@ -315,6 +315,8 @@
 
11767
     rs6000_define_or_undefine_macro (define_p, "_ARCH_PWR6X");
 
11768
   if ((flags & OPTION_MASK_POPCNTD) != 0)
 
11769
     rs6000_define_or_undefine_macro (define_p, "_ARCH_PWR7");
 
11770
+  if ((flags & OPTION_MASK_DIRECT_MOVE) != 0)
 
11771
+    rs6000_define_or_undefine_macro (define_p, "_ARCH_PWR8");
 
11772
   if ((flags & OPTION_MASK_SOFT_FLOAT) != 0)
 
11773
     rs6000_define_or_undefine_macro (define_p, "_SOFT_FLOAT");
 
11774
   if ((flags & OPTION_MASK_RECIP_PRECISION) != 0)
 
11775
@@ -331,6 +333,12 @@
 
11776
     }
 
11777
   if ((flags & OPTION_MASK_VSX) != 0)
 
11778
     rs6000_define_or_undefine_macro (define_p, "__VSX__");
 
11779
+  if ((flags & OPTION_MASK_HTM) != 0)
 
11780
+    rs6000_define_or_undefine_macro (define_p, "__HTM__");
 
11781
+  if ((flags & OPTION_MASK_P8_VECTOR) != 0)
 
11782
+    rs6000_define_or_undefine_macro (define_p, "__POWER8_VECTOR__");
 
11783
+  if ((flags & OPTION_MASK_CRYPTO) != 0)
 
11784
+    rs6000_define_or_undefine_macro (define_p, "__CRYPTO__");
 
11785
 
 
11786
   /* options from the builtin masks.  */
 
11787
   if ((bu_mask & RS6000_BTM_SPE) != 0)
 
11788
@@ -453,7 +461,11 @@
 
11789
     case ABI_AIX:
 
11790
       builtin_define ("_CALL_AIXDESC");
 
11791
       builtin_define ("_CALL_AIX");
 
11792
+      builtin_define ("_CALL_ELF=1");
 
11793
       break;
 
11794
+    case ABI_ELFv2:
 
11795
+      builtin_define ("_CALL_ELF=2");
 
11796
+      break;
 
11797
     case ABI_DARWIN:
 
11798
       builtin_define ("_CALL_DARWIN");
 
11799
       break;
 
11800
@@ -465,6 +477,13 @@
 
11801
   if (TARGET_SOFT_FLOAT || !TARGET_FPRS)
 
11802
     builtin_define ("__NO_FPRS__");
 
11803
 
 
11804
+  /* Whether aggregates passed by value are aligned to a 16 byte boundary
 
11805
+     if their alignment is 16 bytes or larger.  */
 
11806
+  if ((TARGET_MACHO && rs6000_darwin64_abi)
 
11807
+      || DEFAULT_ABI == ABI_ELFv2
 
11808
+      || (DEFAULT_ABI == ABI_AIX && !rs6000_compat_align_parm))
 
11809
+    builtin_define ("__STRUCT_PARM_ALIGN__=16");
 
11810
+
 
11811
   /* Generate defines for Xilinx FPU. */
 
11812
   if (rs6000_xilinx_fpu) 
 
11813
     {
 
11814
@@ -505,6 +524,8 @@
 
11815
     RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0, 0 },
 
11816
   { ALTIVEC_BUILTIN_VEC_ABS, ALTIVEC_BUILTIN_ABS_V4SI,
 
11817
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0, 0 },
 
11818
+  { ALTIVEC_BUILTIN_VEC_ABS, P8V_BUILTIN_ABS_V2DI,
 
11819
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0, 0 },
 
11820
   { ALTIVEC_BUILTIN_VEC_ABS, ALTIVEC_BUILTIN_ABS_V4SF,
 
11821
     RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0, 0 },
 
11822
   { ALTIVEC_BUILTIN_VEC_ABS, VSX_BUILTIN_XVABSDP,
 
11823
@@ -577,12 +598,24 @@
 
11824
     RS6000_BTI_V4SI, RS6000_BTI_V8HI, 0, 0 },
 
11825
   { ALTIVEC_BUILTIN_VEC_UNPACKH, ALTIVEC_BUILTIN_VUPKHSH,
 
11826
     RS6000_BTI_bool_V4SI, RS6000_BTI_bool_V8HI, 0, 0 },
 
11827
+  { ALTIVEC_BUILTIN_VEC_UNPACKH, P8V_BUILTIN_VUPKHSW,
 
11828
+    RS6000_BTI_V2DI, RS6000_BTI_V4SI, 0, 0 },
 
11829
+  { ALTIVEC_BUILTIN_VEC_UNPACKH, P8V_BUILTIN_VUPKHSW,
 
11830
+    RS6000_BTI_bool_V2DI, RS6000_BTI_bool_V4SI, 0, 0 },
 
11831
   { ALTIVEC_BUILTIN_VEC_UNPACKH, ALTIVEC_BUILTIN_VUPKHPX,
 
11832
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_pixel_V8HI, 0, 0 },
 
11833
   { ALTIVEC_BUILTIN_VEC_VUPKHSH, ALTIVEC_BUILTIN_VUPKHSH,
 
11834
     RS6000_BTI_V4SI, RS6000_BTI_V8HI, 0, 0 },
 
11835
   { ALTIVEC_BUILTIN_VEC_VUPKHSH, ALTIVEC_BUILTIN_VUPKHSH,
 
11836
     RS6000_BTI_bool_V4SI, RS6000_BTI_bool_V8HI, 0, 0 },
 
11837
+  { ALTIVEC_BUILTIN_VEC_UNPACKH, P8V_BUILTIN_VUPKHSW,
 
11838
+    RS6000_BTI_V2DI, RS6000_BTI_V4SI, 0, 0 },
 
11839
+  { ALTIVEC_BUILTIN_VEC_UNPACKH, P8V_BUILTIN_VUPKHSW,
 
11840
+    RS6000_BTI_bool_V2DI, RS6000_BTI_bool_V4SI, 0, 0 },
 
11841
+  { ALTIVEC_BUILTIN_VEC_VUPKHSH, P8V_BUILTIN_VUPKHSW,
 
11842
+    RS6000_BTI_V2DI, RS6000_BTI_V4SI, 0, 0 },
 
11843
+  { ALTIVEC_BUILTIN_VEC_VUPKHSH, P8V_BUILTIN_VUPKHSW,
 
11844
+    RS6000_BTI_bool_V2DI, RS6000_BTI_bool_V4SI, 0, 0 },
 
11845
   { ALTIVEC_BUILTIN_VEC_VUPKHPX, ALTIVEC_BUILTIN_VUPKHPX,
 
11846
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V8HI, 0, 0 },
 
11847
   { ALTIVEC_BUILTIN_VEC_VUPKHPX, ALTIVEC_BUILTIN_VUPKHPX,
 
11848
@@ -601,6 +634,10 @@
 
11849
     RS6000_BTI_V4SI, RS6000_BTI_V8HI, 0, 0 },
 
11850
   { ALTIVEC_BUILTIN_VEC_UNPACKL, ALTIVEC_BUILTIN_VUPKLSH,
 
11851
     RS6000_BTI_bool_V4SI, RS6000_BTI_bool_V8HI, 0, 0 },
 
11852
+  { ALTIVEC_BUILTIN_VEC_UNPACKL, P8V_BUILTIN_VUPKLSW,
 
11853
+    RS6000_BTI_V2DI, RS6000_BTI_V4SI, 0, 0 },
 
11854
+  { ALTIVEC_BUILTIN_VEC_UNPACKL, P8V_BUILTIN_VUPKLSW,
 
11855
+    RS6000_BTI_bool_V2DI, RS6000_BTI_bool_V4SI, 0, 0 },
 
11856
   { ALTIVEC_BUILTIN_VEC_VUPKLPX, ALTIVEC_BUILTIN_VUPKLPX,
 
11857
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V8HI, 0, 0 },
 
11858
   { ALTIVEC_BUILTIN_VEC_VUPKLPX, ALTIVEC_BUILTIN_VUPKLPX,
 
11859
@@ -651,6 +688,18 @@
 
11860
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_bool_V4SI, 0 },
 
11861
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDUWM,
 
11862
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
11863
+  { ALTIVEC_BUILTIN_VEC_ADD, P8V_BUILTIN_VADDUDM,
 
11864
+    RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, RS6000_BTI_V2DI, 0 },
 
11865
+  { ALTIVEC_BUILTIN_VEC_ADD, P8V_BUILTIN_VADDUDM,
 
11866
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
11867
+  { ALTIVEC_BUILTIN_VEC_ADD, P8V_BUILTIN_VADDUDM,
 
11868
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
11869
+  { ALTIVEC_BUILTIN_VEC_ADD, P8V_BUILTIN_VADDUDM,
 
11870
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
11871
+  { ALTIVEC_BUILTIN_VEC_ADD, P8V_BUILTIN_VADDUDM,
 
11872
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
11873
+  { ALTIVEC_BUILTIN_VEC_ADD, P8V_BUILTIN_VADDUDM,
 
11874
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
11875
   { ALTIVEC_BUILTIN_VEC_ADD, ALTIVEC_BUILTIN_VADDFP,
 
11876
     RS6000_BTI_V4SF, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
 
11877
   { ALTIVEC_BUILTIN_VEC_ADD, VSX_BUILTIN_XVADDDP,
 
11878
@@ -937,6 +986,10 @@
 
11879
     RS6000_BTI_bool_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
 
11880
   { ALTIVEC_BUILTIN_VEC_CMPEQ, ALTIVEC_BUILTIN_VCMPEQUW,
 
11881
     RS6000_BTI_bool_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
11882
+  { ALTIVEC_BUILTIN_VEC_CMPEQ, P8V_BUILTIN_VCMPEQUD,
 
11883
+    RS6000_BTI_bool_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
11884
+  { ALTIVEC_BUILTIN_VEC_CMPEQ, P8V_BUILTIN_VCMPEQUD,
 
11885
+    RS6000_BTI_bool_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
11886
   { ALTIVEC_BUILTIN_VEC_CMPEQ, ALTIVEC_BUILTIN_VCMPEQFP,
 
11887
     RS6000_BTI_bool_V4SI, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
 
11888
   { ALTIVEC_BUILTIN_VEC_CMPEQ, VSX_BUILTIN_XVCMPEQDP,
 
11889
@@ -975,6 +1028,10 @@
 
11890
     RS6000_BTI_bool_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
11891
   { ALTIVEC_BUILTIN_VEC_CMPGT, ALTIVEC_BUILTIN_VCMPGTSW,
 
11892
     RS6000_BTI_bool_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
 
11893
+  { ALTIVEC_BUILTIN_VEC_CMPGT, P8V_BUILTIN_VCMPGTUD,
 
11894
+    RS6000_BTI_bool_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
11895
+  { ALTIVEC_BUILTIN_VEC_CMPGT, P8V_BUILTIN_VCMPGTSD,
 
11896
+    RS6000_BTI_bool_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
11897
   { ALTIVEC_BUILTIN_VEC_CMPGT, ALTIVEC_BUILTIN_VCMPGTFP,
 
11898
     RS6000_BTI_bool_V4SI, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
 
11899
   { ALTIVEC_BUILTIN_VEC_CMPGT, VSX_BUILTIN_XVCMPGTDP,
 
11900
@@ -1021,6 +1078,10 @@
 
11901
     RS6000_BTI_bool_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
11902
   { ALTIVEC_BUILTIN_VEC_CMPLT, ALTIVEC_BUILTIN_VCMPGTSW,
 
11903
     RS6000_BTI_bool_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
 
11904
+  { ALTIVEC_BUILTIN_VEC_CMPLT, P8V_BUILTIN_VCMPGTUD,
 
11905
+    RS6000_BTI_bool_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
11906
+  { ALTIVEC_BUILTIN_VEC_CMPLT, P8V_BUILTIN_VCMPGTSD,
 
11907
+    RS6000_BTI_bool_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
11908
   { ALTIVEC_BUILTIN_VEC_CMPLT, ALTIVEC_BUILTIN_VCMPGTFP,
 
11909
     RS6000_BTI_bool_V4SI, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
 
11910
   { ALTIVEC_BUILTIN_VEC_CMPLT, VSX_BUILTIN_XVCMPGTDP,
 
11911
@@ -1418,6 +1479,18 @@
 
11912
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_bool_V4SI, 0 },
 
11913
   { ALTIVEC_BUILTIN_VEC_MAX, ALTIVEC_BUILTIN_VMAXSW,
 
11914
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
 
11915
+  { ALTIVEC_BUILTIN_VEC_MAX, P8V_BUILTIN_VMAXUD,
 
11916
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
11917
+  { ALTIVEC_BUILTIN_VEC_MAX, P8V_BUILTIN_VMAXUD,
 
11918
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
11919
+  { ALTIVEC_BUILTIN_VEC_MAX, P8V_BUILTIN_VMAXUD,
 
11920
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
11921
+  { ALTIVEC_BUILTIN_VEC_MAX, P8V_BUILTIN_VMAXSD,
 
11922
+    RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, RS6000_BTI_V2DI, 0 },
 
11923
+  { ALTIVEC_BUILTIN_VEC_MAX, P8V_BUILTIN_VMAXSD,
 
11924
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
11925
+  { ALTIVEC_BUILTIN_VEC_MAX, P8V_BUILTIN_VMAXSD,
 
11926
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
11927
   { ALTIVEC_BUILTIN_VEC_MAX, ALTIVEC_BUILTIN_VMAXFP,
 
11928
     RS6000_BTI_V4SF, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
 
11929
   { ALTIVEC_BUILTIN_VEC_MAX, VSX_BUILTIN_XVMAXDP,
 
11930
@@ -1604,6 +1677,18 @@
 
11931
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_bool_V4SI, 0 },
 
11932
   { ALTIVEC_BUILTIN_VEC_MIN, ALTIVEC_BUILTIN_VMINSW,
 
11933
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
 
11934
+  { ALTIVEC_BUILTIN_VEC_MIN, P8V_BUILTIN_VMINUD,
 
11935
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
11936
+  { ALTIVEC_BUILTIN_VEC_MIN, P8V_BUILTIN_VMINUD,
 
11937
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
11938
+  { ALTIVEC_BUILTIN_VEC_MIN, P8V_BUILTIN_VMINUD,
 
11939
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
11940
+  { ALTIVEC_BUILTIN_VEC_MIN, P8V_BUILTIN_VMINSD,
 
11941
+    RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, RS6000_BTI_V2DI, 0 },
 
11942
+  { ALTIVEC_BUILTIN_VEC_MIN, P8V_BUILTIN_VMINSD,
 
11943
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
11944
+  { ALTIVEC_BUILTIN_VEC_MIN, P8V_BUILTIN_VMINSD,
 
11945
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
11946
   { ALTIVEC_BUILTIN_VEC_MIN, ALTIVEC_BUILTIN_VMINFP,
 
11947
     RS6000_BTI_V4SF, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
 
11948
   { ALTIVEC_BUILTIN_VEC_MIN, VSX_BUILTIN_XVMINDP,
 
11949
@@ -1786,6 +1871,12 @@
 
11950
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
11951
   { ALTIVEC_BUILTIN_VEC_PACK, ALTIVEC_BUILTIN_VPKUWUM,
 
11952
     RS6000_BTI_bool_V8HI, RS6000_BTI_bool_V4SI, RS6000_BTI_bool_V4SI, 0 },
 
11953
+  { ALTIVEC_BUILTIN_VEC_PACK, P8V_BUILTIN_VPKUDUM,
 
11954
+    RS6000_BTI_V4SI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
11955
+  { ALTIVEC_BUILTIN_VEC_PACK, P8V_BUILTIN_VPKUDUM,
 
11956
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
11957
+  { ALTIVEC_BUILTIN_VEC_PACK, P8V_BUILTIN_VPKUDUM,
 
11958
+    RS6000_BTI_bool_V4SI, RS6000_BTI_bool_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
11959
   { ALTIVEC_BUILTIN_VEC_VPKUWUM, ALTIVEC_BUILTIN_VPKUWUM,
 
11960
     RS6000_BTI_V8HI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
 
11961
   { ALTIVEC_BUILTIN_VEC_VPKUWUM, ALTIVEC_BUILTIN_VPKUWUM,
 
11962
@@ -1812,6 +1903,10 @@
 
11963
     RS6000_BTI_V8HI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
 
11964
   { ALTIVEC_BUILTIN_VEC_VPKUWUS, ALTIVEC_BUILTIN_VPKUWUS,
 
11965
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
11966
+  { ALTIVEC_BUILTIN_VEC_PACKS, P8V_BUILTIN_VPKUDUS,
 
11967
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
11968
+  { ALTIVEC_BUILTIN_VEC_PACKS, P8V_BUILTIN_VPKSDSS,
 
11969
+    RS6000_BTI_V4SI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
11970
   { ALTIVEC_BUILTIN_VEC_VPKSHSS, ALTIVEC_BUILTIN_VPKSHSS,
 
11971
     RS6000_BTI_V16QI, RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0 },
 
11972
   { ALTIVEC_BUILTIN_VEC_VPKUHUS, ALTIVEC_BUILTIN_VPKUHUS,
 
11973
@@ -1824,6 +1919,8 @@
 
11974
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
11975
   { ALTIVEC_BUILTIN_VEC_PACKSU, ALTIVEC_BUILTIN_VPKSWUS,
 
11976
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
 
11977
+  { ALTIVEC_BUILTIN_VEC_PACKSU, P8V_BUILTIN_VPKSDUS,
 
11978
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
11979
   { ALTIVEC_BUILTIN_VEC_VPKSWUS, ALTIVEC_BUILTIN_VPKSWUS,
 
11980
     RS6000_BTI_unsigned_V8HI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
 
11981
   { ALTIVEC_BUILTIN_VEC_VPKSHUS, ALTIVEC_BUILTIN_VPKSHUS,
 
11982
@@ -1844,6 +1941,10 @@
 
11983
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
11984
   { ALTIVEC_BUILTIN_VEC_RL, ALTIVEC_BUILTIN_VRLW,
 
11985
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
11986
+  { ALTIVEC_BUILTIN_VEC_RL, P8V_BUILTIN_VRLD,
 
11987
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
11988
+  { ALTIVEC_BUILTIN_VEC_RL, P8V_BUILTIN_VRLD,
 
11989
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
11990
   { ALTIVEC_BUILTIN_VEC_VRLW, ALTIVEC_BUILTIN_VRLW,
 
11991
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
11992
   { ALTIVEC_BUILTIN_VEC_VRLW, ALTIVEC_BUILTIN_VRLW,
 
11993
@@ -1868,6 +1969,10 @@
 
11994
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
11995
   { ALTIVEC_BUILTIN_VEC_SL, ALTIVEC_BUILTIN_VSLW,
 
11996
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
11997
+  { ALTIVEC_BUILTIN_VEC_SL, P8V_BUILTIN_VSLD,
 
11998
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
11999
+  { ALTIVEC_BUILTIN_VEC_SL, P8V_BUILTIN_VSLD,
 
12000
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12001
   { ALTIVEC_BUILTIN_VEC_SQRT, VSX_BUILTIN_XVSQRTDP,
 
12002
     RS6000_BTI_V2DF, RS6000_BTI_V2DF, 0, 0 },
 
12003
   { ALTIVEC_BUILTIN_VEC_SQRT, VSX_BUILTIN_XVSQRTSP,
 
12004
@@ -2032,6 +2137,10 @@
 
12005
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
12006
   { ALTIVEC_BUILTIN_VEC_SR, ALTIVEC_BUILTIN_VSRW,
 
12007
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
12008
+  { ALTIVEC_BUILTIN_VEC_SR, P8V_BUILTIN_VSRD,
 
12009
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12010
+  { ALTIVEC_BUILTIN_VEC_SR, P8V_BUILTIN_VSRD,
 
12011
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12012
   { ALTIVEC_BUILTIN_VEC_VSRW, ALTIVEC_BUILTIN_VSRW,
 
12013
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
12014
   { ALTIVEC_BUILTIN_VEC_VSRW, ALTIVEC_BUILTIN_VSRW,
 
12015
@@ -2056,6 +2165,10 @@
 
12016
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
12017
   { ALTIVEC_BUILTIN_VEC_SRA, ALTIVEC_BUILTIN_VSRAW,
 
12018
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
12019
+  { ALTIVEC_BUILTIN_VEC_SRA, P8V_BUILTIN_VSRAD,
 
12020
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12021
+  { ALTIVEC_BUILTIN_VEC_SRA, P8V_BUILTIN_VSRD,
 
12022
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12023
   { ALTIVEC_BUILTIN_VEC_VSRAW, ALTIVEC_BUILTIN_VSRAW,
 
12024
     RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
12025
   { ALTIVEC_BUILTIN_VEC_VSRAW, ALTIVEC_BUILTIN_VSRAW,
 
12026
@@ -2196,6 +2309,18 @@
 
12027
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_bool_V4SI, 0 },
 
12028
   { ALTIVEC_BUILTIN_VEC_SUB, ALTIVEC_BUILTIN_VSUBUWM,
 
12029
     RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0 },
 
12030
+  { ALTIVEC_BUILTIN_VEC_SUB, P8V_BUILTIN_VSUBUDM,
 
12031
+    RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, RS6000_BTI_V2DI, 0 },
 
12032
+  { ALTIVEC_BUILTIN_VEC_SUB, P8V_BUILTIN_VSUBUDM,
 
12033
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
12034
+  { ALTIVEC_BUILTIN_VEC_SUB, P8V_BUILTIN_VSUBUDM,
 
12035
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
12036
+  { ALTIVEC_BUILTIN_VEC_SUB, P8V_BUILTIN_VSUBUDM,
 
12037
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12038
+  { ALTIVEC_BUILTIN_VEC_SUB, P8V_BUILTIN_VSUBUDM,
 
12039
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
12040
+  { ALTIVEC_BUILTIN_VEC_SUB, P8V_BUILTIN_VSUBUDM,
 
12041
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12042
   { ALTIVEC_BUILTIN_VEC_SUB, ALTIVEC_BUILTIN_VSUBFP,
 
12043
     RS6000_BTI_V4SF, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
 
12044
   { ALTIVEC_BUILTIN_VEC_SUB, VSX_BUILTIN_XVSUBDP,
 
12045
@@ -3327,6 +3452,20 @@
 
12046
     RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_V4SI, RS6000_BTI_V4SI },
 
12047
   { ALTIVEC_BUILTIN_VEC_VCMPEQ_P, ALTIVEC_BUILTIN_VCMPEQUW_P,
 
12048
     RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_bool_V4SI, RS6000_BTI_bool_V4SI },
 
12049
+  { ALTIVEC_BUILTIN_VEC_VCMPEQ_P, P8V_BUILTIN_VCMPEQUD_P,
 
12050
+    RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_bool_V2DI, RS6000_BTI_unsigned_V2DI },
 
12051
+  { ALTIVEC_BUILTIN_VEC_VCMPEQ_P, P8V_BUILTIN_VCMPEQUD_P,
 
12052
+    RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI },
 
12053
+  { ALTIVEC_BUILTIN_VEC_VCMPEQ_P, P8V_BUILTIN_VCMPEQUD_P,
 
12054
+    RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI },
 
12055
+  { ALTIVEC_BUILTIN_VEC_VCMPEQ_P, P8V_BUILTIN_VCMPEQUD_P,
 
12056
+    RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_bool_V2DI, RS6000_BTI_V2DI },
 
12057
+  { ALTIVEC_BUILTIN_VEC_VCMPEQ_P, P8V_BUILTIN_VCMPEQUD_P,
 
12058
+    RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI },
 
12059
+  { ALTIVEC_BUILTIN_VEC_VCMPEQ_P, P8V_BUILTIN_VCMPEQUD_P,
 
12060
+    RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_V2DI, RS6000_BTI_V2DI },
 
12061
+  { ALTIVEC_BUILTIN_VEC_VCMPEQ_P, P8V_BUILTIN_VCMPEQUD_P,
 
12062
+    RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_bool_V2DI, RS6000_BTI_bool_V2DI },
 
12063
   { ALTIVEC_BUILTIN_VEC_VCMPEQ_P, ALTIVEC_BUILTIN_VCMPEQFP_P,
 
12064
     RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_V4SF, RS6000_BTI_V4SF },
 
12065
   { ALTIVEC_BUILTIN_VEC_VCMPEQ_P, VSX_BUILTIN_XVCMPEQDP_P,
 
12066
@@ -3372,11 +3511,455 @@
 
12067
     RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_V4SI, RS6000_BTI_bool_V4SI },
 
12068
   { ALTIVEC_BUILTIN_VEC_VCMPGE_P, ALTIVEC_BUILTIN_VCMPGTSW_P,
 
12069
     RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_V4SI, RS6000_BTI_V4SI },
 
12070
+  { ALTIVEC_BUILTIN_VEC_VCMPGE_P, P8V_BUILTIN_VCMPGTUD_P,
 
12071
+    RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_bool_V2DI, RS6000_BTI_unsigned_V2DI },
 
12072
+  { ALTIVEC_BUILTIN_VEC_VCMPGE_P, P8V_BUILTIN_VCMPGTUD_P,
 
12073
+    RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI },
 
12074
+  { ALTIVEC_BUILTIN_VEC_VCMPGE_P, P8V_BUILTIN_VCMPGTUD_P,
 
12075
+    RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI },
 
12076
+  { ALTIVEC_BUILTIN_VEC_VCMPGE_P, P8V_BUILTIN_VCMPGTSD_P,
 
12077
+    RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_bool_V2DI, RS6000_BTI_V2DI },
 
12078
+  { ALTIVEC_BUILTIN_VEC_VCMPGE_P, P8V_BUILTIN_VCMPGTSD_P,
 
12079
+    RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI },
 
12080
+  { ALTIVEC_BUILTIN_VEC_VCMPGE_P, P8V_BUILTIN_VCMPGTSD_P,
 
12081
+    RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_V2DI, RS6000_BTI_V2DI },
 
12082
   { ALTIVEC_BUILTIN_VEC_VCMPGE_P, ALTIVEC_BUILTIN_VCMPGEFP_P,
 
12083
     RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_V4SF, RS6000_BTI_V4SF },
 
12084
   { ALTIVEC_BUILTIN_VEC_VCMPGE_P, VSX_BUILTIN_XVCMPGEDP_P,
 
12085
     RS6000_BTI_INTSI, RS6000_BTI_INTSI, RS6000_BTI_V2DF, RS6000_BTI_V2DF },
 
12086
 
 
12087
+  /* Power8 vector overloaded functions.  */
 
12088
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V16QI,
 
12089
+    RS6000_BTI_V16QI, RS6000_BTI_bool_V16QI, RS6000_BTI_V16QI, 0 },
 
12090
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V16QI,
 
12091
+    RS6000_BTI_V16QI, RS6000_BTI_V16QI, RS6000_BTI_bool_V16QI, 0 },
 
12092
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V16QI,
 
12093
+    RS6000_BTI_V16QI, RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0 },
 
12094
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V16QI,
 
12095
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_bool_V16QI,
 
12096
+    RS6000_BTI_unsigned_V16QI, 0 },
 
12097
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V16QI,
 
12098
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI,
 
12099
+    RS6000_BTI_bool_V16QI, 0 },
 
12100
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V16QI,
 
12101
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI,
 
12102
+    RS6000_BTI_unsigned_V16QI, 0 },
 
12103
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V8HI,
 
12104
+    RS6000_BTI_V8HI, RS6000_BTI_bool_V8HI, RS6000_BTI_V8HI, 0 },
 
12105
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V8HI,
 
12106
+    RS6000_BTI_V8HI, RS6000_BTI_V8HI, RS6000_BTI_bool_V8HI, 0 },
 
12107
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V8HI,
 
12108
+    RS6000_BTI_V8HI, RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0 },
 
12109
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V8HI,
 
12110
+    RS6000_BTI_unsigned_V8HI, RS6000_BTI_bool_V8HI,
 
12111
+    RS6000_BTI_unsigned_V8HI, 0 },
 
12112
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V8HI,
 
12113
+    RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI,
 
12114
+    RS6000_BTI_bool_V8HI, 0 },
 
12115
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V8HI,
 
12116
+    RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI,
 
12117
+    RS6000_BTI_unsigned_V8HI, 0 },
 
12118
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V4SI,
 
12119
+    RS6000_BTI_V4SI, RS6000_BTI_bool_V4SI, RS6000_BTI_V4SI, 0 },
 
12120
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V4SI,
 
12121
+    RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_bool_V4SI, 0 },
 
12122
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V4SI,
 
12123
+    RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
 
12124
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V4SI,
 
12125
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_bool_V4SI,
 
12126
+    RS6000_BTI_unsigned_V4SI, 0 },
 
12127
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V4SI,
 
12128
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI,
 
12129
+    RS6000_BTI_bool_V4SI, 0 },
 
12130
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V4SI,
 
12131
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI,
 
12132
+    RS6000_BTI_unsigned_V4SI, 0 },
 
12133
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V2DI,
 
12134
+    RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, RS6000_BTI_V2DI, 0 },
 
12135
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V2DI,
 
12136
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
12137
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V2DI,
 
12138
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
12139
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V2DI,
 
12140
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI,
 
12141
+    RS6000_BTI_unsigned_V2DI, 0 },
 
12142
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V2DI,
 
12143
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI,
 
12144
+    RS6000_BTI_bool_V2DI, 0 },
 
12145
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V2DI,
 
12146
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI,
 
12147
+    RS6000_BTI_unsigned_V2DI, 0 },
 
12148
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V4SF,
 
12149
+    RS6000_BTI_V4SF, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
 
12150
+  { P8V_BUILTIN_VEC_EQV, P8V_BUILTIN_EQV_V2DF,
 
12151
+    RS6000_BTI_V2DF, RS6000_BTI_V2DF, RS6000_BTI_V2DF, 0 },
 
12152
+
 
12153
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V16QI,
 
12154
+    RS6000_BTI_V16QI, RS6000_BTI_bool_V16QI, RS6000_BTI_V16QI, 0 },
 
12155
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V16QI,
 
12156
+    RS6000_BTI_V16QI, RS6000_BTI_V16QI, RS6000_BTI_bool_V16QI, 0 },
 
12157
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V16QI,
 
12158
+    RS6000_BTI_V16QI, RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0 },
 
12159
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V16QI,
 
12160
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_bool_V16QI,
 
12161
+    RS6000_BTI_unsigned_V16QI, 0 },
 
12162
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V16QI,
 
12163
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI,
 
12164
+    RS6000_BTI_bool_V16QI, 0 },
 
12165
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V16QI,
 
12166
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI,
 
12167
+    RS6000_BTI_unsigned_V16QI, 0 },
 
12168
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V8HI,
 
12169
+    RS6000_BTI_V8HI, RS6000_BTI_bool_V8HI, RS6000_BTI_V8HI, 0 },
 
12170
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V8HI,
 
12171
+    RS6000_BTI_V8HI, RS6000_BTI_V8HI, RS6000_BTI_bool_V8HI, 0 },
 
12172
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V8HI,
 
12173
+    RS6000_BTI_V8HI, RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0 },
 
12174
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V8HI,
 
12175
+    RS6000_BTI_unsigned_V8HI, RS6000_BTI_bool_V8HI,
 
12176
+    RS6000_BTI_unsigned_V8HI, 0 },
 
12177
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V8HI,
 
12178
+    RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI,
 
12179
+    RS6000_BTI_bool_V8HI, 0 },
 
12180
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V8HI,
 
12181
+    RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI,
 
12182
+    RS6000_BTI_unsigned_V8HI, 0 },
 
12183
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V4SI,
 
12184
+    RS6000_BTI_V4SI, RS6000_BTI_bool_V4SI, RS6000_BTI_V4SI, 0 },
 
12185
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V4SI,
 
12186
+    RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_bool_V4SI, 0 },
 
12187
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V4SI,
 
12188
+    RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
 
12189
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V4SI,
 
12190
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_bool_V4SI,
 
12191
+    RS6000_BTI_unsigned_V4SI, 0 },
 
12192
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V4SI,
 
12193
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI,
 
12194
+    RS6000_BTI_bool_V4SI, 0 },
 
12195
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V4SI,
 
12196
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI,
 
12197
+    RS6000_BTI_unsigned_V4SI, 0 },
 
12198
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V2DI,
 
12199
+    RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, RS6000_BTI_V2DI, 0 },
 
12200
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V2DI,
 
12201
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
12202
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V2DI,
 
12203
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
12204
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V2DI,
 
12205
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI,
 
12206
+    RS6000_BTI_unsigned_V2DI, 0 },
 
12207
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V2DI,
 
12208
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI,
 
12209
+    RS6000_BTI_bool_V2DI, 0 },
 
12210
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V2DI,
 
12211
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI,
 
12212
+    RS6000_BTI_unsigned_V2DI, 0 },
 
12213
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V4SF,
 
12214
+    RS6000_BTI_V4SF, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
 
12215
+  { P8V_BUILTIN_VEC_NAND, P8V_BUILTIN_NAND_V2DF,
 
12216
+    RS6000_BTI_V2DF, RS6000_BTI_V2DF, RS6000_BTI_V2DF, 0 },
 
12217
+
 
12218
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V16QI,
 
12219
+    RS6000_BTI_V16QI, RS6000_BTI_bool_V16QI, RS6000_BTI_V16QI, 0 },
 
12220
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V16QI,
 
12221
+    RS6000_BTI_V16QI, RS6000_BTI_V16QI, RS6000_BTI_bool_V16QI, 0 },
 
12222
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V16QI,
 
12223
+    RS6000_BTI_V16QI, RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0 },
 
12224
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V16QI,
 
12225
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_bool_V16QI,
 
12226
+    RS6000_BTI_unsigned_V16QI, 0 },
 
12227
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V16QI,
 
12228
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI,
 
12229
+    RS6000_BTI_bool_V16QI, 0 },
 
12230
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V16QI,
 
12231
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI,
 
12232
+    RS6000_BTI_unsigned_V16QI, 0 },
 
12233
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V8HI,
 
12234
+    RS6000_BTI_V8HI, RS6000_BTI_bool_V8HI, RS6000_BTI_V8HI, 0 },
 
12235
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V8HI,
 
12236
+    RS6000_BTI_V8HI, RS6000_BTI_V8HI, RS6000_BTI_bool_V8HI, 0 },
 
12237
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V8HI,
 
12238
+    RS6000_BTI_V8HI, RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0 },
 
12239
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V8HI,
 
12240
+    RS6000_BTI_unsigned_V8HI, RS6000_BTI_bool_V8HI,
 
12241
+    RS6000_BTI_unsigned_V8HI, 0 },
 
12242
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V8HI,
 
12243
+    RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI,
 
12244
+    RS6000_BTI_bool_V8HI, 0 },
 
12245
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V8HI,
 
12246
+    RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI,
 
12247
+    RS6000_BTI_unsigned_V8HI, 0 },
 
12248
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V4SI,
 
12249
+    RS6000_BTI_V4SI, RS6000_BTI_bool_V4SI, RS6000_BTI_V4SI, 0 },
 
12250
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V4SI,
 
12251
+    RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_bool_V4SI, 0 },
 
12252
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V4SI,
 
12253
+    RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
 
12254
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V4SI,
 
12255
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_bool_V4SI,
 
12256
+    RS6000_BTI_unsigned_V4SI, 0 },
 
12257
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V4SI,
 
12258
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI,
 
12259
+    RS6000_BTI_bool_V4SI, 0 },
 
12260
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V4SI,
 
12261
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI,
 
12262
+    RS6000_BTI_unsigned_V4SI, 0 },
 
12263
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V2DI,
 
12264
+    RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, RS6000_BTI_V2DI, 0 },
 
12265
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V2DI,
 
12266
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
12267
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V2DI,
 
12268
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
12269
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V2DI,
 
12270
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI,
 
12271
+    RS6000_BTI_unsigned_V2DI, 0 },
 
12272
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V2DI,
 
12273
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI,
 
12274
+    RS6000_BTI_bool_V2DI, 0 },
 
12275
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V2DI,
 
12276
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI,
 
12277
+    RS6000_BTI_unsigned_V2DI, 0 },
 
12278
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V4SF,
 
12279
+    RS6000_BTI_V4SF, RS6000_BTI_V4SF, RS6000_BTI_V4SF, 0 },
 
12280
+  { P8V_BUILTIN_VEC_ORC, P8V_BUILTIN_ORC_V2DF,
 
12281
+    RS6000_BTI_V2DF, RS6000_BTI_V2DF, RS6000_BTI_V2DF, 0 },
 
12282
+
 
12283
+  { P8V_BUILTIN_VEC_VADDUDM, P8V_BUILTIN_VADDUDM,
 
12284
+    RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, RS6000_BTI_V2DI, 0 },
 
12285
+  { P8V_BUILTIN_VEC_VADDUDM, P8V_BUILTIN_VADDUDM,
 
12286
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
12287
+  { P8V_BUILTIN_VEC_VADDUDM, P8V_BUILTIN_VADDUDM,
 
12288
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
12289
+  { P8V_BUILTIN_VEC_VADDUDM, P8V_BUILTIN_VADDUDM,
 
12290
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12291
+  { P8V_BUILTIN_VEC_VADDUDM, P8V_BUILTIN_VADDUDM,
 
12292
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
12293
+  { P8V_BUILTIN_VEC_VADDUDM, P8V_BUILTIN_VADDUDM,
 
12294
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12295
+
 
12296
+  { P8V_BUILTIN_VEC_VCLZ, P8V_BUILTIN_VCLZB,
 
12297
+    RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0, 0 },
 
12298
+  { P8V_BUILTIN_VEC_VCLZ, P8V_BUILTIN_VCLZB,
 
12299
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, 0, 0 },
 
12300
+  { P8V_BUILTIN_VEC_VCLZ, P8V_BUILTIN_VCLZH,
 
12301
+    RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0, 0 },
 
12302
+  { P8V_BUILTIN_VEC_VCLZ, P8V_BUILTIN_VCLZH,
 
12303
+    RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, 0, 0 },
 
12304
+  { P8V_BUILTIN_VEC_VCLZ, P8V_BUILTIN_VCLZW,
 
12305
+    RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0, 0 },
 
12306
+  { P8V_BUILTIN_VEC_VCLZ, P8V_BUILTIN_VCLZW,
 
12307
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0, 0 },
 
12308
+  { P8V_BUILTIN_VEC_VCLZ, P8V_BUILTIN_VCLZD,
 
12309
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0, 0 },
 
12310
+  { P8V_BUILTIN_VEC_VCLZ, P8V_BUILTIN_VCLZD,
 
12311
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0, 0 },
 
12312
+
 
12313
+  { P8V_BUILTIN_VEC_VCLZB, P8V_BUILTIN_VCLZB,
 
12314
+    RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0, 0 },
 
12315
+  { P8V_BUILTIN_VEC_VCLZB, P8V_BUILTIN_VCLZB,
 
12316
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, 0, 0 },
 
12317
+
 
12318
+  { P8V_BUILTIN_VEC_VCLZH, P8V_BUILTIN_VCLZH,
 
12319
+    RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0, 0 },
 
12320
+  { P8V_BUILTIN_VEC_VCLZH, P8V_BUILTIN_VCLZH,
 
12321
+    RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, 0, 0 },
 
12322
+
 
12323
+  { P8V_BUILTIN_VEC_VCLZW, P8V_BUILTIN_VCLZW,
 
12324
+    RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0, 0 },
 
12325
+  { P8V_BUILTIN_VEC_VCLZW, P8V_BUILTIN_VCLZW,
 
12326
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0, 0 },
 
12327
+
 
12328
+  { P8V_BUILTIN_VEC_VCLZD, P8V_BUILTIN_VCLZD,
 
12329
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0, 0 },
 
12330
+  { P8V_BUILTIN_VEC_VCLZD, P8V_BUILTIN_VCLZD,
 
12331
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0, 0 },
 
12332
+
 
12333
+  { P8V_BUILTIN_VEC_VGBBD, P8V_BUILTIN_VGBBD,
 
12334
+    RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0, 0 },
 
12335
+  { P8V_BUILTIN_VEC_VGBBD, P8V_BUILTIN_VGBBD,
 
12336
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, 0, 0 },
 
12337
+
 
12338
+  { P8V_BUILTIN_VEC_VMINSD, P8V_BUILTIN_VMINSD,
 
12339
+    RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, RS6000_BTI_V2DI, 0 },
 
12340
+  { P8V_BUILTIN_VEC_VMINSD, P8V_BUILTIN_VMINSD,
 
12341
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
12342
+  { P8V_BUILTIN_VEC_VMINSD, P8V_BUILTIN_VMINSD,
 
12343
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
12344
+
 
12345
+  { P8V_BUILTIN_VEC_VMAXSD, P8V_BUILTIN_VMAXSD,
 
12346
+    RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, RS6000_BTI_V2DI, 0 },
 
12347
+  { P8V_BUILTIN_VEC_VMAXSD, P8V_BUILTIN_VMAXSD,
 
12348
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
12349
+  { P8V_BUILTIN_VEC_VMAXSD, P8V_BUILTIN_VMAXSD,
 
12350
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
12351
+
 
12352
+  { P8V_BUILTIN_VEC_VMINUD, P8V_BUILTIN_VMINUD,
 
12353
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI,
 
12354
+    RS6000_BTI_unsigned_V2DI, 0 },
 
12355
+  { P8V_BUILTIN_VEC_VMINUD, P8V_BUILTIN_VMINUD,
 
12356
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI,
 
12357
+    RS6000_BTI_bool_V2DI, 0 },
 
12358
+  { P8V_BUILTIN_VEC_VMINUD, P8V_BUILTIN_VMINUD,
 
12359
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI,
 
12360
+    RS6000_BTI_unsigned_V2DI, 0 },
 
12361
+
 
12362
+  { P8V_BUILTIN_VEC_VMAXUD, P8V_BUILTIN_VMAXUD,
 
12363
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI,
 
12364
+    RS6000_BTI_unsigned_V2DI, 0 },
 
12365
+  { P8V_BUILTIN_VEC_VMAXUD, P8V_BUILTIN_VMAXUD,
 
12366
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI,
 
12367
+    RS6000_BTI_bool_V2DI, 0 },
 
12368
+  { P8V_BUILTIN_VEC_VMAXUD, P8V_BUILTIN_VMAXUD,
 
12369
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI,
 
12370
+    RS6000_BTI_unsigned_V2DI, 0 },
 
12371
+
 
12372
+  { P8V_BUILTIN_VEC_VMRGEW, P8V_BUILTIN_VMRGEW,
 
12373
+    RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
 
12374
+  { P8V_BUILTIN_VEC_VMRGEW, P8V_BUILTIN_VMRGEW,
 
12375
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI,
 
12376
+    RS6000_BTI_unsigned_V4SI, 0 },
 
12377
+
 
12378
+  { P8V_BUILTIN_VEC_VMRGOW, P8V_BUILTIN_VMRGOW,
 
12379
+    RS6000_BTI_V4SI, RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0 },
 
12380
+  { P8V_BUILTIN_VEC_VMRGOW, P8V_BUILTIN_VMRGOW,
 
12381
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI,
 
12382
+    RS6000_BTI_unsigned_V4SI, 0 },
 
12383
+
 
12384
+  { P8V_BUILTIN_VEC_VPOPCNT, P8V_BUILTIN_VPOPCNTB,
 
12385
+    RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0, 0 },
 
12386
+  { P8V_BUILTIN_VEC_VPOPCNT, P8V_BUILTIN_VPOPCNTB,
 
12387
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, 0, 0 },
 
12388
+  { P8V_BUILTIN_VEC_VPOPCNT, P8V_BUILTIN_VPOPCNTH,
 
12389
+    RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0, 0 },
 
12390
+  { P8V_BUILTIN_VEC_VPOPCNT, P8V_BUILTIN_VPOPCNTH,
 
12391
+    RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, 0, 0 },
 
12392
+  { P8V_BUILTIN_VEC_VPOPCNT, P8V_BUILTIN_VPOPCNTW,
 
12393
+    RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0, 0 },
 
12394
+  { P8V_BUILTIN_VEC_VPOPCNT, P8V_BUILTIN_VPOPCNTW,
 
12395
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0, 0 },
 
12396
+  { P8V_BUILTIN_VEC_VPOPCNT, P8V_BUILTIN_VPOPCNTD,
 
12397
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0, 0 },
 
12398
+  { P8V_BUILTIN_VEC_VPOPCNT, P8V_BUILTIN_VPOPCNTD,
 
12399
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0, 0 },
 
12400
+
 
12401
+  { P8V_BUILTIN_VEC_VPOPCNTB, P8V_BUILTIN_VPOPCNTB,
 
12402
+    RS6000_BTI_V16QI, RS6000_BTI_V16QI, 0, 0 },
 
12403
+  { P8V_BUILTIN_VEC_VPOPCNTB, P8V_BUILTIN_VPOPCNTB,
 
12404
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI, 0, 0 },
 
12405
+
 
12406
+  { P8V_BUILTIN_VEC_VPOPCNTH, P8V_BUILTIN_VPOPCNTH,
 
12407
+    RS6000_BTI_V8HI, RS6000_BTI_V8HI, 0, 0 },
 
12408
+  { P8V_BUILTIN_VEC_VPOPCNTH, P8V_BUILTIN_VPOPCNTH,
 
12409
+    RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI, 0, 0 },
 
12410
+
 
12411
+  { P8V_BUILTIN_VEC_VPOPCNTW, P8V_BUILTIN_VPOPCNTW,
 
12412
+    RS6000_BTI_V4SI, RS6000_BTI_V4SI, 0, 0 },
 
12413
+  { P8V_BUILTIN_VEC_VPOPCNTW, P8V_BUILTIN_VPOPCNTW,
 
12414
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI, 0, 0 },
 
12415
+
 
12416
+  { P8V_BUILTIN_VEC_VPOPCNTD, P8V_BUILTIN_VPOPCNTD,
 
12417
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0, 0 },
 
12418
+  { P8V_BUILTIN_VEC_VPOPCNTD, P8V_BUILTIN_VPOPCNTD,
 
12419
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0, 0 },
 
12420
+
 
12421
+  { P8V_BUILTIN_VEC_VPKUDUM, P8V_BUILTIN_VPKUDUM,
 
12422
+    RS6000_BTI_V4SI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
12423
+  { P8V_BUILTIN_VEC_VPKUDUM, P8V_BUILTIN_VPKUDUM,
 
12424
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12425
+  { P8V_BUILTIN_VEC_VPKUDUM, P8V_BUILTIN_VPKUDUM,
 
12426
+    RS6000_BTI_bool_V4SI, RS6000_BTI_bool_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
12427
+
 
12428
+  { P8V_BUILTIN_VEC_VPKSDSS, P8V_BUILTIN_VPKSDSS,
 
12429
+    RS6000_BTI_V4SI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
12430
+
 
12431
+  { P8V_BUILTIN_VEC_VPKUDUS, P8V_BUILTIN_VPKUDUS,
 
12432
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12433
+
 
12434
+  { P8V_BUILTIN_VEC_VPKSDUS, P8V_BUILTIN_VPKSDUS,
 
12435
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
12436
+
 
12437
+  { P8V_BUILTIN_VEC_VRLD, P8V_BUILTIN_VRLD,
 
12438
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12439
+  { P8V_BUILTIN_VEC_VRLD, P8V_BUILTIN_VRLD,
 
12440
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12441
+
 
12442
+  { P8V_BUILTIN_VEC_VSLD, P8V_BUILTIN_VSLD,
 
12443
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12444
+  { P8V_BUILTIN_VEC_VSLD, P8V_BUILTIN_VSLD,
 
12445
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12446
+
 
12447
+  { P8V_BUILTIN_VEC_VSRD, P8V_BUILTIN_VSRD,
 
12448
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12449
+  { P8V_BUILTIN_VEC_VSRD, P8V_BUILTIN_VSRD,
 
12450
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12451
+
 
12452
+  { P8V_BUILTIN_VEC_VSRAD, P8V_BUILTIN_VSRAD,
 
12453
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12454
+  { P8V_BUILTIN_VEC_VSRAD, P8V_BUILTIN_VSRD,
 
12455
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12456
+
 
12457
+  { P8V_BUILTIN_VEC_VSUBUDM, P8V_BUILTIN_VSUBUDM,
 
12458
+    RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, RS6000_BTI_V2DI, 0 },
 
12459
+  { P8V_BUILTIN_VEC_VSUBUDM, P8V_BUILTIN_VSUBUDM,
 
12460
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
12461
+  { P8V_BUILTIN_VEC_VSUBUDM, P8V_BUILTIN_VSUBUDM,
 
12462
+    RS6000_BTI_V2DI, RS6000_BTI_V2DI, RS6000_BTI_V2DI, 0 },
 
12463
+  { P8V_BUILTIN_VEC_VSUBUDM, P8V_BUILTIN_VSUBUDM,
 
12464
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12465
+  { P8V_BUILTIN_VEC_VSUBUDM, P8V_BUILTIN_VSUBUDM,
 
12466
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_bool_V2DI, 0 },
 
12467
+  { P8V_BUILTIN_VEC_VSUBUDM, P8V_BUILTIN_VSUBUDM,
 
12468
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI, 0 },
 
12469
+
 
12470
+  { P8V_BUILTIN_VEC_VUPKHSW, P8V_BUILTIN_VUPKHSW,
 
12471
+    RS6000_BTI_V2DI, RS6000_BTI_V4SI, 0, 0 },
 
12472
+  { P8V_BUILTIN_VEC_VUPKHSW, P8V_BUILTIN_VUPKHSW,
 
12473
+    RS6000_BTI_bool_V2DI, RS6000_BTI_bool_V4SI, 0, 0 },
 
12474
+
 
12475
+  { P8V_BUILTIN_VEC_VUPKLSW, P8V_BUILTIN_VUPKLSW,
 
12476
+    RS6000_BTI_V2DI, RS6000_BTI_V4SI, 0, 0 },
 
12477
+  { P8V_BUILTIN_VEC_VUPKLSW, P8V_BUILTIN_VUPKLSW,
 
12478
+    RS6000_BTI_bool_V2DI, RS6000_BTI_bool_V4SI, 0, 0 },
 
12479
+
 
12480
+  { P8V_BUILTIN_VEC_VGBBD, P8V_BUILTIN_VGBBD,
 
12481
+    RS6000_BTI_V16QI, 0, 0, 0 },
 
12482
+  { P8V_BUILTIN_VEC_VGBBD, P8V_BUILTIN_VGBBD,
 
12483
+    RS6000_BTI_unsigned_V16QI, 0, 0, 0 },
 
12484
+
 
12485
+  /* Crypto builtins.  */
 
12486
+  { CRYPTO_BUILTIN_VPERMXOR, CRYPTO_BUILTIN_VPERMXOR_V16QI,
 
12487
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI,
 
12488
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI },
 
12489
+  { CRYPTO_BUILTIN_VPERMXOR, CRYPTO_BUILTIN_VPERMXOR_V8HI,
 
12490
+    RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI,
 
12491
+    RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI },
 
12492
+  { CRYPTO_BUILTIN_VPERMXOR, CRYPTO_BUILTIN_VPERMXOR_V4SI,
 
12493
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI,
 
12494
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI },
 
12495
+  { CRYPTO_BUILTIN_VPERMXOR, CRYPTO_BUILTIN_VPERMXOR_V2DI,
 
12496
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI,
 
12497
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI },
 
12498
+
 
12499
+  { CRYPTO_BUILTIN_VPMSUM, CRYPTO_BUILTIN_VPMSUMB,
 
12500
+    RS6000_BTI_unsigned_V16QI, RS6000_BTI_unsigned_V16QI,
 
12501
+    RS6000_BTI_unsigned_V16QI, 0 },
 
12502
+  { CRYPTO_BUILTIN_VPMSUM, CRYPTO_BUILTIN_VPMSUMH,
 
12503
+    RS6000_BTI_unsigned_V8HI, RS6000_BTI_unsigned_V8HI,
 
12504
+    RS6000_BTI_unsigned_V8HI, 0 },
 
12505
+  { CRYPTO_BUILTIN_VPMSUM, CRYPTO_BUILTIN_VPMSUMW,
 
12506
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI,
 
12507
+    RS6000_BTI_unsigned_V4SI, 0 },
 
12508
+  { CRYPTO_BUILTIN_VPMSUM, CRYPTO_BUILTIN_VPMSUMD,
 
12509
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI,
 
12510
+    RS6000_BTI_unsigned_V2DI, 0 },
 
12511
+
 
12512
+  { CRYPTO_BUILTIN_VSHASIGMA, CRYPTO_BUILTIN_VSHASIGMAW,
 
12513
+    RS6000_BTI_unsigned_V4SI, RS6000_BTI_unsigned_V4SI,
 
12514
+    RS6000_BTI_INTSI, RS6000_BTI_INTSI },
 
12515
+  { CRYPTO_BUILTIN_VSHASIGMA, CRYPTO_BUILTIN_VSHASIGMAD,
 
12516
+    RS6000_BTI_unsigned_V2DI, RS6000_BTI_unsigned_V2DI,
 
12517
+    RS6000_BTI_INTSI, RS6000_BTI_INTSI },
 
12518
+
 
12519
   { (enum rs6000_builtins) 0, (enum rs6000_builtins) 0, 0, 0, 0, 0 }
 
12520
 };
 
12521
 
 
12522
@@ -3824,7 +4407,8 @@
 
12523
        && (desc->op2 == RS6000_BTI_NOT_OPAQUE
 
12524
            || rs6000_builtin_type_compatible (types[1], desc->op2))
 
12525
        && (desc->op3 == RS6000_BTI_NOT_OPAQUE
 
12526
-           || rs6000_builtin_type_compatible (types[2], desc->op3)))
 
12527
+           || rs6000_builtin_type_compatible (types[2], desc->op3))
 
12528
+       && rs6000_builtin_decls[desc->overloaded_code] != NULL_TREE)
 
12529
       return altivec_build_resolved_builtin (args, n, desc);
 
12530
 
 
12531
  bad:
 
12532
--- a/src/gcc/config/rs6000/rs6000.opt
 
12533
+++ b/src/gcc/config/rs6000/rs6000.opt
 
12534
@@ -181,13 +181,16 @@
 
12535
 Target Report Mask(VSX) Var(rs6000_isa_flags)
 
12536
 Use vector/scalar (VSX) instructions
 
12537
 
 
12538
+mvsx-scalar-float
 
12539
+Target Undocumented Report Var(TARGET_VSX_SCALAR_FLOAT) Init(1)
 
12540
+; If -mpower8-vector, use VSX arithmetic instructions for SFmode (on by default)
 
12541
+
 
12542
 mvsx-scalar-double
 
12543
-Target Undocumented Report Var(TARGET_VSX_SCALAR_DOUBLE) Init(-1)
 
12544
-; If -mvsx, use VSX arithmetic instructions for scalar double (on by default)
 
12545
+Target Undocumented Report Var(TARGET_VSX_SCALAR_DOUBLE) Init(1)
 
12546
+; If -mvsx, use VSX arithmetic instructions for DFmode (on by default)
 
12547
 
 
12548
 mvsx-scalar-memory
 
12549
-Target Undocumented Report Var(TARGET_VSX_SCALAR_MEMORY)
 
12550
-; If -mvsx, use VSX scalar memory reference instructions for scalar double (off by default)
 
12551
+Target Undocumented Report Alias(mupper-regs-df)
 
12552
 
 
12553
 mvsx-align-128
 
12554
 Target Undocumented Report Var(TARGET_VSX_ALIGN_128)
 
12555
@@ -363,6 +366,14 @@
 
12556
 Target RejectNegative Var(rs6000_spe_abi, 0)
 
12557
 Do not use the SPE ABI extensions
 
12558
 
 
12559
+mabi=elfv1
 
12560
+Target RejectNegative Var(rs6000_elf_abi, 1) Save
 
12561
+Use the ELFv1 ABI
 
12562
+
 
12563
+mabi=elfv2
 
12564
+Target RejectNegative Var(rs6000_elf_abi, 2)
 
12565
+Use the ELFv2 ABI
 
12566
+
 
12567
 ; These are here for testing during development only, do not document
 
12568
 ; in the manual please.
 
12569
 
 
12570
@@ -514,3 +525,47 @@
 
12571
 msave-toc-indirect
 
12572
 Target Report Var(TARGET_SAVE_TOC_INDIRECT) Save
 
12573
 Control whether we save the TOC in the prologue for indirect calls or generate the save inline
 
12574
+
 
12575
+mvsx-timode
 
12576
+Target Undocumented Mask(VSX_TIMODE) Var(rs6000_isa_flags)
 
12577
+Allow 128-bit integers in VSX registers
 
12578
+
 
12579
+mpower8-fusion
 
12580
+Target Report Mask(P8_FUSION) Var(rs6000_isa_flags)
 
12581
+Fuse certain integer operations together for better performance on power8
 
12582
+
 
12583
+mpower8-fusion-sign
 
12584
+Target Undocumented Mask(P8_FUSION_SIGN) Var(rs6000_isa_flags)
 
12585
+Allow sign extension in fusion operations
 
12586
+
 
12587
+mpower8-vector
 
12588
+Target Report Mask(P8_VECTOR) Var(rs6000_isa_flags)
 
12589
+Use/do not use vector and scalar instructions added in ISA 2.07.
 
12590
+
 
12591
+mcrypto
 
12592
+Target Report Mask(CRYPTO) Var(rs6000_isa_flags)
 
12593
+Use ISA 2.07 crypto instructions
 
12594
+
 
12595
+mdirect-move
 
12596
+Target Report Mask(DIRECT_MOVE) Var(rs6000_isa_flags)
 
12597
+Use ISA 2.07 direct move between GPR & VSX register instructions
 
12598
+
 
12599
+mhtm
 
12600
+Target Report Mask(HTM) Var(rs6000_isa_flags)
 
12601
+Use ISA 2.07 transactional memory (HTM) instructions
 
12602
+
 
12603
+mquad-memory
 
12604
+Target Report Mask(QUAD_MEMORY) Var(rs6000_isa_flags)
 
12605
+Generate the quad word memory instructions (lq/stq/lqarx/stqcx).
 
12606
+
 
12607
+mcompat-align-parm
 
12608
+Target Report Var(rs6000_compat_align_parm) Init(1) Save
 
12609
+Generate aggregate parameter passing code with at most 64-bit alignment.
 
12610
+
 
12611
+mupper-regs-df
 
12612
+Target Undocumented Mask(UPPER_REGS_DF) Var(rs6000_isa_flags)
 
12613
+Allow double variables in upper registers with -mcpu=power7 or -mvsx
 
12614
+
 
12615
+mupper-regs-sf
 
12616
+Target Undocumented Mask(UPPER_REGS_SF) Var(rs6000_isa_flags)
 
12617
+Allow float variables in upper registers with -mcpu=power8 or -mp8-vector
 
12618
--- a/src/gcc/config/rs6000/linux64.h
 
12619
+++ b/src/gcc/config/rs6000/linux64.h
 
12620
@@ -25,9 +25,6 @@
 
12621
 
 
12622
 #ifndef RS6000_BI_ARCH
 
12623
 
 
12624
-#undef DEFAULT_ABI
 
12625
-#define        DEFAULT_ABI ABI_AIX
 
12626
-
 
12627
 #undef TARGET_64BIT
 
12628
 #define        TARGET_64BIT 1
 
12629
 
 
12630
@@ -74,7 +71,11 @@
 
12631
 #undef  PROCESSOR_DEFAULT
 
12632
 #define PROCESSOR_DEFAULT PROCESSOR_POWER7
 
12633
 #undef  PROCESSOR_DEFAULT64
 
12634
+#ifdef LINUX64_DEFAULT_ABI_ELFv2
 
12635
+#define PROCESSOR_DEFAULT64 PROCESSOR_POWER8
 
12636
+#else
 
12637
 #define PROCESSOR_DEFAULT64 PROCESSOR_POWER7
 
12638
+#endif
 
12639
 
 
12640
 /* We don't need to generate entries in .fixup, except when
 
12641
    -mrelocatable or -mrelocatable-lib is given.  */
 
12642
@@ -88,6 +89,12 @@
 
12643
 #define INVALID_64BIT "-m%s not supported in this configuration"
 
12644
 #define INVALID_32BIT INVALID_64BIT
 
12645
 
 
12646
+#ifdef LINUX64_DEFAULT_ABI_ELFv2
 
12647
+#define ELFv2_ABI_CHECK (rs6000_elf_abi != 1)
 
12648
+#else
 
12649
+#define ELFv2_ABI_CHECK (rs6000_elf_abi == 2)
 
12650
+#endif
 
12651
+
 
12652
 #undef SUBSUBTARGET_OVERRIDE_OPTIONS
 
12653
 #define        SUBSUBTARGET_OVERRIDE_OPTIONS                           \
 
12654
   do                                                           \
 
12655
@@ -102,6 +109,12 @@
 
12656
              error (INVALID_64BIT, "call");                    \
 
12657
            }                                                   \
 
12658
          dot_symbols = !strcmp (rs6000_abi_name, "aixdesc");   \
 
12659
+         if (ELFv2_ABI_CHECK)                                  \
 
12660
+           {                                                   \
 
12661
+             rs6000_current_abi = ABI_ELFv2;                   \
 
12662
+             if (dot_symbols)                                  \
 
12663
+               error ("-mcall-aixdesc incompatible with -mabi=elfv2"); \
 
12664
+           }                                                   \
 
12665
          if (rs6000_isa_flags & OPTION_MASK_RELOCATABLE)       \
 
12666
            {                                                   \
 
12667
              rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE;     \
 
12668
@@ -351,7 +364,11 @@
 
12669
 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
 
12670
 
 
12671
 #define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1"
 
12672
-#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld64.so.1"
 
12673
+#ifdef LINUX64_DEFAULT_ABI_ELFv2
 
12674
+#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv1:/lib64/ld64.so.1;:/lib64/ld64.so.2}"
 
12675
+#else
 
12676
+#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv2:/lib64/ld64.so.2;:/lib64/ld64.so.1}"
 
12677
+#endif
 
12678
 #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
 
12679
 #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
 
12680
 #if DEFAULT_LIBC == LIBC_UCLIBC
 
12681
--- a/src/gcc/config/rs6000/darwin.h
 
12682
+++ b/src/gcc/config/rs6000/darwin.h
 
12683
@@ -205,7 +205,8 @@
 
12684
     "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",             \
 
12685
     "vrsave", "vscr",                                                  \
 
12686
     "spe_acc", "spefscr",                                               \
 
12687
-    "sfp"                                                              \
 
12688
+    "sfp",                                                             \
 
12689
+    "tfhar", "tfiar", "texasr"                                         \
 
12690
 }
 
12691
 
 
12692
 /* This outputs NAME to FILE.  */
 
12693
--- a/src/gcc/config/rs6000/rs6000.c
 
12694
+++ b/src/gcc/config/rs6000/rs6000.c
 
12695
@@ -96,6 +96,7 @@
 
12696
   int spe_gp_save_offset;      /* offset to save spe 64-bit gprs  */
 
12697
   int varargs_save_offset;     /* offset to save the varargs registers */
 
12698
   int ehrd_offset;             /* offset to EH return data */
 
12699
+  int ehcr_offset;             /* offset to EH CR field data */
 
12700
   int reg_size;                        /* register size (4 or 8) */
 
12701
   HOST_WIDE_INT vars_size;     /* variable save area size */
 
12702
   int parm_size;               /* outgoing parameter size */
 
12703
@@ -139,6 +140,8 @@
 
12704
      64-bits wide and is allocated early enough so that the offset
 
12705
      does not overflow the 16-bit load/store offset field.  */
 
12706
   rtx sdmode_stack_slot;
 
12707
+  /* Flag if r2 setup is needed with ELFv2 ABI.  */
 
12708
+  bool r2_setup_needed;
 
12709
 } machine_function;
 
12710
 
 
12711
 /* Support targetm.vectorize.builtin_mask_for_load.  */
 
12712
@@ -189,9 +192,6 @@
 
12713
 /* Map register number to register class.  */
 
12714
 enum reg_class rs6000_regno_regclass[FIRST_PSEUDO_REGISTER];
 
12715
 
 
12716
-/* Reload functions based on the type and the vector unit.  */
 
12717
-static enum insn_code rs6000_vector_reload[NUM_MACHINE_MODES][2];
 
12718
-
 
12719
 static int dbg_cost_ctrl;
 
12720
 
 
12721
 /* Built in types.  */
 
12722
@@ -289,6 +289,105 @@
 
12723
    don't link in rs6000-c.c, so we can't call it directly.  */
 
12724
 void (*rs6000_target_modify_macros_ptr) (bool, HOST_WIDE_INT, HOST_WIDE_INT);
 
12725
 
 
12726
+/* Simplfy register classes into simpler classifications.  We assume
 
12727
+   GPR_REG_TYPE - FPR_REG_TYPE are ordered so that we can use a simple range
 
12728
+   check for standard register classes (gpr/floating/altivec/vsx) and
 
12729
+   floating/vector classes (float/altivec/vsx).  */
 
12730
+
 
12731
+enum rs6000_reg_type {
 
12732
+  NO_REG_TYPE,
 
12733
+  PSEUDO_REG_TYPE,
 
12734
+  GPR_REG_TYPE,
 
12735
+  VSX_REG_TYPE,
 
12736
+  ALTIVEC_REG_TYPE,
 
12737
+  FPR_REG_TYPE,
 
12738
+  SPR_REG_TYPE,
 
12739
+  CR_REG_TYPE,
 
12740
+  SPE_ACC_TYPE,
 
12741
+  SPEFSCR_REG_TYPE
 
12742
+};
 
12743
+
 
12744
+/* Map register class to register type.  */
 
12745
+static enum rs6000_reg_type reg_class_to_reg_type[N_REG_CLASSES];
 
12746
+
 
12747
+/* First/last register type for the 'normal' register types (i.e. general
 
12748
+   purpose, floating point, altivec, and VSX registers).  */
 
12749
+#define IS_STD_REG_TYPE(RTYPE) IN_RANGE(RTYPE, GPR_REG_TYPE, FPR_REG_TYPE)
 
12750
+
 
12751
+#define IS_FP_VECT_REG_TYPE(RTYPE) IN_RANGE(RTYPE, VSX_REG_TYPE, FPR_REG_TYPE)
 
12752
+
 
12753
+
 
12754
+/* Register classes we care about in secondary reload or go if legitimate
 
12755
+   address.  We only need to worry about GPR, FPR, and Altivec registers here,
 
12756
+   along an ANY field that is the OR of the 3 register classes.  */
 
12757
+
 
12758
+enum rs6000_reload_reg_type {
 
12759
+  RELOAD_REG_GPR,                      /* General purpose registers.  */
 
12760
+  RELOAD_REG_FPR,                      /* Traditional floating point regs.  */
 
12761
+  RELOAD_REG_VMX,                      /* Altivec (VMX) registers.  */
 
12762
+  RELOAD_REG_ANY,                      /* OR of GPR, FPR, Altivec masks.  */
 
12763
+  N_RELOAD_REG
 
12764
+};
 
12765
+
 
12766
+/* For setting up register classes, loop through the 3 register classes mapping
 
12767
+   into real registers, and skip the ANY class, which is just an OR of the
 
12768
+   bits.  */
 
12769
+#define FIRST_RELOAD_REG_CLASS RELOAD_REG_GPR
 
12770
+#define LAST_RELOAD_REG_CLASS  RELOAD_REG_VMX
 
12771
+
 
12772
+/* Map reload register type to a register in the register class.  */
 
12773
+struct reload_reg_map_type {
 
12774
+  const char *name;                    /* Register class name.  */
 
12775
+  int reg;                             /* Register in the register class.  */
 
12776
+};
 
12777
+
 
12778
+static const struct reload_reg_map_type reload_reg_map[N_RELOAD_REG] = {
 
12779
+  { "Gpr",     FIRST_GPR_REGNO },      /* RELOAD_REG_GPR.  */
 
12780
+  { "Fpr",     FIRST_FPR_REGNO },      /* RELOAD_REG_FPR.  */
 
12781
+  { "VMX",     FIRST_ALTIVEC_REGNO },  /* RELOAD_REG_VMX.  */
 
12782
+  { "Any",     -1 },                   /* RELOAD_REG_ANY.  */
 
12783
+};
 
12784
+
 
12785
+/* Mask bits for each register class, indexed per mode.  Historically the
 
12786
+   compiler has been more restrictive which types can do PRE_MODIFY instead of
 
12787
+   PRE_INC and PRE_DEC, so keep track of sepaate bits for these two.  */
 
12788
+typedef unsigned char addr_mask_type;
 
12789
+
 
12790
+#define RELOAD_REG_VALID       0x01    /* Mode valid in register..  */
 
12791
+#define RELOAD_REG_MULTIPLE    0x02    /* Mode takes multiple registers.  */
 
12792
+#define RELOAD_REG_INDEXED     0x04    /* Reg+reg addressing.  */
 
12793
+#define RELOAD_REG_OFFSET      0x08    /* Reg+offset addressing. */
 
12794
+#define RELOAD_REG_PRE_INCDEC  0x10    /* PRE_INC/PRE_DEC valid.  */
 
12795
+#define RELOAD_REG_PRE_MODIFY  0x20    /* PRE_MODIFY valid.  */
 
12796
+
 
12797
+/* Register type masks based on the type, of valid addressing modes.  */
 
12798
+struct rs6000_reg_addr {
 
12799
+  enum insn_code reload_load;          /* INSN to reload for loading. */
 
12800
+  enum insn_code reload_store;         /* INSN to reload for storing.  */
 
12801
+  enum insn_code reload_fpr_gpr;       /* INSN to move from FPR to GPR.  */
 
12802
+  enum insn_code reload_gpr_vsx;       /* INSN to move from GPR to VSX.  */
 
12803
+  enum insn_code reload_vsx_gpr;       /* INSN to move from VSX to GPR.  */
 
12804
+  addr_mask_type addr_mask[(int)N_RELOAD_REG]; /* Valid address masks.  */
 
12805
+};
 
12806
+
 
12807
+static struct rs6000_reg_addr reg_addr[NUM_MACHINE_MODES];
 
12808
+
 
12809
+/* Helper function to say whether a mode supports PRE_INC or PRE_DEC.  */
 
12810
+static inline bool
 
12811
+mode_supports_pre_incdec_p (enum machine_mode mode)
 
12812
+{
 
12813
+  return ((reg_addr[mode].addr_mask[RELOAD_REG_ANY] & RELOAD_REG_PRE_INCDEC)
 
12814
+         != 0);
 
12815
+}
 
12816
+
 
12817
+/* Helper function to say whether a mode supports PRE_MODIFY.  */
 
12818
+static inline bool
 
12819
+mode_supports_pre_modify_p (enum machine_mode mode)
 
12820
+{
 
12821
+  return ((reg_addr[mode].addr_mask[RELOAD_REG_ANY] & RELOAD_REG_PRE_MODIFY)
 
12822
+         != 0);
 
12823
+}
 
12824
+
 
12825
 
 
12826
 /* Target cpu costs.  */
 
12827
 
 
12828
@@ -828,6 +927,25 @@
 
12829
   12,                  /* prefetch streams */
 
12830
 };
 
12831
 
 
12832
+/* Instruction costs on POWER8 processors.  */
 
12833
+static const
 
12834
+struct processor_costs power8_cost = {
 
12835
+  COSTS_N_INSNS (3),   /* mulsi */
 
12836
+  COSTS_N_INSNS (3),   /* mulsi_const */
 
12837
+  COSTS_N_INSNS (3),   /* mulsi_const9 */
 
12838
+  COSTS_N_INSNS (3),   /* muldi */
 
12839
+  COSTS_N_INSNS (19),  /* divsi */
 
12840
+  COSTS_N_INSNS (35),  /* divdi */
 
12841
+  COSTS_N_INSNS (3),   /* fp */
 
12842
+  COSTS_N_INSNS (3),   /* dmul */
 
12843
+  COSTS_N_INSNS (14),  /* sdiv */
 
12844
+  COSTS_N_INSNS (17),  /* ddiv */
 
12845
+  128,                 /* cache line size */
 
12846
+  32,                  /* l1 cache */
 
12847
+  256,                 /* l2 cache */
 
12848
+  12,                  /* prefetch streams */
 
12849
+};
 
12850
+
 
12851
 /* Instruction costs on POWER A2 processors.  */
 
12852
 static const
 
12853
 struct processor_costs ppca2_cost = {
 
12854
@@ -855,6 +973,7 @@
 
12855
 #undef RS6000_BUILTIN_A
 
12856
 #undef RS6000_BUILTIN_D
 
12857
 #undef RS6000_BUILTIN_E
 
12858
+#undef RS6000_BUILTIN_H
 
12859
 #undef RS6000_BUILTIN_P
 
12860
 #undef RS6000_BUILTIN_Q
 
12861
 #undef RS6000_BUILTIN_S
 
12862
@@ -878,6 +997,9 @@
 
12863
 #define RS6000_BUILTIN_E(ENUM, NAME, MASK, ATTR, ICODE)  \
 
12864
   { NAME, ICODE, MASK, ATTR },
 
12865
 
 
12866
+#define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)  \
 
12867
+  { NAME, ICODE, MASK, ATTR },
 
12868
+
 
12869
 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)  \
 
12870
   { NAME, ICODE, MASK, ATTR },
 
12871
 
 
12872
@@ -908,6 +1030,7 @@
 
12873
 #undef RS6000_BUILTIN_A
 
12874
 #undef RS6000_BUILTIN_D
 
12875
 #undef RS6000_BUILTIN_E
 
12876
+#undef RS6000_BUILTIN_H
 
12877
 #undef RS6000_BUILTIN_P
 
12878
 #undef RS6000_BUILTIN_Q
 
12879
 #undef RS6000_BUILTIN_S
 
12880
@@ -948,6 +1071,7 @@
 
12881
 static void paired_init_builtins (void);
 
12882
 static rtx paired_expand_predicate_builtin (enum insn_code, tree, rtx);
 
12883
 static void spe_init_builtins (void);
 
12884
+static void htm_init_builtins (void);
 
12885
 static rtx spe_expand_predicate_builtin (enum insn_code, tree, rtx);
 
12886
 static rtx spe_expand_evsel_builtin (enum insn_code, tree, rtx);
 
12887
 static int rs6000_emit_int_cmove (rtx, rtx, rtx, rtx);
 
12888
@@ -1020,6 +1144,13 @@
 
12889
 static void rs6000_print_builtin_options (FILE *, int, const char *,
 
12890
                                          HOST_WIDE_INT);
 
12891
 
 
12892
+static enum rs6000_reg_type register_to_reg_type (rtx, bool *);
 
12893
+static bool rs6000_secondary_reload_move (enum rs6000_reg_type,
 
12894
+                                         enum rs6000_reg_type,
 
12895
+                                         enum machine_mode,
 
12896
+                                         secondary_reload_info *,
 
12897
+                                         bool);
 
12898
+
 
12899
 /* Hash table stuff for keeping track of TOC entries.  */
 
12900
 
 
12901
 struct GTY(()) toc_hash_struct
 
12902
@@ -1068,7 +1199,9 @@
 
12903
       /* SPE registers.  */
 
12904
       "spe_acc", "spefscr",
 
12905
       /* Soft frame pointer.  */
 
12906
-      "sfp"
 
12907
+      "sfp",
 
12908
+      /* HTM SPR registers.  */
 
12909
+      "tfhar", "tfiar", "texasr"
 
12910
 };
 
12911
 
 
12912
 #ifdef TARGET_REGNAMES
 
12913
@@ -1094,7 +1227,9 @@
 
12914
   /* SPE registers.  */
 
12915
   "spe_acc", "spefscr",
 
12916
   /* Soft frame pointer.  */
 
12917
-  "sfp"
 
12918
+  "sfp",
 
12919
+  /* HTM SPR registers.  */
 
12920
+  "tfhar", "tfiar", "texasr"
 
12921
 };
 
12922
 #endif
 
12923
 
 
12924
@@ -1316,6 +1451,9 @@
 
12925
 #undef TARGET_RETURN_IN_MEMORY
 
12926
 #define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory
 
12927
 
 
12928
+#undef TARGET_RETURN_IN_MSB
 
12929
+#define TARGET_RETURN_IN_MSB rs6000_return_in_msb
 
12930
+
 
12931
 #undef TARGET_SETUP_INCOMING_VARARGS
 
12932
 #define TARGET_SETUP_INCOMING_VARARGS setup_incoming_varargs
 
12933
 
 
12934
@@ -1513,8 +1651,9 @@
 
12935
 {
 
12936
   unsigned HOST_WIDE_INT reg_size;
 
12937
 
 
12938
+  /* TF/TD modes are special in that they always take 2 registers.  */
 
12939
   if (FP_REGNO_P (regno))
 
12940
-    reg_size = (VECTOR_MEM_VSX_P (mode)
 
12941
+    reg_size = ((VECTOR_MEM_VSX_P (mode) && mode != TDmode && mode != TFmode)
 
12942
                ? UNITS_PER_VSX_WORD
 
12943
                : UNITS_PER_FP_WORD);
 
12944
 
 
12945
@@ -1546,16 +1685,38 @@
 
12946
 {
 
12947
   int last_regno = regno + rs6000_hard_regno_nregs[mode][regno] - 1;
 
12948
 
 
12949
+  /* PTImode can only go in GPRs.  Quad word memory operations require even/odd
 
12950
+     register combinations, and use PTImode where we need to deal with quad
 
12951
+     word memory operations.  Don't allow quad words in the argument or frame
 
12952
+     pointer registers, just registers 0..31.  */
 
12953
+  if (mode == PTImode)
 
12954
+    return (IN_RANGE (regno, FIRST_GPR_REGNO, LAST_GPR_REGNO)
 
12955
+           && IN_RANGE (last_regno, FIRST_GPR_REGNO, LAST_GPR_REGNO)
 
12956
+           && ((regno & 1) == 0));
 
12957
+
 
12958
   /* VSX registers that overlap the FPR registers are larger than for non-VSX
 
12959
      implementations.  Don't allow an item to be split between a FP register
 
12960
-     and an Altivec register.  */
 
12961
-  if (VECTOR_MEM_VSX_P (mode))
 
12962
+     and an Altivec register.  Allow TImode in all VSX registers if the user
 
12963
+     asked for it.  */
 
12964
+  if (TARGET_VSX && VSX_REGNO_P (regno)
 
12965
+      && (VECTOR_MEM_VSX_P (mode)
 
12966
+         || (TARGET_VSX_SCALAR_FLOAT && mode == SFmode)
 
12967
+         || (TARGET_VSX_SCALAR_DOUBLE && (mode == DFmode || mode == DImode))
 
12968
+         || (TARGET_VSX_TIMODE && mode == TImode)))
 
12969
     {
 
12970
       if (FP_REGNO_P (regno))
 
12971
        return FP_REGNO_P (last_regno);
 
12972
 
 
12973
       if (ALTIVEC_REGNO_P (regno))
 
12974
-       return ALTIVEC_REGNO_P (last_regno);
 
12975
+       {
 
12976
+         if (mode == SFmode && !TARGET_UPPER_REGS_SF)
 
12977
+           return 0;
 
12978
+
 
12979
+         if ((mode == DFmode || mode == DImode) && !TARGET_UPPER_REGS_DF)
 
12980
+           return 0;
 
12981
+
 
12982
+         return ALTIVEC_REGNO_P (last_regno);
 
12983
+       }
 
12984
     }
 
12985
 
 
12986
   /* The GPRs can hold any mode, but values bigger than one register
 
12987
@@ -1564,8 +1725,7 @@
 
12988
     return INT_REGNO_P (last_regno);
 
12989
 
 
12990
   /* The float registers (except for VSX vector modes) can only hold floating
 
12991
-     modes and DImode.  This excludes the 32-bit decimal float mode for
 
12992
-     now.  */
 
12993
+     modes and DImode.  */
 
12994
   if (FP_REGNO_P (regno))
 
12995
     {
 
12996
       if (SCALAR_FLOAT_MODE_P (mode)
 
12997
@@ -1599,9 +1759,8 @@
 
12998
   if (SPE_SIMD_REGNO_P (regno) && TARGET_SPE && SPE_VECTOR_MODE (mode))
 
12999
     return 1;
 
13000
 
 
13001
-  /* We cannot put TImode anywhere except general register and it must be able
 
13002
-     to fit within the register set.  In the future, allow TImode in the
 
13003
-     Altivec or VSX registers.  */
 
13004
+  /* We cannot put non-VSX TImode or PTImode anywhere except general register
 
13005
+     and it must be able to fit within the register set.  */
 
13006
 
 
13007
   return GET_MODE_SIZE (mode) <= UNITS_PER_WORD;
 
13008
 }
 
13009
@@ -1674,10 +1833,77 @@
 
13010
          comma = "";
 
13011
        }
 
13012
 
 
13013
+      len += fprintf (stderr, "%sreg-class = %s", comma,
 
13014
+                     reg_class_names[(int)rs6000_regno_regclass[r]]);
 
13015
+      comma = ", ";
 
13016
+
 
13017
+      if (len > 70)
 
13018
+       {
 
13019
+         fprintf (stderr, ",\n\t");
 
13020
+         comma = "";
 
13021
+       }
 
13022
+
 
13023
       fprintf (stderr, "%sregno = %d\n", comma, r);
 
13024
     }
 
13025
 }
 
13026
 
 
13027
+static const char *
 
13028
+rs6000_debug_vector_unit (enum rs6000_vector v)
 
13029
+{
 
13030
+  const char *ret;
 
13031
+
 
13032
+  switch (v)
 
13033
+    {
 
13034
+    case VECTOR_NONE:     ret = "none";      break;
 
13035
+    case VECTOR_ALTIVEC:   ret = "altivec";   break;
 
13036
+    case VECTOR_VSX:      ret = "vsx";       break;
 
13037
+    case VECTOR_P8_VECTOR: ret = "p8_vector"; break;
 
13038
+    case VECTOR_PAIRED:           ret = "paired";    break;
 
13039
+    case VECTOR_SPE:      ret = "spe";       break;
 
13040
+    case VECTOR_OTHER:    ret = "other";     break;
 
13041
+    default:              ret = "unknown";   break;
 
13042
+    }
 
13043
+
 
13044
+  return ret;
 
13045
+}
 
13046
+
 
13047
+/* Print the address masks in a human readble fashion.  */
 
13048
+DEBUG_FUNCTION void
 
13049
+rs6000_debug_print_mode (ssize_t m)
 
13050
+{
 
13051
+  ssize_t rc;
 
13052
+
 
13053
+  fprintf (stderr, "Mode: %-5s", GET_MODE_NAME (m));
 
13054
+  for (rc = 0; rc < N_RELOAD_REG; rc++)
 
13055
+    {
 
13056
+      addr_mask_type mask = reg_addr[m].addr_mask[rc];
 
13057
+      fprintf (stderr,
 
13058
+              "  %s: %c%c%c%c%c%c",
 
13059
+              reload_reg_map[rc].name,
 
13060
+              (mask & RELOAD_REG_VALID)      != 0 ? 'v' : ' ',
 
13061
+              (mask & RELOAD_REG_MULTIPLE)   != 0 ? 'm' : ' ',
 
13062
+              (mask & RELOAD_REG_INDEXED)    != 0 ? 'i' : ' ',
 
13063
+              (mask & RELOAD_REG_OFFSET)     != 0 ? 'o' : ' ',
 
13064
+              (mask & RELOAD_REG_PRE_INCDEC) != 0 ? '+' : ' ',
 
13065
+              (mask & RELOAD_REG_PRE_MODIFY) != 0 ? '+' : ' ');
 
13066
+    }
 
13067
+
 
13068
+  if (rs6000_vector_unit[m] != VECTOR_NONE
 
13069
+      || rs6000_vector_mem[m] != VECTOR_NONE
 
13070
+      || (reg_addr[m].reload_store != CODE_FOR_nothing)
 
13071
+      || (reg_addr[m].reload_load != CODE_FOR_nothing))
 
13072
+    {
 
13073
+      fprintf (stderr,
 
13074
+              "  Vector-arith=%-10s Vector-mem=%-10s Reload=%c%c",
 
13075
+              rs6000_debug_vector_unit (rs6000_vector_unit[m]),
 
13076
+              rs6000_debug_vector_unit (rs6000_vector_mem[m]),
 
13077
+              (reg_addr[m].reload_store != CODE_FOR_nothing) ? 's' : '*',
 
13078
+              (reg_addr[m].reload_load != CODE_FOR_nothing) ? 'l' : '*');
 
13079
+    }
 
13080
+
 
13081
+  fputs ("\n", stderr);
 
13082
+}
 
13083
+
 
13084
 #define DEBUG_FMT_ID "%-32s= "
 
13085
 #define DEBUG_FMT_D   DEBUG_FMT_ID "%d\n"
 
13086
 #define DEBUG_FMT_WX  DEBUG_FMT_ID "%#.12" HOST_WIDE_INT_PRINT "x: "
 
13087
@@ -1690,6 +1916,7 @@
 
13088
   static const char *const tf[2] = { "false", "true" };
 
13089
   const char *nl = (const char *)0;
 
13090
   int m;
 
13091
+  size_t m1, m2, v;
 
13092
   char costly_num[20];
 
13093
   char nop_num[20];
 
13094
   char flags_buffer[40];
 
13095
@@ -1700,20 +1927,67 @@
 
13096
   const char *cmodel_str;
 
13097
   struct cl_target_option cl_opts;
 
13098
 
 
13099
-  /* Map enum rs6000_vector to string.  */
 
13100
-  static const char *rs6000_debug_vector_unit[] = {
 
13101
-    "none",
 
13102
-    "altivec",
 
13103
-    "vsx",
 
13104
-    "paired",
 
13105
-    "spe",
 
13106
-    "other"
 
13107
+  /* Modes we want tieable information on.  */
 
13108
+  static const enum machine_mode print_tieable_modes[] = {
 
13109
+    QImode,
 
13110
+    HImode,
 
13111
+    SImode,
 
13112
+    DImode,
 
13113
+    TImode,
 
13114
+    PTImode,
 
13115
+    SFmode,
 
13116
+    DFmode,
 
13117
+    TFmode,
 
13118
+    SDmode,
 
13119
+    DDmode,
 
13120
+    TDmode,
 
13121
+    V8QImode,
 
13122
+    V4HImode,
 
13123
+    V2SImode,
 
13124
+    V16QImode,
 
13125
+    V8HImode,
 
13126
+    V4SImode,
 
13127
+    V2DImode,
 
13128
+    V32QImode,
 
13129
+    V16HImode,
 
13130
+    V8SImode,
 
13131
+    V4DImode,
 
13132
+    V2SFmode,
 
13133
+    V4SFmode,
 
13134
+    V2DFmode,
 
13135
+    V8SFmode,
 
13136
+    V4DFmode,
 
13137
+    CCmode,
 
13138
+    CCUNSmode,
 
13139
+    CCEQmode,
 
13140
   };
 
13141
 
 
13142
-  fprintf (stderr, "Register information: (last virtual reg = %d)\n",
 
13143
-          LAST_VIRTUAL_REGISTER);
 
13144
-  rs6000_debug_reg_print (0, 31, "gr");
 
13145
-  rs6000_debug_reg_print (32, 63, "fp");
 
13146
+  /* Virtual regs we are interested in.  */
 
13147
+  const static struct {
 
13148
+    int regno;                 /* register number.  */
 
13149
+    const char *name;          /* register name.  */
 
13150
+  } virtual_regs[] = {
 
13151
+    { STACK_POINTER_REGNUM,                    "stack pointer:" },
 
13152
+    { TOC_REGNUM,                              "toc:          " },
 
13153
+    { STATIC_CHAIN_REGNUM,                     "static chain: " },
 
13154
+    { RS6000_PIC_OFFSET_TABLE_REGNUM,          "pic offset:   " },
 
13155
+    { HARD_FRAME_POINTER_REGNUM,               "hard frame:   " },
 
13156
+    { ARG_POINTER_REGNUM,                      "arg pointer:  " },
 
13157
+    { FRAME_POINTER_REGNUM,                    "frame pointer:" },
 
13158
+    { FIRST_PSEUDO_REGISTER,                   "first pseudo: " },
 
13159
+    { FIRST_VIRTUAL_REGISTER,                  "first virtual:" },
 
13160
+    { VIRTUAL_INCOMING_ARGS_REGNUM,            "incoming_args:" },
 
13161
+    { VIRTUAL_STACK_VARS_REGNUM,               "stack_vars:   " },
 
13162
+    { VIRTUAL_STACK_DYNAMIC_REGNUM,            "stack_dynamic:" },
 
13163
+    { VIRTUAL_OUTGOING_ARGS_REGNUM,            "outgoing_args:" },
 
13164
+    { VIRTUAL_CFA_REGNUM,                      "cfa (frame):  " },
 
13165
+    { VIRTUAL_PREFERRED_STACK_BOUNDARY_REGNUM, "stack boundry:" },
 
13166
+    { LAST_VIRTUAL_REGISTER,                   "last virtual: " },
 
13167
+  };
 
13168
+
 
13169
+  fputs ("\nHard register information:\n", stderr);
 
13170
+  rs6000_debug_reg_print (FIRST_GPR_REGNO, LAST_GPR_REGNO, "gr");
 
13171
+  rs6000_debug_reg_print (FIRST_FPR_REGNO, LAST_FPR_REGNO, "fp");
 
13172
   rs6000_debug_reg_print (FIRST_ALTIVEC_REGNO,
 
13173
                          LAST_ALTIVEC_REGNO,
 
13174
                          "vs");
 
13175
@@ -1726,6 +2000,10 @@
 
13176
   rs6000_debug_reg_print (SPE_ACC_REGNO, SPE_ACC_REGNO, "spe_a");
 
13177
   rs6000_debug_reg_print (SPEFSCR_REGNO, SPEFSCR_REGNO, "spe_f");
 
13178
 
 
13179
+  fputs ("\nVirtual/stack/frame registers:\n", stderr);
 
13180
+  for (v = 0; v < ARRAY_SIZE (virtual_regs); v++)
 
13181
+    fprintf (stderr, "%s regno = %3d\n", virtual_regs[v].name, virtual_regs[v].regno);
 
13182
+
 
13183
   fprintf (stderr,
 
13184
           "\n"
 
13185
           "d  reg_class = %s\n"
 
13186
@@ -1734,25 +2012,70 @@
 
13187
           "wa reg_class = %s\n"
 
13188
           "wd reg_class = %s\n"
 
13189
           "wf reg_class = %s\n"
 
13190
-          "ws reg_class = %s\n\n",
 
13191
+          "wg reg_class = %s\n"
 
13192
+          "wl reg_class = %s\n"
 
13193
+          "wm reg_class = %s\n"
 
13194
+          "wr reg_class = %s\n"
 
13195
+          "ws reg_class = %s\n"
 
13196
+          "wt reg_class = %s\n"
 
13197
+          "wu reg_class = %s\n"
 
13198
+          "wv reg_class = %s\n"
 
13199
+          "ww reg_class = %s\n"
 
13200
+          "wx reg_class = %s\n"
 
13201
+          "wy reg_class = %s\n"
 
13202
+          "wz reg_class = %s\n"
 
13203
+          "\n",
 
13204
           reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_d]],
 
13205
           reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_f]],
 
13206
           reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_v]],
 
13207
           reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wa]],
 
13208
           reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wd]],
 
13209
           reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wf]],
 
13210
-          reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_ws]]);
 
13211
+          reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wg]],
 
13212
+          reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wl]],
 
13213
+          reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wm]],
 
13214
+          reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wr]],
 
13215
+          reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_ws]],
 
13216
+          reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wt]],
 
13217
+          reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wu]],
 
13218
+          reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wv]],
 
13219
+          reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_ww]],
 
13220
+          reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wx]],
 
13221
+          reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wy]],
 
13222
+          reg_class_names[rs6000_constraints[RS6000_CONSTRAINT_wz]]);
 
13223
 
 
13224
+  nl = "\n";
 
13225
   for (m = 0; m < NUM_MACHINE_MODES; ++m)
 
13226
-    if (rs6000_vector_unit[m] || rs6000_vector_mem[m])
 
13227
-      {
 
13228
-       nl = "\n";
 
13229
-       fprintf (stderr, "Vector mode: %-5s arithmetic: %-8s move: %-8s\n",
 
13230
-                GET_MODE_NAME (m),
 
13231
-                rs6000_debug_vector_unit[ rs6000_vector_unit[m] ],
 
13232
-                rs6000_debug_vector_unit[ rs6000_vector_mem[m] ]);
 
13233
-      }
 
13234
+    rs6000_debug_print_mode (m);
 
13235
 
 
13236
+  fputs ("\n", stderr);
 
13237
+
 
13238
+  for (m1 = 0; m1 < ARRAY_SIZE (print_tieable_modes); m1++)
 
13239
+    {
 
13240
+      enum machine_mode mode1 = print_tieable_modes[m1];
 
13241
+      bool first_time = true;
 
13242
+
 
13243
+      nl = (const char *)0;
 
13244
+      for (m2 = 0; m2 < ARRAY_SIZE (print_tieable_modes); m2++)
 
13245
+       {
 
13246
+         enum machine_mode mode2 = print_tieable_modes[m2];
 
13247
+         if (mode1 != mode2 && MODES_TIEABLE_P (mode1, mode2))
 
13248
+           {
 
13249
+             if (first_time)
 
13250
+               {
 
13251
+                 fprintf (stderr, "Tieable modes %s:", GET_MODE_NAME (mode1));
 
13252
+                 nl = "\n";
 
13253
+                 first_time = false;
 
13254
+               }
 
13255
+
 
13256
+             fprintf (stderr, " %s", GET_MODE_NAME (mode2));
 
13257
+           }
 
13258
+       }
 
13259
+
 
13260
+      if (!first_time)
 
13261
+       fputs ("\n", stderr);
 
13262
+    }
 
13263
+
 
13264
   if (nl)
 
13265
     fputs (nl, stderr);
 
13266
 
 
13267
@@ -1913,6 +2236,7 @@
 
13268
     {
 
13269
     case ABI_NONE:     abi_str = "none";       break;
 
13270
     case ABI_AIX:      abi_str = "aix";        break;
 
13271
+    case ABI_ELFv2:    abi_str = "ELFv2";      break;
 
13272
     case ABI_V4:       abi_str = "V4";         break;
 
13273
     case ABI_DARWIN:   abi_str = "darwin";     break;
 
13274
     default:           abi_str = "unknown";    break;
 
13275
@@ -1935,6 +2259,13 @@
 
13276
   if (TARGET_LINK_STACK)
 
13277
     fprintf (stderr, DEBUG_FMT_S, "link_stack", "true");
 
13278
 
 
13279
+  if (targetm.lra_p ())
 
13280
+    fprintf (stderr, DEBUG_FMT_S, "lra", "true");
 
13281
+
 
13282
+  if (TARGET_P8_FUSION)
 
13283
+    fprintf (stderr, DEBUG_FMT_S, "p8 fusion",
 
13284
+            (TARGET_P8_FUSION_SIGN) ? "zero+sign" : "zero");
 
13285
+
 
13286
   fprintf (stderr, DEBUG_FMT_S, "plt-format",
 
13287
           TARGET_SECURE_PLT ? "secure" : "bss");
 
13288
   fprintf (stderr, DEBUG_FMT_S, "struct-return",
 
13289
@@ -1954,11 +2285,106 @@
 
13290
           (int)RS6000_BUILTIN_COUNT);
 
13291
 }
 
13292
 
 
13293
+
 
13294
+/* Update the addr mask bits in reg_addr to help secondary reload and go if
 
13295
+   legitimate address support to figure out the appropriate addressing to
 
13296
+   use.  */
 
13297
+
 
13298
+static void
 
13299
+rs6000_setup_reg_addr_masks (void)
 
13300
+{
 
13301
+  ssize_t rc, reg, m, nregs;
 
13302
+  addr_mask_type any_addr_mask, addr_mask;
 
13303
+
 
13304
+  for (m = 0; m < NUM_MACHINE_MODES; ++m)
 
13305
+    {
 
13306
+      /* SDmode is special in that we want to access it only via REG+REG
 
13307
+        addressing on power7 and above, since we want to use the LFIWZX and
 
13308
+        STFIWZX instructions to load it.  */
 
13309
+      bool indexed_only_p = (m == SDmode && TARGET_NO_SDMODE_STACK);
 
13310
+
 
13311
+      any_addr_mask = 0;
 
13312
+      for (rc = FIRST_RELOAD_REG_CLASS; rc <= LAST_RELOAD_REG_CLASS; rc++)
 
13313
+       {
 
13314
+         addr_mask = 0;
 
13315
+         reg = reload_reg_map[rc].reg;
 
13316
+
 
13317
+         /* Can mode values go in the GPR/FPR/Altivec registers?  */
 
13318
+         if (reg >= 0 && rs6000_hard_regno_mode_ok_p[m][reg])
 
13319
+           {
 
13320
+             nregs = rs6000_hard_regno_nregs[m][reg];
 
13321
+             addr_mask |= RELOAD_REG_VALID;
 
13322
+
 
13323
+             /* Indicate if the mode takes more than 1 physical register.  If
 
13324
+                it takes a single register, indicate it can do REG+REG
 
13325
+                addressing.  */
 
13326
+             if (nregs > 1 || m == BLKmode)
 
13327
+               addr_mask |= RELOAD_REG_MULTIPLE;
 
13328
+             else
 
13329
+               addr_mask |= RELOAD_REG_INDEXED;
 
13330
+
 
13331
+             /* Figure out if we can do PRE_INC, PRE_DEC, or PRE_MODIFY
 
13332
+                addressing.  Restrict addressing on SPE for 64-bit types
 
13333
+                because of the SUBREG hackery used to address 64-bit floats in
 
13334
+                '32-bit' GPRs.  To simplify secondary reload, don't allow
 
13335
+                update forms on scalar floating point types that can go in the
 
13336
+                upper registers.  */
 
13337
+
 
13338
+             if (TARGET_UPDATE
 
13339
+                 && (rc == RELOAD_REG_GPR || rc == RELOAD_REG_FPR)
 
13340
+                 && GET_MODE_SIZE (m) <= 8
 
13341
+                 && !VECTOR_MODE_P (m)
 
13342
+                 && !COMPLEX_MODE_P (m)
 
13343
+                 && !indexed_only_p
 
13344
+                 && !(TARGET_E500_DOUBLE && GET_MODE_SIZE (m) == 8)
 
13345
+                 && !(m == DFmode && TARGET_UPPER_REGS_DF)
 
13346
+                 && !(m == SFmode && TARGET_UPPER_REGS_SF))
 
13347
+               {
 
13348
+                 addr_mask |= RELOAD_REG_PRE_INCDEC;
 
13349
+
 
13350
+                 /* PRE_MODIFY is more restricted than PRE_INC/PRE_DEC in that
 
13351
+                    we don't allow PRE_MODIFY for some multi-register
 
13352
+                    operations.  */
 
13353
+                 switch (m)
 
13354
+                   {
 
13355
+                   default:
 
13356
+                     addr_mask |= RELOAD_REG_PRE_MODIFY;
 
13357
+                     break;
 
13358
+
 
13359
+                   case DImode:
 
13360
+                     if (TARGET_POWERPC64)
 
13361
+                       addr_mask |= RELOAD_REG_PRE_MODIFY;
 
13362
+                     break;
 
13363
+
 
13364
+                   case DFmode:
 
13365
+                   case DDmode:
 
13366
+                     if (TARGET_DF_INSN)
 
13367
+                       addr_mask |= RELOAD_REG_PRE_MODIFY;
 
13368
+                     break;
 
13369
+                   }
 
13370
+               }
 
13371
+           }
 
13372
+
 
13373
+         /* GPR and FPR registers can do REG+OFFSET addressing, except
 
13374
+            possibly for SDmode.  */
 
13375
+         if ((addr_mask != 0) && !indexed_only_p
 
13376
+             && (rc == RELOAD_REG_GPR || rc == RELOAD_REG_FPR))
 
13377
+           addr_mask |= RELOAD_REG_OFFSET;
 
13378
+
 
13379
+         reg_addr[m].addr_mask[rc] = addr_mask;
 
13380
+         any_addr_mask |= addr_mask;
 
13381
+       }
 
13382
+
 
13383
+      reg_addr[m].addr_mask[RELOAD_REG_ANY] = any_addr_mask;
 
13384
+    }
 
13385
+}
 
13386
+
 
13387
+
 
13388
 /* Initialize the various global tables that are based on register size.  */
 
13389
 static void
 
13390
 rs6000_init_hard_regno_mode_ok (bool global_init_p)
 
13391
 {
 
13392
-  int r, m, c;
 
13393
+  ssize_t r, m, c;
 
13394
   int align64;
 
13395
   int align32;
 
13396
 
 
13397
@@ -1987,21 +2413,55 @@
 
13398
   rs6000_regno_regclass[VSCR_REGNO] = VRSAVE_REGS;
 
13399
   rs6000_regno_regclass[SPE_ACC_REGNO] = SPE_ACC_REGS;
 
13400
   rs6000_regno_regclass[SPEFSCR_REGNO] = SPEFSCR_REGS;
 
13401
+  rs6000_regno_regclass[TFHAR_REGNO] = SPR_REGS;
 
13402
+  rs6000_regno_regclass[TFIAR_REGNO] = SPR_REGS;
 
13403
+  rs6000_regno_regclass[TEXASR_REGNO] = SPR_REGS;
 
13404
   rs6000_regno_regclass[ARG_POINTER_REGNUM] = BASE_REGS;
 
13405
   rs6000_regno_regclass[FRAME_POINTER_REGNUM] = BASE_REGS;
 
13406
 
 
13407
-  /* Precalculate vector information, this must be set up before the
 
13408
-     rs6000_hard_regno_nregs_internal below.  */
 
13409
-  for (m = 0; m < NUM_MACHINE_MODES; ++m)
 
13410
+  /* Precalculate register class to simpler reload register class.  We don't
 
13411
+     need all of the register classes that are combinations of different
 
13412
+     classes, just the simple ones that have constraint letters.  */
 
13413
+  for (c = 0; c < N_REG_CLASSES; c++)
 
13414
+    reg_class_to_reg_type[c] = NO_REG_TYPE;
 
13415
+
 
13416
+  reg_class_to_reg_type[(int)GENERAL_REGS] = GPR_REG_TYPE;
 
13417
+  reg_class_to_reg_type[(int)BASE_REGS] = GPR_REG_TYPE;
 
13418
+  reg_class_to_reg_type[(int)VSX_REGS] = VSX_REG_TYPE;
 
13419
+  reg_class_to_reg_type[(int)VRSAVE_REGS] = SPR_REG_TYPE;
 
13420
+  reg_class_to_reg_type[(int)VSCR_REGS] = SPR_REG_TYPE;
 
13421
+  reg_class_to_reg_type[(int)LINK_REGS] = SPR_REG_TYPE;
 
13422
+  reg_class_to_reg_type[(int)CTR_REGS] = SPR_REG_TYPE;
 
13423
+  reg_class_to_reg_type[(int)LINK_OR_CTR_REGS] = SPR_REG_TYPE;
 
13424
+  reg_class_to_reg_type[(int)CR_REGS] = CR_REG_TYPE;
 
13425
+  reg_class_to_reg_type[(int)CR0_REGS] = CR_REG_TYPE;
 
13426
+  reg_class_to_reg_type[(int)SPE_ACC_REGS] = SPE_ACC_TYPE;
 
13427
+  reg_class_to_reg_type[(int)SPEFSCR_REGS] = SPEFSCR_REG_TYPE;
 
13428
+
 
13429
+  if (TARGET_VSX)
 
13430
     {
 
13431
-      rs6000_vector_unit[m] = rs6000_vector_mem[m] = VECTOR_NONE;
 
13432
-      rs6000_vector_reload[m][0] = CODE_FOR_nothing;
 
13433
-      rs6000_vector_reload[m][1] = CODE_FOR_nothing;
 
13434
+      reg_class_to_reg_type[(int)FLOAT_REGS] = VSX_REG_TYPE;
 
13435
+      reg_class_to_reg_type[(int)ALTIVEC_REGS] = VSX_REG_TYPE;
 
13436
     }
 
13437
+  else
 
13438
+    {
 
13439
+      reg_class_to_reg_type[(int)FLOAT_REGS] = FPR_REG_TYPE;
 
13440
+      reg_class_to_reg_type[(int)ALTIVEC_REGS] = ALTIVEC_REG_TYPE;
 
13441
+    }
 
13442
 
 
13443
-  for (c = 0; c < (int)(int)RS6000_CONSTRAINT_MAX; c++)
 
13444
-    rs6000_constraints[c] = NO_REGS;
 
13445
+  /* Precalculate the valid memory formats as well as the vector information,
 
13446
+     this must be set up before the rs6000_hard_regno_nregs_internal calls
 
13447
+     below.  */
 
13448
+  gcc_assert ((int)VECTOR_NONE == 0);
 
13449
+  memset ((void *) &rs6000_vector_unit[0], '\0', sizeof (rs6000_vector_unit));
 
13450
+  memset ((void *) &rs6000_vector_mem[0], '\0', sizeof (rs6000_vector_unit));
 
13451
 
 
13452
+  gcc_assert ((int)CODE_FOR_nothing == 0);
 
13453
+  memset ((void *) &reg_addr[0], '\0', sizeof (reg_addr));
 
13454
+
 
13455
+  gcc_assert ((int)NO_REGS == 0);
 
13456
+  memset ((void *) &rs6000_constraints[0], '\0', sizeof (rs6000_constraints));
 
13457
+
 
13458
   /* The VSX hardware allows native alignment for vectors, but control whether the compiler
 
13459
      believes it can use native alignment or still uses 128-bit alignment.  */
 
13460
   if (TARGET_VSX && !TARGET_VSX_ALIGN_128)
 
13461
@@ -2062,12 +2522,13 @@
 
13462
        }
 
13463
     }
 
13464
 
 
13465
-  /* V2DImode, only allow under VSX, which can do V2DI insert/splat/extract.
 
13466
-     Altivec doesn't have 64-bit support.  */
 
13467
+  /* V2DImode, full mode depends on ISA 2.07 vector mode.  Allow under VSX to
 
13468
+     do insert/splat/extract.  Altivec doesn't have 64-bit integer support.  */
 
13469
   if (TARGET_VSX)
 
13470
     {
 
13471
       rs6000_vector_mem[V2DImode] = VECTOR_VSX;
 
13472
-      rs6000_vector_unit[V2DImode] = VECTOR_NONE;
 
13473
+      rs6000_vector_unit[V2DImode]
 
13474
+       = (TARGET_P8_VECTOR) ? VECTOR_P8_VECTOR : VECTOR_NONE;
 
13475
       rs6000_vector_align[V2DImode] = align64;
 
13476
     }
 
13477
 
 
13478
@@ -2076,14 +2537,48 @@
 
13479
     {
 
13480
       rs6000_vector_unit[DFmode] = VECTOR_VSX;
 
13481
       rs6000_vector_mem[DFmode]
 
13482
-       = (TARGET_VSX_SCALAR_MEMORY ? VECTOR_VSX : VECTOR_NONE);
 
13483
+       = (TARGET_UPPER_REGS_DF ? VECTOR_VSX : VECTOR_NONE);
 
13484
       rs6000_vector_align[DFmode] = align64;
 
13485
     }
 
13486
 
 
13487
+  /* Allow TImode in VSX register and set the VSX memory macros.  */
 
13488
+  if (TARGET_VSX && TARGET_VSX_TIMODE)
 
13489
+    {
 
13490
+      rs6000_vector_mem[TImode] = VECTOR_VSX;
 
13491
+      rs6000_vector_align[TImode] = align64;
 
13492
+    }
 
13493
+
 
13494
   /* TODO add SPE and paired floating point vector support.  */
 
13495
 
 
13496
   /* Register class constraints for the constraints that depend on compile
 
13497
-     switches.  */
 
13498
+     switches. When the VSX code was added, different constraints were added
 
13499
+     based on the type (DFmode, V2DFmode, V4SFmode).  For the vector types, all
 
13500
+     of the VSX registers are used.  The register classes for scalar floating
 
13501
+     point types is set, based on whether we allow that type into the upper
 
13502
+     (Altivec) registers.  GCC has register classes to target the Altivec
 
13503
+     registers for load/store operations, to select using a VSX memory
 
13504
+     operation instead of the traditional floating point operation.  The
 
13505
+     constraints are:
 
13506
+
 
13507
+       d  - Register class to use with traditional DFmode instructions.
 
13508
+       f  - Register class to use with traditional SFmode instructions.
 
13509
+       v  - Altivec register.
 
13510
+       wa - Any VSX register.
 
13511
+       wd - Preferred register class for V2DFmode.
 
13512
+       wf - Preferred register class for V4SFmode.
 
13513
+       wg - Float register for power6x move insns.
 
13514
+       wl - Float register if we can do 32-bit signed int loads.
 
13515
+       wm - VSX register for ISA 2.07 direct move operations.
 
13516
+       wr - GPR if 64-bit mode is permitted.
 
13517
+       ws - Register class to do ISA 2.06 DF operations.
 
13518
+       wu - Altivec register for ISA 2.07 VSX SF/SI load/stores.
 
13519
+       wv - Altivec register for ISA 2.06 VSX DF/DI load/stores.
 
13520
+       wt - VSX register for TImode in VSX registers.
 
13521
+       ww - Register class to do SF conversions in with VSX operations.
 
13522
+       wx - Float register if we can do 32-bit int stores.
 
13523
+       wy - Register class to do ISA 2.07 SF operations.
 
13524
+       wz - Float register if we can do 32-bit unsigned int loads.  */
 
13525
+
 
13526
   if (TARGET_HARD_FLOAT && TARGET_FPRS)
 
13527
     rs6000_constraints[RS6000_CONSTRAINT_f] = FLOAT_REGS;
 
13528
 
 
13529
@@ -2092,64 +2587,158 @@
 
13530
 
 
13531
   if (TARGET_VSX)
 
13532
     {
 
13533
-      /* At present, we just use VSX_REGS, but we have different constraints
 
13534
-        based on the use, in case we want to fine tune the default register
 
13535
-        class used.  wa = any VSX register, wf = register class to use for
 
13536
-        V4SF, wd = register class to use for V2DF, and ws = register classs to
 
13537
-        use for DF scalars.  */
 
13538
       rs6000_constraints[RS6000_CONSTRAINT_wa] = VSX_REGS;
 
13539
+      rs6000_constraints[RS6000_CONSTRAINT_wd] = VSX_REGS;
 
13540
       rs6000_constraints[RS6000_CONSTRAINT_wf] = VSX_REGS;
 
13541
-      rs6000_constraints[RS6000_CONSTRAINT_wd] = VSX_REGS;
 
13542
-      rs6000_constraints[RS6000_CONSTRAINT_ws] = (TARGET_VSX_SCALAR_MEMORY
 
13543
-                                                 ? VSX_REGS
 
13544
-                                                 : FLOAT_REGS);
 
13545
+
 
13546
+      if (TARGET_VSX_TIMODE)
 
13547
+       rs6000_constraints[RS6000_CONSTRAINT_wt] = VSX_REGS;
 
13548
+
 
13549
+      if (TARGET_UPPER_REGS_DF)
 
13550
+       {
 
13551
+         rs6000_constraints[RS6000_CONSTRAINT_ws] = VSX_REGS;
 
13552
+         rs6000_constraints[RS6000_CONSTRAINT_wv] = ALTIVEC_REGS;
 
13553
+       }
 
13554
+      else
 
13555
+       rs6000_constraints[RS6000_CONSTRAINT_ws] = FLOAT_REGS;
 
13556
     }
 
13557
 
 
13558
+  /* Add conditional constraints based on various options, to allow us to
 
13559
+     collapse multiple insn patterns.  */
 
13560
   if (TARGET_ALTIVEC)
 
13561
     rs6000_constraints[RS6000_CONSTRAINT_v] = ALTIVEC_REGS;
 
13562
 
 
13563
-  /* Set up the reload helper functions.  */
 
13564
+  if (TARGET_MFPGPR)
 
13565
+    rs6000_constraints[RS6000_CONSTRAINT_wg] = FLOAT_REGS;
 
13566
+
 
13567
+  if (TARGET_LFIWAX)
 
13568
+    rs6000_constraints[RS6000_CONSTRAINT_wl] = FLOAT_REGS;
 
13569
+
 
13570
+  if (TARGET_DIRECT_MOVE)
 
13571
+    rs6000_constraints[RS6000_CONSTRAINT_wm] = VSX_REGS;
 
13572
+
 
13573
+  if (TARGET_POWERPC64)
 
13574
+    rs6000_constraints[RS6000_CONSTRAINT_wr] = GENERAL_REGS;
 
13575
+
 
13576
+  if (TARGET_P8_VECTOR && TARGET_UPPER_REGS_SF)
 
13577
+    {
 
13578
+      rs6000_constraints[RS6000_CONSTRAINT_wu] = ALTIVEC_REGS;
 
13579
+      rs6000_constraints[RS6000_CONSTRAINT_wy] = VSX_REGS;
 
13580
+      rs6000_constraints[RS6000_CONSTRAINT_ww] = VSX_REGS;
 
13581
+    }
 
13582
+  else if (TARGET_P8_VECTOR)
 
13583
+    {
 
13584
+      rs6000_constraints[RS6000_CONSTRAINT_wy] = FLOAT_REGS;
 
13585
+      rs6000_constraints[RS6000_CONSTRAINT_ww] = FLOAT_REGS;
 
13586
+    }
 
13587
+  else if (TARGET_VSX)
 
13588
+    rs6000_constraints[RS6000_CONSTRAINT_ww] = FLOAT_REGS;
 
13589
+
 
13590
+  if (TARGET_STFIWX)
 
13591
+    rs6000_constraints[RS6000_CONSTRAINT_wx] = FLOAT_REGS;
 
13592
+
 
13593
+  if (TARGET_LFIWZX)
 
13594
+    rs6000_constraints[RS6000_CONSTRAINT_wz] = FLOAT_REGS;
 
13595
+
 
13596
+  /* Set up the reload helper and direct move functions.  */
 
13597
   if (TARGET_VSX || TARGET_ALTIVEC)
 
13598
     {
 
13599
       if (TARGET_64BIT)
 
13600
        {
 
13601
-         rs6000_vector_reload[V16QImode][0] = CODE_FOR_reload_v16qi_di_store;
 
13602
-         rs6000_vector_reload[V16QImode][1] = CODE_FOR_reload_v16qi_di_load;
 
13603
-         rs6000_vector_reload[V8HImode][0]  = CODE_FOR_reload_v8hi_di_store;
 
13604
-         rs6000_vector_reload[V8HImode][1]  = CODE_FOR_reload_v8hi_di_load;
 
13605
-         rs6000_vector_reload[V4SImode][0]  = CODE_FOR_reload_v4si_di_store;
 
13606
-         rs6000_vector_reload[V4SImode][1]  = CODE_FOR_reload_v4si_di_load;
 
13607
-         rs6000_vector_reload[V2DImode][0]  = CODE_FOR_reload_v2di_di_store;
 
13608
-         rs6000_vector_reload[V2DImode][1]  = CODE_FOR_reload_v2di_di_load;
 
13609
-         rs6000_vector_reload[V4SFmode][0]  = CODE_FOR_reload_v4sf_di_store;
 
13610
-         rs6000_vector_reload[V4SFmode][1]  = CODE_FOR_reload_v4sf_di_load;
 
13611
-         rs6000_vector_reload[V2DFmode][0]  = CODE_FOR_reload_v2df_di_store;
 
13612
-         rs6000_vector_reload[V2DFmode][1]  = CODE_FOR_reload_v2df_di_load;
 
13613
-         if (TARGET_VSX && TARGET_VSX_SCALAR_MEMORY)
 
13614
+         reg_addr[V16QImode].reload_store = CODE_FOR_reload_v16qi_di_store;
 
13615
+         reg_addr[V16QImode].reload_load  = CODE_FOR_reload_v16qi_di_load;
 
13616
+         reg_addr[V8HImode].reload_store  = CODE_FOR_reload_v8hi_di_store;
 
13617
+         reg_addr[V8HImode].reload_load   = CODE_FOR_reload_v8hi_di_load;
 
13618
+         reg_addr[V4SImode].reload_store  = CODE_FOR_reload_v4si_di_store;
 
13619
+         reg_addr[V4SImode].reload_load   = CODE_FOR_reload_v4si_di_load;
 
13620
+         reg_addr[V2DImode].reload_store  = CODE_FOR_reload_v2di_di_store;
 
13621
+         reg_addr[V2DImode].reload_load   = CODE_FOR_reload_v2di_di_load;
 
13622
+         reg_addr[V4SFmode].reload_store  = CODE_FOR_reload_v4sf_di_store;
 
13623
+         reg_addr[V4SFmode].reload_load   = CODE_FOR_reload_v4sf_di_load;
 
13624
+         reg_addr[V2DFmode].reload_store  = CODE_FOR_reload_v2df_di_store;
 
13625
+         reg_addr[V2DFmode].reload_load   = CODE_FOR_reload_v2df_di_load;
 
13626
+         if (TARGET_VSX && TARGET_UPPER_REGS_DF)
 
13627
            {
 
13628
-             rs6000_vector_reload[DFmode][0]  = CODE_FOR_reload_df_di_store;
 
13629
-             rs6000_vector_reload[DFmode][1]  = CODE_FOR_reload_df_di_load;
 
13630
+             reg_addr[DFmode].reload_store  = CODE_FOR_reload_df_di_store;
 
13631
+             reg_addr[DFmode].reload_load   = CODE_FOR_reload_df_di_load;
 
13632
+             reg_addr[DDmode].reload_store  = CODE_FOR_reload_dd_di_store;
 
13633
+             reg_addr[DDmode].reload_load   = CODE_FOR_reload_dd_di_load;
 
13634
            }
 
13635
+         if (TARGET_P8_VECTOR)
 
13636
+           {
 
13637
+             reg_addr[SFmode].reload_store  = CODE_FOR_reload_sf_di_store;
 
13638
+             reg_addr[SFmode].reload_load   = CODE_FOR_reload_sf_di_load;
 
13639
+             reg_addr[SDmode].reload_store  = CODE_FOR_reload_sd_di_store;
 
13640
+             reg_addr[SDmode].reload_load   = CODE_FOR_reload_sd_di_load;
 
13641
+           }
 
13642
+         if (TARGET_VSX_TIMODE)
 
13643
+           {
 
13644
+             reg_addr[TImode].reload_store  = CODE_FOR_reload_ti_di_store;
 
13645
+             reg_addr[TImode].reload_load   = CODE_FOR_reload_ti_di_load;
 
13646
+           }
 
13647
+         if (TARGET_DIRECT_MOVE)
 
13648
+           {
 
13649
+             if (TARGET_POWERPC64)
 
13650
+               {
 
13651
+                 reg_addr[TImode].reload_gpr_vsx    = CODE_FOR_reload_gpr_from_vsxti;
 
13652
+                 reg_addr[V2DFmode].reload_gpr_vsx  = CODE_FOR_reload_gpr_from_vsxv2df;
 
13653
+                 reg_addr[V2DImode].reload_gpr_vsx  = CODE_FOR_reload_gpr_from_vsxv2di;
 
13654
+                 reg_addr[V4SFmode].reload_gpr_vsx  = CODE_FOR_reload_gpr_from_vsxv4sf;
 
13655
+                 reg_addr[V4SImode].reload_gpr_vsx  = CODE_FOR_reload_gpr_from_vsxv4si;
 
13656
+                 reg_addr[V8HImode].reload_gpr_vsx  = CODE_FOR_reload_gpr_from_vsxv8hi;
 
13657
+                 reg_addr[V16QImode].reload_gpr_vsx = CODE_FOR_reload_gpr_from_vsxv16qi;
 
13658
+                 reg_addr[SFmode].reload_gpr_vsx    = CODE_FOR_reload_gpr_from_vsxsf;
 
13659
+
 
13660
+                 reg_addr[TImode].reload_vsx_gpr    = CODE_FOR_reload_vsx_from_gprti;
 
13661
+                 reg_addr[V2DFmode].reload_vsx_gpr  = CODE_FOR_reload_vsx_from_gprv2df;
 
13662
+                 reg_addr[V2DImode].reload_vsx_gpr  = CODE_FOR_reload_vsx_from_gprv2di;
 
13663
+                 reg_addr[V4SFmode].reload_vsx_gpr  = CODE_FOR_reload_vsx_from_gprv4sf;
 
13664
+                 reg_addr[V4SImode].reload_vsx_gpr  = CODE_FOR_reload_vsx_from_gprv4si;
 
13665
+                 reg_addr[V8HImode].reload_vsx_gpr  = CODE_FOR_reload_vsx_from_gprv8hi;
 
13666
+                 reg_addr[V16QImode].reload_vsx_gpr = CODE_FOR_reload_vsx_from_gprv16qi;
 
13667
+                 reg_addr[SFmode].reload_vsx_gpr    = CODE_FOR_reload_vsx_from_gprsf;
 
13668
+               }
 
13669
+             else
 
13670
+               {
 
13671
+                 reg_addr[DImode].reload_fpr_gpr = CODE_FOR_reload_fpr_from_gprdi;
 
13672
+                 reg_addr[DDmode].reload_fpr_gpr = CODE_FOR_reload_fpr_from_gprdd;
 
13673
+                 reg_addr[DFmode].reload_fpr_gpr = CODE_FOR_reload_fpr_from_gprdf;
 
13674
+               }
 
13675
+           }
 
13676
        }
 
13677
       else
 
13678
        {
 
13679
-         rs6000_vector_reload[V16QImode][0] = CODE_FOR_reload_v16qi_si_store;
 
13680
-         rs6000_vector_reload[V16QImode][1] = CODE_FOR_reload_v16qi_si_load;
 
13681
-         rs6000_vector_reload[V8HImode][0]  = CODE_FOR_reload_v8hi_si_store;
 
13682
-         rs6000_vector_reload[V8HImode][1]  = CODE_FOR_reload_v8hi_si_load;
 
13683
-         rs6000_vector_reload[V4SImode][0]  = CODE_FOR_reload_v4si_si_store;
 
13684
-         rs6000_vector_reload[V4SImode][1]  = CODE_FOR_reload_v4si_si_load;
 
13685
-         rs6000_vector_reload[V2DImode][0]  = CODE_FOR_reload_v2di_si_store;
 
13686
-         rs6000_vector_reload[V2DImode][1]  = CODE_FOR_reload_v2di_si_load;
 
13687
-         rs6000_vector_reload[V4SFmode][0]  = CODE_FOR_reload_v4sf_si_store;
 
13688
-         rs6000_vector_reload[V4SFmode][1]  = CODE_FOR_reload_v4sf_si_load;
 
13689
-         rs6000_vector_reload[V2DFmode][0]  = CODE_FOR_reload_v2df_si_store;
 
13690
-         rs6000_vector_reload[V2DFmode][1]  = CODE_FOR_reload_v2df_si_load;
 
13691
-         if (TARGET_VSX && TARGET_VSX_SCALAR_MEMORY)
 
13692
+         reg_addr[V16QImode].reload_store = CODE_FOR_reload_v16qi_si_store;
 
13693
+         reg_addr[V16QImode].reload_load  = CODE_FOR_reload_v16qi_si_load;
 
13694
+         reg_addr[V8HImode].reload_store  = CODE_FOR_reload_v8hi_si_store;
 
13695
+         reg_addr[V8HImode].reload_load   = CODE_FOR_reload_v8hi_si_load;
 
13696
+         reg_addr[V4SImode].reload_store  = CODE_FOR_reload_v4si_si_store;
 
13697
+         reg_addr[V4SImode].reload_load   = CODE_FOR_reload_v4si_si_load;
 
13698
+         reg_addr[V2DImode].reload_store  = CODE_FOR_reload_v2di_si_store;
 
13699
+         reg_addr[V2DImode].reload_load   = CODE_FOR_reload_v2di_si_load;
 
13700
+         reg_addr[V4SFmode].reload_store  = CODE_FOR_reload_v4sf_si_store;
 
13701
+         reg_addr[V4SFmode].reload_load   = CODE_FOR_reload_v4sf_si_load;
 
13702
+         reg_addr[V2DFmode].reload_store  = CODE_FOR_reload_v2df_si_store;
 
13703
+         reg_addr[V2DFmode].reload_load   = CODE_FOR_reload_v2df_si_load;
 
13704
+         if (TARGET_VSX && TARGET_UPPER_REGS_DF)
 
13705
            {
 
13706
-             rs6000_vector_reload[DFmode][0]  = CODE_FOR_reload_df_si_store;
 
13707
-             rs6000_vector_reload[DFmode][1]  = CODE_FOR_reload_df_si_load;
 
13708
+             reg_addr[DFmode].reload_store  = CODE_FOR_reload_df_si_store;
 
13709
+             reg_addr[DFmode].reload_load   = CODE_FOR_reload_df_si_load;
 
13710
+             reg_addr[DDmode].reload_store  = CODE_FOR_reload_dd_si_store;
 
13711
+             reg_addr[DDmode].reload_load   = CODE_FOR_reload_dd_si_load;
 
13712
            }
 
13713
+         if (TARGET_P8_VECTOR)
 
13714
+           {
 
13715
+             reg_addr[SFmode].reload_store  = CODE_FOR_reload_sf_si_store;
 
13716
+             reg_addr[SFmode].reload_load   = CODE_FOR_reload_sf_si_load;
 
13717
+             reg_addr[SDmode].reload_store  = CODE_FOR_reload_sd_si_store;
 
13718
+             reg_addr[SDmode].reload_load   = CODE_FOR_reload_sd_si_load;
 
13719
+           }
 
13720
+         if (TARGET_VSX_TIMODE)
 
13721
+           {
 
13722
+             reg_addr[TImode].reload_store  = CODE_FOR_reload_ti_si_store;
 
13723
+             reg_addr[TImode].reload_load   = CODE_FOR_reload_ti_si_load;
 
13724
+           }
 
13725
        }
 
13726
     }
 
13727
 
 
13728
@@ -2267,6 +2856,11 @@
 
13729
        }
 
13730
     }
 
13731
 
 
13732
+  /* Update the addr mask bits in reg_addr to help secondary reload and go if
 
13733
+     legitimate address support to figure out the appropriate addressing to
 
13734
+     use.  */
 
13735
+  rs6000_setup_reg_addr_masks ();
 
13736
+
 
13737
   if (global_init_p || TARGET_DEBUG_TARGET)
 
13738
     {
 
13739
       if (TARGET_DEBUG_REG)
 
13740
@@ -2369,16 +2963,19 @@
 
13741
 HOST_WIDE_INT
 
13742
 rs6000_builtin_mask_calculate (void)
 
13743
 {
 
13744
-  return (((TARGET_ALTIVEC)                ? RS6000_BTM_ALTIVEC  : 0)
 
13745
-         | ((TARGET_VSX)                   ? RS6000_BTM_VSX      : 0)
 
13746
-         | ((TARGET_SPE)                   ? RS6000_BTM_SPE      : 0)
 
13747
-         | ((TARGET_PAIRED_FLOAT)          ? RS6000_BTM_PAIRED   : 0)
 
13748
-         | ((TARGET_FRE)                   ? RS6000_BTM_FRE      : 0)
 
13749
-         | ((TARGET_FRES)                  ? RS6000_BTM_FRES     : 0)
 
13750
-         | ((TARGET_FRSQRTE)               ? RS6000_BTM_FRSQRTE  : 0)
 
13751
-         | ((TARGET_FRSQRTES)              ? RS6000_BTM_FRSQRTES : 0)
 
13752
-         | ((TARGET_POPCNTD)               ? RS6000_BTM_POPCNTD  : 0)
 
13753
-         | ((rs6000_cpu == PROCESSOR_CELL) ? RS6000_BTM_CELL     : 0));
 
13754
+  return (((TARGET_ALTIVEC)                ? RS6000_BTM_ALTIVEC   : 0)
 
13755
+         | ((TARGET_VSX)                   ? RS6000_BTM_VSX       : 0)
 
13756
+         | ((TARGET_SPE)                   ? RS6000_BTM_SPE       : 0)
 
13757
+         | ((TARGET_PAIRED_FLOAT)          ? RS6000_BTM_PAIRED    : 0)
 
13758
+         | ((TARGET_FRE)                   ? RS6000_BTM_FRE       : 0)
 
13759
+         | ((TARGET_FRES)                  ? RS6000_BTM_FRES      : 0)
 
13760
+         | ((TARGET_FRSQRTE)               ? RS6000_BTM_FRSQRTE   : 0)
 
13761
+         | ((TARGET_FRSQRTES)              ? RS6000_BTM_FRSQRTES  : 0)
 
13762
+         | ((TARGET_POPCNTD)               ? RS6000_BTM_POPCNTD   : 0)
 
13763
+         | ((rs6000_cpu == PROCESSOR_CELL) ? RS6000_BTM_CELL      : 0)
 
13764
+         | ((TARGET_P8_VECTOR)             ? RS6000_BTM_P8_VECTOR : 0)
 
13765
+         | ((TARGET_CRYPTO)                ? RS6000_BTM_CRYPTO    : 0)
 
13766
+         | ((TARGET_HTM)                   ? RS6000_BTM_HTM       : 0));
 
13767
 }
 
13768
 
 
13769
 /* Override command line options.  Mostly we process the processor type and
 
13770
@@ -2609,6 +3206,12 @@
 
13771
        }
 
13772
     }
 
13773
 
 
13774
+  /* If little-endian, default to -mstrict-align on older processors.
 
13775
+     Testing for htm matches power8 and later.  */
 
13776
+  if (!BYTES_BIG_ENDIAN
 
13777
+      && !(processor_target_table[tune_index].target_enable & OPTION_MASK_HTM))
 
13778
+    rs6000_isa_flags |= ~rs6000_isa_flags_explicit & OPTION_MASK_STRICT_ALIGN;
 
13779
+
 
13780
   /* Add some warnings for VSX.  */
 
13781
   if (TARGET_VSX)
 
13782
     {
 
13783
@@ -2619,15 +3222,13 @@
 
13784
          if (rs6000_isa_flags_explicit & OPTION_MASK_VSX)
 
13785
            msg = N_("-mvsx requires hardware floating point");
 
13786
          else
 
13787
-           rs6000_isa_flags &= ~ OPTION_MASK_VSX;
 
13788
+           {
 
13789
+             rs6000_isa_flags &= ~ OPTION_MASK_VSX;
 
13790
+             rs6000_isa_flags_explicit |= OPTION_MASK_VSX;
 
13791
+           }
 
13792
        }
 
13793
       else if (TARGET_PAIRED_FLOAT)
 
13794
        msg = N_("-mvsx and -mpaired are incompatible");
 
13795
-      /* The hardware will allow VSX and little endian, but until we make sure
 
13796
-        things like vector select, etc. work don't allow VSX on little endian
 
13797
-        systems at this point.  */
 
13798
-      else if (!BYTES_BIG_ENDIAN)
 
13799
-       msg = N_("-mvsx used with little endian code");
 
13800
       else if (TARGET_AVOID_XFORM > 0)
 
13801
        msg = N_("-mvsx needs indexed addressing");
 
13802
       else if (!TARGET_ALTIVEC && (rs6000_isa_flags_explicit
 
13803
@@ -2647,9 +3248,24 @@
 
13804
        }
 
13805
     }
 
13806
 
 
13807
+  /* If hard-float/altivec/vsx were explicitly turned off then don't allow
 
13808
+     the -mcpu setting to enable options that conflict. */
 
13809
+  if ((!TARGET_HARD_FLOAT || !TARGET_ALTIVEC || !TARGET_VSX)
 
13810
+      && (rs6000_isa_flags_explicit & (OPTION_MASK_SOFT_FLOAT
 
13811
+                                      | OPTION_MASK_ALTIVEC
 
13812
+                                      | OPTION_MASK_VSX)) != 0)
 
13813
+    rs6000_isa_flags &= ~((OPTION_MASK_P8_VECTOR | OPTION_MASK_CRYPTO
 
13814
+                          | OPTION_MASK_DIRECT_MOVE)
 
13815
+                        & ~rs6000_isa_flags_explicit);
 
13816
+
 
13817
+  if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET)
 
13818
+    rs6000_print_isa_options (stderr, 0, "before defaults", rs6000_isa_flags);
 
13819
+
 
13820
   /* For the newer switches (vsx, dfp, etc.) set some of the older options,
 
13821
      unless the user explicitly used the -mno-<option> to disable the code.  */
 
13822
-  if (TARGET_VSX)
 
13823
+  if (TARGET_P8_VECTOR || TARGET_DIRECT_MOVE || TARGET_CRYPTO)
 
13824
+    rs6000_isa_flags |= (ISA_2_7_MASKS_SERVER & ~rs6000_isa_flags_explicit);
 
13825
+  else if (TARGET_VSX)
 
13826
     rs6000_isa_flags |= (ISA_2_6_MASKS_SERVER & ~rs6000_isa_flags_explicit);
 
13827
   else if (TARGET_POPCNTD)
 
13828
     rs6000_isa_flags |= (ISA_2_6_MASKS_EMBEDDED & ~rs6000_isa_flags_explicit);
 
13829
@@ -2664,6 +3280,69 @@
 
13830
   else if (TARGET_ALTIVEC)
 
13831
     rs6000_isa_flags |= (OPTION_MASK_PPC_GFXOPT & ~rs6000_isa_flags_explicit);
 
13832
 
 
13833
+  if (TARGET_CRYPTO && !TARGET_ALTIVEC)
 
13834
+    {
 
13835
+      if (rs6000_isa_flags_explicit & OPTION_MASK_CRYPTO)
 
13836
+       error ("-mcrypto requires -maltivec");
 
13837
+      rs6000_isa_flags &= ~OPTION_MASK_CRYPTO;
 
13838
+    }
 
13839
+
 
13840
+  if (TARGET_DIRECT_MOVE && !TARGET_VSX)
 
13841
+    {
 
13842
+      if (rs6000_isa_flags_explicit & OPTION_MASK_DIRECT_MOVE)
 
13843
+       error ("-mdirect-move requires -mvsx");
 
13844
+      rs6000_isa_flags &= ~OPTION_MASK_DIRECT_MOVE;
 
13845
+    }
 
13846
+
 
13847
+  if (TARGET_P8_VECTOR && !TARGET_ALTIVEC)
 
13848
+    {
 
13849
+      if (rs6000_isa_flags_explicit & OPTION_MASK_P8_VECTOR)
 
13850
+       error ("-mpower8-vector requires -maltivec");
 
13851
+      rs6000_isa_flags &= ~OPTION_MASK_P8_VECTOR;
 
13852
+    }
 
13853
+
 
13854
+  if (TARGET_P8_VECTOR && !TARGET_VSX)
 
13855
+    {
 
13856
+      if (rs6000_isa_flags_explicit & OPTION_MASK_P8_VECTOR)
 
13857
+       error ("-mpower8-vector requires -mvsx");
 
13858
+      rs6000_isa_flags &= ~OPTION_MASK_P8_VECTOR;
 
13859
+    }
 
13860
+
 
13861
+  if (TARGET_VSX_TIMODE && !TARGET_VSX)
 
13862
+    {
 
13863
+      if (rs6000_isa_flags_explicit & OPTION_MASK_VSX_TIMODE)
 
13864
+       error ("-mvsx-timode requires -mvsx");
 
13865
+      rs6000_isa_flags &= ~OPTION_MASK_VSX_TIMODE;
 
13866
+    }
 
13867
+
 
13868
+  /* The quad memory instructions only works in 64-bit mode. In 32-bit mode,
 
13869
+     silently turn off quad memory mode.  */
 
13870
+  if (TARGET_QUAD_MEMORY && !TARGET_POWERPC64)
 
13871
+    {
 
13872
+      if ((rs6000_isa_flags_explicit & OPTION_MASK_QUAD_MEMORY) != 0)
 
13873
+       warning (0, N_("-mquad-memory requires 64-bit mode"));
 
13874
+
 
13875
+      rs6000_isa_flags &= ~OPTION_MASK_QUAD_MEMORY;
 
13876
+    }
 
13877
+
 
13878
+  /* Enable power8 fusion if we are tuning for power8, even if we aren't
 
13879
+     generating power8 instructions.  */
 
13880
+  if (!(rs6000_isa_flags_explicit & OPTION_MASK_P8_FUSION))
 
13881
+    rs6000_isa_flags |= (processor_target_table[tune_index].target_enable
 
13882
+                        & OPTION_MASK_P8_FUSION);
 
13883
+
 
13884
+  /* Power8 does not fuse sign extended loads with the addis.  If we are
 
13885
+     optimizing at high levels for speed, convert a sign extended load into a
 
13886
+     zero extending load, and an explicit sign extension.  */
 
13887
+  if (TARGET_P8_FUSION
 
13888
+      && !(rs6000_isa_flags_explicit & OPTION_MASK_P8_FUSION_SIGN)
 
13889
+      && optimize_function_for_speed_p (cfun)
 
13890
+      && optimize >= 3)
 
13891
+    rs6000_isa_flags |= OPTION_MASK_P8_FUSION_SIGN;
 
13892
+
 
13893
+  if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET)
 
13894
+    rs6000_print_isa_options (stderr, 0, "after defaults", rs6000_isa_flags);
 
13895
+
 
13896
   /* E500mc does "better" if we inline more aggressively.  Respect the
 
13897
      user's opinion, though.  */
 
13898
   if (rs6000_block_move_inline_limit == 0
 
13899
@@ -2790,6 +3469,9 @@
 
13900
   if (flag_section_anchors)
 
13901
     TARGET_NO_FP_IN_TOC = 1;
 
13902
 
 
13903
+  if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET)
 
13904
+    rs6000_print_isa_options (stderr, 0, "before subtarget", rs6000_isa_flags);
 
13905
+
 
13906
 #ifdef SUBTARGET_OVERRIDE_OPTIONS
 
13907
   SUBTARGET_OVERRIDE_OPTIONS;
 
13908
 #endif
 
13909
@@ -2800,6 +3482,9 @@
 
13910
   SUB3TARGET_OVERRIDE_OPTIONS;
 
13911
 #endif
 
13912
 
 
13913
+  if (TARGET_DEBUG_REG || TARGET_DEBUG_TARGET)
 
13914
+    rs6000_print_isa_options (stderr, 0, "after subtarget", rs6000_isa_flags);
 
13915
+
 
13916
   /* For the E500 family of cores, reset the single/double FP flags to let us
 
13917
      check that they remain constant across attributes or pragmas.  Also,
 
13918
      clear a possible request for string instructions, not supported and which
 
13919
@@ -2849,16 +3534,19 @@
 
13920
                        && rs6000_cpu != PROCESSOR_POWER5
 
13921
                        && rs6000_cpu != PROCESSOR_POWER6
 
13922
                        && rs6000_cpu != PROCESSOR_POWER7
 
13923
+                       && rs6000_cpu != PROCESSOR_POWER8
 
13924
                        && rs6000_cpu != PROCESSOR_PPCA2
 
13925
                        && rs6000_cpu != PROCESSOR_CELL
 
13926
                        && rs6000_cpu != PROCESSOR_PPC476);
 
13927
   rs6000_sched_groups = (rs6000_cpu == PROCESSOR_POWER4
 
13928
                         || rs6000_cpu == PROCESSOR_POWER5
 
13929
-                        || rs6000_cpu == PROCESSOR_POWER7);
 
13930
+                        || rs6000_cpu == PROCESSOR_POWER7
 
13931
+                        || rs6000_cpu == PROCESSOR_POWER8);
 
13932
   rs6000_align_branch_targets = (rs6000_cpu == PROCESSOR_POWER4
 
13933
                                 || rs6000_cpu == PROCESSOR_POWER5
 
13934
                                 || rs6000_cpu == PROCESSOR_POWER6
 
13935
                                 || rs6000_cpu == PROCESSOR_POWER7
 
13936
+                                || rs6000_cpu == PROCESSOR_POWER8
 
13937
                                 || rs6000_cpu == PROCESSOR_PPCE500MC
 
13938
                                 || rs6000_cpu == PROCESSOR_PPCE500MC64
 
13939
                                 || rs6000_cpu == PROCESSOR_PPCE5500
 
13940
@@ -2988,7 +3676,7 @@
 
13941
 
 
13942
       /* We should always be splitting complex arguments, but we can't break
 
13943
         Linux and Darwin ABIs at the moment.  For now, only AIX is fixed.  */
 
13944
-      if (DEFAULT_ABI != ABI_AIX)
 
13945
+      if (DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_DARWIN)
 
13946
        targetm.calls.split_complex_arg = NULL;
 
13947
     }
 
13948
 
 
13949
@@ -3102,6 +3790,10 @@
 
13950
        rs6000_cost = &power7_cost;
 
13951
        break;
 
13952
 
 
13953
+      case PROCESSOR_POWER8:
 
13954
+       rs6000_cost = &power8_cost;
 
13955
+       break;
 
13956
+
 
13957
       case PROCESSOR_PPCA2:
 
13958
        rs6000_cost = &ppca2_cost;
 
13959
        break;
 
13960
@@ -3274,7 +3966,8 @@
 
13961
       && (rs6000_cpu == PROCESSOR_POWER4
 
13962
          || rs6000_cpu == PROCESSOR_POWER5
 
13963
          || rs6000_cpu == PROCESSOR_POWER6
 
13964
-         || rs6000_cpu == PROCESSOR_POWER7))
 
13965
+         || rs6000_cpu == PROCESSOR_POWER7
 
13966
+         || rs6000_cpu == PROCESSOR_POWER8))
 
13967
     return 5;
 
13968
   else
 
13969
     return align_loops_log;
 
13970
@@ -3813,6 +4506,22 @@
 
13971
       enum built_in_function fn = DECL_FUNCTION_CODE (fndecl);
 
13972
       switch (fn)
 
13973
        {
 
13974
+       case BUILT_IN_CLZIMAX:
 
13975
+       case BUILT_IN_CLZLL:
 
13976
+       case BUILT_IN_CLZL:
 
13977
+       case BUILT_IN_CLZ:
 
13978
+         if (TARGET_P8_VECTOR && in_mode == out_mode && out_n == in_n)
 
13979
+           {
 
13980
+             if (out_mode == QImode && out_n == 16)
 
13981
+               return rs6000_builtin_decls[P8V_BUILTIN_VCLZB];
 
13982
+             else if (out_mode == HImode && out_n == 8)
 
13983
+               return rs6000_builtin_decls[P8V_BUILTIN_VCLZH];
 
13984
+             else if (out_mode == SImode && out_n == 4)
 
13985
+               return rs6000_builtin_decls[P8V_BUILTIN_VCLZW];
 
13986
+             else if (out_mode == DImode && out_n == 2)
 
13987
+               return rs6000_builtin_decls[P8V_BUILTIN_VCLZD];
 
13988
+           }
 
13989
+         break;
 
13990
        case BUILT_IN_COPYSIGN:
 
13991
          if (VECTOR_UNIT_VSX_P (V2DFmode)
 
13992
              && out_mode == DFmode && out_n == 2
 
13993
@@ -3828,6 +4537,22 @@
 
13994
          if (VECTOR_UNIT_ALTIVEC_P (V4SFmode))
 
13995
            return rs6000_builtin_decls[ALTIVEC_BUILTIN_COPYSIGN_V4SF];
 
13996
          break;
 
13997
+       case BUILT_IN_POPCOUNTIMAX:
 
13998
+       case BUILT_IN_POPCOUNTLL:
 
13999
+       case BUILT_IN_POPCOUNTL:
 
14000
+       case BUILT_IN_POPCOUNT:
 
14001
+         if (TARGET_P8_VECTOR && in_mode == out_mode && out_n == in_n)
 
14002
+           {
 
14003
+             if (out_mode == QImode && out_n == 16)
 
14004
+               return rs6000_builtin_decls[P8V_BUILTIN_VPOPCNTB];
 
14005
+             else if (out_mode == HImode && out_n == 8)
 
14006
+               return rs6000_builtin_decls[P8V_BUILTIN_VPOPCNTH];
 
14007
+             else if (out_mode == SImode && out_n == 4)
 
14008
+               return rs6000_builtin_decls[P8V_BUILTIN_VPOPCNTW];
 
14009
+             else if (out_mode == DImode && out_n == 2)
 
14010
+               return rs6000_builtin_decls[P8V_BUILTIN_VPOPCNTD];
 
14011
+           }
 
14012
+         break;
 
14013
        case BUILT_IN_SQRT:
 
14014
          if (VECTOR_UNIT_VSX_P (V2DFmode)
 
14015
              && out_mode == DFmode && out_n == 2
 
14016
@@ -4043,7 +4768,11 @@
 
14017
        putc ('\n', file);
 
14018
     }
 
14019
 
 
14020
-  if (DEFAULT_ABI == ABI_AIX || (TARGET_ELF && flag_pic == 2))
 
14021
+  if (DEFAULT_ABI == ABI_ELFv2)
 
14022
+    fprintf (file, "\t.abiversion 2\n");
 
14023
+
 
14024
+  if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2
 
14025
+      || (TARGET_ELF && flag_pic == 2))
 
14026
     {
 
14027
       switch_to_section (toc_section);
 
14028
       switch_to_section (text_section);
 
14029
@@ -4274,15 +5003,16 @@
 
14030
 
 
14031
   /* Check if VAL is present in every STEP-th element, and the
 
14032
      other elements are filled with its most significant bit.  */
 
14033
-  for (i = 0; i < nunits - 1; ++i)
 
14034
+  for (i = 1; i < nunits; ++i)
 
14035
     {
 
14036
       HOST_WIDE_INT desired_val;
 
14037
-      if (((BYTES_BIG_ENDIAN ? i + 1 : i) & (step - 1)) == 0)
 
14038
+      unsigned elt = BYTES_BIG_ENDIAN ? nunits - 1 - i : i;
 
14039
+      if ((i & (step - 1)) == 0)
 
14040
        desired_val = val;
 
14041
       else
 
14042
        desired_val = msb_val;
 
14043
 
 
14044
-      if (desired_val != const_vector_elt_as_int (op, i))
 
14045
+      if (desired_val != const_vector_elt_as_int (op, elt))
 
14046
        return false;
 
14047
     }
 
14048
 
 
14049
@@ -4698,8 +5428,11 @@
 
14050
        {
 
14051
          rtx freg = gen_reg_rtx (V4SFmode);
 
14052
          rtx sreg = force_reg (SFmode, XVECEXP (vals, 0, 0));
 
14053
+         rtx cvt  = ((TARGET_XSCVDPSPN)
 
14054
+                     ? gen_vsx_xscvdpspn_scalar (freg, sreg)
 
14055
+                     : gen_vsx_xscvdpsp_scalar (freg, sreg));
 
14056
 
 
14057
-         emit_insn (gen_vsx_xscvdpsp_scalar (freg, sreg));
 
14058
+         emit_insn (cvt);
 
14059
          emit_insn (gen_vsx_xxspltw_v4sf (target, freg, const0_rtx));
 
14060
        }
 
14061
       else
 
14062
@@ -4726,6 +5459,7 @@
 
14063
      of 64-bit items is not supported on Altivec.  */
 
14064
   if (all_same && GET_MODE_SIZE (inner_mode) <= 4)
 
14065
     {
 
14066
+      rtx field;
 
14067
       mem = assign_stack_temp (mode, GET_MODE_SIZE (inner_mode));
 
14068
       emit_move_insn (adjust_address_nv (mem, inner_mode, 0),
 
14069
                      XVECEXP (vals, 0, 0));
 
14070
@@ -4736,9 +5470,11 @@
 
14071
                                              gen_rtx_SET (VOIDmode,
 
14072
                                                           target, mem),
 
14073
                                              x)));
 
14074
+      field = (BYTES_BIG_ENDIAN ? const0_rtx
 
14075
+              : GEN_INT (GET_MODE_NUNITS (mode) - 1));
 
14076
       x = gen_rtx_VEC_SELECT (inner_mode, target,
 
14077
                              gen_rtx_PARALLEL (VOIDmode,
 
14078
-                                               gen_rtvec (1, const0_rtx)));
 
14079
+                                               gen_rtvec (1, field)));
 
14080
       emit_insn (gen_rtx_SET (VOIDmode, target,
 
14081
                              gen_rtx_VEC_DUPLICATE (mode, x)));
 
14082
       return;
 
14083
@@ -4811,10 +5547,27 @@
 
14084
     XVECEXP (mask, 0, elt*width + i)
 
14085
       = GEN_INT (i + 0x10);
 
14086
   x = gen_rtx_CONST_VECTOR (V16QImode, XVEC (mask, 0));
 
14087
-  x = gen_rtx_UNSPEC (mode,
 
14088
-                     gen_rtvec (3, target, reg,
 
14089
-                                force_reg (V16QImode, x)),
 
14090
-                     UNSPEC_VPERM);
 
14091
+
 
14092
+  if (BYTES_BIG_ENDIAN)
 
14093
+    x = gen_rtx_UNSPEC (mode,
 
14094
+                       gen_rtvec (3, target, reg,
 
14095
+                                  force_reg (V16QImode, x)),
 
14096
+                       UNSPEC_VPERM);
 
14097
+  else 
 
14098
+    {
 
14099
+      /* Invert selector.  */
 
14100
+      rtx splat = gen_rtx_VEC_DUPLICATE (V16QImode,
 
14101
+                                        gen_rtx_CONST_INT (QImode, -1));
 
14102
+      rtx tmp = gen_reg_rtx (V16QImode);
 
14103
+      emit_move_insn (tmp, splat);
 
14104
+      x = gen_rtx_MINUS (V16QImode, tmp, force_reg (V16QImode, x));
 
14105
+      emit_move_insn (tmp, x);
 
14106
+
 
14107
+      /* Permute with operands reversed and adjusted selector.  */
 
14108
+      x = gen_rtx_UNSPEC (mode, gen_rtvec (3, reg, target, tmp),
 
14109
+                         UNSPEC_VPERM);
 
14110
+    }
 
14111
+
 
14112
   emit_insn (gen_rtx_SET (VOIDmode, target, x));
 
14113
 }
 
14114
 
 
14115
@@ -4938,7 +5691,7 @@
 
14116
         purpose.  */
 
14117
       if (GET_CODE (op) == SUBREG
 
14118
          && (mode == SImode || mode == DImode || mode == TImode
 
14119
-             || mode == DDmode || mode == TDmode)
 
14120
+             || mode == DDmode || mode == TDmode || mode == PTImode)
 
14121
          && REG_P (SUBREG_REG (op))
 
14122
          && (GET_MODE (SUBREG_REG (op)) == DFmode
 
14123
              || GET_MODE (SUBREG_REG (op)) == TFmode))
 
14124
@@ -4951,6 +5704,7 @@
 
14125
          && REG_P (SUBREG_REG (op))
 
14126
          && (GET_MODE (SUBREG_REG (op)) == DImode
 
14127
              || GET_MODE (SUBREG_REG (op)) == TImode
 
14128
+             || GET_MODE (SUBREG_REG (op)) == PTImode
 
14129
              || GET_MODE (SUBREG_REG (op)) == DDmode
 
14130
              || GET_MODE (SUBREG_REG (op)) == TDmode))
 
14131
        return true;
 
14132
@@ -5087,6 +5841,72 @@
 
14133
          || (REG_P (op1) && INT_REGNO_P (REGNO (op1))));
 
14134
 }
 
14135
 
 
14136
+/* Return true if this is a move direct operation between GPR registers and
 
14137
+   floating point/VSX registers.  */
 
14138
+
 
14139
+bool
 
14140
+direct_move_p (rtx op0, rtx op1)
 
14141
+{
 
14142
+  int regno0, regno1;
 
14143
+
 
14144
+  if (!REG_P (op0) || !REG_P (op1))
 
14145
+    return false;
 
14146
+
 
14147
+  if (!TARGET_DIRECT_MOVE && !TARGET_MFPGPR)
 
14148
+    return false;
 
14149
+
 
14150
+  regno0 = REGNO (op0);
 
14151
+  regno1 = REGNO (op1);
 
14152
+  if (regno0 >= FIRST_PSEUDO_REGISTER || regno1 >= FIRST_PSEUDO_REGISTER)
 
14153
+    return false;
 
14154
+
 
14155
+  if (INT_REGNO_P (regno0))
 
14156
+    return (TARGET_DIRECT_MOVE) ? VSX_REGNO_P (regno1) : FP_REGNO_P (regno1);
 
14157
+
 
14158
+  else if (INT_REGNO_P (regno1))
 
14159
+    {
 
14160
+      if (TARGET_MFPGPR && FP_REGNO_P (regno0))
 
14161
+       return true;
 
14162
+
 
14163
+      else if (TARGET_DIRECT_MOVE && VSX_REGNO_P (regno0))
 
14164
+       return true;
 
14165
+    }
 
14166
+
 
14167
+  return false;
 
14168
+}
 
14169
+
 
14170
+/* Return true if this is a load or store quad operation.  */
 
14171
+
 
14172
+bool
 
14173
+quad_load_store_p (rtx op0, rtx op1)
 
14174
+{
 
14175
+  bool ret;
 
14176
+
 
14177
+  if (!TARGET_QUAD_MEMORY)
 
14178
+    ret = false;
 
14179
+
 
14180
+  else if (REG_P (op0) && MEM_P (op1))
 
14181
+    ret = (quad_int_reg_operand (op0, GET_MODE (op0))
 
14182
+          && quad_memory_operand (op1, GET_MODE (op1))
 
14183
+          && !reg_overlap_mentioned_p (op0, op1));
 
14184
+
 
14185
+  else if (MEM_P (op0) && REG_P (op1))
 
14186
+    ret = (quad_memory_operand (op0, GET_MODE (op0))
 
14187
+          && quad_int_reg_operand (op1, GET_MODE (op1)));
 
14188
+
 
14189
+  else
 
14190
+    ret = false;
 
14191
+
 
14192
+  if (TARGET_DEBUG_ADDR)
 
14193
+    {
 
14194
+      fprintf (stderr, "\n========== quad_load_store, return %s\n",
 
14195
+              ret ? "true" : "false");
 
14196
+      debug_rtx (gen_rtx_SET (VOIDmode, op0, op1));
 
14197
+    }
 
14198
+
 
14199
+  return ret;
 
14200
+}
 
14201
+
 
14202
 /* Given an address, return a constant offset term if one exists.  */
 
14203
 
 
14204
 static rtx
 
14205
@@ -5170,7 +5990,11 @@
 
14206
     case V4SImode:
 
14207
     case V2DFmode:
 
14208
     case V2DImode:
 
14209
-      /* AltiVec/VSX vector modes.  Only reg+reg addressing is valid.  */
 
14210
+    case TImode:
 
14211
+      /* AltiVec/VSX vector modes.  Only reg+reg addressing is valid.  While
 
14212
+        TImode is not a vector mode, if we want to use the VSX registers to
 
14213
+        move it around, we need to restrict ourselves to reg+reg
 
14214
+        addressing.  */
 
14215
       if (VECTOR_MEM_ALTIVEC_OR_VSX_P (mode))
 
14216
        return false;
 
14217
       break;
 
14218
@@ -5184,6 +6008,13 @@
 
14219
         return false;
 
14220
       break;
 
14221
 
 
14222
+    case SDmode:
 
14223
+      /* If we can do direct load/stores of SDmode, restrict it to reg+reg
 
14224
+        addressing for the LFIWZX and STFIWX instructions.  */
 
14225
+      if (TARGET_NO_SDMODE_STACK)
 
14226
+       return false;
 
14227
+      break;
 
14228
+
 
14229
     default:
 
14230
       break;
 
14231
     }
 
14232
@@ -5416,7 +6247,7 @@
 
14233
 
 
14234
       /* If we are using VSX scalar loads, restrict ourselves to reg+reg
 
14235
         addressing.  */
 
14236
-      if (mode == DFmode && VECTOR_MEM_VSX_P (DFmode))
 
14237
+      if (VECTOR_MEM_VSX_P (mode))
 
14238
        return false;
 
14239
 
 
14240
       if (!worst_case)
 
14241
@@ -5428,6 +6259,7 @@
 
14242
       break;
 
14243
 
 
14244
     case TFmode:
 
14245
+    case PTImode:
 
14246
       if (TARGET_E500_DOUBLE)
 
14247
        return (SPE_CONST_OFFSET_OK (offset)
 
14248
                && SPE_CONST_OFFSET_OK (offset + 8));
 
14249
@@ -5527,7 +6359,7 @@
 
14250
 
 
14251
   if (TARGET_ELF || TARGET_MACHO)
 
14252
     {
 
14253
-      if (DEFAULT_ABI != ABI_AIX && DEFAULT_ABI != ABI_DARWIN && flag_pic)
 
14254
+      if (DEFAULT_ABI == ABI_V4 && flag_pic)
 
14255
        return false;
 
14256
       if (TARGET_TOC)
 
14257
        return false;
 
14258
@@ -5583,8 +6415,11 @@
 
14259
       if (GET_CODE (x) == PLUS && XEXP (x, 1) == const0_rtx)
 
14260
        return force_reg (Pmode, XEXP (x, 0));
 
14261
 
 
14262
+      /* For TImode with load/store quad, restrict addresses to just a single
 
14263
+        pointer, so it works with both GPRs and VSX registers.  */
 
14264
       /* Make sure both operands are registers.  */
 
14265
-      else if (GET_CODE (x) == PLUS)
 
14266
+      else if (GET_CODE (x) == PLUS
 
14267
+              && (mode != TImode || !TARGET_QUAD_MEMORY))
 
14268
        return gen_rtx_PLUS (Pmode,
 
14269
                             force_reg (Pmode, XEXP (x, 0)),
 
14270
                             force_reg (Pmode, XEXP (x, 1)));
 
14271
@@ -5604,11 +6439,12 @@
 
14272
     case TFmode:
 
14273
     case TDmode:
 
14274
     case TImode:
 
14275
+    case PTImode:
 
14276
       /* As in legitimate_offset_address_p we do not assume
 
14277
         worst-case.  The mode here is just a hint as to the registers
 
14278
         used.  A TImode is usually in gprs, but may actually be in
 
14279
         fprs.  Leave worst-case scenario for reload to handle via
 
14280
-        insn constraints.  */
 
14281
+        insn constraints.  PTImode is only GPRs.  */
 
14282
       extra = 8;
 
14283
       break;
 
14284
     default:
 
14285
@@ -6100,10 +6936,13 @@
 
14286
                                   1, const0_rtx, Pmode);
 
14287
 
 
14288
          r3 = gen_rtx_REG (Pmode, 3);
 
14289
-         if (DEFAULT_ABI == ABI_AIX && TARGET_64BIT)
 
14290
-           insn = gen_tls_gd_aix64 (r3, got, addr, tga, const0_rtx);
 
14291
-         else if (DEFAULT_ABI == ABI_AIX && !TARGET_64BIT)
 
14292
-           insn = gen_tls_gd_aix32 (r3, got, addr, tga, const0_rtx);
 
14293
+         if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
14294
+           {
 
14295
+             if (TARGET_64BIT)
 
14296
+               insn = gen_tls_gd_aix64 (r3, got, addr, tga, const0_rtx);
 
14297
+             else
 
14298
+               insn = gen_tls_gd_aix32 (r3, got, addr, tga, const0_rtx);
 
14299
+           }
 
14300
          else if (DEFAULT_ABI == ABI_V4)
 
14301
            insn = gen_tls_gd_sysvsi (r3, got, addr, tga, const0_rtx);
 
14302
          else
 
14303
@@ -6122,10 +6961,13 @@
 
14304
                                   1, const0_rtx, Pmode);
 
14305
 
 
14306
          r3 = gen_rtx_REG (Pmode, 3);
 
14307
-         if (DEFAULT_ABI == ABI_AIX && TARGET_64BIT)
 
14308
-           insn = gen_tls_ld_aix64 (r3, got, tga, const0_rtx);
 
14309
-         else if (DEFAULT_ABI == ABI_AIX && !TARGET_64BIT)
 
14310
-           insn = gen_tls_ld_aix32 (r3, got, tga, const0_rtx);
 
14311
+         if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
14312
+           {
 
14313
+             if (TARGET_64BIT)
 
14314
+               insn = gen_tls_ld_aix64 (r3, got, tga, const0_rtx);
 
14315
+             else
 
14316
+               insn = gen_tls_ld_aix32 (r3, got, tga, const0_rtx);
 
14317
+           }
 
14318
          else if (DEFAULT_ABI == ABI_V4)
 
14319
            insn = gen_tls_ld_sysvsi (r3, got, tga, const0_rtx);
 
14320
          else
 
14321
@@ -6339,7 +7181,7 @@
 
14322
       && !(TARGET_E500_DOUBLE && (mode == DFmode || mode == TFmode
 
14323
                                  || mode == DDmode || mode == TDmode
 
14324
                                  || mode == DImode))
 
14325
-      && VECTOR_MEM_NONE_P (mode))
 
14326
+      && (!VECTOR_MODE_P (mode) || VECTOR_MEM_NONE_P (mode)))
 
14327
     {
 
14328
       HOST_WIDE_INT val = INTVAL (XEXP (x, 1));
 
14329
       HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
 
14330
@@ -6370,7 +7212,7 @@
 
14331
 
 
14332
   if (GET_CODE (x) == SYMBOL_REF
 
14333
       && reg_offset_p
 
14334
-      && VECTOR_MEM_NONE_P (mode)
 
14335
+      && (!VECTOR_MODE_P (mode) || VECTOR_MEM_NONE_P (mode))
 
14336
       && !SPE_VECTOR_MODE (mode)
 
14337
 #if TARGET_MACHO
 
14338
       && DEFAULT_ABI == ABI_DARWIN
 
14339
@@ -6396,6 +7238,8 @@
 
14340
         mem is sufficiently aligned.  */
 
14341
       && mode != TFmode
 
14342
       && mode != TDmode
 
14343
+      && (mode != TImode || !TARGET_VSX_TIMODE)
 
14344
+      && mode != PTImode
 
14345
       && (mode != DImode || TARGET_POWERPC64)
 
14346
       && ((mode != DFmode && mode != DDmode) || TARGET_POWERPC64
 
14347
          || (TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT)))
 
14348
@@ -6516,15 +7360,9 @@
 
14349
     return 0;
 
14350
   if (legitimate_indirect_address_p (x, reg_ok_strict))
 
14351
     return 1;
 
14352
-  if ((GET_CODE (x) == PRE_INC || GET_CODE (x) == PRE_DEC)
 
14353
-      && !VECTOR_MEM_ALTIVEC_OR_VSX_P (mode)
 
14354
-      && !SPE_VECTOR_MODE (mode)
 
14355
-      && mode != TFmode
 
14356
-      && mode != TDmode
 
14357
-      /* Restrict addressing for DI because of our SUBREG hackery.  */
 
14358
-      && !(TARGET_E500_DOUBLE
 
14359
-          && (mode == DFmode || mode == DDmode || mode == DImode))
 
14360
-      && TARGET_UPDATE
 
14361
+  if (TARGET_UPDATE
 
14362
+      && (GET_CODE (x) == PRE_INC || GET_CODE (x) == PRE_DEC)
 
14363
+      && mode_supports_pre_incdec_p (mode)
 
14364
       && legitimate_indirect_address_p (XEXP (x, 0), reg_ok_strict))
 
14365
     return 1;
 
14366
   if (virtual_stack_registers_memory_p (x))
 
14367
@@ -6534,6 +7372,13 @@
 
14368
   if (reg_offset_p
 
14369
       && legitimate_constant_pool_address_p (x, mode, reg_ok_strict))
 
14370
     return 1;
 
14371
+  /* For TImode, if we have load/store quad and TImode in VSX registers, only
 
14372
+     allow register indirect addresses.  This will allow the values to go in
 
14373
+     either GPRs or VSX registers without reloading.  The vector types would
 
14374
+     tend to go into VSX registers, so we allow REG+REG, while TImode seems
 
14375
+     somewhat split, in that some uses are GPR based, and some VSX based.  */
 
14376
+  if (mode == TImode && TARGET_QUAD_MEMORY && TARGET_VSX_TIMODE)
 
14377
+    return 0;
 
14378
   /* If not REG_OK_STRICT (before reload) let pass any stack offset.  */
 
14379
   if (! reg_ok_strict
 
14380
       && reg_offset_p
 
14381
@@ -6545,31 +7390,20 @@
 
14382
     return 1;
 
14383
   if (rs6000_legitimate_offset_address_p (mode, x, reg_ok_strict, false))
 
14384
     return 1;
 
14385
-  if (mode != TImode
 
14386
-      && mode != TFmode
 
14387
+  if (mode != TFmode
 
14388
       && mode != TDmode
 
14389
       && ((TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT)
 
14390
          || TARGET_POWERPC64
 
14391
          || (mode != DFmode && mode != DDmode)
 
14392
          || (TARGET_E500_DOUBLE && mode != DDmode))
 
14393
       && (TARGET_POWERPC64 || mode != DImode)
 
14394
+      && (mode != TImode || VECTOR_MEM_VSX_P (TImode))
 
14395
+      && mode != PTImode
 
14396
       && !avoiding_indexed_address_p (mode)
 
14397
       && legitimate_indexed_address_p (x, reg_ok_strict))
 
14398
     return 1;
 
14399
-  if (GET_CODE (x) == PRE_MODIFY
 
14400
-      && mode != TImode
 
14401
-      && mode != TFmode
 
14402
-      && mode != TDmode
 
14403
-      && ((TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT)
 
14404
-         || TARGET_POWERPC64
 
14405
-         || ((mode != DFmode && mode != DDmode) || TARGET_E500_DOUBLE))
 
14406
-      && (TARGET_POWERPC64 || mode != DImode)
 
14407
-      && !VECTOR_MEM_ALTIVEC_OR_VSX_P (mode)
 
14408
-      && !SPE_VECTOR_MODE (mode)
 
14409
-      /* Restrict addressing for DI because of our SUBREG hackery.  */
 
14410
-      && !(TARGET_E500_DOUBLE
 
14411
-          && (mode == DFmode || mode == DDmode || mode == DImode))
 
14412
-      && TARGET_UPDATE
 
14413
+  if (TARGET_UPDATE && GET_CODE (x) == PRE_MODIFY
 
14414
+      && mode_supports_pre_modify_p (mode)
 
14415
       && legitimate_indirect_address_p (XEXP (x, 0), reg_ok_strict)
 
14416
       && (rs6000_legitimate_offset_address_p (mode, XEXP (x, 1),
 
14417
                                              reg_ok_strict, false)
 
14418
@@ -6590,10 +7424,13 @@
 
14419
   bool ret = rs6000_legitimate_address_p (mode, x, reg_ok_strict);
 
14420
   fprintf (stderr,
 
14421
           "\nrs6000_legitimate_address_p: return = %s, mode = %s, "
 
14422
-          "strict = %d, code = %s\n",
 
14423
+          "strict = %d, reload = %s, code = %s\n",
 
14424
           ret ? "true" : "false",
 
14425
           GET_MODE_NAME (mode),
 
14426
           reg_ok_strict,
 
14427
+          (reload_completed
 
14428
+           ? "after"
 
14429
+           : (reload_in_progress ? "progress" : "before")),
 
14430
           GET_RTX_NAME (GET_CODE (x)));
 
14431
   debug_rtx (x);
 
14432
 
 
14433
@@ -6759,7 +7596,7 @@
 
14434
 
 
14435
   /* The TOC register is not killed across calls in a way that is
 
14436
      visible to the compiler.  */
 
14437
-  if (DEFAULT_ABI == ABI_AIX)
 
14438
+  if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
14439
     call_really_used_regs[2] = 0;
 
14440
 
 
14441
   if (DEFAULT_ABI == ABI_V4
 
14442
@@ -7007,7 +7844,7 @@
 
14443
 }
 
14444
 
 
14445
 /* Helper for the following.  Get rid of [r+r] memory refs
 
14446
-   in cases where it won't work (TImode, TFmode, TDmode).  */
 
14447
+   in cases where it won't work (TImode, TFmode, TDmode, PTImode).  */
 
14448
 
 
14449
 static void
 
14450
 rs6000_eliminate_indexed_memrefs (rtx operands[2])
 
14451
@@ -7032,6 +7869,107 @@
 
14452
                               copy_addr_to_reg (XEXP (operands[1], 0)));
 
14453
 }
 
14454
 
 
14455
+/* Generate a vector of constants to permute MODE for a little-endian
 
14456
+   storage operation by swapping the two halves of a vector.  */
 
14457
+static rtvec
 
14458
+rs6000_const_vec (enum machine_mode mode)
 
14459
+{
 
14460
+  int i, subparts;
 
14461
+  rtvec v;
 
14462
+
 
14463
+  switch (mode)
 
14464
+    {
 
14465
+    case V2DFmode:
 
14466
+    case V2DImode:
 
14467
+      subparts = 2;
 
14468
+      break;
 
14469
+    case V4SFmode:
 
14470
+    case V4SImode:
 
14471
+      subparts = 4;
 
14472
+      break;
 
14473
+    case V8HImode:
 
14474
+      subparts = 8;
 
14475
+      break;
 
14476
+    case V16QImode:
 
14477
+      subparts = 16;
 
14478
+      break;
 
14479
+    default:
 
14480
+      gcc_unreachable();
 
14481
+    }
 
14482
+
 
14483
+  v = rtvec_alloc (subparts);
 
14484
+
 
14485
+  for (i = 0; i < subparts / 2; ++i)
 
14486
+    RTVEC_ELT (v, i) = gen_rtx_CONST_INT (DImode, i + subparts / 2);
 
14487
+  for (i = subparts / 2; i < subparts; ++i)
 
14488
+    RTVEC_ELT (v, i) = gen_rtx_CONST_INT (DImode, i - subparts / 2);
 
14489
+
 
14490
+  return v;
 
14491
+}
 
14492
+
 
14493
+/* Generate a permute rtx that represents an lxvd2x, stxvd2x, or xxpermdi
 
14494
+   for a VSX load or store operation.  */
 
14495
+rtx
 
14496
+rs6000_gen_le_vsx_permute (rtx source, enum machine_mode mode)
 
14497
+{
 
14498
+  rtx par = gen_rtx_PARALLEL (VOIDmode, rs6000_const_vec (mode));
 
14499
+  return gen_rtx_VEC_SELECT (mode, source, par);
 
14500
+}
 
14501
+
 
14502
+/* Emit a little-endian load from vector memory location SOURCE to VSX
 
14503
+   register DEST in mode MODE.  The load is done with two permuting
 
14504
+   insn's that represent an lxvd2x and xxpermdi.  */
 
14505
+void
 
14506
+rs6000_emit_le_vsx_load (rtx dest, rtx source, enum machine_mode mode)
 
14507
+{
 
14508
+  rtx tmp = can_create_pseudo_p () ? gen_reg_rtx_and_attrs (dest) : dest;
 
14509
+  rtx permute_mem = rs6000_gen_le_vsx_permute (source, mode);
 
14510
+  rtx permute_reg = rs6000_gen_le_vsx_permute (tmp, mode);
 
14511
+  emit_insn (gen_rtx_SET (VOIDmode, tmp, permute_mem));
 
14512
+  emit_insn (gen_rtx_SET (VOIDmode, dest, permute_reg));
 
14513
+}
 
14514
+
 
14515
+/* Emit a little-endian store to vector memory location DEST from VSX
 
14516
+   register SOURCE in mode MODE.  The store is done with two permuting
 
14517
+   insn's that represent an xxpermdi and an stxvd2x.  */
 
14518
+void
 
14519
+rs6000_emit_le_vsx_store (rtx dest, rtx source, enum machine_mode mode)
 
14520
+{
 
14521
+  rtx tmp = can_create_pseudo_p () ? gen_reg_rtx_and_attrs (source) : source;
 
14522
+  rtx permute_src = rs6000_gen_le_vsx_permute (source, mode);
 
14523
+  rtx permute_tmp = rs6000_gen_le_vsx_permute (tmp, mode);
 
14524
+  emit_insn (gen_rtx_SET (VOIDmode, tmp, permute_src));
 
14525
+  emit_insn (gen_rtx_SET (VOIDmode, dest, permute_tmp));
 
14526
+}
 
14527
+
 
14528
+/* Emit a sequence representing a little-endian VSX load or store,
 
14529
+   moving data from SOURCE to DEST in mode MODE.  This is done
 
14530
+   separately from rs6000_emit_move to ensure it is called only
 
14531
+   during expand.  LE VSX loads and stores introduced later are
 
14532
+   handled with a split.  The expand-time RTL generation allows
 
14533
+   us to optimize away redundant pairs of register-permutes.  */
 
14534
+void
 
14535
+rs6000_emit_le_vsx_move (rtx dest, rtx source, enum machine_mode mode)
 
14536
+{
 
14537
+  gcc_assert (!BYTES_BIG_ENDIAN
 
14538
+             && VECTOR_MEM_VSX_P (mode)
 
14539
+             && mode != TImode
 
14540
+             && !gpr_or_gpr_p (dest, source)
 
14541
+             && (MEM_P (source) ^ MEM_P (dest)));
 
14542
+
 
14543
+  if (MEM_P (source))
 
14544
+    {
 
14545
+      gcc_assert (REG_P (dest));
 
14546
+      rs6000_emit_le_vsx_load (dest, source, mode);
 
14547
+    }
 
14548
+  else
 
14549
+    {
 
14550
+      if (!REG_P (source))
 
14551
+       source = force_reg (mode, source);
 
14552
+      rs6000_emit_le_vsx_store (dest, source, mode);
 
14553
+    }
 
14554
+}
 
14555
+
 
14556
 /* Emit a move from SOURCE to DEST in mode MODE.  */
 
14557
 void
 
14558
 rs6000_emit_move (rtx dest, rtx source, enum machine_mode mode)
 
14559
@@ -7152,6 +8090,7 @@
 
14560
 
 
14561
   if (reload_in_progress
 
14562
       && mode == SDmode
 
14563
+      && cfun->machine->sdmode_stack_slot != NULL_RTX
 
14564
       && MEM_P (operands[0])
 
14565
       && rtx_equal_p (operands[0], cfun->machine->sdmode_stack_slot)
 
14566
       && REG_P (operands[1]))
 
14567
@@ -7164,7 +8103,9 @@
 
14568
        }
 
14569
       else if (INT_REGNO_P (REGNO (operands[1])))
 
14570
        {
 
14571
-         rtx mem = adjust_address_nv (operands[0], mode, 4);
 
14572
+         rtx mem = operands[0];
 
14573
+         if (BYTES_BIG_ENDIAN)
 
14574
+           mem = adjust_address_nv (mem, mode, 4);
 
14575
          mem = eliminate_regs (mem, VOIDmode, NULL_RTX);
 
14576
          emit_insn (gen_movsd_hardfloat (mem, operands[1]));
 
14577
        }
 
14578
@@ -7176,6 +8117,7 @@
 
14579
       && mode == SDmode
 
14580
       && REG_P (operands[0])
 
14581
       && MEM_P (operands[1])
 
14582
+      && cfun->machine->sdmode_stack_slot != NULL_RTX
 
14583
       && rtx_equal_p (operands[1], cfun->machine->sdmode_stack_slot))
 
14584
     {
 
14585
       if (FP_REGNO_P (REGNO (operands[0])))
 
14586
@@ -7186,7 +8128,9 @@
 
14587
        }
 
14588
       else if (INT_REGNO_P (REGNO (operands[0])))
 
14589
        {
 
14590
-         rtx mem = adjust_address_nv (operands[1], mode, 4);
 
14591
+         rtx mem = operands[1];
 
14592
+         if (BYTES_BIG_ENDIAN)
 
14593
+           mem = adjust_address_nv (mem, mode, 4);
 
14594
          mem = eliminate_regs (mem, VOIDmode, NULL_RTX);
 
14595
          emit_insn (gen_movsd_hardfloat (operands[0], mem));
 
14596
        }
 
14597
@@ -7389,6 +8333,11 @@
 
14598
       break;
 
14599
 
 
14600
     case TImode:
 
14601
+      if (!VECTOR_MEM_VSX_P (TImode))
 
14602
+       rs6000_eliminate_indexed_memrefs (operands);
 
14603
+      break;
 
14604
+
 
14605
+    case PTImode:
 
14606
       rs6000_eliminate_indexed_memrefs (operands);
 
14607
       break;
 
14608
 
 
14609
@@ -7427,18 +8376,231 @@
 
14610
 }
 
14611
 
 
14612
 /* Nonzero if we can use a floating-point register to pass this arg.  */
 
14613
-#define USE_FP_FOR_ARG_P(CUM,MODE,TYPE)                \
 
14614
+#define USE_FP_FOR_ARG_P(CUM,MODE)             \
 
14615
   (SCALAR_FLOAT_MODE_P (MODE)                  \
 
14616
    && (CUM)->fregno <= FP_ARG_MAX_REG          \
 
14617
    && TARGET_HARD_FLOAT && TARGET_FPRS)
 
14618
 
 
14619
 /* Nonzero if we can use an AltiVec register to pass this arg.  */
 
14620
-#define USE_ALTIVEC_FOR_ARG_P(CUM,MODE,TYPE,NAMED)             \
 
14621
+#define USE_ALTIVEC_FOR_ARG_P(CUM,MODE,NAMED)                  \
 
14622
   (ALTIVEC_OR_VSX_VECTOR_MODE (MODE)                           \
 
14623
    && (CUM)->vregno <= ALTIVEC_ARG_MAX_REG                     \
 
14624
    && TARGET_ALTIVEC_ABI                                       \
 
14625
    && (NAMED))
 
14626
 
 
14627
+/* Walk down the type tree of TYPE counting consecutive base elements.
 
14628
+   If *MODEP is VOIDmode, then set it to the first valid floating point
 
14629
+   or vector type.  If a non-floating point or vector type is found, or
 
14630
+   if a floating point or vector type that doesn't match a non-VOIDmode
 
14631
+   *MODEP is found, then return -1, otherwise return the count in the
 
14632
+   sub-tree.  */
 
14633
+
 
14634
+static int
 
14635
+rs6000_aggregate_candidate (const_tree type, enum machine_mode *modep)
 
14636
+{
 
14637
+  enum machine_mode mode;
 
14638
+  HOST_WIDE_INT size;
 
14639
+
 
14640
+  switch (TREE_CODE (type))
 
14641
+    {
 
14642
+    case REAL_TYPE:
 
14643
+      mode = TYPE_MODE (type);
 
14644
+      if (!SCALAR_FLOAT_MODE_P (mode))
 
14645
+       return -1;
 
14646
+
 
14647
+      if (*modep == VOIDmode)
 
14648
+       *modep = mode;
 
14649
+
 
14650
+      if (*modep == mode)
 
14651
+       return 1;
 
14652
+
 
14653
+      break;
 
14654
+
 
14655
+    case COMPLEX_TYPE:
 
14656
+      mode = TYPE_MODE (TREE_TYPE (type));
 
14657
+      if (!SCALAR_FLOAT_MODE_P (mode))
 
14658
+       return -1;
 
14659
+
 
14660
+      if (*modep == VOIDmode)
 
14661
+       *modep = mode;
 
14662
+
 
14663
+      if (*modep == mode)
 
14664
+       return 2;
 
14665
+
 
14666
+      break;
 
14667
+
 
14668
+    case VECTOR_TYPE:
 
14669
+      if (!TARGET_ALTIVEC_ABI || !TARGET_ALTIVEC)
 
14670
+       return -1;
 
14671
+
 
14672
+      /* Use V4SImode as representative of all 128-bit vector types.  */
 
14673
+      size = int_size_in_bytes (type);
 
14674
+      switch (size)
 
14675
+       {
 
14676
+       case 16:
 
14677
+         mode = V4SImode;
 
14678
+         break;
 
14679
+       default:
 
14680
+         return -1;
 
14681
+       }
 
14682
+
 
14683
+      if (*modep == VOIDmode)
 
14684
+       *modep = mode;
 
14685
+
 
14686
+      /* Vector modes are considered to be opaque: two vectors are
 
14687
+        equivalent for the purposes of being homogeneous aggregates
 
14688
+        if they are the same size.  */
 
14689
+      if (*modep == mode)
 
14690
+       return 1;
 
14691
+
 
14692
+      break;
 
14693
+
 
14694
+    case ARRAY_TYPE:
 
14695
+      {
 
14696
+       int count;
 
14697
+       tree index = TYPE_DOMAIN (type);
 
14698
+
 
14699
+       /* Can't handle incomplete types.  */
 
14700
+       if (!COMPLETE_TYPE_P (type))
 
14701
+         return -1;
 
14702
+
 
14703
+       count = rs6000_aggregate_candidate (TREE_TYPE (type), modep);
 
14704
+       if (count == -1
 
14705
+           || !index
 
14706
+           || !TYPE_MAX_VALUE (index)
 
14707
+           || !host_integerp (TYPE_MAX_VALUE (index), 1)
 
14708
+           || !TYPE_MIN_VALUE (index)
 
14709
+           || !host_integerp (TYPE_MIN_VALUE (index), 1)
 
14710
+           || count < 0)
 
14711
+         return -1;
 
14712
+
 
14713
+       count *= (1 + tree_low_cst (TYPE_MAX_VALUE (index), 1)
 
14714
+                     - tree_low_cst (TYPE_MIN_VALUE (index), 1));
 
14715
+
 
14716
+       /* There must be no padding.  */
 
14717
+       if (!host_integerp (TYPE_SIZE (type), 1)
 
14718
+           || (tree_low_cst (TYPE_SIZE (type), 1)
 
14719
+               != count * GET_MODE_BITSIZE (*modep)))
 
14720
+         return -1;
 
14721
+
 
14722
+       return count;
 
14723
+      }
 
14724
+
 
14725
+    case RECORD_TYPE:
 
14726
+      {
 
14727
+       int count = 0;
 
14728
+       int sub_count;
 
14729
+       tree field;
 
14730
+
 
14731
+       /* Can't handle incomplete types.  */
 
14732
+       if (!COMPLETE_TYPE_P (type))
 
14733
+         return -1;
 
14734
+
 
14735
+       for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
 
14736
+         {
 
14737
+           if (TREE_CODE (field) != FIELD_DECL)
 
14738
+             continue;
 
14739
+
 
14740
+           sub_count = rs6000_aggregate_candidate (TREE_TYPE (field), modep);
 
14741
+           if (sub_count < 0)
 
14742
+             return -1;
 
14743
+           count += sub_count;
 
14744
+         }
 
14745
+
 
14746
+       /* There must be no padding.  */
 
14747
+       if (!host_integerp (TYPE_SIZE (type), 1)
 
14748
+           || (tree_low_cst (TYPE_SIZE (type), 1)
 
14749
+               != count * GET_MODE_BITSIZE (*modep)))
 
14750
+         return -1;
 
14751
+
 
14752
+       return count;
 
14753
+      }
 
14754
+
 
14755
+    case UNION_TYPE:
 
14756
+    case QUAL_UNION_TYPE:
 
14757
+      {
 
14758
+       /* These aren't very interesting except in a degenerate case.  */
 
14759
+       int count = 0;
 
14760
+       int sub_count;
 
14761
+       tree field;
 
14762
+
 
14763
+       /* Can't handle incomplete types.  */
 
14764
+       if (!COMPLETE_TYPE_P (type))
 
14765
+         return -1;
 
14766
+
 
14767
+       for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
 
14768
+         {
 
14769
+           if (TREE_CODE (field) != FIELD_DECL)
 
14770
+             continue;
 
14771
+
 
14772
+           sub_count = rs6000_aggregate_candidate (TREE_TYPE (field), modep);
 
14773
+           if (sub_count < 0)
 
14774
+             return -1;
 
14775
+           count = count > sub_count ? count : sub_count;
 
14776
+         }
 
14777
+
 
14778
+       /* There must be no padding.  */
 
14779
+       if (!host_integerp (TYPE_SIZE (type), 1)
 
14780
+           || (tree_low_cst (TYPE_SIZE (type), 1)
 
14781
+               != count * GET_MODE_BITSIZE (*modep)))
 
14782
+         return -1;
 
14783
+
 
14784
+       return count;
 
14785
+      }
 
14786
+
 
14787
+    default:
 
14788
+      break;
 
14789
+    }
 
14790
+
 
14791
+  return -1;
 
14792
+}
 
14793
+
 
14794
+/* If an argument, whose type is described by TYPE and MODE, is a homogeneous
 
14795
+   float or vector aggregate that shall be passed in FP/vector registers
 
14796
+   according to the ELFv2 ABI, return the homogeneous element mode in
 
14797
+   *ELT_MODE and the number of elements in *N_ELTS, and return TRUE.
 
14798
+
 
14799
+   Otherwise, set *ELT_MODE to MODE and *N_ELTS to 1, and return FALSE.  */
 
14800
+
 
14801
+static bool
 
14802
+rs6000_discover_homogeneous_aggregate (enum machine_mode mode, const_tree type,
 
14803
+                                      enum machine_mode *elt_mode,
 
14804
+                                      int *n_elts)
 
14805
+{
 
14806
+  /* Note that we do not accept complex types at the top level as
 
14807
+     homogeneous aggregates; these types are handled via the
 
14808
+     targetm.calls.split_complex_arg mechanism.  Complex types
 
14809
+     can be elements of homogeneous aggregates, however.  */
 
14810
+  if (DEFAULT_ABI == ABI_ELFv2 && type && AGGREGATE_TYPE_P (type))
 
14811
+    {
 
14812
+      enum machine_mode field_mode = VOIDmode;
 
14813
+      int field_count = rs6000_aggregate_candidate (type, &field_mode);
 
14814
+
 
14815
+      if (field_count > 0)
 
14816
+       {
 
14817
+         int n_regs = (SCALAR_FLOAT_MODE_P (field_mode)?
 
14818
+                       (GET_MODE_SIZE (field_mode) + 7) >> 3 : 1);
 
14819
+
 
14820
+         /* The ELFv2 ABI allows homogeneous aggregates to occupy
 
14821
+            up to AGGR_ARG_NUM_REG registers.  */
 
14822
+         if (field_count * n_regs <= AGGR_ARG_NUM_REG)
 
14823
+           {
 
14824
+             if (elt_mode)
 
14825
+               *elt_mode = field_mode;
 
14826
+             if (n_elts)
 
14827
+               *n_elts = field_count;
 
14828
+             return true;
 
14829
+           }
 
14830
+       }
 
14831
+    }
 
14832
+
 
14833
+  if (elt_mode)
 
14834
+    *elt_mode = mode;
 
14835
+  if (n_elts)
 
14836
+    *n_elts = 1;
 
14837
+  return false;
 
14838
+}
 
14839
+
 
14840
 /* Return a nonzero value to say to return the function value in
 
14841
    memory, just as large structures are always returned.  TYPE will be
 
14842
    the data type of the value, and FNTYPE will be the type of the
 
14843
@@ -7491,6 +8653,16 @@
 
14844
       /* Otherwise fall through to more conventional ABI rules.  */
 
14845
     }
 
14846
 
 
14847
+  /* The ELFv2 ABI returns homogeneous VFP aggregates in registers */
 
14848
+  if (rs6000_discover_homogeneous_aggregate (TYPE_MODE (type), type,
 
14849
+                                            NULL, NULL))
 
14850
+    return false;
 
14851
+
 
14852
+  /* The ELFv2 ABI returns aggregates up to 16B in registers */
 
14853
+  if (DEFAULT_ABI == ABI_ELFv2 && AGGREGATE_TYPE_P (type)
 
14854
+      && (unsigned HOST_WIDE_INT) int_size_in_bytes (type) <= 16)
 
14855
+    return false;
 
14856
+
 
14857
   if (AGGREGATE_TYPE_P (type)
 
14858
       && (aix_struct_return
 
14859
          || (unsigned HOST_WIDE_INT) int_size_in_bytes (type) > 8))
 
14860
@@ -7522,6 +8694,19 @@
 
14861
   return false;
 
14862
 }
 
14863
 
 
14864
+/* Specify whether values returned in registers should be at the most
 
14865
+   significant end of a register.  We want aggregates returned by
 
14866
+   value to match the way aggregates are passed to functions.  */
 
14867
+
 
14868
+static bool
 
14869
+rs6000_return_in_msb (const_tree valtype)
 
14870
+{
 
14871
+  return (DEFAULT_ABI == ABI_ELFv2
 
14872
+         && BYTES_BIG_ENDIAN
 
14873
+         && AGGREGATE_TYPE_P (valtype)
 
14874
+         && FUNCTION_ARG_PADDING (TYPE_MODE (valtype), valtype) == upward);
 
14875
+}
 
14876
+
 
14877
 #ifdef HAVE_AS_GNU_ATTRIBUTE
 
14878
 /* Return TRUE if a call to function FNDECL may be one that
 
14879
    potentially affects the function calling ABI of the object file.  */
 
14880
@@ -7658,7 +8843,7 @@
 
14881
 static bool
 
14882
 rs6000_must_pass_in_stack (enum machine_mode mode, const_tree type)
 
14883
 {
 
14884
-  if (DEFAULT_ABI == ABI_AIX || TARGET_64BIT)
 
14885
+  if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2 || TARGET_64BIT)
 
14886
     return must_pass_in_stack_var_size (mode, type);
 
14887
   else
 
14888
     return must_pass_in_stack_var_size_or_pad (mode, type);
 
14889
@@ -7739,6 +8924,11 @@
 
14890
 static unsigned int
 
14891
 rs6000_function_arg_boundary (enum machine_mode mode, const_tree type)
 
14892
 {
 
14893
+  enum machine_mode elt_mode;
 
14894
+  int n_elts;
 
14895
+
 
14896
+  rs6000_discover_homogeneous_aggregate (mode, type, &elt_mode, &n_elts);
 
14897
+
 
14898
   if (DEFAULT_ABI == ABI_V4
 
14899
       && (GET_MODE_SIZE (mode) == 8
 
14900
          || (TARGET_HARD_FLOAT
 
14901
@@ -7750,12 +8940,13 @@
 
14902
               && int_size_in_bytes (type) >= 8
 
14903
               && int_size_in_bytes (type) < 16))
 
14904
     return 64;
 
14905
-  else if (ALTIVEC_OR_VSX_VECTOR_MODE (mode)
 
14906
+  else if (ALTIVEC_OR_VSX_VECTOR_MODE (elt_mode)
 
14907
           || (type && TREE_CODE (type) == VECTOR_TYPE
 
14908
               && int_size_in_bytes (type) >= 16))
 
14909
     return 128;
 
14910
-  else if (TARGET_MACHO
 
14911
-          && rs6000_darwin64_abi
 
14912
+  else if (((TARGET_MACHO && rs6000_darwin64_abi)
 
14913
+           || DEFAULT_ABI == ABI_ELFv2
 
14914
+            || (DEFAULT_ABI == ABI_AIX && !rs6000_compat_align_parm))
 
14915
           && mode == BLKmode
 
14916
           && type && TYPE_ALIGN (type) > 64)
 
14917
     return 128;
 
14918
@@ -7763,6 +8954,16 @@
 
14919
     return PARM_BOUNDARY;
 
14920
 }
 
14921
 
 
14922
+/* The offset in words to the start of the parameter save area.  */
 
14923
+
 
14924
+static unsigned int
 
14925
+rs6000_parm_offset (void)
 
14926
+{
 
14927
+  return (DEFAULT_ABI == ABI_V4 ? 2
 
14928
+         : DEFAULT_ABI == ABI_ELFv2 ? 4
 
14929
+         : 6);
 
14930
+}
 
14931
+
 
14932
 /* For a function parm of MODE and TYPE, return the starting word in
 
14933
    the parameter area.  NWORDS of the parameter area are already used.  */
 
14934
 
 
14935
@@ -7771,11 +8972,9 @@
 
14936
                   unsigned int nwords)
 
14937
 {
 
14938
   unsigned int align;
 
14939
-  unsigned int parm_offset;
 
14940
 
 
14941
   align = rs6000_function_arg_boundary (mode, type) / PARM_BOUNDARY - 1;
 
14942
-  parm_offset = DEFAULT_ABI == ABI_V4 ? 2 : 6;
 
14943
-  return nwords + (-(parm_offset + nwords) & align);
 
14944
+  return nwords + (-(rs6000_parm_offset () + nwords) & align);
 
14945
 }
 
14946
 
 
14947
 /* Compute the size (in words) of a function argument.  */
 
14948
@@ -7882,7 +9081,7 @@
 
14949
 
 
14950
        if (TREE_CODE (ftype) == RECORD_TYPE)
 
14951
          rs6000_darwin64_record_arg_advance_recurse (cum, ftype, bitpos);
 
14952
-       else if (USE_FP_FOR_ARG_P (cum, mode, ftype))
 
14953
+       else if (USE_FP_FOR_ARG_P (cum, mode))
 
14954
          {
 
14955
            unsigned n_fpregs = (GET_MODE_SIZE (mode) + 7) >> 3;
 
14956
            rs6000_darwin64_record_arg_advance_flush (cum, bitpos, 0);
 
14957
@@ -7923,7 +9122,7 @@
 
14958
            else
 
14959
              cum->words += n_fpregs;
 
14960
          }
 
14961
-       else if (USE_ALTIVEC_FOR_ARG_P (cum, mode, type, 1))
 
14962
+       else if (USE_ALTIVEC_FOR_ARG_P (cum, mode, 1))
 
14963
          {
 
14964
            rs6000_darwin64_record_arg_advance_flush (cum, bitpos, 0);
 
14965
            cum->vregno++;
 
14966
@@ -7960,6 +9159,11 @@
 
14967
 rs6000_function_arg_advance_1 (CUMULATIVE_ARGS *cum, enum machine_mode mode,
 
14968
                               const_tree type, bool named, int depth)
 
14969
 {
 
14970
+  enum machine_mode elt_mode;
 
14971
+  int n_elts;
 
14972
+
 
14973
+  rs6000_discover_homogeneous_aggregate (mode, type, &elt_mode, &n_elts);
 
14974
+
 
14975
   /* Only tick off an argument if we're not recursing.  */
 
14976
   if (depth == 0)
 
14977
     cum->nargs_prototype--;
 
14978
@@ -7980,15 +9184,16 @@
 
14979
 #endif
 
14980
 
 
14981
   if (TARGET_ALTIVEC_ABI
 
14982
-      && (ALTIVEC_OR_VSX_VECTOR_MODE (mode)
 
14983
+      && (ALTIVEC_OR_VSX_VECTOR_MODE (elt_mode)
 
14984
          || (type && TREE_CODE (type) == VECTOR_TYPE
 
14985
              && int_size_in_bytes (type) == 16)))
 
14986
     {
 
14987
       bool stack = false;
 
14988
 
 
14989
-      if (USE_ALTIVEC_FOR_ARG_P (cum, mode, type, named))
 
14990
+      if (USE_ALTIVEC_FOR_ARG_P (cum, elt_mode, named))
 
14991
        {
 
14992
-         cum->vregno++;
 
14993
+         cum->vregno += n_elts;
 
14994
+
 
14995
          if (!TARGET_ALTIVEC)
 
14996
            error ("cannot pass argument in vector register because"
 
14997
                   " altivec instructions are disabled, use -maltivec"
 
14998
@@ -7997,7 +9202,8 @@
 
14999
          /* PowerPC64 Linux and AIX allocate GPRs for a vector argument
 
15000
             even if it is going to be passed in a vector register.
 
15001
             Darwin does the same for variable-argument functions.  */
 
15002
-         if ((DEFAULT_ABI == ABI_AIX && TARGET_64BIT)
 
15003
+         if (((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
15004
+              && TARGET_64BIT)
 
15005
              || (cum->stdarg && DEFAULT_ABI != ABI_V4))
 
15006
            stack = true;
 
15007
        }
 
15008
@@ -8008,15 +9214,13 @@
 
15009
        {
 
15010
          int align;
 
15011
 
 
15012
-         /* Vector parameters must be 16-byte aligned.  This places
 
15013
-            them at 2 mod 4 in terms of words in 32-bit mode, since
 
15014
-            the parameter save area starts at offset 24 from the
 
15015
-            stack.  In 64-bit mode, they just have to start on an
 
15016
-            even word, since the parameter save area is 16-byte
 
15017
-            aligned.  Space for GPRs is reserved even if the argument
 
15018
-            will be passed in memory.  */
 
15019
+         /* Vector parameters must be 16-byte aligned.  In 32-bit
 
15020
+            mode this means we need to take into account the offset
 
15021
+            to the parameter save area.  In 64-bit mode, they just
 
15022
+            have to start on an even word, since the parameter save
 
15023
+            area is 16-byte aligned.  */
 
15024
          if (TARGET_32BIT)
 
15025
-           align = (2 - cum->words) & 3;
 
15026
+           align = -(rs6000_parm_offset () + cum->words) & 3;
 
15027
          else
 
15028
            align = cum->words & 1;
 
15029
          cum->words += align + rs6000_arg_size (mode, type);
 
15030
@@ -8141,15 +9345,15 @@
 
15031
 
 
15032
       cum->words = align_words + n_words;
 
15033
 
 
15034
-      if (SCALAR_FLOAT_MODE_P (mode)
 
15035
+      if (SCALAR_FLOAT_MODE_P (elt_mode)
 
15036
          && TARGET_HARD_FLOAT && TARGET_FPRS)
 
15037
        {
 
15038
          /* _Decimal128 must be passed in an even/odd float register pair.
 
15039
             This assumes that the register number is odd when fregno is
 
15040
             odd.  */
 
15041
-         if (mode == TDmode && (cum->fregno % 2) == 1)
 
15042
+         if (elt_mode == TDmode && (cum->fregno % 2) == 1)
 
15043
            cum->fregno++;
 
15044
-         cum->fregno += (GET_MODE_SIZE (mode) + 7) >> 3;
 
15045
+         cum->fregno += n_elts * ((GET_MODE_SIZE (elt_mode) + 7) >> 3);
 
15046
        }
 
15047
 
 
15048
       if (TARGET_DEBUG_ARG)
 
15049
@@ -8359,7 +9563,7 @@
 
15050
 
 
15051
        if (TREE_CODE (ftype) == RECORD_TYPE)
 
15052
          rs6000_darwin64_record_arg_recurse (cum, ftype, bitpos, rvec, k);
 
15053
-       else if (cum->named && USE_FP_FOR_ARG_P (cum, mode, ftype))
 
15054
+       else if (cum->named && USE_FP_FOR_ARG_P (cum, mode))
 
15055
          {
 
15056
            unsigned n_fpreg = (GET_MODE_SIZE (mode) + 7) >> 3;
 
15057
 #if 0
 
15058
@@ -8387,7 +9591,7 @@
 
15059
            if (mode == TFmode || mode == TDmode)
 
15060
              cum->fregno++;
 
15061
          }
 
15062
-       else if (cum->named && USE_ALTIVEC_FOR_ARG_P (cum, mode, ftype, 1))
 
15063
+       else if (cum->named && USE_ALTIVEC_FOR_ARG_P (cum, mode, 1))
 
15064
          {
 
15065
            rs6000_darwin64_record_arg_flush (cum, bitpos, rvec, k);
 
15066
            rvec[(*k)++]
 
15067
@@ -8504,6 +9708,84 @@
 
15068
   return gen_rtx_PARALLEL (mode, gen_rtvec_v (k, rvec));
 
15069
 }
 
15070
 
 
15071
+/* We have an argument of MODE and TYPE that goes into FPRs or VRs,
 
15072
+   but must also be copied into the parameter save area starting at
 
15073
+   offset ALIGN_WORDS.  Fill in RVEC with the elements corresponding
 
15074
+   to the GPRs and/or memory.  Return the number of elements used.  */
 
15075
+
 
15076
+static int
 
15077
+rs6000_psave_function_arg (enum machine_mode mode, const_tree type,
 
15078
+                          int align_words, rtx *rvec)
 
15079
+{
 
15080
+  int k = 0;
 
15081
+
 
15082
+  if (align_words < GP_ARG_NUM_REG)
 
15083
+    {
 
15084
+      int n_words = rs6000_arg_size (mode, type);
 
15085
+
 
15086
+      if (align_words + n_words > GP_ARG_NUM_REG
 
15087
+         || mode == BLKmode
 
15088
+         || (TARGET_32BIT && TARGET_POWERPC64))
 
15089
+       {
 
15090
+         /* If this is partially on the stack, then we only
 
15091
+            include the portion actually in registers here.  */
 
15092
+         enum machine_mode rmode = TARGET_32BIT ? SImode : DImode;
 
15093
+         int i = 0;
 
15094
+
 
15095
+         if (align_words + n_words > GP_ARG_NUM_REG)
 
15096
+           {
 
15097
+             /* Not all of the arg fits in gprs.  Say that it goes in memory
 
15098
+                too, using a magic NULL_RTX component.  Also see comment in
 
15099
+                rs6000_mixed_function_arg for why the normal
 
15100
+                function_arg_partial_nregs scheme doesn't work in this case. */
 
15101
+             rvec[k++] = gen_rtx_EXPR_LIST (VOIDmode, NULL_RTX, const0_rtx);
 
15102
+           }
 
15103
+
 
15104
+         do
 
15105
+           {
 
15106
+             rtx r = gen_rtx_REG (rmode, GP_ARG_MIN_REG + align_words);
 
15107
+             rtx off = GEN_INT (i++ * GET_MODE_SIZE (rmode));
 
15108
+             rvec[k++] = gen_rtx_EXPR_LIST (VOIDmode, r, off);
 
15109
+           }
 
15110
+         while (++align_words < GP_ARG_NUM_REG && --n_words != 0);
 
15111
+       }
 
15112
+      else
 
15113
+       {
 
15114
+         /* The whole arg fits in gprs.  */
 
15115
+         rtx r = gen_rtx_REG (mode, GP_ARG_MIN_REG + align_words);
 
15116
+         rvec[k++] = gen_rtx_EXPR_LIST (VOIDmode, r, const0_rtx);
 
15117
+       }
 
15118
+    }
 
15119
+  else
 
15120
+    {
 
15121
+      /* It's entirely in memory.  */
 
15122
+      rvec[k++] = gen_rtx_EXPR_LIST (VOIDmode, NULL_RTX, const0_rtx);
 
15123
+    }
 
15124
+
 
15125
+  return k;
 
15126
+}
 
15127
+
 
15128
+/* RVEC is a vector of K components of an argument of mode MODE.
 
15129
+   Construct the final function_arg return value from it.  */
 
15130
+
 
15131
+static rtx
 
15132
+rs6000_finish_function_arg (enum machine_mode mode, rtx *rvec, int k)
 
15133
+{
 
15134
+  gcc_assert (k >= 1);
 
15135
+
 
15136
+  /* Avoid returning a PARALLEL in the trivial cases.  */
 
15137
+  if (k == 1)
 
15138
+    {
 
15139
+      if (XEXP (rvec[0], 0) == NULL_RTX)
 
15140
+       return NULL_RTX;
 
15141
+
 
15142
+      if (GET_MODE (XEXP (rvec[0], 0)) == mode)
 
15143
+       return XEXP (rvec[0], 0);
 
15144
+    }
 
15145
+
 
15146
+  return gen_rtx_PARALLEL (mode, gen_rtvec_v (k, rvec));
 
15147
+}
 
15148
+
 
15149
 /* Determine where to put an argument to a function.
 
15150
    Value is zero to push the argument on the stack,
 
15151
    or a hard register in which to store the argument.
 
15152
@@ -8538,6 +9820,8 @@
 
15153
 {
 
15154
   CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v);
 
15155
   enum rs6000_abi abi = DEFAULT_ABI;
 
15156
+  enum machine_mode elt_mode;
 
15157
+  int n_elts;
 
15158
 
 
15159
   /* Return a marker to indicate whether CR1 needs to set or clear the
 
15160
      bit that V.4 uses to say fp args were passed in registers.
 
15161
@@ -8564,6 +9848,8 @@
 
15162
       return GEN_INT (cum->call_cookie & ~CALL_LIBCALL);
 
15163
     }
 
15164
 
 
15165
+  rs6000_discover_homogeneous_aggregate (mode, type, &elt_mode, &n_elts);
 
15166
+
 
15167
   if (TARGET_MACHO && rs6000_darwin64_struct_check_p (mode, type))
 
15168
     {
 
15169
       rtx rslt = rs6000_darwin64_record_arg (cum, type, named, /*retval= */false);
 
15170
@@ -8572,33 +9858,30 @@
 
15171
       /* Else fall through to usual handling.  */
 
15172
     }
 
15173
 
 
15174
-  if (USE_ALTIVEC_FOR_ARG_P (cum, mode, type, named))
 
15175
-    if (TARGET_64BIT && ! cum->prototype)
 
15176
-      {
 
15177
-       /* Vector parameters get passed in vector register
 
15178
-          and also in GPRs or memory, in absence of prototype.  */
 
15179
-       int align_words;
 
15180
-       rtx slot;
 
15181
-       align_words = (cum->words + 1) & ~1;
 
15182
+  if (USE_ALTIVEC_FOR_ARG_P (cum, elt_mode, named))
 
15183
+    {
 
15184
+      rtx rvec[GP_ARG_NUM_REG + AGGR_ARG_NUM_REG + 1];
 
15185
+      rtx r, off;
 
15186
+      int i, k = 0;
 
15187
 
 
15188
-       if (align_words >= GP_ARG_NUM_REG)
 
15189
-         {
 
15190
-           slot = NULL_RTX;
 
15191
-         }
 
15192
-       else
 
15193
-         {
 
15194
-           slot = gen_rtx_REG (mode, GP_ARG_MIN_REG + align_words);
 
15195
-         }
 
15196
-       return gen_rtx_PARALLEL (mode,
 
15197
-                gen_rtvec (2,
 
15198
-                           gen_rtx_EXPR_LIST (VOIDmode,
 
15199
-                                              slot, const0_rtx),
 
15200
-                           gen_rtx_EXPR_LIST (VOIDmode,
 
15201
-                                              gen_rtx_REG (mode, cum->vregno),
 
15202
-                                              const0_rtx)));
 
15203
-      }
 
15204
-    else
 
15205
-      return gen_rtx_REG (mode, cum->vregno);
 
15206
+      /* Do we also need to pass this argument in the parameter
 
15207
+        save area?  */
 
15208
+      if (TARGET_64BIT && ! cum->prototype)
 
15209
+       {
 
15210
+         int align_words = (cum->words + 1) & ~1;
 
15211
+         k = rs6000_psave_function_arg (mode, type, align_words, rvec);
 
15212
+       }
 
15213
+
 
15214
+      /* Describe where this argument goes in the vector registers.  */
 
15215
+      for (i = 0; i < n_elts && cum->vregno + i <= ALTIVEC_ARG_MAX_REG; i++)
 
15216
+       {
 
15217
+         r = gen_rtx_REG (elt_mode, cum->vregno + i);
 
15218
+         off = GEN_INT (i * GET_MODE_SIZE (elt_mode));
 
15219
+         rvec[k++] =  gen_rtx_EXPR_LIST (VOIDmode, r, off);
 
15220
+       }
 
15221
+
 
15222
+      return rs6000_finish_function_arg (mode, rvec, k);
 
15223
+    }
 
15224
   else if (TARGET_ALTIVEC_ABI
 
15225
           && (ALTIVEC_OR_VSX_VECTOR_MODE (mode)
 
15226
               || (type && TREE_CODE (type) == VECTOR_TYPE
 
15227
@@ -8613,13 +9896,13 @@
 
15228
          int align, align_words, n_words;
 
15229
          enum machine_mode part_mode;
 
15230
 
 
15231
-         /* Vector parameters must be 16-byte aligned.  This places them at
 
15232
-            2 mod 4 in terms of words in 32-bit mode, since the parameter
 
15233
-            save area starts at offset 24 from the stack.  In 64-bit mode,
 
15234
-            they just have to start on an even word, since the parameter
 
15235
-            save area is 16-byte aligned.  */
 
15236
+         /* Vector parameters must be 16-byte aligned.  In 32-bit
 
15237
+            mode this means we need to take into account the offset
 
15238
+            to the parameter save area.  In 64-bit mode, they just
 
15239
+            have to start on an even word, since the parameter save
 
15240
+            area is 16-byte aligned.  */
 
15241
          if (TARGET_32BIT)
 
15242
-           align = (2 - cum->words) & 3;
 
15243
+           align = -(rs6000_parm_offset () + cum->words) & 3;
 
15244
          else
 
15245
            align = cum->words & 1;
 
15246
          align_words = cum->words + align;
 
15247
@@ -8697,101 +9980,50 @@
 
15248
 
 
15249
       /* _Decimal128 must be passed in an even/odd float register pair.
 
15250
         This assumes that the register number is odd when fregno is odd.  */
 
15251
-      if (mode == TDmode && (cum->fregno % 2) == 1)
 
15252
+      if (elt_mode == TDmode && (cum->fregno % 2) == 1)
 
15253
        cum->fregno++;
 
15254
 
 
15255
-      if (USE_FP_FOR_ARG_P (cum, mode, type))
 
15256
+      if (USE_FP_FOR_ARG_P (cum, elt_mode))
 
15257
        {
 
15258
-         rtx rvec[GP_ARG_NUM_REG + 1];
 
15259
-         rtx r;
 
15260
-         int k;
 
15261
-         bool needs_psave;
 
15262
-         enum machine_mode fmode = mode;
 
15263
-         unsigned long n_fpreg = (GET_MODE_SIZE (mode) + 7) >> 3;
 
15264
+         rtx rvec[GP_ARG_NUM_REG + AGGR_ARG_NUM_REG + 1];
 
15265
+         rtx r, off;
 
15266
+         int i, k = 0;
 
15267
+         unsigned long n_fpreg = (GET_MODE_SIZE (elt_mode) + 7) >> 3;
 
15268
 
 
15269
-         if (cum->fregno + n_fpreg > FP_ARG_MAX_REG + 1)
 
15270
-           {
 
15271
-             /* Currently, we only ever need one reg here because complex
 
15272
-                doubles are split.  */
 
15273
-             gcc_assert (cum->fregno == FP_ARG_MAX_REG
 
15274
-                         && (fmode == TFmode || fmode == TDmode));
 
15275
+         /* Do we also need to pass this argument in the parameter
 
15276
+            save area?  */
 
15277
+         if (type && (cum->nargs_prototype <= 0
 
15278
+                      || ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
15279
+                          && TARGET_XL_COMPAT
 
15280
+                          && align_words >= GP_ARG_NUM_REG)))
 
15281
+           k = rs6000_psave_function_arg (mode, type, align_words, rvec);
 
15282
 
 
15283
-             /* Long double or _Decimal128 split over regs and memory.  */
 
15284
-             fmode = DECIMAL_FLOAT_MODE_P (fmode) ? DDmode : DFmode;
 
15285
-           }
 
15286
-
 
15287
-         /* Do we also need to pass this arg in the parameter save
 
15288
-            area?  */
 
15289
-         needs_psave = (type
 
15290
-                        && (cum->nargs_prototype <= 0
 
15291
-                            || (DEFAULT_ABI == ABI_AIX
 
15292
-                                && TARGET_XL_COMPAT
 
15293
-                                && align_words >= GP_ARG_NUM_REG)));
 
15294
-
 
15295
-         if (!needs_psave && mode == fmode)
 
15296
-           return gen_rtx_REG (fmode, cum->fregno);
 
15297
-
 
15298
-         k = 0;
 
15299
-         if (needs_psave)
 
15300
+         /* Describe where this argument goes in the fprs.  */
 
15301
+         for (i = 0; i < n_elts
 
15302
+                     && cum->fregno + i * n_fpreg <= FP_ARG_MAX_REG; i++)
 
15303
            {
 
15304
-             /* Describe the part that goes in gprs or the stack.
 
15305
-                This piece must come first, before the fprs.  */
 
15306
-             if (align_words < GP_ARG_NUM_REG)
 
15307
+             /* Check if the argument is split over registers and memory.
 
15308
+                This can only ever happen for long double or _Decimal128;
 
15309
+                complex types are handled via split_complex_arg.  */
 
15310
+             enum machine_mode fmode = elt_mode;
 
15311
+             if (cum->fregno + (i + 1) * n_fpreg > FP_ARG_MAX_REG + 1)
 
15312
                {
 
15313
-                 unsigned long n_words = rs6000_arg_size (mode, type);
 
15314
+                 gcc_assert (fmode == TFmode || fmode == TDmode);
 
15315
+                 fmode = DECIMAL_FLOAT_MODE_P (fmode) ? DDmode : DFmode;
 
15316
+               }
 
15317
 
 
15318
-                 if (align_words + n_words > GP_ARG_NUM_REG
 
15319
-                     || (TARGET_32BIT && TARGET_POWERPC64))
 
15320
-                   {
 
15321
-                     /* If this is partially on the stack, then we only
 
15322
-                        include the portion actually in registers here.  */
 
15323
-                     enum machine_mode rmode = TARGET_32BIT ? SImode : DImode;
 
15324
-                     rtx off;
 
15325
-                     int i = 0;
 
15326
-                     if (align_words + n_words > GP_ARG_NUM_REG)
 
15327
-                       /* Not all of the arg fits in gprs.  Say that it
 
15328
-                          goes in memory too, using a magic NULL_RTX
 
15329
-                          component.  Also see comment in
 
15330
-                          rs6000_mixed_function_arg for why the normal
 
15331
-                          function_arg_partial_nregs scheme doesn't work
 
15332
-                          in this case. */
 
15333
-                       rvec[k++] = gen_rtx_EXPR_LIST (VOIDmode, NULL_RTX,
 
15334
-                                                      const0_rtx);
 
15335
-                     do
 
15336
-                       {
 
15337
-                         r = gen_rtx_REG (rmode,
 
15338
-                                          GP_ARG_MIN_REG + align_words);
 
15339
-                         off = GEN_INT (i++ * GET_MODE_SIZE (rmode));
 
15340
-                         rvec[k++] = gen_rtx_EXPR_LIST (VOIDmode, r, off);
 
15341
-                       }
 
15342
-                     while (++align_words < GP_ARG_NUM_REG && --n_words != 0);
 
15343
-                   }
 
15344
-                 else
 
15345
-                   {
 
15346
-                     /* The whole arg fits in gprs.  */
 
15347
-                     r = gen_rtx_REG (mode, GP_ARG_MIN_REG + align_words);
 
15348
-                     rvec[k++] = gen_rtx_EXPR_LIST (VOIDmode, r, const0_rtx);
 
15349
-                   }
 
15350
-               }
 
15351
-             else
 
15352
-               /* It's entirely in memory.  */
 
15353
-               rvec[k++] = gen_rtx_EXPR_LIST (VOIDmode, NULL_RTX, const0_rtx);
 
15354
+             r = gen_rtx_REG (fmode, cum->fregno + i * n_fpreg);
 
15355
+             off = GEN_INT (i * GET_MODE_SIZE (elt_mode));
 
15356
+             rvec[k++] = gen_rtx_EXPR_LIST (VOIDmode, r, off);
 
15357
            }
 
15358
 
 
15359
-         /* Describe where this piece goes in the fprs.  */
 
15360
-         r = gen_rtx_REG (fmode, cum->fregno);
 
15361
-         rvec[k++] = gen_rtx_EXPR_LIST (VOIDmode, r, const0_rtx);
 
15362
-
 
15363
-         return gen_rtx_PARALLEL (mode, gen_rtvec_v (k, rvec));
 
15364
+         return rs6000_finish_function_arg (mode, rvec, k);
 
15365
        }
 
15366
       else if (align_words < GP_ARG_NUM_REG)
 
15367
        {
 
15368
          if (TARGET_32BIT && TARGET_POWERPC64)
 
15369
            return rs6000_mixed_function_arg (mode, type, align_words);
 
15370
 
 
15371
-         if (mode == BLKmode)
 
15372
-           mode = Pmode;
 
15373
-
 
15374
          return gen_rtx_REG (mode, GP_ARG_MIN_REG + align_words);
 
15375
        }
 
15376
       else
 
15377
@@ -8810,42 +10042,62 @@
 
15378
                          tree type, bool named)
 
15379
 {
 
15380
   CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v);
 
15381
+  bool passed_in_gprs = true;
 
15382
   int ret = 0;
 
15383
   int align_words;
 
15384
+  enum machine_mode elt_mode;
 
15385
+  int n_elts;
 
15386
 
 
15387
+  rs6000_discover_homogeneous_aggregate (mode, type, &elt_mode, &n_elts);
 
15388
+
 
15389
   if (DEFAULT_ABI == ABI_V4)
 
15390
     return 0;
 
15391
 
 
15392
-  if (USE_ALTIVEC_FOR_ARG_P (cum, mode, type, named)
 
15393
-      && cum->nargs_prototype >= 0)
 
15394
-    return 0;
 
15395
+  if (USE_ALTIVEC_FOR_ARG_P (cum, elt_mode, named))
 
15396
+    {
 
15397
+      /* If we are passing this arg in the fixed parameter save area
 
15398
+         (gprs or memory) as well as VRs, we do not use the partial
 
15399
+        bytes mechanism; instead, rs6000_function_arg will return a
 
15400
+        PARALLEL including a memory element as necessary.  */
 
15401
+      if (TARGET_64BIT && ! cum->prototype)
 
15402
+       return 0;
 
15403
 
 
15404
+      /* Otherwise, we pass in VRs only.  Check for partial copies.  */
 
15405
+      passed_in_gprs = false;
 
15406
+      if (cum->vregno + n_elts > ALTIVEC_ARG_MAX_REG + 1)
 
15407
+       ret = (ALTIVEC_ARG_MAX_REG + 1 - cum->vregno) * 16;
 
15408
+    }
 
15409
+
 
15410
   /* In this complicated case we just disable the partial_nregs code.  */
 
15411
   if (TARGET_MACHO && rs6000_darwin64_struct_check_p (mode, type))
 
15412
     return 0;
 
15413
 
 
15414
   align_words = rs6000_parm_start (mode, type, cum->words);
 
15415
 
 
15416
-  if (USE_FP_FOR_ARG_P (cum, mode, type))
 
15417
+  if (USE_FP_FOR_ARG_P (cum, elt_mode))
 
15418
     {
 
15419
+      unsigned long n_fpreg = (GET_MODE_SIZE (elt_mode) + 7) >> 3;
 
15420
+
 
15421
       /* If we are passing this arg in the fixed parameter save area
 
15422
-        (gprs or memory) as well as fprs, then this function should
 
15423
-        return the number of partial bytes passed in the parameter
 
15424
-        save area rather than partial bytes passed in fprs.  */
 
15425
+         (gprs or memory) as well as FPRs, we do not use the partial
 
15426
+        bytes mechanism; instead, rs6000_function_arg will return a
 
15427
+        PARALLEL including a memory element as necessary.  */
 
15428
       if (type
 
15429
          && (cum->nargs_prototype <= 0
 
15430
-             || (DEFAULT_ABI == ABI_AIX
 
15431
+             || ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
15432
                  && TARGET_XL_COMPAT
 
15433
                  && align_words >= GP_ARG_NUM_REG)))
 
15434
        return 0;
 
15435
-      else if (cum->fregno + ((GET_MODE_SIZE (mode) + 7) >> 3)
 
15436
-              > FP_ARG_MAX_REG + 1)
 
15437
-       ret = (FP_ARG_MAX_REG + 1 - cum->fregno) * 8;
 
15438
-      else if (cum->nargs_prototype >= 0)
 
15439
-       return 0;
 
15440
+
 
15441
+      /* Otherwise, we pass in FPRs only.  Check for partial copies.  */
 
15442
+      passed_in_gprs = false;
 
15443
+      if (cum->fregno + n_elts * n_fpreg > FP_ARG_MAX_REG + 1)
 
15444
+       ret = ((FP_ARG_MAX_REG + 1 - cum->fregno)
 
15445
+              * MIN (8, GET_MODE_SIZE (elt_mode)));
 
15446
     }
 
15447
 
 
15448
-  if (align_words < GP_ARG_NUM_REG
 
15449
+  if (passed_in_gprs
 
15450
+      && align_words < GP_ARG_NUM_REG
 
15451
       && GP_ARG_NUM_REG < align_words + rs6000_arg_size (mode, type))
 
15452
     ret = (GP_ARG_NUM_REG - align_words) * (TARGET_32BIT ? 4 : 8);
 
15453
 
 
15454
@@ -8926,6 +10178,139 @@
 
15455
   return 0;
 
15456
 }
 
15457
 
 
15458
+/* Process parameter of type TYPE after ARGS_SO_FAR parameters were
 
15459
+   already processes.  Return true if the parameter must be passed
 
15460
+   (fully or partially) on the stack.  */
 
15461
+
 
15462
+static bool
 
15463
+rs6000_parm_needs_stack (cumulative_args_t args_so_far, tree type)
 
15464
+{
 
15465
+  enum machine_mode mode;
 
15466
+  int unsignedp;
 
15467
+  rtx entry_parm;
 
15468
+
 
15469
+  /* Catch errors.  */
 
15470
+  if (type == NULL || type == error_mark_node)
 
15471
+    return true;
 
15472
+
 
15473
+  /* Handle types with no storage requirement.  */
 
15474
+  if (TYPE_MODE (type) == VOIDmode)
 
15475
+    return false;
 
15476
+
 
15477
+  /* Handle complex types.  */
 
15478
+  if (TREE_CODE (type) == COMPLEX_TYPE)
 
15479
+    return (rs6000_parm_needs_stack (args_so_far, TREE_TYPE (type))
 
15480
+           || rs6000_parm_needs_stack (args_so_far, TREE_TYPE (type)));
 
15481
+
 
15482
+  /* Handle transparent aggregates.  */
 
15483
+  if ((TREE_CODE (type) == UNION_TYPE || TREE_CODE (type) == RECORD_TYPE)
 
15484
+      && TYPE_TRANSPARENT_AGGR (type))
 
15485
+    type = TREE_TYPE (first_field (type));
 
15486
+
 
15487
+  /* See if this arg was passed by invisible reference.  */
 
15488
+  if (pass_by_reference (get_cumulative_args (args_so_far),
 
15489
+                        TYPE_MODE (type), type, true))
 
15490
+    type = build_pointer_type (type);
 
15491
+
 
15492
+  /* Find mode as it is passed by the ABI.  */
 
15493
+  unsignedp = TYPE_UNSIGNED (type);
 
15494
+  mode = promote_mode (type, TYPE_MODE (type), &unsignedp);
 
15495
+
 
15496
+  /* If we must pass in stack, we need a stack.  */
 
15497
+  if (rs6000_must_pass_in_stack (mode, type))
 
15498
+    return true;
 
15499
+
 
15500
+  /* If there is no incoming register, we need a stack.  */
 
15501
+  entry_parm = rs6000_function_arg (args_so_far, mode, type, true);
 
15502
+  if (entry_parm == NULL)
 
15503
+    return true;
 
15504
+
 
15505
+  /* Likewise if we need to pass both in registers and on the stack.  */
 
15506
+  if (GET_CODE (entry_parm) == PARALLEL
 
15507
+      && XEXP (XVECEXP (entry_parm, 0, 0), 0) == NULL_RTX)
 
15508
+    return true;
 
15509
+
 
15510
+  /* Also true if we're partially in registers and partially not.  */
 
15511
+  if (rs6000_arg_partial_bytes (args_so_far, mode, type, true) != 0)
 
15512
+    return true;
 
15513
+
 
15514
+  /* Update info on where next arg arrives in registers.  */
 
15515
+  rs6000_function_arg_advance (args_so_far, mode, type, true);
 
15516
+  return false;
 
15517
+}
 
15518
+
 
15519
+/* Return true if FUN has no prototype, has a variable argument
 
15520
+   list, or passes any parameter in memory.  */
 
15521
+
 
15522
+static bool
 
15523
+rs6000_function_parms_need_stack (tree fun)
 
15524
+{
 
15525
+  function_args_iterator args_iter;
 
15526
+  tree arg_type;
 
15527
+  CUMULATIVE_ARGS args_so_far_v;
 
15528
+  cumulative_args_t args_so_far;
 
15529
+
 
15530
+  if (!fun)
 
15531
+    /* Must be a libcall, all of which only use reg parms.  */
 
15532
+    return false;
 
15533
+  if (!TYPE_P (fun))
 
15534
+    fun = TREE_TYPE (fun);
 
15535
+
 
15536
+  /* Varargs functions need the parameter save area.  */
 
15537
+  if (!prototype_p (fun) || stdarg_p (fun))
 
15538
+    return true;
 
15539
+
 
15540
+  INIT_CUMULATIVE_INCOMING_ARGS (args_so_far_v, fun, NULL_RTX);
 
15541
+  args_so_far = pack_cumulative_args (&args_so_far_v);
 
15542
+
 
15543
+  if (aggregate_value_p (TREE_TYPE (fun), fun))
 
15544
+    {
 
15545
+      tree type = build_pointer_type (TREE_TYPE (fun));
 
15546
+      rs6000_parm_needs_stack (args_so_far, type);
 
15547
+    }
 
15548
+
 
15549
+  FOREACH_FUNCTION_ARGS (fun, arg_type, args_iter)
 
15550
+    if (rs6000_parm_needs_stack (args_so_far, arg_type))
 
15551
+      return true;
 
15552
+
 
15553
+  return false;
 
15554
+}
 
15555
+
 
15556
+/* Return the size of the REG_PARM_STACK_SPACE are for FUN.  This is
 
15557
+   usually a constant depending on the ABI.  However, in the ELFv2 ABI
 
15558
+   the register parameter area is optional when calling a function that
 
15559
+   has a prototype is scope, has no variable argument list, and passes
 
15560
+   all parameters in registers.  */
 
15561
+
 
15562
+int
 
15563
+rs6000_reg_parm_stack_space (tree fun)
 
15564
+{
 
15565
+  int reg_parm_stack_space;
 
15566
+
 
15567
+  switch (DEFAULT_ABI)
 
15568
+    {
 
15569
+    default:
 
15570
+      reg_parm_stack_space = 0;
 
15571
+      break;
 
15572
+
 
15573
+    case ABI_AIX:
 
15574
+    case ABI_DARWIN:
 
15575
+      reg_parm_stack_space = TARGET_64BIT ? 64 : 32;
 
15576
+      break;
 
15577
+
 
15578
+    case ABI_ELFv2:
 
15579
+      /* ??? Recomputing this every time is a bit expensive.  Is there
 
15580
+        a place to cache this information?  */
 
15581
+      if (rs6000_function_parms_need_stack (fun))
 
15582
+       reg_parm_stack_space = TARGET_64BIT ? 64 : 32;
 
15583
+      else
 
15584
+       reg_parm_stack_space = 0;
 
15585
+      break;
 
15586
+    }
 
15587
+
 
15588
+  return reg_parm_stack_space;
 
15589
+}
 
15590
+
 
15591
 static void
 
15592
 rs6000_move_block_from_reg (int regno, rtx x, int nregs)
 
15593
 {
 
15594
@@ -9307,8 +10692,10 @@
 
15595
      We don't need to check for pass-by-reference because of the test above.
 
15596
      We can return a simplifed answer, since we know there's no offset to add.  */
 
15597
 
 
15598
-  if (TARGET_MACHO
 
15599
-      && rs6000_darwin64_abi 
 
15600
+  if (((TARGET_MACHO
 
15601
+        && rs6000_darwin64_abi)
 
15602
+       || DEFAULT_ABI == ABI_ELFv2
 
15603
+       || (DEFAULT_ABI == ABI_AIX && !rs6000_compat_align_parm))
 
15604
       && integer_zerop (TYPE_SIZE (type)))
 
15605
     {
 
15606
       unsigned HOST_WIDE_INT align, boundary;
 
15607
@@ -9603,6 +10990,7 @@
 
15608
 #undef RS6000_BUILTIN_A
 
15609
 #undef RS6000_BUILTIN_D
 
15610
 #undef RS6000_BUILTIN_E
 
15611
+#undef RS6000_BUILTIN_H
 
15612
 #undef RS6000_BUILTIN_P
 
15613
 #undef RS6000_BUILTIN_Q
 
15614
 #undef RS6000_BUILTIN_S
 
15615
@@ -9616,6 +11004,7 @@
 
15616
 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE)
 
15617
 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE)
 
15618
 #define RS6000_BUILTIN_E(ENUM, NAME, MASK, ATTR, ICODE)
 
15619
+#define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)
 
15620
 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)
 
15621
 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE)
 
15622
 #define RS6000_BUILTIN_S(ENUM, NAME, MASK, ATTR, ICODE)
 
15623
@@ -9634,6 +11023,7 @@
 
15624
 #undef RS6000_BUILTIN_A
 
15625
 #undef RS6000_BUILTIN_D
 
15626
 #undef RS6000_BUILTIN_E
 
15627
+#undef RS6000_BUILTIN_H
 
15628
 #undef RS6000_BUILTIN_P
 
15629
 #undef RS6000_BUILTIN_Q
 
15630
 #undef RS6000_BUILTIN_S
 
15631
@@ -9647,6 +11037,7 @@
 
15632
   { MASK, ICODE, NAME, ENUM },
 
15633
 
 
15634
 #define RS6000_BUILTIN_E(ENUM, NAME, MASK, ATTR, ICODE)
 
15635
+#define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)
 
15636
 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)
 
15637
 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE)
 
15638
 #define RS6000_BUILTIN_S(ENUM, NAME, MASK, ATTR, ICODE)
 
15639
@@ -9665,6 +11056,7 @@
 
15640
 #undef RS6000_BUILTIN_A
 
15641
 #undef RS6000_BUILTIN_D
 
15642
 #undef RS6000_BUILTIN_E
 
15643
+#undef RS6000_BUILTIN_H
 
15644
 #undef RS6000_BUILTIN_P
 
15645
 #undef RS6000_BUILTIN_Q
 
15646
 #undef RS6000_BUILTIN_S
 
15647
@@ -9678,6 +11070,7 @@
 
15648
 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE)
 
15649
 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE)
 
15650
 #define RS6000_BUILTIN_E(ENUM, NAME, MASK, ATTR, ICODE)
 
15651
+#define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)
 
15652
 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)
 
15653
 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE)
 
15654
 #define RS6000_BUILTIN_S(ENUM, NAME, MASK, ATTR, ICODE)
 
15655
@@ -9694,6 +11087,7 @@
 
15656
 #undef RS6000_BUILTIN_A
 
15657
 #undef RS6000_BUILTIN_D
 
15658
 #undef RS6000_BUILTIN_E
 
15659
+#undef RS6000_BUILTIN_H
 
15660
 #undef RS6000_BUILTIN_P
 
15661
 #undef RS6000_BUILTIN_Q
 
15662
 #undef RS6000_BUILTIN_S
 
15663
@@ -9705,6 +11099,7 @@
 
15664
 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE)
 
15665
 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE)
 
15666
 #define RS6000_BUILTIN_E(ENUM, NAME, MASK, ATTR, ICODE)
 
15667
+#define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)
 
15668
 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE) \
 
15669
   { MASK, ICODE, NAME, ENUM },
 
15670
 
 
15671
@@ -9726,6 +11121,7 @@
 
15672
 #undef RS6000_BUILTIN_A
 
15673
 #undef RS6000_BUILTIN_D
 
15674
 #undef RS6000_BUILTIN_E
 
15675
+#undef RS6000_BUILTIN_H
 
15676
 #undef RS6000_BUILTIN_P
 
15677
 #undef RS6000_BUILTIN_Q
 
15678
 #undef RS6000_BUILTIN_S
 
15679
@@ -9737,6 +11133,7 @@
 
15680
 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE)
 
15681
 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE)
 
15682
 #define RS6000_BUILTIN_E(ENUM, NAME, MASK, ATTR, ICODE)
 
15683
+#define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)
 
15684
 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)
 
15685
 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE)
 
15686
 #define RS6000_BUILTIN_S(ENUM, NAME, MASK, ATTR, ICODE) \
 
15687
@@ -9756,6 +11153,7 @@
 
15688
 #undef RS6000_BUILTIN_A
 
15689
 #undef RS6000_BUILTIN_D
 
15690
 #undef RS6000_BUILTIN_E
 
15691
+#undef RS6000_BUILTIN_H
 
15692
 #undef RS6000_BUILTIN_P
 
15693
 #undef RS6000_BUILTIN_Q
 
15694
 #undef RS6000_BUILTIN_S
 
15695
@@ -9769,6 +11167,7 @@
 
15696
 #define RS6000_BUILTIN_E(ENUM, NAME, MASK, ATTR, ICODE) \
 
15697
   { MASK, ICODE, NAME, ENUM },
 
15698
 
 
15699
+#define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)
 
15700
 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)
 
15701
 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE)
 
15702
 #define RS6000_BUILTIN_S(ENUM, NAME, MASK, ATTR, ICODE)
 
15703
@@ -9786,6 +11185,7 @@
 
15704
 #undef RS6000_BUILTIN_A
 
15705
 #undef RS6000_BUILTIN_D
 
15706
 #undef RS6000_BUILTIN_E
 
15707
+#undef RS6000_BUILTIN_H
 
15708
 #undef RS6000_BUILTIN_P
 
15709
 #undef RS6000_BUILTIN_Q
 
15710
 #undef RS6000_BUILTIN_S
 
15711
@@ -9797,6 +11197,7 @@
 
15712
 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE)
 
15713
 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE)
 
15714
 #define RS6000_BUILTIN_E(ENUM, NAME, MASK, ATTR, ICODE)
 
15715
+#define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)
 
15716
 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)
 
15717
 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE) \
 
15718
   { MASK, ICODE, NAME, ENUM },
 
15719
@@ -9817,6 +11218,7 @@
 
15720
 #undef RS6000_BUILTIN_A
 
15721
 #undef RS6000_BUILTIN_D
 
15722
 #undef RS6000_BUILTIN_E
 
15723
+#undef RS6000_BUILTIN_H
 
15724
 #undef RS6000_BUILTIN_P
 
15725
 #undef RS6000_BUILTIN_Q
 
15726
 #undef RS6000_BUILTIN_S
 
15727
@@ -9830,6 +11232,7 @@
 
15728
 
 
15729
 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE)
 
15730
 #define RS6000_BUILTIN_E(ENUM, NAME, MASK, ATTR, ICODE)
 
15731
+#define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)
 
15732
 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)
 
15733
 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE)
 
15734
 #define RS6000_BUILTIN_S(ENUM, NAME, MASK, ATTR, ICODE)
 
15735
@@ -9847,8 +11250,9 @@
 
15736
 #undef RS6000_BUILTIN_2
 
15737
 #undef RS6000_BUILTIN_3
 
15738
 #undef RS6000_BUILTIN_A
 
15739
+#undef RS6000_BUILTIN_D
 
15740
 #undef RS6000_BUILTIN_E
 
15741
-#undef RS6000_BUILTIN_D
 
15742
+#undef RS6000_BUILTIN_H
 
15743
 #undef RS6000_BUILTIN_P
 
15744
 #undef RS6000_BUILTIN_Q
 
15745
 #undef RS6000_BUILTIN_S
 
15746
@@ -9862,6 +11266,7 @@
 
15747
 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE)
 
15748
 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE)
 
15749
 #define RS6000_BUILTIN_E(ENUM, NAME, MASK, ATTR, ICODE)
 
15750
+#define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE)
 
15751
 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)
 
15752
 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE)
 
15753
 #define RS6000_BUILTIN_S(ENUM, NAME, MASK, ATTR, ICODE)
 
15754
@@ -9872,17 +11277,49 @@
 
15755
 #include "rs6000-builtin.def"
 
15756
 };
 
15757
 
 
15758
+/* HTM builtins.  */
 
15759
 #undef RS6000_BUILTIN_1
 
15760
 #undef RS6000_BUILTIN_2
 
15761
 #undef RS6000_BUILTIN_3
 
15762
 #undef RS6000_BUILTIN_A
 
15763
 #undef RS6000_BUILTIN_D
 
15764
 #undef RS6000_BUILTIN_E
 
15765
+#undef RS6000_BUILTIN_H
 
15766
 #undef RS6000_BUILTIN_P
 
15767
 #undef RS6000_BUILTIN_Q
 
15768
 #undef RS6000_BUILTIN_S
 
15769
 #undef RS6000_BUILTIN_X
 
15770
 
 
15771
+#define RS6000_BUILTIN_1(ENUM, NAME, MASK, ATTR, ICODE)
 
15772
+#define RS6000_BUILTIN_2(ENUM, NAME, MASK, ATTR, ICODE)
 
15773
+#define RS6000_BUILTIN_3(ENUM, NAME, MASK, ATTR, ICODE)
 
15774
+#define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE)
 
15775
+#define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE)
 
15776
+#define RS6000_BUILTIN_E(ENUM, NAME, MASK, ATTR, ICODE)
 
15777
+#define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE) \
 
15778
+  { MASK, ICODE, NAME, ENUM },
 
15779
+
 
15780
+#define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE)
 
15781
+#define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE)
 
15782
+#define RS6000_BUILTIN_S(ENUM, NAME, MASK, ATTR, ICODE)
 
15783
+#define RS6000_BUILTIN_X(ENUM, NAME, MASK, ATTR, ICODE)
 
15784
+
 
15785
+static const struct builtin_description bdesc_htm[] =
 
15786
+{
 
15787
+#include "rs6000-builtin.def"
 
15788
+};
 
15789
+
 
15790
+#undef RS6000_BUILTIN_1
 
15791
+#undef RS6000_BUILTIN_2
 
15792
+#undef RS6000_BUILTIN_3
 
15793
+#undef RS6000_BUILTIN_A
 
15794
+#undef RS6000_BUILTIN_D
 
15795
+#undef RS6000_BUILTIN_E
 
15796
+#undef RS6000_BUILTIN_H
 
15797
+#undef RS6000_BUILTIN_P
 
15798
+#undef RS6000_BUILTIN_Q
 
15799
+#undef RS6000_BUILTIN_S
 
15800
+
 
15801
 /* Return true if a builtin function is overloaded.  */
 
15802
 bool
 
15803
 rs6000_overloaded_builtin_p (enum rs6000_builtins fncode)
 
15804
@@ -10352,7 +11789,198 @@
 
15805
   return NULL_RTX;
 
15806
 }
 
15807
 
 
15808
+/* Return the appropriate SPR number associated with the given builtin.  */
 
15809
+static inline HOST_WIDE_INT
 
15810
+htm_spr_num (enum rs6000_builtins code)
 
15811
+{
 
15812
+  if (code == HTM_BUILTIN_GET_TFHAR
 
15813
+      || code == HTM_BUILTIN_SET_TFHAR)
 
15814
+    return TFHAR_SPR;
 
15815
+  else if (code == HTM_BUILTIN_GET_TFIAR
 
15816
+          || code == HTM_BUILTIN_SET_TFIAR)
 
15817
+    return TFIAR_SPR;
 
15818
+  else if (code == HTM_BUILTIN_GET_TEXASR
 
15819
+          || code == HTM_BUILTIN_SET_TEXASR)
 
15820
+    return TEXASR_SPR;
 
15821
+  gcc_assert (code == HTM_BUILTIN_GET_TEXASRU
 
15822
+             || code == HTM_BUILTIN_SET_TEXASRU);
 
15823
+  return TEXASRU_SPR;
 
15824
+}
 
15825
+
 
15826
+/* Return the appropriate SPR regno associated with the given builtin.  */
 
15827
+static inline HOST_WIDE_INT
 
15828
+htm_spr_regno (enum rs6000_builtins code)
 
15829
+{
 
15830
+  if (code == HTM_BUILTIN_GET_TFHAR
 
15831
+      || code == HTM_BUILTIN_SET_TFHAR)
 
15832
+    return TFHAR_REGNO;
 
15833
+  else if (code == HTM_BUILTIN_GET_TFIAR
 
15834
+          || code == HTM_BUILTIN_SET_TFIAR)
 
15835
+    return TFIAR_REGNO;
 
15836
+  gcc_assert (code == HTM_BUILTIN_GET_TEXASR
 
15837
+             || code == HTM_BUILTIN_SET_TEXASR
 
15838
+             || code == HTM_BUILTIN_GET_TEXASRU
 
15839
+             || code == HTM_BUILTIN_SET_TEXASRU);
 
15840
+  return TEXASR_REGNO;
 
15841
+}
 
15842
+
 
15843
+/* Return the correct ICODE value depending on whether we are
 
15844
+   setting or reading the HTM SPRs.  */
 
15845
+static inline enum insn_code
 
15846
+rs6000_htm_spr_icode (bool nonvoid)
 
15847
+{
 
15848
+  if (nonvoid)
 
15849
+    return (TARGET_64BIT) ? CODE_FOR_htm_mfspr_di : CODE_FOR_htm_mfspr_si;
 
15850
+  else
 
15851
+    return (TARGET_64BIT) ? CODE_FOR_htm_mtspr_di : CODE_FOR_htm_mtspr_si;
 
15852
+}
 
15853
+
 
15854
+/* Expand the HTM builtin in EXP and store the result in TARGET.
 
15855
+   Store true in *EXPANDEDP if we found a builtin to expand.  */
 
15856
 static rtx
 
15857
+htm_expand_builtin (tree exp, rtx target, bool * expandedp)
 
15858
+{
 
15859
+  tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0);
 
15860
+  bool nonvoid = TREE_TYPE (TREE_TYPE (fndecl)) != void_type_node;
 
15861
+  enum rs6000_builtins fcode = (enum rs6000_builtins) DECL_FUNCTION_CODE (fndecl);
 
15862
+  const struct builtin_description *d;
 
15863
+  size_t i;
 
15864
+
 
15865
+  *expandedp = false;
 
15866
+
 
15867
+  /* Expand the HTM builtins.  */
 
15868
+  d = bdesc_htm;
 
15869
+  for (i = 0; i < ARRAY_SIZE (bdesc_htm); i++, d++)
 
15870
+    if (d->code == fcode)
 
15871
+      {
 
15872
+       rtx op[MAX_HTM_OPERANDS], pat;
 
15873
+       int nopnds = 0;
 
15874
+       tree arg;
 
15875
+       call_expr_arg_iterator iter;
 
15876
+       unsigned attr = rs6000_builtin_info[fcode].attr;
 
15877
+       enum insn_code icode = d->icode;
 
15878
+
 
15879
+       if (attr & RS6000_BTC_SPR)
 
15880
+         icode = rs6000_htm_spr_icode (nonvoid);
 
15881
+
 
15882
+       if (nonvoid)
 
15883
+         {
 
15884
+           enum machine_mode tmode = insn_data[icode].operand[0].mode;
 
15885
+           if (!target
 
15886
+               || GET_MODE (target) != tmode
 
15887
+               || !(*insn_data[icode].operand[0].predicate) (target, tmode))
 
15888
+             target = gen_reg_rtx (tmode);
 
15889
+           op[nopnds++] = target;
 
15890
+         }
 
15891
+
 
15892
+       FOR_EACH_CALL_EXPR_ARG (arg, iter, exp)
 
15893
+       {
 
15894
+         const struct insn_operand_data *insn_op;
 
15895
+
 
15896
+         if (arg == error_mark_node || nopnds >= MAX_HTM_OPERANDS)
 
15897
+           return NULL_RTX;
 
15898
+
 
15899
+         insn_op = &insn_data[icode].operand[nopnds];
 
15900
+
 
15901
+         op[nopnds] = expand_normal (arg);
 
15902
+
 
15903
+         if (!(*insn_op->predicate) (op[nopnds], insn_op->mode))
 
15904
+           {
 
15905
+             if (!strcmp (insn_op->constraint, "n"))
 
15906
+               {
 
15907
+                 int arg_num = (nonvoid) ? nopnds : nopnds + 1;
 
15908
+                 if (!CONST_INT_P (op[nopnds]))
 
15909
+                   error ("argument %d must be an unsigned literal", arg_num);
 
15910
+                 else
 
15911
+                   error ("argument %d is an unsigned literal that is "
 
15912
+                          "out of range", arg_num);
 
15913
+                 return const0_rtx;
 
15914
+               }
 
15915
+             op[nopnds] = copy_to_mode_reg (insn_op->mode, op[nopnds]);
 
15916
+           }
 
15917
+
 
15918
+         nopnds++;
 
15919
+       }
 
15920
+
 
15921
+       /* Handle the builtins for extended mnemonics.  These accept
 
15922
+          no arguments, but map to builtins that take arguments.  */
 
15923
+       switch (fcode)
 
15924
+         {
 
15925
+         case HTM_BUILTIN_TENDALL:  /* Alias for: tend. 1  */
 
15926
+         case HTM_BUILTIN_TRESUME:  /* Alias for: tsr. 1  */
 
15927
+           op[nopnds++] = GEN_INT (1);
 
15928
+#ifdef ENABLE_CHECKING
 
15929
+           attr |= RS6000_BTC_UNARY;
 
15930
+#endif
 
15931
+           break;
 
15932
+         case HTM_BUILTIN_TSUSPEND: /* Alias for: tsr. 0  */
 
15933
+           op[nopnds++] = GEN_INT (0);
 
15934
+#ifdef ENABLE_CHECKING
 
15935
+           attr |= RS6000_BTC_UNARY;
 
15936
+#endif
 
15937
+           break;
 
15938
+         default:
 
15939
+           break;
 
15940
+         }
 
15941
+
 
15942
+       /* If this builtin accesses SPRs, then pass in the appropriate
 
15943
+          SPR number and SPR regno as the last two operands.  */
 
15944
+       if (attr & RS6000_BTC_SPR)
 
15945
+         {
 
15946
+           op[nopnds++] = gen_rtx_CONST_INT (Pmode, htm_spr_num (fcode));
 
15947
+           op[nopnds++] = gen_rtx_REG (Pmode, htm_spr_regno (fcode));
 
15948
+         }
 
15949
+
 
15950
+#ifdef ENABLE_CHECKING
 
15951
+       int expected_nopnds = 0;
 
15952
+       if ((attr & RS6000_BTC_TYPE_MASK) == RS6000_BTC_UNARY)
 
15953
+         expected_nopnds = 1;
 
15954
+       else if ((attr & RS6000_BTC_TYPE_MASK) == RS6000_BTC_BINARY)
 
15955
+         expected_nopnds = 2;
 
15956
+       else if ((attr & RS6000_BTC_TYPE_MASK) == RS6000_BTC_TERNARY)
 
15957
+         expected_nopnds = 3;
 
15958
+       if (!(attr & RS6000_BTC_VOID))
 
15959
+         expected_nopnds += 1;
 
15960
+       if (attr & RS6000_BTC_SPR)
 
15961
+         expected_nopnds += 2;
 
15962
+
 
15963
+       gcc_assert (nopnds == expected_nopnds && nopnds <= MAX_HTM_OPERANDS);
 
15964
+#endif
 
15965
+
 
15966
+       switch (nopnds)
 
15967
+         {
 
15968
+         case 0:
 
15969
+           pat = GEN_FCN (icode) (NULL_RTX);
 
15970
+           break;
 
15971
+         case 1:
 
15972
+           pat = GEN_FCN (icode) (op[0]);
 
15973
+           break;
 
15974
+         case 2:
 
15975
+           pat = GEN_FCN (icode) (op[0], op[1]);
 
15976
+           break;
 
15977
+         case 3:
 
15978
+           pat = GEN_FCN (icode) (op[0], op[1], op[2]);
 
15979
+           break;
 
15980
+         case 4:
 
15981
+           pat = GEN_FCN (icode) (op[0], op[1], op[2], op[3]);
 
15982
+           break;
 
15983
+         default:
 
15984
+           gcc_unreachable ();
 
15985
+         }
 
15986
+       if (!pat)
 
15987
+         return NULL_RTX;
 
15988
+       emit_insn (pat);
 
15989
+
 
15990
+       *expandedp = true;
 
15991
+       if (nonvoid)
 
15992
+         return target;
 
15993
+       return const0_rtx;
 
15994
+      }
 
15995
+
 
15996
+  return NULL_RTX;
 
15997
+}
 
15998
+
 
15999
+static rtx
 
16000
 rs6000_expand_ternop_builtin (enum insn_code icode, tree exp, rtx target)
 
16001
 {
 
16002
   rtx pat;
 
16003
@@ -10428,7 +12056,28 @@
 
16004
          return const0_rtx;
 
16005
        }
 
16006
     }
 
16007
+  else if (icode == CODE_FOR_crypto_vshasigmaw
 
16008
+          || icode == CODE_FOR_crypto_vshasigmad)
 
16009
+    {
 
16010
+      /* Check whether the 2nd and 3rd arguments are integer constants and in
 
16011
+        range and prepare arguments.  */
 
16012
+      STRIP_NOPS (arg1);
 
16013
+      if (TREE_CODE (arg1) != INTEGER_CST
 
16014
+         || !IN_RANGE (TREE_INT_CST_LOW (arg1), 0, 1))
 
16015
+       {
 
16016
+         error ("argument 2 must be 0 or 1");
 
16017
+         return const0_rtx;
 
16018
+       }
 
16019
 
 
16020
+      STRIP_NOPS (arg2);
 
16021
+      if (TREE_CODE (arg2) != INTEGER_CST
 
16022
+         || !IN_RANGE (TREE_INT_CST_LOW (arg2), 0, 15))
 
16023
+       {
 
16024
+         error ("argument 3 must be in the range 0..15");
 
16025
+         return const0_rtx;
 
16026
+       }
 
16027
+    }
 
16028
+
 
16029
   if (target == 0
 
16030
       || GET_MODE (target) != tmode
 
16031
       || ! (*insn_data[icode].operand[0].predicate) (target, tmode))
 
16032
@@ -11412,6 +13061,8 @@
 
16033
     error ("Builtin function %s is only valid for the cell processor", name);
 
16034
   else if ((fnmask & RS6000_BTM_VSX) != 0)
 
16035
     error ("Builtin function %s requires the -mvsx option", name);
 
16036
+  else if ((fnmask & RS6000_BTM_HTM) != 0)
 
16037
+    error ("Builtin function %s requires the -mhtm option", name);
 
16038
   else if ((fnmask & RS6000_BTM_ALTIVEC) != 0)
 
16039
     error ("Builtin function %s requires the -maltivec option", name);
 
16040
   else if ((fnmask & RS6000_BTM_PAIRED) != 0)
 
16041
@@ -11516,7 +13167,8 @@
 
16042
     case ALTIVEC_BUILTIN_MASK_FOR_LOAD:
 
16043
     case ALTIVEC_BUILTIN_MASK_FOR_STORE:
 
16044
       {
 
16045
-       int icode = (int) CODE_FOR_altivec_lvsr;
 
16046
+       int icode = (BYTES_BIG_ENDIAN ? (int) CODE_FOR_altivec_lvsr
 
16047
+                    : (int) CODE_FOR_altivec_lvsl);
 
16048
        enum machine_mode tmode = insn_data[icode].operand[0].mode;
 
16049
        enum machine_mode mode = insn_data[icode].operand[1].mode;
 
16050
        tree arg;
 
16051
@@ -11591,7 +13243,14 @@
 
16052
       if (success)
 
16053
        return ret;
 
16054
     }  
 
16055
+  if (TARGET_HTM)
 
16056
+    {
 
16057
+      ret = htm_expand_builtin (exp, target, &success);
 
16058
 
 
16059
+      if (success)
 
16060
+       return ret;
 
16061
+    }  
 
16062
+
 
16063
   gcc_assert (TARGET_ALTIVEC || TARGET_VSX || TARGET_SPE || TARGET_PAIRED_FLOAT);
 
16064
 
 
16065
   /* Handle simple unary operations.  */
 
16066
@@ -11773,6 +13432,9 @@
 
16067
     spe_init_builtins ();
 
16068
   if (TARGET_EXTRA_BUILTINS)
 
16069
     altivec_init_builtins ();
 
16070
+  if (TARGET_HTM)
 
16071
+    htm_init_builtins ();
 
16072
+
 
16073
   if (TARGET_EXTRA_BUILTINS || TARGET_SPE || TARGET_PAIRED_FLOAT)
 
16074
     rs6000_common_init_builtins ();
 
16075
 
 
16076
@@ -12118,6 +13780,10 @@
 
16077
     = build_function_type_list (integer_type_node,
 
16078
                                integer_type_node, V4SI_type_node,
 
16079
                                V4SI_type_node, NULL_TREE);
 
16080
+  tree int_ftype_int_v2di_v2di
 
16081
+    = build_function_type_list (integer_type_node,
 
16082
+                               integer_type_node, V2DI_type_node,
 
16083
+                               V2DI_type_node, NULL_TREE);
 
16084
   tree void_ftype_v4si
 
16085
     = build_function_type_list (void_type_node, V4SI_type_node, NULL_TREE);
 
16086
   tree v8hi_ftype_void
 
16087
@@ -12200,6 +13866,8 @@
 
16088
     = build_function_type_list (integer_type_node,
 
16089
                                integer_type_node, V2DF_type_node,
 
16090
                                V2DF_type_node, NULL_TREE);
 
16091
+  tree v2di_ftype_v2di
 
16092
+    = build_function_type_list (V2DI_type_node, V2DI_type_node, NULL_TREE);
 
16093
   tree v4si_ftype_v4si
 
16094
     = build_function_type_list (V4SI_type_node, V4SI_type_node, NULL_TREE);
 
16095
   tree v8hi_ftype_v8hi
 
16096
@@ -12335,6 +14003,9 @@
 
16097
        case VOIDmode:
 
16098
          type = int_ftype_int_opaque_opaque;
 
16099
          break;
 
16100
+       case V2DImode:
 
16101
+         type = int_ftype_int_v2di_v2di;
 
16102
+         break;
 
16103
        case V4SImode:
 
16104
          type = int_ftype_int_v4si_v4si;
 
16105
          break;
 
16106
@@ -12368,6 +14039,9 @@
 
16107
 
 
16108
       switch (mode0)
 
16109
        {
 
16110
+       case V2DImode:
 
16111
+         type = v2di_ftype_v2di;
 
16112
+         break;
 
16113
        case V4SImode:
 
16114
          type = v4si_ftype_v4si;
 
16115
          break;
 
16116
@@ -12500,6 +14174,79 @@
 
16117
   def_builtin ("__builtin_vec_ext_v2di", ftype, VSX_BUILTIN_VEC_EXT_V2DI);
 
16118
 }
 
16119
 
 
16120
+static void
 
16121
+htm_init_builtins (void)
 
16122
+{
 
16123
+  HOST_WIDE_INT builtin_mask = rs6000_builtin_mask;
 
16124
+  const struct builtin_description *d;
 
16125
+  size_t i;
 
16126
+
 
16127
+  d = bdesc_htm;
 
16128
+  for (i = 0; i < ARRAY_SIZE (bdesc_htm); i++, d++)
 
16129
+    {
 
16130
+      tree op[MAX_HTM_OPERANDS], type;
 
16131
+      HOST_WIDE_INT mask = d->mask;
 
16132
+      unsigned attr = rs6000_builtin_info[d->code].attr;
 
16133
+      bool void_func = (attr & RS6000_BTC_VOID);
 
16134
+      int attr_args = (attr & RS6000_BTC_TYPE_MASK);
 
16135
+      int nopnds = 0;
 
16136
+      tree argtype = (attr & RS6000_BTC_SPR) ? long_unsigned_type_node
 
16137
+                                            : unsigned_type_node;
 
16138
+
 
16139
+      if ((mask & builtin_mask) != mask)
 
16140
+       {
 
16141
+         if (TARGET_DEBUG_BUILTIN)
 
16142
+           fprintf (stderr, "htm_builtin, skip binary %s\n", d->name);
 
16143
+         continue;
 
16144
+       }
 
16145
+
 
16146
+      if (d->name == 0)
 
16147
+       {
 
16148
+         if (TARGET_DEBUG_BUILTIN)
 
16149
+           fprintf (stderr, "htm_builtin, bdesc_htm[%ld] no name\n",
 
16150
+                    (long unsigned) i);
 
16151
+         continue;
 
16152
+       }
 
16153
+
 
16154
+      op[nopnds++] = (void_func) ? void_type_node : argtype;
 
16155
+
 
16156
+      if (attr_args == RS6000_BTC_UNARY)
 
16157
+       op[nopnds++] = argtype;
 
16158
+      else if (attr_args == RS6000_BTC_BINARY)
 
16159
+       {
 
16160
+         op[nopnds++] = argtype;
 
16161
+         op[nopnds++] = argtype;
 
16162
+       }
 
16163
+      else if (attr_args == RS6000_BTC_TERNARY)
 
16164
+       {
 
16165
+         op[nopnds++] = argtype;
 
16166
+         op[nopnds++] = argtype;
 
16167
+         op[nopnds++] = argtype;
 
16168
+       }
 
16169
+
 
16170
+      switch (nopnds)
 
16171
+       {
 
16172
+       case 1:
 
16173
+         type = build_function_type_list (op[0], NULL_TREE);
 
16174
+         break;
 
16175
+       case 2:
 
16176
+         type = build_function_type_list (op[0], op[1], NULL_TREE);
 
16177
+         break;
 
16178
+       case 3:
 
16179
+         type = build_function_type_list (op[0], op[1], op[2], NULL_TREE);
 
16180
+         break;
 
16181
+       case 4:
 
16182
+         type = build_function_type_list (op[0], op[1], op[2], op[3],
 
16183
+                                          NULL_TREE);
 
16184
+         break;
 
16185
+       default:
 
16186
+         gcc_unreachable ();
 
16187
+       }
 
16188
+
 
16189
+      def_builtin (d->name, type, d->code);
 
16190
+    }
 
16191
+}
 
16192
+
 
16193
 /* Hash function for builtin functions with up to 3 arguments and a return
 
16194
    type.  */
 
16195
 static unsigned
 
16196
@@ -12573,11 +14320,27 @@
 
16197
      are type correct.  */
 
16198
   switch (builtin)
 
16199
     {
 
16200
+      /* unsigned 1 argument functions.  */
 
16201
+    case CRYPTO_BUILTIN_VSBOX:
 
16202
+    case P8V_BUILTIN_VGBBD:
 
16203
+      h.uns_p[0] = 1;
 
16204
+      h.uns_p[1] = 1;
 
16205
+      break;
 
16206
+
 
16207
       /* unsigned 2 argument functions.  */
 
16208
     case ALTIVEC_BUILTIN_VMULEUB_UNS:
 
16209
     case ALTIVEC_BUILTIN_VMULEUH_UNS:
 
16210
     case ALTIVEC_BUILTIN_VMULOUB_UNS:
 
16211
     case ALTIVEC_BUILTIN_VMULOUH_UNS:
 
16212
+    case CRYPTO_BUILTIN_VCIPHER:
 
16213
+    case CRYPTO_BUILTIN_VCIPHERLAST:
 
16214
+    case CRYPTO_BUILTIN_VNCIPHER:
 
16215
+    case CRYPTO_BUILTIN_VNCIPHERLAST:
 
16216
+    case CRYPTO_BUILTIN_VPMSUMB:
 
16217
+    case CRYPTO_BUILTIN_VPMSUMH:
 
16218
+    case CRYPTO_BUILTIN_VPMSUMW:
 
16219
+    case CRYPTO_BUILTIN_VPMSUMD:
 
16220
+    case CRYPTO_BUILTIN_VPMSUM:
 
16221
       h.uns_p[0] = 1;
 
16222
       h.uns_p[1] = 1;
 
16223
       h.uns_p[2] = 1;
 
16224
@@ -12600,6 +14363,14 @@
 
16225
     case VSX_BUILTIN_XXSEL_8HI_UNS:
 
16226
     case VSX_BUILTIN_XXSEL_4SI_UNS:
 
16227
     case VSX_BUILTIN_XXSEL_2DI_UNS:
 
16228
+    case CRYPTO_BUILTIN_VPERMXOR:
 
16229
+    case CRYPTO_BUILTIN_VPERMXOR_V2DI:
 
16230
+    case CRYPTO_BUILTIN_VPERMXOR_V4SI:
 
16231
+    case CRYPTO_BUILTIN_VPERMXOR_V8HI:
 
16232
+    case CRYPTO_BUILTIN_VPERMXOR_V16QI:
 
16233
+    case CRYPTO_BUILTIN_VSHASIGMAW:
 
16234
+    case CRYPTO_BUILTIN_VSHASIGMAD:
 
16235
+    case CRYPTO_BUILTIN_VSHASIGMA:
 
16236
       h.uns_p[0] = 1;
 
16237
       h.uns_p[1] = 1;
 
16238
       h.uns_p[2] = 1;
 
16239
@@ -12741,9 +14512,24 @@
 
16240
       else
 
16241
        {
 
16242
          enum insn_code icode = d->icode;
 
16243
-          if (d->name == 0 || icode == CODE_FOR_nothing)
 
16244
-           continue;
 
16245
+         if (d->name == 0)
 
16246
+           {
 
16247
+             if (TARGET_DEBUG_BUILTIN)
 
16248
+               fprintf (stderr, "rs6000_builtin, bdesc_3arg[%ld] no name\n",
 
16249
+                        (long unsigned)i);
 
16250
 
 
16251
+             continue;
 
16252
+           }
 
16253
+
 
16254
+          if (icode == CODE_FOR_nothing)
 
16255
+           {
 
16256
+             if (TARGET_DEBUG_BUILTIN)
 
16257
+               fprintf (stderr, "rs6000_builtin, skip ternary %s (no code)\n",
 
16258
+                        d->name);
 
16259
+
 
16260
+             continue;
 
16261
+           }
 
16262
+
 
16263
          type = builtin_function_type (insn_data[icode].operand[0].mode,
 
16264
                                        insn_data[icode].operand[1].mode,
 
16265
                                        insn_data[icode].operand[2].mode,
 
16266
@@ -12781,9 +14567,24 @@
 
16267
       else
 
16268
        {
 
16269
          enum insn_code icode = d->icode;
 
16270
-          if (d->name == 0 || icode == CODE_FOR_nothing)
 
16271
-           continue;
 
16272
+         if (d->name == 0)
 
16273
+           {
 
16274
+             if (TARGET_DEBUG_BUILTIN)
 
16275
+               fprintf (stderr, "rs6000_builtin, bdesc_2arg[%ld] no name\n",
 
16276
+                        (long unsigned)i);
 
16277
 
 
16278
+             continue;
 
16279
+           }
 
16280
+
 
16281
+          if (icode == CODE_FOR_nothing)
 
16282
+           {
 
16283
+             if (TARGET_DEBUG_BUILTIN)
 
16284
+               fprintf (stderr, "rs6000_builtin, skip binary %s (no code)\n",
 
16285
+                        d->name);
 
16286
+
 
16287
+             continue;
 
16288
+           }
 
16289
+
 
16290
           mode0 = insn_data[icode].operand[0].mode;
 
16291
           mode1 = insn_data[icode].operand[1].mode;
 
16292
           mode2 = insn_data[icode].operand[2].mode;
 
16293
@@ -12843,9 +14644,24 @@
 
16294
       else
 
16295
         {
 
16296
          enum insn_code icode = d->icode;
 
16297
-          if (d->name == 0 || icode == CODE_FOR_nothing)
 
16298
-           continue;
 
16299
+         if (d->name == 0)
 
16300
+           {
 
16301
+             if (TARGET_DEBUG_BUILTIN)
 
16302
+               fprintf (stderr, "rs6000_builtin, bdesc_1arg[%ld] no name\n",
 
16303
+                        (long unsigned)i);
 
16304
 
 
16305
+             continue;
 
16306
+           }
 
16307
+
 
16308
+          if (icode == CODE_FOR_nothing)
 
16309
+           {
 
16310
+             if (TARGET_DEBUG_BUILTIN)
 
16311
+               fprintf (stderr, "rs6000_builtin, skip unary %s (no code)\n",
 
16312
+                        d->name);
 
16313
+
 
16314
+             continue;
 
16315
+           }
 
16316
+
 
16317
           mode0 = insn_data[icode].operand[0].mode;
 
16318
           mode1 = insn_data[icode].operand[1].mode;
 
16319
 
 
16320
@@ -13632,7 +15448,7 @@
 
16321
   static bool eliminated = false;
 
16322
   rtx ret;
 
16323
 
 
16324
-  if (mode != SDmode)
 
16325
+  if (mode != SDmode || TARGET_NO_SDMODE_STACK)
 
16326
     ret = assign_stack_local (mode, GET_MODE_SIZE (mode), 0);
 
16327
   else
 
16328
     {
 
16329
@@ -13691,31 +15507,228 @@
 
16330
   return NULL_TREE;
 
16331
 }
 
16332
 
 
16333
-enum reload_reg_type {
 
16334
-  GPR_REGISTER_TYPE,
 
16335
-  VECTOR_REGISTER_TYPE,
 
16336
-  OTHER_REGISTER_TYPE
 
16337
-};
 
16338
+/* Classify a register type.  Because the FMRGOW/FMRGEW instructions only work
 
16339
+   on traditional floating point registers, and the VMRGOW/VMRGEW instructions
 
16340
+   only work on the traditional altivec registers, note if an altivec register
 
16341
+   was chosen.  */
 
16342
 
 
16343
-static enum reload_reg_type
 
16344
-rs6000_reload_register_type (enum reg_class rclass)
 
16345
+static enum rs6000_reg_type
 
16346
+register_to_reg_type (rtx reg, bool *is_altivec)
 
16347
 {
 
16348
-  switch (rclass)
 
16349
+  HOST_WIDE_INT regno;
 
16350
+  enum reg_class rclass;
 
16351
+
 
16352
+  if (GET_CODE (reg) == SUBREG)
 
16353
+    reg = SUBREG_REG (reg);
 
16354
+
 
16355
+  if (!REG_P (reg))
 
16356
+    return NO_REG_TYPE;
 
16357
+
 
16358
+  regno = REGNO (reg);
 
16359
+  if (regno >= FIRST_PSEUDO_REGISTER)
 
16360
     {
 
16361
-    case GENERAL_REGS:
 
16362
-    case BASE_REGS:
 
16363
-      return GPR_REGISTER_TYPE;
 
16364
+      if (!lra_in_progress && !reload_in_progress && !reload_completed)
 
16365
+       return PSEUDO_REG_TYPE;
 
16366
 
 
16367
-    case FLOAT_REGS:
 
16368
-    case ALTIVEC_REGS:
 
16369
-    case VSX_REGS:
 
16370
-      return VECTOR_REGISTER_TYPE;
 
16371
+      regno = true_regnum (reg);
 
16372
+      if (regno < 0 || regno >= FIRST_PSEUDO_REGISTER)
 
16373
+       return PSEUDO_REG_TYPE;
 
16374
+    }  
 
16375
 
 
16376
-    default:
 
16377
-      return OTHER_REGISTER_TYPE;
 
16378
+  gcc_assert (regno >= 0);
 
16379
+
 
16380
+  if (is_altivec && ALTIVEC_REGNO_P (regno))
 
16381
+    *is_altivec = true;
 
16382
+
 
16383
+  rclass = rs6000_regno_regclass[regno];
 
16384
+  return reg_class_to_reg_type[(int)rclass];
 
16385
+}
 
16386
+
 
16387
+/* Helper function for rs6000_secondary_reload to return true if a move to a
 
16388
+   different register classe is really a simple move.  */
 
16389
+
 
16390
+static bool
 
16391
+rs6000_secondary_reload_simple_move (enum rs6000_reg_type to_type,
 
16392
+                                    enum rs6000_reg_type from_type,
 
16393
+                                    enum machine_mode mode)
 
16394
+{
 
16395
+  int size;
 
16396
+
 
16397
+  /* Add support for various direct moves available.  In this function, we only
 
16398
+     look at cases where we don't need any extra registers, and one or more
 
16399
+     simple move insns are issued.  At present, 32-bit integers are not allowed
 
16400
+     in FPR/VSX registers.  Single precision binary floating is not a simple
 
16401
+     move because we need to convert to the single precision memory layout.
 
16402
+     The 4-byte SDmode can be moved.  */
 
16403
+  size = GET_MODE_SIZE (mode);
 
16404
+  if (TARGET_DIRECT_MOVE
 
16405
+      && ((mode == SDmode) || (TARGET_POWERPC64 && size == 8))
 
16406
+      && ((to_type == GPR_REG_TYPE && from_type == VSX_REG_TYPE)
 
16407
+         || (to_type == VSX_REG_TYPE && from_type == GPR_REG_TYPE)))
 
16408
+    return true;
 
16409
+
 
16410
+  else if (TARGET_MFPGPR && TARGET_POWERPC64 && size == 8
 
16411
+          && ((to_type == GPR_REG_TYPE && from_type == FPR_REG_TYPE)
 
16412
+              || (to_type == FPR_REG_TYPE && from_type == GPR_REG_TYPE)))
 
16413
+    return true;
 
16414
+
 
16415
+  else if ((size == 4 || (TARGET_POWERPC64 && size == 8))
 
16416
+          && ((to_type == GPR_REG_TYPE && from_type == SPR_REG_TYPE)
 
16417
+              || (to_type == SPR_REG_TYPE && from_type == GPR_REG_TYPE)))
 
16418
+    return true;
 
16419
+
 
16420
+  return false;
 
16421
+}
 
16422
+
 
16423
+/* Power8 helper function for rs6000_secondary_reload, handle all of the
 
16424
+   special direct moves that involve allocating an extra register, return the
 
16425
+   insn code of the helper function if there is such a function or
 
16426
+   CODE_FOR_nothing if not.  */
 
16427
+
 
16428
+static bool
 
16429
+rs6000_secondary_reload_direct_move (enum rs6000_reg_type to_type,
 
16430
+                                    enum rs6000_reg_type from_type,
 
16431
+                                    enum machine_mode mode,
 
16432
+                                    secondary_reload_info *sri,
 
16433
+                                    bool altivec_p)
 
16434
+{
 
16435
+  bool ret = false;
 
16436
+  enum insn_code icode = CODE_FOR_nothing;
 
16437
+  int cost = 0;
 
16438
+  int size = GET_MODE_SIZE (mode);
 
16439
+
 
16440
+  if (TARGET_POWERPC64)
 
16441
+    {
 
16442
+      if (size == 16)
 
16443
+       {
 
16444
+         /* Handle moving 128-bit values from GPRs to VSX point registers on
 
16445
+            power8 when running in 64-bit mode using XXPERMDI to glue the two
 
16446
+            64-bit values back together.  */
 
16447
+         if (to_type == VSX_REG_TYPE && from_type == GPR_REG_TYPE)
 
16448
+           {
 
16449
+             cost = 3;                 /* 2 mtvsrd's, 1 xxpermdi.  */
 
16450
+             icode = reg_addr[mode].reload_vsx_gpr;
 
16451
+           }
 
16452
+
 
16453
+         /* Handle moving 128-bit values from VSX point registers to GPRs on
 
16454
+            power8 when running in 64-bit mode using XXPERMDI to get access to the
 
16455
+            bottom 64-bit value.  */
 
16456
+         else if (to_type == GPR_REG_TYPE && from_type == VSX_REG_TYPE)
 
16457
+           {
 
16458
+             cost = 3;                 /* 2 mfvsrd's, 1 xxpermdi.  */
 
16459
+             icode = reg_addr[mode].reload_gpr_vsx;
 
16460
+           }
 
16461
+       }
 
16462
+
 
16463
+      else if (mode == SFmode)
 
16464
+       {
 
16465
+         if (to_type == GPR_REG_TYPE && from_type == VSX_REG_TYPE)
 
16466
+           {
 
16467
+             cost = 3;                 /* xscvdpspn, mfvsrd, and.  */
 
16468
+             icode = reg_addr[mode].reload_gpr_vsx;
 
16469
+           }
 
16470
+
 
16471
+         else if (to_type == VSX_REG_TYPE && from_type == GPR_REG_TYPE)
 
16472
+           {
 
16473
+             cost = 2;                 /* mtvsrz, xscvspdpn.  */
 
16474
+             icode = reg_addr[mode].reload_vsx_gpr;
 
16475
+           }
 
16476
+       }
 
16477
     }
 
16478
+
 
16479
+  if (TARGET_POWERPC64 && size == 16)
 
16480
+    {
 
16481
+      /* Handle moving 128-bit values from GPRs to VSX point registers on
 
16482
+        power8 when running in 64-bit mode using XXPERMDI to glue the two
 
16483
+        64-bit values back together.  */
 
16484
+      if (to_type == VSX_REG_TYPE && from_type == GPR_REG_TYPE)
 
16485
+       {
 
16486
+         cost = 3;                     /* 2 mtvsrd's, 1 xxpermdi.  */
 
16487
+         icode = reg_addr[mode].reload_vsx_gpr;
 
16488
+       }
 
16489
+
 
16490
+      /* Handle moving 128-bit values from VSX point registers to GPRs on
 
16491
+        power8 when running in 64-bit mode using XXPERMDI to get access to the
 
16492
+        bottom 64-bit value.  */
 
16493
+      else if (to_type == GPR_REG_TYPE && from_type == VSX_REG_TYPE)
 
16494
+       {
 
16495
+         cost = 3;                     /* 2 mfvsrd's, 1 xxpermdi.  */
 
16496
+         icode = reg_addr[mode].reload_gpr_vsx;
 
16497
+       }
 
16498
+    }
 
16499
+
 
16500
+  else if (!TARGET_POWERPC64 && size == 8)
 
16501
+    {
 
16502
+      /* Handle moving 64-bit values from GPRs to floating point registers on
 
16503
+        power8 when running in 32-bit mode using FMRGOW to glue the two 32-bit
 
16504
+        values back together.  Altivec register classes must be handled
 
16505
+        specially since a different instruction is used, and the secondary
 
16506
+        reload support requires a single instruction class in the scratch
 
16507
+        register constraint.  However, right now TFmode is not allowed in
 
16508
+        Altivec registers, so the pattern will never match.  */
 
16509
+      if (to_type == VSX_REG_TYPE && from_type == GPR_REG_TYPE && !altivec_p)
 
16510
+       {
 
16511
+         cost = 3;                     /* 2 mtvsrwz's, 1 fmrgow.  */
 
16512
+         icode = reg_addr[mode].reload_fpr_gpr;
 
16513
+       }
 
16514
+    }
 
16515
+
 
16516
+  if (icode != CODE_FOR_nothing)
 
16517
+    {
 
16518
+      ret = true;
 
16519
+      if (sri)
 
16520
+       {
 
16521
+         sri->icode = icode;
 
16522
+         sri->extra_cost = cost;
 
16523
+       }
 
16524
+    }
 
16525
+
 
16526
+  return ret;
 
16527
 }
 
16528
 
 
16529
+/* Return whether a move between two register classes can be done either
 
16530
+   directly (simple move) or via a pattern that uses a single extra temporary
 
16531
+   (using power8's direct move in this case.  */
 
16532
+
 
16533
+static bool
 
16534
+rs6000_secondary_reload_move (enum rs6000_reg_type to_type,
 
16535
+                             enum rs6000_reg_type from_type,
 
16536
+                             enum machine_mode mode,
 
16537
+                             secondary_reload_info *sri,
 
16538
+                             bool altivec_p)
 
16539
+{
 
16540
+  /* Fall back to load/store reloads if either type is not a register.  */
 
16541
+  if (to_type == NO_REG_TYPE || from_type == NO_REG_TYPE)
 
16542
+    return false;
 
16543
+
 
16544
+  /* If we haven't allocated registers yet, assume the move can be done for the
 
16545
+     standard register types.  */
 
16546
+  if ((to_type == PSEUDO_REG_TYPE && from_type == PSEUDO_REG_TYPE)
 
16547
+      || (to_type == PSEUDO_REG_TYPE && IS_STD_REG_TYPE (from_type))
 
16548
+      || (from_type == PSEUDO_REG_TYPE && IS_STD_REG_TYPE (to_type)))
 
16549
+    return true;
 
16550
+
 
16551
+  /* Moves to the same set of registers is a simple move for non-specialized
 
16552
+     registers.  */
 
16553
+  if (to_type == from_type && IS_STD_REG_TYPE (to_type))
 
16554
+    return true;
 
16555
+
 
16556
+  /* Check whether a simple move can be done directly.  */
 
16557
+  if (rs6000_secondary_reload_simple_move (to_type, from_type, mode))
 
16558
+    {
 
16559
+      if (sri)
 
16560
+       {
 
16561
+         sri->icode = CODE_FOR_nothing;
 
16562
+         sri->extra_cost = 0;
 
16563
+       }
 
16564
+      return true;
 
16565
+    }
 
16566
+
 
16567
+  /* Now check if we can do it in a few steps.  */
 
16568
+  return rs6000_secondary_reload_direct_move (to_type, from_type, mode, sri,
 
16569
+                                             altivec_p);
 
16570
+}
 
16571
+
 
16572
 /* Inform reload about cases where moving X with a mode MODE to a register in
 
16573
    RCLASS requires an extra scratch or immediate register.  Return the class
 
16574
    needed for the immediate register.
 
16575
@@ -13739,12 +15752,36 @@
 
16576
   bool default_p = false;
 
16577
 
 
16578
   sri->icode = CODE_FOR_nothing;
 
16579
+  icode = ((in_p)
 
16580
+          ? reg_addr[mode].reload_load
 
16581
+          : reg_addr[mode].reload_store);
 
16582
 
 
16583
-  /* Convert vector loads and stores into gprs to use an additional base
 
16584
-     register.  */
 
16585
-  icode = rs6000_vector_reload[mode][in_p != false];
 
16586
-  if (icode != CODE_FOR_nothing)
 
16587
+  if (REG_P (x) || register_operand (x, mode))
 
16588
     {
 
16589
+      enum rs6000_reg_type to_type = reg_class_to_reg_type[(int)rclass];
 
16590
+      bool altivec_p = (rclass == ALTIVEC_REGS);
 
16591
+      enum rs6000_reg_type from_type = register_to_reg_type (x, &altivec_p);
 
16592
+
 
16593
+      if (!in_p)
 
16594
+       {
 
16595
+         enum rs6000_reg_type exchange = to_type;
 
16596
+         to_type = from_type;
 
16597
+         from_type = exchange;
 
16598
+       }
 
16599
+
 
16600
+      /* Can we do a direct move of some sort?  */
 
16601
+      if (rs6000_secondary_reload_move (to_type, from_type, mode, sri,
 
16602
+                                       altivec_p))
 
16603
+       {
 
16604
+         icode = (enum insn_code)sri->icode;
 
16605
+         default_p = false;
 
16606
+         ret = NO_REGS;
 
16607
+       }
 
16608
+    }
 
16609
+
 
16610
+  /* Handle vector moves with reload helper functions.  */
 
16611
+  if (ret == ALL_REGS && icode != CODE_FOR_nothing)
 
16612
+    {
 
16613
       ret = NO_REGS;
 
16614
       sri->icode = CODE_FOR_nothing;
 
16615
       sri->extra_cost = 0;
 
16616
@@ -13755,22 +15792,43 @@
 
16617
 
 
16618
          /* Loads to and stores from gprs can do reg+offset, and wouldn't need
 
16619
             an extra register in that case, but it would need an extra
 
16620
-            register if the addressing is reg+reg or (reg+reg)&(-16).  */
 
16621
+            register if the addressing is reg+reg or (reg+reg)&(-16).  Special
 
16622
+            case load/store quad.  */
 
16623
          if (rclass == GENERAL_REGS || rclass == BASE_REGS)
 
16624
            {
 
16625
-             if (!legitimate_indirect_address_p (addr, false)
 
16626
-                 && !rs6000_legitimate_offset_address_p (TImode, addr,
 
16627
-                                                         false, true))
 
16628
+             if (TARGET_POWERPC64 && TARGET_QUAD_MEMORY
 
16629
+                 && GET_MODE_SIZE (mode) == 16
 
16630
+                 && quad_memory_operand (x, mode))
 
16631
                {
 
16632
                  sri->icode = icode;
 
16633
+                 sri->extra_cost = 2;
 
16634
+               }
 
16635
+
 
16636
+             else if (!legitimate_indirect_address_p (addr, false)
 
16637
+                      && !rs6000_legitimate_offset_address_p (PTImode, addr,
 
16638
+                                                              false, true))
 
16639
+               {
 
16640
+                 sri->icode = icode;
 
16641
                  /* account for splitting the loads, and converting the
 
16642
                     address from reg+reg to reg.  */
 
16643
                  sri->extra_cost = (((TARGET_64BIT) ? 3 : 5)
 
16644
                                     + ((GET_CODE (addr) == AND) ? 1 : 0));
 
16645
                }
 
16646
            }
 
16647
-         /* Loads to and stores from vector registers can only do reg+reg
 
16648
-            addressing.  Altivec registers can also do (reg+reg)&(-16).  */
 
16649
+         /* Allow scalar loads to/from the traditional floating point
 
16650
+            registers, even if VSX memory is set.  */
 
16651
+         else if ((rclass == FLOAT_REGS || rclass == NO_REGS)
 
16652
+                  && (GET_MODE_SIZE (mode) == 4 || GET_MODE_SIZE (mode) == 8)
 
16653
+                  && (legitimate_indirect_address_p (addr, false)
 
16654
+                      || legitimate_indirect_address_p (addr, false)
 
16655
+                      || rs6000_legitimate_offset_address_p (mode, addr,
 
16656
+                                                             false, true)))
 
16657
+
 
16658
+           ;
 
16659
+         /* Loads to and stores from vector registers can only do reg+reg
 
16660
+            addressing.  Altivec registers can also do (reg+reg)&(-16).  Allow
 
16661
+            scalar modes loading up the traditional floating point registers
 
16662
+            to use offset addresses.  */
 
16663
          else if (rclass == VSX_REGS || rclass == ALTIVEC_REGS
 
16664
                   || rclass == FLOAT_REGS || rclass == NO_REGS)
 
16665
            {
 
16666
@@ -13814,12 +15872,12 @@
 
16667
          else
 
16668
            {
 
16669
              enum reg_class xclass = REGNO_REG_CLASS (regno);
 
16670
-             enum reload_reg_type rtype1 = rs6000_reload_register_type (rclass);
 
16671
-             enum reload_reg_type rtype2 = rs6000_reload_register_type (xclass);
 
16672
+             enum rs6000_reg_type rtype1 = reg_class_to_reg_type[(int)rclass];
 
16673
+             enum rs6000_reg_type rtype2 = reg_class_to_reg_type[(int)xclass];
 
16674
 
 
16675
              /* If memory is needed, use default_secondary_reload to create the
 
16676
                 stack slot.  */
 
16677
-             if (rtype1 != rtype2 || rtype1 == OTHER_REGISTER_TYPE)
 
16678
+             if (rtype1 != rtype2 || !IS_STD_REG_TYPE (rtype1))
 
16679
                default_p = true;
 
16680
              else
 
16681
                ret = NO_REGS;
 
16682
@@ -13829,7 +15887,7 @@
 
16683
        default_p = true;
 
16684
     }
 
16685
   else if (TARGET_POWERPC64
 
16686
-          && rs6000_reload_register_type (rclass) == GPR_REGISTER_TYPE
 
16687
+          && reg_class_to_reg_type[(int)rclass] == GPR_REG_TYPE
 
16688
           && MEM_P (x)
 
16689
           && GET_MODE_SIZE (GET_MODE (x)) >= UNITS_PER_WORD)
 
16690
     {
 
16691
@@ -13868,7 +15926,7 @@
 
16692
        default_p = true;
 
16693
     }
 
16694
   else if (!TARGET_POWERPC64
 
16695
-          && rs6000_reload_register_type (rclass) == GPR_REGISTER_TYPE
 
16696
+          && reg_class_to_reg_type[(int)rclass] == GPR_REG_TYPE
 
16697
           && MEM_P (x)
 
16698
           && GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD)
 
16699
     {
 
16700
@@ -13946,6 +16004,36 @@
 
16701
   return ret;
 
16702
 }
 
16703
 
 
16704
+/* Better tracing for rs6000_secondary_reload_inner.  */
 
16705
+
 
16706
+static void
 
16707
+rs6000_secondary_reload_trace (int line, rtx reg, rtx mem, rtx scratch,
 
16708
+                              bool store_p)
 
16709
+{
 
16710
+  rtx set, clobber;
 
16711
+
 
16712
+  gcc_assert (reg != NULL_RTX && mem != NULL_RTX && scratch != NULL_RTX);
 
16713
+
 
16714
+  fprintf (stderr, "rs6000_secondary_reload_inner:%d, type = %s\n", line,
 
16715
+          store_p ? "store" : "load");
 
16716
+
 
16717
+  if (store_p)
 
16718
+    set = gen_rtx_SET (VOIDmode, mem, reg);
 
16719
+  else
 
16720
+    set = gen_rtx_SET (VOIDmode, reg, mem);
 
16721
+
 
16722
+  clobber = gen_rtx_CLOBBER (VOIDmode, scratch);
 
16723
+  debug_rtx (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, set, clobber)));
 
16724
+}
 
16725
+
 
16726
+static void
 
16727
+rs6000_secondary_reload_fail (int line, rtx reg, rtx mem, rtx scratch,
 
16728
+                             bool store_p)
 
16729
+{
 
16730
+  rs6000_secondary_reload_trace (line, reg, mem, scratch, store_p);
 
16731
+  gcc_unreachable ();
 
16732
+}
 
16733
+
 
16734
 /* Fixup reload addresses for Altivec or VSX loads/stores to change SP+offset
 
16735
    to SP+reg addressing.  */
 
16736
 
 
16737
@@ -13964,19 +16052,14 @@
 
16738
   rtx cc_clobber;
 
16739
 
 
16740
   if (TARGET_DEBUG_ADDR)
 
16741
-    {
 
16742
-      fprintf (stderr, "\nrs6000_secondary_reload_inner, type = %s\n",
 
16743
-              store_p ? "store" : "load");
 
16744
-      fprintf (stderr, "reg:\n");
 
16745
-      debug_rtx (reg);
 
16746
-      fprintf (stderr, "mem:\n");
 
16747
-      debug_rtx (mem);
 
16748
-      fprintf (stderr, "scratch:\n");
 
16749
-      debug_rtx (scratch);
 
16750
-    }
 
16751
+    rs6000_secondary_reload_trace (__LINE__, reg, mem, scratch, store_p);
 
16752
 
 
16753
-  gcc_assert (regno >= 0 && regno < FIRST_PSEUDO_REGISTER);
 
16754
-  gcc_assert (GET_CODE (mem) == MEM);
 
16755
+  if (regno < 0 || regno >= FIRST_PSEUDO_REGISTER)
 
16756
+    rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p);
 
16757
+
 
16758
+  if (GET_CODE (mem) != MEM)
 
16759
+    rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p);
 
16760
+
 
16761
   rclass = REGNO_REG_CLASS (regno);
 
16762
   addr = XEXP (mem, 0);
 
16763
 
 
16764
@@ -13995,19 +16078,24 @@
 
16765
       if (GET_CODE (addr) == PRE_MODIFY)
 
16766
        {
 
16767
          scratch_or_premodify = XEXP (addr, 0);
 
16768
-         gcc_assert (REG_P (scratch_or_premodify));
 
16769
-         gcc_assert (GET_CODE (XEXP (addr, 1)) == PLUS);
 
16770
+         if (!REG_P (scratch_or_premodify))
 
16771
+           rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p);
 
16772
+
 
16773
+         if (GET_CODE (XEXP (addr, 1)) != PLUS)
 
16774
+           rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p);
 
16775
+
 
16776
          addr = XEXP (addr, 1);
 
16777
        }
 
16778
 
 
16779
       if (GET_CODE (addr) == PLUS
 
16780
          && (and_op2 != NULL_RTX
 
16781
-             || !rs6000_legitimate_offset_address_p (TImode, addr,
 
16782
+             || !rs6000_legitimate_offset_address_p (PTImode, addr,
 
16783
                                                      false, true)))
 
16784
        {
 
16785
          addr_op1 = XEXP (addr, 0);
 
16786
          addr_op2 = XEXP (addr, 1);
 
16787
-         gcc_assert (legitimate_indirect_address_p (addr_op1, false));
 
16788
+         if (!legitimate_indirect_address_p (addr_op1, false))
 
16789
+           rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p);
 
16790
 
 
16791
          if (!REG_P (addr_op2)
 
16792
              && (GET_CODE (addr_op2) != CONST_INT
 
16793
@@ -14035,7 +16123,7 @@
 
16794
          scratch_or_premodify = scratch;
 
16795
        }
 
16796
       else if (!legitimate_indirect_address_p (addr, false)
 
16797
-              && !rs6000_legitimate_offset_address_p (TImode, addr,
 
16798
+              && !rs6000_legitimate_offset_address_p (PTImode, addr,
 
16799
                                                       false, true))
 
16800
        {
 
16801
          if (TARGET_DEBUG_ADDR)
 
16802
@@ -14051,9 +16139,21 @@
 
16803
        }
 
16804
       break;
 
16805
 
 
16806
-      /* Float/Altivec registers can only handle reg+reg addressing.  Move
 
16807
-        other addresses into a scratch register.  */
 
16808
+      /* Float registers can do offset+reg addressing for scalar types.  */
 
16809
     case FLOAT_REGS:
 
16810
+      if (legitimate_indirect_address_p (addr, false)  /* reg */
 
16811
+         || legitimate_indexed_address_p (addr, false) /* reg+reg */
 
16812
+         || ((GET_MODE_SIZE (mode) == 4 || GET_MODE_SIZE (mode) == 8)
 
16813
+             && and_op2 == NULL_RTX
 
16814
+             && scratch_or_premodify == scratch
 
16815
+             && rs6000_legitimate_offset_address_p (mode, addr, false, false)))
 
16816
+       break;
 
16817
+
 
16818
+      /* If this isn't a legacy floating point load/store, fall through to the
 
16819
+        VSX defaults.  */
 
16820
+
 
16821
+      /* VSX/Altivec registers can only handle reg+reg addressing.  Move other
 
16822
+        addresses into a scratch register.  */
 
16823
     case VSX_REGS:
 
16824
     case ALTIVEC_REGS:
 
16825
 
 
16826
@@ -14073,36 +16173,38 @@
 
16827
       /* If we aren't using a VSX load, save the PRE_MODIFY register and use it
 
16828
         as the address later.  */
 
16829
       if (GET_CODE (addr) == PRE_MODIFY
 
16830
-         && (!VECTOR_MEM_VSX_P (mode)
 
16831
+         && ((ALTIVEC_OR_VSX_VECTOR_MODE (mode)
 
16832
+              && (rclass != FLOAT_REGS
 
16833
+                  || (GET_MODE_SIZE (mode) != 4 && GET_MODE_SIZE (mode) != 8)))
 
16834
              || and_op2 != NULL_RTX
 
16835
              || !legitimate_indexed_address_p (XEXP (addr, 1), false)))
 
16836
        {
 
16837
          scratch_or_premodify = XEXP (addr, 0);
 
16838
-         gcc_assert (legitimate_indirect_address_p (scratch_or_premodify,
 
16839
-                                                    false));
 
16840
-         gcc_assert (GET_CODE (XEXP (addr, 1)) == PLUS);
 
16841
+         if (!legitimate_indirect_address_p (scratch_or_premodify, false))
 
16842
+           rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p);
 
16843
+
 
16844
+         if (GET_CODE (XEXP (addr, 1)) != PLUS)
 
16845
+           rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p);
 
16846
+
 
16847
          addr = XEXP (addr, 1);
 
16848
        }
 
16849
 
 
16850
       if (legitimate_indirect_address_p (addr, false)  /* reg */
 
16851
          || legitimate_indexed_address_p (addr, false) /* reg+reg */
 
16852
-         || GET_CODE (addr) == PRE_MODIFY              /* VSX pre-modify */
 
16853
          || (GET_CODE (addr) == AND                    /* Altivec memory */
 
16854
+             && rclass == ALTIVEC_REGS
 
16855
              && GET_CODE (XEXP (addr, 1)) == CONST_INT
 
16856
              && INTVAL (XEXP (addr, 1)) == -16
 
16857
-             && VECTOR_MEM_ALTIVEC_P (mode))
 
16858
-         || (rclass == FLOAT_REGS                      /* legacy float mem */
 
16859
-             && GET_MODE_SIZE (mode) == 8
 
16860
-             && and_op2 == NULL_RTX
 
16861
-             && scratch_or_premodify == scratch
 
16862
-             && rs6000_legitimate_offset_address_p (mode, addr, false, false)))
 
16863
+             && (legitimate_indirect_address_p (XEXP (addr, 0), false)
 
16864
+                 || legitimate_indexed_address_p (XEXP (addr, 0), false))))
 
16865
        ;
 
16866
 
 
16867
       else if (GET_CODE (addr) == PLUS)
 
16868
        {
 
16869
          addr_op1 = XEXP (addr, 0);
 
16870
          addr_op2 = XEXP (addr, 1);
 
16871
-         gcc_assert (REG_P (addr_op1));
 
16872
+         if (!REG_P (addr_op1))
 
16873
+           rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p);
 
16874
 
 
16875
          if (TARGET_DEBUG_ADDR)
 
16876
            {
 
16877
@@ -14121,7 +16223,8 @@
 
16878
        }
 
16879
 
 
16880
       else if (GET_CODE (addr) == SYMBOL_REF || GET_CODE (addr) == CONST
 
16881
-              || GET_CODE (addr) == CONST_INT || REG_P (addr))
 
16882
+              || GET_CODE (addr) == CONST_INT || GET_CODE (addr) == LO_SUM
 
16883
+              || REG_P (addr))
 
16884
        {
 
16885
          if (TARGET_DEBUG_ADDR)
 
16886
            {
 
16887
@@ -14137,12 +16240,12 @@
 
16888
        }
 
16889
 
 
16890
       else
 
16891
-       gcc_unreachable ();
 
16892
+       rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p);
 
16893
 
 
16894
       break;
 
16895
 
 
16896
     default:
 
16897
-      gcc_unreachable ();
 
16898
+      rs6000_secondary_reload_fail (__LINE__, reg, mem, scratch, store_p);
 
16899
     }
 
16900
 
 
16901
   /* If the original address involved a pre-modify that we couldn't use the VSX
 
16902
@@ -14189,7 +16292,7 @@
 
16903
   /* Adjust the address if it changed.  */
 
16904
   if (addr != XEXP (mem, 0))
 
16905
     {
 
16906
-      mem = change_address (mem, mode, addr);
 
16907
+      mem = replace_equiv_address_nv (mem, addr);
 
16908
       if (TARGET_DEBUG_ADDR)
 
16909
        fprintf (stderr, "\nrs6000_secondary_reload_inner, mem adjusted.\n");
 
16910
     }
 
16911
@@ -14254,8 +16357,10 @@
 
16912
   return;
 
16913
 }
 
16914
 
 
16915
-/* Allocate a 64-bit stack slot to be used for copying SDmode
 
16916
-   values through if this function has any SDmode references.  */
 
16917
+/* Allocate a 64-bit stack slot to be used for copying SDmode values through if
 
16918
+   this function has any SDmode references.  If we are on a power7 or later, we
 
16919
+   don't need the 64-bit stack slot since the LFIWZX and STIFWX instructions
 
16920
+   can load/store the value.  */
 
16921
 
 
16922
 static void
 
16923
 rs6000_alloc_sdmode_stack_slot (void)
 
16924
@@ -14266,6 +16371,9 @@
 
16925
 
 
16926
   gcc_assert (cfun->machine->sdmode_stack_slot == NULL_RTX);
 
16927
 
 
16928
+  if (TARGET_NO_SDMODE_STACK)
 
16929
+    return;
 
16930
+
 
16931
   FOR_EACH_BB (bb)
 
16932
     for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 
16933
       {
 
16934
@@ -14326,8 +16434,7 @@
 
16935
 {
 
16936
   enum machine_mode mode = GET_MODE (x);
 
16937
 
 
16938
-  if (VECTOR_UNIT_VSX_P (mode)
 
16939
-      && x == CONST0_RTX (mode) && VSX_REG_CLASS_P (rclass))
 
16940
+  if (TARGET_VSX && x == CONST0_RTX (mode) && VSX_REG_CLASS_P (rclass))
 
16941
     return rclass;
 
16942
 
 
16943
   if (VECTOR_UNIT_ALTIVEC_OR_VSX_P (mode)
 
16944
@@ -14382,60 +16489,45 @@
 
16945
    set and vice versa.  */
 
16946
 
 
16947
 static bool
 
16948
-rs6000_secondary_memory_needed (enum reg_class class1,
 
16949
-                               enum reg_class class2,
 
16950
+rs6000_secondary_memory_needed (enum reg_class from_class,
 
16951
+                               enum reg_class to_class,
 
16952
                                enum machine_mode mode)
 
16953
 {
 
16954
-  if (class1 == class2)
 
16955
-    return false;
 
16956
+  enum rs6000_reg_type from_type, to_type;
 
16957
+  bool altivec_p = ((from_class == ALTIVEC_REGS)
 
16958
+                   || (to_class == ALTIVEC_REGS));
 
16959
 
 
16960
-  /* Under VSX, there are 3 register classes that values could be in (VSX_REGS,
 
16961
-     ALTIVEC_REGS, and FLOAT_REGS).  We don't need to use memory to copy
 
16962
-     between these classes.  But we need memory for other things that can go in
 
16963
-     FLOAT_REGS like SFmode.  */
 
16964
-  if (TARGET_VSX
 
16965
-      && (VECTOR_MEM_VSX_P (mode) || VECTOR_UNIT_VSX_P (mode))
 
16966
-      && (class1 == VSX_REGS || class1 == ALTIVEC_REGS
 
16967
-         || class1 == FLOAT_REGS))
 
16968
-    return (class2 != VSX_REGS && class2 != ALTIVEC_REGS
 
16969
-           && class2 != FLOAT_REGS);
 
16970
+  /* If a simple/direct move is available, we don't need secondary memory  */
 
16971
+  from_type = reg_class_to_reg_type[(int)from_class];
 
16972
+  to_type = reg_class_to_reg_type[(int)to_class];
 
16973
 
 
16974
-  if (class1 == VSX_REGS || class2 == VSX_REGS)
 
16975
-    return true;
 
16976
+  if (rs6000_secondary_reload_move (to_type, from_type, mode,
 
16977
+                                   (secondary_reload_info *)0, altivec_p))
 
16978
+    return false;
 
16979
 
 
16980
-  if (class1 == FLOAT_REGS
 
16981
-      && (!TARGET_MFPGPR || !TARGET_POWERPC64
 
16982
-         || ((mode != DFmode)
 
16983
-             && (mode != DDmode)
 
16984
-             && (mode != DImode))))
 
16985
+  /* If we have a floating point or vector register class, we need to use
 
16986
+     memory to transfer the data.  */
 
16987
+  if (IS_FP_VECT_REG_TYPE (from_type) || IS_FP_VECT_REG_TYPE (to_type))
 
16988
     return true;
 
16989
 
 
16990
-  if (class2 == FLOAT_REGS
 
16991
-      && (!TARGET_MFPGPR || !TARGET_POWERPC64
 
16992
-         || ((mode != DFmode)
 
16993
-             && (mode != DDmode)
 
16994
-             && (mode != DImode))))
 
16995
-    return true;
 
16996
-
 
16997
-  if (class1 == ALTIVEC_REGS || class2 == ALTIVEC_REGS)
 
16998
-    return true;
 
16999
-
 
17000
   return false;
 
17001
 }
 
17002
 
 
17003
 /* Debug version of rs6000_secondary_memory_needed.  */
 
17004
 static bool
 
17005
-rs6000_debug_secondary_memory_needed (enum reg_class class1,
 
17006
-                                     enum reg_class class2,
 
17007
+rs6000_debug_secondary_memory_needed (enum reg_class from_class,
 
17008
+                                     enum reg_class to_class,
 
17009
                                      enum machine_mode mode)
 
17010
 {
 
17011
-  bool ret = rs6000_secondary_memory_needed (class1, class2, mode);
 
17012
+  bool ret = rs6000_secondary_memory_needed (from_class, to_class, mode);
 
17013
 
 
17014
   fprintf (stderr,
 
17015
-          "rs6000_secondary_memory_needed, return: %s, class1 = %s, "
 
17016
-          "class2 = %s, mode = %s\n",
 
17017
-          ret ? "true" : "false", reg_class_names[class1],
 
17018
-          reg_class_names[class2], GET_MODE_NAME (mode));
 
17019
+          "rs6000_secondary_memory_needed, return: %s, from_class = %s, "
 
17020
+          "to_class = %s, mode = %s\n",
 
17021
+          ret ? "true" : "false",
 
17022
+          reg_class_names[from_class],
 
17023
+          reg_class_names[to_class],
 
17024
+          GET_MODE_NAME (mode));
 
17025
 
 
17026
   return ret;
 
17027
 }
 
17028
@@ -14502,12 +16594,18 @@
 
17029
     return (mode != SDmode) ? NO_REGS : GENERAL_REGS;
 
17030
 
 
17031
   /* Memory, and FP/altivec registers can go into fp/altivec registers under
 
17032
-     VSX.  */
 
17033
+     VSX.  However, for scalar variables, use the traditional floating point
 
17034
+     registers so that we can use offset+register addressing.  */
 
17035
   if (TARGET_VSX
 
17036
       && (regno == -1 || VSX_REGNO_P (regno))
 
17037
       && VSX_REG_CLASS_P (rclass))
 
17038
-    return NO_REGS;
 
17039
+    {
 
17040
+      if (GET_MODE_SIZE (mode) < 16)
 
17041
+       return FLOAT_REGS;
 
17042
 
 
17043
+      return NO_REGS;
 
17044
+    }
 
17045
+
 
17046
   /* Memory, and AltiVec registers can go into AltiVec registers.  */
 
17047
   if ((regno == -1 || ALTIVEC_REGNO_P (regno))
 
17048
       && rclass == ALTIVEC_REGS)
 
17049
@@ -14551,8 +16649,42 @@
 
17050
   if (from_size != to_size)
 
17051
     {
 
17052
       enum reg_class xclass = (TARGET_VSX) ? VSX_REGS : FLOAT_REGS;
 
17053
-      return ((from_size < 8 || to_size < 8 || TARGET_IEEEQUAD)
 
17054
-             && reg_classes_intersect_p (xclass, rclass));
 
17055
+
 
17056
+      if (reg_classes_intersect_p (xclass, rclass))
 
17057
+       {
 
17058
+         unsigned to_nregs = hard_regno_nregs[FIRST_FPR_REGNO][to];
 
17059
+         unsigned from_nregs = hard_regno_nregs[FIRST_FPR_REGNO][from];
 
17060
+
 
17061
+         /* Don't allow 64-bit types to overlap with 128-bit types that take a
 
17062
+            single register under VSX because the scalar part of the register
 
17063
+            is in the upper 64-bits, and not the lower 64-bits.  Types like
 
17064
+            TFmode/TDmode that take 2 scalar register can overlap.  128-bit
 
17065
+            IEEE floating point can't overlap, and neither can small
 
17066
+            values.  */
 
17067
+
 
17068
+         if (TARGET_IEEEQUAD && (to == TFmode || from == TFmode))
 
17069
+           return true;
 
17070
+
 
17071
+         /* TDmode in floating-mode registers must always go into a register
 
17072
+            pair with the most significant word in the even-numbered register
 
17073
+            to match ISA requirements.  In little-endian mode, this does not
 
17074
+            match subreg numbering, so we cannot allow subregs.  */
 
17075
+         if (!BYTES_BIG_ENDIAN && (to == TDmode || from == TDmode))
 
17076
+           return true;
 
17077
+
 
17078
+         if (from_size < 8 || to_size < 8)
 
17079
+           return true;
 
17080
+
 
17081
+         if (from_size == 8 && (8 * to_nregs) != to_size)
 
17082
+           return true;
 
17083
+
 
17084
+         if (to_size == 8 && (8 * from_nregs) != from_size)
 
17085
+           return true;
 
17086
+
 
17087
+         return false;
 
17088
+       }
 
17089
+      else
 
17090
+       return false;
 
17091
     }
 
17092
 
 
17093
   if (TARGET_E500_DOUBLE
 
17094
@@ -14566,10 +16698,19 @@
 
17095
   /* Since the VSX register set includes traditional floating point registers
 
17096
      and altivec registers, just check for the size being different instead of
 
17097
      trying to check whether the modes are vector modes.  Otherwise it won't
 
17098
-     allow say DF and DI to change classes.  */
 
17099
+     allow say DF and DI to change classes.  For types like TFmode and TDmode
 
17100
+     that take 2 64-bit registers, rather than a single 128-bit register, don't
 
17101
+     allow subregs of those types to other 128 bit types.  */
 
17102
   if (TARGET_VSX && VSX_REG_CLASS_P (rclass))
 
17103
-    return (from_size != 8 && from_size != 16);
 
17104
+    {
 
17105
+      unsigned num_regs = (from_size + 15) / 16;
 
17106
+      if (hard_regno_nregs[FIRST_FPR_REGNO][to] > num_regs
 
17107
+         || hard_regno_nregs[FIRST_FPR_REGNO][from] > num_regs)
 
17108
+       return true;
 
17109
 
 
17110
+      return (from_size != 8 && from_size != 16);
 
17111
+    }
 
17112
+
 
17113
   if (TARGET_ALTIVEC && rclass == ALTIVEC_REGS
 
17114
       && (ALTIVEC_VECTOR_MODE (from) + ALTIVEC_VECTOR_MODE (to)) == 1)
 
17115
     return true;
 
17116
@@ -14599,6 +16740,161 @@
 
17117
   return ret;
 
17118
 }
 
17119
 
 
17120
+/* Return a string to do a move operation of 128 bits of data.  */
 
17121
+
 
17122
+const char *
 
17123
+rs6000_output_move_128bit (rtx operands[])
 
17124
+{
 
17125
+  rtx dest = operands[0];
 
17126
+  rtx src = operands[1];
 
17127
+  enum machine_mode mode = GET_MODE (dest);
 
17128
+  int dest_regno;
 
17129
+  int src_regno;
 
17130
+  bool dest_gpr_p, dest_fp_p, dest_vmx_p, dest_vsx_p;
 
17131
+  bool src_gpr_p, src_fp_p, src_vmx_p, src_vsx_p;
 
17132
+
 
17133
+  if (REG_P (dest))
 
17134
+    {
 
17135
+      dest_regno = REGNO (dest);
 
17136
+      dest_gpr_p = INT_REGNO_P (dest_regno);
 
17137
+      dest_fp_p = FP_REGNO_P (dest_regno);
 
17138
+      dest_vmx_p = ALTIVEC_REGNO_P (dest_regno);
 
17139
+      dest_vsx_p = dest_fp_p | dest_vmx_p;
 
17140
+    }
 
17141
+  else
 
17142
+    {
 
17143
+      dest_regno = -1;
 
17144
+      dest_gpr_p = dest_fp_p = dest_vmx_p = dest_vsx_p = false;
 
17145
+    }
 
17146
+
 
17147
+  if (REG_P (src))
 
17148
+    {
 
17149
+      src_regno = REGNO (src);
 
17150
+      src_gpr_p = INT_REGNO_P (src_regno);
 
17151
+      src_fp_p = FP_REGNO_P (src_regno);
 
17152
+      src_vmx_p = ALTIVEC_REGNO_P (src_regno);
 
17153
+      src_vsx_p = src_fp_p | src_vmx_p;
 
17154
+    }
 
17155
+  else
 
17156
+    {
 
17157
+      src_regno = -1;
 
17158
+      src_gpr_p = src_fp_p = src_vmx_p = src_vsx_p = false;
 
17159
+    }
 
17160
+
 
17161
+  /* Register moves.  */
 
17162
+  if (dest_regno >= 0 && src_regno >= 0)
 
17163
+    {
 
17164
+      if (dest_gpr_p)
 
17165
+       {
 
17166
+         if (src_gpr_p)
 
17167
+           return "#";
 
17168
+
 
17169
+         else if (TARGET_VSX && TARGET_DIRECT_MOVE && src_vsx_p)
 
17170
+           return "#";
 
17171
+       }
 
17172
+
 
17173
+      else if (TARGET_VSX && dest_vsx_p)
 
17174
+       {
 
17175
+         if (src_vsx_p)
 
17176
+           return "xxlor %x0,%x1,%x1";
 
17177
+
 
17178
+         else if (TARGET_DIRECT_MOVE && src_gpr_p)
 
17179
+           return "#";
 
17180
+       }
 
17181
+
 
17182
+      else if (TARGET_ALTIVEC && dest_vmx_p && src_vmx_p)
 
17183
+       return "vor %0,%1,%1";
 
17184
+
 
17185
+      else if (dest_fp_p && src_fp_p)
 
17186
+       return "#";
 
17187
+    }
 
17188
+
 
17189
+  /* Loads.  */
 
17190
+  else if (dest_regno >= 0 && MEM_P (src))
 
17191
+    {
 
17192
+      if (dest_gpr_p)
 
17193
+       {
 
17194
+         if (TARGET_QUAD_MEMORY && quad_load_store_p (dest, src))
 
17195
+           return "lq %0,%1";
 
17196
+         else
 
17197
+           return "#";
 
17198
+       }
 
17199
+
 
17200
+      else if (TARGET_ALTIVEC && dest_vmx_p
 
17201
+              && altivec_indexed_or_indirect_operand (src, mode))
 
17202
+       return "lvx %0,%y1";
 
17203
+
 
17204
+      else if (TARGET_VSX && dest_vsx_p)
 
17205
+       {
 
17206
+         if (mode == V16QImode || mode == V8HImode || mode == V4SImode)
 
17207
+           return "lxvw4x %x0,%y1";
 
17208
+         else
 
17209
+           return "lxvd2x %x0,%y1";
 
17210
+       }
 
17211
+
 
17212
+      else if (TARGET_ALTIVEC && dest_vmx_p)
 
17213
+       return "lvx %0,%y1";
 
17214
+
 
17215
+      else if (dest_fp_p)
 
17216
+       return "#";
 
17217
+    }
 
17218
+
 
17219
+  /* Stores.  */
 
17220
+  else if (src_regno >= 0 && MEM_P (dest))
 
17221
+    {
 
17222
+      if (src_gpr_p)
 
17223
+       {
 
17224
+         if (TARGET_QUAD_MEMORY && quad_load_store_p (dest, src))
 
17225
+           return "stq %1,%0";
 
17226
+         else
 
17227
+           return "#";
 
17228
+       }
 
17229
+
 
17230
+      else if (TARGET_ALTIVEC && src_vmx_p
 
17231
+              && altivec_indexed_or_indirect_operand (src, mode))
 
17232
+       return "stvx %1,%y0";
 
17233
+
 
17234
+      else if (TARGET_VSX && src_vsx_p)
 
17235
+       {
 
17236
+         if (mode == V16QImode || mode == V8HImode || mode == V4SImode)
 
17237
+           return "stxvw4x %x1,%y0";
 
17238
+         else
 
17239
+           return "stxvd2x %x1,%y0";
 
17240
+       }
 
17241
+
 
17242
+      else if (TARGET_ALTIVEC && src_vmx_p)
 
17243
+       return "stvx %1,%y0";
 
17244
+
 
17245
+      else if (src_fp_p)
 
17246
+       return "#";
 
17247
+    }
 
17248
+
 
17249
+  /* Constants.  */
 
17250
+  else if (dest_regno >= 0
 
17251
+          && (GET_CODE (src) == CONST_INT
 
17252
+              || GET_CODE (src) == CONST_DOUBLE
 
17253
+              || GET_CODE (src) == CONST_VECTOR))
 
17254
+    {
 
17255
+      if (dest_gpr_p)
 
17256
+       return "#";
 
17257
+
 
17258
+      else if (TARGET_VSX && dest_vsx_p && zero_constant (src, mode))
 
17259
+       return "xxlxor %x0,%x0,%x0";
 
17260
+
 
17261
+      else if (TARGET_ALTIVEC && dest_vmx_p)
 
17262
+       return output_vec_const_move (operands);
 
17263
+    }
 
17264
+
 
17265
+  if (TARGET_DEBUG_ADDR)
 
17266
+    {
 
17267
+      fprintf (stderr, "\n===== Bad 128 bit move:\n");
 
17268
+      debug_rtx (gen_rtx_SET (VOIDmode, dest, src));
 
17269
+    }
 
17270
+
 
17271
+  gcc_unreachable ();
 
17272
+}
 
17273
+
 
17274
+
 
17275
 /* Given a comparison operation, return the bit number in CCR to test.  We
 
17276
    know this is a valid comparison.
 
17277
 
 
17278
@@ -14824,6 +17120,7 @@
 
17279
            ASM_OUTPUT_INTERNAL_LABEL_PREFIX (file, "L.");
 
17280
          break;
 
17281
 
 
17282
+       case ABI_ELFv2:
 
17283
        case ABI_V4:
 
17284
        case ABI_DARWIN:
 
17285
          break;
 
17286
@@ -15303,7 +17600,7 @@
 
17287
       return;
 
17288
 
 
17289
     case 'Y':
 
17290
-      /* Like 'L', for third word of TImode  */
 
17291
+      /* Like 'L', for third word of TImode/PTImode  */
 
17292
       if (REG_P (x))
 
17293
        fputs (reg_names[REGNO (x) + 2], file);
 
17294
       else if (MEM_P (x))
 
17295
@@ -15353,7 +17650,7 @@
 
17296
       return;
 
17297
 
 
17298
     case 'Z':
 
17299
-      /* Like 'L', for last word of TImode.  */
 
17300
+      /* Like 'L', for last word of TImode/PTImode.  */
 
17301
       if (REG_P (x))
 
17302
        fputs (reg_names[REGNO (x) + 3], file);
 
17303
       else if (MEM_P (x))
 
17304
@@ -15384,7 +17681,8 @@
 
17305
        if ((TARGET_SPE || TARGET_E500_DOUBLE)
 
17306
            && (GET_MODE_SIZE (GET_MODE (x)) == 8
 
17307
                || GET_MODE (x) == TFmode
 
17308
-               || GET_MODE (x) == TImode))
 
17309
+               || GET_MODE (x) == TImode
 
17310
+               || GET_MODE (x) == PTImode))
 
17311
          {
 
17312
            /* Handle [reg].  */
 
17313
            if (REG_P (tmp))
 
17314
@@ -16767,7 +19065,8 @@
 
17315
 }
 
17316
 
 
17317
 /* A subroutine of the atomic operation splitters.  Emit a load-locked
 
17318
-   instruction in MODE.  */
 
17319
+   instruction in MODE.  For QI/HImode, possibly use a pattern than includes
 
17320
+   the zero_extend operation.  */
 
17321
 
 
17322
 static void
 
17323
 emit_load_locked (enum machine_mode mode, rtx reg, rtx mem)
 
17324
@@ -16776,12 +19075,26 @@
 
17325
 
 
17326
   switch (mode)
 
17327
     {
 
17328
+    case QImode:
 
17329
+      fn = gen_load_lockedqi;
 
17330
+      break;
 
17331
+    case HImode:
 
17332
+      fn = gen_load_lockedhi;
 
17333
+      break;
 
17334
     case SImode:
 
17335
-      fn = gen_load_lockedsi;
 
17336
+      if (GET_MODE (mem) == QImode)
 
17337
+       fn = gen_load_lockedqi_si;
 
17338
+      else if (GET_MODE (mem) == HImode)
 
17339
+       fn = gen_load_lockedhi_si;
 
17340
+      else
 
17341
+       fn = gen_load_lockedsi;
 
17342
       break;
 
17343
     case DImode:
 
17344
       fn = gen_load_lockeddi;
 
17345
       break;
 
17346
+    case TImode:
 
17347
+      fn = gen_load_lockedti;
 
17348
+      break;
 
17349
     default:
 
17350
       gcc_unreachable ();
 
17351
     }
 
17352
@@ -16798,12 +19111,21 @@
 
17353
 
 
17354
   switch (mode)
 
17355
     {
 
17356
+    case QImode:
 
17357
+      fn = gen_store_conditionalqi;
 
17358
+      break;
 
17359
+    case HImode:
 
17360
+      fn = gen_store_conditionalhi;
 
17361
+      break;
 
17362
     case SImode:
 
17363
       fn = gen_store_conditionalsi;
 
17364
       break;
 
17365
     case DImode:
 
17366
       fn = gen_store_conditionaldi;
 
17367
       break;
 
17368
+    case TImode:
 
17369
+      fn = gen_store_conditionalti;
 
17370
+      break;
 
17371
     default:
 
17372
       gcc_unreachable ();
 
17373
     }
 
17374
@@ -16950,7 +19272,7 @@
 
17375
 {
 
17376
   rtx boolval, retval, mem, oldval, newval, cond;
 
17377
   rtx label1, label2, x, mask, shift;
 
17378
-  enum machine_mode mode;
 
17379
+  enum machine_mode mode, orig_mode;
 
17380
   enum memmodel mod_s, mod_f;
 
17381
   bool is_weak;
 
17382
 
 
17383
@@ -16962,23 +19284,30 @@
 
17384
   is_weak = (INTVAL (operands[5]) != 0);
 
17385
   mod_s = (enum memmodel) INTVAL (operands[6]);
 
17386
   mod_f = (enum memmodel) INTVAL (operands[7]);
 
17387
-  mode = GET_MODE (mem);
 
17388
+  orig_mode = mode = GET_MODE (mem);
 
17389
 
 
17390
   mask = shift = NULL_RTX;
 
17391
   if (mode == QImode || mode == HImode)
 
17392
     {
 
17393
-      mem = rs6000_adjust_atomic_subword (mem, &shift, &mask);
 
17394
-
 
17395
-      /* Shift and mask OLDVAL into position with the word.  */
 
17396
+      /* Before power8, we didn't have access to lbarx/lharx, so generate a
 
17397
+        lwarx and shift/mask operations.  With power8, we need to do the
 
17398
+        comparison in SImode, but the store is still done in QI/HImode.  */
 
17399
       oldval = convert_modes (SImode, mode, oldval, 1);
 
17400
-      oldval = expand_simple_binop (SImode, ASHIFT, oldval, shift,
 
17401
-                                   NULL_RTX, 1, OPTAB_LIB_WIDEN);
 
17402
 
 
17403
-      /* Shift and mask NEWVAL into position within the word.  */
 
17404
-      newval = convert_modes (SImode, mode, newval, 1);
 
17405
-      newval = expand_simple_binop (SImode, ASHIFT, newval, shift,
 
17406
-                                   NULL_RTX, 1, OPTAB_LIB_WIDEN);
 
17407
+      if (!TARGET_SYNC_HI_QI)
 
17408
+       {
 
17409
+         mem = rs6000_adjust_atomic_subword (mem, &shift, &mask);
 
17410
 
 
17411
+         /* Shift and mask OLDVAL into position with the word.  */
 
17412
+         oldval = expand_simple_binop (SImode, ASHIFT, oldval, shift,
 
17413
+                                       NULL_RTX, 1, OPTAB_LIB_WIDEN);
 
17414
+
 
17415
+         /* Shift and mask NEWVAL into position within the word.  */
 
17416
+         newval = convert_modes (SImode, mode, newval, 1);
 
17417
+         newval = expand_simple_binop (SImode, ASHIFT, newval, shift,
 
17418
+                                       NULL_RTX, 1, OPTAB_LIB_WIDEN);
 
17419
+       }
 
17420
+
 
17421
       /* Prepare to adjust the return value.  */
 
17422
       retval = gen_reg_rtx (SImode);
 
17423
       mode = SImode;
 
17424
@@ -17006,7 +19335,25 @@
 
17425
     }
 
17426
 
 
17427
   cond = gen_reg_rtx (CCmode);
 
17428
-  x = gen_rtx_COMPARE (CCmode, x, oldval);
 
17429
+  /* If we have TImode, synthesize a comparison.  */
 
17430
+  if (mode != TImode)
 
17431
+    x = gen_rtx_COMPARE (CCmode, x, oldval);
 
17432
+  else
 
17433
+    {
 
17434
+      rtx xor1_result = gen_reg_rtx (DImode);
 
17435
+      rtx xor2_result = gen_reg_rtx (DImode);
 
17436
+      rtx or_result = gen_reg_rtx (DImode);
 
17437
+      rtx new_word0 = simplify_gen_subreg (DImode, x, TImode, 0);
 
17438
+      rtx new_word1 = simplify_gen_subreg (DImode, x, TImode, 8);
 
17439
+      rtx old_word0 = simplify_gen_subreg (DImode, oldval, TImode, 0);
 
17440
+      rtx old_word1 = simplify_gen_subreg (DImode, oldval, TImode, 8);
 
17441
+
 
17442
+      emit_insn (gen_xordi3 (xor1_result, new_word0, old_word0));
 
17443
+      emit_insn (gen_xordi3 (xor2_result, new_word1, old_word1));
 
17444
+      emit_insn (gen_iordi3 (or_result, xor1_result, xor2_result));
 
17445
+      x = gen_rtx_COMPARE (CCmode, or_result, const0_rtx);
 
17446
+    }
 
17447
+
 
17448
   emit_insn (gen_rtx_SET (VOIDmode, cond, x));
 
17449
 
 
17450
   x = gen_rtx_NE (VOIDmode, cond, const0_rtx);
 
17451
@@ -17016,7 +19363,7 @@
 
17452
   if (mask)
 
17453
     x = rs6000_mask_atomic_subword (retval, newval, mask);
 
17454
 
 
17455
-  emit_store_conditional (mode, cond, mem, x);
 
17456
+  emit_store_conditional (orig_mode, cond, mem, x);
 
17457
 
 
17458
   if (!is_weak)
 
17459
     {
 
17460
@@ -17034,6 +19381,8 @@
 
17461
 
 
17462
   if (shift)
 
17463
     rs6000_finish_atomic_subword (operands[1], retval, shift);
 
17464
+  else if (mode != GET_MODE (operands[1]))
 
17465
+    convert_move (operands[1], retval, 1);
 
17466
 
 
17467
   /* In all cases, CR0 contains EQ on success, and NE on failure.  */
 
17468
   x = gen_rtx_EQ (SImode, cond, const0_rtx);
 
17469
@@ -17057,7 +19406,7 @@
 
17470
   mode = GET_MODE (mem);
 
17471
 
 
17472
   mask = shift = NULL_RTX;
 
17473
-  if (mode == QImode || mode == HImode)
 
17474
+  if (!TARGET_SYNC_HI_QI && (mode == QImode || mode == HImode))
 
17475
     {
 
17476
       mem = rs6000_adjust_atomic_subword (mem, &shift, &mask);
 
17477
 
 
17478
@@ -17106,53 +19455,70 @@
 
17479
 {
 
17480
   enum memmodel model = (enum memmodel) INTVAL (model_rtx);
 
17481
   enum machine_mode mode = GET_MODE (mem);
 
17482
+  enum machine_mode store_mode = mode;
 
17483
   rtx label, x, cond, mask, shift;
 
17484
   rtx before = orig_before, after = orig_after;
 
17485
 
 
17486
   mask = shift = NULL_RTX;
 
17487
+  /* On power8, we want to use SImode for the operation.  On previous systems,
 
17488
+     use the operation in a subword and shift/mask to get the proper byte or
 
17489
+     halfword.  */
 
17490
   if (mode == QImode || mode == HImode)
 
17491
     {
 
17492
-      mem = rs6000_adjust_atomic_subword (mem, &shift, &mask);
 
17493
+      if (TARGET_SYNC_HI_QI)
 
17494
+       {
 
17495
+         val = convert_modes (SImode, mode, val, 1);
 
17496
 
 
17497
-      /* Shift and mask VAL into position with the word.  */
 
17498
-      val = convert_modes (SImode, mode, val, 1);
 
17499
-      val = expand_simple_binop (SImode, ASHIFT, val, shift,
 
17500
-                                NULL_RTX, 1, OPTAB_LIB_WIDEN);
 
17501
-
 
17502
-      switch (code)
 
17503
+         /* Prepare to adjust the return value.  */
 
17504
+         before = gen_reg_rtx (SImode);
 
17505
+         if (after)
 
17506
+           after = gen_reg_rtx (SImode);
 
17507
+         mode = SImode;
 
17508
+       }
 
17509
+      else
 
17510
        {
 
17511
-       case IOR:
 
17512
-       case XOR:
 
17513
-         /* We've already zero-extended VAL.  That is sufficient to
 
17514
-            make certain that it does not affect other bits.  */
 
17515
-         mask = NULL;
 
17516
-         break;
 
17517
+         mem = rs6000_adjust_atomic_subword (mem, &shift, &mask);
 
17518
 
 
17519
-       case AND:
 
17520
-         /* If we make certain that all of the other bits in VAL are
 
17521
-            set, that will be sufficient to not affect other bits.  */
 
17522
-         x = gen_rtx_NOT (SImode, mask);
 
17523
-         x = gen_rtx_IOR (SImode, x, val);
 
17524
-         emit_insn (gen_rtx_SET (VOIDmode, val, x));
 
17525
-         mask = NULL;
 
17526
-         break;
 
17527
+         /* Shift and mask VAL into position with the word.  */
 
17528
+         val = convert_modes (SImode, mode, val, 1);
 
17529
+         val = expand_simple_binop (SImode, ASHIFT, val, shift,
 
17530
+                                    NULL_RTX, 1, OPTAB_LIB_WIDEN);
 
17531
 
 
17532
-       case NOT:
 
17533
-       case PLUS:
 
17534
-       case MINUS:
 
17535
-         /* These will all affect bits outside the field and need
 
17536
-            adjustment via MASK within the loop.  */
 
17537
-         break;
 
17538
+         switch (code)
 
17539
+           {
 
17540
+           case IOR:
 
17541
+           case XOR:
 
17542
+             /* We've already zero-extended VAL.  That is sufficient to
 
17543
+                make certain that it does not affect other bits.  */
 
17544
+             mask = NULL;
 
17545
+             break;
 
17546
 
 
17547
-       default:
 
17548
-         gcc_unreachable ();
 
17549
+           case AND:
 
17550
+             /* If we make certain that all of the other bits in VAL are
 
17551
+                set, that will be sufficient to not affect other bits.  */
 
17552
+             x = gen_rtx_NOT (SImode, mask);
 
17553
+             x = gen_rtx_IOR (SImode, x, val);
 
17554
+             emit_insn (gen_rtx_SET (VOIDmode, val, x));
 
17555
+             mask = NULL;
 
17556
+             break;
 
17557
+
 
17558
+           case NOT:
 
17559
+           case PLUS:
 
17560
+           case MINUS:
 
17561
+             /* These will all affect bits outside the field and need
 
17562
+                adjustment via MASK within the loop.  */
 
17563
+             break;
 
17564
+
 
17565
+           default:
 
17566
+             gcc_unreachable ();
 
17567
+           }
 
17568
+
 
17569
+         /* Prepare to adjust the return value.  */
 
17570
+         before = gen_reg_rtx (SImode);
 
17571
+         if (after)
 
17572
+           after = gen_reg_rtx (SImode);
 
17573
+         store_mode = mode = SImode;
 
17574
        }
 
17575
-
 
17576
-      /* Prepare to adjust the return value.  */
 
17577
-      before = gen_reg_rtx (SImode);
 
17578
-      if (after)
 
17579
-       after = gen_reg_rtx (SImode);
 
17580
-      mode = SImode;
 
17581
     }
 
17582
 
 
17583
   mem = rs6000_pre_atomic_barrier (mem, model);
 
17584
@@ -17185,9 +19551,11 @@
 
17585
                               NULL_RTX, 1, OPTAB_LIB_WIDEN);
 
17586
       x = rs6000_mask_atomic_subword (before, x, mask);
 
17587
     }
 
17588
+  else if (store_mode != mode)
 
17589
+    x = convert_modes (store_mode, mode, x, 1);
 
17590
 
 
17591
   cond = gen_reg_rtx (CCmode);
 
17592
-  emit_store_conditional (mode, cond, mem, x);
 
17593
+  emit_store_conditional (store_mode, cond, mem, x);
 
17594
 
 
17595
   x = gen_rtx_NE (VOIDmode, cond, const0_rtx);
 
17596
   emit_unlikely_jump (x, label);
 
17597
@@ -17196,11 +19564,22 @@
 
17598
 
 
17599
   if (shift)
 
17600
     {
 
17601
+      /* QImode/HImode on machines without lbarx/lharx where we do a lwarx and
 
17602
+        then do the calcuations in a SImode register.  */
 
17603
       if (orig_before)
 
17604
        rs6000_finish_atomic_subword (orig_before, before, shift);
 
17605
       if (orig_after)
 
17606
        rs6000_finish_atomic_subword (orig_after, after, shift);
 
17607
     }
 
17608
+  else if (store_mode != mode)
 
17609
+    {
 
17610
+      /* QImode/HImode on machines with lbarx/lharx where we do the native
 
17611
+        operation and then do the calcuations in a SImode register.  */
 
17612
+      if (orig_before)
 
17613
+       convert_move (orig_before, before, 1);
 
17614
+      if (orig_after)
 
17615
+       convert_move (orig_after, after, 1);
 
17616
+    }
 
17617
   else if (orig_after && after != orig_after)
 
17618
     emit_move_insn (orig_after, after);
 
17619
 }
 
17620
@@ -17240,6 +19619,39 @@
 
17621
 
 
17622
   gcc_assert (reg_mode_size * nregs == GET_MODE_SIZE (mode));
 
17623
 
 
17624
+  /* TDmode residing in FP registers is special, since the ISA requires that
 
17625
+     the lower-numbered word of a register pair is always the most significant
 
17626
+     word, even in little-endian mode.  This does not match the usual subreg
 
17627
+     semantics, so we cannnot use simplify_gen_subreg in those cases.  Access
 
17628
+     the appropriate constituent registers "by hand" in little-endian mode.
 
17629
+
 
17630
+     Note we do not need to check for destructive overlap here since TDmode
 
17631
+     can only reside in even/odd register pairs.  */
 
17632
+  if (FP_REGNO_P (reg) && DECIMAL_FLOAT_MODE_P (mode) && !BYTES_BIG_ENDIAN)
 
17633
+    {
 
17634
+      rtx p_src, p_dst;
 
17635
+      int i;
 
17636
+
 
17637
+      for (i = 0; i < nregs; i++)
 
17638
+       {
 
17639
+         if (REG_P (src) && FP_REGNO_P (REGNO (src)))
 
17640
+           p_src = gen_rtx_REG (reg_mode, REGNO (src) + nregs - 1 - i);
 
17641
+         else
 
17642
+           p_src = simplify_gen_subreg (reg_mode, src, mode,
 
17643
+                                        i * reg_mode_size);
 
17644
+
 
17645
+         if (REG_P (dst) && FP_REGNO_P (REGNO (dst)))
 
17646
+           p_dst = gen_rtx_REG (reg_mode, REGNO (dst) + nregs - 1 - i);
 
17647
+         else
 
17648
+           p_dst = simplify_gen_subreg (reg_mode, dst, mode,
 
17649
+                                        i * reg_mode_size);
 
17650
+
 
17651
+         emit_insn (gen_rtx_SET (VOIDmode, p_dst, p_src));
 
17652
+       }
 
17653
+
 
17654
+      return;
 
17655
+    }
 
17656
+
 
17657
   if (REG_P (src) && REG_P (dst) && (REGNO (src) < REGNO (dst)))
 
17658
     {
 
17659
       /* Move register range backwards, if we might have destructive
 
17660
@@ -17694,7 +20106,7 @@
 
17661
     }
 
17662
   else
 
17663
     {
 
17664
-      gcc_checking_assert (DEFAULT_ABI == ABI_AIX);
 
17665
+      gcc_checking_assert (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2);
 
17666
       if (info->first_fp_reg_save > 61)
 
17667
        strategy |= SAVE_INLINE_FPRS | REST_INLINE_FPRS;
 
17668
       strategy |= SAVE_INLINE_GPRS | REST_INLINE_GPRS;
 
17669
@@ -17705,7 +20117,8 @@
 
17670
      by the static chain.  It would require too much fiddling and the
 
17671
      static chain is rarely used anyway.  FPRs are saved w.r.t the stack
 
17672
      pointer on Darwin, and AIX uses r1 or r12.  */
 
17673
-  if (using_static_chain_p && DEFAULT_ABI != ABI_AIX)
 
17674
+  if (using_static_chain_p
 
17675
+      && (DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_DARWIN))
 
17676
     strategy |= ((DEFAULT_ABI == ABI_DARWIN ? 0 : SAVE_INLINE_FPRS)
 
17677
                 | SAVE_INLINE_GPRS
 
17678
                 | SAVE_INLINE_VRS | REST_INLINE_VRS);
 
17679
@@ -17838,7 +20251,35 @@
 
17680
    The required alignment for AIX configurations is two words (i.e., 8
 
17681
    or 16 bytes).
 
17682
 
 
17683
+   The ELFv2 ABI is a variant of the AIX ABI.  Stack frames look like:
 
17684
 
 
17685
+       SP----> +---------------------------------------+
 
17686
+               | Back chain to caller                  |  0
 
17687
+               +---------------------------------------+
 
17688
+               | Save area for CR                      |  8
 
17689
+               +---------------------------------------+
 
17690
+               | Saved LR                              |  16
 
17691
+               +---------------------------------------+
 
17692
+               | Saved TOC pointer                     |  24
 
17693
+               +---------------------------------------+
 
17694
+               | Parameter save area (P)               |  32
 
17695
+               +---------------------------------------+
 
17696
+               | Alloca space (A)                      |  32+P
 
17697
+               +---------------------------------------+
 
17698
+               | Local variable space (L)              |  32+P+A
 
17699
+               +---------------------------------------+
 
17700
+               | Save area for AltiVec registers (W)   |  32+P+A+L
 
17701
+               +---------------------------------------+
 
17702
+               | AltiVec alignment padding (Y)         |  32+P+A+L+W
 
17703
+               +---------------------------------------+
 
17704
+               | Save area for GP registers (G)        |  32+P+A+L+W+Y
 
17705
+               +---------------------------------------+
 
17706
+               | Save area for FP registers (F)        |  32+P+A+L+W+Y+G
 
17707
+               +---------------------------------------+
 
17708
+       old SP->| back chain to caller's caller         |  32+P+A+L+W+Y+G+F
 
17709
+               +---------------------------------------+
 
17710
+
 
17711
+
 
17712
    V.4 stack frames look like:
 
17713
 
 
17714
        SP----> +---------------------------------------+
 
17715
@@ -17898,6 +20339,7 @@
 
17716
   rs6000_stack_t *info_ptr = &stack_info;
 
17717
   int reg_size = TARGET_32BIT ? 4 : 8;
 
17718
   int ehrd_size;
 
17719
+  int ehcr_size;
 
17720
   int save_align;
 
17721
   int first_gp;
 
17722
   HOST_WIDE_INT non_fixed_size;
 
17723
@@ -17991,6 +20433,18 @@
 
17724
   else
 
17725
     ehrd_size = 0;
 
17726
 
 
17727
+  /* In the ELFv2 ABI, we also need to allocate space for separate
 
17728
+     CR field save areas if the function calls __builtin_eh_return.  */
 
17729
+  if (DEFAULT_ABI == ABI_ELFv2 && crtl->calls_eh_return)
 
17730
+    {
 
17731
+      /* This hard-codes that we have three call-saved CR fields.  */
 
17732
+      ehcr_size = 3 * reg_size;
 
17733
+      /* We do *not* use the regular CR save mechanism.  */
 
17734
+      info_ptr->cr_save_p = 0;
 
17735
+    }
 
17736
+  else
 
17737
+    ehcr_size = 0;
 
17738
+
 
17739
   /* Determine various sizes.  */
 
17740
   info_ptr->reg_size     = reg_size;
 
17741
   info_ptr->fixed_size   = RS6000_SAVE_AREA;
 
17742
@@ -18030,6 +20484,7 @@
 
17743
       gcc_unreachable ();
 
17744
 
 
17745
     case ABI_AIX:
 
17746
+    case ABI_ELFv2:
 
17747
     case ABI_DARWIN:
 
17748
       info_ptr->fp_save_offset   = - info_ptr->fp_size;
 
17749
       info_ptr->gp_save_offset   = info_ptr->fp_save_offset - info_ptr->gp_size;
 
17750
@@ -18059,6 +20514,8 @@
 
17751
        }
 
17752
       else
 
17753
        info_ptr->ehrd_offset      = info_ptr->gp_save_offset - ehrd_size;
 
17754
+
 
17755
+      info_ptr->ehcr_offset      = info_ptr->ehrd_offset - ehcr_size;
 
17756
       info_ptr->cr_save_offset   = reg_size; /* first word when 64-bit.  */
 
17757
       info_ptr->lr_save_offset   = 2*reg_size;
 
17758
       break;
 
17759
@@ -18121,6 +20578,7 @@
 
17760
                                         + info_ptr->spe_gp_size
 
17761
                                         + info_ptr->spe_padding_size
 
17762
                                         + ehrd_size
 
17763
+                                        + ehcr_size
 
17764
                                         + info_ptr->cr_size
 
17765
                                         + info_ptr->vrsave_size,
 
17766
                                         save_align);
 
17767
@@ -18134,7 +20592,7 @@
 
17768
 
 
17769
   /* Determine if we need to save the link register.  */
 
17770
   if (info_ptr->calls_p
 
17771
-      || (DEFAULT_ABI == ABI_AIX
 
17772
+      || ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
17773
          && crtl->profile
 
17774
          && !TARGET_PROFILE_KERNEL)
 
17775
       || (DEFAULT_ABI == ABI_V4 && cfun->calls_alloca)
 
17776
@@ -18280,6 +20738,7 @@
 
17777
     default:            abi_string = "Unknown";        break;
 
17778
     case ABI_NONE:      abi_string = "NONE";           break;
 
17779
     case ABI_AIX:       abi_string = "AIX";            break;
 
17780
+    case ABI_ELFv2:     abi_string = "ELFv2";          break;
 
17781
     case ABI_DARWIN:    abi_string = "Darwin";         break;
 
17782
     case ABI_V4:        abi_string = "V.4";            break;
 
17783
     }
 
17784
@@ -18401,7 +20860,8 @@
 
17785
   /* Currently we don't optimize very well between prolog and body
 
17786
      code and for PIC code the code can be actually quite bad, so
 
17787
      don't try to be too clever here.  */
 
17788
-  if (count != 0 || (DEFAULT_ABI != ABI_AIX && flag_pic))
 
17789
+  if (count != 0
 
17790
+      || ((DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_DARWIN) && flag_pic))
 
17791
     {
 
17792
       cfun->machine->ra_needs_full_frame = 1;
 
17793
 
 
17794
@@ -18460,13 +20920,13 @@
 
17795
        return false;
 
17796
     }
 
17797
 
 
17798
-  /* Under the AIX ABI we can't allow calls to non-local functions,
 
17799
-     because the callee may have a different TOC pointer to the
 
17800
-     caller and there's no way to ensure we restore the TOC when we
 
17801
-     return.  With the secure-plt SYSV ABI we can't make non-local
 
17802
+  /* Under the AIX or ELFv2 ABIs we can't allow calls to non-local
 
17803
+     functions, because the callee may have a different TOC pointer to
 
17804
+     the caller and there's no way to ensure we restore the TOC when
 
17805
+     we return.  With the secure-plt SYSV ABI we can't make non-local
 
17806
      calls when -fpic/PIC because the plt call stubs use r30.  */
 
17807
   if (DEFAULT_ABI == ABI_DARWIN
 
17808
-      || (DEFAULT_ABI == ABI_AIX
 
17809
+      || ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
17810
          && decl
 
17811
          && !DECL_EXTERNAL (decl)
 
17812
          && (*targetm.binds_local_p) (decl))
 
17813
@@ -18567,7 +21027,7 @@
 
17814
   rtx dest;
 
17815
   dest = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
 
17816
 
 
17817
-  if (TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI != ABI_AIX && flag_pic)
 
17818
+  if (TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI == ABI_V4 && flag_pic)
 
17819
     {
 
17820
       char buf[30];
 
17821
       rtx lab, tmp1, tmp2, got;
 
17822
@@ -18595,7 +21055,7 @@
 
17823
       emit_insn (gen_load_toc_v4_pic_si ());
 
17824
       emit_move_insn (dest, gen_rtx_REG (Pmode, LR_REGNO));
 
17825
     }
 
17826
-  else if (TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2)
 
17827
+  else if (TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 2)
 
17828
     {
 
17829
       char buf[30];
 
17830
       rtx temp0 = (fromprolog
 
17831
@@ -18643,7 +21103,7 @@
 
17832
     }
 
17833
   else
 
17834
     {
 
17835
-      gcc_assert (DEFAULT_ABI == ABI_AIX);
 
17836
+      gcc_assert (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2);
 
17837
 
 
17838
       if (TARGET_32BIT)
 
17839
        emit_insn (gen_load_toc_aix_si (dest));
 
17840
@@ -19048,7 +21508,7 @@
 
17841
 
 
17842
 static rtx
 
17843
 rs6000_frame_related (rtx insn, rtx reg, HOST_WIDE_INT val,
 
17844
-                     rtx reg2, rtx rreg)
 
17845
+                     rtx reg2, rtx rreg, rtx split_reg)
 
17846
 {
 
17847
   rtx real, temp;
 
17848
 
 
17849
@@ -19139,6 +21599,11 @@
 
17850
          }
 
17851
     }
 
17852
 
 
17853
+  /* If a store insn has been split into multiple insns, the
 
17854
+     true source register is given by split_reg.  */
 
17855
+  if (split_reg != NULL_RTX)
 
17856
+    real = gen_rtx_SET (VOIDmode, SET_DEST (real), split_reg);
 
17857
+
 
17858
   RTX_FRAME_RELATED_P (insn) = 1;
 
17859
   add_reg_note (insn, REG_FRAME_RELATED_EXPR, real);
 
17860
 
 
17861
@@ -19246,7 +21711,7 @@
 
17862
   reg = gen_rtx_REG (mode, regno);
 
17863
   insn = emit_insn (gen_frame_store (reg, frame_reg, offset));
 
17864
   return rs6000_frame_related (insn, frame_reg, frame_reg_to_sp,
 
17865
-                              NULL_RTX, NULL_RTX);
 
17866
+                              NULL_RTX, NULL_RTX, NULL_RTX);
 
17867
 }
 
17868
 
 
17869
 /* Emit an offset memory reference suitable for a frame store, while
 
17870
@@ -19362,7 +21827,7 @@
 
17871
       if ((sel & SAVRES_LR))
 
17872
        suffix = "_x";
 
17873
     }
 
17874
-  else if (DEFAULT_ABI == ABI_AIX)
 
17875
+  else if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
17876
     {
 
17877
 #if !defined (POWERPC_LINUX) && !defined (POWERPC_FREEBSD)
 
17878
       /* No out-of-line save/restore routines for GPRs on AIX.  */
 
17879
@@ -19503,7 +21968,7 @@
 
17880
 static inline unsigned
 
17881
 ptr_regno_for_savres (int sel)
 
17882
 {
 
17883
-  if (DEFAULT_ABI == ABI_AIX)
 
17884
+  if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
17885
     return (sel & SAVRES_REG) == SAVRES_FPR || (sel & SAVRES_LR) ? 1 : 12;
 
17886
   return DEFAULT_ABI == ABI_DARWIN && (sel & SAVRES_REG) == SAVRES_FPR ? 1 : 11;
 
17887
 }
 
17888
@@ -19588,6 +22053,43 @@
 
17889
   return insn;
 
17890
 }
 
17891
 
 
17892
+/* Emit code to store CR fields that need to be saved into REG.  */
 
17893
+
 
17894
+static void
 
17895
+rs6000_emit_move_from_cr (rtx reg)
 
17896
+{
 
17897
+  /* Only the ELFv2 ABI allows storing only selected fields.  */
 
17898
+  if (DEFAULT_ABI == ABI_ELFv2 && TARGET_MFCRF)
 
17899
+    {
 
17900
+      int i, cr_reg[8], count = 0;
 
17901
+
 
17902
+      /* Collect CR fields that must be saved.  */
 
17903
+      for (i = 0; i < 8; i++)
 
17904
+       if (save_reg_p (CR0_REGNO + i))
 
17905
+         cr_reg[count++] = i;
 
17906
+
 
17907
+      /* If it's just a single one, use mfcrf.  */
 
17908
+      if (count == 1)
 
17909
+       {
 
17910
+         rtvec p = rtvec_alloc (1);
 
17911
+         rtvec r = rtvec_alloc (2);
 
17912
+         RTVEC_ELT (r, 0) = gen_rtx_REG (CCmode, CR0_REGNO + cr_reg[0]);
 
17913
+         RTVEC_ELT (r, 1) = GEN_INT (1 << (7 - cr_reg[0]));
 
17914
+         RTVEC_ELT (p, 0)
 
17915
+           = gen_rtx_SET (VOIDmode, reg,
 
17916
+                          gen_rtx_UNSPEC (SImode, r, UNSPEC_MOVESI_FROM_CR));
 
17917
+
 
17918
+         emit_insn (gen_rtx_PARALLEL (VOIDmode, p));
 
17919
+         return;
 
17920
+       }
 
17921
+
 
17922
+      /* ??? It might be better to handle count == 2 / 3 cases here
 
17923
+        as well, using logical operations to combine the values.  */
 
17924
+    }
 
17925
+
 
17926
+  emit_insn (gen_movesi_from_cr (reg));
 
17927
+}
 
17928
+
 
17929
 /* Determine whether the gp REG is really used.  */
 
17930
 
 
17931
 static bool
 
17932
@@ -19653,6 +22155,17 @@
 
17933
 #define NOT_INUSE(R) do {} while (0)
 
17934
 #endif
 
17935
 
 
17936
+  if (DEFAULT_ABI == ABI_ELFv2)
 
17937
+    {
 
17938
+      cfun->machine->r2_setup_needed = df_regs_ever_live_p (TOC_REGNUM);
 
17939
+
 
17940
+      /* With -mminimal-toc we may generate an extra use of r2 below.  */
 
17941
+      if (!TARGET_SINGLE_PIC_BASE
 
17942
+         && TARGET_TOC && TARGET_MINIMAL_TOC && get_pool_size () != 0)
 
17943
+       cfun->machine->r2_setup_needed = true;
 
17944
+    }
 
17945
+
 
17946
+
 
17947
   if (flag_stack_usage_info)
 
17948
     current_function_static_stack_size = info->total_size;
 
17949
 
 
17950
@@ -19767,7 +22280,7 @@
 
17951
 
 
17952
       insn = emit_insn (gen_rtx_PARALLEL (VOIDmode, p));
 
17953
       rs6000_frame_related (insn, frame_reg_rtx, sp_off - frame_off,
 
17954
-                           treg, GEN_INT (-info->total_size));
 
17955
+                           treg, GEN_INT (-info->total_size), NULL_RTX);
 
17956
       sp_off = frame_off = info->total_size;
 
17957
     }
 
17958
 
 
17959
@@ -19852,14 +22365,14 @@
 
17960
 
 
17961
          insn = emit_move_insn (mem, reg);
 
17962
          rs6000_frame_related (insn, frame_reg_rtx, sp_off - frame_off,
 
17963
-                               NULL_RTX, NULL_RTX);
 
17964
+                               NULL_RTX, NULL_RTX, NULL_RTX);
 
17965
          END_USE (0);
 
17966
        }
 
17967
     }
 
17968
 
 
17969
   /* If we need to save CR, put it into r12 or r11.  Choose r12 except when
 
17970
      r12 will be needed by out-of-line gpr restore.  */
 
17971
-  cr_save_regno = (DEFAULT_ABI == ABI_AIX
 
17972
+  cr_save_regno = ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
17973
                   && !(strategy & (SAVE_INLINE_GPRS
 
17974
                                    | SAVE_NOINLINE_GPRS_SAVES_LR))
 
17975
                   ? 11 : 12);
 
17976
@@ -19868,21 +22381,9 @@
 
17977
       && REGNO (frame_reg_rtx) != cr_save_regno
 
17978
       && !(using_static_chain_p && cr_save_regno == 11))
 
17979
     {
 
17980
-      rtx set;
 
17981
-
 
17982
       cr_save_rtx = gen_rtx_REG (SImode, cr_save_regno);
 
17983
       START_USE (cr_save_regno);
 
17984
-      insn = emit_insn (gen_movesi_from_cr (cr_save_rtx));
 
17985
-      RTX_FRAME_RELATED_P (insn) = 1;
 
17986
-      /* Now, there's no way that dwarf2out_frame_debug_expr is going
 
17987
-        to understand '(unspec:SI [(reg:CC 68) ...] UNSPEC_MOVESI_FROM_CR)'.
 
17988
-        But that's OK.  All we have to do is specify that _one_ condition
 
17989
-        code register is saved in this stack slot.  The thrower's epilogue
 
17990
-        will then restore all the call-saved registers.
 
17991
-        We use CR2_REGNO (70) to be compatible with gcc-2.95 on Linux.  */
 
17992
-      set = gen_rtx_SET (VOIDmode, cr_save_rtx,
 
17993
-                        gen_rtx_REG (SImode, CR2_REGNO));
 
17994
-      add_reg_note (insn, REG_FRAME_RELATED_EXPR, set);
 
17995
+      rs6000_emit_move_from_cr (cr_save_rtx);
 
17996
     }
 
17997
 
 
17998
   /* Do any required saving of fpr's.  If only one or two to save, do
 
17999
@@ -19920,7 +22421,7 @@
 
18000
                                     info->lr_save_offset,
 
18001
                                     DFmode, sel);
 
18002
       rs6000_frame_related (insn, ptr_reg, sp_off,
 
18003
-                           NULL_RTX, NULL_RTX);
 
18004
+                           NULL_RTX, NULL_RTX, NULL_RTX);
 
18005
       if (lr)
 
18006
        END_USE (0);
 
18007
     }
 
18008
@@ -19999,7 +22500,7 @@
 
18009
                                         SAVRES_SAVE | SAVRES_GPR);
 
18010
 
 
18011
          rs6000_frame_related (insn, spe_save_area_ptr, sp_off - save_off,
 
18012
-                               NULL_RTX, NULL_RTX);
 
18013
+                               NULL_RTX, NULL_RTX, NULL_RTX);
 
18014
        }
 
18015
 
 
18016
       /* Move the static chain pointer back.  */
 
18017
@@ -20049,7 +22550,7 @@
 
18018
                                     info->lr_save_offset + ptr_off,
 
18019
                                     reg_mode, sel);
 
18020
       rs6000_frame_related (insn, ptr_reg, sp_off - ptr_off,
 
18021
-                           NULL_RTX, NULL_RTX);
 
18022
+                           NULL_RTX, NULL_RTX, NULL_RTX);
 
18023
       if (lr)
 
18024
        END_USE (0);
 
18025
     }
 
18026
@@ -20065,7 +22566,7 @@
 
18027
                             info->gp_save_offset + frame_off + reg_size * i);
 
18028
       insn = emit_insn (gen_rtx_PARALLEL (VOIDmode, p));
 
18029
       rs6000_frame_related (insn, frame_reg_rtx, sp_off - frame_off,
 
18030
-                           NULL_RTX, NULL_RTX);
 
18031
+                           NULL_RTX, NULL_RTX, NULL_RTX);
 
18032
     }
 
18033
   else if (!WORLD_SAVE_P (info))
 
18034
     {
 
18035
@@ -20134,7 +22635,8 @@
 
18036
         be updated if we arrived at this function via a plt call or
 
18037
         toc adjusting stub.  */
 
18038
       emit_move_insn (tmp_reg_si, gen_rtx_MEM (SImode, tmp_reg));
 
18039
-      toc_restore_insn = TARGET_32BIT ? 0x80410014 : 0xE8410028;
 
18040
+      toc_restore_insn = ((TARGET_32BIT ? 0x80410000 : 0xE8410000)
 
18041
+                         + RS6000_TOC_SAVE_SLOT);
 
18042
       hi = gen_int_mode (toc_restore_insn & ~0xffff, SImode);
 
18043
       emit_insn (gen_xorsi3 (tmp_reg_si, tmp_reg_si, hi));
 
18044
       compare_result = gen_rtx_REG (CCUNSmode, CR0_REGNO);
 
18045
@@ -20153,7 +22655,7 @@
 
18046
       LABEL_NUSES (toc_save_done) += 1;
 
18047
 
 
18048
       save_insn = emit_frame_save (frame_reg_rtx, reg_mode,
 
18049
-                                  TOC_REGNUM, frame_off + 5 * reg_size,
 
18050
+                                  TOC_REGNUM, frame_off + RS6000_TOC_SAVE_SLOT,
 
18051
                                   sp_off - frame_off);
 
18052
 
 
18053
       emit_label (toc_save_done);
 
18054
@@ -20193,28 +22695,123 @@
 
18055
       rtx addr = gen_rtx_PLUS (Pmode, frame_reg_rtx,
 
18056
                               GEN_INT (info->cr_save_offset + frame_off));
 
18057
       rtx mem = gen_frame_mem (SImode, addr);
 
18058
-      /* See the large comment above about why CR2_REGNO is used.  */
 
18059
-      rtx magic_eh_cr_reg = gen_rtx_REG (SImode, CR2_REGNO);
 
18060
 
 
18061
       /* If we didn't copy cr before, do so now using r0.  */
 
18062
       if (cr_save_rtx == NULL_RTX)
 
18063
        {
 
18064
-         rtx set;
 
18065
-
 
18066
          START_USE (0);
 
18067
          cr_save_rtx = gen_rtx_REG (SImode, 0);
 
18068
-         insn = emit_insn (gen_movesi_from_cr (cr_save_rtx));
 
18069
-         RTX_FRAME_RELATED_P (insn) = 1;
 
18070
-         set = gen_rtx_SET (VOIDmode, cr_save_rtx, magic_eh_cr_reg);
 
18071
-         add_reg_note (insn, REG_FRAME_RELATED_EXPR, set);
 
18072
+         rs6000_emit_move_from_cr (cr_save_rtx);
 
18073
        }
 
18074
-      insn = emit_move_insn (mem, cr_save_rtx);
 
18075
+
 
18076
+      /* Saving CR requires a two-instruction sequence: one instruction
 
18077
+        to move the CR to a general-purpose register, and a second
 
18078
+        instruction that stores the GPR to memory.
 
18079
+
 
18080
+        We do not emit any DWARF CFI records for the first of these,
 
18081
+        because we cannot properly represent the fact that CR is saved in
 
18082
+        a register.  One reason is that we cannot express that multiple
 
18083
+        CR fields are saved; another reason is that on 64-bit, the size
 
18084
+        of the CR register in DWARF (4 bytes) differs from the size of
 
18085
+        a general-purpose register.
 
18086
+
 
18087
+        This means if any intervening instruction were to clobber one of
 
18088
+        the call-saved CR fields, we'd have incorrect CFI.  To prevent
 
18089
+        this from happening, we mark the store to memory as a use of
 
18090
+        those CR fields, which prevents any such instruction from being
 
18091
+        scheduled in between the two instructions.  */
 
18092
+      rtx crsave_v[9];
 
18093
+      int n_crsave = 0;
 
18094
+      int i;
 
18095
+
 
18096
+      crsave_v[n_crsave++] = gen_rtx_SET (VOIDmode, mem, cr_save_rtx);
 
18097
+      for (i = 0; i < 8; i++)
 
18098
+       if (save_reg_p (CR0_REGNO + i))
 
18099
+         crsave_v[n_crsave++]
 
18100
+           = gen_rtx_USE (VOIDmode, gen_rtx_REG (CCmode, CR0_REGNO + i));
 
18101
+
 
18102
+      insn = emit_insn (gen_rtx_PARALLEL (VOIDmode,
 
18103
+                                         gen_rtvec_v (n_crsave, crsave_v)));
 
18104
       END_USE (REGNO (cr_save_rtx));
 
18105
 
 
18106
-      rs6000_frame_related (insn, frame_reg_rtx, sp_off - frame_off,
 
18107
-                           NULL_RTX, NULL_RTX);
 
18108
+      /* Now, there's no way that dwarf2out_frame_debug_expr is going to
 
18109
+        understand '(unspec:SI [(reg:CC 68) ...] UNSPEC_MOVESI_FROM_CR)',
 
18110
+        so we need to construct a frame expression manually.  */
 
18111
+      RTX_FRAME_RELATED_P (insn) = 1;
 
18112
+
 
18113
+      /* Update address to be stack-pointer relative, like
 
18114
+        rs6000_frame_related would do.  */
 
18115
+      addr = gen_rtx_PLUS (Pmode, gen_rtx_REG (Pmode, STACK_POINTER_REGNUM),
 
18116
+                          GEN_INT (info->cr_save_offset + sp_off));
 
18117
+      mem = gen_frame_mem (SImode, addr);
 
18118
+
 
18119
+      if (DEFAULT_ABI == ABI_ELFv2)
 
18120
+       {
 
18121
+         /* In the ELFv2 ABI we generate separate CFI records for each
 
18122
+            CR field that was actually saved.  They all point to the
 
18123
+            same 32-bit stack slot.  */
 
18124
+         rtx crframe[8];
 
18125
+         int n_crframe = 0;
 
18126
+
 
18127
+         for (i = 0; i < 8; i++)
 
18128
+           if (save_reg_p (CR0_REGNO + i))
 
18129
+             {
 
18130
+               crframe[n_crframe]
 
18131
+                 = gen_rtx_SET (VOIDmode, mem,
 
18132
+                                gen_rtx_REG (SImode, CR0_REGNO + i));
 
18133
+
 
18134
+               RTX_FRAME_RELATED_P (crframe[n_crframe]) = 1;
 
18135
+               n_crframe++;
 
18136
+            }
 
18137
+
 
18138
+         add_reg_note (insn, REG_FRAME_RELATED_EXPR,
 
18139
+                       gen_rtx_PARALLEL (VOIDmode,
 
18140
+                                         gen_rtvec_v (n_crframe, crframe)));
 
18141
+       }
 
18142
+      else
 
18143
+       {
 
18144
+         /* In other ABIs, by convention, we use a single CR regnum to
 
18145
+            represent the fact that all call-saved CR fields are saved.
 
18146
+            We use CR2_REGNO to be compatible with gcc-2.95 on Linux.  */
 
18147
+         rtx set = gen_rtx_SET (VOIDmode, mem,
 
18148
+                                gen_rtx_REG (SImode, CR2_REGNO));
 
18149
+         add_reg_note (insn, REG_FRAME_RELATED_EXPR, set);
 
18150
+       }
 
18151
     }
 
18152
 
 
18153
+  /* In the ELFv2 ABI we need to save all call-saved CR fields into
 
18154
+     *separate* slots if the routine calls __builtin_eh_return, so
 
18155
+     that they can be independently restored by the unwinder.  */
 
18156
+  if (DEFAULT_ABI == ABI_ELFv2 && crtl->calls_eh_return)
 
18157
+    {
 
18158
+      int i, cr_off = info->ehcr_offset;
 
18159
+      rtx crsave;
 
18160
+
 
18161
+      /* ??? We might get better performance by using multiple mfocrf
 
18162
+        instructions.  */
 
18163
+      crsave = gen_rtx_REG (SImode, 0);
 
18164
+      emit_insn (gen_movesi_from_cr (crsave));
 
18165
+
 
18166
+      for (i = 0; i < 8; i++)
 
18167
+       if (!call_used_regs[CR0_REGNO + i])
 
18168
+         {
 
18169
+           rtvec p = rtvec_alloc (2);
 
18170
+           RTVEC_ELT (p, 0)
 
18171
+             = gen_frame_store (crsave, frame_reg_rtx, cr_off + frame_off);
 
18172
+           RTVEC_ELT (p, 1)
 
18173
+             = gen_rtx_USE (VOIDmode, gen_rtx_REG (CCmode, CR0_REGNO + i));
 
18174
+
 
18175
+           insn = emit_insn (gen_rtx_PARALLEL (VOIDmode, p));
 
18176
+
 
18177
+           RTX_FRAME_RELATED_P (insn) = 1;
 
18178
+           add_reg_note (insn, REG_FRAME_RELATED_EXPR,
 
18179
+                         gen_frame_store (gen_rtx_REG (SImode, CR0_REGNO + i),
 
18180
+                                          sp_reg_rtx, cr_off + sp_off));
 
18181
+
 
18182
+           cr_off += reg_size;
 
18183
+         }
 
18184
+    }
 
18185
+
 
18186
   /* Update stack and set back pointer unless this is V.4,
 
18187
      for which it was done previously.  */
 
18188
   if (!WORLD_SAVE_P (info) && info->push_p
 
18189
@@ -20292,7 +22889,7 @@
 
18190
                                     info->altivec_save_offset + ptr_off,
 
18191
                                     0, V4SImode, SAVRES_SAVE | SAVRES_VR);
 
18192
       rs6000_frame_related (insn, scratch_reg, sp_off - ptr_off,
 
18193
-                           NULL_RTX, NULL_RTX);
 
18194
+                           NULL_RTX, NULL_RTX, NULL_RTX);
 
18195
       if (REGNO (frame_reg_rtx) == REGNO (scratch_reg))
 
18196
        {
 
18197
          /* The oddity mentioned above clobbered our frame reg.  */
 
18198
@@ -20308,7 +22905,7 @@
 
18199
       for (i = info->first_altivec_reg_save; i <= LAST_ALTIVEC_REGNO; ++i)
 
18200
        if (info->vrsave_mask & ALTIVEC_REG_BIT (i))
 
18201
          {
 
18202
-           rtx areg, savereg, mem;
 
18203
+           rtx areg, savereg, mem, split_reg;
 
18204
            int offset;
 
18205
 
 
18206
            offset = (info->altivec_save_offset + frame_off
 
18207
@@ -20326,8 +22923,18 @@
 
18208
 
 
18209
            insn = emit_move_insn (mem, savereg);
 
18210
 
 
18211
+           /* When we split a VSX store into two insns, we need to make
 
18212
+              sure the DWARF info knows which register we are storing.
 
18213
+              Pass it in to be used on the appropriate note.  */
 
18214
+           if (!BYTES_BIG_ENDIAN
 
18215
+               && GET_CODE (PATTERN (insn)) == SET
 
18216
+               && GET_CODE (SET_SRC (PATTERN (insn))) == VEC_SELECT)
 
18217
+             split_reg = savereg;
 
18218
+           else
 
18219
+             split_reg = NULL_RTX;
 
18220
+
 
18221
            rs6000_frame_related (insn, frame_reg_rtx, sp_off - frame_off,
 
18222
-                                 areg, GEN_INT (offset));
 
18223
+                                 areg, GEN_INT (offset), split_reg);
 
18224
          }
 
18225
     }
 
18226
 
 
18227
@@ -20351,7 +22958,8 @@
 
18228
         be using r12 as frame_reg_rtx and r11 as the static chain
 
18229
         pointer for nested functions.  */
 
18230
       save_regno = 12;
 
18231
-      if (DEFAULT_ABI == ABI_AIX && !using_static_chain_p)
 
18232
+      if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
18233
+         && !using_static_chain_p)
 
18234
        save_regno = 11;
 
18235
       else if (REGNO (frame_reg_rtx) == 12)
 
18236
        {
 
18237
@@ -20390,7 +22998,7 @@
 
18238
         can use register 0.  This allows us to use a plain 'blr' to return
 
18239
         from the procedure more often.  */
 
18240
       int save_LR_around_toc_setup = (TARGET_ELF
 
18241
-                                     && DEFAULT_ABI != ABI_AIX
 
18242
+                                     && DEFAULT_ABI == ABI_V4
 
18243
                                      && flag_pic
 
18244
                                      && ! info->lr_save_p
 
18245
                                      && EDGE_COUNT (EXIT_BLOCK_PTR->preds) > 0);
 
18246
@@ -20452,7 +23060,7 @@
 
18247
   if (rs6000_save_toc_in_prologue_p ())
 
18248
     {
 
18249
       rtx reg = gen_rtx_REG (reg_mode, TOC_REGNUM);
 
18250
-      emit_insn (gen_frame_store (reg, sp_reg_rtx, 5 * reg_size));
 
18251
+      emit_insn (gen_frame_store (reg, sp_reg_rtx, RS6000_TOC_SAVE_SLOT));
 
18252
     }
 
18253
 }
 
18254
 
 
18255
@@ -20493,6 +23101,49 @@
 
18256
        }
 
18257
     }
 
18258
 
 
18259
+  /* ELFv2 ABI r2 setup code and local entry point.  This must follow
 
18260
+     immediately after the global entry point label.  */
 
18261
+  if (DEFAULT_ABI == ABI_ELFv2 && cfun->machine->r2_setup_needed)
 
18262
+    {
 
18263
+      const char *name = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
 
18264
+
 
18265
+      fprintf (file, "0:\taddis 2,12,.TOC.-0b@ha\n");
 
18266
+      fprintf (file, "\taddi 2,2,.TOC.-0b@l\n");
 
18267
+
 
18268
+      fputs ("\t.localentry\t", file);
 
18269
+      assemble_name (file, name);
 
18270
+      fputs (",.-", file);
 
18271
+      assemble_name (file, name);
 
18272
+      fputs ("\n", file);
 
18273
+    }
 
18274
+
 
18275
+  /* Output -mprofile-kernel code.  This needs to be done here instead of
 
18276
+     in output_function_profile since it must go after the ELFv2 ABI
 
18277
+     local entry point.  */
 
18278
+  if (TARGET_PROFILE_KERNEL)
 
18279
+    {
 
18280
+      gcc_assert (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2);
 
18281
+      gcc_assert (!TARGET_32BIT);
 
18282
+
 
18283
+      asm_fprintf (file, "\tmflr %s\n", reg_names[0]);
 
18284
+      asm_fprintf (file, "\tstd %s,16(%s)\n", reg_names[0], reg_names[1]);
 
18285
+
 
18286
+      /* In the ELFv2 ABI we have no compiler stack word.  It must be
 
18287
+        the resposibility of _mcount to preserve the static chain
 
18288
+        register if required.  */
 
18289
+      if (DEFAULT_ABI != ABI_ELFv2
 
18290
+         && cfun->static_chain_decl != NULL)
 
18291
+       {
 
18292
+         asm_fprintf (file, "\tstd %s,24(%s)\n",
 
18293
+                      reg_names[STATIC_CHAIN_REGNUM], reg_names[1]);
 
18294
+         fprintf (file, "\tbl %s\n", RS6000_MCOUNT);
 
18295
+         asm_fprintf (file, "\tld %s,24(%s)\n",
 
18296
+                      reg_names[STATIC_CHAIN_REGNUM], reg_names[1]);
 
18297
+       }
 
18298
+      else
 
18299
+       fprintf (file, "\tbl %s\n", RS6000_MCOUNT);
 
18300
+    }
 
18301
+
 
18302
   rs6000_pic_labelno++;
 
18303
 }
 
18304
 
 
18305
@@ -20545,6 +23196,7 @@
 
18306
 
 
18307
   if (using_mfcr_multiple && count > 1)
 
18308
     {
 
18309
+      rtx insn;
 
18310
       rtvec p;
 
18311
       int ndx;
 
18312
 
 
18313
@@ -20562,16 +23214,43 @@
 
18314
                           gen_rtx_UNSPEC (CCmode, r, UNSPEC_MOVESI_TO_CR));
 
18315
            ndx++;
 
18316
          }
 
18317
-      emit_insn (gen_rtx_PARALLEL (VOIDmode, p));
 
18318
+      insn = emit_insn (gen_rtx_PARALLEL (VOIDmode, p));
 
18319
       gcc_assert (ndx == count);
 
18320
+
 
18321
+      /* For the ELFv2 ABI we generate a CFA_RESTORE for each
 
18322
+        CR field separately.  */
 
18323
+      if (!exit_func && DEFAULT_ABI == ABI_ELFv2 && flag_shrink_wrap)
 
18324
+       {
 
18325
+         for (i = 0; i < 8; i++)
 
18326
+           if (save_reg_p (CR0_REGNO + i))
 
18327
+             add_reg_note (insn, REG_CFA_RESTORE,
 
18328
+                           gen_rtx_REG (SImode, CR0_REGNO + i));
 
18329
+
 
18330
+         RTX_FRAME_RELATED_P (insn) = 1;
 
18331
+       }
 
18332
     }
 
18333
   else
 
18334
     for (i = 0; i < 8; i++)
 
18335
       if (save_reg_p (CR0_REGNO + i))
 
18336
-       emit_insn (gen_movsi_to_cr_one (gen_rtx_REG (CCmode, CR0_REGNO + i),
 
18337
-                                       reg));
 
18338
+       {
 
18339
+         rtx insn = emit_insn (gen_movsi_to_cr_one
 
18340
+                                (gen_rtx_REG (CCmode, CR0_REGNO + i), reg));
 
18341
 
 
18342
-  if (!exit_func && (DEFAULT_ABI == ABI_V4 || flag_shrink_wrap))
 
18343
+         /* For the ELFv2 ABI we generate a CFA_RESTORE for each
 
18344
+            CR field separately, attached to the insn that in fact
 
18345
+            restores this particular CR field.  */
 
18346
+         if (!exit_func && DEFAULT_ABI == ABI_ELFv2 && flag_shrink_wrap)
 
18347
+           {
 
18348
+             add_reg_note (insn, REG_CFA_RESTORE,
 
18349
+                           gen_rtx_REG (SImode, CR0_REGNO + i));
 
18350
+
 
18351
+             RTX_FRAME_RELATED_P (insn) = 1;
 
18352
+           }
 
18353
+       }
 
18354
+
 
18355
+  /* For other ABIs, we just generate a single CFA_RESTORE for CR2.  */
 
18356
+  if (!exit_func && DEFAULT_ABI != ABI_ELFv2
 
18357
+      && (DEFAULT_ABI == ABI_V4 || flag_shrink_wrap))
 
18358
     {
 
18359
       rtx insn = get_last_insn ();
 
18360
       rtx cr = gen_rtx_REG (SImode, CR2_REGNO);
 
18361
@@ -20612,10 +23291,22 @@
 
18362
 static rtx
 
18363
 add_crlr_cfa_restore (const rs6000_stack_t *info, rtx cfa_restores)
 
18364
 {
 
18365
-  if (info->cr_save_p)
 
18366
+  if (DEFAULT_ABI == ABI_ELFv2)
 
18367
+    {
 
18368
+      int i;
 
18369
+      for (i = 0; i < 8; i++)
 
18370
+       if (save_reg_p (CR0_REGNO + i))
 
18371
+         {
 
18372
+           rtx cr = gen_rtx_REG (SImode, CR0_REGNO + i);
 
18373
+           cfa_restores = alloc_reg_note (REG_CFA_RESTORE, cr,
 
18374
+                                          cfa_restores);
 
18375
+         }
 
18376
+    }
 
18377
+  else if (info->cr_save_p)
 
18378
     cfa_restores = alloc_reg_note (REG_CFA_RESTORE,
 
18379
                                   gen_rtx_REG (SImode, CR2_REGNO),
 
18380
                                   cfa_restores);
 
18381
+
 
18382
   if (info->lr_save_p)
 
18383
     cfa_restores = alloc_reg_note (REG_CFA_RESTORE,
 
18384
                                   gen_rtx_REG (Pmode, LR_REGNO),
 
18385
@@ -21113,6 +23804,35 @@
 
18386
               || (!restoring_GPRs_inline
 
18387
                   && info->first_fp_reg_save == 64));
 
18388
 
 
18389
+  /* In the ELFv2 ABI we need to restore all call-saved CR fields from
 
18390
+     *separate* slots if the routine calls __builtin_eh_return, so
 
18391
+     that they can be independently restored by the unwinder.  */
 
18392
+  if (DEFAULT_ABI == ABI_ELFv2 && crtl->calls_eh_return)
 
18393
+    {
 
18394
+      int i, cr_off = info->ehcr_offset;
 
18395
+
 
18396
+      for (i = 0; i < 8; i++)
 
18397
+       if (!call_used_regs[CR0_REGNO + i])
 
18398
+         {
 
18399
+           rtx reg = gen_rtx_REG (SImode, 0);
 
18400
+           emit_insn (gen_frame_load (reg, frame_reg_rtx,
 
18401
+                                      cr_off + frame_off));
 
18402
+
 
18403
+           insn = emit_insn (gen_movsi_to_cr_one
 
18404
+                               (gen_rtx_REG (CCmode, CR0_REGNO + i), reg));
 
18405
+
 
18406
+           if (!exit_func && flag_shrink_wrap)
 
18407
+             {
 
18408
+               add_reg_note (insn, REG_CFA_RESTORE,
 
18409
+                             gen_rtx_REG (SImode, CR0_REGNO + i));
 
18410
+
 
18411
+               RTX_FRAME_RELATED_P (insn) = 1;
 
18412
+             }
 
18413
+
 
18414
+           cr_off += reg_size;
 
18415
+         }
 
18416
+    }
 
18417
+
 
18418
   /* Get the old lr if we saved it.  If we are restoring registers
 
18419
      out-of-line, then the out-of-line routines can do this for us.  */
 
18420
   if (restore_lr && restoring_GPRs_inline)
 
18421
@@ -21156,7 +23876,7 @@
 
18422
        {
 
18423
          rtx reg = gen_rtx_REG (reg_mode, 2);
 
18424
          emit_insn (gen_frame_load (reg, frame_reg_rtx,
 
18425
-                                    frame_off + 5 * reg_size));
 
18426
+                                    frame_off + RS6000_TOC_SAVE_SLOT));
 
18427
        }
 
18428
 
 
18429
       for (i = 0; ; ++i)
 
18430
@@ -21442,6 +24162,7 @@
 
18431
       if (! restoring_FPRs_inline)
 
18432
        {
 
18433
          int i;
 
18434
+         int reg;
 
18435
          rtx sym;
 
18436
 
 
18437
          if (flag_shrink_wrap)
 
18438
@@ -21450,10 +24171,9 @@
 
18439
          sym = rs6000_savres_routine_sym (info,
 
18440
                                           SAVRES_FPR | (lr ? SAVRES_LR : 0));
 
18441
          RTVEC_ELT (p, 2) = gen_rtx_USE (VOIDmode, sym);
 
18442
-         RTVEC_ELT (p, 3) = gen_rtx_USE (VOIDmode,
 
18443
-                                         gen_rtx_REG (Pmode,
 
18444
-                                                      DEFAULT_ABI == ABI_AIX
 
18445
-                                                      ? 1 : 11));
 
18446
+         reg = (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)? 1 : 11;
 
18447
+         RTVEC_ELT (p, 3) = gen_rtx_USE (VOIDmode, gen_rtx_REG (Pmode, reg));
 
18448
+
 
18449
          for (i = 0; i < 64 - info->first_fp_reg_save; i++)
 
18450
            {
 
18451
              rtx reg = gen_rtx_REG (DFmode, info->first_fp_reg_save + i);
 
18452
@@ -21531,7 +24251,8 @@
 
18453
 
 
18454
      System V.4 Powerpc's (and the embedded ABI derived from it) use a
 
18455
      different traceback table.  */
 
18456
-  if (DEFAULT_ABI == ABI_AIX && ! flag_inhibit_size_directive
 
18457
+  if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
18458
+      && ! flag_inhibit_size_directive
 
18459
       && rs6000_traceback != traceback_none && !cfun->is_thunk)
 
18460
     {
 
18461
       const char *fname = NULL;
 
18462
@@ -21859,6 +24580,12 @@
 
18463
   SIBLING_CALL_P (insn) = 1;
 
18464
   emit_barrier ();
 
18465
 
 
18466
+  /* Ensure we have a global entry point for the thunk.   ??? We could
 
18467
+     avoid that if the target routine doesn't need a global entry point,
 
18468
+     but we do not know whether this is the case at this point.  */
 
18469
+  if (DEFAULT_ABI == ABI_ELFv2)
 
18470
+    cfun->machine->r2_setup_needed = true;
 
18471
+
 
18472
   /* Run just enough of rest_of_compilation to get the insns emitted.
 
18473
      There's not really enough bulk here to make other passes such as
 
18474
      instruction scheduling worth while.  Note that use_thunk calls
 
18475
@@ -22555,7 +25282,7 @@
 
18476
   if (TARGET_PROFILE_KERNEL)
 
18477
     return;
 
18478
 
 
18479
-  if (DEFAULT_ABI == ABI_AIX)
 
18480
+  if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
18481
     {
 
18482
 #ifndef NO_PROFILE_COUNTERS
 
18483
 # define NO_PROFILE_COUNTERS 0
 
18484
@@ -22699,29 +25426,9 @@
 
18485
       break;
 
18486
 
 
18487
     case ABI_AIX:
 
18488
+    case ABI_ELFv2:
 
18489
     case ABI_DARWIN:
 
18490
-      if (!TARGET_PROFILE_KERNEL)
 
18491
-       {
 
18492
-         /* Don't do anything, done in output_profile_hook ().  */
 
18493
-       }
 
18494
-      else
 
18495
-       {
 
18496
-         gcc_assert (!TARGET_32BIT);
 
18497
-
 
18498
-         asm_fprintf (file, "\tmflr %s\n", reg_names[0]);
 
18499
-         asm_fprintf (file, "\tstd %s,16(%s)\n", reg_names[0], reg_names[1]);
 
18500
-
 
18501
-         if (cfun->static_chain_decl != NULL)
 
18502
-           {
 
18503
-             asm_fprintf (file, "\tstd %s,24(%s)\n",
 
18504
-                          reg_names[STATIC_CHAIN_REGNUM], reg_names[1]);
 
18505
-             fprintf (file, "\tbl %s\n", RS6000_MCOUNT);
 
18506
-             asm_fprintf (file, "\tld %s,24(%s)\n",
 
18507
-                          reg_names[STATIC_CHAIN_REGNUM], reg_names[1]);
 
18508
-           }
 
18509
-         else
 
18510
-           fprintf (file, "\tbl %s\n", RS6000_MCOUNT);
 
18511
-       }
 
18512
+      /* Don't do anything, done in output_profile_hook ().  */
 
18513
       break;
 
18514
     }
 
18515
 }
 
18516
@@ -22847,6 +25554,7 @@
 
18517
                  || rs6000_cpu_attr == CPU_POWER4
 
18518
                  || rs6000_cpu_attr == CPU_POWER5
 
18519
                 || rs6000_cpu_attr == CPU_POWER7
 
18520
+                || rs6000_cpu_attr == CPU_POWER8
 
18521
                  || rs6000_cpu_attr == CPU_CELL)
 
18522
                 && recog_memoized (dep_insn)
 
18523
                 && (INSN_CODE (dep_insn) >= 0))
 
18524
@@ -23129,7 +25837,8 @@
 
18525
   if (rs6000_cpu_attr == CPU_CELL)
 
18526
     return get_attr_cell_micro (insn) == CELL_MICRO_ALWAYS;
 
18527
 
 
18528
-  if (rs6000_sched_groups)
 
18529
+  if (rs6000_sched_groups
 
18530
+      && (rs6000_cpu == PROCESSOR_POWER4 || rs6000_cpu == PROCESSOR_POWER5))
 
18531
     {
 
18532
       enum attr_type type = get_attr_type (insn);
 
18533
       if (type == TYPE_LOAD_EXT_U
 
18534
@@ -23154,7 +25863,8 @@
 
18535
       || GET_CODE (PATTERN (insn)) == CLOBBER)
 
18536
     return false;
 
18537
 
 
18538
-  if (rs6000_sched_groups)
 
18539
+  if (rs6000_sched_groups
 
18540
+      && (rs6000_cpu == PROCESSOR_POWER4 || rs6000_cpu == PROCESSOR_POWER5))
 
18541
     {
 
18542
       enum attr_type type = get_attr_type (insn);
 
18543
       if (type == TYPE_LOAD_U || type == TYPE_STORE_U
 
18544
@@ -23433,6 +26143,8 @@
 
18545
   case CPU_POWER6:
 
18546
   case CPU_POWER7:
 
18547
     return 5;
 
18548
+  case CPU_POWER8:
 
18549
+    return 7;
 
18550
   default:
 
18551
     return 1;
 
18552
   }
 
18553
@@ -24060,6 +26772,39 @@
 
18554
           break;
 
18555
         }
 
18556
       break;
 
18557
+    case PROCESSOR_POWER8:
 
18558
+      type = get_attr_type (insn);
 
18559
+
 
18560
+      switch (type)
 
18561
+        {
 
18562
+        case TYPE_CR_LOGICAL:
 
18563
+        case TYPE_DELAYED_CR:
 
18564
+        case TYPE_MFCR:
 
18565
+        case TYPE_MFCRF:
 
18566
+        case TYPE_MTCR:
 
18567
+        case TYPE_COMPARE:
 
18568
+        case TYPE_DELAYED_COMPARE:
 
18569
+        case TYPE_VAR_DELAYED_COMPARE:
 
18570
+        case TYPE_IMUL_COMPARE:
 
18571
+        case TYPE_LMUL_COMPARE:
 
18572
+        case TYPE_SYNC:
 
18573
+        case TYPE_ISYNC:
 
18574
+        case TYPE_LOAD_L:
 
18575
+        case TYPE_STORE_C:
 
18576
+        case TYPE_LOAD_U:
 
18577
+        case TYPE_LOAD_UX:
 
18578
+        case TYPE_LOAD_EXT:
 
18579
+        case TYPE_LOAD_EXT_U:
 
18580
+        case TYPE_LOAD_EXT_UX:
 
18581
+        case TYPE_STORE_UX:
 
18582
+        case TYPE_VECSTORE:
 
18583
+        case TYPE_MFJMPR:
 
18584
+        case TYPE_MTJMPR:
 
18585
+          return true;
 
18586
+        default:
 
18587
+          break;
 
18588
+        }
 
18589
+      break;
 
18590
     default:
 
18591
       break;
 
18592
     }
 
18593
@@ -24138,6 +26883,25 @@
 
18594
         break;
 
18595
     }
 
18596
     break;
 
18597
+  case PROCESSOR_POWER8:
 
18598
+    type = get_attr_type (insn);
 
18599
+
 
18600
+    switch (type)
 
18601
+      {
 
18602
+      case TYPE_MFCR:
 
18603
+      case TYPE_MTCR:
 
18604
+      case TYPE_ISYNC:
 
18605
+      case TYPE_SYNC:
 
18606
+      case TYPE_LOAD_L:
 
18607
+      case TYPE_STORE_C:
 
18608
+      case TYPE_LOAD_EXT_U:
 
18609
+      case TYPE_LOAD_EXT_UX:
 
18610
+      case TYPE_STORE_UX:
 
18611
+        return true;
 
18612
+      default:
 
18613
+        break;
 
18614
+    }
 
18615
+    break;
 
18616
   default:
 
18617
     break;
 
18618
   }
 
18619
@@ -24227,8 +26991,9 @@
 
18620
       if (can_issue_more && !is_branch_slot_insn (next_insn))
 
18621
        can_issue_more--;
 
18622
 
 
18623
-      /* Power6 and Power7 have special group ending nop. */
 
18624
-      if (rs6000_cpu_attr == CPU_POWER6 || rs6000_cpu_attr == CPU_POWER7)
 
18625
+      /* Do we have a special group ending nop? */
 
18626
+      if (rs6000_cpu_attr == CPU_POWER6 || rs6000_cpu_attr == CPU_POWER7
 
18627
+         || rs6000_cpu_attr == CPU_POWER8)
 
18628
        {
 
18629
          nop = gen_group_ending_nop ();
 
18630
          emit_insn_before (nop, next_insn);
 
18631
@@ -24599,6 +27364,11 @@
 
18632
       ret = (TARGET_32BIT) ? 12 : 24;
 
18633
       break;
 
18634
 
 
18635
+    case ABI_ELFv2:
 
18636
+      gcc_assert (!TARGET_32BIT);
 
18637
+      ret = 32;
 
18638
+      break;
 
18639
+
 
18640
     case ABI_DARWIN:
 
18641
     case ABI_V4:
 
18642
       ret = (TARGET_32BIT) ? 40 : 48;
 
18643
@@ -24654,6 +27424,7 @@
 
18644
       break;
 
18645
 
 
18646
     /* Under V.4/eabi/darwin, __trampoline_setup does the real work.  */
 
18647
+    case ABI_ELFv2:
 
18648
     case ABI_DARWIN:
 
18649
     case ABI_V4:
 
18650
       emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__trampoline_setup"),
 
18651
@@ -24948,7 +27719,7 @@
 
18652
 static void
 
18653
 rs6000_elf_output_toc_section_asm_op (const void *data ATTRIBUTE_UNUSED)
 
18654
 {
 
18655
-  if (DEFAULT_ABI == ABI_AIX
 
18656
+  if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
18657
       && TARGET_MINIMAL_TOC
 
18658
       && !TARGET_RELOCATABLE)
 
18659
     {
 
18660
@@ -24969,7 +27740,8 @@
 
18661
       else
 
18662
        fprintf (asm_out_file, "%s\n", MINIMAL_TOC_SECTION_ASM_OP);
 
18663
     }
 
18664
-  else if (DEFAULT_ABI == ABI_AIX && !TARGET_RELOCATABLE)
 
18665
+  else if ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
18666
+          && !TARGET_RELOCATABLE)
 
18667
     fprintf (asm_out_file, "%s\n", TOC_SECTION_ASM_OP);
 
18668
   else
 
18669
     {
 
18670
@@ -25519,7 +28291,7 @@
 
18671
 {
 
18672
   if (flag_pic)
 
18673
     return 3;
 
18674
-  else if (DEFAULT_ABI == ABI_AIX)
 
18675
+  else if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
18676
     return 2;
 
18677
   else
 
18678
     return 0;
 
18679
@@ -25595,7 +28367,7 @@
 
18680
 void
 
18681
 rs6000_elf_declare_function_name (FILE *file, const char *name, tree decl)
 
18682
 {
 
18683
-  if (TARGET_64BIT)
 
18684
+  if (TARGET_64BIT && DEFAULT_ABI != ABI_ELFv2)
 
18685
     {
 
18686
       fputs ("\t.section\t\".opd\",\"aw\"\n\t.align 3\n", file);
 
18687
       ASM_OUTPUT_LABEL (file, name);
 
18688
@@ -25661,8 +28433,7 @@
 
18689
       fprintf (file, "%s:\n", desc_name);
 
18690
       fprintf (file, "\t.long %s\n", orig_name);
 
18691
       fputs ("\t.long _GLOBAL_OFFSET_TABLE_\n", file);
 
18692
-      if (DEFAULT_ABI == ABI_AIX)
 
18693
-       fputs ("\t.long 0\n", file);
 
18694
+      fputs ("\t.long 0\n", file);
 
18695
       fprintf (file, "\t.previous\n");
 
18696
     }
 
18697
   ASM_OUTPUT_LABEL (file, name);
 
18698
@@ -25691,7 +28462,7 @@
 
18699
     }
 
18700
 #endif
 
18701
 #if defined (POWERPC_LINUX) || defined (POWERPC_FREEBSD)
 
18702
-  if (TARGET_32BIT)
 
18703
+  if (TARGET_32BIT || DEFAULT_ABI == ABI_ELFv2)
 
18704
     file_end_indicate_exec_stack ();
 
18705
 #endif
 
18706
 }
 
18707
@@ -26431,7 +29202,8 @@
 
18708
       /* For those processors that have slow LR/CTR moves, make them more
 
18709
          expensive than memory in order to bias spills to memory .*/
 
18710
       else if ((rs6000_cpu == PROCESSOR_POWER6
 
18711
-               || rs6000_cpu == PROCESSOR_POWER7)
 
18712
+               || rs6000_cpu == PROCESSOR_POWER7
 
18713
+               || rs6000_cpu == PROCESSOR_POWER8)
 
18714
               && reg_classes_intersect_p (rclass, LINK_OR_CTR_REGS))
 
18715
         ret = 6 * hard_regno_nregs[0][mode];
 
18716
 
 
18717
@@ -26441,7 +29213,7 @@
 
18718
     }
 
18719
 
 
18720
   /* If we have VSX, we can easily move between FPR or Altivec registers.  */
 
18721
-  else if (VECTOR_UNIT_VSX_P (mode)
 
18722
+  else if (VECTOR_MEM_VSX_P (mode)
 
18723
           && reg_classes_intersect_p (to, VSX_REGS)
 
18724
           && reg_classes_intersect_p (from, VSX_REGS))
 
18725
     ret = 2 * hard_regno_nregs[32][mode];
 
18726
@@ -26482,7 +29254,8 @@
 
18727
 
 
18728
   if (reg_classes_intersect_p (rclass, GENERAL_REGS))
 
18729
     ret = 4 * hard_regno_nregs[0][mode];
 
18730
-  else if (reg_classes_intersect_p (rclass, FLOAT_REGS))
 
18731
+  else if ((reg_classes_intersect_p (rclass, FLOAT_REGS)
 
18732
+           || reg_classes_intersect_p (rclass, VSX_REGS)))
 
18733
     ret = 4 * hard_regno_nregs[32][mode];
 
18734
   else if (reg_classes_intersect_p (rclass, ALTIVEC_REGS))
 
18735
     ret = 4 * hard_regno_nregs[FIRST_ALTIVEC_REGNO][mode];
 
18736
@@ -26644,54 +29417,26 @@
 
18737
   emit_insn (gen_rtx_SET (VOIDmode, dst, r));
 
18738
 }
 
18739
 
 
18740
-/* Newton-Raphson approximation of floating point divide with just 2 passes
 
18741
-   (either single precision floating point, or newer machines with higher
 
18742
-   accuracy estimates).  Support both scalar and vector divide.  Assumes no
 
18743
-   trapping math and finite arguments.  */
 
18744
+/* Newton-Raphson approximation of floating point divide DST = N/D.  If NOTE_P,
 
18745
+   add a reg_note saying that this was a division.  Support both scalar and
 
18746
+   vector divide.  Assumes no trapping math and finite arguments.  */
 
18747
 
 
18748
-static void
 
18749
-rs6000_emit_swdiv_high_precision (rtx dst, rtx n, rtx d)
 
18750
+void
 
18751
+rs6000_emit_swdiv (rtx dst, rtx n, rtx d, bool note_p)
 
18752
 {
 
18753
   enum machine_mode mode = GET_MODE (dst);
 
18754
-  rtx x0, e0, e1, y1, u0, v0;
 
18755
-  enum insn_code code = optab_handler (smul_optab, mode);
 
18756
-  insn_gen_fn gen_mul = GEN_FCN (code);
 
18757
-  rtx one = rs6000_load_constant_and_splat (mode, dconst1);
 
18758
+  rtx one, x0, e0, x1, xprev, eprev, xnext, enext, u, v;
 
18759
+  int i;
 
18760
 
 
18761
-  gcc_assert (code != CODE_FOR_nothing);
 
18762
+  /* Low precision estimates guarantee 5 bits of accuracy.  High
 
18763
+     precision estimates guarantee 14 bits of accuracy.  SFmode
 
18764
+     requires 23 bits of accuracy.  DFmode requires 52 bits of
 
18765
+     accuracy.  Each pass at least doubles the accuracy, leading
 
18766
+     to the following.  */
 
18767
+  int passes = (TARGET_RECIP_PRECISION) ? 1 : 3;
 
18768
+  if (mode == DFmode || mode == V2DFmode)
 
18769
+    passes++;
 
18770
 
 
18771
-  /* x0 = 1./d estimate */
 
18772
-  x0 = gen_reg_rtx (mode);
 
18773
-  emit_insn (gen_rtx_SET (VOIDmode, x0,
 
18774
-                         gen_rtx_UNSPEC (mode, gen_rtvec (1, d),
 
18775
-                                         UNSPEC_FRES)));
 
18776
-
 
18777
-  e0 = gen_reg_rtx (mode);
 
18778
-  rs6000_emit_nmsub (e0, d, x0, one);          /* e0 = 1. - (d * x0) */
 
18779
-
 
18780
-  e1 = gen_reg_rtx (mode);
 
18781
-  rs6000_emit_madd (e1, e0, e0, e0);           /* e1 = (e0 * e0) + e0 */
 
18782
-
 
18783
-  y1 = gen_reg_rtx (mode);
 
18784
-  rs6000_emit_madd (y1, e1, x0, x0);           /* y1 = (e1 * x0) + x0 */
 
18785
-
 
18786
-  u0 = gen_reg_rtx (mode);
 
18787
-  emit_insn (gen_mul (u0, n, y1));             /* u0 = n * y1 */
 
18788
-
 
18789
-  v0 = gen_reg_rtx (mode);
 
18790
-  rs6000_emit_nmsub (v0, d, u0, n);            /* v0 = n - (d * u0) */
 
18791
-
 
18792
-  rs6000_emit_madd (dst, v0, y1, u0);          /* dst = (v0 * y1) + u0 */
 
18793
-}
 
18794
-
 
18795
-/* Newton-Raphson approximation of floating point divide that has a low
 
18796
-   precision estimate.  Assumes no trapping math and finite arguments.  */
 
18797
-
 
18798
-static void
 
18799
-rs6000_emit_swdiv_low_precision (rtx dst, rtx n, rtx d)
 
18800
-{
 
18801
-  enum machine_mode mode = GET_MODE (dst);
 
18802
-  rtx x0, e0, e1, e2, y1, y2, y3, u0, v0, one;
 
18803
   enum insn_code code = optab_handler (smul_optab, mode);
 
18804
   insn_gen_fn gen_mul = GEN_FCN (code);
 
18805
 
 
18806
@@ -26705,47 +29450,45 @@
 
18807
                          gen_rtx_UNSPEC (mode, gen_rtvec (1, d),
 
18808
                                          UNSPEC_FRES)));
 
18809
 
 
18810
-  e0 = gen_reg_rtx (mode);
 
18811
-  rs6000_emit_nmsub (e0, d, x0, one);          /* e0 = 1. - d * x0 */
 
18812
+  /* Each iteration but the last calculates x_(i+1) = x_i * (2 - d * x_i).  */
 
18813
+  if (passes > 1) {
 
18814
 
 
18815
-  y1 = gen_reg_rtx (mode);
 
18816
-  rs6000_emit_madd (y1, e0, x0, x0);           /* y1 = x0 + e0 * x0 */
 
18817
+    /* e0 = 1. - d * x0  */
 
18818
+    e0 = gen_reg_rtx (mode);
 
18819
+    rs6000_emit_nmsub (e0, d, x0, one);
 
18820
 
 
18821
-  e1 = gen_reg_rtx (mode);
 
18822
-  emit_insn (gen_mul (e1, e0, e0));            /* e1 = e0 * e0 */
 
18823
+    /* x1 = x0 + e0 * x0  */
 
18824
+    x1 = gen_reg_rtx (mode);
 
18825
+    rs6000_emit_madd (x1, e0, x0, x0);
 
18826
 
 
18827
-  y2 = gen_reg_rtx (mode);
 
18828
-  rs6000_emit_madd (y2, e1, y1, y1);           /* y2 = y1 + e1 * y1 */
 
18829
+    for (i = 0, xprev = x1, eprev = e0; i < passes - 2;
 
18830
+        ++i, xprev = xnext, eprev = enext) {
 
18831
+      
 
18832
+      /* enext = eprev * eprev  */
 
18833
+      enext = gen_reg_rtx (mode);
 
18834
+      emit_insn (gen_mul (enext, eprev, eprev));
 
18835
 
 
18836
-  e2 = gen_reg_rtx (mode);
 
18837
-  emit_insn (gen_mul (e2, e1, e1));            /* e2 = e1 * e1 */
 
18838
+      /* xnext = xprev + enext * xprev  */
 
18839
+      xnext = gen_reg_rtx (mode);
 
18840
+      rs6000_emit_madd (xnext, enext, xprev, xprev);
 
18841
+    }
 
18842
 
 
18843
-  y3 = gen_reg_rtx (mode);
 
18844
-  rs6000_emit_madd (y3, e2, y2, y2);           /* y3 = y2 + e2 * y2 */
 
18845
+  } else
 
18846
+    xprev = x0;
 
18847
 
 
18848
-  u0 = gen_reg_rtx (mode);
 
18849
-  emit_insn (gen_mul (u0, n, y3));             /* u0 = n * y3 */
 
18850
+  /* The last iteration calculates x_(i+1) = n * x_i * (2 - d * x_i).  */
 
18851
 
 
18852
-  v0 = gen_reg_rtx (mode);
 
18853
-  rs6000_emit_nmsub (v0, d, u0, n);            /* v0 = n - d * u0 */
 
18854
+  /* u = n * xprev  */
 
18855
+  u = gen_reg_rtx (mode);
 
18856
+  emit_insn (gen_mul (u, n, xprev));
 
18857
 
 
18858
-  rs6000_emit_madd (dst, v0, y3, u0);          /* dst = u0 + v0 * y3 */
 
18859
-}
 
18860
+  /* v = n - (d * u)  */
 
18861
+  v = gen_reg_rtx (mode);
 
18862
+  rs6000_emit_nmsub (v, d, u, n);
 
18863
 
 
18864
-/* Newton-Raphson approximation of floating point divide DST = N/D.  If NOTE_P,
 
18865
-   add a reg_note saying that this was a division.  Support both scalar and
 
18866
-   vector divide.  Assumes no trapping math and finite arguments.  */
 
18867
+  /* dst = (v * xprev) + u  */
 
18868
+  rs6000_emit_madd (dst, v, xprev, u);
 
18869
 
 
18870
-void
 
18871
-rs6000_emit_swdiv (rtx dst, rtx n, rtx d, bool note_p)
 
18872
-{
 
18873
-  enum machine_mode mode = GET_MODE (dst);
 
18874
-
 
18875
-  if (RS6000_RECIP_HIGH_PRECISION_P (mode))
 
18876
-    rs6000_emit_swdiv_high_precision (dst, n, d);
 
18877
-  else
 
18878
-    rs6000_emit_swdiv_low_precision (dst, n, d);
 
18879
-
 
18880
   if (note_p)
 
18881
     add_reg_note (get_last_insn (), REG_EQUAL, gen_rtx_DIV (mode, n, d));
 
18882
 }
 
18883
@@ -26759,7 +29502,16 @@
 
18884
   enum machine_mode mode = GET_MODE (src);
 
18885
   rtx x0 = gen_reg_rtx (mode);
 
18886
   rtx y = gen_reg_rtx (mode);
 
18887
-  int passes = (TARGET_RECIP_PRECISION) ? 2 : 3;
 
18888
+
 
18889
+  /* Low precision estimates guarantee 5 bits of accuracy.  High
 
18890
+     precision estimates guarantee 14 bits of accuracy.  SFmode
 
18891
+     requires 23 bits of accuracy.  DFmode requires 52 bits of
 
18892
+     accuracy.  Each pass at least doubles the accuracy, leading
 
18893
+     to the following.  */
 
18894
+  int passes = (TARGET_RECIP_PRECISION) ? 1 : 3;
 
18895
+  if (mode == DFmode || mode == V2DFmode)
 
18896
+    passes++;
 
18897
+
 
18898
   REAL_VALUE_TYPE dconst3_2;
 
18899
   int i;
 
18900
   rtx halfthree;
 
18901
@@ -26921,6 +29673,136 @@
 
18902
     }
 
18903
 }
 
18904
 
 
18905
+/* Expand an Altivec constant permutation for little endian mode.
 
18906
+   There are two issues: First, the two input operands must be
 
18907
+   swapped so that together they form a double-wide array in LE
 
18908
+   order.  Second, the vperm instruction has surprising behavior
 
18909
+   in LE mode:  it interprets the elements of the source vectors
 
18910
+   in BE mode ("left to right") and interprets the elements of
 
18911
+   the destination vector in LE mode ("right to left").  To
 
18912
+   correct for this, we must subtract each element of the permute
 
18913
+   control vector from 31.
 
18914
+
 
18915
+   For example, suppose we want to concatenate vr10 = {0, 1, 2, 3}
 
18916
+   with vr11 = {4, 5, 6, 7} and extract {0, 2, 4, 6} using a vperm.
 
18917
+   We place {0,1,2,3,8,9,10,11,16,17,18,19,24,25,26,27} in vr12 to
 
18918
+   serve as the permute control vector.  Then, in BE mode,
 
18919
+
 
18920
+     vperm 9,10,11,12
 
18921
+
 
18922
+   places the desired result in vr9.  However, in LE mode the 
 
18923
+   vector contents will be
 
18924
+
 
18925
+     vr10 = 00000003 00000002 00000001 00000000
 
18926
+     vr11 = 00000007 00000006 00000005 00000004
 
18927
+
 
18928
+   The result of the vperm using the same permute control vector is
 
18929
+
 
18930
+     vr9  = 05000000 07000000 01000000 03000000
 
18931
+
 
18932
+   That is, the leftmost 4 bytes of vr10 are interpreted as the
 
18933
+   source for the rightmost 4 bytes of vr9, and so on.
 
18934
+
 
18935
+   If we change the permute control vector to
 
18936
+
 
18937
+     vr12 = {31,20,29,28,23,22,21,20,15,14,13,12,7,6,5,4}
 
18938
+
 
18939
+   and issue
 
18940
+
 
18941
+     vperm 9,11,10,12
 
18942
+
 
18943
+   we get the desired
 
18944
+
 
18945
+   vr9  = 00000006 00000004 00000002 00000000.  */
 
18946
+
 
18947
+void
 
18948
+altivec_expand_vec_perm_const_le (rtx operands[4])
 
18949
+{
 
18950
+  unsigned int i;
 
18951
+  rtx perm[16];
 
18952
+  rtx constv, unspec;
 
18953
+  rtx target = operands[0];
 
18954
+  rtx op0 = operands[1];
 
18955
+  rtx op1 = operands[2];
 
18956
+  rtx sel = operands[3];
 
18957
+
 
18958
+  /* Unpack and adjust the constant selector.  */
 
18959
+  for (i = 0; i < 16; ++i)
 
18960
+    {
 
18961
+      rtx e = XVECEXP (sel, 0, i);
 
18962
+      unsigned int elt = 31 - (INTVAL (e) & 31);
 
18963
+      perm[i] = GEN_INT (elt);
 
18964
+    }
 
18965
+
 
18966
+  /* Expand to a permute, swapping the inputs and using the
 
18967
+     adjusted selector.  */
 
18968
+  if (!REG_P (op0))
 
18969
+    op0 = force_reg (V16QImode, op0);
 
18970
+  if (!REG_P (op1))
 
18971
+    op1 = force_reg (V16QImode, op1);
 
18972
+
 
18973
+  constv = gen_rtx_CONST_VECTOR (V16QImode, gen_rtvec_v (16, perm));
 
18974
+  constv = force_reg (V16QImode, constv);
 
18975
+  unspec = gen_rtx_UNSPEC (V16QImode, gen_rtvec (3, op1, op0, constv),
 
18976
+                          UNSPEC_VPERM);
 
18977
+  if (!REG_P (target))
 
18978
+    {
 
18979
+      rtx tmp = gen_reg_rtx (V16QImode);
 
18980
+      emit_move_insn (tmp, unspec);
 
18981
+      unspec = tmp;
 
18982
+    }
 
18983
+
 
18984
+  emit_move_insn (target, unspec);
 
18985
+}
 
18986
+
 
18987
+/* Similarly to altivec_expand_vec_perm_const_le, we must adjust the
 
18988
+   permute control vector.  But here it's not a constant, so we must
 
18989
+   generate a vector splat/subtract to do the adjustment.  */
 
18990
+
 
18991
+void
 
18992
+altivec_expand_vec_perm_le (rtx operands[4])
 
18993
+{
 
18994
+  rtx splat, unspec;
 
18995
+  rtx target = operands[0];
 
18996
+  rtx op0 = operands[1];
 
18997
+  rtx op1 = operands[2];
 
18998
+  rtx sel = operands[3];
 
18999
+  rtx tmp = target;
 
19000
+
 
19001
+  /* Get everything in regs so the pattern matches.  */
 
19002
+  if (!REG_P (op0))
 
19003
+    op0 = force_reg (V16QImode, op0);
 
19004
+  if (!REG_P (op1))
 
19005
+    op1 = force_reg (V16QImode, op1);
 
19006
+  if (!REG_P (sel))
 
19007
+    sel = force_reg (V16QImode, sel);
 
19008
+  if (!REG_P (target))
 
19009
+    tmp = gen_reg_rtx (V16QImode);
 
19010
+
 
19011
+  /* SEL = splat(31) - SEL.  */
 
19012
+  /* We want to subtract from 31, but we can't vspltisb 31 since
 
19013
+     it's out of range.  -1 works as well because only the low-order
 
19014
+     five bits of the permute control vector elements are used.  */
 
19015
+  splat = gen_rtx_VEC_DUPLICATE (V16QImode,
 
19016
+                                gen_rtx_CONST_INT (QImode, -1));
 
19017
+  emit_move_insn (tmp, splat);
 
19018
+  sel = gen_rtx_MINUS (V16QImode, tmp, sel);
 
19019
+  emit_move_insn (tmp, sel);
 
19020
+
 
19021
+  /* Permute with operands reversed and adjusted selector.  */
 
19022
+  unspec = gen_rtx_UNSPEC (V16QImode, gen_rtvec (3, op1, op0, tmp),
 
19023
+                          UNSPEC_VPERM);
 
19024
+
 
19025
+  /* Copy into target, possibly by way of a register.  */
 
19026
+  if (!REG_P (target))
 
19027
+    {
 
19028
+      emit_move_insn (tmp, unspec);
 
19029
+      unspec = tmp;
 
19030
+    }
 
19031
+
 
19032
+  emit_move_insn (target, unspec);
 
19033
+}
 
19034
+
 
19035
 /* Expand an Altivec constant permutation.  Return true if we match
 
19036
    an efficient implementation; false to fall back to VPERM.  */
 
19037
 
 
19038
@@ -26928,26 +29810,37 @@
 
19039
 altivec_expand_vec_perm_const (rtx operands[4])
 
19040
 {
 
19041
   struct altivec_perm_insn {
 
19042
+    HOST_WIDE_INT mask;
 
19043
     enum insn_code impl;
 
19044
     unsigned char perm[16];
 
19045
   };
 
19046
   static const struct altivec_perm_insn patterns[] = {
 
19047
-    { CODE_FOR_altivec_vpkuhum,
 
19048
+    { OPTION_MASK_ALTIVEC, CODE_FOR_altivec_vpkuhum,
 
19049
       {  1,  3,  5,  7,  9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31 } },
 
19050
-    { CODE_FOR_altivec_vpkuwum,
 
19051
+    { OPTION_MASK_ALTIVEC, CODE_FOR_altivec_vpkuwum,
 
19052
       {  2,  3,  6,  7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31 } },
 
19053
-    { CODE_FOR_altivec_vmrghb,
 
19054
+    { OPTION_MASK_ALTIVEC, 
 
19055
+      BYTES_BIG_ENDIAN ? CODE_FOR_altivec_vmrghb : CODE_FOR_altivec_vmrglb,
 
19056
       {  0, 16,  1, 17,  2, 18,  3, 19,  4, 20,  5, 21,  6, 22,  7, 23 } },
 
19057
-    { CODE_FOR_altivec_vmrghh,
 
19058
+    { OPTION_MASK_ALTIVEC,
 
19059
+      BYTES_BIG_ENDIAN ? CODE_FOR_altivec_vmrghh : CODE_FOR_altivec_vmrglh,
 
19060
       {  0,  1, 16, 17,  2,  3, 18, 19,  4,  5, 20, 21,  6,  7, 22, 23 } },
 
19061
-    { CODE_FOR_altivec_vmrghw,
 
19062
+    { OPTION_MASK_ALTIVEC,
 
19063
+      BYTES_BIG_ENDIAN ? CODE_FOR_altivec_vmrghw : CODE_FOR_altivec_vmrglw,
 
19064
       {  0,  1,  2,  3, 16, 17, 18, 19,  4,  5,  6,  7, 20, 21, 22, 23 } },
 
19065
-    { CODE_FOR_altivec_vmrglb,
 
19066
+    { OPTION_MASK_ALTIVEC,
 
19067
+      BYTES_BIG_ENDIAN ? CODE_FOR_altivec_vmrglb : CODE_FOR_altivec_vmrghb,
 
19068
       {  8, 24,  9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31 } },
 
19069
-    { CODE_FOR_altivec_vmrglh,
 
19070
+    { OPTION_MASK_ALTIVEC,
 
19071
+      BYTES_BIG_ENDIAN ? CODE_FOR_altivec_vmrglh : CODE_FOR_altivec_vmrghh,
 
19072
       {  8,  9, 24, 25, 10, 11, 26, 27, 12, 13, 28, 29, 14, 15, 30, 31 } },
 
19073
-    { CODE_FOR_altivec_vmrglw,
 
19074
-      {  8,  9, 10, 11, 24, 25, 26, 27, 12, 13, 14, 15, 28, 29, 30, 31 } }
 
19075
+    { OPTION_MASK_ALTIVEC,
 
19076
+      BYTES_BIG_ENDIAN ? CODE_FOR_altivec_vmrglw : CODE_FOR_altivec_vmrghw,
 
19077
+      {  8,  9, 10, 11, 24, 25, 26, 27, 12, 13, 14, 15, 28, 29, 30, 31 } },
 
19078
+    { OPTION_MASK_P8_VECTOR, CODE_FOR_p8_vmrgew,
 
19079
+      {  0,  1,  2,  3, 16, 17, 18, 19,  8,  9, 10, 11, 24, 25, 26, 27 } },
 
19080
+    { OPTION_MASK_P8_VECTOR, CODE_FOR_p8_vmrgow,
 
19081
+      {  4,  5,  6,  7, 20, 21, 22, 23, 12, 13, 14, 15, 28, 29, 30, 31 } }
 
19082
   };
 
19083
 
 
19084
   unsigned int i, j, elt, which;
 
19085
@@ -27004,6 +29897,8 @@
 
19086
          break;
 
19087
       if (i == 16)
 
19088
        {
 
19089
+          if (!BYTES_BIG_ENDIAN)
 
19090
+            elt = 15 - elt;
 
19091
          emit_insn (gen_altivec_vspltb (target, op0, GEN_INT (elt)));
 
19092
          return true;
 
19093
        }
 
19094
@@ -27015,9 +29910,10 @@
 
19095
              break;
 
19096
          if (i == 16)
 
19097
            {
 
19098
+             int field = BYTES_BIG_ENDIAN ? elt / 2 : 7 - elt / 2;
 
19099
              x = gen_reg_rtx (V8HImode);
 
19100
              emit_insn (gen_altivec_vsplth (x, gen_lowpart (V8HImode, op0),
 
19101
-                                            GEN_INT (elt / 2)));
 
19102
+                                            GEN_INT (field)));
 
19103
              emit_move_insn (target, gen_lowpart (V16QImode, x));
 
19104
              return true;
 
19105
            }
 
19106
@@ -27033,9 +29929,10 @@
 
19107
              break;
 
19108
          if (i == 16)
 
19109
            {
 
19110
+             int field = BYTES_BIG_ENDIAN ? elt / 4 : 3 - elt / 4;
 
19111
              x = gen_reg_rtx (V4SImode);
 
19112
              emit_insn (gen_altivec_vspltw (x, gen_lowpart (V4SImode, op0),
 
19113
-                                            GEN_INT (elt / 4)));
 
19114
+                                            GEN_INT (field)));
 
19115
              emit_move_insn (target, gen_lowpart (V16QImode, x));
 
19116
              return true;
 
19117
            }
 
19118
@@ -27047,6 +29944,9 @@
 
19119
     {
 
19120
       bool swapped;
 
19121
 
 
19122
+      if ((patterns[j].mask & rs6000_isa_flags) == 0)
 
19123
+       continue;
 
19124
+
 
19125
       elt = patterns[j].perm[0];
 
19126
       if (perm[0] == elt)
 
19127
        swapped = false;
 
19128
@@ -27070,7 +29970,30 @@
 
19129
          enum machine_mode omode = insn_data[icode].operand[0].mode;
 
19130
          enum machine_mode imode = insn_data[icode].operand[1].mode;
 
19131
 
 
19132
-         if (swapped)
 
19133
+         /* For little-endian, don't use vpkuwum and vpkuhum if the
 
19134
+            underlying vector type is not V4SI and V8HI, respectively.
 
19135
+            For example, using vpkuwum with a V8HI picks up the even
 
19136
+            halfwords (BE numbering) when the even halfwords (LE
 
19137
+            numbering) are what we need.  */
 
19138
+         if (!BYTES_BIG_ENDIAN
 
19139
+             && icode == CODE_FOR_altivec_vpkuwum
 
19140
+             && ((GET_CODE (op0) == REG
 
19141
+                  && GET_MODE (op0) != V4SImode)
 
19142
+                 || (GET_CODE (op0) == SUBREG
 
19143
+                     && GET_MODE (XEXP (op0, 0)) != V4SImode)))
 
19144
+           continue;
 
19145
+         if (!BYTES_BIG_ENDIAN
 
19146
+             && icode == CODE_FOR_altivec_vpkuhum
 
19147
+             && ((GET_CODE (op0) == REG
 
19148
+                  && GET_MODE (op0) != V8HImode)
 
19149
+                 || (GET_CODE (op0) == SUBREG
 
19150
+                     && GET_MODE (XEXP (op0, 0)) != V8HImode)))
 
19151
+           continue;
 
19152
+
 
19153
+          /* For little-endian, the two input operands must be swapped
 
19154
+             (or swapped back) to ensure proper right-to-left numbering
 
19155
+             from 0 to 2N-1.  */
 
19156
+         if (swapped ^ !BYTES_BIG_ENDIAN)
 
19157
            x = op0, op0 = op1, op1 = x;
 
19158
          if (imode != V16QImode)
 
19159
            {
 
19160
@@ -27088,6 +30011,12 @@
 
19161
        }
 
19162
     }
 
19163
 
 
19164
+  if (!BYTES_BIG_ENDIAN)
 
19165
+    {
 
19166
+      altivec_expand_vec_perm_const_le (operands);
 
19167
+      return true;
 
19168
+    }
 
19169
+
 
19170
   return false;
 
19171
 }
 
19172
 
 
19173
@@ -27137,6 +30066,21 @@
 
19174
       gcc_assert (GET_MODE_NUNITS (vmode) == 2);
 
19175
       dmode = mode_for_vector (GET_MODE_INNER (vmode), 4);
 
19176
 
 
19177
+      /* For little endian, swap operands and invert/swap selectors
 
19178
+        to get the correct xxpermdi.  The operand swap sets up the
 
19179
+        inputs as a little endian array.  The selectors are swapped
 
19180
+        because they are defined to use big endian ordering.  The
 
19181
+        selectors are inverted to get the correct doublewords for
 
19182
+        little endian ordering.  */
 
19183
+      if (!BYTES_BIG_ENDIAN)
 
19184
+       {
 
19185
+         int n;
 
19186
+         perm0 = 3 - perm0;
 
19187
+         perm1 = 3 - perm1;
 
19188
+         n = perm0, perm0 = perm1, perm1 = n;
 
19189
+         x = op0, op0 = op1, op1 = x;
 
19190
+       }
 
19191
+
 
19192
       x = gen_rtx_VEC_CONCAT (dmode, op0, op1);
 
19193
       v = gen_rtvec (2, GEN_INT (perm0), GEN_INT (perm1));
 
19194
       x = gen_rtx_VEC_SELECT (vmode, x, gen_rtx_PARALLEL (VOIDmode, v));
 
19195
@@ -27232,7 +30176,7 @@
 
19196
   unsigned i, high, nelt = GET_MODE_NUNITS (vmode);
 
19197
   rtx perm[16];
 
19198
 
 
19199
-  high = (highp == BYTES_BIG_ENDIAN ? 0 : nelt / 2);
 
19200
+  high = (highp ? 0 : nelt / 2);
 
19201
   for (i = 0; i < nelt / 2; i++)
 
19202
     {
 
19203
       perm[i * 2] = GEN_INT (i + high);
 
19204
@@ -27287,6 +30231,8 @@
 
19205
 {
 
19206
   enum machine_mode mode;
 
19207
   unsigned int regno;
 
19208
+  enum machine_mode elt_mode;
 
19209
+  int n_elts;
 
19210
 
 
19211
   /* Special handling for structs in darwin64.  */
 
19212
   if (TARGET_MACHO 
 
19213
@@ -27306,6 +30252,36 @@
 
19214
       /* Otherwise fall through to standard ABI rules.  */
 
19215
     }
 
19216
 
 
19217
+  /* The ELFv2 ABI returns homogeneous VFP aggregates in registers.  */
 
19218
+  if (rs6000_discover_homogeneous_aggregate (TYPE_MODE (valtype), valtype,
 
19219
+                                            &elt_mode, &n_elts))
 
19220
+    {
 
19221
+      int first_reg, n_regs, i;
 
19222
+      rtx par;
 
19223
+
 
19224
+      if (SCALAR_FLOAT_MODE_P (elt_mode))
 
19225
+       {
 
19226
+         /* _Decimal128 must use even/odd register pairs.  */
 
19227
+         first_reg = (elt_mode == TDmode) ? FP_ARG_RETURN + 1 : FP_ARG_RETURN;
 
19228
+         n_regs = (GET_MODE_SIZE (elt_mode) + 7) >> 3;
 
19229
+       }
 
19230
+      else
 
19231
+       {
 
19232
+         first_reg = ALTIVEC_ARG_RETURN;
 
19233
+         n_regs = 1;
 
19234
+       }
 
19235
+
 
19236
+      par = gen_rtx_PARALLEL (TYPE_MODE (valtype), rtvec_alloc (n_elts));
 
19237
+      for (i = 0; i < n_elts; i++)
 
19238
+       {
 
19239
+         rtx r = gen_rtx_REG (elt_mode, first_reg + i * n_regs);
 
19240
+         rtx off = GEN_INT (i * GET_MODE_SIZE (elt_mode));
 
19241
+         XVECEXP (par, 0, i) = gen_rtx_EXPR_LIST (VOIDmode, r, off);
 
19242
+       }
 
19243
+
 
19244
+      return par;
 
19245
+    }
 
19246
+
 
19247
   if (TARGET_32BIT && TARGET_POWERPC64 && TYPE_MODE (valtype) == DImode)
 
19248
     {
 
19249
       /* Long long return value need be split in -mpowerpc64, 32bit ABI.  */
 
19250
@@ -27680,22 +30656,32 @@
 
19251
 {
 
19252
   { "altivec",                 OPTION_MASK_ALTIVEC,            false, true  },
 
19253
   { "cmpb",                    OPTION_MASK_CMPB,               false, true  },
 
19254
+  { "crypto",                  OPTION_MASK_CRYPTO,             false, true  },
 
19255
+  { "direct-move",             OPTION_MASK_DIRECT_MOVE,        false, true  },
 
19256
   { "dlmzb",                   OPTION_MASK_DLMZB,              false, true  },
 
19257
   { "fprnd",                   OPTION_MASK_FPRND,              false, true  },
 
19258
   { "hard-dfp",                        OPTION_MASK_DFP,                false, true  },
 
19259
+  { "htm",                     OPTION_MASK_HTM,                false, true  },
 
19260
   { "isel",                    OPTION_MASK_ISEL,               false, true  },
 
19261
   { "mfcrf",                   OPTION_MASK_MFCRF,              false, true  },
 
19262
   { "mfpgpr",                  OPTION_MASK_MFPGPR,             false, true  },
 
19263
   { "mulhw",                   OPTION_MASK_MULHW,              false, true  },
 
19264
   { "multiple",                        OPTION_MASK_MULTIPLE,           false, true  },
 
19265
-  { "update",                  OPTION_MASK_NO_UPDATE,          true , true  },
 
19266
   { "popcntb",                 OPTION_MASK_POPCNTB,            false, true  },
 
19267
   { "popcntd",                 OPTION_MASK_POPCNTD,            false, true  },
 
19268
+  { "power8-fusion",           OPTION_MASK_P8_FUSION,          false, true  },
 
19269
+  { "power8-fusion-sign",      OPTION_MASK_P8_FUSION_SIGN,     false, true  },
 
19270
+  { "power8-vector",           OPTION_MASK_P8_VECTOR,          false, true  },
 
19271
   { "powerpc-gfxopt",          OPTION_MASK_PPC_GFXOPT,         false, true  },
 
19272
   { "powerpc-gpopt",           OPTION_MASK_PPC_GPOPT,          false, true  },
 
19273
+  { "quad-memory",             OPTION_MASK_QUAD_MEMORY,        false, true  },
 
19274
   { "recip-precision",         OPTION_MASK_RECIP_PRECISION,    false, true  },
 
19275
   { "string",                  OPTION_MASK_STRING,             false, true  },
 
19276
+  { "update",                  OPTION_MASK_NO_UPDATE,          true , true  },
 
19277
+  { "upper-regs-df",           OPTION_MASK_UPPER_REGS_DF,      false, false },
 
19278
+  { "upper-regs-sf",           OPTION_MASK_UPPER_REGS_SF,      false, false },
 
19279
   { "vsx",                     OPTION_MASK_VSX,                false, true  },
 
19280
+  { "vsx-timode",              OPTION_MASK_VSX_TIMODE,         false, true  },
 
19281
 #ifdef OPTION_MASK_64BIT
 
19282
 #if TARGET_AIX_OS
 
19283
   { "aix64",                   OPTION_MASK_64BIT,              false, false },
 
19284
@@ -27735,6 +30721,9 @@
 
19285
   { "frsqrtes",                 RS6000_BTM_FRSQRTES,   false, false },
 
19286
   { "popcntd",          RS6000_BTM_POPCNTD,    false, false },
 
19287
   { "cell",             RS6000_BTM_CELL,       false, false },
 
19288
+  { "power8-vector",    RS6000_BTM_P8_VECTOR,  false, false },
 
19289
+  { "crypto",           RS6000_BTM_CRYPTO,     false, false },
 
19290
+  { "htm",              RS6000_BTM_HTM,        false, false },
 
19291
 };
 
19292
 
 
19293
 /* Option variables that we want to support inside attribute((target)) and
 
19294
@@ -28251,7 +31240,6 @@
 
19295
   size_t cur_column;
 
19296
   size_t max_column = 76;
 
19297
   const char *comma = "";
 
19298
-  const char *nl = "\n";
 
19299
 
 
19300
   if (indent)
 
19301
     start_column += fprintf (file, "%*s", indent, "");
 
19302
@@ -28282,7 +31270,6 @@
 
19303
              fprintf (stderr, ", \\\n%*s", (int)start_column, "");
 
19304
              cur_column = start_column + len;
 
19305
              comma = "";
 
19306
-             nl = "\n\n";
 
19307
            }
 
19308
 
 
19309
          fprintf (file, "%s%s%s%s", comma, prefix, no_str,
 
19310
@@ -28292,7 +31279,7 @@
 
19311
        }
 
19312
     }
 
19313
 
 
19314
-  fputs (nl, file);
 
19315
+  fputs ("\n", file);
 
19316
 }
 
19317
 
 
19318
 /* Helper function to print the current isa options on a line.  */
 
19319
@@ -28468,118 +31455,149 @@
 
19320
 }
 
19321
 
 
19322
 
 
19323
-/* A function pointer under AIX is a pointer to a data area whose first word
 
19324
-   contains the actual address of the function, whose second word contains a
 
19325
-   pointer to its TOC, and whose third word contains a value to place in the
 
19326
-   static chain register (r11).  Note that if we load the static chain, our
 
19327
-   "trampoline" need not have any executable code.  */
 
19328
 
 
19329
+/* Expand code to perform a call under the AIX or ELFv2 ABI.  */
 
19330
+
 
19331
 void
 
19332
-rs6000_call_indirect_aix (rtx value, rtx func_desc, rtx flag)
 
19333
+rs6000_call_aix (rtx value, rtx func_desc, rtx flag, rtx cookie)
 
19334
 {
 
19335
+  rtx toc_reg = gen_rtx_REG (Pmode, TOC_REGNUM);
 
19336
+  rtx toc_load = NULL_RTX;
 
19337
+  rtx toc_restore = NULL_RTX;
 
19338
   rtx func_addr;
 
19339
-  rtx toc_reg;
 
19340
-  rtx sc_reg;
 
19341
-  rtx stack_ptr;
 
19342
-  rtx stack_toc_offset;
 
19343
-  rtx stack_toc_mem;
 
19344
-  rtx func_toc_offset;
 
19345
-  rtx func_toc_mem;
 
19346
-  rtx func_sc_offset;
 
19347
-  rtx func_sc_mem;
 
19348
+  rtx abi_reg = NULL_RTX;
 
19349
+  rtx call[4];
 
19350
+  int n_call;
 
19351
   rtx insn;
 
19352
-  rtx (*call_func) (rtx, rtx, rtx, rtx);
 
19353
-  rtx (*call_value_func) (rtx, rtx, rtx, rtx, rtx);
 
19354
 
 
19355
-  stack_ptr = gen_rtx_REG (Pmode, STACK_POINTER_REGNUM);
 
19356
-  toc_reg = gen_rtx_REG (Pmode, TOC_REGNUM);
 
19357
+  /* Handle longcall attributes.  */
 
19358
+  if (INTVAL (cookie) & CALL_LONG)
 
19359
+    func_desc = rs6000_longcall_ref (func_desc);
 
19360
 
 
19361
-  /* Load up address of the actual function.  */
 
19362
-  func_desc = force_reg (Pmode, func_desc);
 
19363
-  func_addr = gen_reg_rtx (Pmode);
 
19364
-  emit_move_insn (func_addr, gen_rtx_MEM (Pmode, func_desc));
 
19365
-
 
19366
-  if (TARGET_32BIT)
 
19367
+  /* Handle indirect calls.  */
 
19368
+  if (GET_CODE (func_desc) != SYMBOL_REF
 
19369
+      || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (func_desc)))
 
19370
     {
 
19371
+      /* Save the TOC into its reserved slot before the call,
 
19372
+        and prepare to restore it after the call.  */
 
19373
+      rtx stack_ptr = gen_rtx_REG (Pmode, STACK_POINTER_REGNUM);
 
19374
+      rtx stack_toc_offset = GEN_INT (RS6000_TOC_SAVE_SLOT);
 
19375
+      rtx stack_toc_mem = gen_frame_mem (Pmode,
 
19376
+                                        gen_rtx_PLUS (Pmode, stack_ptr,
 
19377
+                                                      stack_toc_offset));
 
19378
+      toc_restore = gen_rtx_SET (VOIDmode, toc_reg, stack_toc_mem);
 
19379
 
 
19380
-      stack_toc_offset = GEN_INT (TOC_SAVE_OFFSET_32BIT);
 
19381
-      func_toc_offset = GEN_INT (AIX_FUNC_DESC_TOC_32BIT);
 
19382
-      func_sc_offset = GEN_INT (AIX_FUNC_DESC_SC_32BIT);
 
19383
-      if (TARGET_POINTERS_TO_NESTED_FUNCTIONS)
 
19384
-       {
 
19385
-         call_func = gen_call_indirect_aix32bit;
 
19386
-         call_value_func = gen_call_value_indirect_aix32bit;
 
19387
-       }
 
19388
+      /* Can we optimize saving the TOC in the prologue or
 
19389
+        do we need to do it at every call?  */
 
19390
+      if (TARGET_SAVE_TOC_INDIRECT && !cfun->calls_alloca)
 
19391
+       cfun->machine->save_toc_in_prologue = true;
 
19392
       else
 
19393
        {
 
19394
-         call_func = gen_call_indirect_aix32bit_nor11;
 
19395
-         call_value_func = gen_call_value_indirect_aix32bit_nor11;
 
19396
+         MEM_VOLATILE_P (stack_toc_mem) = 1;
 
19397
+         emit_move_insn (stack_toc_mem, toc_reg);
 
19398
        }
 
19399
-    }
 
19400
-  else
 
19401
-    {
 
19402
-      stack_toc_offset = GEN_INT (TOC_SAVE_OFFSET_64BIT);
 
19403
-      func_toc_offset = GEN_INT (AIX_FUNC_DESC_TOC_64BIT);
 
19404
-      func_sc_offset = GEN_INT (AIX_FUNC_DESC_SC_64BIT);
 
19405
-      if (TARGET_POINTERS_TO_NESTED_FUNCTIONS)
 
19406
+
 
19407
+      if (DEFAULT_ABI == ABI_ELFv2)
 
19408
        {
 
19409
-         call_func = gen_call_indirect_aix64bit;
 
19410
-         call_value_func = gen_call_value_indirect_aix64bit;
 
19411
+         /* A function pointer in the ELFv2 ABI is just a plain address, but
 
19412
+            the ABI requires it to be loaded into r12 before the call.  */
 
19413
+         func_addr = gen_rtx_REG (Pmode, 12);
 
19414
+         emit_move_insn (func_addr, func_desc);
 
19415
+         abi_reg = func_addr;
 
19416
        }
 
19417
       else
 
19418
        {
 
19419
-         call_func = gen_call_indirect_aix64bit_nor11;
 
19420
-         call_value_func = gen_call_value_indirect_aix64bit_nor11;
 
19421
-       }
 
19422
-    }
 
19423
+         /* A function pointer under AIX is a pointer to a data area whose
 
19424
+            first word contains the actual address of the function, whose
 
19425
+            second word contains a pointer to its TOC, and whose third word
 
19426
+            contains a value to place in the static chain register (r11).
 
19427
+            Note that if we load the static chain, our "trampoline" need
 
19428
+            not have any executable code.  */
 
19429
 
 
19430
-  /* Reserved spot to store the TOC.  */
 
19431
-  stack_toc_mem = gen_frame_mem (Pmode,
 
19432
-                                gen_rtx_PLUS (Pmode,
 
19433
-                                              stack_ptr,
 
19434
-                                              stack_toc_offset));
 
19435
+         /* Load up address of the actual function.  */
 
19436
+         func_desc = force_reg (Pmode, func_desc);
 
19437
+         func_addr = gen_reg_rtx (Pmode);
 
19438
+         emit_move_insn (func_addr, gen_rtx_MEM (Pmode, func_desc));
 
19439
 
 
19440
-  gcc_assert (cfun);
 
19441
-  gcc_assert (cfun->machine);
 
19442
+         /* Prepare to load the TOC of the called function.  Note that the
 
19443
+            TOC load must happen immediately before the actual call so
 
19444
+            that unwinding the TOC registers works correctly.  See the
 
19445
+            comment in frob_update_context.  */
 
19446
+         rtx func_toc_offset = GEN_INT (GET_MODE_SIZE (Pmode));
 
19447
+         rtx func_toc_mem = gen_rtx_MEM (Pmode,
 
19448
+                                         gen_rtx_PLUS (Pmode, func_desc,
 
19449
+                                                       func_toc_offset));
 
19450
+         toc_load = gen_rtx_USE (VOIDmode, func_toc_mem);
 
19451
 
 
19452
-  /* Can we optimize saving the TOC in the prologue or do we need to do it at
 
19453
-     every call?  */
 
19454
-  if (TARGET_SAVE_TOC_INDIRECT && !cfun->calls_alloca)
 
19455
-    cfun->machine->save_toc_in_prologue = true;
 
19456
-
 
19457
+         /* If we have a static chain, load it up.  */
 
19458
+         if (TARGET_POINTERS_TO_NESTED_FUNCTIONS)
 
19459
+           {
 
19460
+             rtx sc_reg = gen_rtx_REG (Pmode, STATIC_CHAIN_REGNUM);
 
19461
+             rtx func_sc_offset = GEN_INT (2 * GET_MODE_SIZE (Pmode));
 
19462
+             rtx func_sc_mem = gen_rtx_MEM (Pmode,
 
19463
+                                            gen_rtx_PLUS (Pmode, func_desc,
 
19464
+                                                          func_sc_offset));
 
19465
+             emit_move_insn (sc_reg, func_sc_mem);
 
19466
+             abi_reg = sc_reg;
 
19467
+           }
 
19468
+       }
 
19469
+    }
 
19470
   else
 
19471
     {
 
19472
-      MEM_VOLATILE_P (stack_toc_mem) = 1;
 
19473
-      emit_move_insn (stack_toc_mem, toc_reg);
 
19474
+      /* Direct calls use the TOC: for local calls, the callee will
 
19475
+        assume the TOC register is set; for non-local calls, the
 
19476
+        PLT stub needs the TOC register.  */
 
19477
+      abi_reg = toc_reg;
 
19478
+      func_addr = func_desc;
 
19479
     }
 
19480
 
 
19481
-  /* Calculate the address to load the TOC of the called function.  We don't
 
19482
-     actually load this until the split after reload.  */
 
19483
-  func_toc_mem = gen_rtx_MEM (Pmode,
 
19484
-                             gen_rtx_PLUS (Pmode,
 
19485
-                                           func_desc,
 
19486
-                                           func_toc_offset));
 
19487
+  /* Create the call.  */
 
19488
+  call[0] = gen_rtx_CALL (VOIDmode, gen_rtx_MEM (SImode, func_addr), flag);
 
19489
+  if (value != NULL_RTX)
 
19490
+    call[0] = gen_rtx_SET (VOIDmode, value, call[0]);
 
19491
+  n_call = 1;
 
19492
 
 
19493
-  /* If we have a static chain, load it up.  */
 
19494
-  if (TARGET_POINTERS_TO_NESTED_FUNCTIONS)
 
19495
-    {
 
19496
-      func_sc_mem = gen_rtx_MEM (Pmode,
 
19497
-                                gen_rtx_PLUS (Pmode,
 
19498
-                                              func_desc,
 
19499
-                                              func_sc_offset));
 
19500
+  if (toc_load)
 
19501
+    call[n_call++] = toc_load;
 
19502
+  if (toc_restore)
 
19503
+    call[n_call++] = toc_restore;
 
19504
 
 
19505
-      sc_reg = gen_rtx_REG (Pmode, STATIC_CHAIN_REGNUM);
 
19506
-      emit_move_insn (sc_reg, func_sc_mem);
 
19507
-    }
 
19508
+  call[n_call++] = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (Pmode, LR_REGNO));
 
19509
 
 
19510
+  insn = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (n_call, call));
 
19511
+  insn = emit_call_insn (insn);
 
19512
+
 
19513
+  /* Mention all registers defined by the ABI to hold information
 
19514
+     as uses in CALL_INSN_FUNCTION_USAGE.  */
 
19515
+  if (abi_reg)
 
19516
+    use_reg (&CALL_INSN_FUNCTION_USAGE (insn), abi_reg);
 
19517
+}
 
19518
+
 
19519
+/* Expand code to perform a sibling call under the AIX or ELFv2 ABI.  */
 
19520
+
 
19521
+void
 
19522
+rs6000_sibcall_aix (rtx value, rtx func_desc, rtx flag, rtx cookie)
 
19523
+{
 
19524
+  rtx call[2];
 
19525
+  rtx insn;
 
19526
+
 
19527
+  gcc_assert (INTVAL (cookie) == 0);
 
19528
+
 
19529
   /* Create the call.  */
 
19530
-  if (value)
 
19531
-    insn = call_value_func (value, func_addr, flag, func_toc_mem,
 
19532
-                           stack_toc_mem);
 
19533
-  else
 
19534
-    insn = call_func (func_addr, flag, func_toc_mem, stack_toc_mem);
 
19535
+  call[0] = gen_rtx_CALL (VOIDmode, gen_rtx_MEM (SImode, func_desc), flag);
 
19536
+  if (value != NULL_RTX)
 
19537
+    call[0] = gen_rtx_SET (VOIDmode, value, call[0]);
 
19538
 
 
19539
-  emit_call_insn (insn);
 
19540
+  call[1] = simple_return_rtx;
 
19541
+
 
19542
+  insn = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (2, call));
 
19543
+  insn = emit_call_insn (insn);
 
19544
+
 
19545
+  /* Note use of the TOC register.  */
 
19546
+  use_reg (&CALL_INSN_FUNCTION_USAGE (insn), gen_rtx_REG (Pmode, TOC_REGNUM));
 
19547
+  /* We need to also mark a use of the link register since the function we
 
19548
+     sibling-call to will use it to return to our caller.  */
 
19549
+  use_reg (&CALL_INSN_FUNCTION_USAGE (insn), gen_rtx_REG (Pmode, LR_REGNO));
 
19550
 }
 
19551
 
 
19552
 /* Return whether we need to always update the saved TOC pointer when we update
 
19553
@@ -28680,6 +31698,656 @@
 
19554
     add_to_hard_reg_set (&set->set, Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
 
19555
 }
 
19556
 
 
19557
+
 
19558
+/* Helper function for rs6000_split_logical to emit a logical instruction after
 
19559
+   spliting the operation to single GPR registers.
 
19560
+
 
19561
+   DEST is the destination register.
 
19562
+   OP1 and OP2 are the input source registers.
 
19563
+   CODE is the base operation (AND, IOR, XOR, NOT).
 
19564
+   MODE is the machine mode.
 
19565
+   If COMPLEMENT_FINAL_P is true, wrap the whole operation with NOT.
 
19566
+   If COMPLEMENT_OP1_P is true, wrap operand1 with NOT.
 
19567
+   If COMPLEMENT_OP2_P is true, wrap operand2 with NOT.
 
19568
+   CLOBBER_REG is either NULL or a scratch register of type CC to allow
 
19569
+   formation of the AND instructions.  */
 
19570
+
 
19571
+static void
 
19572
+rs6000_split_logical_inner (rtx dest,
 
19573
+                           rtx op1,
 
19574
+                           rtx op2,
 
19575
+                           enum rtx_code code,
 
19576
+                           enum machine_mode mode,
 
19577
+                           bool complement_final_p,
 
19578
+                           bool complement_op1_p,
 
19579
+                           bool complement_op2_p,
 
19580
+                           rtx clobber_reg)
 
19581
+{
 
19582
+  rtx bool_rtx;
 
19583
+  rtx set_rtx;
 
19584
+
 
19585
+  /* Optimize AND of 0/0xffffffff and IOR/XOR of 0.  */
 
19586
+  if (op2 && GET_CODE (op2) == CONST_INT
 
19587
+      && (mode == SImode || (mode == DImode && TARGET_POWERPC64))
 
19588
+      && !complement_final_p && !complement_op1_p && !complement_op2_p)
 
19589
+    {
 
19590
+      HOST_WIDE_INT mask = GET_MODE_MASK (mode);
 
19591
+      HOST_WIDE_INT value = INTVAL (op2) & mask;
 
19592
+
 
19593
+      /* Optimize AND of 0 to just set 0.  Optimize AND of -1 to be a move.  */
 
19594
+      if (code == AND)
 
19595
+       {
 
19596
+         if (value == 0)
 
19597
+           {
 
19598
+             emit_insn (gen_rtx_SET (VOIDmode, dest, const0_rtx));
 
19599
+             return;
 
19600
+           }
 
19601
+
 
19602
+         else if (value == mask)
 
19603
+           {
 
19604
+             if (!rtx_equal_p (dest, op1))
 
19605
+               emit_insn (gen_rtx_SET (VOIDmode, dest, op1));
 
19606
+             return;
 
19607
+           }
 
19608
+       }
 
19609
+
 
19610
+      /* Optimize IOR/XOR of 0 to be a simple move.  Split large operations
 
19611
+        into separate ORI/ORIS or XORI/XORIS instrucitons.  */
 
19612
+      else if (code == IOR || code == XOR)
 
19613
+       {
 
19614
+         if (value == 0)
 
19615
+           {
 
19616
+             if (!rtx_equal_p (dest, op1))
 
19617
+               emit_insn (gen_rtx_SET (VOIDmode, dest, op1));
 
19618
+             return;
 
19619
+           }
 
19620
+       }
 
19621
+    }
 
19622
+
 
19623
+  if (complement_op1_p)
 
19624
+    op1 = gen_rtx_NOT (mode, op1);
 
19625
+
 
19626
+  if (complement_op2_p)
 
19627
+    op2 = gen_rtx_NOT (mode, op2);
 
19628
+
 
19629
+  bool_rtx = ((code == NOT)
 
19630
+             ? gen_rtx_NOT (mode, op1)
 
19631
+             : gen_rtx_fmt_ee (code, mode, op1, op2));
 
19632
+
 
19633
+  if (complement_final_p)
 
19634
+    bool_rtx = gen_rtx_NOT (mode, bool_rtx);
 
19635
+
 
19636
+  set_rtx = gen_rtx_SET (VOIDmode, dest, bool_rtx);
 
19637
+
 
19638
+  /* Is this AND with an explicit clobber?  */
 
19639
+  if (clobber_reg)
 
19640
+    {
 
19641
+      rtx clobber = gen_rtx_CLOBBER (VOIDmode, clobber_reg);
 
19642
+      set_rtx = gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, set_rtx, clobber));
 
19643
+    }
 
19644
+
 
19645
+  emit_insn (set_rtx);
 
19646
+  return;
 
19647
+}
 
19648
+
 
19649
+/* Split a DImode AND/IOR/XOR with a constant on a 32-bit system.  These
 
19650
+   operations are split immediately during RTL generation to allow for more
 
19651
+   optimizations of the AND/IOR/XOR.
 
19652
+
 
19653
+   OPERANDS is an array containing the destination and two input operands.
 
19654
+   CODE is the base operation (AND, IOR, XOR, NOT).
 
19655
+   MODE is the machine mode.
 
19656
+   If COMPLEMENT_FINAL_P is true, wrap the whole operation with NOT.
 
19657
+   If COMPLEMENT_OP1_P is true, wrap operand1 with NOT.
 
19658
+   If COMPLEMENT_OP2_P is true, wrap operand2 with NOT.
 
19659
+   CLOBBER_REG is either NULL or a scratch register of type CC to allow
 
19660
+   formation of the AND instructions.  */
 
19661
+
 
19662
+static void
 
19663
+rs6000_split_logical_di (rtx operands[3],
 
19664
+                        enum rtx_code code,
 
19665
+                        bool complement_final_p,
 
19666
+                        bool complement_op1_p,
 
19667
+                        bool complement_op2_p,
 
19668
+                        rtx clobber_reg)
 
19669
+{
 
19670
+  const HOST_WIDE_INT lower_32bits = HOST_WIDE_INT_C(0xffffffff);
 
19671
+  const HOST_WIDE_INT upper_32bits = ~ lower_32bits;
 
19672
+  const HOST_WIDE_INT sign_bit = HOST_WIDE_INT_C(0x80000000);
 
19673
+  enum hi_lo { hi = 0, lo = 1 };
 
19674
+  rtx op0_hi_lo[2], op1_hi_lo[2], op2_hi_lo[2];
 
19675
+  size_t i;
 
19676
+
 
19677
+  op0_hi_lo[hi] = gen_highpart (SImode, operands[0]);
 
19678
+  op1_hi_lo[hi] = gen_highpart (SImode, operands[1]);
 
19679
+  op0_hi_lo[lo] = gen_lowpart (SImode, operands[0]);
 
19680
+  op1_hi_lo[lo] = gen_lowpart (SImode, operands[1]);
 
19681
+
 
19682
+  if (code == NOT)
 
19683
+    op2_hi_lo[hi] = op2_hi_lo[lo] = NULL_RTX;
 
19684
+  else
 
19685
+    {
 
19686
+      if (GET_CODE (operands[2]) != CONST_INT)
 
19687
+       {
 
19688
+         op2_hi_lo[hi] = gen_highpart_mode (SImode, DImode, operands[2]);
 
19689
+         op2_hi_lo[lo] = gen_lowpart (SImode, operands[2]);
 
19690
+       }
 
19691
+      else
 
19692
+       {
 
19693
+         HOST_WIDE_INT value = INTVAL (operands[2]);
 
19694
+         HOST_WIDE_INT value_hi_lo[2];
 
19695
+
 
19696
+         gcc_assert (!complement_final_p);
 
19697
+         gcc_assert (!complement_op1_p);
 
19698
+         gcc_assert (!complement_op2_p);
 
19699
+
 
19700
+         value_hi_lo[hi] = value >> 32;
 
19701
+         value_hi_lo[lo] = value & lower_32bits;
 
19702
+
 
19703
+         for (i = 0; i < 2; i++)
 
19704
+           {
 
19705
+             HOST_WIDE_INT sub_value = value_hi_lo[i];
 
19706
+
 
19707
+             if (sub_value & sign_bit)
 
19708
+               sub_value |= upper_32bits;
 
19709
+
 
19710
+             op2_hi_lo[i] = GEN_INT (sub_value);
 
19711
+
 
19712
+             /* If this is an AND instruction, check to see if we need to load
 
19713
+                the value in a register.  */
 
19714
+             if (code == AND && sub_value != -1 && sub_value != 0
 
19715
+                 && !and_operand (op2_hi_lo[i], SImode))
 
19716
+               op2_hi_lo[i] = force_reg (SImode, op2_hi_lo[i]);
 
19717
+           }
 
19718
+       }
 
19719
+    }
 
19720
+
 
19721
+  for (i = 0; i < 2; i++)
 
19722
+    {
 
19723
+      /* Split large IOR/XOR operations.  */
 
19724
+      if ((code == IOR || code == XOR)
 
19725
+         && GET_CODE (op2_hi_lo[i]) == CONST_INT
 
19726
+         && !complement_final_p
 
19727
+         && !complement_op1_p
 
19728
+         && !complement_op2_p
 
19729
+         && clobber_reg == NULL_RTX
 
19730
+         && !logical_const_operand (op2_hi_lo[i], SImode))
 
19731
+       {
 
19732
+         HOST_WIDE_INT value = INTVAL (op2_hi_lo[i]);
 
19733
+         HOST_WIDE_INT hi_16bits = value & HOST_WIDE_INT_C(0xffff0000);
 
19734
+         HOST_WIDE_INT lo_16bits = value & HOST_WIDE_INT_C(0x0000ffff);
 
19735
+         rtx tmp = gen_reg_rtx (SImode);
 
19736
+
 
19737
+         /* Make sure the constant is sign extended.  */
 
19738
+         if ((hi_16bits & sign_bit) != 0)
 
19739
+           hi_16bits |= upper_32bits;
 
19740
+
 
19741
+         rs6000_split_logical_inner (tmp, op1_hi_lo[i], GEN_INT (hi_16bits),
 
19742
+                                     code, SImode, false, false, false,
 
19743
+                                     NULL_RTX);
 
19744
+
 
19745
+         rs6000_split_logical_inner (op0_hi_lo[i], tmp, GEN_INT (lo_16bits),
 
19746
+                                     code, SImode, false, false, false,
 
19747
+                                     NULL_RTX);
 
19748
+       }
 
19749
+      else
 
19750
+       rs6000_split_logical_inner (op0_hi_lo[i], op1_hi_lo[i], op2_hi_lo[i],
 
19751
+                                   code, SImode, complement_final_p,
 
19752
+                                   complement_op1_p, complement_op2_p,
 
19753
+                                   clobber_reg);
 
19754
+    }
 
19755
+
 
19756
+  return;
 
19757
+}
 
19758
+
 
19759
+/* Split the insns that make up boolean operations operating on multiple GPR
 
19760
+   registers.  The boolean MD patterns ensure that the inputs either are
 
19761
+   exactly the same as the output registers, or there is no overlap.
 
19762
+
 
19763
+   OPERANDS is an array containing the destination and two input operands.
 
19764
+   CODE is the base operation (AND, IOR, XOR, NOT).
 
19765
+   MODE is the machine mode.
 
19766
+   If COMPLEMENT_FINAL_P is true, wrap the whole operation with NOT.
 
19767
+   If COMPLEMENT_OP1_P is true, wrap operand1 with NOT.
 
19768
+   If COMPLEMENT_OP2_P is true, wrap operand2 with NOT.
 
19769
+   CLOBBER_REG is either NULL or a scratch register of type CC to allow
 
19770
+   formation of the AND instructions.  */
 
19771
+
 
19772
+void
 
19773
+rs6000_split_logical (rtx operands[3],
 
19774
+                     enum rtx_code code,
 
19775
+                     bool complement_final_p,
 
19776
+                     bool complement_op1_p,
 
19777
+                     bool complement_op2_p,
 
19778
+                     rtx clobber_reg)
 
19779
+{
 
19780
+  enum machine_mode mode = GET_MODE (operands[0]);
 
19781
+  enum machine_mode sub_mode;
 
19782
+  rtx op0, op1, op2;
 
19783
+  int sub_size, regno0, regno1, nregs, i;
 
19784
+
 
19785
+  /* If this is DImode, use the specialized version that can run before
 
19786
+     register allocation.  */
 
19787
+  if (mode == DImode && !TARGET_POWERPC64)
 
19788
+    {
 
19789
+      rs6000_split_logical_di (operands, code, complement_final_p,
 
19790
+                              complement_op1_p, complement_op2_p,
 
19791
+                              clobber_reg);
 
19792
+      return;
 
19793
+    }
 
19794
+
 
19795
+  op0 = operands[0];
 
19796
+  op1 = operands[1];
 
19797
+  op2 = (code == NOT) ? NULL_RTX : operands[2];
 
19798
+  sub_mode = (TARGET_POWERPC64) ? DImode : SImode;
 
19799
+  sub_size = GET_MODE_SIZE (sub_mode);
 
19800
+  regno0 = REGNO (op0);
 
19801
+  regno1 = REGNO (op1);
 
19802
+
 
19803
+  gcc_assert (reload_completed);
 
19804
+  gcc_assert (IN_RANGE (regno0, FIRST_GPR_REGNO, LAST_GPR_REGNO));
 
19805
+  gcc_assert (IN_RANGE (regno1, FIRST_GPR_REGNO, LAST_GPR_REGNO));
 
19806
+
 
19807
+  nregs = rs6000_hard_regno_nregs[(int)mode][regno0];
 
19808
+  gcc_assert (nregs > 1);
 
19809
+
 
19810
+  if (op2 && REG_P (op2))
 
19811
+    gcc_assert (IN_RANGE (REGNO (op2), FIRST_GPR_REGNO, LAST_GPR_REGNO));
 
19812
+
 
19813
+  for (i = 0; i < nregs; i++)
 
19814
+    {
 
19815
+      int offset = i * sub_size;
 
19816
+      rtx sub_op0 = simplify_subreg (sub_mode, op0, mode, offset);
 
19817
+      rtx sub_op1 = simplify_subreg (sub_mode, op1, mode, offset);
 
19818
+      rtx sub_op2 = ((code == NOT)
 
19819
+                    ? NULL_RTX
 
19820
+                    : simplify_subreg (sub_mode, op2, mode, offset));
 
19821
+
 
19822
+      rs6000_split_logical_inner (sub_op0, sub_op1, sub_op2, code, sub_mode,
 
19823
+                                 complement_final_p, complement_op1_p,
 
19824
+                                 complement_op2_p, clobber_reg);
 
19825
+    }
 
19826
+
 
19827
+  return;
 
19828
+}
 
19829
+
 
19830
+
 
19831
+/* Return true if the peephole2 can combine a load involving a combination of
 
19832
+   an addis instruction and a load with an offset that can be fused together on
 
19833
+   a power8.
 
19834
+
 
19835
+   The operands are:
 
19836
+       operands[0]     register set with addis
 
19837
+       operands[1]     value set via addis
 
19838
+       operands[2]     target register being loaded
 
19839
+       operands[3]     D-form memory reference using operands[0].
 
19840
+
 
19841
+   In addition, we are passed a boolean that is true if this is a peephole2,
 
19842
+   and we can use see if the addis_reg is dead after the insn and can be
 
19843
+   replaced by the target register.  */
 
19844
+
 
19845
+bool
 
19846
+fusion_gpr_load_p (rtx *operands, bool peep2_p)
 
19847
+{
 
19848
+  rtx addis_reg = operands[0];
 
19849
+  rtx addis_value = operands[1];
 
19850
+  rtx target = operands[2];
 
19851
+  rtx mem = operands[3];
 
19852
+  rtx addr;
 
19853
+  rtx base_reg;
 
19854
+
 
19855
+  /* Validate arguments.  */
 
19856
+  if (!base_reg_operand (addis_reg, GET_MODE (addis_reg)))
 
19857
+    return false;
 
19858
+
 
19859
+  if (!base_reg_operand (target, GET_MODE (target)))
 
19860
+    return false;
 
19861
+
 
19862
+  if (!fusion_gpr_addis (addis_value, GET_MODE (addis_value)))
 
19863
+    return false;
 
19864
+
 
19865
+  if (!fusion_gpr_mem_load (mem, GET_MODE (mem)))
 
19866
+    return false;
 
19867
+
 
19868
+  /* Allow sign/zero extension.  */
 
19869
+  if (GET_CODE (mem) == ZERO_EXTEND
 
19870
+      || (GET_CODE (mem) == SIGN_EXTEND && TARGET_P8_FUSION_SIGN))
 
19871
+    mem = XEXP (mem, 0);
 
19872
+
 
19873
+  if (!MEM_P (mem))
 
19874
+    return false;
 
19875
+
 
19876
+  addr = XEXP (mem, 0);                        /* either PLUS or LO_SUM.  */
 
19877
+  if (GET_CODE (addr) != PLUS && GET_CODE (addr) != LO_SUM)
 
19878
+    return false;
 
19879
+
 
19880
+  /* Validate that the register used to load the high value is either the
 
19881
+     register being loaded, or we can safely replace its use in a peephole2.
 
19882
+
 
19883
+     If this is a peephole2, we assume that there are 2 instructions in the
 
19884
+     peephole (addis and load), so we want to check if the target register was
 
19885
+     not used in the memory address and the register to hold the addis result
 
19886
+     is dead after the peephole.  */
 
19887
+  if (REGNO (addis_reg) != REGNO (target))
 
19888
+    {
 
19889
+      if (!peep2_p)
 
19890
+       return false;
 
19891
+
 
19892
+      if (reg_mentioned_p (target, mem))
 
19893
+       return false;
 
19894
+
 
19895
+      if (!peep2_reg_dead_p (2, addis_reg))
 
19896
+       return false;
 
19897
+    }
 
19898
+
 
19899
+  base_reg = XEXP (addr, 0);
 
19900
+  return REGNO (addis_reg) == REGNO (base_reg);
 
19901
+}
 
19902
+
 
19903
+/* During the peephole2 pass, adjust and expand the insns for a load fusion
 
19904
+   sequence.  We adjust the addis register to use the target register.  If the
 
19905
+   load sign extends, we adjust the code to do the zero extending load, and an
 
19906
+   explicit sign extension later since the fusion only covers zero extending
 
19907
+   loads.
 
19908
+
 
19909
+   The operands are:
 
19910
+       operands[0]     register set with addis (to be replaced with target)
 
19911
+       operands[1]     value set via addis
 
19912
+       operands[2]     target register being loaded
 
19913
+       operands[3]     D-form memory reference using operands[0].  */
 
19914
+
 
19915
+void
 
19916
+expand_fusion_gpr_load (rtx *operands)
 
19917
+{
 
19918
+  rtx addis_value = operands[1];
 
19919
+  rtx target = operands[2];
 
19920
+  rtx orig_mem = operands[3];
 
19921
+  rtx  new_addr, new_mem, orig_addr, offset;
 
19922
+  enum rtx_code plus_or_lo_sum;
 
19923
+  enum machine_mode target_mode = GET_MODE (target);
 
19924
+  enum machine_mode extend_mode = target_mode;
 
19925
+  enum machine_mode ptr_mode = Pmode;
 
19926
+  enum rtx_code extend = UNKNOWN;
 
19927
+  rtx addis_reg = ((ptr_mode == target_mode)
 
19928
+                  ? target
 
19929
+                  : simplify_subreg (ptr_mode, target, target_mode, 0));
 
19930
+
 
19931
+  if (GET_CODE (orig_mem) == ZERO_EXTEND
 
19932
+      || (TARGET_P8_FUSION_SIGN && GET_CODE (orig_mem) == SIGN_EXTEND))
 
19933
+    {
 
19934
+      extend = GET_CODE (orig_mem);
 
19935
+      orig_mem = XEXP (orig_mem, 0);
 
19936
+      target_mode = GET_MODE (orig_mem);
 
19937
+    }
 
19938
+
 
19939
+  gcc_assert (MEM_P (orig_mem));
 
19940
+
 
19941
+  orig_addr = XEXP (orig_mem, 0);
 
19942
+  plus_or_lo_sum = GET_CODE (orig_addr);
 
19943
+  gcc_assert (plus_or_lo_sum == PLUS || plus_or_lo_sum == LO_SUM);
 
19944
+
 
19945
+  offset = XEXP (orig_addr, 1);
 
19946
+  new_addr = gen_rtx_fmt_ee (plus_or_lo_sum, ptr_mode, addis_reg, offset);
 
19947
+  new_mem = change_address (orig_mem, target_mode, new_addr);
 
19948
+
 
19949
+  if (extend != UNKNOWN)
 
19950
+    new_mem = gen_rtx_fmt_e (ZERO_EXTEND, extend_mode, new_mem);
 
19951
+
 
19952
+  emit_insn (gen_rtx_SET (VOIDmode, addis_reg, addis_value));
 
19953
+  emit_insn (gen_rtx_SET (VOIDmode, target, new_mem));
 
19954
+
 
19955
+  if (extend == SIGN_EXTEND)
 
19956
+    {
 
19957
+      int sub_off = ((BYTES_BIG_ENDIAN)
 
19958
+                    ? GET_MODE_SIZE (extend_mode) - GET_MODE_SIZE (target_mode)
 
19959
+                    : 0);
 
19960
+      rtx sign_reg
 
19961
+       = simplify_subreg (target_mode, target, extend_mode, sub_off);
 
19962
+
 
19963
+      emit_insn (gen_rtx_SET (VOIDmode, target,
 
19964
+                             gen_rtx_SIGN_EXTEND (extend_mode, sign_reg)));
 
19965
+    }
 
19966
+
 
19967
+  return;
 
19968
+}
 
19969
+
 
19970
+/* Return a string to fuse an addis instruction with a gpr load to the same
 
19971
+   register that we loaded up the addis instruction.  The code is complicated,
 
19972
+   so we call output_asm_insn directly, and just return "".
 
19973
+
 
19974
+   The operands are:
 
19975
+       operands[0]     register set with addis (must be same reg as target).
 
19976
+       operands[1]     value set via addis
 
19977
+       operands[2]     target register being loaded
 
19978
+       operands[3]     D-form memory reference using operands[0].  */
 
19979
+
 
19980
+const char *
 
19981
+emit_fusion_gpr_load (rtx *operands)
 
19982
+{
 
19983
+  rtx addis_reg = operands[0];
 
19984
+  rtx addis_value = operands[1];
 
19985
+  rtx target = operands[2];
 
19986
+  rtx mem = operands[3];
 
19987
+  rtx fuse_ops[10];
 
19988
+  rtx addr;
 
19989
+  rtx load_offset;
 
19990
+  const char *addis_str = NULL;
 
19991
+  const char *load_str = NULL;
 
19992
+  const char *extend_insn = NULL;
 
19993
+  const char *mode_name = NULL;
 
19994
+  char insn_template[80];
 
19995
+  enum machine_mode mode;
 
19996
+  const char *comment_str = ASM_COMMENT_START;
 
19997
+  bool sign_p = false;
 
19998
+
 
19999
+  gcc_assert (REG_P (addis_reg) && REG_P (target));
 
20000
+  gcc_assert (REGNO (addis_reg) == REGNO (target));
 
20001
+
 
20002
+  if (*comment_str == ' ')
 
20003
+    comment_str++;
 
20004
+
 
20005
+  /* Allow sign/zero extension.  */
 
20006
+  if (GET_CODE (mem) == ZERO_EXTEND)
 
20007
+    mem = XEXP (mem, 0);
 
20008
+
 
20009
+  else if (GET_CODE (mem) == SIGN_EXTEND && TARGET_P8_FUSION_SIGN)
 
20010
+    {
 
20011
+      sign_p = true;
 
20012
+      mem = XEXP (mem, 0);
 
20013
+    }
 
20014
+
 
20015
+  gcc_assert (MEM_P (mem));
 
20016
+  addr = XEXP (mem, 0);
 
20017
+  if (GET_CODE (addr) != PLUS && GET_CODE (addr) != LO_SUM)
 
20018
+    gcc_unreachable ();
 
20019
+
 
20020
+  load_offset = XEXP (addr, 1);
 
20021
+
 
20022
+  /* Now emit the load instruction to the same register.  */
 
20023
+  mode = GET_MODE (mem);
 
20024
+  switch (mode)
 
20025
+    {
 
20026
+    case QImode:
 
20027
+      mode_name = "char";
 
20028
+      load_str = "lbz";
 
20029
+      extend_insn = "extsb %0,%0";
 
20030
+      break;
 
20031
+
 
20032
+    case HImode:
 
20033
+      mode_name = "short";
 
20034
+      load_str = "lhz";
 
20035
+      extend_insn = "extsh %0,%0";
 
20036
+      break;
 
20037
+
 
20038
+    case SImode:
 
20039
+      mode_name = "int";
 
20040
+      load_str = "lwz";
 
20041
+      extend_insn = "extsw %0,%0";
 
20042
+      break;
 
20043
+
 
20044
+    case DImode:
 
20045
+      if (TARGET_POWERPC64)
 
20046
+       {
 
20047
+         mode_name = "long";
 
20048
+         load_str = "ld";
 
20049
+       }
 
20050
+      else
 
20051
+       gcc_unreachable ();
 
20052
+      break;
 
20053
+
 
20054
+    default:
 
20055
+      gcc_unreachable ();
 
20056
+    }
 
20057
+
 
20058
+  /* Emit the addis instruction.  */
 
20059
+  fuse_ops[0] = target;
 
20060
+  if (satisfies_constraint_L (addis_value))
 
20061
+    {
 
20062
+      fuse_ops[1] = addis_value;
 
20063
+      addis_str = "lis %0,%v1";
 
20064
+    }
 
20065
+
 
20066
+  else if (GET_CODE (addis_value) == PLUS)
 
20067
+    {
 
20068
+      rtx op0 = XEXP (addis_value, 0);
 
20069
+      rtx op1 = XEXP (addis_value, 1);
 
20070
+
 
20071
+      if (REG_P (op0) && CONST_INT_P (op1)
 
20072
+         && satisfies_constraint_L (op1))
 
20073
+       {
 
20074
+         fuse_ops[1] = op0;
 
20075
+         fuse_ops[2] = op1;
 
20076
+         addis_str = "addis %0,%1,%v2";
 
20077
+       }
 
20078
+    }
 
20079
+
 
20080
+  else if (GET_CODE (addis_value) == HIGH)
 
20081
+    {
 
20082
+      rtx value = XEXP (addis_value, 0);
 
20083
+      if (GET_CODE (value) == UNSPEC && XINT (value, 1) == UNSPEC_TOCREL)
 
20084
+       {
 
20085
+         fuse_ops[1] = XVECEXP (value, 0, 0);          /* symbol ref.  */
 
20086
+         fuse_ops[2] = XVECEXP (value, 0, 1);          /* TOC register.  */
 
20087
+         if (TARGET_ELF)
 
20088
+           addis_str = "addis %0,%2,%1@toc@ha";
 
20089
+
 
20090
+         else if (TARGET_XCOFF)
 
20091
+           addis_str = "addis %0,%1@u(%2)";
 
20092
+
 
20093
+         else
 
20094
+           gcc_unreachable ();
 
20095
+       }
 
20096
+
 
20097
+      else if (GET_CODE (value) == PLUS)
 
20098
+       {
 
20099
+         rtx op0 = XEXP (value, 0);
 
20100
+         rtx op1 = XEXP (value, 1);
 
20101
+
 
20102
+         if (GET_CODE (op0) == UNSPEC
 
20103
+             && XINT (op0, 1) == UNSPEC_TOCREL
 
20104
+             && CONST_INT_P (op1))
 
20105
+           {
 
20106
+             fuse_ops[1] = XVECEXP (op0, 0, 0);        /* symbol ref.  */
 
20107
+             fuse_ops[2] = XVECEXP (op0, 0, 1);        /* TOC register.  */
 
20108
+             fuse_ops[3] = op1;
 
20109
+             if (TARGET_ELF)
 
20110
+               addis_str = "addis %0,%2,%1+%3@toc@ha";
 
20111
+
 
20112
+             else if (TARGET_XCOFF)
 
20113
+               addis_str = "addis %0,%1+%3@u(%2)";
 
20114
+
 
20115
+             else
 
20116
+               gcc_unreachable ();
 
20117
+           }
 
20118
+       }
 
20119
+
 
20120
+      else if (satisfies_constraint_L (value))
 
20121
+       {
 
20122
+         fuse_ops[1] = value;
 
20123
+         addis_str = "lis %0,%v1";
 
20124
+       }
 
20125
+
 
20126
+      else if (TARGET_ELF && !TARGET_POWERPC64 && CONSTANT_P (value))
 
20127
+       {
 
20128
+         fuse_ops[1] = value;
 
20129
+         addis_str = "lis %0,%1@ha";
 
20130
+       }
 
20131
+    }
 
20132
+
 
20133
+  if (!addis_str)
 
20134
+    fatal_insn ("Could not generate addis value for fusion", addis_value);
 
20135
+
 
20136
+  sprintf (insn_template, "%s\t\t%s gpr load fusion, type %s", addis_str,
 
20137
+          comment_str, mode_name);
 
20138
+  output_asm_insn (insn_template, fuse_ops);
 
20139
+
 
20140
+  /* Emit the D-form load instruction.  */
 
20141
+  if (CONST_INT_P (load_offset) && satisfies_constraint_I (load_offset))
 
20142
+    {
 
20143
+      sprintf (insn_template, "%s %%0,%%1(%%0)", load_str);
 
20144
+      fuse_ops[1] = load_offset;
 
20145
+      output_asm_insn (insn_template, fuse_ops);
 
20146
+    }
 
20147
+
 
20148
+  else if (GET_CODE (load_offset) == UNSPEC
 
20149
+          && XINT (load_offset, 1) == UNSPEC_TOCREL)
 
20150
+    {
 
20151
+      if (TARGET_ELF)
 
20152
+       sprintf (insn_template, "%s %%0,%%1@toc@l(%%0)", load_str);
 
20153
+
 
20154
+      else if (TARGET_XCOFF)
 
20155
+       sprintf (insn_template, "%s %%0,%%1@l(%%0)", load_str);
 
20156
+
 
20157
+      else
 
20158
+       gcc_unreachable ();
 
20159
+
 
20160
+      fuse_ops[1] = XVECEXP (load_offset, 0, 0);
 
20161
+      output_asm_insn (insn_template, fuse_ops);
 
20162
+    }
 
20163
+
 
20164
+  else if (GET_CODE (load_offset) == PLUS
 
20165
+          && GET_CODE (XEXP (load_offset, 0)) == UNSPEC
 
20166
+          && XINT (XEXP (load_offset, 0), 1) == UNSPEC_TOCREL
 
20167
+          && CONST_INT_P (XEXP (load_offset, 1)))
 
20168
+    {
 
20169
+      rtx tocrel_unspec = XEXP (load_offset, 0);
 
20170
+      if (TARGET_ELF)
 
20171
+       sprintf (insn_template, "%s %%0,%%1+%%2@toc@l(%%0)", load_str);
 
20172
+
 
20173
+      else if (TARGET_XCOFF)
 
20174
+       sprintf (insn_template, "%s %%0,%%1+%%2@l(%%0)", load_str);
 
20175
+
 
20176
+      else
 
20177
+       gcc_unreachable ();
 
20178
+
 
20179
+      fuse_ops[1] = XVECEXP (tocrel_unspec, 0, 0);
 
20180
+      fuse_ops[2] = XEXP (load_offset, 1);
 
20181
+      output_asm_insn (insn_template, fuse_ops);
 
20182
+    }
 
20183
+
 
20184
+  else if (TARGET_ELF && !TARGET_POWERPC64 && CONSTANT_P (load_offset))
 
20185
+    {
 
20186
+      sprintf (insn_template, "%s %%0,%%1@l(%%0)", load_str);
 
20187
+
 
20188
+      fuse_ops[1] = load_offset;
 
20189
+      output_asm_insn (insn_template, fuse_ops);
 
20190
+    }
 
20191
+
 
20192
+  else
 
20193
+    fatal_insn ("Unable to generate load offset for fusion", load_offset);
 
20194
+
 
20195
+  /* Handle sign extension.  The peephole2 pass generates this as a separate
 
20196
+     insn, but we handle it just in case it got reattached.  */
 
20197
+  if (sign_p)
 
20198
+    {
 
20199
+      gcc_assert (extend_insn != NULL);
 
20200
+      output_asm_insn (extend_insn, fuse_ops);
 
20201
+    }
 
20202
+
 
20203
+  return "";
 
20204
+}
 
20205
+
 
20206
+
 
20207
 struct gcc_target targetm = TARGET_INITIALIZER;
 
20208
 
 
20209
 #include "gt-rs6000.h"
 
20210
--- a/src/gcc/config/rs6000/vsx.md
 
20211
+++ b/src/gcc/config/rs6000/vsx.md
 
20212
@@ -40,6 +40,14 @@
 
20213
 ;; it to use gprs as well as vsx registers.
 
20214
 (define_mode_iterator VSX_M [V16QI V8HI V4SI V2DI V4SF V2DF])
 
20215
 
 
20216
+(define_mode_iterator VSX_M2 [V16QI
 
20217
+                             V8HI
 
20218
+                             V4SI
 
20219
+                             V2DI
 
20220
+                             V4SF
 
20221
+                             V2DF
 
20222
+                             (TI       "TARGET_VSX_TIMODE")])
 
20223
+
 
20224
 ;; Map into the appropriate load/store name based on the type
 
20225
 (define_mode_attr VSm  [(V16QI "vw4")
 
20226
                        (V8HI  "vw4")
 
20227
@@ -48,7 +56,7 @@
 
20228
                        (V2DF  "vd2")
 
20229
                        (V2DI  "vd2")
 
20230
                        (DF    "d")
 
20231
-                       (TI    "vw4")])
 
20232
+                       (TI    "vd2")])
 
20233
 
 
20234
 ;; Map into the appropriate suffix based on the type
 
20235
 (define_mode_attr VSs  [(V16QI "sp")
 
20236
@@ -59,7 +67,7 @@
 
20237
                         (V2DI  "dp")
 
20238
                         (DF    "dp")
 
20239
                         (SF    "sp")
 
20240
-                        (TI    "sp")])
 
20241
+                        (TI    "dp")])
 
20242
 
 
20243
 ;; Map the register class used
 
20244
 (define_mode_attr VSr  [(V16QI "v")
 
20245
@@ -70,7 +78,7 @@
 
20246
                         (V2DF  "wd")
 
20247
                         (DF    "ws")
 
20248
                         (SF    "d")
 
20249
-                        (TI    "wd")])
 
20250
+                        (TI    "wt")])
 
20251
 
 
20252
 ;; Map the register class used for float<->int conversions
 
20253
 (define_mode_attr VSr2 [(V2DF  "wd")
 
20254
@@ -115,7 +123,6 @@
 
20255
                         (V4SF  "v")
 
20256
                         (V2DI  "v")
 
20257
                         (V2DF  "v")
 
20258
-                        (TI    "v")
 
20259
                         (DF    "s")])
 
20260
 
 
20261
 ;; Appropriate type for add ops (and other simple FP ops)
 
20262
@@ -192,6 +199,8 @@
 
20263
    UNSPEC_VSX_CVDPSXWS
 
20264
    UNSPEC_VSX_CVDPUXWS
 
20265
    UNSPEC_VSX_CVSPDP
 
20266
+   UNSPEC_VSX_CVSPDPN
 
20267
+   UNSPEC_VSX_CVDPSPN
 
20268
    UNSPEC_VSX_CVSXWDP
 
20269
    UNSPEC_VSX_CVUXWDP
 
20270
    UNSPEC_VSX_CVSXDSP
 
20271
@@ -207,77 +216,393 @@
 
20272
   ])
 
20273
 
 
20274
 ;; VSX moves
 
20275
-(define_insn "*vsx_mov<mode>"
 
20276
-  [(set (match_operand:VSX_M 0 "nonimmediate_operand" "=Z,<VSr>,<VSr>,?Z,?wa,?wa,*Y,*r,*r,<VSr>,?wa,*r,v,wZ,v")
 
20277
-       (match_operand:VSX_M 1 "input_operand" "<VSr>,Z,<VSr>,wa,Z,wa,r,Y,r,j,j,j,W,v,wZ"))]
 
20278
-  "VECTOR_MEM_VSX_P (<MODE>mode)
 
20279
-   && (register_operand (operands[0], <MODE>mode) 
 
20280
-       || register_operand (operands[1], <MODE>mode))"
 
20281
+
 
20282
+;; The patterns for LE permuted loads and stores come before the general
 
20283
+;; VSX moves so they match first.
 
20284
+(define_insn_and_split "*vsx_le_perm_load_<mode>"
 
20285
+  [(set (match_operand:VSX_D 0 "vsx_register_operand" "=wa")
 
20286
+        (match_operand:VSX_D 1 "memory_operand" "Z"))]
 
20287
+  "!BYTES_BIG_ENDIAN && TARGET_VSX"
 
20288
+  "#"
 
20289
+  "!BYTES_BIG_ENDIAN && TARGET_VSX"
 
20290
+  [(set (match_dup 2)
 
20291
+        (vec_select:<MODE>
 
20292
+          (match_dup 1)
 
20293
+          (parallel [(const_int 1) (const_int 0)])))
 
20294
+   (set (match_dup 0)
 
20295
+        (vec_select:<MODE>
 
20296
+          (match_dup 2)
 
20297
+          (parallel [(const_int 1) (const_int 0)])))]
 
20298
+  "
 
20299
 {
 
20300
-  switch (which_alternative)
 
20301
-    {
 
20302
-    case 0:
 
20303
-    case 3:
 
20304
-      gcc_assert (MEM_P (operands[0])
 
20305
-                 && GET_CODE (XEXP (operands[0], 0)) != PRE_INC
 
20306
-                 && GET_CODE (XEXP (operands[0], 0)) != PRE_DEC
 
20307
-                 && GET_CODE (XEXP (operands[0], 0)) != PRE_MODIFY);
 
20308
-      return "stx<VSm>x %x1,%y0";
 
20309
+  operands[2] = can_create_pseudo_p () ? gen_reg_rtx_and_attrs (operands[0])
 
20310
+                                       : operands[0];
 
20311
+}
 
20312
+  "
 
20313
+  [(set_attr "type" "vecload")
 
20314
+   (set_attr "length" "8")])
 
20315
 
 
20316
-    case 1:
 
20317
-    case 4:
 
20318
-      gcc_assert (MEM_P (operands[1])
 
20319
-                 && GET_CODE (XEXP (operands[1], 0)) != PRE_INC
 
20320
-                 && GET_CODE (XEXP (operands[1], 0)) != PRE_DEC
 
20321
-                 && GET_CODE (XEXP (operands[1], 0)) != PRE_MODIFY);
 
20322
-      return "lx<VSm>x %x0,%y1";
 
20323
+(define_insn_and_split "*vsx_le_perm_load_<mode>"
 
20324
+  [(set (match_operand:VSX_W 0 "vsx_register_operand" "=wa")
 
20325
+        (match_operand:VSX_W 1 "memory_operand" "Z"))]
 
20326
+  "!BYTES_BIG_ENDIAN && TARGET_VSX"
 
20327
+  "#"
 
20328
+  "!BYTES_BIG_ENDIAN && TARGET_VSX"
 
20329
+  [(set (match_dup 2)
 
20330
+        (vec_select:<MODE>
 
20331
+          (match_dup 1)
 
20332
+          (parallel [(const_int 2) (const_int 3)
 
20333
+                     (const_int 0) (const_int 1)])))
 
20334
+   (set (match_dup 0)
 
20335
+        (vec_select:<MODE>
 
20336
+          (match_dup 2)
 
20337
+          (parallel [(const_int 2) (const_int 3)
 
20338
+                     (const_int 0) (const_int 1)])))]
 
20339
+  "
 
20340
+{
 
20341
+  operands[2] = can_create_pseudo_p () ? gen_reg_rtx_and_attrs (operands[0])
 
20342
+                                       : operands[0];
 
20343
+}
 
20344
+  "
 
20345
+  [(set_attr "type" "vecload")
 
20346
+   (set_attr "length" "8")])
 
20347
 
 
20348
-    case 2:
 
20349
-    case 5:
 
20350
-      return "xxlor %x0,%x1,%x1";
 
20351
+(define_insn_and_split "*vsx_le_perm_load_v8hi"
 
20352
+  [(set (match_operand:V8HI 0 "vsx_register_operand" "=wa")
 
20353
+        (match_operand:V8HI 1 "memory_operand" "Z"))]
 
20354
+  "!BYTES_BIG_ENDIAN && TARGET_VSX"
 
20355
+  "#"
 
20356
+  "!BYTES_BIG_ENDIAN && TARGET_VSX"
 
20357
+  [(set (match_dup 2)
 
20358
+        (vec_select:V8HI
 
20359
+          (match_dup 1)
 
20360
+          (parallel [(const_int 4) (const_int 5)
 
20361
+                     (const_int 6) (const_int 7)
 
20362
+                     (const_int 0) (const_int 1)
 
20363
+                     (const_int 2) (const_int 3)])))
 
20364
+   (set (match_dup 0)
 
20365
+        (vec_select:V8HI
 
20366
+          (match_dup 2)
 
20367
+          (parallel [(const_int 4) (const_int 5)
 
20368
+                     (const_int 6) (const_int 7)
 
20369
+                     (const_int 0) (const_int 1)
 
20370
+                     (const_int 2) (const_int 3)])))]
 
20371
+  "
 
20372
+{
 
20373
+  operands[2] = can_create_pseudo_p () ? gen_reg_rtx_and_attrs (operands[0])
 
20374
+                                       : operands[0];
 
20375
+}
 
20376
+  "
 
20377
+  [(set_attr "type" "vecload")
 
20378
+   (set_attr "length" "8")])
 
20379
 
 
20380
-    case 6:
 
20381
-    case 7:
 
20382
-    case 8:
 
20383
-    case 11:
 
20384
-      return "#";
 
20385
+(define_insn_and_split "*vsx_le_perm_load_v16qi"
 
20386
+  [(set (match_operand:V16QI 0 "vsx_register_operand" "=wa")
 
20387
+        (match_operand:V16QI 1 "memory_operand" "Z"))]
 
20388
+  "!BYTES_BIG_ENDIAN && TARGET_VSX"
 
20389
+  "#"
 
20390
+  "!BYTES_BIG_ENDIAN && TARGET_VSX"
 
20391
+  [(set (match_dup 2)
 
20392
+        (vec_select:V16QI
 
20393
+          (match_dup 1)
 
20394
+          (parallel [(const_int 8) (const_int 9)
 
20395
+                     (const_int 10) (const_int 11)
 
20396
+                     (const_int 12) (const_int 13)
 
20397
+                     (const_int 14) (const_int 15)
 
20398
+                     (const_int 0) (const_int 1)
 
20399
+                     (const_int 2) (const_int 3)
 
20400
+                     (const_int 4) (const_int 5)
 
20401
+                     (const_int 6) (const_int 7)])))
 
20402
+   (set (match_dup 0)
 
20403
+        (vec_select:V16QI
 
20404
+          (match_dup 2)
 
20405
+          (parallel [(const_int 8) (const_int 9)
 
20406
+                     (const_int 10) (const_int 11)
 
20407
+                     (const_int 12) (const_int 13)
 
20408
+                     (const_int 14) (const_int 15)
 
20409
+                     (const_int 0) (const_int 1)
 
20410
+                     (const_int 2) (const_int 3)
 
20411
+                     (const_int 4) (const_int 5)
 
20412
+                     (const_int 6) (const_int 7)])))]
 
20413
+  "
 
20414
+{
 
20415
+  operands[2] = can_create_pseudo_p () ? gen_reg_rtx_and_attrs (operands[0])
 
20416
+                                       : operands[0];
 
20417
+}
 
20418
+  "
 
20419
+  [(set_attr "type" "vecload")
 
20420
+   (set_attr "length" "8")])
 
20421
 
 
20422
-    case 9:
 
20423
-    case 10:
 
20424
-      return "xxlxor %x0,%x0,%x0";
 
20425
+(define_insn "*vsx_le_perm_store_<mode>"
 
20426
+  [(set (match_operand:VSX_D 0 "memory_operand" "=Z")
 
20427
+        (match_operand:VSX_D 1 "vsx_register_operand" "+wa"))]
 
20428
+  "!BYTES_BIG_ENDIAN && TARGET_VSX"
 
20429
+  "#"
 
20430
+  [(set_attr "type" "vecstore")
 
20431
+   (set_attr "length" "12")])
 
20432
 
 
20433
-    case 12:
 
20434
-      return output_vec_const_move (operands);
 
20435
+(define_split
 
20436
+  [(set (match_operand:VSX_D 0 "memory_operand" "")
 
20437
+        (match_operand:VSX_D 1 "vsx_register_operand" ""))]
 
20438
+  "!BYTES_BIG_ENDIAN && TARGET_VSX && !reload_completed"
 
20439
+  [(set (match_dup 2)
 
20440
+        (vec_select:<MODE>
 
20441
+          (match_dup 1)
 
20442
+          (parallel [(const_int 1) (const_int 0)])))
 
20443
+   (set (match_dup 0)
 
20444
+        (vec_select:<MODE>
 
20445
+          (match_dup 2)
 
20446
+          (parallel [(const_int 1) (const_int 0)])))]
 
20447
+{
 
20448
+  operands[2] = can_create_pseudo_p () ? gen_reg_rtx_and_attrs (operands[1]) 
 
20449
+                                       : operands[1];
 
20450
+})
 
20451
 
 
20452
-    case 13:
 
20453
-      gcc_assert (MEM_P (operands[0])
 
20454
-                 && GET_CODE (XEXP (operands[0], 0)) != PRE_INC
 
20455
-                 && GET_CODE (XEXP (operands[0], 0)) != PRE_DEC
 
20456
-                 && GET_CODE (XEXP (operands[0], 0)) != PRE_MODIFY);
 
20457
-      return "stvx %1,%y0";
 
20458
+;; The post-reload split requires that we re-permute the source
 
20459
+;; register in case it is still live.
 
20460
+(define_split
 
20461
+  [(set (match_operand:VSX_D 0 "memory_operand" "")
 
20462
+        (match_operand:VSX_D 1 "vsx_register_operand" ""))]
 
20463
+  "!BYTES_BIG_ENDIAN && TARGET_VSX && reload_completed"
 
20464
+  [(set (match_dup 1)
 
20465
+        (vec_select:<MODE>
 
20466
+          (match_dup 1)
 
20467
+          (parallel [(const_int 1) (const_int 0)])))
 
20468
+   (set (match_dup 0)
 
20469
+        (vec_select:<MODE>
 
20470
+          (match_dup 1)
 
20471
+          (parallel [(const_int 1) (const_int 0)])))
 
20472
+   (set (match_dup 1)
 
20473
+        (vec_select:<MODE>
 
20474
+          (match_dup 1)
 
20475
+          (parallel [(const_int 1) (const_int 0)])))]
 
20476
+  "")
 
20477
 
 
20478
-    case 14:
 
20479
-      gcc_assert (MEM_P (operands[0])
 
20480
-                 && GET_CODE (XEXP (operands[0], 0)) != PRE_INC
 
20481
-                 && GET_CODE (XEXP (operands[0], 0)) != PRE_DEC
 
20482
-                 && GET_CODE (XEXP (operands[0], 0)) != PRE_MODIFY);
 
20483
-      return "lvx %0,%y1";
 
20484
+(define_insn "*vsx_le_perm_store_<mode>"
 
20485
+  [(set (match_operand:VSX_W 0 "memory_operand" "=Z")
 
20486
+        (match_operand:VSX_W 1 "vsx_register_operand" "+wa"))]
 
20487
+  "!BYTES_BIG_ENDIAN && TARGET_VSX"
 
20488
+  "#"
 
20489
+  [(set_attr "type" "vecstore")
 
20490
+   (set_attr "length" "12")])
 
20491
 
 
20492
-    default:
 
20493
-      gcc_unreachable ();
 
20494
-    }
 
20495
+(define_split
 
20496
+  [(set (match_operand:VSX_W 0 "memory_operand" "")
 
20497
+        (match_operand:VSX_W 1 "vsx_register_operand" ""))]
 
20498
+  "!BYTES_BIG_ENDIAN && TARGET_VSX && !reload_completed"
 
20499
+  [(set (match_dup 2)
 
20500
+        (vec_select:<MODE>
 
20501
+          (match_dup 1)
 
20502
+          (parallel [(const_int 2) (const_int 3)
 
20503
+                    (const_int 0) (const_int 1)])))
 
20504
+   (set (match_dup 0)
 
20505
+        (vec_select:<MODE>
 
20506
+          (match_dup 2)
 
20507
+          (parallel [(const_int 2) (const_int 3)
 
20508
+                    (const_int 0) (const_int 1)])))]
 
20509
+{
 
20510
+  operands[2] = can_create_pseudo_p () ? gen_reg_rtx_and_attrs (operands[1]) 
 
20511
+                                       : operands[1];
 
20512
+})
 
20513
+
 
20514
+;; The post-reload split requires that we re-permute the source
 
20515
+;; register in case it is still live.
 
20516
+(define_split
 
20517
+  [(set (match_operand:VSX_W 0 "memory_operand" "")
 
20518
+        (match_operand:VSX_W 1 "vsx_register_operand" ""))]
 
20519
+  "!BYTES_BIG_ENDIAN && TARGET_VSX && reload_completed"
 
20520
+  [(set (match_dup 1)
 
20521
+        (vec_select:<MODE>
 
20522
+          (match_dup 1)
 
20523
+          (parallel [(const_int 2) (const_int 3)
 
20524
+                    (const_int 0) (const_int 1)])))
 
20525
+   (set (match_dup 0)
 
20526
+        (vec_select:<MODE>
 
20527
+          (match_dup 1)
 
20528
+          (parallel [(const_int 2) (const_int 3)
 
20529
+                    (const_int 0) (const_int 1)])))
 
20530
+   (set (match_dup 1)
 
20531
+        (vec_select:<MODE>
 
20532
+          (match_dup 1)
 
20533
+          (parallel [(const_int 2) (const_int 3)
 
20534
+                    (const_int 0) (const_int 1)])))]
 
20535
+  "")
 
20536
+
 
20537
+(define_insn "*vsx_le_perm_store_v8hi"
 
20538
+  [(set (match_operand:V8HI 0 "memory_operand" "=Z")
 
20539
+        (match_operand:V8HI 1 "vsx_register_operand" "+wa"))]
 
20540
+  "!BYTES_BIG_ENDIAN && TARGET_VSX"
 
20541
+  "#"
 
20542
+  [(set_attr "type" "vecstore")
 
20543
+   (set_attr "length" "12")])
 
20544
+
 
20545
+(define_split
 
20546
+  [(set (match_operand:V8HI 0 "memory_operand" "")
 
20547
+        (match_operand:V8HI 1 "vsx_register_operand" ""))]
 
20548
+  "!BYTES_BIG_ENDIAN && TARGET_VSX && !reload_completed"
 
20549
+  [(set (match_dup 2)
 
20550
+        (vec_select:V8HI
 
20551
+          (match_dup 1)
 
20552
+          (parallel [(const_int 4) (const_int 5)
 
20553
+                     (const_int 6) (const_int 7)
 
20554
+                     (const_int 0) (const_int 1)
 
20555
+                     (const_int 2) (const_int 3)])))
 
20556
+   (set (match_dup 0)
 
20557
+        (vec_select:V8HI
 
20558
+          (match_dup 2)
 
20559
+          (parallel [(const_int 4) (const_int 5)
 
20560
+                     (const_int 6) (const_int 7)
 
20561
+                     (const_int 0) (const_int 1)
 
20562
+                     (const_int 2) (const_int 3)])))]
 
20563
+{
 
20564
+  operands[2] = can_create_pseudo_p () ? gen_reg_rtx_and_attrs (operands[1]) 
 
20565
+                                       : operands[1];
 
20566
+})
 
20567
+
 
20568
+;; The post-reload split requires that we re-permute the source
 
20569
+;; register in case it is still live.
 
20570
+(define_split
 
20571
+  [(set (match_operand:V8HI 0 "memory_operand" "")
 
20572
+        (match_operand:V8HI 1 "vsx_register_operand" ""))]
 
20573
+  "!BYTES_BIG_ENDIAN && TARGET_VSX && reload_completed"
 
20574
+  [(set (match_dup 1)
 
20575
+        (vec_select:V8HI
 
20576
+          (match_dup 1)
 
20577
+          (parallel [(const_int 4) (const_int 5)
 
20578
+                     (const_int 6) (const_int 7)
 
20579
+                     (const_int 0) (const_int 1)
 
20580
+                     (const_int 2) (const_int 3)])))
 
20581
+   (set (match_dup 0)
 
20582
+        (vec_select:V8HI
 
20583
+          (match_dup 1)
 
20584
+          (parallel [(const_int 4) (const_int 5)
 
20585
+                     (const_int 6) (const_int 7)
 
20586
+                     (const_int 0) (const_int 1)
 
20587
+                     (const_int 2) (const_int 3)])))
 
20588
+   (set (match_dup 1)
 
20589
+        (vec_select:V8HI
 
20590
+          (match_dup 1)
 
20591
+          (parallel [(const_int 4) (const_int 5)
 
20592
+                     (const_int 6) (const_int 7)
 
20593
+                     (const_int 0) (const_int 1)
 
20594
+                     (const_int 2) (const_int 3)])))]
 
20595
+  "")
 
20596
+
 
20597
+(define_insn "*vsx_le_perm_store_v16qi"
 
20598
+  [(set (match_operand:V16QI 0 "memory_operand" "=Z")
 
20599
+        (match_operand:V16QI 1 "vsx_register_operand" "+wa"))]
 
20600
+  "!BYTES_BIG_ENDIAN && TARGET_VSX"
 
20601
+  "#"
 
20602
+  [(set_attr "type" "vecstore")
 
20603
+   (set_attr "length" "12")])
 
20604
+
 
20605
+(define_split
 
20606
+  [(set (match_operand:V16QI 0 "memory_operand" "")
 
20607
+        (match_operand:V16QI 1 "vsx_register_operand" ""))]
 
20608
+  "!BYTES_BIG_ENDIAN && TARGET_VSX && !reload_completed"
 
20609
+  [(set (match_dup 2)
 
20610
+        (vec_select:V16QI
 
20611
+          (match_dup 1)
 
20612
+          (parallel [(const_int 8) (const_int 9)
 
20613
+                     (const_int 10) (const_int 11)
 
20614
+                     (const_int 12) (const_int 13)
 
20615
+                     (const_int 14) (const_int 15)
 
20616
+                     (const_int 0) (const_int 1)
 
20617
+                     (const_int 2) (const_int 3)
 
20618
+                     (const_int 4) (const_int 5)
 
20619
+                     (const_int 6) (const_int 7)])))
 
20620
+   (set (match_dup 0)
 
20621
+        (vec_select:V16QI
 
20622
+          (match_dup 2)
 
20623
+          (parallel [(const_int 8) (const_int 9)
 
20624
+                     (const_int 10) (const_int 11)
 
20625
+                     (const_int 12) (const_int 13)
 
20626
+                     (const_int 14) (const_int 15)
 
20627
+                     (const_int 0) (const_int 1)
 
20628
+                     (const_int 2) (const_int 3)
 
20629
+                     (const_int 4) (const_int 5)
 
20630
+                     (const_int 6) (const_int 7)])))]
 
20631
+{
 
20632
+  operands[2] = can_create_pseudo_p () ? gen_reg_rtx_and_attrs (operands[1]) 
 
20633
+                                       : operands[1];
 
20634
+})
 
20635
+
 
20636
+;; The post-reload split requires that we re-permute the source
 
20637
+;; register in case it is still live.
 
20638
+(define_split
 
20639
+  [(set (match_operand:V16QI 0 "memory_operand" "")
 
20640
+        (match_operand:V16QI 1 "vsx_register_operand" ""))]
 
20641
+  "!BYTES_BIG_ENDIAN && TARGET_VSX && reload_completed"
 
20642
+  [(set (match_dup 1)
 
20643
+        (vec_select:V16QI
 
20644
+          (match_dup 1)
 
20645
+          (parallel [(const_int 8) (const_int 9)
 
20646
+                     (const_int 10) (const_int 11)
 
20647
+                     (const_int 12) (const_int 13)
 
20648
+                     (const_int 14) (const_int 15)
 
20649
+                     (const_int 0) (const_int 1)
 
20650
+                     (const_int 2) (const_int 3)
 
20651
+                     (const_int 4) (const_int 5)
 
20652
+                     (const_int 6) (const_int 7)])))
 
20653
+   (set (match_dup 0)
 
20654
+        (vec_select:V16QI
 
20655
+          (match_dup 1)
 
20656
+          (parallel [(const_int 8) (const_int 9)
 
20657
+                     (const_int 10) (const_int 11)
 
20658
+                     (const_int 12) (const_int 13)
 
20659
+                     (const_int 14) (const_int 15)
 
20660
+                     (const_int 0) (const_int 1)
 
20661
+                     (const_int 2) (const_int 3)
 
20662
+                     (const_int 4) (const_int 5)
 
20663
+                     (const_int 6) (const_int 7)])))
 
20664
+   (set (match_dup 1)
 
20665
+        (vec_select:V16QI
 
20666
+          (match_dup 1)
 
20667
+          (parallel [(const_int 8) (const_int 9)
 
20668
+                     (const_int 10) (const_int 11)
 
20669
+                     (const_int 12) (const_int 13)
 
20670
+                     (const_int 14) (const_int 15)
 
20671
+                     (const_int 0) (const_int 1)
 
20672
+                     (const_int 2) (const_int 3)
 
20673
+                     (const_int 4) (const_int 5)
 
20674
+                     (const_int 6) (const_int 7)])))]
 
20675
+  "")
 
20676
+
 
20677
+
 
20678
+(define_insn "*vsx_mov<mode>"
 
20679
+  [(set (match_operand:VSX_M 0 "nonimmediate_operand" "=Z,<VSr>,<VSr>,?Z,?wa,?wa,wQ,?&r,??Y,??r,??r,<VSr>,?wa,*r,v,wZ, v")
 
20680
+       (match_operand:VSX_M 1 "input_operand" "<VSr>,Z,<VSr>,wa,Z,wa,r,wQ,r,Y,r,j,j,j,W,v,wZ"))]
 
20681
+  "VECTOR_MEM_VSX_P (<MODE>mode)
 
20682
+   && (register_operand (operands[0], <MODE>mode) 
 
20683
+       || register_operand (operands[1], <MODE>mode))"
 
20684
+{
 
20685
+  return rs6000_output_move_128bit (operands);
 
20686
 }
 
20687
-  [(set_attr "type" "vecstore,vecload,vecsimple,vecstore,vecload,vecsimple,*,*,*,vecsimple,vecsimple,*,*,vecstore,vecload")])
 
20688
+  [(set_attr "type" "vecstore,vecload,vecsimple,vecstore,vecload,vecsimple,load,store,store,load, *,vecsimple,vecsimple,*, *,vecstore,vecload")
 
20689
+   (set_attr "length" "4,4,4,4,4,4,12,12,12,12,16,4,4,*,16,4,4")])
 
20690
 
 
20691
-;; Unlike other VSX moves, allow the GPRs, since a normal use of TImode is for
 
20692
-;; unions.  However for plain data movement, slightly favor the vector loads
 
20693
-(define_insn "*vsx_movti"
 
20694
-  [(set (match_operand:TI 0 "nonimmediate_operand" "=Z,wa,wa,?Y,?r,?r,wa,v,v,wZ")
 
20695
-       (match_operand:TI 1 "input_operand" "wa,Z,wa,r,Y,r,j,W,wZ,v"))]
 
20696
-  "VECTOR_MEM_VSX_P (TImode)
 
20697
+;; Unlike other VSX moves, allow the GPRs even for reloading, since a normal
 
20698
+;; use of TImode is for unions.  However for plain data movement, slightly
 
20699
+;; favor the vector loads
 
20700
+(define_insn "*vsx_movti_64bit"
 
20701
+  [(set (match_operand:TI 0 "nonimmediate_operand" "=Z,wa,wa,wa,v,v,wZ,wQ,&r,Y,r,r,?r")
 
20702
+       (match_operand:TI 1 "input_operand" "wa,Z,wa,O,W,wZ,v,r,wQ,r,Y,r,n"))]
 
20703
+  "TARGET_POWERPC64 && VECTOR_MEM_VSX_P (TImode)
 
20704
    && (register_operand (operands[0], TImode) 
 
20705
        || register_operand (operands[1], TImode))"
 
20706
 {
 
20707
+  return rs6000_output_move_128bit (operands);
 
20708
+}
 
20709
+  [(set_attr "type" "vecstore,vecload,vecsimple,vecsimple,vecsimple,vecstore,vecload,store,load,store,load,*,*")
 
20710
+   (set_attr "length" "4,4,4,4,16,4,4,8,8,8,8,8,8")])
 
20711
+
 
20712
+(define_insn "*vsx_movti_32bit"
 
20713
+  [(set (match_operand:TI 0 "nonimmediate_operand" "=Z,wa,wa,wa,v, v,wZ,Q,Y,????r,????r,????r,r")
 
20714
+       (match_operand:TI 1 "input_operand"        "wa, Z,wa, O,W,wZ, v,r,r,    Q,    Y,    r,n"))]
 
20715
+  "! TARGET_POWERPC64 && VECTOR_MEM_VSX_P (TImode)
 
20716
+   && (register_operand (operands[0], TImode)
 
20717
+       || register_operand (operands[1], TImode))"
 
20718
+{
 
20719
   switch (which_alternative)
 
20720
     {
 
20721
     case 0:
 
20722
@@ -290,27 +615,45 @@
 
20723
       return "xxlor %x0,%x1,%x1";
 
20724
 
 
20725
     case 3:
 
20726
+      return "xxlxor %x0,%x0,%x0";
 
20727
+
 
20728
     case 4:
 
20729
+      return output_vec_const_move (operands);
 
20730
+
 
20731
     case 5:
 
20732
-      return "#";
 
20733
+      return "stvx %1,%y0";
 
20734
 
 
20735
     case 6:
 
20736
-      return "xxlxor %x0,%x0,%x0";
 
20737
+      return "lvx %0,%y1";
 
20738
 
 
20739
     case 7:
 
20740
-      return output_vec_const_move (operands);
 
20741
+      if (TARGET_STRING)
 
20742
+        return \"stswi %1,%P0,16\";
 
20743
 
 
20744
     case 8:
 
20745
-      return "stvx %1,%y0";
 
20746
+      return \"#\";
 
20747
 
 
20748
     case 9:
 
20749
-      return "lvx %0,%y1";
 
20750
+      /* If the address is not used in the output, we can use lsi.  Otherwise,
 
20751
+        fall through to generating four loads.  */
 
20752
+      if (TARGET_STRING
 
20753
+          && ! reg_overlap_mentioned_p (operands[0], operands[1]))
 
20754
+       return \"lswi %0,%P1,16\";
 
20755
+      /* ... fall through ...  */
 
20756
 
 
20757
+    case 10:
 
20758
+    case 11:
 
20759
+    case 12:
 
20760
+      return \"#\";
 
20761
     default:
 
20762
       gcc_unreachable ();
 
20763
     }
 
20764
 }
 
20765
-  [(set_attr "type" "vecstore,vecload,vecsimple,*,*,*,vecsimple,*,vecstore,vecload")])
 
20766
+  [(set_attr "type" "vecstore,vecload,vecsimple,vecsimple,vecsimple,vecstore,vecload,store_ux,store_ux,load_ux,load_ux, *, *")
 
20767
+   (set_attr "length" "     4,      4,        4,       4,         8,       4,      4,      16,      16,     16,     16,16,16")
 
20768
+   (set (attr "cell_micro") (if_then_else (match_test "TARGET_STRING")
 
20769
+                                         (const_string "always")
 
20770
+                                         (const_string "conditional")))])
 
20771
 
 
20772
 ;; Explicit  load/store expanders for the builtin functions
 
20773
 (define_expand "vsx_load_<mode>"
 
20774
@@ -320,46 +663,48 @@
 
20775
   "")
 
20776
 
 
20777
 (define_expand "vsx_store_<mode>"
 
20778
-  [(set (match_operand:VEC_M 0 "memory_operand" "")
 
20779
-       (match_operand:VEC_M 1 "vsx_register_operand" ""))]
 
20780
+  [(set (match_operand:VSX_M 0 "memory_operand" "")
 
20781
+       (match_operand:VSX_M 1 "vsx_register_operand" ""))]
 
20782
   "VECTOR_MEM_VSX_P (<MODE>mode)"
 
20783
   "")
 
20784
 
 
20785
 
 
20786
-;; VSX scalar and vector floating point arithmetic instructions
 
20787
+;; VSX vector floating point arithmetic instructions.  The VSX scalar
 
20788
+;; instructions are now combined with the insn for the traditional floating
 
20789
+;; point unit.
 
20790
 (define_insn "*vsx_add<mode>3"
 
20791
-  [(set (match_operand:VSX_B 0 "vsx_register_operand" "=<VSr>,?wa")
 
20792
-        (plus:VSX_B (match_operand:VSX_B 1 "vsx_register_operand" "<VSr>,wa")
 
20793
-                   (match_operand:VSX_B 2 "vsx_register_operand" "<VSr>,wa")))]
 
20794
+  [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,?wa")
 
20795
+        (plus:VSX_F (match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,wa")
 
20796
+                   (match_operand:VSX_F 2 "vsx_register_operand" "<VSr>,wa")))]
 
20797
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
20798
-  "x<VSv>add<VSs> %x0,%x1,%x2"
 
20799
+  "xvadd<VSs> %x0,%x1,%x2"
 
20800
   [(set_attr "type" "<VStype_simple>")
 
20801
    (set_attr "fp_type" "<VSfptype_simple>")])
 
20802
 
 
20803
 (define_insn "*vsx_sub<mode>3"
 
20804
-  [(set (match_operand:VSX_B 0 "vsx_register_operand" "=<VSr>,?wa")
 
20805
-        (minus:VSX_B (match_operand:VSX_B 1 "vsx_register_operand" "<VSr>,wa")
 
20806
-                    (match_operand:VSX_B 2 "vsx_register_operand" "<VSr>,wa")))]
 
20807
+  [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,?wa")
 
20808
+        (minus:VSX_F (match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,wa")
 
20809
+                    (match_operand:VSX_F 2 "vsx_register_operand" "<VSr>,wa")))]
 
20810
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
20811
-  "x<VSv>sub<VSs> %x0,%x1,%x2"
 
20812
+  "xvsub<VSs> %x0,%x1,%x2"
 
20813
   [(set_attr "type" "<VStype_simple>")
 
20814
    (set_attr "fp_type" "<VSfptype_simple>")])
 
20815
 
 
20816
 (define_insn "*vsx_mul<mode>3"
 
20817
-  [(set (match_operand:VSX_B 0 "vsx_register_operand" "=<VSr>,?wa")
 
20818
-        (mult:VSX_B (match_operand:VSX_B 1 "vsx_register_operand" "<VSr>,wa")
 
20819
-                   (match_operand:VSX_B 2 "vsx_register_operand" "<VSr>,wa")))]
 
20820
+  [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,?wa")
 
20821
+        (mult:VSX_F (match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,wa")
 
20822
+                   (match_operand:VSX_F 2 "vsx_register_operand" "<VSr>,wa")))]
 
20823
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
20824
-  "x<VSv>mul<VSs> %x0,%x1,%x2"
 
20825
-  [(set_attr "type" "<VStype_mul>")
 
20826
+  "xvmul<VSs> %x0,%x1,%x2"
 
20827
+  [(set_attr "type" "<VStype_simple>")
 
20828
    (set_attr "fp_type" "<VSfptype_mul>")])
 
20829
 
 
20830
 (define_insn "*vsx_div<mode>3"
 
20831
-  [(set (match_operand:VSX_B 0 "vsx_register_operand" "=<VSr>,?wa")
 
20832
-        (div:VSX_B (match_operand:VSX_B 1 "vsx_register_operand" "<VSr>,wa")
 
20833
-                  (match_operand:VSX_B 2 "vsx_register_operand" "<VSr>,wa")))]
 
20834
+  [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,?wa")
 
20835
+        (div:VSX_F (match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,wa")
 
20836
+                  (match_operand:VSX_F 2 "vsx_register_operand" "<VSr>,wa")))]
 
20837
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
20838
-  "x<VSv>div<VSs> %x0,%x1,%x2"
 
20839
+  "xvdiv<VSs> %x0,%x1,%x2"
 
20840
   [(set_attr "type" "<VStype_div>")
 
20841
    (set_attr "fp_type" "<VSfptype_div>")])
 
20842
 
 
20843
@@ -402,94 +747,72 @@
 
20844
    (set_attr "fp_type" "<VSfptype_simple>")])
 
20845
 
 
20846
 (define_insn "vsx_fre<mode>2"
 
20847
-  [(set (match_operand:VSX_B 0 "vsx_register_operand" "=<VSr>,?wa")
 
20848
-       (unspec:VSX_B [(match_operand:VSX_B 1 "vsx_register_operand" "<VSr>,wa")]
 
20849
+  [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,?wa")
 
20850
+       (unspec:VSX_F [(match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,wa")]
 
20851
                      UNSPEC_FRES))]
 
20852
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
20853
-  "x<VSv>re<VSs> %x0,%x1"
 
20854
+  "xvre<VSs> %x0,%x1"
 
20855
   [(set_attr "type" "<VStype_simple>")
 
20856
    (set_attr "fp_type" "<VSfptype_simple>")])
 
20857
 
 
20858
 (define_insn "*vsx_neg<mode>2"
 
20859
-  [(set (match_operand:VSX_B 0 "vsx_register_operand" "=<VSr>,?wa")
 
20860
-        (neg:VSX_B (match_operand:VSX_B 1 "vsx_register_operand" "<VSr>,wa")))]
 
20861
+  [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,?wa")
 
20862
+        (neg:VSX_F (match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,wa")))]
 
20863
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
20864
-  "x<VSv>neg<VSs> %x0,%x1"
 
20865
+  "xvneg<VSs> %x0,%x1"
 
20866
   [(set_attr "type" "<VStype_simple>")
 
20867
    (set_attr "fp_type" "<VSfptype_simple>")])
 
20868
 
 
20869
 (define_insn "*vsx_abs<mode>2"
 
20870
-  [(set (match_operand:VSX_B 0 "vsx_register_operand" "=<VSr>,?wa")
 
20871
-        (abs:VSX_B (match_operand:VSX_B 1 "vsx_register_operand" "<VSr>,wa")))]
 
20872
+  [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,?wa")
 
20873
+        (abs:VSX_F (match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,wa")))]
 
20874
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
20875
-  "x<VSv>abs<VSs> %x0,%x1"
 
20876
+  "xvabs<VSs> %x0,%x1"
 
20877
   [(set_attr "type" "<VStype_simple>")
 
20878
    (set_attr "fp_type" "<VSfptype_simple>")])
 
20879
 
 
20880
 (define_insn "vsx_nabs<mode>2"
 
20881
-  [(set (match_operand:VSX_B 0 "vsx_register_operand" "=<VSr>,?wa")
 
20882
-        (neg:VSX_B
 
20883
-        (abs:VSX_B
 
20884
-         (match_operand:VSX_B 1 "vsx_register_operand" "<VSr>,wa"))))]
 
20885
+  [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,?wa")
 
20886
+        (neg:VSX_F
 
20887
+        (abs:VSX_F
 
20888
+         (match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,wa"))))]
 
20889
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
20890
-  "x<VSv>nabs<VSs> %x0,%x1"
 
20891
+  "xvnabs<VSs> %x0,%x1"
 
20892
   [(set_attr "type" "<VStype_simple>")
 
20893
    (set_attr "fp_type" "<VSfptype_simple>")])
 
20894
 
 
20895
 (define_insn "vsx_smax<mode>3"
 
20896
-  [(set (match_operand:VSX_B 0 "vsx_register_operand" "=<VSr>,?wa")
 
20897
-        (smax:VSX_B (match_operand:VSX_B 1 "vsx_register_operand" "<VSr>,wa")
 
20898
-                   (match_operand:VSX_B 2 "vsx_register_operand" "<VSr>,wa")))]
 
20899
+  [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,?wa")
 
20900
+        (smax:VSX_F (match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,wa")
 
20901
+                   (match_operand:VSX_F 2 "vsx_register_operand" "<VSr>,wa")))]
 
20902
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
20903
-  "x<VSv>max<VSs> %x0,%x1,%x2"
 
20904
+  "xvmax<VSs> %x0,%x1,%x2"
 
20905
   [(set_attr "type" "<VStype_simple>")
 
20906
    (set_attr "fp_type" "<VSfptype_simple>")])
 
20907
 
 
20908
 (define_insn "*vsx_smin<mode>3"
 
20909
-  [(set (match_operand:VSX_B 0 "vsx_register_operand" "=<VSr>,?wa")
 
20910
-        (smin:VSX_B (match_operand:VSX_B 1 "vsx_register_operand" "<VSr>,wa")
 
20911
-                   (match_operand:VSX_B 2 "vsx_register_operand" "<VSr>,wa")))]
 
20912
+  [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,?wa")
 
20913
+        (smin:VSX_F (match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,wa")
 
20914
+                   (match_operand:VSX_F 2 "vsx_register_operand" "<VSr>,wa")))]
 
20915
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
20916
-  "x<VSv>min<VSs> %x0,%x1,%x2"
 
20917
+  "xvmin<VSs> %x0,%x1,%x2"
 
20918
   [(set_attr "type" "<VStype_simple>")
 
20919
    (set_attr "fp_type" "<VSfptype_simple>")])
 
20920
 
 
20921
-;; Special VSX version of smin/smax for single precision floating point.  Since
 
20922
-;; both numbers are rounded to single precision, we can just use the DP version
 
20923
-;; of the instruction.
 
20924
-
 
20925
-(define_insn "*vsx_smaxsf3"
 
20926
-  [(set (match_operand:SF 0 "vsx_register_operand" "=f")
 
20927
-        (smax:SF (match_operand:SF 1 "vsx_register_operand" "f")
 
20928
-                (match_operand:SF 2 "vsx_register_operand" "f")))]
 
20929
-  "VECTOR_UNIT_VSX_P (DFmode)"
 
20930
-  "xsmaxdp %x0,%x1,%x2"
 
20931
-  [(set_attr "type" "fp")
 
20932
-   (set_attr "fp_type" "fp_addsub_d")])
 
20933
-
 
20934
-(define_insn "*vsx_sminsf3"
 
20935
-  [(set (match_operand:SF 0 "vsx_register_operand" "=f")
 
20936
-        (smin:SF (match_operand:SF 1 "vsx_register_operand" "f")
 
20937
-                (match_operand:SF 2 "vsx_register_operand" "f")))]
 
20938
-  "VECTOR_UNIT_VSX_P (DFmode)"
 
20939
-  "xsmindp %x0,%x1,%x2"
 
20940
-  [(set_attr "type" "fp")
 
20941
-   (set_attr "fp_type" "fp_addsub_d")])
 
20942
-
 
20943
 (define_insn "*vsx_sqrt<mode>2"
 
20944
-  [(set (match_operand:VSX_B 0 "vsx_register_operand" "=<VSr>,?wa")
 
20945
-        (sqrt:VSX_B (match_operand:VSX_B 1 "vsx_register_operand" "<VSr>,wa")))]
 
20946
+  [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,?wa")
 
20947
+        (sqrt:VSX_F (match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,wa")))]
 
20948
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
20949
-  "x<VSv>sqrt<VSs> %x0,%x1"
 
20950
+  "xvsqrt<VSs> %x0,%x1"
 
20951
   [(set_attr "type" "<VStype_sqrt>")
 
20952
    (set_attr "fp_type" "<VSfptype_sqrt>")])
 
20953
 
 
20954
 (define_insn "*vsx_rsqrte<mode>2"
 
20955
-  [(set (match_operand:VSX_B 0 "vsx_register_operand" "=<VSr>,?wa")
 
20956
-       (unspec:VSX_B [(match_operand:VSX_B 1 "vsx_register_operand" "<VSr>,wa")]
 
20957
+  [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,?wa")
 
20958
+       (unspec:VSX_F [(match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,wa")]
 
20959
                      UNSPEC_RSQRT))]
 
20960
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
20961
-  "x<VSv>rsqrte<VSs> %x0,%x1"
 
20962
+  "xvrsqrte<VSs> %x0,%x1"
 
20963
   [(set_attr "type" "<VStype_simple>")
 
20964
    (set_attr "fp_type" "<VSfptype_simple>")])
 
20965
 
 
20966
@@ -528,27 +851,11 @@
 
20967
   [(set_attr "type" "<VStype_simple>")
 
20968
    (set_attr "fp_type" "<VSfptype_simple>")])
 
20969
 
 
20970
-;; Fused vector multiply/add instructions Support the classical DF versions of
 
20971
-;; fma, which allows the target to be a separate register from the 3 inputs.
 
20972
-;; Under VSX, the target must be either the addend or the first multiply.
 
20973
-;; Where we can, also do the same for the Altivec V4SF fmas.
 
20974
+;; Fused vector multiply/add instructions. Support the classical Altivec
 
20975
+;; versions of fma, which allows the target to be a separate register from the
 
20976
+;; 3 inputs.  Under VSX, the target must be either the addend or the first
 
20977
+;; multiply.
 
20978
 
 
20979
-(define_insn "*vsx_fmadf4"
 
20980
-  [(set (match_operand:DF 0 "vsx_register_operand" "=ws,ws,?wa,?wa,d")
 
20981
-       (fma:DF
 
20982
-         (match_operand:DF 1 "vsx_register_operand" "%ws,ws,wa,wa,d")
 
20983
-         (match_operand:DF 2 "vsx_register_operand" "ws,0,wa,0,d")
 
20984
-         (match_operand:DF 3 "vsx_register_operand" "0,ws,0,wa,d")))]
 
20985
-  "VECTOR_UNIT_VSX_P (DFmode)"
 
20986
-  "@
 
20987
-   xsmaddadp %x0,%x1,%x2
 
20988
-   xsmaddmdp %x0,%x1,%x3
 
20989
-   xsmaddadp %x0,%x1,%x2
 
20990
-   xsmaddmdp %x0,%x1,%x3
 
20991
-   fmadd %0,%1,%2,%3"
 
20992
-  [(set_attr "type" "fp")
 
20993
-   (set_attr "fp_type" "fp_maddsub_d")])
 
20994
-
 
20995
 (define_insn "*vsx_fmav4sf4"
 
20996
   [(set (match_operand:V4SF 0 "vsx_register_operand" "=ws,ws,?wa,?wa,v")
 
20997
        (fma:V4SF
 
20998
@@ -578,23 +885,6 @@
 
20999
    xvmaddmdp %x0,%x1,%x3"
 
21000
   [(set_attr "type" "vecdouble")])
 
21001
 
 
21002
-(define_insn "*vsx_fmsdf4"
 
21003
-  [(set (match_operand:DF 0 "vsx_register_operand" "=ws,ws,?wa,?wa,d")
 
21004
-       (fma:DF
 
21005
-         (match_operand:DF 1 "vsx_register_operand" "%ws,ws,wa,wa,d")
 
21006
-         (match_operand:DF 2 "vsx_register_operand" "ws,0,wa,0,d")
 
21007
-         (neg:DF
 
21008
-           (match_operand:DF 3 "vsx_register_operand" "0,ws,0,wa,d"))))]
 
21009
-  "VECTOR_UNIT_VSX_P (DFmode)"
 
21010
-  "@
 
21011
-   xsmsubadp %x0,%x1,%x2
 
21012
-   xsmsubmdp %x0,%x1,%x3
 
21013
-   xsmsubadp %x0,%x1,%x2
 
21014
-   xsmsubmdp %x0,%x1,%x3
 
21015
-   fmsub %0,%1,%2,%3"
 
21016
-  [(set_attr "type" "fp")
 
21017
-   (set_attr "fp_type" "fp_maddsub_d")])
 
21018
-
 
21019
 (define_insn "*vsx_fms<mode>4"
 
21020
   [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,<VSr>,?wa,?wa")
 
21021
        (fma:VSX_F
 
21022
@@ -604,29 +894,12 @@
 
21023
            (match_operand:VSX_F 3 "vsx_register_operand" "0,<VSr>,0,wa"))))]
 
21024
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
21025
   "@
 
21026
-   x<VSv>msuba<VSs> %x0,%x1,%x2
 
21027
-   x<VSv>msubm<VSs> %x0,%x1,%x3
 
21028
-   x<VSv>msuba<VSs> %x0,%x1,%x2
 
21029
-   x<VSv>msubm<VSs> %x0,%x1,%x3"
 
21030
+   xvmsuba<VSs> %x0,%x1,%x2
 
21031
+   xvmsubm<VSs> %x0,%x1,%x3
 
21032
+   xvmsuba<VSs> %x0,%x1,%x2
 
21033
+   xvmsubm<VSs> %x0,%x1,%x3"
 
21034
   [(set_attr "type" "<VStype_mul>")])
 
21035
 
 
21036
-(define_insn "*vsx_nfmadf4"
 
21037
-  [(set (match_operand:DF 0 "vsx_register_operand" "=ws,ws,?wa,?wa,d")
 
21038
-       (neg:DF
 
21039
-        (fma:DF
 
21040
-         (match_operand:DF 1 "vsx_register_operand" "ws,ws,wa,wa,d")
 
21041
-         (match_operand:DF 2 "vsx_register_operand" "ws,0,wa,0,d")
 
21042
-         (match_operand:DF 3 "vsx_register_operand" "0,ws,0,wa,d"))))]
 
21043
-  "VECTOR_UNIT_VSX_P (DFmode)"
 
21044
-  "@
 
21045
-   xsnmaddadp %x0,%x1,%x2
 
21046
-   xsnmaddmdp %x0,%x1,%x3
 
21047
-   xsnmaddadp %x0,%x1,%x2
 
21048
-   xsnmaddmdp %x0,%x1,%x3
 
21049
-   fnmadd %0,%1,%2,%3"
 
21050
-  [(set_attr "type" "fp")
 
21051
-   (set_attr "fp_type" "fp_maddsub_d")])
 
21052
-
 
21053
 (define_insn "*vsx_nfma<mode>4"
 
21054
   [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,<VSr>,?wa,?wa")
 
21055
        (neg:VSX_F
 
21056
@@ -636,31 +909,13 @@
 
21057
          (match_operand:VSX_F 3 "vsx_register_operand" "0,<VSr>,0,wa"))))]
 
21058
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
21059
   "@
 
21060
-   x<VSv>nmadda<VSs> %x0,%x1,%x2
 
21061
-   x<VSv>nmaddm<VSs> %x0,%x1,%x3
 
21062
-   x<VSv>nmadda<VSs> %x0,%x1,%x2
 
21063
-   x<VSv>nmaddm<VSs> %x0,%x1,%x3"
 
21064
+   xvnmadda<VSs> %x0,%x1,%x2
 
21065
+   xvnmaddm<VSs> %x0,%x1,%x3
 
21066
+   xvnmadda<VSs> %x0,%x1,%x2
 
21067
+   xvnmaddm<VSs> %x0,%x1,%x3"
 
21068
   [(set_attr "type" "<VStype_mul>")
 
21069
    (set_attr "fp_type" "<VSfptype_mul>")])
 
21070
 
 
21071
-(define_insn "*vsx_nfmsdf4"
 
21072
-  [(set (match_operand:DF 0 "vsx_register_operand" "=ws,ws,?wa,?wa,d")
 
21073
-       (neg:DF
 
21074
-        (fma:DF
 
21075
-          (match_operand:DF 1 "vsx_register_operand" "%ws,ws,wa,wa,d")
 
21076
-          (match_operand:DF 2 "vsx_register_operand" "ws,0,wa,0,d")
 
21077
-          (neg:DF
 
21078
-            (match_operand:DF 3 "vsx_register_operand" "0,ws,0,wa,d")))))]
 
21079
-  "VECTOR_UNIT_VSX_P (DFmode)"
 
21080
-  "@
 
21081
-   xsnmsubadp %x0,%x1,%x2
 
21082
-   xsnmsubmdp %x0,%x1,%x3
 
21083
-   xsnmsubadp %x0,%x1,%x2
 
21084
-   xsnmsubmdp %x0,%x1,%x3
 
21085
-   fnmsub %0,%1,%2,%3"
 
21086
-  [(set_attr "type" "fp")
 
21087
-   (set_attr "fp_type" "fp_maddsub_d")])
 
21088
-
 
21089
 (define_insn "*vsx_nfmsv4sf4"
 
21090
   [(set (match_operand:V4SF 0 "vsx_register_operand" "=wf,wf,?wa,?wa,v")
 
21091
        (neg:V4SF
 
21092
@@ -722,16 +977,6 @@
 
21093
   [(set_attr "type" "<VStype_simple>")
 
21094
    (set_attr "fp_type" "<VSfptype_simple>")])
 
21095
 
 
21096
-;; Floating point scalar compare
 
21097
-(define_insn "*vsx_cmpdf_internal1"
 
21098
-  [(set (match_operand:CCFP 0 "cc_reg_operand" "=y,?y")
 
21099
-       (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "ws,wa")
 
21100
-                     (match_operand:DF 2 "gpc_reg_operand" "ws,wa")))]
 
21101
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
 
21102
-   && VECTOR_UNIT_VSX_P (DFmode)"
 
21103
-  "xscmpudp %0,%x1,%x2"
 
21104
-  [(set_attr "type" "fpcompare")])
 
21105
-
 
21106
 ;; Compare vectors producing a vector result and a predicate, setting CR6 to
 
21107
 ;; indicate a combined status
 
21108
 (define_insn "*vsx_eq_<mode>_p"
 
21109
@@ -798,13 +1043,13 @@
 
21110
 
 
21111
 ;; Copy sign
 
21112
 (define_insn "vsx_copysign<mode>3"
 
21113
-  [(set (match_operand:VSX_B 0 "vsx_register_operand" "=<VSr>,?wa")
 
21114
-       (unspec:VSX_B
 
21115
-        [(match_operand:VSX_B 1 "vsx_register_operand" "<VSr>,wa")
 
21116
-         (match_operand:VSX_B 2 "vsx_register_operand" "<VSr>,wa")]
 
21117
+  [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,?wa")
 
21118
+       (unspec:VSX_F
 
21119
+        [(match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,wa")
 
21120
+         (match_operand:VSX_F 2 "vsx_register_operand" "<VSr>,wa")]
 
21121
         UNSPEC_COPYSIGN))]
 
21122
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
21123
-  "x<VSv>cpsgn<VSs> %x0,%x2,%x1"
 
21124
+  "xvcpsgn<VSs> %x0,%x2,%x1"
 
21125
   [(set_attr "type" "<VStype_simple>")
 
21126
    (set_attr "fp_type" "<VSfptype_simple>")])
 
21127
 
 
21128
@@ -865,10 +1110,10 @@
 
21129
    (set_attr "fp_type" "<VSfptype_simple>")])
 
21130
 
 
21131
 (define_insn "vsx_btrunc<mode>2"
 
21132
-  [(set (match_operand:VSX_B 0 "vsx_register_operand" "=<VSr>,?wa")
 
21133
-       (fix:VSX_B (match_operand:VSX_B 1 "vsx_register_operand" "<VSr>,wa")))]
 
21134
+  [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,?wa")
 
21135
+       (fix:VSX_F (match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,wa")))]
 
21136
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
21137
-  "x<VSv>r<VSs>iz %x0,%x1"
 
21138
+  "xvr<VSs>iz %x0,%x1"
 
21139
   [(set_attr "type" "<VStype_simple>")
 
21140
    (set_attr "fp_type" "<VSfptype_simple>")])
 
21141
 
 
21142
@@ -882,20 +1127,20 @@
 
21143
    (set_attr "fp_type" "<VSfptype_simple>")])
 
21144
 
 
21145
 (define_insn "vsx_floor<mode>2"
 
21146
-  [(set (match_operand:VSX_B 0 "vsx_register_operand" "=<VSr>,?wa")
 
21147
-       (unspec:VSX_B [(match_operand:VSX_B 1 "vsx_register_operand" "<VSr>,wa")]
 
21148
+  [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,?wa")
 
21149
+       (unspec:VSX_F [(match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,wa")]
 
21150
                      UNSPEC_FRIM))]
 
21151
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
21152
-  "x<VSv>r<VSs>im %x0,%x1"
 
21153
+  "xvr<VSs>im %x0,%x1"
 
21154
   [(set_attr "type" "<VStype_simple>")
 
21155
    (set_attr "fp_type" "<VSfptype_simple>")])
 
21156
 
 
21157
 (define_insn "vsx_ceil<mode>2"
 
21158
-  [(set (match_operand:VSX_B 0 "vsx_register_operand" "=<VSr>,?wa")
 
21159
-       (unspec:VSX_B [(match_operand:VSX_B 1 "vsx_register_operand" "<VSr>,wa")]
 
21160
+  [(set (match_operand:VSX_F 0 "vsx_register_operand" "=<VSr>,?wa")
 
21161
+       (unspec:VSX_F [(match_operand:VSX_F 1 "vsx_register_operand" "<VSr>,wa")]
 
21162
                      UNSPEC_FRIP))]
 
21163
   "VECTOR_UNIT_VSX_P (<MODE>mode)"
 
21164
-  "x<VSv>r<VSs>ip %x0,%x1"
 
21165
+  "xvr<VSs>ip %x0,%x1"
 
21166
   [(set_attr "type" "<VStype_simple>")
 
21167
    (set_attr "fp_type" "<VSfptype_simple>")])
 
21168
 
 
21169
@@ -942,6 +1187,40 @@
 
21170
   "xscvspdp %x0,%x1"
 
21171
   [(set_attr "type" "fp")])
 
21172
 
 
21173
+;; ISA 2.07 xscvdpspn/xscvspdpn that does not raise an error on signalling NaNs
 
21174
+(define_insn "vsx_xscvdpspn"
 
21175
+  [(set (match_operand:V4SF 0 "vsx_register_operand" "=ws,?wa")
 
21176
+       (unspec:V4SF [(match_operand:DF 1 "vsx_register_operand" "wd,wa")]
 
21177
+                    UNSPEC_VSX_CVDPSPN))]
 
21178
+  "TARGET_XSCVDPSPN"
 
21179
+  "xscvdpspn %x0,%x1"
 
21180
+  [(set_attr "type" "fp")])
 
21181
+
 
21182
+(define_insn "vsx_xscvspdpn"
 
21183
+  [(set (match_operand:DF 0 "vsx_register_operand" "=ws,?wa")
 
21184
+       (unspec:DF [(match_operand:V4SF 1 "vsx_register_operand" "wa,wa")]
 
21185
+                  UNSPEC_VSX_CVSPDPN))]
 
21186
+  "TARGET_XSCVSPDPN"
 
21187
+  "xscvspdpn %x0,%x1"
 
21188
+  [(set_attr "type" "fp")])
 
21189
+
 
21190
+(define_insn "vsx_xscvdpspn_scalar"
 
21191
+  [(set (match_operand:V4SF 0 "vsx_register_operand" "=wa")
 
21192
+       (unspec:V4SF [(match_operand:SF 1 "vsx_register_operand" "f")]
 
21193
+                    UNSPEC_VSX_CVDPSPN))]
 
21194
+  "TARGET_XSCVDPSPN"
 
21195
+  "xscvdpspn %x0,%x1"
 
21196
+  [(set_attr "type" "fp")])
 
21197
+
 
21198
+;; Used by direct move to move a SFmode value from GPR to VSX register
 
21199
+(define_insn "vsx_xscvspdpn_directmove"
 
21200
+  [(set (match_operand:SF 0 "vsx_register_operand" "=wa")
 
21201
+       (unspec:SF [(match_operand:SF 1 "vsx_register_operand" "wa")]
 
21202
+                  UNSPEC_VSX_CVSPDPN))]
 
21203
+  "TARGET_XSCVSPDPN"
 
21204
+  "xscvspdpn %x0,%x1"
 
21205
+  [(set_attr "type" "fp")])
 
21206
+
 
21207
 ;; Convert from 64-bit to 32-bit types
 
21208
 ;; Note, favor the Altivec registers since the usual use of these instructions
 
21209
 ;; is in vector converts and we need to use the Altivec vperm instruction.
 
21210
@@ -1027,73 +1306,21 @@
 
21211
    (set_attr "fp_type" "<VSfptype_simple>")])
 
21212
 
 
21213
 
 
21214
-;; Logical and permute operations
 
21215
-(define_insn "*vsx_and<mode>3"
 
21216
-  [(set (match_operand:VSX_L 0 "vsx_register_operand" "=<VSr>,?wa")
 
21217
-        (and:VSX_L
 
21218
-        (match_operand:VSX_L 1 "vsx_register_operand" "<VSr>,?wa")
 
21219
-        (match_operand:VSX_L 2 "vsx_register_operand" "<VSr>,?wa")))]
 
21220
-  "VECTOR_MEM_VSX_P (<MODE>mode)"
 
21221
-  "xxland %x0,%x1,%x2"
 
21222
-  [(set_attr "type" "vecsimple")])
 
21223
-
 
21224
-(define_insn "*vsx_ior<mode>3"
 
21225
-  [(set (match_operand:VSX_L 0 "vsx_register_operand" "=<VSr>,?wa")
 
21226
-        (ior:VSX_L (match_operand:VSX_L 1 "vsx_register_operand" "<VSr>,?wa")
 
21227
-                  (match_operand:VSX_L 2 "vsx_register_operand" "<VSr>,?wa")))]
 
21228
-  "VECTOR_MEM_VSX_P (<MODE>mode)"
 
21229
-  "xxlor %x0,%x1,%x2"
 
21230
-  [(set_attr "type" "vecsimple")])
 
21231
-
 
21232
-(define_insn "*vsx_xor<mode>3"
 
21233
-  [(set (match_operand:VSX_L 0 "vsx_register_operand" "=<VSr>,?wa")
 
21234
-        (xor:VSX_L
 
21235
-        (match_operand:VSX_L 1 "vsx_register_operand" "<VSr>,?wa")
 
21236
-        (match_operand:VSX_L 2 "vsx_register_operand" "<VSr>,?wa")))]
 
21237
-  "VECTOR_MEM_VSX_P (<MODE>mode)"
 
21238
-  "xxlxor %x0,%x1,%x2"
 
21239
-  [(set_attr "type" "vecsimple")])
 
21240
-
 
21241
-(define_insn "*vsx_one_cmpl<mode>2"
 
21242
-  [(set (match_operand:VSX_L 0 "vsx_register_operand" "=<VSr>,?wa")
 
21243
-        (not:VSX_L
 
21244
-        (match_operand:VSX_L 1 "vsx_register_operand" "<VSr>,?wa")))]
 
21245
-  "VECTOR_MEM_VSX_P (<MODE>mode)"
 
21246
-  "xxlnor %x0,%x1,%x1"
 
21247
-  [(set_attr "type" "vecsimple")])
 
21248
-  
 
21249
-(define_insn "*vsx_nor<mode>3"
 
21250
-  [(set (match_operand:VSX_L 0 "vsx_register_operand" "=<VSr>,?wa")
 
21251
-        (not:VSX_L
 
21252
-        (ior:VSX_L
 
21253
-         (match_operand:VSX_L 1 "vsx_register_operand" "<VSr>,?wa")
 
21254
-         (match_operand:VSX_L 2 "vsx_register_operand" "<VSr>,?wa"))))]
 
21255
-  "VECTOR_MEM_VSX_P (<MODE>mode)"
 
21256
-  "xxlnor %x0,%x1,%x2"
 
21257
-  [(set_attr "type" "vecsimple")])
 
21258
-
 
21259
-(define_insn "*vsx_andc<mode>3"
 
21260
-  [(set (match_operand:VSX_L 0 "vsx_register_operand" "=<VSr>,?wa")
 
21261
-        (and:VSX_L
 
21262
-        (not:VSX_L
 
21263
-         (match_operand:VSX_L 2 "vsx_register_operand" "<VSr>,?wa"))
 
21264
-        (match_operand:VSX_L 1 "vsx_register_operand" "<VSr>,?wa")))]
 
21265
-  "VECTOR_MEM_VSX_P (<MODE>mode)"
 
21266
-  "xxlandc %x0,%x1,%x2"
 
21267
-  [(set_attr "type" "vecsimple")])
 
21268
-
 
21269
-
 
21270
 ;; Permute operations
 
21271
 
 
21272
 ;; Build a V2DF/V2DI vector from two scalars
 
21273
 (define_insn "vsx_concat_<mode>"
 
21274
-  [(set (match_operand:VSX_D 0 "vsx_register_operand" "=wd,?wa")
 
21275
-       (unspec:VSX_D
 
21276
-        [(match_operand:<VS_scalar> 1 "vsx_register_operand" "ws,wa")
 
21277
-         (match_operand:<VS_scalar> 2 "vsx_register_operand" "ws,wa")]
 
21278
-        UNSPEC_VSX_CONCAT))]
 
21279
+  [(set (match_operand:VSX_D 0 "vsx_register_operand" "=<VSr>,?wa")
 
21280
+       (vec_concat:VSX_D
 
21281
+        (match_operand:<VS_scalar> 1 "vsx_register_operand" "ws,wa")
 
21282
+        (match_operand:<VS_scalar> 2 "vsx_register_operand" "ws,wa")))]
 
21283
   "VECTOR_MEM_VSX_P (<MODE>mode)"
 
21284
-  "xxpermdi %x0,%x1,%x2,0"
 
21285
+{
 
21286
+  if (BYTES_BIG_ENDIAN)
 
21287
+    return "xxpermdi %x0,%x1,%x2,0";
 
21288
+  else
 
21289
+    return "xxpermdi %x0,%x2,%x1,0";
 
21290
+}
 
21291
   [(set_attr "type" "vecperm")])
 
21292
 
 
21293
 ;; Special purpose concat using xxpermdi to glue two single precision values
 
21294
@@ -1106,9 +1333,161 @@
 
21295
          (match_operand:SF 2 "vsx_register_operand" "f,f")]
 
21296
         UNSPEC_VSX_CONCAT))]
 
21297
   "VECTOR_MEM_VSX_P (V2DFmode)"
 
21298
-  "xxpermdi %x0,%x1,%x2,0"
 
21299
+{
 
21300
+  if (BYTES_BIG_ENDIAN)
 
21301
+    return "xxpermdi %x0,%x1,%x2,0";
 
21302
+  else
 
21303
+    return "xxpermdi %x0,%x2,%x1,0";
 
21304
+}
 
21305
   [(set_attr "type" "vecperm")])
 
21306
 
 
21307
+;; xxpermdi for little endian loads and stores.  We need several of
 
21308
+;; these since the form of the PARALLEL differs by mode.
 
21309
+(define_insn "*vsx_xxpermdi2_le_<mode>"
 
21310
+  [(set (match_operand:VSX_D 0 "vsx_register_operand" "=wa")
 
21311
+        (vec_select:VSX_D
 
21312
+          (match_operand:VSX_D 1 "vsx_register_operand" "wa")
 
21313
+          (parallel [(const_int 1) (const_int 0)])))]
 
21314
+  "!BYTES_BIG_ENDIAN && VECTOR_MEM_VSX_P (<MODE>mode)"
 
21315
+  "xxpermdi %x0,%x1,%x1,2"
 
21316
+  [(set_attr "type" "vecperm")])
 
21317
+
 
21318
+(define_insn "*vsx_xxpermdi4_le_<mode>"
 
21319
+  [(set (match_operand:VSX_W 0 "vsx_register_operand" "=wa")
 
21320
+        (vec_select:VSX_W
 
21321
+          (match_operand:VSX_W 1 "vsx_register_operand" "wa")
 
21322
+          (parallel [(const_int 2) (const_int 3)
 
21323
+                     (const_int 0) (const_int 1)])))]
 
21324
+  "!BYTES_BIG_ENDIAN && VECTOR_MEM_VSX_P (<MODE>mode)"
 
21325
+  "xxpermdi %x0,%x1,%x1,2"
 
21326
+  [(set_attr "type" "vecperm")])
 
21327
+
 
21328
+(define_insn "*vsx_xxpermdi8_le_V8HI"
 
21329
+  [(set (match_operand:V8HI 0 "vsx_register_operand" "=wa")
 
21330
+        (vec_select:V8HI
 
21331
+          (match_operand:V8HI 1 "vsx_register_operand" "wa")
 
21332
+          (parallel [(const_int 4) (const_int 5)
 
21333
+                     (const_int 6) (const_int 7)
 
21334
+                     (const_int 0) (const_int 1)
 
21335
+                     (const_int 2) (const_int 3)])))]
 
21336
+  "!BYTES_BIG_ENDIAN && VECTOR_MEM_VSX_P (V8HImode)"
 
21337
+  "xxpermdi %x0,%x1,%x1,2"
 
21338
+  [(set_attr "type" "vecperm")])
 
21339
+
 
21340
+(define_insn "*vsx_xxpermdi16_le_V16QI"
 
21341
+  [(set (match_operand:V16QI 0 "vsx_register_operand" "=wa")
 
21342
+        (vec_select:V16QI
 
21343
+          (match_operand:V16QI 1 "vsx_register_operand" "wa")
 
21344
+          (parallel [(const_int 8) (const_int 9)
 
21345
+                     (const_int 10) (const_int 11)
 
21346
+                     (const_int 12) (const_int 13)
 
21347
+                     (const_int 14) (const_int 15)
 
21348
+                     (const_int 0) (const_int 1)
 
21349
+                     (const_int 2) (const_int 3)
 
21350
+                     (const_int 4) (const_int 5)
 
21351
+                     (const_int 6) (const_int 7)])))]
 
21352
+  "!BYTES_BIG_ENDIAN && VECTOR_MEM_VSX_P (V16QImode)"
 
21353
+  "xxpermdi %x0,%x1,%x1,2"
 
21354
+  [(set_attr "type" "vecperm")])
 
21355
+
 
21356
+;; lxvd2x for little endian loads.  We need several of
 
21357
+;; these since the form of the PARALLEL differs by mode.
 
21358
+(define_insn "*vsx_lxvd2x2_le_<mode>"
 
21359
+  [(set (match_operand:VSX_D 0 "vsx_register_operand" "=wa")
 
21360
+        (vec_select:VSX_D
 
21361
+          (match_operand:VSX_D 1 "memory_operand" "Z")
 
21362
+          (parallel [(const_int 1) (const_int 0)])))]
 
21363
+  "!BYTES_BIG_ENDIAN && VECTOR_MEM_VSX_P (<MODE>mode)"
 
21364
+  "lxvd2x %x0,%y1"
 
21365
+  [(set_attr "type" "vecload")])
 
21366
+
 
21367
+(define_insn "*vsx_lxvd2x4_le_<mode>"
 
21368
+  [(set (match_operand:VSX_W 0 "vsx_register_operand" "=wa")
 
21369
+        (vec_select:VSX_W
 
21370
+          (match_operand:VSX_W 1 "memory_operand" "Z")
 
21371
+          (parallel [(const_int 2) (const_int 3)
 
21372
+                     (const_int 0) (const_int 1)])))]
 
21373
+  "!BYTES_BIG_ENDIAN && VECTOR_MEM_VSX_P (<MODE>mode)"
 
21374
+  "lxvd2x %x0,%y1"
 
21375
+  [(set_attr "type" "vecload")])
 
21376
+
 
21377
+(define_insn "*vsx_lxvd2x8_le_V8HI"
 
21378
+  [(set (match_operand:V8HI 0 "vsx_register_operand" "=wa")
 
21379
+        (vec_select:V8HI
 
21380
+          (match_operand:V8HI 1 "memory_operand" "Z")
 
21381
+          (parallel [(const_int 4) (const_int 5)
 
21382
+                     (const_int 6) (const_int 7)
 
21383
+                     (const_int 0) (const_int 1)
 
21384
+                     (const_int 2) (const_int 3)])))]
 
21385
+  "!BYTES_BIG_ENDIAN && VECTOR_MEM_VSX_P (V8HImode)"
 
21386
+  "lxvd2x %x0,%y1"
 
21387
+  [(set_attr "type" "vecload")])
 
21388
+
 
21389
+(define_insn "*vsx_lxvd2x16_le_V16QI"
 
21390
+  [(set (match_operand:V16QI 0 "vsx_register_operand" "=wa")
 
21391
+        (vec_select:V16QI
 
21392
+          (match_operand:V16QI 1 "memory_operand" "Z")
 
21393
+          (parallel [(const_int 8) (const_int 9)
 
21394
+                     (const_int 10) (const_int 11)
 
21395
+                     (const_int 12) (const_int 13)
 
21396
+                     (const_int 14) (const_int 15)
 
21397
+                     (const_int 0) (const_int 1)
 
21398
+                     (const_int 2) (const_int 3)
 
21399
+                     (const_int 4) (const_int 5)
 
21400
+                     (const_int 6) (const_int 7)])))]
 
21401
+  "!BYTES_BIG_ENDIAN && VECTOR_MEM_VSX_P (V16QImode)"
 
21402
+  "lxvd2x %x0,%y1"
 
21403
+  [(set_attr "type" "vecload")])
 
21404
+
 
21405
+;; stxvd2x for little endian stores.  We need several of
 
21406
+;; these since the form of the PARALLEL differs by mode.
 
21407
+(define_insn "*vsx_stxvd2x2_le_<mode>"
 
21408
+  [(set (match_operand:VSX_D 0 "memory_operand" "=Z")
 
21409
+        (vec_select:VSX_D
 
21410
+          (match_operand:VSX_D 1 "vsx_register_operand" "wa")
 
21411
+          (parallel [(const_int 1) (const_int 0)])))]
 
21412
+  "!BYTES_BIG_ENDIAN && VECTOR_MEM_VSX_P (<MODE>mode)"
 
21413
+  "stxvd2x %x1,%y0"
 
21414
+  [(set_attr "type" "vecstore")])
 
21415
+
 
21416
+(define_insn "*vsx_stxvd2x4_le_<mode>"
 
21417
+  [(set (match_operand:VSX_W 0 "memory_operand" "=Z")
 
21418
+        (vec_select:VSX_W
 
21419
+          (match_operand:VSX_W 1 "vsx_register_operand" "wa")
 
21420
+          (parallel [(const_int 2) (const_int 3)
 
21421
+                     (const_int 0) (const_int 1)])))]
 
21422
+  "!BYTES_BIG_ENDIAN && VECTOR_MEM_VSX_P (<MODE>mode)"
 
21423
+  "stxvd2x %x1,%y0"
 
21424
+  [(set_attr "type" "vecstore")])
 
21425
+
 
21426
+(define_insn "*vsx_stxvd2x8_le_V8HI"
 
21427
+  [(set (match_operand:V8HI 0 "memory_operand" "=Z")
 
21428
+        (vec_select:V8HI
 
21429
+          (match_operand:V8HI 1 "vsx_register_operand" "wa")
 
21430
+          (parallel [(const_int 4) (const_int 5)
 
21431
+                     (const_int 6) (const_int 7)
 
21432
+                     (const_int 0) (const_int 1)
 
21433
+                     (const_int 2) (const_int 3)])))]
 
21434
+  "!BYTES_BIG_ENDIAN && VECTOR_MEM_VSX_P (V8HImode)"
 
21435
+  "stxvd2x %x1,%y0"
 
21436
+  [(set_attr "type" "vecstore")])
 
21437
+
 
21438
+(define_insn "*vsx_stxvd2x16_le_V16QI"
 
21439
+  [(set (match_operand:V16QI 0 "memory_operand" "=Z")
 
21440
+        (vec_select:V16QI
 
21441
+          (match_operand:V16QI 1 "vsx_register_operand" "wa")
 
21442
+          (parallel [(const_int 8) (const_int 9)
 
21443
+                     (const_int 10) (const_int 11)
 
21444
+                     (const_int 12) (const_int 13)
 
21445
+                     (const_int 14) (const_int 15)
 
21446
+                     (const_int 0) (const_int 1)
 
21447
+                     (const_int 2) (const_int 3)
 
21448
+                     (const_int 4) (const_int 5)
 
21449
+                     (const_int 6) (const_int 7)])))]
 
21450
+  "!BYTES_BIG_ENDIAN && VECTOR_MEM_VSX_P (V16QImode)"
 
21451
+  "stxvd2x %x1,%y0"
 
21452
+  [(set_attr "type" "vecstore")])
 
21453
+
 
21454
 ;; Set the element of a V2DI/VD2F mode
 
21455
 (define_insn "vsx_set_<mode>"
 
21456
   [(set (match_operand:VSX_D 0 "vsx_register_operand" "=wd,?wa")
 
21457
@@ -1118,9 +1497,10 @@
 
21458
                      UNSPEC_VSX_SET))]
 
21459
   "VECTOR_MEM_VSX_P (<MODE>mode)"
 
21460
 {
 
21461
-  if (INTVAL (operands[3]) == 0)
 
21462
+  int idx_first = BYTES_BIG_ENDIAN ? 0 : 1;
 
21463
+  if (INTVAL (operands[3]) == idx_first)
 
21464
     return \"xxpermdi %x0,%x2,%x1,1\";
 
21465
-  else if (INTVAL (operands[3]) == 1)
 
21466
+  else if (INTVAL (operands[3]) == 1 - idx_first)
 
21467
     return \"xxpermdi %x0,%x1,%x2,0\";
 
21468
   else
 
21469
     gcc_unreachable ();
 
21470
@@ -1135,8 +1515,12 @@
 
21471
                        [(match_operand:QI 2 "u5bit_cint_operand" "i,i,i")])))]
 
21472
   "VECTOR_MEM_VSX_P (<MODE>mode)"
 
21473
 {
 
21474
+  int fldDM;
 
21475
   gcc_assert (UINTVAL (operands[2]) <= 1);
 
21476
-  operands[3] = GEN_INT (INTVAL (operands[2]) << 1);
 
21477
+  fldDM = INTVAL (operands[2]) << 1;
 
21478
+  if (!BYTES_BIG_ENDIAN)
 
21479
+    fldDM = 3 - fldDM;
 
21480
+  operands[3] = GEN_INT (fldDM);
 
21481
   return \"xxpermdi %x0,%x1,%x1,%3\";
 
21482
 }
 
21483
   [(set_attr "type" "vecperm")])
 
21484
@@ -1149,9 +1533,28 @@
 
21485
         (parallel [(const_int 0)])))]
 
21486
   "VECTOR_MEM_VSX_P (<MODE>mode) && WORDS_BIG_ENDIAN"
 
21487
   "lxsd%U1x %x0,%y1"
 
21488
-  [(set_attr "type" "fpload")
 
21489
+  [(set (attr "type")
 
21490
+      (if_then_else
 
21491
+       (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
21492
+       (const_string "fpload_ux")
 
21493
+       (const_string "fpload")))
 
21494
    (set_attr "length" "4")])  
 
21495
 
 
21496
+;; Optimize extracting element 1 from memory for little endian
 
21497
+(define_insn "*vsx_extract_<mode>_one_le"
 
21498
+  [(set (match_operand:<VS_scalar> 0 "vsx_register_operand" "=ws,d,?wa")
 
21499
+       (vec_select:<VS_scalar>
 
21500
+        (match_operand:VSX_D 1 "indexed_or_indirect_operand" "Z,Z,Z")
 
21501
+        (parallel [(const_int 1)])))]
 
21502
+  "VECTOR_MEM_VSX_P (<MODE>mode) && !WORDS_BIG_ENDIAN"
 
21503
+  "lxsd%U1x %x0,%y1"
 
21504
+  [(set (attr "type")
 
21505
+      (if_then_else
 
21506
+       (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
21507
+       (const_string "fpload_ux")
 
21508
+       (const_string "fpload")))
 
21509
+   (set_attr "length" "4")])  
 
21510
+
 
21511
 ;; Extract a SF element from V4SF
 
21512
 (define_insn_and_split "vsx_extract_v4sf"
 
21513
   [(set (match_operand:SF 0 "vsx_register_operand" "=f,f")
 
21514
@@ -1172,7 +1575,7 @@
 
21515
   rtx op2 = operands[2];
 
21516
   rtx op3 = operands[3];
 
21517
   rtx tmp;
 
21518
-  HOST_WIDE_INT ele = INTVAL (op2);
 
21519
+  HOST_WIDE_INT ele = BYTES_BIG_ENDIAN ? INTVAL (op2) : 3 - INTVAL (op2);
 
21520
 
 
21521
   if (ele == 0)
 
21522
     tmp = op1;
 
21523
@@ -1213,8 +1616,8 @@
 
21524
       if (<MODE>mode != V2DImode)
 
21525
        {
 
21526
          target = gen_lowpart (V2DImode, target);
 
21527
-         op0 = gen_lowpart (V2DImode, target);
 
21528
-         op1 = gen_lowpart (V2DImode, target);
 
21529
+         op0 = gen_lowpart (V2DImode, op0);
 
21530
+         op1 = gen_lowpart (V2DImode, op1);
 
21531
        }
 
21532
     }
 
21533
   emit_insn (gen (target, op0, op1, perm0, perm1));
 
21534
@@ -1483,3 +1886,27 @@
 
21535
 }"
 
21536
   [(set_attr "length" "20")
 
21537
    (set_attr "type" "veccomplex")])
 
21538
+
 
21539
+
 
21540
+;; Power8 Vector fusion.  The fused ops must be physically adjacent.
 
21541
+(define_peephole
 
21542
+  [(set (match_operand:P 0 "base_reg_operand" "")
 
21543
+       (match_operand:P 1 "short_cint_operand" ""))
 
21544
+   (set (match_operand:VSX_M2 2 "vsx_register_operand" "")
 
21545
+       (mem:VSX_M2 (plus:P (match_dup 0)
 
21546
+                           (match_operand:P 3 "int_reg_operand" ""))))]
 
21547
+  "TARGET_VSX && TARGET_P8_FUSION"
 
21548
+  "li %0,%1\t\t\t# vector load fusion\;lx<VSX_M2:VSm>x %x2,%0,%3"  
 
21549
+  [(set_attr "length" "8")
 
21550
+   (set_attr "type" "vecload")])
 
21551
+
 
21552
+(define_peephole
 
21553
+  [(set (match_operand:P 0 "base_reg_operand" "")
 
21554
+       (match_operand:P 1 "short_cint_operand" ""))
 
21555
+   (set (match_operand:VSX_M2 2 "vsx_register_operand" "")
 
21556
+       (mem:VSX_M2 (plus:P (match_operand:P 3 "int_reg_operand" "")
 
21557
+                           (match_dup 0))))]
 
21558
+  "TARGET_VSX && TARGET_P8_FUSION"
 
21559
+  "li %0,%1\t\t\t# vector load fusion\;lx<VSX_M2:VSm>x %x2,%0,%3"  
 
21560
+  [(set_attr "length" "8")
 
21561
+   (set_attr "type" "vecload")])
 
21562
--- a/src/gcc/config/rs6000/rs6000.h
 
21563
+++ b/src/gcc/config/rs6000/rs6000.h
 
21564
@@ -92,7 +92,7 @@
 
21565
 #ifdef HAVE_AS_POWER8
 
21566
 #define ASM_CPU_POWER8_SPEC "-mpower8"
 
21567
 #else
 
21568
-#define ASM_CPU_POWER8_SPEC "-mpower4 -maltivec"
 
21569
+#define ASM_CPU_POWER8_SPEC ASM_CPU_POWER7_SPEC
 
21570
 #endif
 
21571
 
 
21572
 #ifdef HAVE_AS_DCI
 
21573
@@ -164,6 +164,7 @@
 
21574
 %{mcpu=e6500: -me6500} \
 
21575
 %{maltivec: -maltivec} \
 
21576
 %{mvsx: -mvsx %{!maltivec: -maltivec} %{!mcpu*: %(asm_cpu_power7)}} \
 
21577
+%{mpower8-vector|mcrypto|mdirect-move|mhtm: %{!mcpu*: %(asm_cpu_power8)}} \
 
21578
 -many"
 
21579
 
 
21580
 #define CPP_DEFAULT_SPEC ""
 
21581
@@ -277,6 +278,21 @@
 
21582
 #define TARGET_POPCNTD 0
 
21583
 #endif
 
21584
 
 
21585
+/* Define the ISA 2.07 flags as 0 if the target assembler does not support the
 
21586
+   waitasecond instruction.  Allow -mpower8-fusion, since it does not add new
 
21587
+   instructions.  */
 
21588
+
 
21589
+#ifndef HAVE_AS_POWER8
 
21590
+#undef  TARGET_DIRECT_MOVE
 
21591
+#undef  TARGET_CRYPTO
 
21592
+#undef  TARGET_HTM
 
21593
+#undef  TARGET_P8_VECTOR
 
21594
+#define TARGET_DIRECT_MOVE 0
 
21595
+#define TARGET_CRYPTO 0
 
21596
+#define TARGET_HTM 0
 
21597
+#define TARGET_P8_VECTOR 0
 
21598
+#endif
 
21599
+
 
21600
 /* Define TARGET_LWSYNC_INSTRUCTION if the assembler knows about lwsync.  If
 
21601
    not, generate the lwsync code as an integer constant.  */
 
21602
 #ifdef HAVE_AS_LWSYNC
 
21603
@@ -386,6 +402,7 @@
 
21604
 #define TARGET_DEBUG_TARGET    (rs6000_debug & MASK_DEBUG_TARGET)
 
21605
 #define TARGET_DEBUG_BUILTIN   (rs6000_debug & MASK_DEBUG_BUILTIN)
 
21606
 
 
21607
+/* Describe the vector unit used for arithmetic operations.  */
 
21608
 extern enum rs6000_vector rs6000_vector_unit[];
 
21609
 
 
21610
 #define VECTOR_UNIT_NONE_P(MODE)                       \
 
21611
@@ -394,12 +411,25 @@
 
21612
 #define VECTOR_UNIT_VSX_P(MODE)                                \
 
21613
   (rs6000_vector_unit[(MODE)] == VECTOR_VSX)
 
21614
 
 
21615
+#define VECTOR_UNIT_P8_VECTOR_P(MODE)                  \
 
21616
+  (rs6000_vector_unit[(MODE)] == VECTOR_P8_VECTOR)
 
21617
+
 
21618
 #define VECTOR_UNIT_ALTIVEC_P(MODE)                    \
 
21619
   (rs6000_vector_unit[(MODE)] == VECTOR_ALTIVEC)
 
21620
 
 
21621
+#define VECTOR_UNIT_VSX_OR_P8_VECTOR_P(MODE)           \
 
21622
+  (IN_RANGE ((int)rs6000_vector_unit[(MODE)],          \
 
21623
+            (int)VECTOR_VSX,                           \
 
21624
+            (int)VECTOR_P8_VECTOR))
 
21625
+
 
21626
+/* VECTOR_UNIT_ALTIVEC_OR_VSX_P is used in places where we are using either
 
21627
+   altivec (VMX) or VSX vector instructions.  P8 vector support is upwards
 
21628
+   compatible, so allow it as well, rather than changing all of the uses of the
 
21629
+   macro.  */
 
21630
 #define VECTOR_UNIT_ALTIVEC_OR_VSX_P(MODE)             \
 
21631
-  (rs6000_vector_unit[(MODE)] == VECTOR_ALTIVEC        \
 
21632
-   || rs6000_vector_unit[(MODE)] == VECTOR_VSX)
 
21633
+  (IN_RANGE ((int)rs6000_vector_unit[(MODE)],          \
 
21634
+            (int)VECTOR_ALTIVEC,                       \
 
21635
+            (int)VECTOR_P8_VECTOR))
 
21636
 
 
21637
 /* Describe whether to use VSX loads or Altivec loads.  For now, just use the
 
21638
    same unit as the vector unit we are using, but we may want to migrate to
 
21639
@@ -412,12 +442,21 @@
 
21640
 #define VECTOR_MEM_VSX_P(MODE)                         \
 
21641
   (rs6000_vector_mem[(MODE)] == VECTOR_VSX)
 
21642
 
 
21643
+#define VECTOR_MEM_P8_VECTOR_P(MODE)                   \
 
21644
+  (rs6000_vector_mem[(MODE)] == VECTOR_VSX)
 
21645
+
 
21646
 #define VECTOR_MEM_ALTIVEC_P(MODE)                     \
 
21647
   (rs6000_vector_mem[(MODE)] == VECTOR_ALTIVEC)
 
21648
 
 
21649
+#define VECTOR_MEM_VSX_OR_P8_VECTOR_P(MODE)            \
 
21650
+  (IN_RANGE ((int)rs6000_vector_mem[(MODE)],           \
 
21651
+            (int)VECTOR_VSX,                           \
 
21652
+            (int)VECTOR_P8_VECTOR))
 
21653
+
 
21654
 #define VECTOR_MEM_ALTIVEC_OR_VSX_P(MODE)              \
 
21655
-  (rs6000_vector_mem[(MODE)] == VECTOR_ALTIVEC         \
 
21656
-   || rs6000_vector_mem[(MODE)] == VECTOR_VSX)
 
21657
+  (IN_RANGE ((int)rs6000_vector_mem[(MODE)],           \
 
21658
+            (int)VECTOR_ALTIVEC,                       \
 
21659
+            (int)VECTOR_P8_VECTOR))
 
21660
 
 
21661
 /* Return the alignment of a given vector type, which is set based on the
 
21662
    vector unit use.  VSX for instance can load 32 or 64 bit aligned words
 
21663
@@ -479,22 +518,41 @@
 
21664
 #define TARGET_FCTIDUZ TARGET_POPCNTD
 
21665
 #define TARGET_FCTIWUZ TARGET_POPCNTD
 
21666
 
 
21667
+#define TARGET_XSCVDPSPN       (TARGET_DIRECT_MOVE || TARGET_P8_VECTOR)
 
21668
+#define TARGET_XSCVSPDPN       (TARGET_DIRECT_MOVE || TARGET_P8_VECTOR)
 
21669
+
 
21670
+/* Byte/char syncs were added as phased in for ISA 2.06B, but are not present
 
21671
+   in power7, so conditionalize them on p8 features.  TImode syncs need quad
 
21672
+   memory support.  */
 
21673
+#define TARGET_SYNC_HI_QI      (TARGET_QUAD_MEMORY || TARGET_DIRECT_MOVE)
 
21674
+#define TARGET_SYNC_TI         TARGET_QUAD_MEMORY
 
21675
+
 
21676
+/* Power7 has both 32-bit load and store integer for the FPRs, so we don't need
 
21677
+   to allocate the SDmode stack slot to get the value into the proper location
 
21678
+   in the register.  */
 
21679
+#define TARGET_NO_SDMODE_STACK (TARGET_LFIWZX && TARGET_STFIWX && TARGET_DFP)
 
21680
+
 
21681
 /* In switching from using target_flags to using rs6000_isa_flags, the options
 
21682
    machinery creates OPTION_MASK_<xxx> instead of MASK_<xxx>.  For now map
 
21683
    OPTION_MASK_<xxx> back into MASK_<xxx>.  */
 
21684
 #define MASK_ALTIVEC                   OPTION_MASK_ALTIVEC
 
21685
 #define MASK_CMPB                      OPTION_MASK_CMPB
 
21686
+#define MASK_CRYPTO                    OPTION_MASK_CRYPTO
 
21687
 #define MASK_DFP                       OPTION_MASK_DFP
 
21688
+#define MASK_DIRECT_MOVE               OPTION_MASK_DIRECT_MOVE
 
21689
 #define MASK_DLMZB                     OPTION_MASK_DLMZB
 
21690
 #define MASK_EABI                      OPTION_MASK_EABI
 
21691
 #define MASK_FPRND                     OPTION_MASK_FPRND
 
21692
+#define MASK_P8_FUSION                 OPTION_MASK_P8_FUSION
 
21693
 #define MASK_HARD_FLOAT                        OPTION_MASK_HARD_FLOAT
 
21694
+#define MASK_HTM                       OPTION_MASK_HTM
 
21695
 #define MASK_ISEL                      OPTION_MASK_ISEL
 
21696
 #define MASK_MFCRF                     OPTION_MASK_MFCRF
 
21697
 #define MASK_MFPGPR                    OPTION_MASK_MFPGPR
 
21698
 #define MASK_MULHW                     OPTION_MASK_MULHW
 
21699
 #define MASK_MULTIPLE                  OPTION_MASK_MULTIPLE
 
21700
 #define MASK_NO_UPDATE                 OPTION_MASK_NO_UPDATE
 
21701
+#define MASK_P8_VECTOR                 OPTION_MASK_P8_VECTOR
 
21702
 #define MASK_POPCNTB                   OPTION_MASK_POPCNTB
 
21703
 #define MASK_POPCNTD                   OPTION_MASK_POPCNTD
 
21704
 #define MASK_PPC_GFXOPT                        OPTION_MASK_PPC_GFXOPT
 
21705
@@ -505,6 +563,7 @@
 
21706
 #define MASK_STRING                    OPTION_MASK_STRING
 
21707
 #define MASK_UPDATE                    OPTION_MASK_UPDATE
 
21708
 #define MASK_VSX                       OPTION_MASK_VSX
 
21709
+#define MASK_VSX_TIMODE                        OPTION_MASK_VSX_TIMODE
 
21710
 
 
21711
 #ifndef IN_LIBGCC2
 
21712
 #define MASK_POWERPC64                 OPTION_MASK_POWERPC64
 
21713
@@ -558,6 +617,25 @@
 
21714
                          || rs6000_cpu == PROCESSOR_PPC8548)
 
21715
 
 
21716
 
 
21717
+/* Whether SF/DF operations are supported on the E500.  */
 
21718
+#define TARGET_SF_SPE  (TARGET_HARD_FLOAT && TARGET_SINGLE_FLOAT       \
 
21719
+                        && !TARGET_FPRS)
 
21720
+
 
21721
+#define TARGET_DF_SPE  (TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT       \
 
21722
+                        && !TARGET_FPRS && TARGET_E500_DOUBLE)
 
21723
+
 
21724
+/* Whether SF/DF operations are supported by by the normal floating point unit
 
21725
+   (or the vector/scalar unit).  */
 
21726
+#define TARGET_SF_FPR  (TARGET_HARD_FLOAT && TARGET_FPRS               \
 
21727
+                        && TARGET_SINGLE_FLOAT)
 
21728
+
 
21729
+#define TARGET_DF_FPR  (TARGET_HARD_FLOAT && TARGET_FPRS               \
 
21730
+                        && TARGET_DOUBLE_FLOAT)
 
21731
+
 
21732
+/* Whether SF/DF operations are supported by any hardware.  */
 
21733
+#define TARGET_SF_INSN (TARGET_SF_FPR || TARGET_SF_SPE)
 
21734
+#define TARGET_DF_INSN (TARGET_DF_FPR || TARGET_DF_SPE)
 
21735
+
 
21736
 /* Which machine supports the various reciprocal estimate instructions.  */
 
21737
 #define TARGET_FRES    (TARGET_HARD_FLOAT && TARGET_PPC_GFXOPT \
 
21738
                         && TARGET_FPRS && TARGET_SINGLE_FLOAT)
 
21739
@@ -595,9 +673,6 @@
 
21740
 #define RS6000_RECIP_AUTO_RSQRTE_P(MODE) \
 
21741
   (rs6000_recip_bits[(int)(MODE)] & RS6000_RECIP_MASK_AUTO_RSQRTE)
 
21742
 
 
21743
-#define RS6000_RECIP_HIGH_PRECISION_P(MODE) \
 
21744
-  ((MODE) == SFmode || (MODE) == V4SFmode || TARGET_RECIP_PRECISION)
 
21745
-
 
21746
 /* The default CPU for TARGET_OPTION_OVERRIDE.  */
 
21747
 #define OPTION_TARGET_CPU_DEFAULT TARGET_CPU_DEFAULT
 
21748
 
 
21749
@@ -842,15 +917,17 @@
 
21750
    in inline functions.
 
21751
 
 
21752
    Another pseudo (not included in DWARF_FRAME_REGISTERS) is soft frame
 
21753
-   pointer, which is eventually eliminated in favor of SP or FP.  */
 
21754
+   pointer, which is eventually eliminated in favor of SP or FP.
 
21755
 
 
21756
-#define FIRST_PSEUDO_REGISTER 114
 
21757
+   The 3 HTM registers aren't also included in DWARF_FRAME_REGISTERS.  */
 
21758
 
 
21759
+#define FIRST_PSEUDO_REGISTER 117
 
21760
+
 
21761
 /* This must be included for pre gcc 3.0 glibc compatibility.  */
 
21762
 #define PRE_GCC3_DWARF_FRAME_REGISTERS 77
 
21763
 
 
21764
 /* Add 32 dwarf columns for synthetic SPE registers.  */
 
21765
-#define DWARF_FRAME_REGISTERS ((FIRST_PSEUDO_REGISTER - 1) + 32)
 
21766
+#define DWARF_FRAME_REGISTERS ((FIRST_PSEUDO_REGISTER - 4) + 32)
 
21767
 
 
21768
 /* The SPE has an additional 32 synthetic registers, with DWARF debug
 
21769
    info numbering for these registers starting at 1200.  While eh_frame
 
21770
@@ -866,7 +943,7 @@
 
21771
    We must map them here to avoid huge unwinder tables mostly consisting
 
21772
    of unused space.  */
 
21773
 #define DWARF_REG_TO_UNWIND_COLUMN(r) \
 
21774
-  ((r) > 1200 ? ((r) - 1200 + FIRST_PSEUDO_REGISTER - 1) : (r))
 
21775
+  ((r) > 1200 ? ((r) - 1200 + (DWARF_FRAME_REGISTERS - 32)) : (r))
 
21776
 
 
21777
 /* Use standard DWARF numbering for DWARF debugging information.  */
 
21778
 #define DBX_REGISTER_NUMBER(REGNO) rs6000_dbx_register_number (REGNO)
 
21779
@@ -906,7 +983,7 @@
 
21780
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
 
21781
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
 
21782
    1, 1                                                   \
 
21783
-   , 1, 1, 1                                       \
 
21784
+   , 1, 1, 1, 1, 1, 1                             \
 
21785
 }
 
21786
 
 
21787
 /* 1 for registers not available across function calls.
 
21788
@@ -926,7 +1003,7 @@
 
21789
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
 
21790
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
 
21791
    1, 1                                                   \
 
21792
-   , 1, 1, 1                                       \
 
21793
+   , 1, 1, 1, 1, 1, 1                             \
 
21794
 }
 
21795
 
 
21796
 /* Like `CALL_USED_REGISTERS' except this macro doesn't require that
 
21797
@@ -945,7 +1022,7 @@
 
21798
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
 
21799
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
 
21800
    0, 0                                                   \
 
21801
-   , 0, 0, 0                                       \
 
21802
+   , 0, 0, 0, 0, 0, 0                             \
 
21803
 }
 
21804
 
 
21805
 #define TOTAL_ALTIVEC_REGS     (LAST_ALTIVEC_REGNO - FIRST_ALTIVEC_REGNO + 1)
 
21806
@@ -984,6 +1061,9 @@
 
21807
        vrsave, vscr    (fixed)
 
21808
        spe_acc, spefscr (fixed)
 
21809
        sfp             (fixed)
 
21810
+       tfhar           (fixed)
 
21811
+       tfiar           (fixed)
 
21812
+       texasr          (fixed)
 
21813
 */
 
21814
 
 
21815
 #if FIXED_R2 == 1
 
21816
@@ -1004,7 +1084,9 @@
 
21817
 
 
21818
 #define REG_ALLOC_ORDER                                                \
 
21819
   {32,                                                         \
 
21820
-   45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34,             \
 
21821
+   /* move fr13 (ie 45) later, so if we need TFmode, it does */        \
 
21822
+   /* not use fr14 which is a saved register.  */              \
 
21823
+   44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 45,             \
 
21824
    33,                                                         \
 
21825
    63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51,         \
 
21826
    50, 49, 48, 47, 46,                                         \
 
21827
@@ -1023,7 +1105,7 @@
 
21828
    96, 95, 94, 93, 92, 91,                                     \
 
21829
    108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97,    \
 
21830
    109, 110,                                                   \
 
21831
-   111, 112, 113                                               \
 
21832
+   111, 112, 113, 114, 115, 116                                        \
 
21833
 }
 
21834
 
 
21835
 /* True if register is floating-point.  */
 
21836
@@ -1064,8 +1146,11 @@
 
21837
 #define VINT_REGNO_P(N) ALTIVEC_REGNO_P (N)
 
21838
 
 
21839
 /* Alternate name for any vector register supporting logical operations, no
 
21840
-   matter which instruction set(s) are available.  */
 
21841
-#define VLOGICAL_REGNO_P(N) VFLOAT_REGNO_P (N)
 
21842
+   matter which instruction set(s) are available.  Allow GPRs as well as the
 
21843
+   vector registers.  */
 
21844
+#define VLOGICAL_REGNO_P(N)                                            \
 
21845
+  (INT_REGNO_P (N) || ALTIVEC_REGNO_P (N)                              \
 
21846
+   || (TARGET_VSX && FP_REGNO_P (N)))                                  \
 
21847
 
 
21848
 /* Return number of consecutive hard regs needed starting at reg REGNO
 
21849
    to hold something of mode MODE.  */
 
21850
@@ -1125,28 +1210,32 @@
 
21851
 /* Value is 1 if it is a good idea to tie two pseudo registers
 
21852
    when one has mode MODE1 and one has mode MODE2.
 
21853
    If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2,
 
21854
-   for any hard reg, then this must be 0 for correct output.  */
 
21855
-#define MODES_TIEABLE_P(MODE1, MODE2) \
 
21856
-  (SCALAR_FLOAT_MODE_P (MODE1)                 \
 
21857
+   for any hard reg, then this must be 0 for correct output.
 
21858
+
 
21859
+   PTImode cannot tie with other modes because PTImode is restricted to even
 
21860
+   GPR registers, and TImode can go in any GPR as well as VSX registers (PR
 
21861
+   57744).  */
 
21862
+#define MODES_TIEABLE_P(MODE1, MODE2)          \
 
21863
+  ((MODE1) == PTImode                          \
 
21864
+   ? (MODE2) == PTImode                                \
 
21865
+   : (MODE2) == PTImode                                \
 
21866
+   ? 0                                         \
 
21867
+   : SCALAR_FLOAT_MODE_P (MODE1)               \
 
21868
    ? SCALAR_FLOAT_MODE_P (MODE2)               \
 
21869
    : SCALAR_FLOAT_MODE_P (MODE2)               \
 
21870
-   ? SCALAR_FLOAT_MODE_P (MODE1)               \
 
21871
+   ? 0                                         \
 
21872
    : GET_MODE_CLASS (MODE1) == MODE_CC         \
 
21873
    ? GET_MODE_CLASS (MODE2) == MODE_CC         \
 
21874
    : GET_MODE_CLASS (MODE2) == MODE_CC         \
 
21875
-   ? GET_MODE_CLASS (MODE1) == MODE_CC         \
 
21876
+   ? 0                                         \
 
21877
    : SPE_VECTOR_MODE (MODE1)                   \
 
21878
    ? SPE_VECTOR_MODE (MODE2)                   \
 
21879
    : SPE_VECTOR_MODE (MODE2)                   \
 
21880
-   ? SPE_VECTOR_MODE (MODE1)                   \
 
21881
-   : ALTIVEC_VECTOR_MODE (MODE1)               \
 
21882
-   ? ALTIVEC_VECTOR_MODE (MODE2)               \
 
21883
-   : ALTIVEC_VECTOR_MODE (MODE2)               \
 
21884
-   ? ALTIVEC_VECTOR_MODE (MODE1)               \
 
21885
+   ? 0                                         \
 
21886
    : ALTIVEC_OR_VSX_VECTOR_MODE (MODE1)                \
 
21887
    ? ALTIVEC_OR_VSX_VECTOR_MODE (MODE2)                \
 
21888
    : ALTIVEC_OR_VSX_VECTOR_MODE (MODE2)                \
 
21889
-   ? ALTIVEC_OR_VSX_VECTOR_MODE (MODE1)                \
 
21890
+   ? 0                                         \
 
21891
    : 1)
 
21892
 
 
21893
 /* Post-reload, we can't use any new AltiVec registers, as we already
 
21894
@@ -1240,6 +1329,7 @@
 
21895
   VSCR_REGS,
 
21896
   SPE_ACC_REGS,
 
21897
   SPEFSCR_REGS,
 
21898
+  SPR_REGS,
 
21899
   NON_SPECIAL_REGS,
 
21900
   LINK_REGS,
 
21901
   CTR_REGS,
 
21902
@@ -1270,6 +1360,7 @@
 
21903
   "VSCR_REGS",                                                         \
 
21904
   "SPE_ACC_REGS",                                                       \
 
21905
   "SPEFSCR_REGS",                                                       \
 
21906
+  "SPR_REGS",                                                          \
 
21907
   "NON_SPECIAL_REGS",                                                  \
 
21908
   "LINK_REGS",                                                         \
 
21909
   "CTR_REGS",                                                          \
 
21910
@@ -1299,6 +1390,7 @@
 
21911
   { 0x00000000, 0x00000000, 0x00000000, 0x00004000 }, /* VSCR_REGS */       \
 
21912
   { 0x00000000, 0x00000000, 0x00000000, 0x00008000 }, /* SPE_ACC_REGS */     \
 
21913
   { 0x00000000, 0x00000000, 0x00000000, 0x00010000 }, /* SPEFSCR_REGS */     \
 
21914
+  { 0x00000000, 0x00000000, 0x00000000, 0x00040000 }, /* SPR_REGS */     \
 
21915
   { 0xffffffff, 0xffffffff, 0x00000008, 0x00020000 }, /* NON_SPECIAL_REGS */ \
 
21916
   { 0x00000000, 0x00000000, 0x00000002, 0x00000000 }, /* LINK_REGS */       \
 
21917
   { 0x00000000, 0x00000000, 0x00000004, 0x00000000 }, /* CTR_REGS */        \
 
21918
@@ -1309,7 +1401,7 @@
 
21919
   { 0x00000000, 0x00000000, 0x00000ff0, 0x00000000 }, /* CR_REGS */         \
 
21920
   { 0xffffffff, 0x00000000, 0x00000ffe, 0x00020000 }, /* NON_FLOAT_REGS */   \
 
21921
   { 0x00000000, 0x00000000, 0x00001000, 0x00000000 }, /* CA_REGS */         \
 
21922
-  { 0xffffffff, 0xffffffff, 0xfffffffe, 0x0003ffff }  /* ALL_REGS */        \
 
21923
+  { 0xffffffff, 0xffffffff, 0xfffffffe, 0x0007ffff }  /* ALL_REGS */        \
 
21924
 }
 
21925
 
 
21926
 /* The same information, inverted:
 
21927
@@ -1337,7 +1429,18 @@
 
21928
   RS6000_CONSTRAINT_wa,                /* Any VSX register */
 
21929
   RS6000_CONSTRAINT_wd,                /* VSX register for V2DF */
 
21930
   RS6000_CONSTRAINT_wf,                /* VSX register for V4SF */
 
21931
+  RS6000_CONSTRAINT_wg,                /* FPR register for -mmfpgpr */
 
21932
+  RS6000_CONSTRAINT_wl,                /* FPR register for LFIWAX */
 
21933
+  RS6000_CONSTRAINT_wm,                /* VSX register for direct move */
 
21934
+  RS6000_CONSTRAINT_wr,                /* GPR register if 64-bit  */
 
21935
   RS6000_CONSTRAINT_ws,                /* VSX register for DF */
 
21936
+  RS6000_CONSTRAINT_wt,                /* VSX register for TImode */
 
21937
+  RS6000_CONSTRAINT_wu,                /* Altivec register for float load/stores.  */
 
21938
+  RS6000_CONSTRAINT_wv,                /* Altivec register for double load/stores.  */
 
21939
+  RS6000_CONSTRAINT_ww,                /* FP or VSX register for vsx float ops.  */
 
21940
+  RS6000_CONSTRAINT_wx,                /* FPR register for STFIWX */
 
21941
+  RS6000_CONSTRAINT_wy,                /* VSX register for SF */
 
21942
+  RS6000_CONSTRAINT_wz,                /* FPR register for LFIWZX */
 
21943
   RS6000_CONSTRAINT_MAX
 
21944
 };
 
21945
 
 
21946
@@ -1425,21 +1528,14 @@
 
21947
    arguments.  */
 
21948
 #define FRAME_GROWS_DOWNWARD (flag_stack_protect != 0 || flag_asan != 0)
 
21949
 
 
21950
-/* Size of the outgoing register save area */
 
21951
-#define RS6000_REG_SAVE ((DEFAULT_ABI == ABI_AIX                       \
 
21952
-                         || DEFAULT_ABI == ABI_DARWIN)                 \
 
21953
-                        ? (TARGET_64BIT ? 64 : 32)                     \
 
21954
-                        : 0)
 
21955
-
 
21956
 /* Size of the fixed area on the stack */
 
21957
 #define RS6000_SAVE_AREA \
 
21958
-  (((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN) ? 24 : 8)    \
 
21959
+  ((DEFAULT_ABI == ABI_V4 ? 8 : DEFAULT_ABI == ABI_ELFv2 ? 16 : 24)    \
 
21960
    << (TARGET_64BIT ? 1 : 0))
 
21961
 
 
21962
-/* MEM representing address to save the TOC register */
 
21963
-#define RS6000_SAVE_TOC gen_rtx_MEM (Pmode, \
 
21964
-                                    plus_constant (Pmode, stack_pointer_rtx, \
 
21965
-                                                   (TARGET_32BIT ? 20 : 40)))
 
21966
+/* Stack offset for toc save slot.  */
 
21967
+#define RS6000_TOC_SAVE_SLOT \
 
21968
+  ((DEFAULT_ABI == ABI_ELFv2 ? 12 : 20) << (TARGET_64BIT ? 1 : 0))
 
21969
 
 
21970
 /* Align an address */
 
21971
 #define RS6000_ALIGN(n,a) (((n) + (a) - 1) & ~((a) - 1))
 
21972
@@ -1489,7 +1585,7 @@
 
21973
 /* Define this if stack space is still allocated for a parameter passed
 
21974
    in a register.  The value is the number of bytes allocated to this
 
21975
    area.  */
 
21976
-#define REG_PARM_STACK_SPACE(FNDECL)   RS6000_REG_SAVE
 
21977
+#define REG_PARM_STACK_SPACE(FNDECL) rs6000_reg_parm_stack_space((FNDECL))
 
21978
 
 
21979
 /* Define this if the above stack space is to be considered part of the
 
21980
    space allocated by the caller.  */
 
21981
@@ -1522,7 +1618,7 @@
 
21982
    NONLOCAL needs twice Pmode to maintain both backchain and SP.  */
 
21983
 #define STACK_SAVEAREA_MODE(LEVEL)     \
 
21984
   (LEVEL == SAVE_FUNCTION ? VOIDmode   \
 
21985
-  : LEVEL == SAVE_NONLOCAL ? (TARGET_32BIT ? DImode : TImode) : Pmode)
 
21986
+  : LEVEL == SAVE_NONLOCAL ? (TARGET_32BIT ? DImode : PTImode) : Pmode)
 
21987
 
 
21988
 /* Minimum and maximum general purpose registers used to hold arguments.  */
 
21989
 #define GP_ARG_MIN_REG 3
 
21990
@@ -1533,9 +1629,8 @@
 
21991
 #define FP_ARG_MIN_REG 33
 
21992
 #define        FP_ARG_AIX_MAX_REG 45
 
21993
 #define        FP_ARG_V4_MAX_REG  40
 
21994
-#define        FP_ARG_MAX_REG ((DEFAULT_ABI == ABI_AIX                         \
 
21995
-                        || DEFAULT_ABI == ABI_DARWIN)                  \
 
21996
-                       ? FP_ARG_AIX_MAX_REG : FP_ARG_V4_MAX_REG)
 
21997
+#define        FP_ARG_MAX_REG (DEFAULT_ABI == ABI_V4                           \
 
21998
+                       ? FP_ARG_V4_MAX_REG : FP_ARG_AIX_MAX_REG)
 
21999
 #define FP_ARG_NUM_REG (FP_ARG_MAX_REG - FP_ARG_MIN_REG + 1)
 
22000
 
 
22001
 /* Minimum and maximum AltiVec registers used to hold arguments.  */
 
22002
@@ -1543,10 +1638,17 @@
 
22003
 #define ALTIVEC_ARG_MAX_REG (ALTIVEC_ARG_MIN_REG + 11)
 
22004
 #define ALTIVEC_ARG_NUM_REG (ALTIVEC_ARG_MAX_REG - ALTIVEC_ARG_MIN_REG + 1)
 
22005
 
 
22006
+/* Maximum number of registers per ELFv2 homogeneous aggregate argument.  */
 
22007
+#define AGGR_ARG_NUM_REG 8
 
22008
+
 
22009
 /* Return registers */
 
22010
 #define GP_ARG_RETURN GP_ARG_MIN_REG
 
22011
 #define FP_ARG_RETURN FP_ARG_MIN_REG
 
22012
 #define ALTIVEC_ARG_RETURN (FIRST_ALTIVEC_REGNO + 2)
 
22013
+#define FP_ARG_MAX_RETURN (DEFAULT_ABI != ABI_ELFv2 ? FP_ARG_RETURN    \
 
22014
+                          : (FP_ARG_RETURN + AGGR_ARG_NUM_REG - 1))
 
22015
+#define ALTIVEC_ARG_MAX_RETURN (DEFAULT_ABI != ABI_ELFv2 ? ALTIVEC_ARG_RETURN \
 
22016
+                               : (ALTIVEC_ARG_RETURN + AGGR_ARG_NUM_REG - 1))
 
22017
 
 
22018
 /* Flags for the call/call_value rtl operations set up by function_arg */
 
22019
 #define CALL_NORMAL            0x00000000      /* no special processing */
 
22020
@@ -1566,8 +1668,10 @@
 
22021
    On RS/6000, this is r3, fp1, and v2 (for AltiVec).  */
 
22022
 #define FUNCTION_VALUE_REGNO_P(N)                                      \
 
22023
   ((N) == GP_ARG_RETURN                                                        \
 
22024
-   || ((N) == FP_ARG_RETURN && TARGET_HARD_FLOAT && TARGET_FPRS)       \
 
22025
-   || ((N) == ALTIVEC_ARG_RETURN && TARGET_ALTIVEC && TARGET_ALTIVEC_ABI))
 
22026
+   || ((N) >= FP_ARG_RETURN && (N) <= FP_ARG_MAX_RETURN                        \
 
22027
+       && TARGET_HARD_FLOAT && TARGET_FPRS)                            \
 
22028
+   || ((N) >= ALTIVEC_ARG_RETURN && (N) <= ALTIVEC_ARG_MAX_RETURN      \
 
22029
+       && TARGET_ALTIVEC && TARGET_ALTIVEC_ABI))
 
22030
 
 
22031
 /* 1 if N is a possible register number for function argument passing.
 
22032
    On RS/6000, these are r3-r10 and fp1-fp13.
 
22033
@@ -1691,11 +1795,8 @@
 
22034
 /* Number of bytes into the frame return addresses can be found.  See
 
22035
    rs6000_stack_info in rs6000.c for more information on how the different
 
22036
    abi's store the return address.  */
 
22037
-#define RETURN_ADDRESS_OFFSET                                          \
 
22038
- ((DEFAULT_ABI == ABI_AIX                                              \
 
22039
-   || DEFAULT_ABI == ABI_DARWIN)       ? (TARGET_32BIT ? 8 : 16) :     \
 
22040
-  (DEFAULT_ABI == ABI_V4)              ? 4 :                           \
 
22041
-  (internal_error ("RETURN_ADDRESS_OFFSET not supported"), 0))
 
22042
+#define RETURN_ADDRESS_OFFSET \
 
22043
+  ((DEFAULT_ABI == ABI_V4 ? 4 : 8) << (TARGET_64BIT ? 1 : 0))
 
22044
 
 
22045
 /* The current return address is in link register (65).  The return address
 
22046
    of anything farther back is accessed normally at an offset of 8 from the
 
22047
@@ -2215,6 +2316,9 @@
 
22048
   &rs6000_reg_names[111][0],   /* spe_acc */                           \
 
22049
   &rs6000_reg_names[112][0],   /* spefscr */                           \
 
22050
   &rs6000_reg_names[113][0],   /* sfp  */                              \
 
22051
+  &rs6000_reg_names[114][0],   /* tfhar  */                            \
 
22052
+  &rs6000_reg_names[115][0],   /* tfiar  */                            \
 
22053
+  &rs6000_reg_names[116][0],   /* texasr  */                           \
 
22054
 }
 
22055
 
 
22056
 /* Table of additional register names to use in user input.  */
 
22057
@@ -2268,7 +2372,9 @@
 
22058
   {"vs48", 93}, {"vs49", 94}, {"vs50", 95}, {"vs51", 96},       \
 
22059
   {"vs52", 97}, {"vs53", 98}, {"vs54", 99}, {"vs55", 100},     \
 
22060
   {"vs56", 101},{"vs57", 102},{"vs58", 103},{"vs59", 104},      \
 
22061
-  {"vs60", 105},{"vs61", 106},{"vs62", 107},{"vs63", 108} }
 
22062
+  {"vs60", 105},{"vs61", 106},{"vs62", 107},{"vs63", 108},     \
 
22063
+  /* Transactional Memory Facility (HTM) Registers.  */                \
 
22064
+  {"tfhar",  114}, {"tfiar",  115}, {"texasr",  116} }
 
22065
 
 
22066
 /* This is how to output an element of a case-vector that is relative.  */
 
22067
 
 
22068
@@ -2357,7 +2463,12 @@
 
22069
 #define RS6000_BTC_ATTR_MASK   0x00000700      /* Mask of the attributes.  */
 
22070
 
 
22071
 /* Miscellaneous information.  */
 
22072
-#define RS6000_BTC_OVERLOADED  0x4000000       /* function is overloaded.  */
 
22073
+#define RS6000_BTC_SPR         0x01000000      /* function references SPRs.  */
 
22074
+#define RS6000_BTC_VOID                0x02000000      /* function has no return value.  */
 
22075
+#define RS6000_BTC_OVERLOADED  0x04000000      /* function is overloaded.  */
 
22076
+#define RS6000_BTC_32BIT       0x08000000      /* function references SPRs.  */
 
22077
+#define RS6000_BTC_64BIT       0x10000000      /* function references SPRs.  */
 
22078
+#define RS6000_BTC_MISC_MASK   0x1f000000      /* Mask of the misc info.  */
 
22079
 
 
22080
 /* Convenience macros to document the instruction type.  */
 
22081
 #define RS6000_BTC_MEM         RS6000_BTC_MISC /* load/store touches mem.  */
 
22082
@@ -2369,6 +2480,9 @@
 
22083
 #define RS6000_BTM_ALWAYS      0               /* Always enabled.  */
 
22084
 #define RS6000_BTM_ALTIVEC     MASK_ALTIVEC    /* VMX/altivec vectors.  */
 
22085
 #define RS6000_BTM_VSX         MASK_VSX        /* VSX (vector/scalar).  */
 
22086
+#define RS6000_BTM_P8_VECTOR   MASK_P8_VECTOR  /* ISA 2.07 vector.  */
 
22087
+#define RS6000_BTM_CRYPTO      MASK_CRYPTO     /* crypto funcs.  */
 
22088
+#define RS6000_BTM_HTM         MASK_HTM        /* hardware TM funcs.  */
 
22089
 #define RS6000_BTM_SPE         MASK_STRING     /* E500 */
 
22090
 #define RS6000_BTM_PAIRED      MASK_MULHW      /* 750CL paired insns.  */
 
22091
 #define RS6000_BTM_FRE         MASK_POPCNTB    /* FRE instruction.  */
 
22092
@@ -2380,10 +2494,13 @@
 
22093
 
 
22094
 #define RS6000_BTM_COMMON      (RS6000_BTM_ALTIVEC                     \
 
22095
                                 | RS6000_BTM_VSX                       \
 
22096
+                                | RS6000_BTM_P8_VECTOR                 \
 
22097
+                                | RS6000_BTM_CRYPTO                    \
 
22098
                                 | RS6000_BTM_FRE                       \
 
22099
                                 | RS6000_BTM_FRES                      \
 
22100
                                 | RS6000_BTM_FRSQRTE                   \
 
22101
                                 | RS6000_BTM_FRSQRTES                  \
 
22102
+                                | RS6000_BTM_HTM                       \
 
22103
                                 | RS6000_BTM_POPCNTD                   \
 
22104
                                 | RS6000_BTM_CELL)
 
22105
 
 
22106
@@ -2395,6 +2512,7 @@
 
22107
 #undef RS6000_BUILTIN_A
 
22108
 #undef RS6000_BUILTIN_D
 
22109
 #undef RS6000_BUILTIN_E
 
22110
+#undef RS6000_BUILTIN_H
 
22111
 #undef RS6000_BUILTIN_P
 
22112
 #undef RS6000_BUILTIN_Q
 
22113
 #undef RS6000_BUILTIN_S
 
22114
@@ -2406,6 +2524,7 @@
 
22115
 #define RS6000_BUILTIN_A(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
 
22116
 #define RS6000_BUILTIN_D(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
 
22117
 #define RS6000_BUILTIN_E(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
 
22118
+#define RS6000_BUILTIN_H(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
 
22119
 #define RS6000_BUILTIN_P(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
 
22120
 #define RS6000_BUILTIN_Q(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
 
22121
 #define RS6000_BUILTIN_S(ENUM, NAME, MASK, ATTR, ICODE) ENUM,
 
22122
@@ -2424,6 +2543,7 @@
 
22123
 #undef RS6000_BUILTIN_A
 
22124
 #undef RS6000_BUILTIN_D
 
22125
 #undef RS6000_BUILTIN_E
 
22126
+#undef RS6000_BUILTIN_H
 
22127
 #undef RS6000_BUILTIN_P
 
22128
 #undef RS6000_BUILTIN_Q
 
22129
 #undef RS6000_BUILTIN_S
 
22130
--- a/src/gcc/config/rs6000/altivec.md
 
22131
+++ b/src/gcc/config/rs6000/altivec.md
 
22132
@@ -41,15 +41,11 @@
 
22133
    UNSPEC_VMULOSB
 
22134
    UNSPEC_VMULOUH
 
22135
    UNSPEC_VMULOSH
 
22136
-   UNSPEC_VPKUHUM
 
22137
-   UNSPEC_VPKUWUM
 
22138
    UNSPEC_VPKPX
 
22139
-   UNSPEC_VPKSHSS
 
22140
-   UNSPEC_VPKSWSS
 
22141
-   UNSPEC_VPKUHUS
 
22142
-   UNSPEC_VPKSHUS
 
22143
-   UNSPEC_VPKUWUS
 
22144
-   UNSPEC_VPKSWUS
 
22145
+   UNSPEC_VPACK_SIGN_SIGN_SAT
 
22146
+   UNSPEC_VPACK_SIGN_UNS_SAT
 
22147
+   UNSPEC_VPACK_UNS_UNS_SAT
 
22148
+   UNSPEC_VPACK_UNS_UNS_MOD
 
22149
    UNSPEC_VSLV4SI
 
22150
    UNSPEC_VSLO
 
22151
    UNSPEC_VSR
 
22152
@@ -71,12 +67,10 @@
 
22153
    UNSPEC_VLOGEFP
 
22154
    UNSPEC_VEXPTEFP
 
22155
    UNSPEC_VLSDOI
 
22156
-   UNSPEC_VUPKHSB
 
22157
+   UNSPEC_VUNPACK_HI_SIGN
 
22158
+   UNSPEC_VUNPACK_LO_SIGN
 
22159
    UNSPEC_VUPKHPX
 
22160
-   UNSPEC_VUPKHSH
 
22161
-   UNSPEC_VUPKLSB
 
22162
    UNSPEC_VUPKLPX
 
22163
-   UNSPEC_VUPKLSH
 
22164
    UNSPEC_DST
 
22165
    UNSPEC_DSTT
 
22166
    UNSPEC_DSTST
 
22167
@@ -134,6 +128,7 @@
 
22168
    UNSPEC_VUPKLS_V4SF
 
22169
    UNSPEC_VUPKHU_V4SF
 
22170
    UNSPEC_VUPKLU_V4SF
 
22171
+   UNSPEC_VGBBD
 
22172
 ])
 
22173
 
 
22174
 (define_c_enum "unspecv"
 
22175
@@ -146,6 +141,8 @@
 
22176
 
 
22177
 ;; Vec int modes
 
22178
 (define_mode_iterator VI [V4SI V8HI V16QI])
 
22179
+;; Like VI, but add ISA 2.07 integer vector ops
 
22180
+(define_mode_iterator VI2 [V4SI V8HI V16QI V2DI])
 
22181
 ;; Short vec in modes
 
22182
 (define_mode_iterator VIshort [V8HI V16QI])
 
22183
 ;; Vec float modes
 
22184
@@ -159,9 +156,19 @@
 
22185
 ;; Like VM, except don't do TImode
 
22186
 (define_mode_iterator VM2 [V4SI V8HI V16QI V4SF V2DF V2DI])
 
22187
 
 
22188
-(define_mode_attr VI_char [(V4SI "w") (V8HI "h") (V16QI "b")])
 
22189
-(define_mode_attr VI_scalar [(V4SI "SI") (V8HI "HI") (V16QI "QI")])
 
22190
+(define_mode_attr VI_char [(V2DI "d") (V4SI "w") (V8HI "h") (V16QI "b")])
 
22191
+(define_mode_attr VI_scalar [(V2DI "DI") (V4SI "SI") (V8HI "HI") (V16QI "QI")])
 
22192
+(define_mode_attr VI_unit [(V16QI "VECTOR_UNIT_ALTIVEC_P (V16QImode)")
 
22193
+                          (V8HI "VECTOR_UNIT_ALTIVEC_P (V8HImode)")
 
22194
+                          (V4SI "VECTOR_UNIT_ALTIVEC_P (V4SImode)")
 
22195
+                          (V2DI "VECTOR_UNIT_P8_VECTOR_P (V2DImode)")])
 
22196
 
 
22197
+;; Vector pack/unpack
 
22198
+(define_mode_iterator VP [V2DI V4SI V8HI])
 
22199
+(define_mode_attr VP_small [(V2DI "V4SI") (V4SI "V8HI") (V8HI "V16QI")])
 
22200
+(define_mode_attr VP_small_lc [(V2DI "v4si") (V4SI "v8hi") (V8HI "v16qi")])
 
22201
+(define_mode_attr VU_char [(V2DI "w") (V4SI "h") (V8HI "b")])
 
22202
+
 
22203
 ;; Vector move instructions.
 
22204
 (define_insn "*altivec_mov<mode>"
 
22205
   [(set (match_operand:VM2 0 "nonimmediate_operand" "=Z,v,v,*Y,*r,*r,v,v")
 
22206
@@ -378,10 +385,10 @@
 
22207
 
 
22208
 ;; add
 
22209
 (define_insn "add<mode>3"
 
22210
-  [(set (match_operand:VI 0 "register_operand" "=v")
 
22211
-        (plus:VI (match_operand:VI 1 "register_operand" "v")
 
22212
-                 (match_operand:VI 2 "register_operand" "v")))]
 
22213
-  "TARGET_ALTIVEC"
 
22214
+  [(set (match_operand:VI2 0 "register_operand" "=v")
 
22215
+        (plus:VI2 (match_operand:VI2 1 "register_operand" "v")
 
22216
+                 (match_operand:VI2 2 "register_operand" "v")))]
 
22217
+  "<VI_unit>"
 
22218
   "vaddu<VI_char>m %0,%1,%2"
 
22219
   [(set_attr "type" "vecsimple")])
 
22220
 
 
22221
@@ -398,17 +405,17 @@
 
22222
         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
 
22223
                       (match_operand:V4SI 2 "register_operand" "v")]
 
22224
                     UNSPEC_VADDCUW))]
 
22225
-  "TARGET_ALTIVEC"
 
22226
+  "VECTOR_UNIT_ALTIVEC_P (V4SImode)"
 
22227
   "vaddcuw %0,%1,%2"
 
22228
   [(set_attr "type" "vecsimple")])
 
22229
 
 
22230
 (define_insn "altivec_vaddu<VI_char>s"
 
22231
   [(set (match_operand:VI 0 "register_operand" "=v")
 
22232
         (unspec:VI [(match_operand:VI 1 "register_operand" "v")
 
22233
-                    (match_operand:VI 2 "register_operand" "v")]
 
22234
+                   (match_operand:VI 2 "register_operand" "v")]
 
22235
                   UNSPEC_VADDU))
 
22236
    (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
 
22237
-  "TARGET_ALTIVEC"
 
22238
+  "<VI_unit>"
 
22239
   "vaddu<VI_char>s %0,%1,%2"
 
22240
   [(set_attr "type" "vecsimple")])
 
22241
 
 
22242
@@ -418,16 +425,16 @@
 
22243
                     (match_operand:VI 2 "register_operand" "v")]
 
22244
                   UNSPEC_VADDS))
 
22245
    (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
 
22246
-  "TARGET_ALTIVEC"
 
22247
+  "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
 
22248
   "vadds<VI_char>s %0,%1,%2"
 
22249
   [(set_attr "type" "vecsimple")])
 
22250
 
 
22251
 ;; sub
 
22252
 (define_insn "sub<mode>3"
 
22253
-  [(set (match_operand:VI 0 "register_operand" "=v")
 
22254
-        (minus:VI (match_operand:VI 1 "register_operand" "v")
 
22255
-                  (match_operand:VI 2 "register_operand" "v")))]
 
22256
-  "TARGET_ALTIVEC"
 
22257
+  [(set (match_operand:VI2 0 "register_operand" "=v")
 
22258
+        (minus:VI2 (match_operand:VI2 1 "register_operand" "v")
 
22259
+                  (match_operand:VI2 2 "register_operand" "v")))]
 
22260
+  "<VI_unit>"
 
22261
   "vsubu<VI_char>m %0,%1,%2"
 
22262
   [(set_attr "type" "vecsimple")])
 
22263
 
 
22264
@@ -444,7 +451,7 @@
 
22265
         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
 
22266
                       (match_operand:V4SI 2 "register_operand" "v")]
 
22267
                     UNSPEC_VSUBCUW))]
 
22268
-  "TARGET_ALTIVEC"
 
22269
+  "VECTOR_UNIT_ALTIVEC_P (V4SImode)"
 
22270
   "vsubcuw %0,%1,%2"
 
22271
   [(set_attr "type" "vecsimple")])
 
22272
 
 
22273
@@ -454,7 +461,7 @@
 
22274
                     (match_operand:VI 2 "register_operand" "v")]
 
22275
                   UNSPEC_VSUBU))
 
22276
    (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
 
22277
-  "TARGET_ALTIVEC"
 
22278
+  "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
 
22279
   "vsubu<VI_char>s %0,%1,%2"
 
22280
   [(set_attr "type" "vecsimple")])
 
22281
 
 
22282
@@ -464,7 +471,7 @@
 
22283
                     (match_operand:VI 2 "register_operand" "v")]
 
22284
                   UNSPEC_VSUBS))
 
22285
    (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
 
22286
-  "TARGET_ALTIVEC"
 
22287
+  "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
 
22288
   "vsubs<VI_char>s %0,%1,%2"
 
22289
   [(set_attr "type" "vecsimple")])
 
22290
 
 
22291
@@ -483,7 +490,7 @@
 
22292
         (unspec:VI [(match_operand:VI 1 "register_operand" "v")
 
22293
                     (match_operand:VI 2 "register_operand" "v")]
 
22294
                   UNSPEC_VAVGS))]
 
22295
-  "TARGET_ALTIVEC"
 
22296
+  "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
 
22297
   "vavgs<VI_char> %0,%1,%2"
 
22298
   [(set_attr "type" "vecsimple")])
 
22299
 
 
22300
@@ -492,31 +499,31 @@
 
22301
         (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
 
22302
                       (match_operand:V4SF 2 "register_operand" "v")] 
 
22303
                       UNSPEC_VCMPBFP))]
 
22304
-  "TARGET_ALTIVEC"
 
22305
+  "VECTOR_UNIT_ALTIVEC_P (V4SImode)"
 
22306
   "vcmpbfp %0,%1,%2"
 
22307
   [(set_attr "type" "veccmp")])
 
22308
 
 
22309
 (define_insn "*altivec_eq<mode>"
 
22310
-  [(set (match_operand:VI 0 "altivec_register_operand" "=v")
 
22311
-       (eq:VI (match_operand:VI 1 "altivec_register_operand" "v")
 
22312
-              (match_operand:VI 2 "altivec_register_operand" "v")))]
 
22313
-  "TARGET_ALTIVEC"
 
22314
+  [(set (match_operand:VI2 0 "altivec_register_operand" "=v")
 
22315
+       (eq:VI2 (match_operand:VI2 1 "altivec_register_operand" "v")
 
22316
+               (match_operand:VI2 2 "altivec_register_operand" "v")))]
 
22317
+  "<VI_unit>"
 
22318
   "vcmpequ<VI_char> %0,%1,%2"
 
22319
   [(set_attr "type" "veccmp")])
 
22320
 
 
22321
 (define_insn "*altivec_gt<mode>"
 
22322
-  [(set (match_operand:VI 0 "altivec_register_operand" "=v")
 
22323
-       (gt:VI (match_operand:VI 1 "altivec_register_operand" "v")
 
22324
-              (match_operand:VI 2 "altivec_register_operand" "v")))]
 
22325
-  "TARGET_ALTIVEC"
 
22326
+  [(set (match_operand:VI2 0 "altivec_register_operand" "=v")
 
22327
+       (gt:VI2 (match_operand:VI2 1 "altivec_register_operand" "v")
 
22328
+               (match_operand:VI2 2 "altivec_register_operand" "v")))]
 
22329
+  "<VI_unit>"
 
22330
   "vcmpgts<VI_char> %0,%1,%2"
 
22331
   [(set_attr "type" "veccmp")])
 
22332
 
 
22333
 (define_insn "*altivec_gtu<mode>"
 
22334
-  [(set (match_operand:VI 0 "altivec_register_operand" "=v")
 
22335
-       (gtu:VI (match_operand:VI 1 "altivec_register_operand" "v")
 
22336
-               (match_operand:VI 2 "altivec_register_operand" "v")))]
 
22337
-  "TARGET_ALTIVEC"
 
22338
+  [(set (match_operand:VI2 0 "altivec_register_operand" "=v")
 
22339
+       (gtu:VI2 (match_operand:VI2 1 "altivec_register_operand" "v")
 
22340
+                (match_operand:VI2 2 "altivec_register_operand" "v")))]
 
22341
+  "<VI_unit>"
 
22342
   "vcmpgtu<VI_char> %0,%1,%2"
 
22343
   [(set_attr "type" "veccmp")])
 
22344
 
 
22345
@@ -642,7 +649,7 @@
 
22346
    convert_move (small_swap, swap, 0);
 
22347
  
 
22348
    low_product = gen_reg_rtx (V4SImode);
 
22349
-   emit_insn (gen_vec_widen_umult_odd_v8hi (low_product, one, two));
 
22350
+   emit_insn (gen_altivec_vmulouh (low_product, one, two));
 
22351
  
 
22352
    high_product = gen_reg_rtx (V4SImode);
 
22353
    emit_insn (gen_altivec_vmsumuhm (high_product, one, small_swap, zero));
 
22354
@@ -669,11 +676,19 @@
 
22355
    emit_insn (gen_vec_widen_smult_even_v8hi (even, operands[1], operands[2]));
 
22356
    emit_insn (gen_vec_widen_smult_odd_v8hi (odd, operands[1], operands[2]));
 
22357
 
 
22358
-   emit_insn (gen_altivec_vmrghw (high, even, odd));
 
22359
-   emit_insn (gen_altivec_vmrglw (low, even, odd));
 
22360
+   if (BYTES_BIG_ENDIAN)
 
22361
+     {
 
22362
+       emit_insn (gen_altivec_vmrghw (high, even, odd));
 
22363
+       emit_insn (gen_altivec_vmrglw (low, even, odd));
 
22364
+       emit_insn (gen_altivec_vpkuwum (operands[0], high, low));
 
22365
+     }
 
22366
+   else
 
22367
+     {
 
22368
+       emit_insn (gen_altivec_vmrghw (high, odd, even));
 
22369
+       emit_insn (gen_altivec_vmrglw (low, odd, even));
 
22370
+       emit_insn (gen_altivec_vpkuwum (operands[0], low, high));
 
22371
+     } 
 
22372
 
 
22373
-   emit_insn (gen_altivec_vpkuwum (operands[0], high, low));
 
22374
-
 
22375
    DONE;
 
22376
 }")
 
22377
 
 
22378
@@ -744,18 +759,18 @@
 
22379
 ;; max
 
22380
 
 
22381
 (define_insn "umax<mode>3"
 
22382
-  [(set (match_operand:VI 0 "register_operand" "=v")
 
22383
-        (umax:VI (match_operand:VI 1 "register_operand" "v")
 
22384
-                 (match_operand:VI 2 "register_operand" "v")))]
 
22385
-  "TARGET_ALTIVEC"
 
22386
+  [(set (match_operand:VI2 0 "register_operand" "=v")
 
22387
+        (umax:VI2 (match_operand:VI2 1 "register_operand" "v")
 
22388
+                 (match_operand:VI2 2 "register_operand" "v")))]
 
22389
+  "<VI_unit>"
 
22390
   "vmaxu<VI_char> %0,%1,%2"
 
22391
   [(set_attr "type" "vecsimple")])
 
22392
 
 
22393
 (define_insn "smax<mode>3"
 
22394
-  [(set (match_operand:VI 0 "register_operand" "=v")
 
22395
-        (smax:VI (match_operand:VI 1 "register_operand" "v")
 
22396
-                 (match_operand:VI 2 "register_operand" "v")))]
 
22397
-  "TARGET_ALTIVEC"
 
22398
+  [(set (match_operand:VI2 0 "register_operand" "=v")
 
22399
+        (smax:VI2 (match_operand:VI2 1 "register_operand" "v")
 
22400
+                 (match_operand:VI2 2 "register_operand" "v")))]
 
22401
+  "<VI_unit>"
 
22402
   "vmaxs<VI_char> %0,%1,%2"
 
22403
   [(set_attr "type" "vecsimple")])
 
22404
 
 
22405
@@ -768,18 +783,18 @@
 
22406
   [(set_attr "type" "veccmp")])
 
22407
 
 
22408
 (define_insn "umin<mode>3"
 
22409
-  [(set (match_operand:VI 0 "register_operand" "=v")
 
22410
-        (umin:VI (match_operand:VI 1 "register_operand" "v")
 
22411
-                 (match_operand:VI 2 "register_operand" "v")))]
 
22412
-  "TARGET_ALTIVEC"
 
22413
+  [(set (match_operand:VI2 0 "register_operand" "=v")
 
22414
+        (umin:VI2 (match_operand:VI2 1 "register_operand" "v")
 
22415
+                 (match_operand:VI2 2 "register_operand" "v")))]
 
22416
+  "<VI_unit>"
 
22417
   "vminu<VI_char> %0,%1,%2"
 
22418
   [(set_attr "type" "vecsimple")])
 
22419
 
 
22420
 (define_insn "smin<mode>3"
 
22421
-  [(set (match_operand:VI 0 "register_operand" "=v")
 
22422
-        (smin:VI (match_operand:VI 1 "register_operand" "v")
 
22423
-                 (match_operand:VI 2 "register_operand" "v")))]
 
22424
-  "TARGET_ALTIVEC"
 
22425
+  [(set (match_operand:VI2 0 "register_operand" "=v")
 
22426
+        (smin:VI2 (match_operand:VI2 1 "register_operand" "v")
 
22427
+                 (match_operand:VI2 2 "register_operand" "v")))]
 
22428
+  "<VI_unit>"
 
22429
   "vmins<VI_char> %0,%1,%2"
 
22430
   [(set_attr "type" "vecsimple")])
 
22431
 
 
22432
@@ -935,7 +950,136 @@
 
22433
   "vmrglw %0,%1,%2"
 
22434
   [(set_attr "type" "vecperm")])
 
22435
 
 
22436
-(define_insn "vec_widen_umult_even_v16qi"
 
22437
+;; Power8 vector merge even/odd
 
22438
+(define_insn "p8_vmrgew"
 
22439
+  [(set (match_operand:V4SI 0 "register_operand" "=v")
 
22440
+       (vec_select:V4SI
 
22441
+         (vec_concat:V8SI
 
22442
+           (match_operand:V4SI 1 "register_operand" "v")
 
22443
+           (match_operand:V4SI 2 "register_operand" "v"))
 
22444
+         (parallel [(const_int 0) (const_int 4)
 
22445
+                    (const_int 2) (const_int 6)])))]
 
22446
+  "TARGET_P8_VECTOR"
 
22447
+  "vmrgew %0,%1,%2"
 
22448
+  [(set_attr "type" "vecperm")])
 
22449
+
 
22450
+(define_insn "p8_vmrgow"
 
22451
+  [(set (match_operand:V4SI 0 "register_operand" "=v")
 
22452
+       (vec_select:V4SI
 
22453
+         (vec_concat:V8SI
 
22454
+           (match_operand:V4SI 1 "register_operand" "v")
 
22455
+           (match_operand:V4SI 2 "register_operand" "v"))
 
22456
+         (parallel [(const_int 1) (const_int 5)
 
22457
+                    (const_int 3) (const_int 7)])))]
 
22458
+  "TARGET_P8_VECTOR"
 
22459
+  "vmrgow %0,%1,%2"
 
22460
+  [(set_attr "type" "vecperm")])
 
22461
+
 
22462
+(define_expand "vec_widen_umult_even_v16qi"
 
22463
+  [(use (match_operand:V8HI 0 "register_operand" ""))
 
22464
+   (use (match_operand:V16QI 1 "register_operand" ""))
 
22465
+   (use (match_operand:V16QI 2 "register_operand" ""))]
 
22466
+  "TARGET_ALTIVEC"
 
22467
+{
 
22468
+  if (BYTES_BIG_ENDIAN)
 
22469
+    emit_insn (gen_altivec_vmuleub (operands[0], operands[1], operands[2]));
 
22470
+  else
 
22471
+    emit_insn (gen_altivec_vmuloub (operands[0], operands[1], operands[2]));
 
22472
+  DONE;
 
22473
+})
 
22474
+
 
22475
+(define_expand "vec_widen_smult_even_v16qi"
 
22476
+  [(use (match_operand:V8HI 0 "register_operand" ""))
 
22477
+   (use (match_operand:V16QI 1 "register_operand" ""))
 
22478
+   (use (match_operand:V16QI 2 "register_operand" ""))]
 
22479
+  "TARGET_ALTIVEC"
 
22480
+{
 
22481
+  if (BYTES_BIG_ENDIAN)
 
22482
+    emit_insn (gen_altivec_vmulesb (operands[0], operands[1], operands[2]));
 
22483
+  else
 
22484
+    emit_insn (gen_altivec_vmulosb (operands[0], operands[1], operands[2]));
 
22485
+  DONE;
 
22486
+})
 
22487
+
 
22488
+(define_expand "vec_widen_umult_even_v8hi"
 
22489
+  [(use (match_operand:V4SI 0 "register_operand" ""))
 
22490
+   (use (match_operand:V8HI 1 "register_operand" ""))
 
22491
+   (use (match_operand:V8HI 2 "register_operand" ""))]
 
22492
+  "TARGET_ALTIVEC"
 
22493
+{
 
22494
+  if (BYTES_BIG_ENDIAN)
 
22495
+    emit_insn (gen_altivec_vmuleuh (operands[0], operands[1], operands[2]));
 
22496
+  else
 
22497
+    emit_insn (gen_altivec_vmulouh (operands[0], operands[1], operands[2]));
 
22498
+  DONE;
 
22499
+})
 
22500
+
 
22501
+(define_expand "vec_widen_smult_even_v8hi"
 
22502
+  [(use (match_operand:V4SI 0 "register_operand" ""))
 
22503
+   (use (match_operand:V8HI 1 "register_operand" ""))
 
22504
+   (use (match_operand:V8HI 2 "register_operand" ""))]
 
22505
+  "TARGET_ALTIVEC"
 
22506
+{
 
22507
+  if (BYTES_BIG_ENDIAN)
 
22508
+    emit_insn (gen_altivec_vmulesh (operands[0], operands[1], operands[2]));
 
22509
+  else
 
22510
+    emit_insn (gen_altivec_vmulosh (operands[0], operands[1], operands[2]));
 
22511
+  DONE;
 
22512
+})
 
22513
+
 
22514
+(define_expand "vec_widen_umult_odd_v16qi"
 
22515
+  [(use (match_operand:V8HI 0 "register_operand" ""))
 
22516
+   (use (match_operand:V16QI 1 "register_operand" ""))
 
22517
+   (use (match_operand:V16QI 2 "register_operand" ""))]
 
22518
+  "TARGET_ALTIVEC"
 
22519
+{
 
22520
+  if (BYTES_BIG_ENDIAN)
 
22521
+    emit_insn (gen_altivec_vmuloub (operands[0], operands[1], operands[2]));
 
22522
+  else
 
22523
+    emit_insn (gen_altivec_vmuleub (operands[0], operands[1], operands[2]));
 
22524
+  DONE;
 
22525
+})
 
22526
+
 
22527
+(define_expand "vec_widen_smult_odd_v16qi"
 
22528
+  [(use (match_operand:V8HI 0 "register_operand" ""))
 
22529
+   (use (match_operand:V16QI 1 "register_operand" ""))
 
22530
+   (use (match_operand:V16QI 2 "register_operand" ""))]
 
22531
+  "TARGET_ALTIVEC"
 
22532
+{
 
22533
+  if (BYTES_BIG_ENDIAN)
 
22534
+    emit_insn (gen_altivec_vmulosb (operands[0], operands[1], operands[2]));
 
22535
+  else
 
22536
+    emit_insn (gen_altivec_vmulesb (operands[0], operands[1], operands[2]));
 
22537
+  DONE;
 
22538
+})
 
22539
+
 
22540
+(define_expand "vec_widen_umult_odd_v8hi"
 
22541
+  [(use (match_operand:V4SI 0 "register_operand" ""))
 
22542
+   (use (match_operand:V8HI 1 "register_operand" ""))
 
22543
+   (use (match_operand:V8HI 2 "register_operand" ""))]
 
22544
+  "TARGET_ALTIVEC"
 
22545
+{
 
22546
+  if (BYTES_BIG_ENDIAN)
 
22547
+    emit_insn (gen_altivec_vmulouh (operands[0], operands[1], operands[2]));
 
22548
+  else
 
22549
+    emit_insn (gen_altivec_vmuleuh (operands[0], operands[1], operands[2]));
 
22550
+  DONE;
 
22551
+})
 
22552
+
 
22553
+(define_expand "vec_widen_smult_odd_v8hi"
 
22554
+  [(use (match_operand:V4SI 0 "register_operand" ""))
 
22555
+   (use (match_operand:V8HI 1 "register_operand" ""))
 
22556
+   (use (match_operand:V8HI 2 "register_operand" ""))]
 
22557
+  "TARGET_ALTIVEC"
 
22558
+{
 
22559
+  if (BYTES_BIG_ENDIAN)
 
22560
+    emit_insn (gen_altivec_vmulosh (operands[0], operands[1], operands[2]));
 
22561
+  else
 
22562
+    emit_insn (gen_altivec_vmulesh (operands[0], operands[1], operands[2]));
 
22563
+  DONE;
 
22564
+})
 
22565
+
 
22566
+(define_insn "altivec_vmuleub"
 
22567
   [(set (match_operand:V8HI 0 "register_operand" "=v")
 
22568
         (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
 
22569
                       (match_operand:V16QI 2 "register_operand" "v")]
 
22570
@@ -944,43 +1088,25 @@
 
22571
   "vmuleub %0,%1,%2"
 
22572
   [(set_attr "type" "veccomplex")])
 
22573
 
 
22574
-(define_insn "vec_widen_smult_even_v16qi"
 
22575
+(define_insn "altivec_vmuloub"
 
22576
   [(set (match_operand:V8HI 0 "register_operand" "=v")
 
22577
         (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
 
22578
                       (match_operand:V16QI 2 "register_operand" "v")]
 
22579
-                    UNSPEC_VMULESB))]
 
22580
+                    UNSPEC_VMULOUB))]
 
22581
   "TARGET_ALTIVEC"
 
22582
-  "vmulesb %0,%1,%2"
 
22583
+  "vmuloub %0,%1,%2"
 
22584
   [(set_attr "type" "veccomplex")])
 
22585
 
 
22586
-(define_insn "vec_widen_umult_even_v8hi"
 
22587
-  [(set (match_operand:V4SI 0 "register_operand" "=v")
 
22588
-        (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
 
22589
-                      (match_operand:V8HI 2 "register_operand" "v")]
 
22590
-                    UNSPEC_VMULEUH))]
 
22591
-  "TARGET_ALTIVEC"
 
22592
-  "vmuleuh %0,%1,%2"
 
22593
-  [(set_attr "type" "veccomplex")])
 
22594
-
 
22595
-(define_insn "vec_widen_smult_even_v8hi"
 
22596
-  [(set (match_operand:V4SI 0 "register_operand" "=v")
 
22597
-        (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
 
22598
-                      (match_operand:V8HI 2 "register_operand" "v")]
 
22599
-                    UNSPEC_VMULESH))]
 
22600
-  "TARGET_ALTIVEC"
 
22601
-  "vmulesh %0,%1,%2"
 
22602
-  [(set_attr "type" "veccomplex")])
 
22603
-
 
22604
-(define_insn "vec_widen_umult_odd_v16qi"
 
22605
+(define_insn "altivec_vmulesb"
 
22606
   [(set (match_operand:V8HI 0 "register_operand" "=v")
 
22607
         (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
 
22608
                       (match_operand:V16QI 2 "register_operand" "v")]
 
22609
-                    UNSPEC_VMULOUB))]
 
22610
+                    UNSPEC_VMULESB))]
 
22611
   "TARGET_ALTIVEC"
 
22612
-  "vmuloub %0,%1,%2"
 
22613
+  "vmulesb %0,%1,%2"
 
22614
   [(set_attr "type" "veccomplex")])
 
22615
 
 
22616
-(define_insn "vec_widen_smult_odd_v16qi"
 
22617
+(define_insn "altivec_vmulosb"
 
22618
   [(set (match_operand:V8HI 0 "register_operand" "=v")
 
22619
         (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
 
22620
                       (match_operand:V16QI 2 "register_operand" "v")]
 
22621
@@ -989,167 +1115,124 @@
 
22622
   "vmulosb %0,%1,%2"
 
22623
   [(set_attr "type" "veccomplex")])
 
22624
 
 
22625
-(define_insn "vec_widen_umult_odd_v8hi"
 
22626
+(define_insn "altivec_vmuleuh"
 
22627
   [(set (match_operand:V4SI 0 "register_operand" "=v")
 
22628
         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
 
22629
                       (match_operand:V8HI 2 "register_operand" "v")]
 
22630
+                    UNSPEC_VMULEUH))]
 
22631
+  "TARGET_ALTIVEC"
 
22632
+  "vmuleuh %0,%1,%2"
 
22633
+  [(set_attr "type" "veccomplex")])
 
22634
+
 
22635
+(define_insn "altivec_vmulouh"
 
22636
+  [(set (match_operand:V4SI 0 "register_operand" "=v")
 
22637
+        (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
 
22638
+                      (match_operand:V8HI 2 "register_operand" "v")]
 
22639
                     UNSPEC_VMULOUH))]
 
22640
   "TARGET_ALTIVEC"
 
22641
   "vmulouh %0,%1,%2"
 
22642
   [(set_attr "type" "veccomplex")])
 
22643
 
 
22644
-(define_insn "vec_widen_smult_odd_v8hi"
 
22645
+(define_insn "altivec_vmulesh"
 
22646
   [(set (match_operand:V4SI 0 "register_operand" "=v")
 
22647
         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
 
22648
                       (match_operand:V8HI 2 "register_operand" "v")]
 
22649
+                    UNSPEC_VMULESH))]
 
22650
+  "TARGET_ALTIVEC"
 
22651
+  "vmulesh %0,%1,%2"
 
22652
+  [(set_attr "type" "veccomplex")])
 
22653
+
 
22654
+(define_insn "altivec_vmulosh"
 
22655
+  [(set (match_operand:V4SI 0 "register_operand" "=v")
 
22656
+        (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
 
22657
+                      (match_operand:V8HI 2 "register_operand" "v")]
 
22658
                     UNSPEC_VMULOSH))]
 
22659
   "TARGET_ALTIVEC"
 
22660
   "vmulosh %0,%1,%2"
 
22661
   [(set_attr "type" "veccomplex")])
 
22662
 
 
22663
 
 
22664
-;; logical ops.  Have the logical ops follow the memory ops in
 
22665
-;; terms of whether to prefer VSX or Altivec
 
22666
-
 
22667
-(define_insn "*altivec_and<mode>3"
 
22668
-  [(set (match_operand:VM 0 "register_operand" "=v")
 
22669
-        (and:VM (match_operand:VM 1 "register_operand" "v")
 
22670
-               (match_operand:VM 2 "register_operand" "v")))]
 
22671
-  "VECTOR_MEM_ALTIVEC_P (<MODE>mode)"
 
22672
-  "vand %0,%1,%2"
 
22673
-  [(set_attr "type" "vecsimple")])
 
22674
-
 
22675
-(define_insn "*altivec_ior<mode>3"
 
22676
-  [(set (match_operand:VM 0 "register_operand" "=v")
 
22677
-        (ior:VM (match_operand:VM 1 "register_operand" "v")
 
22678
-               (match_operand:VM 2 "register_operand" "v")))]
 
22679
-  "VECTOR_MEM_ALTIVEC_P (<MODE>mode)"
 
22680
-  "vor %0,%1,%2"
 
22681
-  [(set_attr "type" "vecsimple")])
 
22682
-
 
22683
-(define_insn "*altivec_xor<mode>3"
 
22684
-  [(set (match_operand:VM 0 "register_operand" "=v")
 
22685
-        (xor:VM (match_operand:VM 1 "register_operand" "v")
 
22686
-               (match_operand:VM 2 "register_operand" "v")))]
 
22687
-  "VECTOR_MEM_ALTIVEC_P (<MODE>mode)"
 
22688
-  "vxor %0,%1,%2"
 
22689
-  [(set_attr "type" "vecsimple")])
 
22690
-
 
22691
-(define_insn "*altivec_one_cmpl<mode>2"
 
22692
-  [(set (match_operand:VM 0 "register_operand" "=v")
 
22693
-        (not:VM (match_operand:VM 1 "register_operand" "v")))]
 
22694
-  "VECTOR_MEM_ALTIVEC_P (<MODE>mode)"
 
22695
-  "vnor %0,%1,%1"
 
22696
-  [(set_attr "type" "vecsimple")])
 
22697
-  
 
22698
-(define_insn "*altivec_nor<mode>3"
 
22699
-  [(set (match_operand:VM 0 "register_operand" "=v")
 
22700
-        (not:VM (ior:VM (match_operand:VM 1 "register_operand" "v")
 
22701
-                       (match_operand:VM 2 "register_operand" "v"))))]
 
22702
-  "VECTOR_MEM_ALTIVEC_P (<MODE>mode)"
 
22703
-  "vnor %0,%1,%2"
 
22704
-  [(set_attr "type" "vecsimple")])
 
22705
-
 
22706
-(define_insn "*altivec_andc<mode>3"
 
22707
-  [(set (match_operand:VM 0 "register_operand" "=v")
 
22708
-        (and:VM (not:VM (match_operand:VM 2 "register_operand" "v"))
 
22709
-               (match_operand:VM 1 "register_operand" "v")))]
 
22710
-  "VECTOR_MEM_ALTIVEC_P (<MODE>mode)"
 
22711
-  "vandc %0,%1,%2"
 
22712
-  [(set_attr "type" "vecsimple")])
 
22713
-
 
22714
-(define_insn "altivec_vpkuhum"
 
22715
-  [(set (match_operand:V16QI 0 "register_operand" "=v")
 
22716
-        (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
 
22717
-                       (match_operand:V8HI 2 "register_operand" "v")]
 
22718
-                     UNSPEC_VPKUHUM))]
 
22719
-  "TARGET_ALTIVEC"
 
22720
-  "vpkuhum %0,%1,%2"
 
22721
-  [(set_attr "type" "vecperm")])
 
22722
-
 
22723
-(define_insn "altivec_vpkuwum"
 
22724
-  [(set (match_operand:V8HI 0 "register_operand" "=v")
 
22725
-        (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
 
22726
-                      (match_operand:V4SI 2 "register_operand" "v")]
 
22727
-                    UNSPEC_VPKUWUM))]
 
22728
-  "TARGET_ALTIVEC"
 
22729
-  "vpkuwum %0,%1,%2"
 
22730
-  [(set_attr "type" "vecperm")])
 
22731
-
 
22732
+;; Vector pack/unpack
 
22733
 (define_insn "altivec_vpkpx"
 
22734
   [(set (match_operand:V8HI 0 "register_operand" "=v")
 
22735
         (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
 
22736
                       (match_operand:V4SI 2 "register_operand" "v")]
 
22737
                     UNSPEC_VPKPX))]
 
22738
   "TARGET_ALTIVEC"
 
22739
-  "vpkpx %0,%1,%2"
 
22740
+  "*
 
22741
+  {
 
22742
+    if (BYTES_BIG_ENDIAN)
 
22743
+      return \"vpkpx %0,%1,%2\";
 
22744
+    else
 
22745
+      return \"vpkpx %0,%2,%1\";
 
22746
+  }"
 
22747
   [(set_attr "type" "vecperm")])
 
22748
 
 
22749
-(define_insn "altivec_vpkshss"
 
22750
-  [(set (match_operand:V16QI 0 "register_operand" "=v")
 
22751
-        (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
 
22752
-                       (match_operand:V8HI 2 "register_operand" "v")]
 
22753
-                     UNSPEC_VPKSHSS))
 
22754
-   (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
 
22755
-  "TARGET_ALTIVEC"
 
22756
-  "vpkshss %0,%1,%2"
 
22757
+(define_insn "altivec_vpks<VI_char>ss"
 
22758
+  [(set (match_operand:<VP_small> 0 "register_operand" "=v")
 
22759
+       (unspec:<VP_small> [(match_operand:VP 1 "register_operand" "v")
 
22760
+                           (match_operand:VP 2 "register_operand" "v")]
 
22761
+                          UNSPEC_VPACK_SIGN_SIGN_SAT))]
 
22762
+  "<VI_unit>"
 
22763
+  "*
 
22764
+  {
 
22765
+    if (BYTES_BIG_ENDIAN)
 
22766
+      return \"vpks<VI_char>ss %0,%1,%2\";
 
22767
+    else
 
22768
+      return \"vpks<VI_char>ss %0,%2,%1\";
 
22769
+  }"
 
22770
   [(set_attr "type" "vecperm")])
 
22771
 
 
22772
-(define_insn "altivec_vpkswss"
 
22773
-  [(set (match_operand:V8HI 0 "register_operand" "=v")
 
22774
-        (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
 
22775
-                      (match_operand:V4SI 2 "register_operand" "v")]
 
22776
-                    UNSPEC_VPKSWSS))
 
22777
-   (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
 
22778
-  "TARGET_ALTIVEC"
 
22779
-  "vpkswss %0,%1,%2"
 
22780
+(define_insn "altivec_vpks<VI_char>us"
 
22781
+  [(set (match_operand:<VP_small> 0 "register_operand" "=v")
 
22782
+       (unspec:<VP_small> [(match_operand:VP 1 "register_operand" "v")
 
22783
+                           (match_operand:VP 2 "register_operand" "v")]
 
22784
+                          UNSPEC_VPACK_SIGN_UNS_SAT))]
 
22785
+  "<VI_unit>"
 
22786
+  "*
 
22787
+  {
 
22788
+    if (BYTES_BIG_ENDIAN)
 
22789
+      return \"vpks<VI_char>us %0,%1,%2\";
 
22790
+    else
 
22791
+      return \"vpks<VI_char>us %0,%2,%1\";
 
22792
+  }"
 
22793
   [(set_attr "type" "vecperm")])
 
22794
 
 
22795
-(define_insn "altivec_vpkuhus"
 
22796
-  [(set (match_operand:V16QI 0 "register_operand" "=v")
 
22797
-        (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
 
22798
-                       (match_operand:V8HI 2 "register_operand" "v")]
 
22799
-                     UNSPEC_VPKUHUS))
 
22800
-   (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
 
22801
-  "TARGET_ALTIVEC"
 
22802
-  "vpkuhus %0,%1,%2"
 
22803
+(define_insn "altivec_vpku<VI_char>us"
 
22804
+  [(set (match_operand:<VP_small> 0 "register_operand" "=v")
 
22805
+       (unspec:<VP_small> [(match_operand:VP 1 "register_operand" "v")
 
22806
+                           (match_operand:VP 2 "register_operand" "v")]
 
22807
+                          UNSPEC_VPACK_UNS_UNS_SAT))]
 
22808
+  "<VI_unit>"
 
22809
+  "*
 
22810
+  {
 
22811
+    if (BYTES_BIG_ENDIAN)
 
22812
+      return \"vpku<VI_char>us %0,%1,%2\";
 
22813
+    else
 
22814
+      return \"vpku<VI_char>us %0,%2,%1\";
 
22815
+  }"
 
22816
   [(set_attr "type" "vecperm")])
 
22817
 
 
22818
-(define_insn "altivec_vpkshus"
 
22819
-  [(set (match_operand:V16QI 0 "register_operand" "=v")
 
22820
-        (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
 
22821
-                       (match_operand:V8HI 2 "register_operand" "v")]
 
22822
-                     UNSPEC_VPKSHUS))
 
22823
-   (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
 
22824
-  "TARGET_ALTIVEC"
 
22825
-  "vpkshus %0,%1,%2"
 
22826
+(define_insn "altivec_vpku<VI_char>um"
 
22827
+  [(set (match_operand:<VP_small> 0 "register_operand" "=v")
 
22828
+       (unspec:<VP_small> [(match_operand:VP 1 "register_operand" "v")
 
22829
+                           (match_operand:VP 2 "register_operand" "v")]
 
22830
+                          UNSPEC_VPACK_UNS_UNS_MOD))]
 
22831
+  "<VI_unit>"
 
22832
+  "*
 
22833
+  {
 
22834
+    if (BYTES_BIG_ENDIAN)
 
22835
+      return \"vpku<VI_char>um %0,%1,%2\";
 
22836
+    else
 
22837
+      return \"vpku<VI_char>um %0,%2,%1\";
 
22838
+  }"
 
22839
   [(set_attr "type" "vecperm")])
 
22840
 
 
22841
-(define_insn "altivec_vpkuwus"
 
22842
-  [(set (match_operand:V8HI 0 "register_operand" "=v")
 
22843
-        (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
 
22844
-                      (match_operand:V4SI 2 "register_operand" "v")]
 
22845
-                    UNSPEC_VPKUWUS))
 
22846
-   (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
 
22847
-  "TARGET_ALTIVEC"
 
22848
-  "vpkuwus %0,%1,%2"
 
22849
-  [(set_attr "type" "vecperm")])
 
22850
-
 
22851
-(define_insn "altivec_vpkswus"
 
22852
-  [(set (match_operand:V8HI 0 "register_operand" "=v")
 
22853
-        (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
 
22854
-                      (match_operand:V4SI 2 "register_operand" "v")]
 
22855
-                    UNSPEC_VPKSWUS))
 
22856
-   (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
 
22857
-  "TARGET_ALTIVEC"
 
22858
-  "vpkswus %0,%1,%2"
 
22859
-  [(set_attr "type" "vecperm")])
 
22860
-
 
22861
 (define_insn "*altivec_vrl<VI_char>"
 
22862
-  [(set (match_operand:VI 0 "register_operand" "=v")
 
22863
-        (rotate:VI (match_operand:VI 1 "register_operand" "v")
 
22864
-                  (match_operand:VI 2 "register_operand" "v")))]
 
22865
-  "TARGET_ALTIVEC"
 
22866
+  [(set (match_operand:VI2 0 "register_operand" "=v")
 
22867
+        (rotate:VI2 (match_operand:VI2 1 "register_operand" "v")
 
22868
+                   (match_operand:VI2 2 "register_operand" "v")))]
 
22869
+  "<VI_unit>"
 
22870
   "vrl<VI_char> %0,%1,%2"
 
22871
   [(set_attr "type" "vecsimple")])
 
22872
 
 
22873
@@ -1172,26 +1255,26 @@
 
22874
   [(set_attr "type" "vecperm")])
 
22875
 
 
22876
 (define_insn "*altivec_vsl<VI_char>"
 
22877
-  [(set (match_operand:VI 0 "register_operand" "=v")
 
22878
-        (ashift:VI (match_operand:VI 1 "register_operand" "v")
 
22879
-                  (match_operand:VI 2 "register_operand" "v")))]
 
22880
-  "TARGET_ALTIVEC"
 
22881
+  [(set (match_operand:VI2 0 "register_operand" "=v")
 
22882
+        (ashift:VI2 (match_operand:VI2 1 "register_operand" "v")
 
22883
+                   (match_operand:VI2 2 "register_operand" "v")))]
 
22884
+  "<VI_unit>"
 
22885
   "vsl<VI_char> %0,%1,%2"
 
22886
   [(set_attr "type" "vecsimple")])
 
22887
 
 
22888
 (define_insn "*altivec_vsr<VI_char>"
 
22889
-  [(set (match_operand:VI 0 "register_operand" "=v")
 
22890
-        (lshiftrt:VI (match_operand:VI 1 "register_operand" "v")
 
22891
-                    (match_operand:VI 2 "register_operand" "v")))]
 
22892
-  "TARGET_ALTIVEC"
 
22893
+  [(set (match_operand:VI2 0 "register_operand" "=v")
 
22894
+        (lshiftrt:VI2 (match_operand:VI2 1 "register_operand" "v")
 
22895
+                     (match_operand:VI2 2 "register_operand" "v")))]
 
22896
+  "<VI_unit>"
 
22897
   "vsr<VI_char> %0,%1,%2"
 
22898
   [(set_attr "type" "vecsimple")])
 
22899
 
 
22900
 (define_insn "*altivec_vsra<VI_char>"
 
22901
-  [(set (match_operand:VI 0 "register_operand" "=v")
 
22902
-        (ashiftrt:VI (match_operand:VI 1 "register_operand" "v")
 
22903
-                    (match_operand:VI 2 "register_operand" "v")))]
 
22904
-  "TARGET_ALTIVEC"
 
22905
+  [(set (match_operand:VI2 0 "register_operand" "=v")
 
22906
+        (ashiftrt:VI2 (match_operand:VI2 1 "register_operand" "v")
 
22907
+                     (match_operand:VI2 2 "register_operand" "v")))]
 
22908
+  "<VI_unit>"
 
22909
   "vsra<VI_char> %0,%1,%2"
 
22910
   [(set_attr "type" "vecsimple")])
 
22911
 
 
22912
@@ -1335,7 +1418,12 @@
 
22913
                       (match_operand:V16QI 3 "register_operand" "")]
 
22914
                      UNSPEC_VPERM))]
 
22915
   "TARGET_ALTIVEC"
 
22916
-  "")
 
22917
+{
 
22918
+  if (!BYTES_BIG_ENDIAN) {
 
22919
+    altivec_expand_vec_perm_le (operands);
 
22920
+    DONE;
 
22921
+  }
 
22922
+})
 
22923
 
 
22924
 (define_expand "vec_perm_constv16qi"
 
22925
   [(match_operand:V16QI 0 "register_operand" "")
 
22926
@@ -1476,14 +1564,22 @@
 
22927
   "vsldoi %0,%1,%2,%3"
 
22928
   [(set_attr "type" "vecperm")])
 
22929
 
 
22930
-(define_insn "altivec_vupkhsb"
 
22931
-  [(set (match_operand:V8HI 0 "register_operand" "=v")
 
22932
-       (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
 
22933
-                    UNSPEC_VUPKHSB))]
 
22934
-  "TARGET_ALTIVEC"
 
22935
-  "vupkhsb %0,%1"
 
22936
+(define_insn "altivec_vupkhs<VU_char>"
 
22937
+  [(set (match_operand:VP 0 "register_operand" "=v")
 
22938
+       (unspec:VP [(match_operand:<VP_small> 1 "register_operand" "v")]
 
22939
+                    UNSPEC_VUNPACK_HI_SIGN))]
 
22940
+  "<VI_unit>"
 
22941
+  "vupkhs<VU_char> %0,%1"
 
22942
   [(set_attr "type" "vecperm")])
 
22943
 
 
22944
+(define_insn "altivec_vupkls<VU_char>"
 
22945
+  [(set (match_operand:VP 0 "register_operand" "=v")
 
22946
+       (unspec:VP [(match_operand:<VP_small> 1 "register_operand" "v")]
 
22947
+                    UNSPEC_VUNPACK_LO_SIGN))]
 
22948
+  "<VI_unit>"
 
22949
+  "vupkls<VU_char> %0,%1"
 
22950
+  [(set_attr "type" "vecperm")])
 
22951
+
 
22952
 (define_insn "altivec_vupkhpx"
 
22953
   [(set (match_operand:V4SI 0 "register_operand" "=v")
 
22954
        (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
 
22955
@@ -1492,22 +1588,6 @@
 
22956
   "vupkhpx %0,%1"
 
22957
   [(set_attr "type" "vecperm")])
 
22958
 
 
22959
-(define_insn "altivec_vupkhsh"
 
22960
-  [(set (match_operand:V4SI 0 "register_operand" "=v")
 
22961
-       (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
 
22962
-                    UNSPEC_VUPKHSH))]
 
22963
-  "TARGET_ALTIVEC"
 
22964
-  "vupkhsh %0,%1"
 
22965
-  [(set_attr "type" "vecperm")])
 
22966
-
 
22967
-(define_insn "altivec_vupklsb"
 
22968
-  [(set (match_operand:V8HI 0 "register_operand" "=v")
 
22969
-       (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
 
22970
-                    UNSPEC_VUPKLSB))]
 
22971
-  "TARGET_ALTIVEC"
 
22972
-  "vupklsb %0,%1"
 
22973
-  [(set_attr "type" "vecperm")])
 
22974
-
 
22975
 (define_insn "altivec_vupklpx"
 
22976
   [(set (match_operand:V4SI 0 "register_operand" "=v")
 
22977
        (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
 
22978
@@ -1516,49 +1596,41 @@
 
22979
   "vupklpx %0,%1"
 
22980
   [(set_attr "type" "vecperm")])
 
22981
 
 
22982
-(define_insn "altivec_vupklsh"
 
22983
-  [(set (match_operand:V4SI 0 "register_operand" "=v")
 
22984
-       (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
 
22985
-                    UNSPEC_VUPKLSH))]
 
22986
-  "TARGET_ALTIVEC"
 
22987
-  "vupklsh %0,%1"
 
22988
-  [(set_attr "type" "vecperm")])
 
22989
-
 
22990
 ;; Compare vectors producing a vector result and a predicate, setting CR6 to
 
22991
 ;; indicate a combined status
 
22992
 (define_insn "*altivec_vcmpequ<VI_char>_p"
 
22993
   [(set (reg:CC 74)
 
22994
-       (unspec:CC [(eq:CC (match_operand:VI 1 "register_operand" "v")
 
22995
-                          (match_operand:VI 2 "register_operand" "v"))]
 
22996
+       (unspec:CC [(eq:CC (match_operand:VI2 1 "register_operand" "v")
 
22997
+                          (match_operand:VI2 2 "register_operand" "v"))]
 
22998
                   UNSPEC_PREDICATE))
 
22999
-   (set (match_operand:VI 0 "register_operand" "=v")
 
23000
-       (eq:VI (match_dup 1)
 
23001
-              (match_dup 2)))]
 
23002
-  "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
 
23003
+   (set (match_operand:VI2 0 "register_operand" "=v")
 
23004
+       (eq:VI2 (match_dup 1)
 
23005
+               (match_dup 2)))]
 
23006
+  "<VI_unit>"
 
23007
   "vcmpequ<VI_char>. %0,%1,%2"
 
23008
   [(set_attr "type" "veccmp")])
 
23009
 
 
23010
 (define_insn "*altivec_vcmpgts<VI_char>_p"
 
23011
   [(set (reg:CC 74)
 
23012
-       (unspec:CC [(gt:CC (match_operand:VI 1 "register_operand" "v")
 
23013
-                          (match_operand:VI 2 "register_operand" "v"))]
 
23014
+       (unspec:CC [(gt:CC (match_operand:VI2 1 "register_operand" "v")
 
23015
+                          (match_operand:VI2 2 "register_operand" "v"))]
 
23016
                   UNSPEC_PREDICATE))
 
23017
-   (set (match_operand:VI 0 "register_operand" "=v")
 
23018
-       (gt:VI (match_dup 1)
 
23019
-              (match_dup 2)))]
 
23020
-  "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
 
23021
+   (set (match_operand:VI2 0 "register_operand" "=v")
 
23022
+       (gt:VI2 (match_dup 1)
 
23023
+               (match_dup 2)))]
 
23024
+  "<VI_unit>"
 
23025
   "vcmpgts<VI_char>. %0,%1,%2"
 
23026
   [(set_attr "type" "veccmp")])
 
23027
 
 
23028
 (define_insn "*altivec_vcmpgtu<VI_char>_p"
 
23029
   [(set (reg:CC 74)
 
23030
-       (unspec:CC [(gtu:CC (match_operand:VI 1 "register_operand" "v")
 
23031
-                           (match_operand:VI 2 "register_operand" "v"))]
 
23032
+       (unspec:CC [(gtu:CC (match_operand:VI2 1 "register_operand" "v")
 
23033
+                           (match_operand:VI2 2 "register_operand" "v"))]
 
23034
                   UNSPEC_PREDICATE))
 
23035
-   (set (match_operand:VI 0 "register_operand" "=v")
 
23036
-       (gtu:VI (match_dup 1)
 
23037
-               (match_dup 2)))]
 
23038
-  "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
 
23039
+   (set (match_operand:VI2 0 "register_operand" "=v")
 
23040
+       (gtu:VI2 (match_dup 1)
 
23041
+                (match_dup 2)))]
 
23042
+  "<VI_unit>"
 
23043
   "vcmpgtu<VI_char>. %0,%1,%2"
 
23044
   [(set_attr "type" "veccmp")])
 
23045
 
 
23046
@@ -1779,20 +1851,28 @@
 
23047
   [(set_attr "type" "vecstore")])
 
23048
 
 
23049
 ;; Generate
 
23050
-;;    vspltis? SCRATCH0,0
 
23051
+;;    xxlxor/vxor SCRATCH0,SCRATCH0,SCRATCH0
 
23052
 ;;    vsubu?m SCRATCH2,SCRATCH1,%1
 
23053
 ;;    vmaxs? %0,%1,SCRATCH2"
 
23054
 (define_expand "abs<mode>2"
 
23055
-  [(set (match_dup 2) (vec_duplicate:VI (const_int 0)))
 
23056
-   (set (match_dup 3)
 
23057
-        (minus:VI (match_dup 2)
 
23058
-                  (match_operand:VI 1 "register_operand" "v")))
 
23059
-   (set (match_operand:VI 0 "register_operand" "=v")
 
23060
-        (smax:VI (match_dup 1) (match_dup 3)))]
 
23061
-  "TARGET_ALTIVEC"
 
23062
+  [(set (match_dup 2) (match_dup 3))
 
23063
+   (set (match_dup 4)
 
23064
+        (minus:VI2 (match_dup 2)
 
23065
+                  (match_operand:VI2 1 "register_operand" "v")))
 
23066
+   (set (match_operand:VI2 0 "register_operand" "=v")
 
23067
+        (smax:VI2 (match_dup 1) (match_dup 4)))]
 
23068
+  "<VI_unit>"
 
23069
 {
 
23070
-  operands[2] = gen_reg_rtx (GET_MODE (operands[0]));
 
23071
-  operands[3] = gen_reg_rtx (GET_MODE (operands[0]));
 
23072
+  int i, n_elt = GET_MODE_NUNITS (<MODE>mode);
 
23073
+  rtvec v = rtvec_alloc (n_elt);
 
23074
+
 
23075
+  /* Create an all 0 constant.  */
 
23076
+  for (i = 0; i < n_elt; ++i)
 
23077
+    RTVEC_ELT (v, i) = const0_rtx;
 
23078
+
 
23079
+  operands[2] = gen_reg_rtx (<MODE>mode);
 
23080
+  operands[3] = gen_rtx_CONST_VECTOR (<MODE>mode, v);
 
23081
+  operands[4] = gen_reg_rtx (<MODE>mode);
 
23082
 })
 
23083
 
 
23084
 ;; Generate
 
23085
@@ -1950,50 +2030,20 @@
 
23086
   DONE;
 
23087
 }")
 
23088
 
 
23089
-(define_expand "vec_unpacks_hi_v16qi"
 
23090
-  [(set (match_operand:V8HI 0 "register_operand" "=v")
 
23091
-        (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
 
23092
-                     UNSPEC_VUPKHSB))]
 
23093
-  "TARGET_ALTIVEC"
 
23094
-  "
 
23095
-{
 
23096
-  emit_insn (gen_altivec_vupkhsb (operands[0], operands[1]));
 
23097
-  DONE;
 
23098
-}")
 
23099
+(define_expand "vec_unpacks_hi_<VP_small_lc>"
 
23100
+  [(set (match_operand:VP 0 "register_operand" "=v")
 
23101
+        (unspec:VP [(match_operand:<VP_small> 1 "register_operand" "v")]
 
23102
+                  UNSPEC_VUNPACK_HI_SIGN))]
 
23103
+  "<VI_unit>"
 
23104
+  "")
 
23105
 
 
23106
-(define_expand "vec_unpacks_hi_v8hi"
 
23107
-  [(set (match_operand:V4SI 0 "register_operand" "=v")
 
23108
-        (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
 
23109
-                     UNSPEC_VUPKHSH))]
 
23110
-  "TARGET_ALTIVEC"
 
23111
-  "
 
23112
-{
 
23113
-  emit_insn (gen_altivec_vupkhsh (operands[0], operands[1]));
 
23114
-  DONE;
 
23115
-}")
 
23116
+(define_expand "vec_unpacks_lo_<VP_small_lc>"
 
23117
+  [(set (match_operand:VP 0 "register_operand" "=v")
 
23118
+        (unspec:VP [(match_operand:<VP_small> 1 "register_operand" "v")]
 
23119
+                  UNSPEC_VUNPACK_LO_SIGN))]
 
23120
+  "<VI_unit>"
 
23121
+  "")
 
23122
 
 
23123
-(define_expand "vec_unpacks_lo_v16qi"
 
23124
-  [(set (match_operand:V8HI 0 "register_operand" "=v")
 
23125
-        (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
 
23126
-                     UNSPEC_VUPKLSB))]
 
23127
-  "TARGET_ALTIVEC"
 
23128
-  "
 
23129
-{
 
23130
-  emit_insn (gen_altivec_vupklsb (operands[0], operands[1]));
 
23131
-  DONE;
 
23132
-}")
 
23133
-
 
23134
-(define_expand "vec_unpacks_lo_v8hi"
 
23135
-  [(set (match_operand:V4SI 0 "register_operand" "=v")
 
23136
-        (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
 
23137
-                     UNSPEC_VUPKLSH))]
 
23138
-  "TARGET_ALTIVEC"
 
23139
-  "
 
23140
-{
 
23141
-  emit_insn (gen_altivec_vupklsh (operands[0], operands[1]));
 
23142
-  DONE;
 
23143
-}")
 
23144
-
 
23145
 (define_insn "vperm_v8hiv4si"
 
23146
   [(set (match_operand:V4SI 0 "register_operand" "=v")
 
23147
         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
 
23148
@@ -2025,25 +2075,26 @@
 
23149
   rtx vzero = gen_reg_rtx (V8HImode);
 
23150
   rtx mask = gen_reg_rtx (V16QImode);
 
23151
   rtvec v = rtvec_alloc (16);
 
23152
+  bool be = BYTES_BIG_ENDIAN;
 
23153
    
 
23154
   emit_insn (gen_altivec_vspltish (vzero, const0_rtx));
 
23155
    
 
23156
-  RTVEC_ELT (v, 0) = gen_rtx_CONST_INT (QImode, 16);
 
23157
-  RTVEC_ELT (v, 1) = gen_rtx_CONST_INT (QImode, 0);
 
23158
-  RTVEC_ELT (v, 2) = gen_rtx_CONST_INT (QImode, 16);
 
23159
-  RTVEC_ELT (v, 3) = gen_rtx_CONST_INT (QImode, 1);
 
23160
-  RTVEC_ELT (v, 4) = gen_rtx_CONST_INT (QImode, 16);
 
23161
-  RTVEC_ELT (v, 5) = gen_rtx_CONST_INT (QImode, 2);
 
23162
-  RTVEC_ELT (v, 6) = gen_rtx_CONST_INT (QImode, 16);
 
23163
-  RTVEC_ELT (v, 7) = gen_rtx_CONST_INT (QImode, 3);
 
23164
-  RTVEC_ELT (v, 8) = gen_rtx_CONST_INT (QImode, 16);
 
23165
-  RTVEC_ELT (v, 9) = gen_rtx_CONST_INT (QImode, 4);
 
23166
-  RTVEC_ELT (v, 10) = gen_rtx_CONST_INT (QImode, 16);
 
23167
-  RTVEC_ELT (v, 11) = gen_rtx_CONST_INT (QImode, 5);
 
23168
-  RTVEC_ELT (v, 12) = gen_rtx_CONST_INT (QImode, 16);
 
23169
-  RTVEC_ELT (v, 13) = gen_rtx_CONST_INT (QImode, 6);
 
23170
-  RTVEC_ELT (v, 14) = gen_rtx_CONST_INT (QImode, 16);
 
23171
-  RTVEC_ELT (v, 15) = gen_rtx_CONST_INT (QImode, 7);
 
23172
+  RTVEC_ELT (v,  0) = gen_rtx_CONST_INT (QImode, be ? 16 :  7);
 
23173
+  RTVEC_ELT (v,  1) = gen_rtx_CONST_INT (QImode, be ?  0 : 16);
 
23174
+  RTVEC_ELT (v,  2) = gen_rtx_CONST_INT (QImode, be ? 16 :  6);
 
23175
+  RTVEC_ELT (v,  3) = gen_rtx_CONST_INT (QImode, be ?  1 : 16);
 
23176
+  RTVEC_ELT (v,  4) = gen_rtx_CONST_INT (QImode, be ? 16 :  5);
 
23177
+  RTVEC_ELT (v,  5) = gen_rtx_CONST_INT (QImode, be ?  2 : 16);
 
23178
+  RTVEC_ELT (v,  6) = gen_rtx_CONST_INT (QImode, be ? 16 :  4);
 
23179
+  RTVEC_ELT (v,  7) = gen_rtx_CONST_INT (QImode, be ?  3 : 16);
 
23180
+  RTVEC_ELT (v,  8) = gen_rtx_CONST_INT (QImode, be ? 16 :  3);
 
23181
+  RTVEC_ELT (v,  9) = gen_rtx_CONST_INT (QImode, be ?  4 : 16);
 
23182
+  RTVEC_ELT (v, 10) = gen_rtx_CONST_INT (QImode, be ? 16 :  2);
 
23183
+  RTVEC_ELT (v, 11) = gen_rtx_CONST_INT (QImode, be ?  5 : 16);
 
23184
+  RTVEC_ELT (v, 12) = gen_rtx_CONST_INT (QImode, be ? 16 :  1);
 
23185
+  RTVEC_ELT (v, 13) = gen_rtx_CONST_INT (QImode, be ?  6 : 16);
 
23186
+  RTVEC_ELT (v, 14) = gen_rtx_CONST_INT (QImode, be ? 16 :  0);
 
23187
+  RTVEC_ELT (v, 15) = gen_rtx_CONST_INT (QImode, be ?  7 : 16);
 
23188
 
 
23189
   emit_insn (gen_vec_initv16qi (mask, gen_rtx_PARALLEL (V16QImode, v)));
 
23190
   emit_insn (gen_vperm_v16qiv8hi (operands[0], operands[1], vzero, mask));
 
23191
@@ -2060,25 +2111,26 @@
 
23192
   rtx vzero = gen_reg_rtx (V4SImode);
 
23193
   rtx mask = gen_reg_rtx (V16QImode);
 
23194
   rtvec v = rtvec_alloc (16);
 
23195
+  bool be = BYTES_BIG_ENDIAN;
 
23196
 
 
23197
   emit_insn (gen_altivec_vspltisw (vzero, const0_rtx));
 
23198
  
 
23199
-  RTVEC_ELT (v, 0) = gen_rtx_CONST_INT (QImode, 16);
 
23200
-  RTVEC_ELT (v, 1) = gen_rtx_CONST_INT (QImode, 17);
 
23201
-  RTVEC_ELT (v, 2) = gen_rtx_CONST_INT (QImode, 0);
 
23202
-  RTVEC_ELT (v, 3) = gen_rtx_CONST_INT (QImode, 1);
 
23203
-  RTVEC_ELT (v, 4) = gen_rtx_CONST_INT (QImode, 16);
 
23204
-  RTVEC_ELT (v, 5) = gen_rtx_CONST_INT (QImode, 17);
 
23205
-  RTVEC_ELT (v, 6) = gen_rtx_CONST_INT (QImode, 2);
 
23206
-  RTVEC_ELT (v, 7) = gen_rtx_CONST_INT (QImode, 3);
 
23207
-  RTVEC_ELT (v, 8) = gen_rtx_CONST_INT (QImode, 16);
 
23208
-  RTVEC_ELT (v, 9) = gen_rtx_CONST_INT (QImode, 17);
 
23209
-  RTVEC_ELT (v, 10) = gen_rtx_CONST_INT (QImode, 4);
 
23210
-  RTVEC_ELT (v, 11) = gen_rtx_CONST_INT (QImode, 5);
 
23211
-  RTVEC_ELT (v, 12) = gen_rtx_CONST_INT (QImode, 16);
 
23212
-  RTVEC_ELT (v, 13) = gen_rtx_CONST_INT (QImode, 17);
 
23213
-  RTVEC_ELT (v, 14) = gen_rtx_CONST_INT (QImode, 6);
 
23214
-  RTVEC_ELT (v, 15) = gen_rtx_CONST_INT (QImode, 7);
 
23215
+  RTVEC_ELT (v,  0) = gen_rtx_CONST_INT (QImode, be ? 16 :  7);
 
23216
+  RTVEC_ELT (v,  1) = gen_rtx_CONST_INT (QImode, be ? 17 :  6);
 
23217
+  RTVEC_ELT (v,  2) = gen_rtx_CONST_INT (QImode, be ?  0 : 17);
 
23218
+  RTVEC_ELT (v,  3) = gen_rtx_CONST_INT (QImode, be ?  1 : 16);
 
23219
+  RTVEC_ELT (v,  4) = gen_rtx_CONST_INT (QImode, be ? 16 :  5);
 
23220
+  RTVEC_ELT (v,  5) = gen_rtx_CONST_INT (QImode, be ? 17 :  4);
 
23221
+  RTVEC_ELT (v,  6) = gen_rtx_CONST_INT (QImode, be ?  2 : 17);
 
23222
+  RTVEC_ELT (v,  7) = gen_rtx_CONST_INT (QImode, be ?  3 : 16);
 
23223
+  RTVEC_ELT (v,  8) = gen_rtx_CONST_INT (QImode, be ? 16 :  3);
 
23224
+  RTVEC_ELT (v,  9) = gen_rtx_CONST_INT (QImode, be ? 17 :  2);
 
23225
+  RTVEC_ELT (v, 10) = gen_rtx_CONST_INT (QImode, be ?  4 : 17);
 
23226
+  RTVEC_ELT (v, 11) = gen_rtx_CONST_INT (QImode, be ?  5 : 16);
 
23227
+  RTVEC_ELT (v, 12) = gen_rtx_CONST_INT (QImode, be ? 16 :  1);
 
23228
+  RTVEC_ELT (v, 13) = gen_rtx_CONST_INT (QImode, be ? 17 :  0);
 
23229
+  RTVEC_ELT (v, 14) = gen_rtx_CONST_INT (QImode, be ?  6 : 17);
 
23230
+  RTVEC_ELT (v, 15) = gen_rtx_CONST_INT (QImode, be ?  7 : 16);
 
23231
 
 
23232
   emit_insn (gen_vec_initv16qi (mask, gen_rtx_PARALLEL (V16QImode, v)));
 
23233
   emit_insn (gen_vperm_v8hiv4si (operands[0], operands[1], vzero, mask));
 
23234
@@ -2095,25 +2147,26 @@
 
23235
   rtx vzero = gen_reg_rtx (V8HImode);
 
23236
   rtx mask = gen_reg_rtx (V16QImode);
 
23237
   rtvec v = rtvec_alloc (16);
 
23238
+  bool be = BYTES_BIG_ENDIAN;
 
23239
 
 
23240
   emit_insn (gen_altivec_vspltish (vzero, const0_rtx));
 
23241
 
 
23242
-  RTVEC_ELT (v, 0) = gen_rtx_CONST_INT (QImode, 16);
 
23243
-  RTVEC_ELT (v, 1) = gen_rtx_CONST_INT (QImode, 8);
 
23244
-  RTVEC_ELT (v, 2) = gen_rtx_CONST_INT (QImode, 16);
 
23245
-  RTVEC_ELT (v, 3) = gen_rtx_CONST_INT (QImode, 9);
 
23246
-  RTVEC_ELT (v, 4) = gen_rtx_CONST_INT (QImode, 16);
 
23247
-  RTVEC_ELT (v, 5) = gen_rtx_CONST_INT (QImode, 10);
 
23248
-  RTVEC_ELT (v, 6) = gen_rtx_CONST_INT (QImode, 16);
 
23249
-  RTVEC_ELT (v, 7) = gen_rtx_CONST_INT (QImode, 11);
 
23250
-  RTVEC_ELT (v, 8) = gen_rtx_CONST_INT (QImode, 16);
 
23251
-  RTVEC_ELT (v, 9) = gen_rtx_CONST_INT (QImode, 12);
 
23252
-  RTVEC_ELT (v, 10) = gen_rtx_CONST_INT (QImode, 16);
 
23253
-  RTVEC_ELT (v, 11) = gen_rtx_CONST_INT (QImode, 13);
 
23254
-  RTVEC_ELT (v, 12) = gen_rtx_CONST_INT (QImode, 16);
 
23255
-  RTVEC_ELT (v, 13) = gen_rtx_CONST_INT (QImode, 14);
 
23256
-  RTVEC_ELT (v, 14) = gen_rtx_CONST_INT (QImode, 16);
 
23257
-  RTVEC_ELT (v, 15) = gen_rtx_CONST_INT (QImode, 15);
 
23258
+  RTVEC_ELT (v,  0) = gen_rtx_CONST_INT (QImode, be ? 16 : 15);
 
23259
+  RTVEC_ELT (v,  1) = gen_rtx_CONST_INT (QImode, be ?  8 : 16);
 
23260
+  RTVEC_ELT (v,  2) = gen_rtx_CONST_INT (QImode, be ? 16 : 14);
 
23261
+  RTVEC_ELT (v,  3) = gen_rtx_CONST_INT (QImode, be ?  9 : 16);
 
23262
+  RTVEC_ELT (v,  4) = gen_rtx_CONST_INT (QImode, be ? 16 : 13);
 
23263
+  RTVEC_ELT (v,  5) = gen_rtx_CONST_INT (QImode, be ? 10 : 16);
 
23264
+  RTVEC_ELT (v,  6) = gen_rtx_CONST_INT (QImode, be ? 16 : 12);
 
23265
+  RTVEC_ELT (v,  7) = gen_rtx_CONST_INT (QImode, be ? 11 : 16);
 
23266
+  RTVEC_ELT (v,  8) = gen_rtx_CONST_INT (QImode, be ? 16 : 11);
 
23267
+  RTVEC_ELT (v,  9) = gen_rtx_CONST_INT (QImode, be ? 12 : 16);
 
23268
+  RTVEC_ELT (v, 10) = gen_rtx_CONST_INT (QImode, be ? 16 : 10);
 
23269
+  RTVEC_ELT (v, 11) = gen_rtx_CONST_INT (QImode, be ? 13 : 16);
 
23270
+  RTVEC_ELT (v, 12) = gen_rtx_CONST_INT (QImode, be ? 16 :  9);
 
23271
+  RTVEC_ELT (v, 13) = gen_rtx_CONST_INT (QImode, be ? 14 : 16);
 
23272
+  RTVEC_ELT (v, 14) = gen_rtx_CONST_INT (QImode, be ? 16 :  8);
 
23273
+  RTVEC_ELT (v, 15) = gen_rtx_CONST_INT (QImode, be ? 15 : 16);
 
23274
 
 
23275
   emit_insn (gen_vec_initv16qi (mask, gen_rtx_PARALLEL (V16QImode, v)));
 
23276
   emit_insn (gen_vperm_v16qiv8hi (operands[0], operands[1], vzero, mask));
 
23277
@@ -2130,25 +2183,26 @@
 
23278
   rtx vzero = gen_reg_rtx (V4SImode);
 
23279
   rtx mask = gen_reg_rtx (V16QImode);
 
23280
   rtvec v = rtvec_alloc (16);
 
23281
+  bool be = BYTES_BIG_ENDIAN;
 
23282
 
 
23283
   emit_insn (gen_altivec_vspltisw (vzero, const0_rtx));
 
23284
  
 
23285
-  RTVEC_ELT (v, 0) = gen_rtx_CONST_INT (QImode, 16);
 
23286
-  RTVEC_ELT (v, 1) = gen_rtx_CONST_INT (QImode, 17);
 
23287
-  RTVEC_ELT (v, 2) = gen_rtx_CONST_INT (QImode, 8);
 
23288
-  RTVEC_ELT (v, 3) = gen_rtx_CONST_INT (QImode, 9);
 
23289
-  RTVEC_ELT (v, 4) = gen_rtx_CONST_INT (QImode, 16);
 
23290
-  RTVEC_ELT (v, 5) = gen_rtx_CONST_INT (QImode, 17);
 
23291
-  RTVEC_ELT (v, 6) = gen_rtx_CONST_INT (QImode, 10);
 
23292
-  RTVEC_ELT (v, 7) = gen_rtx_CONST_INT (QImode, 11);
 
23293
-  RTVEC_ELT (v, 8) = gen_rtx_CONST_INT (QImode, 16);
 
23294
-  RTVEC_ELT (v, 9) = gen_rtx_CONST_INT (QImode, 17);
 
23295
-  RTVEC_ELT (v, 10) = gen_rtx_CONST_INT (QImode, 12);
 
23296
-  RTVEC_ELT (v, 11) = gen_rtx_CONST_INT (QImode, 13);
 
23297
-  RTVEC_ELT (v, 12) = gen_rtx_CONST_INT (QImode, 16);
 
23298
-  RTVEC_ELT (v, 13) = gen_rtx_CONST_INT (QImode, 17);
 
23299
-  RTVEC_ELT (v, 14) = gen_rtx_CONST_INT (QImode, 14);
 
23300
-  RTVEC_ELT (v, 15) = gen_rtx_CONST_INT (QImode, 15);
 
23301
+  RTVEC_ELT (v,  0) = gen_rtx_CONST_INT (QImode, be ? 16 : 15);
 
23302
+  RTVEC_ELT (v,  1) = gen_rtx_CONST_INT (QImode, be ? 17 : 14);
 
23303
+  RTVEC_ELT (v,  2) = gen_rtx_CONST_INT (QImode, be ?  8 : 17);
 
23304
+  RTVEC_ELT (v,  3) = gen_rtx_CONST_INT (QImode, be ?  9 : 16);
 
23305
+  RTVEC_ELT (v,  4) = gen_rtx_CONST_INT (QImode, be ? 16 : 13);
 
23306
+  RTVEC_ELT (v,  5) = gen_rtx_CONST_INT (QImode, be ? 17 : 12);
 
23307
+  RTVEC_ELT (v,  6) = gen_rtx_CONST_INT (QImode, be ? 10 : 17);
 
23308
+  RTVEC_ELT (v,  7) = gen_rtx_CONST_INT (QImode, be ? 11 : 16);
 
23309
+  RTVEC_ELT (v,  8) = gen_rtx_CONST_INT (QImode, be ? 16 : 11);
 
23310
+  RTVEC_ELT (v,  9) = gen_rtx_CONST_INT (QImode, be ? 17 : 10);
 
23311
+  RTVEC_ELT (v, 10) = gen_rtx_CONST_INT (QImode, be ? 12 : 17);
 
23312
+  RTVEC_ELT (v, 11) = gen_rtx_CONST_INT (QImode, be ? 13 : 16);
 
23313
+  RTVEC_ELT (v, 12) = gen_rtx_CONST_INT (QImode, be ? 16 :  9);
 
23314
+  RTVEC_ELT (v, 13) = gen_rtx_CONST_INT (QImode, be ? 17 :  8);
 
23315
+  RTVEC_ELT (v, 14) = gen_rtx_CONST_INT (QImode, be ? 14 : 17);
 
23316
+  RTVEC_ELT (v, 15) = gen_rtx_CONST_INT (QImode, be ? 15 : 16);
 
23317
 
 
23318
   emit_insn (gen_vec_initv16qi (mask, gen_rtx_PARALLEL (V16QImode, v)));
 
23319
   emit_insn (gen_vperm_v8hiv4si (operands[0], operands[1], vzero, mask));
 
23320
@@ -2168,7 +2222,10 @@
 
23321
   
 
23322
   emit_insn (gen_vec_widen_umult_even_v16qi (ve, operands[1], operands[2]));
 
23323
   emit_insn (gen_vec_widen_umult_odd_v16qi (vo, operands[1], operands[2]));
 
23324
-  emit_insn (gen_altivec_vmrghh (operands[0], ve, vo));
 
23325
+  if (BYTES_BIG_ENDIAN)
 
23326
+    emit_insn (gen_altivec_vmrghh (operands[0], ve, vo));
 
23327
+  else
 
23328
+    emit_insn (gen_altivec_vmrghh (operands[0], vo, ve));
 
23329
   DONE;
 
23330
 }")
 
23331
 
 
23332
@@ -2185,7 +2242,10 @@
 
23333
   
 
23334
   emit_insn (gen_vec_widen_umult_even_v16qi (ve, operands[1], operands[2]));
 
23335
   emit_insn (gen_vec_widen_umult_odd_v16qi (vo, operands[1], operands[2]));
 
23336
-  emit_insn (gen_altivec_vmrglh (operands[0], ve, vo));
 
23337
+  if (BYTES_BIG_ENDIAN)
 
23338
+    emit_insn (gen_altivec_vmrglh (operands[0], ve, vo));
 
23339
+  else
 
23340
+    emit_insn (gen_altivec_vmrglh (operands[0], vo, ve));
 
23341
   DONE;
 
23342
 }")
 
23343
 
 
23344
@@ -2202,7 +2262,10 @@
 
23345
   
 
23346
   emit_insn (gen_vec_widen_smult_even_v16qi (ve, operands[1], operands[2]));
 
23347
   emit_insn (gen_vec_widen_smult_odd_v16qi (vo, operands[1], operands[2]));
 
23348
-  emit_insn (gen_altivec_vmrghh (operands[0], ve, vo));
 
23349
+  if (BYTES_BIG_ENDIAN)
 
23350
+    emit_insn (gen_altivec_vmrghh (operands[0], ve, vo));
 
23351
+  else
 
23352
+    emit_insn (gen_altivec_vmrghh (operands[0], vo, ve));
 
23353
   DONE;
 
23354
 }")
 
23355
 
 
23356
@@ -2219,7 +2282,10 @@
 
23357
   
 
23358
   emit_insn (gen_vec_widen_smult_even_v16qi (ve, operands[1], operands[2]));
 
23359
   emit_insn (gen_vec_widen_smult_odd_v16qi (vo, operands[1], operands[2]));
 
23360
-  emit_insn (gen_altivec_vmrglh (operands[0], ve, vo));
 
23361
+  if (BYTES_BIG_ENDIAN)
 
23362
+    emit_insn (gen_altivec_vmrglh (operands[0], ve, vo));
 
23363
+  else
 
23364
+    emit_insn (gen_altivec_vmrglh (operands[0], vo, ve));
 
23365
   DONE;
 
23366
 }")
 
23367
 
 
23368
@@ -2236,7 +2302,10 @@
 
23369
   
 
23370
   emit_insn (gen_vec_widen_umult_even_v8hi (ve, operands[1], operands[2]));
 
23371
   emit_insn (gen_vec_widen_umult_odd_v8hi (vo, operands[1], operands[2]));
 
23372
-  emit_insn (gen_altivec_vmrghw (operands[0], ve, vo));
 
23373
+  if (BYTES_BIG_ENDIAN)
 
23374
+    emit_insn (gen_altivec_vmrghw (operands[0], ve, vo));
 
23375
+  else
 
23376
+    emit_insn (gen_altivec_vmrghw (operands[0], vo, ve));
 
23377
   DONE;
 
23378
 }")
 
23379
 
 
23380
@@ -2253,7 +2322,10 @@
 
23381
   
 
23382
   emit_insn (gen_vec_widen_umult_even_v8hi (ve, operands[1], operands[2]));
 
23383
   emit_insn (gen_vec_widen_umult_odd_v8hi (vo, operands[1], operands[2]));
 
23384
-  emit_insn (gen_altivec_vmrglw (operands[0], ve, vo));
 
23385
+  if (BYTES_BIG_ENDIAN)
 
23386
+    emit_insn (gen_altivec_vmrglw (operands[0], ve, vo));
 
23387
+  else
 
23388
+    emit_insn (gen_altivec_vmrglw (operands[0], vo, ve));
 
23389
   DONE;
 
23390
 }")
 
23391
 
 
23392
@@ -2270,7 +2342,10 @@
 
23393
   
 
23394
   emit_insn (gen_vec_widen_smult_even_v8hi (ve, operands[1], operands[2]));
 
23395
   emit_insn (gen_vec_widen_smult_odd_v8hi (vo, operands[1], operands[2]));
 
23396
-  emit_insn (gen_altivec_vmrghw (operands[0], ve, vo));
 
23397
+  if (BYTES_BIG_ENDIAN)
 
23398
+    emit_insn (gen_altivec_vmrghw (operands[0], ve, vo));
 
23399
+  else
 
23400
+    emit_insn (gen_altivec_vmrghw (operands[0], vo, ve));
 
23401
   DONE;
 
23402
 }")
 
23403
 
 
23404
@@ -2287,33 +2362,20 @@
 
23405
   
 
23406
   emit_insn (gen_vec_widen_smult_even_v8hi (ve, operands[1], operands[2]));
 
23407
   emit_insn (gen_vec_widen_smult_odd_v8hi (vo, operands[1], operands[2]));
 
23408
-  emit_insn (gen_altivec_vmrglw (operands[0], ve, vo));
 
23409
+  if (BYTES_BIG_ENDIAN)
 
23410
+    emit_insn (gen_altivec_vmrglw (operands[0], ve, vo));
 
23411
+  else
 
23412
+    emit_insn (gen_altivec_vmrglw (operands[0], vo, ve));
 
23413
   DONE;
 
23414
 }")
 
23415
 
 
23416
-(define_expand "vec_pack_trunc_v8hi"
 
23417
-  [(set (match_operand:V16QI 0 "register_operand" "=v")
 
23418
-        (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
 
23419
-                       (match_operand:V8HI 2 "register_operand" "v")]
 
23420
-                      UNSPEC_VPKUHUM))]
 
23421
-  "TARGET_ALTIVEC"
 
23422
-  "
 
23423
-{
 
23424
-  emit_insn (gen_altivec_vpkuhum (operands[0], operands[1], operands[2]));
 
23425
-  DONE;
 
23426
-}")
 
23427
-                                                                                
 
23428
-(define_expand "vec_pack_trunc_v4si"
 
23429
-  [(set (match_operand:V8HI 0 "register_operand" "=v")
 
23430
-        (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
 
23431
-                      (match_operand:V4SI 2 "register_operand" "v")]
 
23432
-                     UNSPEC_VPKUWUM))]
 
23433
-  "TARGET_ALTIVEC"
 
23434
-  "
 
23435
-{
 
23436
-  emit_insn (gen_altivec_vpkuwum (operands[0], operands[1], operands[2]));
 
23437
-  DONE;
 
23438
-}")
 
23439
+(define_expand "vec_pack_trunc_<mode>"
 
23440
+  [(set (match_operand:<VP_small> 0 "register_operand" "=v")
 
23441
+        (unspec:<VP_small> [(match_operand:VP 1 "register_operand" "v")
 
23442
+                           (match_operand:VP 2 "register_operand" "v")]
 
23443
+                      UNSPEC_VPACK_UNS_UNS_MOD))]
 
23444
+  "<VI_unit>"
 
23445
+  "")
 
23446
 
 
23447
 (define_expand "altivec_negv4sf2"
 
23448
   [(use (match_operand:V4SF 0 "register_operand" ""))
 
23449
@@ -2460,3 +2522,34 @@
 
23450
   emit_insn (gen_altivec_vcfux (operands[0], tmp, const0_rtx));
 
23451
   DONE;
 
23452
 }")
 
23453
+
 
23454
+
 
23455
+;; Power8 vector instructions encoded as Altivec instructions
 
23456
+
 
23457
+;; Vector count leading zeros
 
23458
+(define_insn "*p8v_clz<mode>2"
 
23459
+  [(set (match_operand:VI2 0 "register_operand" "=v")
 
23460
+       (clz:VI2 (match_operand:VI2 1 "register_operand" "v")))]
 
23461
+  "TARGET_P8_VECTOR"
 
23462
+  "vclz<wd> %0,%1"
 
23463
+  [(set_attr "length" "4")
 
23464
+   (set_attr "type" "vecsimple")])
 
23465
+
 
23466
+;; Vector population count
 
23467
+(define_insn "*p8v_popcount<mode>2"
 
23468
+  [(set (match_operand:VI2 0 "register_operand" "=v")
 
23469
+        (popcount:VI2 (match_operand:VI2 1 "register_operand" "v")))]
 
23470
+  "TARGET_P8_VECTOR"
 
23471
+  "vpopcnt<wd> %0,%1"
 
23472
+  [(set_attr "length" "4")
 
23473
+   (set_attr "type" "vecsimple")])
 
23474
+
 
23475
+;; Vector Gather Bits by Bytes by Doubleword
 
23476
+(define_insn "p8v_vgbbd"
 
23477
+  [(set (match_operand:V16QI 0 "register_operand" "=v")
 
23478
+       (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")]
 
23479
+                     UNSPEC_VGBBD))]
 
23480
+  "TARGET_P8_VECTOR"
 
23481
+  "vgbbd %0,%1"
 
23482
+  [(set_attr "length" "4")
 
23483
+   (set_attr "type" "vecsimple")])
 
23484
--- a/src/gcc/config/rs6000/sysv4le.h
 
23485
+++ b/src/gcc/config/rs6000/sysv4le.h
 
23486
@@ -34,3 +34,7 @@
 
23487
 
 
23488
 #undef MULTILIB_DEFAULTS
 
23489
 #define        MULTILIB_DEFAULTS { "mlittle", "mcall-sysv" }
 
23490
+
 
23491
+/* Little-endian PowerPC64 Linux uses the ELF v2 ABI by default.  */
 
23492
+#define LINUX64_DEFAULT_ABI_ELFv2
 
23493
+
 
23494
--- a/src/gcc/config/rs6000/dfp.md
 
23495
+++ b/src/gcc/config/rs6000/dfp.md
 
23496
@@ -29,77 +29,6 @@
 
23497
   ])
 
23498
 
 
23499
 
 
23500
-(define_expand "movsd"
 
23501
-  [(set (match_operand:SD 0 "nonimmediate_operand" "")
 
23502
-       (match_operand:SD 1 "any_operand" ""))]
 
23503
-  "TARGET_HARD_FLOAT && TARGET_FPRS"
 
23504
-  "{ rs6000_emit_move (operands[0], operands[1], SDmode); DONE; }")
 
23505
-
 
23506
-(define_split
 
23507
-  [(set (match_operand:SD 0 "gpc_reg_operand" "")
 
23508
-       (match_operand:SD 1 "const_double_operand" ""))]
 
23509
-  "reload_completed
 
23510
-   && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
 
23511
-       || (GET_CODE (operands[0]) == SUBREG
 
23512
-          && GET_CODE (SUBREG_REG (operands[0])) == REG
 
23513
-          && REGNO (SUBREG_REG (operands[0])) <= 31))"
 
23514
-  [(set (match_dup 2) (match_dup 3))]
 
23515
-  "
 
23516
-{
 
23517
-  long l;
 
23518
-  REAL_VALUE_TYPE rv;
 
23519
-
 
23520
-  REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
 
23521
-  REAL_VALUE_TO_TARGET_DECIMAL32 (rv, l);
 
23522
-
 
23523
-  if (! TARGET_POWERPC64)
 
23524
-    operands[2] = operand_subword (operands[0], 0, 0, SDmode);
 
23525
-  else
 
23526
-    operands[2] = gen_lowpart (SImode, operands[0]);
 
23527
-
 
23528
-  operands[3] = gen_int_mode (l, SImode);
 
23529
-}")
 
23530
-
 
23531
-(define_insn "movsd_hardfloat"
 
23532
-  [(set (match_operand:SD 0 "nonimmediate_operand" "=r,r,m,f,*c*l,!r,*h,!r,!r")
 
23533
-       (match_operand:SD 1 "input_operand"        "r,m,r,f,r,h,0,G,Fn"))]
 
23534
-  "(gpc_reg_operand (operands[0], SDmode)
 
23535
-   || gpc_reg_operand (operands[1], SDmode))
 
23536
-   && (TARGET_HARD_FLOAT && TARGET_FPRS)"
 
23537
-  "@
 
23538
-   mr %0,%1
 
23539
-   lwz%U1%X1 %0,%1
 
23540
-   stw%U0%X0 %1,%0
 
23541
-   fmr %0,%1
 
23542
-   mt%0 %1
 
23543
-   mf%1 %0
 
23544
-   nop
 
23545
-   #
 
23546
-   #"
 
23547
-  [(set_attr "type" "*,load,store,fp,mtjmpr,mfjmpr,*,*,*")
 
23548
-   (set_attr "length" "4,4,4,4,4,4,4,4,8")])
 
23549
-
 
23550
-(define_insn "movsd_softfloat"
 
23551
-  [(set (match_operand:SD 0 "nonimmediate_operand" "=r,cl,r,r,m,r,r,r,r,r,*h")
 
23552
-       (match_operand:SD 1 "input_operand" "r,r,h,m,r,I,L,R,G,Fn,0"))]
 
23553
-  "(gpc_reg_operand (operands[0], SDmode)
 
23554
-   || gpc_reg_operand (operands[1], SDmode))
 
23555
-   && (TARGET_SOFT_FLOAT || !TARGET_FPRS)"
 
23556
-  "@
 
23557
-   mr %0,%1
 
23558
-   mt%0 %1
 
23559
-   mf%1 %0
 
23560
-   lwz%U1%X1 %0,%1
 
23561
-   stw%U0%X0 %1,%0
 
23562
-   li %0,%1
 
23563
-   lis %0,%v1
 
23564
-   la %0,%a1
 
23565
-   #
 
23566
-   #
 
23567
-   nop"
 
23568
-  [(set_attr "type" "*,mtjmpr,mfjmpr,load,store,*,*,*,*,*,*")
 
23569
-   (set_attr "length" "4,4,4,4,4,4,4,4,4,8,4")])
 
23570
-
 
23571
 (define_insn "movsd_store"
 
23572
   [(set (match_operand:DD 0 "nonimmediate_operand" "=m")
 
23573
        (unspec:DD [(match_operand:SD 1 "input_operand" "d")]
 
23574
@@ -108,7 +37,14 @@
 
23575
    || gpc_reg_operand (operands[1], SDmode))
 
23576
    && TARGET_HARD_FLOAT && TARGET_FPRS"
 
23577
   "stfd%U0%X0 %1,%0"
 
23578
-  [(set_attr "type" "fpstore")
 
23579
+  [(set (attr "type")
 
23580
+      (if_then_else
 
23581
+       (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
23582
+       (const_string "fpstore_ux")
 
23583
+       (if_then_else
 
23584
+         (match_test "update_address_mem (operands[0], VOIDmode)")
 
23585
+         (const_string "fpstore_u")
 
23586
+         (const_string "fpstore"))))
 
23587
    (set_attr "length" "4")])
 
23588
 
 
23589
 (define_insn "movsd_load"
 
23590
@@ -119,7 +55,14 @@
 
23591
    || gpc_reg_operand (operands[1], DDmode))
 
23592
    && TARGET_HARD_FLOAT && TARGET_FPRS"
 
23593
   "lfd%U1%X1 %0,%1"
 
23594
-  [(set_attr "type" "fpload")
 
23595
+  [(set (attr "type")
 
23596
+      (if_then_else
 
23597
+       (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
23598
+       (const_string "fpload_ux")
 
23599
+       (if_then_else
 
23600
+         (match_test "update_address_mem (operands[1], VOIDmode)")
 
23601
+         (const_string "fpload_u")
 
23602
+         (const_string "fpload"))))
 
23603
    (set_attr "length" "4")])
 
23604
 
 
23605
 ;; Hardware support for decimal floating point operations.
 
23606
@@ -182,211 +125,6 @@
 
23607
   "fnabs %0,%1"
 
23608
   [(set_attr "type" "fp")])
 
23609
 
 
23610
-(define_expand "movdd"
 
23611
-  [(set (match_operand:DD 0 "nonimmediate_operand" "")
 
23612
-       (match_operand:DD 1 "any_operand" ""))]
 
23613
-  ""
 
23614
-  "{ rs6000_emit_move (operands[0], operands[1], DDmode); DONE; }")
 
23615
-
 
23616
-(define_split
 
23617
-  [(set (match_operand:DD 0 "gpc_reg_operand" "")
 
23618
-       (match_operand:DD 1 "const_int_operand" ""))]
 
23619
-  "! TARGET_POWERPC64 && reload_completed
 
23620
-   && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
 
23621
-       || (GET_CODE (operands[0]) == SUBREG
 
23622
-          && GET_CODE (SUBREG_REG (operands[0])) == REG
 
23623
-          && REGNO (SUBREG_REG (operands[0])) <= 31))"
 
23624
-  [(set (match_dup 2) (match_dup 4))
 
23625
-   (set (match_dup 3) (match_dup 1))]
 
23626
-  "
 
23627
-{
 
23628
-  int endian = (WORDS_BIG_ENDIAN == 0);
 
23629
-  HOST_WIDE_INT value = INTVAL (operands[1]);
 
23630
-
 
23631
-  operands[2] = operand_subword (operands[0], endian, 0, DDmode);
 
23632
-  operands[3] = operand_subword (operands[0], 1 - endian, 0, DDmode);
 
23633
-#if HOST_BITS_PER_WIDE_INT == 32
 
23634
-  operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
 
23635
-#else
 
23636
-  operands[4] = GEN_INT (value >> 32);
 
23637
-  operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
 
23638
-#endif
 
23639
-}")
 
23640
-
 
23641
-(define_split
 
23642
-  [(set (match_operand:DD 0 "gpc_reg_operand" "")
 
23643
-       (match_operand:DD 1 "const_double_operand" ""))]
 
23644
-  "! TARGET_POWERPC64 && reload_completed
 
23645
-   && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
 
23646
-       || (GET_CODE (operands[0]) == SUBREG
 
23647
-          && GET_CODE (SUBREG_REG (operands[0])) == REG
 
23648
-          && REGNO (SUBREG_REG (operands[0])) <= 31))"
 
23649
-  [(set (match_dup 2) (match_dup 4))
 
23650
-   (set (match_dup 3) (match_dup 5))]
 
23651
-  "
 
23652
-{
 
23653
-  int endian = (WORDS_BIG_ENDIAN == 0);
 
23654
-  long l[2];
 
23655
-  REAL_VALUE_TYPE rv;
 
23656
-
 
23657
-  REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
 
23658
-  REAL_VALUE_TO_TARGET_DECIMAL64 (rv, l);
 
23659
-
 
23660
-  operands[2] = operand_subword (operands[0], endian, 0, DDmode);
 
23661
-  operands[3] = operand_subword (operands[0], 1 - endian, 0, DDmode);
 
23662
-  operands[4] = gen_int_mode (l[endian], SImode);
 
23663
-  operands[5] = gen_int_mode (l[1 - endian], SImode);
 
23664
-}")
 
23665
-
 
23666
-(define_split
 
23667
-  [(set (match_operand:DD 0 "gpc_reg_operand" "")
 
23668
-       (match_operand:DD 1 "const_double_operand" ""))]
 
23669
-  "TARGET_POWERPC64 && reload_completed
 
23670
-   && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
 
23671
-       || (GET_CODE (operands[0]) == SUBREG
 
23672
-          && GET_CODE (SUBREG_REG (operands[0])) == REG
 
23673
-          && REGNO (SUBREG_REG (operands[0])) <= 31))"
 
23674
-  [(set (match_dup 2) (match_dup 3))]
 
23675
-  "
 
23676
-{
 
23677
-  int endian = (WORDS_BIG_ENDIAN == 0);
 
23678
-  long l[2];
 
23679
-  REAL_VALUE_TYPE rv;
 
23680
-#if HOST_BITS_PER_WIDE_INT >= 64
 
23681
-  HOST_WIDE_INT val;
 
23682
-#endif
 
23683
-
 
23684
-  REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
 
23685
-  REAL_VALUE_TO_TARGET_DECIMAL64 (rv, l);
 
23686
-
 
23687
-  operands[2] = gen_lowpart (DImode, operands[0]);
 
23688
-  /* HIGHPART is lower memory address when WORDS_BIG_ENDIAN.  */
 
23689
-#if HOST_BITS_PER_WIDE_INT >= 64
 
23690
-  val = ((HOST_WIDE_INT)(unsigned long)l[endian] << 32
 
23691
-        | ((HOST_WIDE_INT)(unsigned long)l[1 - endian]));
 
23692
-
 
23693
-  operands[3] = gen_int_mode (val, DImode);
 
23694
-#else
 
23695
-  operands[3] = immed_double_const (l[1 - endian], l[endian], DImode);
 
23696
-#endif
 
23697
-}")
 
23698
-
 
23699
-;; Don't have reload use general registers to load a constant.  First,
 
23700
-;; it might not work if the output operand is the equivalent of
 
23701
-;; a non-offsettable memref, but also it is less efficient than loading
 
23702
-;; the constant into an FP register, since it will probably be used there.
 
23703
-;; The "??" is a kludge until we can figure out a more reasonable way
 
23704
-;; of handling these non-offsettable values.
 
23705
-(define_insn "*movdd_hardfloat32"
 
23706
-  [(set (match_operand:DD 0 "nonimmediate_operand" "=!r,??r,m,d,d,m,!r,!r,!r")
 
23707
-       (match_operand:DD 1 "input_operand" "r,m,r,d,m,d,G,H,F"))]
 
23708
-  "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
 
23709
-   && (gpc_reg_operand (operands[0], DDmode)
 
23710
-       || gpc_reg_operand (operands[1], DDmode))"
 
23711
-  "*
 
23712
-{
 
23713
-  switch (which_alternative)
 
23714
-    {
 
23715
-    default:
 
23716
-      gcc_unreachable ();
 
23717
-    case 0:
 
23718
-    case 1:
 
23719
-    case 2:
 
23720
-      return \"#\";
 
23721
-    case 3:
 
23722
-      return \"fmr %0,%1\";
 
23723
-    case 4:
 
23724
-      return \"lfd%U1%X1 %0,%1\";
 
23725
-    case 5:
 
23726
-      return \"stfd%U0%X0 %1,%0\";
 
23727
-    case 6:
 
23728
-    case 7:
 
23729
-    case 8:
 
23730
-      return \"#\";
 
23731
-    }
 
23732
-}"
 
23733
-  [(set_attr "type" "two,load,store,fp,fpload,fpstore,*,*,*")
 
23734
-   (set_attr "length" "8,16,16,4,4,4,8,12,16")])
 
23735
-
 
23736
-(define_insn "*movdd_softfloat32"
 
23737
-  [(set (match_operand:DD 0 "nonimmediate_operand" "=r,r,m,r,r,r")
 
23738
-       (match_operand:DD 1 "input_operand" "r,m,r,G,H,F"))]
 
23739
-  "! TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
 
23740
-   && (gpc_reg_operand (operands[0], DDmode)
 
23741
-       || gpc_reg_operand (operands[1], DDmode))"
 
23742
-  "#"
 
23743
-  [(set_attr "type" "two,load,store,*,*,*")
 
23744
-   (set_attr "length" "8,8,8,8,12,16")])
 
23745
-
 
23746
-; ld/std require word-aligned displacements -> 'Y' constraint.
 
23747
-; List Y->r and r->Y before r->r for reload.
 
23748
-(define_insn "*movdd_hardfloat64_mfpgpr"
 
23749
-  [(set (match_operand:DD 0 "nonimmediate_operand" "=Y,r,!r,d,d,m,*c*l,!r,*h,!r,!r,!r,r,d")
 
23750
-       (match_operand:DD 1 "input_operand" "r,Y,r,d,m,d,r,h,0,G,H,F,d,r"))]
 
23751
-  "TARGET_POWERPC64 && TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS
 
23752
-   && (gpc_reg_operand (operands[0], DDmode)
 
23753
-       || gpc_reg_operand (operands[1], DDmode))"
 
23754
-  "@
 
23755
-   std%U0%X0 %1,%0
 
23756
-   ld%U1%X1 %0,%1
 
23757
-   mr %0,%1
 
23758
-   fmr %0,%1
 
23759
-   lfd%U1%X1 %0,%1
 
23760
-   stfd%U0%X0 %1,%0
 
23761
-   mt%0 %1
 
23762
-   mf%1 %0
 
23763
-   nop
 
23764
-   #
 
23765
-   #
 
23766
-   #
 
23767
-   mftgpr %0,%1
 
23768
-   mffgpr %0,%1"
 
23769
-  [(set_attr "type" "store,load,*,fp,fpload,fpstore,mtjmpr,mfjmpr,*,*,*,*,mftgpr,mffgpr")
 
23770
-   (set_attr "length" "4,4,4,4,4,4,4,4,4,8,12,16,4,4")])
 
23771
-
 
23772
-; ld/std require word-aligned displacements -> 'Y' constraint.
 
23773
-; List Y->r and r->Y before r->r for reload.
 
23774
-(define_insn "*movdd_hardfloat64"
 
23775
-  [(set (match_operand:DD 0 "nonimmediate_operand" "=Y,r,!r,d,d,m,*c*l,!r,*h,!r,!r,!r")
 
23776
-       (match_operand:DD 1 "input_operand" "r,Y,r,d,m,d,r,h,0,G,H,F"))]
 
23777
-  "TARGET_POWERPC64 && !TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS
 
23778
-   && (gpc_reg_operand (operands[0], DDmode)
 
23779
-       || gpc_reg_operand (operands[1], DDmode))"
 
23780
-  "@
 
23781
-   std%U0%X0 %1,%0
 
23782
-   ld%U1%X1 %0,%1
 
23783
-   mr %0,%1
 
23784
-   fmr %0,%1
 
23785
-   lfd%U1%X1 %0,%1
 
23786
-   stfd%U0%X0 %1,%0
 
23787
-   mt%0 %1
 
23788
-   mf%1 %0
 
23789
-   nop
 
23790
-   #
 
23791
-   #
 
23792
-   #"
 
23793
-  [(set_attr "type" "store,load,*,fp,fpload,fpstore,mtjmpr,mfjmpr,*,*,*,*")
 
23794
-   (set_attr "length" "4,4,4,4,4,4,4,4,4,8,12,16")])
 
23795
-
 
23796
-(define_insn "*movdd_softfloat64"
 
23797
-  [(set (match_operand:DD 0 "nonimmediate_operand" "=r,Y,r,cl,r,r,r,r,*h")
 
23798
-       (match_operand:DD 1 "input_operand" "Y,r,r,r,h,G,H,F,0"))]
 
23799
-  "TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
 
23800
-   && (gpc_reg_operand (operands[0], DDmode)
 
23801
-       || gpc_reg_operand (operands[1], DDmode))"
 
23802
-  "@
 
23803
-   ld%U1%X1 %0,%1
 
23804
-   std%U0%X0 %1,%0
 
23805
-   mr %0,%1
 
23806
-   mt%0 %1
 
23807
-   mf%1 %0
 
23808
-   #
 
23809
-   #
 
23810
-   #
 
23811
-   nop"
 
23812
-  [(set_attr "type" "load,store,*,mtjmpr,mfjmpr,*,*,*,*")
 
23813
-   (set_attr "length" "4,4,4,4,4,8,12,16,4")])
 
23814
-
 
23815
 (define_expand "negtd2"
 
23816
   [(set (match_operand:TD 0 "gpc_reg_operand" "")
 
23817
        (neg:TD (match_operand:TD 1 "gpc_reg_operand" "")))]
 
23818
@@ -410,40 +148,25 @@
 
23819
   "")
 
23820
 
 
23821
 (define_insn "*abstd2_fpr"
 
23822
-  [(set (match_operand:TD 0 "gpc_reg_operand" "=d")
 
23823
-       (abs:TD (match_operand:TD 1 "gpc_reg_operand" "d")))]
 
23824
+  [(set (match_operand:TD 0 "gpc_reg_operand" "=d,d")
 
23825
+       (abs:TD (match_operand:TD 1 "gpc_reg_operand" "0,d")))]
 
23826
   "TARGET_HARD_FLOAT && TARGET_FPRS"
 
23827
-  "fabs %0,%1"
 
23828
-  [(set_attr "type" "fp")])
 
23829
+  "@
 
23830
+   fabs %0,%1
 
23831
+   fabs %0,%1\;fmr %L0,%L1"
 
23832
+  [(set_attr "type" "fp")
 
23833
+   (set_attr "length" "4,8")])
 
23834
 
 
23835
 (define_insn "*nabstd2_fpr"
 
23836
-  [(set (match_operand:TD 0 "gpc_reg_operand" "=d")
 
23837
-       (neg:TD (abs:TD (match_operand:TD 1 "gpc_reg_operand" "d"))))]
 
23838
+  [(set (match_operand:TD 0 "gpc_reg_operand" "=d,d")
 
23839
+       (neg:TD (abs:TD (match_operand:TD 1 "gpc_reg_operand" "0,d"))))]
 
23840
   "TARGET_HARD_FLOAT && TARGET_FPRS"
 
23841
-  "fnabs %0,%1"
 
23842
-  [(set_attr "type" "fp")])
 
23843
+  "@
 
23844
+   fnabs %0,%1
 
23845
+   fnabs %0,%1\;fmr %L0,%L1"
 
23846
+  [(set_attr "type" "fp")
 
23847
+   (set_attr "length" "4,8")])
 
23848
 
 
23849
-(define_expand "movtd"
 
23850
-  [(set (match_operand:TD 0 "general_operand" "")
 
23851
-       (match_operand:TD 1 "any_operand" ""))]
 
23852
-  "TARGET_HARD_FLOAT && TARGET_FPRS"
 
23853
-  "{ rs6000_emit_move (operands[0], operands[1], TDmode); DONE; }")
 
23854
-
 
23855
-; It's important to list the Y->r and r->Y moves before r->r because
 
23856
-; otherwise reload, given m->r, will try to pick r->r and reload it,
 
23857
-; which doesn't make progress.
 
23858
-(define_insn_and_split "*movtd_internal"
 
23859
-  [(set (match_operand:TD 0 "nonimmediate_operand" "=m,d,d,Y,r,r")
 
23860
-       (match_operand:TD 1 "input_operand"         "d,m,d,r,YGHF,r"))]
 
23861
-  "TARGET_HARD_FLOAT && TARGET_FPRS
 
23862
-   && (gpc_reg_operand (operands[0], TDmode)
 
23863
-       || gpc_reg_operand (operands[1], TDmode))"
 
23864
-  "#"
 
23865
-  "&& reload_completed"
 
23866
-  [(pc)]
 
23867
-{ rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
 
23868
-  [(set_attr "length" "8,8,8,20,20,16")])
 
23869
-
 
23870
 ;; Hardware support for decimal floating point operations.
 
23871
 
 
23872
 (define_insn "extendddtd2"
 
23873
--- a/src/gcc/config/rs6000/sync.md
 
23874
+++ b/src/gcc/config/rs6000/sync.md
 
23875
@@ -18,14 +18,23 @@
 
23876
 ;; along with GCC; see the file COPYING3.  If not see
 
23877
 ;; <http://www.gnu.org/licenses/>.
 
23878
 
 
23879
-(define_mode_attr larx [(SI "lwarx") (DI "ldarx")])
 
23880
-(define_mode_attr stcx [(SI "stwcx.") (DI "stdcx.")])
 
23881
+(define_mode_attr larx [(QI "lbarx")
 
23882
+                       (HI "lharx")
 
23883
+                       (SI "lwarx")
 
23884
+                       (DI "ldarx")
 
23885
+                       (TI "lqarx")])
 
23886
 
 
23887
+(define_mode_attr stcx [(QI "stbcx.")
 
23888
+                       (HI "sthcx.")
 
23889
+                       (SI "stwcx.")
 
23890
+                       (DI "stdcx.")
 
23891
+                       (TI "stqcx.")])
 
23892
+
 
23893
 (define_code_iterator FETCHOP [plus minus ior xor and])
 
23894
 (define_code_attr fetchop_name
 
23895
   [(plus "add") (minus "sub") (ior "or") (xor "xor") (and "and")])
 
23896
 (define_code_attr fetchop_pred
 
23897
-  [(plus "add_operand") (minus "gpc_reg_operand")
 
23898
+  [(plus "add_operand") (minus "int_reg_operand")
 
23899
    (ior "logical_operand") (xor "logical_operand") (and "and_operand")])
 
23900
 
 
23901
 (define_expand "mem_thread_fence"
 
23902
@@ -129,16 +138,7 @@
 
23903
     case MEMMODEL_CONSUME:
 
23904
     case MEMMODEL_ACQUIRE:
 
23905
     case MEMMODEL_SEQ_CST:
 
23906
-      if (GET_MODE (operands[0]) == QImode)
 
23907
-       emit_insn (gen_loadsync_qi (operands[0]));
 
23908
-      else if (GET_MODE (operands[0]) == HImode)
 
23909
-       emit_insn (gen_loadsync_hi (operands[0]));
 
23910
-      else if (GET_MODE (operands[0]) == SImode)
 
23911
-       emit_insn (gen_loadsync_si (operands[0]));
 
23912
-      else if (GET_MODE (operands[0]) == DImode)
 
23913
-       emit_insn (gen_loadsync_di (operands[0]));
 
23914
-      else
 
23915
-       gcc_unreachable ();
 
23916
+      emit_insn (gen_loadsync_<mode> (operands[0]));
 
23917
       break;
 
23918
     default:
 
23919
       gcc_unreachable ();
 
23920
@@ -170,35 +170,109 @@
 
23921
   DONE;
 
23922
 })
 
23923
 
 
23924
-;; ??? Power ISA 2.06B says that there *is* a load-{byte,half}-and-reserve
 
23925
-;; opcode that is "phased-in".  Not implemented as of Power7, so not yet used,
 
23926
-;; but let's prepare the macros anyway.
 
23927
+;; Any supported integer mode that has atomic l<x>arx/st<x>cx. instrucitons
 
23928
+;; other than the quad memory operations, which have special restrictions.
 
23929
+;; Byte/halfword atomic instructions were added in ISA 2.06B, but were phased
 
23930
+;; in and did not show up until power8.  TImode atomic lqarx/stqcx. require
 
23931
+;; special handling due to even/odd register requirements.
 
23932
+(define_mode_iterator ATOMIC [(QI "TARGET_SYNC_HI_QI")
 
23933
+                             (HI "TARGET_SYNC_HI_QI")
 
23934
+                             SI
 
23935
+                             (DI "TARGET_POWERPC64")])
 
23936
 
 
23937
-(define_mode_iterator ATOMIC    [SI (DI "TARGET_POWERPC64")])
 
23938
+;; Types that we should provide atomic instructions for.
 
23939
 
 
23940
+(define_mode_iterator AINT [QI
 
23941
+                           HI
 
23942
+                           SI
 
23943
+                           (DI "TARGET_POWERPC64")
 
23944
+                           (TI "TARGET_SYNC_TI")])
 
23945
+
 
23946
 (define_insn "load_locked<mode>"
 
23947
-  [(set (match_operand:ATOMIC 0 "gpc_reg_operand" "=r")
 
23948
+  [(set (match_operand:ATOMIC 0 "int_reg_operand" "=r")
 
23949
        (unspec_volatile:ATOMIC
 
23950
          [(match_operand:ATOMIC 1 "memory_operand" "Z")] UNSPECV_LL))]
 
23951
   ""
 
23952
   "<larx> %0,%y1"
 
23953
   [(set_attr "type" "load_l")])
 
23954
 
 
23955
+(define_insn "load_locked<QHI:mode>_si"
 
23956
+  [(set (match_operand:SI 0 "int_reg_operand" "=r")
 
23957
+       (unspec_volatile:SI
 
23958
+         [(match_operand:QHI 1 "memory_operand" "Z")] UNSPECV_LL))]
 
23959
+  "TARGET_SYNC_HI_QI"
 
23960
+  "<QHI:larx> %0,%y1"
 
23961
+  [(set_attr "type" "load_l")])
 
23962
+
 
23963
+;; Use PTImode to get even/odd register pairs
 
23964
+(define_expand "load_lockedti"
 
23965
+  [(use (match_operand:TI 0 "quad_int_reg_operand" ""))
 
23966
+   (use (match_operand:TI 1 "memory_operand" ""))]
 
23967
+  "TARGET_SYNC_TI"
 
23968
+{
 
23969
+  /* Use a temporary register to force getting an even register for the
 
23970
+     lqarx/stqcrx. instructions.  Normal optimizations will eliminate this
 
23971
+     extra copy.  */
 
23972
+  rtx pti = gen_reg_rtx (PTImode);
 
23973
+  emit_insn (gen_load_lockedpti (pti, operands[1]));
 
23974
+  emit_move_insn (operands[0], gen_lowpart (TImode, pti));
 
23975
+  DONE;
 
23976
+})
 
23977
+
 
23978
+(define_insn "load_lockedpti"
 
23979
+  [(set (match_operand:PTI 0 "quad_int_reg_operand" "=&r")
 
23980
+       (unspec_volatile:PTI
 
23981
+         [(match_operand:TI 1 "memory_operand" "Z")] UNSPECV_LL))]
 
23982
+  "TARGET_SYNC_TI
 
23983
+   && !reg_mentioned_p (operands[0], operands[1])
 
23984
+   && quad_int_reg_operand (operands[0], PTImode)"
 
23985
+  "lqarx %0,%y1"
 
23986
+  [(set_attr "type" "load_l")])
 
23987
+
 
23988
 (define_insn "store_conditional<mode>"
 
23989
   [(set (match_operand:CC 0 "cc_reg_operand" "=x")
 
23990
        (unspec_volatile:CC [(const_int 0)] UNSPECV_SC))
 
23991
    (set (match_operand:ATOMIC 1 "memory_operand" "=Z")
 
23992
-       (match_operand:ATOMIC 2 "gpc_reg_operand" "r"))]
 
23993
+       (match_operand:ATOMIC 2 "int_reg_operand" "r"))]
 
23994
   ""
 
23995
   "<stcx> %2,%y1"
 
23996
   [(set_attr "type" "store_c")])
 
23997
 
 
23998
+(define_expand "store_conditionalti"
 
23999
+  [(use (match_operand:CC 0 "cc_reg_operand" ""))
 
24000
+   (use (match_operand:TI 1 "memory_operand" ""))
 
24001
+   (use (match_operand:TI 2 "quad_int_reg_operand" ""))]
 
24002
+  "TARGET_SYNC_TI"
 
24003
+{
 
24004
+  rtx op0 = operands[0];
 
24005
+  rtx op1 = operands[1];
 
24006
+  rtx op2 = operands[2];
 
24007
+  rtx pti_op1 = change_address (op1, PTImode, XEXP (op1, 0));
 
24008
+  rtx pti_op2 = gen_reg_rtx (PTImode);
 
24009
+
 
24010
+  /* Use a temporary register to force getting an even register for the
 
24011
+     lqarx/stqcrx. instructions.  Normal optimizations will eliminate this
 
24012
+     extra copy.  */
 
24013
+  emit_move_insn (pti_op2, gen_lowpart (PTImode, op2));
 
24014
+  emit_insn (gen_store_conditionalpti (op0, pti_op1, pti_op2));
 
24015
+  DONE;
 
24016
+})
 
24017
+
 
24018
+(define_insn "store_conditionalpti"
 
24019
+  [(set (match_operand:CC 0 "cc_reg_operand" "=x")
 
24020
+       (unspec_volatile:CC [(const_int 0)] UNSPECV_SC))
 
24021
+   (set (match_operand:PTI 1 "memory_operand" "=Z")
 
24022
+       (match_operand:PTI 2 "quad_int_reg_operand" "r"))]
 
24023
+  "TARGET_SYNC_TI && quad_int_reg_operand (operands[2], PTImode)"
 
24024
+  "stqcx. %2,%y1"
 
24025
+  [(set_attr "type" "store_c")])
 
24026
+
 
24027
 (define_expand "atomic_compare_and_swap<mode>"
 
24028
-  [(match_operand:SI 0 "gpc_reg_operand" "")           ;; bool out
 
24029
-   (match_operand:INT1 1 "gpc_reg_operand" "")         ;; val out
 
24030
-   (match_operand:INT1 2 "memory_operand" "")          ;; memory
 
24031
-   (match_operand:INT1 3 "reg_or_short_operand" "")    ;; expected
 
24032
-   (match_operand:INT1 4 "gpc_reg_operand" "")         ;; desired
 
24033
+  [(match_operand:SI 0 "int_reg_operand" "")           ;; bool out
 
24034
+   (match_operand:AINT 1 "int_reg_operand" "")         ;; val out
 
24035
+   (match_operand:AINT 2 "memory_operand" "")          ;; memory
 
24036
+   (match_operand:AINT 3 "reg_or_short_operand" "")    ;; expected
 
24037
+   (match_operand:AINT 4 "int_reg_operand" "")         ;; desired
 
24038
    (match_operand:SI 5 "const_int_operand" "")         ;; is_weak
 
24039
    (match_operand:SI 6 "const_int_operand" "")         ;; model succ
 
24040
    (match_operand:SI 7 "const_int_operand" "")]                ;; model fail
 
24041
@@ -209,9 +283,9 @@
 
24042
 })
 
24043
 
 
24044
 (define_expand "atomic_exchange<mode>"
 
24045
-  [(match_operand:INT1 0 "gpc_reg_operand" "")         ;; output
 
24046
-   (match_operand:INT1 1 "memory_operand" "")          ;; memory
 
24047
-   (match_operand:INT1 2 "gpc_reg_operand" "")         ;; input
 
24048
+  [(match_operand:AINT 0 "int_reg_operand" "")         ;; output
 
24049
+   (match_operand:AINT 1 "memory_operand" "")          ;; memory
 
24050
+   (match_operand:AINT 2 "int_reg_operand" "")         ;; input
 
24051
    (match_operand:SI 3 "const_int_operand" "")]                ;; model
 
24052
   ""
 
24053
 {
 
24054
@@ -220,9 +294,9 @@
 
24055
 })
 
24056
 
 
24057
 (define_expand "atomic_<fetchop_name><mode>"
 
24058
-  [(match_operand:INT1 0 "memory_operand" "")          ;; memory
 
24059
-   (FETCHOP:INT1 (match_dup 0)
 
24060
-     (match_operand:INT1 1 "<fetchop_pred>" ""))       ;; operand
 
24061
+  [(match_operand:AINT 0 "memory_operand" "")          ;; memory
 
24062
+   (FETCHOP:AINT (match_dup 0)
 
24063
+     (match_operand:AINT 1 "<fetchop_pred>" ""))       ;; operand
 
24064
    (match_operand:SI 2 "const_int_operand" "")]                ;; model
 
24065
   ""
 
24066
 {
 
24067
@@ -232,8 +306,8 @@
 
24068
 })
 
24069
 
 
24070
 (define_expand "atomic_nand<mode>"
 
24071
-  [(match_operand:INT1 0 "memory_operand" "")          ;; memory
 
24072
-   (match_operand:INT1 1 "gpc_reg_operand" "")         ;; operand
 
24073
+  [(match_operand:AINT 0 "memory_operand" "")          ;; memory
 
24074
+   (match_operand:AINT 1 "int_reg_operand" "")         ;; operand
 
24075
    (match_operand:SI 2 "const_int_operand" "")]                ;; model
 
24076
   ""
 
24077
 {
 
24078
@@ -243,10 +317,10 @@
 
24079
 })
 
24080
 
 
24081
 (define_expand "atomic_fetch_<fetchop_name><mode>"
 
24082
-  [(match_operand:INT1 0 "gpc_reg_operand" "")         ;; output
 
24083
-   (match_operand:INT1 1 "memory_operand" "")          ;; memory
 
24084
-   (FETCHOP:INT1 (match_dup 1)
 
24085
-     (match_operand:INT1 2 "<fetchop_pred>" ""))       ;; operand
 
24086
+  [(match_operand:AINT 0 "int_reg_operand" "")         ;; output
 
24087
+   (match_operand:AINT 1 "memory_operand" "")          ;; memory
 
24088
+   (FETCHOP:AINT (match_dup 1)
 
24089
+     (match_operand:AINT 2 "<fetchop_pred>" ""))       ;; operand
 
24090
    (match_operand:SI 3 "const_int_operand" "")]                ;; model
 
24091
   ""
 
24092
 { 
 
24093
@@ -256,9 +330,9 @@
 
24094
 })
 
24095
 
 
24096
 (define_expand "atomic_fetch_nand<mode>"
 
24097
-  [(match_operand:INT1 0 "gpc_reg_operand" "")         ;; output
 
24098
-   (match_operand:INT1 1 "memory_operand" "")          ;; memory
 
24099
-   (match_operand:INT1 2 "gpc_reg_operand" "")         ;; operand
 
24100
+  [(match_operand:AINT 0 "int_reg_operand" "")         ;; output
 
24101
+   (match_operand:AINT 1 "memory_operand" "")          ;; memory
 
24102
+   (match_operand:AINT 2 "int_reg_operand" "")         ;; operand
 
24103
    (match_operand:SI 3 "const_int_operand" "")]                ;; model
 
24104
   ""
 
24105
 {
 
24106
@@ -268,10 +342,10 @@
 
24107
 })
 
24108
 
 
24109
 (define_expand "atomic_<fetchop_name>_fetch<mode>"
 
24110
-  [(match_operand:INT1 0 "gpc_reg_operand" "")         ;; output
 
24111
-   (match_operand:INT1 1 "memory_operand" "")          ;; memory
 
24112
-   (FETCHOP:INT1 (match_dup 1)
 
24113
-     (match_operand:INT1 2 "<fetchop_pred>" ""))       ;; operand
 
24114
+  [(match_operand:AINT 0 "int_reg_operand" "")         ;; output
 
24115
+   (match_operand:AINT 1 "memory_operand" "")          ;; memory
 
24116
+   (FETCHOP:AINT (match_dup 1)
 
24117
+     (match_operand:AINT 2 "<fetchop_pred>" ""))       ;; operand
 
24118
    (match_operand:SI 3 "const_int_operand" "")]                ;; model
 
24119
   ""
 
24120
 {
 
24121
@@ -281,9 +355,9 @@
 
24122
 })
 
24123
 
 
24124
 (define_expand "atomic_nand_fetch<mode>"
 
24125
-  [(match_operand:INT1 0 "gpc_reg_operand" "")         ;; output
 
24126
-   (match_operand:INT1 1 "memory_operand" "")          ;; memory
 
24127
-   (match_operand:INT1 2 "gpc_reg_operand" "")         ;; operand
 
24128
+  [(match_operand:AINT 0 "int_reg_operand" "")         ;; output
 
24129
+   (match_operand:AINT 1 "memory_operand" "")          ;; memory
 
24130
+   (match_operand:AINT 2 "int_reg_operand" "")         ;; operand
 
24131
    (match_operand:SI 3 "const_int_operand" "")]                ;; model
 
24132
   ""
 
24133
 {
 
24134
--- a/src/gcc/config/rs6000/crypto.md
 
24135
+++ b/src/gcc/config/rs6000/crypto.md
 
24136
@@ -0,0 +1,101 @@
 
24137
+;; Cryptographic instructions added in ISA 2.07
 
24138
+;; Copyright (C) 2012-2013 Free Software Foundation, Inc.
 
24139
+;; Contributed by Michael Meissner (meissner@linux.vnet.ibm.com)
 
24140
+
 
24141
+;; This file is part of GCC.
 
24142
+
 
24143
+;; GCC is free software; you can redistribute it and/or modify it
 
24144
+;; under the terms of the GNU General Public License as published
 
24145
+;; by the Free Software Foundation; either version 3, or (at your
 
24146
+;; option) any later version.
 
24147
+
 
24148
+;; GCC is distributed in the hope that it will be useful, but WITHOUT
 
24149
+;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 
24150
+;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
 
24151
+;; License for more details.
 
24152
+
 
24153
+;; You should have received a copy of the GNU General Public License
 
24154
+;; along with GCC; see the file COPYING3.  If not see
 
24155
+;; <http://www.gnu.org/licenses/>.
 
24156
+
 
24157
+(define_c_enum "unspec"
 
24158
+  [UNSPEC_VCIPHER
 
24159
+   UNSPEC_VNCIPHER
 
24160
+   UNSPEC_VCIPHERLAST
 
24161
+   UNSPEC_VNCIPHERLAST
 
24162
+   UNSPEC_VSBOX
 
24163
+   UNSPEC_VSHASIGMA
 
24164
+   UNSPEC_VPERMXOR
 
24165
+   UNSPEC_VPMSUM])
 
24166
+
 
24167
+;; Iterator for VPMSUM/VPERMXOR
 
24168
+(define_mode_iterator CR_mode [V16QI V8HI V4SI V2DI])
 
24169
+
 
24170
+(define_mode_attr CR_char [(V16QI "b")
 
24171
+                          (V8HI  "h")
 
24172
+                          (V4SI  "w")
 
24173
+                          (V2DI  "d")])
 
24174
+
 
24175
+;; Iterator for VSHASIGMAD/VSHASIGMAW
 
24176
+(define_mode_iterator CR_hash [V4SI V2DI])
 
24177
+
 
24178
+;; Iterator for the other crypto functions
 
24179
+(define_int_iterator CR_code   [UNSPEC_VCIPHER
 
24180
+                               UNSPEC_VNCIPHER
 
24181
+                               UNSPEC_VCIPHERLAST
 
24182
+                               UNSPEC_VNCIPHERLAST])
 
24183
+
 
24184
+(define_int_attr CR_insn [(UNSPEC_VCIPHER      "vcipher")
 
24185
+                         (UNSPEC_VNCIPHER     "vncipher")
 
24186
+                         (UNSPEC_VCIPHERLAST  "vcipherlast")
 
24187
+                         (UNSPEC_VNCIPHERLAST "vncipherlast")])
 
24188
+
 
24189
+;; 2 operand crypto instructions
 
24190
+(define_insn "crypto_<CR_insn>"
 
24191
+  [(set (match_operand:V2DI 0 "register_operand" "=v")
 
24192
+       (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "v")
 
24193
+                     (match_operand:V2DI 2 "register_operand" "v")]
 
24194
+                    CR_code))]
 
24195
+  "TARGET_CRYPTO"
 
24196
+  "<CR_insn> %0,%1,%2"
 
24197
+  [(set_attr "type" "crypto")])
 
24198
+
 
24199
+(define_insn "crypto_vpmsum<CR_char>"
 
24200
+  [(set (match_operand:CR_mode 0 "register_operand" "=v")
 
24201
+       (unspec:CR_mode [(match_operand:CR_mode 1 "register_operand" "v")
 
24202
+                        (match_operand:CR_mode 2 "register_operand" "v")]
 
24203
+                       UNSPEC_VPMSUM))]
 
24204
+  "TARGET_CRYPTO"
 
24205
+  "vpmsum<CR_char> %0,%1,%2"
 
24206
+  [(set_attr "type" "crypto")])
 
24207
+
 
24208
+;; 3 operand crypto instructions
 
24209
+(define_insn "crypto_vpermxor_<mode>"
 
24210
+  [(set (match_operand:CR_mode 0 "register_operand" "=v")
 
24211
+       (unspec:CR_mode [(match_operand:CR_mode 1 "register_operand" "v")
 
24212
+                        (match_operand:CR_mode 2 "register_operand" "v")
 
24213
+                        (match_operand:CR_mode 3 "register_operand" "v")]
 
24214
+                       UNSPEC_VPERMXOR))]
 
24215
+  "TARGET_CRYPTO"
 
24216
+  "vpermxor %0,%1,%2,%3"
 
24217
+  [(set_attr "type" "crypto")])
 
24218
+
 
24219
+;; 1 operand crypto instruction
 
24220
+(define_insn "crypto_vsbox"
 
24221
+  [(set (match_operand:V2DI 0 "register_operand" "=v")
 
24222
+       (unspec:V2DI [(match_operand:V2DI 1 "register_operand" "v")]
 
24223
+                    UNSPEC_VSBOX))]
 
24224
+  "TARGET_CRYPTO"
 
24225
+  "vsbox %0,%1"
 
24226
+  [(set_attr "type" "crypto")])
 
24227
+
 
24228
+;; Hash crypto instructions
 
24229
+(define_insn "crypto_vshasigma<CR_char>"
 
24230
+  [(set (match_operand:CR_hash 0 "register_operand" "=v")
 
24231
+       (unspec:CR_hash [(match_operand:CR_hash 1 "register_operand" "v")
 
24232
+                        (match_operand:SI 2 "const_0_to_1_operand" "n")
 
24233
+                        (match_operand:SI 3 "const_0_to_15_operand" "n")]
 
24234
+                       UNSPEC_VSHASIGMA))]
 
24235
+  "TARGET_CRYPTO"
 
24236
+  "vshasigma<CR_char> %0,%1,%2,%3"
 
24237
+  [(set_attr "type" "crypto")])
 
24238
--- a/src/gcc/config/rs6000/rs6000.md
 
24239
+++ b/src/gcc/config/rs6000/rs6000.md
 
24240
@@ -25,10 +25,14 @@
 
24241
 ;;
 
24242
 
 
24243
 (define_constants
 
24244
-  [(STACK_POINTER_REGNUM       1)
 
24245
+  [(FIRST_GPR_REGNO            0)
 
24246
+   (STACK_POINTER_REGNUM       1)
 
24247
    (TOC_REGNUM                 2)
 
24248
    (STATIC_CHAIN_REGNUM                11)
 
24249
    (HARD_FRAME_POINTER_REGNUM  31)
 
24250
+   (LAST_GPR_REGNO             31)
 
24251
+   (FIRST_FPR_REGNO            32)
 
24252
+   (LAST_FPR_REGNO             63)
 
24253
    (LR_REGNO                   65)
 
24254
    (CTR_REGNO                  66)
 
24255
    (ARG_POINTER_REGNUM         67)
 
24256
@@ -49,18 +53,9 @@
 
24257
    (SPE_ACC_REGNO              111)
 
24258
    (SPEFSCR_REGNO              112)
 
24259
    (FRAME_POINTER_REGNUM       113)
 
24260
-
 
24261
-   ; ABI defined stack offsets for storing the TOC pointer with AIX calls.
 
24262
-   (TOC_SAVE_OFFSET_32BIT      20)
 
24263
-   (TOC_SAVE_OFFSET_64BIT      40)
 
24264
-
 
24265
-   ; Function TOC offset in the AIX function descriptor.
 
24266
-   (AIX_FUNC_DESC_TOC_32BIT    4)
 
24267
-   (AIX_FUNC_DESC_TOC_64BIT    8)
 
24268
-
 
24269
-   ; Static chain offset in the AIX function descriptor.
 
24270
-   (AIX_FUNC_DESC_SC_32BIT     8)
 
24271
-   (AIX_FUNC_DESC_SC_64BIT     16)
 
24272
+   (TFHAR_REGNO                        114)
 
24273
+   (TFIAR_REGNO                        115)
 
24274
+   (TEXASR_REGNO               116)
 
24275
   ])
 
24276
 
 
24277
 ;;
 
24278
@@ -123,6 +118,12 @@
 
24279
    UNSPEC_LFIWZX
 
24280
    UNSPEC_FCTIWUZ
 
24281
    UNSPEC_GRP_END_NOP
 
24282
+   UNSPEC_P8V_FMRGOW
 
24283
+   UNSPEC_P8V_MTVSRWZ
 
24284
+   UNSPEC_P8V_RELOAD_FROM_GPR
 
24285
+   UNSPEC_P8V_MTVSRD
 
24286
+   UNSPEC_P8V_XXPERMDI
 
24287
+   UNSPEC_P8V_RELOAD_FROM_VSX
 
24288
   ])
 
24289
 
 
24290
 ;;
 
24291
@@ -142,7 +143,7 @@
 
24292
 
 
24293
 ;; Define an insn type attribute.  This is used in function unit delay
 
24294
 ;; computations.
 
24295
-(define_attr "type" "integer,two,three,load,load_ext,load_ext_u,load_ext_ux,load_ux,load_u,store,store_ux,store_u,fpload,fpload_ux,fpload_u,fpstore,fpstore_ux,fpstore_u,vecload,vecstore,imul,imul2,imul3,lmul,idiv,ldiv,insert_word,branch,cmp,fast_compare,compare,var_delayed_compare,delayed_compare,imul_compare,lmul_compare,fpcompare,cr_logical,delayed_cr,mfcr,mfcrf,mtcr,mfjmpr,mtjmpr,fp,fpsimple,dmul,sdiv,ddiv,ssqrt,dsqrt,jmpreg,brinc,vecsimple,veccomplex,vecdiv,veccmp,veccmpsimple,vecperm,vecfloat,vecfdiv,vecdouble,isync,sync,load_l,store_c,shift,trap,insert_dword,var_shift_rotate,cntlz,exts,mffgpr,mftgpr,isel,popcnt"
 
24296
+(define_attr "type" "integer,two,three,load,load_ext,load_ext_u,load_ext_ux,load_ux,load_u,store,store_ux,store_u,fpload,fpload_ux,fpload_u,fpstore,fpstore_ux,fpstore_u,vecload,vecstore,imul,imul2,imul3,lmul,idiv,ldiv,insert_word,branch,cmp,fast_compare,compare,var_delayed_compare,delayed_compare,imul_compare,lmul_compare,fpcompare,cr_logical,delayed_cr,mfcr,mfcrf,mtcr,mfjmpr,mtjmpr,fp,fpsimple,dmul,sdiv,ddiv,ssqrt,dsqrt,jmpreg,brinc,vecsimple,veccomplex,vecdiv,veccmp,veccmpsimple,vecperm,vecfloat,vecfdiv,vecdouble,isync,sync,load_l,store_c,shift,trap,insert_dword,var_shift_rotate,cntlz,exts,mffgpr,mftgpr,isel,popcnt,crypto,htm"
 
24297
   (const_string "integer"))
 
24298
 
 
24299
 ;; Define floating point instruction sub-types for use with Xfpu.md
 
24300
@@ -164,7 +165,7 @@
 
24301
 ;; Processor type -- this attribute must exactly match the processor_type
 
24302
 ;; enumeration in rs6000.h.
 
24303
 
 
24304
-(define_attr "cpu" "rs64a,mpccore,ppc403,ppc405,ppc440,ppc476,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,ppc8548,ppce300c2,ppce300c3,ppce500mc,ppce500mc64,ppce5500,ppce6500,power4,power5,power6,power7,cell,ppca2,titan"
 
24305
+(define_attr "cpu" "rs64a,mpccore,ppc403,ppc405,ppc440,ppc476,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,ppc8548,ppce300c2,ppce300c3,ppce500mc,ppce500mc64,ppce5500,ppce6500,power4,power5,power6,power7,cell,ppca2,titan,power8"
 
24306
   (const (symbol_ref "rs6000_cpu_attr")))
 
24307
 
 
24308
 
 
24309
@@ -197,6 +198,7 @@
 
24310
 (include "power5.md")
 
24311
 (include "power6.md")
 
24312
 (include "power7.md")
 
24313
+(include "power8.md")
 
24314
 (include "cell.md")
 
24315
 (include "xfpu.md")
 
24316
 (include "a2.md")
 
24317
@@ -215,7 +217,7 @@
 
24318
 (define_mode_iterator GPR [SI (DI "TARGET_POWERPC64")])
 
24319
 
 
24320
 ; Any supported integer mode.
 
24321
-(define_mode_iterator INT [QI HI SI DI TI])
 
24322
+(define_mode_iterator INT [QI HI SI DI TI PTI])
 
24323
 
 
24324
 ; Any supported integer mode that fits in one register.
 
24325
 (define_mode_iterator INT1 [QI HI SI (DI "TARGET_POWERPC64")])
 
24326
@@ -223,6 +225,12 @@
 
24327
 ; extend modes for DImode
 
24328
 (define_mode_iterator QHSI [QI HI SI])
 
24329
 
 
24330
+; QImode or HImode for small atomic ops
 
24331
+(define_mode_iterator QHI [QI HI])
 
24332
+
 
24333
+; HImode or SImode for sign extended fusion ops
 
24334
+(define_mode_iterator HSI [HI SI])
 
24335
+
 
24336
 ; SImode or DImode, even if DImode doesn't fit in GPRs.
 
24337
 (define_mode_iterator SDI [SI DI])
 
24338
 
 
24339
@@ -230,6 +238,10 @@
 
24340
 ; (one with a '.') will compare; and the size used for arithmetic carries.
 
24341
 (define_mode_iterator P [(SI "TARGET_32BIT") (DI "TARGET_64BIT")])
 
24342
 
 
24343
+; Iterator to add PTImode along with TImode (TImode can go in VSX registers,
 
24344
+; PTImode is GPR only)
 
24345
+(define_mode_iterator TI2 [TI PTI])
 
24346
+
 
24347
 ; Any hardware-supported floating-point mode
 
24348
 (define_mode_iterator FP [
 
24349
   (SF "TARGET_HARD_FLOAT 
 
24350
@@ -253,6 +265,49 @@
 
24351
   (V2DF "VECTOR_UNIT_ALTIVEC_OR_VSX_P (V2DFmode)")
 
24352
   ])
 
24353
 
 
24354
+; Floating point move iterators to combine binary and decimal moves
 
24355
+(define_mode_iterator FMOVE32 [SF SD])
 
24356
+(define_mode_iterator FMOVE64 [DF DD])
 
24357
+(define_mode_iterator FMOVE64X [DI DF DD])
 
24358
+(define_mode_iterator FMOVE128 [(TF "!TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128")
 
24359
+                               (TD "TARGET_HARD_FLOAT && TARGET_FPRS")])
 
24360
+
 
24361
+; Iterators for 128 bit types for direct move
 
24362
+(define_mode_iterator FMOVE128_GPR [(TI    "TARGET_VSX_TIMODE")
 
24363
+                                   (V16QI "")
 
24364
+                                   (V8HI  "")
 
24365
+                                   (V4SI  "")
 
24366
+                                   (V4SF  "")
 
24367
+                                   (V2DI  "")
 
24368
+                                   (V2DF  "")])
 
24369
+
 
24370
+; Whether a floating point move is ok, don't allow SD without hardware FP
 
24371
+(define_mode_attr fmove_ok [(SF "")
 
24372
+                           (DF "")
 
24373
+                           (SD "TARGET_HARD_FLOAT && TARGET_FPRS")
 
24374
+                           (DD "")])
 
24375
+
 
24376
+; Convert REAL_VALUE to the appropriate bits
 
24377
+(define_mode_attr real_value_to_target [(SF "REAL_VALUE_TO_TARGET_SINGLE")
 
24378
+                                       (DF "REAL_VALUE_TO_TARGET_DOUBLE")
 
24379
+                                       (SD "REAL_VALUE_TO_TARGET_DECIMAL32")
 
24380
+                                       (DD "REAL_VALUE_TO_TARGET_DECIMAL64")])
 
24381
+
 
24382
+; Definitions for load to 32-bit fpr register
 
24383
+(define_mode_attr f32_lr [(SF "f")              (SD "wz")])
 
24384
+(define_mode_attr f32_lm [(SF "m")              (SD "Z")])
 
24385
+(define_mode_attr f32_li [(SF "lfs%U1%X1 %0,%1") (SD "lfiwzx %0,%y1")])
 
24386
+(define_mode_attr f32_lv [(SF "lxsspx %x0,%y1")         (SD "lxsiwzx %x0,%y1")])
 
24387
+
 
24388
+; Definitions for store from 32-bit fpr register
 
24389
+(define_mode_attr f32_sr [(SF "f")               (SD "wx")])
 
24390
+(define_mode_attr f32_sm [(SF "m")               (SD "Z")])
 
24391
+(define_mode_attr f32_si [(SF "stfs%U0%X0 %1,%0") (SD "stfiwx %1,%y0")])
 
24392
+(define_mode_attr f32_sv [(SF "stxsspx %x1,%y0")  (SD "stxsiwzx %x1,%y0")])
 
24393
+
 
24394
+; Definitions for 32-bit fpr direct move
 
24395
+(define_mode_attr f32_dm [(SF "wn") (SD "wm")])
 
24396
+
 
24397
 ; These modes do not fit in integer registers in 32-bit mode.
 
24398
 ; but on e500v2, the gpr are 64 bit registers
 
24399
 (define_mode_iterator DIFD [DI (DF "!TARGET_E500_DOUBLE") DD])
 
24400
@@ -263,6 +318,25 @@
 
24401
 ; Iterator for just SF/DF
 
24402
 (define_mode_iterator SFDF [SF DF])
 
24403
 
 
24404
+; SF/DF suffix for traditional floating instructions
 
24405
+(define_mode_attr Ftrad                [(SF "s") (DF "")])
 
24406
+
 
24407
+; SF/DF suffix for VSX instructions
 
24408
+(define_mode_attr Fvsx         [(SF "sp") (DF  "dp")])
 
24409
+
 
24410
+; SF/DF constraint for arithmetic on traditional floating point registers
 
24411
+(define_mode_attr Ff           [(SF "f") (DF "d")])
 
24412
+
 
24413
+; SF/DF constraint for arithmetic on VSX registers
 
24414
+(define_mode_attr Fv           [(SF "wy") (DF "ws")])
 
24415
+
 
24416
+; s/d suffix for things like fp_addsub_s/fp_addsub_d
 
24417
+(define_mode_attr Fs           [(SF "s")  (DF "d")])
 
24418
+
 
24419
+; FRE/FRES support
 
24420
+(define_mode_attr Ffre         [(SF "fres") (DF "fre")])
 
24421
+(define_mode_attr FFRE         [(SF "FRES") (DF "FRE")])
 
24422
+
 
24423
 ; Conditional returns.
 
24424
 (define_code_iterator any_return [return simple_return])
 
24425
 (define_code_attr return_pred [(return "direct_return ()")
 
24426
@@ -271,7 +345,14 @@
 
24427
 
 
24428
 ; Various instructions that come in SI and DI forms.
 
24429
 ; A generic w/d attribute, for things like cmpw/cmpd.
 
24430
-(define_mode_attr wd [(QI "b") (HI "h") (SI "w") (DI "d")])
 
24431
+(define_mode_attr wd [(QI    "b")
 
24432
+                     (HI    "h")
 
24433
+                     (SI    "w")
 
24434
+                     (DI    "d")
 
24435
+                     (V16QI "b")
 
24436
+                     (V8HI  "h")
 
24437
+                     (V4SI  "w")
 
24438
+                     (V2DI  "d")])
 
24439
 
 
24440
 ; DImode bits
 
24441
 (define_mode_attr dbits [(QI "56") (HI "48") (SI "32")])
 
24442
@@ -311,6 +392,77 @@
 
24443
 
 
24444
 (define_mode_attr TARGET_FLOAT [(SF "TARGET_SINGLE_FLOAT")
 
24445
                                (DF "TARGET_DOUBLE_FLOAT")])
 
24446
+
 
24447
+;; Mode iterator for logical operations on 128-bit types
 
24448
+(define_mode_iterator BOOL_128         [TI
 
24449
+                                        PTI
 
24450
+                                        (V16QI "TARGET_ALTIVEC")
 
24451
+                                        (V8HI  "TARGET_ALTIVEC")
 
24452
+                                        (V4SI  "TARGET_ALTIVEC")
 
24453
+                                        (V4SF  "TARGET_ALTIVEC")
 
24454
+                                        (V2DI  "TARGET_ALTIVEC")
 
24455
+                                        (V2DF  "TARGET_ALTIVEC")])
 
24456
+
 
24457
+;; For the GPRs we use 3 constraints for register outputs, two that are the
 
24458
+;; same as the output register, and a third where the output register is an
 
24459
+;; early clobber, so we don't have to deal with register overlaps.  For the
 
24460
+;; vector types, we prefer to use the vector registers.  For TI mode, allow
 
24461
+;; either.
 
24462
+
 
24463
+;; Mode attribute for boolean operation register constraints for output
 
24464
+(define_mode_attr BOOL_REGS_OUTPUT     [(TI    "&r,r,r,wa,v")
 
24465
+                                        (PTI   "&r,r,r")
 
24466
+                                        (V16QI "wa,v,&?r,?r,?r")
 
24467
+                                        (V8HI  "wa,v,&?r,?r,?r")
 
24468
+                                        (V4SI  "wa,v,&?r,?r,?r")
 
24469
+                                        (V4SF  "wa,v,&?r,?r,?r")
 
24470
+                                        (V2DI  "wa,v,&?r,?r,?r")
 
24471
+                                        (V2DF  "wa,v,&?r,?r,?r")])
 
24472
+
 
24473
+;; Mode attribute for boolean operation register constraints for operand1
 
24474
+(define_mode_attr BOOL_REGS_OP1                [(TI    "r,0,r,wa,v")
 
24475
+                                        (PTI   "r,0,r")
 
24476
+                                        (V16QI "wa,v,r,0,r")
 
24477
+                                        (V8HI  "wa,v,r,0,r")
 
24478
+                                        (V4SI  "wa,v,r,0,r")
 
24479
+                                        (V4SF  "wa,v,r,0,r")
 
24480
+                                        (V2DI  "wa,v,r,0,r")
 
24481
+                                        (V2DF  "wa,v,r,0,r")])
 
24482
+
 
24483
+;; Mode attribute for boolean operation register constraints for operand2
 
24484
+(define_mode_attr BOOL_REGS_OP2                [(TI    "r,r,0,wa,v")
 
24485
+                                        (PTI   "r,r,0")
 
24486
+                                        (V16QI "wa,v,r,r,0")
 
24487
+                                        (V8HI  "wa,v,r,r,0")
 
24488
+                                        (V4SI  "wa,v,r,r,0")
 
24489
+                                        (V4SF  "wa,v,r,r,0")
 
24490
+                                        (V2DI  "wa,v,r,r,0")
 
24491
+                                        (V2DF  "wa,v,r,r,0")])
 
24492
+
 
24493
+;; Mode attribute for boolean operation register constraints for operand1
 
24494
+;; for one_cmpl.  To simplify things, we repeat the constraint where 0
 
24495
+;; is used for operand1 or operand2
 
24496
+(define_mode_attr BOOL_REGS_UNARY      [(TI    "r,0,0,wa,v")
 
24497
+                                        (PTI   "r,0,0")
 
24498
+                                        (V16QI "wa,v,r,0,0")
 
24499
+                                        (V8HI  "wa,v,r,0,0")
 
24500
+                                        (V4SI  "wa,v,r,0,0")
 
24501
+                                        (V4SF  "wa,v,r,0,0")
 
24502
+                                        (V2DI  "wa,v,r,0,0")
 
24503
+                                        (V2DF  "wa,v,r,0,0")])
 
24504
+
 
24505
+;; Mode attribute for the clobber of CC0 for AND expansion.
 
24506
+;; For the 128-bit types, we never do AND immediate, but we need to
 
24507
+;; get the correct number of X's for the number of operands.
 
24508
+(define_mode_attr BOOL_REGS_AND_CR0    [(TI    "X,X,X,X,X")
 
24509
+                                        (PTI   "X,X,X")
 
24510
+                                        (V16QI "X,X,X,X,X")
 
24511
+                                        (V8HI  "X,X,X,X,X")
 
24512
+                                        (V4SI  "X,X,X,X,X")
 
24513
+                                        (V4SF  "X,X,X,X,X")
 
24514
+                                        (V2DI  "X,X,X,X,X")
 
24515
+                                        (V2DF  "X,X,X,X,X")])
 
24516
+
 
24517
 
 
24518
 ;; Start with fixed-point load and store insns.  Here we put only the more
 
24519
 ;; complex forms.  Basic data transfer is done later.
 
24520
@@ -324,11 +476,19 @@
 
24521
 (define_insn "*zero_extend<mode>di2_internal1"
 
24522
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
 
24523
        (zero_extend:DI (match_operand:QHSI 1 "reg_or_mem_operand" "m,r")))]
 
24524
-  "TARGET_POWERPC64"
 
24525
+  "TARGET_POWERPC64 && (<MODE>mode != SImode || !TARGET_LFIWZX)"
 
24526
   "@
 
24527
    l<wd>z%U1%X1 %0,%1
 
24528
    rldicl %0,%1,0,<dbits>"
 
24529
-  [(set_attr "type" "load,*")])
 
24530
+  [(set_attr_alternative "type"
 
24531
+      [(if_then_else
 
24532
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
24533
+        (const_string "load_ux")
 
24534
+        (if_then_else
 
24535
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
24536
+          (const_string "load_u")
 
24537
+          (const_string "load")))
 
24538
+       (const_string "*")])])
 
24539
 
 
24540
 (define_insn "*zero_extend<mode>di2_internal2"
 
24541
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
 
24542
@@ -382,6 +542,29 @@
 
24543
                    (const_int 0)))]
 
24544
   "")
 
24545
 
 
24546
+(define_insn "*zero_extendsidi2_lfiwzx"
 
24547
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,??wm,!wz,!wu")
 
24548
+       (zero_extend:DI (match_operand:SI 1 "reg_or_mem_operand" "m,r,r,Z,Z")))]
 
24549
+  "TARGET_POWERPC64 && TARGET_LFIWZX"
 
24550
+  "@
 
24551
+   lwz%U1%X1 %0,%1
 
24552
+   rldicl %0,%1,0,32
 
24553
+   mtvsrwz %x0,%1
 
24554
+   lfiwzx %0,%y1
 
24555
+   lxsiwzx %x0,%y1"
 
24556
+  [(set_attr_alternative "type"
 
24557
+      [(if_then_else
 
24558
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
24559
+        (const_string "load_ux")
 
24560
+        (if_then_else
 
24561
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
24562
+          (const_string "load_u")
 
24563
+          (const_string "load")))
 
24564
+       (const_string "*")
 
24565
+       (const_string "mffgpr")
 
24566
+       (const_string "fpload")
 
24567
+       (const_string "fpload")])])
 
24568
+
 
24569
 (define_insn "extendqidi2"
 
24570
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
 
24571
        (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
 
24572
@@ -454,7 +637,15 @@
 
24573
   "@
 
24574
    lha%U1%X1 %0,%1
 
24575
    extsh %0,%1"
 
24576
-  [(set_attr "type" "load_ext,exts")])
 
24577
+  [(set_attr_alternative "type"
 
24578
+      [(if_then_else
 
24579
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
24580
+        (const_string "load_ext_ux")
 
24581
+        (if_then_else
 
24582
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
24583
+          (const_string "load_ext_u")
 
24584
+          (const_string "load_ext")))
 
24585
+       (const_string "exts")])])
 
24586
 
 
24587
 (define_insn ""
 
24588
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
 
24589
@@ -521,16 +712,47 @@
 
24590
   "TARGET_POWERPC64"
 
24591
   "")
 
24592
 
 
24593
-(define_insn ""
 
24594
+(define_insn "*extendsidi2_lfiwax"
 
24595
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,??wm,!wl,!wu")
 
24596
+       (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r,r,Z,Z")))]
 
24597
+  "TARGET_POWERPC64 && TARGET_LFIWAX"
 
24598
+  "@
 
24599
+   lwa%U1%X1 %0,%1
 
24600
+   extsw %0,%1
 
24601
+   mtvsrwa %x0,%1
 
24602
+   lfiwax %0,%y1
 
24603
+   lxsiwax %x0,%y1"
 
24604
+  [(set_attr_alternative "type"
 
24605
+      [(if_then_else
 
24606
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
24607
+        (const_string "load_ext_ux")
 
24608
+        (if_then_else
 
24609
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
24610
+          (const_string "load_ext_u")
 
24611
+          (const_string "load_ext")))
 
24612
+       (const_string "exts")
 
24613
+       (const_string "mffgpr")
 
24614
+       (const_string "fpload")
 
24615
+       (const_string "fpload")])])
 
24616
+
 
24617
+(define_insn "*extendsidi2_nocell"
 
24618
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
 
24619
        (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
 
24620
-  "TARGET_POWERPC64 && rs6000_gen_cell_microcode"
 
24621
+  "TARGET_POWERPC64 && rs6000_gen_cell_microcode && !TARGET_LFIWAX"
 
24622
   "@
 
24623
    lwa%U1%X1 %0,%1
 
24624
    extsw %0,%1"
 
24625
-  [(set_attr "type" "load_ext,exts")])
 
24626
+  [(set_attr_alternative "type"
 
24627
+      [(if_then_else
 
24628
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
24629
+        (const_string "load_ext_ux")
 
24630
+        (if_then_else
 
24631
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
24632
+          (const_string "load_ext_u")
 
24633
+          (const_string "load_ext")))
 
24634
+       (const_string "exts")])])
 
24635
 
 
24636
-(define_insn ""
 
24637
+(define_insn "*extendsidi2_nocell"
 
24638
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
 
24639
        (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r")))]
 
24640
   "TARGET_POWERPC64 && !rs6000_gen_cell_microcode"
 
24641
@@ -602,7 +824,15 @@
 
24642
   "@
 
24643
    lbz%U1%X1 %0,%1
 
24644
    rlwinm %0,%1,0,0xff"
 
24645
-  [(set_attr "type" "load,*")])
 
24646
+  [(set_attr_alternative "type"
 
24647
+      [(if_then_else
 
24648
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
24649
+        (const_string "load_ux")
 
24650
+        (if_then_else
 
24651
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
24652
+          (const_string "load_u")
 
24653
+          (const_string "load")))
 
24654
+       (const_string "*")])])
 
24655
 
 
24656
 (define_insn ""
 
24657
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
 
24658
@@ -722,7 +952,15 @@
 
24659
   "@
 
24660
    lbz%U1%X1 %0,%1
 
24661
    rlwinm %0,%1,0,0xff"
 
24662
-  [(set_attr "type" "load,*")])
 
24663
+  [(set_attr_alternative "type"
 
24664
+      [(if_then_else
 
24665
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
24666
+        (const_string "load_ux")
 
24667
+        (if_then_else
 
24668
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
24669
+          (const_string "load_u")
 
24670
+          (const_string "load")))
 
24671
+       (const_string "*")])])
 
24672
 
 
24673
 (define_insn ""
 
24674
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
 
24675
@@ -848,7 +1086,15 @@
 
24676
   "@
 
24677
    lhz%U1%X1 %0,%1
 
24678
    rlwinm %0,%1,0,0xffff"
 
24679
-  [(set_attr "type" "load,*")])
 
24680
+  [(set_attr_alternative "type"
 
24681
+      [(if_then_else
 
24682
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
24683
+        (const_string "load_ux")
 
24684
+        (if_then_else
 
24685
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
24686
+          (const_string "load_u")
 
24687
+          (const_string "load")))
 
24688
+       (const_string "*")])])
 
24689
 
 
24690
 (define_insn ""
 
24691
   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
 
24692
@@ -915,7 +1161,15 @@
 
24693
   "@
 
24694
    lha%U1%X1 %0,%1
 
24695
    extsh %0,%1"
 
24696
-  [(set_attr "type" "load_ext,exts")])
 
24697
+  [(set_attr_alternative "type"
 
24698
+      [(if_then_else
 
24699
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
24700
+        (const_string "load_ext_ux")
 
24701
+        (if_then_else
 
24702
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
24703
+          (const_string "load_ext_u")
 
24704
+          (const_string "load_ext")))
 
24705
+       (const_string "exts")])])
 
24706
 
 
24707
 (define_insn ""
 
24708
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
 
24709
@@ -1658,7 +1912,19 @@
 
24710
     FAIL;
 
24711
 })
 
24712
 
 
24713
-(define_insn "one_cmpl<mode>2"
 
24714
+(define_expand "one_cmpl<mode>2"
 
24715
+  [(set (match_operand:SDI 0 "gpc_reg_operand" "")
 
24716
+       (not:SDI (match_operand:SDI 1 "gpc_reg_operand" "")))]
 
24717
+  ""
 
24718
+{
 
24719
+  if (<MODE>mode == DImode && !TARGET_POWERPC64)
 
24720
+    {
 
24721
+      rs6000_split_logical (operands, NOT, false, false, false, NULL_RTX);
 
24722
+      DONE;
 
24723
+    }
 
24724
+})
 
24725
+
 
24726
+(define_insn "*one_cmpl<mode>2"
 
24727
   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
 
24728
        (not:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")))]
 
24729
   ""
 
24730
@@ -1935,7 +2201,9 @@
 
24731
   [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
 
24732
        (unspec:GPR [(match_operand:GPR 1 "gpc_reg_operand" "r")] UNSPEC_PARITY))]
 
24733
   "TARGET_CMPB && TARGET_POPCNTB"
 
24734
-  "prty<wd> %0,%1")
 
24735
+  "prty<wd> %0,%1"
 
24736
+  [(set_attr "length" "4")
 
24737
+   (set_attr "type" "popcnt")])
 
24738
 
 
24739
 (define_expand "parity<mode>2"
 
24740
   [(set (match_operand:GPR 0 "gpc_reg_operand" "")
 
24741
@@ -4054,7 +4322,7 @@
 
24742
    #
 
24743
    #
 
24744
    #"
 
24745
-  [(set_attr "type" "delayed_compare,var_delayed_compare,delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
 
24746
+  [(set_attr "type" "fast_compare,var_delayed_compare,delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
 
24747
    (set_attr "length" "4,4,4,8,8,8")])
 
24748
 
 
24749
 (define_split
 
24750
@@ -4086,7 +4354,7 @@
 
24751
    #
 
24752
    #
 
24753
    #"
 
24754
-  [(set_attr "type" "delayed_compare,var_delayed_compare,delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
 
24755
+  [(set_attr "type" "fast_compare,var_delayed_compare,delayed_compare,delayed_compare,var_delayed_compare,delayed_compare")
 
24756
    (set_attr "length" "4,4,4,8,8,8")])
 
24757
 
 
24758
 (define_split
 
24759
@@ -4455,224 +4723,226 @@
 
24760
                    (const_int 0)))]
 
24761
   "")
 
24762
 
 
24763
-;; Floating-point insns, excluding normal data motion.
 
24764
-;;
 
24765
-;; PowerPC has a full set of single-precision floating point instructions.
 
24766
-;;
 
24767
-;; For the POWER architecture, we pretend that we have both SFmode and
 
24768
-;; DFmode insns, while, in fact, all fp insns are actually done in double.
 
24769
-;; The only conversions we will do will be when storing to memory.  In that
 
24770
-;; case, we will use the "frsp" instruction before storing.
 
24771
-;;
 
24772
-;; Note that when we store into a single-precision memory location, we need to
 
24773
-;; use the frsp insn first.  If the register being stored isn't dead, we
 
24774
-;; need a scratch register for the frsp.  But this is difficult when the store
 
24775
-;; is done by reload.  It is not incorrect to do the frsp on the register in
 
24776
-;; this case, we just lose precision that we would have otherwise gotten but
 
24777
-;; is not guaranteed.  Perhaps this should be tightened up at some point.
 
24778
+
 
24779
+;; Floating-point insns, excluding normal data motion.  We combine the SF/DF
 
24780
+;; modes here, and also add in conditional vsx/power8-vector support to access
 
24781
+;; values in the traditional Altivec registers if the appropriate
 
24782
+;; -mupper-regs-{df,sf} option is enabled.
 
24783
 
 
24784
-(define_expand "extendsfdf2"
 
24785
-  [(set (match_operand:DF 0 "gpc_reg_operand" "")
 
24786
-       (float_extend:DF (match_operand:SF 1 "reg_or_none500mem_operand" "")))]
 
24787
-  "TARGET_HARD_FLOAT && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
 
24788
+(define_expand "abs<mode>2"
 
24789
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
 
24790
+       (abs:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")))]
 
24791
+  "TARGET_<MODE>_INSN"
 
24792
   "")
 
24793
 
 
24794
-(define_insn_and_split "*extendsfdf2_fpr"
 
24795
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=d,?d,d")
 
24796
-       (float_extend:DF (match_operand:SF 1 "reg_or_mem_operand" "0,f,m")))]
 
24797
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
 
24798
+(define_insn "*abs<mode>2_fpr"
 
24799
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
 
24800
+       (abs:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")))]
 
24801
+  "TARGET_<MODE>_FPR"
 
24802
   "@
 
24803
-   #
 
24804
-   fmr %0,%1
 
24805
-   lfs%U1%X1 %0,%1"
 
24806
-  "&& reload_completed && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])"
 
24807
-  [(const_int 0)]
 
24808
-{
 
24809
-  emit_note (NOTE_INSN_DELETED);
 
24810
-  DONE;
 
24811
-}
 
24812
-  [(set_attr "type" "fp,fp,fpload")])
 
24813
+   fabs %0,%1
 
24814
+   xsabsdp %x0,%x1"
 
24815
+  [(set_attr "type" "fp")
 
24816
+   (set_attr "fp_type" "fp_addsub_<Fs>")])
 
24817
 
 
24818
-(define_expand "truncdfsf2"
 
24819
-  [(set (match_operand:SF 0 "gpc_reg_operand" "")
 
24820
-       (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "")))]
 
24821
-  "TARGET_HARD_FLOAT && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
 
24822
-  "")
 
24823
+(define_insn "*nabs<mode>2_fpr"
 
24824
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
 
24825
+       (neg:SFDF
 
24826
+        (abs:SFDF
 
24827
+         (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>"))))]
 
24828
+  "TARGET_<MODE>_FPR"
 
24829
+  "@
 
24830
+   fnabs %0,%1
 
24831
+   xsnabsdp %x0,%x1"
 
24832
+  [(set_attr "type" "fp")
 
24833
+   (set_attr "fp_type" "fp_addsub_<Fs>")])
 
24834
 
 
24835
-(define_insn "*truncdfsf2_fpr"
 
24836
-  [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
 
24837
-       (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "d")))]
 
24838
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
 
24839
-  "frsp %0,%1"
 
24840
-  [(set_attr "type" "fp")])
 
24841
-
 
24842
-(define_expand "negsf2"
 
24843
-  [(set (match_operand:SF 0 "gpc_reg_operand" "")
 
24844
-       (neg:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
 
24845
-  "TARGET_HARD_FLOAT && TARGET_SINGLE_FLOAT"
 
24846
+(define_expand "neg<mode>2"
 
24847
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
 
24848
+       (neg:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")))]
 
24849
+  "TARGET_<MODE>_INSN"
 
24850
   "")
 
24851
 
 
24852
-(define_insn "*negsf2"
 
24853
-  [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
 
24854
-       (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
 
24855
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
 
24856
-  "fneg %0,%1"
 
24857
-  [(set_attr "type" "fp")])
 
24858
+(define_insn "*neg<mode>2_fpr"
 
24859
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
 
24860
+       (neg:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")))]
 
24861
+  "TARGET_<MODE>_FPR"
 
24862
+  "@
 
24863
+   fneg %0,%1
 
24864
+   xsnegdp %x0,%x1"
 
24865
+  [(set_attr "type" "fp")
 
24866
+   (set_attr "fp_type" "fp_addsub_<Fs>")])
 
24867
 
 
24868
-(define_expand "abssf2"
 
24869
-  [(set (match_operand:SF 0 "gpc_reg_operand" "")
 
24870
-       (abs:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
 
24871
-  "TARGET_HARD_FLOAT && TARGET_SINGLE_FLOAT"
 
24872
+(define_expand "add<mode>3"
 
24873
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
 
24874
+       (plus:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")
 
24875
+                  (match_operand:SFDF 2 "gpc_reg_operand" "")))]
 
24876
+  "TARGET_<MODE>_INSN"
 
24877
   "")
 
24878
 
 
24879
-(define_insn "*abssf2"
 
24880
-  [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
 
24881
-       (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
 
24882
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
 
24883
-  "fabs %0,%1"
 
24884
-  [(set_attr "type" "fp")])
 
24885
+(define_insn "*add<mode>3_fpr"
 
24886
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
 
24887
+       (plus:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>")
 
24888
+                  (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
 
24889
+  "TARGET_<MODE>_FPR"
 
24890
+  "@
 
24891
+   fadd<Ftrad> %0,%1,%2
 
24892
+   xsadd<Fvsx> %x0,%x1,%x2"
 
24893
+  [(set_attr "type" "fp")
 
24894
+   (set_attr "fp_type" "fp_addsub_<Fs>")])
 
24895
 
 
24896
-(define_insn ""
 
24897
-  [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
 
24898
-       (neg:SF (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f"))))]
 
24899
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
 
24900
-  "fnabs %0,%1"
 
24901
-  [(set_attr "type" "fp")])
 
24902
-
 
24903
-(define_expand "addsf3"
 
24904
-  [(set (match_operand:SF 0 "gpc_reg_operand" "")
 
24905
-       (plus:SF (match_operand:SF 1 "gpc_reg_operand" "")
 
24906
-                (match_operand:SF 2 "gpc_reg_operand" "")))]
 
24907
-  "TARGET_HARD_FLOAT && TARGET_SINGLE_FLOAT"
 
24908
+(define_expand "sub<mode>3"
 
24909
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
 
24910
+       (minus:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")
 
24911
+                   (match_operand:SFDF 2 "gpc_reg_operand" "")))]
 
24912
+  "TARGET_<MODE>_INSN"
 
24913
   "")
 
24914
 
 
24915
-(define_insn ""
 
24916
-  [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
 
24917
-       (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
 
24918
-                (match_operand:SF 2 "gpc_reg_operand" "f")))]
 
24919
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
 
24920
-  "fadds %0,%1,%2"
 
24921
+(define_insn "*sub<mode>3_fpr"
 
24922
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
 
24923
+       (minus:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")
 
24924
+                   (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
 
24925
+  "TARGET_<MODE>_FPR"
 
24926
+  "@
 
24927
+   fsub<Ftrad> %0,%1,%2
 
24928
+   xssub<Fvsx> %x0,%x1,%x2"
 
24929
   [(set_attr "type" "fp")
 
24930
-   (set_attr "fp_type" "fp_addsub_s")])
 
24931
+   (set_attr "fp_type" "fp_addsub_<Fs>")])
 
24932
 
 
24933
-(define_expand "subsf3"
 
24934
-  [(set (match_operand:SF 0 "gpc_reg_operand" "")
 
24935
-       (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
 
24936
-                 (match_operand:SF 2 "gpc_reg_operand" "")))]
 
24937
-  "TARGET_HARD_FLOAT && TARGET_SINGLE_FLOAT"
 
24938
+(define_expand "mul<mode>3"
 
24939
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
 
24940
+       (mult:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")
 
24941
+                  (match_operand:SFDF 2 "gpc_reg_operand" "")))]
 
24942
+  "TARGET_<MODE>_INSN"
 
24943
   "")
 
24944
 
 
24945
-(define_insn ""
 
24946
-  [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
 
24947
-       (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
 
24948
-                 (match_operand:SF 2 "gpc_reg_operand" "f")))]
 
24949
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
 
24950
-  "fsubs %0,%1,%2"
 
24951
-  [(set_attr "type" "fp")
 
24952
-   (set_attr "fp_type" "fp_addsub_s")])
 
24953
+(define_insn "*mul<mode>3_fpr"
 
24954
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
 
24955
+       (mult:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>")
 
24956
+                  (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
 
24957
+  "TARGET_<MODE>_FPR"
 
24958
+  "@
 
24959
+   fmul<Ftrad> %0,%1,%2
 
24960
+   xsmul<Fvsx> %x0,%x1,%x2"
 
24961
+  [(set_attr "type" "dmul")
 
24962
+   (set_attr "fp_type" "fp_mul_<Fs>")])
 
24963
 
 
24964
-(define_expand "mulsf3"
 
24965
-  [(set (match_operand:SF 0 "gpc_reg_operand" "")
 
24966
-       (mult:SF (match_operand:SF 1 "gpc_reg_operand" "")
 
24967
-                (match_operand:SF 2 "gpc_reg_operand" "")))]
 
24968
-  "TARGET_HARD_FLOAT && TARGET_SINGLE_FLOAT"
 
24969
+(define_expand "div<mode>3"
 
24970
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
 
24971
+       (div:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "")
 
24972
+                 (match_operand:SFDF 2 "gpc_reg_operand" "")))]
 
24973
+  "TARGET_<MODE>_INSN && !TARGET_SIMPLE_FPU"
 
24974
   "")
 
24975
 
 
24976
-(define_insn ""
 
24977
-  [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
 
24978
-       (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
 
24979
-                (match_operand:SF 2 "gpc_reg_operand" "f")))]
 
24980
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
 
24981
-  "fmuls %0,%1,%2"
 
24982
-  [(set_attr "type" "fp")
 
24983
-   (set_attr "fp_type" "fp_mul_s")])
 
24984
+(define_insn "*div<mode>3_fpr"
 
24985
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
 
24986
+       (div:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")
 
24987
+                 (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
 
24988
+  "TARGET_<MODE>_FPR && !TARGET_SIMPLE_FPU"
 
24989
+  "@
 
24990
+   fdiv<Ftrad> %0,%1,%2
 
24991
+   xsdiv<Fvsx> %x0,%x1,%x2"
 
24992
+  [(set_attr "type" "<Fs>div")
 
24993
+   (set_attr "fp_type" "fp_div_<Fs>")])
 
24994
 
 
24995
-(define_expand "divsf3"
 
24996
-  [(set (match_operand:SF 0 "gpc_reg_operand" "")
 
24997
-       (div:SF (match_operand:SF 1 "gpc_reg_operand" "")
 
24998
-               (match_operand:SF 2 "gpc_reg_operand" "")))]
 
24999
-  "TARGET_HARD_FLOAT && TARGET_SINGLE_FLOAT && !TARGET_SIMPLE_FPU"
 
25000
-  "")
 
25001
+(define_insn "sqrt<mode>2"
 
25002
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
 
25003
+       (sqrt:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")))]
 
25004
+  "TARGET_<MODE>_FPR && !TARGET_SIMPLE_FPU
 
25005
+   && (TARGET_PPC_GPOPT || (<MODE>mode == SFmode && TARGET_XILINX_FPU))"
 
25006
+  "@
 
25007
+   fsqrt<Ftrad> %0,%1
 
25008
+   xssqrt<Fvsx> %x0,%x1"
 
25009
+  [(set_attr "type" "<Fs>sqrt")
 
25010
+   (set_attr "fp_type" "fp_sqrt_<Fs>")])
 
25011
 
 
25012
-(define_insn ""
 
25013
-  [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
 
25014
-       (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
 
25015
-               (match_operand:SF 2 "gpc_reg_operand" "f")))]
 
25016
-  "TARGET_HARD_FLOAT && TARGET_FPRS
 
25017
-   && TARGET_SINGLE_FLOAT && !TARGET_SIMPLE_FPU"
 
25018
-  "fdivs %0,%1,%2"
 
25019
-  [(set_attr "type" "sdiv")])
 
25020
+;; Floating point reciprocal approximation
 
25021
+(define_insn "fre<Fs>"
 
25022
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
 
25023
+       (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
 
25024
+                    UNSPEC_FRES))]
 
25025
+  "TARGET_<FFRE>"
 
25026
+  "@
 
25027
+   fre<Ftrad> %0,%1
 
25028
+   xsre<Fvsx> %x0,%x1"
 
25029
+  [(set_attr "type" "fp")])
 
25030
 
 
25031
-(define_insn "fres"
 
25032
-  [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
 
25033
-       (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRES))]
 
25034
-  "TARGET_FRES"
 
25035
-  "fres %0,%1"
 
25036
+(define_insn "*rsqrt<mode>2"
 
25037
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
 
25038
+       (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
 
25039
+                    UNSPEC_RSQRT))]
 
25040
+  "RS6000_RECIP_HAVE_RSQRTE_P (<MODE>mode)"
 
25041
+  "@
 
25042
+   frsqrte<Ftrad> %0,%1
 
25043
+   xsrsqrte<Fvsx> %x0,%x1"
 
25044
   [(set_attr "type" "fp")])
 
25045
 
 
25046
-; builtin fmaf support
 
25047
-(define_insn "*fmasf4_fpr"
 
25048
-  [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
 
25049
-       (fma:SF (match_operand:SF 1 "gpc_reg_operand" "f")
 
25050
-               (match_operand:SF 2 "gpc_reg_operand" "f")
 
25051
-               (match_operand:SF 3 "gpc_reg_operand" "f")))]
 
25052
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
 
25053
-  "fmadds %0,%1,%2,%3"
 
25054
-  [(set_attr "type" "fp")
 
25055
-   (set_attr "fp_type" "fp_maddsub_s")])
 
25056
+;; Floating point comparisons
 
25057
+(define_insn "*cmp<mode>_fpr"
 
25058
+  [(set (match_operand:CCFP 0 "cc_reg_operand" "=y,y")
 
25059
+       (compare:CCFP (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")
 
25060
+                     (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
 
25061
+  "TARGET_<MODE>_FPR"
 
25062
+  "@
 
25063
+   fcmpu %0,%1,%2
 
25064
+   xscmpudp %0,%x1,%x2"
 
25065
+  [(set_attr "type" "fpcompare")])
 
25066
 
 
25067
-(define_insn "*fmssf4_fpr"
 
25068
-  [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
 
25069
-       (fma:SF (match_operand:SF 1 "gpc_reg_operand" "f")
 
25070
-               (match_operand:SF 2 "gpc_reg_operand" "f")
 
25071
-               (neg:SF (match_operand:SF 3 "gpc_reg_operand" "f"))))]
 
25072
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
 
25073
-  "fmsubs %0,%1,%2,%3"
 
25074
-  [(set_attr "type" "fp")
 
25075
-   (set_attr "fp_type" "fp_maddsub_s")])
 
25076
+;; Floating point conversions
 
25077
+(define_expand "extendsfdf2"
 
25078
+  [(set (match_operand:DF 0 "gpc_reg_operand" "")
 
25079
+       (float_extend:DF (match_operand:SF 1 "reg_or_none500mem_operand" "")))]
 
25080
+  "TARGET_HARD_FLOAT && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
 
25081
+  "")
 
25082
 
 
25083
-(define_insn "*nfmasf4_fpr"
 
25084
-  [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
 
25085
-       (neg:SF (fma:SF (match_operand:SF 1 "gpc_reg_operand" "f")
 
25086
-                       (match_operand:SF 2 "gpc_reg_operand" "f")
 
25087
-                       (match_operand:SF 3 "gpc_reg_operand" "f"))))]
 
25088
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
 
25089
-  "fnmadds %0,%1,%2,%3"
 
25090
-  [(set_attr "type" "fp")
 
25091
-   (set_attr "fp_type" "fp_maddsub_s")])
 
25092
+(define_insn_and_split "*extendsfdf2_fpr"
 
25093
+  [(set (match_operand:DF 0 "gpc_reg_operand" "=d,?d,d,ws,?ws,wv")
 
25094
+       (float_extend:DF (match_operand:SF 1 "reg_or_mem_operand" "0,f,m,0,wy,Z")))]
 
25095
+  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
 
25096
+  "@
 
25097
+   #
 
25098
+   fmr %0,%1
 
25099
+   lfs%U1%X1 %0,%1
 
25100
+   #
 
25101
+   xxlor %x0,%x1,%x1
 
25102
+   lxsspx %x0,%y1"
 
25103
+  "&& reload_completed && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])"
 
25104
+  [(const_int 0)]
 
25105
+{
 
25106
+  emit_note (NOTE_INSN_DELETED);
 
25107
+  DONE;
 
25108
+}
 
25109
+  [(set_attr_alternative "type"
 
25110
+      [(const_string "fp")
 
25111
+       (const_string "fp")
 
25112
+       (if_then_else
 
25113
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
25114
+        (const_string "fpload_ux")
 
25115
+        (if_then_else
 
25116
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
25117
+          (const_string "fpload_u")
 
25118
+          (const_string "fpload")))
 
25119
+       (const_string "fp")
 
25120
+       (const_string "vecsimple")
 
25121
+       (if_then_else
 
25122
+       (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
25123
+       (const_string "fpload_ux")
 
25124
+       (if_then_else
 
25125
+        (match_test "update_address_mem (operands[1], VOIDmode)")
 
25126
+        (const_string "fpload_u")
 
25127
+        (const_string "fpload")))])])
 
25128
 
 
25129
-(define_insn "*nfmssf4_fpr"
 
25130
-  [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
 
25131
-       (neg:SF (fma:SF (match_operand:SF 1 "gpc_reg_operand" "f")
 
25132
-                       (match_operand:SF 2 "gpc_reg_operand" "f")
 
25133
-                       (neg:SF (match_operand:SF 3 "gpc_reg_operand" "f")))))]
 
25134
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
 
25135
-  "fnmsubs %0,%1,%2,%3"
 
25136
-  [(set_attr "type" "fp")
 
25137
-   (set_attr "fp_type" "fp_maddsub_s")])
 
25138
-
 
25139
-(define_expand "sqrtsf2"
 
25140
+(define_expand "truncdfsf2"
 
25141
   [(set (match_operand:SF 0 "gpc_reg_operand" "")
 
25142
-       (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
 
25143
-  "(TARGET_PPC_GPOPT || TARGET_XILINX_FPU)
 
25144
-   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT
 
25145
-   && !TARGET_SIMPLE_FPU"
 
25146
+       (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "")))]
 
25147
+  "TARGET_HARD_FLOAT && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
 
25148
   "")
 
25149
 
 
25150
-(define_insn ""
 
25151
+(define_insn "*truncdfsf2_fpr"
 
25152
   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
 
25153
-       (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
 
25154
-  "(TARGET_PPC_GPOPT || TARGET_XILINX_FPU) && TARGET_HARD_FLOAT
 
25155
-   && TARGET_FPRS && TARGET_SINGLE_FLOAT && !TARGET_SIMPLE_FPU"
 
25156
-  "fsqrts %0,%1"
 
25157
-  [(set_attr "type" "ssqrt")])
 
25158
-
 
25159
-(define_insn "*rsqrtsf_internal1"
 
25160
-  [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
 
25161
-       (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")]
 
25162
-                  UNSPEC_RSQRT))]
 
25163
-  "TARGET_FRSQRTES"
 
25164
-  "frsqrtes %0,%1"
 
25165
+       (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "d")))]
 
25166
+  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
 
25167
+  "frsp %0,%1"
 
25168
   [(set_attr "type" "fp")])
 
25169
 
 
25170
 ;; This expander is here to avoid FLOAT_WORDS_BIGENDIAN tests in
 
25171
@@ -4742,39 +5012,84 @@
 
25172
 ;; Use an unspec rather providing an if-then-else in RTL, to prevent the
 
25173
 ;; compiler from optimizing -0.0
 
25174
 (define_insn "copysign<mode>3_fcpsgn"
 
25175
-  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<rreg2>")
 
25176
-       (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<rreg2>")
 
25177
-                     (match_operand:SFDF 2 "gpc_reg_operand" "<rreg2>")]
 
25178
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
 
25179
+       (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")
 
25180
+                     (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")]
 
25181
                     UNSPEC_COPYSIGN))]
 
25182
-  "TARGET_CMPB && !VECTOR_UNIT_VSX_P (<MODE>mode)"
 
25183
-  "fcpsgn %0,%2,%1"
 
25184
+  "TARGET_<MODE>_FPR && TARGET_CMPB"
 
25185
+  "@
 
25186
+   fcpsgn %0,%2,%1
 
25187
+   xscpsgn<Fvsx> %x0,%x2,%x1"
 
25188
   [(set_attr "type" "fp")])
 
25189
 
 
25190
 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
 
25191
 ;; fsel instruction and some auxiliary computations.  Then we just have a
 
25192
 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
 
25193
 ;; combine.
 
25194
-(define_expand "smaxsf3"
 
25195
-  [(set (match_operand:SF 0 "gpc_reg_operand" "")
 
25196
-       (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
 
25197
-                            (match_operand:SF 2 "gpc_reg_operand" ""))
 
25198
-                        (match_dup 1)
 
25199
-                        (match_dup 2)))]
 
25200
-  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS 
 
25201
-   && TARGET_SINGLE_FLOAT && !flag_trapping_math"
 
25202
-  "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
 
25203
+;; For MIN, MAX on non-VSX machines, and conditional move all of the time, we
 
25204
+;; use DEFINE_EXPAND's that involve a fsel instruction and some auxiliary
 
25205
+;; computations.  Then we just have a single DEFINE_INSN for fsel and the
 
25206
+;; define_splits to make them if made by combine.  On VSX machines we have the
 
25207
+;; min/max instructions.
 
25208
+;;
 
25209
+;; On VSX, we only check for TARGET_VSX instead of checking for a vsx/p8 vector
 
25210
+;; to allow either DF/SF to use only traditional registers.
 
25211
 
 
25212
-(define_expand "sminsf3"
 
25213
-  [(set (match_operand:SF 0 "gpc_reg_operand" "")
 
25214
-       (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
 
25215
-                            (match_operand:SF 2 "gpc_reg_operand" ""))
 
25216
-                        (match_dup 2)
 
25217
-                        (match_dup 1)))]
 
25218
-  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS 
 
25219
-   && TARGET_SINGLE_FLOAT && !flag_trapping_math"
 
25220
-  "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
 
25221
+(define_expand "smax<mode>3"
 
25222
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
 
25223
+       (if_then_else:SFDF (ge (match_operand:SFDF 1 "gpc_reg_operand" "")
 
25224
+                              (match_operand:SFDF 2 "gpc_reg_operand" ""))
 
25225
+                          (match_dup 1)
 
25226
+                          (match_dup 2)))]
 
25227
+  "TARGET_<MODE>_FPR && TARGET_PPC_GFXOPT && !flag_trapping_math"
 
25228
+{
 
25229
+  rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
 
25230
+  DONE;
 
25231
+})
 
25232
 
 
25233
+(define_insn "*smax<mode>3_vsx"
 
25234
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
 
25235
+       (smax:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>")
 
25236
+                  (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
 
25237
+  "TARGET_<MODE>_FPR && TARGET_VSX"
 
25238
+  "xsmaxdp %x0,%x1,%x2"
 
25239
+  [(set_attr "type" "fp")])
 
25240
+
 
25241
+(define_expand "smin<mode>3"
 
25242
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
 
25243
+       (if_then_else:SFDF (ge (match_operand:SFDF 1 "gpc_reg_operand" "")
 
25244
+                              (match_operand:SFDF 2 "gpc_reg_operand" ""))
 
25245
+                          (match_dup 2)
 
25246
+                          (match_dup 1)))]
 
25247
+  "TARGET_<MODE>_FPR && TARGET_PPC_GFXOPT && !flag_trapping_math"
 
25248
+{
 
25249
+  rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
 
25250
+  DONE;
 
25251
+})
 
25252
+
 
25253
+(define_insn "*smin<mode>3_vsx"
 
25254
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
 
25255
+       (smin:SFDF (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>")
 
25256
+                  (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>")))]
 
25257
+  "TARGET_<MODE>_FPR && TARGET_VSX"
 
25258
+  "xsmindp %x0,%x1,%x2"
 
25259
+  [(set_attr "type" "fp")])
 
25260
+
 
25261
 (define_split
 
25262
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
 
25263
+       (match_operator:SFDF 3 "min_max_operator"
 
25264
+        [(match_operand:SFDF 1 "gpc_reg_operand" "")
 
25265
+         (match_operand:SFDF 2 "gpc_reg_operand" "")]))]
 
25266
+  "TARGET_<MODE>_FPR && TARGET_PPC_GFXOPT && !flag_trapping_math
 
25267
+   && !TARGET_VSX"
 
25268
+  [(const_int 0)]
 
25269
+{
 
25270
+  rs6000_emit_minmax (operands[0], GET_CODE (operands[3]), operands[1],
 
25271
+                     operands[2]);
 
25272
+  DONE;
 
25273
+})
 
25274
+
 
25275
+(define_split
 
25276
   [(set (match_operand:SF 0 "gpc_reg_operand" "")
 
25277
        (match_operator:SF 3 "min_max_operator"
 
25278
         [(match_operand:SF 1 "gpc_reg_operand" "")
 
25279
@@ -4904,208 +5219,9 @@
 
25280
   "fsel %0,%1,%2,%3"
 
25281
   [(set_attr "type" "fp")])
 
25282
 
 
25283
-(define_expand "negdf2"
 
25284
-  [(set (match_operand:DF 0 "gpc_reg_operand" "")
 
25285
-       (neg:DF (match_operand:DF 1 "gpc_reg_operand" "")))]
 
25286
-  "TARGET_HARD_FLOAT && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
 
25287
-  "")
 
25288
-
 
25289
-(define_insn "*negdf2_fpr"
 
25290
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
 
25291
-       (neg:DF (match_operand:DF 1 "gpc_reg_operand" "d")))]
 
25292
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
 
25293
-   && !VECTOR_UNIT_VSX_P (DFmode)"
 
25294
-  "fneg %0,%1"
 
25295
-  [(set_attr "type" "fp")])
 
25296
-
 
25297
-(define_expand "absdf2"
 
25298
-  [(set (match_operand:DF 0 "gpc_reg_operand" "")
 
25299
-       (abs:DF (match_operand:DF 1 "gpc_reg_operand" "")))]
 
25300
-  "TARGET_HARD_FLOAT && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
 
25301
-  "")
 
25302
-
 
25303
-(define_insn "*absdf2_fpr"
 
25304
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
 
25305
-       (abs:DF (match_operand:DF 1 "gpc_reg_operand" "d")))]
 
25306
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
 
25307
-   && !VECTOR_UNIT_VSX_P (DFmode)"
 
25308
-  "fabs %0,%1"
 
25309
-  [(set_attr "type" "fp")])
 
25310
-
 
25311
-(define_insn "*nabsdf2_fpr"
 
25312
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
 
25313
-       (neg:DF (abs:DF (match_operand:DF 1 "gpc_reg_operand" "d"))))]
 
25314
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
 
25315
-   && !VECTOR_UNIT_VSX_P (DFmode)"
 
25316
-  "fnabs %0,%1"
 
25317
-  [(set_attr "type" "fp")])
 
25318
-
 
25319
-(define_expand "adddf3"
 
25320
-  [(set (match_operand:DF 0 "gpc_reg_operand" "")
 
25321
-       (plus:DF (match_operand:DF 1 "gpc_reg_operand" "")
 
25322
-                (match_operand:DF 2 "gpc_reg_operand" "")))]
 
25323
-  "TARGET_HARD_FLOAT && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
 
25324
-  "")
 
25325
-
 
25326
-(define_insn "*adddf3_fpr"
 
25327
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
 
25328
-       (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%d")
 
25329
-                (match_operand:DF 2 "gpc_reg_operand" "d")))]
 
25330
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
 
25331
-   && !VECTOR_UNIT_VSX_P (DFmode)"
 
25332
-  "fadd %0,%1,%2"
 
25333
-  [(set_attr "type" "fp")
 
25334
-   (set_attr "fp_type" "fp_addsub_d")])
 
25335
-
 
25336
-(define_expand "subdf3"
 
25337
-  [(set (match_operand:DF 0 "gpc_reg_operand" "")
 
25338
-       (minus:DF (match_operand:DF 1 "gpc_reg_operand" "")
 
25339
-                 (match_operand:DF 2 "gpc_reg_operand" "")))]
 
25340
-  "TARGET_HARD_FLOAT && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
 
25341
-  "")
 
25342
-
 
25343
-(define_insn "*subdf3_fpr"
 
25344
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
 
25345
-       (minus:DF (match_operand:DF 1 "gpc_reg_operand" "d")
 
25346
-                 (match_operand:DF 2 "gpc_reg_operand" "d")))]
 
25347
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
 
25348
-   && !VECTOR_UNIT_VSX_P (DFmode)"
 
25349
-  "fsub %0,%1,%2"
 
25350
-  [(set_attr "type" "fp")
 
25351
-   (set_attr "fp_type" "fp_addsub_d")])
 
25352
-
 
25353
-(define_expand "muldf3"
 
25354
-  [(set (match_operand:DF 0 "gpc_reg_operand" "")
 
25355
-       (mult:DF (match_operand:DF 1 "gpc_reg_operand" "")
 
25356
-                (match_operand:DF 2 "gpc_reg_operand" "")))]
 
25357
-  "TARGET_HARD_FLOAT && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)"
 
25358
-  "")
 
25359
-
 
25360
-(define_insn "*muldf3_fpr"
 
25361
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
 
25362
-       (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%d")
 
25363
-                (match_operand:DF 2 "gpc_reg_operand" "d")))]
 
25364
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
 
25365
-   && !VECTOR_UNIT_VSX_P (DFmode)"
 
25366
-  "fmul %0,%1,%2"
 
25367
-  [(set_attr "type" "dmul")
 
25368
-   (set_attr "fp_type" "fp_mul_d")])
 
25369
-
 
25370
-(define_expand "divdf3"
 
25371
-  [(set (match_operand:DF 0 "gpc_reg_operand" "")
 
25372
-       (div:DF (match_operand:DF 1 "gpc_reg_operand" "")
 
25373
-               (match_operand:DF 2 "gpc_reg_operand" "")))]
 
25374
-  "TARGET_HARD_FLOAT
 
25375
-   && ((TARGET_FPRS && TARGET_DOUBLE_FLOAT) || TARGET_E500_DOUBLE)
 
25376
-   && !TARGET_SIMPLE_FPU"
 
25377
-  "")
 
25378
-
 
25379
-(define_insn "*divdf3_fpr"
 
25380
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
 
25381
-       (div:DF (match_operand:DF 1 "gpc_reg_operand" "d")
 
25382
-               (match_operand:DF 2 "gpc_reg_operand" "d")))]
 
25383
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && !TARGET_SIMPLE_FPU
 
25384
-   && !VECTOR_UNIT_VSX_P (DFmode)"
 
25385
-  "fdiv %0,%1,%2"
 
25386
-  [(set_attr "type" "ddiv")])
 
25387
-
 
25388
-(define_insn "*fred_fpr"
 
25389
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
 
25390
-       (unspec:DF [(match_operand:DF 1 "gpc_reg_operand" "f")] UNSPEC_FRES))]
 
25391
-  "TARGET_FRE && !VECTOR_UNIT_VSX_P (DFmode)"
 
25392
-  "fre %0,%1"
 
25393
-  [(set_attr "type" "fp")])
 
25394
-
 
25395
-(define_insn "*rsqrtdf_internal1"
 
25396
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
 
25397
-       (unspec:DF [(match_operand:DF 1 "gpc_reg_operand" "d")]
 
25398
-                  UNSPEC_RSQRT))]
 
25399
-  "TARGET_FRSQRTE && !VECTOR_UNIT_VSX_P (DFmode)"
 
25400
-  "frsqrte %0,%1"
 
25401
-  [(set_attr "type" "fp")])
 
25402
-
 
25403
-; builtin fma support
 
25404
-(define_insn "*fmadf4_fpr"
 
25405
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
 
25406
-       (fma:DF (match_operand:DF 1 "gpc_reg_operand" "f")
 
25407
-               (match_operand:DF 2 "gpc_reg_operand" "f")
 
25408
-               (match_operand:DF 3 "gpc_reg_operand" "f")))]
 
25409
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
 
25410
-   && VECTOR_UNIT_NONE_P (DFmode)"
 
25411
-  "fmadd %0,%1,%2,%3"
 
25412
-  [(set_attr "type" "fp")
 
25413
-   (set_attr "fp_type" "fp_maddsub_d")])
 
25414
-
 
25415
-(define_insn "*fmsdf4_fpr"
 
25416
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
 
25417
-       (fma:DF (match_operand:DF 1 "gpc_reg_operand" "f")
 
25418
-               (match_operand:DF 2 "gpc_reg_operand" "f")
 
25419
-               (neg:DF (match_operand:DF 3 "gpc_reg_operand" "f"))))]
 
25420
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
 
25421
-   && VECTOR_UNIT_NONE_P (DFmode)"
 
25422
-  "fmsub %0,%1,%2,%3"
 
25423
-  [(set_attr "type" "fp")
 
25424
-   (set_attr "fp_type" "fp_maddsub_d")])
 
25425
-
 
25426
-(define_insn "*nfmadf4_fpr"
 
25427
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
 
25428
-       (neg:DF (fma:DF (match_operand:DF 1 "gpc_reg_operand" "f")
 
25429
-                       (match_operand:DF 2 "gpc_reg_operand" "f")
 
25430
-                       (match_operand:DF 3 "gpc_reg_operand" "f"))))]
 
25431
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
 
25432
-   && VECTOR_UNIT_NONE_P (DFmode)"
 
25433
-  "fnmadd %0,%1,%2,%3"
 
25434
-  [(set_attr "type" "fp")
 
25435
-   (set_attr "fp_type" "fp_maddsub_d")])
 
25436
-
 
25437
-(define_insn "*nfmsdf4_fpr"
 
25438
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
 
25439
-       (neg:DF (fma:DF (match_operand:DF 1 "gpc_reg_operand" "f")
 
25440
-                       (match_operand:DF 2 "gpc_reg_operand" "f")
 
25441
-                       (neg:DF (match_operand:DF 3 "gpc_reg_operand" "f")))))]
 
25442
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
 
25443
-   && VECTOR_UNIT_NONE_P (DFmode)"
 
25444
-  "fnmsub %0,%1,%2,%3"
 
25445
-  [(set_attr "type" "fp")
 
25446
-   (set_attr "fp_type" "fp_maddsub_d")])
 
25447
-
 
25448
-(define_expand "sqrtdf2"
 
25449
-  [(set (match_operand:DF 0 "gpc_reg_operand" "")
 
25450
-       (sqrt:DF (match_operand:DF 1 "gpc_reg_operand" "")))]
 
25451
-  "TARGET_PPC_GPOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT"
 
25452
-  "")
 
25453
-
 
25454
-(define_insn "*sqrtdf2_fpr"
 
25455
-  [(set (match_operand:DF 0 "gpc_reg_operand" "=d")
 
25456
-       (sqrt:DF (match_operand:DF 1 "gpc_reg_operand" "d")))]
 
25457
-  "TARGET_PPC_GPOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
 
25458
-   && !VECTOR_UNIT_VSX_P (DFmode)"
 
25459
-  "fsqrt %0,%1"
 
25460
-  [(set_attr "type" "dsqrt")])
 
25461
-
 
25462
 ;; The conditional move instructions allow us to perform max and min
 
25463
 ;; operations even when
 
25464
 
 
25465
-(define_expand "smaxdf3"
 
25466
-  [(set (match_operand:DF 0 "gpc_reg_operand" "")
 
25467
-       (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
 
25468
-                            (match_operand:DF 2 "gpc_reg_operand" ""))
 
25469
-                        (match_dup 1)
 
25470
-                        (match_dup 2)))]
 
25471
-  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT 
 
25472
-   && !flag_trapping_math"
 
25473
-  "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
 
25474
-
 
25475
-(define_expand "smindf3"
 
25476
-  [(set (match_operand:DF 0 "gpc_reg_operand" "")
 
25477
-       (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
 
25478
-                            (match_operand:DF 2 "gpc_reg_operand" ""))
 
25479
-                        (match_dup 2)
 
25480
-                        (match_dup 1)))]
 
25481
-  "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT 
 
25482
-   && !flag_trapping_math"
 
25483
-  "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
 
25484
-
 
25485
 (define_split
 
25486
   [(set (match_operand:DF 0 "gpc_reg_operand" "")
 
25487
        (match_operator:DF 3 "min_max_operator"
 
25488
@@ -5159,12 +5275,15 @@
 
25489
 ; We don't define lfiwax/lfiwzx with the normal definition, because we
 
25490
 ; don't want to support putting SImode in FPR registers.
 
25491
 (define_insn "lfiwax"
 
25492
-  [(set (match_operand:DI 0 "gpc_reg_operand" "=d")
 
25493
-       (unspec:DI [(match_operand:SI 1 "indexed_or_indirect_operand" "Z")]
 
25494
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=d,wm,!wm")
 
25495
+       (unspec:DI [(match_operand:SI 1 "reg_or_indexed_operand" "Z,Z,r")]
 
25496
                   UNSPEC_LFIWAX))]
 
25497
   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWAX"
 
25498
-  "lfiwax %0,%y1"
 
25499
-  [(set_attr "type" "fpload")])
 
25500
+  "@
 
25501
+   lfiwax %0,%y1
 
25502
+   lxsiwax %x0,%y1
 
25503
+   mtvsrwa %x0,%1"
 
25504
+  [(set_attr "type" "fpload,fpload,mffgpr")])
 
25505
 
 
25506
 ; This split must be run before register allocation because it allocates the
 
25507
 ; memory slot that is needed to move values to/from the FPR.  We don't allocate
 
25508
@@ -5186,7 +5305,8 @@
 
25509
   rtx src = operands[1];
 
25510
   rtx tmp;
 
25511
 
 
25512
-  if (!MEM_P (src) && TARGET_MFPGPR && TARGET_POWERPC64)
 
25513
+  if (!MEM_P (src) && TARGET_POWERPC64
 
25514
+      && (TARGET_MFPGPR || TARGET_DIRECT_MOVE))
 
25515
     tmp = convert_to_mode (DImode, src, false);
 
25516
   else
 
25517
     {
 
25518
@@ -5235,12 +5355,15 @@
 
25519
    (set_attr "type" "fpload")])
 
25520
 
 
25521
 (define_insn "lfiwzx"
 
25522
-  [(set (match_operand:DI 0 "gpc_reg_operand" "=d")
 
25523
-       (unspec:DI [(match_operand:SI 1 "indexed_or_indirect_operand" "Z")]
 
25524
+  [(set (match_operand:DI 0 "gpc_reg_operand" "=d,wm,!wm")
 
25525
+       (unspec:DI [(match_operand:SI 1 "reg_or_indexed_operand" "Z,Z,r")]
 
25526
                   UNSPEC_LFIWZX))]
 
25527
   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT && TARGET_LFIWZX"
 
25528
-  "lfiwzx %0,%y1"
 
25529
-  [(set_attr "type" "fpload")])
 
25530
+  "@
 
25531
+   lfiwzx %0,%y1
 
25532
+   lxsiwzx %x0,%y1
 
25533
+   mtvsrwz %x0,%1"
 
25534
+  [(set_attr "type" "fpload,fpload,mftgpr")])
 
25535
 
 
25536
 (define_insn_and_split "floatunssi<mode>2_lfiwzx"
 
25537
   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d")
 
25538
@@ -5257,7 +5380,8 @@
 
25539
   rtx src = operands[1];
 
25540
   rtx tmp;
 
25541
 
 
25542
-  if (!MEM_P (src) && TARGET_MFPGPR && TARGET_POWERPC64)
 
25543
+  if (!MEM_P (src) && TARGET_POWERPC64
 
25544
+      && (TARGET_MFPGPR || TARGET_DIRECT_MOVE))
 
25545
     tmp = convert_to_mode (DImode, src, true);
 
25546
   else
 
25547
     {
 
25548
@@ -5548,7 +5672,7 @@
 
25549
       emit_insn (gen_stfiwx (dest, tmp));
 
25550
       DONE;
 
25551
     }
 
25552
-  else if (TARGET_MFPGPR && TARGET_POWERPC64)
 
25553
+  else if (TARGET_POWERPC64 && (TARGET_MFPGPR || TARGET_DIRECT_MOVE))
 
25554
     {
 
25555
       dest = gen_lowpart (DImode, dest);
 
25556
       emit_move_insn (dest, tmp);
 
25557
@@ -5642,7 +5766,7 @@
 
25558
       emit_insn (gen_stfiwx (dest, tmp));
 
25559
       DONE;
 
25560
     }
 
25561
-  else if (TARGET_MFPGPR && TARGET_POWERPC64)
 
25562
+  else if (TARGET_POWERPC64 && (TARGET_MFPGPR || TARGET_DIRECT_MOVE))
 
25563
     {
 
25564
       dest = gen_lowpart (DImode, dest);
 
25565
       emit_move_insn (dest, tmp);
 
25566
@@ -5781,66 +5905,52 @@
 
25567
   [(set (match_operand:DI 0 "gpc_reg_operand" "=d")
 
25568
        (unspec:DI [(match_operand:SFDF 1 "gpc_reg_operand" "<rreg2>")]
 
25569
                   UNSPEC_FCTID))]
 
25570
-  "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS && <TARGET_FLOAT>"
 
25571
+  "TARGET_<MODE>_FPR && TARGET_FPRND"
 
25572
   "fctid %0,%1"
 
25573
   [(set_attr "type" "fp")])
 
25574
 
 
25575
-(define_expand "btrunc<mode>2"
 
25576
-  [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
 
25577
-       (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "")]
 
25578
+(define_insn "btrunc<mode>2"
 
25579
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
 
25580
+       (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
 
25581
                     UNSPEC_FRIZ))]
 
25582
-  "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS && <TARGET_FLOAT>"
 
25583
-  "")
 
25584
+  "TARGET_<MODE>_FPR && TARGET_FPRND"
 
25585
+  "@
 
25586
+   friz %0,%1
 
25587
+   xsrdpiz %x0,%x1"
 
25588
+  [(set_attr "type" "fp")
 
25589
+   (set_attr "fp_type" "fp_addsub_<Fs>")])
 
25590
 
 
25591
-(define_insn "*btrunc<mode>2_fpr"
 
25592
-  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<rreg2>")
 
25593
-       (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<rreg2>")]
 
25594
-                    UNSPEC_FRIZ))]
 
25595
-  "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS && <TARGET_FLOAT>
 
25596
-   && !VECTOR_UNIT_VSX_P (<MODE>mode)"
 
25597
-  "friz %0,%1"
 
25598
-  [(set_attr "type" "fp")])
 
25599
-
 
25600
-(define_expand "ceil<mode>2"
 
25601
-  [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
 
25602
-       (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "")]
 
25603
+(define_insn "ceil<mode>2"
 
25604
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
 
25605
+       (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
 
25606
                     UNSPEC_FRIP))]
 
25607
-  "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS && <TARGET_FLOAT>"
 
25608
-  "")
 
25609
+  "TARGET_<MODE>_FPR && TARGET_FPRND"
 
25610
+  "@
 
25611
+   frip %0,%1
 
25612
+   xsrdpip %x0,%x1"
 
25613
+  [(set_attr "type" "fp")
 
25614
+   (set_attr "fp_type" "fp_addsub_<Fs>")])
 
25615
 
 
25616
-(define_insn "*ceil<mode>2_fpr"
 
25617
-  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<rreg2>")
 
25618
-       (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<rreg2>")]
 
25619
-                    UNSPEC_FRIP))]
 
25620
-  "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS && <TARGET_FLOAT>
 
25621
-   && !VECTOR_UNIT_VSX_P (<MODE>mode)"
 
25622
-  "frip %0,%1"
 
25623
-  [(set_attr "type" "fp")])
 
25624
-
 
25625
-(define_expand "floor<mode>2"
 
25626
-  [(set (match_operand:SFDF 0 "gpc_reg_operand" "")
 
25627
-       (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "")]
 
25628
+(define_insn "floor<mode>2"
 
25629
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>")
 
25630
+       (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>")]
 
25631
                     UNSPEC_FRIM))]
 
25632
-  "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS && <TARGET_FLOAT>"
 
25633
-  "")
 
25634
+  "TARGET_<MODE>_FPR && TARGET_FPRND"
 
25635
+  "@
 
25636
+   frim %0,%1
 
25637
+   xsrdpim %x0,%x1"
 
25638
+  [(set_attr "type" "fp")
 
25639
+   (set_attr "fp_type" "fp_addsub_<Fs>")])
 
25640
 
 
25641
-(define_insn "*floor<mode>2_fpr"
 
25642
-  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<rreg2>")
 
25643
-       (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<rreg2>")]
 
25644
-                    UNSPEC_FRIM))]
 
25645
-  "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS && <TARGET_FLOAT>
 
25646
-   && !VECTOR_UNIT_VSX_P (<MODE>mode)"
 
25647
-  "frim %0,%1"
 
25648
-  [(set_attr "type" "fp")])
 
25649
-
 
25650
 ;; No VSX equivalent to frin
 
25651
 (define_insn "round<mode>2"
 
25652
   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<rreg2>")
 
25653
        (unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "<rreg2>")]
 
25654
                     UNSPEC_FRIN))]
 
25655
-  "TARGET_FPRND && TARGET_HARD_FLOAT && TARGET_FPRS && <TARGET_FLOAT>"
 
25656
+  "TARGET_<MODE>_FPR && TARGET_FPRND"
 
25657
   "frin %0,%1"
 
25658
-  [(set_attr "type" "fp")])
 
25659
+  [(set_attr "type" "fp")
 
25660
+   (set_attr "fp_type" "fp_addsub_<Fs>")])
 
25661
 
 
25662
 ; An UNSPEC is used so we don't have to support SImode in FP registers.
 
25663
 (define_insn "stfiwx"
 
25664
@@ -7195,10 +7305,19 @@
 
25665
   [(parallel
 
25666
     [(set (match_operand:DI 0 "gpc_reg_operand" "")
 
25667
          (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
 
25668
-                 (match_operand:DI 2 "and64_2_operand" "")))
 
25669
+                 (match_operand:DI 2 "reg_or_cint_operand" "")))
 
25670
      (clobber (match_scratch:CC 3 ""))])]
 
25671
-  "TARGET_POWERPC64"
 
25672
-  "")
 
25673
+  ""
 
25674
+{
 
25675
+  if (!TARGET_POWERPC64)
 
25676
+    {
 
25677
+      rtx cc = gen_rtx_SCRATCH (CCmode);
 
25678
+      rs6000_split_logical (operands, AND, false, false, false, cc);
 
25679
+      DONE;
 
25680
+    }
 
25681
+  else if (!and64_2_operand (operands[2], DImode))
 
25682
+    operands[2] = force_reg (DImode, operands[2]);
 
25683
+})
 
25684
 
 
25685
 (define_insn "anddi3_mc"
 
25686
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
 
25687
@@ -7379,12 +7498,18 @@
 
25688
 (define_expand "iordi3"
 
25689
   [(set (match_operand:DI 0 "gpc_reg_operand" "")
 
25690
        (ior:DI (match_operand:DI 1 "gpc_reg_operand" "")
 
25691
-               (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
 
25692
-  "TARGET_POWERPC64"
 
25693
-  "
 
25694
+               (match_operand:DI 2 "reg_or_cint_operand" "")))]
 
25695
+  ""
 
25696
 {
 
25697
-  if (non_logical_cint_operand (operands[2], DImode))
 
25698
+  if (!TARGET_POWERPC64)
 
25699
     {
 
25700
+      rs6000_split_logical (operands, IOR, false, false, false, NULL_RTX);
 
25701
+      DONE;
 
25702
+    }
 
25703
+  else if (!reg_or_logical_cint_operand (operands[2], DImode))
 
25704
+    operands[2] = force_reg (DImode, operands[2]);
 
25705
+  else if (non_logical_cint_operand (operands[2], DImode))
 
25706
+    {
 
25707
       HOST_WIDE_INT value;
 
25708
       rtx tmp = ((!can_create_pseudo_p ()
 
25709
                  || rtx_equal_p (operands[0], operands[1]))
 
25710
@@ -7408,15 +7533,21 @@
 
25711
       emit_insn (gen_iordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
 
25712
       DONE;
 
25713
     }
 
25714
-}")
 
25715
+})
 
25716
 
 
25717
 (define_expand "xordi3"
 
25718
   [(set (match_operand:DI 0 "gpc_reg_operand" "")
 
25719
        (xor:DI (match_operand:DI 1 "gpc_reg_operand" "")
 
25720
-               (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
 
25721
-  "TARGET_POWERPC64"
 
25722
-  "
 
25723
+               (match_operand:DI 2 "reg_or_cint_operand" "")))]
 
25724
+  ""
 
25725
 {
 
25726
+  if (!TARGET_POWERPC64)
 
25727
+    {
 
25728
+      rs6000_split_logical (operands, XOR, false, false, false, NULL_RTX);
 
25729
+      DONE;
 
25730
+    }
 
25731
+  else if (!reg_or_logical_cint_operand (operands[2], DImode))
 
25732
+    operands[2] = force_reg (DImode, operands[2]);
 
25733
   if (non_logical_cint_operand (operands[2], DImode))
 
25734
     {
 
25735
       HOST_WIDE_INT value;
 
25736
@@ -7442,7 +7573,7 @@
 
25737
       emit_insn (gen_xordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
 
25738
       DONE;
 
25739
     }
 
25740
-}")
 
25741
+})
 
25742
 
 
25743
 (define_insn "*booldi3_internal1"
 
25744
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
 
25745
@@ -7678,7 +7809,385 @@
 
25746
        (compare:CC (match_dup 0)
 
25747
                    (const_int 0)))]
 
25748
   "")
 
25749
+
 
25750
+;; Eqv operation.
 
25751
+(define_insn "*eqv<mode>3"
 
25752
+  [(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
 
25753
+       (not:GPR
 
25754
+        (xor:GPR (match_operand:GPR 1 "gpc_reg_operand" "r")
 
25755
+                 (match_operand:GPR 2 "gpc_reg_operand" "r"))))]
 
25756
+  ""
 
25757
+  "eqv %0,%1,%2"
 
25758
+  [(set_attr "type" "integer")
 
25759
+   (set_attr "length" "4")])
 
25760
+
 
25761
 
 
25762
+;; 128-bit logical operations expanders
 
25763
+
 
25764
+(define_expand "and<mode>3"
 
25765
+  [(parallel [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
 
25766
+                  (and:BOOL_128
 
25767
+                   (match_operand:BOOL_128 1 "vlogical_operand" "")
 
25768
+                   (match_operand:BOOL_128 2 "vlogical_operand" "")))
 
25769
+             (clobber (match_scratch:CC 3 ""))])]
 
25770
+  ""
 
25771
+  "")
 
25772
+
 
25773
+(define_expand "ior<mode>3"
 
25774
+  [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
 
25775
+        (ior:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")
 
25776
+                     (match_operand:BOOL_128 2 "vlogical_operand" "")))]
 
25777
+  ""
 
25778
+  "")
 
25779
+
 
25780
+(define_expand "xor<mode>3"
 
25781
+  [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
 
25782
+        (xor:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")
 
25783
+                     (match_operand:BOOL_128 2 "vlogical_operand" "")))]
 
25784
+  ""
 
25785
+  "")
 
25786
+
 
25787
+(define_expand "one_cmpl<mode>2"
 
25788
+  [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
 
25789
+        (not:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")))]
 
25790
+  ""
 
25791
+  "")
 
25792
+
 
25793
+(define_expand "nor<mode>3"
 
25794
+  [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
 
25795
+       (and:BOOL_128
 
25796
+        (not:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" ""))
 
25797
+        (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand" ""))))]
 
25798
+  ""
 
25799
+  "")
 
25800
+
 
25801
+(define_expand "andc<mode>3"
 
25802
+  [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
 
25803
+        (and:BOOL_128
 
25804
+        (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand" ""))
 
25805
+        (match_operand:BOOL_128 1 "vlogical_operand" "")))]
 
25806
+  ""
 
25807
+  "")
 
25808
+
 
25809
+;; Power8 vector logical instructions.
 
25810
+(define_expand "eqv<mode>3"
 
25811
+  [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
 
25812
+       (not:BOOL_128
 
25813
+        (xor:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" "")
 
25814
+                      (match_operand:BOOL_128 2 "vlogical_operand" ""))))]
 
25815
+  "<MODE>mode == TImode || <MODE>mode == PTImode || TARGET_P8_VECTOR"
 
25816
+  "")
 
25817
+
 
25818
+;; Rewrite nand into canonical form
 
25819
+(define_expand "nand<mode>3"
 
25820
+  [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
 
25821
+       (ior:BOOL_128
 
25822
+        (not:BOOL_128 (match_operand:BOOL_128 1 "vlogical_operand" ""))
 
25823
+        (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand" ""))))]
 
25824
+  "<MODE>mode == TImode || <MODE>mode == PTImode || TARGET_P8_VECTOR"
 
25825
+  "")
 
25826
+
 
25827
+;; The canonical form is to have the negated element first, so we need to
 
25828
+;; reverse arguments.
 
25829
+(define_expand "orc<mode>3"
 
25830
+  [(set (match_operand:BOOL_128 0 "vlogical_operand" "")
 
25831
+       (ior:BOOL_128
 
25832
+        (not:BOOL_128 (match_operand:BOOL_128 2 "vlogical_operand" ""))
 
25833
+        (match_operand:BOOL_128 1 "vlogical_operand" "")))]
 
25834
+  "<MODE>mode == TImode || <MODE>mode == PTImode || TARGET_P8_VECTOR"
 
25835
+  "")
 
25836
+
 
25837
+;; 128-bit logical operations insns and split operations
 
25838
+(define_insn_and_split "*and<mode>3_internal"
 
25839
+  [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
 
25840
+        (and:BOOL_128
 
25841
+        (match_operand:BOOL_128 1 "vlogical_operand" "%<BOOL_REGS_OP1>")
 
25842
+        (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>")))
 
25843
+   (clobber (match_scratch:CC 3 "<BOOL_REGS_AND_CR0>"))]
 
25844
+  ""
 
25845
+{
 
25846
+  if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
 
25847
+    return "xxland %x0,%x1,%x2";
 
25848
+
 
25849
+  if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
 
25850
+    return "vand %0,%1,%2";
 
25851
+
 
25852
+  return "#";
 
25853
+}
 
25854
+  "reload_completed && int_reg_operand (operands[0], <MODE>mode)"
 
25855
+  [(const_int 0)]
 
25856
+{
 
25857
+  rs6000_split_logical (operands, AND, false, false, false, operands[3]);
 
25858
+  DONE;
 
25859
+}
 
25860
+  [(set (attr "type")
 
25861
+      (if_then_else
 
25862
+       (match_test "vsx_register_operand (operands[0], <MODE>mode)")
 
25863
+       (const_string "vecsimple")
 
25864
+       (const_string "integer")))
 
25865
+   (set (attr "length")
 
25866
+      (if_then_else
 
25867
+       (match_test "vsx_register_operand (operands[0], <MODE>mode)")
 
25868
+       (const_string "4")
 
25869
+       (if_then_else
 
25870
+        (match_test "TARGET_POWERPC64")
 
25871
+        (const_string "8")
 
25872
+        (const_string "16"))))])
 
25873
+
 
25874
+;; 128-bit IOR/XOR
 
25875
+(define_insn_and_split "*bool<mode>3_internal"
 
25876
+  [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
 
25877
+       (match_operator:BOOL_128 3 "boolean_or_operator"
 
25878
+        [(match_operand:BOOL_128 1 "vlogical_operand" "%<BOOL_REGS_OP1>")
 
25879
+         (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>")]))]
 
25880
+  ""
 
25881
+{
 
25882
+  if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
 
25883
+    return "xxl%q3 %x0,%x1,%x2";
 
25884
+
 
25885
+  if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
 
25886
+    return "v%q3 %0,%1,%2";
 
25887
+
 
25888
+  return "#";
 
25889
+}
 
25890
+  "reload_completed && int_reg_operand (operands[0], <MODE>mode)"
 
25891
+  [(const_int 0)]
 
25892
+{
 
25893
+  rs6000_split_logical (operands, GET_CODE (operands[3]), false, false, false,
 
25894
+                       NULL_RTX);
 
25895
+  DONE;
 
25896
+}
 
25897
+  [(set (attr "type")
 
25898
+      (if_then_else
 
25899
+       (match_test "vsx_register_operand (operands[0], <MODE>mode)")
 
25900
+       (const_string "vecsimple")
 
25901
+       (const_string "integer")))
 
25902
+   (set (attr "length")
 
25903
+      (if_then_else
 
25904
+       (match_test "vsx_register_operand (operands[0], <MODE>mode)")
 
25905
+       (const_string "4")
 
25906
+       (if_then_else
 
25907
+        (match_test "TARGET_POWERPC64")
 
25908
+        (const_string "8")
 
25909
+        (const_string "16"))))])
 
25910
+
 
25911
+;; 128-bit ANDC/ORC
 
25912
+(define_insn_and_split "*boolc<mode>3_internal1"
 
25913
+  [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
 
25914
+       (match_operator:BOOL_128 3 "boolean_operator"
 
25915
+        [(not:BOOL_128
 
25916
+          (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP1>"))
 
25917
+         (match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_OP2>")]))]
 
25918
+  "TARGET_P8_VECTOR || (GET_CODE (operands[3]) == AND)"
 
25919
+{
 
25920
+  if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
 
25921
+    return "xxl%q3 %x0,%x1,%x2";
 
25922
+
 
25923
+  if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
 
25924
+    return "v%q3 %0,%1,%2";
 
25925
+
 
25926
+  return "#";
 
25927
+}
 
25928
+  "(TARGET_P8_VECTOR || (GET_CODE (operands[3]) == AND))
 
25929
+   && reload_completed && int_reg_operand (operands[0], <MODE>mode)"
 
25930
+  [(const_int 0)]
 
25931
+{
 
25932
+  rs6000_split_logical (operands, GET_CODE (operands[3]), false, true, false,
 
25933
+                       NULL_RTX);
 
25934
+  DONE;
 
25935
+}
 
25936
+  [(set (attr "type")
 
25937
+      (if_then_else
 
25938
+       (match_test "vsx_register_operand (operands[0], <MODE>mode)")
 
25939
+       (const_string "vecsimple")
 
25940
+       (const_string "integer")))
 
25941
+   (set (attr "length")
 
25942
+      (if_then_else
 
25943
+       (match_test "vsx_register_operand (operands[0], <MODE>mode)")
 
25944
+       (const_string "4")
 
25945
+       (if_then_else
 
25946
+        (match_test "TARGET_POWERPC64")
 
25947
+        (const_string "8")
 
25948
+        (const_string "16"))))])
 
25949
+
 
25950
+(define_insn_and_split "*boolc<mode>3_internal2"
 
25951
+  [(set (match_operand:TI2 0 "int_reg_operand" "=&r,r,r")
 
25952
+       (match_operator:TI2 3 "boolean_operator"
 
25953
+        [(not:TI2
 
25954
+          (match_operand:TI2 1 "int_reg_operand" "r,0,r"))
 
25955
+         (match_operand:TI2 2 "int_reg_operand" "r,r,0")]))]
 
25956
+  "!TARGET_P8_VECTOR && (GET_CODE (operands[3]) != AND)"
 
25957
+  "#"
 
25958
+  "reload_completed && !TARGET_P8_VECTOR && (GET_CODE (operands[3]) != AND)"
 
25959
+  [(const_int 0)]
 
25960
+{
 
25961
+  rs6000_split_logical (operands, GET_CODE (operands[3]), false, true, false,
 
25962
+                       NULL_RTX);
 
25963
+  DONE;
 
25964
+}
 
25965
+  [(set_attr "type" "integer")
 
25966
+   (set (attr "length")
 
25967
+       (if_then_else
 
25968
+        (match_test "TARGET_POWERPC64")
 
25969
+        (const_string "8")
 
25970
+        (const_string "16")))])
 
25971
+
 
25972
+;; 128-bit NAND/NOR
 
25973
+(define_insn_and_split "*boolcc<mode>3_internal1"
 
25974
+  [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
 
25975
+       (match_operator:BOOL_128 3 "boolean_operator"
 
25976
+        [(not:BOOL_128
 
25977
+          (match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_OP1>"))
 
25978
+         (not:BOOL_128
 
25979
+          (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>"))]))]
 
25980
+  "TARGET_P8_VECTOR || (GET_CODE (operands[3]) == AND)"
 
25981
+{
 
25982
+  if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
 
25983
+    return "xxl%q3 %x0,%x1,%x2";
 
25984
+
 
25985
+  if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
 
25986
+    return "v%q3 %0,%1,%2";
 
25987
+
 
25988
+  return "#";
 
25989
+}
 
25990
+  "(TARGET_P8_VECTOR || (GET_CODE (operands[3]) == AND))
 
25991
+   && reload_completed && int_reg_operand (operands[0], <MODE>mode)"
 
25992
+  [(const_int 0)]
 
25993
+{
 
25994
+  rs6000_split_logical (operands, GET_CODE (operands[3]), false, true, true,
 
25995
+                       NULL_RTX);
 
25996
+  DONE;
 
25997
+}
 
25998
+  [(set (attr "type")
 
25999
+      (if_then_else
 
26000
+       (match_test "vsx_register_operand (operands[0], <MODE>mode)")
 
26001
+       (const_string "vecsimple")
 
26002
+       (const_string "integer")))
 
26003
+   (set (attr "length")
 
26004
+      (if_then_else
 
26005
+       (match_test "vsx_register_operand (operands[0], <MODE>mode)")
 
26006
+       (const_string "4")
 
26007
+       (if_then_else
 
26008
+        (match_test "TARGET_POWERPC64")
 
26009
+        (const_string "8")
 
26010
+        (const_string "16"))))])
 
26011
+
 
26012
+(define_insn_and_split "*boolcc<mode>3_internal2"
 
26013
+  [(set (match_operand:TI2 0 "int_reg_operand" "=&r,r,r")
 
26014
+       (match_operator:TI2 3 "boolean_operator"
 
26015
+        [(not:TI2
 
26016
+          (match_operand:TI2 1 "int_reg_operand" "r,0,r"))
 
26017
+         (not:TI2
 
26018
+          (match_operand:TI2 2 "int_reg_operand" "r,r,0"))]))]
 
26019
+  "!TARGET_P8_VECTOR && (GET_CODE (operands[3]) != AND)"
 
26020
+  "#"
 
26021
+  "reload_completed && !TARGET_P8_VECTOR && (GET_CODE (operands[3]) != AND)"
 
26022
+  [(const_int 0)]
 
26023
+{
 
26024
+  rs6000_split_logical (operands, GET_CODE (operands[3]), false, true, true,
 
26025
+                       NULL_RTX);
 
26026
+  DONE;
 
26027
+}
 
26028
+  [(set_attr "type" "integer")
 
26029
+   (set (attr "length")
 
26030
+       (if_then_else
 
26031
+        (match_test "TARGET_POWERPC64")
 
26032
+        (const_string "8")
 
26033
+        (const_string "16")))])
 
26034
+
 
26035
+
 
26036
+;; 128-bit EQV
 
26037
+(define_insn_and_split "*eqv<mode>3_internal1"
 
26038
+  [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
 
26039
+       (not:BOOL_128
 
26040
+        (xor:BOOL_128
 
26041
+         (match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_OP1>")
 
26042
+         (match_operand:BOOL_128 2 "vlogical_operand" "<BOOL_REGS_OP2>"))))]
 
26043
+  "TARGET_P8_VECTOR"
 
26044
+{
 
26045
+  if (vsx_register_operand (operands[0], <MODE>mode))
 
26046
+    return "xxleqv %x0,%x1,%x2";
 
26047
+
 
26048
+  return "#";
 
26049
+}
 
26050
+  "TARGET_P8_VECTOR && reload_completed
 
26051
+   && int_reg_operand (operands[0], <MODE>mode)"
 
26052
+  [(const_int 0)]
 
26053
+{
 
26054
+  rs6000_split_logical (operands, XOR, true, false, false, NULL_RTX);
 
26055
+  DONE;
 
26056
+}
 
26057
+  [(set (attr "type")
 
26058
+      (if_then_else
 
26059
+       (match_test "vsx_register_operand (operands[0], <MODE>mode)")
 
26060
+       (const_string "vecsimple")
 
26061
+       (const_string "integer")))
 
26062
+   (set (attr "length")
 
26063
+      (if_then_else
 
26064
+       (match_test "vsx_register_operand (operands[0], <MODE>mode)")
 
26065
+       (const_string "4")
 
26066
+       (if_then_else
 
26067
+        (match_test "TARGET_POWERPC64")
 
26068
+        (const_string "8")
 
26069
+        (const_string "16"))))])
 
26070
+
 
26071
+(define_insn_and_split "*eqv<mode>3_internal2"
 
26072
+  [(set (match_operand:TI2 0 "int_reg_operand" "=&r,r,r")
 
26073
+       (not:TI2
 
26074
+        (xor:TI2
 
26075
+         (match_operand:TI2 1 "int_reg_operand" "r,0,r")
 
26076
+         (match_operand:TI2 2 "int_reg_operand" "r,r,0"))))]
 
26077
+  "!TARGET_P8_VECTOR"
 
26078
+  "#"
 
26079
+  "reload_completed && !TARGET_P8_VECTOR"
 
26080
+  [(const_int 0)]
 
26081
+{
 
26082
+  rs6000_split_logical (operands, XOR, true, false, false, NULL_RTX);
 
26083
+  DONE;
 
26084
+}
 
26085
+  [(set_attr "type" "integer")
 
26086
+   (set (attr "length")
 
26087
+       (if_then_else
 
26088
+        (match_test "TARGET_POWERPC64")
 
26089
+        (const_string "8")
 
26090
+        (const_string "16")))])
 
26091
+
 
26092
+;; 128-bit one's complement
 
26093
+(define_insn_and_split "*one_cmpl<mode>3_internal"
 
26094
+  [(set (match_operand:BOOL_128 0 "vlogical_operand" "=<BOOL_REGS_OUTPUT>")
 
26095
+       (not:BOOL_128
 
26096
+         (match_operand:BOOL_128 1 "vlogical_operand" "<BOOL_REGS_UNARY>")))]
 
26097
+  ""
 
26098
+{
 
26099
+  if (TARGET_VSX && vsx_register_operand (operands[0], <MODE>mode))
 
26100
+    return "xxlnor %x0,%x1,%x1";
 
26101
+
 
26102
+  if (TARGET_ALTIVEC && altivec_register_operand (operands[0], <MODE>mode))
 
26103
+    return "vnor %0,%1,%1";
 
26104
+
 
26105
+  return "#";
 
26106
+}
 
26107
+  "reload_completed && int_reg_operand (operands[0], <MODE>mode)"
 
26108
+  [(const_int 0)]
 
26109
+{
 
26110
+  rs6000_split_logical (operands, NOT, false, false, false, NULL_RTX);
 
26111
+  DONE;
 
26112
+}
 
26113
+  [(set (attr "type")
 
26114
+      (if_then_else
 
26115
+       (match_test "vsx_register_operand (operands[0], <MODE>mode)")
 
26116
+       (const_string "vecsimple")
 
26117
+       (const_string "integer")))
 
26118
+   (set (attr "length")
 
26119
+      (if_then_else
 
26120
+       (match_test "vsx_register_operand (operands[0], <MODE>mode)")
 
26121
+       (const_string "4")
 
26122
+       (if_then_else
 
26123
+        (match_test "TARGET_POWERPC64")
 
26124
+        (const_string "8")
 
26125
+        (const_string "16"))))])
 
26126
+
 
26127
+
 
26128
 ;; Now define ways of moving data around.
 
26129
 
 
26130
 ;; Set up a register with a value from the GOT table
 
26131
@@ -7765,7 +8274,31 @@
 
26132
    mt%0 %1
 
26133
    mt%0 %1
 
26134
    nop"
 
26135
-  [(set_attr "type" "*,*,load,store,*,*,*,mfjmpr,mtjmpr,*,*")
 
26136
+  [(set_attr_alternative "type"
 
26137
+      [(const_string "*")
 
26138
+       (const_string "*")
 
26139
+       (if_then_else
 
26140
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
26141
+        (const_string "load_ux")
 
26142
+        (if_then_else
 
26143
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
26144
+          (const_string "load_u")
 
26145
+          (const_string "load")))
 
26146
+       (if_then_else
 
26147
+        (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
26148
+        (const_string "store_ux")
 
26149
+        (if_then_else
 
26150
+          (match_test "update_address_mem (operands[0], VOIDmode)")
 
26151
+          (const_string "store_u")
 
26152
+          (const_string "store")))
 
26153
+       (const_string "*")
 
26154
+       (const_string "*")
 
26155
+       (const_string "*")
 
26156
+       (const_string "mfjmpr")
 
26157
+       (const_string "mtjmpr")
 
26158
+       (const_string "*")
 
26159
+       (const_string "*")])
 
26160
+
 
26161
    (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4")])
 
26162
 
 
26163
 (define_insn "*movsi_internal1_single"
 
26164
@@ -7787,7 +8320,44 @@
 
26165
    nop
 
26166
    stfs%U0%X0 %1,%0
 
26167
    lfs%U1%X1 %0,%1"
 
26168
-  [(set_attr "type" "*,*,load,store,*,*,*,mfjmpr,mtjmpr,*,*,*,*")
 
26169
+  [(set_attr_alternative "type"
 
26170
+      [(const_string "*")
 
26171
+       (const_string "*")
 
26172
+       (if_then_else
 
26173
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
26174
+        (const_string "load_ux")
 
26175
+        (if_then_else
 
26176
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
26177
+          (const_string "load_u")
 
26178
+          (const_string "load")))
 
26179
+       (if_then_else
 
26180
+        (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
26181
+        (const_string "store_ux")
 
26182
+        (if_then_else
 
26183
+          (match_test "update_address_mem (operands[0], VOIDmode)")
 
26184
+          (const_string "store_u")
 
26185
+          (const_string "store")))
 
26186
+       (const_string "*")
 
26187
+       (const_string "*")
 
26188
+       (const_string "*")
 
26189
+       (const_string "mfjmpr")
 
26190
+       (const_string "mtjmpr")
 
26191
+       (const_string "*")
 
26192
+       (const_string "*")
 
26193
+       (if_then_else
 
26194
+        (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
26195
+        (const_string "fpstore_ux")
 
26196
+        (if_then_else
 
26197
+          (match_test "update_address_mem (operands[0], VOIDmode)")
 
26198
+          (const_string "fpstore_u")
 
26199
+          (const_string "fpstore")))
 
26200
+       (if_then_else
 
26201
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
26202
+        (const_string "fpload_ux")
 
26203
+        (if_then_else
 
26204
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
26205
+          (const_string "fpload_u")
 
26206
+          (const_string "fpload")))])
 
26207
    (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4,4,4")])
 
26208
 
 
26209
 ;; Split a load of a large constant into the appropriate two-insn
 
26210
@@ -7822,7 +8392,7 @@
 
26211
    cmp<wd>i %2,%0,0
 
26212
    mr. %0,%1
 
26213
    #"
 
26214
-  [(set_attr "type" "cmp,compare,cmp")
 
26215
+  [(set_attr "type" "cmp,fast_compare,cmp")
 
26216
    (set_attr "length" "4,4,8")])
 
26217
 
 
26218
 (define_split
 
26219
@@ -7850,7 +8420,26 @@
 
26220
    mf%1 %0
 
26221
    mt%0 %1
 
26222
    nop"
 
26223
-  [(set_attr "type" "*,load,store,*,mfjmpr,mtjmpr,*")])
 
26224
+  [(set_attr_alternative "type"
 
26225
+      [(const_string "*")
 
26226
+       (if_then_else
 
26227
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
26228
+        (const_string "load_ux")
 
26229
+        (if_then_else
 
26230
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
26231
+          (const_string "load_u")
 
26232
+          (const_string "load")))
 
26233
+       (if_then_else
 
26234
+        (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
26235
+        (const_string "store_ux")
 
26236
+        (if_then_else
 
26237
+          (match_test "update_address_mem (operands[0], VOIDmode)")
 
26238
+          (const_string "store_u")
 
26239
+          (const_string "store")))
 
26240
+       (const_string "*")
 
26241
+       (const_string "mfjmpr")
 
26242
+       (const_string "mtjmpr")
 
26243
+       (const_string "*")])])
 
26244
 
 
26245
 (define_expand "mov<mode>"
 
26246
   [(set (match_operand:INT 0 "general_operand" "")
 
26247
@@ -7871,7 +8460,26 @@
 
26248
    mf%1 %0
 
26249
    mt%0 %1
 
26250
    nop"
 
26251
-  [(set_attr "type" "*,load,store,*,mfjmpr,mtjmpr,*")])
 
26252
+  [(set_attr_alternative "type"
 
26253
+      [(const_string "*")
 
26254
+       (if_then_else
 
26255
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
26256
+        (const_string "load_ux")
 
26257
+        (if_then_else
 
26258
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
26259
+          (const_string "load_u")
 
26260
+          (const_string "load")))
 
26261
+       (if_then_else
 
26262
+        (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
26263
+        (const_string "store_ux")
 
26264
+        (if_then_else
 
26265
+          (match_test "update_address_mem (operands[0], VOIDmode)")
 
26266
+          (const_string "store_u")
 
26267
+          (const_string "store")))
 
26268
+       (const_string "*")
 
26269
+       (const_string "mfjmpr")
 
26270
+       (const_string "mtjmpr")
 
26271
+       (const_string "*")])])
 
26272
 
 
26273
 ;; Here is how to move condition codes around.  When we store CC data in
 
26274
 ;; an integer register or memory, we store just the high-order 4 bits.
 
26275
@@ -7899,7 +8507,7 @@
 
26276
    mf%1 %0
 
26277
    mt%0 %1
 
26278
    lwz%U1%X1 %0,%1
 
26279
-   stw%U0%U1 %1,%0"
 
26280
+   stw%U0%X0 %1,%0"
 
26281
   [(set (attr "type")
 
26282
      (cond [(eq_attr "alternative" "0,3")
 
26283
                (const_string "cr_logical")
 
26284
@@ -7912,9 +8520,23 @@
 
26285
            (eq_attr "alternative" "9")
 
26286
                (const_string "mtjmpr")
 
26287
            (eq_attr "alternative" "10")
 
26288
-               (const_string "load")
 
26289
+               (if_then_else
 
26290
+                 (match_test "update_indexed_address_mem (operands[1],
 
26291
+                                                          VOIDmode)")
 
26292
+                 (const_string "load_ux")
 
26293
+                 (if_then_else
 
26294
+                   (match_test "update_address_mem (operands[1], VOIDmode)")
 
26295
+                   (const_string "load_u")
 
26296
+                   (const_string "load")))
 
26297
            (eq_attr "alternative" "11")
 
26298
-               (const_string "store")
 
26299
+               (if_then_else
 
26300
+                 (match_test "update_indexed_address_mem (operands[0],
 
26301
+                                                          VOIDmode)")
 
26302
+                 (const_string "store_ux")
 
26303
+                 (if_then_else
 
26304
+                   (match_test "update_address_mem (operands[0], VOIDmode)")
 
26305
+                   (const_string "store_u")
 
26306
+                   (const_string "store")))
 
26307
            (match_test "TARGET_MFCRF")
 
26308
                (const_string "mfcrf")
 
26309
           ]
 
26310
@@ -7926,15 +8548,17 @@
 
26311
 ;; can produce floating-point values in fixed-point registers.  Unless the
 
26312
 ;; value is a simple constant or already in memory, we deal with this by
 
26313
 ;; allocating memory and copying the value explicitly via that memory location.
 
26314
-(define_expand "movsf"
 
26315
-  [(set (match_operand:SF 0 "nonimmediate_operand" "")
 
26316
-       (match_operand:SF 1 "any_operand" ""))]
 
26317
-  ""
 
26318
-  "{ rs6000_emit_move (operands[0], operands[1], SFmode); DONE; }")
 
26319
 
 
26320
+;; Move 32-bit binary/decimal floating point
 
26321
+(define_expand "mov<mode>"
 
26322
+  [(set (match_operand:FMOVE32 0 "nonimmediate_operand" "")
 
26323
+       (match_operand:FMOVE32 1 "any_operand" ""))]
 
26324
+  "<fmove_ok>"
 
26325
+  "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
 
26326
+
 
26327
 (define_split
 
26328
-  [(set (match_operand:SF 0 "gpc_reg_operand" "")
 
26329
-       (match_operand:SF 1 "const_double_operand" ""))]
 
26330
+  [(set (match_operand:FMOVE32 0 "gpc_reg_operand" "")
 
26331
+       (match_operand:FMOVE32 1 "const_double_operand" ""))]
 
26332
   "reload_completed
 
26333
    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
 
26334
        || (GET_CODE (operands[0]) == SUBREG
 
26335
@@ -7947,42 +8571,89 @@
 
26336
   REAL_VALUE_TYPE rv;
 
26337
 
 
26338
   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
 
26339
-  REAL_VALUE_TO_TARGET_SINGLE (rv, l);
 
26340
+  <real_value_to_target> (rv, l);
 
26341
 
 
26342
   if (! TARGET_POWERPC64)
 
26343
-    operands[2] = operand_subword (operands[0], 0, 0, SFmode);
 
26344
+    operands[2] = operand_subword (operands[0], 0, 0, <MODE>mode);
 
26345
   else
 
26346
     operands[2] = gen_lowpart (SImode, operands[0]);
 
26347
 
 
26348
   operands[3] = gen_int_mode (l, SImode);
 
26349
 }")
 
26350
 
 
26351
-(define_insn "*movsf_hardfloat"
 
26352
-  [(set (match_operand:SF 0 "nonimmediate_operand" "=!r,!r,m,f,f,m,*c*l,!r,*h,!r,!r")
 
26353
-       (match_operand:SF 1 "input_operand" "r,m,r,f,m,f,r,h,0,G,Fn"))]
 
26354
-  "(gpc_reg_operand (operands[0], SFmode)
 
26355
-   || gpc_reg_operand (operands[1], SFmode))
 
26356
+(define_insn "mov<mode>_hardfloat"
 
26357
+  [(set (match_operand:FMOVE32 0 "nonimmediate_operand" "=!r,!r,m,f,wa,wa,<f32_lr>,<f32_sm>,wu,Z,?<f32_dm>,?r,*c*l,!r,*h,!r,!r")
 
26358
+       (match_operand:FMOVE32 1 "input_operand" "r,m,r,f,wa,j,<f32_lm>,<f32_sr>,Z,wu,r,<f32_dm>,r,h,0,G,Fn"))]
 
26359
+  "(gpc_reg_operand (operands[0], <MODE>mode)
 
26360
+   || gpc_reg_operand (operands[1], <MODE>mode))
 
26361
    && (TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT)"
 
26362
   "@
 
26363
    mr %0,%1
 
26364
    lwz%U1%X1 %0,%1
 
26365
    stw%U0%X0 %1,%0
 
26366
    fmr %0,%1
 
26367
-   lfs%U1%X1 %0,%1
 
26368
-   stfs%U0%X0 %1,%0
 
26369
+   xxlor %x0,%x1,%x1
 
26370
+   xxlxor %x0,%x0,%x0
 
26371
+   <f32_li>
 
26372
+   <f32_si>
 
26373
+   <f32_lv>
 
26374
+   <f32_sv>
 
26375
+   mtvsrwz %x0,%1
 
26376
+   mfvsrwz %0,%x1
 
26377
    mt%0 %1
 
26378
    mf%1 %0
 
26379
    nop
 
26380
    #
 
26381
    #"
 
26382
-  [(set_attr "type" "*,load,store,fp,fpload,fpstore,mtjmpr,mfjmpr,*,*,*")
 
26383
-   (set_attr "length" "4,4,4,4,4,4,4,4,4,4,8")])
 
26384
+  [(set_attr_alternative "type"
 
26385
+      [(const_string "*")
 
26386
+       (if_then_else
 
26387
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
26388
+        (const_string "load_ux")
 
26389
+        (if_then_else
 
26390
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
26391
+          (const_string "load_u")
 
26392
+          (const_string "load")))
 
26393
+       (if_then_else
 
26394
+        (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
26395
+        (const_string "store_ux")
 
26396
+        (if_then_else
 
26397
+          (match_test "update_address_mem (operands[0], VOIDmode)")
 
26398
+          (const_string "store_u")
 
26399
+          (const_string "store")))
 
26400
+       (const_string "fp")
 
26401
+       (const_string "vecsimple")
 
26402
+       (const_string "vecsimple")
 
26403
+       (if_then_else
 
26404
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
26405
+        (const_string "fpload_ux")
 
26406
+        (if_then_else
 
26407
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
26408
+          (const_string "fpload_u")
 
26409
+          (const_string "fpload")))
 
26410
+       (if_then_else
 
26411
+        (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
26412
+        (const_string "fpstore_ux")
 
26413
+        (if_then_else
 
26414
+          (match_test "update_address_mem (operands[0], VOIDmode)")
 
26415
+          (const_string "fpstore_u")
 
26416
+          (const_string "fpstore")))
 
26417
+       (const_string "fpload")
 
26418
+       (const_string "fpstore")
 
26419
+       (const_string "mftgpr")
 
26420
+       (const_string "mffgpr")
 
26421
+       (const_string "mtjmpr")
 
26422
+       (const_string "mfjmpr")
 
26423
+       (const_string "*")
 
26424
+       (const_string "*")
 
26425
+       (const_string "*")])
 
26426
+   (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,8")])
 
26427
 
 
26428
-(define_insn "*movsf_softfloat"
 
26429
-  [(set (match_operand:SF 0 "nonimmediate_operand" "=r,cl,r,r,m,r,r,r,r,*h")
 
26430
-       (match_operand:SF 1 "input_operand" "r,r,h,m,r,I,L,G,Fn,0"))]
 
26431
-  "(gpc_reg_operand (operands[0], SFmode)
 
26432
-   || gpc_reg_operand (operands[1], SFmode))
 
26433
+(define_insn "*mov<mode>_softfloat"
 
26434
+  [(set (match_operand:FMOVE32 0 "nonimmediate_operand" "=r,cl,r,r,m,r,r,r,r,*h")
 
26435
+       (match_operand:FMOVE32 1 "input_operand" "r,r,h,m,r,I,L,G,Fn,0"))]
 
26436
+  "(gpc_reg_operand (operands[0], <MODE>mode)
 
26437
+   || gpc_reg_operand (operands[1], <MODE>mode))
 
26438
    && (TARGET_SOFT_FLOAT || !TARGET_FPRS)"
 
26439
   "@
 
26440
    mr %0,%1
 
26441
@@ -7995,19 +8666,42 @@
 
26442
    #
 
26443
    #
 
26444
    nop"
 
26445
-  [(set_attr "type" "*,mtjmpr,mfjmpr,load,store,*,*,*,*,*")
 
26446
+  [(set_attr_alternative "type"
 
26447
+      [(const_string "*")
 
26448
+       (const_string "mtjmpr")
 
26449
+       (const_string "mfjmpr")
 
26450
+       (if_then_else
 
26451
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
26452
+        (const_string "load_ux")
 
26453
+        (if_then_else
 
26454
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
26455
+          (const_string "load_u")
 
26456
+          (const_string "load")))
 
26457
+       (if_then_else
 
26458
+        (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
26459
+        (const_string "store_ux")
 
26460
+        (if_then_else
 
26461
+          (match_test "update_address_mem (operands[0], VOIDmode)")
 
26462
+          (const_string "store_u")
 
26463
+          (const_string "store")))
 
26464
+       (const_string "*")
 
26465
+       (const_string "*")
 
26466
+       (const_string "*")
 
26467
+       (const_string "*")
 
26468
+       (const_string "*")])
 
26469
    (set_attr "length" "4,4,4,4,4,4,4,4,8,4")])
 
26470
 
 
26471
 
 
26472
-(define_expand "movdf"
 
26473
-  [(set (match_operand:DF 0 "nonimmediate_operand" "")
 
26474
-       (match_operand:DF 1 "any_operand" ""))]
 
26475
+;; Move 64-bit binary/decimal floating point
 
26476
+(define_expand "mov<mode>"
 
26477
+  [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "")
 
26478
+       (match_operand:FMOVE64 1 "any_operand" ""))]
 
26479
   ""
 
26480
-  "{ rs6000_emit_move (operands[0], operands[1], DFmode); DONE; }")
 
26481
+  "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
 
26482
 
 
26483
 (define_split
 
26484
-  [(set (match_operand:DF 0 "gpc_reg_operand" "")
 
26485
-       (match_operand:DF 1 "const_int_operand" ""))]
 
26486
+  [(set (match_operand:FMOVE64 0 "gpc_reg_operand" "")
 
26487
+       (match_operand:FMOVE64 1 "const_int_operand" ""))]
 
26488
   "! TARGET_POWERPC64 && reload_completed
 
26489
    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
 
26490
        || (GET_CODE (operands[0]) == SUBREG
 
26491
@@ -8020,8 +8714,8 @@
 
26492
   int endian = (WORDS_BIG_ENDIAN == 0);
 
26493
   HOST_WIDE_INT value = INTVAL (operands[1]);
 
26494
 
 
26495
-  operands[2] = operand_subword (operands[0], endian, 0, DFmode);
 
26496
-  operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
 
26497
+  operands[2] = operand_subword (operands[0], endian, 0, <MODE>mode);
 
26498
+  operands[3] = operand_subword (operands[0], 1 - endian, 0, <MODE>mode);
 
26499
 #if HOST_BITS_PER_WIDE_INT == 32
 
26500
   operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
 
26501
 #else
 
26502
@@ -8031,8 +8725,8 @@
 
26503
 }")
 
26504
 
 
26505
 (define_split
 
26506
-  [(set (match_operand:DF 0 "gpc_reg_operand" "")
 
26507
-       (match_operand:DF 1 "const_double_operand" ""))]
 
26508
+  [(set (match_operand:FMOVE64 0 "gpc_reg_operand" "")
 
26509
+       (match_operand:FMOVE64 1 "const_double_operand" ""))]
 
26510
   "! TARGET_POWERPC64 && reload_completed
 
26511
    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
 
26512
        || (GET_CODE (operands[0]) == SUBREG
 
26513
@@ -8047,17 +8741,17 @@
 
26514
   REAL_VALUE_TYPE rv;
 
26515
 
 
26516
   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
 
26517
-  REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
 
26518
+  <real_value_to_target> (rv, l);
 
26519
 
 
26520
-  operands[2] = operand_subword (operands[0], endian, 0, DFmode);
 
26521
-  operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
 
26522
+  operands[2] = operand_subword (operands[0], endian, 0, <MODE>mode);
 
26523
+  operands[3] = operand_subword (operands[0], 1 - endian, 0, <MODE>mode);
 
26524
   operands[4] = gen_int_mode (l[endian], SImode);
 
26525
   operands[5] = gen_int_mode (l[1 - endian], SImode);
 
26526
 }")
 
26527
 
 
26528
 (define_split
 
26529
-  [(set (match_operand:DF 0 "gpc_reg_operand" "")
 
26530
-       (match_operand:DF 1 "const_double_operand" ""))]
 
26531
+  [(set (match_operand:FMOVE64 0 "gpc_reg_operand" "")
 
26532
+       (match_operand:FMOVE64 1 "const_double_operand" ""))]
 
26533
   "TARGET_POWERPC64 && reload_completed
 
26534
    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
 
26535
        || (GET_CODE (operands[0]) == SUBREG
 
26536
@@ -8074,7 +8768,7 @@
 
26537
 #endif
 
26538
 
 
26539
   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
 
26540
-  REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
 
26541
+  <real_value_to_target> (rv, l);
 
26542
 
 
26543
   operands[2] = gen_lowpart (DImode, operands[0]);
 
26544
   /* HIGHPART is lower memory address when WORDS_BIG_ENDIAN.  */
 
26545
@@ -8099,22 +8793,19 @@
 
26546
 ;; since the D-form version of the memory instructions does not need a GPR for
 
26547
 ;; reloading.
 
26548
 
 
26549
-(define_insn "*movdf_hardfloat32"
 
26550
-  [(set (match_operand:DF 0 "nonimmediate_operand" "=m,d,d,ws,?wa,Z,?Z,ws,?wa,wa,Y,r,!r,!r,!r,!r")
 
26551
-       (match_operand:DF 1 "input_operand" "d,m,d,Z,Z,ws,wa,ws,wa,j,r,Y,r,G,H,F"))]
 
26552
+(define_insn "*mov<mode>_hardfloat32"
 
26553
+  [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=m,d,d,wv,Z,wa,wa,Y,r,!r,!r,!r,!r")
 
26554
+       (match_operand:FMOVE64 1 "input_operand" "d,m,d,Z,wv,wa,j,r,Y,r,G,H,F"))]
 
26555
   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT 
 
26556
-   && (gpc_reg_operand (operands[0], DFmode)
 
26557
-       || gpc_reg_operand (operands[1], DFmode))"
 
26558
+   && (gpc_reg_operand (operands[0], <MODE>mode)
 
26559
+       || gpc_reg_operand (operands[1], <MODE>mode))"
 
26560
   "@
 
26561
    stfd%U0%X0 %1,%0
 
26562
    lfd%U1%X1 %0,%1
 
26563
    fmr %0,%1
 
26564
    lxsd%U1x %x0,%y1
 
26565
-   lxsd%U1x %x0,%y1
 
26566
    stxsd%U0x %x1,%y0
 
26567
-   stxsd%U0x %x1,%y0
 
26568
    xxlor %x0,%x1,%x1
 
26569
-   xxlor %x0,%x1,%x1
 
26570
    xxlxor %x0,%x0,%x0
 
26571
    #
 
26572
    #
 
26573
@@ -8122,115 +8813,140 @@
 
26574
    #
 
26575
    #
 
26576
    #"
 
26577
-  [(set_attr "type" "fpstore,fpload,fp,fpload,fpload,fpstore,fpstore,vecsimple,vecsimple,vecsimple,store,load,two,fp,fp,*")
 
26578
-   (set_attr "length" "4,4,4,4,4,4,4,4,4,4,8,8,8,8,12,16")])
 
26579
+  [(set_attr_alternative "type"
 
26580
+      [(if_then_else
 
26581
+        (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
26582
+        (const_string "fpstore_ux")
 
26583
+        (if_then_else
 
26584
+          (match_test "update_address_mem (operands[0], VOIDmode)")
 
26585
+          (const_string "fpstore_u")
 
26586
+          (const_string "fpstore")))
 
26587
+       (if_then_else
 
26588
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
26589
+        (const_string "fpload_ux")
 
26590
+        (if_then_else
 
26591
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
26592
+          (const_string "fpload_u")
 
26593
+          (const_string "fpload")))
 
26594
+       (const_string "fp")
 
26595
+       (if_then_else
 
26596
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
26597
+        (const_string "fpload_ux")
 
26598
+        (const_string "fpload"))
 
26599
+       (if_then_else
 
26600
+        (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
26601
+        (const_string "fpstore_ux")
 
26602
+        (const_string "fpstore"))
 
26603
+       (const_string "vecsimple")
 
26604
+       (const_string "vecsimple")
 
26605
+       (const_string "store")
 
26606
+       (const_string "load")
 
26607
+       (const_string "two")
 
26608
+       (const_string "fp")
 
26609
+       (const_string "fp")
 
26610
+       (const_string "*")])
 
26611
+   (set_attr "length" "4,4,4,4,4,4,4,8,8,8,8,12,16")])
 
26612
 
 
26613
-(define_insn "*movdf_softfloat32"
 
26614
-  [(set (match_operand:DF 0 "nonimmediate_operand" "=Y,r,r,r,r,r")
 
26615
-       (match_operand:DF 1 "input_operand" "r,Y,r,G,H,F"))]
 
26616
+(define_insn "*mov<mode>_softfloat32"
 
26617
+  [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=Y,r,r,r,r,r")
 
26618
+       (match_operand:FMOVE64 1 "input_operand" "r,Y,r,G,H,F"))]
 
26619
   "! TARGET_POWERPC64 
 
26620
    && ((TARGET_FPRS && TARGET_SINGLE_FLOAT) 
 
26621
        || TARGET_SOFT_FLOAT || TARGET_E500_SINGLE)
 
26622
-   && (gpc_reg_operand (operands[0], DFmode)
 
26623
-       || gpc_reg_operand (operands[1], DFmode))"
 
26624
+   && (gpc_reg_operand (operands[0], <MODE>mode)
 
26625
+       || gpc_reg_operand (operands[1], <MODE>mode))"
 
26626
   "#"
 
26627
   [(set_attr "type" "store,load,two,*,*,*")
 
26628
    (set_attr "length" "8,8,8,8,12,16")])
 
26629
 
 
26630
-;; Reload patterns to support gpr load/store with misaligned mem.
 
26631
-;; and multiple gpr load/store at offset >= 0xfffc
 
26632
-(define_expand "reload_<mode>_store"
 
26633
-  [(parallel [(match_operand 0 "memory_operand" "=m")
 
26634
-              (match_operand 1 "gpc_reg_operand" "r")
 
26635
-              (match_operand:GPR 2 "register_operand" "=&b")])]
 
26636
-  ""
 
26637
-{
 
26638
-  rs6000_secondary_reload_gpr (operands[1], operands[0], operands[2], true);
 
26639
-  DONE;
 
26640
-})
 
26641
-
 
26642
-(define_expand "reload_<mode>_load"
 
26643
-  [(parallel [(match_operand 0 "gpc_reg_operand" "=r")
 
26644
-              (match_operand 1 "memory_operand" "m")
 
26645
-              (match_operand:GPR 2 "register_operand" "=b")])]
 
26646
-  ""
 
26647
-{
 
26648
-  rs6000_secondary_reload_gpr (operands[0], operands[1], operands[2], false);
 
26649
-  DONE;
 
26650
-})
 
26651
-
 
26652
 ; ld/std require word-aligned displacements -> 'Y' constraint.
 
26653
 ; List Y->r and r->Y before r->r for reload.
 
26654
-(define_insn "*movdf_hardfloat64_mfpgpr"
 
26655
-  [(set (match_operand:DF 0 "nonimmediate_operand" "=Y,r,!r,ws,?wa,ws,?wa,Z,?Z,m,d,d,wa,*c*l,!r,*h,!r,!r,!r,r,d")
 
26656
-       (match_operand:DF 1 "input_operand" "r,Y,r,ws,?wa,Z,Z,ws,wa,d,m,d,j,r,h,0,G,H,F,d,r"))]
 
26657
-  "TARGET_POWERPC64 && TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS 
 
26658
-   && TARGET_DOUBLE_FLOAT
 
26659
-   && (gpc_reg_operand (operands[0], DFmode)
 
26660
-       || gpc_reg_operand (operands[1], DFmode))"
 
26661
+(define_insn "*mov<mode>_hardfloat64"
 
26662
+  [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=m,d,d,wv,Z,wa,wa,Y,r,!r,*c*l,!r,*h,!r,!r,!r,r,wg,r,wm")
 
26663
+       (match_operand:FMOVE64 1 "input_operand" "d,m,d,Z,wv,wa,j,r,Y,r,r,h,0,G,H,F,wg,r,wm,r"))]
 
26664
+  "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
 
26665
+   && (gpc_reg_operand (operands[0], <MODE>mode)
 
26666
+       || gpc_reg_operand (operands[1], <MODE>mode))"
 
26667
   "@
 
26668
-   std%U0%X0 %1,%0
 
26669
-   ld%U1%X1 %0,%1
 
26670
-   mr %0,%1
 
26671
-   xxlor %x0,%x1,%x1
 
26672
-   xxlor %x0,%x1,%x1
 
26673
-   lxsd%U1x %x0,%y1
 
26674
-   lxsd%U1x %x0,%y1
 
26675
-   stxsd%U0x %x1,%y0
 
26676
-   stxsd%U0x %x1,%y0
 
26677
    stfd%U0%X0 %1,%0
 
26678
    lfd%U1%X1 %0,%1
 
26679
    fmr %0,%1
 
26680
+   lxsd%U1x %x0,%y1
 
26681
+   stxsd%U0x %x1,%y0
 
26682
+   xxlor %x0,%x1,%x1
 
26683
    xxlxor %x0,%x0,%x0
 
26684
-   mt%0 %1
 
26685
-   mf%1 %0
 
26686
-   nop
 
26687
-   #
 
26688
-   #
 
26689
-   #
 
26690
-   mftgpr %0,%1
 
26691
-   mffgpr %0,%1"
 
26692
-  [(set_attr "type" "store,load,*,fp,fp,fpload,fpload,fpstore,fpstore,fpstore,fpload,fp,vecsimple,mtjmpr,mfjmpr,*,*,*,*,mftgpr,mffgpr")
 
26693
-   (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,8,12,16,4,4")])
 
26694
-
 
26695
-; ld/std require word-aligned displacements -> 'Y' constraint.
 
26696
-; List Y->r and r->Y before r->r for reload.
 
26697
-(define_insn "*movdf_hardfloat64"
 
26698
-  [(set (match_operand:DF 0 "nonimmediate_operand" "=m,d,d,Y,r,!r,ws,?wa,Z,?Z,ws,?wa,wa,*c*l,!r,*h,!r,!r,!r")
 
26699
-       (match_operand:DF 1 "input_operand" "d,m,d,r,Y,r,Z,Z,ws,wa,ws,wa,j,r,h,0,G,H,F"))]
 
26700
-  "TARGET_POWERPC64 && !TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS 
 
26701
-   && TARGET_DOUBLE_FLOAT
 
26702
-   && (gpc_reg_operand (operands[0], DFmode)
 
26703
-       || gpc_reg_operand (operands[1], DFmode))"
 
26704
-  "@
 
26705
-   stfd%U0%X0 %1,%0
 
26706
-   lfd%U1%X1 %0,%1
 
26707
-   fmr %0,%1
 
26708
    std%U0%X0 %1,%0
 
26709
    ld%U1%X1 %0,%1
 
26710
    mr %0,%1
 
26711
-   lxsd%U1x %x0,%y1
 
26712
-   lxsd%U1x %x0,%y1
 
26713
-   stxsd%U0x %x1,%y0
 
26714
-   stxsd%U0x %x1,%y0
 
26715
-   xxlor %x0,%x1,%x1
 
26716
-   xxlor %x0,%x1,%x1
 
26717
-   xxlxor %x0,%x0,%x0
 
26718
    mt%0 %1
 
26719
    mf%1 %0
 
26720
    nop
 
26721
    #
 
26722
    #
 
26723
-   #"
 
26724
-  [(set_attr "type" "fpstore,fpload,fp,store,load,*,fpload,fpload,fpstore,fpstore,vecsimple,vecsimple,vecsimple,mtjmpr,mfjmpr,*,*,*,*")
 
26725
-   (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,8,12,16")])
 
26726
+   #
 
26727
+   mftgpr %0,%1
 
26728
+   mffgpr %0,%1
 
26729
+   mfvsrd %0,%x1
 
26730
+   mtvsrd %x0,%1"
 
26731
+  [(set_attr_alternative "type"
 
26732
+      [(if_then_else
 
26733
+        (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
26734
+        (const_string "fpstore_ux")
 
26735
+        (if_then_else
 
26736
+          (match_test "update_address_mem (operands[0], VOIDmode)")
 
26737
+          (const_string "fpstore_u")
 
26738
+          (const_string "fpstore")))
 
26739
+       (if_then_else
 
26740
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
26741
+        (const_string "fpload_ux")
 
26742
+        (if_then_else
 
26743
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
26744
+          (const_string "fpload_u")
 
26745
+          (const_string "fpload")))
 
26746
+       (const_string "fp")
 
26747
+       (if_then_else
 
26748
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
26749
+        (const_string "fpload_ux")
 
26750
+        (const_string "fpload"))
 
26751
+       (if_then_else
 
26752
+        (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
26753
+        (const_string "fpstore_ux")
 
26754
+        (const_string "fpstore"))
 
26755
+       (const_string "vecsimple")
 
26756
+       (const_string "vecsimple")
 
26757
+       (if_then_else
 
26758
+        (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
26759
+        (const_string "store_ux")
 
26760
+        (if_then_else
 
26761
+          (match_test "update_address_mem (operands[0], VOIDmode)")
 
26762
+          (const_string "store_u")
 
26763
+          (const_string "store")))
 
26764
+       (if_then_else
 
26765
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
26766
+        (const_string "load_ux")
 
26767
+        (if_then_else
 
26768
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
26769
+          (const_string "load_u")
 
26770
+          (const_string "load")))
 
26771
+       (const_string "*")
 
26772
+       (const_string "mtjmpr")
 
26773
+       (const_string "mfjmpr")
 
26774
+       (const_string "*")
 
26775
+       (const_string "*")
 
26776
+       (const_string "*")
 
26777
+       (const_string "*")
 
26778
+       (const_string "mftgpr")
 
26779
+       (const_string "mffgpr")
 
26780
+       (const_string "mftgpr")
 
26781
+       (const_string "mffgpr")])
 
26782
+   (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,4,4,8,12,16,4,4,4,4")])
 
26783
 
 
26784
-(define_insn "*movdf_softfloat64"
 
26785
-  [(set (match_operand:DF 0 "nonimmediate_operand" "=Y,r,r,cl,r,r,r,r,*h")
 
26786
-       (match_operand:DF 1 "input_operand" "r,Y,r,r,h,G,H,F,0"))]
 
26787
+(define_insn "*mov<mode>_softfloat64"
 
26788
+  [(set (match_operand:FMOVE64 0 "nonimmediate_operand" "=Y,r,r,cl,r,r,r,r,*h")
 
26789
+       (match_operand:FMOVE64 1 "input_operand" "r,Y,r,r,h,G,H,F,0"))]
 
26790
   "TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
 
26791
-   && (gpc_reg_operand (operands[0], DFmode)
 
26792
-       || gpc_reg_operand (operands[1], DFmode))"
 
26793
+   && (gpc_reg_operand (operands[0], <MODE>mode)
 
26794
+       || gpc_reg_operand (operands[1], <MODE>mode))"
 
26795
   "@
 
26796
    std%U0%X0 %1,%0
 
26797
    ld%U1%X1 %0,%1
 
26798
@@ -8241,38 +8957,57 @@
 
26799
    #
 
26800
    #
 
26801
    nop"
 
26802
-  [(set_attr "type" "store,load,*,mtjmpr,mfjmpr,*,*,*,*")
 
26803
+  [(set_attr_alternative "type"
 
26804
+      [(if_then_else
 
26805
+        (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
26806
+        (const_string "store_ux")
 
26807
+        (if_then_else
 
26808
+          (match_test "update_address_mem (operands[0], VOIDmode)")
 
26809
+          (const_string "store_u")
 
26810
+          (const_string "store")))
 
26811
+       (if_then_else
 
26812
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
26813
+        (const_string "load_ux")
 
26814
+        (if_then_else
 
26815
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
26816
+          (const_string "load_u")
 
26817
+          (const_string "load")))
 
26818
+       (const_string "*")
 
26819
+       (const_string "mtjmpr")
 
26820
+       (const_string "mfjmpr")
 
26821
+       (const_string "*")
 
26822
+       (const_string "*")
 
26823
+       (const_string "*")
 
26824
+       (const_string "*")])
 
26825
    (set_attr "length" "4,4,4,4,4,8,12,16,4")])
 
26826
 
 
26827
-(define_expand "movtf"
 
26828
-  [(set (match_operand:TF 0 "general_operand" "")
 
26829
-       (match_operand:TF 1 "any_operand" ""))]
 
26830
-  "!TARGET_IEEEQUAD && TARGET_LONG_DOUBLE_128"
 
26831
-  "{ rs6000_emit_move (operands[0], operands[1], TFmode); DONE; }")
 
26832
+(define_expand "mov<mode>"
 
26833
+  [(set (match_operand:FMOVE128 0 "general_operand" "")
 
26834
+       (match_operand:FMOVE128 1 "any_operand" ""))]
 
26835
+  ""
 
26836
+  "{ rs6000_emit_move (operands[0], operands[1], <MODE>mode); DONE; }")
 
26837
 
 
26838
 ;; It's important to list Y->r and r->Y before r->r because otherwise
 
26839
 ;; reload, given m->r, will try to pick r->r and reload it, which
 
26840
 ;; doesn't make progress.
 
26841
-(define_insn_and_split "*movtf_internal"
 
26842
-  [(set (match_operand:TF 0 "nonimmediate_operand" "=m,d,d,Y,r,r")
 
26843
-       (match_operand:TF 1 "input_operand" "d,m,d,r,YGHF,r"))]
 
26844
-  "!TARGET_IEEEQUAD
 
26845
-   && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128
 
26846
-   && (gpc_reg_operand (operands[0], TFmode)
 
26847
-       || gpc_reg_operand (operands[1], TFmode))"
 
26848
+(define_insn_and_split "*mov<mode>_internal"
 
26849
+  [(set (match_operand:FMOVE128 0 "nonimmediate_operand" "=m,d,d,Y,r,r")
 
26850
+       (match_operand:FMOVE128 1 "input_operand" "d,m,d,r,YGHF,r"))]
 
26851
+  "TARGET_HARD_FLOAT && TARGET_FPRS
 
26852
+   && (gpc_reg_operand (operands[0], <MODE>mode)
 
26853
+       || gpc_reg_operand (operands[1], <MODE>mode))"
 
26854
   "#"
 
26855
   "&& reload_completed"
 
26856
   [(pc)]
 
26857
 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
 
26858
   [(set_attr "length" "8,8,8,20,20,16")])
 
26859
 
 
26860
-(define_insn_and_split "*movtf_softfloat"
 
26861
-  [(set (match_operand:TF 0 "rs6000_nonimmediate_operand" "=Y,r,r")
 
26862
-       (match_operand:TF 1 "input_operand"         "r,YGHF,r"))]
 
26863
-  "!TARGET_IEEEQUAD
 
26864
-   && (TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_LONG_DOUBLE_128
 
26865
-   && (gpc_reg_operand (operands[0], TFmode)
 
26866
-       || gpc_reg_operand (operands[1], TFmode))"
 
26867
+(define_insn_and_split "*mov<mode>_softfloat"
 
26868
+  [(set (match_operand:FMOVE128 0 "rs6000_nonimmediate_operand" "=Y,r,r")
 
26869
+       (match_operand:FMOVE128 1 "input_operand" "r,YGHF,r"))]
 
26870
+  "(TARGET_SOFT_FLOAT || !TARGET_FPRS)
 
26871
+   && (gpc_reg_operand (operands[0], <MODE>mode)
 
26872
+       || gpc_reg_operand (operands[1], <MODE>mode))"
 
26873
   "#"
 
26874
   "&& reload_completed"
 
26875
   [(pc)]
 
26876
@@ -8557,6 +9292,243 @@
 
26877
   operands[6] = simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word);
 
26878
 }")
 
26879
 
 
26880
+;; Reload helper functions used by rs6000_secondary_reload.  The patterns all
 
26881
+;; must have 3 arguments, and scratch register constraint must be a single
 
26882
+;; constraint.
 
26883
+
 
26884
+;; Reload patterns to support gpr load/store with misaligned mem.
 
26885
+;; and multiple gpr load/store at offset >= 0xfffc
 
26886
+(define_expand "reload_<mode>_store"
 
26887
+  [(parallel [(match_operand 0 "memory_operand" "=m")
 
26888
+              (match_operand 1 "gpc_reg_operand" "r")
 
26889
+              (match_operand:GPR 2 "register_operand" "=&b")])]
 
26890
+  ""
 
26891
+{
 
26892
+  rs6000_secondary_reload_gpr (operands[1], operands[0], operands[2], true);
 
26893
+  DONE;
 
26894
+})
 
26895
+
 
26896
+(define_expand "reload_<mode>_load"
 
26897
+  [(parallel [(match_operand 0 "gpc_reg_operand" "=r")
 
26898
+              (match_operand 1 "memory_operand" "m")
 
26899
+              (match_operand:GPR 2 "register_operand" "=b")])]
 
26900
+  ""
 
26901
+{
 
26902
+  rs6000_secondary_reload_gpr (operands[0], operands[1], operands[2], false);
 
26903
+  DONE;
 
26904
+})
 
26905
+
 
26906
+
 
26907
+;; Power8 merge instructions to allow direct move to/from floating point
 
26908
+;; registers in 32-bit mode.  We use TF mode to get two registers to move the
 
26909
+;; individual 32-bit parts across.  Subreg doesn't work too well on the TF
 
26910
+;; value, since it is allocated in reload and not all of the flow information
 
26911
+;; is setup for it.  We have two patterns to do the two moves between gprs and
 
26912
+;; fprs.  There isn't a dependancy between the two, but we could potentially
 
26913
+;; schedule other instructions between the two instructions.  TFmode is
 
26914
+;; currently limited to traditional FPR registers.  If/when this is changed, we
 
26915
+;; will need to revist %L to make sure it works with VSX registers, or add an
 
26916
+;; %x version of %L.
 
26917
+
 
26918
+(define_insn "p8_fmrgow_<mode>"
 
26919
+  [(set (match_operand:FMOVE64X 0 "register_operand" "=d")
 
26920
+       (unspec:FMOVE64X [(match_operand:TF 1 "register_operand" "d")]
 
26921
+                        UNSPEC_P8V_FMRGOW))]
 
26922
+  "!TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
 
26923
+  "fmrgow %0,%1,%L1"
 
26924
+  [(set_attr "type" "vecperm")])
 
26925
+
 
26926
+(define_insn "p8_mtvsrwz_1"
 
26927
+  [(set (match_operand:TF 0 "register_operand" "=d")
 
26928
+       (unspec:TF [(match_operand:SI 1 "register_operand" "r")]
 
26929
+                  UNSPEC_P8V_MTVSRWZ))]
 
26930
+  "!TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
 
26931
+  "mtvsrwz %x0,%1"
 
26932
+  [(set_attr "type" "mftgpr")])
 
26933
+
 
26934
+(define_insn "p8_mtvsrwz_2"
 
26935
+  [(set (match_operand:TF 0 "register_operand" "+d")
 
26936
+       (unspec:TF [(match_dup 0)
 
26937
+                   (match_operand:SI 1 "register_operand" "r")]
 
26938
+                  UNSPEC_P8V_MTVSRWZ))]
 
26939
+  "!TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
 
26940
+  "mtvsrwz %L0,%1"
 
26941
+  [(set_attr "type" "mftgpr")])
 
26942
+
 
26943
+(define_insn_and_split "reload_fpr_from_gpr<mode>"
 
26944
+  [(set (match_operand:FMOVE64X 0 "register_operand" "=ws")
 
26945
+       (unspec:FMOVE64X [(match_operand:FMOVE64X 1 "register_operand" "r")]
 
26946
+                        UNSPEC_P8V_RELOAD_FROM_GPR))
 
26947
+   (clobber (match_operand:TF 2 "register_operand" "=d"))]
 
26948
+  "!TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
 
26949
+  "#"
 
26950
+  "&& reload_completed"
 
26951
+  [(const_int 0)]
 
26952
+{
 
26953
+  rtx dest = operands[0];
 
26954
+  rtx src = operands[1];
 
26955
+  rtx tmp = operands[2];
 
26956
+  rtx gpr_hi_reg = gen_highpart (SImode, src);
 
26957
+  rtx gpr_lo_reg = gen_lowpart (SImode, src);
 
26958
+
 
26959
+  emit_insn (gen_p8_mtvsrwz_1 (tmp, gpr_hi_reg));
 
26960
+  emit_insn (gen_p8_mtvsrwz_2 (tmp, gpr_lo_reg));
 
26961
+  emit_insn (gen_p8_fmrgow_<mode> (dest, tmp));
 
26962
+  DONE;
 
26963
+}
 
26964
+  [(set_attr "length" "12")
 
26965
+   (set_attr "type" "three")])
 
26966
+
 
26967
+;; Move 128 bit values from GPRs to VSX registers in 64-bit mode
 
26968
+(define_insn "p8_mtvsrd_1"
 
26969
+  [(set (match_operand:TF 0 "register_operand" "=ws")
 
26970
+       (unspec:TF [(match_operand:DI 1 "register_operand" "r")]
 
26971
+                  UNSPEC_P8V_MTVSRD))]
 
26972
+  "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
 
26973
+  "mtvsrd %0,%1"
 
26974
+  [(set_attr "type" "mftgpr")])
 
26975
+
 
26976
+(define_insn "p8_mtvsrd_2"
 
26977
+  [(set (match_operand:TF 0 "register_operand" "+ws")
 
26978
+       (unspec:TF [(match_dup 0)
 
26979
+                   (match_operand:DI 1 "register_operand" "r")]
 
26980
+                  UNSPEC_P8V_MTVSRD))]
 
26981
+  "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
 
26982
+  "mtvsrd %L0,%1"
 
26983
+  [(set_attr "type" "mftgpr")])
 
26984
+
 
26985
+(define_insn "p8_xxpermdi_<mode>"
 
26986
+  [(set (match_operand:FMOVE128_GPR 0 "register_operand" "=wa")
 
26987
+       (unspec:FMOVE128_GPR [(match_operand:TF 1 "register_operand" "ws")]
 
26988
+                            UNSPEC_P8V_XXPERMDI))]
 
26989
+  "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
 
26990
+  "xxpermdi %x0,%1,%L1,0"
 
26991
+  [(set_attr "type" "vecperm")])
 
26992
+
 
26993
+(define_insn_and_split "reload_vsx_from_gpr<mode>"
 
26994
+  [(set (match_operand:FMOVE128_GPR 0 "register_operand" "=wa")
 
26995
+       (unspec:FMOVE128_GPR
 
26996
+        [(match_operand:FMOVE128_GPR 1 "register_operand" "r")]
 
26997
+        UNSPEC_P8V_RELOAD_FROM_GPR))
 
26998
+   (clobber (match_operand:TF 2 "register_operand" "=ws"))]
 
26999
+  "TARGET_POWERPC64 && TARGET_DIRECT_MOVE"
 
27000
+  "#"
 
27001
+  "&& reload_completed"
 
27002
+  [(const_int 0)]
 
27003
+{
 
27004
+  rtx dest = operands[0];
 
27005
+  rtx src = operands[1];
 
27006
+  rtx tmp = operands[2];
 
27007
+  rtx gpr_hi_reg = gen_highpart (DImode, src);
 
27008
+  rtx gpr_lo_reg = gen_lowpart (DImode, src);
 
27009
+
 
27010
+  emit_insn (gen_p8_mtvsrd_1 (tmp, gpr_hi_reg));
 
27011
+  emit_insn (gen_p8_mtvsrd_2 (tmp, gpr_lo_reg));
 
27012
+  emit_insn (gen_p8_xxpermdi_<mode> (dest, tmp));
 
27013
+}
 
27014
+  [(set_attr "length" "12")
 
27015
+   (set_attr "type" "three")])
 
27016
+
 
27017
+;; Move SFmode to a VSX from a GPR register.  Because scalar floating point
 
27018
+;; type is stored internally as double precision in the VSX registers, we have
 
27019
+;; to convert it from the vector format.
 
27020
+
 
27021
+(define_insn_and_split "reload_vsx_from_gprsf"
 
27022
+  [(set (match_operand:SF 0 "register_operand" "=wa")
 
27023
+       (unspec:SF [(match_operand:SF 1 "register_operand" "r")]
 
27024
+                  UNSPEC_P8V_RELOAD_FROM_GPR))
 
27025
+   (clobber (match_operand:DI 2 "register_operand" "=r"))]
 
27026
+  "TARGET_POWERPC64 && TARGET_DIRECT_MOVE && WORDS_BIG_ENDIAN"
 
27027
+  "#"
 
27028
+  "&& reload_completed"
 
27029
+  [(const_int 0)]
 
27030
+{
 
27031
+  rtx op0 = operands[0];
 
27032
+  rtx op1 = operands[1];
 
27033
+  rtx op2 = operands[2];
 
27034
+  rtx op0_di = simplify_gen_subreg (DImode, op0, SFmode, 0);
 
27035
+  rtx op1_di = simplify_gen_subreg (DImode, op1, SFmode, 0);
 
27036
+
 
27037
+  /* Move SF value to upper 32-bits for xscvspdpn.  */
 
27038
+  emit_insn (gen_ashldi3 (op2, op1_di, GEN_INT (32)));
 
27039
+  emit_move_insn (op0_di, op2);
 
27040
+  emit_insn (gen_vsx_xscvspdpn_directmove (op0, op0));
 
27041
+  DONE;
 
27042
+}
 
27043
+  [(set_attr "length" "8")
 
27044
+   (set_attr "type" "two")])
 
27045
+
 
27046
+;; Move 128 bit values from VSX registers to GPRs in 64-bit mode by doing a
 
27047
+;; normal 64-bit move, followed by an xxpermdi to get the bottom 64-bit value,
 
27048
+;; and then doing a move of that.
 
27049
+(define_insn "p8_mfvsrd_3_<mode>"
 
27050
+  [(set (match_operand:DF 0 "register_operand" "=r")
 
27051
+       (unspec:DF [(match_operand:FMOVE128_GPR 1 "register_operand" "wa")]
 
27052
+                  UNSPEC_P8V_RELOAD_FROM_VSX))]
 
27053
+  "TARGET_POWERPC64 && TARGET_DIRECT_MOVE && WORDS_BIG_ENDIAN"
 
27054
+  "mfvsrd %0,%x1"
 
27055
+  [(set_attr "type" "mftgpr")])
 
27056
+
 
27057
+(define_insn_and_split "reload_gpr_from_vsx<mode>"
 
27058
+  [(set (match_operand:FMOVE128_GPR 0 "register_operand" "=r")
 
27059
+       (unspec:FMOVE128_GPR
 
27060
+        [(match_operand:FMOVE128_GPR 1 "register_operand" "wa")]
 
27061
+        UNSPEC_P8V_RELOAD_FROM_VSX))
 
27062
+   (clobber (match_operand:FMOVE128_GPR 2 "register_operand" "=wa"))]
 
27063
+  "TARGET_POWERPC64 && TARGET_DIRECT_MOVE && WORDS_BIG_ENDIAN"
 
27064
+  "#"
 
27065
+  "&& reload_completed"
 
27066
+  [(const_int 0)]
 
27067
+{
 
27068
+  rtx dest = operands[0];
 
27069
+  rtx src = operands[1];
 
27070
+  rtx tmp = operands[2];
 
27071
+  rtx gpr_hi_reg = gen_highpart (DFmode, dest);
 
27072
+  rtx gpr_lo_reg = gen_lowpart (DFmode, dest);
 
27073
+
 
27074
+  emit_insn (gen_p8_mfvsrd_3_<mode> (gpr_hi_reg, src));
 
27075
+  emit_insn (gen_vsx_xxpermdi_<mode> (tmp, src, src, GEN_INT (3)));
 
27076
+  emit_insn (gen_p8_mfvsrd_3_<mode> (gpr_lo_reg, tmp));
 
27077
+}
 
27078
+  [(set_attr "length" "12")
 
27079
+   (set_attr "type" "three")])
 
27080
+
 
27081
+;; Move SFmode to a GPR from a VSX register.  Because scalar floating point
 
27082
+;; type is stored internally as double precision, we have to convert it to the
 
27083
+;; vector format.
 
27084
+
 
27085
+(define_insn_and_split "reload_gpr_from_vsxsf"
 
27086
+  [(set (match_operand:SF 0 "register_operand" "=r")
 
27087
+       (unspec:SF [(match_operand:SF 1 "register_operand" "wa")]
 
27088
+                  UNSPEC_P8V_RELOAD_FROM_VSX))
 
27089
+   (clobber (match_operand:V4SF 2 "register_operand" "=wa"))]
 
27090
+  "TARGET_POWERPC64 && TARGET_DIRECT_MOVE && WORDS_BIG_ENDIAN"
 
27091
+  "#"
 
27092
+  "&& reload_completed"
 
27093
+  [(const_int 0)]
 
27094
+{
 
27095
+  rtx op0 = operands[0];
 
27096
+  rtx op1 = operands[1];
 
27097
+  rtx op2 = operands[2];
 
27098
+  rtx diop0 = simplify_gen_subreg (DImode, op0, SFmode, 0);
 
27099
+
 
27100
+  emit_insn (gen_vsx_xscvdpspn_scalar (op2, op1));
 
27101
+  emit_insn (gen_p8_mfvsrd_4_disf (diop0, op2));
 
27102
+  emit_insn (gen_lshrdi3 (diop0, diop0, GEN_INT (32)));
 
27103
+  DONE;
 
27104
+}
 
27105
+  [(set_attr "length" "12")
 
27106
+   (set_attr "type" "three")])
 
27107
+
 
27108
+(define_insn "p8_mfvsrd_4_disf"
 
27109
+  [(set (match_operand:DI 0 "register_operand" "=r")
 
27110
+       (unspec:DI [(match_operand:V4SF 1 "register_operand" "wa")]
 
27111
+                  UNSPEC_P8V_RELOAD_FROM_VSX))]
 
27112
+  "TARGET_POWERPC64 && TARGET_DIRECT_MOVE && WORDS_BIG_ENDIAN"
 
27113
+  "mfvsrd %0,%x1"
 
27114
+  [(set_attr "type" "mftgpr")])
 
27115
+
 
27116
+
 
27117
 ;; Next come the multi-word integer load and store and the load and store
 
27118
 ;; multiple insns.
 
27119
 
 
27120
@@ -8565,8 +9537,8 @@
 
27121
 ;; Use of fprs is disparaged slightly otherwise reload prefers to reload
 
27122
 ;; a gpr into a fpr instead of reloading an invalid 'Y' address
 
27123
 (define_insn "*movdi_internal32"
 
27124
-  [(set (match_operand:DI 0 "rs6000_nonimmediate_operand" "=Y,r,r,?m,?*d,?*d,r,?wa")
 
27125
-       (match_operand:DI 1 "input_operand" "r,Y,r,d,m,d,IJKnGHF,O"))]
 
27126
+  [(set (match_operand:DI 0 "rs6000_nonimmediate_operand" "=Y,r,r,?m,?*d,?*d,r")
 
27127
+       (match_operand:DI 1 "input_operand" "r,Y,r,d,m,d,IJKnGHF"))]
 
27128
   "! TARGET_POWERPC64
 
27129
    && (gpc_reg_operand (operands[0], DImode)
 
27130
        || gpc_reg_operand (operands[1], DImode))"
 
27131
@@ -8577,15 +9549,34 @@
 
27132
    stfd%U0%X0 %1,%0
 
27133
    lfd%U1%X1 %0,%1
 
27134
    fmr %0,%1
 
27135
-   #
 
27136
-   xxlxor %x0,%x0,%x0"
 
27137
-  [(set_attr "type" "store,load,*,fpstore,fpload,fp,*,vecsimple")])
 
27138
+   #"
 
27139
+  [(set_attr_alternative "type"
 
27140
+      [(const_string "store")
 
27141
+       (const_string "load")
 
27142
+       (const_string "*")
 
27143
+       (if_then_else
 
27144
+        (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
27145
+        (const_string "fpstore_ux")
 
27146
+        (if_then_else
 
27147
+          (match_test "update_address_mem (operands[0], VOIDmode)")
 
27148
+          (const_string "fpstore_u")
 
27149
+          (const_string "fpstore")))
 
27150
+       (if_then_else
 
27151
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
27152
+        (const_string "fpload_ux")
 
27153
+        (if_then_else
 
27154
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
27155
+          (const_string "fpload_u")
 
27156
+          (const_string "fpload")))
 
27157
+       (const_string "fp")
 
27158
+       (const_string "*")])])
 
27159
 
 
27160
 (define_split
 
27161
   [(set (match_operand:DI 0 "gpc_reg_operand" "")
 
27162
        (match_operand:DI 1 "const_int_operand" ""))]
 
27163
   "! TARGET_POWERPC64 && reload_completed
 
27164
-   && gpr_or_gpr_p (operands[0], operands[1])"
 
27165
+   && gpr_or_gpr_p (operands[0], operands[1])
 
27166
+   && !direct_move_p (operands[0], operands[1])"
 
27167
   [(set (match_dup 2) (match_dup 4))
 
27168
    (set (match_dup 3) (match_dup 1))]
 
27169
   "
 
27170
@@ -8607,14 +9598,15 @@
 
27171
   [(set (match_operand:DIFD 0 "rs6000_nonimmediate_operand" "")
 
27172
         (match_operand:DIFD 1 "input_operand" ""))]
 
27173
   "reload_completed && !TARGET_POWERPC64
 
27174
-   && gpr_or_gpr_p (operands[0], operands[1])"
 
27175
+   && gpr_or_gpr_p (operands[0], operands[1])
 
27176
+   && !direct_move_p (operands[0], operands[1])"
 
27177
   [(pc)]
 
27178
 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
 
27179
 
 
27180
-(define_insn "*movdi_mfpgpr"
 
27181
-  [(set (match_operand:DI 0 "nonimmediate_operand" "=Y,r,r,r,r,r,?m,?*d,?*d,r,*h,*h,r,?*d")
 
27182
-       (match_operand:DI 1 "input_operand" "r,Y,r,I,L,nF,d,m,d,*h,r,0,*d,r"))]
 
27183
-  "TARGET_POWERPC64 && TARGET_MFPGPR && TARGET_HARD_FLOAT && TARGET_FPRS
 
27184
+(define_insn "*movdi_internal64"
 
27185
+  [(set (match_operand:DI 0 "nonimmediate_operand" "=Y,r,r,r,r,r,?m,?*d,?*d,r,*h,*h,r,?*wg,r,?*wm")
 
27186
+       (match_operand:DI 1 "input_operand" "r,Y,r,I,L,nF,d,m,d,*h,r,0,*wg,r,*wm,r"))]
 
27187
+  "TARGET_POWERPC64
 
27188
    && (gpc_reg_operand (operands[0], DImode)
 
27189
        || gpc_reg_operand (operands[1], DImode))"
 
27190
   "@
 
27191
@@ -8631,33 +9623,52 @@
 
27192
    mt%0 %1
 
27193
    nop
 
27194
    mftgpr %0,%1
 
27195
-   mffgpr %0,%1"
 
27196
-  [(set_attr "type" "store,load,*,*,*,*,fpstore,fpload,fp,mfjmpr,mtjmpr,*,mftgpr,mffgpr")
 
27197
-   (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4,4")])
 
27198
+   mffgpr %0,%1
 
27199
+   mfvsrd %0,%x1
 
27200
+   mtvsrd %x0,%1"
 
27201
+  [(set_attr_alternative "type"
 
27202
+      [(if_then_else
 
27203
+        (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
27204
+        (const_string "store_ux")
 
27205
+        (if_then_else
 
27206
+          (match_test "update_address_mem (operands[0], VOIDmode)")
 
27207
+          (const_string "store_u")
 
27208
+          (const_string "store")))
 
27209
+       (if_then_else
 
27210
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
27211
+        (const_string "load_ux")
 
27212
+        (if_then_else
 
27213
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
27214
+          (const_string "load_u")
 
27215
+          (const_string "load")))
 
27216
+       (const_string "*")
 
27217
+       (const_string "*")
 
27218
+       (const_string "*")
 
27219
+       (const_string "*")
 
27220
+       (if_then_else
 
27221
+        (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
27222
+        (const_string "fpstore_ux")
 
27223
+        (if_then_else
 
27224
+          (match_test "update_address_mem (operands[0], VOIDmode)")
 
27225
+          (const_string "fpstore_u")
 
27226
+          (const_string "fpstore")))
 
27227
+       (if_then_else
 
27228
+        (match_test "update_indexed_address_mem (operands[1], VOIDmode)")
 
27229
+        (const_string "fpload_ux")
 
27230
+        (if_then_else
 
27231
+          (match_test "update_address_mem (operands[1], VOIDmode)")
 
27232
+          (const_string "fpload_u")
 
27233
+          (const_string "fpload")))
 
27234
+       (const_string "fp")
 
27235
+       (const_string "mfjmpr")
 
27236
+       (const_string "mtjmpr")
 
27237
+       (const_string "*")
 
27238
+       (const_string "mftgpr")
 
27239
+       (const_string "mffgpr")
 
27240
+       (const_string "mftgpr")
 
27241
+       (const_string "mffgpr")])
 
27242
+   (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4,4,4,4")])
 
27243
 
 
27244
-(define_insn "*movdi_internal64"
 
27245
-  [(set (match_operand:DI 0 "nonimmediate_operand" "=Y,r,r,r,r,r,?m,?*d,?*d,r,*h,*h,?wa")
 
27246
-       (match_operand:DI 1 "input_operand" "r,Y,r,I,L,nF,d,m,d,*h,r,0,O"))]
 
27247
-  "TARGET_POWERPC64 && (!TARGET_MFPGPR || !TARGET_HARD_FLOAT || !TARGET_FPRS)
 
27248
-   && (gpc_reg_operand (operands[0], DImode)
 
27249
-       || gpc_reg_operand (operands[1], DImode))"
 
27250
-  "@
 
27251
-   std%U0%X0 %1,%0
 
27252
-   ld%U1%X1 %0,%1
 
27253
-   mr %0,%1
 
27254
-   li %0,%1
 
27255
-   lis %0,%v1
 
27256
-   #
 
27257
-   stfd%U0%X0 %1,%0
 
27258
-   lfd%U1%X1 %0,%1
 
27259
-   fmr %0,%1
 
27260
-   mf%1 %0
 
27261
-   mt%0 %1
 
27262
-   nop
 
27263
-   xxlxor %x0,%x0,%x0"
 
27264
-  [(set_attr "type" "store,load,*,*,*,*,fpstore,fpload,fp,mfjmpr,mtjmpr,*,vecsimple")
 
27265
-   (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4")])
 
27266
-
 
27267
 ;; immediate value valid for a single instruction hiding in a const_double
 
27268
 (define_insn ""
 
27269
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
 
27270
@@ -8719,14 +9730,16 @@
 
27271
     FAIL;
 
27272
 }")
 
27273
 
 
27274
-;; TImode is similar, except that we usually want to compute the address into
 
27275
-;; a register and use lsi/stsi (the exception is during reload).
 
27276
+;; TImode/PTImode is similar, except that we usually want to compute the
 
27277
+;; address into a register and use lsi/stsi (the exception is during reload).
 
27278
 
 
27279
-(define_insn "*movti_string"
 
27280
-  [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,Y,????r,????r,????r,r")
 
27281
-       (match_operand:TI 1 "input_operand" "r,r,Q,Y,r,n"))]
 
27282
+(define_insn "*mov<mode>_string"
 
27283
+  [(set (match_operand:TI2 0 "reg_or_mem_operand" "=Q,Y,????r,????r,????r,r")
 
27284
+       (match_operand:TI2 1 "input_operand" "r,r,Q,Y,r,n"))]
 
27285
   "! TARGET_POWERPC64
 
27286
-   && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
 
27287
+   && (<MODE>mode != TImode || VECTOR_MEM_NONE_P (TImode))
 
27288
+   && (gpc_reg_operand (operands[0], <MODE>mode)
 
27289
+       || gpc_reg_operand (operands[1], <MODE>mode))"
 
27290
   "*
 
27291
 {
 
27292
   switch (which_alternative)
 
27293
@@ -8756,27 +9769,32 @@
 
27294
                                          (const_string "always")
 
27295
                                          (const_string "conditional")))])
 
27296
 
 
27297
-(define_insn "*movti_ppc64"
 
27298
-  [(set (match_operand:TI 0 "nonimmediate_operand" "=Y,r,r")
 
27299
-       (match_operand:TI 1 "input_operand" "r,Y,r"))]
 
27300
-  "(TARGET_POWERPC64 && (gpc_reg_operand (operands[0], TImode)
 
27301
-    || gpc_reg_operand (operands[1], TImode)))
 
27302
-   && VECTOR_MEM_NONE_P (TImode)"
 
27303
-  "#"
 
27304
-  [(set_attr "type" "store,load,*")])
 
27305
+(define_insn "*mov<mode>_ppc64"
 
27306
+  [(set (match_operand:TI2 0 "nonimmediate_operand" "=wQ,Y,r,r,r,r")
 
27307
+       (match_operand:TI2 1 "input_operand" "r,r,wQ,Y,r,n"))]
 
27308
+  "(TARGET_POWERPC64 && VECTOR_MEM_NONE_P (<MODE>mode)
 
27309
+   && (gpc_reg_operand (operands[0], <MODE>mode)
 
27310
+       || gpc_reg_operand (operands[1], <MODE>mode)))"
 
27311
+{
 
27312
+  return rs6000_output_move_128bit (operands);
 
27313
+}
 
27314
+  [(set_attr "type" "store,store,load,load,*,*")
 
27315
+   (set_attr "length" "8")])
 
27316
 
 
27317
 (define_split
 
27318
-  [(set (match_operand:TI 0 "gpc_reg_operand" "")
 
27319
-       (match_operand:TI 1 "const_double_operand" ""))]
 
27320
-  "TARGET_POWERPC64 && VECTOR_MEM_NONE_P (TImode)"
 
27321
+  [(set (match_operand:TI2 0 "int_reg_operand" "")
 
27322
+       (match_operand:TI2 1 "const_double_operand" ""))]
 
27323
+  "TARGET_POWERPC64
 
27324
+   && (VECTOR_MEM_NONE_P (<MODE>mode)
 
27325
+       || (reload_completed && INT_REGNO_P (REGNO (operands[0]))))"
 
27326
   [(set (match_dup 2) (match_dup 4))
 
27327
    (set (match_dup 3) (match_dup 5))]
 
27328
   "
 
27329
 {
 
27330
   operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
 
27331
-                                      TImode);
 
27332
+                                      <MODE>mode);
 
27333
   operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
 
27334
-                                      TImode);
 
27335
+                                      <MODE>mode);
 
27336
   if (GET_CODE (operands[1]) == CONST_DOUBLE)
 
27337
     {
 
27338
       operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
 
27339
@@ -8792,10 +9810,12 @@
 
27340
 }")
 
27341
 
 
27342
 (define_split
 
27343
-  [(set (match_operand:TI 0 "nonimmediate_operand" "")
 
27344
-        (match_operand:TI 1 "input_operand" ""))]
 
27345
-  "reload_completed && VECTOR_MEM_NONE_P (TImode)
 
27346
-   && gpr_or_gpr_p (operands[0], operands[1])"
 
27347
+  [(set (match_operand:TI2 0 "nonimmediate_operand" "")
 
27348
+        (match_operand:TI2 1 "input_operand" ""))]
 
27349
+  "reload_completed
 
27350
+   && gpr_or_gpr_p (operands[0], operands[1])
 
27351
+   && !direct_move_p (operands[0], operands[1])
 
27352
+   && !quad_load_store_p (operands[0], operands[1])"
 
27353
   [(pc)]
 
27354
 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
 
27355
 
 
27356
@@ -9651,7 +10671,7 @@
 
27357
                    (match_operand:TLSmode 2 "rs6000_tls_symbol_ref" "")]
 
27358
                   UNSPEC_TLSGD)
 
27359
    (clobber (reg:SI LR_REGNO))]
 
27360
-  "HAVE_AS_TLS && DEFAULT_ABI == ABI_AIX"
 
27361
+  "HAVE_AS_TLS && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)"
 
27362
 {
 
27363
   if (TARGET_CMODEL != CMODEL_SMALL)
 
27364
     return "addis %0,%1,%2@got@tlsgd@ha\;addi %0,%0,%2@got@tlsgd@l\;"
 
27365
@@ -9759,7 +10779,8 @@
 
27366
    (unspec:TLSmode [(match_operand:TLSmode 3 "rs6000_tls_symbol_ref" "")]
 
27367
                   UNSPEC_TLSGD)
 
27368
    (clobber (reg:SI LR_REGNO))]
 
27369
-  "HAVE_AS_TLS && DEFAULT_ABI == ABI_AIX && TARGET_TLS_MARKERS"
 
27370
+  "HAVE_AS_TLS && TARGET_TLS_MARKERS
 
27371
+   && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)"
 
27372
   "bl %z1(%3@tlsgd)\;nop"
 
27373
   [(set_attr "type" "branch")
 
27374
    (set_attr "length" "8")])
 
27375
@@ -9791,7 +10812,7 @@
 
27376
    (unspec:TLSmode [(match_operand:TLSmode 1 "gpc_reg_operand" "b")]
 
27377
                   UNSPEC_TLSLD)
 
27378
    (clobber (reg:SI LR_REGNO))]
 
27379
-  "HAVE_AS_TLS && DEFAULT_ABI == ABI_AIX"
 
27380
+  "HAVE_AS_TLS && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)"
 
27381
 {
 
27382
   if (TARGET_CMODEL != CMODEL_SMALL)
 
27383
     return "addis %0,%1,%&@got@tlsld@ha\;addi %0,%0,%&@got@tlsld@l\;"
 
27384
@@ -9892,7 +10913,8 @@
 
27385
              (match_operand 2 "" "g")))
 
27386
    (unspec:TLSmode [(const_int 0)] UNSPEC_TLSLD)
 
27387
    (clobber (reg:SI LR_REGNO))]
 
27388
-  "HAVE_AS_TLS && DEFAULT_ABI == ABI_AIX && TARGET_TLS_MARKERS"
 
27389
+  "HAVE_AS_TLS && TARGET_TLS_MARKERS
 
27390
+   && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)"
 
27391
   "bl %z1(%&@tlsld)\;nop"
 
27392
   [(set_attr "type" "branch")
 
27393
    (set_attr "length" "8")])
 
27394
@@ -10261,7 +11283,7 @@
 
27395
   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
 
27396
                   (unspec:SI [(const_int 0)] UNSPEC_TOC))
 
27397
              (use (reg:SI 2))])]
 
27398
-  "DEFAULT_ABI == ABI_AIX && TARGET_32BIT"
 
27399
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) && TARGET_32BIT"
 
27400
   "*
 
27401
 {
 
27402
   char buf[30];
 
27403
@@ -10276,7 +11298,7 @@
 
27404
   [(parallel [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
 
27405
                   (unspec:DI [(const_int 0)] UNSPEC_TOC))
 
27406
              (use (reg:DI 2))])]
 
27407
-  "DEFAULT_ABI == ABI_AIX && TARGET_64BIT"
 
27408
+  "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) && TARGET_64BIT"
 
27409
   "*
 
27410
 {
 
27411
   char buf[30];
 
27412
@@ -10306,7 +11328,7 @@
 
27413
   [(parallel [(set (reg:SI LR_REGNO)
 
27414
                   (match_operand:SI 0 "immediate_operand" "s"))
 
27415
              (use (unspec [(match_dup 0)] UNSPEC_TOC))])]
 
27416
-  "TARGET_ELF && DEFAULT_ABI != ABI_AIX
 
27417
+  "TARGET_ELF && DEFAULT_ABI == ABI_V4
 
27418
    && (flag_pic == 2 || (flag_pic && TARGET_SECURE_PLT))"
 
27419
   "")
 
27420
 
 
27421
@@ -10314,7 +11336,7 @@
 
27422
   [(set (reg:SI LR_REGNO)
 
27423
        (match_operand:SI 0 "immediate_operand" "s"))
 
27424
    (use (unspec [(match_dup 0)] UNSPEC_TOC))]
 
27425
-  "!TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI != ABI_AIX
 
27426
+  "!TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI == ABI_V4
 
27427
    && (flag_pic == 2 || (flag_pic && TARGET_SECURE_PLT))"
 
27428
   "bcl 20,31,%0\\n%0:"
 
27429
   [(set_attr "type" "branch")
 
27430
@@ -10324,7 +11346,7 @@
 
27431
   [(set (reg:SI LR_REGNO)
 
27432
        (match_operand:SI 0 "immediate_operand" "s"))
 
27433
    (use (unspec [(match_dup 0)] UNSPEC_TOC))]
 
27434
-  "TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI != ABI_AIX
 
27435
+  "TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI == ABI_V4
 
27436
    && (flag_pic == 2 || (flag_pic && TARGET_SECURE_PLT))"
 
27437
   "*
 
27438
 {
 
27439
@@ -10344,7 +11366,7 @@
 
27440
                               (label_ref (match_operand 1 "" ""))]
 
27441
                           UNSPEC_TOCPTR))
 
27442
              (match_dup 1)])]
 
27443
-  "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
 
27444
+  "TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 2"
 
27445
   "")
 
27446
 
 
27447
 (define_insn "load_toc_v4_PIC_1b_normal"
 
27448
@@ -10353,7 +11375,7 @@
 
27449
                    (label_ref (match_operand 1 "" ""))]
 
27450
                UNSPEC_TOCPTR))
 
27451
    (match_dup 1)]
 
27452
-  "!TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
 
27453
+  "!TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 2"
 
27454
   "bcl 20,31,$+8\;.long %0-$"
 
27455
   [(set_attr "type" "branch")
 
27456
    (set_attr "length" "8")])
 
27457
@@ -10364,7 +11386,7 @@
 
27458
                    (label_ref (match_operand 1 "" ""))]
 
27459
                UNSPEC_TOCPTR))
 
27460
    (match_dup 1)]
 
27461
-  "TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
 
27462
+  "TARGET_LINK_STACK && TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 2"
 
27463
   "*
 
27464
 {
 
27465
   char name[32];
 
27466
@@ -10382,7 +11404,7 @@
 
27467
        (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
 
27468
                   (minus:SI (match_operand:SI 2 "immediate_operand" "s")
 
27469
                             (match_operand:SI 3 "immediate_operand" "s")))))]
 
27470
-  "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
 
27471
+  "TARGET_ELF && DEFAULT_ABI == ABI_V4 && flag_pic == 2"
 
27472
   "lwz %0,%2-%3(%1)"
 
27473
   [(set_attr "type" "load")])
 
27474
 
 
27475
@@ -10392,7 +11414,7 @@
 
27476
                 (high:SI
 
27477
                   (minus:SI (match_operand:SI 2 "symbol_ref_operand" "s")
 
27478
                             (match_operand:SI 3 "symbol_ref_operand" "s")))))]
 
27479
-  "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI != ABI_AIX && flag_pic"
 
27480
+  "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI == ABI_V4 && flag_pic"
 
27481
   "addis %0,%1,%2-%3@ha")
 
27482
 
 
27483
 (define_insn "load_toc_v4_PIC_3c"
 
27484
@@ -10400,7 +11422,7 @@
 
27485
        (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
 
27486
                   (minus:SI (match_operand:SI 2 "symbol_ref_operand" "s")
 
27487
                             (match_operand:SI 3 "symbol_ref_operand" "s"))))]
 
27488
-  "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI != ABI_AIX && flag_pic"
 
27489
+  "TARGET_ELF && TARGET_SECURE_PLT && DEFAULT_ABI == ABI_V4 && flag_pic"
 
27490
   "addi %0,%1,%2-%3@l")
 
27491
 
 
27492
 ;; If the TOC is shared over a translation unit, as happens with all
 
27493
@@ -10542,8 +11564,13 @@
 
27494
 
 
27495
   operands[0] = XEXP (operands[0], 0);
 
27496
 
 
27497
+  if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
27498
+    {
 
27499
+      rs6000_call_aix (NULL_RTX, operands[0], operands[1], operands[2]);
 
27500
+      DONE;
 
27501
+    }
 
27502
+
 
27503
   if (GET_CODE (operands[0]) != SYMBOL_REF
 
27504
-      || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[0]))
 
27505
       || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[2]) & CALL_LONG) != 0))
 
27506
     {
 
27507
       if (INTVAL (operands[2]) & CALL_LONG)
 
27508
@@ -10556,12 +11583,6 @@
 
27509
          operands[0] = force_reg (Pmode, operands[0]);
 
27510
          break;
 
27511
 
 
27512
-       case ABI_AIX:
 
27513
-         /* AIX function pointers are really pointers to a three word
 
27514
-            area.  */
 
27515
-         rs6000_call_indirect_aix (NULL_RTX, operands[0], operands[1]);
 
27516
-         DONE;
 
27517
-
 
27518
        default:
 
27519
          gcc_unreachable ();
 
27520
        }
 
27521
@@ -10587,8 +11608,13 @@
 
27522
 
 
27523
   operands[1] = XEXP (operands[1], 0);
 
27524
 
 
27525
+  if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
27526
+    {
 
27527
+      rs6000_call_aix (operands[0], operands[1], operands[2], operands[3]);
 
27528
+      DONE;
 
27529
+    }
 
27530
+
 
27531
   if (GET_CODE (operands[1]) != SYMBOL_REF
 
27532
-      || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[1]))
 
27533
       || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[3]) & CALL_LONG) != 0))
 
27534
     {
 
27535
       if (INTVAL (operands[3]) & CALL_LONG)
 
27536
@@ -10601,12 +11627,6 @@
 
27537
          operands[1] = force_reg (Pmode, operands[1]);
 
27538
          break;
 
27539
 
 
27540
-       case ABI_AIX:
 
27541
-         /* AIX function pointers are really pointers to a three word
 
27542
-            area.  */
 
27543
-         rs6000_call_indirect_aix (operands[0], operands[1], operands[2]);
 
27544
-         DONE;
 
27545
-
 
27546
        default:
 
27547
          gcc_unreachable ();
 
27548
        }
 
27549
@@ -10698,136 +11718,7 @@
 
27550
   [(set_attr "type" "branch")
 
27551
    (set_attr "length" "4,8")])
 
27552
 
 
27553
-;; Call to indirect functions with the AIX abi using a 3 word descriptor.
 
27554
-;; Operand0 is the addresss of the function to call
 
27555
-;; Operand1 is the flag for System V.4 for unprototyped or FP registers
 
27556
-;; Operand2 is the location in the function descriptor to load r2 from
 
27557
-;; Operand3 is the stack location to hold the current TOC pointer
 
27558
 
 
27559
-(define_insn "call_indirect_aix<ptrsize>"
 
27560
-  [(call (mem:SI (match_operand:P 0 "register_operand" "c,*l"))
 
27561
-        (match_operand 1 "" "g,g"))
 
27562
-   (use (match_operand:P 2 "memory_operand" "<ptrm>,<ptrm>"))
 
27563
-   (set (reg:P TOC_REGNUM) (match_operand:P 3 "memory_operand" "<ptrm>,<ptrm>"))
 
27564
-   (use (reg:P STATIC_CHAIN_REGNUM))
 
27565
-   (clobber (reg:P LR_REGNO))]
 
27566
-  "DEFAULT_ABI == ABI_AIX && TARGET_POINTERS_TO_NESTED_FUNCTIONS"
 
27567
-  "<ptrload> 2,%2\;b%T0l\;<ptrload> 2,%3"
 
27568
-  [(set_attr "type" "jmpreg")
 
27569
-   (set_attr "length" "12")])
 
27570
-
 
27571
-;; Like call_indirect_aix<ptrsize>, but no use of the static chain
 
27572
-;; Operand0 is the addresss of the function to call
 
27573
-;; Operand1 is the flag for System V.4 for unprototyped or FP registers
 
27574
-;; Operand2 is the location in the function descriptor to load r2 from
 
27575
-;; Operand3 is the stack location to hold the current TOC pointer
 
27576
-
 
27577
-(define_insn "call_indirect_aix<ptrsize>_nor11"
 
27578
-  [(call (mem:SI (match_operand:P 0 "register_operand" "c,*l"))
 
27579
-        (match_operand 1 "" "g,g"))
 
27580
-   (use (match_operand:P 2 "memory_operand" "<ptrm>,<ptrm>"))
 
27581
-   (set (reg:P TOC_REGNUM) (match_operand:P 3 "memory_operand" "<ptrm>,<ptrm>"))
 
27582
-   (clobber (reg:P LR_REGNO))]
 
27583
-  "DEFAULT_ABI == ABI_AIX && !TARGET_POINTERS_TO_NESTED_FUNCTIONS"
 
27584
-  "<ptrload> 2,%2\;b%T0l\;<ptrload> 2,%3"
 
27585
-  [(set_attr "type" "jmpreg")
 
27586
-   (set_attr "length" "12")])
 
27587
-
 
27588
-;; Operand0 is the return result of the function
 
27589
-;; Operand1 is the addresss of the function to call
 
27590
-;; Operand2 is the flag for System V.4 for unprototyped or FP registers
 
27591
-;; Operand3 is the location in the function descriptor to load r2 from
 
27592
-;; Operand4 is the stack location to hold the current TOC pointer
 
27593
-
 
27594
-(define_insn "call_value_indirect_aix<ptrsize>"
 
27595
-  [(set (match_operand 0 "" "")
 
27596
-       (call (mem:SI (match_operand:P 1 "register_operand" "c,*l"))
 
27597
-             (match_operand 2 "" "g,g")))
 
27598
-   (use (match_operand:P 3 "memory_operand" "<ptrm>,<ptrm>"))
 
27599
-   (set (reg:P TOC_REGNUM) (match_operand:P 4 "memory_operand" "<ptrm>,<ptrm>"))
 
27600
-   (use (reg:P STATIC_CHAIN_REGNUM))
 
27601
-   (clobber (reg:P LR_REGNO))]
 
27602
-  "DEFAULT_ABI == ABI_AIX && TARGET_POINTERS_TO_NESTED_FUNCTIONS"
 
27603
-  "<ptrload> 2,%3\;b%T1l\;<ptrload> 2,%4"
 
27604
-  [(set_attr "type" "jmpreg")
 
27605
-   (set_attr "length" "12")])
 
27606
-
 
27607
-;; Like call_value_indirect_aix<ptrsize>, but no use of the static chain
 
27608
-;; Operand0 is the return result of the function
 
27609
-;; Operand1 is the addresss of the function to call
 
27610
-;; Operand2 is the flag for System V.4 for unprototyped or FP registers
 
27611
-;; Operand3 is the location in the function descriptor to load r2 from
 
27612
-;; Operand4 is the stack location to hold the current TOC pointer
 
27613
-
 
27614
-(define_insn "call_value_indirect_aix<ptrsize>_nor11"
 
27615
-  [(set (match_operand 0 "" "")
 
27616
-       (call (mem:SI (match_operand:P 1 "register_operand" "c,*l"))
 
27617
-             (match_operand 2 "" "g,g")))
 
27618
-   (use (match_operand:P 3 "memory_operand" "<ptrm>,<ptrm>"))
 
27619
-   (set (reg:P TOC_REGNUM) (match_operand:P 4 "memory_operand" "<ptrm>,<ptrm>"))
 
27620
-   (clobber (reg:P LR_REGNO))]
 
27621
-  "DEFAULT_ABI == ABI_AIX && !TARGET_POINTERS_TO_NESTED_FUNCTIONS"
 
27622
-  "<ptrload> 2,%3\;b%T1l\;<ptrload> 2,%4"
 
27623
-  [(set_attr "type" "jmpreg")
 
27624
-   (set_attr "length" "12")])
 
27625
-
 
27626
-;; Call to function which may be in another module.  Restore the TOC
 
27627
-;; pointer (r2) after the call unless this is System V.
 
27628
-;; Operand2 is nonzero if we are using the V.4 calling sequence and
 
27629
-;; either the function was not prototyped, or it was prototyped as a
 
27630
-;; variable argument function.  It is > 0 if FP registers were passed
 
27631
-;; and < 0 if they were not.
 
27632
-
 
27633
-(define_insn "*call_nonlocal_aix32"
 
27634
-  [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
 
27635
-        (match_operand 1 "" "g"))
 
27636
-   (use (match_operand:SI 2 "immediate_operand" "O"))
 
27637
-   (clobber (reg:SI LR_REGNO))]
 
27638
-  "TARGET_32BIT
 
27639
-   && DEFAULT_ABI == ABI_AIX
 
27640
-   && (INTVAL (operands[2]) & CALL_LONG) == 0"
 
27641
-  "bl %z0\;nop"
 
27642
-  [(set_attr "type" "branch")
 
27643
-   (set_attr "length" "8")])
 
27644
-   
 
27645
-(define_insn "*call_nonlocal_aix64"
 
27646
-  [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
 
27647
-        (match_operand 1 "" "g"))
 
27648
-   (use (match_operand:SI 2 "immediate_operand" "O"))
 
27649
-   (clobber (reg:SI LR_REGNO))]
 
27650
-  "TARGET_64BIT
 
27651
-   && DEFAULT_ABI == ABI_AIX
 
27652
-   && (INTVAL (operands[2]) & CALL_LONG) == 0"
 
27653
-  "bl %z0\;nop"
 
27654
-  [(set_attr "type" "branch")
 
27655
-   (set_attr "length" "8")])
 
27656
-
 
27657
-(define_insn "*call_value_nonlocal_aix32"
 
27658
-  [(set (match_operand 0 "" "")
 
27659
-       (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
 
27660
-             (match_operand 2 "" "g")))
 
27661
-   (use (match_operand:SI 3 "immediate_operand" "O"))
 
27662
-   (clobber (reg:SI LR_REGNO))]
 
27663
-  "TARGET_32BIT
 
27664
-   && DEFAULT_ABI == ABI_AIX
 
27665
-   && (INTVAL (operands[3]) & CALL_LONG) == 0"
 
27666
-  "bl %z1\;nop"
 
27667
-  [(set_attr "type" "branch")
 
27668
-   (set_attr "length" "8")])
 
27669
-
 
27670
-(define_insn "*call_value_nonlocal_aix64"
 
27671
-  [(set (match_operand 0 "" "")
 
27672
-       (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
 
27673
-             (match_operand 2 "" "g")))
 
27674
-   (use (match_operand:SI 3 "immediate_operand" "O"))
 
27675
-   (clobber (reg:SI LR_REGNO))]
 
27676
-  "TARGET_64BIT
 
27677
-   && DEFAULT_ABI == ABI_AIX
 
27678
-   && (INTVAL (operands[3]) & CALL_LONG) == 0"
 
27679
-  "bl %z1\;nop"
 
27680
-  [(set_attr "type" "branch")
 
27681
-   (set_attr "length" "8")])
 
27682
-
 
27683
 ;; A function pointer under System V is just a normal pointer
 
27684
 ;; operands[0] is the function pointer
 
27685
 ;; operands[1] is the stack size to clean up
 
27686
@@ -11009,6 +11900,104 @@
 
27687
   [(set_attr "type" "branch,branch")
 
27688
    (set_attr "length" "4,8")])
 
27689
 
 
27690
+
 
27691
+;; Call to AIX abi function in the same module.
 
27692
+
 
27693
+(define_insn "*call_local_aix<mode>"
 
27694
+  [(call (mem:SI (match_operand:P 0 "current_file_function_operand" "s"))
 
27695
+        (match_operand 1 "" "g"))
 
27696
+   (clobber (reg:P LR_REGNO))]
 
27697
+  "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
 
27698
+  "bl %z0"
 
27699
+  [(set_attr "type" "branch")
 
27700
+   (set_attr "length" "4")])
 
27701
+
 
27702
+(define_insn "*call_value_local_aix<mode>"
 
27703
+  [(set (match_operand 0 "" "")
 
27704
+       (call (mem:SI (match_operand:P 1 "current_file_function_operand" "s"))
 
27705
+             (match_operand 2 "" "g")))
 
27706
+   (clobber (reg:P LR_REGNO))]
 
27707
+  "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
 
27708
+  "bl %z1"
 
27709
+  [(set_attr "type" "branch")
 
27710
+   (set_attr "length" "4")])
 
27711
+
 
27712
+;; Call to AIX abi function which may be in another module.
 
27713
+;; Restore the TOC pointer (r2) after the call.
 
27714
+
 
27715
+(define_insn "*call_nonlocal_aix<mode>"
 
27716
+  [(call (mem:SI (match_operand:P 0 "symbol_ref_operand" "s"))
 
27717
+        (match_operand 1 "" "g"))
 
27718
+   (clobber (reg:P LR_REGNO))]
 
27719
+  "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
 
27720
+  "bl %z0\;nop"
 
27721
+  [(set_attr "type" "branch")
 
27722
+   (set_attr "length" "8")])
 
27723
+
 
27724
+(define_insn "*call_value_nonlocal_aix<mode>"
 
27725
+  [(set (match_operand 0 "" "")
 
27726
+       (call (mem:SI (match_operand:P 1 "symbol_ref_operand" "s"))
 
27727
+             (match_operand 2 "" "g")))
 
27728
+   (clobber (reg:P LR_REGNO))]
 
27729
+  "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
 
27730
+  "bl %z1\;nop"
 
27731
+  [(set_attr "type" "branch")
 
27732
+   (set_attr "length" "8")])
 
27733
+
 
27734
+;; Call to indirect functions with the AIX abi using a 3 word descriptor.
 
27735
+;; Operand0 is the addresss of the function to call
 
27736
+;; Operand2 is the location in the function descriptor to load r2 from
 
27737
+;; Operand3 is the stack location to hold the current TOC pointer
 
27738
+
 
27739
+(define_insn "*call_indirect_aix<mode>"
 
27740
+  [(call (mem:SI (match_operand:P 0 "register_operand" "c,*l"))
 
27741
+        (match_operand 1 "" "g,g"))
 
27742
+   (use (match_operand:P 2 "memory_operand" "<ptrm>,<ptrm>"))
 
27743
+   (set (reg:P TOC_REGNUM) (match_operand:P 3 "memory_operand" "<ptrm>,<ptrm>"))
 
27744
+   (clobber (reg:P LR_REGNO))]
 
27745
+  "DEFAULT_ABI == ABI_AIX"
 
27746
+  "<ptrload> 2,%2\;b%T0l\;<ptrload> 2,%3"
 
27747
+  [(set_attr "type" "jmpreg")
 
27748
+   (set_attr "length" "12")])
 
27749
+
 
27750
+(define_insn "*call_value_indirect_aix<mode>"
 
27751
+  [(set (match_operand 0 "" "")
 
27752
+       (call (mem:SI (match_operand:P 1 "register_operand" "c,*l"))
 
27753
+             (match_operand 2 "" "g,g")))
 
27754
+   (use (match_operand:P 3 "memory_operand" "<ptrm>,<ptrm>"))
 
27755
+   (set (reg:P TOC_REGNUM) (match_operand:P 4 "memory_operand" "<ptrm>,<ptrm>"))
 
27756
+   (clobber (reg:P LR_REGNO))]
 
27757
+  "DEFAULT_ABI == ABI_AIX"
 
27758
+  "<ptrload> 2,%3\;b%T1l\;<ptrload> 2,%4"
 
27759
+  [(set_attr "type" "jmpreg")
 
27760
+   (set_attr "length" "12")])
 
27761
+
 
27762
+;; Call to indirect functions with the ELFv2 ABI.
 
27763
+;; Operand0 is the addresss of the function to call
 
27764
+;; Operand2 is the stack location to hold the current TOC pointer
 
27765
+
 
27766
+(define_insn "*call_indirect_elfv2<mode>"
 
27767
+  [(call (mem:SI (match_operand:P 0 "register_operand" "c,*l"))
 
27768
+        (match_operand 1 "" "g,g"))
 
27769
+   (set (reg:P TOC_REGNUM) (match_operand:P 2 "memory_operand" "<ptrm>,<ptrm>"))
 
27770
+   (clobber (reg:P LR_REGNO))]
 
27771
+  "DEFAULT_ABI == ABI_ELFv2"
 
27772
+  "b%T0l\;<ptrload> 2,%2"
 
27773
+  [(set_attr "type" "jmpreg")
 
27774
+   (set_attr "length" "8")])
 
27775
+
 
27776
+(define_insn "*call_value_indirect_elfv2<mode>"
 
27777
+  [(set (match_operand 0 "" "")
 
27778
+       (call (mem:SI (match_operand:P 1 "register_operand" "c,*l"))
 
27779
+             (match_operand 2 "" "g,g")))
 
27780
+   (set (reg:P TOC_REGNUM) (match_operand:P 3 "memory_operand" "<ptrm>,<ptrm>"))
 
27781
+   (clobber (reg:P LR_REGNO))]
 
27782
+  "DEFAULT_ABI == ABI_ELFv2"
 
27783
+  "b%T1l\;<ptrload> 2,%3"
 
27784
+  [(set_attr "type" "jmpreg")
 
27785
+   (set_attr "length" "8")])
 
27786
+
 
27787
+
 
27788
 ;; Call subroutine returning any type.
 
27789
 (define_expand "untyped_call"
 
27790
   [(parallel [(call (match_operand 0 "" "")
 
27791
@@ -11056,8 +12045,41 @@
 
27792
   gcc_assert (GET_CODE (operands[1]) == CONST_INT);
 
27793
 
 
27794
   operands[0] = XEXP (operands[0], 0);
 
27795
+
 
27796
+  if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
27797
+    {
 
27798
+      rs6000_sibcall_aix (NULL_RTX, operands[0], operands[1], operands[2]);
 
27799
+      DONE;
 
27800
+    }
 
27801
 }")
 
27802
 
 
27803
+(define_expand "sibcall_value"
 
27804
+  [(parallel [(set (match_operand 0 "register_operand" "")
 
27805
+               (call (mem:SI (match_operand 1 "address_operand" ""))
 
27806
+                     (match_operand 2 "" "")))
 
27807
+             (use (match_operand 3 "" ""))
 
27808
+             (use (reg:SI LR_REGNO))
 
27809
+             (simple_return)])]
 
27810
+  ""
 
27811
+  "
 
27812
+{
 
27813
+#if TARGET_MACHO
 
27814
+  if (MACHOPIC_INDIRECT)
 
27815
+    operands[1] = machopic_indirect_call_target (operands[1]);
 
27816
+#endif
 
27817
+
 
27818
+  gcc_assert (GET_CODE (operands[1]) == MEM);
 
27819
+  gcc_assert (GET_CODE (operands[2]) == CONST_INT);
 
27820
+
 
27821
+  operands[1] = XEXP (operands[1], 0);
 
27822
+
 
27823
+  if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2)
 
27824
+    {
 
27825
+      rs6000_sibcall_aix (operands[0], operands[1], operands[2], operands[3]);
 
27826
+      DONE;
 
27827
+    }
 
27828
+}")
 
27829
+
 
27830
 ;; this and similar patterns must be marked as using LR, otherwise
 
27831
 ;; dataflow will try to delete the store into it.  This is true
 
27832
 ;; even when the actual reg to jump to is in CTR, when LR was
 
27833
@@ -11123,7 +12145,6 @@
 
27834
   [(set_attr "type" "branch")
 
27835
    (set_attr "length" "4,8")])
 
27836
 
 
27837
-
 
27838
 (define_insn "*sibcall_value_local64"
 
27839
   [(set (match_operand 0 "" "")
 
27840
        (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
 
27841
@@ -11145,35 +12166,6 @@
 
27842
   [(set_attr "type" "branch")
 
27843
    (set_attr "length" "4,8")])
 
27844
 
 
27845
-(define_insn "*sibcall_nonlocal_aix<mode>"
 
27846
-  [(call (mem:SI (match_operand:P 0 "call_operand" "s,c"))
 
27847
-        (match_operand 1 "" "g,g"))
 
27848
-   (use (match_operand:SI 2 "immediate_operand" "O,O"))
 
27849
-   (use (reg:SI LR_REGNO))
 
27850
-   (simple_return)]
 
27851
-  "DEFAULT_ABI == ABI_AIX
 
27852
-   && (INTVAL (operands[2]) & CALL_LONG) == 0"
 
27853
-  "@
 
27854
-   b %z0
 
27855
-   b%T0"
 
27856
-  [(set_attr "type" "branch")
 
27857
-   (set_attr "length" "4")])
 
27858
-
 
27859
-(define_insn "*sibcall_value_nonlocal_aix<mode>"
 
27860
-  [(set (match_operand 0 "" "")
 
27861
-       (call (mem:SI (match_operand:P 1 "call_operand" "s,c"))
 
27862
-             (match_operand 2 "" "g,g")))
 
27863
-   (use (match_operand:SI 3 "immediate_operand" "O,O"))
 
27864
-   (use (reg:SI LR_REGNO))
 
27865
-   (simple_return)]
 
27866
-  "DEFAULT_ABI == ABI_AIX
 
27867
-   && (INTVAL (operands[3]) & CALL_LONG) == 0"
 
27868
-  "@
 
27869
-   b %z1
 
27870
-   b%T1"
 
27871
-  [(set_attr "type" "branch")
 
27872
-   (set_attr "length" "4")])
 
27873
-
 
27874
 (define_insn "*sibcall_nonlocal_sysv<mode>"
 
27875
   [(call (mem:SI (match_operand:P 0 "call_operand" "s,s,c,c"))
 
27876
         (match_operand 1 "" ""))
 
27877
@@ -11204,27 +12196,6 @@
 
27878
   [(set_attr "type" "branch")
 
27879
    (set_attr "length" "4,8,4,8")])
 
27880
 
 
27881
-(define_expand "sibcall_value"
 
27882
-  [(parallel [(set (match_operand 0 "register_operand" "")
 
27883
-               (call (mem:SI (match_operand 1 "address_operand" ""))
 
27884
-                     (match_operand 2 "" "")))
 
27885
-             (use (match_operand 3 "" ""))
 
27886
-             (use (reg:SI LR_REGNO))
 
27887
-             (simple_return)])]
 
27888
-  ""
 
27889
-  "
 
27890
-{
 
27891
-#if TARGET_MACHO
 
27892
-  if (MACHOPIC_INDIRECT)
 
27893
-    operands[1] = machopic_indirect_call_target (operands[1]);
 
27894
-#endif
 
27895
-
 
27896
-  gcc_assert (GET_CODE (operands[1]) == MEM);
 
27897
-  gcc_assert (GET_CODE (operands[2]) == CONST_INT);
 
27898
-
 
27899
-  operands[1] = XEXP (operands[1], 0);
 
27900
-}")
 
27901
-
 
27902
 (define_insn "*sibcall_value_nonlocal_sysv<mode>"
 
27903
   [(set (match_operand 0 "" "")
 
27904
        (call (mem:SI (match_operand:P 1 "call_operand" "s,s,c,c"))
 
27905
@@ -11256,6 +12227,31 @@
 
27906
   [(set_attr "type" "branch")
 
27907
    (set_attr "length" "4,8,4,8")])
 
27908
 
 
27909
+;; AIX ABI sibling call patterns.
 
27910
+
 
27911
+(define_insn "*sibcall_aix<mode>"
 
27912
+  [(call (mem:SI (match_operand:P 0 "call_operand" "s,c"))
 
27913
+        (match_operand 1 "" "g,g"))
 
27914
+   (simple_return)]
 
27915
+  "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
 
27916
+  "@
 
27917
+   b %z0
 
27918
+   b%T0"
 
27919
+  [(set_attr "type" "branch")
 
27920
+   (set_attr "length" "4")])
 
27921
+
 
27922
+(define_insn "*sibcall_value_aix<mode>"
 
27923
+  [(set (match_operand 0 "" "")
 
27924
+       (call (mem:SI (match_operand:P 1 "call_operand" "s,c"))
 
27925
+             (match_operand 2 "" "g,g")))
 
27926
+   (simple_return)]
 
27927
+  "DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2"
 
27928
+  "@
 
27929
+   b %z1
 
27930
+   b%T1"
 
27931
+  [(set_attr "type" "branch")
 
27932
+   (set_attr "length" "4")])
 
27933
+
 
27934
 (define_expand "sibcall_epilogue"
 
27935
   [(use (const_int 0))]
 
27936
   ""
 
27937
@@ -11294,7 +12290,14 @@
 
27938
   operands[1] = gen_rtx_REG (Pmode, 0);
 
27939
   return "st<wd>%U0%X0 %1,%0";
 
27940
 }
 
27941
-  [(set_attr "type" "store")
 
27942
+  [(set (attr "type")
 
27943
+      (if_then_else
 
27944
+       (match_test "update_indexed_address_mem (operands[0], VOIDmode)")
 
27945
+       (const_string "store_ux")
 
27946
+       (if_then_else
 
27947
+         (match_test "update_address_mem (operands[0], VOIDmode)")
 
27948
+         (const_string "store_u")
 
27949
+         (const_string "store"))))
 
27950
    (set_attr "length" "4")])
 
27951
 
 
27952
 (define_insn "probe_stack_range<P:mode>"
 
27953
@@ -11589,23 +12592,6 @@
 
27954
   [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
 
27955
    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
 
27956
 
 
27957
-(define_insn "*cmpsf_internal1"
 
27958
-  [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
 
27959
-       (compare:CCFP (match_operand:SF 1 "gpc_reg_operand" "f")
 
27960
-                     (match_operand:SF 2 "gpc_reg_operand" "f")))]
 
27961
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_SINGLE_FLOAT"
 
27962
-  "fcmpu %0,%1,%2"
 
27963
-  [(set_attr "type" "fpcompare")])
 
27964
-
 
27965
-(define_insn "*cmpdf_internal1"
 
27966
-  [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
 
27967
-       (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "d")
 
27968
-                     (match_operand:DF 2 "gpc_reg_operand" "d")))]
 
27969
-  "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_DOUBLE_FLOAT
 
27970
-   && !VECTOR_UNIT_VSX_P (DFmode)"
 
27971
-  "fcmpu %0,%1,%2"
 
27972
-  [(set_attr "type" "fpcompare")])
 
27973
-
 
27974
 ;; Only need to compare second words if first words equal
 
27975
 (define_insn "*cmptf_internal1"
 
27976
   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
 
27977
@@ -13501,6 +14487,14 @@
 
27978
   "mfcr %0"
 
27979
   [(set_attr "type" "mfcr")])
 
27980
 
 
27981
+(define_insn "*crsave"
 
27982
+  [(match_parallel 0 "crsave_operation"
 
27983
+                  [(set (match_operand:SI 1 "memory_operand" "=m")
 
27984
+                        (match_operand:SI 2 "gpc_reg_operand" "r"))])]
 
27985
+  ""
 
27986
+  "stw %2,%1"
 
27987
+  [(set_attr "type" "store")])
 
27988
+
 
27989
 (define_insn "*stmw"
 
27990
   [(match_parallel 0 "stmw_operation"
 
27991
                   [(set (match_operand:SI 1 "memory_operand" "=m")
 
27992
@@ -13885,7 +14879,7 @@
 
27993
                   (match_operand:P 2 "gpc_reg_operand" "r")] UNSPEC_BPERM))]
 
27994
   "TARGET_POPCNTD"
 
27995
   "bpermd %0,%1,%2"
 
27996
-  [(set_attr "type" "integer")])
 
27997
+  [(set_attr "type" "popcnt")])
 
27998
 
 
27999
 
 
28000
 ;; Builtin fma support.  Handle 
 
28001
@@ -13900,6 +14894,20 @@
 
28002
   ""
 
28003
   "")
 
28004
 
 
28005
+(define_insn "*fma<mode>4_fpr"
 
28006
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>,<Fv>")
 
28007
+       (fma:SFDF
 
28008
+         (match_operand:SFDF 1 "gpc_reg_operand" "%<Ff>,<Fv>,<Fv>")
 
28009
+         (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>,0")
 
28010
+         (match_operand:SFDF 3 "gpc_reg_operand" "<Ff>,0,<Fv>")))]
 
28011
+  "TARGET_<MODE>_FPR"
 
28012
+  "@
 
28013
+   fmadd<Ftrad> %0,%1,%2,%3
 
28014
+   xsmadda<Fvsx> %x0,%x1,%x2
 
28015
+   xsmaddm<Fvsx> %x0,%x1,%x3"
 
28016
+  [(set_attr "type" "fp")
 
28017
+   (set_attr "fp_type" "fp_maddsub_<Fs>")])
 
28018
+
 
28019
 ; Altivec only has fma and nfms.
 
28020
 (define_expand "fms<mode>4"
 
28021
   [(set (match_operand:FMA_F 0 "register_operand" "")
 
28022
@@ -13910,6 +14918,20 @@
 
28023
   "!VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
 
28024
   "")
 
28025
 
 
28026
+(define_insn "*fms<mode>4_fpr"
 
28027
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>,<Fv>")
 
28028
+       (fma:SFDF
 
28029
+        (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>,<Fv>")
 
28030
+        (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>,0")
 
28031
+        (neg:SFDF (match_operand:SFDF 3 "gpc_reg_operand" "<Ff>,0,<Fv>"))))]
 
28032
+  "TARGET_<MODE>_FPR"
 
28033
+  "@
 
28034
+   fmsub<Ftrad> %0,%1,%2,%3
 
28035
+   xsmsuba<Fvsx> %x0,%x1,%x2
 
28036
+   xsmsubm<Fvsx> %x0,%x1,%x3"
 
28037
+  [(set_attr "type" "fp")
 
28038
+   (set_attr "fp_type" "fp_maddsub_<Fs>")])
 
28039
+
 
28040
 ;; If signed zeros are ignored, -(a * b - c) = -a * b + c.
 
28041
 (define_expand "fnma<mode>4"
 
28042
   [(set (match_operand:FMA_F 0 "register_operand" "")
 
28043
@@ -13943,6 +14965,21 @@
 
28044
   "!VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
 
28045
   "")
 
28046
 
 
28047
+(define_insn "*nfma<mode>4_fpr"
 
28048
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>,<Fv>")
 
28049
+       (neg:SFDF
 
28050
+        (fma:SFDF
 
28051
+         (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>,<Fv>")
 
28052
+         (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>,0")
 
28053
+         (match_operand:SFDF 3 "gpc_reg_operand" "<Ff>,0,<Fv>"))))]
 
28054
+  "TARGET_<MODE>_FPR"
 
28055
+  "@
 
28056
+   fnmadd<Ftrad> %0,%1,%2,%3
 
28057
+   xsnmadda<Fvsx> %x0,%x1,%x2
 
28058
+   xsnmaddm<Fvsx> %x0,%x1,%x3"
 
28059
+  [(set_attr "type" "fp")
 
28060
+   (set_attr "fp_type" "fp_maddsub_<Fs>")])
 
28061
+
 
28062
 ; Not an official optab name, but used from builtins.
 
28063
 (define_expand "nfms<mode>4"
 
28064
   [(set (match_operand:FMA_F 0 "register_operand" "")
 
28065
@@ -13954,6 +14991,23 @@
 
28066
   ""
 
28067
   "")
 
28068
 
 
28069
+(define_insn "*nfmssf4_fpr"
 
28070
+  [(set (match_operand:SFDF 0 "gpc_reg_operand" "=<Ff>,<Fv>,<Fv>")
 
28071
+       (neg:SFDF
 
28072
+        (fma:SFDF
 
28073
+         (match_operand:SFDF 1 "gpc_reg_operand" "<Ff>,<Fv>,<Fv>")
 
28074
+         (match_operand:SFDF 2 "gpc_reg_operand" "<Ff>,<Fv>,0")
 
28075
+         (neg:SFDF
 
28076
+          (match_operand:SFDF 3 "gpc_reg_operand" "<Ff>,0,<Fv>")))))]
 
28077
+  "TARGET_<MODE>_FPR"
 
28078
+  "@
 
28079
+   fnmsub<Ftrad> %0,%1,%2,%3
 
28080
+   xsnmsuba<Fvsx> %x0,%x1,%x2
 
28081
+   xsnmsubm<Fvsx> %x0,%x1,%x3"
 
28082
+  [(set_attr "type" "fp")
 
28083
+   (set_attr "fp_type" "fp_maddsub_<Fs>")])
 
28084
+
 
28085
+
 
28086
 (define_expand "rs6000_get_timebase"
 
28087
   [(use (match_operand:DI 0 "gpc_reg_operand" ""))]
 
28088
   ""
 
28089
@@ -14020,7 +15074,44 @@
 
28090
 })
 
28091
 
 
28092
 
 
28093
+;; Power8 fusion support for fusing an addis instruction with a D-form load of
 
28094
+;; a GPR.  The addis instruction must be adjacent to the load, and use the same
 
28095
+;; register that is being loaded.  The fused ops must be physically adjacent.
 
28096
 
 
28097
+;; We use define_peephole for the actual addis/load, and the register used to
 
28098
+;; hold the addis value must be the same as the register being loaded.  We use
 
28099
+;; define_peephole2 to change the register used for addis to be the register
 
28100
+;; being loaded, since we can look at whether it is dead after the load insn.
 
28101
+
 
28102
+(define_peephole
 
28103
+  [(set (match_operand:P 0 "base_reg_operand" "")
 
28104
+       (match_operand:P 1 "fusion_gpr_addis" ""))
 
28105
+   (set (match_operand:INT1 2 "base_reg_operand" "")
 
28106
+       (match_operand:INT1 3 "fusion_gpr_mem_load" ""))]
 
28107
+  "TARGET_P8_FUSION && fusion_gpr_load_p (operands, false)"
 
28108
+{
 
28109
+  return emit_fusion_gpr_load (operands);
 
28110
+}
 
28111
+  [(set_attr "type" "load")
 
28112
+   (set_attr "length" "8")])
 
28113
+
 
28114
+(define_peephole2
 
28115
+  [(set (match_operand:P 0 "base_reg_operand" "")
 
28116
+       (match_operand:P 1 "fusion_gpr_addis" ""))
 
28117
+   (set (match_operand:INT1 2 "base_reg_operand" "")
 
28118
+       (match_operand:INT1 3 "fusion_gpr_mem_load" ""))]
 
28119
+  "TARGET_P8_FUSION
 
28120
+   && (REGNO (operands[0]) != REGNO (operands[2])
 
28121
+       || GET_CODE (operands[3]) == SIGN_EXTEND)
 
28122
+   && fusion_gpr_load_p (operands, true)"
 
28123
+  [(const_int 0)]
 
28124
+{
 
28125
+  expand_fusion_gpr_load (operands);
 
28126
+  DONE;
 
28127
+})
 
28128
+
 
28129
+
 
28130
+
 
28131
 (include "sync.md")
 
28132
 (include "vector.md")
 
28133
 (include "vsx.md")
 
28134
@@ -14028,3 +15119,5 @@
 
28135
 (include "spe.md")
 
28136
 (include "dfp.md")
 
28137
 (include "paired.md")
 
28138
+(include "crypto.md")
 
28139
+(include "htm.md")
 
28140
--- a/src/gcc/config/rs6000/option-defaults.h
 
28141
+++ b/src/gcc/config/rs6000/option-defaults.h
 
28142
@@ -54,6 +54,7 @@
 
28143
    --with-float is ignored if -mhard-float or -msoft-float are
 
28144
      specified.  */
 
28145
 #define OPTION_DEFAULT_SPECS \
 
28146
+  {"abi", "%{!mabi=elfv*:-mabi=%(VALUE)}" }, \
 
28147
   {"tune", "%{!mtune=*:%{!mcpu=*:-mtune=%(VALUE)}}" }, \
 
28148
   {"tune_32", "%{" OPT_ARCH32 ":%{!mtune=*:%{!mcpu=*:-mtune=%(VALUE)}}}" }, \
 
28149
   {"tune_64", "%{" OPT_ARCH64 ":%{!mtune=*:%{!mcpu=*:-mtune=%(VALUE)}}}" }, \
 
28150
--- a/src/gcc/config/rs6000/rs6000-opts.h
 
28151
+++ b/src/gcc/config/rs6000/rs6000-opts.h
 
28152
@@ -59,7 +59,8 @@
 
28153
    PROCESSOR_POWER7,
 
28154
    PROCESSOR_CELL,
 
28155
    PROCESSOR_PPCA2,
 
28156
-   PROCESSOR_TITAN
 
28157
+   PROCESSOR_TITAN,
 
28158
+   PROCESSOR_POWER8
 
28159
 };
 
28160
 
 
28161
 /* FP processor type.  */
 
28162
@@ -100,7 +101,8 @@
 
28163
 /* Enumeration to give which calling sequence to use.  */
 
28164
 enum rs6000_abi {
 
28165
   ABI_NONE,
 
28166
-  ABI_AIX,                     /* IBM's AIX */
 
28167
+  ABI_AIX,                     /* IBM's AIX, or Linux ELFv1 */
 
28168
+  ABI_ELFv2,                   /* Linux ELFv2 ABI */
 
28169
   ABI_V4,                      /* System V.4/eabi */
 
28170
   ABI_DARWIN                   /* Apple's Darwin (OS X kernel) */
 
28171
 };
 
28172
@@ -131,11 +133,14 @@
 
28173
   CMODEL_LARGE
 
28174
 };
 
28175
 
 
28176
-/* Describe which vector unit to use for a given machine mode.  */
 
28177
+/* Describe which vector unit to use for a given machine mode.  The
 
28178
+   VECTOR_MEM_* and VECTOR_UNIT_* macros assume that Altivec, VSX, and
 
28179
+   P8_VECTOR are contiguous.  */
 
28180
 enum rs6000_vector {
 
28181
   VECTOR_NONE,                 /* Type is not  a vector or not supported */
 
28182
   VECTOR_ALTIVEC,              /* Use altivec for vector processing */
 
28183
   VECTOR_VSX,                  /* Use VSX for vector processing */
 
28184
+  VECTOR_P8_VECTOR,            /* Use ISA 2.07 VSX for vector processing */
 
28185
   VECTOR_PAIRED,               /* Use paired floating point for vectors */
 
28186
   VECTOR_SPE,                  /* Use SPE for vector processing */
 
28187
   VECTOR_OTHER                 /* Some other vector unit */
 
28188
--- a/src/gcc/config/rs6000/driver-rs6000.c
 
28189
+++ b/src/gcc/config/rs6000/driver-rs6000.c
 
28190
@@ -167,7 +167,7 @@
 
28191
 
 
28192
   if (fd != -1)
 
28193
     {
 
28194
-      char buf[1024];
 
28195
+      static char buf[1024];
 
28196
       ElfW(auxv_t) *av;
 
28197
       ssize_t n;
 
28198
 
 
28199
--- a/src/gcc/config/rs6000/altivec.h
 
28200
+++ b/src/gcc/config/rs6000/altivec.h
 
28201
@@ -321,6 +321,42 @@
 
28202
 #define vec_vsx_st __builtin_vec_vsx_st
 
28203
 #endif
 
28204
 
 
28205
+#ifdef _ARCH_PWR8
 
28206
+/* Vector additions added in ISA 2.07.  */
 
28207
+#define vec_eqv __builtin_vec_eqv
 
28208
+#define vec_nand __builtin_vec_nand
 
28209
+#define vec_orc __builtin_vec_orc
 
28210
+#define vec_vaddudm __builtin_vec_vaddudm
 
28211
+#define vec_vclz __builtin_vec_vclz
 
28212
+#define vec_vclzb __builtin_vec_vclzb
 
28213
+#define vec_vclzd __builtin_vec_vclzd
 
28214
+#define vec_vclzh __builtin_vec_vclzh
 
28215
+#define vec_vclzw __builtin_vec_vclzw
 
28216
+#define vec_vgbbd __builtin_vec_vgbbd
 
28217
+#define vec_vmaxsd __builtin_vec_vmaxsd
 
28218
+#define vec_vmaxud __builtin_vec_vmaxud
 
28219
+#define vec_vminsd __builtin_vec_vminsd
 
28220
+#define vec_vminud __builtin_vec_vminud
 
28221
+#define vec_vmrgew __builtin_vec_vmrgew
 
28222
+#define vec_vmrgow __builtin_vec_vmrgow
 
28223
+#define vec_vpksdss __builtin_vec_vpksdss
 
28224
+#define vec_vpksdus __builtin_vec_vpksdus
 
28225
+#define vec_vpkudum __builtin_vec_vpkudum
 
28226
+#define vec_vpkudus __builtin_vec_vpkudus
 
28227
+#define vec_vpopcnt __builtin_vec_vpopcnt
 
28228
+#define vec_vpopcntb __builtin_vec_vpopcntb
 
28229
+#define vec_vpopcntd __builtin_vec_vpopcntd
 
28230
+#define vec_vpopcnth __builtin_vec_vpopcnth
 
28231
+#define vec_vpopcntw __builtin_vec_vpopcntw
 
28232
+#define vec_vrld __builtin_vec_vrld
 
28233
+#define vec_vsld __builtin_vec_vsld
 
28234
+#define vec_vsrad __builtin_vec_vsrad
 
28235
+#define vec_vsrd __builtin_vec_vsrd
 
28236
+#define vec_vsubudm __builtin_vec_vsubudm
 
28237
+#define vec_vupkhsw __builtin_vec_vupkhsw
 
28238
+#define vec_vupklsw __builtin_vec_vupklsw
 
28239
+#endif
 
28240
+
 
28241
 /* Predicates.
 
28242
    For C++, we use templates in order to allow non-parenthesized arguments.
 
28243
    For C, instead, we use macros since non-parenthesized arguments were
 
28244
--- a/src/gcc/config/rs6000/sysv4.h
 
28245
+++ b/src/gcc/config/rs6000/sysv4.h
 
28246
@@ -45,7 +45,7 @@
 
28247
                                      & (OPTION_MASK_RELOCATABLE        \
 
28248
                                         | OPTION_MASK_MINIMAL_TOC))    \
 
28249
                                     && flag_pic > 1)                   \
 
28250
-                                || DEFAULT_ABI == ABI_AIX)
 
28251
+                                || DEFAULT_ABI != ABI_V4)
 
28252
 
 
28253
 #define        TARGET_BITFIELD_TYPE    (! TARGET_NO_BITFIELD_TYPE)
 
28254
 #define        TARGET_BIG_ENDIAN       (! TARGET_LITTLE_ENDIAN)
 
28255
@@ -147,7 +147,7 @@
 
28256
             rs6000_sdata_name);                                        \
 
28257
     }                                                                  \
 
28258
                                                                        \
 
28259
-  else if (flag_pic && DEFAULT_ABI != ABI_AIX                          \
 
28260
+  else if (flag_pic && DEFAULT_ABI == ABI_V4                           \
 
28261
           && (rs6000_sdata == SDATA_EABI                               \
 
28262
               || rs6000_sdata == SDATA_SYSV))                          \
 
28263
     {                                                                  \
 
28264
@@ -173,14 +173,14 @@
 
28265
       error ("-mrelocatable and -mno-minimal-toc are incompatible");   \
 
28266
     }                                                                  \
 
28267
                                                                        \
 
28268
-  if (TARGET_RELOCATABLE && rs6000_current_abi == ABI_AIX)             \
 
28269
+  if (TARGET_RELOCATABLE && rs6000_current_abi != ABI_V4)              \
 
28270
     {                                                                  \
 
28271
       rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE;                    \
 
28272
       error ("-mrelocatable and -mcall-%s are incompatible",           \
 
28273
             rs6000_abi_name);                                          \
 
28274
     }                                                                  \
 
28275
                                                                        \
 
28276
-  if (!TARGET_64BIT && flag_pic > 1 && rs6000_current_abi == ABI_AIX)  \
 
28277
+  if (!TARGET_64BIT && flag_pic > 1 && rs6000_current_abi != ABI_V4)   \
 
28278
     {                                                                  \
 
28279
       flag_pic = 0;                                                    \
 
28280
       error ("-fPIC and -mcall-%s are incompatible",                   \
 
28281
@@ -193,7 +193,7 @@
 
28282
     }                                                                  \
 
28283
                                                                        \
 
28284
   /* Treat -fPIC the same as -mrelocatable.  */                                \
 
28285
-  if (flag_pic > 1 && DEFAULT_ABI != ABI_AIX)                          \
 
28286
+  if (flag_pic > 1 && DEFAULT_ABI == ABI_V4)                           \
 
28287
     {                                                                  \
 
28288
       rs6000_isa_flags |= OPTION_MASK_RELOCATABLE | OPTION_MASK_MINIMAL_TOC; \
 
28289
       TARGET_NO_FP_IN_TOC = 1;                                         \
 
28290
@@ -317,7 +317,7 @@
 
28291
 
 
28292
 /* Put PC relative got entries in .got2.  */
 
28293
 #define        MINIMAL_TOC_SECTION_ASM_OP \
 
28294
-  (TARGET_RELOCATABLE || (flag_pic && DEFAULT_ABI != ABI_AIX)          \
 
28295
+  (TARGET_RELOCATABLE || (flag_pic && DEFAULT_ABI == ABI_V4)           \
 
28296
    ? "\t.section\t\".got2\",\"aw\"" : "\t.section\t\".got1\",\"aw\"")
 
28297
 
 
28298
 #define        SDATA_SECTION_ASM_OP "\t.section\t\".sdata\",\"aw\""
 
28299
@@ -538,12 +538,7 @@
 
28300
 
 
28301
 #define        CC1_ENDIAN_BIG_SPEC ""
 
28302
 
 
28303
-#define        CC1_ENDIAN_LITTLE_SPEC "\
 
28304
-%{!mstrict-align: %{!mno-strict-align: \
 
28305
-    %{!mcall-i960-old: \
 
28306
-       -mstrict-align \
 
28307
-    } \
 
28308
-}}"
 
28309
+#define        CC1_ENDIAN_LITTLE_SPEC ""
 
28310
 
 
28311
 #define        CC1_ENDIAN_DEFAULT_SPEC "%(cc1_endian_big)"
 
28312
 
 
28313
--- a/src/libgo/configure
 
28314
+++ b/src/libgo/configure
 
28315
@@ -6501,7 +6501,7 @@
 
28316
   rm -rf conftest*
 
28317
   ;;
 
28318
 
 
28319
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
28320
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
28321
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
28322
   # Find out which ABI we are using.
 
28323
   echo 'int i;' > conftest.$ac_ext
 
28324
@@ -6519,7 +6519,10 @@
 
28325
          x86_64-*linux*)
 
28326
            LD="${LD-ld} -m elf_i386"
 
28327
            ;;
 
28328
-         ppc64-*linux*|powerpc64-*linux*)
 
28329
+         powerpc64le-*linux*)
 
28330
+           LD="${LD-ld} -m elf32lppclinux"
 
28331
+           ;;
 
28332
+         powerpc64-*linux*)
 
28333
            LD="${LD-ld} -m elf32ppclinux"
 
28334
            ;;
 
28335
          s390x-*linux*)
 
28336
@@ -6538,7 +6541,10 @@
 
28337
          x86_64-*linux*)
 
28338
            LD="${LD-ld} -m elf_x86_64"
 
28339
            ;;
 
28340
-         ppc*-*linux*|powerpc*-*linux*)
 
28341
+         powerpcle-*linux*)
 
28342
+           LD="${LD-ld} -m elf64lppc"
 
28343
+           ;;
 
28344
+         powerpc-*linux*)
 
28345
            LD="${LD-ld} -m elf64ppc"
 
28346
            ;;
 
28347
          s390*-*linux*|s390*-*tpf*)
 
28348
@@ -11105,7 +11111,7 @@
 
28349
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
28350
   lt_status=$lt_dlunknown
 
28351
   cat > conftest.$ac_ext <<_LT_EOF
 
28352
-#line 11108 "configure"
 
28353
+#line 11114 "configure"
 
28354
 #include "confdefs.h"
 
28355
 
 
28356
 #if HAVE_DLFCN_H
 
28357
@@ -11211,7 +11217,7 @@
 
28358
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
28359
   lt_status=$lt_dlunknown
 
28360
   cat > conftest.$ac_ext <<_LT_EOF
 
28361
-#line 11214 "configure"
 
28362
+#line 11220 "configure"
 
28363
 #include "confdefs.h"
 
28364
 
 
28365
 #if HAVE_DLFCN_H
 
28366
--- a/src/libgo/testsuite/gotest
 
28367
+++ b/src/libgo/testsuite/gotest
 
28368
@@ -369,7 +369,7 @@
 
28369
 {
 
28370
        text="T"
 
28371
        case "$GOARCH" in
 
28372
-       ppc64) text="D" ;;
 
28373
+       ppc64) text="[TD]" ;;
 
28374
        esac
 
28375
 
 
28376
        symtogo='sed -e s/_test/XXXtest/ -e s/.*_\([^_]*\.\)/\1/ -e s/XXXtest/_test/'
 
28377
--- a/src/libgo/config/libtool.m4
 
28378
+++ b/src/libgo/config/libtool.m4
 
28379
@@ -1225,7 +1225,7 @@
 
28380
   rm -rf conftest*
 
28381
   ;;
 
28382
 
 
28383
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
28384
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
28385
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
28386
   # Find out which ABI we are using.
 
28387
   echo 'int i;' > conftest.$ac_ext
 
28388
@@ -1239,7 +1239,10 @@
 
28389
          x86_64-*linux*)
 
28390
            LD="${LD-ld} -m elf_i386"
 
28391
            ;;
 
28392
-         ppc64-*linux*|powerpc64-*linux*)
 
28393
+         powerpc64le-*linux*)
 
28394
+           LD="${LD-ld} -m elf32lppclinux"
 
28395
+           ;;
 
28396
+         powerpc64-*linux*)
 
28397
            LD="${LD-ld} -m elf32ppclinux"
 
28398
            ;;
 
28399
          s390x-*linux*)
 
28400
@@ -1258,7 +1261,10 @@
 
28401
          x86_64-*linux*)
 
28402
            LD="${LD-ld} -m elf_x86_64"
 
28403
            ;;
 
28404
-         ppc*-*linux*|powerpc*-*linux*)
 
28405
+         powerpcle-*linux*)
 
28406
+           LD="${LD-ld} -m elf64lppc"
 
28407
+           ;;
 
28408
+         powerpc-*linux*)
 
28409
            LD="${LD-ld} -m elf64ppc"
 
28410
            ;;
 
28411
          s390*-*linux*|s390*-*tpf*)
 
28412
--- a/src/config.sub
 
28413
+++ b/src/config.sub
 
28414
@@ -1,10 +1,8 @@
 
28415
 #! /bin/sh
 
28416
 # Configuration validation subroutine script.
 
28417
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 
28418
-#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
 
28419
-#   2011, 2012, 2013 Free Software Foundation, Inc.
 
28420
+#   Copyright 1992-2013 Free Software Foundation, Inc.
 
28421
 
 
28422
-timestamp='2013-01-11'
 
28423
+timestamp='2013-10-01'
 
28424
 
 
28425
 # This file is free software; you can redistribute it and/or modify it
 
28426
 # under the terms of the GNU General Public License as published by
 
28427
@@ -70,9 +68,7 @@
 
28428
 version="\
 
28429
 GNU config.sub ($timestamp)
 
28430
 
 
28431
-Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
 
28432
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
 
28433
-2012, 2013 Free Software Foundation, Inc.
 
28434
+Copyright 1992-2013 Free Software Foundation, Inc.
 
28435
 
 
28436
 This is free software; see the source for copying conditions.  There is NO
 
28437
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
 
28438
@@ -256,12 +252,12 @@
 
28439
        | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
 
28440
        | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
 
28441
        | am33_2.0 \
 
28442
-       | arc \
 
28443
+       | arc | arceb \
 
28444
        | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
 
28445
        | avr | avr32 \
 
28446
        | be32 | be64 \
 
28447
        | bfin \
 
28448
-       | c4x | clipper \
 
28449
+       | c4x | c8051 | clipper \
 
28450
        | d10v | d30v | dlx | dsp16xx \
 
28451
        | epiphany \
 
28452
        | fido | fr30 | frv \
 
28453
@@ -269,6 +265,7 @@
 
28454
        | hexagon \
 
28455
        | i370 | i860 | i960 | ia64 \
 
28456
        | ip2k | iq2000 \
 
28457
+       | k1om \
 
28458
        | le32 | le64 \
 
28459
        | lm32 \
 
28460
        | m32c | m32r | m32rle | m68000 | m68k | m88k \
 
28461
@@ -297,10 +294,10 @@
 
28462
        | mt \
 
28463
        | msp430 \
 
28464
        | nds32 | nds32le | nds32be \
 
28465
-       | nios | nios2 \
 
28466
+       | nios | nios2 | nios2eb | nios2el \
 
28467
        | ns16k | ns32k \
 
28468
        | open8 \
 
28469
-       | or32 \
 
28470
+       | or1k | or32 \
 
28471
        | pdp10 | pdp11 | pj | pjl \
 
28472
        | powerpc | powerpc64 | powerpc64le | powerpcle \
 
28473
        | pyramid \
 
28474
@@ -328,7 +325,7 @@
 
28475
        c6x)
 
28476
                basic_machine=tic6x-unknown
 
28477
                ;;
 
28478
-       m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
 
28479
+       m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
 
28480
                basic_machine=$basic_machine-unknown
 
28481
                os=-none
 
28482
                ;;
 
28483
@@ -370,13 +367,13 @@
 
28484
        | aarch64-* | aarch64_be-* \
 
28485
        | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
 
28486
        | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
 
28487
-       | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
 
28488
+       | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
 
28489
        | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
 
28490
        | avr-* | avr32-* \
 
28491
        | be32-* | be64-* \
 
28492
        | bfin-* | bs2000-* \
 
28493
        | c[123]* | c30-* | [cjt]90-* | c4x-* \
 
28494
-       | clipper-* | craynv-* | cydra-* \
 
28495
+       | c8051-* | clipper-* | craynv-* | cydra-* \
 
28496
        | d10v-* | d30v-* | dlx-* \
 
28497
        | elxsi-* \
 
28498
        | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
 
28499
@@ -385,6 +382,7 @@
 
28500
        | hexagon-* \
 
28501
        | i*86-* | i860-* | i960-* | ia64-* \
 
28502
        | ip2k-* | iq2000-* \
 
28503
+       | k1om-* \
 
28504
        | le32-* | le64-* \
 
28505
        | lm32-* \
 
28506
        | m32c-* | m32r-* | m32rle-* \
 
28507
@@ -414,7 +412,7 @@
 
28508
        | mt-* \
 
28509
        | msp430-* \
 
28510
        | nds32-* | nds32le-* | nds32be-* \
 
28511
-       | nios-* | nios2-* \
 
28512
+       | nios-* | nios2-* | nios2eb-* | nios2el-* \
 
28513
        | none-* | np1-* | ns16k-* | ns32k-* \
 
28514
        | open8-* \
 
28515
        | orion-* \
 
28516
@@ -798,7 +796,7 @@
 
28517
                os=-mingw64
 
28518
                ;;
 
28519
        mingw32)
 
28520
-               basic_machine=i386-pc
 
28521
+               basic_machine=i686-pc
 
28522
                os=-mingw32
 
28523
                ;;
 
28524
        mingw32ce)
 
28525
@@ -834,7 +832,7 @@
 
28526
                basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
 
28527
                ;;
 
28528
        msys)
 
28529
-               basic_machine=i386-pc
 
28530
+               basic_machine=i686-pc
 
28531
                os=-msys
 
28532
                ;;
 
28533
        mvs)
 
28534
@@ -1550,6 +1548,9 @@
 
28535
        c4x-* | tic4x-*)
 
28536
                os=-coff
 
28537
                ;;
 
28538
+       c8051-*)
 
28539
+               os=-elf
 
28540
+               ;;
 
28541
        hexagon-*)
 
28542
                os=-elf
 
28543
                ;;
 
28544
@@ -1593,6 +1594,9 @@
 
28545
        mips*-*)
 
28546
                os=-elf
 
28547
                ;;
 
28548
+       or1k-*)
 
28549
+               os=-elf
 
28550
+               ;;
 
28551
        or32-*)
 
28552
                os=-coff
 
28553
                ;;
 
28554
--- a/src/ChangeLog.ibm
 
28555
+++ b/src/ChangeLog.ibm
 
28556
@@ -0,0 +1,106 @@
 
28557
+2013-12-10  Alan Modra  <amodra@gmail.com>
 
28558
+
 
28559
+       Apply gcc-4_8-branch r205803
 
28560
+       2013-12-05  Alan Modra  <amodra@gmail.com>
 
28561
+       * gcc/configure.ac (BUILD_CXXFLAGS) Don't use ALL_CXXFLAGS for
 
28562
+       build != host.
 
28563
+       <recursive call for build != host>: Clear GMPINC.  Don't bother
 
28564
+       saving CFLAGS.
 
28565
+       * gcc/configure: Regenerate.
 
28566
+
 
28567
+2013-11-18  Alan Modra  <amodra@gmail.com>
 
28568
+
 
28569
+       Backport mainline r205844.
 
28570
+       * libffi/src/powerpc/ffitarget.h: Import from upstream.
 
28571
+       * libffi/src/powerpc/ffi_powerpc.h: Likewise.
 
28572
+       * libffi/src/powerpc/ffi.c: Likewise.
 
28573
+       * libffi/src/powerpc/ffi_sysv.c: Likewise.
 
28574
+       * libffi/src/powerpc/ffi_linux64.c: Likewise.
 
28575
+       * libffi/src/powerpc/sysv.S: Likewise.
 
28576
+       * libffi/src/powerpc/ppc_closure.S: Likewise.
 
28577
+       * libffi/src/powerpc/linux64.S: Likewise.
 
28578
+       * libffi/src/powerpc/linux64_closure.S: Likewise.
 
28579
+       * libffi/src/types.c: Likewise.
 
28580
+       * libffi/Makefile.am (EXTRA_DIST): Add new src/powerpc files.
 
28581
+       (nodist_libffi_la_SOURCES <POWERPC, POWERPC_FREEBSD>): Likewise.
 
28582
+       * libffi/configure.ac (HAVE_LONG_DOUBLE_VARIANT): Define for powerpc.
 
28583
+       * libffi/include/ffi.h.in (ffi_prep_types): Declare.
 
28584
+       * libffi/src/prep_cif.c (ffi_prep_cif_core): Call ffi_prep_types.
 
28585
+       * libffi/configure: Regenerate.
 
28586
+       * libffi/fficonfig.h.in: Regenerate.
 
28587
+       * libffi/Makefile.in: Regenerate.
 
28588
+       * libffi/man/Makefile.in: Regenerate.
 
28589
+       * libffi/include/Makefile.in: Regenerate.
 
28590
+       * libffi/testsuite/Makefile.in: Regenerate.
 
28591
+
 
28592
+2013-11-22  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
28593
+
 
28594
+       * libgo/config/libtool.m4: Update to mainline version.
 
28595
+       * libgo/configure: Regenerate.
 
28596
+
 
28597
+2013-11-19  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
28598
+
 
28599
+       Backport from mainline r205000.
 
28600
+
 
28601
+       gotest: Recognize PPC ELF v2 function pointers in text section.
 
28602
+
 
28603
+2013-11-18  Alan Modra  <amodra@gmail.com>
 
28604
+
 
28605
+       * libffi/src/powerpc/ppc_closure.S: Don't bl .Luint128.
 
28606
+
 
28607
+       * libffi/src/powerpc/ffitarget.h: Import from upstream.
 
28608
+       * libffi/src/powerpc/ffi.c: Likewise.
 
28609
+       * libffi/src/powerpc/linux64.S: Likewise.
 
28610
+       * libffi/src/powerpc/linux64_closure.S: Likewise.
 
28611
+       * libffi/doc/libffi.texi: Likewise.
 
28612
+       * libffi/testsuite/libffi.call/cls_double_va.c: Likewise.
 
28613
+       * libffi/testsuite/libffi.call/cls_longdouble_va.c: Likewise.
 
28614
+
 
28615
+2013-11-17  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
28616
+
 
28617
+       * libgo/config/libtool.m4: Update to mainline version.
 
28618
+       * libgo/configure: Regenerate.
 
28619
+
 
28620
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
28621
+
 
28622
+       * libtool.m4: Update to mainline version.
 
28623
+       * libjava/libltdl/acinclude.m4: Likewise.
 
28624
+
 
28625
+       * gcc/configure: Regenerate.
 
28626
+       * boehm-gc/configure: Regenerate.
 
28627
+       * libatomic/configure: Regenerate.
 
28628
+       * libbacktrace/configure: Regenerate.
 
28629
+       * libffi/configure: Regenerate.
 
28630
+       * libgfortran/configure: Regenerate.
 
28631
+       * libgomp/configure: Regenerate.
 
28632
+       * libitm/configure: Regenerate.
 
28633
+       * libjava/configure: Regenerate.
 
28634
+       * libjava/libltdl/configure: Regenerate.
 
28635
+       * libjava/classpath/configure: Regenerate.
 
28636
+       * libmudflap/configure: Regenerate.
 
28637
+       * libobjc/configure: Regenerate.
 
28638
+       * libquadmath/configure: Regenerate.
 
28639
+       * libsanitizer/configure: Regenerate.
 
28640
+       * libssp/configure: Regenerate.
 
28641
+       * libstdc++-v3/configure: Regenerate.
 
28642
+       * lto-plugin/configure: Regenerate.
 
28643
+       * zlib/configure: Regenerate.
 
28644
+
 
28645
+2013-11-15  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
 
28646
+
 
28647
+       Backport from mainline r203071:
 
28648
+
 
28649
+       2013-10-01  Joern Rennecke  <joern.rennecke@embecosm.com>
 
28650
+
 
28651
+       Import from savannah.gnu.org:
 
28652
+       * config.guess: Update to 2013-06-10 version.
 
28653
+       * config.sub: Update to 2013-10-01 version.
 
28654
+
 
28655
+2013-11-12  Bill Schmidt  <wschmidt@linux.ibm.com>
 
28656
+
 
28657
+       Backport from mainline
 
28658
+       2013-09-20  Alan Modra  <amodra@gmail.com>
 
28659
+
 
28660
+       * libtool.m4 (_LT_ENABLE_LOCK <ld -m flags>): Remove non-canonical
 
28661
+       ppc host match.  Support little-endian powerpc linux hosts.
 
28662
+
 
28663
--- a/src/libobjc/configure
 
28664
+++ b/src/libobjc/configure
 
28665
@@ -6056,7 +6056,7 @@
 
28666
   rm -rf conftest*
 
28667
   ;;
 
28668
 
 
28669
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
28670
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
28671
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
28672
   # Find out which ABI we are using.
 
28673
   echo 'int i;' > conftest.$ac_ext
 
28674
@@ -6081,7 +6081,10 @@
 
28675
                ;;
 
28676
            esac
 
28677
            ;;
 
28678
-         ppc64-*linux*|powerpc64-*linux*)
 
28679
+         powerpc64le-*linux*)
 
28680
+           LD="${LD-ld} -m elf32lppclinux"
 
28681
+           ;;
 
28682
+         powerpc64-*linux*)
 
28683
            LD="${LD-ld} -m elf32ppclinux"
 
28684
            ;;
 
28685
          s390x-*linux*)
 
28686
@@ -6100,7 +6103,10 @@
 
28687
          x86_64-*linux*)
 
28688
            LD="${LD-ld} -m elf_x86_64"
 
28689
            ;;
 
28690
-         ppc*-*linux*|powerpc*-*linux*)
 
28691
+         powerpcle-*linux*)
 
28692
+           LD="${LD-ld} -m elf64lppc"
 
28693
+           ;;
 
28694
+         powerpc-*linux*)
 
28695
            LD="${LD-ld} -m elf64ppc"
 
28696
            ;;
 
28697
          s390*-*linux*|s390*-*tpf*)
 
28698
@@ -10595,7 +10601,7 @@
 
28699
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
28700
   lt_status=$lt_dlunknown
 
28701
   cat > conftest.$ac_ext <<_LT_EOF
 
28702
-#line 10598 "configure"
 
28703
+#line 10604 "configure"
 
28704
 #include "confdefs.h"
 
28705
 
 
28706
 #if HAVE_DLFCN_H
 
28707
@@ -10701,7 +10707,7 @@
 
28708
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
28709
   lt_status=$lt_dlunknown
 
28710
   cat > conftest.$ac_ext <<_LT_EOF
 
28711
-#line 10704 "configure"
 
28712
+#line 10710 "configure"
 
28713
 #include "confdefs.h"
 
28714
 
 
28715
 #if HAVE_DLFCN_H
 
28716
@@ -11472,7 +11478,7 @@
 
28717
   enableval=$enable_sjlj_exceptions; :
 
28718
 else
 
28719
   cat > conftest.$ac_ext << EOF
 
28720
-#line 11475 "configure"
 
28721
+#line 11481 "configure"
 
28722
 @interface Frob
 
28723
 @end
 
28724
 @implementation Frob
 
28725
--- a/src/libgfortran/configure
 
28726
+++ b/src/libgfortran/configure
 
28727
@@ -8062,7 +8062,7 @@
 
28728
   rm -rf conftest*
 
28729
   ;;
 
28730
 
 
28731
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
28732
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
28733
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
28734
   # Find out which ABI we are using.
 
28735
   echo 'int i;' > conftest.$ac_ext
 
28736
@@ -8087,7 +8087,10 @@
 
28737
                ;;
 
28738
            esac
 
28739
            ;;
 
28740
-         ppc64-*linux*|powerpc64-*linux*)
 
28741
+         powerpc64le-*linux*)
 
28742
+           LD="${LD-ld} -m elf32lppclinux"
 
28743
+           ;;
 
28744
+         powerpc64-*linux*)
 
28745
            LD="${LD-ld} -m elf32ppclinux"
 
28746
            ;;
 
28747
          s390x-*linux*)
 
28748
@@ -8106,7 +8109,10 @@
 
28749
          x86_64-*linux*)
 
28750
            LD="${LD-ld} -m elf_x86_64"
 
28751
            ;;
 
28752
-         ppc*-*linux*|powerpc*-*linux*)
 
28753
+         powerpcle-*linux*)
 
28754
+           LD="${LD-ld} -m elf64lppc"
 
28755
+           ;;
 
28756
+         powerpc-*linux*)
 
28757
            LD="${LD-ld} -m elf64ppc"
 
28758
            ;;
 
28759
          s390*-*linux*|s390*-*tpf*)
 
28760
@@ -12333,7 +12339,7 @@
 
28761
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
28762
   lt_status=$lt_dlunknown
 
28763
   cat > conftest.$ac_ext <<_LT_EOF
 
28764
-#line 12336 "configure"
 
28765
+#line 12342 "configure"
 
28766
 #include "confdefs.h"
 
28767
 
 
28768
 #if HAVE_DLFCN_H
 
28769
@@ -12439,7 +12445,7 @@
 
28770
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
28771
   lt_status=$lt_dlunknown
 
28772
   cat > conftest.$ac_ext <<_LT_EOF
 
28773
-#line 12442 "configure"
 
28774
+#line 12448 "configure"
 
28775
 #include "confdefs.h"
 
28776
 
 
28777
 #if HAVE_DLFCN_H
 
28778
--- a/src/libffi/configure
 
28779
+++ b/src/libffi/configure
 
28780
@@ -613,6 +613,7 @@
 
28781
 FFI_EXEC_TRAMPOLINE_TABLE
 
28782
 FFI_EXEC_TRAMPOLINE_TABLE_FALSE
 
28783
 FFI_EXEC_TRAMPOLINE_TABLE_TRUE
 
28784
+HAVE_LONG_DOUBLE_VARIANT
 
28785
 HAVE_LONG_DOUBLE
 
28786
 ALLOCA
 
28787
 TILE_FALSE
 
28788
@@ -6392,7 +6393,7 @@
 
28789
   rm -rf conftest*
 
28790
   ;;
 
28791
 
 
28792
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
28793
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
28794
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
28795
   # Find out which ABI we are using.
 
28796
   echo 'int i;' > conftest.$ac_ext
 
28797
@@ -6417,7 +6418,10 @@
 
28798
                ;;
 
28799
            esac
 
28800
            ;;
 
28801
-         ppc64-*linux*|powerpc64-*linux*)
 
28802
+         powerpc64le-*linux*)
 
28803
+           LD="${LD-ld} -m elf32lppclinux"
 
28804
+           ;;
 
28805
+         powerpc64-*linux*)
 
28806
            LD="${LD-ld} -m elf32ppclinux"
 
28807
            ;;
 
28808
          s390x-*linux*)
 
28809
@@ -6436,7 +6440,10 @@
 
28810
          x86_64-*linux*)
 
28811
            LD="${LD-ld} -m elf_x86_64"
 
28812
            ;;
 
28813
-         ppc*-*linux*|powerpc*-*linux*)
 
28814
+         powerpcle-*linux*)
 
28815
+           LD="${LD-ld} -m elf64lppc"
 
28816
+           ;;
 
28817
+         powerpc-*linux*)
 
28818
            LD="${LD-ld} -m elf64ppc"
 
28819
            ;;
 
28820
          s390*-*linux*|s390*-*tpf*)
 
28821
@@ -10900,7 +10907,7 @@
 
28822
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
28823
   lt_status=$lt_dlunknown
 
28824
   cat > conftest.$ac_ext <<_LT_EOF
 
28825
-#line 10903 "configure"
 
28826
+#line 10910 "configure"
 
28827
 #include "confdefs.h"
 
28828
 
 
28829
 #if HAVE_DLFCN_H
 
28830
@@ -11006,7 +11013,7 @@
 
28831
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
28832
   lt_status=$lt_dlunknown
 
28833
   cat > conftest.$ac_ext <<_LT_EOF
 
28834
-#line 11009 "configure"
 
28835
+#line 11016 "configure"
 
28836
 #include "confdefs.h"
 
28837
 
 
28838
 #if HAVE_DLFCN_H
 
28839
@@ -11443,6 +11450,7 @@
 
28840
 
 
28841
 
 
28842
 TARGETDIR="unknown"
 
28843
+HAVE_LONG_DOUBLE_VARIANT=0
 
28844
 case "$host" in
 
28845
   aarch64*-*-*)
 
28846
        TARGET=AARCH64; TARGETDIR=aarch64
 
28847
@@ -11540,6 +11548,7 @@
 
28848
 
 
28849
   powerpc*-*-linux* | powerpc-*-sysv*)
 
28850
        TARGET=POWERPC; TARGETDIR=powerpc
 
28851
+       HAVE_LONG_DOUBLE_VARIANT=1
 
28852
        ;;
 
28853
   powerpc-*-amigaos*)
 
28854
        TARGET=POWERPC; TARGETDIR=powerpc
 
28855
@@ -11555,6 +11564,7 @@
 
28856
        ;;
 
28857
   powerpc-*-freebsd* | powerpc-*-openbsd*)
 
28858
        TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
 
28859
+       HAVE_LONG_DOUBLE_VARIANT=1
 
28860
        ;;
 
28861
   powerpc64-*-freebsd*)
 
28862
        TARGET=POWERPC; TARGETDIR=powerpc
 
28863
@@ -12230,17 +12240,25 @@
 
28864
 # Also AC_SUBST this variable for ffi.h.
 
28865
 if test -z "$HAVE_LONG_DOUBLE"; then
 
28866
   HAVE_LONG_DOUBLE=0
 
28867
-  if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
 
28868
-    if test $ac_cv_sizeof_long_double != 0; then
 
28869
+  if test $ac_cv_sizeof_long_double != 0; then
 
28870
+    if test $HAVE_LONG_DOUBLE_VARIANT != 0; then
 
28871
+
 
28872
+$as_echo "#define HAVE_LONG_DOUBLE_VARIANT 1" >>confdefs.h
 
28873
+
 
28874
       HAVE_LONG_DOUBLE=1
 
28875
+    else
 
28876
+      if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
 
28877
+        HAVE_LONG_DOUBLE=1
 
28878
 
 
28879
 $as_echo "#define HAVE_LONG_DOUBLE 1" >>confdefs.h
 
28880
 
 
28881
+      fi
 
28882
     fi
 
28883
   fi
 
28884
 fi
 
28885
 
 
28886
 
 
28887
+
 
28888
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
 
28889
 $as_echo_n "checking whether byte ordering is bigendian... " >&6; }
 
28890
 if test "${ac_cv_c_bigendian+set}" = set; then :
 
28891
--- a/src/libffi/Makefile.in
 
28892
+++ b/src/libffi/Makefile.in
 
28893
@@ -48,10 +48,10 @@
 
28894
 @IA64_TRUE@am__append_11 = src/ia64/ffi.c src/ia64/unix.S
 
28895
 @M32R_TRUE@am__append_12 = src/m32r/sysv.S src/m32r/ffi.c
 
28896
 @M68K_TRUE@am__append_13 = src/m68k/ffi.c src/m68k/sysv.S
 
28897
-@POWERPC_TRUE@am__append_14 = src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S
 
28898
+@POWERPC_TRUE@am__append_14 = src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S
 
28899
 @POWERPC_AIX_TRUE@am__append_15 = src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S
 
28900
 @POWERPC_DARWIN_TRUE@am__append_16 = src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S
 
28901
-@POWERPC_FREEBSD_TRUE@am__append_17 = src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S
 
28902
+@POWERPC_FREEBSD_TRUE@am__append_17 = src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/sysv.S src/powerpc/ppc_closure.S
 
28903
 @AARCH64_TRUE@am__append_18 = src/aarch64/sysv.S src/aarch64/ffi.c
 
28904
 @ARM_TRUE@am__append_19 = src/arm/sysv.S src/arm/ffi.c
 
28905
 @ARM_TRUE@@FFI_EXEC_TRAMPOLINE_TABLE_TRUE@am__append_20 = src/arm/trampoline.S
 
28906
@@ -133,7 +133,9 @@
 
28907
 @IA64_TRUE@am__objects_11 = src/ia64/ffi.lo src/ia64/unix.lo
 
28908
 @M32R_TRUE@am__objects_12 = src/m32r/sysv.lo src/m32r/ffi.lo
 
28909
 @M68K_TRUE@am__objects_13 = src/m68k/ffi.lo src/m68k/sysv.lo
 
28910
-@POWERPC_TRUE@am__objects_14 = src/powerpc/ffi.lo src/powerpc/sysv.lo \
 
28911
+@POWERPC_TRUE@am__objects_14 = src/powerpc/ffi.lo \
 
28912
+@POWERPC_TRUE@ src/powerpc/ffi_sysv.lo \
 
28913
+@POWERPC_TRUE@ src/powerpc/ffi_linux64.lo src/powerpc/sysv.lo \
 
28914
 @POWERPC_TRUE@ src/powerpc/ppc_closure.lo \
 
28915
 @POWERPC_TRUE@ src/powerpc/linux64.lo \
 
28916
 @POWERPC_TRUE@ src/powerpc/linux64_closure.lo
 
28917
@@ -144,6 +146,7 @@
 
28918
 @POWERPC_DARWIN_TRUE@  src/powerpc/darwin.lo \
 
28919
 @POWERPC_DARWIN_TRUE@  src/powerpc/darwin_closure.lo
 
28920
 @POWERPC_FREEBSD_TRUE@am__objects_17 = src/powerpc/ffi.lo \
 
28921
+@POWERPC_FREEBSD_TRUE@ src/powerpc/ffi_sysv.lo \
 
28922
 @POWERPC_FREEBSD_TRUE@ src/powerpc/sysv.lo \
 
28923
 @POWERPC_FREEBSD_TRUE@ src/powerpc/ppc_closure.lo
 
28924
 @AARCH64_TRUE@am__objects_18 = src/aarch64/sysv.lo src/aarch64/ffi.lo
 
28925
@@ -278,6 +281,7 @@
 
28926
 FGREP = @FGREP@
 
28927
 GREP = @GREP@
 
28928
 HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
 
28929
+HAVE_LONG_DOUBLE_VARIANT = @HAVE_LONG_DOUBLE_VARIANT@
 
28930
 INSTALL = @INSTALL@
 
28931
 INSTALL_DATA = @INSTALL_DATA@
 
28932
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 
28933
@@ -387,10 +391,12 @@
 
28934
         src/ia64/unix.S src/mips/ffi.c src/mips/n32.S src/mips/o32.S   \
 
28935
         src/mips/ffitarget.h src/m32r/ffi.c src/m32r/sysv.S            \
 
28936
         src/m32r/ffitarget.h src/m68k/ffi.c src/m68k/sysv.S            \
 
28937
-        src/m68k/ffitarget.h src/powerpc/ffi.c src/powerpc/sysv.S      \
 
28938
-        src/powerpc/linux64.S src/powerpc/linux64_closure.S            \
 
28939
-        src/powerpc/ppc_closure.S src/powerpc/asm.h                    \
 
28940
-       src/powerpc/aix.S src/powerpc/darwin.S                          \
 
28941
+        src/m68k/ffitarget.h                                           \
 
28942
+       src/powerpc/ffi.c src/powerpc/ffi_powerpc.h                     \
 
28943
+       src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c                \
 
28944
+       src/powerpc/sysv.S src/powerpc/linux64.S                        \
 
28945
+       src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S         \
 
28946
+       src/powerpc/asm.h src/powerpc/aix.S src/powerpc/darwin.S        \
 
28947
        src/powerpc/aix_closure.S src/powerpc/darwin_closure.S          \
 
28948
        src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h                \
 
28949
        src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h             \
 
28950
@@ -711,6 +717,10 @@
 
28951
        @: > src/powerpc/$(DEPDIR)/$(am__dirstamp)
 
28952
 src/powerpc/ffi.lo: src/powerpc/$(am__dirstamp) \
 
28953
        src/powerpc/$(DEPDIR)/$(am__dirstamp)
 
28954
+src/powerpc/ffi_sysv.lo: src/powerpc/$(am__dirstamp) \
 
28955
+       src/powerpc/$(DEPDIR)/$(am__dirstamp)
 
28956
+src/powerpc/ffi_linux64.lo: src/powerpc/$(am__dirstamp) \
 
28957
+       src/powerpc/$(DEPDIR)/$(am__dirstamp)
 
28958
 src/powerpc/sysv.lo: src/powerpc/$(am__dirstamp) \
 
28959
        src/powerpc/$(DEPDIR)/$(am__dirstamp)
 
28960
 src/powerpc/ppc_closure.lo: src/powerpc/$(am__dirstamp) \
 
28961
@@ -912,6 +922,10 @@
 
28962
        -rm -f src/powerpc/ffi.lo
 
28963
        -rm -f src/powerpc/ffi_darwin.$(OBJEXT)
 
28964
        -rm -f src/powerpc/ffi_darwin.lo
 
28965
+       -rm -f src/powerpc/ffi_linux64.$(OBJEXT)
 
28966
+       -rm -f src/powerpc/ffi_linux64.lo
 
28967
+       -rm -f src/powerpc/ffi_sysv.$(OBJEXT)
 
28968
+       -rm -f src/powerpc/ffi_sysv.lo
 
28969
        -rm -f src/powerpc/linux64.$(OBJEXT)
 
28970
        -rm -f src/powerpc/linux64.lo
 
28971
        -rm -f src/powerpc/linux64_closure.$(OBJEXT)
 
28972
@@ -1009,6 +1023,8 @@
 
28973
 @AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/darwin_closure.Plo@am__quote@
 
28974
 @AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/ffi.Plo@am__quote@
 
28975
 @AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/ffi_darwin.Plo@am__quote@
 
28976
+@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/ffi_linux64.Plo@am__quote@
 
28977
+@AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/ffi_sysv.Plo@am__quote@
 
28978
 @AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/linux64.Plo@am__quote@
 
28979
 @AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/linux64_closure.Plo@am__quote@
 
28980
 @AMDEP_TRUE@@am__include@ @am__quote@src/powerpc/$(DEPDIR)/ppc_closure.Plo@am__quote@
 
28981
--- a/src/libffi/include/ffi.h.in
 
28982
+++ b/src/libffi/include/ffi.h.in
 
28983
@@ -207,6 +207,11 @@
 
28984
 #endif
 
28985
 } ffi_cif;
 
28986
 
 
28987
+#if HAVE_LONG_DOUBLE_VARIANT
 
28988
+/* Used to adjust size/alignment of ffi types.  */
 
28989
+void ffi_prep_types (ffi_abi abi);
 
28990
+# endif
 
28991
+
 
28992
 /* Used internally, but overridden by some architectures */
 
28993
 ffi_status ffi_prep_cif_core(ffi_cif *cif,
 
28994
                             ffi_abi abi,
 
28995
--- a/src/libffi/include/Makefile.in
 
28996
+++ b/src/libffi/include/Makefile.in
 
28997
@@ -113,6 +113,7 @@
 
28998
 FGREP = @FGREP@
 
28999
 GREP = @GREP@
 
29000
 HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
 
29001
+HAVE_LONG_DOUBLE_VARIANT = @HAVE_LONG_DOUBLE_VARIANT@
 
29002
 INSTALL = @INSTALL@
 
29003
 INSTALL_DATA = @INSTALL_DATA@
 
29004
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 
29005
--- a/src/libffi/fficonfig.h.in
 
29006
+++ b/src/libffi/fficonfig.h.in
 
29007
@@ -73,6 +73,9 @@
 
29008
 /* Define if you have the long double type and it is bigger than a double */
 
29009
 #undef HAVE_LONG_DOUBLE
 
29010
 
 
29011
+/* Define if you support more than one size of the long double type */
 
29012
+#undef HAVE_LONG_DOUBLE_VARIANT
 
29013
+
 
29014
 /* Define to 1 if you have the `memcpy' function. */
 
29015
 #undef HAVE_MEMCPY
 
29016
 
 
29017
--- a/src/libffi/src/powerpc/ppc_closure.S
 
29018
+++ b/src/libffi/src/powerpc/ppc_closure.S
 
29019
@@ -31,7 +31,7 @@
 
29020
 
 
29021
        .file   "ppc_closure.S"
 
29022
 
 
29023
-#ifndef __powerpc64__
 
29024
+#ifndef POWERPC64
 
29025
 
 
29026
 ENTRY(ffi_closure_SYSV)
 
29027
 .LFB1:
 
29028
@@ -238,7 +238,7 @@
 
29029
        lwz %r3,112+0(%r1)
 
29030
        lwz %r4,112+4(%r1)
 
29031
        lwz %r5,112+8(%r1)
 
29032
-       bl .Luint128
 
29033
+       b .Luint128
 
29034
 
 
29035
 # The return types below are only used when the ABI type is FFI_SYSV.
 
29036
 # case FFI_SYSV_TYPE_SMALL_STRUCT + 1. One byte struct.
 
29037
@@ -378,8 +378,7 @@
 
29038
        .align 2
 
29039
 .LEFDE1:
 
29040
 
 
29041
-#endif
 
29042
-
 
29043
 #if defined __ELF__ && defined __linux__
 
29044
        .section        .note.GNU-stack,"",@progbits
 
29045
 #endif
 
29046
+#endif
 
29047
--- a/src/libffi/src/powerpc/ffitarget.h
 
29048
+++ b/src/libffi/src/powerpc/ffitarget.h
 
29049
@@ -60,45 +60,76 @@
 
29050
 typedef enum ffi_abi {
 
29051
   FFI_FIRST_ABI = 0,
 
29052
 
 
29053
-#ifdef POWERPC
 
29054
-  FFI_SYSV,
 
29055
-  FFI_GCC_SYSV,
 
29056
-  FFI_LINUX64,
 
29057
-  FFI_LINUX,
 
29058
-  FFI_LINUX_SOFT_FLOAT,
 
29059
-# if defined(POWERPC64)
 
29060
-  FFI_DEFAULT_ABI = FFI_LINUX64,
 
29061
-# elif defined(__NO_FPRS__)
 
29062
-  FFI_DEFAULT_ABI = FFI_LINUX_SOFT_FLOAT,
 
29063
-# elif (__LDBL_MANT_DIG__ == 106)
 
29064
-  FFI_DEFAULT_ABI = FFI_LINUX,
 
29065
-# else
 
29066
-  FFI_DEFAULT_ABI = FFI_GCC_SYSV,
 
29067
-# endif
 
29068
-#endif
 
29069
-
 
29070
-#ifdef POWERPC_AIX
 
29071
+#if defined (POWERPC_AIX)
 
29072
   FFI_AIX,
 
29073
   FFI_DARWIN,
 
29074
   FFI_DEFAULT_ABI = FFI_AIX,
 
29075
-#endif
 
29076
+  FFI_LAST_ABI
 
29077
 
 
29078
-#ifdef POWERPC_DARWIN
 
29079
+#elif defined (POWERPC_DARWIN)
 
29080
   FFI_AIX,
 
29081
   FFI_DARWIN,
 
29082
   FFI_DEFAULT_ABI = FFI_DARWIN,
 
29083
-#endif
 
29084
+  FFI_LAST_ABI
 
29085
 
 
29086
-#ifdef POWERPC_FREEBSD
 
29087
-  FFI_SYSV,
 
29088
-  FFI_GCC_SYSV,
 
29089
-  FFI_LINUX64,
 
29090
-  FFI_LINUX,
 
29091
-  FFI_LINUX_SOFT_FLOAT,
 
29092
-  FFI_DEFAULT_ABI = FFI_SYSV,
 
29093
+#else
 
29094
+  /* The FFI_COMPAT values are used by old code.  Since libffi may be
 
29095
+     a shared library we have to support old values for backwards
 
29096
+     compatibility.  */
 
29097
+  FFI_COMPAT_SYSV,
 
29098
+  FFI_COMPAT_GCC_SYSV,
 
29099
+  FFI_COMPAT_LINUX64,
 
29100
+  FFI_COMPAT_LINUX,
 
29101
+  FFI_COMPAT_LINUX_SOFT_FLOAT,
 
29102
+
 
29103
+# if defined (POWERPC64)
 
29104
+  /* This bit, always set in new code, must not be set in any of the
 
29105
+     old FFI_COMPAT values that might be used for 64-bit linux.  We
 
29106
+     only need worry about FFI_COMPAT_LINUX64, but to be safe avoid
 
29107
+     all old values.  */
 
29108
+  FFI_LINUX = 8,
 
29109
+  /* This and following bits can reuse FFI_COMPAT values.  */
 
29110
+  FFI_LINUX_STRUCT_ALIGN = 1,
 
29111
+  FFI_LINUX_LONG_DOUBLE_128 = 2,
 
29112
+  FFI_DEFAULT_ABI = (FFI_LINUX
 
29113
+#  ifdef __STRUCT_PARM_ALIGN__
 
29114
+                    | FFI_LINUX_STRUCT_ALIGN
 
29115
+#  endif
 
29116
+#  ifdef __LONG_DOUBLE_128__
 
29117
+                    | FFI_LINUX_LONG_DOUBLE_128
 
29118
+#  endif
 
29119
+                    ),
 
29120
+  FFI_LAST_ABI = 12
 
29121
+
 
29122
+# else
 
29123
+  /* This bit, always set in new code, must not be set in any of the
 
29124
+     old FFI_COMPAT values that might be used for 32-bit linux/sysv/bsd.  */
 
29125
+  FFI_SYSV = 8,
 
29126
+  /* This and following bits can reuse FFI_COMPAT values.  */
 
29127
+  FFI_SYSV_SOFT_FLOAT = 1,
 
29128
+  FFI_SYSV_STRUCT_RET = 2,
 
29129
+  FFI_SYSV_IBM_LONG_DOUBLE = 4,
 
29130
+  FFI_SYSV_LONG_DOUBLE_128 = 16,
 
29131
+
 
29132
+  FFI_DEFAULT_ABI = (FFI_SYSV
 
29133
+#  ifdef __NO_FPRS__
 
29134
+                    | FFI_SYSV_SOFT_FLOAT
 
29135
+#  endif
 
29136
+#  if (defined (__SVR4_STRUCT_RETURN)                                  \
 
29137
+       || defined (POWERPC_FREEBSD) && !defined (__AIX_STRUCT_RETURN))
 
29138
+                    | FFI_SYSV_STRUCT_RET
 
29139
+#  endif
 
29140
+#  if __LDBL_MANT_DIG__ == 106
 
29141
+                    | FFI_SYSV_IBM_LONG_DOUBLE
 
29142
+#  endif
 
29143
+#  ifdef __LONG_DOUBLE_128__
 
29144
+                    | FFI_SYSV_LONG_DOUBLE_128
 
29145
+#  endif
 
29146
+                    ),
 
29147
+  FFI_LAST_ABI = 32
 
29148
+# endif
 
29149
 #endif
 
29150
 
 
29151
-  FFI_LAST_ABI
 
29152
 } ffi_abi;
 
29153
 #endif
 
29154
 
 
29155
@@ -106,6 +137,10 @@
 
29156
 
 
29157
 #define FFI_CLOSURES 1
 
29158
 #define FFI_NATIVE_RAW_API 0
 
29159
+#if defined (POWERPC) || defined (POWERPC_FREEBSD)
 
29160
+# define FFI_TARGET_SPECIFIC_VARIADIC 1
 
29161
+# define FFI_EXTRA_CIF_FIELDS unsigned nfixedargs
 
29162
+#endif
 
29163
 
 
29164
 /* For additional types like the below, take care about the order in
 
29165
    ppc_closures.S. They must follow after the FFI_TYPE_LAST.  */
 
29166
@@ -113,19 +148,26 @@
 
29167
 /* Needed for soft-float long-double-128 support.  */
 
29168
 #define FFI_TYPE_UINT128 (FFI_TYPE_LAST + 1)
 
29169
 
 
29170
-/* Needed for FFI_SYSV small structure returns.
 
29171
-   We use two flag bits, (FLAG_SYSV_SMST_R3, FLAG_SYSV_SMST_R4) which are
 
29172
-   defined in ffi.c, to determine the exact return type and its size.  */
 
29173
+/* Needed for FFI_SYSV small structure returns.  */
 
29174
 #define FFI_SYSV_TYPE_SMALL_STRUCT (FFI_TYPE_LAST + 2)
 
29175
 
 
29176
-#if defined(POWERPC64) || defined(POWERPC_AIX)
 
29177
+/* Used by ELFv2 for homogenous structure returns.  */
 
29178
+#define FFI_V2_TYPE_FLOAT_HOMOG                (FFI_TYPE_LAST + 1)
 
29179
+#define FFI_V2_TYPE_DOUBLE_HOMOG       (FFI_TYPE_LAST + 2)
 
29180
+#define FFI_V2_TYPE_SMALL_STRUCT       (FFI_TYPE_LAST + 3)
 
29181
+
 
29182
+#if _CALL_ELF == 2
 
29183
+# define FFI_TRAMPOLINE_SIZE 32
 
29184
+#else
 
29185
+# if defined(POWERPC64) || defined(POWERPC_AIX)
 
29186
 #  if defined(POWERPC_DARWIN64)
 
29187
 #    define FFI_TRAMPOLINE_SIZE 48
 
29188
 #  else
 
29189
 #    define FFI_TRAMPOLINE_SIZE 24
 
29190
 #  endif
 
29191
-#else /* POWERPC || POWERPC_AIX */
 
29192
+# else /* POWERPC || POWERPC_AIX */
 
29193
 #  define FFI_TRAMPOLINE_SIZE 40
 
29194
+# endif
 
29195
 #endif
 
29196
 
 
29197
 #ifndef LIBFFI_ASM
 
29198
--- a/src/libffi/src/powerpc/ffi.c
 
29199
+++ b/src/libffi/src/powerpc/ffi.c
 
29200
@@ -1,5 +1,6 @@
 
29201
 /* -----------------------------------------------------------------------
 
29202
-   ffi.c - Copyright (C) 2011 Anthony Green
 
29203
+   ffi.c - Copyright (C) 2013 IBM
 
29204
+           Copyright (C) 2011 Anthony Green
 
29205
            Copyright (C) 2011 Kyle Moffett
 
29206
            Copyright (C) 2008 Red Hat, Inc
 
29207
            Copyright (C) 2007, 2008 Free Software Foundation, Inc
 
29208
@@ -27,966 +28,104 @@
 
29209
    OTHER DEALINGS IN THE SOFTWARE.
 
29210
    ----------------------------------------------------------------------- */
 
29211
 
 
29212
-#include <ffi.h>
 
29213
-#include <ffi_common.h>
 
29214
+#include "ffi.h"
 
29215
+#include "ffi_common.h"
 
29216
+#include "ffi_powerpc.h"
 
29217
 
 
29218
-#include <stdlib.h>
 
29219
-#include <stdio.h>
 
29220
-
 
29221
-
 
29222
-extern void ffi_closure_SYSV (void);
 
29223
-extern void FFI_HIDDEN ffi_closure_LINUX64 (void);
 
29224
-
 
29225
-enum {
 
29226
-  /* The assembly depends on these exact flags.  */
 
29227
-  FLAG_RETURNS_SMST    = 1 << (31-31), /* Used for FFI_SYSV small structs.  */
 
29228
-  FLAG_RETURNS_NOTHING  = 1 << (31-30), /* These go in cr7 */
 
29229
-#ifndef __NO_FPRS__
 
29230
-  FLAG_RETURNS_FP       = 1 << (31-29),
 
29231
-#endif
 
29232
-  FLAG_RETURNS_64BITS   = 1 << (31-28),
 
29233
-
 
29234
-  FLAG_RETURNS_128BITS  = 1 << (31-27), /* cr6  */
 
29235
-
 
29236
-  FLAG_ARG_NEEDS_COPY   = 1 << (31- 7),
 
29237
-#ifndef __NO_FPRS__
 
29238
-  FLAG_FP_ARGUMENTS     = 1 << (31- 6), /* cr1.eq; specified by ABI */
 
29239
-#endif
 
29240
-  FLAG_4_GPR_ARGUMENTS  = 1 << (31- 5),
 
29241
-  FLAG_RETVAL_REFERENCE = 1 << (31- 4)
 
29242
-};
 
29243
-
 
29244
-/* About the SYSV ABI.  */
 
29245
-#define ASM_NEEDS_REGISTERS 4
 
29246
-#define NUM_GPR_ARG_REGISTERS 8
 
29247
-#ifndef __NO_FPRS__
 
29248
-# define NUM_FPR_ARG_REGISTERS 8
 
29249
-#endif
 
29250
-
 
29251
-/* ffi_prep_args_SYSV is called by the assembly routine once stack space
 
29252
-   has been allocated for the function's arguments.
 
29253
-
 
29254
-   The stack layout we want looks like this:
 
29255
-
 
29256
-   |   Return address from ffi_call_SYSV 4bytes        |       higher addresses
 
29257
-   |--------------------------------------------|
 
29258
-   |   Previous backchain pointer      4       |       stack pointer here
 
29259
-   |--------------------------------------------|<+ <<<        on entry to
 
29260
-   |   Saved r28-r31                   4*4     | |     ffi_call_SYSV
 
29261
-   |--------------------------------------------| |
 
29262
-   |   GPR registers r3-r10            8*4     | |     ffi_call_SYSV
 
29263
-   |--------------------------------------------| |
 
29264
-   |   FPR registers f1-f8 (optional)  8*8     | |
 
29265
-   |--------------------------------------------| |    stack   |
 
29266
-   |   Space for copied structures             | |     grows   |
 
29267
-   |--------------------------------------------| |    down    V
 
29268
-   |   Parameters that didn't fit in registers  | |
 
29269
-   |--------------------------------------------| |    lower addresses
 
29270
-   |   Space for callee's LR           4       | |
 
29271
-   |--------------------------------------------| |    stack pointer here
 
29272
-   |   Current backchain pointer       4       |-/     during
 
29273
-   |--------------------------------------------|   <<<        ffi_call_SYSV
 
29274
-
 
29275
-*/
 
29276
-
 
29277
-void
 
29278
-ffi_prep_args_SYSV (extended_cif *ecif, unsigned *const stack)
 
29279
+#if HAVE_LONG_DOUBLE_VARIANT
 
29280
+/* Adjust ffi_type_longdouble.  */
 
29281
+void FFI_HIDDEN
 
29282
+ffi_prep_types (ffi_abi abi)
 
29283
 {
 
29284
-  const unsigned bytes = ecif->cif->bytes;
 
29285
-  const unsigned flags = ecif->cif->flags;
 
29286
-
 
29287
-  typedef union {
 
29288
-    char *c;
 
29289
-    unsigned *u;
 
29290
-    long long *ll;
 
29291
-    float *f;
 
29292
-    double *d;
 
29293
-  } valp;
 
29294
-
 
29295
-  /* 'stacktop' points at the previous backchain pointer.  */
 
29296
-  valp stacktop;
 
29297
-
 
29298
-  /* 'gpr_base' points at the space for gpr3, and grows upwards as
 
29299
-     we use GPR registers.  */
 
29300
-  valp gpr_base;
 
29301
-  int intarg_count;
 
29302
-
 
29303
-#ifndef __NO_FPRS__
 
29304
-  /* 'fpr_base' points at the space for fpr1, and grows upwards as
 
29305
-     we use FPR registers.  */
 
29306
-  valp fpr_base;
 
29307
-  int fparg_count;
 
29308
-#endif
 
29309
-
 
29310
-  /* 'copy_space' grows down as we put structures in it.  It should
 
29311
-     stay 16-byte aligned.  */
 
29312
-  valp copy_space;
 
29313
-
 
29314
-  /* 'next_arg' grows up as we put parameters in it.  */
 
29315
-  valp next_arg;
 
29316
-
 
29317
-  int i;
 
29318
-  ffi_type **ptr;
 
29319
-#ifndef __NO_FPRS__
 
29320
-  double double_tmp;
 
29321
-#endif
 
29322
-  union {
 
29323
-    void **v;
 
29324
-    char **c;
 
29325
-    signed char **sc;
 
29326
-    unsigned char **uc;
 
29327
-    signed short **ss;
 
29328
-    unsigned short **us;
 
29329
-    unsigned int **ui;
 
29330
-    long long **ll;
 
29331
-    float **f;
 
29332
-    double **d;
 
29333
-  } p_argv;
 
29334
-  size_t struct_copy_size;
 
29335
-  unsigned gprvalue;
 
29336
-
 
29337
-  stacktop.c = (char *) stack + bytes;
 
29338
-  gpr_base.u = stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS;
 
29339
-  intarg_count = 0;
 
29340
-#ifndef __NO_FPRS__
 
29341
-  fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS;
 
29342
-  fparg_count = 0;
 
29343
-  copy_space.c = ((flags & FLAG_FP_ARGUMENTS) ? fpr_base.c : gpr_base.c);
 
29344
-#else
 
29345
-  copy_space.c = gpr_base.c;
 
29346
-#endif
 
29347
-  next_arg.u = stack + 2;
 
29348
-
 
29349
-  /* Check that everything starts aligned properly.  */
 
29350
-  FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0);
 
29351
-  FFI_ASSERT (((unsigned long) copy_space.c & 0xF) == 0);
 
29352
-  FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0);
 
29353
-  FFI_ASSERT ((bytes & 0xF) == 0);
 
29354
-  FFI_ASSERT (copy_space.c >= next_arg.c);
 
29355
-
 
29356
-  /* Deal with return values that are actually pass-by-reference.  */
 
29357
-  if (flags & FLAG_RETVAL_REFERENCE)
 
29358
-    {
 
29359
-      *gpr_base.u++ = (unsigned long) (char *) ecif->rvalue;
 
29360
-      intarg_count++;
 
29361
-    }
 
29362
-
 
29363
-  /* Now for the arguments.  */
 
29364
-  p_argv.v = ecif->avalue;
 
29365
-  for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
 
29366
-       i > 0;
 
29367
-       i--, ptr++, p_argv.v++)
 
29368
-    {
 
29369
-      unsigned short typenum = (*ptr)->type;
 
29370
-
 
29371
-      /* We may need to handle some values depending on ABI */
 
29372
-      if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT) {
 
29373
-               if (typenum == FFI_TYPE_FLOAT)
 
29374
-                       typenum = FFI_TYPE_UINT32;
 
29375
-               if (typenum == FFI_TYPE_DOUBLE)
 
29376
-                       typenum = FFI_TYPE_UINT64;
 
29377
-               if (typenum == FFI_TYPE_LONGDOUBLE)
 
29378
-                       typenum = FFI_TYPE_UINT128;
 
29379
-      } else if (ecif->cif->abi != FFI_LINUX) {
 
29380
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
29381
-               if (typenum == FFI_TYPE_LONGDOUBLE)
 
29382
-                       typenum = FFI_TYPE_STRUCT;
 
29383
-#endif
 
29384
-      }
 
29385
-
 
29386
-      /* Now test the translated value */
 
29387
-      switch (typenum) {
 
29388
-#ifndef __NO_FPRS__
 
29389
-       case FFI_TYPE_FLOAT:
 
29390
-         /* With FFI_LINUX_SOFT_FLOAT floats are handled like UINT32.  */
 
29391
-         double_tmp = **p_argv.f;
 
29392
-         if (fparg_count >= NUM_FPR_ARG_REGISTERS)
 
29393
-           {
 
29394
-             *next_arg.f = (float) double_tmp;
 
29395
-             next_arg.u += 1;
 
29396
-             intarg_count++;
 
29397
-           }
 
29398
-         else
 
29399
-           *fpr_base.d++ = double_tmp;
 
29400
-         fparg_count++;
 
29401
-         FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
 
29402
-         break;
 
29403
-
 
29404
-       case FFI_TYPE_DOUBLE:
 
29405
-         /* With FFI_LINUX_SOFT_FLOAT doubles are handled like UINT64.  */
 
29406
-         double_tmp = **p_argv.d;
 
29407
-
 
29408
-         if (fparg_count >= NUM_FPR_ARG_REGISTERS)
 
29409
-           {
 
29410
-             if (intarg_count >= NUM_GPR_ARG_REGISTERS
 
29411
-                 && intarg_count % 2 != 0)
 
29412
-               {
 
29413
-                 intarg_count++;
 
29414
-                 next_arg.u++;
 
29415
-               }
 
29416
-             *next_arg.d = double_tmp;
 
29417
-             next_arg.u += 2;
 
29418
-           }
 
29419
-         else
 
29420
-           *fpr_base.d++ = double_tmp;
 
29421
-         fparg_count++;
 
29422
-         FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
 
29423
-         break;
 
29424
-
 
29425
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
29426
-       case FFI_TYPE_LONGDOUBLE:
 
29427
-             double_tmp = (*p_argv.d)[0];
 
29428
-
 
29429
-             if (fparg_count >= NUM_FPR_ARG_REGISTERS - 1)
 
29430
-               {
 
29431
-                 if (intarg_count >= NUM_GPR_ARG_REGISTERS
 
29432
-                     && intarg_count % 2 != 0)
 
29433
-                   {
 
29434
-                     intarg_count++;
 
29435
-                     next_arg.u++;
 
29436
-                   }
 
29437
-                 *next_arg.d = double_tmp;
 
29438
-                 next_arg.u += 2;
 
29439
-                 double_tmp = (*p_argv.d)[1];
 
29440
-                 *next_arg.d = double_tmp;
 
29441
-                 next_arg.u += 2;
 
29442
-               }
 
29443
-             else
 
29444
-               {
 
29445
-                 *fpr_base.d++ = double_tmp;
 
29446
-                 double_tmp = (*p_argv.d)[1];
 
29447
-                 *fpr_base.d++ = double_tmp;
 
29448
-               }
 
29449
-
 
29450
-             fparg_count += 2;
 
29451
-             FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
 
29452
-         break;
 
29453
-#endif
 
29454
-#endif /* have FPRs */
 
29455
-
 
29456
-       /*
 
29457
-        * The soft float ABI for long doubles works like this, a long double
 
29458
-        * is passed in four consecutive GPRs if available.  A maximum of 2
 
29459
-        * long doubles can be passed in gprs.  If we do not have 4 GPRs
 
29460
-        * left, the long double is passed on the stack, 4-byte aligned.
 
29461
-        */
 
29462
-       case FFI_TYPE_UINT128: {
 
29463
-               unsigned int int_tmp = (*p_argv.ui)[0];
 
29464
-               unsigned int ii;
 
29465
-               if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3) {
 
29466
-                       if (intarg_count < NUM_GPR_ARG_REGISTERS)
 
29467
-                               intarg_count += NUM_GPR_ARG_REGISTERS - intarg_count;
 
29468
-                       *(next_arg.u++) = int_tmp;
 
29469
-                       for (ii = 1; ii < 4; ii++) {
 
29470
-                               int_tmp = (*p_argv.ui)[ii];
 
29471
-                               *(next_arg.u++) = int_tmp;
 
29472
-                       }
 
29473
-               } else {
 
29474
-                       *(gpr_base.u++) = int_tmp;
 
29475
-                       for (ii = 1; ii < 4; ii++) {
 
29476
-                               int_tmp = (*p_argv.ui)[ii];
 
29477
-                               *(gpr_base.u++) = int_tmp;
 
29478
-                       }
 
29479
-               }
 
29480
-               intarg_count += 4;
 
29481
-               break;
 
29482
-       }
 
29483
-
 
29484
-       case FFI_TYPE_UINT64:
 
29485
-       case FFI_TYPE_SINT64:
 
29486
-         if (intarg_count == NUM_GPR_ARG_REGISTERS-1)
 
29487
-           intarg_count++;
 
29488
-         if (intarg_count >= NUM_GPR_ARG_REGISTERS)
 
29489
-           {
 
29490
-             if (intarg_count % 2 != 0)
 
29491
-               {
 
29492
-                 intarg_count++;
 
29493
-                 next_arg.u++;
 
29494
-               }
 
29495
-             *next_arg.ll = **p_argv.ll;
 
29496
-             next_arg.u += 2;
 
29497
-           }
 
29498
-         else
 
29499
-           {
 
29500
-             /* whoops: abi states only certain register pairs
 
29501
-              * can be used for passing long long int
 
29502
-              * specifically (r3,r4), (r5,r6), (r7,r8),
 
29503
-              * (r9,r10) and if next arg is long long but
 
29504
-              * not correct starting register of pair then skip
 
29505
-              * until the proper starting register
 
29506
-              */
 
29507
-             if (intarg_count % 2 != 0)
 
29508
-               {
 
29509
-                 intarg_count ++;
 
29510
-                 gpr_base.u++;
 
29511
-               }
 
29512
-             *gpr_base.ll++ = **p_argv.ll;
 
29513
-           }
 
29514
-         intarg_count += 2;
 
29515
-         break;
 
29516
-
 
29517
-       case FFI_TYPE_STRUCT:
 
29518
-         struct_copy_size = ((*ptr)->size + 15) & ~0xF;
 
29519
-         copy_space.c -= struct_copy_size;
 
29520
-         memcpy (copy_space.c, *p_argv.c, (*ptr)->size);
 
29521
-
 
29522
-         gprvalue = (unsigned long) copy_space.c;
 
29523
-
 
29524
-         FFI_ASSERT (copy_space.c > next_arg.c);
 
29525
-         FFI_ASSERT (flags & FLAG_ARG_NEEDS_COPY);
 
29526
-         goto putgpr;
 
29527
-
 
29528
-       case FFI_TYPE_UINT8:
 
29529
-         gprvalue = **p_argv.uc;
 
29530
-         goto putgpr;
 
29531
-       case FFI_TYPE_SINT8:
 
29532
-         gprvalue = **p_argv.sc;
 
29533
-         goto putgpr;
 
29534
-       case FFI_TYPE_UINT16:
 
29535
-         gprvalue = **p_argv.us;
 
29536
-         goto putgpr;
 
29537
-       case FFI_TYPE_SINT16:
 
29538
-         gprvalue = **p_argv.ss;
 
29539
-         goto putgpr;
 
29540
-
 
29541
-       case FFI_TYPE_INT:
 
29542
-       case FFI_TYPE_UINT32:
 
29543
-       case FFI_TYPE_SINT32:
 
29544
-       case FFI_TYPE_POINTER:
 
29545
-
 
29546
-         gprvalue = **p_argv.ui;
 
29547
-
 
29548
-       putgpr:
 
29549
-         if (intarg_count >= NUM_GPR_ARG_REGISTERS)
 
29550
-           *next_arg.u++ = gprvalue;
 
29551
-         else
 
29552
-           *gpr_base.u++ = gprvalue;
 
29553
-         intarg_count++;
 
29554
-         break;
 
29555
-       }
 
29556
-    }
 
29557
-
 
29558
-  /* Check that we didn't overrun the stack...  */
 
29559
-  FFI_ASSERT (copy_space.c >= next_arg.c);
 
29560
-  FFI_ASSERT (gpr_base.u <= stacktop.u - ASM_NEEDS_REGISTERS);
 
29561
-#ifndef __NO_FPRS__
 
29562
-  FFI_ASSERT (fpr_base.u
 
29563
-             <= stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS);
 
29564
-#endif
 
29565
-  FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4);
 
29566
+# if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
29567
+#  ifdef POWERPC64
 
29568
+  ffi_prep_types_linux64 (abi);
 
29569
+#  else
 
29570
+  ffi_prep_types_sysv (abi);
 
29571
+#  endif
 
29572
+# endif
 
29573
 }
 
29574
-
 
29575
-/* About the LINUX64 ABI.  */
 
29576
-enum {
 
29577
-  NUM_GPR_ARG_REGISTERS64 = 8,
 
29578
-  NUM_FPR_ARG_REGISTERS64 = 13
 
29579
-};
 
29580
-enum { ASM_NEEDS_REGISTERS64 = 4 };
 
29581
-
 
29582
-/* ffi_prep_args64 is called by the assembly routine once stack space
 
29583
-   has been allocated for the function's arguments.
 
29584
-
 
29585
-   The stack layout we want looks like this:
 
29586
-
 
29587
-   |   Ret addr from ffi_call_LINUX64  8bytes  |       higher addresses
 
29588
-   |--------------------------------------------|
 
29589
-   |   CR save area                    8bytes  |
 
29590
-   |--------------------------------------------|
 
29591
-   |   Previous backchain pointer      8       |       stack pointer here
 
29592
-   |--------------------------------------------|<+ <<<        on entry to
 
29593
-   |   Saved r28-r31                   4*8     | |     ffi_call_LINUX64
 
29594
-   |--------------------------------------------| |
 
29595
-   |   GPR registers r3-r10            8*8     | |
 
29596
-   |--------------------------------------------| |
 
29597
-   |   FPR registers f1-f13 (optional) 13*8    | |
 
29598
-   |--------------------------------------------| |
 
29599
-   |   Parameter save area                     | |
 
29600
-   |--------------------------------------------| |
 
29601
-   |   TOC save area                   8       | |
 
29602
-   |--------------------------------------------| |    stack   |
 
29603
-   |   Linker doubleword               8       | |     grows   |
 
29604
-   |--------------------------------------------| |    down    V
 
29605
-   |   Compiler doubleword             8       | |
 
29606
-   |--------------------------------------------| |    lower addresses
 
29607
-   |   Space for callee's LR           8       | |
 
29608
-   |--------------------------------------------| |
 
29609
-   |   CR save area                    8       | |
 
29610
-   |--------------------------------------------| |    stack pointer here
 
29611
-   |   Current backchain pointer       8       |-/     during
 
29612
-   |--------------------------------------------|   <<<        ffi_call_LINUX64
 
29613
-
 
29614
-*/
 
29615
-
 
29616
-void FFI_HIDDEN
 
29617
-ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
 
29618
-{
 
29619
-  const unsigned long bytes = ecif->cif->bytes;
 
29620
-  const unsigned long flags = ecif->cif->flags;
 
29621
-
 
29622
-  typedef union {
 
29623
-    char *c;
 
29624
-    unsigned long *ul;
 
29625
-    float *f;
 
29626
-    double *d;
 
29627
-  } valp;
 
29628
-
 
29629
-  /* 'stacktop' points at the previous backchain pointer.  */
 
29630
-  valp stacktop;
 
29631
-
 
29632
-  /* 'next_arg' points at the space for gpr3, and grows upwards as
 
29633
-     we use GPR registers, then continues at rest.  */
 
29634
-  valp gpr_base;
 
29635
-  valp gpr_end;
 
29636
-  valp rest;
 
29637
-  valp next_arg;
 
29638
-
 
29639
-  /* 'fpr_base' points at the space for fpr3, and grows upwards as
 
29640
-     we use FPR registers.  */
 
29641
-  valp fpr_base;
 
29642
-  int fparg_count;
 
29643
-
 
29644
-  int i, words;
 
29645
-  ffi_type **ptr;
 
29646
-  double double_tmp;
 
29647
-  union {
 
29648
-    void **v;
 
29649
-    char **c;
 
29650
-    signed char **sc;
 
29651
-    unsigned char **uc;
 
29652
-    signed short **ss;
 
29653
-    unsigned short **us;
 
29654
-    signed int **si;
 
29655
-    unsigned int **ui;
 
29656
-    unsigned long **ul;
 
29657
-    float **f;
 
29658
-    double **d;
 
29659
-  } p_argv;
 
29660
-  unsigned long gprvalue;
 
29661
-
 
29662
-  stacktop.c = (char *) stack + bytes;
 
29663
-  gpr_base.ul = stacktop.ul - ASM_NEEDS_REGISTERS64 - NUM_GPR_ARG_REGISTERS64;
 
29664
-  gpr_end.ul = gpr_base.ul + NUM_GPR_ARG_REGISTERS64;
 
29665
-  rest.ul = stack + 6 + NUM_GPR_ARG_REGISTERS64;
 
29666
-  fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS64;
 
29667
-  fparg_count = 0;
 
29668
-  next_arg.ul = gpr_base.ul;
 
29669
-
 
29670
-  /* Check that everything starts aligned properly.  */
 
29671
-  FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0);
 
29672
-  FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0);
 
29673
-  FFI_ASSERT ((bytes & 0xF) == 0);
 
29674
-
 
29675
-  /* Deal with return values that are actually pass-by-reference.  */
 
29676
-  if (flags & FLAG_RETVAL_REFERENCE)
 
29677
-    *next_arg.ul++ = (unsigned long) (char *) ecif->rvalue;
 
29678
-
 
29679
-  /* Now for the arguments.  */
 
29680
-  p_argv.v = ecif->avalue;
 
29681
-  for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
 
29682
-       i > 0;
 
29683
-       i--, ptr++, p_argv.v++)
 
29684
-    {
 
29685
-      switch ((*ptr)->type)
 
29686
-       {
 
29687
-       case FFI_TYPE_FLOAT:
 
29688
-         double_tmp = **p_argv.f;
 
29689
-         *next_arg.f = (float) double_tmp;
 
29690
-         if (++next_arg.ul == gpr_end.ul)
 
29691
-           next_arg.ul = rest.ul;
 
29692
-         if (fparg_count < NUM_FPR_ARG_REGISTERS64)
 
29693
-           *fpr_base.d++ = double_tmp;
 
29694
-         fparg_count++;
 
29695
-         FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
 
29696
-         break;
 
29697
-
 
29698
-       case FFI_TYPE_DOUBLE:
 
29699
-         double_tmp = **p_argv.d;
 
29700
-         *next_arg.d = double_tmp;
 
29701
-         if (++next_arg.ul == gpr_end.ul)
 
29702
-           next_arg.ul = rest.ul;
 
29703
-         if (fparg_count < NUM_FPR_ARG_REGISTERS64)
 
29704
-           *fpr_base.d++ = double_tmp;
 
29705
-         fparg_count++;
 
29706
-         FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
 
29707
-         break;
 
29708
-
 
29709
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
29710
-       case FFI_TYPE_LONGDOUBLE:
 
29711
-         double_tmp = (*p_argv.d)[0];
 
29712
-         *next_arg.d = double_tmp;
 
29713
-         if (++next_arg.ul == gpr_end.ul)
 
29714
-           next_arg.ul = rest.ul;
 
29715
-         if (fparg_count < NUM_FPR_ARG_REGISTERS64)
 
29716
-           *fpr_base.d++ = double_tmp;
 
29717
-         fparg_count++;
 
29718
-         double_tmp = (*p_argv.d)[1];
 
29719
-         *next_arg.d = double_tmp;
 
29720
-         if (++next_arg.ul == gpr_end.ul)
 
29721
-           next_arg.ul = rest.ul;
 
29722
-         if (fparg_count < NUM_FPR_ARG_REGISTERS64)
 
29723
-           *fpr_base.d++ = double_tmp;
 
29724
-         fparg_count++;
 
29725
-         FFI_ASSERT (__LDBL_MANT_DIG__ == 106);
 
29726
-         FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
 
29727
-         break;
 
29728
 #endif
 
29729
 
 
29730
-       case FFI_TYPE_STRUCT:
 
29731
-         words = ((*ptr)->size + 7) / 8;
 
29732
-         if (next_arg.ul >= gpr_base.ul && next_arg.ul + words > gpr_end.ul)
 
29733
-           {
 
29734
-             size_t first = gpr_end.c - next_arg.c;
 
29735
-             memcpy (next_arg.c, *p_argv.c, first);
 
29736
-             memcpy (rest.c, *p_argv.c + first, (*ptr)->size - first);
 
29737
-             next_arg.c = rest.c + words * 8 - first;
 
29738
-           }
 
29739
-         else
 
29740
-           {
 
29741
-             char *where = next_arg.c;
 
29742
-
 
29743
-#ifndef __LITTLE_ENDIAN__
 
29744
-             /* Structures with size less than eight bytes are passed
 
29745
-                left-padded.  */
 
29746
-             if ((*ptr)->size < 8)
 
29747
-               where += 8 - (*ptr)->size;
 
29748
-#endif
 
29749
-             memcpy (where, *p_argv.c, (*ptr)->size);
 
29750
-             next_arg.ul += words;
 
29751
-             if (next_arg.ul == gpr_end.ul)
 
29752
-               next_arg.ul = rest.ul;
 
29753
-           }
 
29754
-         break;
 
29755
-
 
29756
-       case FFI_TYPE_UINT8:
 
29757
-         gprvalue = **p_argv.uc;
 
29758
-         goto putgpr;
 
29759
-       case FFI_TYPE_SINT8:
 
29760
-         gprvalue = **p_argv.sc;
 
29761
-         goto putgpr;
 
29762
-       case FFI_TYPE_UINT16:
 
29763
-         gprvalue = **p_argv.us;
 
29764
-         goto putgpr;
 
29765
-       case FFI_TYPE_SINT16:
 
29766
-         gprvalue = **p_argv.ss;
 
29767
-         goto putgpr;
 
29768
-       case FFI_TYPE_UINT32:
 
29769
-         gprvalue = **p_argv.ui;
 
29770
-         goto putgpr;
 
29771
-       case FFI_TYPE_INT:
 
29772
-       case FFI_TYPE_SINT32:
 
29773
-         gprvalue = **p_argv.si;
 
29774
-         goto putgpr;
 
29775
-
 
29776
-       case FFI_TYPE_UINT64:
 
29777
-       case FFI_TYPE_SINT64:
 
29778
-       case FFI_TYPE_POINTER:
 
29779
-         gprvalue = **p_argv.ul;
 
29780
-       putgpr:
 
29781
-         *next_arg.ul++ = gprvalue;
 
29782
-         if (next_arg.ul == gpr_end.ul)
 
29783
-           next_arg.ul = rest.ul;
 
29784
-         break;
 
29785
-       }
 
29786
-    }
 
29787
-
 
29788
-  FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS
 
29789
-             || (next_arg.ul >= gpr_base.ul
 
29790
-                 && next_arg.ul <= gpr_base.ul + 4));
 
29791
-}
 
29792
-
 
29793
-
 
29794
-
 
29795
 /* Perform machine dependent cif processing */
 
29796
-ffi_status
 
29797
+ffi_status FFI_HIDDEN
 
29798
 ffi_prep_cif_machdep (ffi_cif *cif)
 
29799
 {
 
29800
-  /* All this is for the SYSV and LINUX64 ABI.  */
 
29801
-  int i;
 
29802
-  ffi_type **ptr;
 
29803
-  unsigned bytes;
 
29804
-  int fparg_count = 0, intarg_count = 0;
 
29805
-  unsigned flags = 0;
 
29806
-  unsigned struct_copy_size = 0;
 
29807
-  unsigned type = cif->rtype->type;
 
29808
-  unsigned size = cif->rtype->size;
 
29809
-
 
29810
-  if (cif->abi != FFI_LINUX64)
 
29811
-    {
 
29812
-      /* All the machine-independent calculation of cif->bytes will be wrong.
 
29813
-        Redo the calculation for SYSV.  */
 
29814
-
 
29815
-      /* Space for the frame pointer, callee's LR, and the asm's temp regs.  */
 
29816
-      bytes = (2 + ASM_NEEDS_REGISTERS) * sizeof (int);
 
29817
-
 
29818
-      /* Space for the GPR registers.  */
 
29819
-      bytes += NUM_GPR_ARG_REGISTERS * sizeof (int);
 
29820
-    }
 
29821
-  else
 
29822
-    {
 
29823
-      /* 64-bit ABI.  */
 
29824
-
 
29825
-      /* Space for backchain, CR, LR, cc/ld doubleword, TOC and the asm's temp
 
29826
-        regs.  */
 
29827
-      bytes = (6 + ASM_NEEDS_REGISTERS64) * sizeof (long);
 
29828
-
 
29829
-      /* Space for the mandatory parm save area and general registers.  */
 
29830
-      bytes += 2 * NUM_GPR_ARG_REGISTERS64 * sizeof (long);
 
29831
-    }
 
29832
-
 
29833
-  /* Return value handling.  The rules for SYSV are as follows:
 
29834
-     - 32-bit (or less) integer values are returned in gpr3;
 
29835
-     - Structures of size <= 4 bytes also returned in gpr3;
 
29836
-     - 64-bit integer values and structures between 5 and 8 bytes are returned
 
29837
-     in gpr3 and gpr4;
 
29838
-     - Single/double FP values are returned in fpr1;
 
29839
-     - Larger structures are allocated space and a pointer is passed as
 
29840
-     the first argument.
 
29841
-     - long doubles (if not equivalent to double) are returned in
 
29842
-     fpr1,fpr2 for Linux and as for large structs for SysV.
 
29843
-     For LINUX64:
 
29844
-     - integer values in gpr3;
 
29845
-     - Structures/Unions by reference;
 
29846
-     - Single/double FP values in fpr1, long double in fpr1,fpr2.
 
29847
-     - soft-float float/doubles are treated as UINT32/UINT64 respectivley.
 
29848
-     - soft-float long doubles are returned in gpr3-gpr6.  */
 
29849
-  /* First translate for softfloat/nonlinux */
 
29850
-  if (cif->abi == FFI_LINUX_SOFT_FLOAT) {
 
29851
-       if (type == FFI_TYPE_FLOAT)
 
29852
-               type = FFI_TYPE_UINT32;
 
29853
-       if (type == FFI_TYPE_DOUBLE)
 
29854
-               type = FFI_TYPE_UINT64;
 
29855
-       if (type == FFI_TYPE_LONGDOUBLE)
 
29856
-               type = FFI_TYPE_UINT128;
 
29857
-  } else if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX64) {
 
29858
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
29859
-       if (type == FFI_TYPE_LONGDOUBLE)
 
29860
-               type = FFI_TYPE_STRUCT;
 
29861
+#ifdef POWERPC64
 
29862
+  return ffi_prep_cif_linux64 (cif);
 
29863
+#else
 
29864
+  return ffi_prep_cif_sysv (cif);
 
29865
 #endif
 
29866
-  }
 
29867
+}
 
29868
 
 
29869
-  switch (type)
 
29870
-    {
 
29871
-#ifndef __NO_FPRS__
 
29872
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
29873
-    case FFI_TYPE_LONGDOUBLE:
 
29874
-      flags |= FLAG_RETURNS_128BITS;
 
29875
-      /* Fall through.  */
 
29876
+ffi_status FFI_HIDDEN
 
29877
+ffi_prep_cif_machdep_var (ffi_cif *cif,
 
29878
+                         unsigned int nfixedargs MAYBE_UNUSED,
 
29879
+                         unsigned int ntotalargs MAYBE_UNUSED)
 
29880
+{
 
29881
+#ifdef POWERPC64
 
29882
+  return ffi_prep_cif_linux64_var (cif, nfixedargs, ntotalargs);
 
29883
+#else
 
29884
+  return ffi_prep_cif_sysv (cif);
 
29885
 #endif
 
29886
-    case FFI_TYPE_DOUBLE:
 
29887
-      flags |= FLAG_RETURNS_64BITS;
 
29888
-      /* Fall through.  */
 
29889
-    case FFI_TYPE_FLOAT:
 
29890
-      flags |= FLAG_RETURNS_FP;
 
29891
-      break;
 
29892
-#endif
 
29893
-
 
29894
-    case FFI_TYPE_UINT128:
 
29895
-      flags |= FLAG_RETURNS_128BITS;
 
29896
-      /* Fall through.  */
 
29897
-    case FFI_TYPE_UINT64:
 
29898
-    case FFI_TYPE_SINT64:
 
29899
-      flags |= FLAG_RETURNS_64BITS;
 
29900
-      break;
 
29901
-
 
29902
-    case FFI_TYPE_STRUCT:
 
29903
-      /*
 
29904
-       * The final SYSV ABI says that structures smaller or equal 8 bytes
 
29905
-       * are returned in r3/r4. The FFI_GCC_SYSV ABI instead returns them
 
29906
-       * in memory.
 
29907
-       *
 
29908
-       * NOTE: The assembly code can safely assume that it just needs to
 
29909
-       *       store both r3 and r4 into a 8-byte word-aligned buffer, as
 
29910
-       *       we allocate a temporary buffer in ffi_call() if this flag is
 
29911
-       *       set.
 
29912
-       */
 
29913
-      if (cif->abi == FFI_SYSV && size <= 8)
 
29914
-       flags |= FLAG_RETURNS_SMST;
 
29915
-      intarg_count++;
 
29916
-      flags |= FLAG_RETVAL_REFERENCE;
 
29917
-      /* Fall through.  */
 
29918
-    case FFI_TYPE_VOID:
 
29919
-      flags |= FLAG_RETURNS_NOTHING;
 
29920
-      break;
 
29921
-
 
29922
-    default:
 
29923
-      /* Returns 32-bit integer, or similar.  Nothing to do here.  */
 
29924
-      break;
 
29925
-    }
 
29926
-
 
29927
-  if (cif->abi != FFI_LINUX64)
 
29928
-    /* The first NUM_GPR_ARG_REGISTERS words of integer arguments, and the
 
29929
-       first NUM_FPR_ARG_REGISTERS fp arguments, go in registers; the rest
 
29930
-       goes on the stack.  Structures and long doubles (if not equivalent
 
29931
-       to double) are passed as a pointer to a copy of the structure.
 
29932
-       Stuff on the stack needs to keep proper alignment.  */
 
29933
-    for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
 
29934
-      {
 
29935
-       unsigned short typenum = (*ptr)->type;
 
29936
-
 
29937
-       /* We may need to handle some values depending on ABI */
 
29938
-       if (cif->abi == FFI_LINUX_SOFT_FLOAT) {
 
29939
-               if (typenum == FFI_TYPE_FLOAT)
 
29940
-                       typenum = FFI_TYPE_UINT32;
 
29941
-               if (typenum == FFI_TYPE_DOUBLE)
 
29942
-                       typenum = FFI_TYPE_UINT64;
 
29943
-               if (typenum == FFI_TYPE_LONGDOUBLE)
 
29944
-                       typenum = FFI_TYPE_UINT128;
 
29945
-       } else if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX64) {
 
29946
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
29947
-               if (typenum == FFI_TYPE_LONGDOUBLE)
 
29948
-                       typenum = FFI_TYPE_STRUCT;
 
29949
-#endif
 
29950
-       }
 
29951
-
 
29952
-       switch (typenum) {
 
29953
-#ifndef __NO_FPRS__
 
29954
-         case FFI_TYPE_FLOAT:
 
29955
-           fparg_count++;
 
29956
-           /* floating singles are not 8-aligned on stack */
 
29957
-           break;
 
29958
-
 
29959
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
29960
-         case FFI_TYPE_LONGDOUBLE:
 
29961
-           fparg_count++;
 
29962
-           /* Fall thru */
 
29963
-#endif
 
29964
-         case FFI_TYPE_DOUBLE:
 
29965
-           fparg_count++;
 
29966
-           /* If this FP arg is going on the stack, it must be
 
29967
-              8-byte-aligned.  */
 
29968
-           if (fparg_count > NUM_FPR_ARG_REGISTERS
 
29969
-               && intarg_count >= NUM_GPR_ARG_REGISTERS
 
29970
-               && intarg_count % 2 != 0)
 
29971
-             intarg_count++;
 
29972
-           break;
 
29973
-#endif
 
29974
-         case FFI_TYPE_UINT128:
 
29975
-               /*
 
29976
-                * A long double in FFI_LINUX_SOFT_FLOAT can use only a set
 
29977
-                * of four consecutive gprs. If we do not have enough, we
 
29978
-                * have to adjust the intarg_count value.
 
29979
-                */
 
29980
-               if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3
 
29981
-                               && intarg_count < NUM_GPR_ARG_REGISTERS)
 
29982
-                       intarg_count = NUM_GPR_ARG_REGISTERS;
 
29983
-               intarg_count += 4;
 
29984
-               break;
 
29985
-
 
29986
-         case FFI_TYPE_UINT64:
 
29987
-         case FFI_TYPE_SINT64:
 
29988
-           /* 'long long' arguments are passed as two words, but
 
29989
-              either both words must fit in registers or both go
 
29990
-              on the stack.  If they go on the stack, they must
 
29991
-              be 8-byte-aligned.
 
29992
-
 
29993
-              Also, only certain register pairs can be used for
 
29994
-              passing long long int -- specifically (r3,r4), (r5,r6),
 
29995
-              (r7,r8), (r9,r10).
 
29996
-           */
 
29997
-           if (intarg_count == NUM_GPR_ARG_REGISTERS-1
 
29998
-               || intarg_count % 2 != 0)
 
29999
-             intarg_count++;
 
30000
-           intarg_count += 2;
 
30001
-           break;
 
30002
-
 
30003
-         case FFI_TYPE_STRUCT:
 
30004
-           /* We must allocate space for a copy of these to enforce
 
30005
-              pass-by-value.  Pad the space up to a multiple of 16
 
30006
-              bytes (the maximum alignment required for anything under
 
30007
-              the SYSV ABI).  */
 
30008
-           struct_copy_size += ((*ptr)->size + 15) & ~0xF;
 
30009
-           /* Fall through (allocate space for the pointer).  */
 
30010
-
 
30011
-         case FFI_TYPE_POINTER:
 
30012
-         case FFI_TYPE_INT:
 
30013
-         case FFI_TYPE_UINT32:
 
30014
-         case FFI_TYPE_SINT32:
 
30015
-         case FFI_TYPE_UINT16:
 
30016
-         case FFI_TYPE_SINT16:
 
30017
-         case FFI_TYPE_UINT8:
 
30018
-         case FFI_TYPE_SINT8:
 
30019
-           /* Everything else is passed as a 4-byte word in a GPR, either
 
30020
-              the object itself or a pointer to it.  */
 
30021
-           intarg_count++;
 
30022
-           break;
 
30023
-         default:
 
30024
-               FFI_ASSERT (0);
 
30025
-         }
 
30026
-      }
 
30027
-  else
 
30028
-    for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
 
30029
-      {
 
30030
-       switch ((*ptr)->type)
 
30031
-         {
 
30032
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
30033
-         case FFI_TYPE_LONGDOUBLE:
 
30034
-           if (cif->abi == FFI_LINUX_SOFT_FLOAT)
 
30035
-             intarg_count += 4;
 
30036
-           else
 
30037
-             {
 
30038
-               fparg_count += 2;
 
30039
-               intarg_count += 2;
 
30040
-             }
 
30041
-           break;
 
30042
-#endif
 
30043
-         case FFI_TYPE_FLOAT:
 
30044
-         case FFI_TYPE_DOUBLE:
 
30045
-           fparg_count++;
 
30046
-           intarg_count++;
 
30047
-           break;
 
30048
-
 
30049
-         case FFI_TYPE_STRUCT:
 
30050
-           intarg_count += ((*ptr)->size + 7) / 8;
 
30051
-           break;
 
30052
-
 
30053
-         case FFI_TYPE_POINTER:
 
30054
-         case FFI_TYPE_UINT64:
 
30055
-         case FFI_TYPE_SINT64:
 
30056
-         case FFI_TYPE_INT:
 
30057
-         case FFI_TYPE_UINT32:
 
30058
-         case FFI_TYPE_SINT32:
 
30059
-         case FFI_TYPE_UINT16:
 
30060
-         case FFI_TYPE_SINT16:
 
30061
-         case FFI_TYPE_UINT8:
 
30062
-         case FFI_TYPE_SINT8:
 
30063
-           /* Everything else is passed as a 8-byte word in a GPR, either
 
30064
-              the object itself or a pointer to it.  */
 
30065
-           intarg_count++;
 
30066
-           break;
 
30067
-         default:
 
30068
-               FFI_ASSERT (0);
 
30069
-         }
 
30070
-      }
 
30071
-
 
30072
-#ifndef __NO_FPRS__
 
30073
-  if (fparg_count != 0)
 
30074
-    flags |= FLAG_FP_ARGUMENTS;
 
30075
-#endif
 
30076
-  if (intarg_count > 4)
 
30077
-    flags |= FLAG_4_GPR_ARGUMENTS;
 
30078
-  if (struct_copy_size != 0)
 
30079
-    flags |= FLAG_ARG_NEEDS_COPY;
 
30080
-
 
30081
-  if (cif->abi != FFI_LINUX64)
 
30082
-    {
 
30083
-#ifndef __NO_FPRS__
 
30084
-      /* Space for the FPR registers, if needed.  */
 
30085
-      if (fparg_count != 0)
 
30086
-       bytes += NUM_FPR_ARG_REGISTERS * sizeof (double);
 
30087
-#endif
 
30088
-
 
30089
-      /* Stack space.  */
 
30090
-      if (intarg_count > NUM_GPR_ARG_REGISTERS)
 
30091
-       bytes += (intarg_count - NUM_GPR_ARG_REGISTERS) * sizeof (int);
 
30092
-#ifndef __NO_FPRS__
 
30093
-      if (fparg_count > NUM_FPR_ARG_REGISTERS)
 
30094
-       bytes += (fparg_count - NUM_FPR_ARG_REGISTERS) * sizeof (double);
 
30095
-#endif
 
30096
-    }
 
30097
-  else
 
30098
-    {
 
30099
-#ifndef __NO_FPRS__
 
30100
-      /* Space for the FPR registers, if needed.  */
 
30101
-      if (fparg_count != 0)
 
30102
-       bytes += NUM_FPR_ARG_REGISTERS64 * sizeof (double);
 
30103
-#endif
 
30104
-
 
30105
-      /* Stack space.  */
 
30106
-      if (intarg_count > NUM_GPR_ARG_REGISTERS64)
 
30107
-       bytes += (intarg_count - NUM_GPR_ARG_REGISTERS64) * sizeof (long);
 
30108
-    }
 
30109
-
 
30110
-  /* The stack space allocated needs to be a multiple of 16 bytes.  */
 
30111
-  bytes = (bytes + 15) & ~0xF;
 
30112
-
 
30113
-  /* Add in the space for the copied structures.  */
 
30114
-  bytes += struct_copy_size;
 
30115
-
 
30116
-  cif->flags = flags;
 
30117
-  cif->bytes = bytes;
 
30118
-
 
30119
-  return FFI_OK;
 
30120
 }
 
30121
 
 
30122
-extern void ffi_call_SYSV(extended_cif *, unsigned, unsigned, unsigned *,
 
30123
-                         void (*fn)(void));
 
30124
-extern void FFI_HIDDEN ffi_call_LINUX64(extended_cif *, unsigned long,
 
30125
-                                       unsigned long, unsigned long *,
 
30126
-                                       void (*fn)(void));
 
30127
-
 
30128
 void
 
30129
 ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
 
30130
 {
 
30131
-  /*
 
30132
-   * The final SYSV ABI says that structures smaller or equal 8 bytes
 
30133
-   * are returned in r3/r4. The FFI_GCC_SYSV ABI instead returns them
 
30134
-   * in memory.
 
30135
-   *
 
30136
-   * Just to keep things simple for the assembly code, we will always
 
30137
-   * bounce-buffer struct return values less than or equal to 8 bytes.
 
30138
-   * This allows the ASM to handle SYSV small structures by directly
 
30139
-   * writing r3 and r4 to memory without worrying about struct size.
 
30140
-   */
 
30141
-  unsigned int smst_buffer[2];
 
30142
+  /* The final SYSV ABI says that structures smaller or equal 8 bytes
 
30143
+     are returned in r3/r4.  A draft ABI used by linux instead returns
 
30144
+     them in memory.
 
30145
+
 
30146
+     We bounce-buffer SYSV small struct return values so that sysv.S
 
30147
+     can write r3 and r4 to memory without worrying about struct size.
 
30148
+   
 
30149
+     For ELFv2 ABI, use a bounce buffer for homogeneous structs too,
 
30150
+     for similar reasons.  */
 
30151
+  unsigned long smst_buffer[8];
 
30152
   extended_cif ecif;
 
30153
-  unsigned int rsize = 0;
 
30154
 
 
30155
   ecif.cif = cif;
 
30156
   ecif.avalue = avalue;
 
30157
 
 
30158
-  /* Ensure that we have a valid struct return value */
 
30159
   ecif.rvalue = rvalue;
 
30160
-  if (cif->rtype->type == FFI_TYPE_STRUCT) {
 
30161
-    rsize = cif->rtype->size;
 
30162
-    if (rsize <= 8)
 
30163
-      ecif.rvalue = smst_buffer;
 
30164
-    else if (!rvalue)
 
30165
-      ecif.rvalue = alloca(rsize);
 
30166
-  }
 
30167
+  if ((cif->flags & FLAG_RETURNS_SMST) != 0)
 
30168
+    ecif.rvalue = smst_buffer;
 
30169
+  /* Ensure that we have a valid struct return value.
 
30170
+     FIXME: Isn't this just papering over a user problem?  */
 
30171
+  else if (!rvalue && cif->rtype->type == FFI_TYPE_STRUCT)
 
30172
+    ecif.rvalue = alloca (cif->rtype->size);
 
30173
 
 
30174
-  switch (cif->abi)
 
30175
-    {
 
30176
-#ifndef POWERPC64
 
30177
-# ifndef __NO_FPRS__
 
30178
-    case FFI_SYSV:
 
30179
-    case FFI_GCC_SYSV:
 
30180
-    case FFI_LINUX:
 
30181
-# endif
 
30182
-    case FFI_LINUX_SOFT_FLOAT:
 
30183
-      ffi_call_SYSV (&ecif, -cif->bytes, cif->flags, ecif.rvalue, fn);
 
30184
-      break;
 
30185
+#ifdef POWERPC64
 
30186
+  ffi_call_LINUX64 (&ecif, -(long) cif->bytes, cif->flags, ecif.rvalue, fn);
 
30187
 #else
 
30188
-    case FFI_LINUX64:
 
30189
-      ffi_call_LINUX64 (&ecif, -(long) cif->bytes, cif->flags, ecif.rvalue, fn);
 
30190
-      break;
 
30191
+  ffi_call_SYSV (&ecif, -cif->bytes, cif->flags, ecif.rvalue, fn);
 
30192
 #endif
 
30193
-    default:
 
30194
-      FFI_ASSERT (0);
 
30195
-      break;
 
30196
-    }
 
30197
 
 
30198
   /* Check for a bounce-buffered return value */
 
30199
   if (rvalue && ecif.rvalue == smst_buffer)
 
30200
-    memcpy(rvalue, smst_buffer, rsize);
 
30201
+    {
 
30202
+      unsigned int rsize = cif->rtype->size;
 
30203
+#ifndef __LITTLE_ENDIAN__
 
30204
+      /* The SYSV ABI returns a structure of up to 4 bytes in size
 
30205
+        left-padded in r3.  */
 
30206
+# ifndef POWERPC64
 
30207
+      if (rsize <= 4)
 
30208
+       memcpy (rvalue, (char *) smst_buffer + 4 - rsize, rsize);
 
30209
+      else
 
30210
+# endif
 
30211
+       /* The SYSV ABI returns a structure of up to 8 bytes in size
 
30212
+          left-padded in r3/r4, and the ELFv2 ABI similarly returns a
 
30213
+          structure of up to 8 bytes in size left-padded in r3.  */
 
30214
+       if (rsize <= 8)
 
30215
+         memcpy (rvalue, (char *) smst_buffer + 8 - rsize, rsize);
 
30216
+       else
 
30217
+#endif
 
30218
+         memcpy (rvalue, smst_buffer, rsize);
 
30219
+    }
 
30220
 }
 
30221
 
 
30222
 
 
30223
-#ifndef POWERPC64
 
30224
-#define MIN_CACHE_LINE_SIZE 8
 
30225
-
 
30226
-static void
 
30227
-flush_icache (char *wraddr, char *xaddr, int size)
 
30228
-{
 
30229
-  int i;
 
30230
-  for (i = 0; i < size; i += MIN_CACHE_LINE_SIZE)
 
30231
-    __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;"
 
30232
-                     : : "r" (xaddr + i), "r" (wraddr + i) : "memory");
 
30233
-  __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" "sync;" "isync;"
 
30234
-                   : : "r"(xaddr + size - 1), "r"(wraddr + size - 1)
 
30235
-                   : "memory");
 
30236
-}
 
30237
-#endif
 
30238
-
 
30239
 ffi_status
 
30240
 ffi_prep_closure_loc (ffi_closure *closure,
 
30241
                      ffi_cif *cif,
 
30242
@@ -995,487 +134,8 @@
 
30243
                      void *codeloc)
 
30244
 {
 
30245
 #ifdef POWERPC64
 
30246
-  void **tramp = (void **) &closure->tramp[0];
 
30247
-
 
30248
-  if (cif->abi != FFI_LINUX64)
 
30249
-    return FFI_BAD_ABI;
 
30250
-  /* Copy function address and TOC from ffi_closure_LINUX64.  */
 
30251
-  memcpy (tramp, (char *) ffi_closure_LINUX64, 16);
 
30252
-  tramp[2] = codeloc;
 
30253
+  return ffi_prep_closure_loc_linux64 (closure, cif, fun, user_data, codeloc);
 
30254
 #else
 
30255
-  unsigned int *tramp;
 
30256
-
 
30257
-  if (! (cif->abi == FFI_GCC_SYSV 
 
30258
-        || cif->abi == FFI_SYSV
 
30259
-        || cif->abi == FFI_LINUX
 
30260
-        || cif->abi == FFI_LINUX_SOFT_FLOAT))
 
30261
-    return FFI_BAD_ABI;
 
30262
-
 
30263
-  tramp = (unsigned int *) &closure->tramp[0];
 
30264
-  tramp[0] = 0x7c0802a6;  /*   mflr    r0 */
 
30265
-  tramp[1] = 0x4800000d;  /*   bl      10 <trampoline_initial+0x10> */
 
30266
-  tramp[4] = 0x7d6802a6;  /*   mflr    r11 */
 
30267
-  tramp[5] = 0x7c0803a6;  /*   mtlr    r0 */
 
30268
-  tramp[6] = 0x800b0000;  /*   lwz     r0,0(r11) */
 
30269
-  tramp[7] = 0x816b0004;  /*   lwz     r11,4(r11) */
 
30270
-  tramp[8] = 0x7c0903a6;  /*   mtctr   r0 */
 
30271
-  tramp[9] = 0x4e800420;  /*   bctr */
 
30272
-  *(void **) &tramp[2] = (void *) ffi_closure_SYSV; /* function */
 
30273
-  *(void **) &tramp[3] = codeloc;                   /* context */
 
30274
-
 
30275
-  /* Flush the icache.  */
 
30276
-  flush_icache ((char *)tramp, (char *)codeloc, FFI_TRAMPOLINE_SIZE);
 
30277
+  return ffi_prep_closure_loc_sysv (closure, cif, fun, user_data, codeloc);
 
30278
 #endif
 
30279
-
 
30280
-  closure->cif = cif;
 
30281
-  closure->fun = fun;
 
30282
-  closure->user_data = user_data;
 
30283
-
 
30284
-  return FFI_OK;
 
30285
 }
 
30286
-
 
30287
-typedef union
 
30288
-{
 
30289
-  float f;
 
30290
-  double d;
 
30291
-} ffi_dblfl;
 
30292
-
 
30293
-int ffi_closure_helper_SYSV (ffi_closure *, void *, unsigned long *,
 
30294
-                            ffi_dblfl *, unsigned long *);
 
30295
-
 
30296
-/* Basically the trampoline invokes ffi_closure_SYSV, and on
 
30297
- * entry, r11 holds the address of the closure.
 
30298
- * After storing the registers that could possibly contain
 
30299
- * parameters to be passed into the stack frame and setting
 
30300
- * up space for a return value, ffi_closure_SYSV invokes the
 
30301
- * following helper function to do most of the work
 
30302
- */
 
30303
-
 
30304
-int
 
30305
-ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
 
30306
-                        unsigned long *pgr, ffi_dblfl *pfr,
 
30307
-                        unsigned long *pst)
 
30308
-{
 
30309
-  /* rvalue is the pointer to space for return value in closure assembly */
 
30310
-  /* pgr is the pointer to where r3-r10 are stored in ffi_closure_SYSV */
 
30311
-  /* pfr is the pointer to where f1-f8 are stored in ffi_closure_SYSV  */
 
30312
-  /* pst is the pointer to outgoing parameter stack in original caller */
 
30313
-
 
30314
-  void **          avalue;
 
30315
-  ffi_type **      arg_types;
 
30316
-  long             i, avn;
 
30317
-#ifndef __NO_FPRS__
 
30318
-  long             nf = 0;   /* number of floating registers already used */
 
30319
-#endif
 
30320
-  long             ng = 0;   /* number of general registers already used */
 
30321
-
 
30322
-  ffi_cif *cif = closure->cif;
 
30323
-  unsigned       size     = cif->rtype->size;
 
30324
-  unsigned short rtypenum = cif->rtype->type;
 
30325
-
 
30326
-  avalue = alloca (cif->nargs * sizeof (void *));
 
30327
-
 
30328
-  /* First translate for softfloat/nonlinux */
 
30329
-  if (cif->abi == FFI_LINUX_SOFT_FLOAT) {
 
30330
-       if (rtypenum == FFI_TYPE_FLOAT)
 
30331
-               rtypenum = FFI_TYPE_UINT32;
 
30332
-       if (rtypenum == FFI_TYPE_DOUBLE)
 
30333
-               rtypenum = FFI_TYPE_UINT64;
 
30334
-       if (rtypenum == FFI_TYPE_LONGDOUBLE)
 
30335
-               rtypenum = FFI_TYPE_UINT128;
 
30336
-  } else if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX64) {
 
30337
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
30338
-       if (rtypenum == FFI_TYPE_LONGDOUBLE)
 
30339
-               rtypenum = FFI_TYPE_STRUCT;
 
30340
-#endif
 
30341
-  }
 
30342
-
 
30343
-
 
30344
-  /* Copy the caller's structure return value address so that the closure
 
30345
-     returns the data directly to the caller.
 
30346
-     For FFI_SYSV the result is passed in r3/r4 if the struct size is less
 
30347
-     or equal 8 bytes.  */
 
30348
-  if (rtypenum == FFI_TYPE_STRUCT && ((cif->abi != FFI_SYSV) || (size > 8))) {
 
30349
-      rvalue = (void *) *pgr;
 
30350
-      ng++;
 
30351
-      pgr++;
 
30352
-    }
 
30353
-
 
30354
-  i = 0;
 
30355
-  avn = cif->nargs;
 
30356
-  arg_types = cif->arg_types;
 
30357
-
 
30358
-  /* Grab the addresses of the arguments from the stack frame.  */
 
30359
-  while (i < avn) {
 
30360
-      unsigned short typenum = arg_types[i]->type;
 
30361
-
 
30362
-      /* We may need to handle some values depending on ABI */
 
30363
-      if (cif->abi == FFI_LINUX_SOFT_FLOAT) {
 
30364
-               if (typenum == FFI_TYPE_FLOAT)
 
30365
-                       typenum = FFI_TYPE_UINT32;
 
30366
-               if (typenum == FFI_TYPE_DOUBLE)
 
30367
-                       typenum = FFI_TYPE_UINT64;
 
30368
-               if (typenum == FFI_TYPE_LONGDOUBLE)
 
30369
-                       typenum = FFI_TYPE_UINT128;
 
30370
-      } else if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX64) {
 
30371
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
30372
-               if (typenum == FFI_TYPE_LONGDOUBLE)
 
30373
-                       typenum = FFI_TYPE_STRUCT;
 
30374
-#endif
 
30375
-      }
 
30376
-
 
30377
-      switch (typenum) {
 
30378
-#ifndef __NO_FPRS__
 
30379
-       case FFI_TYPE_FLOAT:
 
30380
-         /* unfortunately float values are stored as doubles
 
30381
-          * in the ffi_closure_SYSV code (since we don't check
 
30382
-          * the type in that routine).
 
30383
-          */
 
30384
-
 
30385
-         /* there are 8 64bit floating point registers */
 
30386
-
 
30387
-         if (nf < 8)
 
30388
-           {
 
30389
-             double temp = pfr->d;
 
30390
-             pfr->f = (float) temp;
 
30391
-             avalue[i] = pfr;
 
30392
-             nf++;
 
30393
-             pfr++;
 
30394
-           }
 
30395
-         else
 
30396
-           {
 
30397
-             /* FIXME? here we are really changing the values
 
30398
-              * stored in the original calling routines outgoing
 
30399
-              * parameter stack.  This is probably a really
 
30400
-              * naughty thing to do but...
 
30401
-              */
 
30402
-             avalue[i] = pst;
 
30403
-             pst += 1;
 
30404
-           }
 
30405
-         break;
 
30406
-
 
30407
-       case FFI_TYPE_DOUBLE:
 
30408
-         /* On the outgoing stack all values are aligned to 8 */
 
30409
-         /* there are 8 64bit floating point registers */
 
30410
-
 
30411
-         if (nf < 8)
 
30412
-           {
 
30413
-             avalue[i] = pfr;
 
30414
-             nf++;
 
30415
-             pfr++;
 
30416
-           }
 
30417
-         else
 
30418
-           {
 
30419
-             if (((long) pst) & 4)
 
30420
-               pst++;
 
30421
-             avalue[i] = pst;
 
30422
-             pst += 2;
 
30423
-           }
 
30424
-         break;
 
30425
-
 
30426
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
30427
-       case FFI_TYPE_LONGDOUBLE:
 
30428
-         if (nf < 7)
 
30429
-           {
 
30430
-             avalue[i] = pfr;
 
30431
-             pfr += 2;
 
30432
-             nf += 2;
 
30433
-           }
 
30434
-         else
 
30435
-           {
 
30436
-             if (((long) pst) & 4)
 
30437
-               pst++;
 
30438
-             avalue[i] = pst;
 
30439
-             pst += 4;
 
30440
-             nf = 8;
 
30441
-           }
 
30442
-         break;
 
30443
-#endif
 
30444
-#endif /* have FPRS */
 
30445
-
 
30446
-       case FFI_TYPE_UINT128:
 
30447
-               /*
 
30448
-                * Test if for the whole long double, 4 gprs are available.
 
30449
-                * otherwise the stuff ends up on the stack.
 
30450
-                */
 
30451
-               if (ng < 5) {
 
30452
-                       avalue[i] = pgr;
 
30453
-                       pgr += 4;
 
30454
-                       ng += 4;
 
30455
-               } else {
 
30456
-                       avalue[i] = pst;
 
30457
-                       pst += 4;
 
30458
-                       ng = 8+4;
 
30459
-               }
 
30460
-               break;
 
30461
-
 
30462
-       case FFI_TYPE_SINT8:
 
30463
-       case FFI_TYPE_UINT8:
 
30464
-#ifndef __LITTLE_ENDIAN__
 
30465
-         /* there are 8 gpr registers used to pass values */
 
30466
-         if (ng < 8)
 
30467
-           {
 
30468
-             avalue[i] = (char *) pgr + 3;
 
30469
-             ng++;
 
30470
-             pgr++;
 
30471
-           }
 
30472
-         else
 
30473
-           {
 
30474
-             avalue[i] = (char *) pst + 3;
 
30475
-             pst++;
 
30476
-           }
 
30477
-         break;
 
30478
-#endif
 
30479
-       case FFI_TYPE_SINT16:
 
30480
-       case FFI_TYPE_UINT16:
 
30481
-#ifndef __LITTLE_ENDIAN__
 
30482
-         /* there are 8 gpr registers used to pass values */
 
30483
-         if (ng < 8)
 
30484
-           {
 
30485
-             avalue[i] = (char *) pgr + 2;
 
30486
-             ng++;
 
30487
-             pgr++;
 
30488
-           }
 
30489
-         else
 
30490
-           {
 
30491
-             avalue[i] = (char *) pst + 2;
 
30492
-             pst++;
 
30493
-           }
 
30494
-         break;
 
30495
-#endif
 
30496
-       case FFI_TYPE_SINT32:
 
30497
-       case FFI_TYPE_UINT32:
 
30498
-       case FFI_TYPE_POINTER:
 
30499
-         /* there are 8 gpr registers used to pass values */
 
30500
-         if (ng < 8)
 
30501
-           {
 
30502
-             avalue[i] = pgr;
 
30503
-             ng++;
 
30504
-             pgr++;
 
30505
-           }
 
30506
-         else
 
30507
-           {
 
30508
-             avalue[i] = pst;
 
30509
-             pst++;
 
30510
-           }
 
30511
-         break;
 
30512
-
 
30513
-       case FFI_TYPE_STRUCT:
 
30514
-         /* Structs are passed by reference. The address will appear in a
 
30515
-            gpr if it is one of the first 8 arguments.  */
 
30516
-         if (ng < 8)
 
30517
-           {
 
30518
-             avalue[i] = (void *) *pgr;
 
30519
-             ng++;
 
30520
-             pgr++;
 
30521
-           }
 
30522
-         else
 
30523
-           {
 
30524
-             avalue[i] = (void *) *pst;
 
30525
-             pst++;
 
30526
-           }
 
30527
-         break;
 
30528
-
 
30529
-       case FFI_TYPE_SINT64:
 
30530
-       case FFI_TYPE_UINT64:
 
30531
-         /* passing long long ints are complex, they must
 
30532
-          * be passed in suitable register pairs such as
 
30533
-          * (r3,r4) or (r5,r6) or (r6,r7), or (r7,r8) or (r9,r10)
 
30534
-          * and if the entire pair aren't available then the outgoing
 
30535
-          * parameter stack is used for both but an alignment of 8
 
30536
-          * must will be kept.  So we must either look in pgr
 
30537
-          * or pst to find the correct address for this type
 
30538
-          * of parameter.
 
30539
-          */
 
30540
-         if (ng < 7)
 
30541
-           {
 
30542
-             if (ng & 0x01)
 
30543
-               {
 
30544
-                 /* skip r4, r6, r8 as starting points */
 
30545
-                 ng++;
 
30546
-                 pgr++;
 
30547
-               }
 
30548
-             avalue[i] = pgr;
 
30549
-             ng += 2;
 
30550
-             pgr += 2;
 
30551
-           }
 
30552
-         else
 
30553
-           {
 
30554
-             if (((long) pst) & 4)
 
30555
-               pst++;
 
30556
-             avalue[i] = pst;
 
30557
-             pst += 2;
 
30558
-             ng = 8;
 
30559
-           }
 
30560
-         break;
 
30561
-
 
30562
-       default:
 
30563
-               FFI_ASSERT (0);
 
30564
-       }
 
30565
-
 
30566
-      i++;
 
30567
-    }
 
30568
-
 
30569
-
 
30570
-  (closure->fun) (cif, rvalue, avalue, closure->user_data);
 
30571
-
 
30572
-  /* Tell ffi_closure_SYSV how to perform return type promotions.
 
30573
-     Because the FFI_SYSV ABI returns the structures <= 8 bytes in r3/r4
 
30574
-     we have to tell ffi_closure_SYSV how to treat them. We combine the base
 
30575
-     type FFI_SYSV_TYPE_SMALL_STRUCT - 1  with the size of the struct.
 
30576
-     So a one byte struct gets the return type 16. Return type 1 to 15 are
 
30577
-     already used and we never have a struct with size zero. That is the reason
 
30578
-     for the subtraction of 1. See the comment in ffitarget.h about ordering.
 
30579
-  */
 
30580
-  if (cif->abi == FFI_SYSV && rtypenum == FFI_TYPE_STRUCT && size <= 8)
 
30581
-    return (FFI_SYSV_TYPE_SMALL_STRUCT - 1) + size;
 
30582
-  return rtypenum;
 
30583
-}
 
30584
-
 
30585
-int FFI_HIDDEN ffi_closure_helper_LINUX64 (ffi_closure *, void *,
 
30586
-                                          unsigned long *, ffi_dblfl *);
 
30587
-
 
30588
-int FFI_HIDDEN
 
30589
-ffi_closure_helper_LINUX64 (ffi_closure *closure, void *rvalue,
 
30590
-                           unsigned long *pst, ffi_dblfl *pfr)
 
30591
-{
 
30592
-  /* rvalue is the pointer to space for return value in closure assembly */
 
30593
-  /* pst is the pointer to parameter save area
 
30594
-     (r3-r10 are stored into its first 8 slots by ffi_closure_LINUX64) */
 
30595
-  /* pfr is the pointer to where f1-f13 are stored in ffi_closure_LINUX64 */
 
30596
-
 
30597
-  void **avalue;
 
30598
-  ffi_type **arg_types;
 
30599
-  long i, avn;
 
30600
-  ffi_cif *cif;
 
30601
-  ffi_dblfl *end_pfr = pfr + NUM_FPR_ARG_REGISTERS64;
 
30602
-
 
30603
-  cif = closure->cif;
 
30604
-  avalue = alloca (cif->nargs * sizeof (void *));
 
30605
-
 
30606
-  /* Copy the caller's structure return value address so that the closure
 
30607
-     returns the data directly to the caller.  */
 
30608
-  if (cif->rtype->type == FFI_TYPE_STRUCT)
 
30609
-    {
 
30610
-      rvalue = (void *) *pst;
 
30611
-      pst++;
 
30612
-    }
 
30613
-
 
30614
-  i = 0;
 
30615
-  avn = cif->nargs;
 
30616
-  arg_types = cif->arg_types;
 
30617
-
 
30618
-  /* Grab the addresses of the arguments from the stack frame.  */
 
30619
-  while (i < avn)
 
30620
-    {
 
30621
-      switch (arg_types[i]->type)
 
30622
-       {
 
30623
-       case FFI_TYPE_SINT8:
 
30624
-       case FFI_TYPE_UINT8:
 
30625
-#ifndef __LITTLE_ENDIAN__
 
30626
-         avalue[i] = (char *) pst + 7;
 
30627
-         pst++;
 
30628
-         break;
 
30629
-#endif
 
30630
-       case FFI_TYPE_SINT16:
 
30631
-       case FFI_TYPE_UINT16:
 
30632
-#ifndef __LITTLE_ENDIAN__
 
30633
-         avalue[i] = (char *) pst + 6;
 
30634
-         pst++;
 
30635
-         break;
 
30636
-#endif
 
30637
-       case FFI_TYPE_SINT32:
 
30638
-       case FFI_TYPE_UINT32:
 
30639
-#ifndef __LITTLE_ENDIAN__
 
30640
-         avalue[i] = (char *) pst + 4;
 
30641
-         pst++;
 
30642
-         break;
 
30643
-#endif
 
30644
-       case FFI_TYPE_SINT64:
 
30645
-       case FFI_TYPE_UINT64:
 
30646
-       case FFI_TYPE_POINTER:
 
30647
-         avalue[i] = pst;
 
30648
-         pst++;
 
30649
-         break;
 
30650
-
 
30651
-       case FFI_TYPE_STRUCT:
 
30652
-#ifndef __LITTLE_ENDIAN__
 
30653
-         /* Structures with size less than eight bytes are passed
 
30654
-            left-padded.  */
 
30655
-         if (arg_types[i]->size < 8)
 
30656
-           avalue[i] = (char *) pst + 8 - arg_types[i]->size;
 
30657
-         else
 
30658
-#endif
 
30659
-           avalue[i] = pst;
 
30660
-         pst += (arg_types[i]->size + 7) / 8;
 
30661
-         break;
 
30662
-
 
30663
-       case FFI_TYPE_FLOAT:
 
30664
-         /* unfortunately float values are stored as doubles
 
30665
-          * in the ffi_closure_LINUX64 code (since we don't check
 
30666
-          * the type in that routine).
 
30667
-          */
 
30668
-
 
30669
-         /* there are 13 64bit floating point registers */
 
30670
-
 
30671
-         if (pfr < end_pfr)
 
30672
-           {
 
30673
-             double temp = pfr->d;
 
30674
-             pfr->f = (float) temp;
 
30675
-             avalue[i] = pfr;
 
30676
-             pfr++;
 
30677
-           }
 
30678
-         else
 
30679
-           avalue[i] = pst;
 
30680
-         pst++;
 
30681
-         break;
 
30682
-
 
30683
-       case FFI_TYPE_DOUBLE:
 
30684
-         /* On the outgoing stack all values are aligned to 8 */
 
30685
-         /* there are 13 64bit floating point registers */
 
30686
-
 
30687
-         if (pfr < end_pfr)
 
30688
-           {
 
30689
-             avalue[i] = pfr;
 
30690
-             pfr++;
 
30691
-           }
 
30692
-         else
 
30693
-           avalue[i] = pst;
 
30694
-         pst++;
 
30695
-         break;
 
30696
-
 
30697
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
30698
-       case FFI_TYPE_LONGDOUBLE:
 
30699
-         if (pfr + 1 < end_pfr)
 
30700
-           {
 
30701
-             avalue[i] = pfr;
 
30702
-             pfr += 2;
 
30703
-           }
 
30704
-         else
 
30705
-           {
 
30706
-             if (pfr < end_pfr)
 
30707
-               {
 
30708
-                 /* Passed partly in f13 and partly on the stack.
 
30709
-                    Move it all to the stack.  */
 
30710
-                 *pst = *(unsigned long *) pfr;
 
30711
-                 pfr++;
 
30712
-               }
 
30713
-             avalue[i] = pst;
 
30714
-           }
 
30715
-         pst += 2;
 
30716
-         break;
 
30717
-#endif
 
30718
-
 
30719
-       default:
 
30720
-         FFI_ASSERT (0);
 
30721
-       }
 
30722
-
 
30723
-      i++;
 
30724
-    }
 
30725
-
 
30726
-
 
30727
-  (closure->fun) (cif, rvalue, avalue, closure->user_data);
 
30728
-
 
30729
-  /* Tell ffi_closure_LINUX64 how to perform return type promotions.  */
 
30730
-  return cif->rtype->type;
 
30731
-}
 
30732
--- a/src/libffi/src/powerpc/sysv.S
 
30733
+++ b/src/libffi/src/powerpc/sysv.S
 
30734
@@ -30,7 +30,7 @@
 
30735
 #include <ffi.h>
 
30736
 #include <powerpc/asm.h>
 
30737
 
 
30738
-#ifndef __powerpc64__
 
30739
+#ifndef POWERPC64
 
30740
        .globl ffi_prep_args_SYSV
 
30741
 ENTRY(ffi_call_SYSV)
 
30742
 .LFB1:
 
30743
@@ -213,8 +213,8 @@
 
30744
       .uleb128  0x1c
 
30745
       .align 2
 
30746
 .LEFDE1:
 
30747
-#endif
 
30748
 
 
30749
 #if defined __ELF__ && defined __linux__
 
30750
        .section        .note.GNU-stack,"",@progbits
 
30751
 #endif
 
30752
+#endif
 
30753
--- a/src/libffi/src/powerpc/linux64_closure.S
 
30754
+++ b/src/libffi/src/powerpc/linux64_closure.S
 
30755
@@ -30,18 +30,25 @@
 
30756
 
 
30757
        .file   "linux64_closure.S"
 
30758
 
 
30759
-#ifdef __powerpc64__
 
30760
+#ifdef POWERPC64
 
30761
        FFI_HIDDEN (ffi_closure_LINUX64)
 
30762
        .globl  ffi_closure_LINUX64
 
30763
+# if _CALL_ELF == 2
 
30764
+       .text
 
30765
+ffi_closure_LINUX64:
 
30766
+       addis   %r2, %r12, .TOC.-ffi_closure_LINUX64@ha
 
30767
+       addi    %r2, %r2, .TOC.-ffi_closure_LINUX64@l
 
30768
+       .localentry ffi_closure_LINUX64, . - ffi_closure_LINUX64
 
30769
+# else
 
30770
        .section        ".opd","aw"
 
30771
        .align  3
 
30772
 ffi_closure_LINUX64:
 
30773
-#ifdef _CALL_LINUX
 
30774
+#  ifdef _CALL_LINUX
 
30775
        .quad   .L.ffi_closure_LINUX64,.TOC.@tocbase,0
 
30776
        .type   ffi_closure_LINUX64,@function
 
30777
        .text
 
30778
 .L.ffi_closure_LINUX64:
 
30779
-#else
 
30780
+#  else
 
30781
        FFI_HIDDEN (.ffi_closure_LINUX64)
 
30782
        .globl  .ffi_closure_LINUX64
 
30783
        .quad   .ffi_closure_LINUX64,.TOC.@tocbase,0
 
30784
@@ -49,61 +56,101 @@
 
30785
        .type   .ffi_closure_LINUX64,@function
 
30786
        .text
 
30787
 .ffi_closure_LINUX64:
 
30788
-#endif
 
30789
+#  endif
 
30790
+# endif
 
30791
+
 
30792
+# if _CALL_ELF == 2
 
30793
+#  32 byte special reg save area + 64 byte parm save area
 
30794
+#  + 64 byte retval area + 13*8 fpr save area + round to 16
 
30795
+#  define STACKFRAME 272
 
30796
+#  define PARMSAVE 32
 
30797
+#  define RETVAL PARMSAVE+64
 
30798
+# else
 
30799
+#  48 bytes special reg save area + 64 bytes parm save area
 
30800
+#  + 16 bytes retval area + 13*8 bytes fpr save area + round to 16
 
30801
+#  define STACKFRAME 240
 
30802
+#  define PARMSAVE 48
 
30803
+#  define RETVAL PARMSAVE+64
 
30804
+# endif
 
30805
+
 
30806
 .LFB1:
 
30807
-       # save general regs into parm save area
 
30808
-       std     %r3, 48(%r1)
 
30809
-       std     %r4, 56(%r1)
 
30810
-       std     %r5, 64(%r1)
 
30811
-       std     %r6, 72(%r1)
 
30812
+# if _CALL_ELF == 2
 
30813
+       ld      %r12, FFI_TRAMPOLINE_SIZE(%r11)         # closure->cif
 
30814
        mflr    %r0
 
30815
+       lwz     %r12, 28(%r12)                          # cif->flags
 
30816
+       mtcrf   0x40, %r12
 
30817
+       addi    %r12, %r1, PARMSAVE
 
30818
+       bt      7, .Lparmsave
 
30819
+       # Our caller has not allocated a parameter save area.
 
30820
+       # We need to allocate one here and use it to pass gprs to
 
30821
+       # ffi_closure_helper_LINUX64.
 
30822
+       addi    %r12, %r1, -STACKFRAME+PARMSAVE
 
30823
+.Lparmsave:
 
30824
+       std     %r0, 16(%r1)
 
30825
+       # Save general regs into parm save area
 
30826
+       std     %r3, 0(%r12)
 
30827
+       std     %r4, 8(%r12)
 
30828
+       std     %r5, 16(%r12)
 
30829
+       std     %r6, 24(%r12)
 
30830
+       std     %r7, 32(%r12)
 
30831
+       std     %r8, 40(%r12)
 
30832
+       std     %r9, 48(%r12)
 
30833
+       std     %r10, 56(%r12)
 
30834
 
 
30835
-       std     %r7, 80(%r1)
 
30836
-       std     %r8, 88(%r1)
 
30837
-       std     %r9, 96(%r1)
 
30838
-       std     %r10, 104(%r1)
 
30839
+       # load up the pointer to the parm save area
 
30840
+       mr      %r5, %r12
 
30841
+# else
 
30842
+       mflr    %r0
 
30843
+       # Save general regs into parm save area
 
30844
+       # This is the parameter save area set up by our caller.
 
30845
+       std     %r3, PARMSAVE+0(%r1)
 
30846
+       std     %r4, PARMSAVE+8(%r1)
 
30847
+       std     %r5, PARMSAVE+16(%r1)
 
30848
+       std     %r6, PARMSAVE+24(%r1)
 
30849
+       std     %r7, PARMSAVE+32(%r1)
 
30850
+       std     %r8, PARMSAVE+40(%r1)
 
30851
+       std     %r9, PARMSAVE+48(%r1)
 
30852
+       std     %r10, PARMSAVE+56(%r1)
 
30853
+
 
30854
        std     %r0, 16(%r1)
 
30855
 
 
30856
-       # mandatory 48 bytes special reg save area + 64 bytes parm save area
 
30857
-       # + 16 bytes retval area + 13*8 bytes fpr save area + round to 16
 
30858
-       stdu    %r1, -240(%r1)
 
30859
-.LCFI0:
 
30860
+       # load up the pointer to the parm save area
 
30861
+       addi    %r5, %r1, PARMSAVE
 
30862
+# endif
 
30863
 
 
30864
        # next save fpr 1 to fpr 13
 
30865
-       stfd  %f1, 128+(0*8)(%r1)
 
30866
-       stfd  %f2, 128+(1*8)(%r1)
 
30867
-       stfd  %f3, 128+(2*8)(%r1)
 
30868
-       stfd  %f4, 128+(3*8)(%r1)
 
30869
-       stfd  %f5, 128+(4*8)(%r1)
 
30870
-       stfd  %f6, 128+(5*8)(%r1)
 
30871
-       stfd  %f7, 128+(6*8)(%r1)
 
30872
-       stfd  %f8, 128+(7*8)(%r1)
 
30873
-       stfd  %f9, 128+(8*8)(%r1)
 
30874
-       stfd  %f10, 128+(9*8)(%r1)
 
30875
-       stfd  %f11, 128+(10*8)(%r1)
 
30876
-       stfd  %f12, 128+(11*8)(%r1)
 
30877
-       stfd  %f13, 128+(12*8)(%r1)
 
30878
+       stfd    %f1, -104+(0*8)(%r1)
 
30879
+       stfd    %f2, -104+(1*8)(%r1)
 
30880
+       stfd    %f3, -104+(2*8)(%r1)
 
30881
+       stfd    %f4, -104+(3*8)(%r1)
 
30882
+       stfd    %f5, -104+(4*8)(%r1)
 
30883
+       stfd    %f6, -104+(5*8)(%r1)
 
30884
+       stfd    %f7, -104+(6*8)(%r1)
 
30885
+       stfd    %f8, -104+(7*8)(%r1)
 
30886
+       stfd    %f9, -104+(8*8)(%r1)
 
30887
+       stfd    %f10, -104+(9*8)(%r1)
 
30888
+       stfd    %f11, -104+(10*8)(%r1)
 
30889
+       stfd    %f12, -104+(11*8)(%r1)
 
30890
+       stfd    %f13, -104+(12*8)(%r1)
 
30891
 
 
30892
-       # set up registers for the routine that actually does the work
 
30893
-       # get the context pointer from the trampoline
 
30894
-       mr %r3, %r11
 
30895
+       # load up the pointer to the saved fpr registers */
 
30896
+       addi    %r6, %r1, -104
 
30897
 
 
30898
-       # now load up the pointer to the result storage
 
30899
-       addi %r4, %r1, 112
 
30900
+       # load up the pointer to the result storage
 
30901
+       addi    %r4, %r1, -STACKFRAME+RETVAL
 
30902
 
 
30903
-       # now load up the pointer to the parameter save area
 
30904
-       # in the previous frame
 
30905
-       addi %r5, %r1, 240 + 48
 
30906
+       stdu    %r1, -STACKFRAME(%r1)
 
30907
+.LCFI0:
 
30908
 
 
30909
-       # now load up the pointer to the saved fpr registers */
 
30910
-       addi %r6, %r1, 128
 
30911
+       # get the context pointer from the trampoline
 
30912
+       mr      %r3, %r11
 
30913
 
 
30914
        # make the call
 
30915
-#ifdef _CALL_LINUX
 
30916
+# if defined _CALL_LINUX || _CALL_ELF == 2
 
30917
        bl ffi_closure_helper_LINUX64
 
30918
-#else
 
30919
+# else
 
30920
        bl .ffi_closure_helper_LINUX64
 
30921
-#endif
 
30922
+# endif
 
30923
 .Lret:
 
30924
 
 
30925
        # now r3 contains the return type
 
30926
@@ -112,10 +159,12 @@
 
30927
 
 
30928
        # look up the proper starting point in table
 
30929
        # by using return type as offset
 
30930
+       ld %r0, STACKFRAME+16(%r1)
 
30931
+       cmpldi %r3, FFI_V2_TYPE_SMALL_STRUCT
 
30932
+       bge .Lsmall
 
30933
        mflr %r4                # move address of .Lret to r4
 
30934
        sldi %r3, %r3, 4        # now multiply return type by 16
 
30935
        addi %r4, %r4, .Lret_type0 - .Lret
 
30936
-       ld %r0, 240+16(%r1)
 
30937
        add %r3, %r3, %r4       # add contents of table to table address
 
30938
        mtctr %r3
 
30939
        bctr                    # jump to it
 
30940
@@ -128,117 +177,175 @@
 
30941
 .Lret_type0:
 
30942
 # case FFI_TYPE_VOID
 
30943
        mtlr %r0
 
30944
-       addi %r1, %r1, 240
 
30945
+       addi %r1, %r1, STACKFRAME
 
30946
        blr
 
30947
        nop
 
30948
 # case FFI_TYPE_INT
 
30949
-#ifdef __LITTLE_ENDIAN__
 
30950
-       lwa %r3, 112+0(%r1)
 
30951
-#else
 
30952
-       lwa %r3, 112+4(%r1)
 
30953
-#endif
 
30954
+# ifdef __LITTLE_ENDIAN__
 
30955
+       lwa %r3, RETVAL+0(%r1)
 
30956
+# else
 
30957
+       lwa %r3, RETVAL+4(%r1)
 
30958
+# endif
 
30959
        mtlr %r0
 
30960
-       addi %r1, %r1, 240
 
30961
+       addi %r1, %r1, STACKFRAME
 
30962
        blr
 
30963
 # case FFI_TYPE_FLOAT
 
30964
-       lfs %f1, 112+0(%r1)
 
30965
+       lfs %f1, RETVAL+0(%r1)
 
30966
        mtlr %r0
 
30967
-       addi %r1, %r1, 240
 
30968
+       addi %r1, %r1, STACKFRAME
 
30969
        blr
 
30970
 # case FFI_TYPE_DOUBLE
 
30971
-       lfd %f1, 112+0(%r1)
 
30972
+       lfd %f1, RETVAL+0(%r1)
 
30973
        mtlr %r0
 
30974
-       addi %r1, %r1, 240
 
30975
+       addi %r1, %r1, STACKFRAME
 
30976
        blr
 
30977
 # case FFI_TYPE_LONGDOUBLE
 
30978
-       lfd %f1, 112+0(%r1)
 
30979
+       lfd %f1, RETVAL+0(%r1)
 
30980
        mtlr %r0
 
30981
-       lfd %f2, 112+8(%r1)
 
30982
+       lfd %f2, RETVAL+8(%r1)
 
30983
        b .Lfinish
 
30984
 # case FFI_TYPE_UINT8
 
30985
-#ifdef __LITTLE_ENDIAN__
 
30986
-       lbz %r3, 112+0(%r1)
 
30987
-#else
 
30988
-       lbz %r3, 112+7(%r1)
 
30989
-#endif
 
30990
+# ifdef __LITTLE_ENDIAN__
 
30991
+       lbz %r3, RETVAL+0(%r1)
 
30992
+# else
 
30993
+       lbz %r3, RETVAL+7(%r1)
 
30994
+# endif
 
30995
        mtlr %r0
 
30996
-       addi %r1, %r1, 240
 
30997
+       addi %r1, %r1, STACKFRAME
 
30998
        blr
 
30999
 # case FFI_TYPE_SINT8
 
31000
-#ifdef __LITTLE_ENDIAN__
 
31001
-       lbz %r3, 112+0(%r1)
 
31002
-#else
 
31003
-       lbz %r3, 112+7(%r1)
 
31004
-#endif
 
31005
+# ifdef __LITTLE_ENDIAN__
 
31006
+       lbz %r3, RETVAL+0(%r1)
 
31007
+# else
 
31008
+       lbz %r3, RETVAL+7(%r1)
 
31009
+# endif
 
31010
        extsb %r3,%r3
 
31011
        mtlr %r0
 
31012
        b .Lfinish
 
31013
 # case FFI_TYPE_UINT16
 
31014
-#ifdef __LITTLE_ENDIAN__
 
31015
-       lhz %r3, 112+0(%r1)
 
31016
-#else
 
31017
-       lhz %r3, 112+6(%r1)
 
31018
-#endif
 
31019
+# ifdef __LITTLE_ENDIAN__
 
31020
+       lhz %r3, RETVAL+0(%r1)
 
31021
+# else
 
31022
+       lhz %r3, RETVAL+6(%r1)
 
31023
+# endif
 
31024
        mtlr %r0
 
31025
 .Lfinish:
 
31026
-       addi %r1, %r1, 240
 
31027
+       addi %r1, %r1, STACKFRAME
 
31028
        blr
 
31029
 # case FFI_TYPE_SINT16
 
31030
-#ifdef __LITTLE_ENDIAN__
 
31031
-       lha %r3, 112+0(%r1)
 
31032
-#else
 
31033
-       lha %r3, 112+6(%r1)
 
31034
-#endif
 
31035
+# ifdef __LITTLE_ENDIAN__
 
31036
+       lha %r3, RETVAL+0(%r1)
 
31037
+# else
 
31038
+       lha %r3, RETVAL+6(%r1)
 
31039
+# endif
 
31040
        mtlr %r0
 
31041
-       addi %r1, %r1, 240
 
31042
+       addi %r1, %r1, STACKFRAME
 
31043
        blr
 
31044
 # case FFI_TYPE_UINT32
 
31045
-#ifdef __LITTLE_ENDIAN__
 
31046
-       lwz %r3, 112+0(%r1)
 
31047
-#else
 
31048
-       lwz %r3, 112+4(%r1)
 
31049
-#endif
 
31050
+# ifdef __LITTLE_ENDIAN__
 
31051
+       lwz %r3, RETVAL+0(%r1)
 
31052
+# else
 
31053
+       lwz %r3, RETVAL+4(%r1)
 
31054
+# endif
 
31055
        mtlr %r0
 
31056
-       addi %r1, %r1, 240
 
31057
+       addi %r1, %r1, STACKFRAME
 
31058
        blr
 
31059
 # case FFI_TYPE_SINT32
 
31060
-#ifdef __LITTLE_ENDIAN__
 
31061
-       lwa %r3, 112+0(%r1)
 
31062
-#else
 
31063
-       lwa %r3, 112+4(%r1)
 
31064
-#endif
 
31065
+# ifdef __LITTLE_ENDIAN__
 
31066
+       lwa %r3, RETVAL+0(%r1)
 
31067
+# else
 
31068
+       lwa %r3, RETVAL+4(%r1)
 
31069
+# endif
 
31070
        mtlr %r0
 
31071
-       addi %r1, %r1, 240
 
31072
+       addi %r1, %r1, STACKFRAME
 
31073
        blr
 
31074
 # case FFI_TYPE_UINT64
 
31075
-       ld %r3, 112+0(%r1)
 
31076
+       ld %r3, RETVAL+0(%r1)
 
31077
        mtlr %r0
 
31078
-       addi %r1, %r1, 240
 
31079
+       addi %r1, %r1, STACKFRAME
 
31080
        blr
 
31081
 # case FFI_TYPE_SINT64
 
31082
-       ld %r3, 112+0(%r1)
 
31083
+       ld %r3, RETVAL+0(%r1)
 
31084
        mtlr %r0
 
31085
-       addi %r1, %r1, 240
 
31086
+       addi %r1, %r1, STACKFRAME
 
31087
        blr
 
31088
 # case FFI_TYPE_STRUCT
 
31089
        mtlr %r0
 
31090
-       addi %r1, %r1, 240
 
31091
+       addi %r1, %r1, STACKFRAME
 
31092
        blr
 
31093
        nop
 
31094
 # case FFI_TYPE_POINTER
 
31095
-       ld %r3, 112+0(%r1)
 
31096
+       ld %r3, RETVAL+0(%r1)
 
31097
        mtlr %r0
 
31098
-       addi %r1, %r1, 240
 
31099
+       addi %r1, %r1, STACKFRAME
 
31100
        blr
 
31101
-# esac
 
31102
+# case FFI_V2_TYPE_FLOAT_HOMOG
 
31103
+       lfs %f1, RETVAL+0(%r1)
 
31104
+       lfs %f2, RETVAL+4(%r1)
 
31105
+       lfs %f3, RETVAL+8(%r1)
 
31106
+       b .Lmorefloat
 
31107
+# case FFI_V2_TYPE_DOUBLE_HOMOG
 
31108
+       lfd %f1, RETVAL+0(%r1)
 
31109
+       lfd %f2, RETVAL+8(%r1)
 
31110
+       lfd %f3, RETVAL+16(%r1)
 
31111
+       lfd %f4, RETVAL+24(%r1)
 
31112
+       mtlr %r0
 
31113
+       lfd %f5, RETVAL+32(%r1)
 
31114
+       lfd %f6, RETVAL+40(%r1)
 
31115
+       lfd %f7, RETVAL+48(%r1)
 
31116
+       lfd %f8, RETVAL+56(%r1)
 
31117
+       addi %r1, %r1, STACKFRAME
 
31118
+       blr
 
31119
+.Lmorefloat:
 
31120
+       lfs %f4, RETVAL+12(%r1)
 
31121
+       mtlr %r0
 
31122
+       lfs %f5, RETVAL+16(%r1)
 
31123
+       lfs %f6, RETVAL+20(%r1)
 
31124
+       lfs %f7, RETVAL+24(%r1)
 
31125
+       lfs %f8, RETVAL+28(%r1)
 
31126
+       addi %r1, %r1, STACKFRAME
 
31127
+       blr
 
31128
+.Lsmall:
 
31129
+# ifdef __LITTLE_ENDIAN__
 
31130
+       ld %r3,RETVAL+0(%r1)
 
31131
+       mtlr %r0
 
31132
+       ld %r4,RETVAL+8(%r1)
 
31133
+       addi %r1, %r1, STACKFRAME
 
31134
+       blr
 
31135
+# else
 
31136
+       # A struct smaller than a dword is returned in the low bits of r3
 
31137
+       # ie. right justified.  Larger structs are passed left justified
 
31138
+       # in r3 and r4.  The return value area on the stack will have
 
31139
+       # the structs as they are usually stored in memory.
 
31140
+       cmpldi %r3, FFI_V2_TYPE_SMALL_STRUCT + 7 # size 8 bytes?
 
31141
+       neg %r5, %r3
 
31142
+       ld %r3,RETVAL+0(%r1)
 
31143
+       blt .Lsmalldown
 
31144
+       mtlr %r0
 
31145
+       ld %r4,RETVAL+8(%r1)
 
31146
+       addi %r1, %r1, STACKFRAME
 
31147
+       blr
 
31148
+.Lsmalldown:
 
31149
+       addi %r5, %r5, FFI_V2_TYPE_SMALL_STRUCT + 7
 
31150
+       mtlr %r0
 
31151
+       sldi %r5, %r5, 3
 
31152
+       addi %r1, %r1, STACKFRAME
 
31153
+       srd %r3, %r3, %r5
 
31154
+       blr
 
31155
+# endif
 
31156
+
 
31157
 .LFE1:
 
31158
        .long   0
 
31159
        .byte   0,12,0,1,128,0,0,0
 
31160
-#ifdef _CALL_LINUX
 
31161
+# if _CALL_ELF == 2
 
31162
+       .size   ffi_closure_LINUX64,.-ffi_closure_LINUX64
 
31163
+# else
 
31164
+#  ifdef _CALL_LINUX
 
31165
        .size   ffi_closure_LINUX64,.-.L.ffi_closure_LINUX64
 
31166
-#else
 
31167
+#  else
 
31168
        .size   .ffi_closure_LINUX64,.-.ffi_closure_LINUX64
 
31169
-#endif
 
31170
+#  endif
 
31171
+# endif
 
31172
 
 
31173
        .section        .eh_frame,EH_FRAME_FLAGS,@progbits
 
31174
 .Lframe1:
 
31175
@@ -267,14 +374,14 @@
 
31176
        .byte   0x2      # DW_CFA_advance_loc1
 
31177
        .byte   .LCFI0-.LFB1
 
31178
        .byte   0xe      # DW_CFA_def_cfa_offset
 
31179
-       .uleb128 240
 
31180
+       .uleb128 STACKFRAME
 
31181
        .byte   0x11     # DW_CFA_offset_extended_sf
 
31182
        .uleb128 0x41
 
31183
        .sleb128 -2
 
31184
        .align 3
 
31185
 .LEFDE1:
 
31186
-#endif
 
31187
 
 
31188
-#if defined __ELF__ && defined __linux__
 
31189
+# if defined __ELF__ && defined __linux__
 
31190
        .section        .note.GNU-stack,"",@progbits
 
31191
+# endif
 
31192
 #endif
 
31193
--- a/src/libffi/src/powerpc/ffi_powerpc.h
 
31194
+++ b/src/libffi/src/powerpc/ffi_powerpc.h
 
31195
@@ -0,0 +1,77 @@
 
31196
+/* -----------------------------------------------------------------------
 
31197
+   ffi_powerpc.h - Copyright (C) 2013 IBM
 
31198
+                   Copyright (C) 2011 Anthony Green
 
31199
+                   Copyright (C) 2011 Kyle Moffett
 
31200
+                   Copyright (C) 2008 Red Hat, Inc
 
31201
+                   Copyright (C) 2007, 2008 Free Software Foundation, Inc
 
31202
+                   Copyright (c) 1998 Geoffrey Keating
 
31203
+
 
31204
+   PowerPC Foreign Function Interface
 
31205
+
 
31206
+   Permission is hereby granted, free of charge, to any person obtaining
 
31207
+   a copy of this software and associated documentation files (the
 
31208
+   ``Software''), to deal in the Software without restriction, including
 
31209
+   without limitation the rights to use, copy, modify, merge, publish,
 
31210
+   distribute, sublicense, and/or sell copies of the Software, and to
 
31211
+   permit persons to whom the Software is furnished to do so, subject to
 
31212
+   the following conditions:
 
31213
+
 
31214
+   The above copyright notice and this permission notice shall be included
 
31215
+   in all copies or substantial portions of the Software.
 
31216
+
 
31217
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
31218
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
31219
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
31220
+   IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
 
31221
+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 
31222
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
31223
+   OTHER DEALINGS IN THE SOFTWARE.
 
31224
+   ----------------------------------------------------------------------- */
 
31225
+
 
31226
+enum {
 
31227
+  /* The assembly depends on these exact flags.  */
 
31228
+  /* These go in cr7 */
 
31229
+  FLAG_RETURNS_SMST    = 1 << (31-31), /* Used for FFI_SYSV small structs.  */
 
31230
+  FLAG_RETURNS_NOTHING  = 1 << (31-30),
 
31231
+  FLAG_RETURNS_FP       = 1 << (31-29),
 
31232
+  FLAG_RETURNS_64BITS   = 1 << (31-28),
 
31233
+
 
31234
+  /* This goes in cr6 */
 
31235
+  FLAG_RETURNS_128BITS  = 1 << (31-27),
 
31236
+
 
31237
+  FLAG_COMPAT          = 1 << (31- 8), /* Not used by assembly */
 
31238
+
 
31239
+  /* These go in cr1 */
 
31240
+  FLAG_ARG_NEEDS_COPY   = 1 << (31- 7), /* Used by sysv code */
 
31241
+  FLAG_ARG_NEEDS_PSAVE  = FLAG_ARG_NEEDS_COPY, /* Used by linux64 code */
 
31242
+  FLAG_FP_ARGUMENTS     = 1 << (31- 6), /* cr1.eq; specified by ABI */
 
31243
+  FLAG_4_GPR_ARGUMENTS  = 1 << (31- 5),
 
31244
+  FLAG_RETVAL_REFERENCE = 1 << (31- 4)
 
31245
+};
 
31246
+
 
31247
+typedef union
 
31248
+{
 
31249
+  float f;
 
31250
+  double d;
 
31251
+} ffi_dblfl;
 
31252
+
 
31253
+void FFI_HIDDEN ffi_closure_SYSV (void);
 
31254
+void FFI_HIDDEN ffi_call_SYSV(extended_cif *, unsigned, unsigned, unsigned *,
 
31255
+                             void (*)(void));
 
31256
+
 
31257
+void FFI_HIDDEN ffi_prep_types_sysv (ffi_abi);
 
31258
+ffi_status FFI_HIDDEN ffi_prep_cif_sysv (ffi_cif *);
 
31259
+int FFI_HIDDEN ffi_closure_helper_SYSV (ffi_closure *, void *, unsigned long *,
 
31260
+                                       ffi_dblfl *, unsigned long *);
 
31261
+
 
31262
+void FFI_HIDDEN ffi_call_LINUX64(extended_cif *, unsigned long, unsigned long,
 
31263
+                                unsigned long *, void (*)(void));
 
31264
+void FFI_HIDDEN ffi_closure_LINUX64 (void);
 
31265
+
 
31266
+void FFI_HIDDEN ffi_prep_types_linux64 (ffi_abi);
 
31267
+ffi_status FFI_HIDDEN ffi_prep_cif_linux64 (ffi_cif *);
 
31268
+ffi_status FFI_HIDDEN ffi_prep_cif_linux64_var (ffi_cif *, unsigned int,
 
31269
+                                               unsigned int);
 
31270
+void FFI_HIDDEN ffi_prep_args64 (extended_cif *, unsigned long *const);
 
31271
+int FFI_HIDDEN ffi_closure_helper_LINUX64 (ffi_closure *, void *,
 
31272
+                                          unsigned long *, ffi_dblfl *);
 
31273
--- a/src/libffi/src/powerpc/ffi_sysv.c
 
31274
+++ b/src/libffi/src/powerpc/ffi_sysv.c
 
31275
@@ -0,0 +1,931 @@
 
31276
+/* -----------------------------------------------------------------------
 
31277
+   ffi_sysv.c - Copyright (C) 2013 IBM
 
31278
+                Copyright (C) 2011 Anthony Green
 
31279
+                Copyright (C) 2011 Kyle Moffett
 
31280
+                Copyright (C) 2008 Red Hat, Inc
 
31281
+                Copyright (C) 2007, 2008 Free Software Foundation, Inc
 
31282
+                Copyright (c) 1998 Geoffrey Keating
 
31283
+
 
31284
+   PowerPC Foreign Function Interface
 
31285
+
 
31286
+   Permission is hereby granted, free of charge, to any person obtaining
 
31287
+   a copy of this software and associated documentation files (the
 
31288
+   ``Software''), to deal in the Software without restriction, including
 
31289
+   without limitation the rights to use, copy, modify, merge, publish,
 
31290
+   distribute, sublicense, and/or sell copies of the Software, and to
 
31291
+   permit persons to whom the Software is furnished to do so, subject to
 
31292
+   the following conditions:
 
31293
+
 
31294
+   The above copyright notice and this permission notice shall be included
 
31295
+   in all copies or substantial portions of the Software.
 
31296
+
 
31297
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
31298
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
31299
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
31300
+   IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
 
31301
+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 
31302
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
31303
+   OTHER DEALINGS IN THE SOFTWARE.
 
31304
+   ----------------------------------------------------------------------- */
 
31305
+
 
31306
+#include "ffi.h"
 
31307
+
 
31308
+#ifndef POWERPC64
 
31309
+#include "ffi_common.h"
 
31310
+#include "ffi_powerpc.h"
 
31311
+
 
31312
+
 
31313
+/* About the SYSV ABI.  */
 
31314
+#define ASM_NEEDS_REGISTERS 4
 
31315
+#define NUM_GPR_ARG_REGISTERS 8
 
31316
+#define NUM_FPR_ARG_REGISTERS 8
 
31317
+
 
31318
+
 
31319
+#if HAVE_LONG_DOUBLE_VARIANT && FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
31320
+/* Adjust size of ffi_type_longdouble.  */
 
31321
+void FFI_HIDDEN
 
31322
+ffi_prep_types_sysv (ffi_abi abi)
 
31323
+{
 
31324
+  if ((abi & (FFI_SYSV | FFI_SYSV_LONG_DOUBLE_128)) == FFI_SYSV)
 
31325
+    {
 
31326
+      ffi_type_longdouble.size = 8;
 
31327
+      ffi_type_longdouble.alignment = 8;
 
31328
+    }
 
31329
+  else
 
31330
+    {
 
31331
+      ffi_type_longdouble.size = 16;
 
31332
+      ffi_type_longdouble.alignment = 16;
 
31333
+    }
 
31334
+}
 
31335
+#endif
 
31336
+
 
31337
+/* Transform long double, double and float to other types as per abi.  */
 
31338
+static int
 
31339
+translate_float (int abi, int type)
 
31340
+{
 
31341
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
31342
+  if (type == FFI_TYPE_LONGDOUBLE
 
31343
+      && (abi & FFI_SYSV_LONG_DOUBLE_128) == 0)
 
31344
+    type = FFI_TYPE_DOUBLE;
 
31345
+#endif
 
31346
+  if ((abi & FFI_SYSV_SOFT_FLOAT) != 0)
 
31347
+    {
 
31348
+      if (type == FFI_TYPE_FLOAT)
 
31349
+       type = FFI_TYPE_UINT32;
 
31350
+      else if (type == FFI_TYPE_DOUBLE)
 
31351
+       type = FFI_TYPE_UINT64;
 
31352
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
31353
+      else if (type == FFI_TYPE_LONGDOUBLE)
 
31354
+       type = FFI_TYPE_UINT128;
 
31355
+    }
 
31356
+  else if ((abi & FFI_SYSV_IBM_LONG_DOUBLE) == 0)
 
31357
+    {
 
31358
+      if (type == FFI_TYPE_LONGDOUBLE)
 
31359
+       type = FFI_TYPE_STRUCT;
 
31360
+#endif
 
31361
+    }
 
31362
+  return type;
 
31363
+}
 
31364
+
 
31365
+/* Perform machine dependent cif processing */
 
31366
+static ffi_status
 
31367
+ffi_prep_cif_sysv_core (ffi_cif *cif)
 
31368
+{
 
31369
+  ffi_type **ptr;
 
31370
+  unsigned bytes;
 
31371
+  unsigned i, fparg_count = 0, intarg_count = 0;
 
31372
+  unsigned flags = cif->flags;
 
31373
+  unsigned struct_copy_size = 0;
 
31374
+  unsigned type = cif->rtype->type;
 
31375
+  unsigned size = cif->rtype->size;
 
31376
+
 
31377
+  /* The machine-independent calculation of cif->bytes doesn't work
 
31378
+     for us.  Redo the calculation.  */
 
31379
+
 
31380
+  /* Space for the frame pointer, callee's LR, and the asm's temp regs.  */
 
31381
+  bytes = (2 + ASM_NEEDS_REGISTERS) * sizeof (int);
 
31382
+
 
31383
+  /* Space for the GPR registers.  */
 
31384
+  bytes += NUM_GPR_ARG_REGISTERS * sizeof (int);
 
31385
+
 
31386
+  /* Return value handling.  The rules for SYSV are as follows:
 
31387
+     - 32-bit (or less) integer values are returned in gpr3;
 
31388
+     - Structures of size <= 4 bytes also returned in gpr3;
 
31389
+     - 64-bit integer values and structures between 5 and 8 bytes are returned
 
31390
+     in gpr3 and gpr4;
 
31391
+     - Larger structures are allocated space and a pointer is passed as
 
31392
+     the first argument.
 
31393
+     - Single/double FP values are returned in fpr1;
 
31394
+     - long doubles (if not equivalent to double) are returned in
 
31395
+     fpr1,fpr2 for Linux and as for large structs for SysV.  */
 
31396
+
 
31397
+  type = translate_float (cif->abi, type);
 
31398
+
 
31399
+  switch (type)
 
31400
+    {
 
31401
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
31402
+    case FFI_TYPE_LONGDOUBLE:
 
31403
+      flags |= FLAG_RETURNS_128BITS;
 
31404
+      /* Fall through.  */
 
31405
+#endif
 
31406
+    case FFI_TYPE_DOUBLE:
 
31407
+      flags |= FLAG_RETURNS_64BITS;
 
31408
+      /* Fall through.  */
 
31409
+    case FFI_TYPE_FLOAT:
 
31410
+      flags |= FLAG_RETURNS_FP;
 
31411
+#ifdef __NO_FPRS__
 
31412
+      return FFI_BAD_ABI;
 
31413
+#endif
 
31414
+      break;
 
31415
+
 
31416
+    case FFI_TYPE_UINT128:
 
31417
+      flags |= FLAG_RETURNS_128BITS;
 
31418
+      /* Fall through.  */
 
31419
+    case FFI_TYPE_UINT64:
 
31420
+    case FFI_TYPE_SINT64:
 
31421
+      flags |= FLAG_RETURNS_64BITS;
 
31422
+      break;
 
31423
+
 
31424
+    case FFI_TYPE_STRUCT:
 
31425
+      /* The final SYSV ABI says that structures smaller or equal 8 bytes
 
31426
+        are returned in r3/r4.  A draft ABI used by linux instead
 
31427
+        returns them in memory.  */
 
31428
+      if ((cif->abi & FFI_SYSV_STRUCT_RET) != 0 && size <= 8)
 
31429
+       {
 
31430
+         flags |= FLAG_RETURNS_SMST;
 
31431
+         break;
 
31432
+       }
 
31433
+      intarg_count++;
 
31434
+      flags |= FLAG_RETVAL_REFERENCE;
 
31435
+      /* Fall through.  */
 
31436
+    case FFI_TYPE_VOID:
 
31437
+      flags |= FLAG_RETURNS_NOTHING;
 
31438
+      break;
 
31439
+
 
31440
+    default:
 
31441
+      /* Returns 32-bit integer, or similar.  Nothing to do here.  */
 
31442
+      break;
 
31443
+    }
 
31444
+
 
31445
+  /* The first NUM_GPR_ARG_REGISTERS words of integer arguments, and the
 
31446
+     first NUM_FPR_ARG_REGISTERS fp arguments, go in registers; the rest
 
31447
+     goes on the stack.  Structures and long doubles (if not equivalent
 
31448
+     to double) are passed as a pointer to a copy of the structure.
 
31449
+     Stuff on the stack needs to keep proper alignment.  */
 
31450
+  for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
 
31451
+    {
 
31452
+      unsigned short typenum = (*ptr)->type;
 
31453
+
 
31454
+      typenum = translate_float (cif->abi, typenum);
 
31455
+
 
31456
+      switch (typenum)
 
31457
+       {
 
31458
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
31459
+       case FFI_TYPE_LONGDOUBLE:
 
31460
+         fparg_count++;
 
31461
+         /* Fall thru */
 
31462
+#endif
 
31463
+       case FFI_TYPE_DOUBLE:
 
31464
+         fparg_count++;
 
31465
+         /* If this FP arg is going on the stack, it must be
 
31466
+            8-byte-aligned.  */
 
31467
+         if (fparg_count > NUM_FPR_ARG_REGISTERS
 
31468
+             && intarg_count >= NUM_GPR_ARG_REGISTERS
 
31469
+             && intarg_count % 2 != 0)
 
31470
+           intarg_count++;
 
31471
+#ifdef __NO_FPRS__
 
31472
+         return FFI_BAD_ABI;
 
31473
+#endif
 
31474
+         break;
 
31475
+
 
31476
+       case FFI_TYPE_FLOAT:
 
31477
+         fparg_count++;
 
31478
+#ifdef __NO_FPRS__
 
31479
+         return FFI_BAD_ABI;
 
31480
+#endif
 
31481
+         break;
 
31482
+
 
31483
+       case FFI_TYPE_UINT128:
 
31484
+         /* A long double in FFI_LINUX_SOFT_FLOAT can use only a set
 
31485
+            of four consecutive gprs. If we do not have enough, we
 
31486
+            have to adjust the intarg_count value.  */
 
31487
+         if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3
 
31488
+             && intarg_count < NUM_GPR_ARG_REGISTERS)
 
31489
+           intarg_count = NUM_GPR_ARG_REGISTERS;
 
31490
+         intarg_count += 4;
 
31491
+         break;
 
31492
+
 
31493
+       case FFI_TYPE_UINT64:
 
31494
+       case FFI_TYPE_SINT64:
 
31495
+         /* 'long long' arguments are passed as two words, but
 
31496
+            either both words must fit in registers or both go
 
31497
+            on the stack.  If they go on the stack, they must
 
31498
+            be 8-byte-aligned.
 
31499
+
 
31500
+            Also, only certain register pairs can be used for
 
31501
+            passing long long int -- specifically (r3,r4), (r5,r6),
 
31502
+            (r7,r8), (r9,r10).  */
 
31503
+         if (intarg_count == NUM_GPR_ARG_REGISTERS-1
 
31504
+             || intarg_count % 2 != 0)
 
31505
+           intarg_count++;
 
31506
+         intarg_count += 2;
 
31507
+         break;
 
31508
+
 
31509
+       case FFI_TYPE_STRUCT:
 
31510
+         /* We must allocate space for a copy of these to enforce
 
31511
+            pass-by-value.  Pad the space up to a multiple of 16
 
31512
+            bytes (the maximum alignment required for anything under
 
31513
+            the SYSV ABI).  */
 
31514
+         struct_copy_size += ((*ptr)->size + 15) & ~0xF;
 
31515
+         /* Fall through (allocate space for the pointer).  */
 
31516
+
 
31517
+       case FFI_TYPE_POINTER:
 
31518
+       case FFI_TYPE_INT:
 
31519
+       case FFI_TYPE_UINT32:
 
31520
+       case FFI_TYPE_SINT32:
 
31521
+       case FFI_TYPE_UINT16:
 
31522
+       case FFI_TYPE_SINT16:
 
31523
+       case FFI_TYPE_UINT8:
 
31524
+       case FFI_TYPE_SINT8:
 
31525
+         /* Everything else is passed as a 4-byte word in a GPR, either
 
31526
+            the object itself or a pointer to it.  */
 
31527
+         intarg_count++;
 
31528
+         break;
 
31529
+
 
31530
+       default:
 
31531
+         FFI_ASSERT (0);
 
31532
+       }
 
31533
+    }
 
31534
+
 
31535
+  if (fparg_count != 0)
 
31536
+    flags |= FLAG_FP_ARGUMENTS;
 
31537
+  if (intarg_count > 4)
 
31538
+    flags |= FLAG_4_GPR_ARGUMENTS;
 
31539
+  if (struct_copy_size != 0)
 
31540
+    flags |= FLAG_ARG_NEEDS_COPY;
 
31541
+
 
31542
+  /* Space for the FPR registers, if needed.  */
 
31543
+  if (fparg_count != 0)
 
31544
+    bytes += NUM_FPR_ARG_REGISTERS * sizeof (double);
 
31545
+
 
31546
+  /* Stack space.  */
 
31547
+  if (intarg_count > NUM_GPR_ARG_REGISTERS)
 
31548
+    bytes += (intarg_count - NUM_GPR_ARG_REGISTERS) * sizeof (int);
 
31549
+  if (fparg_count > NUM_FPR_ARG_REGISTERS)
 
31550
+    bytes += (fparg_count - NUM_FPR_ARG_REGISTERS) * sizeof (double);
 
31551
+
 
31552
+  /* The stack space allocated needs to be a multiple of 16 bytes.  */
 
31553
+  bytes = (bytes + 15) & ~0xF;
 
31554
+
 
31555
+  /* Add in the space for the copied structures.  */
 
31556
+  bytes += struct_copy_size;
 
31557
+
 
31558
+  cif->flags = flags;
 
31559
+  cif->bytes = bytes;
 
31560
+
 
31561
+  return FFI_OK;
 
31562
+}
 
31563
+
 
31564
+ffi_status FFI_HIDDEN
 
31565
+ffi_prep_cif_sysv (ffi_cif *cif)
 
31566
+{
 
31567
+  if ((cif->abi & FFI_SYSV) == 0)
 
31568
+    {
 
31569
+      /* This call is from old code.  Translate to new ABI values.  */
 
31570
+      cif->flags |= FLAG_COMPAT;
 
31571
+      switch (cif->abi)
 
31572
+       {
 
31573
+       default:
 
31574
+         return FFI_BAD_ABI;
 
31575
+
 
31576
+       case FFI_COMPAT_SYSV:
 
31577
+         cif->abi = FFI_SYSV | FFI_SYSV_STRUCT_RET | FFI_SYSV_LONG_DOUBLE_128;
 
31578
+         break;
 
31579
+
 
31580
+       case FFI_COMPAT_GCC_SYSV:
 
31581
+         cif->abi = FFI_SYSV | FFI_SYSV_LONG_DOUBLE_128;
 
31582
+         break;
 
31583
+
 
31584
+       case FFI_COMPAT_LINUX:
 
31585
+         cif->abi = (FFI_SYSV | FFI_SYSV_IBM_LONG_DOUBLE
 
31586
+                     | FFI_SYSV_LONG_DOUBLE_128);
 
31587
+         break;
 
31588
+
 
31589
+       case FFI_COMPAT_LINUX_SOFT_FLOAT:
 
31590
+         cif->abi = (FFI_SYSV | FFI_SYSV_SOFT_FLOAT | FFI_SYSV_IBM_LONG_DOUBLE
 
31591
+                     | FFI_SYSV_LONG_DOUBLE_128);
 
31592
+         break;
 
31593
+       }
 
31594
+    }
 
31595
+  return ffi_prep_cif_sysv_core (cif);
 
31596
+}
 
31597
+
 
31598
+/* ffi_prep_args_SYSV is called by the assembly routine once stack space
 
31599
+   has been allocated for the function's arguments.
 
31600
+
 
31601
+   The stack layout we want looks like this:
 
31602
+
 
31603
+   |   Return address from ffi_call_SYSV 4bytes        |       higher addresses
 
31604
+   |--------------------------------------------|
 
31605
+   |   Previous backchain pointer      4       |       stack pointer here
 
31606
+   |--------------------------------------------|<+ <<<        on entry to
 
31607
+   |   Saved r28-r31                   4*4     | |     ffi_call_SYSV
 
31608
+   |--------------------------------------------| |
 
31609
+   |   GPR registers r3-r10            8*4     | |     ffi_call_SYSV
 
31610
+   |--------------------------------------------| |
 
31611
+   |   FPR registers f1-f8 (optional)  8*8     | |
 
31612
+   |--------------------------------------------| |    stack   |
 
31613
+   |   Space for copied structures             | |     grows   |
 
31614
+   |--------------------------------------------| |    down    V
 
31615
+   |   Parameters that didn't fit in registers  | |
 
31616
+   |--------------------------------------------| |    lower addresses
 
31617
+   |   Space for callee's LR           4       | |
 
31618
+   |--------------------------------------------| |    stack pointer here
 
31619
+   |   Current backchain pointer       4       |-/     during
 
31620
+   |--------------------------------------------|   <<<        ffi_call_SYSV
 
31621
+
 
31622
+*/
 
31623
+
 
31624
+void FFI_HIDDEN
 
31625
+ffi_prep_args_SYSV (extended_cif *ecif, unsigned *const stack)
 
31626
+{
 
31627
+  const unsigned bytes = ecif->cif->bytes;
 
31628
+  const unsigned flags = ecif->cif->flags;
 
31629
+
 
31630
+  typedef union
 
31631
+  {
 
31632
+    char *c;
 
31633
+    unsigned *u;
 
31634
+    long long *ll;
 
31635
+    float *f;
 
31636
+    double *d;
 
31637
+  } valp;
 
31638
+
 
31639
+  /* 'stacktop' points at the previous backchain pointer.  */
 
31640
+  valp stacktop;
 
31641
+
 
31642
+  /* 'gpr_base' points at the space for gpr3, and grows upwards as
 
31643
+     we use GPR registers.  */
 
31644
+  valp gpr_base;
 
31645
+  int intarg_count;
 
31646
+
 
31647
+#ifndef __NO_FPRS__
 
31648
+  /* 'fpr_base' points at the space for fpr1, and grows upwards as
 
31649
+     we use FPR registers.  */
 
31650
+  valp fpr_base;
 
31651
+  int fparg_count;
 
31652
+#endif
 
31653
+
 
31654
+  /* 'copy_space' grows down as we put structures in it.  It should
 
31655
+     stay 16-byte aligned.  */
 
31656
+  valp copy_space;
 
31657
+
 
31658
+  /* 'next_arg' grows up as we put parameters in it.  */
 
31659
+  valp next_arg;
 
31660
+
 
31661
+  int i;
 
31662
+  ffi_type **ptr;
 
31663
+#ifndef __NO_FPRS__
 
31664
+  double double_tmp;
 
31665
+#endif
 
31666
+  union
 
31667
+  {
 
31668
+    void **v;
 
31669
+    char **c;
 
31670
+    signed char **sc;
 
31671
+    unsigned char **uc;
 
31672
+    signed short **ss;
 
31673
+    unsigned short **us;
 
31674
+    unsigned int **ui;
 
31675
+    long long **ll;
 
31676
+    float **f;
 
31677
+    double **d;
 
31678
+  } p_argv;
 
31679
+  size_t struct_copy_size;
 
31680
+  unsigned gprvalue;
 
31681
+
 
31682
+  stacktop.c = (char *) stack + bytes;
 
31683
+  gpr_base.u = stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS;
 
31684
+  intarg_count = 0;
 
31685
+#ifndef __NO_FPRS__
 
31686
+  fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS;
 
31687
+  fparg_count = 0;
 
31688
+  copy_space.c = ((flags & FLAG_FP_ARGUMENTS) ? fpr_base.c : gpr_base.c);
 
31689
+#else
 
31690
+  copy_space.c = gpr_base.c;
 
31691
+#endif
 
31692
+  next_arg.u = stack + 2;
 
31693
+
 
31694
+  /* Check that everything starts aligned properly.  */
 
31695
+  FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0);
 
31696
+  FFI_ASSERT (((unsigned long) copy_space.c & 0xF) == 0);
 
31697
+  FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0);
 
31698
+  FFI_ASSERT ((bytes & 0xF) == 0);
 
31699
+  FFI_ASSERT (copy_space.c >= next_arg.c);
 
31700
+
 
31701
+  /* Deal with return values that are actually pass-by-reference.  */
 
31702
+  if (flags & FLAG_RETVAL_REFERENCE)
 
31703
+    {
 
31704
+      *gpr_base.u++ = (unsigned long) (char *) ecif->rvalue;
 
31705
+      intarg_count++;
 
31706
+    }
 
31707
+
 
31708
+  /* Now for the arguments.  */
 
31709
+  p_argv.v = ecif->avalue;
 
31710
+  for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
 
31711
+       i > 0;
 
31712
+       i--, ptr++, p_argv.v++)
 
31713
+    {
 
31714
+      unsigned int typenum = (*ptr)->type;
 
31715
+
 
31716
+      typenum = translate_float (ecif->cif->abi, typenum);
 
31717
+
 
31718
+      /* Now test the translated value */
 
31719
+      switch (typenum)
 
31720
+       {
 
31721
+#ifndef __NO_FPRS__
 
31722
+# if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
31723
+       case FFI_TYPE_LONGDOUBLE:
 
31724
+         double_tmp = (*p_argv.d)[0];
 
31725
+
 
31726
+         if (fparg_count >= NUM_FPR_ARG_REGISTERS - 1)
 
31727
+           {
 
31728
+             if (intarg_count >= NUM_GPR_ARG_REGISTERS
 
31729
+                 && intarg_count % 2 != 0)
 
31730
+               {
 
31731
+                 intarg_count++;
 
31732
+                 next_arg.u++;
 
31733
+               }
 
31734
+             *next_arg.d = double_tmp;
 
31735
+             next_arg.u += 2;
 
31736
+             double_tmp = (*p_argv.d)[1];
 
31737
+             *next_arg.d = double_tmp;
 
31738
+             next_arg.u += 2;
 
31739
+           }
 
31740
+         else
 
31741
+           {
 
31742
+             *fpr_base.d++ = double_tmp;
 
31743
+             double_tmp = (*p_argv.d)[1];
 
31744
+             *fpr_base.d++ = double_tmp;
 
31745
+           }
 
31746
+
 
31747
+         fparg_count += 2;
 
31748
+         FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
 
31749
+         break;
 
31750
+# endif
 
31751
+       case FFI_TYPE_DOUBLE:
 
31752
+         double_tmp = **p_argv.d;
 
31753
+
 
31754
+         if (fparg_count >= NUM_FPR_ARG_REGISTERS)
 
31755
+           {
 
31756
+             if (intarg_count >= NUM_GPR_ARG_REGISTERS
 
31757
+                 && intarg_count % 2 != 0)
 
31758
+               {
 
31759
+                 intarg_count++;
 
31760
+                 next_arg.u++;
 
31761
+               }
 
31762
+             *next_arg.d = double_tmp;
 
31763
+             next_arg.u += 2;
 
31764
+           }
 
31765
+         else
 
31766
+           *fpr_base.d++ = double_tmp;
 
31767
+         fparg_count++;
 
31768
+         FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
 
31769
+         break;
 
31770
+
 
31771
+       case FFI_TYPE_FLOAT:
 
31772
+         double_tmp = **p_argv.f;
 
31773
+         if (fparg_count >= NUM_FPR_ARG_REGISTERS)
 
31774
+           {
 
31775
+             *next_arg.f = (float) double_tmp;
 
31776
+             next_arg.u += 1;
 
31777
+             intarg_count++;
 
31778
+           }
 
31779
+         else
 
31780
+           *fpr_base.d++ = double_tmp;
 
31781
+         fparg_count++;
 
31782
+         FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
 
31783
+         break;
 
31784
+#endif /* have FPRs */
 
31785
+
 
31786
+       case FFI_TYPE_UINT128:
 
31787
+         /* The soft float ABI for long doubles works like this, a long double
 
31788
+            is passed in four consecutive GPRs if available.  A maximum of 2
 
31789
+            long doubles can be passed in gprs.  If we do not have 4 GPRs
 
31790
+            left, the long double is passed on the stack, 4-byte aligned.  */
 
31791
+         {
 
31792
+           unsigned int int_tmp;
 
31793
+           unsigned int ii;
 
31794
+           if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3)
 
31795
+             {
 
31796
+               if (intarg_count < NUM_GPR_ARG_REGISTERS)
 
31797
+                 intarg_count = NUM_GPR_ARG_REGISTERS;
 
31798
+               for (ii = 0; ii < 4; ii++)
 
31799
+                 {
 
31800
+                   int_tmp = (*p_argv.ui)[ii];
 
31801
+                   *next_arg.u++ = int_tmp;
 
31802
+                 }
 
31803
+             }
 
31804
+           else
 
31805
+             {
 
31806
+               for (ii = 0; ii < 4; ii++)
 
31807
+                 {
 
31808
+                   int_tmp = (*p_argv.ui)[ii];
 
31809
+                   *gpr_base.u++ = int_tmp;
 
31810
+                 }
 
31811
+             }
 
31812
+           intarg_count += 4;
 
31813
+           break;
 
31814
+         }
 
31815
+
 
31816
+       case FFI_TYPE_UINT64:
 
31817
+       case FFI_TYPE_SINT64:
 
31818
+         if (intarg_count == NUM_GPR_ARG_REGISTERS-1)
 
31819
+           intarg_count++;
 
31820
+         if (intarg_count >= NUM_GPR_ARG_REGISTERS)
 
31821
+           {
 
31822
+             if (intarg_count % 2 != 0)
 
31823
+               {
 
31824
+                 intarg_count++;
 
31825
+                 next_arg.u++;
 
31826
+               }
 
31827
+             *next_arg.ll = **p_argv.ll;
 
31828
+             next_arg.u += 2;
 
31829
+           }
 
31830
+         else
 
31831
+           {
 
31832
+             /* The abi states only certain register pairs can be
 
31833
+                used for passing long long int specifically (r3,r4),
 
31834
+                (r5,r6), (r7,r8), (r9,r10).  If next arg is long long
 
31835
+                but not correct starting register of pair then skip
 
31836
+                until the proper starting register.  */
 
31837
+             if (intarg_count % 2 != 0)
 
31838
+               {
 
31839
+                 intarg_count ++;
 
31840
+                 gpr_base.u++;
 
31841
+               }
 
31842
+             *gpr_base.ll++ = **p_argv.ll;
 
31843
+           }
 
31844
+         intarg_count += 2;
 
31845
+         break;
 
31846
+
 
31847
+       case FFI_TYPE_STRUCT:
 
31848
+         struct_copy_size = ((*ptr)->size + 15) & ~0xF;
 
31849
+         copy_space.c -= struct_copy_size;
 
31850
+         memcpy (copy_space.c, *p_argv.c, (*ptr)->size);
 
31851
+
 
31852
+         gprvalue = (unsigned long) copy_space.c;
 
31853
+
 
31854
+         FFI_ASSERT (copy_space.c > next_arg.c);
 
31855
+         FFI_ASSERT (flags & FLAG_ARG_NEEDS_COPY);
 
31856
+         goto putgpr;
 
31857
+
 
31858
+       case FFI_TYPE_UINT8:
 
31859
+         gprvalue = **p_argv.uc;
 
31860
+         goto putgpr;
 
31861
+       case FFI_TYPE_SINT8:
 
31862
+         gprvalue = **p_argv.sc;
 
31863
+         goto putgpr;
 
31864
+       case FFI_TYPE_UINT16:
 
31865
+         gprvalue = **p_argv.us;
 
31866
+         goto putgpr;
 
31867
+       case FFI_TYPE_SINT16:
 
31868
+         gprvalue = **p_argv.ss;
 
31869
+         goto putgpr;
 
31870
+
 
31871
+       case FFI_TYPE_INT:
 
31872
+       case FFI_TYPE_UINT32:
 
31873
+       case FFI_TYPE_SINT32:
 
31874
+       case FFI_TYPE_POINTER:
 
31875
+
 
31876
+         gprvalue = **p_argv.ui;
 
31877
+
 
31878
+       putgpr:
 
31879
+         if (intarg_count >= NUM_GPR_ARG_REGISTERS)
 
31880
+           *next_arg.u++ = gprvalue;
 
31881
+         else
 
31882
+           *gpr_base.u++ = gprvalue;
 
31883
+         intarg_count++;
 
31884
+         break;
 
31885
+       }
 
31886
+    }
 
31887
+
 
31888
+  /* Check that we didn't overrun the stack...  */
 
31889
+  FFI_ASSERT (copy_space.c >= next_arg.c);
 
31890
+  FFI_ASSERT (gpr_base.u <= stacktop.u - ASM_NEEDS_REGISTERS);
 
31891
+  /* The assert below is testing that the number of integer arguments agrees
 
31892
+     with the number found in ffi_prep_cif_machdep().  However, intarg_count
 
31893
+     is incremented whenever we place an FP arg on the stack, so account for
 
31894
+     that before our assert test.  */
 
31895
+#ifndef __NO_FPRS__
 
31896
+  if (fparg_count > NUM_FPR_ARG_REGISTERS)
 
31897
+    intarg_count -= fparg_count - NUM_FPR_ARG_REGISTERS;
 
31898
+  FFI_ASSERT (fpr_base.u
 
31899
+             <= stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS);
 
31900
+#endif
 
31901
+  FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4);
 
31902
+}
 
31903
+
 
31904
+#define MIN_CACHE_LINE_SIZE 8
 
31905
+
 
31906
+static void
 
31907
+flush_icache (char *wraddr, char *xaddr, int size)
 
31908
+{
 
31909
+  int i;
 
31910
+  for (i = 0; i < size; i += MIN_CACHE_LINE_SIZE)
 
31911
+    __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;"
 
31912
+                     : : "r" (xaddr + i), "r" (wraddr + i) : "memory");
 
31913
+  __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" "sync;" "isync;"
 
31914
+                   : : "r"(xaddr + size - 1), "r"(wraddr + size - 1)
 
31915
+                   : "memory");
 
31916
+}
 
31917
+
 
31918
+ffi_status FFI_HIDDEN
 
31919
+ffi_prep_closure_loc_sysv (ffi_closure *closure,
 
31920
+                          ffi_cif *cif,
 
31921
+                          void (*fun) (ffi_cif *, void *, void **, void *),
 
31922
+                          void *user_data,
 
31923
+                          void *codeloc)
 
31924
+{
 
31925
+  unsigned int *tramp;
 
31926
+
 
31927
+  if (cif->abi < FFI_SYSV || cif->abi >= FFI_LAST_ABI)
 
31928
+    return FFI_BAD_ABI;
 
31929
+
 
31930
+  tramp = (unsigned int *) &closure->tramp[0];
 
31931
+  tramp[0] = 0x7c0802a6;  /*   mflr    r0 */
 
31932
+  tramp[1] = 0x4800000d;  /*   bl      10 <trampoline_initial+0x10> */
 
31933
+  tramp[4] = 0x7d6802a6;  /*   mflr    r11 */
 
31934
+  tramp[5] = 0x7c0803a6;  /*   mtlr    r0 */
 
31935
+  tramp[6] = 0x800b0000;  /*   lwz     r0,0(r11) */
 
31936
+  tramp[7] = 0x816b0004;  /*   lwz     r11,4(r11) */
 
31937
+  tramp[8] = 0x7c0903a6;  /*   mtctr   r0 */
 
31938
+  tramp[9] = 0x4e800420;  /*   bctr */
 
31939
+  *(void **) &tramp[2] = (void *) ffi_closure_SYSV; /* function */
 
31940
+  *(void **) &tramp[3] = codeloc;                   /* context */
 
31941
+
 
31942
+  /* Flush the icache.  */
 
31943
+  flush_icache ((char *)tramp, (char *)codeloc, FFI_TRAMPOLINE_SIZE);
 
31944
+
 
31945
+  closure->cif = cif;
 
31946
+  closure->fun = fun;
 
31947
+  closure->user_data = user_data;
 
31948
+
 
31949
+  return FFI_OK;
 
31950
+}
 
31951
+
 
31952
+/* Basically the trampoline invokes ffi_closure_SYSV, and on
 
31953
+   entry, r11 holds the address of the closure.
 
31954
+   After storing the registers that could possibly contain
 
31955
+   parameters to be passed into the stack frame and setting
 
31956
+   up space for a return value, ffi_closure_SYSV invokes the
 
31957
+   following helper function to do most of the work.  */
 
31958
+
 
31959
+int
 
31960
+ffi_closure_helper_SYSV (ffi_closure *closure, void *rvalue,
 
31961
+                        unsigned long *pgr, ffi_dblfl *pfr,
 
31962
+                        unsigned long *pst)
 
31963
+{
 
31964
+  /* rvalue is the pointer to space for return value in closure assembly */
 
31965
+  /* pgr is the pointer to where r3-r10 are stored in ffi_closure_SYSV */
 
31966
+  /* pfr is the pointer to where f1-f8 are stored in ffi_closure_SYSV  */
 
31967
+  /* pst is the pointer to outgoing parameter stack in original caller */
 
31968
+
 
31969
+  void **          avalue;
 
31970
+  ffi_type **      arg_types;
 
31971
+  long             i, avn;
 
31972
+#ifndef __NO_FPRS__
 
31973
+  long             nf = 0;   /* number of floating registers already used */
 
31974
+#endif
 
31975
+  long             ng = 0;   /* number of general registers already used */
 
31976
+
 
31977
+  ffi_cif *cif = closure->cif;
 
31978
+  unsigned       size     = cif->rtype->size;
 
31979
+  unsigned short rtypenum = cif->rtype->type;
 
31980
+
 
31981
+  avalue = alloca (cif->nargs * sizeof (void *));
 
31982
+
 
31983
+  /* First translate for softfloat/nonlinux */
 
31984
+  rtypenum = translate_float (cif->abi, rtypenum);
 
31985
+
 
31986
+  /* Copy the caller's structure return value address so that the closure
 
31987
+     returns the data directly to the caller.
 
31988
+     For FFI_SYSV the result is passed in r3/r4 if the struct size is less
 
31989
+     or equal 8 bytes.  */
 
31990
+  if (rtypenum == FFI_TYPE_STRUCT
 
31991
+      && !((cif->abi & FFI_SYSV_STRUCT_RET) != 0 && size <= 8))
 
31992
+    {
 
31993
+      rvalue = (void *) *pgr;
 
31994
+      ng++;
 
31995
+      pgr++;
 
31996
+    }
 
31997
+
 
31998
+  i = 0;
 
31999
+  avn = cif->nargs;
 
32000
+  arg_types = cif->arg_types;
 
32001
+
 
32002
+  /* Grab the addresses of the arguments from the stack frame.  */
 
32003
+  while (i < avn) {
 
32004
+    unsigned short typenum = arg_types[i]->type;
 
32005
+
 
32006
+    /* We may need to handle some values depending on ABI.  */
 
32007
+    typenum = translate_float (cif->abi, typenum);
 
32008
+
 
32009
+    switch (typenum)
 
32010
+      {
 
32011
+#ifndef __NO_FPRS__
 
32012
+      case FFI_TYPE_FLOAT:
 
32013
+       /* Unfortunately float values are stored as doubles
 
32014
+          in the ffi_closure_SYSV code (since we don't check
 
32015
+          the type in that routine).  */
 
32016
+       if (nf < NUM_FPR_ARG_REGISTERS)
 
32017
+         {
 
32018
+           /* FIXME? here we are really changing the values
 
32019
+              stored in the original calling routines outgoing
 
32020
+              parameter stack.  This is probably a really
 
32021
+              naughty thing to do but...  */
 
32022
+           double temp = pfr->d;
 
32023
+           pfr->f = (float) temp;
 
32024
+           avalue[i] = pfr;
 
32025
+           nf++;
 
32026
+           pfr++;
 
32027
+         }
 
32028
+       else
 
32029
+         {
 
32030
+           avalue[i] = pst;
 
32031
+           pst += 1;
 
32032
+         }
 
32033
+       break;
 
32034
+
 
32035
+      case FFI_TYPE_DOUBLE:
 
32036
+       if (nf < NUM_FPR_ARG_REGISTERS)
 
32037
+         {
 
32038
+           avalue[i] = pfr;
 
32039
+           nf++;
 
32040
+           pfr++;
 
32041
+         }
 
32042
+       else
 
32043
+         {
 
32044
+           if (((long) pst) & 4)
 
32045
+             pst++;
 
32046
+           avalue[i] = pst;
 
32047
+           pst += 2;
 
32048
+         }
 
32049
+       break;
 
32050
+
 
32051
+# if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
32052
+      case FFI_TYPE_LONGDOUBLE:
 
32053
+       if (nf < NUM_FPR_ARG_REGISTERS - 1)
 
32054
+         {
 
32055
+           avalue[i] = pfr;
 
32056
+           pfr += 2;
 
32057
+           nf += 2;
 
32058
+         }
 
32059
+       else
 
32060
+         {
 
32061
+           if (((long) pst) & 4)
 
32062
+             pst++;
 
32063
+           avalue[i] = pst;
 
32064
+           pst += 4;
 
32065
+           nf = 8;
 
32066
+         }
 
32067
+       break;
 
32068
+# endif
 
32069
+#endif
 
32070
+
 
32071
+      case FFI_TYPE_UINT128:
 
32072
+       /* Test if for the whole long double, 4 gprs are available.
 
32073
+          otherwise the stuff ends up on the stack.  */
 
32074
+       if (ng < NUM_GPR_ARG_REGISTERS - 3)
 
32075
+         {
 
32076
+           avalue[i] = pgr;
 
32077
+           pgr += 4;
 
32078
+           ng += 4;
 
32079
+         }
 
32080
+       else
 
32081
+         {
 
32082
+           avalue[i] = pst;
 
32083
+           pst += 4;
 
32084
+           ng = 8+4;
 
32085
+         }
 
32086
+       break;
 
32087
+
 
32088
+      case FFI_TYPE_SINT8:
 
32089
+      case FFI_TYPE_UINT8:
 
32090
+#ifndef __LITTLE_ENDIAN__
 
32091
+       if (ng < NUM_GPR_ARG_REGISTERS)
 
32092
+         {
 
32093
+           avalue[i] = (char *) pgr + 3;
 
32094
+           ng++;
 
32095
+           pgr++;
 
32096
+         }
 
32097
+       else
 
32098
+         {
 
32099
+           avalue[i] = (char *) pst + 3;
 
32100
+           pst++;
 
32101
+         }
 
32102
+       break;
 
32103
+#endif
 
32104
+
 
32105
+      case FFI_TYPE_SINT16:
 
32106
+      case FFI_TYPE_UINT16:
 
32107
+#ifndef __LITTLE_ENDIAN__
 
32108
+       if (ng < NUM_GPR_ARG_REGISTERS)
 
32109
+         {
 
32110
+           avalue[i] = (char *) pgr + 2;
 
32111
+           ng++;
 
32112
+           pgr++;
 
32113
+         }
 
32114
+       else
 
32115
+         {
 
32116
+           avalue[i] = (char *) pst + 2;
 
32117
+           pst++;
 
32118
+         }
 
32119
+       break;
 
32120
+#endif
 
32121
+
 
32122
+      case FFI_TYPE_SINT32:
 
32123
+      case FFI_TYPE_UINT32:
 
32124
+      case FFI_TYPE_POINTER:
 
32125
+       if (ng < NUM_GPR_ARG_REGISTERS)
 
32126
+         {
 
32127
+           avalue[i] = pgr;
 
32128
+           ng++;
 
32129
+           pgr++;
 
32130
+         }
 
32131
+       else
 
32132
+         {
 
32133
+           avalue[i] = pst;
 
32134
+           pst++;
 
32135
+         }
 
32136
+       break;
 
32137
+
 
32138
+      case FFI_TYPE_STRUCT:
 
32139
+       /* Structs are passed by reference. The address will appear in a
 
32140
+          gpr if it is one of the first 8 arguments.  */
 
32141
+       if (ng < NUM_GPR_ARG_REGISTERS)
 
32142
+         {
 
32143
+           avalue[i] = (void *) *pgr;
 
32144
+           ng++;
 
32145
+           pgr++;
 
32146
+         }
 
32147
+       else
 
32148
+         {
 
32149
+           avalue[i] = (void *) *pst;
 
32150
+           pst++;
 
32151
+         }
 
32152
+       break;
 
32153
+
 
32154
+      case FFI_TYPE_SINT64:
 
32155
+      case FFI_TYPE_UINT64:
 
32156
+       /* Passing long long ints are complex, they must
 
32157
+          be passed in suitable register pairs such as
 
32158
+          (r3,r4) or (r5,r6) or (r6,r7), or (r7,r8) or (r9,r10)
 
32159
+          and if the entire pair aren't available then the outgoing
 
32160
+          parameter stack is used for both but an alignment of 8
 
32161
+          must will be kept.  So we must either look in pgr
 
32162
+          or pst to find the correct address for this type
 
32163
+          of parameter.  */
 
32164
+       if (ng < NUM_GPR_ARG_REGISTERS - 1)
 
32165
+         {
 
32166
+           if (ng & 1)
 
32167
+             {
 
32168
+               /* skip r4, r6, r8 as starting points */
 
32169
+               ng++;
 
32170
+               pgr++;
 
32171
+             }
 
32172
+           avalue[i] = pgr;
 
32173
+           ng += 2;
 
32174
+           pgr += 2;
 
32175
+         }
 
32176
+       else
 
32177
+         {
 
32178
+           if (((long) pst) & 4)
 
32179
+             pst++;
 
32180
+           avalue[i] = pst;
 
32181
+           pst += 2;
 
32182
+           ng = NUM_GPR_ARG_REGISTERS;
 
32183
+         }
 
32184
+       break;
 
32185
+
 
32186
+      default:
 
32187
+       FFI_ASSERT (0);
 
32188
+      }
 
32189
+
 
32190
+    i++;
 
32191
+  }
 
32192
+
 
32193
+  (closure->fun) (cif, rvalue, avalue, closure->user_data);
 
32194
+
 
32195
+  /* Tell ffi_closure_SYSV how to perform return type promotions.
 
32196
+     Because the FFI_SYSV ABI returns the structures <= 8 bytes in
 
32197
+     r3/r4 we have to tell ffi_closure_SYSV how to treat them.  We
 
32198
+     combine the base type FFI_SYSV_TYPE_SMALL_STRUCT with the size of
 
32199
+     the struct less one.  We never have a struct with size zero.
 
32200
+     See the comment in ffitarget.h about ordering.  */
 
32201
+  if (rtypenum == FFI_TYPE_STRUCT
 
32202
+      && (cif->abi & FFI_SYSV_STRUCT_RET) != 0 && size <= 8)
 
32203
+    return FFI_SYSV_TYPE_SMALL_STRUCT - 1 + size;
 
32204
+  return rtypenum;
 
32205
+}
 
32206
+#endif
 
32207
--- a/src/libffi/src/powerpc/linux64.S
 
32208
+++ b/src/libffi/src/powerpc/linux64.S
 
32209
@@ -29,18 +29,25 @@
 
32210
 #include <fficonfig.h>
 
32211
 #include <ffi.h>
 
32212
 
 
32213
-#ifdef __powerpc64__
 
32214
+#ifdef POWERPC64
 
32215
        .hidden ffi_call_LINUX64
 
32216
        .globl  ffi_call_LINUX64
 
32217
+# if _CALL_ELF == 2
 
32218
+       .text
 
32219
+ffi_call_LINUX64:
 
32220
+       addis   %r2, %r12, .TOC.-ffi_call_LINUX64@ha
 
32221
+       addi    %r2, %r2, .TOC.-ffi_call_LINUX64@l
 
32222
+       .localentry ffi_call_LINUX64, . - ffi_call_LINUX64
 
32223
+# else
 
32224
        .section        ".opd","aw"
 
32225
        .align  3
 
32226
 ffi_call_LINUX64:
 
32227
-#ifdef _CALL_LINUX
 
32228
+#  ifdef _CALL_LINUX
 
32229
        .quad   .L.ffi_call_LINUX64,.TOC.@tocbase,0
 
32230
        .type   ffi_call_LINUX64,@function
 
32231
        .text
 
32232
 .L.ffi_call_LINUX64:
 
32233
-#else
 
32234
+#  else
 
32235
        .hidden .ffi_call_LINUX64
 
32236
        .globl  .ffi_call_LINUX64
 
32237
        .quad   .ffi_call_LINUX64,.TOC.@tocbase,0
 
32238
@@ -48,7 +55,8 @@
 
32239
        .type   .ffi_call_LINUX64,@function
 
32240
        .text
 
32241
 .ffi_call_LINUX64:
 
32242
-#endif
 
32243
+#  endif
 
32244
+# endif
 
32245
 .LFB1:
 
32246
        mflr    %r0
 
32247
        std     %r28, -32(%r1)
 
32248
@@ -63,26 +71,35 @@
 
32249
        mr      %r31, %r5       /* flags, */
 
32250
        mr      %r30, %r6       /* rvalue, */
 
32251
        mr      %r29, %r7       /* function address.  */
 
32252
+/* Save toc pointer, not for the ffi_prep_args64 call, but for the later
 
32253
+   bctrl function call.  */
 
32254
+# if _CALL_ELF == 2
 
32255
+       std     %r2, 24(%r1)
 
32256
+# else
 
32257
        std     %r2, 40(%r1)
 
32258
+# endif
 
32259
 
 
32260
        /* Call ffi_prep_args64.  */
 
32261
        mr      %r4, %r1
 
32262
-#ifdef _CALL_LINUX
 
32263
+# if defined _CALL_LINUX || _CALL_ELF == 2
 
32264
        bl      ffi_prep_args64
 
32265
-#else
 
32266
+# else
 
32267
        bl      .ffi_prep_args64
 
32268
-#endif
 
32269
+# endif
 
32270
 
 
32271
-       ld      %r0, 0(%r29)
 
32272
+# if _CALL_ELF == 2
 
32273
+       mr      %r12, %r29
 
32274
+# else
 
32275
+       ld      %r12, 0(%r29)
 
32276
        ld      %r2, 8(%r29)
 
32277
        ld      %r11, 16(%r29)
 
32278
-
 
32279
+# endif
 
32280
        /* Now do the call.  */
 
32281
        /* Set up cr1 with bits 4-7 of the flags.  */
 
32282
        mtcrf   0x40, %r31
 
32283
 
 
32284
        /* Get the address to call into CTR.  */
 
32285
-       mtctr   %r0
 
32286
+       mtctr   %r12
 
32287
        /* Load all those argument registers.  */
 
32288
        ld      %r3, -32-(8*8)(%r28)
 
32289
        ld      %r4, -32-(7*8)(%r28)
 
32290
@@ -117,12 +134,17 @@
 
32291
 
 
32292
        /* This must follow the call immediately, the unwinder
 
32293
           uses this to find out if r2 has been saved or not.  */
 
32294
+# if _CALL_ELF == 2
 
32295
+       ld      %r2, 24(%r1)
 
32296
+# else
 
32297
        ld      %r2, 40(%r1)
 
32298
+# endif
 
32299
 
 
32300
        /* Now, deal with the return value.  */
 
32301
        mtcrf   0x01, %r31
 
32302
-       bt-     30, .Ldone_return_value
 
32303
-       bt-     29, .Lfp_return_value
 
32304
+       bt      31, .Lstruct_return_value
 
32305
+       bt      30, .Ldone_return_value
 
32306
+       bt      29, .Lfp_return_value
 
32307
        std     %r3, 0(%r30)
 
32308
        /* Fall through...  */
 
32309
 
 
32310
@@ -130,7 +152,7 @@
 
32311
        /* Restore the registers we used and return.  */
 
32312
        mr      %r1, %r28
 
32313
        ld      %r0, 16(%r28)
 
32314
-       ld      %r28, -32(%r1)
 
32315
+       ld      %r28, -32(%r28)
 
32316
        mtlr    %r0
 
32317
        ld      %r29, -24(%r1)
 
32318
        ld      %r30, -16(%r1)
 
32319
@@ -147,14 +169,48 @@
 
32320
 .Lfloat_return_value:
 
32321
        stfs    %f1, 0(%r30)
 
32322
        b       .Ldone_return_value
 
32323
+
 
32324
+.Lstruct_return_value:
 
32325
+       bf      29, .Lsmall_struct
 
32326
+       bf      28, .Lfloat_homog_return_value
 
32327
+       stfd    %f1, 0(%r30)
 
32328
+       stfd    %f2, 8(%r30)
 
32329
+       stfd    %f3, 16(%r30)
 
32330
+       stfd    %f4, 24(%r30)
 
32331
+       stfd    %f5, 32(%r30)
 
32332
+       stfd    %f6, 40(%r30)
 
32333
+       stfd    %f7, 48(%r30)
 
32334
+       stfd    %f8, 56(%r30)
 
32335
+       b       .Ldone_return_value
 
32336
+
 
32337
+.Lfloat_homog_return_value:
 
32338
+       stfs    %f1, 0(%r30)
 
32339
+       stfs    %f2, 4(%r30)
 
32340
+       stfs    %f3, 8(%r30)
 
32341
+       stfs    %f4, 12(%r30)
 
32342
+       stfs    %f5, 16(%r30)
 
32343
+       stfs    %f6, 20(%r30)
 
32344
+       stfs    %f7, 24(%r30)
 
32345
+       stfs    %f8, 28(%r30)
 
32346
+       b       .Ldone_return_value
 
32347
+
 
32348
+.Lsmall_struct:
 
32349
+       std     %r3, 0(%r30)
 
32350
+       std     %r4, 8(%r30)
 
32351
+       b       .Ldone_return_value
 
32352
+
 
32353
 .LFE1:
 
32354
        .long   0
 
32355
        .byte   0,12,0,1,128,4,0,0
 
32356
-#ifdef _CALL_LINUX
 
32357
+# if _CALL_ELF == 2
 
32358
+       .size   ffi_call_LINUX64,.-ffi_call_LINUX64
 
32359
+# else
 
32360
+#  ifdef _CALL_LINUX
 
32361
        .size   ffi_call_LINUX64,.-.L.ffi_call_LINUX64
 
32362
-#else
 
32363
+#  else
 
32364
        .size   .ffi_call_LINUX64,.-.ffi_call_LINUX64
 
32365
-#endif
 
32366
+#  endif
 
32367
+# endif
 
32368
 
 
32369
        .section        .eh_frame,EH_FRAME_FLAGS,@progbits
 
32370
 .Lframe1:
 
32371
@@ -197,8 +253,8 @@
 
32372
        .uleb128 0x4
 
32373
        .align 3
 
32374
 .LEFDE1:
 
32375
-#endif
 
32376
 
 
32377
-#if defined __ELF__ && defined __linux__
 
32378
+# if (defined __ELF__ && defined __linux__) || _CALL_ELF == 2
 
32379
        .section        .note.GNU-stack,"",@progbits
 
32380
+# endif
 
32381
 #endif
 
32382
--- a/src/libffi/src/powerpc/ffi_linux64.c
 
32383
+++ b/src/libffi/src/powerpc/ffi_linux64.c
 
32384
@@ -0,0 +1,942 @@
 
32385
+/* -----------------------------------------------------------------------
 
32386
+   ffi_linux64.c - Copyright (C) 2013 IBM
 
32387
+                   Copyright (C) 2011 Anthony Green
 
32388
+                   Copyright (C) 2011 Kyle Moffett
 
32389
+                   Copyright (C) 2008 Red Hat, Inc
 
32390
+                   Copyright (C) 2007, 2008 Free Software Foundation, Inc
 
32391
+                   Copyright (c) 1998 Geoffrey Keating
 
32392
+
 
32393
+   PowerPC Foreign Function Interface
 
32394
+
 
32395
+   Permission is hereby granted, free of charge, to any person obtaining
 
32396
+   a copy of this software and associated documentation files (the
 
32397
+   ``Software''), to deal in the Software without restriction, including
 
32398
+   without limitation the rights to use, copy, modify, merge, publish,
 
32399
+   distribute, sublicense, and/or sell copies of the Software, and to
 
32400
+   permit persons to whom the Software is furnished to do so, subject to
 
32401
+   the following conditions:
 
32402
+
 
32403
+   The above copyright notice and this permission notice shall be included
 
32404
+   in all copies or substantial portions of the Software.
 
32405
+
 
32406
+   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
 
32407
+   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
32408
+   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
32409
+   IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
 
32410
+   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 
32411
+   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 
32412
+   OTHER DEALINGS IN THE SOFTWARE.
 
32413
+   ----------------------------------------------------------------------- */
 
32414
+
 
32415
+#include "ffi.h"
 
32416
+
 
32417
+#ifdef POWERPC64
 
32418
+#include "ffi_common.h"
 
32419
+#include "ffi_powerpc.h"
 
32420
+
 
32421
+
 
32422
+/* About the LINUX64 ABI.  */
 
32423
+enum {
 
32424
+  NUM_GPR_ARG_REGISTERS64 = 8,
 
32425
+  NUM_FPR_ARG_REGISTERS64 = 13
 
32426
+};
 
32427
+enum { ASM_NEEDS_REGISTERS64 = 4 };
 
32428
+
 
32429
+
 
32430
+#if HAVE_LONG_DOUBLE_VARIANT && FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
32431
+/* Adjust size of ffi_type_longdouble.  */
 
32432
+void FFI_HIDDEN
 
32433
+ffi_prep_types_linux64 (ffi_abi abi)
 
32434
+{
 
32435
+  if ((abi & (FFI_LINUX | FFI_LINUX_LONG_DOUBLE_128)) == FFI_LINUX)
 
32436
+    {
 
32437
+      ffi_type_longdouble.size = 8;
 
32438
+      ffi_type_longdouble.alignment = 8;
 
32439
+    }
 
32440
+  else
 
32441
+    {
 
32442
+      ffi_type_longdouble.size = 16;
 
32443
+      ffi_type_longdouble.alignment = 16;
 
32444
+    }
 
32445
+}
 
32446
+#endif
 
32447
+
 
32448
+
 
32449
+#if _CALL_ELF == 2
 
32450
+static unsigned int
 
32451
+discover_homogeneous_aggregate (const ffi_type *t, unsigned int *elnum)
 
32452
+{
 
32453
+  switch (t->type)
 
32454
+    {
 
32455
+    case FFI_TYPE_FLOAT:
 
32456
+    case FFI_TYPE_DOUBLE:
 
32457
+      *elnum = 1;
 
32458
+      return (int) t->type;
 
32459
+
 
32460
+    case FFI_TYPE_STRUCT:;
 
32461
+      {
 
32462
+       unsigned int base_elt = 0, total_elnum = 0;
 
32463
+       ffi_type **el = t->elements;
 
32464
+       while (*el)
 
32465
+         {
 
32466
+           unsigned int el_elt, el_elnum = 0;
 
32467
+           el_elt = discover_homogeneous_aggregate (*el, &el_elnum);
 
32468
+           if (el_elt == 0
 
32469
+               || (base_elt && base_elt != el_elt))
 
32470
+             return 0;
 
32471
+           base_elt = el_elt;
 
32472
+           total_elnum += el_elnum;
 
32473
+           if (total_elnum > 8)
 
32474
+             return 0;
 
32475
+           el++;
 
32476
+         }
 
32477
+       *elnum = total_elnum;
 
32478
+       return base_elt;
 
32479
+      }
 
32480
+
 
32481
+    default:
 
32482
+      return 0;
 
32483
+    }
 
32484
+}
 
32485
+#endif
 
32486
+
 
32487
+
 
32488
+/* Perform machine dependent cif processing */
 
32489
+static ffi_status
 
32490
+ffi_prep_cif_linux64_core (ffi_cif *cif)
 
32491
+{
 
32492
+  ffi_type **ptr;
 
32493
+  unsigned bytes;
 
32494
+  unsigned i, fparg_count = 0, intarg_count = 0;
 
32495
+  unsigned flags = cif->flags;
 
32496
+#if _CALL_ELF == 2
 
32497
+  unsigned int elt, elnum;
 
32498
+#endif
 
32499
+
 
32500
+#if FFI_TYPE_LONGDOUBLE == FFI_TYPE_DOUBLE
 
32501
+  /* If compiled without long double support..  */
 
32502
+  if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
 
32503
+    return FFI_BAD_ABI;
 
32504
+#endif
 
32505
+
 
32506
+  /* The machine-independent calculation of cif->bytes doesn't work
 
32507
+     for us.  Redo the calculation.  */
 
32508
+#if _CALL_ELF == 2
 
32509
+  /* Space for backchain, CR, LR, TOC and the asm's temp regs.  */
 
32510
+  bytes = (4 + ASM_NEEDS_REGISTERS64) * sizeof (long);
 
32511
+
 
32512
+  /* Space for the general registers.  */
 
32513
+  bytes += NUM_GPR_ARG_REGISTERS64 * sizeof (long);
 
32514
+#else
 
32515
+  /* Space for backchain, CR, LR, cc/ld doubleword, TOC and the asm's temp
 
32516
+     regs.  */
 
32517
+  bytes = (6 + ASM_NEEDS_REGISTERS64) * sizeof (long);
 
32518
+
 
32519
+  /* Space for the mandatory parm save area and general registers.  */
 
32520
+  bytes += 2 * NUM_GPR_ARG_REGISTERS64 * sizeof (long);
 
32521
+#endif
 
32522
+
 
32523
+  /* Return value handling.  */
 
32524
+  switch (cif->rtype->type)
 
32525
+    {
 
32526
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
32527
+    case FFI_TYPE_LONGDOUBLE:
 
32528
+      if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
 
32529
+       flags |= FLAG_RETURNS_128BITS;
 
32530
+      /* Fall through.  */
 
32531
+#endif
 
32532
+    case FFI_TYPE_DOUBLE:
 
32533
+      flags |= FLAG_RETURNS_64BITS;
 
32534
+      /* Fall through.  */
 
32535
+    case FFI_TYPE_FLOAT:
 
32536
+      flags |= FLAG_RETURNS_FP;
 
32537
+      break;
 
32538
+
 
32539
+    case FFI_TYPE_UINT128:
 
32540
+      flags |= FLAG_RETURNS_128BITS;
 
32541
+      /* Fall through.  */
 
32542
+    case FFI_TYPE_UINT64:
 
32543
+    case FFI_TYPE_SINT64:
 
32544
+      flags |= FLAG_RETURNS_64BITS;
 
32545
+      break;
 
32546
+
 
32547
+    case FFI_TYPE_STRUCT:
 
32548
+#if _CALL_ELF == 2
 
32549
+      elt = discover_homogeneous_aggregate (cif->rtype, &elnum);
 
32550
+      if (elt)
 
32551
+       {
 
32552
+         if (elt == FFI_TYPE_DOUBLE)
 
32553
+           flags |= FLAG_RETURNS_64BITS;
 
32554
+         flags |= FLAG_RETURNS_FP | FLAG_RETURNS_SMST;
 
32555
+         break;
 
32556
+       }
 
32557
+      if (cif->rtype->size <= 16)
 
32558
+       {
 
32559
+         flags |= FLAG_RETURNS_SMST;
 
32560
+         break;
 
32561
+       }
 
32562
+#endif
 
32563
+      intarg_count++;
 
32564
+      flags |= FLAG_RETVAL_REFERENCE;
 
32565
+      /* Fall through.  */
 
32566
+    case FFI_TYPE_VOID:
 
32567
+      flags |= FLAG_RETURNS_NOTHING;
 
32568
+      break;
 
32569
+
 
32570
+    default:
 
32571
+      /* Returns 32-bit integer, or similar.  Nothing to do here.  */
 
32572
+      break;
 
32573
+    }
 
32574
+
 
32575
+  for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
 
32576
+    {
 
32577
+      unsigned int align;
 
32578
+
 
32579
+      switch ((*ptr)->type)
 
32580
+       {
 
32581
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
32582
+       case FFI_TYPE_LONGDOUBLE:
 
32583
+         if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
 
32584
+           {
 
32585
+             fparg_count++;
 
32586
+             intarg_count++;
 
32587
+           }
 
32588
+         /* Fall through.  */
 
32589
+#endif
 
32590
+       case FFI_TYPE_DOUBLE:
 
32591
+       case FFI_TYPE_FLOAT:
 
32592
+         fparg_count++;
 
32593
+         intarg_count++;
 
32594
+         if (fparg_count > NUM_FPR_ARG_REGISTERS64)
 
32595
+           flags |= FLAG_ARG_NEEDS_PSAVE;
 
32596
+         break;
 
32597
+
 
32598
+       case FFI_TYPE_STRUCT:
 
32599
+         if ((cif->abi & FFI_LINUX_STRUCT_ALIGN) != 0)
 
32600
+           {
 
32601
+             align = (*ptr)->alignment;
 
32602
+             if (align > 16)
 
32603
+               align = 16;
 
32604
+             align = align / 8;
 
32605
+             if (align > 1)
 
32606
+               intarg_count = ALIGN (intarg_count, align);
 
32607
+           }
 
32608
+         intarg_count += ((*ptr)->size + 7) / 8;
 
32609
+#if _CALL_ELF == 2
 
32610
+         elt = discover_homogeneous_aggregate (*ptr, &elnum);
 
32611
+         if (elt)
 
32612
+           {
 
32613
+             fparg_count += elnum;
 
32614
+             if (fparg_count > NUM_FPR_ARG_REGISTERS64)
 
32615
+               flags |= FLAG_ARG_NEEDS_PSAVE;
 
32616
+           }
 
32617
+         else
 
32618
+#endif
 
32619
+           {
 
32620
+             if (intarg_count > NUM_GPR_ARG_REGISTERS64)
 
32621
+               flags |= FLAG_ARG_NEEDS_PSAVE;
 
32622
+           }
 
32623
+         break;
 
32624
+
 
32625
+       case FFI_TYPE_POINTER:
 
32626
+       case FFI_TYPE_UINT64:
 
32627
+       case FFI_TYPE_SINT64:
 
32628
+       case FFI_TYPE_INT:
 
32629
+       case FFI_TYPE_UINT32:
 
32630
+       case FFI_TYPE_SINT32:
 
32631
+       case FFI_TYPE_UINT16:
 
32632
+       case FFI_TYPE_SINT16:
 
32633
+       case FFI_TYPE_UINT8:
 
32634
+       case FFI_TYPE_SINT8:
 
32635
+         /* Everything else is passed as a 8-byte word in a GPR, either
 
32636
+            the object itself or a pointer to it.  */
 
32637
+         intarg_count++;
 
32638
+         if (intarg_count > NUM_GPR_ARG_REGISTERS64)
 
32639
+           flags |= FLAG_ARG_NEEDS_PSAVE;
 
32640
+         break;
 
32641
+       default:
 
32642
+         FFI_ASSERT (0);
 
32643
+       }
 
32644
+    }
 
32645
+
 
32646
+  if (fparg_count != 0)
 
32647
+    flags |= FLAG_FP_ARGUMENTS;
 
32648
+  if (intarg_count > 4)
 
32649
+    flags |= FLAG_4_GPR_ARGUMENTS;
 
32650
+
 
32651
+  /* Space for the FPR registers, if needed.  */
 
32652
+  if (fparg_count != 0)
 
32653
+    bytes += NUM_FPR_ARG_REGISTERS64 * sizeof (double);
 
32654
+
 
32655
+  /* Stack space.  */
 
32656
+#if _CALL_ELF == 2
 
32657
+  if ((flags & FLAG_ARG_NEEDS_PSAVE) != 0)
 
32658
+    bytes += intarg_count * sizeof (long);
 
32659
+#else
 
32660
+  if (intarg_count > NUM_GPR_ARG_REGISTERS64)
 
32661
+    bytes += (intarg_count - NUM_GPR_ARG_REGISTERS64) * sizeof (long);
 
32662
+#endif
 
32663
+
 
32664
+  /* The stack space allocated needs to be a multiple of 16 bytes.  */
 
32665
+  bytes = (bytes + 15) & ~0xF;
 
32666
+
 
32667
+  cif->flags = flags;
 
32668
+  cif->bytes = bytes;
 
32669
+
 
32670
+  return FFI_OK;
 
32671
+}
 
32672
+
 
32673
+ffi_status FFI_HIDDEN
 
32674
+ffi_prep_cif_linux64 (ffi_cif *cif)
 
32675
+{
 
32676
+  if ((cif->abi & FFI_LINUX) != 0)
 
32677
+    cif->nfixedargs = cif->nargs;
 
32678
+#if _CALL_ELF != 2
 
32679
+  else if (cif->abi == FFI_COMPAT_LINUX64)
 
32680
+    {
 
32681
+      /* This call is from old code.  Don't touch cif->nfixedargs
 
32682
+        since old code will be using a smaller cif.  */
 
32683
+      cif->flags |= FLAG_COMPAT;
 
32684
+      /* Translate to new abi value.  */
 
32685
+      cif->abi = FFI_LINUX | FFI_LINUX_LONG_DOUBLE_128;
 
32686
+    }
 
32687
+#endif
 
32688
+  else
 
32689
+    return FFI_BAD_ABI;
 
32690
+  return ffi_prep_cif_linux64_core (cif);
 
32691
+}
 
32692
+
 
32693
+ffi_status FFI_HIDDEN
 
32694
+ffi_prep_cif_linux64_var (ffi_cif *cif,
 
32695
+                         unsigned int nfixedargs,
 
32696
+                         unsigned int ntotalargs MAYBE_UNUSED)
 
32697
+{
 
32698
+  if ((cif->abi & FFI_LINUX) != 0)
 
32699
+    cif->nfixedargs = nfixedargs;
 
32700
+#if _CALL_ELF != 2
 
32701
+  else if (cif->abi == FFI_COMPAT_LINUX64)
 
32702
+    {
 
32703
+      /* This call is from old code.  Don't touch cif->nfixedargs
 
32704
+        since old code will be using a smaller cif.  */
 
32705
+      cif->flags |= FLAG_COMPAT;
 
32706
+      /* Translate to new abi value.  */
 
32707
+      cif->abi = FFI_LINUX | FFI_LINUX_LONG_DOUBLE_128;
 
32708
+    }
 
32709
+#endif
 
32710
+  else
 
32711
+    return FFI_BAD_ABI;
 
32712
+#if _CALL_ELF == 2
 
32713
+  cif->flags |= FLAG_ARG_NEEDS_PSAVE;
 
32714
+#endif
 
32715
+  return ffi_prep_cif_linux64_core (cif);
 
32716
+}
 
32717
+
 
32718
+
 
32719
+/* ffi_prep_args64 is called by the assembly routine once stack space
 
32720
+   has been allocated for the function's arguments.
 
32721
+
 
32722
+   The stack layout we want looks like this:
 
32723
+
 
32724
+   |   Ret addr from ffi_call_LINUX64  8bytes  |       higher addresses
 
32725
+   |--------------------------------------------|
 
32726
+   |   CR save area                    8bytes  |
 
32727
+   |--------------------------------------------|
 
32728
+   |   Previous backchain pointer      8       |       stack pointer here
 
32729
+   |--------------------------------------------|<+ <<<        on entry to
 
32730
+   |   Saved r28-r31                   4*8     | |     ffi_call_LINUX64
 
32731
+   |--------------------------------------------| |
 
32732
+   |   GPR registers r3-r10            8*8     | |
 
32733
+   |--------------------------------------------| |
 
32734
+   |   FPR registers f1-f13 (optional) 13*8    | |
 
32735
+   |--------------------------------------------| |
 
32736
+   |   Parameter save area                     | |
 
32737
+   |--------------------------------------------| |
 
32738
+   |   TOC save area                   8       | |
 
32739
+   |--------------------------------------------| |    stack   |
 
32740
+   |   Linker doubleword               8       | |     grows   |
 
32741
+   |--------------------------------------------| |    down    V
 
32742
+   |   Compiler doubleword             8       | |
 
32743
+   |--------------------------------------------| |    lower addresses
 
32744
+   |   Space for callee's LR           8       | |
 
32745
+   |--------------------------------------------| |
 
32746
+   |   CR save area                    8       | |
 
32747
+   |--------------------------------------------| |    stack pointer here
 
32748
+   |   Current backchain pointer       8       |-/     during
 
32749
+   |--------------------------------------------|   <<<        ffi_call_LINUX64
 
32750
+
 
32751
+*/
 
32752
+
 
32753
+void FFI_HIDDEN
 
32754
+ffi_prep_args64 (extended_cif *ecif, unsigned long *const stack)
 
32755
+{
 
32756
+  const unsigned long bytes = ecif->cif->bytes;
 
32757
+  const unsigned long flags = ecif->cif->flags;
 
32758
+
 
32759
+  typedef union
 
32760
+  {
 
32761
+    char *c;
 
32762
+    unsigned long *ul;
 
32763
+    float *f;
 
32764
+    double *d;
 
32765
+    size_t p;
 
32766
+  } valp;
 
32767
+
 
32768
+  /* 'stacktop' points at the previous backchain pointer.  */
 
32769
+  valp stacktop;
 
32770
+
 
32771
+  /* 'next_arg' points at the space for gpr3, and grows upwards as
 
32772
+     we use GPR registers, then continues at rest.  */
 
32773
+  valp gpr_base;
 
32774
+  valp gpr_end;
 
32775
+  valp rest;
 
32776
+  valp next_arg;
 
32777
+
 
32778
+  /* 'fpr_base' points at the space for fpr3, and grows upwards as
 
32779
+     we use FPR registers.  */
 
32780
+  valp fpr_base;
 
32781
+  unsigned int fparg_count;
 
32782
+
 
32783
+  unsigned int i, words, nargs, nfixedargs;
 
32784
+  ffi_type **ptr;
 
32785
+  double double_tmp;
 
32786
+  union
 
32787
+  {
 
32788
+    void **v;
 
32789
+    char **c;
 
32790
+    signed char **sc;
 
32791
+    unsigned char **uc;
 
32792
+    signed short **ss;
 
32793
+    unsigned short **us;
 
32794
+    signed int **si;
 
32795
+    unsigned int **ui;
 
32796
+    unsigned long **ul;
 
32797
+    float **f;
 
32798
+    double **d;
 
32799
+  } p_argv;
 
32800
+  unsigned long gprvalue;
 
32801
+  unsigned long align;
 
32802
+
 
32803
+  stacktop.c = (char *) stack + bytes;
 
32804
+  gpr_base.ul = stacktop.ul - ASM_NEEDS_REGISTERS64 - NUM_GPR_ARG_REGISTERS64;
 
32805
+  gpr_end.ul = gpr_base.ul + NUM_GPR_ARG_REGISTERS64;
 
32806
+#if _CALL_ELF == 2
 
32807
+  rest.ul = stack + 4 + NUM_GPR_ARG_REGISTERS64;
 
32808
+#else
 
32809
+  rest.ul = stack + 6 + NUM_GPR_ARG_REGISTERS64;
 
32810
+#endif
 
32811
+  fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS64;
 
32812
+  fparg_count = 0;
 
32813
+  next_arg.ul = gpr_base.ul;
 
32814
+
 
32815
+  /* Check that everything starts aligned properly.  */
 
32816
+  FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0);
 
32817
+  FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0);
 
32818
+  FFI_ASSERT ((bytes & 0xF) == 0);
 
32819
+
 
32820
+  /* Deal with return values that are actually pass-by-reference.  */
 
32821
+  if (flags & FLAG_RETVAL_REFERENCE)
 
32822
+    *next_arg.ul++ = (unsigned long) (char *) ecif->rvalue;
 
32823
+
 
32824
+  /* Now for the arguments.  */
 
32825
+  p_argv.v = ecif->avalue;
 
32826
+  nargs = ecif->cif->nargs;
 
32827
+#if _CALL_ELF != 2
 
32828
+  nfixedargs = (unsigned) -1;
 
32829
+  if ((flags & FLAG_COMPAT) == 0)
 
32830
+#endif
 
32831
+    nfixedargs = ecif->cif->nfixedargs;
 
32832
+  for (ptr = ecif->cif->arg_types, i = 0;
 
32833
+       i < nargs;
 
32834
+       i++, ptr++, p_argv.v++)
 
32835
+    {
 
32836
+#if _CALL_ELF == 2
 
32837
+      unsigned int elt, elnum;
 
32838
+#endif
 
32839
+
 
32840
+      switch ((*ptr)->type)
 
32841
+       {
 
32842
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
32843
+       case FFI_TYPE_LONGDOUBLE:
 
32844
+         if ((ecif->cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
 
32845
+           {
 
32846
+             double_tmp = (*p_argv.d)[0];
 
32847
+             if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
 
32848
+               {
 
32849
+                 *fpr_base.d++ = double_tmp;
 
32850
+# if _CALL_ELF != 2
 
32851
+                 if ((flags & FLAG_COMPAT) != 0)
 
32852
+                   *next_arg.d = double_tmp;
 
32853
+# endif
 
32854
+               }
 
32855
+             else
 
32856
+               *next_arg.d = double_tmp;
 
32857
+             if (++next_arg.ul == gpr_end.ul)
 
32858
+               next_arg.ul = rest.ul;
 
32859
+             fparg_count++;
 
32860
+             double_tmp = (*p_argv.d)[1];
 
32861
+             if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
 
32862
+               {
 
32863
+                 *fpr_base.d++ = double_tmp;
 
32864
+# if _CALL_ELF != 2
 
32865
+                 if ((flags & FLAG_COMPAT) != 0)
 
32866
+                   *next_arg.d = double_tmp;
 
32867
+# endif
 
32868
+               }
 
32869
+             else
 
32870
+               *next_arg.d = double_tmp;
 
32871
+             if (++next_arg.ul == gpr_end.ul)
 
32872
+               next_arg.ul = rest.ul;
 
32873
+             fparg_count++;
 
32874
+             FFI_ASSERT (__LDBL_MANT_DIG__ == 106);
 
32875
+             FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
 
32876
+             break;
 
32877
+           }
 
32878
+         /* Fall through.  */
 
32879
+#endif
 
32880
+       case FFI_TYPE_DOUBLE:
 
32881
+         double_tmp = **p_argv.d;
 
32882
+         if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
 
32883
+           {
 
32884
+             *fpr_base.d++ = double_tmp;
 
32885
+#if _CALL_ELF != 2
 
32886
+             if ((flags & FLAG_COMPAT) != 0)
 
32887
+               *next_arg.d = double_tmp;
 
32888
+#endif
 
32889
+           }
 
32890
+         else
 
32891
+           *next_arg.d = double_tmp;
 
32892
+         if (++next_arg.ul == gpr_end.ul)
 
32893
+           next_arg.ul = rest.ul;
 
32894
+         fparg_count++;
 
32895
+         FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
 
32896
+         break;
 
32897
+
 
32898
+       case FFI_TYPE_FLOAT:
 
32899
+         double_tmp = **p_argv.f;
 
32900
+         if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
 
32901
+           {
 
32902
+             *fpr_base.d++ = double_tmp;
 
32903
+#if _CALL_ELF != 2
 
32904
+             if ((flags & FLAG_COMPAT) != 0)
 
32905
+               *next_arg.f = (float) double_tmp;
 
32906
+#endif
 
32907
+           }
 
32908
+         else
 
32909
+           *next_arg.f = (float) double_tmp;
 
32910
+         if (++next_arg.ul == gpr_end.ul)
 
32911
+           next_arg.ul = rest.ul;
 
32912
+         fparg_count++;
 
32913
+         FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
 
32914
+         break;
 
32915
+
 
32916
+       case FFI_TYPE_STRUCT:
 
32917
+         if ((ecif->cif->abi & FFI_LINUX_STRUCT_ALIGN) != 0)
 
32918
+           {
 
32919
+             align = (*ptr)->alignment;
 
32920
+             if (align > 16)
 
32921
+               align = 16;
 
32922
+             if (align > 1)
 
32923
+               next_arg.p = ALIGN (next_arg.p, align);
 
32924
+           }
 
32925
+#if _CALL_ELF == 2
 
32926
+         elt = discover_homogeneous_aggregate (*ptr, &elnum);
 
32927
+         if (elt)
 
32928
+           {
 
32929
+             union {
 
32930
+               void *v;
 
32931
+               float *f;
 
32932
+               double *d;
 
32933
+             } arg;
 
32934
+
 
32935
+             arg.v = *p_argv.v;
 
32936
+             if (elt == FFI_TYPE_FLOAT)
 
32937
+               {
 
32938
+                 do
 
32939
+                   {
 
32940
+                     double_tmp = *arg.f++;
 
32941
+                     if (fparg_count < NUM_FPR_ARG_REGISTERS64
 
32942
+                         && i < nfixedargs)
 
32943
+                       *fpr_base.d++ = double_tmp;
 
32944
+                     else
 
32945
+                       *next_arg.f = (float) double_tmp;
 
32946
+                     if (++next_arg.f == gpr_end.f)
 
32947
+                       next_arg.f = rest.f;
 
32948
+                     fparg_count++;
 
32949
+                   }
 
32950
+                 while (--elnum != 0);
 
32951
+                 if ((next_arg.p & 3) != 0)
 
32952
+                   {
 
32953
+                     if (++next_arg.f == gpr_end.f)
 
32954
+                       next_arg.f = rest.f;
 
32955
+                   }
 
32956
+               }
 
32957
+             else
 
32958
+               do
 
32959
+                 {
 
32960
+                   double_tmp = *arg.d++;
 
32961
+                   if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
 
32962
+                     *fpr_base.d++ = double_tmp;
 
32963
+                   else
 
32964
+                     *next_arg.d = double_tmp;
 
32965
+                   if (++next_arg.d == gpr_end.d)
 
32966
+                     next_arg.d = rest.d;
 
32967
+                   fparg_count++;
 
32968
+                 }
 
32969
+               while (--elnum != 0);
 
32970
+           }
 
32971
+         else
 
32972
+#endif
 
32973
+           {
 
32974
+             words = ((*ptr)->size + 7) / 8;
 
32975
+             if (next_arg.ul >= gpr_base.ul && next_arg.ul + words > gpr_end.ul)
 
32976
+               {
 
32977
+                 size_t first = gpr_end.c - next_arg.c;
 
32978
+                 memcpy (next_arg.c, *p_argv.c, first);
 
32979
+                 memcpy (rest.c, *p_argv.c + first, (*ptr)->size - first);
 
32980
+                 next_arg.c = rest.c + words * 8 - first;
 
32981
+               }
 
32982
+             else
 
32983
+               {
 
32984
+                 char *where = next_arg.c;
 
32985
+
 
32986
+#ifndef __LITTLE_ENDIAN__
 
32987
+                 /* Structures with size less than eight bytes are passed
 
32988
+                    left-padded.  */
 
32989
+                 if ((*ptr)->size < 8)
 
32990
+                   where += 8 - (*ptr)->size;
 
32991
+#endif
 
32992
+                 memcpy (where, *p_argv.c, (*ptr)->size);
 
32993
+                 next_arg.ul += words;
 
32994
+                 if (next_arg.ul == gpr_end.ul)
 
32995
+                   next_arg.ul = rest.ul;
 
32996
+               }
 
32997
+           }
 
32998
+         break;
 
32999
+
 
33000
+       case FFI_TYPE_UINT8:
 
33001
+         gprvalue = **p_argv.uc;
 
33002
+         goto putgpr;
 
33003
+       case FFI_TYPE_SINT8:
 
33004
+         gprvalue = **p_argv.sc;
 
33005
+         goto putgpr;
 
33006
+       case FFI_TYPE_UINT16:
 
33007
+         gprvalue = **p_argv.us;
 
33008
+         goto putgpr;
 
33009
+       case FFI_TYPE_SINT16:
 
33010
+         gprvalue = **p_argv.ss;
 
33011
+         goto putgpr;
 
33012
+       case FFI_TYPE_UINT32:
 
33013
+         gprvalue = **p_argv.ui;
 
33014
+         goto putgpr;
 
33015
+       case FFI_TYPE_INT:
 
33016
+       case FFI_TYPE_SINT32:
 
33017
+         gprvalue = **p_argv.si;
 
33018
+         goto putgpr;
 
33019
+
 
33020
+       case FFI_TYPE_UINT64:
 
33021
+       case FFI_TYPE_SINT64:
 
33022
+       case FFI_TYPE_POINTER:
 
33023
+         gprvalue = **p_argv.ul;
 
33024
+       putgpr:
 
33025
+         *next_arg.ul++ = gprvalue;
 
33026
+         if (next_arg.ul == gpr_end.ul)
 
33027
+           next_arg.ul = rest.ul;
 
33028
+         break;
 
33029
+       }
 
33030
+    }
 
33031
+
 
33032
+  FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS
 
33033
+             || (next_arg.ul >= gpr_base.ul
 
33034
+                 && next_arg.ul <= gpr_base.ul + 4));
 
33035
+}
 
33036
+
 
33037
+
 
33038
+#if _CALL_ELF == 2
 
33039
+#define MIN_CACHE_LINE_SIZE 8
 
33040
+
 
33041
+static void
 
33042
+flush_icache (char *wraddr, char *xaddr, int size)
 
33043
+{
 
33044
+  int i;
 
33045
+  for (i = 0; i < size; i += MIN_CACHE_LINE_SIZE)
 
33046
+    __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;"
 
33047
+                     : : "r" (xaddr + i), "r" (wraddr + i) : "memory");
 
33048
+  __asm__ volatile ("icbi 0,%0;" "dcbf 0,%1;" "sync;" "isync;"
 
33049
+                   : : "r"(xaddr + size - 1), "r"(wraddr + size - 1)
 
33050
+                   : "memory");
 
33051
+}
 
33052
+#endif
 
33053
+
 
33054
+ffi_status
 
33055
+ffi_prep_closure_loc_linux64 (ffi_closure *closure,
 
33056
+                             ffi_cif *cif,
 
33057
+                             void (*fun) (ffi_cif *, void *, void **, void *),
 
33058
+                             void *user_data,
 
33059
+                             void *codeloc)
 
33060
+{
 
33061
+#if _CALL_ELF == 2
 
33062
+  unsigned int *tramp = (unsigned int *) &closure->tramp[0];
 
33063
+
 
33064
+  if (cif->abi < FFI_LINUX || cif->abi >= FFI_LAST_ABI)
 
33065
+    return FFI_BAD_ABI;
 
33066
+
 
33067
+  tramp[0] = 0xe96c0018;       /* 0:   ld      11,2f-0b(12)    */
 
33068
+  tramp[1] = 0xe98c0010;       /*      ld      12,1f-0b(12)    */
 
33069
+  tramp[2] = 0x7d8903a6;       /*      mtctr   12              */
 
33070
+  tramp[3] = 0x4e800420;       /*      bctr                    */
 
33071
+                               /* 1:   .quad   function_addr   */
 
33072
+                               /* 2:   .quad   context         */
 
33073
+  *(void **) &tramp[4] = (void *) ffi_closure_LINUX64;
 
33074
+  *(void **) &tramp[6] = codeloc;
 
33075
+  flush_icache ((char *)tramp, (char *)codeloc, FFI_TRAMPOLINE_SIZE);
 
33076
+#else
 
33077
+  void **tramp = (void **) &closure->tramp[0];
 
33078
+
 
33079
+  if (cif->abi < FFI_LINUX || cif->abi >= FFI_LAST_ABI)
 
33080
+    return FFI_BAD_ABI;
 
33081
+
 
33082
+  /* Copy function address and TOC from ffi_closure_LINUX64.  */
 
33083
+  memcpy (tramp, (char *) ffi_closure_LINUX64, 16);
 
33084
+  tramp[2] = codeloc;
 
33085
+#endif
 
33086
+
 
33087
+  closure->cif = cif;
 
33088
+  closure->fun = fun;
 
33089
+  closure->user_data = user_data;
 
33090
+
 
33091
+  return FFI_OK;
 
33092
+}
 
33093
+
 
33094
+
 
33095
+int FFI_HIDDEN
 
33096
+ffi_closure_helper_LINUX64 (ffi_closure *closure, void *rvalue,
 
33097
+                           unsigned long *pst, ffi_dblfl *pfr)
 
33098
+{
 
33099
+  /* rvalue is the pointer to space for return value in closure assembly */
 
33100
+  /* pst is the pointer to parameter save area
 
33101
+     (r3-r10 are stored into its first 8 slots by ffi_closure_LINUX64) */
 
33102
+  /* pfr is the pointer to where f1-f13 are stored in ffi_closure_LINUX64 */
 
33103
+
 
33104
+  void **avalue;
 
33105
+  ffi_type **arg_types;
 
33106
+  unsigned long i, avn, nfixedargs;
 
33107
+  ffi_cif *cif;
 
33108
+  ffi_dblfl *end_pfr = pfr + NUM_FPR_ARG_REGISTERS64;
 
33109
+  unsigned long align;
 
33110
+
 
33111
+  cif = closure->cif;
 
33112
+  avalue = alloca (cif->nargs * sizeof (void *));
 
33113
+
 
33114
+  /* Copy the caller's structure return value address so that the
 
33115
+     closure returns the data directly to the caller.  */
 
33116
+  if (cif->rtype->type == FFI_TYPE_STRUCT
 
33117
+      && (cif->flags & FLAG_RETURNS_SMST) == 0)
 
33118
+    {
 
33119
+      rvalue = (void *) *pst;
 
33120
+      pst++;
 
33121
+    }
 
33122
+
 
33123
+  i = 0;
 
33124
+  avn = cif->nargs;
 
33125
+#if _CALL_ELF != 2
 
33126
+  nfixedargs = (unsigned) -1;
 
33127
+  if ((cif->flags & FLAG_COMPAT) == 0)
 
33128
+#endif
 
33129
+    nfixedargs = cif->nfixedargs;
 
33130
+  arg_types = cif->arg_types;
 
33131
+
 
33132
+  /* Grab the addresses of the arguments from the stack frame.  */
 
33133
+  while (i < avn)
 
33134
+    {
 
33135
+      unsigned int elt, elnum;
 
33136
+
 
33137
+      switch (arg_types[i]->type)
 
33138
+       {
 
33139
+       case FFI_TYPE_SINT8:
 
33140
+       case FFI_TYPE_UINT8:
 
33141
+#ifndef __LITTLE_ENDIAN__
 
33142
+         avalue[i] = (char *) pst + 7;
 
33143
+         pst++;
 
33144
+         break;
 
33145
+#endif
 
33146
+
 
33147
+       case FFI_TYPE_SINT16:
 
33148
+       case FFI_TYPE_UINT16:
 
33149
+#ifndef __LITTLE_ENDIAN__
 
33150
+         avalue[i] = (char *) pst + 6;
 
33151
+         pst++;
 
33152
+         break;
 
33153
+#endif
 
33154
+
 
33155
+       case FFI_TYPE_SINT32:
 
33156
+       case FFI_TYPE_UINT32:
 
33157
+#ifndef __LITTLE_ENDIAN__
 
33158
+         avalue[i] = (char *) pst + 4;
 
33159
+         pst++;
 
33160
+         break;
 
33161
+#endif
 
33162
+
 
33163
+       case FFI_TYPE_SINT64:
 
33164
+       case FFI_TYPE_UINT64:
 
33165
+       case FFI_TYPE_POINTER:
 
33166
+         avalue[i] = pst;
 
33167
+         pst++;
 
33168
+         break;
 
33169
+
 
33170
+       case FFI_TYPE_STRUCT:
 
33171
+         if ((cif->abi & FFI_LINUX_STRUCT_ALIGN) != 0)
 
33172
+           {
 
33173
+             align = arg_types[i]->alignment;
 
33174
+             if (align > 16)
 
33175
+               align = 16;
 
33176
+             if (align > 1)
 
33177
+               pst = (unsigned long *) ALIGN ((size_t) pst, align);
 
33178
+           }
 
33179
+         elt = 0;
 
33180
+#if _CALL_ELF == 2
 
33181
+         elt = discover_homogeneous_aggregate (arg_types[i], &elnum);
 
33182
+#endif
 
33183
+         if (elt)
 
33184
+           {
 
33185
+             union {
 
33186
+               void *v;
 
33187
+               unsigned long *ul;
 
33188
+               float *f;
 
33189
+               double *d;
 
33190
+               size_t p;
 
33191
+             } to, from;
 
33192
+
 
33193
+             /* Repackage the aggregate from its parts.  The
 
33194
+                aggregate size is not greater than the space taken by
 
33195
+                the registers so store back to the register/parameter
 
33196
+                save arrays.  */
 
33197
+             if (pfr + elnum <= end_pfr)
 
33198
+               to.v = pfr;
 
33199
+             else
 
33200
+               to.v = pst;
 
33201
+
 
33202
+             avalue[i] = to.v;
 
33203
+             from.ul = pst;
 
33204
+             if (elt == FFI_TYPE_FLOAT)
 
33205
+               {
 
33206
+                 do
 
33207
+                   {
 
33208
+                     if (pfr < end_pfr && i < nfixedargs)
 
33209
+                       {
 
33210
+                         *to.f = (float) pfr->d;
 
33211
+                         pfr++;
 
33212
+                       }
 
33213
+                     else
 
33214
+                       *to.f = *from.f;
 
33215
+                     to.f++;
 
33216
+                     from.f++;
 
33217
+                   }
 
33218
+                 while (--elnum != 0);
 
33219
+               }
 
33220
+             else
 
33221
+               {
 
33222
+                 do
 
33223
+                   {
 
33224
+                     if (pfr < end_pfr && i < nfixedargs)
 
33225
+                       {
 
33226
+                         *to.d = pfr->d;
 
33227
+                         pfr++;
 
33228
+                       }
 
33229
+                     else
 
33230
+                       *to.d = *from.d;
 
33231
+                     to.d++;
 
33232
+                     from.d++;
 
33233
+                   }
 
33234
+                 while (--elnum != 0);
 
33235
+               }
 
33236
+           }
 
33237
+         else
 
33238
+           {
 
33239
+#ifndef __LITTLE_ENDIAN__
 
33240
+             /* Structures with size less than eight bytes are passed
 
33241
+                left-padded.  */
 
33242
+             if (arg_types[i]->size < 8)
 
33243
+               avalue[i] = (char *) pst + 8 - arg_types[i]->size;
 
33244
+             else
 
33245
+#endif
 
33246
+               avalue[i] = pst;
 
33247
+           }
 
33248
+         pst += (arg_types[i]->size + 7) / 8;
 
33249
+         break;
 
33250
+
 
33251
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
33252
+       case FFI_TYPE_LONGDOUBLE:
 
33253
+         if ((cif->abi & FFI_LINUX_LONG_DOUBLE_128) != 0)
 
33254
+           {
 
33255
+             if (pfr + 1 < end_pfr && i + 1 < nfixedargs)
 
33256
+               {
 
33257
+                 avalue[i] = pfr;
 
33258
+                 pfr += 2;
 
33259
+               }
 
33260
+             else
 
33261
+               {
 
33262
+                 if (pfr < end_pfr && i < nfixedargs)
 
33263
+                   {
 
33264
+                     /* Passed partly in f13 and partly on the stack.
 
33265
+                        Move it all to the stack.  */
 
33266
+                     *pst = *(unsigned long *) pfr;
 
33267
+                     pfr++;
 
33268
+                   }
 
33269
+                 avalue[i] = pst;
 
33270
+               }
 
33271
+             pst += 2;
 
33272
+             break;
 
33273
+           }
 
33274
+         /* Fall through.  */
 
33275
+#endif
 
33276
+       case FFI_TYPE_DOUBLE:
 
33277
+         /* On the outgoing stack all values are aligned to 8 */
 
33278
+         /* there are 13 64bit floating point registers */
 
33279
+
 
33280
+         if (pfr < end_pfr && i < nfixedargs)
 
33281
+           {
 
33282
+             avalue[i] = pfr;
 
33283
+             pfr++;
 
33284
+           }
 
33285
+         else
 
33286
+           avalue[i] = pst;
 
33287
+         pst++;
 
33288
+         break;
 
33289
+
 
33290
+       case FFI_TYPE_FLOAT:
 
33291
+         if (pfr < end_pfr && i < nfixedargs)
 
33292
+           {
 
33293
+             /* Float values are stored as doubles in the
 
33294
+                ffi_closure_LINUX64 code.  Fix them here.  */
 
33295
+             pfr->f = (float) pfr->d;
 
33296
+             avalue[i] = pfr;
 
33297
+             pfr++;
 
33298
+           }
 
33299
+         else
 
33300
+           avalue[i] = pst;
 
33301
+         pst++;
 
33302
+         break;
 
33303
+
 
33304
+       default:
 
33305
+         FFI_ASSERT (0);
 
33306
+       }
 
33307
+
 
33308
+      i++;
 
33309
+    }
 
33310
+
 
33311
+
 
33312
+  (closure->fun) (cif, rvalue, avalue, closure->user_data);
 
33313
+
 
33314
+  /* Tell ffi_closure_LINUX64 how to perform return type promotions.  */
 
33315
+  if ((cif->flags & FLAG_RETURNS_SMST) != 0)
 
33316
+    {
 
33317
+      if ((cif->flags & FLAG_RETURNS_FP) == 0)
 
33318
+       return FFI_V2_TYPE_SMALL_STRUCT + cif->rtype->size - 1;
 
33319
+      else if ((cif->flags & FLAG_RETURNS_64BITS) != 0)
 
33320
+       return FFI_V2_TYPE_DOUBLE_HOMOG;
 
33321
+      else
 
33322
+       return FFI_V2_TYPE_FLOAT_HOMOG;
 
33323
+    }
 
33324
+  return cif->rtype->type;
 
33325
+}
 
33326
+#endif
 
33327
--- a/src/libffi/src/types.c
 
33328
+++ b/src/libffi/src/types.c
 
33329
@@ -44,6 +44,17 @@
 
33330
   id, NULL                                     \
 
33331
 }
 
33332
 
 
33333
+#define FFI_NONCONST_TYPEDEF(name, type, id)   \
 
33334
+struct struct_align_##name {                   \
 
33335
+  char c;                                      \
 
33336
+  type x;                                      \
 
33337
+};                                             \
 
33338
+ffi_type ffi_type_##name = {                   \
 
33339
+  sizeof(type),                                        \
 
33340
+  offsetof(struct struct_align_##name, x),     \
 
33341
+  id, NULL                                     \
 
33342
+}
 
33343
+
 
33344
 /* Size and alignment are fake here. They must not be 0. */
 
33345
 const ffi_type ffi_type_void = {
 
33346
   1, 1, FFI_TYPE_VOID, NULL
 
33347
@@ -73,5 +84,9 @@
 
33348
 # endif
 
33349
 const ffi_type ffi_type_longdouble = { 16, 16, 4, NULL };
 
33350
 #elif FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 
33351
+# if HAVE_LONG_DOUBLE_VARIANT
 
33352
+FFI_NONCONST_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE);
 
33353
+# else
 
33354
 FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE);
 
33355
+# endif
 
33356
 #endif
 
33357
--- a/src/libffi/src/prep_cif.c
 
33358
+++ b/src/libffi/src/prep_cif.c
 
33359
@@ -126,6 +126,10 @@
 
33360
 
 
33361
   cif->flags = 0;
 
33362
 
 
33363
+#if HAVE_LONG_DOUBLE_VARIANT
 
33364
+  ffi_prep_types (abi);
 
33365
+#endif
 
33366
+
 
33367
   /* Initialize the return type if necessary */
 
33368
   if ((cif->rtype->size == 0) && (initialize_aggregate(cif->rtype) != FFI_OK))
 
33369
     return FFI_BAD_TYPEDEF;
 
33370
--- a/src/libffi/testsuite/Makefile.in
 
33371
+++ b/src/libffi/testsuite/Makefile.in
 
33372
@@ -88,6 +88,7 @@
 
33373
 FGREP = @FGREP@
 
33374
 GREP = @GREP@
 
33375
 HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
 
33376
+HAVE_LONG_DOUBLE_VARIANT = @HAVE_LONG_DOUBLE_VARIANT@
 
33377
 INSTALL = @INSTALL@
 
33378
 INSTALL_DATA = @INSTALL_DATA@
 
33379
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 
33380
--- a/src/libffi/testsuite/libffi.call/cls_double_va.c
 
33381
+++ b/src/libffi/testsuite/libffi.call/cls_double_va.c
 
33382
@@ -38,26 +38,24 @@
 
33383
 
 
33384
        /* This printf call is variadic */
 
33385
        CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, &ffi_type_sint,
 
33386
-               arg_types) == FFI_OK);
 
33387
+                              arg_types) == FFI_OK);
 
33388
 
 
33389
        args[0] = &format;
 
33390
        args[1] = &doubleArg;
 
33391
        args[2] = NULL;
 
33392
 
 
33393
        ffi_call(&cif, FFI_FN(printf), &res, args);
 
33394
-       // { dg-output "7.0" }
 
33395
+       /* { dg-output "7.0" } */
 
33396
        printf("res: %d\n", (int) res);
 
33397
-       // { dg-output "\nres: 4" }
 
33398
+       /* { dg-output "\nres: 4" } */
 
33399
 
 
33400
-       /* The call to cls_double_va_fn is static, so have to use a normal prep_cif */
 
33401
-       CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_sint, arg_types) == FFI_OK);
 
33402
+       CHECK(ffi_prep_closure_loc(pcl, &cif, cls_double_va_fn, NULL,
 
33403
+                                  code) == FFI_OK);
 
33404
 
 
33405
-       CHECK(ffi_prep_closure_loc(pcl, &cif, cls_double_va_fn, NULL, code) == FFI_OK);
 
33406
-
 
33407
-       res     = ((int(*)(char*, double))(code))(format, doubleArg);
 
33408
-       // { dg-output "\n7.0" }
 
33409
+       res = ((int(*)(char*, ...))(code))(format, doubleArg);
 
33410
+       /* { dg-output "\n7.0" } */
 
33411
        printf("res: %d\n", (int) res);
 
33412
-       // { dg-output "\nres: 4" }
 
33413
+       /* { dg-output "\nres: 4" } */
 
33414
 
 
33415
        exit(0);
 
33416
 }
 
33417
--- a/src/libffi/testsuite/libffi.call/cls_longdouble_va.c
 
33418
+++ b/src/libffi/testsuite/libffi.call/cls_longdouble_va.c
 
33419
@@ -38,27 +38,24 @@
 
33420
 
 
33421
        /* This printf call is variadic */
 
33422
        CHECK(ffi_prep_cif_var(&cif, FFI_DEFAULT_ABI, 1, 2, &ffi_type_sint,
 
33423
-               arg_types) == FFI_OK);
 
33424
+                              arg_types) == FFI_OK);
 
33425
 
 
33426
        args[0] = &format;
 
33427
        args[1] = &ldArg;
 
33428
        args[2] = NULL;
 
33429
 
 
33430
        ffi_call(&cif, FFI_FN(printf), &res, args);
 
33431
-       // { dg-output "7.0" }
 
33432
+       /* { dg-output "7.0" } */
 
33433
        printf("res: %d\n", (int) res);
 
33434
-       // { dg-output "\nres: 4" }
 
33435
+       /* { dg-output "\nres: 4" } */
 
33436
 
 
33437
-       /* The call to cls_longdouble_va_fn is static, so have to use a normal prep_cif */
 
33438
-       CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_sint,
 
33439
-               arg_types) == FFI_OK);
 
33440
+       CHECK(ffi_prep_closure_loc(pcl, &cif, cls_longdouble_va_fn, NULL,
 
33441
+                                  code) == FFI_OK);
 
33442
 
 
33443
-       CHECK(ffi_prep_closure_loc(pcl, &cif, cls_longdouble_va_fn, NULL, code) == FFI_OK);
 
33444
-
 
33445
-       res     = ((int(*)(char*, long double))(code))(format, ldArg);
 
33446
-       // { dg-output "\n7.0" }
 
33447
+       res = ((int(*)(char*, ...))(code))(format, ldArg);
 
33448
+       /* { dg-output "\n7.0" } */
 
33449
        printf("res: %d\n", (int) res);
 
33450
-       // { dg-output "\nres: 4" }
 
33451
+       /* { dg-output "\nres: 4" } */
 
33452
 
 
33453
        exit(0);
 
33454
 }
 
33455
--- a/src/libffi/configure.ac
 
33456
+++ b/src/libffi/configure.ac
 
33457
@@ -65,6 +65,7 @@
 
33458
 AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
 
33459
 
 
33460
 TARGETDIR="unknown"
 
33461
+HAVE_LONG_DOUBLE_VARIANT=0
 
33462
 case "$host" in
 
33463
   aarch64*-*-*)
 
33464
        TARGET=AARCH64; TARGETDIR=aarch64
 
33465
@@ -162,6 +163,7 @@
 
33466
 
 
33467
   powerpc*-*-linux* | powerpc-*-sysv*)
 
33468
        TARGET=POWERPC; TARGETDIR=powerpc
 
33469
+       HAVE_LONG_DOUBLE_VARIANT=1
 
33470
        ;;
 
33471
   powerpc-*-amigaos*)
 
33472
        TARGET=POWERPC; TARGETDIR=powerpc
 
33473
@@ -177,6 +179,7 @@
 
33474
        ;;
 
33475
   powerpc-*-freebsd* | powerpc-*-openbsd*)
 
33476
        TARGET=POWERPC_FREEBSD; TARGETDIR=powerpc
 
33477
+       HAVE_LONG_DOUBLE_VARIANT=1
 
33478
        ;;
 
33479
   powerpc64-*-freebsd*)
 
33480
        TARGET=POWERPC; TARGETDIR=powerpc
 
33481
@@ -273,14 +276,20 @@
 
33482
 # Also AC_SUBST this variable for ffi.h.
 
33483
 if test -z "$HAVE_LONG_DOUBLE"; then
 
33484
   HAVE_LONG_DOUBLE=0
 
33485
-  if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
 
33486
-    if test $ac_cv_sizeof_long_double != 0; then
 
33487
+  if test $ac_cv_sizeof_long_double != 0; then
 
33488
+    if test $HAVE_LONG_DOUBLE_VARIANT != 0; then
 
33489
+      AC_DEFINE(HAVE_LONG_DOUBLE_VARIANT, 1, [Define if you support more than one size of the long double type])
 
33490
       HAVE_LONG_DOUBLE=1
 
33491
-      AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
 
33492
+    else
 
33493
+      if test $ac_cv_sizeof_double != $ac_cv_sizeof_long_double; then
 
33494
+        HAVE_LONG_DOUBLE=1
 
33495
+        AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the long double type and it is bigger than a double])
 
33496
+      fi
 
33497
     fi
 
33498
   fi
 
33499
 fi
 
33500
 AC_SUBST(HAVE_LONG_DOUBLE)
 
33501
+AC_SUBST(HAVE_LONG_DOUBLE_VARIANT)
 
33502
 
 
33503
 AC_C_BIGENDIAN
 
33504
 
 
33505
--- a/src/libffi/doc/libffi.texi
 
33506
+++ b/src/libffi/doc/libffi.texi
 
33507
@@ -184,11 +184,11 @@
 
33508
 
 
33509
 @var{rvalue} is a pointer to a chunk of memory that will hold the
 
33510
 result of the function call.  This must be large enough to hold the
 
33511
-result and must be suitably aligned; it is the caller's responsibility
 
33512
+result, no smaller than the system register size (generally 32 or 64
 
33513
+bits), and must be suitably aligned; it is the caller's responsibility
 
33514
 to ensure this.  If @var{cif} declares that the function returns
 
33515
 @code{void} (using @code{ffi_type_void}), then @var{rvalue} is
 
33516
-ignored.  If @var{rvalue} is @samp{NULL}, then the return value is
 
33517
-discarded.
 
33518
+ignored.
 
33519
 
 
33520
 @var{avalues} is a vector of @code{void *} pointers that point to the
 
33521
 memory locations holding the argument values for a call.  If @var{cif}
 
33522
@@ -214,7 +214,7 @@
 
33523
   ffi_type *args[1];
 
33524
   void *values[1];
 
33525
   char *s;
 
33526
-  int rc;
 
33527
+  ffi_arg rc;
 
33528
   
 
33529
   /* Initialize the argument info vectors */    
 
33530
   args[0] = &ffi_type_pointer;
 
33531
@@ -222,7 +222,7 @@
 
33532
   
 
33533
   /* Initialize the cif */
 
33534
   if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, 
 
33535
-                      &ffi_type_uint, args) == FFI_OK)
 
33536
+                      &ffi_type_sint, args) == FFI_OK)
 
33537
     @{
 
33538
       s = "Hello World!";
 
33539
       ffi_call(&cif, puts, &rc, values);
 
33540
@@ -360,7 +360,7 @@
 
33541
 new @code{ffi_type} object for it.
 
33542
 
 
33543
 @tindex ffi_type
 
33544
-@deftp ffi_type
 
33545
+@deftp {Data type} ffi_type
 
33546
 The @code{ffi_type} has the following members:
 
33547
 @table @code
 
33548
 @item size_t size
 
33549
@@ -414,6 +414,7 @@
 
33550
       int i;
 
33551
 
 
33552
       tm_type.size = tm_type.alignment = 0;
 
33553
+      tm_type.type = FFI_TYPE_STRUCT;
 
33554
       tm_type.elements = &tm_type_elements;
 
33555
     
 
33556
       for (i = 0; i < 9; i++)
 
33557
@@ -540,21 +541,23 @@
 
33558
 #include <ffi.h>
 
33559
 
 
33560
 /* Acts like puts with the file given at time of enclosure. */
 
33561
-void puts_binding(ffi_cif *cif, unsigned int *ret, void* args[], 
 
33562
-                  FILE *stream)
 
33563
+void puts_binding(ffi_cif *cif, void *ret, void* args[],
 
33564
+                  void *stream)
 
33565
 @{
 
33566
-  *ret = fputs(*(char **)args[0], stream);
 
33567
+  *(ffi_arg *)ret = fputs(*(char **)args[0], (FILE *)stream);
 
33568
 @}
 
33569
 
 
33570
+typedef int (*puts_t)(char *);
 
33571
+
 
33572
 int main()
 
33573
 @{
 
33574
   ffi_cif cif;
 
33575
   ffi_type *args[1];
 
33576
   ffi_closure *closure;
 
33577
 
 
33578
-  int (*bound_puts)(char *);
 
33579
+  void *bound_puts;
 
33580
   int rc;
 
33581
-  
 
33582
+
 
33583
   /* Allocate closure and bound_puts */
 
33584
   closure = ffi_closure_alloc(sizeof(ffi_closure), &bound_puts);
 
33585
 
 
33586
@@ -565,13 +568,13 @@
 
33587
 
 
33588
       /* Initialize the cif */
 
33589
       if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
 
33590
-                       &ffi_type_uint, args) == FFI_OK)
 
33591
+                       &ffi_type_sint, args) == FFI_OK)
 
33592
         @{
 
33593
           /* Initialize the closure, setting stream to stdout */
 
33594
-          if (ffi_prep_closure_loc(closure, &cif, puts_binding, 
 
33595
+          if (ffi_prep_closure_loc(closure, &cif, puts_binding,
 
33596
                                    stdout, bound_puts) == FFI_OK)
 
33597
             @{
 
33598
-              rc = bound_puts("Hello World!");
 
33599
+              rc = ((puts_t)bound_puts)("Hello World!");
 
33600
               /* rc now holds the result of the call to fputs */
 
33601
             @}
 
33602
         @}
 
33603
--- a/src/libffi/Makefile.am
 
33604
+++ b/src/libffi/Makefile.am
 
33605
@@ -15,10 +15,12 @@
 
33606
         src/ia64/unix.S src/mips/ffi.c src/mips/n32.S src/mips/o32.S   \
 
33607
         src/mips/ffitarget.h src/m32r/ffi.c src/m32r/sysv.S            \
 
33608
         src/m32r/ffitarget.h src/m68k/ffi.c src/m68k/sysv.S            \
 
33609
-        src/m68k/ffitarget.h src/powerpc/ffi.c src/powerpc/sysv.S      \
 
33610
-        src/powerpc/linux64.S src/powerpc/linux64_closure.S            \
 
33611
-        src/powerpc/ppc_closure.S src/powerpc/asm.h                    \
 
33612
-       src/powerpc/aix.S src/powerpc/darwin.S                          \
 
33613
+        src/m68k/ffitarget.h                                           \
 
33614
+       src/powerpc/ffi.c src/powerpc/ffi_powerpc.h                     \
 
33615
+       src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c                \
 
33616
+       src/powerpc/sysv.S src/powerpc/linux64.S                        \
 
33617
+       src/powerpc/linux64_closure.S src/powerpc/ppc_closure.S         \
 
33618
+       src/powerpc/asm.h src/powerpc/aix.S src/powerpc/darwin.S        \
 
33619
        src/powerpc/aix_closure.S src/powerpc/darwin_closure.S          \
 
33620
        src/powerpc/ffi_darwin.c src/powerpc/ffitarget.h                \
 
33621
        src/s390/ffi.c src/s390/sysv.S src/s390/ffitarget.h             \
 
33622
@@ -179,7 +181,7 @@
 
33623
 nodist_libffi_la_SOURCES += src/m68k/ffi.c src/m68k/sysv.S
 
33624
 endif
 
33625
 if POWERPC
 
33626
-nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S
 
33627
+nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/ffi_linux64.c src/powerpc/sysv.S src/powerpc/ppc_closure.S src/powerpc/linux64.S src/powerpc/linux64_closure.S
 
33628
 endif
 
33629
 if POWERPC_AIX
 
33630
 nodist_libffi_la_SOURCES += src/powerpc/ffi_darwin.c src/powerpc/aix.S src/powerpc/aix_closure.S
 
33631
@@ -188,7 +190,7 @@
 
33632
 nodist_libffi_la_SOURCES += src/powerpc/ffi_darwin.c src/powerpc/darwin.S src/powerpc/darwin_closure.S
 
33633
 endif
 
33634
 if POWERPC_FREEBSD
 
33635
-nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/sysv.S src/powerpc/ppc_closure.S
 
33636
+nodist_libffi_la_SOURCES += src/powerpc/ffi.c src/powerpc/ffi_sysv.c src/powerpc/sysv.S src/powerpc/ppc_closure.S
 
33637
 endif
 
33638
 if AARCH64
 
33639
 nodist_libffi_la_SOURCES += src/aarch64/sysv.S src/aarch64/ffi.c
 
33640
--- a/src/libffi/man/Makefile.in
 
33641
+++ b/src/libffi/man/Makefile.in
 
33642
@@ -111,6 +111,7 @@
 
33643
 FGREP = @FGREP@
 
33644
 GREP = @GREP@
 
33645
 HAVE_LONG_DOUBLE = @HAVE_LONG_DOUBLE@
 
33646
+HAVE_LONG_DOUBLE_VARIANT = @HAVE_LONG_DOUBLE_VARIANT@
 
33647
 INSTALL = @INSTALL@
 
33648
 INSTALL_DATA = @INSTALL_DATA@
 
33649
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 
33650
--- a/src/libssp/configure
 
33651
+++ b/src/libssp/configure
 
33652
@@ -6385,7 +6385,7 @@
 
33653
   rm -rf conftest*
 
33654
   ;;
 
33655
 
 
33656
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
 
33657
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
 
33658
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
 
33659
   # Find out which ABI we are using.
 
33660
   echo 'int i;' > conftest.$ac_ext
 
33661
@@ -6410,7 +6410,10 @@
 
33662
                ;;
 
33663
            esac
 
33664
            ;;
 
33665
-         ppc64-*linux*|powerpc64-*linux*)
 
33666
+         powerpc64le-*linux*)
 
33667
+           LD="${LD-ld} -m elf32lppclinux"
 
33668
+           ;;
 
33669
+         powerpc64-*linux*)
 
33670
            LD="${LD-ld} -m elf32ppclinux"
 
33671
            ;;
 
33672
          s390x-*linux*)
 
33673
@@ -6429,7 +6432,10 @@
 
33674
          x86_64-*linux*)
 
33675
            LD="${LD-ld} -m elf_x86_64"
 
33676
            ;;
 
33677
-         ppc*-*linux*|powerpc*-*linux*)
 
33678
+         powerpcle-*linux*)
 
33679
+           LD="${LD-ld} -m elf64lppc"
 
33680
+           ;;
 
33681
+         powerpc-*linux*)
 
33682
            LD="${LD-ld} -m elf64ppc"
 
33683
            ;;
 
33684
          s390*-*linux*|s390*-*tpf*)
 
33685
@@ -10658,7 +10664,7 @@
 
33686
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
33687
   lt_status=$lt_dlunknown
 
33688
   cat > conftest.$ac_ext <<_LT_EOF
 
33689
-#line 10661 "configure"
 
33690
+#line 10667 "configure"
 
33691
 #include "confdefs.h"
 
33692
 
 
33693
 #if HAVE_DLFCN_H
 
33694
@@ -10764,7 +10770,7 @@
 
33695
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
 
33696
   lt_status=$lt_dlunknown
 
33697
   cat > conftest.$ac_ext <<_LT_EOF
 
33698
-#line 10767 "configure"
 
33699
+#line 10773 "configure"
 
33700
 #include "confdefs.h"
 
33701
 
 
33702
 #if HAVE_DLFCN_H
 
33703
--- a/src/libcpp/ChangeLog.ibm
 
33704
+++ b/src/libcpp/ChangeLog.ibm
 
33705
@@ -0,0 +1,4 @@
 
33706
+2013-11-18  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
33707
+
 
33708
+       * lex.c (search_line_fast): Correct for little endian.
 
33709
+
 
33710
--- a/src/libcpp/lex.c
 
33711
+++ b/src/libcpp/lex.c
 
33712
@@ -559,8 +559,13 @@
 
33713
      beginning with all ones and shifting in zeros according to the
 
33714
      mis-alignment.  The LVSR instruction pulls the exact shift we
 
33715
      want from the address.  */
 
33716
+#ifdef __BIG_ENDIAN__
 
33717
   mask = __builtin_vec_lvsr(0, s);
 
33718
   mask = __builtin_vec_perm(zero, ones, mask);
 
33719
+#else
 
33720
+  mask = __builtin_vec_lvsl(0, s);
 
33721
+  mask = __builtin_vec_perm(ones, zero, mask);
 
33722
+#endif
 
33723
   data &= mask;
 
33724
 
 
33725
   /* While altivec loads mask addresses, we still need to align S so
 
33726
@@ -624,7 +629,11 @@
 
33727
     /* L now contains 0xff in bytes for which we matched one of the
 
33728
        relevant characters.  We can find the byte index by finding
 
33729
        its bit index and dividing by 8.  */
 
33730
+#ifdef __BIG_ENDIAN__
 
33731
     l = __builtin_clzl(l) >> 3;
 
33732
+#else
 
33733
+    l = __builtin_ctzl(l) >> 3;
 
33734
+#endif
 
33735
     return s + l;
 
33736
 
 
33737
 #undef N