Message ID | 20200311180416.6509-2-richard.henderson@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | arm64: gcc asm flag outputs | expand |
Hi Richard, On Wed, Mar 11, 2020 at 11:04:11AM -0700, Richard Henderson wrote: > With gcc 10, arm64 includes support for flag outputs, much like > x86 has done for years. Mirror the macros that x86 places in > asm/asm.h, with the necessary addition of CC_CLOBBER. This sounds like a neat feature on the compiler side, and I can see that this is potentially beneficial for hot paths. I am concerned as Robin suggests for specific patches, that that macros are going to be very easy to misuse, and make the assembly somewhat opaque. So if there's a substantial benefit, it may be worth dealing with that, but otherwise I'd prefer to keep things more legible so that code is easier to maintain. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > arch/arm64/include/asm/ccset.h | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > create mode 100644 arch/arm64/include/asm/ccset.h > > diff --git a/arch/arm64/include/asm/ccset.h b/arch/arm64/include/asm/ccset.h > new file mode 100644 > index 000000000000..e733d383f515 > --- /dev/null > +++ b/arch/arm64/include/asm/ccset.h > @@ -0,0 +1,19 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef __ASM_CCSET_H > +#define __ASM_CCSET_H > + > +/* > + * Macros to generate condition code outputs from inline assembly. > + * The output operand must be integral but type "bool" preferred. > + */ Is there any documentation on this? What value does the output operand nominally have when the flags are clear / set? Thanks, Mark. > +#ifdef __GCC_ASM_FLAG_OUTPUTS__ > +# define CC_SET(c) "\n\t/* output condition code " #c "*/\n" > +# define CC_OUT(c) "=@cc" #c > +# define CC_CLOBBER > +#else > +# define CC_SET(c) "\n\tcset %[_cc_" #c "], " #c "\n" > +# define CC_OUT(c) [_cc_ ## c] "=r" > +# define CC_CLOBBER "cc" > +#endif > + > +#endif /* __ASM_CCSET_H */ > -- > 2.20.1 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On 3/13/20 3:54 AM, Mark Rutland wrote: > Is there any documentation on this? What value does the output operand > nominally have when the flags are clear / set? Yes. https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Flag-Output-Operands The value is explicitly boolean, so {0,1}, just like type bool. r~
diff --git a/arch/arm64/include/asm/ccset.h b/arch/arm64/include/asm/ccset.h new file mode 100644 index 000000000000..e733d383f515 --- /dev/null +++ b/arch/arm64/include/asm/ccset.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_CCSET_H +#define __ASM_CCSET_H + +/* + * Macros to generate condition code outputs from inline assembly. + * The output operand must be integral but type "bool" preferred. + */ +#ifdef __GCC_ASM_FLAG_OUTPUTS__ +# define CC_SET(c) "\n\t/* output condition code " #c "*/\n" +# define CC_OUT(c) "=@cc" #c +# define CC_CLOBBER +#else +# define CC_SET(c) "\n\tcset %[_cc_" #c "], " #c "\n" +# define CC_OUT(c) [_cc_ ## c] "=r" +# define CC_CLOBBER "cc" +#endif + +#endif /* __ASM_CCSET_H */
With gcc 10, arm64 includes support for flag outputs, much like x86 has done for years. Mirror the macros that x86 places in asm/asm.h, with the necessary addition of CC_CLOBBER. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- arch/arm64/include/asm/ccset.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 arch/arm64/include/asm/ccset.h