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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 public: | 329 public: |
330 explicit AssemblerX86(bool use_far_branches = false) : buffer_(*this) { | 330 explicit AssemblerX86(bool use_far_branches = false) : buffer_(*this) { |
331 // This mode is only needed and implemented for MIPS and ARM. | 331 // This mode is only needed and implemented for MIPS and ARM. |
332 assert(!use_far_branches); | 332 assert(!use_far_branches); |
333 } | 333 } |
334 ~AssemblerX86() {} | 334 ~AssemblerX86() {} |
335 | 335 |
336 static const bool kNearJump = true; | 336 static const bool kNearJump = true; |
337 static const bool kFarJump = false; | 337 static const bool kFarJump = false; |
338 | 338 |
| 339 // Operations to emit GPR instructions (and dispatch on operand type). |
| 340 typedef void (AssemblerX86::*TypedEmitGPR)(Type, GPRRegister); |
| 341 typedef void (AssemblerX86::*TypedEmitAddr)(Type, const Address &); |
| 342 struct GPREmitterOneOp { |
| 343 TypedEmitGPR Reg; |
| 344 TypedEmitAddr Addr; |
| 345 }; |
| 346 |
| 347 typedef void (AssemblerX86::*TypedEmitGPRGPR)(Type, GPRRegister, GPRRegister); |
| 348 typedef void (AssemblerX86::*TypedEmitGPRAddr)(Type, GPRRegister, |
| 349 const Address &); |
| 350 typedef void (AssemblerX86::*TypedEmitGPRImm)(Type, GPRRegister, |
| 351 const Immediate &); |
| 352 struct GPREmitterRegOp { |
| 353 TypedEmitGPRGPR GPRGPR; |
| 354 TypedEmitGPRAddr GPRAddr; |
| 355 TypedEmitGPRImm GPRImm; |
| 356 }; |
| 357 |
339 // Operations to emit XMM instructions (and dispatch on operand type). | 358 // Operations to emit XMM instructions (and dispatch on operand type). |
340 typedef void (AssemblerX86::*TypedEmitXmmXmm)(Type, XmmRegister, XmmRegister); | 359 typedef void (AssemblerX86::*TypedEmitXmmXmm)(Type, XmmRegister, XmmRegister); |
341 typedef void (AssemblerX86::*TypedEmitXmmAddr)(Type, XmmRegister, | 360 typedef void (AssemblerX86::*TypedEmitXmmAddr)(Type, XmmRegister, |
342 const Address &); | 361 const Address &); |
343 typedef void (AssemblerX86::*TypedEmitAddrXmm)(Type, const Address &, | 362 typedef void (AssemblerX86::*TypedEmitAddrXmm)(Type, const Address &, |
344 XmmRegister); | 363 XmmRegister); |
345 struct TypedXmmEmitters { | 364 struct XmmEmitterTwoOps { |
346 TypedEmitXmmXmm XmmXmm; | 365 TypedEmitXmmXmm XmmXmm; |
347 TypedEmitXmmAddr XmmAddr; | 366 TypedEmitXmmAddr XmmAddr; |
348 TypedEmitAddrXmm AddrXmm; | 367 TypedEmitAddrXmm AddrXmm; |
349 }; | 368 }; |
350 | 369 |
351 /* | 370 /* |
352 * Emit Machine Instructions. | 371 * Emit Machine Instructions. |
353 */ | 372 */ |
354 void call(GPRRegister reg); | 373 void call(GPRRegister reg); |
355 void call(const Address &address); | 374 void call(const Address &address); |
(...skipping 30 matching lines...) Expand all Loading... |
386 void movb(const Address &dst, ByteRegister src); | 405 void movb(const Address &dst, ByteRegister src); |
387 void movb(const Address &dst, const Immediate &imm); | 406 void movb(const Address &dst, const Immediate &imm); |
388 | 407 |
389 void movzxw(GPRRegister dst, GPRRegister src); | 408 void movzxw(GPRRegister dst, GPRRegister src); |
390 void movzxw(GPRRegister dst, const Address &src); | 409 void movzxw(GPRRegister dst, const Address &src); |
391 void movsxw(GPRRegister dst, GPRRegister src); | 410 void movsxw(GPRRegister dst, GPRRegister src); |
392 void movsxw(GPRRegister dst, const Address &src); | 411 void movsxw(GPRRegister dst, const Address &src); |
393 void movw(GPRRegister dst, const Address &src); | 412 void movw(GPRRegister dst, const Address &src); |
394 void movw(const Address &dst, GPRRegister src); | 413 void movw(const Address &dst, GPRRegister src); |
395 | 414 |
396 void leal(GPRRegister dst, const Address &src); | 415 void lea(Type Ty, GPRRegister dst, const Address &src); |
397 | 416 |
398 void cmov(CondX86::BrCond cond, GPRRegister dst, GPRRegister src); | 417 void cmov(CondX86::BrCond cond, GPRRegister dst, GPRRegister src); |
399 | 418 |
400 void rep_movsb(); | 419 void rep_movsb(); |
401 | 420 |
402 void movss(XmmRegister dst, const Address &src); | 421 void movss(XmmRegister dst, const Address &src); |
403 void movss(const Address &dst, XmmRegister src); | 422 void movss(const Address &dst, XmmRegister src); |
404 void movss(XmmRegister dst, XmmRegister src); | 423 void movss(XmmRegister dst, XmmRegister src); |
405 | 424 |
406 void movd(XmmRegister dst, GPRRegister src); | 425 void movd(XmmRegister dst, GPRRegister src); |
| 426 void movd(XmmRegister dst, const Address &src); |
407 void movd(GPRRegister dst, XmmRegister src); | 427 void movd(GPRRegister dst, XmmRegister src); |
| 428 void movd(const Address &dst, XmmRegister src); |
408 | 429 |
409 void movq(const Address &dst, XmmRegister src); | 430 void movq(const Address &dst, XmmRegister src); |
410 void movq(XmmRegister dst, const Address &src); | 431 void movq(XmmRegister dst, const Address &src); |
411 | 432 |
412 void addss(Type Ty, XmmRegister dst, XmmRegister src); | 433 void addss(Type Ty, XmmRegister dst, XmmRegister src); |
413 void addss(Type Ty, XmmRegister dst, const Address &src); | 434 void addss(Type Ty, XmmRegister dst, const Address &src); |
414 void subss(Type Ty, XmmRegister dst, XmmRegister src); | 435 void subss(Type Ty, XmmRegister dst, XmmRegister src); |
415 void subss(Type Ty, XmmRegister dst, const Address &src); | 436 void subss(Type Ty, XmmRegister dst, const Address &src); |
416 void mulss(Type Ty, XmmRegister dst, XmmRegister src); | 437 void mulss(Type Ty, XmmRegister dst, XmmRegister src); |
417 void mulss(Type Ty, XmmRegister dst, const Address &src); | 438 void mulss(Type Ty, XmmRegister dst, const Address &src); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 void sarl(GPRRegister reg, const Immediate &imm); | 636 void sarl(GPRRegister reg, const Immediate &imm); |
616 void sarl(GPRRegister operand, GPRRegister shifter); | 637 void sarl(GPRRegister operand, GPRRegister shifter); |
617 void sarl(const Address &address, GPRRegister shifter); | 638 void sarl(const Address &address, GPRRegister shifter); |
618 void shld(GPRRegister dst, GPRRegister src); | 639 void shld(GPRRegister dst, GPRRegister src); |
619 void shld(GPRRegister dst, GPRRegister src, const Immediate &imm); | 640 void shld(GPRRegister dst, GPRRegister src, const Immediate &imm); |
620 void shld(const Address &operand, GPRRegister src); | 641 void shld(const Address &operand, GPRRegister src); |
621 void shrd(GPRRegister dst, GPRRegister src); | 642 void shrd(GPRRegister dst, GPRRegister src); |
622 void shrd(GPRRegister dst, GPRRegister src, const Immediate &imm); | 643 void shrd(GPRRegister dst, GPRRegister src, const Immediate &imm); |
623 void shrd(const Address &dst, GPRRegister src); | 644 void shrd(const Address &dst, GPRRegister src); |
624 | 645 |
625 void negl(GPRRegister reg); | 646 void neg(Type Ty, GPRRegister reg); |
| 647 void neg(Type Ty, const Address &addr); |
626 void notl(GPRRegister reg); | 648 void notl(GPRRegister reg); |
627 | 649 |
628 void bsrl(GPRRegister dst, GPRRegister src); | 650 void bsf(Type Ty, GPRRegister dst, GPRRegister src); |
| 651 void bsf(Type Ty, GPRRegister dst, const Address &src); |
| 652 void bsr(Type Ty, GPRRegister dst, GPRRegister src); |
| 653 void bsr(Type Ty, GPRRegister dst, const Address &src); |
| 654 |
| 655 void bswap(Type Ty, GPRRegister reg); |
629 | 656 |
630 void bt(GPRRegister base, GPRRegister offset); | 657 void bt(GPRRegister base, GPRRegister offset); |
631 | 658 |
632 void ret(); | 659 void ret(); |
633 void ret(const Immediate &imm); | 660 void ret(const Immediate &imm); |
634 | 661 |
635 // 'size' indicates size in bytes and must be in the range 1..8. | 662 // 'size' indicates size in bytes and must be in the range 1..8. |
636 void nop(int size = 1); | 663 void nop(int size = 1); |
637 void int3(); | 664 void int3(); |
638 void hlt(); | 665 void hlt(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 inline void AssemblerX86::EmitFixup(AssemblerFixup *fixup) { | 745 inline void AssemblerX86::EmitFixup(AssemblerFixup *fixup) { |
719 buffer_.EmitFixup(fixup); | 746 buffer_.EmitFixup(fixup); |
720 } | 747 } |
721 | 748 |
722 inline void AssemblerX86::EmitOperandSizeOverride() { EmitUint8(0x66); } | 749 inline void AssemblerX86::EmitOperandSizeOverride() { EmitUint8(0x66); } |
723 | 750 |
724 } // end of namespace x86 | 751 } // end of namespace x86 |
725 } // end of namespace Ice | 752 } // end of namespace Ice |
726 | 753 |
727 #endif // SUBZERO_SRC_ASSEMBLER_IA32_H_ | 754 #endif // SUBZERO_SRC_ASSEMBLER_IA32_H_ |
OLD | NEW |