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

Side by Side Diff: src/crankshaft/s390/lithium-gap-resolver-s390.cc

Issue 1763233003: S390: Initial Impl of Crankshaft features (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « src/crankshaft/s390/lithium-gap-resolver-s390.h ('k') | src/crankshaft/s390/lithium-s390.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/crankshaft/ppc/lithium-gap-resolver-ppc.h" 5 #include "src/crankshaft/s390/lithium-gap-resolver-s390.h"
6 6
7 #include "src/crankshaft/ppc/lithium-codegen-ppc.h" 7 #include "src/crankshaft/s390/lithium-codegen-s390.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
11 11
12 static const Register kSavedValueRegister = {11}; 12 static const Register kSavedValueRegister = {1};
13 13
14 LGapResolver::LGapResolver(LCodeGen* owner) 14 LGapResolver::LGapResolver(LCodeGen* owner)
15 : cgen_(owner), 15 : cgen_(owner),
16 moves_(32, owner->zone()), 16 moves_(32, owner->zone()),
17 root_index_(0), 17 root_index_(0),
18 in_cycle_(false), 18 in_cycle_(false),
19 saved_destination_(NULL) {} 19 saved_destination_(NULL) {}
20 20
21
22 void LGapResolver::Resolve(LParallelMove* parallel_move) { 21 void LGapResolver::Resolve(LParallelMove* parallel_move) {
23 DCHECK(moves_.is_empty()); 22 DCHECK(moves_.is_empty());
24 // Build up a worklist of moves. 23 // Build up a worklist of moves.
25 BuildInitialMoveList(parallel_move); 24 BuildInitialMoveList(parallel_move);
26 25
27 for (int i = 0; i < moves_.length(); ++i) { 26 for (int i = 0; i < moves_.length(); ++i) {
28 LMoveOperands move = moves_[i]; 27 LMoveOperands move = moves_[i];
29 // Skip constants to perform them last. They don't block other moves 28 // Skip constants to perform them last. They don't block other moves
30 // and skipping such moves with register destinations keeps those 29 // and skipping such moves with register destinations keeps those
31 // registers free for the whole algorithm. 30 // registers free for the whole algorithm.
(...skipping 10 matching lines...) Expand all
42 for (int i = 0; i < moves_.length(); ++i) { 41 for (int i = 0; i < moves_.length(); ++i) {
43 if (!moves_[i].IsEliminated()) { 42 if (!moves_[i].IsEliminated()) {
44 DCHECK(moves_[i].source()->IsConstantOperand()); 43 DCHECK(moves_[i].source()->IsConstantOperand());
45 EmitMove(i); 44 EmitMove(i);
46 } 45 }
47 } 46 }
48 47
49 moves_.Rewind(0); 48 moves_.Rewind(0);
50 } 49 }
51 50
52
53 void LGapResolver::BuildInitialMoveList(LParallelMove* parallel_move) { 51 void LGapResolver::BuildInitialMoveList(LParallelMove* parallel_move) {
54 // Perform a linear sweep of the moves to add them to the initial list of 52 // Perform a linear sweep of the moves to add them to the initial list of
55 // moves to perform, ignoring any move that is redundant (the source is 53 // moves to perform, ignoring any move that is redundant (the source is
56 // the same as the destination, the destination is ignored and 54 // the same as the destination, the destination is ignored and
57 // unallocated, or the move was already eliminated). 55 // unallocated, or the move was already eliminated).
58 const ZoneList<LMoveOperands>* moves = parallel_move->move_operands(); 56 const ZoneList<LMoveOperands>* moves = parallel_move->move_operands();
59 for (int i = 0; i < moves->length(); ++i) { 57 for (int i = 0; i < moves->length(); ++i) {
60 LMoveOperands move = moves->at(i); 58 LMoveOperands move = moves->at(i);
61 if (!move.IsRedundant()) moves_.Add(move, cgen_->zone()); 59 if (!move.IsRedundant()) moves_.Add(move, cgen_->zone());
62 } 60 }
63 Verify(); 61 Verify();
64 } 62 }
65 63
66
67 void LGapResolver::PerformMove(int index) { 64 void LGapResolver::PerformMove(int index) {
68 // Each call to this function performs a move and deletes it from the move 65 // Each call to this function performs a move and deletes it from the move
69 // graph. We first recursively perform any move blocking this one. We 66 // graph. We first recursively perform any move blocking this one. We
70 // mark a move as "pending" on entry to PerformMove in order to detect 67 // mark a move as "pending" on entry to PerformMove in order to detect
71 // cycles in the move graph. 68 // cycles in the move graph.
72 69
73 // We can only find a cycle, when doing a depth-first traversal of moves, 70 // We can only find a cycle, when doing a depth-first traversal of moves,
74 // be encountering the starting move again. So by spilling the source of 71 // be encountering the starting move again. So by spilling the source of
75 // the starting move, we break the cycle. All moves are then unblocked, 72 // the starting move, we break the cycle. All moves are then unblocked,
76 // and the starting move is completed by writing the spilled value to 73 // and the starting move is completed by writing the spilled value to
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 if (other_move.Blocks(destination)) { 111 if (other_move.Blocks(destination)) {
115 DCHECK(other_move.IsPending()); 112 DCHECK(other_move.IsPending());
116 BreakCycle(index); 113 BreakCycle(index);
117 return; 114 return;
118 } 115 }
119 116
120 // This move is no longer blocked. 117 // This move is no longer blocked.
121 EmitMove(index); 118 EmitMove(index);
122 } 119 }
123 120
124
125 void LGapResolver::Verify() { 121 void LGapResolver::Verify() {
126 #ifdef ENABLE_SLOW_DCHECKS 122 #ifdef ENABLE_SLOW_DCHECKS
127 // No operand should be the destination for more than one move. 123 // No operand should be the destination for more than one move.
128 for (int i = 0; i < moves_.length(); ++i) { 124 for (int i = 0; i < moves_.length(); ++i) {
129 LOperand* destination = moves_[i].destination(); 125 LOperand* destination = moves_[i].destination();
130 for (int j = i + 1; j < moves_.length(); ++j) { 126 for (int j = i + 1; j < moves_.length(); ++j) {
131 SLOW_DCHECK(!destination->Equals(moves_[j].destination())); 127 SLOW_DCHECK(!destination->Equals(moves_[j].destination()));
132 } 128 }
133 } 129 }
134 #endif 130 #endif
135 } 131 }
136 132
137 #define __ ACCESS_MASM(cgen_->masm()) 133 #define __ ACCESS_MASM(cgen_->masm())
138 134
139 void LGapResolver::BreakCycle(int index) { 135 void LGapResolver::BreakCycle(int index) {
140 // We save in a register the value that should end up in the source of 136 // We save in a register the value that should end up in the source of
141 // moves_[root_index]. After performing all moves in the tree rooted 137 // moves_[root_index]. After performing all moves in the tree rooted
142 // in that move, we save the value to that source. 138 // in that move, we save the value to that source.
143 DCHECK(moves_[index].destination()->Equals(moves_[root_index_].source())); 139 DCHECK(moves_[index].destination()->Equals(moves_[root_index_].source()));
144 DCHECK(!in_cycle_); 140 DCHECK(!in_cycle_);
145 in_cycle_ = true; 141 in_cycle_ = true;
146 LOperand* source = moves_[index].source(); 142 LOperand* source = moves_[index].source();
147 saved_destination_ = moves_[index].destination(); 143 saved_destination_ = moves_[index].destination();
148 if (source->IsRegister()) { 144 if (source->IsRegister()) {
149 __ mr(kSavedValueRegister, cgen_->ToRegister(source)); 145 __ LoadRR(kSavedValueRegister, cgen_->ToRegister(source));
150 } else if (source->IsStackSlot()) { 146 } else if (source->IsStackSlot()) {
151 __ LoadP(kSavedValueRegister, cgen_->ToMemOperand(source)); 147 __ LoadP(kSavedValueRegister, cgen_->ToMemOperand(source));
152 } else if (source->IsDoubleRegister()) { 148 } else if (source->IsDoubleRegister()) {
153 __ fmr(kScratchDoubleReg, cgen_->ToDoubleRegister(source)); 149 __ ldr(kScratchDoubleReg, cgen_->ToDoubleRegister(source));
154 } else if (source->IsDoubleStackSlot()) { 150 } else if (source->IsDoubleStackSlot()) {
155 __ lfd(kScratchDoubleReg, cgen_->ToMemOperand(source)); 151 __ LoadDouble(kScratchDoubleReg, cgen_->ToMemOperand(source));
156 } else { 152 } else {
157 UNREACHABLE(); 153 UNREACHABLE();
158 } 154 }
159 // This move will be done by restoring the saved value to the destination. 155 // This move will be done by restoring the saved value to the destination.
160 moves_[index].Eliminate(); 156 moves_[index].Eliminate();
161 } 157 }
162 158
163
164 void LGapResolver::RestoreValue() { 159 void LGapResolver::RestoreValue() {
165 DCHECK(in_cycle_); 160 DCHECK(in_cycle_);
166 DCHECK(saved_destination_ != NULL); 161 DCHECK(saved_destination_ != NULL);
167 162
168 // Spilled value is in kSavedValueRegister or kSavedDoubleValueRegister. 163 // Spilled value is in kSavedValueRegister or kSavedDoubleValueRegister.
169 if (saved_destination_->IsRegister()) { 164 if (saved_destination_->IsRegister()) {
170 __ mr(cgen_->ToRegister(saved_destination_), kSavedValueRegister); 165 __ LoadRR(cgen_->ToRegister(saved_destination_), kSavedValueRegister);
171 } else if (saved_destination_->IsStackSlot()) { 166 } else if (saved_destination_->IsStackSlot()) {
172 __ StoreP(kSavedValueRegister, cgen_->ToMemOperand(saved_destination_)); 167 __ StoreP(kSavedValueRegister, cgen_->ToMemOperand(saved_destination_));
173 } else if (saved_destination_->IsDoubleRegister()) { 168 } else if (saved_destination_->IsDoubleRegister()) {
174 __ fmr(cgen_->ToDoubleRegister(saved_destination_), kScratchDoubleReg); 169 __ ldr(cgen_->ToDoubleRegister(saved_destination_), kScratchDoubleReg);
175 } else if (saved_destination_->IsDoubleStackSlot()) { 170 } else if (saved_destination_->IsDoubleStackSlot()) {
176 __ stfd(kScratchDoubleReg, cgen_->ToMemOperand(saved_destination_)); 171 __ StoreDouble(kScratchDoubleReg, cgen_->ToMemOperand(saved_destination_));
177 } else { 172 } else {
178 UNREACHABLE(); 173 UNREACHABLE();
179 } 174 }
180 175
181 in_cycle_ = false; 176 in_cycle_ = false;
182 saved_destination_ = NULL; 177 saved_destination_ = NULL;
183 } 178 }
184 179
185
186 void LGapResolver::EmitMove(int index) { 180 void LGapResolver::EmitMove(int index) {
187 LOperand* source = moves_[index].source(); 181 LOperand* source = moves_[index].source();
188 LOperand* destination = moves_[index].destination(); 182 LOperand* destination = moves_[index].destination();
189 183
190 // Dispatch on the source and destination operand kinds. Not all 184 // Dispatch on the source and destination operand kinds. Not all
191 // combinations are possible. 185 // combinations are possible.
192 186
193 if (source->IsRegister()) { 187 if (source->IsRegister()) {
194 Register source_register = cgen_->ToRegister(source); 188 Register source_register = cgen_->ToRegister(source);
195 if (destination->IsRegister()) { 189 if (destination->IsRegister()) {
196 __ mr(cgen_->ToRegister(destination), source_register); 190 __ LoadRR(cgen_->ToRegister(destination), source_register);
197 } else { 191 } else {
198 DCHECK(destination->IsStackSlot()); 192 DCHECK(destination->IsStackSlot());
199 __ StoreP(source_register, cgen_->ToMemOperand(destination)); 193 __ StoreP(source_register, cgen_->ToMemOperand(destination));
200 } 194 }
201 } else if (source->IsStackSlot()) { 195 } else if (source->IsStackSlot()) {
202 MemOperand source_operand = cgen_->ToMemOperand(source); 196 MemOperand source_operand = cgen_->ToMemOperand(source);
203 if (destination->IsRegister()) { 197 if (destination->IsRegister()) {
204 __ LoadP(cgen_->ToRegister(destination), source_operand); 198 __ LoadP(cgen_->ToRegister(destination), source_operand);
205 } else { 199 } else {
206 DCHECK(destination->IsStackSlot()); 200 DCHECK(destination->IsStackSlot());
(...skipping 27 matching lines...) Expand all
234 cgen_->EmitLoadIntegerConstant(constant_source, kSavedValueRegister); 228 cgen_->EmitLoadIntegerConstant(constant_source, kSavedValueRegister);
235 } else { 229 } else {
236 __ Move(kSavedValueRegister, cgen_->ToHandle(constant_source)); 230 __ Move(kSavedValueRegister, cgen_->ToHandle(constant_source));
237 } 231 }
238 __ StoreP(kSavedValueRegister, cgen_->ToMemOperand(destination)); 232 __ StoreP(kSavedValueRegister, cgen_->ToMemOperand(destination));
239 } 233 }
240 234
241 } else if (source->IsDoubleRegister()) { 235 } else if (source->IsDoubleRegister()) {
242 DoubleRegister source_register = cgen_->ToDoubleRegister(source); 236 DoubleRegister source_register = cgen_->ToDoubleRegister(source);
243 if (destination->IsDoubleRegister()) { 237 if (destination->IsDoubleRegister()) {
244 __ fmr(cgen_->ToDoubleRegister(destination), source_register); 238 __ ldr(cgen_->ToDoubleRegister(destination), source_register);
245 } else { 239 } else {
246 DCHECK(destination->IsDoubleStackSlot()); 240 DCHECK(destination->IsDoubleStackSlot());
247 __ stfd(source_register, cgen_->ToMemOperand(destination)); 241 __ StoreDouble(source_register, cgen_->ToMemOperand(destination));
248 } 242 }
249 243
250 } else if (source->IsDoubleStackSlot()) { 244 } else if (source->IsDoubleStackSlot()) {
251 MemOperand source_operand = cgen_->ToMemOperand(source); 245 MemOperand source_operand = cgen_->ToMemOperand(source);
252 if (destination->IsDoubleRegister()) { 246 if (destination->IsDoubleRegister()) {
253 __ lfd(cgen_->ToDoubleRegister(destination), source_operand); 247 __ LoadDouble(cgen_->ToDoubleRegister(destination), source_operand);
254 } else { 248 } else {
255 DCHECK(destination->IsDoubleStackSlot()); 249 DCHECK(destination->IsDoubleStackSlot());
256 MemOperand destination_operand = cgen_->ToMemOperand(destination); 250 MemOperand destination_operand = cgen_->ToMemOperand(destination);
257 if (in_cycle_) { 251 if (in_cycle_) {
258 // kSavedDoubleValueRegister was used to break the cycle, 252 // kSavedDoubleValueRegister was used to break the cycle,
259 // but kSavedValueRegister is free. 253 // but kSavedValueRegister is free.
260 #if V8_TARGET_ARCH_PPC64 254 #if V8_TARGET_ARCH_S390X
261 __ ld(kSavedValueRegister, source_operand); 255 __ lg(kSavedValueRegister, source_operand);
262 __ std(kSavedValueRegister, destination_operand); 256 __ stg(kSavedValueRegister, destination_operand);
263 #else 257 #else
264 MemOperand source_high_operand = cgen_->ToHighMemOperand(source); 258 MemOperand source_high_operand = cgen_->ToHighMemOperand(source);
265 MemOperand destination_high_operand = 259 MemOperand destination_high_operand =
266 cgen_->ToHighMemOperand(destination); 260 cgen_->ToHighMemOperand(destination);
267 __ lwz(kSavedValueRegister, source_operand); 261 __ LoadlW(kSavedValueRegister, source_operand);
268 __ stw(kSavedValueRegister, destination_operand); 262 __ StoreW(kSavedValueRegister, destination_operand);
269 __ lwz(kSavedValueRegister, source_high_operand); 263 __ LoadlW(kSavedValueRegister, source_high_operand);
270 __ stw(kSavedValueRegister, destination_high_operand); 264 __ StoreW(kSavedValueRegister, destination_high_operand);
271 #endif 265 #endif
272 } else { 266 } else {
273 __ lfd(kScratchDoubleReg, source_operand); 267 __ LoadDouble(kScratchDoubleReg, source_operand);
274 __ stfd(kScratchDoubleReg, destination_operand); 268 __ StoreDouble(kScratchDoubleReg, destination_operand);
275 } 269 }
276 } 270 }
277 } else { 271 } else {
278 UNREACHABLE(); 272 UNREACHABLE();
279 } 273 }
280 274
281 moves_[index].Eliminate(); 275 moves_[index].Eliminate();
282 } 276 }
283 277
284
285 #undef __ 278 #undef __
286 } // namespace internal 279 } // namespace internal
287 } // namespace v8 280 } // namespace v8
OLDNEW
« no previous file with comments | « src/crankshaft/s390/lithium-gap-resolver-s390.h ('k') | src/crankshaft/s390/lithium-s390.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698