[PATCH] D158820: [Sema][HLSL] Fix naming of anyhit/closesthit shaders
bob80905 added inline comments. Comment at: clang/test/SemaHLSL/entry_shader.hlsl:1 -// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -x hlsl -hlsl-entry foo -o - %s -DSHADER='"anyHit"' -verify +// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -x hlsl -hlsl-entry foo -o - %s -DSHADER='"mesh"' -verify // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -x hlsl -hlsl-entry foo -o - %s -DSHADER='"compute"' Why was this changed to mesh instead of "anyhit" ? Comment at: clang/test/SemaHLSL/shader_type_attr.hlsl:30 // expected-error@+1 {{'shader' attribute parameters do not match the previous declaration}} +[shader("pixel")] bogner wrote: > bob80905 wrote: > > I don't think we should expect this error, given that there is no previous > > declaration for doubledUp(). Maybe something else like %0 and %1 are > > incompatible attributes? > I don't necessarily disagree, but if we're going to change that I think it > should be in a different change than this one. I'm also curious, why is the change from compute to pixel necessary here? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D158820/new/ https://reviews.llvm.org/D158820 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D158820: [Sema][HLSL] Fix naming of anyhit/closesthit shaders
bob80905 added inline comments. Comment at: clang/test/SemaHLSL/shader_type_attr.hlsl:30 // expected-error@+1 {{'shader' attribute parameters do not match the previous declaration}} +[shader("pixel")] I don't think we should expect this error, given that there is no previous declaration for doubledUp(). Maybe something else like %0 and %1 are incompatible attributes? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D158820/new/ https://reviews.llvm.org/D158820 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D157911: clang: Add __builtin_exp10* and use new llvm.exp10 intrinsic
bob80905 added a comment. Release note for addition of exp10 builtin? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D157911/new/ https://reviews.llvm.org/D157911 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D156737: clang: Add __builtin_elementwise_sqrt
bob80905 added a comment. Shouldn't this new builtin be mentioned in Release Notes? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156737/new/ https://reviews.llvm.org/D156737 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D156178: [HLSL] add pow library function
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGdf5137e984a6: [HLSL] add pow library function (authored by bob80905). Changed prior to commit: https://reviews.llvm.org/D156178?vs=548296&id=548322#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156178/new/ https://reviews.llvm.org/D156178 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/pow.hlsl Index: clang/test/CodeGenHLSL/builtins/pow.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/pow.hlsl @@ -0,0 +1,89 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.pow.f16( +// NO_HALF: define noundef float @"?test_pow_half@@YA$halff@$halff@0@Z"( +// NO_HALF: call float @llvm.pow.f32( +half test_pow_half(half p0, half p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <2 x half> @"?test_pow_half2@@YAT?$__vector@$f16@$01@__clang@@T12@0@Z"( +// CHECK: call <2 x half> @llvm.pow.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x float> @llvm.pow.v2f32( +half2 test_pow_half2(half2 p0, half2 p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <3 x half> @"?test_pow_half3@@YAT?$__vector@$f16@$02@__clang@@T12@0@Z"( +// CHECK: call <3 x half> @llvm.pow.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_pow_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x float> @llvm.pow.v3f32( +half3 test_pow_half3(half3 p0, half3 p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <4 x half> @"?test_pow_half4@@YAT?$__vector@$f16@$03@__clang@@T12@0@Z"( +// CHECK: call <4 x half> @llvm.pow.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_pow_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x float> @llvm.pow.v4f32( +half4 test_pow_half4(half4 p0, half4 p1) +{ +return pow(p0, p1); +} + +// CHECK: define noundef float @"?test_pow_float@@YAMMM@Z"( +// CHECK: call float @llvm.pow.f32( +float test_pow_float(float p0, float p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <2 x float> @"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"( +// CHECK: call <2 x float> @llvm.pow.v2f32 +float2 test_pow_float2(float2 p0, float2 p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <3 x float> @"?test_pow_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"( +// CHECK: call <3 x float> @llvm.pow.v3f32 +float3 test_pow_float3(float3 p0, float3 p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <4 x float> @"?test_pow_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"( +// CHECK: call <4 x float> @llvm.pow.v4f32 +float4 test_pow_float4(float4 p0, float4 p1) +{ +return pow(p0, p1); +} + +// CHECK: define noundef double @"?test_pow_double@@YANNN@Z"( +// CHECK: call double @llvm.pow.f64( +double test_pow_double(double p0, double p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <2 x double> @"?test_pow_double2@@YAT?$__vector@N$01@__clang@@T12@0@Z"( +// CHECK: call <2 x double> @llvm.pow.v2f64 +double2 test_pow_double2(double2 p0, double2 p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <3 x double> @"?test_pow_double3@@YAT?$__vector@N$02@__clang@@T12@0@Z"( +// CHECK: call <3 x double> @llvm.pow.v3f64 +double3 test_pow_double3(double3 p0, double3 p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <4 x double> @"?test_pow_double4@@YAT?$__vector@N$03@__clang@@T12@0@Z"( +// CHECK: call <4 x double> @llvm.pow.v4f64 +double4 test_pow_double4(double4 p0, double4 p1) +{ +return pow(p0, p1); +} Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -532,5 +532,36 @@ uint64_t3 reversebits(uint64_t3); __attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse))) uint64_t4 reversebits(uint64_t4); + +// pow builtins +#ifdef __HLSL_ENABLE_16_BIT +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half pow(half, half); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half2 pow(half2, half2); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half3 pow(half3, half3); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half4 pow(half4, half4); +#endif + +__attribute__((clang_builtin_
[PATCH] D156178: [HLSL] add pow library function
bob80905 updated this revision to Diff 548296. bob80905 added a comment. - clang format pow.hlsl Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156178/new/ https://reviews.llvm.org/D156178 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/pow.hlsl Index: clang/test/CodeGenHLSL/builtins/pow.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/pow.hlsl @@ -0,0 +1,89 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.pow.f16( +// NO_HALF: define noundef float @"?test_pow_half@@YA$halff@$halff@0@Z"( +// NO_HALF: call float @llvm.pow.f32( +half test_pow_half(half p0, half p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <2 x half> @"?test_pow_half2@@YAT?$__vector@$f16@$01@__clang@@T12@0@Z"( +// CHECK: call <2 x half> @llvm.pow.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x float> @llvm.pow.v2f32( +half2 test_pow_half2(half2 p0, half2 p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <3 x half> @"?test_pow_half3@@YAT?$__vector@$f16@$02@__clang@@T12@0@Z"( +// CHECK: call <3 x half> @llvm.pow.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_pow_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x float> @llvm.pow.v3f32( +half3 test_pow_half3(half3 p0, half3 p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <4 x half> @"?test_pow_half4@@YAT?$__vector@$f16@$03@__clang@@T12@0@Z"( +// CHECK: call <4 x half> @llvm.pow.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_pow_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x float> @llvm.pow.v4f32( +half4 test_pow_half4(half4 p0, half4 p1) +{ +return pow(p0, p1); +} + +// CHECK: define noundef float @"?test_pow_float@@YAMMM@Z"( +// CHECK: call float @llvm.pow.f32( +float test_pow_float(float p0, float p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <2 x float> @"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"( +// CHECK: call <2 x float> @llvm.pow.v2f32 +float2 test_pow_float2(float2 p0, float2 p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <3 x float> @"?test_pow_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"( +// CHECK: call <3 x float> @llvm.pow.v3f32 +float3 test_pow_float3(float3 p0, float3 p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <4 x float> @"?test_pow_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"( +// CHECK: call <4 x float> @llvm.pow.v4f32 +float4 test_pow_float4(float4 p0, float4 p1) +{ +return pow(p0, p1); +} + +// CHECK: define noundef double @"?test_pow_double@@YANNN@Z"( +// CHECK: call double @llvm.pow.f64( +double test_pow_double(double p0, double p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <2 x double> @"?test_pow_double2@@YAT?$__vector@N$01@__clang@@T12@0@Z"( +// CHECK: call <2 x double> @llvm.pow.v2f64 +double2 test_pow_double2(double2 p0, double2 p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <3 x double> @"?test_pow_double3@@YAT?$__vector@N$02@__clang@@T12@0@Z"( +// CHECK: call <3 x double> @llvm.pow.v3f64 +double3 test_pow_double3(double3 p0, double3 p1) +{ +return pow(p0, p1); +} +// CHECK: define noundef <4 x double> @"?test_pow_double4@@YAT?$__vector@N$03@__clang@@T12@0@Z"( +// CHECK: call <4 x double> @llvm.pow.v4f64 +double4 test_pow_double4(double4 p0, double4 p1) +{ +return pow(p0, p1); +} Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -476,5 +476,35 @@ __attribute__((clang_builtin_alias(__builtin_elementwise_min))) double4 min(double4, double4); +// pow builtins +#ifdef __HLSL_ENABLE_16_BIT +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half pow(half, half); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half2 pow(half2, half2); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half3 pow(half3, half3); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half4 pow(half4, half4); +#endif + +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) float +pow(float, float); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +float2 pow(float2, float2); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +float3 pow(float3, float3); +_
[PATCH] D156933: [HLSL] Add reversebits library function
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGe545392b1de3: [HLSL] Add reversebits library function (authored by bob80905). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156933/new/ https://reviews.llvm.org/D156933 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/bitreverse.hlsl clang/test/CodeGenHLSL/builtins/reversebits.hlsl Index: clang/test/CodeGenHLSL/builtins/reversebits.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/reversebits.hlsl @@ -0,0 +1,155 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -D__HLSL_ENABLE_16_BIT -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s + +#ifdef __HLSL_ENABLE_16_BIT +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.bitreverse.i16( +int16_t test_bitreverse_short(int16_t p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.bitreverse.v2i16( +int16_t2 test_bitreverse_short2(int16_t2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.bitreverse.v3i16 +int16_t3 test_bitreverse_short3(int16_t3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.bitreverse.v4i16 +int16_t4 test_bitreverse_short4(int16_t4 p0) +{ + return reversebits(p0); +} + +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.bitreverse.i16( +uint16_t test_bitreverse_ushort(uint16_t p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.bitreverse.v2i16 +uint16_t2 test_bitreverse_ushort2(uint16_t2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.bitreverse.v3i16 +uint16_t3 test_bitreverse_ushort3(uint16_t3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.bitreverse.v4i16 +uint16_t4 test_bitreverse_ushort4(uint16_t4 p0) +{ + return reversebits(p0); +} +#endif + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.bitreverse.i32( +int test_bitreverse_int(int p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.bitreverse.v2i32 +int2 test_bitreverse_int2(int2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.bitreverse.v3i32 +int3 test_bitreverse_int3(int3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.bitreverse.v4i32 +int4 test_bitreverse_int4(int4 p0) +{ + return reversebits(p0); +} + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.bitreverse.i32( +int test_bitreverse_uint(uint p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.bitreverse.v2i32 +uint2 test_bitreverse_uint2(uint2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.bitreverse.v3i32 +uint3 test_bitreverse_uint3(uint3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.bitreverse.v4i32 +uint4 test_bitreverse_uint4(uint4 p0) +{ + return reversebits(p0); +} + +// CHECK: define noundef i64 @ +// CHECK: call i64 @llvm.bitreverse.i64( +int64_t test_bitreverse_long(int64_t p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i64> @ +// CHECK: call <2 x i64> @llvm.bitreverse.v2i64 +int64_t2 test_bitreverse_long2(int64_t2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i64> @ +// CHECK: call <3 x i64> @llvm.bitreverse.v3i64 +int64_t3 test_bitreverse_long3(int64_t3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i64> @ +// CHECK: call <4 x i64> @llvm.bitreverse.v4i64 +int64_t4 test_bitreverse_long4(int64_t4 p0) +{ + return reversebits(p0); +} + +// CHECK: define noundef i64 @ +// CHECK: call i64 @llvm.bitreverse.i64( +uint64_t test_bitreverse_long(uint64_t p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i64> @ +// CHECK: call <2 x i64> @llvm.bitreverse.v2i64 +uint64_t2 test_bitreverse_long2(uint64_t2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i64> @ +// CHECK: call <3 x i64> @llvm.bitreverse.v3i64 +uint64_t3 test_bitreverse_long3(uint64_t3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i64> @ +// CHECK: call <4 x i64> @llvm.bitreverse.v4i64 +uint64_t4 test_bitreverse_long4(uint64_t4 p0) +{ + return reversebits(p0); +} Index: clang/test/CodeGenHLSL/builtins/bitreverse.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/bitrev
[PATCH] D156933: [HLSL] Add reversebits library function
bob80905 updated this revision to Diff 546618. bob80905 added a comment. - remove fnative half type from run line Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156933/new/ https://reviews.llvm.org/D156933 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/bitreverse.hlsl clang/test/CodeGenHLSL/builtins/reversebits.hlsl Index: clang/test/CodeGenHLSL/builtins/reversebits.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/reversebits.hlsl @@ -0,0 +1,155 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -D__HLSL_ENABLE_16_BIT -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s + +#ifdef __HLSL_ENABLE_16_BIT +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.bitreverse.i16( +int16_t test_bitreverse_short(int16_t p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.bitreverse.v2i16( +int16_t2 test_bitreverse_short2(int16_t2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.bitreverse.v3i16 +int16_t3 test_bitreverse_short3(int16_t3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.bitreverse.v4i16 +int16_t4 test_bitreverse_short4(int16_t4 p0) +{ + return reversebits(p0); +} + +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.bitreverse.i16( +uint16_t test_bitreverse_ushort(uint16_t p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.bitreverse.v2i16 +uint16_t2 test_bitreverse_ushort2(uint16_t2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.bitreverse.v3i16 +uint16_t3 test_bitreverse_ushort3(uint16_t3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.bitreverse.v4i16 +uint16_t4 test_bitreverse_ushort4(uint16_t4 p0) +{ + return reversebits(p0); +} +#endif + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.bitreverse.i32( +int test_bitreverse_int(int p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.bitreverse.v2i32 +int2 test_bitreverse_int2(int2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.bitreverse.v3i32 +int3 test_bitreverse_int3(int3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.bitreverse.v4i32 +int4 test_bitreverse_int4(int4 p0) +{ + return reversebits(p0); +} + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.bitreverse.i32( +int test_bitreverse_uint(uint p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.bitreverse.v2i32 +uint2 test_bitreverse_uint2(uint2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.bitreverse.v3i32 +uint3 test_bitreverse_uint3(uint3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.bitreverse.v4i32 +uint4 test_bitreverse_uint4(uint4 p0) +{ + return reversebits(p0); +} + +// CHECK: define noundef i64 @ +// CHECK: call i64 @llvm.bitreverse.i64( +int64_t test_bitreverse_long(int64_t p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i64> @ +// CHECK: call <2 x i64> @llvm.bitreverse.v2i64 +int64_t2 test_bitreverse_long2(int64_t2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i64> @ +// CHECK: call <3 x i64> @llvm.bitreverse.v3i64 +int64_t3 test_bitreverse_long3(int64_t3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i64> @ +// CHECK: call <4 x i64> @llvm.bitreverse.v4i64 +int64_t4 test_bitreverse_long4(int64_t4 p0) +{ + return reversebits(p0); +} + +// CHECK: define noundef i64 @ +// CHECK: call i64 @llvm.bitreverse.i64( +uint64_t test_bitreverse_long(uint64_t p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i64> @ +// CHECK: call <2 x i64> @llvm.bitreverse.v2i64 +uint64_t2 test_bitreverse_long2(uint64_t2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i64> @ +// CHECK: call <3 x i64> @llvm.bitreverse.v3i64 +uint64_t3 test_bitreverse_long3(uint64_t3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i64> @ +// CHECK: call <4 x i64> @llvm.bitreverse.v4i64 +uint64_t4 test_bitreverse_long4(uint64_t4 p0) +{ + return reversebits(p0); +} Index: clang/test/CodeGenHLSL/builtins/bitreverse.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/bitreverse.hlsl @@ -0,0 +1,155 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN
[PATCH] D156933: [HLSL] Add reversebits library function
bob80905 updated this revision to Diff 546585. bob80905 added a comment. - rename file, make merge 2 Runs into 1 with enable16bit defined Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156933/new/ https://reviews.llvm.org/D156933 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/reversebits.hlsl Index: clang/test/CodeGenHLSL/builtins/reversebits.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/reversebits.hlsl @@ -0,0 +1,155 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -D__HLSL_ENABLE_16_BIT -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s + +#ifdef __HLSL_ENABLE_16_BIT +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.bitreverse.i16( +int16_t test_bitreverse_short(int16_t p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.bitreverse.v2i16( +int16_t2 test_bitreverse_short2(int16_t2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.bitreverse.v3i16 +int16_t3 test_bitreverse_short3(int16_t3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.bitreverse.v4i16 +int16_t4 test_bitreverse_short4(int16_t4 p0) +{ + return reversebits(p0); +} + +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.bitreverse.i16( +uint16_t test_bitreverse_ushort(uint16_t p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.bitreverse.v2i16 +uint16_t2 test_bitreverse_ushort2(uint16_t2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.bitreverse.v3i16 +uint16_t3 test_bitreverse_ushort3(uint16_t3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.bitreverse.v4i16 +uint16_t4 test_bitreverse_ushort4(uint16_t4 p0) +{ + return reversebits(p0); +} +#endif + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.bitreverse.i32( +int test_bitreverse_int(int p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.bitreverse.v2i32 +int2 test_bitreverse_int2(int2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.bitreverse.v3i32 +int3 test_bitreverse_int3(int3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.bitreverse.v4i32 +int4 test_bitreverse_int4(int4 p0) +{ + return reversebits(p0); +} + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.bitreverse.i32( +int test_bitreverse_uint(uint p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.bitreverse.v2i32 +uint2 test_bitreverse_uint2(uint2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.bitreverse.v3i32 +uint3 test_bitreverse_uint3(uint3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.bitreverse.v4i32 +uint4 test_bitreverse_uint4(uint4 p0) +{ + return reversebits(p0); +} + +// CHECK: define noundef i64 @ +// CHECK: call i64 @llvm.bitreverse.i64( +int64_t test_bitreverse_long(int64_t p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i64> @ +// CHECK: call <2 x i64> @llvm.bitreverse.v2i64 +int64_t2 test_bitreverse_long2(int64_t2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i64> @ +// CHECK: call <3 x i64> @llvm.bitreverse.v3i64 +int64_t3 test_bitreverse_long3(int64_t3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i64> @ +// CHECK: call <4 x i64> @llvm.bitreverse.v4i64 +int64_t4 test_bitreverse_long4(int64_t4 p0) +{ + return reversebits(p0); +} + +// CHECK: define noundef i64 @ +// CHECK: call i64 @llvm.bitreverse.i64( +uint64_t test_bitreverse_long(uint64_t p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i64> @ +// CHECK: call <2 x i64> @llvm.bitreverse.v2i64 +uint64_t2 test_bitreverse_long2(uint64_t2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i64> @ +// CHECK: call <3 x i64> @llvm.bitreverse.v3i64 +uint64_t3 test_bitreverse_long3(uint64_t3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i64> @ +// CHECK: call <4 x i64> @llvm.bitreverse.v4i64 +uint64_t4 test_bitreverse_long4(uint64_t4 p0) +{ + return reversebits(p0); +} Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -476,5 +476,61 @@ __attribute__((clang_builtin_alias(__builtin_elementwise_min))) double4 min(double4, dou
[PATCH] D156933: [HLSL] Add bitreverse library function
bob80905 updated this revision to Diff 546576. bob80905 added a comment. - change builtin name to reversebits Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156933/new/ https://reviews.llvm.org/D156933 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/bitreverse.hlsl Index: clang/test/CodeGenHLSL/builtins/bitreverse.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/bitreverse.hlsl @@ -0,0 +1,166 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +#ifdef __HLSL_ENABLE_16_BIT +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.bitreverse.i16( +// NO_HALF: define noundef i16 @"?test_bitreverse_short@@YAFF@Z"( +// NO_HALF: call i16 @llvm.bitreverse.i16( +int16_t test_bitreverse_short ( int16_t p0 ) { + return reversebits( p0 ); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.bitreverse.v2i16( +// NO_HALF: define noundef <2 x i16> @"?test_bitreverse_short2@@YAT?$__vector@F$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x i16> @llvm.bitreverse.v2i16( +int16_t2 test_bitreverse_short2 ( int16_t2 p0 ) { + return reversebits( p0 ); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.bitreverse.v3i16 +// NO_HALF: define noundef <3 x i16> @"?test_bitreverse_short3@@YAT?$__vector@F$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x i16> @llvm.bitreverse.v3i16( +int16_t3 test_bitreverse_short3 ( int16_t3 p0 ) { + return reversebits( p0 ); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.bitreverse.v4i16 +// NO_HALF: define noundef <4 x i16> @"?test_bitreverse_short4@@YAT?$__vector@F$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x i16> @llvm.bitreverse.v4i16( +int16_t4 test_bitreverse_short4 ( int16_t4 p0 ) { + return reversebits( p0 ); +} + +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.bitreverse.i16( +// NO_HALF: define noundef i16 @"?test_bitreverse_ushort@@YAGG@Z"( +// NO_HALF: call i16 @llvm.bitreverse.i16( +uint16_t test_bitreverse_ushort ( uint16_t p0 ) { + return reversebits( p0 ); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.bitreverse.v2i16 +// NO_HALF: define noundef <2 x i16> @"?test_bitreverse_ushort2@@YAT?$__vector@G$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x i16> @llvm.bitreverse.v2i16( +uint16_t2 test_bitreverse_ushort2 ( uint16_t2 p0 ) { + return reversebits( p0 ); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.bitreverse.v3i16 +// NO_HALF: define noundef <3 x i16> @"?test_bitreverse_ushort3@@YAT?$__vector@G$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x i16> @llvm.bitreverse.v3i16( +uint16_t3 test_bitreverse_ushort3 ( uint16_t3 p0 ) { + return reversebits( p0 ); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.bitreverse.v4i16 +// NO_HALF: define noundef <4 x i16> @"?test_bitreverse_ushort4@@YAT?$__vector@G$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x i16> @llvm.bitreverse.v4i16( +uint16_t4 test_bitreverse_ushort4 ( uint16_t4 p0 ) { + return reversebits( p0 ); +} +#endif + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.bitreverse.i32( +int test_bitreverse_int(int p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.bitreverse.v2i32 +int2 test_bitreverse_int2(int2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.bitreverse.v3i32 +int3 test_bitreverse_int3(int3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.bitreverse.v4i32 +int4 test_bitreverse_int4(int4 p0) +{ + return reversebits(p0); +} + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.bitreverse.i32( +int test_bitreverse_uint(uint p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.bitreverse.v2i32 +uint2 test_bitreverse_uint2(uint2 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.bitreverse.v3i32 +uint3 test_bitreverse_uint3(uint3 p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.bitreverse.v4i32 +uint4 test_bitreverse_uint4(uint4 p0) +{ + return reversebits(p0); +} + +// CHECK: define noundef i64 @ +// CHECK: call i64 @llvm.bitreverse.i64( +int64_t test_bitreverse_long(int64_t p0) +{ + return reversebits(p0); +} +// CHECK: define noundef <2 x i64> @ +// CHECK: call <2 x i64> @llvm.bitreverse.v2i64 +in
[PATCH] D156933: [HLSL] Add bitreverse library function
bob80905 created this revision. 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. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D156933 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/bitreverse.hlsl Index: clang/test/CodeGenHLSL/builtins/bitreverse.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/bitreverse.hlsl @@ -0,0 +1,167 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +#ifdef __HLSL_ENABLE_16_BIT +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.bitreverse.i16( +// NO_HALF: define noundef i16 @"?test_bitreverse_short@@YAFF@Z"( +// NO_HALF: call i16 @llvm.bitreverse.i16( +int16_t test_bitreverse_short ( int16_t p0 ) { + return bitreverse ( p0 ); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.bitreverse.v2i16( +// NO_HALF: define noundef <2 x i16> @"?test_bitreverse_short2@@YAT?$__vector@F$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x i16> @llvm.bitreverse.v2i16( +int16_t2 test_bitreverse_short2 ( int16_t2 p0 ) { + return bitreverse ( p0 ); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.bitreverse.v3i16 +// NO_HALF: define noundef <3 x i16> @"?test_bitreverse_short3@@YAT?$__vector@F$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x i16> @llvm.bitreverse.v3i16( +int16_t3 test_bitreverse_short3 ( int16_t3 p0 ) { + return bitreverse ( p0 ); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.bitreverse.v4i16 +// NO_HALF: define noundef <4 x i16> @"?test_bitreverse_short4@@YAT?$__vector@F$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x i16> @llvm.bitreverse.v4i16( +int16_t4 test_bitreverse_short4 ( int16_t4 p0 ) { + return bitreverse ( p0 ); +} + +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.bitreverse.i16( +// NO_HALF: define noundef i16 @"?test_bitreverse_ushort@@YAGG@Z"( +// NO_HALF: call i16 @llvm.bitreverse.i16( +uint16_t test_bitreverse_ushort ( uint16_t p0 ) { + return bitreverse ( p0 ); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.bitreverse.v2i16 +// NO_HALF: define noundef <2 x i16> @"?test_bitreverse_ushort2@@YAT?$__vector@G$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x i16> @llvm.bitreverse.v2i16( +uint16_t2 test_bitreverse_ushort2 ( uint16_t2 p0 ) { + return bitreverse ( p0 ); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.bitreverse.v3i16 +// NO_HALF: define noundef <3 x i16> @"?test_bitreverse_ushort3@@YAT?$__vector@G$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x i16> @llvm.bitreverse.v3i16( +uint16_t3 test_bitreverse_ushort3 ( uint16_t3 p0 ) { + return bitreverse ( p0 ); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.bitreverse.v4i16 +// NO_HALF: define noundef <4 x i16> @"?test_bitreverse_ushort4@@YAT?$__vector@G$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x i16> @llvm.bitreverse.v4i16( +uint16_t4 test_bitreverse_ushort4 ( uint16_t4 p0 ) { + return bitreverse ( p0 ); +} +#endif + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.bitreverse.i32( +int test_bitreverse_int(int p0) +{ + return bitreverse(p0); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.bitreverse.v2i32 +int2 test_bitreverse_int2(int2 p0) +{ + return bitreverse(p0); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.bitreverse.v3i32 +int3 test_bitreverse_int3(int3 p0) +{ + return bitreverse(p0); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.bitreverse.v4i32 +int4 test_bitreverse_int4(int4 p0) +{ + return bitreverse(p0); +} + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.bitreverse.i32( +int test_bitreverse_uint(uint p0) +{ + return bitreverse(p0); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.bitreverse.v2i32 +uint2 test_bitreverse_uint2(uint2 p0) +{ + return bitreverse(p0); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.bitreverse.v3i32 +uint3 test_bitreverse_uint3(uint3 p0) +{ + return bitreverse(p0); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.bitreverse.v4i32 +uint4 test_bitreverse_uint4(uint4 p0) +{ + return bitreverse(p0); +} + +// CHECK: define noundef i64 @ +// CHECK: call i64 @llvm.bitreverse.i64( +int64_t test_bitreverse_long(int64_t p0) +{ + return bitreverse(p0); +} +// CHECK: define noundef <2 x i64> @ +// CHECK: call <2 x i64>
[PATCH] D156737: clang: Add __builtin_elementwise_sqrt
bob80905 added a comment. I think you need to mention this new builtin in clang/docs/ReleaseNotes.rst. Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2548 +case Builtin::BI__builtin_sqrtf128: +case Builtin::BI__builtin_elementwise_sqrt: { llvm::Value *Call = emitUnaryMaybeConstrainedFPBuiltin( Nit: I think despite this code working, it should be moved to be grouped with the other elementwise builtins at around line 3240. Consider BI__builtin_log at around 2436 and the other log builtins, the bultin_elementwise_log builtin is not in that group since it's with the other elementwise builtins. Writing this case here would make an inconsistency with the placement of the other elementwise builtins. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156737/new/ https://reviews.llvm.org/D156737 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D156357: clang: Add elementwise bitreverse builtin
This revision was automatically updated to reflect the committed changes. Closed by commit rG57f879cdd4c6: clang: Add elementwise bitreverse builtin (authored by bob80905). Changed prior to commit: https://reviews.llvm.org/D156357?vs=545251&id=545741#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156357/new/ https://reviews.llvm.org/D156357 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/builtins-elementwise-math.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -206,3 +206,10 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_bitreverse() { + const int a = 2; + int b = 1; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -269,6 +269,27 @@ // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}} } +void test_builtin_elementwise_bitreverse(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_ceil(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_bitreverse(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_bitreverse(f); + // expected-error@-1 {{1st argument must be a vector of integers (was 'float')}} + + i = __builtin_elementwise_bitreverse(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_bitreverse(d); + // expected-error@-1 {{1st argument must be a vector of integers (was 'double')}} + + v = __builtin_elementwise_bitreverse(v); + // expected-error@-1 {{1st argument must be a vector of integers (was 'float4' (vector of 4 'float' values))}} +} + void test_builtin_elementwise_ceil(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_ceil(f); Index: clang/test/CodeGen/builtins-elementwise-math.c === --- clang/test/CodeGen/builtins-elementwise-math.c +++ clang/test/CodeGen/builtins-elementwise-math.c @@ -323,6 +323,42 @@ int_as_one = __builtin_elementwise_min(int_as_one, b); } +void test_builtin_elementwise_bitreverse(si8 vi1, si8 vi2, + long long int i1, long long int i2, short si, + _BitInt(31) bi1, _BitInt(31) bi2) { + + + // CHECK: [[I1:%.+]] = load i64, ptr %i1.addr, align 8 + // CHECK-NEXT: call i64 @llvm.bitreverse.i64(i64 [[I1]]) + i2 = __builtin_elementwise_bitreverse(i1); + + // CHECK: [[VI1:%.+]] = load <8 x i16>, ptr %vi1.addr, align 16 + // CHECK-NEXT: call <8 x i16> @llvm.bitreverse.v8i16(<8 x i16> [[VI1]]) + vi2 = __builtin_elementwise_bitreverse(vi1); + + // CHECK: [[CVI2:%.+]] = load <8 x i16>, ptr %cvi2, align 16 + // CHECK-NEXT: call <8 x i16> @llvm.bitreverse.v8i16(<8 x i16> [[CVI2]]) + const si8 cvi2 = vi2; + vi2 = __builtin_elementwise_bitreverse(cvi2); + + // CHECK: [[BI1:%.+]] = load i31, ptr %bi1.addr, align 4 + // CHECK-NEXT: call i31 @llvm.bitreverse.i31(i31 [[BI1]]) + bi2 = __builtin_elementwise_bitreverse(bi1); + + // CHECK: [[IA1:%.+]] = load i32, ptr addrspace(1) @int_as_one, align 4 + // CHECK-NEXT: call i32 @llvm.bitreverse.i32(i32 [[IA1]]) + b = __builtin_elementwise_bitreverse(int_as_one); + + // CHECK: call i32 @llvm.bitreverse.i32(i32 -10) + b = __builtin_elementwise_bitreverse(-10); + + // CHECK: [[SI:%.+]] = load i16, ptr %si.addr, align 2 + // CHECK-NEXT: [[SI_EXT:%.+]] = sext i16 [[SI]] to i32 + // CHECK-NEXT: [[RES:%.+]] = call i32 @llvm.bitreverse.i32(i32 [[SI_EXT]]) + // CHECK-NEXT: = trunc i32 [[RES]] to i16 + si = __builtin_elementwise_bitreverse(si); +} + void test_builtin_elementwise_ceil(float f1, float f2, double d1, double d2, float4 vf1, float4 vf2) { // CHECK-LABEL: define void @test_builtin_elementwise_ceil( Index: clang/lib/Sema/SemaChecking.cpp === --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -2700,6 +2700,26 @@ if (SemaBuiltinEleme
[PATCH] D156357: clang: Add elementwise bitreverse builtin
bob80905 added inline comments. Comment at: clang/docs/LanguageExtensions.rst:634 the most negative integer remains the most negative integer - T __builtin_elementwise_fma(T x, T y, T z) fused multiply add, (x * y) + z. floating point types + T __builtin_elementwise_fma(T x, T y, T z) fused multiply add, (x * y) + z. floating point types T __builtin_elementwise_ceil(T x) return the smallest integral value greater than or equal to xfloating point types arsenm wrote: > Unrelated but I noticed a couple of the elementwise builtins are missing from > this list if you're fixing up the docs for them. Can't remember which off the > top of my head Are you sure? I double checked CGBuiltin.cpp and Builtins.def for all "builtin_elementwise*"'s, there's only the 24 listed here. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156357/new/ https://reviews.llvm.org/D156357 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D156357: clang: Add elementwise bitreverse builtin
bob80905 updated this revision to Diff 545251. bob80905 added a comment. - add float4 test Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156357/new/ https://reviews.llvm.org/D156357 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/builtins-elementwise-math.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -206,3 +206,10 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_bitreverse() { + const int a = 2; + int b = 1; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -269,6 +269,27 @@ // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}} } +void test_builtin_elementwise_bitreverse(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_ceil(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_bitreverse(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_bitreverse(f); + // expected-error@-1 {{1st argument must be a vector of integers (was 'float')}} + + i = __builtin_elementwise_bitreverse(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_bitreverse(d); + // expected-error@-1 {{1st argument must be a vector of integers (was 'double')}} + + v = __builtin_elementwise_bitreverse(v); + // expected-error@-1 {{1st argument must be a vector of integers (was 'float4' (vector of 4 'float' values))}} +} + void test_builtin_elementwise_ceil(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_ceil(f); Index: clang/test/CodeGen/builtins-elementwise-math.c === --- clang/test/CodeGen/builtins-elementwise-math.c +++ clang/test/CodeGen/builtins-elementwise-math.c @@ -323,6 +323,42 @@ int_as_one = __builtin_elementwise_min(int_as_one, b); } +void test_builtin_elementwise_bitreverse(si8 vi1, si8 vi2, + long long int i1, long long int i2, short si, + _BitInt(31) bi1, _BitInt(31) bi2) { + + + // CHECK: [[I1:%.+]] = load i64, ptr %i1.addr, align 8 + // CHECK-NEXT: call i64 @llvm.bitreverse.i64(i64 [[I1]]) + i2 = __builtin_elementwise_bitreverse(i1); + + // CHECK: [[VI1:%.+]] = load <8 x i16>, ptr %vi1.addr, align 16 + // CHECK-NEXT: call <8 x i16> @llvm.bitreverse.v8i16(<8 x i16> [[VI1]]) + vi2 = __builtin_elementwise_bitreverse(vi1); + + // CHECK: [[CVI2:%.+]] = load <8 x i16>, ptr %cvi2, align 16 + // CHECK-NEXT: call <8 x i16> @llvm.bitreverse.v8i16(<8 x i16> [[CVI2]]) + const si8 cvi2 = vi2; + vi2 = __builtin_elementwise_bitreverse(cvi2); + + // CHECK: [[BI1:%.+]] = load i31, ptr %bi1.addr, align 4 + // CHECK-NEXT: call i31 @llvm.bitreverse.i31(i31 [[BI1]]) + bi2 = __builtin_elementwise_bitreverse(bi1); + + // CHECK: [[IA1:%.+]] = load i32, ptr addrspace(1) @int_as_one, align 4 + // CHECK-NEXT: call i32 @llvm.bitreverse.i32(i32 [[IA1]]) + b = __builtin_elementwise_bitreverse(int_as_one); + + // CHECK: call i32 @llvm.bitreverse.i32(i32 -10) + b = __builtin_elementwise_bitreverse(-10); + + // CHECK: [[SI:%.+]] = load i16, ptr %si.addr, align 2 + // CHECK-NEXT: [[SI_EXT:%.+]] = sext i16 [[SI]] to i32 + // CHECK-NEXT: [[RES:%.+]] = call i32 @llvm.bitreverse.i32(i32 [[SI_EXT]]) + // CHECK-NEXT: = trunc i32 [[RES]] to i16 + si = __builtin_elementwise_bitreverse(si); +} + void test_builtin_elementwise_ceil(float f1, float f2, double d1, double d2, float4 vf1, float4 vf2) { // CHECK-LABEL: define void @test_builtin_elementwise_ceil( Index: clang/lib/Sema/SemaChecking.cpp === --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -2700,6 +2700,26 @@ if (SemaBuiltinElementwiseMath(TheCall)) return ExprError(); break; + + case Builtin::BI__builtin_elementwise_bitreverse: { +if (PrepareBuiltinElementwiseMathOneArgCall(
[PATCH] D156357: clang: Add elementwise bitreverse builtin
bob80905 updated this revision to Diff 544830. bob80905 added a comment. - apply clang-format on CGBuiltin.cpp Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156357/new/ https://reviews.llvm.org/D156357 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/builtins-elementwise-math.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -206,3 +206,10 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_bitreverse() { + const int a = 2; + int b = 1; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -269,6 +269,24 @@ // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}} } +void test_builtin_elementwise_bitreverse(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_ceil(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_bitreverse(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_bitreverse(f); + // expected-error@-1 {{1st argument must be a vector of integers (was 'float')}} + + i = __builtin_elementwise_bitreverse(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_bitreverse(d); + // expected-error@-1 {{1st argument must be a vector of integers (was 'double')}} +} + void test_builtin_elementwise_ceil(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_ceil(f); Index: clang/test/CodeGen/builtins-elementwise-math.c === --- clang/test/CodeGen/builtins-elementwise-math.c +++ clang/test/CodeGen/builtins-elementwise-math.c @@ -323,6 +323,42 @@ int_as_one = __builtin_elementwise_min(int_as_one, b); } +void test_builtin_elementwise_bitreverse(si8 vi1, si8 vi2, + long long int i1, long long int i2, short si, + _BitInt(31) bi1, _BitInt(31) bi2) { + + + // CHECK: [[I1:%.+]] = load i64, ptr %i1.addr, align 8 + // CHECK-NEXT: call i64 @llvm.bitreverse.i64(i64 [[I1]]) + i2 = __builtin_elementwise_bitreverse(i1); + + // CHECK: [[VI1:%.+]] = load <8 x i16>, ptr %vi1.addr, align 16 + // CHECK-NEXT: call <8 x i16> @llvm.bitreverse.v8i16(<8 x i16> [[VI1]]) + vi2 = __builtin_elementwise_bitreverse(vi1); + + // CHECK: [[CVI2:%.+]] = load <8 x i16>, ptr %cvi2, align 16 + // CHECK-NEXT: call <8 x i16> @llvm.bitreverse.v8i16(<8 x i16> [[CVI2]]) + const si8 cvi2 = vi2; + vi2 = __builtin_elementwise_bitreverse(cvi2); + + // CHECK: [[BI1:%.+]] = load i31, ptr %bi1.addr, align 4 + // CHECK-NEXT: call i31 @llvm.bitreverse.i31(i31 [[BI1]]) + bi2 = __builtin_elementwise_bitreverse(bi1); + + // CHECK: [[IA1:%.+]] = load i32, ptr addrspace(1) @int_as_one, align 4 + // CHECK-NEXT: call i32 @llvm.bitreverse.i32(i32 [[IA1]]) + b = __builtin_elementwise_bitreverse(int_as_one); + + // CHECK: call i32 @llvm.bitreverse.i32(i32 -10) + b = __builtin_elementwise_bitreverse(-10); + + // CHECK: [[SI:%.+]] = load i16, ptr %si.addr, align 2 + // CHECK-NEXT: [[SI_EXT:%.+]] = sext i16 [[SI]] to i32 + // CHECK-NEXT: [[RES:%.+]] = call i32 @llvm.bitreverse.i32(i32 [[SI_EXT]]) + // CHECK-NEXT: = trunc i32 [[RES]] to i16 + si = __builtin_elementwise_bitreverse(si); +} + void test_builtin_elementwise_ceil(float f1, float f2, double d1, double d2, float4 vf1, float4 vf2) { // CHECK-LABEL: define void @test_builtin_elementwise_ceil( Index: clang/lib/Sema/SemaChecking.cpp === --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -2700,6 +2700,26 @@ if (SemaBuiltinElementwiseMath(TheCall)) return ExprError(); break; + + case Builtin::BI__builtin_elementwise_bitreverse: { +if (PrepareBuiltinElementwiseMathOneArgCall(TheCall)) + return ExprError(); + +const Expr *Arg = TheCall->getArg(0); +QualType ArgTy = Arg->getType(); +QualType EltTy
[PATCH] D156357: clang: Add elementwise bitreverse builtin
bob80905 updated this revision to Diff 544610. bob80905 added a comment. - remove tests that only test floating point inputs Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156357/new/ https://reviews.llvm.org/D156357 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/builtins-elementwise-math.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -206,3 +206,10 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_bitreverse() { + const int a = 2; + int b = 1; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -269,6 +269,24 @@ // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}} } +void test_builtin_elementwise_bitreverse(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_ceil(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_bitreverse(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_bitreverse(f); + // expected-error@-1 {{1st argument must be a vector of integers (was 'float')}} + + i = __builtin_elementwise_bitreverse(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_bitreverse(d); + // expected-error@-1 {{1st argument must be a vector of integers (was 'double')}} +} + void test_builtin_elementwise_ceil(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_ceil(f); Index: clang/test/CodeGen/builtins-elementwise-math.c === --- clang/test/CodeGen/builtins-elementwise-math.c +++ clang/test/CodeGen/builtins-elementwise-math.c @@ -323,6 +323,42 @@ int_as_one = __builtin_elementwise_min(int_as_one, b); } +void test_builtin_elementwise_bitreverse(si8 vi1, si8 vi2, + long long int i1, long long int i2, short si, + _BitInt(31) bi1, _BitInt(31) bi2) { + + + // CHECK: [[I1:%.+]] = load i64, ptr %i1.addr, align 8 + // CHECK-NEXT: call i64 @llvm.bitreverse.i64(i64 [[I1]]) + i2 = __builtin_elementwise_bitreverse(i1); + + // CHECK: [[VI1:%.+]] = load <8 x i16>, ptr %vi1.addr, align 16 + // CHECK-NEXT: call <8 x i16> @llvm.bitreverse.v8i16(<8 x i16> [[VI1]]) + vi2 = __builtin_elementwise_bitreverse(vi1); + + // CHECK: [[CVI2:%.+]] = load <8 x i16>, ptr %cvi2, align 16 + // CHECK-NEXT: call <8 x i16> @llvm.bitreverse.v8i16(<8 x i16> [[CVI2]]) + const si8 cvi2 = vi2; + vi2 = __builtin_elementwise_bitreverse(cvi2); + + // CHECK: [[BI1:%.+]] = load i31, ptr %bi1.addr, align 4 + // CHECK-NEXT: call i31 @llvm.bitreverse.i31(i31 [[BI1]]) + bi2 = __builtin_elementwise_bitreverse(bi1); + + // CHECK: [[IA1:%.+]] = load i32, ptr addrspace(1) @int_as_one, align 4 + // CHECK-NEXT: call i32 @llvm.bitreverse.i32(i32 [[IA1]]) + b = __builtin_elementwise_bitreverse(int_as_one); + + // CHECK: call i32 @llvm.bitreverse.i32(i32 -10) + b = __builtin_elementwise_bitreverse(-10); + + // CHECK: [[SI:%.+]] = load i16, ptr %si.addr, align 2 + // CHECK-NEXT: [[SI_EXT:%.+]] = sext i16 [[SI]] to i32 + // CHECK-NEXT: [[RES:%.+]] = call i32 @llvm.bitreverse.i32(i32 [[SI_EXT]]) + // CHECK-NEXT: = trunc i32 [[RES]] to i16 + si = __builtin_elementwise_bitreverse(si); +} + void test_builtin_elementwise_ceil(float f1, float f2, double d1, double d2, float4 vf1, float4 vf2) { // CHECK-LABEL: define void @test_builtin_elementwise_ceil( Index: clang/lib/Sema/SemaChecking.cpp === --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -2700,6 +2700,26 @@ if (SemaBuiltinElementwiseMath(TheCall)) return ExprError(); break; + + case Builtin::BI__builtin_elementwise_bitreverse: { +if (PrepareBuiltinElementwiseMathOneArgCall(TheCall)) + return ExprError(); + +const Expr *Arg = TheCall->getArg(0); +QualType ArgTy = Arg->getType(); +Q
[PATCH] D156357: clang: Add elementwise bitreverse builtin
bob80905 updated this revision to Diff 544563. bob80905 added a comment. - remove strictfp test, add cgbuiltin case and update test in codegen Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156357/new/ https://reviews.llvm.org/D156357 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-bitreverse-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-bitreverse-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -206,3 +206,10 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_bitreverse() { + const int a = 2; + int b = 1; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-bitreverse-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-bitreverse-ops.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: riscv-registered-target + +#include + + +vfloat32mf2_t test_bitreverse_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_bitreverse(v, v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -269,6 +269,24 @@ // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}} } +void test_builtin_elementwise_bitreverse(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_ceil(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_bitreverse(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_bitreverse(f); + // expected-error@-1 {{1st argument must be a vector of integers (was 'float')}} + + i = __builtin_elementwise_bitreverse(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_bitreverse(d); + // expected-error@-1 {{1st argument must be a vector of integers (was 'double')}} +} + void test_builtin_elementwise_ceil(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_ceil(f); Index: clang/test/Sema/aarch64-sve-vector-bitreverse-ops.c === --- /dev/null +++ clang/test/Sema/aarch64-sve-vector-bitreverse-ops.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +sve -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: aarch64-registered-target + +#include + +svfloat32_t test_bitreverse_vv_i8mf8(svfloat32_t v) { + + return __builtin_elementwise_bitreverse(v, v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/CodeGen/builtins-elementwise-math.c === --- clang/test/CodeGen/builtins-elementwise-math.c +++ clang/test/CodeGen/builtins-elementwise-math.c @@ -323,6 +323,42 @@ int_as_one = __builtin_elementwise_min(int_as_one, b); } +void test_builtin_elementwise_bitreverse(si8 vi1, si8 vi2, + long long int i1, long long int i2, short si, + _BitInt(31) bi1, _BitInt(31) bi2) { + + + // CHECK: [[I1:%.+]] = load i64, ptr %i1.addr, align 8 + // CHECK-NEXT: call i64 @llvm.bitreverse.i64(i64 [[I1]]) + i2 = __builtin_elementwise_bitreverse(i1); + + // CHECK: [[VI1:%.+]] = load <8 x i16>, ptr %vi1.addr, align 16 + // CHECK-NEXT: call <8 x i16> @llvm.bitreverse.v8i16(<8 x i16> [[VI1]]) + vi2 = __builtin_elementwise_bitreverse(vi1); + + // CHECK: [[CVI2:%.+]] = load <8 x i16>, ptr %cvi2, align 16 + // CHECK-NEXT: call <8 x i16> @llvm.bitreverse.v8i16(<8 x i16> [[CVI2]]) + const si8 cvi2 = vi2; + vi2
[PATCH] D156357: clang: Add elementwise bitreverse builtin
bob80905 updated this revision to Diff 544463. bob80905 added a comment. Herald added subscribers: wangpc, luke, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb. add attempt 1 commit Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156357/new/ https://reviews.llvm.org/D156357 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/CodeGen/strictfp-elementwise-bulitins.cpp clang/test/Sema/aarch64-sve-vector-bitreverse-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-bitreverse-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -206,3 +206,10 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_bitreverse() { + const int a = 2; + int b = 1; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-bitreverse-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-bitreverse-ops.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: riscv-registered-target + +#include + + +vfloat32mf2_t test_bitreverse_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_bitreverse(v, v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -269,6 +269,24 @@ // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}} } +void test_builtin_elementwise_bitreverse(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_ceil(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_bitreverse(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_bitreverse(f); + // expected-error@-1 {{1st argument must be a vector of integers (was 'float')}} + + i = __builtin_elementwise_bitreverse(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_bitreverse(d); + // expected-error@-1 {{1st argument must be a vector of integers (was 'double')}} +} + void test_builtin_elementwise_ceil(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_ceil(f); Index: clang/test/Sema/aarch64-sve-vector-bitreverse-ops.c === --- /dev/null +++ clang/test/Sema/aarch64-sve-vector-bitreverse-ops.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +sve -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: aarch64-registered-target + +#include + +svfloat32_t test_bitreverse_vv_i8mf8(svfloat32_t v) { + + return __builtin_elementwise_bitreverse(v, v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/CodeGen/strictfp-elementwise-bulitins.cpp === --- clang/test/CodeGen/strictfp-elementwise-bulitins.cpp +++ clang/test/CodeGen/strictfp-elementwise-bulitins.cpp @@ -47,6 +47,16 @@ return __builtin_elementwise_min(a, b); } +// CHECK-LABEL: define dso_local noundef <4 x float> @_Z22strict_elementwise_bitreverseDv4_fS_ +// CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]]) local_unnamed_addr #[[ATTR2]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.bitreverse.v4f32(<4 x float> [[A]], <4 x float> [[B]]) #[[ATTR4]] +// CHECK-NEXT:ret <4 x float> [[TMP0]] +// +float4 strict_elementwise_bitreverse(float4 a, float4 b) { + return __builtin_elementwise_bitreverse(a, b); +} + // CHECK-LABEL: d
[PATCH] D156357: clang: Add elementwise bitreverse builtin
bob80905 created this revision. 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. Add codegen for llvm bitreverse elementwise builtin The bitreverse elementwise builtin is necessary for HLSL codegen. Tests were added to make sure that the expected errors are encountered when these functions are given inputs of incompatible types, or too many inputs. The new builtin is restricted to integer types only. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D156357 Files: clang/lib/Sema/SemaChecking.cpp clang/test/Sema/builtins-elementwise-math.c Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -278,13 +278,13 @@ // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} i = __builtin_elementwise_bitreverse(f); - // expected-error@-1 {{1st argument must be a integer type (was 'float')}} - + // expected-error@-1 {{1st argument must be a vector of integers (was 'float')}} + i = __builtin_elementwise_bitreverse(f, f); // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} u = __builtin_elementwise_bitreverse(d); - // expected-error@-1 {{1st argument must be a integer type (was 'double')}} + // expected-error@-1 {{1st argument must be a vector of integers (was 'double')}} } void test_builtin_elementwise_ceil(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { Index: clang/lib/Sema/SemaChecking.cpp === --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -2697,10 +2697,29 @@ case Builtin::BI__builtin_elementwise_min: case Builtin::BI__builtin_elementwise_max: - case Builtin::BI__builtin_elementwise_bitreverse: if (SemaBuiltinElementwiseMath(TheCall)) return ExprError(); break; + + case Builtin::BI__builtin_elementwise_bitreverse: { +if (PrepareBuiltinElementwiseMathOneArgCall(TheCall)) + return ExprError(); + +const Expr *Arg = TheCall->getArg(0); +QualType ArgTy = Arg->getType(); +QualType EltTy = ArgTy; + +if (auto *VecTy = EltTy->getAs()) + EltTy = VecTy->getElementType(); + +if (!EltTy->isIntegerType()) { + Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type) + << 1 << /* integer ty */ 6 << ArgTy; + return ExprError(); +} +break; + } + case Builtin::BI__builtin_elementwise_copysign: { if (checkArgCount(*this, TheCall, 2)) return ExprError(); Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -278,13 +278,13 @@ // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} i = __builtin_elementwise_bitreverse(f); - // expected-error@-1 {{1st argument must be a integer type (was 'float')}} - + // expected-error@-1 {{1st argument must be a vector of integers (was 'float')}} + i = __builtin_elementwise_bitreverse(f, f); // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} u = __builtin_elementwise_bitreverse(d); - // expected-error@-1 {{1st argument must be a integer type (was 'double')}} + // expected-error@-1 {{1st argument must be a vector of integers (was 'double')}} } void test_builtin_elementwise_ceil(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { Index: clang/lib/Sema/SemaChecking.cpp === --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -2697,10 +2697,29 @@ case Builtin::BI__builtin_elementwise_min: case Builtin::BI__builtin_elementwise_max: - case Builtin::BI__builtin_elementwise_bitreverse: if (SemaBuiltinElementwiseMath(TheCall)) return ExprError(); break; + + case Builtin::BI__builtin_elementwise_bitreverse: { +if (PrepareBuiltinElementwiseMathOneArgCall(TheCall)) + return ExprError(); + +const Expr *Arg = TheCall->getArg(0); +QualType ArgTy = Arg->getType(); +QualType EltTy = ArgTy; + +if (auto *VecTy = EltTy->getAs()) + EltTy = VecTy->getElementType(); + +if (!EltTy->isIntegerType()) { + Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type) + << 1 << /* integer ty */ 6 << ArgTy; + return ExprError(); +} +break; + } + case Builtin::BI__builtin_elementwise_copysign: { if (checkArgCount(*this, TheCall, 2)) return ExprError(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://l
[PATCH] D156178: [HLSL] add pow library function
bob80905 added inline comments. Comment at: clang/test/CodeGenHLSL/builtins/pow.hlsl:10 +// CHECK: call half @llvm.pow.f16( +// NO_HALF: define noundef float @"?test_pow_half@@YA$halff@$halff@0@Z"( +// NO_HALF: call float @llvm.pow.f32( bogner wrote: > Why check the function name in the no-half case but not the other check? This is the pattern I've been using since starting on the upstreaming effort, so I've been copying this pattern. I don't see a reason why the function name shouldn't be included, so I'll add it here. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156178/new/ https://reviews.llvm.org/D156178 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D156178: [HLSL] add pow library function
bob80905 updated this revision to Diff 543757. bob80905 added a comment. - add func name to checks, clang format Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156178/new/ https://reviews.llvm.org/D156178 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/pow.hlsl Index: clang/test/CodeGenHLSL/builtins/pow.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/pow.hlsl @@ -0,0 +1,89 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.pow.f16( +// NO_HALF: define noundef float @"?test_pow_half@@YA$halff@$halff@0@Z"( +// NO_HALF: call float @llvm.pow.f32( +half test_pow_half(half p0, half p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <2 x half> @"?test_pow_half2@@YAT?$__vector@$f16@$01@__clang@@T12@0@Z"( +// CHECK: call <2 x half> @llvm.pow.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x float> @llvm.pow.v2f32( +half2 test_pow_half2(half2 p0, half2 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <3 x half> @"?test_pow_half3@@YAT?$__vector@$f16@$02@__clang@@T12@0@Z"( +// CHECK: call <3 x half> @llvm.pow.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_pow_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x float> @llvm.pow.v3f32( +half3 test_pow_half3(half3 p0, half3 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <4 x half> @"?test_pow_half4@@YAT?$__vector@$f16@$03@__clang@@T12@0@Z"( +// CHECK: call <4 x half> @llvm.pow.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_pow_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x float> @llvm.pow.v4f32( +half4 test_pow_half4(half4 p0, half4 p1) +{ + return pow(p0, p1); +} + +// CHECK: define noundef float @"?test_pow_float@@YAMMM@Z"( +// CHECK: call float @llvm.pow.f32( +float test_pow_float(float p0, float p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <2 x float> @"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"( +// CHECK: call <2 x float> @llvm.pow.v2f32 +float2 test_pow_float2(float2 p0, float2 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <3 x float> @"?test_pow_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"( +// CHECK: call <3 x float> @llvm.pow.v3f32 +float3 test_pow_float3(float3 p0, float3 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <4 x float> @"?test_pow_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"( +// CHECK: call <4 x float> @llvm.pow.v4f32 +float4 test_pow_float4(float4 p0, float4 p1) +{ + return pow(p0, p1); +} + +// CHECK: define noundef double @"?test_pow_double@@YANNN@Z"( +// CHECK: call double @llvm.pow.f64( +double test_pow_double(double p0, double p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <2 x double> @"?test_pow_double2@@YAT?$__vector@N$01@__clang@@T12@0@Z"( +// CHECK: call <2 x double> @llvm.pow.v2f64 +double2 test_pow_double2(double2 p0, double2 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <3 x double> @"?test_pow_double3@@YAT?$__vector@N$02@__clang@@T12@0@Z"( +// CHECK: call <3 x double> @llvm.pow.v3f64 +double3 test_pow_double3(double3 p0, double3 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <4 x double> @"?test_pow_double4@@YAT?$__vector@N$03@__clang@@T12@0@Z"( +// CHECK: call <4 x double> @llvm.pow.v4f64 +double4 test_pow_double4(double4 p0, double4 p1) +{ + return pow(p0, p1); +} Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -476,5 +476,35 @@ __attribute__((clang_builtin_alias(__builtin_elementwise_min))) double4 min(double4, double4); +// pow builtins +#ifdef __HLSL_ENABLE_16_BIT +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half pow(half, half); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half2 pow(half2, half2); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half3 pow(half3, half3); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half4 pow(half4, half4); +#endif + +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) float +pow(float, float); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +float2 pow(float2, float2); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +float3 pow(float3, float3); +__attribu
[PATCH] D156178: [HLSL] add pow library function
bob80905 added inline comments. Comment at: clang/test/CodeGenHLSL/builtins/pow.hlsl:6 +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + beanz wrote: > Does this need to set `-D__HLSL_ENABLE_16_BIT`? If 16-bit types are disabled, > this should result in `half` being 32-bit right? The define is necessary (the test fails otherwise) because without the definition, the definition of "half4" wouldn't exist (half4 is defined in hlsl_intrinsics.h). To your second question, yes, I think that's correct. Comment at: clang/test/CodeGenHLSL/builtins/pow.hlsl:12 +// NO_HALF: call float @llvm.pow.f32( +half test_pow_half(half p0, half p1) +{ beanz wrote: > nit: can you clang-format this source? Will do Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156178/new/ https://reviews.llvm.org/D156178 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D156178: [HLSL] add pow library function
bob80905 updated this revision to Diff 543731. bob80905 added a comment. - add eof newline Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156178/new/ https://reviews.llvm.org/D156178 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/pow.hlsl Index: clang/test/CodeGenHLSL/builtins/pow.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/pow.hlsl @@ -0,0 +1,89 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.pow.f16( +// NO_HALF: define noundef float @"?test_pow_half@@YA$halff@$halff@0@Z"( +// NO_HALF: call float @llvm.pow.f32( +half test_pow_half(half p0, half p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.pow.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x float> @llvm.pow.v2f32( +half2 test_pow_half2(half2 p0, half2 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.pow.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_pow_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x float> @llvm.pow.v3f32( +half3 test_pow_half3(half3 p0, half3 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.pow.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_pow_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x float> @llvm.pow.v4f32( +half4 test_pow_half4(half4 p0, half4 p1) +{ + return pow(p0, p1); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.pow.f32( +float test_pow_float(float p0, float p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.pow.v2f32 +float2 test_pow_float2(float2 p0, float2 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.pow.v3f32 +float3 test_pow_float3(float3 p0, float3 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <4 x float> @ +// CHECK: call <4 x float> @llvm.pow.v4f32 +float4 test_pow_float4(float4 p0, float4 p1) +{ + return pow(p0, p1); +} + +// CHECK: define noundef double @ +// CHECK: call double @llvm.pow.f64( +double test_pow_double(double p0, double p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <2 x double> @ +// CHECK: call <2 x double> @llvm.pow.v2f64 +double2 test_pow_double2(double2 p0, double2 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <3 x double> @ +// CHECK: call <3 x double> @llvm.pow.v3f64 +double3 test_pow_double3(double3 p0, double3 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <4 x double> @ +// CHECK: call <4 x double> @llvm.pow.v4f64 +double4 test_pow_double4(double4 p0, double4 p1) +{ + return pow(p0, p1); +} Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -476,5 +476,35 @@ __attribute__((clang_builtin_alias(__builtin_elementwise_min))) double4 min(double4, double4); +// pow builtins +#ifdef __HLSL_ENABLE_16_BIT +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half pow(half, half); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half2 pow(half2, half2); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half3 pow(half3, half3); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half4 pow(half4, half4); +#endif + +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) float +pow(float, float); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +float2 pow(float2, float2); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +float3 pow(float3, float3); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +float4 pow(float4, float4); + +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) double +pow(double, double); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +double2 pow(double2, double2); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +double3 pow(double3, double3); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +double4 pow(double4, double4); + } // namespace hlsl #endif //_HLSL_HLSL_INTRINSICS_H_ ___ cfe-commits mail
[PATCH] D156178: [HLSL] add pow library function
bob80905 updated this revision to Diff 543730. bob80905 added a comment. - remove non-floating-point func decls from header file Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156178/new/ https://reviews.llvm.org/D156178 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/pow.hlsl Index: clang/test/CodeGenHLSL/builtins/pow.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/pow.hlsl @@ -0,0 +1,89 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.pow.f16( +// NO_HALF: define noundef float @"?test_pow_half@@YA$halff@$halff@0@Z"( +// NO_HALF: call float @llvm.pow.f32( +half test_pow_half(half p0, half p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.pow.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x float> @llvm.pow.v2f32( +half2 test_pow_half2(half2 p0, half2 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.pow.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_pow_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x float> @llvm.pow.v3f32( +half3 test_pow_half3(half3 p0, half3 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.pow.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_pow_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x float> @llvm.pow.v4f32( +half4 test_pow_half4(half4 p0, half4 p1) +{ + return pow(p0, p1); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.pow.f32( +float test_pow_float(float p0, float p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.pow.v2f32 +float2 test_pow_float2(float2 p0, float2 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.pow.v3f32 +float3 test_pow_float3(float3 p0, float3 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <4 x float> @ +// CHECK: call <4 x float> @llvm.pow.v4f32 +float4 test_pow_float4(float4 p0, float4 p1) +{ + return pow(p0, p1); +} + +// CHECK: define noundef double @ +// CHECK: call double @llvm.pow.f64( +double test_pow_double(double p0, double p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <2 x double> @ +// CHECK: call <2 x double> @llvm.pow.v2f64 +double2 test_pow_double2(double2 p0, double2 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <3 x double> @ +// CHECK: call <3 x double> @llvm.pow.v3f64 +double3 test_pow_double3(double3 p0, double3 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <4 x double> @ +// CHECK: call <4 x double> @llvm.pow.v4f64 +double4 test_pow_double4(double4 p0, double4 p1) +{ + return pow(p0, p1); +} \ No newline at end of file Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -476,5 +476,35 @@ __attribute__((clang_builtin_alias(__builtin_elementwise_min))) double4 min(double4, double4); +// pow builtins +#ifdef __HLSL_ENABLE_16_BIT +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half pow(half, half); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half2 pow(half2, half2); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half3 pow(half3, half3); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half4 pow(half4, half4); +#endif + +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) float +pow(float, float); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +float2 pow(float2, float2); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +float3 pow(float3, float3); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +float4 pow(float4, float4); + +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) double +pow(double, double); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +double2 pow(double2, double2); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +double3 pow(double3, double3); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +double4 pow(double4, double4); + } // namespace hlsl #endif //_HLSL_HLSL_INTRINSICS_H
[PATCH] D156178: [HLSL] add pow library function
bob80905 created this revision. bob80905 added reviewers: python3kgae, beanz. 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 pow library function for HLSL, only available for floating point types. The pow function is supported for all scalar, vector, and matrix types that contain floating point types. The full documentation of the HLSL pow function is available here: https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-pow Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D156178 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/pow.hlsl Index: clang/test/CodeGenHLSL/builtins/pow.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/pow.hlsl @@ -0,0 +1,89 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.pow.f16( +// NO_HALF: define noundef float @"?test_pow_half@@YA$halff@$halff@0@Z"( +// NO_HALF: call float @llvm.pow.f32( +half test_pow_half(half p0, half p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.pow.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_pow_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x float> @llvm.pow.v2f32( +half2 test_pow_half2(half2 p0, half2 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.pow.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_pow_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x float> @llvm.pow.v3f32( +half3 test_pow_half3(half3 p0, half3 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.pow.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_pow_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x float> @llvm.pow.v4f32( +half4 test_pow_half4(half4 p0, half4 p1) +{ + return pow(p0, p1); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.pow.f32( +float test_pow_float(float p0, float p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.pow.v2f32 +float2 test_pow_float2(float2 p0, float2 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.pow.v3f32 +float3 test_pow_float3(float3 p0, float3 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <4 x float> @ +// CHECK: call <4 x float> @llvm.pow.v4f32 +float4 test_pow_float4(float4 p0, float4 p1) +{ + return pow(p0, p1); +} + +// CHECK: define noundef double @ +// CHECK: call double @llvm.pow.f64( +double test_pow_double(double p0, double p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <2 x double> @ +// CHECK: call <2 x double> @llvm.pow.v2f64 +double2 test_pow_double2(double2 p0, double2 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <3 x double> @ +// CHECK: call <3 x double> @llvm.pow.v3f64 +double3 test_pow_double3(double3 p0, double3 p1) +{ + return pow(p0, p1); +} +// CHECK: define noundef <4 x double> @ +// CHECK: call <4 x double> @llvm.pow.v4f64 +double4 test_pow_double4(double4 p0, double4 p1) +{ + return pow(p0, p1); +} \ No newline at end of file Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -476,5 +476,89 @@ __attribute__((clang_builtin_alias(__builtin_elementwise_min))) double4 min(double4, double4); +// pow builtins +#ifdef __HLSL_ENABLE_16_BIT +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half pow(half, half); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half2 pow(half2, half2); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half3 pow(half3, half3); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +half4 pow(half4, half4); + +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +int16_t pow(int16_t, int16_t); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +int16_t2 pow(int16_t2, int16_t2); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +int16_t3 pow(int16_t3, int16_t3); +__attribute__((clang_builtin_alias(__builtin_elementwise_pow))) +int16_t4 pow(int16_t4, int16_t4); + +__attr
[PATCH] D153310: clang: Add elementwise pow builtin
This revision was automatically updated to reflect the committed changes. Closed by commit rG3a98e73169e1: clang: Add elementwise pow builtin (authored by bob80905). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153310/new/ https://reviews.llvm.org/D153310 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/CodeGen/strictfp-elementwise-bulitins.cpp clang/test/Sema/aarch64-sve-vector-pow-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-pow-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -198,3 +198,11 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_pow() { + const double a = 2; + double b = 1; + static_assert(!is_const::value); + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-pow-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-pow-ops.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: riscv-registered-target + +#include + + +vfloat32mf2_t test_pow_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_pow(v, v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -438,6 +438,31 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_pow(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) { + i = __builtin_elementwise_pow(p, d); + // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}} + + struct Foo foo = __builtin_elementwise_pow(i, i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_pow(i); + // expected-error@-1 {{too few arguments to function call, expected 2, have 1}} + + i = __builtin_elementwise_pow(); + // expected-error@-1 {{too few arguments to function call, expected 2, have 0}} + + i = __builtin_elementwise_pow(i, i, i); + // expected-error@-1 {{too many arguments to function call, expected 2, have 3}} + + i = __builtin_elementwise_pow(v, iv); + // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}} + + i = __builtin_elementwise_pow(uv, iv); + // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}} + +} + + void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_roundeven(f); Index: clang/test/Sema/aarch64-sve-vector-pow-ops.c === --- /dev/null +++ clang/test/Sema/aarch64-sve-vector-pow-ops.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +sve -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: aarch64-registered-target + +#include + +svfloat32_t test_pow_vv_i8mf8(svfloat32_t v) { + + return __builtin_elementwise_pow(v, v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/CodeGen/strictfp-elementwise-bulitins.cpp === --- clang/test/CodeGen/strictfp-elementwise-bulitins.cpp +++ clang/test/CodeGen/strictfp-elementwise-bulitins.cpp @@ -217,3 +217,12 @@ return __builtin_elementwise_fma(a, b, c); } +// CHECK-LABEL: define dso_local noundef <4 x float> @_Z22strict_elementwise_powDv4_fS_ +// CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]]) local_unnamed_addr #[[ATTR2]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.pow.v4f32(<4 x float> [[A]], <4 x float> [[B]]) #[[ATTR4]] +// CHECK-NEXT:ret <
[PATCH] D153310: Add codegen for llvm pow builtin
bob80905 added a comment. Ping, can someone please take a look? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153310/new/ https://reviews.llvm.org/D153310 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D155729: [OptTable] Make explicitly included options override excluded ones
bob80905 added inline comments. Comment at: clang/include/clang/Driver/Options.h:40 + Ignored = (1 << 18), + TargetSpecific = (1 << 19), }; Given that the id for these flags have changed, does it make sense to write a test that makes sure these flags with these bits still behave as expected? (Ignored and target specific, specifically). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D155729/new/ https://reviews.llvm.org/D155729 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D153310: Add codegen for llvm pow builtin
bob80905 updated this revision to Diff 541721. bob80905 added a comment. - add newline EOF Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153310/new/ https://reviews.llvm.org/D153310 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/CodeGen/strictfp-elementwise-bulitins.cpp clang/test/Sema/aarch64-sve-vector-pow-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-pow-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -198,3 +198,11 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_pow() { + const double a = 2; + double b = 1; + static_assert(!is_const::value); + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-pow-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-pow-ops.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: riscv-registered-target + +#include + + +vfloat32mf2_t test_pow_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_pow(v, v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -438,6 +438,31 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_pow(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) { + i = __builtin_elementwise_pow(p, d); + // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}} + + struct Foo foo = __builtin_elementwise_pow(i, i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_pow(i); + // expected-error@-1 {{too few arguments to function call, expected 2, have 1}} + + i = __builtin_elementwise_pow(); + // expected-error@-1 {{too few arguments to function call, expected 2, have 0}} + + i = __builtin_elementwise_pow(i, i, i); + // expected-error@-1 {{too many arguments to function call, expected 2, have 3}} + + i = __builtin_elementwise_pow(v, iv); + // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}} + + i = __builtin_elementwise_pow(uv, iv); + // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}} + +} + + void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_roundeven(f); Index: clang/test/Sema/aarch64-sve-vector-pow-ops.c === --- /dev/null +++ clang/test/Sema/aarch64-sve-vector-pow-ops.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +sve -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: aarch64-registered-target + +#include + +svfloat32_t test_pow_vv_i8mf8(svfloat32_t v) { + + return __builtin_elementwise_pow(v, v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/CodeGen/strictfp-elementwise-bulitins.cpp === --- clang/test/CodeGen/strictfp-elementwise-bulitins.cpp +++ clang/test/CodeGen/strictfp-elementwise-bulitins.cpp @@ -217,3 +217,12 @@ return __builtin_elementwise_fma(a, b, c); } +// CHECK-LABEL: define dso_local noundef <4 x float> @_Z22strict_elementwise_powDv4_fS_ +// CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]]) local_unnamed_addr #[[ATTR2]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.pow.v4f32(<4 x float> [[A]], <4 x float> [[B]]) #[[ATTR4]] +// CHECK-NEXT:ret <4 x float> [[TMP0]] +// +float4 strict_elementwise_pow(float4 a, float4 b)
[PATCH] D153310: Add codegen for llvm pow builtin
bob80905 updated this revision to Diff 541717. bob80905 added a comment. - add strictfp test, use emitbinarybuiltin, fix some whitespace Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153310/new/ https://reviews.llvm.org/D153310 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/CodeGen/strictfp-elementwise-bulitins.cpp clang/test/Sema/aarch64-sve-vector-pow-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-pow-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -198,3 +198,11 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_pow() { + const double a = 2; + double b = 1; + static_assert(!is_const::value); + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-pow-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-pow-ops.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: riscv-registered-target + +#include + + +vfloat32mf2_t test_pow_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_pow(v, v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} \ No newline at end of file Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -438,6 +438,31 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_pow(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) { + i = __builtin_elementwise_pow(p, d); + // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}} + + struct Foo foo = __builtin_elementwise_pow(i, i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_pow(i); + // expected-error@-1 {{too few arguments to function call, expected 2, have 1}} + + i = __builtin_elementwise_pow(); + // expected-error@-1 {{too few arguments to function call, expected 2, have 0}} + + i = __builtin_elementwise_pow(i, i, i); + // expected-error@-1 {{too many arguments to function call, expected 2, have 3}} + + i = __builtin_elementwise_pow(v, iv); + // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}} + + i = __builtin_elementwise_pow(uv, iv); + // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}} + +} + + void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_roundeven(f); Index: clang/test/Sema/aarch64-sve-vector-pow-ops.c === --- /dev/null +++ clang/test/Sema/aarch64-sve-vector-pow-ops.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +sve -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: aarch64-registered-target + +#include + +svfloat32_t test_pow_vv_i8mf8(svfloat32_t v) { + + return __builtin_elementwise_pow(v, v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/CodeGen/strictfp-elementwise-bulitins.cpp === --- clang/test/CodeGen/strictfp-elementwise-bulitins.cpp +++ clang/test/CodeGen/strictfp-elementwise-bulitins.cpp @@ -217,3 +217,12 @@ return __builtin_elementwise_fma(a, b, c); } +// CHECK-LABEL: define dso_local noundef <4 x float> @_Z22strict_elementwise_powDv4_fS_ +// CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]]) local_unnamed_addr #[[ATTR2]] { +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x float> @llvm.pow.v4f32(<4 x float> [[A]], <4 x float> [[B]]) #[[ATTR4]] +// CHECK-NEXT:ret <4
[PATCH] D153310: Add builtin_elementwise_pow
bob80905 updated this revision to Diff 541651. bob80905 added a comment. - remove unimportant part of test Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153310/new/ https://reviews.llvm.org/D153310 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-pow-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-pow-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -198,3 +198,11 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_pow() { + const double a = 2; + double b = 1; + static_assert(!is_const::value); + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-pow-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-pow-ops.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: riscv-registered-target + +#include + + +vfloat32mf2_t test_pow_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_pow(v, v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} \ No newline at end of file Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -438,6 +438,31 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_pow(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) { + i = __builtin_elementwise_pow(p, d); + // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}} + + struct Foo foo = __builtin_elementwise_pow(i, i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_pow(i); + // expected-error@-1 {{too few arguments to function call, expected 2, have 1}} + + i = __builtin_elementwise_pow(); + // expected-error@-1 {{too few arguments to function call, expected 2, have 0}} + + i = __builtin_elementwise_pow(i, i, i); + // expected-error@-1 {{too many arguments to function call, expected 2, have 3}} + + i = __builtin_elementwise_pow(v, iv); + // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}} + + i = __builtin_elementwise_pow(uv, iv); + // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}} + +} + + void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_roundeven(f); Index: clang/test/Sema/aarch64-sve-vector-pow-ops.c === --- /dev/null +++ clang/test/Sema/aarch64-sve-vector-pow-ops.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +sve -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: aarch64-registered-target + +#include + +svfloat32_t test_pow_vv_i8mf8(svfloat32_t v) { + + return __builtin_elementwise_pow(v, v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} \ No newline at end of file Index: clang/test/CodeGen/builtins-elementwise-math.c === --- clang/test/CodeGen/builtins-elementwise-math.c +++ clang/test/CodeGen/builtins-elementwise-math.c @@ -452,6 +452,26 @@ vf2 = __builtin_elementwise_log2(vf1); } +void test_builtin_elementwise_pow(float f1, float f2, double d1, double d2, + float4 vf1, float4 vf2) { + + // CHECK-LABEL: define void @test_builtin_elementwise_pow( + // CHECK: [[F1:%.+]] = load float, ptr %f1.addr, align 4 + // CHECK: [[F2:%.+]] = load float, ptr %f2.addr, align 4 + // CHECK-NEXT: call float @llvm.pow.f32(float [[F1]], float [[F2]]) + f2 = __builtin_elementwise_pow(f1, f2)
[PATCH] D153310: Add builtin_elementwise_pow
bob80905 updated this revision to Diff 541294. bob80905 added a comment. fix void return, and incorrect expectation of arg count Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153310/new/ https://reviews.llvm.org/D153310 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-pow-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-pow-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -198,3 +198,11 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_pow() { + const double a = 2; + double b = 1; + static_assert(!is_const::value); + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-pow-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-pow-ops.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: riscv-registered-target + +#include + + +vfloat32mf2_t test_pow_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_pow(v, v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} \ No newline at end of file Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -438,6 +438,60 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_pow(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) { + i = __builtin_elementwise_pow(p, d); + // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}} + + struct Foo foo = __builtin_elementwise_pow(i, i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_pow(i); + // expected-error@-1 {{too few arguments to function call, expected 2, have 1}} + + i = __builtin_elementwise_pow(); + // expected-error@-1 {{too few arguments to function call, expected 2, have 0}} + + i = __builtin_elementwise_pow(i, i, i); + // expected-error@-1 {{too many arguments to function call, expected 2, have 3}} + + i = __builtin_elementwise_pow(v, iv); + // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}} + + i = __builtin_elementwise_pow(uv, iv); + // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}} + + enum e { one, + two }; + i = __builtin_elementwise_pow(one, two); + + enum f { three }; + enum f x = __builtin_elementwise_pow(one, three); + + _BitInt(32) ext; // expected-warning {{'_BitInt' in C17 and earlier is a Clang extension}} + ext = __builtin_elementwise_pow(ext, ext); + + const int ci; + i = __builtin_elementwise_pow(ci, i); + i = __builtin_elementwise_pow(i, ci); + i = __builtin_elementwise_pow(ci, ci); + + i = __builtin_elementwise_pow(i, int_as_one); // ok (attributes don't match)? + i = __builtin_elementwise_pow(i, b); // ok (sugar doesn't match)? + + int A[10]; + A = __builtin_elementwise_pow(A, A); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'int *')}} + + int(ii); + int j; + j = __builtin_elementwise_pow(i, j); + + _Complex float c1, c2; + c1 = __builtin_elementwise_pow(c1, c2); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}} +} + + void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_roundeven(f); Index: clang/test/Sema/aarch64-sve-vector-pow-ops.c === --- /dev/null +++ clang/test/Sema/aarch64-sve-vector-pow-ops.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +sve -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsynt
[PATCH] D155534: fix arg validation issue and void return issue, tests pass
bob80905 created this revision. Herald added a project: All. bob80905 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D155534 Files: clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/builtins-elementwise-math.c Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -443,7 +443,7 @@ // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}} struct Foo foo = __builtin_elementwise_pow(i, i); - // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}} + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} i = __builtin_elementwise_pow(i); // expected-error@-1 {{too few arguments to function call, expected 2, have 1}} @@ -460,11 +460,6 @@ i = __builtin_elementwise_pow(uv, iv); // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}} - v = __builtin_elementwise_pow(v, v); - // expected-error@-1 {{1st argument must be a vector of integers (was 'float4' (vector of 4 'float' values))}} - - s = __builtin_elementwise_pow(i, s); - enum e { one, two }; i = __builtin_elementwise_pow(one, two); Index: clang/test/CodeGen/builtins-elementwise-math.c === --- clang/test/CodeGen/builtins-elementwise-math.c +++ clang/test/CodeGen/builtins-elementwise-math.c @@ -453,52 +453,23 @@ } void test_builtin_elementwise_pow(float f1, float f2, double d1, double d2, - float4 vf1, float4 vf2, long long int i1, - long long int i2, si8 vi1, si8 vi2, - unsigned u1, unsigned u2, u4 vu1, u4 vu2, - _BitInt(31) bi1, _BitInt(31) bi2, - unsigned _BitInt(55) bu1, unsigned _BitInt(55) bu2) { - // CHECK: [[I1:%.+]] = load i64, ptr %i1.addr, align 8 - // CHECK-NEXT: [[I2:%.+]] = load i64, ptr %i2.addr, align 8 - // CHECK-NEXT: call i64 @llvm.pow.i64(i64 [[I1]], i64 [[I2]]) - i1 = __builtin_elementwise_pow(i1, i2); - - // CHECK: [[I1:%.+]] = load i64, ptr %i1.addr, align 8 - // CHECK-NEXT: call i64 @llvm.pow.i64(i64 [[I1]], i64 10) - i1 = __builtin_elementwise_pow(i1, 10); - - // CHECK: [[VI1:%.+]] = load <8 x i16>, ptr %vi1.addr, align 16 - // CHECK-NEXT: [[VI2:%.+]] = load <8 x i16>, ptr %vi2.addr, align 16 - // CHECK-NEXT: call <8 x i16> @llvm.pow.v8i16(<8 x i16> [[VI1]], <8 x i16> [[VI2]]) - vi1 = __builtin_elementwise_pow(vi1, vi2); - - // CHECK: [[U1:%.+]] = load i32, ptr %u1.addr, align 4 - // CHECK-NEXT: [[U2:%.+]] = load i32, ptr %u2.addr, align 4 - // CHECK-NEXT: call i32 @llvm.pow.i32(i32 [[U1]], i32 [[U2]]) - u1 = __builtin_elementwise_pow(u1, u2); + float4 vf1, float4 vf2) { - // CHECK: [[VU1:%.+]] = load <4 x i32>, ptr %vu1.addr, align 16 - // CHECK-NEXT: [[VU2:%.+]] = load <4 x i32>, ptr %vu2.addr, align 16 - // CHECK-NEXT: call <4 x i32> @llvm.pow.v4i32(<4 x i32> [[VU1]], <4 x i32> [[VU2]]) - vu1 = __builtin_elementwise_pow(vu1, vu2); - - // CHECK: [[BI1:%.+]] = load i31, ptr %bi1.addr, align 4 - // CHECK-NEXT: [[BI2:%.+]] = load i31, ptr %bi2.addr, align 4 - // CHECK-NEXT: call i31 @llvm.pow.i31(i31 [[BI1]], i31 [[BI2]]) - bi1 = __builtin_elementwise_pow(bi1, bi2); - - // CHECK: [[BU1:%.+]] = load i55, ptr %bu1.addr, align 8 - // CHECK-NEXT: [[BU2:%.+]] = load i55, ptr %bu2.addr, align 8 - // CHECK-NEXT: call i55 @llvm.pow.i55(i55 [[BU1]], i55 [[BU2]]) - bu1 = __builtin_elementwise_pow(bu1, bu2); + // CHECK-LABEL: define void @test_builtin_elementwise_pow( + // CHECK: [[F1:%.+]] = load float, ptr %f1.addr, align 4 + // CHECK: [[F2:%.+]] = load float, ptr %f2.addr, align 4 + // CHECK-NEXT: call float @llvm.pow.f32(float [[F1]], float [[F2]]) + f2 = __builtin_elementwise_pow(f1, f2); - // CHECK: [[IAS1:%.+]] = load i32, ptr addrspace(1) @int_as_one, align 4 - // CHECK-NEXT: [[B:%.+]] = load i32, ptr @b, align 4 - // CHECK-NEXT: call i32 @llvm.pow.i32(i32 [[IAS1]], i32 [[B]]) - int_as_one = __builtin_elementwise_pow(int_as_one, b); + // CHECK: [[D1:%.+]] = load double, ptr %d1.addr, align 8 + // CHECK: [[D2:%.+]] = load double, ptr %d2.addr, align 8 + // CHECK-NEXT: call double @llvm.pow.f64(double [[D1]], double [[D2]]) + d2 = __builtin_elementwise_pow(d1, d2); - // CHECK: call i32 @llvm.pow.i32(i32 1, i32 97) - i1 = __builtin_elementwise_pow(1, 'a'); + // CHECK: [[VF1:%.+]] = load <4 x flo
[PATCH] D153233: clang: Add __builtin_elementwise_rint and nearbyint
bob80905 accepted this revision. bob80905 added a comment. This revision is now accepted and ready to land. LGTM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153233/new/ https://reviews.llvm.org/D153233 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D153233: clang: Add __builtin_elementwise_rint and nearbyint
bob80905 added a comment. Should there be tests added for usage of scalable vector types for RISC-V / AArch64? I typically have added such tests in the past, as shown here: https://reviews.llvm.org/D135011 Also, would you be able to add something at the top of the strictfp file that states the purpose? Like "testing that we don't use the constrained intrinsics"? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153233/new/ https://reviews.llvm.org/D153233 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D153233: clang: Add __builtin_elementwise_rint and nearbyint
bob80905 added a comment. I believe it's also necessary to declare the builtin_elementwise builtins in \clang\include\clang\Basic\Builtins.def. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153233/new/ https://reviews.llvm.org/D153233 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D153233: clang: Add __builtin_elementwise_rint and nearbyint
bob80905 added a comment. I'd like to ask, is there a reason why there isn't a test for these new builtins under SemaCXX/builtins_elementwise_math.cpp? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153233/new/ https://reviews.llvm.org/D153233 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D153233: clang: Add __builtin_elementwise_rint and nearbyint
bob80905 added inline comments. Comment at: clang/test/CodeGen/strictfp-elementwise-bulitins.cpp:190 +// CHECK-NEXT: entry: +// CHECK-NEXT:[[ELT_TRUNC:%.*]] = tail call <4 x float> @llvm.canonicalize.v4f32(<4 x float> [[A]]) #[[ATTR4]] +// CHECK-NEXT:ret <4 x float> [[ELT_TRUNC]] I noticed a missing pattern here. Did you mean to write canonicalize instead of TRUNC? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153233/new/ https://reviews.llvm.org/D153233 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D153233: clang: Add __builtin_elementwise_rint and nearbyint
bob80905 added inline comments. Comment at: clang/lib/Sema/SemaChecking.cpp:18583 << Callee << CallerTCB; } } arsenm wrote: > arsenm wrote: > > bob80905 wrote: > > > I don't believe you intended to remove all this code in your latest > > > update, did you? > > I didn't delete any code? > Are you looking at a history diff? I see nothing deleted here I am unsure what I was seeing prior, but I no longer see any deleted code, you can count this comment as resolved. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153233/new/ https://reviews.llvm.org/D153233 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D153233: clang: Add __builtin_elementwise_rint and nearbyint
bob80905 added inline comments. Comment at: clang/docs/LanguageExtensions.rst:656 + T __builtin_elementwise_nearbyint(T x) round x to the nearest integer value in floating point format, floating point types + rounding according to the current rounding direction. + May not raise the inexact floating-point exception. This is Nit: I don't think a "current rounding direction" exists, and personally don't see the significance of the second half of this sentence. Comment at: clang/lib/Sema/SemaChecking.cpp:18583 << Callee << CallerTCB; } } I don't believe you intended to remove all this code in your latest update, did you? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153233/new/ https://reviews.llvm.org/D153233 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D153310: Add builtin_elementwise_pow
bob80905 created this revision. Herald added subscribers: luke, Anastasia, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb. Herald added a project: All. bob80905 requested review of this revision. Herald added subscribers: cfe-commits, wangpc. Herald added a project: clang. Add codegen for llvm pow elementwise builtin The pow elementwise builtin is necessary for HLSL codegen. Tests were added to make sure that the expected errors are encountered when these functions are given inputs of incompatible types, or too many inputs. The new builtin is restricted to floating point types only. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D153310 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-pow-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-pow-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -108,3 +108,11 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_pow() { + const double a = 2; + double b = 1; + static_assert(!is_const::value); + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-pow-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-pow-ops.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: riscv-registered-target + +#include + + +vfloat32mf2_t test_pow_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_pow(v, v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} \ No newline at end of file Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -438,6 +438,65 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_pow(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) { + i = __builtin_elementwise_pow(p, d); + // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}} + + struct Foo foo = __builtin_elementwise_pow(i, i); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}} + + i = __builtin_elementwise_pow(i); + // expected-error@-1 {{too few arguments to function call, expected 2, have 1}} + + i = __builtin_elementwise_pow(); + // expected-error@-1 {{too few arguments to function call, expected 2, have 0}} + + i = __builtin_elementwise_pow(i, i, i); + // expected-error@-1 {{too many arguments to function call, expected 2, have 3}} + + i = __builtin_elementwise_pow(v, iv); + // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}} + + i = __builtin_elementwise_pow(uv, iv); + // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}} + + v = __builtin_elementwise_pow(v, v); + // expected-error@-1 {{1st argument must be a vector of integers (was 'float4' (vector of 4 'float' values))}} + + s = __builtin_elementwise_pow(i, s); + + enum e { one, + two }; + i = __builtin_elementwise_pow(one, two); + + enum f { three }; + enum f x = __builtin_elementwise_pow(one, three); + + _BitInt(32) ext; // expected-warning {{'_BitInt' in C17 and earlier is a Clang extension}} + ext = __builtin_elementwise_pow(ext, ext); + + const int ci; + i = __builtin_elementwise_pow(ci, i); + i = __builtin_elementwise_pow(i, ci); + i = __builtin_elementwise_pow(ci, ci); + + i = __builtin_elementwise_pow(i, int_as_one); // ok (attributes don't match)? + i = __builtin_elementwise_pow(i, b); // ok (sugar doesn't match)? + + int A[10]; + A = __builtin_elementwise_pow(A, A); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'int *')}} + + int(ii); + int j; + j = __builtin_elementwise_pow(i, j); + + _Complex floa
[PATCH] D153233: clang: Add __builtin_elementwise_rint and nearbyint
bob80905 added inline comments. Comment at: clang/docs/LanguageExtensions.rst:656 + T __builtin_elementwise_nearbyint(T x) round x to the nearest integer value in floating point format, floating point types + rounding according to the current current rounding direction. + May not raise the inexact floating-point exception. This is typo with the word current. Comment at: clang/docs/ReleaseNotes.rst:234 arbitrary floating-point and vector of floating-point types. - +- Added ``__builtin_elementwise_rint`` for builtin for floating + point types. This allows access to ``llvm.rint`` for Don't think this for is necessary or intended, and it appears in the nearbyint description too. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153233/new/ https://reviews.llvm.org/D153233 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D145270: Add codegen for llvm exp/exp2 elementwise builtins
This revision was automatically updated to reflect the committed changes. Closed by commit rG4c82050c5692: Add codegen for llvm exp/exp2 elementwise builtins (authored by bob80905). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D145270/new/ https://reviews.llvm.org/D145270 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-exp-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-exp-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -67,6 +67,20 @@ static_assert(!is_const::value); } +void test_builtin_elementwise_exp() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} + +void test_builtin_elementwise_exp2() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} + void test_builtin_elementwise_sin() { const float a = 42.0; float b = 42.3; Index: clang/test/Sema/riscv-sve-vector-exp-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-exp-ops.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: riscv-registered-target + +#include + + +vfloat32mf2_t test_exp_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_exp(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} + +vfloat32mf2_t test_exp2_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_exp2(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -311,6 +311,49 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_exp(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_exp(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_exp(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_exp(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_exp(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_exp(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_exp(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + +void test_builtin_elementwise_exp2(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_exp2(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_exp2(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_exp2(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_exp2(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_exp2(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_exp2(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + + void test_builtin_elementwise_floor(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_floor(f); Index: clang/test/Sema/aarch64-sve-vector-exp-ops.c === --- /dev/null +++ clang/test/Sema/aarch64-sve-vector-exp-ops.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v
[PATCH] D145270: Add codegen for llvm exp/exp2 elementwise builtins
bob80905 updated this revision to Diff 503511. bob80905 added a comment. - remove or to eliminate any ambiguity Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D145270/new/ https://reviews.llvm.org/D145270 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-exp-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-exp-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -67,6 +67,20 @@ static_assert(!is_const::value); } +void test_builtin_elementwise_exp() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} + +void test_builtin_elementwise_exp2() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} + void test_builtin_elementwise_sin() { const float a = 42.0; float b = 42.3; Index: clang/test/Sema/riscv-sve-vector-exp-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-exp-ops.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: riscv-registered-target + +#include + + +vfloat32mf2_t test_exp_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_exp(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} + +vfloat32mf2_t test_exp2_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_exp2(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -311,6 +311,49 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_exp(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_exp(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_exp(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_exp(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_exp(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_exp(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_exp(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + +void test_builtin_elementwise_exp2(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_exp2(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_exp2(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_exp2(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_exp2(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_exp2(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_exp2(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + + void test_builtin_elementwise_floor(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_floor(f); Index: clang/test/Sema/aarch64-sve-vector-exp-ops.c === --- /dev/null +++ clang/test/Sema/aarch64-sve-vector-exp-ops.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +sve -target-feature +experimen
[PATCH] D145270: Add codegen for llvm exp/exp2 elementwise builtins
bob80905 created this revision. bob80905 added reviewers: python3kgae, beanz, fhahn. Herald added subscribers: luke, Anastasia, StephenFan, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb. Herald added a project: All. bob80905 requested review of this revision. Herald added subscribers: cfe-commits, pcwang-thead. Herald added a project: clang. Add codegen for llvm exp/exp2 elementwise builtin The exp/exp2 elementwise builtins are necessary for HLSL codegen. Tests were added to make sure that the expected errors are encountered when these functions are given inputs of incompatible types. The new builtins are restricted to floating point types only. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D145270 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-exp-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-exp-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -67,6 +67,20 @@ static_assert(!is_const::value); } +void test_builtin_elementwise_exp() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} + +void test_builtin_elementwise_exp2() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} + void test_builtin_elementwise_sin() { const float a = 42.0; float b = 42.3; Index: clang/test/Sema/riscv-sve-vector-exp-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-exp-ops.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: riscv-registered-target + +#include + + +vfloat32mf2_t test_exp_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_exp(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} + +vfloat32mf2_t test_exp2_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_exp2(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -311,6 +311,49 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_exp(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_exp(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_exp(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_exp(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_exp(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_exp(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_exp(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + +void test_builtin_elementwise_exp2(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_exp2(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_exp2(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_exp2(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_exp2(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_exp2(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_exp2(uv); + // expected-error@-1 {{1st a
[PATCH] D144309: [HLSL] add max/min library functions
This revision was automatically updated to reflect the committed changes. Closed by commit rG7ac0551e77f4: [HLSL] add max/min library functions (authored by bob80905). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144309/new/ https://reviews.llvm.org/D144309 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/max.hlsl clang/test/CodeGenHLSL/builtins/min.hlsl Index: clang/test/CodeGenHLSL/builtins/min.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/min.hlsl @@ -0,0 +1,223 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +#ifdef __HLSL_ENABLE_16_BIT +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.smin.i16( +// NO_HALF: define noundef i16 @"?test_min_short@@YAFFF@Z"( +// NO_HALF: call i16 @llvm.smin.i16( +int16_t test_min_short ( int16_t p0, int16_t p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.smin.v2i16( +// NO_HALF: define noundef <2 x i16> @"?test_min_short2@@YAT?$__vector@F$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x i16> @llvm.smin.v2i16( +int16_t2 test_min_short2 ( int16_t2 p0, int16_t2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.smin.v3i16 +// NO_HALF: define noundef <3 x i16> @"?test_min_short3@@YAT?$__vector@F$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x i16> @llvm.smin.v3i16( +int16_t3 test_min_short3 ( int16_t3 p0, int16_t3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.smin.v4i16 +// NO_HALF: define noundef <4 x i16> @"?test_min_short4@@YAT?$__vector@F$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x i16> @llvm.smin.v4i16( +int16_t4 test_min_short4 ( int16_t4 p0, int16_t4 p1 ) { + return min ( p0, p1 ); +} + + +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.umin.i16( +// NO_HALF: define noundef i16 @"?test_min_ushort@@YAGGG@Z"( +// NO_HALF: call i16 @llvm.umin.i16( +uint16_t test_min_ushort ( uint16_t p0, uint16_t p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.umin.v2i16 +// NO_HALF: define noundef <2 x i16> @"?test_min_ushort2@@YAT?$__vector@G$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x i16> @llvm.umin.v2i16( +uint16_t2 test_min_ushort2 ( uint16_t2 p0, uint16_t2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.umin.v3i16 +// NO_HALF: define noundef <3 x i16> @"?test_min_ushort3@@YAT?$__vector@G$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x i16> @llvm.umin.v3i16( +uint16_t3 test_min_ushort3 ( uint16_t3 p0, uint16_t3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.umin.v4i16 +// NO_HALF: define noundef <4 x i16> @"?test_min_ushort4@@YAT?$__vector@G$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x i16> @llvm.umin.v4i16( +uint16_t4 test_min_ushort4 ( uint16_t4 p0, uint16_t4 p1 ) { + return min ( p0, p1 ); +} +#endif + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.smin.i32( +int test_min_int ( int p0, int p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.smin.v2i32 +int2 test_min_int2 ( int2 p0, int2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.smin.v3i32 +int3 test_min_int3 ( int3 p0, int3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.smin.v4i32 +int4 test_min_int4 ( int4 p0, int4 p1) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.umin.i32( +int test_min_uint ( uint p0, uint p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.umin.v2i32 +uint2 test_min_uint2 ( uint2 p0, uint2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.umin.v3i32 +uint3 test_min_uint3 ( uint3 p0, uint3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.umin.v4i32 +uint4 test_min_uint4 ( uint4 p0, uint4 p1) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i64 @ +// CHECK: call i64 @llvm.smin.i64( +int64_t test_min_long ( int64_t p0, int64_t p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i64> @ +// CHECK: call <2 x i64> @llvm.smin.v2i64 +int64_t2 test_min_long2 ( int64_t2 p0, int64_t2 p1 ) { + re
[PATCH] D144309: [HLSL] add max/min library functions
bob80905 updated this revision to Diff 502009. bob80905 added a comment. - only run tests if 16 bit is enabled Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144309/new/ https://reviews.llvm.org/D144309 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/max.hlsl clang/test/CodeGenHLSL/builtins/min.hlsl Index: clang/test/CodeGenHLSL/builtins/min.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/min.hlsl @@ -0,0 +1,223 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +#ifdef __HLSL_ENABLE_16_BIT +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.smin.i16( +// NO_HALF: define noundef i16 @"?test_min_short@@YAFFF@Z"( +// NO_HALF: call i16 @llvm.smin.i16( +int16_t test_min_short ( int16_t p0, int16_t p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.smin.v2i16( +// NO_HALF: define noundef <2 x i16> @"?test_min_short2@@YAT?$__vector@F$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x i16> @llvm.smin.v2i16( +int16_t2 test_min_short2 ( int16_t2 p0, int16_t2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.smin.v3i16 +// NO_HALF: define noundef <3 x i16> @"?test_min_short3@@YAT?$__vector@F$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x i16> @llvm.smin.v3i16( +int16_t3 test_min_short3 ( int16_t3 p0, int16_t3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.smin.v4i16 +// NO_HALF: define noundef <4 x i16> @"?test_min_short4@@YAT?$__vector@F$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x i16> @llvm.smin.v4i16( +int16_t4 test_min_short4 ( int16_t4 p0, int16_t4 p1 ) { + return min ( p0, p1 ); +} + + +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.umin.i16( +// NO_HALF: define noundef i16 @"?test_min_ushort@@YAGGG@Z"( +// NO_HALF: call i16 @llvm.umin.i16( +uint16_t test_min_ushort ( uint16_t p0, uint16_t p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.umin.v2i16 +// NO_HALF: define noundef <2 x i16> @"?test_min_ushort2@@YAT?$__vector@G$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x i16> @llvm.umin.v2i16( +uint16_t2 test_min_ushort2 ( uint16_t2 p0, uint16_t2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.umin.v3i16 +// NO_HALF: define noundef <3 x i16> @"?test_min_ushort3@@YAT?$__vector@G$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x i16> @llvm.umin.v3i16( +uint16_t3 test_min_ushort3 ( uint16_t3 p0, uint16_t3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.umin.v4i16 +// NO_HALF: define noundef <4 x i16> @"?test_min_ushort4@@YAT?$__vector@G$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x i16> @llvm.umin.v4i16( +uint16_t4 test_min_ushort4 ( uint16_t4 p0, uint16_t4 p1 ) { + return min ( p0, p1 ); +} +#endif + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.smin.i32( +int test_min_int ( int p0, int p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.smin.v2i32 +int2 test_min_int2 ( int2 p0, int2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.smin.v3i32 +int3 test_min_int3 ( int3 p0, int3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.smin.v4i32 +int4 test_min_int4 ( int4 p0, int4 p1) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.umin.i32( +int test_min_uint ( uint p0, uint p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.umin.v2i32 +uint2 test_min_uint2 ( uint2 p0, uint2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.umin.v3i32 +uint3 test_min_uint3 ( uint3 p0, uint3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.umin.v4i32 +uint4 test_min_uint4 ( uint4 p0, uint4 p1) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i64 @ +// CHECK: call i64 @llvm.smin.i64( +int64_t test_min_long ( int64_t p0, int64_t p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i64> @ +// CHECK: call <2 x i64> @llvm.smin.v2i64 +int64_t2 test_min_long2 ( int64_t2 p0, int64_t2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i
[PATCH] D144309: [HLSL] add max/min library functions
bob80905 updated this revision to Diff 501963. bob80905 added a comment. - use already defined hlsl types Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144309/new/ https://reviews.llvm.org/D144309 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/max.hlsl clang/test/CodeGenHLSL/builtins/min.hlsl Index: clang/test/CodeGenHLSL/builtins/min.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/min.hlsl @@ -0,0 +1,220 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.smin.i16( +// NO_HALF: define noundef i16 @"?test_min_short@@YAFFF@Z"( +// NO_HALF: call i16 @llvm.smin.i16( +int16_t test_min_short ( int16_t p0, int16_t p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.smin.v2i16( +// NO_HALF: define noundef <2 x i16> @"?test_min_short2@@YAT?$__vector@F$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x i16> @llvm.smin.v2i16( +int16_t2 test_min_short2 ( int16_t2 p0, int16_t2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.smin.v3i16 +// NO_HALF: define noundef <3 x i16> @"?test_min_short3@@YAT?$__vector@F$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x i16> @llvm.smin.v3i16( +int16_t3 test_min_short3 ( int16_t3 p0, int16_t3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.smin.v4i16 +// NO_HALF: define noundef <4 x i16> @"?test_min_short4@@YAT?$__vector@F$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x i16> @llvm.smin.v4i16( +int16_t4 test_min_short4 ( int16_t4 p0, int16_t4 p1 ) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.umin.i16( +// NO_HALF: define noundef i16 @"?test_min_ushort@@YAGGG@Z"( +// NO_HALF: call i16 @llvm.umin.i16( +uint16_t test_min_ushort ( uint16_t p0, uint16_t p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.umin.v2i16 +// NO_HALF: define noundef <2 x i16> @"?test_min_ushort2@@YAT?$__vector@G$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x i16> @llvm.umin.v2i16( +uint16_t2 test_min_ushort2 ( uint16_t2 p0, uint16_t2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.umin.v3i16 +// NO_HALF: define noundef <3 x i16> @"?test_min_ushort3@@YAT?$__vector@G$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x i16> @llvm.umin.v3i16( +uint16_t3 test_min_ushort3 ( uint16_t3 p0, uint16_t3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.umin.v4i16 +// NO_HALF: define noundef <4 x i16> @"?test_min_ushort4@@YAT?$__vector@G$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x i16> @llvm.umin.v4i16( +uint16_t4 test_min_ushort4 ( uint16_t4 p0, uint16_t4 p1 ) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.smin.i32( +int test_min_int ( int p0, int p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.smin.v2i32 +int2 test_min_int2 ( int2 p0, int2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.smin.v3i32 +int3 test_min_int3 ( int3 p0, int3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.smin.v4i32 +int4 test_min_int4 ( int4 p0, int4 p1) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.umin.i32( +int test_min_uint ( uint p0, uint p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.umin.v2i32 +uint2 test_min_uint2 ( uint2 p0, uint2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.umin.v3i32 +uint3 test_min_uint3 ( uint3 p0, uint3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.umin.v4i32 +uint4 test_min_uint4 ( uint4 p0, uint4 p1) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i64 @ +// CHECK: call i64 @llvm.smin.i64( +int64_t test_min_long ( int64_t p0, int64_t p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i64> @ +// CHECK: call <2 x i64> @llvm.smin.v2i64 +int64_t2 test_min_long2 ( int64_t2 p0, int64_t2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i64> @ +// CHECK: call <3 x i64> @llvm.smin.v
[PATCH] D144309: [HLSL] add max/min library functions
bob80905 updated this revision to Diff 501933. bob80905 added a comment. - format Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144309/new/ https://reviews.llvm.org/D144309 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/max.hlsl clang/test/CodeGenHLSL/builtins/min.hlsl Index: clang/test/CodeGenHLSL/builtins/min.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/min.hlsl @@ -0,0 +1,220 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.smin.i16( +// NO_HALF: define noundef i16 @"?test_min_short@@YAFFF@Z"( +// NO_HALF: call i16 @llvm.smin.i16( +short test_min_short ( short p0, short p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.smin.v2i16( +// NO_HALF: define noundef <2 x i16> @"?test_min_short2@@YAT?$__vector@F$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x i16> @llvm.smin.v2i16( +short2 test_min_short2 ( short2 p0, short2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.smin.v3i16 +// NO_HALF: define noundef <3 x i16> @"?test_min_short3@@YAT?$__vector@F$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x i16> @llvm.smin.v3i16( +short3 test_min_short3 ( short3 p0, short3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.smin.v4i16 +// NO_HALF: define noundef <4 x i16> @"?test_min_short4@@YAT?$__vector@F$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x i16> @llvm.smin.v4i16( +short4 test_min_short4 ( short4 p0, short4 p1 ) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.umin.i16( +// NO_HALF: define noundef i16 @"?test_min_ushort@@YAGGG@Z"( +// NO_HALF: call i16 @llvm.umin.i16( +unsigned short test_min_ushort ( unsigned short p0, unsigned short p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.umin.v2i16 +// NO_HALF: define noundef <2 x i16> @"?test_min_ushort2@@YAT?$__vector@G$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x i16> @llvm.umin.v2i16( +ushort2 test_min_ushort2 ( ushort2 p0, ushort2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.umin.v3i16 +// NO_HALF: define noundef <3 x i16> @"?test_min_ushort3@@YAT?$__vector@G$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x i16> @llvm.umin.v3i16( +ushort3 test_min_ushort3 ( ushort3 p0, ushort3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.umin.v4i16 +// NO_HALF: define noundef <4 x i16> @"?test_min_ushort4@@YAT?$__vector@G$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x i16> @llvm.umin.v4i16( +ushort4 test_min_ushort4 ( ushort4 p0, ushort4 p1 ) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.smin.i32( +int test_min_int ( int p0, int p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.smin.v2i32 +int2 test_min_int2 ( int2 p0, int2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.smin.v3i32 +int3 test_min_int3 ( int3 p0, int3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.smin.v4i32 +int4 test_min_int4 ( int4 p0, int4 p1) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.umin.i32( +int test_min_uint ( uint p0, uint p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.umin.v2i32 +uint2 test_min_uint2 ( uint2 p0, uint2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.umin.v3i32 +uint3 test_min_uint3 ( uint3 p0, uint3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.umin.v4i32 +uint4 test_min_uint4 ( uint4 p0, uint4 p1) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i64 @ +// CHECK: call i64 @llvm.smin.i64( +long test_min_long ( long p0, long p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i64> @ +// CHECK: call <2 x i64> @llvm.smin.v2i64 +long2 test_min_long2 ( long2 p0, long2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i64> @ +// CHECK: call <3 x i64> @llvm.smin.v3i64 +long3 test_min_long3 ( long3 p0, long3 p1 ) { + return min
[PATCH] D144309: [HLSL] add max/min library functions
bob80905 updated this revision to Diff 501250. bob80905 added a comment. - ushort is now unsigned Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144309/new/ https://reviews.llvm.org/D144309 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/max.hlsl clang/test/CodeGenHLSL/builtins/min.hlsl Index: clang/test/CodeGenHLSL/builtins/min.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/min.hlsl @@ -0,0 +1,220 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.smin.i16( +// NO_HALF: define noundef i16 @"?test_min_short@@YAFFF@Z"( +// NO_HALF: call i16 @llvm.smin.i16( +short test_min_short ( short p0, short p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.smin.v2i16( +// NO_HALF: define noundef <2 x i16> @"?test_min_short2@@YAT?$__vector@F$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x i16> @llvm.smin.v2i16( +short2 test_min_short2 ( short2 p0, short2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.smin.v3i16 +// NO_HALF: define noundef <3 x i16> @"?test_min_short3@@YAT?$__vector@F$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x i16> @llvm.smin.v3i16( +short3 test_min_short3 ( short3 p0, short3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.smin.v4i16 +// NO_HALF: define noundef <4 x i16> @"?test_min_short4@@YAT?$__vector@F$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x i16> @llvm.smin.v4i16( +short4 test_min_short4 ( short4 p0, short4 p1 ) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.umin.i16( +// NO_HALF: define noundef i16 @"?test_min_ushort@@YAGGG@Z"( +// NO_HALF: call i16 @llvm.umin.i16( +unsigned short test_min_ushort ( unsigned short p0, unsigned short p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.umin.v2i16 +// NO_HALF: define noundef <2 x i16> @"?test_min_ushort2@@YAT?$__vector@G$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x i16> @llvm.umin.v2i16( +ushort2 test_min_ushort2 ( ushort2 p0, ushort2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.umin.v3i16 +// NO_HALF: define noundef <3 x i16> @"?test_min_ushort3@@YAT?$__vector@G$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x i16> @llvm.umin.v3i16( +ushort3 test_min_ushort3 ( ushort3 p0, ushort3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.umin.v4i16 +// NO_HALF: define noundef <4 x i16> @"?test_min_ushort4@@YAT?$__vector@G$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x i16> @llvm.umin.v4i16( +ushort4 test_min_ushort4 ( ushort4 p0, ushort4 p1 ) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.smin.i32( +int test_min_int ( int p0, int p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.smin.v2i32 +int2 test_min_int2 ( int2 p0, int2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.smin.v3i32 +int3 test_min_int3 ( int3 p0, int3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.smin.v4i32 +int4 test_min_int4 ( int4 p0, int4 p1) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.umin.i32( +int test_min_uint ( uint p0, uint p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.umin.v2i32 +uint2 test_min_uint2 ( uint2 p0, uint2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.umin.v3i32 +uint3 test_min_uint3 ( uint3 p0, uint3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.umin.v4i32 +uint4 test_min_uint4 ( uint4 p0, uint4 p1) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i64 @ +// CHECK: call i64 @llvm.smin.i64( +long test_min_long ( long p0, long p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i64> @ +// CHECK: call <2 x i64> @llvm.smin.v2i64 +long2 test_min_long2 ( long2 p0, long2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i64> @ +// CHECK: call <3 x i64> @llvm.smin.v3i64 +long3 test_min_long3 ( long3 p0, long3 p1 )
[PATCH] D144309: [HLSL] add max/min library functions
bob80905 updated this revision to Diff 501248. bob80905 added a comment. - add support for these types: i16/u16/i32/u32/i64/u64/f16/f32/f64 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144309/new/ https://reviews.llvm.org/D144309 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/max.hlsl clang/test/CodeGenHLSL/builtins/min.hlsl Index: clang/test/CodeGenHLSL/builtins/min.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/min.hlsl @@ -0,0 +1,220 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.smin.i16( +// NO_HALF: define noundef i16 @"?test_min_short@@YAFFF@Z"( +// NO_HALF: call i16 @llvm.smin.i16( +short test_min_short ( short p0, short p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.smin.v2i16( +// NO_HALF: define noundef <2 x i16> @"?test_min_short2@@YAT?$__vector@F$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x i16> @llvm.smin.v2i16( +short2 test_min_short2 ( short2 p0, short2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.smin.v3i16 +// NO_HALF: define noundef <3 x i16> @"?test_min_short3@@YAT?$__vector@F$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x i16> @llvm.smin.v3i16( +short3 test_min_short3 ( short3 p0, short3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.smin.v4i16 +// NO_HALF: define noundef <4 x i16> @"?test_min_short4@@YAT?$__vector@F$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x i16> @llvm.smin.v4i16( +short4 test_min_short4 ( short4 p0, short4 p1 ) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i16 @ +// CHECK: call i16 @llvm.umin.i16( +// NO_HALF: define noundef i16 @"?test_min_ushort@@YAGGG@Z"( +// NO_HALF: call i16 @llvm.umin.i16( +unsigned short test_min_ushort ( unsigned short p0, unsigned short p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i16> @ +// CHECK: call <2 x i16> @llvm.smin.v2i16 +// NO_HALF: define noundef <2 x i16> @"?test_min_ushort2@@YAT?$__vector@F$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x i16> @llvm.smin.v2i16( +ushort2 test_min_ushort2 ( ushort2 p0, ushort2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i16> @ +// CHECK: call <3 x i16> @llvm.smin.v3i16 +// NO_HALF: define noundef <3 x i16> @"?test_min_ushort3@@YAT?$__vector@F$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x i16> @llvm.smin.v3i16( +ushort3 test_min_ushort3 ( ushort3 p0, ushort3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i16> @ +// CHECK: call <4 x i16> @llvm.smin.v4i16 +// NO_HALF: define noundef <4 x i16> @"?test_min_ushort4@@YAT?$__vector@F$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x i16> @llvm.smin.v4i16( +ushort4 test_min_ushort4 ( ushort4 p0, ushort4 p1 ) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.smin.i32( +int test_min_int ( int p0, int p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.smin.v2i32 +int2 test_min_int2 ( int2 p0, int2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.smin.v3i32 +int3 test_min_int3 ( int3 p0, int3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.smin.v4i32 +int4 test_min_int4 ( int4 p0, int4 p1) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.umin.i32( +int test_min_uint ( uint p0, uint p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.umin.v2i32 +uint2 test_min_uint2 ( uint2 p0, uint2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.umin.v3i32 +uint3 test_min_uint3 ( uint3 p0, uint3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.umin.v4i32 +uint4 test_min_uint4 ( uint4 p0, uint4 p1) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i64 @ +// CHECK: call i64 @llvm.smin.i64( +long test_min_long ( long p0, long p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i64> @ +// CHECK: call <2 x i64> @llvm.smin.v2i64 +long2 test_min_long2 ( long2 p0, long2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i64> @ +// CHECK: call <3 x i64> @llvm.smin.v3i64 +lo
[PATCH] D144309: [HLSL] add max/min library functions
bob80905 updated this revision to Diff 500953. bob80905 added a comment. add int support for max/min. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144309/new/ https://reviews.llvm.org/D144309 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/max.hlsl clang/test/CodeGenHLSL/builtins/min.hlsl Index: clang/test/CodeGenHLSL/builtins/min.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/min.hlsl @@ -0,0 +1,77 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.minnum.f16( +// NO_HALF: define noundef float @"?test_min_half@@YA$halff@$halff@0@Z"( +// NO_HALF: call float @llvm.minnum.f32( +half test_min_half ( half p0, half p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.minnum.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_min_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x float> @llvm.minnum.v2f32( +half2 test_min_half2 ( half2 p0, half2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.minnum.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_min_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x float> @llvm.minnum.v3f32( +half3 test_min_half3 ( half3 p0, half3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.minnum.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_min_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x float> @llvm.minnum.v4f32( +half4 test_min_half4 ( half4 p0, half4 p1 ) { + return min ( p0, p1 ); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.minnum.f32( +float test_min_float ( float p0, float p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.minnum.v2f32 +float2 test_min_float2 ( float2 p0, float2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.minnum.v3f32 +float3 test_min_float3 ( float3 p0, float3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x float> @ +// CHECK: call <4 x float> @llvm.minnum.v4f32 +float4 test_min_float4 ( float4 p0, float4 p1) { + return min ( p0, p1 ); +} + +// CHECK: define noundef i32 @ +// CHECK: call i32 @llvm.smin.i32( +int test_min_int ( int p0, int p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x i32> @ +// CHECK: call <2 x i32> @llvm.smin.v2i32 +int2 test_min_int2 ( int2 p0, int2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x i32> @ +// CHECK: call <3 x i32> @llvm.smin.v3i32 +int3 test_min_int3 ( int3 p0, int3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x i32> @ +// CHECK: call <4 x i32> @llvm.smin.v4i32 +int4 test_min_int4 ( int4 p0, int4 p1) { + return min ( p0, p1 ); +} Index: clang/test/CodeGenHLSL/builtins/max.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/max.hlsl @@ -0,0 +1,77 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.maxnum.f16( +// NO_HALF: define noundef float @"?test_max_half@@YA$halff@$halff@0@Z"( +// NO_HALF: call float @llvm.maxnum.f32( +half test_max_half ( half p0, half p1 ) { + return max ( p0, p1 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.maxnum.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_max_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x float> @llvm.maxnum.v2f32( +half2 test_max_half2 ( half2 p0, half2 p1 ) { + return max ( p0, p1 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.maxnum.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_max_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x float> @llvm.maxnum.v3f32( +half3 test_max_half3 ( half3 p0, half3 p1 ) { + return max ( p0, p1 ); +} +// CHECK: define noundef <4 x
[PATCH] D144802: clang: Add __builtin_elementwise_round
bob80905 added a comment. Should the addition of this builtin be mentioned in clang\docs\ReleaseNotes.rst? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144802/new/ https://reviews.llvm.org/D144802 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144309: [HLSL] add max/min library functions
bob80905 added inline comments. Comment at: clang/test/CodeGenHLSL/builtins/min.hlsl:10 +// CHECK: call half @llvm.minnum.f16( +// NO_HALF: define noundef float @"?test_min_half@@YA$halff@$halff@0@Z"( +// NO_HALF: call float @llvm.minnum.f32( I had to add a 0 here for the NO_HALF case for all these tests, which is unlike what I had to do for previous tests. Not sure why, but thought I would point it out. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144309/new/ https://reviews.llvm.org/D144309 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D144309: add max/min lib fxns
bob80905 created this revision. bob80905 added reviewers: python3kgae, beanz. 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. [HLSL] add max/min library functions This change exposes the max and min library functions for HLSL, excluding long, int, and long long doubles. The max / min functions are supported for all scalar, vector, and matrix types. Long and long long double support is missing in this patch because those types don't exist in HLSL. Int is missing because the max / min functions only work on floating type arguments. The full documentation of the HLSL max / min functions are available here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-max https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-min Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D144309 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/max.hlsl clang/test/CodeGenHLSL/builtins/min.hlsl Index: clang/test/CodeGenHLSL/builtins/min.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/min.hlsl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.minnum.f16( +// NO_HALF: define noundef float @"?test_min_half@@YA$halff@$halff@0@Z"( +// NO_HALF: call float @llvm.minnum.f32( +half test_min_half ( half p0, half p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.minnum.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_min_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x float> @llvm.minnum.v2f32( +half2 test_min_half2 ( half2 p0, half2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.minnum.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_min_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"( +// NO_HALF: call <3 x float> @llvm.minnum.v3f32( +half3 test_min_half3 ( half3 p0, half3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.minnum.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_min_float4@@YAT?$__vector@M$03@__clang@@T12@0@Z"( +// NO_HALF: call <4 x float> @llvm.minnum.v4f32( +half4 test_min_half4 ( half4 p0, half4 p1 ) { + return min ( p0, p1 ); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.minnum.f32( +float test_min_float ( float p0, float p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.minnum.v2f32 +float2 test_min_float2 ( float2 p0, float2 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.minnum.v3f32 +float3 test_min_float3 ( float3 p0, float3 p1 ) { + return min ( p0, p1 ); +} +// CHECK: define noundef <4 x float> @ +// CHECK: call <4 x float> @llvm.minnum.v4f32 +float4 test_min_float4 ( float4 p0, float4 p1) { + return min ( p0, p1 ); +} Index: clang/test/CodeGenHLSL/builtins/max.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/max.hlsl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.maxnum.f16( +// NO_HALF: define noundef float @"?test_max_half@@YA$halff@$halff@0@Z"( +// NO_HALF: call float @llvm.maxnum.f32( +half test_max_half ( half p0, half p1 ) { + return max ( p0, p1 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.maxnum.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_max_float2@@YAT?$__vector@M$01@__clang@@T12@0@Z"( +// NO_HALF: call <2 x float> @llvm.maxnum.v2f32( +half2 test_max_half2 ( half2 p0, half2 p1 ) { + return max ( p0, p1 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.maxnum.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_max_float3@@YAT?$__vector@M$02@__clang@@T12@0@Z"( +// NO_HAL
[PATCH] D144120: [HLSL] add log library functions
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGf842b7a6b8f4: [HLSL] add log library functions (authored by bob80905). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144120/new/ https://reviews.llvm.org/D144120 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/log.hlsl clang/test/CodeGenHLSL/builtins/log10.hlsl clang/test/CodeGenHLSL/builtins/log2.hlsl Index: clang/test/CodeGenHLSL/builtins/log2.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/log2.hlsl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.log2.f16( +// NO_HALF: define noundef float @"?test_log2_half@@YA$halff@$halff@@Z"( +// NO_HALF: call float @llvm.log2.f32( +half test_log2_half ( half p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.log2.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_log2_float2@@YAT?$__vector@M$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x float> @llvm.log2.v2f32( +half2 test_log2_half2 ( half2 p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.log2.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_log2_float3@@YAT?$__vector@M$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x float> @llvm.log2.v3f32( +half3 test_log2_half3 ( half3 p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.log2.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_log2_float4@@YAT?$__vector@M$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x float> @llvm.log2.v4f32( +half4 test_log2_half4 ( half4 p0 ) { + return log2 ( p0 ); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.log2.f32( +float test_log2_float ( float p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.log2.v2f32 +float2 test_log2_float2 ( float2 p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.log2.v3f32 +float3 test_log2_float3 ( float3 p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <4 x float> @ +// CHECK: call <4 x float> @llvm.log2.v4f32 +float4 test_log2_float4 ( float4 p0 ) { + return log2 ( p0 ); +} Index: clang/test/CodeGenHLSL/builtins/log10.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/log10.hlsl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.log10.f16( +// NO_HALF: define noundef float @"?test_log10_half@@YA$halff@$halff@@Z"( +// NO_HALF: call float @llvm.log10.f32( +half test_log10_half ( half p0 ) { + return log10 ( p0 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.log10.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_log10_float2@@YAT?$__vector@M$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x float> @llvm.log10.v2f32( +half2 test_log10_half2 ( half2 p0 ) { + return log10 ( p0 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.log10.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_log10_float3@@YAT?$__vector@M$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x float> @llvm.log10.v3f32( +half3 test_log10_half3 ( half3 p0 ) { + return log10 ( p0 ); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.log10.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_log10_float4@@YAT?$__vector@M$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x float> @llvm.log10.v4f32( +half4 test_log10_half4 ( half4 p0 ) { + return log10 ( p0 ); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.log10.f32( +float test_log10_float ( float p0 ) { + return log10 ( p0 ); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.log10.v2f32 +float2 test_log10_float2 ( float2 p0 ) { + return log10 ( p0 ); +} +// CHECK: defin
[PATCH] D144120: [HLSL] add log library functions
bob80905 updated this revision to Diff 498051. bob80905 added a comment. - add newline Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D144120/new/ https://reviews.llvm.org/D144120 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/log.hlsl clang/test/CodeGenHLSL/builtins/log10.hlsl clang/test/CodeGenHLSL/builtins/log2.hlsl Index: clang/test/CodeGenHLSL/builtins/log2.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/log2.hlsl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.log2.f16( +// NO_HALF: define noundef float @"?test_log2_half@@YA$halff@$halff@@Z"( +// NO_HALF: call float @llvm.log2.f32( +half test_log2_half ( half p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.log2.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_log2_float2@@YAT?$__vector@M$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x float> @llvm.log2.v2f32( +half2 test_log2_half2 ( half2 p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.log2.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_log2_float3@@YAT?$__vector@M$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x float> @llvm.log2.v3f32( +half3 test_log2_half3 ( half3 p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.log2.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_log2_float4@@YAT?$__vector@M$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x float> @llvm.log2.v4f32( +half4 test_log2_half4 ( half4 p0 ) { + return log2 ( p0 ); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.log2.f32( +float test_log2_float ( float p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.log2.v2f32 +float2 test_log2_float2 ( float2 p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.log2.v3f32 +float3 test_log2_float3 ( float3 p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <4 x float> @ +// CHECK: call <4 x float> @llvm.log2.v4f32 +float4 test_log2_float4 ( float4 p0 ) { + return log2 ( p0 ); +} Index: clang/test/CodeGenHLSL/builtins/log10.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/log10.hlsl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.log10.f16( +// NO_HALF: define noundef float @"?test_log10_half@@YA$halff@$halff@@Z"( +// NO_HALF: call float @llvm.log10.f32( +half test_log10_half ( half p0 ) { + return log10 ( p0 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.log10.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_log10_float2@@YAT?$__vector@M$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x float> @llvm.log10.v2f32( +half2 test_log10_half2 ( half2 p0 ) { + return log10 ( p0 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.log10.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_log10_float3@@YAT?$__vector@M$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x float> @llvm.log10.v3f32( +half3 test_log10_half3 ( half3 p0 ) { + return log10 ( p0 ); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.log10.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_log10_float4@@YAT?$__vector@M$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x float> @llvm.log10.v4f32( +half4 test_log10_half4 ( half4 p0 ) { + return log10 ( p0 ); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.log10.f32( +float test_log10_float ( float p0 ) { + return log10 ( p0 ); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.log10.v2f32 +float2 test_log10_float2 ( float2 p0 ) { + return log10 ( p0 ); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.log10.v3f32 +float3 test_log10_float3 ( float3 p0 ) { + return log10 ( p0
[PATCH] D144120: [HLSL] add log library functions This change exposes the log library functions for HLSL, excluding long, int, and long long doubles. The log functions are supported for all scalar, ve
bob80905 created this revision. 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. ...missing in this patch because those types don't exist in HLSL. Int is missing because the log functions only work on floating type arguments. The full documentation of the HLSL log functions are available here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-log https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-log2 https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-log10 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D144120 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/log.hlsl clang/test/CodeGenHLSL/builtins/log10.hlsl clang/test/CodeGenHLSL/builtins/log2.hlsl Index: clang/test/CodeGenHLSL/builtins/log2.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/log2.hlsl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.log2.f16( +// NO_HALF: define noundef float @"?test_log2_half@@YA$halff@$halff@@Z"( +// NO_HALF: call float @llvm.log2.f32( +half test_log2_half ( half p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.log2.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_log2_float2@@YAT?$__vector@M$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x float> @llvm.log2.v2f32( +half2 test_log2_half2 ( half2 p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.log2.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_log2_float3@@YAT?$__vector@M$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x float> @llvm.log2.v3f32( +half3 test_log2_half3 ( half3 p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.log2.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_log2_float4@@YAT?$__vector@M$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x float> @llvm.log2.v4f32( +half4 test_log2_half4 ( half4 p0 ) { + return log2 ( p0 ); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.log2.f32( +float test_log2_float ( float p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.log2.v2f32 +float2 test_log2_float2 ( float2 p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.log2.v3f32 +float3 test_log2_float3 ( float3 p0 ) { + return log2 ( p0 ); +} +// CHECK: define noundef <4 x float> @ +// CHECK: call <4 x float> @llvm.log2.v4f32 +float4 test_log2_float4 ( float4 p0 ) { + return log2 ( p0 ); +} \ No newline at end of file Index: clang/test/CodeGenHLSL/builtins/log10.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/log10.hlsl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.log10.f16( +// NO_HALF: define noundef float @"?test_log10_half@@YA$halff@$halff@@Z"( +// NO_HALF: call float @llvm.log10.f32( +half test_log10_half ( half p0 ) { + return log10 ( p0 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.log10.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_log10_float2@@YAT?$__vector@M$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x float> @llvm.log10.v2f32( +half2 test_log10_half2 ( half2 p0 ) { + return log10 ( p0 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.log10.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_log10_float3@@YAT?$__vector@M$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x float> @llvm.log10.v3f32( +half3 test_log10_half3 ( half3 p0 ) { + return log10 ( p0 ); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.log10.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_log10_float4@@YAT?$__vector@M$03@__clang@@T12@@Z"( +// NO_HA
[PATCH] D143207: Add codegen for llvm log2/log10 elementwise builtins
This revision was automatically updated to reflect the committed changes. Closed by commit rG836249b1c2f0: Add codegen for llvm log2/log10 elementwise builtins (authored by bob80905). Changed prior to commit: https://reviews.llvm.org/D143207?vs=494477&id=495612#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D143207/new/ https://reviews.llvm.org/D143207 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-log-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-log-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -80,3 +80,17 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_log10() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} + +void test_builtin_elementwise_log2() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-log-ops.c === --- clang/test/Sema/riscv-sve-vector-log-ops.c +++ clang/test/Sema/riscv-sve-vector-log-ops.c @@ -11,3 +11,15 @@ return __builtin_elementwise_log(v); // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} } + +vfloat32mf2_t test_log10_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_log10(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} + +vfloat32mf2_t test_log2_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_log2(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -351,6 +351,48 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_log10(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_log10(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_log10(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_log10(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_log10(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_log10(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_log10(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + +void test_builtin_elementwise_log2(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_log2(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_log2(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_log2(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_log2(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_log2(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_log2(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_roundeven(f); Index: clang/test/Sema/aarch64-sve-vector-log-ops.c === --- clang/test/Sema/aarch64-sve-vector-log-ops.c +++ clang/test/Sema/aarch64-sve-vector-log-ops.c @@ -10,3 +10,15 @@ return __builtin_elementwise_log(v); // expected-error@-1 {{1st argument must be a vector, integer or floating
[PATCH] D143207: Add codegen for llvm log10 elementwise builtin
bob80905 updated this revision to Diff 494477. bob80905 added a comment. - add log2 as well Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D143207/new/ https://reviews.llvm.org/D143207 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-log-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-log-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -80,3 +80,17 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_log10() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} + +void test_builtin_elementwise_log2() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-log-ops.c === --- clang/test/Sema/riscv-sve-vector-log-ops.c +++ clang/test/Sema/riscv-sve-vector-log-ops.c @@ -11,3 +11,15 @@ return __builtin_elementwise_log(v); // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} } + +vfloat32mf2_t test_log10_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_log10(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} + +vfloat32mf2_t test_log2_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_log2(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -351,6 +351,48 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_log10(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_log10(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_log10(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_log10(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_log10(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_log10(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_log10(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + +void test_builtin_elementwise_log2(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_log2(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_log2(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_log2(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_log2(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_log2(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_log2(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_roundeven(f); Index: clang/test/Sema/aarch64-sve-vector-log-ops.c === --- clang/test/Sema/aarch64-sve-vector-log-ops.c +++ clang/test/Sema/aarch64-sve-vector-log-ops.c @@ -10,3 +10,15 @@ return __builtin_elementwise_log(v); // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} } + +svfloat32_t test_log10_vv_i8mf8(svfloat32_t v) { + + return __builtin_elementwise_log10(v); + // expected-error@-1 {{1st argument must be a vector, intege
[PATCH] D143207: Add codegen for llvm log10 elementwise builtin
bob80905 updated this revision to Diff 494471. bob80905 added a comment. include first commit Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D143207/new/ https://reviews.llvm.org/D143207 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-log-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-log-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -80,3 +80,10 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_log10() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} \ No newline at end of file Index: clang/test/Sema/riscv-sve-vector-log-ops.c === --- clang/test/Sema/riscv-sve-vector-log-ops.c +++ clang/test/Sema/riscv-sve-vector-log-ops.c @@ -11,3 +11,9 @@ return __builtin_elementwise_log(v); // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} } + +vfloat32mf2_t test_log10_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_log10(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -351,6 +351,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_log10(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_log10(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_log10(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_log10(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_log10(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_log10(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_log10(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_roundeven(f); Index: clang/test/Sema/aarch64-sve-vector-log-ops.c === --- clang/test/Sema/aarch64-sve-vector-log-ops.c +++ clang/test/Sema/aarch64-sve-vector-log-ops.c @@ -10,3 +10,9 @@ return __builtin_elementwise_log(v); // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} } + +svfloat32_t test_log10_vv_i8mf8(svfloat32_t v) { + + return __builtin_elementwise_log10(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} \ No newline at end of file Index: clang/test/CodeGen/builtins-elementwise-math.c === --- clang/test/CodeGen/builtins-elementwise-math.c +++ clang/test/CodeGen/builtins-elementwise-math.c @@ -383,6 +383,22 @@ vf2 = __builtin_elementwise_log(vf1); } +void test_builtin_elementwise_log10(float f1, float f2, double d1, double d2, + float4 vf1, float4 vf2) { + // CHECK-LABEL: define void @test_builtin_elementwise_log10( + // CHECK: [[F1:%.+]] = load float, ptr %f1.addr, align 4 + // CHECK-NEXT: call float @llvm.log10.f32(float [[F1]]) + f2 = __builtin_elementwise_log10(f1); + + // CHECK: [[D1:%.+]] = load double, ptr %d1.addr, align 8 + // CHECK-NEXT: call double @llvm.log10.f64(double [[D1]]) + d2 = __builtin_elementwise_log10(d1); + + // CHECK: [[VF1:%.+]] = load <4 x float>, ptr %vf1.addr, align 16 + // CHECK-NEXT: call <4 x float> @llvm.log10.v4f32(<4 x float> [[VF1]]) + vf2 = __builtin_elementwise_log10(vf1); +} + void test_builtin_elementwise_roundeven(float f1, float f2, double d1, double d2, float4 vf1, float4 vf2) { // CHECK-LABEL: define
[PATCH] D143207: Add codegen for llvm log10 elementwise builtin
bob80905 updated this revision to Diff 494470. bob80905 added a comment. add release note line Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D143207/new/ https://reviews.llvm.org/D143207 Files: clang/docs/ReleaseNotes.rst Index: clang/docs/ReleaseNotes.rst === --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -184,6 +184,7 @@ Floating Point Support in Clang --- - Add ``__builtin_elementwise_log``builtin for floating point types only. +- Add ``__builtin_elementwise_log10`` builtin for floating point types only. Internal API Changes Index: clang/docs/ReleaseNotes.rst === --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -184,6 +184,7 @@ Floating Point Support in Clang --- - Add ``__builtin_elementwise_log``builtin for floating point types only. +- Add ``__builtin_elementwise_log10`` builtin for floating point types only. Internal API Changes ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D143231: add release note line
bob80905 created this revision. Herald added a project: All. bob80905 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D143231 Files: clang/docs/ReleaseNotes.rst Index: clang/docs/ReleaseNotes.rst === --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -184,6 +184,7 @@ Floating Point Support in Clang --- - Add ``__builtin_elementwise_log``builtin for floating point types only. +- Add ``__builtin_elementwise_log10`` builtin for floating point types only. Internal API Changes Index: clang/docs/ReleaseNotes.rst === --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -184,6 +184,7 @@ Floating Point Support in Clang --- - Add ``__builtin_elementwise_log``builtin for floating point types only. +- Add ``__builtin_elementwise_log10`` builtin for floating point types only. Internal API Changes ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D143208: Repair sphinx doc generation
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGa11a6752c15b: Repair sphinx doc generation (authored by bob80905). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D143208/new/ https://reviews.llvm.org/D143208 Files: clang/docs/ReleaseNotes.rst Index: clang/docs/ReleaseNotes.rst === --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -186,7 +186,7 @@ Floating Point Support in Clang --- -- Add ``__builtin_elementwise_log``builtin for floating point types only. +- Add ``__builtin_elementwise_log`` builtin for floating point types only. Internal API Changes Index: clang/docs/ReleaseNotes.rst === --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -186,7 +186,7 @@ Floating Point Support in Clang --- -- Add ``__builtin_elementwise_log``builtin for floating point types only. +- Add ``__builtin_elementwise_log`` builtin for floating point types only. Internal API Changes ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D143208: Repair sphinx doc generation
bob80905 created this revision. bob80905 added reviewers: beanz, python3kgae. Herald added a project: All. bob80905 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. mistake in the log commit neglected to place a space after the `` literal, which messed up the build by incapacitating the sphinx generator. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D143208 Files: clang/docs/ReleaseNotes.rst Index: clang/docs/ReleaseNotes.rst === --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -183,7 +183,7 @@ Floating Point Support in Clang --- -- Add ``__builtin_elementwise_log``builtin for floating point types only. +- Add ``__builtin_elementwise_log`` builtin for floating point types only. Internal API Changes Index: clang/docs/ReleaseNotes.rst === --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -183,7 +183,7 @@ Floating Point Support in Clang --- -- Add ``__builtin_elementwise_log``builtin for floating point types only. +- Add ``__builtin_elementwise_log`` builtin for floating point types only. Internal API Changes ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D143207: Add codegen for llvm log10 elementwise builtin
bob80905 created this revision. bob80905 added reviewers: python3kgae, beanz, craig.topper, fhahn. Herald added subscribers: luke, Anastasia, StephenFan, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb. Herald added a project: All. bob80905 requested review of this revision. Herald added subscribers: cfe-commits, pcwang-thead. Herald added a project: clang. Add codegen for llvm log10 elementwise builtin The log10 elementwise builtin is necessary for HLSL codegen. Tests were added to make sure that the expected errors are encountered when these functions are given inputs of incompatible types. The new builtin is restricted to floating point types only. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D143207 Files: clang/docs/LanguageExtensions.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-log-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-log-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -80,3 +80,10 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_log10() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} \ No newline at end of file Index: clang/test/Sema/riscv-sve-vector-log-ops.c === --- clang/test/Sema/riscv-sve-vector-log-ops.c +++ clang/test/Sema/riscv-sve-vector-log-ops.c @@ -11,3 +11,9 @@ return __builtin_elementwise_log(v); // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} } + +vfloat32mf2_t test_log10_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_log10(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -351,6 +351,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_log10(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_log10(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_log10(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_log10(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_log10(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_log10(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_log10(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_roundeven(f); Index: clang/test/Sema/aarch64-sve-vector-log-ops.c === --- clang/test/Sema/aarch64-sve-vector-log-ops.c +++ clang/test/Sema/aarch64-sve-vector-log-ops.c @@ -10,3 +10,9 @@ return __builtin_elementwise_log(v); // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} } + +svfloat32_t test_log10_vv_i8mf8(svfloat32_t v) { + + return __builtin_elementwise_log10(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} \ No newline at end of file Index: clang/test/CodeGen/builtins-elementwise-math.c === --- clang/test/CodeGen/builtins-elementwise-math.c +++ clang/test/CodeGen/builtins-elementwise-math.c @@ -383,6 +383,22 @@ vf2 = __builtin_elementwise_log(vf1); } +void test_builtin_elementwise_log10(float f1, float f2, double d1, double d2, + float4 vf1, float4 vf2) { + // CHECK-LABEL: define void @test_builtin_elementwise_log10( + // CHECK: [[F1:%.+]] = load float, ptr %f1.addr, align 4 + // CHECK-NE
[PATCH] D140489: Add builtin_elementwise_log
This revision was automatically updated to reflect the committed changes. Closed by commit rG26eb70820fb8: Add builtin_elementwise_log (authored by bob80905). Changed prior to commit: https://reviews.llvm.org/D140489?vs=492581&id=494389#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140489/new/ https://reviews.llvm.org/D140489 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-log-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-log-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -73,3 +73,10 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_log() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-log-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-log-ops.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: riscv-registered-target + +#include + + +vfloat32mf2_t test_log_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_log(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -330,6 +330,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_log(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_log(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_log(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_log(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_log(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_log(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_log(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_roundeven(f); Index: clang/test/Sema/aarch64-sve-vector-log-ops.c === --- /dev/null +++ clang/test/Sema/aarch64-sve-vector-log-ops.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +sve -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: aarch64-registered-target + +#include + +svfloat32_t test_log_vv_i8mf8(svfloat32_t v) { + + return __builtin_elementwise_log(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/CodeGen/builtins-elementwise-math.c === --- clang/test/CodeGen/builtins-elementwise-math.c +++ clang/test/CodeGen/builtins-elementwise-math.c @@ -367,6 +367,22 @@ vf2 = __builtin_elementwise_floor(vf1); } +void test_builtin_elementwise_log(float f1, float f2, double d1, double d2, + float4 vf1, float4 vf2) { + // CHECK-LABEL: define void @test_builtin_elementwise_log( + // CHECK: [[F1:%.+]] = load float, ptr %f1.addr, align 4 + // CHECK-NEXT: call float @llvm.log.f32(float [[F1]]) + f2 = __builtin_elementwise_log(f1); + + // CHECK: [[D1:%.+]] = load double, ptr %d1.addr, align 8 + // CHECK-NEXT: call double @llvm.log.f64(double [[D1]]) + d2 = __builtin_elementwise_log(d1); + + // CHECK: [[VF1:%.+]] = load <4 x float>, ptr %vf1.addr, ali
[PATCH] D140489: Add builtin_elementwise_log
bob80905 updated this revision to Diff 492581. bob80905 added a comment. remove unrelated commit Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140489/new/ https://reviews.llvm.org/D140489 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-log-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-log-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -73,3 +73,10 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_log() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-log-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-log-ops.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: riscv-registered-target + +#include + + +vfloat32mf2_t test_log_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_log(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -322,6 +322,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_log(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_log(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_log(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_log(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_log(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_log(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_log(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_roundeven(f); Index: clang/test/Sema/aarch64-sve-vector-log-ops.c === --- /dev/null +++ clang/test/Sema/aarch64-sve-vector-log-ops.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +sve -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: aarch64-registered-target + +#include + +svfloat32_t test_log_vv_i8mf8(svfloat32_t v) { + + return __builtin_elementwise_log(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/CodeGen/builtins-elementwise-math.c === --- clang/test/CodeGen/builtins-elementwise-math.c +++ clang/test/CodeGen/builtins-elementwise-math.c @@ -365,6 +365,22 @@ vf2 = __builtin_elementwise_floor(vf1); } +void test_builtin_elementwise_log(float f1, float f2, double d1, double d2, + float4 vf1, float4 vf2) { + // CHECK-LABEL: define void @test_builtin_elementwise_log( + // CHECK: [[F1:%.+]] = load float, ptr %f1.addr, align 4 + // CHECK-NEXT: call float @llvm.log.f32(float [[F1]]) + f2 = __builtin_elementwise_log(f1); + + // CHECK: [[D1:%.+]] = load double, ptr %d1.addr, align 8 + // CHECK-NEXT: call double @llvm.log.f64(double [[D1]]) + d2 = __builtin_elementwise_log(d1); + + // CHECK: [[VF1:%.+]] = load <4 x float>, ptr %vf1.addr, align 16 + // CHECK-NEXT: call <4 x float> @llvm.log.v4f32(<4 x float> [[VF1]]) + vf2 = __builtin_elementwise_log(vf1); +} + void test_builtin_ele
[PATCH] D140489: Add builtin_elementwise_log
bob80905 added a comment. Ping Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140489/new/ https://reviews.llvm.org/D140489 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D140489: Add builtin_elementwise_log
bob80905 added a comment. Herald added a subscriber: luke. Ping, can someone please take a look? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140489/new/ https://reviews.llvm.org/D140489 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D140489: Add builtin_elementwise_log
bob80905 updated this revision to Diff 488339. bob80905 added a comment. Herald added a reviewer: NoQ. - replace sin fxn with log Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140489/new/ https://reviews.llvm.org/D140489 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/Analysis/UnsafeBufferUsage.cpp clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-log-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-log-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp clang/test/SemaCXX/warn-unsafe-buffer-usage-crashes.c Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-crashes.c === --- /dev/null +++ clang/test/SemaCXX/warn-unsafe-buffer-usage-crashes.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -Wunsafe-buffer-usage %s -verify %s + +void gnu_stmtexpr_crash(void) { + struct A {}; + struct B { +struct A a; + }; + + struct B b = {{ +// This is a statement-expression (GNU extension). +({ int x; }) // no-crash // expected-warning{{excess elements in struct initializer}} + }}; +} Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -73,3 +73,10 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_log() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-log-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-log-ops.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: riscv-registered-target + +#include + + +vfloat32mf2_t test_log_vv_i8mf8(vfloat32mf2_t v) { + + return __builtin_elementwise_log(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -322,6 +322,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_log(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_log(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_log(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_log(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_log(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_log(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_log(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_roundeven(f); Index: clang/test/Sema/aarch64-sve-vector-log-ops.c === --- /dev/null +++ clang/test/Sema/aarch64-sve-vector-log-ops.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +sve -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: aarch64-registered-target + +#include + +svfloat32_t test_log_vv_i8mf8(svfloat32_t v) { + + return __builtin_elementwise_log(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/CodeGen/builtins-elementwise-math.c === --- clang/test/CodeGen/builtins-elementwise-math.c +++ clang/test/CodeGen/builtins-elementwise-math.c @@ -365,6 +365,22 @@ vf2 = __builtin_elementwise_floor(vf1); } +void test_builtin_elementwise_log(float f1, float f2, double d1, double
[PATCH] D140489: Add builtin_elementwise_log
bob80905 added a comment. Ping Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140489/new/ https://reviews.llvm.org/D140489 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D140992: clang: Add __builtin_elementwise_fma
bob80905 added inline comments. Comment at: clang/lib/Sema/SemaChecking.cpp:2615 QualType ArgTy = TheCall->getArg(0)->getType(); -QualType EltTy = ArgTy; - -if (auto *VecTy = EltTy->getAs()) - EltTy = VecTy->getElementType(); -if (!EltTy->isFloatingType()) { - Diag(TheCall->getArg(0)->getBeginLoc(), - diag::err_builtin_invalid_arg_type) - << 1 << /* float ty*/ 5 << ArgTy; - +if (checkFPMathBuiltinElementType(*this, TheCall->getArg(0)->getBeginLoc(), + ArgTy, 1)) This change appears to allow more types (such as integers) as args for this set of builtins in the above cases, where before the behavior was to just allow floats. Is this intended behavior? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140992/new/ https://reviews.llvm.org/D140992 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D140489: Add builtin_elementwise_log
bob80905 updated this revision to Diff 484633. bob80905 added a comment. Herald added subscribers: pcwang-thead, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb. add both commits Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140489/new/ https://reviews.llvm.org/D140489 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-log-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-log-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -73,3 +73,10 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_log() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-log-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-log-ops.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: riscv-registered-target + +#include + + +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}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -322,6 +322,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_log(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_log(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_log(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_log(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_log(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_log(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_log(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_roundeven(f); Index: clang/test/Sema/aarch64-sve-vector-log-ops.c === --- /dev/null +++ clang/test/Sema/aarch64-sve-vector-log-ops.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple aarch64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +sve -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: aarch64-registered-target + +#include + +svfloat32_t test_log_vv_i8mf8(svfloat32_t v) { + + return __builtin_elementwise_log(v); + // expected-error@-1 {{1st argument must be a vector, integer or floating point type}} +} Index: clang/test/CodeGen/builtins-elementwise-math.c === --- clang/test/CodeGen/builtins-elementwise-math.c +++ clang/test/CodeGen/builtins-elementwise-math.c @@ -365,6 +365,22 @@ vf2 = __builtin_elementwise_floor(vf1); } +void test_builtin_elementwise_log(float f1, float f2, double d1, double d2, + float4 vf1, float4 vf2) { + // CHECK-LABEL: define void @test_builtin_elementwise_log( + // CHECK: [[F1:%.+]] = load float, ptr %f1.addr, align 4 + // CHECK-NEXT: call float @llvm.log.f32(float [[F1]]) + f2 = __builtin_elementwise_log(f1); + + // CHECK: [[D1:%.+]] = load double, ptr %d1.addr, align 8 + // CHECK-NEXT: call double @llvm.log.f64(double [[D1]]) + d2 = __bui
[PATCH] D140489: Add builtin_elementwise_log
bob80905 created this revision. bob80905 added reviewers: python3kgae, beanz. 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. Add codegen for llvm log elementwise builtin The log elementwise builtin is necessary for HLSL codegen. Tests were added to make sure that the expected errors are encountered when these functions are given inputs of incompatible types. The new builtin is restricted to floating point types only. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D140489 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst Index: clang/docs/ReleaseNotes.rst === --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -845,6 +845,7 @@ unsafe floating-point optimizations use ``-funsafe-math-optimizations`` or ``-ffast-math`` instead. - Add ``__builtin_elementwise_sin`` and ``__builtin_elementwise_cos`` builtins for floating point types only. +- Add ``__builtin_elementwise_log``builtin for floating point types only. Internal API Changes Index: clang/docs/LanguageExtensions.rst === --- clang/docs/LanguageExtensions.rst +++ clang/docs/LanguageExtensions.rst @@ -635,6 +635,7 @@ T __builtin_elementwise_sin(T x)return the sine of x interpreted as an angle in radians floating point types T __builtin_elementwise_cos(T x)return the cosine of x interpreted as an angle in radiansfloating point types T __builtin_elementwise_floor(T x) return the largest integral value less than or equal to xfloating point types + T __builtin_elementwise_log(T x)return the natural logarithm of x floating point types T __builtin_elementwise_roundeven(T x) round x to the nearest integer value in floating point format, floating point types rounding halfway cases to even (that is, to the nearest value that is an even integer), regardless of the current rounding Index: clang/docs/ReleaseNotes.rst === --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -845,6 +845,7 @@ unsafe floating-point optimizations use ``-funsafe-math-optimizations`` or ``-ffast-math`` instead. - Add ``__builtin_elementwise_sin`` and ``__builtin_elementwise_cos`` builtins for floating point types only. +- Add ``__builtin_elementwise_log``builtin for floating point types only. Internal API Changes Index: clang/docs/LanguageExtensions.rst === --- clang/docs/LanguageExtensions.rst +++ clang/docs/LanguageExtensions.rst @@ -635,6 +635,7 @@ T __builtin_elementwise_sin(T x)return the sine of x interpreted as an angle in radians floating point types T __builtin_elementwise_cos(T x)return the cosine of x interpreted as an angle in radiansfloating point types T __builtin_elementwise_floor(T x) return the largest integral value less than or equal to xfloating point types + T __builtin_elementwise_log(T x)return the natural logarithm of xfloating point types T __builtin_elementwise_roundeven(T x) round x to the nearest integer value in floating point format, floating point types rounding halfway cases to even (that is, to the nearest value that is an even integer), regardless of the current rounding ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D139742: [HLSL] Add trunc library function
This revision was automatically updated to reflect the committed changes. Closed by commit rG6fbcb3f4baa8: [HLSL] Add trunc library function (authored by bob80905). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139742/new/ https://reviews.llvm.org/D139742 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/trunc.hlsl Index: clang/test/CodeGenHLSL/builtins/trunc.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/trunc.hlsl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.trunc.f16( +// NO_HALF: define noundef float @"?test_trunc_half@@YA$halff@$halff@@Z"( +// NO_HALF: call float @llvm.trunc.f32( +half test_trunc_half ( half p0 ) { + return trunc ( p0 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.trunc.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_trunc_float2@@YAT?$__vector@M$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x float> @llvm.trunc.v2f32( +half2 test_trunc_half2 ( half2 p0 ) { + return trunc ( p0 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.trunc.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_trunc_float3@@YAT?$__vector@M$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x float> @llvm.trunc.v3f32( +half3 test_trunc_half3 ( half3 p0 ) { + return trunc ( p0 ); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.trunc.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_trunc_float4@@YAT?$__vector@M$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x float> @llvm.trunc.v4f32( +half4 test_trunc_half4 ( half4 p0 ) { + return trunc ( p0 ); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.trunc.f32( +float test_trunc_float ( float p0 ) { + return trunc ( p0 ); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.trunc.v2f32 +float2 test_trunc_float2 ( float2 p0 ) { + return trunc ( p0 ); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.trunc.v3f32 +float3 test_trunc_float3 ( float3 p0 ) { + return trunc ( p0 ); +} +// CHECK: define noundef <4 x float> @ +// CHECK: call <4 x float> @llvm.trunc.v4f32 +float4 test_trunc_float4 ( float4 p0 ) { + return trunc ( p0 ); +} Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -189,5 +189,35 @@ __attribute__((clang_builtin_alias(__builtin_elementwise_sin))) double4 sin(double4); +// trunc builtins +#ifdef __HLSL_ENABLE_16_BIT +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +half trunc(half); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +half2 trunc(half2); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +half3 trunc(half3); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +half4 trunc(half4); +#endif + +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) float +trunc(float); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +float2 trunc(float2); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +float3 trunc(float3); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +float4 trunc(float4); + +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) double +trunc(double); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +double2 trunc(double2); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +double3 trunc(double3); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +double4 trunc(double4); + } // namespace hlsl #endif //_HLSL_HLSL_INTRINSICS_H_ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D139742: [HLSL] Add acos library function
bob80905 updated this revision to Diff 481748. bob80905 added a comment. The commit still isn't included, adding ^ character Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139742/new/ https://reviews.llvm.org/D139742 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/trunc.hlsl Index: clang/test/CodeGenHLSL/builtins/trunc.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/trunc.hlsl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.trunc.f16( +// NO_HALF: define noundef float @"?test_trunc_half@@YA$halff@$halff@@Z"( +// NO_HALF: call float @llvm.trunc.f32( +half test_trunc_half ( half p0 ) { + return trunc ( p0 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.trunc.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_trunc_float2@@YAT?$__vector@M$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x float> @llvm.trunc.v2f32( +half2 test_trunc_half2 ( half2 p0 ) { + return trunc ( p0 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.trunc.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_trunc_float3@@YAT?$__vector@M$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x float> @llvm.trunc.v3f32( +half3 test_trunc_half3 ( half3 p0 ) { + return trunc ( p0 ); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.trunc.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_trunc_float4@@YAT?$__vector@M$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x float> @llvm.trunc.v4f32( +half4 test_trunc_half4 ( half4 p0 ) { + return trunc ( p0 ); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.trunc.f32( +float test_trunc_float ( float p0 ) { + return trunc ( p0 ); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.trunc.v2f32 +float2 test_trunc_float2 ( float2 p0 ) { + return trunc ( p0 ); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.trunc.v3f32 +float3 test_trunc_float3 ( float3 p0 ) { + return trunc ( p0 ); +} +// CHECK: define noundef <4 x float> @ +// CHECK: call <4 x float> @llvm.trunc.v4f32 +float4 test_trunc_float4 ( float4 p0 ) { + return trunc ( p0 ); +} Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -189,5 +189,35 @@ __attribute__((clang_builtin_alias(__builtin_elementwise_sin))) double4 sin(double4); +// trunc builtins +#ifdef __HLSL_ENABLE_16_BIT +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +half trunc(half); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +half2 trunc(half2); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +half3 trunc(half3); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +half4 trunc(half4); +#endif + +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) float +trunc(float); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +float2 trunc(float2); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +float3 trunc(float3); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +float4 trunc(float4); + +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) double +trunc(double); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +double2 trunc(double2); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +double3 trunc(double3); +__attribute__((clang_builtin_alias(__builtin_elementwise_trunc))) +double4 trunc(double4); + } // namespace hlsl #endif //_HLSL_HLSL_INTRINSICS_H_ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D139742: [HLSL] Add acos library function
bob80905 updated this revision to Diff 481747. bob80905 added a comment. dont just paste the clang format commit onto the revision Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139742/new/ https://reviews.llvm.org/D139742 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -221,5 +221,3 @@ } // namespace hlsl #endif //_HLSL_HLSL_INTRINSICS_H_ - - Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -221,5 +221,3 @@ } // namespace hlsl #endif //_HLSL_HLSL_INTRINSICS_H_ - - ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D139742: [HLSL] Add acos library function
bob80905 created this revision. bob80905 added reviewers: beanz, python3kgae. 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. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D139742 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -221,5 +221,3 @@ } // namespace hlsl #endif //_HLSL_HLSL_INTRINSICS_H_ - - Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -221,5 +221,3 @@ } // namespace hlsl #endif //_HLSL_HLSL_INTRINSICS_H_ - - ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D139137: add floor library function
This revision was automatically updated to reflect the committed changes. Closed by commit rG500e72924305: add floor library function (authored by bob80905). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139137/new/ https://reviews.llvm.org/D139137 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/floor.hlsl Index: clang/test/CodeGenHLSL/builtins/floor.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/floor.hlsl @@ -0,0 +1,79 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +using hlsl::floor; + +// CHECK: define noundef half @ +// CHECK: call half @llvm.floor.f16( +// NO_HALF: define noundef float @"?test_floor_half@@YA$halff@$halff@@Z"( +// NO_HALF: call float @llvm.floor.f32(float %0) +half test_floor_half ( half p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.floor.v2f16( +// NO_HALF: define noundef <2 x float> @"?test_floor_half2@@YAT?$__vector@$halff@$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x float> @llvm.floor.v2f32( +half2 test_floor_half2 ( half2 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.floor.v3f16( +// NO_HALF: define noundef <3 x float> @"?test_floor_half3@@YAT?$__vector@$halff@$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x float> @llvm.floor.v3f32( +half3 test_floor_half3 ( half3 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.floor.v4f16( +// NO_HALF: define noundef <4 x float> @"?test_floor_half4@@YAT?$__vector@$halff@$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x float> @llvm.floor.v4f32( +half4 test_floor_half4 ( half4 p0 ) { + return floor ( p0 ); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.floor.f32( +float test_floor_float ( float p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.floor.v2f32( +float2 test_floor_float2 ( float2 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.floor.v3f32( +float3 test_floor_float3 ( float3 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <4 x float> @ +// CHECK: call <4 x float> @llvm.floor.v4f32( +float4 test_floor_float4 ( float4 p0 ) { + return floor ( p0 ); +} + +// CHECK: define noundef double @ +// CHECK: call double @llvm.floor.f64( +double test_floor_double ( double p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <2 x double> @ +// CHECK: call <2 x double> @llvm.floor.v2f64( +double2 test_floor_double2 ( double2 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <3 x double> @ +// CHECK: call <3 x double> @llvm.floor.v3f64( +double3 test_floor_double3 ( double3 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <4 x double> @ +// CHECK: call <4 x double> @llvm.floor.v4f64( +double4 test_floor_double4 ( double4 p0 ) { + return floor ( p0 ); +} Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -101,6 +101,36 @@ __attribute__((clang_builtin_alias(__builtin_elementwise_ceil))) double4 ceil(double4); +// floor builtins +#ifdef __HLSL_ENABLE_16_BIT +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +half floor(half); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +half2 floor(half2); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +half3 floor(half3); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +half4 floor(half4); +#endif + +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) float +floor(float); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +float2 floor(float2); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +float3 floor(float3); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +float4 floor(float4); + +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) double +floor(double); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +double2 floor(double2); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +double3 floor(double3); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +double4 floor(double4); + // cos builtins #ifdef __HLSL_ENABLE_16_BIT __attribute__((clang_builtin_
[PATCH] D139137: add floor library function
bob80905 updated this revision to Diff 480218. bob80905 added a comment. - update with clang format Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139137/new/ https://reviews.llvm.org/D139137 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/floor.hlsl Index: clang/test/CodeGenHLSL/builtins/floor.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/floor.hlsl @@ -0,0 +1,79 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +using hlsl::floor; + +// CHECK: define noundef half @ +// CHECK: call half @llvm.floor.f16( +// NO_HALF: define noundef float @"?test_floor_half@@YA$halff@$halff@@Z"( +// NO_HALF: call float @llvm.floor.f32(float %0) +half test_floor_half ( half p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.floor.v2f16( +// NO_HALF: define noundef <2 x float> @"?test_floor_half2@@YAT?$__vector@$halff@$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x float> @llvm.floor.v2f32( +half2 test_floor_half2 ( half2 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.floor.v3f16( +// NO_HALF: define noundef <3 x float> @"?test_floor_half3@@YAT?$__vector@$halff@$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x float> @llvm.floor.v3f32( +half3 test_floor_half3 ( half3 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.floor.v4f16( +// NO_HALF: define noundef <4 x float> @"?test_floor_half4@@YAT?$__vector@$halff@$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x float> @llvm.floor.v4f32( +half4 test_floor_half4 ( half4 p0 ) { + return floor ( p0 ); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.floor.f32( +float test_floor_float ( float p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.floor.v2f32( +float2 test_floor_float2 ( float2 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.floor.v3f32( +float3 test_floor_float3 ( float3 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <4 x float> @ +// CHECK: call <4 x float> @llvm.floor.v4f32( +float4 test_floor_float4 ( float4 p0 ) { + return floor ( p0 ); +} + +// CHECK: define noundef double @ +// CHECK: call double @llvm.floor.f64( +double test_floor_double ( double p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <2 x double> @ +// CHECK: call <2 x double> @llvm.floor.v2f64( +double2 test_floor_double2 ( double2 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <3 x double> @ +// CHECK: call <3 x double> @llvm.floor.v3f64( +double3 test_floor_double3 ( double3 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <4 x double> @ +// CHECK: call <4 x double> @llvm.floor.v4f64( +double4 test_floor_double4 ( double4 p0 ) { + return floor ( p0 ); +} Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -101,6 +101,36 @@ __attribute__((clang_builtin_alias(__builtin_elementwise_ceil))) double4 ceil(double4); +// floor builtins +#ifdef __HLSL_ENABLE_16_BIT +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +half floor(half); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +half2 floor(half2); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +half3 floor(half3); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +half4 floor(half4); +#endif + +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) float +floor(float); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +float2 floor(float2); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +float3 floor(float3); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +float4 floor(float4); + +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) double +floor(double); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +double2 floor(double2); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +double3 floor(double3); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +double4 floor(double4); + // cos builtins #ifdef __HLSL_ENABLE_16_BIT __attribute__((clang_builtin_alias(__builtin_elementwise_cos))) half cos(half); __
[PATCH] D139137: add floor library function
bob80905 created this revision. bob80905 added reviewers: python3kgae, beanz. 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 floor library function for HLSL, excluding long, int, and long long doubles. Floor is supported for all scalar, vector, and matrix types. Long and long long double support is missing in this patch because those types don't exist in HLSL. Int is missing because the floor function only works on floating type arguments. The full documentation of the HLSL floor function is available here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-floor Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D139137 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/floor.hlsl Index: clang/test/CodeGenHLSL/builtins/floor.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/floor.hlsl @@ -0,0 +1,79 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +using hlsl::floor; + +// CHECK: define noundef half @ +// CHECK: call half @llvm.floor.f16( +// NO_HALF: define noundef float @"?test_floor_half@@YA$halff@$halff@@Z"( +// NO_HALF: call float @llvm.floor.f32(float %0) +half test_floor_half ( half p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.floor.v2f16( +// NO_HALF: define noundef <2 x float> @"?test_floor_half2@@YAT?$__vector@$halff@$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x float> @llvm.floor.v2f32( +half2 test_floor_half2 ( half2 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.floor.v3f16( +// NO_HALF: define noundef <3 x float> @"?test_floor_half3@@YAT?$__vector@$halff@$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x float> @llvm.floor.v3f32( +half3 test_floor_half3 ( half3 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.floor.v4f16( +// NO_HALF: define noundef <4 x float> @"?test_floor_half4@@YAT?$__vector@$halff@$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x float> @llvm.floor.v4f32( +half4 test_floor_half4 ( half4 p0 ) { + return floor ( p0 ); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.floor.f32( +float test_floor_float ( float p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.floor.v2f32( +float2 test_floor_float2 ( float2 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.floor.v3f32( +float3 test_floor_float3 ( float3 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <4 x float> @ +// CHECK: call <4 x float> @llvm.floor.v4f32( +float4 test_floor_float4 ( float4 p0 ) { + return floor ( p0 ); +} + +// CHECK: define noundef double @ +// CHECK: call double @llvm.floor.f64( +double test_floor_double ( double p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <2 x double> @ +// CHECK: call <2 x double> @llvm.floor.v2f64( +double2 test_floor_double2 ( double2 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <3 x double> @ +// CHECK: call <3 x double> @llvm.floor.v3f64( +double3 test_floor_double3 ( double3 p0 ) { + return floor ( p0 ); +} +// CHECK: define noundef <4 x double> @ +// CHECK: call <4 x double> @llvm.floor.v4f64( +double4 test_floor_double4 ( double4 p0 ) { + return floor ( p0 ); +} Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -101,6 +101,35 @@ __attribute__((clang_builtin_alias(__builtin_elementwise_ceil))) double4 ceil(double4); +// floor builtins +#ifdef __HLSL_ENABLE_16_BIT +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) half floor(half); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +half2 floor(half2); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +half3 floor(half3); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +half4 floor(half4); +#endif + +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) float +floor(float); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +float2 floor(float2); +__attribute__((clang_builtin_alias(__builtin_elementwise_floor))) +float3 floor(float3); +__
[PATCH] D138161: add sin library function
bob80905 updated this revision to Diff 475952. bob80905 added a comment. [HLSL] add cos library function Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138161/new/ https://reviews.llvm.org/D138161 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/sin.hlsl Index: clang/test/CodeGenHLSL/builtins/sin.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/sin.hlsl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.sin.f16( +// NO_HALF: define noundef float @"?test_sin_half@@YA$halff@$halff@@Z"( +// NO_HALF: call float @llvm.sin.f32( +half test_sin_half ( half p0 ) { + return sin ( p0 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.sin.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_sin_float2@@YAT?$__vector@M$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x float> @llvm.sin.v2f32( +half2 test_sin_half2 ( half2 p0 ) { + return sin ( p0 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.sin.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_sin_float3@@YAT?$__vector@M$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x float> @llvm.sin.v3f32( +half3 test_sin_half3 ( half3 p0 ) { + return sin ( p0 ); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.sin.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_sin_float4@@YAT?$__vector@M$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x float> @llvm.sin.v4f32( +half4 test_sin_half4 ( half4 p0 ) { + return sin ( p0 ); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.sin.f32( +float test_sin_float ( float p0 ) { + return sin ( p0 ); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.sin.v2f32 +float2 test_sin_float2 ( float2 p0 ) { + return sin ( p0 ); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.sin.v3f32 +float3 test_sin_float3 ( float3 p0 ) { + return sin ( p0 ); +} +// CHECK: define noundef <4 x float> @ +// CHECK: call <4 x float> @llvm.sin.v4f32 +float4 test_sin_float4 ( float4 p0 ) { + return sin ( p0 ); +} Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -130,5 +130,34 @@ __attribute__((clang_builtin_alias(__builtin_elementwise_cos))) double4 cos(double4); +// sin builtins +#ifdef __HLSL_ENABLE_16_BIT +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) half sin(half); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +half2 sin(half2); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +half3 sin(half3); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +half4 sin(half4); +#endif + +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) float +sin(float); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +float2 sin(float2); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +float3 sin(float3); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +float4 sin(float4); + +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) double +sin(double); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +double2 sin(double2); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +double3 sin(double3); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +double4 sin(double4); + } // namespace hlsl #endif //_HLSL_HLSL_INTRINSICS_H_ Index: clang/test/CodeGenHLSL/builtins/sin.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/sin.hlsl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.sin.f16( +// NO_HALF: define noundef float @"?test_sin_half@@YA$halff@$halff@@Z"( +// NO_HALF: call float @llvm.sin.f32( +half test_sin_half ( half p0 ) { + return sin ( p0
[PATCH] D138161: add sin library function
bob80905 created this revision. Herald added a project: All. bob80905 requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D138161 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/sin.hlsl Index: clang/test/CodeGenHLSL/builtins/sin.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/sin.hlsl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.sin.f16( +// NO_HALF: define noundef float @"?test_sin_half@@YA$halff@$halff@@Z"( +// NO_HALF: call float @llvm.sin.f32( +half test_sin_half ( half p0 ) { + return sin ( p0 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.sin.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_sin_float2@@YAT?$__vector@M$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x float> @llvm.sin.v2f32( +half2 test_sin_half2 ( half2 p0 ) { + return sin ( p0 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.sin.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_sin_float3@@YAT?$__vector@M$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x float> @llvm.sin.v3f32( +half3 test_sin_half3 ( half3 p0 ) { + return sin ( p0 ); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.sin.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_sin_float4@@YAT?$__vector@M$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x float> @llvm.sin.v4f32( +half4 test_sin_half4 ( half4 p0 ) { + return sin ( p0 ); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.sin.f32( +float test_sin_float ( float p0 ) { + return sin ( p0 ); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.sin.v2f32 +float2 test_sin_float2 ( float2 p0 ) { + return sin ( p0 ); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.sin.v3f32 +float3 test_sin_float3 ( float3 p0 ) { + return sin ( p0 ); +} +// CHECK: define noundef <4 x float> @ +// CHECK: call <4 x float> @llvm.sin.v4f32 +float4 test_sin_float4 ( float4 p0 ) { + return sin ( p0 ); +} Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -130,5 +130,34 @@ __attribute__((clang_builtin_alias(__builtin_elementwise_cos))) double4 cos(double4); +// sin builtins +#ifdef __HLSL_ENABLE_16_BIT +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) half sin(half); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +half2 sin(half2); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +half3 sin(half3); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +half4 sin(half4); +#endif + +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) float +sin(float); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +float2 sin(float2); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +float3 sin(float3); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +float4 sin(float4); + +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) double +sin(double); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +double2 sin(double2); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +double3 sin(double3); +__attribute__((clang_builtin_alias(__builtin_elementwise_sin))) +double4 sin(double4); + } // namespace hlsl #endif //_HLSL_HLSL_INTRINSICS_H_ Index: clang/test/CodeGenHLSL/builtins/sin.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/sin.hlsl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.sin.f16( +// NO_HALF: define noundef float @"?test_sin_half@@YA$halff@$halff@@Z"( +// NO_HALF: call float @llvm.sin.f32( +half test_sin_half ( half p0 ) { + return sin (
[PATCH] D134921: [HLSL] add cos library function
bob80905 updated this revision to Diff 475861. bob80905 added a comment. - clang format Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D134921/new/ https://reviews.llvm.org/D134921 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/cos.hlsl Index: clang/test/CodeGenHLSL/builtins/cos.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/cos.hlsl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.cos.f16( +// NO_HALF: define noundef float @"?test_cos_half@@YA$halff@$halff@@Z"( +// NO_HALF: call float @llvm.cos.f32( +half test_cos_half ( half p0 ) { + return cos ( p0 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.cos.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_cos_float2@@YAT?$__vector@M$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x float> @llvm.cos.v2f32( +half2 test_cos_half2 ( half2 p0 ) { + return cos ( p0 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.cos.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_cos_float3@@YAT?$__vector@M$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x float> @llvm.cos.v3f32( +half3 test_cos_half3 ( half3 p0 ) { + return cos ( p0 ); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.cos.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_cos_float4@@YAT?$__vector@M$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x float> @llvm.cos.v4f32( +half4 test_cos_half4 ( half4 p0 ) { + return cos ( p0 ); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.cos.f32( +float test_cos_float ( float p0 ) { + return cos ( p0 ); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.cos.v2f32 +float2 test_cos_float2 ( float2 p0 ) { + return cos ( p0 ); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.cos.v3f32 +float3 test_cos_float3 ( float3 p0 ) { + return cos ( p0 ); +} +// CHECK: define noundef <4 x float> @ +// CHECK: call <4 x float> @llvm.cos.v4f32 +float4 test_cos_float4 ( float4 p0 ) { + return cos ( p0 ); +} Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -101,6 +101,34 @@ __attribute__((clang_builtin_alias(__builtin_elementwise_ceil))) double4 ceil(double4); -} // namespace hlsl +// cos builtins +#ifdef __HLSL_ENABLE_16_BIT +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) half cos(half); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +half2 cos(half2); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +half3 cos(half3); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +half4 cos(half4); +#endif +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) float +cos(float); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +float2 cos(float2); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +float3 cos(float3); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +float4 cos(float4); + +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) double +cos(double); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +double2 cos(double2); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +double3 cos(double3); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +double4 cos(double4); + +} // namespace hlsl #endif //_HLSL_HLSL_INTRINSICS_H_ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D134921: [HLSL] add cos library function
bob80905 updated this revision to Diff 475633. bob80905 added a comment. - remove int overloads - remove double - update tests after new builtin landed Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D134921/new/ https://reviews.llvm.org/D134921 Files: clang/lib/Headers/hlsl/hlsl_intrinsics.h clang/test/CodeGenHLSL/builtins/cos.hlsl Index: clang/test/CodeGenHLSL/builtins/cos.hlsl === --- /dev/null +++ clang/test/CodeGenHLSL/builtins/cos.hlsl @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -fnative-half-type \ +// RUN: -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s +// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \ +// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \ +// RUN: -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF + +// CHECK: define noundef half @ +// CHECK: call half @llvm.cos.f16( +// NO_HALF: define noundef float @"?test_cos_half@@YA$halff@$halff@@Z"( +// NO_HALF: call float @llvm.cos.f32( +half test_cos_half ( half p0 ) { + return cos ( p0 ); +} +// CHECK: define noundef <2 x half> @ +// CHECK: call <2 x half> @llvm.cos.v2f16 +// NO_HALF: define noundef <2 x float> @"?test_cos_float2@@YAT?$__vector@M$01@__clang@@T12@@Z"( +// NO_HALF: call <2 x float> @llvm.cos.v2f32( +half2 test_cos_half2 ( half2 p0 ) { + return cos ( p0 ); +} +// CHECK: define noundef <3 x half> @ +// CHECK: call <3 x half> @llvm.cos.v3f16 +// NO_HALF: define noundef <3 x float> @"?test_cos_float3@@YAT?$__vector@M$02@__clang@@T12@@Z"( +// NO_HALF: call <3 x float> @llvm.cos.v3f32( +half3 test_cos_half3 ( half3 p0 ) { + return cos ( p0 ); +} +// CHECK: define noundef <4 x half> @ +// CHECK: call <4 x half> @llvm.cos.v4f16 +// NO_HALF: define noundef <4 x float> @"?test_cos_float4@@YAT?$__vector@M$03@__clang@@T12@@Z"( +// NO_HALF: call <4 x float> @llvm.cos.v4f32( +half4 test_cos_half4 ( half4 p0 ) { + return cos ( p0 ); +} + +// CHECK: define noundef float @ +// CHECK: call float @llvm.cos.f32( +float test_cos_float ( float p0 ) { + return cos ( p0 ); +} +// CHECK: define noundef <2 x float> @ +// CHECK: call <2 x float> @llvm.cos.v2f32 +float2 test_cos_float2 ( float2 p0 ) { + return cos ( p0 ); +} +// CHECK: define noundef <3 x float> @ +// CHECK: call <3 x float> @llvm.cos.v3f32 +float3 test_cos_float3 ( float3 p0 ) { + return cos ( p0 ); +} +// CHECK: define noundef <4 x float> @ +// CHECK: call <4 x float> @llvm.cos.v4f32 +float4 test_cos_float4 ( float4 p0 ) { + return cos ( p0 ); +} Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h === --- clang/lib/Headers/hlsl/hlsl_intrinsics.h +++ clang/lib/Headers/hlsl/hlsl_intrinsics.h @@ -101,6 +101,35 @@ __attribute__((clang_builtin_alias(__builtin_elementwise_ceil))) double4 ceil(double4); -} // namespace hlsl +// cos builtins +#ifdef __HLSL_ENABLE_16_BIT +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) half cos(half); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +half2 cos(half2); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +half3 cos(half3); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +half4 cos(half4); +#endif + +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) float +cos(float); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +float2 cos(float2); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +float3 cos(float3); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +float4 cos(float4); + +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) double +cos(double); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +double2 cos(double2); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +double3 cos(double3); +__attribute__((clang_builtin_alias(__builtin_elementwise_cos))) +double4 cos(double4); + +} // namespace hlsl #endif //_HLSL_HLSL_INTRINSICS_H_ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D135011: Add builtin_elementwise_sin and builtin_elementwise_cos
bob80905 updated this revision to Diff 474628. bob80905 added a comment. - add dependency on architecture before testing Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D135011/new/ https://reviews.llvm.org/D135011 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-trig-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-trig-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -59,3 +59,17 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_cos() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} + +void test_builtin_elementwise_sin() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-trig-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-trig-ops.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify +// REQUIRES: riscv-registered-target + +#include + + +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}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -280,6 +280,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_cos(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_cos(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_cos(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_cos(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_cos(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_cos(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_cos(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_floor(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_floor(f); @@ -322,6 +343,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_sin(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_sin(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_sin(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_sin(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_sin(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_sin(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_sin(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_trunc(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_trunc(f); Index: clang/test/Sema/aarch64-sve-vector-trig-ops.c =
[PATCH] D135011: Add builtin_elementwise_sin and builtin_elementwise_cos
bob80905 updated this revision to Diff 474570. bob80905 added a comment. - make format change Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D135011/new/ https://reviews.llvm.org/D135011 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-trig-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-trig-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -59,3 +59,17 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_cos() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} + +void test_builtin_elementwise_sin() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-trig-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-trig-ops.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify + +#include + + +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}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -280,6 +280,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_cos(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_cos(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_cos(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_cos(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_cos(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_cos(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_cos(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_floor(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_floor(f); @@ -322,6 +343,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_sin(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_sin(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_sin(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_sin(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_sin(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_sin(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_sin(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_trunc(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_trunc(f); Index: clang/test/Sema/aarch64-sve-vector-trig-ops.c === --- /dev/null +++ clang/test/Sema/aarch64-sve-vector-t
[PATCH] D135011: Add builtin_elementwise_sin and builtin_elementwise_cos
bob80905 added a comment. Ping Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D135011/new/ https://reviews.llvm.org/D135011 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D135011: Add builtin_elementwise_sin and builtin_elementwise_cos
bob80905 added a comment. Ping Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D135011/new/ https://reviews.llvm.org/D135011 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D135011: Add builtin_elementwise_sin and builtin_elementwise_cos
bob80905 added a comment. Ping Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D135011/new/ https://reviews.llvm.org/D135011 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D135011: Add builtin_elementwise_sin and builtin_elementwise_cos
bob80905 added a comment. Ping, could someone please take a look? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D135011/new/ https://reviews.llvm.org/D135011 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D135011: Add builtin_elementwise_sin and builtin_elementwise_cos
bob80905 updated this revision to Diff 467201. bob80905 added a comment. - drop llvm from release notes description. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D135011/new/ https://reviews.llvm.org/D135011 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-trig-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-trig-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -59,3 +59,17 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_cos() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} + +void test_builtin_elementwise_sin() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-trig-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-trig-ops.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify + +#include + + +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}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -280,6 +280,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_cos(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_cos(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_cos(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_cos(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_cos(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_cos(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_cos(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_floor(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_floor(f); @@ -322,6 +343,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_sin(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_sin(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_sin(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_sin(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_sin(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_sin(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_sin(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_trunc(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_trunc(f); Index: clang/test/Sema/aarch64-sve-vector-trig-ops.c === --- /dev/null +++ clang/test/Se
[PATCH] D135011: Add builtin_elementwise_sin and builtin_elementwise_cos
bob80905 added a comment. Ping Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D135011/new/ https://reviews.llvm.org/D135011 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D135721: [HLSL] Added HLSL this as a reference
bob80905 added inline comments. Comment at: clang/test/AST/HLSL/this-reference.hlsl:62 +// CHECK-NEXT:`-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} 'Pair' lvalue +// CHECK-NEXT:`-CXXThisExpr 0x{{[0-9A-Fa-f]+}} 'PairInfo' lvalue implicit this One small nitpick I've received in some of my revisions is that the llvm repo doesn't want files ending without a new line. I'm surprised clang-format doesn't catch this. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D135721/new/ https://reviews.llvm.org/D135721 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D135011: Add builtin_elementwise_sin and builtin_elementwise_cos
bob80905 updated this revision to Diff 465446. bob80905 added a comment. - shorten builtin description, group sin and cos Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D135011/new/ https://reviews.llvm.org/D135011 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-trig-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-trig-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -59,3 +59,17 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_cos() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} + +void test_builtin_elementwise_sin() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-trig-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-trig-ops.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify + +#include + + +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}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -280,6 +280,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_cos(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_cos(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_cos(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_cos(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_cos(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_cos(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_cos(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_floor(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_floor(f); @@ -322,6 +343,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_sin(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_sin(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_sin(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_sin(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_sin(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_sin(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_sin(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_trunc(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_trunc(f); Index: clang/test/Sema/aarch64-sve-vector-trig-ops.c === --- /dev/null +++ clang/te
[PATCH] D135011: Add builtin_elementwise_sin and builtin_elementwise_cos
bob80905 updated this revision to Diff 465236. bob80905 added a comment. - add new line to end of new files Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D135011/new/ https://reviews.llvm.org/D135011 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-trig-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-trig-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -59,3 +59,17 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_cos() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} + +void test_builtin_elementwise_sin() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-trig-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-trig-ops.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify + +#include + + +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}} +} Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -280,6 +280,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_cos(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_cos(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_cos(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_cos(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_cos(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_cos(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_cos(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_floor(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_floor(f); @@ -322,6 +343,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_sin(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_sin(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_sin(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_sin(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_sin(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_sin(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_sin(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_trunc(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_trunc(f); Index: clang/test/Sema/aarch64-sve-vector-trig-ops.c === --- /dev/null +++ clang/test/Sema/aarch6
[PATCH] D135011: Add builtin_elementwise_sin and builtin_elementwise_cos
bob80905 updated this revision to Diff 465235. bob80905 added a comment. Herald added subscribers: frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb. - add sve tests to prove compiler doesn't crash Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D135011/new/ https://reviews.llvm.org/D135011 Files: clang/docs/LanguageExtensions.rst clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Builtins.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Sema/SemaChecking.cpp clang/test/CodeGen/builtins-elementwise-math.c clang/test/Sema/aarch64-sve-vector-trig-ops.c clang/test/Sema/builtins-elementwise-math.c clang/test/Sema/riscv-sve-vector-trig-ops.c clang/test/SemaCXX/builtins-elementwise-math.cpp Index: clang/test/SemaCXX/builtins-elementwise-math.cpp === --- clang/test/SemaCXX/builtins-elementwise-math.cpp +++ clang/test/SemaCXX/builtins-elementwise-math.cpp @@ -59,3 +59,17 @@ static_assert(!is_const::value); static_assert(!is_const::value); } + +void test_builtin_elementwise_cos() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} + +void test_builtin_elementwise_sin() { + const float a = 42.0; + float b = 42.3; + static_assert(!is_const::value); + static_assert(!is_const::value); +} Index: clang/test/Sema/riscv-sve-vector-trig-ops.c === --- /dev/null +++ clang/test/Sema/riscv-sve-vector-trig-ops.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d \ +// RUN: -target-feature +v -target-feature +zfh -target-feature +experimental-zvfh \ +// RUN: -disable-O0-optnone -o - -fsyntax-only %s -verify + +#include + + +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}} +} \ No newline at end of file Index: clang/test/Sema/builtins-elementwise-math.c === --- clang/test/Sema/builtins-elementwise-math.c +++ clang/test/Sema/builtins-elementwise-math.c @@ -280,6 +280,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_cos(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_cos(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_cos(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_cos(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_cos(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_cos(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_cos(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_floor(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { struct Foo s = __builtin_elementwise_floor(f); @@ -322,6 +343,27 @@ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} } +void test_builtin_elementwise_sin(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { + + struct Foo s = __builtin_elementwise_sin(f); + // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} + + i = __builtin_elementwise_sin(); + // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} + + i = __builtin_elementwise_sin(i); + // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} + + i = __builtin_elementwise_sin(f, f); + // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} + + u = __builtin_elementwise_sin(u); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} + + uv = __builtin_elementwise_sin(uv); + // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} +} + void test_builtin_elementwise_trunc(int i, floa
[PATCH] D135011: Add builtin_elementwise_sin and builtin_elementwise_cos
bob80905 added a comment. Here is the code I used to test the machine code output: typedef float float4 __attribute__((ext_vector_type(4))); void test_builtin_elementwise_sin(float f1, float f2, double d1, double d2, float4 vf1, float4 vf2) { f2 = __builtin_elementwise_sin(f1); d2 = __builtin_elementwise_sin(d1); vf2 = __builtin_elementwise_sin(vf1); } f2 = __builtin_elementwise_sin(f1); can be swapped for f2 = __builtin_elementwise_cos(f1); to test the cos builtin, Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D135011/new/ https://reviews.llvm.org/D135011 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits