DirectX.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //===--- DirectX.h - Declare DirectX 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 DXIL TargetInfo objects.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_H
  13. #define LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_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. static const unsigned DirectXAddrSpaceMap[] = {
  21. 0, // Default
  22. 1, // opencl_global
  23. 3, // opencl_local
  24. 2, // opencl_constant
  25. 0, // opencl_private
  26. 4, // opencl_generic
  27. 5, // opencl_global_device
  28. 6, // opencl_global_host
  29. 0, // cuda_device
  30. 0, // cuda_constant
  31. 0, // cuda_shared
  32. // SYCL address space values for this map are dummy
  33. 0, // sycl_global
  34. 0, // sycl_global_device
  35. 0, // sycl_global_host
  36. 0, // sycl_local
  37. 0, // sycl_private
  38. 0, // ptr32_sptr
  39. 0, // ptr32_uptr
  40. 0, // ptr64
  41. 3, // hlsl_groupshared
  42. };
  43. class LLVM_LIBRARY_VISIBILITY DirectXTargetInfo : public TargetInfo {
  44. public:
  45. DirectXTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
  46. : TargetInfo(Triple) {
  47. TLSSupported = false;
  48. VLASupported = false;
  49. LongWidth = LongAlign = 64;
  50. AddrSpaceMap = &DirectXAddrSpaceMap;
  51. UseAddrSpaceMapMangling = true;
  52. HasLegalHalfType = true;
  53. HasFloat16 = true;
  54. NoAsmVariants = true;
  55. PlatformMinVersion = Triple.getOSVersion();
  56. PlatformName = llvm::Triple::getOSTypeName(Triple.getOS());
  57. resetDataLayout("e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:"
  58. "32-f64:64-n8:16:32:64");
  59. TheCXXABI.set(TargetCXXABI::Microsoft);
  60. }
  61. bool useFP16ConversionIntrinsics() const override { return false; }
  62. void getTargetDefines(const LangOptions &Opts,
  63. MacroBuilder &Builder) const override;
  64. bool hasFeature(StringRef Feature) const override {
  65. return Feature == "directx";
  66. }
  67. ArrayRef<Builtin::Info> getTargetBuiltins() const override {
  68. return std::nullopt;
  69. }
  70. const char *getClobbers() const override { return ""; }
  71. ArrayRef<const char *> getGCCRegNames() const override {
  72. return std::nullopt;
  73. }
  74. bool validateAsmConstraint(const char *&Name,
  75. TargetInfo::ConstraintInfo &info) const override {
  76. return true;
  77. }
  78. ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
  79. return std::nullopt;
  80. }
  81. BuiltinVaListKind getBuiltinVaListKind() const override {
  82. return TargetInfo::VoidPtrBuiltinVaList;
  83. }
  84. };
  85. } // namespace targets
  86. } // namespace clang
  87. #endif // LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_H