2fe7b3542b8ac0fba7531383ed7faff010ba6991
[oota-llvm.git] / lib / Target / CellSPU / SPUFrameInfo.h
1 //===-- SPUFrameInfo.h - Top-level interface for Cell SPU Target -*- C++ -*-==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by a team from the Computer Systems Research
6 // Department at The Aerospace Corporation.
7 //
8 // See README.txt for details.
9 //
10 //===----------------------------------------------------------------------===//
11 //
12 // This file contains CellSPU frame information that doesn't fit anywhere else
13 // cleanly...
14 //
15 //===----------------------------------------------------------------------===//
16
17 #if !defined(SPUFRAMEINFO_H)
18
19 #include "llvm/Target/TargetFrameInfo.h"
20 #include "llvm/Target/TargetMachine.h"
21 #include "SPURegisterInfo.h"
22
23 namespace llvm {
24   class SPUFrameInfo: public TargetFrameInfo {
25     const TargetMachine &TM;
26     std::pair<unsigned, int> LR[1];
27
28   public:
29     SPUFrameInfo(const TargetMachine &tm);
30
31     //! Return a function's saved spill slots
32     /*!
33       For CellSPU, a function's saved spill slots is just the link register.
34      */
35     const std::pair<unsigned, int> *
36     getCalleeSaveSpillSlots(unsigned &NumEntries) const;
37
38     //! Stack slot size (16 bytes)
39     static const int stackSlotSize() {
40       return 16;
41     }
42     //! Maximum frame offset representable by a signed 10-bit integer
43     /*!
44       This is the maximum frame offset that can be expressed as a 10-bit
45       integer, used in D-form addresses.
46      */
47     static const int maxFrameOffset() {
48       return ((1 << 9) - 1) * stackSlotSize();
49     }
50     //! Minimum frame offset representable by a signed 10-bit integer
51     static const int minFrameOffset() {
52       return -(1 << 9) * stackSlotSize();
53     }
54     //! Minimum frame size (enough to spill LR + SP)
55     static const int minStackSize() {
56       return (2 * stackSlotSize());
57     }
58     //! Frame size required to spill all registers plus frame info
59     static const int fullSpillSize() {
60       return (SPURegisterInfo::getNumArgRegs() * stackSlotSize());
61     }
62     //! Number of instructions required to overcome hint-for-branch latency
63     /*!
64       HBR (hint-for-branch) instructions can be inserted when, for example,
65       we know that a given function is going to be called, such as printf(),
66       in the control flow graph. HBRs are only inserted if a sufficient number
67       of instructions occurs between the HBR and the target. Currently, HBRs
68       take 6 cycles, ergo, the magic number 6.
69      */
70     static const int branchHintPenalty() {
71       return 6;
72     }
73   };
74 }
75
76 #define SPUFRAMEINFO_H 1
77 #endif