================
@@ -712,6 +712,36 @@ static bool interp__builtin_expect(InterpState &S, CodePtr 
OpPC,
   return true;
 }
 
+
+/// rotateleft(value, amount)
+static bool interp__builtin_rotate(InterpState &S, CodePtr OpPC,
+                                   const InterpFrame *Frame,
+                                   const CallExpr *Call, bool Right) {
+  APSInt Amount = popToAPSInt(S, Call->getArg(1));
+  APSInt Value = popToAPSInt(S, Call->getArg(0));
+
+  APSInt Result;
+  if (Right)
+    Result = APSInt(Value.rotr(Amount.urem(Value.getBitWidth())),
+                    /*IsUnsigned=*/true);
+  else // Left.
+    Result = APSInt(Value.rotl(Amount.urem(Value.getBitWidth())),
+                    /*IsUnsigned=*/true);
+
+  pushInteger(S, Result, Call->getType());
+  return true;
+}
+
+static bool interp__builtin_ffs(InterpState &S, CodePtr OpPC,
+                                const InterpFrame *Frame,
+                                const CallExpr *Call) {
+  APSInt Value = popToAPSInt(S, Call->getArg(0));
+
+  uint64_t N = Value.countr_zero();
+  pushInteger(S, N == Value.getBitWidth() ? 0 : N + 1, Call->getType());
+  return true;
+}
+
----------------
tbaederr wrote:

Those two functions were removed upstream.

https://github.com/llvm/llvm-project/pull/158853
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to