Skip to content

Commit ade6b77

Browse files
committed
Add test
1 parent b118bd3 commit ade6b77

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

mlir/test/mlir-tblgen/op-decl-and-defs.td

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,33 @@ def _BOp : NS_Op<"_op_with_leading_underscore_and_no_namespace", []>;
544544
// REDUCE_EXC-NOT: NS::AOp declarations
545545
// REDUCE_EXC-LABEL: NS::BOp declarations
546546

547+
def _RedundantBuilderOp : NS_Op<"redundant_builder_op", []> {
548+
let arguments = (ins
549+
SymbolNameAttr:$sym_name,
550+
TypeAttrOf<FunctionType>:$function_type,
551+
OptionalAttr<DictArrayAttr>:$arg_attrs,
552+
OptionalAttr<DictArrayAttr>:$res_attrs
553+
);
554+
let regions = (region AnyRegion:$body);
555+
556+
let builders = [
557+
OpBuilder<(ins
558+
"StringRef":$name, "FunctionType":$type,
559+
CArg<"ArrayRef<DictionaryAttr>", "{}">:$argAttrs,
560+
CArg<"ArrayRef<DictionaryAttr>", "{}">:$resultAttrs)
561+
>,
562+
OpBuilder<(ins
563+
"StringRef":$name, "FunctionType":$type)
564+
>];
565+
566+
let skipDefaultBuilders = 1;
567+
}
568+
// CHECK-LABEL: NS::_RedundantBuilderOp declarations
569+
// CHECK: class _RedundantBuilderOp
570+
// CHECK: static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, StringRef name, FunctionType type, ArrayRef<DictionaryAttr> argAttrs = {}, ArrayRef<DictionaryAttr> resultAttrs = {});
571+
// CHECK: static _RedundantBuilderOp create(::mlir::OpBuilder &builder, ::mlir::Location location, StringRef name, FunctionType type, ArrayRef<DictionaryAttr> argAttrs = {}, ArrayRef<DictionaryAttr> resultAttrs = {});
572+
// CHECK: static _RedundantBuilderOp create(::mlir::ImplicitLocOpBuilder &builder, StringRef name, FunctionType type, ArrayRef<DictionaryAttr> argAttrs = {}, ArrayRef<DictionaryAttr> resultAttrs = {});
573+
547574
// CHECK-LABEL: _TypeInferredPropOp declarations
548575
def _TypeInferredPropOp : NS_Op<"type_inferred_prop_op_with_properties", [
549576
AllTypesMatch<["value", "result"]>

mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3120,7 +3120,8 @@ void OpEmitter::genBuilder() {
31203120
auto properties = body ? Method::Static : Method::StaticDeclaration;
31213121
auto *method = opClass.addMethod("void", "build", properties, arguments);
31223122

3123-
ERROR_IF_PRUNED(method, "build", op);
3123+
if (body)
3124+
ERROR_IF_PRUNED(method, "build", op);
31243125

31253126
if (method)
31263127
method->setDeprecated(builder.getDeprecatedMessage());

0 commit comments

Comments
 (0)