Jia Liu | 31d157a | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- SPUFrameLowering.h - SPU Frame Lowering stuff ----------*- C++ -*--===// |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +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 |
| 6 | // License. See LICENSE.TXT for details. |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file contains CellSPU frame information that doesn't fit anywhere else |
| 11 | // cleanly... |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Anton Korobeynikov | 3346491 | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 15 | #ifndef SPU_FRAMEINFO_H |
| 16 | #define SPU_FRAMEINFO_H |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 17 | |
Anton Korobeynikov | 3346491 | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 18 | #include "SPURegisterInfo.h" |
Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetFrameLowering.h" |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 20 | #include "llvm/Target/TargetMachine.h" |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 21 | |
| 22 | namespace llvm { |
Anton Korobeynikov | 3346491 | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 23 | class SPUSubtarget; |
| 24 | |
Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 25 | class SPUFrameLowering: public TargetFrameLowering { |
Anton Korobeynikov | 3346491 | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 26 | const SPUSubtarget &Subtarget; |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 27 | std::pair<unsigned, int> LR[1]; |
| 28 | |
| 29 | public: |
Anton Korobeynikov | 16c29b5 | 2011-01-10 12:39:04 +0000 | [diff] [blame] | 30 | SPUFrameLowering(const SPUSubtarget &sti); |
Anton Korobeynikov | 3346491 | 2010-11-15 00:06:54 +0000 | [diff] [blame] | 31 | |
| 32 | //! Determine the frame's layour |
| 33 | void determineFrameLayout(MachineFunction &MF) const; |
| 34 | |
| 35 | /// emitProlog/emitEpilog - These methods insert prolog and epilog code into |
| 36 | /// the function. |
| 37 | void emitPrologue(MachineFunction &MF) const; |
| 38 | void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 39 | |
Anton Korobeynikov | d0c3817 | 2010-11-18 21:19:35 +0000 | [diff] [blame] | 40 | //! Prediate: Target has dedicated frame pointer |
| 41 | bool hasFP(const MachineFunction &MF) const; |
| 42 | |
Anton Korobeynikov | 94c5ae0 | 2010-11-27 23:05:25 +0000 | [diff] [blame] | 43 | void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, |
| 44 | RegScavenger *RS = NULL) const; |
| 45 | |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 46 | //! Return a function's saved spill slots |
| 47 | /*! |
| 48 | For CellSPU, a function's saved spill slots is just the link register. |
| 49 | */ |
| 50 | const std::pair<unsigned, int> * |
| 51 | getCalleeSaveSpillSlots(unsigned &NumEntries) const; |
| 52 | |
| 53 | //! Stack slot size (16 bytes) |
Anton Korobeynikov | 4aefd6b | 2008-02-20 12:07:57 +0000 | [diff] [blame] | 54 | static int stackSlotSize() { |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 55 | return 16; |
| 56 | } |
| 57 | //! Maximum frame offset representable by a signed 10-bit integer |
| 58 | /*! |
| 59 | This is the maximum frame offset that can be expressed as a 10-bit |
| 60 | integer, used in D-form addresses. |
| 61 | */ |
Anton Korobeynikov | 4aefd6b | 2008-02-20 12:07:57 +0000 | [diff] [blame] | 62 | static int maxFrameOffset() { |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 63 | return ((1 << 9) - 1) * stackSlotSize(); |
| 64 | } |
| 65 | //! Minimum frame offset representable by a signed 10-bit integer |
Anton Korobeynikov | 4aefd6b | 2008-02-20 12:07:57 +0000 | [diff] [blame] | 66 | static int minFrameOffset() { |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 67 | return -(1 << 9) * stackSlotSize(); |
| 68 | } |
| 69 | //! Minimum frame size (enough to spill LR + SP) |
Anton Korobeynikov | 4aefd6b | 2008-02-20 12:07:57 +0000 | [diff] [blame] | 70 | static int minStackSize() { |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 71 | return (2 * stackSlotSize()); |
| 72 | } |
Scott Michel | 203b2d6 | 2008-04-30 00:30:08 +0000 | [diff] [blame] | 73 | //! Convert frame index to stack offset |
| 74 | static int FItoStackOffset(int frame_index) { |
| 75 | return frame_index * stackSlotSize(); |
| 76 | } |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 77 | }; |
| 78 | } |
| 79 | |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 80 | #endif |