OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 237 } |
238 } else if (source->IsDoubleStackSlot()) { | 238 } else if (source->IsDoubleStackSlot()) { |
239 Operand src = cgen_->ToOperand(source); | 239 Operand src = cgen_->ToOperand(source); |
240 if (destination->IsDoubleRegister()) { | 240 if (destination->IsDoubleRegister()) { |
241 __ movsd(cgen_->ToDoubleRegister(destination), src); | 241 __ movsd(cgen_->ToDoubleRegister(destination), src); |
242 } else { | 242 } else { |
243 ASSERT(destination->IsDoubleStackSlot()); | 243 ASSERT(destination->IsDoubleStackSlot()); |
244 __ movsd(xmm0, src); | 244 __ movsd(xmm0, src); |
245 __ movsd(cgen_->ToOperand(destination), xmm0); | 245 __ movsd(cgen_->ToOperand(destination), xmm0); |
246 } | 246 } |
| 247 } else if (source->IsFloat32x4Register()) { |
| 248 XMMRegister src = cgen_->ToFloat32x4Register(source); |
| 249 if (destination->IsFloat32x4Register()) { |
| 250 __ movaps(cgen_->ToFloat32x4Register(destination), src); |
| 251 } else { |
| 252 ASSERT(destination->IsFloat32x4StackSlot()); |
| 253 __ movups(cgen_->ToOperand(destination), src); |
| 254 } |
| 255 } else if (source->IsFloat32x4StackSlot()) { |
| 256 Operand src = cgen_->ToOperand(source); |
| 257 if (destination->IsFloat32x4Register()) { |
| 258 __ movups(cgen_->ToFloat32x4Register(destination), src); |
| 259 } else { |
| 260 ASSERT(destination->IsFloat32x4StackSlot()); |
| 261 __ movups(xmm0, src); |
| 262 __ movups(cgen_->ToOperand(destination), xmm0); |
| 263 } |
| 264 } else if (source->IsInt32x4Register()) { |
| 265 XMMRegister src = cgen_->ToInt32x4Register(source); |
| 266 if (destination->IsInt32x4Register()) { |
| 267 __ movaps(cgen_->ToInt32x4Register(destination), src); |
| 268 } else { |
| 269 ASSERT(destination->IsInt32x4StackSlot()); |
| 270 __ movups(cgen_->ToOperand(destination), src); |
| 271 } |
| 272 } else if (source->IsInt32x4StackSlot()) { |
| 273 Operand src = cgen_->ToOperand(source); |
| 274 if (destination->IsInt32x4Register()) { |
| 275 __ movups(cgen_->ToInt32x4Register(destination), src); |
| 276 } else { |
| 277 ASSERT(destination->IsInt32x4StackSlot()); |
| 278 __ movups(xmm0, src); |
| 279 __ movups(cgen_->ToOperand(destination), xmm0); |
| 280 } |
247 } else { | 281 } else { |
248 UNREACHABLE(); | 282 UNREACHABLE(); |
249 } | 283 } |
250 | 284 |
251 moves_[index].Eliminate(); | 285 moves_[index].Eliminate(); |
252 } | 286 } |
253 | 287 |
254 | 288 |
255 void LGapResolver::EmitSwap(int index) { | 289 void LGapResolver::EmitSwap(int index) { |
256 LOperand* source = moves_[index].source(); | 290 LOperand* source = moves_[index].source(); |
(...skipping 21 matching lines...) Expand all Loading... |
278 } else if ((source->IsStackSlot() && destination->IsStackSlot()) || | 312 } else if ((source->IsStackSlot() && destination->IsStackSlot()) || |
279 (source->IsDoubleStackSlot() && destination->IsDoubleStackSlot())) { | 313 (source->IsDoubleStackSlot() && destination->IsDoubleStackSlot())) { |
280 // Swap two stack slots or two double stack slots. | 314 // Swap two stack slots or two double stack slots. |
281 Operand src = cgen_->ToOperand(source); | 315 Operand src = cgen_->ToOperand(source); |
282 Operand dst = cgen_->ToOperand(destination); | 316 Operand dst = cgen_->ToOperand(destination); |
283 __ movsd(xmm0, src); | 317 __ movsd(xmm0, src); |
284 __ movq(kScratchRegister, dst); | 318 __ movq(kScratchRegister, dst); |
285 __ movsd(dst, xmm0); | 319 __ movsd(dst, xmm0); |
286 __ movq(src, kScratchRegister); | 320 __ movq(src, kScratchRegister); |
287 | 321 |
| 322 } else if ((source->IsFloat32x4StackSlot() && |
| 323 destination->IsFloat32x4StackSlot()) || |
| 324 ((source->IsInt32x4StackSlot() && |
| 325 destination->IsInt32x4StackSlot()))) { |
| 326 // Swap two XMM stack slots. |
| 327 Operand src = cgen_->ToOperand(source); |
| 328 Operand dst = cgen_->ToOperand(destination); |
| 329 __ movups(xmm0, src); |
| 330 __ movq(kScratchRegister, dst); |
| 331 __ movq(src, kScratchRegister); |
| 332 __ movq(kScratchRegister, Operand(dst, kDoubleSize)); |
| 333 __ movq(Operand(src, kDoubleSize), kScratchRegister); |
| 334 __ movups(dst, xmm0); |
| 335 |
288 } else if (source->IsDoubleRegister() && destination->IsDoubleRegister()) { | 336 } else if (source->IsDoubleRegister() && destination->IsDoubleRegister()) { |
289 // Swap two double registers. | 337 // Swap two double registers. |
290 XMMRegister source_reg = cgen_->ToDoubleRegister(source); | 338 XMMRegister source_reg = cgen_->ToDoubleRegister(source); |
291 XMMRegister destination_reg = cgen_->ToDoubleRegister(destination); | 339 XMMRegister destination_reg = cgen_->ToDoubleRegister(destination); |
292 __ movaps(xmm0, source_reg); | 340 __ movaps(xmm0, source_reg); |
293 __ movaps(source_reg, destination_reg); | 341 __ movaps(source_reg, destination_reg); |
294 __ movaps(destination_reg, xmm0); | 342 __ movaps(destination_reg, xmm0); |
295 | 343 |
| 344 } else if (source->IsFloat32x4Register() && |
| 345 destination->IsFloat32x4Register()) { |
| 346 // Swap two XMM registers. |
| 347 XMMRegister source_reg = cgen_->ToFloat32x4Register(source); |
| 348 XMMRegister destination_reg = cgen_->ToFloat32x4Register(destination); |
| 349 __ movaps(xmm0, source_reg); |
| 350 __ movaps(source_reg, destination_reg); |
| 351 __ movaps(destination_reg, xmm0); |
| 352 |
| 353 } else if (source->IsInt32x4Register() && |
| 354 destination->IsInt32x4Register()) { |
| 355 // Swap two XMM registers. |
| 356 XMMRegister source_reg = cgen_->ToInt32x4Register(source); |
| 357 XMMRegister destination_reg = cgen_->ToInt32x4Register(destination); |
| 358 __ movaps(xmm0, source_reg); |
| 359 __ movaps(source_reg, destination_reg); |
| 360 __ movaps(destination_reg, xmm0); |
| 361 |
296 } else if (source->IsDoubleRegister() || destination->IsDoubleRegister()) { | 362 } else if (source->IsDoubleRegister() || destination->IsDoubleRegister()) { |
297 // Swap a double register and a double stack slot. | 363 // Swap a double register and a double stack slot. |
298 ASSERT((source->IsDoubleRegister() && destination->IsDoubleStackSlot()) || | 364 ASSERT((source->IsDoubleRegister() && destination->IsDoubleStackSlot()) || |
299 (source->IsDoubleStackSlot() && destination->IsDoubleRegister())); | 365 (source->IsDoubleStackSlot() && destination->IsDoubleRegister())); |
300 XMMRegister reg = cgen_->ToDoubleRegister(source->IsDoubleRegister() | 366 XMMRegister reg = cgen_->ToDoubleRegister(source->IsDoubleRegister() |
301 ? source | 367 ? source |
302 : destination); | 368 : destination); |
303 LOperand* other = source->IsDoubleRegister() ? destination : source; | 369 LOperand* other = source->IsDoubleRegister() ? destination : source; |
304 ASSERT(other->IsDoubleStackSlot()); | 370 ASSERT(other->IsDoubleStackSlot()); |
305 Operand other_operand = cgen_->ToOperand(other); | 371 Operand other_operand = cgen_->ToOperand(other); |
306 __ movsd(xmm0, other_operand); | 372 __ movsd(xmm0, other_operand); |
307 __ movsd(other_operand, reg); | 373 __ movsd(other_operand, reg); |
308 __ movaps(reg, xmm0); | 374 __ movaps(reg, xmm0); |
309 | 375 |
| 376 } else if (source->IsFloat32x4Register() || |
| 377 destination->IsFloat32x4Register()) { |
| 378 // Swap a xmm register and a xmm stack slot. |
| 379 ASSERT((source->IsFloat32x4Register() && |
| 380 destination->IsFloat32x4StackSlot()) || |
| 381 (source->IsFloat32x4StackSlot() && |
| 382 destination->IsFloat32x4Register())); |
| 383 XMMRegister reg = cgen_->ToFloat32x4Register(source->IsFloat32x4Register() |
| 384 ? source |
| 385 : destination); |
| 386 LOperand* other = source->IsFloat32x4Register() ? destination : source; |
| 387 ASSERT(other->IsFloat32x4StackSlot()); |
| 388 Operand other_operand = cgen_->ToOperand(other); |
| 389 __ movups(xmm0, other_operand); |
| 390 __ movups(other_operand, reg); |
| 391 __ movups(reg, xmm0); |
| 392 |
| 393 } else if (source->IsInt32x4Register() || |
| 394 destination->IsInt32x4Register()) { |
| 395 // Swap a xmm register and a xmm stack slot. |
| 396 ASSERT((source->IsInt32x4Register() && |
| 397 destination->IsInt32x4StackSlot()) || |
| 398 (source->IsInt32x4StackSlot() && |
| 399 destination->IsInt32x4Register())); |
| 400 XMMRegister reg = cgen_->ToInt32x4Register(source->IsInt32x4Register() |
| 401 ? source |
| 402 : destination); |
| 403 LOperand* other = source->IsInt32x4Register() ? destination : source; |
| 404 ASSERT(other->IsInt32x4StackSlot()); |
| 405 Operand other_operand = cgen_->ToOperand(other); |
| 406 __ movups(xmm0, other_operand); |
| 407 __ movups(other_operand, reg); |
| 408 __ movups(reg, xmm0); |
| 409 |
310 } else { | 410 } else { |
311 // No other combinations are possible. | 411 // No other combinations are possible. |
312 UNREACHABLE(); | 412 UNREACHABLE(); |
313 } | 413 } |
314 | 414 |
315 // The swap of source and destination has executed a move from source to | 415 // The swap of source and destination has executed a move from source to |
316 // destination. | 416 // destination. |
317 moves_[index].Eliminate(); | 417 moves_[index].Eliminate(); |
318 | 418 |
319 // Any unperformed (including pending) move with a source of either | 419 // Any unperformed (including pending) move with a source of either |
320 // this move's source or destination needs to have their source | 420 // this move's source or destination needs to have their source |
321 // changed to reflect the state of affairs after the swap. | 421 // changed to reflect the state of affairs after the swap. |
322 for (int i = 0; i < moves_.length(); ++i) { | 422 for (int i = 0; i < moves_.length(); ++i) { |
323 LMoveOperands other_move = moves_[i]; | 423 LMoveOperands other_move = moves_[i]; |
324 if (other_move.Blocks(source)) { | 424 if (other_move.Blocks(source)) { |
325 moves_[i].set_source(destination); | 425 moves_[i].set_source(destination); |
326 } else if (other_move.Blocks(destination)) { | 426 } else if (other_move.Blocks(destination)) { |
327 moves_[i].set_source(source); | 427 moves_[i].set_source(source); |
328 } | 428 } |
329 } | 429 } |
330 } | 430 } |
331 | 431 |
332 #undef __ | 432 #undef __ |
333 | 433 |
334 } } // namespace v8::internal | 434 } } // namespace v8::internal |
335 | 435 |
336 #endif // V8_TARGET_ARCH_X64 | 436 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |