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