From 68471d29eed2c49f9b439e505b3f24d387d54f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Wed, 18 Jun 2025 15:17:53 +0200 Subject: =?UTF-8?q?Revert=20"Reapply=20"[clang][bytecode]=20Allocate=20Int?= =?UTF-8?q?egralAP=20and=20Floating=20types=20usi=E2=80=A6=20(#144676)"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 7c15edb306932e41c159f3d69c161ed0d89d47b7. This still breaks clang-armv8-quick: https://lab.llvm.org/buildbot/#/builders/154/builds/17587 --- clang/lib/AST/ByteCode/InterpBuiltin.cpp | 55 +++++++------------------------- 1 file changed, 12 insertions(+), 43 deletions(-) (limited to 'clang/lib/AST/ByteCode/InterpBuiltin.cpp') diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index 5304bd7..d01e3d0 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -57,21 +57,6 @@ static void pushInteger(InterpState &S, const APSInt &Val, QualType QT) { assert(T); unsigned BitWidth = S.getASTContext().getTypeSize(QT); - - if (T == PT_IntAPS) { - auto Result = S.allocAP>(BitWidth); - Result.copy(Val); - S.Stk.push>(Result); - return; - } - - if (T == PT_IntAP) { - auto Result = S.allocAP>(BitWidth); - Result.copy(Val); - S.Stk.push>(Result); - return; - } - if (QT->isSignedIntegerOrEnumerationType()) { int64_t V = Val.getSExtValue(); INT_TYPE_SWITCH(*T, { S.Stk.push(T::from(V, BitWidth)); }); @@ -342,13 +327,13 @@ static bool interp__builtin_nan(InterpState &S, CodePtr OpPC, S.getASTContext().getFloatTypeSemantics( Call->getDirectCallee()->getReturnType()); - Floating Result = S.allocFloat(TargetSemantics); + Floating Result; if (S.getASTContext().getTargetInfo().isNan2008()) { if (Signaling) - Result.copy( + Result = Floating( llvm::APFloat::getSNaN(TargetSemantics, /*Negative=*/false, &Fill)); else - Result.copy( + Result = Floating( llvm::APFloat::getQNaN(TargetSemantics, /*Negative=*/false, &Fill)); } else { // Prior to IEEE 754-2008, architectures were allowed to choose whether @@ -357,10 +342,10 @@ static bool interp__builtin_nan(InterpState &S, CodePtr OpPC, // 2008 revisions, MIPS interpreted sNaN-2008 as qNan and qNaN-2008 as // sNaN. This is now known as "legacy NaN" encoding. if (Signaling) - Result.copy( + Result = Floating( llvm::APFloat::getQNaN(TargetSemantics, /*Negative=*/false, &Fill)); else - Result.copy( + Result = Floating( llvm::APFloat::getSNaN(TargetSemantics, /*Negative=*/false, &Fill)); } @@ -375,9 +360,7 @@ static bool interp__builtin_inf(InterpState &S, CodePtr OpPC, S.getASTContext().getFloatTypeSemantics( Call->getDirectCallee()->getReturnType()); - Floating Result = S.allocFloat(TargetSemantics); - Result.copy(APFloat::getInf(TargetSemantics)); - S.Stk.push(Result); + S.Stk.push(Floating::getInf(TargetSemantics)); return true; } @@ -385,12 +368,10 @@ static bool interp__builtin_copysign(InterpState &S, CodePtr OpPC, const InterpFrame *Frame) { const Floating &Arg2 = S.Stk.pop(); const Floating &Arg1 = S.Stk.pop(); - Floating Result = S.allocFloat(Arg1.getSemantics()); APFloat Copy = Arg1.getAPFloat(); Copy.copySign(Arg2.getAPFloat()); - Result.copy(Copy); - S.Stk.push(Result); + S.Stk.push(Floating(Copy)); return true; } @@ -399,13 +380,11 @@ static bool interp__builtin_fmin(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, bool IsNumBuiltin) { const Floating &RHS = S.Stk.pop(); const Floating &LHS = S.Stk.pop(); - Floating Result = S.allocFloat(LHS.getSemantics()); if (IsNumBuiltin) - Result.copy(llvm::minimumnum(LHS.getAPFloat(), RHS.getAPFloat())); + S.Stk.push(llvm::minimumnum(LHS.getAPFloat(), RHS.getAPFloat())); else - Result.copy(minnum(LHS.getAPFloat(), RHS.getAPFloat())); - S.Stk.push(Result); + S.Stk.push(minnum(LHS.getAPFloat(), RHS.getAPFloat())); return true; } @@ -413,13 +392,11 @@ static bool interp__builtin_fmax(InterpState &S, CodePtr OpPC, const InterpFrame *Frame, bool IsNumBuiltin) { const Floating &RHS = S.Stk.pop(); const Floating &LHS = S.Stk.pop(); - Floating Result = S.allocFloat(LHS.getSemantics()); if (IsNumBuiltin) - Result.copy(llvm::maximumnum(LHS.getAPFloat(), RHS.getAPFloat())); + S.Stk.push(llvm::maximumnum(LHS.getAPFloat(), RHS.getAPFloat())); else - Result.copy(maxnum(LHS.getAPFloat(), RHS.getAPFloat())); - S.Stk.push(Result); + S.Stk.push(maxnum(LHS.getAPFloat(), RHS.getAPFloat())); return true; } @@ -594,16 +571,8 @@ static bool interp__builtin_fpclassify(InterpState &S, CodePtr OpPC, static bool interp__builtin_fabs(InterpState &S, CodePtr OpPC, const InterpFrame *Frame) { const Floating &Val = S.Stk.pop(); - APFloat F = Val.getAPFloat(); - if (!F.isNegative()) { - S.Stk.push(Val); - return true; - } - Floating Result = S.allocFloat(Val.getSemantics()); - F.changeSign(); - Result.copy(F); - S.Stk.push(Result); + S.Stk.push(Floating::abs(Val)); return true; } -- cgit v1.1