summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Zinenko <zinenko@google.com>2019-11-21 04:24:52 -0800
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-11-21 05:08:19 -0800
commitb5af3784a6b9c67f67a11a9308b043b877f01095 (patch)
tree09853ee00d2d39a00648761c3ccafb4673043388
parent8bde4aa1bcc7745e1d4274046193358fe3181f16 (diff)
downloadbcm5719-llvm-b5af3784a6b9c67f67a11a9308b043b877f01095.tar.gz
bcm5719-llvm-b5af3784a6b9c67f67a11a9308b043b877f01095.zip
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
-rw-r--r--mlir/lib/IR/FunctionSupport.cpp6
-rw-r--r--mlir/test/Dialect/GPU/outlining.mlir2
-rw-r--r--mlir/test/Dialect/LLVMIR/func.mlir8
-rw-r--r--mlir/test/IR/parser.mlir4
-rw-r--r--mlir/test/IR/test-symbol-rauw.mlir2
5 files changed, 9 insertions, 13 deletions
diff --git a/mlir/lib/IR/FunctionSupport.cpp b/mlir/lib/IR/FunctionSupport.cpp
index 6b27eb833bf..1f39575331c 100644
--- a/mlir/lib/IR/FunctionSupport.cpp
+++ b/mlir/lib/IR/FunctionSupport.cpp
@@ -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);
diff --git a/mlir/test/Dialect/GPU/outlining.mlir b/mlir/test/Dialect/GPU/outlining.mlir
index 0a4a3d9b012..62c87df3e77 100644
--- a/mlir/test/Dialect/GPU/outlining.mlir
+++ b/mlir/test/Dialect/GPU/outlining.mlir
@@ -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
diff --git a/mlir/test/Dialect/LLVMIR/func.mlir b/mlir/test/Dialect/LLVMIR/func.mlir
index 348ad7ae1b5..6955cd0397a 100644
--- a/mlir/test/Dialect/LLVMIR/func.mlir
+++ b/mlir/test/Dialect/LLVMIR/func.mlir
@@ -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
diff --git a/mlir/test/IR/parser.mlir b/mlir/test/IR/parser.mlir
index a6460b46dd9..41e6d5cefcb 100644
--- a/mlir/test/IR/parser.mlir
+++ b/mlir/test/IR/parser.mlir
@@ -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
diff --git a/mlir/test/IR/test-symbol-rauw.mlir b/mlir/test/IR/test-symbol-rauw.mlir
index f0f1cbaad32..963875e762e 100644
--- a/mlir/test/IR/test-symbol-rauw.mlir
+++ b/mlir/test/IR/test-symbol-rauw.mlir
@@ -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,
OpenPOWER on IntegriCloud