summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR
diff options
context:
space:
mode:
authorJacques Pienaar <jpienaar@google.com>2019-11-26 15:30:04 -0800
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-11-26 15:30:35 -0800
commitf27ceb726188d0b16c979fddf644e33886139006 (patch)
tree3ad42f08635e611814f85c20927d69ac415fb8f0 /mlir/lib/IR
parentcf97263cb8cd4f6f21f00eabb9d6a007e221eaab (diff)
downloadbcm5719-llvm-f27ceb726188d0b16c979fddf644e33886139006.tar.gz
bcm5719-llvm-f27ceb726188d0b16c979fddf644e33886139006.zip
Add create method that takes equivalent of OperationState with NamedAttributeList
This method is close to creating an OperationState first and then unpacking it but avoids creating the OperationState and takes a NamedAttributeList for attributes rather than array of NamedAttribute (to enable reusing an already created NamedAttributeList). Reuse this new method via create that takes OperationState. I'll update inferReturnTypes in follow up to also take NamedAttributeList and so a build method that uses both inferReturnTypes and create can reuse the same list. PiperOrigin-RevId: 282651642
Diffstat (limited to 'mlir/lib/IR')
-rw-r--r--mlir/lib/IR/Operation.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp
index 973b83307b3..e5ec43c699b 100644
--- a/mlir/lib/IR/Operation.cpp
+++ b/mlir/lib/IR/Operation.cpp
@@ -125,13 +125,26 @@ Operation *Operation::create(Location location, OperationName name,
/// Create a new Operation from operation state.
Operation *Operation::create(const OperationState &state) {
- unsigned numRegions = state.regions.size();
- Operation *op = create(state.location, state.name, state.types,
- state.operands, state.attributes, state.successors,
- numRegions, state.resizableOperandList);
+ return Operation::create(
+ state.location, state.name, state.types, state.operands,
+ NamedAttributeList(state.attributes).getDictionary(), state.successors,
+ state.regions, state.resizableOperandList);
+}
+
+/// Create a new Operation with the specific fields.
+Operation *Operation::create(Location location, OperationName name,
+ ArrayRef<Type> resultTypes,
+ ArrayRef<Value *> operands,
+ const NamedAttributeList &attributes,
+ ArrayRef<Block *> successors,
+ ArrayRef<std::unique_ptr<Region>> regions,
+ bool resizableOperandList) {
+ unsigned numRegions = regions.size();
+ Operation *op = create(location, name, resultTypes, operands, attributes,
+ successors, numRegions, resizableOperandList);
for (unsigned i = 0; i < numRegions; ++i)
- if (state.regions[i])
- op->getRegion(i).takeBody(*state.regions[i]);
+ if (regions[i])
+ op->getRegion(i).takeBody(*regions[i]);
return op;
}
OpenPOWER on IntegriCloud