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/CodeGen/MachineInstrBuilder.h"
18 #include "llvm/CodeGen/MachineRegisterInfo.h"
19 #include "llvm/Target/TargetInstrInfo.h"
20 #include "llvm/Support/Debug.h"
21 #include "llvm/Support/raw_ostream.h"
22
23 #define GET_REGINFO_TARGET_DESC
24 #include "PTXGenRegisterInfo.inc"
25
26 using namespace llvm;
27
PTXRegisterInfo(PTXTargetMachine & TM,const TargetInstrInfo & tii)28 PTXRegisterInfo::PTXRegisterInfo(PTXTargetMachine &TM,
29 const TargetInstrInfo &tii)
30 // PTX does not have a return address register.
31 : PTXGenRegisterInfo(0), TII(tii) {
32 }
33
eliminateFrameIndex(MachineBasicBlock::iterator II,int SPAdj,RegScavenger * RS) const34 void PTXRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
35 int SPAdj,
36 RegScavenger *RS) const {
37 unsigned Index;
38 MachineInstr &MI = *II;
39 //MachineBasicBlock &MBB = *MI.getParent();
40 //DebugLoc dl = MI.getDebugLoc();
41 //MachineRegisterInfo &MRI = MI.getParent()->getParent()->getRegInfo();
42
43 //unsigned Reg = MRI.createVirtualRegister(PTX::RegF32RegisterClass);
44
45 llvm_unreachable("FrameIndex should have been previously eliminated!");
46
47 Index = 0;
48 while (!MI.getOperand(Index).isFI()) {
49 ++Index;
50 assert(Index < MI.getNumOperands() &&
51 "Instr does not have a FrameIndex operand!");
52 }
53
54 int FrameIndex = MI.getOperand(Index).getIndex();
55
56 DEBUG(dbgs() << "eliminateFrameIndex: " << MI);
57 DEBUG(dbgs() << "- SPAdj: " << SPAdj << "\n");
58 DEBUG(dbgs() << "- FrameIndex: " << FrameIndex << "\n");
59
60 //MachineInstr* MI2 = BuildMI(MBB, II, dl, TII.get(PTX::LOAD_LOCAL_F32))
61 //.addReg(Reg, RegState::Define).addImm(FrameIndex);
62 //if (MI2->findFirstPredOperandIdx() == -1) {
63 // MI2->addOperand(MachineOperand::CreateReg(PTX::NoRegister, /*IsDef=*/false));
64 // MI2->addOperand(MachineOperand::CreateImm(PTX::PRED_NORMAL));
65 //}
66 //MI2->dump();
67
68 //MachineOperand ESOp = MachineOperand::CreateES("__local__");
69
70 // This frame index is post stack slot re-use assignments
71 //MI.getOperand(Index).ChangeToRegister(Reg, false);
72 MI.getOperand(Index).ChangeToImmediate(FrameIndex);
73 //MI.getOperand(Index) = ESOp;
74 }
75