[PATCH] D86617: [GlobalISel][TableGen] Take first result for multi-output instructions

Gabriel Hjort Ã…kerlund via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 05:52:46 PDT 2020


ehjogab created this revision.
ehjogab added reviewers: dsanders, arsenm, qcolombet, ab, bjope.
Herald added a subscriber: rovka.
Herald added a project: LLVM.
ehjogab requested review of this revision.
Herald added a subscriber: wdng.

Previously, tblgen would reject patterns where one of its nested
instructions produced more than one result. These arise when the
instruction definition contains 'outs' as well as 'Defs'. This patch
fixes that by always taking the first result, which is how these
situations are handled in SelectionIDAG.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86617

Files:
  llvm/utils/TableGen/GlobalISelEmitter.cpp


Index: llvm/utils/TableGen/GlobalISelEmitter.cpp
===================================================================
--- llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -3359,9 +3359,11 @@
 
 static Expected<LLTCodeGen> getInstResultType(const TreePatternNode *Dst) {
   ArrayRef<TypeSetByHwMode> ChildTypes = Dst->getExtTypes();
-  if (ChildTypes.size() != 1)
-    return failedImport("Dst pattern child has multiple results");
+  if (ChildTypes.size() < 1)
+    return failedImport("Dst pattern child has no result");
 
+  // If there are multiple results, just take the first one (this is how
+  // SelectionIDAG does it).
   Optional<LLTCodeGen> MaybeOpTy;
   if (ChildTypes.front().isMachineValueType()) {
     MaybeOpTy =
@@ -4753,8 +4755,9 @@
   // We don't have a leaf node, so we have to try and infer something. Check
   // that we have an instruction that we an infer something from.
 
-  // Only handle things that produce a single type.
-  if (N->getNumTypes() != 1)
+  // Only handle things that produce at least one value (if multiple values,
+  // just take the first one).
+  if (N->getNumTypes() < 1)
     return None;
   Record *OpRec = N->getOperator();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86617.287945.patch
Type: text/x-patch
Size: 1219 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200826/bda3328b/attachment.bin>


More information about the llvm-commits mailing list