Skip to content

Commit ac0d9e3

Browse files
committed
Added minimal changes to enable flang future implementation
1 parent 422ffd7 commit ac0d9e3

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
@@ -609,6 +609,7 @@ class ParseTreeDumper {
609609
NODE(OmpLinearClause, Modifier)
610610
NODE(parser, OmpLinearModifier)
611611
NODE_ENUM(OmpLinearModifier, Value)
612+
NODE(parser, OmpLoopRangeClause)
612613
NODE(parser, OmpStepComplexModifier)
613614
NODE(parser, OmpStepSimpleModifier)
614615
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
@@ -841,6 +841,11 @@ TYPE_PARSER(
841841
maybe(":"_tok >> nonemptyList(Parser<OmpLinearClause::Modifier>{})),
842842
/*PostModified=*/pure(true)))
843843

844+
TYPE_PARSER(
845+
construct<OmpLoopRangeClause>(scalarIntConstantExpr,
846+
"," >> scalarIntConstantExpr)
847+
)
848+
844849
// OpenMPv5.2 12.5.2 detach-clause -> DETACH (event-handle)
845850
TYPE_PARSER(construct<OmpDetachClause>(Parser<OmpObject>{}))
846851

@@ -1010,6 +1015,8 @@ TYPE_PARSER( //
10101015
parenthesized(Parser<OmpLinearClause>{}))) ||
10111016
"LINK" >> construct<OmpClause>(construct<OmpClause::Link>(
10121017
parenthesized(Parser<OmpObjectList>{}))) ||
1018+
"LOOPRANGE" >> construct<OmpClause>(construct<OmpClause::Looprange>(
1019+
parenthesized(Parser<OmpLoopRangeClause>{}))) ||
10131020
"MAP" >> construct<OmpClause>(construct<OmpClause::Map>(
10141021
parenthesized(Parser<OmpMapClause>{}))) ||
10151022
"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
@@ -2314,6 +2314,13 @@ class UnparseVisitor {
23142314
}
23152315
}
23162316
}
2317+
void Unparse(const OmpLoopRangeClause &x) {
2318+
Word("LOOPRANGE(");
2319+
Walk(std::get<0>(x.t));
2320+
Put(", ");
2321+
Walk(std::get<1>(x.t));
2322+
Put(")");
2323+
}
23172324
void Unparse(const OmpReductionClause &x) {
23182325
using Modifier = OmpReductionClause::Modifier;
23192326
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
@@ -3383,6 +3383,15 @@ CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Collapse, OMPC_collapse)
33833383
CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Safelen, OMPC_safelen)
33843384
CHECK_REQ_CONSTANT_SCALAR_INT_CLAUSE(Simdlen, OMPC_simdlen)
33853385

3386+
void OmpStructureChecker::Enter(const parser::OmpClause::Looprange &x) {
3387+
context_.Say(GetContext().clauseSource,
3388+
"LOOPRANGE clause is not implemented yet"_err_en_US,
3389+
ContextDirectiveAsFortran());
3390+
}
3391+
3392+
void OmpStructureChecker::Enter(const parser::OmpClause::FreeAgent &x) {
3393+
context_.Say(GetContext().clauseSource,
3394+
"FREE_AGENT clause is not implemented yet"_err_en_US,
33863395
// Restrictions specific to each clause are implemented apart from the
33873396
// generalized restrictions.
33883397

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)