<div dir="ltr"><div class="gmail_signature"><p class="MsoNormal">Hi all,</p>
<p class="MsoNormal"><br></p><p class="MsoNormal">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.</p>
<p class="MsoNormal"><br></p><p class="MsoNormal">For example if we have register definition:</p>
<p class="MsoNormal" style="text-indent:36pt"><span style="font-size:9pt;line-height:115%;font-family:Consolas;color:black;background-image:initial;background-repeat:initial">def MYReg0 : Register<"r0", 0>;</span></p>
<p class="MsoNormal">We want to create inline assembly and add this register to
clobbers list. Inline assembly should look something like this:</p>
<p class="MsoNormal"> <span style="font-size:9pt;line-height:115%;font-family:Consolas">i32 asm "nop", "~{r0}" ()</span></p>
<p class="MsoNormal"><br></p><p class="MsoNormal">We used AsmName
for register MYReg0 inside clobbers list. But this constraint fails to work
because <span style="font-size:10pt;line-height:115%;font-family:'Segoe UI',sans-serif;color:black;background-image:initial;background-repeat:initial">TargetLowering::getRegForInlineAsmConstraint()</span>
tries to match register definition name (“MYReg0”) not its AsmName (“r0”). So
to make this work we should write this assembly:</p>
<p class="MsoNormal"> <span style="font-size:9pt;line-height:115%;font-family:Consolas">i32 asm "nop", "~{MYReg0}" ()</span></p>
<p class="MsoNormal"><br></p><p class="MsoNormal">I believe that
this behavior is not correct. It works because in most back-ends register
definition names and AsmNames are equal (<span style="font-size:10pt;line-height:115%;font-family:'Segoe UI',sans-serif;color:black;background-image:initial;background-repeat:initial">e.g. def EAX : X86Reg<"eax", ...></span>) but in AMDGPU we want to have different
def-names and AsmNames.</p>
<p class="MsoNormal"><br></p><p class="MsoNormal">This might be done
by changing core LLVM code or in target-specific <span style="font-size:10pt;line-height:115%;font-family:'Segoe UI',sans-serif;color:black;background-image:initial;background-repeat:initial">getRegForInlineAsmConstraint() method. What do you suppose to
be better solution?</span></p><p class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:'Segoe UI',sans-serif;color:black;background-image:initial;background-repeat:initial"><br></span></p>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:'Segoe UI',sans-serif;color:black;background-image:initial;background-repeat:initial">Thanks,</span></p>
<p class="MsoNormal"><span style="font-size:10pt;line-height:115%;font-family:'Segoe UI',sans-serif;color:black;background-image:initial;background-repeat:initial">Sam</span></p></div>
</div>