Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/antonlydike/sympy2llvm
Convert sympy to SSA form
https://github.com/antonlydike/sympy2llvm
llvm mlir sympy
Last synced: 6 days ago
JSON representation
Convert sympy to SSA form
- Host: GitHub
- URL: https://github.com/antonlydike/sympy2llvm
- Owner: AntonLydike
- Created: 2025-01-22T18:08:13.000Z (13 days ago)
- Default Branch: main
- Last Pushed: 2025-01-28T16:57:44.000Z (7 days ago)
- Last Synced: 2025-01-28T17:39:21.836Z (7 days ago)
- Topics: llvm, mlir, sympy
- Language: Python
- Homepage:
- Size: 59.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sympy2llvm - Convert sympy expressions to SSA form
This projects provides a simple tool to convert sympy expressions to SSA form.
## Usage:
Either from command line:
```
sympy2llvm [-i input_file] {llvm,mlir} fun_name argument_type ...
```This reads a sympy expression either from stdin or the provided file, and prints the desired output (either MLIRs
llvm dialect, or llvmir directly).Or programmatically:
```py
from sympy2llvm.llvm import ConvertLLVM, LLVMType
import sympyx,y = sympy.symbols("x y")
conv = ConvertLLVM(x/y, "div", (LLVMType.i32, LLVMType.i32), int_t=LLVMType.i32)
llvmir = conv.convert()print(llvmir)
# prints:
# define i32 @div(i32 %a, i32 %b) {
# %1 = sdiv i32 %a, %b
# ret i32 %1
# }
```