Go to the documentation of this file.
22 #include "llvm/Config/llvm-config.h"
27 #define DEBUG_TYPE "codegen"
32 if (!StackRealignable)
33 assert(Alignment <= StackAlignment &&
34 "For targets without stack realignment, Alignment is out of limit!");
35 if (MaxAlignment < Alignment)
36 MaxAlignment = Alignment;
41 Align StackAlignment) {
42 if (!ShouldClamp || Alignment <= StackAlignment)
45 <<
" exceeds the stack alignment "
47 <<
" when stack realignment is off" <<
'\n');
48 return StackAlignment;
55 assert(
Size != 0 &&
"Cannot allocate zero size stack objects!");
57 Objects.push_back(StackObject(
Size, Alignment, 0,
false, IsSpillSlot, Alloca,
58 !IsSpillSlot, StackID));
59 int Index = (
int)Objects.size() - NumFixedObjects - 1;
69 int Index = (
int)Objects.size() - NumFixedObjects - 1;
76 HasVarSizedObjects =
true;
78 Objects.push_back(StackObject(0, Alignment, 0,
false,
false, Alloca,
true));
80 return (
int)Objects.size()-NumFixedObjects-1;
84 bool IsImmutable,
bool IsAliased) {
85 assert(
Size != 0 &&
"Cannot allocate zero size fixed stack objects!");
95 Objects.insert(Objects.begin(),
96 StackObject(
Size, Alignment, SPOffset, IsImmutable,
99 return -++NumFixedObjects;
108 Objects.insert(Objects.begin(),
109 StackObject(
Size, Alignment, SPOffset, IsImmutable,
112 return -++NumFixedObjects;
163 MaxAlign =
std::max(Alignment, MaxAlign);
189 unsigned FrameSetupOpcode =
TII.getCallFrameSetupOpcode();
190 unsigned FrameDestroyOpcode =
TII.getCallFrameDestroyOpcode();
191 assert(FrameSetupOpcode != ~0u && FrameDestroyOpcode != ~0u &&
192 "Can only compute MaxCallFrameSize if Setup/Destroy opcode are known");
194 MaxCallFrameSize = 0;
197 unsigned Opcode =
MI.getOpcode();
198 if (Opcode == FrameSetupOpcode || Opcode == FrameDestroyOpcode) {
202 }
else if (
MI.isInlineAsm()) {
213 if (Objects.empty())
return;
218 OS <<
"Frame Objects:\n";
220 for (
unsigned i = 0,
e = Objects.size();
i !=
e; ++
i) {
221 const StackObject &SO = Objects[
i];
222 OS <<
" fi#" << (
int)(
i-NumFixedObjects) <<
": ";
225 OS <<
"id=" <<
static_cast<unsigned>(SO.StackID) <<
' ';
227 if (SO.Size == ~0ULL) {
232 OS <<
"variable sized";
234 OS <<
"size=" << SO.Size;
235 OS <<
", align=" << SO.Alignment.value();
237 if (
i < NumFixedObjects)
239 if (
i < NumFixedObjects || SO.SPOffset != -1) {
240 int64_t Off = SO.SPOffset - ValOffset;
241 OS <<
", at location [SP";
252 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
uint64_t estimateStackSize(const MachineFunction &MF) const
Estimate and return the size of the stack frame.
Information about stack frame layout on the target.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
virtual const TargetInstrInfo * getInstrInfo() const
std::string DebugStr(const Align &A)
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
int getObjectIndexEnd() const
Return one past the maximum frame object index.
int CreateVariableSizedObject(Align Alignment, const AllocaInst *Alloca)
Notify the MachineFrameInfo object that a variable sized object has been created.
unsigned const TargetRegisterInfo * TRI
unsigned getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call.
Align getTransientStackAlign() const
getTransientStackAlignment - This method returns the number of bytes to which the stack pointer must ...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
TargetInstrInfo - Interface to description of machine instruction set.
int getOffsetOfLocalArea() const
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...
void ensureMaxAlignment(Align Alignment)
Make sure the function is at least Align bytes aligned.
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
virtual bool hasReservedCallFrame(const MachineFunction &MF) const
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
Clang compiles this i1 i64 store i64 i64 store i64 i64 store i64 i64 store i64 align Which gets codegen d xmm0 movaps rbp movaps rbp movaps rbp movaps rbp rbp rbp rbp rbp It would be better to have movq s of instead of the movaps s LLVM produces ret int
void print(const MachineFunction &MF, raw_ostream &OS) const
Used by the MachineFunction printer to print information about stack objects.
const HexagonInstrInfo * TII
uint8_t getStackID(int ObjectIdx) const
This class implements an extremely fast bulk output stream that can only output to a stream.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
This struct is a compact representation of a valid (non-zero power of two) alignment.
int getObjectIndexBegin() const
Return the minimum frame object index.
bool isCalleeSavedInfoValid() const
Has the callee saved info been calculated yet?
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
int CreateSpillStackObject(uint64_t Size, Align Alignment)
Create a new statically sized stack object that represents a spill slot, returning a nonnegative iden...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static Align clampStackAlignment(bool ShouldClamp, Align Alignment, Align StackAlignment)
Clamp the alignment if requested and emit a warning.
int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset, bool IsImmutable=false)
Create a spill slot at a fixed location on the stack.
Representation of each machine instruction.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
const MCPhysReg * getCalleeSavedRegs() const
Returns list of callee saved registers.
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
void computeMaxCallFrameSize(const MachineFunction &MF)
Computes the maximum size of a callframe and the AdjustsStack property.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
int CreateStackObject(uint64_t Size, Align Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it.
BitVector getPristineRegs(const MachineFunction &MF) const
Return a set of physical registers that are pristine.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
unsigned const MachineRegisterInfo * MRI
Align getMaxAlign() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
void dump(const MachineFunction &MF) const
dump - Print the function to stderr.
Align commonAlignment(Align A, Align B)
Returns the alignment that satisfies both alignments.
virtual const TargetFrameLowering * getFrameLowering() const
bool hasStackRealignment(const MachineFunction &MF) const
True if stack realignment is required and still possible.
MCSubRegIterator enumerates all sub-registers of Reg.
Align max(MaybeAlign Lhs, Align Rhs)
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
an instruction to allocate memory on the stack