LLVM  3.7.0
NVPTXRegisterInfo.cpp
Go to the documentation of this file.
1 //===- NVPTXRegisterInfo.cpp - NVPTX 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 NVPTX implementation of the TargetRegisterInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "NVPTXRegisterInfo.h"
15 #include "NVPTX.h"
16 #include "NVPTXSubtarget.h"
17 #include "llvm/ADT/BitVector.h"
23 
24 using namespace llvm;
25 
26 #define DEBUG_TYPE "nvptx-reg-info"
27 
28 namespace llvm {
29 std::string getNVPTXRegClassName(TargetRegisterClass const *RC) {
30  if (RC == &NVPTX::Float32RegsRegClass) {
31  return ".f32";
32  }
33  if (RC == &NVPTX::Float64RegsRegClass) {
34  return ".f64";
35  } else if (RC == &NVPTX::Int64RegsRegClass) {
36  return ".s64";
37  } else if (RC == &NVPTX::Int32RegsRegClass) {
38  return ".s32";
39  } else if (RC == &NVPTX::Int16RegsRegClass) {
40  return ".s16";
41  } else if (RC == &NVPTX::Int1RegsRegClass) {
42  return ".pred";
43  } else if (RC == &NVPTX::SpecialRegsRegClass) {
44  return "!Special!";
45  } else {
46  return "INTERNAL";
47  }
48  return "";
49 }
50 
51 std::string getNVPTXRegClassStr(TargetRegisterClass const *RC) {
52  if (RC == &NVPTX::Float32RegsRegClass) {
53  return "%f";
54  }
55  if (RC == &NVPTX::Float64RegsRegClass) {
56  return "%fd";
57  } else if (RC == &NVPTX::Int64RegsRegClass) {
58  return "%rd";
59  } else if (RC == &NVPTX::Int32RegsRegClass) {
60  return "%r";
61  } else if (RC == &NVPTX::Int16RegsRegClass) {
62  return "%rs";
63  } else if (RC == &NVPTX::Int1RegsRegClass) {
64  return "%p";
65  } else if (RC == &NVPTX::SpecialRegsRegClass) {
66  return "!Special!";
67  } else {
68  return "INTERNAL";
69  }
70  return "";
71 }
72 }
73 
75 
76 #define GET_REGINFO_TARGET_DESC
77 #include "NVPTXGenRegisterInfo.inc"
78 
79 /// NVPTX Callee Saved Registers
80 const MCPhysReg *
82  static const MCPhysReg CalleeSavedRegs[] = { 0 };
83  return CalleeSavedRegs;
84 }
85 
87  BitVector Reserved(getNumRegs());
88  return Reserved;
89 }
90 
92  int SPAdj, unsigned FIOperandNum,
93  RegScavenger *RS) const {
94  assert(SPAdj == 0 && "Unexpected");
95 
96  MachineInstr &MI = *II;
97  int FrameIndex = MI.getOperand(FIOperandNum).getIndex();
98 
99  MachineFunction &MF = *MI.getParent()->getParent();
100  int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex) +
101  MI.getOperand(FIOperandNum + 1).getImm();
102 
103  // Using I0 as the frame pointer
104  MI.getOperand(FIOperandNum).ChangeToRegister(NVPTX::VRFrame, false);
105  MI.getOperand(FIOperandNum + 1).ChangeToImmediate(Offset);
106 }
107 
109  return NVPTX::VRFrame;
110 }
const MachineFunction * getParent() const
getParent - Return the MachineFunction containing this basic block.
void ChangeToRegister(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
ChangeToRegister - Replace this operand with a new register operand of the specified value...
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
NVPTX Callee Saved Registers.
void eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
int64_t getImm() const
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
const MachineBasicBlock * getParent() const
Definition: MachineInstr.h:120
bundle_iterator< MachineInstr, instr_iterator > iterator
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:273
BitVector getReservedRegs(const MachineFunction &MF) const override
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
MachineFrameInfo * getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Representation of each machine instruction.
Definition: MachineInstr.h:51
unsigned getFrameRegister(const MachineFunction &MF) const override
std::string getNVPTXRegClassStr(TargetRegisterClass const *RC)
std::string getNVPTXRegClassName(TargetRegisterClass const *RC)