Convert a single MIR basic block into an OOMIR basic block.
(
bb: BasicBlock,
bb_data: &BasicBlockData<'tcx>,
tcx: TyCtxt<'tcx>,
instance: Instance<'tcx>,
mir: &Body<'tcx>,
return_oomir_type: &oomir::Type, // Pass function return type
| 63 | data_types: &mut HashMap<String, oomir::DataType>, |
| 64 | instructions: &mut Vec<oomir::Instruction>, |
| 65 | temp_prefix: &str, |
| 66 | ) -> oomir::Operand { |
| 67 | let location_ty = tcx.caller_location_ty(); |
| 68 | let location_oomir_ty = super::types::ty_to_oomir_type(location_ty, tcx, data_types, instance); |
| 69 | let inherited_location = |
| 70 | instance |
| 71 | .def |
| 72 | .requires_caller_location(tcx) |
| 73 | .then(|| oomir::Operand::Variable { |
| 74 | name: oomir::CALLER_LOCATION_PARAM_NAME.to_string(), |
| 75 | ty: location_oomir_ty, |
| 76 | }); |
| 77 | |
| 78 | mir.caller_location_span(source_info, inherited_location, tcx, |span| { |
| 79 | let raw_location = super::operand::handle_const_value( |
| 80 | None, |
| 81 | tcx.span_as_caller_location(span), |
| 82 | &location_ty, |
| 83 | tcx, |
| 84 | data_types, |
| 85 | instance, |
| 86 | ); |
| 87 | super::value_repr::adapt_operand_to_rust_type( |
| 88 | raw_location, |
| 89 | location_ty, |
| 90 | temp_prefix, |
| 91 | tcx, |
| 92 | instance, |
| 93 | data_types, |
| 94 | instructions, |
| 95 | ) |
| 96 | }) |
| 97 | } |
| 98 | |
| 99 | fn emit_panic_lang_item<'tcx>( |
| 100 | lang_item: LangItem, |
| 101 | mut args: Vec<oomir::Operand>, |
| 102 | source_info: SourceInfo, |
| 103 | tcx: TyCtxt<'tcx>, |
| 104 | instance: Instance<'tcx>, |
| 105 | mir: &Body<'tcx>, |
| 106 | data_types: &mut HashMap<String, oomir::DataType>, |
| 107 | instructions: &mut Vec<oomir::Instruction>, |
| 108 | temp_prefix: &str, |
| 109 | ) { |
| 110 | let panic_def = tcx.require_lang_item(lang_item, source_info.span); |
| 111 | let panic_instance = Instance::mono(tcx, panic_def); |
| 112 | args.push(caller_location_operand( |
| 113 | source_info, |
| 114 | tcx, |
| 115 | instance, |
| 116 | mir, |
| 117 | data_types, |
| 118 | instructions, |
| 119 | temp_prefix, |
| 120 | )); |
| 121 | let target = super::naming::mono_fn_name_from_instance(tcx, panic_instance); |
| 122 | let params = args |
no test coverage detected