| ... | ... | @@ -28,144 +28,134 @@ const Decl = Module.Decl; |
| 28 | 28 | |
| 29 | 29 | pub fn analyzeInst(mod: *Module, scope: *Scope, old_inst: *zir.Inst) InnerError!*Inst { |
| 30 | 30 | switch (old_inst.tag) { |
| 31 | | .alloc => return analyzeInstAlloc(mod, scope, old_inst.castTag(.alloc).?), |
| 32 | | .alloc_mut => return analyzeInstAllocMut(mod, scope, old_inst.castTag(.alloc_mut).?), |
| 33 | | .alloc_inferred => return analyzeInstAllocInferred( |
| 34 | | mod, |
| 35 | | scope, |
| 36 | | old_inst.castTag(.alloc_inferred).?, |
| 37 | | .inferred_alloc_const, |
| 38 | | ), |
| 39 | | .alloc_inferred_mut => return analyzeInstAllocInferred( |
| 40 | | mod, |
| 41 | | scope, |
| 42 | | old_inst.castTag(.alloc_inferred_mut).?, |
| 43 | | .inferred_alloc_mut, |
| 44 | | ), |
| 45 | | .arg => return analyzeInstArg(mod, scope, old_inst.castTag(.arg).?), |
| 46 | | .bitcast_ref => return bitCastRef(mod, scope, old_inst.castTag(.bitcast_ref).?), |
| 47 | | .bitcast_result_ptr => return bitCastResultPtr(mod, scope, old_inst.castTag(.bitcast_result_ptr).?), |
| 48 | | .block => return analyzeInstBlock(mod, scope, old_inst.castTag(.block).?, false), |
| 49 | | .block_comptime => return analyzeInstBlock(mod, scope, old_inst.castTag(.block_comptime).?, true), |
| 50 | | .block_flat => return analyzeInstBlockFlat(mod, scope, old_inst.castTag(.block_flat).?, false), |
| 51 | | .block_comptime_flat => return analyzeInstBlockFlat(mod, scope, old_inst.castTag(.block_comptime_flat).?, true), |
| 52 | | .@"break" => return analyzeInstBreak(mod, scope, old_inst.castTag(.@"break").?), |
| 53 | | .breakpoint => return analyzeInstBreakpoint(mod, scope, old_inst.castTag(.breakpoint).?), |
| 54 | | .breakvoid => return analyzeInstBreakVoid(mod, scope, old_inst.castTag(.breakvoid).?), |
| 55 | | .call => return call(mod, scope, old_inst.castTag(.call).?), |
| 56 | | .coerce_result_block_ptr => return analyzeInstCoerceResultBlockPtr(mod, scope, old_inst.castTag(.coerce_result_block_ptr).?), |
| 57 | | .coerce_result_ptr => return analyzeInstCoerceResultPtr(mod, scope, old_inst.castTag(.coerce_result_ptr).?), |
| 58 | | .coerce_to_ptr_elem => return analyzeInstCoerceToPtrElem(mod, scope, old_inst.castTag(.coerce_to_ptr_elem).?), |
| 59 | | .compileerror => return analyzeInstCompileError(mod, scope, old_inst.castTag(.compileerror).?), |
| 60 | | .compilelog => return analyzeInstCompileLog(mod, scope, old_inst.castTag(.compilelog).?), |
| 61 | | .@"const" => return analyzeInstConst(mod, scope, old_inst.castTag(.@"const").?), |
| 62 | | .dbg_stmt => return analyzeInstDbgStmt(mod, scope, old_inst.castTag(.dbg_stmt).?), |
| 63 | | .declref => return declRef(mod, scope, old_inst.castTag(.declref).?), |
| 64 | | .declref_str => return analyzeInstDeclRefStr(mod, scope, old_inst.castTag(.declref_str).?), |
| 65 | | .declval => return declVal(mod, scope, old_inst.castTag(.declval).?), |
| 66 | | .ensure_result_used => return analyzeInstEnsureResultUsed(mod, scope, old_inst.castTag(.ensure_result_used).?), |
| 67 | | .ensure_result_non_error => return analyzeInstEnsureResultNonError(mod, scope, old_inst.castTag(.ensure_result_non_error).?), |
| 68 | | .indexable_ptr_len => return indexablePtrLen(mod, scope, old_inst.castTag(.indexable_ptr_len).?), |
| 69 | | .ref => return ref(mod, scope, old_inst.castTag(.ref).?), |
| 70 | | .resolve_inferred_alloc => return analyzeInstResolveInferredAlloc(mod, scope, old_inst.castTag(.resolve_inferred_alloc).?), |
| 71 | | .ret_ptr => return analyzeInstRetPtr(mod, scope, old_inst.castTag(.ret_ptr).?), |
| 72 | | .ret_type => return analyzeInstRetType(mod, scope, old_inst.castTag(.ret_type).?), |
| 73 | | .store_to_inferred_ptr => return analyzeInstStoreToInferredPtr(mod, scope, old_inst.castTag(.store_to_inferred_ptr).?), |
| 74 | | .single_const_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.single_const_ptr_type).?, false, .One), |
| 75 | | .single_mut_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.single_mut_ptr_type).?, true, .One), |
| 76 | | .many_const_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.many_const_ptr_type).?, false, .Many), |
| 77 | | .many_mut_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.many_mut_ptr_type).?, true, .Many), |
| 78 | | .c_const_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.c_const_ptr_type).?, false, .C), |
| 79 | | .c_mut_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.c_mut_ptr_type).?, true, .C), |
| 80 | | .const_slice_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.const_slice_type).?, false, .Slice), |
| 81 | | .mut_slice_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.mut_slice_type).?, true, .Slice), |
| 82 | | .ptr_type => return analyzeInstPtrType(mod, scope, old_inst.castTag(.ptr_type).?), |
| 83 | | .store => return analyzeInstStore(mod, scope, old_inst.castTag(.store).?), |
| 84 | | .set_eval_branch_quota => return analyzeInstSetEvalBranchQuota(mod, scope, old_inst.castTag(.set_eval_branch_quota).?), |
| 85 | | .str => return analyzeInstStr(mod, scope, old_inst.castTag(.str).?), |
| 86 | | .int => return analyzeInstInt(mod, scope, old_inst.castTag(.int).?), |
| 87 | | .inttype => return analyzeInstIntType(mod, scope, old_inst.castTag(.inttype).?), |
| 88 | | .loop => return analyzeInstLoop(mod, scope, old_inst.castTag(.loop).?), |
| 89 | | .param_type => return analyzeInstParamType(mod, scope, old_inst.castTag(.param_type).?), |
| 90 | | .ptrtoint => return analyzeInstPtrToInt(mod, scope, old_inst.castTag(.ptrtoint).?), |
| 91 | | .field_ptr => return fieldPtr(mod, scope, old_inst.castTag(.field_ptr).?), |
| 92 | | .field_val => return fieldVal(mod, scope, old_inst.castTag(.field_val).?), |
| 93 | | .field_ptr_named => return fieldPtrNamed(mod, scope, old_inst.castTag(.field_ptr_named).?), |
| 94 | | .field_val_named => return fieldValNamed(mod, scope, old_inst.castTag(.field_val_named).?), |
| 95 | | .deref => return analyzeInstDeref(mod, scope, old_inst.castTag(.deref).?), |
| 96 | | .as => return analyzeInstAs(mod, scope, old_inst.castTag(.as).?), |
| 97 | | .@"asm" => return analyzeInstAsm(mod, scope, old_inst.castTag(.@"asm").?), |
| 98 | | .@"unreachable" => return analyzeInstUnreachable(mod, scope, old_inst.castTag(.@"unreachable").?, true), |
| 99 | | .unreach_nocheck => return analyzeInstUnreachable(mod, scope, old_inst.castTag(.unreach_nocheck).?, false), |
| 100 | | .@"return" => return analyzeInstRet(mod, scope, old_inst.castTag(.@"return").?), |
| 101 | | .returnvoid => return analyzeInstRetVoid(mod, scope, old_inst.castTag(.returnvoid).?), |
| 102 | | .@"fn" => return analyzeInstFn(mod, scope, old_inst.castTag(.@"fn").?), |
| 103 | | .@"export" => return analyzeInstExport(mod, scope, old_inst.castTag(.@"export").?), |
| 104 | | .primitive => return analyzeInstPrimitive(mod, scope, old_inst.castTag(.primitive).?), |
| 105 | | .fntype => return analyzeInstFnType(mod, scope, old_inst.castTag(.fntype).?), |
| 106 | | .intcast => return analyzeInstIntCast(mod, scope, old_inst.castTag(.intcast).?), |
| 107 | | .bitcast => return analyzeInstBitCast(mod, scope, old_inst.castTag(.bitcast).?), |
| 108 | | .floatcast => return analyzeInstFloatCast(mod, scope, old_inst.castTag(.floatcast).?), |
| 109 | | .elem_ptr => return elemPtr(mod, scope, old_inst.castTag(.elem_ptr).?), |
| 110 | | .elem_val => return elemVal(mod, scope, old_inst.castTag(.elem_val).?), |
| 111 | | .add => return analyzeInstArithmetic(mod, scope, old_inst.castTag(.add).?), |
| 112 | | .addwrap => return analyzeInstArithmetic(mod, scope, old_inst.castTag(.addwrap).?), |
| 113 | | .sub => return analyzeInstArithmetic(mod, scope, old_inst.castTag(.sub).?), |
| 114 | | .subwrap => return analyzeInstArithmetic(mod, scope, old_inst.castTag(.subwrap).?), |
| 115 | | .mul => return analyzeInstArithmetic(mod, scope, old_inst.castTag(.mul).?), |
| 116 | | .mulwrap => return analyzeInstArithmetic(mod, scope, old_inst.castTag(.mulwrap).?), |
| 117 | | .div => return analyzeInstArithmetic(mod, scope, old_inst.castTag(.div).?), |
| 118 | | .mod_rem => return analyzeInstArithmetic(mod, scope, old_inst.castTag(.mod_rem).?), |
| 119 | | .array_cat => return analyzeInstArrayCat(mod, scope, old_inst.castTag(.array_cat).?), |
| 120 | | .array_mul => return analyzeInstArrayMul(mod, scope, old_inst.castTag(.array_mul).?), |
| 121 | | .bitand => return analyzeInstBitwise(mod, scope, old_inst.castTag(.bitand).?), |
| 122 | | .bitnot => return analyzeInstBitNot(mod, scope, old_inst.castTag(.bitnot).?), |
| 123 | | .bitor => return analyzeInstBitwise(mod, scope, old_inst.castTag(.bitor).?), |
| 124 | | .xor => return analyzeInstBitwise(mod, scope, old_inst.castTag(.xor).?), |
| 125 | | .shl => return analyzeInstShl(mod, scope, old_inst.castTag(.shl).?), |
| 126 | | .shr => return analyzeInstShr(mod, scope, old_inst.castTag(.shr).?), |
| 127 | | .cmp_lt => return analyzeInstCmp(mod, scope, old_inst.castTag(.cmp_lt).?, .lt), |
| 128 | | .cmp_lte => return analyzeInstCmp(mod, scope, old_inst.castTag(.cmp_lte).?, .lte), |
| 129 | | .cmp_eq => return analyzeInstCmp(mod, scope, old_inst.castTag(.cmp_eq).?, .eq), |
| 130 | | .cmp_gte => return analyzeInstCmp(mod, scope, old_inst.castTag(.cmp_gte).?, .gte), |
| 131 | | .cmp_gt => return analyzeInstCmp(mod, scope, old_inst.castTag(.cmp_gt).?, .gt), |
| 132 | | .cmp_neq => return analyzeInstCmp(mod, scope, old_inst.castTag(.cmp_neq).?, .neq), |
| 133 | | .condbr => return analyzeInstCondBr(mod, scope, old_inst.castTag(.condbr).?), |
| 134 | | .is_null => return isNull(mod, scope, old_inst.castTag(.is_null).?, false), |
| 135 | | .is_non_null => return isNull(mod, scope, old_inst.castTag(.is_non_null).?, true), |
| 136 | | .is_null_ptr => return isNullPtr(mod, scope, old_inst.castTag(.is_null_ptr).?, false), |
| 137 | | .is_non_null_ptr => return isNullPtr(mod, scope, old_inst.castTag(.is_non_null_ptr).?, true), |
| 138 | | .is_err => return isErr(mod, scope, old_inst.castTag(.is_err).?), |
| 139 | | .is_err_ptr => return isErrPtr(mod, scope, old_inst.castTag(.is_err_ptr).?), |
| 140 | | .boolnot => return analyzeInstBoolNot(mod, scope, old_inst.castTag(.boolnot).?), |
| 141 | | .typeof => return analyzeInstTypeOf(mod, scope, old_inst.castTag(.typeof).?), |
| 142 | | .typeof_peer => return analyzeInstTypeOfPeer(mod, scope, old_inst.castTag(.typeof_peer).?), |
| 143 | | .optional_type => return analyzeInstOptionalType(mod, scope, old_inst.castTag(.optional_type).?), |
| 144 | | .optional_payload_safe => return optionalPayload(mod, scope, old_inst.castTag(.optional_payload_safe).?, true), |
| 145 | | .optional_payload_unsafe => return optionalPayload(mod, scope, old_inst.castTag(.optional_payload_unsafe).?, false), |
| 146 | | .optional_payload_safe_ptr => return optionalPayloadPtr(mod, scope, old_inst.castTag(.optional_payload_safe_ptr).?, true), |
| 147 | | .optional_payload_unsafe_ptr => return optionalPayloadPtr(mod, scope, old_inst.castTag(.optional_payload_unsafe_ptr).?, false), |
| 148 | | .err_union_payload_safe => return errorUnionPayload(mod, scope, old_inst.castTag(.err_union_payload_safe).?, true), |
| 149 | | .err_union_payload_unsafe => return errorUnionPayload(mod, scope, old_inst.castTag(.err_union_payload_unsafe).?, false), |
| 150 | | .err_union_payload_safe_ptr => return errorUnionPayloadPtr(mod, scope, old_inst.castTag(.err_union_payload_safe_ptr).?, true), |
| 151 | | .err_union_payload_unsafe_ptr => return errorUnionPayloadPtr(mod, scope, old_inst.castTag(.err_union_payload_unsafe_ptr).?, false), |
| 152 | | .err_union_code => return errorUnionCode(mod, scope, old_inst.castTag(.err_union_code).?), |
| 153 | | .err_union_code_ptr => return errorUnionCodePtr(mod, scope, old_inst.castTag(.err_union_code_ptr).?), |
| 154 | | .ensure_err_payload_void => return analyzeInstEnsureErrPayloadVoid(mod, scope, old_inst.castTag(.ensure_err_payload_void).?), |
| 155 | | .array_type => return analyzeInstArrayType(mod, scope, old_inst.castTag(.array_type).?), |
| 156 | | .array_type_sentinel => return analyzeInstArrayTypeSentinel(mod, scope, old_inst.castTag(.array_type_sentinel).?), |
| 157 | | .enum_literal => return analyzeInstEnumLiteral(mod, scope, old_inst.castTag(.enum_literal).?), |
| 158 | | .merge_error_sets => return analyzeInstMergeErrorSets(mod, scope, old_inst.castTag(.merge_error_sets).?), |
| 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).?), |
| 31 | .alloc => return zirAlloc(mod, scope, old_inst.castTag(.alloc).?), |
| 32 | .alloc_mut => return zirAllocMut(mod, scope, old_inst.castTag(.alloc_mut).?), |
| 33 | .alloc_inferred => return zirAllocInferred(mod, scope, old_inst.castTag(.alloc_inferred).?, .inferred_alloc_const), |
| 34 | .alloc_inferred_mut => return zirAllocInferred(mod, scope, old_inst.castTag(.alloc_inferred_mut).?, .inferred_alloc_mut), |
| 35 | .arg => return zirArg(mod, scope, old_inst.castTag(.arg).?), |
| 36 | .bitcast_ref => return zirBitcastRef(mod, scope, old_inst.castTag(.bitcast_ref).?), |
| 37 | .bitcast_result_ptr => return zirBitcastResultPtr(mod, scope, old_inst.castTag(.bitcast_result_ptr).?), |
| 38 | .block => return zirBlock(mod, scope, old_inst.castTag(.block).?, false), |
| 39 | .block_comptime => return zirBlock(mod, scope, old_inst.castTag(.block_comptime).?, true), |
| 40 | .block_flat => return zirBlockFlat(mod, scope, old_inst.castTag(.block_flat).?, false), |
| 41 | .block_comptime_flat => return zirBlockFlat(mod, scope, old_inst.castTag(.block_comptime_flat).?, true), |
| 42 | .@"break" => return zirBreak(mod, scope, old_inst.castTag(.@"break").?), |
| 43 | .breakpoint => return zirBreakpoint(mod, scope, old_inst.castTag(.breakpoint).?), |
| 44 | .break_void => return zirBreakVoid(mod, scope, old_inst.castTag(.break_void).?), |
| 45 | .call => return zirCall(mod, scope, old_inst.castTag(.call).?), |
| 46 | .coerce_result_block_ptr => return zirCoerceResultBlockPtr(mod, scope, old_inst.castTag(.coerce_result_block_ptr).?), |
| 47 | .coerce_result_ptr => return zirCoerceResultPtr(mod, scope, old_inst.castTag(.coerce_result_ptr).?), |
| 48 | .compile_error => return zirCompileError(mod, scope, old_inst.castTag(.compile_error).?), |
| 49 | .compile_log => return zirCompileLog(mod, scope, old_inst.castTag(.compile_log).?), |
| 50 | .@"const" => return zirConst(mod, scope, old_inst.castTag(.@"const").?), |
| 51 | .dbg_stmt => return zirDbgStmt(mod, scope, old_inst.castTag(.dbg_stmt).?), |
| 52 | .decl_ref => return zirDeclRef(mod, scope, old_inst.castTag(.decl_ref).?), |
| 53 | .decl_ref_str => return zirDeclRefStr(mod, scope, old_inst.castTag(.decl_ref_str).?), |
| 54 | .decl_val => return zirDeclVal(mod, scope, old_inst.castTag(.decl_val).?), |
| 55 | .ensure_result_used => return zirEnsureResultUsed(mod, scope, old_inst.castTag(.ensure_result_used).?), |
| 56 | .ensure_result_non_error => return zirEnsureResultNonError(mod, scope, old_inst.castTag(.ensure_result_non_error).?), |
| 57 | .indexable_ptr_len => return zirIndexablePtrLen(mod, scope, old_inst.castTag(.indexable_ptr_len).?), |
| 58 | .ref => return zirRef(mod, scope, old_inst.castTag(.ref).?), |
| 59 | .resolve_inferred_alloc => return zirResolveInferredAlloc(mod, scope, old_inst.castTag(.resolve_inferred_alloc).?), |
| 60 | .ret_ptr => return zirRetPtr(mod, scope, old_inst.castTag(.ret_ptr).?), |
| 61 | .ret_type => return zirRetType(mod, scope, old_inst.castTag(.ret_type).?), |
| 62 | .store_to_block_ptr => return zirStoreToBlockPtr(mod, scope, old_inst.castTag(.store_to_block_ptr).?), |
| 63 | .store_to_inferred_ptr => return zirStoreToInferredPtr(mod, scope, old_inst.castTag(.store_to_inferred_ptr).?), |
| 64 | .single_const_ptr_type => return zirSimplePtrType(mod, scope, old_inst.castTag(.single_const_ptr_type).?, false, .One), |
| 65 | .single_mut_ptr_type => return zirSimplePtrType(mod, scope, old_inst.castTag(.single_mut_ptr_type).?, true, .One), |
| 66 | .many_const_ptr_type => return zirSimplePtrType(mod, scope, old_inst.castTag(.many_const_ptr_type).?, false, .Many), |
| 67 | .many_mut_ptr_type => return zirSimplePtrType(mod, scope, old_inst.castTag(.many_mut_ptr_type).?, true, .Many), |
| 68 | .c_const_ptr_type => return zirSimplePtrType(mod, scope, old_inst.castTag(.c_const_ptr_type).?, false, .C), |
| 69 | .c_mut_ptr_type => return zirSimplePtrType(mod, scope, old_inst.castTag(.c_mut_ptr_type).?, true, .C), |
| 70 | .const_slice_type => return zirSimplePtrType(mod, scope, old_inst.castTag(.const_slice_type).?, false, .Slice), |
| 71 | .mut_slice_type => return zirSimplePtrType(mod, scope, old_inst.castTag(.mut_slice_type).?, true, .Slice), |
| 72 | .ptr_type => return zirPtrType(mod, scope, old_inst.castTag(.ptr_type).?), |
| 73 | .store => return zirStore(mod, scope, old_inst.castTag(.store).?), |
| 74 | .set_eval_branch_quota => return zirSetEvalBranchQuota(mod, scope, old_inst.castTag(.set_eval_branch_quota).?), |
| 75 | .str => return zirStr(mod, scope, old_inst.castTag(.str).?), |
| 76 | .int => return zirInt(mod, scope, old_inst.castTag(.int).?), |
| 77 | .int_type => return zirIntType(mod, scope, old_inst.castTag(.int_type).?), |
| 78 | .loop => return zirLoop(mod, scope, old_inst.castTag(.loop).?), |
| 79 | .param_type => return zirParamType(mod, scope, old_inst.castTag(.param_type).?), |
| 80 | .ptrtoint => return zirPtrtoint(mod, scope, old_inst.castTag(.ptrtoint).?), |
| 81 | .field_ptr => return zirFieldPtr(mod, scope, old_inst.castTag(.field_ptr).?), |
| 82 | .field_val => return zirFieldVal(mod, scope, old_inst.castTag(.field_val).?), |
| 83 | .field_ptr_named => return zirFieldPtrNamed(mod, scope, old_inst.castTag(.field_ptr_named).?), |
| 84 | .field_val_named => return zirFieldValNamed(mod, scope, old_inst.castTag(.field_val_named).?), |
| 85 | .deref => return zirDeref(mod, scope, old_inst.castTag(.deref).?), |
| 86 | .as => return zirAs(mod, scope, old_inst.castTag(.as).?), |
| 87 | .@"asm" => return zirAsm(mod, scope, old_inst.castTag(.@"asm").?), |
| 88 | .unreachable_safe => return zirUnreachable(mod, scope, old_inst.castTag(.unreachable_safe).?, true), |
| 89 | .unreachable_unsafe => return zirUnreachable(mod, scope, old_inst.castTag(.unreachable_unsafe).?, false), |
| 90 | .@"return" => return zirReturn(mod, scope, old_inst.castTag(.@"return").?), |
| 91 | .return_void => return zirReturnVoid(mod, scope, old_inst.castTag(.return_void).?), |
| 92 | .@"fn" => return zirFn(mod, scope, old_inst.castTag(.@"fn").?), |
| 93 | .@"export" => return zirExport(mod, scope, old_inst.castTag(.@"export").?), |
| 94 | .primitive => return zirPrimitive(mod, scope, old_inst.castTag(.primitive).?), |
| 95 | .fntype => return zirFnType(mod, scope, old_inst.castTag(.fntype).?), |
| 96 | .intcast => return zirIntcast(mod, scope, old_inst.castTag(.intcast).?), |
| 97 | .bitcast => return zirBitcast(mod, scope, old_inst.castTag(.bitcast).?), |
| 98 | .floatcast => return zirFloatcast(mod, scope, old_inst.castTag(.floatcast).?), |
| 99 | .elem_ptr => return zirElemPtr(mod, scope, old_inst.castTag(.elem_ptr).?), |
| 100 | .elem_val => return zirElemVal(mod, scope, old_inst.castTag(.elem_val).?), |
| 101 | .add => return zirArithmetic(mod, scope, old_inst.castTag(.add).?), |
| 102 | .addwrap => return zirArithmetic(mod, scope, old_inst.castTag(.addwrap).?), |
| 103 | .sub => return zirArithmetic(mod, scope, old_inst.castTag(.sub).?), |
| 104 | .subwrap => return zirArithmetic(mod, scope, old_inst.castTag(.subwrap).?), |
| 105 | .mul => return zirArithmetic(mod, scope, old_inst.castTag(.mul).?), |
| 106 | .mulwrap => return zirArithmetic(mod, scope, old_inst.castTag(.mulwrap).?), |
| 107 | .div => return zirArithmetic(mod, scope, old_inst.castTag(.div).?), |
| 108 | .mod_rem => return zirArithmetic(mod, scope, old_inst.castTag(.mod_rem).?), |
| 109 | .array_cat => return zirArrayCat(mod, scope, old_inst.castTag(.array_cat).?), |
| 110 | .array_mul => return zirArrayMul(mod, scope, old_inst.castTag(.array_mul).?), |
| 111 | .bit_and => return zirBitwise(mod, scope, old_inst.castTag(.bit_and).?), |
| 112 | .bit_not => return zirBitNot(mod, scope, old_inst.castTag(.bit_not).?), |
| 113 | .bit_or => return zirBitwise(mod, scope, old_inst.castTag(.bit_or).?), |
| 114 | .xor => return zirBitwise(mod, scope, old_inst.castTag(.xor).?), |
| 115 | .shl => return zirShl(mod, scope, old_inst.castTag(.shl).?), |
| 116 | .shr => return zirShr(mod, scope, old_inst.castTag(.shr).?), |
| 117 | .cmp_lt => return zirCmp(mod, scope, old_inst.castTag(.cmp_lt).?, .lt), |
| 118 | .cmp_lte => return zirCmp(mod, scope, old_inst.castTag(.cmp_lte).?, .lte), |
| 119 | .cmp_eq => return zirCmp(mod, scope, old_inst.castTag(.cmp_eq).?, .eq), |
| 120 | .cmp_gte => return zirCmp(mod, scope, old_inst.castTag(.cmp_gte).?, .gte), |
| 121 | .cmp_gt => return zirCmp(mod, scope, old_inst.castTag(.cmp_gt).?, .gt), |
| 122 | .cmp_neq => return zirCmp(mod, scope, old_inst.castTag(.cmp_neq).?, .neq), |
| 123 | .condbr => return zirCondbr(mod, scope, old_inst.castTag(.condbr).?), |
| 124 | .is_null => return zirIsNull(mod, scope, old_inst.castTag(.is_null).?, false), |
| 125 | .is_non_null => return zirIsNull(mod, scope, old_inst.castTag(.is_non_null).?, true), |
| 126 | .is_null_ptr => return zirIsNullPtr(mod, scope, old_inst.castTag(.is_null_ptr).?, false), |
| 127 | .is_non_null_ptr => return zirIsNullPtr(mod, scope, old_inst.castTag(.is_non_null_ptr).?, true), |
| 128 | .is_err => return zirIsErr(mod, scope, old_inst.castTag(.is_err).?), |
| 129 | .is_err_ptr => return zirIsErrPtr(mod, scope, old_inst.castTag(.is_err_ptr).?), |
| 130 | .bool_not => return zirBoolNot(mod, scope, old_inst.castTag(.bool_not).?), |
| 131 | .typeof => return zirTypeof(mod, scope, old_inst.castTag(.typeof).?), |
| 132 | .typeof_peer => return zirTypeofPeer(mod, scope, old_inst.castTag(.typeof_peer).?), |
| 133 | .optional_type => return zirOptionalType(mod, scope, old_inst.castTag(.optional_type).?), |
| 134 | .optional_payload_safe => return zirOptionalPayload(mod, scope, old_inst.castTag(.optional_payload_safe).?, true), |
| 135 | .optional_payload_unsafe => return zirOptionalPayload(mod, scope, old_inst.castTag(.optional_payload_unsafe).?, false), |
| 136 | .optional_payload_safe_ptr => return zirOptionalPayloadPtr(mod, scope, old_inst.castTag(.optional_payload_safe_ptr).?, true), |
| 137 | .optional_payload_unsafe_ptr => return zirOptionalPayloadPtr(mod, scope, old_inst.castTag(.optional_payload_unsafe_ptr).?, false), |
| 138 | .err_union_payload_safe => return zirErrUnionPayload(mod, scope, old_inst.castTag(.err_union_payload_safe).?, true), |
| 139 | .err_union_payload_unsafe => return zirErrUnionPayload(mod, scope, old_inst.castTag(.err_union_payload_unsafe).?, false), |
| 140 | .err_union_payload_safe_ptr => return zirErrUnionPayloadPtr(mod, scope, old_inst.castTag(.err_union_payload_safe_ptr).?, true), |
| 141 | .err_union_payload_unsafe_ptr => return zirErrUnionPayloadPtr(mod, scope, old_inst.castTag(.err_union_payload_unsafe_ptr).?, false), |
| 142 | .err_union_code => return zirErrUnionCode(mod, scope, old_inst.castTag(.err_union_code).?), |
| 143 | .err_union_code_ptr => return zirErrUnionCodePtr(mod, scope, old_inst.castTag(.err_union_code_ptr).?), |
| 144 | .ensure_err_payload_void => return zirEnsureErrPayloadVoid(mod, scope, old_inst.castTag(.ensure_err_payload_void).?), |
| 145 | .array_type => return zirArrayType(mod, scope, old_inst.castTag(.array_type).?), |
| 146 | .array_type_sentinel => return zirArrayTypeSentinel(mod, scope, old_inst.castTag(.array_type_sentinel).?), |
| 147 | .enum_literal => return zirEnumLiteral(mod, scope, old_inst.castTag(.enum_literal).?), |
| 148 | .merge_error_sets => return zirMergeErrorSets(mod, scope, old_inst.castTag(.merge_error_sets).?), |
| 149 | .error_union_type => return zirErrorUnionType(mod, scope, old_inst.castTag(.error_union_type).?), |
| 150 | .anyframe_type => return zirAnyframeType(mod, scope, old_inst.castTag(.anyframe_type).?), |
| 151 | .error_set => return zirErrorSet(mod, scope, old_inst.castTag(.error_set).?), |
| 152 | .slice => return zirSlice(mod, scope, old_inst.castTag(.slice).?), |
| 153 | .slice_start => return zirSliceStart(mod, scope, old_inst.castTag(.slice_start).?), |
| 154 | .import => return zirImport(mod, scope, old_inst.castTag(.import).?), |
| 155 | .switchbr => return zirSwitchbr(mod, scope, old_inst.castTag(.switchbr).?), |
| 156 | .switch_range => return zirSwitchRange(mod, scope, old_inst.castTag(.switch_range).?), |
| 157 | .bool_and => return zirBoolOp(mod, scope, old_inst.castTag(.bool_and).?), |
| 158 | .bool_or => return zirBoolOp(mod, scope, old_inst.castTag(.bool_or).?), |
| 169 | 159 | |
| 170 | 160 | .container_field_named, |
| 171 | 161 | .container_field_typed, |
| ... | ... | @@ -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 | 252 | const tracy = trace(@src()); |
| 263 | 253 | defer tracy.end(); |
| 264 | 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 | 265 | }; |
| 276 | 266 | } |
| 277 | 267 | |
| 278 | | fn analyzeInstCoerceResultBlockPtr( |
| 268 | fn zirCoerceResultBlockPtr( |
| 279 | 269 | mod: *Module, |
| 280 | 270 | scope: *Scope, |
| 281 | 271 | inst: *zir.Inst.CoerceResultBlockPtr, |
| 282 | 272 | ) InnerError!*Inst { |
| 283 | 273 | const tracy = trace(@src()); |
| 284 | 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 | 279 | const tracy = trace(@src()); |
| 290 | 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 | 285 | const tracy = trace(@src()); |
| 296 | 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 | 291 | const tracy = trace(@src()); |
| 302 | 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)`. |
| 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 { |
| 296 | fn zirRetPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerError!*Inst { |
| 316 | 297 | const tracy = trace(@src()); |
| 317 | 298 | defer tracy.end(); |
| 318 | 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 | 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 | 307 | const tracy = trace(@src()); |
| 327 | 308 | defer tracy.end(); |
| 328 | 309 | |
| ... | ... | @@ -330,7 +311,7 @@ fn ref(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 330 | 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 | 315 | const tracy = trace(@src()); |
| 335 | 316 | defer tracy.end(); |
| 336 | 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 | 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 | 324 | const tracy = trace(@src()); |
| 344 | 325 | defer tracy.end(); |
| 345 | 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 | 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 | 334 | const tracy = trace(@src()); |
| 354 | 335 | defer tracy.end(); |
| 355 | 336 | const operand = try resolveInst(mod, scope, inst.positionals.operand); |
| ... | ... | @@ -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 | 344 | const tracy = trace(@src()); |
| 364 | 345 | defer tracy.end(); |
| 365 | 346 | |
| ... | ... | @@ -389,7 +370,7 @@ fn indexablePtrLen(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError |
| 389 | 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 | 374 | const tracy = trace(@src()); |
| 394 | 375 | defer tracy.end(); |
| 395 | 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 | 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 | 383 | const tracy = trace(@src()); |
| 403 | 384 | defer tracy.end(); |
| 404 | 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 | 389 | return mod.addNoOp(b, inst.base.src, ptr_type, .alloc); |
| 409 | 390 | } |
| 410 | 391 | |
| 411 | | fn analyzeInstAllocInferred( |
| 392 | fn zirAllocInferred( |
| 412 | 393 | mod: *Module, |
| 413 | 394 | scope: *Scope, |
| 414 | 395 | inst: *zir.Inst.NoOp, |
| ... | ... | @@ -437,7 +418,7 @@ fn analyzeInstAllocInferred( |
| 437 | 418 | return result; |
| 438 | 419 | } |
| 439 | 420 | |
| 440 | | fn analyzeInstResolveInferredAlloc( |
| 421 | fn zirResolveInferredAlloc( |
| 441 | 422 | mod: *Module, |
| 442 | 423 | scope: *Scope, |
| 443 | 424 | inst: *zir.Inst.UnOp, |
| ... | ... | @@ -466,28 +447,44 @@ fn analyzeInstResolveInferredAlloc( |
| 466 | 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 | 467 | mod: *Module, |
| 471 | 468 | scope: *Scope, |
| 472 | 469 | inst: *zir.Inst.BinOp, |
| 473 | 470 | ) InnerError!*Inst { |
| 474 | 471 | const tracy = trace(@src()); |
| 475 | 472 | defer tracy.end(); |
| 473 | |
| 476 | 474 | const ptr = try resolveInst(mod, scope, inst.positionals.lhs); |
| 477 | 475 | const value = try resolveInst(mod, scope, inst.positionals.rhs); |
| 478 | 476 | const inferred_alloc = ptr.castTag(.constant).?.val.castTag(.inferred_alloc).?; |
| 479 | 477 | // Add the stored instruction to the set we will use to resolve peer types |
| 480 | 478 | // for the inferred allocation. |
| 481 | 479 | try inferred_alloc.data.stored_inst_list.append(scope.arena(), value); |
| 482 | | // Create a new alloc with exactly the type the pointer wants. |
| 483 | | // Later it gets cleaned up by aliasing the alloc we are supposed to be storing to. |
| 480 | // Create a runtime bitcast instruction with exactly the type the pointer wants. |
| 484 | 481 | const ptr_ty = try mod.simplePtrType(scope, inst.base.src, value.ty, true, .One); |
| 485 | 482 | const b = try mod.requireRuntimeBlock(scope, inst.base.src); |
| 486 | 483 | const bitcasted_ptr = try mod.addUnOp(b, inst.base.src, ptr_ty, .bitcast, ptr); |
| 487 | 484 | return mod.storePtr(scope, inst.base.src, bitcasted_ptr, value); |
| 488 | 485 | } |
| 489 | 486 | |
| 490 | | fn analyzeInstSetEvalBranchQuota( |
| 487 | fn zirSetEvalBranchQuota( |
| 491 | 488 | mod: *Module, |
| 492 | 489 | scope: *Scope, |
| 493 | 490 | inst: *zir.Inst.UnOp, |
| ... | ... | @@ -499,15 +496,16 @@ fn analyzeInstSetEvalBranchQuota( |
| 499 | 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 | 500 | const tracy = trace(@src()); |
| 504 | 501 | defer tracy.end(); |
| 502 | |
| 505 | 503 | const ptr = try resolveInst(mod, scope, inst.positionals.lhs); |
| 506 | 504 | const value = try resolveInst(mod, scope, inst.positionals.rhs); |
| 507 | 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 | 509 | const tracy = trace(@src()); |
| 512 | 510 | defer tracy.end(); |
| 513 | 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 | 514 | const fn_ty: Type = switch (fn_inst.ty.zigTypeTag()) { |
| 517 | 515 | .Fn => fn_inst.ty, |
| 518 | 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 | 519 | else => { |
| 522 | 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 | 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 | 540 | const tracy = trace(@src()); |
| 543 | 541 | defer tracy.end(); |
| 544 | 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 | 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 | 559 | const tracy = trace(@src()); |
| 562 | 560 | defer tracy.end(); |
| 563 | 561 | |
| 564 | 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 | 566 | const tracy = trace(@src()); |
| 569 | 567 | defer tracy.end(); |
| 570 | 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 | 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 | 576 | const tracy = trace(@src()); |
| 579 | 577 | defer tracy.end(); |
| 580 | 578 | const msg = try resolveConstString(mod, scope, inst.positionals.operand); |
| 581 | 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 | 583 | var managed = mod.compile_log_text.toManaged(mod.gpa); |
| 586 | 584 | defer mod.compile_log_text = managed.moveToUnmanaged(); |
| 587 | 585 | const writer = managed.writer(); |
| ... | ... | @@ -608,7 +606,7 @@ fn analyzeInstCompileLog(mod: *Module, scope: *Scope, inst: *zir.Inst.CompileLog |
| 608 | 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 | 610 | const tracy = trace(@src()); |
| 613 | 611 | defer tracy.end(); |
| 614 | 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 | 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 | 633 | const tracy = trace(@src()); |
| 636 | 634 | defer tracy.end(); |
| 637 | 635 | const parent_block = scope.cast(Scope.Block).?; |
| ... | ... | @@ -672,7 +670,7 @@ fn analyzeInstLoop(mod: *Module, scope: *Scope, inst: *zir.Inst.Loop) InnerError |
| 672 | 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 | 674 | const tracy = trace(@src()); |
| 677 | 675 | defer tracy.end(); |
| 678 | 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 | 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 | 711 | const tracy = trace(@src()); |
| 709 | 712 | defer tracy.end(); |
| 713 | |
| 710 | 714 | const parent_block = scope.cast(Scope.Block).?; |
| 711 | 715 | |
| 712 | 716 | // Reserve space for a Block instruction so that generated Break instructions can |
| ... | ... | @@ -798,30 +802,52 @@ fn analyzeBlockBody( |
| 798 | 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 | 806 | const tracy = trace(@src()); |
| 803 | 807 | defer tracy.end(); |
| 804 | 808 | const b = try mod.requireRuntimeBlock(scope, inst.base.src); |
| 805 | 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 | 813 | const tracy = trace(@src()); |
| 810 | 814 | defer tracy.end(); |
| 815 | |
| 811 | 816 | const operand = try resolveInst(mod, scope, inst.positionals.operand); |
| 812 | 817 | const block = inst.positionals.block; |
| 813 | 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 | 822 | const tracy = trace(@src()); |
| 818 | 823 | defer tracy.end(); |
| 824 | |
| 819 | 825 | const block = inst.positionals.block; |
| 820 | 826 | const void_inst = try mod.constVoid(scope, inst.base.src); |
| 821 | 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 | 851 | const tracy = trace(@src()); |
| 826 | 852 | defer tracy.end(); |
| 827 | 853 | if (scope.cast(Scope.Block)) |b| { |
| ... | ... | @@ -832,26 +858,26 @@ fn analyzeInstDbgStmt(mod: *Module, scope: *Scope, inst: *zir.Inst.NoOp) InnerEr |
| 832 | 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 | 862 | const tracy = trace(@src()); |
| 837 | 863 | defer tracy.end(); |
| 838 | 864 | const decl_name = try resolveConstString(mod, scope, inst.positionals.name); |
| 839 | 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 | 869 | const tracy = trace(@src()); |
| 844 | 870 | defer tracy.end(); |
| 845 | 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 | 875 | const tracy = trace(@src()); |
| 850 | 876 | defer tracy.end(); |
| 851 | 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 | 881 | const tracy = trace(@src()); |
| 856 | 882 | defer tracy.end(); |
| 857 | 883 | |
| ... | ... | @@ -1002,7 +1028,7 @@ fn call(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError!*Inst { |
| 1002 | 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 | 1032 | const tracy = trace(@src()); |
| 1007 | 1033 | defer tracy.end(); |
| 1008 | 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 | 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 | 1049 | const tracy = trace(@src()); |
| 1024 | 1050 | defer tracy.end(); |
| 1025 | 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 | 1055 | const tracy = trace(@src()); |
| 1030 | 1056 | defer tracy.end(); |
| 1031 | 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 | 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 | 1063 | const tracy = trace(@src()); |
| 1038 | 1064 | defer tracy.end(); |
| 1039 | 1065 | // TODO these should be lazily evaluated |
| ... | ... | @@ -1043,7 +1069,7 @@ fn analyzeInstArrayType(mod: *Module, scope: *Scope, array: *zir.Inst.BinOp) Inn |
| 1043 | 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 | 1073 | const tracy = trace(@src()); |
| 1048 | 1074 | defer tracy.end(); |
| 1049 | 1075 | // TODO these should be lazily evaluated |
| ... | ... | @@ -1054,7 +1080,7 @@ fn analyzeInstArrayTypeSentinel(mod: *Module, scope: *Scope, array: *zir.Inst.Ar |
| 1054 | 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 | 1084 | const tracy = trace(@src()); |
| 1059 | 1085 | defer tracy.end(); |
| 1060 | 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 | 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 | 1097 | const tracy = trace(@src()); |
| 1072 | 1098 | defer tracy.end(); |
| 1073 | 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 | 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 | 1105 | const tracy = trace(@src()); |
| 1080 | 1106 | defer tracy.end(); |
| 1081 | 1107 | // The declarations arena will store the hashmap. |
| ... | ... | @@ -1107,13 +1133,13 @@ fn analyzeInstErrorSet(mod: *Module, scope: *Scope, inst: *zir.Inst.ErrorSet) In |
| 1107 | 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 | 1137 | const tracy = trace(@src()); |
| 1112 | 1138 | defer tracy.end(); |
| 1113 | 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 | 1143 | const tracy = trace(@src()); |
| 1118 | 1144 | defer tracy.end(); |
| 1119 | 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 | 1150 | } |
| 1125 | 1151 | |
| 1126 | 1152 | /// Pointer in, pointer out. |
| 1127 | | fn optionalPayloadPtr( |
| 1153 | fn zirOptionalPayloadPtr( |
| 1128 | 1154 | mod: *Module, |
| 1129 | 1155 | scope: *Scope, |
| 1130 | 1156 | unwrap: *zir.Inst.UnOp, |
| ... | ... | @@ -1165,7 +1191,7 @@ fn optionalPayloadPtr( |
| 1165 | 1191 | } |
| 1166 | 1192 | |
| 1167 | 1193 | /// Value in, value out. |
| 1168 | | fn optionalPayload( |
| 1194 | fn zirOptionalPayload( |
| 1169 | 1195 | mod: *Module, |
| 1170 | 1196 | scope: *Scope, |
| 1171 | 1197 | unwrap: *zir.Inst.UnOp, |
| ... | ... | @@ -1201,40 +1227,40 @@ fn optionalPayload( |
| 1201 | 1227 | } |
| 1202 | 1228 | |
| 1203 | 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 | 1231 | const tracy = trace(@src()); |
| 1206 | 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 | 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 | 1238 | const tracy = trace(@src()); |
| 1213 | 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 | 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 | 1245 | const tracy = trace(@src()); |
| 1220 | 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 | 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 | 1252 | const tracy = trace(@src()); |
| 1227 | 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 | 1258 | const tracy = trace(@src()); |
| 1233 | 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 | 1264 | const tracy = trace(@src()); |
| 1239 | 1265 | defer tracy.end(); |
| 1240 | 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 | 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 | 1307 | const tracy = trace(@src()); |
| 1282 | 1308 | defer tracy.end(); |
| 1283 | 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 | 1313 | const tracy = trace(@src()); |
| 1288 | 1314 | defer tracy.end(); |
| 1289 | 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 | 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 | 1321 | const tracy = trace(@src()); |
| 1296 | 1322 | defer tracy.end(); |
| 1297 | 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 | 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 | 1334 | const tracy = trace(@src()); |
| 1309 | 1335 | defer tracy.end(); |
| 1310 | 1336 | |
| ... | ... | @@ -1315,7 +1341,7 @@ fn fieldVal(mod: *Module, scope: *Scope, inst: *zir.Inst.Field) InnerError!*Inst |
| 1315 | 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 | 1345 | const tracy = trace(@src()); |
| 1320 | 1346 | defer tracy.end(); |
| 1321 | 1347 | |
| ... | ... | @@ -1324,7 +1350,7 @@ fn fieldPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.Field) InnerError!*Inst |
| 1324 | 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 | 1354 | const tracy = trace(@src()); |
| 1329 | 1355 | defer tracy.end(); |
| 1330 | 1356 | |
| ... | ... | @@ -1336,7 +1362,7 @@ fn fieldValNamed(mod: *Module, scope: *Scope, inst: *zir.Inst.FieldNamed) InnerE |
| 1336 | 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 | 1366 | const tracy = trace(@src()); |
| 1341 | 1367 | defer tracy.end(); |
| 1342 | 1368 | |
| ... | ... | @@ -1346,7 +1372,7 @@ fn fieldPtrNamed(mod: *Module, scope: *Scope, inst: *zir.Inst.FieldNamed) InnerE |
| 1346 | 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 | 1376 | const tracy = trace(@src()); |
| 1351 | 1377 | defer tracy.end(); |
| 1352 | 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 | 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 | 1414 | const tracy = trace(@src()); |
| 1389 | 1415 | defer tracy.end(); |
| 1390 | 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 | 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 | 1422 | const tracy = trace(@src()); |
| 1397 | 1423 | defer tracy.end(); |
| 1398 | 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 | 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 | 1460 | const tracy = trace(@src()); |
| 1435 | 1461 | defer tracy.end(); |
| 1436 | 1462 | |
| ... | ... | @@ -1441,7 +1467,7 @@ fn elemVal(mod: *Module, scope: *Scope, inst: *zir.Inst.Elem) InnerError!*Inst { |
| 1441 | 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 | 1471 | const tracy = trace(@src()); |
| 1446 | 1472 | defer tracy.end(); |
| 1447 | 1473 | |
| ... | ... | @@ -1450,7 +1476,7 @@ fn elemPtr(mod: *Module, scope: *Scope, inst: *zir.Inst.Elem) InnerError!*Inst { |
| 1450 | 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 | 1480 | const tracy = trace(@src()); |
| 1455 | 1481 | defer tracy.end(); |
| 1456 | 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 | 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 | 1491 | const tracy = trace(@src()); |
| 1466 | 1492 | defer tracy.end(); |
| 1467 | 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 | 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 | 1500 | const tracy = trace(@src()); |
| 1475 | 1501 | defer tracy.end(); |
| 1476 | 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 | 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 | 1524 | const tracy = trace(@src()); |
| 1499 | 1525 | defer tracy.end(); |
| 1500 | 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 | 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 | 1728 | const tracy = trace(@src()); |
| 1703 | 1729 | defer tracy.end(); |
| 1704 | 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 | 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 | 1748 | const tracy = trace(@src()); |
| 1723 | 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 | 1754 | const tracy = trace(@src()); |
| 1729 | 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 | 1760 | const tracy = trace(@src()); |
| 1735 | 1761 | defer tracy.end(); |
| 1736 | 1762 | |
| ... | ... | @@ -1784,8 +1810,8 @@ fn analyzeInstBitwise(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerE |
| 1784 | 1810 | |
| 1785 | 1811 | const b = try mod.requireRuntimeBlock(scope, inst.base.src); |
| 1786 | 1812 | const ir_tag = switch (inst.base.tag) { |
| 1787 | | .bitand => Inst.Tag.bitand, |
| 1788 | | .bitor => Inst.Tag.bitor, |
| 1813 | .bit_and => Inst.Tag.bit_and, |
| 1814 | .bit_or => Inst.Tag.bit_or, |
| 1789 | 1815 | .xor => Inst.Tag.xor, |
| 1790 | 1816 | else => unreachable, |
| 1791 | 1817 | }; |
| ... | ... | @@ -1793,25 +1819,25 @@ fn analyzeInstBitwise(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerE |
| 1793 | 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 | 1823 | const tracy = trace(@src()); |
| 1798 | 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 | 1829 | const tracy = trace(@src()); |
| 1804 | 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 | 1835 | const tracy = trace(@src()); |
| 1810 | 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 | 1841 | const tracy = trace(@src()); |
| 1816 | 1842 | defer tracy.end(); |
| 1817 | 1843 | |
| ... | ... | @@ -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 | 1942 | const tracy = trace(@src()); |
| 1917 | 1943 | defer tracy.end(); |
| 1918 | 1944 | const ptr = try resolveInst(mod, scope, deref.positionals.operand); |
| 1919 | 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 | 1949 | const tracy = trace(@src()); |
| 1924 | 1950 | defer tracy.end(); |
| 1925 | 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 | 1986 | return &inst.base; |
| 1961 | 1987 | } |
| 1962 | 1988 | |
| 1963 | | fn analyzeInstCmp( |
| 1989 | fn zirCmp( |
| 1964 | 1990 | mod: *Module, |
| 1965 | 1991 | scope: *Scope, |
| 1966 | 1992 | inst: *zir.Inst.BinOp, |
| ... | ... | @@ -2018,14 +2044,14 @@ fn analyzeInstCmp( |
| 2018 | 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 | 2048 | const tracy = trace(@src()); |
| 2023 | 2049 | defer tracy.end(); |
| 2024 | 2050 | const operand = try resolveInst(mod, scope, inst.positionals.operand); |
| 2025 | 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 | 2055 | const tracy = trace(@src()); |
| 2030 | 2056 | defer tracy.end(); |
| 2031 | 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 | 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 | 2067 | const tracy = trace(@src()); |
| 2042 | 2068 | defer tracy.end(); |
| 2043 | 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 | 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 | 2080 | const tracy = trace(@src()); |
| 2055 | 2081 | defer tracy.end(); |
| 2056 | 2082 | const bool_type = Type.initTag(.bool); |
| ... | ... | @@ -2059,7 +2085,7 @@ fn analyzeInstBoolOp(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerEr |
| 2059 | 2085 | const uncasted_rhs = try resolveInst(mod, scope, inst.positionals.rhs); |
| 2060 | 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 | 2090 | if (lhs.value()) |lhs_val| { |
| 2065 | 2091 | if (rhs.value()) |rhs_val| { |
| ... | ... | @@ -2071,17 +2097,17 @@ fn analyzeInstBoolOp(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerEr |
| 2071 | 2097 | } |
| 2072 | 2098 | } |
| 2073 | 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 | 2104 | const tracy = trace(@src()); |
| 2079 | 2105 | defer tracy.end(); |
| 2080 | 2106 | const operand = try resolveInst(mod, scope, inst.positionals.operand); |
| 2081 | 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 | 2111 | const tracy = trace(@src()); |
| 2086 | 2112 | defer tracy.end(); |
| 2087 | 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 | 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 | 2119 | const tracy = trace(@src()); |
| 2094 | 2120 | defer tracy.end(); |
| 2095 | 2121 | const operand = try resolveInst(mod, scope, inst.positionals.operand); |
| 2096 | 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 | 2126 | const tracy = trace(@src()); |
| 2101 | 2127 | defer tracy.end(); |
| 2102 | 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 | 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 | 2134 | const tracy = trace(@src()); |
| 2109 | 2135 | defer tracy.end(); |
| 2110 | 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 | 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 | 2183 | mod: *Module, |
| 2158 | 2184 | scope: *Scope, |
| 2159 | 2185 | unreach: *zir.Inst.NoOp, |
| ... | ... | @@ -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 | 2200 | const tracy = trace(@src()); |
| 2175 | 2201 | defer tracy.end(); |
| 2176 | 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 | 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 | 2215 | const tracy = trace(@src()); |
| 2190 | 2216 | defer tracy.end(); |
| 2191 | 2217 | const b = try mod.requireFunctionBlock(scope, inst.base.src); |
| ... | ... | @@ -2216,27 +2242,7 @@ fn floatOpAllowed(tag: zir.Inst.Tag) bool { |
| 2216 | 2242 | }; |
| 2217 | 2243 | } |
| 2218 | 2244 | |
| 2219 | | fn analyzeBreak( |
| 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 { |
| 2245 | fn zirSimplePtrType(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp, mutable: bool, size: std.builtin.TypeInfo.Pointer.Size) InnerError!*Inst { |
| 2240 | 2246 | const tracy = trace(@src()); |
| 2241 | 2247 | defer tracy.end(); |
| 2242 | 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 | 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 | 2254 | const tracy = trace(@src()); |
| 2249 | 2255 | defer tracy.end(); |
| 2250 | 2256 | // TODO lazy values |