LLVM  3.7.0
HexagonFrameLowering.h
Go to the documentation of this file.
1 //=- HexagonFrameLowering.h - Define frame lowering for Hexagon --*- 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 #ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONFRAMELOWERING_H
11 #define LLVM_LIB_TARGET_HEXAGON_HEXAGONFRAMELOWERING_H
12 
13 #include "Hexagon.h"
15 
16 namespace llvm {
17 
18 class HexagonInstrInfo;
19 class HexagonRegisterInfo;
20 
22 public:
25 
26  // All of the prolog/epilog functionality, including saving and restoring
27  // callee-saved registers is handled in emitPrologue. This is to have the
28  // logic for shrink-wrapping in one place.
29  void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const
30  override;
32  override {}
34  MachineBasicBlock::iterator MI, const std::vector<CalleeSavedInfo> &CSI,
35  const TargetRegisterInfo *TRI) const override {
36  return true;
37  }
39  MachineBasicBlock::iterator MI, const std::vector<CalleeSavedInfo> &CSI,
40  const TargetRegisterInfo *TRI) const override {
41  return true;
42  }
43 
45  MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const override;
47  RegScavenger *RS = nullptr) const override;
48  void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
49  RegScavenger *RS) const override;
50 
51  bool targetHandlesStackFrameRounding() const override {
52  return true;
53  }
54  int getFrameIndexOffset(const MachineFunction &MF, int FI) const override;
55  bool hasFP(const MachineFunction &MF) const override;
56 
57  const SpillSlot *getCalleeSavedSpillSlots(unsigned &NumEntries)
58  const override {
59  static const SpillSlot Offsets[] = {
60  { Hexagon::R17, -4 }, { Hexagon::R16, -8 }, { Hexagon::D8, -8 },
61  { Hexagon::R19, -12 }, { Hexagon::R18, -16 }, { Hexagon::D9, -16 },
62  { Hexagon::R21, -20 }, { Hexagon::R20, -24 }, { Hexagon::D10, -24 },
63  { Hexagon::R23, -28 }, { Hexagon::R22, -32 }, { Hexagon::D11, -32 },
64  { Hexagon::R25, -36 }, { Hexagon::R24, -40 }, { Hexagon::D12, -40 },
65  { Hexagon::R27, -44 }, { Hexagon::R26, -48 }, { Hexagon::D13, -48 }
66  };
67  NumEntries = array_lengthof(Offsets);
68  return Offsets;
69  }
70 
72  const TargetRegisterInfo *TRI, std::vector<CalleeSavedInfo> &CSI)
73  const override;
74 
75  bool needsAligna(const MachineFunction &MF) const;
77 
78 private:
79  typedef std::vector<CalleeSavedInfo> CSIVect;
80 
81  void expandAlloca(MachineInstr *AI, const HexagonInstrInfo &TII,
82  unsigned SP, unsigned CF) const;
83  void insertPrologueInBlock(MachineBasicBlock &MBB) const;
84  void insertEpilogueInBlock(MachineBasicBlock &MBB) const;
85  bool insertCSRSpillsInBlock(MachineBasicBlock &MBB, const CSIVect &CSI,
86  const HexagonRegisterInfo &HRI) const;
87  bool insertCSRRestoresInBlock(MachineBasicBlock &MBB, const CSIVect &CSI,
88  const HexagonRegisterInfo &HRI) const;
89 
90  void adjustForCalleeSavedRegsSpillCall(MachineFunction &MF) const;
91  bool replacePredRegPseudoSpillCode(MachineFunction &MF) const;
92  bool replaceVecPredRegPseudoSpillCode(MachineFunction &MF) const;
93 
94  void findShrunkPrologEpilog(MachineFunction &MF, MachineBasicBlock *&PrologB,
95  MachineBasicBlock *&EpilogB) const;
96 
97  bool shouldInlineCSR(llvm::MachineFunction&, const CSIVect&) const;
98  bool useSpillFunction(MachineFunction &MF, const CSIVect &CSI) const;
99  bool useRestoreFunction(MachineFunction &MF, const CSIVect &CSI) const;
100 };
101 
102 } // End llvm namespace
103 
104 #endif
Offsets
Offsets in bytes from the start of the input buffer.
Definition: SIInstrInfo.h:378
const SpillSlot * getCalleeSavedSpillSlots(unsigned &NumEntries) const override
getCalleeSavedSpillSlots - This method returns a pointer to an array of pairs, that contains an entry...
int getFrameIndexOffset(const MachineFunction &MF, int FI) const override
getFrameIndexOffset - Returns the displacement from the frame register to the stack frame of the spec...
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
MachineInstr * getAlignaInstr(MachineFunction &MF) const
const HexagonInstrInfo * TII
bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
bool needsAligna(const MachineFunction &MF) const
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
Perform most of the PEI work here:
LLVM_CONSTEXPR size_t array_lengthof(T(&)[N])
Find the length of an array.
Definition: STLExtras.h:247
bundle_iterator< MachineInstr, instr_iterator > iterator
#define true
Definition: ConvertUTF.c:66
void eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const override
eliminateCallFramePseudoInstr - This method is called during prolog/epilog code insertion to eliminat...
bundle_iterator - MachineBasicBlock iterator that automatically skips over MIs that are inside bundle...
void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS=nullptr) const override
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Information about stack frame layout on the target.
bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override
assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic.
Representation of each machine instruction.
Definition: MachineInstr.h:51
#define I(x, y, z)
Definition: MD5.cpp:54
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...
bool targetHandlesStackFrameRounding() const override
targetHandlesStackFrameRounding - Returns true if the target is responsible for rounding up the stack...
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...