aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Henderson <rth@cygnus.com>1998-06-30 16:19:11 +0000
committerRichard Henderson <rth@cygnus.com>1998-06-30 16:19:11 +0000
commit7324b906c85cef21c881d9c8ab07422892886cf1 (patch)
tree5176e675ace86f9c1b331ce84ab33709cfe7e130
parent6c5a0f86799d2087ec3eb0d42d7a44487dbded91 (diff)
* rtl.def (CONSTANT_P_RTX): New.
* rtl.h (CONSTANT_P): Recognize it. * cse.c (fold_rtx): Eliminate it. * expr.c (can_handle_constant_p): New variable. (init_expr_once): Initialize it. (expand_builtin): Generate CONSTANT_P_RTX if the expression is not immediately recognizable as a constant. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@20846 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog16
-rw-r--r--gcc/cse.c6
-rw-r--r--gcc/expr.c49
-rw-r--r--gcc/rtl.def5
-rw-r--r--gcc/rtl.h3
5 files changed, 72 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c2308f687e6..59396a032a4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,19 @@
+Tue Jun 30 16:01:01 1998 Richard Henderson <rth@cygnus.com>
+
+ * rtl.def (CONSTANT_P_RTX): New.
+ * rtl.h (CONSTANT_P): Recognize it.
+ * cse.c (fold_rtx): Eliminate it.
+ * expr.c (can_handle_constant_p): New variable.
+ (init_expr_once): Initialize it.
+ (expand_builtin): Generate CONSTANT_P_RTX if the expression is not
+ immediately recognizable as a constant.
+
+ * alpha.c (reg_or_6bit_operand): Recognize CONSTANT_P_RTX.
+ (reg_or_8bit_operand, cint8_operand, add_operand): Likewise.
+ (sext_add_operand, and_operand, or_operand): Likewise.
+ (reg_or_cint_operand, some_operand, input_operand): Likewise.
+ * alpha.h (PREDICATE_CODES): Add CONSTANT_P_RTX where needed.
+
1998-06-30 Benjamin Kosnik <bkoz@bliss.nabi.net>
* dbxout.c (dbxout_type_methods): Remove warn_template_debugging.
diff --git a/gcc/cse.c b/gcc/cse.c
index 868b7de3398..bd2aa567d23 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -5715,6 +5715,12 @@ fold_rtx (x, insn)
const_arg1 ? const_arg1 : folded_arg1,
const_arg2 ? const_arg2 : XEXP (x, 2));
break;
+
+ case 'x':
+ /* Always eliminate CONSTANT_P_RTX at this stage. */
+ if (code == CONSTANT_P_RTX)
+ return (const_arg0 ? const1_rtx : const0_rtx);
+ break;
}
return new ? new : x;
diff --git a/gcc/expr.c b/gcc/expr.c
index 666d1ccc403..79c1f9257bd 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -104,6 +104,11 @@ static rtx saveregs_value;
/* Similarly for __builtin_apply_args. */
static rtx apply_args_value;
+/* Nonzero if the machine description has been fixed to accept
+ CONSTANT_P_RTX patterns. We will emit a warning and continue
+ if we find we must actually use such a beast. */
+static int can_handle_constant_p;
+
/* Don't check memory usage, since code is being emitted to check a memory
usage. Used when flag_check_memory_usage is true, to avoid infinite
recursion. */
@@ -239,6 +244,7 @@ init_expr_once ()
{
rtx insn, pat;
enum machine_mode mode;
+ int num_clobbers;
rtx mem, mem1;
char *free_point;
@@ -263,7 +269,6 @@ init_expr_once ()
{
int regno;
rtx reg;
- int num_clobbers;
direct_load[(int) mode] = direct_store[(int) mode] = 0;
PUT_MODE (mem, mode);
@@ -304,10 +309,18 @@ init_expr_once ()
}
}
+ /* Find out if CONSTANT_P_RTX is accepted. */
+ SET_DEST (pat) = gen_rtx_REG (TYPE_MODE (integer_type_node),
+ FIRST_PSEUDO_REGISTER);
+ SET_SRC (pat) = gen_rtx_CONSTANT_P_RTX (TYPE_MODE (integer_type_node),
+ SET_DEST (pat));
+ if (recog (pat, insn, &num_clobbers) >= 0)
+ can_handle_constant_p = 1;
+
end_sequence ();
obfree (free_point);
}
-
+
/* This is run at the start of compiling a function. */
void
@@ -8566,10 +8579,34 @@ expand_builtin (exp, target, subtarget, mode, ignore)
tree arg = TREE_VALUE (arglist);
STRIP_NOPS (arg);
- return (TREE_CODE_CLASS (TREE_CODE (arg)) == 'c'
- || (TREE_CODE (arg) == ADDR_EXPR
- && TREE_CODE (TREE_OPERAND (arg, 0)) == STRING_CST)
- ? const1_rtx : const0_rtx);
+ if (really_constant_p (arg)
+ || (TREE_CODE (arg) == ADDR_EXPR
+ && TREE_CODE (TREE_OPERAND (arg, 0)) == STRING_CST))
+ return const1_rtx;
+
+ /* Only emit CONSTANT_P_RTX if CSE will be run.
+ Moreover, we don't want to expand trees that have side effects,
+ as the original __builtin_constant_p did not evaluate its
+ argument at all, and we would break existing usage by changing
+ this. This quirk was generally useful, eliminating a bit of hair
+ in the writing of the macros that use this function. Now the
+ same thing can be better accomplished in an inline function. */
+
+ if (! cse_not_expected && ! TREE_SIDE_EFFECTS (arg))
+ {
+ /* Lazy fixup of old code: issue a warning and fail the test. */
+ if (! can_handle_constant_p)
+ {
+ warning ("Delayed evaluation of __builtin_constant_p not supported on this target.");
+ warning ("Please report this as a bug to egcs-bugs@cygnus.com.");
+ return const0_rtx;
+ }
+ return gen_rtx_CONSTANT_P_RTX (TYPE_MODE (integer_type_node),
+ expand_expr (arg, NULL_RTX,
+ VOIDmode, 0));
+ }
+
+ return const0_rtx;
}
case BUILT_IN_FRAME_ADDRESS:
diff --git a/gcc/rtl.def b/gcc/rtl.def
index a00d3f1d7c5..1e45157b450 100644
--- a/gcc/rtl.def
+++ b/gcc/rtl.def
@@ -842,6 +842,11 @@ DEF_RTL_EXPR(RANGE_VAR, "range_var", "eti", 'x')
0 is the live bitmap. Operand 1 is the original block number. */
DEF_RTL_EXPR(RANGE_LIVE, "range_live", "bi", 'x')
+/* A unary `__builtin_constant_p' expression. These are only emitted
+ during RTL generation, and then only if optimize > 0. They are
+ eliminated by the first CSE pass. */
+DEF_RTL_EXPR(CONSTANT_P_RTX, "constant_p", "e", 'x')
+
/*
Local variables:
mode:c
diff --git a/gcc/rtl.h b/gcc/rtl.h
index a7eaaf8244d..94a8360b314 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -219,7 +219,8 @@ typedef struct rtvec_def{
#define CONSTANT_P(X) \
(GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \
|| GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST_DOUBLE \
- || GET_CODE (X) == CONST || GET_CODE (X) == HIGH)
+ || GET_CODE (X) == CONST || GET_CODE (X) == HIGH \
+ || GET_CODE (X) == CONSTANT_P_RTX)
/* General accessor macros for accessing the fields of an rtx. */