]> git.ipfire.org Git - thirdparty/gcc.git/commit
sparc: Avoid operandN variables in .md files
authorRichard Sandiford <richard.sandiford@arm.com>
Wed, 21 May 2025 09:01:27 +0000 (10:01 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Wed, 21 May 2025 09:01:27 +0000 (10:01 +0100)
commit35dd609353388886eb574194f2fe2088133f34c8
tree929ba3246408c374797d50046906ac3f74e17b2e
parent856f6de5d19257e3c5802a250e7c749ca44beee3
sparc: Avoid operandN variables in .md files

The automatically-generated gen_* routines take their operands as
individual arguments, named "operand0" upwards.  These arguments are
stored into an "operands" array before invoking the expander's C++
code, which can then modify the operands by writing to the array.

However, the SPARC sign-extend and zero-extend expanders used the
operandN variables directly, rather than operands[N].  That's a
correct usage in context, since the code goes on to expand the
pattern manually and invoke DONE.

But it's also easy for code to accidentally write to operandN instead
of operands[N] when trying to set up something like a match_dup.
It sounds like Jeff had seen an instance of this.

A later patch is therefore going to mark the operandN arguments
as const.  This patch makes way for that by using operands[N]
instead of operandN for the SPARC expanders.

gcc/
* config/sparc/sparc.md (zero_extendhisi2, zero_extendhidi2)
(extendhisi2, extendqihi2, extendqisi2, extendqidi2)
(extendhidi2): Use operands[0] and operands[1] instead of
operand0 and operand1.
gcc/config/sparc/sparc.md