clang 24.0.0git
Builtins.cpp
Go to the documentation of this file.
1//===--- Builtins.cpp - Builtin function implementation -------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements various things for builtin functions.
10//
11//===----------------------------------------------------------------------===//
12
18#include "llvm/ADT/SmallString.h"
19#include "llvm/ADT/StringRef.h"
20using namespace clang;
21
22const char *HeaderDesc::getName() const {
23 switch (ID) {
24#define HEADER(ID, NAME) \
25 case ID: \
26 return NAME;
27#include "clang/Basic/BuiltinHeaders.def"
28#undef HEADER
29 };
30 llvm_unreachable("Unknown HeaderDesc::HeaderID enum");
31}
32
33static constexpr unsigned NumBuiltins = Builtin::FirstTSBuiltin;
34
35#define GET_BUILTIN_STR_TABLE
36#include "clang/Basic/Builtins.inc"
37#undef GET_BUILTIN_STR_TABLE
38
39static constexpr Builtin::Info BuiltinInfos[] = {
40 Builtin::Info{}, // No-builtin info entry.
41#define GET_BUILTIN_INFOS
42#include "clang/Basic/Builtins.inc"
43#undef GET_BUILTIN_INFOS
44};
45static_assert(std::size(BuiltinInfos) == NumBuiltins);
46
47std::pair<const Builtin::InfosShard &, const Builtin::Info &>
48Builtin::Context::getShardAndInfo(unsigned ID) const {
49 assert((ID < (Builtin::FirstTSBuiltin + NumTargetBuiltins +
50 NumAuxTargetBuiltins)) &&
51 "Invalid builtin ID!");
52
53 ArrayRef<InfosShard> Shards = BuiltinShards;
54 if (isAuxBuiltinID(ID)) {
55 Shards = AuxTargetShards;
57 } else if (ID >= Builtin::FirstTSBuiltin) {
58 Shards = TargetShards;
60 }
61
62 // Loop over the shards to find the one matching this ID. We don't expect to
63 // have many shards and so its better to search linearly than with a binary
64 // search.
65 for (const auto &Shard : Shards) {
66 if (ID < Shard.Infos.size()) {
67 return {Shard, Shard.Infos[ID]};
68 }
69
70 ID -= Shard.Infos.size();
71 }
72 llvm_unreachable("Invalid target builtin shard structure!");
73}
74
75/// Return a non-owning StringRef of the builtin's name, reconstructed into Buf.
76static StringRef getBuiltinNameInto(const Builtin::InfosShard &Shard,
77 const Builtin::Info &BuiltinInfo,
79 StringRef Name = (*Shard.Strings)[BuiltinInfo.Offsets.Name];
80 if (Shard.NamePrefix.empty())
81 return Name;
82 Buf.assign(Shard.NamePrefix.begin(), Shard.NamePrefix.end());
83 Buf.append(Name.begin(), Name.end());
84 return StringRef(Buf.data(), Buf.size());
85}
86
87std::string Builtin::Info::getName(const Builtin::InfosShard &Shard) const {
89 return getBuiltinNameInto(Shard, *this, Buf).str();
90}
91
92/// Return the identifier name for the specified builtin,
93/// e.g. "__builtin_abs".
94std::string Builtin::Context::getName(unsigned ID) const {
95 const auto &[Shard, I] = getShardAndInfo(ID);
96 return I.getName(Shard);
97}
98
100 const auto &[Shard, I] = getShardAndInfo(ID);
102 Result += Shard.NamePrefix;
103 Result += (*Shard.Strings)[I.Offsets.Name];
104 Result += '\'';
105 return Result;
106}
107
108const char *Builtin::Context::getTypeString(unsigned ID) const {
109 const auto &[Shard, I] = getShardAndInfo(ID);
110 return (*Shard.Strings)[I.Offsets.Type].data();
111}
112
113const char *Builtin::Context::getAttributesString(unsigned ID) const {
114 const auto &[Shard, I] = getShardAndInfo(ID);
115 return (*Shard.Strings)[I.Offsets.Attributes].data();
116}
117
118const char *Builtin::Context::getRequiredFeatures(unsigned ID) const {
119 const auto &[Shard, I] = getShardAndInfo(ID);
120 return (*Shard.Strings)[I.Offsets.Features].data();
121}
122
124
126 const TargetInfo *AuxTarget) {
127 assert(TargetShards.empty() && "Already initialized target?");
128 assert(NumTargetBuiltins == 0 && "Already initialized target?");
129 TargetShards = Target.getTargetBuiltins();
130 for (const auto &Shard : TargetShards)
131 NumTargetBuiltins += Shard.Infos.size();
132 if (AuxTarget) {
133 AuxTargetShards = AuxTarget->getTargetBuiltins();
134 for (const auto &Shard : AuxTargetShards)
135 NumAuxTargetBuiltins += Shard.Infos.size();
136 }
137}
138
139bool Builtin::Context::isBuiltinFunc(llvm::StringRef FuncName) {
140 bool InStdNamespace = FuncName.consume_front("std-");
141 for (const auto &Shard : {InfosShard{&BuiltinStrings, BuiltinInfos}})
142 if (llvm::StringRef FuncNameSuffix = FuncName;
143 FuncNameSuffix.consume_front(Shard.NamePrefix))
144 for (const auto &I : Shard.Infos)
145 if (FuncNameSuffix == (*Shard.Strings)[I.Offsets.Name] &&
146 (bool)strchr((*Shard.Strings)[I.Offsets.Attributes].data(), 'z') ==
147 InStdNamespace)
148 return strchr((*Shard.Strings)[I.Offsets.Attributes].data(), 'f') !=
149 nullptr;
150
151 return false;
152}
153
154/// Is this builtin supported according to the given language options?
155static bool builtinIsSupported(const llvm::StringTable &Strings,
156 const Builtin::Info &BuiltinInfo,
157 const LangOptions &LangOpts) {
158 auto AttributesStr = Strings[BuiltinInfo.Offsets.Attributes];
159
160 /* Builtins Unsupported */
161 if (LangOpts.NoBuiltin && strchr(AttributesStr.data(), 'f') != nullptr)
162 return false;
163 /* CorBuiltins Unsupported */
164 if (!LangOpts.Coroutines && (BuiltinInfo.Langs & COR_LANG))
165 return false;
166 /* MathBuiltins Unsupported */
167 if (LangOpts.NoMathBuiltin && BuiltinInfo.Header.ID == HeaderDesc::MATH_H)
168 return false;
169 /* GnuMode Unsupported */
170 if (!LangOpts.GNUMode && (BuiltinInfo.Langs & GNU_LANG))
171 return false;
172 /* MSMode Unsupported */
173 if (!LangOpts.MicrosoftExt && (BuiltinInfo.Langs & MS_LANG))
174 return false;
175 /* HLSLMode Unsupported */
176 if (!LangOpts.HLSL && (BuiltinInfo.Langs & HLSL_LANG))
177 return false;
178 /* ObjC Unsupported */
179 if (!LangOpts.ObjC && BuiltinInfo.Langs == OBJC_LANG)
180 return false;
181 /* OpenCLC Unsupported */
182 if (!LangOpts.OpenCL && (BuiltinInfo.Langs & ALL_OCL_LANGUAGES))
183 return false;
184 /* OpenCL GAS Unsupported */
185 if (!LangOpts.OpenCLGenericAddressSpace && (BuiltinInfo.Langs & OCL_GAS))
186 return false;
187 /* OpenCL Pipe Unsupported */
188 if (!LangOpts.OpenCLPipes && (BuiltinInfo.Langs & OCL_PIPE))
189 return false;
190
191 // Device side enqueue is not supported until OpenCL 2.0. In 2.0 and higher
192 // support is indicated with language option for blocks.
193
194 /* OpenCL DSE Unsupported */
195 if ((LangOpts.getOpenCLCompatibleVersion() < 200 || !LangOpts.Blocks) &&
196 (BuiltinInfo.Langs & OCL_DSE))
197 return false;
198 /* OpenMP Unsupported */
199 if (!LangOpts.OpenMP && BuiltinInfo.Langs == OMP_LANG)
200 return false;
201 /* CUDA Unsupported */
202 if (!LangOpts.CUDA && BuiltinInfo.Langs == CUDA_LANG)
203 return false;
204 /* CPlusPlus Unsupported */
205 if (!LangOpts.CPlusPlus && BuiltinInfo.Langs == CXX_LANG)
206 return false;
207 /* consteval Unsupported */
208 if (!LangOpts.CPlusPlus20 && strchr(AttributesStr.data(), 'G') != nullptr)
209 return false;
210 /* C23 unsupported */
211 if (!LangOpts.C23 && BuiltinInfo.Langs == C23_LANG)
212 return false;
213 /* C2y unsupported */
214 if (!LangOpts.C2y && BuiltinInfo.Langs == C2Y_LANG)
215 return false;
216 /* Reflection unsupported */
217 if (!LangOpts.Reflection && (BuiltinInfo.Langs & REFLECTION_LANG))
218 return false;
219 return true;
220}
221
222static bool isBuiltinConstForTriple(unsigned BuiltinID, llvm::Triple Trip) {
223 // There's a special case with the fma builtins where they are always const
224 // if the target environment is GNU or the target is OS is Windows and we're
225 // targeting the MSVCRT.dll environment.
226 // FIXME: This list can be become outdated. Need to find a way to get it some
227 // other way.
228 switch (BuiltinID) {
229 case Builtin::BI__builtin_fma:
230 case Builtin::BI__builtin_fmaf:
231 case Builtin::BI__builtin_fmal:
232 case Builtin::BI__builtin_fmaf16:
233 case Builtin::BIfma:
234 case Builtin::BIfmaf:
235 case Builtin::BIfmal: {
236 if (Trip.isGNUEnvironment() || Trip.isOSMSVCRT())
237 return true;
238 break;
239 }
240 default:
241 break;
242 }
243
244 return false;
245}
246
248 unsigned BuiltinID, llvm::Triple Trip, std::optional<bool> ErrnoOverwritten,
249 bool MathErrnoEnabled, bool HasOptNoneAttr,
250 bool IsOptimizationEnabled) const {
251
252 // True if we are compiling at -O2 and errno has been disabled
253 // using the '#pragma float_control(precise, off)', and
254 // attribute opt-none hasn't been seen.
255 bool ErrnoOverridenToFalseWithOpt = ErrnoOverwritten.has_value() &&
256 !ErrnoOverwritten.value() &&
257 !HasOptNoneAttr && IsOptimizationEnabled;
258
259 // There are LLVM math intrinsics/instructions corresponding to math library
260 // functions except the LLVM op will never set errno while the math library
261 // might. Also, math builtins have the same semantics as their math library
262 // twins. Thus, we can transform math library and builtin calls to their
263 // LLVM counterparts if the call is marked 'const' (known to never set errno).
264 // In case FP exceptions are enabled, the experimental versions of the
265 // intrinsics model those.
266 bool ConstAlways =
267 isConst(BuiltinID) || isBuiltinConstForTriple(BuiltinID, Trip);
268
269 bool ConstWithoutErrnoAndExceptions =
271 bool ConstWithoutExceptions = isConstWithoutExceptions(BuiltinID);
272
273 // ConstAttr is enabled in fast-math mode. In fast-math mode, math-errno is
274 // disabled.
275 // Math intrinsics are generated only when math-errno is disabled. Any pragmas
276 // or attributes that affect math-errno should prevent or allow math
277 // intrinsics to be generated. Intrinsics are generated:
278 // 1- In fast math mode, unless math-errno is overriden
279 // via '#pragma float_control(precise, on)', or via an
280 // 'attribute__((optnone))'.
281 // 2- If math-errno was enabled on command line but overriden
282 // to false via '#pragma float_control(precise, off))' and
283 // 'attribute__((optnone))' hasn't been used.
284 // 3- If we are compiling with optimization and errno has been disabled
285 // via '#pragma float_control(precise, off)', and
286 // 'attribute__((optnone))' hasn't been used.
287
288 bool ConstWithoutErrnoOrExceptions =
289 ConstWithoutErrnoAndExceptions || ConstWithoutExceptions;
290 bool GenerateIntrinsics =
291 (ConstAlways && !HasOptNoneAttr) ||
292 (!MathErrnoEnabled &&
293 !(ErrnoOverwritten.has_value() && ErrnoOverwritten.value()) &&
294 !HasOptNoneAttr);
295 if (!GenerateIntrinsics) {
296 GenerateIntrinsics =
297 ConstWithoutErrnoOrExceptions && !ConstWithoutErrnoAndExceptions;
298 if (!GenerateIntrinsics)
299 GenerateIntrinsics =
300 ConstWithoutErrnoOrExceptions &&
301 (!MathErrnoEnabled &&
302 !(ErrnoOverwritten.has_value() && ErrnoOverwritten.value()) &&
303 !HasOptNoneAttr);
304 if (!GenerateIntrinsics)
305 GenerateIntrinsics =
306 ConstWithoutErrnoOrExceptions && ErrnoOverridenToFalseWithOpt;
307 }
308
309 return GenerateIntrinsics;
310}
311
312/// initializeBuiltins - Mark the identifiers for all the builtins with their
313/// appropriate builtin ID # and mark any non-portable builtin identifiers as
314/// such.
316 const LangOptions &LangOpts) {
317 {
318 unsigned ID = 0;
320 // Step #1: mark all target-independent builtins with their ID's.
321 for (const auto &Shard : BuiltinShards)
322 for (const auto &I : Shard.Infos) {
323 // If this is a real builtin (ID != 0) and is supported, add it.
324 if (ID != 0 && builtinIsSupported(*Shard.Strings, I, LangOpts))
325 Table.get(getBuiltinNameInto(Shard, I, NameBuf)).setBuiltinID(ID);
326 ++ID;
327 }
328 assert(ID == FirstTSBuiltin && "Should have added all non-target IDs!");
329
330 // Step #2: Register target-specific builtins.
331 for (const auto &Shard : TargetShards)
332 for (const auto &I : Shard.Infos) {
333 if (builtinIsSupported(*Shard.Strings, I, LangOpts))
334 Table.get(getBuiltinNameInto(Shard, I, NameBuf)).setBuiltinID(ID);
335 ++ID;
336 }
337
338 // Step #3: Register target-specific builtins for AuxTarget.
339 for (const auto &Shard : AuxTargetShards)
340 for (const auto &I : Shard.Infos) {
341 Table.get(getBuiltinNameInto(Shard, I, NameBuf)).setBuiltinID(ID);
342 ++ID;
343 }
344 }
345
346 // Step #4: Unregister any builtins specified by -fno-builtin-foo.
347 for (llvm::StringRef Name : LangOpts.NoBuiltinFuncs) {
348 bool InStdNamespace = Name.consume_front("std-");
349 auto NameIt = Table.find(Name);
350 if (NameIt != Table.end()) {
351 unsigned ID = NameIt->second->getBuiltinID();
353 isInStdNamespace(ID) == InStdNamespace) {
354 NameIt->second->clearBuiltinID();
355 }
356 }
357 }
358}
359
361 const char *WidthPos = ::strchr(getAttributesString(ID), 'V');
362 if (!WidthPos)
363 return 0;
364
365 ++WidthPos;
366 assert(*WidthPos == ':' &&
367 "Vector width specifier must be followed by a ':'");
368 ++WidthPos;
369
370 char *EndPos;
371 unsigned Width = ::strtol(WidthPos, &EndPos, 10);
372 assert(*EndPos == ':' && "Vector width specific must end with a ':'");
373 return Width;
374}
375
376bool Builtin::Context::isLike(unsigned ID, unsigned &FormatIdx,
377 bool &HasVAListArg, const char *Fmt) const {
378 assert(Fmt && "Not passed a format string");
379 assert(::strlen(Fmt) == 2 &&
380 "Format string needs to be two characters long");
381 assert(::toupper(Fmt[0]) == Fmt[1] &&
382 "Format string is not in the form \"xX\"");
383
384 const char *Like = ::strpbrk(getAttributesString(ID), Fmt);
385 if (!Like)
386 return false;
387
388 HasVAListArg = (*Like == Fmt[1]);
389
390 ++Like;
391 assert(*Like == ':' && "Format specifier must be followed by a ':'");
392 ++Like;
393
394 assert(::strchr(Like, ':') && "Format specifier must end with a ':'");
395 FormatIdx = ::strtol(Like, nullptr, 10);
396 return true;
397}
398
399bool Builtin::Context::isPrintfLike(unsigned ID, unsigned &FormatIdx,
400 bool &HasVAListArg) {
401 return isLike(ID, FormatIdx, HasVAListArg, "pP");
402}
403
404bool Builtin::Context::isScanfLike(unsigned ID, unsigned &FormatIdx,
405 bool &HasVAListArg) {
406 return isLike(ID, FormatIdx, HasVAListArg, "sS");
407}
408
409static void parseCommaSeparatedIndices(const char *CurrPos,
411 assert(*CurrPos == '<' && "Expected '<' to start index list");
412 ++CurrPos;
413
414 char *EndPos;
415 int PosIdx = ::strtol(CurrPos, &EndPos, 10);
416 assert(PosIdx >= 0 && "Index is supposed to be positive!");
417 Indxs.push_back(PosIdx);
418
419 while (*EndPos == ',') {
420 const char *PayloadPos = EndPos + 1;
421
422 int PayloadIdx = ::strtol(PayloadPos, &EndPos, 10);
423 Indxs.push_back(PayloadIdx);
424 }
425
426 assert(*EndPos == '>' && "Index list must end with '>'");
427}
428
430 Info::NonNullMode &Mode) const {
431
432 const char *AttrPos = ::strchr(getAttributesString(ID), 'N');
433 if (!AttrPos)
434 return false;
435
436 ++AttrPos;
437 assert(*AttrPos == ':' && "Format specifier must be followed by a ':'");
438 ++AttrPos;
439 if (*AttrPos == '0')
441 else if (*AttrPos == '1')
443 else
444 llvm_unreachable("Unrecognized NonNull optimization mode");
445 ++AttrPos; // skip mode
446 assert(*AttrPos == ':' && "Mode must be followed by a ':'");
447 ++AttrPos;
448
449 parseCommaSeparatedIndices(AttrPos, Indxs);
450
451 return true;
452}
453
455 unsigned ID, llvm::SmallVectorImpl<ArgRange> &Ranges) const {
456 StringRef Attrs = getAttributesString(ID);
457 size_t Pos = Attrs.find('R');
458 if (Pos == StringRef::npos)
459 return;
460
461 StringRef Str = Attrs.drop_front(Pos + 1);
462 if (!Str.consume_front("<"))
463 llvm_unreachable("Expected '<' to start range list");
464
465 do {
466 ArgRange Range;
467 if (Str.consumeInteger(10, Range.Index) || !Str.consume_front(":") ||
468 Str.consumeInteger(10, Range.Lower) || !Str.consume_front(":") ||
469 Str.consumeInteger(10, Range.Upper))
470 llvm_unreachable("Malformed argument range");
471 Ranges.push_back(Range);
472 } while (Str.consume_front(","));
473
474 assert(Str.starts_with('>') && "Range list must end with '>'");
475}
476
478 SmallVectorImpl<int> &Encoding) const {
479 const char *CalleePos = ::strchr(getAttributesString(ID), 'C');
480 if (!CalleePos)
481 return false;
482
483 ++CalleePos;
484 parseCommaSeparatedIndices(CalleePos, Encoding);
485
486 return true;
487}
488
490 return ID == Builtin::NotBuiltin || ID == Builtin::BI__va_start ||
491 ID == Builtin::BI__builtin_assume_aligned ||
494}
495
497 StringRef RequiredFeatures, const llvm::StringMap<bool> &TargetFetureMap) {
498 // Return true if the builtin doesn't have any required features.
499 if (RequiredFeatures.empty())
500 return true;
501 assert(!RequiredFeatures.contains(' ') && "Space in feature list");
502
503 TargetFeatures TF(TargetFetureMap);
504 return TF.hasRequiredFeatures(RequiredFeatures);
505}
static constexpr llvm::StringTable BuiltinStrings
Definition Mips.cpp:25
static StringRef getBuiltinNameInto(const Builtin::InfosShard &Shard, const Builtin::Info &BuiltinInfo, SmallVectorImpl< char > &Buf)
Return a non-owning StringRef of the builtin's name, reconstructed into Buf.
Definition Builtins.cpp:76
static constexpr Builtin::Info BuiltinInfos[]
Definition Builtins.cpp:39
static bool builtinIsSupported(const llvm::StringTable &Strings, const Builtin::Info &BuiltinInfo, const LangOptions &LangOpts)
Is this builtin supported according to the given language options?
Definition Builtins.cpp:155
static constexpr unsigned NumBuiltins
Definition Builtins.cpp:33
static void parseCommaSeparatedIndices(const char *CurrPos, llvm::SmallVectorImpl< int > &Indxs)
Definition Builtins.cpp:409
static bool isBuiltinConstForTriple(unsigned BuiltinID, llvm::Triple Trip)
Definition Builtins.cpp:222
Defines enum values for all the target-independent builtin functions.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Defines the clang::LangOptions interface.
bool shouldGenerateFPMathIntrinsic(unsigned BuiltinID, llvm::Triple Trip, std::optional< bool > ErrnoOverwritten, bool MathErrnoEnabled, bool HasOptNoneAttr, bool IsOptimizationEnabled) const
Determine whether we can generate LLVM intrinsics for the given builtin ID, based on whether it has s...
Definition Builtins.cpp:247
llvm::SmallString< 64 > getQuotedName(unsigned ID) const
Return the identifier name for the specified builtin inside single quotes for a diagnostic,...
Definition Builtins.cpp:99
bool hasReferenceArgsOrResult(unsigned ID) const
Return true if this builtin has a result or any arguments which are reference types.
Definition Builtins.h:378
bool performsCallback(unsigned ID, llvm::SmallVectorImpl< int > &Encoding) const
Determine whether this builtin has callback behavior (see llvm::AbstractCallSites for details).
Definition Builtins.cpp:477
bool isAuxBuiltinID(unsigned ID) const
Return true if the builtin ID belongs exclusively to the AuxTarget, and false if it belongs to both p...
Definition Builtins.h:455
bool isNonNull(unsigned ID, llvm::SmallVectorImpl< int > &Indxs, Info::NonNullMode &Mode) const
Return true if this builtin has parameters that must be non-null.
Definition Builtins.cpp:429
bool isConstWithoutErrnoAndExceptions(unsigned ID) const
Return true if this function has no side effects and doesn't read memory, except for possibly errno o...
Definition Builtins.h:425
static bool isBuiltinFunc(llvm::StringRef Name)
Returns true if this is a libc/libm function without the '__builtin_' prefix.
Definition Builtins.cpp:139
unsigned getRequiredVectorWidth(unsigned ID) const
Definition Builtins.cpp:360
unsigned getAuxBuiltinID(unsigned ID) const
Return real builtin ID (i.e.
Definition Builtins.h:461
bool hasCustomTypechecking(unsigned ID) const
Determines whether this builtin has custom typechecking.
Definition Builtins.h:359
std::string getName(unsigned ID) const
Return the identifier name for the specified builtin, e.g.
Definition Builtins.cpp:94
void initializeBuiltins(IdentifierTable &Table, const LangOptions &LangOpts)
Mark the identifiers for all the builtins with their appropriate builtin ID # and mark any non-portab...
Definition Builtins.cpp:315
bool isScanfLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg)
Determine whether this builtin is like scanf in its formatting rules and, if so, set the index to the...
Definition Builtins.cpp:404
bool isInStdNamespace(unsigned ID) const
Determines whether this builtin is a C++ standard library function that lives in (possibly-versioned)...
Definition Builtins.h:345
bool canBeRedeclared(unsigned ID) const
Returns true if this is a builtin that can be redeclared.
Definition Builtins.cpp:489
const char * getAttributesString(unsigned ID) const
Get the attributes descriptor string for the specified builtin.
Definition Builtins.cpp:113
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc",...
Definition Builtins.h:323
bool isPrintfLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg)
Determine whether this builtin is like printf in its formatting rules and, if so, set the index to th...
Definition Builtins.cpp:399
const char * getTypeString(unsigned ID) const
Get the type descriptor string for the specified builtin.
Definition Builtins.cpp:108
const char * getRequiredFeatures(unsigned ID) const
Definition Builtins.cpp:118
bool isConstWithoutExceptions(unsigned ID) const
Definition Builtins.h:429
void getArgRanges(unsigned ID, llvm::SmallVectorImpl< ArgRange > &Ranges) const
Append the constant argument ranges of this builtin into Ranges.
Definition Builtins.cpp:454
void InitializeTarget(const TargetInfo &Target, const TargetInfo *AuxTarget)
Perform target-specific initialization.
Definition Builtins.cpp:125
bool isConst(unsigned ID) const
Return true if this function has no side effects and doesn't read memory.
Definition Builtins.h:285
TargetFeatures - This class is used to check whether the builtin function has the required target spe...
void setBuiltinID(unsigned ID)
Implements an efficient mapping from strings to IdentifierInfo nodes.
iterator find(StringRef Name) const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
std::vector< std::string > NoBuiltinFuncs
A list of all -fno-builtin-* function names (e.g., memset).
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
Exposes information about the current target.
Definition TargetInfo.h:228
virtual llvm::SmallVector< Builtin::InfosShard > getTargetBuiltins() const =0
Return information about target-specific builtins for the current primary target, and info about whic...
Defines the clang::TargetInfo interface.
bool evaluateRequiredTargetFeatures(llvm::StringRef RequiredFatures, const llvm::StringMap< bool > &TargetFetureMap)
Returns true if the required target features of a builtin function are enabled.
Top level wrappers for InstallAPI frontend operations.
@ MS_LANG
Definition Builtins.h:40
@ CUDA_LANG
Definition Builtins.h:42
@ OMP_LANG
Definition Builtins.h:41
@ CXX_LANG
Definition Builtins.h:38
@ OBJC_LANG
Definition Builtins.h:39
@ OCL_DSE
Definition Builtins.h:46
@ REFLECTION_LANG
Definition Builtins.h:51
@ C23_LANG
Definition Builtins.h:49
@ ALL_OCL_LANGUAGES
Definition Builtins.h:47
@ HLSL_LANG
Definition Builtins.h:48
@ C2Y_LANG
Definition Builtins.h:50
@ OCL_GAS
Definition Builtins.h:44
@ GNU_LANG
Definition Builtins.h:36
@ COR_LANG
Definition Builtins.h:43
@ OCL_PIPE
Definition Builtins.h:45
@ Result
The result type of a method or function.
Definition TypeBase.h:906
A constant argument that must be in the half-open range [Lower, Upper).
Definition Builtins.h:406
llvm::StringTable::Offset Name
Definition Builtins.h:86
llvm::StringTable::Offset Attributes
Definition Builtins.h:88
The info used to represent each builtin.
Definition Builtins.h:82
HeaderDesc Header
Definition Builtins.h:94
LanguageID Langs
Definition Builtins.h:95
struct clang::Builtin::Info::StrOffsets Offsets
std::string getName(const InfosShard &Shard) const
Get the name for the builtin represented by this Info object.
Definition Builtins.cpp:87
A shard of a target's builtins string table and info.
Definition Builtins.h:141
const llvm::StringTable * Strings
Definition Builtins.h:142
llvm::StringLiteral NamePrefix
Definition Builtins.h:145
const char * getName() const
Definition Builtins.cpp:22
enum clang::HeaderDesc::HeaderID ID