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_BINARY_INST 36 #define FIRST_BINARY_INST(num) 37 #endif 38 #ifndef HANDLE_BINARY_INST 39 #ifndef HANDLE_INST 40 #define HANDLE_BINARY_INST(num, opcode, instclass) 41 #else 42 #define HANDLE_BINARY_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class) 43 #endif 44 #endif 45 #ifndef LAST_BINARY_INST 46 #define LAST_BINARY_INST(num) 47 #endif 48 49 #ifndef FIRST_MEMORY_INST 50 #define FIRST_MEMORY_INST(num) 51 #endif 52 #ifndef HANDLE_MEMORY_INST 53 #ifndef HANDLE_INST 54 #define HANDLE_MEMORY_INST(num, opcode, Class) 55 #else 56 #define HANDLE_MEMORY_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class) 57 #endif 58 #endif 59 #ifndef LAST_MEMORY_INST 60 #define LAST_MEMORY_INST(num) 61 #endif 62 63 #ifndef FIRST_CAST_INST 64 #define FIRST_CAST_INST(num) 65 #endif 66 #ifndef HANDLE_CAST_INST 67 #ifndef HANDLE_INST 68 #define HANDLE_CAST_INST(num, opcode, Class) 69 #else 70 #define HANDLE_CAST_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class) 71 #endif 72 #endif 73 #ifndef LAST_CAST_INST 74 #define LAST_CAST_INST(num) 75 #endif 76 77 #ifndef FIRST_OTHER_INST 78 #define FIRST_OTHER_INST(num) 79 #endif 80 #ifndef HANDLE_OTHER_INST 81 #ifndef HANDLE_INST 82 #define HANDLE_OTHER_INST(num, opcode, Class) 83 #else 84 #define HANDLE_OTHER_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class) 85 #endif 86 #endif 87 #ifndef LAST_OTHER_INST 88 #define LAST_OTHER_INST(num) 89 #endif 90 91 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. 95 // 96 FIRST_TERM_INST ( 1) 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) 105 LAST_TERM_INST ( 8) 106 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) 121 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) 129 LAST_BINARY_INST(26) 130 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 ) 140 LAST_MEMORY_INST(33) 141 142 // Cast operators ... 143 // NOTE: The order matters here because CastInst::isEliminableCastPair 144 // NOTE: (see Instructions.cpp) encodes a table based on this ordering. 145 FIRST_CAST_INST(34) 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 158 LAST_CAST_INST(45) 159 160 // Other operators... 161 FIRST_OTHER_INST(46) 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. 176 LAST_OTHER_INST(59) 177 178 #undef FIRST_TERM_INST 179 #undef HANDLE_TERM_INST 180 #undef LAST_TERM_INST 181 182 #undef FIRST_BINARY_INST 183 #undef HANDLE_BINARY_INST 184 #undef LAST_BINARY_INST 185 186 #undef FIRST_MEMORY_INST 187 #undef HANDLE_MEMORY_INST 188 #undef LAST_MEMORY_INST 189 190 #undef FIRST_CAST_INST 191 #undef HANDLE_CAST_INST 192 #undef LAST_CAST_INST 193 194 #undef FIRST_OTHER_INST 195 #undef HANDLE_OTHER_INST 196 #undef LAST_OTHER_INST 197 198 #ifdef HANDLE_INST 199 #undef HANDLE_INST 200 #endif 201