LoongArchSubtarget.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //===- LoongArchSubtarget.h - Define Subtarget for the LoongArch -*- 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 declares the LoongArch specific subclass of TargetSubtargetInfo.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H
  13. #define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H
  14. #include "LoongArchFrameLowering.h"
  15. #include "LoongArchISelLowering.h"
  16. #include "LoongArchInstrInfo.h"
  17. #include "LoongArchRegisterInfo.h"
  18. #include "MCTargetDesc/LoongArchBaseInfo.h"
  19. #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
  20. #include "llvm/CodeGen/TargetSubtargetInfo.h"
  21. #include "llvm/IR/DataLayout.h"
  22. #include "llvm/Target/TargetMachine.h"
  23. #define GET_SUBTARGETINFO_HEADER
  24. #include "LoongArchGenSubtargetInfo.inc"
  25. namespace llvm {
  26. class StringRef;
  27. class LoongArchSubtarget : public LoongArchGenSubtargetInfo {
  28. virtual void anchor();
  29. bool HasLA32 = false;
  30. bool HasLA64 = false;
  31. bool HasBasicF = false;
  32. bool HasBasicD = false;
  33. bool HasExtLSX = false;
  34. bool HasExtLASX = false;
  35. bool HasExtLVZ = false;
  36. bool HasExtLBT = false;
  37. bool HasLaGlobalWithPcrel = false;
  38. bool HasLaGlobalWithAbs = false;
  39. bool HasLaLocalWithAbs = false;
  40. unsigned GRLen = 32;
  41. MVT GRLenVT = MVT::i32;
  42. LoongArchABI::ABI TargetABI = LoongArchABI::ABI_Unknown;
  43. LoongArchFrameLowering FrameLowering;
  44. LoongArchInstrInfo InstrInfo;
  45. LoongArchRegisterInfo RegInfo;
  46. LoongArchTargetLowering TLInfo;
  47. SelectionDAGTargetInfo TSInfo;
  48. /// Initializes using the passed in CPU and feature strings so that we can
  49. /// use initializer lists for subtarget initialization.
  50. LoongArchSubtarget &initializeSubtargetDependencies(const Triple &TT,
  51. StringRef CPU,
  52. StringRef TuneCPU,
  53. StringRef FS,
  54. StringRef ABIName);
  55. public:
  56. // Initializes the data members to match that of the specified triple.
  57. LoongArchSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU,
  58. StringRef FS, StringRef ABIName, const TargetMachine &TM);
  59. // Parses features string setting specified subtarget options. The
  60. // definition of this function is auto-generated by tblgen.
  61. void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
  62. const LoongArchFrameLowering *getFrameLowering() const override {
  63. return &FrameLowering;
  64. }
  65. const LoongArchInstrInfo *getInstrInfo() const override { return &InstrInfo; }
  66. const LoongArchRegisterInfo *getRegisterInfo() const override {
  67. return &RegInfo;
  68. }
  69. const LoongArchTargetLowering *getTargetLowering() const override {
  70. return &TLInfo;
  71. }
  72. const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
  73. return &TSInfo;
  74. }
  75. bool is64Bit() const { return HasLA64; }
  76. bool hasBasicF() const { return HasBasicF; }
  77. bool hasBasicD() const { return HasBasicD; }
  78. bool hasExtLSX() const { return HasExtLSX; }
  79. bool hasExtLASX() const { return HasExtLASX; }
  80. bool hasExtLVZ() const { return HasExtLVZ; }
  81. bool hasExtLBT() const { return HasExtLBT; }
  82. bool hasLaGlobalWithPcrel() const { return HasLaGlobalWithPcrel; }
  83. bool hasLaGlobalWithAbs() const { return HasLaGlobalWithAbs; }
  84. bool hasLaLocalWithAbs() const { return HasLaLocalWithAbs; }
  85. MVT getGRLenVT() const { return GRLenVT; }
  86. unsigned getGRLen() const { return GRLen; }
  87. LoongArchABI::ABI getTargetABI() const { return TargetABI; }
  88. };
  89. } // end namespace llvm
  90. #endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H