[llvm] [ValueTypes][NFC] Generate EVT::getTypeForEVT from GenVT.inc (PR #96608)

Kito Cheng via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 26 18:29:16 PDT 2024


================
@@ -29,6 +29,51 @@ class VTEmitter {
 
 } // End anonymous namespace.
 
+static void VTtoGetLLVMTyString(raw_ostream &OS, const Record *VT) {
+  bool IsVector = VT->getValueAsBit("isVector");
+  if (IsVector)
+    OS << (VT->getValueAsBit("isScalable") ? "Scalable" : "Fixed")
+       << "VectorType::get(";
+
+  auto OutputVT = IsVector ? VT->getValueAsDef("ElementType") : VT;
+  int64_t OutputVTSize = OutputVT->getValueAsInt("Size");
+
+  if (OutputVT->getValueAsBit("isFP")) {
+    StringRef FloatTy;
+    auto OutputVTName = OutputVT->getValueAsString("LLVMName");
+    switch (OutputVTSize) {
+    default:
+      llvm_unreachable("Unhandled case");
+    case 16:
+      FloatTy = (OutputVTName == "bf16") ? "BFloatTy" : "HalfTy";
+      break;
+    case 32:
+      FloatTy = "FloatTy";
+      break;
+    case 64:
+      FloatTy = "DoubleTy";
+      break;
+    case 80:
+      FloatTy = "X86_FP80Ty";
+      break;
+    case 128:
+      FloatTy = (OutputVTName == "ppcf128") ? "PPC_FP128Ty" : "FP128Ty";
+      break;
+    }
+    OS << "Type::get" << FloatTy << "(Context)";
+  } else if (OutputVT->getValueAsBit("isInteger")) {
+    // We only have Type::getInt1Ty, Int8, Int16, Int32, and Int64
+    if ((isPowerOf2_64(OutputVTSize) && OutputVTSize > 8) || OutputVTSize == 1)
----------------
kito-cheng wrote:

You are right, fixed :P

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


More information about the llvm-commits mailing list