the various ConstantExpr::get*Ty methods existed to work with issues around
[llvm/stm8.git] / lib / Target / TargetFrameLowering.cpp
blob19fd581c7dd5cb65deceae56378cc1508463b0a6
1 //===----- TargetFrameLowering.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.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/CodeGen/MachineFrameInfo.h"
15 #include "llvm/CodeGen/MachineFunction.h"
16 #include "llvm/Target/TargetFrameLowering.h"
17 #include "llvm/Target/TargetMachine.h"
18 #include "llvm/Target/TargetRegisterInfo.h"
20 #include <cstdlib>
21 using namespace llvm;
23 TargetFrameLowering::~TargetFrameLowering() {
26 /// getInitialFrameState - Returns a list of machine moves that are assumed
27 /// on entry to a function.
28 void
29 TargetFrameLowering::getInitialFrameState(std::vector<MachineMove> &Moves)
30 const {
31 // Default is to do nothing.
34 /// getFrameIndexOffset - Returns the displacement from the frame register to
35 /// the stack frame of the specified index. This is the default implementation
36 /// which is overridden for some targets.
37 int TargetFrameLowering::getFrameIndexOffset(const MachineFunction &MF,
38 int FI) const {
39 const MachineFrameInfo *MFI = MF.getFrameInfo();
40 return MFI->getObjectOffset(FI) + MFI->getStackSize() -
41 getOffsetOfLocalArea() + MFI->getOffsetAdjustment();
44 int TargetFrameLowering::getFrameIndexReference(const MachineFunction &MF,
45 int FI, unsigned &FrameReg) const {
46 const TargetRegisterInfo *RI = MF.getTarget().getRegisterInfo();
48 // By default, assume all frame indices are referenced via whatever
49 // getFrameRegister() says. The target can override this if it's doing
50 // something different.
51 FrameReg = RI->getFrameRegister(MF);
52 return getFrameIndexOffset(MF, FI);