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

Side by Side Diff: src/IceOperand.h

Issue 2116213002: Subzero: Allow deeper levels of variable splitting. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Rename getLinkedToTop() to getLinkedToRoot() Created 4 years, 5 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
OLDNEW
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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 bool getIsArg() const { return IsArgument; } 689 bool getIsArg() const { return IsArgument; }
690 virtual void setIsArg(bool Val = true) { IsArgument = Val; } 690 virtual void setIsArg(bool Val = true) { IsArgument = Val; }
691 bool getIsImplicitArg() const { return IsImplicitArgument; } 691 bool getIsImplicitArg() const { return IsImplicitArgument; }
692 void setIsImplicitArg(bool Val = true) { IsImplicitArgument = Val; } 692 void setIsImplicitArg(bool Val = true) { IsImplicitArgument = Val; }
693 693
694 void setIgnoreLiveness() { IgnoreLiveness = true; } 694 void setIgnoreLiveness() { IgnoreLiveness = true; }
695 bool getIgnoreLiveness() const { 695 bool getIgnoreLiveness() const {
696 return IgnoreLiveness || IsRematerializable; 696 return IgnoreLiveness || IsRematerializable;
697 } 697 }
698 698
699 int32_t getStackOffset() const { return StackOffset; } 699 static constexpr int32_t InvalidStackOffset = -1;
John 2016/07/06 16:07:39 maybe put this in the private: section?
Jim Stichnoth 2016/07/08 10:37:54 Done.
700 bool hasStackOffset() const { return StackOffset != InvalidStackOffset; }
701 int32_t getStackOffset() const {
702 assert(hasStackOffset());
703 return StackOffset;
704 }
700 void setStackOffset(int32_t Offset) { StackOffset = Offset; } 705 void setStackOffset(int32_t Offset) { StackOffset = Offset; }
701 /// Returns the variable's stack offset in symbolic form, to improve 706 /// Returns the variable's stack offset in symbolic form, to improve
702 /// readability in DecorateAsm mode. 707 /// readability in DecorateAsm mode.
703 std::string getSymbolicStackOffset() const { 708 std::string getSymbolicStackOffset() const {
704 if (!BuildDefs::dump()) 709 if (!BuildDefs::dump())
705 return ""; 710 return "";
706 return ".L$lv$" + getName(); 711 return ".L$lv$" + getName();
707 } 712 }
708 713
709 bool hasReg() const { return getRegNum().hasValue(); } 714 bool hasReg() const { return getRegNum().hasValue(); }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 /// instead of copying the existing assignment. 771 /// instead of copying the existing assignment.
767 const Variable *asType(const Cfg *Func, Type Ty, RegNumT NewRegNum) const; 772 const Variable *asType(const Cfg *Func, Type Ty, RegNumT NewRegNum) const;
768 773
769 void emit(const Cfg *Func) const override; 774 void emit(const Cfg *Func) const override;
770 using Operand::dump; 775 using Operand::dump;
771 void dump(const Cfg *Func, Ostream &Str) const override; 776 void dump(const Cfg *Func, Ostream &Str) const override;
772 777
773 /// Return reg num of base register, if different from stack/frame register. 778 /// Return reg num of base register, if different from stack/frame register.
774 virtual RegNumT getBaseRegNum() const { return RegNumT(); } 779 virtual RegNumT getBaseRegNum() const { return RegNumT(); }
775 780
776 void setLinkedTo(const Variable *Var) { 781 /// Access the LinkedTo field.
777 // If B is linked to A, and we now want to link C to B, we instead link C to 782 void setLinkedTo(Variable *Var) { LinkedTo = Var; }
778 // A so that we have one root (A) and all leaves (B, C) link directly to the 783 Variable *getLinkedTo() const { return LinkedTo; }
779 // root. 784 /// Follow the LinkedTo chain up to the furthest ancestor.
780 if (Var->getLinkedTo() != nullptr) { 785 Variable *getLinkedToRoot() const {
781 Var = Var->LinkedTo; 786 Variable *Root = LinkedTo;
782 assert(Var->LinkedTo == nullptr); 787 if (Root == nullptr)
John 2016/07/06 16:07:39 so this is if (Root == nullptr) return nullptr;
Jim Stichnoth 2016/07/08 10:37:54 Done.
783 } 788 return Root;
784 LinkedTo = Var; 789 while (Root->LinkedTo != nullptr)
785 } 790 Root = Root->LinkedTo;
John 2016/07/06 16:07:39 Why not if (Root->LinkedTo != nullptr) { return
Jim Stichnoth 2016/07/08 10:37:54 Because of stack overflow. I always think twice b
John 2016/07/08 15:09:05 This function requires minimal stack space, so eve
Jim Stichnoth 2016/07/10 11:44:43 I think maybe what you're suggesting is to pre-com
786 const Variable *getLinkedTo() const { 791 return Root;
787 // Make sure a leaf links directly to the root.
788 if (LinkedTo != nullptr)
789 assert(LinkedTo->LinkedTo == nullptr);
790 return LinkedTo;
791 } 792 }
792 793
793 static bool classof(const Operand *Operand) { 794 static bool classof(const Operand *Operand) {
794 OperandKind Kind = Operand->getKind(); 795 OperandKind Kind = Operand->getKind();
795 return Kind >= kVariable && Kind <= kVariable_Max; 796 return Kind >= kVariable && Kind <= kVariable_Max;
796 } 797 }
797 798
798 SizeT hashValue() const override { return std::hash<SizeT>()(getIndex()); } 799 SizeT hashValue() const override { return std::hash<SizeT>()(getIndex()); }
799 800
800 protected: 801 protected:
(...skipping 19 matching lines...) Expand all
820 // pointer), and StackOffset is the known offset from that register. 821 // pointer), and StackOffset is the known offset from that register.
821 bool IsRematerializable = false; 822 bool IsRematerializable = false;
822 RegRequirement RegRequirement = RR_MayHaveRegister; 823 RegRequirement RegRequirement = RR_MayHaveRegister;
823 RegClass RegisterClass; 824 RegClass RegisterClass;
824 /// RegNum is the allocated register, (as long as RegNum.hasValue() is true). 825 /// RegNum is the allocated register, (as long as RegNum.hasValue() is true).
825 RegNumT RegNum; 826 RegNumT RegNum;
826 /// RegNumTmp is the tentative assignment during register allocation. 827 /// RegNumTmp is the tentative assignment during register allocation.
827 RegNumT RegNumTmp; 828 RegNumT RegNumTmp;
828 /// StackOffset is the canonical location on stack (only if 829 /// StackOffset is the canonical location on stack (only if
829 /// RegNum.hasNoValue() || IsArgument). 830 /// RegNum.hasNoValue() || IsArgument).
830 int32_t StackOffset = 0; 831 int32_t StackOffset = InvalidStackOffset;
831 LiveRange Live; 832 LiveRange Live;
832 /// VarsReal (and Operand::Vars) are set up such that Vars[0] == this. 833 /// VarsReal (and Operand::Vars) are set up such that Vars[0] == this.
833 Variable *VarsReal[1]; 834 Variable *VarsReal[1];
834 /// This Variable may be "linked" to another Variable, such that if neither 835 /// This Variable may be "linked" to another Variable, such that if neither
835 /// Variable gets a register, they are guaranteed to share a stack location. 836 /// Variable gets a register, they are guaranteed to share a stack location.
836 const Variable *LinkedTo = nullptr; 837 Variable *LinkedTo = nullptr;
837 }; 838 };
838 839
839 // Variable64On32 represents a 64-bit variable on a 32-bit architecture. In 840 // Variable64On32 represents a 64-bit variable on a 32-bit architecture. In
840 // this situation the variable must be split into a low and a high word. 841 // this situation the variable must be split into a low and a high word.
841 class Variable64On32 : public Variable { 842 class Variable64On32 : public Variable {
842 Variable64On32() = delete; 843 Variable64On32() = delete;
843 Variable64On32(const Variable64On32 &) = delete; 844 Variable64On32(const Variable64On32 &) = delete;
844 Variable64On32 &operator=(const Variable64On32 &) = delete; 845 Variable64On32 &operator=(const Variable64On32 &) = delete;
845 846
846 public: 847 public:
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 return Operand->getKind() == kVariableBoolean; 1044 return Operand->getKind() == kVariableBoolean;
1044 } 1045 }
1045 1046
1046 private: 1047 private:
1047 Variable *BoolSource = nullptr; 1048 Variable *BoolSource = nullptr;
1048 }; 1049 };
1049 1050
1050 } // end of namespace Ice 1051 } // end of namespace Ice
1051 1052
1052 #endif // SUBZERO_SRC_ICEOPERAND_H 1053 #endif // SUBZERO_SRC_ICEOPERAND_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698