Pete Couperus | 2d1f6d6 | 2017-08-24 15:40:33 +0000 | [diff] [blame] | 1 | //===- ARCFrameLowering.h - Define frame lowering for ARC -------*- C++ -*-===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Pete Couperus | 2d1f6d6 | 2017-08-24 15:40:33 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This class implements the ARC specific frame lowering. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #ifndef LLVM_LIB_TARGET_ARC_ARCFRAMELOWERING_H |
| 14 | #define LLVM_LIB_TARGET_ARC_ARCFRAMELOWERING_H |
| 15 | |
| 16 | #include "ARC.h" |
| 17 | #include "llvm/CodeGen/MachineBasicBlock.h" |
| 18 | #include "llvm/CodeGen/MachineFrameInfo.h" |
David Blaikie | 1be62f0 | 2017-11-03 22:32:11 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/TargetFrameLowering.h" |
Pete Couperus | 2d1f6d6 | 2017-08-24 15:40:33 +0000 | [diff] [blame] | 20 | |
| 21 | namespace llvm { |
| 22 | |
| 23 | class MachineFunction; |
| 24 | class ARCSubtarget; |
| 25 | class ARCInstrInfo; |
| 26 | |
| 27 | class ARCFrameLowering : public TargetFrameLowering { |
| 28 | public: |
| 29 | ARCFrameLowering(const ARCSubtarget &st) |
Guillaume Chatelet | 882c43d | 2019-10-17 07:49:39 +0000 | [diff] [blame^] | 30 | : TargetFrameLowering(TargetFrameLowering::StackGrowsDown, Align(4), 0), |
| 31 | ST(st) {} |
Pete Couperus | 2d1f6d6 | 2017-08-24 15:40:33 +0000 | [diff] [blame] | 32 | |
| 33 | /// Insert Prologue into the function. |
| 34 | void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
| 35 | |
| 36 | /// Insert Epilogue into the function. |
| 37 | void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; |
| 38 | |
| 39 | /// Add explicit callee save registers. |
| 40 | void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, |
| 41 | RegScavenger *RS) const override; |
| 42 | |
| 43 | bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, |
| 44 | MachineBasicBlock::iterator MI, |
| 45 | const std::vector<CalleeSavedInfo> &CSI, |
| 46 | const TargetRegisterInfo *TRI) const override; |
| 47 | |
| 48 | bool |
| 49 | restoreCalleeSavedRegisters(MachineBasicBlock &MBB, |
| 50 | MachineBasicBlock::iterator MI, |
| 51 | std::vector<CalleeSavedInfo> &CSI, |
| 52 | const TargetRegisterInfo *TRI) const override; |
| 53 | |
| 54 | void processFunctionBeforeFrameFinalized(MachineFunction &MF, |
| 55 | RegScavenger *RS) const override; |
| 56 | |
| 57 | bool hasFP(const MachineFunction &MF) const override; |
| 58 | |
| 59 | MachineBasicBlock::iterator |
| 60 | eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, |
| 61 | MachineBasicBlock::iterator I) const override; |
| 62 | |
| 63 | bool assignCalleeSavedSpillSlots( |
| 64 | llvm::MachineFunction &, const llvm::TargetRegisterInfo *, |
| 65 | std::vector<llvm::CalleeSavedInfo> &) const override; |
| 66 | |
| 67 | private: |
| 68 | void adjustStackToMatchRecords(MachineBasicBlock &MBB, |
| 69 | MachineBasicBlock::iterator MI, |
| 70 | bool allocate) const; |
| 71 | |
| 72 | const ARCSubtarget &ST; |
| 73 | }; |
| 74 | |
| 75 | } // end namespace llvm |
| 76 | |
| 77 | #endif // LLVM_LIB_TARGET_ARC_ARCFRAMELOWERING_H |