29#define GEN_DIRECTIVES_IMPL
30#include "llvm/Frontend/OpenMP/OMP.inc"
53 auto firstLoopAssociated =
55 for (
auto It = List.begin(), End = List.end(); It != End; ++It) {
56 if (getDirectiveAssociation(*It) == Association::LoopNest)
64 auto Begin = firstLoopAssociated(Leafs);
65 if (Begin == Leafs.end())
70 if (End == Leafs.end())
73 for (; End != Leafs.end(); ++End) {
74 if (getDirectiveAssociation(*End) != Association::LoopNest)
91 return isAllowedClauseForDirective(
D,
C, Version);
93 if (AllowsPrivatizing)
100 auto Idx =
static_cast<std::size_t
>(
D);
101 if (Idx >= Directive_enumSize)
103 const auto *Row = LeafConstructTable[LeafConstructTableOrdering[Idx]];
104 return ArrayRef(&Row[2],
static_cast<int>(Row[1]));
110 auto Idx =
static_cast<size_t>(
D);
111 assert(Idx < Directive_enumSize &&
"Invalid directive");
112 const auto *Row = LeafConstructTable[LeafConstructTableOrdering[Idx]];
114 return ArrayRef(&Row[0], &Row[0] + 1);
120 using IteratorTy = ArrayTy::iterator;
123 IteratorTy Iter = Leafs.
begin();
127 for (; Iter !=
Range.begin(); ++Iter)
129 if (!
Range.empty()) {
132 assert(Comp != OMPD_unknown);
138 assert(Iter == Leafs.
end() &&
"Malformed directive");
140 }
while (Iter != Leafs.
end());
168 if (GivenLeafs.size() == 1)
169 return GivenLeafs.front();
170 RawLeafs[1] =
static_cast<Directive>(GivenLeafs.size());
172 auto Iter = std::lower_bound(
173 LeafConstructTable, LeafConstructTableEndDirective,
174 static_cast<std::decay_t<decltype(*LeafConstructTable)
>>(RawLeafs.
data()),
175 [](
const llvm::omp::Directive *RowA,
const llvm::omp::Directive *RowB) {
176 const auto *BeginA = &RowA[2];
177 const auto *EndA = BeginA + static_cast<int>(RowA[1]);
178 const auto *BeginB = &RowB[2];
179 const auto *EndB = BeginB + static_cast<int>(RowB[1]);
180 if (BeginA == EndA && BeginB == EndB)
181 return static_cast<int>(RowA[0]) < static_cast<int>(RowB[0]);
182 return std::lexicographical_compare(BeginA, EndA, BeginB, EndB);
185 if (Iter == std::end(LeafConstructTable))
191 if (FoundLeafs == GivenLeafs)
200 if (Leafs.
size() <= 1)
213 static unsigned Versions[]{31, 40, 45, 50, 51, 52, 60, 61};
219 [[maybe_unused]]
static bool Init =
231 static StringRef names[]{
"omp_all_memory"};
237 if (FunctionName.
ends_with(
".internalized"))
238 return FunctionName.
drop_back(
sizeof(
"internalized")).
str() +
243 return FunctionName.
str();
244 return (
"omp target in " + ParentName +
" @ " + std::to_string(LineNo) +
245 " (" + FunctionName +
")")
259 for (
int I = 0;
I < 3; ++
I) {
260 PrettyName = PrettyName.drop_while([](
char c) {
return c !=
'_'; });
261 PrettyName = PrettyName.drop_front();
265 size_t LineIdx = PrettyName.
rfind(
"_l");
268 if (PrettyName.drop_front(LineIdx + 2).consumeInteger(10, LineNo))
270 return demangle(PrettyName.take_front(LineIdx));
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
static iterator_range< ArrayRef< Directive >::iterator > getFirstCompositeRange(iterator_range< ArrayRef< Directive >::iterator > Leafs)
static void collectPrivatizingConstructs(llvm::SmallSet< Directive, 16 > &Constructs, unsigned Version)
Provides some synthesis utilities to produce sequences of values.
This file defines the SmallSet class.
This file defines the SmallVector class.
LocallyHashedType DenseMapInfo< LocallyHashedType >::Empty
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
bool empty() const
Check if the array is empty.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
pointer data()
Return a pointer to the vector's buffer, even if empty().
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
static constexpr size_t npos
std::string str() const
Get the contents as an std::string.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
size_t rfind(char C, size_t From=npos) const
Search for the last character C in the string.
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
StringRef drop_back(size_t N=1) const
Return a StringRef equal to 'this' but with the last N elements dropped.
A range adaptor for a pair of iterators.
@ C
The default llvm calling convention, compatible with C.
static constexpr auto clauses()
LLVM_ABI ArrayRef< unsigned > getOpenMPVersions()
LLVM_ABI bool isCombinedConstruct(Directive D)
LLVM_ABI std::string deconstructOpenMPKernelName(StringRef KernelName, unsigned &LineNo)
Deconstruct an OpenMP kernel name into the parent function name and the line number.
LLVM_ABI ArrayRef< Directive > getLeafOrCompositeConstructs(Directive D, SmallVectorImpl< Directive > &Output)
LLVM_ABI bool isPrivatizingConstruct(Directive D, unsigned Version)
Can directive D, under some circumstances, create a private copy of a variable in given OpenMP versio...
LLVM_ABI bool isCompositeConstruct(Directive D)
LLVM_ABI Directive getCompoundConstruct(ArrayRef< Directive > Parts)
LLVM_ABI ArrayRef< StringRef > getReservedLocatorNames()
LLVM_ABI bool isLeafConstruct(Directive D)
LLVM_ABI ArrayRef< Directive > getLeafConstructsOrSelf(Directive D)
LLVM_ABI std::string prettifyFunctionName(StringRef FunctionName)
Create a nicer version of a function name for humans to look at.
static constexpr auto directives()
LLVM_ABI ArrayRef< Directive > getLeafConstructs(Directive D)
static constexpr bool isPrivatizingClause(Clause C, unsigned Version)
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
ArrayRef(const T &OneElt) -> ArrayRef< T >
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
DEMANGLE_ABI std::string demangle(std::string_view MangledName)
Attempt to demangle a string using different demangling schemes.
static constexpr const char * KernelNamePrefix
The prefix used for kernel names.