-struct MachineConstantPoolEntry {
- Constant *Val; ///< The constant itself.
- unsigned Offset; ///< The offset of the constant from the start of the pool.
- MachineConstantPoolEntry(Constant *V, unsigned O) : Val(V), Offset(O) {}
+class MachineConstantPoolEntry {
+public:
+ /// The constant itself.
+ union {
+ const Constant *ConstVal;
+ MachineConstantPoolValue *MachineCPVal;
+ } Val;
+
+ /// The required alignment for this entry. The top bit is set when Val is
+ /// a target specific MachineConstantPoolValue.
+ unsigned Alignment;
+
+ MachineConstantPoolEntry(const Constant *V, unsigned A)
+ : Alignment(A) {
+ Val.ConstVal = V;
+ }
+ MachineConstantPoolEntry(MachineConstantPoolValue *V, unsigned A)
+ : Alignment(A) {
+ Val.MachineCPVal = V;
+ Alignment |= 1U << (sizeof(unsigned)*CHAR_BIT-1);
+ }
+
+ /// isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry
+ /// is indeed a target specific constantpool entry, not a wrapper over a
+ /// Constant.
+ bool isMachineConstantPoolEntry() const {
+ return (int)Alignment < 0;
+ }
+
+ int getAlignment() const {
+ return Alignment & ~(1 << (sizeof(unsigned)*CHAR_BIT-1));
+ }
+
+ Type *getType() const;
+
+ /// getRelocationInfo - This method classifies the entry according to
+ /// whether or not it may generate a relocation entry. This must be
+ /// conservative, so if it might codegen to a relocatable entry, it should say
+ /// so. The return values are:
+ ///
+ /// 0: This constant pool entry is guaranteed to never have a relocation
+ /// applied to it (because it holds a simple constant like '4').
+ /// 1: This entry has relocations, but the entries are guaranteed to be
+ /// resolvable by the static linker, so the dynamic linker will never see
+ /// them.
+ /// 2: This entry may have arbitrary relocations.
+ unsigned getRelocationInfo() const;