[PATCH] D155368: [clang][Interp] __builtin_copysign
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG57ca62d5d35a: [clang][Interp] Implement __builtin_copysign (authored by tbaeder). Changed prior to commit: https://reviews.llvm.org/D155368?vs=541325=545065#toc Repository: rG LLVM Github Monorepo 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 @@ -130,6 +130,19 @@ return true; } +static bool interp__builtin_copysign(InterpState , CodePtr OpPC, + const InterpFrame *Frame, + const Function *F) { + const Floating = getParam(Frame, 0); + const Floating = getParam(Frame, 1); + + APFloat Copy = Arg1.getAPFloat(); + Copy.copySign(Arg2.getAPFloat()); + S.Stk.push(Floating(Copy)); + + return true; +} + bool InterpretBuiltin(InterpState , CodePtr OpPC, const Function *F) { InterpFrame *Frame = S.Current; APValue Dummy; @@ -174,6 +187,13 @@ if (interp__builtin_inf(S, OpPC, Frame, F)) return Ret(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(S, OpPC, Dummy); +break; default: return false; Index: clang/lib/AST/Interp/InterpBuiltin.cpp === --- clang/lib/AST/Interp/InterpBuiltin.cpp +++ clang/lib/AST/Interp/InterpBuiltin.cpp @@ -130,6 +130,19 @@ return true; } +static bool interp__builtin_copysign(InterpState , CodePtr OpPC, + const InterpFrame *Frame, + const Function *F) { + const Floating = getParam(Frame, 0); + const Floating = getParam(Frame, 1); + + APFloat Copy = Arg1.getAPFloat(); + Copy.copySign(Arg2.getAPFloat()); + S.Stk.push(Floating(Copy)); + + return true; +} + bool InterpretBuiltin(InterpState , CodePtr OpPC, const Function *F) { InterpFrame *Frame = S.Current; APValue Dummy; @@ -174,6 +187,13 @@ if (interp__builtin_inf(S, OpPC, Frame, F)) return Ret(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(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
[PATCH] D155368: [clang][Interp] __builtin_copysign
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D155368/new/ https://reviews.llvm.org/D155368 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D155368: [clang][Interp] __builtin_copysign
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 , CodePtr OpPC, + const InterpFrame *Frame, + const Function *F) { + const Floating = getParam(Frame, 0); + const Floating = getParam(Frame, 1); + + APFloat Copy = Arg1.getAPFloat(); + Copy.copySign(Arg2.getAPFloat()); + S.Stk.push(Floating(Copy)); + + return true; +} + bool InterpretBuiltin(InterpState , 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(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(S, OpPC, Dummy); +break; + default: return false; 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 , CodePtr OpPC, + const InterpFrame *Frame, + const Function *F) { + const Floating = getParam(Frame, 0); + const Floating = getParam(Frame, 1); + + APFloat Copy = Arg1.getAPFloat(); + Copy.copySign(Arg2.getAPFloat()); + S.Stk.push(Floating(Copy)); + + return true; +} + bool InterpretBuiltin(InterpState , 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(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(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
[PATCH] D155368: [clang][Interp] __builtin_copysign
tbaeder added a comment. I can add some basic tests for `__builtin_copysign` here, but there are test added in https://reviews.llvm.org/D155369 as well. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D155368/new/ https://reviews.llvm.org/D155368 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D155368: [clang][Interp] __builtin_copysign
aaron.ballman added a comment. Missing test coverage for copysign. Comment at: clang/lib/AST/Interp/InterpBuiltin.cpp:141 + +static bool interp__builtin_fmin(InterpState , CodePtr OpPC, + const InterpFrame *Frame, const Function *F) { Should split out the fmin functionality into a separate patch. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D155368/new/ https://reviews.llvm.org/D155368 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D155368: [clang][Interp] __builtin_copysign
tbaeder created this revision. tbaeder added reviewers: aaron.ballman, erichkeane, shafik. Herald added a project: All. tbaeder requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Repository: rG LLVM Github Monorepo 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 @@ -125,6 +125,38 @@ return true; } +static bool interp__builtin_copysign(InterpState , CodePtr OpPC, + const InterpFrame *Frame, + const Function *F) { + const Floating = getParam(Frame, 0); + const Floating = getParam(Frame, 1); + + APFloat Copy = Arg1.getAPFloat(); + Copy.copySign(Arg2.getAPFloat()); + S.Stk.push(Floating(Copy)); + + return true; +} + +static bool interp__builtin_fmin(InterpState , CodePtr OpPC, + const InterpFrame *Frame, const Function *F) { + const Floating = getParam(Frame, 0); + const Floating = getParam(Frame, 1); + + Floating Result; + + // When comparing zeroes, return -0.0 if one of the zeroes is negative. + if (LHS.isZero() && RHS.isZero() && RHS.isNegative()) +Result = RHS; + else if (LHS.isNan() || RHS < LHS) +Result = RHS; + else +Result = LHS; + + S.Stk.push(Result); + return true; +} + bool InterpretBuiltin(InterpState , CodePtr OpPC, const Function *F) { InterpFrame *Frame = S.Current; APValue Dummy; @@ -163,6 +195,22 @@ if (interp__builtin_inf(S, OpPC, Frame, F)) return Ret(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(S, OpPC, Dummy); +break; + + case Builtin::BI__builtin_fmin: + case Builtin::BI__builtin_fminf: + case Builtin::BI__builtin_fminl: + case Builtin::BI__builtin_fminf16: + case Builtin::BI__builtin_fminf128: +if (interp__builtin_fmin(S, OpPC, Frame, F)) + return Ret(S, OpPC, Dummy); +break; default: return false; Index: clang/lib/AST/Interp/InterpBuiltin.cpp === --- clang/lib/AST/Interp/InterpBuiltin.cpp +++ clang/lib/AST/Interp/InterpBuiltin.cpp @@ -125,6 +125,38 @@ return true; } +static bool interp__builtin_copysign(InterpState , CodePtr OpPC, + const InterpFrame *Frame, + const Function *F) { + const Floating = getParam(Frame, 0); + const Floating = getParam(Frame, 1); + + APFloat Copy = Arg1.getAPFloat(); + Copy.copySign(Arg2.getAPFloat()); + S.Stk.push(Floating(Copy)); + + return true; +} + +static bool interp__builtin_fmin(InterpState , CodePtr OpPC, + const InterpFrame *Frame, const Function *F) { + const Floating = getParam(Frame, 0); + const Floating = getParam(Frame, 1); + + Floating Result; + + // When comparing zeroes, return -0.0 if one of the zeroes is negative. + if (LHS.isZero() && RHS.isZero() && RHS.isNegative()) +Result = RHS; + else if (LHS.isNan() || RHS < LHS) +Result = RHS; + else +Result = LHS; + + S.Stk.push(Result); + return true; +} + bool InterpretBuiltin(InterpState , CodePtr OpPC, const Function *F) { InterpFrame *Frame = S.Current; APValue Dummy; @@ -163,6 +195,22 @@ if (interp__builtin_inf(S, OpPC, Frame, F)) return Ret(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(S, OpPC, Dummy); +break; + + case Builtin::BI__builtin_fmin: + case Builtin::BI__builtin_fminf: + case Builtin::BI__builtin_fminl: + case Builtin::BI__builtin_fminf16: + case Builtin::BI__builtin_fminf128: +if (interp__builtin_fmin(S, OpPC, Frame, F)) + return Ret(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