CSKY.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //===--- CSKY.h - Declare CSKY target feature support -----------*- 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 CSKY TargetInfo objects.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_CSKY_H
  13. #define LLVM_CLANG_LIB_BASIC_TARGETS_CSKY_H
  14. #include "clang/Basic/MacroBuilder.h"
  15. #include "clang/Basic/TargetInfo.h"
  16. #include "llvm/Support/CSKYTargetParser.h"
  17. namespace clang {
  18. namespace targets {
  19. class LLVM_LIBRARY_VISIBILITY CSKYTargetInfo : public TargetInfo {
  20. protected:
  21. std::string ABI;
  22. llvm::CSKY::ArchKind Arch = llvm::CSKY::ArchKind::INVALID;
  23. std::string CPU;
  24. bool HardFloat = false;
  25. bool HardFloatABI = false;
  26. bool FPUV2_SF = false;
  27. bool FPUV2_DF = false;
  28. bool FPUV3_SF = false;
  29. bool FPUV3_DF = false;
  30. bool VDSPV2 = false;
  31. bool VDSPV1 = false;
  32. bool DSPV2 = false;
  33. bool is3E3R1 = false;
  34. public:
  35. CSKYTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
  36. : TargetInfo(Triple) {
  37. NoAsmVariants = true;
  38. LongLongAlign = 32;
  39. SuitableAlign = 32;
  40. DoubleAlign = LongDoubleAlign = 32;
  41. SizeType = UnsignedInt;
  42. PtrDiffType = SignedInt;
  43. IntPtrType = SignedInt;
  44. WCharType = SignedInt;
  45. WIntType = UnsignedInt;
  46. UseZeroLengthBitfieldAlignment = true;
  47. MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 32;
  48. resetDataLayout("e-m:e-S32-p:32:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-"
  49. "v64:32:32-v128:32:32-a:0:32-Fi32-n32");
  50. setABI("abiv2");
  51. }
  52. StringRef getABI() const override { return ABI; }
  53. bool setABI(const std::string &Name) override {
  54. if (Name == "abiv2" || Name == "abiv1") {
  55. ABI = Name;
  56. return true;
  57. }
  58. return false;
  59. }
  60. bool setCPU(const std::string &Name) override;
  61. bool isValidCPUName(StringRef Name) const override;
  62. unsigned getMinGlobalAlign(uint64_t) const override;
  63. ArrayRef<Builtin::Info> getTargetBuiltins() const override;
  64. BuiltinVaListKind getBuiltinVaListKind() const override {
  65. return VoidPtrBuiltinVaList;
  66. }
  67. bool validateAsmConstraint(const char *&Name,
  68. TargetInfo::ConstraintInfo &info) const override;
  69. const char *getClobbers() const override { return ""; }
  70. void getTargetDefines(const LangOptions &Opts,
  71. MacroBuilder &Builder) const override;
  72. bool hasFeature(StringRef Feature) const override;
  73. bool handleTargetFeatures(std::vector<std::string> &Features,
  74. DiagnosticsEngine &Diags) override;
  75. /// Whether target allows to overalign ABI-specified preferred alignment
  76. bool allowsLargerPreferedTypeAlignment() const override { return false; }
  77. bool hasBitIntType() const override { return true; }
  78. protected:
  79. ArrayRef<const char *> getGCCRegNames() const override;
  80. ArrayRef<GCCRegAlias> getGCCRegAliases() const override;
  81. };
  82. } // namespace targets
  83. } // namespace clang
  84. #endif // LLVM_CLANG_LIB_BASIC_TARGETS_CSKY_H