114 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8//9// This file declares DXIL TargetInfo objects.10//11//===----------------------------------------------------------------------===//12 13#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_H14#define LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_H15#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, // Default25 1, // opencl_global26 3, // opencl_local27 2, // opencl_constant28 0, // opencl_private29 4, // opencl_generic30 5, // opencl_global_device31 6, // opencl_global_host32 0, // cuda_device33 0, // cuda_constant34 0, // cuda_shared35 // SYCL address space values for this map are dummy36 0, // sycl_global37 0, // sycl_global_device38 0, // sycl_global_host39 0, // sycl_local40 0, // sycl_private41 0, // ptr32_sptr42 0, // ptr32_uptr43 0, // ptr6444 3, // hlsl_groupshared45 2, // hlsl_constant46 0, // hlsl_private47 0, // hlsl_device48 0, // hlsl_input49 // Wasm address space values for this target are dummy values,50 // as it is only enabled for Wasm targets.51 20, // wasm_funcref52};53 54class LLVM_LIBRARY_VISIBILITY DirectXTargetInfo : public TargetInfo {55public:56 DirectXTargetInfo(const llvm::Triple &Triple, const TargetOptions &)57 : TargetInfo(Triple) {58 TLSSupported = false;59 VLASupported = false;60 AddrSpaceMap = &DirectXAddrSpaceMap;61 UseAddrSpaceMapMangling = true;62 HasFastHalfType = true;63 HasFloat16 = true;64 NoAsmVariants = true;65 PlatformMinVersion = Triple.getOSVersion();66 PlatformName = llvm::Triple::getOSTypeName(Triple.getOS());67 // TODO: We need to align vectors on the element size generally, but for now68 // we hard code this for 3-element 32- and 64-bit vectors as a workaround.69 // See https://github.com/llvm/llvm-project/issues/12396870 resetDataLayout("e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:"71 "32-f64:64-n8:16:32:64-v48:16:16-v96:32:32-v192:64:64");72 TheCXXABI.set(TargetCXXABI::GenericItanium);73 }74 bool useFP16ConversionIntrinsics() const override { return false; }75 void getTargetDefines(const LangOptions &Opts,76 MacroBuilder &Builder) const override;77 78 bool hasFeature(StringRef Feature) const override {79 return Feature == "directx";80 }81 82 llvm::SmallVector<Builtin::InfosShard> getTargetBuiltins() const override;83 84 std::string_view getClobbers() const override { return ""; }85 86 ArrayRef<const char *> getGCCRegNames() const override { return {}; }87 88 bool validateAsmConstraint(const char *&Name,89 TargetInfo::ConstraintInfo &info) const override {90 return true;91 }92 93 ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {94 return {};95 }96 97 BuiltinVaListKind getBuiltinVaListKind() const override {98 return TargetInfo::VoidPtrBuiltinVaList;99 }100 101 void adjust(DiagnosticsEngine &Diags, LangOptions &Opts,102 const TargetInfo *Aux) override {103 TargetInfo::adjust(Diags, Opts, Aux);104 // The static values this addresses do not apply outside of the same thread105 // This protection is neither available nor needed106 Opts.ThreadsafeStatics = false;107 }108};109 110} // namespace targets111} // namespace clang112 113#endif // LLVM_CLANG_LIB_BASIC_TARGETS_DIRECTX_H114