Skip to content

Commit d7c43de

Browse files
committed
2 parents adb9bac + f389377 commit d7c43de

37 files changed

+739
-359
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "lamina"
3-
version = "0.0.8-dev"
3+
version = "0.0.8"
44
edition = "2024"
55
authors = ["Eira <eira@nornity.com>"]
66
description = "High-performance compiler backend for Lamina Intermediate Representation"

src/codegen/wasm/mod.rs

Lines changed: 233 additions & 151 deletions
Large diffs are not rendered by default.

src/codegen/wasm/state.rs

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,29 @@ impl<'a> CodegenState<'a> {
7676
self.global_next += 1;
7777
}
7878
pub fn get_global(&self, name: &'a str) -> Result<GlobalRef, crate::LaminaError> {
79-
self.globals.get(&name)
80-
.copied()
81-
.ok_or_else(|| crate::LaminaError::ValidationError(format!(
82-
"Global '{}' not found in WASM codegen state", name
83-
)))
79+
self.globals.get(&name).copied().ok_or_else(|| {
80+
crate::LaminaError::ValidationError(format!(
81+
"Global '{}' not found in WASM codegen state",
82+
name
83+
))
84+
})
8485
}
85-
pub fn get_global_value(&self, name: &'a str) -> Result<&Option<Value<'a>>, crate::LaminaError> {
86-
self.global_values.get(&name)
87-
.ok_or_else(|| crate::LaminaError::ValidationError(format!(
88-
"Global value '{}' not found in WASM codegen state", name
89-
)))
86+
pub fn get_global_value(
87+
&self,
88+
name: &'a str,
89+
) -> Result<&Option<Value<'a>>, crate::LaminaError> {
90+
self.global_values.get(&name).ok_or_else(|| {
91+
crate::LaminaError::ValidationError(format!(
92+
"Global value '{}' not found in WASM codegen state",
93+
name
94+
))
95+
})
9096
}
91-
fn set_memory_contents_for_value(&mut self, address: usize, val: Value<'a>) -> Result<(), crate::LaminaError> {
97+
fn set_memory_contents_for_value(
98+
&mut self,
99+
address: usize,
100+
val: Value<'a>,
101+
) -> Result<(), crate::LaminaError> {
92102
let ptr_addr = address;
93103
match val {
94104
Value::Constant(lit) => match lit {
@@ -121,10 +131,16 @@ impl<'a> CodegenState<'a> {
121131
.clone_from_slice(v.to_le_bytes().as_slice()),
122132
},
123133
Value::Global(id) => {
124-
let from = self.mem_registers.iter().find(|v| v.name == id)
125-
.ok_or_else(|| crate::LaminaError::ValidationError(format!(
126-
"Memory register '{}' not found in WASM codegen state", id
127-
)))?;
134+
let from = self
135+
.mem_registers
136+
.iter()
137+
.find(|v| v.name == id)
138+
.ok_or_else(|| {
139+
crate::LaminaError::ValidationError(format!(
140+
"Memory register '{}' not found in WASM codegen state",
141+
id
142+
))
143+
})?;
128144

129145
let from_bytes = self.output_memory
130146
[(from.address as usize)..(from.address + from.size) as usize]
@@ -135,7 +151,7 @@ impl<'a> CodegenState<'a> {
135151
}
136152
Value::Variable(_) => {
137153
return Err(crate::LaminaError::ValidationError(
138-
"Variable values cannot be stored in memory directly".to_string()
154+
"Variable values cannot be stored in memory directly".to_string(),
139155
));
140156
}
141157
}

src/codegen/x86_64/register_allocator.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,7 @@ impl GraphColoringAllocator {
150150
if var1 != var2 && self.intervals_interfere(interval1, interval2) {
151151
// Legacy codegen - unwrap is acceptable here
152152
#[allow(clippy::unwrap_used)]
153-
let list = interference_lists
154-
.get_mut(&var1_key)
155-
.unwrap();
153+
let list = interference_lists.get_mut(&var1_key).unwrap();
156154
list.insert((*var2).to_string());
157155
}
158156
}

src/ir/builder/annotations.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,3 @@ impl<'a> IRBuilder<'a> {
183183
self.annotate_module(ModuleAnnotation::TargetTriple(triple.to_string()))
184184
}
185185
}
186-

src/ir/builder/arithmetic.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,3 @@ impl<'a> IRBuilder<'a> {
4444
})
4545
}
4646
}
47-

src/ir/builder/atomics.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,3 @@ impl<'a> IRBuilder<'a> {
9494
self.inst(Instruction::Fence { ordering })
9595
}
9696
}
97-

src/ir/builder/blocks.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,3 @@ impl<'a> IRBuilder<'a> {
3737
self
3838
}
3939
}
40-

src/ir/builder/control_flow.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,3 @@ impl<'a> IRBuilder<'a> {
9090
})
9191
}
9292
}
93-

src/ir/builder/conversions.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,3 @@ impl<'a> IRBuilder<'a> {
9090
})
9191
}
9292
}
93-

0 commit comments

Comments
 (0)