[PATCH] riscv: asm: use .insn for making custom instructioons

Ben Dooks ben.dooks at codethink.co.uk
Thu Oct 23 10:12:40 PDT 2025


On 18/10/2025 05:50, Maciej W. Rozycki wrote:
> 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?

Thanks, no idea why it was this way, fixed for v2.

-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html



More information about the linux-riscv mailing list