================
@@ -1319,7 +1351,21 @@ emitNeonCallToOp(CIRGenModule &cgm, CIRGenBuilderTy 
&builder,
       assert(!cir::MissingFeatures::emitConstrainedFPCall());
     }
     if (shift > 0 && shift == j) {
-      cgm.errorNYI(loc, std::string("intrinsic requiring a shift Op"));
+      int sv = cast<cir::IntAttr>(
+                   cast<cir::ConstantOp>(args[j].getDefiningOp()).getValue())
+                   .getSInt();
+      // Create a scalar constant of the element type (with matching bitwidth).
+      // Then splat to a vector if needed.
+      auto vecTy = mlir::dyn_cast<cir::VectorType>(argTypes[j]);
+      mlir::Type eltTy = vecTy ? vecTy.getElementType() : argTypes[j];
+      unsigned width = mlir::cast<cir::IntType>(eltTy).getWidth();
+      llvm::APSInt shiftVal(width, /*isUnsigned=*/false);
+      shiftVal = rightshift ? -sv : sv;
+      mlir::Value scalarConst = cir::ConstantOp::create(
+          builder, loc, eltTy, cir::IntAttr::get(eltTy, shiftVal));
+      args[j] = vecTy
+                    ? cir::VecSplatOp::create(builder, loc, vecTy, scalarConst)
+                    : scalarConst;
----------------
banach-space wrote:

Note, we are still "upstreaming" code from the incubator. With that in mind, 
why diverge so much from the existing implementation? See: 
https://github.com/llvm/clangir/blob/main/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp#L2283

Also, please note that @alowqie is adding `emitNeonShiftVector` in 
https://github.com/llvm/llvm-project/pull/186693/. Depending on which patch 
lands first, the other person will have to rebase.

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

Reply via email to