1 //===----------------------- AMDGPUFrameLowering.cpp ----------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //==-----------------------------------------------------------------------===//
10 // Interface to describe a layout of a stack frame on a AMDIL target machine
12 //===----------------------------------------------------------------------===//
13 #include "AMDGPUFrameLowering.h"
14 #include "AMDGPURegisterInfo.h"
15 #include "R600MachineFunctionInfo.h"
16 #include "llvm/CodeGen/MachineFrameInfo.h"
17 #include "llvm/CodeGen/MachineRegisterInfo.h"
18 #include "llvm/IR/Instructions.h"
21 AMDGPUFrameLowering::AMDGPUFrameLowering(StackDirection D, unsigned StackAl,
22 int LAO, unsigned TransAl)
23 : TargetFrameLowering(D, StackAl, LAO, TransAl) { }
25 AMDGPUFrameLowering::~AMDGPUFrameLowering() { }
27 unsigned AMDGPUFrameLowering::getStackWidth(const MachineFunction &MF) const {
29 // XXX: Hardcoding to 1 for now.
31 // I think the StackWidth should stored as metadata associated with the
32 // MachineFunction. This metadata can either be added by a frontend, or
33 // calculated by a R600 specific LLVM IR pass.
35 // The StackWidth determines how stack objects are laid out in memory.
36 // For a vector stack variable, like: int4 stack[2], the data will be stored
37 // in the following ways depending on the StackWidth.
73 /// \returns The number of registers allocated for \p FI.
74 int AMDGPUFrameLowering::getFrameIndexOffset(const MachineFunction &MF,
76 const MachineFrameInfo *MFI = MF.getFrameInfo();
77 // Start the offset at 2 so we don't overwrite work group information.
78 // XXX: We should only do this when the shader actually uses this
81 int UpperBound = FI == -1 ? MFI->getNumObjects() : FI;
83 for (int i = MFI->getObjectIndexBegin(); i < UpperBound; ++i) {
84 unsigned Size = MFI->getObjectSize(i);
85 Offset += (Size / (getStackWidth(MF) * 4));
90 const TargetFrameLowering::SpillSlot *
91 AMDGPUFrameLowering::getCalleeSavedSpillSlots(unsigned &NumEntries) const {
96 AMDGPUFrameLowering::emitPrologue(MachineFunction &MF) const {
99 AMDGPUFrameLowering::emitEpilogue(MachineFunction &MF,
100 MachineBasicBlock &MBB) const {
104 AMDGPUFrameLowering::hasFP(const MachineFunction &MF) const {