]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/llvm/lib/Target/PTX/PTXRegisterInfo.cpp
Copy head to stable/9 as part of 9.0-RELEASE release cycle.
[FreeBSD/stable/9.git] / contrib / llvm / lib / Target / PTX / PTXRegisterInfo.cpp
1 //===- PTXRegisterInfo.cpp - PTX 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 PTX implementation of the TargetRegisterInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "PTX.h"
15 #include "PTXRegisterInfo.h"
16 #include "llvm/CodeGen/MachineFunction.h"
17 #include "llvm/Support/Debug.h"
18 #include "llvm/Support/raw_ostream.h"
19
20 #define GET_REGINFO_TARGET_DESC
21 #include "PTXGenRegisterInfo.inc"
22
23 using namespace llvm;
24
25 PTXRegisterInfo::PTXRegisterInfo(PTXTargetMachine &TM,
26                                  const TargetInstrInfo &TII)
27   : PTXGenRegisterInfo() {
28 }
29
30 void PTXRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
31                                           int SPAdj,
32                                           RegScavenger *RS) const {
33   unsigned Index;
34   MachineInstr& MI = *II;
35
36   Index = 0;
37   while (!MI.getOperand(Index).isFI()) {
38     ++Index;
39     assert(Index < MI.getNumOperands() &&
40            "Instr does not have a FrameIndex operand!");
41   }
42
43   int FrameIndex = MI.getOperand(Index).getIndex();
44
45   DEBUG(dbgs() << "eliminateFrameIndex: " << MI);
46   DEBUG(dbgs() << "- SPAdj: " << SPAdj << "\n");
47   DEBUG(dbgs() << "- FrameIndex: " << FrameIndex << "\n");
48
49   // This frame index is post stack slot re-use assignments
50   MI.getOperand(Index).ChangeToImmediate(FrameIndex);
51 }