Skip to content

Commit f3c634b

Browse files
committed
Address review comments
1 parent 3ffaa8b commit f3c634b

File tree

8 files changed

+37
-30
lines changed

8 files changed

+37
-30
lines changed

mlir/include/mlir/Dialect/OpenMP/OpenMPClauseOperands.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ struct CopyprivateClauseOps {
5353
};
5454

5555
struct CriticalNameClauseOps {
56+
/// This field has a generic name because it's mirroring the `sym_name`
57+
/// argument of the `OpenMP_CriticalNameClause` tablegen definition. That one
58+
/// can't be renamed to anything more specific because the `sym_name` name is
59+
/// a requirement of the `Symbol` MLIR trait associated with that clause.
5660
StringAttr symName;
5761
};
5862

mlir/include/mlir/Dialect/OpenMP/OpenMPClauses.td

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define OPENMP_CLAUSES
2121

2222
include "mlir/Dialect/OpenMP/OpenMPOpBase.td"
23+
include "mlir/IR/SymbolInterfaces.td"
2324

2425
//===----------------------------------------------------------------------===//
2526
// V5.2: [5.11] `aligned` clause
@@ -175,6 +176,10 @@ class OpenMP_CriticalNameClauseSkip<
175176
bit description = false, bit extraClassDeclaration = false
176177
> : OpenMP_Clause</*isRequired=*/true, traits, arguments, assemblyFormat,
177178
description, extraClassDeclaration> {
179+
let traits = [
180+
Symbol
181+
];
182+
178183
let arguments = (ins
179184
SymbolNameAttr:$sym_name
180185
);
@@ -455,11 +460,11 @@ class OpenMP_IfClauseSkip<
455460
> : OpenMP_Clause</*isRequired=*/false, traits, arguments, assemblyFormat,
456461
description, extraClassDeclaration> {
457462
let arguments = (ins
458-
Optional<I1>:$if_var
463+
Optional<I1>:$if_expr
459464
);
460465

461466
let assemblyFormat = [{
462-
`if` `(` $if_var `)`
467+
`if` `(` $if_expr `)`
463468
}];
464469

465470
// Description varies depending on the operation.

mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def ParallelOp : OpenMP_Op<"parallel", traits = [
145145
The parallel construct includes a region of code which is to be executed
146146
by a team of threads.
147147

148-
The optional `if_var` parameter specifies a boolean result of a conditional
148+
The optional `if_expr` parameter specifies a boolean result of a conditional
149149
check. If this value is 1 or is not provided then the parallel region runs
150150
as normal, if it is 0 then the parallel region is executed with one thread.
151151
}] # clausesDescription;
@@ -161,7 +161,7 @@ def ParallelOp : OpenMP_Op<"parallel", traits = [
161161
// no longer skipped for clauses added to this operation at that time.
162162
let assemblyFormat = [{
163163
oilist(
164-
`if` `(` $if_var `)`
164+
`if` `(` $if_expr `)`
165165
| `num_threads` `(` $num_threads `:` type($num_threads) `)`
166166
| `allocate` `(`
167167
custom<AllocateAndAllocator>(
@@ -206,7 +206,7 @@ def TeamsOp : OpenMP_Op<"teams", traits = [
206206
league of teams. Once created, the number of teams remains constant for the
207207
duration of its code region.
208208

209-
If the `if_var` is present and it evaluates to `false`, the number of teams
209+
If the `if_expr` is present and it evaluates to `false`, the number of teams
210210
created is one.
211211
}] # clausesDescription;
212212

@@ -568,7 +568,7 @@ def TaskOp : OpenMP_Op<"task", traits = [
568568
"mergeable task", please check OpenMP Specification.
569569

570570
When an `if` clause is present on a task construct, and the value of
571-
`if_var` evaluates to `false`, an "undeferred task" is generated, and the
571+
`if_expr` evaluates to `false`, an "undeferred task" is generated, and the
572572
encountering thread must suspend the current task region, for which
573573
execution cannot be resumed until execution of the structured block that is
574574
associated with the generated task is completed.
@@ -964,7 +964,7 @@ def TargetDataOp: OpenMP_Op<"target_data", traits = [
964964
to and from the offloading device when multiple target regions are using
965965
the same data.
966966

967-
The optional `if_var` parameter specifies a boolean result of a conditional
967+
The optional `if_expr` parameter specifies a boolean result of a conditional
968968
check. If this value is 1 or is not provided then the target region runs on
969969
a device, if it is 0 then the target region is executed on the host device.
970970
}] # clausesDescription;
@@ -993,7 +993,7 @@ def TargetEnterDataOp: OpenMP_Op<"target_enter_data", traits = [
993993
a device data environment. The target enter data directive is a
994994
stand-alone directive.
995995

996-
The optional `if_var` parameter specifies a boolean result of a conditional
996+
The optional `if_expr` parameter specifies a boolean result of a conditional
997997
check. If this value is 1 or is not provided then the target region runs on
998998
a device, if it is 0 then the target region is executed on the host device.
999999
}] # clausesDescription;
@@ -1022,7 +1022,7 @@ def TargetExitDataOp: OpenMP_Op<"target_exit_data", traits = [
10221022
device data environment. The target exit data directive is
10231023
a stand-alone directive.
10241024

1025-
The optional `if_var` parameter specifies a boolean result of a conditional
1025+
The optional `if_expr` parameter specifies a boolean result of a conditional
10261026
check. If this value is 1 or is not provided then the target region runs on
10271027
a device, if it is 0 then the target region is executed on the host device.
10281028
}] # clausesDescription;
@@ -1052,7 +1052,7 @@ def TargetUpdateOp: OpenMP_Op<"target_update", traits = [
10521052
specified motion clauses. The target update construct is a stand-alone
10531053
directive.
10541054

1055-
The optional `if_var` parameter specifies a boolean result of a conditional
1055+
The optional `if_expr` parameter specifies a boolean result of a conditional
10561056
check. If this value is 1 or is not provided then the target region runs on
10571057
a device, if it is 0 then the target region is executed on the host device.
10581058

@@ -1090,7 +1090,7 @@ def TargetOp : OpenMP_Op<"target", traits = [
10901090
The target construct includes a region of code which is to be executed
10911091
on a device.
10921092

1093-
The optional `if_var` parameter specifies a boolean result of a conditional
1093+
The optional `if_expr` parameter specifies a boolean result of a conditional
10941094
check. If this value is 1 or is not provided then the target region runs on
10951095
a device, if it is 0 then the target region is executed on the host device.
10961096
}] # clausesDescription;
@@ -1119,9 +1119,7 @@ def MasterOp : OpenMP_Op<"master", singleRegion = true> {
11191119
//===----------------------------------------------------------------------===//
11201120
// 2.17.1 critical Construct
11211121
//===----------------------------------------------------------------------===//
1122-
def CriticalDeclareOp : OpenMP_Op<"critical.declare", traits = [
1123-
Symbol
1124-
], clauses = [
1122+
def CriticalDeclareOp : OpenMP_Op<"critical.declare", clauses = [
11251123
OpenMP_CriticalNameClause, OpenMP_HintClause
11261124
]> {
11271125
let summary = "declares a named critical section.";

mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ struct ParallelOpLowering : public OpRewritePattern<scf::ParallelOp> {
444444
// Create the parallel wrapper.
445445
auto ompParallel = rewriter.create<omp::ParallelOp>(
446446
loc,
447-
/* if_var = */ Value{},
447+
/* if_expr = */ Value{},
448448
/* num_threads = */ numThreadsVar,
449449
/* allocate_vars = */ llvm::SmallVector<Value>{},
450450
/* allocator_vars = */ llvm::SmallVector<Value>{},

mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1474,7 +1474,7 @@ LogicalResult TargetOp::verify() {
14741474
void ParallelOp::build(OpBuilder &builder, OperationState &state,
14751475
ArrayRef<NamedAttribute> attributes) {
14761476
ParallelOp::build(
1477-
builder, state, /*if_var=*/nullptr, /*num_threads=*/nullptr,
1477+
builder, state, /*if_expr=*/nullptr, /*num_threads=*/nullptr,
14781478
/*allocate_vars=*/ValueRange(), /*allocator_vars=*/ValueRange(),
14791479
/*reduction_vars=*/ValueRange(), /*reduction_byref=*/nullptr,
14801480
/*reduction_syms=*/nullptr, /*proc_bind_kind=*/nullptr,

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ convertOmpTeams(omp::TeamsOp op, llvm::IRBuilderBase &builder,
10001000
threadLimit = moduleTranslation.lookupValue(threadLimitVar);
10011001

10021002
llvm::Value *ifExpr = nullptr;
1003-
if (Value ifVar = op.getIfVar())
1003+
if (Value ifVar = op.getIfExpr())
10041004
ifExpr = moduleTranslation.lookupValue(ifVar);
10051005

10061006
llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
@@ -1061,7 +1061,7 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder,
10611061
builder.restoreIP(moduleTranslation.getOpenMPBuilder()->createTask(
10621062
ompLoc, allocaIP, bodyCB, !taskOp.getUntied(),
10631063
moduleTranslation.lookupValue(taskOp.getFinal()),
1064-
moduleTranslation.lookupValue(taskOp.getIfVar()), dds));
1064+
moduleTranslation.lookupValue(taskOp.getIfExpr()), dds));
10651065
return bodyGenStatus;
10661066
}
10671067

@@ -1559,7 +1559,7 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
15591559
};
15601560

15611561
llvm::Value *ifCond = nullptr;
1562-
if (auto ifVar = opInst.getIfVar())
1562+
if (auto ifVar = opInst.getIfExpr())
15631563
ifCond = moduleTranslation.lookupValue(ifVar);
15641564
llvm::Value *numThreads = nullptr;
15651565
if (auto numThreadsVar = opInst.getNumThreads())
@@ -1678,8 +1678,8 @@ convertOmpSimd(Operation &opInst, llvm::IRBuilderBase &builder,
16781678
llvm::MapVector<llvm::Value *, llvm::Value *> alignedVars;
16791679
llvm::omp::OrderKind order = convertOrderKind(simdOp.getOrder());
16801680
ompBuilder->applySimd(loopInfo, alignedVars,
1681-
simdOp.getIfVar()
1682-
? moduleTranslation.lookupValue(simdOp.getIfVar())
1681+
simdOp.getIfExpr()
1682+
? moduleTranslation.lookupValue(simdOp.getIfExpr())
16831683
: nullptr,
16841684
order, simdlen, safelen);
16851685

@@ -2790,7 +2790,7 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
27902790
LogicalResult result =
27912791
llvm::TypeSwitch<Operation *, LogicalResult>(op)
27922792
.Case([&](omp::TargetDataOp dataOp) {
2793-
if (auto ifVar = dataOp.getIfVar())
2793+
if (auto ifVar = dataOp.getIfExpr())
27942794
ifCond = moduleTranslation.lookupValue(ifVar);
27952795

27962796
if (auto devId = dataOp.getDevice())
@@ -2809,7 +2809,7 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
28092809
return (LogicalResult)(enterDataOp.emitError(
28102810
"`nowait` is not supported yet"));
28112811

2812-
if (auto ifVar = enterDataOp.getIfVar())
2812+
if (auto ifVar = enterDataOp.getIfExpr())
28132813
ifCond = moduleTranslation.lookupValue(ifVar);
28142814

28152815
if (auto devId = enterDataOp.getDevice())
@@ -2826,7 +2826,7 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
28262826
return (LogicalResult)(exitDataOp.emitError(
28272827
"`nowait` is not supported yet"));
28282828

2829-
if (auto ifVar = exitDataOp.getIfVar())
2829+
if (auto ifVar = exitDataOp.getIfExpr())
28302830
ifCond = moduleTranslation.lookupValue(ifVar);
28312831

28322832
if (auto devId = exitDataOp.getDevice())
@@ -2844,7 +2844,7 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
28442844
return (LogicalResult)(updateDataOp.emitError(
28452845
"`nowait` is not supported yet"));
28462846

2847-
if (auto ifVar = updateDataOp.getIfVar())
2847+
if (auto ifVar = updateDataOp.getIfExpr())
28482848
ifCond = moduleTranslation.lookupValue(ifVar);
28492849

28502850
if (auto devId = updateDataOp.getDevice())
@@ -3012,7 +3012,7 @@ static bool getTargetEntryUniqueInfo(llvm::TargetRegionEntryInfo &targetInfo,
30123012

30133013
static bool targetOpSupported(Operation &opInst) {
30143014
auto targetOp = cast<omp::TargetOp>(opInst);
3015-
if (targetOp.getIfVar()) {
3015+
if (targetOp.getIfExpr()) {
30163016
opInst.emitError("If clause not yet supported");
30173017
return false;
30183018
}

mlir/test/Dialect/OpenMP/ops.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ func.func @omp_distribute(%chunk_size : i32, %data_var : memref<i32>, %arg0 : i3
804804
// CHECK-LABEL: omp_target
805805
func.func @omp_target(%if_cond : i1, %device : si32, %num_threads : i32, %device_ptr: memref<i32>, %device_addr: memref<?xi32>, %map1: memref<?xi32>, %map2: memref<?xi32>) -> () {
806806

807-
// Test with optional operands; if_var, device, thread_limit, private, firstprivate and nowait.
807+
// Test with optional operands; if_expr, device, thread_limit, private, firstprivate and nowait.
808808
// CHECK: omp.target if({{.*}}) device({{.*}}) thread_limit({{.*}}) nowait
809809
"omp.target"(%if_cond, %device, %num_threads) ({
810810
// CHECK: omp.terminator
@@ -2165,7 +2165,7 @@ func.func @omp_threadprivate() {
21652165
llvm.mlir.global internal @_QFsubEx() : i32
21662166

21672167
func.func @omp_cancel_parallel(%if_cond : i1) -> () {
2168-
// Test with optional operand; if_var.
2168+
// Test with optional operand; if_expr.
21692169
omp.parallel {
21702170
// CHECK: omp.cancel cancellation_construct_type(parallel) if(%{{.*}})
21712171
omp.cancel cancellation_construct_type(parallel) if(%if_cond)

mlir/test/Target/LLVMIR/openmp-llvm.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ llvm.func @test_omp_parallel_num_threads_3() -> () {
148148
// CHECK: define internal void @[[OMP_OUTLINED_FN_NUM_THREADS_3_1]]
149149
// CHECK: call void @__kmpc_barrier
150150

151-
// CHECK: define void @test_omp_parallel_if_1(i32 %[[IF_VAR_1:.*]])
151+
// CHECK: define void @test_omp_parallel_if_1(i32 %[[IF_EXPR_1:.*]])
152152
llvm.func @test_omp_parallel_if_1(%arg0: i32) -> () {
153153

154154
%0 = llvm.mlir.constant(0 : index) : i32
155155
%1 = llvm.icmp "slt" %arg0, %0 : i32
156-
// CHECK: %[[IF_COND_VAR_1:.*]] = icmp slt i32 %[[IF_VAR_1]], 0
156+
// CHECK: %[[IF_COND_VAR_1:.*]] = icmp slt i32 %[[IF_EXPR_1]], 0
157157

158158

159159
// CHECK: %[[GTN_IF_1:.*]] = call i32 @__kmpc_global_thread_num(ptr @[[SI_VAR_IF_1:.*]])

0 commit comments

Comments
 (0)