NVPTXRegisterInfo.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXREGISTERINFO_H
  13. #define LLVM_LIB_TARGET_NVPTX_NVPTXREGISTERINFO_H
  14. #include "llvm/CodeGen/TargetRegisterInfo.h"
  15. #include "llvm/Support/StringSaver.h"
  16. #include <sstream>
  17. #define GET_REGINFO_HEADER
  18. #include "NVPTXGenRegisterInfo.inc"
  19. namespace llvm {
  20. class NVPTXRegisterInfo : public NVPTXGenRegisterInfo {
  21. private:
  22. // Hold Strings that can be free'd all together with NVPTXRegisterInfo
  23. BumpPtrAllocator StrAlloc;
  24. UniqueStringSaver StrPool;
  25. public:
  26. NVPTXRegisterInfo();
  27. //------------------------------------------------------
  28. // Pure virtual functions from TargetRegisterInfo
  29. //------------------------------------------------------
  30. // NVPTX callee saved registers
  31. const MCPhysReg *getCalleeSavedRegs(const MachineFunction *MF) const override;
  32. BitVector getReservedRegs(const MachineFunction &MF) const override;
  33. bool eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj,
  34. unsigned FIOperandNum,
  35. RegScavenger *RS = nullptr) const override;
  36. Register getFrameRegister(const MachineFunction &MF) const override;
  37. Register getFrameLocalRegister(const MachineFunction &MF) const;
  38. UniqueStringSaver &getStrPool() const {
  39. return const_cast<UniqueStringSaver &>(StrPool);
  40. }
  41. const char *getName(unsigned RegNo) const {
  42. std::stringstream O;
  43. O << "reg" << RegNo;
  44. return getStrPool().save(O.str()).data();
  45. }
  46. };
  47. std::string getNVPTXRegClassName(const TargetRegisterClass *RC);
  48. std::string getNVPTXRegClassStr(const TargetRegisterClass *RC);
  49. } // end namespace llvm
  50. #endif