✨ Python LLVM backend implementation (experimental)
- Created llvmlite-based LLVM backend in src/llvm_py/ - Implemented all MIR14 instructions (const, binop, jump, branch, ret, compare, phi, call, boxcall, externcall, typeop, newbox, safepoint, barrier) - Experimental LoopForm support - ~2000 lines of clean Python code vs complex Rust/inkwell - Useful for PHI/SSA validation and rapid prototyping - Added documentation to CLAUDE.md This was created while waiting for ChatGPT's investigation of BuilderCursor issues.
This commit is contained in:
61
src/llvm_py/test_boxcall.json
Normal file
61
src/llvm_py/test_boxcall.json
Normal file
@ -0,0 +1,61 @@
|
||||
{
|
||||
"functions": [
|
||||
{
|
||||
"name": "ny_main",
|
||||
"params": [],
|
||||
"blocks": [
|
||||
{
|
||||
"id": 0,
|
||||
"instructions": [
|
||||
{
|
||||
"op": "newbox",
|
||||
"type": "StringBox",
|
||||
"args": [],
|
||||
"dst": 1
|
||||
},
|
||||
{
|
||||
"op": "const",
|
||||
"dst": 2,
|
||||
"value": {
|
||||
"type": "string",
|
||||
"value": "Hello Nyash!"
|
||||
}
|
||||
},
|
||||
{
|
||||
"op": "boxcall",
|
||||
"box": 1,
|
||||
"method": "set",
|
||||
"args": [2],
|
||||
"dst": 3
|
||||
},
|
||||
{
|
||||
"op": "boxcall",
|
||||
"box": 1,
|
||||
"method": "get",
|
||||
"args": [],
|
||||
"dst": 4
|
||||
},
|
||||
{
|
||||
"op": "externcall",
|
||||
"func": "print",
|
||||
"args": [4],
|
||||
"dst": null
|
||||
},
|
||||
{
|
||||
"op": "const",
|
||||
"dst": 5,
|
||||
"value": {
|
||||
"type": "i64",
|
||||
"value": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"op": "ret",
|
||||
"value": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user