27#define GEN_DIRECTIVES_IMPL
28#include "llvm/Frontend/OpenMP/OMP.inc"
51 auto firstLoopAssociated =
54 if (getDirectiveAssociation(*It) == Association::Loop)
62 auto Begin = firstLoopAssociated(Leafs);
63 if (Begin == Leafs.end())
68 if (
End == Leafs.end())
71 for (;
End != Leafs.end(); ++
End) {
72 if (getDirectiveAssociation(*
End) != Association::Loop)
80 auto Idx =
static_cast<std::size_t
>(
D);
81 if (
Idx >= Directive_enumSize)
83 const auto *Row = LeafConstructTable[LeafConstructTableOrdering[
Idx]];
84 return ArrayRef(&Row[2],
static_cast<int>(Row[1]));
90 auto Idx =
static_cast<size_t>(
D);
91 assert(
Idx < Directive_enumSize &&
"Invalid directive");
92 const auto *Row = LeafConstructTable[LeafConstructTableOrdering[
Idx]];
94 return ArrayRef(&Row[0], &Row[0] + 1);
100 using IteratorTy = ArrayTy::iterator;
103 IteratorTy Iter = Leafs.
begin();
107 for (; Iter !=
Range.begin(); ++Iter)
109 if (!
Range.empty()) {
112 assert(Comp != OMPD_unknown);
118 assert(Iter == Leafs.
end() &&
"Malformed directive");
120 }
while (Iter != Leafs.
end());
148 if (GivenLeafs.size() == 1)
149 return GivenLeafs.front();
150 RawLeafs[1] =
static_cast<Directive>(GivenLeafs.size());
152 auto Iter = std::lower_bound(
153 LeafConstructTable, LeafConstructTableEndDirective,
154 static_cast<std::decay_t<decltype(*LeafConstructTable)
>>(RawLeafs.
data()),
155 [](
const llvm::omp::Directive *RowA,
const llvm::omp::Directive *RowB) {
156 const auto *BeginA = &RowA[2];
157 const auto *EndA = BeginA + static_cast<int>(RowA[1]);
158 const auto *BeginB = &RowB[2];
159 const auto *EndB = BeginB + static_cast<int>(RowB[1]);
160 if (BeginA == EndA && BeginB == EndB)
161 return static_cast<int>(RowA[0]) < static_cast<int>(RowB[0]);
162 return std::lexicographical_compare(BeginA, EndA, BeginB, EndB);
165 if (Iter == std::end(LeafConstructTable))
171 if (FoundLeafs == GivenLeafs)
180 if (Leafs.
size() <= 1)
193 static unsigned Versions[]{45, 50, 51, 52, 60};
199 if (FunctionName.
ends_with(
".internalized"))
200 return FunctionName.
drop_back(
sizeof(
"internalized")).
str() +
205 return FunctionName.
str();
206 return (
"omp target in " + ParentName +
" @ " + std::to_string(LineNo) +
207 " (" + FunctionName +
")")
221 for (
int I = 0;
I < 3; ++
I) {
222 PrettyName = PrettyName.
drop_while([](
char c) {
return c !=
'_'; });
227 size_t LineIdx = PrettyName.
rfind(
"_l");
230 if (PrettyName.drop_front(LineIdx + 2).consumeInteger(10, LineNo))
232 return demangle(PrettyName.take_front(LineIdx));
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
static iterator_range< ArrayRef< Directive >::iterator > getFirstCompositeRange(iterator_range< ArrayRef< Directive >::iterator > Leafs)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
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.
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - 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.
static constexpr size_t npos
StringRef drop_while(function_ref< bool(char)> F) const
Return a StringRef equal to 'this', but with all characters satisfying the given predicate dropped fr...
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.
ArrayRef< unsigned > getOpenMPVersions()
bool isCombinedConstruct(Directive D)
std::string deconstructOpenMPKernelName(StringRef KernelName, unsigned &LineNo)
Deconstruct an OpenMP kernel name into the parent function name and the line number.
ArrayRef< Directive > getLeafOrCompositeConstructs(Directive D, SmallVectorImpl< Directive > &Output)
bool isCompositeConstruct(Directive D)
Directive getCompoundConstruct(ArrayRef< Directive > Parts)
bool isLeafConstruct(Directive D)
ArrayRef< Directive > getLeafConstructsOrSelf(Directive D)
std::string prettifyFunctionName(StringRef FunctionName)
Create a nicer version of a function name for humans to look at.
ArrayRef< Directive > getLeafConstructs(Directive D)
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.
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.