TCE.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. //===--- TCE.h - Declare TCE 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 TCE TargetInfo objects.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H
  13. #define LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H
  14. #include "clang/Basic/TargetInfo.h"
  15. #include "clang/Basic/TargetOptions.h"
  16. #include "llvm/ADT/Triple.h"
  17. #include "llvm/Support/Compiler.h"
  18. namespace clang {
  19. namespace targets {
  20. // llvm and clang cannot be used directly to output native binaries for
  21. // target, but is used to compile C code to llvm bitcode with correct
  22. // type and alignment information.
  23. //
  24. // TCE uses the llvm bitcode as input and uses it for generating customized
  25. // target processor and program binary. TCE co-design environment is
  26. // publicly available in http://tce.cs.tut.fi
  27. static const unsigned TCEOpenCLAddrSpaceMap[] = {
  28. 0, // Default
  29. 3, // opencl_global
  30. 4, // opencl_local
  31. 5, // opencl_constant
  32. 0, // opencl_private
  33. 1, // opencl_global_device
  34. 1, // opencl_global_host
  35. // FIXME: generic has to be added to the target
  36. 0, // opencl_generic
  37. 0, // cuda_device
  38. 0, // cuda_constant
  39. 0, // cuda_shared
  40. 0, // sycl_global
  41. 0, // sycl_global_device
  42. 0, // sycl_global_host
  43. 0, // sycl_local
  44. 0, // sycl_private
  45. 0, // ptr32_sptr
  46. 0, // ptr32_uptr
  47. 0, // ptr64
  48. 0, // hlsl_groupshared
  49. };
  50. class LLVM_LIBRARY_VISIBILITY TCETargetInfo : public TargetInfo {
  51. public:
  52. TCETargetInfo(const llvm::Triple &Triple, const TargetOptions &)
  53. : TargetInfo(Triple) {
  54. TLSSupported = false;
  55. IntWidth = 32;
  56. LongWidth = LongLongWidth = 32;
  57. PointerWidth = 32;
  58. IntAlign = 32;
  59. LongAlign = LongLongAlign = 32;
  60. PointerAlign = 32;
  61. SuitableAlign = 32;
  62. SizeType = UnsignedInt;
  63. IntMaxType = SignedLong;
  64. IntPtrType = SignedInt;
  65. PtrDiffType = SignedInt;
  66. FloatWidth = 32;
  67. FloatAlign = 32;
  68. DoubleWidth = 32;
  69. DoubleAlign = 32;
  70. LongDoubleWidth = 32;
  71. LongDoubleAlign = 32;
  72. FloatFormat = &llvm::APFloat::IEEEsingle();
  73. DoubleFormat = &llvm::APFloat::IEEEsingle();
  74. LongDoubleFormat = &llvm::APFloat::IEEEsingle();
  75. resetDataLayout("E-p:32:32:32-i1:8:8-i8:8:32-"
  76. "i16:16:32-i32:32:32-i64:32:32-"
  77. "f32:32:32-f64:32:32-v64:32:32-"
  78. "v128:32:32-v256:32:32-v512:32:32-"
  79. "v1024:32:32-a0:0:32-n32");
  80. AddrSpaceMap = &TCEOpenCLAddrSpaceMap;
  81. UseAddrSpaceMapMangling = true;
  82. }
  83. void getTargetDefines(const LangOptions &Opts,
  84. MacroBuilder &Builder) const override;
  85. bool hasFeature(StringRef Feature) const override { return Feature == "tce"; }
  86. ArrayRef<Builtin::Info> getTargetBuiltins() const override {
  87. return std::nullopt;
  88. }
  89. const char *getClobbers() const override { return ""; }
  90. BuiltinVaListKind getBuiltinVaListKind() const override {
  91. return TargetInfo::VoidPtrBuiltinVaList;
  92. }
  93. ArrayRef<const char *> getGCCRegNames() const override {
  94. return std::nullopt;
  95. }
  96. bool validateAsmConstraint(const char *&Name,
  97. TargetInfo::ConstraintInfo &info) const override {
  98. return true;
  99. }
  100. ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
  101. return std::nullopt;
  102. }
  103. };
  104. class LLVM_LIBRARY_VISIBILITY TCELETargetInfo : public TCETargetInfo {
  105. public:
  106. TCELETargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
  107. : TCETargetInfo(Triple, Opts) {
  108. BigEndian = false;
  109. resetDataLayout("e-p:32:32:32-i1:8:8-i8:8:32-"
  110. "i16:16:32-i32:32:32-i64:32:32-"
  111. "f32:32:32-f64:32:32-v64:32:32-"
  112. "v128:32:32-v256:32:32-v512:32:32-"
  113. "v1024:32:32-a0:0:32-n32");
  114. }
  115. void getTargetDefines(const LangOptions &Opts,
  116. MacroBuilder &Builder) const override;
  117. };
  118. } // namespace targets
  119. } // namespace clang
  120. #endif // LLVM_CLANG_LIB_BASIC_TARGETS_TCE_H