[PATCH] riscv: asm: use .insn for making custom instructioons
Maciej W. Rozycki
macro at orcam.me.uk
Fri Oct 17 21:50:30 PDT 2025
On Fri, 17 Oct 2025, Ben Dooks wrote:
> diff --git a/arch/riscv/include/asm/asm.h b/arch/riscv/include/asm/asm.h
> index 8bd2a11382a3..c92f0ff51ffa 100644
> --- a/arch/riscv/include/asm/asm.h
> +++ b/arch/riscv/include/asm/asm.h
> @@ -12,6 +12,12 @@
> #define __ASM_STR(x) #x
> #endif
>
> +#ifndef CONFIG_AS_HAS_INSN
> +#define ASM_INSN(__x) ".4byte " __x
> +#else
> +#define ASM_INSN(__x) ".insn " __x
> +#endif
FWIW writing code such that double negation applies to the else clause
makes conditionals harder to parse by humans (it's !!CONFIG_AS_HAS_INSN
effectively here). Would you mind rewriting it as:
#ifdef CONFIG_AS_HAS_INSN
#define ASM_INSN(__x) ".insn " __x
#else
#define ASM_INSN(__x) ".4byte " __x
#endif
or has there been a particular reason you chose the proposed form?
Maciej
More information about the linux-riscv
mailing list