@@ -120,9 +120,9 @@ class MLIRGenImpl {
120120 // Arguments type are uniformly unranked tensors.
121121 llvm::SmallVector<mlir::Type, 4 > argTypes (proto.getArgs ().size (),
122122 getType (VarType{}));
123- auto funcType = builder.getFunctionType (argTypes, std:: nullopt );
124- return builder. create < mlir::toy::FuncOp>( location, proto.getName (),
125- funcType);
123+ auto funcType = builder.getFunctionType (argTypes, {} );
124+ return mlir::toy::FuncOp::create (builder, location, proto.getName (),
125+ funcType);
126126 }
127127
128128 // / Emit a new function and add it to the MLIR module.
@@ -166,7 +166,7 @@ class MLIRGenImpl {
166166 if (!entryBlock.empty ())
167167 returnOp = dyn_cast<ReturnOp>(entryBlock.back ());
168168 if (!returnOp) {
169- builder. create < ReturnOp>( loc (funcAST.getProto ()->loc ()));
169+ ReturnOp::create (builder, loc (funcAST.getProto ()->loc ()));
170170 } else if (returnOp.hasOperand ()) {
171171 // Otherwise, if this return operation has an operand then add a result to
172172 // the function.
@@ -202,9 +202,9 @@ class MLIRGenImpl {
202202 // support '+' and '*'.
203203 switch (binop.getOp ()) {
204204 case ' +' :
205- return builder. create < AddOp>( location, lhs, rhs);
205+ return AddOp::create (builder, location, lhs, rhs);
206206 case ' *' :
207- return builder. create < MulOp>( location, lhs, rhs);
207+ return MulOp::create (builder, location, lhs, rhs);
208208 }
209209
210210 emitError (location, " invalid binary operator '" ) << binop.getOp () << " '" ;
@@ -235,8 +235,8 @@ class MLIRGenImpl {
235235 }
236236
237237 // Otherwise, this return operation has zero operands.
238- builder. create < ReturnOp>( location,
239- expr ? ArrayRef (expr) : ArrayRef<mlir::Value>());
238+ ReturnOp::create (builder, location,
239+ expr ? ArrayRef (expr) : ArrayRef<mlir::Value>());
240240 return mlir::success ();
241241 }
242242
@@ -264,8 +264,7 @@ class MLIRGenImpl {
264264 // The attribute is a vector with a floating point value per element
265265 // (number) in the array, see `collectData()` below for more details.
266266 std::vector<double > data;
267- data.reserve (std::accumulate (lit.getDims ().begin (), lit.getDims ().end (), 1 ,
268- std::multiplies<int >()));
267+ data.reserve (llvm::product_of (lit.getDims ()));
269268 collectData (lit, data);
270269
271270 // The type of this attribute is tensor of 64-bit floating-point with the
@@ -280,7 +279,7 @@ class MLIRGenImpl {
280279
281280 // Build the MLIR op `toy.constant`. This invokes the `ConstantOp::build`
282281 // method.
283- return builder. create < ConstantOp>( loc (lit.loc ()), type, dataAttribute);
282+ return ConstantOp::create (builder, loc (lit.loc ()), type, dataAttribute);
284283 }
285284
286285 // / Recursive helper function to accumulate the data that compose an array
@@ -325,13 +324,13 @@ class MLIRGenImpl {
325324 " does not accept multiple arguments" );
326325 return nullptr ;
327326 }
328- return builder. create < TransposeOp>( location, operands[0 ]);
327+ return TransposeOp::create (builder, location, operands[0 ]);
329328 }
330329
331330 // Otherwise this is a call to a user-defined function. Calls to
332331 // user-defined functions are mapped to a custom call that takes the callee
333332 // name as an attribute.
334- return builder. create < GenericCallOp>( location, callee, operands);
333+ return GenericCallOp::create (builder, location, callee, operands);
335334 }
336335
337336 // / Emit a print expression. It emits specific operations for two builtins:
@@ -341,13 +340,13 @@ class MLIRGenImpl {
341340 if (!arg)
342341 return mlir::failure ();
343342
344- builder. create < PrintOp>( loc (call.loc ()), arg);
343+ PrintOp::create (builder, loc (call.loc ()), arg);
345344 return mlir::success ();
346345 }
347346
348347 // / Emit a constant for a single number (FIXME: semantic? broadcast?)
349348 mlir::Value mlirGen (NumberExprAST &num) {
350- return builder. create < ConstantOp>( loc (num.loc ()), num.getValue ());
349+ return ConstantOp::create (builder, loc (num.loc ()), num.getValue ());
351350 }
352351
353352 // / Dispatch codegen for the right expression subclass using RTTI.
@@ -391,8 +390,8 @@ class MLIRGenImpl {
391390 // with specific shape, we emit a "reshape" operation. It will get
392391 // optimized out later as needed.
393392 if (!vardecl.getType ().shape .empty ()) {
394- value = builder. create < ReshapeOp>( loc (vardecl.loc ()),
395- getType (vardecl.getType ()), value);
393+ value = ReshapeOp::create (builder, loc (vardecl.loc ()),
394+ getType (vardecl.getType ()), value);
396395 }
397396
398397 // Register the value in the symbol table.
0 commit comments