]> gcc.gnu.org Git - gcc.git/commit
md: Allow <FOO> to refer to the value of int iterator FOO
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 23 May 2023 10:34:41 +0000 (11:34 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 23 May 2023 10:34:41 +0000 (11:34 +0100)
commitb0ad9159a5ab35ba2cb41c273156216c2f305c0b
treedc8e25caa793bb0e382491e10615ea9f25ef599f
parent51fd69ec2d57721ed502344ebe68b1643d9e7f34
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.
gcc/doc/md.texi
gcc/read-rtl.cc
This page took 0.058031 seconds and 6 git commands to generate.