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