blob: aca6fcded5cd77049cab7a4cb96008ceed173583 [file] [log] [blame]
Scott Michel266bc8f2007-12-04 22:23:35 +00001//===-- SPUFrameInfo.h - Top-level interface for Cell SPU Target -*- C++ -*-==//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Scott Michel266bc8f2007-12-04 22:23:35 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file contains CellSPU frame information that doesn't fit anywhere else
11// cleanly...
12//
13//===----------------------------------------------------------------------===//
14
Anton Korobeynikov33464912010-11-15 00:06:54 +000015#ifndef SPU_FRAMEINFO_H
16#define SPU_FRAMEINFO_H
Scott Michel266bc8f2007-12-04 22:23:35 +000017
Anton Korobeynikov33464912010-11-15 00:06:54 +000018#include "SPURegisterInfo.h"
Scott Michel266bc8f2007-12-04 22:23:35 +000019#include "llvm/Target/TargetFrameInfo.h"
20#include "llvm/Target/TargetMachine.h"
Scott Michel266bc8f2007-12-04 22:23:35 +000021
22namespace llvm {
Anton Korobeynikov33464912010-11-15 00:06:54 +000023 class SPUSubtarget;
24
Scott Michel266bc8f2007-12-04 22:23:35 +000025 class SPUFrameInfo: public TargetFrameInfo {
Anton Korobeynikov33464912010-11-15 00:06:54 +000026 const SPUSubtarget &Subtarget;
Scott Michel266bc8f2007-12-04 22:23:35 +000027 std::pair<unsigned, int> LR[1];
28
29 public:
Anton Korobeynikov33464912010-11-15 00:06:54 +000030 SPUFrameInfo(const SPUSubtarget &sti);
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 Michel266bc8f2007-12-04 22:23:35 +000039
Anton Korobeynikovd0c38172010-11-18 21:19:35 +000040 //! Prediate: Target has dedicated frame pointer
41 bool hasFP(const MachineFunction &MF) const;
42
Anton Korobeynikov94c5ae02010-11-27 23:05:25 +000043 void processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
44 RegScavenger *RS = NULL) const;
45
Anton Korobeynikovd9e33852010-11-18 23:25:52 +000046 //! Perform target-specific stack frame setup.
47 void getInitialFrameState(std::vector<MachineMove> &Moves) const;
48
Scott Michel266bc8f2007-12-04 22:23:35 +000049 //! Return a function's saved spill slots
50 /*!
51 For CellSPU, a function's saved spill slots is just the link register.
52 */
53 const std::pair<unsigned, int> *
54 getCalleeSaveSpillSlots(unsigned &NumEntries) const;
55
56 //! Stack slot size (16 bytes)
Anton Korobeynikov4aefd6b2008-02-20 12:07:57 +000057 static int stackSlotSize() {
Scott Michel266bc8f2007-12-04 22:23:35 +000058 return 16;
59 }
60 //! Maximum frame offset representable by a signed 10-bit integer
61 /*!
62 This is the maximum frame offset that can be expressed as a 10-bit
63 integer, used in D-form addresses.
64 */
Anton Korobeynikov4aefd6b2008-02-20 12:07:57 +000065 static int maxFrameOffset() {
Scott Michel266bc8f2007-12-04 22:23:35 +000066 return ((1 << 9) - 1) * stackSlotSize();
67 }
68 //! Minimum frame offset representable by a signed 10-bit integer
Anton Korobeynikov4aefd6b2008-02-20 12:07:57 +000069 static int minFrameOffset() {
Scott Michel266bc8f2007-12-04 22:23:35 +000070 return -(1 << 9) * stackSlotSize();
71 }
72 //! Minimum frame size (enough to spill LR + SP)
Anton Korobeynikov4aefd6b2008-02-20 12:07:57 +000073 static int minStackSize() {
Scott Michel266bc8f2007-12-04 22:23:35 +000074 return (2 * stackSlotSize());
75 }
Scott Michel203b2d62008-04-30 00:30:08 +000076 //! Convert frame index to stack offset
77 static int FItoStackOffset(int frame_index) {
78 return frame_index * stackSlotSize();
79 }
Scott Michel266bc8f2007-12-04 22:23:35 +000080 //! Number of instructions required to overcome hint-for-branch latency
81 /*!
82 HBR (hint-for-branch) instructions can be inserted when, for example,
83 we know that a given function is going to be called, such as printf(),
84 in the control flow graph. HBRs are only inserted if a sufficient number
85 of instructions occurs between the HBR and the target. Currently, HBRs
86 take 6 cycles, ergo, the magic number 6.
87 */
Anton Korobeynikov4aefd6b2008-02-20 12:07:57 +000088 static int branchHintPenalty() {
Scott Michel266bc8f2007-12-04 22:23:35 +000089 return 6;
90 }
91 };
92}
93
Scott Michel266bc8f2007-12-04 22:23:35 +000094#endif