[clang] [llvm] [HLSL] implementation of lerp intrinsic (PR #83077)

Farzon Lotfi via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 27 08:41:20 PST 2024


================
@@ -24,4 +24,9 @@ def int_dx_dot :
     Intrinsic<[LLVMVectorElementType<0>], 
     [llvm_anyvector_ty, LLVMScalarOrSameVectorWidth<0, LLVMVectorElementType<0>>],
     [IntrNoMem, IntrWillReturn, Commutative] >;
+
+def int_dx_lerp :
+    Intrinsic<[LLVMMatchType<0>], 
+    [llvm_anyvector_ty, LLVMMatchType<0>, LLVMMatchType<0>],
----------------
farzonl wrote:

I think you are right.  here is my understanding of the Tablegen. if you diff a `LLVMMatchType` vs `LLVMScalarOrSameVectorWidth`
The thing that will pop out as different are the type signatures:
<img width="1183" alt="image" src="https://github.com/llvm/llvm-project/assets/1802579/a6bad9a5-88b8-4316-aaea-f7fb7808c45b">
For `anonymous_78` 
1. [15, 512] means
2. 512 maps to `EncMatchType`
3. 15 maps to `LLVMType`

we compare that to `anonymous_6913` `31, 768, 42, 512`

1. 31 is `LLVMScalarOrSameVectorWidth`
2. 768 is `EncSameWidth`
3. 42 is `LLVMVectorElementType`
4. 512 maps to `EncMatchType`

so when we match on anonymous_6913 we match on width and element type as well.

so then if we look at just `int_dx_lerp`  the type sig differences are [15, 7]  vs  [31, 3, 42, 7] with [15, 3] being the same for both.

```
def ArgKind {
  int Any = 0;
  int AnyInteger = 1;
  int AnyFloat = 2;
  int AnyVector = 3;
  int AnyPointer = 4;
  int MatchType = 7;
}
```
The  7 just means match
The  3 means any vector

So with just LLVMMatchType we are matching on anyvector but any vector doesn't get encoded into the  return or argument types. Further we don't get 42  the `LLVMVectorElementType` or  31 the `LLVMScalarOrSameVectorWidth`.

Legend to determine signatures:
![image](https://github.com/llvm/llvm-project/assets/1802579/27b86f6d-14a2-4543-a8eb-3f887cdbea85)



https://github.com/llvm/llvm-project/pull/83077


More information about the cfe-commits mailing list