Build the switch # Arguments The function builder to emit to The value to switch on The default block
(self, bx: &mut FunctionBuilder, val: Value, otherwise: Block)
| 265 | /// * The value to switch on |
| 266 | /// * The default block |
| 267 | pub fn emit(self, bx: &mut FunctionBuilder, val: Value, otherwise: Block) { |
| 268 | // Validate that the type of `val` is sufficiently wide to address all cases. |
| 269 | let max = self.cases.keys().max().copied().unwrap_or(0); |
| 270 | let val_ty = bx.func.dfg.value_type(val); |
| 271 | let val_ty_max = val_ty.bounds(false).1; |
| 272 | if max > val_ty_max { |
| 273 | panic!("The index type {val_ty} does not fit the maximum switch entry of {max}"); |
| 274 | } |
| 275 | |
| 276 | let contiguous_case_ranges = self.collect_contiguous_case_ranges(); |
| 277 | Self::build_search_tree(bx, val, otherwise, &contiguous_case_ranges); |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | fn icmp_imm_u128(bx: &mut FunctionBuilder, cond: IntCC, x: Value, y: u128) -> Value { |