OLD | NEW |
1 //===- subzero/src/IceInstX8632.h - Low-level x86 instructions --*- C++ -*-===// | 1 //===- subzero/src/IceInstX8632.h - Low-level x86 instructions --*- C++ -*-===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file declares the InstX8632 and OperandX8632 classes and | 10 // This file declares the InstX8632 and OperandX8632 classes and |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 Subss, | 256 Subss, |
257 Test, | 257 Test, |
258 Ucomiss, | 258 Ucomiss, |
259 UD2, | 259 UD2, |
260 Xadd, | 260 Xadd, |
261 Xchg, | 261 Xchg, |
262 Xor | 262 Xor |
263 }; | 263 }; |
264 | 264 |
265 static const char *getWidthString(Type Ty); | 265 static const char *getWidthString(Type Ty); |
| 266 static const char *getFldString(Type Ty); |
266 void dump(const Cfg *Func) const override; | 267 void dump(const Cfg *Func) const override; |
267 | 268 |
268 protected: | 269 protected: |
269 InstX8632(Cfg *Func, InstKindX8632 Kind, SizeT Maxsrcs, Variable *Dest) | 270 InstX8632(Cfg *Func, InstKindX8632 Kind, SizeT Maxsrcs, Variable *Dest) |
270 : InstTarget(Func, static_cast<InstKind>(Kind), Maxsrcs, Dest) {} | 271 : InstTarget(Func, static_cast<InstKind>(Kind), Maxsrcs, Dest) {} |
271 ~InstX8632() override {} | 272 ~InstX8632() override {} |
272 static bool isClassof(const Inst *Inst, InstKindX8632 MyKind) { | 273 static bool isClassof(const Inst *Inst, InstKindX8632 MyKind) { |
273 return Inst->getKind() == static_cast<InstKind>(MyKind); | 274 return Inst->getKind() == static_cast<InstKind>(MyKind); |
274 } | 275 } |
275 }; | 276 }; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 InstX8632UnaryopGPR &operator=(const InstX8632UnaryopGPR &) = delete; | 508 InstX8632UnaryopGPR &operator=(const InstX8632UnaryopGPR &) = delete; |
508 | 509 |
509 public: | 510 public: |
510 static InstX8632UnaryopGPR *create(Cfg *Func, Variable *Dest, Operand *Src) { | 511 static InstX8632UnaryopGPR *create(Cfg *Func, Variable *Dest, Operand *Src) { |
511 return new (Func->allocate<InstX8632UnaryopGPR>()) | 512 return new (Func->allocate<InstX8632UnaryopGPR>()) |
512 InstX8632UnaryopGPR(Func, Dest, Src); | 513 InstX8632UnaryopGPR(Func, Dest, Src); |
513 } | 514 } |
514 void emit(const Cfg *Func) const override { | 515 void emit(const Cfg *Func) const override { |
515 Ostream &Str = Func->getContext()->getStrEmit(); | 516 Ostream &Str = Func->getContext()->getStrEmit(); |
516 assert(getSrcSize() == 1); | 517 assert(getSrcSize() == 1); |
517 Str << "\t" << Opcode << "\t"; | 518 Type SrcTy = getSrc(0)->getType(); |
| 519 Type DestTy = getDest()->getType(); |
| 520 Str << "\t" << Opcode << getWidthString(SrcTy); |
| 521 // Movsx and movzx need both the source and dest type width letter |
| 522 // to define the operation. The other unary operations have the |
| 523 // same source and dest type and as a result need only one letter. |
| 524 if (SrcTy != DestTy) |
| 525 Str << getWidthString(DestTy); |
| 526 Str << "\t"; |
| 527 getSrc(0)->emit(Func); |
| 528 Str << ", "; |
518 getDest()->emit(Func); | 529 getDest()->emit(Func); |
519 Str << ", "; | |
520 getSrc(0)->emit(Func); | |
521 } | 530 } |
522 void emitIAS(const Cfg *Func) const override { | 531 void emitIAS(const Cfg *Func) const override { |
523 assert(getSrcSize() == 1); | 532 assert(getSrcSize() == 1); |
524 const Variable *Var = getDest(); | 533 const Variable *Var = getDest(); |
525 Type Ty = Var->getType(); | 534 Type Ty = Var->getType(); |
526 const Operand *Src = getSrc(0); | 535 const Operand *Src = getSrc(0); |
527 emitIASRegOpTyGPR(Func, Ty, Var, Src, Emitter); | 536 emitIASRegOpTyGPR(Func, Ty, Var, Src, Emitter); |
528 } | 537 } |
529 void dump(const Cfg *Func) const override { | 538 void dump(const Cfg *Func) const override { |
530 Ostream &Str = Func->getContext()->getStrDump(); | 539 Ostream &Str = Func->getContext()->getStrDump(); |
(...skipping 24 matching lines...) Expand all Loading... |
555 | 564 |
556 public: | 565 public: |
557 static InstX8632UnaryopXmm *create(Cfg *Func, Variable *Dest, Operand *Src) { | 566 static InstX8632UnaryopXmm *create(Cfg *Func, Variable *Dest, Operand *Src) { |
558 return new (Func->allocate<InstX8632UnaryopXmm>()) | 567 return new (Func->allocate<InstX8632UnaryopXmm>()) |
559 InstX8632UnaryopXmm(Func, Dest, Src); | 568 InstX8632UnaryopXmm(Func, Dest, Src); |
560 } | 569 } |
561 void emit(const Cfg *Func) const override { | 570 void emit(const Cfg *Func) const override { |
562 Ostream &Str = Func->getContext()->getStrEmit(); | 571 Ostream &Str = Func->getContext()->getStrEmit(); |
563 assert(getSrcSize() == 1); | 572 assert(getSrcSize() == 1); |
564 Str << "\t" << Opcode << "\t"; | 573 Str << "\t" << Opcode << "\t"; |
| 574 getSrc(0)->emit(Func); |
| 575 Str << ", "; |
565 getDest()->emit(Func); | 576 getDest()->emit(Func); |
566 Str << ", "; | |
567 getSrc(0)->emit(Func); | |
568 } | 577 } |
569 void emitIAS(const Cfg *Func) const override { | 578 void emitIAS(const Cfg *Func) const override { |
570 Type Ty = getDest()->getType(); | 579 Type Ty = getDest()->getType(); |
571 assert(getSrcSize() == 1); | 580 assert(getSrcSize() == 1); |
572 emitIASRegOpTyXMM(Func, Ty, getDest(), getSrc(0), Emitter); | 581 emitIASRegOpTyXMM(Func, Ty, getDest(), getSrc(0), Emitter); |
573 } | 582 } |
574 void dump(const Cfg *Func) const override { | 583 void dump(const Cfg *Func) const override { |
575 Ostream &Str = Func->getContext()->getStrDump(); | 584 Ostream &Str = Func->getContext()->getStrDump(); |
576 dumpDest(Func); | 585 dumpDest(Func); |
577 Str << " = " << Opcode << "." << getDest()->getType() << " "; | 586 Str << " = " << Opcode << "." << getDest()->getType() << " "; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 // Create a ternary-op instruction like div or idiv. | 782 // Create a ternary-op instruction like div or idiv. |
774 static InstX8632Ternop *create(Cfg *Func, Variable *Dest, Operand *Source1, | 783 static InstX8632Ternop *create(Cfg *Func, Variable *Dest, Operand *Source1, |
775 Operand *Source2) { | 784 Operand *Source2) { |
776 return new (Func->allocate<InstX8632Ternop>()) | 785 return new (Func->allocate<InstX8632Ternop>()) |
777 InstX8632Ternop(Func, Dest, Source1, Source2); | 786 InstX8632Ternop(Func, Dest, Source1, Source2); |
778 } | 787 } |
779 void emit(const Cfg *Func) const override { | 788 void emit(const Cfg *Func) const override { |
780 Ostream &Str = Func->getContext()->getStrEmit(); | 789 Ostream &Str = Func->getContext()->getStrEmit(); |
781 assert(getSrcSize() == 3); | 790 assert(getSrcSize() == 3); |
782 Str << "\t" << Opcode << "\t"; | 791 Str << "\t" << Opcode << "\t"; |
783 getDest()->emit(Func); | 792 getSrc(2)->emit(Func); |
784 Str << ", "; | 793 Str << ", "; |
785 getSrc(1)->emit(Func); | 794 getSrc(1)->emit(Func); |
786 Str << ", "; | 795 Str << ", "; |
787 getSrc(2)->emit(Func); | 796 getDest()->emit(Func); |
788 } | 797 } |
789 void emitIAS(const Cfg *Func) const override; | 798 void emitIAS(const Cfg *Func) const override; |
790 void dump(const Cfg *Func) const override { | 799 void dump(const Cfg *Func) const override { |
791 Ostream &Str = Func->getContext()->getStrDump(); | 800 Ostream &Str = Func->getContext()->getStrDump(); |
792 dumpDest(Func); | 801 dumpDest(Func); |
793 Str << " = " << Opcode << "." << getDest()->getType() << " "; | 802 Str << " = " << Opcode << "." << getDest()->getType() << " "; |
794 dumpSources(Func); | 803 dumpSources(Func); |
795 } | 804 } |
796 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } | 805 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
797 | 806 |
(...skipping 17 matching lines...) Expand all Loading... |
815 public: | 824 public: |
816 static InstX8632ThreeAddressop *create(Cfg *Func, Variable *Dest, | 825 static InstX8632ThreeAddressop *create(Cfg *Func, Variable *Dest, |
817 Operand *Source0, Operand *Source1) { | 826 Operand *Source0, Operand *Source1) { |
818 return new (Func->allocate<InstX8632ThreeAddressop>()) | 827 return new (Func->allocate<InstX8632ThreeAddressop>()) |
819 InstX8632ThreeAddressop(Func, Dest, Source0, Source1); | 828 InstX8632ThreeAddressop(Func, Dest, Source0, Source1); |
820 } | 829 } |
821 void emit(const Cfg *Func) const override { | 830 void emit(const Cfg *Func) const override { |
822 Ostream &Str = Func->getContext()->getStrEmit(); | 831 Ostream &Str = Func->getContext()->getStrEmit(); |
823 assert(getSrcSize() == 2); | 832 assert(getSrcSize() == 2); |
824 Str << "\t" << Opcode << "\t"; | 833 Str << "\t" << Opcode << "\t"; |
825 getDest()->emit(Func); | 834 getSrc(1)->emit(Func); |
826 Str << ", "; | 835 Str << ", "; |
827 getSrc(0)->emit(Func); | 836 getSrc(0)->emit(Func); |
828 Str << ", "; | 837 Str << ", "; |
829 getSrc(1)->emit(Func); | 838 getDest()->emit(Func); |
830 } | 839 } |
831 void emitIAS(const Cfg *Func) const override; | 840 void emitIAS(const Cfg *Func) const override; |
832 void dump(const Cfg *Func) const override { | 841 void dump(const Cfg *Func) const override { |
833 Ostream &Str = Func->getContext()->getStrDump(); | 842 Ostream &Str = Func->getContext()->getStrDump(); |
834 dumpDest(Func); | 843 dumpDest(Func); |
835 Str << " = " << Opcode << "." << getDest()->getType() << " "; | 844 Str << " = " << Opcode << "." << getDest()->getType() << " "; |
836 dumpSources(Func); | 845 dumpSources(Func); |
837 } | 846 } |
838 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } | 847 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } |
839 | 848 |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1545 template <> void InstX8632Pinsr::emitIAS(const Cfg *Func) const; | 1554 template <> void InstX8632Pinsr::emitIAS(const Cfg *Func) const; |
1546 template <> void InstX8632Movsx::emitIAS(const Cfg *Func) const; | 1555 template <> void InstX8632Movsx::emitIAS(const Cfg *Func) const; |
1547 template <> void InstX8632Movzx::emitIAS(const Cfg *Func) const; | 1556 template <> void InstX8632Movzx::emitIAS(const Cfg *Func) const; |
1548 template <> void InstX8632Pmull::emitIAS(const Cfg *Func) const; | 1557 template <> void InstX8632Pmull::emitIAS(const Cfg *Func) const; |
1549 template <> void InstX8632Pshufd::emitIAS(const Cfg *Func) const; | 1558 template <> void InstX8632Pshufd::emitIAS(const Cfg *Func) const; |
1550 template <> void InstX8632Shufps::emitIAS(const Cfg *Func) const; | 1559 template <> void InstX8632Shufps::emitIAS(const Cfg *Func) const; |
1551 | 1560 |
1552 } // end of namespace Ice | 1561 } // end of namespace Ice |
1553 | 1562 |
1554 #endif // SUBZERO_SRC_ICEINSTX8632_H | 1563 #endif // SUBZERO_SRC_ICEINSTX8632_H |
OLD | NEW |