The BLX instruction is encoded differently than the BL, because why not? In
[oota-llvm.git] / lib / Target / TargetFrameInfo.cpp
1 //===-- TargetFrameInfo.cpp - Implement machine frame interface -*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
13
14 #include "llvm/CodeGen/MachineFrameInfo.h"
15 #include "llvm/CodeGen/MachineFunction.h"
16 #include "llvm/Target/TargetFrameInfo.h"
17 #include "llvm/Target/TargetMachine.h"
18 #include "llvm/Target/TargetRegisterInfo.h"
19
20 #include <cstdlib>
21 using namespace llvm;
22
23 TargetFrameInfo::~TargetFrameInfo() {
24 }
25
26 /// getInitialFrameState - Returns a list of machine moves that are assumed
27 /// on entry to a function.
28 void
29 TargetFrameInfo::getInitialFrameState(std::vector<MachineMove> &Moves) const {
30   // Default is to do nothing.
31 }
32
33 /// getFrameIndexOffset - Returns the displacement from the frame register to
34 /// the stack frame of the specified index. This is the default implementation
35 /// which is overridden for some targets.
36 int TargetFrameInfo::getFrameIndexOffset(const MachineFunction &MF,
37                                          int FI) const {
38   const MachineFrameInfo *MFI = MF.getFrameInfo();
39   return MFI->getObjectOffset(FI) + MFI->getStackSize() -
40     getOffsetOfLocalArea() + MFI->getOffsetAdjustment();
41 }
42
43 int TargetFrameInfo::getFrameIndexReference(const MachineFunction &MF, int FI,
44                                             unsigned &FrameReg) const {
45   const TargetRegisterInfo *RI = MF.getTarget().getRegisterInfo();
46
47   // By default, assume all frame indices are referenced via whatever
48   // getFrameRegister() says. The target can override this if it's doing
49   // something different.
50   FrameReg = RI->getFrameRegister(MF);
51   return getFrameIndexOffset(MF, FI);
52 }