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