Skip to content

Commit e6f9ca5

Browse files
authored
cranelift: Delete all references to AllocationConsumer (#8592)
Since there are no calls left to AllocationConsumer's methods, this commit just deletes all the arguments of this type, as well as the definition of the type itself.
1 parent bc081b7 commit e6f9ca5

File tree

20 files changed

+906
-1035
lines changed

20 files changed

+906
-1035
lines changed

cranelift/codegen/src/isa/aarch64/inst/args.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -300,19 +300,19 @@ impl BranchTarget {
300300
}
301301

302302
impl PrettyPrint for ShiftOpAndAmt {
303-
fn pretty_print(&self, _: u8, _: &mut AllocationConsumer) -> String {
303+
fn pretty_print(&self, _: u8) -> String {
304304
format!("{:?} {}", self.op(), self.amt().value())
305305
}
306306
}
307307

308308
impl PrettyPrint for ExtendOp {
309-
fn pretty_print(&self, _: u8, _: &mut AllocationConsumer) -> String {
309+
fn pretty_print(&self, _: u8) -> String {
310310
format!("{:?}", self)
311311
}
312312
}
313313

314314
impl PrettyPrint for MemLabel {
315-
fn pretty_print(&self, _: u8, _: &mut AllocationConsumer) -> String {
315+
fn pretty_print(&self, _: u8) -> String {
316316
match self {
317317
MemLabel::PCRel(off) => format!("pc+{}", off),
318318
MemLabel::Mach(off) => format!("label({})", off.get()),
@@ -332,35 +332,35 @@ fn shift_for_type(size_bytes: u8) -> usize {
332332
}
333333

334334
impl PrettyPrint for AMode {
335-
fn pretty_print(&self, size_bytes: u8, allocs: &mut AllocationConsumer) -> String {
335+
fn pretty_print(&self, size_bytes: u8) -> String {
336336
debug_assert!(size_bytes != 0);
337337
match self {
338338
&AMode::Unscaled { rn, simm9 } => {
339-
let reg = pretty_print_reg(rn, allocs);
339+
let reg = pretty_print_reg(rn);
340340
if simm9.value != 0 {
341-
let simm9 = simm9.pretty_print(8, allocs);
341+
let simm9 = simm9.pretty_print(8);
342342
format!("[{}, {}]", reg, simm9)
343343
} else {
344344
format!("[{}]", reg)
345345
}
346346
}
347347
&AMode::UnsignedOffset { rn, uimm12 } => {
348-
let reg = pretty_print_reg(rn, allocs);
348+
let reg = pretty_print_reg(rn);
349349
if uimm12.value() != 0 {
350-
let uimm12 = uimm12.pretty_print(8, allocs);
350+
let uimm12 = uimm12.pretty_print(8);
351351
format!("[{}, {}]", reg, uimm12)
352352
} else {
353353
format!("[{}]", reg)
354354
}
355355
}
356356
&AMode::RegReg { rn, rm } => {
357-
let r1 = pretty_print_reg(rn, allocs);
358-
let r2 = pretty_print_reg(rm, allocs);
357+
let r1 = pretty_print_reg(rn);
358+
let r2 = pretty_print_reg(rm);
359359
format!("[{}, {}]", r1, r2)
360360
}
361361
&AMode::RegScaled { rn, rm } => {
362-
let r1 = pretty_print_reg(rn, allocs);
363-
let r2 = pretty_print_reg(rm, allocs);
362+
let r1 = pretty_print_reg(rn);
363+
let r2 = pretty_print_reg(rm);
364364
let shift = shift_for_type(size_bytes);
365365
format!("[{}, {}, LSL #{}]", r1, r2, shift)
366366
}
@@ -370,28 +370,28 @@ impl PrettyPrint for AMode {
370370
ExtendOp::SXTW | ExtendOp::UXTW => OperandSize::Size32,
371371
_ => OperandSize::Size64,
372372
};
373-
let r1 = pretty_print_reg(rn, allocs);
374-
let r2 = pretty_print_ireg(rm, size, allocs);
375-
let op = extendop.pretty_print(0, allocs);
373+
let r1 = pretty_print_reg(rn);
374+
let r2 = pretty_print_ireg(rm, size);
375+
let op = extendop.pretty_print(0);
376376
format!("[{}, {}, {} #{}]", r1, r2, op, shift)
377377
}
378378
&AMode::RegExtended { rn, rm, extendop } => {
379379
let size = match extendop {
380380
ExtendOp::SXTW | ExtendOp::UXTW => OperandSize::Size32,
381381
_ => OperandSize::Size64,
382382
};
383-
let r1 = pretty_print_reg(rn, allocs);
384-
let r2 = pretty_print_ireg(rm, size, allocs);
385-
let op = extendop.pretty_print(0, allocs);
383+
let r1 = pretty_print_reg(rn);
384+
let r2 = pretty_print_ireg(rm, size);
385+
let op = extendop.pretty_print(0);
386386
format!("[{}, {}, {}]", r1, r2, op)
387387
}
388-
&AMode::Label { ref label } => label.pretty_print(0, allocs),
388+
&AMode::Label { ref label } => label.pretty_print(0),
389389
&AMode::SPPreIndexed { simm9 } => {
390-
let simm9 = simm9.pretty_print(8, allocs);
390+
let simm9 = simm9.pretty_print(8);
391391
format!("[sp, {}]!", simm9)
392392
}
393393
&AMode::SPPostIndexed { simm9 } => {
394-
let simm9 = simm9.pretty_print(8, allocs);
394+
let simm9 = simm9.pretty_print(8);
395395
format!("[sp], {}", simm9)
396396
}
397397
AMode::Const { addr } => format!("[const({})]", addr.as_u32()),
@@ -409,39 +409,39 @@ impl PrettyPrint for AMode {
409409
}
410410

411411
impl PrettyPrint for PairAMode {
412-
fn pretty_print(&self, _: u8, allocs: &mut AllocationConsumer) -> String {
412+
fn pretty_print(&self, _: u8) -> String {
413413
match self {
414414
&PairAMode::SignedOffset { reg, simm7 } => {
415-
let reg = pretty_print_reg(reg, allocs);
415+
let reg = pretty_print_reg(reg);
416416
if simm7.value != 0 {
417-
let simm7 = simm7.pretty_print(8, allocs);
417+
let simm7 = simm7.pretty_print(8);
418418
format!("[{}, {}]", reg, simm7)
419419
} else {
420420
format!("[{}]", reg)
421421
}
422422
}
423423
&PairAMode::SPPreIndexed { simm7 } => {
424-
let simm7 = simm7.pretty_print(8, allocs);
424+
let simm7 = simm7.pretty_print(8);
425425
format!("[sp, {}]!", simm7)
426426
}
427427
&PairAMode::SPPostIndexed { simm7 } => {
428-
let simm7 = simm7.pretty_print(8, allocs);
428+
let simm7 = simm7.pretty_print(8);
429429
format!("[sp], {}", simm7)
430430
}
431431
}
432432
}
433433
}
434434

435435
impl PrettyPrint for Cond {
436-
fn pretty_print(&self, _: u8, _: &mut AllocationConsumer) -> String {
436+
fn pretty_print(&self, _: u8) -> String {
437437
let mut s = format!("{:?}", self);
438438
s.make_ascii_lowercase();
439439
s
440440
}
441441
}
442442

443443
impl PrettyPrint for BranchTarget {
444-
fn pretty_print(&self, _: u8, _: &mut AllocationConsumer) -> String {
444+
fn pretty_print(&self, _: u8) -> String {
445445
match self {
446446
&BranchTarget::Label(label) => format!("label{:?}", label.get()),
447447
&BranchTarget::ResolvedOffset(off) => format!("{}", off),

cranelift/codegen/src/isa/aarch64/inst/emit.rs

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,7 @@ fn enc_cbr(op_31_24: u32, off_18_0: u32, op_4: u32, cond: u32) -> u32 {
165165
(op_31_24 << 24) | (off_18_0 << 5) | (op_4 << 4) | cond
166166
}
167167

168-
fn enc_conditional_br(
169-
taken: BranchTarget,
170-
kind: CondBrKind,
171-
_allocs: &mut AllocationConsumer,
172-
) -> u32 {
168+
fn enc_conditional_br(taken: BranchTarget, kind: CondBrKind) -> u32 {
173169
match kind {
174170
CondBrKind::Zero(reg) => enc_cmpbr(0b1_011010_0, taken.as_offset19_or_zero(), reg),
175171
CondBrKind::NotZero(reg) => enc_cmpbr(0b1_011010_1, taken.as_offset19_or_zero(), reg),
@@ -722,13 +718,11 @@ impl MachInstEmit for Inst {
722718

723719
fn emit(
724720
&self,
725-
allocs: &[Allocation],
721+
_allocs: &[Allocation],
726722
sink: &mut MachBuffer<Inst>,
727723
emit_info: &Self::Info,
728724
state: &mut EmitState,
729725
) {
730-
let mut allocs = AllocationConsumer::new(allocs);
731-
732726
// N.B.: we *must* not exceed the "worst-case size" used to compute
733727
// where to insert islands, except when islands are explicitly triggered
734728
// (with an `EmitIsland`). We check this in debug builds. This is `mut`
@@ -1626,7 +1620,6 @@ impl MachInstEmit for Inst {
16261620
sink.put4(enc_conditional_br(
16271621
BranchTarget::Label(again_label),
16281622
CondBrKind::NotZero(x24),
1629-
&mut AllocationConsumer::default(),
16301623
));
16311624
sink.use_label_at_offset(br_offset, again_label, LabelUse::Branch19);
16321625
}
@@ -1704,7 +1697,6 @@ impl MachInstEmit for Inst {
17041697
sink.put4(enc_conditional_br(
17051698
BranchTarget::Label(out_label),
17061699
CondBrKind::Cond(Cond::Ne),
1707-
&mut AllocationConsumer::default(),
17081700
));
17091701
sink.use_label_at_offset(br_out_offset, out_label, LabelUse::Branch19);
17101702

@@ -1721,7 +1713,6 @@ impl MachInstEmit for Inst {
17211713
sink.put4(enc_conditional_br(
17221714
BranchTarget::Label(again_label),
17231715
CondBrKind::NotZero(x24),
1724-
&mut AllocationConsumer::default(),
17251716
));
17261717
sink.use_label_at_offset(br_again_offset, again_label, LabelUse::Branch19);
17271718

@@ -2833,7 +2824,6 @@ impl MachInstEmit for Inst {
28332824
sink.put4(enc_conditional_br(
28342825
BranchTarget::Label(else_label),
28352826
CondBrKind::Cond(cond),
2836-
&mut AllocationConsumer::default(),
28372827
));
28382828
sink.use_label_at_offset(br_else_offset, else_label, LabelUse::Branch19);
28392829

@@ -2981,7 +2971,7 @@ impl MachInstEmit for Inst {
29812971
ref callee,
29822972
ref info,
29832973
} => {
2984-
emit_return_call_common_sequence(&mut allocs, sink, emit_info, state, info);
2974+
emit_return_call_common_sequence(sink, emit_info, state, info);
29852975

29862976
// Note: this is not `Inst::Jump { .. }.emit(..)` because we
29872977
// have different metadata in this case: we don't have a label
@@ -2996,7 +2986,7 @@ impl MachInstEmit for Inst {
29962986
start_off = sink.cur_offset();
29972987
}
29982988
&Inst::ReturnCallInd { callee, ref info } => {
2999-
emit_return_call_common_sequence(&mut allocs, sink, emit_info, state, info);
2989+
emit_return_call_common_sequence(sink, emit_info, state, info);
30002990

30012991
Inst::IndirectBr {
30022992
rn: callee,
@@ -3019,12 +3009,10 @@ impl MachInstEmit for Inst {
30193009
let cond_off = sink.cur_offset();
30203010
if let Some(l) = taken.as_label() {
30213011
sink.use_label_at_offset(cond_off, l, LabelUse::Branch19);
3022-
let mut allocs_inv = allocs.clone();
3023-
let inverted =
3024-
enc_conditional_br(taken, kind.invert(), &mut allocs_inv).to_le_bytes();
3012+
let inverted = enc_conditional_br(taken, kind.invert()).to_le_bytes();
30253013
sink.add_cond_branch(cond_off, cond_off + 4, l, &inverted[..]);
30263014
}
3027-
sink.put4(enc_conditional_br(taken, kind, &mut allocs));
3015+
sink.put4(enc_conditional_br(taken, kind));
30283016

30293017
// Unconditional part next.
30303018
let uncond_off = sink.cur_offset();
@@ -3063,11 +3051,7 @@ impl MachInstEmit for Inst {
30633051
let label = sink.defer_trap(trap_code, state.take_stack_map());
30643052
// condbr KIND, LABEL
30653053
let off = sink.cur_offset();
3066-
sink.put4(enc_conditional_br(
3067-
BranchTarget::Label(label),
3068-
kind,
3069-
&mut allocs,
3070-
));
3054+
sink.put4(enc_conditional_br(BranchTarget::Label(label), kind));
30713055
sink.use_label_at_offset(off, label, LabelUse::Branch19);
30723056
}
30733057
&Inst::IndirectBr { rn, .. } => {
@@ -3116,11 +3100,8 @@ impl MachInstEmit for Inst {
31163100
// the middle; we depend on hardcoded PC-rel addressing below.
31173101

31183102
// Branch to default when condition code from prior comparison indicates.
3119-
let br = enc_conditional_br(
3120-
BranchTarget::Label(default),
3121-
CondBrKind::Cond(Cond::Hs),
3122-
&mut AllocationConsumer::default(),
3123-
);
3103+
let br =
3104+
enc_conditional_br(BranchTarget::Label(default), CondBrKind::Cond(Cond::Hs));
31243105

31253106
// No need to inform the sink's branch folding logic about this branch, because it
31263107
// will not be merged with any other branch, flipped, or elided (it is not preceded
@@ -3568,14 +3549,12 @@ impl MachInstEmit for Inst {
35683549
state.clear_post_insn();
35693550
}
35703551

3571-
fn pretty_print_inst(&self, allocs: &[Allocation], state: &mut Self::State) -> String {
3572-
let mut allocs = AllocationConsumer::new(allocs);
3573-
self.print_with_state(state, &mut allocs)
3552+
fn pretty_print_inst(&self, _allocs: &[Allocation], state: &mut Self::State) -> String {
3553+
self.print_with_state(state)
35743554
}
35753555
}
35763556

35773557
fn emit_return_call_common_sequence(
3578-
_allocs: &mut AllocationConsumer,
35793558
sink: &mut MachBuffer<Inst>,
35803559
emit_info: &EmitInfo,
35813560
state: &mut EmitState,

cranelift/codegen/src/isa/aarch64/inst/emit_tests.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7863,8 +7863,7 @@ fn test_aarch64_binemit() {
78637863
);
78647864

78657865
// Check the printed text is as expected.
7866-
let actual_printing =
7867-
insn.print_with_state(&mut EmitState::default(), &mut AllocationConsumer::new(&[]));
7866+
let actual_printing = insn.print_with_state(&mut EmitState::default());
78687867
assert_eq!(expected_printing, actual_printing);
78697868

78707869
let mut buffer = MachBuffer::new();

0 commit comments

Comments
 (0)