This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGd37f1e9965bd: [clang][Interp] Implement __builtin_isnormal (authored by tbaeder).
Changed prior to commit: https://reviews.llvm.org/D155374?vs=540700&id=545523#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D155374/new/ https://reviews.llvm.org/D155374 Files: clang/lib/AST/Interp/Floating.h clang/lib/AST/Interp/InterpBuiltin.cpp clang/test/AST/Interp/builtin-functions.cpp Index: clang/test/AST/Interp/builtin-functions.cpp =================================================================== --- clang/test/AST/Interp/builtin-functions.cpp +++ clang/test/AST/Interp/builtin-functions.cpp @@ -79,4 +79,7 @@ static_assert(__builtin_isfinite(1.0), ""); static_assert(!__builtin_isfinite(__builtin_inf()), ""); + + static_assert(__builtin_isnormal(1.0), ""); + static_assert(!__builtin_isnormal(__builtin_inf()), ""); } Index: clang/lib/AST/Interp/InterpBuiltin.cpp =================================================================== --- clang/lib/AST/Interp/InterpBuiltin.cpp +++ clang/lib/AST/Interp/InterpBuiltin.cpp @@ -196,6 +196,15 @@ return true; } +static bool interp__builtin_isnormal(InterpState &S, CodePtr OpPC, + const InterpFrame *Frame, + const Function *F) { + const Floating &Arg = S.Stk.peek<Floating>(); + + S.Stk.push<Integral<32, true>>(Integral<32, true>::from(Arg.isNormal())); + return true; +} + bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) { InterpFrame *Frame = S.Current; APValue Dummy; @@ -276,6 +285,10 @@ if (interp__builtin_isfinite(S, OpPC, Frame, F)) return Ret<PT_Sint32>(S, OpPC, Dummy); break; + case Builtin::BI__builtin_isnormal: + if (interp__builtin_isnormal(S, OpPC, Frame, F)) + return Ret<PT_Sint32>(S, OpPC, Dummy); + break; default: return false; Index: clang/lib/AST/Interp/Floating.h =================================================================== --- clang/lib/AST/Interp/Floating.h +++ clang/lib/AST/Interp/Floating.h @@ -89,6 +89,7 @@ bool isNan() const { return F.isNaN(); } bool isInf() const { return F.isInfinity(); } bool isFinite() const { return F.isFinite(); } + bool isNormal() const { return F.isNormal(); } ComparisonCategoryResult compare(const Floating &RHS) const { llvm::APFloatBase::cmpResult CmpRes = F.compare(RHS.F);
Index: clang/test/AST/Interp/builtin-functions.cpp =================================================================== --- clang/test/AST/Interp/builtin-functions.cpp +++ clang/test/AST/Interp/builtin-functions.cpp @@ -79,4 +79,7 @@ static_assert(__builtin_isfinite(1.0), ""); static_assert(!__builtin_isfinite(__builtin_inf()), ""); + + static_assert(__builtin_isnormal(1.0), ""); + static_assert(!__builtin_isnormal(__builtin_inf()), ""); } Index: clang/lib/AST/Interp/InterpBuiltin.cpp =================================================================== --- clang/lib/AST/Interp/InterpBuiltin.cpp +++ clang/lib/AST/Interp/InterpBuiltin.cpp @@ -196,6 +196,15 @@ return true; } +static bool interp__builtin_isnormal(InterpState &S, CodePtr OpPC, + const InterpFrame *Frame, + const Function *F) { + const Floating &Arg = S.Stk.peek<Floating>(); + + S.Stk.push<Integral<32, true>>(Integral<32, true>::from(Arg.isNormal())); + return true; +} + bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) { InterpFrame *Frame = S.Current; APValue Dummy; @@ -276,6 +285,10 @@ if (interp__builtin_isfinite(S, OpPC, Frame, F)) return Ret<PT_Sint32>(S, OpPC, Dummy); break; + case Builtin::BI__builtin_isnormal: + if (interp__builtin_isnormal(S, OpPC, Frame, F)) + return Ret<PT_Sint32>(S, OpPC, Dummy); + break; default: return false; Index: clang/lib/AST/Interp/Floating.h =================================================================== --- clang/lib/AST/Interp/Floating.h +++ clang/lib/AST/Interp/Floating.h @@ -89,6 +89,7 @@ bool isNan() const { return F.isNaN(); } bool isInf() const { return F.isInfinity(); } bool isFinite() const { return F.isFinite(); } + bool isNormal() const { return F.isNormal(); } ComparisonCategoryResult compare(const Floating &RHS) const { llvm::APFloatBase::cmpResult CmpRes = F.compare(RHS.F);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits