mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Replace calls to get the subtarget and TargetFrameLowering with
cached variables and a single call in the constructor. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219287 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
13ffdf88dc
commit
5dd4454174
@ -121,7 +121,11 @@ class MachineFrameInfo {
|
||||
isSpillSlot(isSS), Alloca(Val), PreAllocated(false), isAliased(A) {}
|
||||
};
|
||||
|
||||
const TargetMachine &TM;
|
||||
/// StackAlignment - The alignment of the stack.
|
||||
unsigned StackAlignment;
|
||||
|
||||
/// StackRealignable - Can the stack be realigned.
|
||||
bool StackRealignable;
|
||||
|
||||
/// Objects - The list of stack objects allocated...
|
||||
///
|
||||
@ -242,10 +246,11 @@ class MachineFrameInfo {
|
||||
/// True if this is a varargs function that contains a musttail call.
|
||||
bool HasMustTailInVarArgFunc;
|
||||
|
||||
const TargetFrameLowering *getFrameLowering() const;
|
||||
public:
|
||||
explicit MachineFrameInfo(const TargetMachine &TM, bool RealignOpt)
|
||||
: TM(TM), RealignOption(RealignOpt) {
|
||||
explicit MachineFrameInfo(unsigned StackAlign, bool isStackRealign,
|
||||
bool RealignOpt)
|
||||
: StackAlignment(StackAlign), StackRealignable(isStackRealign),
|
||||
RealignOption(RealignOpt) {
|
||||
StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0;
|
||||
HasVarSizedObjects = false;
|
||||
FrameAddressTaken = false;
|
||||
|
@ -63,8 +63,10 @@ MachineFunction::MachineFunction(const Function *F, const TargetMachine &TM,
|
||||
RegInfo = nullptr;
|
||||
|
||||
MFInfo = nullptr;
|
||||
FrameInfo =
|
||||
new (Allocator) MachineFrameInfo(TM,!F->hasFnAttribute("no-realign-stack"));
|
||||
FrameInfo = new (Allocator)
|
||||
MachineFrameInfo(STI->getFrameLowering()->getStackAlignment(),
|
||||
STI->getFrameLowering()->isStackRealignable(),
|
||||
!F->hasFnAttribute("no-realign-stack"));
|
||||
|
||||
if (Fn->getAttributes().hasAttribute(AttributeSet::FunctionIndex,
|
||||
Attribute::StackAlignment))
|
||||
@ -485,15 +487,11 @@ MCSymbol *MachineFunction::getPICBaseSymbol() const {
|
||||
// MachineFrameInfo implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
const TargetFrameLowering *MachineFrameInfo::getFrameLowering() const {
|
||||
return TM.getSubtargetImpl()->getFrameLowering();
|
||||
}
|
||||
|
||||
/// ensureMaxAlignment - Make sure the function is at least Align bytes
|
||||
/// aligned.
|
||||
void MachineFrameInfo::ensureMaxAlignment(unsigned Align) {
|
||||
if (!getFrameLowering()->isStackRealignable() || !RealignOption)
|
||||
assert(Align <= getFrameLowering()->getStackAlignment() &&
|
||||
if (!StackRealignable || !RealignOption)
|
||||
assert(Align <= StackAlignment &&
|
||||
"For targets without stack realignment, Align is out of limit!");
|
||||
if (MaxAlignment < Align) MaxAlignment = Align;
|
||||
}
|
||||
@ -515,10 +513,8 @@ static inline unsigned clampStackAlignment(bool ShouldClamp, unsigned Align,
|
||||
int MachineFrameInfo::CreateStackObject(uint64_t Size, unsigned Alignment,
|
||||
bool isSS, const AllocaInst *Alloca) {
|
||||
assert(Size != 0 && "Cannot allocate zero size stack objects!");
|
||||
Alignment =
|
||||
clampStackAlignment(!getFrameLowering()->isStackRealignable() ||
|
||||
!RealignOption,
|
||||
Alignment, getFrameLowering()->getStackAlignment());
|
||||
Alignment = clampStackAlignment(!StackRealignable || !RealignOption,
|
||||
Alignment, StackAlignment);
|
||||
Objects.push_back(StackObject(Size, Alignment, 0, false, isSS, Alloca,
|
||||
!isSS));
|
||||
int Index = (int)Objects.size() - NumFixedObjects - 1;
|
||||
@ -533,9 +529,8 @@ int MachineFrameInfo::CreateStackObject(uint64_t Size, unsigned Alignment,
|
||||
///
|
||||
int MachineFrameInfo::CreateSpillStackObject(uint64_t Size,
|
||||
unsigned Alignment) {
|
||||
Alignment = clampStackAlignment(
|
||||
!getFrameLowering()->isStackRealignable() || !RealignOption, Alignment,
|
||||
getFrameLowering()->getStackAlignment());
|
||||
Alignment = clampStackAlignment(!StackRealignable || !RealignOption,
|
||||
Alignment, StackAlignment);
|
||||
CreateStackObject(Size, Alignment, true);
|
||||
int Index = (int)Objects.size() - NumFixedObjects - 1;
|
||||
ensureMaxAlignment(Alignment);
|
||||
@ -550,9 +545,8 @@ int MachineFrameInfo::CreateSpillStackObject(uint64_t Size,
|
||||
int MachineFrameInfo::CreateVariableSizedObject(unsigned Alignment,
|
||||
const AllocaInst *Alloca) {
|
||||
HasVarSizedObjects = true;
|
||||
Alignment = clampStackAlignment(
|
||||
!getFrameLowering()->isStackRealignable() || !RealignOption, Alignment,
|
||||
getFrameLowering()->getStackAlignment());
|
||||
Alignment = clampStackAlignment(!StackRealignable || !RealignOption,
|
||||
Alignment, StackAlignment);
|
||||
Objects.push_back(StackObject(0, Alignment, 0, false, false, Alloca, true));
|
||||
ensureMaxAlignment(Alignment);
|
||||
return (int)Objects.size()-NumFixedObjects-1;
|
||||
@ -570,11 +564,9 @@ int MachineFrameInfo::CreateFixedObject(uint64_t Size, int64_t SPOffset,
|
||||
// the incoming frame position. If the frame object is at offset 32 and
|
||||
// the stack is guaranteed to be 16-byte aligned, then we know that the
|
||||
// object is 16-byte aligned.
|
||||
unsigned StackAlign = getFrameLowering()->getStackAlignment();
|
||||
unsigned Align = MinAlign(SPOffset, StackAlign);
|
||||
Align = clampStackAlignment(!getFrameLowering()->isStackRealignable() ||
|
||||
!RealignOption,
|
||||
Align, getFrameLowering()->getStackAlignment());
|
||||
unsigned Align = MinAlign(SPOffset, StackAlignment);
|
||||
Align = clampStackAlignment(!StackRealignable || !RealignOption, Align,
|
||||
StackAlignment);
|
||||
Objects.insert(Objects.begin(), StackObject(Size, Align, SPOffset, Immutable,
|
||||
/*isSS*/ false,
|
||||
/*Alloca*/ nullptr, isAliased));
|
||||
@ -585,11 +577,9 @@ int MachineFrameInfo::CreateFixedObject(uint64_t Size, int64_t SPOffset,
|
||||
/// on the stack. Returns an index with a negative value.
|
||||
int MachineFrameInfo::CreateFixedSpillStackObject(uint64_t Size,
|
||||
int64_t SPOffset) {
|
||||
unsigned StackAlign = getFrameLowering()->getStackAlignment();
|
||||
unsigned Align = MinAlign(SPOffset, StackAlign);
|
||||
Align = clampStackAlignment(!getFrameLowering()->isStackRealignable() ||
|
||||
!RealignOption,
|
||||
Align, getFrameLowering()->getStackAlignment());
|
||||
unsigned Align = MinAlign(SPOffset, StackAlignment);
|
||||
Align = clampStackAlignment(!StackRealignable || !RealignOption, Align,
|
||||
StackAlignment);
|
||||
Objects.insert(Objects.begin(), StackObject(Size, Align, SPOffset,
|
||||
/*Immutable*/ true,
|
||||
/*isSS*/ true,
|
||||
|
Loading…
Reference in New Issue
Block a user