LLVM API Documentation
00001 //===-- PPCFrameLowering.h - Define frame lowering for PowerPC --*- 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 // 00011 //===----------------------------------------------------------------------===// 00012 00013 #ifndef LLVM_LIB_TARGET_POWERPC_PPCFRAMELOWERING_H 00014 #define LLVM_LIB_TARGET_POWERPC_PPCFRAMELOWERING_H 00015 00016 #include "PPC.h" 00017 #include "llvm/ADT/STLExtras.h" 00018 #include "llvm/Target/TargetFrameLowering.h" 00019 #include "llvm/Target/TargetMachine.h" 00020 00021 namespace llvm { 00022 class PPCSubtarget; 00023 00024 class PPCFrameLowering: public TargetFrameLowering { 00025 const PPCSubtarget &Subtarget; 00026 00027 public: 00028 PPCFrameLowering(const PPCSubtarget &STI); 00029 00030 unsigned determineFrameLayout(MachineFunction &MF, 00031 bool UpdateMF = true, 00032 bool UseEstimate = false) const; 00033 00034 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into 00035 /// the function. 00036 void emitPrologue(MachineFunction &MF) const override; 00037 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override; 00038 00039 bool hasFP(const MachineFunction &MF) const override; 00040 bool needsFP(const MachineFunction &MF) const; 00041 void replaceFPWithRealFP(MachineFunction &MF) const; 00042 00043 void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, 00044 RegScavenger *RS = nullptr) const override; 00045 void processFunctionBeforeFrameFinalized(MachineFunction &MF, 00046 RegScavenger *RS = nullptr) const override; 00047 void addScavengingSpillSlot(MachineFunction &MF, RegScavenger *RS) const; 00048 00049 bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, 00050 MachineBasicBlock::iterator MI, 00051 const std::vector<CalleeSavedInfo> &CSI, 00052 const TargetRegisterInfo *TRI) const override; 00053 00054 void eliminateCallFramePseudoInstr(MachineFunction &MF, 00055 MachineBasicBlock &MBB, 00056 MachineBasicBlock::iterator I) const override; 00057 00058 bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, 00059 MachineBasicBlock::iterator MI, 00060 const std::vector<CalleeSavedInfo> &CSI, 00061 const TargetRegisterInfo *TRI) const override; 00062 00063 /// targetHandlesStackFrameRounding - Returns true if the target is 00064 /// responsible for rounding up the stack frame (probably at emitPrologue 00065 /// time). 00066 bool targetHandlesStackFrameRounding() const override { return true; } 00067 00068 /// getReturnSaveOffset - Return the previous frame offset to save the 00069 /// return address. 00070 static unsigned getReturnSaveOffset(bool isPPC64, bool isDarwinABI) { 00071 if (isDarwinABI) 00072 return isPPC64 ? 16 : 8; 00073 // SVR4 ABI: 00074 return isPPC64 ? 16 : 4; 00075 } 00076 00077 /// getTOCSaveOffset - Return the previous frame offset to save the 00078 /// TOC register -- 64-bit SVR4 ABI only. 00079 static unsigned getTOCSaveOffset(bool isELFv2ABI) { 00080 return isELFv2ABI ? 24 : 40; 00081 } 00082 00083 /// getFramePointerSaveOffset - Return the previous frame offset to save the 00084 /// frame pointer. 00085 static unsigned getFramePointerSaveOffset(bool isPPC64, bool isDarwinABI) { 00086 // For the Darwin ABI: 00087 // We cannot use the TOC save slot (offset +20) in the PowerPC linkage area 00088 // for saving the frame pointer (if needed.) While the published ABI has 00089 // not used this slot since at least MacOSX 10.2, there is older code 00090 // around that does use it, and that needs to continue to work. 00091 if (isDarwinABI) 00092 return isPPC64 ? -8U : -4U; 00093 00094 // SVR4 ABI: First slot in the general register save area. 00095 return isPPC64 ? -8U : -4U; 00096 } 00097 00098 /// getBasePointerSaveOffset - Return the previous frame offset to save the 00099 /// base pointer. 00100 static unsigned getBasePointerSaveOffset(bool isPPC64, 00101 bool isDarwinABI, 00102 bool isPIC) { 00103 if (isDarwinABI) 00104 return isPPC64 ? -16U : -8U; 00105 00106 // SVR4 ABI: First slot in the general register save area. 00107 return isPPC64 ? -16U : isPIC ? -12U : -8U; 00108 } 00109 00110 /// getLinkageSize - Return the size of the PowerPC ABI linkage area. 00111 /// 00112 static unsigned getLinkageSize(bool isPPC64, bool isDarwinABI, 00113 bool isELFv2ABI) { 00114 if (isDarwinABI || isPPC64) 00115 return (isELFv2ABI ? 4 : 6) * (isPPC64 ? 8 : 4); 00116 00117 // SVR4 ABI: 00118 return 8; 00119 } 00120 00121 const SpillSlot * 00122 getCalleeSavedSpillSlots(unsigned &NumEntries) const override; 00123 }; 00124 } // End llvm namespace 00125 00126 #endif