[llvm] [GlobalISel][TableGen] Take first result for multi-output instructions (PR #81130)

Björn Pettersson via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 8 06:28:04 PST 2024


================
@@ -288,11 +288,21 @@ static std::string getMangledRootDefName(StringRef DefOperandName) {
 
 //===- GlobalISelEmitter class --------------------------------------------===//
 
-static Expected<LLTCodeGen> getInstResultType(const TreePatternNode *Dst) {
+static Expected<LLTCodeGen> getInstResultType(const TreePatternNode *Dst,
+                                              const CodeGenTarget &Target) {
+  // While allowing more than one output (both implicit and explicit defs)
+  // below, we only expect one explicit def here.
+  assert(Dst->getOperator()->isSubClassOf("Instruction"));
+  CodeGenInstruction &InstInfo = Target.getInstruction(Dst->getOperator());
+  if (InstInfo.Operands.NumDefs != 1)
----------------
bjope wrote:

If I remember correctly this check was added to make the patch less general than the first proposal in Phabricator by Gabriel. So I wanted to narrow it down to the specific scenario that we needed downstream (i.e. allowing additional implicit defs beside the one-and-only explicit def.

With this PR we still report failure when the number of explicit defs aren't equal to one , just like in the baseline version. But it allows importing pattern in situation when we find additional implicit defs.

https://github.com/llvm/llvm-project/pull/81130


More information about the llvm-commits mailing list