Skip to content

Commit 78cec6d

Browse files
committed
Added minimal changes to enable flang future implementation
1 parent 07e7dc8 commit 78cec6d

File tree

8 files changed

+40
-0
lines changed

8 files changed

+40
-0
lines changed

flang/include/flang/Parser/dump-parse-tree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,7 @@ class ParseTreeDumper {
608608
NODE(OmpLinearClause, Modifier)
609609
NODE(parser, OmpLinearModifier)
610610
NODE_ENUM(OmpLinearModifier, Value)
611+
NODE(parser, OmpLoopRangeClause)
611612
NODE(parser, OmpStepComplexModifier)
612613
NODE(parser, OmpStepSimpleModifier)
613614
NODE(parser, OmpLoopDirective)

flang/include/flang/Parser/parse-tree.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4361,6 +4361,15 @@ struct OmpLinearClause {
43614361
std::tuple<OmpObjectList, MODIFIERS(), /*PostModified=*/bool> t;
43624362
};
43634363

4364+
// Ref: [6.0:207-208]
4365+
//
4366+
// loop-range-clause ->
4367+
// LOOPRANGE(first, count) // since 6.0
4368+
struct OmpLoopRangeClause {
4369+
TUPLE_CLASS_BOILERPLATE(OmpLoopRangeClause);
4370+
std::tuple<ScalarIntConstantExpr, ScalarIntConstantExpr> t;
4371+
};
4372+
43644373
// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158]
43654374
//
43664375
// map-clause ->

flang/lib/Lower/OpenMP/Clauses.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,11 @@ Link make(const parser::OmpClause::Link &inp,
998998
return Link{/*List=*/makeObjects(inp.v, semaCtx)};
999999
}
10001000

1001+
LoopRange make(const parser::OmpClause::Looprange &inp,
1002+
semantics::SemanticsContext &semaCtx) {
1003+
llvm_unreachable("Unimplemented: looprange");
1004+
}
1005+
10011006
Map make(const parser::OmpClause::Map &inp,
10021007
semantics::SemanticsContext &semaCtx) {
10031008
// inp.v -> parser::OmpMapClause

flang/lib/Lower/OpenMP/Clauses.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ using Initializer = tomp::clause::InitializerT<TypeTy, IdTy, ExprTy>;
239239
using InReduction = tomp::clause::InReductionT<TypeTy, IdTy, ExprTy>;
240240
using IsDevicePtr = tomp::clause::IsDevicePtrT<TypeTy, IdTy, ExprTy>;
241241
using Lastprivate = tomp::clause::LastprivateT<TypeTy, IdTy, ExprTy>;
242+
using LoopRange = tomp::clause::LoopRangeT<TypeTy, IdTy, ExprTy>;
242243
using Linear = tomp::clause::LinearT<TypeTy, IdTy, ExprTy>;
243244
using Link = tomp::clause::LinkT<TypeTy, IdTy, ExprTy>;
244245
using Map = tomp::clause::MapT<TypeTy, IdTy, ExprTy>;

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,11 @@ TYPE_PARSER(
837837
maybe(":"_tok >> nonemptyList(Parser<OmpLinearClause::Modifier>{})),
838838
/*PostModified=*/pure(true)))
839839

840+
TYPE_PARSER(
841+
construct<OmpLoopRangeClause>(scalarIntConstantExpr,
842+
"," >> scalarIntConstantExpr)
843+
)
844+
840845
// OpenMPv5.2 12.5.2 detach-clause -> DETACH (event-handle)
841846
TYPE_PARSER(construct<OmpDetachClause>(Parser<OmpObject>{}))
842847

@@ -1006,6 +1011,8 @@ TYPE_PARSER( //
10061011
parenthesized(Parser<OmpLinearClause>{}))) ||
10071012
"LINK" >> construct<OmpClause>(construct<OmpClause::Link>(
10081013
parenthesized(Parser<OmpObjectList>{}))) ||
1014+
"LOOPRANGE" >> construct<OmpClause>(construct<OmpClause::Looprange>(
1015+
parenthesized(Parser<OmpLoopRangeClause>{}))) ||
10091016
"MAP" >> construct<OmpClause>(construct<OmpClause::Map>(
10101017
parenthesized(Parser<OmpMapClause>{}))) ||
10111018
"MATCH" >> construct<OmpClause>(construct<OmpClause::Match>(

flang/lib/Parser/unparse.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,6 +2309,13 @@ class UnparseVisitor {
23092309
}
23102310
}
23112311
}
2312+
void Unparse(const OmpLoopRangeClause &x) {
2313+
Word("LOOPRANGE(");
2314+
Walk(std::get<0>(x.t));
2315+
Put(", ");
2316+
Walk(std::get<1>(x.t));
2317+
Put(")");
2318+
}
23122319
void Unparse(const OmpReductionClause &x) {
23132320
using Modifier = OmpReductionClause::Modifier;
23142321
Walk(std::get<std::optional<std::list<Modifier>>>(x.t), ": ");

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3368,6 +3368,15 @@ CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Collapse, OMPC_collapse)
33683368
CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Safelen, OMPC_safelen)
33693369
CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Simdlen, OMPC_simdlen)
33703370

3371+
void OmpStructureChecker::Enter(const parser::OmpClause::Looprange &x) {
3372+
context_.Say(GetContext().clauseSource,
3373+
"LOOPRANGE clause is not implemented yet"_err_en_US,
3374+
ContextDirectiveAsFortran());
3375+
}
3376+
3377+
void OmpStructureChecker::Enter(const parser::OmpClause::FreeAgent &x) {
3378+
context_.Say(GetContext().clauseSource,
3379+
"FREE_AGENT clause is not implemented yet"_err_en_US,
33713380
// Restrictions specific to each clause are implemented apart from the
33723381
// generalized restrictions.
33733382

llvm/include/llvm/Frontend/OpenMP/OMP.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ def OMPC_Link : Clause<"link"> {
273273
}
274274
def OMPC_LoopRange : Clause<"looprange"> {
275275
let clangClass = "OMPLoopRangeClause";
276+
let flangClass = "OmpLoopRangeClause";
276277
}
277278
def OMPC_Map : Clause<"map"> {
278279
let clangClass = "OMPMapClause";

0 commit comments

Comments
 (0)