-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[HLSL] Cleanup TargetInfo handling #90694
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -406,6 +406,16 @@ void TargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) { | |
LongDoubleAlign = 64; | ||
} | ||
|
||
// HLSL explicitly defines the sizes and formats of some data types, and we | ||
// need to conform to those regardless of what architecture you are targeting. | ||
if (Opts.HLSL) { | ||
LongWidth = LongAlign = 64; | ||
if (!Opts.NativeHalfType) { | ||
HalfFormat = &llvm::APFloat::IEEEsingle(); | ||
HalfWidth = HalfAlign = 32; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just as a note, we don't actually use this value anywhere in the HLSL code generation paths (yet), which is why it wasn't causing problems that we overrode the format returned by the AST context, but didn't override these values. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a test case we can add for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, and I totally glossed over that this fixes a bug. Without this line |
||
} | ||
} | ||
|
||
if (Opts.OpenCL) { | ||
// OpenCL C requires specific widths for types, irrespective of | ||
// what these normally are for the target. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.4-library -verify %s | ||
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.4-library -verify -fnative-half-type %s | ||
// RUN: %clang_cc1 -triple spirv-linux-vulkan-library -verify %s | ||
// RUN: %clang_cc1 -triple spirv-linux-vulkan-library -verify -fnative-half-type %s | ||
|
||
// expected-no-diagnostics | ||
#ifdef __HLSL_ENABLE_16_BIT | ||
_Static_assert(sizeof(half) == 2, "half is 2 bytes"); | ||
#else | ||
_Static_assert(sizeof(half) == 4, "half is 4 bytes"); | ||
#endif |
Uh oh!
There was an error while loading. Please reload this page.