forked from OSchip/llvm-project
Don't force newline before function attributes
Due to legacy reasons, a newline character followed by two spaces was always inserted before the attributes of the function Op in pretty form. This breaks formatting when functions are nested in some other operations. Don't print the newline and just put the attributes on the same line, which is also more consistent with module Op. Line breaking aware of indentation can be introduced separately into the parser if deemed useful. PiperOrigin-RevId: 281721793
This commit is contained in:
parent
8bde4aa1bc
commit
b5af3784a6
|
@ -299,11 +299,7 @@ void mlir::impl::printFunctionLikeOp(OpAsmPrinter &p, Operation *op,
|
|||
resultAttrStorage.emplace_back(attrNameBuf);
|
||||
ignoredAttrs.append(resultAttrStorage.begin(), resultAttrStorage.end());
|
||||
|
||||
auto attrs = op->getAttrs();
|
||||
if (attrs.size() > ignoredAttrs.size()) {
|
||||
p << "\n attributes ";
|
||||
p.printOptionalAttrDict(attrs, ignoredAttrs);
|
||||
}
|
||||
p.printOptionalAttrDictWithKeyword(op->getAttrs(), ignoredAttrs);
|
||||
|
||||
// Print the body if this is not an external function.
|
||||
Region &body = op->getRegion(0);
|
||||
|
|
|
@ -40,7 +40,7 @@ func @launch() {
|
|||
// CHECK-LABEL: module @launch_kernel
|
||||
// CHECK-NEXT: func @launch_kernel
|
||||
// CHECK-SAME: (%[[KERNEL_ARG0:.*]]: f32, %[[KERNEL_ARG1:.*]]: memref<?xf32, 1>)
|
||||
// CHECK-NEXT: attributes {gpu.kernel}
|
||||
// CHECK: attributes {gpu.kernel}
|
||||
// CHECK-NEXT: %[[BID:.*]] = "gpu.block_id"() {dimension = "x"} : () -> index
|
||||
// CHECK-NEXT: = "gpu.block_id"() {dimension = "y"} : () -> index
|
||||
// CHECK-NEXT: = "gpu.block_id"() {dimension = "z"} : () -> index
|
||||
|
|
|
@ -32,7 +32,7 @@ module {
|
|||
}) {sym_name = "baz", type = !llvm<"i64 (i64)">} : () -> ()
|
||||
|
||||
// CHECK: llvm.func @qux(!llvm<"i64*"> {llvm.noalias = true}, !llvm.i64)
|
||||
// CHECK-NEXT: attributes {xxx = {yyy = 42 : i64}}
|
||||
// CHECK: attributes {xxx = {yyy = 42 : i64}}
|
||||
"llvm.func"() ({
|
||||
}) {sym_name = "qux", type = !llvm<"void (i64*, i64)">,
|
||||
arg0 = {llvm.noalias = true}, xxx = {yyy = 42}} : () -> ()
|
||||
|
@ -52,11 +52,11 @@ module {
|
|||
}
|
||||
|
||||
// CHECK: llvm.func @roundtrip5()
|
||||
// CHECK-NEXT: attributes {baz = 42 : i64, foo = "bar"}
|
||||
// CHECK: attributes {baz = 42 : i64, foo = "bar"}
|
||||
llvm.func @roundtrip5() attributes {foo = "bar", baz = 42}
|
||||
|
||||
// CHECK: llvm.func @roundtrip6()
|
||||
// CHECK-NEXT: attributes {baz = 42 : i64, foo = "bar"}
|
||||
// CHECK: attributes {baz = 42 : i64, foo = "bar"}
|
||||
llvm.func @roundtrip6() attributes {foo = "bar", baz = 42} {
|
||||
llvm.return
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ module {
|
|||
}
|
||||
|
||||
// CHECK: llvm.func @roundtrip12(%{{.*}}: !llvm<"i32*"> {llvm.noalias = true})
|
||||
// CHECK-NEXT: attributes {foo = 42 : i32}
|
||||
// CHECK: attributes {foo = 42 : i32}
|
||||
llvm.func @roundtrip12(%arg0: !llvm<"i32*"> {llvm.noalias = true})
|
||||
attributes {foo = 42 : i32} {
|
||||
llvm.return
|
||||
|
|
|
@ -834,7 +834,7 @@ func @unregistered_term(%arg0 : i1) -> i1 {
|
|||
|
||||
// CHECK-LABEL: func @dialect_attrs
|
||||
func @dialect_attrs()
|
||||
// CHECK-NEXT: attributes {dialect.attr = 10
|
||||
// CHECK: attributes {dialect.attr = 10
|
||||
attributes {dialect.attr = 10} {
|
||||
return
|
||||
}
|
||||
|
@ -1114,7 +1114,7 @@ func @"\"_string_symbol_reference\""() {
|
|||
}
|
||||
|
||||
// CHECK-LABEL: func @nested_reference
|
||||
// CHECK-NEXT: ref = @some_symbol::@some_nested_symbol
|
||||
// CHECK: ref = @some_symbol::@some_nested_symbol
|
||||
func @nested_reference() attributes {test.ref = @some_symbol::@some_nested_symbol }
|
||||
|
||||
// CHECK-LABEL: func @custom_asm_names
|
||||
|
|
|
@ -9,7 +9,7 @@ module attributes {sym.outside_use = @symbol_foo } {
|
|||
func @symbol_foo() attributes {sym.new_name = "replaced_foo" }
|
||||
|
||||
// CHECK: func @symbol_bar
|
||||
// CHECK-NEXT: @replaced_foo
|
||||
// CHECK: @replaced_foo
|
||||
func @symbol_bar() attributes {sym.use = @symbol_foo} {
|
||||
// CHECK: foo.op
|
||||
// CHECK-SAME: non_symbol_attr,
|
||||
|
|
Loading…
Reference in New Issue