]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[34/77] Add a SCALAR_INT_TYPE_MODE macro
authorRichard Sandiford <richard.sandiford@linaro.org>
Wed, 30 Aug 2017 11:13:13 +0000 (11:13 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Wed, 30 Aug 2017 11:13:13 +0000 (11:13 +0000)
This patch adds a SCALAR_INT_TYPE_MODE macro that asserts
that the type has a scalar integer mode and returns it as
a scalar_int_mode.

2017-08-30  Richard Sandiford  <richard.sandiford@linaro.org>
    Alan Hayward  <alan.hayward@arm.com>
    David Sherwood  <david.sherwood@arm.com>

gcc/
* tree.h (SCALAR_INT_TYPE_MODE): New macro.
* builtins.c (expand_builtin_signbit): Use it.
* cfgexpand.c (expand_debug_expr): Likewise.
* dojump.c (do_jump): Likewise.
(do_compare_and_jump): Likewise.
* dwarf2cfi.c (expand_builtin_init_dwarf_reg_sizes): Likewise.
* expmed.c (make_tree): Likewise.
* expr.c (expand_expr_real_2): Likewise.
(expand_expr_real_1): Likewise.
(try_casesi): Likewise.
* fold-const-call.c (fold_const_call_ss): Likewise.
* fold-const.c (unextend): Likewise.
(extract_muldiv_1): Likewise.
(fold_single_bit_test): Likewise.
(native_encode_int): Likewise.
(native_encode_string): Likewise.
(native_interpret_int): Likewise.
* gimple-fold.c (gimple_fold_builtin_memset): Likewise.
* internal-fn.c (expand_addsub_overflow): Likewise.
(expand_neg_overflow): Likewise.
(expand_mul_overflow): Likewise.
(expand_arith_overflow): Likewise.
* match.pd: Likewise.
* stor-layout.c (layout_type): Likewise.
* tree-cfg.c (verify_gimple_assign_ternary): Likewise.
* tree-ssa-math-opts.c (convert_mult_to_widen): Likewise.
* tree-ssanames.c (get_range_info): Likewise.
* tree-switch-conversion.c (array_value_type) Likewise.
* tree-vect-patterns.c (vect_recog_rotate_pattern): Likewise.
(vect_recog_divmod_pattern): Likewise.
(vect_recog_mixed_size_cond_pattern): Likewise.
* tree-vrp.c (extract_range_basic): Likewise.
(simplify_float_conversion_using_ranges): Likewise.
* tree.c (int_fits_type_p): Likewise.
* ubsan.c (instrument_bool_enum_load): Likewise.
* varasm.c (mergeable_string_section): Likewise.
(narrowing_initializer_constant_valid_p): Likewise.
(output_constant): Likewise.

gcc/cp/
* cvt.c (cp_convert_to_pointer): Use SCALAR_INT_TYPE_MODE.

gcc/fortran/
* target-memory.c (size_integer): Use SCALAR_INT_TYPE_MODE.
(size_logical): Likewise.

gcc/objc/
* objc-encoding.c (encode_type): Use SCALAR_INT_TYPE_MODE.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r251486

29 files changed:
gcc/ChangeLog
gcc/builtins.c
gcc/cfgexpand.c
gcc/cp/ChangeLog
gcc/cp/cvt.c
gcc/dojump.c
gcc/dwarf2cfi.c
gcc/expmed.c
gcc/expr.c
gcc/fold-const-call.c
gcc/fold-const.c
gcc/fortran/ChangeLog
gcc/fortran/target-memory.c
gcc/gimple-fold.c
gcc/internal-fn.c
gcc/match.pd
gcc/objc/ChangeLog
gcc/objc/objc-encoding.c
gcc/stor-layout.c
gcc/tree-cfg.c
gcc/tree-ssa-math-opts.c
gcc/tree-ssanames.c
gcc/tree-switch-conversion.c
gcc/tree-vect-patterns.c
gcc/tree-vrp.c
gcc/tree.c
gcc/tree.h
gcc/ubsan.c
gcc/varasm.c

index 526c57bb89276fa0f18361e99c3264e068c75b85..37e7b70d20224a3251628ffce183636b08e379d1 100644 (file)
@@ -1,3 +1,46 @@
+2017-08-30  Richard Sandiford  <richard.sandiford@linaro.org>
+           Alan Hayward  <alan.hayward@arm.com>
+           David Sherwood  <david.sherwood@arm.com>
+
+       * tree.h (SCALAR_INT_TYPE_MODE): New macro.
+       * builtins.c (expand_builtin_signbit): Use it.
+       * cfgexpand.c (expand_debug_expr): Likewise.
+       * dojump.c (do_jump): Likewise.
+       (do_compare_and_jump): Likewise.
+       * dwarf2cfi.c (expand_builtin_init_dwarf_reg_sizes): Likewise.
+       * expmed.c (make_tree): Likewise.
+       * expr.c (expand_expr_real_2): Likewise.
+       (expand_expr_real_1): Likewise.
+       (try_casesi): Likewise.
+       * fold-const-call.c (fold_const_call_ss): Likewise.
+       * fold-const.c (unextend): Likewise.
+       (extract_muldiv_1): Likewise.
+       (fold_single_bit_test): Likewise.
+       (native_encode_int): Likewise.
+       (native_encode_string): Likewise.
+       (native_interpret_int): Likewise.
+       * gimple-fold.c (gimple_fold_builtin_memset): Likewise.
+       * internal-fn.c (expand_addsub_overflow): Likewise.
+       (expand_neg_overflow): Likewise.
+       (expand_mul_overflow): Likewise.
+       (expand_arith_overflow): Likewise.
+       * match.pd: Likewise.
+       * stor-layout.c (layout_type): Likewise.
+       * tree-cfg.c (verify_gimple_assign_ternary): Likewise.
+       * tree-ssa-math-opts.c (convert_mult_to_widen): Likewise.
+       * tree-ssanames.c (get_range_info): Likewise.
+       * tree-switch-conversion.c (array_value_type) Likewise.
+       * tree-vect-patterns.c (vect_recog_rotate_pattern): Likewise.
+       (vect_recog_divmod_pattern): Likewise.
+       (vect_recog_mixed_size_cond_pattern): Likewise.
+       * tree-vrp.c (extract_range_basic): Likewise.
+       (simplify_float_conversion_using_ranges): Likewise.
+       * tree.c (int_fits_type_p): Likewise.
+       * ubsan.c (instrument_bool_enum_load): Likewise.
+       * varasm.c (mergeable_string_section): Likewise.
+       (narrowing_initializer_constant_valid_p): Likewise.
+       (output_constant): Likewise.
+
 2017-08-30  Richard Sandiford  <richard.sandiford@linaro.org>
            Alan Hayward  <alan.hayward@arm.com>
            David Sherwood  <david.sherwood@arm.com>
index f65c3888f7ae123f82da7c30cad95f1446813baf..1343e9ddc07a3680ead4f36da6d4e419b27ea6dc 100644 (file)
@@ -5314,7 +5314,7 @@ expand_builtin_signbit (tree exp, rtx target)
 
   arg = CALL_EXPR_ARG (exp, 0);
   fmode = SCALAR_FLOAT_TYPE_MODE (TREE_TYPE (arg));
-  rmode = TYPE_MODE (TREE_TYPE (exp));
+  rmode = SCALAR_INT_TYPE_MODE (TREE_TYPE (exp));
   fmt = REAL_MODE_FORMAT (fmode);
 
   arg = builtin_save_expr (arg);
index ad6f05606ab2777ff8332039eea36e8e8a7649cf..8e93ce83bda9a284f72d31da34c31a55a463aa1a 100644 (file)
@@ -4139,7 +4139,7 @@ expand_debug_expr (tree exp)
   machine_mode inner_mode = VOIDmode;
   int unsignedp = TYPE_UNSIGNED (TREE_TYPE (exp));
   addr_space_t as;
-  scalar_int_mode op0_mode, op1_mode;
+  scalar_int_mode op0_mode, op1_mode, addr_mode;
 
   switch (TREE_CODE_CLASS (TREE_CODE (exp)))
     {
@@ -4914,7 +4914,8 @@ expand_debug_expr (tree exp)
        }
 
       as = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp)));
-      op0 = convert_debug_memory_address (mode, XEXP (op0, 0), as);
+      addr_mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (exp));
+      op0 = convert_debug_memory_address (addr_mode, XEXP (op0, 0), as);
 
       return op0;
 
index fc6231c66595a3ef2bad285b643a05aa40c4bbba..42375e9c90281a4b0db5498f81f5490c0b9fd051 100644 (file)
@@ -1,3 +1,9 @@
+2017-08-30  Richard Sandiford  <richard.sandiford@linaro.org>
+           Alan Hayward  <alan.hayward@arm.com>
+           David Sherwood  <david.sherwood@arm.com>
+
+       * cvt.c (cp_convert_to_pointer): Use SCALAR_INT_TYPE_MODE.
+
 2017-08-30  Richard Sandiford  <richard.sandiford@linaro.org>
            Alan Hayward  <alan.hayward@arm.com>
            David Sherwood  <david.sherwood@arm.com>
index fd758d3c2dc3614390d173c1369f07fd73d92a11..a3bd4a137d82a04411683a2a80d17168dd00373f 100644 (file)
@@ -236,8 +236,8 @@ cp_convert_to_pointer (tree type, tree expr, bool dofold,
       /* Modes may be different but sizes should be the same.  There
         is supposed to be some integral type that is the same width
         as a pointer.  */
-      gcc_assert (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (expr)))
-                 == GET_MODE_SIZE (TYPE_MODE (type)));
+      gcc_assert (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (expr)))
+                 == GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type)));
 
       return convert_to_pointer_maybe_fold (type, expr, dofold);
     }
index b084253505128aa4fdb29151d8231684045de5cc..151d2cb6606a9c696c49d4eb932f48c4442e0961 100644 (file)
@@ -571,7 +571,7 @@ do_jump (tree exp, rtx_code_label *if_false_label,
              if (TREE_CODE (shift) == INTEGER_CST
                  && compare_tree_int (shift, 0) >= 0
                  && compare_tree_int (shift, HOST_BITS_PER_WIDE_INT) < 0
-                 && prefer_and_bit_test (TYPE_MODE (argtype),
+                 && prefer_and_bit_test (SCALAR_INT_TYPE_MODE (argtype),
                                          TREE_INT_CST_LOW (shift)))
                {
                  unsigned HOST_WIDE_INT mask
@@ -1190,17 +1190,14 @@ do_compare_and_jump (tree treeop0, tree treeop1, enum rtx_code signed_code,
     return;
 
   type = TREE_TYPE (treeop0);
-  mode = TYPE_MODE (type);
   if (TREE_CODE (treeop0) == INTEGER_CST
       && (TREE_CODE (treeop1) != INTEGER_CST
-          || (GET_MODE_BITSIZE (mode)
-              > GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (treeop1))))))
-    {
-      /* op0 might have been replaced by promoted constant, in which
-         case the type of second argument should be used.  */
-      type = TREE_TYPE (treeop1);
-      mode = TYPE_MODE (type);
-    }
+         || (GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (type))
+             > GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (treeop1))))))
+    /* op0 might have been replaced by promoted constant, in which
+       case the type of second argument should be used.  */
+    type = TREE_TYPE (treeop1);
+  mode = TYPE_MODE (type);
   unsignedp = TYPE_UNSIGNED (type);
   code = unsignedp ? unsigned_code : signed_code;
 
index 371e90e2a30856cdbd263aad776445b604ee16ce..8c934842bf8b5d1ebb31008f7fb9881dee5cddd0 100644 (file)
@@ -299,7 +299,7 @@ void
 expand_builtin_init_dwarf_reg_sizes (tree address)
 {
   unsigned int i;
-  machine_mode mode = TYPE_MODE (char_type_node);
+  scalar_int_mode mode = SCALAR_INT_TYPE_MODE (char_type_node);
   rtx addr = expand_normal (address);
   rtx mem = gen_rtx_MEM (BLKmode, addr);
 
index 292fed343d2d93069a096e4f92933d23882c65bc..1cae1000cdc6c6f4f649612f41ea738e3c5636f7 100644 (file)
@@ -5250,7 +5250,7 @@ make_tree (tree type, rtx x)
         address mode to pointer mode.  */
       if (POINTER_TYPE_P (type))
        x = convert_memory_address_addr_space
-             (TYPE_MODE (type), x, TYPE_ADDR_SPACE (TREE_TYPE (type)));
+         (SCALAR_INT_TYPE_MODE (type), x, TYPE_ADDR_SPACE (TREE_TYPE (type)));
 
       /* Note that we do *not* use SET_DECL_RTL here, because we do not
         want set_decl_rtl to go adjusting REG_ATTRS for this temporary.  */
index 433e05ba9f4da922745892bccd9fa4b615d725af..b68402fe9d6fa520b6513f07421e47ae90ff5a12 100644 (file)
@@ -9077,11 +9077,12 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
         instead.  */
       if (reduce_bit_field && TYPE_UNSIGNED (type))
        {
+         int_mode = SCALAR_INT_TYPE_MODE (type);
          wide_int mask = wi::mask (TYPE_PRECISION (type),
-                                   false, GET_MODE_PRECISION (mode));
+                                   false, GET_MODE_PRECISION (int_mode));
 
-         temp = expand_binop (mode, xor_optab, op0,
-                              immed_wide_int_const (mask, mode),
+         temp = expand_binop (int_mode, xor_optab, op0,
+                              immed_wide_int_const (mask, int_mode),
                               target, 1, OPTAB_LIB_WIDEN);
        }
       else
@@ -9181,7 +9182,7 @@ expand_expr_real_2 (sepops ops, rtx target, machine_mode tmode,
            if (is_gimple_assign (def)
                && gimple_assign_rhs_code (def) == NOP_EXPR)
              {
-               machine_mode rmode = TYPE_MODE
+               scalar_int_mode rmode = SCALAR_INT_TYPE_MODE
                  (TREE_TYPE (gimple_assign_rhs1 (def)));
 
                if (GET_MODE_SIZE (rmode) < GET_MODE_SIZE (int_mode)
@@ -9949,15 +9950,16 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
       return decl_rtl;
 
     case INTEGER_CST:
-      /* Given that TYPE_PRECISION (type) is not always equal to
-         GET_MODE_PRECISION (TYPE_MODE (type)), we need to extend from
-         the former to the latter according to the signedness of the
-         type. */
-      temp = immed_wide_int_const (wi::to_wide
-                                  (exp,
-                                   GET_MODE_PRECISION (TYPE_MODE (type))),
-                                  TYPE_MODE (type));
-      return temp;
+      {
+       /* Given that TYPE_PRECISION (type) is not always equal to
+          GET_MODE_PRECISION (TYPE_MODE (type)), we need to extend from
+          the former to the latter according to the signedness of the
+          type.  */
+       scalar_int_mode mode = SCALAR_INT_TYPE_MODE (type);
+       temp = immed_wide_int_const
+         (wi::to_wide (exp, GET_MODE_PRECISION (mode)), mode);
+       return temp;
+      }
 
     case VECTOR_CST:
       {
@@ -10416,7 +10418,8 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode,
                if (DECL_BIT_FIELD (field))
                  {
                    HOST_WIDE_INT bitsize = TREE_INT_CST_LOW (DECL_SIZE (field));
-                   machine_mode imode = TYPE_MODE (TREE_TYPE (field));
+                   scalar_int_mode imode
+                     = SCALAR_INT_TYPE_MODE (TREE_TYPE (field));
 
                    if (TYPE_UNSIGNED (TREE_TYPE (field)))
                      {
@@ -11546,10 +11549,10 @@ try_casesi (tree index_type, tree index_expr, tree minval, tree range,
   if (! targetm.have_casesi ())
     return 0;
 
-  /* Convert the index to SImode.  */
-  if (GET_MODE_BITSIZE (TYPE_MODE (index_type)) > GET_MODE_BITSIZE (index_mode))
+  /* The index must be some form of integer.  Convert it to SImode.  */
+  scalar_int_mode omode = SCALAR_INT_TYPE_MODE (index_type);
+  if (GET_MODE_BITSIZE (omode) > GET_MODE_BITSIZE (index_mode))
     {
-      machine_mode omode = TYPE_MODE (index_type);
       rtx rangertx = expand_normal (range);
 
       /* We must handle the endpoints in the original mode.  */
@@ -11566,7 +11569,7 @@ try_casesi (tree index_type, tree index_expr, tree minval, tree range,
     }
   else
     {
-      if (TYPE_MODE (index_type) != index_mode)
+      if (omode != index_mode)
        {
          index_type = lang_hooks.types.type_for_mode (index_mode, 0);
          index_expr = fold_convert (index_type, index_expr);
index 381cb7fd2905b3a5957a28bce735226ba7a5cf16..71f0b52468040ae4a5faa11a51f9cd4bc0e41119 100644 (file)
@@ -844,7 +844,8 @@ fold_const_call_ss (wide_int *result, combined_fn fn, const wide_int_ref &arg,
        int tmp;
        if (wi::ne_p (arg, 0))
          tmp = wi::clz (arg);
-       else if (! CLZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (arg_type), tmp))
+       else if (!CLZ_DEFINED_VALUE_AT_ZERO (SCALAR_INT_TYPE_MODE (arg_type),
+                                            tmp))
          tmp = TYPE_PRECISION (arg_type);
        *result = wi::shwi (tmp, precision);
        return true;
@@ -855,7 +856,8 @@ fold_const_call_ss (wide_int *result, combined_fn fn, const wide_int_ref &arg,
        int tmp;
        if (wi::ne_p (arg, 0))
          tmp = wi::ctz (arg);
-       else if (! CTZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (arg_type), tmp))
+       else if (!CTZ_DEFINED_VALUE_AT_ZERO (SCALAR_INT_TYPE_MODE (arg_type),
+                                            tmp))
          tmp = TYPE_PRECISION (arg_type);
        *result = wi::shwi (tmp, precision);
        return true;
index b9f2a39ee853e6071e39783f5bb3d7a68166b85e..d4d3c444297e3db61dc613c7bc7bd70df202201b 100644 (file)
@@ -5441,7 +5441,7 @@ static tree
 unextend (tree c, int p, int unsignedp, tree mask)
 {
   tree type = TREE_TYPE (c);
-  int modesize = GET_MODE_BITSIZE (TYPE_MODE (type));
+  int modesize = GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (type));
   tree temp;
 
   if (p == modesize || unsignedp)
@@ -6031,8 +6031,9 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type,
 {
   tree type = TREE_TYPE (t);
   enum tree_code tcode = TREE_CODE (t);
-  tree ctype = (wide_type != 0 && (GET_MODE_SIZE (TYPE_MODE (wide_type))
-                                  > GET_MODE_SIZE (TYPE_MODE (type)))
+  tree ctype = (wide_type != 0
+               && (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (wide_type))
+                   > GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type)))
                ? wide_type : type);
   tree t1, t2;
   int same_p = tcode == code;
@@ -6669,7 +6670,7 @@ fold_single_bit_test (location_t loc, enum tree_code code,
       tree inner = TREE_OPERAND (arg0, 0);
       tree type = TREE_TYPE (arg0);
       int bitnum = tree_log2 (TREE_OPERAND (arg0, 1));
-      machine_mode operand_mode = TYPE_MODE (type);
+      scalar_int_mode operand_mode = SCALAR_INT_TYPE_MODE (type);
       int ops_unsigned;
       tree signed_type, unsigned_type, intermediate_type;
       tree tem, one;
@@ -6980,7 +6981,7 @@ static int
 native_encode_int (const_tree expr, unsigned char *ptr, int len, int off)
 {
   tree type = TREE_TYPE (expr);
-  int total_bytes = GET_MODE_SIZE (TYPE_MODE (type));
+  int total_bytes = GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type));
   int byte, offset, word, words;
   unsigned char value;
 
@@ -7190,7 +7191,8 @@ native_encode_string (const_tree expr, unsigned char *ptr, int len, int off)
 
   if (TREE_CODE (type) != ARRAY_TYPE
       || TREE_CODE (TREE_TYPE (type)) != INTEGER_TYPE
-      || GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (type))) != BITS_PER_UNIT
+      || (GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (type)))
+         != BITS_PER_UNIT)
       || !tree_fits_shwi_p (TYPE_SIZE_UNIT (type)))
     return 0;
   total_bytes = tree_to_shwi (TYPE_SIZE_UNIT (type));
@@ -7262,7 +7264,7 @@ native_encode_expr (const_tree expr, unsigned char *ptr, int len, int off)
 static tree
 native_interpret_int (tree type, const unsigned char *ptr, int len)
 {
-  int total_bytes = GET_MODE_SIZE (TYPE_MODE (type));
+  int total_bytes = GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (type));
 
   if (total_bytes > len
       || total_bytes * BITS_PER_UNIT > HOST_BITS_PER_DOUBLE_INT)
index 247e04a697b308591cbd3420c4ed3a305d2bb0c5..c0d684b4f10af9d1096b1a3821032aef5494b9e7 100644 (file)
@@ -1,3 +1,10 @@
+2017-08-30  Richard Sandiford  <richard.sandiford@linaro.org>
+           Alan Hayward  <alan.hayward@arm.com>
+           David Sherwood  <david.sherwood@arm.com>
+
+       * target-memory.c (size_integer): Use SCALAR_INT_TYPE_MODE.
+       (size_logical): Likewise.
+
 2017-08-30  Richard Sandiford  <richard.sandiford@linaro.org>
            Alan Hayward  <alan.hayward@arm.com>
            David Sherwood  <david.sherwood@arm.com>
index 1c8de1c59aa3d2587e36bc8fb13d73d4b11ebe59..ceca3accd9390ed41bf41e4360a27fce3e80e9a4 100644 (file)
@@ -39,7 +39,7 @@ along with GCC; see the file COPYING3.  If not see
 static size_t
 size_integer (int kind)
 {
-  return GET_MODE_SIZE (TYPE_MODE (gfc_get_int_type (kind)));;
+  return GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (gfc_get_int_type (kind)));
 }
 
 
@@ -60,7 +60,7 @@ size_complex (int kind)
 static size_t
 size_logical (int kind)
 {
-  return GET_MODE_SIZE (TYPE_MODE (gfc_get_logical_type (kind)));;
+  return GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (gfc_get_logical_type (kind)));
 }
 
 
index 5886b3db91c9e59a38f3c588137bc537cc1e5d76..367b35c5c9ba6f70f89d0e4314a86f4a1cf84076 100644 (file)
@@ -1230,7 +1230,7 @@ gimple_fold_builtin_memset (gimple_stmt_iterator *gsi, tree c, tree len)
     return NULL_TREE;
 
   length = tree_to_uhwi (len);
-  if (GET_MODE_SIZE (TYPE_MODE (etype)) != length
+  if (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (etype)) != length
       || get_pointer_alignment (dest) / BITS_PER_UNIT < length)
     return NULL_TREE;
 
index 2c243fdf44ae02dd10ee0c816bb7e44aeba63449..724ada357192dde11e6000190db522f22ed7270a 100644 (file)
@@ -645,7 +645,7 @@ expand_addsub_overflow (location_t loc, tree_code code, tree lhs,
   do_pending_stack_adjust ();
   rtx op0 = expand_normal (arg0);
   rtx op1 = expand_normal (arg1);
-  machine_mode mode = TYPE_MODE (TREE_TYPE (arg0));
+  scalar_int_mode mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg0));
   int prec = GET_MODE_PRECISION (mode);
   rtx sgn = immed_wide_int_const (wi::min_value (prec, SIGNED), mode);
   bool do_xor = false;
@@ -1097,7 +1097,7 @@ expand_neg_overflow (location_t loc, tree lhs, tree arg1, bool is_ubsan,
   do_pending_stack_adjust ();
   op1 = expand_normal (arg1);
 
-  machine_mode mode = TYPE_MODE (TREE_TYPE (arg1));
+  scalar_int_mode mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg1));
   if (lhs)
     {
       target = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
@@ -1192,7 +1192,7 @@ expand_mul_overflow (location_t loc, tree lhs, tree arg0, tree arg1,
   op0 = expand_normal (arg0);
   op1 = expand_normal (arg1);
 
-  machine_mode mode = TYPE_MODE (TREE_TYPE (arg0));
+  scalar_int_mode mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg0));
   bool uns = unsr_p;
   if (lhs)
     {
@@ -2120,7 +2120,7 @@ expand_arith_overflow (enum tree_code code, gimple *stmt)
          /* The infinity precision result will always fit into result.  */
          rtx target = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
          write_complex_part (target, const0_rtx, true);
-         machine_mode mode = TYPE_MODE (type);
+         scalar_int_mode mode = SCALAR_INT_TYPE_MODE (type);
          struct separate_ops ops;
          ops.code = code;
          ops.type = type;
index 69dd8193cd0524d99fba8be8da8183230b8d621a..ff8f7b18f6a6bdd74b0a6603d3f327a3d4210d59 100644 (file)
@@ -3397,7 +3397,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
             associated with the mode of @1, so the sign bit is
             specified by this mode.  Check that @1 is the signed
             max associated with this sign bit.  */
-         && prec == GET_MODE_PRECISION (TYPE_MODE (arg1_type))
+         && prec == GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (arg1_type))
          /* signed_type does not work on pointer types.  */
          && INTEGRAL_TYPE_P (arg1_type))
       /* The following case also applies to X < signed_max+1
index 8270c92e91e91bd1b20a0ba957a54282f61008f2..d5929493fe3cf4ee63f7a3e8c34c0b3599f7bbc2 100644 (file)
@@ -1,3 +1,9 @@
+2017-08-30  Richard Sandiford  <richard.sandiford@linaro.org>
+           Alan Hayward  <alan.hayward@arm.com>
+           David Sherwood  <david.sherwood@arm.com>
+
+       * objc-encoding.c (encode_type): Use SCALAR_INT_TYPE_MODE.
+
 2017-08-30  Richard Sandiford  <richard.sandiford@linaro.org>
            Alan Hayward  <alan.hayward@arm.com>
            David Sherwood  <david.sherwood@arm.com>
index bd59a29265e68504c99c4e64b0a97be309cc5032..9f46d57ac8ca5f10c08aa6c59a496dfbde361ab4 100644 (file)
@@ -626,7 +626,7 @@ encode_type (tree type, int curtype, int format)
     case INTEGER_TYPE:
       {
        char c;
-       switch (GET_MODE_BITSIZE (TYPE_MODE (type)))
+       switch (GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (type)))
          {
          case 8:  c = TYPE_UNSIGNED (type) ? 'C' : 'c'; break;
          case 16: c = TYPE_UNSIGNED (type) ? 'S' : 's'; break;
index e447f4f9346dfd5101ea5bde3b92cb2848f88804..e37c15f3dad406e508ce96ffae50703a17bf5ae1 100644 (file)
@@ -2309,7 +2309,7 @@ layout_type (tree type)
     case POINTER_TYPE:
     case REFERENCE_TYPE:
       {
-       machine_mode mode = TYPE_MODE (type);
+       scalar_int_mode mode = SCALAR_INT_TYPE_MODE (type);
        TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (mode));
        TYPE_SIZE_UNIT (type) = size_int (GET_MODE_SIZE (mode));
        TYPE_UNSIGNED (type) = 1;
index 6c355f1ed70c6a158e29beeeef5f43577ee6d989..c156b81b186d55b5d8f7194d18a6078dcc6a0a92 100644 (file)
@@ -4191,7 +4191,7 @@ verify_gimple_assign_ternary (gassign *stmt)
        }
 
       if (TREE_CODE (TREE_TYPE (rhs3_type)) != INTEGER_TYPE
-         || GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (rhs3_type)))
+         || GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (rhs3_type)))
             != GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (rhs1_type))))
        {
          error ("invalid mask type in vector permute expression");
index e6b7dbdf100c3ff8a3b332b02a09b1970529770d..86a1559050de5c6d5eb8b6a10e3baee77054629c 100644 (file)
@@ -3256,8 +3256,8 @@ convert_mult_to_widen (gimple *stmt, gimple_stmt_iterator *gsi)
   if (!is_widening_mult_p (stmt, &type1, &rhs1, &type2, &rhs2))
     return false;
 
-  to_mode = TYPE_MODE (type);
-  from_mode = TYPE_MODE (type1);
+  to_mode = SCALAR_INT_TYPE_MODE (type);
+  from_mode = SCALAR_INT_TYPE_MODE (type1);
   from_unsigned1 = TYPE_UNSIGNED (type1);
   from_unsigned2 = TYPE_UNSIGNED (type2);
 
index e48d0860d732a76092bedd5846461d7dca9b8248..5c96075a05e86033bbe44d4a471a1d026da5c8d3 100644 (file)
@@ -405,7 +405,7 @@ get_range_info (const_tree name, wide_int *min, wide_int *max)
 
   /* Return VR_VARYING for SSA_NAMEs with NULL RANGE_INFO or SSA_NAMEs
      with integral types width > 2 * HOST_BITS_PER_WIDE_INT precision.  */
-  if (!ri || (GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (name)))
+  if (!ri || (GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (TREE_TYPE (name)))
              > 2 * HOST_BITS_PER_WIDE_INT))
     return VR_VARYING;
 
index 9f88869fbf9e2e2ddc503a569a3b268853fe79ae..82961d8985c8f71694dc3f785cf12bf192676eb2 100644 (file)
@@ -1050,7 +1050,7 @@ array_value_type (gswitch *swtch, tree type, int num,
   if (!INTEGRAL_TYPE_P (type))
     return type;
 
-  machine_mode type_mode = TYPE_MODE (type);
+  scalar_int_mode type_mode = SCALAR_INT_TYPE_MODE (type);
   machine_mode mode = get_narrowest_mode (type_mode);
   if (GET_MODE_SIZE (type_mode) <= GET_MODE_SIZE (mode))
     return type;
@@ -1097,8 +1097,8 @@ array_value_type (gswitch *swtch, tree type, int num,
   if (sign == 0)
     sign = TYPE_UNSIGNED (type) ? 1 : -1;
   smaller_type = lang_hooks.types.type_for_mode (mode, sign >= 0);
-  if (GET_MODE_SIZE (TYPE_MODE (type))
-      <= GET_MODE_SIZE (TYPE_MODE (smaller_type)))
+  if (GET_MODE_SIZE (type_mode)
+      <= GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (smaller_type)))
     return type;
 
   return smaller_type;
index cfdb72c6499fdcd2ffb954fe553fc1d7dd4e987b..6bc4f7ed7adef04e864aadb744f294360f694afa 100644 (file)
@@ -1883,13 +1883,14 @@ vect_recog_rotate_pattern (vec<gimple *> *stmts, tree *type_in, tree *type_out)
     }
 
   def = NULL_TREE;
+  scalar_int_mode mode = SCALAR_INT_TYPE_MODE (type);
   if (TREE_CODE (oprnd1) == INTEGER_CST
-      || TYPE_MODE (TREE_TYPE (oprnd1)) == TYPE_MODE (type))
+      || TYPE_MODE (TREE_TYPE (oprnd1)) == mode)
     def = oprnd1;
   else if (def_stmt && gimple_assign_cast_p (def_stmt))
     {
       tree rhs1 = gimple_assign_rhs1 (def_stmt);
-      if (TYPE_MODE (TREE_TYPE (rhs1)) == TYPE_MODE (type)
+      if (TYPE_MODE (TREE_TYPE (rhs1)) == mode
          && TYPE_PRECISION (TREE_TYPE (rhs1))
             == TYPE_PRECISION (type))
        def = rhs1;
@@ -1910,16 +1911,16 @@ vect_recog_rotate_pattern (vec<gimple *> *stmts, tree *type_in, tree *type_out)
        append_pattern_def_seq (stmt_vinfo, def_stmt);
     }
   stype = TREE_TYPE (def);
+  scalar_int_mode smode = SCALAR_INT_TYPE_MODE (stype);
 
   if (TREE_CODE (def) == INTEGER_CST)
     {
       if (!tree_fits_uhwi_p (def)
-         || tree_to_uhwi (def) >= GET_MODE_PRECISION (TYPE_MODE (type))
+         || tree_to_uhwi (def) >= GET_MODE_PRECISION (mode)
          || integer_zerop (def))
        return NULL;
       def2 = build_int_cst (stype,
-                           GET_MODE_PRECISION (TYPE_MODE (type))
-                           - tree_to_uhwi (def));
+                           GET_MODE_PRECISION (mode) - tree_to_uhwi (def));
     }
   else
     {
@@ -1945,8 +1946,7 @@ vect_recog_rotate_pattern (vec<gimple *> *stmts, tree *type_in, tree *type_out)
        }
 
       def2 = vect_recog_temp_ssa_var (stype, NULL);
-      tree mask
-       = build_int_cst (stype, GET_MODE_PRECISION (TYPE_MODE (stype)) - 1);
+      tree mask = build_int_cst (stype, GET_MODE_PRECISION (smode) - 1);
       def_stmt = gimple_build_assign (def2, BIT_AND_EXPR,
                                      gimple_assign_lhs (def_stmt), mask);
       if (ext_def)
@@ -2588,6 +2588,7 @@ vect_recog_divmod_pattern (vec<gimple *> *stmts,
       || !type_has_mode_precision_p (itype))
     return NULL;
 
+  scalar_int_mode itype_mode = SCALAR_INT_TYPE_MODE (itype);
   vectype = get_vectype_for_scalar_type (itype);
   if (vectype == NULL_TREE)
     return NULL;
@@ -2655,7 +2656,7 @@ vect_recog_divmod_pattern (vec<gimple *> *stmts,
                = build_nonstandard_integer_type (prec, 1);
              tree vecutype = get_vectype_for_scalar_type (utype);
              tree shift
-               = build_int_cst (utype, GET_MODE_BITSIZE (TYPE_MODE (itype))
+               = build_int_cst (utype, GET_MODE_BITSIZE (itype_mode)
                                        - tree_log2 (oprnd1));
              tree var = vect_recog_temp_ssa_var (utype, NULL);
 
@@ -2721,7 +2722,7 @@ vect_recog_divmod_pattern (vec<gimple *> *stmts,
       unsigned HOST_WIDE_INT mh, ml;
       int pre_shift, post_shift;
       unsigned HOST_WIDE_INT d = (TREE_INT_CST_LOW (oprnd1)
-                                 & GET_MODE_MASK (TYPE_MODE (itype)));
+                                 & GET_MODE_MASK (itype_mode));
       tree t1, t2, t3, t4;
 
       if (d >= (HOST_WIDE_INT_1U << (prec - 1)))
@@ -3066,7 +3067,8 @@ vect_recog_mixed_size_cond_pattern (vec<gimple *> *stmts, tree *type_in,
   HOST_WIDE_INT cmp_mode_size
     = GET_MODE_UNIT_BITSIZE (TYPE_MODE (comp_vectype));
 
-  if (GET_MODE_BITSIZE (TYPE_MODE (type)) == cmp_mode_size)
+  scalar_int_mode type_mode = SCALAR_INT_TYPE_MODE (type);
+  if (GET_MODE_BITSIZE (type_mode) == cmp_mode_size)
     return NULL;
 
   vectype = get_vectype_for_scalar_type (type);
@@ -3091,7 +3093,7 @@ vect_recog_mixed_size_cond_pattern (vec<gimple *> *stmts, tree *type_in,
   if (!expand_vec_cond_expr_p (vecitype, comp_vectype, TREE_CODE (cond_expr)))
     return NULL;
 
-  if (GET_MODE_BITSIZE (TYPE_MODE (type)) > cmp_mode_size)
+  if (GET_MODE_BITSIZE (type_mode) > cmp_mode_size)
     {
       if ((TREE_CODE (then_clause) == INTEGER_CST
           && !int_fits_type_p (then_clause, itype))
index dc5554d1ad86f5face6b13f0c575b38b626c635b..dc5f00ed0ec0f3e1d6d89198970fe4b4d0976b4d 100644 (file)
@@ -3572,6 +3572,7 @@ extract_range_basic (value_range *vr, gimple *stmt)
       int mini, maxi, zerov = 0, prec;
       enum tree_code subcode = ERROR_MARK;
       combined_fn cfn = gimple_call_combined_fn (stmt);
+      scalar_int_mode mode;
 
       switch (cfn)
        {
@@ -3632,10 +3633,9 @@ extract_range_basic (value_range *vr, gimple *stmt)
          prec = TYPE_PRECISION (TREE_TYPE (arg));
          mini = 0;
          maxi = prec;
-         if (optab_handler (clz_optab, TYPE_MODE (TREE_TYPE (arg)))
-             != CODE_FOR_nothing
-             && CLZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (TREE_TYPE (arg)),
-                                           zerov)
+         mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg));
+         if (optab_handler (clz_optab, mode) != CODE_FOR_nothing
+             && CLZ_DEFINED_VALUE_AT_ZERO (mode, zerov)
              /* Handle only the single common value.  */
              && zerov != prec)
            /* Magic value to give up, unless vr0 proves
@@ -3684,10 +3684,9 @@ extract_range_basic (value_range *vr, gimple *stmt)
          prec = TYPE_PRECISION (TREE_TYPE (arg));
          mini = 0;
          maxi = prec - 1;
-         if (optab_handler (ctz_optab, TYPE_MODE (TREE_TYPE (arg)))
-             != CODE_FOR_nothing
-             && CTZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (TREE_TYPE (arg)),
-                                           zerov))
+         mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg));
+         if (optab_handler (ctz_optab, mode) != CODE_FOR_nothing
+             && CTZ_DEFINED_VALUE_AT_ZERO (mode, zerov))
            {
              /* Handle only the two common values.  */
              if (zerov == -1)
@@ -10107,13 +10106,13 @@ simplify_float_conversion_using_ranges (gimple_stmt_iterator *gsi,
     return false;
 
   /* First check if we can use a signed type in place of an unsigned.  */
+  scalar_int_mode rhs_mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (rhs1));
   if (TYPE_UNSIGNED (TREE_TYPE (rhs1))
-      && (can_float_p (fltmode, TYPE_MODE (TREE_TYPE (rhs1)), 0)
-         != CODE_FOR_nothing)
+      && can_float_p (fltmode, rhs_mode, 0) != CODE_FOR_nothing
       && range_fits_type_p (vr, TYPE_PRECISION (TREE_TYPE (rhs1)), SIGNED))
-    mode = TYPE_MODE (TREE_TYPE (rhs1));
+    mode = rhs_mode;
   /* If we can do the conversion in the current input mode do nothing.  */
-  else if (can_float_p (fltmode, TYPE_MODE (TREE_TYPE (rhs1)),
+  else if (can_float_p (fltmode, rhs_mode,
                        TYPE_UNSIGNED (TREE_TYPE (rhs1))) != CODE_FOR_nothing)
     return false;
   /* Otherwise search for a mode we can use, starting from the narrowest
index c36183487a5ca41e4137cb8c61e6e742d03b9d4f..67be31f6684d85bf7188a20501ce7566aa9f8bd0 100644 (file)
@@ -8461,7 +8461,7 @@ retry:
   /* Third, unsigned integers with top bit set never fit signed types.  */
   if (!TYPE_UNSIGNED (type) && sgn_c == UNSIGNED)
     {
-      int prec = GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (c))) - 1;
+      int prec = GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (TREE_TYPE (c))) - 1;
       if (prec < TYPE_PRECISION (TREE_TYPE (c)))
        {
          /* When a tree_cst is converted to a wide-int, the precision
index 47dfa38b04578bc938430919f6b50c534eef0ed6..8347669b414fe497402b94930fdea704b3fd2563 100644 (file)
@@ -1849,6 +1849,8 @@ extern void protected_set_expr_location (tree, location_t);
 #define TYPE_MODE(NODE) \
   (VECTOR_TYPE_P (TYPE_CHECK (NODE)) \
    ? vector_type_mode (NODE) : (NODE)->type_common.mode)
+#define SCALAR_INT_TYPE_MODE(NODE) \
+  (as_a <scalar_int_mode> (TYPE_CHECK (NODE)->type_common.mode))
 #define SCALAR_FLOAT_TYPE_MODE(NODE) \
   (as_a <scalar_float_mode> (TYPE_CHECK (NODE)->type_common.mode))
 #define SET_TYPE_MODE(NODE, MODE) \
index 49e38fa6c09a69432c134b08a2cdf591ae68d58c..9b2083ff42bca831842bb2fe200c768d868f543d 100644 (file)
@@ -1659,7 +1659,7 @@ instrument_bool_enum_load (gimple_stmt_iterator *gsi)
           && TREE_TYPE (type) != NULL_TREE
           && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE
           && (TYPE_PRECISION (TREE_TYPE (type))
-              < GET_MODE_PRECISION (TYPE_MODE (type))))
+              < GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (type))))
     {
       minv = TYPE_MIN_VALUE (TREE_TYPE (type));
       maxv = TYPE_MAX_VALUE (TREE_TYPE (type));
@@ -1667,7 +1667,7 @@ instrument_bool_enum_load (gimple_stmt_iterator *gsi)
   else
     return;
 
-  int modebitsize = GET_MODE_BITSIZE (TYPE_MODE (type));
+  int modebitsize = GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (type));
   HOST_WIDE_INT bitsize, bitpos;
   tree offset;
   machine_mode mode;
@@ -1679,7 +1679,7 @@ instrument_bool_enum_load (gimple_stmt_iterator *gsi)
   if ((VAR_P (base) && DECL_HARD_REGISTER (base))
       || (bitpos % modebitsize) != 0
       || bitsize != modebitsize
-      || GET_MODE_BITSIZE (TYPE_MODE (utype)) != modebitsize
+      || GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (utype)) != modebitsize
       || TREE_CODE (gimple_assign_lhs (stmt)) != SSA_NAME)
     return;
 
index 21fee7fd15f01e8789069030efde73ba99de088e..04f19e6c8ecc4dd493d3434759c786cbbabe7c98 100644 (file)
@@ -785,7 +785,7 @@ mergeable_string_section (tree decl ATTRIBUTE_UNUSED,
       && (len = int_size_in_bytes (TREE_TYPE (decl))) > 0
       && TREE_STRING_LENGTH (decl) >= len)
     {
-      machine_mode mode;
+      scalar_int_mode mode;
       unsigned int modesize;
       const char *str;
       HOST_WIDE_INT i;
@@ -793,7 +793,7 @@ mergeable_string_section (tree decl ATTRIBUTE_UNUSED,
       const char *prefix = function_mergeable_rodata_prefix ();
       char *name = (char *) alloca (strlen (prefix) + 30);
 
-      mode = TYPE_MODE (TREE_TYPE (TREE_TYPE (decl)));
+      mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (TREE_TYPE (decl)));
       modesize = GET_MODE_BITSIZE (mode);
       if (modesize >= 8 && modesize <= 256
          && (modesize & (modesize - 1)) == 0)
@@ -4328,8 +4328,8 @@ narrowing_initializer_constant_valid_p (tree value, tree endtype, tree *cache)
       tree inner = TREE_OPERAND (op0, 0);
       if (inner == error_mark_node
          || ! INTEGRAL_MODE_P (TYPE_MODE (TREE_TYPE (inner)))
-         || (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op0)))
-             > GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (inner)))))
+         || (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (op0)))
+             > GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (inner)))))
        break;
       op0 = inner;
     }
@@ -4340,8 +4340,8 @@ narrowing_initializer_constant_valid_p (tree value, tree endtype, tree *cache)
       tree inner = TREE_OPERAND (op1, 0);
       if (inner == error_mark_node
          || ! INTEGRAL_MODE_P (TYPE_MODE (TREE_TYPE (inner)))
-         || (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op1)))
-             > GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (inner)))))
+         || (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (op1)))
+             > GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (inner)))))
        break;
       op1 = inner;
     }
@@ -4766,7 +4766,7 @@ output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align,
   if (TREE_CODE (exp) == NOP_EXPR
       && POINTER_TYPE_P (TREE_TYPE (exp))
       && targetm.addr_space.valid_pointer_mode
-          (TYPE_MODE (TREE_TYPE (exp)),
+          (SCALAR_INT_TYPE_MODE (TREE_TYPE (exp)),
            TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp)))))
     {
       tree saved_type = TREE_TYPE (exp);
@@ -4776,7 +4776,7 @@ output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align,
       while (TREE_CODE (exp) == NOP_EXPR
             && POINTER_TYPE_P (TREE_TYPE (exp))
             && targetm.addr_space.valid_pointer_mode
-                 (TYPE_MODE (TREE_TYPE (exp)),
+                 (SCALAR_INT_TYPE_MODE (TREE_TYPE (exp)),
                   TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (exp)))))
        exp = TREE_OPERAND (exp, 0);