docs(llvm/vm): 静的Box(self)規約を明文化 + Bridgeトグル追記; Gate‑C/Core 現状反映; CURRENT_TASK 更新。\n\n- 新規: docs/development/architecture/llvm/static_box_singleton.md\n- 追記: lang/src/vm/README.md に self 先頭規約/互換トグルを明記\n- 追記: CURRENT_TASK に本更新を記録\n- phase-20.33/CHECKLIST にドキュメント完了チェックを追加\n- bak フォルダはリポジトリ直下に存在せず(削除対象なし)\n\n併せて未コミット差分をスナップショット(Rust 層の前作業含む)
This commit is contained in:
@ -16,23 +16,42 @@ pub(super) fn lower_loop_stmt(
|
||||
let cond_bb = new_block(f);
|
||||
let body_bb = new_block(f);
|
||||
let exit_bb = new_block(f);
|
||||
|
||||
// フェーズM.2: no_phi変数削除 + PHI UseBeforeDef修正
|
||||
let base_vars = vars.clone();
|
||||
let orig_names: Vec<String> = base_vars.keys().cloned().collect();
|
||||
|
||||
// Step 1: cur_bbでCopy命令を先に生成(PHI inputsの定義を確保)
|
||||
let mut copy_map: HashMap<String, ValueId> = HashMap::new();
|
||||
for name in &orig_names {
|
||||
if let Some(&bval) = base_vars.get(name) {
|
||||
let copy_dst = f.next_value_id();
|
||||
if let Some(bb) = f.get_block_mut(cur_bb) {
|
||||
bb.add_instruction(MirInstruction::Copy {
|
||||
dst: copy_dst,
|
||||
src: bval,
|
||||
});
|
||||
}
|
||||
copy_map.insert(name.clone(), copy_dst);
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2: cur_bbからcond_bbへのJumpを挿入
|
||||
if let Some(bb) = f.get_block_mut(cur_bb) {
|
||||
if !bb.is_terminated() {
|
||||
bb.add_instruction(MirInstruction::Jump { target: cond_bb });
|
||||
}
|
||||
}
|
||||
// フェーズM.2: no_phi変数削除
|
||||
let base_vars = vars.clone();
|
||||
let orig_names: Vec<String> = base_vars.keys().cloned().collect();
|
||||
|
||||
// Step 3: cond_bbでPHI命令生成(copy_mapの値を使用)
|
||||
let mut phi_map: HashMap<String, ValueId> = HashMap::new();
|
||||
for name in &orig_names {
|
||||
if let Some(&bval) = base_vars.get(name) {
|
||||
if let Some(©_val) = copy_map.get(name) {
|
||||
let dst = f.next_value_id();
|
||||
// フェーズM.2: PHI統一処理(no_phi分岐削除)
|
||||
if let Some(bb) = f.get_block_mut(cond_bb) {
|
||||
bb.insert_instruction_after_phis(MirInstruction::Phi {
|
||||
dst,
|
||||
inputs: vec![(cur_bb, bval)],
|
||||
inputs: vec![(cur_bb, copy_val)],
|
||||
});
|
||||
}
|
||||
phi_map.insert(name.clone(), dst);
|
||||
|
||||
Reference in New Issue
Block a user