summaryrefslogtreecommitdiff
path: root/llvm/include/llvm/CodeGen/TargetFrameLowering.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include/llvm/CodeGen/TargetFrameLowering.h')
-rw-r--r--llvm/include/llvm/CodeGen/TargetFrameLowering.h73
1 files changed, 60 insertions, 13 deletions
diff --git a/llvm/include/llvm/CodeGen/TargetFrameLowering.h b/llvm/include/llvm/CodeGen/TargetFrameLowering.h
index c7d4c4d7e5d44..c3a11b1996759 100644
--- a/llvm/include/llvm/CodeGen/TargetFrameLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetFrameLowering.h
@@ -14,8 +14,6 @@
#define LLVM_CODEGEN_TARGETFRAMELOWERING_H
#include "llvm/CodeGen/MachineBasicBlock.h"
-#include "llvm/ADT/StringSwitch.h"
-#include <utility>
#include <vector>
namespace llvm {
@@ -52,6 +50,21 @@ public:
unsigned Reg;
int Offset; // Offset relative to stack pointer on function entry.
};
+
+ struct DwarfFrameBase {
+ // The frame base may be either a register (the default), the CFA,
+ // or a WebAssembly-specific location description.
+ enum FrameBaseKind { Register, CFA, WasmFrameBase } Kind;
+ struct WasmFrameBase {
+ unsigned Kind; // Wasm local, global, or value stack
+ unsigned Index;
+ };
+ union {
+ unsigned Reg;
+ struct WasmFrameBase WasmLoc;
+ } Location;
+ };
+
private:
StackDirection StackDir;
Align StackAlignment;
@@ -60,7 +73,7 @@ private:
bool StackRealignable;
public:
TargetFrameLowering(StackDirection D, Align StackAl, int LAO,
- Align TransAl = Align::None(), bool StackReal = true)
+ Align TransAl = Align(1), bool StackReal = true)
: StackDir(D), StackAlignment(StackAl), TransientStackAlignment(TransAl),
LocalAreaOffset(LAO), StackRealignable(StackReal) {}
@@ -78,6 +91,11 @@ public:
/// is the largest alignment for any data object in the target.
///
unsigned getStackAlignment() const { return StackAlignment.value(); }
+ /// getStackAlignment - This method returns the number of bytes to which the
+ /// stack pointer must be aligned on entry to a function. Typically, this
+ /// is the largest alignment for any data object in the target.
+ ///
+ Align getStackAlign() const { return StackAlignment; }
/// alignSPAdjust - This method aligns the stack adjustment to the correct
/// alignment.
@@ -95,9 +113,15 @@ public:
/// which the stack pointer must be aligned at all times, even between
/// calls.
///
- unsigned getTransientStackAlignment() const {
+ LLVM_ATTRIBUTE_DEPRECATED(unsigned getTransientStackAlignment() const,
+ "Use getTransientStackAlign instead") {
return TransientStackAlignment.value();
}
+ /// getTransientStackAlignment - This method returns the number of bytes to
+ /// which the stack pointer must be aligned at all times, even between
+ /// calls.
+ ///
+ Align getTransientStackAlign() const { return TransientStackAlignment; }
/// isStackRealignable - This method returns whether the stack can be
/// realigned.
@@ -178,6 +202,17 @@ public:
virtual void emitEpilogue(MachineFunction &MF,
MachineBasicBlock &MBB) const = 0;
+ /// With basic block sections, emit callee saved frame moves for basic blocks
+ /// that are in a different section.
+ virtual void
+ emitCalleeSavedFrameMoves(MachineBasicBlock &MBB,
+ MachineBasicBlock::iterator MBBI) const {}
+
+ virtual void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB,
+ MachineBasicBlock::iterator MBBI,
+ const DebugLoc &DL,
+ bool IsPrologue) const {}
+
/// Replace a StackProbe stub (if any) with the actual probe code inline
virtual void inlineStackProbe(MachineFunction &MF,
MachineBasicBlock &PrologueMBB) const {}
@@ -198,7 +233,7 @@ public:
/// storeRegToStackSlot(). Returns false otherwise.
virtual bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
MachineBasicBlock::iterator MI,
- const std::vector<CalleeSavedInfo> &CSI,
+ ArrayRef<CalleeSavedInfo> CSI,
const TargetRegisterInfo *TRI) const {
return false;
}
@@ -209,10 +244,11 @@ public:
/// If it returns true, and any of the registers in CSI is not restored,
/// it sets the corresponding Restored flag in CSI to false.
/// Returns false otherwise.
- virtual bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
- MachineBasicBlock::iterator MI,
- std::vector<CalleeSavedInfo> &CSI,
- const TargetRegisterInfo *TRI) const {
+ virtual bool
+ restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
+ MachineBasicBlock::iterator MI,
+ MutableArrayRef<CalleeSavedInfo> CSI,
+ const TargetRegisterInfo *TRI) const {
return false;
}
@@ -256,7 +292,7 @@ public:
/// and offset used to reference a frame index location. The offset is
/// returned directly, and the base register is returned via FrameReg.
virtual int getFrameIndexReference(const MachineFunction &MF, int FI,
- unsigned &FrameReg) const;
+ Register &FrameReg) const;
/// Same as \c getFrameIndexReference, except that the stack pointer (as
/// opposed to the frame pointer) will be the preferred value for \p
@@ -265,7 +301,7 @@ public:
/// offset is only guaranteed to be valid with respect to the value of SP at
/// the end of the prologue.
virtual int getFrameIndexReferencePreferSP(const MachineFunction &MF, int FI,
- unsigned &FrameReg,
+ Register &FrameReg,
bool IgnoreSPUpdates) const {
// Always safe to dispatch to getFrameIndexReference.
return getFrameIndexReference(MF, FI, FrameReg);
@@ -278,7 +314,7 @@ public:
int FI) const {
// By default, dispatch to getFrameIndexReference. Interested targets can
// override this.
- unsigned FrameReg;
+ Register FrameReg;
return getFrameIndexReference(MF, FI, FrameReg);
}
@@ -309,6 +345,13 @@ public:
RegScavenger *RS = nullptr) const {
}
+ /// processFunctionBeforeFrameIndicesReplaced - This method is called
+ /// immediately before MO_FrameIndex operands are eliminated, but after the
+ /// frame is finalized. This method is optional.
+ virtual void
+ processFunctionBeforeFrameIndicesReplaced(MachineFunction &MF,
+ RegScavenger *RS = nullptr) const {}
+
virtual unsigned getWinEHParentFrameOffset(const MachineFunction &MF) const {
report_fatal_error("WinEH not implemented for this target");
}
@@ -393,7 +436,11 @@ public:
/// Return initial CFA register value i.e. the one valid at the beginning of
/// the function (before any stack operations).
- virtual unsigned getInitialCFARegister(const MachineFunction &MF) const;
+ virtual Register getInitialCFARegister(const MachineFunction &MF) const;
+
+ /// Return the frame base information to be encoded in the DWARF subprogram
+ /// debug info.
+ virtual DwarfFrameBase getDwarfFrameBase(const MachineFunction &MF) const;
};
} // End llvm namespace