Experimental(toy) python compiler written in Python with support for x86 and WASM targets.
- Implement x86 IR and WAT
- Add closure support
- Primitive Escape Analysis for closure
- Generate Inteference Graph for register allocatoin
- Fixed point register allocation(using graph coloring) for x86
- Create CFG with BB
- Fixed point liveness analysis on the basic blocks
- Basic dead store elimination using liveness analysis
- Constant Propagation/Copy Folding using Local value numbering on the CFG
- Support for Control Flow Statement (Ternary, If and While)
- Support for Lambda Function (Anonymous, Named and Closure)
- Support for Class
- Support for Comparison and Logical Operator
- Support for Arithmetic Operator
- Add Single Static Assignment (SSA)
- Add Dominance Analysis
- Add Dominance Frontier Analysis
- Add Reaching Definition Analysis
- Resolve Phi Nodes
- Convert CRuntime to WASM using Emscripten
- Compilation:
./pycomp [--wasm | -w] [--x86 | -x] <input_file.py>
Flags are optional.
> --wasm
: Compile to WebAssembly.
> --x86
: Compile to x86-64.
> <input_file.py>
: Input file.
- Execution:
./input_file_binary
- Execution:
Start the web server from the root folder:
python3 -m http.server
- Checking the output:
- Go to
http://localhost:8000/
on your browser. - Open the
index.html
file. - Open DevTools and click on the
Console
tab. - Call the wasm function that you are interested in.