rtl.def (CONSTANT_P_RTX): New.

* 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.

From-SVN: r20846
This commit is contained in:
Richard Henderson 1998-06-30 09:19:11 -07:00 committed by Richard Henderson
parent 84001dd054
commit cff48d8f76
5 changed files with 72 additions and 7 deletions

View file

@ -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.

View file

@ -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;

View file

@ -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:

View file

@ -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

View file

@ -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. */