OLD | NEW |
1 //===- subzero/src/IceOperand.h - High-level operands -----------*- C++ -*-===// | 1 //===- subzero/src/IceOperand.h - High-level operands -----------*- 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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 RR_MustNotHaveRegister, | 640 RR_MustNotHaveRegister, |
641 }; | 641 }; |
642 | 642 |
643 public: | 643 public: |
644 static Variable *create(Cfg *Func, Type Ty, SizeT Index) { | 644 static Variable *create(Cfg *Func, Type Ty, SizeT Index) { |
645 return new (Func->allocate<Variable>()) | 645 return new (Func->allocate<Variable>()) |
646 Variable(Func, kVariable, Ty, Index); | 646 Variable(Func, kVariable, Ty, Index); |
647 } | 647 } |
648 | 648 |
649 SizeT getIndex() const { return Number; } | 649 SizeT getIndex() const { return Number; } |
650 std::string getName(const Cfg *Func) const; | 650 std::string getName() const { |
| 651 if (Name.hasStdString()) |
| 652 return Name.toString(); |
| 653 return "__" + std::to_string(getIndex()); |
| 654 } |
651 virtual void setName(const Cfg *Func, const std::string &NewName) { | 655 virtual void setName(const Cfg *Func, const std::string &NewName) { |
652 (void)Func; | |
653 if (NewName.empty()) | 656 if (NewName.empty()) |
654 return; | 657 return; |
655 Name = VariableString::createWithString(Func, NewName); | 658 Name = VariableString::createWithString(Func, NewName); |
656 } | 659 } |
657 | 660 |
658 bool getIsArg() const { return IsArgument; } | 661 bool getIsArg() const { return IsArgument; } |
659 virtual void setIsArg(bool Val = true) { IsArgument = Val; } | 662 virtual void setIsArg(bool Val = true) { IsArgument = Val; } |
660 bool getIsImplicitArg() const { return IsImplicitArgument; } | 663 bool getIsImplicitArg() const { return IsImplicitArgument; } |
661 void setIsImplicitArg(bool Val = true) { IsImplicitArgument = Val; } | 664 void setIsImplicitArg(bool Val = true) { IsImplicitArgument = Val; } |
662 | 665 |
663 void setIgnoreLiveness() { IgnoreLiveness = true; } | 666 void setIgnoreLiveness() { IgnoreLiveness = true; } |
664 bool getIgnoreLiveness() const { | 667 bool getIgnoreLiveness() const { |
665 return IgnoreLiveness || IsRematerializable; | 668 return IgnoreLiveness || IsRematerializable; |
666 } | 669 } |
667 | 670 |
668 int32_t getStackOffset() const { return StackOffset; } | 671 int32_t getStackOffset() const { return StackOffset; } |
669 void setStackOffset(int32_t Offset) { StackOffset = Offset; } | 672 void setStackOffset(int32_t Offset) { StackOffset = Offset; } |
670 /// Returns the variable's stack offset in symbolic form, to improve | 673 /// Returns the variable's stack offset in symbolic form, to improve |
671 /// readability in DecorateAsm mode. | 674 /// readability in DecorateAsm mode. |
672 std::string getSymbolicStackOffset(const Cfg *Func) const { | 675 std::string getSymbolicStackOffset() const { |
673 if (!BuildDefs::dump()) | 676 if (!BuildDefs::dump()) |
674 return ""; | 677 return ""; |
675 return "lv$" + getName(Func); | 678 return "lv$" + getName(); |
676 } | 679 } |
677 | 680 |
678 bool hasReg() const { return getRegNum().hasValue(); } | 681 bool hasReg() const { return getRegNum().hasValue(); } |
679 RegNumT getRegNum() const { return RegNum; } | 682 RegNumT getRegNum() const { return RegNum; } |
680 void setRegNum(RegNumT NewRegNum) { | 683 void setRegNum(RegNumT NewRegNum) { |
681 // Regnum shouldn't be set more than once. | 684 // Regnum shouldn't be set more than once. |
682 assert(!hasReg() || RegNum == NewRegNum); | 685 assert(!hasReg() || RegNum == NewRegNum); |
683 RegNum = NewRegNum; | 686 RegNum = NewRegNum; |
684 } | 687 } |
685 bool hasRegTmp() const { return getRegNumTmp().hasValue(); } | 688 bool hasRegTmp() const { return getRegNumTmp().hasValue(); } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 } | 751 } |
749 | 752 |
750 protected: | 753 protected: |
751 Variable(const Cfg *Func, OperandKind K, Type Ty, SizeT Index) | 754 Variable(const Cfg *Func, OperandKind K, Type Ty, SizeT Index) |
752 : Operand(K, Ty), Number(Index), | 755 : Operand(K, Ty), Number(Index), |
753 Name(VariableString::createWithoutString(Func)), | 756 Name(VariableString::createWithoutString(Func)), |
754 RegisterClass(static_cast<RegClass>(Ty)) { | 757 RegisterClass(static_cast<RegClass>(Ty)) { |
755 Vars = VarsReal; | 758 Vars = VarsReal; |
756 Vars[0] = this; | 759 Vars[0] = this; |
757 NumVars = 1; | 760 NumVars = 1; |
758 if (BuildDefs::dump()) { | |
759 Name = VariableString::createWithString( | |
760 Func, "__" + std::to_string(getIndex())); | |
761 } else { | |
762 Name = VariableString::createWithoutString(Func); | |
763 } | |
764 } | 761 } |
765 /// Number is unique across all variables, and is used as a (bit)vector index | 762 /// Number is unique across all variables, and is used as a (bit)vector index |
766 /// for liveness analysis. | 763 /// for liveness analysis. |
767 const SizeT Number; | 764 const SizeT Number; |
768 VariableString Name; | 765 VariableString Name; |
769 bool IsArgument = false; | 766 bool IsArgument = false; |
770 bool IsImplicitArgument = false; | 767 bool IsImplicitArgument = false; |
771 /// IgnoreLiveness means that the variable should be ignored when constructing | 768 /// IgnoreLiveness means that the variable should be ignored when constructing |
772 /// and validating live ranges. This is usually reserved for the stack | 769 /// and validating live ranges. This is usually reserved for the stack |
773 /// pointer and other physical registers specifically referenced by name. | 770 /// pointer and other physical registers specifically referenced by name. |
(...skipping 24 matching lines...) Expand all Loading... |
798 | 795 |
799 public: | 796 public: |
800 static Variable64On32 *create(Cfg *Func, Type Ty, SizeT Index) { | 797 static Variable64On32 *create(Cfg *Func, Type Ty, SizeT Index) { |
801 return new (Func->allocate<Variable64On32>()) | 798 return new (Func->allocate<Variable64On32>()) |
802 Variable64On32(Func, kVariable64On32, Ty, Index); | 799 Variable64On32(Func, kVariable64On32, Ty, Index); |
803 } | 800 } |
804 | 801 |
805 void setName(const Cfg *Func, const std::string &NewName) override { | 802 void setName(const Cfg *Func, const std::string &NewName) override { |
806 Variable::setName(Func, NewName); | 803 Variable::setName(Func, NewName); |
807 if (LoVar && HiVar) { | 804 if (LoVar && HiVar) { |
808 LoVar->setName(Func, getName(Func) + "__lo"); | 805 LoVar->setName(Func, getName() + "__lo"); |
809 HiVar->setName(Func, getName(Func) + "__hi"); | 806 HiVar->setName(Func, getName() + "__hi"); |
810 } | 807 } |
811 } | 808 } |
812 | 809 |
813 void setIsArg(bool Val = true) override { | 810 void setIsArg(bool Val = true) override { |
814 Variable::setIsArg(Val); | 811 Variable::setIsArg(Val); |
815 if (LoVar && HiVar) { | 812 if (LoVar && HiVar) { |
816 LoVar->setIsArg(Val); | 813 LoVar->setIsArg(Val); |
817 HiVar->setIsArg(Val); | 814 HiVar->setIsArg(Val); |
818 } | 815 } |
819 } | 816 } |
820 | 817 |
821 Variable *getLo() const { | 818 Variable *getLo() const { |
822 assert(LoVar != nullptr); | 819 assert(LoVar != nullptr); |
823 return LoVar; | 820 return LoVar; |
824 } | 821 } |
825 Variable *getHi() const { | 822 Variable *getHi() const { |
826 assert(HiVar != nullptr); | 823 assert(HiVar != nullptr); |
827 return HiVar; | 824 return HiVar; |
828 } | 825 } |
829 | 826 |
830 void initHiLo(Cfg *Func) { | 827 void initHiLo(Cfg *Func) { |
831 assert(LoVar == nullptr); | 828 assert(LoVar == nullptr); |
832 assert(HiVar == nullptr); | 829 assert(HiVar == nullptr); |
833 LoVar = Func->makeVariable(IceType_i32); | 830 LoVar = Func->makeVariable(IceType_i32); |
834 HiVar = Func->makeVariable(IceType_i32); | 831 HiVar = Func->makeVariable(IceType_i32); |
835 LoVar->setIsArg(getIsArg()); | 832 LoVar->setIsArg(getIsArg()); |
836 HiVar->setIsArg(getIsArg()); | 833 HiVar->setIsArg(getIsArg()); |
837 if (BuildDefs::dump()) { | 834 if (BuildDefs::dump()) { |
838 LoVar->setName(Func, getName(Func) + "__lo"); | 835 LoVar->setName(Func, getName() + "__lo"); |
839 HiVar->setName(Func, getName(Func) + "__hi"); | 836 HiVar->setName(Func, getName() + "__hi"); |
840 } | 837 } |
841 } | 838 } |
842 | 839 |
843 static bool classof(const Operand *Operand) { | 840 static bool classof(const Operand *Operand) { |
844 OperandKind Kind = Operand->getKind(); | 841 OperandKind Kind = Operand->getKind(); |
845 return Kind == kVariable64On32; | 842 return Kind == kVariable64On32; |
846 } | 843 } |
847 | 844 |
848 protected: | 845 protected: |
849 Variable64On32(const Cfg *Func, OperandKind K, Type Ty, SizeT Index) | 846 Variable64On32(const Cfg *Func, OperandKind K, Type Ty, SizeT Index) |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 private: | 964 private: |
968 const Cfg *Func; | 965 const Cfg *Func; |
969 MetadataKind Kind; | 966 MetadataKind Kind; |
970 CfgVector<VariableTracking> Metadata; | 967 CfgVector<VariableTracking> Metadata; |
971 const static InstDefList NoDefinitions; | 968 const static InstDefList NoDefinitions; |
972 }; | 969 }; |
973 | 970 |
974 } // end of namespace Ice | 971 } // end of namespace Ice |
975 | 972 |
976 #endif // SUBZERO_SRC_ICEOPERAND_H | 973 #endif // SUBZERO_SRC_ICEOPERAND_H |
OLD | NEW |