Skip to content

Commit

Permalink
Work 2
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanBrouwer committed Dec 8, 2023
1 parent 1edc09c commit c611766
Show file tree
Hide file tree
Showing 19 changed files with 611 additions and 487 deletions.
2 changes: 1 addition & 1 deletion compiler/src/passes/assign/assign.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::passes::assign::{Arg, FunAssigned, X86Assigned};
use crate::passes::select::{Block, Instr, InstrSelected, VarArg, X86Selected};
use crate::{display, time};
use crate::utils::unique_sym::UniqueSym;
use crate::{display, time};
use functor_derive::Functor;
use std::collections::HashMap;

Expand Down
4 changes: 2 additions & 2 deletions compiler/src/passes/assign/display.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt::{Display, Formatter};
use indenter::indented;
use crate::passes::assign::{FunAssigned, X86Assigned};
use indenter::indented;
use std::fmt::Write;
use std::fmt::{Display, Formatter};

impl Display for X86Assigned<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
Expand Down
8 changes: 4 additions & 4 deletions compiler/src/passes/assign/include_liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub fn handle_instr<'p>(
match instr {
Instr::Add { src, dst, .. }
| Instr::Sub { src, dst, .. }
| Instr::And{ src, dst, .. }
| Instr::And { src, dst, .. }
| Instr::Or { src, dst, .. }
| Instr::Xor { src, dst, .. } => {
arg(dst, RW);
Expand All @@ -129,7 +129,7 @@ pub fn handle_instr<'p>(
Instr::Push { src, .. } => {
arg(src, R);
}
Instr::Pop{ dst, .. } => {
Instr::Pop { dst, .. } => {
arg(dst, W);
}
Instr::Neg { dst, .. } | Instr::Not { dst, .. } => {
Expand All @@ -151,14 +151,14 @@ pub fn handle_instr<'p>(
arg(&VarArg::Reg(reg), R);
}
}
Instr::Ret => {
Instr::Ret { .. } => {
// Because the return value of our function is in RAX, we need to consider it being read at the end of a block.
arg(&VarArg::Reg(Reg::RAX), R);
}
Instr::Setcc { .. } => {
arg(&VarArg::Reg(Reg::RAX), W);
}
Instr::Mul{ src, .. } => {
Instr::Mul { src, .. } => {
arg(&VarArg::Reg(Reg::RDX), W);
arg(&VarArg::Reg(Reg::RAX), RW);
arg(src, R);
Expand Down
9 changes: 3 additions & 6 deletions compiler/src/passes/assign/mod.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
mod assign;
mod color_interference;
mod compute_interference;
mod include_liveness;
mod display;
mod include_liveness;

use crate::passes::select::{
Block, FunSelected, Instr, InstrSelected, Reg, VarArg, X86Selected,
};
use crate::passes::select::{Block, FunSelected, Instr, InstrSelected, Reg, VarArg, X86Selected};
use crate::passes::validate::Int;
use crate::utils::unique_sym::UniqueSym;
use derive_more::Display;
use functor_derive::Functor;
use petgraph::graphmap::GraphMap;
use petgraph::Undirected;
use std::collections::{HashMap, HashSet};
use crate::passes::validate::Int;

pub struct X86Assigned<'p> {
pub fns: HashMap<UniqueSym<'p>, FunAssigned<'p>>,
pub entry: UniqueSym<'p>,
}


pub struct FunAssigned<'p> {
pub blocks: HashMap<UniqueSym<'p>, Block<'p, Arg>>,
pub entry: UniqueSym<'p>,
Expand Down
Loading

0 comments on commit c611766

Please sign in to comment.