Author: Timm Bäder Date: 2023-07-28T10:50:13+02:00 New Revision: b395e91f2ef41e44c99857b5dd4e241a57d12b76
URL: https://github.com/llvm/llvm-project/commit/b395e91f2ef41e44c99857b5dd4e241a57d12b76 DIFF: https://github.com/llvm/llvm-project/commit/b395e91f2ef41e44c99857b5dd4e241a57d12b76.diff LOG: [clang][Interp] Implement __builtin_inf() etc. Differential Revision: https://reviews.llvm.org/D155367 Added: Modified: clang/lib/AST/Interp/InterpBuiltin.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/InterpBuiltin.cpp b/clang/lib/AST/Interp/InterpBuiltin.cpp index a8758d8cc0569a..7d8ca716cc8025 100644 --- a/clang/lib/AST/Interp/InterpBuiltin.cpp +++ b/clang/lib/AST/Interp/InterpBuiltin.cpp @@ -121,6 +121,15 @@ static bool interp__builtin_nan(InterpState &S, CodePtr OpPC, return true; } +static bool interp__builtin_inf(InterpState &S, CodePtr OpPC, + const InterpFrame *Frame, const Function *F) { + const llvm::fltSemantics &TargetSemantics = + S.getCtx().getFloatTypeSemantics(F->getDecl()->getReturnType()); + + S.Stk.push<Floating>(Floating::getInf(TargetSemantics)); + return true; +} + bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) { InterpFrame *Frame = S.Current; APValue Dummy; @@ -152,6 +161,20 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) { return Ret<PT_Float>(S, OpPC, Dummy); break; + case Builtin::BI__builtin_huge_val: + case Builtin::BI__builtin_huge_valf: + case Builtin::BI__builtin_huge_vall: + case Builtin::BI__builtin_huge_valf16: + case Builtin::BI__builtin_huge_valf128: + case Builtin::BI__builtin_inf: + case Builtin::BI__builtin_inff: + case Builtin::BI__builtin_infl: + case Builtin::BI__builtin_inff16: + case Builtin::BI__builtin_inff128: + if (interp__builtin_inf(S, OpPC, Frame, F)) + return Ret<PT_Float>(S, OpPC, Dummy); + break; + default: return false; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits