[PATCH] D83710: TableGen/GlobalISel: Allow output instructions with multiple defs

Jessica Paquette via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 15 12:46:47 PDT 2020


paquette added inline comments.


================
Comment at: llvm/utils/TableGen/GlobalISelEmitter.cpp:2655-2661
+    if (IsDef) {
+      if (IsDead)
+        Table << MatchTable::NamedValue("RegState::Define|RegState::Dead");
+      else
+        Table << MatchTable::NamedValue("RegState::Define");
+    } else
       Table << MatchTable::IntValue(0);
----------------
Are we going to need more variations on RegState in the future?

If so, maybe it'd be better to do something like the pseudocode below?

```
RegState = nothing
if (IsDef) {
   RegState = "RegState::Define";
   if (IsDead)
      RegState += "|RegState::Dead";
}

if (RegState != nothing)
  Table << MatchTable::NamedValue(RegState);
else
   Table << MatchTable::IntValue(0);
```


================
Comment at: llvm/utils/TableGen/GlobalISelEmitter.cpp:4393
     const CGIOperandList::OperandInfo &DstIOperand = DstI->Operands[I];
+    if (I > 0) {
+      // Patterns only handle a single result, so results after the first is an
----------------
Could you get rid of the `if` in the loop by doing something like this?

```
unsigned NumDefs = DstI->Operands.NumDefs;
if (!NumDefs)
  return InsertPt;

const CodeGenInstruction *DstI = DstMIBuilder.getCGI();
DstMIBuilder.addRenderer<CopyRenderer>(DstI->Operands[0].Name);

for (unsigned I = 1; I < NumDefs; ++I) {
  const TypeSetByHwMode &ExtTy = Dst->getExtType(I);
  ...
}

return InsertPt;
```


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

https://reviews.llvm.org/D83710





More information about the llvm-commits mailing list