Skip to content

[flang][cuda][NFC] Update to the new create APIs #152050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions flang/lib/Lower/Allocatable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,11 @@ class AllocateStmtHelper {

// Keep return type the same as a standard AllocatableAllocate call.
mlir::Type retTy = fir::runtime::getModel<int>()(builder.getContext());
return builder
.create<cuf::AllocateOp>(
loc, retTy, box.getAddr(), errmsg, stream, pinned, source, cudaAttr,
errorManager.hasStatSpec() ? builder.getUnitAttr() : nullptr)

return cuf::AllocateOp::create(
builder, loc, retTy, box.getAddr(), errmsg, stream, pinned,
source, cudaAttr,
errorManager.hasStatSpec() ? builder.getUnitAttr() : nullptr)
.getResult();
}

Expand Down Expand Up @@ -840,10 +841,9 @@ static mlir::Value genCudaDeallocate(fir::FirOpBuilder &builder,

// Keep return type the same as a standard AllocatableAllocate call.
mlir::Type retTy = fir::runtime::getModel<int>()(builder.getContext());
return builder
.create<cuf::DeallocateOp>(
loc, retTy, box.getAddr(), errmsg, cudaAttr,
errorManager.hasStatSpec() ? builder.getUnitAttr() : nullptr)
return cuf::DeallocateOp::create(
builder, loc, retTy, box.getAddr(), errmsg, cudaAttr,
errorManager.hasStatSpec() ? builder.getUnitAttr() : nullptr)
.getResult();
}

Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Lower/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3436,8 +3436,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
}
}

auto op = builder->create<cuf::KernelOp>(
loc, gridValues, blockValues, streamAddr, lbs, ubs, steps, n,
auto op = cuf::KernelOp::create(
*builder, loc, gridValues, blockValues, streamAddr, lbs, ubs, steps, n,
mlir::ValueRange(reduceOperands), builder->getArrayAttr(reduceAttrs));
builder->createBlock(&op.getRegion(), op.getRegion().end(), ivTypes,
ivLocs);
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Lower/ConvertVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ static void instantiateLocal(Fortran::lower::AbstractConverter &converter,
cuf::DataAttributeAttr dataAttr =
Fortran::lower::translateSymbolCUFDataAttribute(
builder->getContext(), *sym);
builder->create<cuf::FreeOp>(loc, fir::getBase(exv), dataAttr);
cuf::FreeOp::create(*builder, loc, fir::getBase(exv), dataAttr);
});
}
}
Expand Down
5 changes: 3 additions & 2 deletions flang/lib/Optimizer/Builder/FIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,9 @@ mlir::Value fir::FirOpBuilder::createTemporaryAlloc(
getRegion().getParentOfType<mlir::omp::OutlineableOpenMPOpInterface>();
if (cudaAttr) {
cuf::DataAttributeAttr attr = cuf::getDataAttribute(getContext(), cudaAttr);
return create<cuf::AllocOp>(loc, type, /*unique_name=*/llvm::StringRef{},
name, attr, lenParams, shape, attrs);
return cuf::AllocOp::create(*this, loc, type,
/*unique_name=*/llvm::StringRef{}, name, attr,
lenParams, shape, attrs);
} else {
return create<fir::AllocaOp>(loc, type, /*unique_name=*/llvm::StringRef{},
name, pinned, lenParams, shape, attrs);
Expand Down
7 changes: 3 additions & 4 deletions flang/lib/Optimizer/Transforms/CUFOpConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,10 +860,9 @@ struct CUFLaunchOpConversion
if (auto global = symTab.lookup<fir::GlobalOp>(
addrOfOp.getSymbol().getRootReference().getValue())) {
if (cuf::isRegisteredDeviceGlobal(global)) {
arg = rewriter
.create<cuf::DeviceAddressOp>(op.getLoc(),
addrOfOp.getType(),
addrOfOp.getSymbol())
arg = cuf::DeviceAddressOp::create(rewriter, op.getLoc(),
addrOfOp.getType(),
addrOfOp.getSymbol())
.getResult();
}
}
Expand Down