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, Unreachable, UnreachableInst)
106 // Standard binary operators...
107 FIRST_BINARY_INST( 8)
108 HANDLE_BINARY_INST( 8, Add , BinaryOperator)
109 HANDLE_BINARY_INST( 9, FAdd , BinaryOperator)
110 HANDLE_BINARY_INST(10, Sub , BinaryOperator)
111 HANDLE_BINARY_INST(11, FSub , BinaryOperator)
112 HANDLE_BINARY_INST(12, Mul , BinaryOperator)
113 HANDLE_BINARY_INST(13, FMul , BinaryOperator)
114 HANDLE_BINARY_INST(14, UDiv , BinaryOperator)
115 HANDLE_BINARY_INST(15, SDiv , BinaryOperator)
116 HANDLE_BINARY_INST(16, FDiv , BinaryOperator)
117 HANDLE_BINARY_INST(17, URem , BinaryOperator)
118 HANDLE_BINARY_INST(18, SRem , BinaryOperator)
119 HANDLE_BINARY_INST(19, FRem , BinaryOperator)
121 // Logical operators (integer operands)
122 HANDLE_BINARY_INST(20, Shl , BinaryOperator) // Shift left (logical)
123 HANDLE_BINARY_INST(21, LShr , BinaryOperator) // Shift right (logical)
124 HANDLE_BINARY_INST(22, AShr , BinaryOperator) // Shift right (arithmetic)
125 HANDLE_BINARY_INST(23, And , BinaryOperator)
126 HANDLE_BINARY_INST(24, Or , BinaryOperator)
127 HANDLE_BINARY_INST(25, Xor , BinaryOperator)
130 // Memory operators...
131 FIRST_MEMORY_INST(26)
132 HANDLE_MEMORY_INST(26, Alloca, AllocaInst) // Stack management
133 HANDLE_MEMORY_INST(27, Load , LoadInst ) // Memory manipulation instrs
134 HANDLE_MEMORY_INST(28, Store , StoreInst )
135 HANDLE_MEMORY_INST(29, GetElementPtr, GetElementPtrInst)
138 // Cast operators ...
139 // NOTE: The order matters here because CastInst::isEliminableCastPair
140 // NOTE: (see Instructions.cpp) encodes a table based on this ordering.
142 HANDLE_CAST_INST(30, Trunc , TruncInst ) // Truncate integers
143 HANDLE_CAST_INST(31, ZExt , ZExtInst ) // Zero extend integers
144 HANDLE_CAST_INST(32, SExt , SExtInst ) // Sign extend integers
145 HANDLE_CAST_INST(33, FPToUI , FPToUIInst ) // floating point -> UInt
146 HANDLE_CAST_INST(34, FPToSI , FPToSIInst ) // floating point -> SInt
147 HANDLE_CAST_INST(35, UIToFP , UIToFPInst ) // UInt -> floating point
148 HANDLE_CAST_INST(36, SIToFP , SIToFPInst ) // SInt -> floating point
149 HANDLE_CAST_INST(37, FPTrunc , FPTruncInst ) // Truncate floating point
150 HANDLE_CAST_INST(38, FPExt , FPExtInst ) // Extend floating point
151 HANDLE_CAST_INST(39, PtrToInt, PtrToIntInst) // Pointer -> Integer
152 HANDLE_CAST_INST(40, IntToPtr, IntToPtrInst) // Integer -> Pointer
153 HANDLE_CAST_INST(41, BitCast , BitCastInst ) // Type cast
156 // Other operators...
158 HANDLE_OTHER_INST(42, ICmp , ICmpInst ) // Integer comparison instruction
159 HANDLE_OTHER_INST(43, FCmp , FCmpInst ) // Floating point comparison instr.
160 HANDLE_OTHER_INST(44, PHI , PHINode ) // PHI node instruction
161 HANDLE_OTHER_INST(45, Call , CallInst ) // Call a function
162 HANDLE_OTHER_INST(46, Select , SelectInst ) // select instruction
163 HANDLE_OTHER_INST(47, UserOp1, Instruction) // May be used internally in a pass
164 HANDLE_OTHER_INST(48, UserOp2, Instruction) // Internal to passes only
165 HANDLE_OTHER_INST(49, VAArg , VAArgInst ) // vaarg instruction
166 HANDLE_OTHER_INST(50, ExtractElement, ExtractElementInst)// extract from vector
167 HANDLE_OTHER_INST(51, InsertElement, InsertElementInst) // insert into vector
168 HANDLE_OTHER_INST(52, ShuffleVector, ShuffleVectorInst) // shuffle two vectors.
169 HANDLE_OTHER_INST(53, ExtractValue, ExtractValueInst)// extract from aggregate
170 HANDLE_OTHER_INST(54, InsertValue, InsertValueInst) // insert into aggregate
174 #undef FIRST_TERM_INST
175 #undef HANDLE_TERM_INST
176 #undef LAST_TERM_INST
178 #undef FIRST_BINARY_INST
179 #undef HANDLE_BINARY_INST
180 #undef LAST_BINARY_INST
182 #undef FIRST_MEMORY_INST
183 #undef HANDLE_MEMORY_INST
184 #undef LAST_MEMORY_INST
186 #undef FIRST_CAST_INST
187 #undef HANDLE_CAST_INST
188 #undef LAST_CAST_INST
190 #undef FIRST_OTHER_INST
191 #undef HANDLE_OTHER_INST
192 #undef LAST_OTHER_INST