mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-15 23:18:48 +00:00
Update skeleton
This commit is contained in:
@@ -208,7 +208,7 @@ impl WriteString for RType {
|
|||||||
Self::Sub(data_size) => format!("sub{}", data_size.write_string()),
|
Self::Sub(data_size) => format!("sub{}", data_size.write_string()),
|
||||||
Self::Sll(data_size) => format!("sll{}", data_size.write_string()),
|
Self::Sll(data_size) => format!("sll{}", data_size.write_string()),
|
||||||
Self::Srl(data_size) => format!("srl{}", data_size.write_string()),
|
Self::Srl(data_size) => format!("srl{}", data_size.write_string()),
|
||||||
Self::Sra(data_size) => format!("sra{}", data_size.write_string()),
|
Self::Sra(data_size) => format!("srl{}", data_size.write_string()),
|
||||||
Self::Mul(data_size) => format!("mul{}", data_size.write_string()),
|
Self::Mul(data_size) => format!("mul{}", data_size.write_string()),
|
||||||
Self::Div {
|
Self::Div {
|
||||||
data_size,
|
data_size,
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ impl HasDtype for Declaration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub struct FunctionSignature {
|
pub struct FunctionSignature {
|
||||||
pub ret: Dtype,
|
pub ret: Dtype,
|
||||||
pub params: Vec<Dtype>,
|
pub params: Vec<Dtype>,
|
||||||
@@ -155,7 +155,7 @@ impl HasDtype for FunctionSignature {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub struct FunctionDefinition {
|
pub struct FunctionDefinition {
|
||||||
/// Memory allocations for local variables. The allocation is performed at the beginning of a
|
/// Memory allocations for local variables. The allocation is performed at the beginning of a
|
||||||
/// function invocation.
|
/// function invocation.
|
||||||
@@ -168,7 +168,7 @@ pub struct FunctionDefinition {
|
|||||||
pub bid_init: BlockId,
|
pub bid_init: BlockId,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
|
||||||
pub struct BlockId(pub usize);
|
pub struct BlockId(pub usize);
|
||||||
|
|
||||||
impl fmt::Display for BlockId {
|
impl fmt::Display for BlockId {
|
||||||
@@ -177,14 +177,14 @@ impl fmt::Display for BlockId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub struct Block {
|
pub struct Block {
|
||||||
pub phinodes: Vec<Named<Dtype>>,
|
pub phinodes: Vec<Named<Dtype>>,
|
||||||
pub instructions: Vec<Named<Instruction>>,
|
pub instructions: Vec<Named<Instruction>>,
|
||||||
pub exit: BlockExit,
|
pub exit: BlockExit,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum Instruction {
|
pub enum Instruction {
|
||||||
Nop,
|
Nop,
|
||||||
@@ -255,7 +255,7 @@ impl Instruction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub enum BlockExit {
|
pub enum BlockExit {
|
||||||
Jump {
|
Jump {
|
||||||
arg: JumpArg,
|
arg: JumpArg,
|
||||||
@@ -300,7 +300,7 @@ impl BlockExit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub struct JumpArg {
|
pub struct JumpArg {
|
||||||
pub bid: BlockId,
|
pub bid: BlockId,
|
||||||
pub args: Vec<Operand>,
|
pub args: Vec<Operand>,
|
||||||
@@ -327,7 +327,7 @@ impl fmt::Display for JumpArg {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub enum Operand {
|
pub enum Operand {
|
||||||
Constant(Constant),
|
Constant(Constant),
|
||||||
Register { rid: RegisterId, dtype: Dtype },
|
Register { rid: RegisterId, dtype: Dtype },
|
||||||
@@ -849,7 +849,7 @@ impl HasDtype for Constant {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
|
||||||
pub struct Named<T> {
|
pub struct Named<T> {
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
inner: T,
|
inner: T,
|
||||||
|
|||||||
@@ -216,7 +216,12 @@ pub fn test_opt<P1: AsRef<Path>, P2: AsRef<Path>, O: Optimize<ir::TranslationUni
|
|||||||
|
|
||||||
pub fn test_asmgen(path: &Path) {
|
pub fn test_asmgen(path: &Path) {
|
||||||
// TODO: delete ignore list in the future
|
// TODO: delete ignore list in the future
|
||||||
let ignore_list = vec!["examples/asmgen/struct3.ir"];
|
let ignore_list = vec![
|
||||||
|
"examples/asmgen/struct.ir",
|
||||||
|
"examples/asmgen/struct2.ir",
|
||||||
|
"examples/asmgen/struct3.ir",
|
||||||
|
"examples/asmgen/temp2.ir",
|
||||||
|
];
|
||||||
if ignore_list.contains(&path.to_str().expect("`path` must be transformed to `&str`")) {
|
if ignore_list.contains(&path.to_str().expect("`path` must be transformed to `&str`")) {
|
||||||
println!("skip test");
|
println!("skip test");
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user