[PATCH] D78318: [GlobalISel][InlineAsm] Add support for basic output operand constraints

Konstantin Schwarz via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 22 07:33:39 PDT 2020


kschwarz added inline comments.


================
Comment at: llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp:133
+
+  for (; NumRegs; --NumRegs, ++I) {
+    assert(I != RC->end() && "Ran out of registers to allocate!");
----------------
kschwarz wrote:
> arsenm wrote:
> > kschwarz wrote:
> > > arsenm wrote:
> > > > Picking multiple physical registers by scanning through the register class doesn't make any sense to me. I would expect NumRegs > 1 only with a virtual register
> > > The LLVM IR reference manual contains the following paragraph:
> > > > There is also an “interesting” feature which deserves a bit of explanation: if a register class constraint allocates a register which is too small for the value type operand provided as input, the input value will be split into multiple registers, and all of them passed to the inline asm.
> > > 
> > > X86 uses this at least with the 'A' register constraint, but there are other targets, too (e.g. ARM uses it to pass 64-bit values in even-odd register pairs).
> > With physical registers? Can you add a testcase for this?
> I can add a fictitious test for AArch64, but it doesn't have asm template argument modifiers to access the "higher" register.
> ARM has test cases for this (for SelectionDAG though) here: https://github.com/llvm/llvm-project/blob/master/llvm/test/CodeGen/ARM/inlineasm-operand-implicit-cast.ll#L291 
Turns out I can't add a test for this at the moment, because I'm bailing out if an output constraint needs more than one register (see line 408).
Do you want me to add support for it in this patch?


================
Comment at: llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp:128-131
+  if (AssignedReg) {
+    for (; *I != AssignedReg; ++I)
+      ;
+  }
----------------
paquette wrote:
> Maybe just use `std::find_if`?
> 
> Also what should happen if you don't find the assigned register here?
> 
Previously, there was an assertion if the end of the iterator was reached without finding the register, but I removed it in another iteration.
Since the physical register and the register class are both provided by the target, there isn't really anything else we can do than abort the compilation if they don't match. I'm adding back the assertion for this case then.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78318/new/

https://reviews.llvm.org/D78318





More information about the llvm-commits mailing list