================
@@ -3279,6 +3279,65 @@ static bool interp__builtin_ia32_vpconflict(InterpState 
&S, CodePtr OpPC,
   return true;
 }
 
+static bool interp__builtin_ia32_shuffle_generic(
+    InterpState &S, CodePtr OpPC, const CallExpr *Call,
+    llvm::function_ref<std::pair<unsigned, unsigned>(unsigned, unsigned,
+                                                     unsigned)>
+        GetSourceIndex,
+    bool IsSingleSrc) {
+
+  assert(Call->getNumArgs() == (IsSingleSrc ? 2 : 3));
+  QualType MaskType = Call->getArg(IsSingleSrc ? 1 : 2)->getType();
+  bool IsMaskVector = MaskType->isVectorType();
+
+  unsigned ShuffleMask = 0;
+  Pointer MaskPtr;
+  if (IsMaskVector) {
+    MaskPtr = S.Stk.pop<Pointer>();
+  } else {
+    ShuffleMask =
+        popToAPSInt(S, Call->getArg(IsSingleSrc ? 1 : 2)).getZExtValue();
+  }
+
+  QualType Arg0Type = Call->getArg(0)->getType();
+  const auto *VecT = Arg0Type->castAs<VectorType>();
+  PrimType ElemT = *S.getContext().classify(VecT->getElementType());
+  unsigned NumElems = VecT->getNumElements();
+  unsigned ElemWidth = S.getContext().getBitWidth(VecT->getElementType());
+
+  Pointer Aptr;
+  Pointer Bptr;
+  if (IsSingleSrc) {
+    Aptr = S.Stk.pop<Pointer>();
+    Bptr = Aptr;
+  } else {
+    Bptr = S.Stk.pop<Pointer>();
+    Aptr = S.Stk.pop<Pointer>();
+  }
+
+  const Pointer &A = Aptr;
+  const Pointer &B = Bptr;
+  const Pointer &Dst = S.Stk.peek<Pointer>();
+
+  for (unsigned DstIdx = 0; DstIdx != NumElems; ++DstIdx) {
+    if (IsMaskVector) {
----------------
RKSimon wrote:

drop this mask handling until its actually used in a future PR - simple first 
implementation that we can build on when we need to

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

Reply via email to