modified: src/ch2/linkedlist.rs

This commit is contained in:
wangfiox 2024-06-12 15:33:20 +08:00
parent 0dd21eca39
commit 3cb60c9922
1 changed files with 29 additions and 10 deletions

View File

@ -241,15 +241,34 @@ pub mod tests {
sdzero8a0,
]);
//.L11:
// mv a4,a5
// ld a5,8(a5)
// bne a5,zero,.L11
// ld ra,24(sp)
// ld s0,16(sp)
// sd a0,8(a4)
// ld s1,8(sp)
// addi sp,sp,32
// jr ra
let mut l11 = Block::new("L11".into());
let mva4a5 = Inst::Mv(MvInst::new(REG_A4.into(), REG_A5.into()));
let lda58a5 = Inst::Ld(LdInst::new(REG_A5.into(), (8).into(), REG_A5.into()));
let bnea5zeroL11 = Inst::Branch(BranchInst::new(
BranchOp::Bne,
REG_A5.into(),
REG_ZERO.into(),
"L11".into(),
));
let ldra24sp = Inst::Ld(LdInst::new(REG_RA.into(), (24).into(), REG_SP.into()));
let lds016sp = Inst::Ld(LdInst::new(REG_S0.into(), (16).into(), REG_SP.into()));
let sds08sp = Inst::Sd(SdInst::new(REG_S0.into(), (8).into(), REG_A4.into()));
let lds18sp = Inst::Ld(LdInst::new(REG_S1.into(), (8).into(), REG_SP.into()));
let addispsp32 = Inst::Add(AddInst::new(REG_SP.into(), REG_SP.into(), (32).into()));
let ret = Inst::Ret;
l11.extend_insts(vec![
mva4a5,
lda58a5,
bnea5zeroL11,
ldra24sp,
lds016sp,
sds08sp,
lds18sp,
addispsp32,
ret,
]);
let mut insertNode = Func::new("insertNode".into(), Vec::new(), entry);
insertNode.push_bb(l11);
}
}