diff --git a/flang/lib/Optimizer/Dialect/FIRType.cpp b/flang/lib/Optimizer/Dialect/FIRType.cpp --- a/flang/lib/Optimizer/Dialect/FIRType.cpp +++ b/flang/lib/Optimizer/Dialect/FIRType.cpp @@ -687,14 +687,17 @@ return {}; } mlir::Type eleTy; - if (parser.parseType(eleTy) || parser.parseGreater()) + if (parser.parseType(eleTy)) return {}; mlir::AffineMapAttr map; - if (!parser.parseOptionalComma()) + if (!parser.parseOptionalComma()) { if (parser.parseAttribute(map)) { parser.emitError(parser.getNameLoc(), "expecting affine map"); return {}; } + } + if (parser.parseGreater()) + return {}; return SequenceType::get(parser.getContext(), shape, eleTy, map); } diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -1549,9 +1549,7 @@ return; } - os << "<\""; - llvm::printEscapedString(symString, os); - os << "\">"; + os << "<" << symString << ">"; } /// Returns true if the given string can be represented as a bare identifier. diff --git a/mlir/lib/Parser/DialectSymbolParser.cpp b/mlir/lib/Parser/DialectSymbolParser.cpp --- a/mlir/lib/Parser/DialectSymbolParser.cpp +++ b/mlir/lib/Parser/DialectSymbolParser.cpp @@ -72,6 +72,10 @@ switch (c) { case '\0': // This also handles the EOF case. + if (!nestedPunctuation.empty()) { + return emitError() << "unbalanced '" << nestedPunctuation.back() + << "' character in pretty dialect name"; + } return emitError("unexpected nul or EOF in pretty dialect name"); case '<': case '[': @@ -102,6 +106,15 @@ if (nestedPunctuation.pop_back_val() != '{') return emitError("unbalanced '}' character in pretty dialect name"); break; + case '"': + while (*curPtr != '"') { + if (*curPtr == '\0') + return emitError("unexpected nul or EOF in pretty dialect name"); + ++curPtr; + } + // Update past the terminal '"'. + ++curPtr; + break; default: continue; @@ -110,11 +123,8 @@ // Ok, we succeeded, remember where we stopped, reset the lexer to know it is // consuming all this stuff, and return. - state.lex.resetPointer(curPtr); - unsigned length = curPtr - prettyName.begin(); prettyName = StringRef(prettyName.begin(), length); - consumeToken(); return success(); } @@ -125,12 +135,14 @@ CreateFn &&createSymbol) { // Parse the dialect namespace. StringRef identifier = p.getTokenSpelling().drop_front(); - auto loc = p.getToken().getLoc(); + SMLoc loc = p.getToken().getLoc(); p.consumeToken(identifierTok); // If there is no '<' token following this, and if the typename contains no // dot, then we are parsing a symbol alias. - if (p.getToken().isNot(Token::less) && !identifier.contains('.')) { + bool isPrettyName = identifier.contains('.'); + bool hasTrailingData = p.getToken().is(Token::less); + if (!hasTrailingData && !isPrettyName) { // Check for an alias for this type. auto aliasIt = aliases.find(identifier); if (aliasIt == aliases.end()) @@ -139,92 +151,39 @@ return aliasIt->second; } - // Otherwise, we are parsing a dialect-specific symbol. If the name contains - // a dot, then this is the "pretty" form. If not, it is the verbose form that - // looks like <"...">. - std::string symbolData; - auto dialectName = identifier; - - // Handle the verbose form, where "identifier" is a simple dialect name. - if (!identifier.contains('.')) { + // If this isn't an alias, we are parsing a dialect-specific symbol. If the + // name contains a dot, then this is the "pretty" form. If not, it is the + // verbose form that looks like <...>. + StringRef dialectName = identifier; + if (!isPrettyName) { // Consume the '<'. - if (p.parseToken(Token::less, "expected '<' in dialect type")) - return nullptr; - - // Parse the symbol specific data. - if (p.getToken().isNot(Token::string)) - return (p.emitError("expected string literal data in dialect symbol"), - nullptr); - symbolData = p.getToken().getStringValue(); - loc = SMLoc::getFromPointer(p.getToken().getLoc().getPointer() + 1); - p.consumeToken(Token::string); + if (!hasTrailingData) + return (p.emitError("expected '<' after dialect name"), nullptr); - // Consume the '>'. - if (p.parseToken(Token::greater, "expected '>' in dialect symbol")) + // Point the symbol data to the end of the dialect name to start. + StringRef symbolData(dialectName.data() + dialectName.size(), 0); + if (p.parsePrettyDialectSymbolName(symbolData)) return nullptr; - } else { - // Ok, the dialect name is the part of the identifier before the dot, the - // part after the dot is the dialect's symbol, or the start thereof. - auto dotHalves = identifier.split('.'); - dialectName = dotHalves.first; - auto prettyName = dotHalves.second; - loc = SMLoc::getFromPointer(prettyName.data()); - - // If the dialect's symbol is followed immediately by a <, then lex the body - // of it into prettyName. - if (p.getToken().is(Token::less) && - prettyName.bytes_end() == p.getTokenSpelling().bytes_begin()) { - if (p.parsePrettyDialectSymbolName(prettyName)) - return nullptr; - } - - symbolData = prettyName.str(); + p.resetToken(symbolData.data() + symbolData.size()); + return createSymbol(dialectName, symbolData.drop_front().drop_back(), loc); } - // Record the name location of the type remapped to the top level buffer. - SMLoc locInTopLevelBuffer = p.remapLocationToTopLevelBuffer(loc); - p.getState().symbols.nestedParserLocs.push_back(locInTopLevelBuffer); - - // Call into the provided symbol construction function. - Symbol sym = createSymbol(dialectName, symbolData, loc); - - // Pop the last parser location. - p.getState().symbols.nestedParserLocs.pop_back(); - return sym; -} - -/// Parses a symbol, of type 'T', and returns it if parsing was successful. If -/// parsing failed, nullptr is returned. The number of bytes read from the input -/// string is returned in 'numRead'. -template -static T parseSymbol(StringRef inputStr, MLIRContext *context, - SymbolState &symbolState, ParserFn &&parserFn, - size_t *numRead = nullptr) { - SourceMgr sourceMgr; - auto memBuffer = MemoryBuffer::getMemBuffer( - inputStr, /*BufferName=*/"", - /*RequiresNullTerminator=*/false); - sourceMgr.AddNewSourceBuffer(std::move(memBuffer), SMLoc()); - ParserState state(sourceMgr, context, symbolState, /*asmState=*/nullptr); - Parser parser(state); - - Token startTok = parser.getToken(); - T symbol = parserFn(parser); - if (!symbol) - return T(); - - // If 'numRead' is valid, then provide the number of bytes that were read. - Token endTok = parser.getToken(); - if (numRead) { - *numRead = static_cast(endTok.getLoc().getPointer() - - startTok.getLoc().getPointer()); - - // Otherwise, ensure that all of the tokens were parsed. - } else if (startTok.getLoc() != endTok.getLoc() && endTok.isNot(Token::eof)) { - parser.emitError(endTok.getLoc(), "encountered unexpected token"); - return T(); + // Otherwise, the dialect name is the part of the identifier before the dot, + // the part after the dot is the dialect's symbol, or the start thereof. + auto dotHalves = identifier.split('.'); + dialectName = dotHalves.first; + StringRef prettyName = dotHalves.second; + loc = SMLoc::getFromPointer(prettyName.data()); + + // If the dialect's symbol is followed immediately by a <, then lex the body + // of it into prettyName. + if (hasTrailingData && + prettyName.bytes_end() == p.getTokenSpelling().bytes_begin()) { + if (p.parsePrettyDialectSymbolName(prettyName)) + return nullptr; } - return symbol; + p.resetToken(prettyName.data() + prettyName.size()); + return createSymbol(dialectName, prettyName, loc); } /// Parse an extended attribute. @@ -247,11 +206,15 @@ // If we found a registered dialect, then ask it to parse the attribute. if (Dialect *dialect = builder.getContext()->getOrLoadDialect(dialectName)) { - return parseSymbol( - symbolData, state.context, state.symbols, [&](Parser &parser) { - CustomDialectAsmParser customParser(symbolData, parser); - return dialect->parseAttribute(customParser, attrType); - }); + // Temporarily reset the lexer to let the dialect parse the attribute. + const char *curLexerPos = getState().curToken.getLoc().getPointer(); + resetToken(symbolData.data()); + + CustomDialectAsmParser customParser(symbolData, *this); + Attribute attr = dialect->parseAttribute(customParser, attrType); + + resetToken(curLexerPos); + return attr; } // Otherwise, form a new opaque attribute. @@ -280,17 +243,18 @@ Type Parser::parseExtendedType() { return parseExtendedSymbol( *this, Token::exclamation_identifier, state.symbols.typeAliasDefinitions, - [&](StringRef dialectName, StringRef symbolData, - SMLoc loc) -> Type { + [&](StringRef dialectName, StringRef symbolData, SMLoc loc) -> Type { // If we found a registered dialect, then ask it to parse the type. - auto *dialect = state.context->getOrLoadDialect(dialectName); - - if (dialect) { - return parseSymbol( - symbolData, state.context, state.symbols, [&](Parser &parser) { - CustomDialectAsmParser customParser(symbolData, parser); - return dialect->parseType(customParser); - }); + if (auto *dialect = state.context->getOrLoadDialect(dialectName)) { + // Temporarily reset the lexer to let the dialect parse the type. + const char *curLexerPos = getState().curToken.getLoc().getPointer(); + resetToken(symbolData.data()); + + CustomDialectAsmParser customParser(symbolData, *this); + Type type = dialect->parseType(customParser); + + resetToken(curLexerPos); + return type; } // Otherwise, form a new opaque type. @@ -310,16 +274,28 @@ template static T parseSymbol(StringRef inputStr, MLIRContext *context, size_t &numRead, ParserFn &&parserFn) { + SourceMgr sourceMgr; + auto memBuffer = MemoryBuffer::getMemBuffer( + inputStr, /*BufferName=*/"", + /*RequiresNullTerminator=*/false); + sourceMgr.AddNewSourceBuffer(std::move(memBuffer), SMLoc()); SymbolState aliasState; - return parseSymbol( - inputStr, context, aliasState, - [&](Parser &parser) { - SourceMgrDiagnosticHandler handler( - const_cast(parser.getSourceMgr()), - parser.getContext()); - return parserFn(parser); - }, - &numRead); + ParserState state(sourceMgr, context, aliasState, /*asmState=*/nullptr); + Parser parser(state); + + SourceMgrDiagnosticHandler handler( + const_cast(parser.getSourceMgr()), + parser.getContext()); + Token startTok = parser.getToken(); + T symbol = parserFn(parser); + if (!symbol) + return T(); + + // Provide the number of bytes that were read. + Token endTok = parser.getToken(); + numRead = static_cast(endTok.getLoc().getPointer() - + startTok.getLoc().getPointer()); + return symbol; } Attribute mlir::parseAttribute(StringRef attrStr, MLIRContext *context) { diff --git a/mlir/lib/Parser/Parser.h b/mlir/lib/Parser/Parser.h --- a/mlir/lib/Parser/Parser.h +++ b/mlir/lib/Parser/Parser.h @@ -76,32 +76,7 @@ /// Encode the specified source location information into an attribute for /// attachment to the IR. Location getEncodedSourceLocation(SMLoc loc) { - // If there are no active nested parsers, we can get the encoded source - // location directly. - if (state.parserDepth == 0) - return state.lex.getEncodedSourceLocation(loc); - // Otherwise, we need to re-encode it to point to the top level buffer. - return state.symbols.topLevelLexer->getEncodedSourceLocation( - remapLocationToTopLevelBuffer(loc)); - } - - /// Remaps the given SMLoc to the top level lexer of the parser. This is used - /// to adjust locations of potentially nested parsers to ensure that they can - /// be emitted properly as diagnostics. - SMLoc remapLocationToTopLevelBuffer(SMLoc loc) { - // If there are no active nested parsers, we can return location directly. - SymbolState &symbols = state.symbols; - if (state.parserDepth == 0) - return loc; - assert(symbols.topLevelLexer && "expected valid top-level lexer"); - - // Otherwise, we need to remap the location to the main parser. This is - // simply offseting the location onto the location of the last nested - // parser. - size_t offset = loc.getPointer() - state.lex.getBufferBegin(); - auto *rawLoc = - symbols.nestedParserLocs[state.parserDepth - 1].getPointer() + offset; - return SMLoc::getFromPointer(rawLoc); + return state.lex.getEncodedSourceLocation(loc); } //===--------------------------------------------------------------------===// @@ -136,6 +111,12 @@ consumeToken(); } + /// Reset the parser to the given lexer position. + void resetToken(const char *tokPos) { + state.lex.resetPointer(tokPos); + state.curToken = state.lex.lexToken(); + } + /// Consume the specified token if present and return success. On failure, /// output a diagnostic and return failure. ParseResult parseToken(Token::Kind expectedToken, const Twine &message); diff --git a/mlir/lib/Parser/ParserState.h b/mlir/lib/Parser/ParserState.h --- a/mlir/lib/Parser/ParserState.h +++ b/mlir/lib/Parser/ParserState.h @@ -27,17 +27,6 @@ // A map from type alias identifier to Type. llvm::StringMap typeAliasDefinitions; - - /// A set of locations into the main parser memory buffer for each of the - /// active nested parsers. Given that some nested parsers, i.e. custom dialect - /// parsers, operate on a temporary memory buffer, this provides an anchor - /// point for emitting diagnostics. - SmallVector nestedParserLocs; - - /// The top-level lexer that contains the original memory buffer provided by - /// the user. This is used by nested parsers to get a properly encoded source - /// location. - Lexer *topLevelLexer = nullptr; }; //===----------------------------------------------------------------------===// @@ -50,17 +39,8 @@ ParserState(const llvm::SourceMgr &sourceMgr, MLIRContext *ctx, SymbolState &symbols, AsmParserState *asmState) : context(ctx), lex(sourceMgr, ctx), curToken(lex.lexToken()), - symbols(symbols), parserDepth(symbols.nestedParserLocs.size()), - asmState(asmState) { - // Set the top level lexer for the symbol state if one doesn't exist. - if (!symbols.topLevelLexer) - symbols.topLevelLexer = &lex; - } - ~ParserState() { - // Reset the top level lexer if it refers the lexer in our state. - if (symbols.topLevelLexer == &lex) - symbols.topLevelLexer = nullptr; - } + symbols(symbols), asmState(asmState) {} + ~ParserState() {} ParserState(const ParserState &) = delete; void operator=(const ParserState &) = delete; @@ -76,9 +56,6 @@ /// The current state for symbol parsing. SymbolState &symbols; - /// The depth of this parser in the nested parsing stack. - size_t parserDepth; - /// An optional pointer to a struct containing high level parser state to be /// populated during parsing. AsmParserState *asmState; diff --git a/mlir/test/Dialect/EmitC/types.mlir b/mlir/test/Dialect/EmitC/types.mlir --- a/mlir/test/Dialect/EmitC/types.mlir +++ b/mlir/test/Dialect/EmitC/types.mlir @@ -5,13 +5,13 @@ // CHECK-LABEL: func @opaque_types() { func @opaque_types() { // CHECK-NEXT: !emitc.opaque<"int"> - emitc.call "f"() {template_args = [!emitc<"opaque<\"int\">">]} : () -> () + emitc.call "f"() {template_args = [!emitc>]} : () -> () // CHECK-NEXT: !emitc.opaque<"byte"> - emitc.call "f"() {template_args = [!emitc<"opaque<\"byte\">">]} : () -> () + emitc.call "f"() {template_args = [!emitc>]} : () -> () // CHECK-NEXT: !emitc.opaque<"unsigned"> - emitc.call "f"() {template_args = [!emitc<"opaque<\"unsigned\">">]} : () -> () + emitc.call "f"() {template_args = [!emitc>]} : () -> () // CHECK-NEXT: !emitc.opaque<"status_t"> - emitc.call "f"() {template_args = [!emitc<"opaque<\"status_t\">">]} : () -> () + emitc.call "f"() {template_args = [!emitc>]} : () -> () // CHECK-NEXT: !emitc.opaque<"std::vector"> emitc.call "f"() {template_args = [!emitc.opaque<"std::vector">]} : () -> () diff --git a/mlir/test/Dialect/GPU/invalid.mlir b/mlir/test/Dialect/GPU/invalid.mlir --- a/mlir/test/Dialect/GPU/invalid.mlir +++ b/mlir/test/Dialect/GPU/invalid.mlir @@ -222,7 +222,7 @@ %res = "gpu.all_reduce"(%arg0) ({ ^bb(%lhs : f32, %rhs : f32): "gpu.yield"(%lhs) : (f32) -> () - }) {op = #gpu<"all_reduce_op add">} : (f32) -> (f32) + }) {op = #gpu} : (f32) -> (f32) return } @@ -302,7 +302,7 @@ func @shuffle_mismatching_type(%arg0 : f32, %arg1 : i32, %arg2 : i32) { // expected-error@+1 {{inferred type(s) 'f32', 'i1' are incompatible with return type(s) of operation 'i32', 'i1'}} - %shfl, %pred = "gpu.shuffle"(%arg0, %arg1, %arg2) { mode = #gpu<"shuffle_mode xor"> } : (f32, i32, i32) -> (i32, i1) + %shfl, %pred = "gpu.shuffle"(%arg0, %arg1, %arg2) { mode = #gpu } : (f32, i32, i32) -> (i32, i1) return } diff --git a/mlir/test/Dialect/OpenACC/ops.mlir b/mlir/test/Dialect/OpenACC/ops.mlir --- a/mlir/test/Dialect/OpenACC/ops.mlir +++ b/mlir/test/Dialect/OpenACC/ops.mlir @@ -376,9 +376,9 @@ acc.parallel private(%a: memref<10xf32>, %c: memref<10x10xf32>) firstprivate(%b: memref<10xf32>) { } acc.parallel { - } attributes {defaultAttr = #acc<"defaultvalue none">} + } attributes {defaultAttr = #acc} acc.parallel { - } attributes {defaultAttr = #acc<"defaultvalue present">} + } attributes {defaultAttr = #acc} acc.parallel { } attributes {asyncAttr} acc.parallel { @@ -441,9 +441,9 @@ // CHECK: acc.parallel private([[ARGA]]: memref<10xf32>, [[ARGC]]: memref<10x10xf32>) firstprivate([[ARGB]]: memref<10xf32>) { // CHECK-NEXT: } // CHECK: acc.parallel { -// CHECK-NEXT: } attributes {defaultAttr = #acc<"defaultvalue none">} +// CHECK-NEXT: } attributes {defaultAttr = #acc} // CHECK: acc.parallel { -// CHECK-NEXT: } attributes {defaultAttr = #acc<"defaultvalue present">} +// CHECK-NEXT: } attributes {defaultAttr = #acc} // CHECK: acc.parallel { // CHECK-NEXT: } attributes {asyncAttr} // CHECK: acc.parallel { @@ -482,11 +482,11 @@ acc.data copyin(%b: memref<10xf32>) copyout(%c: memref<10x10xf32>) present(%a: memref<10xf32>) { } acc.data present(%a : memref<10xf32>) { - } attributes { defaultAttr = #acc<"defaultvalue none"> } + } attributes { defaultAttr = #acc } acc.data present(%a : memref<10xf32>) { - } attributes { defaultAttr = #acc<"defaultvalue present"> } + } attributes { defaultAttr = #acc } acc.data { - } attributes { defaultAttr = #acc<"defaultvalue none"> } + } attributes { defaultAttr = #acc } return } @@ -519,11 +519,11 @@ // CHECK: acc.data copyin([[ARGB]] : memref<10xf32>) copyout([[ARGC]] : memref<10x10xf32>) present([[ARGA]] : memref<10xf32>) { // CHECK-NEXT: } // CHECK: acc.data present([[ARGA]] : memref<10xf32>) { -// CHECK-NEXT: } attributes {defaultAttr = #acc<"defaultvalue none">} +// CHECK-NEXT: } attributes {defaultAttr = #acc} // CHECK: acc.data present([[ARGA]] : memref<10xf32>) { -// CHECK-NEXT: } attributes {defaultAttr = #acc<"defaultvalue present">} +// CHECK-NEXT: } attributes {defaultAttr = #acc} // CHECK: acc.data { -// CHECK-NEXT: } attributes {defaultAttr = #acc<"defaultvalue none">} +// CHECK-NEXT: } attributes {defaultAttr = #acc} // ----- diff --git a/mlir/test/Dialect/OpenMP/ops.mlir b/mlir/test/Dialect/OpenMP/ops.mlir --- a/mlir/test/Dialect/OpenMP/ops.mlir +++ b/mlir/test/Dialect/OpenMP/ops.mlir @@ -59,7 +59,7 @@ // CHECK: omp.parallel num_threads(%{{.*}} : si32) private(%{{.*}} : memref) firstprivate(%{{.*}} : memref) shared(%{{.*}} : memref) copyin(%{{.*}} : memref) allocate(%{{.*}} : memref -> %{{.*}} : memref) "omp.parallel"(%num_threads, %data_var, %data_var, %data_var, %data_var, %data_var, %data_var) ({ omp.terminator - }) {operand_segment_sizes = dense<[0,1,1,1,1,1,1,1]>: vector<8xi32>, default_val = #omp<"clause_default defshared">} : (si32, memref, memref, memref, memref, memref, memref) -> () + }) {operand_segment_sizes = dense<[0,1,1,1,1,1,1,1]>: vector<8xi32>, default_val = #omp} : (si32, memref, memref, memref, memref, memref, memref) -> () // CHECK: omp.barrier omp.barrier @@ -77,7 +77,7 @@ }) {operand_segment_sizes = dense<[1,1,1,1,1,1,0,0]> : vector<8xi32>} : (i1, si32, memref, memref, memref, memref) -> () omp.terminator - }) {operand_segment_sizes = dense<[1,1,1,1,1,1,1,1]> : vector<8xi32>, proc_bind_val = #omp<"procbindkind spread">} : (i1, si32, memref, memref, memref, memref, memref, memref) -> () + }) {operand_segment_sizes = dense<[1,1,1,1,1,1,1,1]> : vector<8xi32>, proc_bind_val = #omp} : (i1, si32, memref, memref, memref, memref, memref, memref) -> () // test with multiple parameters for single variadic argument // CHECK: omp.parallel private(%{{.*}} : memref) firstprivate(%{{.*}} : memref, %{{.*}} : memref) shared(%{{.*}} : memref) copyin(%{{.*}} : memref) allocate(%{{.*}} : memref -> %{{.*}} : memref) @@ -160,28 +160,28 @@ "omp.wsloop" (%lb, %ub, %step, %data_var, %linear_var) ({ ^bb0(%iv: index): omp.yield - }) {operand_segment_sizes = dense<[1,1,1,0,0,0,1,1,0,0]> : vector<10xi32>, schedule_val = #omp<"schedulekind Static">} : + }) {operand_segment_sizes = dense<[1,1,1,0,0,0,1,1,0,0]> : vector<10xi32>, schedule_val = #omp} : (index, index, index, memref, i32) -> () // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) linear(%{{.*}} = %{{.*}} : memref, %{{.*}} = %{{.*}} : memref) schedule(static) "omp.wsloop" (%lb, %ub, %step, %data_var, %data_var, %linear_var, %linear_var) ({ ^bb0(%iv: index): omp.yield - }) {operand_segment_sizes = dense<[1,1,1,0,0,0,2,2,0,0]> : vector<10xi32>, schedule_val = #omp<"schedulekind Static">} : + }) {operand_segment_sizes = dense<[1,1,1,0,0,0,2,2,0,0]> : vector<10xi32>, schedule_val = #omp} : (index, index, index, memref, memref, i32, i32) -> () // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) private(%{{.*}} : memref) firstprivate(%{{.*}} : memref) lastprivate(%{{.*}} : memref) linear(%{{.*}} = %{{.*}} : memref) schedule(dynamic = %{{.*}}) collapse(3) ordered(2) "omp.wsloop" (%lb, %ub, %step, %data_var, %data_var, %data_var, %data_var, %linear_var, %chunk_var) ({ ^bb0(%iv: index): omp.yield - }) {operand_segment_sizes = dense<[1,1,1,1,1,1,1,1,0,1]> : vector<10xi32>, schedule_val = #omp<"schedulekind Dynamic">, collapse_val = 3, ordered_val = 2} : + }) {operand_segment_sizes = dense<[1,1,1,1,1,1,1,1,0,1]> : vector<10xi32>, schedule_val = #omp, collapse_val = 3, ordered_val = 2} : (index, index, index, memref, memref, memref, memref, i32, i32) -> () // CHECK: omp.wsloop (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}}) private(%{{.*}} : memref) schedule(auto) nowait "omp.wsloop" (%lb, %ub, %step, %data_var) ({ ^bb0(%iv: index): omp.yield - }) {operand_segment_sizes = dense<[1,1,1,1,0,0,0,0,0,0]> : vector<10xi32>, nowait, schedule_val = #omp<"schedulekind Auto">} : + }) {operand_segment_sizes = dense<[1,1,1,1,0,0,0,0,0,0]> : vector<10xi32>, nowait, schedule_val = #omp} : (index, index, index, memref) -> () return diff --git a/mlir/test/Dialect/Quant/parse-any-invalid.mlir b/mlir/test/Dialect/Quant/parse-any-invalid.mlir --- a/mlir/test/Dialect/Quant/parse-any-invalid.mlir +++ b/mlir/test/Dialect/Quant/parse-any-invalid.mlir @@ -7,8 +7,8 @@ // ----- // Unrecognized token: missing closing angle bracket -// expected-error@+1 {{expected '>'}} -!qalias = type !quant<"any"> +// expected-error@+1 {{unbalanced '<' character in pretty dialect name}} +!qalias = type !quant> // ----- // Unrecognized token: missing type colon diff --git a/mlir/test/Dialect/Quant/parse-calibrated-invalid.mlir b/mlir/test/Dialect/Quant/parse-calibrated-invalid.mlir --- a/mlir/test/Dialect/Quant/parse-calibrated-invalid.mlir +++ b/mlir/test/Dialect/Quant/parse-calibrated-invalid.mlir @@ -8,8 +8,8 @@ // ----- // Unrecognized token: missing closing angle bracket -// expected-error@+1 {{expected '>'}} -!qalias = type !quant<"calibrated"> +// expected-error@+1 {{unbalanced '<' character in pretty dialect name}} +!qalias = type !quant> // ----- // Unrecognized expressed type: integer type diff --git a/mlir/test/Dialect/Quant/parse-uniform-invalid.mlir b/mlir/test/Dialect/Quant/parse-uniform-invalid.mlir --- a/mlir/test/Dialect/Quant/parse-uniform-invalid.mlir +++ b/mlir/test/Dialect/Quant/parse-uniform-invalid.mlir @@ -22,8 +22,8 @@ // ----- // Unrecognized token: missing closing angle bracket -// expected-error@+1 {{expected '>'}} -!qalias = type !quant<"uniform"> +// expected-error@+1 {{unbalanced '<' character in pretty dialect name}} +!qalias = type !quant> // ----- // Unrecognized token: missing type colon diff --git a/mlir/test/IR/enum-attr-invalid.mlir b/mlir/test/IR/enum-attr-invalid.mlir --- a/mlir/test/IR/enum-attr-invalid.mlir +++ b/mlir/test/IR/enum-attr-invalid.mlir @@ -3,7 +3,7 @@ func @test_invalid_enum_case() -> () { // expected-error@+2 {{expected test::TestEnum to be one of: first, second, third}} // expected-error@+1 {{failed to parse TestEnumAttr}} - test.op_with_enum #test<"enum fourth"> + test.op_with_enum #test } // ----- diff --git a/mlir/test/IR/enum-attr-roundtrip.mlir b/mlir/test/IR/enum-attr-roundtrip.mlir --- a/mlir/test/IR/enum-attr-roundtrip.mlir +++ b/mlir/test/IR/enum-attr-roundtrip.mlir @@ -2,12 +2,12 @@ // CHECK-LABEL: @test_enum_attr_roundtrip func @test_enum_attr_roundtrip() -> () { - // CHECK: value = #test<"enum first"> - "test.op"() {value = #test<"enum first">} : () -> () - // CHECK: value = #test<"enum second"> - "test.op"() {value = #test<"enum second">} : () -> () - // CHECK: value = #test<"enum third"> - "test.op"() {value = #test<"enum third">} : () -> () + // CHECK: value = #test + "test.op"() {value = #test} : () -> () + // CHECK: value = #test + "test.op"() {value = #test} : () -> () + // CHECK: value = #test + "test.op"() {value = #test} : () -> () return } diff --git a/mlir/test/IR/invalid.mlir b/mlir/test/IR/invalid.mlir --- a/mlir/test/IR/invalid.mlir +++ b/mlir/test/IR/invalid.mlir @@ -840,19 +840,13 @@ // ----- -func @dialect_type_empty_namespace(!<"">) -> () { // expected-error {{invalid type identifier}} +func @dialect_type_empty_namespace(!<>) -> () { // expected-error {{invalid type identifier}} return } // ----- -func @dialect_type_no_string_type_data(!foo<>) -> () { // expected-error {{expected string literal data in dialect symbol}} - return -} - -// ----- - -func @dialect_type_missing_greater(!foo<"") -> () { // expected-error {{expected '>' in dialect symbol}} +func @dialect_type_missing_greater(!foo<) -> () { // expected-error {{unbalanced ')' character in pretty dialect name}} return } diff --git a/mlir/test/IR/parser.mlir b/mlir/test/IR/parser.mlir --- a/mlir/test/IR/parser.mlir +++ b/mlir/test/IR/parser.mlir @@ -784,10 +784,10 @@ // CHECK: "foof321"() {bar = sparse<> : tensor} : () -> () "foof321"(){bar = sparse<> : tensor} : () -> () -// CHECK: "foostr"() {bar = sparse<0, "foo"> : tensor<1x1x1x!unknown<"">>} : () -> () - "foostr"(){bar = sparse<0, "foo"> : tensor<1x1x1x!unknown<"">>} : () -> () -// CHECK: "foostr"() {bar = sparse<{{\[\[}}1, 1, 0], {{\[}}0, 1, 0], {{\[}}0, 0, 1]], {{\[}}"a", "b", "c"]> : tensor<2x2x2x!unknown<"">>} : () -> () - "foostr"(){bar = sparse<[[1, 1, 0], [0, 1, 0], [0, 0, 1]], ["a", "b", "c"]> : tensor<2x2x2x!unknown<"">>} : () -> () +// CHECK: "foostr"() {bar = sparse<0, "foo"> : tensor<1x1x1x!unknown<>>} : () -> () + "foostr"(){bar = sparse<0, "foo"> : tensor<1x1x1x!unknown<>>} : () -> () +// CHECK: "foostr"() {bar = sparse<{{\[\[}}1, 1, 0], {{\[}}0, 1, 0], {{\[}}0, 0, 1]], {{\[}}"a", "b", "c"]> : tensor<2x2x2x!unknown<>>} : () -> () + "foostr"(){bar = sparse<[[1, 1, 0], [0, 1, 0], [0, 0, 1]], ["a", "b", "c"]> : tensor<2x2x2x!unknown<>>} : () -> () return } @@ -813,16 +813,16 @@ return } -// CHECK-LABEL: func @unknown_dialect_type() -> !bar<""> { -func @unknown_dialect_type() -> !bar<""> { +// CHECK-LABEL: func @unknown_dialect_type() -> !bar<> { +func @unknown_dialect_type() -> !bar<> { // Unregistered dialect 'bar'. - // CHECK: "foo"() : () -> !bar<""> - %0 = "foo"() : () -> !bar<""> + // CHECK: "foo"() : () -> !bar<> + %0 = "foo"() : () -> !bar<> // CHECK: "foo"() : () -> !bar.baz - %1 = "foo"() : () -> !bar<"baz"> + %1 = "foo"() : () -> !bar - return %0 : !bar<""> + return %0 : !bar<> } // CHECK-LABEL: func @type_alias() -> i32 { @@ -947,10 +947,6 @@ // CHECK: "foo.unknown_op"() {foo = #foo.dialect} : () -> () "foo.unknown_op"() {foo = #foo.dialect} : () -> () - // Extraneous extra > character can't use the pretty syntax. - // CHECK: "foo.unknown_op"() {foo = #foo<"dialect>">} : () -> () - "foo.unknown_op"() {foo = #foo<"dialect>">} : () -> () - return } @@ -972,10 +968,6 @@ // CHECK: %{{.*}} = "foo.unknown_op"() : () -> !foo.dialect %4 = "foo.unknown_op"() : () -> !foo.dialect - // Extraneous extra > character can't use the pretty syntax. - // CHECK: %{{.*}} = "foo.unknown_op"() : () -> !foo<"dialect>"> - %5 = "foo.unknown_op"() : () -> !foo<"dialect>"> - return } @@ -1196,7 +1188,7 @@ // CHECK-LABEL: func private @parse_opaque_attr_escape func private @parse_opaque_attr_escape() { - // CHECK: value = #foo<"\22escaped\\\0A\22"> + // CHECK: value = #foo<"\"escaped\\\n\""> "foo.constant"() {value = #foo<"\"escaped\\\n\"">} : () -> () } diff --git a/mlir/test/Target/Cpp/types.mlir b/mlir/test/Target/Cpp/types.mlir --- a/mlir/test/Target/Cpp/types.mlir +++ b/mlir/test/Target/Cpp/types.mlir @@ -3,13 +3,13 @@ // CHECK-LABEL: void opaque_template_args() { func @opaque_template_args() { // CHECK-NEXT: f(); - emitc.call "f"() {template_args = [!emitc<"opaque<\"int\">">]} : () -> () + emitc.call "f"() {template_args = [!emitc>]} : () -> () // CHECK-NEXT: f(); - emitc.call "f"() {template_args = [!emitc<"opaque<\"byte\">">]} : () -> () + emitc.call "f"() {template_args = [!emitc>]} : () -> () // CHECK-NEXT: f(); - emitc.call "f"() {template_args = [!emitc<"opaque<\"unsigned\">">]} : () -> () + emitc.call "f"() {template_args = [!emitc>]} : () -> () // CHECK-NEXT: f(); - emitc.call "f"() {template_args = [!emitc<"opaque<\"status_t\">">]} : () -> () + emitc.call "f"() {template_args = [!emitc>]} : () -> () // CHECK-NEXT: f>(); emitc.call "f"() {template_args = [!emitc.opaque<"std::vector">]} : () -> () diff --git a/mlir/test/mlir-tblgen/attr-or-type-format-roundtrip.mlir b/mlir/test/mlir-tblgen/attr-or-type-format-roundtrip.mlir --- a/mlir/test/mlir-tblgen/attr-or-type-format-roundtrip.mlir +++ b/mlir/test/mlir-tblgen/attr-or-type-format-roundtrip.mlir @@ -1,16 +1,16 @@ // RUN: mlir-opt %s | mlir-opt | FileCheck %s // CHECK-LABEL: @test_roundtrip_parameter_parsers -// CHECK: !test.type_with_format<111, three = #test<"attr_ugly begin 5 : index end">, two = "foo"> +// CHECK: !test.type_with_format<111, three = #test, two = "foo"> // CHECK: !test.type_with_format<2147, three = "hi", two = "hi"> -func private @test_roundtrip_parameter_parsers(!test.type_with_format<111, three = #test<"attr_ugly begin 5 : index end">, two = "foo">) -> !test.type_with_format<2147, two = "hi", three = "hi"> +func private @test_roundtrip_parameter_parsers(!test.type_with_format<111, three = #test, two = "foo">) -> !test.type_with_format<2147, two = "hi", three = "hi"> attributes { // CHECK: #test.attr_with_format<3 : two = "hello", four = [1, 2, 3] : 42 : i64> attr0 = #test.attr_with_format<3 : two = "hello", four = [1, 2, 3] : 42 : i64>, // CHECK: #test.attr_with_format<5 : two = "a_string", four = [4, 5, 6, 7, 8] : 8 : i8> attr1 = #test.attr_with_format<5 : two = "a_string", four = [4, 5, 6, 7, 8] : 8 : i8>, - // CHECK: #test<"attr_ugly begin 5 : index end"> - attr2 = #test<"attr_ugly begin 5 : index end">, + // CHECK: #test + attr2 = #test, // CHECK: #test.attr_params<42, 24> attr3 = #test.attr_params<42, 24>, // CHECK: #test.attr_with_type> diff --git a/mlir/test/mlir-tblgen/attr-or-type-format.mlir b/mlir/test/mlir-tblgen/attr-or-type-format.mlir --- a/mlir/test/mlir-tblgen/attr-or-type-format.mlir +++ b/mlir/test/mlir-tblgen/attr-or-type-format.mlir @@ -1,22 +1,22 @@ // RUN: mlir-opt --split-input-file %s --verify-diagnostics func private @test_ugly_attr_cannot_be_pretty() -> () attributes { - // expected-error@+1 {{expected 'begin'}} - attr = #test.attr_ugly + // expected-error@below {{expected 'begin'}} + attr = #test.attr_ugly, } // ----- func private @test_ugly_attr_no_mnemonic() -> () attributes { // expected-error@+1 {{expected valid keyword}} - attr = #test<""> + attr = #test<> } // ----- func private @test_ugly_attr_parser_dispatch() -> () attributes { // expected-error@+1 {{expected 'begin'}} - attr = #test<"attr_ugly"> + attr = #test } // ----- @@ -24,21 +24,21 @@ func private @test_ugly_attr_missing_parameter() -> () attributes { // expected-error@+2 {{failed to parse TestAttrUgly parameter 'attr'}} // expected-error@+1 {{expected non-function type}} - attr = #test<"attr_ugly begin"> + attr = #test } // ----- func private @test_ugly_attr_missing_literal() -> () attributes { // expected-error@+1 {{expected 'end'}} - attr = #test<"attr_ugly begin \"string_attr\""> + attr = #test } // ----- func private @test_pretty_attr_expects_less() -> () attributes { // expected-error@+1 {{expected '<'}} - attr = #test.attr_with_format + attr = #test.attr_with_format, } // ----- @@ -55,7 +55,7 @@ // Test parameter parser failure is propagated // expected-error@+2 {{expected integer value}} // expected-error@+1 {{failed to parse TestAttrWithFormat parameter 'one'}} - attr = #test.attr_with_format<"hi"> + attr = #test.attr_with_format } // ----- @@ -105,7 +105,7 @@ // ----- // expected-error@+1 {{expected '<'}} -func private @test_invalid_type() -> !test.type_with_format +func private @test_invalid_type() -> !test.type_with_format, // ----- diff --git a/mlir/test/mlir-tblgen/testdialect-attrdefs.mlir b/mlir/test/mlir-tblgen/testdialect-attrdefs.mlir --- a/mlir/test/mlir-tblgen/testdialect-attrdefs.mlir +++ b/mlir/test/mlir-tblgen/testdialect-attrdefs.mlir @@ -4,11 +4,11 @@ // CHECK-SAME: #test.cmpnd_a<1, !test.smpla, [5, 6]> func private @compoundA() attributes {foo = #test.cmpnd_a<1, !test.smpla, [5, 6]>} -// CHECK: test.result_has_same_type_as_attr #test<"attr_with_self_type_param i32"> -> i32 -%a = test.result_has_same_type_as_attr #test<"attr_with_self_type_param i32"> -> i32 +// CHECK: test.result_has_same_type_as_attr #test -> i32 +%a = test.result_has_same_type_as_attr #test -> i32 -// CHECK: test.result_has_same_type_as_attr #test<"attr_with_type_builder 10 : i16"> -> i16 -%b = test.result_has_same_type_as_attr #test<"attr_with_type_builder 10 : i16"> -> i16 +// CHECK: test.result_has_same_type_as_attr #test -> i16 +%b = test.result_has_same_type_as_attr #test -> i16 // CHECK-LABEL: @qualifiedAttr() // CHECK-SAME: #test.cmpnd_nested_outer_qual>>