summaryrefslogtreecommitdiffstats
path: root/llvm/utils/TableGen/GlobalISelEmitter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/utils/TableGen/GlobalISelEmitter.cpp')
-rw-r--r--llvm/utils/TableGen/GlobalISelEmitter.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index 2e52c8e6fc9..8079e2989b6 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -881,12 +881,19 @@ public:
void defineOperand(StringRef SymbolicName, OperandMatcher &OM);
- void defineComplexSubOperand(StringRef SymbolicName, Record *ComplexPattern,
- unsigned RendererID, unsigned SubOperandID) {
- assert(ComplexSubOperands.count(SymbolicName) == 0 && "Already defined");
+ Error defineComplexSubOperand(StringRef SymbolicName, Record *ComplexPattern,
+ unsigned RendererID, unsigned SubOperandID) {
+ if (ComplexSubOperands.count(SymbolicName))
+ return failedImport(
+ "Complex suboperand referenced more than once (Operand: " +
+ SymbolicName + ")");
+
ComplexSubOperands[SymbolicName] =
std::make_tuple(ComplexPattern, RendererID, SubOperandID);
+
+ return Error::success();
}
+
Optional<DefinedComplexPatternSubOperand>
getComplexSubOperand(StringRef SymbolicName) const {
const auto &I = ComplexSubOperands.find(SymbolicName);
@@ -3421,9 +3428,12 @@ Error GlobalISelEmitter::importChildMatcher(RuleMatcher &Rule,
for (unsigned i = 0, e = SrcChild->getNumChildren(); i != e; ++i) {
auto *SubOperand = SrcChild->getChild(i);
- if (!SubOperand->getName().empty())
- Rule.defineComplexSubOperand(SubOperand->getName(),
- SrcChild->getOperator(), RendererID, i);
+ if (!SubOperand->getName().empty()) {
+ if (auto Error = Rule.defineComplexSubOperand(SubOperand->getName(),
+ SrcChild->getOperator(),
+ RendererID, i))
+ return Error;
+ }
}
return Error::success();
OpenPOWER on IntegriCloud