clang 20.0.0git
HLSLRuntime.h
Go to the documentation of this file.
1//===- HLSLRuntime.h - HLSL Runtime -----------------------------*- 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/// \file
10/// Defines helper utilities for supporting the HLSL runtime environment.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef CLANG_BASIC_HLSLRUNTIME_H
15#define CLANG_BASIC_HLSLRUNTIME_H
16
18#include <cstdint>
19
20namespace clang {
21namespace hlsl {
22
23constexpr ShaderStage
24getStageFromEnvironment(const llvm::Triple::EnvironmentType &E) {
25 uint32_t Pipeline =
26 static_cast<uint32_t>(E) - static_cast<uint32_t>(llvm::Triple::Pixel);
27
28 if (Pipeline > (uint32_t)ShaderStage::Invalid)
30 return static_cast<ShaderStage>(Pipeline);
31}
32
33#define ENUM_COMPARE_ASSERT(Value) \
34 static_assert( \
35 getStageFromEnvironment(llvm::Triple::Value) == ShaderStage::Value, \
36 "Mismatch between llvm::Triple and clang::ShaderStage for " #Value);
37
53
54static_assert(getStageFromEnvironment(llvm::Triple::UnknownEnvironment) ==
56 "Mismatch between llvm::Triple and "
57 "clang::ShaderStage for Invalid");
58static_assert(getStageFromEnvironment(llvm::Triple::MSVC) ==
60 "Mismatch between llvm::Triple and "
61 "clang::ShaderStage for Invalid");
62
63} // namespace hlsl
64} // namespace clang
65
66#endif // CLANG_BASIC_HLSLRUNTIME_H
Expr * E
#define ENUM_COMPARE_ASSERT(Value)
Definition: HLSLRuntime.h:33
Defines the clang::LangOptions interface.
constexpr ShaderStage getStageFromEnvironment(const llvm::Triple::EnvironmentType &E)
Definition: HLSLRuntime.h:24
The JSON file list parser is used to communicate input to InstallAPI.
ShaderStage
Shader programs run in specific pipeline stages.
Definition: LangOptions.h:41