bob80905 created this revision. bob80905 added reviewers: beanz, pow2clk. Herald added a subscriber: Anastasia. Herald added a project: All. bob80905 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
This change exposes the asin library function for HLSL scalar types, excluding long long doubles. Asin is supported for all scalar, vector, and matrix types. This patch only adds a subset of scalar type support. Long long double support is missing in this patch because that type doesn't exist in HLSL. The full documentation of the HLSL asin function is available here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-asin Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D132612 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/asin.hlsl Index: clang/test/CodeGenHLSL/builtins/asin.hlsl =================================================================== --- /dev/null +++ clang/test/CodeGenHLSL/builtins/asin.hlsl @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -o - | FileCheck %s + +double asin_d(double x) +{ + return asin(x); +} + +// CHECK: define noundef double @"?asin_d@@YANN@Z"( +// CHECK: call noundef double @asin(double noundef %0) #2 + +float asin_f(float x) +{ + return asin(x); +} + +// CHECK: define noundef float @"?asin_f@@YAMM@Z"( +// CHECK: call noundef float @asinf(float noundef %0) Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h =================================================================== --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -12,4 +12,9 @@ __attribute__((clang_builtin_alias(__builtin_hlsl_wave_active_count_bits))) uint WaveActiveCountBits(bool bBit); + +__attribute__((clang_builtin_alias(__builtin_asin))) double asin(double In); +__attribute__((clang_builtin_alias(__builtin_asinf))) float asin(float In); + + #endif //_HLSL_HLSL_INTRINSICS_H_
Index: clang/test/CodeGenHLSL/builtins/asin.hlsl =================================================================== --- /dev/null +++ clang/test/CodeGenHLSL/builtins/asin.hlsl @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -o - | FileCheck %s + +double asin_d(double x) +{ + return asin(x); +} + +// CHECK: define noundef double @"?asin_d@@YANN@Z"( +// CHECK: call noundef double @asin(double noundef %0) #2 + +float asin_f(float x) +{ + return asin(x); +} + +// CHECK: define noundef float @"?asin_f@@YAMM@Z"( +// CHECK: call noundef float @asinf(float noundef %0) Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h =================================================================== --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -12,4 +12,9 @@ __attribute__((clang_builtin_alias(__builtin_hlsl_wave_active_count_bits))) uint WaveActiveCountBits(bool bBit); + +__attribute__((clang_builtin_alias(__builtin_asin))) double asin(double In); +__attribute__((clang_builtin_alias(__builtin_asinf))) float asin(float In); + + #endif //_HLSL_HLSL_INTRINSICS_H_
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits