<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/116629>116629</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[X86] Missing support for ‘z’ asm operand modifier
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:X86,
inline-asm
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nathanchance
</td>
</tr>
</table>
<pre>
As initially reported on LKML: https://lore.kernel.org/202411180620.8uhr11le-lkp@intel.com/
```c
void foo(unsigned char *var)
{
asm("shr%z1 %1" : "+m"(*var));
}
```
```
$ gcc -c -o /dev/null test.c
$ clang -c -o /dev/null test.c
test.c:3:6: error: invalid operand in inline asm: 'shr${1:z} $1'
3 | asm("shr%z1 %1" : "+m"(*var));
| ^
test.c:3:6: error: ambiguous instructions require an explicit suffix (could be 'shrb', 'shrw', 'shrl', or 'shrq')
<inline asm>:1:2: note: instantiated into assembly here
1 | shr (%rax)
| ^
2 errors generated.
```
https://godbolt.org/z/o6bWzfh9x
>From [the GCC documentation](https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#x86-Operand-Modifiers):
`z` | Print the opcode suffix for the size of the current integer operand (one of `b/w/l/q`). | `%z0` | `l`
-- | -- | -- | --
I see where the X86 specific modifiers are implemented in `X86AsmPrinter::PrintAsmOperand()` but I am not entirely sure how to implement this there. I am happy to try with any guidance.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVU-T4rgP_TTioiKVKCEkBw5puvnV1G-mdm87VycRxDuOnbGdbuDTb9mE_rdbO4ftarBkbOnp-ckWzsmTZt7B5gE2jysx-8HYnRZ-ELoLH161pr_sGodSSy-FUhe0PBnruUej8ev_v32FvMHB-8lB3gAdgA7KWE5-sNWsEmNPQAdKqciyrEpLSpNqHmyWKV6rHxMUqdSeVdKZMWxOHyFtlu8yvf13N__ZyB6PxgBVs47Ae-wGYRGoeRYWqF72bR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