https://github.com/arsenm updated 
https://github.com/llvm/llvm-project/pull/207213

>From 2ba3ac71242aa7eac526cf48b179d89c9adf4d02 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <[email protected]>
Date: Thu, 2 Jul 2026 10:20:37 +0200
Subject: [PATCH] clang: Use getFloatingPointType instead of reinventing it

Co-authored-by: Claude (Opus 4.8) <[email protected]>
---
 clang/lib/CodeGen/CodeGenTypes.cpp | 31 ++++++------------------------
 1 file changed, 6 insertions(+), 25 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp 
b/clang/lib/CodeGen/CodeGenTypes.cpp
index c68a24ca045bc..55fe216580314 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -299,25 +299,6 @@ void CodeGenTypes::RefreshTypeCacheForClass(const 
CXXRecordDecl *RD) {
   }
 }
 
-static llvm::Type *getTypeForFormat(llvm::LLVMContext &VMContext,
-                                    const llvm::fltSemantics &format) {
-  if (&format == &llvm::APFloat::IEEEhalf())
-    return llvm::Type::getHalfTy(VMContext);
-  if (&format == &llvm::APFloat::BFloat())
-    return llvm::Type::getBFloatTy(VMContext);
-  if (&format == &llvm::APFloat::IEEEsingle())
-    return llvm::Type::getFloatTy(VMContext);
-  if (&format == &llvm::APFloat::IEEEdouble())
-    return llvm::Type::getDoubleTy(VMContext);
-  if (&format == &llvm::APFloat::IEEEquad())
-    return llvm::Type::getFP128Ty(VMContext);
-  if (&format == &llvm::APFloat::PPCDoubleDouble())
-    return llvm::Type::getPPC_FP128Ty(VMContext);
-  if (&format == &llvm::APFloat::x87DoubleExtended())
-    return llvm::Type::getX86_FP80Ty(VMContext);
-  llvm_unreachable("Unknown float format!");
-}
-
 llvm::Type *CodeGenTypes::ConvertFunctionTypeInternal(QualType QFT) {
   assert(QFT.isCanonical());
   const FunctionType *FT = cast<FunctionType>(QFT.getTypePtr());
@@ -479,15 +460,15 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
       break;
 
     case BuiltinType::Float16:
-      ResultType =
-          getTypeForFormat(getLLVMContext(), Context.getFloatTypeSemantics(T));
+      ResultType = llvm::Type::getFloatingPointTy(
+          getLLVMContext(), Context.getFloatTypeSemantics(T));
       break;
 
     case BuiltinType::Half:
       // Half FP can either be storage-only (lowered to i16 for ABI purposes) 
or
       // native.
-      ResultType =
-          getTypeForFormat(getLLVMContext(), Context.getFloatTypeSemantics(T));
+      ResultType = llvm::Type::getFloatingPointTy(
+          getLLVMContext(), Context.getFloatTypeSemantics(T));
       break;
     case BuiltinType::LongDouble:
       LongDoubleReferenced = true;
@@ -497,8 +478,8 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
     case BuiltinType::Double:
     case BuiltinType::Float128:
     case BuiltinType::Ibm128:
-      ResultType =
-          getTypeForFormat(getLLVMContext(), Context.getFloatTypeSemantics(T));
+      ResultType = llvm::Type::getFloatingPointTy(
+          getLLVMContext(), Context.getFloatTypeSemantics(T));
       break;
 
     case BuiltinType::NullPtr:

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to