• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- ARCFrameLowering.h - Define frame lowering for ARC -------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This class implements the ARC specific frame lowering.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_ARC_ARCFRAMELOWERING_H
15 #define LLVM_LIB_TARGET_ARC_ARCFRAMELOWERING_H
16 
17 #include "ARC.h"
18 #include "llvm/CodeGen/MachineBasicBlock.h"
19 #include "llvm/CodeGen/MachineFrameInfo.h"
20 #include "llvm/CodeGen/TargetFrameLowering.h"
21 
22 namespace llvm {
23 
24 class MachineFunction;
25 class ARCSubtarget;
26 class ARCInstrInfo;
27 
28 class ARCFrameLowering : public TargetFrameLowering {
29 public:
ARCFrameLowering(const ARCSubtarget & st)30   ARCFrameLowering(const ARCSubtarget &st)
31       : TargetFrameLowering(TargetFrameLowering::StackGrowsDown, 4, 0), ST(st) {
32   }
33 
34   /// Insert Prologue into the function.
35   void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
36 
37   /// Insert Epilogue into the function.
38   void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
39 
40   /// Add explicit callee save registers.
41   void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
42                             RegScavenger *RS) const override;
43 
44   bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
45                                  MachineBasicBlock::iterator MI,
46                                  const std::vector<CalleeSavedInfo> &CSI,
47                                  const TargetRegisterInfo *TRI) const override;
48 
49   bool
50   restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
51                               MachineBasicBlock::iterator MI,
52                               std::vector<CalleeSavedInfo> &CSI,
53                               const TargetRegisterInfo *TRI) const override;
54 
55   void processFunctionBeforeFrameFinalized(MachineFunction &MF,
56                                            RegScavenger *RS) const override;
57 
58   bool hasFP(const MachineFunction &MF) const override;
59 
60   MachineBasicBlock::iterator
61   eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
62                                 MachineBasicBlock::iterator I) const override;
63 
64   bool assignCalleeSavedSpillSlots(
65       llvm::MachineFunction &, const llvm::TargetRegisterInfo *,
66       std::vector<llvm::CalleeSavedInfo> &) const override;
67 
68 private:
69   void adjustStackToMatchRecords(MachineBasicBlock &MBB,
70                                  MachineBasicBlock::iterator MI,
71                                  bool allocate) const;
72 
73   const ARCSubtarget &ST;
74 };
75 
76 } // end namespace llvm
77 
78 #endif // LLVM_LIB_TARGET_ARC_ARCFRAMELOWERING_H
79