checkpoint in reconstruction

This commit is contained in:
2023-12-26 21:08:01 -08:00
parent 2c2268925a
commit e5db6640f2
21 changed files with 759 additions and 153 deletions

View File

@@ -1,8 +1,6 @@
use crate::backend::Backend;
use crate::eval::EvalError;
use crate::ir::{Expression, Program, TopLevel, Type};
#[cfg(test)]
use crate::syntax::arbitrary::GenerationEnvironment;
use crate::syntax::Location;
use cranelift_jit::JITModule;
use cranelift_object::ObjectModule;
@@ -176,7 +174,7 @@ proptest::proptest! {
// without error, assuming any possible input ... well, any possible input that
// doesn't involve overflow or underflow.
#[test]
fn static_backend(program in Program::arbitrary_with(GenerationEnvironment::new(false))) {
fn static_backend(program in Program::arbitrary()) {
use crate::eval::PrimOpError;
let basic_result = program.eval().map(|(_,x)| x);
@@ -206,7 +204,7 @@ proptest::proptest! {
// without error, assuming any possible input ... well, any possible input that
// doesn't involve overflow or underflow.
#[test]
fn jit_backend(program in Program::arbitrary_with(GenerationEnvironment::new(false))) {
fn jit_backend(program in Program::arbitrary()) {
use crate::eval::PrimOpError;
// use pretty::{DocAllocator, Pretty};
// let allocator = pretty::BoxAllocator;

View File

@@ -338,7 +338,7 @@ impl<M: Module> Backend<M> {
let vtype_repr = builder.ins().iconst(types::I64, vtype as i64);
let casted_val = match vtype {
ConstantType::U64 | ConstantType::I64 => val,
ConstantType::U64 | ConstantType::I64 | ConstantType::Void => val,
ConstantType::I8 | ConstantType::I16 | ConstantType::I32 => {
builder.ins().sextend(types::I64, val)
}
@@ -401,6 +401,7 @@ impl<M: Module> Backend<M> {
builder.ins().iconst(types::I64, v as i64),
ConstantType::U64,
)),
Value::Void => Ok((builder.ins().iconst(types::I64, 0i64), ConstantType::Void)),
},
ValueOrRef::Ref(_, _, name) => match variables.get(&name) {
None => Err(BackendError::VariableLookupFailure(name)),

View File

@@ -110,6 +110,7 @@ extern "C" fn runtime_print(
let reconstituted = cstr.to_string_lossy();
let output = match vtype_repr.try_into() {
Ok(ConstantType::Void) => format!("{} = <void>", reconstituted),
Ok(ConstantType::I8) => format!("{} = {}i8", reconstituted, value as i8),
Ok(ConstantType::I16) => format!("{} = {}i16", reconstituted, value as i16),
Ok(ConstantType::I32) => format!("{} = {}i32", reconstituted, value as i32),