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

Side by Side Diff: src/IceOperand.h

Issue 1381563004: Subzero: Fix a bug in register allocator overlap computation. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix the asserts() guard Created 5 years, 2 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/IceCompileServer.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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 MDS_Unknown, 622 MDS_Unknown,
623 MDS_SingleDef, 623 MDS_SingleDef,
624 MDS_MultiDefSingleBlock, 624 MDS_MultiDefSingleBlock,
625 MDS_MultiDefMultiBlock 625 MDS_MultiDefMultiBlock
626 }; 626 };
627 enum MultiBlockState { MBS_Unknown, MBS_SingleBlock, MBS_MultiBlock }; 627 enum MultiBlockState { MBS_Unknown, MBS_SingleBlock, MBS_MultiBlock };
628 VariableTracking() = default; 628 VariableTracking() = default;
629 VariableTracking(const VariableTracking &) = default; 629 VariableTracking(const VariableTracking &) = default;
630 MultiDefState getMultiDef() const { return MultiDef; } 630 MultiDefState getMultiDef() const { return MultiDef; }
631 MultiBlockState getMultiBlock() const { return MultiBlock; } 631 MultiBlockState getMultiBlock() const { return MultiBlock; }
632 const Inst *getFirstDefinitionSingleBlock() const;
633 const Inst *getSingleDefinition() const;
632 const Inst *getFirstDefinition() const; 634 const Inst *getFirstDefinition() const;
633 const Inst *getSingleDefinition() const;
634 const InstDefList &getLatterDefinitions() const { return Definitions; } 635 const InstDefList &getLatterDefinitions() const { return Definitions; }
635 CfgNode *getNode() const { return SingleUseNode; } 636 CfgNode *getNode() const { return SingleUseNode; }
636 RegWeight getUseWeight() const { return UseWeight; } 637 RegWeight getUseWeight() const { return UseWeight; }
637 void markUse(MetadataKind TrackingKind, const Inst *Instr, CfgNode *Node, 638 void markUse(MetadataKind TrackingKind, const Inst *Instr, CfgNode *Node,
638 bool IsImplicit); 639 bool IsImplicit);
639 void markDef(MetadataKind TrackingKind, const Inst *Instr, CfgNode *Node); 640 void markDef(MetadataKind TrackingKind, const Inst *Instr, CfgNode *Node);
640 641
641 private: 642 private:
642 MultiDefState MultiDef = MDS_Unknown; 643 MultiDefState MultiDef = MDS_Unknown;
643 MultiBlockState MultiBlock = MBS_Unknown; 644 MultiBlockState MultiBlock = MBS_Unknown;
644 CfgNode *SingleUseNode = nullptr; 645 CfgNode *SingleUseNode = nullptr;
645 CfgNode *SingleDefNode = nullptr; 646 CfgNode *SingleDefNode = nullptr;
646 /// All definitions of the variable are collected here, in increasing 647 /// All definitions of the variable are collected in Definitions[] (except for
647 /// order of instruction number. 648 /// the earliest definition), in increasing order of instruction number.
648 InstDefList Definitions; /// Only used if Kind==VMK_All 649 InstDefList Definitions; /// Only used if Kind==VMK_All
649 const Inst *FirstOrSingleDefinition = 650 const Inst *FirstOrSingleDefinition = nullptr;
650 nullptr; /// Is a copy of Definitions[0] if Kind==VMK_All
651 RegWeight UseWeight; 651 RegWeight UseWeight;
652 }; 652 };
653 653
654 /// VariablesMetadata analyzes and summarizes the metadata for the complete set 654 /// VariablesMetadata analyzes and summarizes the metadata for the complete set
655 /// of Variables. 655 /// of Variables.
656 class VariablesMetadata { 656 class VariablesMetadata {
657 VariablesMetadata() = delete; 657 VariablesMetadata() = delete;
658 VariablesMetadata(const VariablesMetadata &) = delete; 658 VariablesMetadata(const VariablesMetadata &) = delete;
659 VariablesMetadata &operator=(const VariablesMetadata &) = delete; 659 VariablesMetadata &operator=(const VariablesMetadata &) = delete;
660 660
661 public: 661 public:
662 explicit VariablesMetadata(const Cfg *Func) : Func(Func) {} 662 explicit VariablesMetadata(const Cfg *Func) : Func(Func) {}
663 /// Initialize the state by traversing all instructions/variables in the CFG. 663 /// Initialize the state by traversing all instructions/variables in the CFG.
664 void init(MetadataKind TrackingKind); 664 void init(MetadataKind TrackingKind);
665 /// Add a single node. This is called by init(), and can be called 665 /// Add a single node. This is called by init(), and can be called
666 /// incrementally from elsewhere, e.g. after edge-splitting. 666 /// incrementally from elsewhere, e.g. after edge-splitting.
667 void addNode(CfgNode *Node); 667 void addNode(CfgNode *Node);
668 MetadataKind getKind() const { return Kind; }
668 /// Returns whether the given Variable is tracked in this object. It should 669 /// Returns whether the given Variable is tracked in this object. It should
669 /// only return false if changes were made to the CFG after running init(), in 670 /// only return false if changes were made to the CFG after running init(), in
670 /// which case the state is stale and the results shouldn't be trusted (but it 671 /// which case the state is stale and the results shouldn't be trusted (but it
671 /// may be OK e.g. for dumping). 672 /// may be OK e.g. for dumping).
672 bool isTracked(const Variable *Var) const { 673 bool isTracked(const Variable *Var) const {
673 return Var->getIndex() < Metadata.size(); 674 return Var->getIndex() < Metadata.size();
674 } 675 }
675 676
676 /// Returns whether the given Variable has multiple definitions. 677 /// Returns whether the given Variable has multiple definitions.
677 bool isMultiDef(const Variable *Var) const; 678 bool isMultiDef(const Variable *Var) const;
678 /// Returns the first definition instruction of the given Variable. This is 679 /// Returns the first definition instruction of the given Variable. This is
679 /// only valid for variables whose definitions are all within the same block, 680 /// only valid for variables whose definitions are all within the same block,
680 /// e.g. T after the lowered sequence "T=B; T+=C; A=T", for which 681 /// e.g. T after the lowered sequence "T=B; T+=C; A=T", for which
681 /// getFirstDefinition(T) would return the "T=B" instruction. For variables 682 /// getFirstDefinitionSingleBlock(T) would return the "T=B" instruction. For
682 /// with definitions span multiple blocks, nullptr is returned. 683 /// variables with definitions span multiple blocks, nullptr is returned.
683 const Inst *getFirstDefinition(const Variable *Var) const; 684 const Inst *getFirstDefinitionSingleBlock(const Variable *Var) const;
684 /// Returns the definition instruction of the given Variable, when the 685 /// Returns the definition instruction of the given Variable, when the
685 /// variable has exactly one definition. Otherwise, nullptr is returned. 686 /// variable has exactly one definition. Otherwise, nullptr is returned.
686 const Inst *getSingleDefinition(const Variable *Var) const; 687 const Inst *getSingleDefinition(const Variable *Var) const;
687 /// Returns the list of all definition instructions of the given Variable. 688 /// getFirstDefinition() and getLatterDefinitions() are used together to
689 /// return the complete set of instructions that define the given Variable,
690 /// regardless of whether the definitions are within the same block (in
691 /// contrast to getFirstDefinitionSingleBlock).
692 const Inst *getFirstDefinition(const Variable *Var) const;
688 const InstDefList &getLatterDefinitions(const Variable *Var) const; 693 const InstDefList &getLatterDefinitions(const Variable *Var) const;
689 694
690 /// Returns whether the given Variable is live across multiple blocks. Mainly, 695 /// Returns whether the given Variable is live across multiple blocks. Mainly,
691 /// this is used to partition Variables into single-block versus multi-block 696 /// this is used to partition Variables into single-block versus multi-block
692 /// sets for leveraging sparsity in liveness analysis, and for implementing 697 /// sets for leveraging sparsity in liveness analysis, and for implementing
693 /// simple stack slot coalescing. As a special case, function arguments are 698 /// simple stack slot coalescing. As a special case, function arguments are
694 /// always considered multi-block because they are live coming into the entry 699 /// always considered multi-block because they are live coming into the entry
695 /// block. 700 /// block.
696 bool isMultiBlock(const Variable *Var) const; 701 bool isMultiBlock(const Variable *Var) const;
697 /// Returns the node that the given Variable is used in, assuming 702 /// Returns the node that the given Variable is used in, assuming
698 /// isMultiBlock() returns false. Otherwise, nullptr is returned. 703 /// isMultiBlock() returns false. Otherwise, nullptr is returned.
699 CfgNode *getLocalUseNode(const Variable *Var) const; 704 CfgNode *getLocalUseNode(const Variable *Var) const;
700 705
701 /// Returns the total use weight computed as the sum of uses multiplied by a 706 /// Returns the total use weight computed as the sum of uses multiplied by a
702 /// loop nest depth factor for each use. 707 /// loop nest depth factor for each use.
703 RegWeight getUseWeight(const Variable *Var) const; 708 RegWeight getUseWeight(const Variable *Var) const;
704 709
705 private: 710 private:
706 const Cfg *Func; 711 const Cfg *Func;
707 MetadataKind Kind; 712 MetadataKind Kind;
708 CfgVector<VariableTracking> Metadata; 713 CfgVector<VariableTracking> Metadata;
709 const static InstDefList NoDefinitions; 714 const static InstDefList NoDefinitions;
710 }; 715 };
711 716
712 } // end of namespace Ice 717 } // end of namespace Ice
713 718
714 #endif // SUBZERO_SRC_ICEOPERAND_H 719 #endif // SUBZERO_SRC_ICEOPERAND_H
OLDNEW
« no previous file with comments | « src/IceCompileServer.cpp ('k') | src/IceOperand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698