de-rust phase-0: archive Rust LLVM backend to archive/rust-llvm-backend (RESTORE documented); defaults unaffected

This commit is contained in:
nyash-codex
2025-11-09 01:00:43 +09:00
parent 024a4fecb7
commit 5d2cd5bad0
37 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,28 @@
/*!
* Select & Condition helpers (scaffolding)
*
* Placeholder for condition normalization / short-circuit pre-processing
* to keep `function.rs` focused on structure. Implementations will be
* added incrementally; for now, this module is documentation-only.
*/
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 {
// 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
}