diff options
Diffstat (limited to 'gcc-4.8/gcc/tree.c')
-rw-r--r-- | gcc-4.8/gcc/tree.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/gcc-4.8/gcc/tree.c b/gcc-4.8/gcc/tree.c index 9c4ddfe50..6d272d095 100644 --- a/gcc-4.8/gcc/tree.c +++ b/gcc-4.8/gcc/tree.c @@ -1619,6 +1619,60 @@ build_one_cst (tree type) } } +/* Return an integer of type TYPE containing all 1's in as much precision as + it contains, or a complex or vector whose subparts are such integers. */ + +tree +build_all_ones_cst (tree type) +{ + if (TREE_CODE (type) == COMPLEX_TYPE) + { + tree scalar = build_all_ones_cst (TREE_TYPE (type)); + return build_complex (type, scalar, scalar); + } + else + return build_minus_one_cst (type); +} + +/* Return a constant of arithmetic type TYPE which is the + opposite of the multiplicative identity of the set TYPE. */ + +tree +build_minus_one_cst (tree type) +{ + switch (TREE_CODE (type)) + { + case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE: + case POINTER_TYPE: case REFERENCE_TYPE: + case OFFSET_TYPE: + return build_int_cst (type, -1); + + case REAL_TYPE: + return build_real (type, dconstm1); + + case FIXED_POINT_TYPE: + /* We can only generate 1 for accum types. */ + gcc_assert (ALL_SCALAR_ACCUM_MODE_P (TYPE_MODE (type))); + return build_fixed (type, fixed_from_double_int (double_int_minus_one, + TYPE_MODE (type))); + + case VECTOR_TYPE: + { + tree scalar = build_minus_one_cst (TREE_TYPE (type)); + + return build_vector_from_val (type, scalar); + } + + case COMPLEX_TYPE: + return build_complex (type, + build_minus_one_cst (TREE_TYPE (type)), + build_zero_cst (TREE_TYPE (type))); + + default: + gcc_unreachable (); + } +} + /* Build 0 constant of type TYPE. This is used by constructor folding and thus the constant should be represented in memory by zero(es). */ |