1 //===-- llvm/Instruction.def - File that describes Instructions -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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.
14 //===----------------------------------------------------------------------===//
16 // NOTE: NO INCLUDE GUARD DESIRED!
18 // Provide definitions of macros so that users of this file do not have to
19 // define everything to use it...
21 #ifndef FIRST_TERM_INST
22 #define FIRST_TERM_INST(num)
24 #ifndef HANDLE_TERM_INST
26 #define HANDLE_TERM_INST(num, opcode, Class)
28 #define HANDLE_TERM_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
31 #ifndef LAST_TERM_INST
32 #define LAST_TERM_INST(num)
35 #ifndef FIRST_BINARY_INST
36 #define FIRST_BINARY_INST(num)
38 #ifndef HANDLE_BINARY_INST
40 #define HANDLE_BINARY_INST(num, opcode, instclass)
42 #define HANDLE_BINARY_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
45 #ifndef LAST_BINARY_INST
46 #define LAST_BINARY_INST(num)
49 #ifndef FIRST_MEMORY_INST
50 #define FIRST_MEMORY_INST(num)
52 #ifndef HANDLE_MEMORY_INST
54 #define HANDLE_MEMORY_INST(num, opcode, Class)
56 #define HANDLE_MEMORY_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
59 #ifndef LAST_MEMORY_INST
60 #define LAST_MEMORY_INST(num)
63 #ifndef FIRST_CAST_INST
64 #define FIRST_CAST_INST(num)
66 #ifndef HANDLE_CAST_INST
68 #define HANDLE_CAST_INST(num, opcode, Class)
70 #define HANDLE_CAST_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
73 #ifndef LAST_CAST_INST
74 #define LAST_CAST_INST(num)
77 #ifndef FIRST_FUNCLETPAD_INST
78 #define FIRST_FUNCLETPAD_INST(num)
80 #ifndef HANDLE_FUNCLETPAD_INST
82 #define HANDLE_FUNCLETPAD_INST(num, opcode, Class)
84 #define HANDLE_FUNCLETPAD_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
87 #ifndef LAST_FUNCLETPAD_INST
88 #define LAST_FUNCLETPAD_INST(num)
91 #ifndef FIRST_OTHER_INST
92 #define FIRST_OTHER_INST(num)
94 #ifndef HANDLE_OTHER_INST
96 #define HANDLE_OTHER_INST(num, opcode, Class)
98 #define HANDLE_OTHER_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
101 #ifndef LAST_OTHER_INST
102 #define LAST_OTHER_INST(num)
105 // Terminator Instructions - These instructions are used to terminate a basic
106 // block of the program. Every basic block must end with one of these
107 // instructions for it to be a well formed basic block.
110 HANDLE_TERM_INST ( 1, Ret , ReturnInst)
111 HANDLE_TERM_INST ( 2, Br , BranchInst)
112 HANDLE_TERM_INST ( 3, Switch , SwitchInst)
113 HANDLE_TERM_INST ( 4, IndirectBr , IndirectBrInst)
114 HANDLE_TERM_INST ( 5, Invoke , InvokeInst)
115 HANDLE_TERM_INST ( 6, Resume , ResumeInst)
116 HANDLE_TERM_INST ( 7, Unreachable , UnreachableInst)
117 HANDLE_TERM_INST ( 8, CleanupRet , CleanupReturnInst)
118 HANDLE_TERM_INST ( 9, CatchRet , CatchReturnInst)
119 HANDLE_TERM_INST (10, CatchSwitch , CatchSwitchInst)
122 // Standard binary operators...
123 FIRST_BINARY_INST(11)
124 HANDLE_BINARY_INST(11, Add , BinaryOperator)
125 HANDLE_BINARY_INST(12, FAdd , BinaryOperator)
126 HANDLE_BINARY_INST(13, Sub , BinaryOperator)
127 HANDLE_BINARY_INST(14, FSub , BinaryOperator)
128 HANDLE_BINARY_INST(15, Mul , BinaryOperator)
129 HANDLE_BINARY_INST(16, FMul , BinaryOperator)
130 HANDLE_BINARY_INST(17, UDiv , BinaryOperator)
131 HANDLE_BINARY_INST(18, SDiv , BinaryOperator)
132 HANDLE_BINARY_INST(19, FDiv , BinaryOperator)
133 HANDLE_BINARY_INST(20, URem , BinaryOperator)
134 HANDLE_BINARY_INST(21, SRem , BinaryOperator)
135 HANDLE_BINARY_INST(22, FRem , BinaryOperator)
137 // Logical operators (integer operands)
138 HANDLE_BINARY_INST(23, Shl , BinaryOperator) // Shift left (logical)
139 HANDLE_BINARY_INST(24, LShr , BinaryOperator) // Shift right (logical)
140 HANDLE_BINARY_INST(25, AShr , BinaryOperator) // Shift right (arithmetic)
141 HANDLE_BINARY_INST(26, And , BinaryOperator)
142 HANDLE_BINARY_INST(27, Or , BinaryOperator)
143 HANDLE_BINARY_INST(28, Xor , BinaryOperator)
146 // Memory operators...
147 FIRST_MEMORY_INST(29)
148 HANDLE_MEMORY_INST(29, Alloca, AllocaInst) // Stack management
149 HANDLE_MEMORY_INST(30, Load , LoadInst ) // Memory manipulation instrs
150 HANDLE_MEMORY_INST(31, Store , StoreInst )
151 HANDLE_MEMORY_INST(32, GetElementPtr, GetElementPtrInst)
152 HANDLE_MEMORY_INST(33, Fence , FenceInst )
153 HANDLE_MEMORY_INST(34, AtomicCmpXchg , AtomicCmpXchgInst )
154 HANDLE_MEMORY_INST(35, AtomicRMW , AtomicRMWInst )
157 // Cast operators ...
158 // NOTE: The order matters here because CastInst::isEliminableCastPair
159 // NOTE: (see Instructions.cpp) encodes a table based on this ordering.
161 HANDLE_CAST_INST(36, Trunc , TruncInst ) // Truncate integers
162 HANDLE_CAST_INST(37, ZExt , ZExtInst ) // Zero extend integers
163 HANDLE_CAST_INST(38, SExt , SExtInst ) // Sign extend integers
164 HANDLE_CAST_INST(39, FPToUI , FPToUIInst ) // floating point -> UInt
165 HANDLE_CAST_INST(40, FPToSI , FPToSIInst ) // floating point -> SInt
166 HANDLE_CAST_INST(41, UIToFP , UIToFPInst ) // UInt -> floating point
167 HANDLE_CAST_INST(42, SIToFP , SIToFPInst ) // SInt -> floating point
168 HANDLE_CAST_INST(43, FPTrunc , FPTruncInst ) // Truncate floating point
169 HANDLE_CAST_INST(44, FPExt , FPExtInst ) // Extend floating point
170 HANDLE_CAST_INST(45, PtrToInt, PtrToIntInst) // Pointer -> Integer
171 HANDLE_CAST_INST(46, IntToPtr, IntToPtrInst) // Integer -> Pointer
172 HANDLE_CAST_INST(47, BitCast , BitCastInst ) // Type cast
173 HANDLE_CAST_INST(48, AddrSpaceCast, AddrSpaceCastInst) // addrspace cast
176 FIRST_FUNCLETPAD_INST(49)
177 HANDLE_FUNCLETPAD_INST(49, CleanupPad, CleanupPadInst)
178 HANDLE_FUNCLETPAD_INST(50, CatchPad , CatchPadInst)
179 LAST_FUNCLETPAD_INST(50)
181 // Other operators...
183 HANDLE_OTHER_INST(51, ICmp , ICmpInst ) // Integer comparison instruction
184 HANDLE_OTHER_INST(52, FCmp , FCmpInst ) // Floating point comparison instr.
185 HANDLE_OTHER_INST(53, PHI , PHINode ) // PHI node instruction
186 HANDLE_OTHER_INST(54, Call , CallInst ) // Call a function
187 HANDLE_OTHER_INST(55, Select , SelectInst ) // select instruction
188 HANDLE_OTHER_INST(56, UserOp1, Instruction) // May be used internally in a pass
189 HANDLE_OTHER_INST(57, UserOp2, Instruction) // Internal to passes only
190 HANDLE_OTHER_INST(58, VAArg , VAArgInst ) // vaarg instruction
191 HANDLE_OTHER_INST(59, ExtractElement, ExtractElementInst)// extract from vector
192 HANDLE_OTHER_INST(60, InsertElement, InsertElementInst) // insert into vector
193 HANDLE_OTHER_INST(61, ShuffleVector, ShuffleVectorInst) // shuffle two vectors.
194 HANDLE_OTHER_INST(62, ExtractValue, ExtractValueInst)// extract from aggregate
195 HANDLE_OTHER_INST(63, InsertValue, InsertValueInst) // insert into aggregate
196 HANDLE_OTHER_INST(64, LandingPad, LandingPadInst) // Landing pad instruction.
199 #undef FIRST_TERM_INST
200 #undef HANDLE_TERM_INST
201 #undef LAST_TERM_INST
203 #undef FIRST_BINARY_INST
204 #undef HANDLE_BINARY_INST
205 #undef LAST_BINARY_INST
207 #undef FIRST_MEMORY_INST
208 #undef HANDLE_MEMORY_INST
209 #undef LAST_MEMORY_INST
211 #undef FIRST_CAST_INST
212 #undef HANDLE_CAST_INST
213 #undef LAST_CAST_INST
215 #undef FIRST_FUNCLETPAD_INST
216 #undef HANDLE_FUNCLETPAD_INST
217 #undef LAST_FUNCLETPAD_INST
219 #undef FIRST_OTHER_INST
220 #undef HANDLE_OTHER_INST
221 #undef LAST_OTHER_INST