59 unsigned char Lead[2];
60 unsigned char Param[5];
62 int maxLeadIndex()
const {
return (
std::max)(Lead[0], Lead[1]); }
63 int getNumLeads()
const {
return (Lead[0] ? 1 : 0) + (Lead[1] ? 1 : 0); }
65 unsigned getNumArgs()
const;
71 class UnmangledFuncInfo {
76 static const UnmangledFuncInfo Table[];
79 static const unsigned TableSize;
85 constexpr UnmangledFuncInfo(
const char *_Name,
unsigned _NumArgs)
86 :
Name(_Name), NumArgs(_NumArgs) {}
89 static unsigned toIndex(
ID Id) {
90 assert(static_cast<unsigned>(Id) >
92 "Invalid unmangled library function");
93 return static_cast<unsigned>(
Id) - 1 -
96 static ID toFuncId(
unsigned Index) {
97 assert(Index < TableSize &&
98 "Invalid unmangled library function");
99 return static_cast<ID>(
102 static unsigned getNumArgs(
ID Id) {
return Table[toIndex(Id)].NumArgs; }
106 unsigned ManglingRule::getNumArgs()
const {
108 while (I < (
sizeof Param/
sizeof Param[0]) && Param[I]) ++
I;
136 static constexpr ManglingRule manglingRules[] = {
138 {
"abs" , {1}, {E_ANY}},
139 {
"abs_diff" , {1}, {E_ANY,E_COPY}},
140 {
"acos" , {1}, {E_ANY}},
141 {
"acosh" , {1}, {E_ANY}},
142 {
"acospi" , {1}, {E_ANY}},
143 {
"add_sat" , {1}, {E_ANY,E_COPY}},
144 {
"all" , {1}, {E_ANY}},
145 {
"any" , {1}, {E_ANY}},
146 {
"asin" , {1}, {E_ANY}},
147 {
"asinh" , {1}, {E_ANY}},
148 {
"asinpi" , {1}, {E_ANY}},
149 {
"async_work_group_copy" , {1}, {E_ANY,E_CONSTPTR_SWAPGL,EX_SIZET,EX_EVENT}},
150 {
"async_work_group_strided_copy" , {1}, {E_ANY,E_CONSTPTR_SWAPGL,EX_SIZET,EX_SIZET,EX_EVENT}},
151 {
"atan" , {1}, {E_ANY}},
152 {
"atan2" , {1}, {E_ANY,E_COPY}},
153 {
"atan2pi" , {1}, {E_ANY,E_COPY}},
154 {
"atanh" , {1}, {E_ANY}},
155 {
"atanpi" , {1}, {E_ANY}},
156 {
"atomic_add" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
157 {
"atomic_and" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
158 {
"atomic_cmpxchg" , {1}, {E_VLTLPTR_ANY,E_POINTEE,E_POINTEE}},
159 {
"atomic_dec" , {1}, {E_VLTLPTR_ANY}},
160 {
"atomic_inc" , {1}, {E_VLTLPTR_ANY}},
161 {
"atomic_max" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
162 {
"atomic_min" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
163 {
"atomic_or" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
164 {
"atomic_sub" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
165 {
"atomic_xchg" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
166 {
"atomic_xor" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
167 {
"bitselect" , {1}, {E_ANY,E_COPY,E_COPY}},
168 {
"cbrt" , {1}, {E_ANY}},
169 {
"ceil" , {1}, {E_ANY}},
170 {
"clamp" , {1}, {E_ANY,E_COPY,E_COPY}},
171 {
"clz" , {1}, {E_ANY}},
172 {
"commit_read_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
173 {
"commit_write_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
174 {
"copysign" , {1}, {E_ANY,E_COPY}},
175 {
"cos" , {1}, {E_ANY}},
176 {
"cosh" , {1}, {E_ANY}},
177 {
"cospi" , {1}, {E_ANY}},
178 {
"cross" , {1}, {E_ANY,E_COPY}},
179 {
"ctz" , {1}, {E_ANY}},
180 {
"degrees" , {1}, {E_ANY}},
181 {
"distance" , {1}, {E_ANY,E_COPY}},
182 {
"divide" , {1}, {E_ANY,E_COPY}},
183 {
"dot" , {1}, {E_ANY,E_COPY}},
184 {
"erf" , {1}, {E_ANY}},
185 {
"erfc" , {1}, {E_ANY}},
186 {
"exp" , {1}, {E_ANY}},
187 {
"exp10" , {1}, {E_ANY}},
188 {
"exp2" , {1}, {E_ANY}},
189 {
"expm1" , {1}, {E_ANY}},
190 {
"fabs" , {1}, {E_ANY}},
191 {
"fast_distance" , {1}, {E_ANY,E_COPY}},
192 {
"fast_length" , {1}, {E_ANY}},
193 {
"fast_normalize" , {1}, {E_ANY}},
194 {
"fdim" , {1}, {E_ANY,E_COPY}},
195 {
"floor" , {1}, {E_ANY}},
196 {
"fma" , {1}, {E_ANY,E_COPY,E_COPY}},
197 {
"fmax" , {1}, {E_ANY,E_COPY}},
198 {
"fmin" , {1}, {E_ANY,E_COPY}},
199 {
"fmod" , {1}, {E_ANY,E_COPY}},
200 {
"fract" , {2}, {E_POINTEE,E_ANY}},
201 {
"frexp" , {1,2}, {E_ANY,E_ANY}},
202 {
"get_image_array_size" , {1}, {E_ANY}},
203 {
"get_image_channel_data_type" , {1}, {E_ANY}},
204 {
"get_image_channel_order" , {1}, {E_ANY}},
205 {
"get_image_dim" , {1}, {E_ANY}},
206 {
"get_image_height" , {1}, {E_ANY}},
207 {
"get_image_width" , {1}, {E_ANY}},
208 {
"get_pipe_max_packets" , {1}, {E_ANY}},
209 {
"get_pipe_num_packets" , {1}, {E_ANY}},
210 {
"hadd" , {1}, {E_ANY,E_COPY}},
211 {
"hypot" , {1}, {E_ANY,E_COPY}},
212 {
"ilogb" , {1}, {E_ANY}},
213 {
"isequal" , {1}, {E_ANY,E_COPY}},
214 {
"isfinite" , {1}, {E_ANY}},
215 {
"isgreater" , {1}, {E_ANY,E_COPY}},
216 {
"isgreaterequal" , {1}, {E_ANY,E_COPY}},
217 {
"isinf" , {1}, {E_ANY}},
218 {
"isless" , {1}, {E_ANY,E_COPY}},
219 {
"islessequal" , {1}, {E_ANY,E_COPY}},
220 {
"islessgreater" , {1}, {E_ANY,E_COPY}},
221 {
"isnan" , {1}, {E_ANY}},
222 {
"isnormal" , {1}, {E_ANY}},
223 {
"isnotequal" , {1}, {E_ANY,E_COPY}},
224 {
"isordered" , {1}, {E_ANY,E_COPY}},
225 {
"isunordered" , {1}, {E_ANY,E_COPY}},
226 {
"ldexp" , {1}, {E_ANY,E_SETBASE_I32}},
227 {
"length" , {1}, {E_ANY}},
228 {
"lgamma" , {1}, {E_ANY}},
229 {
"lgamma_r" , {1,2}, {E_ANY,E_ANY}},
230 {
"log" , {1}, {E_ANY}},
231 {
"log10" , {1}, {E_ANY}},
232 {
"log1p" , {1}, {E_ANY}},
233 {
"log2" , {1}, {E_ANY}},
234 {
"logb" , {1}, {E_ANY}},
235 {
"mad" , {1}, {E_ANY,E_COPY,E_COPY}},
236 {
"mad24" , {1}, {E_ANY,E_COPY,E_COPY}},
237 {
"mad_hi" , {1}, {E_ANY,E_COPY,E_COPY}},
238 {
"mad_sat" , {1}, {E_ANY,E_COPY,E_COPY}},
239 {
"max" , {1}, {E_ANY,E_COPY}},
240 {
"maxmag" , {1}, {E_ANY,E_COPY}},
241 {
"min" , {1}, {E_ANY,E_COPY}},
242 {
"minmag" , {1}, {E_ANY,E_COPY}},
243 {
"mix" , {1}, {E_ANY,E_COPY,E_COPY}},
244 {
"modf" , {2}, {E_POINTEE,E_ANY}},
245 {
"mul24" , {1}, {E_ANY,E_COPY}},
246 {
"mul_hi" , {1}, {E_ANY,E_COPY}},
247 {
"nan" , {1}, {E_ANY}},
248 {
"nextafter" , {1}, {E_ANY,E_COPY}},
249 {
"normalize" , {1}, {E_ANY}},
250 {
"popcount" , {1}, {E_ANY}},
251 {
"pow" , {1}, {E_ANY,E_COPY}},
252 {
"pown" , {1}, {E_ANY,E_SETBASE_I32}},
253 {
"powr" , {1}, {E_ANY,E_COPY}},
254 {
"prefetch" , {1}, {E_CONSTPTR_ANY,EX_SIZET}},
255 {
"radians" , {1}, {E_ANY}},
256 {
"recip" , {1}, {E_ANY}},
257 {
"remainder" , {1}, {E_ANY,E_COPY}},
258 {
"remquo" , {1,3}, {E_ANY,E_COPY,E_ANY}},
259 {
"reserve_read_pipe" , {1}, {E_ANY,EX_UINT}},
260 {
"reserve_write_pipe" , {1}, {E_ANY,EX_UINT}},
261 {
"rhadd" , {1}, {E_ANY,E_COPY}},
262 {
"rint" , {1}, {E_ANY}},
263 {
"rootn" , {1}, {E_ANY,E_SETBASE_I32}},
264 {
"rotate" , {1}, {E_ANY,E_COPY}},
265 {
"round" , {1}, {E_ANY}},
266 {
"rsqrt" , {1}, {E_ANY}},
267 {
"select" , {1,3}, {E_ANY,E_COPY,E_ANY}},
268 {
"shuffle" , {1,2}, {E_ANY,E_ANY}},
269 {
"shuffle2" , {1,3}, {E_ANY,E_COPY,E_ANY}},
270 {
"sign" , {1}, {E_ANY}},
271 {
"signbit" , {1}, {E_ANY}},
272 {
"sin" , {1}, {E_ANY}},
273 {
"sincos" , {2}, {E_POINTEE,E_ANY}},
274 {
"sinh" , {1}, {E_ANY}},
275 {
"sinpi" , {1}, {E_ANY}},
276 {
"smoothstep" , {1}, {E_ANY,E_COPY,E_COPY}},
277 {
"sqrt" , {1}, {E_ANY}},
278 {
"step" , {1}, {E_ANY,E_COPY}},
279 {
"sub_group_broadcast" , {1}, {E_ANY,EX_UINT}},
280 {
"sub_group_commit_read_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
281 {
"sub_group_commit_write_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
282 {
"sub_group_reduce_add" , {1}, {E_ANY}},
283 {
"sub_group_reduce_max" , {1}, {E_ANY}},
284 {
"sub_group_reduce_min" , {1}, {E_ANY}},
285 {
"sub_group_reserve_read_pipe" , {1}, {E_ANY,EX_UINT}},
286 {
"sub_group_reserve_write_pipe" , {1}, {E_ANY,EX_UINT}},
287 {
"sub_group_scan_exclusive_add" , {1}, {E_ANY}},
288 {
"sub_group_scan_exclusive_max" , {1}, {E_ANY}},
289 {
"sub_group_scan_exclusive_min" , {1}, {E_ANY}},
290 {
"sub_group_scan_inclusive_add" , {1}, {E_ANY}},
291 {
"sub_group_scan_inclusive_max" , {1}, {E_ANY}},
292 {
"sub_group_scan_inclusive_min" , {1}, {E_ANY}},
293 {
"sub_sat" , {1}, {E_ANY,E_COPY}},
294 {
"tan" , {1}, {E_ANY}},
295 {
"tanh" , {1}, {E_ANY}},
296 {
"tanpi" , {1}, {E_ANY}},
297 {
"tgamma" , {1}, {E_ANY}},
298 {
"trunc" , {1}, {E_ANY}},
299 {
"upsample" , {1}, {E_ANY,E_MAKEBASE_UNS}},
300 {
"vec_step" , {1}, {E_ANY}},
301 {
"vstore" , {3}, {E_POINTEE,EX_SIZET,E_ANY}},
302 {
"vstore16" , {3}, {E_V16_OF_POINTEE,EX_SIZET,E_ANY}},
303 {
"vstore2" , {3}, {E_V2_OF_POINTEE,EX_SIZET,E_ANY}},
304 {
"vstore3" , {3}, {E_V3_OF_POINTEE,EX_SIZET,E_ANY}},
305 {
"vstore4" , {3}, {E_V4_OF_POINTEE,EX_SIZET,E_ANY}},
306 {
"vstore8" , {3}, {E_V8_OF_POINTEE,EX_SIZET,E_ANY}},
307 {
"work_group_commit_read_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
308 {
"work_group_commit_write_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
309 {
"work_group_reduce_add" , {1}, {E_ANY}},
310 {
"work_group_reduce_max" , {1}, {E_ANY}},
311 {
"work_group_reduce_min" , {1}, {E_ANY}},
312 {
"work_group_reserve_read_pipe" , {1}, {E_ANY,EX_UINT}},
313 {
"work_group_reserve_write_pipe" , {1}, {E_ANY,EX_UINT}},
314 {
"work_group_scan_exclusive_add" , {1}, {E_ANY}},
315 {
"work_group_scan_exclusive_max" , {1}, {E_ANY}},
316 {
"work_group_scan_exclusive_min" , {1}, {E_ANY}},
317 {
"work_group_scan_inclusive_add" , {1}, {E_ANY}},
318 {
"work_group_scan_inclusive_max" , {1}, {E_ANY}},
319 {
"work_group_scan_inclusive_min" , {1}, {E_ANY}},
320 {
"write_imagef" , {1}, {E_ANY,E_IMAGECOORDS,EX_FLOAT4}},
321 {
"write_imagei" , {1}, {E_ANY,E_IMAGECOORDS,EX_INTV4}},
322 {
"write_imageui" , {1}, {E_ANY,E_IMAGECOORDS,EX_UINTV4}},
323 {
"ncos" , {1}, {E_ANY} },
324 {
"nexp2" , {1}, {E_ANY} },
325 {
"nfma" , {1}, {E_ANY, E_COPY, E_COPY} },
326 {
"nlog2" , {1}, {E_ANY} },
327 {
"nrcp" , {1}, {E_ANY} },
328 {
"nrsqrt" , {1}, {E_ANY} },
329 {
"nsin" , {1}, {E_ANY} },
330 {
"nsqrt" , {1}, {E_ANY} },
331 {
"ftz" , {1}, {E_ANY} },
332 {
"fldexp" , {1}, {E_ANY, EX_UINT} },
333 {
"class" , {1}, {E_ANY, EX_UINT} },
334 {
"rcbrt" , {1}, {E_ANY} },
338 const UnmangledFuncInfo UnmangledFuncInfo::Table[] = {
339 {
"__read_pipe_2", 4},
340 {
"__read_pipe_4", 6},
341 {
"__write_pipe_2", 4},
342 {
"__write_pipe_4", 6},
345 const unsigned UnmangledFuncInfo::TableSize =
349 const AMDGPULibFunc::Param (&Leads)[2]) {
350 AMDGPULibFunc::Param Res = Leads[0];
362 class ParamIterator {
363 const AMDGPULibFunc::Param (&Leads)[2];
364 const ManglingRule& Rule;
367 ParamIterator(
const AMDGPULibFunc::Param (&leads)[2],
368 const ManglingRule& rule)
369 : Leads(leads), Rule(rule),
Index(0) {}
371 AMDGPULibFunc::Param getNextParam();
374 AMDGPULibFunc::Param ParamIterator::getNextParam() {
375 AMDGPULibFunc::Param
P;
376 if (
Index >=
int(
sizeof Rule.Param/
sizeof Rule.Param[0]))
return P;
378 const char R = Rule.Param[
Index];
395 case EX_RESERVEDID:
break;
397 if (
Index == (Rule.Lead[1] - 1)) P = Leads[1];
406 case E_V2_OF_POINTEE:
408 case E_V3_OF_POINTEE:
410 case E_V4_OF_POINTEE:
412 case E_V8_OF_POINTEE:
414 case E_V16_OF_POINTEE:
443 case E_CONSTPTR_SWAPGL: {
461 inline static void drop_front(
StringRef& str,
size_t n = 1) {
465 static bool eatTerm(
StringRef& mangledName,
const char c) {
466 if (mangledName.
front() == c) {
467 drop_front(mangledName);
474 static bool eatTerm(
StringRef& mangledName,
const char (&str)[
N]) {
476 drop_front(mangledName, N-1);
482 static inline bool isDigit(
char c) {
return c >=
'0' && c <=
'9'; }
485 size_t const savedSize = s.
size();
488 n = n*10 + s.
front() -
'0';
491 return s.
size() < savedSize ? n : -1;
495 int const Len = eatNumber(mangledName);
496 if (Len <= 0 || static_cast<size_t>(Len) > mangledName.
size())
499 drop_front(mangledName, Len);
521 FKind = copyFrom.
FKind;
522 Leads[0] = copyFrom.
Leads[0];
523 Leads[1] = copyFrom.
Leads[1];
530 size_t const Len = eatNumber(mangledName);
532 case 2:
case 3:
case 4:
case 8:
case 16:
541 std::pair<StringRef, StringRef>
const P = mangledName.
split(
'_');
549 mangledName = P.second;
557 for (
auto Rule : manglingRules)
558 Map.
insert({Rule.Name, Id++});
562 bool AMDGPUMangledLibFunc::parseUnmangledName(
StringRef FullName) {
564 ManglingRule::buildManglingRulesMap();
565 FuncId =
static_cast<EFuncId
>(manglingRulesMap.
lookup(FullName));
573 struct ItaniumParamParser {
574 AMDGPULibFunc::Param Prev;
575 bool parseItaniumParam(
StringRef& param, AMDGPULibFunc::Param &res);
579 bool ItaniumParamParser::parseItaniumParam(
StringRef& param,
580 AMDGPULibFunc::Param &res) {
582 if (param.
empty())
return false;
585 if (eatTerm(param,
'P')) {
589 if (!eatTerm(param,
"U3AS")) {
592 AS = param.
front() -
'0';
593 drop_front(param, 1);
601 if (eatTerm(param,
"Dv")) {
603 if (res.VectorSize==1 || !eatTerm(param,
'_'))
return false;
607 char const TC = param.
front();
610 (eatLengthPrefixedName(param))
633 case 'D':
if (!eatTerm(param,
'h'))
return false;
636 if (!eatTerm(param,
'_')) {
638 if (!eatTerm(param,
'_'))
return false;
640 res.VectorSize = Prev.VectorSize;
641 res.ArgType = Prev.ArgType;
646 if (res.ArgType == 0)
return false;
647 Prev.VectorSize = res.VectorSize;
648 Prev.ArgType = res.ArgType;
655 if (!parseUnmangledName(Name))
658 const ManglingRule& Rule = manglingRules[
FuncId];
659 ItaniumParamParser Parser;
660 for (
int I=0;
I < Rule.maxLeadIndex(); ++
I) {
662 if (!Parser.parseItaniumParam(mangledName, P))
665 if ((
I + 1) == Rule.Lead[0]) Leads[0] = P;
666 if ((
I + 1) == Rule.Lead[1]) Leads[1] = P;
679 if (FuncName.
empty()) {
680 F.Impl = std::unique_ptr<AMDGPULibFuncImpl>();
684 if (eatTerm(FuncName,
"_Z"))
685 F.Impl = std::make_unique<AMDGPUMangledLibFunc>();
687 F.Impl = std::make_unique<AMDGPUUnmangledLibFunc>();
688 if (F.Impl->parseFuncName(FuncName))
691 F.Impl = std::unique_ptr<AMDGPULibFuncImpl>();
697 if (eatTerm(S,
"_Z"))
698 return eatLengthPrefixedName(S);
705 template <
typename Stream>
706 void AMDGPUMangledLibFunc::writeName(Stream &OS)
const {
707 const char *Pfx =
"";
709 case NATIVE: Pfx =
"native_";
break;
710 case HALF: Pfx =
"half_";
break;
715 }
else if (
FuncId != EI_NONE) {
778 class ItaniumMangler {
782 int findSubst(
const AMDGPULibFunc::Param&
P)
const {
783 for(
unsigned I = 0;
I < Str.
size(); ++
I) {
784 const AMDGPULibFunc::Param&
T = Str[
I];
785 if (P.PtrKind == T.PtrKind &&
786 P.VectorSize == T.VectorSize &&
787 P.ArgType == T.ArgType) {
794 template <
typename Stream>
795 bool trySubst(Stream& os,
const AMDGPULibFunc::Param& p) {
796 int const subst = findSubst(p);
797 if (subst < 0)
return false;
801 if (subst == 0) os <<
"S_";
802 else os <<
'S' << (subst-1) <<
'_';
807 ItaniumMangler(
bool useAddrSpace)
808 : UseAddrSpace(useAddrSpace) {}
810 template <
typename Stream>
811 void operator()(Stream& os, AMDGPULibFunc::Param p) {
823 AMDGPULibFunc::Param Ptr;
826 if (trySubst(os, p))
return;
830 unsigned AS = UseAddrSpace
833 if (AS != 0) os <<
"U3AS" << AS;
838 if (p.VectorSize > 1) {
839 if (trySubst(os, p))
goto exit;
841 os <<
"Dv" <<
static_cast<unsigned>(p.VectorSize) <<
'_';
852 std::string AMDGPUMangledLibFunc::mangleNameItanium()
const {
859 S <<
"_Z" <<
static_cast<int>(NameStr.
size()) << NameStr;
862 ParamIterator
I(Leads, manglingRules[
FuncId]);
864 while ((P = I.getNextParam()).ArgType != 0)
874 const AMDGPULibFunc::Param&
P,
905 if (P.VectorSize > 1)
916 std::vector<Type*>
Args;
917 ParamIterator
I(Leads, manglingRules[
FuncId]);
919 while ((P=I.getNextParam()).ArgType != 0)
928 return manglingRules[
FuncId].getNumArgs();
932 return UnmangledFuncInfo::getNumArgs(
FuncId);
943 std::string FuncName = fInfo.
mangle();
944 Function *
F = dyn_cast_or_null<Function>(
958 std::string
const FuncName = fInfo.
mangle();
959 Function *
F = dyn_cast_or_null<Function>(
976 const Type* argTy =
static_cast<const Type*
>(*PI);
991 Attribute::ReadOnly);
993 Attribute::NoUnwind);
1002 for (
unsigned I = 0;
I != TableSize; ++
I)
1009 auto Loc = Map.
find(Name);
1010 if (Loc != Map.
end()) {
1011 Id = toFuncId(Loc->second);
1019 if (
auto *MF = dyn_cast<AMDGPUMangledLibFunc>(F.Impl.get()))
1021 else if (
auto *UMF = dyn_cast<AMDGPUUnmangledLibFunc>(F.Impl.get()))
1024 Impl = std::unique_ptr<AMDGPULibFuncImpl>();
1038 Id, *cast<AMDGPUMangledLibFunc>(CopyFrom.Impl.get())));
1050 return cast<AMDGPUMangledLibFunc>(Impl.get())->Leads;
1054 return cast<const AMDGPUMangledLibFunc>(Impl.get())->Leads;
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
static Type * getDoubleTy(LLVMContext &C)
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
static bool parse(StringRef MangledName, AMDGPULibFunc &Ptr)
void push_back(const T &Elt)
const ValueSymbolTable & getValueSymbolTable() const
Get the symbol table of global variable and function identifiers.
static bool lookup(const GsymReader &GR, DataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs, llvm::Error &Err)
A Lookup helper functions.
Address space for global memory (RAT0, VTX0).
iterator find(StringRef Key)
A raw_ostream that writes to an SmallVector or SmallString.
param_iterator param_end() const
static IntegerType * getInt64Ty(LLVMContext &C)
static IntegerType * getInt16Ty(LLVMContext &C)
StringSwitch & Case(StringLiteral S, T Value)
bool parseFuncName(StringRef &Name) override
static FunctionCallee getOrInsertFunction(llvm::Module *M, const AMDGPULibFunc &fInfo)
static StringRef getUnmangledName(StringRef MangledName)
unsigned getNumArgs() const override
static bool isMangled(EFuncId Id)
static Type * getFloatTy(LLVMContext &C)
LLVM_NODISCARD StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
LLVMContext & getContext() const
Get the global data context.
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
LLVM_NODISCARD R Default(T Value)
Param * getLeads()
Get leading parameters for mangled lib functions.
static StringRef getName(Value *V)
This file contains the simple types necessary to represent the attributes associated with functions a...
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
unsigned getNumArgs() const
Class to represent function types.
unsigned getNumArgs() const override
LLVM_NODISCARD size_t size() const
size - Get the string size.
std::string mangle() const override
A switch()-like statement whose cases are string literals.
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
static Function * getFunction(llvm::Module *M, const AMDGPULibFunc &fInfo)
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
bool isPointerTy() const
True if this is an instance of PointerType.
static AMDGPULibFunc::ENamePrefix parseNamePrefix(StringRef &mangledName)
param_iterator param_begin() const
FunctionType * getFunctionType(Module &M) const override
static FunctionType * get(Type *Result, ArrayRef< Type *> Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Wrapper class for AMDGPULIbFuncImpl.
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
bool parseFuncName(StringRef &mangledName) override
static unsigned getEPtrKindFromAddrSpace(unsigned AS)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static Type * getHalfTy(LLVMContext &C)
static const char * getItaniumTypeName(AMDGPULibFunc::EType T)
static unsigned getAddrSpaceFromEPtrKind(unsigned Kind)
Align max(MaybeAlign Lhs, Align Rhs)
AMDGPULibFunc & operator=(const AMDGPULibFunc &F)
Address space for local memory.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Type::subtype_iterator param_iterator
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
static int parseVecSize(StringRef &mangledName)
StringRef str()
Return a StringRef for the vector contents.
FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
std::string getName() const override
Get unmangled name for mangled library function and name for unmangled library function.
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
LLVM_NODISCARD AttributeList addAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Kind) const
Add an attribute to the attribute set at the given index.
bool isDigit(char C)
Checks if character C is one of the 10 decimal digits.
static IntegerType * getInt32Ty(LLVMContext &C)
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
Value * lookup(StringRef Name) const
This method finds the value with the given Name in the the symbol table.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
LLVM_NODISCARD const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM_NODISCARD char front() const
front - Get the first character in the string.
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
static Type * getIntrinsicParamType(LLVMContext &C, const AMDGPULibFunc::Param &P, bool useAddrSpace)
std::string mangle() const
StringRef - Represent a constant reference to a string, i.e.
static IntegerType * getInt8Ty(LLVMContext &C)
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
FunctionType * getFunctionType(Module &M) const