Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame^] | 1 | //==-- ARMTargetFrameLowering.h - Define frame lowering for ARM --*- C++ -*-==// |
Rafael Espindola | ec46ea3 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
Rafael Espindola | ec46ea3 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef ARM_FRAMEINFO_H |
| 15 | #define ARM_FRAMEINFO_H |
| 16 | |
| 17 | #include "ARM.h" |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 18 | #include "ARMSubtarget.h" |
Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame^] | 19 | #include "llvm/Target/TargetFrameLowering.h" |
Rafael Espindola | ec46ea3 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 20 | |
| 21 | namespace llvm { |
Anton Korobeynikov | 3346491 | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 22 | class ARMSubtarget; |
Rafael Espindola | ec46ea3 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 23 | |
Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame^] | 24 | class ARMFrameLowering : public TargetFrameLowering { |
Anton Korobeynikov | 3346491 | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 25 | protected: |
| 26 | const ARMSubtarget &STI; |
| 27 | |
Rafael Espindola | ec46ea3 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 28 | public: |
Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame^] | 29 | explicit ARMFrameLowering(const ARMSubtarget &sti) |
| 30 | : TargetFrameLowering(StackGrowsDown, sti.getStackAlignment(), 0, 4), |
| 31 | STI(sti) { |
Rafael Espindola | ec46ea3 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 32 | } |
Anton Korobeynikov | 3346491 | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 33 | |
| 34 | /// emitProlog/emitEpilog - These methods insert prolog and epilog code into |
| 35 | /// the function. |
| 36 | void emitPrologue(MachineFunction &MF) const; |
| 37 | void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; |
Anton Korobeynikov | d0c3817 | 2010-11-18 21:19:35 +0000 | [diff] [blame] | 38 | |
Anton Korobeynikov | cd775ce | 2010-11-27 23:05:03 +0000 | [diff] [blame] | 39 | bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, |
| 40 | MachineBasicBlock::iterator MI, |
| 41 | const std::vector<CalleeSavedInfo> &CSI, |
| 42 | const TargetRegisterInfo *TRI) const; |
| 43 | |
| 44 | bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, |
| 45 | MachineBasicBlock::iterator MI, |
| 46 | const std::vector<CalleeSavedInfo> &CSI, |
| 47 | const TargetRegisterInfo *TRI) const; |
| 48 | |
Anton Korobeynikov | d0c3817 | 2010-11-18 21:19:35 +0000 | [diff] [blame] | 49 | bool hasFP(const MachineFunction &MF) const; |
| 50 | bool hasReservedCallFrame(const MachineFunction &MF) const; |
| 51 | bool canSimplifyCallFramePseudos(const MachineFunction &MF) const; |
Anton Korobeynikov | 82f5874 | 2010-11-20 15:59:32 +0000 | [diff] [blame] | 52 | int getFrameIndexReference(const MachineFunction &MF, int FI, |
| 53 | unsigned &FrameReg) const; |
| 54 | int ResolveFrameIndexReference(const MachineFunction &MF, int FI, |
| 55 | unsigned &FrameReg, int SPAdj) const; |
| 56 | int getFrameIndexOffset(const MachineFunction &MF, int FI) const; |
| 57 | |
Anton Korobeynikov | 94c5ae0 | 2010-11-27 23:05:25 +0000 | [diff] [blame] | 58 | void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, |
| 59 | RegScavenger *RS) const; |
| 60 | |
Anton Korobeynikov | cd775ce | 2010-11-27 23:05:03 +0000 | [diff] [blame] | 61 | private: |
Anton Korobeynikov | cd775ce | 2010-11-27 23:05:03 +0000 | [diff] [blame] | 62 | void emitPushInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, |
Jim Grosbach | c6f9261 | 2010-12-09 18:31:13 +0000 | [diff] [blame] | 63 | const std::vector<CalleeSavedInfo> &CSI, unsigned StmOpc, |
| 64 | unsigned StrOpc, bool NoGap, |
| 65 | bool(*Func)(unsigned, bool)) const; |
Evan Cheng | 06d65f5 | 2010-12-07 23:08:38 +0000 | [diff] [blame] | 66 | void emitPopInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, |
Jim Grosbach | c6f9261 | 2010-12-09 18:31:13 +0000 | [diff] [blame] | 67 | const std::vector<CalleeSavedInfo> &CSI, unsigned LdmOpc, |
| 68 | unsigned LdrOpc, bool isVarArg, bool NoGap, |
Evan Cheng | 06d65f5 | 2010-12-07 23:08:38 +0000 | [diff] [blame] | 69 | bool(*Func)(unsigned, bool)) const; |
Rafael Espindola | ec46ea3 | 2006-08-16 14:43:33 +0000 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | } // End llvm namespace |
| 73 | |
| 74 | #endif |