Attributes.td revision 309124
1292915Sdim/// Attribute base class. 2292915Sdimclass Attr<string S> { 3292915Sdim // String representation of this attribute in the IR. 4292915Sdim string AttrString = S; 5292915Sdim} 6292915Sdim 7292915Sdim/// Enum attribute. 8292915Sdimclass EnumAttr<string S> : Attr<S>; 9292915Sdim 10292915Sdim/// StringBool attribute. 11292915Sdimclass StrBoolAttr<string S> : Attr<S>; 12292915Sdim 13292915Sdim/// Target-independent enum attributes. 14292915Sdim 15292915Sdim/// Alignment of parameter (5 bits) stored as log2 of alignment with +1 bias. 16292915Sdim/// 0 means unaligned (different from align(1)). 17292915Sdimdef Alignment : EnumAttr<"align">; 18292915Sdim 19309124Sdim/// The result of the function is guaranteed to point to a number of bytes that 20309124Sdim/// we can determine if we know the value of the function's arguments. 21309124Sdimdef AllocSize : EnumAttr<"allocsize">; 22309124Sdim 23292915Sdim/// inline=always. 24292915Sdimdef AlwaysInline : EnumAttr<"alwaysinline">; 25292915Sdim 26292915Sdim/// Function can access memory only using pointers based on its arguments. 27292915Sdimdef ArgMemOnly : EnumAttr<"argmemonly">; 28292915Sdim 29292915Sdim/// Callee is recognized as a builtin, despite nobuiltin attribute on its 30292915Sdim/// declaration. 31292915Sdimdef Builtin : EnumAttr<"builtin">; 32292915Sdim 33292915Sdim/// Pass structure by value. 34292915Sdimdef ByVal : EnumAttr<"byval">; 35292915Sdim 36292915Sdim/// Marks function as being in a cold path. 37292915Sdimdef Cold : EnumAttr<"cold">; 38292915Sdim 39292915Sdim/// Can only be moved to control-equivalent blocks. 40292915Sdimdef Convergent : EnumAttr<"convergent">; 41292915Sdim 42292915Sdim/// Pointer is known to be dereferenceable. 43292915Sdimdef Dereferenceable : EnumAttr<"dereferenceable">; 44292915Sdim 45292915Sdim/// Pointer is either null or dereferenceable. 46292915Sdimdef DereferenceableOrNull : EnumAttr<"dereferenceable_or_null">; 47292915Sdim 48292915Sdim/// Function may only access memory that is inaccessible from IR. 49292915Sdimdef InaccessibleMemOnly : EnumAttr<"inaccessiblememonly">; 50292915Sdim 51292915Sdim/// Function may only access memory that is either inaccessible from the IR, 52292915Sdim/// or pointed to by its pointer arguments. 53292915Sdimdef InaccessibleMemOrArgMemOnly : EnumAttr<"inaccessiblemem_or_argmemonly">; 54292915Sdim 55292915Sdim/// Pass structure in an alloca. 56292915Sdimdef InAlloca : EnumAttr<"inalloca">; 57292915Sdim 58292915Sdim/// Source said inlining was desirable. 59292915Sdimdef InlineHint : EnumAttr<"inlinehint">; 60292915Sdim 61292915Sdim/// Force argument to be passed in register. 62292915Sdimdef InReg : EnumAttr<"inreg">; 63292915Sdim 64292915Sdim/// Build jump-instruction tables and replace refs. 65292915Sdimdef JumpTable : EnumAttr<"jumptable">; 66292915Sdim 67292915Sdim/// Function must be optimized for size first. 68292915Sdimdef MinSize : EnumAttr<"minsize">; 69292915Sdim 70292915Sdim/// Naked function. 71292915Sdimdef Naked : EnumAttr<"naked">; 72292915Sdim 73292915Sdim/// Nested function static chain. 74292915Sdimdef Nest : EnumAttr<"nest">; 75292915Sdim 76292915Sdim/// Considered to not alias after call. 77292915Sdimdef NoAlias : EnumAttr<"noalias">; 78292915Sdim 79292915Sdim/// Callee isn't recognized as a builtin. 80292915Sdimdef NoBuiltin : EnumAttr<"nobuiltin">; 81292915Sdim 82292915Sdim/// Function creates no aliases of pointer. 83292915Sdimdef NoCapture : EnumAttr<"nocapture">; 84292915Sdim 85292915Sdim/// Call cannot be duplicated. 86292915Sdimdef NoDuplicate : EnumAttr<"noduplicate">; 87292915Sdim 88292915Sdim/// Disable implicit floating point insts. 89292915Sdimdef NoImplicitFloat : EnumAttr<"noimplicitfloat">; 90292915Sdim 91292915Sdim/// inline=never. 92292915Sdimdef NoInline : EnumAttr<"noinline">; 93292915Sdim 94292915Sdim/// Function is called early and/or often, so lazy binding isn't worthwhile. 95292915Sdimdef NonLazyBind : EnumAttr<"nonlazybind">; 96292915Sdim 97292915Sdim/// Pointer is known to be not null. 98292915Sdimdef NonNull : EnumAttr<"nonnull">; 99292915Sdim 100292915Sdim/// The function does not recurse. 101292915Sdimdef NoRecurse : EnumAttr<"norecurse">; 102292915Sdim 103292915Sdim/// Disable redzone. 104292915Sdimdef NoRedZone : EnumAttr<"noredzone">; 105292915Sdim 106292915Sdim/// Mark the function as not returning. 107292915Sdimdef NoReturn : EnumAttr<"noreturn">; 108292915Sdim 109292915Sdim/// Function doesn't unwind stack. 110292915Sdimdef NoUnwind : EnumAttr<"nounwind">; 111292915Sdim 112292915Sdim/// opt_size. 113292915Sdimdef OptimizeForSize : EnumAttr<"optsize">; 114292915Sdim 115292915Sdim/// Function must not be optimized. 116292915Sdimdef OptimizeNone : EnumAttr<"optnone">; 117292915Sdim 118292915Sdim/// Function does not access memory. 119292915Sdimdef ReadNone : EnumAttr<"readnone">; 120292915Sdim 121292915Sdim/// Function only reads from memory. 122292915Sdimdef ReadOnly : EnumAttr<"readonly">; 123292915Sdim 124292915Sdim/// Return value is always equal to this argument. 125292915Sdimdef Returned : EnumAttr<"returned">; 126292915Sdim 127292915Sdim/// Function can return twice. 128292915Sdimdef ReturnsTwice : EnumAttr<"returns_twice">; 129292915Sdim 130292915Sdim/// Safe Stack protection. 131292915Sdimdef SafeStack : EnumAttr<"safestack">; 132292915Sdim 133292915Sdim/// Sign extended before/after call. 134292915Sdimdef SExt : EnumAttr<"signext">; 135292915Sdim 136292915Sdim/// Alignment of stack for function (3 bits) stored as log2 of alignment with 137292915Sdim/// +1 bias 0 means unaligned (different from alignstack=(1)). 138292915Sdimdef StackAlignment : EnumAttr<"alignstack">; 139292915Sdim 140292915Sdim/// Stack protection. 141292915Sdimdef StackProtect : EnumAttr<"ssp">; 142292915Sdim 143292915Sdim/// Stack protection required. 144292915Sdimdef StackProtectReq : EnumAttr<"sspreq">; 145292915Sdim 146292915Sdim/// Strong Stack protection. 147292915Sdimdef StackProtectStrong : EnumAttr<"sspstrong">; 148292915Sdim 149292915Sdim/// Hidden pointer to structure to return. 150292915Sdimdef StructRet : EnumAttr<"sret">; 151292915Sdim 152292915Sdim/// AddressSanitizer is on. 153292915Sdimdef SanitizeAddress : EnumAttr<"sanitize_address">; 154292915Sdim 155292915Sdim/// ThreadSanitizer is on. 156292915Sdimdef SanitizeThread : EnumAttr<"sanitize_thread">; 157292915Sdim 158292915Sdim/// MemorySanitizer is on. 159292915Sdimdef SanitizeMemory : EnumAttr<"sanitize_memory">; 160292915Sdim 161309124Sdim/// Argument is swift error. 162309124Sdimdef SwiftError : EnumAttr<"swifterror">; 163309124Sdim 164309124Sdim/// Argument is swift self/context. 165309124Sdimdef SwiftSelf : EnumAttr<"swiftself">; 166309124Sdim 167292915Sdim/// Function must be in a unwind table. 168292915Sdimdef UWTable : EnumAttr<"uwtable">; 169292915Sdim 170309124Sdim/// Function only writes to memory. 171309124Sdimdef WriteOnly : EnumAttr<"writeonly">; 172309124Sdim 173292915Sdim/// Zero extended before/after call. 174292915Sdimdef ZExt : EnumAttr<"zeroext">; 175292915Sdim 176292915Sdim/// Target-independent string attributes. 177292915Sdimdef LessPreciseFPMAD : StrBoolAttr<"less-precise-fpmad">; 178292915Sdimdef NoInfsFPMath : StrBoolAttr<"no-infs-fp-math">; 179292915Sdimdef NoNansFPMath : StrBoolAttr<"no-nans-fp-math">; 180292915Sdimdef UnsafeFPMath : StrBoolAttr<"unsafe-fp-math">; 181309124Sdimdef NoJumpTables : StrBoolAttr<"no-jump-tables">; 182292915Sdim 183292915Sdimclass CompatRule<string F> { 184292915Sdim // The name of the function called to check the attribute of the caller and 185292915Sdim // callee and decide whether inlining should be allowed. The function's 186292915Sdim // signature must match "bool(const Function&, const Function &)", where the 187292915Sdim // first parameter is the reference to the caller and the second parameter is 188292915Sdim // the reference to the callee. It must return false if the attributes of the 189292915Sdim // caller and callee are incompatible, and true otherwise. 190292915Sdim string CompatFunc = F; 191292915Sdim} 192292915Sdim 193292915Sdimdef : CompatRule<"isEqual<SanitizeAddressAttr>">; 194292915Sdimdef : CompatRule<"isEqual<SanitizeThreadAttr>">; 195292915Sdimdef : CompatRule<"isEqual<SanitizeMemoryAttr>">; 196309124Sdimdef : CompatRule<"isEqual<SafeStackAttr>">; 197292915Sdim 198292915Sdimclass MergeRule<string F> { 199292915Sdim // The name of the function called to merge the attributes of the caller and 200292915Sdim // callee. The function's signature must match 201292915Sdim // "void(Function&, const Function &)", where the first parameter is the 202292915Sdim // reference to the caller and the second parameter is the reference to the 203292915Sdim // callee. 204292915Sdim string MergeFunc = F; 205292915Sdim} 206292915Sdim 207294024Sdimdef : MergeRule<"setAND<LessPreciseFPMADAttr>">; 208294024Sdimdef : MergeRule<"setAND<NoInfsFPMathAttr>">; 209294024Sdimdef : MergeRule<"setAND<NoNansFPMathAttr>">; 210294024Sdimdef : MergeRule<"setAND<UnsafeFPMathAttr>">; 211294024Sdimdef : MergeRule<"setOR<NoImplicitFloatAttr>">; 212309124Sdimdef : MergeRule<"setOR<NoJumpTablesAttr>">; 213292915Sdimdef : MergeRule<"adjustCallerSSPLevel">; 214