-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HLSL] implement the
isinf
intrinsic (#84927)
This change implements part 1 of 2 for #70095 - `hlsl_intrinsics.h` - add the `isinf` api - `Builtins.td` - add an hlsl builtin for `isinf`. - `CGBuiltin.cpp` add the ir generation for `isinf` intrinsic. - `SemaChecking.cpp` - add a non-math elementwise checks because this is a bool return. - `IntrinsicsDirectX.td` - add an `isinf` intrinsic. `DXIL.td` lowering is left, but changes need to be made there before we can support this case.
- Loading branch information
Showing
7 changed files
with
146 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// 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: %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 | ||
|
||
// CHECK: define noundef i1 @ | ||
// NATIVE_HALF: %dx.isinf = call i1 @llvm.dx.isinf.f16( | ||
// NO_HALF: %dx.isinf = call i1 @llvm.dx.isinf.f32( | ||
// CHECK: ret i1 %dx.isinf | ||
bool test_isinf_half(half p0) { return isinf(p0); } | ||
// CHECK: define noundef <2 x i1> @ | ||
// NATIVE_HALF: %dx.isinf = call <2 x i1> @llvm.dx.isinf.v2f16 | ||
// NO_HALF: %dx.isinf = call <2 x i1> @llvm.dx.isinf.v2f32( | ||
// CHECK: ret <2 x i1> %dx.isinf | ||
bool2 test_isinf_half2(half2 p0) { return isinf(p0); } | ||
// NATIVE_HALF: define noundef <3 x i1> @ | ||
// NATIVE_HALF: %dx.isinf = call <3 x i1> @llvm.dx.isinf.v3f16 | ||
// NO_HALF: %dx.isinf = call <3 x i1> @llvm.dx.isinf.v3f32( | ||
// CHECK: ret <3 x i1> %dx.isinf | ||
bool3 test_isinf_half3(half3 p0) { return isinf(p0); } | ||
// NATIVE_HALF: define noundef <4 x i1> @ | ||
// NATIVE_HALF: %dx.isinf = call <4 x i1> @llvm.dx.isinf.v4f16 | ||
// NO_HALF: %dx.isinf = call <4 x i1> @llvm.dx.isinf.v4f32( | ||
// CHECK: ret <4 x i1> %dx.isinf | ||
bool4 test_isinf_half4(half4 p0) { return isinf(p0); } | ||
|
||
// CHECK: define noundef i1 @ | ||
// CHECK: %dx.isinf = call i1 @llvm.dx.isinf.f32( | ||
// CHECK: ret i1 %dx.isinf | ||
bool test_isinf_float(float p0) { return isinf(p0); } | ||
// CHECK: define noundef <2 x i1> @ | ||
// CHECK: %dx.isinf = call <2 x i1> @llvm.dx.isinf.v2f32 | ||
// CHECK: ret <2 x i1> %dx.isinf | ||
bool2 test_isinf_float2(float2 p0) { return isinf(p0); } | ||
// CHECK: define noundef <3 x i1> @ | ||
// CHECK: %dx.isinf = call <3 x i1> @llvm.dx.isinf.v3f32 | ||
// CHECK: ret <3 x i1> %dx.isinf | ||
bool3 test_isinf_float3(float3 p0) { return isinf(p0); } | ||
// CHECK: define noundef <4 x i1> @ | ||
// CHECK: %dx.isinf = call <4 x i1> @llvm.dx.isinf.v4f32 | ||
// CHECK: ret <4 x i1> %dx.isinf | ||
bool4 test_isinf_float4(float4 p0) { return isinf(p0); } |
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,27 @@ | ||
|
||
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm -disable-llvm-passes -verify -verify-ignore-unexpected | ||
|
||
bool test_too_few_arg() { | ||
return __builtin_hlsl_elementwise_isinf(); | ||
// expected-error@-1 {{too few arguments to function call, expected 1, have 0}} | ||
} | ||
|
||
bool2 test_too_many_arg(float2 p0) { | ||
return __builtin_hlsl_elementwise_isinf(p0, p0); | ||
// expected-error@-1 {{too many arguments to function call, expected 1, have 2}} | ||
} | ||
|
||
bool builtin_bool_to_float_type_promotion(bool p1) { | ||
return __builtin_hlsl_elementwise_isinf(p1); | ||
// expected-error@-1 {passing 'bool' to parameter of incompatible type 'float'}} | ||
} | ||
|
||
bool builtin_isinf_int_to_float_promotion(int p1) { | ||
return __builtin_hlsl_elementwise_isinf(p1); | ||
// expected-error@-1 {{passing 'int' to parameter of incompatible type 'float'}} | ||
} | ||
|
||
bool2 builtin_isinf_int2_to_float2_promotion(int2 p1) { | ||
return __builtin_hlsl_elementwise_isinf(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