runner/env: centralize CLI/env getters; parser expr split (call/primary); verifier utils direct; optimizer: boxfield peephole; LLVM: branch cond normalize hook; add trace macro scaffolding; refactor common.rs verbose checks

This commit is contained in:
Selfhosting Dev
2025-09-17 06:55:39 +09:00
parent 9dc5c9afb9
commit c553f2952d
20 changed files with 651 additions and 677 deletions

View File

@ -7,10 +7,22 @@
*/
use crate::mir::{function::MirFunction, ValueId};
use crate::mir::MirType;
use super::super::types; // access mapping helpers if needed later
/// Normalize a branch condition if needed (scaffolding).
/// Currently returns the input unchanged; provides a single place
/// to adjust semantics later (e.g., truthy rules, short-circuit pre-pass).
pub(crate) fn normalize_branch_condition(_func: &MirFunction, cond: &ValueId) -> ValueId {
pub(crate) fn normalize_branch_condition(func: &MirFunction, cond: &ValueId) -> ValueId {
// Minimal truthy normalization hook.
// Strategy (no new instructions here):
// - If we have a recorded type for `cond` and it is a boolean-like i1/i64 (0/1), return as-is.
// - Otherwise, return the original cond and let flow/emit handle `!= 0` lowering as today.
if let Some(ty) = func.metadata.value_types.get(cond) {
match ty {
MirType::I1 | MirType::I64 | MirType::Bool => { return *cond; }
_ => {}
}
}
*cond
}