actually compiles and does stuff now

This commit is contained in:
2024-12-06 19:44:33 -05:00
parent 31c197e991
commit 620c4557e9
67 changed files with 1931 additions and 1287 deletions

View File

@@ -5,14 +5,21 @@ use std::{
process::Command,
};
pub mod arch;
mod elf;
mod program;
pub mod riscv64;
mod target;
mod instruction;
pub use program::*;
use crate::ir::Program;
pub fn compile(program: Program) -> Vec<u8> {
let (compiled, start) = arch::riscv64::compile(program);
let binary = elf::create(compiled, start.expect("no start method found"));
binary
}
pub fn main() {
use std::io::prelude::*;
let dir = Path::new("./build");
@@ -27,7 +34,7 @@ pub fn main() {
.mode(0o750)
.open(path)
.expect("Failed to create file");
file.write_all(&riscv64::gen())
file.write_all(&arch::riscv64::gen())
.expect("Failed to write to file");
file.sync_all().expect("Failed to sync file");
let mut p = Command::new("qemu-riscv64");
@@ -64,4 +71,3 @@ pub fn main() {
}
}
}