X86RegisterBankInfo.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //===- X86RegisterBankInfo ---------------------------------------*- 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. /// \file
  9. /// This file declares the targeting of the RegisterBankInfo class for X86.
  10. /// \todo This should be generated by TableGen.
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_X86_X86REGISTERBANKINFO_H
  13. #define LLVM_LIB_TARGET_X86_X86REGISTERBANKINFO_H
  14. #include "llvm/CodeGen/RegisterBankInfo.h"
  15. #define GET_REGBANK_DECLARATIONS
  16. #include "X86GenRegisterBank.inc"
  17. namespace llvm {
  18. class LLT;
  19. class X86GenRegisterBankInfo : public RegisterBankInfo {
  20. protected:
  21. #define GET_TARGET_REGBANK_CLASS
  22. #include "X86GenRegisterBank.inc"
  23. #define GET_TARGET_REGBANK_INFO_CLASS
  24. #include "X86GenRegisterBankInfo.def"
  25. static RegisterBankInfo::PartialMapping PartMappings[];
  26. static RegisterBankInfo::ValueMapping ValMappings[];
  27. static PartialMappingIdx getPartialMappingIdx(const LLT &Ty, bool isFP);
  28. static const RegisterBankInfo::ValueMapping *
  29. getValueMapping(PartialMappingIdx Idx, unsigned NumOperands);
  30. };
  31. class TargetRegisterInfo;
  32. /// This class provides the information for the target register banks.
  33. class X86RegisterBankInfo final : public X86GenRegisterBankInfo {
  34. private:
  35. /// Get an instruction mapping.
  36. /// \return An InstructionMappings with a statically allocated
  37. /// OperandsMapping.
  38. const InstructionMapping &getSameOperandsMapping(const MachineInstr &MI,
  39. bool isFP) const;
  40. /// Track the bank of each instruction operand(register)
  41. static void
  42. getInstrPartialMappingIdxs(const MachineInstr &MI,
  43. const MachineRegisterInfo &MRI, const bool isFP,
  44. SmallVectorImpl<PartialMappingIdx> &OpRegBankIdx);
  45. /// Construct the instruction ValueMapping from PartialMappingIdxs
  46. /// \return true if mapping succeeded.
  47. static bool
  48. getInstrValueMapping(const MachineInstr &MI,
  49. const SmallVectorImpl<PartialMappingIdx> &OpRegBankIdx,
  50. SmallVectorImpl<const ValueMapping *> &OpdsMapping);
  51. public:
  52. X86RegisterBankInfo(const TargetRegisterInfo &TRI);
  53. const RegisterBank &getRegBankFromRegClass(const TargetRegisterClass &RC,
  54. LLT) const override;
  55. InstructionMappings
  56. getInstrAlternativeMappings(const MachineInstr &MI) const override;
  57. /// See RegisterBankInfo::applyMapping.
  58. void applyMappingImpl(const OperandsMapper &OpdMapper) const override;
  59. const InstructionMapping &
  60. getInstrMapping(const MachineInstr &MI) const override;
  61. };
  62. } // namespace llvm
  63. #endif