LLVM 20.0.0git
NVPTXRegisterInfo.h
Go to the documentation of this file.
1//===- NVPTXRegisterInfo.h - NVPTX Register Information Impl ----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the NVPTX implementation of the TargetRegisterInfo class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXREGISTERINFO_H
14#define LLVM_LIB_TARGET_NVPTX_NVPTXREGISTERINFO_H
15
18#include <sstream>
19
20#define GET_REGINFO_HEADER
21#include "NVPTXGenRegisterInfo.inc"
22
23namespace llvm {
25private:
26 // Hold Strings that can be free'd all together with NVPTXRegisterInfo
27 BumpPtrAllocator StrAlloc;
28 UniqueStringSaver StrPool;
29 // State for debug register mapping that can be mutated even through a const
30 // pointer so that we can get the proper dwarf register encoding during ASM
31 // emission.
32 mutable DenseMap<uint64_t, uint64_t> debugRegisterMap;
33
34public:
36
37 //------------------------------------------------------
38 // Pure virtual functions from TargetRegisterInfo
39 //------------------------------------------------------
40
41 // NVPTX callee saved registers
42 const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override;
43
44 BitVector getReservedRegs(const MachineFunction &MF) const override;
45
47 unsigned FIOperandNum,
48 RegScavenger *RS = nullptr) const override;
49
50 Register getFrameRegister(const MachineFunction &MF) const override;
52
54 return const_cast<UniqueStringSaver &>(StrPool);
55 }
56
57 const char *getName(unsigned RegNo) const {
58 std::stringstream O;
59 O << "reg" << RegNo;
60 return getStrPool().save(O.str()).data();
61 }
62
63 // Manage the debugRegisterMap. PTX virtual registers for DebugInfo are
64 // encoded using the names used in the emitted text of the PTX assembly. This
65 // mapping must be managed during assembly emission.
66 //
67 // These are marked const because the interfaces used to access this
68 // RegisterInfo object are all const, but we need to communicate some state
69 // here, because the proper encoding for debug registers is available only
70 // temporarily during ASM emission.
71 void addToDebugRegisterMap(uint64_t preEncodedVirtualRegister,
72 std::string registerName) const;
73 void clearDebugRegisterMap() const;
74 int64_t getDwarfRegNum(MCRegister RegNum, bool isEH) const override;
75};
76
77std::string getNVPTXRegClassName(const TargetRegisterClass *RC);
78std::string getNVPTXRegClassStr(const TargetRegisterClass *RC);
79
80} // end namespace llvm
81
82#endif
IRTranslator LLVM IR MI
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:66
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:33
const char * getName(unsigned RegNo) const
Register getFrameLocalRegister(const MachineFunction &MF) const
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
NVPTX Callee Saved Registers.
bool eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
void addToDebugRegisterMap(uint64_t preEncodedVirtualRegister, std::string registerName) const
BitVector getReservedRegs(const MachineFunction &MF) const override
UniqueStringSaver & getStrPool() const
int64_t getDwarfRegNum(MCRegister RegNum, bool isEH) const override
Register getFrameRegister(const MachineFunction &MF) const override
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:144
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Definition: StringSaver.h:44
StringRef save(const char *S)
Definition: StringSaver.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::string getNVPTXRegClassName(TargetRegisterClass const *RC)
std::string getNVPTXRegClassStr(TargetRegisterClass const *RC)