LLVM API Documentation
00001 //===-- SPUFrameInfo.h - Top-level interface for Cell SPU Target -*- C++ -*-==// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file contains CellSPU frame information that doesn't fit anywhere else 00011 // cleanly... 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #if !defined(SPUFRAMEINFO_H) 00016 00017 #include "llvm/Target/TargetFrameInfo.h" 00018 #include "llvm/Target/TargetMachine.h" 00019 #include "SPURegisterInfo.h" 00020 00021 namespace llvm { 00022 class SPUFrameInfo: public TargetFrameInfo { 00023 const TargetMachine &TM; 00024 std::pair<unsigned, int> LR[1]; 00025 00026 public: 00027 SPUFrameInfo(const TargetMachine &tm); 00028 00029 //! Return a function's saved spill slots 00030 /*! 00031 For CellSPU, a function's saved spill slots is just the link register. 00032 */ 00033 const std::pair<unsigned, int> * 00034 getCalleeSaveSpillSlots(unsigned &NumEntries) const; 00035 00036 //! Stack slot size (16 bytes) 00037 static int stackSlotSize() { 00038 return 16; 00039 } 00040 //! Maximum frame offset representable by a signed 10-bit integer 00041 /*! 00042 This is the maximum frame offset that can be expressed as a 10-bit 00043 integer, used in D-form addresses. 00044 */ 00045 static int maxFrameOffset() { 00046 return ((1 << 9) - 1) * stackSlotSize(); 00047 } 00048 //! Minimum frame offset representable by a signed 10-bit integer 00049 static int minFrameOffset() { 00050 return -(1 << 9) * stackSlotSize(); 00051 } 00052 //! Minimum frame size (enough to spill LR + SP) 00053 static int minStackSize() { 00054 return (2 * stackSlotSize()); 00055 } 00056 //! Frame size required to spill all registers plus frame info 00057 static int fullSpillSize() { 00058 return (SPURegisterInfo::getNumArgRegs() * stackSlotSize()); 00059 } 00060 //! Convert frame index to stack offset 00061 static int FItoStackOffset(int frame_index) { 00062 return frame_index * stackSlotSize(); 00063 } 00064 //! Number of instructions required to overcome hint-for-branch latency 00065 /*! 00066 HBR (hint-for-branch) instructions can be inserted when, for example, 00067 we know that a given function is going to be called, such as printf(), 00068 in the control flow graph. HBRs are only inserted if a sufficient number 00069 of instructions occurs between the HBR and the target. Currently, HBRs 00070 take 6 cycles, ergo, the magic number 6. 00071 */ 00072 static int branchHintPenalty() { 00073 return 6; 00074 } 00075 }; 00076 } 00077 00078 #define SPUFRAMEINFO_H 1 00079 #endif