| ... | @@ -28,144 +28,134 @@ const Decl = Module.Decl; | ... | @@ -28,144 +28,134 @@ const Decl = Module.Decl; |
| 28 | | 28 | |
| 29 | pub fn analyzeInst(mod: *Module, scope: *Scope, old_inst: *zir.Inst) InnerError!*Inst { | 29 | pub fn analyzeInst(mod: *Module, scope: *Scope, old_inst: *zir.Inst) InnerError!*Inst { |
| 30 | switch (old_inst.tag) { | 30 | switch (old_inst.tag) { |
| 31 | .alloc => return analyzeInstAlloc(mod, scope, old_inst.castTag(.alloc).?), | 31 | .alloc => return zirAlloc(mod, scope, old_inst.castTag(.alloc).?), |
| 32 | .alloc_mut => return analyzeInstAllocMut(mod, scope, old_inst.castTag(.alloc_mut).?), | 32 | .alloc_mut => return zirAllocMut(mod, scope, old_inst.castTag(.alloc_mut).?), |
| 33 | .alloc_inferred => return analyzeInstAllocInferred( | 33 | .alloc_inferred => return zirAllocInferred(mod, scope, old_inst.castTag(.alloc_inferred).?, .inferred_alloc_const), |
| 34 | mod, | 34 | .alloc_inferred_mut => return zirAllocInferred(mod, scope, old_inst.castTag(.alloc_inferred_mut).?, .inferred_alloc_mut), |
| 35 | scope, | 35 | .arg => return zirArg(mod, scope, old_inst.castTag(.arg).?), |
| 36 | old_inst.castTag(.alloc_inferred).?, | 36 | .bitcast_ref => return zirBitcastRef(mod, scope, old_inst.castTag(.bitcast_ref).?), |
| 37 | .inferred_alloc_const, | 37 | .bitcast_result_ptr => return zirBitcastResultPtr(mod, scope, old_inst.castTag(.bitcast_result_ptr).?), |
| 38 | ), | 38 | .block => return zirBlock(mod, scope, old_inst.castTag(.block).?, false), |
| 39 | .alloc_inferred_mut => return analyzeInstAllocInferred( | 39 | .block_comptime => return zirBlock(mod, scope, old_inst.castTag(.block_comptime).?, true), |
| 40 | mod, | 40 | .block_flat => return zirBlockFlat(mod, scope, old_inst.castTag(.block_flat).?, false), |
| 41 | scope, | 41 | .block_comptime_flat => return zirBlockFlat(mod, scope, old_inst.castTag(.block_comptime_flat).?, true), |
| 42 | old_inst.castTag(.alloc_inferred_mut).?, | 42 | .@"break" => return zirBreak(mod, scope, old_inst.castTag(.@"break").?), |
| 43 | .inferred_alloc_mut, | 43 | .breakpoint => return zirBreakpoint(mod, scope, old_inst.castTag(.breakpoint).?), |
| 44 | ), | 44 | .break_void => return zirBreakVoid(mod, scope, old_inst.castTag(.break_void).?), |
| 45 | .arg => return analyzeInstArg(mod, scope, old_inst.castTag(.arg).?), | 45 | .call => return zirCall(mod, scope, old_inst.castTag(.call).?), |
| 46 | .bitcast_ref => return bitCastRef(mod, scope, old_inst.castTag(.bitcast_ref).?), | 46 | .coerce_result_block_ptr => return zirCoerceResultBlockPtr(mod, scope, old_inst.castTag(.coerce_result_block_ptr).?), |
| 47 | .bitcast_result_ptr => return bitCastResultPtr(mod, scope, old_inst.castTag(.bitcast_result_ptr).?), | 47 | .coerce_result_ptr => return zirCoerceResultPtr(mod, scope, old_inst.castTag(.coerce_result_ptr).?), |
| 48 | .block => return analyzeInstBlock(mod, scope, old_inst.castTag(.block).?, false), | 48 | .compile_error => return zirCompileError(mod, scope, old_inst.castTag(.compile_error).?), |
| 49 | .block_comptime => return analyzeInstBlock(mod, scope, old_inst.castTag(.block_comptime).?, true), | 49 | .compile_log => return zirCompileLog(mod, scope, old_inst.castTag(.compile_log).?), |
| 50 | .block_flat => return analyzeInstBlockFlat(mod, scope, old_inst.castTag(.block_flat).?, false), | 50 | .@"const" => return zirConst(mod, scope, old_inst.castTag(.@"const").?), |
| 51 | .block_comptime_flat => return analyzeInstBlockFlat(mod, scope, old_inst.castTag(.block_comptime_flat).?, true), | 51 | .dbg_stmt => return zirDbgStmt(mod, scope, old_inst.castTag(.dbg_stmt).?), |
| 52 | .@"break" => return analyzeInstBreak(mod, scope, old_inst.castTag(.@"break").?), | 52 | .decl_ref => return zirDeclRef(mod, scope, old_inst.castTag(.decl_ref).?), |
| 53 | .breakpoint => return analyzeInstBreakpoint(mod, scope, old_inst.castTag(.breakpoint).?), | 53 | .decl_ref_str => return zirDeclRefStr(mod, scope, old_inst.castTag(.decl_ref_str).?), |
| 54 | .breakvoid => return analyzeInstBreakVoid(mod, scope, old_inst.castTag(.breakvoid).?), | 54 | .decl_val => return zirDeclVal(mod, scope, old_inst.castTag(.decl_val).?), |
| 55 | .call => return call(mod, scope, old_inst.castTag(.call).?), | 55 | .ensure_result_used => return zirEnsureResultUsed(mod, scope, old_inst.castTag(.ensure_result_used).?), |
| 56 | .coerce_result_block_ptr => return analyzeInstCoerceResultBlockPtr(mod, scope, old_inst.castTag(.coerce_result_block_ptr).?), | 56 | .ensure_result_non_error => return zirEnsureResultNonError(mod, scope, old_inst.castTag(.ensure_result_non_error).?), |
| 57 | .coerce_result_ptr => return analyzeInstCoerceResultPtr(mod, scope, old_inst.castTag(.coerce_result_ptr).?), | 57 | .indexable_ptr_len => return zirIndexablePtrLen(mod, scope, old_inst.castTag(.indexable_ptr_len).?), |
| 58 | .coerce_to_ptr_elem => return analyzeInstCoerceToPtrElem(mod, scope, old_inst.castTag(.coerce_to_ptr_elem).?), | 58 | .ref => return zirRef(mod, scope, old_inst.castTag(.ref).?), |
| 59 | .compileerror => return analyzeInstCompileError(mod, scope, old_inst.castTag(.compileerror).?), | 59 | .resolve_inferred_alloc => return zirResolveInferredAlloc(mod, scope, old_inst.castTag(.resolve_inferred_alloc).?), |
| 60 | .compilelog => return analyzeInstCompileLog(mod, scope, old_inst.castTag(.compilelog).?), | 60 | .ret_ptr => return zirRetPtr(mod, scope, old_inst.castTag(.ret_ptr).?), |
| 61 | .@"const" => return analyzeInstConst(mod, scope, old_inst.castTag(.@"const").?), | 61 | .ret_type => return zirRetType(mod, scope, old_inst.castTag(.ret_type).?), |
| 62 | .dbg_stmt => return analyzeInstDbgStmt(mod, scope, old_inst.castTag(.dbg_stmt).?), | 62 | .store_to_block_ptr => return zirStoreToBlockPtr(mod, scope, old_inst.castTag(.store_to_block_ptr).?), |
| 63 | .declref => return declRef(mod, scope, old_inst.castTag(.declref).?), | 63 | .store_to_inferred_ptr => return zirStoreToInferredPtr(mod, scope, old_inst.castTag(.store_to_inferred_ptr).?), |
| 64 | .declref_str => return analyzeInstDeclRefStr(mod, scope, old_inst.castTag(.declref_str).?), | 64 | .single_const_ptr_type => return zirSimplePtrType(mod, scope, old_inst.castTag(.single_const_ptr_type).?, false, .One), |
| 65 | .declval => return declVal(mod, scope, old_inst.castTag(.declval).?), | 65 | .single_mut_ptr_type => return zirSimplePtrType(mod, scope, old_inst.castTag(.single_mut_ptr_type).?, true, .One), |
| 66 | .ensure_result_used => return analyzeInstEnsureResultUsed(mod, scope, old_inst.castTag(.ensure_result_used).?), | 66 | .many_const_ptr_type => return zirSimplePtrType(mod, scope, old_inst.castTag(.many_const_ptr_type).?, false, .Many), |
| 67 | .ensure_result_non_error => return analyzeInstEnsureResultNonError(mod, scope, old_inst.castTag(.ensure_result_non_error).?), | 67 | .many_mut_ptr_type => return zirSimplePtrType(mod, scope, old_inst.castTag(.many_mut_ptr_type).?, true, .Many), |
| 68 | .indexable_ptr_len => return indexablePtrLen(mod, scope, old_inst.castTag(.indexable_ptr_len).?), | 68 | .c_const_ptr_type => return zirSimplePtrType(mod, scope, old_inst.castTag(.c_const_ptr_type).?, false, .C), |
| 69 | .ref => return ref(mod, scope, old_inst.castTag(.ref).?), | 69 | .c_mut_ptr_type => return zirSimplePtrType(mod, scope, old_inst.castTag(.c_mut_ptr_type).?, true, .C), |
| 70 | .resolve_inferred_alloc => return analyzeInstResolveInferredAlloc(mod, scope, old_inst.castTag(.resolve_inferred_alloc).?), | 70 | .const_slice_type => return zirSimplePtrType(mod, scope, old_inst.castTag(.const_slice_type).?, false, .Slice), |
| 71 | .ret_ptr => return analyzeInstRetPtr(mod, scope, old_inst.castTag(.ret_ptr).?), | 71 | .mut_slice_type => return zirSimplePtrType(mod, scope, old_inst.castTag(.mut_slice_type).?, true, .Slice), |
| 72 | .ret_type => return analyzeInstRetType(mod, scope, old_inst.castTag(.ret_type).?), | 72 | .ptr_type => return zirPtrType(mod, scope, old_inst.castTag(.ptr_type).?), |
| 73 | .store_to_inferred_ptr => return analyzeInstStoreToInferredPtr(mod, scope, old_inst.castTag(.store_to_inferred_ptr).?), | 73 | .store => return zirStore(mod, scope, old_inst.castTag(.store).?), |
| 74 | .single_const_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.single_const_ptr_type).?, false, .One), | 74 | .set_eval_branch_quota => return zirSetEvalBranchQuota(mod, scope, old_inst.castTag(.set_eval_branch_quota).?), |
| 75 | .single_mut_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.single_mut_ptr_type).?, true, .One), | 75 | .str => return zirStr(mod, scope, old_inst.castTag(.str).?), |
| 76 | .many_const_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.many_const_ptr_type).?, false, .Many), | 76 | .int => return zirInt(mod, scope, old_inst.castTag(.int).?), |
| 77 | .many_mut_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.many_mut_ptr_type).?, true, .Many), | 77 | .int_type => return zirIntType(mod, scope, old_inst.castTag(.int_type).?), |
| 78 | .c_const_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.c_const_ptr_type).?, false, .C), | 78 | .loop => return zirLoop(mod, scope, old_inst.castTag(.loop).?), |
| 79 | .c_mut_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.c_mut_ptr_type).?, true, .C), | 79 | .param_type => return zirParamType(mod, scope, old_inst.castTag(.param_type).?), |
| 80 | .const_slice_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.const_slice_type).?, false, .Slice), | 80 | .ptrtoint => return zirPtrtoint(mod, scope, old_inst.castTag(.ptrtoint).?), |
| 81 | .mut_slice_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.mut_slice_type).?, true, .Slice), | 81 | .field_ptr => return zirFieldPtr(mod, scope, old_inst.castTag(.field_ptr).?), |
| 82 | .ptr_type => return analyzeInstPtrType(mod, scope, old_inst.castTag(.ptr_type).?), | 82 | .field_val => return zirFieldVal(mod, scope, old_inst.castTag(.field_val).?), |
| 83 | .store => return analyzeInstStore(mod, scope, old_inst.castTag(.store).?), | 83 | .field_ptr_named => return zirFieldPtrNamed(mod, scope, old_inst.castTag(.field_ptr_named).?), |
| 84 | .set_eval_branch_quota => return analyzeInstSetEvalBranchQuota(mod, scope, old_inst.castTag(.set_eval_branch_quota).?), | 84 | .field_val_named => return zirFieldValNamed(mod, scope, old_inst.castTag(.field_val_named).?), |
| 85 | .str => return analyzeInstStr(mod, scope, old_inst.castTag(.str).?), | 85 | .deref => return zirDeref(mod, scope, old_inst.castTag(.deref).?), |
| 86 | .int => return analyzeInstInt(mod, scope, old_inst.castTag(.int).?), | 86 | .as => return zirAs(mod, scope, old_inst.castTag(.as).?), |
| 87 | .inttype => return analyzeInstIntType(mod, scope, old_inst.castTag(.inttype).?), | 87 | .@"asm" => return zirAsm(mod, scope, old_inst.castTag(.@"asm").?), |
| 88 | .loop => return analyzeInstLoop(mod, scope, old_inst.castTag(.loop).?), | 88 | .unreachable_safe => return zirUnreachable(mod, scope, old_inst.castTag(.unreachable_safe).?, true), |
| 89 | .param_type => return analyzeInstParamType(mod, scope, old_inst.castTag(.param_type).?), | 89 | .unreachable_unsafe => return zirUnreachable(mod, scope, old_inst.castTag(.unreachable_unsafe).?, false), |
| 90 | .ptrtoint => return analyzeInstPtrToInt(mod, scope, old_inst.castTag(.ptrtoint).?), | 90 | .@"return" => return zirReturn(mod, scope, old_inst.castTag(.@"return").?), |
| 91 | .field_ptr => return fieldPtr(mod, scope, old_inst.castTag(.field_ptr).?), | 91 | .return_void => return zirReturnVoid(mod, scope, old_inst.castTag(.return_void).?), |
| 92 | .field_val => return fieldVal(mod, scope, old_inst.castTag(.field_val).?), | 92 | .@"fn" => return zirFn(mod, scope, old_inst.castTag(.@"fn").?), |
| 93 | .field_ptr_named => return fieldPtrNamed(mod, scope, old_inst.castTag(.field_ptr_named).?), | 93 | .@"export" => return zirExport(mod, scope, old_inst.castTag(.@"export").?), |
| 94 | .field_val_named => return fieldValNamed(mod, scope, old_inst.castTag(.field_val_named).?), | 94 | .primitive => return zirPrimitive(mod, scope, old_inst.castTag(.primitive).?), |
| 95 | .deref => return analyzeInstDeref(mod, scope, old_inst.castTag(.deref).?), | 95 | .fntype => return zirFnType(mod, scope, old_inst.castTag(.fntype).?), |
| 96 | .as => return analyzeInstAs(mod, scope, old_inst.castTag(.as).?), | 96 | .intcast => return zirIntcast(mod, scope, old_inst.castTag(.intcast).?), |
| 97 | .@"asm" => return analyzeInstAsm(mod, scope, old_inst.castTag(.@"asm").?), | 97 | .bitcast => return zirBitcast(mod, scope, old_inst.castTag(.bitcast).?), |
| 98 | .@"unreachable" => return analyzeInstUnreachable(mod, scope, old_inst.castTag(.@"unreachable").?, true), | 98 | .floatcast => return zirFloatcast(mod, scope, old_inst.castTag(.floatcast).?), |
| 99 | .unreach_nocheck => return analyzeInstUnreachable(mod, scope, old_inst.castTag(.unreach_nocheck).?, false), | 99 | .elem_ptr => return zirElemPtr(mod, scope, old_inst.castTag(.elem_ptr).?), |
| 100 | .@"return" => return analyzeInstRet(mod, scope, old_inst.castTag(.@"return").?), | 100 | .elem_val => return zirElemVal(mod, scope, old_inst.castTag(.elem_val).?), |
| 101 | .returnvoid => return analyzeInstRetVoid(mod, scope, old_inst.castTag(.returnvoid).?), | 101 | .add => return zirArithmetic(mod, scope, old_inst.castTag(.add).?), |
| 102 | .@"fn" => return analyzeInstFn(mod, scope, old_inst.castTag(.@"fn").?), | 102 | .addwrap => return zirArithmetic(mod, scope, old_inst.castTag(.addwrap).?), |
| 103 | .@"export" => return analyzeInstExport(mod, scope, old_inst.castTag(.@"export").?), | 103 | .sub => return zirArithmetic(mod, scope, old_inst.castTag(.sub).?), |
| 104 | .primitive => return analyzeInstPrimitive(mod, scope, old_inst.castTag(.primitive).?), | 104 | .subwrap => return zirArithmetic(mod, scope, old_inst.castTag(.subwrap).?), |
| 105 | .fntype => return analyzeInstFnType(mod, scope, old_inst.castTag(.fntype).?), | 105 | .mul => return zirArithmetic(mod, scope, old_inst.castTag(.mul).?), |
| 106 | .intcast => return analyzeInstIntCast(mod, scope, old_inst.castTag(.intcast).?), | 106 | .mulwrap => return zirArithmetic(mod, scope, old_inst.castTag(.mulwrap).?), |
| 107 | .bitcast => return analyzeInstBitCast(mod, scope, old_inst.castTag(.bitcast).?), | 107 | .div => return zirArithmetic(mod, scope, old_inst.castTag(.div).?), |
| 108 | .floatcast => return analyzeInstFloatCast(mod, scope, old_inst.castTag(.floatcast).?), | 108 | .mod_rem => return zirArithmetic(mod, scope, old_inst.castTag(.mod_rem).?), |
| 109 | .elem_ptr => return elemPtr(mod, scope, old_inst.castTag(.elem_ptr).?), | 109 | .array_cat => return zirArrayCat(mod, scope, old_inst.castTag(.array_cat).?), |
| 110 | .elem_val => return elemVal(mod, scope, old_inst.castTag(.elem_val).?), | 110 | .array_mul => return zirArrayMul(mod, scope, old_inst.castTag(.array_mul).?), |
| 111 | .add => return analyzeInstArithmetic(mod, scope, old_inst.castTag(.add).?), | 111 | .bit_and => return zirBitwise(mod, scope, old_inst.castTag(.bit_and).?), |
| 112 | .addwrap => return analyzeInstArithmetic(mod, scope, old_inst.castTag(.addwrap).?), | 112 | .bit_not => return zirBitNot(mod, scope, old_inst.castTag(.bit_not).?), |
| 113 | .sub => return analyzeInstArithmetic(mod, scope, old_inst.castTag(.sub).?), | 113 | .bit_or => return zirBitwise(mod, scope, old_inst.castTag(.bit_or).?), |
| 114 | .subwrap => return analyzeInstArithmetic(mod, scope, old_inst.castTag(.subwrap).?), | 114 | .xor => return zirBitwise(mod, scope, old_inst.castTag(.xor).?), |
| 115 | .mul => return analyzeInstArithmetic(mod, scope, old_inst.castTag(.mul).?), | 115 | .shl => return zirShl(mod, scope, old_inst.castTag(.shl).?), |
| 116 | .mulwrap => return analyzeInstArithmetic(mod, scope, old_inst.castTag(.mulwrap).?), | 116 | .shr => return zirShr(mod, scope, old_inst.castTag(.shr).?), |
| 117 | .div => return analyzeInstArithmetic(mod, scope, old_inst.castTag(.div).?), | 117 | .cmp_lt => return zirCmp(mod, scope, old_inst.castTag(.cmp_lt).?, .lt), |
| 118 | .mod_rem => return analyzeInstArithmetic(mod, scope, old_inst.castTag(.mod_rem).?), | 118 | .cmp_lte => return zirCmp(mod, scope, old_inst.castTag(.cmp_lte).?, .lte), |
| 119 | .array_cat => return analyzeInstArrayCat(mod, scope, old_inst.castTag(.array_cat).?), | 119 | .cmp_eq => return zirCmp(mod, scope, old_inst.castTag(.cmp_eq).?, .eq), |
| 120 | .array_mul => return analyzeInstArrayMul(mod, scope, old_inst.castTag(.array_mul).?), | 120 | .cmp_gte => return zirCmp(mod, scope, old_inst.castTag(.cmp_gte).?, .gte), |
| 121 | .bitand => return analyzeInstBitwise(mod, scope, old_inst.castTag(.bitand).?), | 121 | .cmp_gt => return zirCmp(mod, scope, old_inst.castTag(.cmp_gt).?, .gt), |
| 122 | .bitnot => return analyzeInstBitNot(mod, scope, old_inst.castTag(.bitnot).?), | 122 | .cmp_neq => return zirCmp(mod, scope, old_inst.castTag(.cmp_neq).?, .neq), |
| 123 | .bitor => return analyzeInstBitwise(mod, scope, old_inst.castTag(.bitor).?), | 123 | .condbr => return zirCondbr(mod, scope, old_inst.castTag(.condbr).?), |
| 124 | .xor => return analyzeInstBitwise(mod, scope, old_inst.castTag(.xor).?), | 124 | .is_null => return zirIsNull(mod, scope, old_inst.castTag(.is_null).?, false), |
| 125 | .shl => return analyzeInstShl(mod, scope, old_inst.castTag(.shl).?), | 125 | .is_non_null => return zirIsNull(mod, scope, old_inst.castTag(.is_non_null).?, true), |
| 126 | .shr => return analyzeInstShr(mod, scope, old_inst.castTag(.shr).?), | 126 | .is_null_ptr => return zirIsNullPtr(mod, scope, old_inst.castTag(.is_null_ptr).?, false), |
| 127 | .cmp_lt => return analyzeInstCmp(mod, scope, old_inst.castTag(.cmp_lt).?, .lt), | 127 | .is_non_null_ptr => return zirIsNullPtr(mod, scope, old_inst.castTag(.is_non_null_ptr).?, true), |
| 128 | .cmp_lte => return analyzeInstCmp(mod, scope, old_inst.castTag(.cmp_lte).?, .lte), | 128 | .is_err => return zirIsErr(mod, scope, old_inst.castTag(.is_err).?), |
| 129 | .cmp_eq => return analyzeInstCmp(mod, scope, old_inst.castTag(.cmp_eq).?, .eq), | 129 | .is_err_ptr => return zirIsErrPtr(mod, scope, old_inst.castTag(.is_err_ptr).?), |
| 130 | .cmp_gte => return analyzeInstCmp(mod, scope, old_inst.castTag(.cmp_gte).?, .gte), | 130 | .bool_not => return zirBoolNot(mod, scope, old_inst.castTag(.bool_not).?), |
| 131 | .cmp_gt => return analyzeInstCmp(mod, scope, old_inst.castTag(.cmp_gt).?, .gt), | 131 | .typeof => return zirTypeof(mod, scope, old_inst.castTag(.typeof).?), |
| 132 | .cmp_neq => return analyzeInstCmp(mod, scope, old_inst.castTag(.cmp_neq).?, .neq), | 132 | .typeof_peer => return zirTypeofPeer(mod, scope, old_inst.castTag(.typeof_peer).?), |
| 133 | .condbr => return analyzeInstCondBr(mod, scope, old_inst.castTag(.condbr).?), | 133 | .optional_type => return zirOptionalType(mod, scope, old_inst.castTag(.optional_type).?), |
| 134 | .is_null => return isNull(mod, scope, old_inst.castTag(.is_null).?, false), | 134 | .optional_payload_safe => return zirOptionalPayload(mod, scope, old_inst.castTag(.optional_payload_safe).?, true), |
| 135 | .is_non_null => return isNull(mod, scope, old_inst.castTag(.is_non_null).?, true), | 135 | .optional_payload_unsafe => return zirOptionalPayload(mod, scope, old_inst.castTag(.optional_payload_unsafe).?, false), |
| 136 | .is_null_ptr => return isNullPtr(mod, scope, old_inst.castTag(.is_null_ptr).?, false), | 136 | .optional_payload_safe_ptr => return zirOptionalPayloadPtr(mod, scope, old_inst.castTag(.optional_payload_safe_ptr).?, true), |
| 137 | .is_non_null_ptr => return isNullPtr(mod, scope, old_inst.castTag(.is_non_null_ptr).?, true), | 137 | .optional_payload_unsafe_ptr => return zirOptionalPayloadPtr(mod, scope, old_inst.castTag(.optional_payload_unsafe_ptr).?, false), |
| 138 | .is_err => return isErr(mod, scope, old_inst.castTag(.is_err).?), | 138 | .err_union_payload_safe => return zirErrUnionPayload(mod, scope, old_inst.castTag(.err_union_payload_safe).?, true), |
| 139 | .is_err_ptr => return isErrPtr(mod, scope, old_inst.castTag(.is_err_ptr).?), | 139 | .err_union_payload_unsafe => return zirErrUnionPayload(mod, scope, old_inst.castTag(.err_union_payload_unsafe).?, false), |
| 140 | .boolnot => return analyzeInstBoolNot(mod, scope, old_inst.castTag(.boolnot).?), | 140 | .err_union_payload_safe_ptr => return zirErrUnionPayloadPtr(mod, scope, old_inst.castTag(.err_union_payload_safe_ptr).?, true), |
| 141 | .typeof => return analyzeInstTypeOf(mod, scope, old_inst.castTag(.typeof).?), | 141 | .err_union_payload_unsafe_ptr => return zirErrUnionPayloadPtr(mod, scope, old_inst.castTag(.err_union_payload_unsafe_ptr).?, false), |
| 142 | .typeof_peer => return analyzeInstTypeOfPeer(mod, scope, old_inst.castTag(.typeof_peer).?), | 142 | .err_union_code => return zirErrUnionCode(mod, scope, old_inst.castTag(.err_union_code).?), |
| 143 | .optional_type => return analyzeInstOptionalType(mod, scope, old_inst.castTag(.optional_type).?), | 143 | .err_union_code_ptr => return zirErrUnionCodePtr(mod, scope, old_inst.castTag(.err_union_code_ptr).?), |
| 144 | .optional_payload_safe => return optionalPayload(mod, scope, old_inst.castTag(.optional_payload_safe).?, true), | 144 | .ensure_err_payload_void => return zirEnsureErrPayloadVoid(mod, scope, old_inst.castTag(.ensure_err_payload_void).?), |
| 145 | .optional_payload_unsafe => return optionalPayload(mod, scope, old_inst.castTag(.optional_payload_unsafe).?, false), | 145 | .array_type => return zirArrayType(mod, scope, old_inst.castTag(.array_type).?), |
| 146 | .optional_payload_safe_ptr => return optionalPayloadPtr(mod, scope, old_inst.castTag(.optional_payload_safe_ptr).?, true), | 146 | .array_type_sentinel => return zirArrayTypeSentinel(mod, scope, old_inst.castTag(.array_type_sentinel).?), |
| 147 | .optional_payload_unsafe_ptr => return optionalPayloadPtr(mod, scope, old_inst.castTag(.optional_payload_unsafe_ptr).?, false), | 147 | .enum_literal => return zirEnumLiteral(mod, scope, old_inst.castTag(.enum_literal).?), |
| 148 | .err_union_payload_safe => return errorUnionPayload(mod, scope, old_inst.castTag(.err_union_payload_safe).?, true), | 148 | .merge_error_sets => return zirMergeErrorSets(mod, scope, old_inst.castTag(.merge_error_sets).?), |
| 149 | .err_union_payload_unsafe => return errorUnionPayload(mod, scope, old_inst.castTag(.err_union_payload_unsafe).?, false), | 149 | .error_union_type => return zirErrorUnionType(mod, scope, old_inst.castTag(.error_union_type).?), |
| 150 | .err_union_payload_safe_ptr => return errorUnionPayloadPtr(mod, scope, old_inst.castTag(.err_union_payload_safe_ptr).?, true), | 150 | .anyframe_type => return zirAnyframeType(mod, scope, old_inst.castTag(.anyframe_type).?), |
| 151 | .err_union_payload_unsafe_ptr => return errorUnionPayloadPtr(mod, scope, old_inst.castTag(.err_union_payload_unsafe_ptr).?, false), | 151 | .error_set => return zirErrorSet(mod, scope, old_inst.castTag(.error_set).?), |
| 152 | .err_union_code => return errorUnionCode(mod, scope, old_inst.castTag(.err_union_code).?), | 152 | .slice => return zirSlice(mod, scope, old_inst.castTag(.slice).?), |
| 153 | .err_union_code_ptr => return errorUnionCodePtr(mod, scope, old_inst.castTag(.err_union_code_ptr).?), | 153 | .slice_start => return zirSliceStart(mod, scope, old_inst.castTag(.slice_start).?), |
| 154 | .ensure_err_payload_void => return analyzeInstEnsureErrPayloadVoid(mod, scope, old_inst.castTag(.ensure_err_payload_void).?), | 154 | .import => return zirImport(mod, scope, old_inst.castTag(.import).?), |
| 155 | .array_type => return analyzeInstArrayType(mod, scope, old_inst.castTag(.array_type).?), | 155 | .switchbr => return zirSwitchbr(mod, scope, old_inst.castTag(.switchbr).?), |
| 156 | .array_type_sentinel => return analyzeInstArrayTypeSentinel(mod, scope, old_inst.castTag(.array_type_sentinel).?), | 156 | .switch_range => return zirSwitchRange(mod, scope, old_inst.castTag(.switch_range).?), |
| 157 | .enum_literal => return analyzeInstEnumLiteral(mod, scope, old_inst.castTag(.enum_literal).?), | 157 | .bool_and => return zirBoolOp(mod, scope, old_inst.castTag(.bool_and).?), |
| 158 | .merge_error_sets => return analyzeInstMergeErrorSets(mod, scope, old_inst.castTag(.merge_error_sets).?), | 158 | .bool_or => return zirBoolOp(mod, scope, old_inst.castTag(.bool_or).?), |
| 159 | .error_union_type => return analyzeInstErrorUnionType(mod, scope, old_inst.castTag(.error_union_type).?), | | |
| 160 | .anyframe_type => return analyzeInstAnyframeType(mod, scope, old_inst.castTag(.anyframe_type).?), | | |
| 161 | .error_set => return analyzeInstErrorSet(mod, scope, old_inst.castTag(.error_set).?), | | |
| 162 | .slice => return analyzeInstSlice(mod, scope, old_inst.castTag(.slice).?), | | |
| 163 | .slice_start => return analyzeInstSliceStart(mod, scope, old_inst.castTag(.slice_start).?), | | |
| 164 | .import => return analyzeInstImport(mod, scope, old_inst.castTag(.import).?), | | |
| 165 | .switchbr => return analyzeInstSwitchBr(mod, scope, old_inst.castTag(.switchbr).?), | | |
| 166 | .switch_range => return analyzeInstSwitchRange(mod, scope, old_inst.castTag(.switch_range).?), | | |
| 167 | .booland => return analyzeInstBoolOp(mod, scope, old_inst.castTag(.booland).?), | | |
| 168 | .boolor => return analyzeInstBoolOp(mod, scope, old_inst.castTag(.boolor).?), | | |
| 169 | | 159 | |
| 170 | .container_field_named, | 160 | .container_field_named, |
| 171 | .container_field_typed, | 161 | .container_field_typed, |
| ... | @@ -258,7 +248,7 @@ pub fn resolveInstConst(mod: *Module, scope: *Scope, old_inst: *zir.Inst) InnerE | ... | @@ -258,7 +248,7 @@ pub fn resolveInstConst(mod: *Module, scope: *Scope, old_inst: *zir.Inst) InnerE |
| 258 | }; | 248 | }; |
| 259 | } | 249 | } |
| 260 | | 250 | |
| 261 | fn analyzeInstConst(mod: *Module, scope: *Scope, const_inst: *zir.Inst.Const) InnerError!*Inst { | 251 | fn zirConst(mod: *Module, scope: *Scope, const_inst: *zir.Inst.Const) InnerError!*Inst { |
| 262 | const tracy = trace(@src()); | 252 | const tracy = trace(@src()); |
| 263 | defer tracy.end(); | 253 | defer tracy.end(); |
| 264 | // Move the TypedValue from old memory to new memory. This allows freeing the ZIR instructions | 254 | // Move the TypedValue from old memory to new memory. This allows freeing the ZIR instructions |
| ... | @@ -275,44 +265,35 @@ fn analyzeConstInst(mod: *Module, scope: *Scope, old_inst: *zir.Inst) InnerError | ... | @@ -275,44 +265,35 @@ fn analyzeConstInst(mod: *Module, scope: *Scope, old_inst: *zir.Inst) InnerError |
| 275 | }; | 265 | }; |
| 276 | } | 266 | } |
| 277 | | 267 | |
| 278 | fn analyzeInstCoerceResultBlockPtr( | 268 | fn zirCoerceResultBlockPtr( |
| 279 | mod: *Module, | 269 | mod: *Module, |
| 280 | scope: *Scope, | 270 | scope: *Scope, |
| 281 | inst: *zir.Inst.CoerceResultBlockPtr, | 271 | inst: *zir.Inst.CoerceResultBlockPtr, |
| 282 | ) InnerError!*Inst { | 272 | ) InnerError!*Inst { |
| 283 | const tracy = trace(@src()); | 273 | const tracy = trace(@src()); |
| 284 | defer tracy.end(); | 274 | defer tracy.end(); |
| 285 | return mod.fail(scope, inst.base.src, "TODO implement analyzeInstCoerceResultBlockPtr", .{}); | 275 | return mod.fail(scope, inst.base.src, "TODO implement zirCoerceResultBlockPtr", .{}); |
| 286 | } | 276 | } |
| 287 | | 277 | |
| 288 | fn bitCastRef(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 278 | fn zirBitcastRef(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 289 | const tracy = trace(@src()); | 279 | const tracy = trace(@src()); |
| 290 | defer tracy.end(); | 280 | defer tracy.end(); |
| 291 | return mod.fail(scope, inst.base.src, "TODO implement zir_sema.bitCastRef", .{}); | 281 | return mod.fail(scope, inst.base.src, "TODO implement zir_sema.zirBitcastRef", .{}); |
| 292 | } | 282 | } |
| 293 | | 283 | |
| 294 | fn bitCastResultPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 284 | fn zirBitcastResultPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 295 | const tracy = trace(@src()); | 285 | const tracy = trace(@src()); |
| 296 | defer tracy.end(); | 286 | defer tracy.end(); |
| 297 | return mod.fail(scope, inst.base.src, "TODO implement zir_sema.bitCastResultPtr", .{}); | 287 | return mod.fail(scope, inst.base.src, "TODO implement zir_sema.zirBitcastResultPtr", .{}); |
| 298 | } | 288 | } |
| 299 | | 289 | |
| 300 | fn analyzeInstCoerceResultPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { | 290 | fn zirCoerceResultPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { |
| 301 | const tracy = trace(@src()); | 291 | const tracy = trace(@src()); |
| 302 | defer tracy.end(); | 292 | defer tracy.end(); |
| 303 | return mod.fail(scope, inst.base.src, "TODO implement analyzeInstCoerceResultPtr", .{}); | 293 | return mod.fail(scope, inst.base.src, "TODO implement zirCoerceResultPtr", .{}); |
| 304 | } | 294 | } |
| 305 | | 295 | |
| 306 | /// Equivalent to `as(ptr_child_type(typeof(ptr)), value)`. | 296 | fn zirRetPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerError!*Inst { |
| 307 | fn analyzeInstCoerceToPtrElem(mod: *Module, scope: *Scope, inst: *zir.Inst.CoerceToPtrElem) InnerError!*Inst { | | |
| 308 | const tracy = trace(@src()); | | |
| 309 | defer tracy.end(); | | |
| 310 | const ptr = try resolveInst(mod, scope, inst.positionals.ptr); | | |
| 311 | const operand = try resolveInst(mod, scope, inst.positionals.value); | | |
| 312 | return mod.coerce(scope, ptr.ty.elemType(), operand); | | |
| 313 | } | | |
| 314 | | | |
| 315 | fn analyzeInstRetPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerError!*Inst { | | |
| 316 | const tracy = trace(@src()); | 297 | const tracy = trace(@src()); |
| 317 | defer tracy.end(); | 298 | defer tracy.end(); |
| 318 | const b = try mod.requireFunctionBlock(scope, inst.base.src); | 299 | const b = try mod.requireFunctionBlock(scope, inst.base.src); |
| ... | @@ -322,7 +303,7 @@ fn analyzeInstRetPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerErr | ... | @@ -322,7 +303,7 @@ fn analyzeInstRetPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerErr |
| 322 | return mod.addNoOp(b, inst.base.src, ptr_type, .alloc); | 303 | return mod.addNoOp(b, inst.base.src, ptr_type, .alloc); |
| 323 | } | 304 | } |
| 324 | | 305 | |
| 325 | fn ref(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 306 | fn zirRef(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 326 | const tracy = trace(@src()); | 307 | const tracy = trace(@src()); |
| 327 | defer tracy.end(); | 308 | defer tracy.end(); |
| 328 | | 309 | |
| ... | @@ -330,7 +311,7 @@ fn ref(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | ... | @@ -330,7 +311,7 @@ fn ref(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 330 | return mod.analyzeRef(scope, inst.base.src, operand); | 311 | return mod.analyzeRef(scope, inst.base.src, operand); |
| 331 | } | 312 | } |
| 332 | | 313 | |
| 333 | fn analyzeInstRetType(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerError!*Inst { | 314 | fn zirRetType(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerError!*Inst { |
| 334 | const tracy = trace(@src()); | 315 | const tracy = trace(@src()); |
| 335 | defer tracy.end(); | 316 | defer tracy.end(); |
| 336 | const b = try mod.requireFunctionBlock(scope, inst.base.src); | 317 | const b = try mod.requireFunctionBlock(scope, inst.base.src); |
| ... | @@ -339,7 +320,7 @@ fn analyzeInstRetType(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerEr | ... | @@ -339,7 +320,7 @@ fn analyzeInstRetType(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerEr |
| 339 | return mod.constType(scope, inst.base.src, ret_type); | 320 | return mod.constType(scope, inst.base.src, ret_type); |
| 340 | } | 321 | } |
| 341 | | 322 | |
| 342 | fn analyzeInstEnsureResultUsed(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 323 | fn zirEnsureResultUsed(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 343 | const tracy = trace(@src()); | 324 | const tracy = trace(@src()); |
| 344 | defer tracy.end(); | 325 | defer tracy.end(); |
| 345 | const operand = try resolveInst(mod, scope, inst.positionals.operand); | 326 | const operand = try resolveInst(mod, scope, inst.positionals.operand); |
| ... | @@ -349,7 +330,7 @@ fn analyzeInstEnsureResultUsed(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp | ... | @@ -349,7 +330,7 @@ fn analyzeInstEnsureResultUsed(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp |
| 349 | } | 330 | } |
| 350 | } | 331 | } |
| 351 | | 332 | |
| 352 | fn analyzeInstEnsureResultNonError(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 333 | fn zirEnsureResultNonError(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 353 | const tracy = trace(@src()); | 334 | const tracy = trace(@src()); |
| 354 | defer tracy.end(); | 335 | defer tracy.end(); |
| 355 | const operand = try resolveInst(mod, scope, inst.positionals.operand); | 336 | const operand = try resolveInst(mod, scope, inst.positionals.operand); |
| ... | @@ -359,7 +340,7 @@ fn analyzeInstEnsureResultNonError(mod: *Module, scope: *Scope, inst: *zir.Inst. | ... | @@ -359,7 +340,7 @@ fn analyzeInstEnsureResultNonError(mod: *Module, scope: *Scope, inst: *zir.Inst. |
| 359 | } | 340 | } |
| 360 | } | 341 | } |
| 361 | | 342 | |
| 362 | fn indexablePtrLen(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 343 | fn zirIndexablePtrLen(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 363 | const tracy = trace(@src()); | 344 | const tracy = trace(@src()); |
| 364 | defer tracy.end(); | 345 | defer tracy.end(); |
| 365 | | 346 | |
| ... | @@ -389,7 +370,7 @@ fn indexablePtrLen(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError | ... | @@ -389,7 +370,7 @@ fn indexablePtrLen(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError |
| 389 | return mod.analyzeDeref(scope, inst.base.src, result_ptr, result_ptr.src); | 370 | return mod.analyzeDeref(scope, inst.base.src, result_ptr, result_ptr.src); |
| 390 | } | 371 | } |
| 391 | | 372 | |
| 392 | fn analyzeInstAlloc(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 373 | fn zirAlloc(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 393 | const tracy = trace(@src()); | 374 | const tracy = trace(@src()); |
| 394 | defer tracy.end(); | 375 | defer tracy.end(); |
| 395 | const var_type = try resolveType(mod, scope, inst.positionals.operand); | 376 | const var_type = try resolveType(mod, scope, inst.positionals.operand); |
| ... | @@ -398,7 +379,7 @@ fn analyzeInstAlloc(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerErro | ... | @@ -398,7 +379,7 @@ fn analyzeInstAlloc(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerErro |
| 398 | return mod.addNoOp(b, inst.base.src, ptr_type, .alloc); | 379 | return mod.addNoOp(b, inst.base.src, ptr_type, .alloc); |
| 399 | } | 380 | } |
| 400 | | 381 | |
| 401 | fn analyzeInstAllocMut(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 382 | fn zirAllocMut(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 402 | const tracy = trace(@src()); | 383 | const tracy = trace(@src()); |
| 403 | defer tracy.end(); | 384 | defer tracy.end(); |
| 404 | const var_type = try resolveType(mod, scope, inst.positionals.operand); | 385 | const var_type = try resolveType(mod, scope, inst.positionals.operand); |
| ... | @@ -408,7 +389,7 @@ fn analyzeInstAllocMut(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerE | ... | @@ -408,7 +389,7 @@ fn analyzeInstAllocMut(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerE |
| 408 | return mod.addNoOp(b, inst.base.src, ptr_type, .alloc); | 389 | return mod.addNoOp(b, inst.base.src, ptr_type, .alloc); |
| 409 | } | 390 | } |
| 410 | | 391 | |
| 411 | fn analyzeInstAllocInferred( | 392 | fn zirAllocInferred( |
| 412 | mod: *Module, | 393 | mod: *Module, |
| 413 | scope: *Scope, | 394 | scope: *Scope, |
| 414 | inst: *zir.Inst.NoOp, | 395 | inst: *zir.Inst.NoOp, |
| ... | @@ -437,7 +418,7 @@ fn analyzeInstAllocInferred( | ... | @@ -437,7 +418,7 @@ fn analyzeInstAllocInferred( |
| 437 | return result; | 418 | return result; |
| 438 | } | 419 | } |
| 439 | | 420 | |
| 440 | fn analyzeInstResolveInferredAlloc( | 421 | fn zirResolveInferredAlloc( |
| 441 | mod: *Module, | 422 | mod: *Module, |
| 442 | scope: *Scope, | 423 | scope: *Scope, |
| 443 | inst: *zir.Inst.UnOp, | 424 | inst: *zir.Inst.UnOp, |
| ... | @@ -466,28 +447,44 @@ fn analyzeInstResolveInferredAlloc( | ... | @@ -466,28 +447,44 @@ fn analyzeInstResolveInferredAlloc( |
| 466 | return mod.constVoid(scope, inst.base.src); | 447 | return mod.constVoid(scope, inst.base.src); |
| 467 | } | 448 | } |
| 468 | | 449 | |
| 469 | fn analyzeInstStoreToInferredPtr( | 450 | fn zirStoreToBlockPtr( |
| | 451 | mod: *Module, |
| | 452 | scope: *Scope, |
| | 453 | inst: *zir.Inst.BinOp, |
| | 454 | ) InnerError!*Inst { |
| | 455 | const tracy = trace(@src()); |
| | 456 | defer tracy.end(); |
| | 457 | |
| | 458 | const ptr = try resolveInst(mod, scope, inst.positionals.lhs); |
| | 459 | const value = try resolveInst(mod, scope, inst.positionals.rhs); |
| | 460 | const ptr_ty = try mod.simplePtrType(scope, inst.base.src, value.ty, true, .One); |
| | 461 | const b = try mod.requireRuntimeBlock(scope, inst.base.src); |
| | 462 | const bitcasted_ptr = try mod.addUnOp(b, inst.base.src, ptr_ty, .bitcast, ptr); |
| | 463 | return mod.storePtr(scope, inst.base.src, bitcasted_ptr, value); |
| | 464 | } |
| | 465 | |
| | 466 | fn zirStoreToInferredPtr( |
| 470 | mod: *Module, | 467 | mod: *Module, |
| 471 | scope: *Scope, | 468 | scope: *Scope, |
| 472 | inst: *zir.Inst.BinOp, | 469 | inst: *zir.Inst.BinOp, |
| 473 | ) InnerError!*Inst { | 470 | ) InnerError!*Inst { |
| 474 | const tracy = trace(@src()); | 471 | const tracy = trace(@src()); |
| 475 | defer tracy.end(); | 472 | defer tracy.end(); |
| | 473 | |
| 476 | const ptr = try resolveInst(mod, scope, inst.positionals.lhs); | 474 | const ptr = try resolveInst(mod, scope, inst.positionals.lhs); |
| 477 | const value = try resolveInst(mod, scope, inst.positionals.rhs); | 475 | const value = try resolveInst(mod, scope, inst.positionals.rhs); |
| 478 | const inferred_alloc = ptr.castTag(.constant).?.val.castTag(.inferred_alloc).?; | 476 | const inferred_alloc = ptr.castTag(.constant).?.val.castTag(.inferred_alloc).?; |
| 479 | // Add the stored instruction to the set we will use to resolve peer types | 477 | // Add the stored instruction to the set we will use to resolve peer types |
| 480 | // for the inferred allocation. | 478 | // for the inferred allocation. |
| 481 | try inferred_alloc.data.stored_inst_list.append(scope.arena(), value); | 479 | try inferred_alloc.data.stored_inst_list.append(scope.arena(), value); |
| 482 | // Create a new alloc with exactly the type the pointer wants. | 480 | // Create a runtime bitcast instruction with exactly the type the pointer wants. |
| 483 | // Later it gets cleaned up by aliasing the alloc we are supposed to be storing to. | | |
| 484 | const ptr_ty = try mod.simplePtrType(scope, inst.base.src, value.ty, true, .One); | 481 | const ptr_ty = try mod.simplePtrType(scope, inst.base.src, value.ty, true, .One); |
| 485 | const b = try mod.requireRuntimeBlock(scope, inst.base.src); | 482 | const b = try mod.requireRuntimeBlock(scope, inst.base.src); |
| 486 | const bitcasted_ptr = try mod.addUnOp(b, inst.base.src, ptr_ty, .bitcast, ptr); | 483 | const bitcasted_ptr = try mod.addUnOp(b, inst.base.src, ptr_ty, .bitcast, ptr); |
| 487 | return mod.storePtr(scope, inst.base.src, bitcasted_ptr, value); | 484 | return mod.storePtr(scope, inst.base.src, bitcasted_ptr, value); |
| 488 | } | 485 | } |
| 489 | | 486 | |
| 490 | fn analyzeInstSetEvalBranchQuota( | 487 | fn zirSetEvalBranchQuota( |
| 491 | mod: *Module, | 488 | mod: *Module, |
| 492 | scope: *Scope, | 489 | scope: *Scope, |
| 493 | inst: *zir.Inst.UnOp, | 490 | inst: *zir.Inst.UnOp, |
| ... | @@ -499,15 +496,16 @@ fn analyzeInstSetEvalBranchQuota( | ... | @@ -499,15 +496,16 @@ fn analyzeInstSetEvalBranchQuota( |
| 499 | return mod.constVoid(scope, inst.base.src); | 496 | return mod.constVoid(scope, inst.base.src); |
| 500 | } | 497 | } |
| 501 | | 498 | |
| 502 | fn analyzeInstStore(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { | 499 | fn zirStore(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { |
| 503 | const tracy = trace(@src()); | 500 | const tracy = trace(@src()); |
| 504 | defer tracy.end(); | 501 | defer tracy.end(); |
| | 502 | |
| 505 | const ptr = try resolveInst(mod, scope, inst.positionals.lhs); | 503 | const ptr = try resolveInst(mod, scope, inst.positionals.lhs); |
| 506 | const value = try resolveInst(mod, scope, inst.positionals.rhs); | 504 | const value = try resolveInst(mod, scope, inst.positionals.rhs); |
| 507 | return mod.storePtr(scope, inst.base.src, ptr, value); | 505 | return mod.storePtr(scope, inst.base.src, ptr, value); |
| 508 | } | 506 | } |
| 509 | | 507 | |
| 510 | fn analyzeInstParamType(mod: *Module, scope: *Scope, inst: *zir.Inst.ParamType) InnerError!*Inst { | 508 | fn zirParamType(mod: *Module, scope: *Scope, inst: *zir.Inst.ParamType) InnerError!*Inst { |
| 511 | const tracy = trace(@src()); | 509 | const tracy = trace(@src()); |
| 512 | defer tracy.end(); | 510 | defer tracy.end(); |
| 513 | const fn_inst = try resolveInst(mod, scope, inst.positionals.func); | 511 | const fn_inst = try resolveInst(mod, scope, inst.positionals.func); |
| ... | @@ -516,7 +514,7 @@ fn analyzeInstParamType(mod: *Module, scope: *Scope, inst: *zir.Inst.ParamType) | ... | @@ -516,7 +514,7 @@ fn analyzeInstParamType(mod: *Module, scope: *Scope, inst: *zir.Inst.ParamType) |
| 516 | const fn_ty: Type = switch (fn_inst.ty.zigTypeTag()) { | 514 | const fn_ty: Type = switch (fn_inst.ty.zigTypeTag()) { |
| 517 | .Fn => fn_inst.ty, | 515 | .Fn => fn_inst.ty, |
| 518 | .BoundFn => { | 516 | .BoundFn => { |
| 519 | return mod.fail(scope, fn_inst.src, "TODO implement analyzeInstParamType for method call syntax", .{}); | 517 | return mod.fail(scope, fn_inst.src, "TODO implement zirParamType for method call syntax", .{}); |
| 520 | }, | 518 | }, |
| 521 | else => { | 519 | else => { |
| 522 | return mod.fail(scope, fn_inst.src, "expected function, found '{}'", .{fn_inst.ty}); | 520 | return mod.fail(scope, fn_inst.src, "expected function, found '{}'", .{fn_inst.ty}); |
| ... | @@ -538,7 +536,7 @@ fn analyzeInstParamType(mod: *Module, scope: *Scope, inst: *zir.Inst.ParamType) | ... | @@ -538,7 +536,7 @@ fn analyzeInstParamType(mod: *Module, scope: *Scope, inst: *zir.Inst.ParamType) |
| 538 | return mod.constType(scope, inst.base.src, param_type); | 536 | return mod.constType(scope, inst.base.src, param_type); |
| 539 | } | 537 | } |
| 540 | | 538 | |
| 541 | fn analyzeInstStr(mod: *Module, scope: *Scope, str_inst: *zir.Inst.Str) InnerError!*Inst { | 539 | fn zirStr(mod: *Module, scope: *Scope, str_inst: *zir.Inst.Str) InnerError!*Inst { |
| 542 | const tracy = trace(@src()); | 540 | const tracy = trace(@src()); |
| 543 | defer tracy.end(); | 541 | defer tracy.end(); |
| 544 | // The bytes references memory inside the ZIR module, which can get deallocated | 542 | // The bytes references memory inside the ZIR module, which can get deallocated |
| ... | @@ -557,14 +555,14 @@ fn analyzeInstStr(mod: *Module, scope: *Scope, str_inst: *zir.Inst.Str) InnerErr | ... | @@ -557,14 +555,14 @@ fn analyzeInstStr(mod: *Module, scope: *Scope, str_inst: *zir.Inst.Str) InnerErr |
| 557 | return mod.analyzeDeclRef(scope, str_inst.base.src, new_decl); | 555 | return mod.analyzeDeclRef(scope, str_inst.base.src, new_decl); |
| 558 | } | 556 | } |
| 559 | | 557 | |
| 560 | fn analyzeInstInt(mod: *Module, scope: *Scope, inst: *zir.Inst.Int) InnerError!*Inst { | 558 | fn zirInt(mod: *Module, scope: *Scope, inst: *zir.Inst.Int) InnerError!*Inst { |
| 561 | const tracy = trace(@src()); | 559 | const tracy = trace(@src()); |
| 562 | defer tracy.end(); | 560 | defer tracy.end(); |
| 563 | | 561 | |
| 564 | return mod.constIntBig(scope, inst.base.src, Type.initTag(.comptime_int), inst.positionals.int); | 562 | return mod.constIntBig(scope, inst.base.src, Type.initTag(.comptime_int), inst.positionals.int); |
| 565 | } | 563 | } |
| 566 | | 564 | |
| 567 | fn analyzeInstExport(mod: *Module, scope: *Scope, export_inst: *zir.Inst.Export) InnerError!*Inst { | 565 | fn zirExport(mod: *Module, scope: *Scope, export_inst: *zir.Inst.Export) InnerError!*Inst { |
| 568 | const tracy = trace(@src()); | 566 | const tracy = trace(@src()); |
| 569 | defer tracy.end(); | 567 | defer tracy.end(); |
| 570 | const symbol_name = try resolveConstString(mod, scope, export_inst.positionals.symbol_name); | 568 | const symbol_name = try resolveConstString(mod, scope, export_inst.positionals.symbol_name); |
| ... | @@ -574,14 +572,14 @@ fn analyzeInstExport(mod: *Module, scope: *Scope, export_inst: *zir.Inst.Export) | ... | @@ -574,14 +572,14 @@ fn analyzeInstExport(mod: *Module, scope: *Scope, export_inst: *zir.Inst.Export) |
| 574 | return mod.constVoid(scope, export_inst.base.src); | 572 | return mod.constVoid(scope, export_inst.base.src); |
| 575 | } | 573 | } |
| 576 | | 574 | |
| 577 | fn analyzeInstCompileError(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 575 | fn zirCompileError(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 578 | const tracy = trace(@src()); | 576 | const tracy = trace(@src()); |
| 579 | defer tracy.end(); | 577 | defer tracy.end(); |
| 580 | const msg = try resolveConstString(mod, scope, inst.positionals.operand); | 578 | const msg = try resolveConstString(mod, scope, inst.positionals.operand); |
| 581 | return mod.fail(scope, inst.base.src, "{s}", .{msg}); | 579 | return mod.fail(scope, inst.base.src, "{s}", .{msg}); |
| 582 | } | 580 | } |
| 583 | | 581 | |
| 584 | fn analyzeInstCompileLog(mod: *Module, scope: *Scope, inst: *zir.Inst.CompileLog) InnerError!*Inst { | 582 | fn zirCompileLog(mod: *Module, scope: *Scope, inst: *zir.Inst.CompileLog) InnerError!*Inst { |
| 585 | var managed = mod.compile_log_text.toManaged(mod.gpa); | 583 | var managed = mod.compile_log_text.toManaged(mod.gpa); |
| 586 | defer mod.compile_log_text = managed.moveToUnmanaged(); | 584 | defer mod.compile_log_text = managed.moveToUnmanaged(); |
| 587 | const writer = managed.writer(); | 585 | const writer = managed.writer(); |
| ... | @@ -608,7 +606,7 @@ fn analyzeInstCompileLog(mod: *Module, scope: *Scope, inst: *zir.Inst.CompileLog | ... | @@ -608,7 +606,7 @@ fn analyzeInstCompileLog(mod: *Module, scope: *Scope, inst: *zir.Inst.CompileLog |
| 608 | return mod.constVoid(scope, inst.base.src); | 606 | return mod.constVoid(scope, inst.base.src); |
| 609 | } | 607 | } |
| 610 | | 608 | |
| 611 | fn analyzeInstArg(mod: *Module, scope: *Scope, inst: *zir.Inst.Arg) InnerError!*Inst { | 609 | fn zirArg(mod: *Module, scope: *Scope, inst: *zir.Inst.Arg) InnerError!*Inst { |
| 612 | const tracy = trace(@src()); | 610 | const tracy = trace(@src()); |
| 613 | defer tracy.end(); | 611 | defer tracy.end(); |
| 614 | const b = try mod.requireFunctionBlock(scope, inst.base.src); | 612 | const b = try mod.requireFunctionBlock(scope, inst.base.src); |
| ... | @@ -631,7 +629,7 @@ fn analyzeInstArg(mod: *Module, scope: *Scope, inst: *zir.Inst.Arg) InnerError!* | ... | @@ -631,7 +629,7 @@ fn analyzeInstArg(mod: *Module, scope: *Scope, inst: *zir.Inst.Arg) InnerError!* |
| 631 | return mod.addArg(b, inst.base.src, param_type, name); | 629 | return mod.addArg(b, inst.base.src, param_type, name); |
| 632 | } | 630 | } |
| 633 | | 631 | |
| 634 | fn analyzeInstLoop(mod: *Module, scope: *Scope, inst: *zir.Inst.Loop) InnerError!*Inst { | 632 | fn zirLoop(mod: *Module, scope: *Scope, inst: *zir.Inst.Loop) InnerError!*Inst { |
| 635 | const tracy = trace(@src()); | 633 | const tracy = trace(@src()); |
| 636 | defer tracy.end(); | 634 | defer tracy.end(); |
| 637 | const parent_block = scope.cast(Scope.Block).?; | 635 | const parent_block = scope.cast(Scope.Block).?; |
| ... | @@ -672,7 +670,7 @@ fn analyzeInstLoop(mod: *Module, scope: *Scope, inst: *zir.Inst.Loop) InnerError | ... | @@ -672,7 +670,7 @@ fn analyzeInstLoop(mod: *Module, scope: *Scope, inst: *zir.Inst.Loop) InnerError |
| 672 | return &loop_inst.base; | 670 | return &loop_inst.base; |
| 673 | } | 671 | } |
| 674 | | 672 | |
| 675 | fn analyzeInstBlockFlat(mod: *Module, scope: *Scope, inst: *zir.Inst.Block, is_comptime: bool) InnerError!*Inst { | 673 | fn zirBlockFlat(mod: *Module, scope: *Scope, inst: *zir.Inst.Block, is_comptime: bool) InnerError!*Inst { |
| 676 | const tracy = trace(@src()); | 674 | const tracy = trace(@src()); |
| 677 | defer tracy.end(); | 675 | defer tracy.end(); |
| 678 | const parent_block = scope.cast(Scope.Block).?; | 676 | const parent_block = scope.cast(Scope.Block).?; |
| ... | @@ -704,9 +702,15 @@ fn analyzeInstBlockFlat(mod: *Module, scope: *Scope, inst: *zir.Inst.Block, is_c | ... | @@ -704,9 +702,15 @@ fn analyzeInstBlockFlat(mod: *Module, scope: *Scope, inst: *zir.Inst.Block, is_c |
| 704 | return resolveInst(mod, scope, last_zir_inst); | 702 | return resolveInst(mod, scope, last_zir_inst); |
| 705 | } | 703 | } |
| 706 | | 704 | |
| 707 | fn analyzeInstBlock(mod: *Module, scope: *Scope, inst: *zir.Inst.Block, is_comptime: bool) InnerError!*Inst { | 705 | fn zirBlock( |
| | 706 | mod: *Module, |
| | 707 | scope: *Scope, |
| | 708 | inst: *zir.Inst.Block, |
| | 709 | is_comptime: bool, |
| | 710 | ) InnerError!*Inst { |
| 708 | const tracy = trace(@src()); | 711 | const tracy = trace(@src()); |
| 709 | defer tracy.end(); | 712 | defer tracy.end(); |
| | 713 | |
| 710 | const parent_block = scope.cast(Scope.Block).?; | 714 | const parent_block = scope.cast(Scope.Block).?; |
| 711 | | 715 | |
| 712 | // Reserve space for a Block instruction so that generated Break instructions can | 716 | // Reserve space for a Block instruction so that generated Break instructions can |
| ... | @@ -798,30 +802,52 @@ fn analyzeBlockBody( | ... | @@ -798,30 +802,52 @@ fn analyzeBlockBody( |
| 798 | return &merges.block_inst.base; | 802 | return &merges.block_inst.base; |
| 799 | } | 803 | } |
| 800 | | 804 | |
| 801 | fn analyzeInstBreakpoint(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerError!*Inst { | 805 | fn zirBreakpoint(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerError!*Inst { |
| 802 | const tracy = trace(@src()); | 806 | const tracy = trace(@src()); |
| 803 | defer tracy.end(); | 807 | defer tracy.end(); |
| 804 | const b = try mod.requireRuntimeBlock(scope, inst.base.src); | 808 | const b = try mod.requireRuntimeBlock(scope, inst.base.src); |
| 805 | return mod.addNoOp(b, inst.base.src, Type.initTag(.void), .breakpoint); | 809 | return mod.addNoOp(b, inst.base.src, Type.initTag(.void), .breakpoint); |
| 806 | } | 810 | } |
| 807 | | 811 | |
| 808 | fn analyzeInstBreak(mod: *Module, scope: *Scope, inst: *zir.Inst.Break) InnerError!*Inst { | 812 | fn zirBreak(mod: *Module, scope: *Scope, inst: *zir.Inst.Break) InnerError!*Inst { |
| 809 | const tracy = trace(@src()); | 813 | const tracy = trace(@src()); |
| 810 | defer tracy.end(); | 814 | defer tracy.end(); |
| | 815 | |
| 811 | const operand = try resolveInst(mod, scope, inst.positionals.operand); | 816 | const operand = try resolveInst(mod, scope, inst.positionals.operand); |
| 812 | const block = inst.positionals.block; | 817 | const block = inst.positionals.block; |
| 813 | return analyzeBreak(mod, scope, inst.base.src, block, operand); | 818 | return analyzeBreak(mod, scope, inst.base.src, block, operand); |
| 814 | } | 819 | } |
| 815 | | 820 | |
| 816 | fn analyzeInstBreakVoid(mod: *Module, scope: *Scope, inst: *zir.Inst.BreakVoid) InnerError!*Inst { | 821 | fn zirBreakVoid(mod: *Module, scope: *Scope, inst: *zir.Inst.BreakVoid) InnerError!*Inst { |
| 817 | const tracy = trace(@src()); | 822 | const tracy = trace(@src()); |
| 818 | defer tracy.end(); | 823 | defer tracy.end(); |
| | 824 | |
| 819 | const block = inst.positionals.block; | 825 | const block = inst.positionals.block; |
| 820 | const void_inst = try mod.constVoid(scope, inst.base.src); | 826 | const void_inst = try mod.constVoid(scope, inst.base.src); |
| 821 | return analyzeBreak(mod, scope, inst.base.src, block, void_inst); | 827 | return analyzeBreak(mod, scope, inst.base.src, block, void_inst); |
| 822 | } | 828 | } |
| 823 | | 829 | |
| 824 | fn analyzeInstDbgStmt(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerError!*Inst { | 830 | fn analyzeBreak( |
| | 831 | mod: *Module, |
| | 832 | scope: *Scope, |
| | 833 | src: usize, |
| | 834 | zir_block: *zir.Inst.Block, |
| | 835 | operand: *Inst, |
| | 836 | ) InnerError!*Inst { |
| | 837 | var opt_block = scope.cast(Scope.Block); |
| | 838 | while (opt_block) |block| { |
| | 839 | if (block.label) |*label| { |
| | 840 | if (label.zir_block == zir_block) { |
| | 841 | try label.merges.results.append(mod.gpa, operand); |
| | 842 | const b = try mod.requireFunctionBlock(scope, src); |
| | 843 | return mod.addBr(b, src, label.merges.block_inst, operand); |
| | 844 | } |
| | 845 | } |
| | 846 | opt_block = block.parent; |
| | 847 | } else unreachable; |
| | 848 | } |
| | 849 | |
| | 850 | fn zirDbgStmt(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerError!*Inst { |
| 825 | const tracy = trace(@src()); | 851 | const tracy = trace(@src()); |
| 826 | defer tracy.end(); | 852 | defer tracy.end(); |
| 827 | if (scope.cast(Scope.Block)) |b| { | 853 | if (scope.cast(Scope.Block)) |b| { |
| ... | @@ -832,26 +858,26 @@ fn analyzeInstDbgStmt(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerEr | ... | @@ -832,26 +858,26 @@ fn analyzeInstDbgStmt(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerEr |
| 832 | return mod.constVoid(scope, inst.base.src); | 858 | return mod.constVoid(scope, inst.base.src); |
| 833 | } | 859 | } |
| 834 | | 860 | |
| 835 | fn analyzeInstDeclRefStr(mod: *Module, scope: *Scope, inst: *zir.Inst.DeclRefStr) InnerError!*Inst { | 861 | fn zirDeclRefStr(mod: *Module, scope: *Scope, inst: *zir.Inst.DeclRefStr) InnerError!*Inst { |
| 836 | const tracy = trace(@src()); | 862 | const tracy = trace(@src()); |
| 837 | defer tracy.end(); | 863 | defer tracy.end(); |
| 838 | const decl_name = try resolveConstString(mod, scope, inst.positionals.name); | 864 | const decl_name = try resolveConstString(mod, scope, inst.positionals.name); |
| 839 | return mod.analyzeDeclRefByName(scope, inst.base.src, decl_name); | 865 | return mod.analyzeDeclRefByName(scope, inst.base.src, decl_name); |
| 840 | } | 866 | } |
| 841 | | 867 | |
| 842 | fn declRef(mod: *Module, scope: *Scope, inst: *zir.Inst.DeclRef) InnerError!*Inst { | 868 | fn zirDeclRef(mod: *Module, scope: *Scope, inst: *zir.Inst.DeclRef) InnerError!*Inst { |
| 843 | const tracy = trace(@src()); | 869 | const tracy = trace(@src()); |
| 844 | defer tracy.end(); | 870 | defer tracy.end(); |
| 845 | return mod.analyzeDeclRef(scope, inst.base.src, inst.positionals.decl); | 871 | return mod.analyzeDeclRef(scope, inst.base.src, inst.positionals.decl); |
| 846 | } | 872 | } |
| 847 | | 873 | |
| 848 | fn declVal(mod: *Module, scope: *Scope, inst: *zir.Inst.DeclVal) InnerError!*Inst { | 874 | fn zirDeclVal(mod: *Module, scope: *Scope, inst: *zir.Inst.DeclVal) InnerError!*Inst { |
| 849 | const tracy = trace(@src()); | 875 | const tracy = trace(@src()); |
| 850 | defer tracy.end(); | 876 | defer tracy.end(); |
| 851 | return mod.analyzeDeclVal(scope, inst.base.src, inst.positionals.decl); | 877 | return mod.analyzeDeclVal(scope, inst.base.src, inst.positionals.decl); |
| 852 | } | 878 | } |
| 853 | | 879 | |
| 854 | fn call(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError!*Inst { | 880 | fn zirCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError!*Inst { |
| 855 | const tracy = trace(@src()); | 881 | const tracy = trace(@src()); |
| 856 | defer tracy.end(); | 882 | defer tracy.end(); |
| 857 | | 883 | |
| ... | @@ -1002,7 +1028,7 @@ fn call(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError!*Inst { | ... | @@ -1002,7 +1028,7 @@ fn call(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError!*Inst { |
| 1002 | return mod.addCall(b, inst.base.src, ret_type, func, casted_args); | 1028 | return mod.addCall(b, inst.base.src, ret_type, func, casted_args); |
| 1003 | } | 1029 | } |
| 1004 | | 1030 | |
| 1005 | fn analyzeInstFn(mod: *Module, scope: *Scope, fn_inst: *zir.Inst.Fn) InnerError!*Inst { | 1031 | fn zirFn(mod: *Module, scope: *Scope, fn_inst: *zir.Inst.Fn) InnerError!*Inst { |
| 1006 | const tracy = trace(@src()); | 1032 | const tracy = trace(@src()); |
| 1007 | defer tracy.end(); | 1033 | defer tracy.end(); |
| 1008 | const fn_type = try resolveType(mod, scope, fn_inst.positionals.fn_type); | 1034 | const fn_type = try resolveType(mod, scope, fn_inst.positionals.fn_type); |
| ... | @@ -1019,13 +1045,13 @@ fn analyzeInstFn(mod: *Module, scope: *Scope, fn_inst: *zir.Inst.Fn) InnerError! | ... | @@ -1019,13 +1045,13 @@ fn analyzeInstFn(mod: *Module, scope: *Scope, fn_inst: *zir.Inst.Fn) InnerError! |
| 1019 | }); | 1045 | }); |
| 1020 | } | 1046 | } |
| 1021 | | 1047 | |
| 1022 | fn analyzeInstIntType(mod: *Module, scope: *Scope, inttype: *zir.Inst.IntType) InnerError!*Inst { | 1048 | fn zirIntType(mod: *Module, scope: *Scope, inttype: *zir.Inst.IntType) InnerError!*Inst { |
| 1023 | const tracy = trace(@src()); | 1049 | const tracy = trace(@src()); |
| 1024 | defer tracy.end(); | 1050 | defer tracy.end(); |
| 1025 | return mod.fail(scope, inttype.base.src, "TODO implement inttype", .{}); | 1051 | return mod.fail(scope, inttype.base.src, "TODO implement inttype", .{}); |
| 1026 | } | 1052 | } |
| 1027 | | 1053 | |
| 1028 | fn analyzeInstOptionalType(mod: *Module, scope: *Scope, optional: *zir.Inst.UnOp) InnerError!*Inst { | 1054 | fn zirOptionalType(mod: *Module, scope: *Scope, optional: *zir.Inst.UnOp) InnerError!*Inst { |
| 1029 | const tracy = trace(@src()); | 1055 | const tracy = trace(@src()); |
| 1030 | defer tracy.end(); | 1056 | defer tracy.end(); |
| 1031 | const child_type = try resolveType(mod, scope, optional.positionals.operand); | 1057 | const child_type = try resolveType(mod, scope, optional.positionals.operand); |
| ... | @@ -1033,7 +1059,7 @@ fn analyzeInstOptionalType(mod: *Module, scope: *Scope, optional: *zir.Inst.UnOp | ... | @@ -1033,7 +1059,7 @@ fn analyzeInstOptionalType(mod: *Module, scope: *Scope, optional: *zir.Inst.UnOp |
| 1033 | return mod.constType(scope, optional.base.src, try mod.optionalType(scope, child_type)); | 1059 | return mod.constType(scope, optional.base.src, try mod.optionalType(scope, child_type)); |
| 1034 | } | 1060 | } |
| 1035 | | 1061 | |
| 1036 | fn analyzeInstArrayType(mod: *Module, scope: *Scope, array: *zir.Inst.BinOp) InnerError!*Inst { | 1062 | fn zirArrayType(mod: *Module, scope: *Scope, array: *zir.Inst.BinOp) InnerError!*Inst { |
| 1037 | const tracy = trace(@src()); | 1063 | const tracy = trace(@src()); |
| 1038 | defer tracy.end(); | 1064 | defer tracy.end(); |
| 1039 | // TODO these should be lazily evaluated | 1065 | // TODO these should be lazily evaluated |
| ... | @@ -1043,7 +1069,7 @@ fn analyzeInstArrayType(mod: *Module, scope: *Scope, array: *zir.Inst.BinOp) Inn | ... | @@ -1043,7 +1069,7 @@ fn analyzeInstArrayType(mod: *Module, scope: *Scope, array: *zir.Inst.BinOp) Inn |
| 1043 | return mod.constType(scope, array.base.src, try mod.arrayType(scope, len.val.toUnsignedInt(), null, elem_type)); | 1069 | return mod.constType(scope, array.base.src, try mod.arrayType(scope, len.val.toUnsignedInt(), null, elem_type)); |
| 1044 | } | 1070 | } |
| 1045 | | 1071 | |
| 1046 | fn analyzeInstArrayTypeSentinel(mod: *Module, scope: *Scope, array: *zir.Inst.ArrayTypeSentinel) InnerError!*Inst { | 1072 | fn zirArrayTypeSentinel(mod: *Module, scope: *Scope, array: *zir.Inst.ArrayTypeSentinel) InnerError!*Inst { |
| 1047 | const tracy = trace(@src()); | 1073 | const tracy = trace(@src()); |
| 1048 | defer tracy.end(); | 1074 | defer tracy.end(); |
| 1049 | // TODO these should be lazily evaluated | 1075 | // TODO these should be lazily evaluated |
| ... | @@ -1054,7 +1080,7 @@ fn analyzeInstArrayTypeSentinel(mod: *Module, scope: *Scope, array: *zir.Inst.Ar | ... | @@ -1054,7 +1080,7 @@ fn analyzeInstArrayTypeSentinel(mod: *Module, scope: *Scope, array: *zir.Inst.Ar |
| 1054 | return mod.constType(scope, array.base.src, try mod.arrayType(scope, len.val.toUnsignedInt(), sentinel.val, elem_type)); | 1080 | return mod.constType(scope, array.base.src, try mod.arrayType(scope, len.val.toUnsignedInt(), sentinel.val, elem_type)); |
| 1055 | } | 1081 | } |
| 1056 | | 1082 | |
| 1057 | fn analyzeInstErrorUnionType(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { | 1083 | fn zirErrorUnionType(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { |
| 1058 | const tracy = trace(@src()); | 1084 | const tracy = trace(@src()); |
| 1059 | defer tracy.end(); | 1085 | defer tracy.end(); |
| 1060 | const error_union = try resolveType(mod, scope, inst.positionals.lhs); | 1086 | const error_union = try resolveType(mod, scope, inst.positionals.lhs); |
| ... | @@ -1067,7 +1093,7 @@ fn analyzeInstErrorUnionType(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) | ... | @@ -1067,7 +1093,7 @@ fn analyzeInstErrorUnionType(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) |
| 1067 | return mod.constType(scope, inst.base.src, try mod.errorUnionType(scope, error_union, payload)); | 1093 | return mod.constType(scope, inst.base.src, try mod.errorUnionType(scope, error_union, payload)); |
| 1068 | } | 1094 | } |
| 1069 | | 1095 | |
| 1070 | fn analyzeInstAnyframeType(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 1096 | fn zirAnyframeType(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 1071 | const tracy = trace(@src()); | 1097 | const tracy = trace(@src()); |
| 1072 | defer tracy.end(); | 1098 | defer tracy.end(); |
| 1073 | const return_type = try resolveType(mod, scope, inst.positionals.operand); | 1099 | const return_type = try resolveType(mod, scope, inst.positionals.operand); |
| ... | @@ -1075,7 +1101,7 @@ fn analyzeInstAnyframeType(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) In | ... | @@ -1075,7 +1101,7 @@ fn analyzeInstAnyframeType(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) In |
| 1075 | return mod.constType(scope, inst.base.src, try mod.anyframeType(scope, return_type)); | 1101 | return mod.constType(scope, inst.base.src, try mod.anyframeType(scope, return_type)); |
| 1076 | } | 1102 | } |
| 1077 | | 1103 | |
| 1078 | fn analyzeInstErrorSet(mod: *Module, scope: *Scope, inst: *zir.Inst.ErrorSet) InnerError!*Inst { | 1104 | fn zirErrorSet(mod: *Module, scope: *Scope, inst: *zir.Inst.ErrorSet) InnerError!*Inst { |
| 1079 | const tracy = trace(@src()); | 1105 | const tracy = trace(@src()); |
| 1080 | defer tracy.end(); | 1106 | defer tracy.end(); |
| 1081 | // The declarations arena will store the hashmap. | 1107 | // The declarations arena will store the hashmap. |
| ... | @@ -1107,13 +1133,13 @@ fn analyzeInstErrorSet(mod: *Module, scope: *Scope, inst: *zir.Inst.ErrorSet) In | ... | @@ -1107,13 +1133,13 @@ fn analyzeInstErrorSet(mod: *Module, scope: *Scope, inst: *zir.Inst.ErrorSet) In |
| 1107 | return mod.analyzeDeclVal(scope, inst.base.src, new_decl); | 1133 | return mod.analyzeDeclVal(scope, inst.base.src, new_decl); |
| 1108 | } | 1134 | } |
| 1109 | | 1135 | |
| 1110 | fn analyzeInstMergeErrorSets(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { | 1136 | fn zirMergeErrorSets(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { |
| 1111 | const tracy = trace(@src()); | 1137 | const tracy = trace(@src()); |
| 1112 | defer tracy.end(); | 1138 | defer tracy.end(); |
| 1113 | return mod.fail(scope, inst.base.src, "TODO implement merge_error_sets", .{}); | 1139 | return mod.fail(scope, inst.base.src, "TODO implement merge_error_sets", .{}); |
| 1114 | } | 1140 | } |
| 1115 | | 1141 | |
| 1116 | fn analyzeInstEnumLiteral(mod: *Module, scope: *Scope, inst: *zir.Inst.EnumLiteral) InnerError!*Inst { | 1142 | fn zirEnumLiteral(mod: *Module, scope: *Scope, inst: *zir.Inst.EnumLiteral) InnerError!*Inst { |
| 1117 | const tracy = trace(@src()); | 1143 | const tracy = trace(@src()); |
| 1118 | defer tracy.end(); | 1144 | defer tracy.end(); |
| 1119 | const duped_name = try scope.arena().dupe(u8, inst.positionals.name); | 1145 | const duped_name = try scope.arena().dupe(u8, inst.positionals.name); |
| ... | @@ -1124,7 +1150,7 @@ fn analyzeInstEnumLiteral(mod: *Module, scope: *Scope, inst: *zir.Inst.EnumLiter | ... | @@ -1124,7 +1150,7 @@ fn analyzeInstEnumLiteral(mod: *Module, scope: *Scope, inst: *zir.Inst.EnumLiter |
| 1124 | } | 1150 | } |
| 1125 | | 1151 | |
| 1126 | /// Pointer in, pointer out. | 1152 | /// Pointer in, pointer out. |
| 1127 | fn optionalPayloadPtr( | 1153 | fn zirOptionalPayloadPtr( |
| 1128 | mod: *Module, | 1154 | mod: *Module, |
| 1129 | scope: *Scope, | 1155 | scope: *Scope, |
| 1130 | unwrap: *zir.Inst.UnOp, | 1156 | unwrap: *zir.Inst.UnOp, |
| ... | @@ -1165,7 +1191,7 @@ fn optionalPayloadPtr( | ... | @@ -1165,7 +1191,7 @@ fn optionalPayloadPtr( |
| 1165 | } | 1191 | } |
| 1166 | | 1192 | |
| 1167 | /// Value in, value out. | 1193 | /// Value in, value out. |
| 1168 | fn optionalPayload( | 1194 | fn zirOptionalPayload( |
| 1169 | mod: *Module, | 1195 | mod: *Module, |
| 1170 | scope: *Scope, | 1196 | scope: *Scope, |
| 1171 | unwrap: *zir.Inst.UnOp, | 1197 | unwrap: *zir.Inst.UnOp, |
| ... | @@ -1201,40 +1227,40 @@ fn optionalPayload( | ... | @@ -1201,40 +1227,40 @@ fn optionalPayload( |
| 1201 | } | 1227 | } |
| 1202 | | 1228 | |
| 1203 | /// Value in, value out | 1229 | /// Value in, value out |
| 1204 | fn errorUnionPayload(mod: *Module, scope: *Scope, unwrap: *zir.Inst.UnOp, safety_check: bool) InnerError!*Inst { | 1230 | fn zirErrUnionPayload(mod: *Module, scope: *Scope, unwrap: *zir.Inst.UnOp, safety_check: bool) InnerError!*Inst { |
| 1205 | const tracy = trace(@src()); | 1231 | const tracy = trace(@src()); |
| 1206 | defer tracy.end(); | 1232 | defer tracy.end(); |
| 1207 | return mod.fail(scope, unwrap.base.src, "TODO implement zir_sema.errorUnionPayload", .{}); | 1233 | return mod.fail(scope, unwrap.base.src, "TODO implement zir_sema.zirErrUnionPayload", .{}); |
| 1208 | } | 1234 | } |
| 1209 | | 1235 | |
| 1210 | /// Pointer in, pointer out | 1236 | /// Pointer in, pointer out |
| 1211 | fn errorUnionPayloadPtr(mod: *Module, scope: *Scope, unwrap: *zir.Inst.UnOp, safety_check: bool) InnerError!*Inst { | 1237 | fn zirErrUnionPayloadPtr(mod: *Module, scope: *Scope, unwrap: *zir.Inst.UnOp, safety_check: bool) InnerError!*Inst { |
| 1212 | const tracy = trace(@src()); | 1238 | const tracy = trace(@src()); |
| 1213 | defer tracy.end(); | 1239 | defer tracy.end(); |
| 1214 | return mod.fail(scope, unwrap.base.src, "TODO implement zir_sema.errorUnionPayloadPtr", .{}); | 1240 | return mod.fail(scope, unwrap.base.src, "TODO implement zir_sema.zirErrUnionPayloadPtr", .{}); |
| 1215 | } | 1241 | } |
| 1216 | | 1242 | |
| 1217 | /// Value in, value out | 1243 | /// Value in, value out |
| 1218 | fn errorUnionCode(mod: *Module, scope: *Scope, unwrap: *zir.Inst.UnOp) InnerError!*Inst { | 1244 | fn zirErrUnionCode(mod: *Module, scope: *Scope, unwrap: *zir.Inst.UnOp) InnerError!*Inst { |
| 1219 | const tracy = trace(@src()); | 1245 | const tracy = trace(@src()); |
| 1220 | defer tracy.end(); | 1246 | defer tracy.end(); |
| 1221 | return mod.fail(scope, unwrap.base.src, "TODO implement zir_sema.errorUnionCode", .{}); | 1247 | return mod.fail(scope, unwrap.base.src, "TODO implement zir_sema.zirErrUnionCode", .{}); |
| 1222 | } | 1248 | } |
| 1223 | | 1249 | |
| 1224 | /// Pointer in, value out | 1250 | /// Pointer in, value out |
| 1225 | fn errorUnionCodePtr(mod: *Module, scope: *Scope, unwrap: *zir.Inst.UnOp) InnerError!*Inst { | 1251 | fn zirErrUnionCodePtr(mod: *Module, scope: *Scope, unwrap: *zir.Inst.UnOp) InnerError!*Inst { |
| 1226 | const tracy = trace(@src()); | 1252 | const tracy = trace(@src()); |
| 1227 | defer tracy.end(); | 1253 | defer tracy.end(); |
| 1228 | return mod.fail(scope, unwrap.base.src, "TODO implement zir_sema.errorUnionCodePtr", .{}); | 1254 | return mod.fail(scope, unwrap.base.src, "TODO implement zir_sema.zirErrUnionCodePtr", .{}); |
| 1229 | } | 1255 | } |
| 1230 | | 1256 | |
| 1231 | fn analyzeInstEnsureErrPayloadVoid(mod: *Module, scope: *Scope, unwrap: *zir.Inst.UnOp) InnerError!*Inst { | 1257 | fn zirEnsureErrPayloadVoid(mod: *Module, scope: *Scope, unwrap: *zir.Inst.UnOp) InnerError!*Inst { |
| 1232 | const tracy = trace(@src()); | 1258 | const tracy = trace(@src()); |
| 1233 | defer tracy.end(); | 1259 | defer tracy.end(); |
| 1234 | return mod.fail(scope, unwrap.base.src, "TODO implement analyzeInstEnsureErrPayloadVoid", .{}); | 1260 | return mod.fail(scope, unwrap.base.src, "TODO implement zirEnsureErrPayloadVoid", .{}); |
| 1235 | } | 1261 | } |
| 1236 | | 1262 | |
| 1237 | fn analyzeInstFnType(mod: *Module, scope: *Scope, fntype: *zir.Inst.FnType) InnerError!*Inst { | 1263 | fn zirFnType(mod: *Module, scope: *Scope, fntype: *zir.Inst.FnType) InnerError!*Inst { |
| 1238 | const tracy = trace(@src()); | 1264 | const tracy = trace(@src()); |
| 1239 | defer tracy.end(); | 1265 | defer tracy.end(); |
| 1240 | const return_type = try resolveType(mod, scope, fntype.positionals.return_type); | 1266 | const return_type = try resolveType(mod, scope, fntype.positionals.return_type); |
| ... | @@ -1277,13 +1303,13 @@ fn analyzeInstFnType(mod: *Module, scope: *Scope, fntype: *zir.Inst.FnType) Inne | ... | @@ -1277,13 +1303,13 @@ fn analyzeInstFnType(mod: *Module, scope: *Scope, fntype: *zir.Inst.FnType) Inne |
| 1277 | return mod.constType(scope, fntype.base.src, fn_ty); | 1303 | return mod.constType(scope, fntype.base.src, fn_ty); |
| 1278 | } | 1304 | } |
| 1279 | | 1305 | |
| 1280 | fn analyzeInstPrimitive(mod: *Module, scope: *Scope, primitive: *zir.Inst.Primitive) InnerError!*Inst { | 1306 | fn zirPrimitive(mod: *Module, scope: *Scope, primitive: *zir.Inst.Primitive) InnerError!*Inst { |
| 1281 | const tracy = trace(@src()); | 1307 | const tracy = trace(@src()); |
| 1282 | defer tracy.end(); | 1308 | defer tracy.end(); |
| 1283 | return mod.constInst(scope, primitive.base.src, primitive.positionals.tag.toTypedValue()); | 1309 | return mod.constInst(scope, primitive.base.src, primitive.positionals.tag.toTypedValue()); |
| 1284 | } | 1310 | } |
| 1285 | | 1311 | |
| 1286 | fn analyzeInstAs(mod: *Module, scope: *Scope, as: *zir.Inst.BinOp) InnerError!*Inst { | 1312 | fn zirAs(mod: *Module, scope: *Scope, as: *zir.Inst.BinOp) InnerError!*Inst { |
| 1287 | const tracy = trace(@src()); | 1313 | const tracy = trace(@src()); |
| 1288 | defer tracy.end(); | 1314 | defer tracy.end(); |
| 1289 | const dest_type = try resolveType(mod, scope, as.positionals.lhs); | 1315 | const dest_type = try resolveType(mod, scope, as.positionals.lhs); |
| ... | @@ -1291,7 +1317,7 @@ fn analyzeInstAs(mod: *Module, scope: *Scope, as: *zir.Inst.BinOp) InnerError!*I | ... | @@ -1291,7 +1317,7 @@ fn analyzeInstAs(mod: *Module, scope: *Scope, as: *zir.Inst.BinOp) InnerError!*I |
| 1291 | return mod.coerce(scope, dest_type, new_inst); | 1317 | return mod.coerce(scope, dest_type, new_inst); |
| 1292 | } | 1318 | } |
| 1293 | | 1319 | |
| 1294 | fn analyzeInstPtrToInt(mod: *Module, scope: *Scope, ptrtoint: *zir.Inst.UnOp) InnerError!*Inst { | 1320 | fn zirPtrtoint(mod: *Module, scope: *Scope, ptrtoint: *zir.Inst.UnOp) InnerError!*Inst { |
| 1295 | const tracy = trace(@src()); | 1321 | const tracy = trace(@src()); |
| 1296 | defer tracy.end(); | 1322 | defer tracy.end(); |
| 1297 | const ptr = try resolveInst(mod, scope, ptrtoint.positionals.operand); | 1323 | const ptr = try resolveInst(mod, scope, ptrtoint.positionals.operand); |
| ... | @@ -1304,7 +1330,7 @@ fn analyzeInstPtrToInt(mod: *Module, scope: *Scope, ptrtoint: *zir.Inst.UnOp) In | ... | @@ -1304,7 +1330,7 @@ fn analyzeInstPtrToInt(mod: *Module, scope: *Scope, ptrtoint: *zir.Inst.UnOp) In |
| 1304 | return mod.addUnOp(b, ptrtoint.base.src, ty, .ptrtoint, ptr); | 1330 | return mod.addUnOp(b, ptrtoint.base.src, ty, .ptrtoint, ptr); |
| 1305 | } | 1331 | } |
| 1306 | | 1332 | |
| 1307 | fn fieldVal(mod: *Module, scope: *Scope, inst: *zir.Inst.Field) InnerError!*Inst { | 1333 | fn zirFieldVal(mod: *Module, scope: *Scope, inst: *zir.Inst.Field) InnerError!*Inst { |
| 1308 | const tracy = trace(@src()); | 1334 | const tracy = trace(@src()); |
| 1309 | defer tracy.end(); | 1335 | defer tracy.end(); |
| 1310 | | 1336 | |
| ... | @@ -1315,7 +1341,7 @@ fn fieldVal(mod: *Module, scope: *Scope, inst: *zir.Inst.Field) InnerError!*Inst | ... | @@ -1315,7 +1341,7 @@ fn fieldVal(mod: *Module, scope: *Scope, inst: *zir.Inst.Field) InnerError!*Inst |
| 1315 | return mod.analyzeDeref(scope, inst.base.src, result_ptr, result_ptr.src); | 1341 | return mod.analyzeDeref(scope, inst.base.src, result_ptr, result_ptr.src); |
| 1316 | } | 1342 | } |
| 1317 | | 1343 | |
| 1318 | fn fieldPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.Field) InnerError!*Inst { | 1344 | fn zirFieldPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.Field) InnerError!*Inst { |
| 1319 | const tracy = trace(@src()); | 1345 | const tracy = trace(@src()); |
| 1320 | defer tracy.end(); | 1346 | defer tracy.end(); |
| 1321 | | 1347 | |
| ... | @@ -1324,7 +1350,7 @@ fn fieldPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.Field) InnerError!*Inst | ... | @@ -1324,7 +1350,7 @@ fn fieldPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.Field) InnerError!*Inst |
| 1324 | return mod.namedFieldPtr(scope, inst.base.src, object_ptr, field_name, inst.base.src); | 1350 | return mod.namedFieldPtr(scope, inst.base.src, object_ptr, field_name, inst.base.src); |
| 1325 | } | 1351 | } |
| 1326 | | 1352 | |
| 1327 | fn fieldValNamed(mod: *Module, scope: *Scope, inst: *zir.Inst.FieldNamed) InnerError!*Inst { | 1353 | fn zirFieldValNamed(mod: *Module, scope: *Scope, inst: *zir.Inst.FieldNamed) InnerError!*Inst { |
| 1328 | const tracy = trace(@src()); | 1354 | const tracy = trace(@src()); |
| 1329 | defer tracy.end(); | 1355 | defer tracy.end(); |
| 1330 | | 1356 | |
| ... | @@ -1336,7 +1362,7 @@ fn fieldValNamed(mod: *Module, scope: *Scope, inst: *zir.Inst.FieldNamed) InnerE | ... | @@ -1336,7 +1362,7 @@ fn fieldValNamed(mod: *Module, scope: *Scope, inst: *zir.Inst.FieldNamed) InnerE |
| 1336 | return mod.analyzeDeref(scope, inst.base.src, result_ptr, result_ptr.src); | 1362 | return mod.analyzeDeref(scope, inst.base.src, result_ptr, result_ptr.src); |
| 1337 | } | 1363 | } |
| 1338 | | 1364 | |
| 1339 | fn fieldPtrNamed(mod: *Module, scope: *Scope, inst: *zir.Inst.FieldNamed) InnerError!*Inst { | 1365 | fn zirFieldPtrNamed(mod: *Module, scope: *Scope, inst: *zir.Inst.FieldNamed) InnerError!*Inst { |
| 1340 | const tracy = trace(@src()); | 1366 | const tracy = trace(@src()); |
| 1341 | defer tracy.end(); | 1367 | defer tracy.end(); |
| 1342 | | 1368 | |
| ... | @@ -1346,7 +1372,7 @@ fn fieldPtrNamed(mod: *Module, scope: *Scope, inst: *zir.Inst.FieldNamed) InnerE | ... | @@ -1346,7 +1372,7 @@ fn fieldPtrNamed(mod: *Module, scope: *Scope, inst: *zir.Inst.FieldNamed) InnerE |
| 1346 | return mod.namedFieldPtr(scope, inst.base.src, object_ptr, field_name, fsrc); | 1372 | return mod.namedFieldPtr(scope, inst.base.src, object_ptr, field_name, fsrc); |
| 1347 | } | 1373 | } |
| 1348 | | 1374 | |
| 1349 | fn analyzeInstIntCast(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { | 1375 | fn zirIntcast(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { |
| 1350 | const tracy = trace(@src()); | 1376 | const tracy = trace(@src()); |
| 1351 | defer tracy.end(); | 1377 | defer tracy.end(); |
| 1352 | const dest_type = try resolveType(mod, scope, inst.positionals.lhs); | 1378 | const dest_type = try resolveType(mod, scope, inst.positionals.lhs); |
| ... | @@ -1384,7 +1410,7 @@ fn analyzeInstIntCast(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerE | ... | @@ -1384,7 +1410,7 @@ fn analyzeInstIntCast(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerE |
| 1384 | return mod.fail(scope, inst.base.src, "TODO implement analyze widen or shorten int", .{}); | 1410 | return mod.fail(scope, inst.base.src, "TODO implement analyze widen or shorten int", .{}); |
| 1385 | } | 1411 | } |
| 1386 | | 1412 | |
| 1387 | fn analyzeInstBitCast(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { | 1413 | fn zirBitcast(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { |
| 1388 | const tracy = trace(@src()); | 1414 | const tracy = trace(@src()); |
| 1389 | defer tracy.end(); | 1415 | defer tracy.end(); |
| 1390 | const dest_type = try resolveType(mod, scope, inst.positionals.lhs); | 1416 | const dest_type = try resolveType(mod, scope, inst.positionals.lhs); |
| ... | @@ -1392,7 +1418,7 @@ fn analyzeInstBitCast(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerE | ... | @@ -1392,7 +1418,7 @@ fn analyzeInstBitCast(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerE |
| 1392 | return mod.bitcast(scope, dest_type, operand); | 1418 | return mod.bitcast(scope, dest_type, operand); |
| 1393 | } | 1419 | } |
| 1394 | | 1420 | |
| 1395 | fn analyzeInstFloatCast(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { | 1421 | fn zirFloatcast(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { |
| 1396 | const tracy = trace(@src()); | 1422 | const tracy = trace(@src()); |
| 1397 | defer tracy.end(); | 1423 | defer tracy.end(); |
| 1398 | const dest_type = try resolveType(mod, scope, inst.positionals.lhs); | 1424 | const dest_type = try resolveType(mod, scope, inst.positionals.lhs); |
| ... | @@ -1430,7 +1456,7 @@ fn analyzeInstFloatCast(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inne | ... | @@ -1430,7 +1456,7 @@ fn analyzeInstFloatCast(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inne |
| 1430 | return mod.fail(scope, inst.base.src, "TODO implement analyze widen or shorten float", .{}); | 1456 | return mod.fail(scope, inst.base.src, "TODO implement analyze widen or shorten float", .{}); |
| 1431 | } | 1457 | } |
| 1432 | | 1458 | |
| 1433 | fn elemVal(mod: *Module, scope: *Scope, inst: *zir.Inst.Elem) InnerError!*Inst { | 1459 | fn zirElemVal(mod: *Module, scope: *Scope, inst: *zir.Inst.Elem) InnerError!*Inst { |
| 1434 | const tracy = trace(@src()); | 1460 | const tracy = trace(@src()); |
| 1435 | defer tracy.end(); | 1461 | defer tracy.end(); |
| 1436 | | 1462 | |
| ... | @@ -1441,7 +1467,7 @@ fn elemVal(mod: *Module, scope: *Scope, inst: *zir.Inst.Elem) InnerError!*Inst { | ... | @@ -1441,7 +1467,7 @@ fn elemVal(mod: *Module, scope: *Scope, inst: *zir.Inst.Elem) InnerError!*Inst { |
| 1441 | return mod.analyzeDeref(scope, inst.base.src, result_ptr, result_ptr.src); | 1467 | return mod.analyzeDeref(scope, inst.base.src, result_ptr, result_ptr.src); |
| 1442 | } | 1468 | } |
| 1443 | | 1469 | |
| 1444 | fn elemPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.Elem) InnerError!*Inst { | 1470 | fn zirElemPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.Elem) InnerError!*Inst { |
| 1445 | const tracy = trace(@src()); | 1471 | const tracy = trace(@src()); |
| 1446 | defer tracy.end(); | 1472 | defer tracy.end(); |
| 1447 | | 1473 | |
| ... | @@ -1450,7 +1476,7 @@ fn elemPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.Elem) InnerError!*Inst { | ... | @@ -1450,7 +1476,7 @@ fn elemPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.Elem) InnerError!*Inst { |
| 1450 | return mod.elemPtr(scope, inst.base.src, array_ptr, elem_index); | 1476 | return mod.elemPtr(scope, inst.base.src, array_ptr, elem_index); |
| 1451 | } | 1477 | } |
| 1452 | | 1478 | |
| 1453 | fn analyzeInstSlice(mod: *Module, scope: *Scope, inst: *zir.Inst.Slice) InnerError!*Inst { | 1479 | fn zirSlice(mod: *Module, scope: *Scope, inst: *zir.Inst.Slice) InnerError!*Inst { |
| 1454 | const tracy = trace(@src()); | 1480 | const tracy = trace(@src()); |
| 1455 | defer tracy.end(); | 1481 | defer tracy.end(); |
| 1456 | const array_ptr = try resolveInst(mod, scope, inst.positionals.array_ptr); | 1482 | const array_ptr = try resolveInst(mod, scope, inst.positionals.array_ptr); |
| ... | @@ -1461,7 +1487,7 @@ fn analyzeInstSlice(mod: *Module, scope: *Scope, inst: *zir.Inst.Slice) InnerErr | ... | @@ -1461,7 +1487,7 @@ fn analyzeInstSlice(mod: *Module, scope: *Scope, inst: *zir.Inst.Slice) InnerErr |
| 1461 | return mod.analyzeSlice(scope, inst.base.src, array_ptr, start, end, sentinel); | 1487 | return mod.analyzeSlice(scope, inst.base.src, array_ptr, start, end, sentinel); |
| 1462 | } | 1488 | } |
| 1463 | | 1489 | |
| 1464 | fn analyzeInstSliceStart(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { | 1490 | fn zirSliceStart(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { |
| 1465 | const tracy = trace(@src()); | 1491 | const tracy = trace(@src()); |
| 1466 | defer tracy.end(); | 1492 | defer tracy.end(); |
| 1467 | const array_ptr = try resolveInst(mod, scope, inst.positionals.lhs); | 1493 | const array_ptr = try resolveInst(mod, scope, inst.positionals.lhs); |
| ... | @@ -1470,7 +1496,7 @@ fn analyzeInstSliceStart(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inn | ... | @@ -1470,7 +1496,7 @@ fn analyzeInstSliceStart(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inn |
| 1470 | return mod.analyzeSlice(scope, inst.base.src, array_ptr, start, null, null); | 1496 | return mod.analyzeSlice(scope, inst.base.src, array_ptr, start, null, null); |
| 1471 | } | 1497 | } |
| 1472 | | 1498 | |
| 1473 | fn analyzeInstSwitchRange(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { | 1499 | fn zirSwitchRange(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { |
| 1474 | const tracy = trace(@src()); | 1500 | const tracy = trace(@src()); |
| 1475 | defer tracy.end(); | 1501 | defer tracy.end(); |
| 1476 | const start = try resolveInst(mod, scope, inst.positionals.lhs); | 1502 | const start = try resolveInst(mod, scope, inst.positionals.lhs); |
| ... | @@ -1494,7 +1520,7 @@ fn analyzeInstSwitchRange(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) In | ... | @@ -1494,7 +1520,7 @@ fn analyzeInstSwitchRange(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) In |
| 1494 | return mod.constVoid(scope, inst.base.src); | 1520 | return mod.constVoid(scope, inst.base.src); |
| 1495 | } | 1521 | } |
| 1496 | | 1522 | |
| 1497 | fn analyzeInstSwitchBr(mod: *Module, scope: *Scope, inst: *zir.Inst.SwitchBr) InnerError!*Inst { | 1523 | fn zirSwitchbr(mod: *Module, scope: *Scope, inst: *zir.Inst.SwitchBr) InnerError!*Inst { |
| 1498 | const tracy = trace(@src()); | 1524 | const tracy = trace(@src()); |
| 1499 | defer tracy.end(); | 1525 | defer tracy.end(); |
| 1500 | const target_ptr = try resolveInst(mod, scope, inst.positionals.target_ptr); | 1526 | const target_ptr = try resolveInst(mod, scope, inst.positionals.target_ptr); |
| ... | @@ -1698,7 +1724,7 @@ fn validateSwitch(mod: *Module, scope: *Scope, target: *Inst, inst: *zir.Inst.Sw | ... | @@ -1698,7 +1724,7 @@ fn validateSwitch(mod: *Module, scope: *Scope, target: *Inst, inst: *zir.Inst.Sw |
| 1698 | } | 1724 | } |
| 1699 | } | 1725 | } |
| 1700 | | 1726 | |
| 1701 | fn analyzeInstImport(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 1727 | fn zirImport(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 1702 | const tracy = trace(@src()); | 1728 | const tracy = trace(@src()); |
| 1703 | defer tracy.end(); | 1729 | defer tracy.end(); |
| 1704 | const operand = try resolveConstString(mod, scope, inst.positionals.operand); | 1730 | const operand = try resolveConstString(mod, scope, inst.positionals.operand); |
| ... | @@ -1718,19 +1744,19 @@ fn analyzeInstImport(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerErr | ... | @@ -1718,19 +1744,19 @@ fn analyzeInstImport(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerErr |
| 1718 | return mod.constType(scope, inst.base.src, file_scope.root_container.ty); | 1744 | return mod.constType(scope, inst.base.src, file_scope.root_container.ty); |
| 1719 | } | 1745 | } |
| 1720 | | 1746 | |
| 1721 | fn analyzeInstShl(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { | 1747 | fn zirShl(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { |
| 1722 | const tracy = trace(@src()); | 1748 | const tracy = trace(@src()); |
| 1723 | defer tracy.end(); | 1749 | defer tracy.end(); |
| 1724 | return mod.fail(scope, inst.base.src, "TODO implement analyzeInstShl", .{}); | 1750 | return mod.fail(scope, inst.base.src, "TODO implement zirShl", .{}); |
| 1725 | } | 1751 | } |
| 1726 | | 1752 | |
| 1727 | fn analyzeInstShr(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { | 1753 | fn zirShr(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { |
| 1728 | const tracy = trace(@src()); | 1754 | const tracy = trace(@src()); |
| 1729 | defer tracy.end(); | 1755 | defer tracy.end(); |
| 1730 | return mod.fail(scope, inst.base.src, "TODO implement analyzeInstShr", .{}); | 1756 | return mod.fail(scope, inst.base.src, "TODO implement zirShr", .{}); |
| 1731 | } | 1757 | } |
| 1732 | | 1758 | |
| 1733 | fn analyzeInstBitwise(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { | 1759 | fn zirBitwise(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { |
| 1734 | const tracy = trace(@src()); | 1760 | const tracy = trace(@src()); |
| 1735 | defer tracy.end(); | 1761 | defer tracy.end(); |
| 1736 | | 1762 | |
| ... | @@ -1784,8 +1810,8 @@ fn analyzeInstBitwise(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerE | ... | @@ -1784,8 +1810,8 @@ fn analyzeInstBitwise(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerE |
| 1784 | | 1810 | |
| 1785 | const b = try mod.requireRuntimeBlock(scope, inst.base.src); | 1811 | const b = try mod.requireRuntimeBlock(scope, inst.base.src); |
| 1786 | const ir_tag = switch (inst.base.tag) { | 1812 | const ir_tag = switch (inst.base.tag) { |
| 1787 | .bitand => Inst.Tag.bitand, | 1813 | .bit_and => Inst.Tag.bit_and, |
| 1788 | .bitor => Inst.Tag.bitor, | 1814 | .bit_or => Inst.Tag.bit_or, |
| 1789 | .xor => Inst.Tag.xor, | 1815 | .xor => Inst.Tag.xor, |
| 1790 | else => unreachable, | 1816 | else => unreachable, |
| 1791 | }; | 1817 | }; |
| ... | @@ -1793,25 +1819,25 @@ fn analyzeInstBitwise(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerE | ... | @@ -1793,25 +1819,25 @@ fn analyzeInstBitwise(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerE |
| 1793 | return mod.addBinOp(b, inst.base.src, scalar_type, ir_tag, casted_lhs, casted_rhs); | 1819 | return mod.addBinOp(b, inst.base.src, scalar_type, ir_tag, casted_lhs, casted_rhs); |
| 1794 | } | 1820 | } |
| 1795 | | 1821 | |
| 1796 | fn analyzeInstBitNot(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 1822 | fn zirBitNot(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 1797 | const tracy = trace(@src()); | 1823 | const tracy = trace(@src()); |
| 1798 | defer tracy.end(); | 1824 | defer tracy.end(); |
| 1799 | return mod.fail(scope, inst.base.src, "TODO implement analyzeInstBitNot", .{}); | 1825 | return mod.fail(scope, inst.base.src, "TODO implement zirBitNot", .{}); |
| 1800 | } | 1826 | } |
| 1801 | | 1827 | |
| 1802 | fn analyzeInstArrayCat(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { | 1828 | fn zirArrayCat(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { |
| 1803 | const tracy = trace(@src()); | 1829 | const tracy = trace(@src()); |
| 1804 | defer tracy.end(); | 1830 | defer tracy.end(); |
| 1805 | return mod.fail(scope, inst.base.src, "TODO implement analyzeInstArrayCat", .{}); | 1831 | return mod.fail(scope, inst.base.src, "TODO implement zirArrayCat", .{}); |
| 1806 | } | 1832 | } |
| 1807 | | 1833 | |
| 1808 | fn analyzeInstArrayMul(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { | 1834 | fn zirArrayMul(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { |
| 1809 | const tracy = trace(@src()); | 1835 | const tracy = trace(@src()); |
| 1810 | defer tracy.end(); | 1836 | defer tracy.end(); |
| 1811 | return mod.fail(scope, inst.base.src, "TODO implement analyzeInstArrayMul", .{}); | 1837 | return mod.fail(scope, inst.base.src, "TODO implement zirArrayMul", .{}); |
| 1812 | } | 1838 | } |
| 1813 | | 1839 | |
| 1814 | fn analyzeInstArithmetic(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { | 1840 | fn zirArithmetic(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { |
| 1815 | const tracy = trace(@src()); | 1841 | const tracy = trace(@src()); |
| 1816 | defer tracy.end(); | 1842 | defer tracy.end(); |
| 1817 | | 1843 | |
| ... | @@ -1912,14 +1938,14 @@ fn analyzeInstComptimeOp(mod: *Module, scope: *Scope, res_type: Type, inst: *zir | ... | @@ -1912,14 +1938,14 @@ fn analyzeInstComptimeOp(mod: *Module, scope: *Scope, res_type: Type, inst: *zir |
| 1912 | }); | 1938 | }); |
| 1913 | } | 1939 | } |
| 1914 | | 1940 | |
| 1915 | fn analyzeInstDeref(mod: *Module, scope: *Scope, deref: *zir.Inst.UnOp) InnerError!*Inst { | 1941 | fn zirDeref(mod: *Module, scope: *Scope, deref: *zir.Inst.UnOp) InnerError!*Inst { |
| 1916 | const tracy = trace(@src()); | 1942 | const tracy = trace(@src()); |
| 1917 | defer tracy.end(); | 1943 | defer tracy.end(); |
| 1918 | const ptr = try resolveInst(mod, scope, deref.positionals.operand); | 1944 | const ptr = try resolveInst(mod, scope, deref.positionals.operand); |
| 1919 | return mod.analyzeDeref(scope, deref.base.src, ptr, deref.positionals.operand.src); | 1945 | return mod.analyzeDeref(scope, deref.base.src, ptr, deref.positionals.operand.src); |
| 1920 | } | 1946 | } |
| 1921 | | 1947 | |
| 1922 | fn analyzeInstAsm(mod: *Module, scope: *Scope, assembly: *zir.Inst.Asm) InnerError!*Inst { | 1948 | fn zirAsm(mod: *Module, scope: *Scope, assembly: *zir.Inst.Asm) InnerError!*Inst { |
| 1923 | const tracy = trace(@src()); | 1949 | const tracy = trace(@src()); |
| 1924 | defer tracy.end(); | 1950 | defer tracy.end(); |
| 1925 | const return_type = try resolveType(mod, scope, assembly.positionals.return_type); | 1951 | const return_type = try resolveType(mod, scope, assembly.positionals.return_type); |
| ... | @@ -1960,7 +1986,7 @@ fn analyzeInstAsm(mod: *Module, scope: *Scope, assembly: *zir.Inst.Asm) InnerErr | ... | @@ -1960,7 +1986,7 @@ fn analyzeInstAsm(mod: *Module, scope: *Scope, assembly: *zir.Inst.Asm) InnerErr |
| 1960 | return &inst.base; | 1986 | return &inst.base; |
| 1961 | } | 1987 | } |
| 1962 | | 1988 | |
| 1963 | fn analyzeInstCmp( | 1989 | fn zirCmp( |
| 1964 | mod: *Module, | 1990 | mod: *Module, |
| 1965 | scope: *Scope, | 1991 | scope: *Scope, |
| 1966 | inst: *zir.Inst.BinOp, | 1992 | inst: *zir.Inst.BinOp, |
| ... | @@ -2018,14 +2044,14 @@ fn analyzeInstCmp( | ... | @@ -2018,14 +2044,14 @@ fn analyzeInstCmp( |
| 2018 | return mod.fail(scope, inst.base.src, "TODO implement more cmp analysis", .{}); | 2044 | return mod.fail(scope, inst.base.src, "TODO implement more cmp analysis", .{}); |
| 2019 | } | 2045 | } |
| 2020 | | 2046 | |
| 2021 | fn analyzeInstTypeOf(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 2047 | fn zirTypeof(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 2022 | const tracy = trace(@src()); | 2048 | const tracy = trace(@src()); |
| 2023 | defer tracy.end(); | 2049 | defer tracy.end(); |
| 2024 | const operand = try resolveInst(mod, scope, inst.positionals.operand); | 2050 | const operand = try resolveInst(mod, scope, inst.positionals.operand); |
| 2025 | return mod.constType(scope, inst.base.src, operand.ty); | 2051 | return mod.constType(scope, inst.base.src, operand.ty); |
| 2026 | } | 2052 | } |
| 2027 | | 2053 | |
| 2028 | fn analyzeInstTypeOfPeer(mod: *Module, scope: *Scope, inst: *zir.Inst.TypeOfPeer) InnerError!*Inst { | 2054 | fn zirTypeofPeer(mod: *Module, scope: *Scope, inst: *zir.Inst.TypeOfPeer) InnerError!*Inst { |
| 2029 | const tracy = trace(@src()); | 2055 | const tracy = trace(@src()); |
| 2030 | defer tracy.end(); | 2056 | defer tracy.end(); |
| 2031 | var insts_to_res = try mod.gpa.alloc(*ir.Inst, inst.positionals.items.len); | 2057 | var insts_to_res = try mod.gpa.alloc(*ir.Inst, inst.positionals.items.len); |
| ... | @@ -2037,7 +2063,7 @@ fn analyzeInstTypeOfPeer(mod: *Module, scope: *Scope, inst: *zir.Inst.TypeOfPeer | ... | @@ -2037,7 +2063,7 @@ fn analyzeInstTypeOfPeer(mod: *Module, scope: *Scope, inst: *zir.Inst.TypeOfPeer |
| 2037 | return mod.constType(scope, inst.base.src, pt_res); | 2063 | return mod.constType(scope, inst.base.src, pt_res); |
| 2038 | } | 2064 | } |
| 2039 | | 2065 | |
| 2040 | fn analyzeInstBoolNot(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 2066 | fn zirBoolNot(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 2041 | const tracy = trace(@src()); | 2067 | const tracy = trace(@src()); |
| 2042 | defer tracy.end(); | 2068 | defer tracy.end(); |
| 2043 | const uncasted_operand = try resolveInst(mod, scope, inst.positionals.operand); | 2069 | const uncasted_operand = try resolveInst(mod, scope, inst.positionals.operand); |
| ... | @@ -2050,7 +2076,7 @@ fn analyzeInstBoolNot(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerEr | ... | @@ -2050,7 +2076,7 @@ fn analyzeInstBoolNot(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerEr |
| 2050 | return mod.addUnOp(b, inst.base.src, bool_type, .not, operand); | 2076 | return mod.addUnOp(b, inst.base.src, bool_type, .not, operand); |
| 2051 | } | 2077 | } |
| 2052 | | 2078 | |
| 2053 | fn analyzeInstBoolOp(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { | 2079 | fn zirBoolOp(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerError!*Inst { |
| 2054 | const tracy = trace(@src()); | 2080 | const tracy = trace(@src()); |
| 2055 | defer tracy.end(); | 2081 | defer tracy.end(); |
| 2056 | const bool_type = Type.initTag(.bool); | 2082 | const bool_type = Type.initTag(.bool); |
| ... | @@ -2059,7 +2085,7 @@ fn analyzeInstBoolOp(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerEr | ... | @@ -2059,7 +2085,7 @@ fn analyzeInstBoolOp(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerEr |
| 2059 | const uncasted_rhs = try resolveInst(mod, scope, inst.positionals.rhs); | 2085 | const uncasted_rhs = try resolveInst(mod, scope, inst.positionals.rhs); |
| 2060 | const rhs = try mod.coerce(scope, bool_type, uncasted_rhs); | 2086 | const rhs = try mod.coerce(scope, bool_type, uncasted_rhs); |
| 2061 | | 2087 | |
| 2062 | const is_bool_or = inst.base.tag == .boolor; | 2088 | const is_bool_or = inst.base.tag == .bool_or; |
| 2063 | | 2089 | |
| 2064 | if (lhs.value()) |lhs_val| { | 2090 | if (lhs.value()) |lhs_val| { |
| 2065 | if (rhs.value()) |rhs_val| { | 2091 | if (rhs.value()) |rhs_val| { |
| ... | @@ -2071,17 +2097,17 @@ fn analyzeInstBoolOp(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerEr | ... | @@ -2071,17 +2097,17 @@ fn analyzeInstBoolOp(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerEr |
| 2071 | } | 2097 | } |
| 2072 | } | 2098 | } |
| 2073 | const b = try mod.requireRuntimeBlock(scope, inst.base.src); | 2099 | const b = try mod.requireRuntimeBlock(scope, inst.base.src); |
| 2074 | return mod.addBinOp(b, inst.base.src, bool_type, if (is_bool_or) .boolor else .booland, lhs, rhs); | 2100 | return mod.addBinOp(b, inst.base.src, bool_type, if (is_bool_or) .bool_or else .bool_and, lhs, rhs); |
| 2075 | } | 2101 | } |
| 2076 | | 2102 | |
| 2077 | fn isNull(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp, invert_logic: bool) InnerError!*Inst { | 2103 | fn zirIsNull(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp, invert_logic: bool) InnerError!*Inst { |
| 2078 | const tracy = trace(@src()); | 2104 | const tracy = trace(@src()); |
| 2079 | defer tracy.end(); | 2105 | defer tracy.end(); |
| 2080 | const operand = try resolveInst(mod, scope, inst.positionals.operand); | 2106 | const operand = try resolveInst(mod, scope, inst.positionals.operand); |
| 2081 | return mod.analyzeIsNull(scope, inst.base.src, operand, invert_logic); | 2107 | return mod.analyzeIsNull(scope, inst.base.src, operand, invert_logic); |
| 2082 | } | 2108 | } |
| 2083 | | 2109 | |
| 2084 | fn isNullPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp, invert_logic: bool) InnerError!*Inst { | 2110 | fn zirIsNullPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp, invert_logic: bool) InnerError!*Inst { |
| 2085 | const tracy = trace(@src()); | 2111 | const tracy = trace(@src()); |
| 2086 | defer tracy.end(); | 2112 | defer tracy.end(); |
| 2087 | const ptr = try resolveInst(mod, scope, inst.positionals.operand); | 2113 | const ptr = try resolveInst(mod, scope, inst.positionals.operand); |
| ... | @@ -2089,14 +2115,14 @@ fn isNullPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp, invert_logic: bo | ... | @@ -2089,14 +2115,14 @@ fn isNullPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp, invert_logic: bo |
| 2089 | return mod.analyzeIsNull(scope, inst.base.src, loaded, invert_logic); | 2115 | return mod.analyzeIsNull(scope, inst.base.src, loaded, invert_logic); |
| 2090 | } | 2116 | } |
| 2091 | | 2117 | |
| 2092 | fn isErr(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 2118 | fn zirIsErr(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 2093 | const tracy = trace(@src()); | 2119 | const tracy = trace(@src()); |
| 2094 | defer tracy.end(); | 2120 | defer tracy.end(); |
| 2095 | const operand = try resolveInst(mod, scope, inst.positionals.operand); | 2121 | const operand = try resolveInst(mod, scope, inst.positionals.operand); |
| 2096 | return mod.analyzeIsErr(scope, inst.base.src, operand); | 2122 | return mod.analyzeIsErr(scope, inst.base.src, operand); |
| 2097 | } | 2123 | } |
| 2098 | | 2124 | |
| 2099 | fn isErrPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 2125 | fn zirIsErrPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 2100 | const tracy = trace(@src()); | 2126 | const tracy = trace(@src()); |
| 2101 | defer tracy.end(); | 2127 | defer tracy.end(); |
| 2102 | const ptr = try resolveInst(mod, scope, inst.positionals.operand); | 2128 | const ptr = try resolveInst(mod, scope, inst.positionals.operand); |
| ... | @@ -2104,7 +2130,7 @@ fn isErrPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst | ... | @@ -2104,7 +2130,7 @@ fn isErrPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst |
| 2104 | return mod.analyzeIsErr(scope, inst.base.src, loaded); | 2130 | return mod.analyzeIsErr(scope, inst.base.src, loaded); |
| 2105 | } | 2131 | } |
| 2106 | | 2132 | |
| 2107 | fn analyzeInstCondBr(mod: *Module, scope: *Scope, inst: *zir.Inst.CondBr) InnerError!*Inst { | 2133 | fn zirCondbr(mod: *Module, scope: *Scope, inst: *zir.Inst.CondBr) InnerError!*Inst { |
| 2108 | const tracy = trace(@src()); | 2134 | const tracy = trace(@src()); |
| 2109 | defer tracy.end(); | 2135 | defer tracy.end(); |
| 2110 | const uncasted_cond = try resolveInst(mod, scope, inst.positionals.condition); | 2136 | const uncasted_cond = try resolveInst(mod, scope, inst.positionals.condition); |
| ... | @@ -2153,7 +2179,7 @@ fn analyzeInstCondBr(mod: *Module, scope: *Scope, inst: *zir.Inst.CondBr) InnerE | ... | @@ -2153,7 +2179,7 @@ fn analyzeInstCondBr(mod: *Module, scope: *Scope, inst: *zir.Inst.CondBr) InnerE |
| 2153 | return mod.addCondBr(parent_block, inst.base.src, cond, then_body, else_body); | 2179 | return mod.addCondBr(parent_block, inst.base.src, cond, then_body, else_body); |
| 2154 | } | 2180 | } |
| 2155 | | 2181 | |
| 2156 | fn analyzeInstUnreachable( | 2182 | fn zirUnreachable( |
| 2157 | mod: *Module, | 2183 | mod: *Module, |
| 2158 | scope: *Scope, | 2184 | scope: *Scope, |
| 2159 | unreach: *zir.Inst.NoOp, | 2185 | unreach: *zir.Inst.NoOp, |
| ... | @@ -2170,7 +2196,7 @@ fn analyzeInstUnreachable( | ... | @@ -2170,7 +2196,7 @@ fn analyzeInstUnreachable( |
| 2170 | } | 2196 | } |
| 2171 | } | 2197 | } |
| 2172 | | 2198 | |
| 2173 | fn analyzeInstRet(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 2199 | fn zirReturn(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 2174 | const tracy = trace(@src()); | 2200 | const tracy = trace(@src()); |
| 2175 | defer tracy.end(); | 2201 | defer tracy.end(); |
| 2176 | const operand = try resolveInst(mod, scope, inst.positionals.operand); | 2202 | const operand = try resolveInst(mod, scope, inst.positionals.operand); |
| ... | @@ -2185,7 +2211,7 @@ fn analyzeInstRet(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError! | ... | @@ -2185,7 +2211,7 @@ fn analyzeInstRet(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError! |
| 2185 | return mod.addUnOp(b, inst.base.src, Type.initTag(.noreturn), .ret, operand); | 2211 | return mod.addUnOp(b, inst.base.src, Type.initTag(.noreturn), .ret, operand); |
| 2186 | } | 2212 | } |
| 2187 | | 2213 | |
| 2188 | fn analyzeInstRetVoid(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerError!*Inst { | 2214 | fn zirReturnVoid(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerError!*Inst { |
| 2189 | const tracy = trace(@src()); | 2215 | const tracy = trace(@src()); |
| 2190 | defer tracy.end(); | 2216 | defer tracy.end(); |
| 2191 | const b = try mod.requireFunctionBlock(scope, inst.base.src); | 2217 | const b = try mod.requireFunctionBlock(scope, inst.base.src); |
| ... | @@ -2216,27 +2242,7 @@ fn floatOpAllowed(tag: zir.Inst.Tag) bool { | ... | @@ -2216,27 +2242,7 @@ fn floatOpAllowed(tag: zir.Inst.Tag) bool { |
| 2216 | }; | 2242 | }; |
| 2217 | } | 2243 | } |
| 2218 | | 2244 | |
| 2219 | fn analyzeBreak( | 2245 | fn zirSimplePtrType(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp, mutable: bool, size: std.builtin.TypeInfo.Pointer.Size) InnerError!*Inst { |
| 2220 | mod: *Module, | | |
| 2221 | scope: *Scope, | | |
| 2222 | src: usize, | | |
| 2223 | zir_block: *zir.Inst.Block, | | |
| 2224 | operand: *Inst, | | |
| 2225 | ) InnerError!*Inst { | | |
| 2226 | var opt_block = scope.cast(Scope.Block); | | |
| 2227 | while (opt_block) |block| { | | |
| 2228 | if (block.label) |*label| { | | |
| 2229 | if (label.zir_block == zir_block) { | | |
| 2230 | try label.merges.results.append(mod.gpa, operand); | | |
| 2231 | const b = try mod.requireFunctionBlock(scope, src); | | |
| 2232 | return mod.addBr(b, src, label.merges.block_inst, operand); | | |
| 2233 | } | | |
| 2234 | } | | |
| 2235 | opt_block = block.parent; | | |
| 2236 | } else unreachable; | | |
| 2237 | } | | |
| 2238 | | | |
| 2239 | fn analyzeInstSimplePtrType(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp, mutable: bool, size: std.builtin.TypeInfo.Pointer.Size) InnerError!*Inst { | | |
| 2240 | const tracy = trace(@src()); | 2246 | const tracy = trace(@src()); |
| 2241 | defer tracy.end(); | 2247 | defer tracy.end(); |
| 2242 | const elem_type = try resolveType(mod, scope, inst.positionals.operand); | 2248 | const elem_type = try resolveType(mod, scope, inst.positionals.operand); |
| ... | @@ -2244,7 +2250,7 @@ fn analyzeInstSimplePtrType(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp, m | ... | @@ -2244,7 +2250,7 @@ fn analyzeInstSimplePtrType(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp, m |
| 2244 | return mod.constType(scope, inst.base.src, ty); | 2250 | return mod.constType(scope, inst.base.src, ty); |
| 2245 | } | 2251 | } |
| 2246 | | 2252 | |
| 2247 | fn analyzeInstPtrType(mod: *Module, scope: *Scope, inst: *zir.Inst.PtrType) InnerError!*Inst { | 2253 | fn zirPtrType(mod: *Module, scope: *Scope, inst: *zir.Inst.PtrType) InnerError!*Inst { |
| 2248 | const tracy = trace(@src()); | 2254 | const tracy = trace(@src()); |
| 2249 | defer tracy.end(); | 2255 | defer tracy.end(); |
| 2250 | // TODO lazy values | 2256 | // TODO lazy values |