LoongArchFrameLowering.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //=- LoongArchFrameLowering.h - TargetFrameLowering for LoongArch -*- 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. // This class implements LoongArch-specific bits of TargetFrameLowering class.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHFRAMELOWERING_H
  13. #define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHFRAMELOWERING_H
  14. #include "llvm/CodeGen/TargetFrameLowering.h"
  15. namespace llvm {
  16. class LoongArchSubtarget;
  17. class LoongArchFrameLowering : public TargetFrameLowering {
  18. const LoongArchSubtarget &STI;
  19. public:
  20. explicit LoongArchFrameLowering(const LoongArchSubtarget &STI)
  21. : TargetFrameLowering(StackGrowsDown,
  22. /*StackAlignment=*/Align(16),
  23. /*LocalAreaOffset=*/0),
  24. STI(STI) {}
  25. void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
  26. void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
  27. void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
  28. RegScavenger *RS) const override;
  29. void processFunctionBeforeFrameFinalized(MachineFunction &MF,
  30. RegScavenger *RS) const override;
  31. bool hasReservedCallFrame(const MachineFunction &MF) const override;
  32. MachineBasicBlock::iterator
  33. eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
  34. MachineBasicBlock::iterator MI) const override;
  35. bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
  36. MachineBasicBlock::iterator MI,
  37. ArrayRef<CalleeSavedInfo> CSI,
  38. const TargetRegisterInfo *TRI) const override;
  39. StackOffset getFrameIndexReference(const MachineFunction &MF, int FI,
  40. Register &FrameReg) const override;
  41. bool hasFP(const MachineFunction &MF) const override;
  42. bool hasBP(const MachineFunction &MF) const;
  43. uint64_t getFirstSPAdjustAmount(const MachineFunction &MF,
  44. bool IsPrologue = false) const;
  45. private:
  46. void determineFrameLayout(MachineFunction &MF) const;
  47. void adjustReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
  48. const DebugLoc &DL, Register DestReg, Register SrcReg,
  49. int64_t Val, MachineInstr::MIFlag Flag) const;
  50. };
  51. } // end namespace llvm
  52. #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHFRAMELOWERING_H