60 unsigned char Lead[2];
61 unsigned char Param[5];
63 int maxLeadIndex()
const {
return (
std::max)(Lead[0], Lead[1]); }
64 int getNumLeads()
const {
return (Lead[0] ? 1 : 0) + (Lead[1] ? 1 : 0); }
66 unsigned getNumArgs()
const;
70 class UnmangledFuncInfo {
75 static const UnmangledFuncInfo Table[];
78 static const unsigned TableSize;
81 class NameMap :
public StringMap<unsigned> {
84 for (
unsigned I = 0;
I != TableSize; ++
I)
85 (*
this)[Table[
I].Name] =
I;
93 UnmangledFuncInfo() =
default;
94 UnmangledFuncInfo(
StringRef _Name,
unsigned _NumArgs)
95 :
Name(_Name), NumArgs(_NumArgs) {}
98 static unsigned toIndex(
ID Id) {
99 assert(static_cast<unsigned>(Id) >
101 "Invalid unmangled library function");
102 return static_cast<unsigned>(
Id) - 1 -
105 static ID toFuncId(
unsigned Index) {
106 assert(Index < TableSize &&
"Invalid unmangled library function");
107 return static_cast<ID>(
110 static unsigned getNumArgs(
ID Id) {
return Table[toIndex(Id)].NumArgs; }
114 unsigned ManglingRule::getNumArgs()
const {
116 while (I < (
sizeof Param/
sizeof Param[0]) && Param[I]) ++
I;
144 static const ManglingRule manglingRules[] = {
146 {
"abs" , {1}, {E_ANY}},
147 {
"abs_diff" , {1}, {E_ANY,E_COPY}},
148 {
"acos" , {1}, {E_ANY}},
149 {
"acosh" , {1}, {E_ANY}},
150 {
"acospi" , {1}, {E_ANY}},
151 {
"add_sat" , {1}, {E_ANY,E_COPY}},
152 {
"all" , {1}, {E_ANY}},
153 {
"any" , {1}, {E_ANY}},
154 {
"asin" , {1}, {E_ANY}},
155 {
"asinh" , {1}, {E_ANY}},
156 {
"asinpi" , {1}, {E_ANY}},
157 {
"async_work_group_copy" , {1}, {E_ANY,E_CONSTPTR_SWAPGL,EX_SIZET,EX_EVENT}},
158 {
"async_work_group_strided_copy" , {1}, {E_ANY,E_CONSTPTR_SWAPGL,EX_SIZET,EX_SIZET,EX_EVENT}},
159 {
"atan" , {1}, {E_ANY}},
160 {
"atan2" , {1}, {E_ANY,E_COPY}},
161 {
"atan2pi" , {1}, {E_ANY,E_COPY}},
162 {
"atanh" , {1}, {E_ANY}},
163 {
"atanpi" , {1}, {E_ANY}},
164 {
"atomic_add" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
165 {
"atomic_and" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
166 {
"atomic_cmpxchg" , {1}, {E_VLTLPTR_ANY,E_POINTEE,E_POINTEE}},
167 {
"atomic_dec" , {1}, {E_VLTLPTR_ANY}},
168 {
"atomic_inc" , {1}, {E_VLTLPTR_ANY}},
169 {
"atomic_max" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
170 {
"atomic_min" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
171 {
"atomic_or" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
172 {
"atomic_sub" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
173 {
"atomic_xchg" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
174 {
"atomic_xor" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
175 {
"bitselect" , {1}, {E_ANY,E_COPY,E_COPY}},
176 {
"cbrt" , {1}, {E_ANY}},
177 {
"ceil" , {1}, {E_ANY}},
178 {
"clamp" , {1}, {E_ANY,E_COPY,E_COPY}},
179 {
"clz" , {1}, {E_ANY}},
180 {
"commit_read_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
181 {
"commit_write_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
182 {
"copysign" , {1}, {E_ANY,E_COPY}},
183 {
"cos" , {1}, {E_ANY}},
184 {
"cosh" , {1}, {E_ANY}},
185 {
"cospi" , {1}, {E_ANY}},
186 {
"cross" , {1}, {E_ANY,E_COPY}},
187 {
"ctz" , {1}, {E_ANY}},
188 {
"degrees" , {1}, {E_ANY}},
189 {
"distance" , {1}, {E_ANY,E_COPY}},
190 {
"divide" , {1}, {E_ANY,E_COPY}},
191 {
"dot" , {1}, {E_ANY,E_COPY}},
192 {
"erf" , {1}, {E_ANY}},
193 {
"erfc" , {1}, {E_ANY}},
194 {
"exp" , {1}, {E_ANY}},
195 {
"exp10" , {1}, {E_ANY}},
196 {
"exp2" , {1}, {E_ANY}},
197 {
"expm1" , {1}, {E_ANY}},
198 {
"fabs" , {1}, {E_ANY}},
199 {
"fast_distance" , {1}, {E_ANY,E_COPY}},
200 {
"fast_length" , {1}, {E_ANY}},
201 {
"fast_normalize" , {1}, {E_ANY}},
202 {
"fdim" , {1}, {E_ANY,E_COPY}},
203 {
"floor" , {1}, {E_ANY}},
204 {
"fma" , {1}, {E_ANY,E_COPY,E_COPY}},
205 {
"fmax" , {1}, {E_ANY,E_COPY}},
206 {
"fmin" , {1}, {E_ANY,E_COPY}},
207 {
"fmod" , {1}, {E_ANY,E_COPY}},
208 {
"fract" , {2}, {E_POINTEE,E_ANY}},
209 {
"frexp" , {1,2}, {E_ANY,E_ANY}},
210 {
"get_image_array_size" , {1}, {E_ANY}},
211 {
"get_image_channel_data_type" , {1}, {E_ANY}},
212 {
"get_image_channel_order" , {1}, {E_ANY}},
213 {
"get_image_dim" , {1}, {E_ANY}},
214 {
"get_image_height" , {1}, {E_ANY}},
215 {
"get_image_width" , {1}, {E_ANY}},
216 {
"get_pipe_max_packets" , {1}, {E_ANY}},
217 {
"get_pipe_num_packets" , {1}, {E_ANY}},
218 {
"hadd" , {1}, {E_ANY,E_COPY}},
219 {
"hypot" , {1}, {E_ANY,E_COPY}},
220 {
"ilogb" , {1}, {E_ANY}},
221 {
"isequal" , {1}, {E_ANY,E_COPY}},
222 {
"isfinite" , {1}, {E_ANY}},
223 {
"isgreater" , {1}, {E_ANY,E_COPY}},
224 {
"isgreaterequal" , {1}, {E_ANY,E_COPY}},
225 {
"isinf" , {1}, {E_ANY}},
226 {
"isless" , {1}, {E_ANY,E_COPY}},
227 {
"islessequal" , {1}, {E_ANY,E_COPY}},
228 {
"islessgreater" , {1}, {E_ANY,E_COPY}},
229 {
"isnan" , {1}, {E_ANY}},
230 {
"isnormal" , {1}, {E_ANY}},
231 {
"isnotequal" , {1}, {E_ANY,E_COPY}},
232 {
"isordered" , {1}, {E_ANY,E_COPY}},
233 {
"isunordered" , {1}, {E_ANY,E_COPY}},
234 {
"ldexp" , {1}, {E_ANY,E_SETBASE_I32}},
235 {
"length" , {1}, {E_ANY}},
236 {
"lgamma" , {1}, {E_ANY}},
237 {
"lgamma_r" , {1,2}, {E_ANY,E_ANY}},
238 {
"log" , {1}, {E_ANY}},
239 {
"log10" , {1}, {E_ANY}},
240 {
"log1p" , {1}, {E_ANY}},
241 {
"log2" , {1}, {E_ANY}},
242 {
"logb" , {1}, {E_ANY}},
243 {
"mad" , {1}, {E_ANY,E_COPY,E_COPY}},
244 {
"mad24" , {1}, {E_ANY,E_COPY,E_COPY}},
245 {
"mad_hi" , {1}, {E_ANY,E_COPY,E_COPY}},
246 {
"mad_sat" , {1}, {E_ANY,E_COPY,E_COPY}},
247 {
"max" , {1}, {E_ANY,E_COPY}},
248 {
"maxmag" , {1}, {E_ANY,E_COPY}},
249 {
"min" , {1}, {E_ANY,E_COPY}},
250 {
"minmag" , {1}, {E_ANY,E_COPY}},
251 {
"mix" , {1}, {E_ANY,E_COPY,E_COPY}},
252 {
"modf" , {2}, {E_POINTEE,E_ANY}},
253 {
"mul24" , {1}, {E_ANY,E_COPY}},
254 {
"mul_hi" , {1}, {E_ANY,E_COPY}},
255 {
"nan" , {1}, {E_ANY}},
256 {
"nextafter" , {1}, {E_ANY,E_COPY}},
257 {
"normalize" , {1}, {E_ANY}},
258 {
"popcount" , {1}, {E_ANY}},
259 {
"pow" , {1}, {E_ANY,E_COPY}},
260 {
"pown" , {1}, {E_ANY,E_SETBASE_I32}},
261 {
"powr" , {1}, {E_ANY,E_COPY}},
262 {
"prefetch" , {1}, {E_CONSTPTR_ANY,EX_SIZET}},
263 {
"radians" , {1}, {E_ANY}},
264 {
"recip" , {1}, {E_ANY}},
265 {
"remainder" , {1}, {E_ANY,E_COPY}},
266 {
"remquo" , {1,3}, {E_ANY,E_COPY,E_ANY}},
267 {
"reserve_read_pipe" , {1}, {E_ANY,EX_UINT}},
268 {
"reserve_write_pipe" , {1}, {E_ANY,EX_UINT}},
269 {
"rhadd" , {1}, {E_ANY,E_COPY}},
270 {
"rint" , {1}, {E_ANY}},
271 {
"rootn" , {1}, {E_ANY,E_SETBASE_I32}},
272 {
"rotate" , {1}, {E_ANY,E_COPY}},
273 {
"round" , {1}, {E_ANY}},
274 {
"rsqrt" , {1}, {E_ANY}},
275 {
"select" , {1,3}, {E_ANY,E_COPY,E_ANY}},
276 {
"shuffle" , {1,2}, {E_ANY,E_ANY}},
277 {
"shuffle2" , {1,3}, {E_ANY,E_COPY,E_ANY}},
278 {
"sign" , {1}, {E_ANY}},
279 {
"signbit" , {1}, {E_ANY}},
280 {
"sin" , {1}, {E_ANY}},
281 {
"sincos" , {2}, {E_POINTEE,E_ANY}},
282 {
"sinh" , {1}, {E_ANY}},
283 {
"sinpi" , {1}, {E_ANY}},
284 {
"smoothstep" , {1}, {E_ANY,E_COPY,E_COPY}},
285 {
"sqrt" , {1}, {E_ANY}},
286 {
"step" , {1}, {E_ANY,E_COPY}},
287 {
"sub_group_broadcast" , {1}, {E_ANY,EX_UINT}},
288 {
"sub_group_commit_read_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
289 {
"sub_group_commit_write_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
290 {
"sub_group_reduce_add" , {1}, {E_ANY}},
291 {
"sub_group_reduce_max" , {1}, {E_ANY}},
292 {
"sub_group_reduce_min" , {1}, {E_ANY}},
293 {
"sub_group_reserve_read_pipe" , {1}, {E_ANY,EX_UINT}},
294 {
"sub_group_reserve_write_pipe" , {1}, {E_ANY,EX_UINT}},
295 {
"sub_group_scan_exclusive_add" , {1}, {E_ANY}},
296 {
"sub_group_scan_exclusive_max" , {1}, {E_ANY}},
297 {
"sub_group_scan_exclusive_min" , {1}, {E_ANY}},
298 {
"sub_group_scan_inclusive_add" , {1}, {E_ANY}},
299 {
"sub_group_scan_inclusive_max" , {1}, {E_ANY}},
300 {
"sub_group_scan_inclusive_min" , {1}, {E_ANY}},
301 {
"sub_sat" , {1}, {E_ANY,E_COPY}},
302 {
"tan" , {1}, {E_ANY}},
303 {
"tanh" , {1}, {E_ANY}},
304 {
"tanpi" , {1}, {E_ANY}},
305 {
"tgamma" , {1}, {E_ANY}},
306 {
"trunc" , {1}, {E_ANY}},
307 {
"upsample" , {1}, {E_ANY,E_MAKEBASE_UNS}},
308 {
"vec_step" , {1}, {E_ANY}},
309 {
"vstore" , {3}, {E_POINTEE,EX_SIZET,E_ANY}},
310 {
"vstore16" , {3}, {E_V16_OF_POINTEE,EX_SIZET,E_ANY}},
311 {
"vstore2" , {3}, {E_V2_OF_POINTEE,EX_SIZET,E_ANY}},
312 {
"vstore3" , {3}, {E_V3_OF_POINTEE,EX_SIZET,E_ANY}},
313 {
"vstore4" , {3}, {E_V4_OF_POINTEE,EX_SIZET,E_ANY}},
314 {
"vstore8" , {3}, {E_V8_OF_POINTEE,EX_SIZET,E_ANY}},
315 {
"work_group_commit_read_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
316 {
"work_group_commit_write_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
317 {
"work_group_reduce_add" , {1}, {E_ANY}},
318 {
"work_group_reduce_max" , {1}, {E_ANY}},
319 {
"work_group_reduce_min" , {1}, {E_ANY}},
320 {
"work_group_reserve_read_pipe" , {1}, {E_ANY,EX_UINT}},
321 {
"work_group_reserve_write_pipe" , {1}, {E_ANY,EX_UINT}},
322 {
"work_group_scan_exclusive_add" , {1}, {E_ANY}},
323 {
"work_group_scan_exclusive_max" , {1}, {E_ANY}},
324 {
"work_group_scan_exclusive_min" , {1}, {E_ANY}},
325 {
"work_group_scan_inclusive_add" , {1}, {E_ANY}},
326 {
"work_group_scan_inclusive_max" , {1}, {E_ANY}},
327 {
"work_group_scan_inclusive_min" , {1}, {E_ANY}},
328 {
"write_imagef" , {1}, {E_ANY,E_IMAGECOORDS,EX_FLOAT4}},
329 {
"write_imagei" , {1}, {E_ANY,E_IMAGECOORDS,EX_INTV4}},
330 {
"write_imageui" , {1}, {E_ANY,E_IMAGECOORDS,EX_UINTV4}},
331 {
"ncos" , {1}, {E_ANY} },
332 {
"nexp2" , {1}, {E_ANY} },
333 {
"nfma" , {1}, {E_ANY, E_COPY, E_COPY} },
334 {
"nlog2" , {1}, {E_ANY} },
335 {
"nrcp" , {1}, {E_ANY} },
336 {
"nrsqrt" , {1}, {E_ANY} },
337 {
"nsin" , {1}, {E_ANY} },
338 {
"nsqrt" , {1}, {E_ANY} },
339 {
"ftz" , {1}, {E_ANY} },
340 {
"fldexp" , {1}, {E_ANY, EX_UINT} },
341 {
"class" , {1}, {E_ANY, EX_UINT} },
342 {
"rcbrt" , {1}, {E_ANY} },
346 const UnmangledFuncInfo UnmangledFuncInfo::Table[] = {
347 {
"__read_pipe_2", 4},
348 {
"__read_pipe_4", 6},
349 {
"__write_pipe_2", 4},
350 {
"__write_pipe_4", 6},
353 const unsigned UnmangledFuncInfo::TableSize =
354 sizeof(UnmangledFuncInfo::Table) /
sizeof(UnmangledFuncInfo::Table[0]);
356 UnmangledFuncInfo::NameMap UnmangledFuncInfo::Map;
358 static const struct ManglingRulesMap :
public StringMap<int> {
360 :
StringMap<int>(
sizeof(manglingRules)/
sizeof(manglingRules[0])) {
362 for (
auto Rule : manglingRules)
363 insert({ Rule.Name, Id++ });
368 const AMDGPULibFunc::Param (&Leads)[2]) {
369 AMDGPULibFunc::Param Res = Leads[0];
381 class ParamIterator {
382 const AMDGPULibFunc::Param (&Leads)[2];
383 const ManglingRule& Rule;
386 ParamIterator(
const AMDGPULibFunc::Param (&leads)[2],
387 const ManglingRule& rule)
388 : Leads(leads), Rule(rule),
Index(0) {}
390 AMDGPULibFunc::Param getNextParam();
393 AMDGPULibFunc::Param ParamIterator::getNextParam() {
394 AMDGPULibFunc::Param
P;
395 if (
Index >=
int(
sizeof Rule.Param/
sizeof Rule.Param[0]))
return P;
397 const char R = Rule.Param[
Index];
414 case EX_RESERVEDID:
break;
416 if (
Index == (Rule.Lead[1] - 1)) P = Leads[1];
425 case E_V2_OF_POINTEE:
427 case E_V3_OF_POINTEE:
429 case E_V4_OF_POINTEE:
431 case E_V8_OF_POINTEE:
433 case E_V16_OF_POINTEE:
462 case E_CONSTPTR_SWAPGL: {
480 inline static void drop_front(
StringRef& str,
size_t n = 1) {
484 static bool eatTerm(
StringRef& mangledName,
const char c) {
485 if (mangledName.
front() == c) {
486 drop_front(mangledName);
493 static bool eatTerm(
StringRef& mangledName,
const char (&str)[
N]) {
495 drop_front(mangledName, N-1);
501 static inline bool isDigit(
char c) {
return c >=
'0' && c <=
'9'; }
504 size_t const savedSize = s.
size();
507 n = n*10 + s.
front() -
'0';
510 return s.
size() < savedSize ? n : -1;
514 int const Len = eatNumber(mangledName);
515 if (Len <= 0 || static_cast<size_t>(Len) > mangledName.
size())
518 drop_front(mangledName, Len);
540 FKind = copyFrom.
FKind;
541 Leads[0] = copyFrom.
Leads[0];
542 Leads[1] = copyFrom.
Leads[1];
549 size_t const Len = eatNumber(mangledName);
551 case 2:
case 3:
case 4:
case 8:
case 16:
560 std::pair<StringRef, StringRef>
const P = mangledName.
split(
'_');
568 mangledName = P.second;
573 bool AMDGPUMangledLibFunc::parseUnmangledName(
StringRef FullName) {
574 FuncId =
static_cast<EFuncId
>(manglingRulesMap.lookup(FullName));
575 return FuncId != EI_NONE;
582 struct ItaniumParamParser {
583 AMDGPULibFunc::Param Prev;
584 bool parseItaniumParam(
StringRef& param, AMDGPULibFunc::Param &res);
588 bool ItaniumParamParser::parseItaniumParam(
StringRef& param,
589 AMDGPULibFunc::Param &res) {
591 if (param.
empty())
return false;
594 if (eatTerm(param,
'P')) {
598 if (!eatTerm(param,
"U3AS")) {
602 drop_front(param, 1);
610 if (eatTerm(param,
"Dv")) {
612 if (res.VectorSize==1 || !eatTerm(param,
'_'))
return false;
616 char const TC = param.
front();
619 (eatLengthPrefixedName(param))
642 case 'D':
if (!eatTerm(param,
'h'))
return false;
645 if (!eatTerm(param,
'_')) {
647 if (!eatTerm(param,
'_'))
return false;
649 res.VectorSize = Prev.VectorSize;
650 res.ArgType = Prev.ArgType;
655 if (res.ArgType == 0)
return false;
656 Prev.VectorSize = res.VectorSize;
657 Prev.ArgType = res.ArgType;
664 if (!parseUnmangledName(Name))
667 const ManglingRule& Rule = manglingRules[FuncId];
668 ItaniumParamParser Parser;
669 for (
int I=0;
I < Rule.maxLeadIndex(); ++
I) {
671 if (!Parser.parseItaniumParam(mangledName, P))
674 if ((
I + 1) == Rule.Lead[0]) Leads[0] = P;
675 if ((
I + 1) == Rule.Lead[1]) Leads[1] = P;
688 if (FuncName.
empty()) {
689 F.Impl = std::unique_ptr<AMDGPULibFuncImpl>();
693 if (eatTerm(FuncName,
"_Z"))
694 F.Impl = make_unique<AMDGPUMangledLibFunc>();
696 F.Impl = make_unique<AMDGPUUnmangledLibFunc>();
697 if (F.Impl->parseFuncName(FuncName))
700 F.Impl = std::unique_ptr<AMDGPULibFuncImpl>();
706 if (eatTerm(S,
"_Z"))
707 return eatLengthPrefixedName(S);
714 template <
typename Stream>
715 void AMDGPUMangledLibFunc::writeName(Stream &OS)
const {
716 const char *Pfx =
"";
718 case NATIVE: Pfx =
"native_";
break;
719 case HALF: Pfx =
"half_";
break;
724 }
else if (FuncId != EI_NONE) {
726 const StringRef& S = manglingRules[FuncId].Name;
787 class ItaniumMangler {
791 int findSubst(
const AMDGPULibFunc::Param&
P)
const {
792 for(
unsigned I = 0;
I < Str.
size(); ++
I) {
793 const AMDGPULibFunc::Param&
T = Str[
I];
794 if (P.PtrKind == T.PtrKind &&
795 P.VectorSize == T.VectorSize &&
796 P.ArgType == T.ArgType) {
803 template <
typename Stream>
804 bool trySubst(Stream& os,
const AMDGPULibFunc::Param& p) {
805 int const subst = findSubst(p);
806 if (subst < 0)
return false;
810 if (subst == 0) os <<
"S_";
811 else os <<
'S' << (subst-1) <<
'_';
816 ItaniumMangler(
bool useAddrSpace)
817 : UseAddrSpace(useAddrSpace) {}
819 template <
typename Stream>
820 void operator()(Stream& os, AMDGPULibFunc::Param p) {
832 AMDGPULibFunc::Param
Ptr;
835 if (trySubst(os, p))
return;
839 unsigned AS = UseAddrSpace
842 if (AS != 0) os <<
"U3AS" <<
AS;
847 if (p.VectorSize > 1) {
848 if (trySubst(os, p))
goto exit;
850 os <<
"Dv" <<
static_cast<unsigned>(p.VectorSize) <<
'_';
861 std::string AMDGPUMangledLibFunc::mangleNameItanium()
const {
868 S <<
"_Z" <<
static_cast<int>(NameStr.
size()) << NameStr;
871 ParamIterator
I(Leads, manglingRules[FuncId]);
873 while ((P = I.getNextParam()).ArgType != 0)
883 const AMDGPULibFunc::Param&
P,
914 if (P.VectorSize > 1)
925 std::vector<Type*>
Args;
926 ParamIterator
I(Leads, manglingRules[FuncId]);
928 while ((P=I.getNextParam()).ArgType != 0)
937 return manglingRules[FuncId].getNumArgs();
941 return UnmangledFuncInfo::getNumArgs(FuncId);
952 std::string FuncName = fInfo.
mangle();
953 Function *
F = dyn_cast_or_null<Function>(
967 std::string
const FuncName = fInfo.
mangle();
968 Function *
F = dyn_cast_or_null<Function>(
985 const Type* argTy =
static_cast<const Type*
>(*PI);
1004 return cast<Function>(
C);
1008 auto Loc = Map.find(Name);
1009 if (Loc != Map.end()) {
1010 Id = toFuncId(Loc->second);
1018 if (
auto *MF = dyn_cast<AMDGPUMangledLibFunc>(F.Impl.get()))
1020 else if (
auto *UMF = dyn_cast<AMDGPUUnmangledLibFunc>(F.Impl.get()))
1023 Impl = std::unique_ptr<AMDGPULibFuncImpl>();
1037 Id, *cast<AMDGPUMangledLibFunc>(CopyFrom.Impl.get())));
1049 return cast<AMDGPUMangledLibFunc>(Impl.get())->Leads;
1053 return cast<const AMDGPUMangledLibFunc>(Impl.get())->Leads;
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
void push_back(const T &Elt)
static Type * getDoubleTy(LLVMContext &C)
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
Compute iterated dominance frontiers using a linear time algorithm.
Constant * getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
A Module instance is used to store all the information related to an LLVM module. ...
static bool parse(StringRef MangledName, AMDGPULibFunc &Ptr)
const ValueSymbolTable & getValueSymbolTable() const
Get the symbol table of global variable and function identifiers.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
A raw_ostream that writes to an SmallVector or SmallString.
param_iterator param_end() const
static IntegerType * getInt64Ty(LLVMContext &C)
Address space for local memory.
static IntegerType * getInt16Ty(LLVMContext &C)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
bool parseFuncName(StringRef &Name) override
static StringRef getUnmangledName(StringRef MangledName)
unsigned getNumArgs() const override
static bool isMangled(EFuncId Id)
static Type * getFloatTy(LLVMContext &C)
LLVMContext & getContext() const
Get the global data context.
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
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 LLVM_ATTRIBUTE_ALWAYS_INLINE R Default(T Value)
static const uint16_t * lookup(unsigned opcode, unsigned domain, ArrayRef< uint16_t[3]> Table)
unsigned getNumArgs() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Class to represent function types.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
unsigned getNumArgs() const override
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
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.
This is an important base class in LLVM.
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.
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.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
static Type * getHalfTy(LLVMContext &C)
static const char * getItaniumTypeName(AMDGPULibFunc::EType T)
static unsigned getAddrSpaceFromEPtrKind(unsigned Kind)
AMDGPULibFunc & operator=(const AMDGPULibFunc &F)
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
static int parseVecSize(StringRef &mangledName)
StringRef str()
Return a StringRef for the vector contents.
std::string getName() const override
Get unmangled name for mangled library function and name for unmangled library function.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
static Function * getOrInsertFunction(llvm::Module *M, const AMDGPULibFunc &fInfo)
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Case(StringLiteral S, T Value)
Address space for global memory (RAT0, VTX0).
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)
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...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM_NODISCARD char front() const
front - Get the first character in the string.
static VectorType * get(Type *ElementType, unsigned NumElements)
This static method is the primary way to construct an VectorType.
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