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

Side by Side Diff: src/IceOperand.h

Issue 1844713004: Subzero: Ignore variables with no actual uses. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Also ignore rematerializable variables Created 4 years, 8 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 | « src/IceLiveness.cpp ('k') | src/IceOperand.cpp » ('j') | 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/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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 return; 654 return;
655 Name = VariableString::createWithString(Func, NewName); 655 Name = VariableString::createWithString(Func, NewName);
656 } 656 }
657 657
658 bool getIsArg() const { return IsArgument; } 658 bool getIsArg() const { return IsArgument; }
659 virtual void setIsArg(bool Val = true) { IsArgument = Val; } 659 virtual void setIsArg(bool Val = true) { IsArgument = Val; }
660 bool getIsImplicitArg() const { return IsImplicitArgument; } 660 bool getIsImplicitArg() const { return IsImplicitArgument; }
661 void setIsImplicitArg(bool Val = true) { IsImplicitArgument = Val; } 661 void setIsImplicitArg(bool Val = true) { IsImplicitArgument = Val; }
662 662
663 void setIgnoreLiveness() { IgnoreLiveness = true; } 663 void setIgnoreLiveness() { IgnoreLiveness = true; }
664 bool getIgnoreLiveness() const { return IgnoreLiveness; } 664 bool getIgnoreLiveness() const {
665 return IgnoreLiveness || IsRematerializable;
666 }
665 667
666 int32_t getStackOffset() const { return StackOffset; } 668 int32_t getStackOffset() const { return StackOffset; }
667 void setStackOffset(int32_t Offset) { StackOffset = Offset; } 669 void setStackOffset(int32_t Offset) { StackOffset = Offset; }
668 /// Returns the variable's stack offset in symbolic form, to improve 670 /// Returns the variable's stack offset in symbolic form, to improve
669 /// readability in DecorateAsm mode. 671 /// readability in DecorateAsm mode.
670 std::string getSymbolicStackOffset(const Cfg *Func) const { 672 std::string getSymbolicStackOffset(const Cfg *Func) const {
671 if (!BuildDefs::dump()) 673 if (!BuildDefs::dump())
672 return ""; 674 return "";
673 return "lv$" + getName(Func); 675 return "lv$" + getName(Func);
674 } 676 }
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 enum MetadataKind { 858 enum MetadataKind {
857 VMK_Uses, /// Track only uses, not defs 859 VMK_Uses, /// Track only uses, not defs
858 VMK_SingleDefs, /// Track uses+defs, but only record single def 860 VMK_SingleDefs, /// Track uses+defs, but only record single def
859 VMK_All /// Track uses+defs, including full def list 861 VMK_All /// Track uses+defs, including full def list
860 }; 862 };
861 using InstDefList = CfgVector<const Inst *>; 863 using InstDefList = CfgVector<const Inst *>;
862 864
863 /// VariableTracking tracks the metadata for a single variable. It is 865 /// VariableTracking tracks the metadata for a single variable. It is
864 /// only meant to be used internally by VariablesMetadata. 866 /// only meant to be used internally by VariablesMetadata.
865 class VariableTracking { 867 class VariableTracking {
866 VariableTracking &operator=(const VariableTracking &) = delete;
867
868 public: 868 public:
869 enum MultiDefState { 869 enum MultiDefState {
870 // TODO(stichnot): Consider using just a simple counter. 870 // TODO(stichnot): Consider using just a simple counter.
871 MDS_Unknown, 871 MDS_Unknown,
872 MDS_SingleDef, 872 MDS_SingleDef,
873 MDS_MultiDefSingleBlock, 873 MDS_MultiDefSingleBlock,
874 MDS_MultiDefMultiBlock 874 MDS_MultiDefMultiBlock
875 }; 875 };
876 enum MultiBlockState { MBS_Unknown, MBS_SingleBlock, MBS_MultiBlock }; 876 enum MultiBlockState {
877 MBS_Unknown, // Not yet initialized, so be conservative
878 MBS_NoUses, // Known to have no uses
879 MBS_SingleBlock, // All uses in are in a single block
880 MBS_MultiBlock // Several uses across several blocks
881 };
877 VariableTracking() = default; 882 VariableTracking() = default;
878 VariableTracking(const VariableTracking &) = default; 883 VariableTracking(const VariableTracking &) = default;
884 VariableTracking &operator=(const VariableTracking &) = default;
885 VariableTracking(MultiBlockState MultiBlock) : MultiBlock(MultiBlock) {}
879 MultiDefState getMultiDef() const { return MultiDef; } 886 MultiDefState getMultiDef() const { return MultiDef; }
880 MultiBlockState getMultiBlock() const { return MultiBlock; } 887 MultiBlockState getMultiBlock() const { return MultiBlock; }
881 const Inst *getFirstDefinitionSingleBlock() const; 888 const Inst *getFirstDefinitionSingleBlock() const;
882 const Inst *getSingleDefinition() const; 889 const Inst *getSingleDefinition() const;
883 const Inst *getFirstDefinition() const; 890 const Inst *getFirstDefinition() const;
884 const InstDefList &getLatterDefinitions() const { return Definitions; } 891 const InstDefList &getLatterDefinitions() const { return Definitions; }
885 CfgNode *getNode() const { return SingleUseNode; } 892 CfgNode *getNode() const { return SingleUseNode; }
886 RegWeight getUseWeight() const { return UseWeight; } 893 RegWeight getUseWeight() const { return UseWeight; }
887 void markUse(MetadataKind TrackingKind, const Inst *Instr, CfgNode *Node, 894 void markUse(MetadataKind TrackingKind, const Inst *Instr, CfgNode *Node,
888 bool IsImplicit); 895 bool IsImplicit);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 const Inst *getFirstDefinition(const Variable *Var) const; 948 const Inst *getFirstDefinition(const Variable *Var) const;
942 const InstDefList &getLatterDefinitions(const Variable *Var) const; 949 const InstDefList &getLatterDefinitions(const Variable *Var) const;
943 950
944 /// Returns whether the given Variable is live across multiple blocks. Mainly, 951 /// Returns whether the given Variable is live across multiple blocks. Mainly,
945 /// this is used to partition Variables into single-block versus multi-block 952 /// this is used to partition Variables into single-block versus multi-block
946 /// sets for leveraging sparsity in liveness analysis, and for implementing 953 /// sets for leveraging sparsity in liveness analysis, and for implementing
947 /// simple stack slot coalescing. As a special case, function arguments are 954 /// simple stack slot coalescing. As a special case, function arguments are
948 /// always considered multi-block because they are live coming into the entry 955 /// always considered multi-block because they are live coming into the entry
949 /// block. 956 /// block.
950 bool isMultiBlock(const Variable *Var) const; 957 bool isMultiBlock(const Variable *Var) const;
958 bool isSingleBlock(const Variable *Var) const;
951 /// Returns the node that the given Variable is used in, assuming 959 /// Returns the node that the given Variable is used in, assuming
952 /// isMultiBlock() returns false. Otherwise, nullptr is returned. 960 /// isMultiBlock() returns false. Otherwise, nullptr is returned.
953 CfgNode *getLocalUseNode(const Variable *Var) const; 961 CfgNode *getLocalUseNode(const Variable *Var) const;
954 962
955 /// Returns the total use weight computed as the sum of uses multiplied by a 963 /// Returns the total use weight computed as the sum of uses multiplied by a
956 /// loop nest depth factor for each use. 964 /// loop nest depth factor for each use.
957 RegWeight getUseWeight(const Variable *Var) const; 965 RegWeight getUseWeight(const Variable *Var) const;
958 966
959 private: 967 private:
960 const Cfg *Func; 968 const Cfg *Func;
961 MetadataKind Kind; 969 MetadataKind Kind;
962 CfgVector<VariableTracking> Metadata; 970 CfgVector<VariableTracking> Metadata;
963 const static InstDefList NoDefinitions; 971 const static InstDefList NoDefinitions;
964 }; 972 };
965 973
966 } // end of namespace Ice 974 } // end of namespace Ice
967 975
968 #endif // SUBZERO_SRC_ICEOPERAND_H 976 #endif // SUBZERO_SRC_ICEOPERAND_H
OLDNEW
« no previous file with comments | « src/IceLiveness.cpp ('k') | src/IceOperand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698