Skip to content
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

core: fix attributes to func outputs #3675

Merged
merged 1 commit into from
Dec 24, 2024
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
10 changes: 10 additions & 0 deletions tests/filecheck/dialects/func/func_ops.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,14 @@ builtin.module {
// CHECK-NEXT: %r1, %r2 = "test.op"() : () -> (f32, f32)
// CHECK-NEXT: func.return %r1, %r2 : f32, f32
// CHECK-NEXT: }

func.func @output_attribute_single() -> (f32 {dialect.a = 0 : i32}) {
%r1 = "test.op"() : () -> (f32)
return %r1: f32
}

// CHECK: func.func @output_attribute_single() -> (f32 {"dialect.a" = 0 : i32}) {
// CHECK-NEXT: %r1 = "test.op"() : () -> f32
// CHECK-NEXT: func.return %r1 : f32
// CHECK-NEXT: }
}
4 changes: 2 additions & 2 deletions xdsl/dialects/utils/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def print_func_op_like(
printer.print(") ")
if function_type.outputs:
printer.print("-> ")
if len(function_type.outputs) > 1:
if len(function_type.outputs) > 1 or res_attrs is not None:
printer.print("(")
if res_attrs is not None:
printer.print_list(
Expand All @@ -72,7 +72,7 @@ def print_func_op_like(
)
else:
printer.print_list(function_type.outputs, printer.print_attribute)
if len(function_type.outputs) > 1:
if len(function_type.outputs) > 1 or res_attrs is not None:
printer.print(")")
printer.print(" ")
else:
Expand Down
Loading