LLVM: lib/IR/MemoryModelRelaxationAnnotations.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
14
15using namespace llvm;
16
17
18
21
23 if (!MD)
24 return;
25
26
27
28
29 MDTuple *Tuple = dyn_cast(MD);
30 assert(Tuple && "Invalid MMRA structure");
31
32 const auto HandleTagMD = [this](MDNode *TagMD) {
33 Tags.insert({cast(TagMD->getOperand(0))->getString(),
34 cast(TagMD->getOperand(1))->getString()});
35 };
36
38 HandleTagMD(Tuple);
39 return;
40 }
41
43 MDNode *MDOp = cast(Op.get());
45 HandleTagMD(MDOp);
46 }
47}
48
50 if (auto *Tuple = dyn_cast(MD)) {
51 return Tuple->getNumOperands() == 2 &&
52 isa(Tuple->getOperand(0)) &&
53 isa(Tuple->getOperand(1));
54 }
55 return false;
56}
57
62}
63
67 return nullptr;
68
69 if (Tags.size() == 1)
71
73 for (const auto &Tag : Tags)
76}
77
80
81
82
83
84
85
86
88
89 for (const auto &[P, S] : A) {
91 Result.push_back(getTagMD(Ctx, P, S));
92 }
93 for (const auto &[P, S] : B) {
95 Result.push_back(getTagMD(Ctx, P, S));
96 }
97
99}
100
102 return Tags.count({Prefix, Suffix});
103}
104
106
107
108
109
110
112 for (const auto &[P, S] : Tags)
113 PrefixStatuses[P] |= (Other.hasTag(P, S) || .hasTagWithPrefix(P));
114 for (const auto &[P, S] : Other)
116
117 for (auto &[Prefix, Status] : PrefixStatuses) {
119 return false;
120 }
121
122 return true;
123}
124
126 for (const auto &[P, S] : Tags)
127 if (P == Prefix)
128 return true;
129 return false;
130}
131
133 return Tags.begin();
134}
135
137
139
141
143 bool IsFirst = true;
144
145 for (const auto &[P, S] : Tags) {
146 if (IsFirst)
147 IsFirst = false;
148 else
149 OS << ", ";
151 }
152}
153
156
157
158
160 if (const auto *C = dyn_cast(&I))
161 return C->mayReadOrWriteMemory() ||
162 ->getMemoryEffects().doesNotAccessMemory();
163 return false;
164}
165
167 return isa(I) || isa(I) || isa(I) ||
169}
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
static bool isReadWriteMemCall(const Instruction &I)
This file provides utility for Memory Model Relaxation Annotations (MMRAs).
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
const T & front() const
front - Get the first element.
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
This class represents an Operation in the Expression.
This is an important class for using LLVM in a threaded context.
ArrayRef< MDOperand > operands() const
Tracking metadata reference owned by Metadata.
static MDString * get(LLVMContext &Context, StringRef Str)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringRef - Represent a constant reference to a string, i.e.
std::pair< iterator, bool > insert(const ValueT &V)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
This class implements an extremely fast bulk output stream that can only output to a stream.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
bool canInstructionHaveMMRAs(const Instruction &I)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.