V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
instruction-codes.h
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_COMPILER_BACKEND_INSTRUCTION_CODES_H_
6 #define V8_COMPILER_BACKEND_INSTRUCTION_CODES_H_
7 
8 #include <iosfwd>
9 
10 #if V8_TARGET_ARCH_ARM
11 #include "src/compiler/backend/arm/instruction-codes-arm.h"
12 #elif V8_TARGET_ARCH_ARM64
13 #include "src/compiler/backend/arm64/instruction-codes-arm64.h"
14 #elif V8_TARGET_ARCH_IA32
15 #include "src/compiler/backend/ia32/instruction-codes-ia32.h"
16 #elif V8_TARGET_ARCH_MIPS
17 #include "src/compiler/backend/mips/instruction-codes-mips.h"
18 #elif V8_TARGET_ARCH_MIPS64
19 #include "src/compiler/backend/mips64/instruction-codes-mips64.h"
20 #elif V8_TARGET_ARCH_X64
21 #include "src/compiler/backend/x64/instruction-codes-x64.h"
22 #elif V8_TARGET_ARCH_PPC
23 #include "src/compiler/backend/ppc/instruction-codes-ppc.h"
24 #elif V8_TARGET_ARCH_S390
25 #include "src/compiler/backend/s390/instruction-codes-s390.h"
26 #else
27 #define TARGET_ARCH_OPCODE_LIST(V)
28 #define TARGET_ADDRESSING_MODE_LIST(V)
29 #endif
30 #include "src/globals.h"
31 #include "src/utils.h"
32 
33 namespace v8 {
34 namespace internal {
35 namespace compiler {
36 
37 // Modes for ArchStoreWithWriteBarrier below.
38 enum class RecordWriteMode { kValueIsMap, kValueIsPointer, kValueIsAny };
39 
40 // Target-specific opcodes that specify which assembly sequence to emit.
41 // Most opcodes specify a single instruction.
42 #define COMMON_ARCH_OPCODE_LIST(V) \
43  V(ArchCallCodeObject) \
44  V(ArchTailCallCodeObjectFromJSFunction) \
45  V(ArchTailCallCodeObject) \
46  V(ArchCallJSFunction) \
47  V(ArchTailCallAddress) \
48  V(ArchPrepareCallCFunction) \
49  V(ArchSaveCallerRegisters) \
50  V(ArchRestoreCallerRegisters) \
51  V(ArchCallCFunction) \
52  V(ArchPrepareTailCall) \
53  V(ArchCallWasmFunction) \
54  V(ArchTailCallWasm) \
55  V(ArchJmp) \
56  V(ArchBinarySearchSwitch) \
57  V(ArchLookupSwitch) \
58  V(ArchTableSwitch) \
59  V(ArchNop) \
60  V(ArchDebugAbort) \
61  V(ArchDebugBreak) \
62  V(ArchComment) \
63  V(ArchThrowTerminator) \
64  V(ArchDeoptimize) \
65  V(ArchRet) \
66  V(ArchStackPointer) \
67  V(ArchFramePointer) \
68  V(ArchParentFramePointer) \
69  V(ArchTruncateDoubleToI) \
70  V(ArchStoreWithWriteBarrier) \
71  V(ArchStackSlot) \
72  V(ArchWordPoisonOnSpeculation) \
73  V(Word32AtomicLoadInt8) \
74  V(Word32AtomicLoadUint8) \
75  V(Word32AtomicLoadInt16) \
76  V(Word32AtomicLoadUint16) \
77  V(Word32AtomicLoadWord32) \
78  V(Word32AtomicStoreWord8) \
79  V(Word32AtomicStoreWord16) \
80  V(Word32AtomicStoreWord32) \
81  V(Word32AtomicExchangeInt8) \
82  V(Word32AtomicExchangeUint8) \
83  V(Word32AtomicExchangeInt16) \
84  V(Word32AtomicExchangeUint16) \
85  V(Word32AtomicExchangeWord32) \
86  V(Word32AtomicCompareExchangeInt8) \
87  V(Word32AtomicCompareExchangeUint8) \
88  V(Word32AtomicCompareExchangeInt16) \
89  V(Word32AtomicCompareExchangeUint16) \
90  V(Word32AtomicCompareExchangeWord32) \
91  V(Word32AtomicAddInt8) \
92  V(Word32AtomicAddUint8) \
93  V(Word32AtomicAddInt16) \
94  V(Word32AtomicAddUint16) \
95  V(Word32AtomicAddWord32) \
96  V(Word32AtomicSubInt8) \
97  V(Word32AtomicSubUint8) \
98  V(Word32AtomicSubInt16) \
99  V(Word32AtomicSubUint16) \
100  V(Word32AtomicSubWord32) \
101  V(Word32AtomicAndInt8) \
102  V(Word32AtomicAndUint8) \
103  V(Word32AtomicAndInt16) \
104  V(Word32AtomicAndUint16) \
105  V(Word32AtomicAndWord32) \
106  V(Word32AtomicOrInt8) \
107  V(Word32AtomicOrUint8) \
108  V(Word32AtomicOrInt16) \
109  V(Word32AtomicOrUint16) \
110  V(Word32AtomicOrWord32) \
111  V(Word32AtomicXorInt8) \
112  V(Word32AtomicXorUint8) \
113  V(Word32AtomicXorInt16) \
114  V(Word32AtomicXorUint16) \
115  V(Word32AtomicXorWord32) \
116  V(Ieee754Float64Acos) \
117  V(Ieee754Float64Acosh) \
118  V(Ieee754Float64Asin) \
119  V(Ieee754Float64Asinh) \
120  V(Ieee754Float64Atan) \
121  V(Ieee754Float64Atanh) \
122  V(Ieee754Float64Atan2) \
123  V(Ieee754Float64Cbrt) \
124  V(Ieee754Float64Cos) \
125  V(Ieee754Float64Cosh) \
126  V(Ieee754Float64Exp) \
127  V(Ieee754Float64Expm1) \
128  V(Ieee754Float64Log) \
129  V(Ieee754Float64Log1p) \
130  V(Ieee754Float64Log10) \
131  V(Ieee754Float64Log2) \
132  V(Ieee754Float64Pow) \
133  V(Ieee754Float64Sin) \
134  V(Ieee754Float64Sinh) \
135  V(Ieee754Float64Tan) \
136  V(Ieee754Float64Tanh)
137 
138 #define ARCH_OPCODE_LIST(V) \
139  COMMON_ARCH_OPCODE_LIST(V) \
140  TARGET_ARCH_OPCODE_LIST(V)
141 
142 enum ArchOpcode {
143 #define DECLARE_ARCH_OPCODE(Name) k##Name,
144  ARCH_OPCODE_LIST(DECLARE_ARCH_OPCODE)
145 #undef DECLARE_ARCH_OPCODE
146 #define COUNT_ARCH_OPCODE(Name) +1
147  kLastArchOpcode = -1 ARCH_OPCODE_LIST(COUNT_ARCH_OPCODE)
148 #undef COUNT_ARCH_OPCODE
149 };
150 
151 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
152  const ArchOpcode& ao);
153 
154 // Addressing modes represent the "shape" of inputs to an instruction.
155 // Many instructions support multiple addressing modes. Addressing modes
156 // are encoded into the InstructionCode of the instruction and tell the
157 // code generator after register allocation which assembler method to call.
158 #define ADDRESSING_MODE_LIST(V) \
159  V(None) \
160  TARGET_ADDRESSING_MODE_LIST(V)
161 
162 enum AddressingMode {
163 #define DECLARE_ADDRESSING_MODE(Name) kMode_##Name,
164  ADDRESSING_MODE_LIST(DECLARE_ADDRESSING_MODE)
165 #undef DECLARE_ADDRESSING_MODE
166 #define COUNT_ADDRESSING_MODE(Name) +1
167  kLastAddressingMode = -1 ADDRESSING_MODE_LIST(COUNT_ADDRESSING_MODE)
168 #undef COUNT_ADDRESSING_MODE
169 };
170 
171 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
172  const AddressingMode& am);
173 
174 // The mode of the flags continuation (see below).
175 enum FlagsMode {
176  kFlags_none = 0,
177  kFlags_branch = 1,
178  kFlags_branch_and_poison = 2,
179  kFlags_deoptimize = 3,
180  kFlags_deoptimize_and_poison = 4,
181  kFlags_set = 5,
182  kFlags_trap = 6
183 };
184 
185 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
186  const FlagsMode& fm);
187 
188 // The condition of flags continuation (see below).
189 enum FlagsCondition {
190  kEqual,
191  kNotEqual,
192  kSignedLessThan,
193  kSignedGreaterThanOrEqual,
194  kSignedLessThanOrEqual,
195  kSignedGreaterThan,
196  kUnsignedLessThan,
197  kUnsignedGreaterThanOrEqual,
198  kUnsignedLessThanOrEqual,
199  kUnsignedGreaterThan,
200  kFloatLessThanOrUnordered,
201  kFloatGreaterThanOrEqual,
202  kFloatLessThanOrEqual,
203  kFloatGreaterThanOrUnordered,
204  kFloatLessThan,
205  kFloatGreaterThanOrEqualOrUnordered,
206  kFloatLessThanOrEqualOrUnordered,
207  kFloatGreaterThan,
208  kUnorderedEqual,
209  kUnorderedNotEqual,
210  kOverflow,
211  kNotOverflow,
212  kPositiveOrZero,
213  kNegative
214 };
215 
216 inline FlagsCondition NegateFlagsCondition(FlagsCondition condition) {
217  return static_cast<FlagsCondition>(condition ^ 1);
218 }
219 
220 FlagsCondition CommuteFlagsCondition(FlagsCondition condition);
221 
222 V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
223  const FlagsCondition& fc);
224 
225 enum MemoryAccessMode {
226  kMemoryAccessDirect = 0,
227  kMemoryAccessProtected = 1,
228  kMemoryAccessPoisoned = 2
229 };
230 
231 // The InstructionCode is an opaque, target-specific integer that encodes
232 // what code to emit for an instruction in the code generator. It is not
233 // interesting to the register allocator, as the inputs and flags on the
234 // instructions specify everything of interest.
235 typedef int32_t InstructionCode;
236 
237 // Helpers for encoding / decoding InstructionCode into the fields needed
238 // for code generation. We encode the instruction, addressing mode, and flags
239 // continuation into a single InstructionCode which is stored as part of
240 // the instruction.
241 typedef BitField<ArchOpcode, 0, 9> ArchOpcodeField;
242 typedef BitField<AddressingMode, 9, 5> AddressingModeField;
243 typedef BitField<FlagsMode, 14, 3> FlagsModeField;
244 typedef BitField<FlagsCondition, 17, 5> FlagsConditionField;
245 typedef BitField<int, 22, 10> MiscField;
246 
247 } // namespace compiler
248 } // namespace internal
249 } // namespace v8
250 
251 #endif // V8_COMPILER_BACKEND_INSTRUCTION_CODES_H_
Definition: libplatform.h:13