On 29/05/25 9:05 pm, Segher Boessenkool wrote:
>> +#define _AMO_LD_INCREMENT(NAME, TYPE, OPCODE, FC)                   \
>> +static __inline__ TYPE                                                      
>> \
>> +NAME (TYPE *_PTR)                                                   \
>> +{                                                                   \
>> +  TYPE _RET;                                                                
>> \
>> +  __asm__ volatile (OPCODE " %[ret],%P[addr],%[code]\n"                     
>> \
>> +                : [addr] "+Q" (_PTR[0]), [ret] "=r" (_RET)          \
>> +                : "Q" (*(TYPE (*)[2]) _PTR), [code] "n" (FC));      \
>> +  return _RET;                                                              
>> \
>> +}
> 
> I don't understand the [2].  Should it be [1]?  These instructions
> can use the value at mem+s (as the ISA names things) as input, but not
> mem+2*s.

The entire expression (*(TYPE (*)[2]) _PTR)) means an array of 2 elements.
Since the _AMO_LD_INCREMENT operation reads two memory locations, hence the [2].
Since the first memory location is already specified in the list of output 
operands
as "+Q" (_PTR[0]), so the following should be specified in the list of input 
operands:

"Q" ((*(TYPE (*)[2]) _PTR)[1])

Regards,
Surya

Reply via email to