[Alignment][NFC] Support compile time constants
[llvm-core.git] / include / llvm / IR / Instruction.def
blob41cdf613ad64d0e74b5db9b330d13e72dc551c25
1 //===-- llvm/Instruction.def - File that describes Instructions -*- 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 // This file contains descriptions of the various LLVM instructions. This is
10 // used as a central place for enumerating the different instructions and
11 // should eventually be the place to put comments about the instructions.
13 //===----------------------------------------------------------------------===//
15 // NOTE: NO INCLUDE GUARD DESIRED!
17 // Provide definitions of macros so that users of this file do not have to
18 // define everything to use it...
20 #ifndef FIRST_TERM_INST
21 #define FIRST_TERM_INST(num)
22 #endif
23 #ifndef HANDLE_TERM_INST
24 #ifndef HANDLE_INST
25 #define HANDLE_TERM_INST(num, opcode, Class)
26 #else
27 #define HANDLE_TERM_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
28 #endif
29 #endif
30 #ifndef LAST_TERM_INST
31 #define LAST_TERM_INST(num)
32 #endif
34 #ifndef FIRST_UNARY_INST
35 #define FIRST_UNARY_INST(num)
36 #endif
37 #ifndef HANDLE_UNARY_INST
38 #ifndef HANDLE_INST
39 #define HANDLE_UNARY_INST(num, opcode, instclass)
40 #else
41 #define HANDLE_UNARY_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
42 #endif
43 #endif
44 #ifndef LAST_UNARY_INST
45 #define LAST_UNARY_INST(num)
46 #endif
48 #ifndef FIRST_BINARY_INST
49 #define FIRST_BINARY_INST(num)
50 #endif
51 #ifndef HANDLE_BINARY_INST
52 #ifndef HANDLE_INST
53 #define HANDLE_BINARY_INST(num, opcode, instclass)
54 #else
55 #define HANDLE_BINARY_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
56 #endif
57 #endif
58 #ifndef LAST_BINARY_INST
59 #define LAST_BINARY_INST(num)
60 #endif
62 #ifndef FIRST_MEMORY_INST
63 #define FIRST_MEMORY_INST(num)
64 #endif
65 #ifndef HANDLE_MEMORY_INST
66 #ifndef HANDLE_INST
67 #define HANDLE_MEMORY_INST(num, opcode, Class)
68 #else
69 #define HANDLE_MEMORY_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
70 #endif
71 #endif
72 #ifndef LAST_MEMORY_INST
73 #define LAST_MEMORY_INST(num)
74 #endif
76 #ifndef FIRST_CAST_INST
77 #define FIRST_CAST_INST(num)
78 #endif
79 #ifndef HANDLE_CAST_INST
80 #ifndef HANDLE_INST
81 #define HANDLE_CAST_INST(num, opcode, Class)
82 #else
83 #define HANDLE_CAST_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
84 #endif
85 #endif
86 #ifndef LAST_CAST_INST
87 #define LAST_CAST_INST(num)
88 #endif
90 #ifndef FIRST_FUNCLETPAD_INST
91 #define FIRST_FUNCLETPAD_INST(num)
92 #endif
93 #ifndef HANDLE_FUNCLETPAD_INST
94 #ifndef HANDLE_INST
95 #define HANDLE_FUNCLETPAD_INST(num, opcode, Class)
96 #else
97 #define HANDLE_FUNCLETPAD_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
98 #endif
99 #endif
100 #ifndef LAST_FUNCLETPAD_INST
101 #define LAST_FUNCLETPAD_INST(num)
102 #endif
104 #ifndef FIRST_OTHER_INST
105 #define FIRST_OTHER_INST(num)
106 #endif
107 #ifndef HANDLE_OTHER_INST
108 #ifndef HANDLE_INST
109 #define HANDLE_OTHER_INST(num, opcode, Class)
110 #else
111 #define HANDLE_OTHER_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
112 #endif
113 #endif
114 #ifndef LAST_OTHER_INST
115 #define LAST_OTHER_INST(num)
116 #endif
118 #ifndef HANDLE_USER_INST
119 #define HANDLE_USER_INST(num, opc, Class) HANDLE_OTHER_INST(num, opc, Class)
120 #endif
122 // Terminator Instructions - These instructions are used to terminate a basic
123 // block of the program. Every basic block must end with one of these
124 // instructions for it to be a well formed basic block.
126 FIRST_TERM_INST ( 1)
127 HANDLE_TERM_INST ( 1, Ret , ReturnInst)
128 HANDLE_TERM_INST ( 2, Br , BranchInst)
129 HANDLE_TERM_INST ( 3, Switch , SwitchInst)
130 HANDLE_TERM_INST ( 4, IndirectBr , IndirectBrInst)
131 HANDLE_TERM_INST ( 5, Invoke , InvokeInst)
132 HANDLE_TERM_INST ( 6, Resume , ResumeInst)
133 HANDLE_TERM_INST ( 7, Unreachable , UnreachableInst)
134 HANDLE_TERM_INST ( 8, CleanupRet , CleanupReturnInst)
135 HANDLE_TERM_INST ( 9, CatchRet , CatchReturnInst)
136 HANDLE_TERM_INST (10, CatchSwitch , CatchSwitchInst)
137 HANDLE_TERM_INST (11, CallBr , CallBrInst) // A call-site terminator
138 LAST_TERM_INST (11)
140 // Standard unary operators...
141 FIRST_UNARY_INST(12)
142 HANDLE_UNARY_INST(12, FNeg , UnaryOperator)
143 LAST_UNARY_INST(12)
145 // Standard binary operators...
146 FIRST_BINARY_INST(13)
147 HANDLE_BINARY_INST(13, Add , BinaryOperator)
148 HANDLE_BINARY_INST(14, FAdd , BinaryOperator)
149 HANDLE_BINARY_INST(15, Sub , BinaryOperator)
150 HANDLE_BINARY_INST(16, FSub , BinaryOperator)
151 HANDLE_BINARY_INST(17, Mul , BinaryOperator)
152 HANDLE_BINARY_INST(18, FMul , BinaryOperator)
153 HANDLE_BINARY_INST(19, UDiv , BinaryOperator)
154 HANDLE_BINARY_INST(20, SDiv , BinaryOperator)
155 HANDLE_BINARY_INST(21, FDiv , BinaryOperator)
156 HANDLE_BINARY_INST(22, URem , BinaryOperator)
157 HANDLE_BINARY_INST(23, SRem , BinaryOperator)
158 HANDLE_BINARY_INST(24, FRem , BinaryOperator)
160 // Logical operators (integer operands)
161 HANDLE_BINARY_INST(25, Shl , BinaryOperator) // Shift left (logical)
162 HANDLE_BINARY_INST(26, LShr , BinaryOperator) // Shift right (logical)
163 HANDLE_BINARY_INST(27, AShr , BinaryOperator) // Shift right (arithmetic)
164 HANDLE_BINARY_INST(28, And , BinaryOperator)
165 HANDLE_BINARY_INST(29, Or , BinaryOperator)
166 HANDLE_BINARY_INST(30, Xor , BinaryOperator)
167 LAST_BINARY_INST(30)
169 // Memory operators...
170 FIRST_MEMORY_INST(31)
171 HANDLE_MEMORY_INST(31, Alloca, AllocaInst) // Stack management
172 HANDLE_MEMORY_INST(32, Load , LoadInst ) // Memory manipulation instrs
173 HANDLE_MEMORY_INST(33, Store , StoreInst )
174 HANDLE_MEMORY_INST(34, GetElementPtr, GetElementPtrInst)
175 HANDLE_MEMORY_INST(35, Fence , FenceInst )
176 HANDLE_MEMORY_INST(36, AtomicCmpXchg , AtomicCmpXchgInst )
177 HANDLE_MEMORY_INST(37, AtomicRMW , AtomicRMWInst )
178 LAST_MEMORY_INST(37)
180 // Cast operators ...
181 // NOTE: The order matters here because CastInst::isEliminableCastPair
182 // NOTE: (see Instructions.cpp) encodes a table based on this ordering.
183 FIRST_CAST_INST(38)
184 HANDLE_CAST_INST(38, Trunc , TruncInst ) // Truncate integers
185 HANDLE_CAST_INST(39, ZExt , ZExtInst ) // Zero extend integers
186 HANDLE_CAST_INST(40, SExt , SExtInst ) // Sign extend integers
187 HANDLE_CAST_INST(41, FPToUI , FPToUIInst ) // floating point -> UInt
188 HANDLE_CAST_INST(42, FPToSI , FPToSIInst ) // floating point -> SInt
189 HANDLE_CAST_INST(43, UIToFP , UIToFPInst ) // UInt -> floating point
190 HANDLE_CAST_INST(44, SIToFP , SIToFPInst ) // SInt -> floating point
191 HANDLE_CAST_INST(45, FPTrunc , FPTruncInst ) // Truncate floating point
192 HANDLE_CAST_INST(46, FPExt , FPExtInst ) // Extend floating point
193 HANDLE_CAST_INST(47, PtrToInt, PtrToIntInst) // Pointer -> Integer
194 HANDLE_CAST_INST(48, IntToPtr, IntToPtrInst) // Integer -> Pointer
195 HANDLE_CAST_INST(49, BitCast , BitCastInst ) // Type cast
196 HANDLE_CAST_INST(50, AddrSpaceCast, AddrSpaceCastInst) // addrspace cast
197 LAST_CAST_INST(50)
199 FIRST_FUNCLETPAD_INST(51)
200 HANDLE_FUNCLETPAD_INST(51, CleanupPad, CleanupPadInst)
201 HANDLE_FUNCLETPAD_INST(52, CatchPad , CatchPadInst)
202 LAST_FUNCLETPAD_INST(52)
204 // Other operators...
205 FIRST_OTHER_INST(53)
206 HANDLE_OTHER_INST(53, ICmp , ICmpInst ) // Integer comparison instruction
207 HANDLE_OTHER_INST(54, FCmp , FCmpInst ) // Floating point comparison instr.
208 HANDLE_OTHER_INST(55, PHI , PHINode ) // PHI node instruction
209 HANDLE_OTHER_INST(56, Call , CallInst ) // Call a function
210 HANDLE_OTHER_INST(57, Select , SelectInst ) // select instruction
211 HANDLE_USER_INST (58, UserOp1, Instruction) // May be used internally in a pass
212 HANDLE_USER_INST (59, UserOp2, Instruction) // Internal to passes only
213 HANDLE_OTHER_INST(60, VAArg , VAArgInst ) // vaarg instruction
214 HANDLE_OTHER_INST(61, ExtractElement, ExtractElementInst)// extract from vector
215 HANDLE_OTHER_INST(62, InsertElement, InsertElementInst) // insert into vector
216 HANDLE_OTHER_INST(63, ShuffleVector, ShuffleVectorInst) // shuffle two vectors.
217 HANDLE_OTHER_INST(64, ExtractValue, ExtractValueInst)// extract from aggregate
218 HANDLE_OTHER_INST(65, InsertValue, InsertValueInst) // insert into aggregate
219 HANDLE_OTHER_INST(66, LandingPad, LandingPadInst) // Landing pad instruction.
220 LAST_OTHER_INST(66)
222 #undef FIRST_TERM_INST
223 #undef HANDLE_TERM_INST
224 #undef LAST_TERM_INST
226 #undef FIRST_UNARY_INST
227 #undef HANDLE_UNARY_INST
228 #undef LAST_UNARY_INST
230 #undef FIRST_BINARY_INST
231 #undef HANDLE_BINARY_INST
232 #undef LAST_BINARY_INST
234 #undef FIRST_MEMORY_INST
235 #undef HANDLE_MEMORY_INST
236 #undef LAST_MEMORY_INST
238 #undef FIRST_CAST_INST
239 #undef HANDLE_CAST_INST
240 #undef LAST_CAST_INST
242 #undef FIRST_FUNCLETPAD_INST
243 #undef HANDLE_FUNCLETPAD_INST
244 #undef LAST_FUNCLETPAD_INST
246 #undef FIRST_OTHER_INST
247 #undef HANDLE_OTHER_INST
248 #undef LAST_OTHER_INST
250 #undef HANDLE_USER_INST
252 #ifdef HANDLE_INST
253 #undef HANDLE_INST
254 #endif