@felixtensor/tree-sitter-mlir 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/grammar.js +37 -1
- package/package.json +4 -3
- package/prebuilds/darwin-arm64/@felixtensor+tree-sitter-mlir.node +0 -0
- package/prebuilds/darwin-x64/@felixtensor+tree-sitter-mlir.node +0 -0
- package/prebuilds/linux-arm64/@felixtensor+tree-sitter-mlir.node +0 -0
- package/prebuilds/linux-x64/@felixtensor+tree-sitter-mlir.node +0 -0
- package/prebuilds/win32-arm64/@felixtensor+tree-sitter-mlir.node +0 -0
- package/prebuilds/win32-x64/@felixtensor+tree-sitter-mlir.node +0 -0
- package/src/grammar.json +156 -1
- package/src/node-types.json +8 -56
- package/src/parser.c +47312 -50065
- package/tree-sitter-mlir.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -47,7 +47,17 @@ export default grammar({
|
|
|
47
47
|
$.external_resources,
|
|
48
48
|
),
|
|
49
49
|
external_resources: ($) =>
|
|
50
|
-
seq("{-#", repeat($.
|
|
50
|
+
seq("{-#", repeat($._external_resource_content), "#-}"),
|
|
51
|
+
_external_resource_content: ($) =>
|
|
52
|
+
choice(
|
|
53
|
+
$.string_literal,
|
|
54
|
+
// File metadata is YAML-like, not a dialect pretty body. Keep it loose
|
|
55
|
+
// so resource keys such as dense_resource_test_2xi32 are not split by
|
|
56
|
+
// dimension-list/type rules.
|
|
57
|
+
token(prec(-1, /[^#"\/]+/)),
|
|
58
|
+
"#",
|
|
59
|
+
"/",
|
|
60
|
+
),
|
|
51
61
|
|
|
52
62
|
// =========================================================================
|
|
53
63
|
// Common syntax (lang-ref)
|
|
@@ -278,6 +288,7 @@ export default grammar({
|
|
|
278
288
|
prec(2, $.func_operation),
|
|
279
289
|
prec(2, $.module_operation),
|
|
280
290
|
prec(2, $._affine_for_operation),
|
|
291
|
+
$._pdl_interp_record_match_operation,
|
|
281
292
|
$._generic_custom_operation_with_location_attr_dict,
|
|
282
293
|
$._generic_custom_operation,
|
|
283
294
|
),
|
|
@@ -350,6 +361,25 @@ export default grammar({
|
|
|
350
361
|
),
|
|
351
362
|
),
|
|
352
363
|
|
|
364
|
+
_pdl_interp_record_match_operation: ($) =>
|
|
365
|
+
prec.dynamic(
|
|
366
|
+
-1,
|
|
367
|
+
prec.right(
|
|
368
|
+
seq(
|
|
369
|
+
field(
|
|
370
|
+
"name",
|
|
371
|
+
alias(
|
|
372
|
+
token(prec(20, "pdl_interp.record_match")),
|
|
373
|
+
$.custom_op_name,
|
|
374
|
+
),
|
|
375
|
+
),
|
|
376
|
+
repeat($._custom_body_element),
|
|
377
|
+
$._custom_body_location_list,
|
|
378
|
+
repeat($._custom_body_element),
|
|
379
|
+
),
|
|
380
|
+
),
|
|
381
|
+
),
|
|
382
|
+
|
|
353
383
|
// Tier 2: Generic custom operation — dialect.op_name + structural body
|
|
354
384
|
// Negative dynamic precedence makes the parser prefer ending the body
|
|
355
385
|
// and starting a new operation (with _op_result_list) over extending
|
|
@@ -434,10 +464,12 @@ export default grammar({
|
|
|
434
464
|
$.region, // { ... } (regions with operations)
|
|
435
465
|
$._custom_body_value_group, // {%v : type, ...}
|
|
436
466
|
$._custom_body_ssa_dict, // {"attr" = %value, ...} / options with SSA values
|
|
467
|
+
$._custom_body_module_symbol_arg, // module(@sym) kernel attr
|
|
437
468
|
$._custom_body_sparse_operand, // sparse(%idx : type)
|
|
438
469
|
$._custom_body_paren, // ( ... )
|
|
439
470
|
$._custom_body_bracket, // [ ... ]
|
|
440
471
|
$._custom_body_angle_group, // < ... >
|
|
472
|
+
$.variadic, // custom assembly ellipsis marker
|
|
441
473
|
$._literal, // 42, 3.14, "string", true, dense<...>
|
|
442
474
|
"array", // property names may collide with array<...>
|
|
443
475
|
"vector", // OpenACC keyword may collide with vector<...>
|
|
@@ -513,8 +545,12 @@ export default grammar({
|
|
|
513
545
|
_custom_body_ssa_value_array: ($) =>
|
|
514
546
|
seq("[", $.value_use, repeat(seq(",", $.value_use)), "]"),
|
|
515
547
|
_custom_body_successor_marker: ($) => seq(">", $.successor),
|
|
548
|
+
_custom_body_module_symbol_arg: ($) =>
|
|
549
|
+
seq(token(prec(20, "module(")), $.symbol_ref_id, ")"),
|
|
516
550
|
_custom_body_sparse_operand: ($) =>
|
|
517
551
|
seq($._sparse_keyword, $._custom_body_paren),
|
|
552
|
+
_custom_body_location_list: ($) =>
|
|
553
|
+
seq(token("loc"), "(", "[", optional($._value_use_list), "]", ")"),
|
|
518
554
|
_custom_body_angle_group: ($) =>
|
|
519
555
|
seq("<", repeat($._nested_custom_body_element), ">"),
|
|
520
556
|
// "Mapped-from" arrow used by OpenMP loop-transform ops, e.g.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@felixtensor/tree-sitter-mlir",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "MLIR grammar for tree-sitter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -55,9 +55,10 @@
|
|
|
55
55
|
"compile": "tree-sitter generate",
|
|
56
56
|
"update-tests": "tree-sitter test --update",
|
|
57
57
|
"test": "tree-sitter test",
|
|
58
|
+
"test:bench": "node --test test/*.test.mjs",
|
|
58
59
|
"test:bindings": "node --test bindings/node/*_test.js",
|
|
59
|
-
"test:examples": "tree-sitter parse --quiet --stat examples/**/*.mlir",
|
|
60
|
-
"test:all": "npm run test && npm run test:examples",
|
|
60
|
+
"test:examples": "tree-sitter parse --quiet --stat \"examples/**/*.mlir\"",
|
|
61
|
+
"test:all": "npm run test && npm run test:bench && npm run test:examples",
|
|
61
62
|
"bench": "node bench.mjs",
|
|
62
63
|
"prebuildify": "prebuildify --napi --strip"
|
|
63
64
|
},
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/grammar.json
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"type": "REPEAT",
|
|
42
42
|
"content": {
|
|
43
43
|
"type": "SYMBOL",
|
|
44
|
-
"name": "
|
|
44
|
+
"name": "_external_resource_content"
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
{
|
|
@@ -50,6 +50,34 @@
|
|
|
50
50
|
}
|
|
51
51
|
]
|
|
52
52
|
},
|
|
53
|
+
"_external_resource_content": {
|
|
54
|
+
"type": "CHOICE",
|
|
55
|
+
"members": [
|
|
56
|
+
{
|
|
57
|
+
"type": "SYMBOL",
|
|
58
|
+
"name": "string_literal"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"type": "TOKEN",
|
|
62
|
+
"content": {
|
|
63
|
+
"type": "PREC",
|
|
64
|
+
"value": -1,
|
|
65
|
+
"content": {
|
|
66
|
+
"type": "PATTERN",
|
|
67
|
+
"value": "[^#\"\\/]+"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"type": "STRING",
|
|
73
|
+
"value": "#"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"type": "STRING",
|
|
77
|
+
"value": "/"
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
},
|
|
53
81
|
"_digit": {
|
|
54
82
|
"type": "PATTERN",
|
|
55
83
|
"value": "[0-9]"
|
|
@@ -1551,6 +1579,10 @@
|
|
|
1551
1579
|
"name": "_affine_for_operation"
|
|
1552
1580
|
}
|
|
1553
1581
|
},
|
|
1582
|
+
{
|
|
1583
|
+
"type": "SYMBOL",
|
|
1584
|
+
"name": "_pdl_interp_record_match_operation"
|
|
1585
|
+
},
|
|
1554
1586
|
{
|
|
1555
1587
|
"type": "SYMBOL",
|
|
1556
1588
|
"name": "_generic_custom_operation_with_location_attr_dict"
|
|
@@ -1882,6 +1914,57 @@
|
|
|
1882
1914
|
]
|
|
1883
1915
|
}
|
|
1884
1916
|
},
|
|
1917
|
+
"_pdl_interp_record_match_operation": {
|
|
1918
|
+
"type": "PREC_DYNAMIC",
|
|
1919
|
+
"value": -1,
|
|
1920
|
+
"content": {
|
|
1921
|
+
"type": "PREC_RIGHT",
|
|
1922
|
+
"value": 0,
|
|
1923
|
+
"content": {
|
|
1924
|
+
"type": "SEQ",
|
|
1925
|
+
"members": [
|
|
1926
|
+
{
|
|
1927
|
+
"type": "FIELD",
|
|
1928
|
+
"name": "name",
|
|
1929
|
+
"content": {
|
|
1930
|
+
"type": "ALIAS",
|
|
1931
|
+
"content": {
|
|
1932
|
+
"type": "TOKEN",
|
|
1933
|
+
"content": {
|
|
1934
|
+
"type": "PREC",
|
|
1935
|
+
"value": 20,
|
|
1936
|
+
"content": {
|
|
1937
|
+
"type": "STRING",
|
|
1938
|
+
"value": "pdl_interp.record_match"
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
},
|
|
1942
|
+
"named": true,
|
|
1943
|
+
"value": "custom_op_name"
|
|
1944
|
+
}
|
|
1945
|
+
},
|
|
1946
|
+
{
|
|
1947
|
+
"type": "REPEAT",
|
|
1948
|
+
"content": {
|
|
1949
|
+
"type": "SYMBOL",
|
|
1950
|
+
"name": "_custom_body_element"
|
|
1951
|
+
}
|
|
1952
|
+
},
|
|
1953
|
+
{
|
|
1954
|
+
"type": "SYMBOL",
|
|
1955
|
+
"name": "_custom_body_location_list"
|
|
1956
|
+
},
|
|
1957
|
+
{
|
|
1958
|
+
"type": "REPEAT",
|
|
1959
|
+
"content": {
|
|
1960
|
+
"type": "SYMBOL",
|
|
1961
|
+
"name": "_custom_body_element"
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
]
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
},
|
|
1885
1968
|
"_generic_custom_operation": {
|
|
1886
1969
|
"type": "PREC_DYNAMIC",
|
|
1887
1970
|
"value": -1,
|
|
@@ -2102,6 +2185,10 @@
|
|
|
2102
2185
|
"type": "SYMBOL",
|
|
2103
2186
|
"name": "_custom_body_ssa_dict"
|
|
2104
2187
|
},
|
|
2188
|
+
{
|
|
2189
|
+
"type": "SYMBOL",
|
|
2190
|
+
"name": "_custom_body_module_symbol_arg"
|
|
2191
|
+
},
|
|
2105
2192
|
{
|
|
2106
2193
|
"type": "SYMBOL",
|
|
2107
2194
|
"name": "_custom_body_sparse_operand"
|
|
@@ -2118,6 +2205,10 @@
|
|
|
2118
2205
|
"type": "SYMBOL",
|
|
2119
2206
|
"name": "_custom_body_angle_group"
|
|
2120
2207
|
},
|
|
2208
|
+
{
|
|
2209
|
+
"type": "SYMBOL",
|
|
2210
|
+
"name": "variadic"
|
|
2211
|
+
},
|
|
2121
2212
|
{
|
|
2122
2213
|
"type": "SYMBOL",
|
|
2123
2214
|
"name": "_literal"
|
|
@@ -2549,6 +2640,30 @@
|
|
|
2549
2640
|
}
|
|
2550
2641
|
]
|
|
2551
2642
|
},
|
|
2643
|
+
"_custom_body_module_symbol_arg": {
|
|
2644
|
+
"type": "SEQ",
|
|
2645
|
+
"members": [
|
|
2646
|
+
{
|
|
2647
|
+
"type": "TOKEN",
|
|
2648
|
+
"content": {
|
|
2649
|
+
"type": "PREC",
|
|
2650
|
+
"value": 20,
|
|
2651
|
+
"content": {
|
|
2652
|
+
"type": "STRING",
|
|
2653
|
+
"value": "module("
|
|
2654
|
+
}
|
|
2655
|
+
}
|
|
2656
|
+
},
|
|
2657
|
+
{
|
|
2658
|
+
"type": "SYMBOL",
|
|
2659
|
+
"name": "symbol_ref_id"
|
|
2660
|
+
},
|
|
2661
|
+
{
|
|
2662
|
+
"type": "STRING",
|
|
2663
|
+
"value": ")"
|
|
2664
|
+
}
|
|
2665
|
+
]
|
|
2666
|
+
},
|
|
2552
2667
|
"_custom_body_sparse_operand": {
|
|
2553
2668
|
"type": "SEQ",
|
|
2554
2669
|
"members": [
|
|
@@ -2562,6 +2677,46 @@
|
|
|
2562
2677
|
}
|
|
2563
2678
|
]
|
|
2564
2679
|
},
|
|
2680
|
+
"_custom_body_location_list": {
|
|
2681
|
+
"type": "SEQ",
|
|
2682
|
+
"members": [
|
|
2683
|
+
{
|
|
2684
|
+
"type": "TOKEN",
|
|
2685
|
+
"content": {
|
|
2686
|
+
"type": "STRING",
|
|
2687
|
+
"value": "loc"
|
|
2688
|
+
}
|
|
2689
|
+
},
|
|
2690
|
+
{
|
|
2691
|
+
"type": "STRING",
|
|
2692
|
+
"value": "("
|
|
2693
|
+
},
|
|
2694
|
+
{
|
|
2695
|
+
"type": "STRING",
|
|
2696
|
+
"value": "["
|
|
2697
|
+
},
|
|
2698
|
+
{
|
|
2699
|
+
"type": "CHOICE",
|
|
2700
|
+
"members": [
|
|
2701
|
+
{
|
|
2702
|
+
"type": "SYMBOL",
|
|
2703
|
+
"name": "_value_use_list"
|
|
2704
|
+
},
|
|
2705
|
+
{
|
|
2706
|
+
"type": "BLANK"
|
|
2707
|
+
}
|
|
2708
|
+
]
|
|
2709
|
+
},
|
|
2710
|
+
{
|
|
2711
|
+
"type": "STRING",
|
|
2712
|
+
"value": "]"
|
|
2713
|
+
},
|
|
2714
|
+
{
|
|
2715
|
+
"type": "STRING",
|
|
2716
|
+
"value": ")"
|
|
2717
|
+
}
|
|
2718
|
+
]
|
|
2719
|
+
},
|
|
2565
2720
|
"_custom_body_angle_group": {
|
|
2566
2721
|
"type": "SEQ",
|
|
2567
2722
|
"members": [
|
package/src/node-types.json
CHANGED
|
@@ -669,6 +669,10 @@
|
|
|
669
669
|
{
|
|
670
670
|
"type": "value_use",
|
|
671
671
|
"named": true
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
"type": "variadic",
|
|
675
|
+
"named": true
|
|
672
676
|
}
|
|
673
677
|
]
|
|
674
678
|
}
|
|
@@ -855,65 +859,9 @@
|
|
|
855
859
|
"multiple": true,
|
|
856
860
|
"required": false,
|
|
857
861
|
"types": [
|
|
858
|
-
{
|
|
859
|
-
"type": "array_literal",
|
|
860
|
-
"named": true
|
|
861
|
-
},
|
|
862
|
-
{
|
|
863
|
-
"type": "attribute",
|
|
864
|
-
"named": true
|
|
865
|
-
},
|
|
866
|
-
{
|
|
867
|
-
"type": "attribute_alias",
|
|
868
|
-
"named": true
|
|
869
|
-
},
|
|
870
|
-
{
|
|
871
|
-
"type": "bare_id",
|
|
872
|
-
"named": true
|
|
873
|
-
},
|
|
874
|
-
{
|
|
875
|
-
"type": "bool_literal",
|
|
876
|
-
"named": true
|
|
877
|
-
},
|
|
878
|
-
{
|
|
879
|
-
"type": "dialect_attribute",
|
|
880
|
-
"named": true
|
|
881
|
-
},
|
|
882
|
-
{
|
|
883
|
-
"type": "dialect_dim_list",
|
|
884
|
-
"named": true
|
|
885
|
-
},
|
|
886
|
-
{
|
|
887
|
-
"type": "float_literal",
|
|
888
|
-
"named": true
|
|
889
|
-
},
|
|
890
|
-
{
|
|
891
|
-
"type": "integer_literal",
|
|
892
|
-
"named": true
|
|
893
|
-
},
|
|
894
|
-
{
|
|
895
|
-
"type": "pretty_dialect_item_body",
|
|
896
|
-
"named": true
|
|
897
|
-
},
|
|
898
862
|
{
|
|
899
863
|
"type": "string_literal",
|
|
900
864
|
"named": true
|
|
901
|
-
},
|
|
902
|
-
{
|
|
903
|
-
"type": "tensor_literal",
|
|
904
|
-
"named": true
|
|
905
|
-
},
|
|
906
|
-
{
|
|
907
|
-
"type": "type",
|
|
908
|
-
"named": true
|
|
909
|
-
},
|
|
910
|
-
{
|
|
911
|
-
"type": "uninitialized_literal",
|
|
912
|
-
"named": true
|
|
913
|
-
},
|
|
914
|
-
{
|
|
915
|
-
"type": "unit_literal",
|
|
916
|
-
"named": true
|
|
917
865
|
}
|
|
918
866
|
]
|
|
919
867
|
}
|
|
@@ -2238,6 +2186,10 @@
|
|
|
2238
2186
|
"type": "module",
|
|
2239
2187
|
"named": false
|
|
2240
2188
|
},
|
|
2189
|
+
{
|
|
2190
|
+
"type": "module(",
|
|
2191
|
+
"named": false
|
|
2192
|
+
},
|
|
2241
2193
|
{
|
|
2242
2194
|
"type": "n_out_of_m",
|
|
2243
2195
|
"named": false
|