Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 14 | pmbaty | 1 | //===- Attributes.td - Defines all LLVM attributes ---------*- tablegen -*-===// |
| 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 defines all the LLVM attributes. |
||
| 10 | // |
||
| 11 | //===----------------------------------------------------------------------===// |
||
| 12 | |||
| 13 | /// Attribute property base class. |
||
| 14 | class AttrProperty; |
||
| 15 | |||
| 16 | /// Can be used as function attribute. |
||
| 17 | def FnAttr : AttrProperty; |
||
| 18 | |||
| 19 | /// Can be used as parameter attribute. |
||
| 20 | def ParamAttr : AttrProperty; |
||
| 21 | |||
| 22 | /// Can be used as return attribute. |
||
| 23 | def RetAttr : AttrProperty; |
||
| 24 | |||
| 25 | /// Attribute base class. |
||
| 26 | class Attr<string S, list<AttrProperty> P> { |
||
| 27 | // String representation of this attribute in the IR. |
||
| 28 | string AttrString = S; |
||
| 29 | list<AttrProperty> Properties = P; |
||
| 30 | } |
||
| 31 | |||
| 32 | /// Enum attribute. |
||
| 33 | class EnumAttr<string S, list<AttrProperty> P> : Attr<S, P>; |
||
| 34 | |||
| 35 | /// Int attribute. |
||
| 36 | class IntAttr<string S, list<AttrProperty> P> : Attr<S, P>; |
||
| 37 | |||
| 38 | /// Type attribute. |
||
| 39 | class TypeAttr<string S, list<AttrProperty> P> : Attr<S, P>; |
||
| 40 | |||
| 41 | /// StringBool attribute. |
||
| 42 | class StrBoolAttr<string S> : Attr<S, []>; |
||
| 43 | |||
| 44 | /// Target-independent enum attributes. |
||
| 45 | |||
| 46 | /// Alignment of parameter (5 bits) stored as log2 of alignment with +1 bias. |
||
| 47 | /// 0 means unaligned (different from align(1)). |
||
| 48 | def Alignment : IntAttr<"align", [ParamAttr, RetAttr]>; |
||
| 49 | |||
| 50 | /// Parameter of a function that tells us the alignment of an allocation, as in |
||
| 51 | /// aligned_alloc and aligned ::operator::new. |
||
| 52 | def AllocAlign: EnumAttr<"allocalign", [ParamAttr]>; |
||
| 53 | |||
| 54 | /// Describes behavior of an allocator function in terms of known properties. |
||
| 55 | def AllocKind: IntAttr<"allockind", [FnAttr]>; |
||
| 56 | |||
| 57 | /// Parameter is the pointer to be manipulated by the allocator function. |
||
| 58 | def AllocatedPointer : EnumAttr<"allocptr", [ParamAttr]>; |
||
| 59 | |||
| 60 | /// The result of the function is guaranteed to point to a number of bytes that |
||
| 61 | /// we can determine if we know the value of the function's arguments. |
||
| 62 | def AllocSize : IntAttr<"allocsize", [FnAttr]>; |
||
| 63 | |||
| 64 | /// inline=always. |
||
| 65 | def AlwaysInline : EnumAttr<"alwaysinline", [FnAttr]>; |
||
| 66 | |||
| 67 | /// Callee is recognized as a builtin, despite nobuiltin attribute on its |
||
| 68 | /// declaration. |
||
| 69 | def Builtin : EnumAttr<"builtin", [FnAttr]>; |
||
| 70 | |||
| 71 | /// Pass structure by value. |
||
| 72 | def ByVal : TypeAttr<"byval", [ParamAttr]>; |
||
| 73 | |||
| 74 | /// Mark in-memory ABI type. |
||
| 75 | def ByRef : TypeAttr<"byref", [ParamAttr]>; |
||
| 76 | |||
| 77 | /// Parameter or return value may not contain uninitialized or poison bits. |
||
| 78 | def NoUndef : EnumAttr<"noundef", [ParamAttr, RetAttr]>; |
||
| 79 | |||
| 80 | /// Marks function as being in a cold path. |
||
| 81 | def Cold : EnumAttr<"cold", [FnAttr]>; |
||
| 82 | |||
| 83 | /// Can only be moved to control-equivalent blocks. |
||
| 84 | def Convergent : EnumAttr<"convergent", [FnAttr]>; |
||
| 85 | |||
| 86 | /// Marks function as being in a hot path and frequently called. |
||
| 87 | def Hot: EnumAttr<"hot", [FnAttr]>; |
||
| 88 | |||
| 89 | /// Pointer is known to be dereferenceable. |
||
| 90 | def Dereferenceable : IntAttr<"dereferenceable", [ParamAttr, RetAttr]>; |
||
| 91 | |||
| 92 | /// Pointer is either null or dereferenceable. |
||
| 93 | def DereferenceableOrNull : IntAttr<"dereferenceable_or_null", |
||
| 94 | [ParamAttr, RetAttr]>; |
||
| 95 | |||
| 96 | /// Do not instrument function with sanitizers. |
||
| 97 | def DisableSanitizerInstrumentation: EnumAttr<"disable_sanitizer_instrumentation", [FnAttr]>; |
||
| 98 | |||
| 99 | /// Provide pointer element type to intrinsic. |
||
| 100 | def ElementType : TypeAttr<"elementtype", [ParamAttr]>; |
||
| 101 | |||
| 102 | /// Whether to keep return instructions, or replace with a jump to an external |
||
| 103 | /// symbol. |
||
| 104 | def FnRetThunkExtern : EnumAttr<"fn_ret_thunk_extern", [FnAttr]>; |
||
| 105 | |||
| 106 | /// Pass structure in an alloca. |
||
| 107 | def InAlloca : TypeAttr<"inalloca", [ParamAttr]>; |
||
| 108 | |||
| 109 | /// Source said inlining was desirable. |
||
| 110 | def InlineHint : EnumAttr<"inlinehint", [FnAttr]>; |
||
| 111 | |||
| 112 | /// Force argument to be passed in register. |
||
| 113 | def InReg : EnumAttr<"inreg", [ParamAttr, RetAttr]>; |
||
| 114 | |||
| 115 | /// Build jump-instruction tables and replace refs. |
||
| 116 | def JumpTable : EnumAttr<"jumptable", [FnAttr]>; |
||
| 117 | |||
| 118 | /// Memory effects of the function. |
||
| 119 | def Memory : IntAttr<"memory", [FnAttr]>; |
||
| 120 | |||
| 121 | /// Function must be optimized for size first. |
||
| 122 | def MinSize : EnumAttr<"minsize", [FnAttr]>; |
||
| 123 | |||
| 124 | /// Naked function. |
||
| 125 | def Naked : EnumAttr<"naked", [FnAttr]>; |
||
| 126 | |||
| 127 | /// Nested function static chain. |
||
| 128 | def Nest : EnumAttr<"nest", [ParamAttr]>; |
||
| 129 | |||
| 130 | /// Considered to not alias after call. |
||
| 131 | def NoAlias : EnumAttr<"noalias", [ParamAttr, RetAttr]>; |
||
| 132 | |||
| 133 | /// Callee isn't recognized as a builtin. |
||
| 134 | def NoBuiltin : EnumAttr<"nobuiltin", [FnAttr]>; |
||
| 135 | |||
| 136 | /// Function cannot enter into caller's translation unit. |
||
| 137 | def NoCallback : EnumAttr<"nocallback", [FnAttr]>; |
||
| 138 | |||
| 139 | /// Function creates no aliases of pointer. |
||
| 140 | def NoCapture : EnumAttr<"nocapture", [ParamAttr]>; |
||
| 141 | |||
| 142 | /// Call cannot be duplicated. |
||
| 143 | def NoDuplicate : EnumAttr<"noduplicate", [FnAttr]>; |
||
| 144 | |||
| 145 | /// Function does not deallocate memory. |
||
| 146 | def NoFree : EnumAttr<"nofree", [FnAttr, ParamAttr]>; |
||
| 147 | |||
| 148 | /// Disable implicit floating point insts. |
||
| 149 | def NoImplicitFloat : EnumAttr<"noimplicitfloat", [FnAttr]>; |
||
| 150 | |||
| 151 | /// inline=never. |
||
| 152 | def NoInline : EnumAttr<"noinline", [FnAttr]>; |
||
| 153 | |||
| 154 | /// Function is called early and/or often, so lazy binding isn't worthwhile. |
||
| 155 | def NonLazyBind : EnumAttr<"nonlazybind", [FnAttr]>; |
||
| 156 | |||
| 157 | /// Disable merging for specified functions or call sites. |
||
| 158 | def NoMerge : EnumAttr<"nomerge", [FnAttr]>; |
||
| 159 | |||
| 160 | /// Pointer is known to be not null. |
||
| 161 | def NonNull : EnumAttr<"nonnull", [ParamAttr, RetAttr]>; |
||
| 162 | |||
| 163 | /// The function does not recurse. |
||
| 164 | def NoRecurse : EnumAttr<"norecurse", [FnAttr]>; |
||
| 165 | |||
| 166 | /// Disable redzone. |
||
| 167 | def NoRedZone : EnumAttr<"noredzone", [FnAttr]>; |
||
| 168 | |||
| 169 | /// Mark the function as not returning. |
||
| 170 | def NoReturn : EnumAttr<"noreturn", [FnAttr]>; |
||
| 171 | |||
| 172 | /// Function does not synchronize. |
||
| 173 | def NoSync : EnumAttr<"nosync", [FnAttr]>; |
||
| 174 | |||
| 175 | /// Disable Indirect Branch Tracking. |
||
| 176 | def NoCfCheck : EnumAttr<"nocf_check", [FnAttr]>; |
||
| 177 | |||
| 178 | /// Function should not be instrumented. |
||
| 179 | def NoProfile : EnumAttr<"noprofile", [FnAttr]>; |
||
| 180 | |||
| 181 | /// This function should not be instrumented but it is ok to inline profiled |
||
| 182 | // functions into it. |
||
| 183 | def SkipProfile : EnumAttr<"skipprofile", [FnAttr]>; |
||
| 184 | |||
| 185 | /// Function doesn't unwind stack. |
||
| 186 | def NoUnwind : EnumAttr<"nounwind", [FnAttr]>; |
||
| 187 | |||
| 188 | /// No SanitizeBounds instrumentation. |
||
| 189 | def NoSanitizeBounds : EnumAttr<"nosanitize_bounds", [FnAttr]>; |
||
| 190 | |||
| 191 | /// No SanitizeCoverage instrumentation. |
||
| 192 | def NoSanitizeCoverage : EnumAttr<"nosanitize_coverage", [FnAttr]>; |
||
| 193 | |||
| 194 | /// Null pointer in address space zero is valid. |
||
| 195 | def NullPointerIsValid : EnumAttr<"null_pointer_is_valid", [FnAttr]>; |
||
| 196 | |||
| 197 | /// Select optimizations for best fuzzing signal. |
||
| 198 | def OptForFuzzing : EnumAttr<"optforfuzzing", [FnAttr]>; |
||
| 199 | |||
| 200 | /// opt_size. |
||
| 201 | def OptimizeForSize : EnumAttr<"optsize", [FnAttr]>; |
||
| 202 | |||
| 203 | /// Function must not be optimized. |
||
| 204 | def OptimizeNone : EnumAttr<"optnone", [FnAttr]>; |
||
| 205 | |||
| 206 | /// Similar to byval but without a copy. |
||
| 207 | def Preallocated : TypeAttr<"preallocated", [FnAttr, ParamAttr]>; |
||
| 208 | |||
| 209 | /// Function does not access memory. |
||
| 210 | def ReadNone : EnumAttr<"readnone", [ParamAttr]>; |
||
| 211 | |||
| 212 | /// Function only reads from memory. |
||
| 213 | def ReadOnly : EnumAttr<"readonly", [ParamAttr]>; |
||
| 214 | |||
| 215 | /// Return value is always equal to this argument. |
||
| 216 | def Returned : EnumAttr<"returned", [ParamAttr]>; |
||
| 217 | |||
| 218 | /// Parameter is required to be a trivial constant. |
||
| 219 | def ImmArg : EnumAttr<"immarg", [ParamAttr]>; |
||
| 220 | |||
| 221 | /// Function can return twice. |
||
| 222 | def ReturnsTwice : EnumAttr<"returns_twice", [FnAttr]>; |
||
| 223 | |||
| 224 | /// Safe Stack protection. |
||
| 225 | def SafeStack : EnumAttr<"safestack", [FnAttr]>; |
||
| 226 | |||
| 227 | /// Shadow Call Stack protection. |
||
| 228 | def ShadowCallStack : EnumAttr<"shadowcallstack", [FnAttr]>; |
||
| 229 | |||
| 230 | /// Sign extended before/after call. |
||
| 231 | def SExt : EnumAttr<"signext", [ParamAttr, RetAttr]>; |
||
| 232 | |||
| 233 | /// Alignment of stack for function (3 bits) stored as log2 of alignment with |
||
| 234 | /// +1 bias 0 means unaligned (different from alignstack=(1)). |
||
| 235 | def StackAlignment : IntAttr<"alignstack", [FnAttr, ParamAttr]>; |
||
| 236 | |||
| 237 | /// Function can be speculated. |
||
| 238 | def Speculatable : EnumAttr<"speculatable", [FnAttr]>; |
||
| 239 | |||
| 240 | /// Stack protection. |
||
| 241 | def StackProtect : EnumAttr<"ssp", [FnAttr]>; |
||
| 242 | |||
| 243 | /// Stack protection required. |
||
| 244 | def StackProtectReq : EnumAttr<"sspreq", [FnAttr]>; |
||
| 245 | |||
| 246 | /// Strong Stack protection. |
||
| 247 | def StackProtectStrong : EnumAttr<"sspstrong", [FnAttr]>; |
||
| 248 | |||
| 249 | /// Function was called in a scope requiring strict floating point semantics. |
||
| 250 | def StrictFP : EnumAttr<"strictfp", [FnAttr]>; |
||
| 251 | |||
| 252 | /// Hidden pointer to structure to return. |
||
| 253 | def StructRet : TypeAttr<"sret", [ParamAttr]>; |
||
| 254 | |||
| 255 | /// AddressSanitizer is on. |
||
| 256 | def SanitizeAddress : EnumAttr<"sanitize_address", [FnAttr]>; |
||
| 257 | |||
| 258 | /// ThreadSanitizer is on. |
||
| 259 | def SanitizeThread : EnumAttr<"sanitize_thread", [FnAttr]>; |
||
| 260 | |||
| 261 | /// MemorySanitizer is on. |
||
| 262 | def SanitizeMemory : EnumAttr<"sanitize_memory", [FnAttr]>; |
||
| 263 | |||
| 264 | /// HWAddressSanitizer is on. |
||
| 265 | def SanitizeHWAddress : EnumAttr<"sanitize_hwaddress", [FnAttr]>; |
||
| 266 | |||
| 267 | /// MemTagSanitizer is on. |
||
| 268 | def SanitizeMemTag : EnumAttr<"sanitize_memtag", [FnAttr]>; |
||
| 269 | |||
| 270 | /// Speculative Load Hardening is enabled. |
||
| 271 | /// |
||
| 272 | /// Note that this uses the default compatibility (always compatible during |
||
| 273 | /// inlining) and a conservative merge strategy where inlining an attributed |
||
| 274 | /// body will add the attribute to the caller. This ensures that code carrying |
||
| 275 | /// this attribute will always be lowered with hardening enabled. |
||
| 276 | def SpeculativeLoadHardening : EnumAttr<"speculative_load_hardening", |
||
| 277 | [FnAttr]>; |
||
| 278 | |||
| 279 | /// Argument is swift error. |
||
| 280 | def SwiftError : EnumAttr<"swifterror", [ParamAttr]>; |
||
| 281 | |||
| 282 | /// Argument is swift self/context. |
||
| 283 | def SwiftSelf : EnumAttr<"swiftself", [ParamAttr]>; |
||
| 284 | |||
| 285 | /// Argument is swift async context. |
||
| 286 | def SwiftAsync : EnumAttr<"swiftasync", [ParamAttr]>; |
||
| 287 | |||
| 288 | /// Function must be in a unwind table. |
||
| 289 | def UWTable : IntAttr<"uwtable", [FnAttr]>; |
||
| 290 | |||
| 291 | /// Minimum/Maximum vscale value for function. |
||
| 292 | def VScaleRange : IntAttr<"vscale_range", [FnAttr]>; |
||
| 293 | |||
| 294 | /// Function always comes back to callsite. |
||
| 295 | def WillReturn : EnumAttr<"willreturn", [FnAttr]>; |
||
| 296 | |||
| 297 | /// Function only writes to memory. |
||
| 298 | def WriteOnly : EnumAttr<"writeonly", [ParamAttr]>; |
||
| 299 | |||
| 300 | /// Zero extended before/after call. |
||
| 301 | def ZExt : EnumAttr<"zeroext", [ParamAttr, RetAttr]>; |
||
| 302 | |||
| 303 | /// Function is required to make Forward Progress. |
||
| 304 | def MustProgress : EnumAttr<"mustprogress", [FnAttr]>; |
||
| 305 | |||
| 306 | /// Function is a presplit coroutine. |
||
| 307 | def PresplitCoroutine : EnumAttr<"presplitcoroutine", [FnAttr]>; |
||
| 308 | |||
| 309 | /// Target-independent string attributes. |
||
| 310 | def LessPreciseFPMAD : StrBoolAttr<"less-precise-fpmad">; |
||
| 311 | def NoInfsFPMath : StrBoolAttr<"no-infs-fp-math">; |
||
| 312 | def NoNansFPMath : StrBoolAttr<"no-nans-fp-math">; |
||
| 313 | def ApproxFuncFPMath : StrBoolAttr<"approx-func-fp-math">; |
||
| 314 | def NoSignedZerosFPMath : StrBoolAttr<"no-signed-zeros-fp-math">; |
||
| 315 | def UnsafeFPMath : StrBoolAttr<"unsafe-fp-math">; |
||
| 316 | def NoJumpTables : StrBoolAttr<"no-jump-tables">; |
||
| 317 | def NoInlineLineTables : StrBoolAttr<"no-inline-line-tables">; |
||
| 318 | def ProfileSampleAccurate : StrBoolAttr<"profile-sample-accurate">; |
||
| 319 | def UseSampleProfile : StrBoolAttr<"use-sample-profile">; |
||
| 320 | |||
| 321 | class CompatRule<string F> { |
||
| 322 | // The name of the function called to check the attribute of the caller and |
||
| 323 | // callee and decide whether inlining should be allowed. The function's |
||
| 324 | // signature must match "bool(const Function&, const Function &)", where the |
||
| 325 | // first parameter is the reference to the caller and the second parameter is |
||
| 326 | // the reference to the callee. It must return false if the attributes of the |
||
| 327 | // caller and callee are incompatible, and true otherwise. |
||
| 328 | string CompatFunc = F; |
||
| 329 | } |
||
| 330 | |||
| 331 | def : CompatRule<"isEqual<SanitizeAddressAttr>">; |
||
| 332 | def : CompatRule<"isEqual<SanitizeThreadAttr>">; |
||
| 333 | def : CompatRule<"isEqual<SanitizeMemoryAttr>">; |
||
| 334 | def : CompatRule<"isEqual<SanitizeHWAddressAttr>">; |
||
| 335 | def : CompatRule<"isEqual<SanitizeMemTagAttr>">; |
||
| 336 | def : CompatRule<"isEqual<SafeStackAttr>">; |
||
| 337 | def : CompatRule<"isEqual<ShadowCallStackAttr>">; |
||
| 338 | def : CompatRule<"isEqual<UseSampleProfileAttr>">; |
||
| 339 | def : CompatRule<"isEqual<NoProfileAttr>">; |
||
| 340 | |||
| 341 | class MergeRule<string F> { |
||
| 342 | // The name of the function called to merge the attributes of the caller and |
||
| 343 | // callee. The function's signature must match |
||
| 344 | // "void(Function&, const Function &)", where the first parameter is the |
||
| 345 | // reference to the caller and the second parameter is the reference to the |
||
| 346 | // callee. |
||
| 347 | string MergeFunc = F; |
||
| 348 | } |
||
| 349 | |||
| 350 | def : MergeRule<"setAND<LessPreciseFPMADAttr>">; |
||
| 351 | def : MergeRule<"setAND<NoInfsFPMathAttr>">; |
||
| 352 | def : MergeRule<"setAND<NoNansFPMathAttr>">; |
||
| 353 | def : MergeRule<"setAND<ApproxFuncFPMathAttr>">; |
||
| 354 | def : MergeRule<"setAND<NoSignedZerosFPMathAttr>">; |
||
| 355 | def : MergeRule<"setAND<UnsafeFPMathAttr>">; |
||
| 356 | def : MergeRule<"setOR<NoImplicitFloatAttr>">; |
||
| 357 | def : MergeRule<"setOR<NoJumpTablesAttr>">; |
||
| 358 | def : MergeRule<"setOR<ProfileSampleAccurateAttr>">; |
||
| 359 | def : MergeRule<"setOR<SpeculativeLoadHardeningAttr>">; |
||
| 360 | def : MergeRule<"adjustCallerSSPLevel">; |
||
| 361 | def : MergeRule<"adjustCallerStackProbes">; |
||
| 362 | def : MergeRule<"adjustCallerStackProbeSize">; |
||
| 363 | def : MergeRule<"adjustMinLegalVectorWidth">; |
||
| 364 | def : MergeRule<"adjustNullPointerValidAttr">; |
||
| 365 | def : MergeRule<"setAND<MustProgressAttr>">; |