1 //=- HexagonFrameLowering.h - Define frame lowering for Hexagon --*- C++ -*--=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONFRAMELOWERING_H
11 #define LLVM_LIB_TARGET_HEXAGON_HEXAGONFRAMELOWERING_H
14 #include "llvm/Target/TargetFrameLowering.h"
18 class HexagonInstrInfo;
20 class HexagonFrameLowering : public TargetFrameLowering {
22 void expandAlloca(MachineInstr *AI, const HexagonInstrInfo &TII,
23 unsigned SP, unsigned CF) const;
26 explicit HexagonFrameLowering()
27 : TargetFrameLowering(StackGrowsDown, 8, 0, 1, true) {}
29 void emitPrologue(MachineFunction &MF) const override;
30 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
31 bool targetHandlesStackFrameRounding() const override {
34 bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
35 MachineBasicBlock::iterator MI,
36 const std::vector<CalleeSavedInfo> &CSI,
37 const TargetRegisterInfo *TRI) const override;
40 eliminateCallFramePseudoInstr(MachineFunction &MF,
41 MachineBasicBlock &MBB,
42 MachineBasicBlock::iterator I) const override;
45 restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
46 MachineBasicBlock::iterator MI,
47 const std::vector<CalleeSavedInfo> &CSI,
48 const TargetRegisterInfo *TRI) const override;
49 void processFunctionBeforeFrameFinalized(MachineFunction &MF,
50 RegScavenger *RS = NULL) const override;
51 void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
52 RegScavenger *RS) const override;
53 int getFrameIndexOffset(const MachineFunction &MF, int FI) const override;
54 bool hasFP(const MachineFunction &MF) const override;
55 bool hasTailCall(MachineBasicBlock &MBB) const;
56 void adjustForCalleeSavedRegsSpillCall(MachineFunction &MF) const;
57 bool replacePredRegPseudoSpillCode(MachineFunction &MF) const;
59 const SpillSlot *getCalleeSavedSpillSlots(unsigned &NumEntries)
61 static const SpillSlot Offsets[] = {
62 { Hexagon::R17, -4 }, { Hexagon::R16, -8 }, { Hexagon::D8, -8 },
63 { Hexagon::R19, -12 }, { Hexagon::R18, -16 }, { Hexagon::D9, -16 },
64 { Hexagon::R21, -20 }, { Hexagon::R20, -24 }, { Hexagon::D10, -24 },
65 { Hexagon::R23, -28 }, { Hexagon::R22, -32 }, { Hexagon::D11, -32 },
66 { Hexagon::R25, -36 }, { Hexagon::R24, -40 }, { Hexagon::D12, -40 },
67 { Hexagon::R27, -44 }, { Hexagon::R26, -48 }, { Hexagon::D13, -48 }
70 NumEntries = array_lengthof(Offsets);
74 bool assignCalleeSavedSpillSlots(MachineFunction &MF,
75 const TargetRegisterInfo *TRI,
76 std::vector<CalleeSavedInfo> &CSI) const override;
78 bool needsAligna(const MachineFunction &MF) const;
79 MachineInstr *getAlignaInstr(MachineFunction &MF) const;
82 } // End llvm namespace