Skip to content

Commit 479e8af

Browse files
Firestar99LegNeato
authored andcommitted
cargo fmt, newer stable added more reformatting
1 parent 88976b8 commit 479e8af

15 files changed

+151
-200
lines changed

src/cfg.rs

+39-56
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
33
use crate::transform::{InnerInPlaceTransform as _, Transformer};
44
use crate::{
5-
spv, AttrSet, Const, ConstDef, ConstKind, Context, ControlNode, ControlNodeDef,
6-
ControlNodeKind, ControlNodeOutputDecl, ControlRegion, ControlRegionDef,
7-
EntityOrientedDenseMap, FuncDefBody, FxIndexMap, FxIndexSet, SelectionKind, Type, TypeKind,
8-
Value,
5+
AttrSet, Const, ConstDef, ConstKind, Context, ControlNode, ControlNodeDef, ControlNodeKind,
6+
ControlNodeOutputDecl, ControlRegion, ControlRegionDef, EntityOrientedDenseMap, FuncDefBody,
7+
FxIndexMap, FxIndexSet, SelectionKind, Type, TypeKind, Value, spv,
98
};
109
use itertools::{Either, Itertools};
1110
use smallvec::SmallVec;
@@ -85,20 +84,17 @@ impl ControlFlowGraph {
8584
func_def_body: &FuncDefBody,
8685
) -> impl DoubleEndedIterator<Item = ControlRegion> {
8786
let mut post_order = SmallVec::<[_; 8]>::new();
88-
self.traverse_whole_func(
89-
func_def_body,
90-
&mut TraversalState {
91-
incoming_edge_counts: EntityOrientedDenseMap::new(),
87+
self.traverse_whole_func(func_def_body, &mut TraversalState {
88+
incoming_edge_counts: EntityOrientedDenseMap::new(),
9289

93-
pre_order_visit: |_| {},
94-
post_order_visit: |region| post_order.push(region),
90+
pre_order_visit: |_| {},
91+
post_order_visit: |region| post_order.push(region),
9592

96-
// NOTE(eddyb) this doesn't impact semantics, but combined with
97-
// the final reversal, it should keep targets in the original
98-
// order in the cases when they didn't get deduplicated.
99-
reverse_targets: true,
100-
},
101-
);
93+
// NOTE(eddyb) this doesn't impact semantics, but combined with
94+
// the final reversal, it should keep targets in the original
95+
// order in the cases when they didn't get deduplicated.
96+
reverse_targets: true,
97+
});
10298
post_order.into_iter().rev()
10399
}
104100
}
@@ -912,13 +908,10 @@ impl DeferredEdgeBundleSet {
912908
Err(new_deferred) => {
913909
assert!(new_deferred.edge_bundle.target == target);
914910
assert!(matches!(new_deferred.condition, LazyCond::True));
915-
(
916-
None,
917-
DeferredEdgeBundleSet::Always {
918-
target,
919-
edge_bundle: new_deferred.edge_bundle.with_target(()),
920-
},
921-
)
911+
(None, DeferredEdgeBundleSet::Always {
912+
target,
913+
edge_bundle: new_deferred.edge_bundle.with_target(()),
914+
})
922915
}
923916
}
924917
}
@@ -927,17 +920,14 @@ impl DeferredEdgeBundleSet {
927920
for (i, (&target, deferred)) in target_to_deferred.iter_mut().enumerate() {
928921
// HACK(eddyb) "take" `deferred` so it can be passed to
929922
// `matches` (and put back if that returned `Err`).
930-
let taken_deferred = mem::replace(
931-
deferred,
932-
DeferredEdgeBundle {
933-
condition: LazyCond::False,
934-
edge_bundle: IncomingEdgeBundle {
935-
target: Default::default(),
936-
accumulated_count: Default::default(),
937-
target_inputs: Default::default(),
938-
},
923+
let taken_deferred = mem::replace(deferred, DeferredEdgeBundle {
924+
condition: LazyCond::False,
925+
edge_bundle: IncomingEdgeBundle {
926+
target: Default::default(),
927+
accumulated_count: Default::default(),
928+
target_inputs: Default::default(),
939929
},
940-
);
930+
});
941931

942932
match matches(taken_deferred.with_target(target)) {
943933
Ok(x) => {
@@ -1123,16 +1113,13 @@ impl<'a> Structurizer<'a> {
11231113
// in the general case (but special-cased because this is very
11241114
// close to being structurizable, just needs a bit of plumbing).
11251115
let mut control_inst_on_exit_from = EntityOrientedDenseMap::new();
1126-
control_inst_on_exit_from.insert(
1127-
self.func_def_body.body,
1128-
ControlInst {
1129-
attrs: AttrSet::default(),
1130-
kind: ControlInstKind::Unreachable,
1131-
inputs: [].into_iter().collect(),
1132-
targets: [].into_iter().collect(),
1133-
target_inputs: FxIndexMap::default(),
1134-
},
1135-
);
1116+
control_inst_on_exit_from.insert(self.func_def_body.body, ControlInst {
1117+
attrs: AttrSet::default(),
1118+
kind: ControlInstKind::Unreachable,
1119+
inputs: [].into_iter().collect(),
1120+
targets: [].into_iter().collect(),
1121+
target_inputs: FxIndexMap::default(),
1122+
});
11361123
self.func_def_body.unstructured_cfg = Some(ControlFlowGraph {
11371124
control_inst_on_exit_from,
11381125
loop_merge_to_loop_header: Default::default(),
@@ -1148,15 +1135,13 @@ impl<'a> Structurizer<'a> {
11481135

11491136
_ => {
11501137
// Repair all the regions that remain unclaimed, including the body.
1151-
let structurize_region_state =
1152-
mem::take(&mut self.structurize_region_state).into_iter().chain([(
1153-
self.func_def_body.body,
1154-
StructurizeRegionState::Ready {
1155-
accumulated_backedge_count: IncomingEdgeCount::default(),
1138+
let structurize_region_state = mem::take(&mut self.structurize_region_state)
1139+
.into_iter()
1140+
.chain([(self.func_def_body.body, StructurizeRegionState::Ready {
1141+
accumulated_backedge_count: IncomingEdgeCount::default(),
11561142

1157-
region_deferred_edges: func_body_deferred_edges,
1158-
},
1159-
)]);
1143+
region_deferred_edges: func_body_deferred_edges,
1144+
})]);
11601145
for (target, state) in structurize_region_state {
11611146
if let StructurizeRegionState::Ready { region_deferred_edges, .. } = state {
11621147
self.rebuild_cfg_from_unclaimed_region_deferred_edges(
@@ -1559,13 +1544,11 @@ impl<'a> Structurizer<'a> {
15591544
.map(|backedge| backedge.accumulated_count)
15601545
.unwrap_or_default();
15611546

1562-
let old_state = self.structurize_region_state.insert(
1563-
region,
1564-
StructurizeRegionState::Ready {
1547+
let old_state =
1548+
self.structurize_region_state.insert(region, StructurizeRegionState::Ready {
15651549
accumulated_backedge_count,
15661550
region_deferred_edges: deferred_edges,
1567-
},
1568-
);
1551+
});
15691552
if !matches!(old_state, Some(StructurizeRegionState::InProgress)) {
15701553
unreachable!(
15711554
"cfg::Structurizer::structurize_region: \

src/cfgssa.rs

+8-14
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,10 @@ impl<'a, BlockId: Copy + Eq + Hash, DefId: Copy + Eq + Hash, DefType: Copy>
228228
.map(|block_id| BlockIdx(self.def_map.blocks_by_id.get_index_of(&block_id).unwrap()));
229229

230230
if self.blocks[target_block_idx].preds.insert(source_block_idx) {
231-
self.add_uses_to(
232-
source_block_idx,
233-
AddUsesSource::PropagateBackwardsAcrossEdge {
234-
target: target_block_idx,
235-
only_dirty: false,
236-
},
237-
);
231+
self.add_uses_to(source_block_idx, AddUsesSource::PropagateBackwardsAcrossEdge {
232+
target: target_block_idx,
233+
only_dirty: false,
234+
});
238235
}
239236
}
240237

@@ -243,13 +240,10 @@ impl<'a, BlockId: Copy + Eq + Hash, DefId: Copy + Eq + Hash, DefType: Copy>
243240
for i in 0..self.blocks[block_idx].preds.len() {
244241
let pred_block_idx = self.blocks[block_idx].preds[i];
245242

246-
self.add_uses_to(
247-
pred_block_idx,
248-
AddUsesSource::PropagateBackwardsAcrossEdge {
249-
target: block_idx,
250-
only_dirty: true,
251-
},
252-
);
243+
self.add_uses_to(pred_block_idx, AddUsesSource::PropagateBackwardsAcrossEdge {
244+
target: block_idx,
245+
only_dirty: true,
246+
});
253247
}
254248
self.blocks[block_idx].dirty_chunks.clear();
255249
}

src/passes/legalize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::visit::{InnerVisit, Visitor};
22
use crate::{
3-
cfg, AttrSet, Const, Context, DataInstForm, DeclDef, Func, FxIndexSet, GlobalVar, Module, Type,
3+
AttrSet, Const, Context, DataInstForm, DeclDef, Func, FxIndexSet, GlobalVar, Module, Type, cfg,
44
};
55

66
/// Apply the [`cfg::Structurizer`] algorithm to all function definitions in `module`.

src/passes/qptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! [`QPtr`](crate::TypeKind::QPtr) transforms.
22
33
use crate::visit::{InnerVisit, Visitor};
4-
use crate::{qptr, DataInstForm};
54
use crate::{AttrSet, Const, Context, Func, FxIndexSet, GlobalVar, Module, Type};
5+
use crate::{DataInstForm, qptr};
66

77
pub fn lower_from_spv_ptrs(module: &mut Module, layout_config: &qptr::LayoutConfig) {
88
let cx = &module.cx();

src/print/mod.rs

+16-24
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ use crate::print::multiversion::Versions;
2424
use crate::qptr::{self, QPtrAttr, QPtrMemUsage, QPtrMemUsageKind, QPtrOp, QPtrUsage};
2525
use crate::visit::{InnerVisit, Visit, Visitor};
2626
use crate::{
27-
cfg, spv, AddrSpace, Attr, AttrSet, AttrSetDef, Const, ConstDef, ConstKind, Context,
28-
ControlNode, ControlNodeDef, ControlNodeKind, ControlNodeOutputDecl, ControlRegion,
29-
ControlRegionDef, ControlRegionInputDecl, DataInst, DataInstDef, DataInstForm, DataInstFormDef,
30-
DataInstKind, DeclDef, Diag, DiagLevel, DiagMsgPart, EntityListIter, ExportKey, Exportee, Func,
31-
FuncDecl, FuncParam, FxIndexMap, FxIndexSet, GlobalVar, GlobalVarDecl, GlobalVarDefBody,
32-
Import, Module, ModuleDebugInfo, ModuleDialect, OrdAssertEq, SelectionKind, Type, TypeDef,
33-
TypeKind, TypeOrConst, Value,
27+
AddrSpace, Attr, AttrSet, AttrSetDef, Const, ConstDef, ConstKind, Context, ControlNode,
28+
ControlNodeDef, ControlNodeKind, ControlNodeOutputDecl, ControlRegion, ControlRegionDef,
29+
ControlRegionInputDecl, DataInst, DataInstDef, DataInstForm, DataInstFormDef, DataInstKind,
30+
DeclDef, Diag, DiagLevel, DiagMsgPart, EntityListIter, ExportKey, Exportee, Func, FuncDecl,
31+
FuncParam, FxIndexMap, FxIndexSet, GlobalVar, GlobalVarDecl, GlobalVarDefBody, Import, Module,
32+
ModuleDebugInfo, ModuleDialect, OrdAssertEq, SelectionKind, Type, TypeDef, TypeKind,
33+
TypeOrConst, Value, cfg, spv,
3434
};
3535
use arrayvec::ArrayVec;
3636
use itertools::Either;
@@ -1839,10 +1839,9 @@ impl Print for spv::Dialect {
18391839
printer.pretty_spv_print_tokens_for_operand({
18401840
let mut tokens = spv::print::operand_from_imms(cap_imms(cap));
18411841
tokens.tokens.drain(..tokens.tokens.len() - 1);
1842-
assert!(matches!(
1843-
tokens.tokens[..],
1844-
[spv::print::Token::EnumerandName(_)]
1845-
));
1842+
assert!(matches!(tokens.tokens[..], [
1843+
spv::print::Token::EnumerandName(_)
1844+
]));
18461845
tokens
18471846
})
18481847
});
@@ -1971,12 +1970,8 @@ impl Print for spv::ModuleDebugInfo {
19711970
printer.pretty_string_literal(
19721971
&printer.cx[file],
19731972
),
1974-
pretty::join_space(
1975-
":",
1976-
[printer.pretty_string_literal(
1977-
contents,
1978-
)],
1979-
),
1973+
pretty::join_space(":", [printer
1974+
.pretty_string_literal(contents)]),
19801975
])
19811976
})
19821977
.map(|entry| {
@@ -2999,13 +2994,10 @@ impl Print for FuncAt<'_, ControlNode> {
29992994
let (inputs_header, body_suffix) = if !inputs.is_empty() {
30002995
let input_decls_and_uses =
30012996
inputs.iter().enumerate().map(|(input_idx, input)| {
3002-
(
3003-
input,
3004-
Value::ControlRegionInput {
3005-
region: *body,
3006-
input_idx: input_idx.try_into().unwrap(),
3007-
},
3008-
)
2997+
(input, Value::ControlRegionInput {
2998+
region: *body,
2999+
input_idx: input_idx.try_into().unwrap(),
3000+
})
30093001
});
30103002
(
30113003
pretty::join_comma_sep(

src/print/multiversion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Multi-version pretty-printing support (e.g. for comparing the IR between passes).
22
3-
use crate::print::pretty::{self, TextOp};
43
use crate::FxIndexMap;
4+
use crate::print::pretty::{self, TextOp};
55
use internal_iterator::{
66
FromInternalIterator, InternalIterator, IntoInternalIterator, IteratorExt,
77
};

src/qptr/analyze.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! [`QPtr`](crate::TypeKind::QPtr) usage analysis (for legalizing/lifting).
22
33
// HACK(eddyb) sharing layout code with other modules.
4-
use super::{layout::*, QPtrMemUsageKind};
4+
use super::{QPtrMemUsageKind, layout::*};
55

6-
use super::{shapes, QPtrAttr, QPtrMemUsage, QPtrOp, QPtrUsage};
6+
use super::{QPtrAttr, QPtrMemUsage, QPtrOp, QPtrUsage, shapes};
77
use crate::func_at::FuncAt;
88
use crate::visit::{InnerVisit, Visitor};
99
use crate::{

src/qptr/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use crate::qptr::shapes;
44
use crate::{
5-
spv, AddrSpace, Attr, Const, ConstKind, Context, Diag, FxIndexMap, Type, TypeKind, TypeOrConst,
5+
AddrSpace, Attr, Const, ConstKind, Context, Diag, FxIndexMap, Type, TypeKind, TypeOrConst, spv,
66
};
77
use itertools::Either;
88
use smallvec::SmallVec;

src/qptr/lift.rs

+19-25
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
use super::layout::*;
55

66
use crate::func_at::FuncAtMut;
7-
use crate::qptr::{shapes, QPtrAttr, QPtrMemUsage, QPtrMemUsageKind, QPtrOp, QPtrUsage};
7+
use crate::qptr::{QPtrAttr, QPtrMemUsage, QPtrMemUsageKind, QPtrOp, QPtrUsage, shapes};
88
use crate::transform::{InnerInPlaceTransform, InnerTransform, Transformed, Transformer};
99
use crate::{
10-
spv, AddrSpace, Attr, AttrSet, AttrSetDef, Const, ConstDef, ConstKind, Context, ControlNode,
10+
AddrSpace, Attr, AttrSet, AttrSetDef, Const, ConstDef, ConstKind, Context, ControlNode,
1111
ControlNodeKind, DataInst, DataInstDef, DataInstFormDef, DataInstKind, DeclDef, Diag,
1212
DiagLevel, EntityDefs, EntityOrientedDenseMap, Func, FuncDecl, FxIndexMap, GlobalVar,
13-
GlobalVarDecl, Module, Type, TypeDef, TypeKind, TypeOrConst, Value,
13+
GlobalVarDecl, Module, Type, TypeDef, TypeKind, TypeOrConst, Value, spv,
1414
};
1515
use smallvec::SmallVec;
1616
use std::cell::Cell;
@@ -520,15 +520,12 @@ impl LiftToSpvPtrInstsInFunc<'_> {
520520
_ => return Err(LiftError(Diag::bug(["non-Buffer pointee".into()]))),
521521
};
522522

523-
self.deferred_ptr_noops.insert(
524-
data_inst,
525-
DeferredPtrNoop {
526-
output_pointer: buf_ptr,
527-
output_pointer_addr_space: addr_space,
528-
output_pointee_layout: buf_data_layout,
529-
parent_block,
530-
},
531-
);
523+
self.deferred_ptr_noops.insert(data_inst, DeferredPtrNoop {
524+
output_pointer: buf_ptr,
525+
output_pointer_addr_space: addr_space,
526+
output_pointee_layout: buf_data_layout,
527+
parent_block,
528+
});
532529

533530
DataInstDef {
534531
// FIXME(eddyb) avoid the repeated call to `type_of_val`
@@ -557,10 +554,10 @@ impl LiftToSpvPtrInstsInFunc<'_> {
557554
last_field.mem_layout.fixed_base.size == 0
558555
&& last_field.mem_layout.dyn_unit_stride
559556
== Some(dyn_unit_stride)
560-
&& matches!(
561-
last_field.components,
562-
Components::Elements { fixed_len: None, .. }
563-
)
557+
&& matches!(last_field.components, Components::Elements {
558+
fixed_len: None,
559+
..
560+
})
564561
}) =>
565562
{
566563
u32::try_from(offsets.len() - 1).unwrap()
@@ -660,15 +657,12 @@ impl LiftToSpvPtrInstsInFunc<'_> {
660657
}
661658

662659
if access_chain_inputs.len() == 1 {
663-
self.deferred_ptr_noops.insert(
664-
data_inst,
665-
DeferredPtrNoop {
666-
output_pointer: base_ptr,
667-
output_pointer_addr_space: addr_space,
668-
output_pointee_layout: TypeLayout::Concrete(layout),
669-
parent_block,
670-
},
671-
);
660+
self.deferred_ptr_noops.insert(data_inst, DeferredPtrNoop {
661+
output_pointer: base_ptr,
662+
output_pointer_addr_space: addr_space,
663+
output_pointee_layout: TypeLayout::Concrete(layout),
664+
parent_block,
665+
});
672666
DataInstDef {
673667
// FIXME(eddyb) avoid the repeated call to `type_of_val`
674668
// (and the interning of a temporary `DataInstFormDef`),

src/qptr/lower.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
use super::layout::*;
55

66
use crate::func_at::FuncAtMut;
7-
use crate::qptr::{shapes, QPtrAttr, QPtrOp};
7+
use crate::qptr::{QPtrAttr, QPtrOp, shapes};
88
use crate::transform::{InnerInPlaceTransform, Transformed, Transformer};
99
use crate::{
10-
spv, AddrSpace, AttrSet, AttrSetDef, Const, ConstDef, ConstKind, Context, ControlNode,
10+
AddrSpace, AttrSet, AttrSetDef, Const, ConstDef, ConstKind, Context, ControlNode,
1111
ControlNodeKind, DataInst, DataInstDef, DataInstForm, DataInstFormDef, DataInstKind, Diag,
12-
FuncDecl, GlobalVarDecl, OrdAssertEq, Type, TypeKind, TypeOrConst, Value,
12+
FuncDecl, GlobalVarDecl, OrdAssertEq, Type, TypeKind, TypeOrConst, Value, spv,
1313
};
1414
use smallvec::SmallVec;
1515
use std::cell::Cell;

0 commit comments

Comments
 (0)