14
14
#define LLVM_CODEGEN_MACHINEFRAMEINFO_H
15
15
16
16
#include " llvm/ADT/SmallVector.h"
17
+ #include " llvm/Support/Alignment.h"
17
18
#include " llvm/Support/DataTypes.h"
18
19
#include < cassert>
19
20
#include < vector>
@@ -129,7 +130,7 @@ class MachineFrameInfo {
129
130
uint64_t Size;
130
131
131
132
// The required alignment of this stack slot.
132
- unsigned Alignment;
133
+ Align Alignment;
133
134
134
135
// If true, the value of the stack object is set before
135
136
// entering the function and is not modified inside the function. By
@@ -180,17 +181,16 @@ class MachineFrameInfo {
180
181
181
182
uint8_t SSPLayout;
182
183
183
- StackObject (uint64_t Size, unsigned Alignment, int64_t SPOffset,
184
+ StackObject (uint64_t Size, llvm::Align Alignment, int64_t SPOffset,
184
185
bool IsImmutable, bool IsSpillSlot, const AllocaInst *Alloca,
185
186
bool IsAliased, uint8_t StackID = 0 )
186
- : SPOffset(SPOffset), Size(Size), Alignment(Alignment),
187
- isImmutable (IsImmutable), isSpillSlot(IsSpillSlot),
188
- StackID(StackID), Alloca(Alloca), isAliased(IsAliased),
189
- SSPLayout(SSPLK_None) {}
187
+ : SPOffset(SPOffset), Size(Size), Alignment(Alignment),
188
+ isImmutable (IsImmutable), isSpillSlot(IsSpillSlot), StackID(StackID),
189
+ Alloca(Alloca), isAliased(IsAliased), SSPLayout(SSPLK_None) {}
190
190
};
191
191
192
192
// / The alignment of the stack.
193
- unsigned StackAlignment;
193
+ Align StackAlignment;
194
194
195
195
// / Can the stack be realigned. This can be false if the target does not
196
196
// / support stack realignment, or if the user asks us not to realign the
@@ -260,7 +260,7 @@ class MachineFrameInfo {
260
260
// / native alignment maintained by the compiler, dynamic alignment code will
261
261
// / be needed.
262
262
// /
263
- unsigned MaxAlignment = 0 ;
263
+ Align MaxAlignment;
264
264
265
265
// / Set to true if this function adjusts the stack -- e.g.,
266
266
// / when calling another function. This is only valid during and after
@@ -304,7 +304,7 @@ class MachineFrameInfo {
304
304
305
305
// / Required alignment of the local object blob, which is the strictest
306
306
// / alignment of any object in it.
307
- unsigned LocalFrameMaxAlign = 0 ;
307
+ Align LocalFrameMaxAlign;
308
308
309
309
// / Whether the local object blob needs to be allocated together. If not,
310
310
// / PEI should ignore the isPreAllocated flags on the stack objects and
@@ -338,8 +338,8 @@ class MachineFrameInfo {
338
338
public:
339
339
explicit MachineFrameInfo (unsigned StackAlignment, bool StackRealignable,
340
340
bool ForcedRealign)
341
- : StackAlignment(StackAlignment), StackRealignable(StackRealignable ),
342
- ForcedRealign(ForcedRealign) {}
341
+ : StackAlignment(assumeAligned( StackAlignment)),
342
+ StackRealignable(StackRealignable), ForcedRealign(ForcedRealign) {}
343
343
344
344
// / Return true if there are any stack objects in this function.
345
345
bool hasStackObjects () const { return !Objects.empty (); }
@@ -419,10 +419,10 @@ class MachineFrameInfo {
419
419
420
420
// / Required alignment of the local object blob,
421
421
// / which is the strictest alignment of any object in it.
422
- void setLocalFrameMaxAlign (unsigned Align) { LocalFrameMaxAlign = Align; }
422
+ void setLocalFrameMaxAlign (Align Align) { LocalFrameMaxAlign = Align; }
423
423
424
424
// / Return the required alignment of the local object blob.
425
- unsigned getLocalFrameMaxAlign () const { return LocalFrameMaxAlign; }
425
+ Align getLocalFrameMaxAlign () const { return LocalFrameMaxAlign; }
426
426
427
427
// / Get whether the local allocation blob should be allocated together or
428
428
// / let PEI allocate the locals in it directly.
@@ -462,14 +462,14 @@ class MachineFrameInfo {
462
462
unsigned getObjectAlignment (int ObjectIdx) const {
463
463
assert (unsigned (ObjectIdx+NumFixedObjects) < Objects.size () &&
464
464
" Invalid Object Idx!" );
465
- return Objects[ObjectIdx+ NumFixedObjects].Alignment ;
465
+ return Objects[ObjectIdx + NumFixedObjects].Alignment . value () ;
466
466
}
467
467
468
468
// / setObjectAlignment - Change the alignment of the specified stack object.
469
469
void setObjectAlignment (int ObjectIdx, unsigned Align) {
470
470
assert (unsigned (ObjectIdx+NumFixedObjects) < Objects.size () &&
471
471
" Invalid Object Idx!" );
472
- Objects[ObjectIdx+ NumFixedObjects].Alignment = Align;
472
+ Objects[ObjectIdx + NumFixedObjects].Alignment = assumeAligned ( Align) ;
473
473
474
474
// Only ensure max alignment for the default stack.
475
475
if (getStackID (ObjectIdx) == 0 )
@@ -561,10 +561,14 @@ class MachineFrameInfo {
561
561
562
562
// / Return the alignment in bytes that this function must be aligned to,
563
563
// / which is greater than the default stack alignment provided by the target.
564
- unsigned getMaxAlignment () const { return MaxAlignment; }
564
+ unsigned getMaxAlignment () const { return MaxAlignment. value () ; }
565
565
566
566
// / Make sure the function is at least Align bytes aligned.
567
- void ensureMaxAlignment (unsigned Align);
567
+ void ensureMaxAlignment (llvm::Align Align);
568
+ // / FIXME: Remove this once transition to Align is over.
569
+ inline void ensureMaxAlignment (unsigned Align) {
570
+ ensureMaxAlignment (assumeAligned (Align));
571
+ }
568
572
569
573
// / Return true if this function adjusts the stack -- e.g.,
570
574
// / when calling another function. This is only valid during and after
@@ -728,12 +732,24 @@ class MachineFrameInfo {
728
732
729
733
// / Create a new statically sized stack object, returning
730
734
// / a nonnegative identifier to represent it.
731
- int CreateStackObject (uint64_t Size, unsigned Alignment, bool isSpillSlot,
735
+ int CreateStackObject (uint64_t Size, llvm::Align Alignment, bool isSpillSlot,
732
736
const AllocaInst *Alloca = nullptr , uint8_t ID = 0 );
737
+ // / FIXME: Remove this function when transition to llvm::Align is over.
738
+ inline int CreateStackObject (uint64_t Size, unsigned Alignment,
739
+ bool isSpillSlot,
740
+ const AllocaInst *Alloca = nullptr ,
741
+ uint8_t ID = 0 ) {
742
+ return CreateStackObject (Size, assumeAligned (Alignment), isSpillSlot,
743
+ Alloca, ID);
744
+ }
733
745
734
746
// / Create a new statically sized stack object that represents a spill slot,
735
747
// / returning a nonnegative identifier to represent it.
736
- int CreateSpillStackObject (uint64_t Size, unsigned Alignment);
748
+ int CreateSpillStackObject (uint64_t Size, llvm::Align Alignment);
749
+ // / FIXME: Remove this function when transition to llvm::Align is over.
750
+ inline int CreateSpillStackObject (uint64_t Size, unsigned Alignment) {
751
+ return CreateSpillStackObject (Size, assumeAligned (Alignment));
752
+ }
737
753
738
754
// / Remove or mark dead a statically sized stack object.
739
755
void RemoveStackObject (int ObjectIdx) {
@@ -744,7 +760,12 @@ class MachineFrameInfo {
744
760
// / Notify the MachineFrameInfo object that a variable sized object has been
745
761
// / created. This must be created whenever a variable sized object is
746
762
// / created, whether or not the index returned is actually used.
747
- int CreateVariableSizedObject (unsigned Alignment, const AllocaInst *Alloca);
763
+ int CreateVariableSizedObject (llvm::Align Alignment,
764
+ const AllocaInst *Alloca);
765
+ // / FIXME: Remove this function when transition to llvm::Align is over.
766
+ int CreateVariableSizedObject (unsigned Alignment, const AllocaInst *Alloca) {
767
+ return CreateVariableSizedObject (assumeAligned (Alignment), Alloca);
768
+ }
748
769
749
770
// / Returns a reference to call saved info vector for the current function.
750
771
const std::vector<CalleeSavedInfo> &getCalleeSavedInfo () const {
0 commit comments