V8 Project
instruction-codes.h
Go to the documentation of this file.
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_INSTRUCTION_CODES_H_
6 #define V8_COMPILER_INSTRUCTION_CODES_H_
7 
8 #if V8_TARGET_ARCH_ARM
10 #elif V8_TARGET_ARCH_ARM64
12 #elif V8_TARGET_ARCH_IA32
14 #elif V8_TARGET_ARCH_X64
16 #else
17 #define TARGET_ARCH_OPCODE_LIST(V)
18 #define TARGET_ADDRESSING_MODE_LIST(V)
19 #endif
20 #include "src/utils.h"
21 
22 namespace v8 {
23 namespace internal {
24 
25 class OStream;
26 
27 namespace compiler {
28 
29 // Target-specific opcodes that specify which assembly sequence to emit.
30 // Most opcodes specify a single instruction.
31 #define ARCH_OPCODE_LIST(V) \
32  V(ArchCallCodeObject) \
33  V(ArchCallJSFunction) \
34  V(ArchJmp) \
35  V(ArchNop) \
36  V(ArchRet) \
37  V(ArchTruncateDoubleToI) \
38  TARGET_ARCH_OPCODE_LIST(V)
39 
40 enum ArchOpcode {
41 #define DECLARE_ARCH_OPCODE(Name) k##Name,
43 #undef DECLARE_ARCH_OPCODE
44 #define COUNT_ARCH_OPCODE(Name) +1
46 #undef COUNT_ARCH_OPCODE
47 };
48 
49 OStream& operator<<(OStream& os, const ArchOpcode& ao);
50 
51 // Addressing modes represent the "shape" of inputs to an instruction.
52 // Many instructions support multiple addressing modes. Addressing modes
53 // are encoded into the InstructionCode of the instruction and tell the
54 // code generator after register allocation which assembler method to call.
55 #define ADDRESSING_MODE_LIST(V) \
56  V(None) \
57  TARGET_ADDRESSING_MODE_LIST(V)
58 
60 #define DECLARE_ADDRESSING_MODE(Name) kMode_##Name,
62 #undef DECLARE_ADDRESSING_MODE
63 #define COUNT_ADDRESSING_MODE(Name) +1
65 #undef COUNT_ADDRESSING_MODE
66 };
67 
68 OStream& operator<<(OStream& os, const AddressingMode& am);
69 
70 // The mode of the flags continuation (see below).
72 
73 OStream& operator<<(OStream& os, const FlagsMode& fm);
74 
75 // The condition of flags continuation (see below).
95 };
96 
97 OStream& operator<<(OStream& os, const FlagsCondition& fc);
98 
99 // The InstructionCode is an opaque, target-specific integer that encodes
100 // what code to emit for an instruction in the code generator. It is not
101 // interesting to the register allocator, as the inputs and flags on the
102 // instructions specify everything of interest.
104 
105 // Helpers for encoding / decoding InstructionCode into the fields needed
106 // for code generation. We encode the instruction, addressing mode, and flags
107 // continuation into a single InstructionCode which is stored as part of
108 // the instruction.
114 
115 } // namespace compiler
116 } // namespace internal
117 } // namespace v8
118 
119 #endif // V8_COMPILER_INSTRUCTION_CODES_H_
#define COUNT_ARCH_OPCODE(Name)
#define COUNT_ADDRESSING_MODE(Name)
#define ARCH_OPCODE_LIST(V)
#define DECLARE_ADDRESSING_MODE(Name)
#define DECLARE_ARCH_OPCODE(Name)
#define ADDRESSING_MODE_LIST(V)
int int32_t
Definition: unicode.cc:24
BitField< FlagsCondition, 14, 5 > FlagsConditionField
std::ostream & operator<<(std::ostream &os, const MachineType &type)
BitField< int, 14, 18 > MiscField
BitField< ArchOpcode, 0, 7 > ArchOpcodeField
BitField< FlagsMode, 12, 2 > FlagsModeField
BitField< AddressingMode, 7, 5 > AddressingModeField
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20