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(
StringRef _Name,
unsigned _NumArgs)
94 :
Name(_Name), NumArgs(_NumArgs) {}
97 static unsigned toIndex(
ID Id) {
98 assert(static_cast<unsigned>(Id) >
100 "Invalid unmangled library function");
101 return static_cast<unsigned>(
Id) - 1 -
104 static ID toFuncId(
unsigned Index) {
105 assert(Index < TableSize &&
"Invalid unmangled library function");
106 return static_cast<ID>(
109 static unsigned getNumArgs(
ID Id) {
return Table[toIndex(Id)].NumArgs; }
113 unsigned ManglingRule::getNumArgs()
const {
115 while (I < (
sizeof Param/
sizeof Param[0]) && Param[I]) ++
I;
143 static const ManglingRule manglingRules[] = {
145 {
"abs" , {1}, {E_ANY}},
146 {
"abs_diff" , {1}, {E_ANY,E_COPY}},
147 {
"acos" , {1}, {E_ANY}},
148 {
"acosh" , {1}, {E_ANY}},
149 {
"acospi" , {1}, {E_ANY}},
150 {
"add_sat" , {1}, {E_ANY,E_COPY}},
151 {
"all" , {1}, {E_ANY}},
152 {
"any" , {1}, {E_ANY}},
153 {
"asin" , {1}, {E_ANY}},
154 {
"asinh" , {1}, {E_ANY}},
155 {
"asinpi" , {1}, {E_ANY}},
156 {
"async_work_group_copy" , {1}, {E_ANY,E_CONSTPTR_SWAPGL,EX_SIZET,EX_EVENT}},
157 {
"async_work_group_strided_copy" , {1}, {E_ANY,E_CONSTPTR_SWAPGL,EX_SIZET,EX_SIZET,EX_EVENT}},
158 {
"atan" , {1}, {E_ANY}},
159 {
"atan2" , {1}, {E_ANY,E_COPY}},
160 {
"atan2pi" , {1}, {E_ANY,E_COPY}},
161 {
"atanh" , {1}, {E_ANY}},
162 {
"atanpi" , {1}, {E_ANY}},
163 {
"atomic_add" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
164 {
"atomic_and" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
165 {
"atomic_cmpxchg" , {1}, {E_VLTLPTR_ANY,E_POINTEE,E_POINTEE}},
166 {
"atomic_dec" , {1}, {E_VLTLPTR_ANY}},
167 {
"atomic_inc" , {1}, {E_VLTLPTR_ANY}},
168 {
"atomic_max" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
169 {
"atomic_min" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
170 {
"atomic_or" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
171 {
"atomic_sub" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
172 {
"atomic_xchg" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
173 {
"atomic_xor" , {1}, {E_VLTLPTR_ANY,E_POINTEE}},
174 {
"bitselect" , {1}, {E_ANY,E_COPY,E_COPY}},
175 {
"cbrt" , {1}, {E_ANY}},
176 {
"ceil" , {1}, {E_ANY}},
177 {
"clamp" , {1}, {E_ANY,E_COPY,E_COPY}},
178 {
"clz" , {1}, {E_ANY}},
179 {
"commit_read_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
180 {
"commit_write_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
181 {
"copysign" , {1}, {E_ANY,E_COPY}},
182 {
"cos" , {1}, {E_ANY}},
183 {
"cosh" , {1}, {E_ANY}},
184 {
"cospi" , {1}, {E_ANY}},
185 {
"cross" , {1}, {E_ANY,E_COPY}},
186 {
"ctz" , {1}, {E_ANY}},
187 {
"degrees" , {1}, {E_ANY}},
188 {
"distance" , {1}, {E_ANY,E_COPY}},
189 {
"divide" , {1}, {E_ANY,E_COPY}},
190 {
"dot" , {1}, {E_ANY,E_COPY}},
191 {
"erf" , {1}, {E_ANY}},
192 {
"erfc" , {1}, {E_ANY}},
193 {
"exp" , {1}, {E_ANY}},
194 {
"exp10" , {1}, {E_ANY}},
195 {
"exp2" , {1}, {E_ANY}},
196 {
"expm1" , {1}, {E_ANY}},
197 {
"fabs" , {1}, {E_ANY}},
198 {
"fast_distance" , {1}, {E_ANY,E_COPY}},
199 {
"fast_length" , {1}, {E_ANY}},
200 {
"fast_normalize" , {1}, {E_ANY}},
201 {
"fdim" , {1}, {E_ANY,E_COPY}},
202 {
"floor" , {1}, {E_ANY}},
203 {
"fma" , {1}, {E_ANY,E_COPY,E_COPY}},
204 {
"fmax" , {1}, {E_ANY,E_COPY}},
205 {
"fmin" , {1}, {E_ANY,E_COPY}},
206 {
"fmod" , {1}, {E_ANY,E_COPY}},
207 {
"fract" , {2}, {E_POINTEE,E_ANY}},
208 {
"frexp" , {1,2}, {E_ANY,E_ANY}},
209 {
"get_image_array_size" , {1}, {E_ANY}},
210 {
"get_image_channel_data_type" , {1}, {E_ANY}},
211 {
"get_image_channel_order" , {1}, {E_ANY}},
212 {
"get_image_dim" , {1}, {E_ANY}},
213 {
"get_image_height" , {1}, {E_ANY}},
214 {
"get_image_width" , {1}, {E_ANY}},
215 {
"get_pipe_max_packets" , {1}, {E_ANY}},
216 {
"get_pipe_num_packets" , {1}, {E_ANY}},
217 {
"hadd" , {1}, {E_ANY,E_COPY}},
218 {
"hypot" , {1}, {E_ANY,E_COPY}},
219 {
"ilogb" , {1}, {E_ANY}},
220 {
"isequal" , {1}, {E_ANY,E_COPY}},
221 {
"isfinite" , {1}, {E_ANY}},
222 {
"isgreater" , {1}, {E_ANY,E_COPY}},
223 {
"isgreaterequal" , {1}, {E_ANY,E_COPY}},
224 {
"isinf" , {1}, {E_ANY}},
225 {
"isless" , {1}, {E_ANY,E_COPY}},
226 {
"islessequal" , {1}, {E_ANY,E_COPY}},
227 {
"islessgreater" , {1}, {E_ANY,E_COPY}},
228 {
"isnan" , {1}, {E_ANY}},
229 {
"isnormal" , {1}, {E_ANY}},
230 {
"isnotequal" , {1}, {E_ANY,E_COPY}},
231 {
"isordered" , {1}, {E_ANY,E_COPY}},
232 {
"isunordered" , {1}, {E_ANY,E_COPY}},
233 {
"ldexp" , {1}, {E_ANY,E_SETBASE_I32}},
234 {
"length" , {1}, {E_ANY}},
235 {
"lgamma" , {1}, {E_ANY}},
236 {
"lgamma_r" , {1,2}, {E_ANY,E_ANY}},
237 {
"log" , {1}, {E_ANY}},
238 {
"log10" , {1}, {E_ANY}},
239 {
"log1p" , {1}, {E_ANY}},
240 {
"log2" , {1}, {E_ANY}},
241 {
"logb" , {1}, {E_ANY}},
242 {
"mad" , {1}, {E_ANY,E_COPY,E_COPY}},
243 {
"mad24" , {1}, {E_ANY,E_COPY,E_COPY}},
244 {
"mad_hi" , {1}, {E_ANY,E_COPY,E_COPY}},
245 {
"mad_sat" , {1}, {E_ANY,E_COPY,E_COPY}},
246 {
"max" , {1}, {E_ANY,E_COPY}},
247 {
"maxmag" , {1}, {E_ANY,E_COPY}},
248 {
"min" , {1}, {E_ANY,E_COPY}},
249 {
"minmag" , {1}, {E_ANY,E_COPY}},
250 {
"mix" , {1}, {E_ANY,E_COPY,E_COPY}},
251 {
"modf" , {2}, {E_POINTEE,E_ANY}},
252 {
"mul24" , {1}, {E_ANY,E_COPY}},
253 {
"mul_hi" , {1}, {E_ANY,E_COPY}},
254 {
"nan" , {1}, {E_ANY}},
255 {
"nextafter" , {1}, {E_ANY,E_COPY}},
256 {
"normalize" , {1}, {E_ANY}},
257 {
"popcount" , {1}, {E_ANY}},
258 {
"pow" , {1}, {E_ANY,E_COPY}},
259 {
"pown" , {1}, {E_ANY,E_SETBASE_I32}},
260 {
"powr" , {1}, {E_ANY,E_COPY}},
261 {
"prefetch" , {1}, {E_CONSTPTR_ANY,EX_SIZET}},
262 {
"radians" , {1}, {E_ANY}},
263 {
"recip" , {1}, {E_ANY}},
264 {
"remainder" , {1}, {E_ANY,E_COPY}},
265 {
"remquo" , {1,3}, {E_ANY,E_COPY,E_ANY}},
266 {
"reserve_read_pipe" , {1}, {E_ANY,EX_UINT}},
267 {
"reserve_write_pipe" , {1}, {E_ANY,EX_UINT}},
268 {
"rhadd" , {1}, {E_ANY,E_COPY}},
269 {
"rint" , {1}, {E_ANY}},
270 {
"rootn" , {1}, {E_ANY,E_SETBASE_I32}},
271 {
"rotate" , {1}, {E_ANY,E_COPY}},
272 {
"round" , {1}, {E_ANY}},
273 {
"rsqrt" , {1}, {E_ANY}},
274 {
"select" , {1,3}, {E_ANY,E_COPY,E_ANY}},
275 {
"shuffle" , {1,2}, {E_ANY,E_ANY}},
276 {
"shuffle2" , {1,3}, {E_ANY,E_COPY,E_ANY}},
277 {
"sign" , {1}, {E_ANY}},
278 {
"signbit" , {1}, {E_ANY}},
279 {
"sin" , {1}, {E_ANY}},
280 {
"sincos" , {2}, {E_POINTEE,E_ANY}},
281 {
"sinh" , {1}, {E_ANY}},
282 {
"sinpi" , {1}, {E_ANY}},
283 {
"smoothstep" , {1}, {E_ANY,E_COPY,E_COPY}},
284 {
"sqrt" , {1}, {E_ANY}},
285 {
"step" , {1}, {E_ANY,E_COPY}},
286 {
"sub_group_broadcast" , {1}, {E_ANY,EX_UINT}},
287 {
"sub_group_commit_read_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
288 {
"sub_group_commit_write_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
289 {
"sub_group_reduce_add" , {1}, {E_ANY}},
290 {
"sub_group_reduce_max" , {1}, {E_ANY}},
291 {
"sub_group_reduce_min" , {1}, {E_ANY}},
292 {
"sub_group_reserve_read_pipe" , {1}, {E_ANY,EX_UINT}},
293 {
"sub_group_reserve_write_pipe" , {1}, {E_ANY,EX_UINT}},
294 {
"sub_group_scan_exclusive_add" , {1}, {E_ANY}},
295 {
"sub_group_scan_exclusive_max" , {1}, {E_ANY}},
296 {
"sub_group_scan_exclusive_min" , {1}, {E_ANY}},
297 {
"sub_group_scan_inclusive_add" , {1}, {E_ANY}},
298 {
"sub_group_scan_inclusive_max" , {1}, {E_ANY}},
299 {
"sub_group_scan_inclusive_min" , {1}, {E_ANY}},
300 {
"sub_sat" , {1}, {E_ANY,E_COPY}},
301 {
"tan" , {1}, {E_ANY}},
302 {
"tanh" , {1}, {E_ANY}},
303 {
"tanpi" , {1}, {E_ANY}},
304 {
"tgamma" , {1}, {E_ANY}},
305 {
"trunc" , {1}, {E_ANY}},
306 {
"upsample" , {1}, {E_ANY,E_MAKEBASE_UNS}},
307 {
"vec_step" , {1}, {E_ANY}},
308 {
"vstore" , {3}, {E_POINTEE,EX_SIZET,E_ANY}},
309 {
"vstore16" , {3}, {E_V16_OF_POINTEE,EX_SIZET,E_ANY}},
310 {
"vstore2" , {3}, {E_V2_OF_POINTEE,EX_SIZET,E_ANY}},
311 {
"vstore3" , {3}, {E_V3_OF_POINTEE,EX_SIZET,E_ANY}},
312 {
"vstore4" , {3}, {E_V4_OF_POINTEE,EX_SIZET,E_ANY}},
313 {
"vstore8" , {3}, {E_V8_OF_POINTEE,EX_SIZET,E_ANY}},
314 {
"work_group_commit_read_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
315 {
"work_group_commit_write_pipe" , {1}, {E_ANY,EX_RESERVEDID}},
316 {
"work_group_reduce_add" , {1}, {E_ANY}},
317 {
"work_group_reduce_max" , {1}, {E_ANY}},
318 {
"work_group_reduce_min" , {1}, {E_ANY}},
319 {
"work_group_reserve_read_pipe" , {1}, {E_ANY,EX_UINT}},
320 {
"work_group_reserve_write_pipe" , {1}, {E_ANY,EX_UINT}},
321 {
"work_group_scan_exclusive_add" , {1}, {E_ANY}},
322 {
"work_group_scan_exclusive_max" , {1}, {E_ANY}},
323 {
"work_group_scan_exclusive_min" , {1}, {E_ANY}},
324 {
"work_group_scan_inclusive_add" , {1}, {E_ANY}},
325 {
"work_group_scan_inclusive_max" , {1}, {E_ANY}},
326 {
"work_group_scan_inclusive_min" , {1}, {E_ANY}},
327 {
"write_imagef" , {1}, {E_ANY,E_IMAGECOORDS,EX_FLOAT4}},
328 {
"write_imagei" , {1}, {E_ANY,E_IMAGECOORDS,EX_INTV4}},
329 {
"write_imageui" , {1}, {E_ANY,E_IMAGECOORDS,EX_UINTV4}},
330 {
"ncos" , {1}, {E_ANY} },
331 {
"nexp2" , {1}, {E_ANY} },
332 {
"nfma" , {1}, {E_ANY, E_COPY, E_COPY} },
333 {
"nlog2" , {1}, {E_ANY} },
334 {
"nrcp" , {1}, {E_ANY} },
335 {
"nrsqrt" , {1}, {E_ANY} },
336 {
"nsin" , {1}, {E_ANY} },
337 {
"nsqrt" , {1}, {E_ANY} },
338 {
"ftz" , {1}, {E_ANY} },
339 {
"fldexp" , {1}, {E_ANY, EX_UINT} },
340 {
"class" , {1}, {E_ANY, EX_UINT} },
341 {
"rcbrt" , {1}, {E_ANY} },
345 const UnmangledFuncInfo UnmangledFuncInfo::Table[] = {
346 {
"__read_pipe_2", 4},
347 {
"__read_pipe_4", 6},
348 {
"__write_pipe_2", 4},
349 {
"__write_pipe_4", 6},
352 const unsigned UnmangledFuncInfo::TableSize =
353 sizeof(UnmangledFuncInfo::Table) /
sizeof(UnmangledFuncInfo::Table[0]);
355 UnmangledFuncInfo::NameMap UnmangledFuncInfo::Map;
357 static const struct ManglingRulesMap :
public StringMap<int> {
359 :
StringMap<int>(
sizeof(manglingRules)/
sizeof(manglingRules[0])) {
361 for (
auto Rule : manglingRules)
362 insert({ Rule.Name, Id++ });
367 const AMDGPULibFunc::Param (&Leads)[2]) {
368 AMDGPULibFunc::Param Res = Leads[0];
380 class ParamIterator {
381 const AMDGPULibFunc::Param (&Leads)[2];
382 const ManglingRule& Rule;
385 ParamIterator(
const AMDGPULibFunc::Param (&leads)[2],
386 const ManglingRule& rule)
387 : Leads(leads), Rule(rule),
Index(0) {}
389 AMDGPULibFunc::Param getNextParam();
392 AMDGPULibFunc::Param ParamIterator::getNextParam() {
393 AMDGPULibFunc::Param
P;
394 if (
Index >=
int(
sizeof Rule.Param/
sizeof Rule.Param[0]))
return P;
396 const char R = Rule.Param[
Index];
413 case EX_RESERVEDID:
break;
415 if (
Index == (Rule.Lead[1] - 1)) P = Leads[1];
424 case E_V2_OF_POINTEE:
426 case E_V3_OF_POINTEE:
428 case E_V4_OF_POINTEE:
430 case E_V8_OF_POINTEE:
432 case E_V16_OF_POINTEE:
461 case E_CONSTPTR_SWAPGL: {
479 inline static void drop_front(
StringRef& str,
size_t n = 1) {
483 static bool eatTerm(
StringRef& mangledName,
const char c) {
484 if (mangledName.
front() == c) {
485 drop_front(mangledName);
492 static bool eatTerm(
StringRef& mangledName,
const char (&str)[
N]) {
494 drop_front(mangledName, N-1);
500 static inline bool isDigit(
char c) {
return c >=
'0' && c <=
'9'; }
503 size_t const savedSize = s.
size();
506 n = n*10 + s.
front() -
'0';
509 return s.
size() < savedSize ? n : -1;
513 int const Len = eatNumber(mangledName);
514 if (Len <= 0 || static_cast<size_t>(Len) > mangledName.
size())
517 drop_front(mangledName, Len);
539 FKind = copyFrom.
FKind;
540 Leads[0] = copyFrom.
Leads[0];
541 Leads[1] = copyFrom.
Leads[1];
548 size_t const Len = eatNumber(mangledName);
550 case 2:
case 3:
case 4:
case 8:
case 16:
559 std::pair<StringRef, StringRef>
const P = mangledName.
split(
'_');
567 mangledName = P.second;
572 bool AMDGPUMangledLibFunc::parseUnmangledName(
StringRef FullName) {
573 FuncId =
static_cast<EFuncId
>(manglingRulesMap.lookup(FullName));
581 struct ItaniumParamParser {
582 AMDGPULibFunc::Param Prev;
583 bool parseItaniumParam(
StringRef& param, AMDGPULibFunc::Param &res);
587 bool ItaniumParamParser::parseItaniumParam(
StringRef& param,
588 AMDGPULibFunc::Param &res) {
590 if (param.
empty())
return false;
593 if (eatTerm(param,
'P')) {
597 if (!eatTerm(param,
"U3AS")) {
600 AS = param.
front() -
'0';
601 drop_front(param, 1);
609 if (eatTerm(param,
"Dv")) {
611 if (res.VectorSize==1 || !eatTerm(param,
'_'))
return false;
615 char const TC = param.
front();
618 (eatLengthPrefixedName(param))
641 case 'D':
if (!eatTerm(param,
'h'))
return false;
644 if (!eatTerm(param,
'_')) {
646 if (!eatTerm(param,
'_'))
return false;
648 res.VectorSize = Prev.VectorSize;
649 res.ArgType = Prev.ArgType;
654 if (res.ArgType == 0)
return false;
655 Prev.VectorSize = res.VectorSize;
656 Prev.ArgType = res.ArgType;
663 if (!parseUnmangledName(Name))
666 const ManglingRule& Rule = manglingRules[
FuncId];
667 ItaniumParamParser Parser;
668 for (
int I=0;
I < Rule.maxLeadIndex(); ++
I) {
670 if (!Parser.parseItaniumParam(mangledName, P))
673 if ((
I + 1) == Rule.Lead[0]) Leads[0] = P;
674 if ((
I + 1) == Rule.Lead[1]) Leads[1] = P;
687 if (FuncName.
empty()) {
688 F.Impl = std::unique_ptr<AMDGPULibFuncImpl>();
692 if (eatTerm(FuncName,
"_Z"))
693 F.Impl = make_unique<AMDGPUMangledLibFunc>();
695 F.Impl = make_unique<AMDGPUUnmangledLibFunc>();
696 if (F.Impl->parseFuncName(FuncName))
699 F.Impl = std::unique_ptr<AMDGPULibFuncImpl>();
705 if (eatTerm(S,
"_Z"))
706 return eatLengthPrefixedName(S);
713 template <
typename Stream>
714 void AMDGPUMangledLibFunc::writeName(Stream &OS)
const {
715 const char *Pfx =
"";
717 case NATIVE: Pfx =
"native_";
break;
718 case HALF: Pfx =
"half_";
break;
723 }
else if (
FuncId != EI_NONE) {
786 class ItaniumMangler {
790 int findSubst(
const AMDGPULibFunc::Param&
P)
const {
791 for(
unsigned I = 0;
I < Str.
size(); ++
I) {
792 const AMDGPULibFunc::Param&
T = Str[
I];
793 if (P.PtrKind == T.PtrKind &&
794 P.VectorSize == T.VectorSize &&
795 P.ArgType == T.ArgType) {
802 template <
typename Stream>
803 bool trySubst(Stream& os,
const AMDGPULibFunc::Param& p) {
804 int const subst = findSubst(p);
805 if (subst < 0)
return false;
809 if (subst == 0) os <<
"S_";
810 else os <<
'S' << (subst-1) <<
'_';
815 ItaniumMangler(
bool useAddrSpace)
816 : UseAddrSpace(useAddrSpace) {}
818 template <
typename Stream>
819 void operator()(Stream& os, AMDGPULibFunc::Param p) {
831 AMDGPULibFunc::Param Ptr;
834 if (trySubst(os, p))
return;
838 unsigned AS = UseAddrSpace
841 if (AS != 0) os <<
"U3AS" << AS;
846 if (p.VectorSize > 1) {
847 if (trySubst(os, p))
goto exit;
849 os <<
"Dv" <<
static_cast<unsigned>(p.VectorSize) <<
'_';
860 std::string AMDGPUMangledLibFunc::mangleNameItanium()
const {
867 S <<
"_Z" <<
static_cast<int>(NameStr.
size()) << NameStr;
870 ParamIterator
I(Leads, manglingRules[
FuncId]);
872 while ((P = I.getNextParam()).ArgType != 0)
882 const AMDGPULibFunc::Param&
P,
913 if (P.VectorSize > 1)
924 std::vector<Type*>
Args;
925 ParamIterator
I(Leads, manglingRules[
FuncId]);
927 while ((P=I.getNextParam()).ArgType != 0)
936 return manglingRules[
FuncId].getNumArgs();
940 return UnmangledFuncInfo::getNumArgs(
FuncId);
951 std::string FuncName = fInfo.
mangle();
952 Function *
F = dyn_cast_or_null<Function>(
966 std::string
const FuncName = fInfo.
mangle();
967 Function *
F = dyn_cast_or_null<Function>(
984 const Type* argTy =
static_cast<const Type*
>(*PI);
1005 return cast<Function>(
C);
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)
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
This class represents lattice values for constants.
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)
void push_back(const T &Elt)
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)
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
amdgpu Simplify well known AMD library false Value Value const Twine & Name
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
Address space for local memory.
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)
Address space for global memory (RAT0, VTX0).
#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)
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)
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