Skip to content

Commit 2d4e9ba

Browse files
author
Razvan Lupusoru
committed
Use varType instead of var in createAndPopulate
1 parent a12edd1 commit 2d4e9ba

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ def OpenACC_PrivateRecipeOp
13281328
::mlir::OpBuilder &builder,
13291329
::mlir::Location loc,
13301330
::llvm::StringRef recipeName,
1331-
::mlir::Value var,
1331+
::mlir::Type varType,
13321332
::llvm::StringRef varName = "",
13331333
::mlir::ValueRange bounds = {});
13341334
}];
@@ -1438,7 +1438,7 @@ def OpenACC_FirstprivateRecipeOp
14381438
::mlir::OpBuilder &builder,
14391439
::mlir::Location loc,
14401440
::llvm::StringRef recipeName,
1441-
::mlir::Value var,
1441+
::mlir::Type varType,
14421442
::llvm::StringRef varName = "",
14431443
::mlir::ValueRange bounds = {});
14441444
}];

mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,8 +1019,8 @@ struct RemoveConstantIfConditionWithRegion : public OpRewritePattern<OpTy> {
10191019
/// Returns the init block on success, or nullptr on failure.
10201020
/// Sets needsFree to indicate if the allocated memory requires deallocation.
10211021
static std::unique_ptr<Block> createInitRegion(OpBuilder &builder, Location loc,
1022-
Value var, StringRef varName,
1023-
ValueRange bounds, Type varType,
1022+
Type varType, StringRef varName,
1023+
ValueRange bounds,
10241024
bool &needsFree) {
10251025
// Create init block with arguments: original value + bounds
10261026
SmallVector<Type> argTypes{varType};
@@ -1070,8 +1070,8 @@ static std::unique_ptr<Block> createInitRegion(OpBuilder &builder, Location loc,
10701070
/// Returns the copy block on success, or nullptr on failure.
10711071
/// TODO: Handle MappableType - it does not yet have a copy API.
10721072
static std::unique_ptr<Block> createCopyRegion(OpBuilder &builder, Location loc,
1073-
ValueRange bounds,
1074-
Type varType) {
1073+
Type varType,
1074+
ValueRange bounds) {
10751075
// Create copy block with arguments: original value + privatized value +
10761076
// bounds
10771077
SmallVector<Type> copyArgTypes{varType, varType};
@@ -1114,9 +1114,9 @@ static std::unique_ptr<Block> createCopyRegion(OpBuilder &builder, Location loc,
11141114
/// Create and populate a destroy region for privatization recipes.
11151115
/// Returns the destroy block on success, or nullptr if not needed.
11161116
static std::unique_ptr<Block> createDestroyRegion(OpBuilder &builder,
1117-
Location loc, Value allocRes,
1118-
ValueRange bounds,
1119-
Type varType) {
1117+
Location loc, Type varType,
1118+
Value allocRes,
1119+
ValueRange bounds) {
11201120
// Create destroy block with arguments: original value + privatized value +
11211121
// bounds
11221122
SmallVector<Type> destroyArgTypes{varType, varType};
@@ -1199,7 +1199,7 @@ LogicalResult acc::PrivateRecipeOp::verifyRegions() {
11991199

12001200
std::optional<PrivateRecipeOp>
12011201
PrivateRecipeOp::createAndPopulate(OpBuilder &builder, Location loc,
1202-
StringRef recipeName, Value var,
1202+
StringRef recipeName, Type varType,
12031203
StringRef varName, ValueRange bounds) {
12041204

12051205
// Check if a symbol with this name already exists in the symbol table.
@@ -1210,8 +1210,6 @@ PrivateRecipeOp::createAndPopulate(OpBuilder &builder, Location loc,
12101210
parentOp, mlir::StringAttr::get(builder.getContext(), varName)))
12111211
return std::nullopt;
12121212

1213-
Type varType = var.getType();
1214-
12151213
// First, validate that we can handle this variable type
12161214
bool isMappable = isa<MappableType>(varType);
12171215
bool isPointerLike = isa<PointerLikeType>(varType);
@@ -1228,7 +1226,7 @@ PrivateRecipeOp::createAndPopulate(OpBuilder &builder, Location loc,
12281226

12291227
bool needsFree = false;
12301228
auto initBlock =
1231-
createInitRegion(builder, loc, var, varName, bounds, varType, needsFree);
1229+
createInitRegion(builder, loc, varType, varName, bounds, needsFree);
12321230
if (!initBlock)
12331231
return std::nullopt;
12341232

@@ -1239,7 +1237,7 @@ PrivateRecipeOp::createAndPopulate(OpBuilder &builder, Location loc,
12391237
auto yieldOp = cast<acc::YieldOp>(initBlock->getTerminator());
12401238
Value allocRes = yieldOp.getOperand(0);
12411239

1242-
destroyBlock = createDestroyRegion(builder, loc, allocRes, bounds, varType);
1240+
destroyBlock = createDestroyRegion(builder, loc, varType, allocRes, bounds);
12431241
if (!destroyBlock)
12441242
return std::nullopt;
12451243
}
@@ -1289,7 +1287,7 @@ LogicalResult acc::FirstprivateRecipeOp::verifyRegions() {
12891287

12901288
std::optional<FirstprivateRecipeOp>
12911289
FirstprivateRecipeOp::createAndPopulate(OpBuilder &builder, Location loc,
1292-
StringRef recipeName, Value var,
1290+
StringRef recipeName, Type varType,
12931291
StringRef varName, ValueRange bounds) {
12941292

12951293
// Check if a symbol with this name already exists in the symbol table.
@@ -1300,8 +1298,6 @@ FirstprivateRecipeOp::createAndPopulate(OpBuilder &builder, Location loc,
13001298
parentOp, mlir::StringAttr::get(builder.getContext(), varName)))
13011299
return std::nullopt;
13021300

1303-
Type varType = var.getType();
1304-
13051301
// First, validate that we can handle this variable type
13061302
bool isMappable = isa<MappableType>(varType);
13071303
bool isPointerLike = isa<PointerLikeType>(varType);
@@ -1318,11 +1314,11 @@ FirstprivateRecipeOp::createAndPopulate(OpBuilder &builder, Location loc,
13181314

13191315
bool needsFree = false;
13201316
auto initBlock =
1321-
createInitRegion(builder, loc, var, varName, bounds, varType, needsFree);
1317+
createInitRegion(builder, loc, varType, varName, bounds, needsFree);
13221318
if (!initBlock)
13231319
return std::nullopt;
13241320

1325-
auto copyBlock = createCopyRegion(builder, loc, bounds, varType);
1321+
auto copyBlock = createCopyRegion(builder, loc, varType, bounds);
13261322
if (!copyBlock)
13271323
return std::nullopt;
13281324

@@ -1333,7 +1329,7 @@ FirstprivateRecipeOp::createAndPopulate(OpBuilder &builder, Location loc,
13331329
auto yieldOp = cast<acc::YieldOp>(initBlock->getTerminator());
13341330
Value allocRes = yieldOp.getOperand(0);
13351331

1336-
destroyBlock = createDestroyRegion(builder, loc, allocRes, bounds, varType);
1332+
destroyBlock = createDestroyRegion(builder, loc, varType, allocRes, bounds);
13371333
if (!destroyBlock)
13381334
return std::nullopt;
13391335
}

mlir/test/lib/Dialect/OpenACC/TestRecipePopulate.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ void TestRecipePopulatePass::runOnOperation() {
8080
ValueRange bounds; // No bounds for memref tests
8181

8282
if (recipeType == "private") {
83-
auto recipe = PrivateRecipeOp::createAndPopulate(builder, loc, recipeName,
84-
var, varName, bounds);
83+
auto recipe = PrivateRecipeOp::createAndPopulate(
84+
builder, loc, recipeName, var.getType(), varName, bounds);
8585

8686
if (!recipe) {
8787
op->emitError("Failed to create private recipe for ") << varName;
8888
}
8989
} else if (recipeType == "firstprivate") {
9090
auto recipe = FirstprivateRecipeOp::createAndPopulate(
91-
builder, loc, recipeName, var, varName, bounds);
91+
builder, loc, recipeName, var.getType(), varName, bounds);
9292

9393
if (!recipe) {
9494
op->emitError("Failed to create firstprivate recipe for ") << varName;

0 commit comments

Comments
 (0)