| ... | ... | @@ -188,7 +188,8 @@ struct ConstCastPtrSentinel { |
| 188 | 188 | static IrInstruction *ir_gen_node(IrBuilder *irb, AstNode *node, Scope *scope); |
| 189 | 189 | static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *scope, LVal lval, |
| 190 | 190 | ResultLoc *result_loc); |
| 191 | | static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, ZigType *expected_type); |
| 191 | static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *source_instr, |
| 192 | IrInstruction *value, ZigType *expected_type); |
| 192 | 193 | static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr, |
| 193 | 194 | ResultLoc *result_loc); |
| 194 | 195 | static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, Buf *msg); |
| ... | ... | @@ -11717,7 +11718,7 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so |
| 11717 | 11718 | |
| 11718 | 11719 | if (instr_is_comptime(value)) { |
| 11719 | 11720 | ZigType *payload_type = wanted_type->data.maybe.child_type; |
| 11720 | | IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type); |
| 11721 | IrInstruction *casted_payload = ir_implicit_cast(ira, source_instr, value, payload_type); |
| 11721 | 11722 | if (type_is_invalid(casted_payload->value.type)) |
| 11722 | 11723 | return ira->codegen->invalid_instruction; |
| 11723 | 11724 | |
| ... | ... | @@ -11760,7 +11761,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction |
| 11760 | 11761 | ZigType *payload_type = wanted_type->data.error_union.payload_type; |
| 11761 | 11762 | ZigType *err_set_type = wanted_type->data.error_union.err_set_type; |
| 11762 | 11763 | if (instr_is_comptime(value)) { |
| 11763 | | IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type); |
| 11764 | IrInstruction *casted_payload = ir_implicit_cast(ira, source_instr, value, payload_type); |
| 11764 | 11765 | if (type_is_invalid(casted_payload->value.type)) |
| 11765 | 11766 | return ira->codegen->invalid_instruction; |
| 11766 | 11767 | |
| ... | ... | @@ -11880,7 +11881,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so |
| 11880 | 11881 | { |
| 11881 | 11882 | assert(wanted_type->id == ZigTypeIdErrorUnion); |
| 11882 | 11883 | |
| 11883 | | IrInstruction *casted_value = ir_implicit_cast(ira, value, wanted_type->data.error_union.err_set_type); |
| 11884 | IrInstruction *casted_value = ir_implicit_cast(ira, source_instr, value, wanted_type->data.error_union.err_set_type); |
| 11884 | 11885 | |
| 11885 | 11886 | if (instr_is_comptime(casted_value)) { |
| 11886 | 11887 | ConstExprValue *val = ir_resolve_const(ira, casted_value, UndefBad); |
| ... | ... | @@ -12065,7 +12066,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 12065 | 12066 | enum_type = ir_resolve_union_tag_type(ira, target, target->value.type); |
| 12066 | 12067 | if (type_is_invalid(enum_type)) |
| 12067 | 12068 | return ira->codegen->invalid_instruction; |
| 12068 | | enum_target = ir_implicit_cast(ira, target, enum_type); |
| 12069 | enum_target = ir_implicit_cast(ira, source_instr, target, enum_type); |
| 12069 | 12070 | if (type_is_invalid(enum_target->value.type)) |
| 12070 | 12071 | return ira->codegen->invalid_instruction; |
| 12071 | 12072 | } else if (target->value.type->id == ZigTypeIdEnum) { |
| ... | ... | @@ -12161,7 +12162,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 12161 | 12162 | if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusZeroBitsKnown))) |
| 12162 | 12163 | return ira->codegen->invalid_instruction; |
| 12163 | 12164 | |
| 12164 | | IrInstruction *target = ir_implicit_cast(ira, uncasted_target, wanted_type->data.unionation.tag_type); |
| 12165 | IrInstruction *target = ir_implicit_cast(ira, source_instr, uncasted_target, wanted_type->data.unionation.tag_type); |
| 12165 | 12166 | if (type_is_invalid(target->value.type)) |
| 12166 | 12167 | return ira->codegen->invalid_instruction; |
| 12167 | 12168 | |
| ... | ... | @@ -12824,8 +12825,55 @@ static IrInstruction *ir_analyze_struct_literal_to_union(IrAnalyze *ira, IrInstr |
| 12824 | 12825 | return ira->codegen->invalid_instruction; |
| 12825 | 12826 | } |
| 12826 | 12827 | |
| 12828 | // Add a compile error and return ErrorSemanticAnalyzeFail if the pointer alignment does not work, |
| 12829 | // otherwise return ErrorNone. Does not emit any instructions. |
| 12830 | // Assumes that the pointer types have element types with the same ABI alignment. Avoids resolving the |
| 12831 | // pointer types' alignments if both of the pointer types are ABI aligned. |
| 12832 | static Error ir_cast_ptr_align(IrAnalyze *ira, IrInstruction *source_instr, ZigType *dest_ptr_type, |
| 12833 | ZigType *src_ptr_type, AstNode *src_source_node) |
| 12834 | { |
| 12835 | Error err; |
| 12836 | |
| 12837 | ir_assert(dest_ptr_type->id == ZigTypeIdPointer, source_instr); |
| 12838 | ir_assert(src_ptr_type->id == ZigTypeIdPointer, source_instr); |
| 12839 | |
| 12840 | if (dest_ptr_type->data.pointer.explicit_alignment == 0 && |
| 12841 | src_ptr_type->data.pointer.explicit_alignment == 0) |
| 12842 | { |
| 12843 | return ErrorNone; |
| 12844 | } |
| 12845 | |
| 12846 | if ((err = type_resolve(ira->codegen, dest_ptr_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) |
| 12847 | return ErrorSemanticAnalyzeFail; |
| 12848 | |
| 12849 | if ((err = type_resolve(ira->codegen, src_ptr_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) |
| 12850 | return ErrorSemanticAnalyzeFail; |
| 12851 | |
| 12852 | uint32_t wanted_align = get_ptr_align(ira->codegen, dest_ptr_type); |
| 12853 | uint32_t actual_align = get_ptr_align(ira->codegen, src_ptr_type); |
| 12854 | if (wanted_align > actual_align) { |
| 12855 | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("cast increases pointer alignment")); |
| 12856 | add_error_note(ira->codegen, msg, src_source_node, |
| 12857 | buf_sprintf("'%s' has alignment %" PRIu32, buf_ptr(&src_ptr_type->name), actual_align)); |
| 12858 | add_error_note(ira->codegen, msg, source_instr->source_node, |
| 12859 | buf_sprintf("'%s' has alignment %" PRIu32, buf_ptr(&dest_ptr_type->name), wanted_align)); |
| 12860 | return ErrorSemanticAnalyzeFail; |
| 12861 | } |
| 12862 | |
| 12863 | return ErrorNone; |
| 12864 | } |
| 12865 | |
| 12866 | static IrInstruction *ir_analyze_struct_value_field_value(IrAnalyze *ira, IrInstruction *source_instr, |
| 12867 | IrInstruction *struct_operand, TypeStructField *field) |
| 12868 | { |
| 12869 | IrInstruction *struct_ptr = ir_get_ref(ira, source_instr, struct_operand, true, false); |
| 12870 | IrInstruction *field_ptr = ir_analyze_struct_field_ptr(ira, source_instr, field, struct_ptr, |
| 12871 | struct_operand->value.type, false); |
| 12872 | return ir_get_deref(ira, source_instr, field_ptr, nullptr); |
| 12873 | } |
| 12874 | |
| 12827 | 12875 | static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_instr, |
| 12828 | | ZigType *wanted_type, IrInstruction *value, ResultLoc *result_loc) |
| 12876 | ZigType *wanted_type, IrInstruction *value) |
| 12829 | 12877 | { |
| 12830 | 12878 | Error err; |
| 12831 | 12879 | ZigType *actual_type = value->value.type; |
| ... | ... | @@ -12871,12 +12919,12 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 12871 | 12919 | if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node, |
| 12872 | 12920 | false).id == ConstCastResultIdOk) |
| 12873 | 12921 | { |
| 12874 | | return ir_analyze_optional_wrap(ira, source_instr, value, wanted_type, result_loc); |
| 12922 | return ir_analyze_optional_wrap(ira, source_instr, value, wanted_type, nullptr); |
| 12875 | 12923 | } else if (actual_type->id == ZigTypeIdComptimeInt || |
| 12876 | 12924 | actual_type->id == ZigTypeIdComptimeFloat) |
| 12877 | 12925 | { |
| 12878 | 12926 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_child_type, true)) { |
| 12879 | | return ir_analyze_optional_wrap(ira, source_instr, value, wanted_type, result_loc); |
| 12927 | return ir_analyze_optional_wrap(ira, source_instr, value, wanted_type, nullptr); |
| 12880 | 12928 | } else { |
| 12881 | 12929 | return ira->codegen->invalid_instruction; |
| 12882 | 12930 | } |
| ... | ... | @@ -12900,7 +12948,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 12900 | 12948 | wanted_child_type); |
| 12901 | 12949 | if (type_is_invalid(cast1->value.type)) |
| 12902 | 12950 | return ira->codegen->invalid_instruction; |
| 12903 | | return ir_analyze_optional_wrap(ira, source_instr, cast1, wanted_type, result_loc); |
| 12951 | return ir_analyze_optional_wrap(ira, source_instr, cast1, wanted_type, nullptr); |
| 12904 | 12952 | } |
| 12905 | 12953 | } |
| 12906 | 12954 | } |
| ... | ... | @@ -12910,12 +12958,12 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 12910 | 12958 | if (types_match_const_cast_only(ira, wanted_type->data.error_union.payload_type, actual_type, |
| 12911 | 12959 | source_node, false).id == ConstCastResultIdOk) |
| 12912 | 12960 | { |
| 12913 | | return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type, result_loc); |
| 12961 | return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type, nullptr); |
| 12914 | 12962 | } else if (actual_type->id == ZigTypeIdComptimeInt || |
| 12915 | 12963 | actual_type->id == ZigTypeIdComptimeFloat) |
| 12916 | 12964 | { |
| 12917 | 12965 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_type->data.error_union.payload_type, true)) { |
| 12918 | | return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type, result_loc); |
| 12966 | return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type, nullptr); |
| 12919 | 12967 | } else { |
| 12920 | 12968 | return ira->codegen->invalid_instruction; |
| 12921 | 12969 | } |
| ... | ... | @@ -12933,11 +12981,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 12933 | 12981 | actual_type->id == ZigTypeIdComptimeInt || |
| 12934 | 12982 | actual_type->id == ZigTypeIdComptimeFloat) |
| 12935 | 12983 | { |
| 12936 | | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value, nullptr); |
| 12984 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); |
| 12937 | 12985 | if (type_is_invalid(cast1->value.type)) |
| 12938 | 12986 | return ira->codegen->invalid_instruction; |
| 12939 | 12987 | |
| 12940 | | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1, result_loc); |
| 12988 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 12941 | 12989 | if (type_is_invalid(cast2->value.type)) |
| 12942 | 12990 | return ira->codegen->invalid_instruction; |
| 12943 | 12991 | |
| ... | ... | @@ -13019,7 +13067,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13019 | 13067 | types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type, |
| 13020 | 13068 | source_node, false).id == ConstCastResultIdOk) |
| 13021 | 13069 | { |
| 13022 | | return ir_analyze_array_to_slice(ira, source_instr, value, wanted_type, result_loc); |
| 13070 | return ir_analyze_array_to_slice(ira, source_instr, value, wanted_type, nullptr); |
| 13023 | 13071 | } |
| 13024 | 13072 | } |
| 13025 | 13073 | |
| ... | ... | @@ -13036,11 +13084,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13036 | 13084 | types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type, |
| 13037 | 13085 | source_node, false).id == ConstCastResultIdOk) |
| 13038 | 13086 | { |
| 13039 | | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value, nullptr); |
| 13087 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value); |
| 13040 | 13088 | if (type_is_invalid(cast1->value.type)) |
| 13041 | 13089 | return ira->codegen->invalid_instruction; |
| 13042 | 13090 | |
| 13043 | | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1, result_loc); |
| 13091 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13044 | 13092 | if (type_is_invalid(cast2->value.type)) |
| 13045 | 13093 | return ira->codegen->invalid_instruction; |
| 13046 | 13094 | |
| ... | ... | @@ -13055,11 +13103,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13055 | 13103 | actual_type->data.pointer.ptr_len == PtrLenSingle && |
| 13056 | 13104 | actual_type->data.pointer.child_type->id == ZigTypeIdArray) |
| 13057 | 13105 | { |
| 13058 | | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value, nullptr); |
| 13106 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value); |
| 13059 | 13107 | if (type_is_invalid(cast1->value.type)) |
| 13060 | 13108 | return ira->codegen->invalid_instruction; |
| 13061 | 13109 | |
| 13062 | | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1, result_loc); |
| 13110 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13063 | 13111 | if (type_is_invalid(cast2->value.type)) |
| 13064 | 13112 | return ira->codegen->invalid_instruction; |
| 13065 | 13113 | |
| ... | ... | @@ -13136,17 +13184,17 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13136 | 13184 | } |
| 13137 | 13185 | if (ok_align) { |
| 13138 | 13186 | if (wanted_type->id == ZigTypeIdErrorUnion) { |
| 13139 | | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, slice_type, value, nullptr); |
| 13187 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, slice_type, value); |
| 13140 | 13188 | if (type_is_invalid(cast1->value.type)) |
| 13141 | 13189 | return ira->codegen->invalid_instruction; |
| 13142 | 13190 | |
| 13143 | | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1, result_loc); |
| 13191 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13144 | 13192 | if (type_is_invalid(cast2->value.type)) |
| 13145 | 13193 | return ira->codegen->invalid_instruction; |
| 13146 | 13194 | |
| 13147 | 13195 | return cast2; |
| 13148 | 13196 | } else { |
| 13149 | | return ir_resolve_ptr_of_array_to_slice(ira, source_instr, value, slice_type, result_loc); |
| 13197 | return ir_resolve_ptr_of_array_to_slice(ira, source_instr, value, slice_type, nullptr); |
| 13150 | 13198 | } |
| 13151 | 13199 | } |
| 13152 | 13200 | } |
| ... | ... | @@ -13187,7 +13235,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13187 | 13235 | ok_align = get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, slice_ptr_type); |
| 13188 | 13236 | } |
| 13189 | 13237 | if (ok_align) { |
| 13190 | | return ir_resolve_ptr_of_array_to_slice(ira, source_instr, value, slice_type, result_loc); |
| 13238 | return ir_resolve_ptr_of_array_to_slice(ira, source_instr, value, slice_type, nullptr); |
| 13191 | 13239 | } |
| 13192 | 13240 | } |
| 13193 | 13241 | } |
| ... | ... | @@ -13243,11 +13291,11 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13243 | 13291 | types_match_const_cast_only(ira, ptr_type->data.pointer.child_type, actual_type->data.array.child_type, |
| 13244 | 13292 | source_node, false).id == ConstCastResultIdOk) |
| 13245 | 13293 | { |
| 13246 | | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value, nullptr); |
| 13294 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); |
| 13247 | 13295 | if (type_is_invalid(cast1->value.type)) |
| 13248 | 13296 | return ira->codegen->invalid_instruction; |
| 13249 | 13297 | |
| 13250 | | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1, result_loc); |
| 13298 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13251 | 13299 | if (type_is_invalid(cast2->value.type)) |
| 13252 | 13300 | return ira->codegen->invalid_instruction; |
| 13253 | 13301 | |
| ... | ... | @@ -13259,7 +13307,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13259 | 13307 | if (wanted_type->id == ZigTypeIdErrorUnion && |
| 13260 | 13308 | actual_type->id == ZigTypeIdErrorSet) |
| 13261 | 13309 | { |
| 13262 | | return ir_analyze_err_wrap_code(ira, source_instr, value, wanted_type, result_loc); |
| 13310 | return ir_analyze_err_wrap_code(ira, source_instr, value, wanted_type, nullptr); |
| 13263 | 13311 | } |
| 13264 | 13312 | |
| 13265 | 13313 | // cast from typed number to integer or float literal. |
| ... | ... | @@ -13285,7 +13333,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13285 | 13333 | if (result == ira->codegen->invalid_instruction) |
| 13286 | 13334 | return result; |
| 13287 | 13335 | |
| 13288 | | return ir_analyze_optional_wrap(ira, result, value, wanted_type, result_loc); |
| 13336 | return ir_analyze_optional_wrap(ira, result, value, wanted_type, nullptr); |
| 13289 | 13337 | } |
| 13290 | 13338 | |
| 13291 | 13339 | // cast from enum literal to error union when payload is an enum |
| ... | ... | @@ -13296,7 +13344,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13296 | 13344 | if (result == ira->codegen->invalid_instruction) |
| 13297 | 13345 | return result; |
| 13298 | 13346 | |
| 13299 | | return ir_analyze_err_wrap_payload(ira, result, value, wanted_type, result_loc); |
| 13347 | return ir_analyze_err_wrap_payload(ira, result, value, wanted_type, nullptr); |
| 13300 | 13348 | } |
| 13301 | 13349 | |
| 13302 | 13350 | // cast from union to the enum type of the union |
| ... | ... | @@ -13326,35 +13374,39 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13326 | 13374 | types_match_const_cast_only(ira, array_type->data.array.child_type, |
| 13327 | 13375 | actual_type->data.pointer.child_type, source_node, |
| 13328 | 13376 | !wanted_type->data.pointer.is_const).id == ConstCastResultIdOk && |
| 13329 | | // This should be the job of `types_match_const_cast_only` |
| 13330 | | // but `types_match_const_cast_only` only gets info for child_types |
| 13331 | | ((wanted_type->data.pointer.is_const && actual_type->data.pointer.is_const) || |
| 13332 | | !actual_type->data.pointer.is_const)) |
| 13377 | // `types_match_const_cast_only` only gets info for child_types |
| 13378 | (!wanted_type->data.pointer.is_const || actual_type->data.pointer.is_const) && |
| 13379 | (!wanted_type->data.pointer.is_volatile || actual_type->data.pointer.is_volatile)) |
| 13333 | 13380 | { |
| 13334 | | if ((err = type_resolve(ira->codegen, wanted_type->data.pointer.child_type, |
| 13335 | | ResolveStatusAlignmentKnown))) |
| 13336 | | { |
| 13337 | | return ira->codegen->invalid_instruction; |
| 13338 | | } |
| 13339 | | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, |
| 13340 | | ResolveStatusAlignmentKnown))) |
| 13341 | | { |
| 13342 | | return ira->codegen->invalid_instruction; |
| 13343 | | } |
| 13344 | | uint32_t wanted_align = get_ptr_align(ira->codegen, wanted_type); |
| 13345 | | uint32_t actual_align = get_ptr_align(ira->codegen, actual_type); |
| 13346 | | if (wanted_align > actual_align) { |
| 13347 | | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("cast increases pointer alignment")); |
| 13348 | | add_error_note(ira->codegen, msg, value->source_node, |
| 13349 | | buf_sprintf("'%s' has alignment %" PRIu32, buf_ptr(&actual_type->name), actual_align)); |
| 13350 | | add_error_note(ira->codegen, msg, source_instr->source_node, |
| 13351 | | buf_sprintf("'%s' has alignment %" PRIu32, buf_ptr(&wanted_type->name), wanted_align)); |
| 13381 | if ((err = ir_cast_ptr_align(ira, source_instr, wanted_type, actual_type, value->source_node))) |
| 13352 | 13382 | return ira->codegen->invalid_instruction; |
| 13353 | | } |
| 13383 | |
| 13354 | 13384 | return ir_analyze_ptr_to_array(ira, source_instr, value, wanted_type); |
| 13355 | 13385 | } |
| 13356 | 13386 | } |
| 13357 | 13387 | |
| 13388 | // [:x]T to [*:x]T |
| 13389 | // [:x]T to [*c]T |
| 13390 | if (wanted_type->id == ZigTypeIdPointer && is_slice(actual_type) && |
| 13391 | ((wanted_type->data.pointer.ptr_len == PtrLenUnknown && wanted_type->data.pointer.sentinel != nullptr) || |
| 13392 | wanted_type->data.pointer.ptr_len == PtrLenC)) |
| 13393 | { |
| 13394 | ZigType *slice_ptr_type = resolve_struct_field_type(ira->codegen, |
| 13395 | actual_type->data.structure.fields[slice_ptr_index]); |
| 13396 | if (types_match_const_cast_only(ira, wanted_type->data.pointer.child_type, |
| 13397 | slice_ptr_type->data.pointer.child_type, source_node, |
| 13398 | !wanted_type->data.pointer.is_const).id == ConstCastResultIdOk && |
| 13399 | (slice_ptr_type->data.pointer.sentinel != nullptr && |
| 13400 | (wanted_type->data.pointer.ptr_len == PtrLenC || |
| 13401 | const_values_equal(ira->codegen, wanted_type->data.pointer.sentinel, |
| 13402 | slice_ptr_type->data.pointer.sentinel)))) |
| 13403 | { |
| 13404 | TypeStructField *ptr_field = actual_type->data.structure.fields[slice_ptr_index]; |
| 13405 | IrInstruction *slice_ptr = ir_analyze_struct_value_field_value(ira, source_instr, value, ptr_field); |
| 13406 | return ir_implicit_cast(ira, source_instr, slice_ptr, wanted_type); |
| 13407 | } |
| 13408 | } |
| 13409 | |
| 13358 | 13410 | // cast from *T and [*]T to *c_void and ?*c_void |
| 13359 | 13411 | // but don't do it if the actual type is a double pointer |
| 13360 | 13412 | if (is_pointery_and_elem_is_not_pointery(actual_type)) { |
| ... | ... | @@ -13393,7 +13445,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13393 | 13445 | types_match_const_cast_only(ira, wanted_type->data.array.child_type, |
| 13394 | 13446 | actual_type->data.vector.elem_type, source_node, false).id == ConstCastResultIdOk) |
| 13395 | 13447 | { |
| 13396 | | return ir_analyze_vector_to_array(ira, source_instr, value, wanted_type, result_loc); |
| 13448 | return ir_analyze_vector_to_array(ira, source_instr, value, wanted_type, nullptr); |
| 13397 | 13449 | } |
| 13398 | 13450 | |
| 13399 | 13451 | // cast from [N]T to @Vector(N, T) |
| ... | ... | @@ -13454,8 +13506,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13454 | 13506 | return ira->codegen->invalid_instruction; |
| 13455 | 13507 | } |
| 13456 | 13508 | |
| 13457 | | static IrInstruction *ir_implicit_cast_with_result(IrAnalyze *ira, IrInstruction *source_instr, |
| 13458 | | IrInstruction *value, ZigType *expected_type, ResultLoc *result_loc) |
| 13509 | static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *source_instr, |
| 13510 | IrInstruction *value, ZigType *expected_type) |
| 13459 | 13511 | { |
| 13460 | 13512 | assert(value); |
| 13461 | 13513 | assert(value != ira->codegen->invalid_instruction); |
| ... | ... | @@ -13469,11 +13521,7 @@ static IrInstruction *ir_implicit_cast_with_result(IrAnalyze *ira, IrInstruction |
| 13469 | 13521 | if (value->value.type->id == ZigTypeIdUnreachable) |
| 13470 | 13522 | return value; |
| 13471 | 13523 | |
| 13472 | | return ir_analyze_cast(ira, source_instr, expected_type, value, result_loc); |
| 13473 | | } |
| 13474 | | |
| 13475 | | static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, ZigType *expected_type) { |
| 13476 | | return ir_implicit_cast_with_result(ira, value, value, expected_type, nullptr); |
| 13524 | return ir_analyze_cast(ira, source_instr, expected_type, value); |
| 13477 | 13525 | } |
| 13478 | 13526 | |
| 13479 | 13527 | static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr, |
| ... | ... | @@ -13611,7 +13659,7 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem |
| 13611 | 13659 | } |
| 13612 | 13660 | } |
| 13613 | 13661 | |
| 13614 | | IrInstruction *casted_value = ir_implicit_cast(ira, value, get_align_amt_type(ira->codegen)); |
| 13662 | IrInstruction *casted_value = ir_implicit_cast(ira, value, value, get_align_amt_type(ira->codegen)); |
| 13615 | 13663 | if (type_is_invalid(casted_value->value.type)) |
| 13616 | 13664 | return false; |
| 13617 | 13665 | |
| ... | ... | @@ -13623,7 +13671,7 @@ static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *i |
| 13623 | 13671 | if (type_is_invalid(value->value.type)) |
| 13624 | 13672 | return false; |
| 13625 | 13673 | |
| 13626 | | IrInstruction *casted_value = ir_implicit_cast(ira, value, int_type); |
| 13674 | IrInstruction *casted_value = ir_implicit_cast(ira, value, value, int_type); |
| 13627 | 13675 | if (type_is_invalid(casted_value->value.type)) |
| 13628 | 13676 | return false; |
| 13629 | 13677 | |
| ... | ... | @@ -13643,7 +13691,7 @@ static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) { |
| 13643 | 13691 | if (type_is_invalid(value->value.type)) |
| 13644 | 13692 | return false; |
| 13645 | 13693 | |
| 13646 | | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_bool); |
| 13694 | IrInstruction *casted_value = ir_implicit_cast(ira, value, value, ira->codegen->builtin_types.entry_bool); |
| 13647 | 13695 | if (type_is_invalid(casted_value->value.type)) |
| 13648 | 13696 | return false; |
| 13649 | 13697 | |
| ... | ... | @@ -13671,7 +13719,7 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic |
| 13671 | 13719 | assert(atomic_order_val->type->id == ZigTypeIdMetaType); |
| 13672 | 13720 | ZigType *atomic_order_type = atomic_order_val->data.x_type; |
| 13673 | 13721 | |
| 13674 | | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_order_type); |
| 13722 | IrInstruction *casted_value = ir_implicit_cast(ira, value, value, atomic_order_type); |
| 13675 | 13723 | if (type_is_invalid(casted_value->value.type)) |
| 13676 | 13724 | return false; |
| 13677 | 13725 | |
| ... | ... | @@ -13691,7 +13739,7 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi |
| 13691 | 13739 | assert(atomic_rmw_op_val->type->id == ZigTypeIdMetaType); |
| 13692 | 13740 | ZigType *atomic_rmw_op_type = atomic_rmw_op_val->data.x_type; |
| 13693 | 13741 | |
| 13694 | | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type); |
| 13742 | IrInstruction *casted_value = ir_implicit_cast(ira, value, value, atomic_rmw_op_type); |
| 13695 | 13743 | if (type_is_invalid(casted_value->value.type)) |
| 13696 | 13744 | return false; |
| 13697 | 13745 | |
| ... | ... | @@ -13711,7 +13759,7 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob |
| 13711 | 13759 | assert(global_linkage_val->type->id == ZigTypeIdMetaType); |
| 13712 | 13760 | ZigType *global_linkage_type = global_linkage_val->data.x_type; |
| 13713 | 13761 | |
| 13714 | | IrInstruction *casted_value = ir_implicit_cast(ira, value, global_linkage_type); |
| 13762 | IrInstruction *casted_value = ir_implicit_cast(ira, value, value, global_linkage_type); |
| 13715 | 13763 | if (type_is_invalid(casted_value->value.type)) |
| 13716 | 13764 | return false; |
| 13717 | 13765 | |
| ... | ... | @@ -13731,7 +13779,7 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod |
| 13731 | 13779 | assert(float_mode_val->type->id == ZigTypeIdMetaType); |
| 13732 | 13780 | ZigType *float_mode_type = float_mode_val->data.x_type; |
| 13733 | 13781 | |
| 13734 | | IrInstruction *casted_value = ir_implicit_cast(ira, value, float_mode_type); |
| 13782 | IrInstruction *casted_value = ir_implicit_cast(ira, value, value, float_mode_type); |
| 13735 | 13783 | if (type_is_invalid(casted_value->value.type)) |
| 13736 | 13784 | return false; |
| 13737 | 13785 | |
| ... | ... | @@ -13750,7 +13798,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { |
| 13750 | 13798 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 13751 | 13799 | true, false, PtrLenUnknown, 0, 0, 0, false); |
| 13752 | 13800 | ZigType *str_type = get_slice_type(ira->codegen, ptr_type); |
| 13753 | | IrInstruction *casted_value = ir_implicit_cast(ira, value, str_type); |
| 13801 | IrInstruction *casted_value = ir_implicit_cast(ira, value, value, str_type); |
| 13754 | 13802 | if (type_is_invalid(casted_value->value.type)) |
| 13755 | 13803 | return nullptr; |
| 13756 | 13804 | |
| ... | ... | @@ -13814,7 +13862,7 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio |
| 13814 | 13862 | return ir_finish_anal(ira, result); |
| 13815 | 13863 | } |
| 13816 | 13864 | |
| 13817 | | IrInstruction *casted_operand = ir_implicit_cast(ira, operand, ira->explicit_return_type); |
| 13865 | IrInstruction *casted_operand = ir_implicit_cast(ira, &instruction->base, operand, ira->explicit_return_type); |
| 13818 | 13866 | if (type_is_invalid(casted_operand->value.type)) { |
| 13819 | 13867 | AstNode *source_node = ira->explicit_return_type_source_node; |
| 13820 | 13868 | if (source_node != nullptr) { |
| ... | ... | @@ -13856,11 +13904,11 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp |
| 13856 | 13904 | |
| 13857 | 13905 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| 13858 | 13906 | |
| 13859 | | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, bool_type); |
| 13907 | IrInstruction *casted_op1 = ir_implicit_cast(ira, &bin_op_instruction->base, op1, bool_type); |
| 13860 | 13908 | if (casted_op1 == ira->codegen->invalid_instruction) |
| 13861 | 13909 | return ira->codegen->invalid_instruction; |
| 13862 | 13910 | |
| 13863 | | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, bool_type); |
| 13911 | IrInstruction *casted_op2 = ir_implicit_cast(ira, &bin_op_instruction->base, op2, bool_type); |
| 13864 | 13912 | if (casted_op2 == ira->codegen->invalid_instruction) |
| 13865 | 13913 | return ira->codegen->invalid_instruction; |
| 13866 | 13914 | |
| ... | ... | @@ -14129,11 +14177,11 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14129 | 14177 | ZigType *tag_type = union_val->value.type->data.unionation.tag_type; |
| 14130 | 14178 | assert(tag_type != nullptr); |
| 14131 | 14179 | |
| 14132 | | IrInstruction *casted_union = ir_implicit_cast(ira, union_val, tag_type); |
| 14180 | IrInstruction *casted_union = ir_implicit_cast(ira, &bin_op_instruction->base, union_val, tag_type); |
| 14133 | 14181 | if (type_is_invalid(casted_union->value.type)) |
| 14134 | 14182 | return ira->codegen->invalid_instruction; |
| 14135 | 14183 | |
| 14136 | | IrInstruction *casted_val = ir_implicit_cast(ira, enum_val, tag_type); |
| 14184 | IrInstruction *casted_val = ir_implicit_cast(ira, &bin_op_instruction->base, enum_val, tag_type); |
| 14137 | 14185 | if (type_is_invalid(casted_val->value.type)) |
| 14138 | 14186 | return ira->codegen->invalid_instruction; |
| 14139 | 14187 | |
| ... | ... | @@ -14296,11 +14344,11 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 14296 | 14344 | return ira->codegen->invalid_instruction; |
| 14297 | 14345 | } |
| 14298 | 14346 | |
| 14299 | | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); |
| 14347 | IrInstruction *casted_op1 = ir_implicit_cast(ira, &bin_op_instruction->base, op1, resolved_type); |
| 14300 | 14348 | if (casted_op1 == ira->codegen->invalid_instruction) |
| 14301 | 14349 | return ira->codegen->invalid_instruction; |
| 14302 | 14350 | |
| 14303 | | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); |
| 14351 | IrInstruction *casted_op2 = ir_implicit_cast(ira, &bin_op_instruction->base, op2, resolved_type); |
| 14304 | 14352 | if (casted_op2 == ira->codegen->invalid_instruction) |
| 14305 | 14353 | return ira->codegen->invalid_instruction; |
| 14306 | 14354 | |
| ... | ... | @@ -14648,7 +14696,7 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i |
| 14648 | 14696 | return ira->codegen->invalid_instruction; |
| 14649 | 14697 | } |
| 14650 | 14698 | } |
| 14651 | | return ir_implicit_cast(ira, result_instruction, type_entry); |
| 14699 | return ir_implicit_cast(ira, source_instr, result_instruction, type_entry); |
| 14652 | 14700 | } |
| 14653 | 14701 | |
| 14654 | 14702 | static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { |
| ... | ... | @@ -14713,7 +14761,7 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b |
| 14713 | 14761 | } |
| 14714 | 14762 | } |
| 14715 | 14763 | |
| 14716 | | casted_op2 = ir_implicit_cast(ira, op2, shift_amt_type); |
| 14764 | casted_op2 = ir_implicit_cast(ira, &bin_op_instruction->base, op2, shift_amt_type); |
| 14717 | 14765 | if (casted_op2 == ira->codegen->invalid_instruction) |
| 14718 | 14766 | return ira->codegen->invalid_instruction; |
| 14719 | 14767 | } |
| ... | ... | @@ -14822,7 +14870,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 14822 | 14870 | |
| 14823 | 14871 | // look for pointer math |
| 14824 | 14872 | if (is_pointer_arithmetic_allowed(op1->value.type, op_id)) { |
| 14825 | | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, ira->codegen->builtin_types.entry_usize); |
| 14873 | IrInstruction *casted_op2 = ir_implicit_cast(ira, &instruction->base, op2, ira->codegen->builtin_types.entry_usize); |
| 14826 | 14874 | if (type_is_invalid(casted_op2->value.type)) |
| 14827 | 14875 | return ira->codegen->invalid_instruction; |
| 14828 | 14876 | |
| ... | ... | @@ -14958,7 +15006,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 14958 | 15006 | ok = bigint_cmp(&rem_result, &mod_result) == CmpEQ; |
| 14959 | 15007 | } |
| 14960 | 15008 | } else { |
| 14961 | | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); |
| 15009 | IrInstruction *casted_op2 = ir_implicit_cast(ira, &instruction->base, op2, resolved_type); |
| 14962 | 15010 | if (casted_op2 == ira->codegen->invalid_instruction) |
| 14963 | 15011 | return ira->codegen->invalid_instruction; |
| 14964 | 15012 | |
| ... | ... | @@ -15022,11 +15070,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15022 | 15070 | } |
| 15023 | 15071 | } |
| 15024 | 15072 | |
| 15025 | | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); |
| 15073 | IrInstruction *casted_op1 = ir_implicit_cast(ira, &instruction->base, op1, resolved_type); |
| 15026 | 15074 | if (casted_op1 == ira->codegen->invalid_instruction) |
| 15027 | 15075 | return ira->codegen->invalid_instruction; |
| 15028 | 15076 | |
| 15029 | | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); |
| 15077 | IrInstruction *casted_op2 = ir_implicit_cast(ira, &instruction->base, op2, resolved_type); |
| 15030 | 15078 | if (casted_op2 == ira->codegen->invalid_instruction) |
| 15031 | 15079 | return ira->codegen->invalid_instruction; |
| 15032 | 15080 | |
| ... | ... | @@ -16239,7 +16287,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 16239 | 16287 | // In this case we can pointer cast the result location. |
| 16240 | 16288 | IrInstruction *casted_value; |
| 16241 | 16289 | if (value != nullptr) { |
| 16242 | | casted_value = ir_implicit_cast(ira, value, dest_type); |
| 16290 | casted_value = ir_implicit_cast(ira, value, value, dest_type); |
| 16243 | 16291 | } else { |
| 16244 | 16292 | casted_value = nullptr; |
| 16245 | 16293 | } |
| ... | ... | @@ -16530,7 +16578,7 @@ static IrInstruction *get_async_call_result_loc(IrAnalyze *ira, IrInstructionCal |
| 16530 | 16578 | // Result location will be inside the async frame. |
| 16531 | 16579 | return nullptr; |
| 16532 | 16580 | } |
| 16533 | | return ir_implicit_cast(ira, ret_ptr_uncasted, get_pointer_to_type(ira->codegen, fn_ret_type, false)); |
| 16581 | return ir_implicit_cast(ira, ret_ptr_uncasted, ret_ptr_uncasted, get_pointer_to_type(ira->codegen, fn_ret_type, false)); |
| 16534 | 16582 | } |
| 16535 | 16583 | |
| 16536 | 16584 | static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc *call_instruction, ZigFn *fn_entry, |
| ... | ... | @@ -16567,7 +16615,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCallSrc |
| 16567 | 16615 | if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) { |
| 16568 | 16616 | return result_loc; |
| 16569 | 16617 | } |
| 16570 | | result_loc = ir_implicit_cast(ira, result_loc, get_pointer_to_type(ira->codegen, frame_type, false)); |
| 16618 | result_loc = ir_implicit_cast(ira, &call_instruction->base, result_loc, get_pointer_to_type(ira->codegen, frame_type, false)); |
| 16571 | 16619 | if (type_is_invalid(result_loc->value.type)) |
| 16572 | 16620 | return ira->codegen->invalid_instruction; |
| 16573 | 16621 | return &ir_build_call_gen(ira, &call_instruction->base, fn_entry, fn_ref, arg_count, |
| ... | ... | @@ -16588,7 +16636,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node |
| 16588 | 16636 | if (type_is_invalid(param_type)) |
| 16589 | 16637 | return false; |
| 16590 | 16638 | |
| 16591 | | casted_arg = ir_implicit_cast(ira, arg, param_type); |
| 16639 | casted_arg = ir_implicit_cast(ira, arg, arg, param_type); |
| 16592 | 16640 | if (type_is_invalid(casted_arg->value.type)) |
| 16593 | 16641 | return false; |
| 16594 | 16642 | } else { |
| ... | ... | @@ -16628,7 +16676,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 16628 | 16676 | if (type_is_invalid(param_type)) |
| 16629 | 16677 | return false; |
| 16630 | 16678 | |
| 16631 | | casted_arg = ir_implicit_cast(ira, arg, param_type); |
| 16679 | casted_arg = ir_implicit_cast(ira, arg, arg, param_type); |
| 16632 | 16680 | if (type_is_invalid(casted_arg->value.type)) |
| 16633 | 16681 | return false; |
| 16634 | 16682 | } else { |
| ... | ... | @@ -16869,7 +16917,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16869 | 16917 | } |
| 16870 | 16918 | |
| 16871 | 16919 | ZigType *child_type = ptr->value.type->data.pointer.child_type; |
| 16872 | | IrInstruction *value = ir_implicit_cast(ira, uncasted_value, child_type); |
| 16920 | IrInstruction *value = ir_implicit_cast(ira, uncasted_value, uncasted_value, child_type); |
| 16873 | 16921 | if (value == ira->codegen->invalid_instruction) |
| 16874 | 16922 | return ira->codegen->invalid_instruction; |
| 16875 | 16923 | |
| ... | ... | @@ -16986,13 +17034,13 @@ static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstructionCall |
| 16986 | 17034 | { |
| 16987 | 17035 | ZigType *needed_frame_type = get_pointer_to_type(ira->codegen, |
| 16988 | 17036 | get_fn_frame_type(ira->codegen, fn_entry), false); |
| 16989 | | return ir_implicit_cast(ira, new_stack, needed_frame_type); |
| 17037 | return ir_implicit_cast(ira, &call_instruction->base, new_stack, needed_frame_type); |
| 16990 | 17038 | } else { |
| 16991 | 17039 | ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 16992 | 17040 | false, false, PtrLenUnknown, target_fn_align(ira->codegen->zig_target), 0, 0, false); |
| 16993 | 17041 | ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr); |
| 16994 | 17042 | ira->codegen->need_frame_size_prefix_data = true; |
| 16995 | | return ir_implicit_cast(ira, new_stack, u8_slice); |
| 17043 | return ir_implicit_cast(ira, &call_instruction->base, new_stack, u8_slice); |
| 16996 | 17044 | } |
| 16997 | 17045 | } |
| 16998 | 17046 | |
| ... | ... | @@ -17466,7 +17514,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17466 | 17514 | return ira->codegen->invalid_instruction; |
| 17467 | 17515 | } |
| 17468 | 17516 | |
| 17469 | | IrInstruction *casted_arg = ir_implicit_cast(ira, first_arg, param_type); |
| 17517 | IrInstruction *casted_arg = ir_implicit_cast(ira, first_arg, first_arg, param_type); |
| 17470 | 17518 | if (type_is_invalid(casted_arg->value.type)) |
| 17471 | 17519 | return ira->codegen->invalid_instruction; |
| 17472 | 17520 | |
| ... | ... | @@ -17501,7 +17549,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17501 | 17549 | ZigType *param_type = fn_type_id->param_info[next_arg_index].type; |
| 17502 | 17550 | if (type_is_invalid(param_type)) |
| 17503 | 17551 | return ira->codegen->invalid_instruction; |
| 17504 | | casted_arg = ir_implicit_cast(ira, arg_tuple_arg, param_type); |
| 17552 | casted_arg = ir_implicit_cast(ira, arg_tuple_arg, arg_tuple_arg, param_type); |
| 17505 | 17553 | if (type_is_invalid(casted_arg->value.type)) |
| 17506 | 17554 | return ira->codegen->invalid_instruction; |
| 17507 | 17555 | } else { |
| ... | ... | @@ -17517,7 +17565,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17517 | 17565 | ZigType *param_type = fn_type_id->param_info[next_arg_index].type; |
| 17518 | 17566 | if (type_is_invalid(param_type)) |
| 17519 | 17567 | return ira->codegen->invalid_instruction; |
| 17520 | | casted_arg = ir_implicit_cast(ira, old_arg, param_type); |
| 17568 | casted_arg = ir_implicit_cast(ira, old_arg, old_arg, param_type); |
| 17521 | 17569 | if (type_is_invalid(casted_arg->value.type)) |
| 17522 | 17570 | return ira->codegen->invalid_instruction; |
| 17523 | 17571 | } else { |
| ... | ... | @@ -17949,7 +17997,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi |
| 17949 | 17997 | return ir_unreach_error(ira); |
| 17950 | 17998 | |
| 17951 | 17999 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| 17952 | | IrInstruction *casted_condition = ir_implicit_cast(ira, condition, bool_type); |
| 18000 | IrInstruction *casted_condition = ir_implicit_cast(ira, &cond_br_instruction->base, condition, bool_type); |
| 17953 | 18001 | if (type_is_invalid(casted_condition->value.type)) |
| 17954 | 18002 | return ir_unreach_error(ira); |
| 17955 | 18003 | |
| ... | ... | @@ -18199,7 +18247,7 @@ skip_resolve_peer_types: |
| 18199 | 18247 | ir_assert(predecessor->instruction_list.length != 0, &phi_instruction->base); |
| 18200 | 18248 | IrInstruction *branch_instruction = predecessor->instruction_list.pop(); |
| 18201 | 18249 | ir_set_cursor_at_end(&ira->new_irb, predecessor); |
| 18202 | | IrInstruction *casted_value = ir_implicit_cast(ira, new_value, resolved_type); |
| 18250 | IrInstruction *casted_value = ir_implicit_cast(ira, new_value, new_value, resolved_type); |
| 18203 | 18251 | if (type_is_invalid(casted_value->value.type)) { |
| 18204 | 18252 | return ira->codegen->invalid_instruction; |
| 18205 | 18253 | } |
| ... | ... | @@ -18385,7 +18433,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18385 | 18433 | array_type->data.structure.resolve_status == ResolveStatusBeingInferred) |
| 18386 | 18434 | { |
| 18387 | 18435 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 18388 | | IrInstruction *casted_elem_index = ir_implicit_cast(ira, elem_index, usize); |
| 18436 | IrInstruction *casted_elem_index = ir_implicit_cast(ira, elem_index, elem_index, usize); |
| 18389 | 18437 | if (casted_elem_index == ira->codegen->invalid_instruction) |
| 18390 | 18438 | return ira->codegen->invalid_instruction; |
| 18391 | 18439 | ir_assert(instr_is_comptime(casted_elem_index), &elem_ptr_instruction->base); |
| ... | ... | @@ -18400,7 +18448,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18400 | 18448 | } |
| 18401 | 18449 | |
| 18402 | 18450 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 18403 | | IrInstruction *casted_elem_index = ir_implicit_cast(ira, elem_index, usize); |
| 18451 | IrInstruction *casted_elem_index = ir_implicit_cast(ira, elem_index, elem_index, usize); |
| 18404 | 18452 | if (casted_elem_index == ira->codegen->invalid_instruction) |
| 18405 | 18453 | return ira->codegen->invalid_instruction; |
| 18406 | 18454 | |
| ... | ... | @@ -19759,7 +19807,7 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, |
| 19759 | 19807 | IrInstruction *uncasted_sentinel = array_type_instruction->sentinel->child; |
| 19760 | 19808 | if (type_is_invalid(uncasted_sentinel->value.type)) |
| 19761 | 19809 | return ira->codegen->invalid_instruction; |
| 19762 | | IrInstruction *sentinel = ir_implicit_cast(ira, uncasted_sentinel, child_type); |
| 19810 | IrInstruction *sentinel = ir_implicit_cast(ira, &array_type_instruction->base, uncasted_sentinel, child_type); |
| 19763 | 19811 | if (type_is_invalid(sentinel->value.type)) |
| 19764 | 19812 | return ira->codegen->invalid_instruction; |
| 19765 | 19813 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| ... | ... | @@ -20033,7 +20081,7 @@ static IrInstruction *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCt |
| 20033 | 20081 | if (type_is_invalid(int_type)) |
| 20034 | 20082 | return ira->codegen->invalid_instruction; |
| 20035 | 20083 | |
| 20036 | | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 20084 | IrInstruction *op = ir_implicit_cast(ira, &instruction->base, instruction->op->child, int_type); |
| 20037 | 20085 | if (type_is_invalid(op->value.type)) |
| 20038 | 20086 | return ira->codegen->invalid_instruction; |
| 20039 | 20087 | |
| ... | ... | @@ -20062,7 +20110,7 @@ static IrInstruction *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionCl |
| 20062 | 20110 | if (type_is_invalid(int_type)) |
| 20063 | 20111 | return ira->codegen->invalid_instruction; |
| 20064 | 20112 | |
| 20065 | | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 20113 | IrInstruction *op = ir_implicit_cast(ira, &instruction->base, instruction->op->child, int_type); |
| 20066 | 20114 | if (type_is_invalid(op->value.type)) |
| 20067 | 20115 | return ira->codegen->invalid_instruction; |
| 20068 | 20116 | |
| ... | ... | @@ -20091,7 +20139,7 @@ static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstruc |
| 20091 | 20139 | if (type_is_invalid(int_type)) |
| 20092 | 20140 | return ira->codegen->invalid_instruction; |
| 20093 | 20141 | |
| 20094 | | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 20142 | IrInstruction *op = ir_implicit_cast(ira, &instruction->base, instruction->op->child, int_type); |
| 20095 | 20143 | if (type_is_invalid(op->value.type)) |
| 20096 | 20144 | return ira->codegen->invalid_instruction; |
| 20097 | 20145 | |
| ... | ... | @@ -20201,7 +20249,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 20201 | 20249 | return ir_unreach_error(ira); |
| 20202 | 20250 | } |
| 20203 | 20251 | |
| 20204 | | IrInstruction *casted_case_value = ir_implicit_cast(ira, case_value, target_value->value.type); |
| 20252 | IrInstruction *casted_case_value = ir_implicit_cast(ira, case_value, case_value, target_value->value.type); |
| 20205 | 20253 | if (type_is_invalid(casted_case_value->value.type)) |
| 20206 | 20254 | return ir_unreach_error(ira); |
| 20207 | 20255 | |
| ... | ... | @@ -20251,7 +20299,7 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 20251 | 20299 | continue; |
| 20252 | 20300 | } |
| 20253 | 20301 | |
| 20254 | | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, target_value->value.type); |
| 20302 | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, new_value, target_value->value.type); |
| 20255 | 20303 | if (type_is_invalid(casted_new_value->value.type)) |
| 20256 | 20304 | continue; |
| 20257 | 20305 | |
| ... | ... | @@ -20421,7 +20469,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 20421 | 20469 | if (type_is_invalid(first_prong_value->value.type)) |
| 20422 | 20470 | return ira->codegen->invalid_instruction; |
| 20423 | 20471 | |
| 20424 | | IrInstruction *first_casted_prong_value = ir_implicit_cast(ira, first_prong_value, enum_type); |
| 20472 | IrInstruction *first_casted_prong_value = ir_implicit_cast(ira, &instruction->base, first_prong_value, enum_type); |
| 20425 | 20473 | if (type_is_invalid(first_casted_prong_value->value.type)) |
| 20426 | 20474 | return ira->codegen->invalid_instruction; |
| 20427 | 20475 | |
| ... | ... | @@ -20437,7 +20485,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 20437 | 20485 | if (type_is_invalid(this_prong_inst->value.type)) |
| 20438 | 20486 | return ira->codegen->invalid_instruction; |
| 20439 | 20487 | |
| 20440 | | IrInstruction *this_casted_prong_value = ir_implicit_cast(ira, this_prong_inst, enum_type); |
| 20488 | IrInstruction *this_casted_prong_value = ir_implicit_cast(ira, &instruction->base, this_prong_inst, enum_type); |
| 20441 | 20489 | if (type_is_invalid(this_casted_prong_value->value.type)) |
| 20442 | 20490 | return ira->codegen->invalid_instruction; |
| 20443 | 20491 | |
| ... | ... | @@ -21057,7 +21105,7 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct |
| 21057 | 21105 | if (type_is_invalid(value->value.type)) |
| 21058 | 21106 | return ira->codegen->invalid_instruction; |
| 21059 | 21107 | |
| 21060 | | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_global_error_set); |
| 21108 | IrInstruction *casted_value = ir_implicit_cast(ira, &instruction->base, value, ira->codegen->builtin_types.entry_global_error_set); |
| 21061 | 21109 | if (type_is_invalid(casted_value->value.type)) |
| 21062 | 21110 | return ira->codegen->invalid_instruction; |
| 21063 | 21111 | |
| ... | ... | @@ -21165,7 +21213,7 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 21165 | 21213 | field_ptr->value.type->data.pointer.is_volatile, |
| 21166 | 21214 | PtrLenSingle, |
| 21167 | 21215 | field_ptr_align, 0, 0, false); |
| 21168 | | IrInstruction *casted_field_ptr = ir_implicit_cast(ira, field_ptr, field_ptr_type); |
| 21216 | IrInstruction *casted_field_ptr = ir_implicit_cast(ira, &instruction->base, field_ptr, field_ptr_type); |
| 21169 | 21217 | if (type_is_invalid(casted_field_ptr->value.type)) |
| 21170 | 21218 | return ira->codegen->invalid_instruction; |
| 21171 | 21219 | |
| ... | ... | @@ -22309,7 +22357,7 @@ static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_inst |
| 22309 | 22357 | { |
| 22310 | 22358 | ConstExprValue *field_val = get_const_field(ira, struct_value, name, field_index); |
| 22311 | 22359 | IrInstruction *field_inst = ir_const(ira, source_instr, field_val->type); |
| 22312 | | IrInstruction *casted_field_inst = ir_implicit_cast(ira, field_inst, |
| 22360 | IrInstruction *casted_field_inst = ir_implicit_cast(ira, source_instr, field_inst, |
| 22313 | 22361 | get_optional_type(ira->codegen, elem_type)); |
| 22314 | 22362 | if (type_is_invalid(casted_field_inst->value.type)) |
| 22315 | 22363 | return ErrorSemanticAnalyzeFail; |
| ... | ... | @@ -22456,7 +22504,7 @@ static IrInstruction *ir_analyze_instruction_type(IrAnalyze *ira, IrInstructionT |
| 22456 | 22504 | if (type_is_invalid(type_info_ir->value.type)) |
| 22457 | 22505 | return ira->codegen->invalid_instruction; |
| 22458 | 22506 | |
| 22459 | | IrInstruction *casted_ir = ir_implicit_cast(ira, type_info_ir, ir_type_info_get_type(ira, nullptr, nullptr)); |
| 22507 | IrInstruction *casted_ir = ir_implicit_cast(ira, &instruction->base, type_info_ir, ir_type_info_get_type(ira, nullptr, nullptr)); |
| 22460 | 22508 | if (type_is_invalid(casted_ir->value.type)) |
| 22461 | 22509 | return ira->codegen->invalid_instruction; |
| 22462 | 22510 | |
| ... | ... | @@ -22817,7 +22865,7 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi |
| 22817 | 22865 | |
| 22818 | 22866 | // TODO let this be volatile |
| 22819 | 22867 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 22820 | | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr, ptr_type); |
| 22868 | IrInstruction *casted_ptr = ir_implicit_cast(ira, &instruction->base, ptr, ptr_type); |
| 22821 | 22869 | if (type_is_invalid(casted_ptr->value.type)) |
| 22822 | 22870 | return ira->codegen->invalid_instruction; |
| 22823 | 22871 | |
| ... | ... | @@ -22845,11 +22893,11 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi |
| 22845 | 22893 | if (!ir_resolve_atomic_order(ira, failure_order_value, &failure_order)) |
| 22846 | 22894 | return ira->codegen->invalid_instruction; |
| 22847 | 22895 | |
| 22848 | | IrInstruction *casted_cmp_value = ir_implicit_cast(ira, cmp_value, operand_type); |
| 22896 | IrInstruction *casted_cmp_value = ir_implicit_cast(ira, &instruction->base, cmp_value, operand_type); |
| 22849 | 22897 | if (type_is_invalid(casted_cmp_value->value.type)) |
| 22850 | 22898 | return ira->codegen->invalid_instruction; |
| 22851 | 22899 | |
| 22852 | | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, operand_type); |
| 22900 | IrInstruction *casted_new_value = ir_implicit_cast(ira, &instruction->base, new_value, operand_type); |
| 22853 | 22901 | if (type_is_invalid(casted_new_value->value.type)) |
| 22854 | 22902 | return ira->codegen->invalid_instruction; |
| 22855 | 22903 | |
| ... | ... | @@ -22943,7 +22991,7 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct |
| 22943 | 22991 | } |
| 22944 | 22992 | |
| 22945 | 22993 | if (dest_type->id == ZigTypeIdComptimeInt) { |
| 22946 | | return ir_implicit_cast(ira, target, dest_type); |
| 22994 | return ir_implicit_cast(ira, &instruction->base, target, dest_type); |
| 22947 | 22995 | } |
| 22948 | 22996 | |
| 22949 | 22997 | if (instr_is_comptime(target)) { |
| ... | ... | @@ -23000,7 +23048,7 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct |
| 23000 | 23048 | } |
| 23001 | 23049 | |
| 23002 | 23050 | if (instr_is_comptime(target)) { |
| 23003 | | return ir_implicit_cast(ira, target, dest_type); |
| 23051 | return ir_implicit_cast(ira, &instruction->base, target, dest_type); |
| 23004 | 23052 | } |
| 23005 | 23053 | |
| 23006 | 23054 | if (dest_type->id == ZigTypeIdComptimeInt) { |
| ... | ... | @@ -23128,7 +23176,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 23128 | 23176 | src_ptr_align, 0, 0, false); |
| 23129 | 23177 | ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr); |
| 23130 | 23178 | |
| 23131 | | IrInstruction *casted_value = ir_implicit_cast(ira, target, u8_slice); |
| 23179 | IrInstruction *casted_value = ir_implicit_cast(ira, &instruction->base, target, u8_slice); |
| 23132 | 23180 | if (type_is_invalid(casted_value->value.type)) |
| 23133 | 23181 | return ira->codegen->invalid_instruction; |
| 23134 | 23182 | |
| ... | ... | @@ -23277,7 +23325,7 @@ static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInst |
| 23277 | 23325 | return ira->codegen->invalid_instruction; |
| 23278 | 23326 | |
| 23279 | 23327 | if (target->value.type->id == ZigTypeIdComptimeInt) { |
| 23280 | | return ir_implicit_cast(ira, target, dest_type); |
| 23328 | return ir_implicit_cast(ira, &instruction->base, target, dest_type); |
| 23281 | 23329 | } |
| 23282 | 23330 | |
| 23283 | 23331 | if (target->value.type->id != ZigTypeIdFloat && target->value.type->id != ZigTypeIdComptimeFloat) { |
| ... | ... | @@ -23298,7 +23346,7 @@ static IrInstruction *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstru |
| 23298 | 23346 | if (target->value.type->id == ZigTypeIdErrorSet) { |
| 23299 | 23347 | casted_target = target; |
| 23300 | 23348 | } else { |
| 23301 | | casted_target = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_global_error_set); |
| 23349 | casted_target = ir_implicit_cast(ira, &instruction->base, target, ira->codegen->builtin_types.entry_global_error_set); |
| 23302 | 23350 | if (type_is_invalid(casted_target->value.type)) |
| 23303 | 23351 | return ira->codegen->invalid_instruction; |
| 23304 | 23352 | } |
| ... | ... | @@ -23311,7 +23359,7 @@ static IrInstruction *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstru |
| 23311 | 23359 | if (type_is_invalid(target->value.type)) |
| 23312 | 23360 | return ira->codegen->invalid_instruction; |
| 23313 | 23361 | |
| 23314 | | IrInstruction *casted_target = ir_implicit_cast(ira, target, ira->codegen->err_tag_type); |
| 23362 | IrInstruction *casted_target = ir_implicit_cast(ira, &instruction->base, target, ira->codegen->err_tag_type); |
| 23315 | 23363 | if (type_is_invalid(casted_target->value.type)) |
| 23316 | 23364 | return ira->codegen->invalid_instruction; |
| 23317 | 23365 | |
| ... | ... | @@ -23386,7 +23434,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23386 | 23434 | buf_ptr(&mask->value.type->name))); |
| 23387 | 23435 | return ira->codegen->invalid_instruction; |
| 23388 | 23436 | } |
| 23389 | | mask = ir_implicit_cast(ira, mask, get_vector_type(ira->codegen, len_mask, |
| 23437 | mask = ir_implicit_cast(ira, source_instr, mask, get_vector_type(ira->codegen, len_mask, |
| 23390 | 23438 | ira->codegen->builtin_types.entry_i32)); |
| 23391 | 23439 | if (type_is_invalid(mask->value.type)) |
| 23392 | 23440 | return ira->codegen->invalid_instruction; |
| ... | ... | @@ -23429,7 +23477,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23429 | 23477 | len_a = len_b; |
| 23430 | 23478 | a = ir_const_undef(ira, a, get_vector_type(ira->codegen, len_a, scalar_type)); |
| 23431 | 23479 | } else { |
| 23432 | | a = ir_implicit_cast(ira, a, get_vector_type(ira->codegen, len_a, scalar_type)); |
| 23480 | a = ir_implicit_cast(ira, source_instr, a, get_vector_type(ira->codegen, len_a, scalar_type)); |
| 23433 | 23481 | if (type_is_invalid(a->value.type)) |
| 23434 | 23482 | return ira->codegen->invalid_instruction; |
| 23435 | 23483 | } |
| ... | ... | @@ -23438,7 +23486,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 23438 | 23486 | len_b = len_a; |
| 23439 | 23487 | b = ir_const_undef(ira, b, get_vector_type(ira->codegen, len_b, scalar_type)); |
| 23440 | 23488 | } else { |
| 23441 | | b = ir_implicit_cast(ira, b, get_vector_type(ira->codegen, len_b, scalar_type)); |
| 23489 | b = ir_implicit_cast(ira, source_instr, b, get_vector_type(ira->codegen, len_b, scalar_type)); |
| 23442 | 23490 | if (type_is_invalid(b->value.type)) |
| 23443 | 23491 | return ira->codegen->invalid_instruction; |
| 23444 | 23492 | } |
| ... | ... | @@ -23614,7 +23662,7 @@ static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruct |
| 23614 | 23662 | |
| 23615 | 23663 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| 23616 | 23664 | |
| 23617 | | IrInstruction *casted_value = ir_implicit_cast(ira, value, bool_type); |
| 23665 | IrInstruction *casted_value = ir_implicit_cast(ira, &instruction->base, value, bool_type); |
| 23618 | 23666 | if (type_is_invalid(casted_value->value.type)) |
| 23619 | 23667 | return ira->codegen->invalid_instruction; |
| 23620 | 23668 | |
| ... | ... | @@ -23663,15 +23711,15 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 23663 | 23711 | ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile, |
| 23664 | 23712 | PtrLenUnknown, dest_align, 0, 0, false); |
| 23665 | 23713 | |
| 23666 | | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr); |
| 23714 | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, &instruction->base, dest_ptr, u8_ptr); |
| 23667 | 23715 | if (type_is_invalid(casted_dest_ptr->value.type)) |
| 23668 | 23716 | return ira->codegen->invalid_instruction; |
| 23669 | 23717 | |
| 23670 | | IrInstruction *casted_byte = ir_implicit_cast(ira, byte_value, u8); |
| 23718 | IrInstruction *casted_byte = ir_implicit_cast(ira, &instruction->base, byte_value, u8); |
| 23671 | 23719 | if (type_is_invalid(casted_byte->value.type)) |
| 23672 | 23720 | return ira->codegen->invalid_instruction; |
| 23673 | 23721 | |
| 23674 | | IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize); |
| 23722 | IrInstruction *casted_count = ir_implicit_cast(ira, &instruction->base, count_value, usize); |
| 23675 | 23723 | if (type_is_invalid(casted_count->value.type)) |
| 23676 | 23724 | return ira->codegen->invalid_instruction; |
| 23677 | 23725 | |
| ... | ... | @@ -23798,15 +23846,15 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 23798 | 23846 | ZigType *u8_ptr_const = get_pointer_to_type_extra(ira->codegen, u8, true, src_is_volatile, |
| 23799 | 23847 | PtrLenUnknown, src_align, 0, 0, false); |
| 23800 | 23848 | |
| 23801 | | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut); |
| 23849 | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, &instruction->base, dest_ptr, u8_ptr_mut); |
| 23802 | 23850 | if (type_is_invalid(casted_dest_ptr->value.type)) |
| 23803 | 23851 | return ira->codegen->invalid_instruction; |
| 23804 | 23852 | |
| 23805 | | IrInstruction *casted_src_ptr = ir_implicit_cast(ira, src_ptr, u8_ptr_const); |
| 23853 | IrInstruction *casted_src_ptr = ir_implicit_cast(ira, &instruction->base, src_ptr, u8_ptr_const); |
| 23806 | 23854 | if (type_is_invalid(casted_src_ptr->value.type)) |
| 23807 | 23855 | return ira->codegen->invalid_instruction; |
| 23808 | 23856 | |
| 23809 | | IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize); |
| 23857 | IrInstruction *casted_count = ir_implicit_cast(ira, &instruction->base, count_value, usize); |
| 23810 | 23858 | if (type_is_invalid(casted_count->value.type)) |
| 23811 | 23859 | return ira->codegen->invalid_instruction; |
| 23812 | 23860 | |
| ... | ... | @@ -23946,7 +23994,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 23946 | 23994 | return ira->codegen->invalid_instruction; |
| 23947 | 23995 | |
| 23948 | 23996 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 23949 | | IrInstruction *casted_start = ir_implicit_cast(ira, start, usize); |
| 23997 | IrInstruction *casted_start = ir_implicit_cast(ira, &instruction->base, start, usize); |
| 23950 | 23998 | if (type_is_invalid(casted_start->value.type)) |
| 23951 | 23999 | return ira->codegen->invalid_instruction; |
| 23952 | 24000 | |
| ... | ... | @@ -23955,7 +24003,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 23955 | 24003 | end = instruction->end->child; |
| 23956 | 24004 | if (type_is_invalid(end->value.type)) |
| 23957 | 24005 | return ira->codegen->invalid_instruction; |
| 23958 | | end = ir_implicit_cast(ira, end, usize); |
| 24006 | end = ir_implicit_cast(ira, &instruction->base, end, usize); |
| 23959 | 24007 | if (type_is_invalid(end->value.type)) |
| 23960 | 24008 | return ira->codegen->invalid_instruction; |
| 23961 | 24009 | } else { |
| ... | ... | @@ -24526,7 +24574,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 24526 | 24574 | if (type_is_invalid(op1->value.type)) |
| 24527 | 24575 | return ira->codegen->invalid_instruction; |
| 24528 | 24576 | |
| 24529 | | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, dest_type); |
| 24577 | IrInstruction *casted_op1 = ir_implicit_cast(ira, &instruction->base, op1, dest_type); |
| 24530 | 24578 | if (type_is_invalid(casted_op1->value.type)) |
| 24531 | 24579 | return ira->codegen->invalid_instruction; |
| 24532 | 24580 | |
| ... | ... | @@ -24538,9 +24586,9 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 24538 | 24586 | if (instruction->op == IrOverflowOpShl) { |
| 24539 | 24587 | ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, |
| 24540 | 24588 | dest_type->data.integral.bit_count - 1); |
| 24541 | | casted_op2 = ir_implicit_cast(ira, op2, shift_amt_type); |
| 24589 | casted_op2 = ir_implicit_cast(ira, &instruction->base, op2, shift_amt_type); |
| 24542 | 24590 | } else { |
| 24543 | | casted_op2 = ir_implicit_cast(ira, op2, dest_type); |
| 24591 | casted_op2 = ir_implicit_cast(ira, &instruction->base, op2, dest_type); |
| 24544 | 24592 | } |
| 24545 | 24593 | if (type_is_invalid(casted_op2->value.type)) |
| 24546 | 24594 | return ira->codegen->invalid_instruction; |
| ... | ... | @@ -24562,7 +24610,7 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 24562 | 24610 | expected_ptr_type = get_pointer_to_type(ira->codegen, dest_type, false); |
| 24563 | 24611 | } |
| 24564 | 24612 | |
| 24565 | | IrInstruction *casted_result_ptr = ir_implicit_cast(ira, result_ptr, expected_ptr_type); |
| 24613 | IrInstruction *casted_result_ptr = ir_implicit_cast(ira, &instruction->base, result_ptr, expected_ptr_type); |
| 24566 | 24614 | if (type_is_invalid(casted_result_ptr->value.type)) |
| 24567 | 24615 | return ira->codegen->invalid_instruction; |
| 24568 | 24616 | |
| ... | ... | @@ -24672,7 +24720,7 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi |
| 24672 | 24720 | if (type_is_invalid(op1->value.type)) |
| 24673 | 24721 | return ira->codegen->invalid_instruction; |
| 24674 | 24722 | |
| 24675 | | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, expr_type); |
| 24723 | IrInstruction *casted_op1 = ir_implicit_cast(ira, &instruction->base, op1, expr_type); |
| 24676 | 24724 | if (type_is_invalid(casted_op1->value.type)) |
| 24677 | 24725 | return ira->codegen->invalid_instruction; |
| 24678 | 24726 | |
| ... | ... | @@ -24680,7 +24728,7 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi |
| 24680 | 24728 | if (type_is_invalid(op2->value.type)) |
| 24681 | 24729 | return ira->codegen->invalid_instruction; |
| 24682 | 24730 | |
| 24683 | | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, expr_type); |
| 24731 | IrInstruction *casted_op2 = ir_implicit_cast(ira, &instruction->base, op2, expr_type); |
| 24684 | 24732 | if (type_is_invalid(casted_op2->value.type)) |
| 24685 | 24733 | return ira->codegen->invalid_instruction; |
| 24686 | 24734 | |
| ... | ... | @@ -24688,7 +24736,7 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi |
| 24688 | 24736 | if (type_is_invalid(op3->value.type)) |
| 24689 | 24737 | return ira->codegen->invalid_instruction; |
| 24690 | 24738 | |
| 24691 | | IrInstruction *casted_op3 = ir_implicit_cast(ira, op3, expr_type); |
| 24739 | IrInstruction *casted_op3 = ir_implicit_cast(ira, &instruction->base, op3, expr_type); |
| 24692 | 24740 | if (type_is_invalid(casted_op3->value.type)) |
| 24693 | 24741 | return ira->codegen->invalid_instruction; |
| 24694 | 24742 | |
| ... | ... | @@ -25060,14 +25108,14 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 25060 | 25108 | IrInstruction *start_value_uncasted = range->start->child; |
| 25061 | 25109 | if (type_is_invalid(start_value_uncasted->value.type)) |
| 25062 | 25110 | return ira->codegen->invalid_instruction; |
| 25063 | | IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); |
| 25111 | IrInstruction *start_value = ir_implicit_cast(ira, &instruction->base, start_value_uncasted, switch_type); |
| 25064 | 25112 | if (type_is_invalid(start_value->value.type)) |
| 25065 | 25113 | return ira->codegen->invalid_instruction; |
| 25066 | 25114 | |
| 25067 | 25115 | IrInstruction *end_value_uncasted = range->end->child; |
| 25068 | 25116 | if (type_is_invalid(end_value_uncasted->value.type)) |
| 25069 | 25117 | return ira->codegen->invalid_instruction; |
| 25070 | | IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); |
| 25118 | IrInstruction *end_value = ir_implicit_cast(ira, &instruction->base, end_value_uncasted, switch_type); |
| 25071 | 25119 | if (type_is_invalid(end_value->value.type)) |
| 25072 | 25120 | return ira->codegen->invalid_instruction; |
| 25073 | 25121 | |
| ... | ... | @@ -25124,14 +25172,14 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 25124 | 25172 | IrInstruction *start_value_uncasted = range->start->child; |
| 25125 | 25173 | if (type_is_invalid(start_value_uncasted->value.type)) |
| 25126 | 25174 | return ira->codegen->invalid_instruction; |
| 25127 | | IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); |
| 25175 | IrInstruction *start_value = ir_implicit_cast(ira, &instruction->base, start_value_uncasted, switch_type); |
| 25128 | 25176 | if (type_is_invalid(start_value->value.type)) |
| 25129 | 25177 | return ira->codegen->invalid_instruction; |
| 25130 | 25178 | |
| 25131 | 25179 | IrInstruction *end_value_uncasted = range->end->child; |
| 25132 | 25180 | if (type_is_invalid(end_value_uncasted->value.type)) |
| 25133 | 25181 | return ira->codegen->invalid_instruction; |
| 25134 | | IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); |
| 25182 | IrInstruction *end_value = ir_implicit_cast(ira, &instruction->base, end_value_uncasted, switch_type); |
| 25135 | 25183 | if (type_is_invalid(end_value->value.type)) |
| 25136 | 25184 | return ira->codegen->invalid_instruction; |
| 25137 | 25185 | |
| ... | ... | @@ -25182,14 +25230,14 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 25182 | 25230 | IrInstruction *start_value = range->start->child; |
| 25183 | 25231 | if (type_is_invalid(start_value->value.type)) |
| 25184 | 25232 | return ira->codegen->invalid_instruction; |
| 25185 | | IrInstruction *casted_start_value = ir_implicit_cast(ira, start_value, switch_type); |
| 25233 | IrInstruction *casted_start_value = ir_implicit_cast(ira, &instruction->base, start_value, switch_type); |
| 25186 | 25234 | if (type_is_invalid(casted_start_value->value.type)) |
| 25187 | 25235 | return ira->codegen->invalid_instruction; |
| 25188 | 25236 | |
| 25189 | 25237 | IrInstruction *end_value = range->end->child; |
| 25190 | 25238 | if (type_is_invalid(end_value->value.type)) |
| 25191 | 25239 | return ira->codegen->invalid_instruction; |
| 25192 | | IrInstruction *casted_end_value = ir_implicit_cast(ira, end_value, switch_type); |
| 25240 | IrInstruction *casted_end_value = ir_implicit_cast(ira, &instruction->base, end_value, switch_type); |
| 25193 | 25241 | if (type_is_invalid(casted_end_value->value.type)) |
| 25194 | 25242 | return ira->codegen->invalid_instruction; |
| 25195 | 25243 | |
| ... | ... | @@ -25229,7 +25277,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 25229 | 25277 | |
| 25230 | 25278 | IrInstruction *value = range->start->child; |
| 25231 | 25279 | |
| 25232 | | IrInstruction *casted_value = ir_implicit_cast(ira, value, switch_type); |
| 25280 | IrInstruction *casted_value = ir_implicit_cast(ira, &instruction->base, value, switch_type); |
| 25233 | 25281 | if (type_is_invalid(casted_value->value.type)) |
| 25234 | 25282 | return ira->codegen->invalid_instruction; |
| 25235 | 25283 | |
| ... | ... | @@ -25290,7 +25338,7 @@ static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstruction |
| 25290 | 25338 | ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 25291 | 25339 | true, false, PtrLenUnknown, 0, 0, 0, false); |
| 25292 | 25340 | ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); |
| 25293 | | IrInstruction *casted_msg = ir_implicit_cast(ira, msg, str_type); |
| 25341 | IrInstruction *casted_msg = ir_implicit_cast(ira, &instruction->base, msg, str_type); |
| 25294 | 25342 | if (type_is_invalid(casted_msg->value.type)) |
| 25295 | 25343 | return ir_unreach_error(ira); |
| 25296 | 25344 | |
| ... | ... | @@ -25900,7 +25948,7 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc |
| 25900 | 25948 | ir_assert(get_src_ptr_type(ptr_type) != nullptr, source_instr); |
| 25901 | 25949 | ir_assert(type_has_bits(ptr_type), source_instr); |
| 25902 | 25950 | |
| 25903 | | IrInstruction *casted_int = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_usize); |
| 25951 | IrInstruction *casted_int = ir_implicit_cast(ira, source_instr, target, ira->codegen->builtin_types.entry_usize); |
| 25904 | 25952 | if (type_is_invalid(casted_int->value.type)) |
| 25905 | 25953 | return ira->codegen->invalid_instruction; |
| 25906 | 25954 | |
| ... | ... | @@ -26259,7 +26307,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru |
| 26259 | 26307 | |
| 26260 | 26308 | // TODO let this be volatile |
| 26261 | 26309 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 26262 | | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); |
| 26310 | IrInstruction *casted_ptr = ir_implicit_cast(ira, &instruction->base, ptr_inst, ptr_type); |
| 26263 | 26311 | if (type_is_invalid(casted_ptr->value.type)) |
| 26264 | 26312 | return ira->codegen->invalid_instruction; |
| 26265 | 26313 | |
| ... | ... | @@ -26282,7 +26330,7 @@ static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstru |
| 26282 | 26330 | if (type_is_invalid(operand->value.type)) |
| 26283 | 26331 | return ira->codegen->invalid_instruction; |
| 26284 | 26332 | |
| 26285 | | IrInstruction *casted_operand = ir_implicit_cast(ira, operand, operand_type); |
| 26333 | IrInstruction *casted_operand = ir_implicit_cast(ira, &instruction->base, operand, operand_type); |
| 26286 | 26334 | if (type_is_invalid(casted_operand->value.type)) |
| 26287 | 26335 | return ira->codegen->invalid_instruction; |
| 26288 | 26336 | |
| ... | ... | @@ -26321,7 +26369,7 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr |
| 26321 | 26369 | return ira->codegen->invalid_instruction; |
| 26322 | 26370 | |
| 26323 | 26371 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, true); |
| 26324 | | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); |
| 26372 | IrInstruction *casted_ptr = ir_implicit_cast(ira, &instruction->base, ptr_inst, ptr_type); |
| 26325 | 26373 | if (type_is_invalid(casted_ptr->value.type)) |
| 26326 | 26374 | return ira->codegen->invalid_instruction; |
| 26327 | 26375 | |
| ... | ... | @@ -26362,7 +26410,7 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst |
| 26362 | 26410 | return ira->codegen->invalid_instruction; |
| 26363 | 26411 | |
| 26364 | 26412 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 26365 | | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); |
| 26413 | IrInstruction *casted_ptr = ir_implicit_cast(ira, &instruction->base, ptr_inst, ptr_type); |
| 26366 | 26414 | if (type_is_invalid(casted_ptr->value.type)) |
| 26367 | 26415 | return ira->codegen->invalid_instruction; |
| 26368 | 26416 | |
| ... | ... | @@ -26370,7 +26418,7 @@ static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInst |
| 26370 | 26418 | if (type_is_invalid(value->value.type)) |
| 26371 | 26419 | return ira->codegen->invalid_instruction; |
| 26372 | 26420 | |
| 26373 | | IrInstruction *casted_value = ir_implicit_cast(ira, value, operand_type); |
| 26421 | IrInstruction *casted_value = ir_implicit_cast(ira, &instruction->base, value, operand_type); |
| 26374 | 26422 | if (type_is_invalid(casted_value->value.type)) |
| 26375 | 26423 | return ira->codegen->invalid_instruction; |
| 26376 | 26424 | |
| ... | ... | @@ -26609,7 +26657,7 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct |
| 26609 | 26657 | if (type_is_invalid(op1->value.type)) |
| 26610 | 26658 | return ira->codegen->invalid_instruction; |
| 26611 | 26659 | |
| 26612 | | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, float_type); |
| 26660 | IrInstruction *casted_op1 = ir_implicit_cast(ira, &instruction->base, op1, float_type); |
| 26613 | 26661 | if (type_is_invalid(casted_op1->value.type)) |
| 26614 | 26662 | return ira->codegen->invalid_instruction; |
| 26615 | 26663 | |
| ... | ... | @@ -26685,7 +26733,7 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 26685 | 26733 | bool is_vector = (vector_len != UINT32_MAX); |
| 26686 | 26734 | ZigType *op_type = is_vector ? get_vector_type(ira->codegen, vector_len, int_type) : int_type; |
| 26687 | 26735 | |
| 26688 | | IrInstruction *op = ir_implicit_cast(ira, uncasted_op, op_type); |
| 26736 | IrInstruction *op = ir_implicit_cast(ira, &instruction->base, uncasted_op, op_type); |
| 26689 | 26737 | if (type_is_invalid(op->value.type)) |
| 26690 | 26738 | return ira->codegen->invalid_instruction; |
| 26691 | 26739 | |
| ... | ... | @@ -26750,7 +26798,7 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr |
| 26750 | 26798 | if (type_is_invalid(int_type)) |
| 26751 | 26799 | return ira->codegen->invalid_instruction; |
| 26752 | 26800 | |
| 26753 | | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 26801 | IrInstruction *op = ir_implicit_cast(ira, &instruction->base, instruction->op->child, int_type); |
| 26754 | 26802 | if (type_is_invalid(op->value.type)) |
| 26755 | 26803 | return ira->codegen->invalid_instruction; |
| 26756 | 26804 | |
| ... | ... | @@ -26831,7 +26879,7 @@ static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstr |
| 26831 | 26879 | if (type_is_invalid(target->value.type)) |
| 26832 | 26880 | return ira->codegen->invalid_instruction; |
| 26833 | 26881 | |
| 26834 | | IrInstruction *casted_target = ir_implicit_cast(ira, target, tag_type); |
| 26882 | IrInstruction *casted_target = ir_implicit_cast(ira, &instruction->base, target, tag_type); |
| 26835 | 26883 | if (type_is_invalid(casted_target->value.type)) |
| 26836 | 26884 | return ira->codegen->invalid_instruction; |
| 26837 | 26885 | |
| ... | ... | @@ -26950,7 +26998,7 @@ static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrIns |
| 26950 | 26998 | ZigType *dest_type = ir_resolve_type(ira, instruction->result_loc_cast->base.source_instruction->child); |
| 26951 | 26999 | if (type_is_invalid(dest_type)) |
| 26952 | 27000 | return ira->codegen->invalid_instruction; |
| 26953 | | return ir_implicit_cast_with_result(ira, &instruction->base, operand, dest_type, nullptr); |
| 27001 | return ir_implicit_cast(ira, &instruction->base, operand, dest_type); |
| 26954 | 27002 | } |
| 26955 | 27003 | |
| 26956 | 27004 | static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInstructionBitCastSrc *instruction) { |
| ... | ... | @@ -27063,7 +27111,7 @@ static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruct |
| 27063 | 27111 | } |
| 27064 | 27112 | |
| 27065 | 27113 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, result_type); |
| 27066 | | IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); |
| 27114 | IrInstruction *casted_frame = ir_implicit_cast(ira, source_instr, frame, any_frame_type); |
| 27067 | 27115 | if (type_is_invalid(casted_frame->value.type)) |
| 27068 | 27116 | return ira->codegen->invalid_instruction; |
| 27069 | 27117 | |
| ... | ... | @@ -27127,7 +27175,7 @@ static IrInstruction *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstructio |
| 27127 | 27175 | } |
| 27128 | 27176 | |
| 27129 | 27177 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, nullptr); |
| 27130 | | IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); |
| 27178 | IrInstruction *casted_frame = ir_implicit_cast(ira, &instruction->base, frame, any_frame_type); |
| 27131 | 27179 | if (type_is_invalid(casted_frame->value.type)) |
| 27132 | 27180 | return ira->codegen->invalid_instruction; |
| 27133 | 27181 | |
| ... | ... | @@ -27979,7 +28027,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { |
| 27979 | 28027 | if (lazy_slice_type->sentinel != nullptr) { |
| 27980 | 28028 | if (type_is_invalid(lazy_slice_type->sentinel->value.type)) |
| 27981 | 28029 | return ErrorSemanticAnalyzeFail; |
| 27982 | | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_slice_type->sentinel, elem_type); |
| 28030 | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_slice_type->sentinel, lazy_slice_type->sentinel, elem_type); |
| 27983 | 28031 | if (type_is_invalid(sentinel->value.type)) |
| 27984 | 28032 | return ErrorSemanticAnalyzeFail; |
| 27985 | 28033 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| ... | ... | @@ -28057,7 +28105,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ConstExprValue *val) { |
| 28057 | 28105 | if (lazy_ptr_type->sentinel != nullptr) { |
| 28058 | 28106 | if (type_is_invalid(lazy_ptr_type->sentinel->value.type)) |
| 28059 | 28107 | return ErrorSemanticAnalyzeFail; |
| 28060 | | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_ptr_type->sentinel, elem_type); |
| 28108 | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_ptr_type->sentinel, lazy_ptr_type->sentinel, elem_type); |
| 28061 | 28109 | if (type_is_invalid(sentinel->value.type)) |
| 28062 | 28110 | return ErrorSemanticAnalyzeFail; |
| 28063 | 28111 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |