X86FrameLowering.h revision 36b56886974eae4f9c5ebc96befd3e7bfe5de338
1//===-- X86TargetFrameLowering.h - Define frame lowering for X86 -*- 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 X86-specific bits of TargetFrameLowering class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef X86_FRAMELOWERING_H
15#define X86_FRAMELOWERING_H
16
17#include "X86Subtarget.h"
18#include "llvm/Target/TargetFrameLowering.h"
19
20namespace llvm {
21
22class MCSymbol;
23class X86TargetMachine;
24
25class X86FrameLowering : public TargetFrameLowering {
26  const X86TargetMachine &TM;
27  const X86Subtarget &STI;
28public:
29  explicit X86FrameLowering(const X86TargetMachine &tm, const X86Subtarget &sti)
30    : TargetFrameLowering(StackGrowsDown,
31                          sti.getStackAlignment(),
32                          (sti.is64Bit() ? -8 : -4)),
33      TM(tm), STI(sti) {
34  }
35
36  void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB,
37                                 MachineBasicBlock::iterator MBBI, DebugLoc DL,
38                                 unsigned FramePtr) const;
39
40  /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
41  /// the function.
42  void emitPrologue(MachineFunction &MF) const override;
43  void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
44
45  void adjustForSegmentedStacks(MachineFunction &MF) const override;
46
47  void adjustForHiPEPrologue(MachineFunction &MF) const override;
48
49  void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
50                                        RegScavenger *RS = NULL) const override;
51
52  bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
53                                 MachineBasicBlock::iterator MI,
54                                 const std::vector<CalleeSavedInfo> &CSI,
55                                 const TargetRegisterInfo *TRI) const override;
56
57  bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
58                                  MachineBasicBlock::iterator MI,
59                                  const std::vector<CalleeSavedInfo> &CSI,
60                                  const TargetRegisterInfo *TRI) const override;
61
62  bool hasFP(const MachineFunction &MF) const override;
63  bool hasReservedCallFrame(const MachineFunction &MF) const override;
64
65  int getFrameIndexOffset(const MachineFunction &MF, int FI) const override;
66  int getFrameIndexReference(const MachineFunction &MF, int FI,
67                             unsigned &FrameReg) const override;
68
69  void eliminateCallFramePseudoInstr(MachineFunction &MF,
70                                 MachineBasicBlock &MBB,
71                                 MachineBasicBlock::iterator MI) const override;
72};
73
74} // End llvm namespace
75
76#endif
77