Constructs a `GenericFunction` from an existing object which implements the [`Function`] trait.
(func: &impl Function)
| 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 | |
| 148 | impl Function for GenericFunction { |
nothing calls this directly
no test coverage detected