[mlir][flang] Do not prevent integer types from being parsed as MLIR keywords
authorJean Perier <jperier@nvidia.com>
Fri, 3 Sep 2021 06:16:52 +0000 (08:16 +0200)
committerJean Perier <jperier@nvidia.com>
Fri, 3 Sep 2021 06:20:49 +0000 (08:20 +0200)
commit49af2a62758a9a526ce446111acaa2cbd5fd2a6e
treee157373978817e9c9959546b33f01972a7cebdbd
parent084d8bebd0fcad80b0b2890e427e804ca42431d8
[mlir][flang] Do not prevent integer types from being parsed as MLIR keywords

DialectAsmParser::parseKeyword is rejecting `'i' digit+` while it is
a valid identifier according to mlir/docs/LangRef.md.

Integer types actually used to be TOK_KEYWORD a while back before the
change: https://github.com/llvm/llvm-project/commit/6af866c58d21813fb243906611d02bb2a8ffa43a.

This patch Modifies `isCurrentTokenAKeyword` to return true for tokens that
match integer types too.

The motivation for this change is the parsing of `!fir.type<{` `component-name: component-type,`+ `}>`
type in FIR that represent Fortran derived types. The component-names are
parsed as keywords, and can very well be i32 or any ixxx (which are
valid Fortran derived type component names).

The Quant dialect type parser had to be modified since it relied on `iw` not
being parsed as keywords.

Differential Revision: https://reviews.llvm.org/D108913
flang/test/Fir/fir-types.fir
mlir/lib/Dialect/Quant/IR/TypeParser.cpp
mlir/lib/Parser/DialectSymbolParser.cpp
mlir/test/mlir-tblgen/types.mlir