aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-08-30 11:13:13 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-08-30 11:13:13 +0000
commit7a504f3390ecfe3457d37b9d716262a14d5d1938 (patch)
treeb82ca3c1c102db705f30f93ae7aedc8c75c391c2 /gcc/expr.c
parente72b0ef4b787599b87cd16b0d929d5d75c6da6bc (diff)
downloadgcc-7a504f3390ecfe3457d37b9d716262a14d5d1938.zip
gcc-7a504f3390ecfe3457d37b9d716262a14d5d1938.tar.gz
gcc-7a504f3390ecfe3457d37b9d716262a14d5d1938.tar.bz2
[34/77] Add a SCALAR_INT_TYPE_MODE macro
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
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index 433e05b..b68402f 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -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);