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_OTHER_INST
78 #define FIRST_OTHER_INST(num)
80 #ifndef HANDLE_OTHER_INST
82 #define HANDLE_OTHER_INST(num, opcode, Class)
84 #define HANDLE_OTHER_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class)
87 #ifndef LAST_OTHER_INST
88 #define LAST_OTHER_INST(num)
92 // Terminator Instructions - These instructions are used to terminate a basic
93 // block of the program. Every basic block must end with one of these
94 // instructions for it to be a well formed basic block.
97 HANDLE_TERM_INST ( 1, Ret , ReturnInst)
98 HANDLE_TERM_INST ( 2, Br , BranchInst)
99 HANDLE_TERM_INST ( 3, Switch , SwitchInst)
100 HANDLE_TERM_INST ( 4, IndirectBr , IndirectBrInst)
101 HANDLE_TERM_INST ( 5, Invoke , InvokeInst)
102 HANDLE_TERM_INST ( 6, Unwind , UnwindInst)
103 HANDLE_TERM_INST ( 7, Resume , ResumeInst)
104 HANDLE_TERM_INST ( 8, Unreachable, UnreachableInst)
107 // Standard binary operators...
108 FIRST_BINARY_INST( 9)
109 HANDLE_BINARY_INST( 9, Add , BinaryOperator)
110 HANDLE_BINARY_INST(10, FAdd , BinaryOperator)
111 HANDLE_BINARY_INST(11, Sub , BinaryOperator)
112 HANDLE_BINARY_INST(12, FSub , BinaryOperator)
113 HANDLE_BINARY_INST(13, Mul , BinaryOperator)
114 HANDLE_BINARY_INST(14, FMul , BinaryOperator)
115 HANDLE_BINARY_INST(15, UDiv , BinaryOperator)
116 HANDLE_BINARY_INST(16, SDiv , BinaryOperator)
117 HANDLE_BINARY_INST(17, FDiv , BinaryOperator)
118 HANDLE_BINARY_INST(18, URem , BinaryOperator)
119 HANDLE_BINARY_INST(19, SRem , BinaryOperator)
120 HANDLE_BINARY_INST(20, FRem , BinaryOperator)
122 // Logical operators (integer operands)
123 HANDLE_BINARY_INST(21, Shl , BinaryOperator) // Shift left (logical)
124 HANDLE_BINARY_INST(22, LShr , BinaryOperator) // Shift right (logical)
125 HANDLE_BINARY_INST(23, AShr , BinaryOperator) // Shift right (arithmetic)
126 HANDLE_BINARY_INST(24, And , BinaryOperator)
127 HANDLE_BINARY_INST(25, Or , BinaryOperator)
128 HANDLE_BINARY_INST(26, Xor , BinaryOperator)
131 // Memory operators...
132 FIRST_MEMORY_INST(27)
133 HANDLE_MEMORY_INST(27, Alloca, AllocaInst) // Stack management
134 HANDLE_MEMORY_INST(28, Load , LoadInst ) // Memory manipulation instrs
135 HANDLE_MEMORY_INST(29, Store , StoreInst )
136 HANDLE_MEMORY_INST(30, GetElementPtr, GetElementPtrInst)
137 HANDLE_MEMORY_INST(31, Fence , FenceInst )
138 HANDLE_MEMORY_INST(32, AtomicCmpXchg , AtomicCmpXchgInst )
139 HANDLE_MEMORY_INST(33, AtomicRMW , AtomicRMWInst )
142 // Cast operators ...
143 // NOTE: The order matters here because CastInst::isEliminableCastPair
144 // NOTE: (see Instructions.cpp) encodes a table based on this ordering.
146 HANDLE_CAST_INST(34, Trunc , TruncInst ) // Truncate integers
147 HANDLE_CAST_INST(35, ZExt , ZExtInst ) // Zero extend integers
148 HANDLE_CAST_INST(36, SExt , SExtInst ) // Sign extend integers
149 HANDLE_CAST_INST(37, FPToUI , FPToUIInst ) // floating point -> UInt
150 HANDLE_CAST_INST(38, FPToSI , FPToSIInst ) // floating point -> SInt
151 HANDLE_CAST_INST(39, UIToFP , UIToFPInst ) // UInt -> floating point
152 HANDLE_CAST_INST(40, SIToFP , SIToFPInst ) // SInt -> floating point
153 HANDLE_CAST_INST(41, FPTrunc , FPTruncInst ) // Truncate floating point
154 HANDLE_CAST_INST(42, FPExt , FPExtInst ) // Extend floating point
155 HANDLE_CAST_INST(43, PtrToInt, PtrToIntInst) // Pointer -> Integer
156 HANDLE_CAST_INST(44, IntToPtr, IntToPtrInst) // Integer -> Pointer
157 HANDLE_CAST_INST(45, BitCast , BitCastInst ) // Type cast
160 // Other operators...
162 HANDLE_OTHER_INST(46, ICmp , ICmpInst ) // Integer comparison instruction
163 HANDLE_OTHER_INST(47, FCmp , FCmpInst ) // Floating point comparison instr.
164 HANDLE_OTHER_INST(48, PHI , PHINode ) // PHI node instruction
165 HANDLE_OTHER_INST(49, Call , CallInst ) // Call a function
166 HANDLE_OTHER_INST(50, Select , SelectInst ) // select instruction
167 HANDLE_OTHER_INST(51, UserOp1, Instruction) // May be used internally in a pass
168 HANDLE_OTHER_INST(52, UserOp2, Instruction) // Internal to passes only
169 HANDLE_OTHER_INST(53, VAArg , VAArgInst ) // vaarg instruction
170 HANDLE_OTHER_INST(54, ExtractElement, ExtractElementInst)// extract from vector
171 HANDLE_OTHER_INST(55, InsertElement, InsertElementInst) // insert into vector
172 HANDLE_OTHER_INST(56, ShuffleVector, ShuffleVectorInst) // shuffle two vectors.
173 HANDLE_OTHER_INST(57, ExtractValue, ExtractValueInst)// extract from aggregate
174 HANDLE_OTHER_INST(58, InsertValue, InsertValueInst) // insert into aggregate
175 HANDLE_OTHER_INST(59, LandingPad, LandingPadInst) // Landing pad instruction.
178 #undef FIRST_TERM_INST
179 #undef HANDLE_TERM_INST
180 #undef LAST_TERM_INST
182 #undef FIRST_BINARY_INST
183 #undef HANDLE_BINARY_INST
184 #undef LAST_BINARY_INST
186 #undef FIRST_MEMORY_INST
187 #undef HANDLE_MEMORY_INST
188 #undef LAST_MEMORY_INST
190 #undef FIRST_CAST_INST
191 #undef HANDLE_CAST_INST
192 #undef LAST_CAST_INST
194 #undef FIRST_OTHER_INST
195 #undef HANDLE_OTHER_INST
196 #undef LAST_OTHER_INST