Switch explicit create methods to match generated build's order
authorJacques Pienaar <jpienaar@google.com>
Sat, 28 Sep 2019 16:35:23 +0000 (09:35 -0700)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Sat, 28 Sep 2019 16:35:58 +0000 (09:35 -0700)
The generated build methods have result type before the arguments (operands and attributes, which are also now adjacent in the explicit create method). This also results in changing the create method's ordering to match most build method's ordering.

PiperOrigin-RevId: 271755054

mlir/include/mlir/IR/Operation.h
mlir/lib/IR/Operation.cpp
mlir/lib/Parser/Parser.cpp
mlir/lib/Transforms/DialectConversion.cpp
mlir/unittests/IR/OperationSupportTest.cpp

index 0c5cbea..b4b1384 100644 (file)
@@ -52,8 +52,8 @@ class Operation final
 public:
   /// Create a new Operation with the specific fields.
   static Operation *create(Location location, OperationName name,
-                           ArrayRef<Value *> operands,
                            ArrayRef<Type> resultTypes,
+                           ArrayRef<Value *> operands,
                            ArrayRef<NamedAttribute> attributes,
                            ArrayRef<Block *> successors, unsigned numRegions,
                            bool resizableOperandList);
@@ -61,8 +61,8 @@ public:
   /// Overload of create that takes an existing NamedAttributeList to avoid
   /// unnecessarily uniquing a list of attributes.
   static Operation *create(Location location, OperationName name,
-                           ArrayRef<Value *> operands,
                            ArrayRef<Type> resultTypes,
+                           ArrayRef<Value *> operands,
                            const NamedAttributeList &attributes,
                            ArrayRef<Block *> successors, unsigned numRegions,
                            bool resizableOperandList);
index b32f968..25302e5 100644 (file)
@@ -101,12 +101,12 @@ template <> unsigned BlockOperand::getOperandNumber() {
 
 /// Create a new Operation with the specific fields.
 Operation *Operation::create(Location location, OperationName name,
-                             ArrayRef<Value *> operands,
                              ArrayRef<Type> resultTypes,
+                             ArrayRef<Value *> operands,
                              ArrayRef<NamedAttribute> attributes,
                              ArrayRef<Block *> successors, unsigned numRegions,
                              bool resizableOperandList) {
-  return create(location, name, operands, resultTypes,
+  return create(location, name, resultTypes, operands,
                 NamedAttributeList(attributes), successors, numRegions,
                 resizableOperandList);
 }
@@ -114,8 +114,8 @@ 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.operands,
-                         state.types, state.attributes, state.successors,
+  Operation *op = create(state.location, state.name, state.types,
+                         state.operands, state.attributes, state.successors,
                          numRegions, state.resizableOperandList);
   for (unsigned i = 0; i < numRegions; ++i)
     if (state.regions[i])
@@ -126,8 +126,8 @@ Operation *Operation::create(const OperationState &state) {
 /// Overload of create that takes an existing NamedAttributeList to avoid
 /// unnecessarily uniquing a list of attributes.
 Operation *Operation::create(Location location, OperationName name,
-                             ArrayRef<Value *> operands,
                              ArrayRef<Type> resultTypes,
+                             ArrayRef<Value *> operands,
                              const NamedAttributeList &attributes,
                              ArrayRef<Block *> successors, unsigned numRegions,
                              bool resizableOperandList) {
@@ -572,7 +572,7 @@ Operation *Operation::cloneWithoutRegions(BlockAndValueMapping &mapper) {
   SmallVector<Type, 8> resultTypes(getResultTypes());
   unsigned numRegions = getNumRegions();
   auto *newOp =
-      Operation::create(getLoc(), getName(), operands, resultTypes, attrs,
+      Operation::create(getLoc(), getName(), resultTypes, operands, attrs,
                         successors, numRegions, hasResizableOperandsList());
 
   // Remember the mapping of any results.
index 9fd2176..33e1c6c 100644 (file)
@@ -3000,7 +3000,7 @@ Value *OperationParser::createForwardRefPlaceholder(SMLoc loc, Type type) {
   // them.
   auto name = OperationName("placeholder", getContext());
   auto *op = Operation::create(
-      getEncodedSourceLocation(loc), name, /*operands=*/{}, type,
+      getEncodedSourceLocation(loc), name, type, /*operands=*/{},
       /*attributes=*/llvm::None, /*successors=*/{}, /*numRegions=*/0,
       /*resizableOperandList=*/false);
   forwardRefPlaceholders[op->getResult(0)] = loc;
index cdd5be8..1b6b9f7 100644 (file)
@@ -298,7 +298,7 @@ Operation *ArgConverter::convertArgument(BlockArgument *origArg,
 /// A utility function used to create a conversion cast operation with the
 /// given input and result types.
 Operation *ArgConverter::createCast(ArrayRef<Value *> inputs, Type outputType) {
-  return Operation::create(loc, castOpName, inputs, outputType, llvm::None,
+  return Operation::create(loc, castOpName, outputType, inputs, llvm::None,
                            llvm::None, 0, false);
 }
 
index 2cebba6..80f82ac 100644 (file)
@@ -28,8 +28,8 @@ Operation *createOp(MLIRContext *context, bool resizableOperands,
                     ArrayRef<Value *> operands = llvm::None,
                     ArrayRef<Type> resultTypes = llvm::None) {
   return Operation::create(
-      UnknownLoc::get(context), OperationName("foo.bar", context), operands,
-      resultTypes, llvm::None, llvm::None, 0, resizableOperands);
+      UnknownLoc::get(context), OperationName("foo.bar", context), resultTypes,
+      operands, llvm::None, llvm::None, 0, resizableOperands);
 }
 
 TEST(OperandStorageTest, NonResizable) {