[Mlir-commits] [mlir] [mlir][LLVM] Add builders for llvm.intr.assume (PR #113317)
Tobias Gysi
llvmlistbot at llvm.org
Thu Oct 24 09:07:30 PDT 2024
================
@@ -3438,7 +3438,46 @@ void InlineAsmOp::getEffects(
void LLVM::AssumeOp::build(OpBuilder &builder, OperationState &state,
mlir::Value cond) {
return build(builder, state, cond, /*op_bundle_operands=*/{},
- /*op_bundle_tags=*/{});
+ /*op_bundle_tags=*/ArrayAttr{});
+}
+
+void LLVM::AssumeOp::build(
+ OpBuilder &builder, OperationState &state, mlir::Value cond,
+ ArrayRef<llvm::OperandBundleDefT<mlir::Value>> opBundles) {
+ SmallVector<mlir::ValueRange> opBundleOperands;
+ SmallVector<mlir::Attribute> opBundleTags;
+ opBundleOperands.reserve(opBundles.size());
+ opBundleTags.reserve(opBundles.size());
+
+ for (const llvm::OperandBundleDefT<mlir::Value> &bundle : opBundles) {
+ opBundleOperands.emplace_back(bundle.inputs());
+ opBundleTags.push_back(
+ StringAttr::get(builder.getContext(), bundle.getTag()));
+ }
+
+ auto opBundleTagsAttr = ArrayAttr::get(builder.getContext(), opBundleTags);
+ return build(builder, state, cond, opBundleOperands, opBundleTagsAttr);
+}
+
+void LLVM::AssumeOp::build(OpBuilder &builder, OperationState &state,
+ mlir::Value cond, llvm::StringRef tag,
+ mlir::ValueRange args) {
+ llvm::OperandBundleDefT<mlir::Value> opBundle(
+ tag.str(), std::vector<mlir::Value>(args.begin(), args.end()));
----------------
gysit wrote:
```suggestion
tag.str(), SmallVector<Value>(args.begin(), args.end()));
```
nit: There seems to be a constructor that takes an ArrayRef. Can you use SmallVector? It is preferred over std::vector.
https://github.com/llvm/llvm-project/pull/113317
More information about the Mlir-commits
mailing list