18 #include "llvm/ADT/StringRef.h"
19 using namespace clang;
22 {
"not a builtin function",
nullptr,
nullptr,
nullptr,
ALL_LANGUAGES,
nullptr},
23 #define BUILTIN(ID, TYPE, ATTRS) \
24 { #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
25 #define LANGBUILTIN(ID, TYPE, ATTRS, LANGS) \
26 { #ID, TYPE, ATTRS, nullptr, LANGS, nullptr },
27 #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER, LANGS) \
28 { #ID, TYPE, ATTRS, HEADER, LANGS, nullptr },
29 #include "clang/Basic/Builtins.def"
36 (TSRecords.size() + AuxTSRecords.size())) &&
37 "Invalid builtin ID!");
45 assert(TSRecords.empty() &&
"Already initialized target?");
46 TSRecords =
Target.getTargetBuiltins();
52 bool InStdNamespace = FuncName.consume_front(
"std-");
56 (
bool)strchr(
BuiltinInfo[i].Attributes,
'z') == InStdNamespace)
57 return strchr(
BuiltinInfo[i].Attributes,
'f') !=
nullptr;
66 bool BuiltinsUnsupported =
68 bool CorBuiltinsUnsupported =
70 bool MathBuiltinsUnsupported =
74 bool MSModeUnsupported =
77 bool OclCUnsupported =
79 bool OclGASUnsupported =
81 bool OclPipeUnsupported =
85 bool OclDSEUnsupported =
90 bool CPlusPlusUnsupported =
92 return !BuiltinsUnsupported && !CorBuiltinsUnsupported &&
93 !MathBuiltinsUnsupported && !OclCUnsupported && !OclGASUnsupported &&
94 !OclPipeUnsupported && !OclDSEUnsupported && !OpenMPUnsupported &&
95 !GnuModeUnsupported && !MSModeUnsupported && !ObjCUnsupported &&
96 !CPlusPlusUnsupported && !CUDAUnsupported;
111 for (
unsigned i = 0, e = TSRecords.size(); i != e; ++i)
116 for (
unsigned i = 0, e = AuxTSRecords.size(); i != e; ++i)
117 Table.
get(AuxTSRecords[i].Name)
122 bool InStdNamespace = Name.consume_front(
"std-");
123 auto NameIt = Table.
find(Name);
124 if (NameIt != Table.
end()) {
125 unsigned ID = NameIt->second->getBuiltinID();
127 isInStdNamespace(
ID) == InStdNamespace) {
135 const char *WidthPos = ::strchr(getRecord(
ID).Attributes,
'V');
140 assert(*WidthPos ==
':' &&
141 "Vector width specifier must be followed by a ':'");
145 unsigned Width = ::strtol(WidthPos, &EndPos, 10);
146 assert(*EndPos ==
':' &&
"Vector width specific must end with a ':'");
150 bool Builtin::Context::isLike(
unsigned ID,
unsigned &FormatIdx,
151 bool &HasVAListArg,
const char *Fmt)
const {
152 assert(Fmt &&
"Not passed a format string");
153 assert(::strlen(Fmt) == 2 &&
154 "Format string needs to be two characters long");
155 assert(::toupper(Fmt[0]) == Fmt[1] &&
156 "Format string is not in the form \"xX\"");
158 const char *Like = ::strpbrk(getRecord(
ID).Attributes, Fmt);
162 HasVAListArg = (*Like == Fmt[1]);
165 assert(*Like ==
':' &&
"Format specifier must be followed by a ':'");
168 assert(::strchr(Like,
':') &&
"Format specifier must end with a ':'");
169 FormatIdx = ::strtol(Like,
nullptr, 10);
174 bool &HasVAListArg) {
175 return isLike(
ID, FormatIdx, HasVAListArg,
"pP");
179 bool &HasVAListArg) {
180 return isLike(
ID, FormatIdx, HasVAListArg,
"sS");
185 const char *CalleePos = ::strchr(getRecord(
ID).Attributes,
'C');
190 assert(*CalleePos ==
'<' &&
191 "Callback callee specifier must be followed by a '<'");
195 int CalleeIdx = ::strtol(CalleePos, &EndPos, 10);
196 assert(CalleeIdx >= 0 &&
"Callee index is supposed to be positive!");
199 while (*EndPos ==
',') {
200 const char *PayloadPos = EndPos + 1;
202 int PayloadIdx = ::strtol(PayloadPos, &EndPos, 10);
206 assert(*EndPos ==
'>' &&
"Callback callee specifier must end with a '>'");
212 (!hasReferenceArgsOrResult(
ID) && !hasCustomTypechecking(
ID)) ||
213 isInStdNamespace(
ID);
217 StringRef RequiredFeatures,
const llvm::StringMap<bool> &TargetFetureMap) {
219 if (RequiredFeatures.empty())
221 assert(!RequiredFeatures.contains(
' ') &&
"Space in feature list");
224 return TF.hasRequiredFeatures(RequiredFeatures);