From 57828fec760f086b334ce0cb1c465fc559dcaea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 17 Jun 2025 21:08:23 +0200 Subject: Revert "[clang][bytecode] Allocate IntegralAP and Floating types using an allocator (#144246)" This reverts commit c66be289901b3f035187d391e80e3610d7d6232e. This breaks the armv8-quick builder: https://lab.llvm.org/buildbot/#/builders/154/builds/17549 --- 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