| 1 | //===-- SparcFrameLowering.h - Define frame lowering for Sparc --*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #ifndef LLVM_LIB_TARGET_SPARC_SPARCFRAMELOWERING_H |
| 14 | #define LLVM_LIB_TARGET_SPARC_SPARCFRAMELOWERING_H |
| 15 | |
| 16 | #include "Sparc.h" |
| 17 | #include "llvm/CodeGen/TargetFrameLowering.h" |
| 18 | #include "llvm/Support/TypeSize.h" |
| 19 | |
| 20 | namespace llvm { |
| 21 | |
| 22 | class SparcSubtarget; |
| 23 | class SparcFrameLowering : public TargetFrameLowering { |
| 24 | public: |
| 25 | explicit SparcFrameLowering(const SparcSubtarget &ST); |
| 26 | |
| 27 | /// emitProlog/emitEpilog - These methods insert prolog and epilog code into |
| 28 | /// the function. |
| 29 | void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
| 30 | void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
| 31 | |
| 32 | MachineBasicBlock::iterator |
| 33 | eliminateCallFramePseudoInstr(MachineFunction &MF, |
| 34 | MachineBasicBlock &MBB, |
| 35 | MachineBasicBlock::iterator I) const override; |
| 36 | |
| 37 | bool hasReservedCallFrame(const MachineFunction &MF) const override; |
| 38 | void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, |
| 39 | RegScavenger *RS = nullptr) const override; |
| 40 | |
| 41 | StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, |
| 42 | Register &FrameReg) const override; |
| 43 | |
| 44 | /// targetHandlesStackFrameRounding - Returns true if the target is |
| 45 | /// responsible for rounding up the stack frame (probably at emitPrologue |
| 46 | /// time). |
| 47 | bool targetHandlesStackFrameRounding() const override { return true; } |
| 48 | |
| 49 | protected: |
| 50 | bool hasFPImpl(const MachineFunction &MF) const override; |
| 51 | |
| 52 | private: |
| 53 | // Remap input registers to output registers for leaf procedure. |
| 54 | void remapRegsForLeafProc(MachineFunction &MF) const; |
| 55 | |
| 56 | // Returns true if MF is a leaf procedure. |
| 57 | bool isLeafProc(MachineFunction &MF) const; |
| 58 | |
| 59 | |
| 60 | // Emits code for adjusting SP in function prologue/epilogue. |
| 61 | void emitSPAdjustment(MachineFunction &MF, |
| 62 | MachineBasicBlock &MBB, |
| 63 | MachineBasicBlock::iterator MBBI, |
| 64 | int NumBytes, unsigned ADDrr, unsigned ADDri) const; |
| 65 | |
| 66 | }; |
| 67 | |
| 68 | } // End llvm namespace |
| 69 | |
| 70 | #endif |
| 71 | |