refactor(llvm): Complete Call instruction modularization + Phase 21 organization

## LLVM Call Instruction Modularization
- Moved MirInstruction::Call lowering to separate instructions/call.rs
- Follows the principle of one MIR instruction per file
- Call implementation was already complete, just needed modularization

## Phase 21 Documentation
- Moved all Phase 21 content to private/papers/paper-f-self-parsing-db/
- Preserved AI evaluations from Gemini and Codex
- Academic paper potential confirmed by both AIs
- Self-parsing AST database approach validated

## Next Steps
- Continue monitoring ChatGPT5's LLVM improvements
- Consider creating separate nyash-llvm-compiler crate when LLVM layer is stable
- This will reduce build times by isolating LLVM dependencies

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Selfhosting Dev
2025-09-12 01:58:07 +09:00
parent 40d0cac0f1
commit b120e4a26b
13 changed files with 2153 additions and 29 deletions

View File

@ -242,30 +242,7 @@ impl LLVMCompiler {
vmap.insert(*dst, bval);
}
MirInstruction::Call { dst, func: callee, args, .. } => {
// Resolve callee name from const string -> lookup predeclared function
let name_s = const_strs.get(callee).ok_or_else(|| format!("call: callee value {} not a const string", callee.as_u32()))?;
let sym = format!("ny_f_{}", sanitize(name_s));
let target = codegen
.module
.get_function(&sym)
.ok_or_else(|| format!("call: function symbol not found: {}", sym))?;
// Collect args
let mut avs: Vec<BasicValueEnum> = Vec::new();
for a in args {
let v = *vmap
.get(a)
.ok_or_else(|| format!("call arg missing: {}", a.as_u32()))?;
avs.push(v);
}
let call = codegen
.builder
.build_call(target, &avs.iter().map(|v| (*v).into()).collect::<Vec<_>>(), "call")
.map_err(|e| e.to_string())?;
if let Some(d) = dst {
if let Some(rv) = call.try_as_basic_value().left() {
vmap.insert(*d, rv);
}
}
instructions::lower_call(&codegen, func, &mut vmap, dst, callee, args, &const_strs, &llvm_funcs)?;
}
MirInstruction::BoxCall {
dst,