Clean up the op builder APIs, and simplify the implementation of ops by making
OperationState contain a context and have the generic builder mechanics handle
the job of initializing the OperationState and setting the op name. NFC.
PiperOrigin-RevId: 209869948
diff --git a/lib/Parser/Parser.cpp b/lib/Parser/Parser.cpp
index d2ea5bf..de82e45 100644
--- a/lib/Parser/Parser.cpp
+++ b/lib/Parser/Parser.cpp
@@ -1648,7 +1648,7 @@
consumeToken(Token::string);
- OperationState result(builder.getIdentifier(name));
+ OperationState result(builder.getContext(), name);
// Parse the operand list.
SmallVector<SSAUseInfo, 8> operandInfos;
@@ -1675,7 +1675,7 @@
if (!fnType)
return (emitError(typeLoc, "expected function type"), nullptr);
- result.types.append(fnType->getResults().begin(), fnType->getResults().end());
+ result.addTypes(fnType->getResults());
// Check that we have the right number of types for the operands.
auto operandTypes = fnType->getInputs();
@@ -1916,7 +1916,7 @@
opNameStr.c_str());
// Have the op implementation take a crack and parsing this.
- OperationState opState(builder.getIdentifier(opName));
+ OperationState opState(builder.getContext(), opName);
if (opDefinition->parseAssembly(&opAsmParser, &opState))
return nullptr;