[Mlir-commits] [mlir] [mlir][LLVMIR] Add operand bundle support for llvm.intr.assume (PR #112143)
Tobias Gysi
llvmlistbot at llvm.org
Tue Oct 15 06:27:39 PDT 2024
================
@@ -854,8 +855,40 @@ llvm::CallInst *mlir::LLVM::detail::createIntrinsicCall(
"LLVM `immArgPositions` and MLIR `immArgAttrNames` should have equal "
"length");
+ SmallVector<llvm::OperandBundleDef> opBundles;
+ std::size_t numOpBundleOperands = 0;
+ auto opBundleSizesAttr = cast_if_present<DenseI32ArrayAttr>(
+ intrOp->getAttr(LLVMDialect::getOpBundleSizesAttrName()));
+ auto opBundleTagsAttr = cast_if_present<ArrayAttr>(
+ intrOp->getAttr(LLVMDialect::getOpBundleTagsAttrName()));
+
+ if (opBundleSizesAttr && opBundleTagsAttr) {
+ ArrayRef<int> opBundleSizes = opBundleSizesAttr.asArrayRef();
+ assert(opBundleSizes.size() == opBundleTagsAttr.size() &&
+ "operand bundles and tags do not match");
+
+ numOpBundleOperands =
+ std::reduce(opBundleSizes.begin(), opBundleSizes.end());
+ assert(numOpBundleOperands <= intrOp->getNumOperands() &&
+ "operand bundle operands is more than the number of operands");
+
+ ValueRange operands = intrOp->getOperands().take_back(numOpBundleOperands);
+ size_t nextOperandIdx = 0;
+ opBundles.reserve(opBundleSizesAttr.size());
+
+ for (auto [opBundleTagAttr, bundleSize] :
+ llvm::zip(opBundleTagsAttr, opBundleSizes)) {
+ auto bundleTag = llvm::cast<StringAttr>(opBundleTagAttr).str();
+ auto bundleOperands = moduleTranslation.lookupValues(
+ operands.slice(nextOperandIdx, bundleSize));
+ opBundles.emplace_back(std::move(bundleTag), std::move(bundleOperands));
----------------
gysit wrote:
Ah missed that one all fine then!
https://github.com/llvm/llvm-project/pull/112143
More information about the Mlir-commits
mailing list