[all-commits] [llvm/llvm-project] 643b31: [HLSL] implement `mad` intrinsic (#83826)

Farzon Lotfi via All-commits all-commits at lists.llvm.org
Tue Mar 5 09:23:37 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 643b31dbe8a515e007a0f1b2e1072c34e461b778
      https://github.com/llvm/llvm-project/commit/643b31dbe8a515e007a0f1b2e1072c34e461b778
  Author: Farzon Lotfi <1802579+farzonl at users.noreply.github.com>
  Date:   2024-03-05 (Tue, 05 Mar 2024)

  Changed paths:
    M clang/include/clang/Basic/Builtins.td
    M clang/include/clang/Sema/Sema.h
    M clang/lib/CodeGen/CGBuiltin.cpp
    M clang/lib/Headers/hlsl/hlsl_intrinsics.h
    M clang/lib/Sema/SemaChecking.cpp
    A clang/test/CodeGenHLSL/builtins/mad.hlsl
    A clang/test/SemaHLSL/BuiltIns/mad-errors.hlsl
    M llvm/include/llvm/IR/IntrinsicsDirectX.td
    M llvm/lib/Target/DirectX/DXIL.td
    A llvm/test/CodeGen/DirectX/fmad.ll
    A llvm/test/CodeGen/DirectX/imad.ll
    A llvm/test/CodeGen/DirectX/umad.ll

  Log Message:
  -----------
  [HLSL] implement `mad` intrinsic (#83826)

This change implements #83736
The dot product lowering needs a tertiary multipy add operation. DXIL
has three mad opcodes for `fmad`(46), `imad`(48), and `umad`(49). Dot
product in DXIL only uses `imad`\ `umad`, but for completeness and
because the hlsl `mad` intrinsic requires it `fmad` was also included.
Two new intrinsics were needed to be created to complete this change.
the `fmad` case already supported by llvm via `fmuladd` intrinsic.

- `hlsl_intrinsics.h` - exposed mad api call.
- `Builtins.td` - exposed a `mad` builtin.
- `Sema.h` - make `tertiary` calls check for float types optional. 
- `CGBuiltin.cpp` - pick the intrinsic for singed\unsigned & float also
reuse `int_fmuladd`.
- `SemaChecking.cpp` - type checks for `__builtin_hlsl_mad`. 
- `IntrinsicsDirectX.td` create the two new intrinsics for
`imad`\`umad`/
- `DXIL.td` - create the llvm intrinsic to  `DXIL` opcode mapping.

---------

Co-authored-by: Farzon Lotfi <farzon at farzon.com>



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