mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[OpenMP] Add initial support for omp [begin/end] assumes
The `assumes` directive is an OpenMP 5.1 feature that allows the user to provide assumptions to the optimizer. Assumptions can refer to directives (`absent` and `contains` clauses), expressions (`holds` clause), or generic properties (`no_openmp_routines`, `ext_ABCD`, ...). The `assumes` spelling is used for assumptions in the global scope while `assume` is used for executable contexts with an associated structured block. This patch only implements the global spellings. While clauses with arguments are "accepted" by the parser, they will simply be ignored for now. The implementation lowers the assumptions directly to the `AssumptionAttr`. Reviewed By: ABataev Differential Revision: https://reviews.llvm.org/D91980
This commit is contained in:
parent
fb6eef330d
commit
62ee447a70
@ -1593,6 +1593,9 @@ def OMP_Scan : Directive<"scan"> {
|
||||
VersionedClause<OMPC_Exclusive, 50>
|
||||
];
|
||||
}
|
||||
def OMP_Assumes : Directive<"assumes"> {}
|
||||
def OMP_BeginAssumes : Directive<"begin assumes"> {}
|
||||
def OMP_EndAssumes : Directive<"end assumes"> {}
|
||||
def OMP_BeginDeclareVariant : Directive<"begin declare variant"> {}
|
||||
def OMP_EndDeclareVariant : Directive<"end declare variant"> {}
|
||||
def OMP_ParallelWorkshare : Directive<"parallel workshare"> {
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "llvm/ADT/BitmaskEnum.h"
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Frontend/OpenMP/OMP.h.inc"
|
||||
|
||||
namespace llvm {
|
||||
@ -79,6 +80,33 @@ enum class IdentFlag {
|
||||
#define OMP_IDENT_FLAG(Enum, ...) constexpr auto Enum = omp::IdentFlag::Enum;
|
||||
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
||||
|
||||
/// Helper to describe assume clauses.
|
||||
struct AssumptionClauseMappingInfo {
|
||||
/// The identifier describing the (beginning of the) clause.
|
||||
llvm::StringLiteral Identifier;
|
||||
/// Flag to determine if the identifier is a full name or the start of a name.
|
||||
bool StartsWith;
|
||||
/// Flag to determine if a directive lists follows.
|
||||
bool HasDirectiveList;
|
||||
/// Flag to determine if an expression follows.
|
||||
bool HasExpression;
|
||||
};
|
||||
|
||||
/// All known assume clauses.
|
||||
static constexpr AssumptionClauseMappingInfo AssumptionClauseMappings[] = {
|
||||
#define OMP_ASSUME_CLAUSE(Identifier, StartsWith, HasDirectiveList, \
|
||||
HasExpression) \
|
||||
{Identifier, StartsWith, HasDirectiveList, HasExpression},
|
||||
#include "llvm/Frontend/OpenMP/OMPKinds.def"
|
||||
};
|
||||
|
||||
inline std::string getAllAssumeClauseOptions() {
|
||||
std::string S;
|
||||
for (const AssumptionClauseMappingInfo &ACMI : AssumptionClauseMappings)
|
||||
S += (S.empty() ? "'" : "', '") + ACMI.Identifier.str();
|
||||
return S + "'";
|
||||
}
|
||||
|
||||
} // end namespace omp
|
||||
|
||||
} // end namespace llvm
|
||||
|
@ -1224,3 +1224,27 @@ OMP_LAST_TRAIT_PROPERTY(
|
||||
#undef __OMP_REQUIRES_TRAIT
|
||||
#undef OMP_REQUIRES_TRAIT
|
||||
///}
|
||||
|
||||
|
||||
/// Assumption clauses
|
||||
///
|
||||
///{
|
||||
|
||||
#ifdef OMP_ASSUME_CLAUSE
|
||||
#define __OMP_ASSUME_CLAUSE(Identifier, StartsWith, HasDirectiveList, HasExpression) \
|
||||
OMP_ASSUME_CLAUSE(Identifier, StartsWith, HasDirectiveList, HasExpression)
|
||||
#else
|
||||
#define __OMP_ASSUME_CLAUSE(...)
|
||||
#endif
|
||||
|
||||
__OMP_ASSUME_CLAUSE(llvm::StringLiteral("ext_"), true, false, false)
|
||||
__OMP_ASSUME_CLAUSE(llvm::StringLiteral("absent"), false, true, false)
|
||||
__OMP_ASSUME_CLAUSE(llvm::StringLiteral("contains"), false, true, false)
|
||||
__OMP_ASSUME_CLAUSE(llvm::StringLiteral("holds"), false, false, true)
|
||||
__OMP_ASSUME_CLAUSE(llvm::StringLiteral("no_openmp"), false, false, false)
|
||||
__OMP_ASSUME_CLAUSE(llvm::StringLiteral("no_openmp_routines"), false, false, false)
|
||||
__OMP_ASSUME_CLAUSE(llvm::StringLiteral("no_parallelism"), false, false, false)
|
||||
|
||||
#undef __OMP_ASSUME_CLAUSE
|
||||
#undef OMP_ASSUME_CLAUSE
|
||||
///}
|
||||
|
Loading…
Reference in New Issue
Block a user