Skip to content

Commit 95185b4

Browse files
committed
Simplify interface
1 parent 67a79ad commit 95185b4

File tree

1 file changed

+24
-39
lines changed

1 file changed

+24
-39
lines changed

llvm/utils/TableGen/GlobalISelEmitter.cpp

Lines changed: 24 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,9 @@ 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;
433432
Error importDefaultOperandRenderers(action_iterator InsertPt, RuleMatcher &M,
434433
BuildMIAction &DstMIBuilder,
435434
const DAGDefaultOperand &DefaultOp) const;
@@ -1364,36 +1363,25 @@ Error GlobalISelEmitter::importInstructionNodeRenderer(
13641363
return Error::success();
13651364
}
13661365

1367-
Expected<action_iterator> GlobalISelEmitter::importExplicitUseRenderer(
1368-
action_iterator InsertPt, RuleMatcher &Rule, BuildMIAction &DstMIBuilder,
1369-
const TreePatternNode &Dst) const {
1370-
if (Dst.hasName()) {
1371-
if (Error Err = importNamedNodeRenderer(Rule, DstMIBuilder, Dst))
1372-
return Err;
1373-
return InsertPt;
1374-
}
1366+
// Equivalent of MatcherGen::EmitResultOperand.
1367+
Error GlobalISelEmitter::importNodeRenderer(RuleMatcher &M,
1368+
BuildMIAction &MIBuilder,
1369+
const TreePatternNode &N,
1370+
action_iterator &InsertPt) const {
1371+
if (N.hasName())
1372+
return importNamedNodeRenderer(M, MIBuilder, N);
13751373

1376-
if (Dst.isLeaf()) {
1377-
if (Error Err = importLeafNodeRenderer(Rule, DstMIBuilder, Dst))
1378-
return Err;
1379-
return InsertPt;
1380-
}
1374+
if (N.isLeaf())
1375+
return importLeafNodeRenderer(M, MIBuilder, N);
13811376

1382-
if (Dst.getOperator()->isSubClassOf("SDNodeXForm")) {
1383-
if (Error Err = importXFormNodeRenderer(Rule, DstMIBuilder, Dst))
1384-
return Err;
1385-
return InsertPt;
1386-
}
1377+
if (N.getOperator()->isSubClassOf("SDNodeXForm"))
1378+
return importXFormNodeRenderer(M, MIBuilder, N);
13871379

1388-
if (Dst.getOperator()->isSubClassOf("Instruction")) {
1389-
if (Error Err =
1390-
importInstructionNodeRenderer(Rule, DstMIBuilder, Dst, InsertPt))
1391-
return Err;
1392-
return InsertPt;
1393-
}
1380+
if (N.getOperator()->isSubClassOf("Instruction"))
1381+
return importInstructionNodeRenderer(M, MIBuilder, N, InsertPt);
13941382

13951383
// Should not reach here.
1396-
return failedImport("unrecognized node " + llvm::to_string(Dst));
1384+
return failedImport("unrecognized node " + llvm::to_string(N));
13971385
}
13981386

13991387
/// Generates code that builds the resulting instruction(s) from the destination
@@ -1647,11 +1635,9 @@ Expected<action_iterator> GlobalISelEmitter::importExplicitUseRenderers(
16471635
dyn_cast<DefInit>(SubRegChild.getLeafValue())) {
16481636
CodeGenSubRegIndex *SubIdx = CGRegs.getSubRegIdx(SubRegInit->getDef());
16491637

1650-
auto InsertPtOrError =
1651-
importExplicitUseRenderer(InsertPt, M, DstMIBuilder, ValChild);
1652-
if (auto Error = InsertPtOrError.takeError())
1653-
return std::move(Error);
1654-
InsertPt = InsertPtOrError.get();
1638+
if (Error Err = importNodeRenderer(M, DstMIBuilder, ValChild, InsertPt))
1639+
return Err;
1640+
16551641
DstMIBuilder.addRenderer<SubRegIndexRenderer>(SubIdx);
16561642
}
16571643
}
@@ -1716,11 +1702,10 @@ Expected<action_iterator> GlobalISelEmitter::importExplicitUseRenderers(
17161702
continue;
17171703
}
17181704

1719-
auto InsertPtOrError = importExplicitUseRenderer(InsertPt, M, DstMIBuilder,
1720-
Dst.getChild(Child));
1721-
if (auto Error = InsertPtOrError.takeError())
1722-
return std::move(Error);
1723-
InsertPt = InsertPtOrError.get();
1705+
if (Error Err =
1706+
importNodeRenderer(M, DstMIBuilder, Dst.getChild(Child), InsertPt))
1707+
return Err;
1708+
17241709
++Child;
17251710
}
17261711

0 commit comments

Comments
 (0)