Files
clang-p2996/mlir/utils/tree-sitter-mlir/dialect/bufferization.js
Ramkumar Ramachandra 10f8be19e7 tree-sitter-mlir: add a more complete grammar
Contribute a grammar, along with associated tests, from the upstream
project maintained at https://github.com/artagnon/tree-sitter-mlir. The
new grammar includes several fixes, and successfully parses 60-80% of
MLIR tests in the Arith, Math, ControlFlow, SCF, Tensor, Affine, and
Linalg dialects.

Differential Revision: https://reviews.llvm.org/D144408
2023-06-05 19:11:06 +01:00

33 lines
1.8 KiB
JavaScript

'use strict';
module.exports = {
bufferization_dialect : $ => choice(
seq('bufferization.alloc_tensor',
field('in', $._value_use_list_parens),
field('copy', optional(seq(token('copy'), '(',
$.value_use, ')'))),
field('size_hint',
optional(seq(token('size_hint'), '=',
$.value_use))),
field('attributes', optional($.attribute)),
field('return', $._type_annotation)),
// operation ::= `bufferization.to_memref` $tensor
// attr-dict `:` type($memref)
seq('bufferization.to_memref',
field('tensor', $.value_use),
field('attributes', optional($.attribute)),
field('return', $._type_annotation)),
// operation ::= `bufferization.to_tensor` $memref
// (`restrict` $restrict^)?
// (`writable` $writable^)? attr-dict
// `:` type($memref)
seq('bufferization.to_tensor',
field('memref', $.value_use),
field('restrict', optional($.restrict_attr)),
field('writable', optional($.writable_attr)),
field('attributes', optional($.attribute)),
field('return', $._type_annotation)))
}