Attributes.td revision 341825
1109998Smarkm/// Attribute base class. 2160814Ssimonclass Attr<string S> { 3160814Ssimon // String representation of this attribute in the IR. 4160814Ssimon string AttrString = S; 5109998Smarkm} 6194206Ssimon 7109998Smarkm/// Enum attribute. 8109998Smarkmclass EnumAttr<string S> : Attr<S>; 9109998Smarkm 10109998Smarkm/// StringBool attribute. 11109998Smarkmclass StrBoolAttr<string S> : Attr<S>; 12109998Smarkm 13296341Sdelphij/// Target-independent enum attributes. 14109998Smarkm 15109998Smarkm/// Alignment of parameter (5 bits) stored as log2 of alignment with +1 bias. 16109998Smarkm/// 0 means unaligned (different from align(1)). 17109998Smarkmdef Alignment : EnumAttr<"align">; 18109998Smarkm 19109998Smarkm/// The result of the function is guaranteed to point to a number of bytes that 20109998Smarkm/// we can determine if we know the value of the function's arguments. 21109998Smarkmdef AllocSize : EnumAttr<"allocsize">; 22109998Smarkm 23109998Smarkm/// inline=always. 24109998Smarkmdef AlwaysInline : EnumAttr<"alwaysinline">; 25109998Smarkm 26109998Smarkm/// Function can access memory only using pointers based on its arguments. 27109998Smarkmdef ArgMemOnly : EnumAttr<"argmemonly">; 28109998Smarkm 29109998Smarkm/// Callee is recognized as a builtin, despite nobuiltin attribute on its 30109998Smarkm/// declaration. 31109998Smarkmdef Builtin : EnumAttr<"builtin">; 32109998Smarkm 33109998Smarkm/// Pass structure by value. 34109998Smarkmdef ByVal : EnumAttr<"byval">; 35109998Smarkm 36109998Smarkm/// Marks function as being in a cold path. 37109998Smarkmdef Cold : EnumAttr<"cold">; 38109998Smarkm 39109998Smarkm/// Can only be moved to control-equivalent blocks. 40109998Smarkmdef Convergent : EnumAttr<"convergent">; 41109998Smarkm 42109998Smarkm/// Pointer is known to be dereferenceable. 43109998Smarkmdef Dereferenceable : EnumAttr<"dereferenceable">; 44109998Smarkm 45109998Smarkm/// Pointer is either null or dereferenceable. 46109998Smarkmdef DereferenceableOrNull : EnumAttr<"dereferenceable_or_null">; 47109998Smarkm 48109998Smarkm/// Function may only access memory that is inaccessible from IR. 49109998Smarkmdef InaccessibleMemOnly : EnumAttr<"inaccessiblememonly">; 50109998Smarkm 51109998Smarkm/// Function may only access memory that is either inaccessible from the IR, 52109998Smarkm/// or pointed to by its pointer arguments. 53109998Smarkmdef InaccessibleMemOrArgMemOnly : EnumAttr<"inaccessiblemem_or_argmemonly">; 54109998Smarkm 55109998Smarkm/// Pass structure in an alloca. 56109998Smarkmdef InAlloca : EnumAttr<"inalloca">; 57109998Smarkm 58160814Ssimon/// Source said inlining was desirable. 59160814Ssimondef InlineHint : EnumAttr<"inlinehint">; 60160814Ssimon 61160814Ssimon/// Force argument to be passed in register. 62160814Ssimondef InReg : EnumAttr<"inreg">; 63109998Smarkm 64160814Ssimon/// Build jump-instruction tables and replace refs. 65160814Ssimondef JumpTable : EnumAttr<"jumptable">; 66109998Smarkm 67109998Smarkm/// Function must be optimized for size first. 68109998Smarkmdef MinSize : EnumAttr<"minsize">; 69109998Smarkm 70160814Ssimon/// Naked function. 71160814Ssimondef Naked : EnumAttr<"naked">; 72160814Ssimon 73160814Ssimon/// Nested function static chain. 74160814Ssimondef Nest : EnumAttr<"nest">; 75160814Ssimon 76109998Smarkm/// Considered to not alias after call. 77160814Ssimondef NoAlias : EnumAttr<"noalias">; 78160814Ssimon 79296341Sdelphij/// Callee isn't recognized as a builtin. 80296341Sdelphijdef NoBuiltin : EnumAttr<"nobuiltin">; 81296341Sdelphij 82296341Sdelphij/// Function creates no aliases of pointer. 83296341Sdelphijdef NoCapture : EnumAttr<"nocapture">; 84296341Sdelphij 85296341Sdelphij/// Call cannot be duplicated. 86296341Sdelphijdef NoDuplicate : EnumAttr<"noduplicate">; 87296341Sdelphij 88296341Sdelphij/// Disable implicit floating point insts. 89160814Ssimondef NoImplicitFloat : EnumAttr<"noimplicitfloat">; 90296341Sdelphij 91160814Ssimon/// inline=never. 92160814Ssimondef NoInline : EnumAttr<"noinline">; 93160814Ssimon 94160814Ssimon/// Function is called early and/or often, so lazy binding isn't worthwhile. 95109998Smarkmdef NonLazyBind : EnumAttr<"nonlazybind">; 96160814Ssimon 97296341Sdelphij/// Pointer is known to be not null. 98296341Sdelphijdef NonNull : EnumAttr<"nonnull">; 99160814Ssimon 100296341Sdelphij/// The function does not recurse. 101296341Sdelphijdef NoRecurse : EnumAttr<"norecurse">; 102160814Ssimon 103296341Sdelphij/// Disable redzone. 104296341Sdelphijdef NoRedZone : EnumAttr<"noredzone">; 105296341Sdelphij 106296341Sdelphij/// Mark the function as not returning. 107296341Sdelphijdef NoReturn : EnumAttr<"noreturn">; 108296341Sdelphij 109296341Sdelphij/// Disable Indirect Branch Tracking. 110296341Sdelphijdef NoCfCheck : EnumAttr<"nocf_check">; 111296341Sdelphij 112296341Sdelphij/// Function doesn't unwind stack. 113296341Sdelphijdef NoUnwind : EnumAttr<"nounwind">; 114296341Sdelphij 115296341Sdelphij/// Select optimizations for best fuzzing signal. 116296341Sdelphijdef OptForFuzzing : EnumAttr<"optforfuzzing">; 117160814Ssimon 118160814Ssimon/// opt_size. 119296341Sdelphijdef OptimizeForSize : EnumAttr<"optsize">; 120296341Sdelphij 121160814Ssimon/// Function must not be optimized. 122296341Sdelphijdef OptimizeNone : EnumAttr<"optnone">; 123160814Ssimon 124296341Sdelphij/// Function does not access memory. 125160814Ssimondef ReadNone : EnumAttr<"readnone">; 126296341Sdelphij 127296341Sdelphij/// Function only reads from memory. 128160814Ssimondef ReadOnly : EnumAttr<"readonly">; 129160814Ssimon 130296341Sdelphij/// Return value is always equal to this argument. 131296341Sdelphijdef Returned : EnumAttr<"returned">; 132296341Sdelphij 133160814Ssimon/// Function can return twice. 134296341Sdelphijdef ReturnsTwice : EnumAttr<"returns_twice">; 135296341Sdelphij 136160814Ssimon/// Safe Stack protection. 137296341Sdelphijdef SafeStack : EnumAttr<"safestack">; 138296341Sdelphij 139296341Sdelphij/// Shadow Call Stack protection. 140160814Ssimondef ShadowCallStack : EnumAttr<"shadowcallstack">; 141296341Sdelphij 142296341Sdelphij/// Sign extended before/after call. 143160814Ssimondef SExt : EnumAttr<"signext">; 144296341Sdelphij 145296341Sdelphij/// Alignment of stack for function (3 bits) stored as log2 of alignment with 146296341Sdelphij/// +1 bias 0 means unaligned (different from alignstack=(1)). 147296341Sdelphijdef StackAlignment : EnumAttr<"alignstack">; 148296341Sdelphij 149296341Sdelphij/// Function can be speculated. 150160814Ssimondef Speculatable : EnumAttr<"speculatable">; 151160814Ssimon 152296341Sdelphij/// Stack protection. 153296341Sdelphijdef StackProtect : EnumAttr<"ssp">; 154296341Sdelphij 155160814Ssimon/// Stack protection required. 156296341Sdelphijdef StackProtectReq : EnumAttr<"sspreq">; 157296341Sdelphij 158160814Ssimon/// Strong Stack protection. 159296341Sdelphijdef StackProtectStrong : EnumAttr<"sspstrong">; 160296341Sdelphij 161296341Sdelphij/// Function was called in a scope requiring strict floating point semantics. 162160814Ssimondef StrictFP : EnumAttr<"strictfp">; 163296341Sdelphij 164296341Sdelphij/// Hidden pointer to structure to return. 165160814Ssimondef StructRet : EnumAttr<"sret">; 166296341Sdelphij 167296341Sdelphij/// AddressSanitizer is on. 168296341Sdelphijdef SanitizeAddress : EnumAttr<"sanitize_address">; 169296341Sdelphij 170296341Sdelphij/// ThreadSanitizer is on. 171296341Sdelphijdef SanitizeThread : EnumAttr<"sanitize_thread">; 172296341Sdelphij 173296341Sdelphij/// MemorySanitizer is on. 174296341Sdelphijdef SanitizeMemory : EnumAttr<"sanitize_memory">; 175160814Ssimon 176296341Sdelphij/// HWAddressSanitizer is on. 177296341Sdelphijdef SanitizeHWAddress : EnumAttr<"sanitize_hwaddress">; 178109998Smarkm 179109998Smarkm/// Argument is swift error. 180109998Smarkmdef SwiftError : EnumAttr<"swifterror">; 181160814Ssimon 182160814Ssimon/// Argument is swift self/context. 183160814Ssimondef SwiftSelf : EnumAttr<"swiftself">; 184109998Smarkm 185160814Ssimon/// Function must be in a unwind table. 186296341Sdelphijdef UWTable : EnumAttr<"uwtable">; 187296341Sdelphij 188296341Sdelphij/// Function only writes to memory. 189296341Sdelphijdef WriteOnly : EnumAttr<"writeonly">; 190296341Sdelphij 191296341Sdelphij/// Zero extended before/after call. 192296341Sdelphijdef ZExt : EnumAttr<"zeroext">; 193109998Smarkm 194296341Sdelphij/// Target-independent string attributes. 195296341Sdelphijdef LessPreciseFPMAD : StrBoolAttr<"less-precise-fpmad">; 196296341Sdelphijdef NoInfsFPMath : StrBoolAttr<"no-infs-fp-math">; 197296341Sdelphijdef NoNansFPMath : StrBoolAttr<"no-nans-fp-math">; 198296341Sdelphijdef UnsafeFPMath : StrBoolAttr<"unsafe-fp-math">; 199296341Sdelphijdef NoJumpTables : StrBoolAttr<"no-jump-tables">; 200296341Sdelphijdef ProfileSampleAccurate : StrBoolAttr<"profile-sample-accurate">; 201296341Sdelphij 202296341Sdelphijclass CompatRule<string F> { 203296341Sdelphij // The name of the function called to check the attribute of the caller and 204109998Smarkm // callee and decide whether inlining should be allowed. The function's 205296341Sdelphij // signature must match "bool(const Function&, const Function &)", where the 206296341Sdelphij // first parameter is the reference to the caller and the second parameter is 207296341Sdelphij // the reference to the callee. It must return false if the attributes of the 208296341Sdelphij // caller and callee are incompatible, and true otherwise. 209296341Sdelphij string CompatFunc = F; 210296341Sdelphij} 211296341Sdelphij 212296341Sdelphijdef : CompatRule<"isEqual<SanitizeAddressAttr>">; 213238405Sjkimdef : CompatRule<"isEqual<SanitizeThreadAttr>">; 214296341Sdelphijdef : CompatRule<"isEqual<SanitizeMemoryAttr>">; 215296341Sdelphijdef : CompatRule<"isEqual<SanitizeHWAddressAttr>">; 216296341Sdelphijdef : CompatRule<"isEqual<SafeStackAttr>">; 217109998Smarkmdef : CompatRule<"isEqual<ShadowCallStackAttr>">; 218296341Sdelphij 219296341Sdelphijclass MergeRule<string F> { 220296341Sdelphij // The name of the function called to merge the attributes of the caller and 221296341Sdelphij // callee. The function's signature must match 222160814Ssimon // "void(Function&, const Function &)", where the first parameter is the 223296341Sdelphij // reference to the caller and the second parameter is the reference to the 224296341Sdelphij // callee. 225296341Sdelphij string MergeFunc = F; 226296341Sdelphij} 227296341Sdelphij 228296341Sdelphijdef : MergeRule<"setAND<LessPreciseFPMADAttr>">; 229296341Sdelphijdef : MergeRule<"setAND<NoInfsFPMathAttr>">; 230296341Sdelphijdef : MergeRule<"setAND<NoNansFPMathAttr>">; 231296341Sdelphijdef : MergeRule<"setAND<UnsafeFPMathAttr>">; 232296341Sdelphijdef : MergeRule<"setOR<NoImplicitFloatAttr>">; 233296341Sdelphijdef : MergeRule<"setOR<NoJumpTablesAttr>">; 234296341Sdelphijdef : MergeRule<"setOR<ProfileSampleAccurateAttr>">; 235296341Sdelphijdef : MergeRule<"adjustCallerSSPLevel">; 236296341Sdelphijdef : MergeRule<"adjustCallerStackProbes">; 237296341Sdelphijdef : MergeRule<"adjustCallerStackProbeSize">; 238160814Ssimondef : MergeRule<"adjustMinLegalVectorWidth">; 239296341Sdelphijdef : MergeRule<"adjustNullPointerValidAttr">; 240160814Ssimon