[PATCH] D155368: [clang][Interp] __builtin_copysign
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 17 23:01:57 PDT 2023
tbaeder updated this revision to Diff 541325.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155368/new/
https://reviews.llvm.org/D155368
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
@@ -126,6 +126,19 @@
return true;
}
+static bool interp__builtin_copysign(InterpState &S, CodePtr OpPC,
+ const InterpFrame *Frame,
+ const Function *F) {
+ const Floating &Arg1 = getParam<Floating>(Frame, 0);
+ const Floating &Arg2 = getParam<Floating>(Frame, 1);
+
+ APFloat Copy = Arg1.getAPFloat();
+ Copy.copySign(Arg2.getAPFloat());
+ S.Stk.push<Floating>(Floating(Copy));
+
+ return true;
+}
+
bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) {
InterpFrame *Frame = S.Current;
APValue Dummy;
@@ -170,6 +183,14 @@
if (interp__builtin_inf(S, OpPC, Frame, F))
return Ret<PT_Float>(S, OpPC, Dummy);
break;
+ case Builtin::BI__builtin_copysign:
+ case Builtin::BI__builtin_copysignf:
+ case Builtin::BI__builtin_copysignl:
+ case Builtin::BI__builtin_copysignf128:
+ if (interp__builtin_copysign(S, OpPC, Frame, F))
+ return Ret<PT_Float>(S, OpPC, Dummy);
+ break;
+
default:
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155368.541325.patch
Type: text/x-patch
Size: 1247 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230718/6a827b91/attachment.bin>
More information about the cfe-commits
mailing list