]> gcc.gnu.org Git - gcc.git/commitdiff
[multiple changes]
authorRamana Radhakrishnan <ramana@gcc.gnu.org>
Fri, 15 Jun 2012 16:43:36 +0000 (16:43 +0000)
committerRamana Radhakrishnan <ramana@gcc.gnu.org>
Fri, 15 Jun 2012 16:43:36 +0000 (16:43 +0000)
2012-06-15  Marc Glisse  <marc.glisse@inria.fr>

PR c++/51033
* c-typeck.c (c_build_vec_perm_expr): Move to c-family/c-common.c.
        * c-tree.h (c_build_vec_perm_expr): Move to c-family/c-common.h.

cp/

2012-06-15  Marc Glisse  <marc.glisse@inria.fr>

PR c++/51033
* semantics.c (literal_type_p): Handle VECTOR_TYPE.
        (potential_constant_expression_1): Handle VEC_PERM_EXPR.
        * parser.c (cp_parser_postfix_expression): Handle RID_BUILTIN_SHUFFLE.

c-family
2012-06-15  Marc Glisse  <marc.glisse@inria.fr>

PR c++/51033
* c-common.h (c_build_vec_perm_expr): Move decl here.
* c-common.c (c_build_vec_perm_expr): Move definition
here.

2012-06-15  Ramana Radhakrishnan  <ramana.radhakrishnan@linaro.org>

PR c++/51033
* c-c++-common/torture/vshuf-16.inc: Move from gcc.c-torture/execute/.
* c-c++-common/torture/vshuf-2.inc: Likewise.
* c-c++-common/torture/vshuf-4.inc: Likewise.
* c-c++-common/torture/vshuf-8.inc: Likewise.
* c-c++-common/torture/vshuf-main.inc: Likewise.
* c-c++-common/torture/vshuf-v16hi.c: Likewise.
* c-c++-common/torture/vshuf-v16qi.c: Likewise.
* c-c++-common/torture/vshuf-v2df.c: Likewise.
* c-c++-common/torture/vshuf-v2di.c: Likewise.
* c-c++-common/torture/vshuf-v2sf.c: Likewise.
* c-c++-common/torture/vshuf-v2si.c: Likewise.
* c-c++-common/torture/vshuf-v4df.c: Likewise.
* c-c++-common/torture/vshuf-v4di.c: Likewise.
* c-c++-common/torture/vshuf-v4hi.c: Likewise.
* c-c++-common/torture/vshuf-v4sf.c: Likewise.
* c-c++-common/torture/vshuf-v4si.c: Likewise.
* c-c++-common/torture/vshuf-v8hi.c: Likewise.
* c-c++-common/torture/vshuf-v8qi.c: Likewise.
* c-c++-common/torture/vshuf-v8si.c: Likewise.

From-SVN: r188671

29 files changed:
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c-common.h
gcc/c-tree.h
gcc/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/cp/semantics.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/torture/vshuf-16.inc [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-16.inc with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-2.inc [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-2.inc with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-4.inc [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-4.inc with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-8.inc [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-8.inc with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-main.inc [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-main.inc with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-v16hi.c [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-v16hi.c with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-v16qi.c [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-v16qi.c with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-v2df.c [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-v2df.c with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-v2di.c [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-v2di.c with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-v2sf.c [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-v2sf.c with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-v2si.c [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-v2si.c with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-v4df.c [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-v4df.c with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-v4di.c [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-v4di.c with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-v4hi.c [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-v4hi.c with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-v4sf.c [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-v4sf.c with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-v4si.c [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-v4si.c with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-v8hi.c [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-v8hi.c with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-v8qi.c [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-v8qi.c with 100% similarity]
gcc/testsuite/c-c++-common/torture/vshuf-v8si.c [moved from gcc/testsuite/gcc.c-torture/execute/vshuf-v8si.c with 100% similarity]

index 07598f2da9d5da2e6e199ae960054f5dd83172d9..9c473e4ed588fc70e21fca3fb7ef37120255ec27 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-15  Marc Glisse  <marc.glisse@inria.fr>
+
+       PR c++/51033
+       * c-typeck.c (c_build_vec_perm_expr): Move to c-family/c-common.c.
+        * c-tree.h (c_build_vec_perm_expr): Move to c-family/c-common.h.
+
 2012-06-15  Georg-Johann Lay  <avr@gjlay.de>
 
        * config/avr/avr.c (avr_default_expand_builtin): New function.
index ac499b359c4d95fd8bb890c7ed517f909db2bd13..529cc06f84bf0bfe67c080612fd427904b6365ae 100644 (file)
@@ -1,3 +1,10 @@
+2012-06-15  Marc Glisse  <marc.glisse@inria.fr>
+
+       PR c++/51033
+       * c-common.h (c_build_vec_perm_expr): Move decl here.
+       * c-common.c (c_build_vec_perm_expr): Move definition
+       here.
+
 2012-06-06  Steven Bosscher  <steven@gcc.gnu.org>
 
        * c.opt (fconserve-space): Turn into a no-op.
index 4dd040b5fa5465b7436e81350682885bf33de14b..61d756760e3c808a3c4e8df1ccadeb9310489b54 100644 (file)
@@ -430,7 +430,7 @@ const struct c_common_resword c_common_reswords[] =
   { "__bases",          RID_BASES, D_CXXONLY },
   { "__builtin_choose_expr", RID_CHOOSE_EXPR, D_CONLY },
   { "__builtin_complex", RID_BUILTIN_COMPLEX, D_CONLY },
-  { "__builtin_shuffle", RID_BUILTIN_SHUFFLE, D_CONLY },
+  { "__builtin_shuffle", RID_BUILTIN_SHUFFLE, 0 },
   { "__builtin_offsetof", RID_OFFSETOF, 0 },
   { "__builtin_types_compatible_p", RID_TYPES_COMPATIBLE_P, D_CONLY },
   { "__builtin_va_arg",        RID_VA_ARG,     0 },
@@ -1950,6 +1950,101 @@ vector_types_convertible_p (const_tree t1, const_tree t2, bool emit_lax_note)
   return false;
 }
 
+/* Build a VEC_PERM_EXPR if V0, V1 and MASK are not error_mark_nodes
+   and have vector types, V0 has the same type as V1, and the number of
+   elements of V0, V1, MASK is the same.
+
+   In case V1 is a NULL_TREE it is assumed that __builtin_shuffle was
+   called with two arguments.  In this case implementation passes the
+   first argument twice in order to share the same tree code.  This fact
+   could enable the mask-values being twice the vector length.  This is
+   an implementation accident and this semantics is not guaranteed to
+   the user.  */
+tree
+c_build_vec_perm_expr (location_t loc, tree v0, tree v1, tree mask)
+{
+  tree ret;
+  bool wrap = true;
+  bool maybe_const = false;
+  bool two_arguments = false;
+
+  if (v1 == NULL_TREE)
+    {
+      two_arguments = true;
+      v1 = v0;
+    }
+
+  if (v0 == error_mark_node || v1 == error_mark_node
+      || mask == error_mark_node)
+    return error_mark_node;
+
+  if (TREE_CODE (TREE_TYPE (mask)) != VECTOR_TYPE
+      || TREE_CODE (TREE_TYPE (TREE_TYPE (mask))) != INTEGER_TYPE)
+    {
+      error_at (loc, "__builtin_shuffle last argument must "
+                    "be an integer vector");
+      return error_mark_node;
+    }
+
+  if (TREE_CODE (TREE_TYPE (v0)) != VECTOR_TYPE
+      || TREE_CODE (TREE_TYPE (v1)) != VECTOR_TYPE)
+    {
+      error_at (loc, "__builtin_shuffle arguments must be vectors");
+      return error_mark_node;
+    }
+
+  if (TYPE_MAIN_VARIANT (TREE_TYPE (v0)) != TYPE_MAIN_VARIANT (TREE_TYPE (v1)))
+    {
+      error_at (loc, "__builtin_shuffle argument vectors must be of "
+                    "the same type");
+      return error_mark_node;
+    }
+
+  if (TYPE_VECTOR_SUBPARTS (TREE_TYPE (v0))
+      != TYPE_VECTOR_SUBPARTS (TREE_TYPE (mask))
+      && TYPE_VECTOR_SUBPARTS (TREE_TYPE (v1))
+        != TYPE_VECTOR_SUBPARTS (TREE_TYPE (mask)))
+    {
+      error_at (loc, "__builtin_shuffle number of elements of the "
+                    "argument vector(s) and the mask vector should "
+                    "be the same");
+      return error_mark_node;
+    }
+
+  if (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (v0))))
+      != GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (mask)))))
+    {
+      error_at (loc, "__builtin_shuffle argument vector(s) inner type "
+                    "must have the same size as inner type of the mask");
+      return error_mark_node;
+    }
+
+  if (!c_dialect_cxx ())
+    {
+      /* Avoid C_MAYBE_CONST_EXPRs inside VEC_PERM_EXPR.  */
+      v0 = c_fully_fold (v0, false, &maybe_const);
+      wrap &= maybe_const;
+
+      if (two_arguments)
+        v1 = v0 = save_expr (v0);
+      else
+        {
+          v1 = c_fully_fold (v1, false, &maybe_const);
+          wrap &= maybe_const;
+        }
+
+      mask = c_fully_fold (mask, false, &maybe_const);
+      wrap &= maybe_const;
+    }
+
+  ret = build3_loc (loc, VEC_PERM_EXPR, TREE_TYPE (v0), v0, v1, mask);
+
+  if (!c_dialect_cxx () && !wrap)
+    ret = c_wrap_maybe_const (ret, true);
+
+  return ret;
+}
+
 /* Like tree.c:get_narrower, but retain conversion from C++0x scoped enum
    to integral type.  */
 
index c8e6ce195778c7653d6889a27e53a638a2f5c578..fea41dd1ed93c48b73bc4855ab4a6bd53cec1221 100644 (file)
@@ -919,6 +919,7 @@ extern bool lvalue_p (const_tree);
 
 extern bool vector_targets_convertible_p (const_tree t1, const_tree t2);
 extern bool vector_types_convertible_p (const_tree t1, const_tree t2, bool emit_lax_note);
+extern tree c_build_vec_perm_expr (location_t, tree, tree, tree);
 
 extern rtx c_expand_expr (tree, rtx, enum machine_mode, int, rtx *);
 
index 8541747a339f25d643bad5e38295db298fd7fda4..145df357af938fae81456276d1863d40b545a420 100644 (file)
@@ -645,7 +645,6 @@ extern tree c_finish_omp_task (location_t, tree, tree);
 extern tree c_finish_omp_clauses (tree);
 extern tree c_build_va_arg (location_t, tree, tree);
 extern tree c_finish_transaction (location_t, tree, int);
-extern tree c_build_vec_perm_expr (location_t, tree, tree, tree);
 
 /* Set to 0 at beginning of a function definition, set to 1 if
    a return statement that specifies a return value is seen.  */
index 00747ebc9c3599d663dd4a8d378cabb825e4f2b3..c2f713eb02d8b5f78c64929e3043f2afb1595e92 100644 (file)
@@ -2866,98 +2866,6 @@ build_function_call_vec (location_t loc, tree function, VEC(tree,gc) *params,
     }
   return require_complete_type (result);
 }
-
-/* Build a VEC_PERM_EXPR if V0, V1 and MASK are not error_mark_nodes
-   and have vector types, V0 has the same type as V1, and the number of
-   elements of V0, V1, MASK is the same.
-
-   In case V1 is a NULL_TREE it is assumed that __builtin_shuffle was
-   called with two arguments.  In this case implementation passes the
-   first argument twice in order to share the same tree code.  This fact
-   could enable the mask-values being twice the vector length.  This is
-   an implementation accident and this semantics is not guaranteed to
-   the user.  */
-tree
-c_build_vec_perm_expr (location_t loc, tree v0, tree v1, tree mask)
-{
-  tree ret;
-  bool wrap = true;
-  bool maybe_const = false;
-  bool two_arguments = false;
-
-  if (v1 == NULL_TREE)
-    {
-      two_arguments = true;
-      v1 = v0;
-    }
-
-  if (v0 == error_mark_node || v1 == error_mark_node
-      || mask == error_mark_node)
-    return error_mark_node;
-
-  if (TREE_CODE (TREE_TYPE (mask)) != VECTOR_TYPE
-      || TREE_CODE (TREE_TYPE (TREE_TYPE (mask))) != INTEGER_TYPE)
-    {
-      error_at (loc, "__builtin_shuffle last argument must "
-                    "be an integer vector");
-      return error_mark_node;
-    }
-
-  if (TREE_CODE (TREE_TYPE (v0)) != VECTOR_TYPE
-      || TREE_CODE (TREE_TYPE (v1)) != VECTOR_TYPE)
-    {
-      error_at (loc, "__builtin_shuffle arguments must be vectors");
-      return error_mark_node;
-    }
-
-  if (TYPE_MAIN_VARIANT (TREE_TYPE (v0)) != TYPE_MAIN_VARIANT (TREE_TYPE (v1)))
-    {
-      error_at (loc, "__builtin_shuffle argument vectors must be of "
-                    "the same type");
-      return error_mark_node;
-    }
-
-  if (TYPE_VECTOR_SUBPARTS (TREE_TYPE (v0))
-      != TYPE_VECTOR_SUBPARTS (TREE_TYPE (mask))
-      && TYPE_VECTOR_SUBPARTS (TREE_TYPE (v1))
-        != TYPE_VECTOR_SUBPARTS (TREE_TYPE (mask)))
-    {
-      error_at (loc, "__builtin_shuffle number of elements of the "
-                    "argument vector(s) and the mask vector should "
-                    "be the same");
-      return error_mark_node;
-    }
-
-  if (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (v0))))
-      != GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (mask)))))
-    {
-      error_at (loc, "__builtin_shuffle argument vector(s) inner type "
-                    "must have the same size as inner type of the mask");
-      return error_mark_node;
-    }
-
-  /* Avoid C_MAYBE_CONST_EXPRs inside VEC_PERM_EXPR.  */
-  v0 = c_fully_fold (v0, false, &maybe_const);
-  wrap &= maybe_const;
-
-  if (two_arguments)
-    v1 = v0 = save_expr (v0);
-  else
-    {
-      v1 = c_fully_fold (v1, false, &maybe_const);
-      wrap &= maybe_const;
-    }
-
-  mask = c_fully_fold (mask, false, &maybe_const);
-  wrap &= maybe_const;
-
-  ret = build3_loc (loc, VEC_PERM_EXPR, TREE_TYPE (v0), v0, v1, mask);
-
-  if (!wrap)
-    ret = c_wrap_maybe_const (ret, true);
-
-  return ret;
-}
 \f
 /* Convert the argument expressions in the vector VALUES
    to the types in the list TYPELIST.
index 9d3fdfefa89f33ce5319443b6cec415b0fdfcbe8..d033bcfbf24fc1da22d5520968072e8025f82fe1 100644 (file)
@@ -1,3 +1,10 @@
+2012-06-15  Marc Glisse  <marc.glisse@inria.fr>
+
+       PR c++/51033
+       * semantics.c (literal_type_p): Handle VECTOR_TYPE.
+        (potential_constant_expression_1): Handle VEC_PERM_EXPR.
+        * parser.c (cp_parser_postfix_expression): Handle RID_BUILTIN_SHUFFLE.
+
 2012-06-09  Jason Merrill  <jason@redhat.com>
 
        * pt.c (tsubst_expr) [TAG_DEFN]: Instantiate local class.
index 85e0322e43f2671b67d0d269afbde8b87623b685..1691f81e4298caea5ee9c092a1accabe3c382c0b 100644 (file)
@@ -5448,6 +5448,44 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
       }
       break;
 
+    case RID_BUILTIN_SHUFFLE:
+      {
+       VEC(tree,gc)* vec;
+       unsigned int i;
+       tree p;
+       location_t loc = token->location;
+
+       cp_lexer_consume_token (parser->lexer);
+       vec = cp_parser_parenthesized_expression_list (parser, non_attr,
+                   /*cast_p=*/false, /*allow_expansion_p=*/true,
+                   /*non_constant_p=*/NULL);
+       if (vec == NULL)
+         return error_mark_node;
+
+       FOR_EACH_VEC_ELT (tree, vec, i, p)
+         mark_exp_read (p);
+
+       if (VEC_length (tree, vec) == 2)
+         return
+           c_build_vec_perm_expr
+           (loc, VEC_index (tree, vec, 0),
+            NULL_TREE, VEC_index (tree, vec, 1));
+
+       else if (VEC_length (tree, vec) == 3)
+         return
+           c_build_vec_perm_expr
+           (loc, VEC_index (tree, vec, 0),
+            VEC_index (tree, vec, 1),
+            VEC_index (tree, vec, 2));
+       else
+       {
+         error_at (loc, "wrong number of arguments to "
+             "%<__builtin_shuffle%>");
+         return error_mark_node;
+       }
+       break;
+      }
+
     default:
       {
        tree type;
index f8ad2a5884a91a1cdbb56c039483e87484677930..ee418616992f7d8ee616c031919585db02a93e34 100644 (file)
@@ -5622,6 +5622,7 @@ bool
 literal_type_p (tree t)
 {
   if (SCALAR_TYPE_P (t)
+      || TREE_CODE (t) == VECTOR_TYPE
       || TREE_CODE (t) == REFERENCE_TYPE)
     return true;
   if (CLASS_TYPE_P (t))
@@ -8505,6 +8506,7 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags)
       return true;
 
     case FMA_EXPR:
+    case VEC_PERM_EXPR:
      for (i = 0; i < 3; ++i)
       if (!potential_constant_expression_1 (TREE_OPERAND (t, i),
                                            true, flags))
index 8678626f8b1ebb64bb51071d7e4c1549b04af839..a81b00121cee87eb36a1dd4dfe2d9538f25fe005 100644 (file)
@@ -1,3 +1,26 @@
+2012-06-15  Ramana Radhakrishnan  <ramana.radhakrishnan@linaro.org>
+
+       PR c++/51033
+       * c-c++-common/torture/vshuf-16.inc: Move from gcc.c-torture/execute/.
+       * c-c++-common/torture/vshuf-2.inc: Likewise.
+       * c-c++-common/torture/vshuf-4.inc: Likewise.
+       * c-c++-common/torture/vshuf-8.inc: Likewise.
+       * c-c++-common/torture/vshuf-main.inc: Likewise.
+       * c-c++-common/torture/vshuf-v16hi.c: Likewise.
+       * c-c++-common/torture/vshuf-v16qi.c: Likewise.
+       * c-c++-common/torture/vshuf-v2df.c: Likewise.
+       * c-c++-common/torture/vshuf-v2di.c: Likewise.
+       * c-c++-common/torture/vshuf-v2sf.c: Likewise.
+       * c-c++-common/torture/vshuf-v2si.c: Likewise.
+       * c-c++-common/torture/vshuf-v4df.c: Likewise.
+       * c-c++-common/torture/vshuf-v4di.c: Likewise.
+       * c-c++-common/torture/vshuf-v4hi.c: Likewise.
+       * c-c++-common/torture/vshuf-v4sf.c: Likewise.
+       * c-c++-common/torture/vshuf-v4si.c: Likewise.
+       * c-c++-common/torture/vshuf-v8hi.c: Likewise.
+       * c-c++-common/torture/vshuf-v8qi.c: Likewise.
+       * c-c++-common/torture/vshuf-v8si.c: Likewise.
+
 2012-06-15  Michael Matz  <matz@suse.de>
 
        * gcc.dg/tree-ssa/vector-4.c: New test.
This page took 0.197008 seconds and 5 git commands to generate.