Skip to content

Commit a8a2cc4

Browse files
committed
Rename AssignmentCopySource to CopySourceAssignment
This aligns better with `OperandAssignment` and just sounds better to me now.
1 parent 59b2464 commit a8a2cc4

File tree

9 files changed

+61
-61
lines changed

9 files changed

+61
-61
lines changed

crates/codegen/src/emit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
code_buffer::{CodeBlob, CodeBuffer, Label},
66
lir::Lir,
77
machine::MachineEmit,
8-
regalloc::{Assignment, AssignmentCopySource, InstrOrCopy},
8+
regalloc::{Assignment, CopySourceAssignment, InstrOrCopy},
99
};
1010

1111
pub type BlockLabelMap = SecondaryMap<Block, Label>;
@@ -44,10 +44,10 @@ pub fn emit_code<M: MachineEmit>(
4444
);
4545
}
4646
InstrOrCopy::Copy(copy) => match copy.from {
47-
AssignmentCopySource::Operand(from) => {
47+
CopySourceAssignment::Operand(from) => {
4848
machine.emit_copy(&mut state, &mut buffer, from, copy.to)
4949
}
50-
AssignmentCopySource::Remat(instr) => machine.emit_instr(
50+
CopySourceAssignment::Remat(instr) => machine.emit_instr(
5151
&mut state,
5252
&mut buffer,
5353
&block_labels,

crates/codegen/src/regalloc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ mod test_utils;
3131

3232
pub use display::{DisplayAssignment, DisplayOperandAssignment};
3333
pub use types::{
34-
AssignmentCopy, AssignmentCopySource, BlockExitGhostCopy, OperandAssignment, SpillSlot,
34+
AssignmentCopy, BlockExitGhostCopy, CopySourceAssignment, OperandAssignment, SpillSlot,
3535
SpillSlotData, TaggedAssignmentCopy,
3636
};
3737

crates/codegen/src/regalloc/display.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::{
1414
machine::MachineCore,
1515
};
1616

17-
use super::{types::AssignmentCopySource, Assignment, InstrOrCopy, OperandAssignment};
17+
use super::{types::CopySourceAssignment, Assignment, InstrOrCopy, OperandAssignment};
1818

1919
pub struct DisplayOperandAssignment<M: MachineCore> {
2020
pub(super) assignment: OperandAssignment,
@@ -32,14 +32,14 @@ impl<M: MachineCore> fmt::Display for DisplayOperandAssignment<M> {
3232

3333
pub struct DisplayAssignmentCopySource<'a, M: MachineCore> {
3434
pub(super) lir: &'a Lir<M>,
35-
pub(super) source: AssignmentCopySource,
35+
pub(super) source: CopySourceAssignment,
3636
}
3737

3838
impl<M: MachineCore> fmt::Display for DisplayAssignmentCopySource<'_, M> {
3939
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4040
match self.source {
41-
AssignmentCopySource::Operand(assignment) => write!(f, "{}", assignment.display::<M>()),
42-
AssignmentCopySource::Remat(instr) => write!(f, "{:?}", self.lir.instr_data(instr)),
41+
CopySourceAssignment::Operand(assignment) => write!(f, "{}", assignment.display::<M>()),
42+
CopySourceAssignment::Remat(instr) => write!(f, "{:?}", self.lir.instr_data(instr)),
4343
}
4444
}
4545
}

crates/codegen/src/regalloc/parallel_copy.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use smallvec::{smallvec, SmallVec};
33
use crate::lir::{Instr, PhysReg};
44

55
use super::{
6-
types::{AssignmentCopy, AssignmentCopySource, ParallelCopy},
6+
types::{AssignmentCopy, CopySourceAssignment, ParallelCopy},
77
OperandAssignment, SpillSlot,
88
};
99

@@ -21,7 +21,7 @@ pub fn resolve(
2121
let mut operands = SmallVec::<[OperandAssignment; 16]>::new();
2222

2323
for copy in parallel_copies {
24-
if let AssignmentCopySource::Operand(from) = copy.from {
24+
if let CopySourceAssignment::Operand(from) = copy.from {
2525
operands.push(from);
2626
}
2727
operands.push(copy.to);
@@ -36,7 +36,7 @@ pub fn resolve(
3636
for copy in parallel_copies {
3737
let to = find_operand(&operands, copy.to);
3838
match copy.from {
39-
AssignmentCopySource::Operand(from) => {
39+
CopySourceAssignment::Operand(from) => {
4040
let from = find_operand(&operands, from);
4141
debug_assert!(
4242
copy_sources[to].is_none(),
@@ -45,7 +45,7 @@ pub fn resolve(
4545

4646
copy_sources[to] = Some(TrackedCopySource::Operand(from as u32));
4747
}
48-
AssignmentCopySource::Remat(instr) => {
48+
CopySourceAssignment::Remat(instr) => {
4949
copy_sources[to] = Some(TrackedCopySource::Remat(instr));
5050
}
5151
}
@@ -84,7 +84,7 @@ pub fn resolve(
8484
TrackedCopySource::Remat(instr) => {
8585
// Remats always terminate the current chain as they can never be
8686
// copied out of a different assignment.
87-
ctx.emit(AssignmentCopySource::Remat(instr), operands[operand]);
87+
ctx.emit(CopySourceAssignment::Remat(instr), operands[operand]);
8888
break;
8989
}
9090
}
@@ -109,7 +109,7 @@ pub fn resolve(
109109

110110
// Insert the final copy out of the temporary here (resolved assignments are in
111111
// reverse order).
112-
ctx.emit(AssignmentCopySource::Operand(tmp_op), operands[prev]);
112+
ctx.emit(CopySourceAssignment::Operand(tmp_op), operands[prev]);
113113

114114
break;
115115
}
@@ -130,15 +130,15 @@ pub fn resolve(
130130
if let Some(src) = last_copy_src {
131131
let from = operands[src];
132132
let to = operands[operand];
133-
ctx.emit(AssignmentCopySource::Operand(from), to);
133+
ctx.emit(CopySourceAssignment::Operand(from), to);
134134
}
135135

136136
match copy_cycle_break {
137137
Some((cycle_operand, tmp_op)) if cycle_operand == operand => {
138138
// We've found the start of a broken parallel copy cycle - make sure the
139139
// original value of `operand` is saved before it is overwritten by the copy
140140
// inserted above.
141-
ctx.emit(AssignmentCopySource::Operand(operands[operand]), tmp_op);
141+
ctx.emit(CopySourceAssignment::Operand(operands[operand]), tmp_op);
142142
}
143143
_ => {}
144144
}
@@ -214,7 +214,7 @@ impl<'s, S: RegScavenger> ResolvedCopyContext<'s, S> {
214214
}
215215
}
216216

217-
fn emit(&mut self, from: AssignmentCopySource, to: OperandAssignment) {
217+
fn emit(&mut self, from: CopySourceAssignment, to: OperandAssignment) {
218218
if from.is_reg() || to.is_reg() {
219219
// Copies involving at least one register can be performed directly.
220220
self.emit_raw(from, to);
@@ -231,7 +231,7 @@ impl<'s, S: RegScavenger> ResolvedCopyContext<'s, S> {
231231

232232
// Restore the original value of `tmp_reg` from the emergency spill.
233233
self.emit_raw(
234-
AssignmentCopySource::Operand(OperandAssignment::Spill(
234+
CopySourceAssignment::Operand(OperandAssignment::Spill(
235235
emergency_spill,
236236
)),
237237
OperandAssignment::Reg(tmp_reg),
@@ -242,7 +242,7 @@ impl<'s, S: RegScavenger> ResolvedCopyContext<'s, S> {
242242
};
243243

244244
self.emit_raw(
245-
AssignmentCopySource::Operand(OperandAssignment::Reg(tmp_reg)),
245+
CopySourceAssignment::Operand(OperandAssignment::Reg(tmp_reg)),
246246
to,
247247
);
248248
self.emit_raw(from, OperandAssignment::Reg(tmp_reg));
@@ -251,14 +251,14 @@ impl<'s, S: RegScavenger> ResolvedCopyContext<'s, S> {
251251
// If we're using an emergency spill, back up the original value of `tmp_reg` before
252252
// using it.
253253
self.emit_raw(
254-
AssignmentCopySource::Operand(OperandAssignment::Reg(tmp_reg)),
254+
CopySourceAssignment::Operand(OperandAssignment::Reg(tmp_reg)),
255255
OperandAssignment::Spill(emergency_spill),
256256
);
257257
}
258258
}
259259
}
260260

261-
fn emit_raw(&mut self, from: AssignmentCopySource, to: OperandAssignment) {
261+
fn emit_raw(&mut self, from: CopySourceAssignment, to: OperandAssignment) {
262262
self.copies.push(AssignmentCopy { from, to });
263263
}
264264
}
@@ -352,7 +352,7 @@ mod tests {
352352
};
353353

354354
for copy in &parallel_copies {
355-
if let AssignmentCopySource::Operand(OperandAssignment::Reg(from)) = copy.from {
355+
if let CopySourceAssignment::Operand(OperandAssignment::Reg(from)) = copy.from {
356356
scavenger.used_regs.insert(from);
357357
}
358358
if let OperandAssignment::Reg(to) = copy.to {

crates/codegen/src/regalloc/redundant_copy.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use fx_utils::FxHashMap;
22
use smallvec::SmallVec;
33

4-
use super::{types::AssignmentCopySource, AssignmentCopy, OperandAssignment};
4+
use super::{types::CopySourceAssignment, AssignmentCopy, OperandAssignment};
55

66
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
77
pub enum RedundantCopyVerdict {
@@ -11,8 +11,8 @@ pub enum RedundantCopyVerdict {
1111

1212
#[derive(Default)]
1313
pub struct RedundantCopyTracker {
14-
copy_sources: FxHashMap<OperandAssignment, AssignmentCopySource>,
15-
copy_targets: FxHashMap<AssignmentCopySource, SmallVec<[OperandAssignment; 4]>>,
14+
copy_sources: FxHashMap<OperandAssignment, CopySourceAssignment>,
15+
copy_targets: FxHashMap<CopySourceAssignment, SmallVec<[OperandAssignment; 4]>>,
1616
}
1717

1818
impl RedundantCopyTracker {
@@ -27,7 +27,7 @@ impl RedundantCopyTracker {
2727

2828
pub fn process_copy(&mut self, copy: &AssignmentCopy) -> RedundantCopyVerdict {
2929
let from = match copy.from {
30-
AssignmentCopySource::Operand(from) => self.assignment_source(from),
30+
CopySourceAssignment::Operand(from) => self.assignment_source(from),
3131
from => from,
3232
};
3333
let to = self.assignment_source(copy.to);
@@ -50,19 +50,19 @@ impl RedundantCopyTracker {
5050
fn remove_copies_from(&mut self, assignment: OperandAssignment) {
5151
if let Some(targets) = self
5252
.copy_targets
53-
.remove(&AssignmentCopySource::Operand(assignment))
53+
.remove(&CopySourceAssignment::Operand(assignment))
5454
{
5555
for target in targets {
5656
self.copy_sources.remove(&target);
5757
}
5858
}
5959
}
6060

61-
fn assignment_source(&self, assignment: OperandAssignment) -> AssignmentCopySource {
61+
fn assignment_source(&self, assignment: OperandAssignment) -> CopySourceAssignment {
6262
self.copy_sources
6363
.get(&assignment)
6464
.copied()
65-
.unwrap_or(AssignmentCopySource::Operand(assignment))
65+
.unwrap_or(CopySourceAssignment::Operand(assignment))
6666
}
6767
}
6868

crates/codegen/src/regalloc/reify.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use super::{
2323
parallel_copy::{self, RegScavenger},
2424
redundant_copy::{RedundantCopyTracker, RedundantCopyVerdict},
2525
types::{
26-
AssignmentCopySource, BlockExitGhostCopy, InstrSlot, LiveRange, ParallelCopies,
26+
BlockExitGhostCopy, CopySourceAssignment, InstrSlot, LiveRange, ParallelCopies,
2727
ParallelCopy, ParallelCopyPhase, ProgramPoint, TaggedAssignmentCopy,
2828
},
2929
Assignment, InstrAssignmentData, OperandAssignment, SpillSlot, SpillSlotData,
@@ -38,7 +38,7 @@ struct BlockParamEdgeKey {
3838
to_vreg: VirtReg,
3939
}
4040

41-
type BlockParamOutMap = FxHashMap<BlockParamEdgeKey, (VirtReg, AssignmentCopySource)>;
41+
type BlockParamOutMap = FxHashMap<BlockParamEdgeKey, (VirtReg, CopySourceAssignment)>;
4242

4343
struct BlockParamIn {
4444
block: Block,
@@ -53,10 +53,10 @@ fn record_parallel_copy(
5353
instr: Instr,
5454
phase: ParallelCopyPhase,
5555
class: RegClass,
56-
from: AssignmentCopySource,
56+
from: CopySourceAssignment,
5757
to: OperandAssignment,
5858
) {
59-
if from != AssignmentCopySource::Operand(to) {
59+
if from != CopySourceAssignment::Operand(to) {
6060
copies.push(ParallelCopy {
6161
instr,
6262
phase,
@@ -153,7 +153,7 @@ impl<M: MachineRegalloc> RegAllocContext<'_, M> {
153153
Instr::new(0),
154154
ParallelCopyPhase::Before,
155155
self.lir.vreg_class(block_param),
156-
AssignmentCopySource::Operand(OperandAssignment::Reg(preg)),
156+
CopySourceAssignment::Operand(OperandAssignment::Reg(preg)),
157157
assignment,
158158
);
159159
}
@@ -193,8 +193,8 @@ impl<M: MachineRegalloc> RegAllocContext<'_, M> {
193193
) {
194194
trace!("collecting intra-block copies: {vreg}");
195195

196-
let mut cur_spill: Option<(LiveRange, AssignmentCopySource)> = None;
197-
let mut last_canonical_range: Option<(LiveRange, AssignmentCopySource)> = None;
196+
let mut cur_spill: Option<(LiveRange, CopySourceAssignment)> = None;
197+
let mut last_canonical_range: Option<(LiveRange, CopySourceAssignment)> = None;
198198

199199
for &range in ranges {
200200
let range_assignment = self.get_range_assignment(range);
@@ -280,7 +280,7 @@ impl<M: MachineRegalloc> RegAllocContext<'_, M> {
280280
instr.next(),
281281
ParallelCopyPhase::Before,
282282
class,
283-
AssignmentCopySource::Operand(range_assignment),
283+
CopySourceAssignment::Operand(range_assignment),
284284
OperandAssignment::Spill(spill),
285285
);
286286
}
@@ -432,7 +432,7 @@ impl<M: MachineRegalloc> RegAllocContext<'_, M> {
432432
panic!("vreg {vreg} not live-out across edge {pred} -> {block}");
433433
};
434434

435-
if pred_assignment == AssignmentCopySource::Operand(assignment) {
435+
if pred_assignment == CopySourceAssignment::Operand(assignment) {
436436
// Nothing to copy here, don't bother trying to figure out where.
437437
continue;
438438
}
@@ -553,7 +553,7 @@ impl<M: MachineRegalloc> RegAllocContext<'_, M> {
553553
instr.next(),
554554
ParallelCopyPhase::Before,
555555
self.lir.vreg_class(vreg),
556-
AssignmentCopySource::Operand(OperandAssignment::Reg(preg)),
556+
CopySourceAssignment::Operand(OperandAssignment::Reg(preg)),
557557
range_assignment,
558558
);
559559
} else {
@@ -596,7 +596,7 @@ impl<M: MachineRegalloc> RegAllocContext<'_, M> {
596596
instr,
597597
ParallelCopyPhase::PreCopy,
598598
self.lir.vreg_class(vreg),
599-
AssignmentCopySource::Operand(range_assignment),
599+
CopySourceAssignment::Operand(range_assignment),
600600
OperandAssignment::Reg(preg),
601601
);
602602
}
@@ -609,7 +609,7 @@ impl<M: MachineRegalloc> RegAllocContext<'_, M> {
609609
instr,
610610
ParallelCopyPhase::PreCopy,
611611
self.lir.vreg_class(vreg),
612-
AssignmentCopySource::Operand(range_assignment),
612+
CopySourceAssignment::Operand(range_assignment),
613613
def_assignment,
614614
);
615615
assignment.assign_instr_use(instr, i, def_assignment);
@@ -657,10 +657,10 @@ impl<M: MachineRegalloc> RegAllocContext<'_, M> {
657657
.expect("expected range assignment to be an operand")
658658
}
659659

660-
fn get_range_assignment(&self, range: LiveRange) -> AssignmentCopySource {
660+
fn get_range_assignment(&self, range: LiveRange) -> CopySourceAssignment {
661661
let fragment_data = &self.live_set_fragments[self.live_ranges[range].fragment];
662662
match fragment_data.assignment.expand() {
663-
Some(preg) => AssignmentCopySource::Operand(OperandAssignment::Reg(preg)),
663+
Some(preg) => CopySourceAssignment::Operand(OperandAssignment::Reg(preg)),
664664
None => {
665665
debug_assert!(fragment_data.flags.contains(LiveSetFragmentFlags::SPILLED));
666666

@@ -670,7 +670,7 @@ impl<M: MachineRegalloc> RegAllocContext<'_, M> {
670670
{
671671
let vreg = self.live_ranges[range].vreg;
672672
let def_instr = self.remattable_vreg_defs[vreg].unwrap();
673-
return AssignmentCopySource::Remat(def_instr);
673+
return CopySourceAssignment::Remat(def_instr);
674674
}
675675

676676
let live_set_data = &self.live_sets[fragment_data.live_set];
@@ -688,7 +688,7 @@ impl<M: MachineRegalloc> RegAllocContext<'_, M> {
688688
);
689689
}
690690

691-
AssignmentCopySource::Operand(OperandAssignment::Spill(
691+
CopySourceAssignment::Operand(OperandAssignment::Spill(
692692
self.live_sets[fragment_data.live_set].spill_slot.unwrap(),
693693
))
694694
}
@@ -846,7 +846,7 @@ impl<'a, M: MachineRegalloc> AssignedRegScavenger<'a, M> {
846846
// before `pos`. Destinations need to be marked as used for correct behavior with block
847847
// live-outs and outgoing params, which might not be live at all at `pos`.
848848
for copy in copies {
849-
if let AssignmentCopySource::Operand(OperandAssignment::Reg(from)) = copy.from {
849+
if let CopySourceAssignment::Operand(OperandAssignment::Reg(from)) = copy.from {
850850
self.used_tmp_regs.insert(from);
851851
}
852852
if let OperandAssignment::Reg(to) = copy.to {

0 commit comments

Comments
 (0)