Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4450454

Browse files
committed
riscv: Rename insert_w_comment to insert_with_comment
1 parent 8c2c863 commit 4450454

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

crates/rush-compiler-risc-v/src/call.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl<'tree> Compiler<'tree> {
159159
}
160160
None => {
161161
// no more param registers: spilling required
162-
self.insert_w_comment(
162+
self.insert_with_comment(
163163
Instruction::Fsd(
164164
res_reg.into(),
165165
Pointer::Register(IntRegister::Sp, spill_count * 8),
@@ -181,7 +181,7 @@ impl<'tree> Compiler<'tree> {
181181
}
182182
None => {
183183
// no more params: spilling required
184-
self.insert_w_comment(
184+
self.insert_with_comment(
185185
Instruction::Sd(
186186
res_reg.into(),
187187
Pointer::Register(IntRegister::Sp, spill_count * 8),

crates/rush-compiler-risc-v/src/compiler.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -566,18 +566,18 @@ impl<'tree> Compiler<'tree> {
566566

567567
match reg {
568568
Register::Int(reg) => match type_ {
569-
Type::Bool(0) | Type::Char(0) => self.insert_w_comment(
569+
Type::Bool(0) | Type::Char(0) => self.insert_with_comment(
570570
Instruction::Sb(reg, Pointer::Register(IntRegister::Fp, offset)),
571571
comment,
572572
),
573573
Type::Int(_) | Type::Float(_) | Type::Bool(_) | Type::Char(_) => self
574-
.insert_w_comment(
574+
.insert_with_comment(
575575
Instruction::Sd(reg, Pointer::Register(IntRegister::Fp, offset)),
576576
comment,
577577
),
578578
_ => unreachable!("only the types above use int registers"),
579579
},
580-
Register::Float(reg) => self.insert_w_comment(
580+
Register::Float(reg) => self.insert_with_comment(
581581
Instruction::Fsd(reg, Pointer::Register(IntRegister::Fp, offset)),
582582
comment,
583583
),
@@ -671,12 +671,12 @@ impl<'tree> Compiler<'tree> {
671671
.expect("the analyzer guarantees valid pointers")
672672
{
673673
Pointer::Register(_, offset) => {
674-
self.insert_w_comment(
674+
self.insert_with_comment(
675675
Instruction::Addi(dest_reg, IntRegister::Fp, offset),
676676
format!("&{}", ident.ident).into(),
677677
);
678678
}
679-
Pointer::Label(label) => self.insert_w_comment(
679+
Pointer::Label(label) => self.insert_with_comment(
680680
Instruction::La(dest_reg, Rc::clone(&label)),
681681
format!("&{label}").into(),
682682
),
@@ -715,7 +715,7 @@ impl<'tree> Compiler<'tree> {
715715

716716
self.insert(Instruction::Mov(dest_reg, lhs_reg.into()));
717717

718-
self.insert_w_comment(
718+
self.insert_with_comment(
719719
Instruction::Lb(dest_reg, Pointer::Register(dest_reg, 0)),
720720
"deref".into(),
721721
);
@@ -725,7 +725,7 @@ impl<'tree> Compiler<'tree> {
725725
(Type::Float(1), PrefixOp::Deref) => {
726726
let dest_reg = self.get_float_reg();
727727

728-
self.insert_w_comment(
728+
self.insert_with_comment(
729729
Instruction::Fld(dest_reg, Pointer::Register(lhs_reg.into(), 0)),
730730
"deref".into(),
731731
);
@@ -737,7 +737,7 @@ impl<'tree> Compiler<'tree> {
737737

738738
self.insert(Instruction::Mov(dest_reg, lhs_reg.into()));
739739

740-
self.insert_w_comment(
740+
self.insert_with_comment(
741741
Instruction::Ld(dest_reg, Pointer::Register(dest_reg, 0)),
742742
"deref".into(),
743743
);
@@ -764,7 +764,7 @@ impl<'tree> Compiler<'tree> {
764764
};
765765

766766
// jump to the merge block if the result is determined by the lhs
767-
self.insert_w_comment(
767+
self.insert_with_comment(
768768
Instruction::BrCond(
769769
condition,
770770
lhs.into(),
@@ -1011,7 +1011,7 @@ impl<'tree> Compiler<'tree> {
10111011
self.use_reg(ptr_reg.into(), Size::Dword);
10121012

10131013
while ptr_count > 0 {
1014-
self.insert_w_comment(
1014+
self.insert_with_comment(
10151015
Instruction::Ld(
10161016
ptr_reg,
10171017
src_ptr

crates/rush-compiler-risc-v/src/utils.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ impl<'tree> Compiler<'tree> {
7676
let ptr = Pointer::Register(IntRegister::Fp, offset);
7777

7878
match size {
79-
Size::Byte => self.insert_w_comment(Instruction::Sb(reg, ptr), comment),
80-
Size::Dword => self.insert_w_comment(Instruction::Sd(reg, ptr), comment),
79+
Size::Byte => self.insert_with_comment(Instruction::Sb(reg, ptr), comment),
80+
Size::Dword => self.insert_with_comment(Instruction::Sd(reg, ptr), comment),
8181
}
8282
}
8383
Register::Float(reg) => self.insert(Instruction::Fsd(
@@ -114,11 +114,11 @@ impl<'tree> Compiler<'tree> {
114114

115115
// perform different load operations depending on the size
116116
match size {
117-
Size::Byte => self.insert_w_comment(
117+
Size::Byte => self.insert_with_comment(
118118
Instruction::Lb(reg, Pointer::Register(IntRegister::Fp, offset)),
119119
comment,
120120
),
121-
Size::Dword => self.insert_w_comment(
121+
Size::Dword => self.insert_with_comment(
122122
Instruction::Ld(reg, Pointer::Register(IntRegister::Fp, offset)),
123123
comment,
124124
),
@@ -136,7 +136,7 @@ impl<'tree> Compiler<'tree> {
136136
self.insert(Instruction::Fmv(new_res_reg, FloatRegister::Fa0));
137137
}
138138

139-
self.insert_w_comment(
139+
self.insert_with_comment(
140140
Instruction::Fld(reg, Pointer::Register(IntRegister::Fp, offset)),
141141
comment,
142142
);
@@ -268,17 +268,17 @@ impl<'tree> Compiler<'tree> {
268268
match type_ {
269269
Type::Bool(0) | Type::Char(0) => {
270270
let dest_reg = self.get_int_reg();
271-
self.insert_w_comment(Instruction::Lb(dest_reg, ptr), ident.into());
271+
self.insert_with_comment(Instruction::Lb(dest_reg, ptr), ident.into());
272272
Register::Int(dest_reg)
273273
}
274274
Type::Float(0) => {
275275
let dest_reg = self.get_float_reg();
276-
self.insert_w_comment(Instruction::Fld(dest_reg, ptr), ident.into());
276+
self.insert_with_comment(Instruction::Fld(dest_reg, ptr), ident.into());
277277
Register::Float(dest_reg)
278278
}
279279
Type::Int(_) | Type::Float(_) | Type::Bool(_) | Type::Char(_) => {
280280
let dest_reg = self.get_int_reg();
281-
self.insert_w_comment(Instruction::Ld(dest_reg, ptr), ident.into());
281+
self.insert_with_comment(Instruction::Ld(dest_reg, ptr), ident.into());
282282
Register::Int(dest_reg)
283283
}
284284
Type::Unit | Type::Never | Type::Unknown => {
@@ -293,7 +293,7 @@ impl<'tree> Compiler<'tree> {
293293
// only insert a jump if the current block is not already terminated
294294
if !self.curr_block().is_terminated {
295295
match comment {
296-
Some(comment) => self.insert_w_comment(Instruction::Jmp(label), comment),
296+
Some(comment) => self.insert_with_comment(Instruction::Jmp(label), comment),
297297
None => self.insert(Instruction::Jmp(label)),
298298
}
299299
self.curr_block_mut().is_terminated = true;
@@ -320,7 +320,7 @@ impl<'tree> Compiler<'tree> {
320320

321321
/// Inserts an [`Instruction`] at the end of the current basic block.
322322
/// Also inserts the specified comment at the end of the instruction.
323-
pub(crate) fn insert_w_comment(&mut self, instruction: Instruction, comment: Cow<'tree, str>) {
323+
pub(crate) fn insert_with_comment(&mut self, instruction: Instruction, comment: Cow<'tree, str>) {
324324
self.blocks[self.curr_block]
325325
.instructions
326326
.push((instruction, Some(comment)));

0 commit comments

Comments
 (0)