Skip to content

[HLSL] Add __spirv__ macro #132848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/lib/Basic/Targets/SPIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void SPIR64TargetInfo::getTargetDefines(const LangOptions &Opts,
void BaseSPIRVTargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
DefineStd(Builder, "SPIRV", Opts);
DefineStd(Builder, "spirv", Opts);
}

void SPIRVTargetInfo::getTargetDefines(const LangOptions &Opts,
Expand Down
4 changes: 4 additions & 0 deletions clang/test/Preprocessor/predefined-macros-hlsl.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-vertex | FileCheck -match-full-lines %s --check-prefixes=CHECK,VERTEX,NOHALF
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.3-vertex -fnative-half-type | FileCheck -match-full-lines %s --check-prefixes=CHECK,VERTEX,HALF

// RUN: %clang_cc1 %s -E -dM -o - -triple spirv-unknown-vulkan-compute | FileCheck -match-full-lines %s --check-prefixes=CHECK,COMPUTE,NOHALF,SPIRV

// HALF: #define __HLSL_ENABLE_16_BIT 1
// NOHALF-NOT: __HLSL_ENABLE_16_BIT

Expand All @@ -34,6 +36,8 @@
// PIXEL: #define __SHADER_TARGET_STAGE 0
// VERTEX: #define __SHADER_TARGET_STAGE 1

// SPIRV: #define __spirv__ 1

// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library %s -E -dM -o - -x hlsl -std=hlsl2015 2>&1 | FileCheck -match-full-lines %s --check-prefixes=STD2015
// STD2015: warning: support for HLSL language version hlsl2015 is incomplete, recommend using hlsl202x instead
// STD2015: #define __HLSL_VERSION 2015
Expand Down