@@ -315,8 +315,10 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
315315 return getConstantInt (loc, getUInt32Ty (), c);
316316 }
317317 cir::ConstantOp getSInt64 (uint64_t c, mlir::Location loc) {
318- cir::IntType sInt64Ty = getSInt64Ty ();
319- return cir::ConstantOp::create (*this , loc, cir::IntAttr::get (sInt64Ty , c));
318+ return getConstantInt (loc, getSInt64Ty (), c);
319+ }
320+ cir::ConstantOp getUInt64 (uint64_t c, mlir::Location loc) {
321+ return getConstantInt (loc, getUInt64Ty (), c);
320322 }
321323
322324 mlir::Value createNeg (mlir::Value value) {
@@ -572,6 +574,35 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
572574 info.isSigned , isLvalueVolatile,
573575 addr.getAlignment ().getAsAlign ().value ());
574576 }
577+
578+ cir::VecShuffleOp
579+ createVecShuffle (mlir::Location loc, mlir::Value vec1, mlir::Value vec2,
580+ llvm::ArrayRef<mlir::Attribute> maskAttrs) {
581+ auto vecType = mlir::cast<cir::VectorType>(vec1.getType ());
582+ auto resultTy = cir::VectorType::get (getContext (), vecType.getElementType (),
583+ maskAttrs.size ());
584+ return cir::VecShuffleOp::create (*this , loc, resultTy, vec1, vec2,
585+ getArrayAttr (maskAttrs));
586+ }
587+
588+ cir::VecShuffleOp createVecShuffle (mlir::Location loc, mlir::Value vec1,
589+ mlir::Value vec2,
590+ llvm::ArrayRef<int64_t > mask) {
591+ auto maskAttrs = llvm::to_vector_of<mlir::Attribute>(
592+ llvm::map_range (mask, [&](int32_t idx) {
593+ return cir::IntAttr::get (getSInt32Ty (), idx);
594+ }));
595+ return createVecShuffle (loc, vec1, vec2, maskAttrs);
596+ }
597+
598+ cir::VecShuffleOp createVecShuffle (mlir::Location loc, mlir::Value vec1,
599+ llvm::ArrayRef<int64_t > mask) {
600+ // / Create a unary shuffle. The second vector operand of the IR instruction
601+ // / is poison.
602+ cir::ConstantOp poison =
603+ getConstant (loc, cir::PoisonAttr::get (vec1.getType ()));
604+ return createVecShuffle (loc, vec1, poison, mask);
605+ }
575606};
576607
577608} // namespace clang::CIRGen
0 commit comments