diff options
author | Soren Lassen <sorenlassen@gmail.com> | 2025-02-04 12:49:15 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-04 13:49:15 -0700 |
commit | c8ca486573adc1affcedee02c6eedc49db3e9245 (patch) | |
tree | 89617f5f503a1606058e9babb8ea5dd43ac5320b /flang/lib/Frontend/CompilerInvocation.cpp | |
parent | d13940ee263ff50b7a71e21424913cc0266bf9d4 (diff) | |
download | llvm-c8ca486573adc1affcedee02c6eedc49db3e9245.zip llvm-c8ca486573adc1affcedee02c6eedc49db3e9245.tar.gz llvm-c8ca486573adc1affcedee02c6eedc49db3e9245.tar.bz2 |
[MLIR] print/parse resource handle key quoted and escaped (#119746)
resource keys have the problem that you can’t parse them from mlir
assembly if they have special or non-printable characters, but nothing
prevents you from specifying such a key when you create e.g. a
DenseResourceElementsAttr, and it works fine in other ways, including
bytecode emission and parsing
this PR solves the parsing by quoting and escaping keys with special or
non-printable characters in mlir assembly, in the same way as symbols,
e.g.:
```
module attributes {
fst = dense_resource<resource_fst> : tensor<2xf16>,
snd = dense_resource<"resource\09snd"> : tensor<2xf16>
} {}
{-#
dialect_resources: {
builtin: {
resource_fst: "0x0200000001000200",
"resource\09snd": "0x0200000008000900"
}
}
#-}
```
by not quoting keys without special or non-printable characters, the
change is effectively backwards compatible
the change is tested by:
1. adding a test with a dense resource handle key with special
characters to `dense-resource-elements-attr.mlir`
2. adding special and unprintable characters to some resource keys in
the existing lit tests `pretty-resources-print.mlir` and
`mlir/test/Bytecode/resources.mlir`
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions