[clang] [mlir] [mlir][acc] Use consistent name for device_num operand (PR #136745)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 22 12:51:25 PDT 2025
https://github.com/erichkeane updated https://github.com/llvm/llvm-project/pull/136745
>From 82a81a4572f23bff9291f2c42409edbfb409776b Mon Sep 17 00:00:00 2001
From: Razvan Lupusoru <rlupusoru at nvidia.com>
Date: Tue, 22 Apr 2025 11:49:27 -0700
Subject: [PATCH 1/2] [mlir][acc] Use consistent name for device_num operand
`acc.set`, `acc.init`, and `acc.shutdown` take a `device_num` operand.
However, this was named inconsistently. Give it the same consistent
name for all aforementioned operations.
---
mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
index 275472bc5edd9..5e249e639d837 100644
--- a/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
+++ b/mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
@@ -2611,11 +2611,11 @@ def OpenACC_InitOp : OpenACC_Op<"init", [AttrSizedOperandSegments]> {
}];
let arguments = (ins OptionalAttr<TypedArrayAttrBase<OpenACC_DeviceTypeAttr, "Device type attributes">>:$device_types,
- Optional<IntOrIndex>:$deviceNumOperand,
+ Optional<IntOrIndex>:$deviceNum,
Optional<I1>:$ifCond);
let assemblyFormat = [{
- oilist(`device_num` `(` $deviceNumOperand `:` type($deviceNumOperand) `)`
+ oilist(`device_num` `(` $deviceNum `:` type($deviceNum) `)`
| `if` `(` $ifCond `)`
) attr-dict-with-keyword
}];
@@ -2642,11 +2642,11 @@ def OpenACC_ShutdownOp : OpenACC_Op<"shutdown", [AttrSizedOperandSegments]> {
}];
let arguments = (ins OptionalAttr<TypedArrayAttrBase<OpenACC_DeviceTypeAttr, "Device type attributes">>:$device_types,
- Optional<IntOrIndex>:$deviceNumOperand,
+ Optional<IntOrIndex>:$deviceNum,
Optional<I1>:$ifCond);
let assemblyFormat = [{
- oilist(`device_num` `(` $deviceNumOperand `:` type($deviceNumOperand) `)`
+ oilist(`device_num` `(` $deviceNum `:` type($deviceNum) `)`
|`if` `(` $ifCond `)`
) attr-dict-with-keyword
}];
>From 1a14808cc5376cda26fe572166e526bd885674b4 Mon Sep 17 00:00:00 2001
From: erichkeane <ekeane at nvidia.com>
Date: Tue, 22 Apr 2025 12:51:12 -0700
Subject: [PATCH 2/2] Fix clang OpenACC lowering for the name change
---
clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp
index 3696bfbd8e4db..47537d65bf381 100644
--- a/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp
@@ -291,12 +291,7 @@ class OpenACCClauseCIREmitter final
}
void VisitDeviceNumClause(const OpenACCDeviceNumClause &clause) {
- if constexpr (isOneOfTypes<OpTy, InitOp, ShutdownOp>) {
- operation.getDeviceNumOperandMutable().append(
- createIntExpr(clause.getIntExpr()));
- } else if constexpr (isOneOfTypes<OpTy, SetOp>) {
- // This is only a separate case because the getter name is different in
- // 'set' for some reason.
+ if constexpr (isOneOfTypes<OpTy, InitOp, ShutdownOp, SetOp>) {
operation.getDeviceNumMutable().append(
createIntExpr(clause.getIntExpr()));
} else {
More information about the cfe-commits
mailing list