[llvm] [DirectX][NFC] Model precise overload type specification of DXIL Ops (PR #83917)

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 7 09:54:00 PST 2024


================
@@ -219,6 +269,20 @@ static std::string getOverloadKindStr(MVT::SimpleValueType VT) {
     return "OverloadKind::I16 | OverloadKind::I32 | OverloadKind::I64";
   case MVT::fAny:
     return "OverloadKind::HALF | OverloadKind::FLOAT | OverloadKind::DOUBLE";
+  case MVT::Other:
+    // Handle DXIL-specific overload types
+    {
+      auto RetStr =
+          StringSwitch<std::string>(R->getNameInitAsString())
+              .Case("llvm_i16ori32_ty", "OverloadKind::I16 | OverloadKind::I32")
+              .Case("llvm_halforfloat_ty",
+                    "OverloadKind::HALF | OverloadKind::FLOAT")
----------------
bogner wrote:

String matching on these two types doesn't feel very robust or scalable - I think we want to do this slightly differently.

One option that keeps this simple but encodes the information a bit more clearly would be to add bits to LLVMType, like so:
```
let isHalfOrFloat = 0
```

This still isn't very extensible but it accomplishes the approach you have here a little bit more cleanly.

The other option is of course to support lists of types and embed them in some kind of LLVMAlternativeType or something, but that's quite a bit more complex and might be overkill.

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


More information about the llvm-commits mailing list