@@ -56,20 +56,6 @@ static APSInt popToAPSInt(InterpState &S, QualType T) {
5656 return popToAPSInt (S.Stk , *S.getContext ().classify (T));
5757}
5858
59- static APInt ROTL_fn (const APSInt &A, const APSInt &B) {
60- const APInt &X = static_cast <const APInt &>(A);
61- const unsigned BW = X.getBitWidth ();
62- const uint64_t Amt = B.getZExtValue ();
63- return X.rotl (static_cast <unsigned >(Amt % BW));
64- }
65-
66- static APInt ROTR_fn (const APSInt &A, const APSInt &B) {
67- const APInt &X = static_cast <const APInt &>(A);
68- const unsigned BW = X.getBitWidth ();
69- const uint64_t Amt = B.getZExtValue ();
70- return X.rotr (static_cast <unsigned >(Amt % BW));
71- }
72-
7359// / Pushes \p Val on the stack as the type given by \p QT.
7460static void pushInteger (InterpState &S, const APSInt &Val, QualType QT) {
7561 assert (QT->isSignedIntegerOrEnumerationType () ||
@@ -3176,7 +3162,10 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
31763162 case Builtin::BI_rotl:
31773163 case Builtin::BI_lrotl:
31783164 case Builtin::BI_rotl64:
3179- return interp__builtin_elementwise_int_binop (S, OpPC, Call, ROTL_fn);
3165+ return interp__builtin_elementwise_int_binop (
3166+ S, OpPC, Call, [](const APSInt &A, const APSInt &B) -> APInt {
3167+ return A.rotl ((unsigned )B.getLimitedValue ());
3168+ });
31803169
31813170 case Builtin::BI__builtin_rotateright8:
31823171 case Builtin::BI__builtin_rotateright16:
@@ -3187,7 +3176,10 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call,
31873176 case Builtin::BI_rotr:
31883177 case Builtin::BI_lrotr:
31893178 case Builtin::BI_rotr64:
3190- return interp__builtin_elementwise_int_binop (S, OpPC, Call, ROTR_fn);
3179+ return interp__builtin_elementwise_int_binop (
3180+ S, OpPC, Call, [](const APSInt &A, const APSInt &B) -> APInt {
3181+ return A.rotr ((unsigned )B.getLimitedValue ());
3182+ });
31913183
31923184 case Builtin::BI__builtin_ffs:
31933185 case Builtin::BI__builtin_ffsl:
0 commit comments