diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2023-05-23 11:34:41 +0100 |
---|---|---|
committer | Richard Sandiford <richard.sandiford@arm.com> | 2023-05-23 11:34:41 +0100 |
commit | b0ad9159a5ab35ba2cb41c273156216c2f305c0b (patch) | |
tree | dc8e25caa793bb0e382491e10615ea9f25ef599f /gcc/doc/md.texi | |
parent | 51fd69ec2d57721ed502344ebe68b1643d9e7f34 (diff) | |
download | gcc-b0ad9159a5ab35ba2cb41c273156216c2f305c0b.zip gcc-b0ad9159a5ab35ba2cb41c273156216c2f305c0b.tar.gz gcc-b0ad9159a5ab35ba2cb41c273156216c2f305c0b.tar.bz2 |
md: Allow <FOO> to refer to the value of int iterator FOO
In a follow-up patch, I wanted to use an int iterator to iterate
over various possible values of a const_int. But one problem
with int iterators was that there was no way of referring to the
current value of the iterator. This is unlike modes and codes,
which provide automatic "mode", "MODE", "code" and "CODE"
attribbutes. These automatic definitions are the equivalent
of an explicit:
(define_mode_attr mode [(QI "qi") (HI "hi") ...])
We obviously can't do that for every possible value of an int.
One option would have been to go for some kind of lazily-populated
attribute. But that sounds quite complicated. This patch instead
goes for the simpler approach of allowing <FOO> to refer to the
current value of FOO.
In principle it would be possible to allow the same thing
for mode and code iterators. But for modes there are at least
4 realistic possiblities:
- the E_* enumeration value (which is what this patch would give)
- the user-facing C token, like DImode, SFmode, etc.
- the equivalent of <MODE>
- the equivalent of <mode>
Because of this ambiguity, it seemed better to stick to the
current approach for modes. For codes it's less clear-cut,
but <CODE> and <code> are both realistic possibilities, so again
it seemed better to be explicit.
The patch also removes “Each @var{int} must have the same rtx format.
@xref{RTL Classes}.”, which was erroneously copied from the code
iterator section.
gcc/
* doc/md.texi: Document that <FOO> can be used to refer to the
numerical value of an int iterator FOO. Tweak other parts of
the int iterator documentation.
* read-rtl.cc (iterator_group::has_self_attr): New field.
(map_attr_string): When has_self_attr is true, make <FOO>
expand to the current value of iterator FOO.
(initialize_iterators): Set has_self_attr for int iterators.
Diffstat (limited to 'gcc/doc/md.texi')
-rw-r--r-- | gcc/doc/md.texi | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi index 8ebce31..6a435eb 100644 --- a/gcc/doc/md.texi +++ b/gcc/doc/md.texi @@ -11502,11 +11502,10 @@ The construct: @end smallexample defines a pseudo integer constant @var{name} that can be instantiated as -@var{inti} if condition @var{condi} is true. Each @var{int} must have the -same rtx format. @xref{RTL Classes}. Int iterators can appear in only -those rtx fields that have 'i', 'n', 'w', or 'p' as the specifier. This -means that each @var{int} has to be a constant defined using define_constant -or define_c_enum. +@var{inti} if condition @var{condi} is true. Int iterators can appear in +only those rtx fields that have `i', `n', `w', or `p' as the specifier. +This means that each @var{int} has to be a constant defined using +@samp{define_constant} or @samp{define_c_enum}. As with mode and code iterators, each pattern that uses @var{name} will be expanded @var{n} times, once with all uses of @var{name} replaced by @@ -11517,9 +11516,13 @@ It is possible to define attributes for ints as well as for codes and modes. Attributes are defined using: @smallexample -(define_int_attr @var{name} [(@var{int1} "@var{value1}") @dots{} (@var{intn} "@var{valuen}")]) +(define_int_attr @var{attr_name} [(@var{int1} "@var{value1}") @dots{} (@var{intn} "@var{valuen}")]) @end smallexample +In additon to these user-defined attributes, it is possible to use +@samp{<@var{name}>} to refer to the current expansion of iterator +@var{name} (such as @var{int1}, @var{int2}, and so on). + Here's an example of int iterators in action, taken from the ARM port: @smallexample |