]> git.ipfire.org Git - thirdparty/gcc.git/commit
genemit: Consistently use operand arrays in gen_* functions
authorRichard Sandiford <richard.sandiford@arm.com>
Wed, 21 May 2025 09:01:29 +0000 (10:01 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Wed, 21 May 2025 09:01:29 +0000 (10:01 +0100)
commit02c3910f75ddae52dd59775bf9a6c4452bbdd0ac
tree8fc17f8bedd454ec4a83f8d72e3b2858c0bc7ba6
parent5355568c75a99fc621e2008fa98626ad811678c5
genemit: Consistently use operand arrays in gen_* functions

One slightly awkward part about emitting the generator function
bodies is that:

* define_insn and define_expand routines have a separate argument for
  each operand, named "operand0" upwards.

* define_split and define_peephole2 routines take a pointer to an array,
  named "operands".

* the C++ preparation code for expands, splits and peephole2s uses an
  array called "operands" to refer to the operands.

* the automatically-generated code uses individual "operand<N>"
  variables to refer to the operands.

So define_expands have to store the incoming arguments into an operands
array before the md file's C++ code, then copy the operands array back
to the individual variables before the automatically-generated code.
splits and peephole2s have to copy the incoming operands array to
individual variables after the md file's C++ code, creating more
local variables that are live across calls to rtx_alloc.

This patch tries to simplify things by making the whole function
body use the operands array in preference to individual variables.
define_insns and define_expands store their arguments to the array
on entry.

This would have pros and cons on its own, but having a single array
helps with future efforts to reduce the duplication between gen_*
functions.

gcc/
* genemit.cc (gen_rtx_scratch, gen_exp): Use operands[%d] rather than
operand%d.
(start_gen_insn): Mark the incoming arguments as const and store
them to an operands array.
(gen_expand, gen_split): Remove copies into and out of the operands
array.
gcc/genemit.cc