1 //===- NVPTXRegisterInfo.cpp - NVPTX Register Information -----------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the NVPTX implementation of the TargetRegisterInfo class.
12 //===----------------------------------------------------------------------===//
14 #include "NVPTXRegisterInfo.h"
16 #include "NVPTXSubtarget.h"
17 #include "llvm/ADT/BitVector.h"
18 #include "llvm/CodeGen/MachineFrameInfo.h"
19 #include "llvm/CodeGen/MachineFunction.h"
20 #include "llvm/CodeGen/MachineInstrBuilder.h"
21 #include "llvm/MC/MachineLocation.h"
22 #include "llvm/Target/TargetInstrInfo.h"
26 #define DEBUG_TYPE "nvptx-reg-info"
29 std::string getNVPTXRegClassName(TargetRegisterClass const *RC) {
30 if (RC == &NVPTX::Float32RegsRegClass) {
33 if (RC == &NVPTX::Float64RegsRegClass) {
35 } else if (RC == &NVPTX::Int64RegsRegClass) {
37 } else if (RC == &NVPTX::Int32RegsRegClass) {
39 } else if (RC == &NVPTX::Int16RegsRegClass) {
41 } else if (RC == &NVPTX::Int1RegsRegClass) {
43 } else if (RC == &NVPTX::SpecialRegsRegClass) {
51 std::string getNVPTXRegClassStr(TargetRegisterClass const *RC) {
52 if (RC == &NVPTX::Float32RegsRegClass) {
55 if (RC == &NVPTX::Float64RegsRegClass) {
57 } else if (RC == &NVPTX::Int64RegsRegClass) {
59 } else if (RC == &NVPTX::Int32RegsRegClass) {
61 } else if (RC == &NVPTX::Int16RegsRegClass) {
63 } else if (RC == &NVPTX::Int1RegsRegClass) {
65 } else if (RC == &NVPTX::SpecialRegsRegClass) {
74 NVPTXRegisterInfo::NVPTXRegisterInfo() : NVPTXGenRegisterInfo(0) {}
76 #define GET_REGINFO_TARGET_DESC
77 #include "NVPTXGenRegisterInfo.inc"
79 /// NVPTX Callee Saved Registers
81 NVPTXRegisterInfo::getCalleeSavedRegs(const MachineFunction *) const {
82 static const MCPhysReg CalleeSavedRegs[] = { 0 };
83 return CalleeSavedRegs;
86 BitVector NVPTXRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
87 BitVector Reserved(getNumRegs());
91 void NVPTXRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
92 int SPAdj, unsigned FIOperandNum,
93 RegScavenger *RS) const {
94 assert(SPAdj == 0 && "Unexpected");
96 MachineInstr &MI = *II;
97 int FrameIndex = MI.getOperand(FIOperandNum).getIndex();
99 MachineFunction &MF = *MI.getParent()->getParent();
100 int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex) +
101 MI.getOperand(FIOperandNum + 1).getImm();
103 // Using I0 as the frame pointer
104 MI.getOperand(FIOperandNum).ChangeToRegister(NVPTX::VRFrame, false);
105 MI.getOperand(FIOperandNum + 1).ChangeToImmediate(Offset);
108 unsigned NVPTXRegisterInfo::getFrameRegister(const MachineFunction &MF) const {
109 return NVPTX::VRFrame;