This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PR 37363 follow-on 2: define a grammar for CONSTs
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 10 Nov 2008 23:30:10 +0000
- Subject: PR 37363 follow-on 2: define a grammar for CONSTs
As discussed previously, this patch defines a grammar for RTL
CONST expressions. After the previous two patches, I think the
only exception to this grammar is the in the m68hc11 port, whose
trampoline set-up routines use (const (symbol_ref ...)) -- rather
than plain symbol_ref -- to refer to the static chain register.
(The static chain register is the "soft" -- i.e. in-memory --
register Z.)
The port uses (const (symbol_ref ...)) rather than symbol_ref
to avoid extra syntax in print_operand. However, the idea of
using symbol_refs to refer to registers behind gcc's back just
seems Plain Wrong. I believe it's there because md_reorg tries
to replace references to Z with references to a hard register,
and this code does not appear to handle cases where Z is live
on entry to the function.
I don't really have time to fix that, and m68hc11 is currently
on the deprecation list anyway, so...
Tested by inspecting the pdf, html and info output. OK to install?
Richard
gcc/
* doc/rtl.texi: Define a grammar for consts.
Index: gcc/doc/rtl.texi
===================================================================
--- gcc/doc/rtl.texi 2008-11-10 23:00:17.000000000 +0000
+++ gcc/doc/rtl.texi 2008-11-10 23:12:13.000000000 +0000
@@ -1582,13 +1582,22 @@ Usually that is the only mode for which
@findex const
@item (const:@var{m} @var{exp})
Represents a constant that is the result of an assembly-time
-arithmetic computation. The operand, @var{exp}, is an expression that
-contains only constants (@code{const_int}, @code{symbol_ref} and
-@code{label_ref} expressions) combined with @code{plus} and
-@code{minus}. However, not all combinations are valid, since the
-assembler cannot do arbitrary arithmetic on relocatable symbols.
+arithmetic computation. The valid values of @var{exp} are:
-@var{m} should be @code{Pmode}.
+@itemize
+@item @samp{(unspec:@var{m} @var{v} @var{c})}
+@item @samp{(plus:@var{m} (unspec:@var{m} @var{v} @var{c}) (const_int @var{offset}))}
+@item @samp{(plus:@var{m} (symbol_ref:@var{m} @var{base}) (const_int @var{offset}))}
+@item @samp{(plus:@var{m} (label_ref:@var{m} @var{base}) (const_int @var{offset}))}
+@end itemize
+
+There is no defined way for target-independent code to tell whether a
+particular @code{unspec} expression can be wrapped in a @code{const}.
+Target-independent code should therefore only create the first two
+forms if it knows that the same @samp{(unspec:@var{m} @var{v} @var{c})}
+occurs somewhere within another @code{const}'s @var{exp}.
+
+@var{m} is usually @code{Pmode}.
@findex high
@item (high:@var{m} @var{exp})