-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir][EmitC] Add builders for call_opaque op #80879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-emitc Author: Simon Camphausen (simon-camp) ChangesAdd builders for the call_opaque op that has default valued attributes at the end. These can then be omitted during op creation. Full diff: https://github.com/llvm/llvm-project/pull/80879.diff 1 Files Affected:
diff --git a/mlir/include/mlir/Dialect/EmitC/IR/EmitC.td b/mlir/include/mlir/Dialect/EmitC/IR/EmitC.td
index 39cc360cef41d4..b264a582df5aad 100644
--- a/mlir/include/mlir/Dialect/EmitC/IR/EmitC.td
+++ b/mlir/include/mlir/Dialect/EmitC/IR/EmitC.td
@@ -122,6 +122,27 @@ def EmitC_CallOpaqueOp : EmitC_Op<"call_opaque", []> {
Variadic<AnyType>:$operands
);
let results = (outs Variadic<AnyType>);
+ let builders = [
+ OpBuilder<(ins
+ "::mlir::TypeRange":$resultTypes,
+ "::llvm::StringRef":$callee,
+ "::mlir::ValueRange":$operands,
+ CArg<"::mlir::ArrayAttr", "{}">:$args,
+ CArg<"::mlir::ArrayAttr", "{}">:$template_args), [{
+ build($_builder, $_state, resultTypes, callee, args, template_args, operands);
+ }]
+ >,
+ OpBuilder<(ins
+ "::mlir::TypeRange":$resultTypes,
+ "::mlir::StringAttr":$callee,
+ "::mlir::ValueRange":$operands,
+ CArg<"::mlir::ArrayAttr", "{}">:$args,
+ CArg<"::mlir::ArrayAttr", "{}">:$template_args), [{
+ build($_builder, $_state, resultTypes, callee, args, template_args, operands);
+ }]
+ >
+ ];
+
let assemblyFormat = [{
$callee `(` $operands `)` attr-dict `:` functional-type($operands, results)
}];
|
49918bc
to
c9c1b01
Compare
This allows to omit the default valued attributes and therefore write more compact code.
c9c1b01
to
e9b4f9a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, I was about to suggest reordering optional op arguments (to move them to the end), but this is even better!
That's what I did first and then I realized it would break all downstream users 😄 |
This allows to omit the default valued attributes and therefore write more compact code.
…17600) llvm/llvm-project#80879 introduced custom build methods for the `emitc.call_opaque` op for common cases. Signed-off-by: Simon Camphausen <[email protected]>
This allows to omit the default valued attributes and therefore write more compact code.