Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Side by Side Diff: src/a64/decoder-a64.cc

Issue 181233002: A64: Move the dispatching logic of the decoder to a separate class. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/a64/decoder-a64.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 19 matching lines...) Expand all
30 #if V8_TARGET_ARCH_A64 30 #if V8_TARGET_ARCH_A64
31 31
32 #include "globals.h" 32 #include "globals.h"
33 #include "utils.h" 33 #include "utils.h"
34 #include "a64/decoder-a64.h" 34 #include "a64/decoder-a64.h"
35 35
36 36
37 namespace v8 { 37 namespace v8 {
38 namespace internal { 38 namespace internal {
39 39
40
41 void DispatchingDecoderVisitor::AppendVisitor(DecoderVisitor* new_visitor) {
42 visitors_.remove(new_visitor);
43 visitors_.push_front(new_visitor);
44 }
45
46
47 void DispatchingDecoderVisitor::PrependVisitor(DecoderVisitor* new_visitor) {
48 visitors_.remove(new_visitor);
49 visitors_.push_back(new_visitor);
50 }
51
52
53 void DispatchingDecoderVisitor::InsertVisitorBefore(
54 DecoderVisitor* new_visitor, DecoderVisitor* registered_visitor) {
55 visitors_.remove(new_visitor);
56 std::list<DecoderVisitor*>::iterator it;
57 for (it = visitors_.begin(); it != visitors_.end(); it++) {
58 if (*it == registered_visitor) {
59 visitors_.insert(it, new_visitor);
60 return;
61 }
62 }
63 // We reached the end of the list. The last element must be
64 // registered_visitor.
65 ASSERT(*it == registered_visitor);
66 visitors_.insert(it, new_visitor);
67 }
68
69
70 void DispatchingDecoderVisitor::InsertVisitorAfter(
71 DecoderVisitor* new_visitor, DecoderVisitor* registered_visitor) {
72 visitors_.remove(new_visitor);
73 std::list<DecoderVisitor*>::iterator it;
74 for (it = visitors_.begin(); it != visitors_.end(); it++) {
75 if (*it == registered_visitor) {
76 it++;
77 visitors_.insert(it, new_visitor);
78 return;
79 }
80 }
81 // We reached the end of the list. The last element must be
82 // registered_visitor.
83 ASSERT(*it == registered_visitor);
84 visitors_.push_back(new_visitor);
85 }
86
87
88 void DispatchingDecoderVisitor::RemoveVisitor(DecoderVisitor* visitor) {
89 visitors_.remove(visitor);
90 }
91
92
93 #define DEFINE_VISITOR_CALLERS(A) \
94 void DispatchingDecoderVisitor::Visit##A(Instruction* instr) { \
95 if (!(instr->Mask(A##FMask) == A##Fixed)) { \
96 ASSERT(instr->Mask(A##FMask) == A##Fixed); \
97 } \
98 std::list<DecoderVisitor*>::iterator it; \
99 for (it = visitors_.begin(); it != visitors_.end(); it++) { \
100 (*it)->Visit##A(instr); \
101 } \
102 }
103 VISITOR_LIST(DEFINE_VISITOR_CALLERS)
104 #undef DEFINE_VISITOR_CALLERS
105
106
40 // Top-level instruction decode function. 107 // Top-level instruction decode function.
41 void Decoder::Decode(Instruction *instr) { 108 void Decoder::Decode(Instruction *instr) {
42 if (instr->Bits(28, 27) == 0) { 109 if (instr->Bits(28, 27) == 0) {
43 VisitUnallocated(instr); 110 VisitUnallocated(instr);
44 } else { 111 } else {
45 switch (instr->Bits(27, 24)) { 112 switch (instr->Bits(27, 24)) {
46 // 0: PC relative addressing. 113 // 0: PC relative addressing.
47 case 0x0: DecodePCRelAddressing(instr); break; 114 case 0x0: DecodePCRelAddressing(instr); break;
48 115
49 // 1: Add/sub immediate. 116 // 1: Add/sub immediate.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // Advanced SIMD. 176 // Advanced SIMD.
110 // F: FP data processing 3 source. 177 // F: FP data processing 3 source.
111 // Advanced SIMD. 178 // Advanced SIMD.
112 case 0xE: 179 case 0xE:
113 case 0xF: DecodeFP(instr); break; 180 case 0xF: DecodeFP(instr); break;
114 } 181 }
115 } 182 }
116 } 183 }
117 184
118 185
119 void Decoder::AppendVisitor(DecoderVisitor* new_visitor) {
120 visitors_.remove(new_visitor);
121 visitors_.push_front(new_visitor);
122 }
123
124
125 void Decoder::PrependVisitor(DecoderVisitor* new_visitor) {
126 visitors_.remove(new_visitor);
127 visitors_.push_back(new_visitor);
128 }
129
130
131 void Decoder::InsertVisitorBefore(DecoderVisitor* new_visitor,
132 DecoderVisitor* registered_visitor) {
133 visitors_.remove(new_visitor);
134 std::list<DecoderVisitor*>::iterator it;
135 for (it = visitors_.begin(); it != visitors_.end(); it++) {
136 if (*it == registered_visitor) {
137 visitors_.insert(it, new_visitor);
138 return;
139 }
140 }
141 // We reached the end of the list. The last element must be
142 // registered_visitor.
143 ASSERT(*it == registered_visitor);
144 visitors_.insert(it, new_visitor);
145 }
146
147
148 void Decoder::InsertVisitorAfter(DecoderVisitor* new_visitor,
149 DecoderVisitor* registered_visitor) {
150 visitors_.remove(new_visitor);
151 std::list<DecoderVisitor*>::iterator it;
152 for (it = visitors_.begin(); it != visitors_.end(); it++) {
153 if (*it == registered_visitor) {
154 it++;
155 visitors_.insert(it, new_visitor);
156 return;
157 }
158 }
159 // We reached the end of the list. The last element must be
160 // registered_visitor.
161 ASSERT(*it == registered_visitor);
162 visitors_.push_back(new_visitor);
163 }
164
165
166 void Decoder::RemoveVisitor(DecoderVisitor* visitor) {
167 visitors_.remove(visitor);
168 }
169
170
171 void Decoder::DecodePCRelAddressing(Instruction* instr) { 186 void Decoder::DecodePCRelAddressing(Instruction* instr) {
172 ASSERT(instr->Bits(27, 24) == 0x0); 187 ASSERT(instr->Bits(27, 24) == 0x0);
173 // We know bit 28 is set, as <b28:b27> = 0 is filtered out at the top level 188 // We know bit 28 is set, as <b28:b27> = 0 is filtered out at the top level
174 // decode. 189 // decode.
175 ASSERT(instr->Bit(28) == 0x1); 190 ASSERT(instr->Bit(28) == 0x1);
176 VisitPCRelAddressing(instr); 191 VisitPCRelAddressing(instr);
177 } 192 }
178 193
179 194
180 void Decoder::DecodeBranchSystemException(Instruction* instr) { 195 void Decoder::DecodeBranchSystemException(Instruction* instr) {
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 } 715 }
701 716
702 717
703 void Decoder::DecodeAdvSIMDDataProcessing(Instruction* instr) { 718 void Decoder::DecodeAdvSIMDDataProcessing(Instruction* instr) {
704 // TODO(all): Implement Advanced SIMD data processing instruction decode. 719 // TODO(all): Implement Advanced SIMD data processing instruction decode.
705 ASSERT(instr->Bits(27, 25) == 0x7); 720 ASSERT(instr->Bits(27, 25) == 0x7);
706 VisitUnimplemented(instr); 721 VisitUnimplemented(instr);
707 } 722 }
708 723
709 724
710 #define DEFINE_VISITOR_CALLERS(A) \
711 void Decoder::Visit##A(Instruction *instr) { \
712 if (!(instr->Mask(A##FMask) == A##Fixed)) { \
713 ASSERT(instr->Mask(A##FMask) == A##Fixed); \
714 } \
715 std::list<DecoderVisitor*>::iterator it; \
716 for (it = visitors_.begin(); it != visitors_.end(); it++) { \
717 (*it)->Visit##A(instr); \
718 } \
719 }
720 VISITOR_LIST(DEFINE_VISITOR_CALLERS)
721 #undef DEFINE_VISITOR_CALLERS
722
723
724 } } // namespace v8::internal 725 } } // namespace v8::internal
725 726
726 #endif // V8_TARGET_ARCH_A64 727 #endif // V8_TARGET_ARCH_A64
OLDNEW
« no previous file with comments | « src/a64/decoder-a64.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698