Skip to content

Commit 847fadd

Browse files
committed
Simplify interface
1 parent 5ee3665 commit 847fadd

File tree

1 file changed

+25
-39
lines changed

1 file changed

+25
-39
lines changed

llvm/utils/TableGen/GlobalISelEmitter.cpp

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,10 @@ class GlobalISelEmitter final : public GlobalISelMatchTableExecutorEmitter {
426426
const TreePatternNode &N,
427427
action_iterator &InsertPt) const;
428428

429-
Expected<action_iterator>
430-
importExplicitUseRenderer(action_iterator InsertPt, RuleMatcher &Rule,
431-
BuildMIAction &DstMIBuilder,
432-
const TreePatternNode &Dst) const;
429+
Error importNodeRenderer(RuleMatcher &M, BuildMIAction &MIBuilder,
430+
const TreePatternNode &N,
431+
action_iterator &InsertPt) const;
432+
433433
Error importDefaultOperandRenderers(action_iterator InsertPt, RuleMatcher &M,
434434
BuildMIAction &DstMIBuilder,
435435
const DAGDefaultOperand &DefaultOp) const;
@@ -1385,36 +1385,25 @@ Error GlobalISelEmitter::importInstructionNodeRenderer(
13851385
return Error::success();
13861386
}
13871387

1388-
Expected<action_iterator> GlobalISelEmitter::importExplicitUseRenderer(
1389-
action_iterator InsertPt, RuleMatcher &Rule, BuildMIAction &DstMIBuilder,
1390-
const TreePatternNode &Dst) const {
1391-
if (Dst.hasName()) {
1392-
if (Error Err = importNamedNodeRenderer(Rule, DstMIBuilder, Dst))
1393-
return Err;
1394-
return InsertPt;
1395-
}
1388+
// Equivalent of MatcherGen::EmitResultOperand.
1389+
Error GlobalISelEmitter::importNodeRenderer(RuleMatcher &M,
1390+
BuildMIAction &MIBuilder,
1391+
const TreePatternNode &N,
1392+
action_iterator &InsertPt) const {
1393+
if (N.hasName())
1394+
return importNamedNodeRenderer(M, MIBuilder, N);
13961395

1397-
if (Dst.isLeaf()) {
1398-
if (Error Err = importLeafNodeRenderer(Rule, DstMIBuilder, Dst))
1399-
return Err;
1400-
return InsertPt;
1401-
}
1396+
if (N.isLeaf())
1397+
return importLeafNodeRenderer(M, MIBuilder, N);
14021398

1403-
if (Dst.getOperator()->isSubClassOf("SDNodeXForm")) {
1404-
if (Error Err = importXFormNodeRenderer(Rule, DstMIBuilder, Dst))
1405-
return Err;
1406-
return InsertPt;
1407-
}
1399+
if (N.getOperator()->isSubClassOf("SDNodeXForm"))
1400+
return importXFormNodeRenderer(M, MIBuilder, N);
14081401

1409-
if (Dst.getOperator()->isSubClassOf("Instruction")) {
1410-
if (Error Err =
1411-
importInstructionNodeRenderer(Rule, DstMIBuilder, Dst, InsertPt))
1412-
return Err;
1413-
return InsertPt;
1414-
}
1402+
if (N.getOperator()->isSubClassOf("Instruction"))
1403+
return importInstructionNodeRenderer(M, MIBuilder, N, InsertPt);
14151404

14161405
// Should not reach here.
1417-
return failedImport("unrecognized node " + llvm::to_string(Dst));
1406+
return failedImport("unrecognized node " + llvm::to_string(N));
14181407
}
14191408

14201409
/// Generates code that builds the resulting instruction(s) from the destination
@@ -1668,11 +1657,9 @@ Expected<action_iterator> GlobalISelEmitter::importExplicitUseRenderers(
16681657
dyn_cast<DefInit>(SubRegChild.getLeafValue())) {
16691658
CodeGenSubRegIndex *SubIdx = CGRegs.getSubRegIdx(SubRegInit->getDef());
16701659

1671-
auto InsertPtOrError =
1672-
importExplicitUseRenderer(InsertPt, M, DstMIBuilder, ValChild);
1673-
if (auto Error = InsertPtOrError.takeError())
1674-
return std::move(Error);
1675-
InsertPt = InsertPtOrError.get();
1660+
if (Error Err = importNodeRenderer(M, DstMIBuilder, ValChild, InsertPt))
1661+
return Err;
1662+
16761663
DstMIBuilder.addRenderer<SubRegIndexRenderer>(SubIdx);
16771664
}
16781665
}
@@ -1737,11 +1724,10 @@ Expected<action_iterator> GlobalISelEmitter::importExplicitUseRenderers(
17371724
continue;
17381725
}
17391726

1740-
auto InsertPtOrError = importExplicitUseRenderer(InsertPt, M, DstMIBuilder,
1741-
Dst.getChild(Child));
1742-
if (auto Error = InsertPtOrError.takeError())
1743-
return std::move(Error);
1744-
InsertPt = InsertPtOrError.get();
1727+
if (Error Err =
1728+
importNodeRenderer(M, DstMIBuilder, Dst.getChild(Child), InsertPt))
1729+
return Err;
1730+
17451731
++Child;
17461732
}
17471733

0 commit comments

Comments
 (0)