mirror of
https://github.com/Noratrieb/uwucc.git
synced 2026-01-14 16:45:07 +01:00
more codegen
This commit is contained in:
parent
ee0b311261
commit
db219d3d74
7 changed files with 214 additions and 15 deletions
|
|
@ -104,7 +104,7 @@ pub struct RegisterData<'cx> {
|
|||
pub name: Option<Symbol>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct Register(pub u32);
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
|
@ -245,6 +245,14 @@ impl ConstValue {
|
|||
pub fn u64(int: u64) -> Self {
|
||||
Self::Int(int.into())
|
||||
}
|
||||
|
||||
pub fn as_i32(self) -> i32 {
|
||||
match self {
|
||||
Self::StaticPtr(_) => panic!("StaticPtr cannot be converted to integer"),
|
||||
Self::Void => panic!("Void cannot be converted to integer"),
|
||||
Self::Int(int) => int.try_into().unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Operand {
|
||||
|
|
|
|||
|
|
@ -184,6 +184,8 @@ impl<W: Write> PrettyPrinter<W> {
|
|||
}
|
||||
}
|
||||
|
||||
writeln!(self.out, "}}")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue