Commit 0b624fef authored by Misha Brukman's avatar Misha Brukman
Browse files

* Order #includes as per style guide

* Doxygen-ify comments
* Make code layout more consistent

llvm-svn: 9431
parent 28ba80e6
Loading
Loading
Loading
Loading
+29 −29
Original line number Diff line number Diff line
@@ -18,58 +18,58 @@
#ifndef LIVERANGE_H
#define LIVERANGE_H

#include "llvm/CodeGen/ValueSet.h"
#include "llvm/Value.h"
#include "llvm/CodeGen/ValueSet.h"

class RegClass;
class IGNode;

class LiveRange : public ValueSet {
  RegClass *MyRegClass;       // register classs (e.g., int, FP) for this LR
  RegClass *MyRegClass;       // register class (e.g., int, FP) for this LR

  // doesSpanAcrossCalls - Does this live range span across calls? 
  // This information is used by graph
  // coloring algo to avoid allocating volatile colors to live ranges
  // that span across calls (since they have to be saved/restored)
  //
  /// doesSpanAcrossCalls - Does this live range span across calls? 
  /// This information is used by graph coloring algo to avoid allocating
  /// volatile colors to live ranges that span across calls (since they have to
  /// be saved/restored)
  ///
  bool doesSpanAcrossCalls;

  IGNode *UserIGNode;         // IGNode which uses this LR
  int Color;                  // color assigned to this live range
  bool mustSpill;             // whether this LR must be spilt

  // mustSaveAcrossCalls - whether this LR must be saved accross calls
  // ***TODO REMOVE this
  //
  /// mustSaveAcrossCalls - whether this LR must be saved accross calls
  /// ***TODO REMOVE this
  ///
  bool mustSaveAcrossCalls;        
  
  // SuggestedColor - if this LR has a suggested color, can it be
  // really alloated?  A suggested color cannot be allocated when the
  // suggested color is volatile and when there are call
  // interferences.
  //
  /// SuggestedColor - if this LR has a suggested color, can it be
  /// really alloated?  A suggested color cannot be allocated when the
  /// suggested color is volatile and when there are call
  /// interferences.
  ///
  int SuggestedColor;        // The suggested color for this LR

  // CanUseSuggestedCol - It is possible that a suggested color for
  // this live range is not available before graph coloring (e.g., it
  // can be allocated to another live range which interferes with
  // this)
  // 
  /// CanUseSuggestedCol - It is possible that a suggested color for
  /// this live range is not available before graph coloring (e.g., it
  /// can be allocated to another live range which interferes with
  /// this)
  /// 
  bool CanUseSuggestedCol;

  // SpilledStackOffsetFromFP - If this LR is spilled, its stack
  // offset from *FP*. The spilled offsets must always be relative to
  // the FP.
  //
  /// SpilledStackOffsetFromFP - If this LR is spilled, its stack
  /// offset from *FP*. The spilled offsets must always be relative to
  /// the FP.
  ///
  int SpilledStackOffsetFromFP;

  // HasSpillOffset 0 Whether this live range has a spill offset
  //
  /// HasSpillOffset 0 Whether this live range has a spill offset
  ///
  bool HasSpillOffset;

  // The spill cost of this live range. Calculated using loop depth of
  // each reference to each Value in the live range
  //
  /// The spill cost of this live range. Calculated using loop depth of
  /// each reference to each Value in the live range
  ///
  unsigned SpillCost;

public:
+4 −7
Original line number Diff line number Diff line
@@ -11,16 +11,16 @@
// 
//===----------------------------------------------------------------------===//

#include "IGNode.h"
#include "LiveRangeInfo.h"
#include "RegAllocCommon.h"
#include "RegClass.h"
#include "IGNode.h"
#include "llvm/Function.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetRegInfo.h"
#include "llvm/Function.h"
#include "Support/SetOperations.h"

unsigned LiveRange::getRegClassID() const { return getRegClass()->getID(); }
@@ -217,7 +217,6 @@ void LiveRangeInfo::constructLiveRanges() {
	}

    } // for all machine instructions in the BB

  } // for all BBs in function

  // Now we have to suggest clors for call and return arg live ranges.
@@ -278,8 +277,7 @@ void LiveRangeInfo::suggestRegs4CallRets() {
// Checks if live range LR interferes with any node assigned or suggested to
// be assigned the specified color
// 
inline bool InterferesWithColor(const LiveRange& LR, unsigned color)
{
inline bool InterferesWithColor(const LiveRange& LR, unsigned color) {
  IGNode* lrNode = LR.getUserIGNode();
  for (unsigned n=0, NN = lrNode->getNumOfNeighbors(); n < NN; n++) {
    LiveRange *neighLR = lrNode->getAdjIGNode(n)->getParentLR();
@@ -299,8 +297,7 @@ inline bool InterferesWithColor(const LiveRange& LR, unsigned color)
// (4) LR2 has color and LR1 interferes with any LR that has the same color
// 
inline bool InterfsPreventCoalescing(const LiveRange& LROfDef,
                                     const LiveRange& LROfUse)
{
                                     const LiveRange& LROfUse) {
  // (4) if they have different suggested colors, cannot coalesce
  if (LROfDef.hasSuggestedColor() && LROfUse.hasSuggestedColor())
    return true;
+12 −10
Original line number Diff line number Diff line
@@ -87,20 +87,22 @@ public:
		std::vector<RegClass *> & RCList);


  // Destructor to destroy all LiveRanges in the LiveRange Map
  /// Destructor to destroy all LiveRanges in the LiveRange Map
  ///
  ~LiveRangeInfo();

  // Main entry point for live range construction
  //
  void constructLiveRanges();
  
  // return the common live range map for this method
  //
  /// return the common live range map for this method
  ///
  inline const LiveRangeMapType *getLiveRangeMap() const 
    { return &LiveRangeMap; }

  // Method used to get the live range containing a Value.
  // This may return NULL if no live range exists for a Value (eg, some consts)
  /// Method used to get the live range containing a Value.
  /// This may return NULL if no live range exists for a Value (eg, some consts)
  ///
  inline LiveRange *getLiveRangeForValue(const Value *Val) {
    return LiveRangeMap[Val];
  }
@@ -109,13 +111,13 @@ public:
    return I->second;
  }

  // Method for coalescing live ranges. Called only after interference info
  // is calculated.
  //
  /// Method for coalescing live ranges. Called only after interference info
  /// is calculated.
  ///
  void coalesceLRs();  

  // debugging method to print the live ranges
  //
  /// debugging method to print the live ranges
  ///
  void printLiveRanges();
};