[all-commits] [llvm/llvm-project] 844706: [MLIR] Add `KeywordOrString` handling to AsmParser

Andrew Young via All-commits all-commits at lists.llvm.org
Fri Oct 15 00:08:51 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 844706701ea36ea78ffab8398541bccf967ae40c
      https://github.com/llvm/llvm-project/commit/844706701ea36ea78ffab8398541bccf967ae40c
  Author: Andrew Young <youngar17 at gmail.com>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M mlir/include/mlir/IR/OpImplementation.h
    M mlir/lib/IR/AsmPrinter.cpp
    M mlir/lib/Parser/AsmParserImpl.h

  Log Message:
  -----------
  [MLIR] Add `KeywordOrString` handling to AsmParser

This adds a new parser and printer for text which may be a keyword or a
string. When printing, it will attempt to print the text as a keyword,
but if it has any special or non-printable characters, it will be
printed as an escaped string.  When parsing, it will parse either a
valid keyword or a potentially escaped string. The printer allows for an
empty string, in which case it prints `""`.

This new function is used for printing the name in NamedAttributes, and
for printing the symbol name after the `@`. In CIRCT we are using this
to print module port names, which are conceptually similar to named
function arguments.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D111683




More information about the All-commits mailing list