xref: /aosp_15_r20/external/llvm/lib/Target/Sparc/SparcFrameLowering.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===-- SparcFrameLowering.h - Define frame lowering for Sparc --*- C++ -*-===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker //
11*9880d681SAndroid Build Coastguard Worker //
12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
13*9880d681SAndroid Build Coastguard Worker 
14*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_SPARC_SPARCFRAMELOWERING_H
15*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_SPARC_SPARCFRAMELOWERING_H
16*9880d681SAndroid Build Coastguard Worker 
17*9880d681SAndroid Build Coastguard Worker #include "Sparc.h"
18*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetFrameLowering.h"
19*9880d681SAndroid Build Coastguard Worker 
20*9880d681SAndroid Build Coastguard Worker namespace llvm {
21*9880d681SAndroid Build Coastguard Worker 
22*9880d681SAndroid Build Coastguard Worker class SparcSubtarget;
23*9880d681SAndroid Build Coastguard Worker class SparcFrameLowering : public TargetFrameLowering {
24*9880d681SAndroid Build Coastguard Worker public:
25*9880d681SAndroid Build Coastguard Worker   explicit SparcFrameLowering(const SparcSubtarget &ST);
26*9880d681SAndroid Build Coastguard Worker 
27*9880d681SAndroid Build Coastguard Worker   /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
28*9880d681SAndroid Build Coastguard Worker   /// the function.
29*9880d681SAndroid Build Coastguard Worker   void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
30*9880d681SAndroid Build Coastguard Worker   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
31*9880d681SAndroid Build Coastguard Worker 
32*9880d681SAndroid Build Coastguard Worker   MachineBasicBlock::iterator
33*9880d681SAndroid Build Coastguard Worker   eliminateCallFramePseudoInstr(MachineFunction &MF,
34*9880d681SAndroid Build Coastguard Worker                                 MachineBasicBlock &MBB,
35*9880d681SAndroid Build Coastguard Worker                                 MachineBasicBlock::iterator I) const override;
36*9880d681SAndroid Build Coastguard Worker 
37*9880d681SAndroid Build Coastguard Worker   bool hasReservedCallFrame(const MachineFunction &MF) const override;
38*9880d681SAndroid Build Coastguard Worker   bool hasFP(const MachineFunction &MF) const override;
39*9880d681SAndroid Build Coastguard Worker   void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
40*9880d681SAndroid Build Coastguard Worker                             RegScavenger *RS = nullptr) const override;
41*9880d681SAndroid Build Coastguard Worker 
42*9880d681SAndroid Build Coastguard Worker   int getFrameIndexReference(const MachineFunction &MF, int FI,
43*9880d681SAndroid Build Coastguard Worker                              unsigned &FrameReg) const override;
44*9880d681SAndroid Build Coastguard Worker 
45*9880d681SAndroid Build Coastguard Worker   /// targetHandlesStackFrameRounding - Returns true if the target is
46*9880d681SAndroid Build Coastguard Worker   /// responsible for rounding up the stack frame (probably at emitPrologue
47*9880d681SAndroid Build Coastguard Worker   /// time).
targetHandlesStackFrameRounding()48*9880d681SAndroid Build Coastguard Worker   bool targetHandlesStackFrameRounding() const override { return true; }
49*9880d681SAndroid Build Coastguard Worker 
50*9880d681SAndroid Build Coastguard Worker private:
51*9880d681SAndroid Build Coastguard Worker   // Remap input registers to output registers for leaf procedure.
52*9880d681SAndroid Build Coastguard Worker   void remapRegsForLeafProc(MachineFunction &MF) const;
53*9880d681SAndroid Build Coastguard Worker 
54*9880d681SAndroid Build Coastguard Worker   // Returns true if MF is a leaf procedure.
55*9880d681SAndroid Build Coastguard Worker   bool isLeafProc(MachineFunction &MF) const;
56*9880d681SAndroid Build Coastguard Worker 
57*9880d681SAndroid Build Coastguard Worker 
58*9880d681SAndroid Build Coastguard Worker   // Emits code for adjusting SP in function prologue/epilogue.
59*9880d681SAndroid Build Coastguard Worker   void emitSPAdjustment(MachineFunction &MF,
60*9880d681SAndroid Build Coastguard Worker                         MachineBasicBlock &MBB,
61*9880d681SAndroid Build Coastguard Worker                         MachineBasicBlock::iterator MBBI,
62*9880d681SAndroid Build Coastguard Worker                         int NumBytes, unsigned ADDrr, unsigned ADDri) const;
63*9880d681SAndroid Build Coastguard Worker 
64*9880d681SAndroid Build Coastguard Worker };
65*9880d681SAndroid Build Coastguard Worker 
66*9880d681SAndroid Build Coastguard Worker } // End llvm namespace
67*9880d681SAndroid Build Coastguard Worker 
68*9880d681SAndroid Build Coastguard Worker #endif
69