[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:57 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
----------------
kito-cheng wrote:
Yeah, and I also add check the size is less or equal than 128 in the code now
https://github.com/llvm/llvm-project/pull/96608
More information about the llvm-commits
mailing list