#define LLVM_CODEGEN_LIVEINTERVAL_H
#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Streams.h"
#include <iosfwd>
#include <vector>
#include <cassert>
namespace llvm {
+ class MachineInstr;
class MRegisterInfo;
/// LiveRange structure - This represents a simple register range in the
}
void dump() const;
+ void print(std::ostream &os) const;
+ void print(std::ostream *os) const { if (os) print(*os); }
private:
LiveRange(); // DO NOT IMPLEMENT
};
+
std::ostream& operator<<(std::ostream& os, const LiveRange &LR);
+
inline bool operator<(unsigned V, const LiveRange &LR) {
return V < LR.start;
}
struct LiveInterval {
typedef SmallVector<LiveRange,4> Ranges;
unsigned reg; // the register of this interval
+ unsigned preference; // preferred register to allocate for this interval
float weight; // weight of this interval
+ MachineInstr* remat; // definition if the definition rematerializable
Ranges ranges; // the ranges in which this register is live
private:
/// ValueNumberInfo - If this value number is not defined by a copy, this
public:
LiveInterval(unsigned Reg, float Weight)
- : reg(Reg), weight(Weight) {
+ : reg(Reg), preference(0), weight(Weight), remat(NULL) {
}
typedef Ranges::iterator iterator;
void swap(LiveInterval& other) {
std::swap(reg, other.reg);
std::swap(weight, other.weight);
+ std::swap(remat, other.remat);
std::swap(ranges, other.ranges);
std::swap(ValueNumberInfo, other.ValueNumberInfo);
}
/// the range must already be in this interval in its entirety.
void removeRange(unsigned Start, unsigned End);
+ void removeRange(LiveRange LR) {
+ removeRange(LR.start, LR.end);
+ }
+
+ /// getSize - Returns the sum of sizes of all the LiveRange's.
+ ///
+ unsigned getSize() const;
+
bool operator<(const LiveInterval& other) const {
return beginNumber() < other.beginNumber();
}
void print(std::ostream &OS, const MRegisterInfo *MRI = 0) const;
+ void print(std::ostream *OS, const MRegisterInfo *MRI = 0) const {
+ if (OS) print(*OS, MRI);
+ }
void dump() const;
private: