llvm-project/clang/lib/Parse
Michael Kruse b119120673 [clang][OpenMP] Use OpenMPIRBuilder for workshare loops.
Initial support for using the OpenMPIRBuilder by clang to generate loops using the OpenMPIRBuilder. This initial support is intentionally limited to:
 * Only the worksharing-loop directive.
 * Recognizes only the nowait clause.
 * No loop nests with more than one loop.
 * Untested with templates, exceptions.
 * Semantic checking left to the existing infrastructure.

This patch introduces a new AST node, OMPCanonicalLoop, which becomes parent of any loop that has to adheres to the restrictions as specified by the OpenMP standard. These restrictions allow OMPCanonicalLoop to provide the following additional information that depends on base language semantics:
 * The distance function: How many loop iterations there will be before entering the loop nest.
 * The loop variable function: Conversion from a logical iteration number to the loop variable.

These allow the OpenMPIRBuilder to act solely using logical iteration numbers without needing to be concerned with iterator semantics between calling the distance function and determining what the value of the loop variable ought to be. Any OpenMP logical should be done by the OpenMPIRBuilder such that it can be reused MLIR OpenMP dialect and thus by flang.

The distance and loop variable function are implemented using lambdas (or more exactly: CapturedStmt because lambda implementation is more interviewed with the parser). It is up to the OpenMPIRBuilder how they are called which depends on what is done with the loop. By default, these are emitted as outlined functions but we might think about emitting them inline as the OpenMPRuntime does.

For compatibility with the current OpenMP implementation, even though not necessary for the OpenMPIRBuilder, OMPCanonicalLoop can still be nested within OMPLoopDirectives' CapturedStmt. Although OMPCanonicalLoop's are not currently generated when the OpenMPIRBuilder is not enabled, these can just be skipped when not using the OpenMPIRBuilder in case we don't want to make the AST dependent on the EnableOMPBuilder setting.

Loop nests with more than one loop require support by the OpenMPIRBuilder (D93268). A simple implementation of non-rectangular loop nests would add another lambda function that returns whether a loop iteration of the rectangular overapproximation is also within its non-rectangular subset.

Reviewed By: jdenny

Differential Revision: https://reviews.llvm.org/D94973
2021-03-04 22:52:59 -06:00
..
CMakeLists.txt [openmp] Base of tablegen generated OpenMP common declaration 2020-06-23 10:32:32 -04:00
ParseAST.cpp [Support] Add TimeTraceScope constructor without detail arg 2019-12-11 14:32:21 +00:00
ParseCXXInlineMethods.cpp [NFC, Refactor] Modernize enum FunctionDefinitionKind (DeclSpech.h) into a scoped enum 2020-11-21 09:49:52 -06:00
ParseDecl.cpp [clang][parse][NFC] Remove dead ProhibitAttributes() call 2021-02-23 13:54:35 +01:00
ParseDeclCXX.cpp Improve static_assert/_Static_assert diagnostics 2021-03-03 08:48:27 -05:00
ParseExpr.cpp [OpenCL] Allow taking address of functions as an extension. 2021-02-24 12:32:02 +00:00
ParseExprCXX.cpp Implement P2173 for attributes on lambdas 2021-03-03 10:05:39 -05:00
ParseInit.cpp [CodeComplete] Guess type for designated initializers 2021-02-04 22:14:49 +01:00
ParseObjc.cpp Parse different attribute syntaxes in arbitrary order 2021-01-27 15:30:15 -05:00
ParseOpenMP.cpp [clang][OpenMP] Use OpenMPIRBuilder for workshare loops. 2021-03-04 22:52:59 -06:00
ParsePragma.cpp [OpenCL] Prevent adding extension pragma by default. 2021-03-03 15:02:21 +00:00
ParseStmt.cpp [Attr] Apply GNU-style attributes to expression statements 2021-02-11 16:44:41 +03:00
ParseStmtAsm.cpp [Parser] ParseMicrosoftAsmStatement - Replace bit '|' operator with logical '||' operator. (PR47071) 2020-10-05 14:23:28 +01:00
ParseTemplate.cpp PR45699: Fix crash if an unexpanded parameter pack appears in a 2020-12-03 15:26:06 -08:00
ParseTentative.cpp [clang] Add a new nullability annotation for swift async: _Nullable_result 2020-12-07 17:19:20 -05:00
Parser.cpp [NFC, Refactor] Modernize enum FunctionDefinitionKind (DeclSpech.h) into a scoped enum 2020-11-21 09:49:52 -06:00