[Mlir-commits] [mlir] 2736fbd - [mlir][NFC] update `mlir/lib` create APIs (26/n) (#149933)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Jul 22 05:40:46 PDT 2025
Author: Maksim Levental
Date: 2025-07-22T08:40:42-04:00
New Revision: 2736fbd8324bf21a130c8abd4bd0e7d3aa840ac1
URL: https://github.com/llvm/llvm-project/commit/2736fbd8324bf21a130c8abd4bd0e7d3aa840ac1
DIFF: https://github.com/llvm/llvm-project/commit/2736fbd8324bf21a130c8abd4bd0e7d3aa840ac1.diff
LOG: [mlir][NFC] update `mlir/lib` create APIs (26/n) (#149933)
See https://github.com/llvm/llvm-project/pull/147168 for more info.
---------
Co-authored-by: Tobias Gysi <tobias.gysi at nextsilicon.com>
Added:
Modified:
mlir/lib/IR/BuiltinDialect.cpp
mlir/lib/Query/Query.cpp
mlir/lib/Target/LLVMIR/LLVMImportInterface.cpp
mlir/lib/Target/LLVMIR/ModuleImport.cpp
mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp
mlir/lib/Transforms/Utils/DialectConversion.cpp
Removed:
################################################################################
diff --git a/mlir/lib/IR/BuiltinDialect.cpp b/mlir/lib/IR/BuiltinDialect.cpp
index 6d7e2aa0ece7d..c88b328282275 100644
--- a/mlir/lib/IR/BuiltinDialect.cpp
+++ b/mlir/lib/IR/BuiltinDialect.cpp
@@ -132,7 +132,7 @@ void ModuleOp::build(OpBuilder &builder, OperationState &state,
/// Construct a module from the given context.
ModuleOp ModuleOp::create(Location loc, std::optional<StringRef> name) {
OpBuilder builder(loc->getContext());
- return builder.create<ModuleOp>(loc, name);
+ return ModuleOp::create(builder, loc, name);
}
DataLayoutSpecInterface ModuleOp::getDataLayoutSpec() {
diff --git a/mlir/lib/Query/Query.cpp b/mlir/lib/Query/Query.cpp
index b5a9d2f1d350c..03e4177bbbe24 100644
--- a/mlir/lib/Query/Query.cpp
+++ b/mlir/lib/Query/Query.cpp
@@ -77,7 +77,7 @@ static Operation *extractFunction(std::vector<Operation *> &ops,
clonedOp->result_end());
}
// Add return operation
- builder.create<func::ReturnOp>(loc, clonedVals);
+ func::ReturnOp::create(builder, loc, clonedVals);
// Remove unused function arguments
size_t currentIndex = 0;
diff --git a/mlir/lib/Target/LLVMIR/LLVMImportInterface.cpp b/mlir/lib/Target/LLVMIR/LLVMImportInterface.cpp
index 4e7f1d3185129..580afdddd7078 100644
--- a/mlir/lib/Target/LLVMIR/LLVMImportInterface.cpp
+++ b/mlir/lib/Target/LLVMIR/LLVMImportInterface.cpp
@@ -37,8 +37,8 @@ LogicalResult mlir::LLVMImportInterface::convertUnregisteredIntrinsic(
return failure();
Type resultType = moduleImport.convertType(inst->getType());
- auto op = builder.create<::mlir::LLVM::CallIntrinsicOp>(
- moduleImport.translateLoc(inst->getDebugLoc()),
+ auto op = CallIntrinsicOp::create(
+ builder, moduleImport.translateLoc(inst->getDebugLoc()),
isa<LLVMVoidType>(resultType) ? TypeRange{} : TypeRange{resultType},
StringAttr::get(builder.getContext(), intrinName),
ValueRange{mlirOperands}, FastmathFlagsAttr{});
diff --git a/mlir/lib/Target/LLVMIR/ModuleImport.cpp b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
index c807985756539..94db7f8888129 100644
--- a/mlir/lib/Target/LLVMIR/ModuleImport.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
@@ -185,7 +185,7 @@ ComdatOp ModuleImport::getGlobalComdatOp() {
OpBuilder::InsertionGuard guard(builder);
builder.setInsertionPointToEnd(mlirModule.getBody());
globalComdatOp =
- builder.create<ComdatOp>(mlirModule.getLoc(), getGlobalComdatOpName());
+ ComdatOp::create(builder, mlirModule.getLoc(), getGlobalComdatOpName());
globalInsertionOp = globalComdatOp;
return globalComdatOp;
}
@@ -864,8 +864,8 @@ LogicalResult ModuleImport::convertModuleFlagsMetadata() {
}
if (!moduleFlags.empty())
- builder.create<LLVM::ModuleFlagsOp>(mlirModule.getLoc(),
- builder.getArrayAttr(moduleFlags));
+ LLVM::ModuleFlagsOp::create(builder, mlirModule.getLoc(),
+ builder.getArrayAttr(moduleFlags));
return success();
}
@@ -880,8 +880,8 @@ LogicalResult ModuleImport::convertLinkerOptionsMetadata() {
options.reserve(node->getNumOperands());
for (const llvm::MDOperand &option : node->operands())
options.push_back(cast<llvm::MDString>(option)->getString());
- builder.create<LLVM::LinkerOptionsOp>(mlirModule.getLoc(),
- builder.getStrArrayAttr(options));
+ LLVM::LinkerOptionsOp::create(builder, mlirModule.getLoc(),
+ builder.getStrArrayAttr(options));
}
}
return success();
@@ -984,8 +984,8 @@ void ModuleImport::processComdat(const llvm::Comdat *comdat) {
ComdatOp comdatOp = getGlobalComdatOp();
OpBuilder::InsertionGuard guard(builder);
builder.setInsertionPointToEnd(&comdatOp.getBody().back());
- auto selectorOp = builder.create<ComdatSelectorOp>(
- mlirModule.getLoc(), comdat->getName(),
+ auto selectorOp = ComdatSelectorOp::create(
+ builder, mlirModule.getLoc(), comdat->getName(),
convertComdatFromLLVM(comdat->getSelectionKind()));
auto symbolRef =
SymbolRefAttr::get(builder.getContext(), getGlobalComdatOpName(),
@@ -1356,12 +1356,12 @@ LogicalResult ModuleImport::convertAlias(llvm::GlobalAlias *alias) {
OpBuilder::InsertionGuard guard = setGlobalInsertionPoint();
Type type = convertType(alias->getValueType());
- AliasOp aliasOp = builder.create<AliasOp>(
- mlirModule.getLoc(), type, convertLinkageFromLLVM(alias->getLinkage()),
- alias->getName(),
- /*dso_local=*/alias->isDSOLocal(),
- /*thread_local=*/alias->isThreadLocal(),
- /*attrs=*/ArrayRef<NamedAttribute>());
+ AliasOp aliasOp = AliasOp::create(builder, mlirModule.getLoc(), type,
+ convertLinkageFromLLVM(alias->getLinkage()),
+ alias->getName(),
+ /*dso_local=*/alias->isDSOLocal(),
+ /*thread_local=*/alias->isThreadLocal(),
+ /*attrs=*/ArrayRef<NamedAttribute>());
globalInsertionOp = aliasOp;
clearRegionState();
@@ -1370,7 +1370,7 @@ LogicalResult ModuleImport::convertAlias(llvm::GlobalAlias *alias) {
FailureOr<Value> initializer = convertConstantExpr(alias->getAliasee());
if (failed(initializer))
return failure();
- builder.create<ReturnOp>(aliasOp.getLoc(), *initializer);
+ ReturnOp::create(builder, aliasOp.getLoc(), *initializer);
if (alias->hasAtLeastLocalUnnamedAddr())
aliasOp.setUnnamedAddr(convertUnnamedAddrFromLLVM(alias->getUnnamedAddr()));
@@ -1385,12 +1385,12 @@ LogicalResult ModuleImport::convertIFunc(llvm::GlobalIFunc *ifunc) {
Type type = convertType(ifunc->getValueType());
llvm::Constant *resolver = ifunc->getResolver();
Type resolverType = convertType(resolver->getType());
- builder.create<IFuncOp>(mlirModule.getLoc(), ifunc->getName(), type,
- resolver->getName(), resolverType,
- convertLinkageFromLLVM(ifunc->getLinkage()),
- ifunc->isDSOLocal(), ifunc->getAddressSpace(),
- convertUnnamedAddrFromLLVM(ifunc->getUnnamedAddr()),
- convertVisibilityFromLLVM(ifunc->getVisibility()));
+ IFuncOp::create(builder, mlirModule.getLoc(), ifunc->getName(), type,
+ resolver->getName(), resolverType,
+ convertLinkageFromLLVM(ifunc->getLinkage()),
+ ifunc->isDSOLocal(), ifunc->getAddressSpace(),
+ convertUnnamedAddrFromLLVM(ifunc->getUnnamedAddr()),
+ convertVisibilityFromLLVM(ifunc->getVisibility()));
return success();
}
@@ -1428,8 +1428,8 @@ LogicalResult ModuleImport::convertGlobal(llvm::GlobalVariable *globalVar) {
if (globalName.empty())
globalName = getOrCreateNamelessSymbolName(globalVar).getValue();
- GlobalOp globalOp = builder.create<GlobalOp>(
- mlirModule.getLoc(), type, globalVar->isConstant(),
+ GlobalOp globalOp = GlobalOp::create(
+ builder, mlirModule.getLoc(), type, globalVar->isConstant(),
convertLinkageFromLLVM(globalVar->getLinkage()), StringRef(globalName),
valueAttr, alignment, /*addr_space=*/globalVar->getAddressSpace(),
/*dso_local=*/globalVar->isDSOLocal(),
@@ -1445,7 +1445,7 @@ LogicalResult ModuleImport::convertGlobal(llvm::GlobalVariable *globalVar) {
convertConstantExpr(globalVar->getInitializer());
if (failed(initializer))
return failure();
- builder.create<ReturnOp>(globalOp.getLoc(), *initializer);
+ ReturnOp::create(builder, globalOp.getLoc(), *initializer);
}
if (globalVar->hasAtLeastLocalUnnamedAddr()) {
globalOp.setUnnamedAddr(
@@ -1513,13 +1513,13 @@ ModuleImport::convertGlobalCtorsAndDtors(llvm::GlobalVariable *globalVar) {
OpBuilder::InsertionGuard guard = setGlobalInsertionPoint();
if (globalVar->getName() == getGlobalCtorsVarName()) {
- globalInsertionOp = builder.create<LLVM::GlobalCtorsOp>(
- mlirModule.getLoc(), builder.getArrayAttr(funcs),
+ globalInsertionOp = LLVM::GlobalCtorsOp::create(
+ builder, mlirModule.getLoc(), builder.getArrayAttr(funcs),
builder.getI32ArrayAttr(priorities), builder.getArrayAttr(dataList));
return success();
}
- globalInsertionOp = builder.create<LLVM::GlobalDtorsOp>(
- mlirModule.getLoc(), builder.getArrayAttr(funcs),
+ globalInsertionOp = LLVM::GlobalDtorsOp::create(
+ builder, mlirModule.getLoc(), builder.getArrayAttr(funcs),
builder.getI32ArrayAttr(priorities), builder.getArrayAttr(dataList));
return success();
}
@@ -1594,33 +1594,33 @@ FailureOr<Value> ModuleImport::convertConstant(llvm::Constant *constant) {
if (Attribute attr = getConstantAsAttr(constant)) {
Type type = convertType(constant->getType());
if (auto symbolRef = dyn_cast<FlatSymbolRefAttr>(attr)) {
- return builder.create<AddressOfOp>(loc, type, symbolRef.getValue())
+ return AddressOfOp::create(builder, loc, type, symbolRef.getValue())
.getResult();
}
- return builder.create<ConstantOp>(loc, type, attr).getResult();
+ return ConstantOp::create(builder, loc, type, attr).getResult();
}
// Convert null pointer constants.
if (auto *nullPtr = dyn_cast<llvm::ConstantPointerNull>(constant)) {
Type type = convertType(nullPtr->getType());
- return builder.create<ZeroOp>(loc, type).getResult();
+ return ZeroOp::create(builder, loc, type).getResult();
}
// Convert none token constants.
if (isa<llvm::ConstantTokenNone>(constant)) {
- return builder.create<NoneTokenOp>(loc).getResult();
+ return NoneTokenOp::create(builder, loc).getResult();
}
// Convert poison.
if (auto *poisonVal = dyn_cast<llvm::PoisonValue>(constant)) {
Type type = convertType(poisonVal->getType());
- return builder.create<PoisonOp>(loc, type).getResult();
+ return PoisonOp::create(builder, loc, type).getResult();
}
// Convert undef.
if (auto *undefVal = dyn_cast<llvm::UndefValue>(constant)) {
Type type = convertType(undefVal->getType());
- return builder.create<UndefOp>(loc, type).getResult();
+ return UndefOp::create(builder, loc, type).getResult();
}
// Convert dso_local_equivalent.
@@ -1646,7 +1646,7 @@ FailureOr<Value> ModuleImport::convertConstant(llvm::Constant *constant) {
getOrCreateNamelessSymbolName(cast<llvm::GlobalVariable>(globalObj));
else
symbolRef = FlatSymbolRefAttr::get(context, globalName);
- return builder.create<AddressOfOp>(loc, type, symbolRef).getResult();
+ return AddressOfOp::create(builder, loc, type, symbolRef).getResult();
}
// Convert global alias accesses.
@@ -1654,7 +1654,7 @@ FailureOr<Value> ModuleImport::convertConstant(llvm::Constant *constant) {
Type type = convertType(globalAliasObj->getType());
StringRef aliaseeName = globalAliasObj->getName();
FlatSymbolRefAttr symbolRef = FlatSymbolRefAttr::get(context, aliaseeName);
- return builder.create<AddressOfOp>(loc, type, symbolRef).getResult();
+ return AddressOfOp::create(builder, loc, type, symbolRef).getResult();
}
// Convert constant expressions.
@@ -1705,16 +1705,17 @@ FailureOr<Value> ModuleImport::convertConstant(llvm::Constant *constant) {
bool isArrayOrStruct = isa<LLVMArrayType, LLVMStructType>(rootType);
assert((isArrayOrStruct || LLVM::isCompatibleVectorType(rootType)) &&
"unrecognized aggregate type");
- Value root = builder.create<UndefOp>(loc, rootType);
+ Value root = UndefOp::create(builder, loc, rootType);
for (const auto &it : llvm::enumerate(elementValues)) {
if (isArrayOrStruct) {
- root = builder.create<InsertValueOp>(loc, root, it.value(), it.index());
+ root =
+ InsertValueOp::create(builder, loc, root, it.value(), it.index());
} else {
Attribute indexAttr = builder.getI32IntegerAttr(it.index());
Value indexValue =
- builder.create<ConstantOp>(loc, builder.getI32Type(), indexAttr);
- root = builder.create<InsertElementOp>(loc, rootType, root, it.value(),
- indexValue);
+ ConstantOp::create(builder, loc, builder.getI32Type(), indexAttr);
+ root = InsertElementOp::create(builder, loc, rootType, root, it.value(),
+ indexValue);
}
}
return root;
@@ -1727,7 +1728,7 @@ FailureOr<Value> ModuleImport::convertConstant(llvm::Constant *constant) {
"target extension type does not support zero-initialization");
// Create llvm.mlir.zero operation to represent zero-initialization of
// target extension type.
- return builder.create<LLVM::ZeroOp>(loc, targetExtType).getRes();
+ return LLVM::ZeroOp::create(builder, loc, targetExtType).getRes();
}
if (auto *blockAddr = dyn_cast<llvm::BlockAddress>(constant)) {
@@ -2158,16 +2159,16 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) {
}
if (!brInst->isConditional()) {
- auto brOp = builder.create<LLVM::BrOp>(loc, succBlockArgs.front(),
- succBlocks.front());
+ auto brOp = LLVM::BrOp::create(builder, loc, succBlockArgs.front(),
+ succBlocks.front());
mapNoResultOp(inst, brOp);
return success();
}
FailureOr<Value> condition = convertValue(brInst->getCondition());
if (failed(condition))
return failure();
- auto condBrOp = builder.create<LLVM::CondBrOp>(
- loc, *condition, succBlocks.front(), succBlockArgs.front(),
+ auto condBrOp = LLVM::CondBrOp::create(
+ builder, loc, *condition, succBlocks.front(), succBlockArgs.front(),
succBlocks.back(), succBlockArgs.back());
mapNoResultOp(inst, condBrOp);
return success();
@@ -2200,9 +2201,9 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) {
caseBlocks[it.index()] = lookupBlock(succBB);
}
- auto switchOp = builder.create<SwitchOp>(
- loc, *condition, lookupBlock(defaultBB), defaultBlockArgs, caseValues,
- caseBlocks, caseOperandRefs);
+ auto switchOp = SwitchOp::create(builder, loc, *condition,
+ lookupBlock(defaultBB), defaultBlockArgs,
+ caseValues, caseBlocks, caseOperandRefs);
mapNoResultOp(inst, switchOp);
return success();
}
@@ -2252,14 +2253,14 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) {
// IR). Build the indirect call by passing an empty `callee` operand and
// insert into `operands` to include the indirect call target.
FlatSymbolRefAttr calleeSym = convertCalleeName(callInst);
- Value indirectCallVal = builder.create<LLVM::AddressOfOp>(
- loc, LLVM::LLVMPointerType::get(context), calleeSym);
+ Value indirectCallVal = LLVM::AddressOfOp::create(
+ builder, loc, LLVM::LLVMPointerType::get(context), calleeSym);
operands->insert(operands->begin(), indirectCallVal);
} else {
// Regular direct call using callee name.
callee = convertCalleeName(callInst);
}
- CallOp callOp = builder.create<CallOp>(loc, *funcTy, callee, *operands);
+ CallOp callOp = CallOp::create(builder, loc, *funcTy, callee, *operands);
if (failed(convertCallAttributes(callInst, callOp)))
return failure();
@@ -2294,7 +2295,7 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) {
Type type = convertType(lpInst->getType());
auto lpOp =
- builder.create<LandingpadOp>(loc, type, lpInst->isCleanup(), operands);
+ LandingpadOp::create(builder, loc, type, lpInst->isCleanup(), operands);
mapValue(inst, lpOp);
return success();
}
@@ -2344,8 +2345,8 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) {
// IR). Build the indirect invoke by passing an empty `callee` operand and
// insert into `operands` to include the indirect invoke target.
FlatSymbolRefAttr calleeSym = convertCalleeName(invokeInst);
- Value indirectInvokeVal = builder.create<LLVM::AddressOfOp>(
- loc, LLVM::LLVMPointerType::get(context), calleeSym);
+ Value indirectInvokeVal = LLVM::AddressOfOp::create(
+ builder, loc, LLVM::LLVMPointerType::get(context), calleeSym);
operands->insert(operands->begin(), indirectInvokeVal);
} else {
// Regular direct invoke using callee name.
@@ -2354,9 +2355,9 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) {
// Create the invoke operation. Normal destination block arguments will be
// added later on to handle the case in which the operation result is
// included in this list.
- auto invokeOp = builder.create<InvokeOp>(
- loc, *funcTy, calleeName, *operands, directNormalDest, ValueRange(),
- lookupBlock(invokeInst->getUnwindDest()), unwindArgs);
+ auto invokeOp = InvokeOp::create(
+ builder, loc, *funcTy, calleeName, *operands, directNormalDest,
+ ValueRange(), lookupBlock(invokeInst->getUnwindDest()), unwindArgs);
if (failed(convertInvokeAttributes(invokeInst, invokeOp)))
return failure();
@@ -2382,7 +2383,7 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) {
// arguments (including the invoke operation's result).
OpBuilder::InsertionGuard g(builder);
builder.setInsertionPointToStart(directNormalDest);
- builder.create<LLVM::BrOp>(loc, normalArgs, normalDest);
+ LLVM::BrOp::create(builder, loc, normalArgs, normalDest);
} else {
// If the invoke operation's result is not a block argument to the normal
// destination block, just add the block arguments as usual.
@@ -2416,8 +2417,8 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) {
}
Type type = convertType(inst->getType());
- auto gepOp = builder.create<GEPOp>(
- loc, type, sourceElementType, *basePtr, indices,
+ auto gepOp = GEPOp::create(
+ builder, loc, type, sourceElementType, *basePtr, indices,
static_cast<GEPNoWrapFlags>(gepInst->getNoWrapFlags().getRaw()));
mapValue(inst, gepOp);
return success();
@@ -2443,8 +2444,8 @@ LogicalResult ModuleImport::convertInstruction(llvm::Instruction *inst) {
SmallVector<ValueRange> succBlockArgsRange =
llvm::to_vector_of<ValueRange>(succBlockArgs);
Location loc = translateLoc(inst->getDebugLoc());
- auto indBrOp = builder.create<LLVM::IndirectBrOp>(
- loc, *basePtr, succBlockArgsRange, succBlocks);
+ auto indBrOp = LLVM::IndirectBrOp::create(builder, loc, *basePtr,
+ succBlockArgsRange, succBlocks);
mapNoResultOp(inst, indBrOp);
return success();
@@ -2888,8 +2889,8 @@ LogicalResult ModuleImport::processFunction(llvm::Function *func) {
builder.setInsertionPointToEnd(mlirModule.getBody());
Location loc = debugImporter->translateFuncLocation(func);
- LLVMFuncOp funcOp = builder.create<LLVMFuncOp>(
- loc, func->getName(), functionType,
+ LLVMFuncOp funcOp = LLVMFuncOp::create(
+ builder, loc, func->getName(), functionType,
convertLinkageFromLLVM(func->getLinkage()), dsoLocal, cconv);
convertParameterAttributes(func, funcOp, builder);
@@ -3066,12 +3067,12 @@ ModuleImport::processDebugIntrinsic(llvm::DbgVariableIntrinsic *dbgIntr,
Operation *op =
llvm::TypeSwitch<llvm::DbgVariableIntrinsic *, Operation *>(dbgIntr)
.Case([&](llvm::DbgDeclareInst *) {
- return builder.create<LLVM::DbgDeclareOp>(
- loc, *argOperand, localVariableAttr, locationExprAttr);
+ return LLVM::DbgDeclareOp::create(
+ builder, loc, *argOperand, localVariableAttr, locationExprAttr);
})
.Case([&](llvm::DbgValueInst *) {
- return builder.create<LLVM::DbgValueOp>(
- loc, *argOperand, localVariableAttr, locationExprAttr);
+ return LLVM::DbgValueOp::create(
+ builder, loc, *argOperand, localVariableAttr, locationExprAttr);
});
mapNoResultOp(dbgIntr, op);
setNonDebugMetadataAttrs(dbgIntr, op);
@@ -3116,8 +3117,8 @@ LogicalResult ModuleImport::processBasicBlock(llvm::BasicBlock *bb,
if (bb->hasAddressTaken()) {
OpBuilder::InsertionGuard guard(builder);
builder.setInsertionPointToStart(block);
- builder.create<BlockTagOp>(block->getParentOp()->getLoc(),
- BlockTagAttr::get(context, bb->getNumber()));
+ BlockTagOp::create(builder, block->getParentOp()->getLoc(),
+ BlockTagAttr::get(context, bb->getNumber()));
}
return success();
}
diff --git a/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp b/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
index 9fa03725d05ee..ee18cf815e4a7 100644
--- a/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
+++ b/mlir/lib/Target/SPIRV/Deserialization/DeserializeOps.cpp
@@ -42,37 +42,38 @@ static inline spirv::Opcode extractOpcode(uint32_t word) {
Value spirv::Deserializer::getValue(uint32_t id) {
if (auto constInfo = getConstant(id)) {
// Materialize a `spirv.Constant` op at every use site.
- return opBuilder.create<spirv::ConstantOp>(unknownLoc, constInfo->second,
- constInfo->first);
+ return spirv::ConstantOp::create(opBuilder, unknownLoc, constInfo->second,
+ constInfo->first);
}
if (std::optional<std::pair<Attribute, Type>> constCompositeReplicateInfo =
getConstantCompositeReplicate(id)) {
- return opBuilder.create<spirv::EXTConstantCompositeReplicateOp>(
- unknownLoc, constCompositeReplicateInfo->second,
+ return spirv::EXTConstantCompositeReplicateOp::create(
+ opBuilder, unknownLoc, constCompositeReplicateInfo->second,
constCompositeReplicateInfo->first);
}
if (auto varOp = getGlobalVariable(id)) {
- auto addressOfOp = opBuilder.create<spirv::AddressOfOp>(
- unknownLoc, varOp.getType(), SymbolRefAttr::get(varOp.getOperation()));
+ auto addressOfOp =
+ spirv::AddressOfOp::create(opBuilder, unknownLoc, varOp.getType(),
+ SymbolRefAttr::get(varOp.getOperation()));
return addressOfOp.getPointer();
}
if (auto constOp = getSpecConstant(id)) {
- auto referenceOfOp = opBuilder.create<spirv::ReferenceOfOp>(
- unknownLoc, constOp.getDefaultValue().getType(),
+ auto referenceOfOp = spirv::ReferenceOfOp::create(
+ opBuilder, unknownLoc, constOp.getDefaultValue().getType(),
SymbolRefAttr::get(constOp.getOperation()));
return referenceOfOp.getReference();
}
if (SpecConstantCompositeOp specConstCompositeOp =
getSpecConstantComposite(id)) {
- auto referenceOfOp = opBuilder.create<spirv::ReferenceOfOp>(
- unknownLoc, specConstCompositeOp.getType(),
+ auto referenceOfOp = spirv::ReferenceOfOp::create(
+ opBuilder, unknownLoc, specConstCompositeOp.getType(),
SymbolRefAttr::get(specConstCompositeOp.getOperation()));
return referenceOfOp.getReference();
}
if (auto specConstCompositeReplicateOp =
getSpecConstantCompositeReplicate(id)) {
- auto referenceOfOp = opBuilder.create<spirv::ReferenceOfOp>(
- unknownLoc, specConstCompositeReplicateOp.getType(),
+ auto referenceOfOp = spirv::ReferenceOfOp::create(
+ opBuilder, unknownLoc, specConstCompositeReplicateOp.getType(),
SymbolRefAttr::get(specConstCompositeReplicateOp.getOperation()));
return referenceOfOp.getReference();
}
@@ -83,7 +84,7 @@ Value spirv::Deserializer::getValue(uint32_t id) {
specConstOperationInfo->enclosedOpOperands);
}
if (auto undef = getUndefType(id)) {
- return opBuilder.create<spirv::UndefOp>(unknownLoc, undef);
+ return spirv::UndefOp::create(opBuilder, unknownLoc, undef);
}
return valueMap.lookup(id);
}
@@ -387,8 +388,9 @@ Deserializer::processOp<spirv::EntryPointOp>(ArrayRef<uint32_t> words) {
interface.push_back(SymbolRefAttr::get(arg.getOperation()));
wordIndex++;
}
- opBuilder.create<spirv::EntryPointOp>(
- unknownLoc, execModel, SymbolRefAttr::get(opBuilder.getContext(), fnName),
+ spirv::EntryPointOp::create(
+ opBuilder, unknownLoc, execModel,
+ SymbolRefAttr::get(opBuilder.getContext(), fnName),
opBuilder.getArrayAttr(interface));
return success();
}
@@ -420,9 +422,10 @@ Deserializer::processOp<spirv::ExecutionModeOp>(ArrayRef<uint32_t> words) {
attrListElems.push_back(opBuilder.getI32IntegerAttr(words[wordIndex++]));
}
auto values = opBuilder.getArrayAttr(attrListElems);
- opBuilder.create<spirv::ExecutionModeOp>(
- unknownLoc, SymbolRefAttr::get(opBuilder.getContext(), fn.getName()),
- execMode, values);
+ spirv::ExecutionModeOp::create(
+ opBuilder, unknownLoc,
+ SymbolRefAttr::get(opBuilder.getContext(), fn.getName()), execMode,
+ values);
return success();
}
@@ -459,8 +462,8 @@ Deserializer::processOp<spirv::FunctionCallOp>(ArrayRef<uint32_t> operands) {
arguments.push_back(value);
}
- auto opFunctionCall = opBuilder.create<spirv::FunctionCallOp>(
- unknownLoc, resultType,
+ auto opFunctionCall = spirv::FunctionCallOp::create(
+ opBuilder, unknownLoc, resultType,
SymbolRefAttr::get(opBuilder.getContext(), functionName), arguments);
if (resultType)
@@ -536,7 +539,8 @@ Deserializer::processOp<spirv::CopyMemoryOp>(ArrayRef<uint32_t> words) {
}
Location loc = createFileLineColLoc(opBuilder);
- opBuilder.create<spirv::CopyMemoryOp>(loc, resultTypes, operands, attributes);
+ spirv::CopyMemoryOp::create(opBuilder, loc, resultTypes, operands,
+ attributes);
return success();
}
@@ -567,8 +571,8 @@ LogicalResult Deserializer::processOp<spirv::GenericCastToPtrExplicitOp>(
operands.push_back(arg);
Location loc = createFileLineColLoc(opBuilder);
- Operation *op = opBuilder.create<spirv::GenericCastToPtrExplicitOp>(
- loc, resultTypes, operands);
+ Operation *op = spirv::GenericCastToPtrExplicitOp::create(
+ opBuilder, loc, resultTypes, operands);
valueMap[valueID] = op->getResult(0);
return success();
}
diff --git a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
index d133d0332e271..88799a5ee8d52 100644
--- a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
+++ b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp
@@ -518,8 +518,8 @@ spirv::Deserializer::processFunction(ArrayRef<uint32_t> operands) {
}
std::string fnName = getFunctionSymbol(fnID);
- auto funcOp = opBuilder.create<spirv::FuncOp>(
- unknownLoc, fnName, functionType, fnControl.value());
+ auto funcOp = spirv::FuncOp::create(opBuilder, unknownLoc, fnName,
+ functionType, fnControl.value());
// Processing other function attributes.
if (decorations.count(fnID)) {
for (auto attr : decorations[fnID].getAttrs()) {
@@ -714,8 +714,8 @@ spirv::SpecConstantOp
spirv::Deserializer::createSpecConstant(Location loc, uint32_t resultID,
TypedAttr defaultValue) {
auto symName = opBuilder.getStringAttr(getSpecConstantSymbol(resultID));
- auto op = opBuilder.create<spirv::SpecConstantOp>(unknownLoc, symName,
- defaultValue);
+ auto op = spirv::SpecConstantOp::create(opBuilder, unknownLoc, symName,
+ defaultValue);
if (decorations.count(resultID)) {
for (auto attr : decorations[resultID].getAttrs())
op->setAttr(attr.getName(), attr.getValue());
@@ -790,9 +790,9 @@ spirv::Deserializer::processGlobalVariable(ArrayRef<uint32_t> operands) {
<< wordIndex << " of " << operands.size() << " processed";
}
auto loc = createFileLineColLoc(opBuilder);
- auto varOp = opBuilder.create<spirv::GlobalVariableOp>(
- loc, TypeAttr::get(type), opBuilder.getStringAttr(variableName),
- initializer);
+ auto varOp = spirv::GlobalVariableOp::create(
+ opBuilder, loc, TypeAttr::get(type),
+ opBuilder.getStringAttr(variableName), initializer);
// Decorations.
if (decorations.count(variableID)) {
@@ -1637,8 +1637,8 @@ spirv::Deserializer::processSpecConstantComposite(ArrayRef<uint32_t> operands) {
elements.push_back(SymbolRefAttr::get(elementInfo));
}
- auto op = opBuilder.create<spirv::SpecConstantCompositeOp>(
- unknownLoc, TypeAttr::get(resultType), symName,
+ auto op = spirv::SpecConstantCompositeOp::create(
+ opBuilder, unknownLoc, TypeAttr::get(resultType), symName,
opBuilder.getArrayAttr(elements));
specConstCompositeMap[resultID] = op;
@@ -1671,8 +1671,8 @@ LogicalResult spirv::Deserializer::processSpecConstantCompositeReplicateEXT(
auto symName = opBuilder.getStringAttr(getSpecConstantSymbol(resultID));
spirv::SpecConstantOp constituentSpecConstantOp =
getSpecConstant(operands[2]);
- auto op = opBuilder.create<spirv::EXTSpecConstantCompositeReplicateOp>(
- unknownLoc, TypeAttr::get(resultType), symName,
+ auto op = spirv::EXTSpecConstantCompositeReplicateOp::create(
+ opBuilder, unknownLoc, TypeAttr::get(resultType), symName,
SymbolRefAttr::get(constituentSpecConstantOp));
specConstCompositeReplicateMap[resultID] = op;
@@ -1747,7 +1747,7 @@ Value spirv::Deserializer::materializeSpecConstantOperation(
auto loc = createFileLineColLoc(opBuilder);
auto specConstOperationOp =
- opBuilder.create<spirv::SpecConstantOperationOp>(loc, resultType);
+ spirv::SpecConstantOperationOp::create(opBuilder, loc, resultType);
Region &body = specConstOperationOp.getBody();
// Move the new block into SpecConstantOperation's body.
@@ -1760,7 +1760,7 @@ Value spirv::Deserializer::materializeSpecConstantOperation(
OpBuilder::InsertionGuard moduleInsertionGuard(opBuilder);
opBuilder.setInsertionPointToEnd(&block);
- opBuilder.create<spirv::YieldOp>(loc, block.front().getResult(0));
+ spirv::YieldOp::create(opBuilder, loc, block.front().getResult(0));
return specConstOperationOp.getResult();
}
@@ -1824,7 +1824,7 @@ LogicalResult spirv::Deserializer::processBranch(ArrayRef<uint32_t> operands) {
// The preceding instruction for the OpBranch instruction could be an
// OpLoopMerge or an OpSelectionMerge instruction, in this case they will have
// the same OpLine information.
- opBuilder.create<spirv::BranchOp>(loc, target);
+ spirv::BranchOp::create(opBuilder, loc, target);
clearDebugLine();
return success();
@@ -1855,8 +1855,8 @@ spirv::Deserializer::processBranchConditional(ArrayRef<uint32_t> operands) {
// an OpSelectionMerge instruction, in this case they will have the same
// OpLine information.
auto loc = createFileLineColLoc(opBuilder);
- opBuilder.create<spirv::BranchConditionalOp>(
- loc, condition, trueBlock,
+ spirv::BranchConditionalOp::create(
+ opBuilder, loc, condition, trueBlock,
/*trueArguments=*/ArrayRef<Value>(), falseBlock,
/*falseArguments=*/ArrayRef<Value>(), weights);
@@ -2038,7 +2038,7 @@ ControlFlowStructurizer::createSelectionOp(uint32_t selectionControl) {
OpBuilder builder(&mergeBlock->front());
auto control = static_cast<spirv::SelectionControl>(selectionControl);
- auto selectionOp = builder.create<spirv::SelectionOp>(location, control);
+ auto selectionOp = spirv::SelectionOp::create(builder, location, control);
selectionOp.addMergeBlock(builder);
return selectionOp;
@@ -2050,7 +2050,7 @@ spirv::LoopOp ControlFlowStructurizer::createLoopOp(uint32_t loopControl) {
OpBuilder builder(&mergeBlock->front());
auto control = static_cast<spirv::LoopControl>(loopControl);
- auto loopOp = builder.create<spirv::LoopOp>(location, control);
+ auto loopOp = spirv::LoopOp::create(builder, location, control);
loopOp.addEntryAndMergeBlock(builder);
return loopOp;
@@ -2183,8 +2183,8 @@ LogicalResult ControlFlowStructurizer::structurize() {
// The loop entry block should have a unconditional branch jumping to the
// loop header block.
builder.setInsertionPointToEnd(&body.front());
- builder.create<spirv::BranchOp>(location, mapper.lookupOrNull(headerBlock),
- ArrayRef<Value>(blockArgs));
+ spirv::BranchOp::create(builder, location, mapper.lookupOrNull(headerBlock),
+ ArrayRef<Value>(blockArgs));
}
// Values defined inside the selection region that need to be yielded outside
@@ -2268,12 +2268,12 @@ LogicalResult ControlFlowStructurizer::structurize() {
Operation *newOp = nullptr;
if (isLoop)
- newOp = builder.create<spirv::LoopOp>(
- location, TypeRange(ValueRange(outsideUses)),
- static_cast<spirv::LoopControl>(control));
+ newOp = spirv::LoopOp::create(builder, location,
+ TypeRange(ValueRange(outsideUses)),
+ static_cast<spirv::LoopControl>(control));
else
- newOp = builder.create<spirv::SelectionOp>(
- location, TypeRange(ValueRange(outsideUses)),
+ newOp = spirv::SelectionOp::create(
+ builder, location, TypeRange(ValueRange(outsideUses)),
static_cast<spirv::SelectionControl>(control));
newOp->getRegion(0).takeBody(body);
@@ -2399,7 +2399,7 @@ LogicalResult ControlFlowStructurizer::structurize() {
// but replace all ops inside with a branch to the merge block.
block->clear();
builder.setInsertionPointToEnd(block);
- builder.create<spirv::BranchOp>(location, mergeBlock);
+ spirv::BranchOp::create(builder, location, mergeBlock);
} else {
LLVM_DEBUG(logger.startLine() << "[cf] erasing block " << block << "\n");
block->erase();
@@ -2453,22 +2453,22 @@ LogicalResult spirv::Deserializer::wireUpBlockArgument() {
if (auto branchOp = dyn_cast<spirv::BranchOp>(op)) {
// Replace the previous branch op with a new one with block arguments.
- opBuilder.create<spirv::BranchOp>(branchOp.getLoc(), branchOp.getTarget(),
- blockArgs);
+ spirv::BranchOp::create(opBuilder, branchOp.getLoc(),
+ branchOp.getTarget(), blockArgs);
branchOp.erase();
} else if (auto branchCondOp = dyn_cast<spirv::BranchConditionalOp>(op)) {
assert((branchCondOp.getTrueBlock() == target ||
branchCondOp.getFalseBlock() == target) &&
"expected target to be either the true or false target");
if (target == branchCondOp.getTrueTarget())
- opBuilder.create<spirv::BranchConditionalOp>(
- branchCondOp.getLoc(), branchCondOp.getCondition(), blockArgs,
- branchCondOp.getFalseBlockArguments(),
+ spirv::BranchConditionalOp::create(
+ opBuilder, branchCondOp.getLoc(), branchCondOp.getCondition(),
+ blockArgs, branchCondOp.getFalseBlockArguments(),
branchCondOp.getBranchWeightsAttr(), branchCondOp.getTrueTarget(),
branchCondOp.getFalseTarget());
else
- opBuilder.create<spirv::BranchConditionalOp>(
- branchCondOp.getLoc(), branchCondOp.getCondition(),
+ spirv::BranchConditionalOp::create(
+ opBuilder, branchCondOp.getLoc(), branchCondOp.getCondition(),
branchCondOp.getTrueBlockArguments(), blockArgs,
branchCondOp.getBranchWeightsAttr(), branchCondOp.getTrueBlock(),
branchCondOp.getFalseBlock());
@@ -2528,7 +2528,7 @@ LogicalResult spirv::Deserializer::splitConditionalBlocks() {
if (!llvm::hasSingleElement(*block) || splitHeaderMergeBlock) {
Block *newBlock = block->splitBlock(terminator);
OpBuilder builder(block, block->end());
- builder.create<spirv::BranchOp>(block->getParent()->getLoc(), newBlock);
+ spirv::BranchOp::create(builder, block->getParent()->getLoc(), newBlock);
// After splitting we need to update the map to use the new block as a
// header.
diff --git a/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp b/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp
index 824201d17b5ab..0677828b635d4 100644
--- a/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp
+++ b/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp
@@ -134,7 +134,7 @@ class CodeGen {
OwningOpRef<ModuleOp> CodeGen::generate(const ast::Module &module) {
OwningOpRef<ModuleOp> mlirModule =
- builder.create<ModuleOp>(genLoc(module.getLoc()));
+ ModuleOp::create(builder, genLoc(module.getLoc()));
builder.setInsertionPointToStart(mlirModule->getBody());
// Generate code for each of the decls within the module.
@@ -205,8 +205,8 @@ static void checkAndNestUnderRewriteOp(OpBuilder &builder, Value rootExpr,
Location loc) {
if (isa<pdl::PatternOp>(builder.getInsertionBlock()->getParentOp())) {
pdl::RewriteOp rewrite =
- builder.create<pdl::RewriteOp>(loc, rootExpr, /*name=*/StringAttr(),
- /*externalArgs=*/ValueRange());
+ pdl::RewriteOp::create(builder, loc, rootExpr, /*name=*/StringAttr(),
+ /*externalArgs=*/ValueRange());
builder.createBlock(&rewrite.getBodyRegion());
}
}
@@ -219,7 +219,7 @@ void CodeGen::genImpl(const ast::EraseStmt *stmt) {
// Make sure we are nested in a RewriteOp.
OpBuilder::InsertionGuard guard(builder);
checkAndNestUnderRewriteOp(builder, rootExpr, loc);
- builder.create<pdl::EraseOp>(loc, rootExpr);
+ pdl::EraseOp::create(builder, loc, rootExpr);
}
void CodeGen::genImpl(const ast::LetStmt *stmt) { genVar(stmt->getVarDecl()); }
@@ -242,8 +242,8 @@ void CodeGen::genImpl(const ast::ReplaceStmt *stmt) {
bool usesReplOperation =
replValues.size() == 1 &&
isa<pdl::OperationType>(replValues.front().getType());
- builder.create<pdl::ReplaceOp>(
- loc, rootExpr, usesReplOperation ? replValues[0] : Value(),
+ pdl::ReplaceOp::create(
+ builder, loc, rootExpr, usesReplOperation ? replValues[0] : Value(),
usesReplOperation ? ValueRange() : ValueRange(replValues));
}
@@ -283,8 +283,8 @@ void CodeGen::genImpl(const ast::PatternDecl *decl) {
// FIXME: Properly model HasBoundedRecursion in PDL so that we don't drop it
// here.
- pdl::PatternOp pattern = builder.create<pdl::PatternOp>(
- genLoc(decl->getLoc()), decl->getBenefit(),
+ pdl::PatternOp pattern = pdl::PatternOp::create(
+ builder, genLoc(decl->getLoc()), decl->getBenefit(),
name ? std::optional<StringRef>(name->getName())
: std::optional<StringRef>());
@@ -338,30 +338,31 @@ Value CodeGen::genNonInitializerVar(const ast::VariableDecl *varDecl,
ast::Type type = varDecl->getType();
Type mlirType = genType(type);
if (isa<ast::ValueType>(type))
- return builder.create<pdl::OperandOp>(loc, mlirType, getTypeConstraint());
+ return pdl::OperandOp::create(builder, loc, mlirType, getTypeConstraint());
if (isa<ast::TypeType>(type))
- return builder.create<pdl::TypeOp>(loc, mlirType, /*type=*/TypeAttr());
+ return pdl::TypeOp::create(builder, loc, mlirType, /*type=*/TypeAttr());
if (isa<ast::AttributeType>(type))
- return builder.create<pdl::AttributeOp>(loc, getTypeConstraint());
+ return pdl::AttributeOp::create(builder, loc, getTypeConstraint());
if (ast::OperationType opType = dyn_cast<ast::OperationType>(type)) {
- Value operands = builder.create<pdl::OperandsOp>(
- loc, pdl::RangeType::get(builder.getType<pdl::ValueType>()),
+ Value operands = pdl::OperandsOp::create(
+ builder, loc, pdl::RangeType::get(builder.getType<pdl::ValueType>()),
/*type=*/Value());
- Value results = builder.create<pdl::TypesOp>(
- loc, pdl::RangeType::get(builder.getType<pdl::TypeType>()),
+ Value results = pdl::TypesOp::create(
+ builder, loc, pdl::RangeType::get(builder.getType<pdl::TypeType>()),
/*types=*/ArrayAttr());
- return builder.create<pdl::OperationOp>(loc, opType.getName(), operands,
- ArrayRef<StringRef>(), ValueRange(),
- results);
+ return pdl::OperationOp::create(builder, loc, opType.getName(), operands,
+ ArrayRef<StringRef>(), ValueRange(),
+ results);
}
if (ast::RangeType rangeTy = dyn_cast<ast::RangeType>(type)) {
ast::Type eleTy = rangeTy.getElementType();
if (isa<ast::ValueType>(eleTy))
- return builder.create<pdl::OperandsOp>(loc, mlirType,
- getTypeConstraint());
+ return pdl::OperandsOp::create(builder, loc, mlirType,
+ getTypeConstraint());
if (isa<ast::TypeType>(eleTy))
- return builder.create<pdl::TypesOp>(loc, mlirType, /*types=*/ArrayAttr());
+ return pdl::TypesOp::create(builder, loc, mlirType,
+ /*types=*/ArrayAttr());
}
llvm_unreachable("invalid non-initialized variable type");
@@ -404,7 +405,7 @@ SmallVector<Value> CodeGen::genExpr(const ast::Expr *expr) {
Value CodeGen::genExprImpl(const ast::AttributeExpr *expr) {
Attribute attr = parseAttribute(expr->getValue(), builder.getContext());
assert(attr && "invalid MLIR attribute data");
- return builder.create<pdl::AttributeOp>(genLoc(expr->getLoc()), attr);
+ return pdl::AttributeOp::create(builder, genLoc(expr->getLoc()), attr);
}
SmallVector<Value> CodeGen::genExprImpl(const ast::CallExpr *expr) {
@@ -443,9 +444,9 @@ Value CodeGen::genExprImpl(const ast::MemberAccessExpr *expr) {
if (isa<ast::AllResultsMemberAccessExpr>(expr)) {
Type mlirType = genType(expr->getType());
if (isa<pdl::ValueType>(mlirType))
- return builder.create<pdl::ResultOp>(loc, mlirType, parentExprs[0],
- builder.getI32IntegerAttr(0));
- return builder.create<pdl::ResultsOp>(loc, mlirType, parentExprs[0]);
+ return pdl::ResultOp::create(builder, loc, mlirType, parentExprs[0],
+ builder.getI32IntegerAttr(0));
+ return pdl::ResultsOp::create(builder, loc, mlirType, parentExprs[0]);
}
const ods::Operation *odsOp = opType.getODSOperation();
@@ -455,8 +456,8 @@ Value CodeGen::genExprImpl(const ast::MemberAccessExpr *expr) {
unsigned resultIndex;
name.getAsInteger(/*Radix=*/10, resultIndex);
IntegerAttr index = builder.getI32IntegerAttr(resultIndex);
- return builder.create<pdl::ResultOp>(loc, genType(expr->getType()),
- parentExprs[0], index);
+ return pdl::ResultOp::create(builder, loc, genType(expr->getType()),
+ parentExprs[0], index);
}
// Find the result with the member name or by index.
@@ -474,8 +475,8 @@ Value CodeGen::genExprImpl(const ast::MemberAccessExpr *expr) {
// Generate the result access.
IntegerAttr index = builder.getI32IntegerAttr(resultIndex);
- return builder.create<pdl::ResultsOp>(loc, genType(expr->getType()),
- parentExprs[0], index);
+ return pdl::ResultsOp::create(builder, loc, genType(expr->getType()),
+ parentExprs[0], index);
}
// Handle tuple based member access.
@@ -518,8 +519,8 @@ Value CodeGen::genExprImpl(const ast::OperationExpr *expr) {
for (const ast::Expr *result : expr->getResultTypes())
results.push_back(genSingleExpr(result));
- return builder.create<pdl::OperationOp>(loc, opName, operands, attrNames,
- attrValues, results);
+ return pdl::OperationOp::create(builder, loc, opName, operands, attrNames,
+ attrValues, results);
}
Value CodeGen::genExprImpl(const ast::RangeExpr *expr) {
@@ -527,8 +528,8 @@ Value CodeGen::genExprImpl(const ast::RangeExpr *expr) {
for (const ast::Expr *element : expr->getElements())
llvm::append_range(elements, genExpr(element));
- return builder.create<pdl::RangeOp>(genLoc(expr->getLoc()),
- genType(expr->getType()), elements);
+ return pdl::RangeOp::create(builder, genLoc(expr->getLoc()),
+ genType(expr->getType()), elements);
}
SmallVector<Value> CodeGen::genExprImpl(const ast::TupleExpr *expr) {
@@ -541,9 +542,9 @@ SmallVector<Value> CodeGen::genExprImpl(const ast::TupleExpr *expr) {
Value CodeGen::genExprImpl(const ast::TypeExpr *expr) {
Type type = parseType(expr->getValue(), builder.getContext());
assert(type && "invalid MLIR type data");
- return builder.create<pdl::TypeOp>(genLoc(expr->getLoc()),
- builder.getType<pdl::TypeType>(),
- TypeAttr::get(type));
+ return pdl::TypeOp::create(builder, genLoc(expr->getLoc()),
+ builder.getType<pdl::TypeType>(),
+ TypeAttr::get(type));
}
SmallVector<Value>
@@ -586,8 +587,8 @@ CodeGen::genConstraintOrRewriteCall(const T *decl, Location loc,
} else {
resultTypes.push_back(genType(declResultType));
}
- PDLOpT pdlOp = builder.create<PDLOpT>(loc, resultTypes,
- decl->getName().getName(), inputs);
+ PDLOpT pdlOp = PDLOpT::create(builder, loc, resultTypes,
+ decl->getName().getName(), inputs);
if (isNegated && std::is_same_v<PDLOpT, pdl::ApplyNativeConstraintOp>)
cast<pdl::ApplyNativeConstraintOp>(pdlOp).setIsNegated(true);
return pdlOp->getResults();
diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 4c4ce3cb41fd5..d224f732a198b 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -1502,7 +1502,7 @@ ValueRange ConversionPatternRewriterImpl::buildUnresolvedMaterialization(
OpBuilder builder(outputTypes.front().getContext());
builder.setInsertionPoint(ip.getBlock(), ip.getPoint());
auto convertOp =
- builder.create<UnrealizedConversionCastOp>(loc, outputTypes, inputs);
+ UnrealizedConversionCastOp::create(builder, loc, outputTypes, inputs);
if (!valuesToMap.empty())
mapping.map(valuesToMap, convertOp.getResults());
if (castOp)
More information about the Mlir-commits
mailing list