brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.4 KiB · 2935fbb Raw
119 lines · plain
1// RUN: %clang_cc1 -finclude-default-header  -x hlsl  -triple dxil-pc-shadermodel6.3-library %s \2// RUN:  -emit-llvm -disable-llvm-passes -fnative-half-type -o - | \3// RUN:  FileCheck %s --check-prefixes=CHECK4// RUN: %clang_cc1 -finclude-default-header  -x hlsl  -triple spirv-unknown-vulkan1.3-library  %s \5// RUN:  -emit-llvm -disable-llvm-passes -fnative-half-type -o - | \6// RUN:  FileCheck %s --check-prefixes=CHECK-SPIRV7 8// CHECK-LABEL: define {{.*}} half @_ZN4hlsl8__detail11fwidth_implIDhEET_S2_9// CHECK: %hlsl.ddx.coarse = call {{.*}} half @llvm.dx.ddx.coarse.f16(half %{{.*}})10// CHECK: %{{.*}} = call {{.*}} half @llvm.fabs.f16(half %{{.*}})11// CHECK: %hlsl.ddy.coarse = call {{.*}} half @llvm.dx.ddy.coarse.f16(half %{{.*}})12// CHECK: %{{.*}} = call {{.*}} half @llvm.fabs.f16(half %{{.*}})13// CHECK: %{{.*}} = fadd {{.*}} %{{.*}}, %{{.*}}14// CHECK: ret half %{{.*}}15// CHECK-LABEL-SPIRV: half @_Z15test_f16_fwidthDh16// CHECK-SPIRV: %spv.fwidth = call {{.*}} half @llvm.spv.fwidth.f16(half %{{.*}})17// CHECK-SPIRV: ret half %spv.fwidth18half test_f16_fwidth(half val) {19    return fwidth(val);20}21 22// CHECK-LABEL: define {{.*}} <2 x half> @_ZN4hlsl8__detail11fwidth_implIDv2_DhEET_S3_23// CHECK: %hlsl.ddx.coarse = call {{.*}} <2 x half> @llvm.dx.ddx.coarse.v2f16(<2 x half> %{{.*}})24// CHECK: %{{.*}} = call {{.*}} <2 x half> @llvm.fabs.v2f16(<2 x half> %{{.*}})25// CHECK: %hlsl.ddy.coarse = call {{.*}} <2 x half> @llvm.dx.ddy.coarse.v2f16(<2 x half> %{{.*}})26// CHECK: %{{.*}} = call {{.*}} <2 x half> @llvm.fabs.v2f16(<2 x half> %{{.*}})27// CHECK: %{{.*}} = fadd {{.*}} %{{.*}}, %{{.*}}28// CHECK: ret <2 x half> %{{.*}}29// CHECK-LABEL-SPIRV: <2 x half> @_Z16test_f16_fwidth2Dv2_Dh30// CHECK-SPIRV: %spv.fwidth = call {{.*}} <2 x half> @llvm.spv.fwidth.v2f16(<2 x half> %{{.*}})31// CHECK-SPIRV: ret <2 x half> %spv.fwidth32half2 test_f16_fwidth2(half2 val) {33    return fwidth(val);34}35 36// CHECK-LABEL: define {{.*}} <3 x half> @_ZN4hlsl8__detail11fwidth_implIDv3_DhEET_S3_37// CHECK: %hlsl.ddx.coarse = call {{.*}} <3 x half> @llvm.dx.ddx.coarse.v3f16(<3 x half> %{{.*}})38// CHECK: %{{.*}} = call {{.*}} <3 x half> @llvm.fabs.v3f16(<3 x half> %{{.*}})39// CHECK: %hlsl.ddy.coarse = call {{.*}} <3 x half> @llvm.dx.ddy.coarse.v3f16(<3 x half> %{{.*}})40// CHECK: %{{.*}} = call {{.*}} <3 x half> @llvm.fabs.v3f16(<3 x half> %{{.*}})41// CHECK: %{{.*}} = fadd {{.*}} %{{.*}}, %{{.*}}42// CHECK: ret <3 x half> %{{.*}}43// CHECK-LABEL-SPIRV: <3 x half> @_Z16test_f16_fwidth3Dv3_Dh44// CHECK-SPIRV: %spv.fwidth = call {{.*}} <3 x half> @llvm.spv.fwidth.v3f16(<3 x half> %{{.*}})45// CHECK-SPIRV: ret <3 x half> %spv.fwidth46half3 test_f16_fwidth3(half3 val) {47    return fwidth(val);48}49 50// CHECK-LABEL: define {{.*}} <4 x half> @_ZN4hlsl8__detail11fwidth_implIDv4_DhEET_S3_51// CHECK: %hlsl.ddx.coarse = call {{.*}} <4 x half> @llvm.dx.ddx.coarse.v4f16(<4 x half> %{{.*}})52// CHECK: %{{.*}} = call {{.*}} <4 x half> @llvm.fabs.v4f16(<4 x half> %{{.*}})53// CHECK: %hlsl.ddy.coarse = call {{.*}} <4 x half> @llvm.dx.ddy.coarse.v4f16(<4 x half> %{{.*}})54// CHECK: %{{.*}} = call {{.*}} <4 x half> @llvm.fabs.v4f16(<4 x half> %{{.*}})55// CHECK: %{{.*}} = fadd {{.*}} %{{.*}}, %{{.*}}56// CHECK: ret <4 x half> %{{.*}}57// CHECK-LABEL-SPIRV: <4 x half> @_Z16test_f16_fwidth4Dv4_Dh58// CHECK-SPIRV: %spv.fwidth = call {{.*}} <4 x half> @llvm.spv.fwidth.v4f16(<4 x half> %{{.*}})59// CHECK-SPIRV: ret <4 x half> %spv.fwidth60half4 test_f16_fwidth4(half4 val) {61    return fwidth(val);62}63 64// CHECK-LABEL: define {{.*}} float @_ZN4hlsl8__detail11fwidth_implIfEET_S2_65// CHECK: %hlsl.ddx.coarse = call {{.*}} float @llvm.dx.ddx.coarse.f32(float %{{.*}})66// CHECK: %{{.*}} = call {{.*}} float @llvm.fabs.f32(float %{{.*}})67// CHECK: %hlsl.ddy.coarse = call {{.*}} float @llvm.dx.ddy.coarse.f32(float %{{.*}})68// CHECK: %{{.*}} = call {{.*}} float @llvm.fabs.f32(float %{{.*}})69// CHECK: %{{.*}} = fadd {{.*}} %{{.*}}, %{{.*}}70// CHECK: ret float %{{.*}}71// CHECK-LABEL-SPIRV: float @_Z15test_f32_fwidthf72// CHECK-SPIRV: %spv.fwidth = call {{.*}} float @llvm.spv.fwidth.f32(float %{{.*}})73// CHECK-SPIRV: ret float %spv.fwidth74float test_f32_fwidth(float val) {75    return fwidth(val);76}77 78// CHECK-LABEL: define {{.*}} <2 x float> @_ZN4hlsl8__detail11fwidth_implIDv2_fEET_S3_79// CHECK: %hlsl.ddx.coarse = call {{.*}} <2 x float> @llvm.dx.ddx.coarse.v2f32(<2 x float> %{{.*}})80// CHECK: %{{.*}} = call {{.*}} <2 x float> @llvm.fabs.v2f32(<2 x float> %{{.*}})81// CHECK: %hlsl.ddy.coarse = call {{.*}} <2 x float> @llvm.dx.ddy.coarse.v2f32(<2 x float> %{{.*}})82// CHECK: %{{.*}} = call {{.*}} <2 x float> @llvm.fabs.v2f32(<2 x float> %{{.*}})83// CHECK: %{{.*}} = fadd {{.*}} %{{.*}}, %{{.*}}84// CHECK: ret <2 x float> %{{.*}}85// CHECK-LABEL-SPIRV: <2 x float> @_Z16test_f32_fwidth2Dv2_f86// CHECK-SPIRV: %spv.fwidth = call {{.*}} <2 x float> @llvm.spv.fwidth.v2f32(<2 x float> %{{.*}})87// CHECK-SPIRV: ret <2 x float> %spv.fwidth88float2 test_f32_fwidth2(float2 val) {89    return fwidth(val);90}91 92// CHECK-LABEL: define {{.*}} <3 x float> @_ZN4hlsl8__detail11fwidth_implIDv3_fEET_S3_93// CHECK: %hlsl.ddx.coarse = call {{.*}} <3 x float> @llvm.dx.ddx.coarse.v3f32(<3 x float> %{{.*}})94// CHECK: %{{.*}} = call {{.*}} <3 x float> @llvm.fabs.v3f32(<3 x float> %{{.*}})95// CHECK: %hlsl.ddy.coarse = call {{.*}} <3 x float> @llvm.dx.ddy.coarse.v3f32(<3 x float> %{{.*}})96// CHECK: %{{.*}} = call {{.*}} <3 x float> @llvm.fabs.v3f32(<3 x float> %{{.*}})97// CHECK: %{{.*}} = fadd {{.*}} %{{.*}}, %{{.*}}98// CHECK: ret <3 x float> %{{.*}}99// CHECK-LABEL-SPIRV: <3 x float> @_Z16test_f32_fwidth3Dv3_f100// CHECK-SPIRV: %spv.fwidth = call {{.*}} <3 x float> @llvm.spv.fwidth.v3f32(<3 x float> %{{.*}})101// CHECK-SPIRV: ret <3 x float> %spv.fwidth102float3 test_f32_fwidth3(float3 val) {103    return fwidth(val);104}105 106// CHECK-LABEL: define {{.*}} <4 x float> @_ZN4hlsl8__detail11fwidth_implIDv4_fEET_S3_107// CHECK: %hlsl.ddx.coarse = call {{.*}} <4 x float> @llvm.dx.ddx.coarse.v4f32(<4 x float> %{{.*}})108// CHECK: %{{.*}} = call {{.*}} <4 x float> @llvm.fabs.v4f32(<4 x float> %{{.*}})109// CHECK: %hlsl.ddy.coarse = call {{.*}} <4 x float> @llvm.dx.ddy.coarse.v4f32(<4 x float> %{{.*}})110// CHECK: %{{.*}} = call {{.*}} <4 x float> @llvm.fabs.v4f32(<4 x float> %{{.*}})111// CHECK: %{{.*}} = fadd {{.*}} %{{.*}}, %{{.*}}112// CHECK: ret <4 x float> %{{.*}}113// CHECK-LABEL-SPIRV: <4 x float> @_Z16test_f32_fwidth4Dv4_f114// CHECK-SPIRV: %spv.fwidth = call {{.*}} <4 x float> @llvm.spv.fwidth.v4f32(<4 x float> %{{.*}})115// CHECK-SPIRV: ret <4 x float> %spv.fwidth116float4 test_f32_fwidth4(float4 val) {117    return fwidth(val);118}119