Skip to content

Commit

Permalink
[clang][Interp] Implement __builtin_inf() etc.
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D155367
  • Loading branch information
tbaederr committed Jul 28, 2023
1 parent afb2e9f commit b395e91
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions clang/lib/AST/Interp/InterpBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit b395e91

Please sign in to comment.