[llvm-dev] Inline asm clobber registers name

Семен Колтон via llvm-dev llvm-dev at lists.llvm.org
Thu Apr 7 08:06:21 PDT 2016


Hi all,


I am currently working on AMDGPU inline assembly and encountered problem
with naming clobber registers in asm constraints. It looks like by default
LLVM tries to match register specified in constraint to register name of
register definition in .td file but not to the AsmName for this register.


For example if we have register definition:

def MYReg0 : Register<"r0", 0>;

We want to create inline assembly and add this register to clobbers list.
Inline assembly should look something like this:

                i32 asm "nop", "~{r0}" ()


We used AsmName for register MYReg0 inside clobbers list. But this
constraint fails to work because
TargetLowering::getRegForInlineAsmConstraint() tries to match register
definition name (“MYReg0”) not its AsmName (“r0”). So to make this work we
should write this assembly:

                i32 asm "nop", "~{MYReg0}" ()


I believe that this behavior is not correct. It works because in most
back-ends register definition names and AsmNames are equal (e.g. def EAX :
X86Reg<"eax", ...>) but in AMDGPU we want to have different def-names and
AsmNames.


This might be done by changing core LLVM code or in target-specific
getRegForInlineAsmConstraint()
method. What do you suppose to be better solution?


Thanks,

Sam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160407/6e1e7239/attachment.html>


More information about the llvm-dev mailing list