summaryrefslogtreecommitdiff
path: root/lib/Target/PTX/PTXRegisterInfo.cpp
blob: f32c2b70a3bc07a49ee4c7d77765249f21cdbad2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//===- PTXRegisterInfo.cpp - PTX Register Information ---------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the PTX implementation of the TargetRegisterInfo class.
//
//===----------------------------------------------------------------------===//

#include "PTX.h"
#include "PTXRegisterInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"

#define GET_REGINFO_MC_DESC
#define GET_REGINFO_TARGET_DESC
#include "PTXGenRegisterInfo.inc"

using namespace llvm;

PTXRegisterInfo::PTXRegisterInfo(PTXTargetMachine &TM,
                                 const TargetInstrInfo &TII)
  : PTXGenRegisterInfo() {
}

void PTXRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
                                          int SPAdj,
                                          RegScavenger *RS) const {
  unsigned Index;
  MachineInstr& MI = *II;

  Index = 0;
  while (!MI.getOperand(Index).isFI()) {
    ++Index;
    assert(Index < MI.getNumOperands() &&
           "Instr does not have a FrameIndex operand!");
  }

  int FrameIndex = MI.getOperand(Index).getIndex();

  DEBUG(dbgs() << "eliminateFrameIndex: " << MI);
  DEBUG(dbgs() << "- SPAdj: " << SPAdj << "\n");
  DEBUG(dbgs() << "- FrameIndex: " << FrameIndex << "\n");

  // This frame index is post stack slot re-use assignments
  MI.getOperand(Index).ChangeToImmediate(FrameIndex);
}