[PATCH] D106968: [flang][openacc] Use TableGen to generate the clause parser
Kiran Chandramohan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 12 15:56:14 PDT 2022
kiranchandramohan accepted this revision.
kiranchandramohan added a comment.
This revision is now accepted and ready to land.
LGTM.
I have a Nit and a question.
================
Comment at: flang/lib/Parser/openacc-parsers.cpp:25
-// Basic clauses
-TYPE_PARSER("AUTO" >> construct<AccClause>(construct<AccClause::Auto>()) ||
- "ASYNC" >> construct<AccClause>(construct<AccClause::Async>(
- maybe(parenthesized(scalarIntExpr)))) ||
- "ATTACH" >> construct<AccClause>(construct<AccClause::Attach>(
- parenthesized(Parser<AccObjectList>{}))) ||
- "BIND" >> construct<AccClause>(
- construct<AccClause::Bind>(Parser<AccBindClause>{})) ||
- "CAPTURE" >> construct<AccClause>(construct<AccClause::Capture>()) ||
- "COLLAPSE" >> construct<AccClause>(construct<AccClause::Collapse>(
- parenthesized(scalarIntConstantExpr))) ||
- ("COPY"_tok || "PRESENT_OR_COPY"_tok || "PCOPY"_tok) >>
- construct<AccClause>(construct<AccClause::Copy>(
- parenthesized(Parser<AccObjectList>{}))) ||
- ("COPYIN"_tok || "PRESENT_OR_COPYIN"_tok || "PCOPYIN"_tok) >>
- construct<AccClause>(construct<AccClause::Copyin>(
- parenthesized(Parser<AccObjectListWithModifier>{}))) ||
- ("COPYOUT"_tok || "PRESENT_OR_COPYOUT"_tok || "PCOPYOUT"_tok) >>
- construct<AccClause>(construct<AccClause::Copyout>(
- parenthesized(Parser<AccObjectListWithModifier>{}))) ||
- ("CREATE"_tok || "PRESENT_OR_CREATE"_tok || "PCREATE"_tok) >>
- construct<AccClause>(construct<AccClause::Create>(
- parenthesized(Parser<AccObjectListWithModifier>{}))) ||
- "DEFAULT" >> construct<AccClause>(construct<AccClause::Default>(
- Parser<AccDefaultClause>{})) ||
- "DEFAULT_ASYNC" >> construct<AccClause>(construct<AccClause::DefaultAsync>(
- parenthesized(scalarIntExpr))) ||
- "DELETE" >> construct<AccClause>(construct<AccClause::Delete>(
- parenthesized(Parser<AccObjectList>{}))) ||
- "DETACH" >> construct<AccClause>(construct<AccClause::Detach>(
- parenthesized(Parser<AccObjectList>{}))) ||
- "DEVICE" >> construct<AccClause>(construct<AccClause::Device>(
- parenthesized(Parser<AccObjectList>{}))) ||
- "DEVICEPTR" >> construct<AccClause>(construct<AccClause::Deviceptr>(
- parenthesized(Parser<AccObjectList>{}))) ||
- "DEVICE_NUM" >> construct<AccClause>(construct<AccClause::DeviceNum>(
- parenthesized(scalarIntExpr))) ||
- "DEVICE_RESIDENT" >>
- construct<AccClause>(construct<AccClause::DeviceResident>(
- parenthesized(Parser<AccObjectList>{}))) ||
- ("DEVICE_TYPE"_tok || "DTYPE"_tok) >>
- construct<AccClause>(construct<AccClause::DeviceType>(
- parenthesized(Parser<AccDeviceTypeExprList>{}))) ||
- "FINALIZE" >> construct<AccClause>(construct<AccClause::Finalize>()) ||
- "FIRSTPRIVATE" >> construct<AccClause>(construct<AccClause::Firstprivate>(
- parenthesized(Parser<AccObjectList>{}))) ||
- "GANG" >> construct<AccClause>(construct<AccClause::Gang>(
- maybe(parenthesized(Parser<AccGangArgument>{})))) ||
- "HOST" >> construct<AccClause>(construct<AccClause::Host>(
- parenthesized(Parser<AccObjectList>{}))) ||
- "IF" >> construct<AccClause>(
- construct<AccClause::If>(parenthesized(scalarLogicalExpr))) ||
- "IF_PRESENT" >> construct<AccClause>(construct<AccClause::IfPresent>()) ||
- "INDEPENDENT" >>
- construct<AccClause>(construct<AccClause::Independent>()) ||
- "LINK" >> construct<AccClause>(construct<AccClause::Link>(
- parenthesized(Parser<AccObjectList>{}))) ||
- "NO_CREATE" >> construct<AccClause>(construct<AccClause::NoCreate>(
- parenthesized(Parser<AccObjectList>{}))) ||
- "NOHOST" >> construct<AccClause>(construct<AccClause::Nohost>()) ||
- "NUM_GANGS" >> construct<AccClause>(construct<AccClause::NumGangs>(
- parenthesized(scalarIntExpr))) ||
- "NUM_WORKERS" >> construct<AccClause>(construct<AccClause::NumWorkers>(
- parenthesized(scalarIntExpr))) ||
- "PRESENT" >> construct<AccClause>(construct<AccClause::Present>(
- parenthesized(Parser<AccObjectList>{}))) ||
- "PRIVATE" >> construct<AccClause>(construct<AccClause::Private>(
- parenthesized(Parser<AccObjectList>{}))) ||
- "READ" >> construct<AccClause>(construct<AccClause::Read>()) ||
- "REDUCTION" >> construct<AccClause>(construct<AccClause::Reduction>(
- parenthesized(construct<AccObjectListWithReduction>(
- Parser<AccReductionOperator>{} / ":",
- Parser<AccObjectList>{})))) ||
- "SELF" >> construct<AccClause>(construct<AccClause::Self>(
- maybe(parenthesized(Parser<AccSelfClause>{})))) ||
- "SEQ" >> construct<AccClause>(construct<AccClause::Seq>()) ||
- "TILE" >> construct<AccClause>(construct<AccClause::Tile>(
- parenthesized(Parser<AccTileExprList>{}))) ||
- "USE_DEVICE" >> construct<AccClause>(construct<AccClause::UseDevice>(
- parenthesized(Parser<AccObjectList>{}))) ||
- "VECTOR_LENGTH" >> construct<AccClause>(construct<AccClause::VectorLength>(
- parenthesized(scalarIntExpr))) ||
- "VECTOR" >>
- construct<AccClause>(construct<AccClause::Vector>(maybe(
- parenthesized(("LENGTH:" >> scalarIntExpr || scalarIntExpr))))) ||
- "WAIT" >> construct<AccClause>(construct<AccClause::Wait>(
- maybe(parenthesized(Parser<AccWaitArgument>{})))) ||
- "WORKER" >>
- construct<AccClause>(construct<AccClause::Worker>(maybe(
- parenthesized(("NUM:" >> scalarIntExpr || scalarIntExpr))))) ||
- "WRITE" >> construct<AccClause>(construct<AccClause::Auto>()))
+// Basic clause parser
+#define GEN_FLANG_CLAUSES_PARSER
----------------
Nit: Can you expand the comment to briefly describe what is the kind of clauses for which parsers can be autogenerated? Or alternatively, what kind of clause parsers are not autogenerated?
================
Comment at: llvm/utils/TableGen/DirectiveEmitter.cpp:772
+
+ GenerateFlangClausesParser(DirLang, OS);
}
----------------
I see that this is autogenerating clause parsers for OpenMP as well. Will you be creating a patch for enabling it or would you like one of us to do it?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106968/new/
https://reviews.llvm.org/D106968
More information about the llvm-commits
mailing list