Delete member MipsFunctionInfo::OutArgFIRange and code that accesses it.
[oota-llvm.git] / lib / Target / Mips / Mips16RegisterInfo.cpp
1 //===-- Mips16RegisterInfo.cpp - MIPS16 Register Information -== ----------===//
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 // This file contains the MIPS16 implementation of the TargetRegisterInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "Mips16RegisterInfo.h"
15 #include "Mips.h"
16 #include "MipsAnalyzeImmediate.h"
17 #include "MipsInstrInfo.h"
18 #include "MipsSubtarget.h"
19 #include "MipsMachineFunction.h"
20 #include "llvm/Constants.h"
21 #include "llvm/DebugInfo.h"
22 #include "llvm/Type.h"
23 #include "llvm/Function.h"
24 #include "llvm/CodeGen/ValueTypes.h"
25 #include "llvm/CodeGen/MachineInstrBuilder.h"
26 #include "llvm/CodeGen/MachineFunction.h"
27 #include "llvm/CodeGen/MachineFrameInfo.h"
28 #include "llvm/Target/TargetFrameLowering.h"
29 #include "llvm/Target/TargetMachine.h"
30 #include "llvm/Target/TargetOptions.h"
31 #include "llvm/Target/TargetInstrInfo.h"
32 #include "llvm/Support/CommandLine.h"
33 #include "llvm/Support/Debug.h"
34 #include "llvm/Support/ErrorHandling.h"
35 #include "llvm/Support/raw_ostream.h"
36 #include "llvm/ADT/BitVector.h"
37 #include "llvm/ADT/STLExtras.h"
38
39 using namespace llvm;
40
41 Mips16RegisterInfo::Mips16RegisterInfo(const MipsSubtarget &ST)
42   : MipsRegisterInfo(ST) {}
43
44 // This function eliminate ADJCALLSTACKDOWN,
45 // ADJCALLSTACKUP pseudo instructions
46 void Mips16RegisterInfo::
47 eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
48                               MachineBasicBlock::iterator I) const {
49   // Simply discard ADJCALLSTACKDOWN, ADJCALLSTACKUP instructions.
50   MBB.erase(I);
51 }
52
53 void Mips16RegisterInfo::eliminateFI(MachineBasicBlock::iterator II,
54                                      unsigned OpNo, int FrameIndex,
55                                      uint64_t StackSize,
56                                      int64_t SPOffset) const {
57       MachineInstr &MI = *II;
58       MachineFunction &MF = *MI.getParent()->getParent();
59       MachineFrameInfo *MFI = MF.getFrameInfo();
60
61       const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
62       int MinCSFI = 0;
63       int MaxCSFI = -1;
64
65       if (CSI.size()) {
66         MinCSFI = CSI[0].getFrameIdx();
67         MaxCSFI = CSI[CSI.size() - 1].getFrameIdx();
68       }
69
70       // The following stack frame objects are always
71       // referenced relative to $sp:
72       //  1. Outgoing arguments.
73       //  2. Pointer to dynamically allocated stack space.
74       //  3. Locations for callee-saved registers.
75       // Everything else is referenced relative to whatever register
76       // getFrameRegister() returns.
77       unsigned FrameReg;
78
79       if (FrameIndex >= MinCSFI && FrameIndex <= MaxCSFI)
80         FrameReg = Subtarget.isABI_N64() ? Mips::SP_64 : Mips::SP;
81       else
82         FrameReg = getFrameRegister(MF);
83
84       // Calculate final offset.
85       // - There is no need to change the offset if the frame object
86       //   is one of the
87       //   following: an outgoing argument, pointer to a dynamically allocated
88       //   stack space or a $gp restore location,
89       // - If the frame object is any of the following,
90       //   its offset must be adjusted
91       //   by adding the size of the stack:
92       //   incoming argument, callee-saved register location or local variable.
93       int64_t Offset;
94
95       Offset = SPOffset + (int64_t)StackSize;
96       Offset += MI.getOperand(OpNo + 1).getImm();
97
98       DEBUG(errs() << "Offset     : " << Offset << "\n" << "<--------->\n");
99
100       MI.getOperand(OpNo).ChangeToRegister(FrameReg, false);
101       MI.getOperand(OpNo + 1).ChangeToImmediate(Offset);
102
103
104 }