This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[RFA:] Adjust documentation for LEGITIMATE_CONSTANT_P et al to match reality
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 7 Sep 2008 18:27:59 +0200
- Subject: [RFA:] Adjust documentation for LEGITIMATE_CONSTANT_P et al to match reality
See recent discussion on gcc@ regarding "PR37363: PR36090 and
PR36182 all over again",
e.g. <http://gcc.gnu.org/ml/gcc/2008-09/msg00170.html>. There
seems to be consensus that the current state of affairs
regarding CONST contents wins.
Tested with "make info-gcc dvi-gcc" and inspecting messages and
output.
* doc/tm.texi (Addressing Modes) <CONSTANT_ADDRESS_P>: Recommend
using CONSTANT_P in conjunction with CONST contents test.
<CONSTANT_P, GO_IF_LEGITIMATE_ADDRESS>: Ditto.
<LEGITIMATE_CONSTANT_P>: Do not recommend to define as 1.
Advise to check CONST contents.
(PIC) <LEGITIMATE_PIC_OPERAND_P>: Remove sentence advising to
leave undefined in the rare special case of all constants being
valid.
Index: doc/tm.texi
===================================================================
--- doc/tm.texi (revision 140087)
+++ doc/tm.texi (working copy)
@@ -5258,17 +5258,20 @@ post-address side-effect generation invo
@defmac CONSTANT_ADDRESS_P (@var{x})
A C expression that is 1 if the RTX @var{x} is a constant which
-is a valid address. On most machines, this can be defined as
-@code{CONSTANT_P (@var{x})}, but a few machines are more restrictive
-in which constant addresses are supported.
+is a valid address. A port can use @code{CONSTANT_P (@var{x})} to
+simplify the expression, but must always validize the contents of
+a @code{CONST} expression.
@end defmac
@defmac CONSTANT_P (@var{x})
@code{CONSTANT_P}, which is defined by target-independent code,
-accepts integer-values expressions whose values are not explicitly
+accepts integer-valued expressions whose values are not explicitly
known, such as @code{symbol_ref}, @code{label_ref}, and @code{high}
expressions and @code{const} arithmetic expressions, in addition to
-@code{const_int} and @code{const_double} expressions.
+@code{const_int} and @code{const_double} expressions. This macro
+must always be used in conjunction with a test that a @code{CONST}
+expression is valid, as a CONST can wrap just any constant expression
+that is algorithmically valid.
@end defmac
@defmac MAX_REGS_PER_ADDRESS
@@ -5312,9 +5315,8 @@ levels of macros may be the same whether
Normally, constant addresses which are the sum of a @code{symbol_ref}
and an integer are stored inside a @code{const} RTX to mark them as
-constant. Therefore, there is no need to recognize such sums
-specifically as legitimate addresses. Normally you would simply
-recognize any @code{const} as legitimate.
+constant, but this is not always the case. Therefore, you need to
+validize such expressions as legitimate addresses.
Usually @code{PRINT_OPERAND_ADDRESS} is not prepared to handle constant
sums that are not marked with @code{const}. It assumes that a naked
@@ -5448,9 +5450,8 @@ You may assume that @var{addr} is a vali
@defmac LEGITIMATE_CONSTANT_P (@var{x})
A C expression that is nonzero if @var{x} is a legitimate constant for
an immediate operand on the target machine. You can assume that
-@var{x} satisfies @code{CONSTANT_P}, so you need not check this. In fact,
-@samp{1} is a suitable definition for this macro on machines where
-anything @code{CONSTANT_P} is valid.
+@var{x} satisfies @code{CONSTANT_P}, so you need not check this, but
+you need to validize @code{CONST} expressions.
@end defmac
@deftypefn {Target Hook} rtx TARGET_DELEGITIMIZE_ADDRESS (rtx @var{x})
@@ -6797,9 +6798,7 @@ A C expression that is nonzero if @var{x
operand on the target machine when generating position independent code.
You can assume that @var{x} satisfies @code{CONSTANT_P}, so you need not
check this. You can also assume @var{flag_pic} is true, so you need not
-check it either. You need not define this macro if all constants
-(including @code{SYMBOL_REF}) can be immediate operands when generating
-position independent code.
+check it either.
@end defmac
@node Assembler Format
brgds, H-P