[all-commits] [llvm/llvm-project] d91ff3: [HLSL] Rework implicit conversion sequences (#96011)

Chris B via All-commits all-commits at lists.llvm.org
Sat Jul 13 10:23:43 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d91ff3f2409a721b61b68c6a8438ea6c59323df8
      https://github.com/llvm/llvm-project/commit/d91ff3f2409a721b61b68c6a8438ea6c59323df8
  Author: Chris B <chris.bieneman at me.com>
  Date:   2024-07-13 (Sat, 13 Jul 2024)

  Changed paths:
    M clang/docs/HLSL/ExpectedDifferences.rst
    M clang/include/clang/Sema/Overload.h
    M clang/lib/Sema/SemaExprCXX.cpp
    M clang/lib/Sema/SemaOverload.cpp
    M clang/test/CodeGenHLSL/BasicFeatures/standard_conversion_sequences.hlsl
    M clang/test/CodeGenHLSL/builtins/dot.hlsl
    M clang/test/CodeGenHLSL/builtins/lerp.hlsl
    M clang/test/CodeGenHLSL/builtins/mad.hlsl
    R clang/test/SemaHLSL/OverloadResolutionBugs.hlsl
    M clang/test/SemaHLSL/ScalarOverloadResolution.hlsl
    A clang/test/SemaHLSL/SplatOverloadResolution.hlsl
    A clang/test/SemaHLSL/TruncationOverloadResolution.hlsl
    M clang/test/SemaHLSL/Types/BuiltinVector/ScalarSwizzles.hlsl
    M clang/test/SemaHLSL/VectorElementOverloadResolution.hlsl
    M clang/test/SemaHLSL/VectorOverloadResolution.hlsl
    M clang/test/SemaHLSL/standard_conversion_sequences.hlsl

  Log Message:
  -----------
  [HLSL] Rework implicit conversion sequences (#96011)

This PR reworks HLSL's implicit conversion sequences. Initially I was
seeking to match DXC's behavior more closely, but that was leading to a
pile of special case rules to tie-break ambiguous cases that should
really be left as ambiguous. We've decided that we're going to break
compatibility with DXC here, and we may port this new behavior over to
DXC instead.

This change is a bit closer to C++'s overload resolution rules, but it
does have a bit of nuance around how dimension adjustment conversions
are ranked. Conversion sequence ranks for HLSL are:

* Exact match
* Scalar Widening (i.e. splat)
* Promotion
* Scalar Widening with Promotion
* Conversion
* Scalar Widening with Conversion
* Dimension Reduction (i.e. truncation)
* Dimension Reduction with Promotion
* Dimension Reduction with Conversion

In this implementation I've folded the disambiguation into the
conversion sequence ranks which does add some complexity as compared to
C++, however this avoids needing to add special casing in
`CompareStandardConversionSequences`. I believe the added conversion
rank values provide a simpler approach, but feedback is appreciated.

The HLSL language spec updates are in the PR here:
https://github.com/microsoft/hlsl-specs/pull/261



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