Compare commits

...

2 Commits

Author SHA1 Message Date
wangfiox 9cc7d29143 modified: .gitignore
modified:   src/ch2/linkedlist.rs
	modified:   src/ch2/mod.rs
2024-06-11 18:50:51 +08:00
wangfiox afed4d2856 new file: src/ch2/linkedlist.rs
modified:   .gitignore
	modified:   src/ch2/linkedlist.rs
	modified:   src/ch2/mod.rs
2024-06-11 18:50:41 +08:00
3 changed files with 31 additions and 0 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/target /target
.idea

28
src/ch2/linkedlist.rs Normal file
View File

@ -0,0 +1,28 @@
pub mod tests {
use compiler::backend::{AddInst, Block, BranchInst, BranchOp, CallInst, Inst, JmpInst, MvInst, REG_A0, REG_A1, REG_A2, REG_RA, REG_S0, REG_S1, REG_S2, REG_SP, REG_ZERO, SdInst};
use compiler::backend::Inst::Call;
#[test]
pub fn linked() {
// createLinkedList
let mut entry = Block::new("entry".into());
let addispsp_16 = Inst::Add(AddInst::new(REG_SP.into(), REG_SP.into(), (-16).into()));
let lia08 = Inst::Add(AddInst::new(REG_A0.into(), REG_ZERO.into(), (-16).into()));
let sdra8sp = Inst::Sd(SdInst::new(REG_RA.into(), (8).into(), REG_SP.into()));
let sds00sp = Inst::Sd(SdInst::new(REG_S0.into(), (0).into(), REG_SP.into()));
let callmalloc = Inst::Call(CallInst::new("malloc@plt".into()));
let beqa0zerol2 = Inst::Branch(BranchInst::new(BranchOp::Beq, REG_A0.into(), REG_ZERO.into(), "L2".into()));
let mvs0a0 = Inst::Mv(MvInst::new(REG_S0.into(), REG_A0.into()));
let lia016 = Inst::Add(AddInst::new(REG_A0.into(), REG_ZERO.into(), (16).into()));
let callmalloc = Inst::Call(CallInst::new("malloc@plt".into()));
let sda00s0 = Inst::Sd(SdInst::new(REG_A0.into(), (0).into(), REG_S0.into()));
let beqa0zerol3 = Inst::Branch(BranchInst::new(BranchOp::Beq, REG_A0.into(), REG_ZERO.into(), "L3".into()));
}
}

View File

@ -1,3 +1,5 @@
mod quicksort; mod quicksort;
mod linkedlist;
pub use quicksort::*; pub use quicksort::*;
pub use linkedlist::*;