more codegen

This commit is contained in:
nora 2023-05-24 21:49:56 +02:00
parent ee0b311261
commit db219d3d74
7 changed files with 214 additions and 15 deletions

View file

@ -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 {