| 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 | |
| 16 | #include "llvm/CodeGen/TargetRegisterInfo.h" |
| 17 | |
| 18 | #define |
| 19 | #include "NVPTXGenRegisterInfo.inc" |
| 20 | |
| 21 | namespace llvm { |
| 22 | class NVPTXRegisterInfo : public NVPTXGenRegisterInfo { |
| 23 | private: |
| 24 | // State for debug register mapping that can be mutated even through a const |
| 25 | // pointer so that we can get the proper dwarf register encoding during ASM |
| 26 | // emission. |
| 27 | mutable DenseMap<Register, uint64_t> DebugRegisterMap; |
| 28 | |
| 29 | public: |
| 30 | NVPTXRegisterInfo(); |
| 31 | |
| 32 | //------------------------------------------------------ |
| 33 | // Pure virtual functions from TargetRegisterInfo |
| 34 | //------------------------------------------------------ |
| 35 | |
| 36 | // NVPTX callee saved registers |
| 37 | const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override; |
| 38 | |
| 39 | BitVector getReservedRegs(const MachineFunction &MF) const override; |
| 40 | |
| 41 | bool eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj, |
| 42 | unsigned FIOperandNum, |
| 43 | RegScavenger *RS = nullptr) const override; |
| 44 | |
| 45 | Register getFrameRegister(const MachineFunction &MF) const override; |
| 46 | Register getFrameLocalRegister(const MachineFunction &MF) const; |
| 47 | |
| 48 | // Manage the DebugRegisterMap. PTX virtual registers for DebugInfo are |
| 49 | // encoded using the names used in the emitted text of the PTX assembly. This |
| 50 | // mapping must be managed during assembly emission. |
| 51 | // |
| 52 | // These are marked const because the interfaces used to access this |
| 53 | // RegisterInfo object are all const, but we need to communicate some state |
| 54 | // here, because the proper encoding for debug registers is available only |
| 55 | // temporarily during ASM emission. |
| 56 | void addToDebugRegisterMap(Register VirtReg, StringRef RegisterName) const; |
| 57 | void clearDebugRegisterMap() const; |
| 58 | int64_t getDwarfRegNum(MCRegister RegNum, bool isEH) const override; |
| 59 | int64_t getDwarfRegNumForVirtReg(Register RegNum, bool isEH) const override; |
| 60 | }; |
| 61 | |
| 62 | } // end namespace llvm |
| 63 | |
| 64 | #endif |
| 65 | |