Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "mlir/Support/ThreadLocalCache.h"
#include "llvm/ADT/PointerEmbeddedInt.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
Expand Down Expand Up @@ -87,6 +88,13 @@ class GEPArg : public PointerUnion<Value, GEPConstantIndex> {
} // namespace LLVM
} // namespace mlir

namespace mlir {
namespace LLVM {
struct AssumeAlignTag {};
struct AssumeSeparateStorageTag {};
} // namespace LLVM
} // namespace mlir

///// Ops /////
#define GET_OP_CLASSES
#include "mlir/Dialect/LLVMIR/LLVMOps.h.inc"
Expand Down
9 changes: 8 additions & 1 deletion mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,14 @@ def LLVM_AssumeOp
}];

let builders = [
OpBuilder<(ins "Value":$cond)>
OpBuilder<(ins "Value":$cond)>,
OpBuilder<(ins "Value":$cond,
"ArrayRef<llvm::OperandBundleDefT<Value>>":$opBundles)>,
OpBuilder<(ins "Value":$cond, "llvm::StringRef":$tag, "ValueRange":$args)>,
OpBuilder<(ins "Value":$cond, "AssumeAlignTag":$tag, "Value":$ptr,
"Value":$align)>,
OpBuilder<(ins "Value":$cond, "AssumeSeparateStorageTag":$tag,
"Value":$ptr1, "Value":$ptr2)>
];

let hasVerifier = 1;
Expand Down
39 changes: 38 additions & 1 deletion mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3438,7 +3438,44 @@ 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,
Value cond,
ArrayRef<llvm::OperandBundleDefT<Value>> opBundles) {
SmallVector<ValueRange> opBundleOperands;
SmallVector<Attribute> opBundleTags;
opBundleOperands.reserve(opBundles.size());
opBundleTags.reserve(opBundles.size());

for (const llvm::OperandBundleDefT<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,
Value cond, llvm::StringRef tag, ValueRange args) {
llvm::OperandBundleDefT<Value> opBundle(
tag.str(), SmallVector<Value>(args.begin(), args.end()));
return build(builder, state, cond, opBundle);
}

void LLVM::AssumeOp::build(OpBuilder &builder, OperationState &state,
Value cond, AssumeAlignTag, Value ptr, Value align) {
return build(builder, state, cond, "align", ValueRange{ptr, align});
}

void LLVM::AssumeOp::build(OpBuilder &builder, OperationState &state,
Value cond, AssumeSeparateStorageTag, Value ptr1,
Value ptr2) {
return build(builder, state, cond, "separate_storage",
ValueRange{ptr1, ptr2});
}

LogicalResult LLVM::AssumeOp::verify() { return verifyOperandBundles(*this); }
Expand Down
Loading