-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Description
(.venv) vscode ➜ /workspaces/project (main) $ python3 -m project ./test/fibonacci/fibonacci.scf.mlir
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/workspaces/project/project/__main__.py", line 78, in <module>
main(args.file)
File "/workspaces/project/project/__main__.py", line 28, in main
tree = mlir.parse_path(file)
^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/project/.venv/lib/python3.12/site-packages/mlir/parser.py", line 159, in parse_path
return parse_file(fp, dialects)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/project/.venv/lib/python3.12/site-packages/mlir/parser.py", line 146, in parse_file
return parse_string(file.read(), dialects)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/project/.venv/lib/python3.12/site-packages/mlir/parser.py", line 133, in parse_string
return parser.parse(code)
^^^^^^^^^^^^^^^^^^
File "/workspaces/project/.venv/lib/python3.12/site-packages/mlir/parser.py", line 93, in parse
tree = self.parser.parse(code)
^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/project/.venv/lib/python3.12/site-packages/lark/lark.py", line 655, in parse
return self.parser.parse(text, start=start, on_error=on_error)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/project/.venv/lib/python3.12/site-packages/lark/parser_frontends.py", line 104, in parse
return self.parser.parse(stream, chosen_start, **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/project/.venv/lib/python3.12/site-packages/lark/parsers/earley.py", line 280, in parse
to_scan = self._parse(lexer, columns, to_scan, start_symbol)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/project/.venv/lib/python3.12/site-packages/lark/parsers/xearley.py", line 152, in _parse
to_scan = scan(i, to_scan)
^^^^^^^^^^^^^^^^
File "/workspaces/project/.venv/lib/python3.12/site-packages/lark/parsers/xearley.py", line 125, in scan
raise UnexpectedCharacters(stream, i, text_line, text_column, {item.expect.name for item in to_scan},
lark.exceptions.UnexpectedCharacters: No terminal matches '-' in the current parser context, at line 5 col 36
%c_minus1_i64 = arith.constant -1 : i64
^
Expected one of:
* PERCENT
* __ANON_8
* __ANON_7
* COLON
* DOT
* __ANON_4
* __ANON_1
* TRUE
* __ANON_0
* FALSE
* __ANON_9
* ESCAPED_STRING
* __ANON_10
module {
func.func @generate_fibonacci(%arg0: i64, %arg1: memref<?xi32>) attributes {llvm.linkage = #llvm.linkage<external>} {
%c0 = arith.constant 0 : index
%c1 = arith.constant 1 : index
%c_minus1_i64 = arith.constant -1 : i64
%c_minus2_i64 = arith.constant -2 : i64
%true = arith.constant true
%c1_i64 = arith.constant 1 : i64
%c0_i64 = arith.constant 0 : i64
%0 = arith.index_cast %arg0 : i64 to index
scf.for %arg2 = %c0 to %0 step %c1 {
%1 = arith.index_cast %arg2 : index to i64
%2 = arith.cmpi eq, %1, %c0_i64 : i64
%3 = scf.if %2 -> (i1) {
scf.yield %true : i1
} else {
%4 = arith.cmpi eq, %1, %c1_i64 : i64
scf.yield %4 : i1
}
scf.if %3 {
%4 = arith.trunci %1 : i64 to i32
memref.store %4, %arg1[%arg2] : memref<?xi32>
} else {
%4 = arith.addi %1, %c_minus1_i64 : i64
%5 = arith.index_cast %4 : i64 to index
%6 = memref.load %arg1[%5] : memref<?xi32>
%7 = arith.addi %1, %c_minus2_i64 : i64
%8 = arith.index_cast %7 : i64 to index
%9 = memref.load %arg1[%8] : memref<?xi32>
%10 = arith.addi %6, %9 : i32
memref.store %10, %arg1[%arg2] : memref<?xi32>
}
}
return
}
func.func @main(%arg0: i32, %arg1: memref<?xmemref<?xi8>>) -> i32 attributes {llvm.linkage = #llvm.linkage<external>} {
%c32 = arith.constant 32 : index
%c0_i64 = arith.constant 0 : i64
%c1_i64 = arith.constant 1 : i64
%true = arith.constant true
%c_minus2_i64 = arith.constant -2 : i64
%c_minus1_i64 = arith.constant -1 : i64
%c1 = arith.constant 1 : index
%c0 = arith.constant 0 : index
%alloca = memref.alloca() : memref<32xi32>
scf.for %arg2 = %c0 to %c32 step %c1 {
%1 = arith.index_cast %arg2 : index to i64
%2 = arith.cmpi eq, %1, %c0_i64 : i64
%3 = scf.if %2 -> (i1) {
scf.yield %true : i1
} else {
%4 = arith.cmpi eq, %1, %c1_i64 : i64
scf.yield %4 : i1
}
scf.if %3 {
%4 = arith.trunci %1 : i64 to i32
memref.store %4, %alloca[%arg2] : memref<32xi32>
} else {
%4 = arith.addi %1, %c_minus1_i64 : i64
%5 = arith.index_cast %4 : i64 to index
%6 = memref.load %alloca[%5] : memref<32xi32>
%7 = arith.addi %1, %c_minus2_i64 : i64
%8 = arith.index_cast %7 : i64 to index
%9 = memref.load %alloca[%8] : memref<32xi32>
%10 = arith.addi %6, %9 : i32
memref.store %10, %alloca[%arg2] : memref<32xi32>
}
}
%c31 = arith.constant 31 : index
%0 = memref.load %alloca[%c31] : memref<32xi32>
return %0 : i32
}
func.func @jit_main() -> i32 attributes {llvm.linkage = #llvm.linkage<external>} {
%c32 = arith.constant 32 : index
%c0_i64 = arith.constant 0 : i64
%c1_i64 = arith.constant 1 : i64
%true = arith.constant true
%c_minus2_i64 = arith.constant -2 : i64
%c_minus1_i64 = arith.constant -1 : i64
%c1 = arith.constant 1 : index
%c0 = arith.constant 0 : index
%c1346269_i32 = arith.constant 1346269 : i32
%alloca = memref.alloca() : memref<32xi32>
scf.for %arg0 = %c0 to %c32 step %c1 {
%3 = arith.index_cast %arg0 : index to i64
%4 = arith.cmpi eq, %3, %c0_i64 : i64
%5 = scf.if %4 -> (i1) {
scf.yield %true : i1
} else {
%6 = arith.cmpi eq, %3, %c1_i64 : i64
scf.yield %6 : i1
}
scf.if %5 {
%6 = arith.trunci %3 : i64 to i32
memref.store %6, %alloca[%arg0] : memref<32xi32>
} else {
%6 = arith.addi %3, %c_minus1_i64 : i64
%7 = arith.index_cast %6 : i64 to index
%8 = memref.load %alloca[%7] : memref<32xi32>
%9 = arith.addi %3, %c_minus2_i64 : i64
%10 = arith.index_cast %9 : i64 to index
%11 = memref.load %alloca[%10] : memref<32xi32>
%12 = arith.addi %8, %11 : i32
memref.store %12, %alloca[%arg0] : memref<32xi32>
}
}
%c31 = arith.constant 31 : index
%0 = memref.load %alloca[%c31] : memref<32xi32>
%1 = arith.cmpi ne, %0, %c1346269_i32 : i32
%2 = arith.extui %1 : i1 to i32
return %2 : i32
}
}
Metadata
Metadata
Assignees
Labels
No labels