Skip to content

Commit 24c22b7

Browse files
authored
[flang][OpenMP] Sort and move macro-based clause checks to the end, NFC (#166175)
1 parent bb9bd5f commit 24c22b7

File tree

1 file changed

+100
-106
lines changed

1 file changed

+100
-106
lines changed

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 100 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -195,30 +195,6 @@ void OmpStructureChecker::Leave(const parser::ExecutionPart &) {
195195
partStack_.pop_back();
196196
}
197197

198-
// Use when clause falls under 'struct OmpClause' in 'parse-tree.h'.
199-
#define CHECK_SIMPLE_CLAUSE(X, Y) \
200-
void OmpStructureChecker::Enter(const parser::OmpClause::X &) { \
201-
CheckAllowedClause(llvm::omp::Clause::Y); \
202-
}
203-
204-
#define CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(X, Y) \
205-
void OmpStructureChecker::Enter(const parser::OmpClause::X &c) { \
206-
CheckAllowedClause(llvm::omp::Clause::Y); \
207-
RequiresConstantPositiveParameter(llvm::omp::Clause::Y, c.v); \
208-
}
209-
210-
#define CHECK_REQ_SCALAR_INT_CLAUSE(X, Y) \
211-
void OmpStructureChecker::Enter(const parser::OmpClause::X &c) { \
212-
CheckAllowedClause(llvm::omp::Clause::Y); \
213-
RequiresPositiveParameter(llvm::omp::Clause::Y, c.v); \
214-
}
215-
216-
// Use when clause don't falls under 'struct OmpClause' in 'parse-tree.h'.
217-
#define CHECK_SIMPLE_PARSER_CLAUSE(X, Y) \
218-
void OmpStructureChecker::Enter(const parser::X &) { \
219-
CheckAllowedClause(llvm::omp::Y); \
220-
}
221-
222198
// 'OmpWorkshareBlockChecker' is used to check the validity of the assignment
223199
// statements and the expressions enclosed in an OpenMP Workshare construct
224200
class OmpWorkshareBlockChecker {
@@ -3391,88 +3367,6 @@ void OmpStructureChecker::Enter(const parser::OmpClause::Sizes &c) {
33913367
/*paramName=*/"parameter", /*allowZero=*/false);
33923368
}
33933369

3394-
// Following clauses do not have a separate node in parse-tree.h.
3395-
CHECK_SIMPLE_CLAUSE(Absent, OMPC_absent)
3396-
CHECK_SIMPLE_CLAUSE(Affinity, OMPC_affinity)
3397-
CHECK_SIMPLE_CLAUSE(Capture, OMPC_capture)
3398-
CHECK_SIMPLE_CLAUSE(Contains, OMPC_contains)
3399-
CHECK_SIMPLE_CLAUSE(Default, OMPC_default)
3400-
CHECK_SIMPLE_CLAUSE(Depobj, OMPC_depobj)
3401-
CHECK_SIMPLE_CLAUSE(DeviceType, OMPC_device_type)
3402-
CHECK_SIMPLE_CLAUSE(DistSchedule, OMPC_dist_schedule)
3403-
CHECK_SIMPLE_CLAUSE(DynGroupprivate, OMPC_dyn_groupprivate)
3404-
CHECK_SIMPLE_CLAUSE(Exclusive, OMPC_exclusive)
3405-
CHECK_SIMPLE_CLAUSE(Final, OMPC_final)
3406-
CHECK_SIMPLE_CLAUSE(Flush, OMPC_flush)
3407-
CHECK_SIMPLE_CLAUSE(Full, OMPC_full)
3408-
CHECK_SIMPLE_CLAUSE(Grainsize, OMPC_grainsize)
3409-
CHECK_SIMPLE_CLAUSE(GraphId, OMPC_graph_id)
3410-
CHECK_SIMPLE_CLAUSE(GraphReset, OMPC_graph_reset)
3411-
CHECK_SIMPLE_CLAUSE(Holds, OMPC_holds)
3412-
CHECK_SIMPLE_CLAUSE(Inclusive, OMPC_inclusive)
3413-
CHECK_SIMPLE_CLAUSE(Initializer, OMPC_initializer)
3414-
CHECK_SIMPLE_CLAUSE(Match, OMPC_match)
3415-
CHECK_SIMPLE_CLAUSE(Nontemporal, OMPC_nontemporal)
3416-
CHECK_SIMPLE_CLAUSE(NumTasks, OMPC_num_tasks)
3417-
CHECK_SIMPLE_CLAUSE(Order, OMPC_order)
3418-
CHECK_SIMPLE_CLAUSE(Read, OMPC_read)
3419-
CHECK_SIMPLE_CLAUSE(Threadprivate, OMPC_threadprivate)
3420-
CHECK_SIMPLE_CLAUSE(Groupprivate, OMPC_groupprivate)
3421-
CHECK_SIMPLE_CLAUSE(Threads, OMPC_threads)
3422-
CHECK_SIMPLE_CLAUSE(Threadset, OMPC_threadset)
3423-
CHECK_SIMPLE_CLAUSE(Inbranch, OMPC_inbranch)
3424-
CHECK_SIMPLE_CLAUSE(Link, OMPC_link)
3425-
CHECK_SIMPLE_CLAUSE(Indirect, OMPC_indirect)
3426-
CHECK_SIMPLE_CLAUSE(Mergeable, OMPC_mergeable)
3427-
CHECK_SIMPLE_CLAUSE(NoOpenmp, OMPC_no_openmp)
3428-
CHECK_SIMPLE_CLAUSE(NoOpenmpRoutines, OMPC_no_openmp_routines)
3429-
CHECK_SIMPLE_CLAUSE(NoOpenmpConstructs, OMPC_no_openmp_constructs)
3430-
CHECK_SIMPLE_CLAUSE(NoParallelism, OMPC_no_parallelism)
3431-
CHECK_SIMPLE_CLAUSE(Nogroup, OMPC_nogroup)
3432-
CHECK_SIMPLE_CLAUSE(Notinbranch, OMPC_notinbranch)
3433-
CHECK_SIMPLE_CLAUSE(Partial, OMPC_partial)
3434-
CHECK_SIMPLE_CLAUSE(ProcBind, OMPC_proc_bind)
3435-
CHECK_SIMPLE_CLAUSE(Simd, OMPC_simd)
3436-
CHECK_SIMPLE_CLAUSE(Permutation, OMPC_permutation)
3437-
CHECK_SIMPLE_CLAUSE(Uniform, OMPC_uniform)
3438-
CHECK_SIMPLE_CLAUSE(Unknown, OMPC_unknown)
3439-
CHECK_SIMPLE_CLAUSE(Untied, OMPC_untied)
3440-
CHECK_SIMPLE_CLAUSE(UsesAllocators, OMPC_uses_allocators)
3441-
CHECK_SIMPLE_CLAUSE(Write, OMPC_write)
3442-
CHECK_SIMPLE_CLAUSE(Init, OMPC_init)
3443-
CHECK_SIMPLE_CLAUSE(Use, OMPC_use)
3444-
CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
3445-
CHECK_SIMPLE_CLAUSE(Nocontext, OMPC_nocontext)
3446-
CHECK_SIMPLE_CLAUSE(Severity, OMPC_severity)
3447-
CHECK_SIMPLE_CLAUSE(Message, OMPC_message)
3448-
CHECK_SIMPLE_CLAUSE(Filter, OMPC_filter)
3449-
CHECK_SIMPLE_CLAUSE(Otherwise, OMPC_otherwise)
3450-
CHECK_SIMPLE_CLAUSE(AdjustArgs, OMPC_adjust_args)
3451-
CHECK_SIMPLE_CLAUSE(AppendArgs, OMPC_append_args)
3452-
CHECK_SIMPLE_CLAUSE(MemoryOrder, OMPC_memory_order)
3453-
CHECK_SIMPLE_CLAUSE(Bind, OMPC_bind)
3454-
CHECK_SIMPLE_CLAUSE(Compare, OMPC_compare)
3455-
CHECK_SIMPLE_CLAUSE(OmpxAttribute, OMPC_ompx_attribute)
3456-
CHECK_SIMPLE_CLAUSE(Weak, OMPC_weak)
3457-
CHECK_SIMPLE_CLAUSE(AcqRel, OMPC_acq_rel)
3458-
CHECK_SIMPLE_CLAUSE(Acquire, OMPC_acquire)
3459-
CHECK_SIMPLE_CLAUSE(Relaxed, OMPC_relaxed)
3460-
CHECK_SIMPLE_CLAUSE(Release, OMPC_release)
3461-
CHECK_SIMPLE_CLAUSE(Replayable, OMPC_replayable)
3462-
CHECK_SIMPLE_CLAUSE(Transparent, OMPC_transparent)
3463-
CHECK_SIMPLE_CLAUSE(SeqCst, OMPC_seq_cst)
3464-
CHECK_SIMPLE_CLAUSE(Fail, OMPC_fail)
3465-
3466-
CHECK_REQ_SCALAR_INT_CLAUSE(NumTeams, OMPC_num_teams)
3467-
CHECK_REQ_SCALAR_INT_CLAUSE(NumThreads, OMPC_num_threads)
3468-
CHECK_REQ_SCALAR_INT_CLAUSE(OmpxDynCgroupMem, OMPC_ompx_dyn_cgroup_mem)
3469-
CHECK_REQ_SCALAR_INT_CLAUSE(Priority, OMPC_priority)
3470-
CHECK_REQ_SCALAR_INT_CLAUSE(ThreadLimit, OMPC_thread_limit)
3471-
3472-
CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Collapse, OMPC_collapse)
3473-
CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Safelen, OMPC_safelen)
3474-
CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Simdlen, OMPC_simdlen)
3475-
34763370
void OmpStructureChecker::Enter(const parser::OmpClause::Looprange &x) {
34773371
context_.Say(GetContext().clauseSource,
34783372
"LOOPRANGE clause is not implemented yet"_err_en_US,
@@ -5545,4 +5439,104 @@ void OmpStructureChecker::CheckAllowedRequiresClause(llvmOmpClause clause) {
55455439
}
55465440
}
55475441

5442+
// Use when clause falls under 'struct OmpClause' in 'parse-tree.h'.
5443+
#define CHECK_SIMPLE_CLAUSE(X, Y) \
5444+
void OmpStructureChecker::Enter(const parser::OmpClause::X &) { \
5445+
CheckAllowedClause(llvm::omp::Clause::Y); \
5446+
}
5447+
5448+
#define CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(X, Y) \
5449+
void OmpStructureChecker::Enter(const parser::OmpClause::X &c) { \
5450+
CheckAllowedClause(llvm::omp::Clause::Y); \
5451+
RequiresConstantPositiveParameter(llvm::omp::Clause::Y, c.v); \
5452+
}
5453+
5454+
#define CHECK_REQ_SCALAR_INT_CLAUSE(X, Y) \
5455+
void OmpStructureChecker::Enter(const parser::OmpClause::X &c) { \
5456+
CheckAllowedClause(llvm::omp::Clause::Y); \
5457+
RequiresPositiveParameter(llvm::omp::Clause::Y, c.v); \
5458+
}
5459+
5460+
// Following clauses do not have a separate node in parse-tree.h.
5461+
CHECK_SIMPLE_CLAUSE(Absent, OMPC_absent)
5462+
CHECK_SIMPLE_CLAUSE(AcqRel, OMPC_acq_rel)
5463+
CHECK_SIMPLE_CLAUSE(Acquire, OMPC_acquire)
5464+
CHECK_SIMPLE_CLAUSE(AdjustArgs, OMPC_adjust_args)
5465+
CHECK_SIMPLE_CLAUSE(Affinity, OMPC_affinity)
5466+
CHECK_SIMPLE_CLAUSE(AppendArgs, OMPC_append_args)
5467+
CHECK_SIMPLE_CLAUSE(Bind, OMPC_bind)
5468+
CHECK_SIMPLE_CLAUSE(Capture, OMPC_capture)
5469+
CHECK_SIMPLE_CLAUSE(Compare, OMPC_compare)
5470+
CHECK_SIMPLE_CLAUSE(Contains, OMPC_contains)
5471+
CHECK_SIMPLE_CLAUSE(Default, OMPC_default)
5472+
CHECK_SIMPLE_CLAUSE(Depobj, OMPC_depobj)
5473+
CHECK_SIMPLE_CLAUSE(DeviceType, OMPC_device_type)
5474+
CHECK_SIMPLE_CLAUSE(DistSchedule, OMPC_dist_schedule)
5475+
CHECK_SIMPLE_CLAUSE(DynGroupprivate, OMPC_dyn_groupprivate)
5476+
CHECK_SIMPLE_CLAUSE(Exclusive, OMPC_exclusive)
5477+
CHECK_SIMPLE_CLAUSE(Fail, OMPC_fail)
5478+
CHECK_SIMPLE_CLAUSE(Filter, OMPC_filter)
5479+
CHECK_SIMPLE_CLAUSE(Final, OMPC_final)
5480+
CHECK_SIMPLE_CLAUSE(Flush, OMPC_flush)
5481+
CHECK_SIMPLE_CLAUSE(Full, OMPC_full)
5482+
CHECK_SIMPLE_CLAUSE(Grainsize, OMPC_grainsize)
5483+
CHECK_SIMPLE_CLAUSE(GraphId, OMPC_graph_id)
5484+
CHECK_SIMPLE_CLAUSE(GraphReset, OMPC_graph_reset)
5485+
CHECK_SIMPLE_CLAUSE(Groupprivate, OMPC_groupprivate)
5486+
CHECK_SIMPLE_CLAUSE(Holds, OMPC_holds)
5487+
CHECK_SIMPLE_CLAUSE(Inbranch, OMPC_inbranch)
5488+
CHECK_SIMPLE_CLAUSE(Inclusive, OMPC_inclusive)
5489+
CHECK_SIMPLE_CLAUSE(Indirect, OMPC_indirect)
5490+
CHECK_SIMPLE_CLAUSE(Initializer, OMPC_initializer)
5491+
CHECK_SIMPLE_CLAUSE(Init, OMPC_init)
5492+
CHECK_SIMPLE_CLAUSE(Link, OMPC_link)
5493+
CHECK_SIMPLE_CLAUSE(Match, OMPC_match)
5494+
CHECK_SIMPLE_CLAUSE(MemoryOrder, OMPC_memory_order)
5495+
CHECK_SIMPLE_CLAUSE(Mergeable, OMPC_mergeable)
5496+
CHECK_SIMPLE_CLAUSE(Message, OMPC_message)
5497+
CHECK_SIMPLE_CLAUSE(Nocontext, OMPC_nocontext)
5498+
CHECK_SIMPLE_CLAUSE(Nogroup, OMPC_nogroup)
5499+
CHECK_SIMPLE_CLAUSE(Nontemporal, OMPC_nontemporal)
5500+
CHECK_SIMPLE_CLAUSE(NoOpenmpConstructs, OMPC_no_openmp_constructs)
5501+
CHECK_SIMPLE_CLAUSE(NoOpenmp, OMPC_no_openmp)
5502+
CHECK_SIMPLE_CLAUSE(NoOpenmpRoutines, OMPC_no_openmp_routines)
5503+
CHECK_SIMPLE_CLAUSE(NoParallelism, OMPC_no_parallelism)
5504+
CHECK_SIMPLE_CLAUSE(Notinbranch, OMPC_notinbranch)
5505+
CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
5506+
CHECK_SIMPLE_CLAUSE(NumTasks, OMPC_num_tasks)
5507+
CHECK_SIMPLE_CLAUSE(OmpxAttribute, OMPC_ompx_attribute)
5508+
CHECK_SIMPLE_CLAUSE(Order, OMPC_order)
5509+
CHECK_SIMPLE_CLAUSE(Otherwise, OMPC_otherwise)
5510+
CHECK_SIMPLE_CLAUSE(Partial, OMPC_partial)
5511+
CHECK_SIMPLE_CLAUSE(Permutation, OMPC_permutation)
5512+
CHECK_SIMPLE_CLAUSE(ProcBind, OMPC_proc_bind)
5513+
CHECK_SIMPLE_CLAUSE(Read, OMPC_read)
5514+
CHECK_SIMPLE_CLAUSE(Relaxed, OMPC_relaxed)
5515+
CHECK_SIMPLE_CLAUSE(Release, OMPC_release)
5516+
CHECK_SIMPLE_CLAUSE(Replayable, OMPC_replayable)
5517+
CHECK_SIMPLE_CLAUSE(SeqCst, OMPC_seq_cst)
5518+
CHECK_SIMPLE_CLAUSE(Severity, OMPC_severity)
5519+
CHECK_SIMPLE_CLAUSE(Simd, OMPC_simd)
5520+
CHECK_SIMPLE_CLAUSE(Threadprivate, OMPC_threadprivate)
5521+
CHECK_SIMPLE_CLAUSE(Threadset, OMPC_threadset)
5522+
CHECK_SIMPLE_CLAUSE(Threads, OMPC_threads)
5523+
CHECK_SIMPLE_CLAUSE(Transparent, OMPC_transparent)
5524+
CHECK_SIMPLE_CLAUSE(Uniform, OMPC_uniform)
5525+
CHECK_SIMPLE_CLAUSE(Unknown, OMPC_unknown)
5526+
CHECK_SIMPLE_CLAUSE(Untied, OMPC_untied)
5527+
CHECK_SIMPLE_CLAUSE(Use, OMPC_use)
5528+
CHECK_SIMPLE_CLAUSE(UsesAllocators, OMPC_uses_allocators)
5529+
CHECK_SIMPLE_CLAUSE(Weak, OMPC_weak)
5530+
CHECK_SIMPLE_CLAUSE(Write, OMPC_write)
5531+
5532+
CHECK_REQ_SCALAR_INT_CLAUSE(NumTeams, OMPC_num_teams)
5533+
CHECK_REQ_SCALAR_INT_CLAUSE(NumThreads, OMPC_num_threads)
5534+
CHECK_REQ_SCALAR_INT_CLAUSE(OmpxDynCgroupMem, OMPC_ompx_dyn_cgroup_mem)
5535+
CHECK_REQ_SCALAR_INT_CLAUSE(Priority, OMPC_priority)
5536+
CHECK_REQ_SCALAR_INT_CLAUSE(ThreadLimit, OMPC_thread_limit)
5537+
5538+
CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Collapse, OMPC_collapse)
5539+
CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Safelen, OMPC_safelen)
5540+
CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Simdlen, OMPC_simdlen)
5541+
55485542
} // namespace Fortran::semantics

0 commit comments

Comments
 (0)