Assign a valid sequence number to `inst` such that the numbers are still monotonic. This may require renumbering.
(&mut self, inst: Inst)
| 128 | /// Assign a valid sequence number to `inst` such that the numbers are still monotonic. This may |
| 129 | /// require renumbering. |
| 130 | fn assign_inst_seq(&mut self, inst: Inst) { |
| 131 | // Get the sequence number immediately before `inst`. |
| 132 | let prev_seq = match self.insts[inst].prev.expand() { |
| 133 | Some(prev_inst) => self.insts[prev_inst].seq, |
| 134 | None => 0, |
| 135 | }; |
| 136 | |
| 137 | // Get the sequence number immediately following `inst`. |
| 138 | let next_seq = if let Some(next_inst) = self.insts[inst].next.expand() { |
| 139 | self.insts[next_inst].seq |
| 140 | } else { |
| 141 | // There is nothing after `inst`. We can just use a major stride. |
| 142 | self.insts[inst].seq = prev_seq + MAJOR_STRIDE; |
| 143 | return; |
| 144 | }; |
| 145 | |
| 146 | // Check if there is room between these sequence numbers. |
| 147 | if let Some(seq) = midpoint(prev_seq, next_seq) { |
| 148 | self.insts[inst].seq = seq; |
| 149 | } else { |
| 150 | // No available integers between `prev_seq` and `next_seq`. We have to renumber. |
| 151 | self.renumber_insts(inst, prev_seq + MINOR_STRIDE, prev_seq + LOCAL_LIMIT); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | /// Renumber instructions starting from `inst` until the end of the block or until numbers catch |
| 156 | /// up. |
no test coverage detected