v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
decoder-arm64.h
Go to the documentation of this file.
1// Copyright 2013 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_CODEGEN_ARM64_DECODER_ARM64_H_
6#define V8_CODEGEN_ARM64_DECODER_ARM64_H_
7
8#include <list>
9
11#include "src/common/globals.h"
12
13namespace v8 {
14namespace internal {
15
16// List macro containing all visitors needed by the decoder class.
17
18#define VISITOR_LIST(V) \
19 V(PCRelAddressing) \
20 V(AddSubImmediate) \
21 V(LogicalImmediate) \
22 V(MoveWideImmediate) \
23 V(Bitfield) \
24 V(Extract) \
25 V(UnconditionalBranch) \
26 V(UnconditionalBranchToRegister) \
27 V(CompareBranch) \
28 V(TestBranch) \
29 V(ConditionalBranch) \
30 V(System) \
31 V(Exception) \
32 V(LoadStorePairPostIndex) \
33 V(LoadStorePairOffset) \
34 V(LoadStorePairPreIndex) \
35 V(LoadLiteral) \
36 V(LoadStoreUnscaledOffset) \
37 V(LoadStorePostIndex) \
38 V(LoadStorePreIndex) \
39 V(LoadStoreRegisterOffset) \
40 V(LoadStoreUnsignedOffset) \
41 V(LoadStoreAcquireRelease) \
42 V(AtomicMemory) \
43 V(LogicalShifted) \
44 V(AddSubShifted) \
45 V(AddSubExtended) \
46 V(AddSubWithCarry) \
47 V(ConditionalCompareRegister) \
48 V(ConditionalCompareImmediate) \
49 V(ConditionalSelect) \
50 V(DataProcessing1Source) \
51 V(DataProcessing2Source) \
52 V(DataProcessing3Source) \
53 V(FPCompare) \
54 V(FPConditionalCompare) \
55 V(FPConditionalSelect) \
56 V(FPImmediate) \
57 V(FPDataProcessing1Source) \
58 V(FPDataProcessing2Source) \
59 V(FPDataProcessing3Source) \
60 V(FPIntegerConvert) \
61 V(FPFixedPointConvert) \
62 V(NEON2RegMisc) \
63 V(NEON3Different) \
64 V(NEON3Extension) \
65 V(NEON3Same) \
66 V(NEON3SameHP) \
67 V(NEONAcrossLanes) \
68 V(NEONByIndexedElement) \
69 V(NEONCopy) \
70 V(NEONExtract) \
71 V(NEONLoadStoreMultiStruct) \
72 V(NEONLoadStoreMultiStructPostIndex) \
73 V(NEONLoadStoreSingleStruct) \
74 V(NEONLoadStoreSingleStructPostIndex) \
75 V(NEONModifiedImmediate) \
76 V(NEONScalar2RegMisc) \
77 V(NEONScalar3Diff) \
78 V(NEONScalar3Same) \
79 V(NEONScalarByIndexedElement) \
80 V(NEONScalarCopy) \
81 V(NEONScalarPairwise) \
82 V(NEONScalarShiftImmediate) \
83 V(NEONShiftImmediate) \
84 V(NEONTable) \
85 V(NEONPerm) \
86 V(NEONSHA3) \
87 V(Unallocated) \
88 V(Unimplemented)
89
90// The Visitor interface. Disassembler and simulator (and other tools)
91// must provide implementations for all of these functions.
93 public:
94 virtual ~DecoderVisitor() {}
95
96#define DECLARE(A) virtual void Visit##A(Instruction* instr) = 0;
98#undef DECLARE
99};
100
101// A visitor that dispatches to a list of visitors.
103 public:
106
107 // Register a new visitor class with the decoder.
108 // Decode() will call the corresponding visitor method from all registered
109 // visitor classes when decoding reaches the leaf node of the instruction
110 // decode tree.
111 // Visitors are called in the order.
112 // A visitor can only be registered once.
113 // Registering an already registered visitor will update its position.
114 //
115 // d.AppendVisitor(V1);
116 // d.AppendVisitor(V2);
117 // d.PrependVisitor(V2); // Move V2 at the start of the list.
118 // d.InsertVisitorBefore(V3, V2);
119 // d.AppendVisitor(V4);
120 // d.AppendVisitor(V4); // No effect.
121 //
122 // d.Decode(i);
123 //
124 // will call in order visitor methods in V3, V2, V1, V4.
128 DecoderVisitor* registered_visitor);
130 DecoderVisitor* registered_visitor);
131
132 // Remove a previously registered visitor class from the list of visitors
133 // stored by the decoder.
135
137
138#define DECLARE(A) void Visit##A(Instruction* instr);
140#undef DECLARE
141
142 private:
143 // Visitors are registered in a list.
144 std::list<DecoderVisitor*> visitors_;
145};
146
147template <typename V>
148class Decoder : public V {
149 public:
151 virtual ~Decoder() {}
152
153 // Top-level instruction decoder function. Decodes an instruction and calls
154 // the visitor functions registered with the Decoder class.
155 virtual void Decode(Instruction* instr);
156
157 private:
158 // Decode the PC relative addressing instruction, and call the corresponding
159 // visitors.
160 // On entry, instruction bits 27:24 = 0x0.
162
163 // Decode the add/subtract immediate instruction, and call the corresponding
164 // visitors.
165 // On entry, instruction bits 27:24 = 0x1.
167
168 // Decode the branch, system command, and exception generation parts of
169 // the instruction tree, and call the corresponding visitors.
170 // On entry, instruction bits 27:24 = {0x4, 0x5, 0x6, 0x7}.
172
173 // Decode the load and store parts of the instruction tree, and call
174 // the corresponding visitors.
175 // On entry, instruction bits 27:24 = {0x8, 0x9, 0xC, 0xD}.
177
178 // Decode the logical immediate and move wide immediate parts of the
179 // instruction tree, and call the corresponding visitors.
180 // On entry, instruction bits 27:24 = 0x2.
182
183 // Decode the bitfield and extraction parts of the instruction tree,
184 // and call the corresponding visitors.
185 // On entry, instruction bits 27:24 = 0x3.
187
188 // Decode the data processing parts of the instruction tree, and call the
189 // corresponding visitors.
190 // On entry, instruction bits 27:24 = {0x1, 0xA, 0xB}.
192
193 // Decode the floating point parts of the instruction tree, and call the
194 // corresponding visitors.
195 // On entry, instruction bits 27:24 = {0xE, 0xF}.
197
198 // Decode the Advanced SIMD (NEON) load/store part of the instruction tree,
199 // and call the corresponding visitors.
200 // On entry, instruction bits 29:25 = 0x6.
202
203 // Decode the Advanced SIMD (NEON) data processing part of the instruction
204 // tree, and call the corresponding visitors.
205 // On entry, instruction bits 27:25 = 0x7.
207
208 // Decode the Advanced SIMD (NEON) scalar data processing part of the
209 // instruction tree, and call the corresponding visitors.
210 // On entry, instruction bits 28:25 = 0xF.
212};
213
214} // namespace internal
215} // namespace v8
216
217#endif // V8_CODEGEN_ARM64_DECODER_ARM64_H_
void DecodePCRelAddressing(Instruction *instr)
void DecodeNEONLoadStore(Instruction *instr)
void DecodeDataProcessing(Instruction *instr)
void DecodeLogical(Instruction *instr)
void DecodeAddSubImmediate(Instruction *instr)
void DecodeLoadStore(Instruction *instr)
virtual void Decode(Instruction *instr)
void DecodeFP(Instruction *instr)
void DecodeBitfieldExtract(Instruction *instr)
void DecodeBranchSystemException(Instruction *instr)
void DecodeNEONVectorDataProcessing(Instruction *instr)
void DecodeNEONScalarDataProcessing(Instruction *instr)
void InsertVisitorBefore(DecoderVisitor *new_visitor, DecoderVisitor *registered_visitor)
void AppendVisitor(DecoderVisitor *visitor)
std::list< DecoderVisitor * > visitors_
void InsertVisitorAfter(DecoderVisitor *new_visitor, DecoderVisitor *registered_visitor)
void PrependVisitor(DecoderVisitor *visitor)
void VisitNEONShiftImmediate(const Instruction *instr)
void RemoveVisitor(DecoderVisitor *visitor)
#define VISITOR_LIST(V)
#define DECLARE(A)
Instruction * instr
#define V8_EXPORT_PRIVATE
Definition macros.h:460