1//===--- BuiltinsBase.td - common structured used by builtins ---*- C++ -*-===// 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// Attributes 10// ========== 11 12class Attribute<string mangling> { 13 string Mangling = mangling; 14} 15 16class IndexedAttribute<string baseMangling, int I> : Attribute<baseMangling> { 17 int Index = I; 18} 19 20// Standard Attributes 21// ------------------- 22def NoReturn : Attribute<"r">; 23 24// Attributes from the gnu:: namespace 25// ----------------------------------- 26def Const : Attribute<"c">; 27def NoThrow : Attribute<"n">; 28def Pure : Attribute<"U">; 29def ReturnsTwice : Attribute<"j">; 30// FIXME: gcc has nonnull 31 32// builtin-specific attributes 33// --------------------------- 34 35// Signature is meaningless, use custom typechecking. 36def CustomTypeChecking : Attribute<"t">; 37 38// Type is not important to semantic analysis and codegen; recognize as builtin 39// even if type doesn't match signature, and don't warn if we can't be sure the 40// type is right. 41def IgnoreSignature : Attribute<"T">; 42 43// Arguments are not evaluated for their side-effects. 44def UnevaluatedArguments : Attribute<"u">; 45 46// FIXME: This is misused in a lot of the places it is used currently. 47// This function is equivalent to a library function without the __builtin_ 48// prefix. This is relevant for CodeGen; it should not be used if custom CodeGen 49// is required for a builtin. 50def FunctionWithBuiltinPrefix : Attribute<"F">; 51 52def FunctionWithoutBuiltinPrefix : Attribute<"f">; 53 54// const, but only when -fno-math-errno and FP exceptions are ignored. 55def ConstIgnoringErrnoAndExceptions : Attribute<"e">; 56 57// const when FP exceptions are ignored. 58def ConstIgnoringExceptions : Attribute<"g">; 59 60// This function requires a specific header or an explicit declaration. 61def RequireDeclaration : Attribute<"h">; 62 63class PrintfFormat<int I> : IndexedAttribute<"p", I>; 64class VPrintfFormat<int I> : IndexedAttribute<"P", I>; 65class ScanfFormat<int I> : IndexedAttribute<"s", I>; 66class VScanfFormat<int I> : IndexedAttribute<"S", I>; 67 68// Other Attributes 69// ---------------- 70 71// Builtin can be constant evaluated 72def Constexpr : Attribute<"E">; 73// Builtin is immediate and must be constant evaluated. Implies Constexpr, and will only be supported in C++20 mode. 74def Consteval : Attribute<"EG">; 75 76// Builtin kinds 77// ============= 78 79class Builtin { 80 list<string> Spellings; 81 list<Attribute> Attributes = []; 82 string Prototype; 83 string Namespace; 84 // On some platforms, some functions are actually macros. In that case we need 85 // to #undef them. 86 bit RequiresUndef = 0; 87} 88 89class CustomEntry { 90 string Entry; 91} 92 93class AtomicBuiltin : Builtin; 94class TargetBuiltin : Builtin { 95 string Features = ""; 96} 97 98class LibBuiltin<string header, string languages = "ALL_LANGUAGES"> : Builtin { 99 string Header = header; 100 string Languages = languages; 101 bit AddBuiltinPrefixedAlias = 0; 102 bit OnlyBuiltinPrefixedAliasIsConstexpr = 0; 103} 104 105class MSLibBuiltin<string header> : LibBuiltin<header, "ALL_MS_LANGUAGES">; 106class GNULibBuiltin<string header> : LibBuiltin<header, "ALL_GNU_LANGUAGES">; 107class ObjCLibBuiltin<string header> : LibBuiltin<header, "OBJC_LANG">; 108class CxxLibBuiltin<string header> : LibBuiltin<header, "CXX_LANG">; 109 110class LangBuiltin<string languages> : Builtin { 111 string Languages = languages; 112} 113 114class MSLangBuiltin : LangBuiltin<"ALL_MS_LANGUAGES">; 115class CoroLangBuiltin : LangBuiltin<"COR_LANG">; 116class OCLPipeLangBuiltin : LangBuiltin<"OCL_PIPE">; 117class OCL_DSELangBuiltin : LangBuiltin<"OCL_DSE">; 118class OCL_GASLangBuiltin : LangBuiltin<"OCL_GAS">; 119class OCLLangBuiltin : LangBuiltin<"ALL_OCL_LANGUAGES">; 120 121class Template<list<string> substitutions, 122 list<string> affixes, 123 bit as_prefix = 0> { 124 list<string> Substitutions = substitutions; 125 list<string> Affixes = affixes; 126 bit AsPrefix = as_prefix; 127} 128