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,39 @@
use crate::mir::instruction::{ConstValue, MirInstruction};
use crate::mir::ValueId;
use std::collections::HashMap;
pub(super) fn sanitize_symbol(name: &str) -> String {
name.chars()
.map(|c| match c {
'.' | '/' | '-' => '_',
other => other,
})
.collect()
}
pub(super) fn build_const_str_map(
f: &crate::mir::function::MirFunction,
) -> HashMap<ValueId, String> {
let mut m = HashMap::new();
for bid in f.block_ids() {
if let Some(b) = f.blocks.get(&bid) {
for inst in &b.instructions {
if let MirInstruction::Const {
dst,
value: ConstValue::String(s),
} = inst
{
m.insert(*dst, s.clone());
}
}
if let Some(MirInstruction::Const {
dst,
value: ConstValue::String(s),
}) = &b.terminator
{
m.insert(*dst, s.clone());
}
}
}
m
}