diff options
author | Neil Booth <neil@daikokuya.demon.co.uk> | 2002-04-01 08:46:10 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2002-04-01 08:46:10 +0000 |
commit | ceef8ce4b43a36a75e3c7df8a8696866fc398a56 (patch) | |
tree | a06146fa6279ee4373ef4b809f8c3aedca99fb3f /gcc/fold-const.c | |
parent | c7a39ea995852db80b150e9b24c68f56461aff6d (diff) | |
download | gcc-ceef8ce4b43a36a75e3c7df8a8696866fc398a56.zip gcc-ceef8ce4b43a36a75e3c7df8a8696866fc398a56.tar.gz gcc-ceef8ce4b43a36a75e3c7df8a8696866fc398a56.tar.bz2 |
c-common.c (unsigned_conversion_warning, [...]): Use new hooks.
* c-common.c (unsigned_conversion_warning, convert_and_check,
unsigned_type, signed_type, shorten_compare,
c_common_get_alias_set, c_common_nodes_and_builtins): Use new hooks.
(unsigned_type, signed_type, signed_or_unsigned_type): Rename.
* c-common.h (unsigned_type, signed_type, signed_or_unsigned_type):
New.
* c-decl.c (grokdeclarator): Update.
* c-format.c (check_format_types): Update.
* c-lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
* c-typeck.c (build_binary_op, convert_for_assignment): Update.
* convert.c (convert_to_integer): Use new hooks.
* expmed.c (make_tree): Use new hooks.
* expr.c (store_expr): Use new hooks.
* fold-const.c (operand_equal_for_comparison_p, build_range_check,
all_ones_mask_p, unextend, fold): Use new hooks.
* langhooks.h (struct lang_hooks_for_types): New hooks.
* tree.h (signed_or_unsigned_type, signed_type,
unsigned_type): Remove.
ada:
* gigi.h (unsigned_type, signed_type, signed_or_unsigned_type):
Rename.
* misc.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
* trans.c (tree_transform, convert_with_check): Update.
* utils.c (unsigned_type, signed_type, signed_or_unsigned_type):
Rename.
cp:
* cp-lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
* decl.c (grokdeclarator): Update.
* mangle.c (write_integer_cst): Update.
* typeck.c (build_binary_op): Update.
f:
* com.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
(unsigned_type, signed_type, signed_or_unsigned_type): Rename.
java:
* expr.c (build_java_binop): Update.
* java-tree.h (java_signed_type, java_unsigned_type,
java_signed_or_unsigned_type): Update.
* lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
* parse.y (patch_binop): Update.
* typeck.c (signed_or_unsigned_type, unsigned_type,
signed_type): Update.
objc:
* objc-lang.c (LANG_HOOKS_SIGNED_TYPE, LANG_HOOKS_UNSIGNED_TYPE,
LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE): New.
From-SVN: r51684
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 875ade3..26bdd66 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -1937,9 +1937,8 @@ operand_equal_for_comparison_p (arg0, arg1, other) /* Make sure shorter operand is extended the right way to match the longer operand. */ - primarg1 = convert (signed_or_unsigned_type (unsignedp1, - TREE_TYPE (primarg1)), - primarg1); + primarg1 = convert ((*lang_hooks.types.signed_or_unsigned_type) + (unsignedp1, TREE_TYPE (primarg1)), primarg1); if (operand_equal_p (arg0, convert (type, primarg1), 0)) return 1; @@ -2622,7 +2621,7 @@ all_ones_mask_p (mask, size) tree tmask; tmask = build_int_2 (~0, ~0); - TREE_TYPE (tmask) = signed_type (type); + TREE_TYPE (tmask) = (*lang_hooks.types.signed_type) (type); force_fit_type (tmask, 0); return tree_int_cst_equal (mask, @@ -3063,7 +3062,7 @@ build_range_check (type, exp, in_p, low, high) else if (integer_zerop (low)) { - utype = unsigned_type (etype); + utype = (*lang_hooks.types.unsigned_type) (etype); return build_range_check (type, convert (utype, exp), 1, 0, convert (utype, high)); } @@ -3316,7 +3315,7 @@ unextend (c, p, unsignedp, mask) zero or one, and the conversion to a signed type can never overflow. We could get an overflow if this conversion is done anywhere else. */ if (TREE_UNSIGNED (type)) - temp = convert (signed_type (type), temp); + temp = convert ((*lang_hooks.types.signed_type) (type), temp); temp = const_binop (LSHIFT_EXPR, temp, size_int (modesize - 1), 0); temp = const_binop (RSHIFT_EXPR, temp, size_int (modesize - p - 1), 0); @@ -5939,7 +5938,7 @@ fold (expr) || TREE_CODE (arg0) == ROUND_MOD_EXPR) && integer_pow2p (TREE_OPERAND (arg0, 1))) { - tree newtype = unsigned_type (TREE_TYPE (arg0)); + tree newtype = (*lang_hooks.types.unsigned_type) (TREE_TYPE (arg0)); tree newmod = build (TREE_CODE (arg0), newtype, convert (newtype, TREE_OPERAND (arg0, 0)), convert (newtype, TREE_OPERAND (arg0, 1))); @@ -6114,25 +6113,18 @@ fold (expr) && TREE_UNSIGNED (TREE_TYPE (arg1)) /* signed_type does not work on pointer types. */ && INTEGRAL_TYPE_P (TREE_TYPE (arg1))) - switch (TREE_CODE (t)) - { - case LE_EXPR: - return fold (build (GE_EXPR, type, - convert (signed_type (TREE_TYPE (arg0)), - arg0), - convert (signed_type (TREE_TYPE (arg1)), - integer_zero_node))); - case GT_EXPR: - return fold (build (LT_EXPR, type, - convert (signed_type (TREE_TYPE (arg0)), - arg0), - convert (signed_type (TREE_TYPE (arg1)), - integer_zero_node))); - - default: - break; - } - + { + if (TREE_CODE (t) == LE_EXPR || TREE_CODE (t) == GT_EXPR) + { + tree st0, st1; + st0 = (*lang_hooks.types.signed_type) (TREE_TYPE (arg0)); + st1 = (*lang_hooks.types.signed_type) (TREE_TYPE (arg1)); + return fold + (build (TREE_CODE (t) == LE_EXPR ? GE_EXPR: LT_EXPR, + type, convert (st0, arg0), + convert (st1, integer_zero_node))); + } + } else if (TREE_INT_CST_HIGH (arg1) == 0 && (TREE_INT_CST_LOW (arg1) == ((unsigned HOST_WIDE_INT) 2 << (width - 1)) - 1) @@ -6506,14 +6498,16 @@ fold (expr) case GE_EXPR: case GT_EXPR: if (TREE_UNSIGNED (TREE_TYPE (arg1))) - arg1 = convert (signed_type (TREE_TYPE (arg1)), arg1); + arg1 = convert ((*lang_hooks.types.signed_type) + (TREE_TYPE (arg1)), arg1); return pedantic_non_lvalue (convert (type, fold (build1 (ABS_EXPR, TREE_TYPE (arg1), arg1)))); case LE_EXPR: case LT_EXPR: if (TREE_UNSIGNED (TREE_TYPE (arg1))) - arg1 = convert (signed_type (TREE_TYPE (arg1)), arg1); + arg1 = convert ((lang_hooks.types.signed_type) + (TREE_TYPE (arg1)), arg1); return pedantic_non_lvalue (negate_expr (convert (type, fold (build1 (ABS_EXPR, |