Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / v8 / src / compiler / 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_INSTRUCTION_CODES_H_
6 #define V8_COMPILER_INSTRUCTION_CODES_H_
7
8 #if V8_TARGET_ARCH_ARM
9 #include "src/compiler/arm/instruction-codes-arm.h"
10 #elif V8_TARGET_ARCH_ARM64
11 #include "src/compiler/arm64/instruction-codes-arm64.h"
12 #elif V8_TARGET_ARCH_IA32
13 #include "src/compiler/ia32/instruction-codes-ia32.h"
14 #elif V8_TARGET_ARCH_X64
15 #include "src/compiler/x64/instruction-codes-x64.h"
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(ArchDeoptimize)         \
33   V(ArchJmp)                \
34   V(ArchNop)                \
35   V(ArchRet)                \
36   TARGET_ARCH_OPCODE_LIST(V)
37
38 enum ArchOpcode {
39 #define DECLARE_ARCH_OPCODE(Name) k##Name,
40   ARCH_OPCODE_LIST(DECLARE_ARCH_OPCODE)
41 #undef DECLARE_ARCH_OPCODE
42 #define COUNT_ARCH_OPCODE(Name) +1
43   kLastArchOpcode = -1 ARCH_OPCODE_LIST(COUNT_ARCH_OPCODE)
44 #undef COUNT_ARCH_OPCODE
45 };
46
47 OStream& operator<<(OStream& os, const ArchOpcode& ao);
48
49 // Addressing modes represent the "shape" of inputs to an instruction.
50 // Many instructions support multiple addressing modes. Addressing modes
51 // are encoded into the InstructionCode of the instruction and tell the
52 // code generator after register allocation which assembler method to call.
53 #define ADDRESSING_MODE_LIST(V) \
54   V(None)                       \
55   TARGET_ADDRESSING_MODE_LIST(V)
56
57 enum AddressingMode {
58 #define DECLARE_ADDRESSING_MODE(Name) kMode_##Name,
59   ADDRESSING_MODE_LIST(DECLARE_ADDRESSING_MODE)
60 #undef DECLARE_ADDRESSING_MODE
61 #define COUNT_ADDRESSING_MODE(Name) +1
62   kLastAddressingMode = -1 ADDRESSING_MODE_LIST(COUNT_ADDRESSING_MODE)
63 #undef COUNT_ADDRESSING_MODE
64 };
65
66 OStream& operator<<(OStream& os, const AddressingMode& am);
67
68 // The mode of the flags continuation (see below).
69 enum FlagsMode { kFlags_none = 0, kFlags_branch = 1, kFlags_set = 2 };
70
71 OStream& operator<<(OStream& os, const FlagsMode& fm);
72
73 // The condition of flags continuation (see below).
74 enum FlagsCondition {
75   kEqual,
76   kNotEqual,
77   kSignedLessThan,
78   kSignedGreaterThanOrEqual,
79   kSignedLessThanOrEqual,
80   kSignedGreaterThan,
81   kUnsignedLessThan,
82   kUnsignedGreaterThanOrEqual,
83   kUnsignedLessThanOrEqual,
84   kUnsignedGreaterThan,
85   kUnorderedEqual,
86   kUnorderedNotEqual,
87   kUnorderedLessThan,
88   kUnorderedGreaterThanOrEqual,
89   kUnorderedLessThanOrEqual,
90   kUnorderedGreaterThan,
91   kOverflow,
92   kNotOverflow
93 };
94
95 OStream& operator<<(OStream& os, const FlagsCondition& fc);
96
97 // The InstructionCode is an opaque, target-specific integer that encodes
98 // what code to emit for an instruction in the code generator. It is not
99 // interesting to the register allocator, as the inputs and flags on the
100 // instructions specify everything of interest.
101 typedef int32_t InstructionCode;
102
103 // Helpers for encoding / decoding InstructionCode into the fields needed
104 // for code generation. We encode the instruction, addressing mode, and flags
105 // continuation into a single InstructionCode which is stored as part of
106 // the instruction.
107 typedef BitField<ArchOpcode, 0, 7> ArchOpcodeField;
108 typedef BitField<AddressingMode, 7, 4> AddressingModeField;
109 typedef BitField<FlagsMode, 11, 2> FlagsModeField;
110 typedef BitField<FlagsCondition, 13, 5> FlagsConditionField;
111 typedef BitField<int, 13, 19> MiscField;
112
113 }  // namespace compiler
114 }  // namespace internal
115 }  // namespace v8
116
117 #endif  // V8_COMPILER_INSTRUCTION_CODES_H_