[all-commits] [llvm/llvm-project] 82acec: [HLSL] Implementation of dot intrinsic (#81190)

Farzon Lotfi via All-commits all-commits at lists.llvm.org
Mon Feb 26 08:09:11 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 82acec15afeb2bcba534a333c89cea33da7ffa47
      https://github.com/llvm/llvm-project/commit/82acec15afeb2bcba534a333c89cea33da7ffa47
  Author: Farzon Lotfi <1802579+farzonl at users.noreply.github.com>
  Date:   2024-02-26 (Mon, 26 Feb 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/CodeGen/CodeGenFunction.h
    M clang/lib/Headers/hlsl/hlsl_intrinsics.h
    M clang/lib/Sema/SemaChecking.cpp
    A clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl
    A clang/test/CodeGenHLSL/builtins/dot.hlsl
    A clang/test/SemaHLSL/BuiltIns/dot-errors.hlsl
    M clang/test/SemaHLSL/OverloadResolutionBugs.hlsl
    M llvm/include/llvm/IR/IntrinsicsDirectX.td

  Log Message:
  -----------
  [HLSL] Implementation of dot intrinsic (#81190)

This change implements https://github.com/llvm/llvm-project/issues/70073

HLSL has a dot intrinsic defined here:

https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-dot

The intrinsic itself is defined as a HLSL_LANG LangBuiltin in
Builtins.td.
This is used to associate all the dot product typdef defined
hlsl_intrinsics.h
with a single intrinsic check in CGBuiltin.cpp & SemaChecking.cpp.

In IntrinsicsDirectX.td we define the llvmIR for the dot product.
A few goals were in mind for this IR. First it should operate on only
vectors. Second the return type should be the vector element type. Third
the second parameter vector should be of the same size as the first
parameter. Finally `a dot b` should be the same as `b dot a`.

In CGBuiltin.cpp hlsl has built on top of existing clang intrinsics via
EmitBuiltinExpr. Dot
product though is language specific intrinsic and so is guarded behind
getLangOpts().HLSL.
The call chain looks like this: EmitBuiltinExpr -> EmitHLSLBuiltinExp

EmitHLSLBuiltinExp dot product intrinsics makes a destinction
between vectors and scalars. This is because HLSL supports dot product
on scalars which simplifies down to multiply.

Sema.h & SemaChecking.cpp saw the addition of
CheckHLSLBuiltinFunctionCall, a language specific semantic validation
that can be expanded for other hlsl specific intrinsics.

Fixes #70073



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