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:
Selfhosting Dev
2025-09-12 20:55:13 +09:00
parent 38aea59fc1
commit ef44801fa6
17 changed files with 1368 additions and 10 deletions

View File

@ -42,7 +42,10 @@ def lower_const(
# String constant - create global and get pointer
i8 = ir.IntType(8)
str_val = str(const_val)
str_const = ir.Constant.literal_string(str_val.encode('utf-8') + b'\0')
# Create array constant for the string
str_bytes = str_val.encode('utf-8') + b'\0'
str_const = ir.Constant(ir.ArrayType(i8, len(str_bytes)),
bytearray(str_bytes))
# Create global string constant
global_name = f".str.{dst}"