Skip to content

Commit b0fb1b3

Browse files
committed
Added minimal changes to enable flang future implementation
1 parent 65cbfeb commit b0fb1b3

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
@@ -600,6 +600,7 @@ class ParseTreeDumper {
600600
NODE(OmpLinearClause, Modifier)
601601
NODE(parser, OmpLinearModifier)
602602
NODE_ENUM(OmpLinearModifier, Value)
603+
NODE(parser, OmpLoopRangeClause)
603604
NODE(parser, OmpStepComplexModifier)
604605
NODE(parser, OmpStepSimpleModifier)
605606
NODE(parser, OmpLoopDirective)

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

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

4370+
// Ref: [6.0:207-208]
4371+
//
4372+
// loop-range-clause ->
4373+
// LOOPRANGE(first, count) // since 6.0
4374+
struct OmpLoopRangeClause {
4375+
TUPLE_CLASS_BOILERPLATE(OmpLoopRangeClause);
4376+
std::tuple<ScalarIntConstantExpr, ScalarIntConstantExpr> t;
4377+
};
4378+
43704379
// Ref: [4.5:216-219], [5.0:315-324], [5.1:347-355], [5.2:150-158]
43714380
//
43724381
// map-clause ->

flang/lib/Lower/OpenMP/Clauses.cpp

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

1000+
LoopRange make(const parser::OmpClause::Looprange &inp,
1001+
semantics::SemanticsContext &semaCtx) {
1002+
llvm_unreachable("Unimplemented: looprange");
1003+
}
1004+
10001005
Map make(const parser::OmpClause::Map &inp,
10011006
semantics::SemanticsContext &semaCtx) {
10021007
// 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
@@ -847,6 +847,11 @@ TYPE_PARSER(
847847
maybe(":"_tok >> nonemptyList(Parser<OmpLinearClause::Modifier>{})),
848848
/*PostModified=*/pure(true)))
849849

850+
TYPE_PARSER(
851+
construct<OmpLoopRangeClause>(scalarIntConstantExpr,
852+
"," >> scalarIntConstantExpr)
853+
)
854+
850855
// OpenMPv5.2 12.5.2 detach-clause -> DETACH (event-handle)
851856
TYPE_PARSER(construct<OmpDetachClause>(Parser<OmpObject>{}))
852857

@@ -1020,6 +1025,8 @@ TYPE_PARSER( //
10201025
parenthesized(Parser<OmpLinearClause>{}))) ||
10211026
"LINK" >> construct<OmpClause>(construct<OmpClause::Link>(
10221027
parenthesized(Parser<OmpObjectList>{}))) ||
1028+
"LOOPRANGE" >> construct<OmpClause>(construct<OmpClause::Looprange>(
1029+
parenthesized(Parser<OmpLoopRangeClause>{}))) ||
10231030
"MAP" >> construct<OmpClause>(construct<OmpClause::Map>(
10241031
parenthesized(Parser<OmpMapClause>{}))) ||
10251032
"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
@@ -2318,6 +2318,13 @@ class UnparseVisitor {
23182318
}
23192319
}
23202320
}
2321+
void Unparse(const OmpLoopRangeClause &x) {
2322+
Word("LOOPRANGE(");
2323+
Walk(std::get<0>(x.t));
2324+
Put(", ");
2325+
Walk(std::get<1>(x.t));
2326+
Put(")");
2327+
}
23212328
void Unparse(const OmpReductionClause &x) {
23222329
using Modifier = OmpReductionClause::Modifier;
23232330
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
@@ -4446,6 +4446,15 @@ CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Collapse, OMPC_collapse)
44464446
CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Safelen, OMPC_safelen)
44474447
CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Simdlen, OMPC_simdlen)
44484448

4449+
void OmpStructureChecker::Enter(const parser::OmpClause::Looprange &x) {
4450+
context_.Say(GetContext().clauseSource,
4451+
"LOOPRANGE clause is not implemented yet"_err_en_US,
4452+
ContextDirectiveAsFortran());
4453+
}
4454+
4455+
void OmpStructureChecker::Enter(const parser::OmpClause::FreeAgent &x) {
4456+
context_.Say(GetContext().clauseSource,
4457+
"FREE_AGENT clause is not implemented yet"_err_en_US,
44494458
// Restrictions specific to each clause are implemented apart from the
44504459
// generalized restrictions.
44514460

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ def OMPC_Link : Clause<[Spelling<"link">]> {
276276
}
277277
def OMPC_LoopRange : Clause<[Spelling<"looprange">]> {
278278
let clangClass = "OMPLoopRangeClause";
279+
let flangClass = "OmpLoopRangeClause";
279280
}
280281
def OMPC_Map : Clause<[Spelling<"map">]> {
281282
let clangClass = "OMPMapClause";

0 commit comments

Comments
 (0)