[PATCH] D155367: [clang][Interp] Implement __builtin_inf() etc.

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 28 01:50:49 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb395e91f2ef4: [clang][Interp] Implement __builtin_inf() etc. (authored by tbaeder).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155367/new/

https://reviews.llvm.org/D155367

Files:
  clang/lib/AST/Interp/InterpBuiltin.cpp


Index: clang/lib/AST/Interp/InterpBuiltin.cpp
===================================================================
--- clang/lib/AST/Interp/InterpBuiltin.cpp
+++ clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -121,6 +121,15 @@
   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 @@
       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;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155367.545061.patch
Type: text/x-patch
Size: 1321 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230728/d593429d/attachment.bin>


More information about the cfe-commits mailing list