diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td --- a/flang/include/flang/Optimizer/Dialect/FIROps.td +++ b/flang/include/flang/Optimizer/Dialect/FIROps.td @@ -138,7 +138,7 @@ // Base builder for allocate operations def fir_AllocateOpBuilder : OpBuilder< - "Builder *builder, OperationState &result, Type inType," + "OpBuilder &builder, OperationState &result, Type inType," "ValueRange lenParams = {}, ValueRange sizes = {}," "ArrayRef attributes = {}", [{ @@ -149,7 +149,7 @@ }]>; def fir_NamedAllocateOpBuilder : OpBuilder< - "Builder *builder, OperationState &result, Type inType, StringRef name," + "OpBuilder &builder, OperationState &result, Type inType, StringRef name," "ValueRange lenParams = {}, ValueRange sizes = {}," "ArrayRef attributes = {}", [{ @@ -161,7 +161,7 @@ }]>; def fir_OneResultOpBuilder : OpBuilder< - "Builder *, OperationState &result, Type resultType," + "OpBuilder &, OperationState &result, Type resultType," "ValueRange operands, ArrayRef attributes = {}", [{ if (resultType) @@ -356,7 +356,7 @@ let arguments = (ins AnyReferenceLike:$memref); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value refVal", + "OpBuilder &builder, OperationState &result, Value refVal", [{ if (!refVal) { mlir::emitError(result.location, "LoadOp has null argument"); @@ -547,7 +547,7 @@ let successors = (successor VariadicSuccessor:$targets); let builders = [OpBuilder< - "Builder *, OperationState &result, Value selector," + "OpBuilder &, OperationState &result, Value selector," "ValueRange properOperands, ArrayRef destinations," "ArrayRef operands = {}," "ArrayRef attributes = {}", @@ -1572,7 +1572,7 @@ }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, StringRef fieldName," + "OpBuilder &builder, OperationState &result, StringRef fieldName," "Type recTy, ValueRange operands = {}", [{ result.addAttribute(fieldAttrName(), builder->getStringAttr(fieldName)); @@ -1696,7 +1696,7 @@ }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, StringRef fieldName, Type recTy", + "OpBuilder &builder, OperationState &result, StringRef fieldName, Type recTy", [{ result.addAttribute(fieldAttrName(), builder->getStringAttr(fieldName)); result.addAttribute(typeAttrName(), TypeAttr::get(recTy)); @@ -1751,7 +1751,7 @@ let skipDefaultBuilders = 1; let builders = [ - OpBuilder<"mlir::Builder *builder, OperationState &result," + OpBuilder<"mlir::OpBuilder &builder, OperationState &result," "mlir::Value lowerBound, mlir::Value upperBound," "ValueRange step = {}, ArrayRef attributes = {}"> ]; @@ -1853,7 +1853,7 @@ let skipDefaultBuilders = 1; let builders = [ - OpBuilder<"Builder *builder, OperationState &result, " + OpBuilder<"OpBuilder &builder, OperationState &result, " "Value cond, bool withOtherRegion"> ]; @@ -2168,7 +2168,7 @@ let results = (outs AnyLogicalLike); let builders = [OpBuilder< - "Builder *builder, OperationState &result, CmpFPredicate predicate," + "OpBuilder &builder, OperationState &result, CmpFPredicate predicate," "Value lhs, Value rhs", [{ buildCmpFOp(builder, result, predicate, lhs, rhs); }]>]; @@ -2276,7 +2276,7 @@ let printer = "printCmpcOp(p, *this);"; let builders = [OpBuilder< - "Builder *builder, OperationState &result, CmpFPredicate predicate," + "OpBuilder &builder, OperationState &result, CmpFPredicate predicate," "Value lhs, Value rhs", [{ buildCmpCOp(builder, result, predicate, lhs, rhs); }]>]; @@ -2380,7 +2380,7 @@ }]; let builders = [ - OpBuilder<"Builder *, OperationState &result, mlir::TypeAttr inty"> + OpBuilder<"OpBuilder &, OperationState &result, mlir::TypeAttr inty"> ]; let verifier = [{ @@ -2523,7 +2523,7 @@ let skipDefaultBuilders = 1; let builders = [ - OpBuilder<"mlir::Builder *builder, OperationState &result," + OpBuilder<"mlir::OpBuilder &builder, OperationState &result," "StringRef name, Type type, ArrayRef attrs = {}", [{ result.addAttribute(typeAttrName(), mlir::TypeAttr::get(type)); @@ -2663,7 +2663,7 @@ let skipDefaultBuilders = 1; let builders = [ - OpBuilder<"mlir::Builder *builder, OperationState *result," + OpBuilder<"mlir::OpBuilder &builder, OperationState *result," "StringRef name, Type type, ArrayRef attrs = {}", [{ result->addAttribute(mlir::SymbolTable::getSymbolAttrName(), diff --git a/flang/lib/Optimizer/Dialect/FIROps.cpp b/flang/lib/Optimizer/Dialect/FIROps.cpp --- a/flang/lib/Optimizer/Dialect/FIROps.cpp +++ b/flang/lib/Optimizer/Dialect/FIROps.cpp @@ -185,7 +185,7 @@ return pred.getValue(); } -void fir::buildCmpFOp(Builder *builder, OperationState &result, +void fir::buildCmpFOp(OpBuilder &builder, OperationState &result, CmpFPredicate predicate, Value lhs, Value rhs) { result.addOperands({lhs, rhs}); result.types.push_back(builder->getI1Type()); @@ -251,7 +251,7 @@ // CmpcOp //===----------------------------------------------------------------------===// -void fir::buildCmpCOp(Builder *builder, OperationState &result, +void fir::buildCmpCOp(OpBuilder &builder, OperationState &result, CmpFPredicate predicate, Value lhs, Value rhs) { result.addOperands({lhs, rhs}); result.types.push_back(builder->getI1Type()); @@ -331,7 +331,7 @@ // GenTypeDescOp //===----------------------------------------------------------------------===// -void fir::GenTypeDescOp::build(Builder *, OperationState &result, +void fir::GenTypeDescOp::build(OpBuilder &, OperationState &result, mlir::TypeAttr inty) { result.addAttribute("in_type", inty); result.addTypes(TypeDescType::get(inty.getValue())); @@ -367,7 +367,7 @@ // LoopOp //===----------------------------------------------------------------------===// -void fir::LoopOp::build(mlir::Builder *builder, OperationState &result, +void fir::LoopOp::build(mlir::OpBuilder &builder, OperationState &result, mlir::Value lb, mlir::Value ub, ValueRange step, ArrayRef attributes) { if (step.empty()) @@ -730,7 +730,7 @@ // WhereOp //===----------------------------------------------------------------------===// -void fir::WhereOp::build(mlir::Builder *builder, OperationState &result, +void fir::WhereOp::build(mlir::OpBuilder &builder, OperationState &result, mlir::Value cond, bool withElseRegion) { result.addOperands(cond); mlir::Region *thenRegion = result.addRegion(); diff --git a/mlir/docs/DeclarativeRewrites.md b/mlir/docs/DeclarativeRewrites.md --- a/mlir/docs/DeclarativeRewrites.md +++ b/mlir/docs/DeclarativeRewrites.md @@ -265,7 +265,7 @@ ```c++ -void AOp::build(Builder *builder, OperationState &state, +void AOp::build(OpBuilder &builder, OperationState &state, Value input, Attribute attr) { state.addOperands({input}); state.addAttribute("a_attr", attr); diff --git a/mlir/docs/OpDefinitions.md b/mlir/docs/OpDefinitions.md --- a/mlir/docs/OpDefinitions.md +++ b/mlir/docs/OpDefinitions.md @@ -490,14 +490,14 @@ ```c++ // All result-types/operands/attributes have one aggregate parameter. -static void build(Builder *odsBuilder, OperationState &odsState, +static void build(OpBuilder &odsBuilder, OperationState &odsState, ArrayRef resultTypes, ValueRange operands, ArrayRef attributes); // Each result-type/operand/attribute has a separate parameter. The parameters // for attributes are of mlir::Attribute types. -static void build(Builder *odsBuilder, OperationState &odsState, +static void build(OpBuilder &odsBuilder, OperationState &odsState, Type i32_result, Type f32_result, ..., Value i32_operand, Value f32_operand, ..., IntegerAttr i32_attr, FloatAttr f32_attr, ...); @@ -506,20 +506,20 @@ // for attributes are raw values unwrapped with mlir::Attribute instances. // (Note that this builder will not always be generated. See the following // explanation for more details.) -static void build(Builder *odsBuilder, OperationState &odsState, +static void build(OpBuilder &odsBuilder, OperationState &odsState, Type i32_result, Type f32_result, ..., Value i32_operand, Value f32_operand, ..., APInt i32_attr, StringRef f32_attr, ...); // Each operand/attribute has a separate parameter but result type is aggregate. -static void build(Builder *odsBuilder, OperationState &odsState, +static void build(OpBuilder &odsBuilder, OperationState &odsState, ArrayRef resultTypes, Value i32_operand, Value f32_operand, ..., IntegerAttr i32_attr, FloatAttr f32_attr, ...); // All operands/attributes have aggregate parameters. // Generated if InferTypeOpInterface interface is specified. -static void build(Builder *odsBuilder, OperationState &odsState, +static void build(OpBuilder &odsBuilder, OperationState &odsState, ValueRange operands, ArrayRef attributes); @@ -581,8 +581,8 @@ ... let builders = [ - OpBuilder<"Builder *builder, OperationState &state, float val = 0.5f", [{ - state.addAttribute("attr", builder->getF32FloatAttr(val)); + OpBuilder<"OpBuilder &builder, OperationState &state, float val = 0.5f", [{ + state.addAttribute("attr", builder.getF32FloatAttr(val)); }]> ]; } @@ -591,8 +591,8 @@ The generated builder will look like: ```c++ -static void build(Builder *builder, OperationState &state, float val = 0.5f) { - state.addAttribute("attr", builder->getF32FloatAttr(val)); +static void build(OpBuilder &builder, OperationState &state, float val = 0.5f) { + state.addAttribute("attr", builder.getF32FloatAttr(val)); } ``` diff --git a/mlir/docs/Tutorials/Toy/Ch-2.md b/mlir/docs/Tutorials/Toy/Ch-2.md --- a/mlir/docs/Tutorials/Toy/Ch-2.md +++ b/mlir/docs/Tutorials/Toy/Ch-2.md @@ -476,7 +476,7 @@ // using `builder.create(...)`. let builders = [ // Build a constant with a given constant tensor value. - OpBuilder<"Builder *builder, OperationState &result, " + OpBuilder<"OpBuilder &builder, OperationState &result, " "DenseElementsAttr value", [{ // Call into an autogenerated `build` method. build(builder, result, value.getType(), value); @@ -484,7 +484,7 @@ // Build a constant with a given constant floating-point value. This builder // creates a declaration for `ConstantOp::build` with the given parameters. - OpBuilder<"Builder *builder, OperationState &result, double value"> + OpBuilder<"OpBuilder &builder, OperationState &result, double value"> ]; } ``` diff --git a/mlir/examples/toy/Ch2/include/toy/Ops.td b/mlir/examples/toy/Ch2/include/toy/Ops.td --- a/mlir/examples/toy/Ch2/include/toy/Ops.td +++ b/mlir/examples/toy/Ch2/include/toy/Ops.td @@ -68,13 +68,13 @@ // using `builder.create(...)`. let builders = [ // Build a constant with a given constant tensor value. - OpBuilder<"Builder *builder, OperationState &state, " + OpBuilder<"OpBuilder &builder, OperationState &state, " "DenseElementsAttr value", [{ build(builder, state, value.getType(), value); }]>, // Build a constant with a given constant floating-point value. - OpBuilder<"Builder *builder, OperationState &state, double value"> + OpBuilder<"OpBuilder &builder, OperationState &state, double value"> ]; // Invoke a static verify method to verify this constant operation. @@ -97,7 +97,7 @@ // Allow building an AddOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value lhs, Value rhs"> + OpBuilder<"OpBuilder &b, OperationState &state, Value lhs, Value rhs"> ]; } @@ -132,7 +132,7 @@ // Add custom build methods for the generic call operation. let builders = [ - OpBuilder<"Builder *builder, OperationState &state, " + OpBuilder<"OpBuilder &builder, OperationState &state, " "StringRef callee, ArrayRef arguments"> ]; } @@ -153,7 +153,7 @@ // Allow building a MulOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value lhs, Value rhs"> + OpBuilder<"OpBuilder &b, OperationState &state, Value lhs, Value rhs"> ]; } @@ -217,7 +217,7 @@ // Allow building a ReturnOp with no return operand. let builders = [OpBuilder< - "Builder *b, OperationState &state", [{ build(b, state, llvm::None); }] + "OpBuilder &b, OperationState &state", [{ build(b, state, llvm::None); }] >]; // Provide extra utility definitions on the c++ operation class definition. @@ -241,7 +241,7 @@ // Allow building a TransposeOp with from the input operand. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value input"> + OpBuilder<"OpBuilder &b, OperationState &state, Value input"> ]; // Invoke a static verify method to verify this transpose operation. diff --git a/mlir/examples/toy/Ch2/mlir/Dialect.cpp b/mlir/examples/toy/Ch2/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch2/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch2/mlir/Dialect.cpp @@ -91,9 +91,9 @@ /// Build a constant operation. /// The builder is passed as an argument, so is the state that this method is /// expected to fill in order to build the operation. -void ConstantOp::build(mlir::Builder *builder, mlir::OperationState &state, +void ConstantOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, double value) { - auto dataType = RankedTensorType::get({}, builder->getF64Type()); + auto dataType = RankedTensorType::get({}, builder.getF64Type()); auto dataAttribute = DenseElementsAttr::get(dataType, value); ConstantOp::build(builder, state, dataType, dataAttribute); } @@ -158,29 +158,29 @@ //===----------------------------------------------------------------------===// // AddOp -void AddOp::build(mlir::Builder *builder, mlir::OperationState &state, +void AddOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value lhs, mlir::Value rhs) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands({lhs, rhs}); } //===----------------------------------------------------------------------===// // GenericCallOp -void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState &state, +void GenericCallOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, StringRef callee, ArrayRef arguments) { // Generic call always returns an unranked Tensor initially. - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands(arguments); - state.addAttribute("callee", builder->getSymbolRefAttr(callee)); + state.addAttribute("callee", builder.getSymbolRefAttr(callee)); } //===----------------------------------------------------------------------===// // MulOp -void MulOp::build(mlir::Builder *builder, mlir::OperationState &state, +void MulOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value lhs, mlir::Value rhs) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands({lhs, rhs}); } @@ -225,9 +225,9 @@ //===----------------------------------------------------------------------===// // TransposeOp -void TransposeOp::build(mlir::Builder *builder, mlir::OperationState &state, +void TransposeOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value value) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands(value); } diff --git a/mlir/examples/toy/Ch3/include/toy/Ops.td b/mlir/examples/toy/Ch3/include/toy/Ops.td --- a/mlir/examples/toy/Ch3/include/toy/Ops.td +++ b/mlir/examples/toy/Ch3/include/toy/Ops.td @@ -67,13 +67,13 @@ // using `builder.create(...)`. let builders = [ // Build a constant with a given constant tensor value. - OpBuilder<"Builder *builder, OperationState &state, " + OpBuilder<"OpBuilder &builder, OperationState &state, " "DenseElementsAttr value", [{ build(builder, state, value.getType(), value); }]>, // Build a constant with a given constant floating-point value. - OpBuilder<"Builder *builder, OperationState &state, double value"> + OpBuilder<"OpBuilder &builder, OperationState &state, double value"> ]; // Invoke a static verify method to verify this constant operation. @@ -96,7 +96,7 @@ // Allow building an AddOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value lhs, Value rhs"> + OpBuilder<"OpBuilder &b, OperationState &state, Value lhs, Value rhs"> ]; } @@ -131,7 +131,7 @@ // Add custom build methods for the generic call operation. let builders = [ - OpBuilder<"Builder *builder, OperationState &state, " + OpBuilder<"OpBuilder &builder, OperationState &state, " "StringRef callee, ArrayRef arguments"> ]; } @@ -152,7 +152,7 @@ // Allow building a MulOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value lhs, Value rhs"> + OpBuilder<"OpBuilder &b, OperationState &state, Value lhs, Value rhs"> ]; } @@ -219,7 +219,7 @@ // Allow building a ReturnOp with no return operand. let builders = [OpBuilder< - "Builder *b, OperationState &state", [{ build(b, state, llvm::None); }] + "OpBuilder &b, OperationState &state", [{ build(b, state, llvm::None); }] >]; // Provide extra utility definitions on the c++ operation class definition. @@ -246,7 +246,7 @@ // Allow building a TransposeOp with from the input operand. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value input"> + OpBuilder<"OpBuilder &b, OperationState &state, Value input"> ]; // Invoke a static verify method to verify this transpose operation. diff --git a/mlir/examples/toy/Ch3/mlir/Dialect.cpp b/mlir/examples/toy/Ch3/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch3/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch3/mlir/Dialect.cpp @@ -91,9 +91,9 @@ /// Build a constant operation. /// The builder is passed as an argument, so is the state that this method is /// expected to fill in order to build the operation. -void ConstantOp::build(mlir::Builder *builder, mlir::OperationState &state, +void ConstantOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, double value) { - auto dataType = RankedTensorType::get({}, builder->getF64Type()); + auto dataType = RankedTensorType::get({}, builder.getF64Type()); auto dataAttribute = DenseElementsAttr::get(dataType, value); ConstantOp::build(builder, state, dataType, dataAttribute); } @@ -158,29 +158,29 @@ //===----------------------------------------------------------------------===// // AddOp -void AddOp::build(mlir::Builder *builder, mlir::OperationState &state, +void AddOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value lhs, mlir::Value rhs) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands({lhs, rhs}); } //===----------------------------------------------------------------------===// // GenericCallOp -void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState &state, +void GenericCallOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, StringRef callee, ArrayRef arguments) { // Generic call always returns an unranked Tensor initially. - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands(arguments); - state.addAttribute("callee", builder->getSymbolRefAttr(callee)); + state.addAttribute("callee", builder.getSymbolRefAttr(callee)); } //===----------------------------------------------------------------------===// // MulOp -void MulOp::build(mlir::Builder *builder, mlir::OperationState &state, +void MulOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value lhs, mlir::Value rhs) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands({lhs, rhs}); } @@ -225,9 +225,9 @@ //===----------------------------------------------------------------------===// // TransposeOp -void TransposeOp::build(mlir::Builder *builder, mlir::OperationState &state, +void TransposeOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value value) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands(value); } diff --git a/mlir/examples/toy/Ch4/include/toy/Ops.td b/mlir/examples/toy/Ch4/include/toy/Ops.td --- a/mlir/examples/toy/Ch4/include/toy/Ops.td +++ b/mlir/examples/toy/Ch4/include/toy/Ops.td @@ -69,13 +69,13 @@ // using `builder.create(...)`. let builders = [ // Build a constant with a given constant tensor value. - OpBuilder<"Builder *builder, OperationState &state, " + OpBuilder<"OpBuilder &builder, OperationState &state, " "DenseElementsAttr value", [{ build(builder, state, value.getType(), value); }]>, // Build a constant with a given constant floating-point value. - OpBuilder<"Builder *builder, OperationState &state, double value"> + OpBuilder<"OpBuilder &builder, OperationState &state, double value"> ]; // Invoke a static verify method to verify this constant operation. @@ -99,7 +99,7 @@ // Allow building an AddOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value lhs, Value rhs"> + OpBuilder<"OpBuilder &b, OperationState &state, Value lhs, Value rhs"> ]; } @@ -156,7 +156,7 @@ // Add custom build methods for the generic call operation. let builders = [ - OpBuilder<"Builder *builder, OperationState &state, " + OpBuilder<"OpBuilder &builder, OperationState &state, " "StringRef callee, ArrayRef arguments"> ]; } @@ -178,7 +178,7 @@ // Allow building a MulOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value lhs, Value rhs"> + OpBuilder<"OpBuilder &b, OperationState &state, Value lhs, Value rhs"> ]; } @@ -245,7 +245,7 @@ // Allow building a ReturnOp with no return operand. let builders = [OpBuilder< - "Builder *b, OperationState &state", [{ build(b, state, llvm::None); }] + "OpBuilder &b, OperationState &state", [{ build(b, state, llvm::None); }] >]; // Provide extra utility definitions on the c++ operation class definition. @@ -273,7 +273,7 @@ // Allow building a TransposeOp with from the input operand. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value input"> + OpBuilder<"OpBuilder &b, OperationState &state, Value input"> ]; // Invoke a static verify method to verify this transpose operation. diff --git a/mlir/examples/toy/Ch4/mlir/Dialect.cpp b/mlir/examples/toy/Ch4/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch4/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch4/mlir/Dialect.cpp @@ -141,9 +141,9 @@ /// Build a constant operation. /// The builder is passed as an argument, so is the state that this method is /// expected to fill in order to build the operation. -void ConstantOp::build(mlir::Builder *builder, mlir::OperationState &state, +void ConstantOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, double value) { - auto dataType = RankedTensorType::get({}, builder->getF64Type()); + auto dataType = RankedTensorType::get({}, builder.getF64Type()); auto dataAttribute = DenseElementsAttr::get(dataType, value); ConstantOp::build(builder, state, dataType, dataAttribute); } @@ -208,9 +208,9 @@ //===----------------------------------------------------------------------===// // AddOp -void AddOp::build(mlir::Builder *builder, mlir::OperationState &state, +void AddOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value lhs, mlir::Value rhs) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands({lhs, rhs}); } @@ -228,12 +228,12 @@ //===----------------------------------------------------------------------===// // GenericCallOp -void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState &state, +void GenericCallOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, StringRef callee, ArrayRef arguments) { // Generic call always returns an unranked Tensor initially. - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands(arguments); - state.addAttribute("callee", builder->getSymbolRefAttr(callee)); + state.addAttribute("callee", builder.getSymbolRefAttr(callee)); } /// Return the callee of the generic call operation, this is required by the @@ -249,9 +249,9 @@ //===----------------------------------------------------------------------===// // MulOp -void MulOp::build(mlir::Builder *builder, mlir::OperationState &state, +void MulOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value lhs, mlir::Value rhs) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands({lhs, rhs}); } @@ -300,9 +300,9 @@ //===----------------------------------------------------------------------===// // TransposeOp -void TransposeOp::build(mlir::Builder *builder, mlir::OperationState &state, +void TransposeOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value value) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands(value); } diff --git a/mlir/examples/toy/Ch5/include/toy/Ops.td b/mlir/examples/toy/Ch5/include/toy/Ops.td --- a/mlir/examples/toy/Ch5/include/toy/Ops.td +++ b/mlir/examples/toy/Ch5/include/toy/Ops.td @@ -69,13 +69,13 @@ // using `builder.create(...)`. let builders = [ // Build a constant with a given constant tensor value. - OpBuilder<"Builder *builder, OperationState &state, " + OpBuilder<"OpBuilder &builder, OperationState &state, " "DenseElementsAttr value", [{ build(builder, state, value.getType(), value); }]>, // Build a constant with a given constant floating-point value. - OpBuilder<"Builder *builder, OperationState &state, double value"> + OpBuilder<"OpBuilder &builder, OperationState &state, double value"> ]; // Invoke a static verify method to verify this constant operation. @@ -99,7 +99,7 @@ // Allow building an AddOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value lhs, Value rhs"> + OpBuilder<"OpBuilder &b, OperationState &state, Value lhs, Value rhs"> ]; } @@ -156,7 +156,7 @@ // Add custom build methods for the generic call operation. let builders = [ - OpBuilder<"Builder *builder, OperationState &state, " + OpBuilder<"OpBuilder &builder, OperationState &state, " "StringRef callee, ArrayRef arguments"> ]; } @@ -178,7 +178,7 @@ // Allow building a MulOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value lhs, Value rhs"> + OpBuilder<"OpBuilder &b, OperationState &state, Value lhs, Value rhs"> ]; } @@ -246,7 +246,7 @@ // Allow building a ReturnOp with no return operand. let builders = [OpBuilder< - "Builder *b, OperationState &state", [{ build(b, state, llvm::None); }] + "OpBuilder &b, OperationState &state", [{ build(b, state, llvm::None); }] >]; // Provide extra utility definitions on the c++ operation class definition. @@ -274,7 +274,7 @@ // Allow building a TransposeOp with from the input operand. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value input"> + OpBuilder<"OpBuilder &b, OperationState &state, Value input"> ]; // Invoke a static verify method to verify this transpose operation. diff --git a/mlir/examples/toy/Ch5/mlir/Dialect.cpp b/mlir/examples/toy/Ch5/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch5/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch5/mlir/Dialect.cpp @@ -141,9 +141,9 @@ /// Build a constant operation. /// The builder is passed as an argument, so is the state that this method is /// expected to fill in order to build the operation. -void ConstantOp::build(mlir::Builder *builder, mlir::OperationState &state, +void ConstantOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, double value) { - auto dataType = RankedTensorType::get({}, builder->getF64Type()); + auto dataType = RankedTensorType::get({}, builder.getF64Type()); auto dataAttribute = DenseElementsAttr::get(dataType, value); ConstantOp::build(builder, state, dataType, dataAttribute); } @@ -208,9 +208,9 @@ //===----------------------------------------------------------------------===// // AddOp -void AddOp::build(mlir::Builder *builder, mlir::OperationState &state, +void AddOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value lhs, mlir::Value rhs) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands({lhs, rhs}); } @@ -228,12 +228,12 @@ //===----------------------------------------------------------------------===// // GenericCallOp -void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState &state, +void GenericCallOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, StringRef callee, ArrayRef arguments) { // Generic call always returns an unranked Tensor initially. - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands(arguments); - state.addAttribute("callee", builder->getSymbolRefAttr(callee)); + state.addAttribute("callee", builder.getSymbolRefAttr(callee)); } /// Return the callee of the generic call operation, this is required by the @@ -249,9 +249,9 @@ //===----------------------------------------------------------------------===// // MulOp -void MulOp::build(mlir::Builder *builder, mlir::OperationState &state, +void MulOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value lhs, mlir::Value rhs) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands({lhs, rhs}); } @@ -300,9 +300,9 @@ //===----------------------------------------------------------------------===// // TransposeOp -void TransposeOp::build(mlir::Builder *builder, mlir::OperationState &state, +void TransposeOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value value) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands(value); } diff --git a/mlir/examples/toy/Ch6/include/toy/Ops.td b/mlir/examples/toy/Ch6/include/toy/Ops.td --- a/mlir/examples/toy/Ch6/include/toy/Ops.td +++ b/mlir/examples/toy/Ch6/include/toy/Ops.td @@ -69,13 +69,13 @@ // using `builder.create(...)`. let builders = [ // Build a constant with a given constant tensor value. - OpBuilder<"Builder *builder, OperationState &state, " + OpBuilder<"OpBuilder &builder, OperationState &state, " "DenseElementsAttr value", [{ build(builder, state, value.getType(), value); }]>, // Build a constant with a given constant floating-point value. - OpBuilder<"Builder *builder, OperationState &state, double value"> + OpBuilder<"OpBuilder &builder, OperationState &state, double value"> ]; // Invoke a static verify method to verify this constant operation. @@ -99,7 +99,7 @@ // Allow building an AddOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value lhs, Value rhs"> + OpBuilder<"OpBuilder &b, OperationState &state, Value lhs, Value rhs"> ]; } @@ -156,7 +156,7 @@ // Add custom build methods for the generic call operation. let builders = [ - OpBuilder<"Builder *builder, OperationState &state, " + OpBuilder<"OpBuilder &builder, OperationState &state, " "StringRef callee, ArrayRef arguments"> ]; } @@ -178,7 +178,7 @@ // Allow building a MulOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value lhs, Value rhs"> + OpBuilder<"OpBuilder &b, OperationState &state, Value lhs, Value rhs"> ]; } @@ -246,7 +246,7 @@ // Allow building a ReturnOp with no return operand. let builders = [OpBuilder< - "Builder *b, OperationState &state", [{ build(b, state, llvm::None); }] + "OpBuilder &b, OperationState &state", [{ build(b, state, llvm::None); }] >]; // Provide extra utility definitions on the c++ operation class definition. @@ -274,7 +274,7 @@ // Allow building a TransposeOp with from the input operand. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value input"> + OpBuilder<"OpBuilder &b, OperationState &state, Value input"> ]; // Invoke a static verify method to verify this transpose operation. diff --git a/mlir/examples/toy/Ch6/mlir/Dialect.cpp b/mlir/examples/toy/Ch6/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch6/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch6/mlir/Dialect.cpp @@ -141,9 +141,9 @@ /// Build a constant operation. /// The builder is passed as an argument, so is the state that this method is /// expected to fill in order to build the operation. -void ConstantOp::build(mlir::Builder *builder, mlir::OperationState &state, +void ConstantOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, double value) { - auto dataType = RankedTensorType::get({}, builder->getF64Type()); + auto dataType = RankedTensorType::get({}, builder.getF64Type()); auto dataAttribute = DenseElementsAttr::get(dataType, value); ConstantOp::build(builder, state, dataType, dataAttribute); } @@ -208,9 +208,9 @@ //===----------------------------------------------------------------------===// // AddOp -void AddOp::build(mlir::Builder *builder, mlir::OperationState &state, +void AddOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value lhs, mlir::Value rhs) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands({lhs, rhs}); } @@ -228,12 +228,12 @@ //===----------------------------------------------------------------------===// // GenericCallOp -void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState &state, +void GenericCallOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, StringRef callee, ArrayRef arguments) { // Generic call always returns an unranked Tensor initially. - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands(arguments); - state.addAttribute("callee", builder->getSymbolRefAttr(callee)); + state.addAttribute("callee", builder.getSymbolRefAttr(callee)); } /// Return the callee of the generic call operation, this is required by the @@ -249,9 +249,9 @@ //===----------------------------------------------------------------------===// // MulOp -void MulOp::build(mlir::Builder *builder, mlir::OperationState &state, +void MulOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value lhs, mlir::Value rhs) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands({lhs, rhs}); } @@ -300,9 +300,9 @@ //===----------------------------------------------------------------------===// // TransposeOp -void TransposeOp::build(mlir::Builder *builder, mlir::OperationState &state, +void TransposeOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value value) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands(value); } diff --git a/mlir/examples/toy/Ch7/include/toy/Ops.td b/mlir/examples/toy/Ch7/include/toy/Ops.td --- a/mlir/examples/toy/Ch7/include/toy/Ops.td +++ b/mlir/examples/toy/Ch7/include/toy/Ops.td @@ -79,13 +79,13 @@ // using `builder.create(...)`. let builders = [ // Build a constant with a given constant tensor value. - OpBuilder<"Builder *builder, OperationState &state, " + OpBuilder<"OpBuilder &builder, OperationState &state, " "DenseElementsAttr value", [{ build(builder, state, value.getType(), value); }]>, // Build a constant with a given constant floating-point value. - OpBuilder<"Builder *builder, OperationState &state, double value"> + OpBuilder<"OpBuilder &builder, OperationState &state, double value"> ]; // Invoke a static verify method to verify this constant operation. @@ -112,7 +112,7 @@ // Allow building an AddOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value lhs, Value rhs"> + OpBuilder<"OpBuilder &b, OperationState &state, Value lhs, Value rhs"> ]; } @@ -170,7 +170,7 @@ // Add custom build methods for the generic call operation. let builders = [ - OpBuilder<"Builder *builder, OperationState &state, " + OpBuilder<"OpBuilder &builder, OperationState &state, " "StringRef callee, ArrayRef arguments"> ]; } @@ -192,7 +192,7 @@ // Allow building a MulOp with from the two input operands. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value lhs, Value rhs"> + OpBuilder<"OpBuilder &b, OperationState &state, Value lhs, Value rhs"> ]; } @@ -260,7 +260,7 @@ // Allow building a ReturnOp with no return operand. let builders = [OpBuilder< - "Builder *b, OperationState &state", [{ build(b, state, llvm::None); }] + "OpBuilder &b, OperationState &state", [{ build(b, state, llvm::None); }] >]; // Provide extra utility definitions on the c++ operation class definition. @@ -287,7 +287,7 @@ // Allow building a StructAccessOp with just a struct value and an index. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value input, size_t index"> + OpBuilder<"OpBuilder &b, OperationState &state, Value input, size_t index"> ]; let verifier = [{ return ::verify(*this); }]; @@ -335,7 +335,7 @@ // Allow building a TransposeOp with from the input operand. let builders = [ - OpBuilder<"Builder *b, OperationState &state, Value input"> + OpBuilder<"OpBuilder &b, OperationState &state, Value input"> ]; // Invoke a static verify method to verify this transpose operation. diff --git a/mlir/examples/toy/Ch7/mlir/Dialect.cpp b/mlir/examples/toy/Ch7/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch7/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch7/mlir/Dialect.cpp @@ -154,9 +154,9 @@ /// Build a constant operation. /// The builder is passed as an argument, so is the state that this method is /// expected to fill in order to build the operation. -void ConstantOp::build(mlir::Builder *builder, mlir::OperationState &state, +void ConstantOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, double value) { - auto dataType = RankedTensorType::get({}, builder->getF64Type()); + auto dataType = RankedTensorType::get({}, builder.getF64Type()); auto dataAttribute = DenseElementsAttr::get(dataType, value); ConstantOp::build(builder, state, dataType, dataAttribute); } @@ -260,9 +260,9 @@ //===----------------------------------------------------------------------===// // AddOp -void AddOp::build(mlir::Builder *builder, mlir::OperationState &state, +void AddOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value lhs, mlir::Value rhs) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands({lhs, rhs}); } @@ -280,12 +280,12 @@ //===----------------------------------------------------------------------===// // GenericCallOp -void GenericCallOp::build(mlir::Builder *builder, mlir::OperationState &state, +void GenericCallOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, StringRef callee, ArrayRef arguments) { // Generic call always returns an unranked Tensor initially. - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands(arguments); - state.addAttribute("callee", builder->getSymbolRefAttr(callee)); + state.addAttribute("callee", builder.getSymbolRefAttr(callee)); } /// Return the callee of the generic call operation, this is required by the @@ -301,9 +301,9 @@ //===----------------------------------------------------------------------===// // MulOp -void MulOp::build(mlir::Builder *builder, mlir::OperationState &state, +void MulOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value lhs, mlir::Value rhs) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands({lhs, rhs}); } @@ -352,7 +352,7 @@ //===----------------------------------------------------------------------===// // StructAccessOp -void StructAccessOp::build(mlir::Builder *b, mlir::OperationState &state, +void StructAccessOp::build(mlir::OpBuilder &b, mlir::OperationState &state, mlir::Value input, size_t index) { // Extract the result type from the input type. StructType structTy = input.getType().cast(); @@ -360,7 +360,7 @@ mlir::Type resultType = structTy.getElementTypes()[index]; // Call into the auto-generated build method. - build(b, state, resultType, input, b->getI64IntegerAttr(index)); + build(b, state, resultType, input, b.getI64IntegerAttr(index)); } static mlir::LogicalResult verify(StructAccessOp op) { @@ -379,9 +379,9 @@ //===----------------------------------------------------------------------===// // TransposeOp -void TransposeOp::build(mlir::Builder *builder, mlir::OperationState &state, +void TransposeOp::build(mlir::OpBuilder &builder, mlir::OperationState &state, mlir::Value value) { - state.addTypes(UnrankedTensorType::get(builder->getF64Type())); + state.addTypes(UnrankedTensorType::get(builder.getF64Type())); state.addOperands(value); } diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h --- a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h +++ b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.h @@ -82,7 +82,7 @@ public: using Op::Op; - static void build(Builder *builder, OperationState &result, Value srcMemRef, + static void build(OpBuilder &builder, OperationState &result, Value srcMemRef, AffineMap srcMap, ValueRange srcIndices, Value destMemRef, AffineMap dstMap, ValueRange destIndices, Value tagMemRef, AffineMap tagMap, ValueRange tagIndices, Value numElements, @@ -270,7 +270,7 @@ public: using Op::Op; - static void build(Builder *builder, OperationState &result, Value tagMemRef, + static void build(OpBuilder &builder, OperationState &result, Value tagMemRef, AffineMap tagMap, ValueRange tagIndices, Value numElements); static StringRef getOperationName() { return "affine.dma_wait"; } @@ -338,13 +338,13 @@ using Op::Op; /// Builds an affine load op with the specified map and operands. - static void build(Builder *builder, OperationState &result, AffineMap map, + static void build(OpBuilder &builder, OperationState &result, AffineMap map, ValueRange operands); /// Builds an affine load op with an identity map and operands. - static void build(Builder *builder, OperationState &result, Value memref, + static void build(OpBuilder &builder, OperationState &result, Value memref, ValueRange indices = {}); /// Builds an affine load op with the specified map and its operands. - static void build(Builder *builder, OperationState &result, Value memref, + static void build(OpBuilder &builder, OperationState &result, Value memref, AffineMap map, ValueRange mapOperands); /// Returns the operand index of the memref. @@ -407,10 +407,10 @@ using Op::Op; /// Builds an affine store operation with the provided indices (identity map). - static void build(Builder *builder, OperationState &result, + static void build(OpBuilder &builder, OperationState &result, Value valueToStore, Value memref, ValueRange indices); /// Builds an affine store operation with the specified map and its operands. - static void build(Builder *builder, OperationState &result, + static void build(OpBuilder &builder, OperationState &result, Value valueToStore, Value memref, AffineMap map, ValueRange mapOperands); diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td --- a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td +++ b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td @@ -70,9 +70,9 @@ // has a constant builder. That way we wouldn't need to explicitly specify the // result types here. let builders = [ - OpBuilder<"Builder *builder, OperationState &result, " + OpBuilder<"OpBuilder &builder, OperationState &result, " "AffineMap map, ValueRange mapOperands", [{ - build(builder, result, builder->getIndexType(), map, mapOperands); + build(builder, result, builder.getIndexType(), map, mapOperands); }]> ]; @@ -167,9 +167,9 @@ let skipDefaultBuilders = 1; let builders = [ - OpBuilder<"Builder *builder, OperationState &result, " + OpBuilder<"OpBuilder &builder, OperationState &result, " "int64_t lowerBound, int64_t upperBound, int64_t step = 1">, - OpBuilder<"Builder *builder, OperationState &result, " + OpBuilder<"OpBuilder &builder, OperationState &result, " "ValueRange lbOperands, AffineMap lbMap, " "ValueRange ubOperands, AffineMap ubMap, " "int64_t step = 1"> @@ -322,7 +322,7 @@ let skipDefaultBuilders = 1; let builders = [ - OpBuilder<"Builder *builder, OperationState &result, " + OpBuilder<"OpBuilder &builder, OperationState &result, " "IntegerSet set, ValueRange args, bool withElseRegion"> ]; @@ -372,10 +372,10 @@ let results = (outs Index); let builders = [ - OpBuilder<"Builder *builder, OperationState &result, AffineMap affineMap, " + OpBuilder<"OpBuilder &builder, OperationState &result, AffineMap affineMap, " "ValueRange mapOperands", [{ - build(builder, result, builder->getIndexType(), affineMap, mapOperands); + build(builder, result, builder.getIndexType(), affineMap, mapOperands); }]> ]; @@ -469,11 +469,11 @@ let regions = (region SizedRegion<1>:$region); let builders = [ - OpBuilder<"Builder* builder, OperationState& result," + OpBuilder<"OpBuilder &builder, OperationState &result," "ArrayRef ranges">, - OpBuilder<"Builder* builder, OperationState& result, AffineMap lbMap," + OpBuilder<"OpBuilder &builder, OperationState &result, AffineMap lbMap," "ValueRange lbArgs, AffineMap ubMap, ValueRange ubArgs">, - OpBuilder<"Builder* builder, OperationState& result, AffineMap lbMap," + OpBuilder<"OpBuilder &builder, OperationState &result, AffineMap lbMap," "ValueRange lbArgs, AffineMap ubMap, ValueRange ubArgs," "ArrayRef steps"> ]; @@ -531,15 +531,15 @@ BoolAttr:$isDataCache); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value memref," + "OpBuilder &builder, OperationState &result, Value memref," "AffineMap map, ArrayRef mapOperands, bool isWrite," "unsigned localityHint, bool isDataCache", [{ assert(map.getNumInputs() == mapOperands.size() && "inconsistent index info"); - auto localityHintAttr = builder->getI32IntegerAttr(localityHint); - auto isWriteAttr = builder->getBoolAttr(isWrite); - auto isDataCacheAttr = builder->getBoolAttr(isDataCache); + auto localityHintAttr = builder.getI32IntegerAttr(localityHint); + auto isWriteAttr = builder.getBoolAttr(isWrite); + auto isDataCacheAttr = builder.getBoolAttr(isDataCache); result.addOperands(memref); result.addAttribute(getMapAttrName(), AffineMapAttr::get(map)); result.addOperands(mapOperands); diff --git a/mlir/include/mlir/Dialect/GPU/GPUOps.td b/mlir/include/mlir/Dialect/GPU/GPUOps.td --- a/mlir/include/mlir/Dialect/GPU/GPUOps.td +++ b/mlir/include/mlir/Dialect/GPU/GPUOps.td @@ -152,7 +152,7 @@ let skipDefaultBuilders = 1; let builders = [ - OpBuilder<"Builder *builder, OperationState &result, StringRef name, " + OpBuilder<"OpBuilder &builder, OperationState &result, StringRef name, " "FunctionType type, ArrayRef workgroupAttributions = {}, " "ArrayRef privateAttributions = {}, " "ArrayRef attrs = {}"> @@ -323,11 +323,11 @@ let skipDefaultBuilders = 1; let builders = [ - OpBuilder<"Builder *builder, OperationState &result, GPUFuncOp kernelFunc, " + OpBuilder<"OpBuilder &builder, OperationState &result, GPUFuncOp kernelFunc, " "Value gridSizeX, Value gridSizeY, Value gridSizeZ, " "Value blockSizeX, Value blockSizeY, Value blockSizeZ, " "ValueRange kernelOperands">, - OpBuilder<"Builder *builder, OperationState &result, GPUFuncOp kernelFunc, " + OpBuilder<"OpBuilder &builder, OperationState &result, GPUFuncOp kernelFunc, " "KernelDim3 gridSize, KernelDim3 blockSize, " "ValueRange kernelOperands"> ]; @@ -442,7 +442,7 @@ let skipDefaultBuilders = 1; let builders = [ - OpBuilder<"Builder *builder, OperationState &result, Value gridSizeX," + OpBuilder<"OpBuilder &builder, OperationState &result, Value gridSizeX," "Value gridSizeY, Value gridSizeZ, Value blockSizeX," "Value blockSizeY, Value blockSizeZ"> ]; @@ -489,7 +489,7 @@ by an invocation of the `gpu.func`. }]; - let builders = [OpBuilder<"Builder *builder, OperationState &result", " // empty">]; + let builders = [OpBuilder<"OpBuilder &builder, OperationState &result", " // empty">]; let parser = [{ return parseReturnOp(parser, result); }]; let printer = [{ p << getOperationName(); }]; @@ -668,7 +668,7 @@ ``` }]; - let builders = [OpBuilder<"Builder *builder, OperationState &result, " + let builders = [OpBuilder<"OpBuilder &builder, OperationState &result, " "StringRef name">]; let parser = [{ return ::parseGPUModuleOp(parser, result); }]; let printer = [{ return ::print(p, *this); }]; diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -22,7 +22,7 @@ } def LLVM_OneResultOpBuilder : OpBuilder< - "Builder *, OperationState &result, Type resultType, " + "OpBuilder &, OperationState &result, Type resultType, " "ValueRange operands, ArrayRef attributes = {}", [{ if (resultType) result.addTypes(resultType); @@ -33,7 +33,7 @@ }]>; def LLVM_ZeroResultOpBuilder : OpBuilder< - "Builder *, OperationState &result, ValueRange operands, " + "OpBuilder &, OperationState &result, ValueRange operands, " "ArrayRef attributes = {}", [{ result.addOperands(operands); @@ -55,7 +55,7 @@ // Compatibility builder that takes an instance of wrapped llvm::VoidType // to indicate no result. def LLVM_VoidResultTypeOpBuilder : OpBuilder< - "Builder *builder, OperationState &result, Type resultType, " + "OpBuilder &builder, OperationState &result, Type resultType, " "ValueRange operands, ArrayRef attributes = {}", [{ auto llvmType = resultType.dyn_cast(); (void)llvmType; @@ -73,7 +73,7 @@ // Opaque builder used for terminator operations that contain successors. def LLVM_TerminatorPassthroughOpBuilder : OpBuilder< - "Builder *, OperationState &result, ValueRange operands, " + "OpBuilder &, OperationState &result, ValueRange operands, " "SuccessorRange destinations, ArrayRef attributes = {}", [{ result.addOperands(operands); @@ -149,11 +149,11 @@ $res = builder.CreateICmp(getLLVMCmpPredicate($predicate), $lhs, $rhs); }]; let builders = [OpBuilder< - "Builder *b, OperationState &result, ICmpPredicate predicate, Value lhs, " + "OpBuilder &b, OperationState &result, ICmpPredicate predicate, Value lhs, " "Value rhs", [{ LLVMDialect *dialect = &lhs.getType().cast().getDialect(); build(b, result, LLVMType::getInt1Ty(dialect), - b->getI64IntegerAttr(static_cast(predicate)), lhs, rhs); + b.getI64IntegerAttr(static_cast(predicate)), lhs, rhs); }]>]; let parser = [{ return parseCmpOp(parser, result); }]; let printer = [{ printICmpOp(p, *this); }]; @@ -196,11 +196,11 @@ $res = builder.CreateFCmp(getLLVMCmpPredicate($predicate), $lhs, $rhs); }]; let builders = [OpBuilder< - "Builder *b, OperationState &result, FCmpPredicate predicate, Value lhs, " + "OpBuilder &b, OperationState &result, FCmpPredicate predicate, Value lhs, " "Value rhs", [{ LLVMDialect *dialect = &lhs.getType().cast().getDialect(); build(b, result, LLVMType::getInt1Ty(dialect), - b->getI64IntegerAttr(static_cast(predicate)), lhs, rhs); + b.getI64IntegerAttr(static_cast(predicate)), lhs, rhs); }]>]; let parser = [{ return parseCmpOp(parser, result); }]; let printer = [{ printFCmpOp(p, *this); }]; @@ -229,12 +229,12 @@ $res = alloca; }]; let builders = [OpBuilder< - "Builder *b, OperationState &result, Type resultType, Value arraySize, " + "OpBuilder &b, OperationState &result, Type resultType, Value arraySize, " "unsigned alignment", [{ if (alignment == 0) return build(b, result, resultType, arraySize, IntegerAttr()); - build(b, result, resultType, arraySize, b->getI64IntegerAttr(alignment)); + build(b, result, resultType, arraySize, b.getI64IntegerAttr(alignment)); }]>]; let parser = [{ return parseAllocaOp(parser, result); }]; let printer = [{ printAllocaOp(p, *this); }]; @@ -257,7 +257,7 @@ def LLVM_LoadOp : LLVM_OneResultOp<"load">, Arguments<(ins LLVM_Type:$addr)>, LLVM_Builder<"$res = builder.CreateLoad($addr);"> { let builders = [OpBuilder< - "Builder *b, OperationState &result, Value addr", + "OpBuilder &b, OperationState &result, Value addr", [{ auto type = addr.getType().cast().getPointerElementTy(); build(b, result, type, addr); @@ -311,7 +311,7 @@ AnySuccessor:$unwindDest); let builders = [OpBuilder< - "Builder *b, OperationState &result, ArrayRef tys, " + "OpBuilder &b, OperationState &result, ArrayRef tys, " "FlatSymbolRefAttr callee, ValueRange ops, Block* normal, " "ValueRange normalOps, Block* unwind, ValueRange unwindOps", [{ @@ -319,7 +319,7 @@ build(b, result, tys, ops, normal, normalOps, unwind, unwindOps); }]>, OpBuilder< - "Builder *b, OperationState &result, ArrayRef tys, " + "OpBuilder &b, OperationState &result, ArrayRef tys, " "ValueRange ops, Block* normal, " "ValueRange normalOps, Block* unwind, ValueRange unwindOps", [{ @@ -344,13 +344,13 @@ Variadic)>, Results<(outs Variadic)> { let builders = [OpBuilder< - "Builder *builder, OperationState &result, LLVMFuncOp func," + "OpBuilder &builder, OperationState &result, LLVMFuncOp func," "ValueRange operands, ArrayRef attributes = {}", [{ LLVMType resultType = func.getType().getFunctionResultType(); if (!resultType.isVoidTy()) result.addTypes(resultType); - result.addAttribute("callee", builder->getSymbolRefAttr(func)); + result.addAttribute("callee", builder.getSymbolRefAttr(func)); result.addAttributes(attributes); result.addOperands(operands); }]>]; @@ -369,7 +369,7 @@ $res = builder.CreateExtractElement($vector, $position); }]; let builders = [OpBuilder< - "Builder *b, OperationState &result, Value vector, Value position," + "OpBuilder &b, OperationState &result, Value vector, Value position," "ArrayRef attrs = {}">]; let parser = [{ return parseExtractElementOp(parser, result); }]; let printer = [{ printExtractElementOp(p, *this); }]; @@ -400,7 +400,7 @@ extractPosition($position)); }]; let builders = [OpBuilder< - "Builder *b, OperationState &result, Value container, Value value, " + "OpBuilder &b, OperationState &result, Value container, Value value, " "ArrayAttr position", [{ build(b, result, container.getType(), container, value, position); @@ -417,7 +417,7 @@ $res = builder.CreateShuffleVector($v1, $v2, mask); }]; let builders = [OpBuilder< - "Builder *b, OperationState &result, Value v1, Value v2, " + "OpBuilder &b, OperationState &result, Value v1, Value v2, " "ArrayAttr mask, ArrayRef attrs = {}">]; let verifier = [{ auto wrappedVectorType1 = v1().getType().cast(); @@ -442,7 +442,7 @@ LLVM_Builder< "$res = builder.CreateSelect($condition, $trueValue, $falseValue);"> { let builders = [OpBuilder< - "Builder *b, OperationState &result, Value condition, Value lhs, " + "OpBuilder &b, OperationState &result, Value condition, Value lhs, " "Value rhs", [{ build(b, result, lhs.getType(), condition, lhs, rhs); }]>]; @@ -479,13 +479,13 @@ }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value condition," + "OpBuilder &builder, OperationState &result, Value condition," "Block *trueDest, ValueRange trueOperands," "Block *falseDest, ValueRange falseOperands", [{ build(builder, result, condition, trueOperands, falseOperands, trueDest, falseDest); }]>, OpBuilder< - "Builder *builder, OperationState &result, Value condition," + "OpBuilder &builder, OperationState &result, Value condition," "Block *trueDest, Block *falseDest, ValueRange falseOperands = {}", [{ build(builder, result, condition, trueDest, ValueRange(), falseDest, falseOperands); @@ -575,13 +575,13 @@ : LLVM_OneResultOp<"mlir.addressof">, Arguments<(ins FlatSymbolRefAttr:$global_name)> { let builders = [ - OpBuilder<"Builder *builder, OperationState &result, LLVMType resType, " + OpBuilder<"OpBuilder &builder, OperationState &result, LLVMType resType, " "StringRef name, ArrayRef attrs = {}", [{ - result.addAttribute("global_name", builder->getSymbolRefAttr(name)); + result.addAttribute("global_name", builder.getSymbolRefAttr(name)); result.addAttributes(attrs); result.addTypes(resType);}]>, - OpBuilder<"Builder *builder, OperationState &result, GlobalOp global, " + OpBuilder<"OpBuilder &builder, OperationState &result, GlobalOp global, " "ArrayRef attrs = {}", [{ build(builder, result, global.getType().getPointerTo(global.addr_space().getZExtValue()), @@ -628,7 +628,7 @@ let regions = (region AnyRegion:$initializer); let builders = [ - OpBuilder<"Builder *builder, OperationState &result, LLVMType type, " + OpBuilder<"OpBuilder &builder, OperationState &result, LLVMType type, " "bool isConstant, Linkage linkage, StringRef name, " "Attribute value, unsigned addrSpace = 0, " "ArrayRef attrs = {}"> @@ -676,7 +676,7 @@ let skipDefaultBuilders = 1; let builders = [ - OpBuilder<"Builder *builder, OperationState &result, StringRef name, " + OpBuilder<"OpBuilder &builder, OperationState &result, StringRef name, " "LLVMType type, LLVM::Linkage linkage = LLVM::Linkage::External, " "ArrayRef attrs = {}, " "ArrayRef argAttrs = {}"> diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td @@ -48,10 +48,10 @@ ```` }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value min, Value max, " + "OpBuilder &builder, OperationState &result, Value min, Value max, " "Value step", [{ - auto rangeType = RangeType::get(builder->getContext()); + auto rangeType = RangeType::get(builder.getContext()); build(builder, result, rangeType, min, max, step); }]>]; @@ -65,12 +65,12 @@ let builders = [ // Builder for a contracting reshape whose result type is computed from // `src` and `reassociation`. - OpBuilder<"Builder *b, OperationState &result, Value src, " + OpBuilder<"OpBuilder &b, OperationState &result, Value src, " "ArrayRef> reassociation, " "ArrayRef attrs = {}">, // Builder for a reshape whose result type is passed explicitly. This may be // either a contracting or expanding reshape. - OpBuilder<"Builder *b, OperationState &result, Type resultType, Value src," + OpBuilder<"OpBuilder &b, OperationState &result, Type resultType, Value src," "ArrayRef> reassociation, " "ArrayRef attrs = {}">]; @@ -221,7 +221,7 @@ }]; let builders = [OpBuilder< - "Builder *b, OperationState &result, Value base, " + "OpBuilder &b, OperationState &result, Value base, " "ValueRange indexings">]; let extraClassDeclaration = [{ @@ -265,7 +265,7 @@ }]; let builders = [OpBuilder< - "Builder *b, OperationState &result, Value view, " + "OpBuilder &b, OperationState &result, Value view, " "AffineMapAttr permutation, ArrayRef attrs = {}">]; let verifier = [{ diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td @@ -117,7 +117,7 @@ // TODO(ntv) this should go away once the usage of OptionalAttr triggers // emission of builders with default arguments left unspecified. let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value input, Value output", [{ + "OpBuilder &builder, OperationState &result, Value input, Value output", [{ return build( builder, result, input, output, AffineMapAttr(), AffineMapAttr()); }]>]; diff --git a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td b/mlir/include/mlir/Dialect/LoopOps/LoopOps.td --- a/mlir/include/mlir/Dialect/LoopOps/LoopOps.td +++ b/mlir/include/mlir/Dialect/LoopOps/LoopOps.td @@ -135,7 +135,7 @@ let skipDefaultBuilders = 1; let builders = [ - OpBuilder<"Builder *builder, OperationState &result, " + OpBuilder<"OpBuilder &builder, OperationState &result, " "Value lowerBound, Value upperBound, Value step, " "ValueRange iterArgs = llvm::None"> ]; @@ -234,9 +234,9 @@ let skipDefaultBuilders = 1; let builders = [ - OpBuilder<"Builder *builder, OperationState &result, " + OpBuilder<"OpBuilder &builder, OperationState &result, " "Value cond, bool withElseRegion">, - OpBuilder<"Builder *builder, OperationState &result, " + OpBuilder<"OpBuilder &builder, OperationState &result, " "TypeRange resultTypes, Value cond, bool withElseRegion"> ]; @@ -315,7 +315,7 @@ let skipDefaultBuilders = 1; let builders = [ - OpBuilder<"Builder *builder, OperationState &result, " + OpBuilder<"OpBuilder &builder, OperationState &result, " "ValueRange lowerBounds, ValueRange upperBounds, " "ValueRange steps, ValueRange initVals = {}">, ]; @@ -369,7 +369,7 @@ let skipDefaultBuilders = 1; let builders = [ - OpBuilder<"Builder *builder, OperationState &result, " + OpBuilder<"OpBuilder &builder, OperationState &result, " "Value operand"> ]; @@ -411,7 +411,7 @@ let arguments = (ins Variadic:$results); let builders = [ - OpBuilder<"Builder *builder, OperationState &result", + OpBuilder<"OpBuilder &builder, OperationState &result", [{ /* nothing to do */ }]> ]; } diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td @@ -50,7 +50,7 @@ let builders = [ OpBuilder< - [{Builder *builder, OperationState &state, Value pointer, + [{OpBuilder &builder, OperationState &state, Value pointer, ::mlir::spirv::Scope scope, ::mlir::spirv::MemorySemantics memory, Value value}], [{build(builder, state, value.getType(), pointer, scope, memory, value);}] diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVCompositeOps.td @@ -111,7 +111,7 @@ ); let builders = [ - OpBuilder<[{Builder *builder, OperationState &state, + OpBuilder<[{OpBuilder &builder, OperationState &state, Value composite, ArrayRef indices}]> ]; diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td @@ -55,7 +55,7 @@ let builders = [ OpBuilder< - "Builder *, OperationState &state, " + "OpBuilder &, OperationState &state, " "Block *successor, ValueRange arguments = {}", [{ state.addSuccessors(successor); state.addOperands(arguments); @@ -137,7 +137,7 @@ let builders = [ OpBuilder< - "Builder *builder, OperationState &state, Value condition, " + "OpBuilder &builder, OperationState &state, Value condition, " "Block *trueBlock, ValueRange trueArguments, " "Block *falseBlock, ValueRange falseArguments, " "Optional> weights = {}", @@ -145,8 +145,8 @@ ArrayAttr weightsAttr; if (weights) { weightsAttr = - builder->getI32ArrayAttr({static_cast(weights->first), - static_cast(weights->second)}); + builder.getI32ArrayAttr({static_cast(weights->first), + static_cast(weights->second)}); } build(builder, state, condition, trueArguments, falseArguments, weightsAttr, trueBlock, falseBlock); @@ -290,7 +290,7 @@ let regions = (region AnyRegion:$body); - let builders = [OpBuilder<"Builder *builder, OperationState &state">]; + let builders = [OpBuilder<"OpBuilder &builder, OperationState &state">]; let extraClassDeclaration = [{ // Returns the entry block. @@ -465,8 +465,8 @@ /// newly inserted spv.selection op afterwards. static SelectionOp createIfThen( Location loc, Value condition, - function_ref thenBody, - OpBuilder *builder); + function_ref thenBody, + OpBuilder &builder); }]; let hasOpcode = 0; diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVLogicalOps.td @@ -854,7 +854,7 @@ SPV_SelectType:$result ); - let builders = [OpBuilder<[{Builder *builder, OperationState &state, + let builders = [OpBuilder<[{OpBuilder &builder, OperationState &state, Value cond, Value trueValue, Value falseValue}]>]; diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVNonUniformOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVNonUniformOps.td --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVNonUniformOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVNonUniformOps.td @@ -147,7 +147,7 @@ ); let builders = [ - OpBuilder<[{Builder *builder, OperationState &state, spirv::Scope}]> + OpBuilder<[{OpBuilder &builder, OperationState &state, spirv::Scope}]> ]; let assemblyFormat = "$execution_scope attr-dict `:` type($result)"; diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVOps.td @@ -93,7 +93,7 @@ SPV_AnyPtr:$component_ptr ); - let builders = [OpBuilder<[{Builder *builder, OperationState &state, + let builders = [OpBuilder<[{OpBuilder &builder, OperationState &state, Value basePtr, ValueRange indices}]>]; let hasCanonicalizer = 1; @@ -214,7 +214,7 @@ let autogenSerialization = 0; - let builders = [OpBuilder<[{Builder *builder, OperationState &state, + let builders = [OpBuilder<[{OpBuilder &builder, OperationState &state, spirv::FuncOp function, spirv::ExecutionMode executionMode, ArrayRef params}]>]; @@ -269,7 +269,7 @@ let builders = [ OpBuilder<[{ - Builder *builder, OperationState &state, + OpBuilder &builder, OperationState &state, Value basePtr, IntegerAttr memory_access = {}, IntegerAttr alignment = {} }]> @@ -371,7 +371,7 @@ let results = (outs); let builders = [ - OpBuilder<"Builder *builder, OperationState &state, " + OpBuilder<"OpBuilder &builder, OperationState &state, " "Value ptr, Value value, ArrayRef namedAttrs = {}", [{ state.addOperands(ptr); state.addOperands(value); diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td --- a/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVStructureOps.td @@ -59,7 +59,7 @@ let autogenSerialization = 0; - let builders = [OpBuilder<[{Builder *builder, OperationState &state, + let builders = [OpBuilder<[{OpBuilder &builder, OperationState &state, spirv::GlobalVariableOp var}]>]; let assemblyFormat = "$variable attr-dict `:` type($pointer)"; @@ -121,9 +121,9 @@ // Creates a constant zero/one of the given `type` at the current insertion // point of `builder` and returns it. static spirv::ConstantOp getZero(Type type, Location loc, - OpBuilder *builder); + OpBuilder &builder); static spirv::ConstantOp getOne(Type type, Location loc, - OpBuilder *builder); + OpBuilder &builder); }]; let hasOpcode = 0; @@ -188,7 +188,7 @@ let autogenSerialization = 0; - let builders = [OpBuilder<[{Builder *builder, OperationState &state, + let builders = [OpBuilder<[{OpBuilder &builder, OperationState &state, spirv::ExecutionModel executionModel, spirv::FuncOp function, ArrayRef interfaceVars}]>]; @@ -243,7 +243,7 @@ let verifier = [{ return success(); }]; let builders = [OpBuilder<[{ - Builder *, OperationState &state, + OpBuilder &, OperationState &state, StringRef name, FunctionType type, spirv::FunctionControl control = spirv::FunctionControl::None, ArrayRef attrs = {} @@ -332,15 +332,15 @@ let results = (outs); let builders = [ - OpBuilder<"Builder *builder, OperationState &state, " + OpBuilder<"OpBuilder &builder, OperationState &state, " "TypeAttr type, ArrayRef namedAttrs", [{ state.addAttribute("type", type); state.addAttributes(namedAttrs); }]>, - OpBuilder<[{Builder *builder, OperationState &state, + OpBuilder<[{OpBuilder &builder, OperationState &state, Type type, StringRef name, unsigned descriptorSet, unsigned binding}]>, - OpBuilder<[{Builder *builder, OperationState &state, + OpBuilder<[{OpBuilder &builder, OperationState &state, Type type, StringRef name, spirv::BuiltIn builtin}]> ]; @@ -416,8 +416,8 @@ let regions = (region SizedRegion<1>:$body); let builders = [ - OpBuilder<[{Builder *, OperationState &state}]>, - OpBuilder<[{Builder *, OperationState &state, + OpBuilder<[{OpBuilder &, OperationState &state}]>, + OpBuilder<[{OpBuilder &, OperationState &state, spirv::AddressingModel addressing_model, spirv::MemoryModel memory_model}]> ]; diff --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td --- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td +++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td @@ -299,7 +299,7 @@ let arguments = (ins Variadic:$operands); let builders = [OpBuilder< - "Builder *b, OperationState &result", [{ build(b, result, llvm::None); }] + "OpBuilder &b, OperationState &result", [{ build(b, result, llvm::None); }] >]; let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?"; diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h @@ -46,7 +46,7 @@ using ConstantOp::ConstantOp; /// Builds a constant float op producing a float of the specified type. - static void build(Builder *builder, OperationState &result, + static void build(OpBuilder &builder, OperationState &result, const APFloat &value, FloatType type); APFloat getValue() { return getAttrOfType("value").getValue(); } @@ -63,12 +63,12 @@ public: using ConstantOp::ConstantOp; /// Build a constant int op producing an integer of the specified width. - static void build(Builder *builder, OperationState &result, int64_t value, + static void build(OpBuilder &builder, OperationState &result, int64_t value, unsigned width); /// Build a constant int op producing an integer with the specified type, /// which must be an integer type. - static void build(Builder *builder, OperationState &result, int64_t value, + static void build(OpBuilder &builder, OperationState &result, int64_t value, Type type); int64_t getValue() { return getAttrOfType("value").getInt(); } @@ -86,7 +86,7 @@ using ConstantOp::ConstantOp; /// Build a constant int op producing an index. - static void build(Builder *builder, OperationState &result, int64_t value); + static void build(OpBuilder &builder, OperationState &result, int64_t value); int64_t getValue() { return getAttrOfType("value").getInt(); } @@ -135,7 +135,7 @@ public: using Op::Op; - static void build(Builder *builder, OperationState &result, Value srcMemRef, + static void build(OpBuilder &builder, OperationState &result, Value srcMemRef, ValueRange srcIndices, Value destMemRef, ValueRange destIndices, Value numElements, Value tagMemRef, ValueRange tagIndices, Value stride = nullptr, @@ -259,7 +259,7 @@ public: using Op::Op; - static void build(Builder *builder, OperationState &result, Value tagMemRef, + static void build(OpBuilder &builder, OperationState &result, Value tagMemRef, ValueRange tagIndices, Value numElements); static StringRef getOperationName() { return "std.dma_wait"; } diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td @@ -46,7 +46,7 @@ let results = (outs AnyType); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value source, Type destType", [{ + "OpBuilder &builder, OperationState &result, Value source, Type destType", [{ impl::buildCastOp(builder, result, source, destType); }]>]; @@ -136,11 +136,11 @@ let results = (outs AnyMemRef); let builders = [OpBuilder< - "Builder *builder, OperationState &result, MemRefType memrefType", [{ + "OpBuilder &builder, OperationState &result, MemRefType memrefType", [{ result.types.push_back(memrefType); }]>, OpBuilder< - "Builder *builder, OperationState &result, MemRefType memrefType, " # + "OpBuilder &builder, OperationState &result, MemRefType memrefType, " # "ValueRange operands, IntegerAttr alignment = IntegerAttr()", [{ result.addOperands(operands); result.types.push_back(memrefType); @@ -525,7 +525,7 @@ let skipDefaultBuilders = 1; let builders = [ - OpBuilder<"Builder *builder, OperationState &result, " + OpBuilder<"OpBuilder &builder, OperationState &result, " "Value memref, ValueRange ivs"> ]; @@ -585,7 +585,7 @@ let arguments = (ins Variadic:$destOperands); let successors = (successor AnySuccessor:$dest); - let builders = [OpBuilder<"Builder *, OperationState &result, Block *dest, " + let builders = [OpBuilder<"OpBuilder &, OperationState &result, Block *dest, " "ValueRange destOperands = {}", [{ result.addSuccessors(dest); result.addOperands(destOperands); @@ -635,21 +635,21 @@ let results = (outs Variadic); let builders = [OpBuilder< - "Builder *builder, OperationState &result, FuncOp callee," + "OpBuilder &builder, OperationState &result, FuncOp callee," "ValueRange operands = {}", [{ result.addOperands(operands); - result.addAttribute("callee", builder->getSymbolRefAttr(callee)); + result.addAttribute("callee", builder.getSymbolRefAttr(callee)); result.addTypes(callee.getType().getResults()); }]>, OpBuilder< - "Builder *builder, OperationState &result, SymbolRefAttr callee," + "OpBuilder &builder, OperationState &result, SymbolRefAttr callee," "ArrayRef results, ValueRange operands = {}", [{ result.addOperands(operands); result.addAttribute("callee", callee); result.addTypes(results); }]>, OpBuilder< - "Builder *builder, OperationState &result, StringRef callee," + "OpBuilder &builder, OperationState &result, StringRef callee," "ArrayRef results, ValueRange operands = {}", [{ - build(builder, result, builder->getSymbolRefAttr(callee), results, + build(builder, result, builder.getSymbolRefAttr(callee), results, operands); }]>]; @@ -711,7 +711,7 @@ let results = (outs Variadic:$results); let builders = [OpBuilder< - "Builder *, OperationState &result, Value callee," + "OpBuilder &, OperationState &result, Value callee," "ValueRange operands = {}", [{ result.operands.push_back(callee); result.addOperands(operands); @@ -844,7 +844,7 @@ let results = (outs BoolLike:$result); let builders = [OpBuilder< - "Builder *builder, OperationState &result, CmpFPredicate predicate," + "OpBuilder &builder, OperationState &result, CmpFPredicate predicate," "Value lhs, Value rhs", [{ ::buildCmpFOp(builder, result, predicate, lhs, rhs); }]>]; @@ -966,7 +966,7 @@ let results = (outs BoolLike:$result); let builders = [OpBuilder< - "Builder *builder, OperationState &result, CmpIPredicate predicate," + "OpBuilder &builder, OperationState &result, CmpIPredicate predicate," "Value lhs, Value rhs", [{ ::buildCmpIOp(builder, result, predicate, lhs, rhs); }]>]; @@ -1029,13 +1029,13 @@ let successors = (successor AnySuccessor:$trueDest, AnySuccessor:$falseDest); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value condition," + "OpBuilder &builder, OperationState &result, Value condition," "Block *trueDest, ValueRange trueOperands," "Block *falseDest, ValueRange falseOperands", [{ build(builder, result, condition, trueOperands, falseOperands, trueDest, falseDest); }]>, OpBuilder< - "Builder *builder, OperationState &result, Value condition," + "OpBuilder &builder, OperationState &result, Value condition," "Block *trueDest, Block *falseDest, ValueRange falseOperands = {}", [{ build(builder, result, condition, trueDest, ValueRange(), falseDest, falseOperands); @@ -1167,7 +1167,7 @@ let results = (outs AnyType); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Attribute value", + "OpBuilder &builder, OperationState &result, Attribute value", [{ build(builder, result, value.getType(), value); }]>]; let extraClassDeclaration = [{ @@ -1316,10 +1316,10 @@ let results = (outs Index); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value memrefOrTensor," + "OpBuilder &builder, OperationState &result, Value memrefOrTensor," "unsigned index", [{ - auto indexType = builder->getIndexType(); - auto indexAttr = builder->getIntegerAttr(indexType, index); + auto indexType = builder.getIndexType(); + auto indexAttr = builder.getIntegerAttr(indexType, index); build(builder, result, indexType, memrefOrTensor, indexAttr); }]>]; @@ -1412,7 +1412,7 @@ let results = (outs AnyType:$result); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value aggregate," + "OpBuilder &builder, OperationState &result, Value aggregate," "ValueRange indices = {}", [{ auto resType = aggregate.getType().cast() .getElementType(); @@ -1550,7 +1550,7 @@ let results = (outs AnyType:$result); let builders = [OpBuilder< - "Builder *, OperationState &result, Value memref," + "OpBuilder &, OperationState &result, Value memref," "ValueRange indices = {}", [{ auto memrefType = memref.getType().cast(); result.addOperands(memref); @@ -1802,12 +1802,12 @@ BoolAttr:$isDataCache); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value memref," + "OpBuilder &builder, OperationState &result, Value memref," "ArrayRef indices, bool isWrite, unsigned hint, bool isData", [{ - auto hintAttr = builder->getI32IntegerAttr(hint); - auto isWriteAttr = builder->getBoolAttr(isWrite); - auto isDataCacheAttr = builder->getBoolAttr(isData); + auto hintAttr = builder.getI32IntegerAttr(hint); + auto isWriteAttr = builder.getBoolAttr(isWrite); + auto isDataCacheAttr = builder.getBoolAttr(isData); result.addOperands(memref); result.addOperands(indices); result.addAttribute("localityHint", hintAttr); @@ -1848,8 +1848,8 @@ let verifier = ?; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value tensor", [{ - auto indexType = builder->getIndexType(); + "OpBuilder &builder, OperationState &result, Value tensor", [{ + auto indexType = builder.getIndexType(); build(builder, result, indexType, tensor); }]>]; @@ -1891,7 +1891,7 @@ let arguments = (ins Variadic:$operands); let builders = [OpBuilder< - "Builder *b, OperationState &result", [{ build(b, result, llvm::None); }] + "OpBuilder &b, OperationState &result", [{ build(b, result, llvm::None); }] >]; let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?"; @@ -1956,7 +1956,7 @@ let results = (outs AnyType:$result); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value condition," + "OpBuilder &builder, OperationState &result, Value condition," "Value trueValue, Value falseValue", [{ result.addOperands({condition, trueValue, falseValue}); result.addTypes(trueValue.getType()); @@ -2115,7 +2115,7 @@ let results = (outs SignlessIntegerLike); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value value, Type destType", [{ + "OpBuilder &builder, OperationState &result, Value value, Type destType", [{ result.addOperands(value); result.addTypes(destType); }]>]; @@ -2189,7 +2189,7 @@ let results = (outs AnyTypeOf<[AnyVector, AnyStaticShapeTensor]>:$aggregate); let builders = - [OpBuilder<"Builder *builder, OperationState &result, Value element, " + [OpBuilder<"OpBuilder &builder, OperationState &result, Value element, " "Type aggregateType", [{ build(builder, result, aggregateType, element); }]>]; @@ -2267,7 +2267,7 @@ Variadic:$indices); let builders = [OpBuilder< - "Builder *, OperationState &result, Value valueToStore, Value memref", [{ + "OpBuilder &, OperationState &result, Value valueToStore, Value memref", [{ result.addOperands(valueToStore); result.addOperands(memref); }]>]; @@ -2443,12 +2443,12 @@ let builders = [ OpBuilder< - "Builder *b, OperationState &result, Value source, " + "OpBuilder &b, OperationState &result, Value source, " "ValueRange offsets, ValueRange sizes, " "ValueRange strides, Type resultType = Type(), " "ArrayRef attrs = {}">, OpBuilder< - "Builder *builder, OperationState &result, " + "OpBuilder &builder, OperationState &result, " "Type resultType, Value source"> ]; @@ -2601,7 +2601,7 @@ let verifier = ?; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value memref", [{ + "OpBuilder &builder, OperationState &result, Value memref", [{ auto memrefType = memref.getType().cast(); auto resultType = RankedTensorType::get(memrefType.getShape(), memrefType.getElementType()); @@ -2677,7 +2677,7 @@ let results = (outs SignlessIntegerLike); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value value, Type destType", [{ + "OpBuilder &builder, OperationState &result, Value value, Type destType", [{ result.addOperands(value); result.addTypes(destType); }]>]; @@ -2907,7 +2907,7 @@ let results = (outs SignlessIntegerLike); let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value value, Type destType", [{ + "OpBuilder &builder, OperationState &result, Value value, Type destType", [{ result.addOperands(value); result.addTypes(destType); }]>]; diff --git a/mlir/include/mlir/Dialect/Vector/VectorOps.td b/mlir/include/mlir/Dialect/Vector/VectorOps.td --- a/mlir/include/mlir/Dialect/Vector/VectorOps.td +++ b/mlir/include/mlir/Dialect/Vector/VectorOps.td @@ -143,10 +143,10 @@ ``` }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value lhs, Value rhs, " + "OpBuilder &builder, OperationState &result, Value lhs, Value rhs, " "Value acc, ArrayAttr indexingMaps, ArrayAttr iteratorTypes">, OpBuilder< - "Builder *builder, OperationState &result, Value lhs, Value rhs, " + "OpBuilder &builder, OperationState &result, Value lhs, Value rhs, " "Value acc, ArrayRef> indexingExprs, " "ArrayRef iteratorTypes">]; let extraClassDeclaration = [{ @@ -304,7 +304,7 @@ : vector<2xf32>, vector<2xf32> ; yields vector<4xf32> ``` }]; - let builders = [OpBuilder<"Builder *builder, OperationState &result," + let builders = [OpBuilder<"OpBuilder &builder, OperationState &result," "Value v1, Value v2, ArrayRef">]; let extraClassDeclaration = [{ static StringRef getMaskAttrName() { return "mask"; } @@ -372,7 +372,7 @@ ``` }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value source," + "OpBuilder &builder, OperationState &result, Value source," "ArrayRef">]; let extraClassDeclaration = [{ static StringRef getPositionAttrName() { return "position"; } @@ -418,7 +418,7 @@ ``` }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, TupleType tupleType, " # + "OpBuilder &builder, OperationState &result, TupleType tupleType, " # "Value vector, ArrayRef sizes, " # "ArrayRef strides">]; let extraClassDeclaration = [{ @@ -464,7 +464,7 @@ let verifier = ?; let assemblyFormat = "$lhs `,` $rhs `,` $acc attr-dict `:` type($lhs)"; let builders = [OpBuilder< - "Builder *b, OperationState &result, Value lhs, Value rhs, Value acc", + "OpBuilder &b, OperationState &result, Value lhs, Value rhs, Value acc", "build(b, result, lhs.getType(), lhs, rhs, acc);">]; let extraClassDeclaration = [{ VectorType getVectorType() { return lhs().getType().cast(); } @@ -535,7 +535,7 @@ }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value source, " # + "OpBuilder &builder, OperationState &result, Value source, " # "Value dest, ArrayRef">]; let extraClassDeclaration = [{ static StringRef getPositionAttrName() { return "position"; } @@ -638,7 +638,7 @@ }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value source, Value dest, " # + "OpBuilder &builder, OperationState &result, Value source, Value dest, " # "ArrayRef offsets, ArrayRef strides">]; let extraClassDeclaration = [{ static StringRef getOffsetsAttrName() { return "offsets"; } @@ -849,7 +849,7 @@ ``` }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value source, " # + "OpBuilder &builder, OperationState &result, Value source, " # "ArrayRef offsets, ArrayRef sizes, " # "ArrayRef strides">]; let extraClassDeclaration = [{ @@ -1155,7 +1155,7 @@ }]; let builders = [OpBuilder< - "Builder *builder, OperationState &result, Value source">]; + "OpBuilder &builder, OperationState &result, Value source">]; let parser = [{ return impl::parseCastOp(parser, result); @@ -1439,13 +1439,13 @@ ``` }]; let builders = [ - OpBuilder<"Builder *builder, OperationState &result, Value lhs, Value rhs, " + OpBuilder<"OpBuilder &builder, OperationState &result, Value lhs, Value rhs, " "unsigned lhsRows, unsigned lhsColumns, unsigned rhsColumns", [{ result.addOperands({lhs, rhs}); - result.addAttribute("lhs_rows", builder->getI32IntegerAttr(lhsRows)); - result.addAttribute("lhs_columns", builder->getI32IntegerAttr(lhsColumns)); - result.addAttribute("rhs_columns", builder->getI32IntegerAttr(rhsColumns)); + result.addAttribute("lhs_rows", builder.getI32IntegerAttr(lhsRows)); + result.addAttribute("lhs_columns", builder.getI32IntegerAttr(lhsColumns)); + result.addAttribute("rhs_columns", builder.getI32IntegerAttr(rhsColumns)); result.addTypes(VectorType::get(lhsRows * rhsColumns, lhs.getType().cast().getElementType())); }]>, diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h --- a/mlir/include/mlir/IR/Builders.h +++ b/mlir/include/mlir/IR/Builders.h @@ -319,7 +319,7 @@ template OpTy create(Location location, Args &&... args) { OperationState state(location, OpTy::getOperationName()); - OpTy::build(this, state, std::forward(args)...); + OpTy::build(*this, state, std::forward(args)...); auto *op = createOperation(state); auto result = dyn_cast(op); assert(result && "Builder didn't return the right type"); @@ -335,7 +335,7 @@ // Create the operation without using 'createOperation' as we don't want to // insert it yet. OperationState state(location, OpTy::getOperationName()); - OpTy::build(this, state, std::forward(args)...); + OpTy::build(*this, state, std::forward(args)...); Operation *op = Operation::create(state); // Fold the operation. If successful destroy it, otherwise insert it. diff --git a/mlir/include/mlir/IR/Function.h b/mlir/include/mlir/IR/Function.h --- a/mlir/include/mlir/IR/Function.h +++ b/mlir/include/mlir/IR/Function.h @@ -49,9 +49,9 @@ ArrayRef attrs, ArrayRef argAttrs); - static void build(Builder *builder, OperationState &result, StringRef name, + static void build(OpBuilder &builder, OperationState &result, StringRef name, FunctionType type, ArrayRef attrs); - static void build(Builder *builder, OperationState &result, StringRef name, + static void build(OpBuilder &builder, OperationState &result, StringRef name, FunctionType type, ArrayRef attrs, ArrayRef argAttrs); diff --git a/mlir/include/mlir/IR/Module.h b/mlir/include/mlir/IR/Module.h --- a/mlir/include/mlir/IR/Module.h +++ b/mlir/include/mlir/IR/Module.h @@ -38,7 +38,7 @@ static StringRef getOperationName() { return "module"; } - static void build(Builder *builder, OperationState &result, + static void build(OpBuilder &builder, OperationState &result, Optional name = llvm::None); /// Construct a module from the given location with an optional name. @@ -109,7 +109,7 @@ public: using Op::Op; static StringRef getOperationName() { return "module_terminator"; } - static void build(Builder *, OperationState &) {} + static void build(OpBuilder &, OperationState &) {} }; /// This class acts as an owning reference to a module, and will automatically diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -1797,7 +1797,7 @@ // The signature of the builder is always // // ```c++ -// static void build(Builder *builder, OperationState &state, +// static void build(OpBuilder &builder, OperationState &state, // ...) { // ... // } @@ -1877,7 +1877,7 @@ // following signatures: // // ```c++ - // static void build(Builder *, OperationState &odsState, + // static void build(OpBuilder &, OperationState &odsState, // Type , Type , ..., // Value , Value , ..., // Attribute , Attribute , ...); @@ -1885,7 +1885,7 @@ // * where the attributes follow the same declaration order as in the op. // // ```c++ - // static void build(Builder *, OperationState &odsState, + // static void build(OpBuilder &, OperationState &odsState, // ArrayRef resultTypes, // ArrayRef operands, // ArrayRef attributes); diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -25,6 +25,7 @@ namespace mlir { class Builder; +class OpBuilder; namespace OpTrait { template class OneResult; @@ -77,14 +78,15 @@ /// region's only block if it does not have a terminator already. If the region /// is empty, insert a new block first. `buildTerminatorOp` should return the /// terminator operation to insert. -void ensureRegionTerminator(Region ®ion, Location loc, - function_ref buildTerminatorOp); +void ensureRegionTerminator( + Region ®ion, Location loc, + function_ref buildTerminatorOp); /// Templated version that fills the generates the provided operation type. template void ensureRegionTerminator(Region ®ion, Builder &builder, Location loc) { - ensureRegionTerminator(region, loc, [&] { + ensureRegionTerminator(region, loc, [&](OpBuilder &b) { OperationState state(loc, OpTy::getOperationName()); - OpTy::build(&builder, state); + OpTy::build(b, state); return Operation::create(state); }); } @@ -1415,7 +1417,7 @@ ParseResult parseOneResultOneOperandTypeOp(OpAsmParser &parser, OperationState &result); -void buildBinaryOp(Builder *builder, OperationState &result, Value lhs, +void buildBinaryOp(OpBuilder &builder, OperationState &result, Value lhs, Value rhs); ParseResult parseOneResultSameOperandTypeOp(OpAsmParser &parser, OperationState &result); @@ -1429,7 +1431,7 @@ // These functions are out-of-line implementations of the methods in CastOp, // which avoids them being template instantiated/duplicated. namespace impl { -void buildCastOp(Builder *builder, OperationState &result, Value source, +void buildCastOp(OpBuilder &builder, OperationState &result, Value source, Type destType); ParseResult parseCastOp(OpAsmParser &parser, OperationState &result); void printCastOp(Operation *op, OpAsmPrinter &p); diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -218,7 +218,7 @@ template OpTy create(Location location, Args... args) { OperationState state(location, OpTy::getOperationName()); - OpTy::build(this, state, args...); + OpTy::build(*this, state, args...); auto *op = createOperation(state); auto result = dyn_cast(op); assert(result && "Builder didn't return the right type"); @@ -231,7 +231,7 @@ template OpTy createChecked(Location location, Args... args) { OperationState state(location, OpTy::getOperationName()); - OpTy::build(this, state, args...); + OpTy::build(*this, state, args...); auto *op = createOperation(state); // If the Operation we produce is valid, return it. diff --git a/mlir/include/mlir/Transforms/FoldUtils.h b/mlir/include/mlir/Transforms/FoldUtils.h --- a/mlir/include/mlir/Transforms/FoldUtils.h +++ b/mlir/include/mlir/Transforms/FoldUtils.h @@ -81,7 +81,7 @@ // fold). Using create methods of the builder will insert the op, so not // using it here. OperationState state(location, OpTy::getOperationName()); - OpTy::build(&builder, state, std::forward(args)...); + OpTy::build(builder, state, std::forward(args)...); Operation *op = Operation::create(state); if (failed(tryToFold(builder, op, results)) || op->getNumResults() == 0) { diff --git a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp --- a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp +++ b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp @@ -164,7 +164,7 @@ // Get the output element accessed by this reduction. Value zero = spirv::ConstantOp::getZero( - typeConverter.getIndexType(rewriter.getContext()), loc, &rewriter); + typeConverter.getIndexType(rewriter.getContext()), loc, rewriter); SmallVector zeroIndices(originalOutputType.getRank(), zero); Value outputElementPtr = spirv::getElementPtr(typeConverter, originalOutputType, convertedOutput, @@ -181,18 +181,18 @@ Value condition = rewriter.create( loc, spirv::Scope::Subgroup); - auto createAtomicOp = [&](OpBuilder *builder) { + auto createAtomicOp = [&](OpBuilder &builder) { #define CREATE_ATOMIC_BIN_OP(opKind, spvOp) \ case linalg::RegionMatcher::BinaryOpKind::opKind: { \ - builder->create(loc, outputElementPtr, spirv::Scope::Device, \ - spirv::MemorySemantics::AcquireRelease, \ - groupOperation); \ + builder.create(loc, outputElementPtr, spirv::Scope::Device, \ + spirv::MemorySemantics::AcquireRelease, \ + groupOperation); \ } break switch (*binaryOpKind) { CREATE_ATOMIC_BIN_OP(IAdd, AtomicIAddOp); } #undef CREATE_ATOMIC_BIN_OP }; - spirv::SelectionOp::createIfThen(loc, condition, createAtomicOp, &rewriter); + spirv::SelectionOp::createIfThen(loc, condition, createAtomicOp, rewriter); rewriter.eraseOp(genericOp); return success(); diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp --- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp +++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp @@ -811,7 +811,7 @@ //===----------------------------------------------------------------------===// // TODO(b/133776335) Check that map operands are loop IVs or symbols. -void AffineDmaStartOp::build(Builder *builder, OperationState &result, +void AffineDmaStartOp::build(OpBuilder &builder, OperationState &result, Value srcMemRef, AffineMap srcMap, ValueRange srcIndices, Value destMemRef, AffineMap dstMap, ValueRange destIndices, @@ -980,7 +980,7 @@ //===----------------------------------------------------------------------===// // TODO(b/133776335) Check that map operands are loop IVs or symbols. -void AffineDmaWaitOp::build(Builder *builder, OperationState &result, +void AffineDmaWaitOp::build(OpBuilder &builder, OperationState &result, Value tagMemRef, AffineMap tagMap, ValueRange tagIndices, Value numElements) { result.addOperands(tagMemRef); @@ -1055,7 +1055,7 @@ // AffineForOp //===----------------------------------------------------------------------===// -void AffineForOp::build(Builder *builder, OperationState &result, +void AffineForOp::build(OpBuilder &builder, OperationState &result, ValueRange lbOperands, AffineMap lbMap, ValueRange ubOperands, AffineMap ubMap, int64_t step) { assert(((!lbMap && lbOperands.empty()) || @@ -1068,7 +1068,7 @@ // Add an attribute for the step. result.addAttribute(getStepAttrName(), - builder->getIntegerAttr(builder->getIndexType(), step)); + builder.getIntegerAttr(builder.getIndexType(), step)); // Add the lower bound. result.addAttribute(getLowerBoundAttrName(), AffineMapAttr::get(lbMap)); @@ -1082,18 +1082,18 @@ // the loop induction variable. Region *bodyRegion = result.addRegion(); Block *body = new Block(); - body->addArgument(IndexType::get(builder->getContext())); + body->addArgument(IndexType::get(builder.getContext())); bodyRegion->push_back(body); - ensureTerminator(*bodyRegion, *builder, result.location); + ensureTerminator(*bodyRegion, builder, result.location); // Set the operands list as resizable so that we can freely modify the bounds. result.setOperandListToResizable(); } -void AffineForOp::build(Builder *builder, OperationState &result, int64_t lb, +void AffineForOp::build(OpBuilder &builder, OperationState &result, int64_t lb, int64_t ub, int64_t step) { - auto lbMap = AffineMap::getConstantMap(lb, builder->getContext()); - auto ubMap = AffineMap::getConstantMap(ub, builder->getContext()); + auto lbMap = AffineMap::getConstantMap(lb, builder.getContext()); + auto ubMap = AffineMap::getConstantMap(ub, builder.getContext()); return build(builder, result, {}, lbMap, {}, ubMap, step); } @@ -1703,15 +1703,15 @@ getOperation()->setOperands(operands); } -void AffineIfOp::build(Builder *builder, OperationState &result, IntegerSet set, - ValueRange args, bool withElseRegion) { +void AffineIfOp::build(OpBuilder &builder, OperationState &result, + IntegerSet set, ValueRange args, bool withElseRegion) { result.addOperands(args); result.addAttribute(getConditionAttrName(), IntegerSetAttr::get(set)); Region *thenRegion = result.addRegion(); Region *elseRegion = result.addRegion(); - AffineIfOp::ensureTerminator(*thenRegion, *builder, result.location); + AffineIfOp::ensureTerminator(*thenRegion, builder, result.location); if (withElseRegion) - AffineIfOp::ensureTerminator(*elseRegion, *builder, result.location); + AffineIfOp::ensureTerminator(*elseRegion, builder, result.location); } /// Canonicalize an affine if op's conditional (integer set + operands). @@ -1742,7 +1742,7 @@ // AffineLoadOp //===----------------------------------------------------------------------===// -void AffineLoadOp::build(Builder *builder, OperationState &result, +void AffineLoadOp::build(OpBuilder &builder, OperationState &result, AffineMap map, ValueRange operands) { assert(operands.size() == 1 + map.getNumInputs() && "inconsistent operands"); result.addOperands(operands); @@ -1752,8 +1752,8 @@ result.types.push_back(memrefType.getElementType()); } -void AffineLoadOp::build(Builder *builder, OperationState &result, Value memref, - AffineMap map, ValueRange mapOperands) { +void AffineLoadOp::build(OpBuilder &builder, OperationState &result, + Value memref, AffineMap map, ValueRange mapOperands) { assert(map.getNumInputs() == mapOperands.size() && "inconsistent index info"); result.addOperands(memref); result.addOperands(mapOperands); @@ -1762,14 +1762,14 @@ result.types.push_back(memrefType.getElementType()); } -void AffineLoadOp::build(Builder *builder, OperationState &result, Value memref, - ValueRange indices) { +void AffineLoadOp::build(OpBuilder &builder, OperationState &result, + Value memref, ValueRange indices) { auto memrefType = memref.getType().cast(); auto rank = memrefType.getRank(); // Create identity map for memrefs with at least one dimension or () -> () // for zero-dimensional memrefs. - auto map = rank ? builder->getMultiDimIdentityMap(rank) - : builder->getEmptyAffineMap(); + auto map = + rank ? builder.getMultiDimIdentityMap(rank) : builder.getEmptyAffineMap(); build(builder, result, memref, map, indices); } @@ -1844,7 +1844,7 @@ // AffineStoreOp //===----------------------------------------------------------------------===// -void AffineStoreOp::build(Builder *builder, OperationState &result, +void AffineStoreOp::build(OpBuilder &builder, OperationState &result, Value valueToStore, Value memref, AffineMap map, ValueRange mapOperands) { assert(map.getNumInputs() == mapOperands.size() && "inconsistent index info"); @@ -1855,15 +1855,15 @@ } // Use identity map. -void AffineStoreOp::build(Builder *builder, OperationState &result, +void AffineStoreOp::build(OpBuilder &builder, OperationState &result, Value valueToStore, Value memref, ValueRange indices) { auto memrefType = memref.getType().cast(); auto rank = memrefType.getRank(); // Create identity map for memrefs with at least one dimension or () -> () // for zero-dimensional memrefs. - auto map = rank ? builder->getMultiDimIdentityMap(rank) - : builder->getEmptyAffineMap(); + auto map = + rank ? builder.getMultiDimIdentityMap(rank) : builder.getEmptyAffineMap(); build(builder, result, valueToStore, memref, map, indices); } @@ -2162,19 +2162,19 @@ // AffineParallelOp //===----------------------------------------------------------------------===// -void AffineParallelOp::build(Builder *builder, OperationState &result, +void AffineParallelOp::build(OpBuilder &builder, OperationState &result, ArrayRef ranges) { SmallVector lbExprs(ranges.size(), - builder->getAffineConstantExpr(0)); - auto lbMap = AffineMap::get(0, 0, lbExprs, builder->getContext()); + builder.getAffineConstantExpr(0)); + auto lbMap = AffineMap::get(0, 0, lbExprs, builder.getContext()); SmallVector ubExprs; for (int64_t range : ranges) - ubExprs.push_back(builder->getAffineConstantExpr(range)); - auto ubMap = AffineMap::get(0, 0, ubExprs, builder->getContext()); + ubExprs.push_back(builder.getAffineConstantExpr(range)); + auto ubMap = AffineMap::get(0, 0, ubExprs, builder.getContext()); build(builder, result, lbMap, {}, ubMap, {}); } -void AffineParallelOp::build(Builder *builder, OperationState &result, +void AffineParallelOp::build(OpBuilder &builder, OperationState &result, AffineMap lbMap, ValueRange lbArgs, AffineMap ubMap, ValueRange ubArgs) { auto numDims = lbMap.getNumResults(); @@ -2186,7 +2186,7 @@ build(builder, result, lbMap, lbArgs, ubMap, ubArgs, steps); } -void AffineParallelOp::build(Builder *builder, OperationState &result, +void AffineParallelOp::build(OpBuilder &builder, OperationState &result, AffineMap lbMap, ValueRange lbArgs, AffineMap ubMap, ValueRange ubArgs, ArrayRef steps) { @@ -2197,7 +2197,7 @@ assert(numDims == steps.size() && "num dims and num steps mismatch"); result.addAttribute(getLowerBoundsMapAttrName(), AffineMapAttr::get(lbMap)); result.addAttribute(getUpperBoundsMapAttrName(), AffineMapAttr::get(ubMap)); - result.addAttribute(getStepsAttrName(), builder->getI64ArrayAttr(steps)); + result.addAttribute(getStepsAttrName(), builder.getI64ArrayAttr(steps)); result.addOperands(lbArgs); result.addOperands(ubArgs); // Create a region and a block for the body. @@ -2205,9 +2205,9 @@ auto body = new Block(); // Add all the block arguments. for (unsigned i = 0; i < numDims; ++i) - body->addArgument(IndexType::get(builder->getContext())); + body->addArgument(IndexType::get(builder.getContext())); bodyRegion->push_back(body); - ensureTerminator(*bodyRegion, *builder, result.location); + ensureTerminator(*bodyRegion, builder, result.location); } unsigned AffineParallelOp::getNumDims() { return steps().size(); } diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -200,9 +200,9 @@ // LaunchOp //===----------------------------------------------------------------------===// -void LaunchOp::build(Builder *builder, OperationState &result, Value gridSizeX, - Value gridSizeY, Value gridSizeZ, Value blockSizeX, - Value blockSizeY, Value blockSizeZ) { +void LaunchOp::build(OpBuilder &builder, OperationState &result, + Value gridSizeX, Value gridSizeY, Value gridSizeZ, + Value blockSizeX, Value blockSizeY, Value blockSizeZ) { // Add grid and block sizes as op operands, followed by the data operands. result.addOperands( {gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ}); @@ -213,7 +213,7 @@ Region *kernelRegion = result.addRegion(); Block *body = new Block(); body->addArguments( - std::vector(kNumConfigRegionAttributes, builder->getIndexType())); + std::vector(kNumConfigRegionAttributes, builder.getIndexType())); kernelRegion->push_back(body); } @@ -388,7 +388,7 @@ // LaunchFuncOp //===----------------------------------------------------------------------===// -void LaunchFuncOp::build(Builder *builder, OperationState &result, +void LaunchFuncOp::build(OpBuilder &builder, OperationState &result, GPUFuncOp kernelFunc, Value gridSizeX, Value gridSizeY, Value gridSizeZ, Value blockSizeX, Value blockSizeY, Value blockSizeZ, ValueRange kernelOperands) { @@ -397,13 +397,12 @@ {gridSizeX, gridSizeY, gridSizeZ, blockSizeX, blockSizeY, blockSizeZ}); result.addOperands(kernelOperands); auto kernelModule = kernelFunc.getParentOfType(); - auto kernelSymbol = builder->getSymbolRefAttr( - kernelModule.getName(), - {builder->getSymbolRefAttr(kernelFunc.getName())}); + auto kernelSymbol = builder.getSymbolRefAttr( + kernelModule.getName(), {builder.getSymbolRefAttr(kernelFunc.getName())}); result.addAttribute(getKernelAttrName(), kernelSymbol); } -void LaunchFuncOp::build(Builder *builder, OperationState &result, +void LaunchFuncOp::build(OpBuilder &builder, OperationState &result, GPUFuncOp kernelFunc, KernelDim3 gridSize, KernelDim3 blockSize, ValueRange kernelOperands) { build(builder, result, kernelFunc, gridSize.x, gridSize.y, gridSize.z, @@ -476,15 +475,16 @@ return attribution; } -void GPUFuncOp::build(Builder *builder, OperationState &result, StringRef name, - FunctionType type, ArrayRef workgroupAttributions, +void GPUFuncOp::build(OpBuilder &builder, OperationState &result, + StringRef name, FunctionType type, + ArrayRef workgroupAttributions, ArrayRef privateAttributions, ArrayRef attrs) { result.addAttribute(SymbolTable::getSymbolAttrName(), - builder->getStringAttr(name)); + builder.getStringAttr(name)); result.addAttribute(getTypeAttrName(), TypeAttr::get(type)); result.addAttribute(getNumWorkgroupAttributionsAttrName(), - builder->getI64IntegerAttr(workgroupAttributions.size())); + builder.getI64IntegerAttr(workgroupAttributions.size())); result.addAttributes(attrs); Region *body = result.addRegion(); Block *entryBlock = new Block; @@ -742,11 +742,11 @@ // GPUModuleOp //===----------------------------------------------------------------------===// -void GPUModuleOp::build(Builder *builder, OperationState &result, +void GPUModuleOp::build(OpBuilder &builder, OperationState &result, StringRef name) { - ensureTerminator(*result.addRegion(), *builder, result.location); - result.attributes.push_back(builder->getNamedAttr( - ::mlir::SymbolTable::getSymbolAttrName(), builder->getStringAttr(name))); + ensureTerminator(*result.addRegion(), builder, result.location); + result.attributes.push_back(builder.getNamedAttr( + ::mlir::SymbolTable::getSymbolAttrName(), builder.getStringAttr(name))); } static ParseResult parseGPUModuleOp(OpAsmParser &parser, diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp --- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp @@ -265,10 +265,10 @@ // prevent manual building of Ops with symbols in code using SymbolTables // and then this needs to use the OpBuilder. auto context = getOperation().getContext(); - Builder builder(context); + OpBuilder builder(context); OperationState state(kernelFunc.getLoc(), gpu::GPUModuleOp::getOperationName()); - gpu::GPUModuleOp::build(&builder, state, kernelFunc.getName()); + gpu::GPUModuleOp::build(builder, state, kernelFunc.getName()); auto kernelModule = cast(Operation::create(state)); SymbolTable symbolTable(kernelModule); symbolTable.insert(kernelFunc); diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -612,7 +612,7 @@ //===----------------------------------------------------------------------===// // Expects vector to be of wrapped LLVM vector type and position to be of // wrapped LLVM i32 type. -void LLVM::ExtractElementOp::build(Builder *b, OperationState &result, +void LLVM::ExtractElementOp::build(OpBuilder &b, OperationState &result, Value vector, Value position, ArrayRef attrs) { auto wrappedVectorType = vector.getType().cast(); @@ -892,21 +892,21 @@ /// the name of the attribute in ODS. static StringRef getLinkageAttrName() { return "linkage"; } -void GlobalOp::build(Builder *builder, OperationState &result, LLVMType type, +void GlobalOp::build(OpBuilder &builder, OperationState &result, LLVMType type, bool isConstant, Linkage linkage, StringRef name, Attribute value, unsigned addrSpace, ArrayRef attrs) { result.addAttribute(SymbolTable::getSymbolAttrName(), - builder->getStringAttr(name)); + builder.getStringAttr(name)); result.addAttribute("type", TypeAttr::get(type)); if (isConstant) - result.addAttribute("constant", builder->getUnitAttr()); + result.addAttribute("constant", builder.getUnitAttr()); if (value) result.addAttribute("value", value); - result.addAttribute(getLinkageAttrName(), builder->getI64IntegerAttr( - static_cast(linkage))); + result.addAttribute(getLinkageAttrName(), + builder.getI64IntegerAttr(static_cast(linkage))); if (addrSpace != 0) - result.addAttribute("addr_space", builder->getI32IntegerAttr(addrSpace)); + result.addAttribute("addr_space", builder.getI32IntegerAttr(addrSpace)); result.attributes.append(attrs.begin(), attrs.end()); result.addRegion(); } @@ -1106,8 +1106,8 @@ //===----------------------------------------------------------------------===// // Expects vector to be of wrapped LLVM vector type and position to be of // wrapped LLVM i32 type. -void LLVM::ShuffleVectorOp::build(Builder *b, OperationState &result, Value v1, - Value v2, ArrayAttr mask, +void LLVM::ShuffleVectorOp::build(OpBuilder &b, OperationState &result, + Value v1, Value v2, ArrayAttr mask, ArrayRef attrs) { auto wrappedContainerType1 = v1.getType().cast(); auto vType = LLVMType::getVectorTy( @@ -1170,16 +1170,16 @@ return entry; } -void LLVMFuncOp::build(Builder *builder, OperationState &result, StringRef name, - LLVMType type, LLVM::Linkage linkage, +void LLVMFuncOp::build(OpBuilder &builder, OperationState &result, + StringRef name, LLVMType type, LLVM::Linkage linkage, ArrayRef attrs, ArrayRef argAttrs) { result.addRegion(); result.addAttribute(SymbolTable::getSymbolAttrName(), - builder->getStringAttr(name)); + builder.getStringAttr(name)); result.addAttribute("type", TypeAttr::get(type)); - result.addAttribute(getLinkageAttrName(), builder->getI64IntegerAttr( - static_cast(linkage))); + result.addAttribute(getLinkageAttrName(), + builder.getI64IntegerAttr(static_cast(linkage))); result.attributes.append(attrs.begin(), attrs.end()); if (argAttrs.empty()) return; diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -468,7 +468,7 @@ } void mlir::linalg::ReshapeOp::build( - Builder *b, OperationState &result, Value src, + OpBuilder &b, OperationState &result, Value src, ArrayRef> reassociation, ArrayRef attrs) { auto maps = getSymbolLessAffineMaps(reassociation); @@ -476,17 +476,17 @@ auto resultType = computeReshapeCollapsedType(memRefType, maps); build(b, result, resultType, src, attrs); result.addAttribute(ReshapeOp::getReassociationAttrName(), - b->getAffineMapArrayAttr(maps)); + b.getAffineMapArrayAttr(maps)); } void mlir::linalg::ReshapeOp::build( - Builder *b, OperationState &result, Type resultType, Value src, + OpBuilder &b, OperationState &result, Type resultType, Value src, ArrayRef> reassociation, ArrayRef attrs) { auto maps = getSymbolLessAffineMaps(reassociation); build(b, result, resultType, src, attrs); result.addAttribute(ReshapeOp::getReassociationAttrName(), - b->getAffineMapArrayAttr(maps)); + b.getAffineMapArrayAttr(maps)); } // Common verifier for reshape-like types. Fills `expandedType` and @@ -569,7 +569,7 @@ } void mlir::linalg::TensorReshapeOp::build( - Builder *b, OperationState &result, Value src, + OpBuilder &b, OperationState &result, Value src, ArrayRef> reassociation, ArrayRef attrs) { auto maps = getSymbolLessAffineMaps(reassociation); @@ -577,17 +577,17 @@ src.getType().cast(), maps); build(b, result, resultType, src, attrs); result.addAttribute(TensorReshapeOp::getReassociationAttrName(), - b->getAffineMapArrayAttr(maps)); + b.getAffineMapArrayAttr(maps)); } void mlir::linalg::TensorReshapeOp::build( - Builder *b, OperationState &result, Type resultType, Value src, + OpBuilder &b, OperationState &result, Type resultType, Value src, ArrayRef> reassociation, ArrayRef attrs) { auto maps = getSymbolLessAffineMaps(reassociation); build(b, result, resultType, src, attrs); result.addAttribute(TensorReshapeOp::getReassociationAttrName(), - b->getAffineMapArrayAttr(maps)); + b.getAffineMapArrayAttr(maps)); } static LogicalResult verify(TensorReshapeOp op) { @@ -608,7 +608,7 @@ //===----------------------------------------------------------------------===// // SliceOp //===----------------------------------------------------------------------===// -void mlir::linalg::SliceOp::build(Builder *b, OperationState &result, +void mlir::linalg::SliceOp::build(OpBuilder &b, OperationState &result, Value base, ValueRange indexings) { result.addOperands(base); result.addOperands(indexings); @@ -626,7 +626,7 @@ result.addTypes({MemRefType::Builder(memRefType) .setShape(sizes) .setAffineMaps(makeStridedLinearLayoutMap( - strides, offset, b->getContext()))}); + strides, offset, b.getContext()))}); } static void print(OpAsmPrinter &p, SliceOp op) { @@ -683,7 +683,7 @@ //===----------------------------------------------------------------------===// // TransposeOp //===----------------------------------------------------------------------===// -void mlir::linalg::TransposeOp::build(Builder *b, OperationState &result, +void mlir::linalg::TransposeOp::build(OpBuilder &b, OperationState &result, Value view, AffineMapAttr permutation, ArrayRef attrs) { auto permutationMap = permutation.getValue(); @@ -704,7 +704,7 @@ auto res = getStridesAndOffset(memRefType, strides, offset); assert(succeeded(res) && strides.size() == static_cast(rank)); (void)res; - auto map = makeStridedLinearLayoutMap(strides, offset, b->getContext()); + auto map = makeStridedLinearLayoutMap(strides, offset, b.getContext()); map = permutationMap ? map.compose(permutationMap) : map; // Compute result type. MemRefType resultType = diff --git a/mlir/lib/Dialect/LoopOps/LoopOps.cpp b/mlir/lib/Dialect/LoopOps/LoopOps.cpp --- a/mlir/lib/Dialect/LoopOps/LoopOps.cpp +++ b/mlir/lib/Dialect/LoopOps/LoopOps.cpp @@ -39,8 +39,8 @@ // ForOp //===----------------------------------------------------------------------===// -void ForOp::build(Builder *builder, OperationState &result, Value lb, Value ub, - Value step, ValueRange iterArgs) { +void ForOp::build(OpBuilder &builder, OperationState &result, Value lb, + Value ub, Value step, ValueRange iterArgs) { result.addOperands({lb, ub, step}); result.addOperands(iterArgs); for (Value v : iterArgs) @@ -48,8 +48,8 @@ Region *bodyRegion = result.addRegion(); bodyRegion->push_back(new Block()); if (iterArgs.empty()) - ForOp::ensureTerminator(*bodyRegion, *builder, result.location); - bodyRegion->front().addArgument(builder->getIndexType()); + ForOp::ensureTerminator(*bodyRegion, builder, result.location); + bodyRegion->front().addArgument(builder.getIndexType()); for (Value v : iterArgs) bodyRegion->front().addArgument(v.getType()); } @@ -233,12 +233,12 @@ // IfOp //===----------------------------------------------------------------------===// -void IfOp::build(Builder *builder, OperationState &result, Value cond, +void IfOp::build(OpBuilder &builder, OperationState &result, Value cond, bool withElseRegion) { build(builder, result, /*resultTypes=*/llvm::None, cond, withElseRegion); } -void IfOp::build(Builder *builder, OperationState &result, +void IfOp::build(OpBuilder &builder, OperationState &result, TypeRange resultTypes, Value cond, bool withElseRegion) { result.addOperands(cond); result.addTypes(resultTypes); @@ -246,13 +246,13 @@ Region *thenRegion = result.addRegion(); thenRegion->push_back(new Block()); if (resultTypes.empty()) - IfOp::ensureTerminator(*thenRegion, *builder, result.location); + IfOp::ensureTerminator(*thenRegion, builder, result.location); Region *elseRegion = result.addRegion(); if (withElseRegion) { elseRegion->push_back(new Block()); if (resultTypes.empty()) - IfOp::ensureTerminator(*elseRegion, *builder, result.location); + IfOp::ensureTerminator(*elseRegion, builder, result.location); } } @@ -371,22 +371,23 @@ // ParallelOp //===----------------------------------------------------------------------===// -void ParallelOp::build(Builder *builder, OperationState &result, ValueRange lbs, - ValueRange ubs, ValueRange steps, ValueRange initVals) { +void ParallelOp::build(OpBuilder &builder, OperationState &result, + ValueRange lbs, ValueRange ubs, ValueRange steps, + ValueRange initVals) { result.addOperands(lbs); result.addOperands(ubs); result.addOperands(steps); result.addOperands(initVals); result.addAttribute( ParallelOp::getOperandSegmentSizeAttr(), - builder->getI32VectorAttr({static_cast(lbs.size()), - static_cast(ubs.size()), - static_cast(steps.size()), - static_cast(initVals.size())})); + builder.getI32VectorAttr({static_cast(lbs.size()), + static_cast(ubs.size()), + static_cast(steps.size()), + static_cast(initVals.size())})); Region *bodyRegion = result.addRegion(); - ParallelOp::ensureTerminator(*bodyRegion, *builder, result.location); + ParallelOp::ensureTerminator(*bodyRegion, builder, result.location); for (size_t i = 0, e = steps.size(); i < e; ++i) - bodyRegion->front().addArgument(builder->getIndexType()); + bodyRegion->front().addArgument(builder.getIndexType()); for (Value init : initVals) result.addTypes(init.getType()); } @@ -554,7 +555,8 @@ // ReduceOp //===----------------------------------------------------------------------===// -void ReduceOp::build(Builder *builder, OperationState &result, Value operand) { +void ReduceOp::build(OpBuilder &builder, OperationState &result, + Value operand) { auto type = operand.getType(); result.addOperands(operand); Region *bodyRegion = result.addRegion(); diff --git a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp --- a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp @@ -596,7 +596,7 @@ } SmallVector linearizedIndices; // Add a '0' at the start to index into the struct. - auto zero = spirv::ConstantOp::getZero(indexType, loc, &builder); + auto zero = spirv::ConstantOp::getZero(indexType, loc, builder); linearizedIndices.push_back(zero); // If it is a zero-rank memref type, extract the element directly. if (!ptrLoc) { diff --git a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp --- a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp @@ -788,7 +788,7 @@ return spirv::PointerType::get(resultType, resultStorageClass); } -void spirv::AccessChainOp::build(Builder *builder, OperationState &state, +void spirv::AccessChainOp::build(OpBuilder &builder, OperationState &state, Value basePtr, ValueRange indices) { auto type = getElementPtrType(basePtr.getType(), indices, state.location); assert(type && "Unable to deduce return type based on basePtr and indices"); @@ -857,9 +857,9 @@ // spv._address_of //===----------------------------------------------------------------------===// -void spirv::AddressOfOp::build(Builder *builder, OperationState &state, +void spirv::AddressOfOp::build(OpBuilder &builder, OperationState &state, spirv::GlobalVariableOp var) { - build(builder, state, var.type(), builder->getSymbolRefAttr(var)); + build(builder, state, var.type(), builder.getSymbolRefAttr(var)); } static LogicalResult verify(spirv::AddressOfOp addressOfOp) { @@ -1163,10 +1163,10 @@ // spv.CompositeExtractOp //===----------------------------------------------------------------------===// -void spirv::CompositeExtractOp::build(Builder *builder, OperationState &state, +void spirv::CompositeExtractOp::build(OpBuilder &builder, OperationState &state, Value composite, ArrayRef indices) { - auto indexAttr = builder->getI32ArrayAttr(indices); + auto indexAttr = builder.getI32ArrayAttr(indices); auto elementType = getElementType(composite.getType(), indexAttr, state.location); if (!elementType) { @@ -1386,28 +1386,28 @@ } spirv::ConstantOp spirv::ConstantOp::getZero(Type type, Location loc, - OpBuilder *builder) { + OpBuilder &builder) { if (auto intType = type.dyn_cast()) { unsigned width = intType.getWidth(); if (width == 1) - return builder->create(loc, type, - builder->getBoolAttr(false)); - return builder->create( - loc, type, builder->getIntegerAttr(type, APInt(width, 0))); + return builder.create(loc, type, + builder.getBoolAttr(false)); + return builder.create( + loc, type, builder.getIntegerAttr(type, APInt(width, 0))); } llvm_unreachable("unimplemented types for ConstantOp::getZero()"); } spirv::ConstantOp spirv::ConstantOp::getOne(Type type, Location loc, - OpBuilder *builder) { + OpBuilder &builder) { if (auto intType = type.dyn_cast()) { unsigned width = intType.getWidth(); if (width == 1) - return builder->create(loc, type, - builder->getBoolAttr(true)); - return builder->create( - loc, type, builder->getIntegerAttr(type, APInt(width, 1))); + return builder.create(loc, type, + builder.getBoolAttr(true)); + return builder.create( + loc, type, builder.getIntegerAttr(type, APInt(width, 1))); } llvm_unreachable("unimplemented types for ConstantOp::getOne()"); @@ -1417,14 +1417,14 @@ // spv.EntryPoint //===----------------------------------------------------------------------===// -void spirv::EntryPointOp::build(Builder *builder, OperationState &state, +void spirv::EntryPointOp::build(OpBuilder &builder, OperationState &state, spirv::ExecutionModel executionModel, spirv::FuncOp function, ArrayRef interfaceVars) { build(builder, state, - builder->getI32IntegerAttr(static_cast(executionModel)), - builder->getSymbolRefAttr(function), - builder->getArrayAttr(interfaceVars)); + builder.getI32IntegerAttr(static_cast(executionModel)), + builder.getSymbolRefAttr(function), + builder.getArrayAttr(interfaceVars)); } static ParseResult parseEntryPointOp(OpAsmParser &parser, @@ -1479,13 +1479,13 @@ // spv.ExecutionMode //===----------------------------------------------------------------------===// -void spirv::ExecutionModeOp::build(Builder *builder, OperationState &state, +void spirv::ExecutionModeOp::build(OpBuilder &builder, OperationState &state, spirv::FuncOp function, spirv::ExecutionMode executionMode, ArrayRef params) { - build(builder, state, builder->getSymbolRefAttr(function), - builder->getI32IntegerAttr(static_cast(executionMode)), - builder->getI32ArrayAttr(params)); + build(builder, state, builder.getSymbolRefAttr(function), + builder.getI32IntegerAttr(static_cast(executionMode)), + builder.getI32ArrayAttr(params)); } static ParseResult parseExecutionModeOp(OpAsmParser &parser, @@ -1632,16 +1632,15 @@ return failure(walkResult.wasInterrupted()); } -void spirv::FuncOp::build(Builder *builder, OperationState &state, +void spirv::FuncOp::build(OpBuilder &builder, OperationState &state, StringRef name, FunctionType type, spirv::FunctionControl control, ArrayRef attrs) { state.addAttribute(SymbolTable::getSymbolAttrName(), - builder->getStringAttr(name)); + builder.getStringAttr(name)); state.addAttribute(getTypeAttrName(), TypeAttr::get(type)); - state.addAttribute( - spirv::attributeName(), - builder->getI32IntegerAttr(static_cast(control))); + state.addAttribute(spirv::attributeName(), + builder.getI32IntegerAttr(static_cast(control))); state.attributes.append(attrs.begin(), attrs.end()); state.addRegion(); } @@ -1725,27 +1724,27 @@ // spv.globalVariable //===----------------------------------------------------------------------===// -void spirv::GlobalVariableOp::build(Builder *builder, OperationState &state, +void spirv::GlobalVariableOp::build(OpBuilder &builder, OperationState &state, Type type, StringRef name, unsigned descriptorSet, unsigned binding) { - build(builder, state, TypeAttr::get(type), builder->getStringAttr(name), + build(builder, state, TypeAttr::get(type), builder.getStringAttr(name), nullptr); state.addAttribute( spirv::SPIRVDialect::getAttributeName(spirv::Decoration::DescriptorSet), - builder->getI32IntegerAttr(descriptorSet)); + builder.getI32IntegerAttr(descriptorSet)); state.addAttribute( spirv::SPIRVDialect::getAttributeName(spirv::Decoration::Binding), - builder->getI32IntegerAttr(binding)); + builder.getI32IntegerAttr(binding)); } -void spirv::GlobalVariableOp::build(Builder *builder, OperationState &state, +void spirv::GlobalVariableOp::build(OpBuilder &builder, OperationState &state, Type type, StringRef name, spirv::BuiltIn builtin) { - build(builder, state, TypeAttr::get(type), builder->getStringAttr(name), + build(builder, state, TypeAttr::get(type), builder.getStringAttr(name), nullptr); state.addAttribute( spirv::SPIRVDialect::getAttributeName(spirv::Decoration::BuiltIn), - builder->getStringAttr(spirv::stringifyBuiltIn(builtin))); + builder.getStringAttr(spirv::stringifyBuiltIn(builtin))); } static ParseResult parseGlobalVariableOp(OpAsmParser &parser, @@ -1849,10 +1848,10 @@ // spv.GroupNonUniformElectOp //===----------------------------------------------------------------------===// -void spirv::GroupNonUniformElectOp::build(Builder *builder, +void spirv::GroupNonUniformElectOp::build(OpBuilder &builder, OperationState &state, spirv::Scope scope) { - build(builder, state, builder->getI1Type(), scope); + build(builder, state, builder.getI1Type(), scope); } static LogicalResult verify(spirv::GroupNonUniformElectOp groupOp) { @@ -1868,7 +1867,7 @@ // spv.LoadOp //===----------------------------------------------------------------------===// -void spirv::LoadOp::build(Builder *builder, OperationState &state, +void spirv::LoadOp::build(OpBuilder &builder, OperationState &state, Value basePtr, IntegerAttr memory_access, IntegerAttr alignment) { auto ptrType = basePtr.getType().cast(); @@ -1926,9 +1925,9 @@ // spv.loop //===----------------------------------------------------------------------===// -void spirv::LoopOp::build(Builder *builder, OperationState &state) { +void spirv::LoopOp::build(OpBuilder &builder, OperationState &state) { state.addAttribute("loop_control", - builder->getI32IntegerAttr( + builder.getI32IntegerAttr( static_cast(spirv::LoopControl::None))); state.addRegion(); } @@ -2104,19 +2103,19 @@ // spv.module //===----------------------------------------------------------------------===// -void spirv::ModuleOp::build(Builder *builder, OperationState &state) { - ensureTerminator(*state.addRegion(), *builder, state.location); +void spirv::ModuleOp::build(OpBuilder &builder, OperationState &state) { + ensureTerminator(*state.addRegion(), builder, state.location); } -void spirv::ModuleOp::build(Builder *builder, OperationState &state, +void spirv::ModuleOp::build(OpBuilder &builder, OperationState &state, spirv::AddressingModel addressing_model, spirv::MemoryModel memory_model) { state.addAttribute( "addressing_model", - builder->getI32IntegerAttr(static_cast(addressing_model))); - state.addAttribute("memory_model", builder->getI32IntegerAttr( + builder.getI32IntegerAttr(static_cast(addressing_model))); + state.addAttribute("memory_model", builder.getI32IntegerAttr( static_cast(memory_model))); - ensureTerminator(*state.addRegion(), *builder, state.location); + ensureTerminator(*state.addRegion(), builder, state.location); } static ParseResult parseModuleOp(OpAsmParser &parser, OperationState &state) { @@ -2272,8 +2271,8 @@ // spv.Select //===----------------------------------------------------------------------===// -void spirv::SelectOp::build(Builder *builder, OperationState &state, Value cond, - Value trueValue, Value falseValue) { +void spirv::SelectOp::build(OpBuilder &builder, OperationState &state, + Value cond, Value trueValue, Value falseValue) { build(builder, state, trueValue.getType(), cond, trueValue, falseValue); } @@ -2381,10 +2380,10 @@ spirv::SelectionOp spirv::SelectionOp::createIfThen( Location loc, Value condition, - function_ref thenBody, OpBuilder *builder) { - auto selectionControl = builder->getI32IntegerAttr( + function_ref thenBody, OpBuilder &builder) { + auto selectionControl = builder.getI32IntegerAttr( static_cast(spirv::SelectionControl::None)); - auto selectionOp = builder->create(loc, selectionControl); + auto selectionOp = builder.create(loc, selectionControl); selectionOp.addMergeBlock(); Block *mergeBlock = selectionOp.getMergeBlock(); @@ -2392,17 +2391,17 @@ // Build the "then" block. { - OpBuilder::InsertionGuard guard(*builder); - thenBlock = builder->createBlock(mergeBlock); + OpBuilder::InsertionGuard guard(builder); + thenBlock = builder.createBlock(mergeBlock); thenBody(builder); - builder->create(loc, mergeBlock); + builder.create(loc, mergeBlock); } // Build the header block. { - OpBuilder::InsertionGuard guard(*builder); - builder->createBlock(thenBlock); - builder->create( + OpBuilder::InsertionGuard guard(builder); + builder.createBlock(thenBlock); + builder.create( loc, condition, thenBlock, /*trueArguments=*/ArrayRef(), mergeBlock, /*falseArguments=*/ArrayRef()); diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp --- a/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Deserializer.cpp @@ -521,9 +521,9 @@ //===----------------------------------------------------------------------===// spirv::ModuleOp Deserializer::createModuleOp() { - Builder builder(context); + OpBuilder builder(context); OperationState state(unknownLoc, spirv::ModuleOp::getOperationName()); - spirv::ModuleOp::build(&builder, state); + spirv::ModuleOp::build(builder, state); return cast(Operation::create(state)); } diff --git a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp @@ -194,7 +194,7 @@ if (argType.value().cast().isScalarOrVector()) { auto indexType = SPIRVTypeConverter::getIndexType(funcOp.getContext()); auto zero = - spirv::ConstantOp::getZero(indexType, funcOp.getLoc(), &rewriter); + spirv::ConstantOp::getZero(indexType, funcOp.getLoc(), rewriter); auto loadPtr = rewriter.create( funcOp.getLoc(), replacement, zero.constant()); replacement = rewriter.create(funcOp.getLoc(), loadPtr); diff --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp --- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp @@ -484,7 +484,7 @@ // GenericAtomicRMWOp //===----------------------------------------------------------------------===// -void GenericAtomicRMWOp::build(Builder *builder, OperationState &result, +void GenericAtomicRMWOp::build(OpBuilder &builder, OperationState &result, Value memref, ValueRange ivs) { result.addOperands(memref); result.addOperands(ivs); @@ -775,13 +775,12 @@ // CmpIOp //===----------------------------------------------------------------------===// -static void buildCmpIOp(Builder *build, OperationState &result, +static void buildCmpIOp(OpBuilder &build, OperationState &result, CmpIPredicate predicate, Value lhs, Value rhs) { result.addOperands({lhs, rhs}); result.types.push_back(getI1SameShape(lhs.getType())); - result.addAttribute( - CmpIOp::getPredicateAttrName(), - build->getI64IntegerAttr(static_cast(predicate))); + result.addAttribute(CmpIOp::getPredicateAttrName(), + build.getI64IntegerAttr(static_cast(predicate))); } // Compute `lhs` `pred` `rhs`, where `pred` is one of the known integer @@ -830,13 +829,12 @@ // CmpFOp //===----------------------------------------------------------------------===// -static void buildCmpFOp(Builder *build, OperationState &result, +static void buildCmpFOp(OpBuilder &build, OperationState &result, CmpFPredicate predicate, Value lhs, Value rhs) { result.addOperands({lhs, rhs}); result.types.push_back(getI1SameShape(lhs.getType())); - result.addAttribute( - CmpFOp::getPredicateAttrName(), - build->getI64IntegerAttr(static_cast(predicate))); + result.addAttribute(CmpFOp::getPredicateAttrName(), + build.getI64IntegerAttr(static_cast(predicate))); } /// Compute `lhs` `pred` `rhs`, where `pred` is one of the known floating point @@ -1180,9 +1178,9 @@ value.isa(); } -void ConstantFloatOp::build(Builder *builder, OperationState &result, +void ConstantFloatOp::build(OpBuilder &builder, OperationState &result, const APFloat &value, FloatType type) { - ConstantOp::build(builder, result, type, builder->getFloatAttr(type, value)); + ConstantOp::build(builder, result, type, builder.getFloatAttr(type, value)); } bool ConstantFloatOp::classof(Operation *op) { @@ -1195,21 +1193,19 @@ op->getResult(0).getType().isSignlessInteger(); } -void ConstantIntOp::build(Builder *builder, OperationState &result, +void ConstantIntOp::build(OpBuilder &builder, OperationState &result, int64_t value, unsigned width) { - Type type = builder->getIntegerType(width); - ConstantOp::build(builder, result, type, - builder->getIntegerAttr(type, value)); + Type type = builder.getIntegerType(width); + ConstantOp::build(builder, result, type, builder.getIntegerAttr(type, value)); } /// Build a constant int op producing an integer with the specified type, /// which must be an integer type. -void ConstantIntOp::build(Builder *builder, OperationState &result, +void ConstantIntOp::build(OpBuilder &builder, OperationState &result, int64_t value, Type type) { assert(type.isSignlessInteger() && "ConstantIntOp can only have signless integer type"); - ConstantOp::build(builder, result, type, - builder->getIntegerAttr(type, value)); + ConstantOp::build(builder, result, type, builder.getIntegerAttr(type, value)); } /// ConstantIndexOp only matches values whose result type is Index. @@ -1217,11 +1213,10 @@ return ConstantOp::classof(op) && op->getResult(0).getType().isIndex(); } -void ConstantIndexOp::build(Builder *builder, OperationState &result, +void ConstantIndexOp::build(OpBuilder &builder, OperationState &result, int64_t value) { - Type type = builder->getIndexType(); - ConstantOp::build(builder, result, type, - builder->getIntegerAttr(type, value)); + Type type = builder.getIndexType(); + ConstantOp::build(builder, result, type, builder.getIntegerAttr(type, value)); } //===----------------------------------------------------------------------===// @@ -1363,7 +1358,7 @@ // DmaStartOp // --------------------------------------------------------------------------- -void DmaStartOp::build(Builder *builder, OperationState &result, +void DmaStartOp::build(OpBuilder &builder, OperationState &result, Value srcMemRef, ValueRange srcIndices, Value destMemRef, ValueRange destIndices, Value numElements, Value tagMemRef, ValueRange tagIndices, Value stride, @@ -1506,8 +1501,9 @@ // DmaWaitOp // --------------------------------------------------------------------------- -void DmaWaitOp::build(Builder *builder, OperationState &result, Value tagMemRef, - ValueRange tagIndices, Value numElements) { +void DmaWaitOp::build(OpBuilder &builder, OperationState &result, + Value tagMemRef, ValueRange tagIndices, + Value numElements) { result.addOperands(tagMemRef); result.addOperands(tagIndices); result.addOperands(numElements); @@ -2147,7 +2143,7 @@ .setAffineMaps(stridedLayout); } -void mlir::SubViewOp::build(Builder *b, OperationState &result, Value source, +void mlir::SubViewOp::build(OpBuilder &b, OperationState &result, Value source, ValueRange offsets, ValueRange sizes, ValueRange strides, Type resultType, ArrayRef attrs) { @@ -2157,8 +2153,8 @@ result.addAttributes(attrs); } -void mlir::SubViewOp::build(Builder *b, OperationState &result, Type resultType, - Value source) { +void mlir::SubViewOp::build(OpBuilder &b, OperationState &result, + Type resultType, Value source) { build(b, result, source, /*offsets=*/{}, /*sizes=*/{}, /*strides=*/{}, resultType); } diff --git a/mlir/lib/Dialect/Vector/VectorOps.cpp b/mlir/lib/Dialect/Vector/VectorOps.cpp --- a/mlir/lib/Dialect/Vector/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/VectorOps.cpp @@ -126,20 +126,20 @@ // ContractionOp //===----------------------------------------------------------------------===// -void vector::ContractionOp::build(Builder *builder, OperationState &result, +void vector::ContractionOp::build(OpBuilder &builder, OperationState &result, Value lhs, Value rhs, Value acc, ArrayRef> indexingExprs, ArrayRef iteratorTypes) { result.addOperands({lhs, rhs, acc}); result.addTypes(acc.getType()); result.addAttribute(getIndexingMapsAttrName(), - builder->getAffineMapArrayAttr( + builder.getAffineMapArrayAttr( AffineMap::inferFromExprList(indexingExprs))); result.addAttribute(getIteratorTypesAttrName(), - builder->getStrArrayAttr(iteratorTypes)); + builder.getStrArrayAttr(iteratorTypes)); } -void vector::ContractionOp::build(Builder *builder, OperationState &result, +void vector::ContractionOp::build(OpBuilder &builder, OperationState &result, Value lhs, Value rhs, Value acc, ArrayAttr indexingMaps, ArrayAttr iteratorTypes) { @@ -461,10 +461,10 @@ vectorType.getElementType()); } -void vector::ExtractOp::build(Builder *builder, OperationState &result, +void vector::ExtractOp::build(OpBuilder &builder, OperationState &result, Value source, ArrayRef position) { result.addOperands(source); - auto positionAttr = getVectorSubscriptAttr(*builder, position); + auto positionAttr = getVectorSubscriptAttr(builder, position); result.addTypes(inferExtractOpResultType(source.getType().cast(), positionAttr)); result.addAttribute(getPositionAttrName(), positionAttr); @@ -528,13 +528,13 @@ // ExtractSlicesOp //===----------------------------------------------------------------------===// -void ExtractSlicesOp::build(Builder *builder, OperationState &result, +void ExtractSlicesOp::build(OpBuilder &builder, OperationState &result, TupleType tupleType, Value vector, ArrayRef sizes, ArrayRef strides) { result.addOperands(vector); - auto sizesAttr = getVectorSubscriptAttr(*builder, sizes); - auto stridesAttr = getVectorSubscriptAttr(*builder, strides); + auto sizesAttr = getVectorSubscriptAttr(builder, sizes); + auto stridesAttr = getVectorSubscriptAttr(builder, strides); result.addTypes(tupleType); result.addAttribute(getSizesAttrName(), sizesAttr); result.addAttribute(getStridesAttrName(), stridesAttr); @@ -634,10 +634,10 @@ // ShuffleOp //===----------------------------------------------------------------------===// -void ShuffleOp::build(Builder *builder, OperationState &result, Value v1, +void ShuffleOp::build(OpBuilder &builder, OperationState &result, Value v1, Value v2, ArrayRef mask) { result.addOperands({v1, v2}); - auto maskAttr = getVectorSubscriptAttr(*builder, mask); + auto maskAttr = getVectorSubscriptAttr(builder, mask); result.addTypes(v1.getType()); result.addAttribute(getMaskAttrName(), maskAttr); } @@ -731,10 +731,10 @@ // InsertOp //===----------------------------------------------------------------------===// -void InsertOp::build(Builder *builder, OperationState &result, Value source, +void InsertOp::build(OpBuilder &builder, OperationState &result, Value source, Value dest, ArrayRef position) { result.addOperands({source, dest}); - auto positionAttr = getVectorSubscriptAttr(*builder, position); + auto positionAttr = getVectorSubscriptAttr(builder, position); result.addTypes(dest.getType()); result.addAttribute(getPositionAttrName(), positionAttr); } @@ -795,13 +795,13 @@ // InsertStridedSliceOp //===----------------------------------------------------------------------===// -void InsertStridedSliceOp::build(Builder *builder, OperationState &result, +void InsertStridedSliceOp::build(OpBuilder &builder, OperationState &result, Value source, Value dest, ArrayRef offsets, ArrayRef strides) { result.addOperands({source, dest}); - auto offsetsAttr = getVectorSubscriptAttr(*builder, offsets); - auto stridesAttr = getVectorSubscriptAttr(*builder, strides); + auto offsetsAttr = getVectorSubscriptAttr(builder, offsets); + auto stridesAttr = getVectorSubscriptAttr(builder, strides); result.addTypes(dest.getType()); result.addAttribute(getOffsetsAttrName(), offsetsAttr); result.addAttribute(getStridesAttrName(), stridesAttr); @@ -1074,13 +1074,13 @@ return VectorType::get(shape, vectorType.getElementType()); } -void StridedSliceOp::build(Builder *builder, OperationState &result, +void StridedSliceOp::build(OpBuilder &builder, OperationState &result, Value source, ArrayRef offsets, ArrayRef sizes, ArrayRef strides) { result.addOperands(source); - auto offsetsAttr = getVectorSubscriptAttr(*builder, offsets); - auto sizesAttr = getVectorSubscriptAttr(*builder, sizes); - auto stridesAttr = getVectorSubscriptAttr(*builder, strides); + auto offsetsAttr = getVectorSubscriptAttr(builder, offsets); + auto sizesAttr = getVectorSubscriptAttr(builder, sizes); + auto stridesAttr = getVectorSubscriptAttr(builder, strides); result.addTypes( inferStridedSliceOpResultType(source.getType().cast(), offsetsAttr, sizesAttr, stridesAttr)); @@ -1466,7 +1466,8 @@ return MemRefType::get({}, VectorType::get(t.getShape(), t.getElementType())); } -void TypeCastOp::build(Builder *builder, OperationState &result, Value source) { +void TypeCastOp::build(OpBuilder &builder, OperationState &result, + Value source) { result.addOperands(source); result.addTypes( inferVectorTypeCastResultType(source.getType().cast())); diff --git a/mlir/lib/IR/Function.cpp b/mlir/lib/IR/Function.cpp --- a/mlir/lib/IR/Function.cpp +++ b/mlir/lib/IR/Function.cpp @@ -24,8 +24,8 @@ FuncOp FuncOp::create(Location location, StringRef name, FunctionType type, ArrayRef attrs) { OperationState state(location, "func"); - Builder builder(location->getContext()); - FuncOp::build(&builder, state, name, type, attrs); + OpBuilder builder(location->getContext()); + FuncOp::build(builder, state, name, type, attrs); return cast(Operation::create(state)); } FuncOp FuncOp::create(Location location, StringRef name, FunctionType type, @@ -41,16 +41,16 @@ return func; } -void FuncOp::build(Builder *builder, OperationState &result, StringRef name, +void FuncOp::build(OpBuilder &builder, OperationState &result, StringRef name, FunctionType type, ArrayRef attrs) { result.addAttribute(SymbolTable::getSymbolAttrName(), - builder->getStringAttr(name)); + builder.getStringAttr(name)); result.addAttribute(getTypeAttrName(), TypeAttr::get(type)); result.attributes.append(attrs.begin(), attrs.end()); result.addRegion(); } -void FuncOp::build(Builder *builder, OperationState &result, StringRef name, +void FuncOp::build(OpBuilder &builder, OperationState &result, StringRef name, FunctionType type, ArrayRef attrs, ArrayRef argAttrs) { build(builder, result, name, type, attrs); diff --git a/mlir/lib/IR/Module.cpp b/mlir/lib/IR/Module.cpp --- a/mlir/lib/IR/Module.cpp +++ b/mlir/lib/IR/Module.cpp @@ -16,19 +16,19 @@ // Module Operation. //===----------------------------------------------------------------------===// -void ModuleOp::build(Builder *builder, OperationState &result, +void ModuleOp::build(OpBuilder &builder, OperationState &result, Optional name) { - ensureTerminator(*result.addRegion(), *builder, result.location); + ensureTerminator(*result.addRegion(), builder, result.location); if (name) - result.attributes.push_back(builder->getNamedAttr( - mlir::SymbolTable::getSymbolAttrName(), builder->getStringAttr(*name))); + result.attributes.push_back(builder.getNamedAttr( + mlir::SymbolTable::getSymbolAttrName(), builder.getStringAttr(*name))); } /// Construct a module from the given context. ModuleOp ModuleOp::create(Location loc, Optional name) { OperationState state(loc, "module"); - Builder builder(loc->getContext()); - ModuleOp::build(&builder, state, name); + OpBuilder builder(loc->getContext()); + ModuleOp::build(builder, state, name); return cast(Operation::create(state)); } diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -980,7 +980,7 @@ // These functions are out-of-line implementations of the methods in BinaryOp, // which avoids them being template instantiated/duplicated. -void impl::buildBinaryOp(Builder *builder, OperationState &result, Value lhs, +void impl::buildBinaryOp(OpBuilder &builder, OperationState &result, Value lhs, Value rhs) { assert(lhs.getType() == rhs.getType()); result.addOperands({lhs, rhs}); @@ -1021,7 +1021,7 @@ // CastOp implementation //===----------------------------------------------------------------------===// -void impl::buildCastOp(Builder *builder, OperationState &result, Value source, +void impl::buildCastOp(OpBuilder &builder, OperationState &result, Value source, Type destType) { result.addOperands(source); result.addTypes(destType); @@ -1062,7 +1062,7 @@ /// terminator operation to insert. void impl::ensureRegionTerminator( Region ®ion, Location loc, - function_ref buildTerminatorOp) { + function_ref buildTerminatorOp) { if (region.empty()) region.push_back(new Block); @@ -1070,5 +1070,6 @@ if (!block.empty() && block.back().isKnownTerminator()) return; - block.push_back(buildTerminatorOp()); + OpBuilder builder(loc.getContext()); + block.push_back(buildTerminatorOp(builder)); } diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td --- a/mlir/test/lib/Dialect/Test/TestOps.td +++ b/mlir/test/lib/Dialect/Test/TestOps.td @@ -731,9 +731,9 @@ let builders = [ OpBuilder< - "Builder *builder, OperationState &state, Value operand", + "OpBuilder &builder, OperationState &state, Value operand", [{ - state.types.assign({builder->getIntegerType(32)}); + state.types.assign({builder.getIntegerType(32)}); state.addOperands({operand}); }]> ]; @@ -843,10 +843,10 @@ let builders = [ OpBuilder< - "Builder *builder, OperationState &state, IntegerAttr kind", + "OpBuilder &builder, OperationState &state, IntegerAttr kind", [{ - auto i32 = builder->getIntegerType(32); - auto f32 = builder->getF32Type(); + auto i32 = builder.getIntegerType(32); + auto f32 = builder.getF32Type(); state.types.assign({i32, f32}); state.addAttribute("kind", kind); }]> @@ -999,9 +999,9 @@ // result type. So need to provide a builder not requiring result types. let builders = [ OpBuilder< - "Builder *builder, OperationState &state, IntegerAttr count", + "OpBuilder &builder, OperationState &state, IntegerAttr count", [{ - auto i32Type = builder->getIntegerType(32); + auto i32Type = builder.getIntegerType(32); state.addTypes(i32Type); // $output1 SmallVector types(count.getInt(), i32Type); state.addTypes(types); // $output2 diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -77,7 +77,7 @@ inferredReturnTypes))) { OperationState state(location, OpTy::getOperationName()); // TODO(jpienaar): Expand to regions. - OpTy::build(&b, state, values, op->getAttrs()); + OpTy::build(b, state, values, op->getAttrs()); (void)b.createOperation(state); } } diff --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td --- a/mlir/test/mlir-tblgen/op-attribute.td +++ b/mlir/test/mlir-tblgen/op-attribute.td @@ -74,7 +74,7 @@ // DEF: void AOp::build( // DEF: some-return-type aAttr, some-return-type bAttr, /*optional*/some-attr-kind cAttr -// DEF: odsState.addAttribute("aAttr", some-const-builder-call((*odsBuilder), aAttr)); +// DEF: odsState.addAttribute("aAttr", some-const-builder-call(odsBuilder, aAttr)); // DEF: void AOp::build( // DEF: ArrayRef attributes @@ -198,8 +198,8 @@ // DECL: static void build({{.*}}, APInt i32_attr, APFloat f64_attr, StringRef str_attr, bool bool_attr, ::SomeI32Enum enum_attr, APInt dv_i32_attr, APFloat dv_f64_attr, StringRef dv_str_attr = "abc", bool dv_bool_attr = true, ::SomeI32Enum dv_enum_attr = ::SomeI32Enum::case5) // DEF-LABEL: DOp definitions -// DEF: odsState.addAttribute("str_attr", (*odsBuilder).getStringAttr(str_attr)); -// DEF: odsState.addAttribute("dv_str_attr", (*odsBuilder).getStringAttr(dv_str_attr)); +// DEF: odsState.addAttribute("str_attr", odsBuilder.getStringAttr(str_attr)); +// DEF: odsState.addAttribute("dv_str_attr", odsBuilder.getStringAttr(dv_str_attr)); // Test derived type attr. // --- @@ -249,7 +249,7 @@ // DEF-LABEL: MixOperandsAndAttrs definitions // DEF-DAG: Value MixOperandsAndAttrs::operand() // DEF-DAG: Value MixOperandsAndAttrs::otherArg() -// DEF-DAG: void MixOperandsAndAttrs::build(Builder *odsBuilder, OperationState &odsState, FloatAttr attr, Value operand, FloatAttr otherAttr, Value otherArg) +// DEF-DAG: void MixOperandsAndAttrs::build(OpBuilder &odsBuilder, OperationState &odsState, FloatAttr attr, Value operand, FloatAttr otherAttr, Value otherArg) // DEF-DAG: APFloat MixOperandsAndAttrs::attr() // DEF-DAG: APFloat MixOperandsAndAttrs::otherAttr() @@ -264,7 +264,7 @@ // DEF: bool UnitAttrOp::attr() { // DEF: return {{.*}} != nullptr -// DEF: build(Builder *odsBuilder, OperationState &odsState, /*optional*/UnitAttr attr) +// DEF: build(OpBuilder &odsBuilder, OperationState &odsState, /*optional*/UnitAttr attr) // Test elementAttr field of TypedArrayAttr. diff --git a/mlir/test/mlir-tblgen/op-decl.td b/mlir/test/mlir-tblgen/op-decl.td --- a/mlir/test/mlir-tblgen/op-decl.td +++ b/mlir/test/mlir-tblgen/op-decl.td @@ -76,9 +76,9 @@ // CHECK: FloatAttr attr2Attr() // CHECK: Optional< APFloat > attr2(); // CHECK: static void build(Value val); -// CHECK: static void build(Builder *odsBuilder, OperationState &odsState, Type r, ArrayRef s, Value a, ValueRange b, IntegerAttr attr1, /*optional*/FloatAttr attr2, unsigned someRegionsCount) -// CHECK: static void build(Builder *odsBuilder, OperationState &odsState, Type r, ArrayRef s, Value a, ValueRange b, APInt attr1, /*optional*/FloatAttr attr2, unsigned someRegionsCount) -// CHECK: static void build(Builder *, OperationState &odsState, ArrayRef resultTypes, ValueRange operands, ArrayRef attributes, unsigned numRegions) +// CHECK: static void build(OpBuilder &odsBuilder, OperationState &odsState, Type r, ArrayRef s, Value a, ValueRange b, IntegerAttr attr1, /*optional*/FloatAttr attr2, unsigned someRegionsCount) +// CHECK: static void build(OpBuilder &odsBuilder, OperationState &odsState, Type r, ArrayRef s, Value a, ValueRange b, APInt attr1, /*optional*/FloatAttr attr2, unsigned someRegionsCount) +// CHECK: static void build(OpBuilder &, OperationState &odsState, ArrayRef resultTypes, ValueRange operands, ArrayRef attributes, unsigned numRegions) // CHECK: static ParseResult parse(OpAsmParser &parser, OperationState &result); // CHECK: void print(OpAsmPrinter &p); // CHECK: LogicalResult verify(); @@ -120,7 +120,7 @@ // CHECK-LABEL: NS::EOp declarations // CHECK: Value a(); // CHECK: Value b(); -// CHECK: static void build(Builder *odsBuilder, OperationState &odsState, /*optional*/Type b, /*optional*/Value a) +// CHECK: static void build(OpBuilder &odsBuilder, OperationState &odsState, /*optional*/Type b, /*optional*/Value a) // Check that default builders can be suppressed. // --- diff --git a/mlir/test/mlir-tblgen/op-operand.td b/mlir/test/mlir-tblgen/op-operand.td --- a/mlir/test/mlir-tblgen/op-operand.td +++ b/mlir/test/mlir-tblgen/op-operand.td @@ -67,13 +67,13 @@ let assemblyFormat = "$input attr-dict `:` type($input)"; } -// CHECK-LABEL: OpE::build(Builder *odsBuilder, OperationState &odsState, ValueRange +// CHECK-LABEL: OpE::build(OpBuilder &odsBuilder, OperationState &odsState, ValueRange // CHECK: odsState.setOperandListToResizable() -// CHECK-LABEL: OpE::build(Builder *odsBuilder, OperationState &odsState, ArrayRef +// CHECK-LABEL: OpE::build(OpBuilder &odsBuilder, OperationState &odsState, ArrayRef // CHECK: odsState.setOperandListToResizable() -// CHECK-LABEL: OpE::build(Builder *, OperationState +// CHECK-LABEL: OpE::build(OpBuilder &, OperationState // CHECK: odsState.setOperandListToResizable() // CHECK-LABEL: OpE::parse diff --git a/mlir/test/mlir-tblgen/op-result.td b/mlir/test/mlir-tblgen/op-result.td --- a/mlir/test/mlir-tblgen/op-result.td +++ b/mlir/test/mlir-tblgen/op-result.td @@ -23,9 +23,9 @@ } // CHECK-LABEL: OpB definitions -// CHECK: void OpB::build(Builder *odsBuilder, OperationState &odsState, Type y, Value x) +// CHECK: void OpB::build(OpBuilder &odsBuilder, OperationState &odsState, Type y, Value x) // CHECK: odsState.addTypes(y); -// CHECK: void OpB::build(Builder *odsBuilder, OperationState &odsState, Value x) +// CHECK: void OpB::build(OpBuilder &odsBuilder, OperationState &odsState, Value x) // CHECK: odsState.addTypes({x.getType()}); def OpC : NS_Op<"three_normal_result_op", []> { @@ -33,12 +33,12 @@ } // CHECK-LABEL: OpC definitions -// CHECK: void OpC::build(Builder *odsBuilder, OperationState &odsState, Type x, Type resultType1, Type z) +// CHECK: void OpC::build(OpBuilder &odsBuilder, OperationState &odsState, Type x, Type resultType1, Type z) // CHECK-NEXT: odsState.addTypes(x) // CHECK-NEXT: odsState.addTypes(resultType1) // CHECK-NEXT: odsState.addTypes(z) -// CHECK: void OpC::build(Builder *odsBuilder, OperationState &odsState, ArrayRef resultTypes) { +// CHECK: void OpC::build(OpBuilder &odsBuilder, OperationState &odsState, ArrayRef resultTypes) { // CHECK-NEXT: assert(resultTypes.size() == 3u && "mismatched number of results"); // CHECK-NEXT: odsState.addTypes(resultTypes); @@ -49,7 +49,7 @@ } // CHECK-LABEL: OpD definitions -// CHECK: void OpD::build(Builder *odsBuilder, OperationState &odsState, ValueRange operands, ArrayRef attributes) +// CHECK: void OpD::build(OpBuilder &odsBuilder, OperationState &odsState, ValueRange operands, ArrayRef attributes) // CHECK: odsState.addTypes({attr.second.cast().getValue()}); def OpE : NS_Op<"value_attr_as_result_type", [FirstAttrDerivedResultType]> { @@ -58,7 +58,7 @@ } // CHECK-LABEL: OpE definitions -// CHECK: void OpE::build(Builder *odsBuilder, OperationState &odsState, ValueRange operands, ArrayRef attributes) +// CHECK: void OpE::build(OpBuilder &odsBuilder, OperationState &odsState, ValueRange operands, ArrayRef attributes) // CHECK: odsState.addTypes({attr.second.getType()}); def OpF : NS_Op<"one_variadic_result_op", []> { @@ -77,7 +77,7 @@ // CHECK-LABEL: OpG definitions -// CHECK: void OpG::build(Builder *odsBuilder, OperationState &odsState, Type x, ArrayRef y) +// CHECK: void OpG::build(OpBuilder &odsBuilder, OperationState &odsState, Type x, ArrayRef y) // CHECK-NEXT: odsState.addTypes(x); // CHECK-NEXT: odsState.addTypes(y); @@ -109,5 +109,5 @@ let results = (outs AnyTensor:$result); } -// CHECK-LABEL: OpK::build(Builder *odsBuilder, OperationState &odsState, ValueRange input) +// CHECK-LABEL: OpK::build(OpBuilder &odsBuilder, OperationState &odsState, ValueRange input) // CHECK: odsState.addTypes({input.front().getType()}); diff --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp --- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp +++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-gen.cpp @@ -1467,13 +1467,13 @@ let results = (outs Variadic:$output_tensors); let regions = (region SizedRegion<1>:$region); let builders = [OpBuilder< - "Builder *b, OperationState &result, TypeRange outputTypes, " + "OpBuilder &b, OperationState &result, TypeRange outputTypes, " # "ValueRange views", [{{ result.addOperands(views); result.addTypes(outputTypes); buildNamedStructuredOpRegion<{0}>( - *b, result, TypeRange(views), outputTypes); + b, result, TypeRange(views), outputTypes); }]> ]; let parser = [{ diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -743,7 +743,7 @@ // TODO(jpienaar): Expand to handle regions. body << formatv(R"( SmallVector inferredReturnTypes; - if (succeeded({0}::inferReturnTypes(odsBuilder->getContext(), + if (succeeded({0}::inferReturnTypes(odsBuilder.getContext(), {1}.location, {1}.operands, {1}.attributes, /*regions=*/{{}, inferredReturnTypes))) {1}.addTypes(inferredReturnTypes); @@ -800,7 +800,7 @@ // Signature std::string params = - std::string("Builder *odsBuilder, OperationState &") + builderOpState + + std::string("OpBuilder &odsBuilder, OperationState &") + builderOpState + ", ValueRange operands, ArrayRef attributes"; if (op.getNumVariadicRegions()) params += ", unsigned numRegions"; @@ -832,7 +832,7 @@ void OpEmitter::genInferredTypeCollectiveParamBuilder() { // TODO(jpienaar): Expand to support regions. const char *params = - "Builder *odsBuilder, OperationState &{0}, " + "OpBuilder &odsBuilder, OperationState &{0}, " "ValueRange operands, ArrayRef attributes"; auto &m = opClass.newMethod("void", "build", formatv(params, builderOpState).str(), @@ -840,7 +840,7 @@ auto &body = m.body(); body << formatv(R"( SmallVector inferredReturnTypes; - if (succeeded({0}::inferReturnTypes(odsBuilder->getContext(), + if (succeeded({0}::inferReturnTypes(odsBuilder.getContext(), {1}.location, operands, attributes, /*regions=*/{{}, inferredReturnTypes))) build(odsBuilder, odsState, inferredReturnTypes, operands, attributes); @@ -873,7 +873,7 @@ void OpEmitter::genUseAttrAsResultTypeBuilder() { std::string params = - std::string("Builder *odsBuilder, OperationState &") + builderOpState + + std::string("OpBuilder &odsBuilder, OperationState &") + builderOpState + ", ValueRange operands, ArrayRef attributes"; auto &m = opClass.newMethod("void", "build", params, OpMethod::MP_Static); auto &body = m.body(); @@ -965,7 +965,7 @@ int numVariadicOperands = op.getNumVariableLengthOperands(); int numNonVariadicOperands = numOperands - numVariadicOperands; // Signature - std::string params = std::string("Builder *, OperationState &") + + std::string params = std::string("OpBuilder &, OperationState &") + builderOpState + ", ArrayRef resultTypes, ValueRange operands, " "ArrayRef attributes"; @@ -1019,7 +1019,7 @@ auto numResults = op.getNumResults(); resultTypeNames.reserve(numResults); - paramList = "Builder *odsBuilder, OperationState &"; + paramList = "OpBuilder &odsBuilder, OperationState &"; paramList.append(builderOpState); switch (typeParamKind) { @@ -1159,7 +1159,7 @@ if (op.getTrait("OpTrait::AttrSizedOperandSegments")) { body << " " << builderOpState << ".addAttribute(\"operand_segment_sizes\", " - "odsBuilder->getI32VectorAttr({"; + "odsBuilder.getI32VectorAttr({"; interleaveComma(llvm::seq(0, op.getNumOperands()), body, [&](int i) { if (op.getOperand(i).isOptional()) body << "(" << getArgumentName(op, i) << " ? 1 : 0)"; @@ -1183,7 +1183,7 @@ // If this is a raw value, then we need to wrap it in an Attribute // instance. FmtContext fctx; - fctx.withBuilder("(*odsBuilder)"); + fctx.withBuilder("odsBuilder"); std::string builderTemplate = std::string(attr.getConstBuilderTemplate()); diff --git a/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp b/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp --- a/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp +++ b/mlir/unittests/Dialect/SPIRV/SerializationTest.cpp @@ -38,7 +38,7 @@ SerializationTest() { createModuleOp(); } void createModuleOp() { - Builder builder(&context); + OpBuilder builder(&context); OperationState state(UnknownLoc::get(&context), spirv::ModuleOp::getOperationName()); state.addAttribute("addressing_model", @@ -51,7 +51,7 @@ spirv::VerCapExtAttr::get( spirv::Version::V_1_0, ArrayRef(), ArrayRef(), &context)); - spirv::ModuleOp::build(&builder, state); + spirv::ModuleOp::build(builder, state); module = cast(Operation::create(state)); }