-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang][hlsl] Add tan intrinsic part 1 (#90276)
This change is an implementation of #87367's investigation on supporting IEEE math operations as intrinsics. Which was discussed in this RFC: https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294 If you want an overarching view of how this will all connect see: #90088 Changes: - `clang/docs/LanguageExtensions.rst` - Document the new elementwise tan builtin. - `clang/include/clang/Basic/Builtins.td` - Implement the tan builtin. - `clang/lib/CodeGen/CGBuiltin.cpp` - invoke the tan intrinsic on uses of the builtin - `clang/lib/Headers/hlsl/hlsl_intrinsics.h` - Associate the tan builtin with the equivalent hlsl apis - `clang/lib/Sema/SemaChecking.cpp` - Add generic sema checks as well as HLSL specifc sema checks to the tan builtin - `llvm/include/llvm/IR/Intrinsics.td` - Create the tan intrinsic - `llvm/docs/LangRef.rst` - Document the tan intrinsic
- Loading branch information
Showing
15 changed files
with
236 additions
and
38 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
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,59 @@ | ||
// 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: spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \ | ||
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF | ||
|
||
// CHECK-LABEL: test_tan_half | ||
// NATIVE_HALF: call half @llvm.tan.f16 | ||
// NO_HALF: call float @llvm.tan.f32 | ||
half test_tan_half ( half p0 ) { | ||
return tan ( p0 ); | ||
} | ||
|
||
// CHECK-LABEL: test_tan_half2 | ||
// NATIVE_HALF: call <2 x half> @llvm.tan.v2f16 | ||
// NO_HALF: call <2 x float> @llvm.tan.v2f32 | ||
half2 test_tan_half2 ( half2 p0 ) { | ||
return tan ( p0 ); | ||
} | ||
|
||
// CHECK-LABEL: test_tan_half3 | ||
// NATIVE_HALF: call <3 x half> @llvm.tan.v3f16 | ||
// NO_HALF: call <3 x float> @llvm.tan.v3f32 | ||
half3 test_tan_half3 ( half3 p0 ) { | ||
return tan ( p0 ); | ||
} | ||
|
||
// CHECK-LABEL: test_tan_half4 | ||
// NATIVE_HALF: call <4 x half> @llvm.tan.v4f16 | ||
// NO_HALF: call <4 x float> @llvm.tan.v4f32 | ||
half4 test_tan_half4 ( half4 p0 ) { | ||
return tan ( p0 ); | ||
} | ||
|
||
// CHECK-LABEL: test_tan_float | ||
// CHECK: call float @llvm.tan.f32 | ||
float test_tan_float ( float p0 ) { | ||
return tan ( p0 ); | ||
} | ||
|
||
// CHECK-LABEL: test_tan_float2 | ||
// CHECK: call <2 x float> @llvm.tan.v2f32 | ||
float2 test_tan_float2 ( float2 p0 ) { | ||
return tan ( p0 ); | ||
} | ||
|
||
// CHECK-LABEL: test_tan_float3 | ||
// CHECK: call <3 x float> @llvm.tan.v3f32 | ||
float3 test_tan_float3 ( float3 p0 ) { | ||
return tan ( p0 ); | ||
} | ||
|
||
// CHECK-LABEL: test_tan_float4 | ||
// CHECK: call <4 x float> @llvm.tan.v4f32 | ||
float4 test_tan_float4 ( float4 p0 ) { | ||
return tan ( 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 |
---|---|---|
@@ -1,18 +1,24 @@ | ||
// RUN: %clang_cc1 -triple aarch64 -target-feature +sve \ | ||
// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify | ||
// REQUIRES: aarch64-registered-target | ||
|
||
#include <arm_sve.h> | ||
|
||
|
||
svfloat32_t test_sin_vv_i8mf8(svfloat32_t v) { | ||
|
||
return __builtin_elementwise_sin(v); | ||
// expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
} | ||
|
||
svfloat32_t test_cos_vv_i8mf8(svfloat32_t v) { | ||
|
||
return __builtin_elementwise_cos(v); | ||
// expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
} | ||
// RUN: %clang_cc1 -triple aarch64 -target-feature +sve \ | ||
// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify | ||
// REQUIRES: aarch64-registered-target | ||
|
||
#include <arm_sve.h> | ||
|
||
|
||
svfloat32_t test_sin_vv_i8mf8(svfloat32_t v) { | ||
|
||
return __builtin_elementwise_sin(v); | ||
// expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
} | ||
|
||
svfloat32_t test_cos_vv_i8mf8(svfloat32_t v) { | ||
|
||
return __builtin_elementwise_cos(v); | ||
// expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
} | ||
|
||
svfloat32_t test_tan_vv_i8mf8(svfloat32_t v) { | ||
|
||
return __builtin_elementwise_tan(v); | ||
// expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
} |
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 |
---|---|---|
@@ -1,19 +1,25 @@ | ||
// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ | ||
// RUN: -target-feature +v -target-feature +zfh -target-feature +zvfh \ | ||
// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify | ||
// REQUIRES: riscv-registered-target | ||
|
||
#include <riscv_vector.h> | ||
|
||
|
||
vfloat32mf2_t test_sin_vv_i8mf8(vfloat32mf2_t v) { | ||
|
||
return __builtin_elementwise_sin(v); | ||
// expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
} | ||
|
||
vfloat32mf2_t test_cos_vv_i8mf8(vfloat32mf2_t v) { | ||
|
||
return __builtin_elementwise_cos(v); | ||
// expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
} | ||
// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ | ||
// RUN: -target-feature +v -target-feature +zfh -target-feature +zvfh \ | ||
// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify | ||
// REQUIRES: riscv-registered-target | ||
|
||
#include <riscv_vector.h> | ||
|
||
|
||
vfloat32mf2_t test_sin_vv_i8mf8(vfloat32mf2_t v) { | ||
|
||
return __builtin_elementwise_sin(v); | ||
// expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
} | ||
|
||
vfloat32mf2_t test_cos_vv_i8mf8(vfloat32mf2_t v) { | ||
|
||
return __builtin_elementwise_cos(v); | ||
// expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
} | ||
|
||
vfloat32mf2_t test_tan_vv_i8mf8(vfloat32mf2_t v) { | ||
|
||
return __builtin_elementwise_tan(v); | ||
// expected-error@-1 {{1st argument must be a vector, integer or floating point type}} | ||
} |
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