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
13#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_H
14#define LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_H
15#include "clang/Basic/TargetInfo.h"
16#include "clang/Basic/TargetOptions.h"
17#include "llvm/Support/Compiler.h"
18#include "llvm/TargetParser/Triple.h"
19
20namespace clang {
21namespace targets {
22
23static const unsigned DirectXAddrSpaceMap[] = {
24 0, // Default
25 1, // opencl_global
26 3, // opencl_local
27 2, // opencl_constant
28 0, // opencl_private
29 4, // opencl_generic
30 5, // opencl_global_device
31 6, // opencl_global_host
32 0, // cuda_device
33 0, // cuda_constant
34 0, // cuda_shared
35 // SYCL address space values for this map are dummy
36 0, // sycl_global
37 0, // sycl_global_device
38 0, // sycl_global_host
39 0, // sycl_local
40 0, // sycl_private
41 0, // ptr32_sptr
42 0, // ptr32_uptr
43 0, // ptr64
44 3, // hlsl_groupshared
45 2, // hlsl_constant
46 0, // hlsl_private
47 0, // hlsl_device
48 0, // hlsl_input
49 0, // hlsl_push_constant
50 // Wasm address space values for this target are dummy values,
51 // as it is only enabled for Wasm targets.
52 20, // wasm_funcref
53};
54
55class LLVM_LIBRARY_VISIBILITY DirectXTargetInfo : public TargetInfo {
56public:
57 DirectXTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
58 : TargetInfo(Triple) {
59 TLSSupported = false;
60 VLASupported = false;
61 AddrSpaceMap = &DirectXAddrSpaceMap;
62 UseAddrSpaceMapMangling = true;
63 HasFastHalfType = true;
64 HasFloat16 = true;
65 NoAsmVariants = true;
66 VectorsAreElementAligned = true;
67 PlatformMinVersion = Triple.getOSVersion();
68 PlatformName = llvm::Triple::getOSTypeName(Kind: Triple.getOS());
69 resetDataLayout();
70 TheCXXABI.set(TargetCXXABI::GenericItanium);
71 }
72 bool useFP16ConversionIntrinsics() const override { return false; }
73 void getTargetDefines(const LangOptions &Opts,
74 MacroBuilder &Builder) const override;
75
76 bool hasFeature(StringRef Feature) const override {
77 return Feature == "directx";
78 }
79
80 llvm::SmallVector<Builtin::InfosShard> getTargetBuiltins() const override;
81
82 std::string_view getClobbers() const override { return ""; }
83
84 ArrayRef<const char *> getGCCRegNames() const override { return {}; }
85
86 bool validateAsmConstraint(const char *&Name,
87 TargetInfo::ConstraintInfo &info) const override {
88 return true;
89 }
90
91 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
92 return {};
93 }
94
95 BuiltinVaListKind getBuiltinVaListKind() const override {
96 return TargetInfo::VoidPtrBuiltinVaList;
97 }
98
99 void adjust(DiagnosticsEngine &Diags, LangOptions &Opts,
100 const TargetInfo *Aux) override {
101 TargetInfo::adjust(Diags, Opts, Aux);
102 // The static values this addresses do not apply outside of the same thread
103 // This protection is neither available nor needed
104 Opts.ThreadsafeStatics = false;
105 }
106};
107
108} // namespace targets
109} // namespace clang
110
111#endif // LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_H
112