xref: /aosp_15_r20/external/llvm/lib/Target/NVPTX/NVPTXRegisterInfo.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===- NVPTXRegisterInfo.h - NVPTX Register Information Impl ----*- C++ -*-===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker // This file contains the NVPTX implementation of the TargetRegisterInfo class.
11*9880d681SAndroid Build Coastguard Worker //
12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
13*9880d681SAndroid Build Coastguard Worker 
14*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXREGISTERINFO_H
15*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_NVPTX_NVPTXREGISTERINFO_H
16*9880d681SAndroid Build Coastguard Worker 
17*9880d681SAndroid Build Coastguard Worker #include "ManagedStringPool.h"
18*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetRegisterInfo.h"
19*9880d681SAndroid Build Coastguard Worker #include <sstream>
20*9880d681SAndroid Build Coastguard Worker 
21*9880d681SAndroid Build Coastguard Worker #define GET_REGINFO_HEADER
22*9880d681SAndroid Build Coastguard Worker #include "NVPTXGenRegisterInfo.inc"
23*9880d681SAndroid Build Coastguard Worker 
24*9880d681SAndroid Build Coastguard Worker namespace llvm {
25*9880d681SAndroid Build Coastguard Worker class NVPTXRegisterInfo : public NVPTXGenRegisterInfo {
26*9880d681SAndroid Build Coastguard Worker private:
27*9880d681SAndroid Build Coastguard Worker   // Hold Strings that can be free'd all together with NVPTXRegisterInfo
28*9880d681SAndroid Build Coastguard Worker   ManagedStringPool ManagedStrPool;
29*9880d681SAndroid Build Coastguard Worker 
30*9880d681SAndroid Build Coastguard Worker public:
31*9880d681SAndroid Build Coastguard Worker   NVPTXRegisterInfo();
32*9880d681SAndroid Build Coastguard Worker 
33*9880d681SAndroid Build Coastguard Worker   //------------------------------------------------------
34*9880d681SAndroid Build Coastguard Worker   // Pure virtual functions from TargetRegisterInfo
35*9880d681SAndroid Build Coastguard Worker   //------------------------------------------------------
36*9880d681SAndroid Build Coastguard Worker 
37*9880d681SAndroid Build Coastguard Worker   // NVPTX callee saved registers
38*9880d681SAndroid Build Coastguard Worker   const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override;
39*9880d681SAndroid Build Coastguard Worker 
40*9880d681SAndroid Build Coastguard Worker   BitVector getReservedRegs(const MachineFunction &MF) const override;
41*9880d681SAndroid Build Coastguard Worker 
42*9880d681SAndroid Build Coastguard Worker   void eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj,
43*9880d681SAndroid Build Coastguard Worker                            unsigned FIOperandNum,
44*9880d681SAndroid Build Coastguard Worker                            RegScavenger *RS = nullptr) const override;
45*9880d681SAndroid Build Coastguard Worker 
46*9880d681SAndroid Build Coastguard Worker   unsigned getFrameRegister(const MachineFunction &MF) const override;
47*9880d681SAndroid Build Coastguard Worker 
getStrPool()48*9880d681SAndroid Build Coastguard Worker   ManagedStringPool *getStrPool() const {
49*9880d681SAndroid Build Coastguard Worker     return const_cast<ManagedStringPool *>(&ManagedStrPool);
50*9880d681SAndroid Build Coastguard Worker   }
51*9880d681SAndroid Build Coastguard Worker 
getName(unsigned RegNo)52*9880d681SAndroid Build Coastguard Worker   const char *getName(unsigned RegNo) const {
53*9880d681SAndroid Build Coastguard Worker     std::stringstream O;
54*9880d681SAndroid Build Coastguard Worker     O << "reg" << RegNo;
55*9880d681SAndroid Build Coastguard Worker     return getStrPool()->getManagedString(O.str().c_str())->c_str();
56*9880d681SAndroid Build Coastguard Worker   }
57*9880d681SAndroid Build Coastguard Worker 
58*9880d681SAndroid Build Coastguard Worker };
59*9880d681SAndroid Build Coastguard Worker 
60*9880d681SAndroid Build Coastguard Worker std::string getNVPTXRegClassName(const TargetRegisterClass *RC);
61*9880d681SAndroid Build Coastguard Worker std::string getNVPTXRegClassStr(const TargetRegisterClass *RC);
62*9880d681SAndroid Build Coastguard Worker 
63*9880d681SAndroid Build Coastguard Worker } // end namespace llvm
64*9880d681SAndroid Build Coastguard Worker 
65*9880d681SAndroid Build Coastguard Worker #endif
66