[all-commits] [llvm/llvm-project] dd860b: [HLSL] Implement the `reflect` HLSL function (#122...

Deric Cheung via All-commits all-commits at lists.llvm.org
Tue Jan 21 14:30:51 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dd860bcfb57df429c0a1ad2e2d869ff3b795bc4d
      https://github.com/llvm/llvm-project/commit/dd860bcfb57df429c0a1ad2e2d869ff3b795bc4d
  Author: Deric Cheung <cheung.deric at gmail.com>
  Date:   2025-01-21 (Tue, 21 Jan 2025)

  Changed paths:
    M clang/include/clang/Basic/BuiltinsSPIRV.td
    M clang/lib/CodeGen/CGBuiltin.cpp
    M clang/lib/Headers/hlsl/hlsl_detail.h
    M clang/lib/Headers/hlsl/hlsl_intrinsics.h
    M clang/lib/Sema/SemaSPIRV.cpp
    A clang/test/CodeGenHLSL/builtins/reflect.hlsl
    A clang/test/CodeGenSPIRV/Builtins/reflect.c
    A clang/test/SemaHLSL/BuiltIns/reflect-errors.hlsl
    A clang/test/SemaSPIRV/BuiltIns/reflect-errors.c
    M llvm/include/llvm/IR/IntrinsicsSPIRV.td
    M llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
    A llvm/test/CodeGen/SPIRV/hlsl-intrinsics/reflect.ll
    A llvm/test/CodeGen/SPIRV/opencl/reflect-error.ll

  Log Message:
  -----------
  [HLSL] Implement the `reflect` HLSL function (#122992)

Fixes #99152

Tasks completed:

- Implement `reflect` in `clang/lib/Headers/hlsl/hlsl_intrinsics.h`
- Implement the `reflect` SPIR-V target built-in in
`clang/include/clang/Basic/BuiltinsSPIRV.td`
- Add a SPIR-V fast path in `clang/lib/Headers/hlsl/hlsl_detail.h` in
the form
 ```c++
#if (__has_builtin(__builtin_spirv_reflect))
  return __builtin_spirv_reflect(...);
 #else
   return ...; // regular behavior
 #endif
 ```
- Add codegen for the SPIR-V `reflect` built-in to
`EmitSPIRVBuiltinExpr` in `clang/lib/CodeGen/CGBuiltin.cpp`
- Add HLSL codegen tests to
`clang/test/CodeGenHLSL/builtins/reflect.hlsl`
- Add SPIR-V built-in codegen tests to
`clang/test/CodeGenSPIRV/Builtins/reflect.c`
- Add sema tests to `clang/test/SemaHLSL/BuiltIns/reflect-errors.hlsl`
- Add SPIR-V sema tests to
`clang/test/CodeGenSPIRV/Builtins/reflect-errors.c`
- Create the `int_spv_reflect` intrinsic in
`llvm/include/llvm/IR/IntrinsicsSPIRV.td`
- In `llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp` create the
`reflect` lowering and map it to `int_spv_reflect` in
`SPIRVInstructionSelector::selectIntrinsic`
- Create a SPIR-V backend test case in
`llvm/test/CodeGen/SPIRV/hlsl-intrinsics/reflect.ll`

Additional tasks completed:

- Implement sema check for the `reflect` SPIR-V built-in in
`clang/lib/Sema/SemaSPIRV.cpp`
- Required for HLSL codegen to work via the SPIR-V fast path, because
the types defined in `clang/include/clang/Basic/BuiltinsSPIRV.td` are
being overridden
- Create SPIR-V backend error test case in
`llvm/test/CodeGen/SPIRV/opencl/reflect-error.ll`
- Since `reflect` is only available in the GLSL extended instruction
set, using it in OpenCL should result in an error

Incomplete tasks:

- Create SPIR-V backend test case in
`llvm/test/CodeGen/SPIRV/opencl/reflect.ll`
- An OpenCL test is not applicable in this case because the [OpenCL
SPIR-V extended instruction
set](https://registry.khronos.org/SPIR-V/specs/unified1/OpenCL.ExtendedInstructionSet.100.html)
does not include a `reflect` function



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list