17
17
18
18
#include " llvm/ADT/DenseSet.h"
19
19
#include " llvm/MC/SectionKind.h"
20
+ #include " llvm/Support/Alignment.h"
20
21
#include < climits>
21
22
#include < vector>
22
23
@@ -45,7 +46,7 @@ class MachineConstantPoolValue {
45
46
Type *getType () const { return Ty; }
46
47
47
48
virtual int getExistingMachineCPValue (MachineConstantPool *CP,
48
- unsigned Alignment) = 0;
49
+ Align Alignment) = 0;
49
50
50
51
virtual void addSelectionDAGCSEId (FoldingSetNodeID &ID) = 0;
51
52
@@ -71,31 +72,27 @@ class MachineConstantPoolEntry {
71
72
MachineConstantPoolValue *MachineCPVal;
72
73
} Val;
73
74
74
- // / The required alignment for this entry. The top bit is set when Val is
75
- // / a target specific MachineConstantPoolValue.
76
- unsigned Alignment;
75
+ // / The required alignment for this entry.
76
+ Align Alignment;
77
77
78
- MachineConstantPoolEntry (const Constant *V, unsigned A)
79
- : Alignment(A) {
78
+ bool IsMachineConstantPoolEntry;
79
+
80
+ MachineConstantPoolEntry (const Constant *V, Align A)
81
+ : Alignment(A), IsMachineConstantPoolEntry(false ) {
80
82
Val.ConstVal = V;
81
83
}
82
84
83
- MachineConstantPoolEntry (MachineConstantPoolValue *V, unsigned A)
84
- : Alignment(A) {
85
+ MachineConstantPoolEntry (MachineConstantPoolValue *V, Align A)
86
+ : Alignment(A), IsMachineConstantPoolEntry( true ) {
85
87
Val.MachineCPVal = V;
86
- Alignment |= 1U << (sizeof (unsigned ) * CHAR_BIT - 1 );
87
88
}
88
89
89
90
// / isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry
90
91
// / is indeed a target specific constantpool entry, not a wrapper over a
91
92
// / Constant.
92
- bool isMachineConstantPoolEntry () const {
93
- return (int )Alignment < 0 ;
94
- }
93
+ bool isMachineConstantPoolEntry () const { return IsMachineConstantPoolEntry; }
95
94
96
- int getAlignment () const {
97
- return Alignment & ~(1 << (sizeof (unsigned ) * CHAR_BIT - 1 ));
98
- }
95
+ Align getAlign () const { return Alignment; }
99
96
100
97
Type *getType () const ;
101
98
@@ -118,7 +115,7 @@ class MachineConstantPoolEntry {
118
115
// / address of the function constant pool values.
119
116
// / The machine constant pool.
120
117
class MachineConstantPool {
121
- unsigned PoolAlignment; // /< The alignment for the pool.
118
+ Align PoolAlignment; // /< The alignment for the pool.
122
119
std::vector<MachineConstantPoolEntry> Constants; // /< The pool of constants.
123
120
// / MachineConstantPoolValues that use an existing MachineConstantPoolEntry.
124
121
DenseSet<MachineConstantPoolValue*> MachineCPVsSharingEntries;
@@ -132,16 +129,15 @@ class MachineConstantPool {
132
129
: PoolAlignment(1 ), DL(DL) {}
133
130
~MachineConstantPool ();
134
131
135
- // / getConstantPoolAlignment - Return the alignment required by
136
- // / the whole constant pool, of which the first element must be aligned.
137
- unsigned getConstantPoolAlignment () const { return PoolAlignment; }
132
+ // / Return the alignment required by the whole constant pool, of which the
133
+ // / first element must be aligned.
134
+ Align getConstantPoolAlign () const { return PoolAlignment; }
138
135
139
136
// / getConstantPoolIndex - Create a new entry in the constant pool or return
140
137
// / an existing one. User must specify the minimum required alignment for
141
138
// / the object.
142
- unsigned getConstantPoolIndex (const Constant *C, unsigned Alignment);
143
- unsigned getConstantPoolIndex (MachineConstantPoolValue *V,
144
- unsigned Alignment);
139
+ unsigned getConstantPoolIndex (const Constant *C, Align Alignment);
140
+ unsigned getConstantPoolIndex (MachineConstantPoolValue *V, Align Alignment);
145
141
146
142
// / isEmpty - Return true if this constant pool contains no constants.
147
143
bool isEmpty () const { return Constants.empty (); }
0 commit comments