Skip to content

Commit b06dc04

Browse files
committed
Simplify interface
1 parent cb3cc0a commit b06dc04

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;
@@ -1388,36 +1388,25 @@ Error GlobalISelEmitter::importInstructionNodeRenderer(
13881388
return Error::success();
13891389
}
13901390

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

1400-
if (Dst.isLeaf()) {
1401-
if (Error Err = importLeafNodeRenderer(Rule, DstMIBuilder, Dst))
1402-
return Err;
1403-
return InsertPt;
1404-
}
1399+
if (N.isLeaf())
1400+
return importLeafNodeRenderer(M, MIBuilder, N);
14051401

1406-
if (Dst.getOperator()->isSubClassOf("SDNodeXForm")) {
1407-
if (Error Err = importXFormNodeRenderer(Rule, DstMIBuilder, Dst))
1408-
return Err;
1409-
return InsertPt;
1410-
}
1402+
if (N.getOperator()->isSubClassOf("SDNodeXForm"))
1403+
return importXFormNodeRenderer(M, MIBuilder, N);
14111404

1412-
if (Dst.getOperator()->isSubClassOf("Instruction")) {
1413-
if (Error Err =
1414-
importInstructionNodeRenderer(Rule, DstMIBuilder, Dst, InsertPt))
1415-
return Err;
1416-
return InsertPt;
1417-
}
1405+
if (N.getOperator()->isSubClassOf("Instruction"))
1406+
return importInstructionNodeRenderer(M, MIBuilder, N, InsertPt);
14181407

14191408
// Should not reach here.
1420-
return failedImport("unrecognized node " + llvm::to_string(Dst));
1409+
return failedImport("unrecognized node " + llvm::to_string(N));
14211410
}
14221411

14231412
/// Generates code that builds the resulting instruction(s) from the destination
@@ -1671,11 +1660,9 @@ Expected<action_iterator> GlobalISelEmitter::importExplicitUseRenderers(
16711660
dyn_cast<DefInit>(SubRegChild.getLeafValue())) {
16721661
CodeGenSubRegIndex *SubIdx = CGRegs.getSubRegIdx(SubRegInit->getDef());
16731662

1674-
auto InsertPtOrError =
1675-
importExplicitUseRenderer(InsertPt, M, DstMIBuilder, ValChild);
1676-
if (auto Error = InsertPtOrError.takeError())
1677-
return std::move(Error);
1678-
InsertPt = InsertPtOrError.get();
1663+
if (Error Err = importNodeRenderer(M, DstMIBuilder, ValChild, InsertPt))
1664+
return Err;
1665+
16791666
DstMIBuilder.addRenderer<SubRegIndexRenderer>(SubIdx);
16801667
}
16811668
}
@@ -1740,11 +1727,10 @@ Expected<action_iterator> GlobalISelEmitter::importExplicitUseRenderers(
17401727
continue;
17411728
}
17421729

1743-
auto InsertPtOrError = importExplicitUseRenderer(InsertPt, M, DstMIBuilder,
1744-
Dst.getChild(Child));
1745-
if (auto Error = InsertPtOrError.takeError())
1746-
return std::move(Error);
1747-
InsertPt = InsertPtOrError.get();
1730+
if (Error Err =
1731+
importNodeRenderer(M, DstMIBuilder, Dst.getChild(Child), InsertPt))
1732+
return Err;
1733+
17481734
++Child;
17491735
}
17501736

0 commit comments

Comments
 (0)