[PATCH] D41446: [TableGen][AsmMatcherEmitter] Generate assembler checks for tied operands

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 3 06:21:06 PST 2018


fhahn added inline comments.


================
Comment at: utils/TableGen/AsmMatcherEmitter.cpp:969
+  const auto &CGIOperands = getResultInst()->Operands;
+  for (const auto &CGIOp : CGIOperands) {
+    const auto &CGIConstraints = CGIOp.Constraints;
----------------
I think the loop body here can be simplified by using `CGIOp.getTiedRegister();` rather than checking the constraints here:


```
+    int TiedReg = CGIOp.getTiedRegister();
+    if (TiedReg == -1)
+      continue;
+
+    Optional<size_t> LHSIdx = getAsmOperandIdx(AsmOperands, CGIOp.Name);
+    Optional<size_t> RHSIdx = getAsmOperandIdx(AsmOperands, CGIOperands[TiedReg].Name);
+    // Skipping operands with constraint but no reference in the
+    // AsmString. No need to throw a warning, as it's normal to have
+    // a $dst operand in the outs dag that is constrained to a $src
+    // operand in the ins dag but that does not appear in the AsmString.
+    if (!LHSIdx || !RHSIdx)
+      continue;
+
+    // Add the constraint. Using min/max as we consider constraint
+    // pair {A,B} and {B,A} the same
+    size_t AddMnemonicIdx = HasMnemonicFirst;
+    AsmOperandTiedConstraints.emplace_back(
+        std::min(*LHSIdx, *RHSIdx) + AddMnemonicIdx,
+        std::max(*LHSIdx, *RHSIdx) + AddMnemonicIdx);
+  }
```


https://reviews.llvm.org/D41446





More information about the llvm-commits mailing list