This change implements the frontend for #70099
Builtins.td - add the frac builtin
CGBuiltin.cpp - add the builtin to DirectX intrinsic mapping
hlsl_intrinsics.h - add the frac api
SemaChecking.cpp - add type checks for builtin
IntrinsicsDirectX.td - add the frac intrinsic
The backend changes for this are going to be very simple:
f309a0eb55
They were not included because llvm/lib/Target/DirectX/DXIL.td is going
through a major refactor.
74 lines
1.9 KiB
HLSL
74 lines
1.9 KiB
HLSL
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -o - -fsyntax-only %s -verify
|
|
// XFAIL: *
|
|
|
|
// https://github.com/llvm/llvm-project/issues/81047
|
|
|
|
// expected-no-diagnostics
|
|
void Fn3(double2 D);
|
|
void Fn3(float2 F);
|
|
|
|
void Call3(half2 H) { Fn3(H); }
|
|
|
|
void Fn5(double2 D);
|
|
|
|
void Call5(half2 H) { Fn5(H); }
|
|
|
|
void Fn4(int64_t2 L);
|
|
void Fn4(int2 I);
|
|
|
|
void Call4(int16_t H) { Fn4(H); }
|
|
|
|
int test_builtin_dot_bool_type_promotion(bool p0, bool p1) {
|
|
return dot(p0, p1);
|
|
}
|
|
|
|
float test_dot_scalar_mismatch(float p0, int p1) { return dot(p0, p1); }
|
|
|
|
float test_dot_element_type_mismatch(int2 p0, float2 p1) { return dot(p0, p1); }
|
|
|
|
float test_builtin_dot_vec_int_to_float_promotion(int2 p0, float2 p1) {
|
|
return dot(p0, p1);
|
|
}
|
|
|
|
int64_t test_builtin_dot_vec_int_to_int64_promotion(int64_t2 p0, int2 p1) {
|
|
return dot(p0, p1);
|
|
}
|
|
|
|
float test_builtin_dot_vec_half_to_float_promotion(float2 p0, half2 p1) {
|
|
return dot(p0, p1);
|
|
}
|
|
|
|
float test_builtin_dot_vec_int16_to_float_promotion(float2 p0, int16_t2 p1) {
|
|
return dot(p0, p1);
|
|
}
|
|
|
|
half test_builtin_dot_vec_int16_to_half_promotion(half2 p0, int16_t2 p1) {
|
|
return dot(p0, p1);
|
|
}
|
|
|
|
int test_builtin_dot_vec_int16_to_int_promotion(int2 p0, int16_t2 p1) {
|
|
return dot(p0, p1);
|
|
}
|
|
|
|
int64_t test_builtin_dot_vec_int16_to_int64_promotion(int64_t2 p0,
|
|
int16_t2 p1) {
|
|
return dot(p0, p1);
|
|
}
|
|
|
|
float4 test_frac_int4(int4 p0) { return frac(p0); }
|
|
|
|
float test_frac_int(int p0) { return frac(p0); }
|
|
|
|
float test_frac_bool(bool p0) { return frac(p0); }
|
|
|
|
// https://github.com/llvm/llvm-project/issues/81049
|
|
|
|
// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
|
|
// RUN: dxil-pc-shadermodel6.2-library %s -emit-llvm -disable-llvm-passes \
|
|
// RUN: -o - | FileCheck %s --check-prefix=NO_HALF
|
|
|
|
half sqrt_h(half x) { return sqrt(x); }
|
|
|
|
// NO_HALF: define noundef float @"?sqrt_h@@YA$halff@$halff@@Z"(
|
|
// NO_HALF: call float @llvm.sqrt.f32(float %0)
|