]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - opencl/llvm.git/blob - lib/CodeGen/TargetFrameLoweringImpl.cpp
Cleanup collectChangingRegs
[opencl/llvm.git] / lib / CodeGen / TargetFrameLoweringImpl.cpp
1 //===----- TargetFrameLoweringImpl.cpp - Implement target frame interface --==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Implements the layout of a stack frame on the target machine.
11 //
12 //===----------------------------------------------------------------------===//
14 #include "llvm/Target/TargetFrameLowering.h"
15 #include "llvm/CodeGen/MachineFrameInfo.h"
16 #include "llvm/CodeGen/MachineFunction.h"
17 #include "llvm/Target/TargetMachine.h"
18 #include "llvm/Target/TargetRegisterInfo.h"
19 #include "llvm/Target/TargetSubtargetInfo.h"
20 #include <cstdlib>
21 using namespace llvm;
23 TargetFrameLowering::~TargetFrameLowering() {
24 }
26 /// getFrameIndexOffset - Returns the displacement from the frame register to
27 /// the stack frame of the specified index. This is the default implementation
28 /// which is overridden for some targets.
29 int TargetFrameLowering::getFrameIndexOffset(const MachineFunction &MF,
30                                          int FI) const {
31   const MachineFrameInfo *MFI = MF.getFrameInfo();
32   return MFI->getObjectOffset(FI) + MFI->getStackSize() -
33     getOffsetOfLocalArea() + MFI->getOffsetAdjustment();
34 }
36 int TargetFrameLowering::getFrameIndexReference(const MachineFunction &MF,
37                                              int FI, unsigned &FrameReg) const {
38   const TargetRegisterInfo *RI = MF.getSubtarget().getRegisterInfo();
40   // By default, assume all frame indices are referenced via whatever
41   // getFrameRegister() says. The target can override this if it's doing
42   // something different.
43   FrameReg = RI->getFrameRegister(MF);
44   return getFrameIndexOffset(MF, FI);
45 }