Skip to content

Commit 6d40f05

Browse files
Julien Grallwilldeacon
authored andcommitted
arm64/fpsimdmacros: Allow the macro "for" to be used in more cases
The current version of the macro "for" is not able to work when the counter is used to generate registers using mnemonics. This is because gas is not able to evaluate the expression generated if used in register's name (i.e x\n). Gas offers a way to evaluate macro arguments by using % in front of them under the alternate macro mode. The implementation of "for" is updated to use the alternate macro mode and %, so we can use the macro in more cases. As the alternate macro mode may have side-effects, this is disabled when expanding the body. While it is enough to prefix the argument of the macro "__for_body" with %, the arguments of "__for" are also prefixed to get a more bearable value in case of compilation error. Suggested-by: Dave Martin <dave.martin@arm.com> Signed-off-by: Julien Grall <julien.grall@arm.com> Signed-off-by: Mark Brown <broonie@kernel.org> Reviewed-by: Dave Martin <Dave.Martin@arm.com> Link: https://lore.kernel.org/r/20200828181155.17745-4-broonie@kernel.org Signed-off-by: Will Deacon <will@kernel.org>
1 parent 315cf04 commit 6d40f05

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

arch/arm64/include/asm/fpsimdmacros.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,23 @@
166166

167167
.macro __for from:req, to:req
168168
.if (\from) == (\to)
169-
_for__body \from
169+
_for__body %\from
170170
.else
171-
__for \from, (\from) + ((\to) - (\from)) / 2
172-
__for (\from) + ((\to) - (\from)) / 2 + 1, \to
171+
__for %\from, %((\from) + ((\to) - (\from)) / 2)
172+
__for %((\from) + ((\to) - (\from)) / 2 + 1), %\to
173173
.endif
174174
.endm
175175

176176
.macro _for var:req, from:req, to:req, insn:vararg
177177
.macro _for__body \var:req
178+
.noaltmacro
178179
\insn
180+
.altmacro
179181
.endm
180182

183+
.altmacro
181184
__for \from, \to
185+
.noaltmacro
182186

183187
.purgem _for__body
184188
.endm

0 commit comments

Comments
 (0)