ARMFrameLowering.h revision cd81d94322a39503e4a3e87b6ee03d4fcb3465fb
13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//==-- ARMTargetFrameLowering.h - Define frame lowering for ARM --*- C++ -*-==//
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//                     The LLVM Compiler Infrastructure
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// This file is distributed under the University of Illinois Open Source
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// License. See LICENSE.TXT for details.
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//===----------------------------------------------------------------------===//
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry//===----------------------------------------------------------------------===//
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#ifndef ARM_FRAMEINFO_H
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#define ARM_FRAMEINFO_H
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "llvm/Target/TargetFrameLowering.h"
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace llvm {
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  class ARMSubtarget;
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ARMFrameLowering : public TargetFrameLowering {
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  const ARMSubtarget &STI;
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  explicit ARMFrameLowering(const ARMSubtarget &sti);
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  /// the function.
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  void emitPrologue(MachineFunction &MF) const override;
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                                 MachineBasicBlock::iterator MI,
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                                 const std::vector<CalleeSavedInfo> &CSI,
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                                 const TargetRegisterInfo *TRI) const override;
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                                  MachineBasicBlock::iterator MI,
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                                  const std::vector<CalleeSavedInfo> &CSI,
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                                  const TargetRegisterInfo *TRI) const override;
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  bool hasFP(const MachineFunction &MF) const override;
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  bool hasReservedCallFrame(const MachineFunction &MF) const override;
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override;
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  int getFrameIndexReference(const MachineFunction &MF, int FI,
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                             unsigned &FrameReg) const override;
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  int ResolveFrameIndexReference(const MachineFunction &MF, int FI,
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                                 unsigned &FrameReg, int SPAdj) const;
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  int getFrameIndexOffset(const MachineFunction &MF, int FI) const override;
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                                            RegScavenger *RS) const override;
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  void adjustForSegmentedStacks(MachineFunction &MF) const override;
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry private:
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  void emitPushInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                    const std::vector<CalleeSavedInfo> &CSI, unsigned StmOpc,
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                    unsigned StrOpc, bool NoGap,
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                    bool(*Func)(unsigned, bool), unsigned NumAlignedDPRCS2Regs,
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                    unsigned MIFlags = 0) const;
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  void emitPopInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                   const std::vector<CalleeSavedInfo> &CSI, unsigned LdmOpc,
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                   unsigned LdrOpc, bool isVarArg, bool NoGap,
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                   bool(*Func)(unsigned, bool),
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                   unsigned NumAlignedDPRCS2Regs) const;
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  void
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry  eliminateCallFramePseudoInstr(MachineFunction &MF,
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                                MachineBasicBlock &MBB,
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry                                MachineBasicBlock::iterator MI) const override;
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // End llvm namespace
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#endif
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry