Files
clang-p2996/clang/test/SemaSPIRV/BuiltIns/smoothstep-errors.c
Kaitlin Peng 67cbfb9d8c [HLSL] Implement the faceforward intrinsic (#135878)
Resolves #99114.

Tasks completed:
- Implement `faceforward` in
`hlsl_intrinsics.h`/`hlsl_intrinsic_helpers.h`
- Implement `faceforward` SPIR-V target builtin in
`clang/include/clang/Basic/BuiltinsSPIRV.td`
- Add a SPIR-V fast path in `hlsl_intrinsic_helpers.h`
- Add sema checks for `faceforward` to `CheckSPIRVBuiltinFunctionCall`
in `clang/lib/Sema/SemaSPIRV.cpp`
- Add codegen for SPIR-V `faceforward` builtin to `EmitSPIRVBuiltinExpr`
in `SPIR.cpp`
- Add HLSL codegen tests to
`clang/test/CodeGenHLSL/builtins/faceforward.hlsl`
- Add SPIRV builtin codegen tests to
`clang/test/CodeGenSPIRV/Builtins/faceforward.c`
- Add sema tests to
`clang/test/SemaHLSL/BuiltIns/faceforward-errors.hlsl`
- Add spirv sema tests to
`clang/test/SemaSPIRV/BuiltIns/faceforward-errors.c`
- Create the `int_spv_faceforward` intrinsic in `IntrinsicsSPIRV.td`
- In `SPIRVInstructionSelector.cpp` create the `faceforward` lowering
and map it to `int_spv_faceforward` in
`SPIRVInstructionSelector::selectIntrinsic`
- Create SPIR-V backend test case in
`llvm/test/CodeGen/SPIRV/hlsl-intrinsics/faceforward.ll`

Incomplete tasks:
- Create SPIR-V backend test case in
`llvm/test/CodeGen/SPIRV/opencl/faceforward.ll`
- Not applicable because the OpenCL SPIR-V extended instruction set does
not include a `faceforward` function

Follow-up tasks:
- Implement pattern matching for `faceforward` in `SPIRVCombine.td` and
`SPIRVPreLegalizerCombiner.cpp`
- In `faceforward.ll`, change `--target-env spv1.4` to `vulkan1.3` and
update the test accordingly once
[#136344](https://github.com/llvm/llvm-project/issues/136344) has been
resolved
2025-04-24 14:45:05 -07:00

55 lines
2.1 KiB
C

// RUN: %clang_cc1 %s -triple spirv-pc-vulkan-compute -verify
typedef float float2 __attribute__((ext_vector_type(2)));
typedef float float3 __attribute__((ext_vector_type(3)));
float2 test_no_second_arg(float2 p0) {
return __builtin_spirv_smoothstep(p0);
// expected-error@-1 {{too few arguments to function call, expected 3, have 1}}
}
float2 test_no_third_arg(float2 p0) {
return __builtin_spirv_smoothstep(p0, p0);
// expected-error@-1 {{too few arguments to function call, expected 3, have 2}}
}
float2 test_too_many_arg(float2 p0) {
return __builtin_spirv_smoothstep(p0, p0, p0, p0);
// expected-error@-1 {{too many arguments to function call, expected 3, have 4}}
}
int test_int_scalar_inputs(int p0) {
return __builtin_spirv_smoothstep(p0, p0, p0);
// expected-error@-1 {{1st argument must be a scalar or vector of floating-point types (was 'int')}}
}
float test_int_scalar_inputs2(float p0, int p1) {
return __builtin_spirv_smoothstep(p0, p1, p1);
// expected-error@-1 {{all arguments to '__builtin_spirv_smoothstep' must have the same type}}
}
float test_int_scalar_inputs3(float p0, int p1) {
return __builtin_spirv_smoothstep(p0, p0, p1);
// expected-error@-1 {{all arguments to '__builtin_spirv_smoothstep' must have the same type}}
}
float test_mismatched_arg(float p0, float2 p1) {
return __builtin_spirv_smoothstep(p0, p1, p1);
// expected-error@-1 {{all arguments to '__builtin_spirv_smoothstep' must have the same type}}
}
float test_mismatched_arg2(float p0, float2 p1) {
return __builtin_spirv_smoothstep(p0, p0, p1);
// expected-error@-1 {{all arguments to '__builtin_spirv_smoothstep' must have the same type}}
}
float test_mismatched_return(float2 p0) {
return __builtin_spirv_smoothstep(p0, p0, p0);
// expected-error@-1 {{returning 'float2' (vector of 2 'float' values) from a function with incompatible result type 'float'}}
}
float3 test_mismatched_return2(float2 p0) {
return __builtin_spirv_smoothstep(p0, p0, p0);
// expected-error@-1 {{returning 'float2' (vector of 2 'float' values) from a function with incompatible result type 'float3' (vector of 3 'float' values)}}
}