| ... | ... | @@ -473,19 +473,20 @@ static constexpr IrInstructionId ir_instruction_id(IrInstructionIntToEnum *) { |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | template<typename T> |
| 476 | | static T *ir_create_instruction(IrExecutable *exec, Scope *scope, AstNode *source_node) { |
| 476 | static T *ir_create_instruction(IrBuilder *irb, Scope *scope, AstNode *source_node) { |
| 477 | 477 | T *special_instruction = allocate<T>(1); |
| 478 | 478 | special_instruction->base.id = ir_instruction_id(special_instruction); |
| 479 | 479 | special_instruction->base.scope = scope; |
| 480 | 480 | special_instruction->base.source_node = source_node; |
| 481 | | special_instruction->base.debug_id = exec_next_debug_id(exec); |
| 481 | special_instruction->base.debug_id = exec_next_debug_id(irb->exec); |
| 482 | special_instruction->base.owner_bb = irb->current_basic_block; |
| 482 | 483 | return special_instruction; |
| 483 | 484 | } |
| 484 | 485 | |
| 485 | 486 | template<typename T> |
| 486 | 487 | static T *ir_build_instruction(IrBuilder *irb, Scope *scope, AstNode *source_node) { |
| 487 | 488 | assert(source_node); |
| 488 | | T *special_instruction = ir_create_instruction<T>(irb->exec, scope, source_node); |
| 489 | T *special_instruction = ir_create_instruction<T>(irb, scope, source_node); |
| 489 | 490 | ir_instruction_append(irb->current_basic_block, &special_instruction->base); |
| 490 | 491 | return special_instruction; |
| 491 | 492 | } |
| ... | ... | @@ -554,7 +555,7 @@ static IrInstruction *ir_create_const(IrBuilder *irb, Scope *scope, AstNode *sou |
| 554 | 555 | TypeTableEntry *type_entry, bool depends_on_compile_var) |
| 555 | 556 | { |
| 556 | 557 | assert(type_entry); |
| 557 | | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb->exec, scope, source_node); |
| 558 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); |
| 558 | 559 | const_instruction->base.value.type = type_entry; |
| 559 | 560 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 560 | 561 | const_instruction->base.value.depends_on_compile_var = depends_on_compile_var; |
| ... | ... | @@ -610,7 +611,7 @@ static IrInstruction *ir_build_const_usize(IrBuilder *irb, Scope *scope, AstNode |
| 610 | 611 | static IrInstruction *ir_create_const_type(IrBuilder *irb, Scope *scope, AstNode *source_node, |
| 611 | 612 | TypeTableEntry *type_entry) |
| 612 | 613 | { |
| 613 | | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb->exec, scope, source_node); |
| 614 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); |
| 614 | 615 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_type; |
| 615 | 616 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 616 | 617 | const_instruction->base.value.data.x_type = type_entry; |
| ... | ... | @@ -672,7 +673,7 @@ static IrInstruction *ir_build_const_bound_fn(IrBuilder *irb, Scope *scope, AstN |
| 672 | 673 | } |
| 673 | 674 | |
| 674 | 675 | static IrInstruction *ir_create_const_str_lit(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *str) { |
| 675 | | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb->exec, scope, source_node); |
| 676 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); |
| 676 | 677 | init_const_str_lit(irb->codegen, &const_instruction->base.value, str); |
| 677 | 678 | |
| 678 | 679 | return &const_instruction->base; |
| ... | ... | @@ -863,7 +864,7 @@ static IrInstruction *ir_build_phi_from(IrBuilder *irb, IrInstruction *old_instr |
| 863 | 864 | static IrInstruction *ir_create_br(IrBuilder *irb, Scope *scope, AstNode *source_node, |
| 864 | 865 | IrBasicBlock *dest_block, IrInstruction *is_comptime) |
| 865 | 866 | { |
| 866 | | IrInstructionBr *br_instruction = ir_create_instruction<IrInstructionBr>(irb->exec, scope, source_node); |
| 867 | IrInstructionBr *br_instruction = ir_create_instruction<IrInstructionBr>(irb, scope, source_node); |
| 867 | 868 | br_instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable; |
| 868 | 869 | br_instruction->base.value.special = ConstValSpecialStatic; |
| 869 | 870 | br_instruction->dest_block = dest_block; |
| ... | ... | @@ -1948,6 +1949,777 @@ static IrInstruction *ir_build_int_to_enum(IrBuilder *irb, Scope *scope, AstNode |
| 1948 | 1949 | return &instruction->base; |
| 1949 | 1950 | } |
| 1950 | 1951 | |
| 1952 | static IrInstruction *ir_instruction_br_get_dep(IrInstructionBr *instruction, size_t index) { |
| 1953 | switch (index) { |
| 1954 | case 0: return instruction->is_comptime; |
| 1955 | default: return nullptr; |
| 1956 | } |
| 1957 | } |
| 1958 | |
| 1959 | static IrInstruction *ir_instruction_condbr_get_dep(IrInstructionCondBr *instruction, size_t index) { |
| 1960 | switch (index) { |
| 1961 | case 0: return instruction->condition; |
| 1962 | case 1: return instruction->is_comptime; |
| 1963 | default: return nullptr; |
| 1964 | } |
| 1965 | } |
| 1966 | |
| 1967 | static IrInstruction *ir_instruction_switchbr_get_dep(IrInstructionSwitchBr *instruction, size_t index) { |
| 1968 | switch (index) { |
| 1969 | case 0: return instruction->target_value; |
| 1970 | case 1: return instruction->is_comptime; |
| 1971 | } |
| 1972 | size_t case_index = index - 2; |
| 1973 | if (case_index < instruction->case_count) return instruction->cases[case_index].value; |
| 1974 | return nullptr; |
| 1975 | } |
| 1976 | |
| 1977 | static IrInstruction *ir_instruction_switchvar_get_dep(IrInstructionSwitchVar *instruction, size_t index) { |
| 1978 | switch (index) { |
| 1979 | case 0: return instruction->target_value_ptr; |
| 1980 | case 1: return instruction->prong_value; |
| 1981 | default: return nullptr; |
| 1982 | } |
| 1983 | } |
| 1984 | |
| 1985 | static IrInstruction *ir_instruction_switchtarget_get_dep(IrInstructionSwitchTarget *instruction, size_t index) { |
| 1986 | switch (index) { |
| 1987 | case 0: return instruction->target_value_ptr; |
| 1988 | default: return nullptr; |
| 1989 | } |
| 1990 | } |
| 1991 | |
| 1992 | static IrInstruction *ir_instruction_phi_get_dep(IrInstructionPhi *instruction, size_t index) { |
| 1993 | if (index < instruction->incoming_count) return instruction->incoming_values[index]; |
| 1994 | return nullptr; |
| 1995 | } |
| 1996 | |
| 1997 | static IrInstruction *ir_instruction_unop_get_dep(IrInstructionUnOp *instruction, size_t index) { |
| 1998 | switch (index) { |
| 1999 | case 0: return instruction->value; |
| 2000 | default: return nullptr; |
| 2001 | } |
| 2002 | } |
| 2003 | |
| 2004 | static IrInstruction *ir_instruction_binop_get_dep(IrInstructionBinOp *instruction, size_t index) { |
| 2005 | switch (index) { |
| 2006 | case 0: return instruction->op1; |
| 2007 | case 1: return instruction->op2; |
| 2008 | default: return nullptr; |
| 2009 | } |
| 2010 | } |
| 2011 | |
| 2012 | static IrInstruction *ir_instruction_declvar_get_dep(IrInstructionDeclVar *instruction, size_t index) { |
| 2013 | switch (index) { |
| 2014 | case 0: return instruction->var_type; |
| 2015 | case 1: return instruction->init_value; |
| 2016 | default: return nullptr; |
| 2017 | } |
| 2018 | } |
| 2019 | |
| 2020 | static IrInstruction *ir_instruction_loadptr_get_dep(IrInstructionLoadPtr *instruction, size_t index) { |
| 2021 | switch (index) { |
| 2022 | case 0: return instruction->ptr; |
| 2023 | default: return nullptr; |
| 2024 | } |
| 2025 | } |
| 2026 | |
| 2027 | static IrInstruction *ir_instruction_storeptr_get_dep(IrInstructionStorePtr *instruction, size_t index) { |
| 2028 | switch (index) { |
| 2029 | case 0: return instruction->ptr; |
| 2030 | case 1: return instruction->value; |
| 2031 | default: return nullptr; |
| 2032 | } |
| 2033 | } |
| 2034 | |
| 2035 | static IrInstruction *ir_instruction_fieldptr_get_dep(IrInstructionFieldPtr *instruction, size_t index) { |
| 2036 | switch (index) { |
| 2037 | case 0: return instruction->container_ptr; |
| 2038 | default: return nullptr; |
| 2039 | } |
| 2040 | } |
| 2041 | |
| 2042 | static IrInstruction *ir_instruction_structfieldptr_get_dep(IrInstructionStructFieldPtr *instruction, size_t index) { |
| 2043 | switch (index) { |
| 2044 | case 0: return instruction->struct_ptr; |
| 2045 | default: return nullptr; |
| 2046 | } |
| 2047 | } |
| 2048 | |
| 2049 | static IrInstruction *ir_instruction_enumfieldptr_get_dep(IrInstructionEnumFieldPtr *instruction, size_t index) { |
| 2050 | switch (index) { |
| 2051 | case 0: return instruction->enum_ptr; |
| 2052 | default: return nullptr; |
| 2053 | } |
| 2054 | } |
| 2055 | |
| 2056 | static IrInstruction *ir_instruction_elemptr_get_dep(IrInstructionElemPtr *instruction, size_t index) { |
| 2057 | switch (index) { |
| 2058 | case 0: return instruction->array_ptr; |
| 2059 | case 1: return instruction->elem_index; |
| 2060 | default: return nullptr; |
| 2061 | } |
| 2062 | } |
| 2063 | |
| 2064 | static IrInstruction *ir_instruction_varptr_get_dep(IrInstructionVarPtr *instruction, size_t index) { |
| 2065 | return nullptr; |
| 2066 | } |
| 2067 | |
| 2068 | static IrInstruction *ir_instruction_call_get_dep(IrInstructionCall *instruction, size_t index) { |
| 2069 | if (index == 0) return instruction->fn_ref; |
| 2070 | size_t arg_index = index - 1; |
| 2071 | if (arg_index < instruction->arg_count) return instruction->args[arg_index]; |
| 2072 | return nullptr; |
| 2073 | } |
| 2074 | |
| 2075 | static IrInstruction *ir_instruction_const_get_dep(IrInstructionConst *instruction, size_t index) { |
| 2076 | return nullptr; |
| 2077 | } |
| 2078 | |
| 2079 | static IrInstruction *ir_instruction_return_get_dep(IrInstructionReturn *instruction, size_t index) { |
| 2080 | switch (index) { |
| 2081 | case 0: return instruction->value; |
| 2082 | default: return nullptr; |
| 2083 | } |
| 2084 | } |
| 2085 | |
| 2086 | static IrInstruction *ir_instruction_cast_get_dep(IrInstructionCast *instruction, size_t index) { |
| 2087 | switch (index) { |
| 2088 | case 0: return instruction->value; |
| 2089 | default: return nullptr; |
| 2090 | } |
| 2091 | } |
| 2092 | |
| 2093 | static IrInstruction *ir_instruction_containerinitlist_get_dep(IrInstructionContainerInitList *instruction, |
| 2094 | size_t index) |
| 2095 | { |
| 2096 | if (index == 0) return instruction->container_type; |
| 2097 | size_t item_index = index - 1; |
| 2098 | if (item_index < instruction->item_count) return instruction->items[item_index]; |
| 2099 | return nullptr; |
| 2100 | } |
| 2101 | |
| 2102 | static IrInstruction *ir_instruction_containerinitfields_get_dep(IrInstructionContainerInitFields *instruction, |
| 2103 | size_t index) |
| 2104 | { |
| 2105 | if (index == 0) return instruction->container_type; |
| 2106 | size_t field_index = index - 1; |
| 2107 | if (field_index < instruction->field_count) return instruction->fields[field_index].value; |
| 2108 | return nullptr; |
| 2109 | } |
| 2110 | |
| 2111 | static IrInstruction *ir_instruction_structinit_get_dep(IrInstructionStructInit *instruction, size_t index) { |
| 2112 | if (index < instruction->field_count) return instruction->fields[index].value; |
| 2113 | return nullptr; |
| 2114 | } |
| 2115 | |
| 2116 | static IrInstruction *ir_instruction_unreachable_get_dep(IrInstructionUnreachable *instruction, size_t index) { |
| 2117 | return nullptr; |
| 2118 | } |
| 2119 | |
| 2120 | static IrInstruction *ir_instruction_typeof_get_dep(IrInstructionTypeOf *instruction, size_t index) { |
| 2121 | switch (index) { |
| 2122 | case 0: return instruction->value; |
| 2123 | default: return nullptr; |
| 2124 | } |
| 2125 | } |
| 2126 | |
| 2127 | static IrInstruction *ir_instruction_toptrtype_get_dep(IrInstructionToPtrType *instruction, size_t index) { |
| 2128 | switch (index) { |
| 2129 | case 0: return instruction->value; |
| 2130 | default: return nullptr; |
| 2131 | } |
| 2132 | } |
| 2133 | |
| 2134 | static IrInstruction *ir_instruction_ptrtypechild_get_dep(IrInstructionPtrTypeChild *instruction, size_t index) { |
| 2135 | switch (index) { |
| 2136 | case 0: return instruction->value; |
| 2137 | default: return nullptr; |
| 2138 | } |
| 2139 | } |
| 2140 | |
| 2141 | static IrInstruction *ir_instruction_setfntest_get_dep(IrInstructionSetFnTest *instruction, size_t index) { |
| 2142 | switch (index) { |
| 2143 | case 0: return instruction->fn_value; |
| 2144 | default: return nullptr; |
| 2145 | } |
| 2146 | } |
| 2147 | |
| 2148 | static IrInstruction *ir_instruction_setfnvisible_get_dep(IrInstructionSetFnVisible *instruction, size_t index) { |
| 2149 | switch (index) { |
| 2150 | case 0: return instruction->fn_value; |
| 2151 | case 1: return instruction->is_visible; |
| 2152 | default: return nullptr; |
| 2153 | } |
| 2154 | } |
| 2155 | |
| 2156 | static IrInstruction *ir_instruction_setdebugsafety_get_dep(IrInstructionSetDebugSafety *instruction, size_t index) { |
| 2157 | switch (index) { |
| 2158 | case 0: return instruction->scope_value; |
| 2159 | case 1: return instruction->debug_safety_on; |
| 2160 | default: return nullptr; |
| 2161 | } |
| 2162 | } |
| 2163 | |
| 2164 | static IrInstruction *ir_instruction_arraytype_get_dep(IrInstructionArrayType *instruction, size_t index) { |
| 2165 | switch (index) { |
| 2166 | case 0: return instruction->size; |
| 2167 | case 1: return instruction->child_type; |
| 2168 | default: return nullptr; |
| 2169 | } |
| 2170 | } |
| 2171 | |
| 2172 | static IrInstruction *ir_instruction_slicetype_get_dep(IrInstructionSliceType *instruction, size_t index) { |
| 2173 | switch (index) { |
| 2174 | case 0: return instruction->child_type; |
| 2175 | default: return nullptr; |
| 2176 | } |
| 2177 | } |
| 2178 | |
| 2179 | static IrInstruction *ir_instruction_asm_get_dep(IrInstructionAsm *instruction, size_t index) { |
| 2180 | AstNode *asm_node = instruction->base.source_node; |
| 2181 | if (index < asm_node->data.asm_expr.output_list.length) return instruction->output_types[index]; |
| 2182 | size_t input_index = index - asm_node->data.asm_expr.output_list.length; |
| 2183 | if (input_index < asm_node->data.asm_expr.input_list.length) return instruction->input_list[input_index]; |
| 2184 | return nullptr; |
| 2185 | } |
| 2186 | |
| 2187 | static IrInstruction *ir_instruction_compilevar_get_dep(IrInstructionCompileVar *instruction, size_t index) { |
| 2188 | switch (index) { |
| 2189 | case 0: return instruction->name; |
| 2190 | default: return nullptr; |
| 2191 | } |
| 2192 | } |
| 2193 | |
| 2194 | static IrInstruction *ir_instruction_sizeof_get_dep(IrInstructionSizeOf *instruction, size_t index) { |
| 2195 | switch (index) { |
| 2196 | case 0: return instruction->type_value; |
| 2197 | default: return nullptr; |
| 2198 | } |
| 2199 | } |
| 2200 | |
| 2201 | static IrInstruction *ir_instruction_testnonnull_get_dep(IrInstructionTestNonNull *instruction, size_t index) { |
| 2202 | switch (index) { |
| 2203 | case 0: return instruction->value; |
| 2204 | default: return nullptr; |
| 2205 | } |
| 2206 | } |
| 2207 | |
| 2208 | static IrInstruction *ir_instruction_unwrapmaybe_get_dep(IrInstructionUnwrapMaybe *instruction, size_t index) { |
| 2209 | switch (index) { |
| 2210 | case 0: return instruction->value; |
| 2211 | default: return nullptr; |
| 2212 | } |
| 2213 | } |
| 2214 | |
| 2215 | static IrInstruction *ir_instruction_maybewrap_get_dep(IrInstructionMaybeWrap *instruction, size_t index) { |
| 2216 | switch (index) { |
| 2217 | case 0: return instruction->value; |
| 2218 | default: return nullptr; |
| 2219 | } |
| 2220 | } |
| 2221 | |
| 2222 | static IrInstruction *ir_instruction_enumtag_get_dep(IrInstructionEnumTag *instruction, size_t index) { |
| 2223 | switch (index) { |
| 2224 | case 0: return instruction->value; |
| 2225 | default: return nullptr; |
| 2226 | } |
| 2227 | } |
| 2228 | |
| 2229 | static IrInstruction *ir_instruction_clz_get_dep(IrInstructionClz *instruction, size_t index) { |
| 2230 | switch (index) { |
| 2231 | case 0: return instruction->value; |
| 2232 | default: return nullptr; |
| 2233 | } |
| 2234 | } |
| 2235 | |
| 2236 | static IrInstruction *ir_instruction_ctz_get_dep(IrInstructionCtz *instruction, size_t index) { |
| 2237 | switch (index) { |
| 2238 | case 0: return instruction->value; |
| 2239 | default: return nullptr; |
| 2240 | } |
| 2241 | } |
| 2242 | |
| 2243 | static IrInstruction *ir_instruction_staticeval_get_dep(IrInstructionStaticEval *instruction, size_t index) { |
| 2244 | switch (index) { |
| 2245 | case 0: return instruction->value; |
| 2246 | default: return nullptr; |
| 2247 | } |
| 2248 | } |
| 2249 | |
| 2250 | static IrInstruction *ir_instruction_import_get_dep(IrInstructionImport *instruction, size_t index) { |
| 2251 | switch (index) { |
| 2252 | case 0: return instruction->name; |
| 2253 | default: return nullptr; |
| 2254 | } |
| 2255 | } |
| 2256 | |
| 2257 | static IrInstruction *ir_instruction_cimport_get_dep(IrInstructionCImport *instruction, size_t index) { |
| 2258 | return nullptr; |
| 2259 | } |
| 2260 | |
| 2261 | static IrInstruction *ir_instruction_cinclude_get_dep(IrInstructionCInclude *instruction, size_t index) { |
| 2262 | switch (index) { |
| 2263 | case 0: return instruction->name; |
| 2264 | default: return nullptr; |
| 2265 | } |
| 2266 | } |
| 2267 | |
| 2268 | static IrInstruction *ir_instruction_cdefine_get_dep(IrInstructionCDefine *instruction, size_t index) { |
| 2269 | switch (index) { |
| 2270 | case 0: return instruction->name; |
| 2271 | case 1: return instruction->value; |
| 2272 | default: return nullptr; |
| 2273 | } |
| 2274 | } |
| 2275 | |
| 2276 | static IrInstruction *ir_instruction_cundef_get_dep(IrInstructionCUndef *instruction, size_t index) { |
| 2277 | switch (index) { |
| 2278 | case 0: return instruction->name; |
| 2279 | default: return nullptr; |
| 2280 | } |
| 2281 | } |
| 2282 | |
| 2283 | static IrInstruction *ir_instruction_arraylen_get_dep(IrInstructionArrayLen *instruction, size_t index) { |
| 2284 | switch (index) { |
| 2285 | case 0: return instruction->array_value; |
| 2286 | default: return nullptr; |
| 2287 | } |
| 2288 | } |
| 2289 | |
| 2290 | static IrInstruction *ir_instruction_ref_get_dep(IrInstructionRef *instruction, size_t index) { |
| 2291 | switch (index) { |
| 2292 | case 0: return instruction->value; |
| 2293 | default: return nullptr; |
| 2294 | } |
| 2295 | } |
| 2296 | |
| 2297 | static IrInstruction *ir_instruction_minvalue_get_dep(IrInstructionMinValue *instruction, size_t index) { |
| 2298 | switch (index) { |
| 2299 | case 0: return instruction->value; |
| 2300 | default: return nullptr; |
| 2301 | } |
| 2302 | } |
| 2303 | |
| 2304 | static IrInstruction *ir_instruction_maxvalue_get_dep(IrInstructionMaxValue *instruction, size_t index) { |
| 2305 | switch (index) { |
| 2306 | case 0: return instruction->value; |
| 2307 | default: return nullptr; |
| 2308 | } |
| 2309 | } |
| 2310 | |
| 2311 | static IrInstruction *ir_instruction_compileerr_get_dep(IrInstructionCompileErr *instruction, size_t index) { |
| 2312 | switch (index) { |
| 2313 | case 0: return instruction->msg; |
| 2314 | default: return nullptr; |
| 2315 | } |
| 2316 | } |
| 2317 | |
| 2318 | static IrInstruction *ir_instruction_errname_get_dep(IrInstructionErrName *instruction, size_t index) { |
| 2319 | switch (index) { |
| 2320 | case 0: return instruction->value; |
| 2321 | default: return nullptr; |
| 2322 | } |
| 2323 | } |
| 2324 | |
| 2325 | static IrInstruction *ir_instruction_embedfile_get_dep(IrInstructionEmbedFile *instruction, size_t index) { |
| 2326 | switch (index) { |
| 2327 | case 0: return instruction->name; |
| 2328 | default: return nullptr; |
| 2329 | } |
| 2330 | } |
| 2331 | |
| 2332 | static IrInstruction *ir_instruction_cmpxchg_get_dep(IrInstructionCmpxchg *instruction, size_t index) { |
| 2333 | switch (index) { |
| 2334 | case 0: return instruction->ptr; |
| 2335 | case 1: return instruction->cmp_value; |
| 2336 | case 2: return instruction->new_value; |
| 2337 | case 3: return instruction->success_order_value; |
| 2338 | case 4: return instruction->failure_order_value; |
| 2339 | default: return nullptr; |
| 2340 | } |
| 2341 | } |
| 2342 | |
| 2343 | static IrInstruction *ir_instruction_fence_get_dep(IrInstructionFence *instruction, size_t index) { |
| 2344 | switch (index) { |
| 2345 | case 0: return instruction->order_value; |
| 2346 | default: return nullptr; |
| 2347 | } |
| 2348 | } |
| 2349 | |
| 2350 | static IrInstruction *ir_instruction_divexact_get_dep(IrInstructionDivExact *instruction, size_t index) { |
| 2351 | switch (index) { |
| 2352 | case 0: return instruction->op1; |
| 2353 | case 1: return instruction->op2; |
| 2354 | default: return nullptr; |
| 2355 | } |
| 2356 | } |
| 2357 | |
| 2358 | static IrInstruction *ir_instruction_truncate_get_dep(IrInstructionTruncate *instruction, size_t index) { |
| 2359 | switch (index) { |
| 2360 | case 0: return instruction->dest_type; |
| 2361 | case 1: return instruction->target; |
| 2362 | default: return nullptr; |
| 2363 | } |
| 2364 | } |
| 2365 | |
| 2366 | static IrInstruction *ir_instruction_inttype_get_dep(IrInstructionIntType *instruction, size_t index) { |
| 2367 | switch (index) { |
| 2368 | case 0: return instruction->is_signed; |
| 2369 | case 1: return instruction->bit_count; |
| 2370 | default: return nullptr; |
| 2371 | } |
| 2372 | } |
| 2373 | |
| 2374 | static IrInstruction *ir_instruction_boolnot_get_dep(IrInstructionBoolNot *instruction, size_t index) { |
| 2375 | switch (index) { |
| 2376 | case 0: return instruction->value; |
| 2377 | default: return nullptr; |
| 2378 | } |
| 2379 | } |
| 2380 | |
| 2381 | static IrInstruction *ir_instruction_alloca_get_dep(IrInstructionAlloca *instruction, size_t index) { |
| 2382 | switch (index) { |
| 2383 | case 0: return instruction->type_value; |
| 2384 | case 1: return instruction->count; |
| 2385 | default: return nullptr; |
| 2386 | } |
| 2387 | } |
| 2388 | |
| 2389 | static IrInstruction *ir_instruction_memset_get_dep(IrInstructionMemset *instruction, size_t index) { |
| 2390 | switch (index) { |
| 2391 | case 0: return instruction->dest_ptr; |
| 2392 | case 1: return instruction->byte; |
| 2393 | case 2: return instruction->count; |
| 2394 | default: return nullptr; |
| 2395 | } |
| 2396 | } |
| 2397 | |
| 2398 | static IrInstruction *ir_instruction_memcpy_get_dep(IrInstructionMemcpy *instruction, size_t index) { |
| 2399 | switch (index) { |
| 2400 | case 0: return instruction->dest_ptr; |
| 2401 | case 1: return instruction->src_ptr; |
| 2402 | case 2: return instruction->count; |
| 2403 | default: return nullptr; |
| 2404 | } |
| 2405 | } |
| 2406 | |
| 2407 | static IrInstruction *ir_instruction_slice_get_dep(IrInstructionSlice *instruction, size_t index) { |
| 2408 | switch (index) { |
| 2409 | case 0: return instruction->ptr; |
| 2410 | case 1: return instruction->start; |
| 2411 | case 2: return instruction->end; |
| 2412 | default: return nullptr; |
| 2413 | } |
| 2414 | } |
| 2415 | |
| 2416 | static IrInstruction *ir_instruction_membercount_get_dep(IrInstructionMemberCount *instruction, size_t index) { |
| 2417 | switch (index) { |
| 2418 | case 0: return instruction->container; |
| 2419 | default: return nullptr; |
| 2420 | } |
| 2421 | } |
| 2422 | |
| 2423 | static IrInstruction *ir_instruction_breakpoint_get_dep(IrInstructionBreakpoint *instruction, size_t index) { |
| 2424 | return nullptr; |
| 2425 | } |
| 2426 | |
| 2427 | static IrInstruction *ir_instruction_returnaddress_get_dep(IrInstructionReturnAddress *instruction, size_t index) { |
| 2428 | return nullptr; |
| 2429 | } |
| 2430 | |
| 2431 | static IrInstruction *ir_instruction_frameaddress_get_dep(IrInstructionFrameAddress *instruction, size_t index) { |
| 2432 | return nullptr; |
| 2433 | } |
| 2434 | |
| 2435 | static IrInstruction *ir_instruction_alignof_get_dep(IrInstructionAlignOf *instruction, size_t index) { |
| 2436 | switch (index) { |
| 2437 | case 0: return instruction->type_value; |
| 2438 | default: return nullptr; |
| 2439 | } |
| 2440 | } |
| 2441 | |
| 2442 | static IrInstruction *ir_instruction_overflowop_get_dep(IrInstructionOverflowOp *instruction, size_t index) { |
| 2443 | switch (index) { |
| 2444 | case 0: return instruction->type_value; |
| 2445 | case 1: return instruction->op1; |
| 2446 | case 2: return instruction->op2; |
| 2447 | case 3: return instruction->result_ptr; |
| 2448 | default: return nullptr; |
| 2449 | } |
| 2450 | } |
| 2451 | |
| 2452 | static IrInstruction *ir_instruction_testerr_get_dep(IrInstructionTestErr *instruction, size_t index) { |
| 2453 | switch (index) { |
| 2454 | case 0: return instruction->value; |
| 2455 | default: return nullptr; |
| 2456 | } |
| 2457 | } |
| 2458 | |
| 2459 | static IrInstruction *ir_instruction_unwraperrcode_get_dep(IrInstructionUnwrapErrCode *instruction, size_t index) { |
| 2460 | switch (index) { |
| 2461 | case 0: return instruction->value; |
| 2462 | default: return nullptr; |
| 2463 | } |
| 2464 | } |
| 2465 | |
| 2466 | static IrInstruction *ir_instruction_unwraperrpayload_get_dep(IrInstructionUnwrapErrPayload *instruction, |
| 2467 | size_t index) |
| 2468 | { |
| 2469 | switch (index) { |
| 2470 | case 0: return instruction->value; |
| 2471 | default: return nullptr; |
| 2472 | } |
| 2473 | } |
| 2474 | |
| 2475 | static IrInstruction *ir_instruction_errwrapcode_get_dep(IrInstructionErrWrapCode *instruction, size_t index) { |
| 2476 | switch (index) { |
| 2477 | case 0: return instruction->value; |
| 2478 | default: return nullptr; |
| 2479 | } |
| 2480 | } |
| 2481 | |
| 2482 | static IrInstruction *ir_instruction_errwrappayload_get_dep(IrInstructionErrWrapPayload *instruction, size_t index) { |
| 2483 | switch (index) { |
| 2484 | case 0: return instruction->value; |
| 2485 | default: return nullptr; |
| 2486 | } |
| 2487 | } |
| 2488 | |
| 2489 | static IrInstruction *ir_instruction_fnproto_get_dep(IrInstructionFnProto *instruction, size_t index) { |
| 2490 | if (index == 0) return instruction->return_type; |
| 2491 | size_t param_index = index - 1; |
| 2492 | if (param_index < instruction->base.source_node->data.fn_proto.params.length) { |
| 2493 | return instruction->param_types[param_index]; |
| 2494 | } |
| 2495 | return nullptr; |
| 2496 | } |
| 2497 | |
| 2498 | static IrInstruction *ir_instruction_testcomptime_get_dep(IrInstructionTestComptime *instruction, size_t index) { |
| 2499 | switch (index) { |
| 2500 | case 0: return instruction->value; |
| 2501 | default: return nullptr; |
| 2502 | } |
| 2503 | } |
| 2504 | |
| 2505 | static IrInstruction *ir_instruction_initenum_get_dep(IrInstructionInitEnum *instruction, size_t index) { |
| 2506 | switch (index) { |
| 2507 | case 0: return instruction->init_value; |
| 2508 | default: return nullptr; |
| 2509 | } |
| 2510 | } |
| 2511 | |
| 2512 | static IrInstruction *ir_instruction_pointerreinterpret_get_dep(IrInstructionPointerReinterpret *instruction, |
| 2513 | size_t index) |
| 2514 | { |
| 2515 | switch (index) { |
| 2516 | case 0: return instruction->ptr; |
| 2517 | default: return nullptr; |
| 2518 | } |
| 2519 | } |
| 2520 | |
| 2521 | static IrInstruction *ir_instruction_widenorshorten_get_dep(IrInstructionWidenOrShorten *instruction, size_t index) { |
| 2522 | switch (index) { |
| 2523 | case 0: return instruction->target; |
| 2524 | default: return nullptr; |
| 2525 | } |
| 2526 | } |
| 2527 | |
| 2528 | static IrInstruction *ir_instruction_inttoptr_get_dep(IrInstructionIntToPtr *instruction, size_t index) { |
| 2529 | switch (index) { |
| 2530 | case 0: return instruction->target; |
| 2531 | default: return nullptr; |
| 2532 | } |
| 2533 | } |
| 2534 | |
| 2535 | static IrInstruction *ir_instruction_ptrtoint_get_dep(IrInstructionPtrToInt *instruction, size_t index) { |
| 2536 | switch (index) { |
| 2537 | case 0: return instruction->target; |
| 2538 | default: return nullptr; |
| 2539 | } |
| 2540 | } |
| 2541 | |
| 2542 | static IrInstruction *ir_instruction_inttoenum_get_dep(IrInstructionIntToEnum *instruction, size_t index) { |
| 2543 | switch (index) { |
| 2544 | case 0: return instruction->target; |
| 2545 | default: return nullptr; |
| 2546 | } |
| 2547 | } |
| 2548 | |
| 2549 | static IrInstruction *ir_instruction_get_dep(IrInstruction *instruction, size_t index) { |
| 2550 | switch (instruction->id) { |
| 2551 | case IrInstructionIdInvalid: |
| 2552 | zig_unreachable(); |
| 2553 | case IrInstructionIdBr: |
| 2554 | return ir_instruction_br_get_dep((IrInstructionBr *) instruction, index); |
| 2555 | case IrInstructionIdCondBr: |
| 2556 | return ir_instruction_condbr_get_dep((IrInstructionCondBr *) instruction, index); |
| 2557 | case IrInstructionIdSwitchBr: |
| 2558 | return ir_instruction_switchbr_get_dep((IrInstructionSwitchBr *) instruction, index); |
| 2559 | case IrInstructionIdSwitchVar: |
| 2560 | return ir_instruction_switchvar_get_dep((IrInstructionSwitchVar *) instruction, index); |
| 2561 | case IrInstructionIdSwitchTarget: |
| 2562 | return ir_instruction_switchtarget_get_dep((IrInstructionSwitchTarget *) instruction, index); |
| 2563 | case IrInstructionIdPhi: |
| 2564 | return ir_instruction_phi_get_dep((IrInstructionPhi *) instruction, index); |
| 2565 | case IrInstructionIdUnOp: |
| 2566 | return ir_instruction_unop_get_dep((IrInstructionUnOp *) instruction, index); |
| 2567 | case IrInstructionIdBinOp: |
| 2568 | return ir_instruction_binop_get_dep((IrInstructionBinOp *) instruction, index); |
| 2569 | case IrInstructionIdDeclVar: |
| 2570 | return ir_instruction_declvar_get_dep((IrInstructionDeclVar *) instruction, index); |
| 2571 | case IrInstructionIdLoadPtr: |
| 2572 | return ir_instruction_loadptr_get_dep((IrInstructionLoadPtr *) instruction, index); |
| 2573 | case IrInstructionIdStorePtr: |
| 2574 | return ir_instruction_storeptr_get_dep((IrInstructionStorePtr *) instruction, index); |
| 2575 | case IrInstructionIdFieldPtr: |
| 2576 | return ir_instruction_fieldptr_get_dep((IrInstructionFieldPtr *) instruction, index); |
| 2577 | case IrInstructionIdStructFieldPtr: |
| 2578 | return ir_instruction_structfieldptr_get_dep((IrInstructionStructFieldPtr *) instruction, index); |
| 2579 | case IrInstructionIdEnumFieldPtr: |
| 2580 | return ir_instruction_enumfieldptr_get_dep((IrInstructionEnumFieldPtr *) instruction, index); |
| 2581 | case IrInstructionIdElemPtr: |
| 2582 | return ir_instruction_elemptr_get_dep((IrInstructionElemPtr *) instruction, index); |
| 2583 | case IrInstructionIdVarPtr: |
| 2584 | return ir_instruction_varptr_get_dep((IrInstructionVarPtr *) instruction, index); |
| 2585 | case IrInstructionIdCall: |
| 2586 | return ir_instruction_call_get_dep((IrInstructionCall *) instruction, index); |
| 2587 | case IrInstructionIdConst: |
| 2588 | return ir_instruction_const_get_dep((IrInstructionConst *) instruction, index); |
| 2589 | case IrInstructionIdReturn: |
| 2590 | return ir_instruction_return_get_dep((IrInstructionReturn *) instruction, index); |
| 2591 | case IrInstructionIdCast: |
| 2592 | return ir_instruction_cast_get_dep((IrInstructionCast *) instruction, index); |
| 2593 | case IrInstructionIdContainerInitList: |
| 2594 | return ir_instruction_containerinitlist_get_dep((IrInstructionContainerInitList *) instruction, index); |
| 2595 | case IrInstructionIdContainerInitFields: |
| 2596 | return ir_instruction_containerinitfields_get_dep((IrInstructionContainerInitFields *) instruction, index); |
| 2597 | case IrInstructionIdStructInit: |
| 2598 | return ir_instruction_structinit_get_dep((IrInstructionStructInit *) instruction, index); |
| 2599 | case IrInstructionIdUnreachable: |
| 2600 | return ir_instruction_unreachable_get_dep((IrInstructionUnreachable *) instruction, index); |
| 2601 | case IrInstructionIdTypeOf: |
| 2602 | return ir_instruction_typeof_get_dep((IrInstructionTypeOf *) instruction, index); |
| 2603 | case IrInstructionIdToPtrType: |
| 2604 | return ir_instruction_toptrtype_get_dep((IrInstructionToPtrType *) instruction, index); |
| 2605 | case IrInstructionIdPtrTypeChild: |
| 2606 | return ir_instruction_ptrtypechild_get_dep((IrInstructionPtrTypeChild *) instruction, index); |
| 2607 | case IrInstructionIdSetFnTest: |
| 2608 | return ir_instruction_setfntest_get_dep((IrInstructionSetFnTest *) instruction, index); |
| 2609 | case IrInstructionIdSetFnVisible: |
| 2610 | return ir_instruction_setfnvisible_get_dep((IrInstructionSetFnVisible *) instruction, index); |
| 2611 | case IrInstructionIdSetDebugSafety: |
| 2612 | return ir_instruction_setdebugsafety_get_dep((IrInstructionSetDebugSafety *) instruction, index); |
| 2613 | case IrInstructionIdArrayType: |
| 2614 | return ir_instruction_arraytype_get_dep((IrInstructionArrayType *) instruction, index); |
| 2615 | case IrInstructionIdSliceType: |
| 2616 | return ir_instruction_slicetype_get_dep((IrInstructionSliceType *) instruction, index); |
| 2617 | case IrInstructionIdAsm: |
| 2618 | return ir_instruction_asm_get_dep((IrInstructionAsm *) instruction, index); |
| 2619 | case IrInstructionIdCompileVar: |
| 2620 | return ir_instruction_compilevar_get_dep((IrInstructionCompileVar *) instruction, index); |
| 2621 | case IrInstructionIdSizeOf: |
| 2622 | return ir_instruction_sizeof_get_dep((IrInstructionSizeOf *) instruction, index); |
| 2623 | case IrInstructionIdTestNonNull: |
| 2624 | return ir_instruction_testnonnull_get_dep((IrInstructionTestNonNull *) instruction, index); |
| 2625 | case IrInstructionIdUnwrapMaybe: |
| 2626 | return ir_instruction_unwrapmaybe_get_dep((IrInstructionUnwrapMaybe *) instruction, index); |
| 2627 | case IrInstructionIdMaybeWrap: |
| 2628 | return ir_instruction_maybewrap_get_dep((IrInstructionMaybeWrap *) instruction, index); |
| 2629 | case IrInstructionIdEnumTag: |
| 2630 | return ir_instruction_enumtag_get_dep((IrInstructionEnumTag *) instruction, index); |
| 2631 | case IrInstructionIdClz: |
| 2632 | return ir_instruction_clz_get_dep((IrInstructionClz *) instruction, index); |
| 2633 | case IrInstructionIdCtz: |
| 2634 | return ir_instruction_ctz_get_dep((IrInstructionCtz *) instruction, index); |
| 2635 | case IrInstructionIdStaticEval: |
| 2636 | return ir_instruction_staticeval_get_dep((IrInstructionStaticEval *) instruction, index); |
| 2637 | case IrInstructionIdImport: |
| 2638 | return ir_instruction_import_get_dep((IrInstructionImport *) instruction, index); |
| 2639 | case IrInstructionIdCImport: |
| 2640 | return ir_instruction_cimport_get_dep((IrInstructionCImport *) instruction, index); |
| 2641 | case IrInstructionIdCInclude: |
| 2642 | return ir_instruction_cinclude_get_dep((IrInstructionCInclude *) instruction, index); |
| 2643 | case IrInstructionIdCDefine: |
| 2644 | return ir_instruction_cdefine_get_dep((IrInstructionCDefine *) instruction, index); |
| 2645 | case IrInstructionIdCUndef: |
| 2646 | return ir_instruction_cundef_get_dep((IrInstructionCUndef *) instruction, index); |
| 2647 | case IrInstructionIdArrayLen: |
| 2648 | return ir_instruction_arraylen_get_dep((IrInstructionArrayLen *) instruction, index); |
| 2649 | case IrInstructionIdRef: |
| 2650 | return ir_instruction_ref_get_dep((IrInstructionRef *) instruction, index); |
| 2651 | case IrInstructionIdMinValue: |
| 2652 | return ir_instruction_minvalue_get_dep((IrInstructionMinValue *) instruction, index); |
| 2653 | case IrInstructionIdMaxValue: |
| 2654 | return ir_instruction_maxvalue_get_dep((IrInstructionMaxValue *) instruction, index); |
| 2655 | case IrInstructionIdCompileErr: |
| 2656 | return ir_instruction_compileerr_get_dep((IrInstructionCompileErr *) instruction, index); |
| 2657 | case IrInstructionIdErrName: |
| 2658 | return ir_instruction_errname_get_dep((IrInstructionErrName *) instruction, index); |
| 2659 | case IrInstructionIdEmbedFile: |
| 2660 | return ir_instruction_embedfile_get_dep((IrInstructionEmbedFile *) instruction, index); |
| 2661 | case IrInstructionIdCmpxchg: |
| 2662 | return ir_instruction_cmpxchg_get_dep((IrInstructionCmpxchg *) instruction, index); |
| 2663 | case IrInstructionIdFence: |
| 2664 | return ir_instruction_fence_get_dep((IrInstructionFence *) instruction, index); |
| 2665 | case IrInstructionIdDivExact: |
| 2666 | return ir_instruction_divexact_get_dep((IrInstructionDivExact *) instruction, index); |
| 2667 | case IrInstructionIdTruncate: |
| 2668 | return ir_instruction_truncate_get_dep((IrInstructionTruncate *) instruction, index); |
| 2669 | case IrInstructionIdIntType: |
| 2670 | return ir_instruction_inttype_get_dep((IrInstructionIntType *) instruction, index); |
| 2671 | case IrInstructionIdBoolNot: |
| 2672 | return ir_instruction_boolnot_get_dep((IrInstructionBoolNot *) instruction, index); |
| 2673 | case IrInstructionIdAlloca: |
| 2674 | return ir_instruction_alloca_get_dep((IrInstructionAlloca *) instruction, index); |
| 2675 | case IrInstructionIdMemset: |
| 2676 | return ir_instruction_memset_get_dep((IrInstructionMemset *) instruction, index); |
| 2677 | case IrInstructionIdMemcpy: |
| 2678 | return ir_instruction_memcpy_get_dep((IrInstructionMemcpy *) instruction, index); |
| 2679 | case IrInstructionIdSlice: |
| 2680 | return ir_instruction_slice_get_dep((IrInstructionSlice *) instruction, index); |
| 2681 | case IrInstructionIdMemberCount: |
| 2682 | return ir_instruction_membercount_get_dep((IrInstructionMemberCount *) instruction, index); |
| 2683 | case IrInstructionIdBreakpoint: |
| 2684 | return ir_instruction_breakpoint_get_dep((IrInstructionBreakpoint *) instruction, index); |
| 2685 | case IrInstructionIdReturnAddress: |
| 2686 | return ir_instruction_returnaddress_get_dep((IrInstructionReturnAddress *) instruction, index); |
| 2687 | case IrInstructionIdFrameAddress: |
| 2688 | return ir_instruction_frameaddress_get_dep((IrInstructionFrameAddress *) instruction, index); |
| 2689 | case IrInstructionIdAlignOf: |
| 2690 | return ir_instruction_alignof_get_dep((IrInstructionAlignOf *) instruction, index); |
| 2691 | case IrInstructionIdOverflowOp: |
| 2692 | return ir_instruction_overflowop_get_dep((IrInstructionOverflowOp *) instruction, index); |
| 2693 | case IrInstructionIdTestErr: |
| 2694 | return ir_instruction_testerr_get_dep((IrInstructionTestErr *) instruction, index); |
| 2695 | case IrInstructionIdUnwrapErrCode: |
| 2696 | return ir_instruction_unwraperrcode_get_dep((IrInstructionUnwrapErrCode *) instruction, index); |
| 2697 | case IrInstructionIdUnwrapErrPayload: |
| 2698 | return ir_instruction_unwraperrpayload_get_dep((IrInstructionUnwrapErrPayload *) instruction, index); |
| 2699 | case IrInstructionIdErrWrapCode: |
| 2700 | return ir_instruction_errwrapcode_get_dep((IrInstructionErrWrapCode *) instruction, index); |
| 2701 | case IrInstructionIdErrWrapPayload: |
| 2702 | return ir_instruction_errwrappayload_get_dep((IrInstructionErrWrapPayload *) instruction, index); |
| 2703 | case IrInstructionIdFnProto: |
| 2704 | return ir_instruction_fnproto_get_dep((IrInstructionFnProto *) instruction, index); |
| 2705 | case IrInstructionIdTestComptime: |
| 2706 | return ir_instruction_testcomptime_get_dep((IrInstructionTestComptime *) instruction, index); |
| 2707 | case IrInstructionIdInitEnum: |
| 2708 | return ir_instruction_initenum_get_dep((IrInstructionInitEnum *) instruction, index); |
| 2709 | case IrInstructionIdPointerReinterpret: |
| 2710 | return ir_instruction_pointerreinterpret_get_dep((IrInstructionPointerReinterpret *) instruction, index); |
| 2711 | case IrInstructionIdWidenOrShorten: |
| 2712 | return ir_instruction_widenorshorten_get_dep((IrInstructionWidenOrShorten *) instruction, index); |
| 2713 | case IrInstructionIdIntToPtr: |
| 2714 | return ir_instruction_inttoptr_get_dep((IrInstructionIntToPtr *) instruction, index); |
| 2715 | case IrInstructionIdPtrToInt: |
| 2716 | return ir_instruction_ptrtoint_get_dep((IrInstructionPtrToInt *) instruction, index); |
| 2717 | case IrInstructionIdIntToEnum: |
| 2718 | return ir_instruction_inttoenum_get_dep((IrInstructionIntToEnum *) instruction, index); |
| 2719 | } |
| 2720 | zig_unreachable(); |
| 2721 | } |
| 2722 | |
| 1951 | 2723 | static void ir_count_defers(IrBuilder *irb, Scope *inner_scope, Scope *outer_scope, size_t *results) { |
| 1952 | 2724 | results[ReturnKindUnconditional] = 0; |
| 1953 | 2725 | results[ReturnKindError] = 0; |
| ... | ... | @@ -4804,23 +5576,24 @@ static bool is_u8(TypeTableEntry *type) { |
| 4804 | 5576 | } |
| 4805 | 5577 | |
| 4806 | 5578 | static IrBasicBlock *ir_get_new_bb(IrAnalyze *ira, IrBasicBlock *old_bb) { |
| 5579 | assert(old_bb); |
| 5580 | |
| 4807 | 5581 | if (old_bb->other) |
| 4808 | 5582 | return old_bb->other; |
| 4809 | 5583 | |
| 4810 | 5584 | IrBasicBlock *new_bb = ir_build_bb_from(&ira->new_irb, old_bb); |
| 4811 | 5585 | |
| 4812 | | // We are about to enqueue old_bb for analysis. Before we do so, check old_bb |
| 4813 | | // for phi instructions. Any incoming blocks in the phi instructions need to be |
| 4814 | | // queued first. |
| 5586 | // We are about to enqueue old_bb for analysis. Before we do so, look over old_bb's |
| 5587 | // instructions and make sure we have enqueued first the blocks which contain |
| 5588 | // instructions old_bb depends on. |
| 4815 | 5589 | for (size_t instr_i = 0; instr_i < old_bb->instruction_list.length; instr_i += 1) { |
| 4816 | 5590 | IrInstruction *instruction = old_bb->instruction_list.at(instr_i); |
| 4817 | | if (instruction->id != IrInstructionIdPhi) |
| 4818 | | break; |
| 4819 | | IrInstructionPhi *phi_instruction = (IrInstructionPhi *)instruction; |
| 4820 | | for (size_t incoming_i = 0; incoming_i < phi_instruction->incoming_count; incoming_i += 1) { |
| 4821 | | IrBasicBlock *predecessor = phi_instruction->incoming_blocks[incoming_i]; |
| 4822 | | IrBasicBlock *new_predecessor = ir_get_new_bb(ira, predecessor); |
| 4823 | | ir_ref_bb(new_predecessor); |
| 5591 | |
| 5592 | for (size_t dep_i = 0; ; dep_i += 1) { |
| 5593 | IrInstruction *dep_instruction = ir_instruction_get_dep(instruction, dep_i); |
| 5594 | if (dep_instruction == nullptr) |
| 5595 | break; |
| 5596 | ir_get_new_bb(ira, dep_instruction->owner_bb); |
| 4824 | 5597 | } |
| 4825 | 5598 | } |
| 4826 | 5599 | ira->old_bb_queue.append(old_bb); |
| ... | ... | @@ -4892,20 +5665,20 @@ static ConstExprValue *ir_build_const_from(IrAnalyze *ira, IrInstruction *old_in |
| 4892 | 5665 | IrInstruction *new_instruction; |
| 4893 | 5666 | if (old_instruction->id == IrInstructionIdVarPtr) { |
| 4894 | 5667 | IrInstructionVarPtr *old_var_ptr_instruction = (IrInstructionVarPtr *)old_instruction; |
| 4895 | | IrInstructionVarPtr *var_ptr_instruction = ir_create_instruction<IrInstructionVarPtr>(ira->new_irb.exec, |
| 5668 | IrInstructionVarPtr *var_ptr_instruction = ir_create_instruction<IrInstructionVarPtr>(&ira->new_irb, |
| 4896 | 5669 | old_instruction->scope, old_instruction->source_node); |
| 4897 | 5670 | var_ptr_instruction->var = old_var_ptr_instruction->var; |
| 4898 | 5671 | new_instruction = &var_ptr_instruction->base; |
| 4899 | 5672 | } else if (old_instruction->id == IrInstructionIdFieldPtr) { |
| 4900 | | IrInstructionFieldPtr *field_ptr_instruction = ir_create_instruction<IrInstructionFieldPtr>(ira->new_irb.exec, |
| 5673 | IrInstructionFieldPtr *field_ptr_instruction = ir_create_instruction<IrInstructionFieldPtr>(&ira->new_irb, |
| 4901 | 5674 | old_instruction->scope, old_instruction->source_node); |
| 4902 | 5675 | new_instruction = &field_ptr_instruction->base; |
| 4903 | 5676 | } else if (old_instruction->id == IrInstructionIdElemPtr) { |
| 4904 | | IrInstructionElemPtr *elem_ptr_instruction = ir_create_instruction<IrInstructionElemPtr>(ira->new_irb.exec, |
| 5677 | IrInstructionElemPtr *elem_ptr_instruction = ir_create_instruction<IrInstructionElemPtr>(&ira->new_irb, |
| 4905 | 5678 | old_instruction->scope, old_instruction->source_node); |
| 4906 | 5679 | new_instruction = &elem_ptr_instruction->base; |
| 4907 | 5680 | } else { |
| 4908 | | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(ira->new_irb.exec, |
| 5681 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 4909 | 5682 | old_instruction->scope, old_instruction->source_node); |
| 4910 | 5683 | new_instruction = &const_instruction->base; |
| 4911 | 5684 | } |
| ... | ... | @@ -5079,7 +5852,7 @@ static IrInstruction *ir_analyze_maybe_wrap(IrAnalyze *ira, IrInstruction *sourc |
| 5079 | 5852 | if (!val) |
| 5080 | 5853 | return ira->codegen->invalid_instruction; |
| 5081 | 5854 | |
| 5082 | | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(ira->new_irb.exec, |
| 5855 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 5083 | 5856 | source_instr->scope, source_instr->source_node); |
| 5084 | 5857 | const_instruction->base.value.type = wanted_type; |
| 5085 | 5858 | const_instruction->base.value.special = ConstValSpecialStatic; |
| ... | ... | @@ -5110,7 +5883,7 @@ static IrInstruction *ir_analyze_pointer_reinterpret(IrAnalyze *ira, IrInstructi |
| 5110 | 5883 | if (!val) |
| 5111 | 5884 | return ira->codegen->invalid_instruction; |
| 5112 | 5885 | |
| 5113 | | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(ira->new_irb.exec, |
| 5886 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 5114 | 5887 | source_instr->scope, source_instr->source_node); |
| 5115 | 5888 | const_instruction->base.value = *val; |
| 5116 | 5889 | const_instruction->base.value.type = wanted_type; |
| ... | ... | @@ -5138,7 +5911,7 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction |
| 5138 | 5911 | if (!val) |
| 5139 | 5912 | return ira->codegen->invalid_instruction; |
| 5140 | 5913 | |
| 5141 | | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(ira->new_irb.exec, |
| 5914 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 5142 | 5915 | source_instr->scope, source_instr->source_node); |
| 5143 | 5916 | const_instruction->base.value.type = wanted_type; |
| 5144 | 5917 | const_instruction->base.value.special = ConstValSpecialStatic; |
| ... | ... | @@ -5163,7 +5936,7 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so |
| 5163 | 5936 | if (!val) |
| 5164 | 5937 | return ira->codegen->invalid_instruction; |
| 5165 | 5938 | |
| 5166 | | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(ira->new_irb.exec, |
| 5939 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 5167 | 5940 | source_instr->scope, source_instr->source_node); |
| 5168 | 5941 | const_instruction->base.value.type = wanted_type; |
| 5169 | 5942 | const_instruction->base.value.special = ConstValSpecialStatic; |
| ... | ... | @@ -5186,7 +5959,7 @@ static IrInstruction *ir_analyze_cast_ref(IrAnalyze *ira, IrInstruction *source_ |
| 5186 | 5959 | if (!val) |
| 5187 | 5960 | return ira->codegen->invalid_instruction; |
| 5188 | 5961 | |
| 5189 | | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(ira->new_irb.exec, |
| 5962 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 5190 | 5963 | source_instr->scope, source_instr->source_node); |
| 5191 | 5964 | const_instruction->base.value.type = wanted_type; |
| 5192 | 5965 | const_instruction->base.value.special = ConstValSpecialStatic; |
| ... | ... | @@ -5220,7 +5993,7 @@ static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *so |
| 5220 | 5993 | ConstExprValue *val = ir_resolve_const(ira, value, UndefBad); |
| 5221 | 5994 | assert(val); |
| 5222 | 5995 | |
| 5223 | | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(ira->new_irb.exec, source_instr->scope, source_instr->source_node); |
| 5996 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| 5224 | 5997 | const_instruction->base.value.type = wanted_type; |
| 5225 | 5998 | const_instruction->base.value.special = ConstValSpecialStatic; |
| 5226 | 5999 | const_instruction->base.value.depends_on_compile_var = val->depends_on_compile_var; |
| ... | ... | @@ -8309,7 +9082,7 @@ static IrInstruction *ir_analyze_enum_tag(IrAnalyze *ira, IrInstruction *source_ |
| 8309 | 9082 | if (!val) |
| 8310 | 9083 | return ira->codegen->invalid_instruction; |
| 8311 | 9084 | |
| 8312 | | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(ira->new_irb.exec, |
| 9085 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, |
| 8313 | 9086 | source_instr->scope, source_instr->source_node); |
| 8314 | 9087 | const_instruction->base.value.type = value->value.type->data.enumeration.tag_type; |
| 8315 | 9088 | const_instruction->base.value.special = ConstValSpecialStatic; |