From aa7c85ca71859aab15bdf1e6dc1ea3a5aa5d1e28 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Thu, 13 Aug 2026 06:52:15 +0800 Subject: [Support] Split APInt and APFloat ownership --- backend/lib/CodeGen/GenericConstant.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'backend/lib/CodeGen/GenericConstant.cpp') diff --git a/backend/lib/CodeGen/GenericConstant.cpp b/backend/lib/CodeGen/GenericConstant.cpp index d9d9233..afcdd44 100644 --- a/backend/lib/CodeGen/GenericConstant.cpp +++ b/backend/lib/CodeGen/GenericConstant.cpp @@ -203,8 +203,7 @@ nonPointerFixedBitWidth(const GenericConstantType &Type) noexcept { return false; } -[[nodiscard]] bool signedIntegerLess(const IntegerImmediate &Left, - const IntegerImmediate &Right) noexcept { +[[nodiscard]] bool signedIntegerLess(const APInt &Left, const APInt &Right) noexcept { if (Left.bitWidth() != Right.bitWidth()) return false; if (Left.isNegative() != Right.isNegative()) @@ -249,7 +248,7 @@ nonPointerFixedBitWidth(const GenericConstantType &Type) noexcept { case GenericConstantTypeKind::Metadata: return RequireNoElements(); case GenericConstantTypeKind::Integer: - if (Type.BitWidth == 0 || Type.BitWidth > IntegerImmediate::MaxBitWidth) { + if (Type.BitWidth == 0 || Type.BitWidth > APInt::MaxBitWidth) { return makeUnexpected(ErrorCode::VerificationError, "generic integer type has an invalid bit width"); } @@ -257,7 +256,7 @@ nonPointerFixedBitWidth(const GenericConstantType &Type) noexcept { case GenericConstantTypeKind::Byte: return RequireNoElements(); case GenericConstantTypeKind::Floating: - if (!isKnownFloatSemantics(Type.Semantics)) { + if (!getFloatSemanticsBitWidth(Type.Semantics)) { return makeUnexpected(ErrorCode::VerificationError, "generic floating type has unknown semantics"); } @@ -702,7 +701,7 @@ nonPointerFixedBitWidth(const GenericConstantType &Type) noexcept { } // namespace Expected GenericConstantType::integer(std::uint32_t Width) { - if (Width == 0 || Width > IntegerImmediate::MaxBitWidth) + if (Width == 0 || Width > APInt::MaxBitWidth) return makeUnexpected(ErrorCode::InvalidArgument, "generic integer type width is invalid"); GenericConstantType Type; Type.Kind = GenericConstantTypeKind::Integer; @@ -724,7 +723,7 @@ GenericConstantType GenericConstantType::byte() noexcept { } Expected GenericConstantType::floating(FloatSemantics ValueSemantics) { - if (!isKnownFloatSemantics(ValueSemantics)) + if (!getFloatSemanticsBitWidth(ValueSemantics)) return makeUnexpected(ErrorCode::InvalidArgument, "generic floating semantics is unknown"); GenericConstantType Type; Type.Kind = GenericConstantTypeKind::Floating; @@ -810,7 +809,7 @@ Expected GenericConstantType::verify() const { return verifyType(*this, 0, Nodes); } -Expected GenericConstantData::integer(IntegerImmediate Value) { +Expected GenericConstantData::integer(APInt Value) { auto Type = GenericConstantType::integer(Value.bitWidth()); if (!Type) return std::unexpected(Type.error()); @@ -821,7 +820,7 @@ Expected GenericConstantData::integer(IntegerImmediate Valu return Result; } -Expected GenericConstantData::floating(FloatingPointBits Value) { +Expected GenericConstantData::floating(APFloat Value) { auto Type = GenericConstantType::floating(Value.semantics()); if (!Type) return std::unexpected(Type.error()); -- cgit v1.2.3