blob: 0614a0032523c558113672fc3f01da52641cd659 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===-- llvm/Support/TargetOpcodes.def - Target Indep Opcodes ---*- 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 defines the target independent instruction opcodes.
11//
12//===----------------------------------------------------------------------===//
13
14// NOTE: NO INCLUDE GUARD DESIRED!
15
16/// HANDLE_TARGET_OPCODE defines an opcode and its associated enum value.
17///
18#ifndef HANDLE_TARGET_OPCODE
19#define HANDLE_TARGET_OPCODE(OPC, NUM)
20#endif
21
22/// HANDLE_TARGET_OPCODE_MARKER defines an alternative identifier for an opcode.
23///
24#ifndef HANDLE_TARGET_OPCODE_MARKER
25#define HANDLE_TARGET_OPCODE_MARKER(IDENT, OPC)
26#endif
27
28/// Every instruction defined here must also appear in Target.td.
29///
30HANDLE_TARGET_OPCODE(PHI)
31HANDLE_TARGET_OPCODE(INLINEASM)
32HANDLE_TARGET_OPCODE(CFI_INSTRUCTION)
33HANDLE_TARGET_OPCODE(EH_LABEL)
34HANDLE_TARGET_OPCODE(GC_LABEL)
35HANDLE_TARGET_OPCODE(ANNOTATION_LABEL)
36
37/// KILL - This instruction is a noop that is used only to adjust the
38/// liveness of registers. This can be useful when dealing with
39/// sub-registers.
40HANDLE_TARGET_OPCODE(KILL)
41
42/// EXTRACT_SUBREG - This instruction takes two operands: a register
43/// that has subregisters, and a subregister index. It returns the
44/// extracted subregister value. This is commonly used to implement
45/// truncation operations on target architectures which support it.
46HANDLE_TARGET_OPCODE(EXTRACT_SUBREG)
47
48/// INSERT_SUBREG - This instruction takes three operands: a register that
49/// has subregisters, a register providing an insert value, and a
50/// subregister index. It returns the value of the first register with the
51/// value of the second register inserted. The first register is often
52/// defined by an IMPLICIT_DEF, because it is commonly used to implement
53/// anyext operations on target architectures which support it.
54HANDLE_TARGET_OPCODE(INSERT_SUBREG)
55
56/// IMPLICIT_DEF - This is the MachineInstr-level equivalent of undef.
57HANDLE_TARGET_OPCODE(IMPLICIT_DEF)
58
59/// SUBREG_TO_REG - Assert the value of bits in a super register.
60/// The result of this instruction is the value of the second operand inserted
61/// into the subregister specified by the third operand. All other bits are
62/// assumed to be equal to the bits in the immediate integer constant in the
63/// first operand. This instruction just communicates information; No code
64/// should be generated.
65/// This is typically used after an instruction where the write to a subregister
66/// implicitly cleared the bits in the super registers.
67HANDLE_TARGET_OPCODE(SUBREG_TO_REG)
68
69/// COPY_TO_REGCLASS - This instruction is a placeholder for a plain
70/// register-to-register copy into a specific register class. This is only
71/// used between instruction selection and MachineInstr creation, before
72/// virtual registers have been created for all the instructions, and it's
73/// only needed in cases where the register classes implied by the
74/// instructions are insufficient. It is emitted as a COPY MachineInstr.
75 HANDLE_TARGET_OPCODE(COPY_TO_REGCLASS)
76
77/// DBG_VALUE - a mapping of the llvm.dbg.value intrinsic
78HANDLE_TARGET_OPCODE(DBG_VALUE)
79
80/// REG_SEQUENCE - This variadic instruction is used to form a register that
81/// represents a consecutive sequence of sub-registers. It's used as a
82/// register coalescing / allocation aid and must be eliminated before code
83/// emission.
84// In SDNode form, the first operand encodes the register class created by
85// the REG_SEQUENCE, while each subsequent pair names a vreg + subreg index
86// pair. Once it has been lowered to a MachineInstr, the regclass operand
87// is no longer present.
88/// e.g. v1027 = REG_SEQUENCE v1024, 3, v1025, 4, v1026, 5
89/// After register coalescing references of v1024 should be replace with
90/// v1027:3, v1025 with v1027:4, etc.
91 HANDLE_TARGET_OPCODE(REG_SEQUENCE)
92
93/// COPY - Target-independent register copy. This instruction can also be
94/// used to copy between subregisters of virtual registers.
95 HANDLE_TARGET_OPCODE(COPY)
96
97/// BUNDLE - This instruction represents an instruction bundle. Instructions
98/// which immediately follow a BUNDLE instruction which are marked with
99/// 'InsideBundle' flag are inside the bundle.
100HANDLE_TARGET_OPCODE(BUNDLE)
101
102/// Lifetime markers.
103HANDLE_TARGET_OPCODE(LIFETIME_START)
104HANDLE_TARGET_OPCODE(LIFETIME_END)
105
106/// A Stackmap instruction captures the location of live variables at its
107/// position in the instruction stream. It is followed by a shadow of bytes
108/// that must lie within the function and not contain another stackmap.
109HANDLE_TARGET_OPCODE(STACKMAP)
110
111/// FEntry all - This is a marker instruction which gets translated into a raw fentry call.
112HANDLE_TARGET_OPCODE(FENTRY_CALL)
113
114/// Patchable call instruction - this instruction represents a call to a
115/// constant address, followed by a series of NOPs. It is intended to
116/// support optimizations for dynamic languages (such as javascript) that
117/// rewrite calls to runtimes with more efficient code sequences.
118/// This also implies a stack map.
119HANDLE_TARGET_OPCODE(PATCHPOINT)
120
121/// This pseudo-instruction loads the stack guard value. Targets which need
122/// to prevent the stack guard value or address from being spilled to the
123/// stack should override TargetLowering::emitLoadStackGuardNode and
124/// additionally expand this pseudo after register allocation.
125HANDLE_TARGET_OPCODE(LOAD_STACK_GUARD)
126
127/// Call instruction with associated vm state for deoptimization and list
128/// of live pointers for relocation by the garbage collector. It is
129/// intended to support garbage collection with fully precise relocating
130/// collectors and deoptimizations in either the callee or caller.
131HANDLE_TARGET_OPCODE(STATEPOINT)
132
133/// Instruction that records the offset of a local stack allocation passed to
134/// llvm.localescape. It has two arguments: the symbol for the label and the
135/// frame index of the local stack allocation.
136HANDLE_TARGET_OPCODE(LOCAL_ESCAPE)
137
138/// Wraps a machine instruction which can fault, bundled with associated
139/// information on how to handle such a fault.
140/// For example loading instruction that may page fault, bundled with associated
141/// information on how to handle such a page fault. It is intended to support
142/// "zero cost" null checks in managed languages by allowing LLVM to fold
143/// comparisons into existing memory operations.
144HANDLE_TARGET_OPCODE(FAULTING_OP)
145
146/// Wraps a machine instruction to add patchability constraints. An
147/// instruction wrapped in PATCHABLE_OP has to either have a minimum
148/// size or be preceded with a nop of that size. The first operand is
149/// an immediate denoting the minimum size of the instruction, the
150/// second operand is an immediate denoting the opcode of the original
151/// instruction. The rest of the operands are the operands of the
152/// original instruction.
153HANDLE_TARGET_OPCODE(PATCHABLE_OP)
154
155/// This is a marker instruction which gets translated into a nop sled, useful
156/// for inserting instrumentation instructions at runtime.
157HANDLE_TARGET_OPCODE(PATCHABLE_FUNCTION_ENTER)
158
159/// Wraps a return instruction and its operands to enable adding nop sleds
160/// either before or after the return. The nop sleds are useful for inserting
161/// instrumentation instructions at runtime.
162/// The patch here replaces the return instruction.
163HANDLE_TARGET_OPCODE(PATCHABLE_RET)
164
165/// This is a marker instruction which gets translated into a nop sled, useful
166/// for inserting instrumentation instructions at runtime.
167/// The patch here prepends the return instruction.
168/// The same thing as in x86_64 is not possible for ARM because it has multiple
169/// return instructions. Furthermore, CPU allows parametrized and even
170/// conditional return instructions. In the current ARM implementation we are
171/// making use of the fact that currently LLVM doesn't seem to generate
172/// conditional return instructions.
173/// On ARM, the same instruction can be used for popping multiple registers
174/// from the stack and returning (it just pops pc register too), and LLVM
175/// generates it sometimes. So we can't insert the sled between this stack
176/// adjustment and the return without splitting the original instruction into 2
177/// instructions. So on ARM, rather than jumping into the exit trampoline, we
178/// call it, it does the tracing, preserves the stack and returns.
179HANDLE_TARGET_OPCODE(PATCHABLE_FUNCTION_EXIT)
180
181/// Wraps a tail call instruction and its operands to enable adding nop sleds
182/// either before or after the tail exit. We use this as a disambiguation from
183/// PATCHABLE_RET which specifically only works for return instructions.
184HANDLE_TARGET_OPCODE(PATCHABLE_TAIL_CALL)
185
186/// Wraps a logging call and its arguments with nop sleds. At runtime, this can be
187/// patched to insert instrumentation instructions.
188HANDLE_TARGET_OPCODE(PATCHABLE_EVENT_CALL)
189
190HANDLE_TARGET_OPCODE(ICALL_BRANCH_FUNNEL)
191
192/// The following generic opcodes are not supposed to appear after ISel.
193/// This is something we might want to relax, but for now, this is convenient
194/// to produce diagnostics.
195
196/// Generic ADD instruction. This is an integer add.
197HANDLE_TARGET_OPCODE(G_ADD)
198HANDLE_TARGET_OPCODE_MARKER(PRE_ISEL_GENERIC_OPCODE_START, G_ADD)
199
200/// Generic SUB instruction. This is an integer sub.
201HANDLE_TARGET_OPCODE(G_SUB)
202
203// Generic multiply instruction.
204HANDLE_TARGET_OPCODE(G_MUL)
205
206// Generic signed division instruction.
207HANDLE_TARGET_OPCODE(G_SDIV)
208
209// Generic unsigned division instruction.
210HANDLE_TARGET_OPCODE(G_UDIV)
211
212// Generic signed remainder instruction.
213HANDLE_TARGET_OPCODE(G_SREM)
214
215// Generic unsigned remainder instruction.
216HANDLE_TARGET_OPCODE(G_UREM)
217
218/// Generic bitwise and instruction.
219HANDLE_TARGET_OPCODE(G_AND)
220
221/// Generic bitwise or instruction.
222HANDLE_TARGET_OPCODE(G_OR)
223
224/// Generic bitwise exclusive-or instruction.
225HANDLE_TARGET_OPCODE(G_XOR)
226
227
228HANDLE_TARGET_OPCODE(G_IMPLICIT_DEF)
229
230/// Generic PHI instruction with types.
231HANDLE_TARGET_OPCODE(G_PHI)
232
233/// Generic instruction to materialize the address of an alloca or other
234/// stack-based object.
235HANDLE_TARGET_OPCODE(G_FRAME_INDEX)
236
237/// Generic reference to global value.
238HANDLE_TARGET_OPCODE(G_GLOBAL_VALUE)
239
240/// Generic instruction to extract blocks of bits from the register given
241/// (typically a sub-register COPY after instruction selection).
242HANDLE_TARGET_OPCODE(G_EXTRACT)
243
244HANDLE_TARGET_OPCODE(G_UNMERGE_VALUES)
245
246/// Generic instruction to insert blocks of bits from the registers given into
247/// the source.
248HANDLE_TARGET_OPCODE(G_INSERT)
249
250/// Generic instruction to paste a variable number of components together into a
251/// larger register.
252HANDLE_TARGET_OPCODE(G_MERGE_VALUES)
253
254/// Generic pointer to int conversion.
255HANDLE_TARGET_OPCODE(G_PTRTOINT)
256
257/// Generic int to pointer conversion.
258HANDLE_TARGET_OPCODE(G_INTTOPTR)
259
260/// Generic bitcast. The source and destination types must be different, or a
261/// COPY is the relevant instruction.
262HANDLE_TARGET_OPCODE(G_BITCAST)
263
264/// Generic load.
265HANDLE_TARGET_OPCODE(G_LOAD)
266
267/// Generic store.
268HANDLE_TARGET_OPCODE(G_STORE)
269
270/// Generic atomic cmpxchg with internal success check.
271HANDLE_TARGET_OPCODE(G_ATOMIC_CMPXCHG_WITH_SUCCESS)
272
273/// Generic atomic cmpxchg.
274HANDLE_TARGET_OPCODE(G_ATOMIC_CMPXCHG)
275
276/// Generic atomicrmw.
277HANDLE_TARGET_OPCODE(G_ATOMICRMW_XCHG)
278HANDLE_TARGET_OPCODE(G_ATOMICRMW_ADD)
279HANDLE_TARGET_OPCODE(G_ATOMICRMW_SUB)
280HANDLE_TARGET_OPCODE(G_ATOMICRMW_AND)
281HANDLE_TARGET_OPCODE(G_ATOMICRMW_NAND)
282HANDLE_TARGET_OPCODE(G_ATOMICRMW_OR)
283HANDLE_TARGET_OPCODE(G_ATOMICRMW_XOR)
284HANDLE_TARGET_OPCODE(G_ATOMICRMW_MAX)
285HANDLE_TARGET_OPCODE(G_ATOMICRMW_MIN)
286HANDLE_TARGET_OPCODE(G_ATOMICRMW_UMAX)
287HANDLE_TARGET_OPCODE(G_ATOMICRMW_UMIN)
288
289/// Generic conditional branch instruction.
290HANDLE_TARGET_OPCODE(G_BRCOND)
291
292/// Generic indirect branch instruction.
293HANDLE_TARGET_OPCODE(G_BRINDIRECT)
294
295/// Generic intrinsic use (without side effects).
296HANDLE_TARGET_OPCODE(G_INTRINSIC)
297
298/// Generic intrinsic use (with side effects).
299HANDLE_TARGET_OPCODE(G_INTRINSIC_W_SIDE_EFFECTS)
300
301/// Generic extension allowing rubbish in high bits.
302HANDLE_TARGET_OPCODE(G_ANYEXT)
303
304/// Generic instruction to discard the high bits of a register. This differs
305/// from (G_EXTRACT val, 0) on its action on vectors: G_TRUNC will truncate
306/// each element individually, G_EXTRACT will typically discard the high
307/// elements of the vector.
308HANDLE_TARGET_OPCODE(G_TRUNC)
309
310/// Generic integer constant.
311HANDLE_TARGET_OPCODE(G_CONSTANT)
312
313/// Generic floating constant.
314HANDLE_TARGET_OPCODE(G_FCONSTANT)
315
316/// Generic va_start instruction. Stores to its one pointer operand.
317HANDLE_TARGET_OPCODE(G_VASTART)
318
319/// Generic va_start instruction. Stores to its one pointer operand.
320HANDLE_TARGET_OPCODE(G_VAARG)
321
322// Generic sign extend
323HANDLE_TARGET_OPCODE(G_SEXT)
324
325// Generic zero extend
326HANDLE_TARGET_OPCODE(G_ZEXT)
327
328// Generic left-shift
329HANDLE_TARGET_OPCODE(G_SHL)
330
331// Generic logical right-shift
332HANDLE_TARGET_OPCODE(G_LSHR)
333
334// Generic arithmetic right-shift
335HANDLE_TARGET_OPCODE(G_ASHR)
336
337/// Generic integer-base comparison, also applicable to vectors of integers.
338HANDLE_TARGET_OPCODE(G_ICMP)
339
340/// Generic floating-point comparison, also applicable to vectors.
341HANDLE_TARGET_OPCODE(G_FCMP)
342
343/// Generic select.
344HANDLE_TARGET_OPCODE(G_SELECT)
345
346/// Generic unsigned add instruction, consuming the normal operands plus a carry
347/// flag, and similarly producing the result and a carry flag.
348HANDLE_TARGET_OPCODE(G_UADDE)
349
350/// Generic unsigned subtract instruction, consuming the normal operands plus a
351/// carry flag, and similarly producing the result and a carry flag.
352HANDLE_TARGET_OPCODE(G_USUBE)
353
354/// Generic signed add instruction, producing the result and a signed overflow
355/// flag.
356HANDLE_TARGET_OPCODE(G_SADDO)
357
358/// Generic signed subtract instruction, producing the result and a signed
359/// overflow flag.
360HANDLE_TARGET_OPCODE(G_SSUBO)
361
362/// Generic unsigned multiply instruction, producing the result and a signed
363/// overflow flag.
364HANDLE_TARGET_OPCODE(G_UMULO)
365
366/// Generic signed multiply instruction, producing the result and a signed
367/// overflow flag.
368HANDLE_TARGET_OPCODE(G_SMULO)
369
370// Multiply two numbers at twice the incoming bit width (unsigned) and return
371// the high half of the result.
372HANDLE_TARGET_OPCODE(G_UMULH)
373
374// Multiply two numbers at twice the incoming bit width (signed) and return
375// the high half of the result.
376HANDLE_TARGET_OPCODE(G_SMULH)
377
378/// Generic FP addition.
379HANDLE_TARGET_OPCODE(G_FADD)
380
381/// Generic FP subtraction.
382HANDLE_TARGET_OPCODE(G_FSUB)
383
384/// Generic FP multiplication.
385HANDLE_TARGET_OPCODE(G_FMUL)
386
387/// Generic FMA multiplication. Behaves like llvm fma intrinsic
388HANDLE_TARGET_OPCODE(G_FMA)
389
390/// Generic FP division.
391HANDLE_TARGET_OPCODE(G_FDIV)
392
393/// Generic FP remainder.
394HANDLE_TARGET_OPCODE(G_FREM)
395
396/// Generic FP exponentiation.
397HANDLE_TARGET_OPCODE(G_FPOW)
398
399/// Generic base-e exponential of a value.
400HANDLE_TARGET_OPCODE(G_FEXP)
401
402/// Generic base-2 exponential of a value.
403HANDLE_TARGET_OPCODE(G_FEXP2)
404
405/// Floating point base-e logarithm of a value.
406HANDLE_TARGET_OPCODE(G_FLOG)
407
408/// Floating point base-2 logarithm of a value.
409HANDLE_TARGET_OPCODE(G_FLOG2)
410
411/// Generic FP negation.
412HANDLE_TARGET_OPCODE(G_FNEG)
413
414/// Generic FP extension.
415HANDLE_TARGET_OPCODE(G_FPEXT)
416
417/// Generic float to signed-int conversion
418HANDLE_TARGET_OPCODE(G_FPTRUNC)
419
420/// Generic float to signed-int conversion
421HANDLE_TARGET_OPCODE(G_FPTOSI)
422
423/// Generic float to unsigned-int conversion
424HANDLE_TARGET_OPCODE(G_FPTOUI)
425
426/// Generic signed-int to float conversion
427HANDLE_TARGET_OPCODE(G_SITOFP)
428
429/// Generic unsigned-int to float conversion
430HANDLE_TARGET_OPCODE(G_UITOFP)
431
432/// Generic FP absolute value.
433HANDLE_TARGET_OPCODE(G_FABS)
434
435/// Generic pointer offset
436HANDLE_TARGET_OPCODE(G_GEP)
437
438/// Clear the specified number of low bits in a pointer. This rounds the value
439/// *down* to the given alignment.
440HANDLE_TARGET_OPCODE(G_PTR_MASK)
441
442/// Generic BRANCH instruction. This is an unconditional branch.
443HANDLE_TARGET_OPCODE(G_BR)
444
445/// Generic insertelement.
446HANDLE_TARGET_OPCODE(G_INSERT_VECTOR_ELT)
447
448/// Generic extractelement.
449HANDLE_TARGET_OPCODE(G_EXTRACT_VECTOR_ELT)
450
451/// Generic shufflevector.
452HANDLE_TARGET_OPCODE(G_SHUFFLE_VECTOR)
453
454/// Generic byte swap.
455HANDLE_TARGET_OPCODE(G_BSWAP)
456
457// TODO: Add more generic opcodes as we move along.
458
459/// Marker for the end of the generic opcode.
460/// This is used to check if an opcode is in the range of the
461/// generic opcodes.
462HANDLE_TARGET_OPCODE_MARKER(PRE_ISEL_GENERIC_OPCODE_END, G_BSWAP)
463
464/// BUILTIN_OP_END - This must be the last enum value in this list.
465/// The target-specific post-isel opcode values start here.
466HANDLE_TARGET_OPCODE_MARKER(GENERIC_OP_END, PRE_ISEL_GENERIC_OPCODE_END)