1235633Sdim//===-- SparcFrameLowering.h - Define frame lowering for Sparc --*- C++ -*-===//
2218885Sdim//
3218885Sdim//                     The LLVM Compiler Infrastructure
4218885Sdim//
5218885Sdim// This file is distributed under the University of Illinois Open Source
6218885Sdim// License. See LICENSE.TXT for details.
7218885Sdim//
8218885Sdim//===----------------------------------------------------------------------===//
9218885Sdim//
10218885Sdim//
11218885Sdim//
12218885Sdim//===----------------------------------------------------------------------===//
13218885Sdim
14218885Sdim#ifndef SPARC_FRAMEINFO_H
15218885Sdim#define SPARC_FRAMEINFO_H
16218885Sdim
17218885Sdim#include "Sparc.h"
18218885Sdim#include "SparcSubtarget.h"
19218885Sdim#include "llvm/Target/TargetFrameLowering.h"
20218885Sdim
21218885Sdimnamespace llvm {
22218885Sdim  class SparcSubtarget;
23218885Sdim
24218885Sdimclass SparcFrameLowering : public TargetFrameLowering {
25252723Sdim  const SparcSubtarget &SubTarget;
26218885Sdimpublic:
27252723Sdim  explicit SparcFrameLowering(const SparcSubtarget &ST)
28252723Sdim    : TargetFrameLowering(TargetFrameLowering::StackGrowsDown,
29252723Sdim                          ST.is64Bit() ? 16 : 8, 0, ST.is64Bit() ? 16 : 8),
30252723Sdim      SubTarget(ST) {}
31218885Sdim
32218885Sdim  /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
33218885Sdim  /// the function.
34218885Sdim  void emitPrologue(MachineFunction &MF) const;
35218885Sdim  void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
36218885Sdim
37252723Sdim  void eliminateCallFramePseudoInstr(MachineFunction &MF,
38252723Sdim                                     MachineBasicBlock &MBB,
39252723Sdim                                     MachineBasicBlock::iterator I) const;
40252723Sdim
41263509Sdim  bool hasReservedCallFrame(const MachineFunction &MF) const;
42263509Sdim  bool hasFP(const MachineFunction &MF) const;
43263509Sdim  void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
44263509Sdim                                            RegScavenger *RS = NULL) const;
45263509Sdim
46263509Sdimprivate:
47263509Sdim  // Remap input registers to output registers for leaf procedure.
48263509Sdim  void remapRegsForLeafProc(MachineFunction &MF) const;
49263509Sdim
50263509Sdim  // Returns true if MF is a leaf procedure.
51263509Sdim  bool isLeafProc(MachineFunction &MF) const;
52263509Sdim
53263509Sdim
54263509Sdim  // Emits code for adjusting SP in function prologue/epilogue.
55263509Sdim  void emitSPAdjustment(MachineFunction &MF,
56263509Sdim                        MachineBasicBlock &MBB,
57263509Sdim                        MachineBasicBlock::iterator MBBI,
58263509Sdim                        int NumBytes, unsigned ADDrr, unsigned ADDri) const;
59263509Sdim
60218885Sdim};
61218885Sdim
62218885Sdim} // End llvm namespace
63218885Sdim
64218885Sdim#endif
65