-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Add step builtins and step HLSL function to DirectX and SPIR-V backend #106471
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ | ||
// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ | ||
// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ | ||
// RUN: --check-prefixes=CHECK,NATIVE_HALF \ | ||
// RUN: -DFNATTRS=noundef -DTARGET=dx | ||
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ | ||
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ | ||
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF \ | ||
// RUN: -DFNATTRS=noundef -DTARGET=dx | ||
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ | ||
// RUN: spirv-unknown-vulkan-compute %s -fnative-half-type \ | ||
// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s \ | ||
// RUN: --check-prefixes=CHECK,NATIVE_HALF \ | ||
// RUN: -DFNATTRS="spir_func noundef" -DTARGET=spv | ||
// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \ | ||
// RUN: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \ | ||
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF \ | ||
// RUN: -DFNATTRS="spir_func noundef" -DTARGET=spv | ||
|
||
// NATIVE_HALF: define [[FNATTRS]] half @ | ||
// NATIVE_HALF: call half @llvm.[[TARGET]].step.f16(half | ||
// NO_HALF: call float @llvm.[[TARGET]].step.f32(float | ||
// NATIVE_HALF: ret half | ||
// NO_HALF: ret float | ||
half test_step_half(half p0, half p1) | ||
{ | ||
return step(p0, p1); | ||
} | ||
// NATIVE_HALF: define [[FNATTRS]] <2 x half> @ | ||
// NATIVE_HALF: call <2 x half> @llvm.[[TARGET]].step.v2f16(<2 x half> | ||
// NO_HALF: call <2 x float> @llvm.[[TARGET]].step.v2f32(<2 x float> | ||
// NATIVE_HALF: ret <2 x half> %hlsl.step | ||
// NO_HALF: ret <2 x float> %hlsl.step | ||
half2 test_step_half2(half2 p0, half2 p1) | ||
{ | ||
return step(p0, p1); | ||
} | ||
// NATIVE_HALF: define [[FNATTRS]] <3 x half> @ | ||
// NATIVE_HALF: call <3 x half> @llvm.[[TARGET]].step.v3f16(<3 x half> | ||
// NO_HALF: call <3 x float> @llvm.[[TARGET]].step.v3f32(<3 x float> | ||
// NATIVE_HALF: ret <3 x half> %hlsl.step | ||
// NO_HALF: ret <3 x float> %hlsl.step | ||
half3 test_step_half3(half3 p0, half3 p1) | ||
{ | ||
return step(p0, p1); | ||
} | ||
// NATIVE_HALF: define [[FNATTRS]] <4 x half> @ | ||
// NATIVE_HALF: call <4 x half> @llvm.[[TARGET]].step.v4f16(<4 x half> | ||
// NO_HALF: call <4 x float> @llvm.[[TARGET]].step.v4f32(<4 x float> | ||
// NATIVE_HALF: ret <4 x half> %hlsl.step | ||
// NO_HALF: ret <4 x float> %hlsl.step | ||
half4 test_step_half4(half4 p0, half4 p1) | ||
{ | ||
return step(p0, p1); | ||
} | ||
|
||
// CHECK: define [[FNATTRS]] float @ | ||
// CHECK: call float @llvm.[[TARGET]].step.f32(float | ||
// CHECK: ret float | ||
float test_step_float(float p0, float p1) | ||
{ | ||
return step(p0, p1); | ||
} | ||
// CHECK: define [[FNATTRS]] <2 x float> @ | ||
// CHECK: %hlsl.step = call <2 x float> @llvm.[[TARGET]].step.v2f32( | ||
// CHECK: ret <2 x float> %hlsl.step | ||
float2 test_step_float2(float2 p0, float2 p1) | ||
{ | ||
return step(p0, p1); | ||
} | ||
// CHECK: define [[FNATTRS]] <3 x float> @ | ||
// CHECK: %hlsl.step = call <3 x float> @llvm.[[TARGET]].step.v3f32( | ||
// CHECK: ret <3 x float> %hlsl.step | ||
float3 test_step_float3(float3 p0, float3 p1) | ||
{ | ||
return step(p0, p1); | ||
} | ||
// CHECK: define [[FNATTRS]] <4 x float> @ | ||
// CHECK: %hlsl.step = call <4 x float> @llvm.[[TARGET]].step.v4f32( | ||
// CHECK: ret <4 x float> %hlsl.step | ||
float4 test_step_float4(float4 p0, float4 p1) | ||
{ | ||
return step(p0, p1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -disable-llvm-passes -verify -verify-ignore-unexpected | ||
|
||
void test_too_few_arg() | ||
{ | ||
return __builtin_hlsl_step(); | ||
// expected-error@-1 {{too few arguments to function call, expected 2, have 0}} | ||
} | ||
|
||
void test_too_many_arg(float2 p0) | ||
{ | ||
return __builtin_hlsl_step(p0, p0, p0); | ||
// expected-error@-1 {{too many arguments to function call, expected 2, have 3}} | ||
} | ||
|
||
bool builtin_bool_to_float_type_promotion(bool p1) | ||
{ | ||
return __builtin_hlsl_step(p1, p1); | ||
// expected-error@-1 {passing 'bool' to parameter of incompatible type 'float'}} | ||
} | ||
|
||
bool builtin_step_int_to_float_promotion(int p1) | ||
{ | ||
return __builtin_hlsl_step(p1, p1); | ||
// expected-error@-1 {{passing 'int' to parameter of incompatible type 'float'}} | ||
} | ||
|
||
bool2 builtin_step_int2_to_float2_promotion(int2 p1) | ||
{ | ||
return __builtin_hlsl_step(p1, p1); | ||
// expected-error@-1 {{passing 'int2' (aka 'vector<int, 2>') to parameter of incompatible type '__attribute__((__vector_size__(2 * sizeof(float)))) float' (vector of 2 'float' values)}} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: we usually check the arg count first.