[Mlir-commits] [mlir] [mlir] Migrate away from a soft-deprecated constructor of APInt (NFC) (PR #166128)

Kazu Hirata llvmlistbot at llvm.org
Mon Nov 3 07:17:33 PST 2025


https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/166128

>From 1207eda10f9fe822af9acfaf840f5bd7fa5a0696 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 2 Nov 2025 15:04:58 -0800
Subject: [PATCH 1/2] [mlir] Migrate away from a soft-deprecated constructor of
 APInt (NFC)

We have:

/// Once all uses of this constructor are migrated to other constructors,
/// consider marking this overload ""= delete" to prevent calls from being
/// incorrectly bound to the APInt(unsigned, uint64_t, bool) constructor.
LLVM_ABI APInt(unsigned numBits, unsigned numWords, const uint64_t bigVal[]);

This patch migrates away from this soft-deprecated constructor.
---
 mlir/lib/AsmParser/Parser.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/AsmParser/Parser.cpp b/mlir/lib/AsmParser/Parser.cpp
index 82bdb844480f1..6c1fde4b9542c 100644
--- a/mlir/lib/AsmParser/Parser.cpp
+++ b/mlir/lib/AsmParser/Parser.cpp
@@ -407,8 +407,8 @@ Parser::parseFloatFromIntegerLiteral(std::optional<APFloat> &result,
                      "hexadecimal float constant out of range for type");
   }
 
-  APInt truncatedValue(typeSizeInBits, intValue.getNumWords(),
-                       intValue.getRawData());
+  APInt truncatedValue(typeSizeInBits, llvm::ArrayRef(intValue.getRawData(),
+                                                      intValue.getNumWords()));
   result.emplace(semantics, truncatedValue);
   return success();
 }

>From 8df5371be2b321176dd9ccfa195c353438d1c66c Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 3 Nov 2025 07:17:14 -0800
Subject: [PATCH 2/2] Address a comment.

---
 mlir/lib/AsmParser/Parser.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/AsmParser/Parser.cpp b/mlir/lib/AsmParser/Parser.cpp
index 6c1fde4b9542c..74936e32bd9d9 100644
--- a/mlir/lib/AsmParser/Parser.cpp
+++ b/mlir/lib/AsmParser/Parser.cpp
@@ -407,8 +407,8 @@ Parser::parseFloatFromIntegerLiteral(std::optional<APFloat> &result,
                      "hexadecimal float constant out of range for type");
   }
 
-  APInt truncatedValue(typeSizeInBits, llvm::ArrayRef(intValue.getRawData(),
-                                                      intValue.getNumWords()));
+  APInt truncatedValue(typeSizeInBits,
+                       ArrayRef(intValue.getRawData(), intValue.getNumWords()));
   result.emplace(semantics, truncatedValue);
   return success();
 }



More information about the Mlir-commits mailing list