Skip to content

Commit

Permalink
Not working
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanBrouwer committed Dec 5, 2023
1 parent 1c0b179 commit 4829bbd
Show file tree
Hide file tree
Showing 31 changed files with 208 additions and 803 deletions.
123 changes: 0 additions & 123 deletions compiler/src/interpreter.rs

This file was deleted.

1 change: 0 additions & 1 deletion compiler/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![allow(clippy::module_inception)]

pub mod interpreter;
pub mod passes;
pub mod utils;

Expand Down
2 changes: 0 additions & 2 deletions compiler/src/passes/assign/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ mod assign;
mod color_interference;
mod compute_interference;
mod include_liveness;
#[cfg(test)]
mod tests;

use crate::passes::select::{Block, FunSelected, Instr, InstrSelected, Reg, VarArg, X86Selected};
use crate::utils::gen_sym::UniqueSym;
Expand Down
35 changes: 0 additions & 35 deletions compiler/src/passes/assign/tests.rs

This file was deleted.

6 changes: 2 additions & 4 deletions compiler/src/passes/conclude/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
pub mod conclude;

use crate::passes::assign::Arg;
use crate::passes::select::Block;
use crate::utils::gen_sym::UniqueSym;

use std::collections::HashMap;

pub mod conclude;
#[cfg(test)]
mod tests;

pub struct X86Concluded<'p> {
pub blocks: HashMap<UniqueSym<'p>, Block<'p, Arg>>,
Expand Down
30 changes: 0 additions & 30 deletions compiler/src/passes/conclude/tests.rs

This file was deleted.

2 changes: 1 addition & 1 deletion compiler/src/passes/eliminate/eliminate_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn flatten_type<'p>(
defs: &HashMap<UniqueSym<'p>, TypeDef<UniqueSym<'p>, &'p str>>,
) -> Vec<(UniqueSym<'p>, Type<UniqueSym<'p>>)> {
match typ {
Type::I64 | Type::U64 | Type::Bool | Type::Unit | Type::Never | Type::Fn { .. } => {
Type::Int {..} | Type::Bool | Type::Unit | Type::Never | Type::Fn { .. } => {
vec![(sym, typ.clone())]
}
Type::Var { sym: def_sym } => match &defs[&def_sym] {
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/passes/eliminate/eliminate_seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn eliminate_seq<'p>(
// Changes based on LHS
match typ {
// No changes needed
Type::I64 | Type::U64 | Type::Bool | Type::Unit | Type::Never | Type::Fn { .. } => {
Type::Int {.. } | Type::Bool | Type::Unit | Type::Never | Type::Fn { .. } => {
TailEliminated::Seq {
syms: vec![sym],
bnd: Meta {
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/passes/emit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod push_pop;
mod special;
mod unary;

use crate::imm;
use crate::passes::assign::Arg;
use crate::passes::conclude::X86Concluded;
use crate::passes::emit::binary::{
Expand All @@ -19,6 +18,7 @@ use crate::passes::emit::unary::{encode_unary_instr, CALLQ_INDIRECT_INFO, NEGQ_I
use crate::passes::select::{Block, Cnd, Instr, Reg};
use crate::utils::gen_sym::UniqueSym;
use std::collections::HashMap;
use crate::imm32;

impl<'p> X86Concluded<'p> {
#[must_use]
Expand Down Expand Up @@ -115,7 +115,7 @@ fn emit_instr<'p>(
// todo: this offset is *only* correct when dst is a register!
assert!(matches!(dst, Arg::Reg { .. }));
abs_jumps.insert(machine_code.len() + 3, *sym);
encode_binary_instr(MOVQ_INFO, &imm!(0), dst)
encode_binary_instr(MOVQ_INFO, &imm32!(0), dst)
}
};
machine_code.extend(v);
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/passes/explicate/explicate_pred.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn explicate_pred<'p>(
exprs: [
Atom::Var { sym },
Atom::Val {
val: TLit::Bool { val: true },
val: TLit::Bool(true),
},
],
},
Expand All @@ -38,7 +38,7 @@ pub fn explicate_pred<'p>(
},
AExpr::Atom {
atm: Atom::Val {
val: TLit::Bool { val },
val: TLit::Bool(val),
},
..
} => {
Expand Down Expand Up @@ -180,7 +180,7 @@ pub fn explicate_pred<'p>(
| AExpr::Atom {
atm:
Atom::Val {
val: TLit::U64 { .. } | TLit::I64 { .. } | TLit::Unit,
val: TLit::Int { .. } | TLit::Unit,
},
..
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/src/passes/parse/grammar.lalrpop
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::passes::parse::{
BinaryOp, DefParsed, ExprParsed, InstrParsed, Lit, Meta, Param, PrgParsed, Spanned, Type, TypeDef, UnaryOp,
BinaryOp, DefParsed, ExprParsed, InstrParsed, Lit, Meta, Param, PrgParsed, Spanned, Type, TypeDef, UnaryOp, types::Int,
};
use crate::passes::select::{VarArg, Reg};
use functor_derive::Functor;
Expand Down Expand Up @@ -159,8 +159,8 @@ Param: Param<Spanned<&'input str>> = {
}

Type: Type<Spanned<&'input str>> = {
"I64" => Type::I64,
"U64" => Type::U64,
"I64" => Type::Int(Int::I64),
"U64" => Type::Int(Int::I64),
"Bool" => Type::Bool,
"Unit" => Type::Unit,
"Never" => Type::Never,
Expand Down Expand Up @@ -340,7 +340,7 @@ ExprAtom<T>: ExprParsed<'input> = {
val,
},
},
<val:Bool> => ExprParsed::Lit { val: Lit::Bool { val } },
<val:Bool> => ExprParsed::Lit { val: Lit::Bool(val) },
"unit" => ExprParsed::Lit { val: Lit::Unit },
<sym:Ident> => ExprParsed::Var { sym },
<enum_sym:Ident> "::" <variant_sym:Ident> "(" <bdy:Spanned<Expr>> ")" => ExprParsed::Variant {
Expand Down
10 changes: 2 additions & 8 deletions compiler/src/passes/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,9 @@ pub enum Lit<'p> {
#[display(fmt = "{val}")]
Int { val: &'p str },
/// Boolean literal, representing a value of *true* or *false*.
#[display(fmt = "{}", r#"if *val { "true" } else { "false" }"#)]
Bool { val: bool },
#[display(fmt = "{}", r#"if *_0 { "true" } else { "false" }"#)]
Bool(bool),
/// Unit literal, representing the absence of a value.
#[display(fmt = "unit")]
Unit,
}

#[derive(Copy, Clone)]
pub enum IntSuffix {
I64,
U64,
}
19 changes: 15 additions & 4 deletions compiler/src/passes/parse/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ use std::fmt::Display;
#[derive(Debug, Clone, Display)]
#[display(bound = "A: Display")]
pub enum Type<A> {
#[display(fmt = "I64")]
I64,
#[display(fmt = "U64")]
U64,
#[display(fmt = "{_0}")]
Int(Int),
#[display(fmt = "Bool")]
Bool,
#[display(fmt = "Unit")]
Expand All @@ -23,3 +21,16 @@ pub enum Type<A> {
#[display(fmt = "{sym}")]
Var { sym: A },
}

/// Integer types
#[derive(Debug, Clone, Display, Eq, PartialEq)]
pub enum Int{
I8,
U8,
I16,
U16,
I32,
U32,
I64,
U64,
}
2 changes: 0 additions & 2 deletions compiler/src/passes/patch/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
pub mod patch;
#[cfg(test)]
mod tests;

use crate::passes::assign::FunAssigned;
use crate::passes::select::X86Selected;
Expand Down
Loading

0 comments on commit 4829bbd

Please sign in to comment.