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 constexpr LangASMap DirectXAddrSpaceMap = {
24 {LangAS::opencl_global, 1}, {LangAS::opencl_local, 3},
25 {LangAS::opencl_constant, 2}, {LangAS::opencl_generic, 4},
26 {LangAS::opencl_global_device, 5}, {LangAS::opencl_global_host, 6},
27 {LangAS::hlsl_groupshared, 3}, {LangAS::hlsl_constant, 2},
28};
29
30class LLVM_LIBRARY_VISIBILITY DirectXTargetInfo : public TargetInfo {
31public:
32 DirectXTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
33 : TargetInfo(Triple) {
34 TLSSupported = false;
35 VLASupported = false;
36 AddrSpaceMap = &DirectXAddrSpaceMap;
37 UseAddrSpaceMapMangling = true;
38 HasFastHalfType = true;
39 HasFloat16 = true;
40 NoAsmVariants = true;
41 VectorsAreElementAligned = true;
42 PlatformMinVersion = Triple.getOSVersion();
43 PlatformName = llvm::Triple::getOSTypeName(Kind: Triple.getOS());
44 resetDataLayout();
45 TheCXXABI.set(TargetCXXABI::GenericItanium);
46 }
47 void getTargetDefines(const LangOptions &Opts,
48 MacroBuilder &Builder) const override;
49
50 bool hasFeature(StringRef Feature) const override {
51 return Feature == "directx";
52 }
53
54 llvm::SmallVector<Builtin::InfosShard> getTargetBuiltins() const override;
55
56 std::string_view getClobbers() const override { return ""; }
57
58 ArrayRef<const char *> getGCCRegNames() const override { return {}; }
59
60 bool validateAsmConstraint(const char *&Name,
61 TargetInfo::ConstraintInfo &info) const override {
62 return true;
63 }
64
65 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
66 return {};
67 }
68
69 BuiltinVaListKind getBuiltinVaListKind() const override {
70 return TargetInfo::VoidPtrBuiltinVaList;
71 }
72
73 void adjust(DiagnosticsEngine &Diags, LangOptions &Opts,
74 const TargetInfo *Aux) override {
75 TargetInfo::adjust(Diags, Opts, Aux);
76 // The static values this addresses do not apply outside of the same thread
77 // This protection is neither available nor needed
78 Opts.ThreadsafeStatics = false;
79 }
80};
81
82} // namespace targets
83} // namespace clang
84
85#endif // LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_H
86