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

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

Issue 422063005: Contribution of PowerPC port. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: re-upload - catch up to 8/19 level Created 6 years, 3 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 //
3 // Copyright IBM Corp. 2012, 2013. All rights reserved.
4 //
2 // Use of this source code is governed by a BSD-style license that can be 5 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 6 // found in the LICENSE file.
4 7
5 #include "src/v8.h" 8 #include "src/v8.h"
6 9
7 #include "src/mips/lithium-codegen-mips.h" 10 #include "src/ppc/lithium-codegen-ppc.h"
8 #include "src/mips/lithium-gap-resolver-mips.h" 11 #include "src/ppc/lithium-gap-resolver-ppc.h"
9 12
10 namespace v8 { 13 namespace v8 {
11 namespace internal { 14 namespace internal {
12 15
16 static const Register kSavedValueRegister = {11};
17
13 LGapResolver::LGapResolver(LCodeGen* owner) 18 LGapResolver::LGapResolver(LCodeGen* owner)
14 : cgen_(owner), 19 : cgen_(owner),
15 moves_(32, owner->zone()), 20 moves_(32, owner->zone()),
16 root_index_(0), 21 root_index_(0),
17 in_cycle_(false), 22 in_cycle_(false),
18 saved_destination_(NULL) {} 23 saved_destination_(NULL) {}
19 24
20 25
21 void LGapResolver::Resolve(LParallelMove* parallel_move) { 26 void LGapResolver::Resolve(LParallelMove* parallel_move) {
22 DCHECK(moves_.is_empty()); 27 DCHECK(moves_.is_empty());
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 void LGapResolver::BreakCycle(int index) { 143 void LGapResolver::BreakCycle(int index) {
139 // We save in a register the value that should end up in the source of 144 // We save in a register the value that should end up in the source of
140 // moves_[root_index]. After performing all moves in the tree rooted 145 // moves_[root_index]. After performing all moves in the tree rooted
141 // in that move, we save the value to that source. 146 // in that move, we save the value to that source.
142 DCHECK(moves_[index].destination()->Equals(moves_[root_index_].source())); 147 DCHECK(moves_[index].destination()->Equals(moves_[root_index_].source()));
143 DCHECK(!in_cycle_); 148 DCHECK(!in_cycle_);
144 in_cycle_ = true; 149 in_cycle_ = true;
145 LOperand* source = moves_[index].source(); 150 LOperand* source = moves_[index].source();
146 saved_destination_ = moves_[index].destination(); 151 saved_destination_ = moves_[index].destination();
147 if (source->IsRegister()) { 152 if (source->IsRegister()) {
148 __ mov(kLithiumScratchReg, cgen_->ToRegister(source)); 153 __ mr(kSavedValueRegister, cgen_->ToRegister(source));
149 } else if (source->IsStackSlot()) { 154 } else if (source->IsStackSlot()) {
150 __ lw(kLithiumScratchReg, cgen_->ToMemOperand(source)); 155 __ LoadP(kSavedValueRegister, cgen_->ToMemOperand(source));
151 } else if (source->IsDoubleRegister()) { 156 } else if (source->IsDoubleRegister()) {
152 __ mov_d(kLithiumScratchDouble, cgen_->ToDoubleRegister(source)); 157 __ fmr(kScratchDoubleReg, cgen_->ToDoubleRegister(source));
153 } else if (source->IsDoubleStackSlot()) { 158 } else if (source->IsDoubleStackSlot()) {
154 __ ldc1(kLithiumScratchDouble, cgen_->ToMemOperand(source)); 159 __ lfd(kScratchDoubleReg, cgen_->ToMemOperand(source));
155 } else { 160 } else {
156 UNREACHABLE(); 161 UNREACHABLE();
157 } 162 }
158 // This move will be done by restoring the saved value to the destination. 163 // This move will be done by restoring the saved value to the destination.
159 moves_[index].Eliminate(); 164 moves_[index].Eliminate();
160 } 165 }
161 166
162 167
163 void LGapResolver::RestoreValue() { 168 void LGapResolver::RestoreValue() {
164 DCHECK(in_cycle_); 169 DCHECK(in_cycle_);
165 DCHECK(saved_destination_ != NULL); 170 DCHECK(saved_destination_ != NULL);
166 171
167 // Spilled value is in kLithiumScratchReg or kLithiumScratchDouble. 172 // Spilled value is in kSavedValueRegister or kSavedDoubleValueRegister.
168 if (saved_destination_->IsRegister()) { 173 if (saved_destination_->IsRegister()) {
169 __ mov(cgen_->ToRegister(saved_destination_), kLithiumScratchReg); 174 __ mr(cgen_->ToRegister(saved_destination_), kSavedValueRegister);
170 } else if (saved_destination_->IsStackSlot()) { 175 } else if (saved_destination_->IsStackSlot()) {
171 __ sw(kLithiumScratchReg, cgen_->ToMemOperand(saved_destination_)); 176 __ StoreP(kSavedValueRegister, cgen_->ToMemOperand(saved_destination_));
172 } else if (saved_destination_->IsDoubleRegister()) { 177 } else if (saved_destination_->IsDoubleRegister()) {
173 __ mov_d(cgen_->ToDoubleRegister(saved_destination_), 178 __ fmr(cgen_->ToDoubleRegister(saved_destination_), kScratchDoubleReg);
174 kLithiumScratchDouble);
175 } else if (saved_destination_->IsDoubleStackSlot()) { 179 } else if (saved_destination_->IsDoubleStackSlot()) {
176 __ sdc1(kLithiumScratchDouble, 180 __ stfd(kScratchDoubleReg, cgen_->ToMemOperand(saved_destination_));
177 cgen_->ToMemOperand(saved_destination_));
178 } else { 181 } else {
179 UNREACHABLE(); 182 UNREACHABLE();
180 } 183 }
181 184
182 in_cycle_ = false; 185 in_cycle_ = false;
183 saved_destination_ = NULL; 186 saved_destination_ = NULL;
184 } 187 }
185 188
186 189
187 void LGapResolver::EmitMove(int index) { 190 void LGapResolver::EmitMove(int index) {
188 LOperand* source = moves_[index].source(); 191 LOperand* source = moves_[index].source();
189 LOperand* destination = moves_[index].destination(); 192 LOperand* destination = moves_[index].destination();
190 193
191 // Dispatch on the source and destination operand kinds. Not all 194 // Dispatch on the source and destination operand kinds. Not all
192 // combinations are possible. 195 // combinations are possible.
193 196
194 if (source->IsRegister()) { 197 if (source->IsRegister()) {
195 Register source_register = cgen_->ToRegister(source); 198 Register source_register = cgen_->ToRegister(source);
196 if (destination->IsRegister()) { 199 if (destination->IsRegister()) {
197 __ mov(cgen_->ToRegister(destination), source_register); 200 __ mr(cgen_->ToRegister(destination), source_register);
198 } else { 201 } else {
199 DCHECK(destination->IsStackSlot()); 202 DCHECK(destination->IsStackSlot());
200 __ sw(source_register, cgen_->ToMemOperand(destination)); 203 __ StoreP(source_register, cgen_->ToMemOperand(destination));
201 } 204 }
202 } else if (source->IsStackSlot()) { 205 } else if (source->IsStackSlot()) {
203 MemOperand source_operand = cgen_->ToMemOperand(source); 206 MemOperand source_operand = cgen_->ToMemOperand(source);
204 if (destination->IsRegister()) { 207 if (destination->IsRegister()) {
205 __ lw(cgen_->ToRegister(destination), source_operand); 208 __ LoadP(cgen_->ToRegister(destination), source_operand);
206 } else { 209 } else {
207 DCHECK(destination->IsStackSlot()); 210 DCHECK(destination->IsStackSlot());
208 MemOperand destination_operand = cgen_->ToMemOperand(destination); 211 MemOperand destination_operand = cgen_->ToMemOperand(destination);
209 if (in_cycle_) { 212 if (in_cycle_) {
210 if (!destination_operand.OffsetIsInt16Encodable()) { 213 __ LoadP(ip, source_operand);
211 // 'at' is overwritten while saving the value to the destination. 214 __ StoreP(ip, destination_operand);
212 // Therefore we can't use 'at'. It is OK if the read from the source
213 // destroys 'at', since that happens before the value is read.
214 // This uses only a single reg of the double reg-pair.
215 __ lwc1(kLithiumScratchDouble, source_operand);
216 __ swc1(kLithiumScratchDouble, destination_operand);
217 } else {
218 __ lw(at, source_operand);
219 __ sw(at, destination_operand);
220 }
221 } else { 215 } else {
222 __ lw(kLithiumScratchReg, source_operand); 216 __ LoadP(kSavedValueRegister, source_operand);
223 __ sw(kLithiumScratchReg, destination_operand); 217 __ StoreP(kSavedValueRegister, destination_operand);
224 } 218 }
225 } 219 }
226 220
227 } else if (source->IsConstantOperand()) { 221 } else if (source->IsConstantOperand()) {
228 LConstantOperand* constant_source = LConstantOperand::cast(source); 222 LConstantOperand* constant_source = LConstantOperand::cast(source);
229 if (destination->IsRegister()) { 223 if (destination->IsRegister()) {
230 Register dst = cgen_->ToRegister(destination); 224 Register dst = cgen_->ToRegister(destination);
231 Representation r = cgen_->IsSmi(constant_source)
232 ? Representation::Smi() : Representation::Integer32();
233 if (cgen_->IsInteger32(constant_source)) { 225 if (cgen_->IsInteger32(constant_source)) {
234 __ li(dst, Operand(cgen_->ToRepresentation(constant_source, r))); 226 cgen_->EmitLoadIntegerConstant(constant_source, dst);
235 } else { 227 } else {
236 __ li(dst, cgen_->ToHandle(constant_source)); 228 __ Move(dst, cgen_->ToHandle(constant_source));
237 } 229 }
238 } else if (destination->IsDoubleRegister()) { 230 } else if (destination->IsDoubleRegister()) {
239 DoubleRegister result = cgen_->ToDoubleRegister(destination); 231 DoubleRegister result = cgen_->ToDoubleRegister(destination);
240 double v = cgen_->ToDouble(constant_source); 232 double v = cgen_->ToDouble(constant_source);
241 __ Move(result, v); 233 __ LoadDoubleLiteral(result, v, ip);
242 } else { 234 } else {
243 DCHECK(destination->IsStackSlot()); 235 DCHECK(destination->IsStackSlot());
244 DCHECK(!in_cycle_); // Constant moves happen after all cycles are gone. 236 DCHECK(!in_cycle_); // Constant moves happen after all cycles are gone.
245 Representation r = cgen_->IsSmi(constant_source)
246 ? Representation::Smi() : Representation::Integer32();
247 if (cgen_->IsInteger32(constant_source)) { 237 if (cgen_->IsInteger32(constant_source)) {
248 __ li(kLithiumScratchReg, 238 cgen_->EmitLoadIntegerConstant(constant_source, kSavedValueRegister);
249 Operand(cgen_->ToRepresentation(constant_source, r)));
250 } else { 239 } else {
251 __ li(kLithiumScratchReg, cgen_->ToHandle(constant_source)); 240 __ Move(kSavedValueRegister, cgen_->ToHandle(constant_source));
252 } 241 }
253 __ sw(kLithiumScratchReg, cgen_->ToMemOperand(destination)); 242 __ StoreP(kSavedValueRegister, cgen_->ToMemOperand(destination));
254 } 243 }
255 244
256 } else if (source->IsDoubleRegister()) { 245 } else if (source->IsDoubleRegister()) {
257 DoubleRegister source_register = cgen_->ToDoubleRegister(source); 246 DoubleRegister source_register = cgen_->ToDoubleRegister(source);
258 if (destination->IsDoubleRegister()) { 247 if (destination->IsDoubleRegister()) {
259 __ mov_d(cgen_->ToDoubleRegister(destination), source_register); 248 __ fmr(cgen_->ToDoubleRegister(destination), source_register);
260 } else { 249 } else {
261 DCHECK(destination->IsDoubleStackSlot()); 250 DCHECK(destination->IsDoubleStackSlot());
262 MemOperand destination_operand = cgen_->ToMemOperand(destination); 251 __ stfd(source_register, cgen_->ToMemOperand(destination));
263 __ sdc1(source_register, destination_operand);
264 } 252 }
265 253
266 } else if (source->IsDoubleStackSlot()) { 254 } else if (source->IsDoubleStackSlot()) {
267 MemOperand source_operand = cgen_->ToMemOperand(source); 255 MemOperand source_operand = cgen_->ToMemOperand(source);
268 if (destination->IsDoubleRegister()) { 256 if (destination->IsDoubleRegister()) {
269 __ ldc1(cgen_->ToDoubleRegister(destination), source_operand); 257 __ lfd(cgen_->ToDoubleRegister(destination), source_operand);
270 } else { 258 } else {
271 DCHECK(destination->IsDoubleStackSlot()); 259 DCHECK(destination->IsDoubleStackSlot());
272 MemOperand destination_operand = cgen_->ToMemOperand(destination); 260 MemOperand destination_operand = cgen_->ToMemOperand(destination);
273 if (in_cycle_) { 261 if (in_cycle_) {
274 // kLithiumScratchDouble was used to break the cycle, 262 // kSavedDoubleValueRegister was used to break the cycle,
275 // but kLithiumScratchReg is free. 263 // but kSavedValueRegister is free.
276 MemOperand source_high_operand = 264 #if V8_TARGET_ARCH_PPC64
277 cgen_->ToHighMemOperand(source); 265 __ ld(kSavedValueRegister, source_operand);
266 __ std(kSavedValueRegister, destination_operand);
267 #else
268 MemOperand source_high_operand = cgen_->ToHighMemOperand(source);
278 MemOperand destination_high_operand = 269 MemOperand destination_high_operand =
279 cgen_->ToHighMemOperand(destination); 270 cgen_->ToHighMemOperand(destination);
280 __ lw(kLithiumScratchReg, source_operand); 271 __ lwz(kSavedValueRegister, source_operand);
281 __ sw(kLithiumScratchReg, destination_operand); 272 __ stw(kSavedValueRegister, destination_operand);
282 __ lw(kLithiumScratchReg, source_high_operand); 273 __ lwz(kSavedValueRegister, source_high_operand);
283 __ sw(kLithiumScratchReg, destination_high_operand); 274 __ stw(kSavedValueRegister, destination_high_operand);
275 #endif
284 } else { 276 } else {
285 __ ldc1(kLithiumScratchDouble, source_operand); 277 __ lfd(kScratchDoubleReg, source_operand);
286 __ sdc1(kLithiumScratchDouble, destination_operand); 278 __ stfd(kScratchDoubleReg, destination_operand);
287 } 279 }
288 } 280 }
289 } else { 281 } else {
290 UNREACHABLE(); 282 UNREACHABLE();
291 } 283 }
292 284
293 moves_[index].Eliminate(); 285 moves_[index].Eliminate();
294 } 286 }
295 287
296 288
297 #undef __ 289 #undef __
298 290 }
299 } } // namespace v8::internal 291 } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698