summaryrefslogtreecommitdiffstats
path: root/recipes-devtools/gcc/files/gcc.builtin_isel.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-devtools/gcc/files/gcc.builtin_isel.patch')
-rw-r--r--recipes-devtools/gcc/files/gcc.builtin_isel.patch1059
1 files changed, 1059 insertions, 0 deletions
diff --git a/recipes-devtools/gcc/files/gcc.builtin_isel.patch b/recipes-devtools/gcc/files/gcc.builtin_isel.patch
new file mode 100644
index 0000000..10e5999
--- /dev/null
+++ b/recipes-devtools/gcc/files/gcc.builtin_isel.patch
@@ -0,0 +1,1059 @@
1diff -ruN gcc-4.6.0-orig/gcc/config/rs6000/rs6000-builtin.def gcc-4.6.0-new/gcc/config/rs6000/rs6000-builtin.def
2--- gcc-4.6.0-orig/gcc/config/rs6000/rs6000-builtin.def 2011-02-21 15:38:21.000000000 -0600
3+++ gcc-4.6.0-new/gcc/config/rs6000/rs6000-builtin.def 2011-07-25 12:32:26.626006000 -0500
4@@ -750,6 +750,71 @@
5 RS6000_BUILTIN(SPE_BUILTIN_MFSPEFSCR, RS6000_BTC_MISC)
6 RS6000_BUILTIN(SPE_BUILTIN_BRINC, RS6000_BTC_MISC)
7
8+/* ISEL builtins. */
9+/* Generic versions that get resolved to specific builtins. */
10+RS6000_BUILTIN(RS6000_BUILTIN_ISELEQ, RS6000_BTC_PURE)
11+RS6000_BUILTIN_EQUATE(ISEL_BUILTIN_OVERLOADED_FIRST,
12+ RS6000_BUILTIN_ISELEQ)
13+RS6000_BUILTIN(RS6000_BUILTIN_ISELGT, RS6000_BTC_PURE)
14+RS6000_BUILTIN(RS6000_BUILTIN_ISELLT, RS6000_BTC_PURE)
15+RS6000_BUILTIN(RS6000_BUILTIN_ISELGTU, RS6000_BTC_PURE)
16+RS6000_BUILTIN(RS6000_BUILTIN_ISELLTU, RS6000_BTC_PURE)
17+/* Same deal, but for 64-bit comparisons. */
18+RS6000_BUILTIN(RS6000_BUILTIN_ISELEQD, RS6000_BTC_PURE)
19+RS6000_BUILTIN(RS6000_BUILTIN_ISELGTD, RS6000_BTC_PURE)
20+RS6000_BUILTIN(RS6000_BUILTIN_ISELLTD, RS6000_BTC_PURE)
21+RS6000_BUILTIN(RS6000_BUILTIN_ISELGTDU, RS6000_BTC_PURE)
22+RS6000_BUILTIN(RS6000_BUILTIN_ISELLTDU, RS6000_BTC_PURE)
23+RS6000_BUILTIN_EQUATE(ISEL_BUILTIN_OVERLOADED_LAST,
24+ RS6000_BUILTIN_ISELLTDU)
25+
26+/* Each set of arguments is polymorphic in selected arguments and return
27+ value. */
28+#undef RS6000_ISEL_BASE
29+#define RS6000_ISEL_BASE(ARG, PRED, CMP) \
30+ RS6000_BUILTIN(RS6000_BUILTIN_ISEL_##PRED##CMP##_##ARG##_SS, RS6000_BTC_PURE) \
31+ RS6000_BUILTIN(RS6000_BUILTIN_ISEL_##PRED##CMP##_##ARG##_PP, RS6000_BTC_PURE) \
32+ RS6000_BUILTIN(RS6000_BUILTIN_ISEL_##PRED##CMP##_##ARG##_UU, RS6000_BTC_PURE)
33+#undef RS6000_ISEL_PTR_ARG
34+#define RS6000_ISEL_PTR_ARG(PRED, CMP) RS6000_ISEL_BASE(PP, PRED, CMP)
35+#undef RS6000_ISEL_SIGNED_ARG
36+#define RS6000_ISEL_SIGNED_ARG(PRED, CMP) RS6000_ISEL_BASE(SS, PRED, CMP)
37+#undef RS6000_ISEL_UNSIGNED_ARG
38+#define RS6000_ISEL_UNSIGNED_ARG(PRED, CMP) RS6000_ISEL_BASE(UU, PRED, CMP)
39+
40+#undef RS6000_ISEL_EQ
41+#define RS6000_ISEL_EQ(CMP) \
42+ RS6000_ISEL_PTR_ARG(EQ, CMP) \
43+ RS6000_ISEL_SIGNED_ARG(EQ, CMP) \
44+ RS6000_ISEL_UNSIGNED_ARG(EQ, CMP)
45+
46+#undef RS6000_ISEL_LT
47+#define RS6000_ISEL_LT(CMP) RS6000_ISEL_SIGNED_ARG(LT, CMP)
48+
49+#undef RS6000_ISEL_GT
50+#define RS6000_ISEL_GT(CMP) RS6000_ISEL_SIGNED_ARG(GT, CMP)
51+
52+#undef RS6000_ISEL_LTU
53+#define RS6000_ISEL_LTU(CMP) \
54+ RS6000_ISEL_PTR_ARG(LTU, CMP) \
55+ RS6000_ISEL_UNSIGNED_ARG(LTU, CMP)
56+
57+#undef RS6000_ISEL_GTU
58+#define RS6000_ISEL_GTU(CMP) \
59+ RS6000_ISEL_PTR_ARG(GTU, CMP) \
60+ RS6000_ISEL_UNSIGNED_ARG(GTU, CMP)
61+
62+RS6000_ISEL_EQ(CMPW)
63+RS6000_ISEL_LT(CMPW)
64+RS6000_ISEL_GT(CMPW)
65+RS6000_ISEL_LTU(CMPW)
66+RS6000_ISEL_GTU(CMPW)
67+RS6000_ISEL_EQ(CMPD)
68+RS6000_ISEL_LT(CMPD)
69+RS6000_ISEL_GT(CMPD)
70+RS6000_ISEL_LTU(CMPD)
71+RS6000_ISEL_GTU(CMPD)
72+
73 /* PAIRED builtins. */
74 RS6000_BUILTIN(PAIRED_BUILTIN_DIVV2SF3, RS6000_BTC_MISC)
75 RS6000_BUILTIN(PAIRED_BUILTIN_ABSV2SF2, RS6000_BTC_MISC)
76diff -ruN gcc-4.6.0-orig/gcc/config/rs6000/rs6000.c gcc-4.6.0-new/gcc/config/rs6000/rs6000.c
77--- gcc-4.6.0-orig/gcc/config/rs6000/rs6000.c 2011-03-15 07:57:37.000000000 -0500
78+++ gcc-4.6.0-new/gcc/config/rs6000/rs6000.c 2011-07-25 13:19:52.415921000 -0500
79@@ -12402,6 +12402,289 @@
80 return target;
81 }
82
83+/* isel builtins are a bit funny, because we want the user to be able to do:
84+
85+ char *p, *q, *r;
86+ int x, y, z;
87+ unsigned int a, b, c;
88+ ...
89+ p = __builtin_iseleq (i, j, q, r);
90+ x = __builtin_iseleq (i, j, y, z);
91+ a = __builtin_iseleq (i, j, b, c);
92+
93+ and, of course, i and j may be of several different types depending on the
94+ condition.
95+
96+ We handle this by having generic builtins that
97+ TARGET_RESOLVE_OVERLOADED_BUILTIN takes and turns into calls to our
98+ specific builtins. */
99+
100+/* Macros to help constructing the isel_builtin_desc arrays.
101+ These closely mirror the macros in rs6000-builtins.def. */
102+/* HACK: Use VOIDmode here as a constant approximation to Pmode and fix
103+ at runtime. We can't use Pmode because in biarch its definition is
104+ not constant. */
105+#define ISEL_Pmode VOIDmode
106+#define ISEL_BASE(FLAGS, ARG, RESULT, PRED, CMP, MODE, RMODE) \
107+ { NULL, FLAGS, RS6000_BUILTIN_ISEL_##PRED##CMP##_##ARG##_##RESULT, \
108+ PRED, MODE, RMODE },
109+#define ISEL_P_RESULT(FLAGS, ARG, PRED, CMP, MODE, RMODE) \
110+ ISEL_BASE (FLAGS | ISEL_FLAG_SEL_PTR, ARG, PP, PRED, \
111+ CMP, MODE, ISEL_Pmode)
112+#define ISEL_S_RESULT(FLAGS, ARG, PRED, CMP, MODE, RMODE) \
113+ ISEL_BASE (FLAGS | ISEL_FLAG_SEL_SIGNED, ARG, SS, PRED, \
114+ CMP, MODE, RMODE)
115+#define ISEL_U_RESULT(FLAGS, ARG, PRED, CMP, MODE, RMODE) \
116+ ISEL_BASE (FLAGS | ISEL_FLAG_SEL_UNSIGNED, ARG, UU, PRED, \
117+ CMP, MODE, RMODE)
118+
119+#define ISEL_EXPAND_ARG(FLAG, ARG, PRED, CMP, MODE, RMODE) \
120+ ISEL_P_RESULT (FLAG, ARG, PRED, CMP, MODE, RMODE) \
121+ ISEL_S_RESULT (FLAG, ARG, PRED, CMP, MODE, RMODE) \
122+ ISEL_U_RESULT (FLAG, ARG, PRED, CMP, MODE, RMODE)
123+#define ISEL_PTR_ARG(PRED, CMP, MODE) \
124+ ISEL_EXPAND_ARG (ISEL_FLAG_CMP_PTR, PP, PRED, CMP, ISEL_Pmode, MODE)
125+#define ISEL_SIGNED_ARG(PRED, CMP, MODE) \
126+ ISEL_EXPAND_ARG (ISEL_FLAG_CMP_SIGNED, SS, PRED, CMP, MODE, MODE)
127+#define ISEL_UNSIGNED_ARG(PRED, CMP, MODE) \
128+ ISEL_EXPAND_ARG (ISEL_FLAG_CMP_UNSIGNED, UU, PRED, CMP, MODE, MODE)
129+
130+#define ISEL_EQ(CMP, MODE) \
131+ ISEL_PTR_ARG (EQ, CMP, MODE) \
132+ ISEL_SIGNED_ARG (EQ, CMP, MODE) \
133+ ISEL_UNSIGNED_ARG (EQ, CMP, MODE)
134+#define ISEL_LT(CMP, MODE) ISEL_SIGNED_ARG (LT, CMP, MODE)
135+#define ISEL_GT(CMP, MODE) ISEL_SIGNED_ARG (GT, CMP, MODE)
136+#define ISEL_LTU(CMP, MODE) \
137+ ISEL_PTR_ARG (LTU, CMP, MODE) \
138+ ISEL_UNSIGNED_ARG (LTU, CMP, MODE)
139+#define ISEL_GTU(CMP, MODE) \
140+ ISEL_PTR_ARG (GTU, CMP, MODE) \
141+ ISEL_UNSIGNED_ARG (GTU, CMP, MODE)
142+
143+const struct isel_builtin_desc builtin_iselw[32] = {
144+ ISEL_EQ (CMPW, SImode)
145+ ISEL_LT (CMPW, SImode)
146+ ISEL_GT (CMPW, SImode)
147+ ISEL_LTU (CMPW, SImode)
148+ ISEL_GTU (CMPW, SImode)
149+ { "__builtin_iseleq", 0, RS6000_BUILTIN_ISELEQ, EQ, SImode, SImode },
150+ { "__builtin_isellt", 0, RS6000_BUILTIN_ISELLT, LT, SImode, SImode },
151+ { "__builtin_iselgt", 0, RS6000_BUILTIN_ISELGT, GT, SImode, SImode },
152+ { "__builtin_iselltu", 0, RS6000_BUILTIN_ISELLTU, LTU, SImode, SImode },
153+ { "__builtin_iselgtu", 0, RS6000_BUILTIN_ISELGTU, GTU, SImode, SImode }
154+};
155+
156+const struct isel_builtin_desc builtin_iseld[32] = {
157+ ISEL_EQ (CMPD, DImode)
158+ ISEL_LT (CMPD, DImode)
159+ ISEL_GT (CMPD, DImode)
160+ ISEL_LTU (CMPD, DImode)
161+ ISEL_GTU (CMPD, DImode)
162+ { "__builtin_isel64eq", 0, RS6000_BUILTIN_ISELEQD, EQ, DImode, DImode },
163+ { "__builtin_isel64lt", 0, RS6000_BUILTIN_ISELLTD, LT, DImode, DImode },
164+ { "__builtin_isel64gt", 0, RS6000_BUILTIN_ISELGTD, GT, DImode, DImode },
165+ { "__builtin_isel64ltu", 0, RS6000_BUILTIN_ISELLTDU, LTU, DImode, DImode },
166+ { "__builtin_isel64gtu", 0, RS6000_BUILTIN_ISELGTDU, GTU, DImode, DImode }
167+};
168+
169+/* Return the mode which DESC uses for comparisons. */
170+
171+static enum machine_mode
172+isel_cmp_mode (const struct isel_builtin_desc *desc)
173+{
174+ enum machine_mode mode = (enum machine_mode) desc->cmp_mode;
175+
176+ return (mode == VOIDmode ? Pmode : mode);
177+}
178+
179+/* Return the mode in which DESC selects arguments. */
180+
181+static enum machine_mode
182+isel_sel_mode (const struct isel_builtin_desc *desc)
183+{
184+ enum machine_mode mode = (enum machine_mode) desc->sel_mode;
185+
186+ return (mode == VOIDmode ? Pmode : mode);
187+}
188+
189+/* Return a tree describing the arguments for DESC according to CMPP:
190+ true for comparison arguments, false for select arguments. */
191+
192+static tree
193+isel_argtype (const struct isel_builtin_desc *desc, bool cmpp)
194+{
195+ switch (desc->arg_flags & (cmpp
196+ ? ISEL_FLAG_CMP_MASK
197+ : ISEL_FLAG_SEL_MASK))
198+ {
199+ case ISEL_FLAG_CMP_PTR:
200+ case ISEL_FLAG_SEL_PTR:
201+ return ptr_type_node;
202+ case ISEL_FLAG_CMP_SIGNED:
203+ return (isel_cmp_mode (desc) == SImode
204+ ? integer_type_node
205+ : long_integer_type_node);
206+ case ISEL_FLAG_SEL_SIGNED:
207+ return (isel_sel_mode (desc) == SImode
208+ ? integer_type_node
209+ : long_integer_type_node);
210+ case ISEL_FLAG_CMP_UNSIGNED:
211+ return (isel_cmp_mode (desc) == SImode
212+ ? unsigned_type_node
213+ : long_unsigned_type_node);
214+ case ISEL_FLAG_SEL_UNSIGNED:
215+ default:
216+ return (isel_sel_mode (desc) == SImode
217+ ? unsigned_type_node
218+ : long_unsigned_type_node);
219+ }
220+}
221+
222+/* Return a mnemonic string describing the argument or result of FLAGS
223+ depending on CMPP. */
224+
225+static const char *
226+isel_strdesc (int flags, bool cmpp)
227+{
228+ switch (flags & (cmpp ? ISEL_FLAG_CMP_MASK : ISEL_FLAG_SEL_MASK))
229+ {
230+ case ISEL_FLAG_CMP_PTR:
231+ case ISEL_FLAG_SEL_PTR:
232+ return "p";
233+ case ISEL_FLAG_CMP_SIGNED:
234+ case ISEL_FLAG_SEL_SIGNED:
235+ return "s";
236+ case ISEL_FLAG_CMP_UNSIGNED:
237+ case ISEL_FLAG_SEL_UNSIGNED:
238+ return "u";
239+ default:
240+ gcc_unreachable ();
241+ }
242+}
243+
244+/* Initialize N_DESC isel builtins from DESC. SIGNED_TYPE holds the
245+ basic type for signed variants of isel, UNSIGNED_TYPE the type for
246+ unsigned variants. */
247+
248+static void
249+rs6000_init_isel_builtins (const struct isel_builtin_desc *desc, int n_descs)
250+{
251+ int i;
252+ const char *is64 = (desc == &builtin_iselw[0] ? "32" : "64");
253+
254+ for (i = 0; i < n_descs; i++)
255+ {
256+ const struct isel_builtin_desc *d = &desc[i];
257+ tree cmptype, seltype, ftype;
258+
259+ cmptype = isel_argtype (d, true);
260+ seltype = isel_argtype (d, false);
261+
262+ ftype = build_function_type_list (seltype, cmptype, cmptype,
263+ seltype, seltype, NULL_TREE);
264+
265+ if (d->name)
266+ def_builtin (MASK_ISEL, d->name, ftype, d->code);
267+ else
268+ {
269+ char builtin_name[40];
270+
271+ sprintf (builtin_name, "__builtin_isel%s%s%s%s%s%s",
272+ is64,
273+ GET_RTX_NAME (d->cmp_code),
274+ GET_MODE_NAME (isel_cmp_mode (d)),
275+ isel_strdesc (d->arg_flags, true),
276+ isel_strdesc (d->arg_flags, false),
277+ GET_MODE_NAME (isel_sel_mode (d)));
278+
279+ def_builtin (MASK_ISEL, ggc_strdup (builtin_name), ftype, d->code);
280+ }
281+ }
282+}
283+
284+static rtx
285+rs6000_expand_isel_builtin (const struct isel_builtin_desc *desc,
286+ int n_descs, tree exp, rtx target, int fcode)
287+{
288+ int i;
289+
290+ for (i = 0; i < n_descs; i++)
291+ {
292+ const struct isel_builtin_desc *d = &desc[i];
293+
294+ if (fcode == (int) d->code)
295+ {
296+ int opidx;
297+ unsigned int j;
298+ rtx cmp;
299+ rtx operands[4];
300+ enum insn_code icode;
301+ enum machine_mode opmode;
302+ enum machine_mode cmpmode = isel_cmp_mode (d);
303+ enum machine_mode selmode = isel_sel_mode (d);
304+
305+ /* Determine underlying isel insn. */
306+ switch (d->cmp_code)
307+ {
308+ case GTU:
309+ case LTU:
310+ icode = (Pmode == SImode
311+ ? CODE_FOR_isel_unsigned_si
312+ : CODE_FOR_isel_unsigned_di);
313+ break;
314+ default:
315+ icode = (Pmode == SImode
316+ ? CODE_FOR_isel_signed_si
317+ : CODE_FOR_isel_signed_di);
318+ break;
319+ }
320+
321+ for (j = 0; j < ARRAY_SIZE (operands); j++)
322+ {
323+ tree arg = CALL_EXPR_ARG (exp, j);
324+
325+ /* If we got invalid arguments, bail out before generating
326+ bad rtl. */
327+ if (arg == error_mark_node)
328+ return const0_rtx;
329+
330+ operands[j] = expand_normal (arg);
331+
332+ /* Validate. */
333+ /* HACK: The isel pattern doesn't actually consume all the
334+ operands to the builtin; it only consumes 2 and 3. The
335+ other two will be handed off to a compare
336+ insn. Unfortunately, said insn is not named, so we
337+ can't directly access its insn_data here. Fake it by
338+ validating operands 0 and 1 with the isel pattern; that
339+ should be good enough. */
340+ opidx = (j < 2 ? 2 : j);
341+ opmode = (j < 2 ? cmpmode : selmode);
342+ if (! (*insn_data[icode].operand[opidx].predicate) (operands[j],
343+ opmode))
344+ operands[j] = copy_to_mode_reg (opmode, operands[j]);
345+ }
346+
347+ /* Validate target. */
348+ if (target == NULL_RTX
349+ || GET_MODE (target) != selmode
350+ || ! (*insn_data[icode].operand[0].predicate) (target, selmode))
351+ target = gen_reg_rtx (selmode);
352+
353+ /* Generate comparison. */
354+ cmp = gen_rtx_fmt_ee ((enum rtx_code)d->cmp_code, cmpmode,
355+ operands[0], operands[1]);
356+
357+ rs6000_emit_int_cmove (target, cmp, operands[2], operands[3]);
358+
359+ return target;
360+ }
361+ }
362+
363+ return NULL_RTX;
364+}
365+
366 /* Expand an expression EXP that calls a built-in function,
367 with result going to TARGET if that's convenient
368 (and in mode MODE if that's convenient).
369@@ -12520,6 +12803,24 @@
370 if (success)
371 return ret;
372 }
373+ if (TARGET_ISEL)
374+ {
375+ ret = rs6000_expand_isel_builtin (builtin_iselw,
376+ ARRAY_SIZE (builtin_iselw),
377+ exp, target, fcode);
378+
379+ if (ret != NULL_RTX)
380+ return ret;
381+ }
382+ if (TARGET_ISEL64)
383+ {
384+ ret = rs6000_expand_isel_builtin (builtin_iseld,
385+ ARRAY_SIZE (builtin_iseld),
386+ exp, target, fcode);
387+
388+ if (ret != NULL_RTX)
389+ return ret;
390+ }
391
392 gcc_assert (TARGET_ALTIVEC || TARGET_VSX || TARGET_SPE || TARGET_PAIRED_FLOAT);
393
394@@ -12738,6 +13039,10 @@
395 spe_init_builtins ();
396 if (TARGET_ALTIVEC)
397 altivec_init_builtins ();
398+ if (TARGET_ISEL)
399+ rs6000_init_isel_builtins (builtin_iselw, ARRAY_SIZE (builtin_iselw));
400+ if (TARGET_ISEL64)
401+ rs6000_init_isel_builtins (builtin_iseld, ARRAY_SIZE (builtin_iseld));
402 if (TARGET_ALTIVEC || TARGET_SPE || TARGET_PAIRED_FLOAT || TARGET_VSX)
403 rs6000_common_init_builtins ();
404 if (TARGET_FRE)
405diff -ruN gcc-4.6.0-orig/gcc/config/rs6000/rs6000-c.c gcc-4.6.0-new/gcc/config/rs6000/rs6000-c.c
406--- gcc-4.6.0-orig/gcc/config/rs6000/rs6000-c.c 2011-02-02 23:42:19.000000000 -0600
407+++ gcc-4.6.0-new/gcc/config/rs6000/rs6000-c.c 2011-07-25 16:07:14.616209000 -0500
408@@ -3439,7 +3439,7 @@
409 /* Implementation of the resolve_overloaded_builtin target hook, to
410 support Altivec's overloaded builtins. */
411
412-tree
413+static tree
414 altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
415 void *passed_arglist)
416 {
417@@ -3770,3 +3770,148 @@
418 error ("invalid parameter combination for AltiVec intrinsic");
419 return error_mark_node;
420 }
421+
422+/* Return true if the pair of arguments in ARGS is acceptable according
423+ to DECLTYPES and FLAGS. CMPP determines whether this is for the
424+ comparison arguments. */
425+
426+static bool
427+isel_arguments_valid (tree *args, tree *decltypes, int flags, bool cmpp)
428+{
429+ tree type0 = TREE_TYPE (args[0]);
430+ tree type1 = TREE_TYPE (args[1]);
431+ tree decltype0 = decltypes[0];
432+ tree decltype1 = decltypes[1];
433+
434+ switch (flags & (cmpp ? ISEL_FLAG_CMP_MASK : ISEL_FLAG_SEL_MASK))
435+ {
436+ /* For pointer arguments and results, we just need to make sure
437+ we're receiving pointers, and they can be freely converted to
438+ and from void *. For pointer results, we also need to ensure
439+ that the types of the passed arguments are compatible: this is
440+ similar to what the ?: construct would need to ensure. */
441+ case ISEL_FLAG_CMP_PTR:
442+ case ISEL_FLAG_SEL_PTR:
443+ {
444+ /* Results compatible with each other? */
445+ if (!lang_hooks.types_compatible_p (type0, type1))
446+ return false;
447+
448+ return (POINTER_TYPE_P (type0)
449+ && POINTER_TYPE_P (type1));
450+ }
451+ break;
452+ /* For signed and unsigned arguments and results, we just need to
453+ make sure that the argument types are compatible with the
454+ declared types; we can insert conversions to make everything
455+ match up. */
456+ case ISEL_FLAG_CMP_SIGNED:
457+ case ISEL_FLAG_SEL_SIGNED:
458+ case ISEL_FLAG_CMP_UNSIGNED:
459+ case ISEL_FLAG_SEL_UNSIGNED:
460+ return (lang_hooks.types_compatible_p (type0, decltype0)
461+ && lang_hooks.types_compatible_p (type1, decltype1));
462+ default:
463+ ;
464+ }
465+
466+ gcc_unreachable ();
467+}
468+
469+/* Determine if FNDECL is a generic isel intrinsic and if it can be
470+ resolved to a non-generic version with a proper type using the
471+ descriptions found in DESC. Return a call to the non-generic builtin
472+ if so. */
473+
474+static tree
475+rs6000_resolve_isel_builtin (location_t loc, tree fndecl,
476+ void *passed_arglist,
477+ const struct isel_builtin_desc *desc,
478+ int n_descs)
479+{
480+ VEC(tree,gc) *arglist = (VEC(tree,gc) *) passed_arglist;
481+ unsigned int nargs = VEC_length (tree, arglist);
482+ int i;
483+ unsigned int fcode = DECL_FUNCTION_CODE (fndecl);
484+ const struct isel_builtin_desc *generic = NULL;
485+
486+ /* Is this even a builtin we care about? */
487+ if (fcode < ISEL_BUILTIN_OVERLOADED_FIRST
488+ || fcode > ISEL_BUILTIN_OVERLOADED_LAST)
489+ return NULL_TREE;
490+
491+ if (nargs != 4)
492+ {
493+ error ("isel intrinsics only accept 4 arguments");
494+ return error_mark_node;
495+ }
496+
497+ /* Find the generic builtin we're resolving. */
498+ for (i = 0; i < n_descs; i++)
499+ if (desc[i].code == fcode)
500+ {
501+ generic = &desc[i];
502+ break;
503+ }
504+
505+ /* Happens if we're looking for a 64-bit builtin in the 32-bit
506+ descriptors. */
507+ if (generic == NULL)
508+ return NULL_TREE;
509+
510+ /* Try all the builtins whose comparison matches the generic one. */
511+ for (i = 0; i < n_descs; i++)
512+ {
513+ const struct isel_builtin_desc *d = &desc[i];
514+ int j;
515+ tree *argp = VEC_address (tree, arglist);
516+ tree impl_fndecl;
517+ tree decltypes[4], t;
518+ tree converted_args[4];
519+
520+ if (d == generic || d->cmp_code != generic->cmp_code)
521+ continue;
522+
523+ impl_fndecl = rs6000_builtin_decls[d->code];
524+ t = TYPE_ARG_TYPES (TREE_TYPE (impl_fndecl));
525+ for (j = 0 ; t != void_list_node; j++, t = TREE_CHAIN (t))
526+ decltypes[j] = TREE_VALUE (t);
527+
528+ if (!isel_arguments_valid (argp, decltypes, d->arg_flags, true)
529+ || !isel_arguments_valid (argp+2, decltypes+2, d->arg_flags, false))
530+ continue;
531+
532+ /* We got here, we're ok. Build a new, resolved CALL_EXPR. */
533+ for (j = 0; j < 4; j++)
534+ converted_args[j] = fold_convert (decltypes[j], argp[j]);
535+
536+ return build_call_expr_loc (loc, impl_fndecl, 4,
537+ converted_args[0], converted_args[1],
538+ converted_args[2], converted_args[3]);
539+ }
540+
541+ error ("invalid parameter combination for isel intrinsic");
542+ return error_mark_node;
543+}
544+
545+tree
546+rs6000_resolve_overloaded_builtin (location_t loc, tree fndecl, void *arglist)
547+{
548+ tree t;
549+
550+ t = altivec_resolve_overloaded_builtin (loc, fndecl, arglist);
551+ if (t)
552+ return t;
553+
554+ t = rs6000_resolve_isel_builtin (loc, fndecl, arglist,
555+ builtin_iselw, ARRAY_SIZE (builtin_iselw));
556+ if (t)
557+ return t;
558+
559+ t = rs6000_resolve_isel_builtin (loc, fndecl, arglist,
560+ builtin_iseld, ARRAY_SIZE (builtin_iseld));
561+ if (t)
562+ return t;
563+
564+ return NULL_TREE;
565+}
566diff -ruN gcc-4.6.0-orig/gcc/config/rs6000/rs6000.h gcc-4.6.0-new/gcc/config/rs6000/rs6000.h
567--- gcc-4.6.0-orig/gcc/config/rs6000/rs6000.h 2011-03-07 13:27:09.000000000 -0600
568+++ gcc-4.6.0-new/gcc/config/rs6000/rs6000.h 2011-07-25 16:07:04.045105000 -0500
569@@ -535,7 +535,7 @@
570 #define REGISTER_TARGET_PRAGMAS() do { \
571 c_register_pragma (0, "longcall", rs6000_pragma_longcall); \
572 targetm.target_option.pragma_parse = rs6000_pragma_target_parse; \
573- targetm.resolve_overloaded_builtin = altivec_resolve_overloaded_builtin; \
574+ targetm.resolve_overloaded_builtin = rs6000_resolve_overloaded_builtin; \
575 } while (0)
576
577 /* Target #defines. */
578@@ -2446,3 +2446,41 @@
579 extern GTY(()) tree rs6000_builtin_types[RS6000_BTI_MAX];
580 extern GTY(()) tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT];
581
582+/* Values for struct isel_builtin_desc.arg_flags. */
583+enum {
584+ ISEL_FLAG_CMP_PTR = 0x1,
585+ ISEL_FLAG_CMP_SIGNED = 0x2,
586+ ISEL_FLAG_CMP_UNSIGNED = 0x4,
587+ ISEL_FLAG_CMP_MASK = 0x7,
588+ ISEL_FLAG_SEL_PTR = 0x10,
589+ ISEL_FLAG_SEL_SIGNED = 0x20,
590+ ISEL_FLAG_SEL_UNSIGNED = 0x40,
591+ ISEL_FLAG_SEL_MASK = 0x70
592+};
593+
594+struct isel_builtin_desc {
595+ /* Name of this builtin. NULL if we should construct it. */
596+ const char *name;
597+
598+ /* Flags for argument combinations accepted by the builtin.
599+ Zero if this builtin is a generic builtin, to be resolved later. */
600+ int arg_flags;
601+
602+ /* The code of the builtin. */
603+ enum rs6000_builtins code;
604+
605+ /* rtx_code and machine_mode are not available here; use ints instead. */
606+ /* The comparison code the builtin uses. */
607+ int cmp_code;
608+
609+ /* The mode the builtin does comparisons in. */
610+ int cmp_mode;
611+
612+ /* The mode the builtin's selected arguments are in.
613+ Also happens to be its result mode. */
614+ int sel_mode;
615+};
616+
617+/* Arrays describing isel builtins. */
618+extern const struct isel_builtin_desc builtin_iselw[32];
619+extern const struct isel_builtin_desc builtin_iseld[32];
620diff -ruN gcc-4.6.0-orig/gcc/config/rs6000/rs6000-protos.h gcc-4.6.0-new/gcc/config/rs6000/rs6000-protos.h
621--- gcc-4.6.0-orig/gcc/config/rs6000/rs6000-protos.h 2011-03-15 07:57:37.000000000 -0500
622+++ gcc-4.6.0-new/gcc/config/rs6000/rs6000-protos.h 2011-07-25 16:07:50.484773000 -0500
623@@ -142,7 +142,7 @@
624 unsigned int);
625 extern unsigned int darwin_rs6000_special_round_type_align (tree, unsigned int,
626 unsigned int);
627-extern tree altivec_resolve_overloaded_builtin (location_t, tree, void *);
628+extern tree rs6000_resolve_overloaded_builtin (location_t, tree, void *);
629 extern rtx rs6000_libcall_value (enum machine_mode);
630 extern rtx rs6000_va_arg (tree, tree);
631 extern int function_ok_for_sibcall (tree);
632diff -ruN gcc-4.6.0-orig/gcc/testsuite/gcc.target/powerpc/builtin-isel64.c gcc-4.6.0-new/gcc/testsuite/gcc.target/powerpc/builtin-isel64.c
633--- gcc-4.6.0-orig/gcc/testsuite/gcc.target/powerpc/builtin-isel64.c 1969-12-31 18:00:00.000000000 -0600
634+++ gcc-4.6.0-new/gcc/testsuite/gcc.target/powerpc/builtin-isel64.c 2011-07-25 12:27:55.343932000 -0500
635@@ -0,0 +1,75 @@
636+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
637+/* { dg-options "-mcpu=e500mc64" } */
638+
639+#include "builtin-isel.h"
640+
641+/* Equality comparisons. */
642+
643+#undef FUNCTION_NAME
644+#define FUNCTION_NAME isel64eq
645+
646+SIGNED64_PROTO
647+{
648+ L = ISEL_BUILTIN (x, y, a, b);
649+ U = ISEL_BUILTIN (x, y, (unsigned long) a, (unsigned long) b);
650+ r = ISEL_BUILTIN (x, y, p, q);
651+ r = ISEL_BUILTIN (x, y, (char *) p, (char *) q);
652+ L = ISEL_BUILTIN (p, q, a, b);
653+ /* Equality checks explicitly permit unsigned comparison operands. */
654+ L = ISEL_BUILTIN ((unsigned long) x, (unsigned long) y, a, b);
655+ r = ISEL_BUILTIN ((unsigned long) x, (unsigned long) y, p, q);
656+}
657+
658+/* less-than, greater-than. */
659+
660+#undef FUNCTION_NAME
661+#define FUNCTION_NAME isel64lt
662+
663+SIGNED64_PROTO
664+{
665+ L = ISEL_BUILTIN (x, y, a, b);
666+ U = ISEL_BUILTIN (x, y, (unsigned long) a, (unsigned long) b);
667+ r = ISEL_BUILTIN (x, y, p, q);
668+ r = ISEL_BUILTIN (x, y, (char *) p, (char *) q);
669+}
670+
671+#undef FUNCTION_NAME
672+#define FUNCTION_NAME isel64gt
673+
674+SIGNED64_PROTO
675+{
676+ L = ISEL_BUILTIN (x, y, a, b);
677+ U = ISEL_BUILTIN (x, y, (unsigned long) a, (unsigned long) b);
678+ r = ISEL_BUILTIN (x, y, p, q);
679+ r = ISEL_BUILTIN (x, y, (char *) p, (char *) q);
680+}
681+
682+/* Unsigned variants. These permit unsigned and pointer operands for
683+ comparison only. */
684+
685+#undef FUNCTION_NAME
686+#define FUNCTION_NAME isel64ltu
687+
688+UNSIGNED64_PROTO
689+{
690+ L = ISEL_BUILTIN (x, y, a, b);
691+ U = ISEL_BUILTIN (x, y, (unsigned long) a, (unsigned long) b);
692+ r = ISEL_BUILTIN (x, y, p, q);
693+ r = ISEL_BUILTIN (x, y, (char *) p, (char *) q);
694+ L = ISEL_BUILTIN (p, q, a, b);
695+}
696+
697+#undef FUNCTION_NAME
698+#define FUNCTION_NAME isel64gtu
699+
700+UNSIGNED64_PROTO
701+{
702+ L = ISEL_BUILTIN (x, y, a, b);
703+ U = ISEL_BUILTIN (x, y, (unsigned long) a, (unsigned long) b);
704+ r = ISEL_BUILTIN (x, y, p, q);
705+ r = ISEL_BUILTIN (x, y, (char *) p, (char *) q);
706+ L = ISEL_BUILTIN (p, q, a, b);
707+}
708+
709+/* Don't use bare isel, as that'll match function names and the like. */
710+/* { dg-final { scan-assembler-times "isel " 26 } } */
711diff -ruN gcc-4.6.0-orig/gcc/testsuite/gcc.target/powerpc/builtin-isel64-errors.c gcc-4.6.0-new/gcc/testsuite/gcc.target/powerpc/builtin-isel64-errors.c
712--- gcc-4.6.0-orig/gcc/testsuite/gcc.target/powerpc/builtin-isel64-errors.c 1969-12-31 18:00:00.000000000 -0600
713+++ gcc-4.6.0-new/gcc/testsuite/gcc.target/powerpc/builtin-isel64-errors.c 2011-07-25 12:27:55.372965000 -0500
714@@ -0,0 +1,110 @@
715+/* Test rejection of invalid parameter combinations in isel builtins. */
716+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
717+/* { dg-options "-mcpu=e5500" } */
718+
719+#include "builtin-isel.h"
720+
721+
722+/* Equality comparisons. */
723+
724+#undef FUNCTION_NAME
725+#define FUNCTION_NAME isel64eq
726+
727+SIGNED64_PROTO
728+{
729+ /* Mismatches in argument type. */
730+ ISEL_BUILTIN ((unsigned long) x, y, a, b); /* { dg-error "isel intrinsic" } */
731+ ISEL_BUILTIN (x, (unsigned long) y, a, b); /* { dg-error "isel intrinsic" } */
732+ ISEL_BUILTIN ((long *) p, q, a, b); /* { dg-error "isel intrinsic" } */
733+ ISEL_BUILTIN (p, (long *) q, a, b); /* { dg-error "isel intrinsic" } */
734+ /* Mismatches in return type. */
735+ ISEL_BUILTIN (x, y, (unsigned long) a, b); /* { dg-error "isel intrinsic" } */
736+ ISEL_BUILTIN (x, y, a, (unsigned long) b); /* { dg-error "isel intrinsic" } */
737+ ISEL_BUILTIN (x, y, (long *) p, q); /* { dg-error "isel intrinsic" } */
738+ ISEL_BUILTIN (x, y, p, (long *) q); /* { dg-error "isel intrinsic" } */
739+}
740+
741+/* less-than, greater-than. */
742+
743+#undef FUNCTION_NAME
744+#define FUNCTION_NAME isel64lt
745+
746+SIGNED64_PROTO
747+{
748+ /* Unsigned comparison should be done with the *u variants. */
749+ ISEL_BUILTIN ((unsigned long) x, (unsigned long) y, a, b); /* { dg-error "isel intrinsic" } */
750+ /* So should pointer comparison. */
751+ ISEL_BUILTIN (p, q, a, b); /* { dg-error "isel intrinsic" } */
752+ /* Mismatches in argument type. */
753+ ISEL_BUILTIN ((unsigned long) x, y, a, b); /* { dg-error "isel intrinsic" } */
754+ ISEL_BUILTIN (x, (unsigned long) y, a, b); /* { dg-error "isel intrinsic" } */
755+ ISEL_BUILTIN ((long *) p, q, a, b); /* { dg-error "isel intrinsic" } */
756+ ISEL_BUILTIN (p, (long *) q, a, b); /* { dg-error "isel intrinsic" } */
757+ /* Mismatches in return type. */
758+ ISEL_BUILTIN (x, y, (unsigned long) a, b); /* { dg-error "isel intrinsic" } */
759+ ISEL_BUILTIN (x, y, a, (unsigned long) b); /* { dg-error "isel intrinsic" } */
760+ ISEL_BUILTIN (x, y, (long *) p, q); /* { dg-error "isel intrinsic" } */
761+ ISEL_BUILTIN (x, y, p, (long *) q); /* { dg-error "isel intrinsic" } */
762+}
763+
764+#undef FUNCTION_NAME
765+#define FUNCTION_NAME isel64gt
766+
767+SIGNED64_PROTO
768+{
769+ /* Unsigned comparison should be done with the *u variants. */
770+ ISEL_BUILTIN ((unsigned long) x, (unsigned long) y, a, b); /* { dg-error "isel intrinsic" } */
771+ /* So should pointer comparison. */
772+ ISEL_BUILTIN (p, q, a, b); /* { dg-error "isel intrinsic" } */
773+ /* Mismatches in argument type. */
774+ ISEL_BUILTIN ((unsigned long) x, y, a, b); /* { dg-error "isel intrinsic" } */
775+ ISEL_BUILTIN (x, (unsigned long) y, a, b); /* { dg-error "isel intrinsic" } */
776+ ISEL_BUILTIN ((long *) p, q, a, b); /* { dg-error "isel intrinsic" } */
777+ ISEL_BUILTIN (p, (long *) q, a, b); /* { dg-error "isel intrinsic" } */
778+ /* Mismatches in return type. */
779+ ISEL_BUILTIN (x, y, (unsigned long) a, b); /* { dg-error "isel intrinsic" } */
780+ ISEL_BUILTIN (x, y, a, (unsigned long) b); /* { dg-error "isel intrinsic" } */
781+ ISEL_BUILTIN (x, y, (long *) p, q); /* { dg-error "isel intrinsic" } */
782+ ISEL_BUILTIN (x, y, p, (long *) q); /* { dg-error "isel intrinsic" } */
783+}
784+
785+/* Unsigned variants. These permit unsigned and pointer operands for
786+ comparison only. */
787+
788+#undef FUNCTION_NAME
789+#define FUNCTION_NAME isel64ltu
790+
791+UNSIGNED64_PROTO
792+{
793+ /* Signed comparison should be done with the signed variants. */
794+ ISEL_BUILTIN ((long) x, (long) y, a, b); /* { dg-error "isel intrinsic" } */
795+ /* Mismatches in argument type. */
796+ ISEL_BUILTIN ((long) x, y, a, b); /* { dg-error "isel intrinsic" } */
797+ ISEL_BUILTIN (x, (long) y, a, b); /* { dg-error "isel intrinsic" } */
798+ ISEL_BUILTIN ((long *) p, q, a, b); /* { dg-error "isel intrinsic" } */
799+ ISEL_BUILTIN (p, (long *) q, a, b); /* { dg-error "isel intrinsic" } */
800+ /* Mismatches in return type. */
801+ ISEL_BUILTIN (x, y, (unsigned long) a, b); /* { dg-error "isel intrinsic" } */
802+ ISEL_BUILTIN (x, y, a, (unsigned long) b); /* { dg-error "isel intrinsic" } */
803+ ISEL_BUILTIN (x, y, (long *) p, q); /* { dg-error "isel intrinsic" } */
804+ ISEL_BUILTIN (x, y, p, (long *) q); /* { dg-error "isel intrinsic" } */
805+}
806+
807+#undef FUNCTION_NAME
808+#define FUNCTION_NAME isel64gtu
809+
810+UNSIGNED64_PROTO
811+{
812+ /* Signed comparison should be done with the signed variants. */
813+ ISEL_BUILTIN ((long) x, (long) y, a, b); /* { dg-error "isel intrinsic" } */
814+ /* Mismatches in argument type. */
815+ ISEL_BUILTIN ((long) x, y, a, b); /* { dg-error "isel intrinsic" } */
816+ ISEL_BUILTIN (x, (long) y, a, b); /* { dg-error "isel intrinsic" } */
817+ ISEL_BUILTIN ((long *) p, q, a, b); /* { dg-error "isel intrinsic" } */
818+ ISEL_BUILTIN (p, (long *) q, a, b); /* { dg-error "isel intrinsic" } */
819+ /* Mismatches in return type. */
820+ ISEL_BUILTIN (x, y, (unsigned long) a, b); /* { dg-error "isel intrinsic" } */
821+ ISEL_BUILTIN (x, y, a, (unsigned long) b); /* { dg-error "isel intrinsic" } */
822+ ISEL_BUILTIN (x, y, (long *) p, q); /* { dg-error "isel intrinsic" } */
823+ ISEL_BUILTIN (x, y, p, (long *) q); /* { dg-error "isel intrinsic" } */
824+}
825diff -ruN gcc-4.6.0-orig/gcc/testsuite/gcc.target/powerpc/builtin-isel.c gcc-4.6.0-new/gcc/testsuite/gcc.target/powerpc/builtin-isel.c
826--- gcc-4.6.0-orig/gcc/testsuite/gcc.target/powerpc/builtin-isel.c 1969-12-31 18:00:00.000000000 -0600
827+++ gcc-4.6.0-new/gcc/testsuite/gcc.target/powerpc/builtin-isel.c 2011-07-25 12:27:55.405959000 -0500
828@@ -0,0 +1,81 @@
829+/* { dg-do compile } */
830+/* { dg-options "-mcpu=e500mc" } */
831+
832+#include "builtin-isel.h"
833+
834+/* We're not being clever with the preprocessor here because DejaGNU
835+ will get confused. We do try to use it to eliminate what duplication
836+ we can. */
837+
838+/* We check to see that the resolution permits polymorphic results. */
839+
840+/* Equality comparisons. */
841+
842+#undef FUNCTION_NAME
843+#define FUNCTION_NAME iseleq
844+
845+SIGNED_PROTO
846+{
847+ i = ISEL_BUILTIN (x, y, a, b);
848+ u = ISEL_BUILTIN (x, y, (unsigned int) a, (unsigned int) b);
849+ r = ISEL_BUILTIN (x, y, p, q);
850+ r = ISEL_BUILTIN (x, y, (char *) p, (char *) q);
851+ i = ISEL_BUILTIN (p, q, a, b);
852+ /* Equality checks explicitly permit unsigned comparison operands. */
853+ i = ISEL_BUILTIN ((unsigned int) x, (unsigned int) y, a, b);
854+ r = ISEL_BUILTIN ((unsigned int) x, (unsigned int) y, p, q);
855+}
856+
857+/* less-than, greater-than. */
858+
859+#undef FUNCTION_NAME
860+#define FUNCTION_NAME isellt
861+
862+SIGNED_PROTO
863+{
864+ i = ISEL_BUILTIN (x, y, a, b);
865+ u = ISEL_BUILTIN (x, y, (unsigned int) a, (unsigned int) b);
866+ r = ISEL_BUILTIN (x, y, p, q);
867+ r = ISEL_BUILTIN (x, y, (char *) p, (char *) q);
868+}
869+
870+#undef FUNCTION_NAME
871+#define FUNCTION_NAME iselgt
872+
873+SIGNED_PROTO
874+{
875+ i = ISEL_BUILTIN (x, y, a, b);
876+ u = ISEL_BUILTIN (x, y, (unsigned int) a, (unsigned int) b);
877+ r = ISEL_BUILTIN (x, y, p, q);
878+ r = ISEL_BUILTIN (x, y, (char *) p, (char *) q);
879+}
880+
881+/* Unsigned variants. These permit unsigned and pointer operands for
882+ comparison only. */
883+
884+#undef FUNCTION_NAME
885+#define FUNCTION_NAME iselltu
886+
887+UNSIGNED_PROTO
888+{
889+ i = ISEL_BUILTIN (x, y, a, b);
890+ u = ISEL_BUILTIN (x, y, (unsigned int) a, (unsigned int) b);
891+ r = ISEL_BUILTIN (x, y, p, q);
892+ r = ISEL_BUILTIN (x, y, (char *) p, (char *) q);
893+ i = ISEL_BUILTIN (p, q, a, b);
894+}
895+
896+#undef FUNCTION_NAME
897+#define FUNCTION_NAME iselgtu
898+
899+UNSIGNED_PROTO
900+{
901+ i = ISEL_BUILTIN (x, y, a, b);
902+ u = ISEL_BUILTIN (x, y, (unsigned int) a, (unsigned int) b);
903+ r = ISEL_BUILTIN (x, y, p, q);
904+ r = ISEL_BUILTIN (x, y, (char *) p, (char *) q);
905+ i = ISEL_BUILTIN (p, q, a, b);
906+}
907+
908+/* Don't use bare isel, as that'll match function names and the like. */
909+/* { dg-final { scan-assembler-times "isel " 26 } } */
910diff -ruN gcc-4.6.0-orig/gcc/testsuite/gcc.target/powerpc/builtin-isel-errors.c gcc-4.6.0-new/gcc/testsuite/gcc.target/powerpc/builtin-isel-errors.c
911--- gcc-4.6.0-orig/gcc/testsuite/gcc.target/powerpc/builtin-isel-errors.c 1969-12-31 18:00:00.000000000 -0600
912+++ gcc-4.6.0-new/gcc/testsuite/gcc.target/powerpc/builtin-isel-errors.c 2011-07-25 12:27:55.443938000 -0500
913@@ -0,0 +1,117 @@
914+/* Test rejection of invalid parameter combinations in isel builtins. */
915+/* { dg-do compile } */
916+/* { dg-options "-mcpu=e500mc" } */
917+
918+#include "builtin-isel.h"
919+
920+/* We're not being clever with the preprocessor here because DejaGNU
921+ will get confused. We do try to use it to eliminate what duplication
922+ we can. */
923+
924+/* We check basic resolution of each builtin. We also check to see that
925+ the resolution permits polymorphic results. Argument type mismatches
926+ and result type mismatches are not permitted, except where noted. */
927+
928+/* Equality comparisons. */
929+
930+#undef FUNCTION_NAME
931+#define FUNCTION_NAME iseleq
932+
933+SIGNED_PROTO
934+{
935+ /* Mismatches in argument type. */
936+ ISEL_BUILTIN ((unsigned int) x, y, a, b); /* { dg-error "isel intrinsic" } */
937+ ISEL_BUILTIN (x, (unsigned int) y, a, b); /* { dg-error "isel intrinsic" } */
938+ ISEL_BUILTIN ((int *) p, q, a, b); /* { dg-error "isel intrinsic" } */
939+ ISEL_BUILTIN (p, (int *) q, a, b); /* { dg-error "isel intrinsic" } */
940+ /* Mismatches in return type. */
941+ ISEL_BUILTIN (x, y, (unsigned int) a, b); /* { dg-error "isel intrinsic" } */
942+ ISEL_BUILTIN (x, y, a, (unsigned int) b); /* { dg-error "isel intrinsic" } */
943+ ISEL_BUILTIN (x, y, (int *) p, q); /* { dg-error "isel intrinsic" } */
944+ ISEL_BUILTIN (x, y, p, (int *) q); /* { dg-error "isel intrinsic" } */
945+}
946+
947+/* less-than, greater-than. */
948+
949+#undef FUNCTION_NAME
950+#define FUNCTION_NAME isellt
951+
952+SIGNED_PROTO
953+{
954+ /* Unsigned comparison should be done with the *u variants. */
955+ ISEL_BUILTIN ((unsigned int) x, (unsigned int) y, a, b); /* { dg-error "isel intrinsic" } */
956+ /* So should pointer comparison. */
957+ ISEL_BUILTIN (p, q, a, b); /* { dg-error "isel intrinsic" } */
958+ /* Mismatches in argument type. */
959+ ISEL_BUILTIN ((unsigned int) x, y, a, b); /* { dg-error "isel intrinsic" } */
960+ ISEL_BUILTIN (x, (unsigned int) y, a, b); /* { dg-error "isel intrinsic" } */
961+ ISEL_BUILTIN ((int *) p, q, a, b); /* { dg-error "isel intrinsic" } */
962+ ISEL_BUILTIN (p, (int *) q, a, b); /* { dg-error "isel intrinsic" } */
963+ /* Mismatches in return type. */
964+ ISEL_BUILTIN (x, y, (unsigned int) a, b); /* { dg-error "isel intrinsic" } */
965+ ISEL_BUILTIN (x, y, a, (unsigned int) b); /* { dg-error "isel intrinsic" } */
966+ ISEL_BUILTIN (x, y, (int *) p, q); /* { dg-error "isel intrinsic" } */
967+ ISEL_BUILTIN (x, y, p, (int *) q); /* { dg-error "isel intrinsic" } */
968+}
969+
970+#undef FUNCTION_NAME
971+#define FUNCTION_NAME iselgt
972+
973+SIGNED_PROTO
974+{
975+ /* Unsigned comparison should be done with the *u variants. */
976+ ISEL_BUILTIN ((unsigned int) x, (unsigned int) y, a, b); /* { dg-error "isel intrinsic" } */
977+ /* So should pointer comparison. */
978+ ISEL_BUILTIN (p, q, a, b); /* { dg-error "isel intrinsic" } */
979+ /* Mismatches in argument type. */
980+ ISEL_BUILTIN ((unsigned int) x, y, a, b); /* { dg-error "isel intrinsic" } */
981+ ISEL_BUILTIN (x, (unsigned int) y, a, b); /* { dg-error "isel intrinsic" } */
982+ ISEL_BUILTIN ((int *) p, q, a, b); /* { dg-error "isel intrinsic" } */
983+ ISEL_BUILTIN (p, (int *) q, a, b); /* { dg-error "isel intrinsic" } */
984+ /* Mismatches in return type. */
985+ ISEL_BUILTIN (x, y, (unsigned int) a, b); /* { dg-error "isel intrinsic" } */
986+ ISEL_BUILTIN (x, y, a, (unsigned int) b); /* { dg-error "isel intrinsic" } */
987+ ISEL_BUILTIN (x, y, (int *) p, q); /* { dg-error "isel intrinsic" } */
988+ ISEL_BUILTIN (x, y, p, (int *) q); /* { dg-error "isel intrinsic" } */
989+}
990+
991+/* Unsigned variants. These permit unsigned and pointer operands for
992+ comparison only. */
993+
994+#undef FUNCTION_NAME
995+#define FUNCTION_NAME iselltu
996+
997+UNSIGNED_PROTO
998+{
999+ /* Signed comparison should be done with the signed variants. */
1000+ ISEL_BUILTIN ((int) x, (int) y, a, b); /* { dg-error "isel intrinsic" } */
1001+ /* Mismatches in argument type. */
1002+ ISEL_BUILTIN ((int) x, y, a, b); /* { dg-error "isel intrinsic" } */
1003+ ISEL_BUILTIN (x, (int) y, a, b); /* { dg-error "isel intrinsic" } */
1004+ ISEL_BUILTIN ((int *) p, q, a, b); /* { dg-error "isel intrinsic" } */
1005+ ISEL_BUILTIN (p, (int *) q, a, b); /* { dg-error "isel intrinsic" } */
1006+ /* Mismatches in return type. */
1007+ ISEL_BUILTIN (x, y, (unsigned int) a, b); /* { dg-error "isel intrinsic" } */
1008+ ISEL_BUILTIN (x, y, a, (unsigned int) b); /* { dg-error "isel intrinsic" } */
1009+ ISEL_BUILTIN (x, y, (int *) p, q); /* { dg-error "isel intrinsic" } */
1010+ ISEL_BUILTIN (x, y, p, (int *) q); /* { dg-error "isel intrinsic" } */
1011+}
1012+
1013+#undef FUNCTION_NAME
1014+#define FUNCTION_NAME iselgtu
1015+
1016+UNSIGNED_PROTO
1017+{
1018+ /* Signed comparison should be done with the signed variants. */
1019+ ISEL_BUILTIN ((int) x, (int) y, a, b); /* { dg-error "isel intrinsic" } */
1020+ /* Mismatches in argument type. */
1021+ ISEL_BUILTIN ((int) x, y, a, b); /* { dg-error "isel intrinsic" } */
1022+ ISEL_BUILTIN (x, (int) y, a, b); /* { dg-error "isel intrinsic" } */
1023+ ISEL_BUILTIN ((int *) p, q, a, b); /* { dg-error "isel intrinsic" } */
1024+ ISEL_BUILTIN (p, (int *) q, a, b); /* { dg-error "isel intrinsic" } */
1025+ /* Mismatches in return type. */
1026+ ISEL_BUILTIN (x, y, (unsigned int) a, b); /* { dg-error "isel intrinsic" } */
1027+ ISEL_BUILTIN (x, y, a, (unsigned int) b); /* { dg-error "isel intrinsic" } */
1028+ ISEL_BUILTIN (x, y, (int *) p, q); /* { dg-error "isel intrinsic" } */
1029+ ISEL_BUILTIN (x, y, p, (int *) q); /* { dg-error "isel intrinsic" } */
1030+}
1031diff -ruN gcc-4.6.0-orig/gcc/testsuite/gcc.target/powerpc/builtin-isel.h gcc-4.6.0-new/gcc/testsuite/gcc.target/powerpc/builtin-isel.h
1032--- gcc-4.6.0-orig/gcc/testsuite/gcc.target/powerpc/builtin-isel.h 1969-12-31 18:00:00.000000000 -0600
1033+++ gcc-4.6.0-new/gcc/testsuite/gcc.target/powerpc/builtin-isel.h 2011-07-25 12:27:55.483942000 -0500
1034@@ -0,0 +1,25 @@
1035+/* Common definitions for builtin isel testing. */
1036+
1037+#define SIGNED_ARGLIST (int x, int y, int a, int b, void *p, void *q)
1038+#define UNSIGNED_ARGLIST (unsigned int x, unsigned int y, \
1039+ int a, int b, void *p, void *q)
1040+
1041+#define SIGNED_PROTO void FUNCTION_NAME SIGNED_ARGLIST
1042+#define UNSIGNED_PROTO void FUNCTION_NAME UNSIGNED_ARGLIST
1043+
1044+#define SIGNED64_ARGLIST (long x, long y, long a, long b, void *p, void *q)
1045+#define UNSIGNED64_ARGLIST (unsigned long x, unsigned long y, \
1046+ long a, long b, void *p, void *q)
1047+
1048+#define SIGNED64_PROTO void FUNCTION_NAME SIGNED64_ARGLIST
1049+#define UNSIGNED64_PROTO void FUNCTION_NAME UNSIGNED64_ARGLIST
1050+
1051+#define CONCAT2(X,Y) X##Y
1052+#define CONCAT(X,Y) CONCAT2(X, Y)
1053+#define ISEL_BUILTIN CONCAT(__builtin_, FUNCTION_NAME)
1054+
1055+volatile int i;
1056+volatile unsigned int u;
1057+volatile void *r;
1058+volatile long L;
1059+volatile unsigned long U;