[clang] [Clang] `constexpr` builtin floating point classification / comparison functions (PR #94118)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 4 06:36:15 PDT 2024
================
@@ -430,6 +430,78 @@ static bool interp__builtin_iszero(InterpState &S, CodePtr OpPC,
return true;
}
+static bool interp__builtin_signbit(InterpState &S, CodePtr OpPC,
+ const InterpFrame *Frame, const Function *F,
+ const CallExpr *Call) {
+ const Floating &Arg = S.Stk.peek<Floating>();
+
+ pushInteger(S, Arg.isNegative(), Call->getType());
+ return true;
+}
+
+static bool interp_floating_comparison(InterpState &S, CodePtr OpPC,
+ const InterpFrame *Frame,
+ const Function *F,
+ const CallExpr *Call) {
+ const Floating &RHS = S.Stk.peek<Floating>();
+ const Floating &LHS = S.Stk.peek<Floating>(align(2u * primSize(PT_Float)));
+ unsigned ID = F->getBuiltinID();
+ assert(ID == Builtin::BI__builtin_isgreater ||
+ ID == Builtin::BI__builtin_isgreaterequal ||
+ ID == Builtin::BI__builtin_isless ||
+ ID == Builtin::BI__builtin_islessequal ||
+ ID == Builtin::BI__builtin_islessgreater ||
+ ID == Builtin::BI__builtin_isunordered);
+
+ ComparisonCategoryResult Cmp = LHS.compare(RHS);
+ bool FunctionResult;
+ if (ID == Builtin::BI__builtin_isunordered ||
----------------
AaronBallman wrote:
It would be nice if we could share much of this implementation with the one in ExprConstant.cpp instead of duplicating the code. However, I don't insist (eventually I hope the ExprConstant.cpp code will go away).
https://github.com/llvm/llvm-project/pull/94118
More information about the cfe-commits
mailing list