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

Side by Side Diff: src/IceInstMIPS32.h

Issue 2250203005: [SubZero] Added InstMIPS32Load to differentiate stores from loads (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Renamed InstMIPS32Memory to InstMIPS32Store Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceInstMIPS32.h - MIPS32 machine instrs --*- C++ -*-=== // 1 //===- subzero/src/IceInstMIPS32.h - MIPS32 machine instrs --*- 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 /// \file 10 /// \file
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 InstMIPS32ThreeAddrGPR(Cfg *Func, Variable *Dest, Variable *Src0, 485 InstMIPS32ThreeAddrGPR(Cfg *Func, Variable *Dest, Variable *Src0,
486 Variable *Src1) 486 Variable *Src1)
487 : InstMIPS32(Func, K, 2, Dest) { 487 : InstMIPS32(Func, K, 2, Dest) {
488 addSource(Src0); 488 addSource(Src0);
489 addSource(Src1); 489 addSource(Src1);
490 } 490 }
491 491
492 static const char *Opcode; 492 static const char *Opcode;
493 }; 493 };
494 494
495 // InstMIPS32Memory represents instructions which loads/stores data on memory 495 // InstMIPS32Load represents instructions which loads data from memory
496 // Its format is "OPCODE GPR, OFFSET(BASE GPR)" 496 // Its format is "OPCODE GPR, OFFSET(BASE GPR)"
497 template <InstMIPS32::InstKindMIPS32 K> 497 template <InstMIPS32::InstKindMIPS32 K>
498 class InstMIPS32Memory : public InstMIPS32 { 498 class InstMIPS32Load : public InstMIPS32 {
499 InstMIPS32Memory() = delete; 499 InstMIPS32Load() = delete;
500 InstMIPS32Memory(const InstMIPS32Memory &) = delete; 500 InstMIPS32Load(const InstMIPS32Load &) = delete;
501 InstMIPS32Memory &operator=(const InstMIPS32Memory &) = delete; 501 InstMIPS32Load &operator=(const InstMIPS32Load &) = delete;
502 502
503 public: 503 public:
504 static InstMIPS32Memory *create(Cfg *Func, Variable *Value, 504 static InstMIPS32Load *create(Cfg *Func, Variable *Value,
505 OperandMIPS32Mem *Mem, 505 OperandMIPS32Mem *Mem,
506 RelocOp Reloc = RO_No) { 506 RelocOp Reloc = RO_No) {
507 return new (Func->allocate<InstMIPS32Memory>()) 507 return new (Func->allocate<InstMIPS32Load>())
508 InstMIPS32Memory(Func, Value, Mem, Reloc); 508 InstMIPS32Load(Func, Value, Mem, Reloc);
509 } 509 }
510 510
511 void emit(const Cfg *Func) const override { 511 void emit(const Cfg *Func) const override {
512 if (!BuildDefs::dump())
513 return;
514 Ostream &Str = Func->getContext()->getStrEmit();
515 assert(getSrcSize() == 1);
516 Str << "\t" << Opcode << "\t";
517 getDest()->emit(Func);
518 Str << ", ";
519 emitRelocOp(Str, Reloc);
520 getSrc(0)->emit(Func);
521 }
522
523 void emitIAS(const Cfg *Func) const override {
524 (void)Func;
525 llvm_unreachable("Not yet implemented");
526 }
527
528 void dump(const Cfg *Func) const override {
529 if (!BuildDefs::dump())
530 return;
531 Ostream &Str = Func->getContext()->getStrDump();
532 Str << "\t" << Opcode << "\t";
533 getDest()->dump(Func);
534 Str << ", ";
535 emitRelocOp(Str, Reloc);
536 Str << (Reloc ? "(" : "");
537 getSrc(0)->dump(Func);
538 Str << (Reloc ? ")" : "");
539 }
540 static bool classof(const Inst *Inst) { return isClassof(Inst, K); }
541
542 private:
543 InstMIPS32Load(Cfg *Func, Variable *Value, OperandMIPS32Mem *Mem,
544 RelocOp Reloc = RO_No)
545 : InstMIPS32(Func, K, 2, Value), Reloc(Reloc) {
546 addSource(Mem);
547 }
548 static const char *Opcode;
549 const RelocOp Reloc;
550 };
551
552 // InstMIPS32Store represents instructions which stores data to memory
553 // Its format is "OPCODE GPR, OFFSET(BASE GPR)"
554 template <InstMIPS32::InstKindMIPS32 K>
555 class InstMIPS32Store : public InstMIPS32 {
556 InstMIPS32Store() = delete;
557 InstMIPS32Store(const InstMIPS32Store &) = delete;
558 InstMIPS32Store &operator=(const InstMIPS32Store &) = delete;
559
560 public:
561 static InstMIPS32Store *create(Cfg *Func, Variable *Value,
562 OperandMIPS32Mem *Mem,
563 RelocOp Reloc = RO_No) {
564 return new (Func->allocate<InstMIPS32Store>())
565 InstMIPS32Store(Func, Value, Mem, Reloc);
566 }
567
568 void emit(const Cfg *Func) const override {
512 if (!BuildDefs::dump()) 569 if (!BuildDefs::dump())
513 return; 570 return;
514 Ostream &Str = Func->getContext()->getStrEmit(); 571 Ostream &Str = Func->getContext()->getStrEmit();
515 assert(getSrcSize() == 2); 572 assert(getSrcSize() == 2);
516 Str << "\t" << Opcode << "\t"; 573 Str << "\t" << Opcode << "\t";
517 getSrc(0)->emit(Func); 574 getSrc(0)->emit(Func);
518 Str << ", "; 575 Str << ", ";
519 emitRelocOp(Str, Reloc); 576 emitRelocOp(Str, Reloc);
520 getSrc(1)->emit(Func); 577 getSrc(1)->emit(Func);
521 } 578 }
(...skipping 11 matching lines...) Expand all
533 getSrc(0)->dump(Func); 590 getSrc(0)->dump(Func);
534 Str << ", "; 591 Str << ", ";
535 emitRelocOp(Str, Reloc); 592 emitRelocOp(Str, Reloc);
536 Str << (Reloc ? "(" : ""); 593 Str << (Reloc ? "(" : "");
537 getSrc(1)->dump(Func); 594 getSrc(1)->dump(Func);
538 Str << (Reloc ? ")" : ""); 595 Str << (Reloc ? ")" : "");
539 } 596 }
540 static bool classof(const Inst *Inst) { return isClassof(Inst, K); } 597 static bool classof(const Inst *Inst) { return isClassof(Inst, K); }
541 598
542 private: 599 private:
543 InstMIPS32Memory(Cfg *Func, Variable *Value, OperandMIPS32Mem *Mem, 600 InstMIPS32Store(Cfg *Func, Variable *Value, OperandMIPS32Mem *Mem,
544 RelocOp Reloc = RO_No) 601 RelocOp Reloc = RO_No)
545 : InstMIPS32(Func, K, 2, nullptr), Reloc(Reloc) { 602 : InstMIPS32(Func, K, 2, nullptr), Reloc(Reloc) {
546 addSource(Value); 603 addSource(Value);
547 addSource(Mem); 604 addSource(Mem);
548 } 605 }
549 static const char *Opcode; 606 static const char *Opcode;
550 const RelocOp Reloc; 607 const RelocOp Reloc;
551 }; 608 };
552 609
553 // InstMIPS32Label represents an intra-block label that is the target of an 610 // InstMIPS32Label represents an intra-block label that is the target of an
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 using InstMIPS32Cvt_d_l = InstMIPS32TwoAddrFPR<InstMIPS32::Cvt_d_l>; 807 using InstMIPS32Cvt_d_l = InstMIPS32TwoAddrFPR<InstMIPS32::Cvt_d_l>;
751 using InstMIPS32Cvt_d_w = InstMIPS32TwoAddrFPR<InstMIPS32::Cvt_d_w>; 808 using InstMIPS32Cvt_d_w = InstMIPS32TwoAddrFPR<InstMIPS32::Cvt_d_w>;
752 using InstMIPS32Cvt_s_d = InstMIPS32TwoAddrFPR<InstMIPS32::Cvt_s_d>; 809 using InstMIPS32Cvt_s_d = InstMIPS32TwoAddrFPR<InstMIPS32::Cvt_s_d>;
753 using InstMIPS32Cvt_s_l = InstMIPS32TwoAddrFPR<InstMIPS32::Cvt_s_l>; 810 using InstMIPS32Cvt_s_l = InstMIPS32TwoAddrFPR<InstMIPS32::Cvt_s_l>;
754 using InstMIPS32Cvt_s_w = InstMIPS32TwoAddrFPR<InstMIPS32::Cvt_s_w>; 811 using InstMIPS32Cvt_s_w = InstMIPS32TwoAddrFPR<InstMIPS32::Cvt_s_w>;
755 using InstMIPS32Div = InstMIPS32ThreeAddrGPR<InstMIPS32::Div>; 812 using InstMIPS32Div = InstMIPS32ThreeAddrGPR<InstMIPS32::Div>;
756 using InstMIPS32Div_d = InstMIPS32ThreeAddrFPR<InstMIPS32::Div_d>; 813 using InstMIPS32Div_d = InstMIPS32ThreeAddrFPR<InstMIPS32::Div_d>;
757 using InstMIPS32Div_s = InstMIPS32ThreeAddrFPR<InstMIPS32::Div_s>; 814 using InstMIPS32Div_s = InstMIPS32ThreeAddrFPR<InstMIPS32::Div_s>;
758 using InstMIPS32Divu = InstMIPS32ThreeAddrGPR<InstMIPS32::Divu>; 815 using InstMIPS32Divu = InstMIPS32ThreeAddrGPR<InstMIPS32::Divu>;
759 using InstMIPS32La = InstMIPS32UnaryopGPR<InstMIPS32::La>; 816 using InstMIPS32La = InstMIPS32UnaryopGPR<InstMIPS32::La>;
760 using InstMIPS32Ldc1 = InstMIPS32Memory<InstMIPS32::Ldc1>; 817 using InstMIPS32Ldc1 = InstMIPS32Load<InstMIPS32::Ldc1>;
761 using InstMIPS32Lui = InstMIPS32UnaryopGPR<InstMIPS32::Lui>; 818 using InstMIPS32Lui = InstMIPS32UnaryopGPR<InstMIPS32::Lui>;
762 using InstMIPS32Lw = InstMIPS32Memory<InstMIPS32::Lw>; 819 using InstMIPS32Lw = InstMIPS32Load<InstMIPS32::Lw>;
763 using InstMIPS32Lwc1 = InstMIPS32Memory<InstMIPS32::Lwc1>; 820 using InstMIPS32Lwc1 = InstMIPS32Load<InstMIPS32::Lwc1>;
764 using InstMIPS32Mfc1 = InstMIPS32TwoAddrGPR<InstMIPS32::Mfc1>; 821 using InstMIPS32Mfc1 = InstMIPS32TwoAddrGPR<InstMIPS32::Mfc1>;
765 using InstMIPS32Mfhi = InstMIPS32UnaryopGPR<InstMIPS32::Mfhi>; 822 using InstMIPS32Mfhi = InstMIPS32UnaryopGPR<InstMIPS32::Mfhi>;
766 using InstMIPS32Mflo = InstMIPS32UnaryopGPR<InstMIPS32::Mflo>; 823 using InstMIPS32Mflo = InstMIPS32UnaryopGPR<InstMIPS32::Mflo>;
767 using InstMIPS32Mov_d = InstMIPS32TwoAddrFPR<InstMIPS32::Mov_d>; 824 using InstMIPS32Mov_d = InstMIPS32TwoAddrFPR<InstMIPS32::Mov_d>;
768 using InstMIPS32Mov_s = InstMIPS32TwoAddrFPR<InstMIPS32::Mov_s>; 825 using InstMIPS32Mov_s = InstMIPS32TwoAddrFPR<InstMIPS32::Mov_s>;
769 using InstMIPS32Mtc1 = InstMIPS32TwoAddrGPR<InstMIPS32::Mtc1>; 826 using InstMIPS32Mtc1 = InstMIPS32TwoAddrGPR<InstMIPS32::Mtc1>;
770 using InstMIPS32Mthi = InstMIPS32UnaryopGPR<InstMIPS32::Mthi>; 827 using InstMIPS32Mthi = InstMIPS32UnaryopGPR<InstMIPS32::Mthi>;
771 using InstMIPS32Mtlo = InstMIPS32UnaryopGPR<InstMIPS32::Mtlo>; 828 using InstMIPS32Mtlo = InstMIPS32UnaryopGPR<InstMIPS32::Mtlo>;
772 using InstMIPS32Mul = InstMIPS32ThreeAddrGPR<InstMIPS32::Mul>; 829 using InstMIPS32Mul = InstMIPS32ThreeAddrGPR<InstMIPS32::Mul>;
773 using InstMIPS32Mul_d = InstMIPS32ThreeAddrFPR<InstMIPS32::Mul_d>; 830 using InstMIPS32Mul_d = InstMIPS32ThreeAddrFPR<InstMIPS32::Mul_d>;
774 using InstMIPS32Mul_s = InstMIPS32ThreeAddrFPR<InstMIPS32::Mul_s>; 831 using InstMIPS32Mul_s = InstMIPS32ThreeAddrFPR<InstMIPS32::Mul_s>;
775 using InstMIPS32Mult = InstMIPS32ThreeAddrGPR<InstMIPS32::Mult>; 832 using InstMIPS32Mult = InstMIPS32ThreeAddrGPR<InstMIPS32::Mult>;
776 using InstMIPS32Multu = InstMIPS32ThreeAddrGPR<InstMIPS32::Multu>; 833 using InstMIPS32Multu = InstMIPS32ThreeAddrGPR<InstMIPS32::Multu>;
777 using InstMIPS32Or = InstMIPS32ThreeAddrGPR<InstMIPS32::Or>; 834 using InstMIPS32Or = InstMIPS32ThreeAddrGPR<InstMIPS32::Or>;
778 using InstMIPS32Ori = InstMIPS32Imm16<InstMIPS32::Ori>; 835 using InstMIPS32Ori = InstMIPS32Imm16<InstMIPS32::Ori>;
779 using InstMIPS32Sdc1 = InstMIPS32Memory<InstMIPS32::Sdc1>; 836 using InstMIPS32Sdc1 = InstMIPS32Store<InstMIPS32::Sdc1>;
780 using InstMIPS32Sll = InstMIPS32Imm16<InstMIPS32::Sll>; 837 using InstMIPS32Sll = InstMIPS32Imm16<InstMIPS32::Sll>;
781 using InstMIPS32Sllv = InstMIPS32ThreeAddrGPR<InstMIPS32::Sllv>; 838 using InstMIPS32Sllv = InstMIPS32ThreeAddrGPR<InstMIPS32::Sllv>;
782 using InstMIPS32Slt = InstMIPS32ThreeAddrGPR<InstMIPS32::Slt>; 839 using InstMIPS32Slt = InstMIPS32ThreeAddrGPR<InstMIPS32::Slt>;
783 using InstMIPS32Slti = InstMIPS32Imm16<InstMIPS32::Slti>; 840 using InstMIPS32Slti = InstMIPS32Imm16<InstMIPS32::Slti>;
784 using InstMIPS32Sltiu = InstMIPS32Imm16<InstMIPS32::Sltiu>; 841 using InstMIPS32Sltiu = InstMIPS32Imm16<InstMIPS32::Sltiu>;
785 using InstMIPS32Sltu = InstMIPS32ThreeAddrGPR<InstMIPS32::Sltu>; 842 using InstMIPS32Sltu = InstMIPS32ThreeAddrGPR<InstMIPS32::Sltu>;
786 using InstMIPS32Sra = InstMIPS32Imm16<InstMIPS32::Sra>; 843 using InstMIPS32Sra = InstMIPS32Imm16<InstMIPS32::Sra>;
787 using InstMIPS32Srav = InstMIPS32ThreeAddrGPR<InstMIPS32::Srav>; 844 using InstMIPS32Srav = InstMIPS32ThreeAddrGPR<InstMIPS32::Srav>;
788 using InstMIPS32Srl = InstMIPS32Imm16<InstMIPS32::Srl>; 845 using InstMIPS32Srl = InstMIPS32Imm16<InstMIPS32::Srl>;
789 using InstMIPS32Srlv = InstMIPS32ThreeAddrGPR<InstMIPS32::Srlv>; 846 using InstMIPS32Srlv = InstMIPS32ThreeAddrGPR<InstMIPS32::Srlv>;
790 using InstMIPS32Sub = InstMIPS32ThreeAddrGPR<InstMIPS32::Sub>; 847 using InstMIPS32Sub = InstMIPS32ThreeAddrGPR<InstMIPS32::Sub>;
791 using InstMIPS32Sub_d = InstMIPS32ThreeAddrFPR<InstMIPS32::Sub_d>; 848 using InstMIPS32Sub_d = InstMIPS32ThreeAddrFPR<InstMIPS32::Sub_d>;
792 using InstMIPS32Sub_s = InstMIPS32ThreeAddrFPR<InstMIPS32::Sub_s>; 849 using InstMIPS32Sub_s = InstMIPS32ThreeAddrFPR<InstMIPS32::Sub_s>;
793 using InstMIPS32Subu = InstMIPS32ThreeAddrGPR<InstMIPS32::Subu>; 850 using InstMIPS32Subu = InstMIPS32ThreeAddrGPR<InstMIPS32::Subu>;
794 using InstMIPS32Sw = InstMIPS32Memory<InstMIPS32::Sw>; 851 using InstMIPS32Sw = InstMIPS32Store<InstMIPS32::Sw>;
795 using InstMIPS32Swc1 = InstMIPS32Memory<InstMIPS32::Swc1>; 852 using InstMIPS32Swc1 = InstMIPS32Store<InstMIPS32::Swc1>;
796 using InstMIPS32Trunc_l_d = InstMIPS32TwoAddrFPR<InstMIPS32::Trunc_l_d>; 853 using InstMIPS32Trunc_l_d = InstMIPS32TwoAddrFPR<InstMIPS32::Trunc_l_d>;
797 using InstMIPS32Trunc_l_s = InstMIPS32TwoAddrFPR<InstMIPS32::Trunc_l_s>; 854 using InstMIPS32Trunc_l_s = InstMIPS32TwoAddrFPR<InstMIPS32::Trunc_l_s>;
798 using InstMIPS32Trunc_w_d = InstMIPS32TwoAddrFPR<InstMIPS32::Trunc_w_d>; 855 using InstMIPS32Trunc_w_d = InstMIPS32TwoAddrFPR<InstMIPS32::Trunc_w_d>;
799 using InstMIPS32Trunc_w_s = InstMIPS32TwoAddrFPR<InstMIPS32::Trunc_w_s>; 856 using InstMIPS32Trunc_w_s = InstMIPS32TwoAddrFPR<InstMIPS32::Trunc_w_s>;
800 using InstMIPS32Ori = InstMIPS32Imm16<InstMIPS32::Ori>; 857 using InstMIPS32Ori = InstMIPS32Imm16<InstMIPS32::Ori>;
801 using InstMIPS32Xor = InstMIPS32ThreeAddrGPR<InstMIPS32::Xor>; 858 using InstMIPS32Xor = InstMIPS32ThreeAddrGPR<InstMIPS32::Xor>;
802 using InstMIPS32Xori = InstMIPS32Imm16<InstMIPS32::Xori>; 859 using InstMIPS32Xori = InstMIPS32Imm16<InstMIPS32::Xori>;
803 860
804 /// Handles (some of) vmov's various formats. 861 /// Handles (some of) vmov's various formats.
805 class InstMIPS32Mov final : public InstMIPS32 { 862 class InstMIPS32Mov final : public InstMIPS32 {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 template <> void InstMIPS32Mtlo::emit(const Cfg *Func) const; 906 template <> void InstMIPS32Mtlo::emit(const Cfg *Func) const;
850 template <> void InstMIPS32Mthi::emit(const Cfg *Func) const; 907 template <> void InstMIPS32Mthi::emit(const Cfg *Func) const;
851 template <> void InstMIPS32Mult::emit(const Cfg *Func) const; 908 template <> void InstMIPS32Mult::emit(const Cfg *Func) const;
852 template <> void InstMIPS32Multu::emit(const Cfg *Func) const; 909 template <> void InstMIPS32Multu::emit(const Cfg *Func) const;
853 template <> void InstMIPS32Lui::emit(const Cfg *Func) const; 910 template <> void InstMIPS32Lui::emit(const Cfg *Func) const;
854 911
855 } // end of namespace MIPS32 912 } // end of namespace MIPS32
856 } // end of namespace Ice 913 } // end of namespace Ice
857 914
858 #endif // SUBZERO_SRC_ICEINSTMIPS32_H 915 #endif // SUBZERO_SRC_ICEINSTMIPS32_H
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698