+ class LiveIntervals;
+ class MachineInstr;
+ class MachineRegisterInfo;
+ class TargetRegisterInfo;
+ class raw_ostream;
+
+ /// VNInfo - Value Number Information.
+ /// This class holds information about a machine level values, including
+ /// definition and use points.
+ ///
+ /// Care must be taken in interpreting the def index of the value. The
+ /// following rules apply:
+ ///
+ /// If the isDefAccurate() method returns false then def does not contain the
+ /// index of the defining MachineInstr, or even (necessarily) to a
+ /// MachineInstr at all. In general such a def index is not meaningful
+ /// and should not be used. The exception is that, for values originally
+ /// defined by PHI instructions, after PHI elimination def will contain the
+ /// index of the MBB in which the PHI originally existed. This can be used
+ /// to insert code (spills or copies) which deals with the value, which will
+ /// be live in to the block.
+ class VNInfo {
+ private:
+ enum {
+ HAS_PHI_KILL = 1,
+ REDEF_BY_EC = 1 << 1,
+ IS_PHI_DEF = 1 << 2,
+ IS_UNUSED = 1 << 3,
+ IS_DEF_ACCURATE = 1 << 4
+ };
+
+ unsigned char flags;
+ union {
+ MachineInstr *copy;
+ unsigned reg;
+ } cr;
+
+ public:
+ typedef BumpPtrAllocator Allocator;
+
+ /// The ID number of this value.
+ unsigned id;
+
+ /// The index of the defining instruction (if isDefAccurate() returns true).
+ SlotIndex def;
+
+ /// VNInfo constructor.
+ /// d is presumed to point to the actual defining instr. If it doesn't
+ /// setIsDefAccurate(false) should be called after construction.
+ VNInfo(unsigned i, SlotIndex d, MachineInstr *c)
+ : flags(IS_DEF_ACCURATE), id(i), def(d) { cr.copy = c; }
+
+ /// VNInfo construtor, copies values from orig, except for the value number.
+ VNInfo(unsigned i, const VNInfo &orig)
+ : flags(orig.flags), cr(orig.cr), id(i), def(orig.def)
+ { }
+
+ /// Copy from the parameter into this VNInfo.
+ void copyFrom(VNInfo &src) {
+ flags = src.flags;
+ cr = src.cr;
+ def = src.def;
+ }
+
+ /// Used for copying value number info.
+ unsigned getFlags() const { return flags; }
+ void setFlags(unsigned flags) { this->flags = flags; }
+
+ /// For a register interval, if this VN was definied by a copy instr
+ /// getCopy() returns a pointer to it, otherwise returns 0.
+ /// For a stack interval the behaviour of this method is undefined.
+ MachineInstr* getCopy() const { return cr.copy; }
+ /// For a register interval, set the copy member.
+ /// This method should not be called on stack intervals as it may lead to
+ /// undefined behavior.
+ void setCopy(MachineInstr *c) { cr.copy = c; }
+
+ /// For a stack interval, returns the reg which this stack interval was
+ /// defined from.
+ /// For a register interval the behaviour of this method is undefined.
+ unsigned getReg() const { return cr.reg; }
+ /// For a stack interval, set the defining register.
+ /// This method should not be called on register intervals as it may lead
+ /// to undefined behaviour.
+ void setReg(unsigned reg) { cr.reg = reg; }
+
+ /// Returns true if one or more kills are PHI nodes.
+ bool hasPHIKill() const { return flags & HAS_PHI_KILL; }
+ /// Set the PHI kill flag on this value.
+ void setHasPHIKill(bool hasKill) {
+ if (hasKill)
+ flags |= HAS_PHI_KILL;
+ else
+ flags &= ~HAS_PHI_KILL;
+ }
+
+ /// Returns true if this value is re-defined by an early clobber somewhere
+ /// during the live range.
+ bool hasRedefByEC() const { return flags & REDEF_BY_EC; }
+ /// Set the "redef by early clobber" flag on this value.
+ void setHasRedefByEC(bool hasRedef) {
+ if (hasRedef)
+ flags |= REDEF_BY_EC;
+ else
+ flags &= ~REDEF_BY_EC;
+ }
+
+ /// Returns true if this value is defined by a PHI instruction (or was,
+ /// PHI instrucions may have been eliminated).
+ bool isPHIDef() const { return flags & IS_PHI_DEF; }
+ /// Set the "phi def" flag on this value.
+ void setIsPHIDef(bool phiDef) {
+ if (phiDef)
+ flags |= IS_PHI_DEF;
+ else
+ flags &= ~IS_PHI_DEF;
+ }
+
+ /// Returns true if this value is unused.
+ bool isUnused() const { return flags & IS_UNUSED; }
+ /// Set the "is unused" flag on this value.
+ void setIsUnused(bool unused) {
+ if (unused)
+ flags |= IS_UNUSED;
+ else
+ flags &= ~IS_UNUSED;
+ }
+
+ /// Returns true if the def is accurate.
+ bool isDefAccurate() const { return flags & IS_DEF_ACCURATE; }
+ /// Set the "is def accurate" flag on this value.
+ void setIsDefAccurate(bool defAccurate) {
+ if (defAccurate)
+ flags |= IS_DEF_ACCURATE;
+ else
+ flags &= ~IS_DEF_ACCURATE;
+ }
+ };