• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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)
97HANDLE_TERM_INST  ( 1, Ret        , ReturnInst)
98HANDLE_TERM_INST  ( 2, Br         , BranchInst)
99HANDLE_TERM_INST  ( 3, Switch     , SwitchInst)
100HANDLE_TERM_INST  ( 4, IndirectBr , IndirectBrInst)
101HANDLE_TERM_INST  ( 5, Invoke     , InvokeInst)
102HANDLE_TERM_INST  ( 6, Resume     , ResumeInst)
103HANDLE_TERM_INST  ( 7, Unreachable, UnreachableInst)
104  LAST_TERM_INST  ( 7)
105
106// Standard binary operators...
107 FIRST_BINARY_INST( 8)
108HANDLE_BINARY_INST( 8, Add  , BinaryOperator)
109HANDLE_BINARY_INST( 9, FAdd , BinaryOperator)
110HANDLE_BINARY_INST(10, Sub  , BinaryOperator)
111HANDLE_BINARY_INST(11, FSub , BinaryOperator)
112HANDLE_BINARY_INST(12, Mul  , BinaryOperator)
113HANDLE_BINARY_INST(13, FMul , BinaryOperator)
114HANDLE_BINARY_INST(14, UDiv , BinaryOperator)
115HANDLE_BINARY_INST(15, SDiv , BinaryOperator)
116HANDLE_BINARY_INST(16, FDiv , BinaryOperator)
117HANDLE_BINARY_INST(17, URem , BinaryOperator)
118HANDLE_BINARY_INST(18, SRem , BinaryOperator)
119HANDLE_BINARY_INST(19, FRem , BinaryOperator)
120
121// Logical operators (integer operands)
122HANDLE_BINARY_INST(20, Shl  , BinaryOperator) // Shift left  (logical)
123HANDLE_BINARY_INST(21, LShr , BinaryOperator) // Shift right (logical)
124HANDLE_BINARY_INST(22, AShr , BinaryOperator) // Shift right (arithmetic)
125HANDLE_BINARY_INST(23, And  , BinaryOperator)
126HANDLE_BINARY_INST(24, Or   , BinaryOperator)
127HANDLE_BINARY_INST(25, Xor  , BinaryOperator)
128  LAST_BINARY_INST(25)
129
130// Memory operators...
131 FIRST_MEMORY_INST(26)
132HANDLE_MEMORY_INST(26, Alloca, AllocaInst)  // Stack management
133HANDLE_MEMORY_INST(27, Load  , LoadInst  )  // Memory manipulation instrs
134HANDLE_MEMORY_INST(28, Store , StoreInst )
135HANDLE_MEMORY_INST(29, GetElementPtr, GetElementPtrInst)
136HANDLE_MEMORY_INST(30, Fence , FenceInst )
137HANDLE_MEMORY_INST(31, AtomicCmpXchg , AtomicCmpXchgInst )
138HANDLE_MEMORY_INST(32, AtomicRMW , AtomicRMWInst )
139  LAST_MEMORY_INST(32)
140
141// Cast operators ...
142// NOTE: The order matters here because CastInst::isEliminableCastPair
143// NOTE: (see Instructions.cpp) encodes a table based on this ordering.
144 FIRST_CAST_INST(33)
145HANDLE_CAST_INST(33, Trunc   , TruncInst   )  // Truncate integers
146HANDLE_CAST_INST(34, ZExt    , ZExtInst    )  // Zero extend integers
147HANDLE_CAST_INST(35, SExt    , SExtInst    )  // Sign extend integers
148HANDLE_CAST_INST(36, FPToUI  , FPToUIInst  )  // floating point -> UInt
149HANDLE_CAST_INST(37, FPToSI  , FPToSIInst  )  // floating point -> SInt
150HANDLE_CAST_INST(38, UIToFP  , UIToFPInst  )  // UInt -> floating point
151HANDLE_CAST_INST(39, SIToFP  , SIToFPInst  )  // SInt -> floating point
152HANDLE_CAST_INST(40, FPTrunc , FPTruncInst )  // Truncate floating point
153HANDLE_CAST_INST(41, FPExt   , FPExtInst   )  // Extend floating point
154HANDLE_CAST_INST(42, PtrToInt, PtrToIntInst)  // Pointer -> Integer
155HANDLE_CAST_INST(43, IntToPtr, IntToPtrInst)  // Integer -> Pointer
156HANDLE_CAST_INST(44, BitCast , BitCastInst )  // Type cast
157HANDLE_CAST_INST(45, AddrSpaceCast, AddrSpaceCastInst)  // addrspace cast
158  LAST_CAST_INST(45)
159
160// Other operators...
161 FIRST_OTHER_INST(46)
162HANDLE_OTHER_INST(46, ICmp   , ICmpInst   )  // Integer comparison instruction
163HANDLE_OTHER_INST(47, FCmp   , FCmpInst   )  // Floating point comparison instr.
164HANDLE_OTHER_INST(48, PHI    , PHINode    )  // PHI node instruction
165HANDLE_OTHER_INST(49, Call   , CallInst   )  // Call a function
166HANDLE_OTHER_INST(50, Select , SelectInst )  // select instruction
167HANDLE_OTHER_INST(51, UserOp1, Instruction)  // May be used internally in a pass
168HANDLE_OTHER_INST(52, UserOp2, Instruction)  // Internal to passes only
169HANDLE_OTHER_INST(53, VAArg  , VAArgInst  )  // vaarg instruction
170HANDLE_OTHER_INST(54, ExtractElement, ExtractElementInst)// extract from vector
171HANDLE_OTHER_INST(55, InsertElement, InsertElementInst)  // insert into vector
172HANDLE_OTHER_INST(56, ShuffleVector, ShuffleVectorInst)  // shuffle two vectors.
173HANDLE_OTHER_INST(57, ExtractValue, ExtractValueInst)// extract from aggregate
174HANDLE_OTHER_INST(58, InsertValue, InsertValueInst)  // insert into aggregate
175HANDLE_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