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
5 changes: 3 additions & 2 deletions mlir/test/mlir-tblgen/op-decl-and-defs.td
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ def NS_AOp : NS_Op<"a_op", [IsolatedFromAbove, IsolatedFromAbove]> {
// CHECK: template <typename RangeT>
// CHECK: class AOpGenericAdaptor : public detail::AOpGenericAdaptorBase {
// CHECK: public:
// CHECK: AOpGenericAdaptor(RangeT values,
// CHECK-SAME: odsOperands(values)
// CHECK: AOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs = {}, const ::mlir::EmptyProperties &properties = {}, ::mlir::RegionRange regions = {}) : Base(attrs, properties, regions), odsOperands(values) {}
// CHECK: AOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions = {}) : AOpGenericAdaptor(values, attrs, (properties ? *properties.as<::mlir::EmptyProperties *>() : ::mlir::EmptyProperties{}), regions) {}
// CHECK: AOpGenericAdaptor(RangeT values, const AOpGenericAdaptorBase &base) : Base(base), odsOperands(values) {}
// CHECK: RangeT getODSOperands(unsigned index) {
// CHECK: ValueT getA() {
// CHECK: RangeT getB() {
Expand Down
13 changes: 13 additions & 0 deletions mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4282,6 +4282,19 @@ OpOperandAdaptorEmitter::OpOperandAdaptorEmitter(
}
}

// Create a constructor that creates a new generic adaptor by copying
// everything from another adaptor, except for the values.
{
SmallVector<MethodParameter> paramList;
paramList.emplace_back("RangeT", "values");
paramList.emplace_back("const " + op.getGenericAdaptorName() + "Base &",
"base");
auto *constructor =
genericAdaptor.addConstructor<Method::Inline>(paramList);
constructor->addMemberInitializer("Base", "base");
constructor->addMemberInitializer("odsOperands", "values");
}

// Create constructors constructing the adaptor from an instance of the op.
// This takes the attributes, properties and regions from the op instance
// and the value range from the parameter.
Expand Down
Loading