MCPcopy Create free account
hub / github.com/Amanieu/regalloc3 / from_function

Method from_function

src/debug_utils/generic_function/mod.rs:94–145  ·  view source on GitHub ↗

Constructs a `GenericFunction` from an existing object which implements the [`Function`] trait.

(func: &impl Function)

Source from the content-addressed store, hash-verified

92 /// Constructs a `GenericFunction` from an existing object which implements
93 /// the [`Function`] trait.
94 pub fn from_function(func: &impl Function) -> Self {
95 let mut blocks = PrimaryMap::new();
96 let mut insts = PrimaryMap::new();
97 let mut values = PrimaryMap::new();
98 let mut value_groups = PrimaryMap::new();
99 let entry_points = func.entry_points().into();
100 for block in func.blocks() {
101 blocks.push(BlockData {
102 insts: func.block_insts(block),
103 preds: func.block_preds(block).into(),
104 succs: func.block_succs(block).into(),
105 block_params_in: func.block_params(block).into(),
106 block_params_out: func.jump_blockparams(block).into(),
107 frequency: func.block_frequency(block),
108 immediate_dominator: func.block_immediate_dominator(block).into(),
109 is_critical_edge: func.block_is_critical_edge(block),
110 });
111 }
112 for inst in func.insts() {
113 insts.push(InstData {
114 operands: func.inst_operands(inst).into(),
115 clobbers: func.inst_clobbers(inst).collect(),
116 block: func.inst_block(inst),
117 terminator_kind: func.terminator_kind(inst),
118 is_pure: func.can_eliminate_dead_inst(inst),
119 });
120 }
121 for value in func.values() {
122 let indirect_remat =
123 func.can_indirectly_rematerialize(value)
124 .map(|remat| IndirectRematData {
125 constraint: remat.constraint,
126 inputs: remat.inputs.into(),
127 allow_destination_overlap: remat.allow_destination_overlap,
128 });
129 values.push(ValueData {
130 bank: func.value_bank(value),
131 remat: func.can_rematerialize(value),
132 indirect_remat,
133 });
134 }
135 for group in func.value_groups() {
136 value_groups.push(func.value_group_members(group).into());
137 }
138 Self {
139 entry_points,
140 blocks,
141 insts,
142 values,
143 value_groups,
144 }
145 }
146}
147
148impl Function for GenericFunction {

Callers

nothing calls this directly

Calls 15

blocksMethod · 0.80
pushMethod · 0.80
instsMethod · 0.80
mapMethod · 0.80
value_groupsMethod · 0.80
entry_pointsMethod · 0.45
block_instsMethod · 0.45
block_predsMethod · 0.45
block_succsMethod · 0.45
block_paramsMethod · 0.45
jump_blockparamsMethod · 0.45
block_frequencyMethod · 0.45

Tested by

no test coverage detected