From 37579ae8c4879e2de3498a38cf94490e595dba52 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 29 Dec 2018 11:32:37 -0800 Subject: [PATCH] Introduce ^ as a basic block sigil, eliminating an ambiguity on the MLIR syntax. PiperOrigin-RevId: 227234174 --- mlir/g3doc/LangRef.md | 34 +-- mlir/g3doc/MLIRForGraphAlgorithms.md | 2 +- mlir/g3doc/Rationale.md | 32 +- mlir/lib/IR/AsmPrinter.cpp | 4 +- mlir/lib/Parser/Lexer.cpp | 10 +- mlir/lib/Parser/Parser.cpp | 6 +- mlir/lib/Parser/TokenKinds.def | 1 + mlir/test/IR/core-ops.mlir | 10 +- mlir/test/IR/invalid-ops.mlir | 98 +++---- mlir/test/IR/invalid.mlir | 114 ++++---- mlir/test/IR/memory-ops.mlir | 6 +- mlir/test/IR/op-stats.mlir | 2 +- mlir/test/IR/parser.mlir | 90 +++--- mlir/test/IR/repro_b120295301.mlir | 2 +- mlir/test/Target/llvmir.mlir | 284 +++++++++--------- mlir/test/Transforms/canonicalize.mlir | 4 +- mlir/test/Transforms/constant-fold.mlir | 12 +- mlir/test/Transforms/convert2cfg.mlir | 292 +++++++++---------- mlir/test/Transforms/cse.mlir | 34 +-- mlir/test/Transforms/lower-affine-apply.mlir | 10 +- 20 files changed, 528 insertions(+), 519 deletions(-) diff --git a/mlir/g3doc/LangRef.md b/mlir/g3doc/LangRef.md index e9087dc54159..5bd3bca08ba5 100644 --- a/mlir/g3doc/LangRef.md +++ b/mlir/g3doc/LangRef.md @@ -65,8 +65,8 @@ Here's an example of an MLIR module: // result using a TensorFlow op. The dimensions of A and B are partially // known. The shapes are assumed to match. cfgfunc @mul(tensor<100x?xf32>, tensor) -> (tensor<100x50xf32>) { -// Block bb0. %A and %B come from function arguments. -bb0(%A: tensor<100x?xf32>, %B: tensor): +// Block ^bb0. %A and %B come from function arguments. +^bb0(%A: tensor<100x?xf32>, %B: tensor): // Compute the inner dimension of %A using the dim operation. %n = dim %A, 1 : tensor<100x?xf32> @@ -923,7 +923,7 @@ A simple CFG function that returns its argument twice looks like this: ```mlir {.mlir} cfgfunc @count(i64) -> (i64, i64) attributes {fruit: "banana"} { -bb0(%x: i64): +^bb0(%x: i64): return %x, %x: i64, i64 } ``` @@ -941,7 +941,7 @@ Syntax: ``` {.ebnf} block ::= bb-label operation* terminator-inst bb-label ::= bb-id bb-arg-list? `:` -bb-id ::= bare-id +bb-id ::= caret-id ssa-id-and-type ::= ssa-id `:` type // Non-empty list of names and types. @@ -965,22 +965,22 @@ arguments: ```mlir {.mlir} cfgfunc @simple(i64, i1) -> i64 { -bb0(%a: i64, %cond: i1): // Code dominated by bb0 may refer to %a - br_cond %cond, bb1, bb2 +^bb0(%a: i64, %cond: i1): // Code dominated by ^bb0 may refer to %a + br_cond %cond, ^bb1, ^bb2 -bb1: - br bb3(%a: i64) // Branch passes %a as the argument +^bb1: + br ^bb3(%a: i64) // Branch passes %a as the argument -bb2: +^bb2: %b = "add"(%a, %a) : (i64, i64) -> i64 - br bb3(%b: i64) // Branch passes %b as the argument + br ^bb3(%b: i64) // Branch passes %b as the argument -// bb3 receives an argument, named %c, from predecessors +// ^bb3 receives an argument, named %c, from predecessors // and passes it on to bb4 twice. -bb3(%c: i64): - br bb4(%c, %c : i64, i64) +^bb3(%c: i64): + br ^bb4(%c, %c : i64, i64) -bb4(%d : i64, %e : i64): +^bb4(%d : i64, %e : i64): %0 = addi %d, %e : i64 return %0 : i64 } @@ -1043,11 +1043,11 @@ instruction that targets the same block: ```mlir {.mlir} cfgfunc @select(%a : i32, %b :i32, %flag : i1) -> i32 { -bb0: +^bb0: // Both targets are the same, operands differ - cond_br %flag, bb1 (%a : i32), bb1 (%b : i32) + cond_br %flag, ^bb1(%a : i32), ^bb1(%b : i32) -bb1 (%x : i32) : +^bb1(%x : i32) : return %x : i32 } ``` diff --git a/mlir/g3doc/MLIRForGraphAlgorithms.md b/mlir/g3doc/MLIRForGraphAlgorithms.md index 6e0b0ae38e83..8540b65935c7 100644 --- a/mlir/g3doc/MLIRForGraphAlgorithms.md +++ b/mlir/g3doc/MLIRForGraphAlgorithms.md @@ -156,7 +156,7 @@ turned into zero: ```mlir // RUN: mlir-opt %s -canonicalize | FileCheck %s cfgfunc @test_subi_zero_cfg(i32) -> i32 { - bb0(%arg0: i32): + ^bb0(%arg0: i32): %y = subi %arg0, %arg0 : i32 return %y: i32 } diff --git a/mlir/g3doc/Rationale.md b/mlir/g3doc/Rationale.md index 883951637ef1..e8083ae1a8a5 100644 --- a/mlir/g3doc/Rationale.md +++ b/mlir/g3doc/Rationale.md @@ -360,9 +360,9 @@ This operation could have been implemented with additional control flow: `%r = select %cond, %t, %f` is equivalent to ```mlir -bb0: - br_cond %cond, bb1(%t), bb1(%f) -bb1(%r): +^bb0: + br_cond %cond, ^bb1(%t), ^bb1(%f) +^bb1(%r): ``` However, this control flow granularity is not available in the ML functions @@ -430,28 +430,28 @@ mlfunc @search(memref %S, i32 %key) { } cfgfunc @search_body(memref, memref, i32) { -bb0(%A: memref, %S: memref, %key: i32) +^bb0(%A: memref, %S: memref, %key: i32) %nj = dim %A, 1 : memref - br bb1(0) + br ^bb1(0) -bb1(%j: i32) +^bb1(%j: i32) %p1 = cmpi "lt", %j, %nj : i32 - br_cond %p1, bb2, bb5 + br_cond %p1, ^bb2, ^bb5 -bb2: +^bb2: %v = load %A[%i, %j] : memref %p2 = cmpi "eq", %v, %key : i32 - br_cond %p2, bb3(%j), bb4 + br_cond %p2, ^bb3(%j), ^bb4 -bb3(%j: i32) - store %j to %S [%i] : memref - br bb5 +^bb3(%j: i32) + store %j to %S[%i] : memref + br ^bb5 -bb4: +^bb4: %jinc = addi %j, 1 : i32 - br bb1(%jinc) + br ^bb1(%jinc) -bb5: +^bb5: return } ``` @@ -488,7 +488,7 @@ mlfunc @outer_nest(%n) : (i32) { } cfgfunc @inner_nest(i32, i32, i32) { -bb0(%i, %j, %n): +^bb0(%i, %j, %n): %pow = call @pow(2, %j) : (f32, f32) -> f32 // TODO(missing cast from f32 to i32) call @inner_nest2(%pow, %n) diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index 23bac0c76204..9b97d1074f54 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -944,7 +944,7 @@ public: enum { nameSentinel = ~0U }; - void printBlockName(const Block *block) { os << "bb" << getBlockID(block); } + void printBlockName(const Block *block) { os << "^bb" << getBlockID(block); } unsigned getBlockID(const Block *block) { auto it = blockIDs.find(block); @@ -1213,7 +1213,7 @@ void FunctionPrinter::print(const Block *block) { os << "\t// " << predIDs.size() << " preds: "; - interleaveComma(predIDs, [&](unsigned predID) { os << "bb" << predID; }); + interleaveComma(predIDs, [&](unsigned predID) { os << "^bb" << predID; }); } os << '\n'; } diff --git a/mlir/lib/Parser/Lexer.cpp b/mlir/lib/Parser/Lexer.cpp index aa225c478226..e1f009d41e0d 100644 --- a/mlir/lib/Parser/Lexer.cpp +++ b/mlir/lib/Parser/Lexer.cpp @@ -24,6 +24,7 @@ #include "mlir/IR/MLIRContext.h" #include "llvm/Support/SourceMgr.h" using namespace mlir; + using llvm::SMLoc; using llvm::SourceMgr; @@ -124,6 +125,8 @@ Token Lexer::lexToken() { case '@': return lexAtIdentifier(tokStart); + case '^': + LLVM_FALLTHROUGH; case '#': LLVM_FALLTHROUGH; case '%': @@ -215,7 +218,8 @@ Token Lexer::lexAtIdentifier(const char *tokStart) { /// /// affine-map-id ::= `#` suffix-id /// ssa-id ::= '%' suffix-id -/// suffix-id ::= digit+ | (letter|id-punct) (letter|id-punct|digit)* +/// block-id ::= '^' suffix-id +/// suffix-id ::= digit+ | (letter|id-punct) (letter|id-punct|digit)* /// Token Lexer::lexPrefixedIdentifier(const char *tokStart) { Token::Kind kind; @@ -229,6 +233,10 @@ Token Lexer::lexPrefixedIdentifier(const char *tokStart) { kind = Token::percent_identifier; errorKind = "invalid SSA name"; break; + case '^': + kind = Token::caret_identifier; + errorKind = "invalid block name"; + break; default: llvm_unreachable("invalid caller"); } diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp index 63a6572d5b43..c5dbc80f32e6 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -2036,13 +2036,13 @@ ParseResult FunctionParser::parseFunctionBody(bool hadNamedArguments) { /// /// block ::= block-label? instruction* terminator-inst /// block-label ::= block-id block-arg-list? `:` -/// block-id ::= bare-id +/// block-id ::= caret-id /// block-arg-list ::= `(` ssa-id-and-type-list? `)` /// ParseResult FunctionParser::parseBlock() { SMLoc nameLoc = getToken().getLoc(); auto name = getTokenSpelling(); - if (parseToken(Token::bare_identifier, "expected block name")) + if (parseToken(Token::caret_identifier, "expected block name")) return ParseFailure; auto *block = defineBlockNamed(name, nameLoc); @@ -2364,7 +2364,7 @@ Block *FunctionParser::defineBlockNamed(StringRef name, SMLoc loc) { bool FunctionParser::parseSuccessorAndUseList( Block *&dest, SmallVectorImpl &operands) { // Verify branch is identifier and get the matching block. - if (!getToken().is(Token::bare_identifier)) + if (!getToken().is(Token::caret_identifier)) return emitError("expected block name"); dest = getBlockNamed(getTokenSpelling(), getToken().getLoc()); consumeToken(); diff --git a/mlir/lib/Parser/TokenKinds.def b/mlir/lib/Parser/TokenKinds.def index 9df0967e9f0d..1ac5505f4e68 100644 --- a/mlir/lib/Parser/TokenKinds.def +++ b/mlir/lib/Parser/TokenKinds.def @@ -54,6 +54,7 @@ TOK_IDENTIFIER(bare_identifier) // foo TOK_IDENTIFIER(at_identifier) // @foo TOK_IDENTIFIER(hash_identifier) // #foo TOK_IDENTIFIER(percent_identifier) // %foo +TOK_IDENTIFIER(caret_identifier) // ^foo // Literals TOK_LITERAL(floatliteral) // 2.0 diff --git a/mlir/test/IR/core-ops.mlir b/mlir/test/IR/core-ops.mlir index ca1607f1d90f..1e992836ea95 100644 --- a/mlir/test/IR/core-ops.mlir +++ b/mlir/test/IR/core-ops.mlir @@ -15,7 +15,7 @@ // CHECK-LABEL: cfgfunc @cfgfunc_with_ops(f32) { cfgfunc @cfgfunc_with_ops(f32) { -bb0(%a : f32): +^bb0(%a : f32): // CHECK: %0 = "getTensor"() : () -> tensor<4x4x?xf32> %t = "getTensor"() : () -> tensor<4x4x?xf32> @@ -31,8 +31,8 @@ bb0(%a : f32): // CHECK-LABEL: cfgfunc @standard_instrs(tensor<4x4x?xf32>, f32, i32, index) { cfgfunc @standard_instrs(tensor<4x4x?xf32>, f32, i32, index) { -// CHECK: bb0(%arg0: tensor<4x4x?xf32>, %arg1: f32, %arg2: i32, %arg3: index): -bb42(%t: tensor<4x4x?xf32>, %f: f32, %i: i32, %idx : index): +// CHECK: ^bb0(%arg0: tensor<4x4x?xf32>, %arg1: f32, %arg2: i32, %arg3: index): +^bb42(%t: tensor<4x4x?xf32>, %f: f32, %i: i32, %idx : index): // CHECK: %0 = dim %arg0, 2 : tensor<4x4x?xf32> %a = "dim"(%t){index: 2} : (tensor<4x4x?xf32>) -> index @@ -147,7 +147,7 @@ bb42(%t: tensor<4x4x?xf32>, %f: f32, %i: i32, %idx : index): // CHECK-LABEL: cfgfunc @affine_apply() { cfgfunc @affine_apply() { -bb0: +^bb0: %i = "constant"() {value: 0: index} : () -> index %j = "constant"() {value: 1: index} : () -> index @@ -170,7 +170,7 @@ bb0: // CHECK-LABEL: cfgfunc @load_store cfgfunc @load_store(memref<4x4xi32>, index) { -bb0(%0: memref<4x4xi32>, %1: index): +^bb0(%0: memref<4x4xi32>, %1: index): // CHECK: %0 = load %arg0[%arg1, %arg1] : memref<4x4xi32> %2 = "load"(%0, %1, %1) : (memref<4x4xi32>, index, index)->i32 diff --git a/mlir/test/IR/invalid-ops.mlir b/mlir/test/IR/invalid-ops.mlir index a56637966f73..441a78be172d 100644 --- a/mlir/test/IR/invalid-ops.mlir +++ b/mlir/test/IR/invalid-ops.mlir @@ -1,7 +1,7 @@ // RUN: mlir-opt %s -split-input-file -verify cfgfunc @dim(tensor<1xf32>) { -bb(%0: tensor<1xf32>): +^bb(%0: tensor<1xf32>): "dim"(%0){index: "xyz"} : (tensor<1xf32>)->i32 // expected-error {{'dim' op requires an integer attribute named 'index'}} return } @@ -9,7 +9,7 @@ bb(%0: tensor<1xf32>): // ----- cfgfunc @dim2(tensor<1xf32>) { -bb(%0: tensor<1xf32>): +^bb(%0: tensor<1xf32>): "dim"(){index: "xyz"} : ()->i32 // expected-error {{'dim' op requires a single operand}} return } @@ -17,7 +17,7 @@ bb(%0: tensor<1xf32>): // ----- cfgfunc @dim3(tensor<1xf32>) { -bb(%0: tensor<1xf32>): +^bb(%0: tensor<1xf32>): "dim"(%0){index: 1} : (tensor<1xf32>)->i32 // expected-error {{'dim' op index is out of range}} return } @@ -25,7 +25,7 @@ bb(%0: tensor<1xf32>): // ----- cfgfunc @constant() { -bb: +^bb: %x = "constant"(){value: "xyz"} : () -> i32 // expected-error {{'constant' op requires 'value' to be an integer for an integer result type}} return } @@ -33,7 +33,7 @@ bb: // ----- cfgfunc @constant_out_of_range() { -bb: +^bb: %x = "constant"(){value: 100} : () -> i1 // expected-error {{'constant' op requires 'value' to be an integer within the range of the integer result type}} return } @@ -41,7 +41,7 @@ bb: // ----- cfgfunc @affine_apply_no_map() { -bb0: +^bb0: %i = "constant"() {value: 0} : () -> index %x = "affine_apply" (%i) { } : (index) -> (index) // expected-error {{'affine_apply' op requires an affine map}} return @@ -50,7 +50,7 @@ bb0: // ----- cfgfunc @affine_apply_wrong_operand_count() { -bb0: +^bb0: %i = "constant"() {value: 0} : () -> index %x = "affine_apply" (%i) {map: (d0, d1) -> ((d0 + 1), (d1 + 2))} : (index) -> (index) // expected-error {{'affine_apply' op operand count and affine map dimension and symbol count must match}} return @@ -59,7 +59,7 @@ bb0: // ----- cfgfunc @affine_apply_wrong_result_count() { -bb0: +^bb0: %i = "constant"() {value: 0} : () -> index %j = "constant"() {value: 1} : () -> index %x = "affine_apply" (%i, %j) {map: (d0, d1) -> ((d0 + 1), (d1 + 2))} : (index,index) -> (index) // expected-error {{'affine_apply' op result count and affine map result count must match}} @@ -69,7 +69,7 @@ bb0: // ----- cfgfunc @unknown_custom_op() { -bb0: +^bb0: %i = crazyThing() {value: 0} : () -> index // expected-error {{custom op 'crazyThing' is unknown}} return } @@ -77,7 +77,7 @@ bb0: // ----- cfgfunc @bad_alloc_wrong_dynamic_dim_count() { -bb0: +^bb0: %0 = "constant"() {value: 7} : () -> index // Test alloc with wrong number of dynamic dimensions. %1 = alloc(%0)[%1] : memref<2x4xf32, (d0, d1)[s0] -> ((d0 + s0), d1), 1> // expected-error {{custom op 'alloc' dimension operand count does not equal memref dynamic dimension count}} @@ -87,7 +87,7 @@ bb0: // ----- cfgfunc @bad_alloc_wrong_symbol_count() { -bb0: +^bb0: %0 = "constant"() {value: 7} : () -> index // Test alloc with wrong number of symbols %1 = alloc(%0) : memref<2x?xf32, (d0, d1)[s0] -> ((d0 + s0), d1), 1> // expected-error {{operand count does not equal dimension plus symbol operand count}} @@ -97,7 +97,7 @@ bb0: // ----- cfgfunc @test_store_zero_results() { -bb0: +^bb0: %0 = alloc() : memref<1024x64xf32, (d0, d1) -> (d0, d1), 1> %1 = "constant"() {value: 0} : () -> index %2 = "constant"() {value: 1} : () -> index @@ -117,7 +117,7 @@ mlfunc @test_store_zero_results2(%x: i32, %p: memref) { // ----- cfgfunc @test_alloc_memref_map_rank_mismatch() { -bb0: +^bb0: %0 = alloc() : memref<1024x64xf32, (d0) -> (d0), 1> // expected-error {{memref affine map dimension mismatch}} return } @@ -125,7 +125,7 @@ bb0: // ----- cfgfunc @intlimit2() { -bb: +^bb: %0 = "constant"() {value: 0} : () -> i4096 %1 = "constant"() {value: 1} : () -> i4097 // expected-error {{integer bitwidth is limited to 4096 bits}} return @@ -155,21 +155,21 @@ mlfunc @calls(%arg0 : i32) { // ----- cfgfunc @cfgfunc_with_ops(f32) { -bb0(%a : f32): +^bb0(%a : f32): %sf = addf %a, %a, %a : f32 // expected-error {{custom op 'addf' expected 2 operands}} } // ----- cfgfunc @cfgfunc_with_ops(f32) { -bb0(%a : f32): +^bb0(%a : f32): %sf = addf(%a, %a) : f32 // expected-error {{unexpected delimiter}} } // ----- cfgfunc @cfgfunc_with_ops(f32) { -bb0(%a : f32): +^bb0(%a : f32): %sf = addf{%a, %a} : f32 // expected-error {{invalid operand}} } @@ -177,14 +177,14 @@ bb0(%a : f32): // ----- cfgfunc @cfgfunc_with_ops(i32) { -bb0(%a : i32): +^bb0(%a : i32): %sf = addf %a, %a : i32 // expected-error {{'addf' op requires a floating point type}} } // ----- cfgfunc @cfgfunc_with_ops(i32) { -bb0(%a : i32): +^bb0(%a : i32): // expected-error@+1 {{'predicate' attribute value out of range}} %r = "cmpi"(%a, %b) {predicate: 42} : (i32, i32) -> i1 } @@ -193,7 +193,7 @@ bb0(%a : i32): // Comparison are defined for arguments of the same type. cfgfunc @cfgfunc_with_ops(i32, i64) { -bb0(%a : i32, %b : i64): // expected-error {{prior use here}} +^bb0(%a : i32, %b : i64): // expected-error {{prior use here}} %r = cmpi "eq", %a, %b : i32 // expected-error {{use of value '%b' expects different type than prior uses}} } @@ -201,7 +201,7 @@ bb0(%a : i32, %b : i64): // expected-error {{prior use here}} // Comparisons must have the "predicate" attribute. cfgfunc @cfgfunc_with_ops(i32, i32) { -bb0(%a : i32, %b : i32): +^bb0(%a : i32, %b : i32): %r = cmpi %a, %b : i32 // expected-error {{expected type}} } @@ -209,7 +209,7 @@ bb0(%a : i32, %b : i32): // Integer comparisons are not recognized for float types. cfgfunc @cfgfunc_with_ops(f32, f32) { -bb0(%a : f32, %b : f32): +^bb0(%a : f32, %b : f32): %r = cmpi "eq", %a, %b : f32 // expected-error {{op requires an integer or index type}} } @@ -217,14 +217,14 @@ bb0(%a : f32, %b : f32): // Result type must be boolean like. cfgfunc @cfgfunc_with_ops(i32, i32) { -bb0(%a : i32, %b : i32): +^bb0(%a : i32, %b : i32): %r = "cmpi"(%a, %b) {predicate: 0} : (i32, i32) -> i32 // expected-error {{op requires a bool result type}} } // ----- cfgfunc @cfgfunc_with_ops(i32, i32) { -bb0(%a : i32, %b : i32): +^bb0(%a : i32, %b : i32): // expected-error@+1 {{requires an integer attribute named 'predicate'}} %r = "cmpi"(%a, %b) {foo: 1} : (i32, i32) -> i1 } @@ -232,7 +232,7 @@ bb0(%a : i32, %b : i32): // ----- cfgfunc @cfgfunc_with_ops() { -bb0: +^bb0: %c = constant splat, 0> : vector<42 x i32> // expected-error@+1 {{op requires the same shape for all operands and results}} %r = "cmpi"(%c, %c) {predicate: 0} : (vector<42 x i32>, vector<42 x i32>) -> vector<41 x i1> @@ -241,7 +241,7 @@ bb0: // ----- cfgfunc @cfgfunc_with_ops(i32, i32, i32) { -bb0(%cond : i32, %t : i32, %f : i32): +^bb0(%cond : i32, %t : i32, %f : i32): // expected-error@+2 {{different type than prior uses}} // expected-error@-2 {{prior use here}} %r = select %cond, %t, %f : i32 @@ -250,7 +250,7 @@ bb0(%cond : i32, %t : i32, %f : i32): // ----- cfgfunc @cfgfunc_with_ops(i32, i32, i32) { -bb0(%cond : i32, %t : i32, %f : i32): +^bb0(%cond : i32, %t : i32, %f : i32): // expected-error@+1 {{elemental type i1}} %r = "select"(%cond, %t, %f) : (i32, i32, i32) -> i32 } @@ -258,7 +258,7 @@ bb0(%cond : i32, %t : i32, %f : i32): // ----- cfgfunc @cfgfunc_with_ops(i1, i32, i64) { -bb0(%cond : i1, %t : i32, %f : i64): +^bb0(%cond : i1, %t : i32, %f : i64): // expected-error@+1 {{'true' and 'false' arguments to be of the same type}} %r = "select"(%cond, %t, %f) : (i1, i32, i64) -> i32 } @@ -266,7 +266,7 @@ bb0(%cond : i1, %t : i32, %f : i64): // ----- cfgfunc @cfgfunc_with_ops(i1, vector<42xi32>, vector<42xi32>) { -bb0(%cond : i1, %t : vector<42xi32>, %f : vector<42xi32>): +^bb0(%cond : i1, %t : vector<42xi32>, %f : vector<42xi32>): // expected-error@+1 {{requires the condition to have the same shape as arguments}} %r = "select"(%cond, %t, %f) : (i1, vector<42xi32>, vector<42xi32>) -> vector<42xi32> } @@ -274,7 +274,7 @@ bb0(%cond : i1, %t : vector<42xi32>, %f : vector<42xi32>): // ----- cfgfunc @cfgfunc_with_ops(i1, tensor<42xi32>, tensor) { -bb0(%cond : i1, %t : tensor<42xi32>, %f : tensor): +^bb0(%cond : i1, %t : tensor<42xi32>, %f : tensor): // expected-error@+1 {{'true' and 'false' arguments to be of the same type}} %r = "select"(%cond, %t, %f) : (i1, tensor<42xi32>, tensor) -> tensor<42xi32> } @@ -282,7 +282,7 @@ bb0(%cond : i1, %t : tensor<42xi32>, %f : tensor): // ----- cfgfunc @cfgfunc_with_ops(tensor, tensor<42xi32>, tensor<42xi32>) { -bb0(%cond : tensor, %t : tensor<42xi32>, %f : tensor<42xi32>): +^bb0(%cond : tensor, %t : tensor<42xi32>, %f : tensor<42xi32>): // expected-error@+1 {{requires the condition to have the same shape as arguments}} %r = "select"(%cond, %t, %f) : (tensor, tensor<42xi32>, tensor<42xi32>) -> tensor<42xi32> } @@ -290,7 +290,7 @@ bb0(%cond : tensor, %t : tensor<42xi32>, %f : tensor<42xi32>): // ----- cfgfunc @test_vector_transfer_read(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant 3.0 : f32 // expected-error@+1 {{expected 4 operand types but had 3}} @@ -300,7 +300,7 @@ bb0(%arg0 : memref): // ----- cfgfunc @test_vector_transfer_read(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant 3.0 : f32 // expected-error@+1 {{requires 3 operands}} @@ -310,7 +310,7 @@ bb0(%arg0 : memref): // ----- cfgfunc @test_vector_transfer_read(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant 3.0 : f32 // expected-error@+1 {{requires an AffineMapAttr named 'permutation_map'}} @@ -320,7 +320,7 @@ bb0(%arg0 : memref): // ----- cfgfunc @test_vector_transfer_read(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant 3.0 : f32 // expected-error@+1 {{requires an AffineMapAttr named 'permutation_map'}} @@ -330,7 +330,7 @@ bb0(%arg0 : memref): // ----- cfgfunc @test_vector_transfer_read(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant 3.0 : f32 // expected-error@+1 {{requires a permutation_map with input dims of the same rank as the memref type}} @@ -340,7 +340,7 @@ bb0(%arg0 : memref): // ----- cfgfunc @test_vector_transfer_read(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant 3.0 : f32 // expected-error@+1 {{requires a permutation_map with result dims of the same rank as the vector type}} @@ -350,7 +350,7 @@ bb0(%arg0 : memref): // ----- cfgfunc @test_vector_transfer_read(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant 3.0 : f32 // expected-error@+1 {{requires a projected permutation_map (at most one dim or the zero constant can appear in each result)}} @@ -360,7 +360,7 @@ bb0(%arg0 : memref): // ----- cfgfunc @test_vector_transfer_read(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant 3.0 : f32 // expected-error@+1 {{requires a projected permutation_map (at most one dim or the zero constant can appear in each result)}} @@ -369,7 +369,7 @@ bb0(%arg0 : memref): // ----- cfgfunc @test_vector_transfer_read(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant 3.0 : f32 // expected-error@+1 {{requires a permutation_map that is a permutation (found one dim used more than once)}} @@ -379,7 +379,7 @@ bb0(%arg0 : memref): // ----- cfgfunc @test_vector_transfer_write(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant splat, 3.0> : vector<128 x f32> // expected-error@+1 {{expected 5 operand types but had 4}} @@ -389,7 +389,7 @@ bb0(%arg0 : memref): // ----- cfgfunc @test_vector_transfer_write(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant splat, 3.0> : vector<128 x f32> // expected-error@+1 {{requires number of operands and input types to match}} @@ -399,7 +399,7 @@ bb0(%arg0 : memref): // ----- cfgfunc @test_vector_transfer_write(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant splat, 3.0> : vector<128 x f32> // expected-error@+1 {{requires an AffineMapAttr named 'permutation_map'}} @@ -409,7 +409,7 @@ bb0(%arg0 : memref): // ----- cfgfunc @test_vector_transfer_write(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant splat, 3.0> : vector<128 x f32> // expected-error@+1 {{requires an AffineMapAttr named 'permutation_map'}} @@ -419,7 +419,7 @@ bb0(%arg0 : memref): // ----- cfgfunc @test_vector_transfer_write(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant splat, 3.0> : vector<128 x f32> // expected-error@+1 {{requires a permutation_map with input dims of the same rank as the memref type}} @@ -429,7 +429,7 @@ bb0(%arg0 : memref): // ----- cfgfunc @test_vector_transfer_write(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant splat, 3.0> : vector<128 x f32> // expected-error@+1 {{requires a permutation_map with result dims of the same rank as the vector type}} @@ -439,7 +439,7 @@ bb0(%arg0 : memref): // ----- cfgfunc @test_vector_transfer_write(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant splat, 3.0> : vector<128 x f32> // expected-error@+1 {{requires a projected permutation_map (at most one dim or the zero constant can appear in each result)}} @@ -449,7 +449,7 @@ bb0(%arg0 : memref): // ----- cfgfunc @test_vector_transfer_write(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant splat, 3.0> : vector<128 x f32> // expected-error@+1 {{requires a projected permutation_map (at most one dim or the zero constant can appear in each result)}} @@ -458,7 +458,7 @@ bb0(%arg0 : memref): // ----- cfgfunc @test_vector_transfer_write(memref) { -bb0(%arg0 : memref): +^bb0(%arg0 : memref): %c3 = constant 3 : index %cst = constant splat, 3.0> : vector<3 x 7 x f32> // expected-error@+1 {{requires a permutation_map that is a permutation (found one dim used more than once)}} diff --git a/mlir/test/IR/invalid.mlir b/mlir/test/IR/invalid.mlir index 1af50ced567e..ac3c74019b5e 100644 --- a/mlir/test/IR/invalid.mlir +++ b/mlir/test/IR/invalid.mlir @@ -87,55 +87,55 @@ extfunc missingsigil() -> (i1, index, f32) // expected-error {{expected a functi // ----- cfgfunc @bad_branch() { -bb12: - br missing // expected-error {{reference to an undefined block}} +^bb12: + br ^missing // expected-error {{reference to an undefined block}} } // ----- cfgfunc @block_redef() { -bb42: +^bb42: return -bb42: // expected-error {{redefinition of block 'bb42'}} +^bb42: // expected-error {{redefinition of block '^bb42'}} return } // ----- cfgfunc @no_terminator() { -bb40: +^bb40: return -bb41: -bb42: // expected-error {{custom op 'bb42' is unknown}} +^bb41: +^bb42: // expected-error {{expected operation name in quotes}} return } // ----- cfgfunc @block_no_rparen() { -bb42 (%bb42 : i32: // expected-error {{expected ')' to end argument list}} +^bb42 (%bb42 : i32: // expected-error {{expected ')' to end argument list}} return } // ----- cfgfunc @block_arg_no_ssaid() { -bb42 (i32): // expected-error {{expected SSA operand}} +^bb42 (i32): // expected-error {{expected SSA operand}} return } // ----- cfgfunc @block_arg_no_type() { -bb42 (%0): // expected-error {{expected ':' and type for SSA operand}} +^bb42 (%0): // expected-error {{expected ':' and type for SSA operand}} return } // ----- cfgfunc @block_arg_no_close_paren() { -bb42: - br bb2( // expected-error@+1 {{expected ')' to close argument list}} +^bb42: + br ^bb2( // expected-error@+1 {{expected ')' to close argument list}} return } @@ -143,17 +143,17 @@ bb42: cfgfunc @block_first_has_predecessor() { // expected-error@-1 {{entry block of function may not have predecessors}} -bb42: - br bb43 -bb43: - br bb42 +^bb42: + br ^bb43 +^bb43: + br ^bb42 } // ----- cfgfunc @illegalattrs() -> () attributes { key } { // expected-error {{expected ':' in attribute list}} -bb42: +^bb42: return } @@ -171,7 +171,7 @@ mlfunc @empty() { mlfunc @illegalattrs() -> () attributes { key } { // expected-error {{expected ':' in attribute list}} -bb42: +^bb42: return } @@ -193,14 +193,14 @@ mlfunc @no_return() { // ----- cfgfunc @bad_op_type() { -bb40: +^bb40: "foo"() : i32 // expected-error {{expected function type}} return } // ----- cfgfunc @no_terminator() { -bb40: +^bb40: "foo"() : ()->() ""() : ()->() // expected-error {{empty operation name is invalid}} return @@ -313,7 +313,7 @@ mlfunc @invalid_if_conditional7() { // ----- cfgfunc @test() { -bb40: +^bb40: %1 = "foo"() : (i32)->i64 // expected-error {{expected 0 operand types but had 1}} return } @@ -321,7 +321,7 @@ bb40: // ----- cfgfunc @redef() { -bb42: +^bb42: %x = "xxx"(){index: 0} : ()->i32 // expected-error {{previously defined here}} %x = "xxx"(){index: 0} : ()->i32 // expected-error {{redefinition of SSA value '%x'}} return @@ -330,7 +330,7 @@ bb42: // ----- cfgfunc @undef() { -bb42: +^bb42: %x = "xxx"(%y) : (i32)->i32 // expected-error {{use of undeclared SSA value}} return } @@ -349,7 +349,7 @@ mlfunc @malformed_type(%a : intt) { // expected-error {{expected type}} // ----- cfgfunc @resulterror() -> i32 { -bb42: +^bb42: return // expected-error {{'return' op has 0 operands, but enclosing function returns 1}} } @@ -362,28 +362,28 @@ mlfunc @mlfunc_resulterror() -> i32 { // ----- cfgfunc @argError() { -bb1(%a: i64): // expected-error {{previously defined here}} - br bb2 -bb2(%a: i64): // expected-error{{redefinition of SSA value '%a'}} +^bb1(%a: i64): // expected-error {{previously defined here}} + br ^bb2 +^bb2(%a: i64): // expected-error{{redefinition of SSA value '%a'}} return } // ----- cfgfunc @bbargMismatch(i32, f32) { // expected-error {{first block of function must have 2 arguments to match function signature}} -bb42(%0: f32): +^bb42(%0: f32): return } // ----- cfgfunc @br_mismatch() { -bb0: +^bb0: %0 = "foo"() : () -> (i1, i17) // expected-error @+1 {{branch has 2 operands, but target block has 1}} - br bb1(%0#1, %0#0 : i17, i1) + br ^bb1(%0#1, %0#0 : i17, i1) -bb1(%x: i17): +^bb1(%x: i17): return } @@ -396,34 +396,34 @@ extfunc @vectors(vector<1 x vector<1xi32>>, vector<2x4xf32>) // ----- cfgfunc @condbr_notbool() { -bb0: +^bb0: %a = "foo"() : () -> i32 // expected-error {{prior use here}} - cond_br %a, bb0, bb0 // expected-error {{use of value '%a' expects different type than prior uses}} + cond_br %a, ^bb0, ^bb0 // expected-error {{use of value '%a' expects different type than prior uses}} // expected-error@-1 {{expected condition type was boolean (i1)}} } // ----- cfgfunc @condbr_badtype() { -bb0: +^bb0: %c = "foo"() : () -> i1 %a = "foo"() : () -> i32 - cond_br %c, bb0(%a, %a : i32, bb0) // expected-error {{expected type}} + cond_br %c, ^bb0(%a, %a : i32, ^bb0) // expected-error {{expected type}} } // ----- cfgfunc @condbr_a_bb_is_not_a_type() { -bb0: +^bb0: %c = "foo"() : () -> i1 %a = "foo"() : () -> i32 - cond_br %c, bb0(%a, %a : i32, i32), i32 // expected-error {{expected block name}} + cond_br %c, ^bb0(%a, %a : i32, i32), i32 // expected-error {{expected block name}} } // ----- cfgfunc @undef() { -bb0: +^bb0: %x = "xxx"(%y) : (i32)->i32 // expected-error {{use of undeclared SSA value name}} return } @@ -457,10 +457,10 @@ mlfunc @dominance_failure() { // ----- cfgfunc @dominance_failure() { -bb0: +^bb0: "foo"(%x) : (i32) -> () // expected-error {{operand #0 does not dominate this use}} - br bb1 -bb1: + br ^bb1 +^bb1: %x = "bar"() : () -> i32 // expected-note {{operand defined here}} return } @@ -490,7 +490,7 @@ extfunc @redef() // expected-error {{redefinition of function named 'redef'}} // ----- cfgfunc @foo() { -bb0: +^bb0: %x = constant @foo : (i32) -> () // expected-error {{reference to function with mismatched type}} return } @@ -498,7 +498,7 @@ bb0: // ----- cfgfunc @undefined_function() { -bb0: +^bb0: %x = constant @bar : (i32) -> () // expected-error {{reference to undefined function 'bar'}} return } @@ -662,46 +662,46 @@ mlfunc @calls(%arg0 : i32) { } // ----- // expected-error@+2 {{expected SSA operand}} -cfgfunc@n(){b( +cfgfunc@n(){^b( // ----- cfgfunc @elementsattr_non_tensor_type() -> () { -bb0: +^bb0: "foo"(){bar: dense} : () -> () // expected-error {{expected elements literal has a tensor or vector type}} } // ----- cfgfunc @elementsattr_non_ranked() -> () { -bb0: +^bb0: "foo"(){bar: dense, [4]>} : () -> () // expected-error {{tensor literals must be ranked and have static shape}} } // ----- cfgfunc @elementsattr_shape_mismatch() -> () { -bb0: +^bb0: "foo"(){bar: dense, [4]>} : () -> () // expected-error {{inferred shape of elements literal ([1]) does not match type ([5])}} } // ----- cfgfunc @elementsattr_invalid() -> () { -bb0: +^bb0: "foo"(){bar: dense, [4, [5]]>} : () -> () // expected-error {{tensor literal is invalid; ranks are not consistent between elements}} } // ----- cfgfunc @elementsattr_badtoken() -> () { -bb0: +^bb0: "foo"(){bar: dense, [tf_opaque]>} : () -> () // expected-error {{expected '[' or scalar constant inside tensor literal}} } // ----- cfgfunc @elementsattr_floattype1() -> () { -bb0: +^bb0: // expected-error@+1 {{floating point value not valid for specified type}} "foo"(){bar: dense, [4.0]>} : () -> () } @@ -709,7 +709,7 @@ bb0: // ----- cfgfunc @elementsattr_floattype2() -> () { -bb0: +^bb0: // expected-error@+1 {{integer value not valid for specified type}} "foo"(){bar: dense, [4]>} : () -> () } @@ -717,35 +717,35 @@ bb0: // ----- cfgfunc @elementsattr_toolarge1() -> () { -bb0: +^bb0: "foo"(){bar: dense, [777]>} : () -> () // expected-error {{integer constant out of range for attribute}} } // ----- cfgfunc @elementsattr_toolarge2() -> () { -bb0: +^bb0: "foo"(){bar: dense, [-777]>} : () -> () // expected-error {{integer constant out of range for attribute}} } // ----- cfgfunc @elementsattr_malformed_opaque() -> () { -bb0: +^bb0: "foo"(){bar: opaque, "0xQZz123">} : () -> () // expected-error {{opaque string only contains hex digits}} } // ----- cfgfunc @elementsattr_malformed_opaque1() -> () { -bb0: +^bb0: "foo"(){bar: opaque, "00abc">} : () -> () // expected-error {{opaque string should start with '0x'}} } // ----- cfgfunc @redundant_signature(%a : i32) -> () { -bb0(%b : i32): // expected-error {{custom op 'bb0' is unknown}} +^bb0(%b : i32): // expected-error {{expected operation name in quotes}} return } @@ -770,6 +770,6 @@ mlfunc @multi_block(%N : index) { // expected-error {{mlfunc should have exactl for %i = 1 to %N {} return -bb42: +^bb42: return } diff --git a/mlir/test/IR/memory-ops.mlir b/mlir/test/IR/memory-ops.mlir index a70c7f5dd56f..a38363162516 100644 --- a/mlir/test/IR/memory-ops.mlir +++ b/mlir/test/IR/memory-ops.mlir @@ -4,7 +4,7 @@ // CHECK-LABEL: cfgfunc @alloc() { cfgfunc @alloc() { -bb0: +^bb0: // Test simple alloc. // CHECK: %0 = alloc() : memref<1024x64xf32, 1> %0 = alloc() : memref<1024x64xf32, (d0, d1) -> (d0, d1), 1> @@ -35,7 +35,7 @@ bb0: // CHECK-LABEL: cfgfunc @dealloc() { cfgfunc @dealloc() { -bb0: +^bb0: // CHECK: %0 = alloc() : memref<1024x64xf32> %0 = alloc() : memref<1024x64xf32, (d0, d1) -> (d0, d1), 0> @@ -46,7 +46,7 @@ bb0: // CHECK-LABEL: cfgfunc @load_store cfgfunc @load_store() { -bb0: +^bb0: // CHECK: %0 = alloc() : memref<1024x64xf32, 1> %0 = alloc() : memref<1024x64xf32, (d0, d1) -> (d0, d1), 1> diff --git a/mlir/test/IR/op-stats.mlir b/mlir/test/IR/op-stats.mlir index 27674ef2d5f9..da70acbb6d36 100644 --- a/mlir/test/IR/op-stats.mlir +++ b/mlir/test/IR/op-stats.mlir @@ -1,7 +1,7 @@ // RUN: mlir-opt -print-op-stats %s -o=/dev/null 2>&1 | FileCheck %s cfgfunc @main(tensor<4xf32>, tensor<4xf32>) -> tensor<4xf32> { -bb0(%arg0: tensor<4xf32>, %arg1: tensor<4xf32>): +^bb0(%arg0: tensor<4xf32>, %arg1: tensor<4xf32>): %0 = addf %arg0, %arg1 : tensor<4xf32> %1 = addf %arg0, %arg1 : tensor<4xf32> %2 = addf %arg0, %arg1 : tensor<4xf32> diff --git a/mlir/test/IR/parser.mlir b/mlir/test/IR/parser.mlir index 15612e0c2534..574848fe5f37 100644 --- a/mlir/test/IR/parser.mlir +++ b/mlir/test/IR/parser.mlir @@ -134,8 +134,8 @@ extfunc @functions((memref<1x?x4x?x?xi32, #map0, 0>, memref<8xi8, #map1, 0>) -> // CHECK-LABEL: cfgfunc @simpleCFG(i32, f32) -> i1 { cfgfunc @simpleCFG(i32, f32) -> i1 { -// CHECK: bb0(%arg0: i32, %arg1: f32): -bb42 (%arg0: i32, %f: f32): +// CHECK: ^bb0(%arg0: i32, %arg1: f32): +^bb42 (%arg0: i32, %f: f32): // CHECK: %0 = "foo"() : () -> i64 %1 = "foo"() : ()->i64 // CHECK: "bar"(%0) : (i64) -> (i1, i1, i1) @@ -147,8 +147,8 @@ bb42 (%arg0: i32, %f: f32): // CHECK-LABEL: cfgfunc @simpleCFGUsingBBArgs(i32, i64) { cfgfunc @simpleCFGUsingBBArgs(i32, i64) { -// CHECK: bb0(%arg0: i32, %arg1: i64): -bb42 (%arg0: i32, %f: i64): +// CHECK: ^bb0(%arg0: i32, %arg1: i64): +^bb42 (%arg0: i32, %f: i64): // CHECK: "bar"(%arg1) : (i64) -> (i1, i1, i1) %2 = "bar"(%f) : (i64) -> (i1,i1,i1) // CHECK: return{{$}} @@ -158,13 +158,13 @@ bb42 (%arg0: i32, %f: i64): // CHECK-LABEL: cfgfunc @multiblock() { cfgfunc @multiblock() { -bb0: // CHECK: bb0: +^bb0: // CHECK: ^bb0: return // CHECK: return -bb1: // CHECK: bb1: // no predecessors - br bb4 // CHECK: br bb3 -bb2: // CHECK: bb2: // pred: bb2 - br bb2 // CHECK: br bb2 -bb4: // CHECK: bb3: // pred: bb1 +^bb1: // CHECK: ^bb1: // no predecessors + br ^bb4 // CHECK: br ^bb3 +^bb2: // CHECK: ^bb2: // pred: ^bb2 + br ^bb2 // CHECK: br ^bb2 +^bb4: // CHECK: ^bb3: // pred: ^bb1 return // CHECK: return } // CHECK: } @@ -189,7 +189,7 @@ mlfunc @mlfunc_with_two_args(%a : f16, %b : i8) -> (i1, i32) { // CHECK-LABEL: cfgfunc @cfgfunc_with_two_args(f16, i8) -> (i1, i32) { cfgfunc @cfgfunc_with_two_args(%a : f16, %b : i8) -> (i1, i32) { - // CHECK: bb0(%arg0: f16, %arg1: i8): + // CHECK: ^bb0(%arg0: f16, %arg1: i8): // CHECK: %0 = "foo"(%arg0, %arg1) : (f16, i8) -> (i1, i32) %c = "foo"(%a, %b) : (f16, i8)->(i1, i32) return %c#0, %c#1 : i1, i32 // CHECK: return %0#0, %0#1 : i1, i32 @@ -328,7 +328,7 @@ mlfunc @simple_ifinst(%N: index) { // CHECK-LABEL: cfgfunc @attributes() { cfgfunc @attributes() { -bb42: // CHECK: bb0: +^bb42: // CHECK: ^bb0: // CHECK: "foo"() "foo"(){} : ()->() @@ -364,32 +364,32 @@ bb42: // CHECK: bb0: // CHECK-LABEL: cfgfunc @ssa_values() -> (i16, i8) { cfgfunc @ssa_values() -> (i16, i8) { -bb0: // CHECK: bb0: +^bb0: // CHECK: ^bb0: // CHECK: %0 = "foo"() : () -> (i1, i17) %0 = "foo"() : () -> (i1, i17) - br bb2 + br ^bb2 -bb1: // CHECK: bb1: // pred: bb2 +^bb1: // CHECK: ^bb1: // pred: ^bb2 // CHECK: %1 = "baz"(%2#1, %2#0, %0#1) : (f32, i11, i17) -> (i16, i8) %1 = "baz"(%2#1, %2#0, %0#1) : (f32, i11, i17) -> (i16, i8) // CHECK: return %1#0, %1#1 : i16, i8 return %1#0, %1#1 : i16, i8 -bb2: // CHECK: bb2: // pred: bb0 +^bb2: // CHECK: ^bb2: // pred: ^bb0 // CHECK: %2 = "bar"(%0#0, %0#1) : (i1, i17) -> (i11, f32) %2 = "bar"(%0#0, %0#1) : (i1, i17) -> (i11, f32) - br bb1 + br ^bb1 } // CHECK-LABEL: cfgfunc @bbargs() -> (i16, i8) { cfgfunc @bbargs() -> (i16, i8) { -bb0: // CHECK: bb0: +^bb0: // CHECK: ^bb0: // CHECK: %0 = "foo"() : () -> (i1, i17) %0 = "foo"() : () -> (i1, i17) - br bb1(%0#1, %0#0 : i17, i1) + br ^bb1(%0#1, %0#0 : i17, i1) -bb1(%x: i17, %y: i1): // CHECK: bb1(%1: i17, %2: i1): +^bb1(%x: i17, %y: i1): // CHECK: ^bb1(%1: i17, %2: i1): // CHECK: %3 = "baz"(%1, %2, %0#1) : (i17, i1, i17) -> (i16, i8) %1 = "baz"(%x, %y, %0#1) : (i17, i1, i17) -> (i16, i8) return %1#0, %1#1 : i16, i8 @@ -397,36 +397,36 @@ bb1(%x: i17, %y: i1): // CHECK: bb1(%1: i17, %2: i1): // CHECK-LABEL: cfgfunc @condbr_simple cfgfunc @condbr_simple() -> (i32) { -bb0: +^bb0: %cond = "foo"() : () -> i1 %a = "bar"() : () -> i32 %b = "bar"() : () -> i64 - // CHECK: cond_br %0, bb1(%1 : i32), bb2(%2 : i64) - cond_br %cond, bb1(%a : i32), bb2(%b : i64) + // CHECK: cond_br %0, ^bb1(%1 : i32), ^bb2(%2 : i64) + cond_br %cond, ^bb1(%a : i32), ^bb2(%b : i64) -// CHECK: bb1({{.*}}: i32): // pred: bb0 -bb1(%x : i32): - br bb2(%b: i64) +// CHECK: ^bb1({{.*}}: i32): // pred: ^bb0 +^bb1(%x : i32): + br ^bb2(%b: i64) -// CHECK: bb2({{.*}}: i64): // 2 preds: bb0, bb1 -bb2(%y : i64): +// CHECK: ^bb2({{.*}}: i64): // 2 preds: ^bb0, ^bb1 +^bb2(%y : i64): %z = "foo"() : () -> i32 return %z : i32 } // CHECK-LABEL: cfgfunc @condbr_moarargs cfgfunc @condbr_moarargs() -> (i32) { -bb0: +^bb0: %cond = "foo"() : () -> i1 %a = "bar"() : () -> i32 %b = "bar"() : () -> i64 - // CHECK: cond_br %0, bb1(%1, %2 : i32, i64), bb2(%2, %1, %1 : i64, i32, i32) - cond_br %cond, bb1(%a, %b : i32, i64), bb2(%b, %a, %a : i64, i32, i32) + // CHECK: cond_br %0, ^bb1(%1, %2 : i32, i64), ^bb2(%2, %1, %1 : i64, i32, i32) + cond_br %cond, ^bb1(%a, %b : i32, i64), ^bb2(%b, %a, %a : i64, i32, i32) -bb1(%x : i32, %y : i64): +^bb1(%x : i32, %y : i64): return %x : i32 -bb2(%x2 : i64, %y2 : i32, %z2 : i32): +^bb2(%x2 : i64, %y2 : i32, %z2 : i32): %z = "foo"() : () -> i32 return %z : i32 } @@ -435,7 +435,7 @@ bb2(%x2 : i64, %y2 : i32, %z2 : i32): // Test pretty printing of constant names. // CHECK-LABEL: cfgfunc @constants cfgfunc @constants() -> (i32, i23, i23, i1, i1) { -bb0: +^bb0: // CHECK: %c42_i32 = constant 42 : i32 %x = constant 42 : i32 // CHECK: %c17_i23 = constant 17 : i23 @@ -456,7 +456,7 @@ bb0: // CHECK-LABEL: cfgfunc @typeattr cfgfunc @typeattr() -> () { -bb0: +^bb0: // CHECK: "foo"() {bar: tensor<*xf32>} : () -> () "foo"(){bar: tensor<*xf32>} : () -> () return @@ -464,7 +464,7 @@ bb0: // CHECK-LABEL: cfgfunc @stringquote cfgfunc @stringquote() -> () { -bb0: +^bb0: // CHECK: "foo"() {bar: "a\22quoted\22string"} : () -> () "foo"(){bar: "a\"quoted\"string"} : () -> () return @@ -472,7 +472,7 @@ bb0: // CHECK-LABEL: cfgfunc @floatAttrs cfgfunc @floatAttrs() -> () { -bb0: +^bb0: // CHECK: "foo"() {a: 4.000000e+00, b: 2.000000e+00, c: 7.100000e+00, d: -0.000000e+00} : () -> () "foo"(){a: 4.0, b: 2.0, c: 7.1, d: -0.0} : () -> () return @@ -492,7 +492,7 @@ extfunc @extfuncattrempty() -> () cfgfunc @cfgfuncattr() -> () // CHECK: attributes {a: "a\22quoted\22string", b: 4.000000e+00, c: tensor<*xf32>} attributes {a: "a\"quoted\"string", b: 4.0, c: tensor<*xf32>} { -bb0: +^bb0: return } @@ -500,7 +500,7 @@ bb0: cfgfunc @cfgfuncattrempty() -> () // CHECK-EMPTY attributes {} { -bb0: +^bb0: return } @@ -550,7 +550,7 @@ mlfunc @mlfuncsimplemap(%arg0 : index, %arg1 : index) -> () { // CHECK-LABEL: cfgfunc @splattensorattr cfgfunc @splattensorattr() -> () { -bb0: +^bb0: // CHECK: "splatIntTensor"() {bar: splat, 5>} : () -> () "splatIntTensor"(){bar: splat, 5>} : () -> () // CHECK: "splatFloatTensor"() {bar: splat, -5.000000e+00>} : () -> () @@ -564,7 +564,7 @@ bb0: // CHECK-LABEL: cfgfunc @opaquetensorattr cfgfunc @opaquetensorattr() -> () { -bb0: +^bb0: // CHECK: "opaqueIntTensor"() {bar: opaque, "0x68656C6C6F">} : () -> () "opaqueIntTensor"(){bar: opaque, "0x68656C6C6F">} : () -> () // CHECK: "opaqueFloatTensor"() {bar: opaque, "0x68656C6C6F">} : () -> () @@ -579,7 +579,7 @@ bb0: // CHECK-LABEL: cfgfunc @densetensorattr cfgfunc @densetensorattr() -> () { -bb0: +^bb0: // NOTE: The {{\[\[}} syntax is because "[[" confuses FileCheck. // CHECK: "fooi3"() {bar: dense, {{\[\[\[}}1, -2, 1, 2]], {{\[\[}}0, 2, -1, 2]]]>} : () -> () @@ -634,7 +634,7 @@ bb0: // CHECK-LABEL: cfgfunc @densevectorattr cfgfunc @densevectorattr() -> () { -bb0: +^bb0: // NOTE: The {{\[\[}} syntax is because "[[" confuses FileCheck. // CHECK: "fooi8"() {bar: dense, {{\[\[\[}}5]]]>} : () -> () "fooi8"(){bar: dense, [[[5]]]>} : () -> () @@ -672,7 +672,7 @@ bb0: // CHECK-LABEL: cfgfunc @sparsetensorattr cfgfunc @sparsetensorattr() -> () { -bb0: +^bb0: // NOTE: The {{\[\[}} syntax is because "[[" confuses FileCheck. // CHECK: "fooi8"() {bar: sparse, {{\[\[}}0, 0, 0]], {{\[}}-2]>} : () -> () "fooi8"(){bar: sparse, [[0, 0, 0]], [-2]>} : () -> () @@ -700,7 +700,7 @@ bb0: // CHECK-LABEL: cfgfunc @sparsevectorattr cfgfunc @sparsevectorattr() -> () { -bb0: +^bb0: // NOTE: The {{\[\[}} syntax is because "[[" confuses FileCheck. // CHECK: "fooi8"() {bar: sparse, {{\[\[}}0, 0, 0]], {{\[}}-2]>} : () -> () "fooi8"(){bar: sparse, [[0, 0, 0]], [-2]>} : () -> () diff --git a/mlir/test/IR/repro_b120295301.mlir b/mlir/test/IR/repro_b120295301.mlir index 57438af52eaf..c258ef13fce0 100755 --- a/mlir/test/IR/repro_b120295301.mlir +++ b/mlir/test/IR/repro_b120295301.mlir @@ -1,7 +1,7 @@ // RUN: mlir-opt %s | FileCheck %s cfgfunc @testType(tensor<1x224x224x3xf32>) -> tensor<96xf32> { -bb0(%arg0: tensor<1x224x224x3xf32>): +^bb0(%arg0: tensor<1x224x224x3xf32>): %1 = "constant"() {value: splat, 0.1>} : () -> (tensor<1xf32>) %2 = "constant"() {value: splat, 0.1>} : () -> (tensor<2xf32>) %3 = "constant"() {value: splat, 0.1>} : () -> (tensor<3xf32>) diff --git a/mlir/test/Target/llvmir.mlir b/mlir/test/Target/llvmir.mlir index 2dc7b87eaa05..58d9d73b225d 100644 --- a/mlir/test/Target/llvmir.mlir +++ b/mlir/test/Target/llvmir.mlir @@ -17,7 +17,7 @@ // CHECK-NEXT: ret void // CHECK-NEXT: } cfgfunc @empty() { -bb0: +^bb0: return } @@ -27,39 +27,39 @@ extfunc @body(index) // CHECK-LABEL: define void @simple_loop() { cfgfunc @simple_loop() { -bb0: -// CHECK: br label %[[SIMPLE_BB1:[0-9]+]] - br bb1 +^bb0: +// CHECK: br label %[[SIMPLE_bb1:[0-9]+]] + br ^bb1 // Constants are inlined in LLVM rather than a separate instruction. -// CHECK: