[llvm] [DirectX][DXIL] Distinguish return type for overload type resolution. (PR #85646)

S. Bharadwaj Yadavalli via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 18 12:29:54 PDT 2024


================
@@ -229,13 +229,13 @@ static Type *getTypeFromParameterKind(ParameterKind Kind, Type *OverloadTy) {
 ///               its specification in DXIL.td.
 /// \param OverloadTy Return type to be used to construct DXIL function type.
 static FunctionType *getDXILOpFunctionType(const OpCodeProperty *Prop,
-                                           Type *OverloadTy) {
+                                           Type *ReturnTy, Type *OverloadTy) {
   SmallVector<Type *> ArgTys;
 
   auto ParamKinds = getOpCodeParameterKind(*Prop);
 
-  // Add OverloadTy as return type of the function
-  ArgTys.emplace_back(OverloadTy);
+  // Add ReturnTy as return type of the function
+  ArgTys.emplace_back(ReturnTy);
----------------
bharadwajy wrote:

> From what I can tell the fix was to add the return type field and add it as the firstArg and then the change in llvm/utils/TableGen/DXILEmitter.cpp that lets you toggle between index 0 an1 for the overload type. Everything else looks to be a change to support these two changes?

As noted in the PR description, current implementation in `DXILEmitter` assumes the return type to be the same as parameter overload type, if one exists. This change breaks that amalgamated view as return type and overload type (see the added `ReturnTy` parameter to a couple of functions along with the existing `OverloadTy` parameter). Making this distinction allows for correctly addressing the case where the return type and overload type are different. Return type is already part of the type-vector along with parameter types and thus not newly added nor is a toggle involved. 

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


More information about the llvm-commits mailing list