[PATCH] D155372: [clang][Interp] Implement __builtin_isfinite
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 31 00:13:07 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf444f396863c: [clang][Interp] Implement __builtin_isfinite (authored by tbaeder).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155372/new/
https://reviews.llvm.org/D155372
Files:
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
@@ -76,4 +76,7 @@
namespace inf {
static_assert(__builtin_isinf(__builtin_inf()), "");
static_assert(!__builtin_isinf(1.0), "");
+
+ static_assert(__builtin_isfinite(1.0), "");
+ static_assert(!__builtin_isfinite(__builtin_inf()), "");
}
Index: clang/lib/AST/Interp/InterpBuiltin.cpp
===================================================================
--- clang/lib/AST/Interp/InterpBuiltin.cpp
+++ clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -187,6 +187,15 @@
return true;
}
+static bool interp__builtin_isfinite(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.isFinite()));
+ return true;
+}
+
bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) {
InterpFrame *Frame = S.Current;
APValue Dummy;
@@ -263,6 +272,11 @@
return Ret<PT_Sint32>(S, OpPC, Dummy);
break;
+ case Builtin::BI__builtin_isfinite:
+ if (interp__builtin_isfinite(S, OpPC, Frame, F))
+ return Ret<PT_Sint32>(S, OpPC, Dummy);
+ break;
+
default:
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155372.545522.patch
Type: text/x-patch
Size: 1442 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230731/777b90c0/attachment.bin>
More information about the cfe-commits
mailing list