[llvm] [AMDGPU] Add lit() asm operand modifier for SP3 compatibility. (PR #68839)

Stanislav Mekhanoshin via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 12 00:19:06 PDT 2023


rampitec wrote:

> > Does your implementation accept `lit(abs(123.0))`? Does SP3 accept that?
> 
> This does not support it:
> 
> ```
> llvm-mc -arch=amdgcn -mcpu=tonga -show-encoding  <<< 'v_sqrt_f32 v2, lit(abs(123.0))'
> 	.text
> <stdin>:1:20: error: failed parsing operand.
> v_sqrt_f32 v2, lit(abs(123.0))
>                    ^
> ```
> 
> SP3 does, although there is no abs modifier used anyway. It might be possible to support, but I see no usecases. On practice people just use lit(). Actually since SP3 does not do it I see no way to check if HW even supports modifier bits with literals. So far lit() is just a sort of syntax glue.

BTW, it does support the opposite:
```
llvm-mc -arch=amdgcn -mcpu=tonga -show-encoding  <<< 'v_sqrt_f32 v2, abs(lit(-123.0))'
	.text
	v_sqrt_f32_e32 v2, 0x42f60000           ; encoding: [0xff,0x4e,0x04,0x7e,0x00,0x00,0xf6,0x42]
```
It makes more sense to me: use literal and abs bit on that literal. The `abs(<num>)` thing is constant evaluated. Just in case if we support actual literal encoding one day. I do not really understand a meaning of lit(abs(<num>)) other than the ask to constant evaluate a number and then use as a literal.

https://github.com/llvm/llvm-project/pull/68839


More information about the llvm-commits mailing list