1//===-- llvm/Instruction.def - File that describes Instructions -*- C++ -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8// 9// This file contains descriptions of the various LLVM instructions. This is 10// used as a central place for enumerating the different instructions and 11// should eventually be the place to put comments about the instructions. 12// 13//===----------------------------------------------------------------------===// 14 15// NOTE: NO INCLUDE GUARD DESIRED! 16 17// Provide definitions of macros so that users of this file do not have to 18// define everything to use it... 19// 20#ifndef FIRST_TERM_INST 21#define FIRST_TERM_INST(num) 22#endif 23#ifndef HANDLE_TERM_INST 24#ifndef HANDLE_INST 25#define HANDLE_TERM_INST(num, opcode, Class) 26#else 27#define HANDLE_TERM_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class) 28#endif 29#endif 30#ifndef LAST_TERM_INST 31#define LAST_TERM_INST(num) 32#endif 33 34#ifndef FIRST_UNARY_INST 35#define FIRST_UNARY_INST(num) 36#endif 37#ifndef HANDLE_UNARY_INST 38#ifndef HANDLE_INST 39#define HANDLE_UNARY_INST(num, opcode, instclass) 40#else 41#define HANDLE_UNARY_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class) 42#endif 43#endif 44#ifndef LAST_UNARY_INST 45#define LAST_UNARY_INST(num) 46#endif 47 48#ifndef FIRST_BINARY_INST 49#define FIRST_BINARY_INST(num) 50#endif 51#ifndef HANDLE_BINARY_INST 52#ifndef HANDLE_INST 53#define HANDLE_BINARY_INST(num, opcode, instclass) 54#else 55#define HANDLE_BINARY_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class) 56#endif 57#endif 58#ifndef LAST_BINARY_INST 59#define LAST_BINARY_INST(num) 60#endif 61 62#ifndef FIRST_MEMORY_INST 63#define FIRST_MEMORY_INST(num) 64#endif 65#ifndef HANDLE_MEMORY_INST 66#ifndef HANDLE_INST 67#define HANDLE_MEMORY_INST(num, opcode, Class) 68#else 69#define HANDLE_MEMORY_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class) 70#endif 71#endif 72#ifndef LAST_MEMORY_INST 73#define LAST_MEMORY_INST(num) 74#endif 75 76#ifndef FIRST_CAST_INST 77#define FIRST_CAST_INST(num) 78#endif 79#ifndef HANDLE_CAST_INST 80#ifndef HANDLE_INST 81#define HANDLE_CAST_INST(num, opcode, Class) 82#else 83#define HANDLE_CAST_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class) 84#endif 85#endif 86#ifndef LAST_CAST_INST 87#define LAST_CAST_INST(num) 88#endif 89 90#ifndef FIRST_FUNCLETPAD_INST 91#define FIRST_FUNCLETPAD_INST(num) 92#endif 93#ifndef HANDLE_FUNCLETPAD_INST 94#ifndef HANDLE_INST 95#define HANDLE_FUNCLETPAD_INST(num, opcode, Class) 96#else 97#define HANDLE_FUNCLETPAD_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class) 98#endif 99#endif 100#ifndef LAST_FUNCLETPAD_INST 101#define LAST_FUNCLETPAD_INST(num) 102#endif 103 104#ifndef FIRST_OTHER_INST 105#define FIRST_OTHER_INST(num) 106#endif 107#ifndef HANDLE_OTHER_INST 108#ifndef HANDLE_INST 109#define HANDLE_OTHER_INST(num, opcode, Class) 110#else 111#define HANDLE_OTHER_INST(num, opcode, Class) HANDLE_INST(num, opcode, Class) 112#endif 113#endif 114#ifndef LAST_OTHER_INST 115#define LAST_OTHER_INST(num) 116#endif 117 118#ifndef HANDLE_USER_INST 119#define HANDLE_USER_INST(num, opc, Class) HANDLE_OTHER_INST(num, opc, Class) 120#endif 121 122// Terminator Instructions - These instructions are used to terminate a basic 123// block of the program. Every basic block must end with one of these 124// instructions for it to be a well formed basic block. 125// 126 FIRST_TERM_INST ( 1) 127HANDLE_TERM_INST ( 1, Ret , ReturnInst) 128HANDLE_TERM_INST ( 2, Br , BranchInst) 129HANDLE_TERM_INST ( 3, Switch , SwitchInst) 130HANDLE_TERM_INST ( 4, IndirectBr , IndirectBrInst) 131HANDLE_TERM_INST ( 5, Invoke , InvokeInst) 132HANDLE_TERM_INST ( 6, Resume , ResumeInst) 133HANDLE_TERM_INST ( 7, Unreachable , UnreachableInst) 134HANDLE_TERM_INST ( 8, CleanupRet , CleanupReturnInst) 135HANDLE_TERM_INST ( 9, CatchRet , CatchReturnInst) 136HANDLE_TERM_INST (10, CatchSwitch , CatchSwitchInst) 137HANDLE_TERM_INST (11, CallBr , CallBrInst) // A call-site terminator 138 LAST_TERM_INST (11) 139 140// Standard unary operators... 141 FIRST_UNARY_INST(12) 142HANDLE_UNARY_INST(12, FNeg , UnaryOperator) 143 LAST_UNARY_INST(12) 144 145// Standard binary operators... 146 FIRST_BINARY_INST(13) 147HANDLE_BINARY_INST(13, Add , BinaryOperator) 148HANDLE_BINARY_INST(14, FAdd , BinaryOperator) 149HANDLE_BINARY_INST(15, Sub , BinaryOperator) 150HANDLE_BINARY_INST(16, FSub , BinaryOperator) 151HANDLE_BINARY_INST(17, Mul , BinaryOperator) 152HANDLE_BINARY_INST(18, FMul , BinaryOperator) 153HANDLE_BINARY_INST(19, UDiv , BinaryOperator) 154HANDLE_BINARY_INST(20, SDiv , BinaryOperator) 155HANDLE_BINARY_INST(21, FDiv , BinaryOperator) 156HANDLE_BINARY_INST(22, URem , BinaryOperator) 157HANDLE_BINARY_INST(23, SRem , BinaryOperator) 158HANDLE_BINARY_INST(24, FRem , BinaryOperator) 159 160// Logical operators (integer operands) 161HANDLE_BINARY_INST(25, Shl , BinaryOperator) // Shift left (logical) 162HANDLE_BINARY_INST(26, LShr , BinaryOperator) // Shift right (logical) 163HANDLE_BINARY_INST(27, AShr , BinaryOperator) // Shift right (arithmetic) 164HANDLE_BINARY_INST(28, And , BinaryOperator) 165HANDLE_BINARY_INST(29, Or , BinaryOperator) 166HANDLE_BINARY_INST(30, Xor , BinaryOperator) 167 LAST_BINARY_INST(30) 168 169// Memory operators... 170 FIRST_MEMORY_INST(31) 171HANDLE_MEMORY_INST(31, Alloca, AllocaInst) // Stack management 172HANDLE_MEMORY_INST(32, Load , LoadInst ) // Memory manipulation instrs 173HANDLE_MEMORY_INST(33, Store , StoreInst ) 174HANDLE_MEMORY_INST(34, GetElementPtr, GetElementPtrInst) 175HANDLE_MEMORY_INST(35, Fence , FenceInst ) 176HANDLE_MEMORY_INST(36, AtomicCmpXchg , AtomicCmpXchgInst ) 177HANDLE_MEMORY_INST(37, AtomicRMW , AtomicRMWInst ) 178 LAST_MEMORY_INST(37) 179 180// Cast operators ... 181// NOTE: The order matters here because CastInst::isEliminableCastPair 182// NOTE: (see Instructions.cpp) encodes a table based on this ordering. 183 FIRST_CAST_INST(38) 184HANDLE_CAST_INST(38, Trunc , TruncInst ) // Truncate integers 185HANDLE_CAST_INST(39, ZExt , ZExtInst ) // Zero extend integers 186HANDLE_CAST_INST(40, SExt , SExtInst ) // Sign extend integers 187HANDLE_CAST_INST(41, FPToUI , FPToUIInst ) // floating point -> UInt 188HANDLE_CAST_INST(42, FPToSI , FPToSIInst ) // floating point -> SInt 189HANDLE_CAST_INST(43, UIToFP , UIToFPInst ) // UInt -> floating point 190HANDLE_CAST_INST(44, SIToFP , SIToFPInst ) // SInt -> floating point 191HANDLE_CAST_INST(45, FPTrunc , FPTruncInst ) // Truncate floating point 192HANDLE_CAST_INST(46, FPExt , FPExtInst ) // Extend floating point 193HANDLE_CAST_INST(47, PtrToInt, PtrToIntInst) // Pointer -> Integer 194HANDLE_CAST_INST(48, IntToPtr, IntToPtrInst) // Integer -> Pointer 195HANDLE_CAST_INST(49, BitCast , BitCastInst ) // Type cast 196HANDLE_CAST_INST(50, AddrSpaceCast, AddrSpaceCastInst) // addrspace cast 197 LAST_CAST_INST(50) 198 199 FIRST_FUNCLETPAD_INST(51) 200HANDLE_FUNCLETPAD_INST(51, CleanupPad, CleanupPadInst) 201HANDLE_FUNCLETPAD_INST(52, CatchPad , CatchPadInst) 202 LAST_FUNCLETPAD_INST(52) 203 204// Other operators... 205 FIRST_OTHER_INST(53) 206HANDLE_OTHER_INST(53, ICmp , ICmpInst ) // Integer comparison instruction 207HANDLE_OTHER_INST(54, FCmp , FCmpInst ) // Floating point comparison instr. 208HANDLE_OTHER_INST(55, PHI , PHINode ) // PHI node instruction 209HANDLE_OTHER_INST(56, Call , CallInst ) // Call a function 210HANDLE_OTHER_INST(57, Select , SelectInst ) // select instruction 211HANDLE_USER_INST (58, UserOp1, Instruction) // May be used internally in a pass 212HANDLE_USER_INST (59, UserOp2, Instruction) // Internal to passes only 213HANDLE_OTHER_INST(60, VAArg , VAArgInst ) // vaarg instruction 214HANDLE_OTHER_INST(61, ExtractElement, ExtractElementInst)// extract from vector 215HANDLE_OTHER_INST(62, InsertElement, InsertElementInst) // insert into vector 216HANDLE_OTHER_INST(63, ShuffleVector, ShuffleVectorInst) // shuffle two vectors. 217HANDLE_OTHER_INST(64, ExtractValue, ExtractValueInst)// extract from aggregate 218HANDLE_OTHER_INST(65, InsertValue, InsertValueInst) // insert into aggregate 219HANDLE_OTHER_INST(66, LandingPad, LandingPadInst) // Landing pad instruction. 220HANDLE_OTHER_INST(67, Freeze, FreezeInst) // Freeze instruction. 221 LAST_OTHER_INST(67) 222 223#undef FIRST_TERM_INST 224#undef HANDLE_TERM_INST 225#undef LAST_TERM_INST 226 227#undef FIRST_UNARY_INST 228#undef HANDLE_UNARY_INST 229#undef LAST_UNARY_INST 230 231#undef FIRST_BINARY_INST 232#undef HANDLE_BINARY_INST 233#undef LAST_BINARY_INST 234 235#undef FIRST_MEMORY_INST 236#undef HANDLE_MEMORY_INST 237#undef LAST_MEMORY_INST 238 239#undef FIRST_CAST_INST 240#undef HANDLE_CAST_INST 241#undef LAST_CAST_INST 242 243#undef FIRST_FUNCLETPAD_INST 244#undef HANDLE_FUNCLETPAD_INST 245#undef LAST_FUNCLETPAD_INST 246 247#undef FIRST_OTHER_INST 248#undef HANDLE_OTHER_INST 249#undef LAST_OTHER_INST 250 251#undef HANDLE_USER_INST 252 253#ifdef HANDLE_INST 254#undef HANDLE_INST 255#endif 256