OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // | 4 // |
5 // Modified by the Subzero authors. | 5 // Modified by the Subzero authors. |
6 // | 6 // |
7 //===- subzero/src/assembler_ia32.h - Assembler for x86-32 ----------------===// | 7 //===- subzero/src/assembler_ia32.h - Assembler for x86-32 ----------------===// |
8 // | 8 // |
9 // The Subzero Code Generator | 9 // The Subzero Code Generator |
10 // | 10 // |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 typedef void (AssemblerX86::*TypedEmitGPRAddr)(Type, GPRRegister, | 347 typedef void (AssemblerX86::*TypedEmitGPRAddr)(Type, GPRRegister, |
348 const Address &); | 348 const Address &); |
349 typedef void (AssemblerX86::*TypedEmitGPRImm)(Type, GPRRegister, | 349 typedef void (AssemblerX86::*TypedEmitGPRImm)(Type, GPRRegister, |
350 const Immediate &); | 350 const Immediate &); |
351 struct GPREmitterRegOp { | 351 struct GPREmitterRegOp { |
352 TypedEmitGPRGPR GPRGPR; | 352 TypedEmitGPRGPR GPRGPR; |
353 TypedEmitGPRAddr GPRAddr; | 353 TypedEmitGPRAddr GPRAddr; |
354 TypedEmitGPRImm GPRImm; | 354 TypedEmitGPRImm GPRImm; |
355 }; | 355 }; |
356 | 356 |
| 357 struct GPREmitterShiftOp { |
| 358 TypedEmitGPRGPR GPRGPR; |
| 359 TypedEmitGPRImm GPRImm; |
| 360 // Technically, Addr/GPR and Addr/Imm are also allowed, but */Addr are not. |
| 361 // In practice, we always normalize the Dest to a Register first. |
| 362 }; |
| 363 |
357 // Operations to emit XMM instructions (and dispatch on operand type). | 364 // Operations to emit XMM instructions (and dispatch on operand type). |
358 typedef void (AssemblerX86::*TypedEmitXmmXmm)(Type, XmmRegister, XmmRegister); | 365 typedef void (AssemblerX86::*TypedEmitXmmXmm)(Type, XmmRegister, XmmRegister); |
359 typedef void (AssemblerX86::*TypedEmitXmmAddr)(Type, XmmRegister, | 366 typedef void (AssemblerX86::*TypedEmitXmmAddr)(Type, XmmRegister, |
360 const Address &); | 367 const Address &); |
361 typedef void (AssemblerX86::*TypedEmitAddrXmm)(Type, const Address &, | 368 typedef void (AssemblerX86::*TypedEmitAddrXmm)(Type, const Address &, |
362 XmmRegister); | 369 XmmRegister); |
363 struct XmmEmitterTwoOps { | 370 struct XmmEmitterTwoOps { |
364 TypedEmitXmmXmm XmmXmm; | 371 TypedEmitXmmXmm XmmXmm; |
365 TypedEmitXmmAddr XmmAddr; | 372 TypedEmitXmmAddr XmmAddr; |
366 TypedEmitAddrXmm AddrXmm; | 373 TypedEmitAddrXmm AddrXmm; |
367 }; | 374 }; |
368 | 375 |
| 376 typedef void (AssemblerX86::*TypedEmitXmmImm)(Type, XmmRegister, |
| 377 const Immediate &); |
| 378 |
| 379 struct XmmEmitterShiftOp { |
| 380 TypedEmitXmmXmm XmmXmm; |
| 381 TypedEmitXmmAddr XmmAddr; |
| 382 TypedEmitXmmImm XmmImm; |
| 383 }; |
| 384 |
369 /* | 385 /* |
370 * Emit Machine Instructions. | 386 * Emit Machine Instructions. |
371 */ | 387 */ |
372 void call(GPRRegister reg); | 388 void call(GPRRegister reg); |
373 void call(const Address &address); | 389 void call(const Address &address); |
374 void call(Label *label); | 390 void call(Label *label); |
375 void call(const ConstantRelocatable *label); | 391 void call(const ConstantRelocatable *label); |
376 | 392 |
377 static const intptr_t kCallExternalLabelSize = 5; | 393 static const intptr_t kCallExternalLabelSize = 5; |
378 | 394 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 | 462 |
447 void movups(XmmRegister dst, const Address &src); | 463 void movups(XmmRegister dst, const Address &src); |
448 void movups(const Address &dst, XmmRegister src); | 464 void movups(const Address &dst, XmmRegister src); |
449 | 465 |
450 void padd(Type Ty, XmmRegister dst, XmmRegister src); | 466 void padd(Type Ty, XmmRegister dst, XmmRegister src); |
451 void padd(Type Ty, XmmRegister dst, const Address &src); | 467 void padd(Type Ty, XmmRegister dst, const Address &src); |
452 void pand(Type Ty, XmmRegister dst, XmmRegister src); | 468 void pand(Type Ty, XmmRegister dst, XmmRegister src); |
453 void pand(Type Ty, XmmRegister dst, const Address &src); | 469 void pand(Type Ty, XmmRegister dst, const Address &src); |
454 void pandn(Type Ty, XmmRegister dst, XmmRegister src); | 470 void pandn(Type Ty, XmmRegister dst, XmmRegister src); |
455 void pandn(Type Ty, XmmRegister dst, const Address &src); | 471 void pandn(Type Ty, XmmRegister dst, const Address &src); |
| 472 void pmull(Type Ty, XmmRegister dst, XmmRegister src); |
| 473 void pmull(Type Ty, XmmRegister dst, const Address &src); |
456 void pmuludq(Type Ty, XmmRegister dst, XmmRegister src); | 474 void pmuludq(Type Ty, XmmRegister dst, XmmRegister src); |
457 void pmuludq(Type Ty, XmmRegister dst, const Address &src); | 475 void pmuludq(Type Ty, XmmRegister dst, const Address &src); |
458 void por(Type Ty, XmmRegister dst, XmmRegister src); | 476 void por(Type Ty, XmmRegister dst, XmmRegister src); |
459 void por(Type Ty, XmmRegister dst, const Address &src); | 477 void por(Type Ty, XmmRegister dst, const Address &src); |
460 void psub(Type Ty, XmmRegister dst, XmmRegister src); | 478 void psub(Type Ty, XmmRegister dst, XmmRegister src); |
461 void psub(Type Ty, XmmRegister dst, const Address &src); | 479 void psub(Type Ty, XmmRegister dst, const Address &src); |
462 void pxor(Type Ty, XmmRegister dst, XmmRegister src); | 480 void pxor(Type Ty, XmmRegister dst, XmmRegister src); |
463 void pxor(Type Ty, XmmRegister dst, const Address &src); | 481 void pxor(Type Ty, XmmRegister dst, const Address &src); |
464 | 482 |
| 483 void psll(Type Ty, XmmRegister dst, XmmRegister src); |
| 484 void psll(Type Ty, XmmRegister dst, const Address &src); |
| 485 void psll(Type Ty, XmmRegister dst, const Immediate &src); |
| 486 |
| 487 void psra(Type Ty, XmmRegister dst, XmmRegister src); |
| 488 void psra(Type Ty, XmmRegister dst, const Address &src); |
| 489 void psra(Type Ty, XmmRegister dst, const Immediate &src); |
| 490 |
465 void addps(Type Ty, XmmRegister dst, XmmRegister src); | 491 void addps(Type Ty, XmmRegister dst, XmmRegister src); |
466 void addps(Type Ty, XmmRegister dst, const Address &src); | 492 void addps(Type Ty, XmmRegister dst, const Address &src); |
467 void subps(Type Ty, XmmRegister dst, XmmRegister src); | 493 void subps(Type Ty, XmmRegister dst, XmmRegister src); |
468 void subps(Type Ty, XmmRegister dst, const Address &src); | 494 void subps(Type Ty, XmmRegister dst, const Address &src); |
469 void divps(Type Ty, XmmRegister dst, XmmRegister src); | 495 void divps(Type Ty, XmmRegister dst, XmmRegister src); |
470 void divps(Type Ty, XmmRegister dst, const Address &src); | 496 void divps(Type Ty, XmmRegister dst, const Address &src); |
471 void mulps(Type Ty, XmmRegister dst, XmmRegister src); | 497 void mulps(Type Ty, XmmRegister dst, XmmRegister src); |
472 void mulps(Type Ty, XmmRegister dst, const Address &src); | 498 void mulps(Type Ty, XmmRegister dst, const Address &src); |
473 void minps(XmmRegister dst, XmmRegister src); | 499 void minps(XmmRegister dst, XmmRegister src); |
474 void maxps(XmmRegister dst, XmmRegister src); | 500 void maxps(XmmRegister dst, XmmRegister src); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 | 648 |
623 void mul(Type Ty, GPRRegister reg); | 649 void mul(Type Ty, GPRRegister reg); |
624 void mul(Type Ty, const Address &address); | 650 void mul(Type Ty, const Address &address); |
625 | 651 |
626 void incl(GPRRegister reg); | 652 void incl(GPRRegister reg); |
627 void incl(const Address &address); | 653 void incl(const Address &address); |
628 | 654 |
629 void decl(GPRRegister reg); | 655 void decl(GPRRegister reg); |
630 void decl(const Address &address); | 656 void decl(const Address &address); |
631 | 657 |
632 void shll(GPRRegister reg, const Immediate &imm); | 658 void rol(Type Ty, GPRRegister reg, const Immediate &imm); |
633 void shll(GPRRegister operand, GPRRegister shifter); | 659 void rol(Type Ty, GPRRegister operand, GPRRegister shifter); |
634 void shll(const Address &operand, GPRRegister shifter); | 660 void rol(Type Ty, const Address &operand, GPRRegister shifter); |
635 void shrl(GPRRegister reg, const Immediate &imm); | 661 |
636 void shrl(GPRRegister operand, GPRRegister shifter); | 662 void shl(Type Ty, GPRRegister reg, const Immediate &imm); |
637 void sarl(GPRRegister reg, const Immediate &imm); | 663 void shl(Type Ty, GPRRegister operand, GPRRegister shifter); |
638 void sarl(GPRRegister operand, GPRRegister shifter); | 664 void shl(Type Ty, const Address &operand, GPRRegister shifter); |
639 void sarl(const Address &address, GPRRegister shifter); | 665 |
| 666 void shr(Type Ty, GPRRegister reg, const Immediate &imm); |
| 667 void shr(Type Ty, GPRRegister operand, GPRRegister shifter); |
| 668 void shr(Type Ty, const Address &operand, GPRRegister shifter); |
| 669 |
| 670 void sar(Type Ty, GPRRegister reg, const Immediate &imm); |
| 671 void sar(Type Ty, GPRRegister operand, GPRRegister shifter); |
| 672 void sar(Type Ty, const Address &address, GPRRegister shifter); |
| 673 |
640 void shld(GPRRegister dst, GPRRegister src); | 674 void shld(GPRRegister dst, GPRRegister src); |
641 void shld(GPRRegister dst, GPRRegister src, const Immediate &imm); | 675 void shld(GPRRegister dst, GPRRegister src, const Immediate &imm); |
642 void shld(const Address &operand, GPRRegister src); | 676 void shld(const Address &operand, GPRRegister src); |
643 void shrd(GPRRegister dst, GPRRegister src); | 677 void shrd(GPRRegister dst, GPRRegister src); |
644 void shrd(GPRRegister dst, GPRRegister src, const Immediate &imm); | 678 void shrd(GPRRegister dst, GPRRegister src, const Immediate &imm); |
645 void shrd(const Address &dst, GPRRegister src); | 679 void shrd(const Address &dst, GPRRegister src); |
646 | 680 |
647 void neg(Type Ty, GPRRegister reg); | 681 void neg(Type Ty, GPRRegister reg); |
648 void neg(Type Ty, const Address &addr); | 682 void neg(Type Ty, const Address &addr); |
649 void notl(GPRRegister reg); | 683 void notl(GPRRegister reg); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 void EmitOperand(int rm, const Operand &operand); | 748 void EmitOperand(int rm, const Operand &operand); |
715 void EmitImmediate(Type ty, const Immediate &imm); | 749 void EmitImmediate(Type ty, const Immediate &imm); |
716 void EmitComplexI8(int rm, const Operand &operand, | 750 void EmitComplexI8(int rm, const Operand &operand, |
717 const Immediate &immediate); | 751 const Immediate &immediate); |
718 void EmitComplex(Type Ty, int rm, const Operand &operand, | 752 void EmitComplex(Type Ty, int rm, const Operand &operand, |
719 const Immediate &immediate); | 753 const Immediate &immediate); |
720 void EmitLabel(Label *label, intptr_t instruction_size); | 754 void EmitLabel(Label *label, intptr_t instruction_size); |
721 void EmitLabelLink(Label *label); | 755 void EmitLabelLink(Label *label); |
722 void EmitNearLabelLink(Label *label); | 756 void EmitNearLabelLink(Label *label); |
723 | 757 |
724 void EmitGenericShift(int rm, GPRRegister reg, const Immediate &imm); | 758 void EmitGenericShift(int rm, Type Ty, GPRRegister reg, const Immediate &imm); |
725 void EmitGenericShift(int rm, const Operand &operand, GPRRegister shifter); | 759 void EmitGenericShift(int rm, Type Ty, const Operand &operand, |
| 760 GPRRegister shifter); |
726 | 761 |
727 AssemblerBuffer buffer_; | 762 AssemblerBuffer buffer_; |
728 | 763 |
729 AssemblerX86(const AssemblerX86 &) = delete; | 764 AssemblerX86(const AssemblerX86 &) = delete; |
730 AssemblerX86 &operator=(const AssemblerX86 &) = delete; | 765 AssemblerX86 &operator=(const AssemblerX86 &) = delete; |
731 }; | 766 }; |
732 | 767 |
733 inline void AssemblerX86::EmitUint8(uint8_t value) { | 768 inline void AssemblerX86::EmitUint8(uint8_t value) { |
734 buffer_.Emit<uint8_t>(value); | 769 buffer_.Emit<uint8_t>(value); |
735 } | 770 } |
(...skipping 18 matching lines...) Expand all Loading... |
754 inline void AssemblerX86::EmitFixup(AssemblerFixup *fixup) { | 789 inline void AssemblerX86::EmitFixup(AssemblerFixup *fixup) { |
755 buffer_.EmitFixup(fixup); | 790 buffer_.EmitFixup(fixup); |
756 } | 791 } |
757 | 792 |
758 inline void AssemblerX86::EmitOperandSizeOverride() { EmitUint8(0x66); } | 793 inline void AssemblerX86::EmitOperandSizeOverride() { EmitUint8(0x66); } |
759 | 794 |
760 } // end of namespace x86 | 795 } // end of namespace x86 |
761 } // end of namespace Ice | 796 } // end of namespace Ice |
762 | 797 |
763 #endif // SUBZERO_SRC_ASSEMBLER_IA32_H_ | 798 #endif // SUBZERO_SRC_ASSEMBLER_IA32_H_ |
OLD | NEW |