]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/IR/Attributes.td
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / IR / Attributes.td
1 /// Attribute base class.
2 class Attr<string S> {
3   // String representation of this attribute in the IR.
4   string AttrString = S;
5 }
6
7 /// Enum attribute.
8 class EnumAttr<string S> : Attr<S>;
9
10 /// StringBool attribute.
11 class StrBoolAttr<string S> : Attr<S>;
12
13 /// Target-independent enum attributes.
14
15 /// Alignment of parameter (5 bits) stored as log2 of alignment with +1 bias.
16 /// 0 means unaligned (different from align(1)).
17 def Alignment : EnumAttr<"align">;
18
19 /// The result of the function is guaranteed to point to a number of bytes that
20 /// we can determine if we know the value of the function's arguments.
21 def AllocSize : EnumAttr<"allocsize">;
22
23 /// inline=always.
24 def AlwaysInline : EnumAttr<"alwaysinline">;
25
26 /// Function can access memory only using pointers based on its arguments.
27 def ArgMemOnly : EnumAttr<"argmemonly">;
28
29 /// Callee is recognized as a builtin, despite nobuiltin attribute on its
30 /// declaration.
31 def Builtin : EnumAttr<"builtin">;
32
33 /// Pass structure by value.
34 def ByVal : EnumAttr<"byval">;
35
36 /// Marks function as being in a cold path.
37 def Cold : EnumAttr<"cold">;
38
39 /// Can only be moved to control-equivalent blocks.
40 def Convergent : EnumAttr<"convergent">;
41
42 /// Pointer is known to be dereferenceable.
43 def Dereferenceable : EnumAttr<"dereferenceable">;
44
45 /// Pointer is either null or dereferenceable.
46 def DereferenceableOrNull : EnumAttr<"dereferenceable_or_null">;
47
48 /// Function may only access memory that is inaccessible from IR.
49 def InaccessibleMemOnly : EnumAttr<"inaccessiblememonly">;
50
51 /// Function may only access memory that is either inaccessible from the IR,
52 /// or pointed to by its pointer arguments.
53 def InaccessibleMemOrArgMemOnly : EnumAttr<"inaccessiblemem_or_argmemonly">;
54
55 /// Pass structure in an alloca.
56 def InAlloca : EnumAttr<"inalloca">;
57
58 /// Source said inlining was desirable.
59 def InlineHint : EnumAttr<"inlinehint">;
60
61 /// Force argument to be passed in register.
62 def InReg : EnumAttr<"inreg">;
63
64 /// Build jump-instruction tables and replace refs.
65 def JumpTable : EnumAttr<"jumptable">;
66
67 /// Function must be optimized for size first.
68 def MinSize : EnumAttr<"minsize">;
69
70 /// Naked function.
71 def Naked : EnumAttr<"naked">;
72
73 /// Nested function static chain.
74 def Nest : EnumAttr<"nest">;
75
76 /// Considered to not alias after call.
77 def NoAlias : EnumAttr<"noalias">;
78
79 /// Callee isn't recognized as a builtin.
80 def NoBuiltin : EnumAttr<"nobuiltin">;
81
82 /// Function creates no aliases of pointer.
83 def NoCapture : EnumAttr<"nocapture">;
84
85 /// Call cannot be duplicated.
86 def NoDuplicate : EnumAttr<"noduplicate">;
87
88 /// Function does not deallocate memory.
89 def NoFree : EnumAttr<"nofree">;
90
91 /// Disable implicit floating point insts.
92 def NoImplicitFloat : EnumAttr<"noimplicitfloat">;
93
94 /// inline=never.
95 def NoInline : EnumAttr<"noinline">;
96
97 /// Function is called early and/or often, so lazy binding isn't worthwhile.
98 def NonLazyBind : EnumAttr<"nonlazybind">;
99
100 /// Pointer is known to be not null.
101 def NonNull : EnumAttr<"nonnull">;
102
103 /// The function does not recurse.
104 def NoRecurse : EnumAttr<"norecurse">;
105
106 /// Disable redzone.
107 def NoRedZone : EnumAttr<"noredzone">;
108
109 /// Mark the function as not returning.
110 def NoReturn : EnumAttr<"noreturn">;
111
112 /// Function does not synchronize.
113 def NoSync : EnumAttr<"nosync">;
114
115 /// Disable Indirect Branch Tracking.
116 def NoCfCheck : EnumAttr<"nocf_check">;
117
118 /// Function doesn't unwind stack.
119 def NoUnwind : EnumAttr<"nounwind">;
120
121 /// Select optimizations for best fuzzing signal.
122 def OptForFuzzing : EnumAttr<"optforfuzzing">;
123
124 /// opt_size.
125 def OptimizeForSize : EnumAttr<"optsize">;
126
127 /// Function must not be optimized.
128 def OptimizeNone : EnumAttr<"optnone">;
129
130 /// Function does not access memory.
131 def ReadNone : EnumAttr<"readnone">;
132
133 /// Function only reads from memory.
134 def ReadOnly : EnumAttr<"readonly">;
135
136 /// Return value is always equal to this argument.
137 def Returned : EnumAttr<"returned">;
138
139 /// Parameter is required to be a trivial constant.
140 def ImmArg : EnumAttr<"immarg">;
141
142 /// Function can return twice.
143 def ReturnsTwice : EnumAttr<"returns_twice">;
144
145 /// Safe Stack protection.
146 def SafeStack : EnumAttr<"safestack">;
147
148 /// Shadow Call Stack protection.
149 def ShadowCallStack : EnumAttr<"shadowcallstack">;
150
151 /// Sign extended before/after call.
152 def SExt : EnumAttr<"signext">;
153
154 /// Alignment of stack for function (3 bits)  stored as log2 of alignment with
155 /// +1 bias 0 means unaligned (different from alignstack=(1)).
156 def StackAlignment : EnumAttr<"alignstack">;
157
158 /// Function can be speculated.
159 def Speculatable : EnumAttr<"speculatable">;
160
161 /// Stack protection.
162 def StackProtect : EnumAttr<"ssp">;
163
164 /// Stack protection required.
165 def StackProtectReq : EnumAttr<"sspreq">;
166
167 /// Strong Stack protection.
168 def StackProtectStrong : EnumAttr<"sspstrong">;
169
170 /// Function was called in a scope requiring strict floating point semantics.
171 def StrictFP : EnumAttr<"strictfp">;
172
173 /// Hidden pointer to structure to return.
174 def StructRet : EnumAttr<"sret">;
175
176 /// AddressSanitizer is on.
177 def SanitizeAddress : EnumAttr<"sanitize_address">;
178
179 /// ThreadSanitizer is on.
180 def SanitizeThread : EnumAttr<"sanitize_thread">;
181
182 /// MemorySanitizer is on.
183 def SanitizeMemory : EnumAttr<"sanitize_memory">;
184
185 /// HWAddressSanitizer is on.
186 def SanitizeHWAddress : EnumAttr<"sanitize_hwaddress">;
187
188 /// MemTagSanitizer is on.
189 def SanitizeMemTag : EnumAttr<"sanitize_memtag">;
190
191 /// Speculative Load Hardening is enabled.
192 ///
193 /// Note that this uses the default compatibility (always compatible during
194 /// inlining) and a conservative merge strategy where inlining an attributed
195 /// body will add the attribute to the caller. This ensures that code carrying
196 /// this attribute will always be lowered with hardening enabled.
197 def SpeculativeLoadHardening : EnumAttr<"speculative_load_hardening">;
198
199 /// Argument is swift error.
200 def SwiftError : EnumAttr<"swifterror">;
201
202 /// Argument is swift self/context.
203 def SwiftSelf : EnumAttr<"swiftself">;
204
205 /// Function must be in a unwind table.
206 def UWTable : EnumAttr<"uwtable">;
207
208 /// Function always comes back to callsite.
209 def WillReturn : EnumAttr<"willreturn">;
210
211 /// Function only writes to memory.
212 def WriteOnly : EnumAttr<"writeonly">;
213
214 /// Zero extended before/after call.
215 def ZExt : EnumAttr<"zeroext">;
216
217 /// Target-independent string attributes.
218 def LessPreciseFPMAD : StrBoolAttr<"less-precise-fpmad">;
219 def NoInfsFPMath : StrBoolAttr<"no-infs-fp-math">;
220 def NoNansFPMath : StrBoolAttr<"no-nans-fp-math">;
221 def UnsafeFPMath : StrBoolAttr<"unsafe-fp-math">;
222 def NoJumpTables : StrBoolAttr<"no-jump-tables">;
223 def ProfileSampleAccurate : StrBoolAttr<"profile-sample-accurate">;
224
225 class CompatRule<string F> {
226   // The name of the function called to check the attribute of the caller and
227   // callee and decide whether inlining should be allowed. The function's
228   // signature must match "bool(const Function&, const Function &)", where the
229   // first parameter is the reference to the caller and the second parameter is
230   // the reference to the callee. It must return false if the attributes of the
231   // caller and callee are incompatible, and true otherwise.
232   string CompatFunc = F;
233 }
234
235 def : CompatRule<"isEqual<SanitizeAddressAttr>">;
236 def : CompatRule<"isEqual<SanitizeThreadAttr>">;
237 def : CompatRule<"isEqual<SanitizeMemoryAttr>">;
238 def : CompatRule<"isEqual<SanitizeHWAddressAttr>">;
239 def : CompatRule<"isEqual<SanitizeMemTagAttr>">;
240 def : CompatRule<"isEqual<SafeStackAttr>">;
241 def : CompatRule<"isEqual<ShadowCallStackAttr>">;
242
243 class MergeRule<string F> {
244   // The name of the function called to merge the attributes of the caller and
245   // callee. The function's signature must match
246   // "void(Function&, const Function &)", where the first parameter is the
247   // reference to the caller and the second parameter is the reference to the
248   // callee.
249   string MergeFunc = F;
250 }
251
252 def : MergeRule<"setAND<LessPreciseFPMADAttr>">;
253 def : MergeRule<"setAND<NoInfsFPMathAttr>">;
254 def : MergeRule<"setAND<NoNansFPMathAttr>">;
255 def : MergeRule<"setAND<UnsafeFPMathAttr>">;
256 def : MergeRule<"setOR<NoImplicitFloatAttr>">;
257 def : MergeRule<"setOR<NoJumpTablesAttr>">;
258 def : MergeRule<"setOR<ProfileSampleAccurateAttr>">;
259 def : MergeRule<"setOR<SpeculativeLoadHardeningAttr>">;
260 def : MergeRule<"adjustCallerSSPLevel">;
261 def : MergeRule<"adjustCallerStackProbes">;
262 def : MergeRule<"adjustCallerStackProbeSize">;
263 def : MergeRule<"adjustMinLegalVectorWidth">;
264 def : MergeRule<"adjustNullPointerValidAttr">;