| ... | @@ -17,27 +17,33 @@ | ... | @@ -17,27 +17,33 @@ |
| 17 | | 17 | |
| 18 | #include <errno.h> | 18 | #include <errno.h> |
| 19 | | 19 | |
| 20 | struct IrBuilder { | 20 | struct IrBuilderSrc { |
| 21 | CodeGen *codegen; | 21 | CodeGen *codegen; |
| 22 | IrExecutable *exec; | 22 | IrExecutableSrc *exec; |
| 23 | IrBasicBlock *current_basic_block; | 23 | IrBasicBlockSrc *current_basic_block; |
| 24 | AstNode *main_block_node; | 24 | AstNode *main_block_node; |
| 25 | }; | 25 | }; |
| 26 | | 26 | |
| | 27 | struct IrBuilderGen { |
| | 28 | CodeGen *codegen; |
| | 29 | IrExecutableGen *exec; |
| | 30 | IrBasicBlockGen *current_basic_block; |
| | 31 | }; |
| | 32 | |
| 27 | struct IrAnalyze { | 33 | struct IrAnalyze { |
| 28 | CodeGen *codegen; | 34 | CodeGen *codegen; |
| 29 | IrBuilder old_irb; | 35 | IrBuilderSrc old_irb; |
| 30 | IrBuilder new_irb; | 36 | IrBuilderGen new_irb; |
| 31 | size_t old_bb_index; | 37 | size_t old_bb_index; |
| 32 | size_t instruction_index; | 38 | size_t instruction_index; |
| 33 | ZigType *explicit_return_type; | 39 | ZigType *explicit_return_type; |
| 34 | AstNode *explicit_return_type_source_node; | 40 | AstNode *explicit_return_type_source_node; |
| 35 | ZigList<IrInstruction *> src_implicit_return_type_list; | 41 | ZigList<IrInstGen *> src_implicit_return_type_list; |
| 36 | ZigList<IrSuspendPosition> resume_stack; | 42 | ZigList<IrSuspendPosition> resume_stack; |
| 37 | IrBasicBlock *const_predecessor_bb; | 43 | IrBasicBlockSrc *const_predecessor_bb; |
| 38 | size_t ref_count; | 44 | size_t ref_count; |
| 39 | size_t break_debug_id; // for debugging purposes | 45 | size_t break_debug_id; // for debugging purposes |
| 40 | IrInstruction *return_ptr; | 46 | IrInstGen *return_ptr; |
| 41 | | 47 | |
| 42 | // For the purpose of using in a debugger | 48 | // For the purpose of using in a debugger |
| 43 | void dump(); | 49 | void dump(); |
| ... | @@ -202,412 +208,537 @@ struct DbgIrBreakPoint { | ... | @@ -202,412 +208,537 @@ struct DbgIrBreakPoint { |
| 202 | DbgIrBreakPoint dbg_ir_breakpoints_buf[20]; | 208 | DbgIrBreakPoint dbg_ir_breakpoints_buf[20]; |
| 203 | size_t dbg_ir_breakpoints_count = 0; | 209 | size_t dbg_ir_breakpoints_count = 0; |
| 204 | | 210 | |
| 205 | static IrInstruction *ir_gen_node(IrBuilder *irb, AstNode *node, Scope *scope); | 211 | static IrInstSrc *ir_gen_node(IrBuilderSrc *irb, AstNode *node, Scope *scope); |
| 206 | static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *scope, LVal lval, | 212 | static IrInstSrc *ir_gen_node_extra(IrBuilderSrc *irb, AstNode *node, Scope *scope, LVal lval, |
| 207 | ResultLoc *result_loc); | 213 | ResultLoc *result_loc); |
| 208 | static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, ZigType *expected_type); | 214 | static IrInstGen *ir_implicit_cast(IrAnalyze *ira, IrInstGen *value, ZigType *expected_type); |
| 209 | static IrInstruction *ir_implicit_cast2(IrAnalyze *ira, IrInstruction *value_source_instr, | 215 | static IrInstGen *ir_implicit_cast2(IrAnalyze *ira, IrInst *value_source_instr, |
| 210 | IrInstruction *value, ZigType *expected_type); | 216 | IrInstGen *value, ZigType *expected_type); |
| 211 | static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr, | 217 | static IrInstGen *ir_get_deref(IrAnalyze *ira, IrInst *source_instr, IrInstGen *ptr, |
| 212 | ResultLoc *result_loc); | 218 | ResultLoc *result_loc); |
| 213 | static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, Buf *msg); | 219 | static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutableSrc *exec, AstNode *source_node, Buf *msg); |
| 214 | static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name, | 220 | static IrInstGen *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name, |
| 215 | IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type, bool initializing); | 221 | IrInst* source_instr, IrInstGen *container_ptr, ZigType *container_type, bool initializing); |
| 216 | static void ir_assert(bool ok, IrInstruction *source_instruction); | 222 | static void ir_assert(bool ok, IrInst* source_instruction); |
| 217 | static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, ZigVar *var); | 223 | static void ir_assert_gen(bool ok, IrInstGen *source_instruction); |
| 218 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op); | 224 | static IrInstGen *ir_get_var_ptr(IrAnalyze *ira, IrInst *source_instr, ZigVar *var); |
| 219 | static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction *value, LVal lval, ResultLoc *result_loc); | 225 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstGen *op); |
| 220 | static IrInstruction *ir_expr_wrap(IrBuilder *irb, Scope *scope, IrInstruction *inst, ResultLoc *result_loc); | 226 | static IrInstSrc *ir_lval_wrap(IrBuilderSrc *irb, Scope *scope, IrInstSrc *value, LVal lval, ResultLoc *result_loc); |
| | 227 | static IrInstSrc *ir_expr_wrap(IrBuilderSrc *irb, Scope *scope, IrInstSrc *inst, ResultLoc *result_loc); |
| 221 | static ZigType *adjust_ptr_align(CodeGen *g, ZigType *ptr_type, uint32_t new_align); | 228 | static ZigType *adjust_ptr_align(CodeGen *g, ZigType *ptr_type, uint32_t new_align); |
| 222 | static ZigType *adjust_slice_align(CodeGen *g, ZigType *slice_type, uint32_t new_align); | 229 | static ZigType *adjust_slice_align(CodeGen *g, ZigType *slice_type, uint32_t new_align); |
| 223 | static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, ZigValue *val); | 230 | static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, ZigValue *val); |
| 224 | static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ZigValue *val); | 231 | static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ZigValue *val); |
| 225 | static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, | 232 | static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, |
| 226 | ZigValue *out_val, ZigValue *ptr_val); | 233 | ZigValue *out_val, ZigValue *ptr_val); |
| 227 | static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *ptr, | 234 | static IrInstGen *ir_analyze_ptr_cast(IrAnalyze *ira, IrInst* source_instr, IrInstGen *ptr, |
| 228 | ZigType *dest_type, IrInstruction *dest_type_src, bool safety_check_on); | 235 | ZigType *dest_type, IrInst *dest_type_src, bool safety_check_on); |
| 229 | static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed); | 236 | static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstGen *value, UndefAllowed undef_allowed); |
| 230 | static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_align); | 237 | static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_align); |
| 231 | static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, | 238 | static IrInstGen *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInst* source_instr, IrInstGen *target, |
| 232 | ZigType *ptr_type); | 239 | ZigType *ptr_type); |
| 233 | static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 240 | static IrInstGen *ir_analyze_bit_cast(IrAnalyze *ira, IrInst* source_instr, IrInstGen *value, |
| 234 | ZigType *dest_type); | 241 | ZigType *dest_type); |
| 235 | static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspend_source_instr, | 242 | static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInst *suspend_source_instr, |
| 236 | ResultLoc *result_loc, ZigType *value_type, IrInstruction *value, bool force_runtime, | 243 | ResultLoc *result_loc, ZigType *value_type, IrInstGen *value, bool force_runtime, bool allow_discard); |
| 237 | bool allow_discard); | 244 | static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr, |
| 238 | static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_source_instr, | 245 | ResultLoc *result_loc, ZigType *value_type, IrInstGen *value, bool force_runtime, bool allow_discard); |
| 239 | ResultLoc *result_loc, ZigType *value_type, IrInstruction *value, bool force_runtime, | 246 | static IrInstGen *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInst* source_instr, |
| 240 | bool allow_discard); | 247 | IrInstGen *base_ptr, bool safety_check_on, bool initializing); |
| 241 | static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstruction *source_instr, | 248 | static IrInstGen *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInst* source_instr, |
| 242 | IrInstruction *base_ptr, bool safety_check_on, bool initializing); | 249 | IrInstGen *base_ptr, bool safety_check_on, bool initializing); |
| 243 | static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruction *source_instr, | 250 | static IrInstGen *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInst* source_instr, |
| 244 | IrInstruction *base_ptr, bool safety_check_on, bool initializing); | 251 | IrInstGen *base_ptr, bool initializing); |
| 245 | static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction *source_instr, | 252 | static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, IrInst* source_instr, |
| 246 | IrInstruction *base_ptr, bool initializing); | 253 | IrInstGen *ptr, IrInstGen *uncasted_value, bool allow_write_through_const); |
| 247 | static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source_instr, | 254 | static IrInstSrc *ir_gen_union_init_expr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 248 | IrInstruction *ptr, IrInstruction *uncasted_value, bool allow_write_through_const); | 255 | IrInstSrc *union_type, IrInstSrc *field_name, AstNode *expr_node, |
| 249 | static IrInstruction *ir_gen_union_init_expr(IrBuilder *irb, Scope *scope, AstNode *source_node, | | |
| 250 | IrInstruction *union_type, IrInstruction *field_name, AstNode *expr_node, | | |
| 251 | LVal lval, ResultLoc *parent_result_loc); | 256 | LVal lval, ResultLoc *parent_result_loc); |
| 252 | static void ir_reset_result(ResultLoc *result_loc); | 257 | static void ir_reset_result(ResultLoc *result_loc); |
| 253 | static Buf *get_anon_type_name(CodeGen *codegen, IrExecutable *exec, const char *kind_name, | 258 | static Buf *get_anon_type_name(CodeGen *codegen, IrExecutableSrc *exec, const char *kind_name, |
| 254 | Scope *scope, AstNode *source_node, Buf *out_bare_name); | 259 | Scope *scope, AstNode *source_node, Buf *out_bare_name); |
| 255 | static ResultLocCast *ir_build_cast_result_loc(IrBuilder *irb, IrInstruction *dest_type, | 260 | static ResultLocCast *ir_build_cast_result_loc(IrBuilderSrc *irb, IrInstSrc *dest_type, |
| 256 | ResultLoc *parent_result_loc); | 261 | ResultLoc *parent_result_loc); |
| 257 | static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction *source_instr, | 262 | static IrInstGen *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInst* source_instr, |
| 258 | TypeStructField *field, IrInstruction *struct_ptr, ZigType *struct_type, bool initializing); | 263 | TypeStructField *field, IrInstGen *struct_ptr, ZigType *struct_type, bool initializing); |
| 259 | static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, | 264 | static IrInstGen *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, |
| 260 | IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type); | 265 | IrInst* source_instr, IrInstGen *container_ptr, ZigType *container_type); |
| 261 | static ResultLoc *no_result_loc(void); | 266 | static ResultLoc *no_result_loc(void); |
| 262 | static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *source_inst, IrInstruction *value); | 267 | static IrInstGen *ir_analyze_test_non_null(IrAnalyze *ira, IrInst *source_inst, IrInstGen *value); |
| | 268 | static IrInstGen *ir_error_dependency_loop(IrAnalyze *ira, IrInst *source_instr); |
| | 269 | |
| | 270 | static void destroy_instruction_src(IrInstSrc *inst) { |
| | 271 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| | 272 | const char *name = ir_inst_src_type_str(inst->id); |
| | 273 | #else |
| | 274 | const char *name = nullptr; |
| | 275 | #endif |
| | 276 | switch (inst->id) { |
| | 277 | case IrInstSrcIdInvalid: |
| | 278 | zig_unreachable(); |
| | 279 | case IrInstSrcIdReturn: |
| | 280 | return destroy(reinterpret_cast<IrInstSrcReturn *>(inst), name); |
| | 281 | case IrInstSrcIdConst: |
| | 282 | return destroy(reinterpret_cast<IrInstSrcConst *>(inst), name); |
| | 283 | case IrInstSrcIdBinOp: |
| | 284 | return destroy(reinterpret_cast<IrInstSrcBinOp *>(inst), name); |
| | 285 | case IrInstSrcIdMergeErrSets: |
| | 286 | return destroy(reinterpret_cast<IrInstSrcMergeErrSets *>(inst), name); |
| | 287 | case IrInstSrcIdDeclVar: |
| | 288 | return destroy(reinterpret_cast<IrInstSrcDeclVar *>(inst), name); |
| | 289 | case IrInstSrcIdCall: |
| | 290 | return destroy(reinterpret_cast<IrInstSrcCall *>(inst), name); |
| | 291 | case IrInstSrcIdCallExtra: |
| | 292 | return destroy(reinterpret_cast<IrInstSrcCallExtra *>(inst), name); |
| | 293 | case IrInstSrcIdUnOp: |
| | 294 | return destroy(reinterpret_cast<IrInstSrcUnOp *>(inst), name); |
| | 295 | case IrInstSrcIdCondBr: |
| | 296 | return destroy(reinterpret_cast<IrInstSrcCondBr *>(inst), name); |
| | 297 | case IrInstSrcIdBr: |
| | 298 | return destroy(reinterpret_cast<IrInstSrcBr *>(inst), name); |
| | 299 | case IrInstSrcIdPhi: |
| | 300 | return destroy(reinterpret_cast<IrInstSrcPhi *>(inst), name); |
| | 301 | case IrInstSrcIdContainerInitList: |
| | 302 | return destroy(reinterpret_cast<IrInstSrcContainerInitList *>(inst), name); |
| | 303 | case IrInstSrcIdContainerInitFields: |
| | 304 | return destroy(reinterpret_cast<IrInstSrcContainerInitFields *>(inst), name); |
| | 305 | case IrInstSrcIdUnreachable: |
| | 306 | return destroy(reinterpret_cast<IrInstSrcUnreachable *>(inst), name); |
| | 307 | case IrInstSrcIdElemPtr: |
| | 308 | return destroy(reinterpret_cast<IrInstSrcElemPtr *>(inst), name); |
| | 309 | case IrInstSrcIdVarPtr: |
| | 310 | return destroy(reinterpret_cast<IrInstSrcVarPtr *>(inst), name); |
| | 311 | case IrInstSrcIdLoadPtr: |
| | 312 | return destroy(reinterpret_cast<IrInstSrcLoadPtr *>(inst), name); |
| | 313 | case IrInstSrcIdStorePtr: |
| | 314 | return destroy(reinterpret_cast<IrInstSrcStorePtr *>(inst), name); |
| | 315 | case IrInstSrcIdTypeOf: |
| | 316 | return destroy(reinterpret_cast<IrInstSrcTypeOf *>(inst), name); |
| | 317 | case IrInstSrcIdFieldPtr: |
| | 318 | return destroy(reinterpret_cast<IrInstSrcFieldPtr *>(inst), name); |
| | 319 | case IrInstSrcIdSetCold: |
| | 320 | return destroy(reinterpret_cast<IrInstSrcSetCold *>(inst), name); |
| | 321 | case IrInstSrcIdSetRuntimeSafety: |
| | 322 | return destroy(reinterpret_cast<IrInstSrcSetRuntimeSafety *>(inst), name); |
| | 323 | case IrInstSrcIdSetFloatMode: |
| | 324 | return destroy(reinterpret_cast<IrInstSrcSetFloatMode *>(inst), name); |
| | 325 | case IrInstSrcIdArrayType: |
| | 326 | return destroy(reinterpret_cast<IrInstSrcArrayType *>(inst), name); |
| | 327 | case IrInstSrcIdSliceType: |
| | 328 | return destroy(reinterpret_cast<IrInstSrcSliceType *>(inst), name); |
| | 329 | case IrInstSrcIdAnyFrameType: |
| | 330 | return destroy(reinterpret_cast<IrInstSrcAnyFrameType *>(inst), name); |
| | 331 | case IrInstSrcIdAsm: |
| | 332 | return destroy(reinterpret_cast<IrInstSrcAsm *>(inst), name); |
| | 333 | case IrInstSrcIdSizeOf: |
| | 334 | return destroy(reinterpret_cast<IrInstSrcSizeOf *>(inst), name); |
| | 335 | case IrInstSrcIdTestNonNull: |
| | 336 | return destroy(reinterpret_cast<IrInstSrcTestNonNull *>(inst), name); |
| | 337 | case IrInstSrcIdOptionalUnwrapPtr: |
| | 338 | return destroy(reinterpret_cast<IrInstSrcOptionalUnwrapPtr *>(inst), name); |
| | 339 | case IrInstSrcIdPopCount: |
| | 340 | return destroy(reinterpret_cast<IrInstSrcPopCount *>(inst), name); |
| | 341 | case IrInstSrcIdClz: |
| | 342 | return destroy(reinterpret_cast<IrInstSrcClz *>(inst), name); |
| | 343 | case IrInstSrcIdCtz: |
| | 344 | return destroy(reinterpret_cast<IrInstSrcCtz *>(inst), name); |
| | 345 | case IrInstSrcIdBswap: |
| | 346 | return destroy(reinterpret_cast<IrInstSrcBswap *>(inst), name); |
| | 347 | case IrInstSrcIdBitReverse: |
| | 348 | return destroy(reinterpret_cast<IrInstSrcBitReverse *>(inst), name); |
| | 349 | case IrInstSrcIdSwitchBr: |
| | 350 | return destroy(reinterpret_cast<IrInstSrcSwitchBr *>(inst), name); |
| | 351 | case IrInstSrcIdSwitchVar: |
| | 352 | return destroy(reinterpret_cast<IrInstSrcSwitchVar *>(inst), name); |
| | 353 | case IrInstSrcIdSwitchElseVar: |
| | 354 | return destroy(reinterpret_cast<IrInstSrcSwitchElseVar *>(inst), name); |
| | 355 | case IrInstSrcIdSwitchTarget: |
| | 356 | return destroy(reinterpret_cast<IrInstSrcSwitchTarget *>(inst), name); |
| | 357 | case IrInstSrcIdImport: |
| | 358 | return destroy(reinterpret_cast<IrInstSrcImport *>(inst), name); |
| | 359 | case IrInstSrcIdRef: |
| | 360 | return destroy(reinterpret_cast<IrInstSrcRef *>(inst), name); |
| | 361 | case IrInstSrcIdCompileErr: |
| | 362 | return destroy(reinterpret_cast<IrInstSrcCompileErr *>(inst), name); |
| | 363 | case IrInstSrcIdCompileLog: |
| | 364 | return destroy(reinterpret_cast<IrInstSrcCompileLog *>(inst), name); |
| | 365 | case IrInstSrcIdErrName: |
| | 366 | return destroy(reinterpret_cast<IrInstSrcErrName *>(inst), name); |
| | 367 | case IrInstSrcIdCImport: |
| | 368 | return destroy(reinterpret_cast<IrInstSrcCImport *>(inst), name); |
| | 369 | case IrInstSrcIdCInclude: |
| | 370 | return destroy(reinterpret_cast<IrInstSrcCInclude *>(inst), name); |
| | 371 | case IrInstSrcIdCDefine: |
| | 372 | return destroy(reinterpret_cast<IrInstSrcCDefine *>(inst), name); |
| | 373 | case IrInstSrcIdCUndef: |
| | 374 | return destroy(reinterpret_cast<IrInstSrcCUndef *>(inst), name); |
| | 375 | case IrInstSrcIdEmbedFile: |
| | 376 | return destroy(reinterpret_cast<IrInstSrcEmbedFile *>(inst), name); |
| | 377 | case IrInstSrcIdCmpxchg: |
| | 378 | return destroy(reinterpret_cast<IrInstSrcCmpxchg *>(inst), name); |
| | 379 | case IrInstSrcIdFence: |
| | 380 | return destroy(reinterpret_cast<IrInstSrcFence *>(inst), name); |
| | 381 | case IrInstSrcIdTruncate: |
| | 382 | return destroy(reinterpret_cast<IrInstSrcTruncate *>(inst), name); |
| | 383 | case IrInstSrcIdIntCast: |
| | 384 | return destroy(reinterpret_cast<IrInstSrcIntCast *>(inst), name); |
| | 385 | case IrInstSrcIdFloatCast: |
| | 386 | return destroy(reinterpret_cast<IrInstSrcFloatCast *>(inst), name); |
| | 387 | case IrInstSrcIdErrSetCast: |
| | 388 | return destroy(reinterpret_cast<IrInstSrcErrSetCast *>(inst), name); |
| | 389 | case IrInstSrcIdFromBytes: |
| | 390 | return destroy(reinterpret_cast<IrInstSrcFromBytes *>(inst), name); |
| | 391 | case IrInstSrcIdToBytes: |
| | 392 | return destroy(reinterpret_cast<IrInstSrcToBytes *>(inst), name); |
| | 393 | case IrInstSrcIdIntToFloat: |
| | 394 | return destroy(reinterpret_cast<IrInstSrcIntToFloat *>(inst), name); |
| | 395 | case IrInstSrcIdFloatToInt: |
| | 396 | return destroy(reinterpret_cast<IrInstSrcFloatToInt *>(inst), name); |
| | 397 | case IrInstSrcIdBoolToInt: |
| | 398 | return destroy(reinterpret_cast<IrInstSrcBoolToInt *>(inst), name); |
| | 399 | case IrInstSrcIdIntType: |
| | 400 | return destroy(reinterpret_cast<IrInstSrcIntType *>(inst), name); |
| | 401 | case IrInstSrcIdVectorType: |
| | 402 | return destroy(reinterpret_cast<IrInstSrcVectorType *>(inst), name); |
| | 403 | case IrInstSrcIdShuffleVector: |
| | 404 | return destroy(reinterpret_cast<IrInstSrcShuffleVector *>(inst), name); |
| | 405 | case IrInstSrcIdSplat: |
| | 406 | return destroy(reinterpret_cast<IrInstSrcSplat *>(inst), name); |
| | 407 | case IrInstSrcIdBoolNot: |
| | 408 | return destroy(reinterpret_cast<IrInstSrcBoolNot *>(inst), name); |
| | 409 | case IrInstSrcIdMemset: |
| | 410 | return destroy(reinterpret_cast<IrInstSrcMemset *>(inst), name); |
| | 411 | case IrInstSrcIdMemcpy: |
| | 412 | return destroy(reinterpret_cast<IrInstSrcMemcpy *>(inst), name); |
| | 413 | case IrInstSrcIdSlice: |
| | 414 | return destroy(reinterpret_cast<IrInstSrcSlice *>(inst), name); |
| | 415 | case IrInstSrcIdMemberCount: |
| | 416 | return destroy(reinterpret_cast<IrInstSrcMemberCount *>(inst), name); |
| | 417 | case IrInstSrcIdMemberType: |
| | 418 | return destroy(reinterpret_cast<IrInstSrcMemberType *>(inst), name); |
| | 419 | case IrInstSrcIdMemberName: |
| | 420 | return destroy(reinterpret_cast<IrInstSrcMemberName *>(inst), name); |
| | 421 | case IrInstSrcIdBreakpoint: |
| | 422 | return destroy(reinterpret_cast<IrInstSrcBreakpoint *>(inst), name); |
| | 423 | case IrInstSrcIdReturnAddress: |
| | 424 | return destroy(reinterpret_cast<IrInstSrcReturnAddress *>(inst), name); |
| | 425 | case IrInstSrcIdFrameAddress: |
| | 426 | return destroy(reinterpret_cast<IrInstSrcFrameAddress *>(inst), name); |
| | 427 | case IrInstSrcIdFrameHandle: |
| | 428 | return destroy(reinterpret_cast<IrInstSrcFrameHandle *>(inst), name); |
| | 429 | case IrInstSrcIdFrameType: |
| | 430 | return destroy(reinterpret_cast<IrInstSrcFrameType *>(inst), name); |
| | 431 | case IrInstSrcIdFrameSize: |
| | 432 | return destroy(reinterpret_cast<IrInstSrcFrameSize *>(inst), name); |
| | 433 | case IrInstSrcIdAlignOf: |
| | 434 | return destroy(reinterpret_cast<IrInstSrcAlignOf *>(inst), name); |
| | 435 | case IrInstSrcIdOverflowOp: |
| | 436 | return destroy(reinterpret_cast<IrInstSrcOverflowOp *>(inst), name); |
| | 437 | case IrInstSrcIdTestErr: |
| | 438 | return destroy(reinterpret_cast<IrInstSrcTestErr *>(inst), name); |
| | 439 | case IrInstSrcIdUnwrapErrCode: |
| | 440 | return destroy(reinterpret_cast<IrInstSrcUnwrapErrCode *>(inst), name); |
| | 441 | case IrInstSrcIdUnwrapErrPayload: |
| | 442 | return destroy(reinterpret_cast<IrInstSrcUnwrapErrPayload *>(inst), name); |
| | 443 | case IrInstSrcIdFnProto: |
| | 444 | return destroy(reinterpret_cast<IrInstSrcFnProto *>(inst), name); |
| | 445 | case IrInstSrcIdTestComptime: |
| | 446 | return destroy(reinterpret_cast<IrInstSrcTestComptime *>(inst), name); |
| | 447 | case IrInstSrcIdPtrCast: |
| | 448 | return destroy(reinterpret_cast<IrInstSrcPtrCast *>(inst), name); |
| | 449 | case IrInstSrcIdBitCast: |
| | 450 | return destroy(reinterpret_cast<IrInstSrcBitCast *>(inst), name); |
| | 451 | case IrInstSrcIdPtrToInt: |
| | 452 | return destroy(reinterpret_cast<IrInstSrcPtrToInt *>(inst), name); |
| | 453 | case IrInstSrcIdIntToPtr: |
| | 454 | return destroy(reinterpret_cast<IrInstSrcIntToPtr *>(inst), name); |
| | 455 | case IrInstSrcIdIntToEnum: |
| | 456 | return destroy(reinterpret_cast<IrInstSrcIntToEnum *>(inst), name); |
| | 457 | case IrInstSrcIdIntToErr: |
| | 458 | return destroy(reinterpret_cast<IrInstSrcIntToErr *>(inst), name); |
| | 459 | case IrInstSrcIdErrToInt: |
| | 460 | return destroy(reinterpret_cast<IrInstSrcErrToInt *>(inst), name); |
| | 461 | case IrInstSrcIdCheckSwitchProngs: |
| | 462 | return destroy(reinterpret_cast<IrInstSrcCheckSwitchProngs *>(inst), name); |
| | 463 | case IrInstSrcIdCheckStatementIsVoid: |
| | 464 | return destroy(reinterpret_cast<IrInstSrcCheckStatementIsVoid *>(inst), name); |
| | 465 | case IrInstSrcIdTypeName: |
| | 466 | return destroy(reinterpret_cast<IrInstSrcTypeName *>(inst), name); |
| | 467 | case IrInstSrcIdTagName: |
| | 468 | return destroy(reinterpret_cast<IrInstSrcTagName *>(inst), name); |
| | 469 | case IrInstSrcIdPtrType: |
| | 470 | return destroy(reinterpret_cast<IrInstSrcPtrType *>(inst), name); |
| | 471 | case IrInstSrcIdDeclRef: |
| | 472 | return destroy(reinterpret_cast<IrInstSrcDeclRef *>(inst), name); |
| | 473 | case IrInstSrcIdPanic: |
| | 474 | return destroy(reinterpret_cast<IrInstSrcPanic *>(inst), name); |
| | 475 | case IrInstSrcIdFieldParentPtr: |
| | 476 | return destroy(reinterpret_cast<IrInstSrcFieldParentPtr *>(inst), name); |
| | 477 | case IrInstSrcIdByteOffsetOf: |
| | 478 | return destroy(reinterpret_cast<IrInstSrcByteOffsetOf *>(inst), name); |
| | 479 | case IrInstSrcIdBitOffsetOf: |
| | 480 | return destroy(reinterpret_cast<IrInstSrcBitOffsetOf *>(inst), name); |
| | 481 | case IrInstSrcIdTypeInfo: |
| | 482 | return destroy(reinterpret_cast<IrInstSrcTypeInfo *>(inst), name); |
| | 483 | case IrInstSrcIdType: |
| | 484 | return destroy(reinterpret_cast<IrInstSrcType *>(inst), name); |
| | 485 | case IrInstSrcIdHasField: |
| | 486 | return destroy(reinterpret_cast<IrInstSrcHasField *>(inst), name); |
| | 487 | case IrInstSrcIdTypeId: |
| | 488 | return destroy(reinterpret_cast<IrInstSrcTypeId *>(inst), name); |
| | 489 | case IrInstSrcIdSetEvalBranchQuota: |
| | 490 | return destroy(reinterpret_cast<IrInstSrcSetEvalBranchQuota *>(inst), name); |
| | 491 | case IrInstSrcIdAlignCast: |
| | 492 | return destroy(reinterpret_cast<IrInstSrcAlignCast *>(inst), name); |
| | 493 | case IrInstSrcIdImplicitCast: |
| | 494 | return destroy(reinterpret_cast<IrInstSrcImplicitCast *>(inst), name); |
| | 495 | case IrInstSrcIdResolveResult: |
| | 496 | return destroy(reinterpret_cast<IrInstSrcResolveResult *>(inst), name); |
| | 497 | case IrInstSrcIdResetResult: |
| | 498 | return destroy(reinterpret_cast<IrInstSrcResetResult *>(inst), name); |
| | 499 | case IrInstSrcIdOpaqueType: |
| | 500 | return destroy(reinterpret_cast<IrInstSrcOpaqueType *>(inst), name); |
| | 501 | case IrInstSrcIdSetAlignStack: |
| | 502 | return destroy(reinterpret_cast<IrInstSrcSetAlignStack *>(inst), name); |
| | 503 | case IrInstSrcIdArgType: |
| | 504 | return destroy(reinterpret_cast<IrInstSrcArgType *>(inst), name); |
| | 505 | case IrInstSrcIdTagType: |
| | 506 | return destroy(reinterpret_cast<IrInstSrcTagType *>(inst), name); |
| | 507 | case IrInstSrcIdExport: |
| | 508 | return destroy(reinterpret_cast<IrInstSrcExport *>(inst), name); |
| | 509 | case IrInstSrcIdErrorReturnTrace: |
| | 510 | return destroy(reinterpret_cast<IrInstSrcErrorReturnTrace *>(inst), name); |
| | 511 | case IrInstSrcIdErrorUnion: |
| | 512 | return destroy(reinterpret_cast<IrInstSrcErrorUnion *>(inst), name); |
| | 513 | case IrInstSrcIdAtomicRmw: |
| | 514 | return destroy(reinterpret_cast<IrInstSrcAtomicRmw *>(inst), name); |
| | 515 | case IrInstSrcIdSaveErrRetAddr: |
| | 516 | return destroy(reinterpret_cast<IrInstSrcSaveErrRetAddr *>(inst), name); |
| | 517 | case IrInstSrcIdAddImplicitReturnType: |
| | 518 | return destroy(reinterpret_cast<IrInstSrcAddImplicitReturnType *>(inst), name); |
| | 519 | case IrInstSrcIdFloatOp: |
| | 520 | return destroy(reinterpret_cast<IrInstSrcFloatOp *>(inst), name); |
| | 521 | case IrInstSrcIdMulAdd: |
| | 522 | return destroy(reinterpret_cast<IrInstSrcMulAdd *>(inst), name); |
| | 523 | case IrInstSrcIdAtomicLoad: |
| | 524 | return destroy(reinterpret_cast<IrInstSrcAtomicLoad *>(inst), name); |
| | 525 | case IrInstSrcIdAtomicStore: |
| | 526 | return destroy(reinterpret_cast<IrInstSrcAtomicStore *>(inst), name); |
| | 527 | case IrInstSrcIdEnumToInt: |
| | 528 | return destroy(reinterpret_cast<IrInstSrcEnumToInt *>(inst), name); |
| | 529 | case IrInstSrcIdCheckRuntimeScope: |
| | 530 | return destroy(reinterpret_cast<IrInstSrcCheckRuntimeScope *>(inst), name); |
| | 531 | case IrInstSrcIdHasDecl: |
| | 532 | return destroy(reinterpret_cast<IrInstSrcHasDecl *>(inst), name); |
| | 533 | case IrInstSrcIdUndeclaredIdent: |
| | 534 | return destroy(reinterpret_cast<IrInstSrcUndeclaredIdent *>(inst), name); |
| | 535 | case IrInstSrcIdAlloca: |
| | 536 | return destroy(reinterpret_cast<IrInstSrcAlloca *>(inst), name); |
| | 537 | case IrInstSrcIdEndExpr: |
| | 538 | return destroy(reinterpret_cast<IrInstSrcEndExpr *>(inst), name); |
| | 539 | case IrInstSrcIdUnionInitNamedField: |
| | 540 | return destroy(reinterpret_cast<IrInstSrcUnionInitNamedField *>(inst), name); |
| | 541 | case IrInstSrcIdSuspendBegin: |
| | 542 | return destroy(reinterpret_cast<IrInstSrcSuspendBegin *>(inst), name); |
| | 543 | case IrInstSrcIdSuspendFinish: |
| | 544 | return destroy(reinterpret_cast<IrInstSrcSuspendFinish *>(inst), name); |
| | 545 | case IrInstSrcIdResume: |
| | 546 | return destroy(reinterpret_cast<IrInstSrcResume *>(inst), name); |
| | 547 | case IrInstSrcIdAwait: |
| | 548 | return destroy(reinterpret_cast<IrInstSrcAwait *>(inst), name); |
| | 549 | case IrInstSrcIdSpillBegin: |
| | 550 | return destroy(reinterpret_cast<IrInstSrcSpillBegin *>(inst), name); |
| | 551 | case IrInstSrcIdSpillEnd: |
| | 552 | return destroy(reinterpret_cast<IrInstSrcSpillEnd *>(inst), name); |
| | 553 | case IrInstSrcIdCallArgs: |
| | 554 | return destroy(reinterpret_cast<IrInstSrcCallArgs *>(inst), name); |
| | 555 | } |
| | 556 | zig_unreachable(); |
| | 557 | } |
| 263 | | 558 | |
| 264 | static void destroy_instruction(IrInstruction *inst) { | 559 | void destroy_instruction_gen(IrInstGen *inst) { |
| 265 | #ifdef ZIG_ENABLE_MEM_PROFILE | 560 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| 266 | const char *name = ir_instruction_type_str(inst->id); | 561 | const char *name = ir_inst_gen_type_str(inst->id); |
| 267 | #else | 562 | #else |
| 268 | const char *name = nullptr; | 563 | const char *name = nullptr; |
| 269 | #endif | 564 | #endif |
| 270 | switch (inst->id) { | 565 | switch (inst->id) { |
| 271 | case IrInstructionIdInvalid: | 566 | case IrInstGenIdInvalid: |
| 272 | zig_unreachable(); | 567 | zig_unreachable(); |
| 273 | case IrInstructionIdReturn: | 568 | case IrInstGenIdReturn: |
| 274 | return destroy(reinterpret_cast<IrInstructionReturn *>(inst), name); | 569 | return destroy(reinterpret_cast<IrInstGenReturn *>(inst), name); |
| 275 | case IrInstructionIdConst: | 570 | case IrInstGenIdConst: |
| 276 | return destroy(reinterpret_cast<IrInstructionConst *>(inst), name); | 571 | return destroy(reinterpret_cast<IrInstGenConst *>(inst), name); |
| 277 | case IrInstructionIdBinOp: | 572 | case IrInstGenIdBinOp: |
| 278 | return destroy(reinterpret_cast<IrInstructionBinOp *>(inst), name); | 573 | return destroy(reinterpret_cast<IrInstGenBinOp *>(inst), name); |
| 279 | case IrInstructionIdMergeErrSets: | 574 | case IrInstGenIdCast: |
| 280 | return destroy(reinterpret_cast<IrInstructionMergeErrSets *>(inst), name); | 575 | return destroy(reinterpret_cast<IrInstGenCast *>(inst), name); |
| 281 | case IrInstructionIdDeclVarSrc: | 576 | case IrInstGenIdCall: |
| 282 | return destroy(reinterpret_cast<IrInstructionDeclVarSrc *>(inst), name); | 577 | return destroy(reinterpret_cast<IrInstGenCall *>(inst), name); |
| 283 | case IrInstructionIdCast: | 578 | case IrInstGenIdCondBr: |
| 284 | return destroy(reinterpret_cast<IrInstructionCast *>(inst), name); | 579 | return destroy(reinterpret_cast<IrInstGenCondBr *>(inst), name); |
| 285 | case IrInstructionIdCallSrc: | 580 | case IrInstGenIdBr: |
| 286 | return destroy(reinterpret_cast<IrInstructionCallSrc *>(inst), name); | 581 | return destroy(reinterpret_cast<IrInstGenBr *>(inst), name); |
| 287 | case IrInstructionIdCallSrcArgs: | 582 | case IrInstGenIdPhi: |
| 288 | return destroy(reinterpret_cast<IrInstructionCallSrcArgs *>(inst), name); | 583 | return destroy(reinterpret_cast<IrInstGenPhi *>(inst), name); |
| 289 | case IrInstructionIdCallExtra: | 584 | case IrInstGenIdUnreachable: |
| 290 | return destroy(reinterpret_cast<IrInstructionCallExtra *>(inst), name); | 585 | return destroy(reinterpret_cast<IrInstGenUnreachable *>(inst), name); |
| 291 | case IrInstructionIdCallGen: | 586 | case IrInstGenIdElemPtr: |
| 292 | return destroy(reinterpret_cast<IrInstructionCallGen *>(inst), name); | 587 | return destroy(reinterpret_cast<IrInstGenElemPtr *>(inst), name); |
| 293 | case IrInstructionIdUnOp: | 588 | case IrInstGenIdVarPtr: |
| 294 | return destroy(reinterpret_cast<IrInstructionUnOp *>(inst), name); | 589 | return destroy(reinterpret_cast<IrInstGenVarPtr *>(inst), name); |
| 295 | case IrInstructionIdCondBr: | 590 | case IrInstGenIdReturnPtr: |
| 296 | return destroy(reinterpret_cast<IrInstructionCondBr *>(inst), name); | 591 | return destroy(reinterpret_cast<IrInstGenReturnPtr *>(inst), name); |
| 297 | case IrInstructionIdBr: | 592 | case IrInstGenIdLoadPtr: |
| 298 | return destroy(reinterpret_cast<IrInstructionBr *>(inst), name); | 593 | return destroy(reinterpret_cast<IrInstGenLoadPtr *>(inst), name); |
| 299 | case IrInstructionIdPhi: | 594 | case IrInstGenIdStorePtr: |
| 300 | return destroy(reinterpret_cast<IrInstructionPhi *>(inst), name); | 595 | return destroy(reinterpret_cast<IrInstGenStorePtr *>(inst), name); |
| 301 | case IrInstructionIdContainerInitList: | 596 | case IrInstGenIdVectorStoreElem: |
| 302 | return destroy(reinterpret_cast<IrInstructionContainerInitList *>(inst), name); | 597 | return destroy(reinterpret_cast<IrInstGenVectorStoreElem *>(inst), name); |
| 303 | case IrInstructionIdContainerInitFields: | 598 | case IrInstGenIdStructFieldPtr: |
| 304 | return destroy(reinterpret_cast<IrInstructionContainerInitFields *>(inst), name); | 599 | return destroy(reinterpret_cast<IrInstGenStructFieldPtr *>(inst), name); |
| 305 | case IrInstructionIdUnreachable: | 600 | case IrInstGenIdUnionFieldPtr: |
| 306 | return destroy(reinterpret_cast<IrInstructionUnreachable *>(inst), name); | 601 | return destroy(reinterpret_cast<IrInstGenUnionFieldPtr *>(inst), name); |
| 307 | case IrInstructionIdElemPtr: | 602 | case IrInstGenIdAsm: |
| 308 | return destroy(reinterpret_cast<IrInstructionElemPtr *>(inst), name); | 603 | return destroy(reinterpret_cast<IrInstGenAsm *>(inst), name); |
| 309 | case IrInstructionIdVarPtr: | 604 | case IrInstGenIdTestNonNull: |
| 310 | return destroy(reinterpret_cast<IrInstructionVarPtr *>(inst), name); | 605 | return destroy(reinterpret_cast<IrInstGenTestNonNull *>(inst), name); |
| 311 | case IrInstructionIdReturnPtr: | 606 | case IrInstGenIdOptionalUnwrapPtr: |
| 312 | return destroy(reinterpret_cast<IrInstructionReturnPtr *>(inst), name); | 607 | return destroy(reinterpret_cast<IrInstGenOptionalUnwrapPtr *>(inst), name); |
| 313 | case IrInstructionIdLoadPtr: | 608 | case IrInstGenIdPopCount: |
| 314 | return destroy(reinterpret_cast<IrInstructionLoadPtr *>(inst), name); | 609 | return destroy(reinterpret_cast<IrInstGenPopCount *>(inst), name); |
| 315 | case IrInstructionIdLoadPtrGen: | 610 | case IrInstGenIdClz: |
| 316 | return destroy(reinterpret_cast<IrInstructionLoadPtrGen *>(inst), name); | 611 | return destroy(reinterpret_cast<IrInstGenClz *>(inst), name); |
| 317 | case IrInstructionIdStorePtr: | 612 | case IrInstGenIdCtz: |
| 318 | return destroy(reinterpret_cast<IrInstructionStorePtr *>(inst), name); | 613 | return destroy(reinterpret_cast<IrInstGenCtz *>(inst), name); |
| 319 | case IrInstructionIdVectorStoreElem: | 614 | case IrInstGenIdBswap: |
| 320 | return destroy(reinterpret_cast<IrInstructionVectorStoreElem *>(inst), name); | 615 | return destroy(reinterpret_cast<IrInstGenBswap *>(inst), name); |
| 321 | case IrInstructionIdTypeOf: | 616 | case IrInstGenIdBitReverse: |
| 322 | return destroy(reinterpret_cast<IrInstructionTypeOf *>(inst), name); | 617 | return destroy(reinterpret_cast<IrInstGenBitReverse *>(inst), name); |
| 323 | case IrInstructionIdFieldPtr: | 618 | case IrInstGenIdSwitchBr: |
| 324 | return destroy(reinterpret_cast<IrInstructionFieldPtr *>(inst), name); | 619 | return destroy(reinterpret_cast<IrInstGenSwitchBr *>(inst), name); |
| 325 | case IrInstructionIdStructFieldPtr: | 620 | case IrInstGenIdUnionTag: |
| 326 | return destroy(reinterpret_cast<IrInstructionStructFieldPtr *>(inst), name); | 621 | return destroy(reinterpret_cast<IrInstGenUnionTag *>(inst), name); |
| 327 | case IrInstructionIdUnionFieldPtr: | 622 | case IrInstGenIdRef: |
| 328 | return destroy(reinterpret_cast<IrInstructionUnionFieldPtr *>(inst), name); | 623 | return destroy(reinterpret_cast<IrInstGenRef *>(inst), name); |
| 329 | case IrInstructionIdSetCold: | 624 | case IrInstGenIdErrName: |
| 330 | return destroy(reinterpret_cast<IrInstructionSetCold *>(inst), name); | 625 | return destroy(reinterpret_cast<IrInstGenErrName *>(inst), name); |
| 331 | case IrInstructionIdSetRuntimeSafety: | 626 | case IrInstGenIdCmpxchg: |
| 332 | return destroy(reinterpret_cast<IrInstructionSetRuntimeSafety *>(inst), name); | 627 | return destroy(reinterpret_cast<IrInstGenCmpxchg *>(inst), name); |
| 333 | case IrInstructionIdSetFloatMode: | 628 | case IrInstGenIdFence: |
| 334 | return destroy(reinterpret_cast<IrInstructionSetFloatMode *>(inst), name); | 629 | return destroy(reinterpret_cast<IrInstGenFence *>(inst), name); |
| 335 | case IrInstructionIdArrayType: | 630 | case IrInstGenIdTruncate: |
| 336 | return destroy(reinterpret_cast<IrInstructionArrayType *>(inst), name); | 631 | return destroy(reinterpret_cast<IrInstGenTruncate *>(inst), name); |
| 337 | case IrInstructionIdSliceType: | 632 | case IrInstGenIdShuffleVector: |
| 338 | return destroy(reinterpret_cast<IrInstructionSliceType *>(inst), name); | 633 | return destroy(reinterpret_cast<IrInstGenShuffleVector *>(inst), name); |
| 339 | case IrInstructionIdAnyFrameType: | 634 | case IrInstGenIdSplat: |
| 340 | return destroy(reinterpret_cast<IrInstructionAnyFrameType *>(inst), name); | 635 | return destroy(reinterpret_cast<IrInstGenSplat *>(inst), name); |
| 341 | case IrInstructionIdAsmSrc: | 636 | case IrInstGenIdBoolNot: |
| 342 | return destroy(reinterpret_cast<IrInstructionAsmSrc *>(inst), name); | 637 | return destroy(reinterpret_cast<IrInstGenBoolNot *>(inst), name); |
| 343 | case IrInstructionIdAsmGen: | 638 | case IrInstGenIdMemset: |
| 344 | return destroy(reinterpret_cast<IrInstructionAsmGen *>(inst), name); | 639 | return destroy(reinterpret_cast<IrInstGenMemset *>(inst), name); |
| 345 | case IrInstructionIdSizeOf: | 640 | case IrInstGenIdMemcpy: |
| 346 | return destroy(reinterpret_cast<IrInstructionSizeOf *>(inst), name); | 641 | return destroy(reinterpret_cast<IrInstGenMemcpy *>(inst), name); |
| 347 | case IrInstructionIdTestNonNull: | 642 | case IrInstGenIdSlice: |
| 348 | return destroy(reinterpret_cast<IrInstructionTestNonNull *>(inst), name); | 643 | return destroy(reinterpret_cast<IrInstGenSlice *>(inst), name); |
| 349 | case IrInstructionIdOptionalUnwrapPtr: | 644 | case IrInstGenIdBreakpoint: |
| 350 | return destroy(reinterpret_cast<IrInstructionOptionalUnwrapPtr *>(inst), name); | 645 | return destroy(reinterpret_cast<IrInstGenBreakpoint *>(inst), name); |
| 351 | case IrInstructionIdPopCount: | 646 | case IrInstGenIdReturnAddress: |
| 352 | return destroy(reinterpret_cast<IrInstructionPopCount *>(inst), name); | 647 | return destroy(reinterpret_cast<IrInstGenReturnAddress *>(inst), name); |
| 353 | case IrInstructionIdClz: | 648 | case IrInstGenIdFrameAddress: |
| 354 | return destroy(reinterpret_cast<IrInstructionClz *>(inst), name); | 649 | return destroy(reinterpret_cast<IrInstGenFrameAddress *>(inst), name); |
| 355 | case IrInstructionIdCtz: | 650 | case IrInstGenIdFrameHandle: |
| 356 | return destroy(reinterpret_cast<IrInstructionCtz *>(inst), name); | 651 | return destroy(reinterpret_cast<IrInstGenFrameHandle *>(inst), name); |
| 357 | case IrInstructionIdBswap: | 652 | case IrInstGenIdFrameSize: |
| 358 | return destroy(reinterpret_cast<IrInstructionBswap *>(inst), name); | 653 | return destroy(reinterpret_cast<IrInstGenFrameSize *>(inst), name); |
| 359 | case IrInstructionIdBitReverse: | 654 | case IrInstGenIdOverflowOp: |
| 360 | return destroy(reinterpret_cast<IrInstructionBitReverse *>(inst), name); | 655 | return destroy(reinterpret_cast<IrInstGenOverflowOp *>(inst), name); |
| 361 | case IrInstructionIdSwitchBr: | 656 | case IrInstGenIdTestErr: |
| 362 | return destroy(reinterpret_cast<IrInstructionSwitchBr *>(inst), name); | 657 | return destroy(reinterpret_cast<IrInstGenTestErr *>(inst), name); |
| 363 | case IrInstructionIdSwitchVar: | 658 | case IrInstGenIdUnwrapErrCode: |
| 364 | return destroy(reinterpret_cast<IrInstructionSwitchVar *>(inst), name); | 659 | return destroy(reinterpret_cast<IrInstGenUnwrapErrCode *>(inst), name); |
| 365 | case IrInstructionIdSwitchElseVar: | 660 | case IrInstGenIdUnwrapErrPayload: |
| 366 | return destroy(reinterpret_cast<IrInstructionSwitchElseVar *>(inst), name); | 661 | return destroy(reinterpret_cast<IrInstGenUnwrapErrPayload *>(inst), name); |
| 367 | case IrInstructionIdSwitchTarget: | 662 | case IrInstGenIdOptionalWrap: |
| 368 | return destroy(reinterpret_cast<IrInstructionSwitchTarget *>(inst), name); | 663 | return destroy(reinterpret_cast<IrInstGenOptionalWrap *>(inst), name); |
| 369 | case IrInstructionIdUnionTag: | 664 | case IrInstGenIdErrWrapCode: |
| 370 | return destroy(reinterpret_cast<IrInstructionUnionTag *>(inst), name); | 665 | return destroy(reinterpret_cast<IrInstGenErrWrapCode *>(inst), name); |
| 371 | case IrInstructionIdImport: | 666 | case IrInstGenIdErrWrapPayload: |
| 372 | return destroy(reinterpret_cast<IrInstructionImport *>(inst), name); | 667 | return destroy(reinterpret_cast<IrInstGenErrWrapPayload *>(inst), name); |
| 373 | case IrInstructionIdRef: | 668 | case IrInstGenIdPtrCast: |
| 374 | return destroy(reinterpret_cast<IrInstructionRef *>(inst), name); | 669 | return destroy(reinterpret_cast<IrInstGenPtrCast *>(inst), name); |
| 375 | case IrInstructionIdRefGen: | 670 | case IrInstGenIdBitCast: |
| 376 | return destroy(reinterpret_cast<IrInstructionRefGen *>(inst), name); | 671 | return destroy(reinterpret_cast<IrInstGenBitCast *>(inst), name); |
| 377 | case IrInstructionIdCompileErr: | 672 | case IrInstGenIdWidenOrShorten: |
| 378 | return destroy(reinterpret_cast<IrInstructionCompileErr *>(inst), name); | 673 | return destroy(reinterpret_cast<IrInstGenWidenOrShorten *>(inst), name); |
| 379 | case IrInstructionIdCompileLog: | 674 | case IrInstGenIdPtrToInt: |
| 380 | return destroy(reinterpret_cast<IrInstructionCompileLog *>(inst), name); | 675 | return destroy(reinterpret_cast<IrInstGenPtrToInt *>(inst), name); |
| 381 | case IrInstructionIdErrName: | 676 | case IrInstGenIdIntToPtr: |
| 382 | return destroy(reinterpret_cast<IrInstructionErrName *>(inst), name); | 677 | return destroy(reinterpret_cast<IrInstGenIntToPtr *>(inst), name); |
| 383 | case IrInstructionIdCImport: | 678 | case IrInstGenIdIntToEnum: |
| 384 | return destroy(reinterpret_cast<IrInstructionCImport *>(inst), name); | 679 | return destroy(reinterpret_cast<IrInstGenIntToEnum *>(inst), name); |
| 385 | case IrInstructionIdCInclude: | 680 | case IrInstGenIdIntToErr: |
| 386 | return destroy(reinterpret_cast<IrInstructionCInclude *>(inst), name); | 681 | return destroy(reinterpret_cast<IrInstGenIntToErr *>(inst), name); |
| 387 | case IrInstructionIdCDefine: | 682 | case IrInstGenIdErrToInt: |
| 388 | return destroy(reinterpret_cast<IrInstructionCDefine *>(inst), name); | 683 | return destroy(reinterpret_cast<IrInstGenErrToInt *>(inst), name); |
| 389 | case IrInstructionIdCUndef: | 684 | case IrInstGenIdTagName: |
| 390 | return destroy(reinterpret_cast<IrInstructionCUndef *>(inst), name); | 685 | return destroy(reinterpret_cast<IrInstGenTagName *>(inst), name); |
| 391 | case IrInstructionIdEmbedFile: | 686 | case IrInstGenIdPanic: |
| 392 | return destroy(reinterpret_cast<IrInstructionEmbedFile *>(inst), name); | 687 | return destroy(reinterpret_cast<IrInstGenPanic *>(inst), name); |
| 393 | case IrInstructionIdCmpxchgSrc: | 688 | case IrInstGenIdFieldParentPtr: |
| 394 | return destroy(reinterpret_cast<IrInstructionCmpxchgSrc *>(inst), name); | 689 | return destroy(reinterpret_cast<IrInstGenFieldParentPtr *>(inst), name); |
| 395 | case IrInstructionIdCmpxchgGen: | 690 | case IrInstGenIdAlignCast: |
| 396 | return destroy(reinterpret_cast<IrInstructionCmpxchgGen *>(inst), name); | 691 | return destroy(reinterpret_cast<IrInstGenAlignCast *>(inst), name); |
| 397 | case IrInstructionIdFence: | 692 | case IrInstGenIdErrorReturnTrace: |
| 398 | return destroy(reinterpret_cast<IrInstructionFence *>(inst), name); | 693 | return destroy(reinterpret_cast<IrInstGenErrorReturnTrace *>(inst), name); |
| 399 | case IrInstructionIdTruncate: | 694 | case IrInstGenIdAtomicRmw: |
| 400 | return destroy(reinterpret_cast<IrInstructionTruncate *>(inst), name); | 695 | return destroy(reinterpret_cast<IrInstGenAtomicRmw *>(inst), name); |
| 401 | case IrInstructionIdIntCast: | 696 | case IrInstGenIdSaveErrRetAddr: |
| 402 | return destroy(reinterpret_cast<IrInstructionIntCast *>(inst), name); | 697 | return destroy(reinterpret_cast<IrInstGenSaveErrRetAddr *>(inst), name); |
| 403 | case IrInstructionIdFloatCast: | 698 | case IrInstGenIdFloatOp: |
| 404 | return destroy(reinterpret_cast<IrInstructionFloatCast *>(inst), name); | 699 | return destroy(reinterpret_cast<IrInstGenFloatOp *>(inst), name); |
| 405 | case IrInstructionIdErrSetCast: | 700 | case IrInstGenIdMulAdd: |
| 406 | return destroy(reinterpret_cast<IrInstructionErrSetCast *>(inst), name); | 701 | return destroy(reinterpret_cast<IrInstGenMulAdd *>(inst), name); |
| 407 | case IrInstructionIdFromBytes: | 702 | case IrInstGenIdAtomicLoad: |
| 408 | return destroy(reinterpret_cast<IrInstructionFromBytes *>(inst), name); | 703 | return destroy(reinterpret_cast<IrInstGenAtomicLoad *>(inst), name); |
| 409 | case IrInstructionIdToBytes: | 704 | case IrInstGenIdAtomicStore: |
| 410 | return destroy(reinterpret_cast<IrInstructionToBytes *>(inst), name); | 705 | return destroy(reinterpret_cast<IrInstGenAtomicStore *>(inst), name); |
| 411 | case IrInstructionIdIntToFloat: | 706 | case IrInstGenIdDeclVar: |
| 412 | return destroy(reinterpret_cast<IrInstructionIntToFloat *>(inst), name); | 707 | return destroy(reinterpret_cast<IrInstGenDeclVar *>(inst), name); |
| 413 | case IrInstructionIdFloatToInt: | 708 | case IrInstGenIdArrayToVector: |
| 414 | return destroy(reinterpret_cast<IrInstructionFloatToInt *>(inst), name); | 709 | return destroy(reinterpret_cast<IrInstGenArrayToVector *>(inst), name); |
| 415 | case IrInstructionIdBoolToInt: | 710 | case IrInstGenIdVectorToArray: |
| 416 | return destroy(reinterpret_cast<IrInstructionBoolToInt *>(inst), name); | 711 | return destroy(reinterpret_cast<IrInstGenVectorToArray *>(inst), name); |
| 417 | case IrInstructionIdIntType: | 712 | case IrInstGenIdPtrOfArrayToSlice: |
| 418 | return destroy(reinterpret_cast<IrInstructionIntType *>(inst), name); | 713 | return destroy(reinterpret_cast<IrInstGenPtrOfArrayToSlice *>(inst), name); |
| 419 | case IrInstructionIdVectorType: | 714 | case IrInstGenIdAssertZero: |
| 420 | return destroy(reinterpret_cast<IrInstructionVectorType *>(inst), name); | 715 | return destroy(reinterpret_cast<IrInstGenAssertZero *>(inst), name); |
| 421 | case IrInstructionIdShuffleVector: | 716 | case IrInstGenIdAssertNonNull: |
| 422 | return destroy(reinterpret_cast<IrInstructionShuffleVector *>(inst), name); | 717 | return destroy(reinterpret_cast<IrInstGenAssertNonNull *>(inst), name); |
| 423 | case IrInstructionIdSplatSrc: | 718 | case IrInstGenIdResizeSlice: |
| 424 | return destroy(reinterpret_cast<IrInstructionSplatSrc *>(inst), name); | 719 | return destroy(reinterpret_cast<IrInstGenResizeSlice *>(inst), name); |
| 425 | case IrInstructionIdSplatGen: | 720 | case IrInstGenIdAlloca: |
| 426 | return destroy(reinterpret_cast<IrInstructionSplatGen *>(inst), name); | 721 | return destroy(reinterpret_cast<IrInstGenAlloca *>(inst), name); |
| 427 | case IrInstructionIdBoolNot: | 722 | case IrInstGenIdSuspendBegin: |
| 428 | return destroy(reinterpret_cast<IrInstructionBoolNot *>(inst), name); | 723 | return destroy(reinterpret_cast<IrInstGenSuspendBegin *>(inst), name); |
| 429 | case IrInstructionIdMemset: | 724 | case IrInstGenIdSuspendFinish: |
| 430 | return destroy(reinterpret_cast<IrInstructionMemset *>(inst), name); | 725 | return destroy(reinterpret_cast<IrInstGenSuspendFinish *>(inst), name); |
| 431 | case IrInstructionIdMemcpy: | 726 | case IrInstGenIdResume: |
| 432 | return destroy(reinterpret_cast<IrInstructionMemcpy *>(inst), name); | 727 | return destroy(reinterpret_cast<IrInstGenResume *>(inst), name); |
| 433 | case IrInstructionIdSliceSrc: | 728 | case IrInstGenIdAwait: |
| 434 | return destroy(reinterpret_cast<IrInstructionSliceSrc *>(inst), name); | 729 | return destroy(reinterpret_cast<IrInstGenAwait *>(inst), name); |
| 435 | case IrInstructionIdSliceGen: | 730 | case IrInstGenIdSpillBegin: |
| 436 | return destroy(reinterpret_cast<IrInstructionSliceGen *>(inst), name); | 731 | return destroy(reinterpret_cast<IrInstGenSpillBegin *>(inst), name); |
| 437 | case IrInstructionIdMemberCount: | 732 | case IrInstGenIdSpillEnd: |
| 438 | return destroy(reinterpret_cast<IrInstructionMemberCount *>(inst), name); | 733 | return destroy(reinterpret_cast<IrInstGenSpillEnd *>(inst), name); |
| 439 | case IrInstructionIdMemberType: | 734 | case IrInstGenIdVectorExtractElem: |
| 440 | return destroy(reinterpret_cast<IrInstructionMemberType *>(inst), name); | 735 | return destroy(reinterpret_cast<IrInstGenVectorExtractElem *>(inst), name); |
| 441 | case IrInstructionIdMemberName: | 736 | case IrInstGenIdBinaryNot: |
| 442 | return destroy(reinterpret_cast<IrInstructionMemberName *>(inst), name); | 737 | return destroy(reinterpret_cast<IrInstGenBinaryNot *>(inst), name); |
| 443 | case IrInstructionIdBreakpoint: | 738 | case IrInstGenIdNegation: |
| 444 | return destroy(reinterpret_cast<IrInstructionBreakpoint *>(inst), name); | 739 | return destroy(reinterpret_cast<IrInstGenNegation *>(inst), name); |
| 445 | case IrInstructionIdReturnAddress: | 740 | case IrInstGenIdNegationWrapping: |
| 446 | return destroy(reinterpret_cast<IrInstructionReturnAddress *>(inst), name); | 741 | return destroy(reinterpret_cast<IrInstGenNegationWrapping *>(inst), name); |
| 447 | case IrInstructionIdFrameAddress: | | |
| 448 | return destroy(reinterpret_cast<IrInstructionFrameAddress *>(inst), name); | | |
| 449 | case IrInstructionIdFrameHandle: | | |
| 450 | return destroy(reinterpret_cast<IrInstructionFrameHandle *>(inst), name); | | |
| 451 | case IrInstructionIdFrameType: | | |
| 452 | return destroy(reinterpret_cast<IrInstructionFrameType *>(inst), name); | | |
| 453 | case IrInstructionIdFrameSizeSrc: | | |
| 454 | return destroy(reinterpret_cast<IrInstructionFrameSizeSrc *>(inst), name); | | |
| 455 | case IrInstructionIdFrameSizeGen: | | |
| 456 | return destroy(reinterpret_cast<IrInstructionFrameSizeGen *>(inst), name); | | |
| 457 | case IrInstructionIdAlignOf: | | |
| 458 | return destroy(reinterpret_cast<IrInstructionAlignOf *>(inst), name); | | |
| 459 | case IrInstructionIdOverflowOp: | | |
| 460 | return destroy(reinterpret_cast<IrInstructionOverflowOp *>(inst), name); | | |
| 461 | case IrInstructionIdTestErrSrc: | | |
| 462 | return destroy(reinterpret_cast<IrInstructionTestErrSrc *>(inst), name); | | |
| 463 | case IrInstructionIdTestErrGen: | | |
| 464 | return destroy(reinterpret_cast<IrInstructionTestErrGen *>(inst), name); | | |
| 465 | case IrInstructionIdUnwrapErrCode: | | |
| 466 | return destroy(reinterpret_cast<IrInstructionUnwrapErrCode *>(inst), name); | | |
| 467 | case IrInstructionIdUnwrapErrPayload: | | |
| 468 | return destroy(reinterpret_cast<IrInstructionUnwrapErrPayload *>(inst), name); | | |
| 469 | case IrInstructionIdOptionalWrap: | | |
| 470 | return destroy(reinterpret_cast<IrInstructionOptionalWrap *>(inst), name); | | |
| 471 | case IrInstructionIdErrWrapCode: | | |
| 472 | return destroy(reinterpret_cast<IrInstructionErrWrapCode *>(inst), name); | | |
| 473 | case IrInstructionIdErrWrapPayload: | | |
| 474 | return destroy(reinterpret_cast<IrInstructionErrWrapPayload *>(inst), name); | | |
| 475 | case IrInstructionIdFnProto: | | |
| 476 | return destroy(reinterpret_cast<IrInstructionFnProto *>(inst), name); | | |
| 477 | case IrInstructionIdTestComptime: | | |
| 478 | return destroy(reinterpret_cast<IrInstructionTestComptime *>(inst), name); | | |
| 479 | case IrInstructionIdPtrCastSrc: | | |
| 480 | return destroy(reinterpret_cast<IrInstructionPtrCastSrc *>(inst), name); | | |
| 481 | case IrInstructionIdPtrCastGen: | | |
| 482 | return destroy(reinterpret_cast<IrInstructionPtrCastGen *>(inst), name); | | |
| 483 | case IrInstructionIdBitCastSrc: | | |
| 484 | return destroy(reinterpret_cast<IrInstructionBitCastSrc *>(inst), name); | | |
| 485 | case IrInstructionIdBitCastGen: | | |
| 486 | return destroy(reinterpret_cast<IrInstructionBitCastGen *>(inst), name); | | |
| 487 | case IrInstructionIdWidenOrShorten: | | |
| 488 | return destroy(reinterpret_cast<IrInstructionWidenOrShorten *>(inst), name); | | |
| 489 | case IrInstructionIdPtrToInt: | | |
| 490 | return destroy(reinterpret_cast<IrInstructionPtrToInt *>(inst), name); | | |
| 491 | case IrInstructionIdIntToPtr: | | |
| 492 | return destroy(reinterpret_cast<IrInstructionIntToPtr *>(inst), name); | | |
| 493 | case IrInstructionIdIntToEnum: | | |
| 494 | return destroy(reinterpret_cast<IrInstructionIntToEnum *>(inst), name); | | |
| 495 | case IrInstructionIdIntToErr: | | |
| 496 | return destroy(reinterpret_cast<IrInstructionIntToErr *>(inst), name); | | |
| 497 | case IrInstructionIdErrToInt: | | |
| 498 | return destroy(reinterpret_cast<IrInstructionErrToInt *>(inst), name); | | |
| 499 | case IrInstructionIdCheckSwitchProngs: | | |
| 500 | return destroy(reinterpret_cast<IrInstructionCheckSwitchProngs *>(inst), name); | | |
| 501 | case IrInstructionIdCheckStatementIsVoid: | | |
| 502 | return destroy(reinterpret_cast<IrInstructionCheckStatementIsVoid *>(inst), name); | | |
| 503 | case IrInstructionIdTypeName: | | |
| 504 | return destroy(reinterpret_cast<IrInstructionTypeName *>(inst), name); | | |
| 505 | case IrInstructionIdTagName: | | |
| 506 | return destroy(reinterpret_cast<IrInstructionTagName *>(inst), name); | | |
| 507 | case IrInstructionIdPtrType: | | |
| 508 | return destroy(reinterpret_cast<IrInstructionPtrType *>(inst), name); | | |
| 509 | case IrInstructionIdDeclRef: | | |
| 510 | return destroy(reinterpret_cast<IrInstructionDeclRef *>(inst), name); | | |
| 511 | case IrInstructionIdPanic: | | |
| 512 | return destroy(reinterpret_cast<IrInstructionPanic *>(inst), name); | | |
| 513 | case IrInstructionIdFieldParentPtr: | | |
| 514 | return destroy(reinterpret_cast<IrInstructionFieldParentPtr *>(inst), name); | | |
| 515 | case IrInstructionIdByteOffsetOf: | | |
| 516 | return destroy(reinterpret_cast<IrInstructionByteOffsetOf *>(inst), name); | | |
| 517 | case IrInstructionIdBitOffsetOf: | | |
| 518 | return destroy(reinterpret_cast<IrInstructionBitOffsetOf *>(inst), name); | | |
| 519 | case IrInstructionIdTypeInfo: | | |
| 520 | return destroy(reinterpret_cast<IrInstructionTypeInfo *>(inst), name); | | |
| 521 | case IrInstructionIdType: | | |
| 522 | return destroy(reinterpret_cast<IrInstructionType *>(inst), name); | | |
| 523 | case IrInstructionIdHasField: | | |
| 524 | return destroy(reinterpret_cast<IrInstructionHasField *>(inst), name); | | |
| 525 | case IrInstructionIdTypeId: | | |
| 526 | return destroy(reinterpret_cast<IrInstructionTypeId *>(inst), name); | | |
| 527 | case IrInstructionIdSetEvalBranchQuota: | | |
| 528 | return destroy(reinterpret_cast<IrInstructionSetEvalBranchQuota *>(inst), name); | | |
| 529 | case IrInstructionIdAlignCast: | | |
| 530 | return destroy(reinterpret_cast<IrInstructionAlignCast *>(inst), name); | | |
| 531 | case IrInstructionIdImplicitCast: | | |
| 532 | return destroy(reinterpret_cast<IrInstructionImplicitCast *>(inst), name); | | |
| 533 | case IrInstructionIdResolveResult: | | |
| 534 | return destroy(reinterpret_cast<IrInstructionResolveResult *>(inst), name); | | |
| 535 | case IrInstructionIdResetResult: | | |
| 536 | return destroy(reinterpret_cast<IrInstructionResetResult *>(inst), name); | | |
| 537 | case IrInstructionIdOpaqueType: | | |
| 538 | return destroy(reinterpret_cast<IrInstructionOpaqueType *>(inst), name); | | |
| 539 | case IrInstructionIdSetAlignStack: | | |
| 540 | return destroy(reinterpret_cast<IrInstructionSetAlignStack *>(inst), name); | | |
| 541 | case IrInstructionIdArgType: | | |
| 542 | return destroy(reinterpret_cast<IrInstructionArgType *>(inst), name); | | |
| 543 | case IrInstructionIdTagType: | | |
| 544 | return destroy(reinterpret_cast<IrInstructionTagType *>(inst), name); | | |
| 545 | case IrInstructionIdExport: | | |
| 546 | return destroy(reinterpret_cast<IrInstructionExport *>(inst), name); | | |
| 547 | case IrInstructionIdErrorReturnTrace: | | |
| 548 | return destroy(reinterpret_cast<IrInstructionErrorReturnTrace *>(inst), name); | | |
| 549 | case IrInstructionIdErrorUnion: | | |
| 550 | return destroy(reinterpret_cast<IrInstructionErrorUnion *>(inst), name); | | |
| 551 | case IrInstructionIdAtomicRmw: | | |
| 552 | return destroy(reinterpret_cast<IrInstructionAtomicRmw *>(inst), name); | | |
| 553 | case IrInstructionIdSaveErrRetAddr: | | |
| 554 | return destroy(reinterpret_cast<IrInstructionSaveErrRetAddr *>(inst), name); | | |
| 555 | case IrInstructionIdAddImplicitReturnType: | | |
| 556 | return destroy(reinterpret_cast<IrInstructionAddImplicitReturnType *>(inst), name); | | |
| 557 | case IrInstructionIdFloatOp: | | |
| 558 | return destroy(reinterpret_cast<IrInstructionFloatOp *>(inst), name); | | |
| 559 | case IrInstructionIdMulAdd: | | |
| 560 | return destroy(reinterpret_cast<IrInstructionMulAdd *>(inst), name); | | |
| 561 | case IrInstructionIdAtomicLoad: | | |
| 562 | return destroy(reinterpret_cast<IrInstructionAtomicLoad *>(inst), name); | | |
| 563 | case IrInstructionIdAtomicStore: | | |
| 564 | return destroy(reinterpret_cast<IrInstructionAtomicStore *>(inst), name); | | |
| 565 | case IrInstructionIdEnumToInt: | | |
| 566 | return destroy(reinterpret_cast<IrInstructionEnumToInt *>(inst), name); | | |
| 567 | case IrInstructionIdCheckRuntimeScope: | | |
| 568 | return destroy(reinterpret_cast<IrInstructionCheckRuntimeScope *>(inst), name); | | |
| 569 | case IrInstructionIdDeclVarGen: | | |
| 570 | return destroy(reinterpret_cast<IrInstructionDeclVarGen *>(inst), name); | | |
| 571 | case IrInstructionIdArrayToVector: | | |
| 572 | return destroy(reinterpret_cast<IrInstructionArrayToVector *>(inst), name); | | |
| 573 | case IrInstructionIdVectorToArray: | | |
| 574 | return destroy(reinterpret_cast<IrInstructionVectorToArray *>(inst), name); | | |
| 575 | case IrInstructionIdPtrOfArrayToSlice: | | |
| 576 | return destroy(reinterpret_cast<IrInstructionPtrOfArrayToSlice *>(inst), name); | | |
| 577 | case IrInstructionIdAssertZero: | | |
| 578 | return destroy(reinterpret_cast<IrInstructionAssertZero *>(inst), name); | | |
| 579 | case IrInstructionIdAssertNonNull: | | |
| 580 | return destroy(reinterpret_cast<IrInstructionAssertNonNull *>(inst), name); | | |
| 581 | case IrInstructionIdResizeSlice: | | |
| 582 | return destroy(reinterpret_cast<IrInstructionResizeSlice *>(inst), name); | | |
| 583 | case IrInstructionIdHasDecl: | | |
| 584 | return destroy(reinterpret_cast<IrInstructionHasDecl *>(inst), name); | | |
| 585 | case IrInstructionIdUndeclaredIdent: | | |
| 586 | return destroy(reinterpret_cast<IrInstructionUndeclaredIdent *>(inst), name); | | |
| 587 | case IrInstructionIdAllocaSrc: | | |
| 588 | return destroy(reinterpret_cast<IrInstructionAllocaSrc *>(inst), name); | | |
| 589 | case IrInstructionIdAllocaGen: | | |
| 590 | return destroy(reinterpret_cast<IrInstructionAllocaGen *>(inst), name); | | |
| 591 | case IrInstructionIdEndExpr: | | |
| 592 | return destroy(reinterpret_cast<IrInstructionEndExpr *>(inst), name); | | |
| 593 | case IrInstructionIdUnionInitNamedField: | | |
| 594 | return destroy(reinterpret_cast<IrInstructionUnionInitNamedField *>(inst), name); | | |
| 595 | case IrInstructionIdSuspendBegin: | | |
| 596 | return destroy(reinterpret_cast<IrInstructionSuspendBegin *>(inst), name); | | |
| 597 | case IrInstructionIdSuspendFinish: | | |
| 598 | return destroy(reinterpret_cast<IrInstructionSuspendFinish *>(inst), name); | | |
| 599 | case IrInstructionIdResume: | | |
| 600 | return destroy(reinterpret_cast<IrInstructionResume *>(inst), name); | | |
| 601 | case IrInstructionIdAwaitSrc: | | |
| 602 | return destroy(reinterpret_cast<IrInstructionAwaitSrc *>(inst), name); | | |
| 603 | case IrInstructionIdAwaitGen: | | |
| 604 | return destroy(reinterpret_cast<IrInstructionAwaitGen *>(inst), name); | | |
| 605 | case IrInstructionIdSpillBegin: | | |
| 606 | return destroy(reinterpret_cast<IrInstructionSpillBegin *>(inst), name); | | |
| 607 | case IrInstructionIdSpillEnd: | | |
| 608 | return destroy(reinterpret_cast<IrInstructionSpillEnd *>(inst), name); | | |
| 609 | case IrInstructionIdVectorExtractElem: | | |
| 610 | return destroy(reinterpret_cast<IrInstructionVectorExtractElem *>(inst), name); | | |
| 611 | } | 742 | } |
| 612 | zig_unreachable(); | 743 | zig_unreachable(); |
| 613 | } | 744 | } |
| ... | @@ -623,17 +754,17 @@ static void ira_deref(IrAnalyze *ira) { | ... | @@ -623,17 +754,17 @@ static void ira_deref(IrAnalyze *ira) { |
| 623 | assert(ira->ref_count != 0); | 754 | assert(ira->ref_count != 0); |
| 624 | | 755 | |
| 625 | for (size_t bb_i = 0; bb_i < ira->old_irb.exec->basic_block_list.length; bb_i += 1) { | 756 | for (size_t bb_i = 0; bb_i < ira->old_irb.exec->basic_block_list.length; bb_i += 1) { |
| 626 | IrBasicBlock *pass1_bb = ira->old_irb.exec->basic_block_list.items[bb_i]; | 757 | IrBasicBlockSrc *pass1_bb = ira->old_irb.exec->basic_block_list.items[bb_i]; |
| 627 | for (size_t inst_i = 0; inst_i < pass1_bb->instruction_list.length; inst_i += 1) { | 758 | for (size_t inst_i = 0; inst_i < pass1_bb->instruction_list.length; inst_i += 1) { |
| 628 | IrInstruction *pass1_inst = pass1_bb->instruction_list.items[inst_i]; | 759 | IrInstSrc *pass1_inst = pass1_bb->instruction_list.items[inst_i]; |
| 629 | destroy_instruction(pass1_inst); | 760 | destroy_instruction_src(pass1_inst); |
| 630 | } | 761 | } |
| 631 | destroy(pass1_bb, "IrBasicBlock"); | 762 | destroy(pass1_bb, "IrBasicBlockSrc"); |
| 632 | } | 763 | } |
| 633 | ira->old_irb.exec->basic_block_list.deinit(); | 764 | ira->old_irb.exec->basic_block_list.deinit(); |
| 634 | ira->old_irb.exec->tld_list.deinit(); | 765 | ira->old_irb.exec->tld_list.deinit(); |
| 635 | // cannot destroy here because of var->owner_exec | 766 | // cannot destroy here because of var->owner_exec |
| 636 | //destroy(ira->old_irb.exec, "IrExecutablePass1"); | 767 | //destroy(ira->old_irb.exec, "IrExecutableSrc"); |
| 637 | ira->src_implicit_return_type_list.deinit(); | 768 | ira->src_implicit_return_type_list.deinit(); |
| 638 | ira->resume_stack.deinit(); | 769 | ira->resume_stack.deinit(); |
| 639 | destroy(ira, "IrAnalyze"); | 770 | destroy(ira, "IrAnalyze"); |
| ... | @@ -780,7 +911,7 @@ static bool types_have_same_zig_comptime_repr(CodeGen *codegen, ZigType *expecte | ... | @@ -780,7 +911,7 @@ static bool types_have_same_zig_comptime_repr(CodeGen *codegen, ZigType *expecte |
| 780 | zig_unreachable(); | 911 | zig_unreachable(); |
| 781 | } | 912 | } |
| 782 | | 913 | |
| 783 | static bool ir_should_inline(IrExecutable *exec, Scope *scope) { | 914 | static bool ir_should_inline(IrExecutableSrc *exec, Scope *scope) { |
| 784 | if (exec->is_inline) | 915 | if (exec->is_inline) |
| 785 | return true; | 916 | return true; |
| 786 | | 917 | |
| ... | @@ -796,23 +927,35 @@ static bool ir_should_inline(IrExecutable *exec, Scope *scope) { | ... | @@ -796,23 +927,35 @@ static bool ir_should_inline(IrExecutable *exec, Scope *scope) { |
| 796 | return false; | 927 | return false; |
| 797 | } | 928 | } |
| 798 | | 929 | |
| 799 | static void ir_instruction_append(IrBasicBlock *basic_block, IrInstruction *instruction) { | 930 | static void ir_instruction_append(IrBasicBlockSrc *basic_block, IrInstSrc *instruction) { |
| | 931 | assert(basic_block); |
| | 932 | assert(instruction); |
| | 933 | basic_block->instruction_list.append(instruction); |
| | 934 | } |
| | 935 | |
| | 936 | static void ir_inst_gen_append(IrBasicBlockGen *basic_block, IrInstGen *instruction) { |
| 800 | assert(basic_block); | 937 | assert(basic_block); |
| 801 | assert(instruction); | 938 | assert(instruction); |
| 802 | basic_block->instruction_list.append(instruction); | 939 | basic_block->instruction_list.append(instruction); |
| 803 | } | 940 | } |
| 804 | | 941 | |
| 805 | static size_t exec_next_debug_id(IrExecutable *exec) { | 942 | static size_t exec_next_debug_id(IrExecutableSrc *exec) { |
| | 943 | size_t result = exec->next_debug_id; |
| | 944 | exec->next_debug_id += 1; |
| | 945 | return result; |
| | 946 | } |
| | 947 | |
| | 948 | static size_t exec_next_debug_id_gen(IrExecutableGen *exec) { |
| 806 | size_t result = exec->next_debug_id; | 949 | size_t result = exec->next_debug_id; |
| 807 | exec->next_debug_id += 1; | 950 | exec->next_debug_id += 1; |
| 808 | return result; | 951 | return result; |
| 809 | } | 952 | } |
| 810 | | 953 | |
| 811 | static ZigFn *exec_fn_entry(IrExecutable *exec) { | 954 | static ZigFn *exec_fn_entry(IrExecutableSrc *exec) { |
| 812 | return exec->fn_entry; | 955 | return exec->fn_entry; |
| 813 | } | 956 | } |
| 814 | | 957 | |
| 815 | static Buf *exec_c_import_buf(IrExecutable *exec) { | 958 | static Buf *exec_c_import_buf(IrExecutableSrc *exec) { |
| 816 | return exec->c_import_buf; | 959 | return exec->c_import_buf; |
| 817 | } | 960 | } |
| 818 | | 961 | |
| ... | @@ -820,28 +963,42 @@ static bool value_is_comptime(ZigValue *const_val) { | ... | @@ -820,28 +963,42 @@ static bool value_is_comptime(ZigValue *const_val) { |
| 820 | return const_val->special != ConstValSpecialRuntime; | 963 | return const_val->special != ConstValSpecialRuntime; |
| 821 | } | 964 | } |
| 822 | | 965 | |
| 823 | static bool instr_is_comptime(IrInstruction *instruction) { | 966 | static bool instr_is_comptime(IrInstGen *instruction) { |
| 824 | return value_is_comptime(instruction->value); | 967 | return value_is_comptime(instruction->value); |
| 825 | } | 968 | } |
| 826 | | 969 | |
| 827 | static bool instr_is_unreachable(IrInstruction *instruction) { | 970 | static bool instr_is_unreachable(IrInstSrc *instruction) { |
| 828 | return instruction->value->type && instruction->value->type->id == ZigTypeIdUnreachable; | 971 | return instruction->is_noreturn; |
| 829 | } | 972 | } |
| 830 | | 973 | |
| 831 | static void ir_link_new_bb(IrBasicBlock *new_bb, IrBasicBlock *old_bb) { | 974 | static void ir_link_new_bb(IrBasicBlockGen *new_bb, IrBasicBlockSrc *old_bb) { |
| 832 | new_bb->other = old_bb; | 975 | new_bb->parent = old_bb; |
| 833 | old_bb->other = new_bb; | 976 | old_bb->child = new_bb; |
| 834 | } | 977 | } |
| 835 | | 978 | |
| 836 | static void ir_ref_bb(IrBasicBlock *bb) { | 979 | static void ir_ref_bb(IrBasicBlockSrc *bb) { |
| 837 | bb->ref_count += 1; | 980 | bb->ref_count += 1; |
| 838 | } | 981 | } |
| 839 | | 982 | |
| 840 | static void ir_ref_instruction(IrInstruction *instruction, IrBasicBlock *cur_bb) { | 983 | static void ir_ref_bb_gen(IrBasicBlockGen *bb) { |
| 841 | assert(instruction->id != IrInstructionIdInvalid); | 984 | bb->ref_count += 1; |
| 842 | instruction->ref_count += 1; | 985 | } |
| 843 | if (instruction->owner_bb != cur_bb && !instr_is_comptime(instruction)) | 986 | |
| | 987 | static void ir_ref_instruction(IrInstSrc *instruction, IrBasicBlockSrc *cur_bb) { |
| | 988 | assert(instruction->id != IrInstSrcIdInvalid); |
| | 989 | instruction->base.ref_count += 1; |
| | 990 | if (instruction->owner_bb != cur_bb && !instr_is_unreachable(instruction) |
| | 991 | && instruction->id != IrInstSrcIdConst) |
| | 992 | { |
| 844 | ir_ref_bb(instruction->owner_bb); | 993 | ir_ref_bb(instruction->owner_bb); |
| | 994 | } |
| | 995 | } |
| | 996 | |
| | 997 | static void ir_ref_inst_gen(IrInstGen *instruction, IrBasicBlockGen *cur_bb) { |
| | 998 | assert(instruction->id != IrInstGenIdInvalid); |
| | 999 | instruction->base.ref_count += 1; |
| | 1000 | if (instruction->owner_bb != cur_bb && !instr_is_comptime(instruction)) |
| | 1001 | ir_ref_bb_gen(instruction->owner_bb); |
| 845 | } | 1002 | } |
| 846 | | 1003 | |
| 847 | static void ir_ref_var(ZigVar *var) { | 1004 | static void ir_ref_var(ZigVar *var) { |
| ... | @@ -890,962 +1047,1259 @@ ZigType *ir_analyze_type_expr(IrAnalyze *ira, Scope *scope, AstNode *node) { | ... | @@ -890,962 +1047,1259 @@ ZigType *ir_analyze_type_expr(IrAnalyze *ira, Scope *scope, AstNode *node) { |
| 890 | return res_type; | 1047 | return res_type; |
| 891 | } | 1048 | } |
| 892 | | 1049 | |
| 893 | static IrBasicBlock *ir_create_basic_block(IrBuilder *irb, Scope *scope, const char *name_hint) { | 1050 | static IrBasicBlockSrc *ir_create_basic_block(IrBuilderSrc *irb, Scope *scope, const char *name_hint) { |
| 894 | IrBasicBlock *result = allocate<IrBasicBlock>(1, "IrBasicBlock"); | 1051 | IrBasicBlockSrc *result = allocate<IrBasicBlockSrc>(1, "IrBasicBlockSrc"); |
| 895 | result->scope = scope; | 1052 | result->scope = scope; |
| 896 | result->name_hint = name_hint; | 1053 | result->name_hint = name_hint; |
| 897 | result->debug_id = exec_next_debug_id(irb->exec); | 1054 | result->debug_id = exec_next_debug_id(irb->exec); |
| 898 | result->index = SIZE_MAX; // set later | 1055 | result->index = UINT32_MAX; // set later |
| 899 | return result; | 1056 | return result; |
| 900 | } | 1057 | } |
| 901 | | 1058 | |
| 902 | static IrBasicBlock *ir_build_bb_from(IrBuilder *irb, IrBasicBlock *other_bb) { | 1059 | static IrBasicBlockGen *ir_create_basic_block_gen(IrAnalyze *ira, Scope *scope, const char *name_hint) { |
| 903 | IrBasicBlock *new_bb = ir_create_basic_block(irb, other_bb->scope, other_bb->name_hint); | 1060 | IrBasicBlockGen *result = allocate<IrBasicBlockGen>(1, "IrBasicBlockGen"); |
| | 1061 | result->scope = scope; |
| | 1062 | result->name_hint = name_hint; |
| | 1063 | result->debug_id = exec_next_debug_id_gen(ira->new_irb.exec); |
| | 1064 | result->index = UINT32_MAX; // set later |
| | 1065 | return result; |
| | 1066 | } |
| | 1067 | |
| | 1068 | static IrBasicBlockGen *ir_build_bb_from(IrAnalyze *ira, IrBasicBlockSrc *other_bb) { |
| | 1069 | IrBasicBlockGen *new_bb = ir_create_basic_block_gen(ira, other_bb->scope, other_bb->name_hint); |
| 904 | ir_link_new_bb(new_bb, other_bb); | 1070 | ir_link_new_bb(new_bb, other_bb); |
| 905 | return new_bb; | 1071 | return new_bb; |
| 906 | } | 1072 | } |
| 907 | | 1073 | |
| 908 | static constexpr IrInstructionId ir_instruction_id(IrInstructionDeclVarSrc *) { | 1074 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcDeclVar *) { |
| 909 | return IrInstructionIdDeclVarSrc; | 1075 | return IrInstSrcIdDeclVar; |
| | 1076 | } |
| | 1077 | |
| | 1078 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBr *) { |
| | 1079 | return IrInstSrcIdBr; |
| | 1080 | } |
| | 1081 | |
| | 1082 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCondBr *) { |
| | 1083 | return IrInstSrcIdCondBr; |
| | 1084 | } |
| | 1085 | |
| | 1086 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSwitchBr *) { |
| | 1087 | return IrInstSrcIdSwitchBr; |
| | 1088 | } |
| | 1089 | |
| | 1090 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSwitchVar *) { |
| | 1091 | return IrInstSrcIdSwitchVar; |
| | 1092 | } |
| | 1093 | |
| | 1094 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSwitchElseVar *) { |
| | 1095 | return IrInstSrcIdSwitchElseVar; |
| | 1096 | } |
| | 1097 | |
| | 1098 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSwitchTarget *) { |
| | 1099 | return IrInstSrcIdSwitchTarget; |
| | 1100 | } |
| | 1101 | |
| | 1102 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPhi *) { |
| | 1103 | return IrInstSrcIdPhi; |
| | 1104 | } |
| | 1105 | |
| | 1106 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUnOp *) { |
| | 1107 | return IrInstSrcIdUnOp; |
| | 1108 | } |
| | 1109 | |
| | 1110 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBinOp *) { |
| | 1111 | return IrInstSrcIdBinOp; |
| | 1112 | } |
| | 1113 | |
| | 1114 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMergeErrSets *) { |
| | 1115 | return IrInstSrcIdMergeErrSets; |
| | 1116 | } |
| | 1117 | |
| | 1118 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcLoadPtr *) { |
| | 1119 | return IrInstSrcIdLoadPtr; |
| | 1120 | } |
| | 1121 | |
| | 1122 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcStorePtr *) { |
| | 1123 | return IrInstSrcIdStorePtr; |
| | 1124 | } |
| | 1125 | |
| | 1126 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFieldPtr *) { |
| | 1127 | return IrInstSrcIdFieldPtr; |
| | 1128 | } |
| | 1129 | |
| | 1130 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcElemPtr *) { |
| | 1131 | return IrInstSrcIdElemPtr; |
| | 1132 | } |
| | 1133 | |
| | 1134 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcVarPtr *) { |
| | 1135 | return IrInstSrcIdVarPtr; |
| | 1136 | } |
| | 1137 | |
| | 1138 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCall *) { |
| | 1139 | return IrInstSrcIdCall; |
| | 1140 | } |
| | 1141 | |
| | 1142 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCallArgs *) { |
| | 1143 | return IrInstSrcIdCallArgs; |
| | 1144 | } |
| | 1145 | |
| | 1146 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCallExtra *) { |
| | 1147 | return IrInstSrcIdCallExtra; |
| | 1148 | } |
| | 1149 | |
| | 1150 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcConst *) { |
| | 1151 | return IrInstSrcIdConst; |
| | 1152 | } |
| | 1153 | |
| | 1154 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcReturn *) { |
| | 1155 | return IrInstSrcIdReturn; |
| | 1156 | } |
| | 1157 | |
| | 1158 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcContainerInitList *) { |
| | 1159 | return IrInstSrcIdContainerInitList; |
| | 1160 | } |
| | 1161 | |
| | 1162 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcContainerInitFields *) { |
| | 1163 | return IrInstSrcIdContainerInitFields; |
| | 1164 | } |
| | 1165 | |
| | 1166 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUnreachable *) { |
| | 1167 | return IrInstSrcIdUnreachable; |
| | 1168 | } |
| | 1169 | |
| | 1170 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTypeOf *) { |
| | 1171 | return IrInstSrcIdTypeOf; |
| | 1172 | } |
| | 1173 | |
| | 1174 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetCold *) { |
| | 1175 | return IrInstSrcIdSetCold; |
| | 1176 | } |
| | 1177 | |
| | 1178 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetRuntimeSafety *) { |
| | 1179 | return IrInstSrcIdSetRuntimeSafety; |
| | 1180 | } |
| | 1181 | |
| | 1182 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetFloatMode *) { |
| | 1183 | return IrInstSrcIdSetFloatMode; |
| | 1184 | } |
| | 1185 | |
| | 1186 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcArrayType *) { |
| | 1187 | return IrInstSrcIdArrayType; |
| | 1188 | } |
| | 1189 | |
| | 1190 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAnyFrameType *) { |
| | 1191 | return IrInstSrcIdAnyFrameType; |
| | 1192 | } |
| | 1193 | |
| | 1194 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSliceType *) { |
| | 1195 | return IrInstSrcIdSliceType; |
| | 1196 | } |
| | 1197 | |
| | 1198 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAsm *) { |
| | 1199 | return IrInstSrcIdAsm; |
| | 1200 | } |
| | 1201 | |
| | 1202 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSizeOf *) { |
| | 1203 | return IrInstSrcIdSizeOf; |
| | 1204 | } |
| | 1205 | |
| | 1206 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTestNonNull *) { |
| | 1207 | return IrInstSrcIdTestNonNull; |
| | 1208 | } |
| | 1209 | |
| | 1210 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcOptionalUnwrapPtr *) { |
| | 1211 | return IrInstSrcIdOptionalUnwrapPtr; |
| | 1212 | } |
| | 1213 | |
| | 1214 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcClz *) { |
| | 1215 | return IrInstSrcIdClz; |
| | 1216 | } |
| | 1217 | |
| | 1218 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCtz *) { |
| | 1219 | return IrInstSrcIdCtz; |
| | 1220 | } |
| | 1221 | |
| | 1222 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPopCount *) { |
| | 1223 | return IrInstSrcIdPopCount; |
| | 1224 | } |
| | 1225 | |
| | 1226 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBswap *) { |
| | 1227 | return IrInstSrcIdBswap; |
| | 1228 | } |
| | 1229 | |
| | 1230 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBitReverse *) { |
| | 1231 | return IrInstSrcIdBitReverse; |
| | 1232 | } |
| | 1233 | |
| | 1234 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcImport *) { |
| | 1235 | return IrInstSrcIdImport; |
| | 1236 | } |
| | 1237 | |
| | 1238 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCImport *) { |
| | 1239 | return IrInstSrcIdCImport; |
| | 1240 | } |
| | 1241 | |
| | 1242 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCInclude *) { |
| | 1243 | return IrInstSrcIdCInclude; |
| | 1244 | } |
| | 1245 | |
| | 1246 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCDefine *) { |
| | 1247 | return IrInstSrcIdCDefine; |
| | 1248 | } |
| | 1249 | |
| | 1250 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCUndef *) { |
| | 1251 | return IrInstSrcIdCUndef; |
| | 1252 | } |
| | 1253 | |
| | 1254 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcRef *) { |
| | 1255 | return IrInstSrcIdRef; |
| | 1256 | } |
| | 1257 | |
| | 1258 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCompileErr *) { |
| | 1259 | return IrInstSrcIdCompileErr; |
| | 1260 | } |
| | 1261 | |
| | 1262 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCompileLog *) { |
| | 1263 | return IrInstSrcIdCompileLog; |
| | 1264 | } |
| | 1265 | |
| | 1266 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrName *) { |
| | 1267 | return IrInstSrcIdErrName; |
| | 1268 | } |
| | 1269 | |
| | 1270 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcEmbedFile *) { |
| | 1271 | return IrInstSrcIdEmbedFile; |
| | 1272 | } |
| | 1273 | |
| | 1274 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCmpxchg *) { |
| | 1275 | return IrInstSrcIdCmpxchg; |
| | 1276 | } |
| | 1277 | |
| | 1278 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFence *) { |
| | 1279 | return IrInstSrcIdFence; |
| | 1280 | } |
| | 1281 | |
| | 1282 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTruncate *) { |
| | 1283 | return IrInstSrcIdTruncate; |
| | 1284 | } |
| | 1285 | |
| | 1286 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntCast *) { |
| | 1287 | return IrInstSrcIdIntCast; |
| | 1288 | } |
| | 1289 | |
| | 1290 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFloatCast *) { |
| | 1291 | return IrInstSrcIdFloatCast; |
| | 1292 | } |
| | 1293 | |
| | 1294 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntToFloat *) { |
| | 1295 | return IrInstSrcIdIntToFloat; |
| | 1296 | } |
| | 1297 | |
| | 1298 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFloatToInt *) { |
| | 1299 | return IrInstSrcIdFloatToInt; |
| | 1300 | } |
| | 1301 | |
| | 1302 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBoolToInt *) { |
| | 1303 | return IrInstSrcIdBoolToInt; |
| 910 | } | 1304 | } |
| 911 | | 1305 | |
| 912 | static constexpr IrInstructionId ir_instruction_id(IrInstructionDeclVarGen *) { | 1306 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntType *) { |
| 913 | return IrInstructionIdDeclVarGen; | 1307 | return IrInstSrcIdIntType; |
| 914 | } | 1308 | } |
| 915 | | 1309 | |
| 916 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCondBr *) { | 1310 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcVectorType *) { |
| 917 | return IrInstructionIdCondBr; | 1311 | return IrInstSrcIdVectorType; |
| 918 | } | 1312 | } |
| 919 | | 1313 | |
| 920 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBr *) { | 1314 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcShuffleVector *) { |
| 921 | return IrInstructionIdBr; | 1315 | return IrInstSrcIdShuffleVector; |
| 922 | } | 1316 | } |
| 923 | | 1317 | |
| 924 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSwitchBr *) { | 1318 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSplat *) { |
| 925 | return IrInstructionIdSwitchBr; | 1319 | return IrInstSrcIdSplat; |
| 926 | } | 1320 | } |
| 927 | | 1321 | |
| 928 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSwitchVar *) { | 1322 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBoolNot *) { |
| 929 | return IrInstructionIdSwitchVar; | 1323 | return IrInstSrcIdBoolNot; |
| 930 | } | 1324 | } |
| 931 | | 1325 | |
| 932 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSwitchElseVar *) { | 1326 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMemset *) { |
| 933 | return IrInstructionIdSwitchElseVar; | 1327 | return IrInstSrcIdMemset; |
| 934 | } | 1328 | } |
| 935 | | 1329 | |
| 936 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSwitchTarget *) { | 1330 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMemcpy *) { |
| 937 | return IrInstructionIdSwitchTarget; | 1331 | return IrInstSrcIdMemcpy; |
| 938 | } | 1332 | } |
| 939 | | 1333 | |
| 940 | static constexpr IrInstructionId ir_instruction_id(IrInstructionPhi *) { | 1334 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSlice *) { |
| 941 | return IrInstructionIdPhi; | 1335 | return IrInstSrcIdSlice; |
| 942 | } | 1336 | } |
| 943 | | 1337 | |
| 944 | static constexpr IrInstructionId ir_instruction_id(IrInstructionUnOp *) { | 1338 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMemberCount *) { |
| 945 | return IrInstructionIdUnOp; | 1339 | return IrInstSrcIdMemberCount; |
| 946 | } | 1340 | } |
| 947 | | 1341 | |
| 948 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBinOp *) { | 1342 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMemberType *) { |
| 949 | return IrInstructionIdBinOp; | 1343 | return IrInstSrcIdMemberType; |
| 950 | } | 1344 | } |
| 951 | | 1345 | |
| 952 | static constexpr IrInstructionId ir_instruction_id(IrInstructionMergeErrSets *) { | 1346 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMemberName *) { |
| 953 | return IrInstructionIdMergeErrSets; | 1347 | return IrInstSrcIdMemberName; |
| 954 | } | 1348 | } |
| 955 | | 1349 | |
| 956 | static constexpr IrInstructionId ir_instruction_id(IrInstructionExport *) { | 1350 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBreakpoint *) { |
| 957 | return IrInstructionIdExport; | 1351 | return IrInstSrcIdBreakpoint; |
| 958 | } | 1352 | } |
| 959 | | 1353 | |
| 960 | static constexpr IrInstructionId ir_instruction_id(IrInstructionLoadPtr *) { | 1354 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcReturnAddress *) { |
| 961 | return IrInstructionIdLoadPtr; | 1355 | return IrInstSrcIdReturnAddress; |
| 962 | } | 1356 | } |
| 963 | | 1357 | |
| 964 | static constexpr IrInstructionId ir_instruction_id(IrInstructionLoadPtrGen *) { | 1358 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFrameAddress *) { |
| 965 | return IrInstructionIdLoadPtrGen; | 1359 | return IrInstSrcIdFrameAddress; |
| 966 | } | 1360 | } |
| 967 | | 1361 | |
| 968 | static constexpr IrInstructionId ir_instruction_id(IrInstructionStorePtr *) { | 1362 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFrameHandle *) { |
| 969 | return IrInstructionIdStorePtr; | 1363 | return IrInstSrcIdFrameHandle; |
| 970 | } | 1364 | } |
| 971 | | 1365 | |
| 972 | static constexpr IrInstructionId ir_instruction_id(IrInstructionVectorStoreElem *) { | 1366 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFrameType *) { |
| 973 | return IrInstructionIdVectorStoreElem; | 1367 | return IrInstSrcIdFrameType; |
| 974 | } | 1368 | } |
| 975 | | 1369 | |
| 976 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFieldPtr *) { | 1370 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFrameSize *) { |
| 977 | return IrInstructionIdFieldPtr; | 1371 | return IrInstSrcIdFrameSize; |
| 978 | } | 1372 | } |
| 979 | | 1373 | |
| 980 | static constexpr IrInstructionId ir_instruction_id(IrInstructionStructFieldPtr *) { | 1374 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAlignOf *) { |
| 981 | return IrInstructionIdStructFieldPtr; | 1375 | return IrInstSrcIdAlignOf; |
| 982 | } | 1376 | } |
| 983 | | 1377 | |
| 984 | static constexpr IrInstructionId ir_instruction_id(IrInstructionUnionFieldPtr *) { | 1378 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcOverflowOp *) { |
| 985 | return IrInstructionIdUnionFieldPtr; | 1379 | return IrInstSrcIdOverflowOp; |
| 986 | } | 1380 | } |
| 987 | | 1381 | |
| 988 | static constexpr IrInstructionId ir_instruction_id(IrInstructionElemPtr *) { | 1382 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTestErr *) { |
| 989 | return IrInstructionIdElemPtr; | 1383 | return IrInstSrcIdTestErr; |
| 990 | } | 1384 | } |
| 991 | | 1385 | |
| 992 | static constexpr IrInstructionId ir_instruction_id(IrInstructionVarPtr *) { | 1386 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMulAdd *) { |
| 993 | return IrInstructionIdVarPtr; | 1387 | return IrInstSrcIdMulAdd; |
| 994 | } | 1388 | } |
| 995 | | 1389 | |
| 996 | static constexpr IrInstructionId ir_instruction_id(IrInstructionReturnPtr *) { | 1390 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFloatOp *) { |
| 997 | return IrInstructionIdReturnPtr; | 1391 | return IrInstSrcIdFloatOp; |
| 998 | } | 1392 | } |
| 999 | | 1393 | |
| 1000 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCallSrc *) { | 1394 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUnwrapErrCode *) { |
| 1001 | return IrInstructionIdCallSrc; | 1395 | return IrInstSrcIdUnwrapErrCode; |
| 1002 | } | 1396 | } |
| 1003 | | 1397 | |
| 1004 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCallSrcArgs *) { | 1398 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUnwrapErrPayload *) { |
| 1005 | return IrInstructionIdCallSrcArgs; | 1399 | return IrInstSrcIdUnwrapErrPayload; |
| 1006 | } | 1400 | } |
| 1007 | | 1401 | |
| 1008 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCallExtra *) { | 1402 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFnProto *) { |
| 1009 | return IrInstructionIdCallExtra; | 1403 | return IrInstSrcIdFnProto; |
| 1010 | } | 1404 | } |
| 1011 | | 1405 | |
| 1012 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCallGen *) { | 1406 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTestComptime *) { |
| 1013 | return IrInstructionIdCallGen; | 1407 | return IrInstSrcIdTestComptime; |
| 1014 | } | 1408 | } |
| 1015 | | 1409 | |
| 1016 | static constexpr IrInstructionId ir_instruction_id(IrInstructionConst *) { | 1410 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPtrCast *) { |
| 1017 | return IrInstructionIdConst; | 1411 | return IrInstSrcIdPtrCast; |
| 1018 | } | 1412 | } |
| 1019 | | 1413 | |
| 1020 | static constexpr IrInstructionId ir_instruction_id(IrInstructionReturn *) { | 1414 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBitCast *) { |
| 1021 | return IrInstructionIdReturn; | 1415 | return IrInstSrcIdBitCast; |
| 1022 | } | 1416 | } |
| 1023 | | 1417 | |
| 1024 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCast *) { | 1418 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntToPtr *) { |
| 1025 | return IrInstructionIdCast; | 1419 | return IrInstSrcIdIntToPtr; |
| 1026 | } | 1420 | } |
| 1027 | | 1421 | |
| 1028 | static constexpr IrInstructionId ir_instruction_id(IrInstructionResizeSlice *) { | 1422 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPtrToInt *) { |
| 1029 | return IrInstructionIdResizeSlice; | 1423 | return IrInstSrcIdPtrToInt; |
| 1030 | } | 1424 | } |
| 1031 | | 1425 | |
| 1032 | static constexpr IrInstructionId ir_instruction_id(IrInstructionContainerInitList *) { | 1426 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntToEnum *) { |
| 1033 | return IrInstructionIdContainerInitList; | 1427 | return IrInstSrcIdIntToEnum; |
| 1034 | } | 1428 | } |
| 1035 | | 1429 | |
| 1036 | static constexpr IrInstructionId ir_instruction_id(IrInstructionContainerInitFields *) { | 1430 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcEnumToInt *) { |
| 1037 | return IrInstructionIdContainerInitFields; | 1431 | return IrInstSrcIdEnumToInt; |
| 1038 | } | 1432 | } |
| 1039 | | 1433 | |
| 1040 | static constexpr IrInstructionId ir_instruction_id(IrInstructionUnreachable *) { | 1434 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntToErr *) { |
| 1041 | return IrInstructionIdUnreachable; | 1435 | return IrInstSrcIdIntToErr; |
| 1042 | } | 1436 | } |
| 1043 | | 1437 | |
| 1044 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTypeOf *) { | 1438 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrToInt *) { |
| 1045 | return IrInstructionIdTypeOf; | 1439 | return IrInstSrcIdErrToInt; |
| 1046 | } | 1440 | } |
| 1047 | | 1441 | |
| 1048 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSetCold *) { | 1442 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCheckSwitchProngs *) { |
| 1049 | return IrInstructionIdSetCold; | 1443 | return IrInstSrcIdCheckSwitchProngs; |
| 1050 | } | 1444 | } |
| 1051 | | 1445 | |
| 1052 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSetRuntimeSafety *) { | 1446 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCheckStatementIsVoid *) { |
| 1053 | return IrInstructionIdSetRuntimeSafety; | 1447 | return IrInstSrcIdCheckStatementIsVoid; |
| 1054 | } | 1448 | } |
| 1055 | | 1449 | |
| 1056 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSetFloatMode *) { | 1450 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTypeName *) { |
| 1057 | return IrInstructionIdSetFloatMode; | 1451 | return IrInstSrcIdTypeName; |
| 1058 | } | 1452 | } |
| 1059 | | 1453 | |
| 1060 | static constexpr IrInstructionId ir_instruction_id(IrInstructionArrayType *) { | 1454 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcDeclRef *) { |
| 1061 | return IrInstructionIdArrayType; | 1455 | return IrInstSrcIdDeclRef; |
| 1062 | } | 1456 | } |
| 1063 | | 1457 | |
| 1064 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAnyFrameType *) { | 1458 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPanic *) { |
| 1065 | return IrInstructionIdAnyFrameType; | 1459 | return IrInstSrcIdPanic; |
| 1066 | } | 1460 | } |
| 1067 | | 1461 | |
| 1068 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSliceType *) { | 1462 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTagName *) { |
| 1069 | return IrInstructionIdSliceType; | 1463 | return IrInstSrcIdTagName; |
| 1070 | } | 1464 | } |
| 1071 | | 1465 | |
| 1072 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAsmSrc *) { | 1466 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTagType *) { |
| 1073 | return IrInstructionIdAsmSrc; | 1467 | return IrInstSrcIdTagType; |
| 1074 | } | 1468 | } |
| 1075 | | 1469 | |
| 1076 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAsmGen *) { | 1470 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFieldParentPtr *) { |
| 1077 | return IrInstructionIdAsmGen; | 1471 | return IrInstSrcIdFieldParentPtr; |
| 1078 | } | 1472 | } |
| 1079 | | 1473 | |
| 1080 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSizeOf *) { | 1474 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcByteOffsetOf *) { |
| 1081 | return IrInstructionIdSizeOf; | 1475 | return IrInstSrcIdByteOffsetOf; |
| 1082 | } | 1476 | } |
| 1083 | | 1477 | |
| 1084 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTestNonNull *) { | 1478 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBitOffsetOf *) { |
| 1085 | return IrInstructionIdTestNonNull; | 1479 | return IrInstSrcIdBitOffsetOf; |
| 1086 | } | 1480 | } |
| 1087 | | 1481 | |
| 1088 | static constexpr IrInstructionId ir_instruction_id(IrInstructionOptionalUnwrapPtr *) { | 1482 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTypeInfo *) { |
| 1089 | return IrInstructionIdOptionalUnwrapPtr; | 1483 | return IrInstSrcIdTypeInfo; |
| 1090 | } | 1484 | } |
| 1091 | | 1485 | |
| 1092 | static constexpr IrInstructionId ir_instruction_id(IrInstructionClz *) { | 1486 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcType *) { |
| 1093 | return IrInstructionIdClz; | 1487 | return IrInstSrcIdType; |
| 1094 | } | 1488 | } |
| 1095 | | 1489 | |
| 1096 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCtz *) { | 1490 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcHasField *) { |
| 1097 | return IrInstructionIdCtz; | 1491 | return IrInstSrcIdHasField; |
| 1098 | } | 1492 | } |
| 1099 | | 1493 | |
| 1100 | static constexpr IrInstructionId ir_instruction_id(IrInstructionPopCount *) { | 1494 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTypeId *) { |
| 1101 | return IrInstructionIdPopCount; | 1495 | return IrInstSrcIdTypeId; |
| 1102 | } | 1496 | } |
| 1103 | | 1497 | |
| 1104 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBswap *) { | 1498 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetEvalBranchQuota *) { |
| 1105 | return IrInstructionIdBswap; | 1499 | return IrInstSrcIdSetEvalBranchQuota; |
| 1106 | } | 1500 | } |
| 1107 | | 1501 | |
| 1108 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBitReverse *) { | 1502 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPtrType *) { |
| 1109 | return IrInstructionIdBitReverse; | 1503 | return IrInstSrcIdPtrType; |
| 1110 | } | 1504 | } |
| 1111 | | 1505 | |
| 1112 | static constexpr IrInstructionId ir_instruction_id(IrInstructionUnionTag *) { | 1506 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAlignCast *) { |
| 1113 | return IrInstructionIdUnionTag; | 1507 | return IrInstSrcIdAlignCast; |
| 1114 | } | 1508 | } |
| 1115 | | 1509 | |
| 1116 | static constexpr IrInstructionId ir_instruction_id(IrInstructionImport *) { | 1510 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcImplicitCast *) { |
| 1117 | return IrInstructionIdImport; | 1511 | return IrInstSrcIdImplicitCast; |
| 1118 | } | 1512 | } |
| 1119 | | 1513 | |
| 1120 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCImport *) { | 1514 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcResolveResult *) { |
| 1121 | return IrInstructionIdCImport; | 1515 | return IrInstSrcIdResolveResult; |
| 1122 | } | 1516 | } |
| 1123 | | 1517 | |
| 1124 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCInclude *) { | 1518 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcResetResult *) { |
| 1125 | return IrInstructionIdCInclude; | 1519 | return IrInstSrcIdResetResult; |
| 1126 | } | 1520 | } |
| 1127 | | 1521 | |
| 1128 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCDefine *) { | 1522 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcOpaqueType *) { |
| 1129 | return IrInstructionIdCDefine; | 1523 | return IrInstSrcIdOpaqueType; |
| 1130 | } | 1524 | } |
| 1131 | | 1525 | |
| 1132 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCUndef *) { | 1526 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetAlignStack *) { |
| 1133 | return IrInstructionIdCUndef; | 1527 | return IrInstSrcIdSetAlignStack; |
| 1134 | } | 1528 | } |
| 1135 | | 1529 | |
| 1136 | static constexpr IrInstructionId ir_instruction_id(IrInstructionRef *) { | 1530 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcArgType *) { |
| 1137 | return IrInstructionIdRef; | 1531 | return IrInstSrcIdArgType; |
| 1138 | } | 1532 | } |
| 1139 | | 1533 | |
| 1140 | static constexpr IrInstructionId ir_instruction_id(IrInstructionRefGen *) { | 1534 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcExport *) { |
| 1141 | return IrInstructionIdRefGen; | 1535 | return IrInstSrcIdExport; |
| 1142 | } | 1536 | } |
| 1143 | | 1537 | |
| 1144 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCompileErr *) { | 1538 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrorReturnTrace *) { |
| 1145 | return IrInstructionIdCompileErr; | 1539 | return IrInstSrcIdErrorReturnTrace; |
| 1146 | } | 1540 | } |
| 1147 | | 1541 | |
| 1148 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCompileLog *) { | 1542 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrorUnion *) { |
| 1149 | return IrInstructionIdCompileLog; | 1543 | return IrInstSrcIdErrorUnion; |
| 1150 | } | 1544 | } |
| 1151 | | 1545 | |
| 1152 | static constexpr IrInstructionId ir_instruction_id(IrInstructionErrName *) { | 1546 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAtomicRmw *) { |
| 1153 | return IrInstructionIdErrName; | 1547 | return IrInstSrcIdAtomicRmw; |
| 1154 | } | 1548 | } |
| 1155 | | 1549 | |
| 1156 | static constexpr IrInstructionId ir_instruction_id(IrInstructionEmbedFile *) { | 1550 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAtomicLoad *) { |
| 1157 | return IrInstructionIdEmbedFile; | 1551 | return IrInstSrcIdAtomicLoad; |
| 1158 | } | 1552 | } |
| 1159 | | 1553 | |
| 1160 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCmpxchgSrc *) { | 1554 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAtomicStore *) { |
| 1161 | return IrInstructionIdCmpxchgSrc; | 1555 | return IrInstSrcIdAtomicStore; |
| 1162 | } | 1556 | } |
| 1163 | | 1557 | |
| 1164 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCmpxchgGen *) { | 1558 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSaveErrRetAddr *) { |
| 1165 | return IrInstructionIdCmpxchgGen; | 1559 | return IrInstSrcIdSaveErrRetAddr; |
| 1166 | } | 1560 | } |
| 1167 | | 1561 | |
| 1168 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFence *) { | 1562 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAddImplicitReturnType *) { |
| 1169 | return IrInstructionIdFence; | 1563 | return IrInstSrcIdAddImplicitReturnType; |
| 1170 | } | 1564 | } |
| 1171 | | 1565 | |
| 1172 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTruncate *) { | 1566 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrSetCast *) { |
| 1173 | return IrInstructionIdTruncate; | 1567 | return IrInstSrcIdErrSetCast; |
| 1174 | } | 1568 | } |
| 1175 | | 1569 | |
| 1176 | static constexpr IrInstructionId ir_instruction_id(IrInstructionIntCast *) { | 1570 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcToBytes *) { |
| 1177 | return IrInstructionIdIntCast; | 1571 | return IrInstSrcIdToBytes; |
| 1178 | } | 1572 | } |
| 1179 | | 1573 | |
| 1180 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFloatCast *) { | 1574 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFromBytes *) { |
| 1181 | return IrInstructionIdFloatCast; | 1575 | return IrInstSrcIdFromBytes; |
| 1182 | } | 1576 | } |
| 1183 | | 1577 | |
| 1184 | static constexpr IrInstructionId ir_instruction_id(IrInstructionErrSetCast *) { | 1578 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCheckRuntimeScope *) { |
| 1185 | return IrInstructionIdErrSetCast; | 1579 | return IrInstSrcIdCheckRuntimeScope; |
| 1186 | } | 1580 | } |
| 1187 | | 1581 | |
| 1188 | static constexpr IrInstructionId ir_instruction_id(IrInstructionToBytes *) { | 1582 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcHasDecl *) { |
| 1189 | return IrInstructionIdToBytes; | 1583 | return IrInstSrcIdHasDecl; |
| 1190 | } | 1584 | } |
| 1191 | | 1585 | |
| 1192 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFromBytes *) { | 1586 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUndeclaredIdent *) { |
| 1193 | return IrInstructionIdFromBytes; | 1587 | return IrInstSrcIdUndeclaredIdent; |
| 1194 | } | 1588 | } |
| 1195 | | 1589 | |
| 1196 | static constexpr IrInstructionId ir_instruction_id(IrInstructionIntToFloat *) { | 1590 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAlloca *) { |
| 1197 | return IrInstructionIdIntToFloat; | 1591 | return IrInstSrcIdAlloca; |
| 1198 | } | 1592 | } |
| 1199 | | 1593 | |
| 1200 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFloatToInt *) { | 1594 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcEndExpr *) { |
| 1201 | return IrInstructionIdFloatToInt; | 1595 | return IrInstSrcIdEndExpr; |
| 1202 | } | 1596 | } |
| 1203 | | 1597 | |
| 1204 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBoolToInt *) { | 1598 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUnionInitNamedField *) { |
| 1205 | return IrInstructionIdBoolToInt; | 1599 | return IrInstSrcIdUnionInitNamedField; |
| 1206 | } | 1600 | } |
| 1207 | | 1601 | |
| 1208 | static constexpr IrInstructionId ir_instruction_id(IrInstructionIntType *) { | 1602 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSuspendBegin *) { |
| 1209 | return IrInstructionIdIntType; | 1603 | return IrInstSrcIdSuspendBegin; |
| 1210 | } | 1604 | } |
| 1211 | | 1605 | |
| 1212 | static constexpr IrInstructionId ir_instruction_id(IrInstructionVectorType *) { | 1606 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSuspendFinish *) { |
| 1213 | return IrInstructionIdVectorType; | 1607 | return IrInstSrcIdSuspendFinish; |
| 1214 | } | 1608 | } |
| 1215 | | 1609 | |
| 1216 | static constexpr IrInstructionId ir_instruction_id(IrInstructionShuffleVector *) { | 1610 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAwait *) { |
| 1217 | return IrInstructionIdShuffleVector; | 1611 | return IrInstSrcIdAwait; |
| 1218 | } | 1612 | } |
| 1219 | | 1613 | |
| 1220 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSplatSrc *) { | 1614 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcResume *) { |
| 1221 | return IrInstructionIdSplatSrc; | 1615 | return IrInstSrcIdResume; |
| 1222 | } | 1616 | } |
| 1223 | | 1617 | |
| 1224 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSplatGen *) { | 1618 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSpillBegin *) { |
| 1225 | return IrInstructionIdSplatGen; | 1619 | return IrInstSrcIdSpillBegin; |
| 1226 | } | 1620 | } |
| 1227 | | 1621 | |
| 1228 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBoolNot *) { | 1622 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSpillEnd *) { |
| 1229 | return IrInstructionIdBoolNot; | 1623 | return IrInstSrcIdSpillEnd; |
| 1230 | } | 1624 | } |
| 1231 | | 1625 | |
| 1232 | static constexpr IrInstructionId ir_instruction_id(IrInstructionMemset *) { | 1626 | |
| 1233 | return IrInstructionIdMemset; | 1627 | static constexpr IrInstGenId ir_inst_id(IrInstGenDeclVar *) { |
| | 1628 | return IrInstGenIdDeclVar; |
| 1234 | } | 1629 | } |
| 1235 | | 1630 | |
| 1236 | static constexpr IrInstructionId ir_instruction_id(IrInstructionMemcpy *) { | 1631 | static constexpr IrInstGenId ir_inst_id(IrInstGenBr *) { |
| 1237 | return IrInstructionIdMemcpy; | 1632 | return IrInstGenIdBr; |
| 1238 | } | 1633 | } |
| 1239 | | 1634 | |
| 1240 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSliceSrc *) { | 1635 | static constexpr IrInstGenId ir_inst_id(IrInstGenCondBr *) { |
| 1241 | return IrInstructionIdSliceSrc; | 1636 | return IrInstGenIdCondBr; |
| 1242 | } | 1637 | } |
| 1243 | | 1638 | |
| 1244 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSliceGen *) { | 1639 | static constexpr IrInstGenId ir_inst_id(IrInstGenSwitchBr *) { |
| 1245 | return IrInstructionIdSliceGen; | 1640 | return IrInstGenIdSwitchBr; |
| 1246 | } | 1641 | } |
| 1247 | | 1642 | |
| 1248 | static constexpr IrInstructionId ir_instruction_id(IrInstructionMemberCount *) { | 1643 | static constexpr IrInstGenId ir_inst_id(IrInstGenPhi *) { |
| 1249 | return IrInstructionIdMemberCount; | 1644 | return IrInstGenIdPhi; |
| 1250 | } | 1645 | } |
| 1251 | | 1646 | |
| 1252 | static constexpr IrInstructionId ir_instruction_id(IrInstructionMemberType *) { | 1647 | static constexpr IrInstGenId ir_inst_id(IrInstGenBinaryNot *) { |
| 1253 | return IrInstructionIdMemberType; | 1648 | return IrInstGenIdBinaryNot; |
| 1254 | } | 1649 | } |
| 1255 | | 1650 | |
| 1256 | static constexpr IrInstructionId ir_instruction_id(IrInstructionMemberName *) { | 1651 | static constexpr IrInstGenId ir_inst_id(IrInstGenNegation *) { |
| 1257 | return IrInstructionIdMemberName; | 1652 | return IrInstGenIdNegation; |
| 1258 | } | 1653 | } |
| 1259 | | 1654 | |
| 1260 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBreakpoint *) { | 1655 | static constexpr IrInstGenId ir_inst_id(IrInstGenNegationWrapping *) { |
| 1261 | return IrInstructionIdBreakpoint; | 1656 | return IrInstGenIdNegationWrapping; |
| 1262 | } | 1657 | } |
| 1263 | | 1658 | |
| 1264 | static constexpr IrInstructionId ir_instruction_id(IrInstructionReturnAddress *) { | 1659 | static constexpr IrInstGenId ir_inst_id(IrInstGenBinOp *) { |
| 1265 | return IrInstructionIdReturnAddress; | 1660 | return IrInstGenIdBinOp; |
| 1266 | } | 1661 | } |
| 1267 | | 1662 | |
| 1268 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFrameAddress *) { | 1663 | static constexpr IrInstGenId ir_inst_id(IrInstGenLoadPtr *) { |
| 1269 | return IrInstructionIdFrameAddress; | 1664 | return IrInstGenIdLoadPtr; |
| 1270 | } | 1665 | } |
| 1271 | | 1666 | |
| 1272 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFrameHandle *) { | 1667 | static constexpr IrInstGenId ir_inst_id(IrInstGenStorePtr *) { |
| 1273 | return IrInstructionIdFrameHandle; | 1668 | return IrInstGenIdStorePtr; |
| 1274 | } | 1669 | } |
| 1275 | | 1670 | |
| 1276 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFrameType *) { | 1671 | static constexpr IrInstGenId ir_inst_id(IrInstGenVectorStoreElem *) { |
| 1277 | return IrInstructionIdFrameType; | 1672 | return IrInstGenIdVectorStoreElem; |
| 1278 | } | 1673 | } |
| 1279 | | 1674 | |
| 1280 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFrameSizeSrc *) { | 1675 | static constexpr IrInstGenId ir_inst_id(IrInstGenStructFieldPtr *) { |
| 1281 | return IrInstructionIdFrameSizeSrc; | 1676 | return IrInstGenIdStructFieldPtr; |
| 1282 | } | 1677 | } |
| 1283 | | 1678 | |
| 1284 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFrameSizeGen *) { | 1679 | static constexpr IrInstGenId ir_inst_id(IrInstGenUnionFieldPtr *) { |
| 1285 | return IrInstructionIdFrameSizeGen; | 1680 | return IrInstGenIdUnionFieldPtr; |
| 1286 | } | 1681 | } |
| 1287 | | 1682 | |
| 1288 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAlignOf *) { | 1683 | static constexpr IrInstGenId ir_inst_id(IrInstGenElemPtr *) { |
| 1289 | return IrInstructionIdAlignOf; | 1684 | return IrInstGenIdElemPtr; |
| 1290 | } | 1685 | } |
| 1291 | | 1686 | |
| 1292 | static constexpr IrInstructionId ir_instruction_id(IrInstructionOverflowOp *) { | 1687 | static constexpr IrInstGenId ir_inst_id(IrInstGenVarPtr *) { |
| 1293 | return IrInstructionIdOverflowOp; | 1688 | return IrInstGenIdVarPtr; |
| 1294 | } | 1689 | } |
| 1295 | | 1690 | |
| 1296 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTestErrSrc *) { | 1691 | static constexpr IrInstGenId ir_inst_id(IrInstGenReturnPtr *) { |
| 1297 | return IrInstructionIdTestErrSrc; | 1692 | return IrInstGenIdReturnPtr; |
| 1298 | } | 1693 | } |
| 1299 | | 1694 | |
| 1300 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTestErrGen *) { | 1695 | static constexpr IrInstGenId ir_inst_id(IrInstGenCall *) { |
| 1301 | return IrInstructionIdTestErrGen; | 1696 | return IrInstGenIdCall; |
| 1302 | } | 1697 | } |
| 1303 | | 1698 | |
| 1304 | static constexpr IrInstructionId ir_instruction_id(IrInstructionMulAdd *) { | 1699 | static constexpr IrInstGenId ir_inst_id(IrInstGenReturn *) { |
| 1305 | return IrInstructionIdMulAdd; | 1700 | return IrInstGenIdReturn; |
| 1306 | } | 1701 | } |
| 1307 | | 1702 | |
| 1308 | static constexpr IrInstructionId ir_instruction_id(IrInstructionUnwrapErrCode *) { | 1703 | static constexpr IrInstGenId ir_inst_id(IrInstGenCast *) { |
| 1309 | return IrInstructionIdUnwrapErrCode; | 1704 | return IrInstGenIdCast; |
| 1310 | } | 1705 | } |
| 1311 | | 1706 | |
| 1312 | static constexpr IrInstructionId ir_instruction_id(IrInstructionUnwrapErrPayload *) { | 1707 | static constexpr IrInstGenId ir_inst_id(IrInstGenResizeSlice *) { |
| 1313 | return IrInstructionIdUnwrapErrPayload; | 1708 | return IrInstGenIdResizeSlice; |
| 1314 | } | 1709 | } |
| 1315 | | 1710 | |
| 1316 | static constexpr IrInstructionId ir_instruction_id(IrInstructionOptionalWrap *) { | 1711 | static constexpr IrInstGenId ir_inst_id(IrInstGenUnreachable *) { |
| 1317 | return IrInstructionIdOptionalWrap; | 1712 | return IrInstGenIdUnreachable; |
| 1318 | } | 1713 | } |
| 1319 | | 1714 | |
| 1320 | static constexpr IrInstructionId ir_instruction_id(IrInstructionErrWrapPayload *) { | 1715 | static constexpr IrInstGenId ir_inst_id(IrInstGenAsm *) { |
| 1321 | return IrInstructionIdErrWrapPayload; | 1716 | return IrInstGenIdAsm; |
| 1322 | } | 1717 | } |
| 1323 | | 1718 | |
| 1324 | static constexpr IrInstructionId ir_instruction_id(IrInstructionErrWrapCode *) { | 1719 | static constexpr IrInstGenId ir_inst_id(IrInstGenTestNonNull *) { |
| 1325 | return IrInstructionIdErrWrapCode; | 1720 | return IrInstGenIdTestNonNull; |
| 1326 | } | 1721 | } |
| 1327 | | 1722 | |
| 1328 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFnProto *) { | 1723 | static constexpr IrInstGenId ir_inst_id(IrInstGenOptionalUnwrapPtr *) { |
| 1329 | return IrInstructionIdFnProto; | 1724 | return IrInstGenIdOptionalUnwrapPtr; |
| 1330 | } | 1725 | } |
| 1331 | | 1726 | |
| 1332 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTestComptime *) { | 1727 | static constexpr IrInstGenId ir_inst_id(IrInstGenOptionalWrap *) { |
| 1333 | return IrInstructionIdTestComptime; | 1728 | return IrInstGenIdOptionalWrap; |
| 1334 | } | 1729 | } |
| 1335 | | 1730 | |
| 1336 | static constexpr IrInstructionId ir_instruction_id(IrInstructionPtrCastSrc *) { | 1731 | static constexpr IrInstGenId ir_inst_id(IrInstGenUnionTag *) { |
| 1337 | return IrInstructionIdPtrCastSrc; | 1732 | return IrInstGenIdUnionTag; |
| 1338 | } | 1733 | } |
| 1339 | | 1734 | |
| 1340 | static constexpr IrInstructionId ir_instruction_id(IrInstructionPtrCastGen *) { | 1735 | static constexpr IrInstGenId ir_inst_id(IrInstGenClz *) { |
| 1341 | return IrInstructionIdPtrCastGen; | 1736 | return IrInstGenIdClz; |
| 1342 | } | 1737 | } |
| 1343 | | 1738 | |
| 1344 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBitCastSrc *) { | 1739 | static constexpr IrInstGenId ir_inst_id(IrInstGenCtz *) { |
| 1345 | return IrInstructionIdBitCastSrc; | 1740 | return IrInstGenIdCtz; |
| 1346 | } | 1741 | } |
| 1347 | | 1742 | |
| 1348 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBitCastGen *) { | 1743 | static constexpr IrInstGenId ir_inst_id(IrInstGenPopCount *) { |
| 1349 | return IrInstructionIdBitCastGen; | 1744 | return IrInstGenIdPopCount; |
| 1350 | } | 1745 | } |
| 1351 | | 1746 | |
| 1352 | static constexpr IrInstructionId ir_instruction_id(IrInstructionWidenOrShorten *) { | 1747 | static constexpr IrInstGenId ir_inst_id(IrInstGenBswap *) { |
| 1353 | return IrInstructionIdWidenOrShorten; | 1748 | return IrInstGenIdBswap; |
| 1354 | } | 1749 | } |
| 1355 | | 1750 | |
| 1356 | static constexpr IrInstructionId ir_instruction_id(IrInstructionPtrToInt *) { | 1751 | static constexpr IrInstGenId ir_inst_id(IrInstGenBitReverse *) { |
| 1357 | return IrInstructionIdPtrToInt; | 1752 | return IrInstGenIdBitReverse; |
| 1358 | } | 1753 | } |
| 1359 | | 1754 | |
| 1360 | static constexpr IrInstructionId ir_instruction_id(IrInstructionIntToPtr *) { | 1755 | static constexpr IrInstGenId ir_inst_id(IrInstGenRef *) { |
| 1361 | return IrInstructionIdIntToPtr; | 1756 | return IrInstGenIdRef; |
| 1362 | } | 1757 | } |
| 1363 | | 1758 | |
| 1364 | static constexpr IrInstructionId ir_instruction_id(IrInstructionIntToEnum *) { | 1759 | static constexpr IrInstGenId ir_inst_id(IrInstGenErrName *) { |
| 1365 | return IrInstructionIdIntToEnum; | 1760 | return IrInstGenIdErrName; |
| 1366 | } | 1761 | } |
| 1367 | | 1762 | |
| 1368 | static constexpr IrInstructionId ir_instruction_id(IrInstructionEnumToInt *) { | 1763 | static constexpr IrInstGenId ir_inst_id(IrInstGenCmpxchg *) { |
| 1369 | return IrInstructionIdEnumToInt; | 1764 | return IrInstGenIdCmpxchg; |
| 1370 | } | 1765 | } |
| 1371 | | 1766 | |
| 1372 | static constexpr IrInstructionId ir_instruction_id(IrInstructionIntToErr *) { | 1767 | static constexpr IrInstGenId ir_inst_id(IrInstGenFence *) { |
| 1373 | return IrInstructionIdIntToErr; | 1768 | return IrInstGenIdFence; |
| 1374 | } | 1769 | } |
| 1375 | | 1770 | |
| 1376 | static constexpr IrInstructionId ir_instruction_id(IrInstructionErrToInt *) { | 1771 | static constexpr IrInstGenId ir_inst_id(IrInstGenTruncate *) { |
| 1377 | return IrInstructionIdErrToInt; | 1772 | return IrInstGenIdTruncate; |
| 1378 | } | 1773 | } |
| 1379 | | 1774 | |
| 1380 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCheckSwitchProngs *) { | 1775 | static constexpr IrInstGenId ir_inst_id(IrInstGenShuffleVector *) { |
| 1381 | return IrInstructionIdCheckSwitchProngs; | 1776 | return IrInstGenIdShuffleVector; |
| 1382 | } | 1777 | } |
| 1383 | | 1778 | |
| 1384 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCheckStatementIsVoid *) { | 1779 | static constexpr IrInstGenId ir_inst_id(IrInstGenSplat *) { |
| 1385 | return IrInstructionIdCheckStatementIsVoid; | 1780 | return IrInstGenIdSplat; |
| 1386 | } | 1781 | } |
| 1387 | | 1782 | |
| 1388 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTypeName *) { | 1783 | static constexpr IrInstGenId ir_inst_id(IrInstGenBoolNot *) { |
| 1389 | return IrInstructionIdTypeName; | 1784 | return IrInstGenIdBoolNot; |
| 1390 | } | 1785 | } |
| 1391 | | 1786 | |
| 1392 | static constexpr IrInstructionId ir_instruction_id(IrInstructionDeclRef *) { | 1787 | static constexpr IrInstGenId ir_inst_id(IrInstGenMemset *) { |
| 1393 | return IrInstructionIdDeclRef; | 1788 | return IrInstGenIdMemset; |
| 1394 | } | 1789 | } |
| 1395 | | 1790 | |
| 1396 | static constexpr IrInstructionId ir_instruction_id(IrInstructionPanic *) { | 1791 | static constexpr IrInstGenId ir_inst_id(IrInstGenMemcpy *) { |
| 1397 | return IrInstructionIdPanic; | 1792 | return IrInstGenIdMemcpy; |
| 1398 | } | 1793 | } |
| 1399 | | 1794 | |
| 1400 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTagName *) { | 1795 | static constexpr IrInstGenId ir_inst_id(IrInstGenSlice *) { |
| 1401 | return IrInstructionIdTagName; | 1796 | return IrInstGenIdSlice; |
| 1402 | } | 1797 | } |
| 1403 | | 1798 | |
| 1404 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTagType *) { | 1799 | static constexpr IrInstGenId ir_inst_id(IrInstGenBreakpoint *) { |
| 1405 | return IrInstructionIdTagType; | 1800 | return IrInstGenIdBreakpoint; |
| 1406 | } | 1801 | } |
| 1407 | | 1802 | |
| 1408 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFieldParentPtr *) { | 1803 | static constexpr IrInstGenId ir_inst_id(IrInstGenReturnAddress *) { |
| 1409 | return IrInstructionIdFieldParentPtr; | 1804 | return IrInstGenIdReturnAddress; |
| 1410 | } | 1805 | } |
| 1411 | | 1806 | |
| 1412 | static constexpr IrInstructionId ir_instruction_id(IrInstructionByteOffsetOf *) { | 1807 | static constexpr IrInstGenId ir_inst_id(IrInstGenFrameAddress *) { |
| 1413 | return IrInstructionIdByteOffsetOf; | 1808 | return IrInstGenIdFrameAddress; |
| 1414 | } | 1809 | } |
| 1415 | | 1810 | |
| 1416 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBitOffsetOf *) { | 1811 | static constexpr IrInstGenId ir_inst_id(IrInstGenFrameHandle *) { |
| 1417 | return IrInstructionIdBitOffsetOf; | 1812 | return IrInstGenIdFrameHandle; |
| 1418 | } | 1813 | } |
| 1419 | | 1814 | |
| 1420 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTypeInfo *) { | 1815 | static constexpr IrInstGenId ir_inst_id(IrInstGenFrameSize *) { |
| 1421 | return IrInstructionIdTypeInfo; | 1816 | return IrInstGenIdFrameSize; |
| 1422 | } | 1817 | } |
| 1423 | | 1818 | |
| 1424 | static constexpr IrInstructionId ir_instruction_id(IrInstructionType *) { | 1819 | static constexpr IrInstGenId ir_inst_id(IrInstGenOverflowOp *) { |
| 1425 | return IrInstructionIdType; | 1820 | return IrInstGenIdOverflowOp; |
| 1426 | } | 1821 | } |
| 1427 | | 1822 | |
| 1428 | static constexpr IrInstructionId ir_instruction_id(IrInstructionHasField *) { | 1823 | static constexpr IrInstGenId ir_inst_id(IrInstGenTestErr *) { |
| 1429 | return IrInstructionIdHasField; | 1824 | return IrInstGenIdTestErr; |
| 1430 | } | 1825 | } |
| 1431 | | 1826 | |
| 1432 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTypeId *) { | 1827 | static constexpr IrInstGenId ir_inst_id(IrInstGenMulAdd *) { |
| 1433 | return IrInstructionIdTypeId; | 1828 | return IrInstGenIdMulAdd; |
| 1434 | } | 1829 | } |
| 1435 | | 1830 | |
| 1436 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSetEvalBranchQuota *) { | 1831 | static constexpr IrInstGenId ir_inst_id(IrInstGenFloatOp *) { |
| 1437 | return IrInstructionIdSetEvalBranchQuota; | 1832 | return IrInstGenIdFloatOp; |
| 1438 | } | 1833 | } |
| 1439 | | 1834 | |
| 1440 | static constexpr IrInstructionId ir_instruction_id(IrInstructionPtrType *) { | 1835 | static constexpr IrInstGenId ir_inst_id(IrInstGenUnwrapErrCode *) { |
| 1441 | return IrInstructionIdPtrType; | 1836 | return IrInstGenIdUnwrapErrCode; |
| 1442 | } | 1837 | } |
| 1443 | | 1838 | |
| 1444 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAlignCast *) { | 1839 | static constexpr IrInstGenId ir_inst_id(IrInstGenUnwrapErrPayload *) { |
| 1445 | return IrInstructionIdAlignCast; | 1840 | return IrInstGenIdUnwrapErrPayload; |
| 1446 | } | 1841 | } |
| 1447 | | 1842 | |
| 1448 | static constexpr IrInstructionId ir_instruction_id(IrInstructionImplicitCast *) { | 1843 | static constexpr IrInstGenId ir_inst_id(IrInstGenErrWrapCode *) { |
| 1449 | return IrInstructionIdImplicitCast; | 1844 | return IrInstGenIdErrWrapCode; |
| 1450 | } | 1845 | } |
| 1451 | | 1846 | |
| 1452 | static constexpr IrInstructionId ir_instruction_id(IrInstructionResolveResult *) { | 1847 | static constexpr IrInstGenId ir_inst_id(IrInstGenErrWrapPayload *) { |
| 1453 | return IrInstructionIdResolveResult; | 1848 | return IrInstGenIdErrWrapPayload; |
| 1454 | } | 1849 | } |
| 1455 | | 1850 | |
| 1456 | static constexpr IrInstructionId ir_instruction_id(IrInstructionResetResult *) { | 1851 | static constexpr IrInstGenId ir_inst_id(IrInstGenPtrCast *) { |
| 1457 | return IrInstructionIdResetResult; | 1852 | return IrInstGenIdPtrCast; |
| 1458 | } | 1853 | } |
| 1459 | | 1854 | |
| 1460 | static constexpr IrInstructionId ir_instruction_id(IrInstructionPtrOfArrayToSlice *) { | 1855 | static constexpr IrInstGenId ir_inst_id(IrInstGenBitCast *) { |
| 1461 | return IrInstructionIdPtrOfArrayToSlice; | 1856 | return IrInstGenIdBitCast; |
| 1462 | } | 1857 | } |
| 1463 | | 1858 | |
| 1464 | static constexpr IrInstructionId ir_instruction_id(IrInstructionOpaqueType *) { | 1859 | static constexpr IrInstGenId ir_inst_id(IrInstGenWidenOrShorten *) { |
| 1465 | return IrInstructionIdOpaqueType; | 1860 | return IrInstGenIdWidenOrShorten; |
| 1466 | } | 1861 | } |
| 1467 | | 1862 | |
| 1468 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSetAlignStack *) { | 1863 | static constexpr IrInstGenId ir_inst_id(IrInstGenIntToPtr *) { |
| 1469 | return IrInstructionIdSetAlignStack; | 1864 | return IrInstGenIdIntToPtr; |
| 1470 | } | 1865 | } |
| 1471 | | 1866 | |
| 1472 | static constexpr IrInstructionId ir_instruction_id(IrInstructionArgType *) { | 1867 | static constexpr IrInstGenId ir_inst_id(IrInstGenPtrToInt *) { |
| 1473 | return IrInstructionIdArgType; | 1868 | return IrInstGenIdPtrToInt; |
| 1474 | } | 1869 | } |
| 1475 | | 1870 | |
| 1476 | static constexpr IrInstructionId ir_instruction_id(IrInstructionErrorReturnTrace *) { | 1871 | static constexpr IrInstGenId ir_inst_id(IrInstGenIntToEnum *) { |
| 1477 | return IrInstructionIdErrorReturnTrace; | 1872 | return IrInstGenIdIntToEnum; |
| 1478 | } | 1873 | } |
| 1479 | | 1874 | |
| 1480 | static constexpr IrInstructionId ir_instruction_id(IrInstructionErrorUnion *) { | 1875 | static constexpr IrInstGenId ir_inst_id(IrInstGenIntToErr *) { |
| 1481 | return IrInstructionIdErrorUnion; | 1876 | return IrInstGenIdIntToErr; |
| 1482 | } | 1877 | } |
| 1483 | | 1878 | |
| 1484 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAtomicRmw *) { | 1879 | static constexpr IrInstGenId ir_inst_id(IrInstGenErrToInt *) { |
| 1485 | return IrInstructionIdAtomicRmw; | 1880 | return IrInstGenIdErrToInt; |
| 1486 | } | 1881 | } |
| 1487 | | 1882 | |
| 1488 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAtomicLoad *) { | 1883 | static constexpr IrInstGenId ir_inst_id(IrInstGenPanic *) { |
| 1489 | return IrInstructionIdAtomicLoad; | 1884 | return IrInstGenIdPanic; |
| 1490 | } | 1885 | } |
| 1491 | | 1886 | |
| 1492 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAtomicStore *) { | 1887 | static constexpr IrInstGenId ir_inst_id(IrInstGenTagName *) { |
| 1493 | return IrInstructionIdAtomicStore; | 1888 | return IrInstGenIdTagName; |
| 1494 | } | 1889 | } |
| 1495 | | 1890 | |
| 1496 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSaveErrRetAddr *) { | 1891 | static constexpr IrInstGenId ir_inst_id(IrInstGenFieldParentPtr *) { |
| 1497 | return IrInstructionIdSaveErrRetAddr; | 1892 | return IrInstGenIdFieldParentPtr; |
| 1498 | } | 1893 | } |
| 1499 | | 1894 | |
| 1500 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAddImplicitReturnType *) { | 1895 | static constexpr IrInstGenId ir_inst_id(IrInstGenAlignCast *) { |
| 1501 | return IrInstructionIdAddImplicitReturnType; | 1896 | return IrInstGenIdAlignCast; |
| 1502 | } | 1897 | } |
| 1503 | | 1898 | |
| 1504 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFloatOp *) { | 1899 | static constexpr IrInstGenId ir_inst_id(IrInstGenErrorReturnTrace *) { |
| 1505 | return IrInstructionIdFloatOp; | 1900 | return IrInstGenIdErrorReturnTrace; |
| 1506 | } | 1901 | } |
| 1507 | | 1902 | |
| 1508 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCheckRuntimeScope *) { | 1903 | static constexpr IrInstGenId ir_inst_id(IrInstGenAtomicRmw *) { |
| 1509 | return IrInstructionIdCheckRuntimeScope; | 1904 | return IrInstGenIdAtomicRmw; |
| 1510 | } | 1905 | } |
| 1511 | | 1906 | |
| 1512 | static constexpr IrInstructionId ir_instruction_id(IrInstructionVectorToArray *) { | 1907 | static constexpr IrInstGenId ir_inst_id(IrInstGenAtomicLoad *) { |
| 1513 | return IrInstructionIdVectorToArray; | 1908 | return IrInstGenIdAtomicLoad; |
| 1514 | } | 1909 | } |
| 1515 | | 1910 | |
| 1516 | static constexpr IrInstructionId ir_instruction_id(IrInstructionArrayToVector *) { | 1911 | static constexpr IrInstGenId ir_inst_id(IrInstGenAtomicStore *) { |
| 1517 | return IrInstructionIdArrayToVector; | 1912 | return IrInstGenIdAtomicStore; |
| 1518 | } | 1913 | } |
| 1519 | | 1914 | |
| 1520 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAssertZero *) { | 1915 | static constexpr IrInstGenId ir_inst_id(IrInstGenSaveErrRetAddr *) { |
| 1521 | return IrInstructionIdAssertZero; | 1916 | return IrInstGenIdSaveErrRetAddr; |
| 1522 | } | 1917 | } |
| 1523 | | 1918 | |
| 1524 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAssertNonNull *) { | 1919 | static constexpr IrInstGenId ir_inst_id(IrInstGenVectorToArray *) { |
| 1525 | return IrInstructionIdAssertNonNull; | 1920 | return IrInstGenIdVectorToArray; |
| 1526 | } | 1921 | } |
| 1527 | | 1922 | |
| 1528 | static constexpr IrInstructionId ir_instruction_id(IrInstructionHasDecl *) { | 1923 | static constexpr IrInstGenId ir_inst_id(IrInstGenArrayToVector *) { |
| 1529 | return IrInstructionIdHasDecl; | 1924 | return IrInstGenIdArrayToVector; |
| 1530 | } | 1925 | } |
| 1531 | | 1926 | |
| 1532 | static constexpr IrInstructionId ir_instruction_id(IrInstructionUndeclaredIdent *) { | 1927 | static constexpr IrInstGenId ir_inst_id(IrInstGenAssertZero *) { |
| 1533 | return IrInstructionIdUndeclaredIdent; | 1928 | return IrInstGenIdAssertZero; |
| 1534 | } | 1929 | } |
| 1535 | | 1930 | |
| 1536 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAllocaSrc *) { | 1931 | static constexpr IrInstGenId ir_inst_id(IrInstGenAssertNonNull *) { |
| 1537 | return IrInstructionIdAllocaSrc; | 1932 | return IrInstGenIdAssertNonNull; |
| 1538 | } | 1933 | } |
| 1539 | | 1934 | |
| 1540 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAllocaGen *) { | 1935 | static constexpr IrInstGenId ir_inst_id(IrInstGenPtrOfArrayToSlice *) { |
| 1541 | return IrInstructionIdAllocaGen; | 1936 | return IrInstGenIdPtrOfArrayToSlice; |
| 1542 | } | 1937 | } |
| 1543 | | 1938 | |
| 1544 | static constexpr IrInstructionId ir_instruction_id(IrInstructionEndExpr *) { | 1939 | static constexpr IrInstGenId ir_inst_id(IrInstGenSuspendBegin *) { |
| 1545 | return IrInstructionIdEndExpr; | 1940 | return IrInstGenIdSuspendBegin; |
| 1546 | } | 1941 | } |
| 1547 | | 1942 | |
| 1548 | static constexpr IrInstructionId ir_instruction_id(IrInstructionUnionInitNamedField *) { | 1943 | static constexpr IrInstGenId ir_inst_id(IrInstGenSuspendFinish *) { |
| 1549 | return IrInstructionIdUnionInitNamedField; | 1944 | return IrInstGenIdSuspendFinish; |
| 1550 | } | 1945 | } |
| 1551 | | 1946 | |
| 1552 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSuspendBegin *) { | 1947 | static constexpr IrInstGenId ir_inst_id(IrInstGenAwait *) { |
| 1553 | return IrInstructionIdSuspendBegin; | 1948 | return IrInstGenIdAwait; |
| 1554 | } | 1949 | } |
| 1555 | | 1950 | |
| 1556 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSuspendFinish *) { | 1951 | static constexpr IrInstGenId ir_inst_id(IrInstGenResume *) { |
| 1557 | return IrInstructionIdSuspendFinish; | 1952 | return IrInstGenIdResume; |
| 1558 | } | 1953 | } |
| 1559 | | 1954 | |
| 1560 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAwaitSrc *) { | 1955 | static constexpr IrInstGenId ir_inst_id(IrInstGenSpillBegin *) { |
| 1561 | return IrInstructionIdAwaitSrc; | 1956 | return IrInstGenIdSpillBegin; |
| 1562 | } | 1957 | } |
| 1563 | | 1958 | |
| 1564 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAwaitGen *) { | 1959 | static constexpr IrInstGenId ir_inst_id(IrInstGenSpillEnd *) { |
| 1565 | return IrInstructionIdAwaitGen; | 1960 | return IrInstGenIdSpillEnd; |
| 1566 | } | 1961 | } |
| 1567 | | 1962 | |
| 1568 | static constexpr IrInstructionId ir_instruction_id(IrInstructionResume *) { | 1963 | static constexpr IrInstGenId ir_inst_id(IrInstGenVectorExtractElem *) { |
| 1569 | return IrInstructionIdResume; | 1964 | return IrInstGenIdVectorExtractElem; |
| 1570 | } | 1965 | } |
| 1571 | | 1966 | |
| 1572 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSpillBegin *) { | 1967 | static constexpr IrInstGenId ir_inst_id(IrInstGenAlloca *) { |
| 1573 | return IrInstructionIdSpillBegin; | 1968 | return IrInstGenIdAlloca; |
| 1574 | } | 1969 | } |
| 1575 | | 1970 | |
| 1576 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSpillEnd *) { | 1971 | static constexpr IrInstGenId ir_inst_id(IrInstGenConst *) { |
| 1577 | return IrInstructionIdSpillEnd; | 1972 | return IrInstGenIdConst; |
| 1578 | } | 1973 | } |
| 1579 | | 1974 | |
| 1580 | static constexpr IrInstructionId ir_instruction_id(IrInstructionVectorExtractElem *) { | 1975 | template<typename T> |
| 1581 | return IrInstructionIdVectorExtractElem; | 1976 | static T *ir_create_instruction(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| | 1977 | const char *name = nullptr; |
| | 1978 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| | 1979 | T *dummy = nullptr; |
| | 1980 | name = ir_inst_src_type_str(ir_inst_id(dummy)); |
| | 1981 | #endif |
| | 1982 | T *special_instruction = allocate<T>(1, name); |
| | 1983 | special_instruction->base.id = ir_inst_id(special_instruction); |
| | 1984 | special_instruction->base.base.scope = scope; |
| | 1985 | special_instruction->base.base.source_node = source_node; |
| | 1986 | special_instruction->base.base.debug_id = exec_next_debug_id(irb->exec); |
| | 1987 | special_instruction->base.owner_bb = irb->current_basic_block; |
| | 1988 | return special_instruction; |
| 1582 | } | 1989 | } |
| 1583 | | 1990 | |
| 1584 | template<typename T> | 1991 | template<typename T> |
| 1585 | static T *ir_create_instruction(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 1992 | static T *ir_create_inst_gen(IrBuilderGen *irb, Scope *scope, AstNode *source_node) { |
| 1586 | const char *name = nullptr; | 1993 | const char *name = nullptr; |
| 1587 | #ifdef ZIG_ENABLE_MEM_PROFILE | 1994 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| 1588 | T *dummy = nullptr; | 1995 | T *dummy = nullptr; |
| 1589 | name = ir_instruction_type_str(ir_instruction_id(dummy)); | 1996 | name = ir_inst_gen_type_str(ir_inst_id(dummy)); |
| 1590 | #endif | 1997 | #endif |
| 1591 | T *special_instruction = allocate<T>(1, name); | 1998 | T *special_instruction = allocate<T>(1, name); |
| 1592 | special_instruction->base.id = ir_instruction_id(special_instruction); | 1999 | special_instruction->base.id = ir_inst_id(special_instruction); |
| 1593 | special_instruction->base.scope = scope; | 2000 | special_instruction->base.base.scope = scope; |
| 1594 | special_instruction->base.source_node = source_node; | 2001 | special_instruction->base.base.source_node = source_node; |
| 1595 | special_instruction->base.debug_id = exec_next_debug_id(irb->exec); | 2002 | special_instruction->base.base.debug_id = exec_next_debug_id_gen(irb->exec); |
| 1596 | special_instruction->base.owner_bb = irb->current_basic_block; | 2003 | special_instruction->base.owner_bb = irb->current_basic_block; |
| 1597 | special_instruction->base.value = allocate<ZigValue>(1, "ZigValue"); | 2004 | special_instruction->base.value = allocate<ZigValue>(1, "ZigValue"); |
| 1598 | return special_instruction; | 2005 | return special_instruction; |
| 1599 | } | 2006 | } |
| 1600 | | 2007 | |
| 1601 | template<typename T> | 2008 | template<typename T> |
| 1602 | static T *ir_create_instruction_noval(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 2009 | static T *ir_create_inst_noval(IrBuilderGen *irb, Scope *scope, AstNode *source_node) { |
| 1603 | const char *name = nullptr; | 2010 | const char *name = nullptr; |
| 1604 | #ifdef ZIG_ENABLE_MEM_PROFILE | 2011 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| 1605 | T *dummy = nullptr; | 2012 | T *dummy = nullptr; |
| 1606 | name = ir_instruction_type_str(ir_instruction_id(dummy)); | 2013 | name = ir_inst_gen_type_str(ir_inst_id(dummy)); |
| 1607 | #endif | 2014 | #endif |
| 1608 | T *special_instruction = allocate<T>(1, name); | 2015 | T *special_instruction = allocate<T>(1, name); |
| 1609 | special_instruction->base.id = ir_instruction_id(special_instruction); | 2016 | special_instruction->base.id = ir_inst_id(special_instruction); |
| 1610 | special_instruction->base.scope = scope; | 2017 | special_instruction->base.base.scope = scope; |
| 1611 | special_instruction->base.source_node = source_node; | 2018 | special_instruction->base.base.source_node = source_node; |
| 1612 | special_instruction->base.debug_id = exec_next_debug_id(irb->exec); | 2019 | special_instruction->base.base.debug_id = exec_next_debug_id_gen(irb->exec); |
| 1613 | special_instruction->base.owner_bb = irb->current_basic_block; | 2020 | special_instruction->base.owner_bb = irb->current_basic_block; |
| 1614 | return special_instruction; | 2021 | return special_instruction; |
| 1615 | } | 2022 | } |
| 1616 | | 2023 | |
| 1617 | template<typename T> | 2024 | template<typename T> |
| 1618 | static T *ir_build_instruction(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 2025 | static T *ir_build_instruction(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 1619 | T *special_instruction = ir_create_instruction<T>(irb, scope, source_node); | 2026 | T *special_instruction = ir_create_instruction<T>(irb, scope, source_node); |
| 1620 | ir_instruction_append(irb->current_basic_block, &special_instruction->base); | 2027 | ir_instruction_append(irb->current_basic_block, &special_instruction->base); |
| 1621 | return special_instruction; | 2028 | return special_instruction; |
| 1622 | } | 2029 | } |
| 1623 | | 2030 | |
| 1624 | static IrInstruction *ir_build_cast(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigType *dest_type, | 2031 | template<typename T> |
| 1625 | IrInstruction *value, CastOp cast_op) | 2032 | static T *ir_build_inst_gen(IrBuilderGen *irb, Scope *scope, AstNode *source_node) { |
| | 2033 | T *special_instruction = ir_create_inst_gen<T>(irb, scope, source_node); |
| | 2034 | ir_inst_gen_append(irb->current_basic_block, &special_instruction->base); |
| | 2035 | return special_instruction; |
| | 2036 | } |
| | 2037 | |
| | 2038 | template<typename T> |
| | 2039 | static T *ir_build_inst_noreturn(IrBuilderGen *irb, Scope *scope, AstNode *source_node) { |
| | 2040 | T *special_instruction = ir_create_inst_noval<T>(irb, scope, source_node); |
| | 2041 | special_instruction->base.value = irb->codegen->intern.for_unreachable(); |
| | 2042 | ir_inst_gen_append(irb->current_basic_block, &special_instruction->base); |
| | 2043 | return special_instruction; |
| | 2044 | } |
| | 2045 | |
| | 2046 | template<typename T> |
| | 2047 | static T *ir_build_inst_void(IrBuilderGen *irb, Scope *scope, AstNode *source_node) { |
| | 2048 | T *special_instruction = ir_create_inst_noval<T>(irb, scope, source_node); |
| | 2049 | special_instruction->base.value = irb->codegen->intern.for_void(); |
| | 2050 | ir_inst_gen_append(irb->current_basic_block, &special_instruction->base); |
| | 2051 | return special_instruction; |
| | 2052 | } |
| | 2053 | |
| | 2054 | IrInstGen *ir_create_alloca(CodeGen *g, Scope *scope, AstNode *source_node, ZigFn *fn, |
| | 2055 | ZigType *var_type, const char *name_hint) |
| 1626 | { | 2056 | { |
| 1627 | IrInstructionCast *cast_instruction = ir_build_instruction<IrInstructionCast>(irb, scope, source_node); | 2057 | IrInstGenAlloca *alloca_gen = allocate<IrInstGenAlloca>(1); |
| 1628 | cast_instruction->dest_type = dest_type; | 2058 | alloca_gen->base.id = IrInstGenIdAlloca; |
| 1629 | cast_instruction->value = value; | 2059 | alloca_gen->base.base.source_node = source_node; |
| 1630 | cast_instruction->cast_op = cast_op; | 2060 | alloca_gen->base.base.scope = scope; |
| | 2061 | alloca_gen->base.value = allocate<ZigValue>(1, "ZigValue"); |
| | 2062 | alloca_gen->base.value->type = get_pointer_to_type(g, var_type, false); |
| | 2063 | alloca_gen->base.base.ref_count = 1; |
| | 2064 | alloca_gen->name_hint = name_hint; |
| | 2065 | fn->alloca_gen_list.append(alloca_gen); |
| | 2066 | return &alloca_gen->base; |
| | 2067 | } |
| 1631 | | 2068 | |
| 1632 | ir_ref_instruction(value, irb->current_basic_block); | 2069 | static IrInstGen *ir_build_cast(IrAnalyze *ira, IrInst *source_instr,ZigType *dest_type, |
| | 2070 | IrInstGen *value, CastOp cast_op) |
| | 2071 | { |
| | 2072 | IrInstGenCast *inst = ir_build_inst_gen<IrInstGenCast>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| | 2073 | inst->base.value->type = dest_type; |
| | 2074 | inst->value = value; |
| | 2075 | inst->cast_op = cast_op; |
| 1633 | | 2076 | |
| 1634 | return &cast_instruction->base; | 2077 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| | 2078 | |
| | 2079 | return &inst->base; |
| 1635 | } | 2080 | } |
| 1636 | | 2081 | |
| 1637 | static IrInstruction *ir_build_cond_br(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *condition, | 2082 | static IrInstSrc *ir_build_cond_br(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *condition, |
| 1638 | IrBasicBlock *then_block, IrBasicBlock *else_block, IrInstruction *is_comptime) | 2083 | IrBasicBlockSrc *then_block, IrBasicBlockSrc *else_block, IrInstSrc *is_comptime) |
| 1639 | { | 2084 | { |
| 1640 | IrInstructionCondBr *cond_br_instruction = ir_build_instruction<IrInstructionCondBr>(irb, scope, source_node); | 2085 | IrInstSrcCondBr *inst = ir_build_instruction<IrInstSrcCondBr>(irb, scope, source_node); |
| 1641 | cond_br_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; | 2086 | inst->base.is_noreturn = true; |
| 1642 | cond_br_instruction->base.value->special = ConstValSpecialStatic; | 2087 | inst->condition = condition; |
| 1643 | cond_br_instruction->condition = condition; | 2088 | inst->then_block = then_block; |
| 1644 | cond_br_instruction->then_block = then_block; | 2089 | inst->else_block = else_block; |
| 1645 | cond_br_instruction->else_block = else_block; | 2090 | inst->is_comptime = is_comptime; |
| 1646 | cond_br_instruction->is_comptime = is_comptime; | | |
| 1647 | | 2091 | |
| 1648 | ir_ref_instruction(condition, irb->current_basic_block); | 2092 | ir_ref_instruction(condition, irb->current_basic_block); |
| 1649 | ir_ref_bb(then_block); | 2093 | ir_ref_bb(then_block); |
| 1650 | ir_ref_bb(else_block); | 2094 | ir_ref_bb(else_block); |
| 1651 | if (is_comptime != nullptr) ir_ref_instruction(is_comptime, irb->current_basic_block); | 2095 | if (is_comptime != nullptr) ir_ref_instruction(is_comptime, irb->current_basic_block); |
| 1652 | | 2096 | |
| 1653 | return &cond_br_instruction->base; | 2097 | return &inst->base; |
| 1654 | } | 2098 | } |
| 1655 | | 2099 | |
| 1656 | static IrInstruction *ir_build_return(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2100 | static IrInstGen *ir_build_cond_br_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *condition, |
| 1657 | IrInstruction *operand) | 2101 | IrBasicBlockGen *then_block, IrBasicBlockGen *else_block) |
| 1658 | { | 2102 | { |
| 1659 | IrInstructionReturn *return_instruction = ir_build_instruction<IrInstructionReturn>(irb, scope, source_node); | 2103 | IrInstGenCondBr *inst = ir_build_inst_noreturn<IrInstGenCondBr>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| 1660 | return_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; | 2104 | inst->condition = condition; |
| 1661 | return_instruction->base.value->special = ConstValSpecialStatic; | 2105 | inst->then_block = then_block; |
| 1662 | return_instruction->operand = operand; | 2106 | inst->else_block = else_block; |
| | 2107 | |
| | 2108 | ir_ref_inst_gen(condition, ira->new_irb.current_basic_block); |
| | 2109 | ir_ref_bb_gen(then_block); |
| | 2110 | ir_ref_bb_gen(else_block); |
| | 2111 | |
| | 2112 | return &inst->base; |
| | 2113 | } |
| | 2114 | |
| | 2115 | static IrInstSrc *ir_build_return_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *operand) { |
| | 2116 | IrInstSrcReturn *inst = ir_build_instruction<IrInstSrcReturn>(irb, scope, source_node); |
| | 2117 | inst->base.is_noreturn = true; |
| | 2118 | inst->operand = operand; |
| 1663 | | 2119 | |
| 1664 | if (operand != nullptr) ir_ref_instruction(operand, irb->current_basic_block); | 2120 | if (operand != nullptr) ir_ref_instruction(operand, irb->current_basic_block); |
| 1665 | | 2121 | |
| 1666 | return &return_instruction->base; | 2122 | return &inst->base; |
| | 2123 | } |
| | 2124 | |
| | 2125 | static IrInstGen *ir_build_return_gen(IrAnalyze *ira, IrInst *source_inst, IrInstGen *operand) { |
| | 2126 | IrInstGenReturn *inst = ir_build_inst_noreturn<IrInstGenReturn>(&ira->new_irb, |
| | 2127 | source_inst->scope, source_inst->source_node); |
| | 2128 | inst->operand = operand; |
| | 2129 | |
| | 2130 | if (operand != nullptr) ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| | 2131 | |
| | 2132 | return &inst->base; |
| 1667 | } | 2133 | } |
| 1668 | | 2134 | |
| 1669 | static IrInstruction *ir_build_const_void(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 2135 | static IrInstSrc *ir_build_const_void(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 1670 | IrInstructionConst *const_instruction = ir_create_instruction_noval<IrInstructionConst>(irb, scope, source_node); | 2136 | IrInstSrcConst *const_instruction = ir_create_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1671 | ir_instruction_append(irb->current_basic_block, &const_instruction->base); | 2137 | ir_instruction_append(irb->current_basic_block, &const_instruction->base); |
| 1672 | const_instruction->base.value = irb->codegen->intern.for_void(); | 2138 | const_instruction->value = irb->codegen->intern.for_void(); |
| 1673 | return &const_instruction->base; | 2139 | return &const_instruction->base; |
| 1674 | } | 2140 | } |
| 1675 | | 2141 | |
| 1676 | static IrInstruction *ir_build_const_undefined(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 2142 | static IrInstSrc *ir_build_const_undefined(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 1677 | IrInstructionConst *const_instruction = ir_create_instruction_noval<IrInstructionConst>(irb, scope, source_node); | 2143 | IrInstSrcConst *const_instruction = ir_create_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1678 | ir_instruction_append(irb->current_basic_block, &const_instruction->base); | 2144 | ir_instruction_append(irb->current_basic_block, &const_instruction->base); |
| 1679 | const_instruction->base.value = irb->codegen->intern.for_undefined(); | 2145 | const_instruction->value = irb->codegen->intern.for_undefined(); |
| 1680 | return &const_instruction->base; | 2146 | return &const_instruction->base; |
| 1681 | } | 2147 | } |
| 1682 | | 2148 | |
| 1683 | static IrInstruction *ir_build_const_uint(IrBuilder *irb, Scope *scope, AstNode *source_node, uint64_t value) { | 2149 | static IrInstSrc *ir_build_const_uint(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, uint64_t value) { |
| 1684 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 2150 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1685 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_num_lit_int; | 2151 | const_instruction->value = create_const_vals(1); |
| 1686 | const_instruction->base.value->special = ConstValSpecialStatic; | 2152 | const_instruction->value->type = irb->codegen->builtin_types.entry_num_lit_int; |
| 1687 | bigint_init_unsigned(&const_instruction->base.value->data.x_bigint, value); | 2153 | const_instruction->value->special = ConstValSpecialStatic; |
| | 2154 | bigint_init_unsigned(&const_instruction->value->data.x_bigint, value); |
| 1688 | return &const_instruction->base; | 2155 | return &const_instruction->base; |
| 1689 | } | 2156 | } |
| 1690 | | 2157 | |
| 1691 | static IrInstruction *ir_build_const_bigint(IrBuilder *irb, Scope *scope, AstNode *source_node, BigInt *bigint) { | 2158 | static IrInstSrc *ir_build_const_bigint(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, BigInt *bigint) { |
| 1692 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 2159 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1693 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_num_lit_int; | 2160 | const_instruction->value = create_const_vals(1); |
| 1694 | const_instruction->base.value->special = ConstValSpecialStatic; | 2161 | const_instruction->value->type = irb->codegen->builtin_types.entry_num_lit_int; |
| 1695 | bigint_init_bigint(&const_instruction->base.value->data.x_bigint, bigint); | 2162 | const_instruction->value->special = ConstValSpecialStatic; |
| | 2163 | bigint_init_bigint(&const_instruction->value->data.x_bigint, bigint); |
| 1696 | return &const_instruction->base; | 2164 | return &const_instruction->base; |
| 1697 | } | 2165 | } |
| 1698 | | 2166 | |
| 1699 | static IrInstruction *ir_build_const_bigfloat(IrBuilder *irb, Scope *scope, AstNode *source_node, BigFloat *bigfloat) { | 2167 | static IrInstSrc *ir_build_const_bigfloat(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, BigFloat *bigfloat) { |
| 1700 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 2168 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1701 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_num_lit_float; | 2169 | const_instruction->value = create_const_vals(1); |
| 1702 | const_instruction->base.value->special = ConstValSpecialStatic; | 2170 | const_instruction->value->type = irb->codegen->builtin_types.entry_num_lit_float; |
| 1703 | bigfloat_init_bigfloat(&const_instruction->base.value->data.x_bigfloat, bigfloat); | 2171 | const_instruction->value->special = ConstValSpecialStatic; |
| | 2172 | bigfloat_init_bigfloat(&const_instruction->value->data.x_bigfloat, bigfloat); |
| 1704 | return &const_instruction->base; | 2173 | return &const_instruction->base; |
| 1705 | } | 2174 | } |
| 1706 | | 2175 | |
| 1707 | static IrInstruction *ir_build_const_null(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 2176 | static IrInstSrc *ir_build_const_null(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 1708 | IrInstructionConst *const_instruction = ir_create_instruction_noval<IrInstructionConst>(irb, scope, source_node); | 2177 | IrInstSrcConst *const_instruction = ir_create_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1709 | ir_instruction_append(irb->current_basic_block, &const_instruction->base); | 2178 | ir_instruction_append(irb->current_basic_block, &const_instruction->base); |
| 1710 | const_instruction->base.value = irb->codegen->intern.for_null(); | 2179 | const_instruction->value = irb->codegen->intern.for_null(); |
| 1711 | return &const_instruction->base; | 2180 | return &const_instruction->base; |
| 1712 | } | 2181 | } |
| 1713 | | 2182 | |
| 1714 | static IrInstruction *ir_build_const_usize(IrBuilder *irb, Scope *scope, AstNode *source_node, uint64_t value) { | 2183 | static IrInstSrc *ir_build_const_usize(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, uint64_t value) { |
| 1715 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 2184 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1716 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_usize; | 2185 | const_instruction->value = create_const_vals(1); |
| 1717 | const_instruction->base.value->special = ConstValSpecialStatic; | 2186 | const_instruction->value->type = irb->codegen->builtin_types.entry_usize; |
| 1718 | bigint_init_unsigned(&const_instruction->base.value->data.x_bigint, value); | 2187 | const_instruction->value->special = ConstValSpecialStatic; |
| | 2188 | bigint_init_unsigned(&const_instruction->value->data.x_bigint, value); |
| 1719 | return &const_instruction->base; | 2189 | return &const_instruction->base; |
| 1720 | } | 2190 | } |
| 1721 | | 2191 | |
| 1722 | static IrInstruction *ir_create_const_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2192 | static IrInstSrc *ir_create_const_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1723 | ZigType *type_entry) | 2193 | ZigType *type_entry) |
| 1724 | { | 2194 | { |
| 1725 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); | 2195 | IrInstSrcConst *const_instruction = ir_create_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1726 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_type; | 2196 | const_instruction->value = create_const_vals(1); |
| 1727 | const_instruction->base.value->special = ConstValSpecialStatic; | 2197 | const_instruction->value->type = irb->codegen->builtin_types.entry_type; |
| 1728 | const_instruction->base.value->data.x_type = type_entry; | 2198 | const_instruction->value->special = ConstValSpecialStatic; |
| | 2199 | const_instruction->value->data.x_type = type_entry; |
| 1729 | return &const_instruction->base; | 2200 | return &const_instruction->base; |
| 1730 | } | 2201 | } |
| 1731 | | 2202 | |
| 1732 | static IrInstruction *ir_build_const_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2203 | static IrInstSrc *ir_build_const_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1733 | ZigType *type_entry) | 2204 | ZigType *type_entry) |
| 1734 | { | 2205 | { |
| 1735 | IrInstruction *instruction = ir_create_const_type(irb, scope, source_node, type_entry); | 2206 | IrInstSrc *instruction = ir_create_const_type(irb, scope, source_node, type_entry); |
| 1736 | ir_instruction_append(irb->current_basic_block, instruction); | 2207 | ir_instruction_append(irb->current_basic_block, instruction); |
| 1737 | return instruction; | 2208 | return instruction; |
| 1738 | } | 2209 | } |
| 1739 | | 2210 | |
| 1740 | static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigFn *fn_entry) { | 2211 | static IrInstSrc *ir_build_const_import(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, ZigType *import) { |
| 1741 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); | 2212 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1742 | const_instruction->base.value->type = fn_entry->type_entry; | 2213 | const_instruction->value = create_const_vals(1); |
| 1743 | const_instruction->base.value->special = ConstValSpecialStatic; | 2214 | const_instruction->value->type = irb->codegen->builtin_types.entry_type; |
| 1744 | const_instruction->base.value->data.x_ptr.data.fn.fn_entry = fn_entry; | 2215 | const_instruction->value->special = ConstValSpecialStatic; |
| 1745 | const_instruction->base.value->data.x_ptr.mut = ConstPtrMutComptimeConst; | 2216 | const_instruction->value->data.x_type = import; |
| 1746 | const_instruction->base.value->data.x_ptr.special = ConstPtrSpecialFunction; | | |
| 1747 | return &const_instruction->base; | | |
| 1748 | } | | |
| 1749 | | | |
| 1750 | static IrInstruction *ir_build_const_import(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigType *import) { | | |
| 1751 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | | |
| 1752 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_type; | | |
| 1753 | const_instruction->base.value->special = ConstValSpecialStatic; | | |
| 1754 | const_instruction->base.value->data.x_type = import; | | |
| 1755 | return &const_instruction->base; | | |
| 1756 | } | | |
| 1757 | | | |
| 1758 | static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode *source_node, bool value) { | | |
| 1759 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | | |
| 1760 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_bool; | | |
| 1761 | const_instruction->base.value->special = ConstValSpecialStatic; | | |
| 1762 | const_instruction->base.value->data.x_bool = value; | | |
| 1763 | return &const_instruction->base; | 2217 | return &const_instruction->base; |
| 1764 | } | 2218 | } |
| 1765 | | 2219 | |
| 1766 | static IrInstruction *ir_build_const_enum_literal(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *name) { | 2220 | static IrInstSrc *ir_build_const_bool(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, bool value) { |
| 1767 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 2221 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1768 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_enum_literal; | 2222 | const_instruction->value = create_const_vals(1); |
| 1769 | const_instruction->base.value->special = ConstValSpecialStatic; | 2223 | const_instruction->value->type = irb->codegen->builtin_types.entry_bool; |
| 1770 | const_instruction->base.value->data.x_enum_literal = name; | 2224 | const_instruction->value->special = ConstValSpecialStatic; |
| | 2225 | const_instruction->value->data.x_bool = value; |
| 1771 | return &const_instruction->base; | 2226 | return &const_instruction->base; |
| 1772 | } | 2227 | } |
| 1773 | | 2228 | |
| 1774 | static IrInstruction *ir_build_const_bound_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2229 | static IrInstSrc *ir_build_const_enum_literal(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, Buf *name) { |
| 1775 | ZigFn *fn_entry, IrInstruction *first_arg) | 2230 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1776 | { | 2231 | const_instruction->value = create_const_vals(1); |
| 1777 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 2232 | const_instruction->value->type = irb->codegen->builtin_types.entry_enum_literal; |
| 1778 | const_instruction->base.value->type = get_bound_fn_type(irb->codegen, fn_entry); | 2233 | const_instruction->value->special = ConstValSpecialStatic; |
| 1779 | const_instruction->base.value->special = ConstValSpecialStatic; | 2234 | const_instruction->value->data.x_enum_literal = name; |
| 1780 | const_instruction->base.value->data.x_bound_fn.fn = fn_entry; | | |
| 1781 | const_instruction->base.value->data.x_bound_fn.first_arg = first_arg; | | |
| 1782 | return &const_instruction->base; | 2235 | return &const_instruction->base; |
| 1783 | } | 2236 | } |
| 1784 | | 2237 | |
| 1785 | static IrInstruction *ir_create_const_str_lit(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *str) { | 2238 | static IrInstSrc *ir_create_const_str_lit(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, Buf *str) { |
| 1786 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); | 2239 | IrInstSrcConst *const_instruction = ir_create_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1787 | init_const_str_lit(irb->codegen, const_instruction->base.value, str); | 2240 | const_instruction->value = create_const_vals(1); |
| | 2241 | init_const_str_lit(irb->codegen, const_instruction->value, str); |
| 1788 | | 2242 | |
| 1789 | return &const_instruction->base; | 2243 | return &const_instruction->base; |
| 1790 | } | 2244 | } |
| 1791 | | 2245 | |
| 1792 | static IrInstruction *ir_build_const_str_lit(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *str) { | 2246 | static IrInstSrc *ir_build_const_str_lit(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, Buf *str) { |
| 1793 | IrInstruction *instruction = ir_create_const_str_lit(irb, scope, source_node, str); | 2247 | IrInstSrc *instruction = ir_create_const_str_lit(irb, scope, source_node, str); |
| 1794 | ir_instruction_append(irb->current_basic_block, instruction); | 2248 | ir_instruction_append(irb->current_basic_block, instruction); |
| 1795 | return instruction; | 2249 | return instruction; |
| 1796 | } | 2250 | } |
| 1797 | | 2251 | |
| 1798 | static IrInstruction *ir_build_bin_op(IrBuilder *irb, Scope *scope, AstNode *source_node, IrBinOp op_id, | 2252 | static IrInstSrc *ir_build_bin_op(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrBinOp op_id, |
| 1799 | IrInstruction *op1, IrInstruction *op2, bool safety_check_on) | 2253 | IrInstSrc *op1, IrInstSrc *op2, bool safety_check_on) |
| 1800 | { | 2254 | { |
| 1801 | IrInstructionBinOp *bin_op_instruction = ir_build_instruction<IrInstructionBinOp>(irb, scope, source_node); | 2255 | IrInstSrcBinOp *inst = ir_build_instruction<IrInstSrcBinOp>(irb, scope, source_node); |
| 1802 | bin_op_instruction->op_id = op_id; | 2256 | inst->op_id = op_id; |
| 1803 | bin_op_instruction->op1 = op1; | 2257 | inst->op1 = op1; |
| 1804 | bin_op_instruction->op2 = op2; | 2258 | inst->op2 = op2; |
| 1805 | bin_op_instruction->safety_check_on = safety_check_on; | 2259 | inst->safety_check_on = safety_check_on; |
| 1806 | | 2260 | |
| 1807 | ir_ref_instruction(op1, irb->current_basic_block); | 2261 | ir_ref_instruction(op1, irb->current_basic_block); |
| 1808 | ir_ref_instruction(op2, irb->current_basic_block); | 2262 | ir_ref_instruction(op2, irb->current_basic_block); |
| 1809 | | 2263 | |
| 1810 | return &bin_op_instruction->base; | 2264 | return &inst->base; |
| 1811 | } | 2265 | } |
| 1812 | | 2266 | |
| 1813 | static IrInstruction *ir_build_bin_op_gen(IrAnalyze *ira, IrInstruction *source_instr, ZigType *res_type, | 2267 | static IrInstGen *ir_build_bin_op_gen(IrAnalyze *ira, IrInst *source_instr, ZigType *res_type, |
| 1814 | IrBinOp op_id, IrInstruction *op1, IrInstruction *op2, bool safety_check_on) | 2268 | IrBinOp op_id, IrInstGen *op1, IrInstGen *op2, bool safety_check_on) |
| 1815 | { | 2269 | { |
| 1816 | IrInstructionBinOp *bin_op_instruction = ir_build_instruction<IrInstructionBinOp>(&ira->new_irb, | 2270 | IrInstGenBinOp *inst = ir_build_inst_gen<IrInstGenBinOp>(&ira->new_irb, |
| 1817 | source_instr->scope, source_instr->source_node); | 2271 | source_instr->scope, source_instr->source_node); |
| 1818 | bin_op_instruction->base.value->type = res_type; | 2272 | inst->base.value->type = res_type; |
| 1819 | bin_op_instruction->op_id = op_id; | 2273 | inst->op_id = op_id; |
| 1820 | bin_op_instruction->op1 = op1; | 2274 | inst->op1 = op1; |
| 1821 | bin_op_instruction->op2 = op2; | 2275 | inst->op2 = op2; |
| 1822 | bin_op_instruction->safety_check_on = safety_check_on; | 2276 | inst->safety_check_on = safety_check_on; |
| 1823 | | 2277 | |
| 1824 | ir_ref_instruction(op1, ira->new_irb.current_basic_block); | 2278 | ir_ref_inst_gen(op1, ira->new_irb.current_basic_block); |
| 1825 | ir_ref_instruction(op2, ira->new_irb.current_basic_block); | 2279 | ir_ref_inst_gen(op2, ira->new_irb.current_basic_block); |
| 1826 | | 2280 | |
| 1827 | return &bin_op_instruction->base; | 2281 | return &inst->base; |
| 1828 | } | 2282 | } |
| 1829 | | 2283 | |
| 1830 | | 2284 | |
| 1831 | static IrInstruction *ir_build_merge_err_sets(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2285 | static IrInstSrc *ir_build_merge_err_sets(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1832 | IrInstruction *op1, IrInstruction *op2, Buf *type_name) | 2286 | IrInstSrc *op1, IrInstSrc *op2, Buf *type_name) |
| 1833 | { | 2287 | { |
| 1834 | IrInstructionMergeErrSets *merge_err_sets_instruction = ir_build_instruction<IrInstructionMergeErrSets>(irb, scope, source_node); | 2288 | IrInstSrcMergeErrSets *inst = ir_build_instruction<IrInstSrcMergeErrSets>(irb, scope, source_node); |
| 1835 | merge_err_sets_instruction->op1 = op1; | 2289 | inst->op1 = op1; |
| 1836 | merge_err_sets_instruction->op2 = op2; | 2290 | inst->op2 = op2; |
| 1837 | merge_err_sets_instruction->type_name = type_name; | 2291 | inst->type_name = type_name; |
| 1838 | | 2292 | |
| 1839 | ir_ref_instruction(op1, irb->current_basic_block); | 2293 | ir_ref_instruction(op1, irb->current_basic_block); |
| 1840 | ir_ref_instruction(op2, irb->current_basic_block); | 2294 | ir_ref_instruction(op2, irb->current_basic_block); |
| 1841 | | 2295 | |
| 1842 | return &merge_err_sets_instruction->base; | 2296 | return &inst->base; |
| 1843 | } | 2297 | } |
| 1844 | | 2298 | |
| 1845 | static IrInstruction *ir_build_var_ptr_x(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigVar *var, | 2299 | static IrInstSrc *ir_build_var_ptr_x(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, ZigVar *var, |
| 1846 | ScopeFnDef *crossed_fndef_scope) | 2300 | ScopeFnDef *crossed_fndef_scope) |
| 1847 | { | 2301 | { |
| 1848 | IrInstructionVarPtr *instruction = ir_build_instruction<IrInstructionVarPtr>(irb, scope, source_node); | 2302 | IrInstSrcVarPtr *instruction = ir_build_instruction<IrInstSrcVarPtr>(irb, scope, source_node); |
| 1849 | instruction->var = var; | 2303 | instruction->var = var; |
| 1850 | instruction->crossed_fndef_scope = crossed_fndef_scope; | 2304 | instruction->crossed_fndef_scope = crossed_fndef_scope; |
| 1851 | | 2305 | |
| ... | @@ -1854,24 +2308,30 @@ static IrInstruction *ir_build_var_ptr_x(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -1854,24 +2308,30 @@ static IrInstruction *ir_build_var_ptr_x(IrBuilder *irb, Scope *scope, AstNode * |
| 1854 | return &instruction->base; | 2308 | return &instruction->base; |
| 1855 | } | 2309 | } |
| 1856 | | 2310 | |
| 1857 | static IrInstruction *ir_build_var_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigVar *var) { | 2311 | static IrInstSrc *ir_build_var_ptr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, ZigVar *var) { |
| 1858 | return ir_build_var_ptr_x(irb, scope, source_node, var, nullptr); | 2312 | return ir_build_var_ptr_x(irb, scope, source_node, var, nullptr); |
| 1859 | } | 2313 | } |
| 1860 | | 2314 | |
| 1861 | static IrInstruction *ir_build_return_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, | 2315 | static IrInstGen *ir_build_var_ptr_gen(IrAnalyze *ira, IrInst *source_instr, ZigVar *var) { |
| 1862 | ZigType *ty) | 2316 | IrInstGenVarPtr *instruction = ir_build_inst_gen<IrInstGenVarPtr>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| 1863 | { | 2317 | instruction->var = var; |
| 1864 | IrInstructionReturnPtr *instruction = ir_build_instruction<IrInstructionReturnPtr>(&ira->new_irb, | 2318 | |
| 1865 | scope, source_node); | 2319 | ir_ref_var(var); |
| | 2320 | |
| | 2321 | return &instruction->base; |
| | 2322 | } |
| | 2323 | |
| | 2324 | static IrInstGen *ir_build_return_ptr(IrAnalyze *ira, Scope *scope, AstNode *source_node, ZigType *ty) { |
| | 2325 | IrInstGenReturnPtr *instruction = ir_build_inst_gen<IrInstGenReturnPtr>(&ira->new_irb, scope, source_node); |
| 1866 | instruction->base.value->type = ty; | 2326 | instruction->base.value->type = ty; |
| 1867 | return &instruction->base; | 2327 | return &instruction->base; |
| 1868 | } | 2328 | } |
| 1869 | | 2329 | |
| 1870 | static IrInstruction *ir_build_elem_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2330 | static IrInstSrc *ir_build_elem_ptr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1871 | IrInstruction *array_ptr, IrInstruction *elem_index, bool safety_check_on, PtrLen ptr_len, | 2331 | IrInstSrc *array_ptr, IrInstSrc *elem_index, bool safety_check_on, PtrLen ptr_len, |
| 1872 | AstNode *init_array_type_source_node) | 2332 | AstNode *init_array_type_source_node) |
| 1873 | { | 2333 | { |
| 1874 | IrInstructionElemPtr *instruction = ir_build_instruction<IrInstructionElemPtr>(irb, scope, source_node); | 2334 | IrInstSrcElemPtr *instruction = ir_build_instruction<IrInstSrcElemPtr>(irb, scope, source_node); |
| 1875 | instruction->array_ptr = array_ptr; | 2335 | instruction->array_ptr = array_ptr; |
| 1876 | instruction->elem_index = elem_index; | 2336 | instruction->elem_index = elem_index; |
| 1877 | instruction->safety_check_on = safety_check_on; | 2337 | instruction->safety_check_on = safety_check_on; |
| ... | @@ -1884,10 +2344,25 @@ static IrInstruction *ir_build_elem_ptr(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -1884,10 +2344,25 @@ static IrInstruction *ir_build_elem_ptr(IrBuilder *irb, Scope *scope, AstNode *s |
| 1884 | return &instruction->base; | 2344 | return &instruction->base; |
| 1885 | } | 2345 | } |
| 1886 | | 2346 | |
| 1887 | static IrInstruction *ir_build_field_ptr_instruction(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2347 | static IrInstGen *ir_build_elem_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, |
| 1888 | IrInstruction *container_ptr, IrInstruction *field_name_expr, bool initializing) | 2348 | IrInstGen *array_ptr, IrInstGen *elem_index, bool safety_check_on, ZigType *return_type) |
| 1889 | { | 2349 | { |
| 1890 | IrInstructionFieldPtr *instruction = ir_build_instruction<IrInstructionFieldPtr>(irb, scope, source_node); | 2350 | IrInstGenElemPtr *instruction = ir_build_inst_gen<IrInstGenElemPtr>(&ira->new_irb, scope, source_node); |
| | 2351 | instruction->base.value->type = return_type; |
| | 2352 | instruction->array_ptr = array_ptr; |
| | 2353 | instruction->elem_index = elem_index; |
| | 2354 | instruction->safety_check_on = safety_check_on; |
| | 2355 | |
| | 2356 | ir_ref_inst_gen(array_ptr, ira->new_irb.current_basic_block); |
| | 2357 | ir_ref_inst_gen(elem_index, ira->new_irb.current_basic_block); |
| | 2358 | |
| | 2359 | return &instruction->base; |
| | 2360 | } |
| | 2361 | |
| | 2362 | static IrInstSrc *ir_build_field_ptr_instruction(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 2363 | IrInstSrc *container_ptr, IrInstSrc *field_name_expr, bool initializing) |
| | 2364 | { |
| | 2365 | IrInstSrcFieldPtr *instruction = ir_build_instruction<IrInstSrcFieldPtr>(irb, scope, source_node); |
| 1891 | instruction->container_ptr = container_ptr; | 2366 | instruction->container_ptr = container_ptr; |
| 1892 | instruction->field_name_buffer = nullptr; | 2367 | instruction->field_name_buffer = nullptr; |
| 1893 | instruction->field_name_expr = field_name_expr; | 2368 | instruction->field_name_expr = field_name_expr; |
| ... | @@ -1899,10 +2374,10 @@ static IrInstruction *ir_build_field_ptr_instruction(IrBuilder *irb, Scope *scop | ... | @@ -1899,10 +2374,10 @@ static IrInstruction *ir_build_field_ptr_instruction(IrBuilder *irb, Scope *scop |
| 1899 | return &instruction->base; | 2374 | return &instruction->base; |
| 1900 | } | 2375 | } |
| 1901 | | 2376 | |
| 1902 | static IrInstruction *ir_build_field_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2377 | static IrInstSrc *ir_build_field_ptr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1903 | IrInstruction *container_ptr, Buf *field_name, bool initializing) | 2378 | IrInstSrc *container_ptr, Buf *field_name, bool initializing) |
| 1904 | { | 2379 | { |
| 1905 | IrInstructionFieldPtr *instruction = ir_build_instruction<IrInstructionFieldPtr>(irb, scope, source_node); | 2380 | IrInstSrcFieldPtr *instruction = ir_build_instruction<IrInstSrcFieldPtr>(irb, scope, source_node); |
| 1906 | instruction->container_ptr = container_ptr; | 2381 | instruction->container_ptr = container_ptr; |
| 1907 | instruction->field_name_buffer = field_name; | 2382 | instruction->field_name_buffer = field_name; |
| 1908 | instruction->field_name_expr = nullptr; | 2383 | instruction->field_name_expr = nullptr; |
| ... | @@ -1913,10 +2388,10 @@ static IrInstruction *ir_build_field_ptr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -1913,10 +2388,10 @@ static IrInstruction *ir_build_field_ptr(IrBuilder *irb, Scope *scope, AstNode * |
| 1913 | return &instruction->base; | 2388 | return &instruction->base; |
| 1914 | } | 2389 | } |
| 1915 | | 2390 | |
| 1916 | static IrInstruction *ir_build_has_field(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2391 | static IrInstSrc *ir_build_has_field(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1917 | IrInstruction *container_type, IrInstruction *field_name) | 2392 | IrInstSrc *container_type, IrInstSrc *field_name) |
| 1918 | { | 2393 | { |
| 1919 | IrInstructionHasField *instruction = ir_build_instruction<IrInstructionHasField>(irb, scope, source_node); | 2394 | IrInstSrcHasField *instruction = ir_build_instruction<IrInstSrcHasField>(irb, scope, source_node); |
| 1920 | instruction->container_type = container_type; | 2395 | instruction->container_type = container_type; |
| 1921 | instruction->field_name = field_name; | 2396 | instruction->field_name = field_name; |
| 1922 | | 2397 | |
| ... | @@ -1926,36 +2401,39 @@ static IrInstruction *ir_build_has_field(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -1926,36 +2401,39 @@ static IrInstruction *ir_build_has_field(IrBuilder *irb, Scope *scope, AstNode * |
| 1926 | return &instruction->base; | 2401 | return &instruction->base; |
| 1927 | } | 2402 | } |
| 1928 | | 2403 | |
| 1929 | static IrInstruction *ir_build_struct_field_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2404 | static IrInstGen *ir_build_struct_field_ptr(IrAnalyze *ira, IrInst *source_instr, |
| 1930 | IrInstruction *struct_ptr, TypeStructField *field) | 2405 | IrInstGen *struct_ptr, TypeStructField *field, ZigType *ptr_type) |
| 1931 | { | 2406 | { |
| 1932 | IrInstructionStructFieldPtr *instruction = ir_build_instruction<IrInstructionStructFieldPtr>(irb, scope, source_node); | 2407 | IrInstGenStructFieldPtr *inst = ir_build_inst_gen<IrInstGenStructFieldPtr>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| 1933 | instruction->struct_ptr = struct_ptr; | 2408 | inst->base.value->type = ptr_type; |
| 1934 | instruction->field = field; | 2409 | inst->struct_ptr = struct_ptr; |
| | 2410 | inst->field = field; |
| 1935 | | 2411 | |
| 1936 | ir_ref_instruction(struct_ptr, irb->current_basic_block); | 2412 | ir_ref_inst_gen(struct_ptr, ira->new_irb.current_basic_block); |
| 1937 | | 2413 | |
| 1938 | return &instruction->base; | 2414 | return &inst->base; |
| 1939 | } | 2415 | } |
| 1940 | | 2416 | |
| 1941 | static IrInstruction *ir_build_union_field_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2417 | static IrInstGen *ir_build_union_field_ptr(IrAnalyze *ira, IrInst *source_instr, |
| 1942 | IrInstruction *union_ptr, TypeUnionField *field, bool safety_check_on, bool initializing) | 2418 | IrInstGen *union_ptr, TypeUnionField *field, bool safety_check_on, bool initializing, ZigType *ptr_type) |
| 1943 | { | 2419 | { |
| 1944 | IrInstructionUnionFieldPtr *instruction = ir_build_instruction<IrInstructionUnionFieldPtr>(irb, scope, source_node); | 2420 | IrInstGenUnionFieldPtr *inst = ir_build_inst_gen<IrInstGenUnionFieldPtr>(&ira->new_irb, |
| 1945 | instruction->initializing = initializing; | 2421 | source_instr->scope, source_instr->source_node); |
| 1946 | instruction->safety_check_on = safety_check_on; | 2422 | inst->base.value->type = ptr_type; |
| 1947 | instruction->union_ptr = union_ptr; | 2423 | inst->initializing = initializing; |
| 1948 | instruction->field = field; | 2424 | inst->safety_check_on = safety_check_on; |
| | 2425 | inst->union_ptr = union_ptr; |
| | 2426 | inst->field = field; |
| 1949 | | 2427 | |
| 1950 | ir_ref_instruction(union_ptr, irb->current_basic_block); | 2428 | ir_ref_inst_gen(union_ptr, ira->new_irb.current_basic_block); |
| 1951 | | 2429 | |
| 1952 | return &instruction->base; | 2430 | return &inst->base; |
| 1953 | } | 2431 | } |
| 1954 | | 2432 | |
| 1955 | static IrInstruction *ir_build_call_extra(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2433 | static IrInstSrc *ir_build_call_extra(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1956 | IrInstruction *options, IrInstruction *fn_ref, IrInstruction *args, ResultLoc *result_loc) | 2434 | IrInstSrc *options, IrInstSrc *fn_ref, IrInstSrc *args, ResultLoc *result_loc) |
| 1957 | { | 2435 | { |
| 1958 | IrInstructionCallExtra *call_instruction = ir_build_instruction<IrInstructionCallExtra>(irb, scope, source_node); | 2436 | IrInstSrcCallExtra *call_instruction = ir_build_instruction<IrInstSrcCallExtra>(irb, scope, source_node); |
| 1959 | call_instruction->options = options; | 2437 | call_instruction->options = options; |
| 1960 | call_instruction->fn_ref = fn_ref; | 2438 | call_instruction->fn_ref = fn_ref; |
| 1961 | call_instruction->args = args; | 2439 | call_instruction->args = args; |
| ... | @@ -1968,11 +2446,11 @@ static IrInstruction *ir_build_call_extra(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -1968,11 +2446,11 @@ static IrInstruction *ir_build_call_extra(IrBuilder *irb, Scope *scope, AstNode |
| 1968 | return &call_instruction->base; | 2446 | return &call_instruction->base; |
| 1969 | } | 2447 | } |
| 1970 | | 2448 | |
| 1971 | static IrInstruction *ir_build_call_src_args(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2449 | static IrInstSrc *ir_build_call_args(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1972 | IrInstruction *options, IrInstruction *fn_ref, IrInstruction **args_ptr, size_t args_len, | 2450 | IrInstSrc *options, IrInstSrc *fn_ref, IrInstSrc **args_ptr, size_t args_len, |
| 1973 | ResultLoc *result_loc) | 2451 | ResultLoc *result_loc) |
| 1974 | { | 2452 | { |
| 1975 | IrInstructionCallSrcArgs *call_instruction = ir_build_instruction<IrInstructionCallSrcArgs>(irb, scope, source_node); | 2453 | IrInstSrcCallArgs *call_instruction = ir_build_instruction<IrInstSrcCallArgs>(irb, scope, source_node); |
| 1976 | call_instruction->options = options; | 2454 | call_instruction->options = options; |
| 1977 | call_instruction->fn_ref = fn_ref; | 2455 | call_instruction->fn_ref = fn_ref; |
| 1978 | call_instruction->args_ptr = args_ptr; | 2456 | call_instruction->args_ptr = args_ptr; |
| ... | @@ -1987,12 +2465,12 @@ static IrInstruction *ir_build_call_src_args(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -1987,12 +2465,12 @@ static IrInstruction *ir_build_call_src_args(IrBuilder *irb, Scope *scope, AstNo |
| 1987 | return &call_instruction->base; | 2465 | return &call_instruction->base; |
| 1988 | } | 2466 | } |
| 1989 | | 2467 | |
| 1990 | static IrInstruction *ir_build_call_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2468 | static IrInstSrc *ir_build_call_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1991 | ZigFn *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args, | 2469 | ZigFn *fn_entry, IrInstSrc *fn_ref, size_t arg_count, IrInstSrc **args, |
| 1992 | IrInstruction *ret_ptr, CallModifier modifier, bool is_async_call_builtin, | 2470 | IrInstSrc *ret_ptr, CallModifier modifier, bool is_async_call_builtin, |
| 1993 | IrInstruction *new_stack, ResultLoc *result_loc) | 2471 | IrInstSrc *new_stack, ResultLoc *result_loc) |
| 1994 | { | 2472 | { |
| 1995 | IrInstructionCallSrc *call_instruction = ir_build_instruction<IrInstructionCallSrc>(irb, scope, source_node); | 2473 | IrInstSrcCall *call_instruction = ir_build_instruction<IrInstSrcCall>(irb, scope, source_node); |
| 1996 | call_instruction->fn_entry = fn_entry; | 2474 | call_instruction->fn_entry = fn_entry; |
| 1997 | call_instruction->fn_ref = fn_ref; | 2475 | call_instruction->fn_ref = fn_ref; |
| 1998 | call_instruction->args = args; | 2476 | call_instruction->args = args; |
| ... | @@ -2012,12 +2490,12 @@ static IrInstruction *ir_build_call_src(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2012,12 +2490,12 @@ static IrInstruction *ir_build_call_src(IrBuilder *irb, Scope *scope, AstNode *s |
| 2012 | return &call_instruction->base; | 2490 | return &call_instruction->base; |
| 2013 | } | 2491 | } |
| 2014 | | 2492 | |
| 2015 | static IrInstructionCallGen *ir_build_call_gen(IrAnalyze *ira, IrInstruction *source_instruction, | 2493 | static IrInstGenCall *ir_build_call_gen(IrAnalyze *ira, IrInst *source_instruction, |
| 2016 | ZigFn *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args, | 2494 | ZigFn *fn_entry, IrInstGen *fn_ref, size_t arg_count, IrInstGen **args, |
| 2017 | CallModifier modifier, IrInstruction *new_stack, bool is_async_call_builtin, | 2495 | CallModifier modifier, IrInstGen *new_stack, bool is_async_call_builtin, |
| 2018 | IrInstruction *result_loc, ZigType *return_type) | 2496 | IrInstGen *result_loc, ZigType *return_type) |
| 2019 | { | 2497 | { |
| 2020 | IrInstructionCallGen *call_instruction = ir_build_instruction<IrInstructionCallGen>(&ira->new_irb, | 2498 | IrInstGenCall *call_instruction = ir_build_inst_gen<IrInstGenCall>(&ira->new_irb, |
| 2021 | source_instruction->scope, source_instruction->source_node); | 2499 | source_instruction->scope, source_instruction->source_node); |
| 2022 | call_instruction->base.value->type = return_type; | 2500 | call_instruction->base.value->type = return_type; |
| 2023 | call_instruction->fn_entry = fn_entry; | 2501 | call_instruction->fn_entry = fn_entry; |
| ... | @@ -2029,23 +2507,23 @@ static IrInstructionCallGen *ir_build_call_gen(IrAnalyze *ira, IrInstruction *so | ... | @@ -2029,23 +2507,23 @@ static IrInstructionCallGen *ir_build_call_gen(IrAnalyze *ira, IrInstruction *so |
| 2029 | call_instruction->new_stack = new_stack; | 2507 | call_instruction->new_stack = new_stack; |
| 2030 | call_instruction->result_loc = result_loc; | 2508 | call_instruction->result_loc = result_loc; |
| 2031 | | 2509 | |
| 2032 | if (fn_ref != nullptr) ir_ref_instruction(fn_ref, ira->new_irb.current_basic_block); | 2510 | if (fn_ref != nullptr) ir_ref_inst_gen(fn_ref, ira->new_irb.current_basic_block); |
| 2033 | for (size_t i = 0; i < arg_count; i += 1) | 2511 | for (size_t i = 0; i < arg_count; i += 1) |
| 2034 | ir_ref_instruction(args[i], ira->new_irb.current_basic_block); | 2512 | ir_ref_inst_gen(args[i], ira->new_irb.current_basic_block); |
| 2035 | if (new_stack != nullptr) ir_ref_instruction(new_stack, ira->new_irb.current_basic_block); | 2513 | if (new_stack != nullptr) ir_ref_inst_gen(new_stack, ira->new_irb.current_basic_block); |
| 2036 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 2514 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 2037 | | 2515 | |
| 2038 | return call_instruction; | 2516 | return call_instruction; |
| 2039 | } | 2517 | } |
| 2040 | | 2518 | |
| 2041 | static IrInstruction *ir_build_phi(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2519 | static IrInstSrc *ir_build_phi(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2042 | size_t incoming_count, IrBasicBlock **incoming_blocks, IrInstruction **incoming_values, | 2520 | size_t incoming_count, IrBasicBlockSrc **incoming_blocks, IrInstSrc **incoming_values, |
| 2043 | ResultLocPeerParent *peer_parent) | 2521 | ResultLocPeerParent *peer_parent) |
| 2044 | { | 2522 | { |
| 2045 | assert(incoming_count != 0); | 2523 | assert(incoming_count != 0); |
| 2046 | assert(incoming_count != SIZE_MAX); | 2524 | assert(incoming_count != SIZE_MAX); |
| 2047 | | 2525 | |
| 2048 | IrInstructionPhi *phi_instruction = ir_build_instruction<IrInstructionPhi>(irb, scope, source_node); | 2526 | IrInstSrcPhi *phi_instruction = ir_build_instruction<IrInstSrcPhi>(irb, scope, source_node); |
| 2049 | phi_instruction->incoming_count = incoming_count; | 2527 | phi_instruction->incoming_count = incoming_count; |
| 2050 | phi_instruction->incoming_blocks = incoming_blocks; | 2528 | phi_instruction->incoming_blocks = incoming_blocks; |
| 2051 | phi_instruction->incoming_values = incoming_values; | 2529 | phi_instruction->incoming_values = incoming_values; |
| ... | @@ -2059,56 +2537,77 @@ static IrInstruction *ir_build_phi(IrBuilder *irb, Scope *scope, AstNode *source | ... | @@ -2059,56 +2537,77 @@ static IrInstruction *ir_build_phi(IrBuilder *irb, Scope *scope, AstNode *source |
| 2059 | return &phi_instruction->base; | 2537 | return &phi_instruction->base; |
| 2060 | } | 2538 | } |
| 2061 | | 2539 | |
| 2062 | static IrInstruction *ir_create_br(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2540 | static IrInstGen *ir_build_phi_gen(IrAnalyze *ira, IrInst *source_instr, size_t incoming_count, |
| 2063 | IrBasicBlock *dest_block, IrInstruction *is_comptime) | 2541 | IrBasicBlockGen **incoming_blocks, IrInstGen **incoming_values, ZigType *result_type) |
| 2064 | { | 2542 | { |
| 2065 | IrInstructionBr *br_instruction = ir_create_instruction<IrInstructionBr>(irb, scope, source_node); | 2543 | assert(incoming_count != 0); |
| 2066 | br_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; | 2544 | assert(incoming_count != SIZE_MAX); |
| 2067 | br_instruction->base.value->special = ConstValSpecialStatic; | 2545 | |
| 2068 | br_instruction->dest_block = dest_block; | 2546 | IrInstGenPhi *phi_instruction = ir_build_inst_gen<IrInstGenPhi>(&ira->new_irb, |
| 2069 | br_instruction->is_comptime = is_comptime; | 2547 | source_instr->scope, source_instr->source_node); |
| | 2548 | phi_instruction->base.value->type = result_type; |
| | 2549 | phi_instruction->incoming_count = incoming_count; |
| | 2550 | phi_instruction->incoming_blocks = incoming_blocks; |
| | 2551 | phi_instruction->incoming_values = incoming_values; |
| | 2552 | |
| | 2553 | for (size_t i = 0; i < incoming_count; i += 1) { |
| | 2554 | ir_ref_bb_gen(incoming_blocks[i]); |
| | 2555 | ir_ref_inst_gen(incoming_values[i], ira->new_irb.current_basic_block); |
| | 2556 | } |
| | 2557 | |
| | 2558 | return &phi_instruction->base; |
| | 2559 | } |
| | 2560 | |
| | 2561 | static IrInstSrc *ir_build_br(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 2562 | IrBasicBlockSrc *dest_block, IrInstSrc *is_comptime) |
| | 2563 | { |
| | 2564 | IrInstSrcBr *inst = ir_build_instruction<IrInstSrcBr>(irb, scope, source_node); |
| | 2565 | inst->base.is_noreturn = true; |
| | 2566 | inst->dest_block = dest_block; |
| | 2567 | inst->is_comptime = is_comptime; |
| 2070 | | 2568 | |
| 2071 | ir_ref_bb(dest_block); | 2569 | ir_ref_bb(dest_block); |
| 2072 | if (is_comptime) ir_ref_instruction(is_comptime, irb->current_basic_block); | 2570 | if (is_comptime) ir_ref_instruction(is_comptime, irb->current_basic_block); |
| 2073 | | 2571 | |
| 2074 | return &br_instruction->base; | 2572 | return &inst->base; |
| 2075 | } | 2573 | } |
| 2076 | | 2574 | |
| 2077 | static IrInstruction *ir_build_br(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2575 | static IrInstGen *ir_build_br_gen(IrAnalyze *ira, IrInst *source_instr, IrBasicBlockGen *dest_block) { |
| 2078 | IrBasicBlock *dest_block, IrInstruction *is_comptime) | 2576 | IrInstGenBr *inst = ir_build_inst_noreturn<IrInstGenBr>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| 2079 | { | 2577 | inst->dest_block = dest_block; |
| 2080 | IrInstruction *instruction = ir_create_br(irb, scope, source_node, dest_block, is_comptime); | 2578 | |
| 2081 | ir_instruction_append(irb->current_basic_block, instruction); | 2579 | ir_ref_bb_gen(dest_block); |
| 2082 | return instruction; | 2580 | |
| | 2581 | return &inst->base; |
| 2083 | } | 2582 | } |
| 2084 | | 2583 | |
| 2085 | static IrInstruction *ir_build_ptr_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2584 | static IrInstSrc *ir_build_ptr_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2086 | IrInstruction *child_type, bool is_const, bool is_volatile, PtrLen ptr_len, | 2585 | IrInstSrc *child_type, bool is_const, bool is_volatile, PtrLen ptr_len, |
| 2087 | IrInstruction *sentinel, IrInstruction *align_value, | 2586 | IrInstSrc *sentinel, IrInstSrc *align_value, |
| 2088 | uint32_t bit_offset_start, uint32_t host_int_bytes, bool is_allow_zero) | 2587 | uint32_t bit_offset_start, uint32_t host_int_bytes, bool is_allow_zero) |
| 2089 | { | 2588 | { |
| 2090 | IrInstructionPtrType *ptr_type_of_instruction = ir_build_instruction<IrInstructionPtrType>(irb, scope, source_node); | 2589 | IrInstSrcPtrType *inst = ir_build_instruction<IrInstSrcPtrType>(irb, scope, source_node); |
| 2091 | ptr_type_of_instruction->sentinel = sentinel; | 2590 | inst->sentinel = sentinel; |
| 2092 | ptr_type_of_instruction->align_value = align_value; | 2591 | inst->align_value = align_value; |
| 2093 | ptr_type_of_instruction->child_type = child_type; | 2592 | inst->child_type = child_type; |
| 2094 | ptr_type_of_instruction->is_const = is_const; | 2593 | inst->is_const = is_const; |
| 2095 | ptr_type_of_instruction->is_volatile = is_volatile; | 2594 | inst->is_volatile = is_volatile; |
| 2096 | ptr_type_of_instruction->ptr_len = ptr_len; | 2595 | inst->ptr_len = ptr_len; |
| 2097 | ptr_type_of_instruction->bit_offset_start = bit_offset_start; | 2596 | inst->bit_offset_start = bit_offset_start; |
| 2098 | ptr_type_of_instruction->host_int_bytes = host_int_bytes; | 2597 | inst->host_int_bytes = host_int_bytes; |
| 2099 | ptr_type_of_instruction->is_allow_zero = is_allow_zero; | 2598 | inst->is_allow_zero = is_allow_zero; |
| 2100 | | 2599 | |
| 2101 | if (sentinel) ir_ref_instruction(sentinel, irb->current_basic_block); | 2600 | if (sentinel) ir_ref_instruction(sentinel, irb->current_basic_block); |
| 2102 | if (align_value) ir_ref_instruction(align_value, irb->current_basic_block); | 2601 | if (align_value) ir_ref_instruction(align_value, irb->current_basic_block); |
| 2103 | ir_ref_instruction(child_type, irb->current_basic_block); | 2602 | ir_ref_instruction(child_type, irb->current_basic_block); |
| 2104 | | 2603 | |
| 2105 | return &ptr_type_of_instruction->base; | 2604 | return &inst->base; |
| 2106 | } | 2605 | } |
| 2107 | | 2606 | |
| 2108 | static IrInstruction *ir_build_un_op_lval(IrBuilder *irb, Scope *scope, AstNode *source_node, IrUnOp op_id, | 2607 | static IrInstSrc *ir_build_un_op_lval(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrUnOp op_id, |
| 2109 | IrInstruction *value, LVal lval, ResultLoc *result_loc) | 2608 | IrInstSrc *value, LVal lval, ResultLoc *result_loc) |
| 2110 | { | 2609 | { |
| 2111 | IrInstructionUnOp *instruction = ir_build_instruction<IrInstructionUnOp>(irb, scope, source_node); | 2610 | IrInstSrcUnOp *instruction = ir_build_instruction<IrInstSrcUnOp>(irb, scope, source_node); |
| 2112 | instruction->op_id = op_id; | 2611 | instruction->op_id = op_id; |
| 2113 | instruction->value = value; | 2612 | instruction->value = value; |
| 2114 | instruction->lval = lval; | 2613 | instruction->lval = lval; |
| ... | @@ -2119,18 +2618,55 @@ static IrInstruction *ir_build_un_op_lval(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2119,18 +2618,55 @@ static IrInstruction *ir_build_un_op_lval(IrBuilder *irb, Scope *scope, AstNode |
| 2119 | return &instruction->base; | 2618 | return &instruction->base; |
| 2120 | } | 2619 | } |
| 2121 | | 2620 | |
| 2122 | static IrInstruction *ir_build_un_op(IrBuilder *irb, Scope *scope, AstNode *source_node, IrUnOp op_id, | 2621 | static IrInstSrc *ir_build_un_op(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrUnOp op_id, |
| 2123 | IrInstruction *value) | 2622 | IrInstSrc *value) |
| 2124 | { | 2623 | { |
| 2125 | return ir_build_un_op_lval(irb, scope, source_node, op_id, value, LValNone, nullptr); | 2624 | return ir_build_un_op_lval(irb, scope, source_node, op_id, value, LValNone, nullptr); |
| 2126 | } | 2625 | } |
| 2127 | | 2626 | |
| 2128 | static IrInstruction *ir_build_container_init_list(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2627 | static IrInstGen *ir_build_negation(IrAnalyze *ira, IrInst *source_instr, IrInstGen *operand, ZigType *expr_type) { |
| 2129 | size_t item_count, IrInstruction **elem_result_loc_list, IrInstruction *result_loc, | 2628 | IrInstGenNegation *instruction = ir_build_inst_gen<IrInstGenNegation>(&ira->new_irb, |
| | 2629 | source_instr->scope, source_instr->source_node); |
| | 2630 | instruction->base.value->type = expr_type; |
| | 2631 | instruction->operand = operand; |
| | 2632 | |
| | 2633 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| | 2634 | |
| | 2635 | return &instruction->base; |
| | 2636 | } |
| | 2637 | |
| | 2638 | static IrInstGen *ir_build_negation_wrapping(IrAnalyze *ira, IrInst *source_instr, IrInstGen *operand, |
| | 2639 | ZigType *expr_type) |
| | 2640 | { |
| | 2641 | IrInstGenNegationWrapping *instruction = ir_build_inst_gen<IrInstGenNegationWrapping>(&ira->new_irb, |
| | 2642 | source_instr->scope, source_instr->source_node); |
| | 2643 | instruction->base.value->type = expr_type; |
| | 2644 | instruction->operand = operand; |
| | 2645 | |
| | 2646 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| | 2647 | |
| | 2648 | return &instruction->base; |
| | 2649 | } |
| | 2650 | |
| | 2651 | static IrInstGen *ir_build_binary_not(IrAnalyze *ira, IrInst *source_instr, IrInstGen *operand, |
| | 2652 | ZigType *expr_type) |
| | 2653 | { |
| | 2654 | IrInstGenBinaryNot *instruction = ir_build_inst_gen<IrInstGenBinaryNot>(&ira->new_irb, |
| | 2655 | source_instr->scope, source_instr->source_node); |
| | 2656 | instruction->base.value->type = expr_type; |
| | 2657 | instruction->operand = operand; |
| | 2658 | |
| | 2659 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| | 2660 | |
| | 2661 | return &instruction->base; |
| | 2662 | } |
| | 2663 | |
| | 2664 | static IrInstSrc *ir_build_container_init_list(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 2665 | size_t item_count, IrInstSrc **elem_result_loc_list, IrInstSrc *result_loc, |
| 2130 | AstNode *init_array_type_source_node) | 2666 | AstNode *init_array_type_source_node) |
| 2131 | { | 2667 | { |
| 2132 | IrInstructionContainerInitList *container_init_list_instruction = | 2668 | IrInstSrcContainerInitList *container_init_list_instruction = |
| 2133 | ir_build_instruction<IrInstructionContainerInitList>(irb, scope, source_node); | 2669 | ir_build_instruction<IrInstSrcContainerInitList>(irb, scope, source_node); |
| 2134 | container_init_list_instruction->item_count = item_count; | 2670 | container_init_list_instruction->item_count = item_count; |
| 2135 | container_init_list_instruction->elem_result_loc_list = elem_result_loc_list; | 2671 | container_init_list_instruction->elem_result_loc_list = elem_result_loc_list; |
| 2136 | container_init_list_instruction->result_loc = result_loc; | 2672 | container_init_list_instruction->result_loc = result_loc; |
| ... | @@ -2144,11 +2680,11 @@ static IrInstruction *ir_build_container_init_list(IrBuilder *irb, Scope *scope, | ... | @@ -2144,11 +2680,11 @@ static IrInstruction *ir_build_container_init_list(IrBuilder *irb, Scope *scope, |
| 2144 | return &container_init_list_instruction->base; | 2680 | return &container_init_list_instruction->base; |
| 2145 | } | 2681 | } |
| 2146 | | 2682 | |
| 2147 | static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2683 | static IrInstSrc *ir_build_container_init_fields(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2148 | size_t field_count, IrInstructionContainerInitFieldsField *fields, IrInstruction *result_loc) | 2684 | size_t field_count, IrInstSrcContainerInitFieldsField *fields, IrInstSrc *result_loc) |
| 2149 | { | 2685 | { |
| 2150 | IrInstructionContainerInitFields *container_init_fields_instruction = | 2686 | IrInstSrcContainerInitFields *container_init_fields_instruction = |
| 2151 | ir_build_instruction<IrInstructionContainerInitFields>(irb, scope, source_node); | 2687 | ir_build_instruction<IrInstSrcContainerInitFields>(irb, scope, source_node); |
| 2152 | container_init_fields_instruction->field_count = field_count; | 2688 | container_init_fields_instruction->field_count = field_count; |
| 2153 | container_init_fields_instruction->fields = fields; | 2689 | container_init_fields_instruction->fields = fields; |
| 2154 | container_init_fields_instruction->result_loc = result_loc; | 2690 | container_init_fields_instruction->result_loc = result_loc; |
| ... | @@ -2161,20 +2697,21 @@ static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scop | ... | @@ -2161,20 +2697,21 @@ static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scop |
| 2161 | return &container_init_fields_instruction->base; | 2697 | return &container_init_fields_instruction->base; |
| 2162 | } | 2698 | } |
| 2163 | | 2699 | |
| 2164 | static IrInstruction *ir_build_unreachable(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 2700 | static IrInstSrc *ir_build_unreachable(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 2165 | IrInstructionUnreachable *unreachable_instruction = | 2701 | IrInstSrcUnreachable *inst = ir_build_instruction<IrInstSrcUnreachable>(irb, scope, source_node); |
| 2166 | ir_build_instruction<IrInstructionUnreachable>(irb, scope, source_node); | 2702 | inst->base.is_noreturn = true; |
| 2167 | unreachable_instruction->base.value->special = ConstValSpecialStatic; | 2703 | return &inst->base; |
| 2168 | unreachable_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; | 2704 | } |
| 2169 | return &unreachable_instruction->base; | 2705 | |
| | 2706 | static IrInstGen *ir_build_unreachable_gen(IrAnalyze *ira, IrInst *source_instr) { |
| | 2707 | IrInstGenUnreachable *inst = ir_build_inst_noreturn<IrInstGenUnreachable>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| | 2708 | return &inst->base; |
| 2170 | } | 2709 | } |
| 2171 | | 2710 | |
| 2172 | static IrInstructionStorePtr *ir_build_store_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2711 | static IrInstSrcStorePtr *ir_build_store_ptr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2173 | IrInstruction *ptr, IrInstruction *value) | 2712 | IrInstSrc *ptr, IrInstSrc *value) |
| 2174 | { | 2713 | { |
| 2175 | IrInstructionStorePtr *instruction = ir_build_instruction<IrInstructionStorePtr>(irb, scope, source_node); | 2714 | IrInstSrcStorePtr *instruction = ir_build_instruction<IrInstSrcStorePtr>(irb, scope, source_node); |
| 2176 | instruction->base.value->special = ConstValSpecialStatic; | | |
| 2177 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; | | |
| 2178 | instruction->ptr = ptr; | 2715 | instruction->ptr = ptr; |
| 2179 | instruction->value = value; | 2716 | instruction->value = value; |
| 2180 | | 2717 | |
| ... | @@ -2184,76 +2721,83 @@ static IrInstructionStorePtr *ir_build_store_ptr(IrBuilder *irb, Scope *scope, A | ... | @@ -2184,76 +2721,83 @@ static IrInstructionStorePtr *ir_build_store_ptr(IrBuilder *irb, Scope *scope, A |
| 2184 | return instruction; | 2721 | return instruction; |
| 2185 | } | 2722 | } |
| 2186 | | 2723 | |
| 2187 | static IrInstruction *ir_build_vector_store_elem(IrAnalyze *ira, IrInstruction *source_instruction, | 2724 | static IrInstGen *ir_build_store_ptr_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *ptr, IrInstGen *value) { |
| 2188 | IrInstruction *vector_ptr, IrInstruction *index, IrInstruction *value) | 2725 | IrInstGenStorePtr *instruction = ir_build_inst_void<IrInstGenStorePtr>(&ira->new_irb, |
| | 2726 | source_instr->scope, source_instr->source_node); |
| | 2727 | instruction->ptr = ptr; |
| | 2728 | instruction->value = value; |
| | 2729 | |
| | 2730 | ir_ref_inst_gen(ptr, ira->new_irb.current_basic_block); |
| | 2731 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| | 2732 | |
| | 2733 | return &instruction->base; |
| | 2734 | } |
| | 2735 | |
| | 2736 | static IrInstGen *ir_build_vector_store_elem(IrAnalyze *ira, IrInst *src_inst, |
| | 2737 | IrInstGen *vector_ptr, IrInstGen *index, IrInstGen *value) |
| 2189 | { | 2738 | { |
| 2190 | IrInstructionVectorStoreElem *inst = ir_build_instruction<IrInstructionVectorStoreElem>( | 2739 | IrInstGenVectorStoreElem *inst = ir_build_inst_void<IrInstGenVectorStoreElem>( |
| 2191 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 2740 | &ira->new_irb, src_inst->scope, src_inst->source_node); |
| 2192 | inst->base.value->type = ira->codegen->builtin_types.entry_void; | | |
| 2193 | inst->vector_ptr = vector_ptr; | 2741 | inst->vector_ptr = vector_ptr; |
| 2194 | inst->index = index; | 2742 | inst->index = index; |
| 2195 | inst->value = value; | 2743 | inst->value = value; |
| 2196 | | 2744 | |
| 2197 | ir_ref_instruction(vector_ptr, ira->new_irb.current_basic_block); | 2745 | ir_ref_inst_gen(vector_ptr, ira->new_irb.current_basic_block); |
| 2198 | ir_ref_instruction(index, ira->new_irb.current_basic_block); | 2746 | ir_ref_inst_gen(index, ira->new_irb.current_basic_block); |
| 2199 | ir_ref_instruction(value, ira->new_irb.current_basic_block); | 2747 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| 2200 | | 2748 | |
| 2201 | return &inst->base; | 2749 | return &inst->base; |
| 2202 | } | 2750 | } |
| 2203 | | 2751 | |
| 2204 | static IrInstruction *ir_build_var_decl_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2752 | static IrInstSrc *ir_build_var_decl_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2205 | ZigVar *var, IrInstruction *align_value, IrInstruction *ptr) | 2753 | ZigVar *var, IrInstSrc *align_value, IrInstSrc *ptr) |
| 2206 | { | 2754 | { |
| 2207 | IrInstructionDeclVarSrc *decl_var_instruction = ir_build_instruction<IrInstructionDeclVarSrc>(irb, scope, source_node); | 2755 | IrInstSrcDeclVar *inst = ir_build_instruction<IrInstSrcDeclVar>(irb, scope, source_node); |
| 2208 | decl_var_instruction->base.value->special = ConstValSpecialStatic; | 2756 | inst->var = var; |
| 2209 | decl_var_instruction->base.value->type = irb->codegen->builtin_types.entry_void; | 2757 | inst->align_value = align_value; |
| 2210 | decl_var_instruction->var = var; | 2758 | inst->ptr = ptr; |
| 2211 | decl_var_instruction->align_value = align_value; | | |
| 2212 | decl_var_instruction->ptr = ptr; | | |
| 2213 | | 2759 | |
| 2214 | if (align_value != nullptr) ir_ref_instruction(align_value, irb->current_basic_block); | 2760 | if (align_value != nullptr) ir_ref_instruction(align_value, irb->current_basic_block); |
| 2215 | ir_ref_instruction(ptr, irb->current_basic_block); | 2761 | ir_ref_instruction(ptr, irb->current_basic_block); |
| 2216 | | 2762 | |
| 2217 | return &decl_var_instruction->base; | 2763 | return &inst->base; |
| 2218 | } | 2764 | } |
| 2219 | | 2765 | |
| 2220 | static IrInstruction *ir_build_var_decl_gen(IrAnalyze *ira, IrInstruction *source_instruction, | 2766 | static IrInstGen *ir_build_var_decl_gen(IrAnalyze *ira, IrInst *source_instruction, |
| 2221 | ZigVar *var, IrInstruction *var_ptr) | 2767 | ZigVar *var, IrInstGen *var_ptr) |
| 2222 | { | 2768 | { |
| 2223 | IrInstructionDeclVarGen *decl_var_instruction = ir_build_instruction<IrInstructionDeclVarGen>(&ira->new_irb, | 2769 | IrInstGenDeclVar *inst = ir_build_inst_gen<IrInstGenDeclVar>(&ira->new_irb, |
| 2224 | source_instruction->scope, source_instruction->source_node); | 2770 | source_instruction->scope, source_instruction->source_node); |
| 2225 | decl_var_instruction->base.value->special = ConstValSpecialStatic; | 2771 | inst->base.value->special = ConstValSpecialStatic; |
| 2226 | decl_var_instruction->base.value->type = ira->codegen->builtin_types.entry_void; | 2772 | inst->base.value->type = ira->codegen->builtin_types.entry_void; |
| 2227 | decl_var_instruction->var = var; | 2773 | inst->var = var; |
| 2228 | decl_var_instruction->var_ptr = var_ptr; | 2774 | inst->var_ptr = var_ptr; |
| 2229 | | 2775 | |
| 2230 | ir_ref_instruction(var_ptr, ira->new_irb.current_basic_block); | 2776 | ir_ref_inst_gen(var_ptr, ira->new_irb.current_basic_block); |
| 2231 | | 2777 | |
| 2232 | return &decl_var_instruction->base; | 2778 | return &inst->base; |
| 2233 | } | 2779 | } |
| 2234 | | 2780 | |
| 2235 | static IrInstruction *ir_build_resize_slice(IrAnalyze *ira, IrInstruction *source_instruction, | 2781 | static IrInstGen *ir_build_resize_slice(IrAnalyze *ira, IrInst *source_instruction, |
| 2236 | IrInstruction *operand, ZigType *ty, IrInstruction *result_loc) | 2782 | IrInstGen *operand, ZigType *ty, IrInstGen *result_loc) |
| 2237 | { | 2783 | { |
| 2238 | IrInstructionResizeSlice *instruction = ir_build_instruction<IrInstructionResizeSlice>(&ira->new_irb, | 2784 | IrInstGenResizeSlice *instruction = ir_build_inst_gen<IrInstGenResizeSlice>(&ira->new_irb, |
| 2239 | source_instruction->scope, source_instruction->source_node); | 2785 | source_instruction->scope, source_instruction->source_node); |
| 2240 | instruction->base.value->type = ty; | 2786 | instruction->base.value->type = ty; |
| 2241 | instruction->operand = operand; | 2787 | instruction->operand = operand; |
| 2242 | instruction->result_loc = result_loc; | 2788 | instruction->result_loc = result_loc; |
| 2243 | | 2789 | |
| 2244 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); | 2790 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 2245 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 2791 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 2246 | | 2792 | |
| 2247 | return &instruction->base; | 2793 | return &instruction->base; |
| 2248 | } | 2794 | } |
| 2249 | | 2795 | |
| 2250 | static IrInstruction *ir_build_export(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2796 | static IrInstSrc *ir_build_export(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2251 | IrInstruction *target, IrInstruction *options) | 2797 | IrInstSrc *target, IrInstSrc *options) |
| 2252 | { | 2798 | { |
| 2253 | IrInstructionExport *export_instruction = ir_build_instruction<IrInstructionExport>( | 2799 | IrInstSrcExport *export_instruction = ir_build_instruction<IrInstSrcExport>( |
| 2254 | irb, scope, source_node); | 2800 | irb, scope, source_node); |
| 2255 | export_instruction->base.value->special = ConstValSpecialStatic; | | |
| 2256 | export_instruction->base.value->type = irb->codegen->builtin_types.entry_void; | | |
| 2257 | export_instruction->target = target; | 2801 | export_instruction->target = target; |
| 2258 | export_instruction->options = options; | 2802 | export_instruction->options = options; |
| 2259 | | 2803 | |
| ... | @@ -2263,8 +2807,8 @@ static IrInstruction *ir_build_export(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -2263,8 +2807,8 @@ static IrInstruction *ir_build_export(IrBuilder *irb, Scope *scope, AstNode *sou |
| 2263 | return &export_instruction->base; | 2807 | return &export_instruction->base; |
| 2264 | } | 2808 | } |
| 2265 | | 2809 | |
| 2266 | static IrInstruction *ir_build_load_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *ptr) { | 2810 | static IrInstSrc *ir_build_load_ptr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *ptr) { |
| 2267 | IrInstructionLoadPtr *instruction = ir_build_instruction<IrInstructionLoadPtr>(irb, scope, source_node); | 2811 | IrInstSrcLoadPtr *instruction = ir_build_instruction<IrInstSrcLoadPtr>(irb, scope, source_node); |
| 2268 | instruction->ptr = ptr; | 2812 | instruction->ptr = ptr; |
| 2269 | | 2813 | |
| 2270 | ir_ref_instruction(ptr, irb->current_basic_block); | 2814 | ir_ref_instruction(ptr, irb->current_basic_block); |
| ... | @@ -2272,8 +2816,23 @@ static IrInstruction *ir_build_load_ptr(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2272,8 +2816,23 @@ static IrInstruction *ir_build_load_ptr(IrBuilder *irb, Scope *scope, AstNode *s |
| 2272 | return &instruction->base; | 2816 | return &instruction->base; |
| 2273 | } | 2817 | } |
| 2274 | | 2818 | |
| 2275 | static IrInstruction *ir_build_typeof(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *value) { | 2819 | static IrInstGen *ir_build_load_ptr_gen(IrAnalyze *ira, IrInst *source_instruction, |
| 2276 | IrInstructionTypeOf *instruction = ir_build_instruction<IrInstructionTypeOf>(irb, scope, source_node); | 2820 | IrInstGen *ptr, ZigType *ty, IrInstGen *result_loc) |
| | 2821 | { |
| | 2822 | IrInstGenLoadPtr *instruction = ir_build_inst_gen<IrInstGenLoadPtr>( |
| | 2823 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| | 2824 | instruction->base.value->type = ty; |
| | 2825 | instruction->ptr = ptr; |
| | 2826 | instruction->result_loc = result_loc; |
| | 2827 | |
| | 2828 | ir_ref_inst_gen(ptr, ira->new_irb.current_basic_block); |
| | 2829 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| | 2830 | |
| | 2831 | return &instruction->base; |
| | 2832 | } |
| | 2833 | |
| | 2834 | static IrInstSrc *ir_build_typeof(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *value) { |
| | 2835 | IrInstSrcTypeOf *instruction = ir_build_instruction<IrInstSrcTypeOf>(irb, scope, source_node); |
| 2277 | instruction->value = value; | 2836 | instruction->value = value; |
| 2278 | | 2837 | |
| 2279 | ir_ref_instruction(value, irb->current_basic_block); | 2838 | ir_ref_instruction(value, irb->current_basic_block); |
| ... | @@ -2281,8 +2840,8 @@ static IrInstruction *ir_build_typeof(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -2281,8 +2840,8 @@ static IrInstruction *ir_build_typeof(IrBuilder *irb, Scope *scope, AstNode *sou |
| 2281 | return &instruction->base; | 2840 | return &instruction->base; |
| 2282 | } | 2841 | } |
| 2283 | | 2842 | |
| 2284 | static IrInstruction *ir_build_set_cold(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *is_cold) { | 2843 | static IrInstSrc *ir_build_set_cold(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *is_cold) { |
| 2285 | IrInstructionSetCold *instruction = ir_build_instruction<IrInstructionSetCold>(irb, scope, source_node); | 2844 | IrInstSrcSetCold *instruction = ir_build_instruction<IrInstSrcSetCold>(irb, scope, source_node); |
| 2286 | instruction->is_cold = is_cold; | 2845 | instruction->is_cold = is_cold; |
| 2287 | | 2846 | |
| 2288 | ir_ref_instruction(is_cold, irb->current_basic_block); | 2847 | ir_ref_instruction(is_cold, irb->current_basic_block); |
| ... | @@ -2290,21 +2849,21 @@ static IrInstruction *ir_build_set_cold(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2290,21 +2849,21 @@ static IrInstruction *ir_build_set_cold(IrBuilder *irb, Scope *scope, AstNode *s |
| 2290 | return &instruction->base; | 2849 | return &instruction->base; |
| 2291 | } | 2850 | } |
| 2292 | | 2851 | |
| 2293 | static IrInstruction *ir_build_set_runtime_safety(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2852 | static IrInstSrc *ir_build_set_runtime_safety(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2294 | IrInstruction *safety_on) | 2853 | IrInstSrc *safety_on) |
| 2295 | { | 2854 | { |
| 2296 | IrInstructionSetRuntimeSafety *instruction = ir_build_instruction<IrInstructionSetRuntimeSafety>(irb, scope, source_node); | 2855 | IrInstSrcSetRuntimeSafety *inst = ir_build_instruction<IrInstSrcSetRuntimeSafety>(irb, scope, source_node); |
| 2297 | instruction->safety_on = safety_on; | 2856 | inst->safety_on = safety_on; |
| 2298 | | 2857 | |
| 2299 | ir_ref_instruction(safety_on, irb->current_basic_block); | 2858 | ir_ref_instruction(safety_on, irb->current_basic_block); |
| 2300 | | 2859 | |
| 2301 | return &instruction->base; | 2860 | return &inst->base; |
| 2302 | } | 2861 | } |
| 2303 | | 2862 | |
| 2304 | static IrInstruction *ir_build_set_float_mode(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2863 | static IrInstSrc *ir_build_set_float_mode(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2305 | IrInstruction *mode_value) | 2864 | IrInstSrc *mode_value) |
| 2306 | { | 2865 | { |
| 2307 | IrInstructionSetFloatMode *instruction = ir_build_instruction<IrInstructionSetFloatMode>(irb, scope, source_node); | 2866 | IrInstSrcSetFloatMode *instruction = ir_build_instruction<IrInstSrcSetFloatMode>(irb, scope, source_node); |
| 2308 | instruction->mode_value = mode_value; | 2867 | instruction->mode_value = mode_value; |
| 2309 | | 2868 | |
| 2310 | ir_ref_instruction(mode_value, irb->current_basic_block); | 2869 | ir_ref_instruction(mode_value, irb->current_basic_block); |
| ... | @@ -2312,10 +2871,10 @@ static IrInstruction *ir_build_set_float_mode(IrBuilder *irb, Scope *scope, AstN | ... | @@ -2312,10 +2871,10 @@ static IrInstruction *ir_build_set_float_mode(IrBuilder *irb, Scope *scope, AstN |
| 2312 | return &instruction->base; | 2871 | return &instruction->base; |
| 2313 | } | 2872 | } |
| 2314 | | 2873 | |
| 2315 | static IrInstruction *ir_build_array_type(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *size, | 2874 | static IrInstSrc *ir_build_array_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *size, |
| 2316 | IrInstruction *sentinel, IrInstruction *child_type) | 2875 | IrInstSrc *sentinel, IrInstSrc *child_type) |
| 2317 | { | 2876 | { |
| 2318 | IrInstructionArrayType *instruction = ir_build_instruction<IrInstructionArrayType>(irb, scope, source_node); | 2877 | IrInstSrcArrayType *instruction = ir_build_instruction<IrInstSrcArrayType>(irb, scope, source_node); |
| 2319 | instruction->size = size; | 2878 | instruction->size = size; |
| 2320 | instruction->sentinel = sentinel; | 2879 | instruction->sentinel = sentinel; |
| 2321 | instruction->child_type = child_type; | 2880 | instruction->child_type = child_type; |
| ... | @@ -2327,10 +2886,10 @@ static IrInstruction *ir_build_array_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2327,10 +2886,10 @@ static IrInstruction *ir_build_array_type(IrBuilder *irb, Scope *scope, AstNode |
| 2327 | return &instruction->base; | 2886 | return &instruction->base; |
| 2328 | } | 2887 | } |
| 2329 | | 2888 | |
| 2330 | static IrInstruction *ir_build_anyframe_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2889 | static IrInstSrc *ir_build_anyframe_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2331 | IrInstruction *payload_type) | 2890 | IrInstSrc *payload_type) |
| 2332 | { | 2891 | { |
| 2333 | IrInstructionAnyFrameType *instruction = ir_build_instruction<IrInstructionAnyFrameType>(irb, scope, source_node); | 2892 | IrInstSrcAnyFrameType *instruction = ir_build_instruction<IrInstSrcAnyFrameType>(irb, scope, source_node); |
| 2334 | instruction->payload_type = payload_type; | 2893 | instruction->payload_type = payload_type; |
| 2335 | | 2894 | |
| 2336 | if (payload_type != nullptr) ir_ref_instruction(payload_type, irb->current_basic_block); | 2895 | if (payload_type != nullptr) ir_ref_instruction(payload_type, irb->current_basic_block); |
| ... | @@ -2338,11 +2897,11 @@ static IrInstruction *ir_build_anyframe_type(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -2338,11 +2897,11 @@ static IrInstruction *ir_build_anyframe_type(IrBuilder *irb, Scope *scope, AstNo |
| 2338 | return &instruction->base; | 2897 | return &instruction->base; |
| 2339 | } | 2898 | } |
| 2340 | | 2899 | |
| 2341 | static IrInstruction *ir_build_slice_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2900 | static IrInstSrc *ir_build_slice_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2342 | IrInstruction *child_type, bool is_const, bool is_volatile, | 2901 | IrInstSrc *child_type, bool is_const, bool is_volatile, |
| 2343 | IrInstruction *sentinel, IrInstruction *align_value, bool is_allow_zero) | 2902 | IrInstSrc *sentinel, IrInstSrc *align_value, bool is_allow_zero) |
| 2344 | { | 2903 | { |
| 2345 | IrInstructionSliceType *instruction = ir_build_instruction<IrInstructionSliceType>(irb, scope, source_node); | 2904 | IrInstSrcSliceType *instruction = ir_build_instruction<IrInstSrcSliceType>(irb, scope, source_node); |
| 2346 | instruction->is_const = is_const; | 2905 | instruction->is_const = is_const; |
| 2347 | instruction->is_volatile = is_volatile; | 2906 | instruction->is_volatile = is_volatile; |
| 2348 | instruction->child_type = child_type; | 2907 | instruction->child_type = child_type; |
| ... | @@ -2357,11 +2916,11 @@ static IrInstruction *ir_build_slice_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2357,11 +2916,11 @@ static IrInstruction *ir_build_slice_type(IrBuilder *irb, Scope *scope, AstNode |
| 2357 | return &instruction->base; | 2916 | return &instruction->base; |
| 2358 | } | 2917 | } |
| 2359 | | 2918 | |
| 2360 | static IrInstruction *ir_build_asm_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2919 | static IrInstSrc *ir_build_asm_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2361 | IrInstruction *asm_template, IrInstruction **input_list, IrInstruction **output_types, | 2920 | IrInstSrc *asm_template, IrInstSrc **input_list, IrInstSrc **output_types, |
| 2362 | ZigVar **output_vars, size_t return_count, bool has_side_effects, bool is_global) | 2921 | ZigVar **output_vars, size_t return_count, bool has_side_effects, bool is_global) |
| 2363 | { | 2922 | { |
| 2364 | IrInstructionAsmSrc *instruction = ir_build_instruction<IrInstructionAsmSrc>(irb, scope, source_node); | 2923 | IrInstSrcAsm *instruction = ir_build_instruction<IrInstSrcAsm>(irb, scope, source_node); |
| 2365 | instruction->asm_template = asm_template; | 2924 | instruction->asm_template = asm_template; |
| 2366 | instruction->input_list = input_list; | 2925 | instruction->input_list = input_list; |
| 2367 | instruction->output_types = output_types; | 2926 | instruction->output_types = output_types; |
| ... | @@ -2372,24 +2931,25 @@ static IrInstruction *ir_build_asm_src(IrBuilder *irb, Scope *scope, AstNode *so | ... | @@ -2372,24 +2931,25 @@ static IrInstruction *ir_build_asm_src(IrBuilder *irb, Scope *scope, AstNode *so |
| 2372 | | 2931 | |
| 2373 | assert(source_node->type == NodeTypeAsmExpr); | 2932 | assert(source_node->type == NodeTypeAsmExpr); |
| 2374 | for (size_t i = 0; i < source_node->data.asm_expr.output_list.length; i += 1) { | 2933 | for (size_t i = 0; i < source_node->data.asm_expr.output_list.length; i += 1) { |
| 2375 | IrInstruction *output_type = output_types[i]; | 2934 | IrInstSrc *output_type = output_types[i]; |
| 2376 | if (output_type) ir_ref_instruction(output_type, irb->current_basic_block); | 2935 | if (output_type) ir_ref_instruction(output_type, irb->current_basic_block); |
| 2377 | } | 2936 | } |
| 2378 | | 2937 | |
| 2379 | for (size_t i = 0; i < source_node->data.asm_expr.input_list.length; i += 1) { | 2938 | for (size_t i = 0; i < source_node->data.asm_expr.input_list.length; i += 1) { |
| 2380 | IrInstruction *input_value = input_list[i]; | 2939 | IrInstSrc *input_value = input_list[i]; |
| 2381 | ir_ref_instruction(input_value, irb->current_basic_block); | 2940 | ir_ref_instruction(input_value, irb->current_basic_block); |
| 2382 | } | 2941 | } |
| 2383 | | 2942 | |
| 2384 | return &instruction->base; | 2943 | return &instruction->base; |
| 2385 | } | 2944 | } |
| 2386 | | 2945 | |
| 2387 | static IrInstruction *ir_build_asm_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | 2946 | static IrInstGen *ir_build_asm_gen(IrAnalyze *ira, IrInst *source_instr, |
| 2388 | Buf *asm_template, AsmToken *token_list, size_t token_list_len, | 2947 | Buf *asm_template, AsmToken *token_list, size_t token_list_len, |
| 2389 | IrInstruction **input_list, IrInstruction **output_types, ZigVar **output_vars, size_t return_count, | 2948 | IrInstGen **input_list, IrInstGen **output_types, ZigVar **output_vars, size_t return_count, |
| 2390 | bool has_side_effects) | 2949 | bool has_side_effects, ZigType *return_type) |
| 2391 | { | 2950 | { |
| 2392 | IrInstructionAsmGen *instruction = ir_build_instruction<IrInstructionAsmGen>(&ira->new_irb, scope, source_node); | 2951 | IrInstGenAsm *instruction = ir_build_inst_gen<IrInstGenAsm>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| | 2952 | instruction->base.value->type = return_type; |
| 2393 | instruction->asm_template = asm_template; | 2953 | instruction->asm_template = asm_template; |
| 2394 | instruction->token_list = token_list; | 2954 | instruction->token_list = token_list; |
| 2395 | instruction->token_list_len = token_list_len; | 2955 | instruction->token_list_len = token_list_len; |
| ... | @@ -2399,22 +2959,24 @@ static IrInstruction *ir_build_asm_gen(IrAnalyze *ira, Scope *scope, AstNode *so | ... | @@ -2399,22 +2959,24 @@ static IrInstruction *ir_build_asm_gen(IrAnalyze *ira, Scope *scope, AstNode *so |
| 2399 | instruction->return_count = return_count; | 2959 | instruction->return_count = return_count; |
| 2400 | instruction->has_side_effects = has_side_effects; | 2960 | instruction->has_side_effects = has_side_effects; |
| 2401 | | 2961 | |
| 2402 | assert(source_node->type == NodeTypeAsmExpr); | 2962 | assert(source_instr->source_node->type == NodeTypeAsmExpr); |
| 2403 | for (size_t i = 0; i < source_node->data.asm_expr.output_list.length; i += 1) { | 2963 | for (size_t i = 0; i < source_instr->source_node->data.asm_expr.output_list.length; i += 1) { |
| 2404 | IrInstruction *output_type = output_types[i]; | 2964 | IrInstGen *output_type = output_types[i]; |
| 2405 | if (output_type) ir_ref_instruction(output_type, ira->new_irb.current_basic_block); | 2965 | if (output_type) ir_ref_inst_gen(output_type, ira->new_irb.current_basic_block); |
| 2406 | } | 2966 | } |
| 2407 | | 2967 | |
| 2408 | for (size_t i = 0; i < source_node->data.asm_expr.input_list.length; i += 1) { | 2968 | for (size_t i = 0; i < source_instr->source_node->data.asm_expr.input_list.length; i += 1) { |
| 2409 | IrInstruction *input_value = input_list[i]; | 2969 | IrInstGen *input_value = input_list[i]; |
| 2410 | ir_ref_instruction(input_value, ira->new_irb.current_basic_block); | 2970 | ir_ref_inst_gen(input_value, ira->new_irb.current_basic_block); |
| 2411 | } | 2971 | } |
| 2412 | | 2972 | |
| 2413 | return &instruction->base; | 2973 | return &instruction->base; |
| 2414 | } | 2974 | } |
| 2415 | | 2975 | |
| 2416 | static IrInstruction *ir_build_size_of(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *type_value, bool bit_size) { | 2976 | static IrInstSrc *ir_build_size_of(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type_value, |
| 2417 | IrInstructionSizeOf *instruction = ir_build_instruction<IrInstructionSizeOf>(irb, scope, source_node); | 2977 | bool bit_size) |
| | 2978 | { |
| | 2979 | IrInstSrcSizeOf *instruction = ir_build_instruction<IrInstSrcSizeOf>(irb, scope, source_node); |
| 2418 | instruction->type_value = type_value; | 2980 | instruction->type_value = type_value; |
| 2419 | instruction->bit_size = bit_size; | 2981 | instruction->bit_size = bit_size; |
| 2420 | | 2982 | |
| ... | @@ -2423,8 +2985,10 @@ static IrInstruction *ir_build_size_of(IrBuilder *irb, Scope *scope, AstNode *so | ... | @@ -2423,8 +2985,10 @@ static IrInstruction *ir_build_size_of(IrBuilder *irb, Scope *scope, AstNode *so |
| 2423 | return &instruction->base; | 2985 | return &instruction->base; |
| 2424 | } | 2986 | } |
| 2425 | | 2987 | |
| 2426 | static IrInstruction *ir_build_test_nonnull(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *value) { | 2988 | static IrInstSrc *ir_build_test_non_null_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2427 | IrInstructionTestNonNull *instruction = ir_build_instruction<IrInstructionTestNonNull>(irb, scope, source_node); | 2989 | IrInstSrc *value) |
| | 2990 | { |
| | 2991 | IrInstSrcTestNonNull *instruction = ir_build_instruction<IrInstSrcTestNonNull>(irb, scope, source_node); |
| 2428 | instruction->value = value; | 2992 | instruction->value = value; |
| 2429 | | 2993 | |
| 2430 | ir_ref_instruction(value, irb->current_basic_block); | 2994 | ir_ref_instruction(value, irb->current_basic_block); |
| ... | @@ -2432,10 +2996,21 @@ static IrInstruction *ir_build_test_nonnull(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -2432,10 +2996,21 @@ static IrInstruction *ir_build_test_nonnull(IrBuilder *irb, Scope *scope, AstNod |
| 2432 | return &instruction->base; | 2996 | return &instruction->base; |
| 2433 | } | 2997 | } |
| 2434 | | 2998 | |
| 2435 | static IrInstruction *ir_build_optional_unwrap_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2999 | static IrInstGen *ir_build_test_non_null_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *value) { |
| 2436 | IrInstruction *base_ptr, bool safety_check_on, bool initializing) | 3000 | IrInstGenTestNonNull *inst = ir_build_inst_gen<IrInstGenTestNonNull>(&ira->new_irb, |
| | 3001 | source_instr->scope, source_instr->source_node); |
| | 3002 | inst->base.value->type = ira->codegen->builtin_types.entry_bool; |
| | 3003 | inst->value = value; |
| | 3004 | |
| | 3005 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| | 3006 | |
| | 3007 | return &inst->base; |
| | 3008 | } |
| | 3009 | |
| | 3010 | static IrInstSrc *ir_build_optional_unwrap_ptr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 3011 | IrInstSrc *base_ptr, bool safety_check_on, bool initializing) |
| 2437 | { | 3012 | { |
| 2438 | IrInstructionOptionalUnwrapPtr *instruction = ir_build_instruction<IrInstructionOptionalUnwrapPtr>(irb, scope, source_node); | 3013 | IrInstSrcOptionalUnwrapPtr *instruction = ir_build_instruction<IrInstSrcOptionalUnwrapPtr>(irb, scope, source_node); |
| 2439 | instruction->base_ptr = base_ptr; | 3014 | instruction->base_ptr = base_ptr; |
| 2440 | instruction->safety_check_on = safety_check_on; | 3015 | instruction->safety_check_on = safety_check_on; |
| 2441 | instruction->initializing = initializing; | 3016 | instruction->initializing = initializing; |
| ... | @@ -2445,113 +3020,198 @@ static IrInstruction *ir_build_optional_unwrap_ptr(IrBuilder *irb, Scope *scope, | ... | @@ -2445,113 +3020,198 @@ static IrInstruction *ir_build_optional_unwrap_ptr(IrBuilder *irb, Scope *scope, |
| 2445 | return &instruction->base; | 3020 | return &instruction->base; |
| 2446 | } | 3021 | } |
| 2447 | | 3022 | |
| 2448 | static IrInstruction *ir_build_optional_wrap(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *result_ty, | 3023 | static IrInstGen *ir_build_optional_unwrap_ptr_gen(IrAnalyze *ira, IrInst *source_instr, |
| 2449 | IrInstruction *operand, IrInstruction *result_loc) | 3024 | IrInstGen *base_ptr, bool safety_check_on, bool initializing, ZigType *result_type) |
| | 3025 | { |
| | 3026 | IrInstGenOptionalUnwrapPtr *inst = ir_build_inst_gen<IrInstGenOptionalUnwrapPtr>(&ira->new_irb, |
| | 3027 | source_instr->scope, source_instr->source_node); |
| | 3028 | inst->base.value->type = result_type; |
| | 3029 | inst->base_ptr = base_ptr; |
| | 3030 | inst->safety_check_on = safety_check_on; |
| | 3031 | inst->initializing = initializing; |
| | 3032 | |
| | 3033 | ir_ref_inst_gen(base_ptr, ira->new_irb.current_basic_block); |
| | 3034 | |
| | 3035 | return &inst->base; |
| | 3036 | } |
| | 3037 | |
| | 3038 | static IrInstGen *ir_build_optional_wrap(IrAnalyze *ira, IrInst *source_instruction, ZigType *result_ty, |
| | 3039 | IrInstGen *operand, IrInstGen *result_loc) |
| 2450 | { | 3040 | { |
| 2451 | IrInstructionOptionalWrap *instruction = ir_build_instruction<IrInstructionOptionalWrap>( | 3041 | IrInstGenOptionalWrap *instruction = ir_build_inst_gen<IrInstGenOptionalWrap>( |
| 2452 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 3042 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2453 | instruction->base.value->type = result_ty; | 3043 | instruction->base.value->type = result_ty; |
| 2454 | instruction->operand = operand; | 3044 | instruction->operand = operand; |
| 2455 | instruction->result_loc = result_loc; | 3045 | instruction->result_loc = result_loc; |
| 2456 | | 3046 | |
| 2457 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); | 3047 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 2458 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 3048 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 2459 | | 3049 | |
| 2460 | return &instruction->base; | 3050 | return &instruction->base; |
| 2461 | } | 3051 | } |
| 2462 | | 3052 | |
| 2463 | static IrInstruction *ir_build_err_wrap_payload(IrAnalyze *ira, IrInstruction *source_instruction, | 3053 | static IrInstGen *ir_build_err_wrap_payload(IrAnalyze *ira, IrInst *source_instruction, |
| 2464 | ZigType *result_type, IrInstruction *operand, IrInstruction *result_loc) | 3054 | ZigType *result_type, IrInstGen *operand, IrInstGen *result_loc) |
| 2465 | { | 3055 | { |
| 2466 | IrInstructionErrWrapPayload *instruction = ir_build_instruction<IrInstructionErrWrapPayload>( | 3056 | IrInstGenErrWrapPayload *instruction = ir_build_inst_gen<IrInstGenErrWrapPayload>( |
| 2467 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 3057 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2468 | instruction->base.value->type = result_type; | 3058 | instruction->base.value->type = result_type; |
| 2469 | instruction->operand = operand; | 3059 | instruction->operand = operand; |
| 2470 | instruction->result_loc = result_loc; | 3060 | instruction->result_loc = result_loc; |
| 2471 | | 3061 | |
| 2472 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); | 3062 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 2473 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 3063 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 2474 | | 3064 | |
| 2475 | return &instruction->base; | 3065 | return &instruction->base; |
| 2476 | } | 3066 | } |
| 2477 | | 3067 | |
| 2478 | static IrInstruction *ir_build_err_wrap_code(IrAnalyze *ira, IrInstruction *source_instruction, | 3068 | static IrInstGen *ir_build_err_wrap_code(IrAnalyze *ira, IrInst *source_instruction, |
| 2479 | ZigType *result_type, IrInstruction *operand, IrInstruction *result_loc) | 3069 | ZigType *result_type, IrInstGen *operand, IrInstGen *result_loc) |
| 2480 | { | 3070 | { |
| 2481 | IrInstructionErrWrapCode *instruction = ir_build_instruction<IrInstructionErrWrapCode>( | 3071 | IrInstGenErrWrapCode *instruction = ir_build_inst_gen<IrInstGenErrWrapCode>( |
| 2482 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 3072 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2483 | instruction->base.value->type = result_type; | 3073 | instruction->base.value->type = result_type; |
| 2484 | instruction->operand = operand; | 3074 | instruction->operand = operand; |
| 2485 | instruction->result_loc = result_loc; | 3075 | instruction->result_loc = result_loc; |
| 2486 | | 3076 | |
| 2487 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); | 3077 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 2488 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 3078 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 2489 | | 3079 | |
| 2490 | return &instruction->base; | 3080 | return &instruction->base; |
| 2491 | } | 3081 | } |
| 2492 | | 3082 | |
| 2493 | static IrInstruction *ir_build_clz(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *type, IrInstruction *op) { | 3083 | static IrInstSrc *ir_build_clz(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type, |
| 2494 | IrInstructionClz *instruction = ir_build_instruction<IrInstructionClz>(irb, scope, source_node); | 3084 | IrInstSrc *op) |
| | 3085 | { |
| | 3086 | IrInstSrcClz *instruction = ir_build_instruction<IrInstSrcClz>(irb, scope, source_node); |
| 2495 | instruction->type = type; | 3087 | instruction->type = type; |
| 2496 | instruction->op = op; | 3088 | instruction->op = op; |
| 2497 | | 3089 | |
| 2498 | if (type != nullptr) ir_ref_instruction(type, irb->current_basic_block); | 3090 | ir_ref_instruction(type, irb->current_basic_block); |
| 2499 | ir_ref_instruction(op, irb->current_basic_block); | 3091 | ir_ref_instruction(op, irb->current_basic_block); |
| 2500 | | 3092 | |
| 2501 | return &instruction->base; | 3093 | return &instruction->base; |
| 2502 | } | 3094 | } |
| 2503 | | 3095 | |
| 2504 | static IrInstruction *ir_build_ctz(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *type, IrInstruction *op) { | 3096 | static IrInstGen *ir_build_clz_gen(IrAnalyze *ira, IrInst *source_instr, ZigType *result_type, IrInstGen *op) { |
| 2505 | IrInstructionCtz *instruction = ir_build_instruction<IrInstructionCtz>(irb, scope, source_node); | 3097 | IrInstGenClz *instruction = ir_build_inst_gen<IrInstGenClz>(&ira->new_irb, |
| | 3098 | source_instr->scope, source_instr->source_node); |
| | 3099 | instruction->base.value->type = result_type; |
| | 3100 | instruction->op = op; |
| | 3101 | |
| | 3102 | ir_ref_inst_gen(op, ira->new_irb.current_basic_block); |
| | 3103 | |
| | 3104 | return &instruction->base; |
| | 3105 | } |
| | 3106 | |
| | 3107 | static IrInstSrc *ir_build_ctz(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type, |
| | 3108 | IrInstSrc *op) |
| | 3109 | { |
| | 3110 | IrInstSrcCtz *instruction = ir_build_instruction<IrInstSrcCtz>(irb, scope, source_node); |
| 2506 | instruction->type = type; | 3111 | instruction->type = type; |
| 2507 | instruction->op = op; | 3112 | instruction->op = op; |
| 2508 | | 3113 | |
| 2509 | if (type != nullptr) ir_ref_instruction(type, irb->current_basic_block); | 3114 | ir_ref_instruction(type, irb->current_basic_block); |
| 2510 | ir_ref_instruction(op, irb->current_basic_block); | 3115 | ir_ref_instruction(op, irb->current_basic_block); |
| 2511 | | 3116 | |
| 2512 | return &instruction->base; | 3117 | return &instruction->base; |
| 2513 | } | 3118 | } |
| 2514 | | 3119 | |
| 2515 | static IrInstruction *ir_build_pop_count(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *type, IrInstruction *op) { | 3120 | static IrInstGen *ir_build_ctz_gen(IrAnalyze *ira, IrInst *source_instr, ZigType *result_type, IrInstGen *op) { |
| 2516 | IrInstructionPopCount *instruction = ir_build_instruction<IrInstructionPopCount>(irb, scope, source_node); | 3121 | IrInstGenCtz *instruction = ir_build_inst_gen<IrInstGenCtz>(&ira->new_irb, |
| | 3122 | source_instr->scope, source_instr->source_node); |
| | 3123 | instruction->base.value->type = result_type; |
| | 3124 | instruction->op = op; |
| | 3125 | |
| | 3126 | ir_ref_inst_gen(op, ira->new_irb.current_basic_block); |
| | 3127 | |
| | 3128 | return &instruction->base; |
| | 3129 | } |
| | 3130 | |
| | 3131 | static IrInstSrc *ir_build_pop_count(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type, |
| | 3132 | IrInstSrc *op) |
| | 3133 | { |
| | 3134 | IrInstSrcPopCount *instruction = ir_build_instruction<IrInstSrcPopCount>(irb, scope, source_node); |
| 2517 | instruction->type = type; | 3135 | instruction->type = type; |
| 2518 | instruction->op = op; | 3136 | instruction->op = op; |
| 2519 | | 3137 | |
| 2520 | if (type != nullptr) ir_ref_instruction(type, irb->current_basic_block); | 3138 | ir_ref_instruction(type, irb->current_basic_block); |
| 2521 | ir_ref_instruction(op, irb->current_basic_block); | 3139 | ir_ref_instruction(op, irb->current_basic_block); |
| 2522 | | 3140 | |
| 2523 | return &instruction->base; | 3141 | return &instruction->base; |
| 2524 | } | 3142 | } |
| 2525 | | 3143 | |
| 2526 | static IrInstruction *ir_build_bswap(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *type, IrInstruction *op) { | 3144 | static IrInstGen *ir_build_pop_count_gen(IrAnalyze *ira, IrInst *source_instr, ZigType *result_type, |
| 2527 | IrInstructionBswap *instruction = ir_build_instruction<IrInstructionBswap>(irb, scope, source_node); | 3145 | IrInstGen *op) |
| | 3146 | { |
| | 3147 | IrInstGenPopCount *instruction = ir_build_inst_gen<IrInstGenPopCount>(&ira->new_irb, |
| | 3148 | source_instr->scope, source_instr->source_node); |
| | 3149 | instruction->base.value->type = result_type; |
| | 3150 | instruction->op = op; |
| | 3151 | |
| | 3152 | ir_ref_inst_gen(op, ira->new_irb.current_basic_block); |
| | 3153 | |
| | 3154 | return &instruction->base; |
| | 3155 | } |
| | 3156 | |
| | 3157 | static IrInstSrc *ir_build_bswap(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type, |
| | 3158 | IrInstSrc *op) |
| | 3159 | { |
| | 3160 | IrInstSrcBswap *instruction = ir_build_instruction<IrInstSrcBswap>(irb, scope, source_node); |
| 2528 | instruction->type = type; | 3161 | instruction->type = type; |
| 2529 | instruction->op = op; | 3162 | instruction->op = op; |
| 2530 | | 3163 | |
| 2531 | if (type != nullptr) ir_ref_instruction(type, irb->current_basic_block); | 3164 | ir_ref_instruction(type, irb->current_basic_block); |
| 2532 | ir_ref_instruction(op, irb->current_basic_block); | 3165 | ir_ref_instruction(op, irb->current_basic_block); |
| 2533 | | 3166 | |
| 2534 | return &instruction->base; | 3167 | return &instruction->base; |
| 2535 | } | 3168 | } |
| 2536 | | 3169 | |
| 2537 | static IrInstruction *ir_build_bit_reverse(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *type, IrInstruction *op) { | 3170 | static IrInstGen *ir_build_bswap_gen(IrAnalyze *ira, IrInst *source_instr, ZigType *op_type, |
| 2538 | IrInstructionBitReverse *instruction = ir_build_instruction<IrInstructionBitReverse>(irb, scope, source_node); | 3171 | IrInstGen *op) |
| | 3172 | { |
| | 3173 | IrInstGenBswap *instruction = ir_build_inst_gen<IrInstGenBswap>(&ira->new_irb, |
| | 3174 | source_instr->scope, source_instr->source_node); |
| | 3175 | instruction->base.value->type = op_type; |
| | 3176 | instruction->op = op; |
| | 3177 | |
| | 3178 | ir_ref_inst_gen(op, ira->new_irb.current_basic_block); |
| | 3179 | |
| | 3180 | return &instruction->base; |
| | 3181 | } |
| | 3182 | |
| | 3183 | static IrInstSrc *ir_build_bit_reverse(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type, |
| | 3184 | IrInstSrc *op) |
| | 3185 | { |
| | 3186 | IrInstSrcBitReverse *instruction = ir_build_instruction<IrInstSrcBitReverse>(irb, scope, source_node); |
| 2539 | instruction->type = type; | 3187 | instruction->type = type; |
| 2540 | instruction->op = op; | 3188 | instruction->op = op; |
| 2541 | | 3189 | |
| 2542 | if (type != nullptr) ir_ref_instruction(type, irb->current_basic_block); | 3190 | ir_ref_instruction(type, irb->current_basic_block); |
| 2543 | ir_ref_instruction(op, irb->current_basic_block); | 3191 | ir_ref_instruction(op, irb->current_basic_block); |
| 2544 | | 3192 | |
| 2545 | return &instruction->base; | 3193 | return &instruction->base; |
| 2546 | } | 3194 | } |
| 2547 | | 3195 | |
| 2548 | static IrInstructionSwitchBr *ir_build_switch_br(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *target_value, | 3196 | static IrInstGen *ir_build_bit_reverse_gen(IrAnalyze *ira, IrInst *source_instr, ZigType *int_type, |
| 2549 | IrBasicBlock *else_block, size_t case_count, IrInstructionSwitchBrCase *cases, IrInstruction *is_comptime, | 3197 | IrInstGen *op) |
| 2550 | IrInstruction *switch_prongs_void) | 3198 | { |
| | 3199 | IrInstGenBitReverse *instruction = ir_build_inst_gen<IrInstGenBitReverse>(&ira->new_irb, |
| | 3200 | source_instr->scope, source_instr->source_node); |
| | 3201 | instruction->base.value->type = int_type; |
| | 3202 | instruction->op = op; |
| | 3203 | |
| | 3204 | ir_ref_inst_gen(op, ira->new_irb.current_basic_block); |
| | 3205 | |
| | 3206 | return &instruction->base; |
| | 3207 | } |
| | 3208 | |
| | 3209 | static IrInstSrcSwitchBr *ir_build_switch_br_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 3210 | IrInstSrc *target_value, IrBasicBlockSrc *else_block, size_t case_count, IrInstSrcSwitchBrCase *cases, |
| | 3211 | IrInstSrc *is_comptime, IrInstSrc *switch_prongs_void) |
| 2551 | { | 3212 | { |
| 2552 | IrInstructionSwitchBr *instruction = ir_build_instruction<IrInstructionSwitchBr>(irb, scope, source_node); | 3213 | IrInstSrcSwitchBr *instruction = ir_build_instruction<IrInstSrcSwitchBr>(irb, scope, source_node); |
| 2553 | instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; | 3214 | instruction->base.is_noreturn = true; |
| 2554 | instruction->base.value->special = ConstValSpecialStatic; | | |
| 2555 | instruction->target_value = target_value; | 3215 | instruction->target_value = target_value; |
| 2556 | instruction->else_block = else_block; | 3216 | instruction->else_block = else_block; |
| 2557 | instruction->case_count = case_count; | 3217 | instruction->case_count = case_count; |
| ... | @@ -2560,9 +3220,9 @@ static IrInstructionSwitchBr *ir_build_switch_br(IrBuilder *irb, Scope *scope, A | ... | @@ -2560,9 +3220,9 @@ static IrInstructionSwitchBr *ir_build_switch_br(IrBuilder *irb, Scope *scope, A |
| 2560 | instruction->switch_prongs_void = switch_prongs_void; | 3220 | instruction->switch_prongs_void = switch_prongs_void; |
| 2561 | | 3221 | |
| 2562 | ir_ref_instruction(target_value, irb->current_basic_block); | 3222 | ir_ref_instruction(target_value, irb->current_basic_block); |
| 2563 | if (is_comptime) ir_ref_instruction(is_comptime, irb->current_basic_block); | 3223 | ir_ref_instruction(is_comptime, irb->current_basic_block); |
| 2564 | ir_ref_bb(else_block); | 3224 | ir_ref_bb(else_block); |
| 2565 | if (switch_prongs_void) ir_ref_instruction(switch_prongs_void, irb->current_basic_block); | 3225 | ir_ref_instruction(switch_prongs_void, irb->current_basic_block); |
| 2566 | | 3226 | |
| 2567 | for (size_t i = 0; i < case_count; i += 1) { | 3227 | for (size_t i = 0; i < case_count; i += 1) { |
| 2568 | ir_ref_instruction(cases[i].value, irb->current_basic_block); | 3228 | ir_ref_instruction(cases[i].value, irb->current_basic_block); |
| ... | @@ -2572,10 +3232,31 @@ static IrInstructionSwitchBr *ir_build_switch_br(IrBuilder *irb, Scope *scope, A | ... | @@ -2572,10 +3232,31 @@ static IrInstructionSwitchBr *ir_build_switch_br(IrBuilder *irb, Scope *scope, A |
| 2572 | return instruction; | 3232 | return instruction; |
| 2573 | } | 3233 | } |
| 2574 | | 3234 | |
| 2575 | static IrInstruction *ir_build_switch_target(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3235 | static IrInstGenSwitchBr *ir_build_switch_br_gen(IrAnalyze *ira, IrInst *source_instr, |
| 2576 | IrInstruction *target_value_ptr) | 3236 | IrInstGen *target_value, IrBasicBlockGen *else_block, size_t case_count, IrInstGenSwitchBrCase *cases) |
| | 3237 | { |
| | 3238 | IrInstGenSwitchBr *instruction = ir_build_inst_noreturn<IrInstGenSwitchBr>(&ira->new_irb, |
| | 3239 | source_instr->scope, source_instr->source_node); |
| | 3240 | instruction->target_value = target_value; |
| | 3241 | instruction->else_block = else_block; |
| | 3242 | instruction->case_count = case_count; |
| | 3243 | instruction->cases = cases; |
| | 3244 | |
| | 3245 | ir_ref_inst_gen(target_value, ira->new_irb.current_basic_block); |
| | 3246 | ir_ref_bb_gen(else_block); |
| | 3247 | |
| | 3248 | for (size_t i = 0; i < case_count; i += 1) { |
| | 3249 | ir_ref_inst_gen(cases[i].value, ira->new_irb.current_basic_block); |
| | 3250 | ir_ref_bb_gen(cases[i].block); |
| | 3251 | } |
| | 3252 | |
| | 3253 | return instruction; |
| | 3254 | } |
| | 3255 | |
| | 3256 | static IrInstSrc *ir_build_switch_target(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 3257 | IrInstSrc *target_value_ptr) |
| 2577 | { | 3258 | { |
| 2578 | IrInstructionSwitchTarget *instruction = ir_build_instruction<IrInstructionSwitchTarget>(irb, scope, source_node); | 3259 | IrInstSrcSwitchTarget *instruction = ir_build_instruction<IrInstSrcSwitchTarget>(irb, scope, source_node); |
| 2579 | instruction->target_value_ptr = target_value_ptr; | 3260 | instruction->target_value_ptr = target_value_ptr; |
| 2580 | | 3261 | |
| 2581 | ir_ref_instruction(target_value_ptr, irb->current_basic_block); | 3262 | ir_ref_instruction(target_value_ptr, irb->current_basic_block); |
| ... | @@ -2583,10 +3264,10 @@ static IrInstruction *ir_build_switch_target(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -2583,10 +3264,10 @@ static IrInstruction *ir_build_switch_target(IrBuilder *irb, Scope *scope, AstNo |
| 2583 | return &instruction->base; | 3264 | return &instruction->base; |
| 2584 | } | 3265 | } |
| 2585 | | 3266 | |
| 2586 | static IrInstruction *ir_build_switch_var(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3267 | static IrInstSrc *ir_build_switch_var(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2587 | IrInstruction *target_value_ptr, IrInstruction **prongs_ptr, size_t prongs_len) | 3268 | IrInstSrc *target_value_ptr, IrInstSrc **prongs_ptr, size_t prongs_len) |
| 2588 | { | 3269 | { |
| 2589 | IrInstructionSwitchVar *instruction = ir_build_instruction<IrInstructionSwitchVar>(irb, scope, source_node); | 3270 | IrInstSrcSwitchVar *instruction = ir_build_instruction<IrInstSrcSwitchVar>(irb, scope, source_node); |
| 2590 | instruction->target_value_ptr = target_value_ptr; | 3271 | instruction->target_value_ptr = target_value_ptr; |
| 2591 | instruction->prongs_ptr = prongs_ptr; | 3272 | instruction->prongs_ptr = prongs_ptr; |
| 2592 | instruction->prongs_len = prongs_len; | 3273 | instruction->prongs_len = prongs_len; |
| ... | @@ -2600,10 +3281,10 @@ static IrInstruction *ir_build_switch_var(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2600,10 +3281,10 @@ static IrInstruction *ir_build_switch_var(IrBuilder *irb, Scope *scope, AstNode |
| 2600 | } | 3281 | } |
| 2601 | | 3282 | |
| 2602 | // For this instruction the switch_br must be set later. | 3283 | // For this instruction the switch_br must be set later. |
| 2603 | static IrInstructionSwitchElseVar *ir_build_switch_else_var(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3284 | static IrInstSrcSwitchElseVar *ir_build_switch_else_var(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2604 | IrInstruction *target_value_ptr) | 3285 | IrInstSrc *target_value_ptr) |
| 2605 | { | 3286 | { |
| 2606 | IrInstructionSwitchElseVar *instruction = ir_build_instruction<IrInstructionSwitchElseVar>(irb, scope, source_node); | 3287 | IrInstSrcSwitchElseVar *instruction = ir_build_instruction<IrInstSrcSwitchElseVar>(irb, scope, source_node); |
| 2607 | instruction->target_value_ptr = target_value_ptr; | 3288 | instruction->target_value_ptr = target_value_ptr; |
| 2608 | | 3289 | |
| 2609 | ir_ref_instruction(target_value_ptr, irb->current_basic_block); | 3290 | ir_ref_instruction(target_value_ptr, irb->current_basic_block); |
| ... | @@ -2611,17 +3292,21 @@ static IrInstructionSwitchElseVar *ir_build_switch_else_var(IrBuilder *irb, Scop | ... | @@ -2611,17 +3292,21 @@ static IrInstructionSwitchElseVar *ir_build_switch_else_var(IrBuilder *irb, Scop |
| 2611 | return instruction; | 3292 | return instruction; |
| 2612 | } | 3293 | } |
| 2613 | | 3294 | |
| 2614 | static IrInstruction *ir_build_union_tag(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *value) { | 3295 | static IrInstGen *ir_build_union_tag(IrAnalyze *ira, IrInst *source_instr, IrInstGen *value, |
| 2615 | IrInstructionUnionTag *instruction = ir_build_instruction<IrInstructionUnionTag>(irb, scope, source_node); | 3296 | ZigType *tag_type) |
| | 3297 | { |
| | 3298 | IrInstGenUnionTag *instruction = ir_build_inst_gen<IrInstGenUnionTag>(&ira->new_irb, |
| | 3299 | source_instr->scope, source_instr->source_node); |
| 2616 | instruction->value = value; | 3300 | instruction->value = value; |
| | 3301 | instruction->base.value->type = tag_type; |
| 2617 | | 3302 | |
| 2618 | ir_ref_instruction(value, irb->current_basic_block); | 3303 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| 2619 | | 3304 | |
| 2620 | return &instruction->base; | 3305 | return &instruction->base; |
| 2621 | } | 3306 | } |
| 2622 | | 3307 | |
| 2623 | static IrInstruction *ir_build_import(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *name) { | 3308 | static IrInstSrc *ir_build_import(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *name) { |
| 2624 | IrInstructionImport *instruction = ir_build_instruction<IrInstructionImport>(irb, scope, source_node); | 3309 | IrInstSrcImport *instruction = ir_build_instruction<IrInstSrcImport>(irb, scope, source_node); |
| 2625 | instruction->name = name; | 3310 | instruction->name = name; |
| 2626 | | 3311 | |
| 2627 | ir_ref_instruction(name, irb->current_basic_block); | 3312 | ir_ref_instruction(name, irb->current_basic_block); |
| ... | @@ -2629,10 +3314,10 @@ static IrInstruction *ir_build_import(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -2629,10 +3314,10 @@ static IrInstruction *ir_build_import(IrBuilder *irb, Scope *scope, AstNode *sou |
| 2629 | return &instruction->base; | 3314 | return &instruction->base; |
| 2630 | } | 3315 | } |
| 2631 | | 3316 | |
| 2632 | static IrInstruction *ir_build_ref(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *value, | 3317 | static IrInstSrc *ir_build_ref_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *value, |
| 2633 | bool is_const, bool is_volatile) | 3318 | bool is_const, bool is_volatile) |
| 2634 | { | 3319 | { |
| 2635 | IrInstructionRef *instruction = ir_build_instruction<IrInstructionRef>(irb, scope, source_node); | 3320 | IrInstSrcRef *instruction = ir_build_instruction<IrInstSrcRef>(irb, scope, source_node); |
| 2636 | instruction->value = value; | 3321 | instruction->value = value; |
| 2637 | instruction->is_const = is_const; | 3322 | instruction->is_const = is_const; |
| 2638 | instruction->is_volatile = is_volatile; | 3323 | instruction->is_volatile = is_volatile; |
| ... | @@ -2642,23 +3327,23 @@ static IrInstruction *ir_build_ref(IrBuilder *irb, Scope *scope, AstNode *source | ... | @@ -2642,23 +3327,23 @@ static IrInstruction *ir_build_ref(IrBuilder *irb, Scope *scope, AstNode *source |
| 2642 | return &instruction->base; | 3327 | return &instruction->base; |
| 2643 | } | 3328 | } |
| 2644 | | 3329 | |
| 2645 | static IrInstruction *ir_build_ref_gen(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *result_type, | 3330 | static IrInstGen *ir_build_ref_gen(IrAnalyze *ira, IrInst *source_instruction, ZigType *result_type, |
| 2646 | IrInstruction *operand, IrInstruction *result_loc) | 3331 | IrInstGen *operand, IrInstGen *result_loc) |
| 2647 | { | 3332 | { |
| 2648 | IrInstructionRefGen *instruction = ir_build_instruction<IrInstructionRefGen>(&ira->new_irb, | 3333 | IrInstGenRef *instruction = ir_build_inst_gen<IrInstGenRef>(&ira->new_irb, |
| 2649 | source_instruction->scope, source_instruction->source_node); | 3334 | source_instruction->scope, source_instruction->source_node); |
| 2650 | instruction->base.value->type = result_type; | 3335 | instruction->base.value->type = result_type; |
| 2651 | instruction->operand = operand; | 3336 | instruction->operand = operand; |
| 2652 | instruction->result_loc = result_loc; | 3337 | instruction->result_loc = result_loc; |
| 2653 | | 3338 | |
| 2654 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); | 3339 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 2655 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 3340 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 2656 | | 3341 | |
| 2657 | return &instruction->base; | 3342 | return &instruction->base; |
| 2658 | } | 3343 | } |
| 2659 | | 3344 | |
| 2660 | static IrInstruction *ir_build_compile_err(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *msg) { | 3345 | static IrInstSrc *ir_build_compile_err(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *msg) { |
| 2661 | IrInstructionCompileErr *instruction = ir_build_instruction<IrInstructionCompileErr>(irb, scope, source_node); | 3346 | IrInstSrcCompileErr *instruction = ir_build_instruction<IrInstSrcCompileErr>(irb, scope, source_node); |
| 2662 | instruction->msg = msg; | 3347 | instruction->msg = msg; |
| 2663 | | 3348 | |
| 2664 | ir_ref_instruction(msg, irb->current_basic_block); | 3349 | ir_ref_instruction(msg, irb->current_basic_block); |
| ... | @@ -2666,10 +3351,10 @@ static IrInstruction *ir_build_compile_err(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2666,10 +3351,10 @@ static IrInstruction *ir_build_compile_err(IrBuilder *irb, Scope *scope, AstNode |
| 2666 | return &instruction->base; | 3351 | return &instruction->base; |
| 2667 | } | 3352 | } |
| 2668 | | 3353 | |
| 2669 | static IrInstruction *ir_build_compile_log(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3354 | static IrInstSrc *ir_build_compile_log(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2670 | size_t msg_count, IrInstruction **msg_list) | 3355 | size_t msg_count, IrInstSrc **msg_list) |
| 2671 | { | 3356 | { |
| 2672 | IrInstructionCompileLog *instruction = ir_build_instruction<IrInstructionCompileLog>(irb, scope, source_node); | 3357 | IrInstSrcCompileLog *instruction = ir_build_instruction<IrInstSrcCompileLog>(irb, scope, source_node); |
| 2673 | instruction->msg_count = msg_count; | 3358 | instruction->msg_count = msg_count; |
| 2674 | instruction->msg_list = msg_list; | 3359 | instruction->msg_list = msg_list; |
| 2675 | | 3360 | |
| ... | @@ -2680,8 +3365,8 @@ static IrInstruction *ir_build_compile_log(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2680,8 +3365,8 @@ static IrInstruction *ir_build_compile_log(IrBuilder *irb, Scope *scope, AstNode |
| 2680 | return &instruction->base; | 3365 | return &instruction->base; |
| 2681 | } | 3366 | } |
| 2682 | | 3367 | |
| 2683 | static IrInstruction *ir_build_err_name(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *value) { | 3368 | static IrInstSrc *ir_build_err_name(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *value) { |
| 2684 | IrInstructionErrName *instruction = ir_build_instruction<IrInstructionErrName>(irb, scope, source_node); | 3369 | IrInstSrcErrName *instruction = ir_build_instruction<IrInstSrcErrName>(irb, scope, source_node); |
| 2685 | instruction->value = value; | 3370 | instruction->value = value; |
| 2686 | | 3371 | |
| 2687 | ir_ref_instruction(value, irb->current_basic_block); | 3372 | ir_ref_instruction(value, irb->current_basic_block); |
| ... | @@ -2689,13 +3374,26 @@ static IrInstruction *ir_build_err_name(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2689,13 +3374,26 @@ static IrInstruction *ir_build_err_name(IrBuilder *irb, Scope *scope, AstNode *s |
| 2689 | return &instruction->base; | 3374 | return &instruction->base; |
| 2690 | } | 3375 | } |
| 2691 | | 3376 | |
| 2692 | static IrInstruction *ir_build_c_import(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 3377 | static IrInstGen *ir_build_err_name_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *value, |
| 2693 | IrInstructionCImport *instruction = ir_build_instruction<IrInstructionCImport>(irb, scope, source_node); | 3378 | ZigType *str_type) |
| | 3379 | { |
| | 3380 | IrInstGenErrName *instruction = ir_build_inst_gen<IrInstGenErrName>(&ira->new_irb, |
| | 3381 | source_instr->scope, source_instr->source_node); |
| | 3382 | instruction->base.value->type = str_type; |
| | 3383 | instruction->value = value; |
| | 3384 | |
| | 3385 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| | 3386 | |
| 2694 | return &instruction->base; | 3387 | return &instruction->base; |
| 2695 | } | 3388 | } |
| 2696 | | 3389 | |
| 2697 | static IrInstruction *ir_build_c_include(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *name) { | 3390 | static IrInstSrc *ir_build_c_import(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 2698 | IrInstructionCInclude *instruction = ir_build_instruction<IrInstructionCInclude>(irb, scope, source_node); | 3391 | IrInstSrcCImport *instruction = ir_build_instruction<IrInstSrcCImport>(irb, scope, source_node); |
| | 3392 | return &instruction->base; |
| | 3393 | } |
| | 3394 | |
| | 3395 | static IrInstSrc *ir_build_c_include(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *name) { |
| | 3396 | IrInstSrcCInclude *instruction = ir_build_instruction<IrInstSrcCInclude>(irb, scope, source_node); |
| 2699 | instruction->name = name; | 3397 | instruction->name = name; |
| 2700 | | 3398 | |
| 2701 | ir_ref_instruction(name, irb->current_basic_block); | 3399 | ir_ref_instruction(name, irb->current_basic_block); |
| ... | @@ -2703,8 +3401,8 @@ static IrInstruction *ir_build_c_include(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -2703,8 +3401,8 @@ static IrInstruction *ir_build_c_include(IrBuilder *irb, Scope *scope, AstNode * |
| 2703 | return &instruction->base; | 3401 | return &instruction->base; |
| 2704 | } | 3402 | } |
| 2705 | | 3403 | |
| 2706 | static IrInstruction *ir_build_c_define(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *name, IrInstruction *value) { | 3404 | static IrInstSrc *ir_build_c_define(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *name, IrInstSrc *value) { |
| 2707 | IrInstructionCDefine *instruction = ir_build_instruction<IrInstructionCDefine>(irb, scope, source_node); | 3405 | IrInstSrcCDefine *instruction = ir_build_instruction<IrInstSrcCDefine>(irb, scope, source_node); |
| 2708 | instruction->name = name; | 3406 | instruction->name = name; |
| 2709 | instruction->value = value; | 3407 | instruction->value = value; |
| 2710 | | 3408 | |
| ... | @@ -2714,8 +3412,8 @@ static IrInstruction *ir_build_c_define(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2714,8 +3412,8 @@ static IrInstruction *ir_build_c_define(IrBuilder *irb, Scope *scope, AstNode *s |
| 2714 | return &instruction->base; | 3412 | return &instruction->base; |
| 2715 | } | 3413 | } |
| 2716 | | 3414 | |
| 2717 | static IrInstruction *ir_build_c_undef(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *name) { | 3415 | static IrInstSrc *ir_build_c_undef(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *name) { |
| 2718 | IrInstructionCUndef *instruction = ir_build_instruction<IrInstructionCUndef>(irb, scope, source_node); | 3416 | IrInstSrcCUndef *instruction = ir_build_instruction<IrInstSrcCUndef>(irb, scope, source_node); |
| 2719 | instruction->name = name; | 3417 | instruction->name = name; |
| 2720 | | 3418 | |
| 2721 | ir_ref_instruction(name, irb->current_basic_block); | 3419 | ir_ref_instruction(name, irb->current_basic_block); |
| ... | @@ -2723,8 +3421,8 @@ static IrInstruction *ir_build_c_undef(IrBuilder *irb, Scope *scope, AstNode *so | ... | @@ -2723,8 +3421,8 @@ static IrInstruction *ir_build_c_undef(IrBuilder *irb, Scope *scope, AstNode *so |
| 2723 | return &instruction->base; | 3421 | return &instruction->base; |
| 2724 | } | 3422 | } |
| 2725 | | 3423 | |
| 2726 | static IrInstruction *ir_build_embed_file(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *name) { | 3424 | static IrInstSrc *ir_build_embed_file(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *name) { |
| 2727 | IrInstructionEmbedFile *instruction = ir_build_instruction<IrInstructionEmbedFile>(irb, scope, source_node); | 3425 | IrInstSrcEmbedFile *instruction = ir_build_instruction<IrInstSrcEmbedFile>(irb, scope, source_node); |
| 2728 | instruction->name = name; | 3426 | instruction->name = name; |
| 2729 | | 3427 | |
| 2730 | ir_ref_instruction(name, irb->current_basic_block); | 3428 | ir_ref_instruction(name, irb->current_basic_block); |
| ... | @@ -2732,11 +3430,11 @@ static IrInstruction *ir_build_embed_file(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2732,11 +3430,11 @@ static IrInstruction *ir_build_embed_file(IrBuilder *irb, Scope *scope, AstNode |
| 2732 | return &instruction->base; | 3430 | return &instruction->base; |
| 2733 | } | 3431 | } |
| 2734 | | 3432 | |
| 2735 | static IrInstruction *ir_build_cmpxchg_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3433 | static IrInstSrc *ir_build_cmpxchg_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2736 | IrInstruction *type_value, IrInstruction *ptr, IrInstruction *cmp_value, IrInstruction *new_value, | 3434 | IrInstSrc *type_value, IrInstSrc *ptr, IrInstSrc *cmp_value, IrInstSrc *new_value, |
| 2737 | IrInstruction *success_order_value, IrInstruction *failure_order_value, bool is_weak, ResultLoc *result_loc) | 3435 | IrInstSrc *success_order_value, IrInstSrc *failure_order_value, bool is_weak, ResultLoc *result_loc) |
| 2738 | { | 3436 | { |
| 2739 | IrInstructionCmpxchgSrc *instruction = ir_build_instruction<IrInstructionCmpxchgSrc>(irb, scope, source_node); | 3437 | IrInstSrcCmpxchg *instruction = ir_build_instruction<IrInstSrcCmpxchg>(irb, scope, source_node); |
| 2740 | instruction->type_value = type_value; | 3438 | instruction->type_value = type_value; |
| 2741 | instruction->ptr = ptr; | 3439 | instruction->ptr = ptr; |
| 2742 | instruction->cmp_value = cmp_value; | 3440 | instruction->cmp_value = cmp_value; |
| ... | @@ -2756,11 +3454,11 @@ static IrInstruction *ir_build_cmpxchg_src(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2756,11 +3454,11 @@ static IrInstruction *ir_build_cmpxchg_src(IrBuilder *irb, Scope *scope, AstNode |
| 2756 | return &instruction->base; | 3454 | return &instruction->base; |
| 2757 | } | 3455 | } |
| 2758 | | 3456 | |
| 2759 | static IrInstruction *ir_build_cmpxchg_gen(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *result_type, | 3457 | static IrInstGen *ir_build_cmpxchg_gen(IrAnalyze *ira, IrInst *source_instruction, ZigType *result_type, |
| 2760 | IrInstruction *ptr, IrInstruction *cmp_value, IrInstruction *new_value, | 3458 | IrInstGen *ptr, IrInstGen *cmp_value, IrInstGen *new_value, |
| 2761 | AtomicOrder success_order, AtomicOrder failure_order, bool is_weak, IrInstruction *result_loc) | 3459 | AtomicOrder success_order, AtomicOrder failure_order, bool is_weak, IrInstGen *result_loc) |
| 2762 | { | 3460 | { |
| 2763 | IrInstructionCmpxchgGen *instruction = ir_build_instruction<IrInstructionCmpxchgGen>(&ira->new_irb, | 3461 | IrInstGenCmpxchg *instruction = ir_build_inst_gen<IrInstGenCmpxchg>(&ira->new_irb, |
| 2764 | source_instruction->scope, source_instruction->source_node); | 3462 | source_instruction->scope, source_instruction->source_node); |
| 2765 | instruction->base.value->type = result_type; | 3463 | instruction->base.value->type = result_type; |
| 2766 | instruction->ptr = ptr; | 3464 | instruction->ptr = ptr; |
| ... | @@ -2771,26 +3469,35 @@ static IrInstruction *ir_build_cmpxchg_gen(IrAnalyze *ira, IrInstruction *source | ... | @@ -2771,26 +3469,35 @@ static IrInstruction *ir_build_cmpxchg_gen(IrAnalyze *ira, IrInstruction *source |
| 2771 | instruction->is_weak = is_weak; | 3469 | instruction->is_weak = is_weak; |
| 2772 | instruction->result_loc = result_loc; | 3470 | instruction->result_loc = result_loc; |
| 2773 | | 3471 | |
| 2774 | ir_ref_instruction(ptr, ira->new_irb.current_basic_block); | 3472 | ir_ref_inst_gen(ptr, ira->new_irb.current_basic_block); |
| 2775 | ir_ref_instruction(cmp_value, ira->new_irb.current_basic_block); | 3473 | ir_ref_inst_gen(cmp_value, ira->new_irb.current_basic_block); |
| 2776 | ir_ref_instruction(new_value, ira->new_irb.current_basic_block); | 3474 | ir_ref_inst_gen(new_value, ira->new_irb.current_basic_block); |
| 2777 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 3475 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 2778 | | 3476 | |
| 2779 | return &instruction->base; | 3477 | return &instruction->base; |
| 2780 | } | 3478 | } |
| 2781 | | 3479 | |
| 2782 | static IrInstruction *ir_build_fence(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *order_value, AtomicOrder order) { | 3480 | static IrInstSrc *ir_build_fence(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *order) { |
| 2783 | IrInstructionFence *instruction = ir_build_instruction<IrInstructionFence>(irb, scope, source_node); | 3481 | IrInstSrcFence *instruction = ir_build_instruction<IrInstSrcFence>(irb, scope, source_node); |
| 2784 | instruction->order_value = order_value; | | |
| 2785 | instruction->order = order; | 3482 | instruction->order = order; |
| 2786 | | 3483 | |
| 2787 | ir_ref_instruction(order_value, irb->current_basic_block); | 3484 | ir_ref_instruction(order, irb->current_basic_block); |
| | 3485 | |
| | 3486 | return &instruction->base; |
| | 3487 | } |
| | 3488 | |
| | 3489 | static IrInstGen *ir_build_fence_gen(IrAnalyze *ira, IrInst *source_instr, AtomicOrder order) { |
| | 3490 | IrInstGenFence *instruction = ir_build_inst_void<IrInstGenFence>(&ira->new_irb, |
| | 3491 | source_instr->scope, source_instr->source_node); |
| | 3492 | instruction->order = order; |
| 2788 | | 3493 | |
| 2789 | return &instruction->base; | 3494 | return &instruction->base; |
| 2790 | } | 3495 | } |
| 2791 | | 3496 | |
| 2792 | static IrInstruction *ir_build_truncate(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *dest_type, IrInstruction *target) { | 3497 | static IrInstSrc *ir_build_truncate(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2793 | IrInstructionTruncate *instruction = ir_build_instruction<IrInstructionTruncate>(irb, scope, source_node); | 3498 | IrInstSrc *dest_type, IrInstSrc *target) |
| | 3499 | { |
| | 3500 | IrInstSrcTruncate *instruction = ir_build_instruction<IrInstSrcTruncate>(irb, scope, source_node); |
| 2794 | instruction->dest_type = dest_type; | 3501 | instruction->dest_type = dest_type; |
| 2795 | instruction->target = target; | 3502 | instruction->target = target; |
| 2796 | | 3503 | |
| ... | @@ -2800,8 +3507,23 @@ static IrInstruction *ir_build_truncate(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2800,8 +3507,23 @@ static IrInstruction *ir_build_truncate(IrBuilder *irb, Scope *scope, AstNode *s |
| 2800 | return &instruction->base; | 3507 | return &instruction->base; |
| 2801 | } | 3508 | } |
| 2802 | | 3509 | |
| 2803 | static IrInstruction *ir_build_int_cast(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *dest_type, IrInstruction *target) { | 3510 | static IrInstGen *ir_build_truncate_gen(IrAnalyze *ira, IrInst *source_instr, ZigType *dest_type, |
| 2804 | IrInstructionIntCast *instruction = ir_build_instruction<IrInstructionIntCast>(irb, scope, source_node); | 3511 | IrInstGen *target) |
| | 3512 | { |
| | 3513 | IrInstGenTruncate *instruction = ir_build_inst_gen<IrInstGenTruncate>(&ira->new_irb, |
| | 3514 | source_instr->scope, source_instr->source_node); |
| | 3515 | instruction->base.value->type = dest_type; |
| | 3516 | instruction->target = target; |
| | 3517 | |
| | 3518 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| | 3519 | |
| | 3520 | return &instruction->base; |
| | 3521 | } |
| | 3522 | |
| | 3523 | static IrInstSrc *ir_build_int_cast(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *dest_type, |
| | 3524 | IrInstSrc *target) |
| | 3525 | { |
| | 3526 | IrInstSrcIntCast *instruction = ir_build_instruction<IrInstSrcIntCast>(irb, scope, source_node); |
| 2805 | instruction->dest_type = dest_type; | 3527 | instruction->dest_type = dest_type; |
| 2806 | instruction->target = target; | 3528 | instruction->target = target; |
| 2807 | | 3529 | |
| ... | @@ -2811,8 +3533,10 @@ static IrInstruction *ir_build_int_cast(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2811,8 +3533,10 @@ static IrInstruction *ir_build_int_cast(IrBuilder *irb, Scope *scope, AstNode *s |
| 2811 | return &instruction->base; | 3533 | return &instruction->base; |
| 2812 | } | 3534 | } |
| 2813 | | 3535 | |
| 2814 | static IrInstruction *ir_build_float_cast(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *dest_type, IrInstruction *target) { | 3536 | static IrInstSrc *ir_build_float_cast(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *dest_type, |
| 2815 | IrInstructionFloatCast *instruction = ir_build_instruction<IrInstructionFloatCast>(irb, scope, source_node); | 3537 | IrInstSrc *target) |
| | 3538 | { |
| | 3539 | IrInstSrcFloatCast *instruction = ir_build_instruction<IrInstSrcFloatCast>(irb, scope, source_node); |
| 2816 | instruction->dest_type = dest_type; | 3540 | instruction->dest_type = dest_type; |
| 2817 | instruction->target = target; | 3541 | instruction->target = target; |
| 2818 | | 3542 | |
| ... | @@ -2822,8 +3546,10 @@ static IrInstruction *ir_build_float_cast(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2822,8 +3546,10 @@ static IrInstruction *ir_build_float_cast(IrBuilder *irb, Scope *scope, AstNode |
| 2822 | return &instruction->base; | 3546 | return &instruction->base; |
| 2823 | } | 3547 | } |
| 2824 | | 3548 | |
| 2825 | static IrInstruction *ir_build_err_set_cast(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *dest_type, IrInstruction *target) { | 3549 | static IrInstSrc *ir_build_err_set_cast(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2826 | IrInstructionErrSetCast *instruction = ir_build_instruction<IrInstructionErrSetCast>(irb, scope, source_node); | 3550 | IrInstSrc *dest_type, IrInstSrc *target) |
| | 3551 | { |
| | 3552 | IrInstSrcErrSetCast *instruction = ir_build_instruction<IrInstSrcErrSetCast>(irb, scope, source_node); |
| 2827 | instruction->dest_type = dest_type; | 3553 | instruction->dest_type = dest_type; |
| 2828 | instruction->target = target; | 3554 | instruction->target = target; |
| 2829 | | 3555 | |
| ... | @@ -2833,10 +3559,10 @@ static IrInstruction *ir_build_err_set_cast(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -2833,10 +3559,10 @@ static IrInstruction *ir_build_err_set_cast(IrBuilder *irb, Scope *scope, AstNod |
| 2833 | return &instruction->base; | 3559 | return &instruction->base; |
| 2834 | } | 3560 | } |
| 2835 | | 3561 | |
| 2836 | static IrInstruction *ir_build_to_bytes(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *target, | 3562 | static IrInstSrc *ir_build_to_bytes(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *target, |
| 2837 | ResultLoc *result_loc) | 3563 | ResultLoc *result_loc) |
| 2838 | { | 3564 | { |
| 2839 | IrInstructionToBytes *instruction = ir_build_instruction<IrInstructionToBytes>(irb, scope, source_node); | 3565 | IrInstSrcToBytes *instruction = ir_build_instruction<IrInstSrcToBytes>(irb, scope, source_node); |
| 2840 | instruction->target = target; | 3566 | instruction->target = target; |
| 2841 | instruction->result_loc = result_loc; | 3567 | instruction->result_loc = result_loc; |
| 2842 | | 3568 | |
| ... | @@ -2845,10 +3571,10 @@ static IrInstruction *ir_build_to_bytes(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2845,10 +3571,10 @@ static IrInstruction *ir_build_to_bytes(IrBuilder *irb, Scope *scope, AstNode *s |
| 2845 | return &instruction->base; | 3571 | return &instruction->base; |
| 2846 | } | 3572 | } |
| 2847 | | 3573 | |
| 2848 | static IrInstruction *ir_build_from_bytes(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3574 | static IrInstSrc *ir_build_from_bytes(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2849 | IrInstruction *dest_child_type, IrInstruction *target, ResultLoc *result_loc) | 3575 | IrInstSrc *dest_child_type, IrInstSrc *target, ResultLoc *result_loc) |
| 2850 | { | 3576 | { |
| 2851 | IrInstructionFromBytes *instruction = ir_build_instruction<IrInstructionFromBytes>(irb, scope, source_node); | 3577 | IrInstSrcFromBytes *instruction = ir_build_instruction<IrInstSrcFromBytes>(irb, scope, source_node); |
| 2852 | instruction->dest_child_type = dest_child_type; | 3578 | instruction->dest_child_type = dest_child_type; |
| 2853 | instruction->target = target; | 3579 | instruction->target = target; |
| 2854 | instruction->result_loc = result_loc; | 3580 | instruction->result_loc = result_loc; |
| ... | @@ -2859,8 +3585,10 @@ static IrInstruction *ir_build_from_bytes(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2859,8 +3585,10 @@ static IrInstruction *ir_build_from_bytes(IrBuilder *irb, Scope *scope, AstNode |
| 2859 | return &instruction->base; | 3585 | return &instruction->base; |
| 2860 | } | 3586 | } |
| 2861 | | 3587 | |
| 2862 | static IrInstruction *ir_build_int_to_float(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *dest_type, IrInstruction *target) { | 3588 | static IrInstSrc *ir_build_int_to_float(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2863 | IrInstructionIntToFloat *instruction = ir_build_instruction<IrInstructionIntToFloat>(irb, scope, source_node); | 3589 | IrInstSrc *dest_type, IrInstSrc *target) |
| | 3590 | { |
| | 3591 | IrInstSrcIntToFloat *instruction = ir_build_instruction<IrInstSrcIntToFloat>(irb, scope, source_node); |
| 2864 | instruction->dest_type = dest_type; | 3592 | instruction->dest_type = dest_type; |
| 2865 | instruction->target = target; | 3593 | instruction->target = target; |
| 2866 | | 3594 | |
| ... | @@ -2870,8 +3598,10 @@ static IrInstruction *ir_build_int_to_float(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -2870,8 +3598,10 @@ static IrInstruction *ir_build_int_to_float(IrBuilder *irb, Scope *scope, AstNod |
| 2870 | return &instruction->base; | 3598 | return &instruction->base; |
| 2871 | } | 3599 | } |
| 2872 | | 3600 | |
| 2873 | static IrInstruction *ir_build_float_to_int(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *dest_type, IrInstruction *target) { | 3601 | static IrInstSrc *ir_build_float_to_int(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2874 | IrInstructionFloatToInt *instruction = ir_build_instruction<IrInstructionFloatToInt>(irb, scope, source_node); | 3602 | IrInstSrc *dest_type, IrInstSrc *target) |
| | 3603 | { |
| | 3604 | IrInstSrcFloatToInt *instruction = ir_build_instruction<IrInstSrcFloatToInt>(irb, scope, source_node); |
| 2875 | instruction->dest_type = dest_type; | 3605 | instruction->dest_type = dest_type; |
| 2876 | instruction->target = target; | 3606 | instruction->target = target; |
| 2877 | | 3607 | |
| ... | @@ -2881,8 +3611,8 @@ static IrInstruction *ir_build_float_to_int(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -2881,8 +3611,8 @@ static IrInstruction *ir_build_float_to_int(IrBuilder *irb, Scope *scope, AstNod |
| 2881 | return &instruction->base; | 3611 | return &instruction->base; |
| 2882 | } | 3612 | } |
| 2883 | | 3613 | |
| 2884 | static IrInstruction *ir_build_bool_to_int(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *target) { | 3614 | static IrInstSrc *ir_build_bool_to_int(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *target) { |
| 2885 | IrInstructionBoolToInt *instruction = ir_build_instruction<IrInstructionBoolToInt>(irb, scope, source_node); | 3615 | IrInstSrcBoolToInt *instruction = ir_build_instruction<IrInstSrcBoolToInt>(irb, scope, source_node); |
| 2886 | instruction->target = target; | 3616 | instruction->target = target; |
| 2887 | | 3617 | |
| 2888 | ir_ref_instruction(target, irb->current_basic_block); | 3618 | ir_ref_instruction(target, irb->current_basic_block); |
| ... | @@ -2890,8 +3620,10 @@ static IrInstruction *ir_build_bool_to_int(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2890,8 +3620,10 @@ static IrInstruction *ir_build_bool_to_int(IrBuilder *irb, Scope *scope, AstNode |
| 2890 | return &instruction->base; | 3620 | return &instruction->base; |
| 2891 | } | 3621 | } |
| 2892 | | 3622 | |
| 2893 | static IrInstruction *ir_build_int_type(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *is_signed, IrInstruction *bit_count) { | 3623 | static IrInstSrc *ir_build_int_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *is_signed, |
| 2894 | IrInstructionIntType *instruction = ir_build_instruction<IrInstructionIntType>(irb, scope, source_node); | 3624 | IrInstSrc *bit_count) |
| | 3625 | { |
| | 3626 | IrInstSrcIntType *instruction = ir_build_instruction<IrInstSrcIntType>(irb, scope, source_node); |
| 2895 | instruction->is_signed = is_signed; | 3627 | instruction->is_signed = is_signed; |
| 2896 | instruction->bit_count = bit_count; | 3628 | instruction->bit_count = bit_count; |
| 2897 | | 3629 | |
| ... | @@ -2901,10 +3633,10 @@ static IrInstruction *ir_build_int_type(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2901,10 +3633,10 @@ static IrInstruction *ir_build_int_type(IrBuilder *irb, Scope *scope, AstNode *s |
| 2901 | return &instruction->base; | 3633 | return &instruction->base; |
| 2902 | } | 3634 | } |
| 2903 | | 3635 | |
| 2904 | static IrInstruction *ir_build_vector_type(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *len, | 3636 | static IrInstSrc *ir_build_vector_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *len, |
| 2905 | IrInstruction *elem_type) | 3637 | IrInstSrc *elem_type) |
| 2906 | { | 3638 | { |
| 2907 | IrInstructionVectorType *instruction = ir_build_instruction<IrInstructionVectorType>(irb, scope, source_node); | 3639 | IrInstSrcVectorType *instruction = ir_build_instruction<IrInstSrcVectorType>(irb, scope, source_node); |
| 2908 | instruction->len = len; | 3640 | instruction->len = len; |
| 2909 | instruction->elem_type = elem_type; | 3641 | instruction->elem_type = elem_type; |
| 2910 | | 3642 | |
| ... | @@ -2914,18 +3646,16 @@ static IrInstruction *ir_build_vector_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2914,18 +3646,16 @@ static IrInstruction *ir_build_vector_type(IrBuilder *irb, Scope *scope, AstNode |
| 2914 | return &instruction->base; | 3646 | return &instruction->base; |
| 2915 | } | 3647 | } |
| 2916 | | 3648 | |
| 2917 | static IrInstruction *ir_build_shuffle_vector(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3649 | static IrInstSrc *ir_build_shuffle_vector(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2918 | IrInstruction *scalar_type, IrInstruction *a, IrInstruction *b, IrInstruction *mask) | 3650 | IrInstSrc *scalar_type, IrInstSrc *a, IrInstSrc *b, IrInstSrc *mask) |
| 2919 | { | 3651 | { |
| 2920 | IrInstructionShuffleVector *instruction = ir_build_instruction<IrInstructionShuffleVector>(irb, scope, source_node); | 3652 | IrInstSrcShuffleVector *instruction = ir_build_instruction<IrInstSrcShuffleVector>(irb, scope, source_node); |
| 2921 | instruction->scalar_type = scalar_type; | 3653 | instruction->scalar_type = scalar_type; |
| 2922 | instruction->a = a; | 3654 | instruction->a = a; |
| 2923 | instruction->b = b; | 3655 | instruction->b = b; |
| 2924 | instruction->mask = mask; | 3656 | instruction->mask = mask; |
| 2925 | | 3657 | |
| 2926 | if (scalar_type != nullptr) { | 3658 | if (scalar_type != nullptr) ir_ref_instruction(scalar_type, irb->current_basic_block); |
| 2927 | ir_ref_instruction(scalar_type, irb->current_basic_block); | | |
| 2928 | } | | |
| 2929 | ir_ref_instruction(a, irb->current_basic_block); | 3659 | ir_ref_instruction(a, irb->current_basic_block); |
| 2930 | ir_ref_instruction(b, irb->current_basic_block); | 3660 | ir_ref_instruction(b, irb->current_basic_block); |
| 2931 | ir_ref_instruction(mask, irb->current_basic_block); | 3661 | ir_ref_instruction(mask, irb->current_basic_block); |
| ... | @@ -2933,10 +3663,26 @@ static IrInstruction *ir_build_shuffle_vector(IrBuilder *irb, Scope *scope, AstN | ... | @@ -2933,10 +3663,26 @@ static IrInstruction *ir_build_shuffle_vector(IrBuilder *irb, Scope *scope, AstN |
| 2933 | return &instruction->base; | 3663 | return &instruction->base; |
| 2934 | } | 3664 | } |
| 2935 | | 3665 | |
| 2936 | static IrInstruction *ir_build_splat_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3666 | static IrInstGen *ir_build_shuffle_vector_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, |
| 2937 | IrInstruction *len, IrInstruction *scalar) | 3667 | ZigType *result_type, IrInstGen *a, IrInstGen *b, IrInstGen *mask) |
| | 3668 | { |
| | 3669 | IrInstGenShuffleVector *inst = ir_build_inst_gen<IrInstGenShuffleVector>(&ira->new_irb, scope, source_node); |
| | 3670 | inst->base.value->type = result_type; |
| | 3671 | inst->a = a; |
| | 3672 | inst->b = b; |
| | 3673 | inst->mask = mask; |
| | 3674 | |
| | 3675 | ir_ref_inst_gen(a, ira->new_irb.current_basic_block); |
| | 3676 | ir_ref_inst_gen(b, ira->new_irb.current_basic_block); |
| | 3677 | ir_ref_inst_gen(mask, ira->new_irb.current_basic_block); |
| | 3678 | |
| | 3679 | return &inst->base; |
| | 3680 | } |
| | 3681 | |
| | 3682 | static IrInstSrc *ir_build_splat_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 3683 | IrInstSrc *len, IrInstSrc *scalar) |
| 2938 | { | 3684 | { |
| 2939 | IrInstructionSplatSrc *instruction = ir_build_instruction<IrInstructionSplatSrc>(irb, scope, source_node); | 3685 | IrInstSrcSplat *instruction = ir_build_instruction<IrInstSrcSplat>(irb, scope, source_node); |
| 2940 | instruction->len = len; | 3686 | instruction->len = len; |
| 2941 | instruction->scalar = scalar; | 3687 | instruction->scalar = scalar; |
| 2942 | | 3688 | |
| ... | @@ -2946,8 +3692,21 @@ static IrInstruction *ir_build_splat_src(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -2946,8 +3692,21 @@ static IrInstruction *ir_build_splat_src(IrBuilder *irb, Scope *scope, AstNode * |
| 2946 | return &instruction->base; | 3692 | return &instruction->base; |
| 2947 | } | 3693 | } |
| 2948 | | 3694 | |
| 2949 | static IrInstruction *ir_build_bool_not(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *value) { | 3695 | static IrInstGen *ir_build_splat_gen(IrAnalyze *ira, IrInst *source_instruction, ZigType *result_type, |
| 2950 | IrInstructionBoolNot *instruction = ir_build_instruction<IrInstructionBoolNot>(irb, scope, source_node); | 3696 | IrInstGen *scalar) |
| | 3697 | { |
| | 3698 | IrInstGenSplat *instruction = ir_build_inst_gen<IrInstGenSplat>( |
| | 3699 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| | 3700 | instruction->base.value->type = result_type; |
| | 3701 | instruction->scalar = scalar; |
| | 3702 | |
| | 3703 | ir_ref_inst_gen(scalar, ira->new_irb.current_basic_block); |
| | 3704 | |
| | 3705 | return &instruction->base; |
| | 3706 | } |
| | 3707 | |
| | 3708 | static IrInstSrc *ir_build_bool_not(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *value) { |
| | 3709 | IrInstSrcBoolNot *instruction = ir_build_instruction<IrInstSrcBoolNot>(irb, scope, source_node); |
| 2951 | instruction->value = value; | 3710 | instruction->value = value; |
| 2952 | | 3711 | |
| 2953 | ir_ref_instruction(value, irb->current_basic_block); | 3712 | ir_ref_instruction(value, irb->current_basic_block); |
| ... | @@ -2955,10 +3714,21 @@ static IrInstruction *ir_build_bool_not(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2955,10 +3714,21 @@ static IrInstruction *ir_build_bool_not(IrBuilder *irb, Scope *scope, AstNode *s |
| 2955 | return &instruction->base; | 3714 | return &instruction->base; |
| 2956 | } | 3715 | } |
| 2957 | | 3716 | |
| 2958 | static IrInstruction *ir_build_memset(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3717 | static IrInstGen *ir_build_bool_not_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *value) { |
| 2959 | IrInstruction *dest_ptr, IrInstruction *byte, IrInstruction *count) | 3718 | IrInstGenBoolNot *instruction = ir_build_inst_gen<IrInstGenBoolNot>(&ira->new_irb, |
| | 3719 | source_instr->scope, source_instr->source_node); |
| | 3720 | instruction->base.value->type = ira->codegen->builtin_types.entry_bool; |
| | 3721 | instruction->value = value; |
| | 3722 | |
| | 3723 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| | 3724 | |
| | 3725 | return &instruction->base; |
| | 3726 | } |
| | 3727 | |
| | 3728 | static IrInstSrc *ir_build_memset_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 3729 | IrInstSrc *dest_ptr, IrInstSrc *byte, IrInstSrc *count) |
| 2960 | { | 3730 | { |
| 2961 | IrInstructionMemset *instruction = ir_build_instruction<IrInstructionMemset>(irb, scope, source_node); | 3731 | IrInstSrcMemset *instruction = ir_build_instruction<IrInstSrcMemset>(irb, scope, source_node); |
| 2962 | instruction->dest_ptr = dest_ptr; | 3732 | instruction->dest_ptr = dest_ptr; |
| 2963 | instruction->byte = byte; | 3733 | instruction->byte = byte; |
| 2964 | instruction->count = count; | 3734 | instruction->count = count; |
| ... | @@ -2970,10 +3740,26 @@ static IrInstruction *ir_build_memset(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -2970,10 +3740,26 @@ static IrInstruction *ir_build_memset(IrBuilder *irb, Scope *scope, AstNode *sou |
| 2970 | return &instruction->base; | 3740 | return &instruction->base; |
| 2971 | } | 3741 | } |
| 2972 | | 3742 | |
| 2973 | static IrInstruction *ir_build_memcpy(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3743 | static IrInstGen *ir_build_memset_gen(IrAnalyze *ira, IrInst *source_instr, |
| 2974 | IrInstruction *dest_ptr, IrInstruction *src_ptr, IrInstruction *count) | 3744 | IrInstGen *dest_ptr, IrInstGen *byte, IrInstGen *count) |
| | 3745 | { |
| | 3746 | IrInstGenMemset *instruction = ir_build_inst_void<IrInstGenMemset>(&ira->new_irb, |
| | 3747 | source_instr->scope, source_instr->source_node); |
| | 3748 | instruction->dest_ptr = dest_ptr; |
| | 3749 | instruction->byte = byte; |
| | 3750 | instruction->count = count; |
| | 3751 | |
| | 3752 | ir_ref_inst_gen(dest_ptr, ira->new_irb.current_basic_block); |
| | 3753 | ir_ref_inst_gen(byte, ira->new_irb.current_basic_block); |
| | 3754 | ir_ref_inst_gen(count, ira->new_irb.current_basic_block); |
| | 3755 | |
| | 3756 | return &instruction->base; |
| | 3757 | } |
| | 3758 | |
| | 3759 | static IrInstSrc *ir_build_memcpy_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 3760 | IrInstSrc *dest_ptr, IrInstSrc *src_ptr, IrInstSrc *count) |
| 2975 | { | 3761 | { |
| 2976 | IrInstructionMemcpy *instruction = ir_build_instruction<IrInstructionMemcpy>(irb, scope, source_node); | 3762 | IrInstSrcMemcpy *instruction = ir_build_instruction<IrInstSrcMemcpy>(irb, scope, source_node); |
| 2977 | instruction->dest_ptr = dest_ptr; | 3763 | instruction->dest_ptr = dest_ptr; |
| 2978 | instruction->src_ptr = src_ptr; | 3764 | instruction->src_ptr = src_ptr; |
| 2979 | instruction->count = count; | 3765 | instruction->count = count; |
| ... | @@ -2985,11 +3771,27 @@ static IrInstruction *ir_build_memcpy(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -2985,11 +3771,27 @@ static IrInstruction *ir_build_memcpy(IrBuilder *irb, Scope *scope, AstNode *sou |
| 2985 | return &instruction->base; | 3771 | return &instruction->base; |
| 2986 | } | 3772 | } |
| 2987 | | 3773 | |
| 2988 | static IrInstruction *ir_build_slice_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3774 | static IrInstGen *ir_build_memcpy_gen(IrAnalyze *ira, IrInst *source_instr, |
| 2989 | IrInstruction *ptr, IrInstruction *start, IrInstruction *end, IrInstruction *sentinel, | 3775 | IrInstGen *dest_ptr, IrInstGen *src_ptr, IrInstGen *count) |
| | 3776 | { |
| | 3777 | IrInstGenMemcpy *instruction = ir_build_inst_void<IrInstGenMemcpy>(&ira->new_irb, |
| | 3778 | source_instr->scope, source_instr->source_node); |
| | 3779 | instruction->dest_ptr = dest_ptr; |
| | 3780 | instruction->src_ptr = src_ptr; |
| | 3781 | instruction->count = count; |
| | 3782 | |
| | 3783 | ir_ref_inst_gen(dest_ptr, ira->new_irb.current_basic_block); |
| | 3784 | ir_ref_inst_gen(src_ptr, ira->new_irb.current_basic_block); |
| | 3785 | ir_ref_inst_gen(count, ira->new_irb.current_basic_block); |
| | 3786 | |
| | 3787 | return &instruction->base; |
| | 3788 | } |
| | 3789 | |
| | 3790 | static IrInstSrc *ir_build_slice_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 3791 | IrInstSrc *ptr, IrInstSrc *start, IrInstSrc *end, IrInstSrc *sentinel, |
| 2990 | bool safety_check_on, ResultLoc *result_loc) | 3792 | bool safety_check_on, ResultLoc *result_loc) |
| 2991 | { | 3793 | { |
| 2992 | IrInstructionSliceSrc *instruction = ir_build_instruction<IrInstructionSliceSrc>(irb, scope, source_node); | 3794 | IrInstSrcSlice *instruction = ir_build_instruction<IrInstSrcSlice>(irb, scope, source_node); |
| 2993 | instruction->ptr = ptr; | 3795 | instruction->ptr = ptr; |
| 2994 | instruction->start = start; | 3796 | instruction->start = start; |
| 2995 | instruction->end = end; | 3797 | instruction->end = end; |
| ... | @@ -3005,23 +3807,10 @@ static IrInstruction *ir_build_slice_src(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -3005,23 +3807,10 @@ static IrInstruction *ir_build_slice_src(IrBuilder *irb, Scope *scope, AstNode * |
| 3005 | return &instruction->base; | 3807 | return &instruction->base; |
| 3006 | } | 3808 | } |
| 3007 | | 3809 | |
| 3008 | static IrInstruction *ir_build_splat_gen(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *result_type, | 3810 | static IrInstGen *ir_build_slice_gen(IrAnalyze *ira, IrInst *source_instruction, ZigType *slice_type, |
| 3009 | IrInstruction *scalar) | 3811 | IrInstGen *ptr, IrInstGen *start, IrInstGen *end, bool safety_check_on, IrInstGen *result_loc) |
| 3010 | { | | |
| 3011 | IrInstructionSplatGen *instruction = ir_build_instruction<IrInstructionSplatGen>( | | |
| 3012 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | | |
| 3013 | instruction->base.value->type = result_type; | | |
| 3014 | instruction->scalar = scalar; | | |
| 3015 | | | |
| 3016 | ir_ref_instruction(scalar, ira->new_irb.current_basic_block); | | |
| 3017 | | | |
| 3018 | return &instruction->base; | | |
| 3019 | } | | |
| 3020 | | | |
| 3021 | static IrInstruction *ir_build_slice_gen(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *slice_type, | | |
| 3022 | IrInstruction *ptr, IrInstruction *start, IrInstruction *end, bool safety_check_on, IrInstruction *result_loc) | | |
| 3023 | { | 3812 | { |
| 3024 | IrInstructionSliceGen *instruction = ir_build_instruction<IrInstructionSliceGen>( | 3813 | IrInstGenSlice *instruction = ir_build_inst_gen<IrInstGenSlice>( |
| 3025 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 3814 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 3026 | instruction->base.value->type = slice_type; | 3815 | instruction->base.value->type = slice_type; |
| 3027 | instruction->ptr = ptr; | 3816 | instruction->ptr = ptr; |
| ... | @@ -3030,16 +3819,16 @@ static IrInstruction *ir_build_slice_gen(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -3030,16 +3819,16 @@ static IrInstruction *ir_build_slice_gen(IrAnalyze *ira, IrInstruction *source_i |
| 3030 | instruction->safety_check_on = safety_check_on; | 3819 | instruction->safety_check_on = safety_check_on; |
| 3031 | instruction->result_loc = result_loc; | 3820 | instruction->result_loc = result_loc; |
| 3032 | | 3821 | |
| 3033 | ir_ref_instruction(ptr, ira->new_irb.current_basic_block); | 3822 | ir_ref_inst_gen(ptr, ira->new_irb.current_basic_block); |
| 3034 | ir_ref_instruction(start, ira->new_irb.current_basic_block); | 3823 | ir_ref_inst_gen(start, ira->new_irb.current_basic_block); |
| 3035 | if (end) ir_ref_instruction(end, ira->new_irb.current_basic_block); | 3824 | if (end) ir_ref_inst_gen(end, ira->new_irb.current_basic_block); |
| 3036 | ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 3825 | ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 3037 | | 3826 | |
| 3038 | return &instruction->base; | 3827 | return &instruction->base; |
| 3039 | } | 3828 | } |
| 3040 | | 3829 | |
| 3041 | static IrInstruction *ir_build_member_count(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *container) { | 3830 | static IrInstSrc *ir_build_member_count(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *container) { |
| 3042 | IrInstructionMemberCount *instruction = ir_build_instruction<IrInstructionMemberCount>(irb, scope, source_node); | 3831 | IrInstSrcMemberCount *instruction = ir_build_instruction<IrInstSrcMemberCount>(irb, scope, source_node); |
| 3043 | instruction->container = container; | 3832 | instruction->container = container; |
| 3044 | | 3833 | |
| 3045 | ir_ref_instruction(container, irb->current_basic_block); | 3834 | ir_ref_instruction(container, irb->current_basic_block); |
| ... | @@ -3047,10 +3836,10 @@ static IrInstruction *ir_build_member_count(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -3047,10 +3836,10 @@ static IrInstruction *ir_build_member_count(IrBuilder *irb, Scope *scope, AstNod |
| 3047 | return &instruction->base; | 3836 | return &instruction->base; |
| 3048 | } | 3837 | } |
| 3049 | | 3838 | |
| 3050 | static IrInstruction *ir_build_member_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3839 | static IrInstSrc *ir_build_member_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3051 | IrInstruction *container_type, IrInstruction *member_index) | 3840 | IrInstSrc *container_type, IrInstSrc *member_index) |
| 3052 | { | 3841 | { |
| 3053 | IrInstructionMemberType *instruction = ir_build_instruction<IrInstructionMemberType>(irb, scope, source_node); | 3842 | IrInstSrcMemberType *instruction = ir_build_instruction<IrInstSrcMemberType>(irb, scope, source_node); |
| 3054 | instruction->container_type = container_type; | 3843 | instruction->container_type = container_type; |
| 3055 | instruction->member_index = member_index; | 3844 | instruction->member_index = member_index; |
| 3056 | | 3845 | |
| ... | @@ -3060,10 +3849,10 @@ static IrInstruction *ir_build_member_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3060,10 +3849,10 @@ static IrInstruction *ir_build_member_type(IrBuilder *irb, Scope *scope, AstNode |
| 3060 | return &instruction->base; | 3849 | return &instruction->base; |
| 3061 | } | 3850 | } |
| 3062 | | 3851 | |
| 3063 | static IrInstruction *ir_build_member_name(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3852 | static IrInstSrc *ir_build_member_name(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3064 | IrInstruction *container_type, IrInstruction *member_index) | 3853 | IrInstSrc *container_type, IrInstSrc *member_index) |
| 3065 | { | 3854 | { |
| 3066 | IrInstructionMemberName *instruction = ir_build_instruction<IrInstructionMemberName>(irb, scope, source_node); | 3855 | IrInstSrcMemberName *instruction = ir_build_instruction<IrInstSrcMemberName>(irb, scope, source_node); |
| 3067 | instruction->container_type = container_type; | 3856 | instruction->container_type = container_type; |
| 3068 | instruction->member_index = member_index; | 3857 | instruction->member_index = member_index; |
| 3069 | | 3858 | |
| ... | @@ -3073,65 +3862,88 @@ static IrInstruction *ir_build_member_name(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3073,65 +3862,88 @@ static IrInstruction *ir_build_member_name(IrBuilder *irb, Scope *scope, AstNode |
| 3073 | return &instruction->base; | 3862 | return &instruction->base; |
| 3074 | } | 3863 | } |
| 3075 | | 3864 | |
| 3076 | static IrInstruction *ir_build_breakpoint(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 3865 | static IrInstSrc *ir_build_breakpoint(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 3077 | IrInstructionBreakpoint *instruction = ir_build_instruction<IrInstructionBreakpoint>(irb, scope, source_node); | 3866 | IrInstSrcBreakpoint *instruction = ir_build_instruction<IrInstSrcBreakpoint>(irb, scope, source_node); |
| 3078 | return &instruction->base; | 3867 | return &instruction->base; |
| 3079 | } | 3868 | } |
| 3080 | | 3869 | |
| 3081 | static IrInstruction *ir_build_return_address(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 3870 | static IrInstGen *ir_build_breakpoint_gen(IrAnalyze *ira, IrInst *source_instr) { |
| 3082 | IrInstructionReturnAddress *instruction = ir_build_instruction<IrInstructionReturnAddress>(irb, scope, source_node); | 3871 | IrInstGenBreakpoint *instruction = ir_build_inst_void<IrInstGenBreakpoint>(&ira->new_irb, |
| | 3872 | source_instr->scope, source_instr->source_node); |
| 3083 | return &instruction->base; | 3873 | return &instruction->base; |
| 3084 | } | 3874 | } |
| 3085 | | 3875 | |
| 3086 | static IrInstruction *ir_build_frame_address(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 3876 | static IrInstSrc *ir_build_return_address_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 3087 | IrInstructionFrameAddress *instruction = ir_build_instruction<IrInstructionFrameAddress>(irb, scope, source_node); | 3877 | IrInstSrcReturnAddress *instruction = ir_build_instruction<IrInstSrcReturnAddress>(irb, scope, source_node); |
| 3088 | return &instruction->base; | 3878 | return &instruction->base; |
| 3089 | } | 3879 | } |
| 3090 | | 3880 | |
| 3091 | static IrInstruction *ir_build_handle(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 3881 | static IrInstGen *ir_build_return_address_gen(IrAnalyze *ira, IrInst *source_instr) { |
| 3092 | IrInstructionFrameHandle *instruction = ir_build_instruction<IrInstructionFrameHandle>(irb, scope, source_node); | 3882 | IrInstGenReturnAddress *inst = ir_build_inst_gen<IrInstGenReturnAddress>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| 3093 | return &instruction->base; | 3883 | inst->base.value->type = ira->codegen->builtin_types.entry_usize; |
| | 3884 | return &inst->base; |
| | 3885 | } |
| | 3886 | |
| | 3887 | static IrInstSrc *ir_build_frame_address_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| | 3888 | IrInstSrcFrameAddress *inst = ir_build_instruction<IrInstSrcFrameAddress>(irb, scope, source_node); |
| | 3889 | return &inst->base; |
| | 3890 | } |
| | 3891 | |
| | 3892 | static IrInstGen *ir_build_frame_address_gen(IrAnalyze *ira, IrInst *source_instr) { |
| | 3893 | IrInstGenFrameAddress *inst = ir_build_inst_gen<IrInstGenFrameAddress>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| | 3894 | inst->base.value->type = ira->codegen->builtin_types.entry_usize; |
| | 3895 | return &inst->base; |
| | 3896 | } |
| | 3897 | |
| | 3898 | static IrInstSrc *ir_build_handle_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| | 3899 | IrInstSrcFrameHandle *inst = ir_build_instruction<IrInstSrcFrameHandle>(irb, scope, source_node); |
| | 3900 | return &inst->base; |
| | 3901 | } |
| | 3902 | |
| | 3903 | static IrInstGen *ir_build_handle_gen(IrAnalyze *ira, IrInst *source_instr, ZigType *ty) { |
| | 3904 | IrInstGenFrameHandle *inst = ir_build_inst_gen<IrInstGenFrameHandle>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| | 3905 | inst->base.value->type = ty; |
| | 3906 | return &inst->base; |
| 3094 | } | 3907 | } |
| 3095 | | 3908 | |
| 3096 | static IrInstruction *ir_build_frame_type(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *fn) { | 3909 | static IrInstSrc *ir_build_frame_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *fn) { |
| 3097 | IrInstructionFrameType *instruction = ir_build_instruction<IrInstructionFrameType>(irb, scope, source_node); | 3910 | IrInstSrcFrameType *inst = ir_build_instruction<IrInstSrcFrameType>(irb, scope, source_node); |
| 3098 | instruction->fn = fn; | 3911 | inst->fn = fn; |
| 3099 | | 3912 | |
| 3100 | ir_ref_instruction(fn, irb->current_basic_block); | 3913 | ir_ref_instruction(fn, irb->current_basic_block); |
| 3101 | | 3914 | |
| 3102 | return &instruction->base; | 3915 | return &inst->base; |
| 3103 | } | 3916 | } |
| 3104 | | 3917 | |
| 3105 | static IrInstruction *ir_build_frame_size_src(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *fn) { | 3918 | static IrInstSrc *ir_build_frame_size_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *fn) { |
| 3106 | IrInstructionFrameSizeSrc *instruction = ir_build_instruction<IrInstructionFrameSizeSrc>(irb, scope, source_node); | 3919 | IrInstSrcFrameSize *inst = ir_build_instruction<IrInstSrcFrameSize>(irb, scope, source_node); |
| 3107 | instruction->fn = fn; | 3920 | inst->fn = fn; |
| 3108 | | 3921 | |
| 3109 | ir_ref_instruction(fn, irb->current_basic_block); | 3922 | ir_ref_instruction(fn, irb->current_basic_block); |
| 3110 | | 3923 | |
| 3111 | return &instruction->base; | 3924 | return &inst->base; |
| 3112 | } | 3925 | } |
| 3113 | | 3926 | |
| 3114 | static IrInstruction *ir_build_frame_size_gen(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *fn) | 3927 | static IrInstGen *ir_build_frame_size_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *fn) |
| 3115 | { | 3928 | { |
| 3116 | IrInstructionFrameSizeGen *instruction = ir_build_instruction<IrInstructionFrameSizeGen>(irb, scope, source_node); | 3929 | IrInstGenFrameSize *inst = ir_build_inst_gen<IrInstGenFrameSize>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| 3117 | instruction->fn = fn; | 3930 | inst->base.value->type = ira->codegen->builtin_types.entry_usize; |
| | 3931 | inst->fn = fn; |
| 3118 | | 3932 | |
| 3119 | ir_ref_instruction(fn, irb->current_basic_block); | 3933 | ir_ref_inst_gen(fn, ira->new_irb.current_basic_block); |
| 3120 | | 3934 | |
| 3121 | return &instruction->base; | 3935 | return &inst->base; |
| 3122 | } | 3936 | } |
| 3123 | | 3937 | |
| 3124 | static IrInstruction *ir_build_overflow_op(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3938 | static IrInstSrc *ir_build_overflow_op_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3125 | IrOverflowOp op, IrInstruction *type_value, IrInstruction *op1, IrInstruction *op2, | 3939 | IrOverflowOp op, IrInstSrc *type_value, IrInstSrc *op1, IrInstSrc *op2, IrInstSrc *result_ptr) |
| 3126 | IrInstruction *result_ptr, ZigType *result_ptr_type) | | |
| 3127 | { | 3940 | { |
| 3128 | IrInstructionOverflowOp *instruction = ir_build_instruction<IrInstructionOverflowOp>(irb, scope, source_node); | 3941 | IrInstSrcOverflowOp *instruction = ir_build_instruction<IrInstSrcOverflowOp>(irb, scope, source_node); |
| 3129 | instruction->op = op; | 3942 | instruction->op = op; |
| 3130 | instruction->type_value = type_value; | 3943 | instruction->type_value = type_value; |
| 3131 | instruction->op1 = op1; | 3944 | instruction->op1 = op1; |
| 3132 | instruction->op2 = op2; | 3945 | instruction->op2 = op2; |
| 3133 | instruction->result_ptr = result_ptr; | 3946 | instruction->result_ptr = result_ptr; |
| 3134 | instruction->result_ptr_type = result_ptr_type; | | |
| 3135 | | 3947 | |
| 3136 | ir_ref_instruction(type_value, irb->current_basic_block); | 3948 | ir_ref_instruction(type_value, irb->current_basic_block); |
| 3137 | ir_ref_instruction(op1, irb->current_basic_block); | 3949 | ir_ref_instruction(op1, irb->current_basic_block); |
| ... | @@ -3141,60 +3953,56 @@ static IrInstruction *ir_build_overflow_op(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3141,60 +3953,56 @@ static IrInstruction *ir_build_overflow_op(IrBuilder *irb, Scope *scope, AstNode |
| 3141 | return &instruction->base; | 3953 | return &instruction->base; |
| 3142 | } | 3954 | } |
| 3143 | | 3955 | |
| | 3956 | static IrInstGen *ir_build_overflow_op_gen(IrAnalyze *ira, IrInst *source_instr, |
| | 3957 | IrOverflowOp op, IrInstGen *op1, IrInstGen *op2, IrInstGen *result_ptr, |
| | 3958 | ZigType *result_ptr_type) |
| | 3959 | { |
| | 3960 | IrInstGenOverflowOp *instruction = ir_build_inst_gen<IrInstGenOverflowOp>(&ira->new_irb, |
| | 3961 | source_instr->scope, source_instr->source_node); |
| | 3962 | instruction->base.value->type = ira->codegen->builtin_types.entry_bool; |
| | 3963 | instruction->op = op; |
| | 3964 | instruction->op1 = op1; |
| | 3965 | instruction->op2 = op2; |
| | 3966 | instruction->result_ptr = result_ptr; |
| | 3967 | instruction->result_ptr_type = result_ptr_type; |
| 3144 | | 3968 | |
| 3145 | //TODO Powi, Pow, minnum, maxnum, maximum, minimum, copysign, | 3969 | ir_ref_inst_gen(op1, ira->new_irb.current_basic_block); |
| 3146 | // lround, llround, lrint, llrint | 3970 | ir_ref_inst_gen(op2, ira->new_irb.current_basic_block); |
| 3147 | // So far this is only non-complicated type functions. | 3971 | ir_ref_inst_gen(result_ptr, ira->new_irb.current_basic_block); |
| 3148 | const char *float_op_to_name(BuiltinFnId op) { | 3972 | |
| 3149 | switch (op) { | 3973 | return &instruction->base; |
| 3150 | case BuiltinFnIdSqrt: | | |
| 3151 | return "sqrt"; | | |
| 3152 | case BuiltinFnIdSin: | | |
| 3153 | return "sin"; | | |
| 3154 | case BuiltinFnIdCos: | | |
| 3155 | return "cos"; | | |
| 3156 | case BuiltinFnIdExp: | | |
| 3157 | return "exp"; | | |
| 3158 | case BuiltinFnIdExp2: | | |
| 3159 | return "exp2"; | | |
| 3160 | case BuiltinFnIdLog: | | |
| 3161 | return "log"; | | |
| 3162 | case BuiltinFnIdLog10: | | |
| 3163 | return "log10"; | | |
| 3164 | case BuiltinFnIdLog2: | | |
| 3165 | return "log2"; | | |
| 3166 | case BuiltinFnIdFabs: | | |
| 3167 | return "fabs"; | | |
| 3168 | case BuiltinFnIdFloor: | | |
| 3169 | return "floor"; | | |
| 3170 | case BuiltinFnIdCeil: | | |
| 3171 | return "ceil"; | | |
| 3172 | case BuiltinFnIdTrunc: | | |
| 3173 | return "trunc"; | | |
| 3174 | case BuiltinFnIdNearbyInt: | | |
| 3175 | return "nearbyint"; | | |
| 3176 | case BuiltinFnIdRound: | | |
| 3177 | return "round"; | | |
| 3178 | default: | | |
| 3179 | zig_unreachable(); | | |
| 3180 | } | | |
| 3181 | } | 3974 | } |
| 3182 | | 3975 | |
| 3183 | static IrInstruction *ir_build_float_op(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *operand, | 3976 | static IrInstSrc *ir_build_float_op_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *operand, |
| 3184 | BuiltinFnId fn_id) | 3977 | BuiltinFnId fn_id) |
| 3185 | { | 3978 | { |
| 3186 | IrInstructionFloatOp *instruction = ir_build_instruction<IrInstructionFloatOp>(irb, scope, source_node); | 3979 | IrInstSrcFloatOp *instruction = ir_build_instruction<IrInstSrcFloatOp>(irb, scope, source_node); |
| | 3980 | instruction->operand = operand; |
| | 3981 | instruction->fn_id = fn_id; |
| | 3982 | |
| | 3983 | ir_ref_instruction(operand, irb->current_basic_block); |
| | 3984 | |
| | 3985 | return &instruction->base; |
| | 3986 | } |
| | 3987 | |
| | 3988 | static IrInstGen *ir_build_float_op_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *operand, |
| | 3989 | BuiltinFnId fn_id, ZigType *operand_type) |
| | 3990 | { |
| | 3991 | IrInstGenFloatOp *instruction = ir_build_inst_gen<IrInstGenFloatOp>(&ira->new_irb, |
| | 3992 | source_instr->scope, source_instr->source_node); |
| | 3993 | instruction->base.value->type = operand_type; |
| 3187 | instruction->operand = operand; | 3994 | instruction->operand = operand; |
| 3188 | instruction->fn_id = fn_id; | 3995 | instruction->fn_id = fn_id; |
| 3189 | | 3996 | |
| 3190 | ir_ref_instruction(operand, irb->current_basic_block); | 3997 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 3191 | | 3998 | |
| 3192 | return &instruction->base; | 3999 | return &instruction->base; |
| 3193 | } | 4000 | } |
| 3194 | | 4001 | |
| 3195 | static IrInstruction *ir_build_mul_add(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4002 | static IrInstSrc *ir_build_mul_add_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3196 | IrInstruction *type_value, IrInstruction *op1, IrInstruction *op2, IrInstruction *op3) { | 4003 | IrInstSrc *type_value, IrInstSrc *op1, IrInstSrc *op2, IrInstSrc *op3) |
| 3197 | IrInstructionMulAdd *instruction = ir_build_instruction<IrInstructionMulAdd>(irb, scope, source_node); | 4004 | { |
| | 4005 | IrInstSrcMulAdd *instruction = ir_build_instruction<IrInstSrcMulAdd>(irb, scope, source_node); |
| 3198 | instruction->type_value = type_value; | 4006 | instruction->type_value = type_value; |
| 3199 | instruction->op1 = op1; | 4007 | instruction->op1 = op1; |
| 3200 | instruction->op2 = op2; | 4008 | instruction->op2 = op2; |
| ... | @@ -3208,8 +4016,25 @@ static IrInstruction *ir_build_mul_add(IrBuilder *irb, Scope *scope, AstNode *so | ... | @@ -3208,8 +4016,25 @@ static IrInstruction *ir_build_mul_add(IrBuilder *irb, Scope *scope, AstNode *so |
| 3208 | return &instruction->base; | 4016 | return &instruction->base; |
| 3209 | } | 4017 | } |
| 3210 | | 4018 | |
| 3211 | static IrInstruction *ir_build_align_of(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *type_value) { | 4019 | static IrInstGen *ir_build_mul_add_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *op1, IrInstGen *op2, |
| 3212 | IrInstructionAlignOf *instruction = ir_build_instruction<IrInstructionAlignOf>(irb, scope, source_node); | 4020 | IrInstGen *op3, ZigType *expr_type) |
| | 4021 | { |
| | 4022 | IrInstGenMulAdd *instruction = ir_build_inst_gen<IrInstGenMulAdd>(&ira->new_irb, |
| | 4023 | source_instr->scope, source_instr->source_node); |
| | 4024 | instruction->base.value->type = expr_type; |
| | 4025 | instruction->op1 = op1; |
| | 4026 | instruction->op2 = op2; |
| | 4027 | instruction->op3 = op3; |
| | 4028 | |
| | 4029 | ir_ref_inst_gen(op1, ira->new_irb.current_basic_block); |
| | 4030 | ir_ref_inst_gen(op2, ira->new_irb.current_basic_block); |
| | 4031 | ir_ref_inst_gen(op3, ira->new_irb.current_basic_block); |
| | 4032 | |
| | 4033 | return &instruction->base; |
| | 4034 | } |
| | 4035 | |
| | 4036 | static IrInstSrc *ir_build_align_of(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type_value) { |
| | 4037 | IrInstSrcAlignOf *instruction = ir_build_instruction<IrInstSrcAlignOf>(irb, scope, source_node); |
| 3213 | instruction->type_value = type_value; | 4038 | instruction->type_value = type_value; |
| 3214 | | 4039 | |
| 3215 | ir_ref_instruction(type_value, irb->current_basic_block); | 4040 | ir_ref_instruction(type_value, irb->current_basic_block); |
| ... | @@ -3217,10 +4042,10 @@ static IrInstruction *ir_build_align_of(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -3217,10 +4042,10 @@ static IrInstruction *ir_build_align_of(IrBuilder *irb, Scope *scope, AstNode *s |
| 3217 | return &instruction->base; | 4042 | return &instruction->base; |
| 3218 | } | 4043 | } |
| 3219 | | 4044 | |
| 3220 | static IrInstruction *ir_build_test_err_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4045 | static IrInstSrc *ir_build_test_err_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3221 | IrInstruction *base_ptr, bool resolve_err_set, bool base_ptr_is_payload) | 4046 | IrInstSrc *base_ptr, bool resolve_err_set, bool base_ptr_is_payload) |
| 3222 | { | 4047 | { |
| 3223 | IrInstructionTestErrSrc *instruction = ir_build_instruction<IrInstructionTestErrSrc>(irb, scope, source_node); | 4048 | IrInstSrcTestErr *instruction = ir_build_instruction<IrInstSrcTestErr>(irb, scope, source_node); |
| 3224 | instruction->base_ptr = base_ptr; | 4049 | instruction->base_ptr = base_ptr; |
| 3225 | instruction->resolve_err_set = resolve_err_set; | 4050 | instruction->resolve_err_set = resolve_err_set; |
| 3226 | instruction->base_ptr_is_payload = base_ptr_is_payload; | 4051 | instruction->base_ptr_is_payload = base_ptr_is_payload; |
| ... | @@ -3230,48 +4055,72 @@ static IrInstruction *ir_build_test_err_src(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -3230,48 +4055,72 @@ static IrInstruction *ir_build_test_err_src(IrBuilder *irb, Scope *scope, AstNod |
| 3230 | return &instruction->base; | 4055 | return &instruction->base; |
| 3231 | } | 4056 | } |
| 3232 | | 4057 | |
| 3233 | static IrInstruction *ir_build_test_err_gen(IrAnalyze *ira, IrInstruction *source_instruction, | 4058 | static IrInstGen *ir_build_test_err_gen(IrAnalyze *ira, IrInst *source_instruction, IrInstGen *err_union) { |
| 3234 | IrInstruction *err_union) | 4059 | IrInstGenTestErr *instruction = ir_build_inst_gen<IrInstGenTestErr>( |
| 3235 | { | | |
| 3236 | IrInstructionTestErrGen *instruction = ir_build_instruction<IrInstructionTestErrGen>( | | |
| 3237 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 4060 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 3238 | instruction->base.value->type = ira->codegen->builtin_types.entry_bool; | 4061 | instruction->base.value->type = ira->codegen->builtin_types.entry_bool; |
| 3239 | instruction->err_union = err_union; | 4062 | instruction->err_union = err_union; |
| 3240 | | 4063 | |
| 3241 | ir_ref_instruction(err_union, ira->new_irb.current_basic_block); | 4064 | ir_ref_inst_gen(err_union, ira->new_irb.current_basic_block); |
| 3242 | | 4065 | |
| 3243 | return &instruction->base; | 4066 | return &instruction->base; |
| 3244 | } | 4067 | } |
| 3245 | | 4068 | |
| 3246 | static IrInstruction *ir_build_unwrap_err_code(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4069 | static IrInstSrc *ir_build_unwrap_err_code_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3247 | IrInstruction *err_union_ptr) | 4070 | IrInstSrc *err_union_ptr) |
| 3248 | { | 4071 | { |
| 3249 | IrInstructionUnwrapErrCode *instruction = ir_build_instruction<IrInstructionUnwrapErrCode>(irb, scope, source_node); | 4072 | IrInstSrcUnwrapErrCode *inst = ir_build_instruction<IrInstSrcUnwrapErrCode>(irb, scope, source_node); |
| 3250 | instruction->err_union_ptr = err_union_ptr; | 4073 | inst->err_union_ptr = err_union_ptr; |
| 3251 | | 4074 | |
| 3252 | ir_ref_instruction(err_union_ptr, irb->current_basic_block); | 4075 | ir_ref_instruction(err_union_ptr, irb->current_basic_block); |
| 3253 | | 4076 | |
| 3254 | return &instruction->base; | 4077 | return &inst->base; |
| 3255 | } | 4078 | } |
| 3256 | | 4079 | |
| 3257 | static IrInstruction *ir_build_unwrap_err_payload(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4080 | static IrInstGen *ir_build_unwrap_err_code_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, |
| 3258 | IrInstruction *value, bool safety_check_on, bool initializing) | 4081 | IrInstGen *err_union_ptr, ZigType *result_type) |
| 3259 | { | 4082 | { |
| 3260 | IrInstructionUnwrapErrPayload *instruction = ir_build_instruction<IrInstructionUnwrapErrPayload>(irb, scope, source_node); | 4083 | IrInstGenUnwrapErrCode *inst = ir_build_inst_gen<IrInstGenUnwrapErrCode>(&ira->new_irb, scope, source_node); |
| 3261 | instruction->value = value; | 4084 | inst->base.value->type = result_type; |
| 3262 | instruction->safety_check_on = safety_check_on; | 4085 | inst->err_union_ptr = err_union_ptr; |
| 3263 | instruction->initializing = initializing; | 4086 | |
| | 4087 | ir_ref_inst_gen(err_union_ptr, ira->new_irb.current_basic_block); |
| | 4088 | |
| | 4089 | return &inst->base; |
| | 4090 | } |
| | 4091 | |
| | 4092 | static IrInstSrc *ir_build_unwrap_err_payload_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 4093 | IrInstSrc *value, bool safety_check_on, bool initializing) |
| | 4094 | { |
| | 4095 | IrInstSrcUnwrapErrPayload *inst = ir_build_instruction<IrInstSrcUnwrapErrPayload>(irb, scope, source_node); |
| | 4096 | inst->value = value; |
| | 4097 | inst->safety_check_on = safety_check_on; |
| | 4098 | inst->initializing = initializing; |
| 3264 | | 4099 | |
| 3265 | ir_ref_instruction(value, irb->current_basic_block); | 4100 | ir_ref_instruction(value, irb->current_basic_block); |
| 3266 | | 4101 | |
| 3267 | return &instruction->base; | 4102 | return &inst->base; |
| | 4103 | } |
| | 4104 | |
| | 4105 | static IrInstGen *ir_build_unwrap_err_payload_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, |
| | 4106 | IrInstGen *value, bool safety_check_on, bool initializing, ZigType *result_type) |
| | 4107 | { |
| | 4108 | IrInstGenUnwrapErrPayload *inst = ir_build_inst_gen<IrInstGenUnwrapErrPayload>(&ira->new_irb, scope, source_node); |
| | 4109 | inst->base.value->type = result_type; |
| | 4110 | inst->value = value; |
| | 4111 | inst->safety_check_on = safety_check_on; |
| | 4112 | inst->initializing = initializing; |
| | 4113 | |
| | 4114 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| | 4115 | |
| | 4116 | return &inst->base; |
| 3268 | } | 4117 | } |
| 3269 | | 4118 | |
| 3270 | static IrInstruction *ir_build_fn_proto(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4119 | static IrInstSrc *ir_build_fn_proto(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3271 | IrInstruction **param_types, IrInstruction *align_value, IrInstruction *callconv_value, | 4120 | IrInstSrc **param_types, IrInstSrc *align_value, IrInstSrc *callconv_value, |
| 3272 | IrInstruction *return_type, bool is_var_args) | 4121 | IrInstSrc *return_type, bool is_var_args) |
| 3273 | { | 4122 | { |
| 3274 | IrInstructionFnProto *instruction = ir_build_instruction<IrInstructionFnProto>(irb, scope, source_node); | 4123 | IrInstSrcFnProto *instruction = ir_build_instruction<IrInstSrcFnProto>(irb, scope, source_node); |
| 3275 | instruction->param_types = param_types; | 4124 | instruction->param_types = param_types; |
| 3276 | instruction->align_value = align_value; | 4125 | instruction->align_value = align_value; |
| 3277 | instruction->callconv_value = callconv_value; | 4126 | instruction->callconv_value = callconv_value; |
| ... | @@ -3291,8 +4140,8 @@ static IrInstruction *ir_build_fn_proto(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -3291,8 +4140,8 @@ static IrInstruction *ir_build_fn_proto(IrBuilder *irb, Scope *scope, AstNode *s |
| 3291 | return &instruction->base; | 4140 | return &instruction->base; |
| 3292 | } | 4141 | } |
| 3293 | | 4142 | |
| 3294 | static IrInstruction *ir_build_test_comptime(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *value) { | 4143 | static IrInstSrc *ir_build_test_comptime(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *value) { |
| 3295 | IrInstructionTestComptime *instruction = ir_build_instruction<IrInstructionTestComptime>(irb, scope, source_node); | 4144 | IrInstSrcTestComptime *instruction = ir_build_instruction<IrInstSrcTestComptime>(irb, scope, source_node); |
| 3296 | instruction->value = value; | 4145 | instruction->value = value; |
| 3297 | | 4146 | |
| 3298 | ir_ref_instruction(value, irb->current_basic_block); | 4147 | ir_ref_instruction(value, irb->current_basic_block); |
| ... | @@ -3300,10 +4149,10 @@ static IrInstruction *ir_build_test_comptime(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3300,10 +4149,10 @@ static IrInstruction *ir_build_test_comptime(IrBuilder *irb, Scope *scope, AstNo |
| 3300 | return &instruction->base; | 4149 | return &instruction->base; |
| 3301 | } | 4150 | } |
| 3302 | | 4151 | |
| 3303 | static IrInstruction *ir_build_ptr_cast_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4152 | static IrInstSrc *ir_build_ptr_cast_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3304 | IrInstruction *dest_type, IrInstruction *ptr, bool safety_check_on) | 4153 | IrInstSrc *dest_type, IrInstSrc *ptr, bool safety_check_on) |
| 3305 | { | 4154 | { |
| 3306 | IrInstructionPtrCastSrc *instruction = ir_build_instruction<IrInstructionPtrCastSrc>( | 4155 | IrInstSrcPtrCast *instruction = ir_build_instruction<IrInstSrcPtrCast>( |
| 3307 | irb, scope, source_node); | 4156 | irb, scope, source_node); |
| 3308 | instruction->dest_type = dest_type; | 4157 | instruction->dest_type = dest_type; |
| 3309 | instruction->ptr = ptr; | 4158 | instruction->ptr = ptr; |
| ... | @@ -3315,39 +4164,24 @@ static IrInstruction *ir_build_ptr_cast_src(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -3315,39 +4164,24 @@ static IrInstruction *ir_build_ptr_cast_src(IrBuilder *irb, Scope *scope, AstNod |
| 3315 | return &instruction->base; | 4164 | return &instruction->base; |
| 3316 | } | 4165 | } |
| 3317 | | 4166 | |
| 3318 | static IrInstruction *ir_build_ptr_cast_gen(IrAnalyze *ira, IrInstruction *source_instruction, | 4167 | static IrInstGen *ir_build_ptr_cast_gen(IrAnalyze *ira, IrInst *source_instruction, |
| 3319 | ZigType *ptr_type, IrInstruction *ptr, bool safety_check_on) | 4168 | ZigType *ptr_type, IrInstGen *ptr, bool safety_check_on) |
| 3320 | { | 4169 | { |
| 3321 | IrInstructionPtrCastGen *instruction = ir_build_instruction<IrInstructionPtrCastGen>( | 4170 | IrInstGenPtrCast *instruction = ir_build_inst_gen<IrInstGenPtrCast>( |
| 3322 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 4171 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 3323 | instruction->base.value->type = ptr_type; | 4172 | instruction->base.value->type = ptr_type; |
| 3324 | instruction->ptr = ptr; | 4173 | instruction->ptr = ptr; |
| 3325 | instruction->safety_check_on = safety_check_on; | 4174 | instruction->safety_check_on = safety_check_on; |
| 3326 | | 4175 | |
| 3327 | ir_ref_instruction(ptr, ira->new_irb.current_basic_block); | 4176 | ir_ref_inst_gen(ptr, ira->new_irb.current_basic_block); |
| 3328 | | | |
| 3329 | return &instruction->base; | | |
| 3330 | } | | |
| 3331 | | | |
| 3332 | static IrInstruction *ir_build_load_ptr_gen(IrAnalyze *ira, IrInstruction *source_instruction, | | |
| 3333 | IrInstruction *ptr, ZigType *ty, IrInstruction *result_loc) | | |
| 3334 | { | | |
| 3335 | IrInstructionLoadPtrGen *instruction = ir_build_instruction<IrInstructionLoadPtrGen>( | | |
| 3336 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | | |
| 3337 | instruction->base.value->type = ty; | | |
| 3338 | instruction->ptr = ptr; | | |
| 3339 | instruction->result_loc = result_loc; | | |
| 3340 | | | |
| 3341 | ir_ref_instruction(ptr, ira->new_irb.current_basic_block); | | |
| 3342 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | | |
| 3343 | | 4177 | |
| 3344 | return &instruction->base; | 4178 | return &instruction->base; |
| 3345 | } | 4179 | } |
| 3346 | | 4180 | |
| 3347 | static IrInstruction *ir_build_implicit_cast(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4181 | static IrInstSrc *ir_build_implicit_cast(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3348 | IrInstruction *operand, ResultLocCast *result_loc_cast) | 4182 | IrInstSrc *operand, ResultLocCast *result_loc_cast) |
| 3349 | { | 4183 | { |
| 3350 | IrInstructionImplicitCast *instruction = ir_build_instruction<IrInstructionImplicitCast>(irb, scope, source_node); | 4184 | IrInstSrcImplicitCast *instruction = ir_build_instruction<IrInstSrcImplicitCast>(irb, scope, source_node); |
| 3351 | instruction->operand = operand; | 4185 | instruction->operand = operand; |
| 3352 | instruction->result_loc_cast = result_loc_cast; | 4186 | instruction->result_loc_cast = result_loc_cast; |
| 3353 | | 4187 | |
| ... | @@ -3356,10 +4190,10 @@ static IrInstruction *ir_build_implicit_cast(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3356,10 +4190,10 @@ static IrInstruction *ir_build_implicit_cast(IrBuilder *irb, Scope *scope, AstNo |
| 3356 | return &instruction->base; | 4190 | return &instruction->base; |
| 3357 | } | 4191 | } |
| 3358 | | 4192 | |
| 3359 | static IrInstruction *ir_build_bit_cast_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4193 | static IrInstSrc *ir_build_bit_cast_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3360 | IrInstruction *operand, ResultLocBitCast *result_loc_bit_cast) | 4194 | IrInstSrc *operand, ResultLocBitCast *result_loc_bit_cast) |
| 3361 | { | 4195 | { |
| 3362 | IrInstructionBitCastSrc *instruction = ir_build_instruction<IrInstructionBitCastSrc>(irb, scope, source_node); | 4196 | IrInstSrcBitCast *instruction = ir_build_instruction<IrInstSrcBitCast>(irb, scope, source_node); |
| 3363 | instruction->operand = operand; | 4197 | instruction->operand = operand; |
| 3364 | instruction->result_loc_bit_cast = result_loc_bit_cast; | 4198 | instruction->result_loc_bit_cast = result_loc_bit_cast; |
| 3365 | | 4199 | |
| ... | @@ -3368,62 +4202,81 @@ static IrInstruction *ir_build_bit_cast_src(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -3368,62 +4202,81 @@ static IrInstruction *ir_build_bit_cast_src(IrBuilder *irb, Scope *scope, AstNod |
| 3368 | return &instruction->base; | 4202 | return &instruction->base; |
| 3369 | } | 4203 | } |
| 3370 | | 4204 | |
| 3371 | static IrInstruction *ir_build_bit_cast_gen(IrAnalyze *ira, IrInstruction *source_instruction, | 4205 | static IrInstGen *ir_build_bit_cast_gen(IrAnalyze *ira, IrInst *source_instruction, |
| 3372 | IrInstruction *operand, ZigType *ty) | 4206 | IrInstGen *operand, ZigType *ty) |
| 3373 | { | 4207 | { |
| 3374 | IrInstructionBitCastGen *instruction = ir_build_instruction<IrInstructionBitCastGen>( | 4208 | IrInstGenBitCast *instruction = ir_build_inst_gen<IrInstGenBitCast>( |
| 3375 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 4209 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 3376 | instruction->base.value->type = ty; | 4210 | instruction->base.value->type = ty; |
| 3377 | instruction->operand = operand; | 4211 | instruction->operand = operand; |
| 3378 | | 4212 | |
| 3379 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); | 4213 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 3380 | | 4214 | |
| 3381 | return &instruction->base; | 4215 | return &instruction->base; |
| 3382 | } | 4216 | } |
| 3383 | | 4217 | |
| 3384 | static IrInstruction *ir_build_widen_or_shorten(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4218 | static IrInstGen *ir_build_widen_or_shorten(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, |
| 3385 | IrInstruction *target) | 4219 | ZigType *result_type) |
| 3386 | { | 4220 | { |
| 3387 | IrInstructionWidenOrShorten *instruction = ir_build_instruction<IrInstructionWidenOrShorten>( | 4221 | IrInstGenWidenOrShorten *inst = ir_build_inst_gen<IrInstGenWidenOrShorten>(&ira->new_irb, scope, source_node); |
| 3388 | irb, scope, source_node); | 4222 | inst->base.value->type = result_type; |
| 3389 | instruction->target = target; | 4223 | inst->target = target; |
| 3390 | | 4224 | |
| 3391 | ir_ref_instruction(target, irb->current_basic_block); | 4225 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| 3392 | | 4226 | |
| 3393 | return &instruction->base; | 4227 | return &inst->base; |
| 3394 | } | 4228 | } |
| 3395 | | 4229 | |
| 3396 | static IrInstruction *ir_build_int_to_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4230 | static IrInstSrc *ir_build_int_to_ptr_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3397 | IrInstruction *dest_type, IrInstruction *target) | 4231 | IrInstSrc *dest_type, IrInstSrc *target) |
| 3398 | { | 4232 | { |
| 3399 | IrInstructionIntToPtr *instruction = ir_build_instruction<IrInstructionIntToPtr>( | 4233 | IrInstSrcIntToPtr *instruction = ir_build_instruction<IrInstSrcIntToPtr>(irb, scope, source_node); |
| 3400 | irb, scope, source_node); | | |
| 3401 | instruction->dest_type = dest_type; | 4234 | instruction->dest_type = dest_type; |
| 3402 | instruction->target = target; | 4235 | instruction->target = target; |
| 3403 | | 4236 | |
| 3404 | if (dest_type) ir_ref_instruction(dest_type, irb->current_basic_block); | 4237 | ir_ref_instruction(dest_type, irb->current_basic_block); |
| 3405 | ir_ref_instruction(target, irb->current_basic_block); | 4238 | ir_ref_instruction(target, irb->current_basic_block); |
| 3406 | | 4239 | |
| 3407 | return &instruction->base; | 4240 | return &instruction->base; |
| 3408 | } | 4241 | } |
| 3409 | | 4242 | |
| 3410 | static IrInstruction *ir_build_ptr_to_int(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4243 | static IrInstGen *ir_build_int_to_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, |
| 3411 | IrInstruction *target) | 4244 | IrInstGen *target, ZigType *ptr_type) |
| 3412 | { | 4245 | { |
| 3413 | IrInstructionPtrToInt *instruction = ir_build_instruction<IrInstructionPtrToInt>( | 4246 | IrInstGenIntToPtr *instruction = ir_build_inst_gen<IrInstGenIntToPtr>(&ira->new_irb, scope, source_node); |
| 3414 | irb, scope, source_node); | 4247 | instruction->base.value->type = ptr_type; |
| 3415 | instruction->target = target; | 4248 | instruction->target = target; |
| 3416 | | 4249 | |
| 3417 | ir_ref_instruction(target, irb->current_basic_block); | 4250 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| 3418 | | 4251 | |
| 3419 | return &instruction->base; | 4252 | return &instruction->base; |
| 3420 | } | 4253 | } |
| 3421 | | 4254 | |
| 3422 | static IrInstruction *ir_build_int_to_enum(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4255 | static IrInstSrc *ir_build_ptr_to_int_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3423 | IrInstruction *dest_type, IrInstruction *target) | 4256 | IrInstSrc *target) |
| 3424 | { | 4257 | { |
| 3425 | IrInstructionIntToEnum *instruction = ir_build_instruction<IrInstructionIntToEnum>( | 4258 | IrInstSrcPtrToInt *inst = ir_build_instruction<IrInstSrcPtrToInt>(irb, scope, source_node); |
| 3426 | irb, scope, source_node); | 4259 | inst->target = target; |
| | 4260 | |
| | 4261 | ir_ref_instruction(target, irb->current_basic_block); |
| | 4262 | |
| | 4263 | return &inst->base; |
| | 4264 | } |
| | 4265 | |
| | 4266 | static IrInstGen *ir_build_ptr_to_int_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *target) { |
| | 4267 | IrInstGenPtrToInt *inst = ir_build_inst_gen<IrInstGenPtrToInt>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| | 4268 | inst->base.value->type = ira->codegen->builtin_types.entry_usize; |
| | 4269 | inst->target = target; |
| | 4270 | |
| | 4271 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| | 4272 | |
| | 4273 | return &inst->base; |
| | 4274 | } |
| | 4275 | |
| | 4276 | static IrInstSrc *ir_build_int_to_enum_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 4277 | IrInstSrc *dest_type, IrInstSrc *target) |
| | 4278 | { |
| | 4279 | IrInstSrcIntToEnum *instruction = ir_build_instruction<IrInstSrcIntToEnum>(irb, scope, source_node); |
| 3427 | instruction->dest_type = dest_type; | 4280 | instruction->dest_type = dest_type; |
| 3428 | instruction->target = target; | 4281 | instruction->target = target; |
| 3429 | | 4282 | |
| ... | @@ -3433,12 +4286,22 @@ static IrInstruction *ir_build_int_to_enum(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3433,12 +4286,22 @@ static IrInstruction *ir_build_int_to_enum(IrBuilder *irb, Scope *scope, AstNode |
| 3433 | return &instruction->base; | 4286 | return &instruction->base; |
| 3434 | } | 4287 | } |
| 3435 | | 4288 | |
| | 4289 | static IrInstGen *ir_build_int_to_enum_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, |
| | 4290 | ZigType *dest_type, IrInstGen *target) |
| | 4291 | { |
| | 4292 | IrInstGenIntToEnum *instruction = ir_build_inst_gen<IrInstGenIntToEnum>(&ira->new_irb, scope, source_node); |
| | 4293 | instruction->base.value->type = dest_type; |
| | 4294 | instruction->target = target; |
| | 4295 | |
| | 4296 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| 3436 | | 4297 | |
| | 4298 | return &instruction->base; |
| | 4299 | } |
| 3437 | | 4300 | |
| 3438 | static IrInstruction *ir_build_enum_to_int(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4301 | static IrInstSrc *ir_build_enum_to_int(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3439 | IrInstruction *target) | 4302 | IrInstSrc *target) |
| 3440 | { | 4303 | { |
| 3441 | IrInstructionEnumToInt *instruction = ir_build_instruction<IrInstructionEnumToInt>( | 4304 | IrInstSrcEnumToInt *instruction = ir_build_instruction<IrInstSrcEnumToInt>( |
| 3442 | irb, scope, source_node); | 4305 | irb, scope, source_node); |
| 3443 | instruction->target = target; | 4306 | instruction->target = target; |
| 3444 | | 4307 | |
| ... | @@ -3447,11 +4310,10 @@ static IrInstruction *ir_build_enum_to_int(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3447,11 +4310,10 @@ static IrInstruction *ir_build_enum_to_int(IrBuilder *irb, Scope *scope, AstNode |
| 3447 | return &instruction->base; | 4310 | return &instruction->base; |
| 3448 | } | 4311 | } |
| 3449 | | 4312 | |
| 3450 | static IrInstruction *ir_build_int_to_err(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4313 | static IrInstSrc *ir_build_int_to_err_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3451 | IrInstruction *target) | 4314 | IrInstSrc *target) |
| 3452 | { | 4315 | { |
| 3453 | IrInstructionIntToErr *instruction = ir_build_instruction<IrInstructionIntToErr>( | 4316 | IrInstSrcIntToErr *instruction = ir_build_instruction<IrInstSrcIntToErr>(irb, scope, source_node); |
| 3454 | irb, scope, source_node); | | |
| 3455 | instruction->target = target; | 4317 | instruction->target = target; |
| 3456 | | 4318 | |
| 3457 | ir_ref_instruction(target, irb->current_basic_block); | 4319 | ir_ref_instruction(target, irb->current_basic_block); |
| ... | @@ -3459,10 +4321,22 @@ static IrInstruction *ir_build_int_to_err(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3459,10 +4321,22 @@ static IrInstruction *ir_build_int_to_err(IrBuilder *irb, Scope *scope, AstNode |
| 3459 | return &instruction->base; | 4321 | return &instruction->base; |
| 3460 | } | 4322 | } |
| 3461 | | 4323 | |
| 3462 | static IrInstruction *ir_build_err_to_int(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4324 | static IrInstGen *ir_build_int_to_err_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, |
| 3463 | IrInstruction *target) | 4325 | ZigType *wanted_type) |
| | 4326 | { |
| | 4327 | IrInstGenIntToErr *instruction = ir_build_inst_gen<IrInstGenIntToErr>(&ira->new_irb, scope, source_node); |
| | 4328 | instruction->base.value->type = wanted_type; |
| | 4329 | instruction->target = target; |
| | 4330 | |
| | 4331 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| | 4332 | |
| | 4333 | return &instruction->base; |
| | 4334 | } |
| | 4335 | |
| | 4336 | static IrInstSrc *ir_build_err_to_int_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 4337 | IrInstSrc *target) |
| 3464 | { | 4338 | { |
| 3465 | IrInstructionErrToInt *instruction = ir_build_instruction<IrInstructionErrToInt>( | 4339 | IrInstSrcErrToInt *instruction = ir_build_instruction<IrInstSrcErrToInt>( |
| 3466 | irb, scope, source_node); | 4340 | irb, scope, source_node); |
| 3467 | instruction->target = target; | 4341 | instruction->target = target; |
| 3468 | | 4342 | |
| ... | @@ -3471,16 +4345,29 @@ static IrInstruction *ir_build_err_to_int(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3471,16 +4345,29 @@ static IrInstruction *ir_build_err_to_int(IrBuilder *irb, Scope *scope, AstNode |
| 3471 | return &instruction->base; | 4345 | return &instruction->base; |
| 3472 | } | 4346 | } |
| 3473 | | 4347 | |
| 3474 | static IrInstruction *ir_build_check_switch_prongs(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4348 | static IrInstGen *ir_build_err_to_int_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, |
| 3475 | IrInstruction *target_value, IrInstructionCheckSwitchProngsRange *ranges, size_t range_count, | 4349 | ZigType *wanted_type) |
| 3476 | bool have_else_prong) | 4350 | { |
| | 4351 | IrInstGenErrToInt *instruction = ir_build_inst_gen<IrInstGenErrToInt>(&ira->new_irb, scope, source_node); |
| | 4352 | instruction->base.value->type = wanted_type; |
| | 4353 | instruction->target = target; |
| | 4354 | |
| | 4355 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| | 4356 | |
| | 4357 | return &instruction->base; |
| | 4358 | } |
| | 4359 | |
| | 4360 | static IrInstSrc *ir_build_check_switch_prongs(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 4361 | IrInstSrc *target_value, IrInstSrcCheckSwitchProngsRange *ranges, size_t range_count, |
| | 4362 | bool have_else_prong, bool have_underscore_prong) |
| 3477 | { | 4363 | { |
| 3478 | IrInstructionCheckSwitchProngs *instruction = ir_build_instruction<IrInstructionCheckSwitchProngs>( | 4364 | IrInstSrcCheckSwitchProngs *instruction = ir_build_instruction<IrInstSrcCheckSwitchProngs>( |
| 3479 | irb, scope, source_node); | 4365 | irb, scope, source_node); |
| 3480 | instruction->target_value = target_value; | 4366 | instruction->target_value = target_value; |
| 3481 | instruction->ranges = ranges; | 4367 | instruction->ranges = ranges; |
| 3482 | instruction->range_count = range_count; | 4368 | instruction->range_count = range_count; |
| 3483 | instruction->have_else_prong = have_else_prong; | 4369 | instruction->have_else_prong = have_else_prong; |
| | 4370 | instruction->have_underscore_prong = have_underscore_prong; |
| 3484 | | 4371 | |
| 3485 | ir_ref_instruction(target_value, irb->current_basic_block); | 4372 | ir_ref_instruction(target_value, irb->current_basic_block); |
| 3486 | for (size_t i = 0; i < range_count; i += 1) { | 4373 | for (size_t i = 0; i < range_count; i += 1) { |
| ... | @@ -3491,10 +4378,10 @@ static IrInstruction *ir_build_check_switch_prongs(IrBuilder *irb, Scope *scope, | ... | @@ -3491,10 +4378,10 @@ static IrInstruction *ir_build_check_switch_prongs(IrBuilder *irb, Scope *scope, |
| 3491 | return &instruction->base; | 4378 | return &instruction->base; |
| 3492 | } | 4379 | } |
| 3493 | | 4380 | |
| 3494 | static IrInstruction *ir_build_check_statement_is_void(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4381 | static IrInstSrc *ir_build_check_statement_is_void(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3495 | IrInstruction* statement_value) | 4382 | IrInstSrc* statement_value) |
| 3496 | { | 4383 | { |
| 3497 | IrInstructionCheckStatementIsVoid *instruction = ir_build_instruction<IrInstructionCheckStatementIsVoid>( | 4384 | IrInstSrcCheckStatementIsVoid *instruction = ir_build_instruction<IrInstSrcCheckStatementIsVoid>( |
| 3498 | irb, scope, source_node); | 4385 | irb, scope, source_node); |
| 3499 | instruction->statement_value = statement_value; | 4386 | instruction->statement_value = statement_value; |
| 3500 | | 4387 | |
| ... | @@ -3503,11 +4390,10 @@ static IrInstruction *ir_build_check_statement_is_void(IrBuilder *irb, Scope *sc | ... | @@ -3503,11 +4390,10 @@ static IrInstruction *ir_build_check_statement_is_void(IrBuilder *irb, Scope *sc |
| 3503 | return &instruction->base; | 4390 | return &instruction->base; |
| 3504 | } | 4391 | } |
| 3505 | | 4392 | |
| 3506 | static IrInstruction *ir_build_type_name(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4393 | static IrInstSrc *ir_build_type_name(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3507 | IrInstruction *type_value) | 4394 | IrInstSrc *type_value) |
| 3508 | { | 4395 | { |
| 3509 | IrInstructionTypeName *instruction = ir_build_instruction<IrInstructionTypeName>( | 4396 | IrInstSrcTypeName *instruction = ir_build_instruction<IrInstSrcTypeName>(irb, scope, source_node); |
| 3510 | irb, scope, source_node); | | |
| 3511 | instruction->type_value = type_value; | 4397 | instruction->type_value = type_value; |
| 3512 | | 4398 | |
| 3513 | ir_ref_instruction(type_value, irb->current_basic_block); | 4399 | ir_ref_instruction(type_value, irb->current_basic_block); |
| ... | @@ -3515,18 +4401,17 @@ static IrInstruction *ir_build_type_name(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -3515,18 +4401,17 @@ static IrInstruction *ir_build_type_name(IrBuilder *irb, Scope *scope, AstNode * |
| 3515 | return &instruction->base; | 4401 | return &instruction->base; |
| 3516 | } | 4402 | } |
| 3517 | | 4403 | |
| 3518 | static IrInstruction *ir_build_decl_ref(IrBuilder *irb, Scope *scope, AstNode *source_node, Tld *tld, LVal lval) { | 4404 | static IrInstSrc *ir_build_decl_ref(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, Tld *tld, LVal lval) { |
| 3519 | IrInstructionDeclRef *instruction = ir_build_instruction<IrInstructionDeclRef>(irb, scope, source_node); | 4405 | IrInstSrcDeclRef *instruction = ir_build_instruction<IrInstSrcDeclRef>(irb, scope, source_node); |
| 3520 | instruction->tld = tld; | 4406 | instruction->tld = tld; |
| 3521 | instruction->lval = lval; | 4407 | instruction->lval = lval; |
| 3522 | | 4408 | |
| 3523 | return &instruction->base; | 4409 | return &instruction->base; |
| 3524 | } | 4410 | } |
| 3525 | | 4411 | |
| 3526 | static IrInstruction *ir_build_panic(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *msg) { | 4412 | static IrInstSrc *ir_build_panic_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *msg) { |
| 3527 | IrInstructionPanic *instruction = ir_build_instruction<IrInstructionPanic>(irb, scope, source_node); | 4413 | IrInstSrcPanic *instruction = ir_build_instruction<IrInstSrcPanic>(irb, scope, source_node); |
| 3528 | instruction->base.value->special = ConstValSpecialStatic; | 4414 | instruction->base.is_noreturn = true; |
| 3529 | instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; | | |
| 3530 | instruction->msg = msg; | 4415 | instruction->msg = msg; |
| 3531 | | 4416 | |
| 3532 | ir_ref_instruction(msg, irb->current_basic_block); | 4417 | ir_ref_instruction(msg, irb->current_basic_block); |
| ... | @@ -3534,10 +4419,18 @@ static IrInstruction *ir_build_panic(IrBuilder *irb, Scope *scope, AstNode *sour | ... | @@ -3534,10 +4419,18 @@ static IrInstruction *ir_build_panic(IrBuilder *irb, Scope *scope, AstNode *sour |
| 3534 | return &instruction->base; | 4419 | return &instruction->base; |
| 3535 | } | 4420 | } |
| 3536 | | 4421 | |
| 3537 | static IrInstruction *ir_build_tag_name(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4422 | static IrInstGen *ir_build_panic_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *msg) { |
| 3538 | IrInstruction *target) | 4423 | IrInstGenPanic *instruction = ir_build_inst_noreturn<IrInstGenPanic>(&ira->new_irb, |
| 3539 | { | 4424 | source_instr->scope, source_instr->source_node); |
| 3540 | IrInstructionTagName *instruction = ir_build_instruction<IrInstructionTagName>(irb, scope, source_node); | 4425 | instruction->msg = msg; |
| | 4426 | |
| | 4427 | ir_ref_inst_gen(msg, ira->new_irb.current_basic_block); |
| | 4428 | |
| | 4429 | return &instruction->base; |
| | 4430 | } |
| | 4431 | |
| | 4432 | static IrInstSrc *ir_build_tag_name_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *target) { |
| | 4433 | IrInstSrcTagName *instruction = ir_build_instruction<IrInstSrcTagName>(irb, scope, source_node); |
| 3541 | instruction->target = target; | 4434 | instruction->target = target; |
| 3542 | | 4435 | |
| 3543 | ir_ref_instruction(target, irb->current_basic_block); | 4436 | ir_ref_instruction(target, irb->current_basic_block); |
| ... | @@ -3545,10 +4438,23 @@ static IrInstruction *ir_build_tag_name(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -3545,10 +4438,23 @@ static IrInstruction *ir_build_tag_name(IrBuilder *irb, Scope *scope, AstNode *s |
| 3545 | return &instruction->base; | 4438 | return &instruction->base; |
| 3546 | } | 4439 | } |
| 3547 | | 4440 | |
| 3548 | static IrInstruction *ir_build_tag_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4441 | static IrInstGen *ir_build_tag_name_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *target, |
| 3549 | IrInstruction *target) | 4442 | ZigType *result_type) |
| | 4443 | { |
| | 4444 | IrInstGenTagName *instruction = ir_build_inst_gen<IrInstGenTagName>(&ira->new_irb, |
| | 4445 | source_instr->scope, source_instr->source_node); |
| | 4446 | instruction->base.value->type = result_type; |
| | 4447 | instruction->target = target; |
| | 4448 | |
| | 4449 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| | 4450 | |
| | 4451 | return &instruction->base; |
| | 4452 | } |
| | 4453 | |
| | 4454 | static IrInstSrc *ir_build_tag_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 4455 | IrInstSrc *target) |
| 3550 | { | 4456 | { |
| 3551 | IrInstructionTagType *instruction = ir_build_instruction<IrInstructionTagType>(irb, scope, source_node); | 4457 | IrInstSrcTagType *instruction = ir_build_instruction<IrInstSrcTagType>(irb, scope, source_node); |
| 3552 | instruction->target = target; | 4458 | instruction->target = target; |
| 3553 | | 4459 | |
| 3554 | ir_ref_instruction(target, irb->current_basic_block); | 4460 | ir_ref_instruction(target, irb->current_basic_block); |
| ... | @@ -3556,27 +4462,40 @@ static IrInstruction *ir_build_tag_type(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -3556,27 +4462,40 @@ static IrInstruction *ir_build_tag_type(IrBuilder *irb, Scope *scope, AstNode *s |
| 3556 | return &instruction->base; | 4462 | return &instruction->base; |
| 3557 | } | 4463 | } |
| 3558 | | 4464 | |
| 3559 | static IrInstruction *ir_build_field_parent_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4465 | static IrInstSrc *ir_build_field_parent_ptr_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3560 | IrInstruction *type_value, IrInstruction *field_name, IrInstruction *field_ptr, TypeStructField *field) | 4466 | IrInstSrc *type_value, IrInstSrc *field_name, IrInstSrc *field_ptr) |
| 3561 | { | 4467 | { |
| 3562 | IrInstructionFieldParentPtr *instruction = ir_build_instruction<IrInstructionFieldParentPtr>( | 4468 | IrInstSrcFieldParentPtr *inst = ir_build_instruction<IrInstSrcFieldParentPtr>( |
| 3563 | irb, scope, source_node); | 4469 | irb, scope, source_node); |
| 3564 | instruction->type_value = type_value; | 4470 | inst->type_value = type_value; |
| 3565 | instruction->field_name = field_name; | 4471 | inst->field_name = field_name; |
| 3566 | instruction->field_ptr = field_ptr; | 4472 | inst->field_ptr = field_ptr; |
| 3567 | instruction->field = field; | | |
| 3568 | | 4473 | |
| 3569 | ir_ref_instruction(type_value, irb->current_basic_block); | 4474 | ir_ref_instruction(type_value, irb->current_basic_block); |
| 3570 | ir_ref_instruction(field_name, irb->current_basic_block); | 4475 | ir_ref_instruction(field_name, irb->current_basic_block); |
| 3571 | ir_ref_instruction(field_ptr, irb->current_basic_block); | 4476 | ir_ref_instruction(field_ptr, irb->current_basic_block); |
| 3572 | | 4477 | |
| 3573 | return &instruction->base; | 4478 | return &inst->base; |
| | 4479 | } |
| | 4480 | |
| | 4481 | static IrInstGen *ir_build_field_parent_ptr_gen(IrAnalyze *ira, IrInst *source_instr, |
| | 4482 | IrInstGen *field_ptr, TypeStructField *field, ZigType *result_type) |
| | 4483 | { |
| | 4484 | IrInstGenFieldParentPtr *inst = ir_build_inst_gen<IrInstGenFieldParentPtr>(&ira->new_irb, |
| | 4485 | source_instr->scope, source_instr->source_node); |
| | 4486 | inst->base.value->type = result_type; |
| | 4487 | inst->field_ptr = field_ptr; |
| | 4488 | inst->field = field; |
| | 4489 | |
| | 4490 | ir_ref_inst_gen(field_ptr, ira->new_irb.current_basic_block); |
| | 4491 | |
| | 4492 | return &inst->base; |
| 3574 | } | 4493 | } |
| 3575 | | 4494 | |
| 3576 | static IrInstruction *ir_build_byte_offset_of(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4495 | static IrInstSrc *ir_build_byte_offset_of(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3577 | IrInstruction *type_value, IrInstruction *field_name) | 4496 | IrInstSrc *type_value, IrInstSrc *field_name) |
| 3578 | { | 4497 | { |
| 3579 | IrInstructionByteOffsetOf *instruction = ir_build_instruction<IrInstructionByteOffsetOf>(irb, scope, source_node); | 4498 | IrInstSrcByteOffsetOf *instruction = ir_build_instruction<IrInstSrcByteOffsetOf>(irb, scope, source_node); |
| 3580 | instruction->type_value = type_value; | 4499 | instruction->type_value = type_value; |
| 3581 | instruction->field_name = field_name; | 4500 | instruction->field_name = field_name; |
| 3582 | | 4501 | |
| ... | @@ -3586,10 +4505,10 @@ static IrInstruction *ir_build_byte_offset_of(IrBuilder *irb, Scope *scope, AstN | ... | @@ -3586,10 +4505,10 @@ static IrInstruction *ir_build_byte_offset_of(IrBuilder *irb, Scope *scope, AstN |
| 3586 | return &instruction->base; | 4505 | return &instruction->base; |
| 3587 | } | 4506 | } |
| 3588 | | 4507 | |
| 3589 | static IrInstruction *ir_build_bit_offset_of(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4508 | static IrInstSrc *ir_build_bit_offset_of(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3590 | IrInstruction *type_value, IrInstruction *field_name) | 4509 | IrInstSrc *type_value, IrInstSrc *field_name) |
| 3591 | { | 4510 | { |
| 3592 | IrInstructionBitOffsetOf *instruction = ir_build_instruction<IrInstructionBitOffsetOf>(irb, scope, source_node); | 4511 | IrInstSrcBitOffsetOf *instruction = ir_build_instruction<IrInstSrcBitOffsetOf>(irb, scope, source_node); |
| 3593 | instruction->type_value = type_value; | 4512 | instruction->type_value = type_value; |
| 3594 | instruction->field_name = field_name; | 4513 | instruction->field_name = field_name; |
| 3595 | | 4514 | |
| ... | @@ -3599,9 +4518,8 @@ static IrInstruction *ir_build_bit_offset_of(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3599,9 +4518,8 @@ static IrInstruction *ir_build_bit_offset_of(IrBuilder *irb, Scope *scope, AstNo |
| 3599 | return &instruction->base; | 4518 | return &instruction->base; |
| 3600 | } | 4519 | } |
| 3601 | | 4520 | |
| 3602 | static IrInstruction *ir_build_type_info(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4521 | static IrInstSrc *ir_build_type_info(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type_value) { |
| 3603 | IrInstruction *type_value) { | 4522 | IrInstSrcTypeInfo *instruction = ir_build_instruction<IrInstSrcTypeInfo>(irb, scope, source_node); |
| 3604 | IrInstructionTypeInfo *instruction = ir_build_instruction<IrInstructionTypeInfo>(irb, scope, source_node); | | |
| 3605 | instruction->type_value = type_value; | 4523 | instruction->type_value = type_value; |
| 3606 | | 4524 | |
| 3607 | ir_ref_instruction(type_value, irb->current_basic_block); | 4525 | ir_ref_instruction(type_value, irb->current_basic_block); |
| ... | @@ -3609,8 +4527,8 @@ static IrInstruction *ir_build_type_info(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -3609,8 +4527,8 @@ static IrInstruction *ir_build_type_info(IrBuilder *irb, Scope *scope, AstNode * |
| 3609 | return &instruction->base; | 4527 | return &instruction->base; |
| 3610 | } | 4528 | } |
| 3611 | | 4529 | |
| 3612 | static IrInstruction *ir_build_type(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *type_info) { | 4530 | static IrInstSrc *ir_build_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type_info) { |
| 3613 | IrInstructionType *instruction = ir_build_instruction<IrInstructionType>(irb, scope, source_node); | 4531 | IrInstSrcType *instruction = ir_build_instruction<IrInstSrcType>(irb, scope, source_node); |
| 3614 | instruction->type_info = type_info; | 4532 | instruction->type_info = type_info; |
| 3615 | | 4533 | |
| 3616 | ir_ref_instruction(type_info, irb->current_basic_block); | 4534 | ir_ref_instruction(type_info, irb->current_basic_block); |
| ... | @@ -3618,10 +4536,8 @@ static IrInstruction *ir_build_type(IrBuilder *irb, Scope *scope, AstNode *sourc | ... | @@ -3618,10 +4536,8 @@ static IrInstruction *ir_build_type(IrBuilder *irb, Scope *scope, AstNode *sourc |
| 3618 | return &instruction->base; | 4536 | return &instruction->base; |
| 3619 | } | 4537 | } |
| 3620 | | 4538 | |
| 3621 | static IrInstruction *ir_build_type_id(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4539 | static IrInstSrc *ir_build_type_id(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type_value) { |
| 3622 | IrInstruction *type_value) | 4540 | IrInstSrcTypeId *instruction = ir_build_instruction<IrInstSrcTypeId>(irb, scope, source_node); |
| 3623 | { | | |
| 3624 | IrInstructionTypeId *instruction = ir_build_instruction<IrInstructionTypeId>(irb, scope, source_node); | | |
| 3625 | instruction->type_value = type_value; | 4541 | instruction->type_value = type_value; |
| 3626 | | 4542 | |
| 3627 | ir_ref_instruction(type_value, irb->current_basic_block); | 4543 | ir_ref_instruction(type_value, irb->current_basic_block); |
| ... | @@ -3629,10 +4545,10 @@ static IrInstruction *ir_build_type_id(IrBuilder *irb, Scope *scope, AstNode *so | ... | @@ -3629,10 +4545,10 @@ static IrInstruction *ir_build_type_id(IrBuilder *irb, Scope *scope, AstNode *so |
| 3629 | return &instruction->base; | 4545 | return &instruction->base; |
| 3630 | } | 4546 | } |
| 3631 | | 4547 | |
| 3632 | static IrInstruction *ir_build_set_eval_branch_quota(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4548 | static IrInstSrc *ir_build_set_eval_branch_quota(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3633 | IrInstruction *new_quota) | 4549 | IrInstSrc *new_quota) |
| 3634 | { | 4550 | { |
| 3635 | IrInstructionSetEvalBranchQuota *instruction = ir_build_instruction<IrInstructionSetEvalBranchQuota>(irb, scope, source_node); | 4551 | IrInstSrcSetEvalBranchQuota *instruction = ir_build_instruction<IrInstSrcSetEvalBranchQuota>(irb, scope, source_node); |
| 3636 | instruction->new_quota = new_quota; | 4552 | instruction->new_quota = new_quota; |
| 3637 | | 4553 | |
| 3638 | ir_ref_instruction(new_quota, irb->current_basic_block); | 4554 | ir_ref_instruction(new_quota, irb->current_basic_block); |
| ... | @@ -3640,23 +4556,35 @@ static IrInstruction *ir_build_set_eval_branch_quota(IrBuilder *irb, Scope *scop | ... | @@ -3640,23 +4556,35 @@ static IrInstruction *ir_build_set_eval_branch_quota(IrBuilder *irb, Scope *scop |
| 3640 | return &instruction->base; | 4556 | return &instruction->base; |
| 3641 | } | 4557 | } |
| 3642 | | 4558 | |
| 3643 | static IrInstruction *ir_build_align_cast(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4559 | static IrInstSrc *ir_build_align_cast_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3644 | IrInstruction *align_bytes, IrInstruction *target) | 4560 | IrInstSrc *align_bytes, IrInstSrc *target) |
| 3645 | { | 4561 | { |
| 3646 | IrInstructionAlignCast *instruction = ir_build_instruction<IrInstructionAlignCast>(irb, scope, source_node); | 4562 | IrInstSrcAlignCast *instruction = ir_build_instruction<IrInstSrcAlignCast>(irb, scope, source_node); |
| 3647 | instruction->align_bytes = align_bytes; | 4563 | instruction->align_bytes = align_bytes; |
| 3648 | instruction->target = target; | 4564 | instruction->target = target; |
| 3649 | | 4565 | |
| 3650 | if (align_bytes) ir_ref_instruction(align_bytes, irb->current_basic_block); | 4566 | ir_ref_instruction(align_bytes, irb->current_basic_block); |
| 3651 | ir_ref_instruction(target, irb->current_basic_block); | 4567 | ir_ref_instruction(target, irb->current_basic_block); |
| 3652 | | 4568 | |
| 3653 | return &instruction->base; | 4569 | return &instruction->base; |
| 3654 | } | 4570 | } |
| 3655 | | 4571 | |
| 3656 | static IrInstruction *ir_build_resolve_result(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4572 | static IrInstGen *ir_build_align_cast_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, |
| 3657 | ResultLoc *result_loc, IrInstruction *ty) | 4573 | ZigType *result_type) |
| | 4574 | { |
| | 4575 | IrInstGenAlignCast *instruction = ir_build_inst_gen<IrInstGenAlignCast>(&ira->new_irb, scope, source_node); |
| | 4576 | instruction->base.value->type = result_type; |
| | 4577 | instruction->target = target; |
| | 4578 | |
| | 4579 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| | 4580 | |
| | 4581 | return &instruction->base; |
| | 4582 | } |
| | 4583 | |
| | 4584 | static IrInstSrc *ir_build_resolve_result(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 4585 | ResultLoc *result_loc, IrInstSrc *ty) |
| 3658 | { | 4586 | { |
| 3659 | IrInstructionResolveResult *instruction = ir_build_instruction<IrInstructionResolveResult>(irb, scope, source_node); | 4587 | IrInstSrcResolveResult *instruction = ir_build_instruction<IrInstSrcResolveResult>(irb, scope, source_node); |
| 3660 | instruction->result_loc = result_loc; | 4588 | instruction->result_loc = result_loc; |
| 3661 | instruction->ty = ty; | 4589 | instruction->ty = ty; |
| 3662 | | 4590 | |
| ... | @@ -3665,26 +4593,26 @@ static IrInstruction *ir_build_resolve_result(IrBuilder *irb, Scope *scope, AstN | ... | @@ -3665,26 +4593,26 @@ static IrInstruction *ir_build_resolve_result(IrBuilder *irb, Scope *scope, AstN |
| 3665 | return &instruction->base; | 4593 | return &instruction->base; |
| 3666 | } | 4594 | } |
| 3667 | | 4595 | |
| 3668 | static IrInstruction *ir_build_reset_result(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4596 | static IrInstSrc *ir_build_reset_result(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3669 | ResultLoc *result_loc) | 4597 | ResultLoc *result_loc) |
| 3670 | { | 4598 | { |
| 3671 | IrInstructionResetResult *instruction = ir_build_instruction<IrInstructionResetResult>(irb, scope, source_node); | 4599 | IrInstSrcResetResult *instruction = ir_build_instruction<IrInstSrcResetResult>(irb, scope, source_node); |
| 3672 | instruction->result_loc = result_loc; | 4600 | instruction->result_loc = result_loc; |
| 3673 | instruction->base.is_gen = true; | 4601 | instruction->base.is_gen = true; |
| 3674 | | 4602 | |
| 3675 | return &instruction->base; | 4603 | return &instruction->base; |
| 3676 | } | 4604 | } |
| 3677 | | 4605 | |
| 3678 | static IrInstruction *ir_build_opaque_type(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 4606 | static IrInstSrc *ir_build_opaque_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 3679 | IrInstructionOpaqueType *instruction = ir_build_instruction<IrInstructionOpaqueType>(irb, scope, source_node); | 4607 | IrInstSrcOpaqueType *instruction = ir_build_instruction<IrInstSrcOpaqueType>(irb, scope, source_node); |
| 3680 | | 4608 | |
| 3681 | return &instruction->base; | 4609 | return &instruction->base; |
| 3682 | } | 4610 | } |
| 3683 | | 4611 | |
| 3684 | static IrInstruction *ir_build_set_align_stack(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4612 | static IrInstSrc *ir_build_set_align_stack(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3685 | IrInstruction *align_bytes) | 4613 | IrInstSrc *align_bytes) |
| 3686 | { | 4614 | { |
| 3687 | IrInstructionSetAlignStack *instruction = ir_build_instruction<IrInstructionSetAlignStack>(irb, scope, source_node); | 4615 | IrInstSrcSetAlignStack *instruction = ir_build_instruction<IrInstSrcSetAlignStack>(irb, scope, source_node); |
| 3688 | instruction->align_bytes = align_bytes; | 4616 | instruction->align_bytes = align_bytes; |
| 3689 | | 4617 | |
| 3690 | ir_ref_instruction(align_bytes, irb->current_basic_block); | 4618 | ir_ref_instruction(align_bytes, irb->current_basic_block); |
| ... | @@ -3692,10 +4620,10 @@ static IrInstruction *ir_build_set_align_stack(IrBuilder *irb, Scope *scope, Ast | ... | @@ -3692,10 +4620,10 @@ static IrInstruction *ir_build_set_align_stack(IrBuilder *irb, Scope *scope, Ast |
| 3692 | return &instruction->base; | 4620 | return &instruction->base; |
| 3693 | } | 4621 | } |
| 3694 | | 4622 | |
| 3695 | static IrInstruction *ir_build_arg_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4623 | static IrInstSrc *ir_build_arg_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3696 | IrInstruction *fn_type, IrInstruction *arg_index, bool allow_var) | 4624 | IrInstSrc *fn_type, IrInstSrc *arg_index, bool allow_var) |
| 3697 | { | 4625 | { |
| 3698 | IrInstructionArgType *instruction = ir_build_instruction<IrInstructionArgType>(irb, scope, source_node); | 4626 | IrInstSrcArgType *instruction = ir_build_instruction<IrInstSrcArgType>(irb, scope, source_node); |
| 3699 | instruction->fn_type = fn_type; | 4627 | instruction->fn_type = fn_type; |
| 3700 | instruction->arg_index = arg_index; | 4628 | instruction->arg_index = arg_index; |
| 3701 | instruction->allow_var = allow_var; | 4629 | instruction->allow_var = allow_var; |
| ... | @@ -3706,17 +4634,29 @@ static IrInstruction *ir_build_arg_type(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -3706,17 +4634,29 @@ static IrInstruction *ir_build_arg_type(IrBuilder *irb, Scope *scope, AstNode *s |
| 3706 | return &instruction->base; | 4634 | return &instruction->base; |
| 3707 | } | 4635 | } |
| 3708 | | 4636 | |
| 3709 | static IrInstruction *ir_build_error_return_trace(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstructionErrorReturnTrace::Optional optional) { | 4637 | static IrInstSrc *ir_build_error_return_trace_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3710 | IrInstructionErrorReturnTrace *instruction = ir_build_instruction<IrInstructionErrorReturnTrace>(irb, scope, source_node); | 4638 | IrInstErrorReturnTraceOptional optional) |
| 3711 | instruction->optional = optional; | 4639 | { |
| | 4640 | IrInstSrcErrorReturnTrace *inst = ir_build_instruction<IrInstSrcErrorReturnTrace>(irb, scope, source_node); |
| | 4641 | inst->optional = optional; |
| 3712 | | 4642 | |
| 3713 | return &instruction->base; | 4643 | return &inst->base; |
| | 4644 | } |
| | 4645 | |
| | 4646 | static IrInstGen *ir_build_error_return_trace_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, |
| | 4647 | IrInstErrorReturnTraceOptional optional, ZigType *result_type) |
| | 4648 | { |
| | 4649 | IrInstGenErrorReturnTrace *inst = ir_build_inst_gen<IrInstGenErrorReturnTrace>(&ira->new_irb, scope, source_node); |
| | 4650 | inst->base.value->type = result_type; |
| | 4651 | inst->optional = optional; |
| | 4652 | |
| | 4653 | return &inst->base; |
| 3714 | } | 4654 | } |
| 3715 | | 4655 | |
| 3716 | static IrInstruction *ir_build_error_union(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4656 | static IrInstSrc *ir_build_error_union(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3717 | IrInstruction *err_set, IrInstruction *payload) | 4657 | IrInstSrc *err_set, IrInstSrc *payload) |
| 3718 | { | 4658 | { |
| 3719 | IrInstructionErrorUnion *instruction = ir_build_instruction<IrInstructionErrorUnion>(irb, scope, source_node); | 4659 | IrInstSrcErrorUnion *instruction = ir_build_instruction<IrInstSrcErrorUnion>(irb, scope, source_node); |
| 3720 | instruction->err_set = err_set; | 4660 | instruction->err_set = err_set; |
| 3721 | instruction->payload = payload; | 4661 | instruction->payload = payload; |
| 3722 | | 4662 | |
| ... | @@ -3726,85 +4666,130 @@ static IrInstruction *ir_build_error_union(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3726,85 +4666,130 @@ static IrInstruction *ir_build_error_union(IrBuilder *irb, Scope *scope, AstNode |
| 3726 | return &instruction->base; | 4666 | return &instruction->base; |
| 3727 | } | 4667 | } |
| 3728 | | 4668 | |
| 3729 | static IrInstruction *ir_build_atomic_rmw(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4669 | static IrInstSrc *ir_build_atomic_rmw_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3730 | IrInstruction *operand_type, IrInstruction *ptr, IrInstruction *op, IrInstruction *operand, | 4670 | IrInstSrc *operand_type, IrInstSrc *ptr, IrInstSrc *op, IrInstSrc *operand, |
| 3731 | IrInstruction *ordering, AtomicRmwOp resolved_op, AtomicOrder resolved_ordering) | 4671 | IrInstSrc *ordering) |
| 3732 | { | 4672 | { |
| 3733 | IrInstructionAtomicRmw *instruction = ir_build_instruction<IrInstructionAtomicRmw>(irb, scope, source_node); | 4673 | IrInstSrcAtomicRmw *instruction = ir_build_instruction<IrInstSrcAtomicRmw>(irb, scope, source_node); |
| 3734 | instruction->operand_type = operand_type; | 4674 | instruction->operand_type = operand_type; |
| 3735 | instruction->ptr = ptr; | 4675 | instruction->ptr = ptr; |
| 3736 | instruction->op = op; | 4676 | instruction->op = op; |
| 3737 | instruction->operand = operand; | 4677 | instruction->operand = operand; |
| 3738 | instruction->ordering = ordering; | 4678 | instruction->ordering = ordering; |
| 3739 | instruction->resolved_op = resolved_op; | | |
| 3740 | instruction->resolved_ordering = resolved_ordering; | | |
| 3741 | | 4679 | |
| 3742 | if (operand_type != nullptr) ir_ref_instruction(operand_type, irb->current_basic_block); | 4680 | ir_ref_instruction(operand_type, irb->current_basic_block); |
| 3743 | ir_ref_instruction(ptr, irb->current_basic_block); | 4681 | ir_ref_instruction(ptr, irb->current_basic_block); |
| 3744 | if (op != nullptr) ir_ref_instruction(op, irb->current_basic_block); | 4682 | ir_ref_instruction(op, irb->current_basic_block); |
| 3745 | ir_ref_instruction(operand, irb->current_basic_block); | 4683 | ir_ref_instruction(operand, irb->current_basic_block); |
| 3746 | if (ordering != nullptr) ir_ref_instruction(ordering, irb->current_basic_block); | 4684 | ir_ref_instruction(ordering, irb->current_basic_block); |
| | 4685 | |
| | 4686 | return &instruction->base; |
| | 4687 | } |
| | 4688 | |
| | 4689 | static IrInstGen *ir_build_atomic_rmw_gen(IrAnalyze *ira, IrInst *source_instr, |
| | 4690 | IrInstGen *ptr, IrInstGen *operand, AtomicRmwOp op, AtomicOrder ordering, ZigType *operand_type) |
| | 4691 | { |
| | 4692 | IrInstGenAtomicRmw *instruction = ir_build_inst_gen<IrInstGenAtomicRmw>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| | 4693 | instruction->base.value->type = operand_type; |
| | 4694 | instruction->ptr = ptr; |
| | 4695 | instruction->op = op; |
| | 4696 | instruction->operand = operand; |
| | 4697 | instruction->ordering = ordering; |
| | 4698 | |
| | 4699 | ir_ref_inst_gen(ptr, ira->new_irb.current_basic_block); |
| | 4700 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 3747 | | 4701 | |
| 3748 | return &instruction->base; | 4702 | return &instruction->base; |
| 3749 | } | 4703 | } |
| 3750 | | 4704 | |
| 3751 | static IrInstruction *ir_build_atomic_load(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4705 | static IrInstSrc *ir_build_atomic_load_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3752 | IrInstruction *operand_type, IrInstruction *ptr, | 4706 | IrInstSrc *operand_type, IrInstSrc *ptr, IrInstSrc *ordering) |
| 3753 | IrInstruction *ordering, AtomicOrder resolved_ordering) | | |
| 3754 | { | 4707 | { |
| 3755 | IrInstructionAtomicLoad *instruction = ir_build_instruction<IrInstructionAtomicLoad>(irb, scope, source_node); | 4708 | IrInstSrcAtomicLoad *instruction = ir_build_instruction<IrInstSrcAtomicLoad>(irb, scope, source_node); |
| 3756 | instruction->operand_type = operand_type; | 4709 | instruction->operand_type = operand_type; |
| 3757 | instruction->ptr = ptr; | 4710 | instruction->ptr = ptr; |
| 3758 | instruction->ordering = ordering; | 4711 | instruction->ordering = ordering; |
| 3759 | instruction->resolved_ordering = resolved_ordering; | | |
| 3760 | | 4712 | |
| 3761 | if (operand_type != nullptr) ir_ref_instruction(operand_type, irb->current_basic_block); | 4713 | ir_ref_instruction(operand_type, irb->current_basic_block); |
| 3762 | ir_ref_instruction(ptr, irb->current_basic_block); | 4714 | ir_ref_instruction(ptr, irb->current_basic_block); |
| 3763 | if (ordering != nullptr) ir_ref_instruction(ordering, irb->current_basic_block); | 4715 | ir_ref_instruction(ordering, irb->current_basic_block); |
| | 4716 | |
| | 4717 | return &instruction->base; |
| | 4718 | } |
| | 4719 | |
| | 4720 | static IrInstGen *ir_build_atomic_load_gen(IrAnalyze *ira, IrInst *source_instr, |
| | 4721 | IrInstGen *ptr, AtomicOrder ordering, ZigType *operand_type) |
| | 4722 | { |
| | 4723 | IrInstGenAtomicLoad *instruction = ir_build_inst_gen<IrInstGenAtomicLoad>(&ira->new_irb, |
| | 4724 | source_instr->scope, source_instr->source_node); |
| | 4725 | instruction->base.value->type = operand_type; |
| | 4726 | instruction->ptr = ptr; |
| | 4727 | instruction->ordering = ordering; |
| | 4728 | |
| | 4729 | ir_ref_inst_gen(ptr, ira->new_irb.current_basic_block); |
| 3764 | | 4730 | |
| 3765 | return &instruction->base; | 4731 | return &instruction->base; |
| 3766 | } | 4732 | } |
| 3767 | | 4733 | |
| 3768 | static IrInstruction *ir_build_atomic_store(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4734 | static IrInstSrc *ir_build_atomic_store_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3769 | IrInstruction *operand_type, IrInstruction *ptr, IrInstruction *value, | 4735 | IrInstSrc *operand_type, IrInstSrc *ptr, IrInstSrc *value, IrInstSrc *ordering) |
| 3770 | IrInstruction *ordering, AtomicOrder resolved_ordering) | | |
| 3771 | { | 4736 | { |
| 3772 | IrInstructionAtomicStore *instruction = ir_build_instruction<IrInstructionAtomicStore>(irb, scope, source_node); | 4737 | IrInstSrcAtomicStore *instruction = ir_build_instruction<IrInstSrcAtomicStore>(irb, scope, source_node); |
| 3773 | instruction->operand_type = operand_type; | 4738 | instruction->operand_type = operand_type; |
| 3774 | instruction->ptr = ptr; | 4739 | instruction->ptr = ptr; |
| 3775 | instruction->value = value; | 4740 | instruction->value = value; |
| 3776 | instruction->ordering = ordering; | 4741 | instruction->ordering = ordering; |
| 3777 | instruction->resolved_ordering = resolved_ordering; | | |
| 3778 | | 4742 | |
| 3779 | if (operand_type != nullptr) ir_ref_instruction(operand_type, irb->current_basic_block); | 4743 | ir_ref_instruction(operand_type, irb->current_basic_block); |
| 3780 | ir_ref_instruction(ptr, irb->current_basic_block); | 4744 | ir_ref_instruction(ptr, irb->current_basic_block); |
| 3781 | ir_ref_instruction(value, irb->current_basic_block); | 4745 | ir_ref_instruction(value, irb->current_basic_block); |
| 3782 | if (ordering != nullptr) ir_ref_instruction(ordering, irb->current_basic_block); | 4746 | ir_ref_instruction(ordering, irb->current_basic_block); |
| 3783 | | 4747 | |
| 3784 | return &instruction->base; | 4748 | return &instruction->base; |
| 3785 | } | 4749 | } |
| 3786 | | 4750 | |
| 3787 | static IrInstruction *ir_build_save_err_ret_addr(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 4751 | static IrInstGen *ir_build_atomic_store_gen(IrAnalyze *ira, IrInst *source_instr, |
| 3788 | IrInstructionSaveErrRetAddr *instruction = ir_build_instruction<IrInstructionSaveErrRetAddr>(irb, scope, source_node); | 4752 | IrInstGen *ptr, IrInstGen *value, AtomicOrder ordering) |
| | 4753 | { |
| | 4754 | IrInstGenAtomicStore *instruction = ir_build_inst_void<IrInstGenAtomicStore>(&ira->new_irb, |
| | 4755 | source_instr->scope, source_instr->source_node); |
| | 4756 | instruction->ptr = ptr; |
| | 4757 | instruction->value = value; |
| | 4758 | instruction->ordering = ordering; |
| | 4759 | |
| | 4760 | ir_ref_inst_gen(ptr, ira->new_irb.current_basic_block); |
| | 4761 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| | 4762 | |
| 3789 | return &instruction->base; | 4763 | return &instruction->base; |
| 3790 | } | 4764 | } |
| 3791 | | 4765 | |
| 3792 | static IrInstruction *ir_build_add_implicit_return_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4766 | static IrInstSrc *ir_build_save_err_ret_addr_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 3793 | IrInstruction *value, ResultLocReturn *result_loc_ret) | 4767 | IrInstSrcSaveErrRetAddr *inst = ir_build_instruction<IrInstSrcSaveErrRetAddr>(irb, scope, source_node); |
| | 4768 | return &inst->base; |
| | 4769 | } |
| | 4770 | |
| | 4771 | static IrInstGen *ir_build_save_err_ret_addr_gen(IrAnalyze *ira, IrInst *source_instr) { |
| | 4772 | IrInstGenSaveErrRetAddr *inst = ir_build_inst_void<IrInstGenSaveErrRetAddr>(&ira->new_irb, |
| | 4773 | source_instr->scope, source_instr->source_node); |
| | 4774 | return &inst->base; |
| | 4775 | } |
| | 4776 | |
| | 4777 | static IrInstSrc *ir_build_add_implicit_return_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 4778 | IrInstSrc *value, ResultLocReturn *result_loc_ret) |
| 3794 | { | 4779 | { |
| 3795 | IrInstructionAddImplicitReturnType *instruction = ir_build_instruction<IrInstructionAddImplicitReturnType>(irb, scope, source_node); | 4780 | IrInstSrcAddImplicitReturnType *inst = ir_build_instruction<IrInstSrcAddImplicitReturnType>(irb, scope, source_node); |
| 3796 | instruction->value = value; | 4781 | inst->value = value; |
| 3797 | instruction->result_loc_ret = result_loc_ret; | 4782 | inst->result_loc_ret = result_loc_ret; |
| 3798 | | 4783 | |
| 3799 | ir_ref_instruction(value, irb->current_basic_block); | 4784 | ir_ref_instruction(value, irb->current_basic_block); |
| 3800 | | 4785 | |
| 3801 | return &instruction->base; | 4786 | return &inst->base; |
| 3802 | } | 4787 | } |
| 3803 | | 4788 | |
| 3804 | static IrInstruction *ir_build_has_decl(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4789 | static IrInstSrc *ir_build_has_decl(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3805 | IrInstruction *container, IrInstruction *name) | 4790 | IrInstSrc *container, IrInstSrc *name) |
| 3806 | { | 4791 | { |
| 3807 | IrInstructionHasDecl *instruction = ir_build_instruction<IrInstructionHasDecl>(irb, scope, source_node); | 4792 | IrInstSrcHasDecl *instruction = ir_build_instruction<IrInstSrcHasDecl>(irb, scope, source_node); |
| 3808 | instruction->container = container; | 4793 | instruction->container = container; |
| 3809 | instruction->name = name; | 4794 | instruction->name = name; |
| 3810 | | 4795 | |
| ... | @@ -3814,17 +4799,15 @@ static IrInstruction *ir_build_has_decl(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -3814,17 +4799,15 @@ static IrInstruction *ir_build_has_decl(IrBuilder *irb, Scope *scope, AstNode *s |
| 3814 | return &instruction->base; | 4799 | return &instruction->base; |
| 3815 | } | 4800 | } |
| 3816 | | 4801 | |
| 3817 | static IrInstruction *ir_build_undeclared_identifier(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4802 | static IrInstSrc *ir_build_undeclared_identifier(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, Buf *name) { |
| 3818 | Buf *name) | 4803 | IrInstSrcUndeclaredIdent *instruction = ir_build_instruction<IrInstSrcUndeclaredIdent>(irb, scope, source_node); |
| 3819 | { | | |
| 3820 | IrInstructionUndeclaredIdent *instruction = ir_build_instruction<IrInstructionUndeclaredIdent>(irb, scope, source_node); | | |
| 3821 | instruction->name = name; | 4804 | instruction->name = name; |
| 3822 | | 4805 | |
| 3823 | return &instruction->base; | 4806 | return &instruction->base; |
| 3824 | } | 4807 | } |
| 3825 | | 4808 | |
| 3826 | static IrInstruction *ir_build_check_runtime_scope(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *scope_is_comptime, IrInstruction *is_comptime) { | 4809 | static IrInstSrc *ir_build_check_runtime_scope(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *scope_is_comptime, IrInstSrc *is_comptime) { |
| 3827 | IrInstructionCheckRuntimeScope *instruction = ir_build_instruction<IrInstructionCheckRuntimeScope>(irb, scope, source_node); | 4810 | IrInstSrcCheckRuntimeScope *instruction = ir_build_instruction<IrInstSrcCheckRuntimeScope>(irb, scope, source_node); |
| 3828 | instruction->scope_is_comptime = scope_is_comptime; | 4811 | instruction->scope_is_comptime = scope_is_comptime; |
| 3829 | instruction->is_comptime = is_comptime; | 4812 | instruction->is_comptime = is_comptime; |
| 3830 | | 4813 | |
| ... | @@ -3834,10 +4817,10 @@ static IrInstruction *ir_build_check_runtime_scope(IrBuilder *irb, Scope *scope, | ... | @@ -3834,10 +4817,10 @@ static IrInstruction *ir_build_check_runtime_scope(IrBuilder *irb, Scope *scope, |
| 3834 | return &instruction->base; | 4817 | return &instruction->base; |
| 3835 | } | 4818 | } |
| 3836 | | 4819 | |
| 3837 | static IrInstruction *ir_build_union_init_named_field(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4820 | static IrInstSrc *ir_build_union_init_named_field(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3838 | IrInstruction *union_type, IrInstruction *field_name, IrInstruction *field_result_loc, IrInstruction *result_loc) | 4821 | IrInstSrc *union_type, IrInstSrc *field_name, IrInstSrc *field_result_loc, IrInstSrc *result_loc) |
| 3839 | { | 4822 | { |
| 3840 | IrInstructionUnionInitNamedField *instruction = ir_build_instruction<IrInstructionUnionInitNamedField>(irb, scope, source_node); | 4823 | IrInstSrcUnionInitNamedField *instruction = ir_build_instruction<IrInstSrcUnionInitNamedField>(irb, scope, source_node); |
| 3841 | instruction->union_type = union_type; | 4824 | instruction->union_type = union_type; |
| 3842 | instruction->field_name = field_name; | 4825 | instruction->field_name = field_name; |
| 3843 | instruction->field_result_loc = field_result_loc; | 4826 | instruction->field_result_loc = field_result_loc; |
| ... | @@ -3852,79 +4835,79 @@ static IrInstruction *ir_build_union_init_named_field(IrBuilder *irb, Scope *sco | ... | @@ -3852,79 +4835,79 @@ static IrInstruction *ir_build_union_init_named_field(IrBuilder *irb, Scope *sco |
| 3852 | } | 4835 | } |
| 3853 | | 4836 | |
| 3854 | | 4837 | |
| 3855 | static IrInstruction *ir_build_vector_to_array(IrAnalyze *ira, IrInstruction *source_instruction, | 4838 | static IrInstGen *ir_build_vector_to_array(IrAnalyze *ira, IrInst *source_instruction, |
| 3856 | ZigType *result_type, IrInstruction *vector, IrInstruction *result_loc) | 4839 | ZigType *result_type, IrInstGen *vector, IrInstGen *result_loc) |
| 3857 | { | 4840 | { |
| 3858 | IrInstructionVectorToArray *instruction = ir_build_instruction<IrInstructionVectorToArray>(&ira->new_irb, | 4841 | IrInstGenVectorToArray *instruction = ir_build_inst_gen<IrInstGenVectorToArray>(&ira->new_irb, |
| 3859 | source_instruction->scope, source_instruction->source_node); | 4842 | source_instruction->scope, source_instruction->source_node); |
| 3860 | instruction->base.value->type = result_type; | 4843 | instruction->base.value->type = result_type; |
| 3861 | instruction->vector = vector; | 4844 | instruction->vector = vector; |
| 3862 | instruction->result_loc = result_loc; | 4845 | instruction->result_loc = result_loc; |
| 3863 | | 4846 | |
| 3864 | ir_ref_instruction(vector, ira->new_irb.current_basic_block); | 4847 | ir_ref_inst_gen(vector, ira->new_irb.current_basic_block); |
| 3865 | ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 4848 | ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 3866 | | 4849 | |
| 3867 | return &instruction->base; | 4850 | return &instruction->base; |
| 3868 | } | 4851 | } |
| 3869 | | 4852 | |
| 3870 | static IrInstruction *ir_build_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruction *source_instruction, | 4853 | static IrInstGen *ir_build_ptr_of_array_to_slice(IrAnalyze *ira, IrInst *source_instruction, |
| 3871 | ZigType *result_type, IrInstruction *operand, IrInstruction *result_loc) | 4854 | ZigType *result_type, IrInstGen *operand, IrInstGen *result_loc) |
| 3872 | { | 4855 | { |
| 3873 | IrInstructionPtrOfArrayToSlice *instruction = ir_build_instruction<IrInstructionPtrOfArrayToSlice>(&ira->new_irb, | 4856 | IrInstGenPtrOfArrayToSlice *instruction = ir_build_inst_gen<IrInstGenPtrOfArrayToSlice>(&ira->new_irb, |
| 3874 | source_instruction->scope, source_instruction->source_node); | 4857 | source_instruction->scope, source_instruction->source_node); |
| 3875 | instruction->base.value->type = result_type; | 4858 | instruction->base.value->type = result_type; |
| 3876 | instruction->operand = operand; | 4859 | instruction->operand = operand; |
| 3877 | instruction->result_loc = result_loc; | 4860 | instruction->result_loc = result_loc; |
| 3878 | | 4861 | |
| 3879 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); | 4862 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 3880 | ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 4863 | ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 3881 | | 4864 | |
| 3882 | return &instruction->base; | 4865 | return &instruction->base; |
| 3883 | } | 4866 | } |
| 3884 | | 4867 | |
| 3885 | static IrInstruction *ir_build_array_to_vector(IrAnalyze *ira, IrInstruction *source_instruction, | 4868 | static IrInstGen *ir_build_array_to_vector(IrAnalyze *ira, IrInst *source_instruction, |
| 3886 | IrInstruction *array, ZigType *result_type) | 4869 | IrInstGen *array, ZigType *result_type) |
| 3887 | { | 4870 | { |
| 3888 | IrInstructionArrayToVector *instruction = ir_build_instruction<IrInstructionArrayToVector>(&ira->new_irb, | 4871 | IrInstGenArrayToVector *instruction = ir_build_inst_gen<IrInstGenArrayToVector>(&ira->new_irb, |
| 3889 | source_instruction->scope, source_instruction->source_node); | 4872 | source_instruction->scope, source_instruction->source_node); |
| 3890 | instruction->base.value->type = result_type; | 4873 | instruction->base.value->type = result_type; |
| 3891 | instruction->array = array; | 4874 | instruction->array = array; |
| 3892 | | 4875 | |
| 3893 | ir_ref_instruction(array, ira->new_irb.current_basic_block); | 4876 | ir_ref_inst_gen(array, ira->new_irb.current_basic_block); |
| 3894 | | 4877 | |
| 3895 | return &instruction->base; | 4878 | return &instruction->base; |
| 3896 | } | 4879 | } |
| 3897 | | 4880 | |
| 3898 | static IrInstruction *ir_build_assert_zero(IrAnalyze *ira, IrInstruction *source_instruction, | 4881 | static IrInstGen *ir_build_assert_zero(IrAnalyze *ira, IrInst *source_instruction, |
| 3899 | IrInstruction *target) | 4882 | IrInstGen *target) |
| 3900 | { | 4883 | { |
| 3901 | IrInstructionAssertZero *instruction = ir_build_instruction<IrInstructionAssertZero>(&ira->new_irb, | 4884 | IrInstGenAssertZero *instruction = ir_build_inst_gen<IrInstGenAssertZero>(&ira->new_irb, |
| 3902 | source_instruction->scope, source_instruction->source_node); | 4885 | source_instruction->scope, source_instruction->source_node); |
| 3903 | instruction->base.value->type = ira->codegen->builtin_types.entry_void; | 4886 | instruction->base.value->type = ira->codegen->builtin_types.entry_void; |
| 3904 | instruction->target = target; | 4887 | instruction->target = target; |
| 3905 | | 4888 | |
| 3906 | ir_ref_instruction(target, ira->new_irb.current_basic_block); | 4889 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| 3907 | | 4890 | |
| 3908 | return &instruction->base; | 4891 | return &instruction->base; |
| 3909 | } | 4892 | } |
| 3910 | | 4893 | |
| 3911 | static IrInstruction *ir_build_assert_non_null(IrAnalyze *ira, IrInstruction *source_instruction, | 4894 | static IrInstGen *ir_build_assert_non_null(IrAnalyze *ira, IrInst *source_instruction, |
| 3912 | IrInstruction *target) | 4895 | IrInstGen *target) |
| 3913 | { | 4896 | { |
| 3914 | IrInstructionAssertNonNull *instruction = ir_build_instruction<IrInstructionAssertNonNull>(&ira->new_irb, | 4897 | IrInstGenAssertNonNull *instruction = ir_build_inst_gen<IrInstGenAssertNonNull>(&ira->new_irb, |
| 3915 | source_instruction->scope, source_instruction->source_node); | 4898 | source_instruction->scope, source_instruction->source_node); |
| 3916 | instruction->base.value->type = ira->codegen->builtin_types.entry_void; | 4899 | instruction->base.value->type = ira->codegen->builtin_types.entry_void; |
| 3917 | instruction->target = target; | 4900 | instruction->target = target; |
| 3918 | | 4901 | |
| 3919 | ir_ref_instruction(target, ira->new_irb.current_basic_block); | 4902 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| 3920 | | 4903 | |
| 3921 | return &instruction->base; | 4904 | return &instruction->base; |
| 3922 | } | 4905 | } |
| 3923 | | 4906 | |
| 3924 | static IrInstruction *ir_build_alloca_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4907 | static IrInstSrc *ir_build_alloca_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3925 | IrInstruction *align, const char *name_hint, IrInstruction *is_comptime) | 4908 | IrInstSrc *align, const char *name_hint, IrInstSrc *is_comptime) |
| 3926 | { | 4909 | { |
| 3927 | IrInstructionAllocaSrc *instruction = ir_build_instruction<IrInstructionAllocaSrc>(irb, scope, source_node); | 4910 | IrInstSrcAlloca *instruction = ir_build_instruction<IrInstSrcAlloca>(irb, scope, source_node); |
| 3928 | instruction->base.is_gen = true; | 4911 | instruction->base.is_gen = true; |
| 3929 | instruction->align = align; | 4912 | instruction->align = align; |
| 3930 | instruction->name_hint = name_hint; | 4913 | instruction->name_hint = name_hint; |
| ... | @@ -3936,10 +4919,10 @@ static IrInstruction *ir_build_alloca_src(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3936,10 +4919,10 @@ static IrInstruction *ir_build_alloca_src(IrBuilder *irb, Scope *scope, AstNode |
| 3936 | return &instruction->base; | 4919 | return &instruction->base; |
| 3937 | } | 4920 | } |
| 3938 | | 4921 | |
| 3939 | static IrInstructionAllocaGen *ir_build_alloca_gen(IrAnalyze *ira, IrInstruction *source_instruction, | 4922 | static IrInstGenAlloca *ir_build_alloca_gen(IrAnalyze *ira, IrInst *source_instruction, |
| 3940 | uint32_t align, const char *name_hint) | 4923 | uint32_t align, const char *name_hint) |
| 3941 | { | 4924 | { |
| 3942 | IrInstructionAllocaGen *instruction = ir_create_instruction<IrInstructionAllocaGen>(&ira->new_irb, | 4925 | IrInstGenAlloca *instruction = ir_create_inst_gen<IrInstGenAlloca>(&ira->new_irb, |
| 3943 | source_instruction->scope, source_instruction->source_node); | 4926 | source_instruction->scope, source_instruction->source_node); |
| 3944 | instruction->align = align; | 4927 | instruction->align = align; |
| 3945 | instruction->name_hint = name_hint; | 4928 | instruction->name_hint = name_hint; |
| ... | @@ -3947,10 +4930,10 @@ static IrInstructionAllocaGen *ir_build_alloca_gen(IrAnalyze *ira, IrInstruction | ... | @@ -3947,10 +4930,10 @@ static IrInstructionAllocaGen *ir_build_alloca_gen(IrAnalyze *ira, IrInstruction |
| 3947 | return instruction; | 4930 | return instruction; |
| 3948 | } | 4931 | } |
| 3949 | | 4932 | |
| 3950 | static IrInstruction *ir_build_end_expr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4933 | static IrInstSrc *ir_build_end_expr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3951 | IrInstruction *value, ResultLoc *result_loc) | 4934 | IrInstSrc *value, ResultLoc *result_loc) |
| 3952 | { | 4935 | { |
| 3953 | IrInstructionEndExpr *instruction = ir_build_instruction<IrInstructionEndExpr>(irb, scope, source_node); | 4936 | IrInstSrcEndExpr *instruction = ir_build_instruction<IrInstSrcEndExpr>(irb, scope, source_node); |
| 3954 | instruction->base.is_gen = true; | 4937 | instruction->base.is_gen = true; |
| 3955 | instruction->value = value; | 4938 | instruction->value = value; |
| 3956 | instruction->result_loc = result_loc; | 4939 | instruction->result_loc = result_loc; |
| ... | @@ -3960,29 +4943,41 @@ static IrInstruction *ir_build_end_expr(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -3960,29 +4943,41 @@ static IrInstruction *ir_build_end_expr(IrBuilder *irb, Scope *scope, AstNode *s |
| 3960 | return &instruction->base; | 4943 | return &instruction->base; |
| 3961 | } | 4944 | } |
| 3962 | | 4945 | |
| 3963 | static IrInstructionSuspendBegin *ir_build_suspend_begin(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 4946 | static IrInstSrcSuspendBegin *ir_build_suspend_begin_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 3964 | IrInstructionSuspendBegin *instruction = ir_build_instruction<IrInstructionSuspendBegin>(irb, scope, source_node); | 4947 | return ir_build_instruction<IrInstSrcSuspendBegin>(irb, scope, source_node); |
| 3965 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; | 4948 | } |
| 3966 | | 4949 | |
| 3967 | return instruction; | 4950 | static IrInstGen *ir_build_suspend_begin_gen(IrAnalyze *ira, IrInst *source_instr) { |
| | 4951 | IrInstGenSuspendBegin *inst = ir_build_inst_void<IrInstGenSuspendBegin>(&ira->new_irb, |
| | 4952 | source_instr->scope, source_instr->source_node); |
| | 4953 | return &inst->base; |
| 3968 | } | 4954 | } |
| 3969 | | 4955 | |
| 3970 | static IrInstruction *ir_build_suspend_finish(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4956 | static IrInstSrc *ir_build_suspend_finish_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3971 | IrInstructionSuspendBegin *begin) | 4957 | IrInstSrcSuspendBegin *begin) |
| 3972 | { | 4958 | { |
| 3973 | IrInstructionSuspendFinish *instruction = ir_build_instruction<IrInstructionSuspendFinish>(irb, scope, source_node); | 4959 | IrInstSrcSuspendFinish *inst = ir_build_instruction<IrInstSrcSuspendFinish>(irb, scope, source_node); |
| 3974 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; | 4960 | inst->begin = begin; |
| 3975 | instruction->begin = begin; | | |
| 3976 | | 4961 | |
| 3977 | ir_ref_instruction(&begin->base, irb->current_basic_block); | 4962 | ir_ref_instruction(&begin->base, irb->current_basic_block); |
| 3978 | | 4963 | |
| 3979 | return &instruction->base; | 4964 | return &inst->base; |
| 3980 | } | 4965 | } |
| 3981 | | 4966 | |
| 3982 | static IrInstruction *ir_build_await_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4967 | static IrInstGen *ir_build_suspend_finish_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGenSuspendBegin *begin) { |
| 3983 | IrInstruction *frame, ResultLoc *result_loc) | 4968 | IrInstGenSuspendFinish *inst = ir_build_inst_void<IrInstGenSuspendFinish>(&ira->new_irb, |
| | 4969 | source_instr->scope, source_instr->source_node); |
| | 4970 | inst->begin = begin; |
| | 4971 | |
| | 4972 | ir_ref_inst_gen(&begin->base, ira->new_irb.current_basic_block); |
| | 4973 | |
| | 4974 | return &inst->base; |
| | 4975 | } |
| | 4976 | |
| | 4977 | static IrInstSrc *ir_build_await_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 4978 | IrInstSrc *frame, ResultLoc *result_loc) |
| 3984 | { | 4979 | { |
| 3985 | IrInstructionAwaitSrc *instruction = ir_build_instruction<IrInstructionAwaitSrc>(irb, scope, source_node); | 4980 | IrInstSrcAwait *instruction = ir_build_instruction<IrInstSrcAwait>(irb, scope, source_node); |
| 3986 | instruction->frame = frame; | 4981 | instruction->frame = frame; |
| 3987 | instruction->result_loc = result_loc; | 4982 | instruction->result_loc = result_loc; |
| 3988 | | 4983 | |
| ... | @@ -3991,24 +4986,23 @@ static IrInstruction *ir_build_await_src(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -3991,24 +4986,23 @@ static IrInstruction *ir_build_await_src(IrBuilder *irb, Scope *scope, AstNode * |
| 3991 | return &instruction->base; | 4986 | return &instruction->base; |
| 3992 | } | 4987 | } |
| 3993 | | 4988 | |
| 3994 | static IrInstructionAwaitGen *ir_build_await_gen(IrAnalyze *ira, IrInstruction *source_instruction, | 4989 | static IrInstGenAwait *ir_build_await_gen(IrAnalyze *ira, IrInst *source_instruction, |
| 3995 | IrInstruction *frame, ZigType *result_type, IrInstruction *result_loc) | 4990 | IrInstGen *frame, ZigType *result_type, IrInstGen *result_loc) |
| 3996 | { | 4991 | { |
| 3997 | IrInstructionAwaitGen *instruction = ir_build_instruction<IrInstructionAwaitGen>(&ira->new_irb, | 4992 | IrInstGenAwait *instruction = ir_build_inst_gen<IrInstGenAwait>(&ira->new_irb, |
| 3998 | source_instruction->scope, source_instruction->source_node); | 4993 | source_instruction->scope, source_instruction->source_node); |
| 3999 | instruction->base.value->type = result_type; | 4994 | instruction->base.value->type = result_type; |
| 4000 | instruction->frame = frame; | 4995 | instruction->frame = frame; |
| 4001 | instruction->result_loc = result_loc; | 4996 | instruction->result_loc = result_loc; |
| 4002 | | 4997 | |
| 4003 | ir_ref_instruction(frame, ira->new_irb.current_basic_block); | 4998 | ir_ref_inst_gen(frame, ira->new_irb.current_basic_block); |
| 4004 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 4999 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 4005 | | 5000 | |
| 4006 | return instruction; | 5001 | return instruction; |
| 4007 | } | 5002 | } |
| 4008 | | 5003 | |
| 4009 | static IrInstruction *ir_build_resume(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *frame) { | 5004 | static IrInstSrc *ir_build_resume_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *frame) { |
| 4010 | IrInstructionResume *instruction = ir_build_instruction<IrInstructionResume>(irb, scope, source_node); | 5005 | IrInstSrcResume *instruction = ir_build_instruction<IrInstSrcResume>(irb, scope, source_node); |
| 4011 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; | | |
| 4012 | instruction->frame = frame; | 5006 | instruction->frame = frame; |
| 4013 | | 5007 | |
| 4014 | ir_ref_instruction(frame, irb->current_basic_block); | 5008 | ir_ref_instruction(frame, irb->current_basic_block); |
| ... | @@ -4016,12 +5010,20 @@ static IrInstruction *ir_build_resume(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -4016,12 +5010,20 @@ static IrInstruction *ir_build_resume(IrBuilder *irb, Scope *scope, AstNode *sou |
| 4016 | return &instruction->base; | 5010 | return &instruction->base; |
| 4017 | } | 5011 | } |
| 4018 | | 5012 | |
| 4019 | static IrInstructionSpillBegin *ir_build_spill_begin(IrBuilder *irb, Scope *scope, AstNode *source_node, | 5013 | static IrInstGen *ir_build_resume_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *frame) { |
| 4020 | IrInstruction *operand, SpillId spill_id) | 5014 | IrInstGenResume *instruction = ir_build_inst_void<IrInstGenResume>(&ira->new_irb, |
| | 5015 | source_instr->scope, source_instr->source_node); |
| | 5016 | instruction->frame = frame; |
| | 5017 | |
| | 5018 | ir_ref_inst_gen(frame, ira->new_irb.current_basic_block); |
| | 5019 | |
| | 5020 | return &instruction->base; |
| | 5021 | } |
| | 5022 | |
| | 5023 | static IrInstSrcSpillBegin *ir_build_spill_begin_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 5024 | IrInstSrc *operand, SpillId spill_id) |
| 4021 | { | 5025 | { |
| 4022 | IrInstructionSpillBegin *instruction = ir_build_instruction<IrInstructionSpillBegin>(irb, scope, source_node); | 5026 | IrInstSrcSpillBegin *instruction = ir_build_instruction<IrInstSrcSpillBegin>(irb, scope, source_node); |
| 4023 | instruction->base.value->special = ConstValSpecialStatic; | | |
| 4024 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; | | |
| 4025 | instruction->operand = operand; | 5027 | instruction->operand = operand; |
| 4026 | instruction->spill_id = spill_id; | 5028 | instruction->spill_id = spill_id; |
| 4027 | | 5029 | |
| ... | @@ -4030,10 +5032,23 @@ static IrInstructionSpillBegin *ir_build_spill_begin(IrBuilder *irb, Scope *scop | ... | @@ -4030,10 +5032,23 @@ static IrInstructionSpillBegin *ir_build_spill_begin(IrBuilder *irb, Scope *scop |
| 4030 | return instruction; | 5032 | return instruction; |
| 4031 | } | 5033 | } |
| 4032 | | 5034 | |
| 4033 | static IrInstruction *ir_build_spill_end(IrBuilder *irb, Scope *scope, AstNode *source_node, | 5035 | static IrInstGen *ir_build_spill_begin_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *operand, |
| 4034 | IrInstructionSpillBegin *begin) | 5036 | SpillId spill_id) |
| | 5037 | { |
| | 5038 | IrInstGenSpillBegin *instruction = ir_build_inst_void<IrInstGenSpillBegin>(&ira->new_irb, |
| | 5039 | source_instr->scope, source_instr->source_node); |
| | 5040 | instruction->operand = operand; |
| | 5041 | instruction->spill_id = spill_id; |
| | 5042 | |
| | 5043 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| | 5044 | |
| | 5045 | return &instruction->base; |
| | 5046 | } |
| | 5047 | |
| | 5048 | static IrInstSrc *ir_build_spill_end_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 5049 | IrInstSrcSpillBegin *begin) |
| 4035 | { | 5050 | { |
| 4036 | IrInstructionSpillEnd *instruction = ir_build_instruction<IrInstructionSpillEnd>(irb, scope, source_node); | 5051 | IrInstSrcSpillEnd *instruction = ir_build_instruction<IrInstSrcSpillEnd>(irb, scope, source_node); |
| 4037 | instruction->begin = begin; | 5052 | instruction->begin = begin; |
| 4038 | | 5053 | |
| 4039 | ir_ref_instruction(&begin->base, irb->current_basic_block); | 5054 | ir_ref_instruction(&begin->base, irb->current_basic_block); |
| ... | @@ -4041,22 +5056,35 @@ static IrInstruction *ir_build_spill_end(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -4041,22 +5056,35 @@ static IrInstruction *ir_build_spill_end(IrBuilder *irb, Scope *scope, AstNode * |
| 4041 | return &instruction->base; | 5056 | return &instruction->base; |
| 4042 | } | 5057 | } |
| 4043 | | 5058 | |
| 4044 | static IrInstruction *ir_build_vector_extract_elem(IrAnalyze *ira, IrInstruction *source_instruction, | 5059 | static IrInstGen *ir_build_spill_end_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGenSpillBegin *begin, |
| 4045 | IrInstruction *vector, IrInstruction *index) | 5060 | ZigType *result_type) |
| | 5061 | { |
| | 5062 | IrInstGenSpillEnd *instruction = ir_build_inst_gen<IrInstGenSpillEnd>(&ira->new_irb, |
| | 5063 | source_instr->scope, source_instr->source_node); |
| | 5064 | instruction->base.value->type = result_type; |
| | 5065 | instruction->begin = begin; |
| | 5066 | |
| | 5067 | ir_ref_inst_gen(&begin->base, ira->new_irb.current_basic_block); |
| | 5068 | |
| | 5069 | return &instruction->base; |
| | 5070 | } |
| | 5071 | |
| | 5072 | static IrInstGen *ir_build_vector_extract_elem(IrAnalyze *ira, IrInst *source_instruction, |
| | 5073 | IrInstGen *vector, IrInstGen *index) |
| 4046 | { | 5074 | { |
| 4047 | IrInstructionVectorExtractElem *instruction = ir_build_instruction<IrInstructionVectorExtractElem>( | 5075 | IrInstGenVectorExtractElem *instruction = ir_build_inst_gen<IrInstGenVectorExtractElem>( |
| 4048 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 5076 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 4049 | instruction->base.value->type = vector->value->type->data.vector.elem_type; | 5077 | instruction->base.value->type = vector->value->type->data.vector.elem_type; |
| 4050 | instruction->vector = vector; | 5078 | instruction->vector = vector; |
| 4051 | instruction->index = index; | 5079 | instruction->index = index; |
| 4052 | | 5080 | |
| 4053 | ir_ref_instruction(vector, ira->new_irb.current_basic_block); | 5081 | ir_ref_inst_gen(vector, ira->new_irb.current_basic_block); |
| 4054 | ir_ref_instruction(index, ira->new_irb.current_basic_block); | 5082 | ir_ref_inst_gen(index, ira->new_irb.current_basic_block); |
| 4055 | | 5083 | |
| 4056 | return &instruction->base; | 5084 | return &instruction->base; |
| 4057 | } | 5085 | } |
| 4058 | | 5086 | |
| 4059 | static void ir_count_defers(IrBuilder *irb, Scope *inner_scope, Scope *outer_scope, size_t *results) { | 5087 | static void ir_count_defers(IrBuilderSrc *irb, Scope *inner_scope, Scope *outer_scope, size_t *results) { |
| 4060 | results[ReturnKindUnconditional] = 0; | 5088 | results[ReturnKindUnconditional] = 0; |
| 4061 | results[ReturnKindError] = 0; | 5089 | results[ReturnKindError] = 0; |
| 4062 | | 5090 | |
| ... | @@ -4093,12 +5121,12 @@ static void ir_count_defers(IrBuilder *irb, Scope *inner_scope, Scope *outer_sco | ... | @@ -4093,12 +5121,12 @@ static void ir_count_defers(IrBuilder *irb, Scope *inner_scope, Scope *outer_sco |
| 4093 | } | 5121 | } |
| 4094 | } | 5122 | } |
| 4095 | | 5123 | |
| 4096 | static IrInstruction *ir_mark_gen(IrInstruction *instruction) { | 5124 | static IrInstSrc *ir_mark_gen(IrInstSrc *instruction) { |
| 4097 | instruction->is_gen = true; | 5125 | instruction->is_gen = true; |
| 4098 | return instruction; | 5126 | return instruction; |
| 4099 | } | 5127 | } |
| 4100 | | 5128 | |
| 4101 | static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *outer_scope, bool gen_error_defers) { | 5129 | static bool ir_gen_defers_for_block(IrBuilderSrc *irb, Scope *inner_scope, Scope *outer_scope, bool gen_error_defers) { |
| 4102 | Scope *scope = inner_scope; | 5130 | Scope *scope = inner_scope; |
| 4103 | bool is_noreturn = false; | 5131 | bool is_noreturn = false; |
| 4104 | while (scope != outer_scope) { | 5132 | while (scope != outer_scope) { |
| ... | @@ -4115,11 +5143,9 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o | ... | @@ -4115,11 +5143,9 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o |
| 4115 | { | 5143 | { |
| 4116 | AstNode *defer_expr_node = defer_node->data.defer.expr; | 5144 | AstNode *defer_expr_node = defer_node->data.defer.expr; |
| 4117 | Scope *defer_expr_scope = defer_node->data.defer.expr_scope; | 5145 | Scope *defer_expr_scope = defer_node->data.defer.expr_scope; |
| 4118 | IrInstruction *defer_expr_value = ir_gen_node(irb, defer_expr_node, defer_expr_scope); | 5146 | IrInstSrc *defer_expr_value = ir_gen_node(irb, defer_expr_node, defer_expr_scope); |
| 4119 | if (defer_expr_value != irb->codegen->invalid_instruction) { | 5147 | if (defer_expr_value != irb->codegen->invalid_inst_src) { |
| 4120 | if (defer_expr_value->value->type != nullptr && | 5148 | if (defer_expr_value->is_noreturn) { |
| 4121 | defer_expr_value->value->type->id == ZigTypeIdUnreachable) | | |
| 4122 | { | | |
| 4123 | is_noreturn = true; | 5149 | is_noreturn = true; |
| 4124 | } else { | 5150 | } else { |
| 4125 | ir_mark_gen(ir_build_check_statement_is_void(irb, defer_expr_scope, defer_expr_node, | 5151 | ir_mark_gen(ir_build_check_statement_is_void(irb, defer_expr_scope, defer_expr_node, |
| ... | @@ -4151,13 +5177,17 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o | ... | @@ -4151,13 +5177,17 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o |
| 4151 | return is_noreturn; | 5177 | return is_noreturn; |
| 4152 | } | 5178 | } |
| 4153 | | 5179 | |
| 4154 | static void ir_set_cursor_at_end(IrBuilder *irb, IrBasicBlock *basic_block) { | 5180 | static void ir_set_cursor_at_end_gen(IrBuilderGen *irb, IrBasicBlockGen *basic_block) { |
| 4155 | assert(basic_block); | 5181 | assert(basic_block); |
| | 5182 | irb->current_basic_block = basic_block; |
| | 5183 | } |
| 4156 | | 5184 | |
| | 5185 | static void ir_set_cursor_at_end(IrBuilderSrc *irb, IrBasicBlockSrc *basic_block) { |
| | 5186 | assert(basic_block); |
| 4157 | irb->current_basic_block = basic_block; | 5187 | irb->current_basic_block = basic_block; |
| 4158 | } | 5188 | } |
| 4159 | | 5189 | |
| 4160 | static void ir_set_cursor_at_end_and_append_block(IrBuilder *irb, IrBasicBlock *basic_block) { | 5190 | static void ir_set_cursor_at_end_and_append_block(IrBuilderSrc *irb, IrBasicBlockSrc *basic_block) { |
| 4161 | basic_block->index = irb->exec->basic_block_list.length; | 5191 | basic_block->index = irb->exec->basic_block_list.length; |
| 4162 | irb->exec->basic_block_list.append(basic_block); | 5192 | irb->exec->basic_block_list.append(basic_block); |
| 4163 | ir_set_cursor_at_end(irb, basic_block); | 5193 | ir_set_cursor_at_end(irb, basic_block); |
| ... | @@ -4187,7 +5217,7 @@ static ScopeDeferExpr *get_scope_defer_expr(Scope *scope) { | ... | @@ -4187,7 +5217,7 @@ static ScopeDeferExpr *get_scope_defer_expr(Scope *scope) { |
| 4187 | return nullptr; | 5217 | return nullptr; |
| 4188 | } | 5218 | } |
| 4189 | | 5219 | |
| 4190 | static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { | 5220 | static IrInstSrc *ir_gen_return(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { |
| 4191 | assert(node->type == NodeTypeReturnExpr); | 5221 | assert(node->type == NodeTypeReturnExpr); |
| 4192 | | 5222 | |
| 4193 | ScopeDeferExpr *scope_defer_expr = get_scope_defer_expr(scope); | 5223 | ScopeDeferExpr *scope_defer_expr = get_scope_defer_expr(scope); |
| ... | @@ -4196,7 +5226,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4196,7 +5226,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4196 | add_node_error(irb->codegen, node, buf_sprintf("cannot return from defer expression")); | 5226 | add_node_error(irb->codegen, node, buf_sprintf("cannot return from defer expression")); |
| 4197 | scope_defer_expr->reported_err = true; | 5227 | scope_defer_expr->reported_err = true; |
| 4198 | } | 5228 | } |
| 4199 | return irb->codegen->invalid_instruction; | 5229 | return irb->codegen->invalid_inst_src; |
| 4200 | } | 5230 | } |
| 4201 | | 5231 | |
| 4202 | Scope *outer_scope = irb->exec->begin_scope; | 5232 | Scope *outer_scope = irb->exec->begin_scope; |
| ... | @@ -4209,15 +5239,15 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4209,15 +5239,15 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4209 | result_loc_ret->base.id = ResultLocIdReturn; | 5239 | result_loc_ret->base.id = ResultLocIdReturn; |
| 4210 | ir_build_reset_result(irb, scope, node, &result_loc_ret->base); | 5240 | ir_build_reset_result(irb, scope, node, &result_loc_ret->base); |
| 4211 | | 5241 | |
| 4212 | IrInstruction *return_value; | 5242 | IrInstSrc *return_value; |
| 4213 | if (expr_node) { | 5243 | if (expr_node) { |
| 4214 | // Temporarily set this so that if we return a type it gets the name of the function | 5244 | // Temporarily set this so that if we return a type it gets the name of the function |
| 4215 | ZigFn *prev_name_fn = irb->exec->name_fn; | 5245 | ZigFn *prev_name_fn = irb->exec->name_fn; |
| 4216 | irb->exec->name_fn = exec_fn_entry(irb->exec); | 5246 | irb->exec->name_fn = exec_fn_entry(irb->exec); |
| 4217 | return_value = ir_gen_node_extra(irb, expr_node, scope, LValNone, &result_loc_ret->base); | 5247 | return_value = ir_gen_node_extra(irb, expr_node, scope, LValNone, &result_loc_ret->base); |
| 4218 | irb->exec->name_fn = prev_name_fn; | 5248 | irb->exec->name_fn = prev_name_fn; |
| 4219 | if (return_value == irb->codegen->invalid_instruction) | 5249 | if (return_value == irb->codegen->invalid_inst_src) |
| 4220 | return irb->codegen->invalid_instruction; | 5250 | return irb->codegen->invalid_inst_src; |
| 4221 | } else { | 5251 | } else { |
| 4222 | return_value = ir_build_const_void(irb, scope, node); | 5252 | return_value = ir_build_const_void(irb, scope, node); |
| 4223 | } | 5253 | } |
| ... | @@ -4230,22 +5260,22 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4230,22 +5260,22 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4230 | if (!have_err_defers && !irb->codegen->have_err_ret_tracing) { | 5260 | if (!have_err_defers && !irb->codegen->have_err_ret_tracing) { |
| 4231 | // only generate unconditional defers | 5261 | // only generate unconditional defers |
| 4232 | ir_gen_defers_for_block(irb, scope, outer_scope, false); | 5262 | ir_gen_defers_for_block(irb, scope, outer_scope, false); |
| 4233 | IrInstruction *result = ir_build_return(irb, scope, node, return_value); | 5263 | IrInstSrc *result = ir_build_return_src(irb, scope, node, return_value); |
| 4234 | result_loc_ret->base.source_instruction = result; | 5264 | result_loc_ret->base.source_instruction = result; |
| 4235 | return result; | 5265 | return result; |
| 4236 | } | 5266 | } |
| 4237 | bool should_inline = ir_should_inline(irb->exec, scope); | 5267 | bool should_inline = ir_should_inline(irb->exec, scope); |
| 4238 | | 5268 | |
| 4239 | IrBasicBlock *err_block = ir_create_basic_block(irb, scope, "ErrRetErr"); | 5269 | IrBasicBlockSrc *err_block = ir_create_basic_block(irb, scope, "ErrRetErr"); |
| 4240 | IrBasicBlock *ok_block = ir_create_basic_block(irb, scope, "ErrRetOk"); | 5270 | IrBasicBlockSrc *ok_block = ir_create_basic_block(irb, scope, "ErrRetOk"); |
| 4241 | | 5271 | |
| 4242 | if (!have_err_defers) { | 5272 | if (!have_err_defers) { |
| 4243 | ir_gen_defers_for_block(irb, scope, outer_scope, false); | 5273 | ir_gen_defers_for_block(irb, scope, outer_scope, false); |
| 4244 | } | 5274 | } |
| 4245 | | 5275 | |
| 4246 | IrInstruction *is_err = ir_build_test_err_src(irb, scope, node, return_value, false, true); | 5276 | IrInstSrc *is_err = ir_build_test_err_src(irb, scope, node, return_value, false, true); |
| 4247 | | 5277 | |
| 4248 | IrInstruction *is_comptime; | 5278 | IrInstSrc *is_comptime; |
| 4249 | if (should_inline) { | 5279 | if (should_inline) { |
| 4250 | is_comptime = ir_build_const_bool(irb, scope, node, should_inline); | 5280 | is_comptime = ir_build_const_bool(irb, scope, node, should_inline); |
| 4251 | } else { | 5281 | } else { |
| ... | @@ -4253,14 +5283,14 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4253,14 +5283,14 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4253 | } | 5283 | } |
| 4254 | | 5284 | |
| 4255 | ir_mark_gen(ir_build_cond_br(irb, scope, node, is_err, err_block, ok_block, is_comptime)); | 5285 | ir_mark_gen(ir_build_cond_br(irb, scope, node, is_err, err_block, ok_block, is_comptime)); |
| 4256 | IrBasicBlock *ret_stmt_block = ir_create_basic_block(irb, scope, "RetStmt"); | 5286 | IrBasicBlockSrc *ret_stmt_block = ir_create_basic_block(irb, scope, "RetStmt"); |
| 4257 | | 5287 | |
| 4258 | ir_set_cursor_at_end_and_append_block(irb, err_block); | 5288 | ir_set_cursor_at_end_and_append_block(irb, err_block); |
| 4259 | if (have_err_defers) { | 5289 | if (have_err_defers) { |
| 4260 | ir_gen_defers_for_block(irb, scope, outer_scope, true); | 5290 | ir_gen_defers_for_block(irb, scope, outer_scope, true); |
| 4261 | } | 5291 | } |
| 4262 | if (irb->codegen->have_err_ret_tracing && !should_inline) { | 5292 | if (irb->codegen->have_err_ret_tracing && !should_inline) { |
| 4263 | ir_build_save_err_ret_addr(irb, scope, node); | 5293 | ir_build_save_err_ret_addr_src(irb, scope, node); |
| 4264 | } | 5294 | } |
| 4265 | ir_build_br(irb, scope, node, ret_stmt_block, is_comptime); | 5295 | ir_build_br(irb, scope, node, ret_stmt_block, is_comptime); |
| 4266 | | 5296 | |
| ... | @@ -4271,21 +5301,21 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4271,21 +5301,21 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4271 | ir_build_br(irb, scope, node, ret_stmt_block, is_comptime); | 5301 | ir_build_br(irb, scope, node, ret_stmt_block, is_comptime); |
| 4272 | | 5302 | |
| 4273 | ir_set_cursor_at_end_and_append_block(irb, ret_stmt_block); | 5303 | ir_set_cursor_at_end_and_append_block(irb, ret_stmt_block); |
| 4274 | IrInstruction *result = ir_build_return(irb, scope, node, return_value); | 5304 | IrInstSrc *result = ir_build_return_src(irb, scope, node, return_value); |
| 4275 | result_loc_ret->base.source_instruction = result; | 5305 | result_loc_ret->base.source_instruction = result; |
| 4276 | return result; | 5306 | return result; |
| 4277 | } | 5307 | } |
| 4278 | case ReturnKindError: | 5308 | case ReturnKindError: |
| 4279 | { | 5309 | { |
| 4280 | assert(expr_node); | 5310 | assert(expr_node); |
| 4281 | IrInstruction *err_union_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); | 5311 | IrInstSrc *err_union_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); |
| 4282 | if (err_union_ptr == irb->codegen->invalid_instruction) | 5312 | if (err_union_ptr == irb->codegen->invalid_inst_src) |
| 4283 | return irb->codegen->invalid_instruction; | 5313 | return irb->codegen->invalid_inst_src; |
| 4284 | IrInstruction *is_err_val = ir_build_test_err_src(irb, scope, node, err_union_ptr, true, false); | 5314 | IrInstSrc *is_err_val = ir_build_test_err_src(irb, scope, node, err_union_ptr, true, false); |
| 4285 | | 5315 | |
| 4286 | IrBasicBlock *return_block = ir_create_basic_block(irb, scope, "ErrRetReturn"); | 5316 | IrBasicBlockSrc *return_block = ir_create_basic_block(irb, scope, "ErrRetReturn"); |
| 4287 | IrBasicBlock *continue_block = ir_create_basic_block(irb, scope, "ErrRetContinue"); | 5317 | IrBasicBlockSrc *continue_block = ir_create_basic_block(irb, scope, "ErrRetContinue"); |
| 4288 | IrInstruction *is_comptime; | 5318 | IrInstSrc *is_comptime; |
| 4289 | bool should_inline = ir_should_inline(irb->exec, scope); | 5319 | bool should_inline = ir_should_inline(irb->exec, scope); |
| 4290 | if (should_inline) { | 5320 | if (should_inline) { |
| 4291 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 5321 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| ... | @@ -4295,10 +5325,10 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4295,10 +5325,10 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4295 | ir_mark_gen(ir_build_cond_br(irb, scope, node, is_err_val, return_block, continue_block, is_comptime)); | 5325 | ir_mark_gen(ir_build_cond_br(irb, scope, node, is_err_val, return_block, continue_block, is_comptime)); |
| 4296 | | 5326 | |
| 4297 | ir_set_cursor_at_end_and_append_block(irb, return_block); | 5327 | ir_set_cursor_at_end_and_append_block(irb, return_block); |
| 4298 | IrInstruction *err_val_ptr = ir_build_unwrap_err_code(irb, scope, node, err_union_ptr); | 5328 | IrInstSrc *err_val_ptr = ir_build_unwrap_err_code_src(irb, scope, node, err_union_ptr); |
| 4299 | IrInstruction *err_val = ir_build_load_ptr(irb, scope, node, err_val_ptr); | 5329 | IrInstSrc *err_val = ir_build_load_ptr(irb, scope, node, err_val_ptr); |
| 4300 | ir_mark_gen(ir_build_add_implicit_return_type(irb, scope, node, err_val, nullptr)); | 5330 | ir_mark_gen(ir_build_add_implicit_return_type(irb, scope, node, err_val, nullptr)); |
| 4301 | IrInstructionSpillBegin *spill_begin = ir_build_spill_begin(irb, scope, node, err_val, | 5331 | IrInstSrcSpillBegin *spill_begin = ir_build_spill_begin_src(irb, scope, node, err_val, |
| 4302 | SpillIdRetErrCode); | 5332 | SpillIdRetErrCode); |
| 4303 | ResultLocReturn *result_loc_ret = allocate<ResultLocReturn>(1, "ResultLocReturn"); | 5333 | ResultLocReturn *result_loc_ret = allocate<ResultLocReturn>(1, "ResultLocReturn"); |
| 4304 | result_loc_ret->base.id = ResultLocIdReturn; | 5334 | result_loc_ret->base.id = ResultLocIdReturn; |
| ... | @@ -4306,15 +5336,15 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4306,15 +5336,15 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4306 | ir_build_end_expr(irb, scope, node, err_val, &result_loc_ret->base); | 5336 | ir_build_end_expr(irb, scope, node, err_val, &result_loc_ret->base); |
| 4307 | if (!ir_gen_defers_for_block(irb, scope, outer_scope, true)) { | 5337 | if (!ir_gen_defers_for_block(irb, scope, outer_scope, true)) { |
| 4308 | if (irb->codegen->have_err_ret_tracing && !should_inline) { | 5338 | if (irb->codegen->have_err_ret_tracing && !should_inline) { |
| 4309 | ir_build_save_err_ret_addr(irb, scope, node); | 5339 | ir_build_save_err_ret_addr_src(irb, scope, node); |
| 4310 | } | 5340 | } |
| 4311 | err_val = ir_build_spill_end(irb, scope, node, spill_begin); | 5341 | err_val = ir_build_spill_end_src(irb, scope, node, spill_begin); |
| 4312 | IrInstruction *ret_inst = ir_build_return(irb, scope, node, err_val); | 5342 | IrInstSrc *ret_inst = ir_build_return_src(irb, scope, node, err_val); |
| 4313 | result_loc_ret->base.source_instruction = ret_inst; | 5343 | result_loc_ret->base.source_instruction = ret_inst; |
| 4314 | } | 5344 | } |
| 4315 | | 5345 | |
| 4316 | ir_set_cursor_at_end_and_append_block(irb, continue_block); | 5346 | ir_set_cursor_at_end_and_append_block(irb, continue_block); |
| 4317 | IrInstruction *unwrapped_ptr = ir_build_unwrap_err_payload(irb, scope, node, err_union_ptr, false, false); | 5347 | IrInstSrc *unwrapped_ptr = ir_build_unwrap_err_payload_src(irb, scope, node, err_union_ptr, false, false); |
| 4318 | if (lval == LValPtr) | 5348 | if (lval == LValPtr) |
| 4319 | return unwrapped_ptr; | 5349 | return unwrapped_ptr; |
| 4320 | else | 5350 | else |
| ... | @@ -4325,7 +5355,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4325,7 +5355,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4325 | } | 5355 | } |
| 4326 | | 5356 | |
| 4327 | static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_scope, | 5357 | static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_scope, |
| 4328 | Buf *name, bool src_is_const, bool gen_is_const, bool is_shadowable, IrInstruction *is_comptime, | 5358 | Buf *name, bool src_is_const, bool gen_is_const, bool is_shadowable, IrInstSrc *is_comptime, |
| 4329 | bool skip_name_check) | 5359 | bool skip_name_check) |
| 4330 | { | 5360 | { |
| 4331 | ZigVar *variable_entry = allocate<ZigVar>(1, "ZigVar"); | 5361 | ZigVar *variable_entry = allocate<ZigVar>(1, "ZigVar"); |
| ... | @@ -4336,7 +5366,7 @@ static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_s | ... | @@ -4336,7 +5366,7 @@ static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_s |
| 4336 | variable_entry->const_value = create_const_vals(1); | 5366 | variable_entry->const_value = create_const_vals(1); |
| 4337 | | 5367 | |
| 4338 | if (is_comptime != nullptr) { | 5368 | if (is_comptime != nullptr) { |
| 4339 | is_comptime->ref_count += 1; | 5369 | is_comptime->base.ref_count += 1; |
| 4340 | } | 5370 | } |
| 4341 | | 5371 | |
| 4342 | if (name) { | 5372 | if (name) { |
| ... | @@ -4386,8 +5416,8 @@ static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_s | ... | @@ -4386,8 +5416,8 @@ static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_s |
| 4386 | | 5416 | |
| 4387 | // Set name to nullptr to make the variable anonymous (not visible to programmer). | 5417 | // Set name to nullptr to make the variable anonymous (not visible to programmer). |
| 4388 | // After you call this function var->child_scope has the variable in scope | 5418 | // After you call this function var->child_scope has the variable in scope |
| 4389 | static ZigVar *ir_create_var(IrBuilder *irb, AstNode *node, Scope *scope, Buf *name, | 5419 | static ZigVar *ir_create_var(IrBuilderSrc *irb, AstNode *node, Scope *scope, Buf *name, |
| 4390 | bool src_is_const, bool gen_is_const, bool is_shadowable, IrInstruction *is_comptime) | 5420 | bool src_is_const, bool gen_is_const, bool is_shadowable, IrInstSrc *is_comptime) |
| 4391 | { | 5421 | { |
| 4392 | bool is_underscored = name ? buf_eql_str(name, "_") : false; | 5422 | bool is_underscored = name ? buf_eql_str(name, "_") : false; |
| 4393 | ZigVar *var = create_local_var(irb->codegen, node, scope, | 5423 | ZigVar *var = create_local_var(irb->codegen, node, scope, |
| ... | @@ -4409,13 +5439,13 @@ static ResultLocPeer *create_peer_result(ResultLocPeerParent *peer_parent) { | ... | @@ -4409,13 +5439,13 @@ static ResultLocPeer *create_peer_result(ResultLocPeerParent *peer_parent) { |
| 4409 | return result; | 5439 | return result; |
| 4410 | } | 5440 | } |
| 4411 | | 5441 | |
| 4412 | static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode *block_node, LVal lval, | 5442 | static IrInstSrc *ir_gen_block(IrBuilderSrc *irb, Scope *parent_scope, AstNode *block_node, LVal lval, |
| 4413 | ResultLoc *result_loc) | 5443 | ResultLoc *result_loc) |
| 4414 | { | 5444 | { |
| 4415 | assert(block_node->type == NodeTypeBlock); | 5445 | assert(block_node->type == NodeTypeBlock); |
| 4416 | | 5446 | |
| 4417 | ZigList<IrInstruction *> incoming_values = {0}; | 5447 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 4418 | ZigList<IrBasicBlock *> incoming_blocks = {0}; | 5448 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; |
| 4419 | | 5449 | |
| 4420 | ScopeBlock *scope_block = create_block_scope(irb->codegen, block_node, parent_scope); | 5450 | ScopeBlock *scope_block = create_block_scope(irb->codegen, block_node, parent_scope); |
| 4421 | | 5451 | |
| ... | @@ -4451,11 +5481,11 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -4451,11 +5481,11 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode |
| 4451 | } | 5481 | } |
| 4452 | | 5482 | |
| 4453 | bool is_continuation_unreachable = false; | 5483 | bool is_continuation_unreachable = false; |
| 4454 | IrInstruction *noreturn_return_value = nullptr; | 5484 | IrInstSrc *noreturn_return_value = nullptr; |
| 4455 | for (size_t i = 0; i < block_node->data.block.statements.length; i += 1) { | 5485 | for (size_t i = 0; i < block_node->data.block.statements.length; i += 1) { |
| 4456 | AstNode *statement_node = block_node->data.block.statements.at(i); | 5486 | AstNode *statement_node = block_node->data.block.statements.at(i); |
| 4457 | | 5487 | |
| 4458 | IrInstruction *statement_value = ir_gen_node(irb, statement_node, child_scope); | 5488 | IrInstSrc *statement_value = ir_gen_node(irb, statement_node, child_scope); |
| 4459 | is_continuation_unreachable = instr_is_unreachable(statement_value); | 5489 | is_continuation_unreachable = instr_is_unreachable(statement_value); |
| 4460 | if (is_continuation_unreachable) { | 5490 | if (is_continuation_unreachable) { |
| 4461 | // keep the last noreturn statement value around in case we need to return it | 5491 | // keep the last noreturn statement value around in case we need to return it |
| ... | @@ -4463,15 +5493,15 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -4463,15 +5493,15 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode |
| 4463 | } | 5493 | } |
| 4464 | // This logic must be kept in sync with | 5494 | // This logic must be kept in sync with |
| 4465 | // [STMT_EXPR_TEST_THING] <--- (search this token) | 5495 | // [STMT_EXPR_TEST_THING] <--- (search this token) |
| 4466 | if (statement_node->type == NodeTypeDefer && statement_value != irb->codegen->invalid_instruction) { | 5496 | if (statement_node->type == NodeTypeDefer && statement_value != irb->codegen->invalid_inst_src) { |
| 4467 | // defer starts a new scope | 5497 | // defer starts a new scope |
| 4468 | child_scope = statement_node->data.defer.child_scope; | 5498 | child_scope = statement_node->data.defer.child_scope; |
| 4469 | assert(child_scope); | 5499 | assert(child_scope); |
| 4470 | } else if (statement_value->id == IrInstructionIdDeclVarSrc) { | 5500 | } else if (statement_value->id == IrInstSrcIdDeclVar) { |
| 4471 | // variable declarations start a new scope | 5501 | // variable declarations start a new scope |
| 4472 | IrInstructionDeclVarSrc *decl_var_instruction = (IrInstructionDeclVarSrc *)statement_value; | 5502 | IrInstSrcDeclVar *decl_var_instruction = (IrInstSrcDeclVar *)statement_value; |
| 4473 | child_scope = decl_var_instruction->var->child_scope; | 5503 | child_scope = decl_var_instruction->var->child_scope; |
| 4474 | } else if (statement_value != irb->codegen->invalid_instruction && !is_continuation_unreachable) { | 5504 | } else if (statement_value != irb->codegen->invalid_inst_src && !is_continuation_unreachable) { |
| 4475 | // this statement's value must be void | 5505 | // this statement's value must be void |
| 4476 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, statement_node, statement_value)); | 5506 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, statement_node, statement_value)); |
| 4477 | } | 5507 | } |
| ... | @@ -4487,12 +5517,12 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -4487,12 +5517,12 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode |
| 4487 | scope_block->peer_parent->peers.last()->next_bb = scope_block->end_block; | 5517 | scope_block->peer_parent->peers.last()->next_bb = scope_block->end_block; |
| 4488 | } | 5518 | } |
| 4489 | ir_set_cursor_at_end_and_append_block(irb, scope_block->end_block); | 5519 | ir_set_cursor_at_end_and_append_block(irb, scope_block->end_block); |
| 4490 | IrInstruction *phi = ir_build_phi(irb, parent_scope, block_node, incoming_blocks.length, | 5520 | IrInstSrc *phi = ir_build_phi(irb, parent_scope, block_node, incoming_blocks.length, |
| 4491 | incoming_blocks.items, incoming_values.items, scope_block->peer_parent); | 5521 | incoming_blocks.items, incoming_values.items, scope_block->peer_parent); |
| 4492 | return ir_expr_wrap(irb, parent_scope, phi, result_loc); | 5522 | return ir_expr_wrap(irb, parent_scope, phi, result_loc); |
| 4493 | } else { | 5523 | } else { |
| 4494 | incoming_blocks.append(irb->current_basic_block); | 5524 | incoming_blocks.append(irb->current_basic_block); |
| 4495 | IrInstruction *else_expr_result = ir_mark_gen(ir_build_const_void(irb, parent_scope, block_node)); | 5525 | IrInstSrc *else_expr_result = ir_mark_gen(ir_build_const_void(irb, parent_scope, block_node)); |
| 4496 | | 5526 | |
| 4497 | if (scope_block->peer_parent != nullptr) { | 5527 | if (scope_block->peer_parent != nullptr) { |
| 4498 | ResultLocPeer *peer_result = create_peer_result(scope_block->peer_parent); | 5528 | ResultLocPeer *peer_result = create_peer_result(scope_block->peer_parent); |
| ... | @@ -4512,15 +5542,15 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -4512,15 +5542,15 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode |
| 4512 | ir_gen_defers_for_block(irb, child_scope, outer_block_scope, false); | 5542 | ir_gen_defers_for_block(irb, child_scope, outer_block_scope, false); |
| 4513 | } | 5543 | } |
| 4514 | | 5544 | |
| 4515 | IrInstruction *result; | 5545 | IrInstSrc *result; |
| 4516 | if (block_node->data.block.name != nullptr) { | 5546 | if (block_node->data.block.name != nullptr) { |
| 4517 | ir_mark_gen(ir_build_br(irb, parent_scope, block_node, scope_block->end_block, scope_block->is_comptime)); | 5547 | ir_mark_gen(ir_build_br(irb, parent_scope, block_node, scope_block->end_block, scope_block->is_comptime)); |
| 4518 | ir_set_cursor_at_end_and_append_block(irb, scope_block->end_block); | 5548 | ir_set_cursor_at_end_and_append_block(irb, scope_block->end_block); |
| 4519 | IrInstruction *phi = ir_build_phi(irb, parent_scope, block_node, incoming_blocks.length, | 5549 | IrInstSrc *phi = ir_build_phi(irb, parent_scope, block_node, incoming_blocks.length, |
| 4520 | incoming_blocks.items, incoming_values.items, scope_block->peer_parent); | 5550 | incoming_blocks.items, incoming_values.items, scope_block->peer_parent); |
| 4521 | result = ir_expr_wrap(irb, parent_scope, phi, result_loc); | 5551 | result = ir_expr_wrap(irb, parent_scope, phi, result_loc); |
| 4522 | } else { | 5552 | } else { |
| 4523 | IrInstruction *void_inst = ir_mark_gen(ir_build_const_void(irb, child_scope, block_node)); | 5553 | IrInstSrc *void_inst = ir_mark_gen(ir_build_const_void(irb, child_scope, block_node)); |
| 4524 | result = ir_lval_wrap(irb, parent_scope, void_inst, lval, result_loc); | 5554 | result = ir_lval_wrap(irb, parent_scope, void_inst, lval, result_loc); |
| 4525 | } | 5555 | } |
| 4526 | if (!is_return_from_fn) | 5556 | if (!is_return_from_fn) |
| ... | @@ -4535,30 +5565,30 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -4535,30 +5565,30 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode |
| 4535 | ir_build_reset_result(irb, parent_scope, block_node, &result_loc_ret->base); | 5565 | ir_build_reset_result(irb, parent_scope, block_node, &result_loc_ret->base); |
| 4536 | ir_mark_gen(ir_build_end_expr(irb, parent_scope, block_node, result, &result_loc_ret->base)); | 5566 | ir_mark_gen(ir_build_end_expr(irb, parent_scope, block_node, result, &result_loc_ret->base)); |
| 4537 | ir_gen_defers_for_block(irb, child_scope, outer_block_scope, false); | 5567 | ir_gen_defers_for_block(irb, child_scope, outer_block_scope, false); |
| 4538 | return ir_mark_gen(ir_build_return(irb, child_scope, result->source_node, result)); | 5568 | return ir_mark_gen(ir_build_return_src(irb, child_scope, result->base.source_node, result)); |
| 4539 | } | 5569 | } |
| 4540 | | 5570 | |
| 4541 | static IrInstruction *ir_gen_bin_op_id(IrBuilder *irb, Scope *scope, AstNode *node, IrBinOp op_id) { | 5571 | static IrInstSrc *ir_gen_bin_op_id(IrBuilderSrc *irb, Scope *scope, AstNode *node, IrBinOp op_id) { |
| 4542 | Scope *inner_scope = scope; | 5572 | Scope *inner_scope = scope; |
| 4543 | if (op_id == IrBinOpArrayCat || op_id == IrBinOpArrayMult) { | 5573 | if (op_id == IrBinOpArrayCat || op_id == IrBinOpArrayMult) { |
| 4544 | inner_scope = create_comptime_scope(irb->codegen, node, scope); | 5574 | inner_scope = create_comptime_scope(irb->codegen, node, scope); |
| 4545 | } | 5575 | } |
| 4546 | | 5576 | |
| 4547 | IrInstruction *op1 = ir_gen_node(irb, node->data.bin_op_expr.op1, inner_scope); | 5577 | IrInstSrc *op1 = ir_gen_node(irb, node->data.bin_op_expr.op1, inner_scope); |
| 4548 | IrInstruction *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, inner_scope); | 5578 | IrInstSrc *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, inner_scope); |
| 4549 | | 5579 | |
| 4550 | if (op1 == irb->codegen->invalid_instruction || op2 == irb->codegen->invalid_instruction) | 5580 | if (op1 == irb->codegen->invalid_inst_src || op2 == irb->codegen->invalid_inst_src) |
| 4551 | return irb->codegen->invalid_instruction; | 5581 | return irb->codegen->invalid_inst_src; |
| 4552 | | 5582 | |
| 4553 | return ir_build_bin_op(irb, scope, node, op_id, op1, op2, true); | 5583 | return ir_build_bin_op(irb, scope, node, op_id, op1, op2, true); |
| 4554 | } | 5584 | } |
| 4555 | | 5585 | |
| 4556 | static IrInstruction *ir_gen_merge_err_sets(IrBuilder *irb, Scope *scope, AstNode *node) { | 5586 | static IrInstSrc *ir_gen_merge_err_sets(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4557 | IrInstruction *op1 = ir_gen_node(irb, node->data.bin_op_expr.op1, scope); | 5587 | IrInstSrc *op1 = ir_gen_node(irb, node->data.bin_op_expr.op1, scope); |
| 4558 | IrInstruction *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); | 5588 | IrInstSrc *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); |
| 4559 | | 5589 | |
| 4560 | if (op1 == irb->codegen->invalid_instruction || op2 == irb->codegen->invalid_instruction) | 5590 | if (op1 == irb->codegen->invalid_inst_src || op2 == irb->codegen->invalid_inst_src) |
| 4561 | return irb->codegen->invalid_instruction; | 5591 | return irb->codegen->invalid_inst_src; |
| 4562 | | 5592 | |
| 4563 | // TODO only pass type_name when the || operator is the top level AST node in the var decl expr | 5593 | // TODO only pass type_name when the || operator is the top level AST node in the var decl expr |
| 4564 | Buf bare_name = BUF_INIT; | 5594 | Buf bare_name = BUF_INIT; |
| ... | @@ -4567,10 +5597,10 @@ static IrInstruction *ir_gen_merge_err_sets(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -4567,10 +5597,10 @@ static IrInstruction *ir_gen_merge_err_sets(IrBuilder *irb, Scope *scope, AstNod |
| 4567 | return ir_build_merge_err_sets(irb, scope, node, op1, op2, type_name); | 5597 | return ir_build_merge_err_sets(irb, scope, node, op1, op2, type_name); |
| 4568 | } | 5598 | } |
| 4569 | | 5599 | |
| 4570 | static IrInstruction *ir_gen_assign(IrBuilder *irb, Scope *scope, AstNode *node) { | 5600 | static IrInstSrc *ir_gen_assign(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4571 | IrInstruction *lvalue = ir_gen_node_extra(irb, node->data.bin_op_expr.op1, scope, LValPtr, nullptr); | 5601 | IrInstSrc *lvalue = ir_gen_node_extra(irb, node->data.bin_op_expr.op1, scope, LValPtr, nullptr); |
| 4572 | if (lvalue == irb->codegen->invalid_instruction) | 5602 | if (lvalue == irb->codegen->invalid_inst_src) |
| 4573 | return irb->codegen->invalid_instruction; | 5603 | return irb->codegen->invalid_inst_src; |
| 4574 | | 5604 | |
| 4575 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1, "ResultLocInstruction"); | 5605 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1, "ResultLocInstruction"); |
| 4576 | result_loc_inst->base.id = ResultLocIdInstruction; | 5606 | result_loc_inst->base.id = ResultLocIdInstruction; |
| ... | @@ -4578,49 +5608,49 @@ static IrInstruction *ir_gen_assign(IrBuilder *irb, Scope *scope, AstNode *node) | ... | @@ -4578,49 +5608,49 @@ static IrInstruction *ir_gen_assign(IrBuilder *irb, Scope *scope, AstNode *node) |
| 4578 | ir_ref_instruction(lvalue, irb->current_basic_block); | 5608 | ir_ref_instruction(lvalue, irb->current_basic_block); |
| 4579 | ir_build_reset_result(irb, scope, node, &result_loc_inst->base); | 5609 | ir_build_reset_result(irb, scope, node, &result_loc_inst->base); |
| 4580 | | 5610 | |
| 4581 | IrInstruction *rvalue = ir_gen_node_extra(irb, node->data.bin_op_expr.op2, scope, LValNone, | 5611 | IrInstSrc *rvalue = ir_gen_node_extra(irb, node->data.bin_op_expr.op2, scope, LValNone, |
| 4582 | &result_loc_inst->base); | 5612 | &result_loc_inst->base); |
| 4583 | if (rvalue == irb->codegen->invalid_instruction) | 5613 | if (rvalue == irb->codegen->invalid_inst_src) |
| 4584 | return irb->codegen->invalid_instruction; | 5614 | return irb->codegen->invalid_inst_src; |
| 4585 | | 5615 | |
| 4586 | return ir_build_const_void(irb, scope, node); | 5616 | return ir_build_const_void(irb, scope, node); |
| 4587 | } | 5617 | } |
| 4588 | | 5618 | |
| 4589 | static IrInstruction *ir_gen_assign_merge_err_sets(IrBuilder *irb, Scope *scope, AstNode *node) { | 5619 | static IrInstSrc *ir_gen_assign_merge_err_sets(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4590 | IrInstruction *lvalue = ir_gen_node_extra(irb, node->data.bin_op_expr.op1, scope, LValPtr, nullptr); | 5620 | IrInstSrc *lvalue = ir_gen_node_extra(irb, node->data.bin_op_expr.op1, scope, LValPtr, nullptr); |
| 4591 | if (lvalue == irb->codegen->invalid_instruction) | 5621 | if (lvalue == irb->codegen->invalid_inst_src) |
| 4592 | return lvalue; | 5622 | return lvalue; |
| 4593 | IrInstruction *op1 = ir_build_load_ptr(irb, scope, node->data.bin_op_expr.op1, lvalue); | 5623 | IrInstSrc *op1 = ir_build_load_ptr(irb, scope, node->data.bin_op_expr.op1, lvalue); |
| 4594 | IrInstruction *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); | 5624 | IrInstSrc *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); |
| 4595 | if (op2 == irb->codegen->invalid_instruction) | 5625 | if (op2 == irb->codegen->invalid_inst_src) |
| 4596 | return op2; | 5626 | return op2; |
| 4597 | IrInstruction *result = ir_build_merge_err_sets(irb, scope, node, op1, op2, nullptr); | 5627 | IrInstSrc *result = ir_build_merge_err_sets(irb, scope, node, op1, op2, nullptr); |
| 4598 | ir_build_store_ptr(irb, scope, node, lvalue, result); | 5628 | ir_build_store_ptr(irb, scope, node, lvalue, result); |
| 4599 | return ir_build_const_void(irb, scope, node); | 5629 | return ir_build_const_void(irb, scope, node); |
| 4600 | } | 5630 | } |
| 4601 | | 5631 | |
| 4602 | static IrInstruction *ir_gen_assign_op(IrBuilder *irb, Scope *scope, AstNode *node, IrBinOp op_id) { | 5632 | static IrInstSrc *ir_gen_assign_op(IrBuilderSrc *irb, Scope *scope, AstNode *node, IrBinOp op_id) { |
| 4603 | IrInstruction *lvalue = ir_gen_node_extra(irb, node->data.bin_op_expr.op1, scope, LValPtr, nullptr); | 5633 | IrInstSrc *lvalue = ir_gen_node_extra(irb, node->data.bin_op_expr.op1, scope, LValPtr, nullptr); |
| 4604 | if (lvalue == irb->codegen->invalid_instruction) | 5634 | if (lvalue == irb->codegen->invalid_inst_src) |
| 4605 | return lvalue; | 5635 | return lvalue; |
| 4606 | IrInstruction *op1 = ir_build_load_ptr(irb, scope, node->data.bin_op_expr.op1, lvalue); | 5636 | IrInstSrc *op1 = ir_build_load_ptr(irb, scope, node->data.bin_op_expr.op1, lvalue); |
| 4607 | IrInstruction *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); | 5637 | IrInstSrc *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); |
| 4608 | if (op2 == irb->codegen->invalid_instruction) | 5638 | if (op2 == irb->codegen->invalid_inst_src) |
| 4609 | return op2; | 5639 | return op2; |
| 4610 | IrInstruction *result = ir_build_bin_op(irb, scope, node, op_id, op1, op2, true); | 5640 | IrInstSrc *result = ir_build_bin_op(irb, scope, node, op_id, op1, op2, true); |
| 4611 | ir_build_store_ptr(irb, scope, node, lvalue, result); | 5641 | ir_build_store_ptr(irb, scope, node, lvalue, result); |
| 4612 | return ir_build_const_void(irb, scope, node); | 5642 | return ir_build_const_void(irb, scope, node); |
| 4613 | } | 5643 | } |
| 4614 | | 5644 | |
| 4615 | static IrInstruction *ir_gen_bool_or(IrBuilder *irb, Scope *scope, AstNode *node) { | 5645 | static IrInstSrc *ir_gen_bool_or(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4616 | assert(node->type == NodeTypeBinOpExpr); | 5646 | assert(node->type == NodeTypeBinOpExpr); |
| 4617 | | 5647 | |
| 4618 | IrInstruction *val1 = ir_gen_node(irb, node->data.bin_op_expr.op1, scope); | 5648 | IrInstSrc *val1 = ir_gen_node(irb, node->data.bin_op_expr.op1, scope); |
| 4619 | if (val1 == irb->codegen->invalid_instruction) | 5649 | if (val1 == irb->codegen->invalid_inst_src) |
| 4620 | return irb->codegen->invalid_instruction; | 5650 | return irb->codegen->invalid_inst_src; |
| 4621 | IrBasicBlock *post_val1_block = irb->current_basic_block; | 5651 | IrBasicBlockSrc *post_val1_block = irb->current_basic_block; |
| 4622 | | 5652 | |
| 4623 | IrInstruction *is_comptime; | 5653 | IrInstSrc *is_comptime; |
| 4624 | if (ir_should_inline(irb->exec, scope)) { | 5654 | if (ir_should_inline(irb->exec, scope)) { |
| 4625 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 5655 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 4626 | } else { | 5656 | } else { |
| ... | @@ -4628,41 +5658,41 @@ static IrInstruction *ir_gen_bool_or(IrBuilder *irb, Scope *scope, AstNode *node | ... | @@ -4628,41 +5658,41 @@ static IrInstruction *ir_gen_bool_or(IrBuilder *irb, Scope *scope, AstNode *node |
| 4628 | } | 5658 | } |
| 4629 | | 5659 | |
| 4630 | // block for when val1 == false | 5660 | // block for when val1 == false |
| 4631 | IrBasicBlock *false_block = ir_create_basic_block(irb, scope, "BoolOrFalse"); | 5661 | IrBasicBlockSrc *false_block = ir_create_basic_block(irb, scope, "BoolOrFalse"); |
| 4632 | // block for when val1 == true (don't even evaluate the second part) | 5662 | // block for when val1 == true (don't even evaluate the second part) |
| 4633 | IrBasicBlock *true_block = ir_create_basic_block(irb, scope, "BoolOrTrue"); | 5663 | IrBasicBlockSrc *true_block = ir_create_basic_block(irb, scope, "BoolOrTrue"); |
| 4634 | | 5664 | |
| 4635 | ir_build_cond_br(irb, scope, node, val1, true_block, false_block, is_comptime); | 5665 | ir_build_cond_br(irb, scope, node, val1, true_block, false_block, is_comptime); |
| 4636 | | 5666 | |
| 4637 | ir_set_cursor_at_end_and_append_block(irb, false_block); | 5667 | ir_set_cursor_at_end_and_append_block(irb, false_block); |
| 4638 | IrInstruction *val2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); | 5668 | IrInstSrc *val2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); |
| 4639 | if (val2 == irb->codegen->invalid_instruction) | 5669 | if (val2 == irb->codegen->invalid_inst_src) |
| 4640 | return irb->codegen->invalid_instruction; | 5670 | return irb->codegen->invalid_inst_src; |
| 4641 | IrBasicBlock *post_val2_block = irb->current_basic_block; | 5671 | IrBasicBlockSrc *post_val2_block = irb->current_basic_block; |
| 4642 | | 5672 | |
| 4643 | ir_build_br(irb, scope, node, true_block, is_comptime); | 5673 | ir_build_br(irb, scope, node, true_block, is_comptime); |
| 4644 | | 5674 | |
| 4645 | ir_set_cursor_at_end_and_append_block(irb, true_block); | 5675 | ir_set_cursor_at_end_and_append_block(irb, true_block); |
| 4646 | | 5676 | |
| 4647 | IrInstruction **incoming_values = allocate<IrInstruction *>(2, "IrInstruction *"); | 5677 | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2, "IrInstSrc *"); |
| 4648 | incoming_values[0] = val1; | 5678 | incoming_values[0] = val1; |
| 4649 | incoming_values[1] = val2; | 5679 | incoming_values[1] = val2; |
| 4650 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); | 5680 | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 4651 | incoming_blocks[0] = post_val1_block; | 5681 | incoming_blocks[0] = post_val1_block; |
| 4652 | incoming_blocks[1] = post_val2_block; | 5682 | incoming_blocks[1] = post_val2_block; |
| 4653 | | 5683 | |
| 4654 | return ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, nullptr); | 5684 | return ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, nullptr); |
| 4655 | } | 5685 | } |
| 4656 | | 5686 | |
| 4657 | static IrInstruction *ir_gen_bool_and(IrBuilder *irb, Scope *scope, AstNode *node) { | 5687 | static IrInstSrc *ir_gen_bool_and(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4658 | assert(node->type == NodeTypeBinOpExpr); | 5688 | assert(node->type == NodeTypeBinOpExpr); |
| 4659 | | 5689 | |
| 4660 | IrInstruction *val1 = ir_gen_node(irb, node->data.bin_op_expr.op1, scope); | 5690 | IrInstSrc *val1 = ir_gen_node(irb, node->data.bin_op_expr.op1, scope); |
| 4661 | if (val1 == irb->codegen->invalid_instruction) | 5691 | if (val1 == irb->codegen->invalid_inst_src) |
| 4662 | return irb->codegen->invalid_instruction; | 5692 | return irb->codegen->invalid_inst_src; |
| 4663 | IrBasicBlock *post_val1_block = irb->current_basic_block; | 5693 | IrBasicBlockSrc *post_val1_block = irb->current_basic_block; |
| 4664 | | 5694 | |
| 4665 | IrInstruction *is_comptime; | 5695 | IrInstSrc *is_comptime; |
| 4666 | if (ir_should_inline(irb->exec, scope)) { | 5696 | if (ir_should_inline(irb->exec, scope)) { |
| 4667 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 5697 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 4668 | } else { | 5698 | } else { |
| ... | @@ -4670,34 +5700,34 @@ static IrInstruction *ir_gen_bool_and(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -4670,34 +5700,34 @@ static IrInstruction *ir_gen_bool_and(IrBuilder *irb, Scope *scope, AstNode *nod |
| 4670 | } | 5700 | } |
| 4671 | | 5701 | |
| 4672 | // block for when val1 == true | 5702 | // block for when val1 == true |
| 4673 | IrBasicBlock *true_block = ir_create_basic_block(irb, scope, "BoolAndTrue"); | 5703 | IrBasicBlockSrc *true_block = ir_create_basic_block(irb, scope, "BoolAndTrue"); |
| 4674 | // block for when val1 == false (don't even evaluate the second part) | 5704 | // block for when val1 == false (don't even evaluate the second part) |
| 4675 | IrBasicBlock *false_block = ir_create_basic_block(irb, scope, "BoolAndFalse"); | 5705 | IrBasicBlockSrc *false_block = ir_create_basic_block(irb, scope, "BoolAndFalse"); |
| 4676 | | 5706 | |
| 4677 | ir_build_cond_br(irb, scope, node, val1, true_block, false_block, is_comptime); | 5707 | ir_build_cond_br(irb, scope, node, val1, true_block, false_block, is_comptime); |
| 4678 | | 5708 | |
| 4679 | ir_set_cursor_at_end_and_append_block(irb, true_block); | 5709 | ir_set_cursor_at_end_and_append_block(irb, true_block); |
| 4680 | IrInstruction *val2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); | 5710 | IrInstSrc *val2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); |
| 4681 | if (val2 == irb->codegen->invalid_instruction) | 5711 | if (val2 == irb->codegen->invalid_inst_src) |
| 4682 | return irb->codegen->invalid_instruction; | 5712 | return irb->codegen->invalid_inst_src; |
| 4683 | IrBasicBlock *post_val2_block = irb->current_basic_block; | 5713 | IrBasicBlockSrc *post_val2_block = irb->current_basic_block; |
| 4684 | | 5714 | |
| 4685 | ir_build_br(irb, scope, node, false_block, is_comptime); | 5715 | ir_build_br(irb, scope, node, false_block, is_comptime); |
| 4686 | | 5716 | |
| 4687 | ir_set_cursor_at_end_and_append_block(irb, false_block); | 5717 | ir_set_cursor_at_end_and_append_block(irb, false_block); |
| 4688 | | 5718 | |
| 4689 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 5719 | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 4690 | incoming_values[0] = val1; | 5720 | incoming_values[0] = val1; |
| 4691 | incoming_values[1] = val2; | 5721 | incoming_values[1] = val2; |
| 4692 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); | 5722 | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 4693 | incoming_blocks[0] = post_val1_block; | 5723 | incoming_blocks[0] = post_val1_block; |
| 4694 | incoming_blocks[1] = post_val2_block; | 5724 | incoming_blocks[1] = post_val2_block; |
| 4695 | | 5725 | |
| 4696 | return ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, nullptr); | 5726 | return ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, nullptr); |
| 4697 | } | 5727 | } |
| 4698 | | 5728 | |
| 4699 | static ResultLocPeerParent *ir_build_result_peers(IrBuilder *irb, IrInstruction *cond_br_inst, | 5729 | static ResultLocPeerParent *ir_build_result_peers(IrBuilderSrc *irb, IrInstSrc *cond_br_inst, |
| 4700 | IrBasicBlock *end_block, ResultLoc *parent, IrInstruction *is_comptime) | 5730 | IrBasicBlockSrc *end_block, ResultLoc *parent, IrInstSrc *is_comptime) |
| 4701 | { | 5731 | { |
| 4702 | ResultLocPeerParent *peer_parent = allocate<ResultLocPeerParent>(1); | 5732 | ResultLocPeerParent *peer_parent = allocate<ResultLocPeerParent>(1); |
| 4703 | peer_parent->base.id = ResultLocIdPeerParent; | 5733 | peer_parent->base.id = ResultLocIdPeerParent; |
| ... | @@ -4707,17 +5737,17 @@ static ResultLocPeerParent *ir_build_result_peers(IrBuilder *irb, IrInstruction | ... | @@ -4707,17 +5737,17 @@ static ResultLocPeerParent *ir_build_result_peers(IrBuilder *irb, IrInstruction |
| 4707 | peer_parent->is_comptime = is_comptime; | 5737 | peer_parent->is_comptime = is_comptime; |
| 4708 | peer_parent->parent = parent; | 5738 | peer_parent->parent = parent; |
| 4709 | | 5739 | |
| 4710 | IrInstruction *popped_inst = irb->current_basic_block->instruction_list.pop(); | 5740 | IrInstSrc *popped_inst = irb->current_basic_block->instruction_list.pop(); |
| 4711 | ir_assert(popped_inst == cond_br_inst, cond_br_inst); | 5741 | ir_assert(popped_inst == cond_br_inst, &cond_br_inst->base); |
| 4712 | | 5742 | |
| 4713 | ir_build_reset_result(irb, cond_br_inst->scope, cond_br_inst->source_node, &peer_parent->base); | 5743 | ir_build_reset_result(irb, cond_br_inst->base.scope, cond_br_inst->base.source_node, &peer_parent->base); |
| 4714 | irb->current_basic_block->instruction_list.append(popped_inst); | 5744 | irb->current_basic_block->instruction_list.append(popped_inst); |
| 4715 | | 5745 | |
| 4716 | return peer_parent; | 5746 | return peer_parent; |
| 4717 | } | 5747 | } |
| 4718 | | 5748 | |
| 4719 | static ResultLocPeerParent *ir_build_binary_result_peers(IrBuilder *irb, IrInstruction *cond_br_inst, | 5749 | static ResultLocPeerParent *ir_build_binary_result_peers(IrBuilderSrc *irb, IrInstSrc *cond_br_inst, |
| 4720 | IrBasicBlock *else_block, IrBasicBlock *end_block, ResultLoc *parent, IrInstruction *is_comptime) | 5750 | IrBasicBlockSrc *else_block, IrBasicBlockSrc *end_block, ResultLoc *parent, IrInstSrc *is_comptime) |
| 4721 | { | 5751 | { |
| 4722 | ResultLocPeerParent *peer_parent = ir_build_result_peers(irb, cond_br_inst, end_block, parent, is_comptime); | 5752 | ResultLocPeerParent *peer_parent = ir_build_result_peers(irb, cond_br_inst, end_block, parent, is_comptime); |
| 4723 | | 5753 | |
| ... | @@ -4730,7 +5760,7 @@ static ResultLocPeerParent *ir_build_binary_result_peers(IrBuilder *irb, IrInstr | ... | @@ -4730,7 +5760,7 @@ static ResultLocPeerParent *ir_build_binary_result_peers(IrBuilder *irb, IrInstr |
| 4730 | return peer_parent; | 5760 | return peer_parent; |
| 4731 | } | 5761 | } |
| 4732 | | 5762 | |
| 4733 | static IrInstruction *ir_gen_orelse(IrBuilder *irb, Scope *parent_scope, AstNode *node, LVal lval, | 5763 | static IrInstSrc *ir_gen_orelse(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node, LVal lval, |
| 4734 | ResultLoc *result_loc) | 5764 | ResultLoc *result_loc) |
| 4735 | { | 5765 | { |
| 4736 | assert(node->type == NodeTypeBinOpExpr); | 5766 | assert(node->type == NodeTypeBinOpExpr); |
| ... | @@ -4738,73 +5768,73 @@ static IrInstruction *ir_gen_orelse(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -4738,73 +5768,73 @@ static IrInstruction *ir_gen_orelse(IrBuilder *irb, Scope *parent_scope, AstNode |
| 4738 | AstNode *op1_node = node->data.bin_op_expr.op1; | 5768 | AstNode *op1_node = node->data.bin_op_expr.op1; |
| 4739 | AstNode *op2_node = node->data.bin_op_expr.op2; | 5769 | AstNode *op2_node = node->data.bin_op_expr.op2; |
| 4740 | | 5770 | |
| 4741 | IrInstruction *maybe_ptr = ir_gen_node_extra(irb, op1_node, parent_scope, LValPtr, nullptr); | 5771 | IrInstSrc *maybe_ptr = ir_gen_node_extra(irb, op1_node, parent_scope, LValPtr, nullptr); |
| 4742 | if (maybe_ptr == irb->codegen->invalid_instruction) | 5772 | if (maybe_ptr == irb->codegen->invalid_inst_src) |
| 4743 | return irb->codegen->invalid_instruction; | 5773 | return irb->codegen->invalid_inst_src; |
| 4744 | | 5774 | |
| 4745 | IrInstruction *maybe_val = ir_build_load_ptr(irb, parent_scope, node, maybe_ptr); | 5775 | IrInstSrc *maybe_val = ir_build_load_ptr(irb, parent_scope, node, maybe_ptr); |
| 4746 | IrInstruction *is_non_null = ir_build_test_nonnull(irb, parent_scope, node, maybe_val); | 5776 | IrInstSrc *is_non_null = ir_build_test_non_null_src(irb, parent_scope, node, maybe_val); |
| 4747 | | 5777 | |
| 4748 | IrInstruction *is_comptime; | 5778 | IrInstSrc *is_comptime; |
| 4749 | if (ir_should_inline(irb->exec, parent_scope)) { | 5779 | if (ir_should_inline(irb->exec, parent_scope)) { |
| 4750 | is_comptime = ir_build_const_bool(irb, parent_scope, node, true); | 5780 | is_comptime = ir_build_const_bool(irb, parent_scope, node, true); |
| 4751 | } else { | 5781 | } else { |
| 4752 | is_comptime = ir_build_test_comptime(irb, parent_scope, node, is_non_null); | 5782 | is_comptime = ir_build_test_comptime(irb, parent_scope, node, is_non_null); |
| 4753 | } | 5783 | } |
| 4754 | | 5784 | |
| 4755 | IrBasicBlock *ok_block = ir_create_basic_block(irb, parent_scope, "OptionalNonNull"); | 5785 | IrBasicBlockSrc *ok_block = ir_create_basic_block(irb, parent_scope, "OptionalNonNull"); |
| 4756 | IrBasicBlock *null_block = ir_create_basic_block(irb, parent_scope, "OptionalNull"); | 5786 | IrBasicBlockSrc *null_block = ir_create_basic_block(irb, parent_scope, "OptionalNull"); |
| 4757 | IrBasicBlock *end_block = ir_create_basic_block(irb, parent_scope, "OptionalEnd"); | 5787 | IrBasicBlockSrc *end_block = ir_create_basic_block(irb, parent_scope, "OptionalEnd"); |
| 4758 | IrInstruction *cond_br_inst = ir_build_cond_br(irb, parent_scope, node, is_non_null, ok_block, null_block, is_comptime); | 5788 | IrInstSrc *cond_br_inst = ir_build_cond_br(irb, parent_scope, node, is_non_null, ok_block, null_block, is_comptime); |
| 4759 | | 5789 | |
| 4760 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, ok_block, end_block, | 5790 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, ok_block, end_block, |
| 4761 | result_loc, is_comptime); | 5791 | result_loc, is_comptime); |
| 4762 | | 5792 | |
| 4763 | ir_set_cursor_at_end_and_append_block(irb, null_block); | 5793 | ir_set_cursor_at_end_and_append_block(irb, null_block); |
| 4764 | IrInstruction *null_result = ir_gen_node_extra(irb, op2_node, parent_scope, LValNone, | 5794 | IrInstSrc *null_result = ir_gen_node_extra(irb, op2_node, parent_scope, LValNone, |
| 4765 | &peer_parent->peers.at(0)->base); | 5795 | &peer_parent->peers.at(0)->base); |
| 4766 | if (null_result == irb->codegen->invalid_instruction) | 5796 | if (null_result == irb->codegen->invalid_inst_src) |
| 4767 | return irb->codegen->invalid_instruction; | 5797 | return irb->codegen->invalid_inst_src; |
| 4768 | IrBasicBlock *after_null_block = irb->current_basic_block; | 5798 | IrBasicBlockSrc *after_null_block = irb->current_basic_block; |
| 4769 | if (!instr_is_unreachable(null_result)) | 5799 | if (!instr_is_unreachable(null_result)) |
| 4770 | ir_mark_gen(ir_build_br(irb, parent_scope, node, end_block, is_comptime)); | 5800 | ir_mark_gen(ir_build_br(irb, parent_scope, node, end_block, is_comptime)); |
| 4771 | | 5801 | |
| 4772 | ir_set_cursor_at_end_and_append_block(irb, ok_block); | 5802 | ir_set_cursor_at_end_and_append_block(irb, ok_block); |
| 4773 | IrInstruction *unwrapped_ptr = ir_build_optional_unwrap_ptr(irb, parent_scope, node, maybe_ptr, false, false); | 5803 | IrInstSrc *unwrapped_ptr = ir_build_optional_unwrap_ptr(irb, parent_scope, node, maybe_ptr, false, false); |
| 4774 | IrInstruction *unwrapped_payload = ir_build_load_ptr(irb, parent_scope, node, unwrapped_ptr); | 5804 | IrInstSrc *unwrapped_payload = ir_build_load_ptr(irb, parent_scope, node, unwrapped_ptr); |
| 4775 | ir_build_end_expr(irb, parent_scope, node, unwrapped_payload, &peer_parent->peers.at(1)->base); | 5805 | ir_build_end_expr(irb, parent_scope, node, unwrapped_payload, &peer_parent->peers.at(1)->base); |
| 4776 | IrBasicBlock *after_ok_block = irb->current_basic_block; | 5806 | IrBasicBlockSrc *after_ok_block = irb->current_basic_block; |
| 4777 | ir_build_br(irb, parent_scope, node, end_block, is_comptime); | 5807 | ir_build_br(irb, parent_scope, node, end_block, is_comptime); |
| 4778 | | 5808 | |
| 4779 | ir_set_cursor_at_end_and_append_block(irb, end_block); | 5809 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 4780 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 5810 | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 4781 | incoming_values[0] = null_result; | 5811 | incoming_values[0] = null_result; |
| 4782 | incoming_values[1] = unwrapped_payload; | 5812 | incoming_values[1] = unwrapped_payload; |
| 4783 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); | 5813 | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 4784 | incoming_blocks[0] = after_null_block; | 5814 | incoming_blocks[0] = after_null_block; |
| 4785 | incoming_blocks[1] = after_ok_block; | 5815 | incoming_blocks[1] = after_ok_block; |
| 4786 | IrInstruction *phi = ir_build_phi(irb, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); | 5816 | IrInstSrc *phi = ir_build_phi(irb, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); |
| 4787 | return ir_lval_wrap(irb, parent_scope, phi, lval, result_loc); | 5817 | return ir_lval_wrap(irb, parent_scope, phi, lval, result_loc); |
| 4788 | } | 5818 | } |
| 4789 | | 5819 | |
| 4790 | static IrInstruction *ir_gen_error_union(IrBuilder *irb, Scope *parent_scope, AstNode *node) { | 5820 | static IrInstSrc *ir_gen_error_union(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node) { |
| 4791 | assert(node->type == NodeTypeBinOpExpr); | 5821 | assert(node->type == NodeTypeBinOpExpr); |
| 4792 | | 5822 | |
| 4793 | AstNode *op1_node = node->data.bin_op_expr.op1; | 5823 | AstNode *op1_node = node->data.bin_op_expr.op1; |
| 4794 | AstNode *op2_node = node->data.bin_op_expr.op2; | 5824 | AstNode *op2_node = node->data.bin_op_expr.op2; |
| 4795 | | 5825 | |
| 4796 | IrInstruction *err_set = ir_gen_node(irb, op1_node, parent_scope); | 5826 | IrInstSrc *err_set = ir_gen_node(irb, op1_node, parent_scope); |
| 4797 | if (err_set == irb->codegen->invalid_instruction) | 5827 | if (err_set == irb->codegen->invalid_inst_src) |
| 4798 | return irb->codegen->invalid_instruction; | 5828 | return irb->codegen->invalid_inst_src; |
| 4799 | | 5829 | |
| 4800 | IrInstruction *payload = ir_gen_node(irb, op2_node, parent_scope); | 5830 | IrInstSrc *payload = ir_gen_node(irb, op2_node, parent_scope); |
| 4801 | if (payload == irb->codegen->invalid_instruction) | 5831 | if (payload == irb->codegen->invalid_inst_src) |
| 4802 | return irb->codegen->invalid_instruction; | 5832 | return irb->codegen->invalid_inst_src; |
| 4803 | | 5833 | |
| 4804 | return ir_build_error_union(irb, parent_scope, node, err_set, payload); | 5834 | return ir_build_error_union(irb, parent_scope, node, err_set, payload); |
| 4805 | } | 5835 | } |
| 4806 | | 5836 | |
| 4807 | static IrInstruction *ir_gen_bin_op(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { | 5837 | static IrInstSrc *ir_gen_bin_op(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { |
| 4808 | assert(node->type == NodeTypeBinOpExpr); | 5838 | assert(node->type == NodeTypeBinOpExpr); |
| 4809 | | 5839 | |
| 4810 | BinOpType bin_op_type = node->data.bin_op_expr.bin_op; | 5840 | BinOpType bin_op_type = node->data.bin_op_expr.bin_op; |
| ... | @@ -4897,30 +5927,30 @@ static IrInstruction *ir_gen_bin_op(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4897,30 +5927,30 @@ static IrInstruction *ir_gen_bin_op(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4897 | zig_unreachable(); | 5927 | zig_unreachable(); |
| 4898 | } | 5928 | } |
| 4899 | | 5929 | |
| 4900 | static IrInstruction *ir_gen_int_lit(IrBuilder *irb, Scope *scope, AstNode *node) { | 5930 | static IrInstSrc *ir_gen_int_lit(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4901 | assert(node->type == NodeTypeIntLiteral); | 5931 | assert(node->type == NodeTypeIntLiteral); |
| 4902 | | 5932 | |
| 4903 | return ir_build_const_bigint(irb, scope, node, node->data.int_literal.bigint); | 5933 | return ir_build_const_bigint(irb, scope, node, node->data.int_literal.bigint); |
| 4904 | } | 5934 | } |
| 4905 | | 5935 | |
| 4906 | static IrInstruction *ir_gen_float_lit(IrBuilder *irb, Scope *scope, AstNode *node) { | 5936 | static IrInstSrc *ir_gen_float_lit(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4907 | assert(node->type == NodeTypeFloatLiteral); | 5937 | assert(node->type == NodeTypeFloatLiteral); |
| 4908 | | 5938 | |
| 4909 | if (node->data.float_literal.overflow) { | 5939 | if (node->data.float_literal.overflow) { |
| 4910 | add_node_error(irb->codegen, node, buf_sprintf("float literal out of range of any type")); | 5940 | add_node_error(irb->codegen, node, buf_sprintf("float literal out of range of any type")); |
| 4911 | return irb->codegen->invalid_instruction; | 5941 | return irb->codegen->invalid_inst_src; |
| 4912 | } | 5942 | } |
| 4913 | | 5943 | |
| 4914 | return ir_build_const_bigfloat(irb, scope, node, node->data.float_literal.bigfloat); | 5944 | return ir_build_const_bigfloat(irb, scope, node, node->data.float_literal.bigfloat); |
| 4915 | } | 5945 | } |
| 4916 | | 5946 | |
| 4917 | static IrInstruction *ir_gen_char_lit(IrBuilder *irb, Scope *scope, AstNode *node) { | 5947 | static IrInstSrc *ir_gen_char_lit(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4918 | assert(node->type == NodeTypeCharLiteral); | 5948 | assert(node->type == NodeTypeCharLiteral); |
| 4919 | | 5949 | |
| 4920 | return ir_build_const_uint(irb, scope, node, node->data.char_literal.value); | 5950 | return ir_build_const_uint(irb, scope, node, node->data.char_literal.value); |
| 4921 | } | 5951 | } |
| 4922 | | 5952 | |
| 4923 | static IrInstruction *ir_gen_null_literal(IrBuilder *irb, Scope *scope, AstNode *node) { | 5953 | static IrInstSrc *ir_gen_null_literal(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4924 | assert(node->type == NodeTypeNullLiteral); | 5954 | assert(node->type == NodeTypeNullLiteral); |
| 4925 | | 5955 | |
| 4926 | return ir_build_const_null(irb, scope, node); | 5956 | return ir_build_const_null(irb, scope, node); |
| ... | @@ -4938,11 +5968,11 @@ static void populate_invalid_variable_in_scope(CodeGen *g, Scope *scope, AstNode | ... | @@ -4938,11 +5968,11 @@ static void populate_invalid_variable_in_scope(CodeGen *g, Scope *scope, AstNode |
| 4938 | init_tld(&tld_var->base, TldIdVar, var_name, VisibModPub, node, &scope_decls->base); | 5968 | init_tld(&tld_var->base, TldIdVar, var_name, VisibModPub, node, &scope_decls->base); |
| 4939 | tld_var->base.resolution = TldResolutionInvalid; | 5969 | tld_var->base.resolution = TldResolutionInvalid; |
| 4940 | tld_var->var = add_variable(g, node, &scope_decls->base, var_name, false, | 5970 | tld_var->var = add_variable(g, node, &scope_decls->base, var_name, false, |
| 4941 | g->invalid_instruction->value, &tld_var->base, g->builtin_types.entry_invalid); | 5971 | g->invalid_inst_gen->value, &tld_var->base, g->builtin_types.entry_invalid); |
| 4942 | scope_decls->decl_table.put(var_name, &tld_var->base); | 5972 | scope_decls->decl_table.put(var_name, &tld_var->base); |
| 4943 | } | 5973 | } |
| 4944 | | 5974 | |
| 4945 | static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { | 5975 | static IrInstSrc *ir_gen_symbol(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { |
| 4946 | Error err; | 5976 | Error err; |
| 4947 | assert(node->type == NodeTypeSymbol); | 5977 | assert(node->type == NodeTypeSymbol); |
| 4948 | | 5978 | |
| ... | @@ -4950,15 +5980,16 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4950,15 +5980,16 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4950 | | 5980 | |
| 4951 | if (buf_eql_str(variable_name, "_")) { | 5981 | if (buf_eql_str(variable_name, "_")) { |
| 4952 | if (lval == LValPtr) { | 5982 | if (lval == LValPtr) { |
| 4953 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, node); | 5983 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, node); |
| 4954 | const_instruction->base.value->type = get_pointer_to_type(irb->codegen, | 5984 | const_instruction->value = create_const_vals(1); |
| | 5985 | const_instruction->value->type = get_pointer_to_type(irb->codegen, |
| 4955 | irb->codegen->builtin_types.entry_void, false); | 5986 | irb->codegen->builtin_types.entry_void, false); |
| 4956 | const_instruction->base.value->special = ConstValSpecialStatic; | 5987 | const_instruction->value->special = ConstValSpecialStatic; |
| 4957 | const_instruction->base.value->data.x_ptr.special = ConstPtrSpecialDiscard; | 5988 | const_instruction->value->data.x_ptr.special = ConstPtrSpecialDiscard; |
| 4958 | return &const_instruction->base; | 5989 | return &const_instruction->base; |
| 4959 | } else { | 5990 | } else { |
| 4960 | add_node_error(irb->codegen, node, buf_sprintf("`_` may only be used to assign things to")); | 5991 | add_node_error(irb->codegen, node, buf_sprintf("`_` may only be used to assign things to")); |
| 4961 | return irb->codegen->invalid_instruction; | 5992 | return irb->codegen->invalid_inst_src; |
| 4962 | } | 5993 | } |
| 4963 | } | 5994 | } |
| 4964 | | 5995 | |
| ... | @@ -4968,13 +5999,13 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4968,13 +5999,13 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4968 | add_node_error(irb->codegen, node, | 5999 | add_node_error(irb->codegen, node, |
| 4969 | buf_sprintf("primitive integer type '%s' exceeds maximum bit width of 65535", | 6000 | buf_sprintf("primitive integer type '%s' exceeds maximum bit width of 65535", |
| 4970 | buf_ptr(variable_name))); | 6001 | buf_ptr(variable_name))); |
| 4971 | return irb->codegen->invalid_instruction; | 6002 | return irb->codegen->invalid_inst_src; |
| 4972 | } | 6003 | } |
| 4973 | assert(err == ErrorPrimitiveTypeNotFound); | 6004 | assert(err == ErrorPrimitiveTypeNotFound); |
| 4974 | } else { | 6005 | } else { |
| 4975 | IrInstruction *value = ir_build_const_type(irb, scope, node, primitive_type); | 6006 | IrInstSrc *value = ir_build_const_type(irb, scope, node, primitive_type); |
| 4976 | if (lval == LValPtr) { | 6007 | if (lval == LValPtr) { |
| 4977 | return ir_build_ref(irb, scope, node, value, false, false); | 6008 | return ir_build_ref_src(irb, scope, node, value, false, false); |
| 4978 | } else { | 6009 | } else { |
| 4979 | return ir_expr_wrap(irb, scope, value, result_loc); | 6010 | return ir_expr_wrap(irb, scope, value, result_loc); |
| 4980 | } | 6011 | } |
| ... | @@ -4983,7 +6014,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4983,7 +6014,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4983 | ScopeFnDef *crossed_fndef_scope; | 6014 | ScopeFnDef *crossed_fndef_scope; |
| 4984 | ZigVar *var = find_variable(irb->codegen, scope, variable_name, &crossed_fndef_scope); | 6015 | ZigVar *var = find_variable(irb->codegen, scope, variable_name, &crossed_fndef_scope); |
| 4985 | if (var) { | 6016 | if (var) { |
| 4986 | IrInstruction *var_ptr = ir_build_var_ptr_x(irb, scope, node, var, crossed_fndef_scope); | 6017 | IrInstSrc *var_ptr = ir_build_var_ptr_x(irb, scope, node, var, crossed_fndef_scope); |
| 4987 | if (lval == LValPtr) { | 6018 | if (lval == LValPtr) { |
| 4988 | return var_ptr; | 6019 | return var_ptr; |
| 4989 | } else { | 6020 | } else { |
| ... | @@ -4993,7 +6024,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4993,7 +6024,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4993 | | 6024 | |
| 4994 | Tld *tld = find_decl(irb->codegen, scope, variable_name); | 6025 | Tld *tld = find_decl(irb->codegen, scope, variable_name); |
| 4995 | if (tld) { | 6026 | if (tld) { |
| 4996 | IrInstruction *decl_ref = ir_build_decl_ref(irb, scope, node, tld, lval); | 6027 | IrInstSrc *decl_ref = ir_build_decl_ref(irb, scope, node, tld, lval); |
| 4997 | if (lval == LValPtr) { | 6028 | if (lval == LValPtr) { |
| 4998 | return decl_ref; | 6029 | return decl_ref; |
| 4999 | } else { | 6030 | } else { |
| ... | @@ -5004,50 +6035,50 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -5004,50 +6035,50 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, |
| 5004 | if (get_container_scope(node->owner)->any_imports_failed) { | 6035 | if (get_container_scope(node->owner)->any_imports_failed) { |
| 5005 | // skip the error message since we had a failing import in this file | 6036 | // skip the error message since we had a failing import in this file |
| 5006 | // if an import breaks we don't need redundant undeclared identifier errors | 6037 | // if an import breaks we don't need redundant undeclared identifier errors |
| 5007 | return irb->codegen->invalid_instruction; | 6038 | return irb->codegen->invalid_inst_src; |
| 5008 | } | 6039 | } |
| 5009 | | 6040 | |
| 5010 | return ir_build_undeclared_identifier(irb, scope, node, variable_name); | 6041 | return ir_build_undeclared_identifier(irb, scope, node, variable_name); |
| 5011 | } | 6042 | } |
| 5012 | | 6043 | |
| 5013 | static IrInstruction *ir_gen_array_access(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 6044 | static IrInstSrc *ir_gen_array_access(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 5014 | ResultLoc *result_loc) | 6045 | ResultLoc *result_loc) |
| 5015 | { | 6046 | { |
| 5016 | assert(node->type == NodeTypeArrayAccessExpr); | 6047 | assert(node->type == NodeTypeArrayAccessExpr); |
| 5017 | | 6048 | |
| 5018 | AstNode *array_ref_node = node->data.array_access_expr.array_ref_expr; | 6049 | AstNode *array_ref_node = node->data.array_access_expr.array_ref_expr; |
| 5019 | IrInstruction *array_ref_instruction = ir_gen_node_extra(irb, array_ref_node, scope, LValPtr, nullptr); | 6050 | IrInstSrc *array_ref_instruction = ir_gen_node_extra(irb, array_ref_node, scope, LValPtr, nullptr); |
| 5020 | if (array_ref_instruction == irb->codegen->invalid_instruction) | 6051 | if (array_ref_instruction == irb->codegen->invalid_inst_src) |
| 5021 | return array_ref_instruction; | 6052 | return array_ref_instruction; |
| 5022 | | 6053 | |
| 5023 | AstNode *subscript_node = node->data.array_access_expr.subscript; | 6054 | AstNode *subscript_node = node->data.array_access_expr.subscript; |
| 5024 | IrInstruction *subscript_instruction = ir_gen_node(irb, subscript_node, scope); | 6055 | IrInstSrc *subscript_instruction = ir_gen_node(irb, subscript_node, scope); |
| 5025 | if (subscript_instruction == irb->codegen->invalid_instruction) | 6056 | if (subscript_instruction == irb->codegen->invalid_inst_src) |
| 5026 | return subscript_instruction; | 6057 | return subscript_instruction; |
| 5027 | | 6058 | |
| 5028 | IrInstruction *ptr_instruction = ir_build_elem_ptr(irb, scope, node, array_ref_instruction, | 6059 | IrInstSrc *ptr_instruction = ir_build_elem_ptr(irb, scope, node, array_ref_instruction, |
| 5029 | subscript_instruction, true, PtrLenSingle, nullptr); | 6060 | subscript_instruction, true, PtrLenSingle, nullptr); |
| 5030 | if (lval == LValPtr) | 6061 | if (lval == LValPtr) |
| 5031 | return ptr_instruction; | 6062 | return ptr_instruction; |
| 5032 | | 6063 | |
| 5033 | IrInstruction *load_ptr = ir_build_load_ptr(irb, scope, node, ptr_instruction); | 6064 | IrInstSrc *load_ptr = ir_build_load_ptr(irb, scope, node, ptr_instruction); |
| 5034 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); | 6065 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); |
| 5035 | } | 6066 | } |
| 5036 | | 6067 | |
| 5037 | static IrInstruction *ir_gen_field_access(IrBuilder *irb, Scope *scope, AstNode *node) { | 6068 | static IrInstSrc *ir_gen_field_access(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 5038 | assert(node->type == NodeTypeFieldAccessExpr); | 6069 | assert(node->type == NodeTypeFieldAccessExpr); |
| 5039 | | 6070 | |
| 5040 | AstNode *container_ref_node = node->data.field_access_expr.struct_expr; | 6071 | AstNode *container_ref_node = node->data.field_access_expr.struct_expr; |
| 5041 | Buf *field_name = node->data.field_access_expr.field_name; | 6072 | Buf *field_name = node->data.field_access_expr.field_name; |
| 5042 | | 6073 | |
| 5043 | IrInstruction *container_ref_instruction = ir_gen_node_extra(irb, container_ref_node, scope, LValPtr, nullptr); | 6074 | IrInstSrc *container_ref_instruction = ir_gen_node_extra(irb, container_ref_node, scope, LValPtr, nullptr); |
| 5044 | if (container_ref_instruction == irb->codegen->invalid_instruction) | 6075 | if (container_ref_instruction == irb->codegen->invalid_inst_src) |
| 5045 | return container_ref_instruction; | 6076 | return container_ref_instruction; |
| 5046 | | 6077 | |
| 5047 | return ir_build_field_ptr(irb, scope, node, container_ref_instruction, field_name, false); | 6078 | return ir_build_field_ptr(irb, scope, node, container_ref_instruction, field_name, false); |
| 5048 | } | 6079 | } |
| 5049 | | 6080 | |
| 5050 | static IrInstruction *ir_gen_overflow_op(IrBuilder *irb, Scope *scope, AstNode *node, IrOverflowOp op) { | 6081 | static IrInstSrc *ir_gen_overflow_op(IrBuilderSrc *irb, Scope *scope, AstNode *node, IrOverflowOp op) { |
| 5051 | assert(node->type == NodeTypeFnCallExpr); | 6082 | assert(node->type == NodeTypeFnCallExpr); |
| 5052 | | 6083 | |
| 5053 | AstNode *type_node = node->data.fn_call_expr.params.at(0); | 6084 | AstNode *type_node = node->data.fn_call_expr.params.at(0); |
| ... | @@ -5056,26 +6087,26 @@ static IrInstruction *ir_gen_overflow_op(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -5056,26 +6087,26 @@ static IrInstruction *ir_gen_overflow_op(IrBuilder *irb, Scope *scope, AstNode * |
| 5056 | AstNode *result_ptr_node = node->data.fn_call_expr.params.at(3); | 6087 | AstNode *result_ptr_node = node->data.fn_call_expr.params.at(3); |
| 5057 | | 6088 | |
| 5058 | | 6089 | |
| 5059 | IrInstruction *type_value = ir_gen_node(irb, type_node, scope); | 6090 | IrInstSrc *type_value = ir_gen_node(irb, type_node, scope); |
| 5060 | if (type_value == irb->codegen->invalid_instruction) | 6091 | if (type_value == irb->codegen->invalid_inst_src) |
| 5061 | return irb->codegen->invalid_instruction; | 6092 | return irb->codegen->invalid_inst_src; |
| 5062 | | 6093 | |
| 5063 | IrInstruction *op1 = ir_gen_node(irb, op1_node, scope); | 6094 | IrInstSrc *op1 = ir_gen_node(irb, op1_node, scope); |
| 5064 | if (op1 == irb->codegen->invalid_instruction) | 6095 | if (op1 == irb->codegen->invalid_inst_src) |
| 5065 | return irb->codegen->invalid_instruction; | 6096 | return irb->codegen->invalid_inst_src; |
| 5066 | | 6097 | |
| 5067 | IrInstruction *op2 = ir_gen_node(irb, op2_node, scope); | 6098 | IrInstSrc *op2 = ir_gen_node(irb, op2_node, scope); |
| 5068 | if (op2 == irb->codegen->invalid_instruction) | 6099 | if (op2 == irb->codegen->invalid_inst_src) |
| 5069 | return irb->codegen->invalid_instruction; | 6100 | return irb->codegen->invalid_inst_src; |
| 5070 | | 6101 | |
| 5071 | IrInstruction *result_ptr = ir_gen_node(irb, result_ptr_node, scope); | 6102 | IrInstSrc *result_ptr = ir_gen_node(irb, result_ptr_node, scope); |
| 5072 | if (result_ptr == irb->codegen->invalid_instruction) | 6103 | if (result_ptr == irb->codegen->invalid_inst_src) |
| 5073 | return irb->codegen->invalid_instruction; | 6104 | return irb->codegen->invalid_inst_src; |
| 5074 | | 6105 | |
| 5075 | return ir_build_overflow_op(irb, scope, node, op, type_value, op1, op2, result_ptr, nullptr); | 6106 | return ir_build_overflow_op_src(irb, scope, node, op, type_value, op1, op2, result_ptr); |
| 5076 | } | 6107 | } |
| 5077 | | 6108 | |
| 5078 | static IrInstruction *ir_gen_mul_add(IrBuilder *irb, Scope *scope, AstNode *node) { | 6109 | static IrInstSrc *ir_gen_mul_add(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 5079 | assert(node->type == NodeTypeFnCallExpr); | 6110 | assert(node->type == NodeTypeFnCallExpr); |
| 5080 | | 6111 | |
| 5081 | AstNode *type_node = node->data.fn_call_expr.params.at(0); | 6112 | AstNode *type_node = node->data.fn_call_expr.params.at(0); |
| ... | @@ -5083,26 +6114,26 @@ static IrInstruction *ir_gen_mul_add(IrBuilder *irb, Scope *scope, AstNode *node | ... | @@ -5083,26 +6114,26 @@ static IrInstruction *ir_gen_mul_add(IrBuilder *irb, Scope *scope, AstNode *node |
| 5083 | AstNode *op2_node = node->data.fn_call_expr.params.at(2); | 6114 | AstNode *op2_node = node->data.fn_call_expr.params.at(2); |
| 5084 | AstNode *op3_node = node->data.fn_call_expr.params.at(3); | 6115 | AstNode *op3_node = node->data.fn_call_expr.params.at(3); |
| 5085 | | 6116 | |
| 5086 | IrInstruction *type_value = ir_gen_node(irb, type_node, scope); | 6117 | IrInstSrc *type_value = ir_gen_node(irb, type_node, scope); |
| 5087 | if (type_value == irb->codegen->invalid_instruction) | 6118 | if (type_value == irb->codegen->invalid_inst_src) |
| 5088 | return irb->codegen->invalid_instruction; | 6119 | return irb->codegen->invalid_inst_src; |
| 5089 | | 6120 | |
| 5090 | IrInstruction *op1 = ir_gen_node(irb, op1_node, scope); | 6121 | IrInstSrc *op1 = ir_gen_node(irb, op1_node, scope); |
| 5091 | if (op1 == irb->codegen->invalid_instruction) | 6122 | if (op1 == irb->codegen->invalid_inst_src) |
| 5092 | return irb->codegen->invalid_instruction; | 6123 | return irb->codegen->invalid_inst_src; |
| 5093 | | 6124 | |
| 5094 | IrInstruction *op2 = ir_gen_node(irb, op2_node, scope); | 6125 | IrInstSrc *op2 = ir_gen_node(irb, op2_node, scope); |
| 5095 | if (op2 == irb->codegen->invalid_instruction) | 6126 | if (op2 == irb->codegen->invalid_inst_src) |
| 5096 | return irb->codegen->invalid_instruction; | 6127 | return irb->codegen->invalid_inst_src; |
| 5097 | | 6128 | |
| 5098 | IrInstruction *op3 = ir_gen_node(irb, op3_node, scope); | 6129 | IrInstSrc *op3 = ir_gen_node(irb, op3_node, scope); |
| 5099 | if (op3 == irb->codegen->invalid_instruction) | 6130 | if (op3 == irb->codegen->invalid_inst_src) |
| 5100 | return irb->codegen->invalid_instruction; | 6131 | return irb->codegen->invalid_inst_src; |
| 5101 | | 6132 | |
| 5102 | return ir_build_mul_add(irb, scope, node, type_value, op1, op2, op3); | 6133 | return ir_build_mul_add_src(irb, scope, node, type_value, op1, op2, op3); |
| 5103 | } | 6134 | } |
| 5104 | | 6135 | |
| 5105 | static IrInstruction *ir_gen_this(IrBuilder *irb, Scope *orig_scope, AstNode *node) { | 6136 | static IrInstSrc *ir_gen_this(IrBuilderSrc *irb, Scope *orig_scope, AstNode *node) { |
| 5106 | for (Scope *it_scope = orig_scope; it_scope != nullptr; it_scope = it_scope->parent) { | 6137 | for (Scope *it_scope = orig_scope; it_scope != nullptr; it_scope = it_scope->parent) { |
| 5107 | if (it_scope->id == ScopeIdDecls) { | 6138 | if (it_scope->id == ScopeIdDecls) { |
| 5108 | ScopeDecls *decls_scope = (ScopeDecls *)it_scope; | 6139 | ScopeDecls *decls_scope = (ScopeDecls *)it_scope; |
| ... | @@ -5117,7 +6148,7 @@ static IrInstruction *ir_gen_this(IrBuilder *irb, Scope *orig_scope, AstNode *no | ... | @@ -5117,7 +6148,7 @@ static IrInstruction *ir_gen_this(IrBuilder *irb, Scope *orig_scope, AstNode *no |
| 5117 | zig_unreachable(); | 6148 | zig_unreachable(); |
| 5118 | } | 6149 | } |
| 5119 | | 6150 | |
| 5120 | static IrInstruction *ir_gen_async_call(IrBuilder *irb, Scope *scope, AstNode *await_node, AstNode *call_node, | 6151 | static IrInstSrc *ir_gen_async_call(IrBuilderSrc *irb, Scope *scope, AstNode *await_node, AstNode *call_node, |
| 5121 | LVal lval, ResultLoc *result_loc) | 6152 | LVal lval, ResultLoc *result_loc) |
| 5122 | { | 6153 | { |
| 5123 | size_t arg_offset = 3; | 6154 | size_t arg_offset = 3; |
| ... | @@ -5125,71 +6156,71 @@ static IrInstruction *ir_gen_async_call(IrBuilder *irb, Scope *scope, AstNode *a | ... | @@ -5125,71 +6156,71 @@ static IrInstruction *ir_gen_async_call(IrBuilder *irb, Scope *scope, AstNode *a |
| 5125 | add_node_error(irb->codegen, call_node, | 6156 | add_node_error(irb->codegen, call_node, |
| 5126 | buf_sprintf("expected at least %" ZIG_PRI_usize " arguments, found %" ZIG_PRI_usize, | 6157 | buf_sprintf("expected at least %" ZIG_PRI_usize " arguments, found %" ZIG_PRI_usize, |
| 5127 | arg_offset, call_node->data.fn_call_expr.params.length)); | 6158 | arg_offset, call_node->data.fn_call_expr.params.length)); |
| 5128 | return irb->codegen->invalid_instruction; | 6159 | return irb->codegen->invalid_inst_src; |
| 5129 | } | 6160 | } |
| 5130 | | 6161 | |
| 5131 | AstNode *bytes_node = call_node->data.fn_call_expr.params.at(0); | 6162 | AstNode *bytes_node = call_node->data.fn_call_expr.params.at(0); |
| 5132 | IrInstruction *bytes = ir_gen_node(irb, bytes_node, scope); | 6163 | IrInstSrc *bytes = ir_gen_node(irb, bytes_node, scope); |
| 5133 | if (bytes == irb->codegen->invalid_instruction) | 6164 | if (bytes == irb->codegen->invalid_inst_src) |
| 5134 | return bytes; | 6165 | return bytes; |
| 5135 | | 6166 | |
| 5136 | AstNode *ret_ptr_node = call_node->data.fn_call_expr.params.at(1); | 6167 | AstNode *ret_ptr_node = call_node->data.fn_call_expr.params.at(1); |
| 5137 | IrInstruction *ret_ptr = ir_gen_node(irb, ret_ptr_node, scope); | 6168 | IrInstSrc *ret_ptr = ir_gen_node(irb, ret_ptr_node, scope); |
| 5138 | if (ret_ptr == irb->codegen->invalid_instruction) | 6169 | if (ret_ptr == irb->codegen->invalid_inst_src) |
| 5139 | return ret_ptr; | 6170 | return ret_ptr; |
| 5140 | | 6171 | |
| 5141 | AstNode *fn_ref_node = call_node->data.fn_call_expr.params.at(2); | 6172 | AstNode *fn_ref_node = call_node->data.fn_call_expr.params.at(2); |
| 5142 | IrInstruction *fn_ref = ir_gen_node(irb, fn_ref_node, scope); | 6173 | IrInstSrc *fn_ref = ir_gen_node(irb, fn_ref_node, scope); |
| 5143 | if (fn_ref == irb->codegen->invalid_instruction) | 6174 | if (fn_ref == irb->codegen->invalid_inst_src) |
| 5144 | return fn_ref; | 6175 | return fn_ref; |
| 5145 | | 6176 | |
| 5146 | size_t arg_count = call_node->data.fn_call_expr.params.length - arg_offset; | 6177 | size_t arg_count = call_node->data.fn_call_expr.params.length - arg_offset; |
| 5147 | IrInstruction **args = allocate<IrInstruction*>(arg_count); | 6178 | IrInstSrc **args = allocate<IrInstSrc*>(arg_count); |
| 5148 | for (size_t i = 0; i < arg_count; i += 1) { | 6179 | for (size_t i = 0; i < arg_count; i += 1) { |
| 5149 | AstNode *arg_node = call_node->data.fn_call_expr.params.at(i + arg_offset); | 6180 | AstNode *arg_node = call_node->data.fn_call_expr.params.at(i + arg_offset); |
| 5150 | IrInstruction *arg = ir_gen_node(irb, arg_node, scope); | 6181 | IrInstSrc *arg = ir_gen_node(irb, arg_node, scope); |
| 5151 | if (arg == irb->codegen->invalid_instruction) | 6182 | if (arg == irb->codegen->invalid_inst_src) |
| 5152 | return arg; | 6183 | return arg; |
| 5153 | args[i] = arg; | 6184 | args[i] = arg; |
| 5154 | } | 6185 | } |
| 5155 | | 6186 | |
| 5156 | CallModifier modifier = (await_node == nullptr) ? CallModifierAsync : CallModifierNone; | 6187 | CallModifier modifier = (await_node == nullptr) ? CallModifierAsync : CallModifierNone; |
| 5157 | bool is_async_call_builtin = true; | 6188 | bool is_async_call_builtin = true; |
| 5158 | IrInstruction *call = ir_build_call_src(irb, scope, call_node, nullptr, fn_ref, arg_count, args, | 6189 | IrInstSrc *call = ir_build_call_src(irb, scope, call_node, nullptr, fn_ref, arg_count, args, |
| 5159 | ret_ptr, modifier, is_async_call_builtin, bytes, result_loc); | 6190 | ret_ptr, modifier, is_async_call_builtin, bytes, result_loc); |
| 5160 | return ir_lval_wrap(irb, scope, call, lval, result_loc); | 6191 | return ir_lval_wrap(irb, scope, call, lval, result_loc); |
| 5161 | } | 6192 | } |
| 5162 | | 6193 | |
| 5163 | static IrInstruction *ir_gen_fn_call_with_args(IrBuilder *irb, Scope *scope, AstNode *source_node, | 6194 | static IrInstSrc *ir_gen_fn_call_with_args(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 5164 | AstNode *fn_ref_node, CallModifier modifier, IrInstruction *options, | 6195 | AstNode *fn_ref_node, CallModifier modifier, IrInstSrc *options, |
| 5165 | AstNode **args_ptr, size_t args_len, LVal lval, ResultLoc *result_loc) | 6196 | AstNode **args_ptr, size_t args_len, LVal lval, ResultLoc *result_loc) |
| 5166 | { | 6197 | { |
| 5167 | IrInstruction *fn_ref = ir_gen_node(irb, fn_ref_node, scope); | 6198 | IrInstSrc *fn_ref = ir_gen_node(irb, fn_ref_node, scope); |
| 5168 | if (fn_ref == irb->codegen->invalid_instruction) | 6199 | if (fn_ref == irb->codegen->invalid_inst_src) |
| 5169 | return fn_ref; | 6200 | return fn_ref; |
| 5170 | | 6201 | |
| 5171 | IrInstruction *fn_type = ir_build_typeof(irb, scope, source_node, fn_ref); | 6202 | IrInstSrc *fn_type = ir_build_typeof(irb, scope, source_node, fn_ref); |
| 5172 | | 6203 | |
| 5173 | IrInstruction **args = allocate<IrInstruction*>(args_len); | 6204 | IrInstSrc **args = allocate<IrInstSrc*>(args_len); |
| 5174 | for (size_t i = 0; i < args_len; i += 1) { | 6205 | for (size_t i = 0; i < args_len; i += 1) { |
| 5175 | AstNode *arg_node = args_ptr[i]; | 6206 | AstNode *arg_node = args_ptr[i]; |
| 5176 | | 6207 | |
| 5177 | IrInstruction *arg_index = ir_build_const_usize(irb, scope, arg_node, i); | 6208 | IrInstSrc *arg_index = ir_build_const_usize(irb, scope, arg_node, i); |
| 5178 | IrInstruction *arg_type = ir_build_arg_type(irb, scope, source_node, fn_type, arg_index, true); | 6209 | IrInstSrc *arg_type = ir_build_arg_type(irb, scope, source_node, fn_type, arg_index, true); |
| 5179 | ResultLoc *no_result = no_result_loc(); | 6210 | ResultLoc *no_result = no_result_loc(); |
| 5180 | ir_build_reset_result(irb, scope, source_node, no_result); | 6211 | ir_build_reset_result(irb, scope, source_node, no_result); |
| 5181 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, arg_type, no_result); | 6212 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, arg_type, no_result); |
| 5182 | | 6213 | |
| 5183 | IrInstruction *arg = ir_gen_node_extra(irb, arg_node, scope, LValNone, &result_loc_cast->base); | 6214 | IrInstSrc *arg = ir_gen_node_extra(irb, arg_node, scope, LValNone, &result_loc_cast->base); |
| 5184 | if (arg == irb->codegen->invalid_instruction) | 6215 | if (arg == irb->codegen->invalid_inst_src) |
| 5185 | return arg; | 6216 | return arg; |
| 5186 | | 6217 | |
| 5187 | args[i] = ir_build_implicit_cast(irb, scope, arg_node, arg, result_loc_cast); | 6218 | args[i] = ir_build_implicit_cast(irb, scope, arg_node, arg, result_loc_cast); |
| 5188 | } | 6219 | } |
| 5189 | | 6220 | |
| 5190 | IrInstruction *fn_call; | 6221 | IrInstSrc *fn_call; |
| 5191 | if (options != nullptr) { | 6222 | if (options != nullptr) { |
| 5192 | fn_call = ir_build_call_src_args(irb, scope, source_node, options, fn_ref, args, args_len, result_loc); | 6223 | fn_call = ir_build_call_args(irb, scope, source_node, options, fn_ref, args, args_len, result_loc); |
| 5193 | } else { | 6224 | } else { |
| 5194 | fn_call = ir_build_call_src(irb, scope, source_node, nullptr, fn_ref, args_len, args, nullptr, | 6225 | fn_call = ir_build_call_src(irb, scope, source_node, nullptr, fn_ref, args_len, args, nullptr, |
| 5195 | modifier, false, nullptr, result_loc); | 6226 | modifier, false, nullptr, result_loc); |
| ... | @@ -5197,7 +6228,7 @@ static IrInstruction *ir_gen_fn_call_with_args(IrBuilder *irb, Scope *scope, Ast | ... | @@ -5197,7 +6228,7 @@ static IrInstruction *ir_gen_fn_call_with_args(IrBuilder *irb, Scope *scope, Ast |
| 5197 | return ir_lval_wrap(irb, scope, fn_call, lval, result_loc); | 6228 | return ir_lval_wrap(irb, scope, fn_call, lval, result_loc); |
| 5198 | } | 6229 | } |
| 5199 | | 6230 | |
| 5200 | static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 6231 | static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 5201 | ResultLoc *result_loc) | 6232 | ResultLoc *result_loc) |
| 5202 | { | 6233 | { |
| 5203 | assert(node->type == NodeTypeFnCallExpr); | 6234 | assert(node->type == NodeTypeFnCallExpr); |
| ... | @@ -5209,7 +6240,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -5209,7 +6240,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 5209 | if (!entry) { | 6240 | if (!entry) { |
| 5210 | add_node_error(irb->codegen, node, | 6241 | add_node_error(irb->codegen, node, |
| 5211 | buf_sprintf("invalid builtin function: '%s'", buf_ptr(name))); | 6242 | buf_sprintf("invalid builtin function: '%s'", buf_ptr(name))); |
| 5212 | return irb->codegen->invalid_instruction; | 6243 | return irb->codegen->invalid_inst_src; |
| 5213 | } | 6244 | } |
| 5214 | | 6245 | |
| 5215 | BuiltinFnEntry *builtin_fn = entry->value; | 6246 | BuiltinFnEntry *builtin_fn = entry->value; |
| ... | @@ -5219,7 +6250,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -5219,7 +6250,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 5219 | add_node_error(irb->codegen, node, | 6250 | add_node_error(irb->codegen, node, |
| 5220 | buf_sprintf("expected %" ZIG_PRI_usize " arguments, found %" ZIG_PRI_usize, | 6251 | buf_sprintf("expected %" ZIG_PRI_usize " arguments, found %" ZIG_PRI_usize, |
| 5221 | builtin_fn->param_count, actual_param_count)); | 6252 | builtin_fn->param_count, actual_param_count)); |
| 5222 | return irb->codegen->invalid_instruction; | 6253 | return irb->codegen->invalid_inst_src; |
| 5223 | } | 6254 | } |
| 5224 | | 6255 | |
| 5225 | switch (builtin_fn->id) { | 6256 | switch (builtin_fn->id) { |
| ... | @@ -5230,197 +6261,197 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -5230,197 +6261,197 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 5230 | Scope *sub_scope = create_typeof_scope(irb->codegen, node, scope); | 6261 | Scope *sub_scope = create_typeof_scope(irb->codegen, node, scope); |
| 5231 | | 6262 | |
| 5232 | AstNode *arg_node = node->data.fn_call_expr.params.at(0); | 6263 | AstNode *arg_node = node->data.fn_call_expr.params.at(0); |
| 5233 | IrInstruction *arg = ir_gen_node(irb, arg_node, sub_scope); | 6264 | IrInstSrc *arg = ir_gen_node(irb, arg_node, sub_scope); |
| 5234 | if (arg == irb->codegen->invalid_instruction) | 6265 | if (arg == irb->codegen->invalid_inst_src) |
| 5235 | return arg; | 6266 | return arg; |
| 5236 | | 6267 | |
| 5237 | IrInstruction *type_of = ir_build_typeof(irb, scope, node, arg); | 6268 | IrInstSrc *type_of = ir_build_typeof(irb, scope, node, arg); |
| 5238 | return ir_lval_wrap(irb, scope, type_of, lval, result_loc); | 6269 | return ir_lval_wrap(irb, scope, type_of, lval, result_loc); |
| 5239 | } | 6270 | } |
| 5240 | case BuiltinFnIdSetCold: | 6271 | case BuiltinFnIdSetCold: |
| 5241 | { | 6272 | { |
| 5242 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6273 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5243 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6274 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5244 | if (arg0_value == irb->codegen->invalid_instruction) | 6275 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5245 | return arg0_value; | 6276 | return arg0_value; |
| 5246 | | 6277 | |
| 5247 | IrInstruction *set_cold = ir_build_set_cold(irb, scope, node, arg0_value); | 6278 | IrInstSrc *set_cold = ir_build_set_cold(irb, scope, node, arg0_value); |
| 5248 | return ir_lval_wrap(irb, scope, set_cold, lval, result_loc); | 6279 | return ir_lval_wrap(irb, scope, set_cold, lval, result_loc); |
| 5249 | } | 6280 | } |
| 5250 | case BuiltinFnIdSetRuntimeSafety: | 6281 | case BuiltinFnIdSetRuntimeSafety: |
| 5251 | { | 6282 | { |
| 5252 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6283 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5253 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6284 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5254 | if (arg0_value == irb->codegen->invalid_instruction) | 6285 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5255 | return arg0_value; | 6286 | return arg0_value; |
| 5256 | | 6287 | |
| 5257 | IrInstruction *set_safety = ir_build_set_runtime_safety(irb, scope, node, arg0_value); | 6288 | IrInstSrc *set_safety = ir_build_set_runtime_safety(irb, scope, node, arg0_value); |
| 5258 | return ir_lval_wrap(irb, scope, set_safety, lval, result_loc); | 6289 | return ir_lval_wrap(irb, scope, set_safety, lval, result_loc); |
| 5259 | } | 6290 | } |
| 5260 | case BuiltinFnIdSetFloatMode: | 6291 | case BuiltinFnIdSetFloatMode: |
| 5261 | { | 6292 | { |
| 5262 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6293 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5263 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6294 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5264 | if (arg0_value == irb->codegen->invalid_instruction) | 6295 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5265 | return arg0_value; | 6296 | return arg0_value; |
| 5266 | | 6297 | |
| 5267 | IrInstruction *set_float_mode = ir_build_set_float_mode(irb, scope, node, arg0_value); | 6298 | IrInstSrc *set_float_mode = ir_build_set_float_mode(irb, scope, node, arg0_value); |
| 5268 | return ir_lval_wrap(irb, scope, set_float_mode, lval, result_loc); | 6299 | return ir_lval_wrap(irb, scope, set_float_mode, lval, result_loc); |
| 5269 | } | 6300 | } |
| 5270 | case BuiltinFnIdSizeof: | 6301 | case BuiltinFnIdSizeof: |
| 5271 | case BuiltinFnIdBitSizeof: | 6302 | case BuiltinFnIdBitSizeof: |
| 5272 | { | 6303 | { |
| 5273 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6304 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5274 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6305 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5275 | if (arg0_value == irb->codegen->invalid_instruction) | 6306 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5276 | return arg0_value; | 6307 | return arg0_value; |
| 5277 | | 6308 | |
| 5278 | IrInstruction *size_of = ir_build_size_of(irb, scope, node, arg0_value, builtin_fn->id == BuiltinFnIdBitSizeof); | 6309 | IrInstSrc *size_of = ir_build_size_of(irb, scope, node, arg0_value, builtin_fn->id == BuiltinFnIdBitSizeof); |
| 5279 | return ir_lval_wrap(irb, scope, size_of, lval, result_loc); | 6310 | return ir_lval_wrap(irb, scope, size_of, lval, result_loc); |
| 5280 | } | 6311 | } |
| 5281 | case BuiltinFnIdImport: | 6312 | case BuiltinFnIdImport: |
| 5282 | { | 6313 | { |
| 5283 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6314 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5284 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6315 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5285 | if (arg0_value == irb->codegen->invalid_instruction) | 6316 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5286 | return arg0_value; | 6317 | return arg0_value; |
| 5287 | | 6318 | |
| 5288 | IrInstruction *import = ir_build_import(irb, scope, node, arg0_value); | 6319 | IrInstSrc *import = ir_build_import(irb, scope, node, arg0_value); |
| 5289 | return ir_lval_wrap(irb, scope, import, lval, result_loc); | 6320 | return ir_lval_wrap(irb, scope, import, lval, result_loc); |
| 5290 | } | 6321 | } |
| 5291 | case BuiltinFnIdCImport: | 6322 | case BuiltinFnIdCImport: |
| 5292 | { | 6323 | { |
| 5293 | IrInstruction *c_import = ir_build_c_import(irb, scope, node); | 6324 | IrInstSrc *c_import = ir_build_c_import(irb, scope, node); |
| 5294 | return ir_lval_wrap(irb, scope, c_import, lval, result_loc); | 6325 | return ir_lval_wrap(irb, scope, c_import, lval, result_loc); |
| 5295 | } | 6326 | } |
| 5296 | case BuiltinFnIdCInclude: | 6327 | case BuiltinFnIdCInclude: |
| 5297 | { | 6328 | { |
| 5298 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6329 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5299 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6330 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5300 | if (arg0_value == irb->codegen->invalid_instruction) | 6331 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5301 | return arg0_value; | 6332 | return arg0_value; |
| 5302 | | 6333 | |
| 5303 | if (!exec_c_import_buf(irb->exec)) { | 6334 | if (!exec_c_import_buf(irb->exec)) { |
| 5304 | add_node_error(irb->codegen, node, buf_sprintf("C include valid only inside C import block")); | 6335 | add_node_error(irb->codegen, node, buf_sprintf("C include valid only inside C import block")); |
| 5305 | return irb->codegen->invalid_instruction; | 6336 | return irb->codegen->invalid_inst_src; |
| 5306 | } | 6337 | } |
| 5307 | | 6338 | |
| 5308 | IrInstruction *c_include = ir_build_c_include(irb, scope, node, arg0_value); | 6339 | IrInstSrc *c_include = ir_build_c_include(irb, scope, node, arg0_value); |
| 5309 | return ir_lval_wrap(irb, scope, c_include, lval, result_loc); | 6340 | return ir_lval_wrap(irb, scope, c_include, lval, result_loc); |
| 5310 | } | 6341 | } |
| 5311 | case BuiltinFnIdCDefine: | 6342 | case BuiltinFnIdCDefine: |
| 5312 | { | 6343 | { |
| 5313 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6344 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5314 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6345 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5315 | if (arg0_value == irb->codegen->invalid_instruction) | 6346 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5316 | return arg0_value; | 6347 | return arg0_value; |
| 5317 | | 6348 | |
| 5318 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6349 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5319 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6350 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5320 | if (arg1_value == irb->codegen->invalid_instruction) | 6351 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5321 | return arg1_value; | 6352 | return arg1_value; |
| 5322 | | 6353 | |
| 5323 | if (!exec_c_import_buf(irb->exec)) { | 6354 | if (!exec_c_import_buf(irb->exec)) { |
| 5324 | add_node_error(irb->codegen, node, buf_sprintf("C define valid only inside C import block")); | 6355 | add_node_error(irb->codegen, node, buf_sprintf("C define valid only inside C import block")); |
| 5325 | return irb->codegen->invalid_instruction; | 6356 | return irb->codegen->invalid_inst_src; |
| 5326 | } | 6357 | } |
| 5327 | | 6358 | |
| 5328 | IrInstruction *c_define = ir_build_c_define(irb, scope, node, arg0_value, arg1_value); | 6359 | IrInstSrc *c_define = ir_build_c_define(irb, scope, node, arg0_value, arg1_value); |
| 5329 | return ir_lval_wrap(irb, scope, c_define, lval, result_loc); | 6360 | return ir_lval_wrap(irb, scope, c_define, lval, result_loc); |
| 5330 | } | 6361 | } |
| 5331 | case BuiltinFnIdCUndef: | 6362 | case BuiltinFnIdCUndef: |
| 5332 | { | 6363 | { |
| 5333 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6364 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5334 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6365 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5335 | if (arg0_value == irb->codegen->invalid_instruction) | 6366 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5336 | return arg0_value; | 6367 | return arg0_value; |
| 5337 | | 6368 | |
| 5338 | if (!exec_c_import_buf(irb->exec)) { | 6369 | if (!exec_c_import_buf(irb->exec)) { |
| 5339 | add_node_error(irb->codegen, node, buf_sprintf("C undef valid only inside C import block")); | 6370 | add_node_error(irb->codegen, node, buf_sprintf("C undef valid only inside C import block")); |
| 5340 | return irb->codegen->invalid_instruction; | 6371 | return irb->codegen->invalid_inst_src; |
| 5341 | } | 6372 | } |
| 5342 | | 6373 | |
| 5343 | IrInstruction *c_undef = ir_build_c_undef(irb, scope, node, arg0_value); | 6374 | IrInstSrc *c_undef = ir_build_c_undef(irb, scope, node, arg0_value); |
| 5344 | return ir_lval_wrap(irb, scope, c_undef, lval, result_loc); | 6375 | return ir_lval_wrap(irb, scope, c_undef, lval, result_loc); |
| 5345 | } | 6376 | } |
| 5346 | case BuiltinFnIdCompileErr: | 6377 | case BuiltinFnIdCompileErr: |
| 5347 | { | 6378 | { |
| 5348 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6379 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5349 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6380 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5350 | if (arg0_value == irb->codegen->invalid_instruction) | 6381 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5351 | return arg0_value; | 6382 | return arg0_value; |
| 5352 | | 6383 | |
| 5353 | IrInstruction *compile_err = ir_build_compile_err(irb, scope, node, arg0_value); | 6384 | IrInstSrc *compile_err = ir_build_compile_err(irb, scope, node, arg0_value); |
| 5354 | return ir_lval_wrap(irb, scope, compile_err, lval, result_loc); | 6385 | return ir_lval_wrap(irb, scope, compile_err, lval, result_loc); |
| 5355 | } | 6386 | } |
| 5356 | case BuiltinFnIdCompileLog: | 6387 | case BuiltinFnIdCompileLog: |
| 5357 | { | 6388 | { |
| 5358 | IrInstruction **args = allocate<IrInstruction*>(actual_param_count); | 6389 | IrInstSrc **args = allocate<IrInstSrc*>(actual_param_count); |
| 5359 | | 6390 | |
| 5360 | for (size_t i = 0; i < actual_param_count; i += 1) { | 6391 | for (size_t i = 0; i < actual_param_count; i += 1) { |
| 5361 | AstNode *arg_node = node->data.fn_call_expr.params.at(i); | 6392 | AstNode *arg_node = node->data.fn_call_expr.params.at(i); |
| 5362 | args[i] = ir_gen_node(irb, arg_node, scope); | 6393 | args[i] = ir_gen_node(irb, arg_node, scope); |
| 5363 | if (args[i] == irb->codegen->invalid_instruction) | 6394 | if (args[i] == irb->codegen->invalid_inst_src) |
| 5364 | return irb->codegen->invalid_instruction; | 6395 | return irb->codegen->invalid_inst_src; |
| 5365 | } | 6396 | } |
| 5366 | | 6397 | |
| 5367 | IrInstruction *compile_log = ir_build_compile_log(irb, scope, node, actual_param_count, args); | 6398 | IrInstSrc *compile_log = ir_build_compile_log(irb, scope, node, actual_param_count, args); |
| 5368 | return ir_lval_wrap(irb, scope, compile_log, lval, result_loc); | 6399 | return ir_lval_wrap(irb, scope, compile_log, lval, result_loc); |
| 5369 | } | 6400 | } |
| 5370 | case BuiltinFnIdErrName: | 6401 | case BuiltinFnIdErrName: |
| 5371 | { | 6402 | { |
| 5372 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6403 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5373 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6404 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5374 | if (arg0_value == irb->codegen->invalid_instruction) | 6405 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5375 | return arg0_value; | 6406 | return arg0_value; |
| 5376 | | 6407 | |
| 5377 | IrInstruction *err_name = ir_build_err_name(irb, scope, node, arg0_value); | 6408 | IrInstSrc *err_name = ir_build_err_name(irb, scope, node, arg0_value); |
| 5378 | return ir_lval_wrap(irb, scope, err_name, lval, result_loc); | 6409 | return ir_lval_wrap(irb, scope, err_name, lval, result_loc); |
| 5379 | } | 6410 | } |
| 5380 | case BuiltinFnIdEmbedFile: | 6411 | case BuiltinFnIdEmbedFile: |
| 5381 | { | 6412 | { |
| 5382 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6413 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5383 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6414 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5384 | if (arg0_value == irb->codegen->invalid_instruction) | 6415 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5385 | return arg0_value; | 6416 | return arg0_value; |
| 5386 | | 6417 | |
| 5387 | IrInstruction *embed_file = ir_build_embed_file(irb, scope, node, arg0_value); | 6418 | IrInstSrc *embed_file = ir_build_embed_file(irb, scope, node, arg0_value); |
| 5388 | return ir_lval_wrap(irb, scope, embed_file, lval, result_loc); | 6419 | return ir_lval_wrap(irb, scope, embed_file, lval, result_loc); |
| 5389 | } | 6420 | } |
| 5390 | case BuiltinFnIdCmpxchgWeak: | 6421 | case BuiltinFnIdCmpxchgWeak: |
| 5391 | case BuiltinFnIdCmpxchgStrong: | 6422 | case BuiltinFnIdCmpxchgStrong: |
| 5392 | { | 6423 | { |
| 5393 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6424 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5394 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6425 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5395 | if (arg0_value == irb->codegen->invalid_instruction) | 6426 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5396 | return arg0_value; | 6427 | return arg0_value; |
| 5397 | | 6428 | |
| 5398 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6429 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5399 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6430 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5400 | if (arg1_value == irb->codegen->invalid_instruction) | 6431 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5401 | return arg1_value; | 6432 | return arg1_value; |
| 5402 | | 6433 | |
| 5403 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); | 6434 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 5404 | IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope); | 6435 | IrInstSrc *arg2_value = ir_gen_node(irb, arg2_node, scope); |
| 5405 | if (arg2_value == irb->codegen->invalid_instruction) | 6436 | if (arg2_value == irb->codegen->invalid_inst_src) |
| 5406 | return arg2_value; | 6437 | return arg2_value; |
| 5407 | | 6438 | |
| 5408 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); | 6439 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); |
| 5409 | IrInstruction *arg3_value = ir_gen_node(irb, arg3_node, scope); | 6440 | IrInstSrc *arg3_value = ir_gen_node(irb, arg3_node, scope); |
| 5410 | if (arg3_value == irb->codegen->invalid_instruction) | 6441 | if (arg3_value == irb->codegen->invalid_inst_src) |
| 5411 | return arg3_value; | 6442 | return arg3_value; |
| 5412 | | 6443 | |
| 5413 | AstNode *arg4_node = node->data.fn_call_expr.params.at(4); | 6444 | AstNode *arg4_node = node->data.fn_call_expr.params.at(4); |
| 5414 | IrInstruction *arg4_value = ir_gen_node(irb, arg4_node, scope); | 6445 | IrInstSrc *arg4_value = ir_gen_node(irb, arg4_node, scope); |
| 5415 | if (arg4_value == irb->codegen->invalid_instruction) | 6446 | if (arg4_value == irb->codegen->invalid_inst_src) |
| 5416 | return arg4_value; | 6447 | return arg4_value; |
| 5417 | | 6448 | |
| 5418 | AstNode *arg5_node = node->data.fn_call_expr.params.at(5); | 6449 | AstNode *arg5_node = node->data.fn_call_expr.params.at(5); |
| 5419 | IrInstruction *arg5_value = ir_gen_node(irb, arg5_node, scope); | 6450 | IrInstSrc *arg5_value = ir_gen_node(irb, arg5_node, scope); |
| 5420 | if (arg5_value == irb->codegen->invalid_instruction) | 6451 | if (arg5_value == irb->codegen->invalid_inst_src) |
| 5421 | return arg5_value; | 6452 | return arg5_value; |
| 5422 | | 6453 | |
| 5423 | IrInstruction *cmpxchg = ir_build_cmpxchg_src(irb, scope, node, arg0_value, arg1_value, | 6454 | IrInstSrc *cmpxchg = ir_build_cmpxchg_src(irb, scope, node, arg0_value, arg1_value, |
| 5424 | arg2_value, arg3_value, arg4_value, arg5_value, (builtin_fn->id == BuiltinFnIdCmpxchgWeak), | 6455 | arg2_value, arg3_value, arg4_value, arg5_value, (builtin_fn->id == BuiltinFnIdCmpxchgWeak), |
| 5425 | result_loc); | 6456 | result_loc); |
| 5426 | return ir_lval_wrap(irb, scope, cmpxchg, lval, result_loc); | 6457 | return ir_lval_wrap(irb, scope, cmpxchg, lval, result_loc); |
| ... | @@ -5428,86 +6459,86 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -5428,86 +6459,86 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 5428 | case BuiltinFnIdFence: | 6459 | case BuiltinFnIdFence: |
| 5429 | { | 6460 | { |
| 5430 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6461 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5431 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6462 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5432 | if (arg0_value == irb->codegen->invalid_instruction) | 6463 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5433 | return arg0_value; | 6464 | return arg0_value; |
| 5434 | | 6465 | |
| 5435 | IrInstruction *fence = ir_build_fence(irb, scope, node, arg0_value, AtomicOrderUnordered); | 6466 | IrInstSrc *fence = ir_build_fence(irb, scope, node, arg0_value); |
| 5436 | return ir_lval_wrap(irb, scope, fence, lval, result_loc); | 6467 | return ir_lval_wrap(irb, scope, fence, lval, result_loc); |
| 5437 | } | 6468 | } |
| 5438 | case BuiltinFnIdDivExact: | 6469 | case BuiltinFnIdDivExact: |
| 5439 | { | 6470 | { |
| 5440 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6471 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5441 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6472 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5442 | if (arg0_value == irb->codegen->invalid_instruction) | 6473 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5443 | return arg0_value; | 6474 | return arg0_value; |
| 5444 | | 6475 | |
| 5445 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6476 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5446 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6477 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5447 | if (arg1_value == irb->codegen->invalid_instruction) | 6478 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5448 | return arg1_value; | 6479 | return arg1_value; |
| 5449 | | 6480 | |
| 5450 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpDivExact, arg0_value, arg1_value, true); | 6481 | IrInstSrc *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpDivExact, arg0_value, arg1_value, true); |
| 5451 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); | 6482 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); |
| 5452 | } | 6483 | } |
| 5453 | case BuiltinFnIdDivTrunc: | 6484 | case BuiltinFnIdDivTrunc: |
| 5454 | { | 6485 | { |
| 5455 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6486 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5456 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6487 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5457 | if (arg0_value == irb->codegen->invalid_instruction) | 6488 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5458 | return arg0_value; | 6489 | return arg0_value; |
| 5459 | | 6490 | |
| 5460 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6491 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5461 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6492 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5462 | if (arg1_value == irb->codegen->invalid_instruction) | 6493 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5463 | return arg1_value; | 6494 | return arg1_value; |
| 5464 | | 6495 | |
| 5465 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpDivTrunc, arg0_value, arg1_value, true); | 6496 | IrInstSrc *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpDivTrunc, arg0_value, arg1_value, true); |
| 5466 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); | 6497 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); |
| 5467 | } | 6498 | } |
| 5468 | case BuiltinFnIdDivFloor: | 6499 | case BuiltinFnIdDivFloor: |
| 5469 | { | 6500 | { |
| 5470 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6501 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5471 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6502 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5472 | if (arg0_value == irb->codegen->invalid_instruction) | 6503 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5473 | return arg0_value; | 6504 | return arg0_value; |
| 5474 | | 6505 | |
| 5475 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6506 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5476 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6507 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5477 | if (arg1_value == irb->codegen->invalid_instruction) | 6508 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5478 | return arg1_value; | 6509 | return arg1_value; |
| 5479 | | 6510 | |
| 5480 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpDivFloor, arg0_value, arg1_value, true); | 6511 | IrInstSrc *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpDivFloor, arg0_value, arg1_value, true); |
| 5481 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); | 6512 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); |
| 5482 | } | 6513 | } |
| 5483 | case BuiltinFnIdRem: | 6514 | case BuiltinFnIdRem: |
| 5484 | { | 6515 | { |
| 5485 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6516 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5486 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6517 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5487 | if (arg0_value == irb->codegen->invalid_instruction) | 6518 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5488 | return arg0_value; | 6519 | return arg0_value; |
| 5489 | | 6520 | |
| 5490 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6521 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5491 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6522 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5492 | if (arg1_value == irb->codegen->invalid_instruction) | 6523 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5493 | return arg1_value; | 6524 | return arg1_value; |
| 5494 | | 6525 | |
| 5495 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpRemRem, arg0_value, arg1_value, true); | 6526 | IrInstSrc *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpRemRem, arg0_value, arg1_value, true); |
| 5496 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); | 6527 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); |
| 5497 | } | 6528 | } |
| 5498 | case BuiltinFnIdMod: | 6529 | case BuiltinFnIdMod: |
| 5499 | { | 6530 | { |
| 5500 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6531 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5501 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6532 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5502 | if (arg0_value == irb->codegen->invalid_instruction) | 6533 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5503 | return arg0_value; | 6534 | return arg0_value; |
| 5504 | | 6535 | |
| 5505 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6536 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5506 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6537 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5507 | if (arg1_value == irb->codegen->invalid_instruction) | 6538 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5508 | return arg1_value; | 6539 | return arg1_value; |
| 5509 | | 6540 | |
| 5510 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpRemMod, arg0_value, arg1_value, true); | 6541 | IrInstSrc *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpRemMod, arg0_value, arg1_value, true); |
| 5511 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); | 6542 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); |
| 5512 | } | 6543 | } |
| 5513 | case BuiltinFnIdSqrt: | 6544 | case BuiltinFnIdSqrt: |
| ... | @@ -5526,406 +6557,406 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -5526,406 +6557,406 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 5526 | case BuiltinFnIdRound: | 6557 | case BuiltinFnIdRound: |
| 5527 | { | 6558 | { |
| 5528 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6559 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5529 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6560 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5530 | if (arg0_value == irb->codegen->invalid_instruction) | 6561 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5531 | return arg0_value; | 6562 | return arg0_value; |
| 5532 | | 6563 | |
| 5533 | IrInstruction *inst = ir_build_float_op(irb, scope, node, arg0_value, builtin_fn->id); | 6564 | IrInstSrc *inst = ir_build_float_op_src(irb, scope, node, arg0_value, builtin_fn->id); |
| 5534 | return ir_lval_wrap(irb, scope, inst, lval, result_loc); | 6565 | return ir_lval_wrap(irb, scope, inst, lval, result_loc); |
| 5535 | } | 6566 | } |
| 5536 | case BuiltinFnIdTruncate: | 6567 | case BuiltinFnIdTruncate: |
| 5537 | { | 6568 | { |
| 5538 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6569 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5539 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6570 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5540 | if (arg0_value == irb->codegen->invalid_instruction) | 6571 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5541 | return arg0_value; | 6572 | return arg0_value; |
| 5542 | | 6573 | |
| 5543 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6574 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5544 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6575 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5545 | if (arg1_value == irb->codegen->invalid_instruction) | 6576 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5546 | return arg1_value; | 6577 | return arg1_value; |
| 5547 | | 6578 | |
| 5548 | IrInstruction *truncate = ir_build_truncate(irb, scope, node, arg0_value, arg1_value); | 6579 | IrInstSrc *truncate = ir_build_truncate(irb, scope, node, arg0_value, arg1_value); |
| 5549 | return ir_lval_wrap(irb, scope, truncate, lval, result_loc); | 6580 | return ir_lval_wrap(irb, scope, truncate, lval, result_loc); |
| 5550 | } | 6581 | } |
| 5551 | case BuiltinFnIdIntCast: | 6582 | case BuiltinFnIdIntCast: |
| 5552 | { | 6583 | { |
| 5553 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6584 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5554 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6585 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5555 | if (arg0_value == irb->codegen->invalid_instruction) | 6586 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5556 | return arg0_value; | 6587 | return arg0_value; |
| 5557 | | 6588 | |
| 5558 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6589 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5559 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6590 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5560 | if (arg1_value == irb->codegen->invalid_instruction) | 6591 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5561 | return arg1_value; | 6592 | return arg1_value; |
| 5562 | | 6593 | |
| 5563 | IrInstruction *result = ir_build_int_cast(irb, scope, node, arg0_value, arg1_value); | 6594 | IrInstSrc *result = ir_build_int_cast(irb, scope, node, arg0_value, arg1_value); |
| 5564 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6595 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5565 | } | 6596 | } |
| 5566 | case BuiltinFnIdFloatCast: | 6597 | case BuiltinFnIdFloatCast: |
| 5567 | { | 6598 | { |
| 5568 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6599 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5569 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6600 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5570 | if (arg0_value == irb->codegen->invalid_instruction) | 6601 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5571 | return arg0_value; | 6602 | return arg0_value; |
| 5572 | | 6603 | |
| 5573 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6604 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5574 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6605 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5575 | if (arg1_value == irb->codegen->invalid_instruction) | 6606 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5576 | return arg1_value; | 6607 | return arg1_value; |
| 5577 | | 6608 | |
| 5578 | IrInstruction *result = ir_build_float_cast(irb, scope, node, arg0_value, arg1_value); | 6609 | IrInstSrc *result = ir_build_float_cast(irb, scope, node, arg0_value, arg1_value); |
| 5579 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6610 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5580 | } | 6611 | } |
| 5581 | case BuiltinFnIdErrSetCast: | 6612 | case BuiltinFnIdErrSetCast: |
| 5582 | { | 6613 | { |
| 5583 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6614 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5584 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6615 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5585 | if (arg0_value == irb->codegen->invalid_instruction) | 6616 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5586 | return arg0_value; | 6617 | return arg0_value; |
| 5587 | | 6618 | |
| 5588 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6619 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5589 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6620 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5590 | if (arg1_value == irb->codegen->invalid_instruction) | 6621 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5591 | return arg1_value; | 6622 | return arg1_value; |
| 5592 | | 6623 | |
| 5593 | IrInstruction *result = ir_build_err_set_cast(irb, scope, node, arg0_value, arg1_value); | 6624 | IrInstSrc *result = ir_build_err_set_cast(irb, scope, node, arg0_value, arg1_value); |
| 5594 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6625 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5595 | } | 6626 | } |
| 5596 | case BuiltinFnIdFromBytes: | 6627 | case BuiltinFnIdFromBytes: |
| 5597 | { | 6628 | { |
| 5598 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6629 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5599 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6630 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5600 | if (arg0_value == irb->codegen->invalid_instruction) | 6631 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5601 | return arg0_value; | 6632 | return arg0_value; |
| 5602 | | 6633 | |
| 5603 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6634 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5604 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6635 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5605 | if (arg1_value == irb->codegen->invalid_instruction) | 6636 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5606 | return arg1_value; | 6637 | return arg1_value; |
| 5607 | | 6638 | |
| 5608 | IrInstruction *result = ir_build_from_bytes(irb, scope, node, arg0_value, arg1_value, result_loc); | 6639 | IrInstSrc *result = ir_build_from_bytes(irb, scope, node, arg0_value, arg1_value, result_loc); |
| 5609 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6640 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5610 | } | 6641 | } |
| 5611 | case BuiltinFnIdToBytes: | 6642 | case BuiltinFnIdToBytes: |
| 5612 | { | 6643 | { |
| 5613 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6644 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5614 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6645 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5615 | if (arg0_value == irb->codegen->invalid_instruction) | 6646 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5616 | return arg0_value; | 6647 | return arg0_value; |
| 5617 | | 6648 | |
| 5618 | IrInstruction *result = ir_build_to_bytes(irb, scope, node, arg0_value, result_loc); | 6649 | IrInstSrc *result = ir_build_to_bytes(irb, scope, node, arg0_value, result_loc); |
| 5619 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6650 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5620 | } | 6651 | } |
| 5621 | case BuiltinFnIdIntToFloat: | 6652 | case BuiltinFnIdIntToFloat: |
| 5622 | { | 6653 | { |
| 5623 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6654 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5624 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6655 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5625 | if (arg0_value == irb->codegen->invalid_instruction) | 6656 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5626 | return arg0_value; | 6657 | return arg0_value; |
| 5627 | | 6658 | |
| 5628 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6659 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5629 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6660 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5630 | if (arg1_value == irb->codegen->invalid_instruction) | 6661 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5631 | return arg1_value; | 6662 | return arg1_value; |
| 5632 | | 6663 | |
| 5633 | IrInstruction *result = ir_build_int_to_float(irb, scope, node, arg0_value, arg1_value); | 6664 | IrInstSrc *result = ir_build_int_to_float(irb, scope, node, arg0_value, arg1_value); |
| 5634 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6665 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5635 | } | 6666 | } |
| 5636 | case BuiltinFnIdFloatToInt: | 6667 | case BuiltinFnIdFloatToInt: |
| 5637 | { | 6668 | { |
| 5638 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6669 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5639 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6670 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5640 | if (arg0_value == irb->codegen->invalid_instruction) | 6671 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5641 | return arg0_value; | 6672 | return arg0_value; |
| 5642 | | 6673 | |
| 5643 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6674 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5644 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6675 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5645 | if (arg1_value == irb->codegen->invalid_instruction) | 6676 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5646 | return arg1_value; | 6677 | return arg1_value; |
| 5647 | | 6678 | |
| 5648 | IrInstruction *result = ir_build_float_to_int(irb, scope, node, arg0_value, arg1_value); | 6679 | IrInstSrc *result = ir_build_float_to_int(irb, scope, node, arg0_value, arg1_value); |
| 5649 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6680 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5650 | } | 6681 | } |
| 5651 | case BuiltinFnIdErrToInt: | 6682 | case BuiltinFnIdErrToInt: |
| 5652 | { | 6683 | { |
| 5653 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6684 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5654 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6685 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5655 | if (arg0_value == irb->codegen->invalid_instruction) | 6686 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5656 | return arg0_value; | 6687 | return arg0_value; |
| 5657 | | 6688 | |
| 5658 | IrInstruction *result = ir_build_err_to_int(irb, scope, node, arg0_value); | 6689 | IrInstSrc *result = ir_build_err_to_int_src(irb, scope, node, arg0_value); |
| 5659 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6690 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5660 | } | 6691 | } |
| 5661 | case BuiltinFnIdIntToErr: | 6692 | case BuiltinFnIdIntToErr: |
| 5662 | { | 6693 | { |
| 5663 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6694 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5664 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6695 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5665 | if (arg0_value == irb->codegen->invalid_instruction) | 6696 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5666 | return arg0_value; | 6697 | return arg0_value; |
| 5667 | | 6698 | |
| 5668 | IrInstruction *result = ir_build_int_to_err(irb, scope, node, arg0_value); | 6699 | IrInstSrc *result = ir_build_int_to_err_src(irb, scope, node, arg0_value); |
| 5669 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6700 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5670 | } | 6701 | } |
| 5671 | case BuiltinFnIdBoolToInt: | 6702 | case BuiltinFnIdBoolToInt: |
| 5672 | { | 6703 | { |
| 5673 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6704 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5674 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6705 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5675 | if (arg0_value == irb->codegen->invalid_instruction) | 6706 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5676 | return arg0_value; | 6707 | return arg0_value; |
| 5677 | | 6708 | |
| 5678 | IrInstruction *result = ir_build_bool_to_int(irb, scope, node, arg0_value); | 6709 | IrInstSrc *result = ir_build_bool_to_int(irb, scope, node, arg0_value); |
| 5679 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6710 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5680 | } | 6711 | } |
| 5681 | case BuiltinFnIdIntType: | 6712 | case BuiltinFnIdIntType: |
| 5682 | { | 6713 | { |
| 5683 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6714 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5684 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6715 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5685 | if (arg0_value == irb->codegen->invalid_instruction) | 6716 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5686 | return arg0_value; | 6717 | return arg0_value; |
| 5687 | | 6718 | |
| 5688 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6719 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5689 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6720 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5690 | if (arg1_value == irb->codegen->invalid_instruction) | 6721 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5691 | return arg1_value; | 6722 | return arg1_value; |
| 5692 | | 6723 | |
| 5693 | IrInstruction *int_type = ir_build_int_type(irb, scope, node, arg0_value, arg1_value); | 6724 | IrInstSrc *int_type = ir_build_int_type(irb, scope, node, arg0_value, arg1_value); |
| 5694 | return ir_lval_wrap(irb, scope, int_type, lval, result_loc); | 6725 | return ir_lval_wrap(irb, scope, int_type, lval, result_loc); |
| 5695 | } | 6726 | } |
| 5696 | case BuiltinFnIdVectorType: | 6727 | case BuiltinFnIdVectorType: |
| 5697 | { | 6728 | { |
| 5698 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6729 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5699 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6730 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5700 | if (arg0_value == irb->codegen->invalid_instruction) | 6731 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5701 | return arg0_value; | 6732 | return arg0_value; |
| 5702 | | 6733 | |
| 5703 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6734 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5704 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6735 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5705 | if (arg1_value == irb->codegen->invalid_instruction) | 6736 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5706 | return arg1_value; | 6737 | return arg1_value; |
| 5707 | | 6738 | |
| 5708 | IrInstruction *vector_type = ir_build_vector_type(irb, scope, node, arg0_value, arg1_value); | 6739 | IrInstSrc *vector_type = ir_build_vector_type(irb, scope, node, arg0_value, arg1_value); |
| 5709 | return ir_lval_wrap(irb, scope, vector_type, lval, result_loc); | 6740 | return ir_lval_wrap(irb, scope, vector_type, lval, result_loc); |
| 5710 | } | 6741 | } |
| 5711 | case BuiltinFnIdShuffle: | 6742 | case BuiltinFnIdShuffle: |
| 5712 | { | 6743 | { |
| 5713 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6744 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5714 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6745 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5715 | if (arg0_value == irb->codegen->invalid_instruction) | 6746 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5716 | return arg0_value; | 6747 | return arg0_value; |
| 5717 | | 6748 | |
| 5718 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6749 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5719 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6750 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5720 | if (arg1_value == irb->codegen->invalid_instruction) | 6751 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5721 | return arg1_value; | 6752 | return arg1_value; |
| 5722 | | 6753 | |
| 5723 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); | 6754 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 5724 | IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope); | 6755 | IrInstSrc *arg2_value = ir_gen_node(irb, arg2_node, scope); |
| 5725 | if (arg2_value == irb->codegen->invalid_instruction) | 6756 | if (arg2_value == irb->codegen->invalid_inst_src) |
| 5726 | return arg2_value; | 6757 | return arg2_value; |
| 5727 | | 6758 | |
| 5728 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); | 6759 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); |
| 5729 | IrInstruction *arg3_value = ir_gen_node(irb, arg3_node, scope); | 6760 | IrInstSrc *arg3_value = ir_gen_node(irb, arg3_node, scope); |
| 5730 | if (arg3_value == irb->codegen->invalid_instruction) | 6761 | if (arg3_value == irb->codegen->invalid_inst_src) |
| 5731 | return arg3_value; | 6762 | return arg3_value; |
| 5732 | | 6763 | |
| 5733 | IrInstruction *shuffle_vector = ir_build_shuffle_vector(irb, scope, node, | 6764 | IrInstSrc *shuffle_vector = ir_build_shuffle_vector(irb, scope, node, |
| 5734 | arg0_value, arg1_value, arg2_value, arg3_value); | 6765 | arg0_value, arg1_value, arg2_value, arg3_value); |
| 5735 | return ir_lval_wrap(irb, scope, shuffle_vector, lval, result_loc); | 6766 | return ir_lval_wrap(irb, scope, shuffle_vector, lval, result_loc); |
| 5736 | } | 6767 | } |
| 5737 | case BuiltinFnIdSplat: | 6768 | case BuiltinFnIdSplat: |
| 5738 | { | 6769 | { |
| 5739 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6770 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5740 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6771 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5741 | if (arg0_value == irb->codegen->invalid_instruction) | 6772 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5742 | return arg0_value; | 6773 | return arg0_value; |
| 5743 | | 6774 | |
| 5744 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6775 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5745 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6776 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5746 | if (arg1_value == irb->codegen->invalid_instruction) | 6777 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5747 | return arg1_value; | 6778 | return arg1_value; |
| 5748 | | 6779 | |
| 5749 | IrInstruction *splat = ir_build_splat_src(irb, scope, node, | 6780 | IrInstSrc *splat = ir_build_splat_src(irb, scope, node, |
| 5750 | arg0_value, arg1_value); | 6781 | arg0_value, arg1_value); |
| 5751 | return ir_lval_wrap(irb, scope, splat, lval, result_loc); | 6782 | return ir_lval_wrap(irb, scope, splat, lval, result_loc); |
| 5752 | } | 6783 | } |
| 5753 | case BuiltinFnIdMemcpy: | 6784 | case BuiltinFnIdMemcpy: |
| 5754 | { | 6785 | { |
| 5755 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6786 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5756 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6787 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5757 | if (arg0_value == irb->codegen->invalid_instruction) | 6788 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5758 | return arg0_value; | 6789 | return arg0_value; |
| 5759 | | 6790 | |
| 5760 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6791 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5761 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6792 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5762 | if (arg1_value == irb->codegen->invalid_instruction) | 6793 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5763 | return arg1_value; | 6794 | return arg1_value; |
| 5764 | | 6795 | |
| 5765 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); | 6796 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 5766 | IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope); | 6797 | IrInstSrc *arg2_value = ir_gen_node(irb, arg2_node, scope); |
| 5767 | if (arg2_value == irb->codegen->invalid_instruction) | 6798 | if (arg2_value == irb->codegen->invalid_inst_src) |
| 5768 | return arg2_value; | 6799 | return arg2_value; |
| 5769 | | 6800 | |
| 5770 | IrInstruction *ir_memcpy = ir_build_memcpy(irb, scope, node, arg0_value, arg1_value, arg2_value); | 6801 | IrInstSrc *ir_memcpy = ir_build_memcpy_src(irb, scope, node, arg0_value, arg1_value, arg2_value); |
| 5771 | return ir_lval_wrap(irb, scope, ir_memcpy, lval, result_loc); | 6802 | return ir_lval_wrap(irb, scope, ir_memcpy, lval, result_loc); |
| 5772 | } | 6803 | } |
| 5773 | case BuiltinFnIdMemset: | 6804 | case BuiltinFnIdMemset: |
| 5774 | { | 6805 | { |
| 5775 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6806 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5776 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6807 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5777 | if (arg0_value == irb->codegen->invalid_instruction) | 6808 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5778 | return arg0_value; | 6809 | return arg0_value; |
| 5779 | | 6810 | |
| 5780 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6811 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5781 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6812 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5782 | if (arg1_value == irb->codegen->invalid_instruction) | 6813 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5783 | return arg1_value; | 6814 | return arg1_value; |
| 5784 | | 6815 | |
| 5785 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); | 6816 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 5786 | IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope); | 6817 | IrInstSrc *arg2_value = ir_gen_node(irb, arg2_node, scope); |
| 5787 | if (arg2_value == irb->codegen->invalid_instruction) | 6818 | if (arg2_value == irb->codegen->invalid_inst_src) |
| 5788 | return arg2_value; | 6819 | return arg2_value; |
| 5789 | | 6820 | |
| 5790 | IrInstruction *ir_memset = ir_build_memset(irb, scope, node, arg0_value, arg1_value, arg2_value); | 6821 | IrInstSrc *ir_memset = ir_build_memset_src(irb, scope, node, arg0_value, arg1_value, arg2_value); |
| 5791 | return ir_lval_wrap(irb, scope, ir_memset, lval, result_loc); | 6822 | return ir_lval_wrap(irb, scope, ir_memset, lval, result_loc); |
| 5792 | } | 6823 | } |
| 5793 | case BuiltinFnIdMemberCount: | 6824 | case BuiltinFnIdMemberCount: |
| 5794 | { | 6825 | { |
| 5795 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6826 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5796 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6827 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5797 | if (arg0_value == irb->codegen->invalid_instruction) | 6828 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5798 | return arg0_value; | 6829 | return arg0_value; |
| 5799 | | 6830 | |
| 5800 | IrInstruction *member_count = ir_build_member_count(irb, scope, node, arg0_value); | 6831 | IrInstSrc *member_count = ir_build_member_count(irb, scope, node, arg0_value); |
| 5801 | return ir_lval_wrap(irb, scope, member_count, lval, result_loc); | 6832 | return ir_lval_wrap(irb, scope, member_count, lval, result_loc); |
| 5802 | } | 6833 | } |
| 5803 | case BuiltinFnIdMemberType: | 6834 | case BuiltinFnIdMemberType: |
| 5804 | { | 6835 | { |
| 5805 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6836 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5806 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6837 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5807 | if (arg0_value == irb->codegen->invalid_instruction) | 6838 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5808 | return arg0_value; | 6839 | return arg0_value; |
| 5809 | | 6840 | |
| 5810 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6841 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5811 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6842 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5812 | if (arg1_value == irb->codegen->invalid_instruction) | 6843 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5813 | return arg1_value; | 6844 | return arg1_value; |
| 5814 | | 6845 | |
| 5815 | | 6846 | |
| 5816 | IrInstruction *member_type = ir_build_member_type(irb, scope, node, arg0_value, arg1_value); | 6847 | IrInstSrc *member_type = ir_build_member_type(irb, scope, node, arg0_value, arg1_value); |
| 5817 | return ir_lval_wrap(irb, scope, member_type, lval, result_loc); | 6848 | return ir_lval_wrap(irb, scope, member_type, lval, result_loc); |
| 5818 | } | 6849 | } |
| 5819 | case BuiltinFnIdMemberName: | 6850 | case BuiltinFnIdMemberName: |
| 5820 | { | 6851 | { |
| 5821 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6852 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5822 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6853 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5823 | if (arg0_value == irb->codegen->invalid_instruction) | 6854 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5824 | return arg0_value; | 6855 | return arg0_value; |
| 5825 | | 6856 | |
| 5826 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6857 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5827 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6858 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5828 | if (arg1_value == irb->codegen->invalid_instruction) | 6859 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5829 | return arg1_value; | 6860 | return arg1_value; |
| 5830 | | 6861 | |
| 5831 | | 6862 | |
| 5832 | IrInstruction *member_name = ir_build_member_name(irb, scope, node, arg0_value, arg1_value); | 6863 | IrInstSrc *member_name = ir_build_member_name(irb, scope, node, arg0_value, arg1_value); |
| 5833 | return ir_lval_wrap(irb, scope, member_name, lval, result_loc); | 6864 | return ir_lval_wrap(irb, scope, member_name, lval, result_loc); |
| 5834 | } | 6865 | } |
| 5835 | case BuiltinFnIdField: | 6866 | case BuiltinFnIdField: |
| 5836 | { | 6867 | { |
| 5837 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6868 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5838 | IrInstruction *arg0_value = ir_gen_node_extra(irb, arg0_node, scope, LValPtr, nullptr); | 6869 | IrInstSrc *arg0_value = ir_gen_node_extra(irb, arg0_node, scope, LValPtr, nullptr); |
| 5839 | if (arg0_value == irb->codegen->invalid_instruction) | 6870 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5840 | return arg0_value; | 6871 | return arg0_value; |
| 5841 | | 6872 | |
| 5842 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6873 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5843 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6874 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5844 | if (arg1_value == irb->codegen->invalid_instruction) | 6875 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5845 | return arg1_value; | 6876 | return arg1_value; |
| 5846 | | 6877 | |
| 5847 | IrInstruction *ptr_instruction = ir_build_field_ptr_instruction(irb, scope, node, | 6878 | IrInstSrc *ptr_instruction = ir_build_field_ptr_instruction(irb, scope, node, |
| 5848 | arg0_value, arg1_value, false); | 6879 | arg0_value, arg1_value, false); |
| 5849 | | 6880 | |
| 5850 | if (lval == LValPtr) | 6881 | if (lval == LValPtr) |
| 5851 | return ptr_instruction; | 6882 | return ptr_instruction; |
| 5852 | | 6883 | |
| 5853 | IrInstruction *load_ptr = ir_build_load_ptr(irb, scope, node, ptr_instruction); | 6884 | IrInstSrc *load_ptr = ir_build_load_ptr(irb, scope, node, ptr_instruction); |
| 5854 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); | 6885 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); |
| 5855 | } | 6886 | } |
| 5856 | case BuiltinFnIdHasField: | 6887 | case BuiltinFnIdHasField: |
| 5857 | { | 6888 | { |
| 5858 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6889 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5859 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6890 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5860 | if (arg0_value == irb->codegen->invalid_instruction) | 6891 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5861 | return arg0_value; | 6892 | return arg0_value; |
| 5862 | | 6893 | |
| 5863 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6894 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5864 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6895 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5865 | if (arg1_value == irb->codegen->invalid_instruction) | 6896 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5866 | return arg1_value; | 6897 | return arg1_value; |
| 5867 | | 6898 | |
| 5868 | IrInstruction *type_info = ir_build_has_field(irb, scope, node, arg0_value, arg1_value); | 6899 | IrInstSrc *type_info = ir_build_has_field(irb, scope, node, arg0_value, arg1_value); |
| 5869 | return ir_lval_wrap(irb, scope, type_info, lval, result_loc); | 6900 | return ir_lval_wrap(irb, scope, type_info, lval, result_loc); |
| 5870 | } | 6901 | } |
| 5871 | case BuiltinFnIdTypeInfo: | 6902 | case BuiltinFnIdTypeInfo: |
| 5872 | { | 6903 | { |
| 5873 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6904 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5874 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6905 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5875 | if (arg0_value == irb->codegen->invalid_instruction) | 6906 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5876 | return arg0_value; | 6907 | return arg0_value; |
| 5877 | | 6908 | |
| 5878 | IrInstruction *type_info = ir_build_type_info(irb, scope, node, arg0_value); | 6909 | IrInstSrc *type_info = ir_build_type_info(irb, scope, node, arg0_value); |
| 5879 | return ir_lval_wrap(irb, scope, type_info, lval, result_loc); | 6910 | return ir_lval_wrap(irb, scope, type_info, lval, result_loc); |
| 5880 | } | 6911 | } |
| 5881 | case BuiltinFnIdType: | 6912 | case BuiltinFnIdType: |
| 5882 | { | 6913 | { |
| 5883 | AstNode *arg_node = node->data.fn_call_expr.params.at(0); | 6914 | AstNode *arg_node = node->data.fn_call_expr.params.at(0); |
| 5884 | IrInstruction *arg = ir_gen_node(irb, arg_node, scope); | 6915 | IrInstSrc *arg = ir_gen_node(irb, arg_node, scope); |
| 5885 | if (arg == irb->codegen->invalid_instruction) | 6916 | if (arg == irb->codegen->invalid_inst_src) |
| 5886 | return arg; | 6917 | return arg; |
| 5887 | | 6918 | |
| 5888 | IrInstruction *type = ir_build_type(irb, scope, node, arg); | 6919 | IrInstSrc *type = ir_build_type(irb, scope, node, arg); |
| 5889 | return ir_lval_wrap(irb, scope, type, lval, result_loc); | 6920 | return ir_lval_wrap(irb, scope, type, lval, result_loc); |
| 5890 | } | 6921 | } |
| 5891 | case BuiltinFnIdBreakpoint: | 6922 | case BuiltinFnIdBreakpoint: |
| 5892 | return ir_lval_wrap(irb, scope, ir_build_breakpoint(irb, scope, node), lval, result_loc); | 6923 | return ir_lval_wrap(irb, scope, ir_build_breakpoint(irb, scope, node), lval, result_loc); |
| 5893 | case BuiltinFnIdReturnAddress: | 6924 | case BuiltinFnIdReturnAddress: |
| 5894 | return ir_lval_wrap(irb, scope, ir_build_return_address(irb, scope, node), lval, result_loc); | 6925 | return ir_lval_wrap(irb, scope, ir_build_return_address_src(irb, scope, node), lval, result_loc); |
| 5895 | case BuiltinFnIdFrameAddress: | 6926 | case BuiltinFnIdFrameAddress: |
| 5896 | return ir_lval_wrap(irb, scope, ir_build_frame_address(irb, scope, node), lval, result_loc); | 6927 | return ir_lval_wrap(irb, scope, ir_build_frame_address_src(irb, scope, node), lval, result_loc); |
| 5897 | case BuiltinFnIdFrameHandle: | 6928 | case BuiltinFnIdFrameHandle: |
| 5898 | if (!irb->exec->fn_entry) { | 6929 | if (!irb->exec->fn_entry) { |
| 5899 | add_node_error(irb->codegen, node, buf_sprintf("@frame() called outside of function definition")); | 6930 | add_node_error(irb->codegen, node, buf_sprintf("@frame() called outside of function definition")); |
| 5900 | return irb->codegen->invalid_instruction; | 6931 | return irb->codegen->invalid_inst_src; |
| 5901 | } | 6932 | } |
| 5902 | return ir_lval_wrap(irb, scope, ir_build_handle(irb, scope, node), lval, result_loc); | 6933 | return ir_lval_wrap(irb, scope, ir_build_handle_src(irb, scope, node), lval, result_loc); |
| 5903 | case BuiltinFnIdFrameType: { | 6934 | case BuiltinFnIdFrameType: { |
| 5904 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6935 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5905 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6936 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5906 | if (arg0_value == irb->codegen->invalid_instruction) | 6937 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5907 | return arg0_value; | 6938 | return arg0_value; |
| 5908 | | 6939 | |
| 5909 | IrInstruction *frame_type = ir_build_frame_type(irb, scope, node, arg0_value); | 6940 | IrInstSrc *frame_type = ir_build_frame_type(irb, scope, node, arg0_value); |
| 5910 | return ir_lval_wrap(irb, scope, frame_type, lval, result_loc); | 6941 | return ir_lval_wrap(irb, scope, frame_type, lval, result_loc); |
| 5911 | } | 6942 | } |
| 5912 | case BuiltinFnIdFrameSize: { | 6943 | case BuiltinFnIdFrameSize: { |
| 5913 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6944 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5914 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6945 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5915 | if (arg0_value == irb->codegen->invalid_instruction) | 6946 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5916 | return arg0_value; | 6947 | return arg0_value; |
| 5917 | | 6948 | |
| 5918 | IrInstruction *frame_size = ir_build_frame_size_src(irb, scope, node, arg0_value); | 6949 | IrInstSrc *frame_size = ir_build_frame_size_src(irb, scope, node, arg0_value); |
| 5919 | return ir_lval_wrap(irb, scope, frame_size, lval, result_loc); | 6950 | return ir_lval_wrap(irb, scope, frame_size, lval, result_loc); |
| 5920 | } | 6951 | } |
| 5921 | case BuiltinFnIdAlignOf: | 6952 | case BuiltinFnIdAlignOf: |
| 5922 | { | 6953 | { |
| 5923 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6954 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5924 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6955 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5925 | if (arg0_value == irb->codegen->invalid_instruction) | 6956 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5926 | return arg0_value; | 6957 | return arg0_value; |
| 5927 | | 6958 | |
| 5928 | IrInstruction *align_of = ir_build_align_of(irb, scope, node, arg0_value); | 6959 | IrInstSrc *align_of = ir_build_align_of(irb, scope, node, arg0_value); |
| 5929 | return ir_lval_wrap(irb, scope, align_of, lval, result_loc); | 6960 | return ir_lval_wrap(irb, scope, align_of, lval, result_loc); |
| 5930 | } | 6961 | } |
| 5931 | case BuiltinFnIdAddWithOverflow: | 6962 | case BuiltinFnIdAddWithOverflow: |
| ... | @@ -5941,43 +6972,43 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -5941,43 +6972,43 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 5941 | case BuiltinFnIdTypeName: | 6972 | case BuiltinFnIdTypeName: |
| 5942 | { | 6973 | { |
| 5943 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6974 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5944 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6975 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5945 | if (arg0_value == irb->codegen->invalid_instruction) | 6976 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5946 | return arg0_value; | 6977 | return arg0_value; |
| 5947 | | 6978 | |
| 5948 | IrInstruction *type_name = ir_build_type_name(irb, scope, node, arg0_value); | 6979 | IrInstSrc *type_name = ir_build_type_name(irb, scope, node, arg0_value); |
| 5949 | return ir_lval_wrap(irb, scope, type_name, lval, result_loc); | 6980 | return ir_lval_wrap(irb, scope, type_name, lval, result_loc); |
| 5950 | } | 6981 | } |
| 5951 | case BuiltinFnIdPanic: | 6982 | case BuiltinFnIdPanic: |
| 5952 | { | 6983 | { |
| 5953 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6984 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5954 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6985 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5955 | if (arg0_value == irb->codegen->invalid_instruction) | 6986 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5956 | return arg0_value; | 6987 | return arg0_value; |
| 5957 | | 6988 | |
| 5958 | IrInstruction *panic = ir_build_panic(irb, scope, node, arg0_value); | 6989 | IrInstSrc *panic = ir_build_panic_src(irb, scope, node, arg0_value); |
| 5959 | return ir_lval_wrap(irb, scope, panic, lval, result_loc); | 6990 | return ir_lval_wrap(irb, scope, panic, lval, result_loc); |
| 5960 | } | 6991 | } |
| 5961 | case BuiltinFnIdPtrCast: | 6992 | case BuiltinFnIdPtrCast: |
| 5962 | { | 6993 | { |
| 5963 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6994 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5964 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6995 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5965 | if (arg0_value == irb->codegen->invalid_instruction) | 6996 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5966 | return arg0_value; | 6997 | return arg0_value; |
| 5967 | | 6998 | |
| 5968 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6999 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5969 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7000 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5970 | if (arg1_value == irb->codegen->invalid_instruction) | 7001 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5971 | return arg1_value; | 7002 | return arg1_value; |
| 5972 | | 7003 | |
| 5973 | IrInstruction *ptr_cast = ir_build_ptr_cast_src(irb, scope, node, arg0_value, arg1_value, true); | 7004 | IrInstSrc *ptr_cast = ir_build_ptr_cast_src(irb, scope, node, arg0_value, arg1_value, true); |
| 5974 | return ir_lval_wrap(irb, scope, ptr_cast, lval, result_loc); | 7005 | return ir_lval_wrap(irb, scope, ptr_cast, lval, result_loc); |
| 5975 | } | 7006 | } |
| 5976 | case BuiltinFnIdBitCast: | 7007 | case BuiltinFnIdBitCast: |
| 5977 | { | 7008 | { |
| 5978 | AstNode *dest_type_node = node->data.fn_call_expr.params.at(0); | 7009 | AstNode *dest_type_node = node->data.fn_call_expr.params.at(0); |
| 5979 | IrInstruction *dest_type = ir_gen_node(irb, dest_type_node, scope); | 7010 | IrInstSrc *dest_type = ir_gen_node(irb, dest_type_node, scope); |
| 5980 | if (dest_type == irb->codegen->invalid_instruction) | 7011 | if (dest_type == irb->codegen->invalid_inst_src) |
| 5981 | return dest_type; | 7012 | return dest_type; |
| 5982 | | 7013 | |
| 5983 | ResultLocBitCast *result_loc_bit_cast = allocate<ResultLocBitCast>(1); | 7014 | ResultLocBitCast *result_loc_bit_cast = allocate<ResultLocBitCast>(1); |
| ... | @@ -5989,126 +7020,126 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -5989,126 +7020,126 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 5989 | ir_build_reset_result(irb, scope, node, &result_loc_bit_cast->base); | 7020 | ir_build_reset_result(irb, scope, node, &result_loc_bit_cast->base); |
| 5990 | | 7021 | |
| 5991 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7022 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5992 | IrInstruction *arg1_value = ir_gen_node_extra(irb, arg1_node, scope, LValNone, | 7023 | IrInstSrc *arg1_value = ir_gen_node_extra(irb, arg1_node, scope, LValNone, |
| 5993 | &result_loc_bit_cast->base); | 7024 | &result_loc_bit_cast->base); |
| 5994 | if (arg1_value == irb->codegen->invalid_instruction) | 7025 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5995 | return arg1_value; | 7026 | return arg1_value; |
| 5996 | | 7027 | |
| 5997 | IrInstruction *bitcast = ir_build_bit_cast_src(irb, scope, arg1_node, arg1_value, result_loc_bit_cast); | 7028 | IrInstSrc *bitcast = ir_build_bit_cast_src(irb, scope, arg1_node, arg1_value, result_loc_bit_cast); |
| 5998 | return ir_lval_wrap(irb, scope, bitcast, lval, result_loc); | 7029 | return ir_lval_wrap(irb, scope, bitcast, lval, result_loc); |
| 5999 | } | 7030 | } |
| 6000 | case BuiltinFnIdAs: | 7031 | case BuiltinFnIdAs: |
| 6001 | { | 7032 | { |
| 6002 | AstNode *dest_type_node = node->data.fn_call_expr.params.at(0); | 7033 | AstNode *dest_type_node = node->data.fn_call_expr.params.at(0); |
| 6003 | IrInstruction *dest_type = ir_gen_node(irb, dest_type_node, scope); | 7034 | IrInstSrc *dest_type = ir_gen_node(irb, dest_type_node, scope); |
| 6004 | if (dest_type == irb->codegen->invalid_instruction) | 7035 | if (dest_type == irb->codegen->invalid_inst_src) |
| 6005 | return dest_type; | 7036 | return dest_type; |
| 6006 | | 7037 | |
| 6007 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, dest_type, result_loc); | 7038 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, dest_type, result_loc); |
| 6008 | | 7039 | |
| 6009 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7040 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6010 | IrInstruction *arg1_value = ir_gen_node_extra(irb, arg1_node, scope, LValNone, | 7041 | IrInstSrc *arg1_value = ir_gen_node_extra(irb, arg1_node, scope, LValNone, |
| 6011 | &result_loc_cast->base); | 7042 | &result_loc_cast->base); |
| 6012 | if (arg1_value == irb->codegen->invalid_instruction) | 7043 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6013 | return arg1_value; | 7044 | return arg1_value; |
| 6014 | | 7045 | |
| 6015 | IrInstruction *result = ir_build_implicit_cast(irb, scope, node, arg1_value, result_loc_cast); | 7046 | IrInstSrc *result = ir_build_implicit_cast(irb, scope, node, arg1_value, result_loc_cast); |
| 6016 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 7047 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 6017 | } | 7048 | } |
| 6018 | case BuiltinFnIdIntToPtr: | 7049 | case BuiltinFnIdIntToPtr: |
| 6019 | { | 7050 | { |
| 6020 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7051 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6021 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7052 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6022 | if (arg0_value == irb->codegen->invalid_instruction) | 7053 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6023 | return arg0_value; | 7054 | return arg0_value; |
| 6024 | | 7055 | |
| 6025 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7056 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6026 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7057 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6027 | if (arg1_value == irb->codegen->invalid_instruction) | 7058 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6028 | return arg1_value; | 7059 | return arg1_value; |
| 6029 | | 7060 | |
| 6030 | IrInstruction *int_to_ptr = ir_build_int_to_ptr(irb, scope, node, arg0_value, arg1_value); | 7061 | IrInstSrc *int_to_ptr = ir_build_int_to_ptr_src(irb, scope, node, arg0_value, arg1_value); |
| 6031 | return ir_lval_wrap(irb, scope, int_to_ptr, lval, result_loc); | 7062 | return ir_lval_wrap(irb, scope, int_to_ptr, lval, result_loc); |
| 6032 | } | 7063 | } |
| 6033 | case BuiltinFnIdPtrToInt: | 7064 | case BuiltinFnIdPtrToInt: |
| 6034 | { | 7065 | { |
| 6035 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7066 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6036 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7067 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6037 | if (arg0_value == irb->codegen->invalid_instruction) | 7068 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6038 | return arg0_value; | 7069 | return arg0_value; |
| 6039 | | 7070 | |
| 6040 | IrInstruction *ptr_to_int = ir_build_ptr_to_int(irb, scope, node, arg0_value); | 7071 | IrInstSrc *ptr_to_int = ir_build_ptr_to_int_src(irb, scope, node, arg0_value); |
| 6041 | return ir_lval_wrap(irb, scope, ptr_to_int, lval, result_loc); | 7072 | return ir_lval_wrap(irb, scope, ptr_to_int, lval, result_loc); |
| 6042 | } | 7073 | } |
| 6043 | case BuiltinFnIdTagName: | 7074 | case BuiltinFnIdTagName: |
| 6044 | { | 7075 | { |
| 6045 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7076 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6046 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7077 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6047 | if (arg0_value == irb->codegen->invalid_instruction) | 7078 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6048 | return arg0_value; | 7079 | return arg0_value; |
| 6049 | | 7080 | |
| 6050 | IrInstruction *actual_tag = ir_build_union_tag(irb, scope, node, arg0_value); | 7081 | IrInstSrc *tag_name = ir_build_tag_name_src(irb, scope, node, arg0_value); |
| 6051 | IrInstruction *tag_name = ir_build_tag_name(irb, scope, node, actual_tag); | | |
| 6052 | return ir_lval_wrap(irb, scope, tag_name, lval, result_loc); | 7082 | return ir_lval_wrap(irb, scope, tag_name, lval, result_loc); |
| 6053 | } | 7083 | } |
| 6054 | case BuiltinFnIdTagType: | 7084 | case BuiltinFnIdTagType: |
| 6055 | { | 7085 | { |
| 6056 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7086 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6057 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7087 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6058 | if (arg0_value == irb->codegen->invalid_instruction) | 7088 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6059 | return arg0_value; | 7089 | return arg0_value; |
| 6060 | | 7090 | |
| 6061 | IrInstruction *tag_type = ir_build_tag_type(irb, scope, node, arg0_value); | 7091 | IrInstSrc *tag_type = ir_build_tag_type(irb, scope, node, arg0_value); |
| 6062 | return ir_lval_wrap(irb, scope, tag_type, lval, result_loc); | 7092 | return ir_lval_wrap(irb, scope, tag_type, lval, result_loc); |
| 6063 | } | 7093 | } |
| 6064 | case BuiltinFnIdFieldParentPtr: | 7094 | case BuiltinFnIdFieldParentPtr: |
| 6065 | { | 7095 | { |
| 6066 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7096 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6067 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7097 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6068 | if (arg0_value == irb->codegen->invalid_instruction) | 7098 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6069 | return arg0_value; | 7099 | return arg0_value; |
| 6070 | | 7100 | |
| 6071 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7101 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6072 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7102 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6073 | if (arg1_value == irb->codegen->invalid_instruction) | 7103 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6074 | return arg1_value; | 7104 | return arg1_value; |
| 6075 | | 7105 | |
| 6076 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); | 7106 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 6077 | IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope); | 7107 | IrInstSrc *arg2_value = ir_gen_node(irb, arg2_node, scope); |
| 6078 | if (arg2_value == irb->codegen->invalid_instruction) | 7108 | if (arg2_value == irb->codegen->invalid_inst_src) |
| 6079 | return arg2_value; | 7109 | return arg2_value; |
| 6080 | | 7110 | |
| 6081 | IrInstruction *field_parent_ptr = ir_build_field_parent_ptr(irb, scope, node, arg0_value, arg1_value, arg2_value, nullptr); | 7111 | IrInstSrc *field_parent_ptr = ir_build_field_parent_ptr_src(irb, scope, node, |
| | 7112 | arg0_value, arg1_value, arg2_value); |
| 6082 | return ir_lval_wrap(irb, scope, field_parent_ptr, lval, result_loc); | 7113 | return ir_lval_wrap(irb, scope, field_parent_ptr, lval, result_loc); |
| 6083 | } | 7114 | } |
| 6084 | case BuiltinFnIdByteOffsetOf: | 7115 | case BuiltinFnIdByteOffsetOf: |
| 6085 | { | 7116 | { |
| 6086 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7117 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6087 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7118 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6088 | if (arg0_value == irb->codegen->invalid_instruction) | 7119 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6089 | return arg0_value; | 7120 | return arg0_value; |
| 6090 | | 7121 | |
| 6091 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7122 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6092 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7123 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6093 | if (arg1_value == irb->codegen->invalid_instruction) | 7124 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6094 | return arg1_value; | 7125 | return arg1_value; |
| 6095 | | 7126 | |
| 6096 | IrInstruction *offset_of = ir_build_byte_offset_of(irb, scope, node, arg0_value, arg1_value); | 7127 | IrInstSrc *offset_of = ir_build_byte_offset_of(irb, scope, node, arg0_value, arg1_value); |
| 6097 | return ir_lval_wrap(irb, scope, offset_of, lval, result_loc); | 7128 | return ir_lval_wrap(irb, scope, offset_of, lval, result_loc); |
| 6098 | } | 7129 | } |
| 6099 | case BuiltinFnIdBitOffsetOf: | 7130 | case BuiltinFnIdBitOffsetOf: |
| 6100 | { | 7131 | { |
| 6101 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7132 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6102 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7133 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6103 | if (arg0_value == irb->codegen->invalid_instruction) | 7134 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6104 | return arg0_value; | 7135 | return arg0_value; |
| 6105 | | 7136 | |
| 6106 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7137 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6107 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7138 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6108 | if (arg1_value == irb->codegen->invalid_instruction) | 7139 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6109 | return arg1_value; | 7140 | return arg1_value; |
| 6110 | | 7141 | |
| 6111 | IrInstruction *offset_of = ir_build_bit_offset_of(irb, scope, node, arg0_value, arg1_value); | 7142 | IrInstSrc *offset_of = ir_build_bit_offset_of(irb, scope, node, arg0_value, arg1_value); |
| 6112 | return ir_lval_wrap(irb, scope, offset_of, lval, result_loc); | 7143 | return ir_lval_wrap(irb, scope, offset_of, lval, result_loc); |
| 6113 | } | 7144 | } |
| 6114 | case BuiltinFnIdNewStackCall: | 7145 | case BuiltinFnIdNewStackCall: |
| ... | @@ -6117,45 +7148,45 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -6117,45 +7148,45 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 6117 | add_node_error(irb->codegen, node, | 7148 | add_node_error(irb->codegen, node, |
| 6118 | buf_sprintf("expected at least 2 arguments, found %" ZIG_PRI_usize, | 7149 | buf_sprintf("expected at least 2 arguments, found %" ZIG_PRI_usize, |
| 6119 | node->data.fn_call_expr.params.length)); | 7150 | node->data.fn_call_expr.params.length)); |
| 6120 | return irb->codegen->invalid_instruction; | 7151 | return irb->codegen->invalid_inst_src; |
| 6121 | } | 7152 | } |
| 6122 | | 7153 | |
| 6123 | AstNode *new_stack_node = node->data.fn_call_expr.params.at(0); | 7154 | AstNode *new_stack_node = node->data.fn_call_expr.params.at(0); |
| 6124 | IrInstruction *new_stack = ir_gen_node(irb, new_stack_node, scope); | 7155 | IrInstSrc *new_stack = ir_gen_node(irb, new_stack_node, scope); |
| 6125 | if (new_stack == irb->codegen->invalid_instruction) | 7156 | if (new_stack == irb->codegen->invalid_inst_src) |
| 6126 | return new_stack; | 7157 | return new_stack; |
| 6127 | | 7158 | |
| 6128 | AstNode *fn_ref_node = node->data.fn_call_expr.params.at(1); | 7159 | AstNode *fn_ref_node = node->data.fn_call_expr.params.at(1); |
| 6129 | IrInstruction *fn_ref = ir_gen_node(irb, fn_ref_node, scope); | 7160 | IrInstSrc *fn_ref = ir_gen_node(irb, fn_ref_node, scope); |
| 6130 | if (fn_ref == irb->codegen->invalid_instruction) | 7161 | if (fn_ref == irb->codegen->invalid_inst_src) |
| 6131 | return fn_ref; | 7162 | return fn_ref; |
| 6132 | | 7163 | |
| 6133 | size_t arg_count = node->data.fn_call_expr.params.length - 2; | 7164 | size_t arg_count = node->data.fn_call_expr.params.length - 2; |
| 6134 | | 7165 | |
| 6135 | IrInstruction **args = allocate<IrInstruction*>(arg_count); | 7166 | IrInstSrc **args = allocate<IrInstSrc*>(arg_count); |
| 6136 | for (size_t i = 0; i < arg_count; i += 1) { | 7167 | for (size_t i = 0; i < arg_count; i += 1) { |
| 6137 | AstNode *arg_node = node->data.fn_call_expr.params.at(i + 2); | 7168 | AstNode *arg_node = node->data.fn_call_expr.params.at(i + 2); |
| 6138 | args[i] = ir_gen_node(irb, arg_node, scope); | 7169 | args[i] = ir_gen_node(irb, arg_node, scope); |
| 6139 | if (args[i] == irb->codegen->invalid_instruction) | 7170 | if (args[i] == irb->codegen->invalid_inst_src) |
| 6140 | return args[i]; | 7171 | return args[i]; |
| 6141 | } | 7172 | } |
| 6142 | | 7173 | |
| 6143 | IrInstruction *call = ir_build_call_src(irb, scope, node, nullptr, fn_ref, arg_count, args, | 7174 | IrInstSrc *call = ir_build_call_src(irb, scope, node, nullptr, fn_ref, arg_count, args, |
| 6144 | nullptr, CallModifierNone, false, new_stack, result_loc); | 7175 | nullptr, CallModifierNone, false, new_stack, result_loc); |
| 6145 | return ir_lval_wrap(irb, scope, call, lval, result_loc); | 7176 | return ir_lval_wrap(irb, scope, call, lval, result_loc); |
| 6146 | } | 7177 | } |
| 6147 | case BuiltinFnIdCall: { | 7178 | case BuiltinFnIdCall: { |
| 6148 | // Cast the options parameter to the options type | 7179 | // Cast the options parameter to the options type |
| 6149 | ZigType *options_type = get_builtin_type(irb->codegen, "CallOptions"); | 7180 | ZigType *options_type = get_builtin_type(irb->codegen, "CallOptions"); |
| 6150 | IrInstruction *options_type_inst = ir_build_const_type(irb, scope, node, options_type); | 7181 | IrInstSrc *options_type_inst = ir_build_const_type(irb, scope, node, options_type); |
| 6151 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, options_type_inst, no_result_loc()); | 7182 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, options_type_inst, no_result_loc()); |
| 6152 | | 7183 | |
| 6153 | AstNode *options_node = node->data.fn_call_expr.params.at(0); | 7184 | AstNode *options_node = node->data.fn_call_expr.params.at(0); |
| 6154 | IrInstruction *options_inner = ir_gen_node_extra(irb, options_node, scope, | 7185 | IrInstSrc *options_inner = ir_gen_node_extra(irb, options_node, scope, |
| 6155 | LValNone, &result_loc_cast->base); | 7186 | LValNone, &result_loc_cast->base); |
| 6156 | if (options_inner == irb->codegen->invalid_instruction) | 7187 | if (options_inner == irb->codegen->invalid_inst_src) |
| 6157 | return options_inner; | 7188 | return options_inner; |
| 6158 | IrInstruction *options = ir_build_implicit_cast(irb, scope, options_node, options_inner, result_loc_cast); | 7189 | IrInstSrc *options = ir_build_implicit_cast(irb, scope, options_node, options_inner, result_loc_cast); |
| 6159 | | 7190 | |
| 6160 | AstNode *fn_ref_node = node->data.fn_call_expr.params.at(1); | 7191 | AstNode *fn_ref_node = node->data.fn_call_expr.params.at(1); |
| 6161 | AstNode *args_node = node->data.fn_call_expr.params.at(2); | 7192 | AstNode *args_node = node->data.fn_call_expr.params.at(2); |
| ... | @@ -6171,18 +7202,18 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -6171,18 +7202,18 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 6171 | } else { | 7202 | } else { |
| 6172 | exec_add_error_node(irb->codegen, irb->exec, args_node, | 7203 | exec_add_error_node(irb->codegen, irb->exec, args_node, |
| 6173 | buf_sprintf("TODO: @call with anon struct literal")); | 7204 | buf_sprintf("TODO: @call with anon struct literal")); |
| 6174 | return irb->codegen->invalid_instruction; | 7205 | return irb->codegen->invalid_inst_src; |
| 6175 | } | 7206 | } |
| 6176 | } else { | 7207 | } else { |
| 6177 | IrInstruction *fn_ref = ir_gen_node(irb, fn_ref_node, scope); | 7208 | IrInstSrc *fn_ref = ir_gen_node(irb, fn_ref_node, scope); |
| 6178 | if (fn_ref == irb->codegen->invalid_instruction) | 7209 | if (fn_ref == irb->codegen->invalid_inst_src) |
| 6179 | return fn_ref; | 7210 | return fn_ref; |
| 6180 | | 7211 | |
| 6181 | IrInstruction *args = ir_gen_node(irb, args_node, scope); | 7212 | IrInstSrc *args = ir_gen_node(irb, args_node, scope); |
| 6182 | if (args == irb->codegen->invalid_instruction) | 7213 | if (args == irb->codegen->invalid_inst_src) |
| 6183 | return args; | 7214 | return args; |
| 6184 | | 7215 | |
| 6185 | IrInstruction *call = ir_build_call_extra(irb, scope, node, options, fn_ref, args, result_loc); | 7216 | IrInstSrc *call = ir_build_call_extra(irb, scope, node, options, fn_ref, args, result_loc); |
| 6186 | return ir_lval_wrap(irb, scope, call, lval, result_loc); | 7217 | return ir_lval_wrap(irb, scope, call, lval, result_loc); |
| 6187 | } | 7218 | } |
| 6188 | } | 7219 | } |
| ... | @@ -6191,237 +7222,233 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -6191,237 +7222,233 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 6191 | case BuiltinFnIdTypeId: | 7222 | case BuiltinFnIdTypeId: |
| 6192 | { | 7223 | { |
| 6193 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7224 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6194 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7225 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6195 | if (arg0_value == irb->codegen->invalid_instruction) | 7226 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6196 | return arg0_value; | 7227 | return arg0_value; |
| 6197 | | 7228 | |
| 6198 | IrInstruction *type_id = ir_build_type_id(irb, scope, node, arg0_value); | 7229 | IrInstSrc *type_id = ir_build_type_id(irb, scope, node, arg0_value); |
| 6199 | return ir_lval_wrap(irb, scope, type_id, lval, result_loc); | 7230 | return ir_lval_wrap(irb, scope, type_id, lval, result_loc); |
| 6200 | } | 7231 | } |
| 6201 | case BuiltinFnIdShlExact: | 7232 | case BuiltinFnIdShlExact: |
| 6202 | { | 7233 | { |
| 6203 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7234 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6204 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7235 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6205 | if (arg0_value == irb->codegen->invalid_instruction) | 7236 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6206 | return arg0_value; | 7237 | return arg0_value; |
| 6207 | | 7238 | |
| 6208 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7239 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6209 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7240 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6210 | if (arg1_value == irb->codegen->invalid_instruction) | 7241 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6211 | return arg1_value; | 7242 | return arg1_value; |
| 6212 | | 7243 | |
| 6213 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpBitShiftLeftExact, arg0_value, arg1_value, true); | 7244 | IrInstSrc *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpBitShiftLeftExact, arg0_value, arg1_value, true); |
| 6214 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); | 7245 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); |
| 6215 | } | 7246 | } |
| 6216 | case BuiltinFnIdShrExact: | 7247 | case BuiltinFnIdShrExact: |
| 6217 | { | 7248 | { |
| 6218 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7249 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6219 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7250 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6220 | if (arg0_value == irb->codegen->invalid_instruction) | 7251 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6221 | return arg0_value; | 7252 | return arg0_value; |
| 6222 | | 7253 | |
| 6223 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7254 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6224 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7255 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6225 | if (arg1_value == irb->codegen->invalid_instruction) | 7256 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6226 | return arg1_value; | 7257 | return arg1_value; |
| 6227 | | 7258 | |
| 6228 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpBitShiftRightExact, arg0_value, arg1_value, true); | 7259 | IrInstSrc *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpBitShiftRightExact, arg0_value, arg1_value, true); |
| 6229 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); | 7260 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); |
| 6230 | } | 7261 | } |
| 6231 | case BuiltinFnIdSetEvalBranchQuota: | 7262 | case BuiltinFnIdSetEvalBranchQuota: |
| 6232 | { | 7263 | { |
| 6233 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7264 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6234 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7265 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6235 | if (arg0_value == irb->codegen->invalid_instruction) | 7266 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6236 | return arg0_value; | 7267 | return arg0_value; |
| 6237 | | 7268 | |
| 6238 | IrInstruction *set_eval_branch_quota = ir_build_set_eval_branch_quota(irb, scope, node, arg0_value); | 7269 | IrInstSrc *set_eval_branch_quota = ir_build_set_eval_branch_quota(irb, scope, node, arg0_value); |
| 6239 | return ir_lval_wrap(irb, scope, set_eval_branch_quota, lval, result_loc); | 7270 | return ir_lval_wrap(irb, scope, set_eval_branch_quota, lval, result_loc); |
| 6240 | } | 7271 | } |
| 6241 | case BuiltinFnIdAlignCast: | 7272 | case BuiltinFnIdAlignCast: |
| 6242 | { | 7273 | { |
| 6243 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7274 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6244 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7275 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6245 | if (arg0_value == irb->codegen->invalid_instruction) | 7276 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6246 | return arg0_value; | 7277 | return arg0_value; |
| 6247 | | 7278 | |
| 6248 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7279 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6249 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7280 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6250 | if (arg1_value == irb->codegen->invalid_instruction) | 7281 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6251 | return arg1_value; | 7282 | return arg1_value; |
| 6252 | | 7283 | |
| 6253 | IrInstruction *align_cast = ir_build_align_cast(irb, scope, node, arg0_value, arg1_value); | 7284 | IrInstSrc *align_cast = ir_build_align_cast_src(irb, scope, node, arg0_value, arg1_value); |
| 6254 | return ir_lval_wrap(irb, scope, align_cast, lval, result_loc); | 7285 | return ir_lval_wrap(irb, scope, align_cast, lval, result_loc); |
| 6255 | } | 7286 | } |
| 6256 | case BuiltinFnIdOpaqueType: | 7287 | case BuiltinFnIdOpaqueType: |
| 6257 | { | 7288 | { |
| 6258 | IrInstruction *opaque_type = ir_build_opaque_type(irb, scope, node); | 7289 | IrInstSrc *opaque_type = ir_build_opaque_type(irb, scope, node); |
| 6259 | return ir_lval_wrap(irb, scope, opaque_type, lval, result_loc); | 7290 | return ir_lval_wrap(irb, scope, opaque_type, lval, result_loc); |
| 6260 | } | 7291 | } |
| 6261 | case BuiltinFnIdThis: | 7292 | case BuiltinFnIdThis: |
| 6262 | { | 7293 | { |
| 6263 | IrInstruction *this_inst = ir_gen_this(irb, scope, node); | 7294 | IrInstSrc *this_inst = ir_gen_this(irb, scope, node); |
| 6264 | return ir_lval_wrap(irb, scope, this_inst, lval, result_loc); | 7295 | return ir_lval_wrap(irb, scope, this_inst, lval, result_loc); |
| 6265 | } | 7296 | } |
| 6266 | case BuiltinFnIdSetAlignStack: | 7297 | case BuiltinFnIdSetAlignStack: |
| 6267 | { | 7298 | { |
| 6268 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7299 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6269 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7300 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6270 | if (arg0_value == irb->codegen->invalid_instruction) | 7301 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6271 | return arg0_value; | 7302 | return arg0_value; |
| 6272 | | 7303 | |
| 6273 | IrInstruction *set_align_stack = ir_build_set_align_stack(irb, scope, node, arg0_value); | 7304 | IrInstSrc *set_align_stack = ir_build_set_align_stack(irb, scope, node, arg0_value); |
| 6274 | return ir_lval_wrap(irb, scope, set_align_stack, lval, result_loc); | 7305 | return ir_lval_wrap(irb, scope, set_align_stack, lval, result_loc); |
| 6275 | } | 7306 | } |
| 6276 | case BuiltinFnIdArgType: | 7307 | case BuiltinFnIdArgType: |
| 6277 | { | 7308 | { |
| 6278 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7309 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6279 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7310 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6280 | if (arg0_value == irb->codegen->invalid_instruction) | 7311 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6281 | return arg0_value; | 7312 | return arg0_value; |
| 6282 | | 7313 | |
| 6283 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7314 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6284 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7315 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6285 | if (arg1_value == irb->codegen->invalid_instruction) | 7316 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6286 | return arg1_value; | 7317 | return arg1_value; |
| 6287 | | 7318 | |
| 6288 | IrInstruction *arg_type = ir_build_arg_type(irb, scope, node, arg0_value, arg1_value, false); | 7319 | IrInstSrc *arg_type = ir_build_arg_type(irb, scope, node, arg0_value, arg1_value, false); |
| 6289 | return ir_lval_wrap(irb, scope, arg_type, lval, result_loc); | 7320 | return ir_lval_wrap(irb, scope, arg_type, lval, result_loc); |
| 6290 | } | 7321 | } |
| 6291 | case BuiltinFnIdExport: | 7322 | case BuiltinFnIdExport: |
| 6292 | { | 7323 | { |
| 6293 | // Cast the options parameter to the options type | 7324 | // Cast the options parameter to the options type |
| 6294 | ZigType *options_type = get_builtin_type(irb->codegen, "ExportOptions"); | 7325 | ZigType *options_type = get_builtin_type(irb->codegen, "ExportOptions"); |
| 6295 | IrInstruction *options_type_inst = ir_build_const_type(irb, scope, node, options_type); | 7326 | IrInstSrc *options_type_inst = ir_build_const_type(irb, scope, node, options_type); |
| 6296 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, options_type_inst, no_result_loc()); | 7327 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, options_type_inst, no_result_loc()); |
| 6297 | | 7328 | |
| 6298 | AstNode *target_node = node->data.fn_call_expr.params.at(0); | 7329 | AstNode *target_node = node->data.fn_call_expr.params.at(0); |
| 6299 | IrInstruction *target_value = ir_gen_node(irb, target_node, scope); | 7330 | IrInstSrc *target_value = ir_gen_node(irb, target_node, scope); |
| 6300 | if (target_value == irb->codegen->invalid_instruction) | 7331 | if (target_value == irb->codegen->invalid_inst_src) |
| 6301 | return target_value; | 7332 | return target_value; |
| 6302 | | 7333 | |
| 6303 | AstNode *options_node = node->data.fn_call_expr.params.at(1); | 7334 | AstNode *options_node = node->data.fn_call_expr.params.at(1); |
| 6304 | IrInstruction *options_value = ir_gen_node_extra(irb, options_node, | 7335 | IrInstSrc *options_value = ir_gen_node_extra(irb, options_node, |
| 6305 | scope, LValNone, &result_loc_cast->base); | 7336 | scope, LValNone, &result_loc_cast->base); |
| 6306 | if (options_value == irb->codegen->invalid_instruction) | 7337 | if (options_value == irb->codegen->invalid_inst_src) |
| 6307 | return options_value; | 7338 | return options_value; |
| 6308 | | 7339 | |
| 6309 | IrInstruction *casted_options_value = ir_build_implicit_cast( | 7340 | IrInstSrc *casted_options_value = ir_build_implicit_cast( |
| 6310 | irb, scope, options_node, options_value, result_loc_cast); | 7341 | irb, scope, options_node, options_value, result_loc_cast); |
| 6311 | | 7342 | |
| 6312 | IrInstruction *ir_export = ir_build_export(irb, scope, node, target_value, casted_options_value); | 7343 | IrInstSrc *ir_export = ir_build_export(irb, scope, node, target_value, casted_options_value); |
| 6313 | return ir_lval_wrap(irb, scope, ir_export, lval, result_loc); | 7344 | return ir_lval_wrap(irb, scope, ir_export, lval, result_loc); |
| 6314 | } | 7345 | } |
| 6315 | case BuiltinFnIdErrorReturnTrace: | 7346 | case BuiltinFnIdErrorReturnTrace: |
| 6316 | { | 7347 | { |
| 6317 | IrInstruction *error_return_trace = ir_build_error_return_trace(irb, scope, node, IrInstructionErrorReturnTrace::Null); | 7348 | IrInstSrc *error_return_trace = ir_build_error_return_trace_src(irb, scope, node, |
| | 7349 | IrInstErrorReturnTraceNull); |
| 6318 | return ir_lval_wrap(irb, scope, error_return_trace, lval, result_loc); | 7350 | return ir_lval_wrap(irb, scope, error_return_trace, lval, result_loc); |
| 6319 | } | 7351 | } |
| 6320 | case BuiltinFnIdAtomicRmw: | 7352 | case BuiltinFnIdAtomicRmw: |
| 6321 | { | 7353 | { |
| 6322 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7354 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6323 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7355 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6324 | if (arg0_value == irb->codegen->invalid_instruction) | 7356 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6325 | return arg0_value; | 7357 | return arg0_value; |
| 6326 | | 7358 | |
| 6327 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7359 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6328 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7360 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6329 | if (arg1_value == irb->codegen->invalid_instruction) | 7361 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6330 | return arg1_value; | 7362 | return arg1_value; |
| 6331 | | 7363 | |
| 6332 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); | 7364 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 6333 | IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope); | 7365 | IrInstSrc *arg2_value = ir_gen_node(irb, arg2_node, scope); |
| 6334 | if (arg2_value == irb->codegen->invalid_instruction) | 7366 | if (arg2_value == irb->codegen->invalid_inst_src) |
| 6335 | return arg2_value; | 7367 | return arg2_value; |
| 6336 | | 7368 | |
| 6337 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); | 7369 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); |
| 6338 | IrInstruction *arg3_value = ir_gen_node(irb, arg3_node, scope); | 7370 | IrInstSrc *arg3_value = ir_gen_node(irb, arg3_node, scope); |
| 6339 | if (arg3_value == irb->codegen->invalid_instruction) | 7371 | if (arg3_value == irb->codegen->invalid_inst_src) |
| 6340 | return arg3_value; | 7372 | return arg3_value; |
| 6341 | | 7373 | |
| 6342 | AstNode *arg4_node = node->data.fn_call_expr.params.at(4); | 7374 | AstNode *arg4_node = node->data.fn_call_expr.params.at(4); |
| 6343 | IrInstruction *arg4_value = ir_gen_node(irb, arg4_node, scope); | 7375 | IrInstSrc *arg4_value = ir_gen_node(irb, arg4_node, scope); |
| 6344 | if (arg4_value == irb->codegen->invalid_instruction) | 7376 | if (arg4_value == irb->codegen->invalid_inst_src) |
| 6345 | return arg4_value; | 7377 | return arg4_value; |
| 6346 | | 7378 | |
| 6347 | IrInstruction *inst = ir_build_atomic_rmw(irb, scope, node, arg0_value, arg1_value, arg2_value, arg3_value, | 7379 | IrInstSrc *inst = ir_build_atomic_rmw_src(irb, scope, node, |
| 6348 | arg4_value, | 7380 | arg0_value, arg1_value, arg2_value, arg3_value, arg4_value); |
| 6349 | // these 2 values don't mean anything since we passed non-null values for other args | | |
| 6350 | AtomicRmwOp_xchg, AtomicOrderMonotonic); | | |
| 6351 | return ir_lval_wrap(irb, scope, inst, lval, result_loc); | 7381 | return ir_lval_wrap(irb, scope, inst, lval, result_loc); |
| 6352 | } | 7382 | } |
| 6353 | case BuiltinFnIdAtomicLoad: | 7383 | case BuiltinFnIdAtomicLoad: |
| 6354 | { | 7384 | { |
| 6355 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7385 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6356 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7386 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6357 | if (arg0_value == irb->codegen->invalid_instruction) | 7387 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6358 | return arg0_value; | 7388 | return arg0_value; |
| 6359 | | 7389 | |
| 6360 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7390 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6361 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7391 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6362 | if (arg1_value == irb->codegen->invalid_instruction) | 7392 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6363 | return arg1_value; | 7393 | return arg1_value; |
| 6364 | | 7394 | |
| 6365 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); | 7395 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 6366 | IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope); | 7396 | IrInstSrc *arg2_value = ir_gen_node(irb, arg2_node, scope); |
| 6367 | if (arg2_value == irb->codegen->invalid_instruction) | 7397 | if (arg2_value == irb->codegen->invalid_inst_src) |
| 6368 | return arg2_value; | 7398 | return arg2_value; |
| 6369 | | 7399 | |
| 6370 | IrInstruction *inst = ir_build_atomic_load(irb, scope, node, arg0_value, arg1_value, arg2_value, | 7400 | IrInstSrc *inst = ir_build_atomic_load_src(irb, scope, node, arg0_value, arg1_value, arg2_value); |
| 6371 | // this value does not mean anything since we passed non-null values for other arg | | |
| 6372 | AtomicOrderMonotonic); | | |
| 6373 | return ir_lval_wrap(irb, scope, inst, lval, result_loc); | 7401 | return ir_lval_wrap(irb, scope, inst, lval, result_loc); |
| 6374 | } | 7402 | } |
| 6375 | case BuiltinFnIdAtomicStore: | 7403 | case BuiltinFnIdAtomicStore: |
| 6376 | { | 7404 | { |
| 6377 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7405 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6378 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7406 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6379 | if (arg0_value == irb->codegen->invalid_instruction) | 7407 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6380 | return arg0_value; | 7408 | return arg0_value; |
| 6381 | | 7409 | |
| 6382 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7410 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6383 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7411 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6384 | if (arg1_value == irb->codegen->invalid_instruction) | 7412 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6385 | return arg1_value; | 7413 | return arg1_value; |
| 6386 | | 7414 | |
| 6387 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); | 7415 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 6388 | IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope); | 7416 | IrInstSrc *arg2_value = ir_gen_node(irb, arg2_node, scope); |
| 6389 | if (arg2_value == irb->codegen->invalid_instruction) | 7417 | if (arg2_value == irb->codegen->invalid_inst_src) |
| 6390 | return arg2_value; | 7418 | return arg2_value; |
| 6391 | | 7419 | |
| 6392 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); | 7420 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); |
| 6393 | IrInstruction *arg3_value = ir_gen_node(irb, arg3_node, scope); | 7421 | IrInstSrc *arg3_value = ir_gen_node(irb, arg3_node, scope); |
| 6394 | if (arg3_value == irb->codegen->invalid_instruction) | 7422 | if (arg3_value == irb->codegen->invalid_inst_src) |
| 6395 | return arg3_value; | 7423 | return arg3_value; |
| 6396 | | 7424 | |
| 6397 | IrInstruction *inst = ir_build_atomic_store(irb, scope, node, arg0_value, arg1_value, arg2_value, arg3_value, | 7425 | IrInstSrc *inst = ir_build_atomic_store_src(irb, scope, node, arg0_value, arg1_value, |
| 6398 | // this value does not mean anything since we passed non-null values for other arg | 7426 | arg2_value, arg3_value); |
| 6399 | AtomicOrderMonotonic); | | |
| 6400 | return ir_lval_wrap(irb, scope, inst, lval, result_loc); | 7427 | return ir_lval_wrap(irb, scope, inst, lval, result_loc); |
| 6401 | } | 7428 | } |
| 6402 | case BuiltinFnIdIntToEnum: | 7429 | case BuiltinFnIdIntToEnum: |
| 6403 | { | 7430 | { |
| 6404 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7431 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6405 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7432 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6406 | if (arg0_value == irb->codegen->invalid_instruction) | 7433 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6407 | return arg0_value; | 7434 | return arg0_value; |
| 6408 | | 7435 | |
| 6409 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7436 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6410 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7437 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6411 | if (arg1_value == irb->codegen->invalid_instruction) | 7438 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6412 | return arg1_value; | 7439 | return arg1_value; |
| 6413 | | 7440 | |
| 6414 | IrInstruction *result = ir_build_int_to_enum(irb, scope, node, arg0_value, arg1_value); | 7441 | IrInstSrc *result = ir_build_int_to_enum_src(irb, scope, node, arg0_value, arg1_value); |
| 6415 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 7442 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 6416 | } | 7443 | } |
| 6417 | case BuiltinFnIdEnumToInt: | 7444 | case BuiltinFnIdEnumToInt: |
| 6418 | { | 7445 | { |
| 6419 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7446 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6420 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7447 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6421 | if (arg0_value == irb->codegen->invalid_instruction) | 7448 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6422 | return arg0_value; | 7449 | return arg0_value; |
| 6423 | | 7450 | |
| 6424 | IrInstruction *result = ir_build_enum_to_int(irb, scope, node, arg0_value); | 7451 | IrInstSrc *result = ir_build_enum_to_int(irb, scope, node, arg0_value); |
| 6425 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 7452 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 6426 | } | 7453 | } |
| 6427 | case BuiltinFnIdCtz: | 7454 | case BuiltinFnIdCtz: |
| ... | @@ -6431,16 +7458,16 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -6431,16 +7458,16 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 6431 | case BuiltinFnIdBitReverse: | 7458 | case BuiltinFnIdBitReverse: |
| 6432 | { | 7459 | { |
| 6433 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7460 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6434 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7461 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6435 | if (arg0_value == irb->codegen->invalid_instruction) | 7462 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6436 | return arg0_value; | 7463 | return arg0_value; |
| 6437 | | 7464 | |
| 6438 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7465 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6439 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7466 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6440 | if (arg1_value == irb->codegen->invalid_instruction) | 7467 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6441 | return arg1_value; | 7468 | return arg1_value; |
| 6442 | | 7469 | |
| 6443 | IrInstruction *result; | 7470 | IrInstSrc *result; |
| 6444 | switch (builtin_fn->id) { | 7471 | switch (builtin_fn->id) { |
| 6445 | case BuiltinFnIdCtz: | 7472 | case BuiltinFnIdCtz: |
| 6446 | result = ir_build_ctz(irb, scope, node, arg0_value, arg1_value); | 7473 | result = ir_build_ctz(irb, scope, node, arg0_value, arg1_value); |
| ... | @@ -6465,28 +7492,28 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -6465,28 +7492,28 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 6465 | case BuiltinFnIdHasDecl: | 7492 | case BuiltinFnIdHasDecl: |
| 6466 | { | 7493 | { |
| 6467 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7494 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6468 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7495 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6469 | if (arg0_value == irb->codegen->invalid_instruction) | 7496 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6470 | return arg0_value; | 7497 | return arg0_value; |
| 6471 | | 7498 | |
| 6472 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7499 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6473 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7500 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6474 | if (arg1_value == irb->codegen->invalid_instruction) | 7501 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6475 | return arg1_value; | 7502 | return arg1_value; |
| 6476 | | 7503 | |
| 6477 | IrInstruction *has_decl = ir_build_has_decl(irb, scope, node, arg0_value, arg1_value); | 7504 | IrInstSrc *has_decl = ir_build_has_decl(irb, scope, node, arg0_value, arg1_value); |
| 6478 | return ir_lval_wrap(irb, scope, has_decl, lval, result_loc); | 7505 | return ir_lval_wrap(irb, scope, has_decl, lval, result_loc); |
| 6479 | } | 7506 | } |
| 6480 | case BuiltinFnIdUnionInit: | 7507 | case BuiltinFnIdUnionInit: |
| 6481 | { | 7508 | { |
| 6482 | AstNode *union_type_node = node->data.fn_call_expr.params.at(0); | 7509 | AstNode *union_type_node = node->data.fn_call_expr.params.at(0); |
| 6483 | IrInstruction *union_type_inst = ir_gen_node(irb, union_type_node, scope); | 7510 | IrInstSrc *union_type_inst = ir_gen_node(irb, union_type_node, scope); |
| 6484 | if (union_type_inst == irb->codegen->invalid_instruction) | 7511 | if (union_type_inst == irb->codegen->invalid_inst_src) |
| 6485 | return union_type_inst; | 7512 | return union_type_inst; |
| 6486 | | 7513 | |
| 6487 | AstNode *name_node = node->data.fn_call_expr.params.at(1); | 7514 | AstNode *name_node = node->data.fn_call_expr.params.at(1); |
| 6488 | IrInstruction *name_inst = ir_gen_node(irb, name_node, scope); | 7515 | IrInstSrc *name_inst = ir_gen_node(irb, name_node, scope); |
| 6489 | if (name_inst == irb->codegen->invalid_instruction) | 7516 | if (name_inst == irb->codegen->invalid_inst_src) |
| 6490 | return name_inst; | 7517 | return name_inst; |
| 6491 | | 7518 | |
| 6492 | AstNode *init_node = node->data.fn_call_expr.params.at(2); | 7519 | AstNode *init_node = node->data.fn_call_expr.params.at(2); |
| ... | @@ -6498,7 +7525,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -6498,7 +7525,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 6498 | zig_unreachable(); | 7525 | zig_unreachable(); |
| 6499 | } | 7526 | } |
| 6500 | | 7527 | |
| 6501 | static IrInstruction *ir_gen_fn_call(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 7528 | static IrInstSrc *ir_gen_fn_call(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 6502 | ResultLoc *result_loc) | 7529 | ResultLoc *result_loc) |
| 6503 | { | 7530 | { |
| 6504 | assert(node->type == NodeTypeFnCallExpr); | 7531 | assert(node->type == NodeTypeFnCallExpr); |
| ... | @@ -6511,16 +7538,16 @@ static IrInstruction *ir_gen_fn_call(IrBuilder *irb, Scope *scope, AstNode *node | ... | @@ -6511,16 +7538,16 @@ static IrInstruction *ir_gen_fn_call(IrBuilder *irb, Scope *scope, AstNode *node |
| 6511 | nullptr, node->data.fn_call_expr.params.items, node->data.fn_call_expr.params.length, lval, result_loc); | 7538 | nullptr, node->data.fn_call_expr.params.items, node->data.fn_call_expr.params.length, lval, result_loc); |
| 6512 | } | 7539 | } |
| 6513 | | 7540 | |
| 6514 | static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 7541 | static IrInstSrc *ir_gen_if_bool_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 6515 | ResultLoc *result_loc) | 7542 | ResultLoc *result_loc) |
| 6516 | { | 7543 | { |
| 6517 | assert(node->type == NodeTypeIfBoolExpr); | 7544 | assert(node->type == NodeTypeIfBoolExpr); |
| 6518 | | 7545 | |
| 6519 | IrInstruction *condition = ir_gen_node(irb, node->data.if_bool_expr.condition, scope); | 7546 | IrInstSrc *condition = ir_gen_node(irb, node->data.if_bool_expr.condition, scope); |
| 6520 | if (condition == irb->codegen->invalid_instruction) | 7547 | if (condition == irb->codegen->invalid_inst_src) |
| 6521 | return irb->codegen->invalid_instruction; | 7548 | return irb->codegen->invalid_inst_src; |
| 6522 | | 7549 | |
| 6523 | IrInstruction *is_comptime; | 7550 | IrInstSrc *is_comptime; |
| 6524 | if (ir_should_inline(irb->exec, scope)) { | 7551 | if (ir_should_inline(irb->exec, scope)) { |
| 6525 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 7552 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 6526 | } else { | 7553 | } else { |
| ... | @@ -6530,11 +7557,11 @@ static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -6530,11 +7557,11 @@ static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode |
| 6530 | AstNode *then_node = node->data.if_bool_expr.then_block; | 7557 | AstNode *then_node = node->data.if_bool_expr.then_block; |
| 6531 | AstNode *else_node = node->data.if_bool_expr.else_node; | 7558 | AstNode *else_node = node->data.if_bool_expr.else_node; |
| 6532 | | 7559 | |
| 6533 | IrBasicBlock *then_block = ir_create_basic_block(irb, scope, "Then"); | 7560 | IrBasicBlockSrc *then_block = ir_create_basic_block(irb, scope, "Then"); |
| 6534 | IrBasicBlock *else_block = ir_create_basic_block(irb, scope, "Else"); | 7561 | IrBasicBlockSrc *else_block = ir_create_basic_block(irb, scope, "Else"); |
| 6535 | IrBasicBlock *endif_block = ir_create_basic_block(irb, scope, "EndIf"); | 7562 | IrBasicBlockSrc *endif_block = ir_create_basic_block(irb, scope, "EndIf"); |
| 6536 | | 7563 | |
| 6537 | IrInstruction *cond_br_inst = ir_build_cond_br(irb, scope, node, condition, | 7564 | IrInstSrc *cond_br_inst = ir_build_cond_br(irb, scope, node, condition, |
| 6538 | then_block, else_block, is_comptime); | 7565 | then_block, else_block, is_comptime); |
| 6539 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, else_block, endif_block, | 7566 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, else_block, endif_block, |
| 6540 | result_loc, is_comptime); | 7567 | result_loc, is_comptime); |
| ... | @@ -6542,70 +7569,70 @@ static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -6542,70 +7569,70 @@ static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode |
| 6542 | ir_set_cursor_at_end_and_append_block(irb, then_block); | 7569 | ir_set_cursor_at_end_and_append_block(irb, then_block); |
| 6543 | | 7570 | |
| 6544 | Scope *subexpr_scope = create_runtime_scope(irb->codegen, node, scope, is_comptime); | 7571 | Scope *subexpr_scope = create_runtime_scope(irb->codegen, node, scope, is_comptime); |
| 6545 | IrInstruction *then_expr_result = ir_gen_node_extra(irb, then_node, subexpr_scope, lval, | 7572 | IrInstSrc *then_expr_result = ir_gen_node_extra(irb, then_node, subexpr_scope, lval, |
| 6546 | &peer_parent->peers.at(0)->base); | 7573 | &peer_parent->peers.at(0)->base); |
| 6547 | if (then_expr_result == irb->codegen->invalid_instruction) | 7574 | if (then_expr_result == irb->codegen->invalid_inst_src) |
| 6548 | return irb->codegen->invalid_instruction; | 7575 | return irb->codegen->invalid_inst_src; |
| 6549 | IrBasicBlock *after_then_block = irb->current_basic_block; | 7576 | IrBasicBlockSrc *after_then_block = irb->current_basic_block; |
| 6550 | if (!instr_is_unreachable(then_expr_result)) | 7577 | if (!instr_is_unreachable(then_expr_result)) |
| 6551 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); | 7578 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); |
| 6552 | | 7579 | |
| 6553 | ir_set_cursor_at_end_and_append_block(irb, else_block); | 7580 | ir_set_cursor_at_end_and_append_block(irb, else_block); |
| 6554 | IrInstruction *else_expr_result; | 7581 | IrInstSrc *else_expr_result; |
| 6555 | if (else_node) { | 7582 | if (else_node) { |
| 6556 | else_expr_result = ir_gen_node_extra(irb, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base); | 7583 | else_expr_result = ir_gen_node_extra(irb, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base); |
| 6557 | if (else_expr_result == irb->codegen->invalid_instruction) | 7584 | if (else_expr_result == irb->codegen->invalid_inst_src) |
| 6558 | return irb->codegen->invalid_instruction; | 7585 | return irb->codegen->invalid_inst_src; |
| 6559 | } else { | 7586 | } else { |
| 6560 | else_expr_result = ir_build_const_void(irb, scope, node); | 7587 | else_expr_result = ir_build_const_void(irb, scope, node); |
| 6561 | ir_build_end_expr(irb, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); | 7588 | ir_build_end_expr(irb, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); |
| 6562 | } | 7589 | } |
| 6563 | IrBasicBlock *after_else_block = irb->current_basic_block; | 7590 | IrBasicBlockSrc *after_else_block = irb->current_basic_block; |
| 6564 | if (!instr_is_unreachable(else_expr_result)) | 7591 | if (!instr_is_unreachable(else_expr_result)) |
| 6565 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); | 7592 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); |
| 6566 | | 7593 | |
| 6567 | ir_set_cursor_at_end_and_append_block(irb, endif_block); | 7594 | ir_set_cursor_at_end_and_append_block(irb, endif_block); |
| 6568 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 7595 | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 6569 | incoming_values[0] = then_expr_result; | 7596 | incoming_values[0] = then_expr_result; |
| 6570 | incoming_values[1] = else_expr_result; | 7597 | incoming_values[1] = else_expr_result; |
| 6571 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); | 7598 | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 6572 | incoming_blocks[0] = after_then_block; | 7599 | incoming_blocks[0] = after_then_block; |
| 6573 | incoming_blocks[1] = after_else_block; | 7600 | incoming_blocks[1] = after_else_block; |
| 6574 | | 7601 | |
| 6575 | IrInstruction *phi = ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, peer_parent); | 7602 | IrInstSrc *phi = ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, peer_parent); |
| 6576 | return ir_expr_wrap(irb, scope, phi, result_loc); | 7603 | return ir_expr_wrap(irb, scope, phi, result_loc); |
| 6577 | } | 7604 | } |
| 6578 | | 7605 | |
| 6579 | static IrInstruction *ir_gen_prefix_op_id_lval(IrBuilder *irb, Scope *scope, AstNode *node, IrUnOp op_id, LVal lval) { | 7606 | static IrInstSrc *ir_gen_prefix_op_id_lval(IrBuilderSrc *irb, Scope *scope, AstNode *node, IrUnOp op_id, LVal lval) { |
| 6580 | assert(node->type == NodeTypePrefixOpExpr); | 7607 | assert(node->type == NodeTypePrefixOpExpr); |
| 6581 | AstNode *expr_node = node->data.prefix_op_expr.primary_expr; | 7608 | AstNode *expr_node = node->data.prefix_op_expr.primary_expr; |
| 6582 | | 7609 | |
| 6583 | IrInstruction *value = ir_gen_node_extra(irb, expr_node, scope, lval, nullptr); | 7610 | IrInstSrc *value = ir_gen_node_extra(irb, expr_node, scope, lval, nullptr); |
| 6584 | if (value == irb->codegen->invalid_instruction) | 7611 | if (value == irb->codegen->invalid_inst_src) |
| 6585 | return value; | 7612 | return value; |
| 6586 | | 7613 | |
| 6587 | return ir_build_un_op(irb, scope, node, op_id, value); | 7614 | return ir_build_un_op(irb, scope, node, op_id, value); |
| 6588 | } | 7615 | } |
| 6589 | | 7616 | |
| 6590 | static IrInstruction *ir_gen_prefix_op_id(IrBuilder *irb, Scope *scope, AstNode *node, IrUnOp op_id) { | 7617 | static IrInstSrc *ir_gen_prefix_op_id(IrBuilderSrc *irb, Scope *scope, AstNode *node, IrUnOp op_id) { |
| 6591 | return ir_gen_prefix_op_id_lval(irb, scope, node, op_id, LValNone); | 7618 | return ir_gen_prefix_op_id_lval(irb, scope, node, op_id, LValNone); |
| 6592 | } | 7619 | } |
| 6593 | | 7620 | |
| 6594 | static IrInstruction *ir_expr_wrap(IrBuilder *irb, Scope *scope, IrInstruction *inst, ResultLoc *result_loc) { | 7621 | static IrInstSrc *ir_expr_wrap(IrBuilderSrc *irb, Scope *scope, IrInstSrc *inst, ResultLoc *result_loc) { |
| 6595 | if (inst == irb->codegen->invalid_instruction) return inst; | 7622 | if (inst == irb->codegen->invalid_inst_src) return inst; |
| 6596 | ir_build_end_expr(irb, scope, inst->source_node, inst, result_loc); | 7623 | ir_build_end_expr(irb, scope, inst->base.source_node, inst, result_loc); |
| 6597 | return inst; | 7624 | return inst; |
| 6598 | } | 7625 | } |
| 6599 | | 7626 | |
| 6600 | static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction *value, LVal lval, | 7627 | static IrInstSrc *ir_lval_wrap(IrBuilderSrc *irb, Scope *scope, IrInstSrc *value, LVal lval, |
| 6601 | ResultLoc *result_loc) | 7628 | ResultLoc *result_loc) |
| 6602 | { | 7629 | { |
| 6603 | // This logic must be kept in sync with | 7630 | // This logic must be kept in sync with |
| 6604 | // [STMT_EXPR_TEST_THING] <--- (search this token) | 7631 | // [STMT_EXPR_TEST_THING] <--- (search this token) |
| 6605 | if (value == irb->codegen->invalid_instruction || | 7632 | if (value == irb->codegen->invalid_inst_src || |
| 6606 | instr_is_unreachable(value) || | 7633 | instr_is_unreachable(value) || |
| 6607 | value->source_node->type == NodeTypeDefer || | 7634 | value->base.source_node->type == NodeTypeDefer || |
| 6608 | value->id == IrInstructionIdDeclVarSrc) | 7635 | value->id == IrInstSrcIdDeclVar) |
| 6609 | { | 7636 | { |
| 6610 | return value; | 7637 | return value; |
| 6611 | } | 7638 | } |
| ... | @@ -6613,7 +7640,7 @@ static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction * | ... | @@ -6613,7 +7640,7 @@ static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction * |
| 6613 | if (lval == LValPtr) { | 7640 | if (lval == LValPtr) { |
| 6614 | // We needed a pointer to a value, but we got a value. So we create | 7641 | // We needed a pointer to a value, but we got a value. So we create |
| 6615 | // an instruction which just makes a pointer of it. | 7642 | // an instruction which just makes a pointer of it. |
| 6616 | return ir_build_ref(irb, scope, value->source_node, value, false, false); | 7643 | return ir_build_ref_src(irb, scope, value->base.source_node, value, false, false); |
| 6617 | } else if (result_loc != nullptr) { | 7644 | } else if (result_loc != nullptr) { |
| 6618 | return ir_expr_wrap(irb, scope, value, result_loc); | 7645 | return ir_expr_wrap(irb, scope, value, result_loc); |
| 6619 | } else { | 7646 | } else { |
| ... | @@ -6636,7 +7663,7 @@ static PtrLen star_token_to_ptr_len(TokenId token_id) { | ... | @@ -6636,7 +7663,7 @@ static PtrLen star_token_to_ptr_len(TokenId token_id) { |
| 6636 | } | 7663 | } |
| 6637 | } | 7664 | } |
| 6638 | | 7665 | |
| 6639 | static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode *node) { | 7666 | static IrInstSrc *ir_gen_pointer_type(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 6640 | assert(node->type == NodeTypePointerType); | 7667 | assert(node->type == NodeTypePointerType); |
| 6641 | | 7668 | |
| 6642 | PtrLen ptr_len = star_token_to_ptr_len(node->data.pointer_type.star_token->id); | 7669 | PtrLen ptr_len = star_token_to_ptr_len(node->data.pointer_type.star_token->id); |
| ... | @@ -6648,26 +7675,26 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -6648,26 +7675,26 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode |
| 6648 | AstNode *expr_node = node->data.pointer_type.op_expr; | 7675 | AstNode *expr_node = node->data.pointer_type.op_expr; |
| 6649 | AstNode *align_expr = node->data.pointer_type.align_expr; | 7676 | AstNode *align_expr = node->data.pointer_type.align_expr; |
| 6650 | | 7677 | |
| 6651 | IrInstruction *sentinel; | 7678 | IrInstSrc *sentinel; |
| 6652 | if (sentinel_expr != nullptr) { | 7679 | if (sentinel_expr != nullptr) { |
| 6653 | sentinel = ir_gen_node(irb, sentinel_expr, scope); | 7680 | sentinel = ir_gen_node(irb, sentinel_expr, scope); |
| 6654 | if (sentinel == irb->codegen->invalid_instruction) | 7681 | if (sentinel == irb->codegen->invalid_inst_src) |
| 6655 | return sentinel; | 7682 | return sentinel; |
| 6656 | } else { | 7683 | } else { |
| 6657 | sentinel = nullptr; | 7684 | sentinel = nullptr; |
| 6658 | } | 7685 | } |
| 6659 | | 7686 | |
| 6660 | IrInstruction *align_value; | 7687 | IrInstSrc *align_value; |
| 6661 | if (align_expr != nullptr) { | 7688 | if (align_expr != nullptr) { |
| 6662 | align_value = ir_gen_node(irb, align_expr, scope); | 7689 | align_value = ir_gen_node(irb, align_expr, scope); |
| 6663 | if (align_value == irb->codegen->invalid_instruction) | 7690 | if (align_value == irb->codegen->invalid_inst_src) |
| 6664 | return align_value; | 7691 | return align_value; |
| 6665 | } else { | 7692 | } else { |
| 6666 | align_value = nullptr; | 7693 | align_value = nullptr; |
| 6667 | } | 7694 | } |
| 6668 | | 7695 | |
| 6669 | IrInstruction *child_type = ir_gen_node(irb, expr_node, scope); | 7696 | IrInstSrc *child_type = ir_gen_node(irb, expr_node, scope); |
| 6670 | if (child_type == irb->codegen->invalid_instruction) | 7697 | if (child_type == irb->codegen->invalid_inst_src) |
| 6671 | return child_type; | 7698 | return child_type; |
| 6672 | | 7699 | |
| 6673 | uint32_t bit_offset_start = 0; | 7700 | uint32_t bit_offset_start = 0; |
| ... | @@ -6677,7 +7704,7 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -6677,7 +7704,7 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode |
| 6677 | bigint_append_buf(val_buf, node->data.pointer_type.bit_offset_start, 10); | 7704 | bigint_append_buf(val_buf, node->data.pointer_type.bit_offset_start, 10); |
| 6678 | exec_add_error_node(irb->codegen, irb->exec, node, | 7705 | exec_add_error_node(irb->codegen, irb->exec, node, |
| 6679 | buf_sprintf("value %s too large for u32 bit offset", buf_ptr(val_buf))); | 7706 | buf_sprintf("value %s too large for u32 bit offset", buf_ptr(val_buf))); |
| 6680 | return irb->codegen->invalid_instruction; | 7707 | return irb->codegen->invalid_inst_src; |
| 6681 | } | 7708 | } |
| 6682 | bit_offset_start = bigint_as_u32(node->data.pointer_type.bit_offset_start); | 7709 | bit_offset_start = bigint_as_u32(node->data.pointer_type.bit_offset_start); |
| 6683 | } | 7710 | } |
| ... | @@ -6689,7 +7716,7 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -6689,7 +7716,7 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode |
| 6689 | bigint_append_buf(val_buf, node->data.pointer_type.host_int_bytes, 10); | 7716 | bigint_append_buf(val_buf, node->data.pointer_type.host_int_bytes, 10); |
| 6690 | exec_add_error_node(irb->codegen, irb->exec, node, | 7717 | exec_add_error_node(irb->codegen, irb->exec, node, |
| 6691 | buf_sprintf("value %s too large for u32 byte count", buf_ptr(val_buf))); | 7718 | buf_sprintf("value %s too large for u32 byte count", buf_ptr(val_buf))); |
| 6692 | return irb->codegen->invalid_instruction; | 7719 | return irb->codegen->invalid_inst_src; |
| 6693 | } | 7720 | } |
| 6694 | host_int_bytes = bigint_as_u32(node->data.pointer_type.host_int_bytes); | 7721 | host_int_bytes = bigint_as_u32(node->data.pointer_type.host_int_bytes); |
| 6695 | } | 7722 | } |
| ... | @@ -6697,43 +7724,43 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -6697,43 +7724,43 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode |
| 6697 | if (host_int_bytes != 0 && bit_offset_start >= host_int_bytes * 8) { | 7724 | if (host_int_bytes != 0 && bit_offset_start >= host_int_bytes * 8) { |
| 6698 | exec_add_error_node(irb->codegen, irb->exec, node, | 7725 | exec_add_error_node(irb->codegen, irb->exec, node, |
| 6699 | buf_sprintf("bit offset starts after end of host integer")); | 7726 | buf_sprintf("bit offset starts after end of host integer")); |
| 6700 | return irb->codegen->invalid_instruction; | 7727 | return irb->codegen->invalid_inst_src; |
| 6701 | } | 7728 | } |
| 6702 | | 7729 | |
| 6703 | return ir_build_ptr_type(irb, scope, node, child_type, is_const, is_volatile, | 7730 | return ir_build_ptr_type(irb, scope, node, child_type, is_const, is_volatile, |
| 6704 | ptr_len, sentinel, align_value, bit_offset_start, host_int_bytes, is_allow_zero); | 7731 | ptr_len, sentinel, align_value, bit_offset_start, host_int_bytes, is_allow_zero); |
| 6705 | } | 7732 | } |
| 6706 | | 7733 | |
| 6707 | static IrInstruction *ir_gen_catch_unreachable(IrBuilder *irb, Scope *scope, AstNode *source_node, | 7734 | static IrInstSrc *ir_gen_catch_unreachable(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 6708 | AstNode *expr_node, LVal lval, ResultLoc *result_loc) | 7735 | AstNode *expr_node, LVal lval, ResultLoc *result_loc) |
| 6709 | { | 7736 | { |
| 6710 | IrInstruction *err_union_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); | 7737 | IrInstSrc *err_union_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); |
| 6711 | if (err_union_ptr == irb->codegen->invalid_instruction) | 7738 | if (err_union_ptr == irb->codegen->invalid_inst_src) |
| 6712 | return irb->codegen->invalid_instruction; | 7739 | return irb->codegen->invalid_inst_src; |
| 6713 | | 7740 | |
| 6714 | IrInstruction *payload_ptr = ir_build_unwrap_err_payload(irb, scope, source_node, err_union_ptr, true, false); | 7741 | IrInstSrc *payload_ptr = ir_build_unwrap_err_payload_src(irb, scope, source_node, err_union_ptr, true, false); |
| 6715 | if (payload_ptr == irb->codegen->invalid_instruction) | 7742 | if (payload_ptr == irb->codegen->invalid_inst_src) |
| 6716 | return irb->codegen->invalid_instruction; | 7743 | return irb->codegen->invalid_inst_src; |
| 6717 | | 7744 | |
| 6718 | if (lval == LValPtr) | 7745 | if (lval == LValPtr) |
| 6719 | return payload_ptr; | 7746 | return payload_ptr; |
| 6720 | | 7747 | |
| 6721 | IrInstruction *load_ptr = ir_build_load_ptr(irb, scope, source_node, payload_ptr); | 7748 | IrInstSrc *load_ptr = ir_build_load_ptr(irb, scope, source_node, payload_ptr); |
| 6722 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); | 7749 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); |
| 6723 | } | 7750 | } |
| 6724 | | 7751 | |
| 6725 | static IrInstruction *ir_gen_bool_not(IrBuilder *irb, Scope *scope, AstNode *node) { | 7752 | static IrInstSrc *ir_gen_bool_not(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 6726 | assert(node->type == NodeTypePrefixOpExpr); | 7753 | assert(node->type == NodeTypePrefixOpExpr); |
| 6727 | AstNode *expr_node = node->data.prefix_op_expr.primary_expr; | 7754 | AstNode *expr_node = node->data.prefix_op_expr.primary_expr; |
| 6728 | | 7755 | |
| 6729 | IrInstruction *value = ir_gen_node(irb, expr_node, scope); | 7756 | IrInstSrc *value = ir_gen_node(irb, expr_node, scope); |
| 6730 | if (value == irb->codegen->invalid_instruction) | 7757 | if (value == irb->codegen->invalid_inst_src) |
| 6731 | return irb->codegen->invalid_instruction; | 7758 | return irb->codegen->invalid_inst_src; |
| 6732 | | 7759 | |
| 6733 | return ir_build_bool_not(irb, scope, node, value); | 7760 | return ir_build_bool_not(irb, scope, node, value); |
| 6734 | } | 7761 | } |
| 6735 | | 7762 | |
| 6736 | static IrInstruction *ir_gen_prefix_op_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 7763 | static IrInstSrc *ir_gen_prefix_op_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 6737 | ResultLoc *result_loc) | 7764 | ResultLoc *result_loc) |
| 6738 | { | 7765 | { |
| 6739 | assert(node->type == NodeTypePrefixOpExpr); | 7766 | assert(node->type == NodeTypePrefixOpExpr); |
| ... | @@ -6761,12 +7788,12 @@ static IrInstruction *ir_gen_prefix_op_expr(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -6761,12 +7788,12 @@ static IrInstruction *ir_gen_prefix_op_expr(IrBuilder *irb, Scope *scope, AstNod |
| 6761 | zig_unreachable(); | 7788 | zig_unreachable(); |
| 6762 | } | 7789 | } |
| 6763 | | 7790 | |
| 6764 | static IrInstruction *ir_gen_union_init_expr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 7791 | static IrInstSrc *ir_gen_union_init_expr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 6765 | IrInstruction *union_type, IrInstruction *field_name, AstNode *expr_node, | 7792 | IrInstSrc *union_type, IrInstSrc *field_name, AstNode *expr_node, |
| 6766 | LVal lval, ResultLoc *parent_result_loc) | 7793 | LVal lval, ResultLoc *parent_result_loc) |
| 6767 | { | 7794 | { |
| 6768 | IrInstruction *container_ptr = ir_build_resolve_result(irb, scope, source_node, parent_result_loc, union_type); | 7795 | IrInstSrc *container_ptr = ir_build_resolve_result(irb, scope, source_node, parent_result_loc, union_type); |
| 6769 | IrInstruction *field_ptr = ir_build_field_ptr_instruction(irb, scope, source_node, container_ptr, | 7796 | IrInstSrc *field_ptr = ir_build_field_ptr_instruction(irb, scope, source_node, container_ptr, |
| 6770 | field_name, true); | 7797 | field_name, true); |
| 6771 | | 7798 | |
| 6772 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); | 7799 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); |
| ... | @@ -6775,18 +7802,18 @@ static IrInstruction *ir_gen_union_init_expr(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -6775,18 +7802,18 @@ static IrInstruction *ir_gen_union_init_expr(IrBuilder *irb, Scope *scope, AstNo |
| 6775 | ir_ref_instruction(field_ptr, irb->current_basic_block); | 7802 | ir_ref_instruction(field_ptr, irb->current_basic_block); |
| 6776 | ir_build_reset_result(irb, scope, expr_node, &result_loc_inst->base); | 7803 | ir_build_reset_result(irb, scope, expr_node, &result_loc_inst->base); |
| 6777 | | 7804 | |
| 6778 | IrInstruction *expr_value = ir_gen_node_extra(irb, expr_node, scope, LValNone, | 7805 | IrInstSrc *expr_value = ir_gen_node_extra(irb, expr_node, scope, LValNone, |
| 6779 | &result_loc_inst->base); | 7806 | &result_loc_inst->base); |
| 6780 | if (expr_value == irb->codegen->invalid_instruction) | 7807 | if (expr_value == irb->codegen->invalid_inst_src) |
| 6781 | return expr_value; | 7808 | return expr_value; |
| 6782 | | 7809 | |
| 6783 | IrInstruction *init_union = ir_build_union_init_named_field(irb, scope, source_node, union_type, | 7810 | IrInstSrc *init_union = ir_build_union_init_named_field(irb, scope, source_node, union_type, |
| 6784 | field_name, field_ptr, container_ptr); | 7811 | field_name, field_ptr, container_ptr); |
| 6785 | | 7812 | |
| 6786 | return ir_lval_wrap(irb, scope, init_union, lval, parent_result_loc); | 7813 | return ir_lval_wrap(irb, scope, init_union, lval, parent_result_loc); |
| 6787 | } | 7814 | } |
| 6788 | | 7815 | |
| 6789 | static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 7816 | static IrInstSrc *ir_gen_container_init_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 6790 | ResultLoc *parent_result_loc) | 7817 | ResultLoc *parent_result_loc) |
| 6791 | { | 7818 | { |
| 6792 | assert(node->type == NodeTypeContainerInitExpr); | 7819 | assert(node->type == NodeTypeContainerInitExpr); |
| ... | @@ -6798,42 +7825,42 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A | ... | @@ -6798,42 +7825,42 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 6798 | ResultLoc *child_result_loc; | 7825 | ResultLoc *child_result_loc; |
| 6799 | AstNode *init_array_type_source_node; | 7826 | AstNode *init_array_type_source_node; |
| 6800 | if (container_init_expr->type != nullptr) { | 7827 | if (container_init_expr->type != nullptr) { |
| 6801 | IrInstruction *container_type; | 7828 | IrInstSrc *container_type; |
| 6802 | if (container_init_expr->type->type == NodeTypeInferredArrayType) { | 7829 | if (container_init_expr->type->type == NodeTypeInferredArrayType) { |
| 6803 | if (kind == ContainerInitKindStruct) { | 7830 | if (kind == ContainerInitKindStruct) { |
| 6804 | add_node_error(irb->codegen, container_init_expr->type, | 7831 | add_node_error(irb->codegen, container_init_expr->type, |
| 6805 | buf_sprintf("initializing array with struct syntax")); | 7832 | buf_sprintf("initializing array with struct syntax")); |
| 6806 | return irb->codegen->invalid_instruction; | 7833 | return irb->codegen->invalid_inst_src; |
| 6807 | } | 7834 | } |
| 6808 | IrInstruction *sentinel; | 7835 | IrInstSrc *sentinel; |
| 6809 | if (container_init_expr->type->data.inferred_array_type.sentinel != nullptr) { | 7836 | if (container_init_expr->type->data.inferred_array_type.sentinel != nullptr) { |
| 6810 | sentinel = ir_gen_node(irb, container_init_expr->type->data.inferred_array_type.sentinel, scope); | 7837 | sentinel = ir_gen_node(irb, container_init_expr->type->data.inferred_array_type.sentinel, scope); |
| 6811 | if (sentinel == irb->codegen->invalid_instruction) | 7838 | if (sentinel == irb->codegen->invalid_inst_src) |
| 6812 | return sentinel; | 7839 | return sentinel; |
| 6813 | } else { | 7840 | } else { |
| 6814 | sentinel = nullptr; | 7841 | sentinel = nullptr; |
| 6815 | } | 7842 | } |
| 6816 | | 7843 | |
| 6817 | IrInstruction *elem_type = ir_gen_node(irb, | 7844 | IrInstSrc *elem_type = ir_gen_node(irb, |
| 6818 | container_init_expr->type->data.inferred_array_type.child_type, scope); | 7845 | container_init_expr->type->data.inferred_array_type.child_type, scope); |
| 6819 | if (elem_type == irb->codegen->invalid_instruction) | 7846 | if (elem_type == irb->codegen->invalid_inst_src) |
| 6820 | return elem_type; | 7847 | return elem_type; |
| 6821 | size_t item_count = container_init_expr->entries.length; | 7848 | size_t item_count = container_init_expr->entries.length; |
| 6822 | IrInstruction *item_count_inst = ir_build_const_usize(irb, scope, node, item_count); | 7849 | IrInstSrc *item_count_inst = ir_build_const_usize(irb, scope, node, item_count); |
| 6823 | container_type = ir_build_array_type(irb, scope, node, item_count_inst, sentinel, elem_type); | 7850 | container_type = ir_build_array_type(irb, scope, node, item_count_inst, sentinel, elem_type); |
| 6824 | } else { | 7851 | } else { |
| 6825 | container_type = ir_gen_node(irb, container_init_expr->type, scope); | 7852 | container_type = ir_gen_node(irb, container_init_expr->type, scope); |
| 6826 | if (container_type == irb->codegen->invalid_instruction) | 7853 | if (container_type == irb->codegen->invalid_inst_src) |
| 6827 | return container_type; | 7854 | return container_type; |
| 6828 | } | 7855 | } |
| 6829 | | 7856 | |
| 6830 | result_loc_cast = ir_build_cast_result_loc(irb, container_type, parent_result_loc); | 7857 | result_loc_cast = ir_build_cast_result_loc(irb, container_type, parent_result_loc); |
| 6831 | child_result_loc = &result_loc_cast->base; | 7858 | child_result_loc = &result_loc_cast->base; |
| 6832 | init_array_type_source_node = container_type->source_node; | 7859 | init_array_type_source_node = container_type->base.source_node; |
| 6833 | } else { | 7860 | } else { |
| 6834 | child_result_loc = parent_result_loc; | 7861 | child_result_loc = parent_result_loc; |
| 6835 | if (parent_result_loc->source_instruction != nullptr) { | 7862 | if (parent_result_loc->source_instruction != nullptr) { |
| 6836 | init_array_type_source_node = parent_result_loc->source_instruction->source_node; | 7863 | init_array_type_source_node = parent_result_loc->source_instruction->base.source_node; |
| 6837 | } else { | 7864 | } else { |
| 6838 | init_array_type_source_node = node; | 7865 | init_array_type_source_node = node; |
| 6839 | } | 7866 | } |
| ... | @@ -6841,11 +7868,11 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A | ... | @@ -6841,11 +7868,11 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 6841 | | 7868 | |
| 6842 | switch (kind) { | 7869 | switch (kind) { |
| 6843 | case ContainerInitKindStruct: { | 7870 | case ContainerInitKindStruct: { |
| 6844 | IrInstruction *container_ptr = ir_build_resolve_result(irb, scope, node, child_result_loc, | 7871 | IrInstSrc *container_ptr = ir_build_resolve_result(irb, scope, node, child_result_loc, |
| 6845 | nullptr); | 7872 | nullptr); |
| 6846 | | 7873 | |
| 6847 | size_t field_count = container_init_expr->entries.length; | 7874 | size_t field_count = container_init_expr->entries.length; |
| 6848 | IrInstructionContainerInitFieldsField *fields = allocate<IrInstructionContainerInitFieldsField>(field_count); | 7875 | IrInstSrcContainerInitFieldsField *fields = allocate<IrInstSrcContainerInitFieldsField>(field_count); |
| 6849 | for (size_t i = 0; i < field_count; i += 1) { | 7876 | for (size_t i = 0; i < field_count; i += 1) { |
| 6850 | AstNode *entry_node = container_init_expr->entries.at(i); | 7877 | AstNode *entry_node = container_init_expr->entries.at(i); |
| 6851 | assert(entry_node->type == NodeTypeStructValueField); | 7878 | assert(entry_node->type == NodeTypeStructValueField); |
| ... | @@ -6853,7 +7880,7 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A | ... | @@ -6853,7 +7880,7 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 6853 | Buf *name = entry_node->data.struct_val_field.name; | 7880 | Buf *name = entry_node->data.struct_val_field.name; |
| 6854 | AstNode *expr_node = entry_node->data.struct_val_field.expr; | 7881 | AstNode *expr_node = entry_node->data.struct_val_field.expr; |
| 6855 | | 7882 | |
| 6856 | IrInstruction *field_ptr = ir_build_field_ptr(irb, scope, entry_node, container_ptr, name, true); | 7883 | IrInstSrc *field_ptr = ir_build_field_ptr(irb, scope, entry_node, container_ptr, name, true); |
| 6857 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); | 7884 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); |
| 6858 | result_loc_inst->base.id = ResultLocIdInstruction; | 7885 | result_loc_inst->base.id = ResultLocIdInstruction; |
| 6859 | result_loc_inst->base.source_instruction = field_ptr; | 7886 | result_loc_inst->base.source_instruction = field_ptr; |
| ... | @@ -6861,16 +7888,16 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A | ... | @@ -6861,16 +7888,16 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 6861 | ir_ref_instruction(field_ptr, irb->current_basic_block); | 7888 | ir_ref_instruction(field_ptr, irb->current_basic_block); |
| 6862 | ir_build_reset_result(irb, scope, expr_node, &result_loc_inst->base); | 7889 | ir_build_reset_result(irb, scope, expr_node, &result_loc_inst->base); |
| 6863 | | 7890 | |
| 6864 | IrInstruction *expr_value = ir_gen_node_extra(irb, expr_node, scope, LValNone, | 7891 | IrInstSrc *expr_value = ir_gen_node_extra(irb, expr_node, scope, LValNone, |
| 6865 | &result_loc_inst->base); | 7892 | &result_loc_inst->base); |
| 6866 | if (expr_value == irb->codegen->invalid_instruction) | 7893 | if (expr_value == irb->codegen->invalid_inst_src) |
| 6867 | return expr_value; | 7894 | return expr_value; |
| 6868 | | 7895 | |
| 6869 | fields[i].name = name; | 7896 | fields[i].name = name; |
| 6870 | fields[i].source_node = entry_node; | 7897 | fields[i].source_node = entry_node; |
| 6871 | fields[i].result_loc = field_ptr; | 7898 | fields[i].result_loc = field_ptr; |
| 6872 | } | 7899 | } |
| 6873 | IrInstruction *result = ir_build_container_init_fields(irb, scope, node, field_count, | 7900 | IrInstSrc *result = ir_build_container_init_fields(irb, scope, node, field_count, |
| 6874 | fields, container_ptr); | 7901 | fields, container_ptr); |
| 6875 | | 7902 | |
| 6876 | if (result_loc_cast != nullptr) { | 7903 | if (result_loc_cast != nullptr) { |
| ... | @@ -6881,15 +7908,15 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A | ... | @@ -6881,15 +7908,15 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 6881 | case ContainerInitKindArray: { | 7908 | case ContainerInitKindArray: { |
| 6882 | size_t item_count = container_init_expr->entries.length; | 7909 | size_t item_count = container_init_expr->entries.length; |
| 6883 | | 7910 | |
| 6884 | IrInstruction *container_ptr = ir_build_resolve_result(irb, scope, node, child_result_loc, | 7911 | IrInstSrc *container_ptr = ir_build_resolve_result(irb, scope, node, child_result_loc, |
| 6885 | nullptr); | 7912 | nullptr); |
| 6886 | | 7913 | |
| 6887 | IrInstruction **result_locs = allocate<IrInstruction *>(item_count); | 7914 | IrInstSrc **result_locs = allocate<IrInstSrc *>(item_count); |
| 6888 | for (size_t i = 0; i < item_count; i += 1) { | 7915 | for (size_t i = 0; i < item_count; i += 1) { |
| 6889 | AstNode *expr_node = container_init_expr->entries.at(i); | 7916 | AstNode *expr_node = container_init_expr->entries.at(i); |
| 6890 | | 7917 | |
| 6891 | IrInstruction *elem_index = ir_build_const_usize(irb, scope, expr_node, i); | 7918 | IrInstSrc *elem_index = ir_build_const_usize(irb, scope, expr_node, i); |
| 6892 | IrInstruction *elem_ptr = ir_build_elem_ptr(irb, scope, expr_node, container_ptr, | 7919 | IrInstSrc *elem_ptr = ir_build_elem_ptr(irb, scope, expr_node, container_ptr, |
| 6893 | elem_index, false, PtrLenSingle, init_array_type_source_node); | 7920 | elem_index, false, PtrLenSingle, init_array_type_source_node); |
| 6894 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); | 7921 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); |
| 6895 | result_loc_inst->base.id = ResultLocIdInstruction; | 7922 | result_loc_inst->base.id = ResultLocIdInstruction; |
| ... | @@ -6898,14 +7925,14 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A | ... | @@ -6898,14 +7925,14 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 6898 | ir_ref_instruction(elem_ptr, irb->current_basic_block); | 7925 | ir_ref_instruction(elem_ptr, irb->current_basic_block); |
| 6899 | ir_build_reset_result(irb, scope, expr_node, &result_loc_inst->base); | 7926 | ir_build_reset_result(irb, scope, expr_node, &result_loc_inst->base); |
| 6900 | | 7927 | |
| 6901 | IrInstruction *expr_value = ir_gen_node_extra(irb, expr_node, scope, LValNone, | 7928 | IrInstSrc *expr_value = ir_gen_node_extra(irb, expr_node, scope, LValNone, |
| 6902 | &result_loc_inst->base); | 7929 | &result_loc_inst->base); |
| 6903 | if (expr_value == irb->codegen->invalid_instruction) | 7930 | if (expr_value == irb->codegen->invalid_inst_src) |
| 6904 | return expr_value; | 7931 | return expr_value; |
| 6905 | | 7932 | |
| 6906 | result_locs[i] = elem_ptr; | 7933 | result_locs[i] = elem_ptr; |
| 6907 | } | 7934 | } |
| 6908 | IrInstruction *result = ir_build_container_init_list(irb, scope, node, item_count, | 7935 | IrInstSrc *result = ir_build_container_init_list(irb, scope, node, item_count, |
| 6909 | result_locs, container_ptr, init_array_type_source_node); | 7936 | result_locs, container_ptr, init_array_type_source_node); |
| 6910 | if (result_loc_cast != nullptr) { | 7937 | if (result_loc_cast != nullptr) { |
| 6911 | result = ir_build_implicit_cast(irb, scope, node, result, result_loc_cast); | 7938 | result = ir_build_implicit_cast(irb, scope, node, result, result_loc_cast); |
| ... | @@ -6916,19 +7943,19 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A | ... | @@ -6916,19 +7943,19 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 6916 | zig_unreachable(); | 7943 | zig_unreachable(); |
| 6917 | } | 7944 | } |
| 6918 | | 7945 | |
| 6919 | static ResultLocVar *ir_build_var_result_loc(IrBuilder *irb, IrInstruction *alloca, ZigVar *var) { | 7946 | static ResultLocVar *ir_build_var_result_loc(IrBuilderSrc *irb, IrInstSrc *alloca, ZigVar *var) { |
| 6920 | ResultLocVar *result_loc_var = allocate<ResultLocVar>(1); | 7947 | ResultLocVar *result_loc_var = allocate<ResultLocVar>(1); |
| 6921 | result_loc_var->base.id = ResultLocIdVar; | 7948 | result_loc_var->base.id = ResultLocIdVar; |
| 6922 | result_loc_var->base.source_instruction = alloca; | 7949 | result_loc_var->base.source_instruction = alloca; |
| 6923 | result_loc_var->base.allow_write_through_const = true; | 7950 | result_loc_var->base.allow_write_through_const = true; |
| 6924 | result_loc_var->var = var; | 7951 | result_loc_var->var = var; |
| 6925 | | 7952 | |
| 6926 | ir_build_reset_result(irb, alloca->scope, alloca->source_node, &result_loc_var->base); | 7953 | ir_build_reset_result(irb, alloca->base.scope, alloca->base.source_node, &result_loc_var->base); |
| 6927 | | 7954 | |
| 6928 | return result_loc_var; | 7955 | return result_loc_var; |
| 6929 | } | 7956 | } |
| 6930 | | 7957 | |
| 6931 | static ResultLocCast *ir_build_cast_result_loc(IrBuilder *irb, IrInstruction *dest_type, | 7958 | static ResultLocCast *ir_build_cast_result_loc(IrBuilderSrc *irb, IrInstSrc *dest_type, |
| 6932 | ResultLoc *parent_result_loc) | 7959 | ResultLoc *parent_result_loc) |
| 6933 | { | 7960 | { |
| 6934 | ResultLocCast *result_loc_cast = allocate<ResultLocCast>(1); | 7961 | ResultLocCast *result_loc_cast = allocate<ResultLocCast>(1); |
| ... | @@ -6938,37 +7965,37 @@ static ResultLocCast *ir_build_cast_result_loc(IrBuilder *irb, IrInstruction *de | ... | @@ -6938,37 +7965,37 @@ static ResultLocCast *ir_build_cast_result_loc(IrBuilder *irb, IrInstruction *de |
| 6938 | ir_ref_instruction(dest_type, irb->current_basic_block); | 7965 | ir_ref_instruction(dest_type, irb->current_basic_block); |
| 6939 | result_loc_cast->parent = parent_result_loc; | 7966 | result_loc_cast->parent = parent_result_loc; |
| 6940 | | 7967 | |
| 6941 | ir_build_reset_result(irb, dest_type->scope, dest_type->source_node, &result_loc_cast->base); | 7968 | ir_build_reset_result(irb, dest_type->base.scope, dest_type->base.source_node, &result_loc_cast->base); |
| 6942 | | 7969 | |
| 6943 | return result_loc_cast; | 7970 | return result_loc_cast; |
| 6944 | } | 7971 | } |
| 6945 | | 7972 | |
| 6946 | static void build_decl_var_and_init(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigVar *var, | 7973 | static void build_decl_var_and_init(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, ZigVar *var, |
| 6947 | IrInstruction *init, const char *name_hint, IrInstruction *is_comptime) | 7974 | IrInstSrc *init, const char *name_hint, IrInstSrc *is_comptime) |
| 6948 | { | 7975 | { |
| 6949 | IrInstruction *alloca = ir_build_alloca_src(irb, scope, source_node, nullptr, name_hint, is_comptime); | 7976 | IrInstSrc *alloca = ir_build_alloca_src(irb, scope, source_node, nullptr, name_hint, is_comptime); |
| 6950 | ResultLocVar *var_result_loc = ir_build_var_result_loc(irb, alloca, var); | 7977 | ResultLocVar *var_result_loc = ir_build_var_result_loc(irb, alloca, var); |
| 6951 | ir_build_end_expr(irb, scope, source_node, init, &var_result_loc->base); | 7978 | ir_build_end_expr(irb, scope, source_node, init, &var_result_loc->base); |
| 6952 | ir_build_var_decl_src(irb, scope, source_node, var, nullptr, alloca); | 7979 | ir_build_var_decl_src(irb, scope, source_node, var, nullptr, alloca); |
| 6953 | } | 7980 | } |
| 6954 | | 7981 | |
| 6955 | static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *node) { | 7982 | static IrInstSrc *ir_gen_var_decl(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 6956 | assert(node->type == NodeTypeVariableDeclaration); | 7983 | assert(node->type == NodeTypeVariableDeclaration); |
| 6957 | | 7984 | |
| 6958 | AstNodeVariableDeclaration *variable_declaration = &node->data.variable_declaration; | 7985 | AstNodeVariableDeclaration *variable_declaration = &node->data.variable_declaration; |
| 6959 | | 7986 | |
| 6960 | if (buf_eql_str(variable_declaration->symbol, "_")) { | 7987 | if (buf_eql_str(variable_declaration->symbol, "_")) { |
| 6961 | add_node_error(irb->codegen, node, buf_sprintf("`_` is not a declarable symbol")); | 7988 | add_node_error(irb->codegen, node, buf_sprintf("`_` is not a declarable symbol")); |
| 6962 | return irb->codegen->invalid_instruction; | 7989 | return irb->codegen->invalid_inst_src; |
| 6963 | } | 7990 | } |
| 6964 | | 7991 | |
| 6965 | // Used for the type expr and the align expr | 7992 | // Used for the type expr and the align expr |
| 6966 | Scope *comptime_scope = create_comptime_scope(irb->codegen, node, scope); | 7993 | Scope *comptime_scope = create_comptime_scope(irb->codegen, node, scope); |
| 6967 | | 7994 | |
| 6968 | IrInstruction *type_instruction; | 7995 | IrInstSrc *type_instruction; |
| 6969 | if (variable_declaration->type != nullptr) { | 7996 | if (variable_declaration->type != nullptr) { |
| 6970 | type_instruction = ir_gen_node(irb, variable_declaration->type, comptime_scope); | 7997 | type_instruction = ir_gen_node(irb, variable_declaration->type, comptime_scope); |
| 6971 | if (type_instruction == irb->codegen->invalid_instruction) | 7998 | if (type_instruction == irb->codegen->invalid_inst_src) |
| 6972 | return type_instruction; | 7999 | return type_instruction; |
| 6973 | } else { | 8000 | } else { |
| 6974 | type_instruction = nullptr; | 8001 | type_instruction = nullptr; |
| ... | @@ -6979,22 +8006,22 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -6979,22 +8006,22 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod |
| 6979 | bool is_extern = variable_declaration->is_extern; | 8006 | bool is_extern = variable_declaration->is_extern; |
| 6980 | | 8007 | |
| 6981 | bool is_comptime_scalar = ir_should_inline(irb->exec, scope) || variable_declaration->is_comptime; | 8008 | bool is_comptime_scalar = ir_should_inline(irb->exec, scope) || variable_declaration->is_comptime; |
| 6982 | IrInstruction *is_comptime = ir_build_const_bool(irb, scope, node, is_comptime_scalar); | 8009 | IrInstSrc *is_comptime = ir_build_const_bool(irb, scope, node, is_comptime_scalar); |
| 6983 | ZigVar *var = ir_create_var(irb, node, scope, variable_declaration->symbol, | 8010 | ZigVar *var = ir_create_var(irb, node, scope, variable_declaration->symbol, |
| 6984 | is_const, is_const, is_shadowable, is_comptime); | 8011 | is_const, is_const, is_shadowable, is_comptime); |
| 6985 | // we detect IrInstructionIdDeclVarSrc in gen_block to make sure the next node | 8012 | // we detect IrInstSrcDeclVar in gen_block to make sure the next node |
| 6986 | // is inside var->child_scope | 8013 | // is inside var->child_scope |
| 6987 | | 8014 | |
| 6988 | if (!is_extern && !variable_declaration->expr) { | 8015 | if (!is_extern && !variable_declaration->expr) { |
| 6989 | var->var_type = irb->codegen->builtin_types.entry_invalid; | 8016 | var->var_type = irb->codegen->builtin_types.entry_invalid; |
| 6990 | add_node_error(irb->codegen, node, buf_sprintf("variables must be initialized")); | 8017 | add_node_error(irb->codegen, node, buf_sprintf("variables must be initialized")); |
| 6991 | return irb->codegen->invalid_instruction; | 8018 | return irb->codegen->invalid_inst_src; |
| 6992 | } | 8019 | } |
| 6993 | | 8020 | |
| 6994 | IrInstruction *align_value = nullptr; | 8021 | IrInstSrc *align_value = nullptr; |
| 6995 | if (variable_declaration->align_expr != nullptr) { | 8022 | if (variable_declaration->align_expr != nullptr) { |
| 6996 | align_value = ir_gen_node(irb, variable_declaration->align_expr, comptime_scope); | 8023 | align_value = ir_gen_node(irb, variable_declaration->align_expr, comptime_scope); |
| 6997 | if (align_value == irb->codegen->invalid_instruction) | 8024 | if (align_value == irb->codegen->invalid_inst_src) |
| 6998 | return align_value; | 8025 | return align_value; |
| 6999 | } | 8026 | } |
| 7000 | | 8027 | |
| ... | @@ -7006,7 +8033,7 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -7006,7 +8033,7 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod |
| 7006 | // Parser should ensure that this never happens | 8033 | // Parser should ensure that this never happens |
| 7007 | assert(variable_declaration->threadlocal_tok == nullptr); | 8034 | assert(variable_declaration->threadlocal_tok == nullptr); |
| 7008 | | 8035 | |
| 7009 | IrInstruction *alloca = ir_build_alloca_src(irb, scope, node, align_value, | 8036 | IrInstSrc *alloca = ir_build_alloca_src(irb, scope, node, align_value, |
| 7010 | buf_ptr(variable_declaration->symbol), is_comptime); | 8037 | buf_ptr(variable_declaration->symbol), is_comptime); |
| 7011 | | 8038 | |
| 7012 | // Create a result location for the initialization expression. | 8039 | // Create a result location for the initialization expression. |
| ... | @@ -7024,19 +8051,19 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -7024,19 +8051,19 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod |
| 7024 | Scope *init_scope = is_comptime_scalar ? | 8051 | Scope *init_scope = is_comptime_scalar ? |
| 7025 | create_comptime_scope(irb->codegen, variable_declaration->expr, scope) : scope; | 8052 | create_comptime_scope(irb->codegen, variable_declaration->expr, scope) : scope; |
| 7026 | | 8053 | |
| 7027 | // Temporarily set the name of the IrExecutable to the VariableDeclaration | 8054 | // Temporarily set the name of the IrExecutableSrc to the VariableDeclaration |
| 7028 | // so that the struct or enum from the init expression inherits the name. | 8055 | // so that the struct or enum from the init expression inherits the name. |
| 7029 | Buf *old_exec_name = irb->exec->name; | 8056 | Buf *old_exec_name = irb->exec->name; |
| 7030 | irb->exec->name = variable_declaration->symbol; | 8057 | irb->exec->name = variable_declaration->symbol; |
| 7031 | IrInstruction *init_value = ir_gen_node_extra(irb, variable_declaration->expr, init_scope, | 8058 | IrInstSrc *init_value = ir_gen_node_extra(irb, variable_declaration->expr, init_scope, |
| 7032 | LValNone, init_result_loc); | 8059 | LValNone, init_result_loc); |
| 7033 | irb->exec->name = old_exec_name; | 8060 | irb->exec->name = old_exec_name; |
| 7034 | | 8061 | |
| 7035 | if (init_value == irb->codegen->invalid_instruction) | 8062 | if (init_value == irb->codegen->invalid_inst_src) |
| 7036 | return irb->codegen->invalid_instruction; | 8063 | return irb->codegen->invalid_inst_src; |
| 7037 | | 8064 | |
| 7038 | if (result_loc_cast != nullptr) { | 8065 | if (result_loc_cast != nullptr) { |
| 7039 | IrInstruction *implicit_cast = ir_build_implicit_cast(irb, scope, init_value->source_node, | 8066 | IrInstSrc *implicit_cast = ir_build_implicit_cast(irb, scope, init_value->base.source_node, |
| 7040 | init_value, result_loc_cast); | 8067 | init_value, result_loc_cast); |
| 7041 | ir_build_end_expr(irb, scope, node, implicit_cast, &result_loc_var->base); | 8068 | ir_build_end_expr(irb, scope, node, implicit_cast, &result_loc_var->base); |
| 7042 | } | 8069 | } |
| ... | @@ -7044,7 +8071,7 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -7044,7 +8071,7 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod |
| 7044 | return ir_build_var_decl_src(irb, scope, node, var, align_value, alloca); | 8071 | return ir_build_var_decl_src(irb, scope, node, var, align_value, alloca); |
| 7045 | } | 8072 | } |
| 7046 | | 8073 | |
| 7047 | static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 8074 | static IrInstSrc *ir_gen_while_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 7048 | ResultLoc *result_loc) | 8075 | ResultLoc *result_loc) |
| 7049 | { | 8076 | { |
| 7050 | assert(node->type == NodeTypeWhileExpr); | 8077 | assert(node->type == NodeTypeWhileExpr); |
| ... | @@ -7052,15 +8079,15 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7052,15 +8079,15 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7052 | AstNode *continue_expr_node = node->data.while_expr.continue_expr; | 8079 | AstNode *continue_expr_node = node->data.while_expr.continue_expr; |
| 7053 | AstNode *else_node = node->data.while_expr.else_node; | 8080 | AstNode *else_node = node->data.while_expr.else_node; |
| 7054 | | 8081 | |
| 7055 | IrBasicBlock *cond_block = ir_create_basic_block(irb, scope, "WhileCond"); | 8082 | IrBasicBlockSrc *cond_block = ir_create_basic_block(irb, scope, "WhileCond"); |
| 7056 | IrBasicBlock *body_block = ir_create_basic_block(irb, scope, "WhileBody"); | 8083 | IrBasicBlockSrc *body_block = ir_create_basic_block(irb, scope, "WhileBody"); |
| 7057 | IrBasicBlock *continue_block = continue_expr_node ? | 8084 | IrBasicBlockSrc *continue_block = continue_expr_node ? |
| 7058 | ir_create_basic_block(irb, scope, "WhileContinue") : cond_block; | 8085 | ir_create_basic_block(irb, scope, "WhileContinue") : cond_block; |
| 7059 | IrBasicBlock *end_block = ir_create_basic_block(irb, scope, "WhileEnd"); | 8086 | IrBasicBlockSrc *end_block = ir_create_basic_block(irb, scope, "WhileEnd"); |
| 7060 | IrBasicBlock *else_block = else_node ? | 8087 | IrBasicBlockSrc *else_block = else_node ? |
| 7061 | ir_create_basic_block(irb, scope, "WhileElse") : end_block; | 8088 | ir_create_basic_block(irb, scope, "WhileElse") : end_block; |
| 7062 | | 8089 | |
| 7063 | IrInstruction *is_comptime = ir_build_const_bool(irb, scope, node, | 8090 | IrInstSrc *is_comptime = ir_build_const_bool(irb, scope, node, |
| 7064 | ir_should_inline(irb->exec, scope) || node->data.while_expr.is_inline); | 8091 | ir_should_inline(irb->exec, scope) || node->data.while_expr.is_inline); |
| 7065 | ir_build_br(irb, scope, node, cond_block, is_comptime); | 8092 | ir_build_br(irb, scope, node, cond_block, is_comptime); |
| 7066 | | 8093 | |
| ... | @@ -7081,15 +8108,15 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7081,15 +8108,15 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7081 | } else { | 8108 | } else { |
| 7082 | payload_scope = subexpr_scope; | 8109 | payload_scope = subexpr_scope; |
| 7083 | } | 8110 | } |
| 7084 | IrInstruction *err_val_ptr = ir_gen_node_extra(irb, node->data.while_expr.condition, subexpr_scope, | 8111 | IrInstSrc *err_val_ptr = ir_gen_node_extra(irb, node->data.while_expr.condition, subexpr_scope, |
| 7085 | LValPtr, nullptr); | 8112 | LValPtr, nullptr); |
| 7086 | if (err_val_ptr == irb->codegen->invalid_instruction) | 8113 | if (err_val_ptr == irb->codegen->invalid_inst_src) |
| 7087 | return err_val_ptr; | 8114 | return err_val_ptr; |
| 7088 | IrInstruction *is_err = ir_build_test_err_src(irb, scope, node->data.while_expr.condition, err_val_ptr, | 8115 | IrInstSrc *is_err = ir_build_test_err_src(irb, scope, node->data.while_expr.condition, err_val_ptr, |
| 7089 | true, false); | 8116 | true, false); |
| 7090 | IrBasicBlock *after_cond_block = irb->current_basic_block; | 8117 | IrBasicBlockSrc *after_cond_block = irb->current_basic_block; |
| 7091 | IrInstruction *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, scope, node)); | 8118 | IrInstSrc *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, scope, node)); |
| 7092 | IrInstruction *cond_br_inst; | 8119 | IrInstSrc *cond_br_inst; |
| 7093 | if (!instr_is_unreachable(is_err)) { | 8120 | if (!instr_is_unreachable(is_err)) { |
| 7094 | cond_br_inst = ir_build_cond_br(irb, scope, node->data.while_expr.condition, is_err, | 8121 | cond_br_inst = ir_build_cond_br(irb, scope, node->data.while_expr.condition, is_err, |
| 7095 | else_block, body_block, is_comptime); | 8122 | else_block, body_block, is_comptime); |
| ... | @@ -7104,15 +8131,15 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7104,15 +8131,15 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7104 | | 8131 | |
| 7105 | ir_set_cursor_at_end_and_append_block(irb, body_block); | 8132 | ir_set_cursor_at_end_and_append_block(irb, body_block); |
| 7106 | if (var_symbol) { | 8133 | if (var_symbol) { |
| 7107 | IrInstruction *payload_ptr = ir_build_unwrap_err_payload(irb, payload_scope, symbol_node, | 8134 | IrInstSrc *payload_ptr = ir_build_unwrap_err_payload_src(irb, payload_scope, symbol_node, |
| 7108 | err_val_ptr, false, false); | 8135 | err_val_ptr, false, false); |
| 7109 | IrInstruction *var_ptr = node->data.while_expr.var_is_ptr ? | 8136 | IrInstSrc *var_ptr = node->data.while_expr.var_is_ptr ? |
| 7110 | ir_build_ref(irb, payload_scope, symbol_node, payload_ptr, true, false) : payload_ptr; | 8137 | ir_build_ref_src(irb, payload_scope, symbol_node, payload_ptr, true, false) : payload_ptr; |
| 7111 | ir_build_var_decl_src(irb, payload_scope, symbol_node, payload_var, nullptr, var_ptr); | 8138 | ir_build_var_decl_src(irb, payload_scope, symbol_node, payload_var, nullptr, var_ptr); |
| 7112 | } | 8139 | } |
| 7113 | | 8140 | |
| 7114 | ZigList<IrInstruction *> incoming_values = {0}; | 8141 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 7115 | ZigList<IrBasicBlock *> incoming_blocks = {0}; | 8142 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; |
| 7116 | | 8143 | |
| 7117 | ScopeLoop *loop_scope = create_loop_scope(irb->codegen, node, payload_scope); | 8144 | ScopeLoop *loop_scope = create_loop_scope(irb->codegen, node, payload_scope); |
| 7118 | loop_scope->break_block = end_block; | 8145 | loop_scope->break_block = end_block; |
| ... | @@ -7126,8 +8153,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7126,8 +8153,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7126 | // Note the body block of the loop is not the place that lval and result_loc are used - | 8153 | // Note the body block of the loop is not the place that lval and result_loc are used - |
| 7127 | // it's actually in break statements, handled similarly to return statements. | 8154 | // it's actually in break statements, handled similarly to return statements. |
| 7128 | // That is why we set those values in loop_scope above and not in this ir_gen_node call. | 8155 | // That is why we set those values in loop_scope above and not in this ir_gen_node call. |
| 7129 | IrInstruction *body_result = ir_gen_node(irb, node->data.while_expr.body, &loop_scope->base); | 8156 | IrInstSrc *body_result = ir_gen_node(irb, node->data.while_expr.body, &loop_scope->base); |
| 7130 | if (body_result == irb->codegen->invalid_instruction) | 8157 | if (body_result == irb->codegen->invalid_inst_src) |
| 7131 | return body_result; | 8158 | return body_result; |
| 7132 | | 8159 | |
| 7133 | if (!instr_is_unreachable(body_result)) { | 8160 | if (!instr_is_unreachable(body_result)) { |
| ... | @@ -7137,8 +8164,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7137,8 +8164,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7137 | | 8164 | |
| 7138 | if (continue_expr_node) { | 8165 | if (continue_expr_node) { |
| 7139 | ir_set_cursor_at_end_and_append_block(irb, continue_block); | 8166 | ir_set_cursor_at_end_and_append_block(irb, continue_block); |
| 7140 | IrInstruction *expr_result = ir_gen_node(irb, continue_expr_node, payload_scope); | 8167 | IrInstSrc *expr_result = ir_gen_node(irb, continue_expr_node, payload_scope); |
| 7141 | if (expr_result == irb->codegen->invalid_instruction) | 8168 | if (expr_result == irb->codegen->invalid_inst_src) |
| 7142 | return expr_result; | 8169 | return expr_result; |
| 7143 | if (!instr_is_unreachable(expr_result)) { | 8170 | if (!instr_is_unreachable(expr_result)) { |
| 7144 | ir_mark_gen(ir_build_check_statement_is_void(irb, payload_scope, continue_expr_node, expr_result)); | 8171 | ir_mark_gen(ir_build_check_statement_is_void(irb, payload_scope, continue_expr_node, expr_result)); |
| ... | @@ -7154,7 +8181,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7154,7 +8181,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7154 | ZigVar *err_var = ir_create_var(irb, err_symbol_node, scope, err_symbol, | 8181 | ZigVar *err_var = ir_create_var(irb, err_symbol_node, scope, err_symbol, |
| 7155 | true, false, false, is_comptime); | 8182 | true, false, false, is_comptime); |
| 7156 | Scope *err_scope = err_var->child_scope; | 8183 | Scope *err_scope = err_var->child_scope; |
| 7157 | IrInstruction *err_ptr = ir_build_unwrap_err_code(irb, err_scope, err_symbol_node, err_val_ptr); | 8184 | IrInstSrc *err_ptr = ir_build_unwrap_err_code_src(irb, err_scope, err_symbol_node, err_val_ptr); |
| 7158 | ir_build_var_decl_src(irb, err_scope, symbol_node, err_var, nullptr, err_ptr); | 8185 | ir_build_var_decl_src(irb, err_scope, symbol_node, err_var, nullptr, err_ptr); |
| 7159 | | 8186 | |
| 7160 | if (peer_parent->peers.length != 0) { | 8187 | if (peer_parent->peers.length != 0) { |
| ... | @@ -7162,12 +8189,12 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7162,12 +8189,12 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7162 | } | 8189 | } |
| 7163 | ResultLocPeer *peer_result = create_peer_result(peer_parent); | 8190 | ResultLocPeer *peer_result = create_peer_result(peer_parent); |
| 7164 | peer_parent->peers.append(peer_result); | 8191 | peer_parent->peers.append(peer_result); |
| 7165 | IrInstruction *else_result = ir_gen_node_extra(irb, else_node, err_scope, lval, &peer_result->base); | 8192 | IrInstSrc *else_result = ir_gen_node_extra(irb, else_node, err_scope, lval, &peer_result->base); |
| 7166 | if (else_result == irb->codegen->invalid_instruction) | 8193 | if (else_result == irb->codegen->invalid_inst_src) |
| 7167 | return else_result; | 8194 | return else_result; |
| 7168 | if (!instr_is_unreachable(else_result)) | 8195 | if (!instr_is_unreachable(else_result)) |
| 7169 | ir_mark_gen(ir_build_br(irb, scope, node, end_block, is_comptime)); | 8196 | ir_mark_gen(ir_build_br(irb, scope, node, end_block, is_comptime)); |
| 7170 | IrBasicBlock *after_else_block = irb->current_basic_block; | 8197 | IrBasicBlockSrc *after_else_block = irb->current_basic_block; |
| 7171 | ir_set_cursor_at_end_and_append_block(irb, end_block); | 8198 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 7172 | if (else_result) { | 8199 | if (else_result) { |
| 7173 | incoming_blocks.append(after_else_block); | 8200 | incoming_blocks.append(after_else_block); |
| ... | @@ -7180,7 +8207,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7180,7 +8207,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7180 | peer_parent->peers.last()->next_bb = end_block; | 8207 | peer_parent->peers.last()->next_bb = end_block; |
| 7181 | } | 8208 | } |
| 7182 | | 8209 | |
| 7183 | IrInstruction *phi = ir_build_phi(irb, scope, node, incoming_blocks.length, | 8210 | IrInstSrc *phi = ir_build_phi(irb, scope, node, incoming_blocks.length, |
| 7184 | incoming_blocks.items, incoming_values.items, peer_parent); | 8211 | incoming_blocks.items, incoming_values.items, peer_parent); |
| 7185 | return ir_expr_wrap(irb, scope, phi, result_loc); | 8212 | return ir_expr_wrap(irb, scope, phi, result_loc); |
| 7186 | } else if (var_symbol != nullptr) { | 8213 | } else if (var_symbol != nullptr) { |
| ... | @@ -7192,15 +8219,15 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7192,15 +8219,15 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7192 | ZigVar *payload_var = ir_create_var(irb, symbol_node, subexpr_scope, var_symbol, | 8219 | ZigVar *payload_var = ir_create_var(irb, symbol_node, subexpr_scope, var_symbol, |
| 7193 | true, false, false, is_comptime); | 8220 | true, false, false, is_comptime); |
| 7194 | Scope *child_scope = payload_var->child_scope; | 8221 | Scope *child_scope = payload_var->child_scope; |
| 7195 | IrInstruction *maybe_val_ptr = ir_gen_node_extra(irb, node->data.while_expr.condition, subexpr_scope, | 8222 | IrInstSrc *maybe_val_ptr = ir_gen_node_extra(irb, node->data.while_expr.condition, subexpr_scope, |
| 7196 | LValPtr, nullptr); | 8223 | LValPtr, nullptr); |
| 7197 | if (maybe_val_ptr == irb->codegen->invalid_instruction) | 8224 | if (maybe_val_ptr == irb->codegen->invalid_inst_src) |
| 7198 | return maybe_val_ptr; | 8225 | return maybe_val_ptr; |
| 7199 | IrInstruction *maybe_val = ir_build_load_ptr(irb, scope, node->data.while_expr.condition, maybe_val_ptr); | 8226 | IrInstSrc *maybe_val = ir_build_load_ptr(irb, scope, node->data.while_expr.condition, maybe_val_ptr); |
| 7200 | IrInstruction *is_non_null = ir_build_test_nonnull(irb, scope, node->data.while_expr.condition, maybe_val); | 8227 | IrInstSrc *is_non_null = ir_build_test_non_null_src(irb, scope, node->data.while_expr.condition, maybe_val); |
| 7201 | IrBasicBlock *after_cond_block = irb->current_basic_block; | 8228 | IrBasicBlockSrc *after_cond_block = irb->current_basic_block; |
| 7202 | IrInstruction *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, scope, node)); | 8229 | IrInstSrc *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, scope, node)); |
| 7203 | IrInstruction *cond_br_inst; | 8230 | IrInstSrc *cond_br_inst; |
| 7204 | if (!instr_is_unreachable(is_non_null)) { | 8231 | if (!instr_is_unreachable(is_non_null)) { |
| 7205 | cond_br_inst = ir_build_cond_br(irb, scope, node->data.while_expr.condition, is_non_null, | 8232 | cond_br_inst = ir_build_cond_br(irb, scope, node->data.while_expr.condition, is_non_null, |
| 7206 | body_block, else_block, is_comptime); | 8233 | body_block, else_block, is_comptime); |
| ... | @@ -7214,13 +8241,13 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7214,13 +8241,13 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7214 | is_comptime); | 8241 | is_comptime); |
| 7215 | | 8242 | |
| 7216 | ir_set_cursor_at_end_and_append_block(irb, body_block); | 8243 | ir_set_cursor_at_end_and_append_block(irb, body_block); |
| 7217 | IrInstruction *payload_ptr = ir_build_optional_unwrap_ptr(irb, child_scope, symbol_node, maybe_val_ptr, false, false); | 8244 | IrInstSrc *payload_ptr = ir_build_optional_unwrap_ptr(irb, child_scope, symbol_node, maybe_val_ptr, false, false); |
| 7218 | IrInstruction *var_ptr = node->data.while_expr.var_is_ptr ? | 8245 | IrInstSrc *var_ptr = node->data.while_expr.var_is_ptr ? |
| 7219 | ir_build_ref(irb, child_scope, symbol_node, payload_ptr, true, false) : payload_ptr; | 8246 | ir_build_ref_src(irb, child_scope, symbol_node, payload_ptr, true, false) : payload_ptr; |
| 7220 | ir_build_var_decl_src(irb, child_scope, symbol_node, payload_var, nullptr, var_ptr); | 8247 | ir_build_var_decl_src(irb, child_scope, symbol_node, payload_var, nullptr, var_ptr); |
| 7221 | | 8248 | |
| 7222 | ZigList<IrInstruction *> incoming_values = {0}; | 8249 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 7223 | ZigList<IrBasicBlock *> incoming_blocks = {0}; | 8250 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; |
| 7224 | | 8251 | |
| 7225 | ScopeLoop *loop_scope = create_loop_scope(irb->codegen, node, child_scope); | 8252 | ScopeLoop *loop_scope = create_loop_scope(irb->codegen, node, child_scope); |
| 7226 | loop_scope->break_block = end_block; | 8253 | loop_scope->break_block = end_block; |
| ... | @@ -7234,8 +8261,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7234,8 +8261,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7234 | // Note the body block of the loop is not the place that lval and result_loc are used - | 8261 | // Note the body block of the loop is not the place that lval and result_loc are used - |
| 7235 | // it's actually in break statements, handled similarly to return statements. | 8262 | // it's actually in break statements, handled similarly to return statements. |
| 7236 | // That is why we set those values in loop_scope above and not in this ir_gen_node call. | 8263 | // That is why we set those values in loop_scope above and not in this ir_gen_node call. |
| 7237 | IrInstruction *body_result = ir_gen_node(irb, node->data.while_expr.body, &loop_scope->base); | 8264 | IrInstSrc *body_result = ir_gen_node(irb, node->data.while_expr.body, &loop_scope->base); |
| 7238 | if (body_result == irb->codegen->invalid_instruction) | 8265 | if (body_result == irb->codegen->invalid_inst_src) |
| 7239 | return body_result; | 8266 | return body_result; |
| 7240 | | 8267 | |
| 7241 | if (!instr_is_unreachable(body_result)) { | 8268 | if (!instr_is_unreachable(body_result)) { |
| ... | @@ -7245,8 +8272,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7245,8 +8272,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7245 | | 8272 | |
| 7246 | if (continue_expr_node) { | 8273 | if (continue_expr_node) { |
| 7247 | ir_set_cursor_at_end_and_append_block(irb, continue_block); | 8274 | ir_set_cursor_at_end_and_append_block(irb, continue_block); |
| 7248 | IrInstruction *expr_result = ir_gen_node(irb, continue_expr_node, child_scope); | 8275 | IrInstSrc *expr_result = ir_gen_node(irb, continue_expr_node, child_scope); |
| 7249 | if (expr_result == irb->codegen->invalid_instruction) | 8276 | if (expr_result == irb->codegen->invalid_inst_src) |
| 7250 | return expr_result; | 8277 | return expr_result; |
| 7251 | if (!instr_is_unreachable(expr_result)) { | 8278 | if (!instr_is_unreachable(expr_result)) { |
| 7252 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, continue_expr_node, expr_result)); | 8279 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, continue_expr_node, expr_result)); |
| ... | @@ -7254,7 +8281,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7254,7 +8281,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7254 | } | 8281 | } |
| 7255 | } | 8282 | } |
| 7256 | | 8283 | |
| 7257 | IrInstruction *else_result = nullptr; | 8284 | IrInstSrc *else_result = nullptr; |
| 7258 | if (else_node) { | 8285 | if (else_node) { |
| 7259 | ir_set_cursor_at_end_and_append_block(irb, else_block); | 8286 | ir_set_cursor_at_end_and_append_block(irb, else_block); |
| 7260 | | 8287 | |
| ... | @@ -7264,12 +8291,12 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7264,12 +8291,12 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7264 | ResultLocPeer *peer_result = create_peer_result(peer_parent); | 8291 | ResultLocPeer *peer_result = create_peer_result(peer_parent); |
| 7265 | peer_parent->peers.append(peer_result); | 8292 | peer_parent->peers.append(peer_result); |
| 7266 | else_result = ir_gen_node_extra(irb, else_node, scope, lval, &peer_result->base); | 8293 | else_result = ir_gen_node_extra(irb, else_node, scope, lval, &peer_result->base); |
| 7267 | if (else_result == irb->codegen->invalid_instruction) | 8294 | if (else_result == irb->codegen->invalid_inst_src) |
| 7268 | return else_result; | 8295 | return else_result; |
| 7269 | if (!instr_is_unreachable(else_result)) | 8296 | if (!instr_is_unreachable(else_result)) |
| 7270 | ir_mark_gen(ir_build_br(irb, scope, node, end_block, is_comptime)); | 8297 | ir_mark_gen(ir_build_br(irb, scope, node, end_block, is_comptime)); |
| 7271 | } | 8298 | } |
| 7272 | IrBasicBlock *after_else_block = irb->current_basic_block; | 8299 | IrBasicBlockSrc *after_else_block = irb->current_basic_block; |
| 7273 | ir_set_cursor_at_end_and_append_block(irb, end_block); | 8300 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 7274 | if (else_result) { | 8301 | if (else_result) { |
| 7275 | incoming_blocks.append(after_else_block); | 8302 | incoming_blocks.append(after_else_block); |
| ... | @@ -7282,17 +8309,17 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7282,17 +8309,17 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7282 | peer_parent->peers.last()->next_bb = end_block; | 8309 | peer_parent->peers.last()->next_bb = end_block; |
| 7283 | } | 8310 | } |
| 7284 | | 8311 | |
| 7285 | IrInstruction *phi = ir_build_phi(irb, scope, node, incoming_blocks.length, | 8312 | IrInstSrc *phi = ir_build_phi(irb, scope, node, incoming_blocks.length, |
| 7286 | incoming_blocks.items, incoming_values.items, peer_parent); | 8313 | incoming_blocks.items, incoming_values.items, peer_parent); |
| 7287 | return ir_expr_wrap(irb, scope, phi, result_loc); | 8314 | return ir_expr_wrap(irb, scope, phi, result_loc); |
| 7288 | } else { | 8315 | } else { |
| 7289 | ir_set_cursor_at_end_and_append_block(irb, cond_block); | 8316 | ir_set_cursor_at_end_and_append_block(irb, cond_block); |
| 7290 | IrInstruction *cond_val = ir_gen_node(irb, node->data.while_expr.condition, scope); | 8317 | IrInstSrc *cond_val = ir_gen_node(irb, node->data.while_expr.condition, scope); |
| 7291 | if (cond_val == irb->codegen->invalid_instruction) | 8318 | if (cond_val == irb->codegen->invalid_inst_src) |
| 7292 | return cond_val; | 8319 | return cond_val; |
| 7293 | IrBasicBlock *after_cond_block = irb->current_basic_block; | 8320 | IrBasicBlockSrc *after_cond_block = irb->current_basic_block; |
| 7294 | IrInstruction *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, scope, node)); | 8321 | IrInstSrc *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, scope, node)); |
| 7295 | IrInstruction *cond_br_inst; | 8322 | IrInstSrc *cond_br_inst; |
| 7296 | if (!instr_is_unreachable(cond_val)) { | 8323 | if (!instr_is_unreachable(cond_val)) { |
| 7297 | cond_br_inst = ir_build_cond_br(irb, scope, node->data.while_expr.condition, cond_val, | 8324 | cond_br_inst = ir_build_cond_br(irb, scope, node->data.while_expr.condition, cond_val, |
| 7298 | body_block, else_block, is_comptime); | 8325 | body_block, else_block, is_comptime); |
| ... | @@ -7306,8 +8333,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7306,8 +8333,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7306 | is_comptime); | 8333 | is_comptime); |
| 7307 | ir_set_cursor_at_end_and_append_block(irb, body_block); | 8334 | ir_set_cursor_at_end_and_append_block(irb, body_block); |
| 7308 | | 8335 | |
| 7309 | ZigList<IrInstruction *> incoming_values = {0}; | 8336 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 7310 | ZigList<IrBasicBlock *> incoming_blocks = {0}; | 8337 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; |
| 7311 | | 8338 | |
| 7312 | Scope *subexpr_scope = create_runtime_scope(irb->codegen, node, scope, is_comptime); | 8339 | Scope *subexpr_scope = create_runtime_scope(irb->codegen, node, scope, is_comptime); |
| 7313 | | 8340 | |
| ... | @@ -7323,8 +8350,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7323,8 +8350,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7323 | // Note the body block of the loop is not the place that lval and result_loc are used - | 8350 | // Note the body block of the loop is not the place that lval and result_loc are used - |
| 7324 | // it's actually in break statements, handled similarly to return statements. | 8351 | // it's actually in break statements, handled similarly to return statements. |
| 7325 | // That is why we set those values in loop_scope above and not in this ir_gen_node call. | 8352 | // That is why we set those values in loop_scope above and not in this ir_gen_node call. |
| 7326 | IrInstruction *body_result = ir_gen_node(irb, node->data.while_expr.body, &loop_scope->base); | 8353 | IrInstSrc *body_result = ir_gen_node(irb, node->data.while_expr.body, &loop_scope->base); |
| 7327 | if (body_result == irb->codegen->invalid_instruction) | 8354 | if (body_result == irb->codegen->invalid_inst_src) |
| 7328 | return body_result; | 8355 | return body_result; |
| 7329 | | 8356 | |
| 7330 | if (!instr_is_unreachable(body_result)) { | 8357 | if (!instr_is_unreachable(body_result)) { |
| ... | @@ -7334,8 +8361,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7334,8 +8361,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7334 | | 8361 | |
| 7335 | if (continue_expr_node) { | 8362 | if (continue_expr_node) { |
| 7336 | ir_set_cursor_at_end_and_append_block(irb, continue_block); | 8363 | ir_set_cursor_at_end_and_append_block(irb, continue_block); |
| 7337 | IrInstruction *expr_result = ir_gen_node(irb, continue_expr_node, subexpr_scope); | 8364 | IrInstSrc *expr_result = ir_gen_node(irb, continue_expr_node, subexpr_scope); |
| 7338 | if (expr_result == irb->codegen->invalid_instruction) | 8365 | if (expr_result == irb->codegen->invalid_inst_src) |
| 7339 | return expr_result; | 8366 | return expr_result; |
| 7340 | if (!instr_is_unreachable(expr_result)) { | 8367 | if (!instr_is_unreachable(expr_result)) { |
| 7341 | ir_mark_gen(ir_build_check_statement_is_void(irb, scope, continue_expr_node, expr_result)); | 8368 | ir_mark_gen(ir_build_check_statement_is_void(irb, scope, continue_expr_node, expr_result)); |
| ... | @@ -7343,7 +8370,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7343,7 +8370,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7343 | } | 8370 | } |
| 7344 | } | 8371 | } |
| 7345 | | 8372 | |
| 7346 | IrInstruction *else_result = nullptr; | 8373 | IrInstSrc *else_result = nullptr; |
| 7347 | if (else_node) { | 8374 | if (else_node) { |
| 7348 | ir_set_cursor_at_end_and_append_block(irb, else_block); | 8375 | ir_set_cursor_at_end_and_append_block(irb, else_block); |
| 7349 | | 8376 | |
| ... | @@ -7354,12 +8381,12 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7354,12 +8381,12 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7354 | peer_parent->peers.append(peer_result); | 8381 | peer_parent->peers.append(peer_result); |
| 7355 | | 8382 | |
| 7356 | else_result = ir_gen_node_extra(irb, else_node, subexpr_scope, lval, &peer_result->base); | 8383 | else_result = ir_gen_node_extra(irb, else_node, subexpr_scope, lval, &peer_result->base); |
| 7357 | if (else_result == irb->codegen->invalid_instruction) | 8384 | if (else_result == irb->codegen->invalid_inst_src) |
| 7358 | return else_result; | 8385 | return else_result; |
| 7359 | if (!instr_is_unreachable(else_result)) | 8386 | if (!instr_is_unreachable(else_result)) |
| 7360 | ir_mark_gen(ir_build_br(irb, scope, node, end_block, is_comptime)); | 8387 | ir_mark_gen(ir_build_br(irb, scope, node, end_block, is_comptime)); |
| 7361 | } | 8388 | } |
| 7362 | IrBasicBlock *after_else_block = irb->current_basic_block; | 8389 | IrBasicBlockSrc *after_else_block = irb->current_basic_block; |
| 7363 | ir_set_cursor_at_end_and_append_block(irb, end_block); | 8390 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 7364 | if (else_result) { | 8391 | if (else_result) { |
| 7365 | incoming_blocks.append(after_else_block); | 8392 | incoming_blocks.append(after_else_block); |
| ... | @@ -7372,13 +8399,13 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7372,13 +8399,13 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7372 | peer_parent->peers.last()->next_bb = end_block; | 8399 | peer_parent->peers.last()->next_bb = end_block; |
| 7373 | } | 8400 | } |
| 7374 | | 8401 | |
| 7375 | IrInstruction *phi = ir_build_phi(irb, scope, node, incoming_blocks.length, | 8402 | IrInstSrc *phi = ir_build_phi(irb, scope, node, incoming_blocks.length, |
| 7376 | incoming_blocks.items, incoming_values.items, peer_parent); | 8403 | incoming_blocks.items, incoming_values.items, peer_parent); |
| 7377 | return ir_expr_wrap(irb, scope, phi, result_loc); | 8404 | return ir_expr_wrap(irb, scope, phi, result_loc); |
| 7378 | } | 8405 | } |
| 7379 | } | 8406 | } |
| 7380 | | 8407 | |
| 7381 | static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNode *node, LVal lval, | 8408 | static IrInstSrc *ir_gen_for_expr(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node, LVal lval, |
| 7382 | ResultLoc *result_loc) | 8409 | ResultLoc *result_loc) |
| 7383 | { | 8410 | { |
| 7384 | assert(node->type == NodeTypeForExpr); | 8411 | assert(node->type == NodeTypeForExpr); |
| ... | @@ -7391,17 +8418,17 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -7391,17 +8418,17 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo |
| 7391 | | 8418 | |
| 7392 | if (!elem_node) { | 8419 | if (!elem_node) { |
| 7393 | add_node_error(irb->codegen, node, buf_sprintf("for loop expression missing element parameter")); | 8420 | add_node_error(irb->codegen, node, buf_sprintf("for loop expression missing element parameter")); |
| 7394 | return irb->codegen->invalid_instruction; | 8421 | return irb->codegen->invalid_inst_src; |
| 7395 | } | 8422 | } |
| 7396 | assert(elem_node->type == NodeTypeSymbol); | 8423 | assert(elem_node->type == NodeTypeSymbol); |
| 7397 | | 8424 | |
| 7398 | ScopeExpr *spill_scope = create_expr_scope(irb->codegen, node, parent_scope); | 8425 | ScopeExpr *spill_scope = create_expr_scope(irb->codegen, node, parent_scope); |
| 7399 | | 8426 | |
| 7400 | IrInstruction *array_val_ptr = ir_gen_node_extra(irb, array_node, &spill_scope->base, LValPtr, nullptr); | 8427 | IrInstSrc *array_val_ptr = ir_gen_node_extra(irb, array_node, &spill_scope->base, LValPtr, nullptr); |
| 7401 | if (array_val_ptr == irb->codegen->invalid_instruction) | 8428 | if (array_val_ptr == irb->codegen->invalid_inst_src) |
| 7402 | return array_val_ptr; | 8429 | return array_val_ptr; |
| 7403 | | 8430 | |
| 7404 | IrInstruction *is_comptime = ir_build_const_bool(irb, parent_scope, node, | 8431 | IrInstSrc *is_comptime = ir_build_const_bool(irb, parent_scope, node, |
| 7405 | ir_should_inline(irb->exec, parent_scope) || node->data.for_expr.is_inline); | 8432 | ir_should_inline(irb->exec, parent_scope) || node->data.for_expr.is_inline); |
| 7406 | | 8433 | |
| 7407 | AstNode *index_var_source_node; | 8434 | AstNode *index_var_source_node; |
| ... | @@ -7418,50 +8445,50 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -7418,50 +8445,50 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo |
| 7418 | index_var_name = "i"; | 8445 | index_var_name = "i"; |
| 7419 | } | 8446 | } |
| 7420 | | 8447 | |
| 7421 | IrInstruction *zero = ir_build_const_usize(irb, parent_scope, node, 0); | 8448 | IrInstSrc *zero = ir_build_const_usize(irb, parent_scope, node, 0); |
| 7422 | build_decl_var_and_init(irb, parent_scope, index_var_source_node, index_var, zero, index_var_name, is_comptime); | 8449 | build_decl_var_and_init(irb, parent_scope, index_var_source_node, index_var, zero, index_var_name, is_comptime); |
| 7423 | parent_scope = index_var->child_scope; | 8450 | parent_scope = index_var->child_scope; |
| 7424 | | 8451 | |
| 7425 | IrInstruction *one = ir_build_const_usize(irb, parent_scope, node, 1); | 8452 | IrInstSrc *one = ir_build_const_usize(irb, parent_scope, node, 1); |
| 7426 | IrInstruction *index_ptr = ir_build_var_ptr(irb, parent_scope, node, index_var); | 8453 | IrInstSrc *index_ptr = ir_build_var_ptr(irb, parent_scope, node, index_var); |
| 7427 | | 8454 | |
| 7428 | | 8455 | |
| 7429 | IrBasicBlock *cond_block = ir_create_basic_block(irb, parent_scope, "ForCond"); | 8456 | IrBasicBlockSrc *cond_block = ir_create_basic_block(irb, parent_scope, "ForCond"); |
| 7430 | IrBasicBlock *body_block = ir_create_basic_block(irb, parent_scope, "ForBody"); | 8457 | IrBasicBlockSrc *body_block = ir_create_basic_block(irb, parent_scope, "ForBody"); |
| 7431 | IrBasicBlock *end_block = ir_create_basic_block(irb, parent_scope, "ForEnd"); | 8458 | IrBasicBlockSrc *end_block = ir_create_basic_block(irb, parent_scope, "ForEnd"); |
| 7432 | IrBasicBlock *else_block = else_node ? ir_create_basic_block(irb, parent_scope, "ForElse") : end_block; | 8459 | IrBasicBlockSrc *else_block = else_node ? ir_create_basic_block(irb, parent_scope, "ForElse") : end_block; |
| 7433 | IrBasicBlock *continue_block = ir_create_basic_block(irb, parent_scope, "ForContinue"); | 8460 | IrBasicBlockSrc *continue_block = ir_create_basic_block(irb, parent_scope, "ForContinue"); |
| 7434 | | 8461 | |
| 7435 | Buf *len_field_name = buf_create_from_str("len"); | 8462 | Buf *len_field_name = buf_create_from_str("len"); |
| 7436 | IrInstruction *len_ref = ir_build_field_ptr(irb, parent_scope, node, array_val_ptr, len_field_name, false); | 8463 | IrInstSrc *len_ref = ir_build_field_ptr(irb, parent_scope, node, array_val_ptr, len_field_name, false); |
| 7437 | IrInstruction *len_val = ir_build_load_ptr(irb, &spill_scope->base, node, len_ref); | 8464 | IrInstSrc *len_val = ir_build_load_ptr(irb, &spill_scope->base, node, len_ref); |
| 7438 | ir_build_br(irb, parent_scope, node, cond_block, is_comptime); | 8465 | ir_build_br(irb, parent_scope, node, cond_block, is_comptime); |
| 7439 | | 8466 | |
| 7440 | ir_set_cursor_at_end_and_append_block(irb, cond_block); | 8467 | ir_set_cursor_at_end_and_append_block(irb, cond_block); |
| 7441 | IrInstruction *index_val = ir_build_load_ptr(irb, &spill_scope->base, node, index_ptr); | 8468 | IrInstSrc *index_val = ir_build_load_ptr(irb, &spill_scope->base, node, index_ptr); |
| 7442 | IrInstruction *cond = ir_build_bin_op(irb, parent_scope, node, IrBinOpCmpLessThan, index_val, len_val, false); | 8469 | IrInstSrc *cond = ir_build_bin_op(irb, parent_scope, node, IrBinOpCmpLessThan, index_val, len_val, false); |
| 7443 | IrBasicBlock *after_cond_block = irb->current_basic_block; | 8470 | IrBasicBlockSrc *after_cond_block = irb->current_basic_block; |
| 7444 | IrInstruction *void_else_value = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, parent_scope, node)); | 8471 | IrInstSrc *void_else_value = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, parent_scope, node)); |
| 7445 | IrInstruction *cond_br_inst = ir_mark_gen(ir_build_cond_br(irb, parent_scope, node, cond, | 8472 | IrInstSrc *cond_br_inst = ir_mark_gen(ir_build_cond_br(irb, parent_scope, node, cond, |
| 7446 | body_block, else_block, is_comptime)); | 8473 | body_block, else_block, is_comptime)); |
| 7447 | | 8474 | |
| 7448 | ResultLocPeerParent *peer_parent = ir_build_result_peers(irb, cond_br_inst, end_block, result_loc, is_comptime); | 8475 | ResultLocPeerParent *peer_parent = ir_build_result_peers(irb, cond_br_inst, end_block, result_loc, is_comptime); |
| 7449 | | 8476 | |
| 7450 | ir_set_cursor_at_end_and_append_block(irb, body_block); | 8477 | ir_set_cursor_at_end_and_append_block(irb, body_block); |
| 7451 | Scope *elem_ptr_scope = node->data.for_expr.elem_is_ptr ? parent_scope : &spill_scope->base; | 8478 | Scope *elem_ptr_scope = node->data.for_expr.elem_is_ptr ? parent_scope : &spill_scope->base; |
| 7452 | IrInstruction *elem_ptr = ir_build_elem_ptr(irb, elem_ptr_scope, node, array_val_ptr, index_val, false, | 8479 | IrInstSrc *elem_ptr = ir_build_elem_ptr(irb, elem_ptr_scope, node, array_val_ptr, index_val, false, |
| 7453 | PtrLenSingle, nullptr); | 8480 | PtrLenSingle, nullptr); |
| 7454 | // TODO make it an error to write to element variable or i variable. | 8481 | // TODO make it an error to write to element variable or i variable. |
| 7455 | Buf *elem_var_name = elem_node->data.symbol_expr.symbol; | 8482 | Buf *elem_var_name = elem_node->data.symbol_expr.symbol; |
| 7456 | ZigVar *elem_var = ir_create_var(irb, elem_node, parent_scope, elem_var_name, true, false, false, is_comptime); | 8483 | ZigVar *elem_var = ir_create_var(irb, elem_node, parent_scope, elem_var_name, true, false, false, is_comptime); |
| 7457 | Scope *child_scope = elem_var->child_scope; | 8484 | Scope *child_scope = elem_var->child_scope; |
| 7458 | | 8485 | |
| 7459 | IrInstruction *var_ptr = node->data.for_expr.elem_is_ptr ? | 8486 | IrInstSrc *var_ptr = node->data.for_expr.elem_is_ptr ? |
| 7460 | ir_build_ref(irb, &spill_scope->base, elem_node, elem_ptr, true, false) : elem_ptr; | 8487 | ir_build_ref_src(irb, &spill_scope->base, elem_node, elem_ptr, true, false) : elem_ptr; |
| 7461 | ir_build_var_decl_src(irb, parent_scope, elem_node, elem_var, nullptr, var_ptr); | 8488 | ir_build_var_decl_src(irb, parent_scope, elem_node, elem_var, nullptr, var_ptr); |
| 7462 | | 8489 | |
| 7463 | ZigList<IrInstruction *> incoming_values = {0}; | 8490 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 7464 | ZigList<IrBasicBlock *> incoming_blocks = {0}; | 8491 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; |
| 7465 | ScopeLoop *loop_scope = create_loop_scope(irb->codegen, node, child_scope); | 8492 | ScopeLoop *loop_scope = create_loop_scope(irb->codegen, node, child_scope); |
| 7466 | loop_scope->break_block = end_block; | 8493 | loop_scope->break_block = end_block; |
| 7467 | loop_scope->continue_block = continue_block; | 8494 | loop_scope->continue_block = continue_block; |
| ... | @@ -7475,9 +8502,9 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -7475,9 +8502,9 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo |
| 7475 | // Note the body block of the loop is not the place that lval and result_loc are used - | 8502 | // Note the body block of the loop is not the place that lval and result_loc are used - |
| 7476 | // it's actually in break statements, handled similarly to return statements. | 8503 | // it's actually in break statements, handled similarly to return statements. |
| 7477 | // That is why we set those values in loop_scope above and not in this ir_gen_node call. | 8504 | // That is why we set those values in loop_scope above and not in this ir_gen_node call. |
| 7478 | IrInstruction *body_result = ir_gen_node(irb, body_node, &loop_scope->base); | 8505 | IrInstSrc *body_result = ir_gen_node(irb, body_node, &loop_scope->base); |
| 7479 | if (body_result == irb->codegen->invalid_instruction) | 8506 | if (body_result == irb->codegen->invalid_inst_src) |
| 7480 | return irb->codegen->invalid_instruction; | 8507 | return irb->codegen->invalid_inst_src; |
| 7481 | | 8508 | |
| 7482 | if (!instr_is_unreachable(body_result)) { | 8509 | if (!instr_is_unreachable(body_result)) { |
| 7483 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, node->data.for_expr.body, body_result)); | 8510 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, node->data.for_expr.body, body_result)); |
| ... | @@ -7485,11 +8512,11 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -7485,11 +8512,11 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo |
| 7485 | } | 8512 | } |
| 7486 | | 8513 | |
| 7487 | ir_set_cursor_at_end_and_append_block(irb, continue_block); | 8514 | ir_set_cursor_at_end_and_append_block(irb, continue_block); |
| 7488 | IrInstruction *new_index_val = ir_build_bin_op(irb, child_scope, node, IrBinOpAdd, index_val, one, false); | 8515 | IrInstSrc *new_index_val = ir_build_bin_op(irb, child_scope, node, IrBinOpAdd, index_val, one, false); |
| 7489 | ir_build_store_ptr(irb, child_scope, node, index_ptr, new_index_val)->allow_write_through_const = true; | 8516 | ir_build_store_ptr(irb, child_scope, node, index_ptr, new_index_val)->allow_write_through_const = true; |
| 7490 | ir_build_br(irb, child_scope, node, cond_block, is_comptime); | 8517 | ir_build_br(irb, child_scope, node, cond_block, is_comptime); |
| 7491 | | 8518 | |
| 7492 | IrInstruction *else_result = nullptr; | 8519 | IrInstSrc *else_result = nullptr; |
| 7493 | if (else_node) { | 8520 | if (else_node) { |
| 7494 | ir_set_cursor_at_end_and_append_block(irb, else_block); | 8521 | ir_set_cursor_at_end_and_append_block(irb, else_block); |
| 7495 | | 8522 | |
| ... | @@ -7499,12 +8526,12 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -7499,12 +8526,12 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo |
| 7499 | ResultLocPeer *peer_result = create_peer_result(peer_parent); | 8526 | ResultLocPeer *peer_result = create_peer_result(peer_parent); |
| 7500 | peer_parent->peers.append(peer_result); | 8527 | peer_parent->peers.append(peer_result); |
| 7501 | else_result = ir_gen_node_extra(irb, else_node, parent_scope, LValNone, &peer_result->base); | 8528 | else_result = ir_gen_node_extra(irb, else_node, parent_scope, LValNone, &peer_result->base); |
| 7502 | if (else_result == irb->codegen->invalid_instruction) | 8529 | if (else_result == irb->codegen->invalid_inst_src) |
| 7503 | return else_result; | 8530 | return else_result; |
| 7504 | if (!instr_is_unreachable(else_result)) | 8531 | if (!instr_is_unreachable(else_result)) |
| 7505 | ir_mark_gen(ir_build_br(irb, parent_scope, node, end_block, is_comptime)); | 8532 | ir_mark_gen(ir_build_br(irb, parent_scope, node, end_block, is_comptime)); |
| 7506 | } | 8533 | } |
| 7507 | IrBasicBlock *after_else_block = irb->current_basic_block; | 8534 | IrBasicBlockSrc *after_else_block = irb->current_basic_block; |
| 7508 | ir_set_cursor_at_end_and_append_block(irb, end_block); | 8535 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 7509 | | 8536 | |
| 7510 | if (else_result) { | 8537 | if (else_result) { |
| ... | @@ -7518,29 +8545,29 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -7518,29 +8545,29 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo |
| 7518 | peer_parent->peers.last()->next_bb = end_block; | 8545 | peer_parent->peers.last()->next_bb = end_block; |
| 7519 | } | 8546 | } |
| 7520 | | 8547 | |
| 7521 | IrInstruction *phi = ir_build_phi(irb, parent_scope, node, incoming_blocks.length, | 8548 | IrInstSrc *phi = ir_build_phi(irb, parent_scope, node, incoming_blocks.length, |
| 7522 | incoming_blocks.items, incoming_values.items, peer_parent); | 8549 | incoming_blocks.items, incoming_values.items, peer_parent); |
| 7523 | return ir_lval_wrap(irb, parent_scope, phi, lval, result_loc); | 8550 | return ir_lval_wrap(irb, parent_scope, phi, lval, result_loc); |
| 7524 | } | 8551 | } |
| 7525 | | 8552 | |
| 7526 | static IrInstruction *ir_gen_bool_literal(IrBuilder *irb, Scope *scope, AstNode *node) { | 8553 | static IrInstSrc *ir_gen_bool_literal(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 7527 | assert(node->type == NodeTypeBoolLiteral); | 8554 | assert(node->type == NodeTypeBoolLiteral); |
| 7528 | return ir_build_const_bool(irb, scope, node, node->data.bool_literal.value); | 8555 | return ir_build_const_bool(irb, scope, node, node->data.bool_literal.value); |
| 7529 | } | 8556 | } |
| 7530 | | 8557 | |
| 7531 | static IrInstruction *ir_gen_enum_literal(IrBuilder *irb, Scope *scope, AstNode *node) { | 8558 | static IrInstSrc *ir_gen_enum_literal(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 7532 | assert(node->type == NodeTypeEnumLiteral); | 8559 | assert(node->type == NodeTypeEnumLiteral); |
| 7533 | Buf *name = &node->data.enum_literal.identifier->data.str_lit.str; | 8560 | Buf *name = &node->data.enum_literal.identifier->data.str_lit.str; |
| 7534 | return ir_build_const_enum_literal(irb, scope, node, name); | 8561 | return ir_build_const_enum_literal(irb, scope, node, name); |
| 7535 | } | 8562 | } |
| 7536 | | 8563 | |
| 7537 | static IrInstruction *ir_gen_string_literal(IrBuilder *irb, Scope *scope, AstNode *node) { | 8564 | static IrInstSrc *ir_gen_string_literal(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 7538 | assert(node->type == NodeTypeStringLiteral); | 8565 | assert(node->type == NodeTypeStringLiteral); |
| 7539 | | 8566 | |
| 7540 | return ir_build_const_str_lit(irb, scope, node, node->data.string_literal.buf); | 8567 | return ir_build_const_str_lit(irb, scope, node, node->data.string_literal.buf); |
| 7541 | } | 8568 | } |
| 7542 | | 8569 | |
| 7543 | static IrInstruction *ir_gen_array_type(IrBuilder *irb, Scope *scope, AstNode *node) { | 8570 | static IrInstSrc *ir_gen_array_type(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 7544 | assert(node->type == NodeTypeArrayType); | 8571 | assert(node->type == NodeTypeArrayType); |
| 7545 | | 8572 | |
| 7546 | AstNode *size_node = node->data.array_type.size; | 8573 | AstNode *size_node = node->data.array_type.size; |
| ... | @@ -7553,10 +8580,10 @@ static IrInstruction *ir_gen_array_type(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7553,10 +8580,10 @@ static IrInstruction *ir_gen_array_type(IrBuilder *irb, Scope *scope, AstNode *n |
| 7553 | | 8580 | |
| 7554 | Scope *comptime_scope = create_comptime_scope(irb->codegen, node, scope); | 8581 | Scope *comptime_scope = create_comptime_scope(irb->codegen, node, scope); |
| 7555 | | 8582 | |
| 7556 | IrInstruction *sentinel; | 8583 | IrInstSrc *sentinel; |
| 7557 | if (sentinel_expr != nullptr) { | 8584 | if (sentinel_expr != nullptr) { |
| 7558 | sentinel = ir_gen_node(irb, sentinel_expr, comptime_scope); | 8585 | sentinel = ir_gen_node(irb, sentinel_expr, comptime_scope); |
| 7559 | if (sentinel == irb->codegen->invalid_instruction) | 8586 | if (sentinel == irb->codegen->invalid_inst_src) |
| 7560 | return sentinel; | 8587 | return sentinel; |
| 7561 | } else { | 8588 | } else { |
| 7562 | sentinel = nullptr; | 8589 | sentinel = nullptr; |
| ... | @@ -7565,42 +8592,42 @@ static IrInstruction *ir_gen_array_type(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7565,42 +8592,42 @@ static IrInstruction *ir_gen_array_type(IrBuilder *irb, Scope *scope, AstNode *n |
| 7565 | if (size_node) { | 8592 | if (size_node) { |
| 7566 | if (is_const) { | 8593 | if (is_const) { |
| 7567 | add_node_error(irb->codegen, node, buf_create_from_str("const qualifier invalid on array type")); | 8594 | add_node_error(irb->codegen, node, buf_create_from_str("const qualifier invalid on array type")); |
| 7568 | return irb->codegen->invalid_instruction; | 8595 | return irb->codegen->invalid_inst_src; |
| 7569 | } | 8596 | } |
| 7570 | if (is_volatile) { | 8597 | if (is_volatile) { |
| 7571 | add_node_error(irb->codegen, node, buf_create_from_str("volatile qualifier invalid on array type")); | 8598 | add_node_error(irb->codegen, node, buf_create_from_str("volatile qualifier invalid on array type")); |
| 7572 | return irb->codegen->invalid_instruction; | 8599 | return irb->codegen->invalid_inst_src; |
| 7573 | } | 8600 | } |
| 7574 | if (is_allow_zero) { | 8601 | if (is_allow_zero) { |
| 7575 | add_node_error(irb->codegen, node, buf_create_from_str("allowzero qualifier invalid on array type")); | 8602 | add_node_error(irb->codegen, node, buf_create_from_str("allowzero qualifier invalid on array type")); |
| 7576 | return irb->codegen->invalid_instruction; | 8603 | return irb->codegen->invalid_inst_src; |
| 7577 | } | 8604 | } |
| 7578 | if (align_expr != nullptr) { | 8605 | if (align_expr != nullptr) { |
| 7579 | add_node_error(irb->codegen, node, buf_create_from_str("align qualifier invalid on array type")); | 8606 | add_node_error(irb->codegen, node, buf_create_from_str("align qualifier invalid on array type")); |
| 7580 | return irb->codegen->invalid_instruction; | 8607 | return irb->codegen->invalid_inst_src; |
| 7581 | } | 8608 | } |
| 7582 | | 8609 | |
| 7583 | IrInstruction *size_value = ir_gen_node(irb, size_node, comptime_scope); | 8610 | IrInstSrc *size_value = ir_gen_node(irb, size_node, comptime_scope); |
| 7584 | if (size_value == irb->codegen->invalid_instruction) | 8611 | if (size_value == irb->codegen->invalid_inst_src) |
| 7585 | return size_value; | 8612 | return size_value; |
| 7586 | | 8613 | |
| 7587 | IrInstruction *child_type = ir_gen_node(irb, child_type_node, comptime_scope); | 8614 | IrInstSrc *child_type = ir_gen_node(irb, child_type_node, comptime_scope); |
| 7588 | if (child_type == irb->codegen->invalid_instruction) | 8615 | if (child_type == irb->codegen->invalid_inst_src) |
| 7589 | return child_type; | 8616 | return child_type; |
| 7590 | | 8617 | |
| 7591 | return ir_build_array_type(irb, scope, node, size_value, sentinel, child_type); | 8618 | return ir_build_array_type(irb, scope, node, size_value, sentinel, child_type); |
| 7592 | } else { | 8619 | } else { |
| 7593 | IrInstruction *align_value; | 8620 | IrInstSrc *align_value; |
| 7594 | if (align_expr != nullptr) { | 8621 | if (align_expr != nullptr) { |
| 7595 | align_value = ir_gen_node(irb, align_expr, comptime_scope); | 8622 | align_value = ir_gen_node(irb, align_expr, comptime_scope); |
| 7596 | if (align_value == irb->codegen->invalid_instruction) | 8623 | if (align_value == irb->codegen->invalid_inst_src) |
| 7597 | return align_value; | 8624 | return align_value; |
| 7598 | } else { | 8625 | } else { |
| 7599 | align_value = nullptr; | 8626 | align_value = nullptr; |
| 7600 | } | 8627 | } |
| 7601 | | 8628 | |
| 7602 | IrInstruction *child_type = ir_gen_node(irb, child_type_node, comptime_scope); | 8629 | IrInstSrc *child_type = ir_gen_node(irb, child_type_node, comptime_scope); |
| 7603 | if (child_type == irb->codegen->invalid_instruction) | 8630 | if (child_type == irb->codegen->invalid_inst_src) |
| 7604 | return child_type; | 8631 | return child_type; |
| 7605 | | 8632 | |
| 7606 | return ir_build_slice_type(irb, scope, node, child_type, is_const, is_volatile, sentinel, | 8633 | return ir_build_slice_type(irb, scope, node, child_type, is_const, is_volatile, sentinel, |
| ... | @@ -7608,15 +8635,15 @@ static IrInstruction *ir_gen_array_type(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7608,15 +8635,15 @@ static IrInstruction *ir_gen_array_type(IrBuilder *irb, Scope *scope, AstNode *n |
| 7608 | } | 8635 | } |
| 7609 | } | 8636 | } |
| 7610 | | 8637 | |
| 7611 | static IrInstruction *ir_gen_anyframe_type(IrBuilder *irb, Scope *scope, AstNode *node) { | 8638 | static IrInstSrc *ir_gen_anyframe_type(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 7612 | assert(node->type == NodeTypeAnyFrameType); | 8639 | assert(node->type == NodeTypeAnyFrameType); |
| 7613 | | 8640 | |
| 7614 | AstNode *payload_type_node = node->data.anyframe_type.payload_type; | 8641 | AstNode *payload_type_node = node->data.anyframe_type.payload_type; |
| 7615 | IrInstruction *payload_type_value = nullptr; | 8642 | IrInstSrc *payload_type_value = nullptr; |
| 7616 | | 8643 | |
| 7617 | if (payload_type_node != nullptr) { | 8644 | if (payload_type_node != nullptr) { |
| 7618 | payload_type_value = ir_gen_node(irb, payload_type_node, scope); | 8645 | payload_type_value = ir_gen_node(irb, payload_type_node, scope); |
| 7619 | if (payload_type_value == irb->codegen->invalid_instruction) | 8646 | if (payload_type_value == irb->codegen->invalid_inst_src) |
| 7620 | return payload_type_value; | 8647 | return payload_type_value; |
| 7621 | | 8648 | |
| 7622 | } | 8649 | } |
| ... | @@ -7624,7 +8651,7 @@ static IrInstruction *ir_gen_anyframe_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -7624,7 +8651,7 @@ static IrInstruction *ir_gen_anyframe_type(IrBuilder *irb, Scope *scope, AstNode |
| 7624 | return ir_build_anyframe_type(irb, scope, node, payload_type_value); | 8651 | return ir_build_anyframe_type(irb, scope, node, payload_type_value); |
| 7625 | } | 8652 | } |
| 7626 | | 8653 | |
| 7627 | static IrInstruction *ir_gen_undefined_literal(IrBuilder *irb, Scope *scope, AstNode *node) { | 8654 | static IrInstSrc *ir_gen_undefined_literal(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 7628 | assert(node->type == NodeTypeUndefinedLiteral); | 8655 | assert(node->type == NodeTypeUndefinedLiteral); |
| 7629 | return ir_build_const_undefined(irb, scope, node); | 8656 | return ir_build_const_undefined(irb, scope, node); |
| 7630 | } | 8657 | } |
| ... | @@ -7741,13 +8768,13 @@ static size_t find_asm_index(CodeGen *g, AstNode *node, AsmToken *tok, Buf *src_ | ... | @@ -7741,13 +8768,13 @@ static size_t find_asm_index(CodeGen *g, AstNode *node, AsmToken *tok, Buf *src_ |
| 7741 | return SIZE_MAX; | 8768 | return SIZE_MAX; |
| 7742 | } | 8769 | } |
| 7743 | | 8770 | |
| 7744 | static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *node) { | 8771 | static IrInstSrc *ir_gen_asm_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 7745 | assert(node->type == NodeTypeAsmExpr); | 8772 | assert(node->type == NodeTypeAsmExpr); |
| 7746 | AstNodeAsmExpr *asm_expr = &node->data.asm_expr; | 8773 | AstNodeAsmExpr *asm_expr = &node->data.asm_expr; |
| 7747 | | 8774 | |
| 7748 | IrInstruction *asm_template = ir_gen_node(irb, asm_expr->asm_template, scope); | 8775 | IrInstSrc *asm_template = ir_gen_node(irb, asm_expr->asm_template, scope); |
| 7749 | if (asm_template == irb->codegen->invalid_instruction) | 8776 | if (asm_template == irb->codegen->invalid_inst_src) |
| 7750 | return irb->codegen->invalid_instruction; | 8777 | return irb->codegen->invalid_inst_src; |
| 7751 | | 8778 | |
| 7752 | bool is_volatile = asm_expr->volatile_token != nullptr; | 8779 | bool is_volatile = asm_expr->volatile_token != nullptr; |
| 7753 | bool in_fn_scope = (scope_fn_entry(scope) != nullptr); | 8780 | bool in_fn_scope = (scope_fn_entry(scope) != nullptr); |
| ... | @@ -7756,7 +8783,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -7756,7 +8783,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod |
| 7756 | if (is_volatile) { | 8783 | if (is_volatile) { |
| 7757 | add_token_error(irb->codegen, node->owner, asm_expr->volatile_token, | 8784 | add_token_error(irb->codegen, node->owner, asm_expr->volatile_token, |
| 7758 | buf_sprintf("volatile is meaningless on global assembly")); | 8785 | buf_sprintf("volatile is meaningless on global assembly")); |
| 7759 | return irb->codegen->invalid_instruction; | 8786 | return irb->codegen->invalid_inst_src; |
| 7760 | } | 8787 | } |
| 7761 | | 8788 | |
| 7762 | if (asm_expr->output_list.length != 0 || asm_expr->input_list.length != 0 || | 8789 | if (asm_expr->output_list.length != 0 || asm_expr->input_list.length != 0 || |
| ... | @@ -7764,34 +8791,34 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -7764,34 +8791,34 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod |
| 7764 | { | 8791 | { |
| 7765 | add_node_error(irb->codegen, node, | 8792 | add_node_error(irb->codegen, node, |
| 7766 | buf_sprintf("global assembly cannot have inputs, outputs, or clobbers")); | 8793 | buf_sprintf("global assembly cannot have inputs, outputs, or clobbers")); |
| 7767 | return irb->codegen->invalid_instruction; | 8794 | return irb->codegen->invalid_inst_src; |
| 7768 | } | 8795 | } |
| 7769 | | 8796 | |
| 7770 | return ir_build_asm_src(irb, scope, node, asm_template, nullptr, nullptr, | 8797 | return ir_build_asm_src(irb, scope, node, asm_template, nullptr, nullptr, |
| 7771 | nullptr, 0, is_volatile, true); | 8798 | nullptr, 0, is_volatile, true); |
| 7772 | } | 8799 | } |
| 7773 | | 8800 | |
| 7774 | IrInstruction **input_list = allocate<IrInstruction *>(asm_expr->input_list.length); | 8801 | IrInstSrc **input_list = allocate<IrInstSrc *>(asm_expr->input_list.length); |
| 7775 | IrInstruction **output_types = allocate<IrInstruction *>(asm_expr->output_list.length); | 8802 | IrInstSrc **output_types = allocate<IrInstSrc *>(asm_expr->output_list.length); |
| 7776 | ZigVar **output_vars = allocate<ZigVar *>(asm_expr->output_list.length); | 8803 | ZigVar **output_vars = allocate<ZigVar *>(asm_expr->output_list.length); |
| 7777 | size_t return_count = 0; | 8804 | size_t return_count = 0; |
| 7778 | if (!is_volatile && asm_expr->output_list.length == 0) { | 8805 | if (!is_volatile && asm_expr->output_list.length == 0) { |
| 7779 | add_node_error(irb->codegen, node, | 8806 | add_node_error(irb->codegen, node, |
| 7780 | buf_sprintf("assembly expression with no output must be marked volatile")); | 8807 | buf_sprintf("assembly expression with no output must be marked volatile")); |
| 7781 | return irb->codegen->invalid_instruction; | 8808 | return irb->codegen->invalid_inst_src; |
| 7782 | } | 8809 | } |
| 7783 | for (size_t i = 0; i < asm_expr->output_list.length; i += 1) { | 8810 | for (size_t i = 0; i < asm_expr->output_list.length; i += 1) { |
| 7784 | AsmOutput *asm_output = asm_expr->output_list.at(i); | 8811 | AsmOutput *asm_output = asm_expr->output_list.at(i); |
| 7785 | if (asm_output->return_type) { | 8812 | if (asm_output->return_type) { |
| 7786 | return_count += 1; | 8813 | return_count += 1; |
| 7787 | | 8814 | |
| 7788 | IrInstruction *return_type = ir_gen_node(irb, asm_output->return_type, scope); | 8815 | IrInstSrc *return_type = ir_gen_node(irb, asm_output->return_type, scope); |
| 7789 | if (return_type == irb->codegen->invalid_instruction) | 8816 | if (return_type == irb->codegen->invalid_inst_src) |
| 7790 | return irb->codegen->invalid_instruction; | 8817 | return irb->codegen->invalid_inst_src; |
| 7791 | if (return_count > 1) { | 8818 | if (return_count > 1) { |
| 7792 | add_node_error(irb->codegen, node, | 8819 | add_node_error(irb->codegen, node, |
| 7793 | buf_sprintf("inline assembly allows up to one output value")); | 8820 | buf_sprintf("inline assembly allows up to one output value")); |
| 7794 | return irb->codegen->invalid_instruction; | 8821 | return irb->codegen->invalid_inst_src; |
| 7795 | } | 8822 | } |
| 7796 | output_types[i] = return_type; | 8823 | output_types[i] = return_type; |
| 7797 | } else { | 8824 | } else { |
| ... | @@ -7804,7 +8831,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -7804,7 +8831,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod |
| 7804 | } else { | 8831 | } else { |
| 7805 | add_node_error(irb->codegen, node, | 8832 | add_node_error(irb->codegen, node, |
| 7806 | buf_sprintf("use of undeclared identifier '%s'", buf_ptr(variable_name))); | 8833 | buf_sprintf("use of undeclared identifier '%s'", buf_ptr(variable_name))); |
| 7807 | return irb->codegen->invalid_instruction; | 8834 | return irb->codegen->invalid_inst_src; |
| 7808 | } | 8835 | } |
| 7809 | } | 8836 | } |
| 7810 | | 8837 | |
| ... | @@ -7814,14 +8841,14 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -7814,14 +8841,14 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod |
| 7814 | buf_sprintf("invalid modifier starting output constraint for '%s': '%c', only '=' is supported." | 8841 | buf_sprintf("invalid modifier starting output constraint for '%s': '%c', only '=' is supported." |
| 7815 | " Compiler TODO: see https://github.com/ziglang/zig/issues/215", | 8842 | " Compiler TODO: see https://github.com/ziglang/zig/issues/215", |
| 7816 | buf_ptr(asm_output->asm_symbolic_name), modifier)); | 8843 | buf_ptr(asm_output->asm_symbolic_name), modifier)); |
| 7817 | return irb->codegen->invalid_instruction; | 8844 | return irb->codegen->invalid_inst_src; |
| 7818 | } | 8845 | } |
| 7819 | } | 8846 | } |
| 7820 | for (size_t i = 0; i < asm_expr->input_list.length; i += 1) { | 8847 | for (size_t i = 0; i < asm_expr->input_list.length; i += 1) { |
| 7821 | AsmInput *asm_input = asm_expr->input_list.at(i); | 8848 | AsmInput *asm_input = asm_expr->input_list.at(i); |
| 7822 | IrInstruction *input_value = ir_gen_node(irb, asm_input->expr, scope); | 8849 | IrInstSrc *input_value = ir_gen_node(irb, asm_input->expr, scope); |
| 7823 | if (input_value == irb->codegen->invalid_instruction) | 8850 | if (input_value == irb->codegen->invalid_inst_src) |
| 7824 | return irb->codegen->invalid_instruction; | 8851 | return irb->codegen->invalid_inst_src; |
| 7825 | | 8852 | |
| 7826 | input_list[i] = input_value; | 8853 | input_list[i] = input_value; |
| 7827 | } | 8854 | } |
| ... | @@ -7830,7 +8857,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -7830,7 +8857,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod |
| 7830 | output_vars, return_count, is_volatile, false); | 8857 | output_vars, return_count, is_volatile, false); |
| 7831 | } | 8858 | } |
| 7832 | | 8859 | |
| 7833 | static IrInstruction *ir_gen_if_optional_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 8860 | static IrInstSrc *ir_gen_if_optional_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 7834 | ResultLoc *result_loc) | 8861 | ResultLoc *result_loc) |
| 7835 | { | 8862 | { |
| 7836 | assert(node->type == NodeTypeIfOptional); | 8863 | assert(node->type == NodeTypeIfOptional); |
| ... | @@ -7841,24 +8868,24 @@ static IrInstruction *ir_gen_if_optional_expr(IrBuilder *irb, Scope *scope, AstN | ... | @@ -7841,24 +8868,24 @@ static IrInstruction *ir_gen_if_optional_expr(IrBuilder *irb, Scope *scope, AstN |
| 7841 | AstNode *else_node = node->data.test_expr.else_node; | 8868 | AstNode *else_node = node->data.test_expr.else_node; |
| 7842 | bool var_is_ptr = node->data.test_expr.var_is_ptr; | 8869 | bool var_is_ptr = node->data.test_expr.var_is_ptr; |
| 7843 | | 8870 | |
| 7844 | IrInstruction *maybe_val_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); | 8871 | IrInstSrc *maybe_val_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); |
| 7845 | if (maybe_val_ptr == irb->codegen->invalid_instruction) | 8872 | if (maybe_val_ptr == irb->codegen->invalid_inst_src) |
| 7846 | return maybe_val_ptr; | 8873 | return maybe_val_ptr; |
| 7847 | | 8874 | |
| 7848 | IrInstruction *maybe_val = ir_build_load_ptr(irb, scope, node, maybe_val_ptr); | 8875 | IrInstSrc *maybe_val = ir_build_load_ptr(irb, scope, node, maybe_val_ptr); |
| 7849 | IrInstruction *is_non_null = ir_build_test_nonnull(irb, scope, node, maybe_val); | 8876 | IrInstSrc *is_non_null = ir_build_test_non_null_src(irb, scope, node, maybe_val); |
| 7850 | | 8877 | |
| 7851 | IrBasicBlock *then_block = ir_create_basic_block(irb, scope, "OptionalThen"); | 8878 | IrBasicBlockSrc *then_block = ir_create_basic_block(irb, scope, "OptionalThen"); |
| 7852 | IrBasicBlock *else_block = ir_create_basic_block(irb, scope, "OptionalElse"); | 8879 | IrBasicBlockSrc *else_block = ir_create_basic_block(irb, scope, "OptionalElse"); |
| 7853 | IrBasicBlock *endif_block = ir_create_basic_block(irb, scope, "OptionalEndIf"); | 8880 | IrBasicBlockSrc *endif_block = ir_create_basic_block(irb, scope, "OptionalEndIf"); |
| 7854 | | 8881 | |
| 7855 | IrInstruction *is_comptime; | 8882 | IrInstSrc *is_comptime; |
| 7856 | if (ir_should_inline(irb->exec, scope)) { | 8883 | if (ir_should_inline(irb->exec, scope)) { |
| 7857 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 8884 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 7858 | } else { | 8885 | } else { |
| 7859 | is_comptime = ir_build_test_comptime(irb, scope, node, is_non_null); | 8886 | is_comptime = ir_build_test_comptime(irb, scope, node, is_non_null); |
| 7860 | } | 8887 | } |
| 7861 | IrInstruction *cond_br_inst = ir_build_cond_br(irb, scope, node, is_non_null, | 8888 | IrInstSrc *cond_br_inst = ir_build_cond_br(irb, scope, node, is_non_null, |
| 7862 | then_block, else_block, is_comptime); | 8889 | then_block, else_block, is_comptime); |
| 7863 | | 8890 | |
| 7864 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, else_block, endif_block, | 8891 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, else_block, endif_block, |
| ... | @@ -7874,48 +8901,48 @@ static IrInstruction *ir_gen_if_optional_expr(IrBuilder *irb, Scope *scope, AstN | ... | @@ -7874,48 +8901,48 @@ static IrInstruction *ir_gen_if_optional_expr(IrBuilder *irb, Scope *scope, AstN |
| 7874 | ZigVar *var = ir_create_var(irb, node, subexpr_scope, | 8901 | ZigVar *var = ir_create_var(irb, node, subexpr_scope, |
| 7875 | var_symbol, is_const, is_const, is_shadowable, is_comptime); | 8902 | var_symbol, is_const, is_const, is_shadowable, is_comptime); |
| 7876 | | 8903 | |
| 7877 | IrInstruction *payload_ptr = ir_build_optional_unwrap_ptr(irb, subexpr_scope, node, maybe_val_ptr, false, false); | 8904 | IrInstSrc *payload_ptr = ir_build_optional_unwrap_ptr(irb, subexpr_scope, node, maybe_val_ptr, false, false); |
| 7878 | IrInstruction *var_ptr = var_is_ptr ? ir_build_ref(irb, subexpr_scope, node, payload_ptr, true, false) : payload_ptr; | 8905 | IrInstSrc *var_ptr = var_is_ptr ? ir_build_ref_src(irb, subexpr_scope, node, payload_ptr, true, false) : payload_ptr; |
| 7879 | ir_build_var_decl_src(irb, subexpr_scope, node, var, nullptr, var_ptr); | 8906 | ir_build_var_decl_src(irb, subexpr_scope, node, var, nullptr, var_ptr); |
| 7880 | var_scope = var->child_scope; | 8907 | var_scope = var->child_scope; |
| 7881 | } else { | 8908 | } else { |
| 7882 | var_scope = subexpr_scope; | 8909 | var_scope = subexpr_scope; |
| 7883 | } | 8910 | } |
| 7884 | IrInstruction *then_expr_result = ir_gen_node_extra(irb, then_node, var_scope, lval, | 8911 | IrInstSrc *then_expr_result = ir_gen_node_extra(irb, then_node, var_scope, lval, |
| 7885 | &peer_parent->peers.at(0)->base); | 8912 | &peer_parent->peers.at(0)->base); |
| 7886 | if (then_expr_result == irb->codegen->invalid_instruction) | 8913 | if (then_expr_result == irb->codegen->invalid_inst_src) |
| 7887 | return then_expr_result; | 8914 | return then_expr_result; |
| 7888 | IrBasicBlock *after_then_block = irb->current_basic_block; | 8915 | IrBasicBlockSrc *after_then_block = irb->current_basic_block; |
| 7889 | if (!instr_is_unreachable(then_expr_result)) | 8916 | if (!instr_is_unreachable(then_expr_result)) |
| 7890 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); | 8917 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); |
| 7891 | | 8918 | |
| 7892 | ir_set_cursor_at_end_and_append_block(irb, else_block); | 8919 | ir_set_cursor_at_end_and_append_block(irb, else_block); |
| 7893 | IrInstruction *else_expr_result; | 8920 | IrInstSrc *else_expr_result; |
| 7894 | if (else_node) { | 8921 | if (else_node) { |
| 7895 | else_expr_result = ir_gen_node_extra(irb, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base); | 8922 | else_expr_result = ir_gen_node_extra(irb, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base); |
| 7896 | if (else_expr_result == irb->codegen->invalid_instruction) | 8923 | if (else_expr_result == irb->codegen->invalid_inst_src) |
| 7897 | return else_expr_result; | 8924 | return else_expr_result; |
| 7898 | } else { | 8925 | } else { |
| 7899 | else_expr_result = ir_build_const_void(irb, scope, node); | 8926 | else_expr_result = ir_build_const_void(irb, scope, node); |
| 7900 | ir_build_end_expr(irb, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); | 8927 | ir_build_end_expr(irb, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); |
| 7901 | } | 8928 | } |
| 7902 | IrBasicBlock *after_else_block = irb->current_basic_block; | 8929 | IrBasicBlockSrc *after_else_block = irb->current_basic_block; |
| 7903 | if (!instr_is_unreachable(else_expr_result)) | 8930 | if (!instr_is_unreachable(else_expr_result)) |
| 7904 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); | 8931 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); |
| 7905 | | 8932 | |
| 7906 | ir_set_cursor_at_end_and_append_block(irb, endif_block); | 8933 | ir_set_cursor_at_end_and_append_block(irb, endif_block); |
| 7907 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 8934 | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 7908 | incoming_values[0] = then_expr_result; | 8935 | incoming_values[0] = then_expr_result; |
| 7909 | incoming_values[1] = else_expr_result; | 8936 | incoming_values[1] = else_expr_result; |
| 7910 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); | 8937 | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 7911 | incoming_blocks[0] = after_then_block; | 8938 | incoming_blocks[0] = after_then_block; |
| 7912 | incoming_blocks[1] = after_else_block; | 8939 | incoming_blocks[1] = after_else_block; |
| 7913 | | 8940 | |
| 7914 | IrInstruction *phi = ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, peer_parent); | 8941 | IrInstSrc *phi = ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, peer_parent); |
| 7915 | return ir_expr_wrap(irb, scope, phi, result_loc); | 8942 | return ir_expr_wrap(irb, scope, phi, result_loc); |
| 7916 | } | 8943 | } |
| 7917 | | 8944 | |
| 7918 | static IrInstruction *ir_gen_if_err_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 8945 | static IrInstSrc *ir_gen_if_err_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 7919 | ResultLoc *result_loc) | 8946 | ResultLoc *result_loc) |
| 7920 | { | 8947 | { |
| 7921 | assert(node->type == NodeTypeIfErrorExpr); | 8948 | assert(node->type == NodeTypeIfErrorExpr); |
| ... | @@ -7928,20 +8955,20 @@ static IrInstruction *ir_gen_if_err_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -7928,20 +8955,20 @@ static IrInstruction *ir_gen_if_err_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 7928 | Buf *var_symbol = node->data.if_err_expr.var_symbol; | 8955 | Buf *var_symbol = node->data.if_err_expr.var_symbol; |
| 7929 | Buf *err_symbol = node->data.if_err_expr.err_symbol; | 8956 | Buf *err_symbol = node->data.if_err_expr.err_symbol; |
| 7930 | | 8957 | |
| 7931 | IrInstruction *err_val_ptr = ir_gen_node_extra(irb, target_node, scope, LValPtr, nullptr); | 8958 | IrInstSrc *err_val_ptr = ir_gen_node_extra(irb, target_node, scope, LValPtr, nullptr); |
| 7932 | if (err_val_ptr == irb->codegen->invalid_instruction) | 8959 | if (err_val_ptr == irb->codegen->invalid_inst_src) |
| 7933 | return err_val_ptr; | 8960 | return err_val_ptr; |
| 7934 | | 8961 | |
| 7935 | IrInstruction *err_val = ir_build_load_ptr(irb, scope, node, err_val_ptr); | 8962 | IrInstSrc *err_val = ir_build_load_ptr(irb, scope, node, err_val_ptr); |
| 7936 | IrInstruction *is_err = ir_build_test_err_src(irb, scope, node, err_val_ptr, true, false); | 8963 | IrInstSrc *is_err = ir_build_test_err_src(irb, scope, node, err_val_ptr, true, false); |
| 7937 | | 8964 | |
| 7938 | IrBasicBlock *ok_block = ir_create_basic_block(irb, scope, "TryOk"); | 8965 | IrBasicBlockSrc *ok_block = ir_create_basic_block(irb, scope, "TryOk"); |
| 7939 | IrBasicBlock *else_block = ir_create_basic_block(irb, scope, "TryElse"); | 8966 | IrBasicBlockSrc *else_block = ir_create_basic_block(irb, scope, "TryElse"); |
| 7940 | IrBasicBlock *endif_block = ir_create_basic_block(irb, scope, "TryEnd"); | 8967 | IrBasicBlockSrc *endif_block = ir_create_basic_block(irb, scope, "TryEnd"); |
| 7941 | | 8968 | |
| 7942 | bool force_comptime = ir_should_inline(irb->exec, scope); | 8969 | bool force_comptime = ir_should_inline(irb->exec, scope); |
| 7943 | IrInstruction *is_comptime = force_comptime ? ir_build_const_bool(irb, scope, node, true) : ir_build_test_comptime(irb, scope, node, is_err); | 8970 | IrInstSrc *is_comptime = force_comptime ? ir_build_const_bool(irb, scope, node, true) : ir_build_test_comptime(irb, scope, node, is_err); |
| 7944 | IrInstruction *cond_br_inst = ir_build_cond_br(irb, scope, node, is_err, else_block, ok_block, is_comptime); | 8971 | IrInstSrc *cond_br_inst = ir_build_cond_br(irb, scope, node, is_err, else_block, ok_block, is_comptime); |
| 7945 | | 8972 | |
| 7946 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, else_block, endif_block, | 8973 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, else_block, endif_block, |
| 7947 | result_loc, is_comptime); | 8974 | result_loc, is_comptime); |
| ... | @@ -7952,29 +8979,29 @@ static IrInstruction *ir_gen_if_err_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -7952,29 +8979,29 @@ static IrInstruction *ir_gen_if_err_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 7952 | Scope *var_scope; | 8979 | Scope *var_scope; |
| 7953 | if (var_symbol) { | 8980 | if (var_symbol) { |
| 7954 | bool is_shadowable = false; | 8981 | bool is_shadowable = false; |
| 7955 | IrInstruction *var_is_comptime = force_comptime ? ir_build_const_bool(irb, subexpr_scope, node, true) : ir_build_test_comptime(irb, subexpr_scope, node, err_val); | 8982 | IrInstSrc *var_is_comptime = force_comptime ? ir_build_const_bool(irb, subexpr_scope, node, true) : ir_build_test_comptime(irb, subexpr_scope, node, err_val); |
| 7956 | ZigVar *var = ir_create_var(irb, node, subexpr_scope, | 8983 | ZigVar *var = ir_create_var(irb, node, subexpr_scope, |
| 7957 | var_symbol, var_is_const, var_is_const, is_shadowable, var_is_comptime); | 8984 | var_symbol, var_is_const, var_is_const, is_shadowable, var_is_comptime); |
| 7958 | | 8985 | |
| 7959 | IrInstruction *payload_ptr = ir_build_unwrap_err_payload(irb, subexpr_scope, node, err_val_ptr, false, false); | 8986 | IrInstSrc *payload_ptr = ir_build_unwrap_err_payload_src(irb, subexpr_scope, node, err_val_ptr, false, false); |
| 7960 | IrInstruction *var_ptr = var_is_ptr ? | 8987 | IrInstSrc *var_ptr = var_is_ptr ? |
| 7961 | ir_build_ref(irb, subexpr_scope, node, payload_ptr, true, false) : payload_ptr; | 8988 | ir_build_ref_src(irb, subexpr_scope, node, payload_ptr, true, false) : payload_ptr; |
| 7962 | ir_build_var_decl_src(irb, subexpr_scope, node, var, nullptr, var_ptr); | 8989 | ir_build_var_decl_src(irb, subexpr_scope, node, var, nullptr, var_ptr); |
| 7963 | var_scope = var->child_scope; | 8990 | var_scope = var->child_scope; |
| 7964 | } else { | 8991 | } else { |
| 7965 | var_scope = subexpr_scope; | 8992 | var_scope = subexpr_scope; |
| 7966 | } | 8993 | } |
| 7967 | IrInstruction *then_expr_result = ir_gen_node_extra(irb, then_node, var_scope, lval, | 8994 | IrInstSrc *then_expr_result = ir_gen_node_extra(irb, then_node, var_scope, lval, |
| 7968 | &peer_parent->peers.at(0)->base); | 8995 | &peer_parent->peers.at(0)->base); |
| 7969 | if (then_expr_result == irb->codegen->invalid_instruction) | 8996 | if (then_expr_result == irb->codegen->invalid_inst_src) |
| 7970 | return then_expr_result; | 8997 | return then_expr_result; |
| 7971 | IrBasicBlock *after_then_block = irb->current_basic_block; | 8998 | IrBasicBlockSrc *after_then_block = irb->current_basic_block; |
| 7972 | if (!instr_is_unreachable(then_expr_result)) | 8999 | if (!instr_is_unreachable(then_expr_result)) |
| 7973 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); | 9000 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); |
| 7974 | | 9001 | |
| 7975 | ir_set_cursor_at_end_and_append_block(irb, else_block); | 9002 | ir_set_cursor_at_end_and_append_block(irb, else_block); |
| 7976 | | 9003 | |
| 7977 | IrInstruction *else_expr_result; | 9004 | IrInstSrc *else_expr_result; |
| 7978 | if (else_node) { | 9005 | if (else_node) { |
| 7979 | Scope *err_var_scope; | 9006 | Scope *err_var_scope; |
| 7980 | if (err_symbol) { | 9007 | if (err_symbol) { |
| ... | @@ -7983,40 +9010,40 @@ static IrInstruction *ir_gen_if_err_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -7983,40 +9010,40 @@ static IrInstruction *ir_gen_if_err_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 7983 | ZigVar *var = ir_create_var(irb, node, subexpr_scope, | 9010 | ZigVar *var = ir_create_var(irb, node, subexpr_scope, |
| 7984 | err_symbol, is_const, is_const, is_shadowable, is_comptime); | 9011 | err_symbol, is_const, is_const, is_shadowable, is_comptime); |
| 7985 | | 9012 | |
| 7986 | IrInstruction *err_ptr = ir_build_unwrap_err_code(irb, subexpr_scope, node, err_val_ptr); | 9013 | IrInstSrc *err_ptr = ir_build_unwrap_err_code_src(irb, subexpr_scope, node, err_val_ptr); |
| 7987 | ir_build_var_decl_src(irb, subexpr_scope, node, var, nullptr, err_ptr); | 9014 | ir_build_var_decl_src(irb, subexpr_scope, node, var, nullptr, err_ptr); |
| 7988 | err_var_scope = var->child_scope; | 9015 | err_var_scope = var->child_scope; |
| 7989 | } else { | 9016 | } else { |
| 7990 | err_var_scope = subexpr_scope; | 9017 | err_var_scope = subexpr_scope; |
| 7991 | } | 9018 | } |
| 7992 | else_expr_result = ir_gen_node_extra(irb, else_node, err_var_scope, lval, &peer_parent->peers.at(1)->base); | 9019 | else_expr_result = ir_gen_node_extra(irb, else_node, err_var_scope, lval, &peer_parent->peers.at(1)->base); |
| 7993 | if (else_expr_result == irb->codegen->invalid_instruction) | 9020 | if (else_expr_result == irb->codegen->invalid_inst_src) |
| 7994 | return else_expr_result; | 9021 | return else_expr_result; |
| 7995 | } else { | 9022 | } else { |
| 7996 | else_expr_result = ir_build_const_void(irb, scope, node); | 9023 | else_expr_result = ir_build_const_void(irb, scope, node); |
| 7997 | ir_build_end_expr(irb, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); | 9024 | ir_build_end_expr(irb, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); |
| 7998 | } | 9025 | } |
| 7999 | IrBasicBlock *after_else_block = irb->current_basic_block; | 9026 | IrBasicBlockSrc *after_else_block = irb->current_basic_block; |
| 8000 | if (!instr_is_unreachable(else_expr_result)) | 9027 | if (!instr_is_unreachable(else_expr_result)) |
| 8001 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); | 9028 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); |
| 8002 | | 9029 | |
| 8003 | ir_set_cursor_at_end_and_append_block(irb, endif_block); | 9030 | ir_set_cursor_at_end_and_append_block(irb, endif_block); |
| 8004 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 9031 | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 8005 | incoming_values[0] = then_expr_result; | 9032 | incoming_values[0] = then_expr_result; |
| 8006 | incoming_values[1] = else_expr_result; | 9033 | incoming_values[1] = else_expr_result; |
| 8007 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); | 9034 | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 8008 | incoming_blocks[0] = after_then_block; | 9035 | incoming_blocks[0] = after_then_block; |
| 8009 | incoming_blocks[1] = after_else_block; | 9036 | incoming_blocks[1] = after_else_block; |
| 8010 | | 9037 | |
| 8011 | IrInstruction *phi = ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, peer_parent); | 9038 | IrInstSrc *phi = ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, peer_parent); |
| 8012 | return ir_expr_wrap(irb, scope, phi, result_loc); | 9039 | return ir_expr_wrap(irb, scope, phi, result_loc); |
| 8013 | } | 9040 | } |
| 8014 | | 9041 | |
| 8015 | static bool ir_gen_switch_prong_expr(IrBuilder *irb, Scope *scope, AstNode *switch_node, AstNode *prong_node, | 9042 | static bool ir_gen_switch_prong_expr(IrBuilderSrc *irb, Scope *scope, AstNode *switch_node, AstNode *prong_node, |
| 8016 | IrBasicBlock *end_block, IrInstruction *is_comptime, IrInstruction *var_is_comptime, | 9043 | IrBasicBlockSrc *end_block, IrInstSrc *is_comptime, IrInstSrc *var_is_comptime, |
| 8017 | IrInstruction *target_value_ptr, IrInstruction **prong_values, size_t prong_values_len, | 9044 | IrInstSrc *target_value_ptr, IrInstSrc **prong_values, size_t prong_values_len, |
| 8018 | ZigList<IrBasicBlock *> *incoming_blocks, ZigList<IrInstruction *> *incoming_values, | 9045 | ZigList<IrBasicBlockSrc *> *incoming_blocks, ZigList<IrInstSrc *> *incoming_values, |
| 8019 | IrInstructionSwitchElseVar **out_switch_else_var, LVal lval, ResultLoc *result_loc) | 9046 | IrInstSrcSwitchElseVar **out_switch_else_var, LVal lval, ResultLoc *result_loc) |
| 8020 | { | 9047 | { |
| 8021 | assert(switch_node->type == NodeTypeSwitchExpr); | 9048 | assert(switch_node->type == NodeTypeSwitchExpr); |
| 8022 | assert(prong_node->type == NodeTypeSwitchProng); | 9049 | assert(prong_node->type == NodeTypeSwitchProng); |
| ... | @@ -8034,28 +9061,28 @@ static bool ir_gen_switch_prong_expr(IrBuilder *irb, Scope *scope, AstNode *swit | ... | @@ -8034,28 +9061,28 @@ static bool ir_gen_switch_prong_expr(IrBuilder *irb, Scope *scope, AstNode *swit |
| 8034 | ZigVar *var = ir_create_var(irb, var_symbol_node, scope, | 9061 | ZigVar *var = ir_create_var(irb, var_symbol_node, scope, |
| 8035 | var_name, is_const, is_const, is_shadowable, var_is_comptime); | 9062 | var_name, is_const, is_const, is_shadowable, var_is_comptime); |
| 8036 | child_scope = var->child_scope; | 9063 | child_scope = var->child_scope; |
| 8037 | IrInstruction *var_ptr; | 9064 | IrInstSrc *var_ptr; |
| 8038 | if (out_switch_else_var != nullptr) { | 9065 | if (out_switch_else_var != nullptr) { |
| 8039 | IrInstructionSwitchElseVar *switch_else_var = ir_build_switch_else_var(irb, scope, var_symbol_node, | 9066 | IrInstSrcSwitchElseVar *switch_else_var = ir_build_switch_else_var(irb, scope, var_symbol_node, |
| 8040 | target_value_ptr); | 9067 | target_value_ptr); |
| 8041 | *out_switch_else_var = switch_else_var; | 9068 | *out_switch_else_var = switch_else_var; |
| 8042 | IrInstruction *payload_ptr = &switch_else_var->base; | 9069 | IrInstSrc *payload_ptr = &switch_else_var->base; |
| 8043 | var_ptr = var_is_ptr ? ir_build_ref(irb, scope, var_symbol_node, payload_ptr, true, false) : payload_ptr; | 9070 | var_ptr = var_is_ptr ? ir_build_ref_src(irb, scope, var_symbol_node, payload_ptr, true, false) : payload_ptr; |
| 8044 | } else if (prong_values != nullptr) { | 9071 | } else if (prong_values != nullptr) { |
| 8045 | IrInstruction *payload_ptr = ir_build_switch_var(irb, scope, var_symbol_node, target_value_ptr, | 9072 | IrInstSrc *payload_ptr = ir_build_switch_var(irb, scope, var_symbol_node, target_value_ptr, |
| 8046 | prong_values, prong_values_len); | 9073 | prong_values, prong_values_len); |
| 8047 | var_ptr = var_is_ptr ? ir_build_ref(irb, scope, var_symbol_node, payload_ptr, true, false) : payload_ptr; | 9074 | var_ptr = var_is_ptr ? ir_build_ref_src(irb, scope, var_symbol_node, payload_ptr, true, false) : payload_ptr; |
| 8048 | } else { | 9075 | } else { |
| 8049 | var_ptr = var_is_ptr ? | 9076 | var_ptr = var_is_ptr ? |
| 8050 | ir_build_ref(irb, scope, var_symbol_node, target_value_ptr, true, false) : target_value_ptr; | 9077 | ir_build_ref_src(irb, scope, var_symbol_node, target_value_ptr, true, false) : target_value_ptr; |
| 8051 | } | 9078 | } |
| 8052 | ir_build_var_decl_src(irb, scope, var_symbol_node, var, nullptr, var_ptr); | 9079 | ir_build_var_decl_src(irb, scope, var_symbol_node, var, nullptr, var_ptr); |
| 8053 | } else { | 9080 | } else { |
| 8054 | child_scope = scope; | 9081 | child_scope = scope; |
| 8055 | } | 9082 | } |
| 8056 | | 9083 | |
| 8057 | IrInstruction *expr_result = ir_gen_node_extra(irb, expr_node, child_scope, lval, result_loc); | 9084 | IrInstSrc *expr_result = ir_gen_node_extra(irb, expr_node, child_scope, lval, result_loc); |
| 8058 | if (expr_result == irb->codegen->invalid_instruction) | 9085 | if (expr_result == irb->codegen->invalid_inst_src) |
| 8059 | return false; | 9086 | return false; |
| 8060 | if (!instr_is_unreachable(expr_result)) | 9087 | if (!instr_is_unreachable(expr_result)) |
| 8061 | ir_mark_gen(ir_build_br(irb, scope, switch_node, end_block, is_comptime)); | 9088 | ir_mark_gen(ir_build_br(irb, scope, switch_node, end_block, is_comptime)); |
| ... | @@ -8064,25 +9091,25 @@ static bool ir_gen_switch_prong_expr(IrBuilder *irb, Scope *scope, AstNode *swit | ... | @@ -8064,25 +9091,25 @@ static bool ir_gen_switch_prong_expr(IrBuilder *irb, Scope *scope, AstNode *swit |
| 8064 | return true; | 9091 | return true; |
| 8065 | } | 9092 | } |
| 8066 | | 9093 | |
| 8067 | static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 9094 | static IrInstSrc *ir_gen_switch_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 8068 | ResultLoc *result_loc) | 9095 | ResultLoc *result_loc) |
| 8069 | { | 9096 | { |
| 8070 | assert(node->type == NodeTypeSwitchExpr); | 9097 | assert(node->type == NodeTypeSwitchExpr); |
| 8071 | | 9098 | |
| 8072 | AstNode *target_node = node->data.switch_expr.expr; | 9099 | AstNode *target_node = node->data.switch_expr.expr; |
| 8073 | IrInstruction *target_value_ptr = ir_gen_node_extra(irb, target_node, scope, LValPtr, nullptr); | 9100 | IrInstSrc *target_value_ptr = ir_gen_node_extra(irb, target_node, scope, LValPtr, nullptr); |
| 8074 | if (target_value_ptr == irb->codegen->invalid_instruction) | 9101 | if (target_value_ptr == irb->codegen->invalid_inst_src) |
| 8075 | return target_value_ptr; | 9102 | return target_value_ptr; |
| 8076 | IrInstruction *target_value = ir_build_switch_target(irb, scope, node, target_value_ptr); | 9103 | IrInstSrc *target_value = ir_build_switch_target(irb, scope, node, target_value_ptr); |
| 8077 | | 9104 | |
| 8078 | IrBasicBlock *else_block = ir_create_basic_block(irb, scope, "SwitchElse"); | 9105 | IrBasicBlockSrc *else_block = ir_create_basic_block(irb, scope, "SwitchElse"); |
| 8079 | IrBasicBlock *end_block = ir_create_basic_block(irb, scope, "SwitchEnd"); | 9106 | IrBasicBlockSrc *end_block = ir_create_basic_block(irb, scope, "SwitchEnd"); |
| 8080 | | 9107 | |
| 8081 | size_t prong_count = node->data.switch_expr.prongs.length; | 9108 | size_t prong_count = node->data.switch_expr.prongs.length; |
| 8082 | ZigList<IrInstructionSwitchBrCase> cases = {0}; | 9109 | ZigList<IrInstSrcSwitchBrCase> cases = {0}; |
| 8083 | | 9110 | |
| 8084 | IrInstruction *is_comptime; | 9111 | IrInstSrc *is_comptime; |
| 8085 | IrInstruction *var_is_comptime; | 9112 | IrInstSrc *var_is_comptime; |
| 8086 | if (ir_should_inline(irb->exec, scope)) { | 9113 | if (ir_should_inline(irb->exec, scope)) { |
| 8087 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 9114 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 8088 | var_is_comptime = is_comptime; | 9115 | var_is_comptime = is_comptime; |
| ... | @@ -8091,11 +9118,11 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8091,11 +9118,11 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8091 | var_is_comptime = ir_build_test_comptime(irb, scope, node, target_value_ptr); | 9118 | var_is_comptime = ir_build_test_comptime(irb, scope, node, target_value_ptr); |
| 8092 | } | 9119 | } |
| 8093 | | 9120 | |
| 8094 | ZigList<IrInstruction *> incoming_values = {0}; | 9121 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 8095 | ZigList<IrBasicBlock *> incoming_blocks = {0}; | 9122 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; |
| 8096 | ZigList<IrInstructionCheckSwitchProngsRange> check_ranges = {0}; | 9123 | ZigList<IrInstSrcCheckSwitchProngsRange> check_ranges = {0}; |
| 8097 | | 9124 | |
| 8098 | IrInstructionSwitchElseVar *switch_else_var = nullptr; | 9125 | IrInstSrcSwitchElseVar *switch_else_var = nullptr; |
| 8099 | | 9126 | |
| 8100 | ResultLocPeerParent *peer_parent = allocate<ResultLocPeerParent>(1); | 9127 | ResultLocPeerParent *peer_parent = allocate<ResultLocPeerParent>(1); |
| 8101 | peer_parent->base.id = ResultLocIdPeerParent; | 9128 | peer_parent->base.id = ResultLocIdPeerParent; |
| ... | @@ -8110,37 +9137,14 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8110,37 +9137,14 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8110 | Scope *subexpr_scope = create_runtime_scope(irb->codegen, node, scope, is_comptime); | 9137 | Scope *subexpr_scope = create_runtime_scope(irb->codegen, node, scope, is_comptime); |
| 8111 | Scope *comptime_scope = create_comptime_scope(irb->codegen, node, scope); | 9138 | Scope *comptime_scope = create_comptime_scope(irb->codegen, node, scope); |
| 8112 | AstNode *else_prong = nullptr; | 9139 | AstNode *else_prong = nullptr; |
| | 9140 | AstNode *underscore_prong = nullptr; |
| 8113 | for (size_t prong_i = 0; prong_i < prong_count; prong_i += 1) { | 9141 | for (size_t prong_i = 0; prong_i < prong_count; prong_i += 1) { |
| 8114 | AstNode *prong_node = node->data.switch_expr.prongs.at(prong_i); | 9142 | AstNode *prong_node = node->data.switch_expr.prongs.at(prong_i); |
| 8115 | size_t prong_item_count = prong_node->data.switch_prong.items.length; | 9143 | size_t prong_item_count = prong_node->data.switch_prong.items.length; |
| 8116 | if (prong_item_count == 0) { | 9144 | if (prong_node->data.switch_prong.any_items_are_range) { |
| 8117 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); | | |
| 8118 | if (else_prong) { | | |
| 8119 | ErrorMsg *msg = add_node_error(irb->codegen, prong_node, | | |
| 8120 | buf_sprintf("multiple else prongs in switch expression")); | | |
| 8121 | add_error_note(irb->codegen, msg, else_prong, | | |
| 8122 | buf_sprintf("previous else prong is here")); | | |
| 8123 | return irb->codegen->invalid_instruction; | | |
| 8124 | } | | |
| 8125 | else_prong = prong_node; | | |
| 8126 | | | |
| 8127 | IrBasicBlock *prev_block = irb->current_basic_block; | | |
| 8128 | if (peer_parent->peers.length > 0) { | | |
| 8129 | peer_parent->peers.last()->next_bb = else_block; | | |
| 8130 | } | | |
| 8131 | peer_parent->peers.append(this_peer_result_loc); | | |
| 8132 | ir_set_cursor_at_end_and_append_block(irb, else_block); | | |
| 8133 | if (!ir_gen_switch_prong_expr(irb, subexpr_scope, node, prong_node, end_block, | | |
| 8134 | is_comptime, var_is_comptime, target_value_ptr, nullptr, 0, &incoming_blocks, &incoming_values, | | |
| 8135 | &switch_else_var, LValNone, &this_peer_result_loc->base)) | | |
| 8136 | { | | |
| 8137 | return irb->codegen->invalid_instruction; | | |
| 8138 | } | | |
| 8139 | ir_set_cursor_at_end(irb, prev_block); | | |
| 8140 | } else if (prong_node->data.switch_prong.any_items_are_range) { | | |
| 8141 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); | 9145 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); |
| 8142 | | 9146 | |
| 8143 | IrInstruction *ok_bit = nullptr; | 9147 | IrInstSrc *ok_bit = nullptr; |
| 8144 | AstNode *last_item_node = nullptr; | 9148 | AstNode *last_item_node = nullptr; |
| 8145 | for (size_t item_i = 0; item_i < prong_item_count; item_i += 1) { | 9149 | for (size_t item_i = 0; item_i < prong_item_count; item_i += 1) { |
| 8146 | AstNode *item_node = prong_node->data.switch_prong.items.at(item_i); | 9150 | AstNode *item_node = prong_node->data.switch_prong.items.at(item_i); |
| ... | @@ -8149,23 +9153,23 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8149,23 +9153,23 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8149 | AstNode *start_node = item_node->data.switch_range.start; | 9153 | AstNode *start_node = item_node->data.switch_range.start; |
| 8150 | AstNode *end_node = item_node->data.switch_range.end; | 9154 | AstNode *end_node = item_node->data.switch_range.end; |
| 8151 | | 9155 | |
| 8152 | IrInstruction *start_value = ir_gen_node(irb, start_node, comptime_scope); | 9156 | IrInstSrc *start_value = ir_gen_node(irb, start_node, comptime_scope); |
| 8153 | if (start_value == irb->codegen->invalid_instruction) | 9157 | if (start_value == irb->codegen->invalid_inst_src) |
| 8154 | return irb->codegen->invalid_instruction; | 9158 | return irb->codegen->invalid_inst_src; |
| 8155 | | 9159 | |
| 8156 | IrInstruction *end_value = ir_gen_node(irb, end_node, comptime_scope); | 9160 | IrInstSrc *end_value = ir_gen_node(irb, end_node, comptime_scope); |
| 8157 | if (end_value == irb->codegen->invalid_instruction) | 9161 | if (end_value == irb->codegen->invalid_inst_src) |
| 8158 | return irb->codegen->invalid_instruction; | 9162 | return irb->codegen->invalid_inst_src; |
| 8159 | | 9163 | |
| 8160 | IrInstructionCheckSwitchProngsRange *check_range = check_ranges.add_one(); | 9164 | IrInstSrcCheckSwitchProngsRange *check_range = check_ranges.add_one(); |
| 8161 | check_range->start = start_value; | 9165 | check_range->start = start_value; |
| 8162 | check_range->end = end_value; | 9166 | check_range->end = end_value; |
| 8163 | | 9167 | |
| 8164 | IrInstruction *lower_range_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpCmpGreaterOrEq, | 9168 | IrInstSrc *lower_range_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpCmpGreaterOrEq, |
| 8165 | target_value, start_value, false); | 9169 | target_value, start_value, false); |
| 8166 | IrInstruction *upper_range_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpCmpLessOrEq, | 9170 | IrInstSrc *upper_range_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpCmpLessOrEq, |
| 8167 | target_value, end_value, false); | 9171 | target_value, end_value, false); |
| 8168 | IrInstruction *both_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpBoolAnd, | 9172 | IrInstSrc *both_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpBoolAnd, |
| 8169 | lower_range_ok, upper_range_ok, false); | 9173 | lower_range_ok, upper_range_ok, false); |
| 8170 | if (ok_bit) { | 9174 | if (ok_bit) { |
| 8171 | ok_bit = ir_build_bin_op(irb, scope, item_node, IrBinOpBoolOr, both_ok, ok_bit, false); | 9175 | ok_bit = ir_build_bin_op(irb, scope, item_node, IrBinOpBoolOr, both_ok, ok_bit, false); |
| ... | @@ -8173,15 +9177,15 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8173,15 +9177,15 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8173 | ok_bit = both_ok; | 9177 | ok_bit = both_ok; |
| 8174 | } | 9178 | } |
| 8175 | } else { | 9179 | } else { |
| 8176 | IrInstruction *item_value = ir_gen_node(irb, item_node, comptime_scope); | 9180 | IrInstSrc *item_value = ir_gen_node(irb, item_node, comptime_scope); |
| 8177 | if (item_value == irb->codegen->invalid_instruction) | 9181 | if (item_value == irb->codegen->invalid_inst_src) |
| 8178 | return irb->codegen->invalid_instruction; | 9182 | return irb->codegen->invalid_inst_src; |
| 8179 | | 9183 | |
| 8180 | IrInstructionCheckSwitchProngsRange *check_range = check_ranges.add_one(); | 9184 | IrInstSrcCheckSwitchProngsRange *check_range = check_ranges.add_one(); |
| 8181 | check_range->start = item_value; | 9185 | check_range->start = item_value; |
| 8182 | check_range->end = item_value; | 9186 | check_range->end = item_value; |
| 8183 | | 9187 | |
| 8184 | IrInstruction *cmp_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpCmpEq, | 9188 | IrInstSrc *cmp_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpCmpEq, |
| 8185 | item_value, target_value, false); | 9189 | item_value, target_value, false); |
| 8186 | if (ok_bit) { | 9190 | if (ok_bit) { |
| 8187 | ok_bit = ir_build_bin_op(irb, scope, item_node, IrBinOpBoolOr, cmp_ok, ok_bit, false); | 9191 | ok_bit = ir_build_bin_op(irb, scope, item_node, IrBinOpBoolOr, cmp_ok, ok_bit, false); |
| ... | @@ -8191,12 +9195,12 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8191,12 +9195,12 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8191 | } | 9195 | } |
| 8192 | } | 9196 | } |
| 8193 | | 9197 | |
| 8194 | IrBasicBlock *range_block_yes = ir_create_basic_block(irb, scope, "SwitchRangeYes"); | 9198 | IrBasicBlockSrc *range_block_yes = ir_create_basic_block(irb, scope, "SwitchRangeYes"); |
| 8195 | IrBasicBlock *range_block_no = ir_create_basic_block(irb, scope, "SwitchRangeNo"); | 9199 | IrBasicBlockSrc *range_block_no = ir_create_basic_block(irb, scope, "SwitchRangeNo"); |
| 8196 | | 9200 | |
| 8197 | assert(ok_bit); | 9201 | assert(ok_bit); |
| 8198 | assert(last_item_node); | 9202 | assert(last_item_node); |
| 8199 | IrInstruction *br_inst = ir_mark_gen(ir_build_cond_br(irb, scope, last_item_node, ok_bit, | 9203 | IrInstSrc *br_inst = ir_mark_gen(ir_build_cond_br(irb, scope, last_item_node, ok_bit, |
| 8200 | range_block_yes, range_block_no, is_comptime)); | 9204 | range_block_yes, range_block_no, is_comptime)); |
| 8201 | if (peer_parent->base.source_instruction == nullptr) { | 9205 | if (peer_parent->base.source_instruction == nullptr) { |
| 8202 | peer_parent->base.source_instruction = br_inst; | 9206 | peer_parent->base.source_instruction = br_inst; |
| ... | @@ -8211,10 +9215,60 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8211,10 +9215,60 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8211 | is_comptime, var_is_comptime, target_value_ptr, nullptr, 0, | 9215 | is_comptime, var_is_comptime, target_value_ptr, nullptr, 0, |
| 8212 | &incoming_blocks, &incoming_values, nullptr, LValNone, &this_peer_result_loc->base)) | 9216 | &incoming_blocks, &incoming_values, nullptr, LValNone, &this_peer_result_loc->base)) |
| 8213 | { | 9217 | { |
| 8214 | return irb->codegen->invalid_instruction; | 9218 | return irb->codegen->invalid_inst_src; |
| | 9219 | } |
| | 9220 | |
| | 9221 | ir_set_cursor_at_end_and_append_block(irb, range_block_no); |
| | 9222 | } else { |
| | 9223 | if (prong_item_count == 0) { |
| | 9224 | if (else_prong) { |
| | 9225 | ErrorMsg *msg = add_node_error(irb->codegen, prong_node, |
| | 9226 | buf_sprintf("multiple else prongs in switch expression")); |
| | 9227 | add_error_note(irb->codegen, msg, else_prong, |
| | 9228 | buf_sprintf("previous else prong is here")); |
| | 9229 | return irb->codegen->invalid_inst_src; |
| | 9230 | } |
| | 9231 | else_prong = prong_node; |
| | 9232 | } else if (prong_item_count == 1 && |
| | 9233 | prong_node->data.switch_prong.items.at(0)->type == NodeTypeSymbol && |
| | 9234 | buf_eql_str(prong_node->data.switch_prong.items.at(0)->data.symbol_expr.symbol, "_")) { |
| | 9235 | if (underscore_prong) { |
| | 9236 | ErrorMsg *msg = add_node_error(irb->codegen, prong_node, |
| | 9237 | buf_sprintf("multiple '_' prongs in switch expression")); |
| | 9238 | add_error_note(irb->codegen, msg, underscore_prong, |
| | 9239 | buf_sprintf("previous '_' prong is here")); |
| | 9240 | return irb->codegen->invalid_inst_src; |
| | 9241 | } |
| | 9242 | underscore_prong = prong_node; |
| | 9243 | } else { |
| | 9244 | continue; |
| | 9245 | } |
| | 9246 | if (underscore_prong && else_prong) { |
| | 9247 | ErrorMsg *msg = add_node_error(irb->codegen, prong_node, |
| | 9248 | buf_sprintf("else and '_' prong in switch expression")); |
| | 9249 | if (underscore_prong == prong_node) |
| | 9250 | add_error_note(irb->codegen, msg, else_prong, |
| | 9251 | buf_sprintf("else prong is here")); |
| | 9252 | else |
| | 9253 | add_error_note(irb->codegen, msg, underscore_prong, |
| | 9254 | buf_sprintf("'_' prong is here")); |
| | 9255 | return irb->codegen->invalid_inst_src; |
| | 9256 | } |
| | 9257 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); |
| | 9258 | |
| | 9259 | IrBasicBlockSrc *prev_block = irb->current_basic_block; |
| | 9260 | if (peer_parent->peers.length > 0) { |
| | 9261 | peer_parent->peers.last()->next_bb = else_block; |
| | 9262 | } |
| | 9263 | peer_parent->peers.append(this_peer_result_loc); |
| | 9264 | ir_set_cursor_at_end_and_append_block(irb, else_block); |
| | 9265 | if (!ir_gen_switch_prong_expr(irb, subexpr_scope, node, prong_node, end_block, |
| | 9266 | is_comptime, var_is_comptime, target_value_ptr, nullptr, 0, &incoming_blocks, &incoming_values, |
| | 9267 | &switch_else_var, LValNone, &this_peer_result_loc->base)) |
| | 9268 | { |
| | 9269 | return irb->codegen->invalid_inst_src; |
| 8215 | } | 9270 | } |
| 8216 | | 9271 | ir_set_cursor_at_end(irb, prev_block); |
| 8217 | ir_set_cursor_at_end_and_append_block(irb, range_block_no); | | |
| 8218 | } | 9272 | } |
| 8219 | } | 9273 | } |
| 8220 | | 9274 | |
| ... | @@ -8226,32 +9280,34 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8226,32 +9280,34 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8226 | continue; | 9280 | continue; |
| 8227 | if (prong_node->data.switch_prong.any_items_are_range) | 9281 | if (prong_node->data.switch_prong.any_items_are_range) |
| 8228 | continue; | 9282 | continue; |
| | 9283 | if (underscore_prong == prong_node) |
| | 9284 | continue; |
| 8229 | | 9285 | |
| 8230 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); | 9286 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); |
| 8231 | | 9287 | |
| 8232 | IrBasicBlock *prong_block = ir_create_basic_block(irb, scope, "SwitchProng"); | 9288 | IrBasicBlockSrc *prong_block = ir_create_basic_block(irb, scope, "SwitchProng"); |
| 8233 | IrInstruction **items = allocate<IrInstruction *>(prong_item_count); | 9289 | IrInstSrc **items = allocate<IrInstSrc *>(prong_item_count); |
| 8234 | | 9290 | |
| 8235 | for (size_t item_i = 0; item_i < prong_item_count; item_i += 1) { | 9291 | for (size_t item_i = 0; item_i < prong_item_count; item_i += 1) { |
| 8236 | AstNode *item_node = prong_node->data.switch_prong.items.at(item_i); | 9292 | AstNode *item_node = prong_node->data.switch_prong.items.at(item_i); |
| 8237 | assert(item_node->type != NodeTypeSwitchRange); | 9293 | assert(item_node->type != NodeTypeSwitchRange); |
| 8238 | | 9294 | |
| 8239 | IrInstruction *item_value = ir_gen_node(irb, item_node, comptime_scope); | 9295 | IrInstSrc *item_value = ir_gen_node(irb, item_node, comptime_scope); |
| 8240 | if (item_value == irb->codegen->invalid_instruction) | 9296 | if (item_value == irb->codegen->invalid_inst_src) |
| 8241 | return irb->codegen->invalid_instruction; | 9297 | return irb->codegen->invalid_inst_src; |
| 8242 | | 9298 | |
| 8243 | IrInstructionCheckSwitchProngsRange *check_range = check_ranges.add_one(); | 9299 | IrInstSrcCheckSwitchProngsRange *check_range = check_ranges.add_one(); |
| 8244 | check_range->start = item_value; | 9300 | check_range->start = item_value; |
| 8245 | check_range->end = item_value; | 9301 | check_range->end = item_value; |
| 8246 | | 9302 | |
| 8247 | IrInstructionSwitchBrCase *this_case = cases.add_one(); | 9303 | IrInstSrcSwitchBrCase *this_case = cases.add_one(); |
| 8248 | this_case->value = item_value; | 9304 | this_case->value = item_value; |
| 8249 | this_case->block = prong_block; | 9305 | this_case->block = prong_block; |
| 8250 | | 9306 | |
| 8251 | items[item_i] = item_value; | 9307 | items[item_i] = item_value; |
| 8252 | } | 9308 | } |
| 8253 | | 9309 | |
| 8254 | IrBasicBlock *prev_block = irb->current_basic_block; | 9310 | IrBasicBlockSrc *prev_block = irb->current_basic_block; |
| 8255 | if (peer_parent->peers.length > 0) { | 9311 | if (peer_parent->peers.length > 0) { |
| 8256 | peer_parent->peers.last()->next_bb = prong_block; | 9312 | peer_parent->peers.last()->next_bb = prong_block; |
| 8257 | } | 9313 | } |
| ... | @@ -8261,21 +9317,21 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8261,21 +9317,21 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8261 | is_comptime, var_is_comptime, target_value_ptr, items, prong_item_count, | 9317 | is_comptime, var_is_comptime, target_value_ptr, items, prong_item_count, |
| 8262 | &incoming_blocks, &incoming_values, nullptr, LValNone, &this_peer_result_loc->base)) | 9318 | &incoming_blocks, &incoming_values, nullptr, LValNone, &this_peer_result_loc->base)) |
| 8263 | { | 9319 | { |
| 8264 | return irb->codegen->invalid_instruction; | 9320 | return irb->codegen->invalid_inst_src; |
| 8265 | } | 9321 | } |
| 8266 | | 9322 | |
| 8267 | ir_set_cursor_at_end(irb, prev_block); | 9323 | ir_set_cursor_at_end(irb, prev_block); |
| 8268 | | 9324 | |
| 8269 | } | 9325 | } |
| 8270 | | 9326 | |
| 8271 | IrInstruction *switch_prongs_void = ir_build_check_switch_prongs(irb, scope, node, target_value, | 9327 | IrInstSrc *switch_prongs_void = ir_build_check_switch_prongs(irb, scope, node, target_value, |
| 8272 | check_ranges.items, check_ranges.length, else_prong != nullptr); | 9328 | check_ranges.items, check_ranges.length, else_prong != nullptr, underscore_prong != nullptr); |
| 8273 | | 9329 | |
| 8274 | IrInstruction *br_instruction; | 9330 | IrInstSrc *br_instruction; |
| 8275 | if (cases.length == 0) { | 9331 | if (cases.length == 0) { |
| 8276 | br_instruction = ir_build_br(irb, scope, node, else_block, is_comptime); | 9332 | br_instruction = ir_build_br(irb, scope, node, else_block, is_comptime); |
| 8277 | } else { | 9333 | } else { |
| 8278 | IrInstructionSwitchBr *switch_br = ir_build_switch_br(irb, scope, node, target_value, else_block, | 9334 | IrInstSrcSwitchBr *switch_br = ir_build_switch_br_src(irb, scope, node, target_value, else_block, |
| 8279 | cases.length, cases.items, is_comptime, switch_prongs_void); | 9335 | cases.length, cases.items, is_comptime, switch_prongs_void); |
| 8280 | if (switch_else_var != nullptr) { | 9336 | if (switch_else_var != nullptr) { |
| 8281 | switch_else_var->switch_br = switch_br; | 9337 | switch_else_var->switch_br = switch_br; |
| ... | @@ -8289,7 +9345,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8289,7 +9345,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8289 | peer_parent->peers.at(i)->base.source_instruction = peer_parent->base.source_instruction; | 9345 | peer_parent->peers.at(i)->base.source_instruction = peer_parent->base.source_instruction; |
| 8290 | } | 9346 | } |
| 8291 | | 9347 | |
| 8292 | if (!else_prong) { | 9348 | if (!else_prong && !underscore_prong) { |
| 8293 | if (peer_parent->peers.length != 0) { | 9349 | if (peer_parent->peers.length != 0) { |
| 8294 | peer_parent->peers.last()->next_bb = else_block; | 9350 | peer_parent->peers.last()->next_bb = else_block; |
| 8295 | } | 9351 | } |
| ... | @@ -8303,7 +9359,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8303,7 +9359,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8303 | | 9359 | |
| 8304 | ir_set_cursor_at_end_and_append_block(irb, end_block); | 9360 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 8305 | assert(incoming_blocks.length == incoming_values.length); | 9361 | assert(incoming_blocks.length == incoming_values.length); |
| 8306 | IrInstruction *result_instruction; | 9362 | IrInstSrc *result_instruction; |
| 8307 | if (incoming_blocks.length == 0) { | 9363 | if (incoming_blocks.length == 0) { |
| 8308 | result_instruction = ir_build_const_void(irb, scope, node); | 9364 | result_instruction = ir_build_const_void(irb, scope, node); |
| 8309 | } else { | 9365 | } else { |
| ... | @@ -8313,7 +9369,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8313,7 +9369,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8313 | return ir_lval_wrap(irb, scope, result_instruction, lval, result_loc); | 9369 | return ir_lval_wrap(irb, scope, result_instruction, lval, result_loc); |
| 8314 | } | 9370 | } |
| 8315 | | 9371 | |
| 8316 | static IrInstruction *ir_gen_comptime(IrBuilder *irb, Scope *parent_scope, AstNode *node, LVal lval) { | 9372 | static IrInstSrc *ir_gen_comptime(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node, LVal lval) { |
| 8317 | assert(node->type == NodeTypeCompTime); | 9373 | assert(node->type == NodeTypeCompTime); |
| 8318 | | 9374 | |
| 8319 | Scope *child_scope = create_comptime_scope(irb->codegen, node, parent_scope); | 9375 | Scope *child_scope = create_comptime_scope(irb->codegen, node, parent_scope); |
| ... | @@ -8321,28 +9377,28 @@ static IrInstruction *ir_gen_comptime(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -8321,28 +9377,28 @@ static IrInstruction *ir_gen_comptime(IrBuilder *irb, Scope *parent_scope, AstNo |
| 8321 | return ir_gen_node_extra(irb, node->data.comptime_expr.expr, child_scope, lval, nullptr); | 9377 | return ir_gen_node_extra(irb, node->data.comptime_expr.expr, child_scope, lval, nullptr); |
| 8322 | } | 9378 | } |
| 8323 | | 9379 | |
| 8324 | static IrInstruction *ir_gen_return_from_block(IrBuilder *irb, Scope *break_scope, AstNode *node, ScopeBlock *block_scope) { | 9380 | static IrInstSrc *ir_gen_return_from_block(IrBuilderSrc *irb, Scope *break_scope, AstNode *node, ScopeBlock *block_scope) { |
| 8325 | IrInstruction *is_comptime; | 9381 | IrInstSrc *is_comptime; |
| 8326 | if (ir_should_inline(irb->exec, break_scope)) { | 9382 | if (ir_should_inline(irb->exec, break_scope)) { |
| 8327 | is_comptime = ir_build_const_bool(irb, break_scope, node, true); | 9383 | is_comptime = ir_build_const_bool(irb, break_scope, node, true); |
| 8328 | } else { | 9384 | } else { |
| 8329 | is_comptime = block_scope->is_comptime; | 9385 | is_comptime = block_scope->is_comptime; |
| 8330 | } | 9386 | } |
| 8331 | | 9387 | |
| 8332 | IrInstruction *result_value; | 9388 | IrInstSrc *result_value; |
| 8333 | if (node->data.break_expr.expr) { | 9389 | if (node->data.break_expr.expr) { |
| 8334 | ResultLocPeer *peer_result = create_peer_result(block_scope->peer_parent); | 9390 | ResultLocPeer *peer_result = create_peer_result(block_scope->peer_parent); |
| 8335 | block_scope->peer_parent->peers.append(peer_result); | 9391 | block_scope->peer_parent->peers.append(peer_result); |
| 8336 | | 9392 | |
| 8337 | result_value = ir_gen_node_extra(irb, node->data.break_expr.expr, break_scope, block_scope->lval, | 9393 | result_value = ir_gen_node_extra(irb, node->data.break_expr.expr, break_scope, block_scope->lval, |
| 8338 | &peer_result->base); | 9394 | &peer_result->base); |
| 8339 | if (result_value == irb->codegen->invalid_instruction) | 9395 | if (result_value == irb->codegen->invalid_inst_src) |
| 8340 | return irb->codegen->invalid_instruction; | 9396 | return irb->codegen->invalid_inst_src; |
| 8341 | } else { | 9397 | } else { |
| 8342 | result_value = ir_build_const_void(irb, break_scope, node); | 9398 | result_value = ir_build_const_void(irb, break_scope, node); |
| 8343 | } | 9399 | } |
| 8344 | | 9400 | |
| 8345 | IrBasicBlock *dest_block = block_scope->end_block; | 9401 | IrBasicBlockSrc *dest_block = block_scope->end_block; |
| 8346 | ir_gen_defers_for_block(irb, break_scope, dest_block->scope, false); | 9402 | ir_gen_defers_for_block(irb, break_scope, dest_block->scope, false); |
| 8347 | | 9403 | |
| 8348 | block_scope->incoming_blocks->append(irb->current_basic_block); | 9404 | block_scope->incoming_blocks->append(irb->current_basic_block); |
| ... | @@ -8350,7 +9406,7 @@ static IrInstruction *ir_gen_return_from_block(IrBuilder *irb, Scope *break_scop | ... | @@ -8350,7 +9406,7 @@ static IrInstruction *ir_gen_return_from_block(IrBuilder *irb, Scope *break_scop |
| 8350 | return ir_build_br(irb, break_scope, node, dest_block, is_comptime); | 9406 | return ir_build_br(irb, break_scope, node, dest_block, is_comptime); |
| 8351 | } | 9407 | } |
| 8352 | | 9408 | |
| 8353 | static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *break_scope, AstNode *node) { | 9409 | static IrInstSrc *ir_gen_break(IrBuilderSrc *irb, Scope *break_scope, AstNode *node) { |
| 8354 | assert(node->type == NodeTypeBreak); | 9410 | assert(node->type == NodeTypeBreak); |
| 8355 | | 9411 | |
| 8356 | // Search up the scope. We'll find one of these things first: | 9412 | // Search up the scope. We'll find one of these things first: |
| ... | @@ -8365,14 +9421,14 @@ static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *break_scope, AstNode * | ... | @@ -8365,14 +9421,14 @@ static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *break_scope, AstNode * |
| 8365 | if (search_scope == nullptr || search_scope->id == ScopeIdFnDef) { | 9421 | if (search_scope == nullptr || search_scope->id == ScopeIdFnDef) { |
| 8366 | if (node->data.break_expr.name != nullptr) { | 9422 | if (node->data.break_expr.name != nullptr) { |
| 8367 | add_node_error(irb->codegen, node, buf_sprintf("label not found: '%s'", buf_ptr(node->data.break_expr.name))); | 9423 | add_node_error(irb->codegen, node, buf_sprintf("label not found: '%s'", buf_ptr(node->data.break_expr.name))); |
| 8368 | return irb->codegen->invalid_instruction; | 9424 | return irb->codegen->invalid_inst_src; |
| 8369 | } else { | 9425 | } else { |
| 8370 | add_node_error(irb->codegen, node, buf_sprintf("break expression outside loop")); | 9426 | add_node_error(irb->codegen, node, buf_sprintf("break expression outside loop")); |
| 8371 | return irb->codegen->invalid_instruction; | 9427 | return irb->codegen->invalid_inst_src; |
| 8372 | } | 9428 | } |
| 8373 | } else if (search_scope->id == ScopeIdDeferExpr) { | 9429 | } else if (search_scope->id == ScopeIdDeferExpr) { |
| 8374 | add_node_error(irb->codegen, node, buf_sprintf("cannot break out of defer expression")); | 9430 | add_node_error(irb->codegen, node, buf_sprintf("cannot break out of defer expression")); |
| 8375 | return irb->codegen->invalid_instruction; | 9431 | return irb->codegen->invalid_inst_src; |
| 8376 | } else if (search_scope->id == ScopeIdLoop) { | 9432 | } else if (search_scope->id == ScopeIdLoop) { |
| 8377 | ScopeLoop *this_loop_scope = (ScopeLoop *)search_scope; | 9433 | ScopeLoop *this_loop_scope = (ScopeLoop *)search_scope; |
| 8378 | if (node->data.break_expr.name == nullptr || | 9434 | if (node->data.break_expr.name == nullptr || |
| ... | @@ -8391,32 +9447,32 @@ static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *break_scope, AstNode * | ... | @@ -8391,32 +9447,32 @@ static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *break_scope, AstNode * |
| 8391 | } | 9447 | } |
| 8392 | } else if (search_scope->id == ScopeIdSuspend) { | 9448 | } else if (search_scope->id == ScopeIdSuspend) { |
| 8393 | add_node_error(irb->codegen, node, buf_sprintf("cannot break out of suspend block")); | 9449 | add_node_error(irb->codegen, node, buf_sprintf("cannot break out of suspend block")); |
| 8394 | return irb->codegen->invalid_instruction; | 9450 | return irb->codegen->invalid_inst_src; |
| 8395 | } | 9451 | } |
| 8396 | search_scope = search_scope->parent; | 9452 | search_scope = search_scope->parent; |
| 8397 | } | 9453 | } |
| 8398 | | 9454 | |
| 8399 | IrInstruction *is_comptime; | 9455 | IrInstSrc *is_comptime; |
| 8400 | if (ir_should_inline(irb->exec, break_scope)) { | 9456 | if (ir_should_inline(irb->exec, break_scope)) { |
| 8401 | is_comptime = ir_build_const_bool(irb, break_scope, node, true); | 9457 | is_comptime = ir_build_const_bool(irb, break_scope, node, true); |
| 8402 | } else { | 9458 | } else { |
| 8403 | is_comptime = loop_scope->is_comptime; | 9459 | is_comptime = loop_scope->is_comptime; |
| 8404 | } | 9460 | } |
| 8405 | | 9461 | |
| 8406 | IrInstruction *result_value; | 9462 | IrInstSrc *result_value; |
| 8407 | if (node->data.break_expr.expr) { | 9463 | if (node->data.break_expr.expr) { |
| 8408 | ResultLocPeer *peer_result = create_peer_result(loop_scope->peer_parent); | 9464 | ResultLocPeer *peer_result = create_peer_result(loop_scope->peer_parent); |
| 8409 | loop_scope->peer_parent->peers.append(peer_result); | 9465 | loop_scope->peer_parent->peers.append(peer_result); |
| 8410 | | 9466 | |
| 8411 | result_value = ir_gen_node_extra(irb, node->data.break_expr.expr, break_scope, | 9467 | result_value = ir_gen_node_extra(irb, node->data.break_expr.expr, break_scope, |
| 8412 | loop_scope->lval, &peer_result->base); | 9468 | loop_scope->lval, &peer_result->base); |
| 8413 | if (result_value == irb->codegen->invalid_instruction) | 9469 | if (result_value == irb->codegen->invalid_inst_src) |
| 8414 | return irb->codegen->invalid_instruction; | 9470 | return irb->codegen->invalid_inst_src; |
| 8415 | } else { | 9471 | } else { |
| 8416 | result_value = ir_build_const_void(irb, break_scope, node); | 9472 | result_value = ir_build_const_void(irb, break_scope, node); |
| 8417 | } | 9473 | } |
| 8418 | | 9474 | |
| 8419 | IrBasicBlock *dest_block = loop_scope->break_block; | 9475 | IrBasicBlockSrc *dest_block = loop_scope->break_block; |
| 8420 | ir_gen_defers_for_block(irb, break_scope, dest_block->scope, false); | 9476 | ir_gen_defers_for_block(irb, break_scope, dest_block->scope, false); |
| 8421 | | 9477 | |
| 8422 | loop_scope->incoming_blocks->append(irb->current_basic_block); | 9478 | loop_scope->incoming_blocks->append(irb->current_basic_block); |
| ... | @@ -8424,7 +9480,7 @@ static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *break_scope, AstNode * | ... | @@ -8424,7 +9480,7 @@ static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *break_scope, AstNode * |
| 8424 | return ir_build_br(irb, break_scope, node, dest_block, is_comptime); | 9480 | return ir_build_br(irb, break_scope, node, dest_block, is_comptime); |
| 8425 | } | 9481 | } |
| 8426 | | 9482 | |
| 8427 | static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *continue_scope, AstNode *node) { | 9483 | static IrInstSrc *ir_gen_continue(IrBuilderSrc *irb, Scope *continue_scope, AstNode *node) { |
| 8428 | assert(node->type == NodeTypeContinue); | 9484 | assert(node->type == NodeTypeContinue); |
| 8429 | | 9485 | |
| 8430 | // Search up the scope. We'll find one of these things first: | 9486 | // Search up the scope. We'll find one of these things first: |
| ... | @@ -8440,14 +9496,14 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *continue_scope, Ast | ... | @@ -8440,14 +9496,14 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *continue_scope, Ast |
| 8440 | if (search_scope == nullptr || search_scope->id == ScopeIdFnDef) { | 9496 | if (search_scope == nullptr || search_scope->id == ScopeIdFnDef) { |
| 8441 | if (node->data.continue_expr.name != nullptr) { | 9497 | if (node->data.continue_expr.name != nullptr) { |
| 8442 | add_node_error(irb->codegen, node, buf_sprintf("labeled loop not found: '%s'", buf_ptr(node->data.continue_expr.name))); | 9498 | add_node_error(irb->codegen, node, buf_sprintf("labeled loop not found: '%s'", buf_ptr(node->data.continue_expr.name))); |
| 8443 | return irb->codegen->invalid_instruction; | 9499 | return irb->codegen->invalid_inst_src; |
| 8444 | } else { | 9500 | } else { |
| 8445 | add_node_error(irb->codegen, node, buf_sprintf("continue expression outside loop")); | 9501 | add_node_error(irb->codegen, node, buf_sprintf("continue expression outside loop")); |
| 8446 | return irb->codegen->invalid_instruction; | 9502 | return irb->codegen->invalid_inst_src; |
| 8447 | } | 9503 | } |
| 8448 | } else if (search_scope->id == ScopeIdDeferExpr) { | 9504 | } else if (search_scope->id == ScopeIdDeferExpr) { |
| 8449 | add_node_error(irb->codegen, node, buf_sprintf("cannot continue out of defer expression")); | 9505 | add_node_error(irb->codegen, node, buf_sprintf("cannot continue out of defer expression")); |
| 8450 | return irb->codegen->invalid_instruction; | 9506 | return irb->codegen->invalid_inst_src; |
| 8451 | } else if (search_scope->id == ScopeIdLoop) { | 9507 | } else if (search_scope->id == ScopeIdLoop) { |
| 8452 | ScopeLoop *this_loop_scope = (ScopeLoop *)search_scope; | 9508 | ScopeLoop *this_loop_scope = (ScopeLoop *)search_scope; |
| 8453 | if (node->data.continue_expr.name == nullptr || | 9509 | if (node->data.continue_expr.name == nullptr || |
| ... | @@ -8463,7 +9519,7 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *continue_scope, Ast | ... | @@ -8463,7 +9519,7 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *continue_scope, Ast |
| 8463 | search_scope = search_scope->parent; | 9519 | search_scope = search_scope->parent; |
| 8464 | } | 9520 | } |
| 8465 | | 9521 | |
| 8466 | IrInstruction *is_comptime; | 9522 | IrInstSrc *is_comptime; |
| 8467 | if (ir_should_inline(irb->exec, continue_scope)) { | 9523 | if (ir_should_inline(irb->exec, continue_scope)) { |
| 8468 | is_comptime = ir_build_const_bool(irb, continue_scope, node, true); | 9524 | is_comptime = ir_build_const_bool(irb, continue_scope, node, true); |
| 8469 | } else { | 9525 | } else { |
| ... | @@ -8475,17 +9531,17 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *continue_scope, Ast | ... | @@ -8475,17 +9531,17 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *continue_scope, Ast |
| 8475 | ir_mark_gen(ir_build_check_runtime_scope(irb, continue_scope, node, scope_runtime->is_comptime, is_comptime)); | 9531 | ir_mark_gen(ir_build_check_runtime_scope(irb, continue_scope, node, scope_runtime->is_comptime, is_comptime)); |
| 8476 | } | 9532 | } |
| 8477 | | 9533 | |
| 8478 | IrBasicBlock *dest_block = loop_scope->continue_block; | 9534 | IrBasicBlockSrc *dest_block = loop_scope->continue_block; |
| 8479 | ir_gen_defers_for_block(irb, continue_scope, dest_block->scope, false); | 9535 | ir_gen_defers_for_block(irb, continue_scope, dest_block->scope, false); |
| 8480 | return ir_mark_gen(ir_build_br(irb, continue_scope, node, dest_block, is_comptime)); | 9536 | return ir_mark_gen(ir_build_br(irb, continue_scope, node, dest_block, is_comptime)); |
| 8481 | } | 9537 | } |
| 8482 | | 9538 | |
| 8483 | static IrInstruction *ir_gen_error_type(IrBuilder *irb, Scope *scope, AstNode *node) { | 9539 | static IrInstSrc *ir_gen_error_type(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 8484 | assert(node->type == NodeTypeErrorType); | 9540 | assert(node->type == NodeTypeErrorType); |
| 8485 | return ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_global_error_set); | 9541 | return ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_global_error_set); |
| 8486 | } | 9542 | } |
| 8487 | | 9543 | |
| 8488 | static IrInstruction *ir_gen_defer(IrBuilder *irb, Scope *parent_scope, AstNode *node) { | 9544 | static IrInstSrc *ir_gen_defer(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node) { |
| 8489 | assert(node->type == NodeTypeDefer); | 9545 | assert(node->type == NodeTypeDefer); |
| 8490 | | 9546 | |
| 8491 | ScopeDefer *defer_child_scope = create_defer_scope(irb->codegen, node, parent_scope); | 9547 | ScopeDefer *defer_child_scope = create_defer_scope(irb->codegen, node, parent_scope); |
| ... | @@ -8497,7 +9553,7 @@ static IrInstruction *ir_gen_defer(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -8497,7 +9553,7 @@ static IrInstruction *ir_gen_defer(IrBuilder *irb, Scope *parent_scope, AstNode |
| 8497 | return ir_build_const_void(irb, parent_scope, node); | 9553 | return ir_build_const_void(irb, parent_scope, node); |
| 8498 | } | 9554 | } |
| 8499 | | 9555 | |
| 8500 | static IrInstruction *ir_gen_slice(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { | 9556 | static IrInstSrc *ir_gen_slice(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { |
| 8501 | assert(node->type == NodeTypeSliceExpr); | 9557 | assert(node->type == NodeTypeSliceExpr); |
| 8502 | | 9558 | |
| 8503 | AstNodeSliceExpr *slice_expr = &node->data.slice_expr; | 9559 | AstNodeSliceExpr *slice_expr = &node->data.slice_expr; |
| ... | @@ -8506,38 +9562,38 @@ static IrInstruction *ir_gen_slice(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -8506,38 +9562,38 @@ static IrInstruction *ir_gen_slice(IrBuilder *irb, Scope *scope, AstNode *node, |
| 8506 | AstNode *end_node = slice_expr->end; | 9562 | AstNode *end_node = slice_expr->end; |
| 8507 | AstNode *sentinel_node = slice_expr->sentinel; | 9563 | AstNode *sentinel_node = slice_expr->sentinel; |
| 8508 | | 9564 | |
| 8509 | IrInstruction *ptr_value = ir_gen_node_extra(irb, array_node, scope, LValPtr, nullptr); | 9565 | IrInstSrc *ptr_value = ir_gen_node_extra(irb, array_node, scope, LValPtr, nullptr); |
| 8510 | if (ptr_value == irb->codegen->invalid_instruction) | 9566 | if (ptr_value == irb->codegen->invalid_inst_src) |
| 8511 | return irb->codegen->invalid_instruction; | 9567 | return irb->codegen->invalid_inst_src; |
| 8512 | | 9568 | |
| 8513 | IrInstruction *start_value = ir_gen_node(irb, start_node, scope); | 9569 | IrInstSrc *start_value = ir_gen_node(irb, start_node, scope); |
| 8514 | if (start_value == irb->codegen->invalid_instruction) | 9570 | if (start_value == irb->codegen->invalid_inst_src) |
| 8515 | return irb->codegen->invalid_instruction; | 9571 | return irb->codegen->invalid_inst_src; |
| 8516 | | 9572 | |
| 8517 | IrInstruction *end_value; | 9573 | IrInstSrc *end_value; |
| 8518 | if (end_node) { | 9574 | if (end_node) { |
| 8519 | end_value = ir_gen_node(irb, end_node, scope); | 9575 | end_value = ir_gen_node(irb, end_node, scope); |
| 8520 | if (end_value == irb->codegen->invalid_instruction) | 9576 | if (end_value == irb->codegen->invalid_inst_src) |
| 8521 | return irb->codegen->invalid_instruction; | 9577 | return irb->codegen->invalid_inst_src; |
| 8522 | } else { | 9578 | } else { |
| 8523 | end_value = nullptr; | 9579 | end_value = nullptr; |
| 8524 | } | 9580 | } |
| 8525 | | 9581 | |
| 8526 | IrInstruction *sentinel_value; | 9582 | IrInstSrc *sentinel_value; |
| 8527 | if (sentinel_node) { | 9583 | if (sentinel_node) { |
| 8528 | sentinel_value = ir_gen_node(irb, sentinel_node, scope); | 9584 | sentinel_value = ir_gen_node(irb, sentinel_node, scope); |
| 8529 | if (sentinel_value == irb->codegen->invalid_instruction) | 9585 | if (sentinel_value == irb->codegen->invalid_inst_src) |
| 8530 | return irb->codegen->invalid_instruction; | 9586 | return irb->codegen->invalid_inst_src; |
| 8531 | } else { | 9587 | } else { |
| 8532 | sentinel_value = nullptr; | 9588 | sentinel_value = nullptr; |
| 8533 | } | 9589 | } |
| 8534 | | 9590 | |
| 8535 | IrInstruction *slice = ir_build_slice_src(irb, scope, node, ptr_value, start_value, end_value, | 9591 | IrInstSrc *slice = ir_build_slice_src(irb, scope, node, ptr_value, start_value, end_value, |
| 8536 | sentinel_value, true, result_loc); | 9592 | sentinel_value, true, result_loc); |
| 8537 | return ir_lval_wrap(irb, scope, slice, lval, result_loc); | 9593 | return ir_lval_wrap(irb, scope, slice, lval, result_loc); |
| 8538 | } | 9594 | } |
| 8539 | | 9595 | |
| 8540 | static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode *node, LVal lval, | 9596 | static IrInstSrc *ir_gen_catch(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node, LVal lval, |
| 8541 | ResultLoc *result_loc) | 9597 | ResultLoc *result_loc) |
| 8542 | { | 9598 | { |
| 8543 | assert(node->type == NodeTypeCatchExpr); | 9599 | assert(node->type == NodeTypeCatchExpr); |
| ... | @@ -8551,29 +9607,29 @@ static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -8551,29 +9607,29 @@ static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode |
| 8551 | assert(var_node->type == NodeTypeSymbol); | 9607 | assert(var_node->type == NodeTypeSymbol); |
| 8552 | Buf *var_name = var_node->data.symbol_expr.symbol; | 9608 | Buf *var_name = var_node->data.symbol_expr.symbol; |
| 8553 | add_node_error(irb->codegen, var_node, buf_sprintf("unused variable: '%s'", buf_ptr(var_name))); | 9609 | add_node_error(irb->codegen, var_node, buf_sprintf("unused variable: '%s'", buf_ptr(var_name))); |
| 8554 | return irb->codegen->invalid_instruction; | 9610 | return irb->codegen->invalid_inst_src; |
| 8555 | } | 9611 | } |
| 8556 | return ir_gen_catch_unreachable(irb, parent_scope, node, op1_node, lval, result_loc); | 9612 | return ir_gen_catch_unreachable(irb, parent_scope, node, op1_node, lval, result_loc); |
| 8557 | } | 9613 | } |
| 8558 | | 9614 | |
| 8559 | | 9615 | |
| 8560 | IrInstruction *err_union_ptr = ir_gen_node_extra(irb, op1_node, parent_scope, LValPtr, nullptr); | 9616 | IrInstSrc *err_union_ptr = ir_gen_node_extra(irb, op1_node, parent_scope, LValPtr, nullptr); |
| 8561 | if (err_union_ptr == irb->codegen->invalid_instruction) | 9617 | if (err_union_ptr == irb->codegen->invalid_inst_src) |
| 8562 | return irb->codegen->invalid_instruction; | 9618 | return irb->codegen->invalid_inst_src; |
| 8563 | | 9619 | |
| 8564 | IrInstruction *is_err = ir_build_test_err_src(irb, parent_scope, node, err_union_ptr, true, false); | 9620 | IrInstSrc *is_err = ir_build_test_err_src(irb, parent_scope, node, err_union_ptr, true, false); |
| 8565 | | 9621 | |
| 8566 | IrInstruction *is_comptime; | 9622 | IrInstSrc *is_comptime; |
| 8567 | if (ir_should_inline(irb->exec, parent_scope)) { | 9623 | if (ir_should_inline(irb->exec, parent_scope)) { |
| 8568 | is_comptime = ir_build_const_bool(irb, parent_scope, node, true); | 9624 | is_comptime = ir_build_const_bool(irb, parent_scope, node, true); |
| 8569 | } else { | 9625 | } else { |
| 8570 | is_comptime = ir_build_test_comptime(irb, parent_scope, node, is_err); | 9626 | is_comptime = ir_build_test_comptime(irb, parent_scope, node, is_err); |
| 8571 | } | 9627 | } |
| 8572 | | 9628 | |
| 8573 | IrBasicBlock *ok_block = ir_create_basic_block(irb, parent_scope, "UnwrapErrOk"); | 9629 | IrBasicBlockSrc *ok_block = ir_create_basic_block(irb, parent_scope, "UnwrapErrOk"); |
| 8574 | IrBasicBlock *err_block = ir_create_basic_block(irb, parent_scope, "UnwrapErrError"); | 9630 | IrBasicBlockSrc *err_block = ir_create_basic_block(irb, parent_scope, "UnwrapErrError"); |
| 8575 | IrBasicBlock *end_block = ir_create_basic_block(irb, parent_scope, "UnwrapErrEnd"); | 9631 | IrBasicBlockSrc *end_block = ir_create_basic_block(irb, parent_scope, "UnwrapErrEnd"); |
| 8576 | IrInstruction *cond_br_inst = ir_build_cond_br(irb, parent_scope, node, is_err, err_block, ok_block, is_comptime); | 9632 | IrInstSrc *cond_br_inst = ir_build_cond_br(irb, parent_scope, node, is_err, err_block, ok_block, is_comptime); |
| 8577 | | 9633 | |
| 8578 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, ok_block, end_block, result_loc, | 9634 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, ok_block, end_block, result_loc, |
| 8579 | is_comptime); | 9635 | is_comptime); |
| ... | @@ -8589,33 +9645,33 @@ static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -8589,33 +9645,33 @@ static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode |
| 8589 | ZigVar *var = ir_create_var(irb, node, subexpr_scope, var_name, | 9645 | ZigVar *var = ir_create_var(irb, node, subexpr_scope, var_name, |
| 8590 | is_const, is_const, is_shadowable, is_comptime); | 9646 | is_const, is_const, is_shadowable, is_comptime); |
| 8591 | err_scope = var->child_scope; | 9647 | err_scope = var->child_scope; |
| 8592 | IrInstruction *err_ptr = ir_build_unwrap_err_code(irb, err_scope, node, err_union_ptr); | 9648 | IrInstSrc *err_ptr = ir_build_unwrap_err_code_src(irb, err_scope, node, err_union_ptr); |
| 8593 | ir_build_var_decl_src(irb, err_scope, var_node, var, nullptr, err_ptr); | 9649 | ir_build_var_decl_src(irb, err_scope, var_node, var, nullptr, err_ptr); |
| 8594 | } else { | 9650 | } else { |
| 8595 | err_scope = subexpr_scope; | 9651 | err_scope = subexpr_scope; |
| 8596 | } | 9652 | } |
| 8597 | IrInstruction *err_result = ir_gen_node_extra(irb, op2_node, err_scope, LValNone, &peer_parent->peers.at(0)->base); | 9653 | IrInstSrc *err_result = ir_gen_node_extra(irb, op2_node, err_scope, LValNone, &peer_parent->peers.at(0)->base); |
| 8598 | if (err_result == irb->codegen->invalid_instruction) | 9654 | if (err_result == irb->codegen->invalid_inst_src) |
| 8599 | return irb->codegen->invalid_instruction; | 9655 | return irb->codegen->invalid_inst_src; |
| 8600 | IrBasicBlock *after_err_block = irb->current_basic_block; | 9656 | IrBasicBlockSrc *after_err_block = irb->current_basic_block; |
| 8601 | if (!instr_is_unreachable(err_result)) | 9657 | if (!instr_is_unreachable(err_result)) |
| 8602 | ir_mark_gen(ir_build_br(irb, parent_scope, node, end_block, is_comptime)); | 9658 | ir_mark_gen(ir_build_br(irb, parent_scope, node, end_block, is_comptime)); |
| 8603 | | 9659 | |
| 8604 | ir_set_cursor_at_end_and_append_block(irb, ok_block); | 9660 | ir_set_cursor_at_end_and_append_block(irb, ok_block); |
| 8605 | IrInstruction *unwrapped_ptr = ir_build_unwrap_err_payload(irb, parent_scope, node, err_union_ptr, false, false); | 9661 | IrInstSrc *unwrapped_ptr = ir_build_unwrap_err_payload_src(irb, parent_scope, node, err_union_ptr, false, false); |
| 8606 | IrInstruction *unwrapped_payload = ir_build_load_ptr(irb, parent_scope, node, unwrapped_ptr); | 9662 | IrInstSrc *unwrapped_payload = ir_build_load_ptr(irb, parent_scope, node, unwrapped_ptr); |
| 8607 | ir_build_end_expr(irb, parent_scope, node, unwrapped_payload, &peer_parent->peers.at(1)->base); | 9663 | ir_build_end_expr(irb, parent_scope, node, unwrapped_payload, &peer_parent->peers.at(1)->base); |
| 8608 | IrBasicBlock *after_ok_block = irb->current_basic_block; | 9664 | IrBasicBlockSrc *after_ok_block = irb->current_basic_block; |
| 8609 | ir_build_br(irb, parent_scope, node, end_block, is_comptime); | 9665 | ir_build_br(irb, parent_scope, node, end_block, is_comptime); |
| 8610 | | 9666 | |
| 8611 | ir_set_cursor_at_end_and_append_block(irb, end_block); | 9667 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 8612 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 9668 | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 8613 | incoming_values[0] = err_result; | 9669 | incoming_values[0] = err_result; |
| 8614 | incoming_values[1] = unwrapped_payload; | 9670 | incoming_values[1] = unwrapped_payload; |
| 8615 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); | 9671 | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 8616 | incoming_blocks[0] = after_err_block; | 9672 | incoming_blocks[0] = after_err_block; |
| 8617 | incoming_blocks[1] = after_ok_block; | 9673 | incoming_blocks[1] = after_ok_block; |
| 8618 | IrInstruction *phi = ir_build_phi(irb, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); | 9674 | IrInstSrc *phi = ir_build_phi(irb, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); |
| 8619 | return ir_lval_wrap(irb, parent_scope, phi, lval, result_loc); | 9675 | return ir_lval_wrap(irb, parent_scope, phi, lval, result_loc); |
| 8620 | } | 9676 | } |
| 8621 | | 9677 | |
| ... | @@ -8633,7 +9689,7 @@ static bool render_instance_name_recursive(CodeGen *codegen, Buf *name, Scope *o | ... | @@ -8633,7 +9689,7 @@ static bool render_instance_name_recursive(CodeGen *codegen, Buf *name, Scope *o |
| 8633 | return true; | 9689 | return true; |
| 8634 | } | 9690 | } |
| 8635 | | 9691 | |
| 8636 | static Buf *get_anon_type_name(CodeGen *codegen, IrExecutable *exec, const char *kind_name, | 9692 | static Buf *get_anon_type_name(CodeGen *codegen, IrExecutableSrc *exec, const char *kind_name, |
| 8637 | Scope *scope, AstNode *source_node, Buf *out_bare_name) | 9693 | Scope *scope, AstNode *source_node, Buf *out_bare_name) |
| 8638 | { | 9694 | { |
| 8639 | if (exec != nullptr && exec->name) { | 9695 | if (exec != nullptr && exec->name) { |
| ... | @@ -8662,7 +9718,7 @@ static Buf *get_anon_type_name(CodeGen *codegen, IrExecutable *exec, const char | ... | @@ -8662,7 +9718,7 @@ static Buf *get_anon_type_name(CodeGen *codegen, IrExecutable *exec, const char |
| 8662 | } | 9718 | } |
| 8663 | } | 9719 | } |
| 8664 | | 9720 | |
| 8665 | static IrInstruction *ir_gen_container_decl(IrBuilder *irb, Scope *parent_scope, AstNode *node) { | 9721 | static IrInstSrc *ir_gen_container_decl(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node) { |
| 8666 | assert(node->type == NodeTypeContainerDecl); | 9722 | assert(node->type == NodeTypeContainerDecl); |
| 8667 | | 9723 | |
| 8668 | ContainerKind kind = node->data.container_decl.kind; | 9724 | ContainerKind kind = node->data.container_decl.kind; |
| ... | @@ -8787,7 +9843,7 @@ static AstNode *ast_field_to_symbol_node(AstNode *err_set_field_node) { | ... | @@ -8787,7 +9843,7 @@ static AstNode *ast_field_to_symbol_node(AstNode *err_set_field_node) { |
| 8787 | } | 9843 | } |
| 8788 | } | 9844 | } |
| 8789 | | 9845 | |
| 8790 | static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, AstNode *node) { | 9846 | static IrInstSrc *ir_gen_err_set_decl(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node) { |
| 8791 | assert(node->type == NodeTypeErrorSetDecl); | 9847 | assert(node->type == NodeTypeErrorSetDecl); |
| 8792 | | 9848 | |
| 8793 | uint32_t err_count = node->data.err_set_decl.decls.length; | 9849 | uint32_t err_count = node->data.err_set_decl.decls.length; |
| ... | @@ -8830,7 +9886,7 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A | ... | @@ -8830,7 +9886,7 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A |
| 8830 | buf_sprintf("duplicate error: '%s'", buf_ptr(&err->name))); | 9886 | buf_sprintf("duplicate error: '%s'", buf_ptr(&err->name))); |
| 8831 | add_error_note(irb->codegen, msg, ast_field_to_symbol_node(prev_err->decl_node), | 9887 | add_error_note(irb->codegen, msg, ast_field_to_symbol_node(prev_err->decl_node), |
| 8832 | buf_sprintf("other error here")); | 9888 | buf_sprintf("other error here")); |
| 8833 | return irb->codegen->invalid_instruction; | 9889 | return irb->codegen->invalid_inst_src; |
| 8834 | } | 9890 | } |
| 8835 | errors[err->value] = err; | 9891 | errors[err->value] = err; |
| 8836 | } | 9892 | } |
| ... | @@ -8838,11 +9894,11 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A | ... | @@ -8838,11 +9894,11 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A |
| 8838 | return ir_build_const_type(irb, parent_scope, node, err_set_type); | 9894 | return ir_build_const_type(irb, parent_scope, node, err_set_type); |
| 8839 | } | 9895 | } |
| 8840 | | 9896 | |
| 8841 | static IrInstruction *ir_gen_fn_proto(IrBuilder *irb, Scope *parent_scope, AstNode *node) { | 9897 | static IrInstSrc *ir_gen_fn_proto(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node) { |
| 8842 | assert(node->type == NodeTypeFnProto); | 9898 | assert(node->type == NodeTypeFnProto); |
| 8843 | | 9899 | |
| 8844 | size_t param_count = node->data.fn_proto.params.length; | 9900 | size_t param_count = node->data.fn_proto.params.length; |
| 8845 | IrInstruction **param_types = allocate<IrInstruction*>(param_count); | 9901 | IrInstSrc **param_types = allocate<IrInstSrc*>(param_count); |
| 8846 | | 9902 | |
| 8847 | bool is_var_args = false; | 9903 | bool is_var_args = false; |
| 8848 | for (size_t i = 0; i < param_count; i += 1) { | 9904 | for (size_t i = 0; i < param_count; i += 1) { |
| ... | @@ -8853,59 +9909,59 @@ static IrInstruction *ir_gen_fn_proto(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -8853,59 +9909,59 @@ static IrInstruction *ir_gen_fn_proto(IrBuilder *irb, Scope *parent_scope, AstNo |
| 8853 | } | 9909 | } |
| 8854 | if (param_node->data.param_decl.var_token == nullptr) { | 9910 | if (param_node->data.param_decl.var_token == nullptr) { |
| 8855 | AstNode *type_node = param_node->data.param_decl.type; | 9911 | AstNode *type_node = param_node->data.param_decl.type; |
| 8856 | IrInstruction *type_value = ir_gen_node(irb, type_node, parent_scope); | 9912 | IrInstSrc *type_value = ir_gen_node(irb, type_node, parent_scope); |
| 8857 | if (type_value == irb->codegen->invalid_instruction) | 9913 | if (type_value == irb->codegen->invalid_inst_src) |
| 8858 | return irb->codegen->invalid_instruction; | 9914 | return irb->codegen->invalid_inst_src; |
| 8859 | param_types[i] = type_value; | 9915 | param_types[i] = type_value; |
| 8860 | } else { | 9916 | } else { |
| 8861 | param_types[i] = nullptr; | 9917 | param_types[i] = nullptr; |
| 8862 | } | 9918 | } |
| 8863 | } | 9919 | } |
| 8864 | | 9920 | |
| 8865 | IrInstruction *align_value = nullptr; | 9921 | IrInstSrc *align_value = nullptr; |
| 8866 | if (node->data.fn_proto.align_expr != nullptr) { | 9922 | if (node->data.fn_proto.align_expr != nullptr) { |
| 8867 | align_value = ir_gen_node(irb, node->data.fn_proto.align_expr, parent_scope); | 9923 | align_value = ir_gen_node(irb, node->data.fn_proto.align_expr, parent_scope); |
| 8868 | if (align_value == irb->codegen->invalid_instruction) | 9924 | if (align_value == irb->codegen->invalid_inst_src) |
| 8869 | return irb->codegen->invalid_instruction; | 9925 | return irb->codegen->invalid_inst_src; |
| 8870 | } | 9926 | } |
| 8871 | | 9927 | |
| 8872 | IrInstruction *callconv_value = nullptr; | 9928 | IrInstSrc *callconv_value = nullptr; |
| 8873 | if (node->data.fn_proto.callconv_expr != nullptr) { | 9929 | if (node->data.fn_proto.callconv_expr != nullptr) { |
| 8874 | callconv_value = ir_gen_node(irb, node->data.fn_proto.callconv_expr, parent_scope); | 9930 | callconv_value = ir_gen_node(irb, node->data.fn_proto.callconv_expr, parent_scope); |
| 8875 | if (callconv_value == irb->codegen->invalid_instruction) | 9931 | if (callconv_value == irb->codegen->invalid_inst_src) |
| 8876 | return irb->codegen->invalid_instruction; | 9932 | return irb->codegen->invalid_inst_src; |
| 8877 | } | 9933 | } |
| 8878 | | 9934 | |
| 8879 | IrInstruction *return_type; | 9935 | IrInstSrc *return_type; |
| 8880 | if (node->data.fn_proto.return_var_token == nullptr) { | 9936 | if (node->data.fn_proto.return_var_token == nullptr) { |
| 8881 | if (node->data.fn_proto.return_type == nullptr) { | 9937 | if (node->data.fn_proto.return_type == nullptr) { |
| 8882 | return_type = ir_build_const_type(irb, parent_scope, node, irb->codegen->builtin_types.entry_void); | 9938 | return_type = ir_build_const_type(irb, parent_scope, node, irb->codegen->builtin_types.entry_void); |
| 8883 | } else { | 9939 | } else { |
| 8884 | return_type = ir_gen_node(irb, node->data.fn_proto.return_type, parent_scope); | 9940 | return_type = ir_gen_node(irb, node->data.fn_proto.return_type, parent_scope); |
| 8885 | if (return_type == irb->codegen->invalid_instruction) | 9941 | if (return_type == irb->codegen->invalid_inst_src) |
| 8886 | return irb->codegen->invalid_instruction; | 9942 | return irb->codegen->invalid_inst_src; |
| 8887 | } | 9943 | } |
| 8888 | } else { | 9944 | } else { |
| 8889 | add_node_error(irb->codegen, node, | 9945 | add_node_error(irb->codegen, node, |
| 8890 | buf_sprintf("TODO implement inferred return types https://github.com/ziglang/zig/issues/447")); | 9946 | buf_sprintf("TODO implement inferred return types https://github.com/ziglang/zig/issues/447")); |
| 8891 | return irb->codegen->invalid_instruction; | 9947 | return irb->codegen->invalid_inst_src; |
| 8892 | //return_type = nullptr; | 9948 | //return_type = nullptr; |
| 8893 | } | 9949 | } |
| 8894 | | 9950 | |
| 8895 | return ir_build_fn_proto(irb, parent_scope, node, param_types, align_value, callconv_value, return_type, is_var_args); | 9951 | return ir_build_fn_proto(irb, parent_scope, node, param_types, align_value, callconv_value, return_type, is_var_args); |
| 8896 | } | 9952 | } |
| 8897 | | 9953 | |
| 8898 | static IrInstruction *ir_gen_resume(IrBuilder *irb, Scope *scope, AstNode *node) { | 9954 | static IrInstSrc *ir_gen_resume(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 8899 | assert(node->type == NodeTypeResume); | 9955 | assert(node->type == NodeTypeResume); |
| 8900 | | 9956 | |
| 8901 | IrInstruction *target_inst = ir_gen_node_extra(irb, node->data.resume_expr.expr, scope, LValPtr, nullptr); | 9957 | IrInstSrc *target_inst = ir_gen_node_extra(irb, node->data.resume_expr.expr, scope, LValPtr, nullptr); |
| 8902 | if (target_inst == irb->codegen->invalid_instruction) | 9958 | if (target_inst == irb->codegen->invalid_inst_src) |
| 8903 | return irb->codegen->invalid_instruction; | 9959 | return irb->codegen->invalid_inst_src; |
| 8904 | | 9960 | |
| 8905 | return ir_build_resume(irb, scope, node, target_inst); | 9961 | return ir_build_resume_src(irb, scope, node, target_inst); |
| 8906 | } | 9962 | } |
| 8907 | | 9963 | |
| 8908 | static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 9964 | static IrInstSrc *ir_gen_await_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 8909 | ResultLoc *result_loc) | 9965 | ResultLoc *result_loc) |
| 8910 | { | 9966 | { |
| 8911 | assert(node->type == NodeTypeAwaitExpr); | 9967 | assert(node->type == NodeTypeAwaitExpr); |
| ... | @@ -8926,7 +9982,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -8926,7 +9982,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 8926 | ZigFn *fn_entry = exec_fn_entry(irb->exec); | 9982 | ZigFn *fn_entry = exec_fn_entry(irb->exec); |
| 8927 | if (!fn_entry) { | 9983 | if (!fn_entry) { |
| 8928 | add_node_error(irb->codegen, node, buf_sprintf("await outside function definition")); | 9984 | add_node_error(irb->codegen, node, buf_sprintf("await outside function definition")); |
| 8929 | return irb->codegen->invalid_instruction; | 9985 | return irb->codegen->invalid_inst_src; |
| 8930 | } | 9986 | } |
| 8931 | ScopeSuspend *existing_suspend_scope = get_scope_suspend(scope); | 9987 | ScopeSuspend *existing_suspend_scope = get_scope_suspend(scope); |
| 8932 | if (existing_suspend_scope) { | 9988 | if (existing_suspend_scope) { |
| ... | @@ -8935,24 +9991,24 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -8935,24 +9991,24 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 8935 | add_error_note(irb->codegen, msg, existing_suspend_scope->base.source_node, buf_sprintf("suspend block here")); | 9991 | add_error_note(irb->codegen, msg, existing_suspend_scope->base.source_node, buf_sprintf("suspend block here")); |
| 8936 | existing_suspend_scope->reported_err = true; | 9992 | existing_suspend_scope->reported_err = true; |
| 8937 | } | 9993 | } |
| 8938 | return irb->codegen->invalid_instruction; | 9994 | return irb->codegen->invalid_inst_src; |
| 8939 | } | 9995 | } |
| 8940 | | 9996 | |
| 8941 | IrInstruction *target_inst = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); | 9997 | IrInstSrc *target_inst = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); |
| 8942 | if (target_inst == irb->codegen->invalid_instruction) | 9998 | if (target_inst == irb->codegen->invalid_inst_src) |
| 8943 | return irb->codegen->invalid_instruction; | 9999 | return irb->codegen->invalid_inst_src; |
| 8944 | | 10000 | |
| 8945 | IrInstruction *await_inst = ir_build_await_src(irb, scope, node, target_inst, result_loc); | 10001 | IrInstSrc *await_inst = ir_build_await_src(irb, scope, node, target_inst, result_loc); |
| 8946 | return ir_lval_wrap(irb, scope, await_inst, lval, result_loc); | 10002 | return ir_lval_wrap(irb, scope, await_inst, lval, result_loc); |
| 8947 | } | 10003 | } |
| 8948 | | 10004 | |
| 8949 | static IrInstruction *ir_gen_suspend(IrBuilder *irb, Scope *parent_scope, AstNode *node) { | 10005 | static IrInstSrc *ir_gen_suspend(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node) { |
| 8950 | assert(node->type == NodeTypeSuspend); | 10006 | assert(node->type == NodeTypeSuspend); |
| 8951 | | 10007 | |
| 8952 | ZigFn *fn_entry = exec_fn_entry(irb->exec); | 10008 | ZigFn *fn_entry = exec_fn_entry(irb->exec); |
| 8953 | if (!fn_entry) { | 10009 | if (!fn_entry) { |
| 8954 | add_node_error(irb->codegen, node, buf_sprintf("suspend outside function definition")); | 10010 | add_node_error(irb->codegen, node, buf_sprintf("suspend outside function definition")); |
| 8955 | return irb->codegen->invalid_instruction; | 10011 | return irb->codegen->invalid_inst_src; |
| 8956 | } | 10012 | } |
| 8957 | ScopeSuspend *existing_suspend_scope = get_scope_suspend(parent_scope); | 10013 | ScopeSuspend *existing_suspend_scope = get_scope_suspend(parent_scope); |
| 8958 | if (existing_suspend_scope) { | 10014 | if (existing_suspend_scope) { |
| ... | @@ -8961,21 +10017,21 @@ static IrInstruction *ir_gen_suspend(IrBuilder *irb, Scope *parent_scope, AstNod | ... | @@ -8961,21 +10017,21 @@ static IrInstruction *ir_gen_suspend(IrBuilder *irb, Scope *parent_scope, AstNod |
| 8961 | add_error_note(irb->codegen, msg, existing_suspend_scope->base.source_node, buf_sprintf("other suspend block here")); | 10017 | add_error_note(irb->codegen, msg, existing_suspend_scope->base.source_node, buf_sprintf("other suspend block here")); |
| 8962 | existing_suspend_scope->reported_err = true; | 10018 | existing_suspend_scope->reported_err = true; |
| 8963 | } | 10019 | } |
| 8964 | return irb->codegen->invalid_instruction; | 10020 | return irb->codegen->invalid_inst_src; |
| 8965 | } | 10021 | } |
| 8966 | | 10022 | |
| 8967 | IrInstructionSuspendBegin *begin = ir_build_suspend_begin(irb, parent_scope, node); | 10023 | IrInstSrcSuspendBegin *begin = ir_build_suspend_begin_src(irb, parent_scope, node); |
| 8968 | if (node->data.suspend.block != nullptr) { | 10024 | if (node->data.suspend.block != nullptr) { |
| 8969 | ScopeSuspend *suspend_scope = create_suspend_scope(irb->codegen, node, parent_scope); | 10025 | ScopeSuspend *suspend_scope = create_suspend_scope(irb->codegen, node, parent_scope); |
| 8970 | Scope *child_scope = &suspend_scope->base; | 10026 | Scope *child_scope = &suspend_scope->base; |
| 8971 | IrInstruction *susp_res = ir_gen_node(irb, node->data.suspend.block, child_scope); | 10027 | IrInstSrc *susp_res = ir_gen_node(irb, node->data.suspend.block, child_scope); |
| 8972 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, node->data.suspend.block, susp_res)); | 10028 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, node->data.suspend.block, susp_res)); |
| 8973 | } | 10029 | } |
| 8974 | | 10030 | |
| 8975 | return ir_mark_gen(ir_build_suspend_finish(irb, parent_scope, node, begin)); | 10031 | return ir_mark_gen(ir_build_suspend_finish_src(irb, parent_scope, node, begin)); |
| 8976 | } | 10032 | } |
| 8977 | | 10033 | |
| 8978 | static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scope, | 10034 | static IrInstSrc *ir_gen_node_raw(IrBuilderSrc *irb, AstNode *node, Scope *scope, |
| 8979 | LVal lval, ResultLoc *result_loc) | 10035 | LVal lval, ResultLoc *result_loc) |
| 8980 | { | 10036 | { |
| 8981 | assert(scope); | 10037 | assert(scope); |
| ... | @@ -9024,39 +10080,39 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop | ... | @@ -9024,39 +10080,39 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop |
| 9024 | return ir_gen_return(irb, scope, node, lval, result_loc); | 10080 | return ir_gen_return(irb, scope, node, lval, result_loc); |
| 9025 | case NodeTypeFieldAccessExpr: | 10081 | case NodeTypeFieldAccessExpr: |
| 9026 | { | 10082 | { |
| 9027 | IrInstruction *ptr_instruction = ir_gen_field_access(irb, scope, node); | 10083 | IrInstSrc *ptr_instruction = ir_gen_field_access(irb, scope, node); |
| 9028 | if (ptr_instruction == irb->codegen->invalid_instruction) | 10084 | if (ptr_instruction == irb->codegen->invalid_inst_src) |
| 9029 | return ptr_instruction; | 10085 | return ptr_instruction; |
| 9030 | if (lval == LValPtr) | 10086 | if (lval == LValPtr) |
| 9031 | return ptr_instruction; | 10087 | return ptr_instruction; |
| 9032 | | 10088 | |
| 9033 | IrInstruction *load_ptr = ir_build_load_ptr(irb, scope, node, ptr_instruction); | 10089 | IrInstSrc *load_ptr = ir_build_load_ptr(irb, scope, node, ptr_instruction); |
| 9034 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); | 10090 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); |
| 9035 | } | 10091 | } |
| 9036 | case NodeTypePtrDeref: { | 10092 | case NodeTypePtrDeref: { |
| 9037 | AstNode *expr_node = node->data.ptr_deref_expr.target; | 10093 | AstNode *expr_node = node->data.ptr_deref_expr.target; |
| 9038 | IrInstruction *value = ir_gen_node_extra(irb, expr_node, scope, lval, nullptr); | 10094 | IrInstSrc *value = ir_gen_node_extra(irb, expr_node, scope, lval, nullptr); |
| 9039 | if (value == irb->codegen->invalid_instruction) | 10095 | if (value == irb->codegen->invalid_inst_src) |
| 9040 | return value; | 10096 | return value; |
| 9041 | | 10097 | |
| 9042 | // We essentially just converted any lvalue from &(x.*) to (&x).*; | 10098 | // We essentially just converted any lvalue from &(x.*) to (&x).*; |
| 9043 | // this inhibits checking that x is a pointer later, so we directly | 10099 | // this inhibits checking that x is a pointer later, so we directly |
| 9044 | // record whether the pointer check is needed | 10100 | // record whether the pointer check is needed |
| 9045 | IrInstruction *un_op = ir_build_un_op_lval(irb, scope, node, IrUnOpDereference, value, lval, result_loc); | 10101 | IrInstSrc *un_op = ir_build_un_op_lval(irb, scope, node, IrUnOpDereference, value, lval, result_loc); |
| 9046 | return ir_expr_wrap(irb, scope, un_op, result_loc); | 10102 | return ir_expr_wrap(irb, scope, un_op, result_loc); |
| 9047 | } | 10103 | } |
| 9048 | case NodeTypeUnwrapOptional: { | 10104 | case NodeTypeUnwrapOptional: { |
| 9049 | AstNode *expr_node = node->data.unwrap_optional.expr; | 10105 | AstNode *expr_node = node->data.unwrap_optional.expr; |
| 9050 | | 10106 | |
| 9051 | IrInstruction *maybe_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); | 10107 | IrInstSrc *maybe_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); |
| 9052 | if (maybe_ptr == irb->codegen->invalid_instruction) | 10108 | if (maybe_ptr == irb->codegen->invalid_inst_src) |
| 9053 | return irb->codegen->invalid_instruction; | 10109 | return irb->codegen->invalid_inst_src; |
| 9054 | | 10110 | |
| 9055 | IrInstruction *unwrapped_ptr = ir_build_optional_unwrap_ptr(irb, scope, node, maybe_ptr, true, false); | 10111 | IrInstSrc *unwrapped_ptr = ir_build_optional_unwrap_ptr(irb, scope, node, maybe_ptr, true, false); |
| 9056 | if (lval == LValPtr) | 10112 | if (lval == LValPtr) |
| 9057 | return unwrapped_ptr; | 10113 | return unwrapped_ptr; |
| 9058 | | 10114 | |
| 9059 | IrInstruction *load_ptr = ir_build_load_ptr(irb, scope, node, unwrapped_ptr); | 10115 | IrInstSrc *load_ptr = ir_build_load_ptr(irb, scope, node, unwrapped_ptr); |
| 9060 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); | 10116 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); |
| 9061 | } | 10117 | } |
| 9062 | case NodeTypeBoolLiteral: | 10118 | case NodeTypeBoolLiteral: |
| ... | @@ -9114,7 +10170,7 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop | ... | @@ -9114,7 +10170,7 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop |
| 9114 | case NodeTypeInferredArrayType: | 10170 | case NodeTypeInferredArrayType: |
| 9115 | add_node_error(irb->codegen, node, | 10171 | add_node_error(irb->codegen, node, |
| 9116 | buf_sprintf("inferred array size invalid here")); | 10172 | buf_sprintf("inferred array size invalid here")); |
| 9117 | return irb->codegen->invalid_instruction; | 10173 | return irb->codegen->invalid_inst_src; |
| 9118 | case NodeTypeVarFieldType: | 10174 | case NodeTypeVarFieldType: |
| 9119 | return ir_lval_wrap(irb, scope, | 10175 | return ir_lval_wrap(irb, scope, |
| 9120 | ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_var), lval, result_loc); | 10176 | ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_var), lval, result_loc); |
| ... | @@ -9128,7 +10184,7 @@ static ResultLoc *no_result_loc(void) { | ... | @@ -9128,7 +10184,7 @@ static ResultLoc *no_result_loc(void) { |
| 9128 | return &result_loc_none->base; | 10184 | return &result_loc_none->base; |
| 9129 | } | 10185 | } |
| 9130 | | 10186 | |
| 9131 | static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *scope, LVal lval, | 10187 | static IrInstSrc *ir_gen_node_extra(IrBuilderSrc *irb, AstNode *node, Scope *scope, LVal lval, |
| 9132 | ResultLoc *result_loc) | 10188 | ResultLoc *result_loc) |
| 9133 | { | 10189 | { |
| 9134 | if (result_loc == nullptr) { | 10190 | if (result_loc == nullptr) { |
| ... | @@ -9145,8 +10201,8 @@ static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *sc | ... | @@ -9145,8 +10201,8 @@ static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *sc |
| 9145 | } else { | 10201 | } else { |
| 9146 | child_scope = &create_expr_scope(irb->codegen, node, scope)->base; | 10202 | child_scope = &create_expr_scope(irb->codegen, node, scope)->base; |
| 9147 | } | 10203 | } |
| 9148 | IrInstruction *result = ir_gen_node_raw(irb, node, child_scope, lval, result_loc); | 10204 | IrInstSrc *result = ir_gen_node_raw(irb, node, child_scope, lval, result_loc); |
| 9149 | if (result == irb->codegen->invalid_instruction) { | 10205 | if (result == irb->codegen->invalid_inst_src) { |
| 9150 | if (irb->exec->first_err_trace_msg == nullptr) { | 10206 | if (irb->exec->first_err_trace_msg == nullptr) { |
| 9151 | irb->exec->first_err_trace_msg = irb->codegen->trace_err; | 10207 | irb->exec->first_err_trace_msg = irb->codegen->trace_err; |
| 9152 | } | 10208 | } |
| ... | @@ -9154,11 +10210,22 @@ static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *sc | ... | @@ -9154,11 +10210,22 @@ static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *sc |
| 9154 | return result; | 10210 | return result; |
| 9155 | } | 10211 | } |
| 9156 | | 10212 | |
| 9157 | static IrInstruction *ir_gen_node(IrBuilder *irb, AstNode *node, Scope *scope) { | 10213 | static IrInstSrc *ir_gen_node(IrBuilderSrc *irb, AstNode *node, Scope *scope) { |
| 9158 | return ir_gen_node_extra(irb, node, scope, LValNone, nullptr); | 10214 | return ir_gen_node_extra(irb, node, scope, LValNone, nullptr); |
| 9159 | } | 10215 | } |
| 9160 | | 10216 | |
| 9161 | static void invalidate_exec(IrExecutable *exec, ErrorMsg *msg) { | 10217 | static void invalidate_exec(IrExecutableSrc *exec, ErrorMsg *msg) { |
| | 10218 | if (exec->first_err_trace_msg != nullptr) |
| | 10219 | return; |
| | 10220 | |
| | 10221 | exec->first_err_trace_msg = msg; |
| | 10222 | |
| | 10223 | for (size_t i = 0; i < exec->tld_list.length; i += 1) { |
| | 10224 | exec->tld_list.items[i]->resolution = TldResolutionInvalid; |
| | 10225 | } |
| | 10226 | } |
| | 10227 | |
| | 10228 | static void invalidate_exec_gen(IrExecutableGen *exec, ErrorMsg *msg) { |
| 9162 | if (exec->first_err_trace_msg != nullptr) | 10229 | if (exec->first_err_trace_msg != nullptr) |
| 9163 | return; | 10230 | return; |
| 9164 | | 10231 | |
| ... | @@ -9172,24 +10239,25 @@ static void invalidate_exec(IrExecutable *exec, ErrorMsg *msg) { | ... | @@ -9172,24 +10239,25 @@ static void invalidate_exec(IrExecutable *exec, ErrorMsg *msg) { |
| 9172 | invalidate_exec(exec->source_exec, msg); | 10239 | invalidate_exec(exec->source_exec, msg); |
| 9173 | } | 10240 | } |
| 9174 | | 10241 | |
| 9175 | bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_executable) { | 10242 | |
| | 10243 | bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutableSrc *ir_executable) { |
| 9176 | assert(node->owner); | 10244 | assert(node->owner); |
| 9177 | | 10245 | |
| 9178 | IrBuilder ir_builder = {0}; | 10246 | IrBuilderSrc ir_builder = {0}; |
| 9179 | IrBuilder *irb = &ir_builder; | 10247 | IrBuilderSrc *irb = &ir_builder; |
| 9180 | | 10248 | |
| 9181 | irb->codegen = codegen; | 10249 | irb->codegen = codegen; |
| 9182 | irb->exec = ir_executable; | 10250 | irb->exec = ir_executable; |
| 9183 | irb->main_block_node = node; | 10251 | irb->main_block_node = node; |
| 9184 | | 10252 | |
| 9185 | IrBasicBlock *entry_block = ir_create_basic_block(irb, scope, "Entry"); | 10253 | IrBasicBlockSrc *entry_block = ir_create_basic_block(irb, scope, "Entry"); |
| 9186 | ir_set_cursor_at_end_and_append_block(irb, entry_block); | 10254 | ir_set_cursor_at_end_and_append_block(irb, entry_block); |
| 9187 | // Entry block gets a reference because we enter it to begin. | 10255 | // Entry block gets a reference because we enter it to begin. |
| 9188 | ir_ref_bb(irb->current_basic_block); | 10256 | ir_ref_bb(irb->current_basic_block); |
| 9189 | | 10257 | |
| 9190 | IrInstruction *result = ir_gen_node_extra(irb, node, scope, LValNone, nullptr); | 10258 | IrInstSrc *result = ir_gen_node_extra(irb, node, scope, LValNone, nullptr); |
| 9191 | | 10259 | |
| 9192 | if (result == irb->codegen->invalid_instruction) | 10260 | if (result == irb->codegen->invalid_inst_src) |
| 9193 | return false; | 10261 | return false; |
| 9194 | | 10262 | |
| 9195 | if (irb->exec->first_err_trace_msg != nullptr) { | 10263 | if (irb->exec->first_err_trace_msg != nullptr) { |
| ... | @@ -9198,13 +10266,13 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec | ... | @@ -9198,13 +10266,13 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec |
| 9198 | } | 10266 | } |
| 9199 | | 10267 | |
| 9200 | if (!instr_is_unreachable(result)) { | 10268 | if (!instr_is_unreachable(result)) { |
| 9201 | ir_mark_gen(ir_build_add_implicit_return_type(irb, scope, result->source_node, result, nullptr)); | 10269 | ir_mark_gen(ir_build_add_implicit_return_type(irb, scope, result->base.source_node, result, nullptr)); |
| 9202 | // no need for save_err_ret_addr because this cannot return error | 10270 | // no need for save_err_ret_addr because this cannot return error |
| 9203 | ResultLocReturn *result_loc_ret = allocate<ResultLocReturn>(1, "ResultLocReturn"); | 10271 | ResultLocReturn *result_loc_ret = allocate<ResultLocReturn>(1, "ResultLocReturn"); |
| 9204 | result_loc_ret->base.id = ResultLocIdReturn; | 10272 | result_loc_ret->base.id = ResultLocIdReturn; |
| 9205 | ir_build_reset_result(irb, scope, node, &result_loc_ret->base); | 10273 | ir_build_reset_result(irb, scope, node, &result_loc_ret->base); |
| 9206 | ir_mark_gen(ir_build_end_expr(irb, scope, node, result, &result_loc_ret->base)); | 10274 | ir_mark_gen(ir_build_end_expr(irb, scope, node, result, &result_loc_ret->base)); |
| 9207 | ir_mark_gen(ir_build_return(irb, scope, result->source_node, result)); | 10275 | ir_mark_gen(ir_build_return_src(irb, scope, result->base.source_node, result)); |
| 9208 | } | 10276 | } |
| 9209 | | 10277 | |
| 9210 | return true; | 10278 | return true; |
| ... | @@ -9213,7 +10281,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec | ... | @@ -9213,7 +10281,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec |
| 9213 | bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) { | 10281 | bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) { |
| 9214 | assert(fn_entry); | 10282 | assert(fn_entry); |
| 9215 | | 10283 | |
| 9216 | IrExecutable *ir_executable = fn_entry->ir_executable; | 10284 | IrExecutableSrc *ir_executable = fn_entry->ir_executable; |
| 9217 | AstNode *body_node = fn_entry->body_node; | 10285 | AstNode *body_node = fn_entry->body_node; |
| 9218 | | 10286 | |
| 9219 | assert(fn_entry->child_scope); | 10287 | assert(fn_entry->child_scope); |
| ... | @@ -9221,14 +10289,21 @@ bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) { | ... | @@ -9221,14 +10289,21 @@ bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) { |
| 9221 | return ir_gen(codegen, body_node, fn_entry->child_scope, ir_executable); | 10289 | return ir_gen(codegen, body_node, fn_entry->child_scope, ir_executable); |
| 9222 | } | 10290 | } |
| 9223 | | 10291 | |
| 9224 | static void ir_add_call_stack_errors(CodeGen *codegen, IrExecutable *exec, ErrorMsg *err_msg, int limit) { | 10292 | static void ir_add_call_stack_errors_gen(CodeGen *codegen, IrExecutableGen *exec, ErrorMsg *err_msg, int limit) { |
| 9225 | if (!exec || !exec->source_node || limit < 0) return; | 10293 | if (!exec || !exec->source_node || limit < 0) return; |
| 9226 | add_error_note(codegen, err_msg, exec->source_node, buf_sprintf("called from here")); | 10294 | add_error_note(codegen, err_msg, exec->source_node, buf_sprintf("called from here")); |
| 9227 | | 10295 | |
| 9228 | ir_add_call_stack_errors(codegen, exec->parent_exec, err_msg, limit - 1); | 10296 | ir_add_call_stack_errors_gen(codegen, exec->parent_exec, err_msg, limit - 1); |
| 9229 | } | 10297 | } |
| 9230 | | 10298 | |
| 9231 | static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, Buf *msg) { | 10299 | static void ir_add_call_stack_errors(CodeGen *codegen, IrExecutableSrc *exec, ErrorMsg *err_msg, int limit) { |
| | 10300 | if (!exec || !exec->source_node || limit < 0) return; |
| | 10301 | add_error_note(codegen, err_msg, exec->source_node, buf_sprintf("called from here")); |
| | 10302 | |
| | 10303 | ir_add_call_stack_errors_gen(codegen, exec->parent_exec, err_msg, limit - 1); |
| | 10304 | } |
| | 10305 | |
| | 10306 | static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutableSrc *exec, AstNode *source_node, Buf *msg) { |
| 9232 | ErrorMsg *err_msg = add_node_error(codegen, source_node, msg); | 10307 | ErrorMsg *err_msg = add_node_error(codegen, source_node, msg); |
| 9233 | invalidate_exec(exec, err_msg); | 10308 | invalidate_exec(exec, err_msg); |
| 9234 | if (exec->parent_exec) { | 10309 | if (exec->parent_exec) { |
| ... | @@ -9237,26 +10312,40 @@ static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutable *exec, AstNo | ... | @@ -9237,26 +10312,40 @@ static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutable *exec, AstNo |
| 9237 | return err_msg; | 10312 | return err_msg; |
| 9238 | } | 10313 | } |
| 9239 | | 10314 | |
| | 10315 | static ErrorMsg *exec_add_error_node_gen(CodeGen *codegen, IrExecutableGen *exec, AstNode *source_node, Buf *msg) { |
| | 10316 | ErrorMsg *err_msg = add_node_error(codegen, source_node, msg); |
| | 10317 | invalidate_exec_gen(exec, err_msg); |
| | 10318 | if (exec->parent_exec) { |
| | 10319 | ir_add_call_stack_errors_gen(codegen, exec, err_msg, 10); |
| | 10320 | } |
| | 10321 | return err_msg; |
| | 10322 | } |
| | 10323 | |
| 9240 | static ErrorMsg *ir_add_error_node(IrAnalyze *ira, AstNode *source_node, Buf *msg) { | 10324 | static ErrorMsg *ir_add_error_node(IrAnalyze *ira, AstNode *source_node, Buf *msg) { |
| 9241 | return exec_add_error_node(ira->codegen, ira->new_irb.exec, source_node, msg); | 10325 | return exec_add_error_node_gen(ira->codegen, ira->new_irb.exec, source_node, msg); |
| 9242 | } | 10326 | } |
| 9243 | | 10327 | |
| 9244 | static ErrorMsg *opt_ir_add_error_node(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, Buf *msg) { | 10328 | static ErrorMsg *opt_ir_add_error_node(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, Buf *msg) { |
| 9245 | if (ira != nullptr) | 10329 | if (ira != nullptr) |
| 9246 | return exec_add_error_node(codegen, ira->new_irb.exec, source_node, msg); | 10330 | return exec_add_error_node_gen(codegen, ira->new_irb.exec, source_node, msg); |
| 9247 | else | 10331 | else |
| 9248 | return add_node_error(codegen, source_node, msg); | 10332 | return add_node_error(codegen, source_node, msg); |
| 9249 | } | 10333 | } |
| 9250 | | 10334 | |
| 9251 | static ErrorMsg *ir_add_error(IrAnalyze *ira, IrInstruction *source_instruction, Buf *msg) { | 10335 | static ErrorMsg *ir_add_error(IrAnalyze *ira, IrInst *source_instruction, Buf *msg) { |
| 9252 | return ir_add_error_node(ira, source_instruction->source_node, msg); | 10336 | return ir_add_error_node(ira, source_instruction->source_node, msg); |
| 9253 | } | 10337 | } |
| 9254 | | 10338 | |
| 9255 | static void ir_assert(bool ok, IrInstruction *source_instruction) { | 10339 | static void ir_assert(bool ok, IrInst *source_instruction) { |
| 9256 | if (ok) return; | 10340 | if (ok) return; |
| 9257 | src_assert(ok, source_instruction->source_node); | 10341 | src_assert(ok, source_instruction->source_node); |
| 9258 | } | 10342 | } |
| 9259 | | 10343 | |
| | 10344 | static void ir_assert_gen(bool ok, IrInstGen *source_instruction) { |
| | 10345 | if (ok) return; |
| | 10346 | src_assert(ok, source_instruction->base.source_node); |
| | 10347 | } |
| | 10348 | |
| 9260 | // This function takes a comptime ptr and makes the child const value conform to the type | 10349 | // This function takes a comptime ptr and makes the child const value conform to the type |
| 9261 | // described by the pointer. | 10350 | // described by the pointer. |
| 9262 | static Error eval_comptime_ptr_reinterpret(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, | 10351 | static Error eval_comptime_ptr_reinterpret(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, |
| ... | @@ -9302,36 +10391,36 @@ ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_va | ... | @@ -9302,36 +10391,36 @@ ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_va |
| 9302 | return val; | 10391 | return val; |
| 9303 | } | 10392 | } |
| 9304 | | 10393 | |
| 9305 | static Error ir_exec_scan_for_side_effects(CodeGen *codegen, IrExecutable *exec) { | 10394 | static Error ir_exec_scan_for_side_effects(CodeGen *codegen, IrExecutableGen *exec) { |
| 9306 | IrBasicBlock *bb = exec->basic_block_list.at(0); | 10395 | IrBasicBlockGen *bb = exec->basic_block_list.at(0); |
| 9307 | for (size_t i = 0; i < bb->instruction_list.length; i += 1) { | 10396 | for (size_t i = 0; i < bb->instruction_list.length; i += 1) { |
| 9308 | IrInstruction *instruction = bb->instruction_list.at(i); | 10397 | IrInstGen *instruction = bb->instruction_list.at(i); |
| 9309 | if (instruction->id == IrInstructionIdReturn) { | 10398 | if (instruction->id == IrInstGenIdReturn) { |
| 9310 | return ErrorNone; | 10399 | return ErrorNone; |
| 9311 | } else if (ir_has_side_effects(instruction)) { | 10400 | } else if (ir_inst_gen_has_side_effects(instruction)) { |
| 9312 | if (instr_is_comptime(instruction)) { | 10401 | if (instr_is_comptime(instruction)) { |
| 9313 | switch (instruction->id) { | 10402 | switch (instruction->id) { |
| 9314 | case IrInstructionIdUnwrapErrPayload: | 10403 | case IrInstGenIdUnwrapErrPayload: |
| 9315 | case IrInstructionIdUnionFieldPtr: | 10404 | case IrInstGenIdUnionFieldPtr: |
| 9316 | continue; | 10405 | continue; |
| 9317 | default: | 10406 | default: |
| 9318 | break; | 10407 | break; |
| 9319 | } | 10408 | } |
| 9320 | } | 10409 | } |
| 9321 | if (get_scope_typeof(instruction->scope) != nullptr) { | 10410 | if (get_scope_typeof(instruction->base.scope) != nullptr) { |
| 9322 | // doesn't count, it's inside a @TypeOf() | 10411 | // doesn't count, it's inside a @TypeOf() |
| 9323 | continue; | 10412 | continue; |
| 9324 | } | 10413 | } |
| 9325 | exec_add_error_node(codegen, exec, instruction->source_node, | 10414 | exec_add_error_node_gen(codegen, exec, instruction->base.source_node, |
| 9326 | buf_sprintf("unable to evaluate constant expression")); | 10415 | buf_sprintf("unable to evaluate constant expression")); |
| 9327 | return ErrorSemanticAnalyzeFail; | 10416 | return ErrorSemanticAnalyzeFail; |
| 9328 | } | 10417 | } |
| 9329 | } | 10418 | } |
| 9330 | zig_unreachable(); | 10419 | zig_unreachable(); |
| 9331 | } | 10420 | } |
| 9332 | | 10421 | |
| 9333 | static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *source_instruction) { | 10422 | static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInst* source_instruction) { |
| 9334 | if (ir_should_inline(ira->new_irb.exec, source_instruction->scope)) { | 10423 | if (ir_should_inline(ira->old_irb.exec, source_instruction->scope)) { |
| 9335 | ir_add_error(ira, source_instruction, buf_sprintf("unable to evaluate constant expression")); | 10424 | ir_add_error(ira, source_instruction, buf_sprintf("unable to evaluate constant expression")); |
| 9336 | return false; | 10425 | return false; |
| 9337 | } | 10426 | } |
| ... | @@ -10065,7 +11154,7 @@ void float_read_ieee597(ZigValue *val, uint8_t *buf, bool is_big_endian) { | ... | @@ -10065,7 +11154,7 @@ void float_read_ieee597(ZigValue *val, uint8_t *buf, bool is_big_endian) { |
| 10065 | } | 11154 | } |
| 10066 | } | 11155 | } |
| 10067 | | 11156 | |
| 10068 | static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruction, ZigType *other_type, | 11157 | static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstGen *instruction, ZigType *other_type, |
| 10069 | bool explicit_cast) | 11158 | bool explicit_cast) |
| 10070 | { | 11159 | { |
| 10071 | if (type_is_invalid(other_type)) { | 11160 | if (type_is_invalid(other_type)) { |
| ... | @@ -10159,7 +11248,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -10159,7 +11248,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 10159 | } | 11248 | } |
| 10160 | Buf *val_buf = buf_alloc(); | 11249 | Buf *val_buf = buf_alloc(); |
| 10161 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); | 11250 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); |
| 10162 | ir_add_error(ira, instruction, | 11251 | ir_add_error_node(ira, instruction->base.source_node, |
| 10163 | buf_sprintf("integer value %s has no representation in type '%s'", | 11252 | buf_sprintf("integer value %s has no representation in type '%s'", |
| 10164 | buf_ptr(val_buf), | 11253 | buf_ptr(val_buf), |
| 10165 | buf_ptr(&other_type->name))); | 11254 | buf_ptr(&other_type->name))); |
| ... | @@ -10254,7 +11343,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -10254,7 +11343,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 10254 | } | 11343 | } |
| 10255 | Buf *val_buf = buf_alloc(); | 11344 | Buf *val_buf = buf_alloc(); |
| 10256 | float_append_buf(val_buf, const_val); | 11345 | float_append_buf(val_buf, const_val); |
| 10257 | ir_add_error(ira, instruction, | 11346 | ir_add_error_node(ira, instruction->base.source_node, |
| 10258 | buf_sprintf("cast of value %s to type '%s' loses information", | 11347 | buf_sprintf("cast of value %s to type '%s' loses information", |
| 10259 | buf_ptr(val_buf), | 11348 | buf_ptr(val_buf), |
| 10260 | buf_ptr(&other_type->name))); | 11349 | buf_ptr(&other_type->name))); |
| ... | @@ -10263,7 +11352,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -10263,7 +11352,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 10263 | if (!other_type->data.integral.is_signed && const_val->data.x_bigint.is_negative) { | 11352 | if (!other_type->data.integral.is_signed && const_val->data.x_bigint.is_negative) { |
| 10264 | Buf *val_buf = buf_alloc(); | 11353 | Buf *val_buf = buf_alloc(); |
| 10265 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); | 11354 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); |
| 10266 | ir_add_error(ira, instruction, | 11355 | ir_add_error_node(ira, instruction->base.source_node, |
| 10267 | buf_sprintf("cannot cast negative value %s to unsigned integer type '%s'", | 11356 | buf_sprintf("cannot cast negative value %s to unsigned integer type '%s'", |
| 10268 | buf_ptr(val_buf), | 11357 | buf_ptr(val_buf), |
| 10269 | buf_ptr(&other_type->name))); | 11358 | buf_ptr(&other_type->name))); |
| ... | @@ -10284,7 +11373,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -10284,7 +11373,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 10284 | if (!child_type->data.integral.is_signed && const_val->data.x_bigint.is_negative) { | 11373 | if (!child_type->data.integral.is_signed && const_val->data.x_bigint.is_negative) { |
| 10285 | Buf *val_buf = buf_alloc(); | 11374 | Buf *val_buf = buf_alloc(); |
| 10286 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); | 11375 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); |
| 10287 | ir_add_error(ira, instruction, | 11376 | ir_add_error_node(ira, instruction->base.source_node, |
| 10288 | buf_sprintf("cannot cast negative value %s to unsigned integer type '%s'", | 11377 | buf_sprintf("cannot cast negative value %s to unsigned integer type '%s'", |
| 10289 | buf_ptr(val_buf), | 11378 | buf_ptr(val_buf), |
| 10290 | buf_ptr(&child_type->name))); | 11379 | buf_ptr(&child_type->name))); |
| ... | @@ -10307,7 +11396,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -10307,7 +11396,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 10307 | Buf *val_buf = buf_alloc(); | 11396 | Buf *val_buf = buf_alloc(); |
| 10308 | float_append_buf(val_buf, const_val); | 11397 | float_append_buf(val_buf, const_val); |
| 10309 | | 11398 | |
| 10310 | ir_add_error(ira, instruction, | 11399 | ir_add_error_node(ira, instruction->base.source_node, |
| 10311 | buf_sprintf("fractional component prevents float value %s from being casted to type '%s'", | 11400 | buf_sprintf("fractional component prevents float value %s from being casted to type '%s'", |
| 10312 | buf_ptr(val_buf), | 11401 | buf_ptr(val_buf), |
| 10313 | buf_ptr(&other_type->name))); | 11402 | buf_ptr(&other_type->name))); |
| ... | @@ -10337,7 +11426,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -10337,7 +11426,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 10337 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); | 11426 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); |
| 10338 | } | 11427 | } |
| 10339 | | 11428 | |
| 10340 | ir_add_error(ira, instruction, | 11429 | ir_add_error_node(ira, instruction->base.source_node, |
| 10341 | buf_sprintf("%s value %s cannot be coerced to type '%s'", | 11430 | buf_sprintf("%s value %s cannot be coerced to type '%s'", |
| 10342 | num_lit_str, | 11431 | num_lit_str, |
| 10343 | buf_ptr(val_buf), | 11432 | buf_ptr(val_buf), |
| ... | @@ -10791,11 +11880,11 @@ static void update_errors_helper(CodeGen *g, ErrorTableEntry ***errors, size_t * | ... | @@ -10791,11 +11880,11 @@ static void update_errors_helper(CodeGen *g, ErrorTableEntry ***errors, size_t * |
| 10791 | } | 11880 | } |
| 10792 | | 11881 | |
| 10793 | static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigType *expected_type, | 11882 | static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigType *expected_type, |
| 10794 | IrInstruction **instructions, size_t instruction_count) | 11883 | IrInstGen **instructions, size_t instruction_count) |
| 10795 | { | 11884 | { |
| 10796 | Error err; | 11885 | Error err; |
| 10797 | assert(instruction_count >= 1); | 11886 | assert(instruction_count >= 1); |
| 10798 | IrInstruction *prev_inst; | 11887 | IrInstGen *prev_inst; |
| 10799 | size_t i = 0; | 11888 | size_t i = 0; |
| 10800 | for (;;) { | 11889 | for (;;) { |
| 10801 | prev_inst = instructions[i]; | 11890 | prev_inst = instructions[i]; |
| ... | @@ -10815,7 +11904,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10815,7 +11904,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10815 | size_t errors_count = 0; | 11904 | size_t errors_count = 0; |
| 10816 | ZigType *err_set_type = nullptr; | 11905 | ZigType *err_set_type = nullptr; |
| 10817 | if (prev_inst->value->type->id == ZigTypeIdErrorSet) { | 11906 | if (prev_inst->value->type->id == ZigTypeIdErrorSet) { |
| 10818 | if (!resolve_inferred_error_set(ira->codegen, prev_inst->value->type, prev_inst->source_node)) { | 11907 | if (!resolve_inferred_error_set(ira->codegen, prev_inst->value->type, prev_inst->base.source_node)) { |
| 10819 | return ira->codegen->builtin_types.entry_invalid; | 11908 | return ira->codegen->builtin_types.entry_invalid; |
| 10820 | } | 11909 | } |
| 10821 | if (type_is_global_error_set(prev_inst->value->type)) { | 11910 | if (type_is_global_error_set(prev_inst->value->type)) { |
| ... | @@ -10835,7 +11924,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10835,7 +11924,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10835 | bool any_are_null = (prev_inst->value->type->id == ZigTypeIdNull); | 11924 | bool any_are_null = (prev_inst->value->type->id == ZigTypeIdNull); |
| 10836 | bool convert_to_const_slice = false; | 11925 | bool convert_to_const_slice = false; |
| 10837 | for (; i < instruction_count; i += 1) { | 11926 | for (; i < instruction_count; i += 1) { |
| 10838 | IrInstruction *cur_inst = instructions[i]; | 11927 | IrInstGen *cur_inst = instructions[i]; |
| 10839 | ZigType *cur_type = cur_inst->value->type; | 11928 | ZigType *cur_type = cur_inst->value->type; |
| 10840 | ZigType *prev_type = prev_inst->value->type; | 11929 | ZigType *prev_type = prev_inst->value->type; |
| 10841 | | 11930 | |
| ... | @@ -10857,14 +11946,14 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10857,14 +11946,14 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10857 | } | 11946 | } |
| 10858 | | 11947 | |
| 10859 | if (prev_type->id == ZigTypeIdErrorSet) { | 11948 | if (prev_type->id == ZigTypeIdErrorSet) { |
| 10860 | ir_assert(err_set_type != nullptr, prev_inst); | 11949 | ir_assert_gen(err_set_type != nullptr, prev_inst); |
| 10861 | if (cur_type->id == ZigTypeIdErrorSet) { | 11950 | if (cur_type->id == ZigTypeIdErrorSet) { |
| 10862 | if (type_is_global_error_set(err_set_type)) { | 11951 | if (type_is_global_error_set(err_set_type)) { |
| 10863 | continue; | 11952 | continue; |
| 10864 | } | 11953 | } |
| 10865 | bool allow_infer = cur_type->data.error_set.infer_fn != nullptr && | 11954 | bool allow_infer = cur_type->data.error_set.infer_fn != nullptr && |
| 10866 | cur_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; | 11955 | cur_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; |
| 10867 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, cur_type, cur_inst->source_node)) { | 11956 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, cur_type, cur_inst->base.source_node)) { |
| 10868 | return ira->codegen->builtin_types.entry_invalid; | 11957 | return ira->codegen->builtin_types.entry_invalid; |
| 10869 | } | 11958 | } |
| 10870 | if (!allow_infer && type_is_global_error_set(cur_type)) { | 11959 | if (!allow_infer && type_is_global_error_set(cur_type)) { |
| ... | @@ -10932,7 +12021,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10932,7 +12021,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10932 | ZigType *cur_err_set_type = cur_type->data.error_union.err_set_type; | 12021 | ZigType *cur_err_set_type = cur_type->data.error_union.err_set_type; |
| 10933 | bool allow_infer = cur_err_set_type->data.error_set.infer_fn != nullptr && | 12022 | bool allow_infer = cur_err_set_type->data.error_set.infer_fn != nullptr && |
| 10934 | cur_err_set_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; | 12023 | cur_err_set_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; |
| 10935 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->source_node)) { | 12024 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->base.source_node)) { |
| 10936 | return ira->codegen->builtin_types.entry_invalid; | 12025 | return ira->codegen->builtin_types.entry_invalid; |
| 10937 | } | 12026 | } |
| 10938 | if (!allow_infer && type_is_global_error_set(cur_err_set_type)) { | 12027 | if (!allow_infer && type_is_global_error_set(cur_err_set_type)) { |
| ... | @@ -10987,7 +12076,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10987,7 +12076,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10987 | if (cur_type->id == ZigTypeIdErrorSet) { | 12076 | if (cur_type->id == ZigTypeIdErrorSet) { |
| 10988 | bool allow_infer = cur_type->data.error_set.infer_fn != nullptr && | 12077 | bool allow_infer = cur_type->data.error_set.infer_fn != nullptr && |
| 10989 | cur_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; | 12078 | cur_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; |
| 10990 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, cur_type, cur_inst->source_node)) { | 12079 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, cur_type, cur_inst->base.source_node)) { |
| 10991 | return ira->codegen->builtin_types.entry_invalid; | 12080 | return ira->codegen->builtin_types.entry_invalid; |
| 10992 | } | 12081 | } |
| 10993 | if (!allow_infer && type_is_global_error_set(cur_type)) { | 12082 | if (!allow_infer && type_is_global_error_set(cur_type)) { |
| ... | @@ -11010,7 +12099,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -11010,7 +12099,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 11010 | err_set_type = cur_type; | 12099 | err_set_type = cur_type; |
| 11011 | } | 12100 | } |
| 11012 | | 12101 | |
| 11013 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, err_set_type, cur_inst->source_node)) { | 12102 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, err_set_type, cur_inst->base.source_node)) { |
| 11014 | return ira->codegen->builtin_types.entry_invalid; | 12103 | return ira->codegen->builtin_types.entry_invalid; |
| 11015 | } | 12104 | } |
| 11016 | | 12105 | |
| ... | @@ -11073,11 +12162,11 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -11073,11 +12162,11 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 11073 | bool allow_infer_cur = cur_err_set_type->data.error_set.infer_fn != nullptr && | 12162 | bool allow_infer_cur = cur_err_set_type->data.error_set.infer_fn != nullptr && |
| 11074 | cur_err_set_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; | 12163 | cur_err_set_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; |
| 11075 | | 12164 | |
| 11076 | if (!allow_infer_prev && !resolve_inferred_error_set(ira->codegen, prev_err_set_type, cur_inst->source_node)) { | 12165 | if (!allow_infer_prev && !resolve_inferred_error_set(ira->codegen, prev_err_set_type, cur_inst->base.source_node)) { |
| 11077 | return ira->codegen->builtin_types.entry_invalid; | 12166 | return ira->codegen->builtin_types.entry_invalid; |
| 11078 | } | 12167 | } |
| 11079 | | 12168 | |
| 11080 | if (!allow_infer_cur && !resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->source_node)) { | 12169 | if (!allow_infer_cur && !resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->base.source_node)) { |
| 11081 | return ira->codegen->builtin_types.entry_invalid; | 12170 | return ira->codegen->builtin_types.entry_invalid; |
| 11082 | } | 12171 | } |
| 11083 | | 12172 | |
| ... | @@ -11254,7 +12343,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -11254,7 +12343,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 11254 | ZigType *cur_err_set_type = cur_type->data.error_union.err_set_type; | 12343 | ZigType *cur_err_set_type = cur_type->data.error_union.err_set_type; |
| 11255 | bool allow_infer = cur_err_set_type->data.error_set.infer_fn != nullptr && | 12344 | bool allow_infer = cur_err_set_type->data.error_set.infer_fn != nullptr && |
| 11256 | cur_err_set_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; | 12345 | cur_err_set_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; |
| 11257 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->source_node)) { | 12346 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->base.source_node)) { |
| 11258 | return ira->codegen->builtin_types.entry_invalid; | 12347 | return ira->codegen->builtin_types.entry_invalid; |
| 11259 | } | 12348 | } |
| 11260 | if ((!allow_infer && type_is_global_error_set(cur_err_set_type)) || | 12349 | if ((!allow_infer && type_is_global_error_set(cur_err_set_type)) || |
| ... | @@ -11449,9 +12538,9 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -11449,9 +12538,9 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 11449 | ErrorMsg *msg = ir_add_error_node(ira, source_node, | 12538 | ErrorMsg *msg = ir_add_error_node(ira, source_node, |
| 11450 | buf_sprintf("incompatible types: '%s' and '%s'", | 12539 | buf_sprintf("incompatible types: '%s' and '%s'", |
| 11451 | buf_ptr(&prev_type->name), buf_ptr(&cur_type->name))); | 12540 | buf_ptr(&prev_type->name), buf_ptr(&cur_type->name))); |
| 11452 | add_error_note(ira->codegen, msg, prev_inst->source_node, | 12541 | add_error_note(ira->codegen, msg, prev_inst->base.source_node, |
| 11453 | buf_sprintf("type '%s' here", buf_ptr(&prev_type->name))); | 12542 | buf_sprintf("type '%s' here", buf_ptr(&prev_type->name))); |
| 11454 | add_error_note(ira->codegen, msg, cur_inst->source_node, | 12543 | add_error_note(ira->codegen, msg, cur_inst->base.source_node, |
| 11455 | buf_sprintf("type '%s' here", buf_ptr(&cur_type->name))); | 12544 | buf_sprintf("type '%s' here", buf_ptr(&cur_type->name))); |
| 11456 | | 12545 | |
| 11457 | return ira->codegen->builtin_types.entry_invalid; | 12546 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -11521,7 +12610,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -11521,7 +12610,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 11521 | } | 12610 | } |
| 11522 | } | 12611 | } |
| 11523 | | 12612 | |
| 11524 | static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_instr, | 12613 | static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInst *source_instr, |
| 11525 | CastOp cast_op, | 12614 | CastOp cast_op, |
| 11526 | ZigValue *other_val, ZigType *other_type, | 12615 | ZigValue *other_val, ZigType *other_type, |
| 11527 | ZigValue *const_val, ZigType *new_type) | 12616 | ZigValue *const_val, ZigType *new_type) |
| ... | @@ -11621,58 +12710,56 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -11621,58 +12710,56 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 11621 | return true; | 12710 | return true; |
| 11622 | } | 12711 | } |
| 11623 | | 12712 | |
| 11624 | static IrInstruction *ir_const(IrAnalyze *ira, IrInstruction *old_instruction, ZigType *ty) { | 12713 | static IrInstGen *ir_const(IrAnalyze *ira, IrInst *inst, ZigType *ty) { |
| 11625 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 12714 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, |
| 11626 | old_instruction->scope, old_instruction->source_node); | 12715 | inst->scope, inst->source_node); |
| 11627 | IrInstruction *new_instruction = &const_instruction->base; | 12716 | IrInstGen *new_instruction = &const_instruction->base; |
| 11628 | new_instruction->value->type = ty; | 12717 | new_instruction->value->type = ty; |
| 11629 | new_instruction->value->special = ConstValSpecialStatic; | 12718 | new_instruction->value->special = ConstValSpecialStatic; |
| 11630 | return new_instruction; | 12719 | return new_instruction; |
| 11631 | } | 12720 | } |
| 11632 | | 12721 | |
| 11633 | static IrInstruction *ir_const_noval(IrAnalyze *ira, IrInstruction *old_instruction) { | 12722 | static IrInstGen *ir_const_noval(IrAnalyze *ira, IrInst *old_instruction) { |
| 11634 | IrInstructionConst *const_instruction = ir_create_instruction_noval<IrInstructionConst>(&ira->new_irb, | 12723 | IrInstGenConst *const_instruction = ir_create_inst_noval<IrInstGenConst>(&ira->new_irb, |
| 11635 | old_instruction->scope, old_instruction->source_node); | 12724 | old_instruction->scope, old_instruction->source_node); |
| 11636 | return &const_instruction->base; | 12725 | return &const_instruction->base; |
| 11637 | } | 12726 | } |
| 11638 | | 12727 | |
| 11639 | // This function initializes the new IrInstruction with the provided ZigValue, | 12728 | // This function initializes the new IrInstGen with the provided ZigValue, |
| 11640 | // rather than creating a new one. | 12729 | // rather than creating a new one. |
| 11641 | static IrInstruction *ir_const_move(IrAnalyze *ira, IrInstruction *old_instruction, ZigValue *val) { | 12730 | static IrInstGen *ir_const_move(IrAnalyze *ira, IrInst *old_instruction, ZigValue *val) { |
| 11642 | IrInstruction *result = ir_const_noval(ira, old_instruction); | 12731 | IrInstGen *result = ir_const_noval(ira, old_instruction); |
| 11643 | result->value = val; | 12732 | result->value = val; |
| 11644 | return result; | 12733 | return result; |
| 11645 | } | 12734 | } |
| 11646 | | 12735 | |
| 11647 | static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 12736 | static IrInstGen *ir_resolve_cast(IrAnalyze *ira, IrInst *source_instr, IrInstGen *value, |
| 11648 | ZigType *wanted_type, CastOp cast_op) | 12737 | ZigType *wanted_type, CastOp cast_op) |
| 11649 | { | 12738 | { |
| 11650 | if (instr_is_comptime(value) || !type_has_bits(wanted_type)) { | 12739 | if (instr_is_comptime(value) || !type_has_bits(wanted_type)) { |
| 11651 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12740 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 11652 | if (!eval_const_expr_implicit_cast(ira, source_instr, cast_op, value->value, value->value->type, | 12741 | if (!eval_const_expr_implicit_cast(ira, source_instr, cast_op, value->value, value->value->type, |
| 11653 | result->value, wanted_type)) | 12742 | result->value, wanted_type)) |
| 11654 | { | 12743 | { |
| 11655 | return ira->codegen->invalid_instruction; | 12744 | return ira->codegen->invalid_inst_gen; |
| 11656 | } | 12745 | } |
| 11657 | return result; | 12746 | return result; |
| 11658 | } else { | 12747 | } else { |
| 11659 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, wanted_type, value, cast_op); | 12748 | return ir_build_cast(ira, source_instr, wanted_type, value, cast_op); |
| 11660 | result->value->type = wanted_type; | | |
| 11661 | return result; | | |
| 11662 | } | 12749 | } |
| 11663 | } | 12750 | } |
| 11664 | | 12751 | |
| 11665 | static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, IrInstruction *source_instr, | 12752 | static IrInstGen *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, IrInst* source_instr, |
| 11666 | IrInstruction *value, ZigType *wanted_type) | 12753 | IrInstGen *value, ZigType *wanted_type) |
| 11667 | { | 12754 | { |
| 11668 | assert(value->value->type->id == ZigTypeIdPointer); | 12755 | ir_assert(value->value->type->id == ZigTypeIdPointer, source_instr); |
| 11669 | | 12756 | |
| 11670 | Error err; | 12757 | Error err; |
| 11671 | | 12758 | |
| 11672 | if ((err = type_resolve(ira->codegen, value->value->type->data.pointer.child_type, | 12759 | if ((err = type_resolve(ira->codegen, value->value->type->data.pointer.child_type, |
| 11673 | ResolveStatusAlignmentKnown))) | 12760 | ResolveStatusAlignmentKnown))) |
| 11674 | { | 12761 | { |
| 11675 | return ira->codegen->invalid_instruction; | 12762 | return ira->codegen->invalid_inst_gen; |
| 11676 | } | 12763 | } |
| 11677 | | 12764 | |
| 11678 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, value->value->type)); | 12765 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, value->value->type)); |
| ... | @@ -11680,9 +12767,9 @@ static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, | ... | @@ -11680,9 +12767,9 @@ static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, |
| 11680 | if (instr_is_comptime(value)) { | 12767 | if (instr_is_comptime(value)) { |
| 11681 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, value->value, source_instr->source_node); | 12768 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, value->value, source_instr->source_node); |
| 11682 | if (pointee == nullptr) | 12769 | if (pointee == nullptr) |
| 11683 | return ira->codegen->invalid_instruction; | 12770 | return ira->codegen->invalid_inst_gen; |
| 11684 | if (pointee->special != ConstValSpecialRuntime) { | 12771 | if (pointee->special != ConstValSpecialRuntime) { |
| 11685 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12772 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 11686 | result->value->data.x_ptr.special = ConstPtrSpecialBaseArray; | 12773 | result->value->data.x_ptr.special = ConstPtrSpecialBaseArray; |
| 11687 | result->value->data.x_ptr.mut = value->value->data.x_ptr.mut; | 12774 | result->value->data.x_ptr.mut = value->value->data.x_ptr.mut; |
| 11688 | result->value->data.x_ptr.data.base_array.array_val = pointee; | 12775 | result->value->data.x_ptr.data.base_array.array_val = pointee; |
| ... | @@ -11691,21 +12778,18 @@ static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, | ... | @@ -11691,21 +12778,18 @@ static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, |
| 11691 | } | 12778 | } |
| 11692 | } | 12779 | } |
| 11693 | | 12780 | |
| 11694 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, | 12781 | return ir_build_cast(ira, source_instr, wanted_type, value, CastOpBitCast); |
| 11695 | wanted_type, value, CastOpBitCast); | | |
| 11696 | result->value->type = wanted_type; | | |
| 11697 | return result; | | |
| 11698 | } | 12782 | } |
| 11699 | | 12783 | |
| 11700 | static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruction *source_instr, | 12784 | static IrInstGen *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInst* source_instr, |
| 11701 | IrInstruction *array_ptr, ZigType *wanted_type, ResultLoc *result_loc) | 12785 | IrInstGen *array_ptr, ZigType *wanted_type, ResultLoc *result_loc) |
| 11702 | { | 12786 | { |
| 11703 | Error err; | 12787 | Error err; |
| 11704 | | 12788 | |
| 11705 | if ((err = type_resolve(ira->codegen, array_ptr->value->type->data.pointer.child_type, | 12789 | if ((err = type_resolve(ira->codegen, array_ptr->value->type->data.pointer.child_type, |
| 11706 | ResolveStatusAlignmentKnown))) | 12790 | ResolveStatusAlignmentKnown))) |
| 11707 | { | 12791 | { |
| 11708 | return ira->codegen->invalid_instruction; | 12792 | return ira->codegen->invalid_inst_gen; |
| 11709 | } | 12793 | } |
| 11710 | | 12794 | |
| 11711 | wanted_type = adjust_slice_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, array_ptr->value->type)); | 12795 | wanted_type = adjust_slice_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, array_ptr->value->type)); |
| ... | @@ -11713,17 +12797,17 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc | ... | @@ -11713,17 +12797,17 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc |
| 11713 | if (instr_is_comptime(array_ptr)) { | 12797 | if (instr_is_comptime(array_ptr)) { |
| 11714 | ZigValue *array_ptr_val = ir_resolve_const(ira, array_ptr, UndefBad); | 12798 | ZigValue *array_ptr_val = ir_resolve_const(ira, array_ptr, UndefBad); |
| 11715 | if (array_ptr_val == nullptr) | 12799 | if (array_ptr_val == nullptr) |
| 11716 | return ira->codegen->invalid_instruction; | 12800 | return ira->codegen->invalid_inst_gen; |
| 11717 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, array_ptr_val, source_instr->source_node); | 12801 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, array_ptr_val, source_instr->source_node); |
| 11718 | if (pointee == nullptr) | 12802 | if (pointee == nullptr) |
| 11719 | return ira->codegen->invalid_instruction; | 12803 | return ira->codegen->invalid_inst_gen; |
| 11720 | if (pointee->special != ConstValSpecialRuntime) { | 12804 | if (pointee->special != ConstValSpecialRuntime) { |
| 11721 | assert(array_ptr_val->type->id == ZigTypeIdPointer); | 12805 | assert(array_ptr_val->type->id == ZigTypeIdPointer); |
| 11722 | ZigType *array_type = array_ptr_val->type->data.pointer.child_type; | 12806 | ZigType *array_type = array_ptr_val->type->data.pointer.child_type; |
| 11723 | assert(is_slice(wanted_type)); | 12807 | assert(is_slice(wanted_type)); |
| 11724 | bool is_const = wanted_type->data.structure.fields[slice_ptr_index]->type_entry->data.pointer.is_const; | 12808 | bool is_const = wanted_type->data.structure.fields[slice_ptr_index]->type_entry->data.pointer.is_const; |
| 11725 | | 12809 | |
| 11726 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12810 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 11727 | init_const_slice(ira->codegen, result->value, pointee, 0, array_type->data.array.len, is_const); | 12811 | init_const_slice(ira->codegen, result->value, pointee, 0, array_type->data.array.len, is_const); |
| 11728 | result->value->data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; | 12812 | result->value->data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; |
| 11729 | result->value->type = wanted_type; | 12813 | result->value->type = wanted_type; |
| ... | @@ -11732,32 +12816,33 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc | ... | @@ -11732,32 +12816,33 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc |
| 11732 | } | 12816 | } |
| 11733 | | 12817 | |
| 11734 | if (result_loc == nullptr) result_loc = no_result_loc(); | 12818 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 11735 | IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, | 12819 | IrInstGen *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, true); |
| 11736 | nullptr, true, true); | 12820 | if (type_is_invalid(result_loc_inst->value->type) || |
| 11737 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { | 12821 | result_loc_inst->value->type->id == ZigTypeIdUnreachable) |
| | 12822 | { |
| 11738 | return result_loc_inst; | 12823 | return result_loc_inst; |
| 11739 | } | 12824 | } |
| 11740 | return ir_build_ptr_of_array_to_slice(ira, source_instr, wanted_type, array_ptr, result_loc_inst); | 12825 | return ir_build_ptr_of_array_to_slice(ira, source_instr, wanted_type, array_ptr, result_loc_inst); |
| 11741 | } | 12826 | } |
| 11742 | | 12827 | |
| 11743 | static IrBasicBlock *ir_get_new_bb(IrAnalyze *ira, IrBasicBlock *old_bb, IrInstruction *ref_old_instruction) { | 12828 | static IrBasicBlockGen *ir_get_new_bb(IrAnalyze *ira, IrBasicBlockSrc *old_bb, IrInst *ref_old_instruction) { |
| 11744 | assert(old_bb); | 12829 | assert(old_bb); |
| 11745 | | 12830 | |
| 11746 | if (old_bb->other) { | 12831 | if (old_bb->child) { |
| 11747 | if (ref_old_instruction == nullptr || old_bb->other->ref_instruction != ref_old_instruction) { | 12832 | if (ref_old_instruction == nullptr || old_bb->child->ref_instruction != ref_old_instruction) { |
| 11748 | return old_bb->other; | 12833 | return old_bb->child; |
| 11749 | } | 12834 | } |
| 11750 | } | 12835 | } |
| 11751 | | 12836 | |
| 11752 | IrBasicBlock *new_bb = ir_build_bb_from(&ira->new_irb, old_bb); | 12837 | IrBasicBlockGen *new_bb = ir_build_bb_from(ira, old_bb); |
| 11753 | new_bb->ref_instruction = ref_old_instruction; | 12838 | new_bb->ref_instruction = ref_old_instruction; |
| 11754 | | 12839 | |
| 11755 | return new_bb; | 12840 | return new_bb; |
| 11756 | } | 12841 | } |
| 11757 | | 12842 | |
| 11758 | static IrBasicBlock *ir_get_new_bb_runtime(IrAnalyze *ira, IrBasicBlock *old_bb, IrInstruction *ref_old_instruction) { | 12843 | static IrBasicBlockGen *ir_get_new_bb_runtime(IrAnalyze *ira, IrBasicBlockSrc *old_bb, IrInst *ref_old_instruction) { |
| 11759 | assert(ref_old_instruction != nullptr); | 12844 | assert(ref_old_instruction != nullptr); |
| 11760 | IrBasicBlock *new_bb = ir_get_new_bb(ira, old_bb, ref_old_instruction); | 12845 | IrBasicBlockGen *new_bb = ir_get_new_bb(ira, old_bb, ref_old_instruction); |
| 11761 | if (new_bb->must_be_comptime_source_instr) { | 12846 | if (new_bb->must_be_comptime_source_instr) { |
| 11762 | ErrorMsg *msg = ir_add_error(ira, ref_old_instruction, | 12847 | ErrorMsg *msg = ir_add_error(ira, ref_old_instruction, |
| 11763 | buf_sprintf("control flow attempts to use compile-time variable at runtime")); | 12848 | buf_sprintf("control flow attempts to use compile-time variable at runtime")); |
| ... | @@ -11768,24 +12853,24 @@ static IrBasicBlock *ir_get_new_bb_runtime(IrAnalyze *ira, IrBasicBlock *old_bb, | ... | @@ -11768,24 +12853,24 @@ static IrBasicBlock *ir_get_new_bb_runtime(IrAnalyze *ira, IrBasicBlock *old_bb, |
| 11768 | return new_bb; | 12853 | return new_bb; |
| 11769 | } | 12854 | } |
| 11770 | | 12855 | |
| 11771 | static void ir_start_bb(IrAnalyze *ira, IrBasicBlock *old_bb, IrBasicBlock *const_predecessor_bb) { | 12856 | static void ir_start_bb(IrAnalyze *ira, IrBasicBlockSrc *old_bb, IrBasicBlockSrc *const_predecessor_bb) { |
| 11772 | ir_assert(!old_bb->suspended, (old_bb->instruction_list.length != 0) ? old_bb->instruction_list.at(0) : nullptr); | 12857 | ir_assert(!old_bb->suspended, (old_bb->instruction_list.length != 0) ? &old_bb->instruction_list.at(0)->base : nullptr); |
| 11773 | ira->instruction_index = 0; | 12858 | ira->instruction_index = 0; |
| 11774 | ira->old_irb.current_basic_block = old_bb; | 12859 | ira->old_irb.current_basic_block = old_bb; |
| 11775 | ira->const_predecessor_bb = const_predecessor_bb; | 12860 | ira->const_predecessor_bb = const_predecessor_bb; |
| 11776 | ira->old_bb_index = old_bb->index; | 12861 | ira->old_bb_index = old_bb->index; |
| 11777 | } | 12862 | } |
| 11778 | | 12863 | |
| 11779 | static IrInstruction *ira_suspend(IrAnalyze *ira, IrInstruction *old_instruction, IrBasicBlock *next_bb, | 12864 | static IrInstGen *ira_suspend(IrAnalyze *ira, IrInst *old_instruction, IrBasicBlockSrc *next_bb, |
| 11780 | IrSuspendPosition *suspend_pos) | 12865 | IrSuspendPosition *suspend_pos) |
| 11781 | { | 12866 | { |
| 11782 | if (ira->codegen->verbose_ir) { | 12867 | if (ira->codegen->verbose_ir) { |
| 11783 | fprintf(stderr, "suspend %s_%zu %s_%zu #%" PRIu32 " (%zu,%zu)\n", | 12868 | fprintf(stderr, "suspend %s_%" PRIu32 " %s_%" PRIu32 " #%" PRIu32 " (%zu,%zu)\n", |
| 11784 | ira->old_irb.current_basic_block->name_hint, | 12869 | ira->old_irb.current_basic_block->name_hint, |
| 11785 | ira->old_irb.current_basic_block->debug_id, | 12870 | ira->old_irb.current_basic_block->debug_id, |
| 11786 | ira->old_irb.exec->basic_block_list.at(ira->old_bb_index)->name_hint, | 12871 | ira->old_irb.exec->basic_block_list.at(ira->old_bb_index)->name_hint, |
| 11787 | ira->old_irb.exec->basic_block_list.at(ira->old_bb_index)->debug_id, | 12872 | ira->old_irb.exec->basic_block_list.at(ira->old_bb_index)->debug_id, |
| 11788 | ira->old_irb.current_basic_block->instruction_list.at(ira->instruction_index)->debug_id, | 12873 | ira->old_irb.current_basic_block->instruction_list.at(ira->instruction_index)->base.debug_id, |
| 11789 | ira->old_bb_index, ira->instruction_index); | 12874 | ira->old_bb_index, ira->instruction_index); |
| 11790 | } | 12875 | } |
| 11791 | suspend_pos->basic_block_index = ira->old_bb_index; | 12876 | suspend_pos->basic_block_index = ira->old_bb_index; |
| ... | @@ -11800,13 +12885,13 @@ static IrInstruction *ira_suspend(IrAnalyze *ira, IrInstruction *old_instruction | ... | @@ -11800,13 +12885,13 @@ static IrInstruction *ira_suspend(IrAnalyze *ira, IrInstruction *old_instruction |
| 11800 | assert(ira->old_irb.current_basic_block == next_bb); | 12885 | assert(ira->old_irb.current_basic_block == next_bb); |
| 11801 | ira->instruction_index = 0; | 12886 | ira->instruction_index = 0; |
| 11802 | ira->const_predecessor_bb = nullptr; | 12887 | ira->const_predecessor_bb = nullptr; |
| 11803 | next_bb->other = ir_get_new_bb_runtime(ira, next_bb, old_instruction); | 12888 | next_bb->child = ir_get_new_bb_runtime(ira, next_bb, old_instruction); |
| 11804 | ira->new_irb.current_basic_block = next_bb->other; | 12889 | ira->new_irb.current_basic_block = next_bb->child; |
| 11805 | } | 12890 | } |
| 11806 | return ira->codegen->unreach_instruction; | 12891 | return ira->codegen->unreach_instruction; |
| 11807 | } | 12892 | } |
| 11808 | | 12893 | |
| 11809 | static IrInstruction *ira_resume(IrAnalyze *ira) { | 12894 | static IrInstGen *ira_resume(IrAnalyze *ira) { |
| 11810 | IrSuspendPosition pos = ira->resume_stack.pop(); | 12895 | IrSuspendPosition pos = ira->resume_stack.pop(); |
| 11811 | if (ira->codegen->verbose_ir) { | 12896 | if (ira->codegen->verbose_ir) { |
| 11812 | fprintf(stderr, "resume (%zu,%zu) ", pos.basic_block_index, pos.instruction_index); | 12897 | fprintf(stderr, "resume (%zu,%zu) ", pos.basic_block_index, pos.instruction_index); |
| ... | @@ -11819,12 +12904,12 @@ static IrInstruction *ira_resume(IrAnalyze *ira) { | ... | @@ -11819,12 +12904,12 @@ static IrInstruction *ira_resume(IrAnalyze *ira) { |
| 11819 | ira->instruction_index = pos.instruction_index; | 12904 | ira->instruction_index = pos.instruction_index; |
| 11820 | assert(pos.instruction_index < ira->old_irb.current_basic_block->instruction_list.length); | 12905 | assert(pos.instruction_index < ira->old_irb.current_basic_block->instruction_list.length); |
| 11821 | if (ira->codegen->verbose_ir) { | 12906 | if (ira->codegen->verbose_ir) { |
| 11822 | fprintf(stderr, "%s_%zu #%" PRIu32 "\n", ira->old_irb.current_basic_block->name_hint, | 12907 | fprintf(stderr, "%s_%" PRIu32 " #%" PRIu32 "\n", ira->old_irb.current_basic_block->name_hint, |
| 11823 | ira->old_irb.current_basic_block->debug_id, | 12908 | ira->old_irb.current_basic_block->debug_id, |
| 11824 | ira->old_irb.current_basic_block->instruction_list.at(pos.instruction_index)->debug_id); | 12909 | ira->old_irb.current_basic_block->instruction_list.at(pos.instruction_index)->base.debug_id); |
| 11825 | } | 12910 | } |
| 11826 | ira->const_predecessor_bb = nullptr; | 12911 | ira->const_predecessor_bb = nullptr; |
| 11827 | ira->new_irb.current_basic_block = ira->old_irb.current_basic_block->other; | 12912 | ira->new_irb.current_basic_block = ira->old_irb.current_basic_block->child; |
| 11828 | assert(ira->new_irb.current_basic_block != nullptr); | 12913 | assert(ira->new_irb.current_basic_block != nullptr); |
| 11829 | return ira->codegen->unreach_instruction; | 12914 | return ira->codegen->unreach_instruction; |
| 11830 | } | 12915 | } |
| ... | @@ -11835,8 +12920,8 @@ static void ir_start_next_bb(IrAnalyze *ira) { | ... | @@ -11835,8 +12920,8 @@ static void ir_start_next_bb(IrAnalyze *ira) { |
| 11835 | bool need_repeat = true; | 12920 | bool need_repeat = true; |
| 11836 | for (;;) { | 12921 | for (;;) { |
| 11837 | while (ira->old_bb_index < ira->old_irb.exec->basic_block_list.length) { | 12922 | while (ira->old_bb_index < ira->old_irb.exec->basic_block_list.length) { |
| 11838 | IrBasicBlock *old_bb = ira->old_irb.exec->basic_block_list.at(ira->old_bb_index); | 12923 | IrBasicBlockSrc *old_bb = ira->old_irb.exec->basic_block_list.at(ira->old_bb_index); |
| 11839 | if (old_bb->other == nullptr && old_bb->suspend_instruction_ref == nullptr) { | 12924 | if (old_bb->child == nullptr && old_bb->suspend_instruction_ref == nullptr) { |
| 11840 | ira->old_bb_index += 1; | 12925 | ira->old_bb_index += 1; |
| 11841 | continue; | 12926 | continue; |
| 11842 | } | 12927 | } |
| ... | @@ -11844,8 +12929,8 @@ static void ir_start_next_bb(IrAnalyze *ira) { | ... | @@ -11844,8 +12929,8 @@ static void ir_start_next_bb(IrAnalyze *ira) { |
| 11844 | // if it's a suspended block, | 12929 | // if it's a suspended block, |
| 11845 | // then skip it | 12930 | // then skip it |
| 11846 | if (old_bb->suspended || | 12931 | if (old_bb->suspended || |
| 11847 | (old_bb->other != nullptr && old_bb->other->instruction_list.length != 0) || | 12932 | (old_bb->child != nullptr && old_bb->child->instruction_list.length != 0) || |
| 11848 | (old_bb->other != nullptr && old_bb->other->already_appended)) | 12933 | (old_bb->child != nullptr && old_bb->child->already_appended)) |
| 11849 | { | 12934 | { |
| 11850 | ira->old_bb_index += 1; | 12935 | ira->old_bb_index += 1; |
| 11851 | continue; | 12936 | continue; |
| ... | @@ -11859,10 +12944,10 @@ static void ir_start_next_bb(IrAnalyze *ira) { | ... | @@ -11859,10 +12944,10 @@ static void ir_start_next_bb(IrAnalyze *ira) { |
| 11859 | return; | 12944 | return; |
| 11860 | } | 12945 | } |
| 11861 | | 12946 | |
| 11862 | if (old_bb->other == nullptr) { | 12947 | if (old_bb->child == nullptr) { |
| 11863 | old_bb->other = ir_get_new_bb_runtime(ira, old_bb, old_bb->suspend_instruction_ref); | 12948 | old_bb->child = ir_get_new_bb_runtime(ira, old_bb, old_bb->suspend_instruction_ref); |
| 11864 | } | 12949 | } |
| 11865 | ira->new_irb.current_basic_block = old_bb->other; | 12950 | ira->new_irb.current_basic_block = old_bb->child; |
| 11866 | ir_start_bb(ira, old_bb, nullptr); | 12951 | ir_start_bb(ira, old_bb, nullptr); |
| 11867 | return; | 12952 | return; |
| 11868 | } | 12953 | } |
| ... | @@ -11882,16 +12967,16 @@ static void ir_finish_bb(IrAnalyze *ira) { | ... | @@ -11882,16 +12967,16 @@ static void ir_finish_bb(IrAnalyze *ira) { |
| 11882 | if (!ira->new_irb.current_basic_block->already_appended) { | 12967 | if (!ira->new_irb.current_basic_block->already_appended) { |
| 11883 | ira->new_irb.current_basic_block->already_appended = true; | 12968 | ira->new_irb.current_basic_block->already_appended = true; |
| 11884 | if (ira->codegen->verbose_ir) { | 12969 | if (ira->codegen->verbose_ir) { |
| 11885 | fprintf(stderr, "append new bb %s_%zu\n", ira->new_irb.current_basic_block->name_hint, | 12970 | fprintf(stderr, "append new bb %s_%" PRIu32 "\n", ira->new_irb.current_basic_block->name_hint, |
| 11886 | ira->new_irb.current_basic_block->debug_id); | 12971 | ira->new_irb.current_basic_block->debug_id); |
| 11887 | } | 12972 | } |
| 11888 | ira->new_irb.exec->basic_block_list.append(ira->new_irb.current_basic_block); | 12973 | ira->new_irb.exec->basic_block_list.append(ira->new_irb.current_basic_block); |
| 11889 | } | 12974 | } |
| 11890 | ira->instruction_index += 1; | 12975 | ira->instruction_index += 1; |
| 11891 | while (ira->instruction_index < ira->old_irb.current_basic_block->instruction_list.length) { | 12976 | while (ira->instruction_index < ira->old_irb.current_basic_block->instruction_list.length) { |
| 11892 | IrInstruction *next_instruction = ira->old_irb.current_basic_block->instruction_list.at(ira->instruction_index); | 12977 | IrInstSrc *next_instruction = ira->old_irb.current_basic_block->instruction_list.at(ira->instruction_index); |
| 11893 | if (!next_instruction->is_gen) { | 12978 | if (!next_instruction->is_gen) { |
| 11894 | ir_add_error(ira, next_instruction, buf_sprintf("unreachable code")); | 12979 | ir_add_error(ira, &next_instruction->base, buf_sprintf("unreachable code")); |
| 11895 | break; | 12980 | break; |
| 11896 | } | 12981 | } |
| 11897 | ira->instruction_index += 1; | 12982 | ira->instruction_index += 1; |
| ... | @@ -11900,7 +12985,7 @@ static void ir_finish_bb(IrAnalyze *ira) { | ... | @@ -11900,7 +12985,7 @@ static void ir_finish_bb(IrAnalyze *ira) { |
| 11900 | ir_start_next_bb(ira); | 12985 | ir_start_next_bb(ira); |
| 11901 | } | 12986 | } |
| 11902 | | 12987 | |
| 11903 | static IrInstruction *ir_unreach_error(IrAnalyze *ira) { | 12988 | static IrInstGen *ir_unreach_error(IrAnalyze *ira) { |
| 11904 | ira->old_bb_index = SIZE_MAX; | 12989 | ira->old_bb_index = SIZE_MAX; |
| 11905 | if (ira->new_irb.exec->first_err_trace_msg == nullptr) { | 12990 | if (ira->new_irb.exec->first_err_trace_msg == nullptr) { |
| 11906 | ira->new_irb.exec->first_err_trace_msg = ira->codegen->trace_err; | 12991 | ira->new_irb.exec->first_err_trace_msg = ira->codegen->trace_err; |
| ... | @@ -11908,7 +12993,7 @@ static IrInstruction *ir_unreach_error(IrAnalyze *ira) { | ... | @@ -11908,7 +12993,7 @@ static IrInstruction *ir_unreach_error(IrAnalyze *ira) { |
| 11908 | return ira->codegen->unreach_instruction; | 12993 | return ira->codegen->unreach_instruction; |
| 11909 | } | 12994 | } |
| 11910 | | 12995 | |
| 11911 | static bool ir_emit_backward_branch(IrAnalyze *ira, IrInstruction *source_instruction) { | 12996 | static bool ir_emit_backward_branch(IrAnalyze *ira, IrInst* source_instruction) { |
| 11912 | size_t *bbc = ira->new_irb.exec->backward_branch_count; | 12997 | size_t *bbc = ira->new_irb.exec->backward_branch_count; |
| 11913 | size_t *quota = ira->new_irb.exec->backward_branch_quota; | 12998 | size_t *quota = ira->new_irb.exec->backward_branch_quota; |
| 11914 | | 12999 | |
| ... | @@ -11927,66 +13012,82 @@ static bool ir_emit_backward_branch(IrAnalyze *ira, IrInstruction *source_instru | ... | @@ -11927,66 +13012,82 @@ static bool ir_emit_backward_branch(IrAnalyze *ira, IrInstruction *source_instru |
| 11927 | return true; | 13012 | return true; |
| 11928 | } | 13013 | } |
| 11929 | | 13014 | |
| 11930 | static IrInstruction *ir_inline_bb(IrAnalyze *ira, IrInstruction *source_instruction, IrBasicBlock *old_bb) { | 13015 | static IrInstGen *ir_inline_bb(IrAnalyze *ira, IrInst* source_instruction, IrBasicBlockSrc *old_bb) { |
| 11931 | if (old_bb->debug_id <= ira->old_irb.current_basic_block->debug_id) { | 13016 | if (old_bb->debug_id <= ira->old_irb.current_basic_block->debug_id) { |
| 11932 | if (!ir_emit_backward_branch(ira, source_instruction)) | 13017 | if (!ir_emit_backward_branch(ira, source_instruction)) |
| 11933 | return ir_unreach_error(ira); | 13018 | return ir_unreach_error(ira); |
| 11934 | } | 13019 | } |
| 11935 | | 13020 | |
| 11936 | old_bb->other = ira->old_irb.current_basic_block->other; | 13021 | old_bb->child = ira->old_irb.current_basic_block->child; |
| 11937 | ir_start_bb(ira, old_bb, ira->old_irb.current_basic_block); | 13022 | ir_start_bb(ira, old_bb, ira->old_irb.current_basic_block); |
| 11938 | return ira->codegen->unreach_instruction; | 13023 | return ira->codegen->unreach_instruction; |
| 11939 | } | 13024 | } |
| 11940 | | 13025 | |
| 11941 | static IrInstruction *ir_finish_anal(IrAnalyze *ira, IrInstruction *instruction) { | 13026 | static IrInstGen *ir_finish_anal(IrAnalyze *ira, IrInstGen *instruction) { |
| 11942 | if (instruction->value->type->id == ZigTypeIdUnreachable) | 13027 | if (instruction->value->type->id == ZigTypeIdUnreachable) |
| 11943 | ir_finish_bb(ira); | 13028 | ir_finish_bb(ira); |
| 11944 | return instruction; | 13029 | return instruction; |
| 11945 | } | 13030 | } |
| 11946 | | 13031 | |
| 11947 | static IrInstruction *ir_const_type(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) { | 13032 | static IrInstGen *ir_const_fn(IrAnalyze *ira, IrInst *source_instr, ZigFn *fn_entry) { |
| 11948 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_type); | 13033 | IrInstGen *result = ir_const(ira, source_instr, fn_entry->type_entry); |
| | 13034 | result->value->special = ConstValSpecialStatic; |
| | 13035 | result->value->data.x_ptr.data.fn.fn_entry = fn_entry; |
| | 13036 | result->value->data.x_ptr.mut = ConstPtrMutComptimeConst; |
| | 13037 | result->value->data.x_ptr.special = ConstPtrSpecialFunction; |
| | 13038 | return result; |
| | 13039 | } |
| | 13040 | |
| | 13041 | static IrInstGen *ir_const_bound_fn(IrAnalyze *ira, IrInst *src_inst, ZigFn *fn_entry, IrInstGen *first_arg) { |
| | 13042 | IrInstGen *result = ir_const(ira, src_inst, get_bound_fn_type(ira->codegen, fn_entry)); |
| | 13043 | result->value->data.x_bound_fn.fn = fn_entry; |
| | 13044 | result->value->data.x_bound_fn.first_arg = first_arg; |
| | 13045 | return result; |
| | 13046 | } |
| | 13047 | |
| | 13048 | static IrInstGen *ir_const_type(IrAnalyze *ira, IrInst *source_instruction, ZigType *ty) { |
| | 13049 | IrInstGen *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_type); |
| 11949 | result->value->data.x_type = ty; | 13050 | result->value->data.x_type = ty; |
| 11950 | return result; | 13051 | return result; |
| 11951 | } | 13052 | } |
| 11952 | | 13053 | |
| 11953 | static IrInstruction *ir_const_bool(IrAnalyze *ira, IrInstruction *source_instruction, bool value) { | 13054 | static IrInstGen *ir_const_bool(IrAnalyze *ira, IrInst *source_instruction, bool value) { |
| 11954 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_bool); | 13055 | IrInstGen *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_bool); |
| 11955 | result->value->data.x_bool = value; | 13056 | result->value->data.x_bool = value; |
| 11956 | return result; | 13057 | return result; |
| 11957 | } | 13058 | } |
| 11958 | | 13059 | |
| 11959 | static IrInstruction *ir_const_undef(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) { | 13060 | static IrInstGen *ir_const_undef(IrAnalyze *ira, IrInst *source_instruction, ZigType *ty) { |
| 11960 | IrInstruction *result = ir_const(ira, source_instruction, ty); | 13061 | IrInstGen *result = ir_const(ira, source_instruction, ty); |
| 11961 | result->value->special = ConstValSpecialUndef; | 13062 | result->value->special = ConstValSpecialUndef; |
| 11962 | return result; | 13063 | return result; |
| 11963 | } | 13064 | } |
| 11964 | | 13065 | |
| 11965 | static IrInstruction *ir_const_unreachable(IrAnalyze *ira, IrInstruction *source_instruction) { | 13066 | static IrInstGen *ir_const_unreachable(IrAnalyze *ira, IrInst *source_instruction) { |
| 11966 | IrInstruction *result = ir_const_noval(ira, source_instruction); | 13067 | IrInstGen *result = ir_const_noval(ira, source_instruction); |
| 11967 | result->value = ira->codegen->intern.for_unreachable(); | 13068 | result->value = ira->codegen->intern.for_unreachable(); |
| 11968 | return result; | 13069 | return result; |
| 11969 | } | 13070 | } |
| 11970 | | 13071 | |
| 11971 | static IrInstruction *ir_const_void(IrAnalyze *ira, IrInstruction *source_instruction) { | 13072 | static IrInstGen *ir_const_void(IrAnalyze *ira, IrInst *source_instruction) { |
| 11972 | IrInstruction *result = ir_const_noval(ira, source_instruction); | 13073 | IrInstGen *result = ir_const_noval(ira, source_instruction); |
| 11973 | result->value = ira->codegen->intern.for_void(); | 13074 | result->value = ira->codegen->intern.for_void(); |
| 11974 | return result; | 13075 | return result; |
| 11975 | } | 13076 | } |
| 11976 | | 13077 | |
| 11977 | static IrInstruction *ir_const_unsigned(IrAnalyze *ira, IrInstruction *source_instruction, uint64_t value) { | 13078 | static IrInstGen *ir_const_unsigned(IrAnalyze *ira, IrInst *source_instruction, uint64_t value) { |
| 11978 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_num_lit_int); | 13079 | IrInstGen *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_num_lit_int); |
| 11979 | bigint_init_unsigned(&result->value->data.x_bigint, value); | 13080 | bigint_init_unsigned(&result->value->data.x_bigint, value); |
| 11980 | return result; | 13081 | return result; |
| 11981 | } | 13082 | } |
| 11982 | | 13083 | |
| 11983 | static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instruction, | 13084 | static IrInstGen *ir_get_const_ptr(IrAnalyze *ira, IrInst *instruction, |
| 11984 | ZigValue *pointee, ZigType *pointee_type, | 13085 | ZigValue *pointee, ZigType *pointee_type, |
| 11985 | ConstPtrMut ptr_mut, bool ptr_is_const, bool ptr_is_volatile, uint32_t ptr_align) | 13086 | ConstPtrMut ptr_mut, bool ptr_is_const, bool ptr_is_volatile, uint32_t ptr_align) |
| 11986 | { | 13087 | { |
| 11987 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type, | 13088 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type, |
| 11988 | ptr_is_const, ptr_is_volatile, PtrLenSingle, ptr_align, 0, 0, false); | 13089 | ptr_is_const, ptr_is_volatile, PtrLenSingle, ptr_align, 0, 0, false); |
| 11989 | IrInstruction *const_instr = ir_const(ira, instruction, ptr_type); | 13090 | IrInstGen *const_instr = ir_const(ira, instruction, ptr_type); |
| 11990 | ZigValue *const_val = const_instr->value; | 13091 | ZigValue *const_val = const_instr->value; |
| 11991 | const_val->data.x_ptr.special = ConstPtrSpecialRef; | 13092 | const_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 11992 | const_val->data.x_ptr.mut = ptr_mut; | 13093 | const_val->data.x_ptr.mut = ptr_mut; |
| ... | @@ -11994,7 +13095,7 @@ static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instructio | ... | @@ -11994,7 +13095,7 @@ static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instructio |
| 11994 | return const_instr; | 13095 | return const_instr; |
| 11995 | } | 13096 | } |
| 11996 | | 13097 | |
| 11997 | static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, | 13098 | static Error ir_resolve_const_val(CodeGen *codegen, IrExecutableGen *exec, AstNode *source_node, |
| 11998 | ZigValue *val, UndefAllowed undef_allowed) | 13099 | ZigValue *val, UndefAllowed undef_allowed) |
| 11999 | { | 13100 | { |
| 12000 | Error err; | 13101 | Error err; |
| ... | @@ -12006,14 +13107,14 @@ static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode | ... | @@ -12006,14 +13107,14 @@ static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode |
| 12006 | if (!type_has_bits(val->type)) | 13107 | if (!type_has_bits(val->type)) |
| 12007 | return ErrorNone; | 13108 | return ErrorNone; |
| 12008 | | 13109 | |
| 12009 | exec_add_error_node(codegen, exec, source_node, | 13110 | exec_add_error_node_gen(codegen, exec, source_node, |
| 12010 | buf_sprintf("unable to evaluate constant expression")); | 13111 | buf_sprintf("unable to evaluate constant expression")); |
| 12011 | return ErrorSemanticAnalyzeFail; | 13112 | return ErrorSemanticAnalyzeFail; |
| 12012 | case ConstValSpecialUndef: | 13113 | case ConstValSpecialUndef: |
| 12013 | if (undef_allowed == UndefOk || undef_allowed == LazyOk) | 13114 | if (undef_allowed == UndefOk || undef_allowed == LazyOk) |
| 12014 | return ErrorNone; | 13115 | return ErrorNone; |
| 12015 | | 13116 | |
| 12016 | exec_add_error_node(codegen, exec, source_node, | 13117 | exec_add_error_node_gen(codegen, exec, source_node, |
| 12017 | buf_sprintf("use of undefined value here causes undefined behavior")); | 13118 | buf_sprintf("use of undefined value here causes undefined behavior")); |
| 12018 | return ErrorSemanticAnalyzeFail; | 13119 | return ErrorSemanticAnalyzeFail; |
| 12019 | case ConstValSpecialLazy: | 13120 | case ConstValSpecialLazy: |
| ... | @@ -12028,9 +13129,9 @@ static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode | ... | @@ -12028,9 +13129,9 @@ static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode |
| 12028 | } | 13129 | } |
| 12029 | } | 13130 | } |
| 12030 | | 13131 | |
| 12031 | static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed) { | 13132 | static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstGen *value, UndefAllowed undef_allowed) { |
| 12032 | Error err; | 13133 | Error err; |
| 12033 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, value->source_node, | 13134 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, value->base.source_node, |
| 12034 | value->value, undef_allowed))) | 13135 | value->value, undef_allowed))) |
| 12035 | { | 13136 | { |
| 12036 | return nullptr; | 13137 | return nullptr; |
| ... | @@ -12041,7 +13142,7 @@ static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAll | ... | @@ -12041,7 +13142,7 @@ static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAll |
| 12041 | Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | 13142 | Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 12042 | ZigValue *return_ptr, size_t *backward_branch_count, size_t *backward_branch_quota, | 13143 | ZigValue *return_ptr, size_t *backward_branch_count, size_t *backward_branch_quota, |
| 12043 | ZigFn *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name, | 13144 | ZigFn *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name, |
| 12044 | IrExecutable *parent_exec, AstNode *expected_type_source_node, UndefAllowed undef_allowed) | 13145 | IrExecutableGen *parent_exec, AstNode *expected_type_source_node, UndefAllowed undef_allowed) |
| 12045 | { | 13146 | { |
| 12046 | Error err; | 13147 | Error err; |
| 12047 | | 13148 | |
| ... | @@ -12050,7 +13151,7 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | ... | @@ -12050,7 +13151,7 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 12050 | if (type_is_invalid(return_ptr->type)) | 13151 | if (type_is_invalid(return_ptr->type)) |
| 12051 | return ErrorSemanticAnalyzeFail; | 13152 | return ErrorSemanticAnalyzeFail; |
| 12052 | | 13153 | |
| 12053 | IrExecutable *ir_executable = allocate<IrExecutable>(1, "IrExecutablePass1"); | 13154 | IrExecutableSrc *ir_executable = allocate<IrExecutableSrc>(1, "IrExecutableSrc"); |
| 12054 | ir_executable->source_node = source_node; | 13155 | ir_executable->source_node = source_node; |
| 12055 | ir_executable->parent_exec = parent_exec; | 13156 | ir_executable->parent_exec = parent_exec; |
| 12056 | ir_executable->name = exec_name; | 13157 | ir_executable->name = exec_name; |
| ... | @@ -12071,10 +13172,10 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | ... | @@ -12071,10 +13172,10 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 12071 | fprintf(stderr, "\nSource: "); | 13172 | fprintf(stderr, "\nSource: "); |
| 12072 | ast_render(stderr, node, 4); | 13173 | ast_render(stderr, node, 4); |
| 12073 | fprintf(stderr, "\n{ // (IR)\n"); | 13174 | fprintf(stderr, "\n{ // (IR)\n"); |
| 12074 | ir_print(codegen, stderr, ir_executable, 2, IrPassSrc); | 13175 | ir_print_src(codegen, stderr, ir_executable, 2); |
| 12075 | fprintf(stderr, "}\n"); | 13176 | fprintf(stderr, "}\n"); |
| 12076 | } | 13177 | } |
| 12077 | IrExecutable *analyzed_executable = allocate<IrExecutable>(1, "IrExecutablePass2"); | 13178 | IrExecutableGen *analyzed_executable = allocate<IrExecutableGen>(1, "IrExecutableGen"); |
| 12078 | analyzed_executable->source_node = source_node; | 13179 | analyzed_executable->source_node = source_node; |
| 12079 | analyzed_executable->parent_exec = parent_exec; | 13180 | analyzed_executable->parent_exec = parent_exec; |
| 12080 | analyzed_executable->source_exec = ir_executable; | 13181 | analyzed_executable->source_exec = ir_executable; |
| ... | @@ -12093,7 +13194,7 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | ... | @@ -12093,7 +13194,7 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 12093 | | 13194 | |
| 12094 | if (codegen->verbose_ir) { | 13195 | if (codegen->verbose_ir) { |
| 12095 | fprintf(stderr, "{ // (analyzed)\n"); | 13196 | fprintf(stderr, "{ // (analyzed)\n"); |
| 12096 | ir_print(codegen, stderr, analyzed_executable, 2, IrPassGen); | 13197 | ir_print_gen(codegen, stderr, analyzed_executable, 2); |
| 12097 | fprintf(stderr, "}\n"); | 13198 | fprintf(stderr, "}\n"); |
| 12098 | } | 13199 | } |
| 12099 | | 13200 | |
| ... | @@ -12109,12 +13210,12 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | ... | @@ -12109,12 +13210,12 @@ Error ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 12109 | return ErrorNone; | 13210 | return ErrorNone; |
| 12110 | } | 13211 | } |
| 12111 | | 13212 | |
| 12112 | static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_value) { | 13213 | static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstGen *err_value) { |
| 12113 | if (type_is_invalid(err_value->value->type)) | 13214 | if (type_is_invalid(err_value->value->type)) |
| 12114 | return nullptr; | 13215 | return nullptr; |
| 12115 | | 13216 | |
| 12116 | if (err_value->value->type->id != ZigTypeIdErrorSet) { | 13217 | if (err_value->value->type->id != ZigTypeIdErrorSet) { |
| 12117 | ir_add_error(ira, err_value, | 13218 | ir_add_error_node(ira, err_value->base.source_node, |
| 12118 | buf_sprintf("expected error, found '%s'", buf_ptr(&err_value->value->type->name))); | 13219 | buf_sprintf("expected error, found '%s'", buf_ptr(&err_value->value->type->name))); |
| 12119 | return nullptr; | 13220 | return nullptr; |
| 12120 | } | 13221 | } |
| ... | @@ -12127,7 +13228,7 @@ static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_valu | ... | @@ -12127,7 +13228,7 @@ static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_valu |
| 12127 | return const_val->data.x_err_set; | 13228 | return const_val->data.x_err_set; |
| 12128 | } | 13229 | } |
| 12129 | | 13230 | |
| 12130 | static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, | 13231 | static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutableGen *exec, AstNode *source_node, |
| 12131 | ZigValue *val) | 13232 | ZigValue *val) |
| 12132 | { | 13233 | { |
| 12133 | Error err; | 13234 | Error err; |
| ... | @@ -12138,18 +13239,18 @@ static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstN | ... | @@ -12138,18 +13239,18 @@ static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstN |
| 12138 | return val->data.x_type; | 13239 | return val->data.x_type; |
| 12139 | } | 13240 | } |
| 12140 | | 13241 | |
| 12141 | static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_value) { | 13242 | static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstGen *type_value) { |
| 12142 | if (type_is_invalid(type_value->value->type)) | 13243 | if (type_is_invalid(type_value->value->type)) |
| 12143 | return nullptr; | 13244 | return nullptr; |
| 12144 | | 13245 | |
| 12145 | if (type_value->value->type->id != ZigTypeIdMetaType) { | 13246 | if (type_value->value->type->id != ZigTypeIdMetaType) { |
| 12146 | ir_add_error(ira, type_value, | 13247 | ir_add_error_node(ira, type_value->base.source_node, |
| 12147 | buf_sprintf("expected type 'type', found '%s'", buf_ptr(&type_value->value->type->name))); | 13248 | buf_sprintf("expected type 'type', found '%s'", buf_ptr(&type_value->value->type->name))); |
| 12148 | return nullptr; | 13249 | return nullptr; |
| 12149 | } | 13250 | } |
| 12150 | | 13251 | |
| 12151 | Error err; | 13252 | Error err; |
| 12152 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, type_value->source_node, | 13253 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, type_value->base.source_node, |
| 12153 | type_value->value, LazyOk))) | 13254 | type_value->value, LazyOk))) |
| 12154 | { | 13255 | { |
| 12155 | return nullptr; | 13256 | return nullptr; |
| ... | @@ -12158,17 +13259,17 @@ static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_value) | ... | @@ -12158,17 +13259,17 @@ static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_value) |
| 12158 | return type_value->value; | 13259 | return type_value->value; |
| 12159 | } | 13260 | } |
| 12160 | | 13261 | |
| 12161 | static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { | 13262 | static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstGen *type_value) { |
| 12162 | ZigValue *val = ir_resolve_type_lazy(ira, type_value); | 13263 | ZigValue *val = ir_resolve_type_lazy(ira, type_value); |
| 12163 | if (val == nullptr) | 13264 | if (val == nullptr) |
| 12164 | return ira->codegen->builtin_types.entry_invalid; | 13265 | return ira->codegen->builtin_types.entry_invalid; |
| 12165 | | 13266 | |
| 12166 | return ir_resolve_const_type(ira->codegen, ira->new_irb.exec, type_value->source_node, val); | 13267 | return ir_resolve_const_type(ira->codegen, ira->new_irb.exec, type_value->base.source_node, val); |
| 12167 | } | 13268 | } |
| 12168 | | 13269 | |
| 12169 | static Error ir_validate_vector_elem_type(IrAnalyze *ira, IrInstruction *source_instr, ZigType *elem_type) { | 13270 | static Error ir_validate_vector_elem_type(IrAnalyze *ira, AstNode *source_node, ZigType *elem_type) { |
| 12170 | if (!is_valid_vector_elem_type(elem_type)) { | 13271 | if (!is_valid_vector_elem_type(elem_type)) { |
| 12171 | ir_add_error(ira, source_instr, | 13272 | ir_add_error_node(ira, source_node, |
| 12172 | buf_sprintf("vector element type must be integer, float, bool, or pointer; '%s' is invalid", | 13273 | buf_sprintf("vector element type must be integer, float, bool, or pointer; '%s' is invalid", |
| 12173 | buf_ptr(&elem_type->name))); | 13274 | buf_ptr(&elem_type->name))); |
| 12174 | return ErrorSemanticAnalyzeFail; | 13275 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -12176,28 +13277,28 @@ static Error ir_validate_vector_elem_type(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -12176,28 +13277,28 @@ static Error ir_validate_vector_elem_type(IrAnalyze *ira, IrInstruction *source_ |
| 12176 | return ErrorNone; | 13277 | return ErrorNone; |
| 12177 | } | 13278 | } |
| 12178 | | 13279 | |
| 12179 | static ZigType *ir_resolve_vector_elem_type(IrAnalyze *ira, IrInstruction *elem_type_value) { | 13280 | static ZigType *ir_resolve_vector_elem_type(IrAnalyze *ira, IrInstGen *elem_type_value) { |
| 12180 | Error err; | 13281 | Error err; |
| 12181 | ZigType *elem_type = ir_resolve_type(ira, elem_type_value); | 13282 | ZigType *elem_type = ir_resolve_type(ira, elem_type_value); |
| 12182 | if (type_is_invalid(elem_type)) | 13283 | if (type_is_invalid(elem_type)) |
| 12183 | return ira->codegen->builtin_types.entry_invalid; | 13284 | return ira->codegen->builtin_types.entry_invalid; |
| 12184 | if ((err = ir_validate_vector_elem_type(ira, elem_type_value, elem_type))) | 13285 | if ((err = ir_validate_vector_elem_type(ira, elem_type_value->base.source_node, elem_type))) |
| 12185 | return ira->codegen->builtin_types.entry_invalid; | 13286 | return ira->codegen->builtin_types.entry_invalid; |
| 12186 | return elem_type; | 13287 | return elem_type; |
| 12187 | } | 13288 | } |
| 12188 | | 13289 | |
| 12189 | static ZigType *ir_resolve_int_type(IrAnalyze *ira, IrInstruction *type_value) { | 13290 | static ZigType *ir_resolve_int_type(IrAnalyze *ira, IrInstGen *type_value) { |
| 12190 | ZigType *ty = ir_resolve_type(ira, type_value); | 13291 | ZigType *ty = ir_resolve_type(ira, type_value); |
| 12191 | if (type_is_invalid(ty)) | 13292 | if (type_is_invalid(ty)) |
| 12192 | return ira->codegen->builtin_types.entry_invalid; | 13293 | return ira->codegen->builtin_types.entry_invalid; |
| 12193 | | 13294 | |
| 12194 | if (ty->id != ZigTypeIdInt) { | 13295 | if (ty->id != ZigTypeIdInt) { |
| 12195 | ErrorMsg *msg = ir_add_error(ira, type_value, | 13296 | ErrorMsg *msg = ir_add_error_node(ira, type_value->base.source_node, |
| 12196 | buf_sprintf("expected integer type, found '%s'", buf_ptr(&ty->name))); | 13297 | buf_sprintf("expected integer type, found '%s'", buf_ptr(&ty->name))); |
| 12197 | if (ty->id == ZigTypeIdVector && | 13298 | if (ty->id == ZigTypeIdVector && |
| 12198 | ty->data.vector.elem_type->id == ZigTypeIdInt) | 13299 | ty->data.vector.elem_type->id == ZigTypeIdInt) |
| 12199 | { | 13300 | { |
| 12200 | add_error_note(ira->codegen, msg, type_value->source_node, | 13301 | add_error_note(ira->codegen, msg, type_value->base.source_node, |
| 12201 | buf_sprintf("represent vectors with their element types, i.e. '%s'", | 13302 | buf_sprintf("represent vectors with their element types, i.e. '%s'", |
| 12202 | buf_ptr(&ty->data.vector.elem_type->name))); | 13303 | buf_ptr(&ty->data.vector.elem_type->name))); |
| 12203 | } | 13304 | } |
| ... | @@ -12207,12 +13308,12 @@ static ZigType *ir_resolve_int_type(IrAnalyze *ira, IrInstruction *type_value) { | ... | @@ -12207,12 +13308,12 @@ static ZigType *ir_resolve_int_type(IrAnalyze *ira, IrInstruction *type_value) { |
| 12207 | return ty; | 13308 | return ty; |
| 12208 | } | 13309 | } |
| 12209 | | 13310 | |
| 12210 | static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_source, IrInstruction *type_value) { | 13311 | static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInst *op_source, IrInstGen *type_value) { |
| 12211 | if (type_is_invalid(type_value->value->type)) | 13312 | if (type_is_invalid(type_value->value->type)) |
| 12212 | return ira->codegen->builtin_types.entry_invalid; | 13313 | return ira->codegen->builtin_types.entry_invalid; |
| 12213 | | 13314 | |
| 12214 | if (type_value->value->type->id != ZigTypeIdMetaType) { | 13315 | if (type_value->value->type->id != ZigTypeIdMetaType) { |
| 12215 | ErrorMsg *msg = ir_add_error(ira, type_value, | 13316 | ErrorMsg *msg = ir_add_error_node(ira, type_value->base.source_node, |
| 12216 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&type_value->value->type->name))); | 13317 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&type_value->value->type->name))); |
| 12217 | add_error_note(ira->codegen, msg, op_source->source_node, | 13318 | add_error_note(ira->codegen, msg, op_source->source_node, |
| 12218 | buf_sprintf("`||` merges error sets; `or` performs boolean OR")); | 13319 | buf_sprintf("`||` merges error sets; `or` performs boolean OR")); |
| ... | @@ -12226,7 +13327,7 @@ static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_sour | ... | @@ -12226,7 +13327,7 @@ static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_sour |
| 12226 | assert(const_val->data.x_type != nullptr); | 13327 | assert(const_val->data.x_type != nullptr); |
| 12227 | ZigType *result_type = const_val->data.x_type; | 13328 | ZigType *result_type = const_val->data.x_type; |
| 12228 | if (result_type->id != ZigTypeIdErrorSet) { | 13329 | if (result_type->id != ZigTypeIdErrorSet) { |
| 12229 | ErrorMsg *msg = ir_add_error(ira, type_value, | 13330 | ErrorMsg *msg = ir_add_error_node(ira, type_value->base.source_node, |
| 12230 | buf_sprintf("expected error set type, found type '%s'", buf_ptr(&result_type->name))); | 13331 | buf_sprintf("expected error set type, found type '%s'", buf_ptr(&result_type->name))); |
| 12231 | add_error_note(ira->codegen, msg, op_source->source_node, | 13332 | add_error_note(ira->codegen, msg, op_source->source_node, |
| 12232 | buf_sprintf("`||` merges error sets; `or` performs boolean OR")); | 13333 | buf_sprintf("`||` merges error sets; `or` performs boolean OR")); |
| ... | @@ -12235,15 +13336,12 @@ static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_sour | ... | @@ -12235,15 +13336,12 @@ static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_sour |
| 12235 | return result_type; | 13336 | return result_type; |
| 12236 | } | 13337 | } |
| 12237 | | 13338 | |
| 12238 | static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { | 13339 | static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstGen *fn_value) { |
| 12239 | if (fn_value == ira->codegen->invalid_instruction) | | |
| 12240 | return nullptr; | | |
| 12241 | | | |
| 12242 | if (type_is_invalid(fn_value->value->type)) | 13340 | if (type_is_invalid(fn_value->value->type)) |
| 12243 | return nullptr; | 13341 | return nullptr; |
| 12244 | | 13342 | |
| 12245 | if (fn_value->value->type->id != ZigTypeIdFn) { | 13343 | if (fn_value->value->type->id != ZigTypeIdFn) { |
| 12246 | ir_add_error_node(ira, fn_value->source_node, | 13344 | ir_add_error_node(ira, fn_value->base.source_node, |
| 12247 | buf_sprintf("expected function type, found '%s'", buf_ptr(&fn_value->value->type->name))); | 13345 | buf_sprintf("expected function type, found '%s'", buf_ptr(&fn_value->value->type->name))); |
| 12248 | return nullptr; | 13346 | return nullptr; |
| 12249 | } | 13347 | } |
| ... | @@ -12259,22 +13357,22 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { | ... | @@ -12259,22 +13357,22 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { |
| 12259 | return const_val->data.x_ptr.data.fn.fn_entry; | 13357 | return const_val->data.x_ptr.data.fn.fn_entry; |
| 12260 | } | 13358 | } |
| 12261 | | 13359 | |
| 12262 | static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 13360 | static IrInstGen *ir_analyze_optional_wrap(IrAnalyze *ira, IrInst* source_instr, |
| 12263 | ZigType *wanted_type, ResultLoc *result_loc) | 13361 | IrInstGen *value, ZigType *wanted_type, ResultLoc *result_loc) |
| 12264 | { | 13362 | { |
| 12265 | assert(wanted_type->id == ZigTypeIdOptional); | 13363 | assert(wanted_type->id == ZigTypeIdOptional); |
| 12266 | | 13364 | |
| 12267 | if (instr_is_comptime(value)) { | 13365 | if (instr_is_comptime(value)) { |
| 12268 | ZigType *payload_type = wanted_type->data.maybe.child_type; | 13366 | ZigType *payload_type = wanted_type->data.maybe.child_type; |
| 12269 | IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type); | 13367 | IrInstGen *casted_payload = ir_implicit_cast(ira, value, payload_type); |
| 12270 | if (type_is_invalid(casted_payload->value->type)) | 13368 | if (type_is_invalid(casted_payload->value->type)) |
| 12271 | return ira->codegen->invalid_instruction; | 13369 | return ira->codegen->invalid_inst_gen; |
| 12272 | | 13370 | |
| 12273 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefOk); | 13371 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefOk); |
| 12274 | if (!val) | 13372 | if (!val) |
| 12275 | return ira->codegen->invalid_instruction; | 13373 | return ira->codegen->invalid_inst_gen; |
| 12276 | | 13374 | |
| 12277 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 13375 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, |
| 12278 | source_instr->scope, source_instr->source_node); | 13376 | source_instr->scope, source_instr->source_node); |
| 12279 | const_instruction->base.value->special = ConstValSpecialStatic; | 13377 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 12280 | if (types_have_same_zig_comptime_repr(ira->codegen, wanted_type, payload_type)) { | 13378 | if (types_have_same_zig_comptime_repr(ira->codegen, wanted_type, payload_type)) { |
| ... | @@ -12289,40 +13387,42 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so | ... | @@ -12289,40 +13387,42 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so |
| 12289 | if (result_loc == nullptr && handle_is_ptr(wanted_type)) { | 13387 | if (result_loc == nullptr && handle_is_ptr(wanted_type)) { |
| 12290 | result_loc = no_result_loc(); | 13388 | result_loc = no_result_loc(); |
| 12291 | } | 13389 | } |
| 12292 | IrInstruction *result_loc_inst = nullptr; | 13390 | IrInstGen *result_loc_inst = nullptr; |
| 12293 | if (result_loc != nullptr) { | 13391 | if (result_loc != nullptr) { |
| 12294 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, true); | 13392 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, true); |
| 12295 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { | 13393 | if (type_is_invalid(result_loc_inst->value->type) || |
| | 13394 | result_loc_inst->value->type->id == ZigTypeIdUnreachable) |
| | 13395 | { |
| 12296 | return result_loc_inst; | 13396 | return result_loc_inst; |
| 12297 | } | 13397 | } |
| 12298 | } | 13398 | } |
| 12299 | IrInstruction *result = ir_build_optional_wrap(ira, source_instr, wanted_type, value, result_loc_inst); | 13399 | IrInstGen *result = ir_build_optional_wrap(ira, source_instr, wanted_type, value, result_loc_inst); |
| 12300 | result->value->data.rh_maybe = RuntimeHintOptionalNonNull; | 13400 | result->value->data.rh_maybe = RuntimeHintOptionalNonNull; |
| 12301 | return result; | 13401 | return result; |
| 12302 | } | 13402 | } |
| 12303 | | 13403 | |
| 12304 | static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction *source_instr, | 13404 | static IrInstGen *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInst* source_instr, |
| 12305 | IrInstruction *value, ZigType *wanted_type, ResultLoc *result_loc) | 13405 | IrInstGen *value, ZigType *wanted_type, ResultLoc *result_loc) |
| 12306 | { | 13406 | { |
| 12307 | assert(wanted_type->id == ZigTypeIdErrorUnion); | 13407 | assert(wanted_type->id == ZigTypeIdErrorUnion); |
| 12308 | | 13408 | |
| 12309 | ZigType *payload_type = wanted_type->data.error_union.payload_type; | 13409 | ZigType *payload_type = wanted_type->data.error_union.payload_type; |
| 12310 | ZigType *err_set_type = wanted_type->data.error_union.err_set_type; | 13410 | ZigType *err_set_type = wanted_type->data.error_union.err_set_type; |
| 12311 | if (instr_is_comptime(value)) { | 13411 | if (instr_is_comptime(value)) { |
| 12312 | IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type); | 13412 | IrInstGen *casted_payload = ir_implicit_cast(ira, value, payload_type); |
| 12313 | if (type_is_invalid(casted_payload->value->type)) | 13413 | if (type_is_invalid(casted_payload->value->type)) |
| 12314 | return ira->codegen->invalid_instruction; | 13414 | return ira->codegen->invalid_inst_gen; |
| 12315 | | 13415 | |
| 12316 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefOk); | 13416 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefOk); |
| 12317 | if (val == nullptr) | 13417 | if (val == nullptr) |
| 12318 | return ira->codegen->invalid_instruction; | 13418 | return ira->codegen->invalid_inst_gen; |
| 12319 | | 13419 | |
| 12320 | ZigValue *err_set_val = create_const_vals(1); | 13420 | ZigValue *err_set_val = create_const_vals(1); |
| 12321 | err_set_val->type = err_set_type; | 13421 | err_set_val->type = err_set_type; |
| 12322 | err_set_val->special = ConstValSpecialStatic; | 13422 | err_set_val->special = ConstValSpecialStatic; |
| 12323 | err_set_val->data.x_err_set = nullptr; | 13423 | err_set_val->data.x_err_set = nullptr; |
| 12324 | | 13424 | |
| 12325 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 13425 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, |
| 12326 | source_instr->scope, source_instr->source_node); | 13426 | source_instr->scope, source_instr->source_node); |
| 12327 | const_instruction->base.value->type = wanted_type; | 13427 | const_instruction->base.value->type = wanted_type; |
| 12328 | const_instruction->base.value->special = ConstValSpecialStatic; | 13428 | const_instruction->base.value->special = ConstValSpecialStatic; |
| ... | @@ -12331,23 +13431,24 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction | ... | @@ -12331,23 +13431,24 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction |
| 12331 | return &const_instruction->base; | 13431 | return &const_instruction->base; |
| 12332 | } | 13432 | } |
| 12333 | | 13433 | |
| 12334 | IrInstruction *result_loc_inst; | 13434 | IrInstGen *result_loc_inst; |
| 12335 | if (handle_is_ptr(wanted_type)) { | 13435 | if (handle_is_ptr(wanted_type)) { |
| 12336 | if (result_loc == nullptr) result_loc = no_result_loc(); | 13436 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 12337 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, true); | 13437 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, true); |
| 12338 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { | 13438 | if (type_is_invalid(result_loc_inst->value->type) || |
| | 13439 | result_loc_inst->value->type->id == ZigTypeIdUnreachable) { |
| 12339 | return result_loc_inst; | 13440 | return result_loc_inst; |
| 12340 | } | 13441 | } |
| 12341 | } else { | 13442 | } else { |
| 12342 | result_loc_inst = nullptr; | 13443 | result_loc_inst = nullptr; |
| 12343 | } | 13444 | } |
| 12344 | | 13445 | |
| 12345 | IrInstruction *result = ir_build_err_wrap_payload(ira, source_instr, wanted_type, value, result_loc_inst); | 13446 | IrInstGen *result = ir_build_err_wrap_payload(ira, source_instr, wanted_type, value, result_loc_inst); |
| 12346 | result->value->data.rh_error_union = RuntimeHintErrorUnionNonError; | 13447 | result->value->data.rh_error_union = RuntimeHintErrorUnionNonError; |
| 12347 | return result; | 13448 | return result; |
| 12348 | } | 13449 | } |
| 12349 | | 13450 | |
| 12350 | static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 13451 | static IrInstGen *ir_analyze_err_set_cast(IrAnalyze *ira, IrInst* source_instr, IrInstGen *value, |
| 12351 | ZigType *wanted_type) | 13452 | ZigType *wanted_type) |
| 12352 | { | 13453 | { |
| 12353 | assert(value->value->type->id == ZigTypeIdErrorSet); | 13454 | assert(value->value->type->id == ZigTypeIdErrorSet); |
| ... | @@ -12356,10 +13457,10 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12356,10 +13457,10 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou |
| 12356 | if (instr_is_comptime(value)) { | 13457 | if (instr_is_comptime(value)) { |
| 12357 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); | 13458 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 12358 | if (!val) | 13459 | if (!val) |
| 12359 | return ira->codegen->invalid_instruction; | 13460 | return ira->codegen->invalid_inst_gen; |
| 12360 | | 13461 | |
| 12361 | if (!resolve_inferred_error_set(ira->codegen, wanted_type, source_instr->source_node)) { | 13462 | if (!resolve_inferred_error_set(ira->codegen, wanted_type, source_instr->source_node)) { |
| 12362 | return ira->codegen->invalid_instruction; | 13463 | return ira->codegen->invalid_inst_gen; |
| 12363 | } | 13464 | } |
| 12364 | if (!type_is_global_error_set(wanted_type)) { | 13465 | if (!type_is_global_error_set(wanted_type)) { |
| 12365 | bool subset = false; | 13466 | bool subset = false; |
| ... | @@ -12373,11 +13474,11 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12373,11 +13474,11 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou |
| 12373 | ir_add_error(ira, source_instr, | 13474 | ir_add_error(ira, source_instr, |
| 12374 | buf_sprintf("error.%s not a member of error set '%s'", | 13475 | buf_sprintf("error.%s not a member of error set '%s'", |
| 12375 | buf_ptr(&val->data.x_err_set->name), buf_ptr(&wanted_type->name))); | 13476 | buf_ptr(&val->data.x_err_set->name), buf_ptr(&wanted_type->name))); |
| 12376 | return ira->codegen->invalid_instruction; | 13477 | return ira->codegen->invalid_inst_gen; |
| 12377 | } | 13478 | } |
| 12378 | } | 13479 | } |
| 12379 | | 13480 | |
| 12380 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 13481 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, |
| 12381 | source_instr->scope, source_instr->source_node); | 13482 | source_instr->scope, source_instr->source_node); |
| 12382 | const_instruction->base.value->type = wanted_type; | 13483 | const_instruction->base.value->type = wanted_type; |
| 12383 | const_instruction->base.value->special = ConstValSpecialStatic; | 13484 | const_instruction->base.value->special = ConstValSpecialStatic; |
| ... | @@ -12385,18 +13486,16 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12385,18 +13486,16 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou |
| 12385 | return &const_instruction->base; | 13486 | return &const_instruction->base; |
| 12386 | } | 13487 | } |
| 12387 | | 13488 | |
| 12388 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, wanted_type, value, CastOpErrSet); | 13489 | return ir_build_cast(ira, source_instr, wanted_type, value, CastOpErrSet); |
| 12389 | result->value->type = wanted_type; | | |
| 12390 | return result; | | |
| 12391 | } | 13490 | } |
| 12392 | | 13491 | |
| 12393 | static IrInstruction *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInstruction *source_instr, | 13492 | static IrInstGen *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInst* source_instr, |
| 12394 | IrInstruction *frame_ptr, ZigType *wanted_type) | 13493 | IrInstGen *frame_ptr, ZigType *wanted_type) |
| 12395 | { | 13494 | { |
| 12396 | if (instr_is_comptime(frame_ptr)) { | 13495 | if (instr_is_comptime(frame_ptr)) { |
| 12397 | ZigValue *ptr_val = ir_resolve_const(ira, frame_ptr, UndefBad); | 13496 | ZigValue *ptr_val = ir_resolve_const(ira, frame_ptr, UndefBad); |
| 12398 | if (ptr_val == nullptr) | 13497 | if (ptr_val == nullptr) |
| 12399 | return ira->codegen->invalid_instruction; | 13498 | return ira->codegen->invalid_inst_gen; |
| 12400 | | 13499 | |
| 12401 | ir_assert(ptr_val->type->id == ZigTypeIdPointer, source_instr); | 13500 | ir_assert(ptr_val->type->id == ZigTypeIdPointer, source_instr); |
| 12402 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 13501 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| ... | @@ -12404,44 +13503,38 @@ static IrInstruction *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInstruc | ... | @@ -12404,44 +13503,38 @@ static IrInstruction *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInstruc |
| 12404 | } | 13503 | } |
| 12405 | } | 13504 | } |
| 12406 | | 13505 | |
| 12407 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, | 13506 | return ir_build_cast(ira, source_instr, wanted_type, frame_ptr, CastOpBitCast); |
| 12408 | wanted_type, frame_ptr, CastOpBitCast); | | |
| 12409 | result->value->type = wanted_type; | | |
| 12410 | return result; | | |
| 12411 | } | 13507 | } |
| 12412 | | 13508 | |
| 12413 | static IrInstruction *ir_analyze_anyframe_to_anyframe(IrAnalyze *ira, IrInstruction *source_instr, | 13509 | static IrInstGen *ir_analyze_anyframe_to_anyframe(IrAnalyze *ira, IrInst* source_instr, |
| 12414 | IrInstruction *value, ZigType *wanted_type) | 13510 | IrInstGen *value, ZigType *wanted_type) |
| 12415 | { | 13511 | { |
| 12416 | if (instr_is_comptime(value)) { | 13512 | if (instr_is_comptime(value)) { |
| 12417 | zig_panic("TODO comptime anyframe->T to anyframe"); | 13513 | zig_panic("TODO comptime anyframe->T to anyframe"); |
| 12418 | } | 13514 | } |
| 12419 | | 13515 | |
| 12420 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, | 13516 | return ir_build_cast(ira, source_instr, wanted_type, value, CastOpBitCast); |
| 12421 | wanted_type, value, CastOpBitCast); | | |
| 12422 | result->value->type = wanted_type; | | |
| 12423 | return result; | | |
| 12424 | } | 13517 | } |
| 12425 | | 13518 | |
| 12426 | | 13519 | |
| 12427 | static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 13520 | static IrInstGen *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInst* source_instr, IrInstGen *value, |
| 12428 | ZigType *wanted_type, ResultLoc *result_loc) | 13521 | ZigType *wanted_type, ResultLoc *result_loc) |
| 12429 | { | 13522 | { |
| 12430 | assert(wanted_type->id == ZigTypeIdErrorUnion); | 13523 | assert(wanted_type->id == ZigTypeIdErrorUnion); |
| 12431 | | 13524 | |
| 12432 | IrInstruction *casted_value = ir_implicit_cast(ira, value, wanted_type->data.error_union.err_set_type); | 13525 | IrInstGen *casted_value = ir_implicit_cast(ira, value, wanted_type->data.error_union.err_set_type); |
| 12433 | | 13526 | |
| 12434 | if (instr_is_comptime(casted_value)) { | 13527 | if (instr_is_comptime(casted_value)) { |
| 12435 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); | 13528 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); |
| 12436 | if (!val) | 13529 | if (!val) |
| 12437 | return ira->codegen->invalid_instruction; | 13530 | return ira->codegen->invalid_inst_gen; |
| 12438 | | 13531 | |
| 12439 | ZigValue *err_set_val = create_const_vals(1); | 13532 | ZigValue *err_set_val = create_const_vals(1); |
| 12440 | err_set_val->special = ConstValSpecialStatic; | 13533 | err_set_val->special = ConstValSpecialStatic; |
| 12441 | err_set_val->type = wanted_type->data.error_union.err_set_type; | 13534 | err_set_val->type = wanted_type->data.error_union.err_set_type; |
| 12442 | err_set_val->data.x_err_set = val->data.x_err_set; | 13535 | err_set_val->data.x_err_set = val->data.x_err_set; |
| 12443 | | 13536 | |
| 12444 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 13537 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, |
| 12445 | source_instr->scope, source_instr->source_node); | 13538 | source_instr->scope, source_instr->source_node); |
| 12446 | const_instruction->base.value->type = wanted_type; | 13539 | const_instruction->base.value->type = wanted_type; |
| 12447 | const_instruction->base.value->special = ConstValSpecialStatic; | 13540 | const_instruction->base.value->special = ConstValSpecialStatic; |
| ... | @@ -12450,11 +13543,13 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so | ... | @@ -12450,11 +13543,13 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so |
| 12450 | return &const_instruction->base; | 13543 | return &const_instruction->base; |
| 12451 | } | 13544 | } |
| 12452 | | 13545 | |
| 12453 | IrInstruction *result_loc_inst; | 13546 | IrInstGen *result_loc_inst; |
| 12454 | if (handle_is_ptr(wanted_type)) { | 13547 | if (handle_is_ptr(wanted_type)) { |
| 12455 | if (result_loc == nullptr) result_loc = no_result_loc(); | 13548 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 12456 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, true); | 13549 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, true); |
| 12457 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { | 13550 | if (type_is_invalid(result_loc_inst->value->type) || |
| | 13551 | result_loc_inst->value->type->id == ZigTypeIdUnreachable) |
| | 13552 | { |
| 12458 | return result_loc_inst; | 13553 | return result_loc_inst; |
| 12459 | } | 13554 | } |
| 12460 | } else { | 13555 | } else { |
| ... | @@ -12462,19 +13557,19 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so | ... | @@ -12462,19 +13557,19 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so |
| 12462 | } | 13557 | } |
| 12463 | | 13558 | |
| 12464 | | 13559 | |
| 12465 | IrInstruction *result = ir_build_err_wrap_code(ira, source_instr, wanted_type, value, result_loc_inst); | 13560 | IrInstGen *result = ir_build_err_wrap_code(ira, source_instr, wanted_type, value, result_loc_inst); |
| 12466 | result->value->data.rh_error_union = RuntimeHintErrorUnionError; | 13561 | result->value->data.rh_error_union = RuntimeHintErrorUnionError; |
| 12467 | return result; | 13562 | return result; |
| 12468 | } | 13563 | } |
| 12469 | | 13564 | |
| 12470 | static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, ZigType *wanted_type) { | 13565 | static IrInstGen *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInst *source_instr, IrInstGen *value, ZigType *wanted_type) { |
| 12471 | assert(wanted_type->id == ZigTypeIdOptional); | 13566 | assert(wanted_type->id == ZigTypeIdOptional); |
| 12472 | assert(instr_is_comptime(value)); | 13567 | assert(instr_is_comptime(value)); |
| 12473 | | 13568 | |
| 12474 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); | 13569 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 12475 | assert(val != nullptr); | 13570 | assert(val != nullptr); |
| 12476 | | 13571 | |
| 12477 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13572 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12478 | result->value->special = ConstValSpecialStatic; | 13573 | result->value->special = ConstValSpecialStatic; |
| 12479 | if (get_codegen_ptr_type(wanted_type) != nullptr) { | 13574 | if (get_codegen_ptr_type(wanted_type) != nullptr) { |
| 12480 | result->value->data.x_ptr.special = ConstPtrSpecialNull; | 13575 | result->value->data.x_ptr.special = ConstPtrSpecialNull; |
| ... | @@ -12486,8 +13581,8 @@ static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *so | ... | @@ -12486,8 +13581,8 @@ static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *so |
| 12486 | return result; | 13581 | return result; |
| 12487 | } | 13582 | } |
| 12488 | | 13583 | |
| 12489 | static IrInstruction *ir_analyze_null_to_c_pointer(IrAnalyze *ira, IrInstruction *source_instr, | 13584 | static IrInstGen *ir_analyze_null_to_c_pointer(IrAnalyze *ira, IrInst *source_instr, |
| 12490 | IrInstruction *value, ZigType *wanted_type) | 13585 | IrInstGen *value, ZigType *wanted_type) |
| 12491 | { | 13586 | { |
| 12492 | assert(wanted_type->id == ZigTypeIdPointer); | 13587 | assert(wanted_type->id == ZigTypeIdPointer); |
| 12493 | assert(wanted_type->data.pointer.ptr_len == PtrLenC); | 13588 | assert(wanted_type->data.pointer.ptr_len == PtrLenC); |
| ... | @@ -12496,24 +13591,24 @@ static IrInstruction *ir_analyze_null_to_c_pointer(IrAnalyze *ira, IrInstruction | ... | @@ -12496,24 +13591,24 @@ static IrInstruction *ir_analyze_null_to_c_pointer(IrAnalyze *ira, IrInstruction |
| 12496 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); | 13591 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 12497 | assert(val != nullptr); | 13592 | assert(val != nullptr); |
| 12498 | | 13593 | |
| 12499 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13594 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12500 | result->value->data.x_ptr.special = ConstPtrSpecialNull; | 13595 | result->value->data.x_ptr.special = ConstPtrSpecialNull; |
| 12501 | result->value->data.x_ptr.mut = ConstPtrMutComptimeConst; | 13596 | result->value->data.x_ptr.mut = ConstPtrMutComptimeConst; |
| 12502 | return result; | 13597 | return result; |
| 12503 | } | 13598 | } |
| 12504 | | 13599 | |
| 12505 | static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *value, | 13600 | static IrInstGen *ir_get_ref(IrAnalyze *ira, IrInst* source_instruction, IrInstGen *value, |
| 12506 | bool is_const, bool is_volatile) | 13601 | bool is_const, bool is_volatile) |
| 12507 | { | 13602 | { |
| 12508 | Error err; | 13603 | Error err; |
| 12509 | | 13604 | |
| 12510 | if (type_is_invalid(value->value->type)) | 13605 | if (type_is_invalid(value->value->type)) |
| 12511 | return ira->codegen->invalid_instruction; | 13606 | return ira->codegen->invalid_inst_gen; |
| 12512 | | 13607 | |
| 12513 | if (instr_is_comptime(value)) { | 13608 | if (instr_is_comptime(value)) { |
| 12514 | ZigValue *val = ir_resolve_const(ira, value, LazyOk); | 13609 | ZigValue *val = ir_resolve_const(ira, value, LazyOk); |
| 12515 | if (!val) | 13610 | if (!val) |
| 12516 | return ira->codegen->invalid_instruction; | 13611 | return ira->codegen->invalid_inst_gen; |
| 12517 | return ir_get_const_ptr(ira, source_instruction, val, value->value->type, | 13612 | return ir_get_const_ptr(ira, source_instruction, val, value->value->type, |
| 12518 | ConstPtrMutComptimeConst, is_const, is_volatile, 0); | 13613 | ConstPtrMutComptimeConst, is_const, is_volatile, 0); |
| 12519 | } | 13614 | } |
| ... | @@ -12522,9 +13617,9 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi | ... | @@ -12522,9 +13617,9 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi |
| 12522 | is_const, is_volatile, PtrLenSingle, 0, 0, 0, false); | 13617 | is_const, is_volatile, PtrLenSingle, 0, 0, 0, false); |
| 12523 | | 13618 | |
| 12524 | if ((err = type_resolve(ira->codegen, ptr_type, ResolveStatusZeroBitsKnown))) | 13619 | if ((err = type_resolve(ira->codegen, ptr_type, ResolveStatusZeroBitsKnown))) |
| 12525 | return ira->codegen->invalid_instruction; | 13620 | return ira->codegen->invalid_inst_gen; |
| 12526 | | 13621 | |
| 12527 | IrInstruction *result_loc; | 13622 | IrInstGen *result_loc; |
| 12528 | if (type_has_bits(ptr_type) && !handle_is_ptr(value->value->type)) { | 13623 | if (type_has_bits(ptr_type) && !handle_is_ptr(value->value->type)) { |
| 12529 | result_loc = ir_resolve_result(ira, source_instruction, no_result_loc(), value->value->type, | 13624 | result_loc = ir_resolve_result(ira, source_instruction, no_result_loc(), value->value->type, |
| 12530 | nullptr, true, true); | 13625 | nullptr, true, true); |
| ... | @@ -12532,12 +13627,12 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi | ... | @@ -12532,12 +13627,12 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi |
| 12532 | result_loc = nullptr; | 13627 | result_loc = nullptr; |
| 12533 | } | 13628 | } |
| 12534 | | 13629 | |
| 12535 | IrInstruction *new_instruction = ir_build_ref_gen(ira, source_instruction, ptr_type, value, result_loc); | 13630 | IrInstGen *new_instruction = ir_build_ref_gen(ira, source_instruction, ptr_type, value, result_loc); |
| 12536 | new_instruction->value->data.rh_ptr = RuntimeHintPtrStack; | 13631 | new_instruction->value->data.rh_ptr = RuntimeHintPtrStack; |
| 12537 | return new_instruction; | 13632 | return new_instruction; |
| 12538 | } | 13633 | } |
| 12539 | | 13634 | |
| 12540 | static ZigType *ir_resolve_union_tag_type(IrAnalyze *ira, IrInstruction *source_instr, ZigType *union_type) { | 13635 | static ZigType *ir_resolve_union_tag_type(IrAnalyze *ira, AstNode *source_node, ZigType *union_type) { |
| 12541 | assert(union_type->id == ZigTypeIdUnion); | 13636 | assert(union_type->id == ZigTypeIdUnion); |
| 12542 | | 13637 | |
| 12543 | Error err; | 13638 | Error err; |
| ... | @@ -12549,36 +13644,36 @@ static ZigType *ir_resolve_union_tag_type(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -12549,36 +13644,36 @@ static ZigType *ir_resolve_union_tag_type(IrAnalyze *ira, IrInstruction *source_ |
| 12549 | assert(union_type->data.unionation.tag_type != nullptr); | 13644 | assert(union_type->data.unionation.tag_type != nullptr); |
| 12550 | return union_type->data.unionation.tag_type; | 13645 | return union_type->data.unionation.tag_type; |
| 12551 | } else { | 13646 | } else { |
| 12552 | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("union '%s' has no tag", | 13647 | ErrorMsg *msg = ir_add_error_node(ira, source_node, buf_sprintf("union '%s' has no tag", |
| 12553 | buf_ptr(&union_type->name))); | 13648 | buf_ptr(&union_type->name))); |
| 12554 | add_error_note(ira->codegen, msg, decl_node, buf_sprintf("consider 'union(enum)' here")); | 13649 | add_error_note(ira->codegen, msg, decl_node, buf_sprintf("consider 'union(enum)' here")); |
| 12555 | return ira->codegen->builtin_types.entry_invalid; | 13650 | return ira->codegen->builtin_types.entry_invalid; |
| 12556 | } | 13651 | } |
| 12557 | } | 13652 | } |
| 12558 | | 13653 | |
| 12559 | static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target) { | 13654 | static IrInstGen *ir_analyze_enum_to_int(IrAnalyze *ira, IrInst *source_instr, IrInstGen *target) { |
| 12560 | Error err; | 13655 | Error err; |
| 12561 | | 13656 | |
| 12562 | IrInstruction *enum_target; | 13657 | IrInstGen *enum_target; |
| 12563 | ZigType *enum_type; | 13658 | ZigType *enum_type; |
| 12564 | if (target->value->type->id == ZigTypeIdUnion) { | 13659 | if (target->value->type->id == ZigTypeIdUnion) { |
| 12565 | enum_type = ir_resolve_union_tag_type(ira, target, target->value->type); | 13660 | enum_type = ir_resolve_union_tag_type(ira, target->base.source_node, target->value->type); |
| 12566 | if (type_is_invalid(enum_type)) | 13661 | if (type_is_invalid(enum_type)) |
| 12567 | return ira->codegen->invalid_instruction; | 13662 | return ira->codegen->invalid_inst_gen; |
| 12568 | enum_target = ir_implicit_cast(ira, target, enum_type); | 13663 | enum_target = ir_implicit_cast(ira, target, enum_type); |
| 12569 | if (type_is_invalid(enum_target->value->type)) | 13664 | if (type_is_invalid(enum_target->value->type)) |
| 12570 | return ira->codegen->invalid_instruction; | 13665 | return ira->codegen->invalid_inst_gen; |
| 12571 | } else if (target->value->type->id == ZigTypeIdEnum) { | 13666 | } else if (target->value->type->id == ZigTypeIdEnum) { |
| 12572 | enum_target = target; | 13667 | enum_target = target; |
| 12573 | enum_type = target->value->type; | 13668 | enum_type = target->value->type; |
| 12574 | } else { | 13669 | } else { |
| 12575 | ir_add_error(ira, target, | 13670 | ir_add_error_node(ira, target->base.source_node, |
| 12576 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&target->value->type->name))); | 13671 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&target->value->type->name))); |
| 12577 | return ira->codegen->invalid_instruction; | 13672 | return ira->codegen->invalid_inst_gen; |
| 12578 | } | 13673 | } |
| 12579 | | 13674 | |
| 12580 | if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusSizeKnown))) | 13675 | if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusSizeKnown))) |
| 12581 | return ira->codegen->invalid_instruction; | 13676 | return ira->codegen->invalid_inst_gen; |
| 12582 | | 13677 | |
| 12583 | ZigType *tag_type = enum_type->data.enumeration.tag_int_type; | 13678 | ZigType *tag_type = enum_type->data.enumeration.tag_int_type; |
| 12584 | assert(tag_type->id == ZigTypeIdInt || tag_type->id == ZigTypeIdComptimeInt); | 13679 | assert(tag_type->id == ZigTypeIdInt || tag_type->id == ZigTypeIdComptimeInt); |
| ... | @@ -12587,7 +13682,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12587,7 +13682,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 12587 | if (enum_type->data.enumeration.layout == ContainerLayoutAuto && | 13682 | if (enum_type->data.enumeration.layout == ContainerLayoutAuto && |
| 12588 | enum_type->data.enumeration.src_field_count == 1) | 13683 | enum_type->data.enumeration.src_field_count == 1) |
| 12589 | { | 13684 | { |
| 12590 | IrInstruction *result = ir_const(ira, source_instr, tag_type); | 13685 | IrInstGen *result = ir_const(ira, source_instr, tag_type); |
| 12591 | init_const_bigint(result->value, tag_type, | 13686 | init_const_bigint(result->value, tag_type, |
| 12592 | &enum_type->data.enumeration.fields[0].value); | 13687 | &enum_type->data.enumeration.fields[0].value); |
| 12593 | return result; | 13688 | return result; |
| ... | @@ -12596,20 +13691,17 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12596,20 +13691,17 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 12596 | if (instr_is_comptime(enum_target)) { | 13691 | if (instr_is_comptime(enum_target)) { |
| 12597 | ZigValue *val = ir_resolve_const(ira, enum_target, UndefBad); | 13692 | ZigValue *val = ir_resolve_const(ira, enum_target, UndefBad); |
| 12598 | if (!val) | 13693 | if (!val) |
| 12599 | return ira->codegen->invalid_instruction; | 13694 | return ira->codegen->invalid_inst_gen; |
| 12600 | IrInstruction *result = ir_const(ira, source_instr, tag_type); | 13695 | IrInstGen *result = ir_const(ira, source_instr, tag_type); |
| 12601 | init_const_bigint(result->value, tag_type, &val->data.x_enum_tag); | 13696 | init_const_bigint(result->value, tag_type, &val->data.x_enum_tag); |
| 12602 | return result; | 13697 | return result; |
| 12603 | } | 13698 | } |
| 12604 | | 13699 | |
| 12605 | IrInstruction *result = ir_build_widen_or_shorten(&ira->new_irb, source_instr->scope, | 13700 | return ir_build_widen_or_shorten(ira, source_instr->scope, source_instr->source_node, enum_target, tag_type); |
| 12606 | source_instr->source_node, enum_target); | | |
| 12607 | result->value->type = tag_type; | | |
| 12608 | return result; | | |
| 12609 | } | 13701 | } |
| 12610 | | 13702 | |
| 12611 | static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *source_instr, | 13703 | static IrInstGen *ir_analyze_union_to_tag(IrAnalyze *ira, IrInst* source_instr, |
| 12612 | IrInstruction *target, ZigType *wanted_type) | 13704 | IrInstGen *target, ZigType *wanted_type) |
| 12613 | { | 13705 | { |
| 12614 | assert(target->value->type->id == ZigTypeIdUnion); | 13706 | assert(target->value->type->id == ZigTypeIdUnion); |
| 12615 | assert(wanted_type->id == ZigTypeIdEnum); | 13707 | assert(wanted_type->id == ZigTypeIdEnum); |
| ... | @@ -12618,8 +13710,8 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12618,8 +13710,8 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou |
| 12618 | if (instr_is_comptime(target)) { | 13710 | if (instr_is_comptime(target)) { |
| 12619 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 13711 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12620 | if (!val) | 13712 | if (!val) |
| 12621 | return ira->codegen->invalid_instruction; | 13713 | return ira->codegen->invalid_inst_gen; |
| 12622 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13714 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12623 | result->value->special = ConstValSpecialStatic; | 13715 | result->value->special = ConstValSpecialStatic; |
| 12624 | result->value->type = wanted_type; | 13716 | result->value->type = wanted_type; |
| 12625 | bigint_init_bigint(&result->value->data.x_enum_tag, &val->data.x_union.tag); | 13717 | bigint_init_bigint(&result->value->data.x_enum_tag, &val->data.x_union.tag); |
| ... | @@ -12630,7 +13722,7 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12630,7 +13722,7 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou |
| 12630 | if (wanted_type->data.enumeration.layout == ContainerLayoutAuto && | 13722 | if (wanted_type->data.enumeration.layout == ContainerLayoutAuto && |
| 12631 | wanted_type->data.enumeration.src_field_count == 1) | 13723 | wanted_type->data.enumeration.src_field_count == 1) |
| 12632 | { | 13724 | { |
| 12633 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13725 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12634 | result->value->special = ConstValSpecialStatic; | 13726 | result->value->special = ConstValSpecialStatic; |
| 12635 | result->value->type = wanted_type; | 13727 | result->value->type = wanted_type; |
| 12636 | TypeEnumField *enum_field = target->value->type->data.unionation.fields[0].enum_field; | 13728 | TypeEnumField *enum_field = target->value->type->data.unionation.fields[0].enum_field; |
| ... | @@ -12638,48 +13730,45 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12638,48 +13730,45 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou |
| 12638 | return result; | 13730 | return result; |
| 12639 | } | 13731 | } |
| 12640 | | 13732 | |
| 12641 | IrInstruction *result = ir_build_union_tag(&ira->new_irb, source_instr->scope, | 13733 | return ir_build_union_tag(ira, source_instr, target, wanted_type); |
| 12642 | source_instr->source_node, target); | | |
| 12643 | result->value->type = wanted_type; | | |
| 12644 | return result; | | |
| 12645 | } | 13734 | } |
| 12646 | | 13735 | |
| 12647 | static IrInstruction *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInstruction *source_instr, | 13736 | static IrInstGen *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInst* source_instr, |
| 12648 | IrInstruction *target, ZigType *wanted_type) | 13737 | IrInstGen *target, ZigType *wanted_type) |
| 12649 | { | 13738 | { |
| 12650 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13739 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12651 | result->value->special = ConstValSpecialUndef; | 13740 | result->value->special = ConstValSpecialUndef; |
| 12652 | return result; | 13741 | return result; |
| 12653 | } | 13742 | } |
| 12654 | | 13743 | |
| 12655 | static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *source_instr, | 13744 | static IrInstGen *ir_analyze_enum_to_union(IrAnalyze *ira, IrInst* source_instr, |
| 12656 | IrInstruction *uncasted_target, ZigType *wanted_type) | 13745 | IrInstGen *uncasted_target, ZigType *wanted_type) |
| 12657 | { | 13746 | { |
| 12658 | Error err; | 13747 | Error err; |
| 12659 | assert(wanted_type->id == ZigTypeIdUnion); | 13748 | assert(wanted_type->id == ZigTypeIdUnion); |
| 12660 | | 13749 | |
| 12661 | if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusZeroBitsKnown))) | 13750 | if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusZeroBitsKnown))) |
| 12662 | return ira->codegen->invalid_instruction; | 13751 | return ira->codegen->invalid_inst_gen; |
| 12663 | | 13752 | |
| 12664 | IrInstruction *target = ir_implicit_cast(ira, uncasted_target, wanted_type->data.unionation.tag_type); | 13753 | IrInstGen *target = ir_implicit_cast(ira, uncasted_target, wanted_type->data.unionation.tag_type); |
| 12665 | if (type_is_invalid(target->value->type)) | 13754 | if (type_is_invalid(target->value->type)) |
| 12666 | return ira->codegen->invalid_instruction; | 13755 | return ira->codegen->invalid_inst_gen; |
| 12667 | | 13756 | |
| 12668 | if (instr_is_comptime(target)) { | 13757 | if (instr_is_comptime(target)) { |
| 12669 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 13758 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12670 | if (!val) | 13759 | if (!val) |
| 12671 | return ira->codegen->invalid_instruction; | 13760 | return ira->codegen->invalid_inst_gen; |
| 12672 | TypeUnionField *union_field = find_union_field_by_tag(wanted_type, &val->data.x_enum_tag); | 13761 | TypeUnionField *union_field = find_union_field_by_tag(wanted_type, &val->data.x_enum_tag); |
| 12673 | assert(union_field != nullptr); | 13762 | assert(union_field != nullptr); |
| 12674 | ZigType *field_type = resolve_union_field_type(ira->codegen, union_field); | 13763 | ZigType *field_type = resolve_union_field_type(ira->codegen, union_field); |
| 12675 | if (field_type == nullptr) | 13764 | if (field_type == nullptr) |
| 12676 | return ira->codegen->invalid_instruction; | 13765 | return ira->codegen->invalid_inst_gen; |
| 12677 | if ((err = type_resolve(ira->codegen, field_type, ResolveStatusZeroBitsKnown))) | 13766 | if ((err = type_resolve(ira->codegen, field_type, ResolveStatusZeroBitsKnown))) |
| 12678 | return ira->codegen->invalid_instruction; | 13767 | return ira->codegen->invalid_inst_gen; |
| 12679 | | 13768 | |
| 12680 | switch (type_has_one_possible_value(ira->codegen, field_type)) { | 13769 | switch (type_has_one_possible_value(ira->codegen, field_type)) { |
| 12681 | case OnePossibleValueInvalid: | 13770 | case OnePossibleValueInvalid: |
| 12682 | return ira->codegen->invalid_instruction; | 13771 | return ira->codegen->invalid_inst_gen; |
| 12683 | case OnePossibleValueNo: { | 13772 | case OnePossibleValueNo: { |
| 12684 | AstNode *field_node = wanted_type->data.unionation.decl_node->data.container_decl.fields.at( | 13773 | AstNode *field_node = wanted_type->data.unionation.decl_node->data.container_decl.fields.at( |
| 12685 | union_field->enum_field->decl_index); | 13774 | union_field->enum_field->decl_index); |
| ... | @@ -12690,13 +13779,13 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -12690,13 +13779,13 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 12690 | buf_ptr(union_field->name))); | 13779 | buf_ptr(union_field->name))); |
| 12691 | add_error_note(ira->codegen, msg, field_node, | 13780 | add_error_note(ira->codegen, msg, field_node, |
| 12692 | buf_sprintf("field '%s' declared here", buf_ptr(union_field->name))); | 13781 | buf_sprintf("field '%s' declared here", buf_ptr(union_field->name))); |
| 12693 | return ira->codegen->invalid_instruction; | 13782 | return ira->codegen->invalid_inst_gen; |
| 12694 | } | 13783 | } |
| 12695 | case OnePossibleValueYes: | 13784 | case OnePossibleValueYes: |
| 12696 | break; | 13785 | break; |
| 12697 | } | 13786 | } |
| 12698 | | 13787 | |
| 12699 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13788 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12700 | result->value->special = ConstValSpecialStatic; | 13789 | result->value->special = ConstValSpecialStatic; |
| 12701 | result->value->type = wanted_type; | 13790 | result->value->type = wanted_type; |
| 12702 | bigint_init_bigint(&result->value->data.x_union.tag, &val->data.x_enum_tag); | 13791 | bigint_init_bigint(&result->value->data.x_union.tag, &val->data.x_enum_tag); |
| ... | @@ -12709,9 +13798,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -12709,9 +13798,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 12709 | // if the union has all fields 0 bits, we can do it | 13798 | // if the union has all fields 0 bits, we can do it |
| 12710 | // and in fact it's a noop cast because the union value is just the enum value | 13799 | // and in fact it's a noop cast because the union value is just the enum value |
| 12711 | if (wanted_type->data.unionation.gen_field_count == 0) { | 13800 | if (wanted_type->data.unionation.gen_field_count == 0) { |
| 12712 | IrInstruction *result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, wanted_type, target, CastOpNoop); | 13801 | return ir_build_cast(ira, &target->base, wanted_type, target, CastOpNoop); |
| 12713 | result->value->type = wanted_type; | | |
| 12714 | return result; | | |
| 12715 | } | 13802 | } |
| 12716 | | 13803 | |
| 12717 | ErrorMsg *msg = ir_add_error(ira, source_instr, | 13804 | ErrorMsg *msg = ir_add_error(ira, source_instr, |
| ... | @@ -12721,10 +13808,10 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -12721,10 +13808,10 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 12721 | TypeUnionField *union_field = &wanted_type->data.unionation.fields[i]; | 13808 | TypeUnionField *union_field = &wanted_type->data.unionation.fields[i]; |
| 12722 | ZigType *field_type = resolve_union_field_type(ira->codegen, union_field); | 13809 | ZigType *field_type = resolve_union_field_type(ira->codegen, union_field); |
| 12723 | if (field_type == nullptr) | 13810 | if (field_type == nullptr) |
| 12724 | return ira->codegen->invalid_instruction; | 13811 | return ira->codegen->invalid_inst_gen; |
| 12725 | bool has_bits; | 13812 | bool has_bits; |
| 12726 | if ((err = type_has_bits2(ira->codegen, field_type, &has_bits))) | 13813 | if ((err = type_has_bits2(ira->codegen, field_type, &has_bits))) |
| 12727 | return ira->codegen->invalid_instruction; | 13814 | return ira->codegen->invalid_inst_gen; |
| 12728 | if (has_bits) { | 13815 | if (has_bits) { |
| 12729 | AstNode *field_node = wanted_type->data.unionation.decl_node->data.container_decl.fields.at(i); | 13816 | AstNode *field_node = wanted_type->data.unionation.decl_node->data.container_decl.fields.at(i); |
| 12730 | add_error_note(ira->codegen, msg, field_node, | 13817 | add_error_note(ira->codegen, msg, field_node, |
| ... | @@ -12733,23 +13820,23 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -12733,23 +13820,23 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 12733 | buf_ptr(&field_type->name))); | 13820 | buf_ptr(&field_type->name))); |
| 12734 | } | 13821 | } |
| 12735 | } | 13822 | } |
| 12736 | return ira->codegen->invalid_instruction; | 13823 | return ira->codegen->invalid_inst_gen; |
| 12737 | } | 13824 | } |
| 12738 | | 13825 | |
| 12739 | static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction *source_instr, | 13826 | static IrInstGen *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInst* source_instr, |
| 12740 | IrInstruction *target, ZigType *wanted_type) | 13827 | IrInstGen *target, ZigType *wanted_type) |
| 12741 | { | 13828 | { |
| 12742 | assert(wanted_type->id == ZigTypeIdInt || wanted_type->id == ZigTypeIdFloat); | 13829 | assert(wanted_type->id == ZigTypeIdInt || wanted_type->id == ZigTypeIdFloat); |
| 12743 | | 13830 | |
| 12744 | if (instr_is_comptime(target)) { | 13831 | if (instr_is_comptime(target)) { |
| 12745 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 13832 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12746 | if (!val) | 13833 | if (!val) |
| 12747 | return ira->codegen->invalid_instruction; | 13834 | return ira->codegen->invalid_inst_gen; |
| 12748 | if (wanted_type->id == ZigTypeIdInt) { | 13835 | if (wanted_type->id == ZigTypeIdInt) { |
| 12749 | if (bigint_cmp_zero(&val->data.x_bigint) == CmpLT && !wanted_type->data.integral.is_signed) { | 13836 | if (bigint_cmp_zero(&val->data.x_bigint) == CmpLT && !wanted_type->data.integral.is_signed) { |
| 12750 | ir_add_error(ira, source_instr, | 13837 | ir_add_error(ira, source_instr, |
| 12751 | buf_sprintf("attempt to cast negative value to unsigned integer")); | 13838 | buf_sprintf("attempt to cast negative value to unsigned integer")); |
| 12752 | return ira->codegen->invalid_instruction; | 13839 | return ira->codegen->invalid_inst_gen; |
| 12753 | } | 13840 | } |
| 12754 | if (!bigint_fits_in_bits(&val->data.x_bigint, wanted_type->data.integral.bit_count, | 13841 | if (!bigint_fits_in_bits(&val->data.x_bigint, wanted_type->data.integral.bit_count, |
| 12755 | wanted_type->data.integral.is_signed)) | 13842 | wanted_type->data.integral.is_signed)) |
| ... | @@ -12757,10 +13844,10 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction | ... | @@ -12757,10 +13844,10 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction |
| 12757 | ir_add_error(ira, source_instr, | 13844 | ir_add_error(ira, source_instr, |
| 12758 | buf_sprintf("cast from '%s' to '%s' truncates bits", | 13845 | buf_sprintf("cast from '%s' to '%s' truncates bits", |
| 12759 | buf_ptr(&target->value->type->name), buf_ptr(&wanted_type->name))); | 13846 | buf_ptr(&target->value->type->name), buf_ptr(&wanted_type->name))); |
| 12760 | return ira->codegen->invalid_instruction; | 13847 | return ira->codegen->invalid_inst_gen; |
| 12761 | } | 13848 | } |
| 12762 | } | 13849 | } |
| 12763 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13850 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12764 | result->value->type = wanted_type; | 13851 | result->value->type = wanted_type; |
| 12765 | if (wanted_type->id == ZigTypeIdInt) { | 13852 | if (wanted_type->id == ZigTypeIdInt) { |
| 12766 | bigint_init_bigint(&result->value->data.x_bigint, &val->data.x_bigint); | 13853 | bigint_init_bigint(&result->value->data.x_bigint, &val->data.x_bigint); |
| ... | @@ -12777,19 +13864,16 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction | ... | @@ -12777,19 +13864,16 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction |
| 12777 | assert(wanted_type->id == ZigTypeIdInt); | 13864 | assert(wanted_type->id == ZigTypeIdInt); |
| 12778 | assert(type_has_bits(target->value->type)); | 13865 | assert(type_has_bits(target->value->type)); |
| 12779 | ir_build_assert_zero(ira, source_instr, target); | 13866 | ir_build_assert_zero(ira, source_instr, target); |
| 12780 | IrInstruction *result = ir_const_unsigned(ira, source_instr, 0); | 13867 | IrInstGen *result = ir_const_unsigned(ira, source_instr, 0); |
| 12781 | result->value->type = wanted_type; | 13868 | result->value->type = wanted_type; |
| 12782 | return result; | 13869 | return result; |
| 12783 | } | 13870 | } |
| 12784 | | 13871 | |
| 12785 | IrInstruction *result = ir_build_widen_or_shorten(&ira->new_irb, source_instr->scope, | 13872 | return ir_build_widen_or_shorten(ira, source_instr->scope, source_instr->source_node, target, wanted_type); |
| 12786 | source_instr->source_node, target); | | |
| 12787 | result->value->type = wanted_type; | | |
| 12788 | return result; | | |
| 12789 | } | 13873 | } |
| 12790 | | 13874 | |
| 12791 | static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *source_instr, | 13875 | static IrInstGen *ir_analyze_int_to_enum(IrAnalyze *ira, IrInst* source_instr, |
| 12792 | IrInstruction *target, ZigType *wanted_type) | 13876 | IrInstGen *target, ZigType *wanted_type) |
| 12793 | { | 13877 | { |
| 12794 | Error err; | 13878 | Error err; |
| 12795 | assert(wanted_type->id == ZigTypeIdEnum); | 13879 | assert(wanted_type->id == ZigTypeIdEnum); |
| ... | @@ -12797,14 +13881,14 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12797,14 +13881,14 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 12797 | ZigType *actual_type = target->value->type; | 13881 | ZigType *actual_type = target->value->type; |
| 12798 | | 13882 | |
| 12799 | if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusSizeKnown))) | 13883 | if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusSizeKnown))) |
| 12800 | return ira->codegen->invalid_instruction; | 13884 | return ira->codegen->invalid_inst_gen; |
| 12801 | | 13885 | |
| 12802 | if (actual_type != wanted_type->data.enumeration.tag_int_type) { | 13886 | if (actual_type != wanted_type->data.enumeration.tag_int_type) { |
| 12803 | ir_add_error(ira, source_instr, | 13887 | ir_add_error(ira, source_instr, |
| 12804 | buf_sprintf("integer to enum cast from '%s' instead of its tag type, '%s'", | 13888 | buf_sprintf("integer to enum cast from '%s' instead of its tag type, '%s'", |
| 12805 | buf_ptr(&actual_type->name), | 13889 | buf_ptr(&actual_type->name), |
| 12806 | buf_ptr(&wanted_type->data.enumeration.tag_int_type->name))); | 13890 | buf_ptr(&wanted_type->data.enumeration.tag_int_type->name))); |
| 12807 | return ira->codegen->invalid_instruction; | 13891 | return ira->codegen->invalid_inst_gen; |
| 12808 | } | 13892 | } |
| 12809 | | 13893 | |
| 12810 | assert(actual_type->id == ZigTypeIdInt || actual_type->id == ZigTypeIdComptimeInt); | 13894 | assert(actual_type->id == ZigTypeIdInt || actual_type->id == ZigTypeIdComptimeInt); |
| ... | @@ -12812,10 +13896,10 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12812,10 +13896,10 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 12812 | if (instr_is_comptime(target)) { | 13896 | if (instr_is_comptime(target)) { |
| 12813 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 13897 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12814 | if (!val) | 13898 | if (!val) |
| 12815 | return ira->codegen->invalid_instruction; | 13899 | return ira->codegen->invalid_inst_gen; |
| 12816 | | 13900 | |
| 12817 | TypeEnumField *field = find_enum_field_by_tag(wanted_type, &val->data.x_bigint); | 13901 | TypeEnumField *field = find_enum_field_by_tag(wanted_type, &val->data.x_bigint); |
| 12818 | if (field == nullptr && wanted_type->data.enumeration.layout != ContainerLayoutExtern) { | 13902 | if (field == nullptr && !wanted_type->data.enumeration.non_exhaustive) { |
| 12819 | Buf *val_buf = buf_alloc(); | 13903 | Buf *val_buf = buf_alloc(); |
| 12820 | bigint_append_buf(val_buf, &val->data.x_bigint, 10); | 13904 | bigint_append_buf(val_buf, &val->data.x_bigint, 10); |
| 12821 | ErrorMsg *msg = ir_add_error(ira, source_instr, | 13905 | ErrorMsg *msg = ir_add_error(ira, source_instr, |
| ... | @@ -12823,28 +13907,25 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12823,28 +13907,25 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 12823 | buf_ptr(&wanted_type->name), buf_ptr(val_buf))); | 13907 | buf_ptr(&wanted_type->name), buf_ptr(val_buf))); |
| 12824 | add_error_note(ira->codegen, msg, wanted_type->data.enumeration.decl_node, | 13908 | add_error_note(ira->codegen, msg, wanted_type->data.enumeration.decl_node, |
| 12825 | buf_sprintf("'%s' declared here", buf_ptr(&wanted_type->name))); | 13909 | buf_sprintf("'%s' declared here", buf_ptr(&wanted_type->name))); |
| 12826 | return ira->codegen->invalid_instruction; | 13910 | return ira->codegen->invalid_inst_gen; |
| 12827 | } | 13911 | } |
| 12828 | | 13912 | |
| 12829 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13913 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12830 | bigint_init_bigint(&result->value->data.x_enum_tag, &val->data.x_bigint); | 13914 | bigint_init_bigint(&result->value->data.x_enum_tag, &val->data.x_bigint); |
| 12831 | return result; | 13915 | return result; |
| 12832 | } | 13916 | } |
| 12833 | | 13917 | |
| 12834 | IrInstruction *result = ir_build_int_to_enum(&ira->new_irb, source_instr->scope, | 13918 | return ir_build_int_to_enum_gen(ira, source_instr->scope, source_instr->source_node, wanted_type, target); |
| 12835 | source_instr->source_node, nullptr, target); | | |
| 12836 | result->value->type = wanted_type; | | |
| 12837 | return result; | | |
| 12838 | } | 13919 | } |
| 12839 | | 13920 | |
| 12840 | static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction *source_instr, | 13921 | static IrInstGen *ir_analyze_number_to_literal(IrAnalyze *ira, IrInst* source_instr, |
| 12841 | IrInstruction *target, ZigType *wanted_type) | 13922 | IrInstGen *target, ZigType *wanted_type) |
| 12842 | { | 13923 | { |
| 12843 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 13924 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12844 | if (!val) | 13925 | if (!val) |
| 12845 | return ira->codegen->invalid_instruction; | 13926 | return ira->codegen->invalid_inst_gen; |
| 12846 | | 13927 | |
| 12847 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13928 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12848 | if (wanted_type->id == ZigTypeIdComptimeFloat) { | 13929 | if (wanted_type->id == ZigTypeIdComptimeFloat) { |
| 12849 | float_init_float(result->value, val); | 13930 | float_init_float(result->value, val); |
| 12850 | } else if (wanted_type->id == ZigTypeIdComptimeInt) { | 13931 | } else if (wanted_type->id == ZigTypeIdComptimeInt) { |
| ... | @@ -12855,7 +13936,7 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction | ... | @@ -12855,7 +13936,7 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction |
| 12855 | return result; | 13936 | return result; |
| 12856 | } | 13937 | } |
| 12857 | | 13938 | |
| 12858 | static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, | 13939 | static IrInstGen *ir_analyze_int_to_err(IrAnalyze *ira, IrInst* source_instr, IrInstGen *target, |
| 12859 | ZigType *wanted_type) | 13940 | ZigType *wanted_type) |
| 12860 | { | 13941 | { |
| 12861 | assert(target->value->type->id == ZigTypeIdInt); | 13942 | assert(target->value->type->id == ZigTypeIdInt); |
| ... | @@ -12865,12 +13946,12 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12865,12 +13946,12 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc |
| 12865 | if (instr_is_comptime(target)) { | 13946 | if (instr_is_comptime(target)) { |
| 12866 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 13947 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12867 | if (!val) | 13948 | if (!val) |
| 12868 | return ira->codegen->invalid_instruction; | 13949 | return ira->codegen->invalid_inst_gen; |
| 12869 | | 13950 | |
| 12870 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13951 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12871 | | 13952 | |
| 12872 | if (!resolve_inferred_error_set(ira->codegen, wanted_type, source_instr->source_node)) { | 13953 | if (!resolve_inferred_error_set(ira->codegen, wanted_type, source_instr->source_node)) { |
| 12873 | return ira->codegen->invalid_instruction; | 13954 | return ira->codegen->invalid_inst_gen; |
| 12874 | } | 13955 | } |
| 12875 | | 13956 | |
| 12876 | if (type_is_global_error_set(wanted_type)) { | 13957 | if (type_is_global_error_set(wanted_type)) { |
| ... | @@ -12882,7 +13963,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12882,7 +13963,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc |
| 12882 | bigint_append_buf(val_buf, &val->data.x_bigint, 10); | 13963 | bigint_append_buf(val_buf, &val->data.x_bigint, 10); |
| 12883 | ir_add_error(ira, source_instr, | 13964 | ir_add_error(ira, source_instr, |
| 12884 | buf_sprintf("integer value %s represents no error", buf_ptr(val_buf))); | 13965 | buf_sprintf("integer value %s represents no error", buf_ptr(val_buf))); |
| 12885 | return ira->codegen->invalid_instruction; | 13966 | return ira->codegen->invalid_inst_gen; |
| 12886 | } | 13967 | } |
| 12887 | | 13968 | |
| 12888 | size_t index = bigint_as_usize(&val->data.x_bigint); | 13969 | size_t index = bigint_as_usize(&val->data.x_bigint); |
| ... | @@ -12906,7 +13987,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12906,7 +13987,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc |
| 12906 | bigint_append_buf(val_buf, &val->data.x_bigint, 10); | 13987 | bigint_append_buf(val_buf, &val->data.x_bigint, 10); |
| 12907 | ir_add_error(ira, source_instr, | 13988 | ir_add_error(ira, source_instr, |
| 12908 | buf_sprintf("integer value %s represents no error in '%s'", buf_ptr(val_buf), buf_ptr(&wanted_type->name))); | 13989 | buf_sprintf("integer value %s represents no error in '%s'", buf_ptr(val_buf), buf_ptr(&wanted_type->name))); |
| 12909 | return ira->codegen->invalid_instruction; | 13990 | return ira->codegen->invalid_inst_gen; |
| 12910 | } | 13991 | } |
| 12911 | | 13992 | |
| 12912 | result->value->data.x_err_set = err; | 13993 | result->value->data.x_err_set = err; |
| ... | @@ -12914,12 +13995,10 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12914,12 +13995,10 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc |
| 12914 | } | 13995 | } |
| 12915 | } | 13996 | } |
| 12916 | | 13997 | |
| 12917 | IrInstruction *result = ir_build_int_to_err(&ira->new_irb, source_instr->scope, source_instr->source_node, target); | 13998 | return ir_build_int_to_err_gen(ira, source_instr->scope, source_instr->source_node, target, wanted_type); |
| 12918 | result->value->type = wanted_type; | | |
| 12919 | return result; | | |
| 12920 | } | 13999 | } |
| 12921 | | 14000 | |
| 12922 | static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, | 14001 | static IrInstGen *ir_analyze_err_to_int(IrAnalyze *ira, IrInst* source_instr, IrInstGen *target, |
| 12923 | ZigType *wanted_type) | 14002 | ZigType *wanted_type) |
| 12924 | { | 14003 | { |
| 12925 | assert(wanted_type->id == ZigTypeIdInt); | 14004 | assert(wanted_type->id == ZigTypeIdInt); |
| ... | @@ -12929,9 +14008,9 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12929,9 +14008,9 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 12929 | if (instr_is_comptime(target)) { | 14008 | if (instr_is_comptime(target)) { |
| 12930 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 14009 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12931 | if (!val) | 14010 | if (!val) |
| 12932 | return ira->codegen->invalid_instruction; | 14011 | return ira->codegen->invalid_inst_gen; |
| 12933 | | 14012 | |
| 12934 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 14013 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12935 | | 14014 | |
| 12936 | ErrorTableEntry *err; | 14015 | ErrorTableEntry *err; |
| 12937 | if (err_type->id == ZigTypeIdErrorUnion) { | 14016 | if (err_type->id == ZigTypeIdErrorUnion) { |
| ... | @@ -12951,7 +14030,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12951,7 +14030,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 12951 | ir_add_error_node(ira, source_instr->source_node, | 14030 | ir_add_error_node(ira, source_instr->source_node, |
| 12952 | buf_sprintf("error code '%s' does not fit in '%s'", | 14031 | buf_sprintf("error code '%s' does not fit in '%s'", |
| 12953 | buf_ptr(&err->name), buf_ptr(&wanted_type->name))); | 14032 | buf_ptr(&err->name), buf_ptr(&wanted_type->name))); |
| 12954 | return ira->codegen->invalid_instruction; | 14033 | return ira->codegen->invalid_inst_gen; |
| 12955 | } | 14034 | } |
| 12956 | | 14035 | |
| 12957 | return result; | 14036 | return result; |
| ... | @@ -12967,14 +14046,14 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12967,14 +14046,14 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 12967 | } | 14046 | } |
| 12968 | if (!type_is_global_error_set(err_set_type)) { | 14047 | if (!type_is_global_error_set(err_set_type)) { |
| 12969 | if (!resolve_inferred_error_set(ira->codegen, err_set_type, source_instr->source_node)) { | 14048 | if (!resolve_inferred_error_set(ira->codegen, err_set_type, source_instr->source_node)) { |
| 12970 | return ira->codegen->invalid_instruction; | 14049 | return ira->codegen->invalid_inst_gen; |
| 12971 | } | 14050 | } |
| 12972 | if (err_set_type->data.error_set.err_count == 0) { | 14051 | if (err_set_type->data.error_set.err_count == 0) { |
| 12973 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 14052 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12974 | bigint_init_unsigned(&result->value->data.x_bigint, 0); | 14053 | bigint_init_unsigned(&result->value->data.x_bigint, 0); |
| 12975 | return result; | 14054 | return result; |
| 12976 | } else if (err_set_type->data.error_set.err_count == 1) { | 14055 | } else if (err_set_type->data.error_set.err_count == 1) { |
| 12977 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 14056 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12978 | ErrorTableEntry *err = err_set_type->data.error_set.errors[0]; | 14057 | ErrorTableEntry *err = err_set_type->data.error_set.errors[0]; |
| 12979 | bigint_init_unsigned(&result->value->data.x_bigint, err->value); | 14058 | bigint_init_unsigned(&result->value->data.x_bigint, err->value); |
| 12980 | return result; | 14059 | return result; |
| ... | @@ -12986,21 +14065,19 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12986,21 +14065,19 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 12986 | if (!bigint_fits_in_bits(&bn, wanted_type->data.integral.bit_count, wanted_type->data.integral.is_signed)) { | 14065 | if (!bigint_fits_in_bits(&bn, wanted_type->data.integral.bit_count, wanted_type->data.integral.is_signed)) { |
| 12987 | ir_add_error_node(ira, source_instr->source_node, | 14066 | ir_add_error_node(ira, source_instr->source_node, |
| 12988 | buf_sprintf("too many error values to fit in '%s'", buf_ptr(&wanted_type->name))); | 14067 | buf_sprintf("too many error values to fit in '%s'", buf_ptr(&wanted_type->name))); |
| 12989 | return ira->codegen->invalid_instruction; | 14068 | return ira->codegen->invalid_inst_gen; |
| 12990 | } | 14069 | } |
| 12991 | | 14070 | |
| 12992 | IrInstruction *result = ir_build_err_to_int(&ira->new_irb, source_instr->scope, source_instr->source_node, target); | 14071 | return ir_build_err_to_int_gen(ira, source_instr->scope, source_instr->source_node, target, wanted_type); |
| 12993 | result->value->type = wanted_type; | | |
| 12994 | return result; | | |
| 12995 | } | 14072 | } |
| 12996 | | 14073 | |
| 12997 | static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, | 14074 | static IrInstGen *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInst* source_instr, IrInstGen *target, |
| 12998 | ZigType *wanted_type) | 14075 | ZigType *wanted_type) |
| 12999 | { | 14076 | { |
| 13000 | assert(wanted_type->id == ZigTypeIdPointer); | 14077 | assert(wanted_type->id == ZigTypeIdPointer); |
| 13001 | Error err; | 14078 | Error err; |
| 13002 | if ((err = type_resolve(ira->codegen, target->value->type->data.pointer.child_type, ResolveStatusAlignmentKnown))) | 14079 | if ((err = type_resolve(ira->codegen, target->value->type->data.pointer.child_type, ResolveStatusAlignmentKnown))) |
| 13003 | return ira->codegen->invalid_instruction; | 14080 | return ira->codegen->invalid_inst_gen; |
| 13004 | assert((wanted_type->data.pointer.is_const && target->value->type->data.pointer.is_const) || !target->value->type->data.pointer.is_const); | 14081 | assert((wanted_type->data.pointer.is_const && target->value->type->data.pointer.is_const) || !target->value->type->data.pointer.is_const); |
| 13005 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, target->value->type)); | 14082 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, target->value->type)); |
| 13006 | ZigType *array_type = wanted_type->data.pointer.child_type; | 14083 | ZigType *array_type = wanted_type->data.pointer.child_type; |
| ... | @@ -13010,12 +14087,12 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou | ... | @@ -13010,12 +14087,12 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou |
| 13010 | if (instr_is_comptime(target)) { | 14087 | if (instr_is_comptime(target)) { |
| 13011 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 14088 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 13012 | if (!val) | 14089 | if (!val) |
| 13013 | return ira->codegen->invalid_instruction; | 14090 | return ira->codegen->invalid_inst_gen; |
| 13014 | | 14091 | |
| 13015 | assert(val->type->id == ZigTypeIdPointer); | 14092 | assert(val->type->id == ZigTypeIdPointer); |
| 13016 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, val, source_instr->source_node); | 14093 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, val, source_instr->source_node); |
| 13017 | if (pointee == nullptr) | 14094 | if (pointee == nullptr) |
| 13018 | return ira->codegen->invalid_instruction; | 14095 | return ira->codegen->invalid_inst_gen; |
| 13019 | if (pointee->special != ConstValSpecialRuntime) { | 14096 | if (pointee->special != ConstValSpecialRuntime) { |
| 13020 | ZigValue *array_val = create_const_vals(1); | 14097 | ZigValue *array_val = create_const_vals(1); |
| 13021 | array_val->special = ConstValSpecialStatic; | 14098 | array_val->special = ConstValSpecialStatic; |
| ... | @@ -13025,7 +14102,7 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou | ... | @@ -13025,7 +14102,7 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou |
| 13025 | array_val->parent.id = ConstParentIdScalar; | 14102 | array_val->parent.id = ConstParentIdScalar; |
| 13026 | array_val->parent.data.p_scalar.scalar_val = pointee; | 14103 | array_val->parent.data.p_scalar.scalar_val = pointee; |
| 13027 | | 14104 | |
| 13028 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 14105 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, |
| 13029 | source_instr->scope, source_instr->source_node); | 14106 | source_instr->scope, source_instr->source_node); |
| 13030 | const_instruction->base.value->type = wanted_type; | 14107 | const_instruction->base.value->type = wanted_type; |
| 13031 | const_instruction->base.value->special = ConstValSpecialStatic; | 14108 | const_instruction->base.value->special = ConstValSpecialStatic; |
| ... | @@ -13037,10 +14114,7 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou | ... | @@ -13037,10 +14114,7 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou |
| 13037 | } | 14114 | } |
| 13038 | | 14115 | |
| 13039 | // pointer to array and pointer to single item are represented the same way at runtime | 14116 | // pointer to array and pointer to single item are represented the same way at runtime |
| 13040 | IrInstruction *result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, | 14117 | return ir_build_cast(ira, &target->base, wanted_type, target, CastOpBitCast); |
| 13041 | wanted_type, target, CastOpBitCast); | | |
| 13042 | result->value->type = wanted_type; | | |
| 13043 | return result; | | |
| 13044 | } | 14118 | } |
| 13045 | | 14119 | |
| 13046 | static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCastOnly *cast_result, | 14120 | static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCastOnly *cast_result, |
| ... | @@ -13228,12 +14302,12 @@ static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCa | ... | @@ -13228,12 +14302,12 @@ static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCa |
| 13228 | } | 14302 | } |
| 13229 | } | 14303 | } |
| 13230 | | 14304 | |
| 13231 | static IrInstruction *ir_analyze_array_to_vector(IrAnalyze *ira, IrInstruction *source_instr, | 14305 | static IrInstGen *ir_analyze_array_to_vector(IrAnalyze *ira, IrInst* source_instr, |
| 13232 | IrInstruction *array, ZigType *vector_type) | 14306 | IrInstGen *array, ZigType *vector_type) |
| 13233 | { | 14307 | { |
| 13234 | if (instr_is_comptime(array)) { | 14308 | if (instr_is_comptime(array)) { |
| 13235 | // arrays and vectors have the same ZigValue representation | 14309 | // arrays and vectors have the same ZigValue representation |
| 13236 | IrInstruction *result = ir_const(ira, source_instr, vector_type); | 14310 | IrInstGen *result = ir_const(ira, source_instr, vector_type); |
| 13237 | copy_const_val(result->value, array->value); | 14311 | copy_const_val(result->value, array->value); |
| 13238 | result->value->type = vector_type; | 14312 | result->value->type = vector_type; |
| 13239 | return result; | 14313 | return result; |
| ... | @@ -13241,12 +14315,12 @@ static IrInstruction *ir_analyze_array_to_vector(IrAnalyze *ira, IrInstruction * | ... | @@ -13241,12 +14315,12 @@ static IrInstruction *ir_analyze_array_to_vector(IrAnalyze *ira, IrInstruction * |
| 13241 | return ir_build_array_to_vector(ira, source_instr, array, vector_type); | 14315 | return ir_build_array_to_vector(ira, source_instr, array, vector_type); |
| 13242 | } | 14316 | } |
| 13243 | | 14317 | |
| 13244 | static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction *source_instr, | 14318 | static IrInstGen *ir_analyze_vector_to_array(IrAnalyze *ira, IrInst* source_instr, |
| 13245 | IrInstruction *vector, ZigType *array_type, ResultLoc *result_loc) | 14319 | IrInstGen *vector, ZigType *array_type, ResultLoc *result_loc) |
| 13246 | { | 14320 | { |
| 13247 | if (instr_is_comptime(vector)) { | 14321 | if (instr_is_comptime(vector)) { |
| 13248 | // arrays and vectors have the same ZigValue representation | 14322 | // arrays and vectors have the same ZigValue representation |
| 13249 | IrInstruction *result = ir_const(ira, source_instr, array_type); | 14323 | IrInstGen *result = ir_const(ira, source_instr, array_type); |
| 13250 | copy_const_val(result->value, vector->value); | 14324 | copy_const_val(result->value, vector->value); |
| 13251 | result->value->type = array_type; | 14325 | result->value->type = array_type; |
| 13252 | return result; | 14326 | return result; |
| ... | @@ -13254,18 +14328,17 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction * | ... | @@ -13254,18 +14328,17 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction * |
| 13254 | if (result_loc == nullptr) { | 14328 | if (result_loc == nullptr) { |
| 13255 | result_loc = no_result_loc(); | 14329 | result_loc = no_result_loc(); |
| 13256 | } | 14330 | } |
| 13257 | IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, array_type, nullptr, | 14331 | IrInstGen *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, array_type, nullptr, true, true); |
| 13258 | true, true); | 14332 | if (type_is_invalid(result_loc_inst->value->type) || result_loc_inst->value->type->id == ZigTypeIdUnreachable) { |
| 13259 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { | | |
| 13260 | return result_loc_inst; | 14333 | return result_loc_inst; |
| 13261 | } | 14334 | } |
| 13262 | return ir_build_vector_to_array(ira, source_instr, array_type, vector, result_loc_inst); | 14335 | return ir_build_vector_to_array(ira, source_instr, array_type, vector, result_loc_inst); |
| 13263 | } | 14336 | } |
| 13264 | | 14337 | |
| 13265 | static IrInstruction *ir_analyze_int_to_c_ptr(IrAnalyze *ira, IrInstruction *source_instr, | 14338 | static IrInstGen *ir_analyze_int_to_c_ptr(IrAnalyze *ira, IrInst* source_instr, |
| 13266 | IrInstruction *integer, ZigType *dest_type) | 14339 | IrInstGen *integer, ZigType *dest_type) |
| 13267 | { | 14340 | { |
| 13268 | IrInstruction *unsigned_integer; | 14341 | IrInstGen *unsigned_integer; |
| 13269 | if (instr_is_comptime(integer)) { | 14342 | if (instr_is_comptime(integer)) { |
| 13270 | unsigned_integer = integer; | 14343 | unsigned_integer = integer; |
| 13271 | } else { | 14344 | } else { |
| ... | @@ -13278,7 +14351,7 @@ static IrInstruction *ir_analyze_int_to_c_ptr(IrAnalyze *ira, IrInstruction *sou | ... | @@ -13278,7 +14351,7 @@ static IrInstruction *ir_analyze_int_to_c_ptr(IrAnalyze *ira, IrInstruction *sou |
| 13278 | buf_sprintf("integer type '%s' too big for implicit @intToPtr to type '%s'", | 14351 | buf_sprintf("integer type '%s' too big for implicit @intToPtr to type '%s'", |
| 13279 | buf_ptr(&integer->value->type->name), | 14352 | buf_ptr(&integer->value->type->name), |
| 13280 | buf_ptr(&dest_type->name))); | 14353 | buf_ptr(&dest_type->name))); |
| 13281 | return ira->codegen->invalid_instruction; | 14354 | return ira->codegen->invalid_inst_gen; |
| 13282 | } | 14355 | } |
| 13283 | | 14356 | |
| 13284 | if (integer->value->type->data.integral.is_signed) { | 14357 | if (integer->value->type->data.integral.is_signed) { |
| ... | @@ -13286,7 +14359,7 @@ static IrInstruction *ir_analyze_int_to_c_ptr(IrAnalyze *ira, IrInstruction *sou | ... | @@ -13286,7 +14359,7 @@ static IrInstruction *ir_analyze_int_to_c_ptr(IrAnalyze *ira, IrInstruction *sou |
| 13286 | integer->value->type->data.integral.bit_count); | 14359 | integer->value->type->data.integral.bit_count); |
| 13287 | unsigned_integer = ir_analyze_bit_cast(ira, source_instr, integer, unsigned_int_type); | 14360 | unsigned_integer = ir_analyze_bit_cast(ira, source_instr, integer, unsigned_int_type); |
| 13288 | if (type_is_invalid(unsigned_integer->value->type)) | 14361 | if (type_is_invalid(unsigned_integer->value->type)) |
| 13289 | return ira->codegen->invalid_instruction; | 14362 | return ira->codegen->invalid_inst_gen; |
| 13290 | } else { | 14363 | } else { |
| 13291 | unsigned_integer = integer; | 14364 | unsigned_integer = integer; |
| 13292 | } | 14365 | } |
| ... | @@ -13306,14 +14379,14 @@ static bool is_pointery_and_elem_is_not_pointery(ZigType *ty) { | ... | @@ -13306,14 +14379,14 @@ static bool is_pointery_and_elem_is_not_pointery(ZigType *ty) { |
| 13306 | return false; | 14379 | return false; |
| 13307 | } | 14380 | } |
| 13308 | | 14381 | |
| 13309 | static IrInstruction *ir_analyze_enum_literal(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 14382 | static IrInstGen *ir_analyze_enum_literal(IrAnalyze *ira, IrInst* source_instr, IrInstGen *value, |
| 13310 | ZigType *enum_type) | 14383 | ZigType *enum_type) |
| 13311 | { | 14384 | { |
| 13312 | assert(enum_type->id == ZigTypeIdEnum); | 14385 | assert(enum_type->id == ZigTypeIdEnum); |
| 13313 | | 14386 | |
| 13314 | Error err; | 14387 | Error err; |
| 13315 | if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusZeroBitsKnown))) | 14388 | if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusZeroBitsKnown))) |
| 13316 | return ira->codegen->invalid_instruction; | 14389 | return ira->codegen->invalid_inst_gen; |
| 13317 | | 14390 | |
| 13318 | TypeEnumField *field = find_enum_type_field(enum_type, value->value->data.x_enum_literal); | 14391 | TypeEnumField *field = find_enum_type_field(enum_type, value->value->data.x_enum_literal); |
| 13319 | if (field == nullptr) { | 14392 | if (field == nullptr) { |
| ... | @@ -13321,40 +14394,40 @@ static IrInstruction *ir_analyze_enum_literal(IrAnalyze *ira, IrInstruction *sou | ... | @@ -13321,40 +14394,40 @@ static IrInstruction *ir_analyze_enum_literal(IrAnalyze *ira, IrInstruction *sou |
| 13321 | buf_ptr(&enum_type->name), buf_ptr(value->value->data.x_enum_literal))); | 14394 | buf_ptr(&enum_type->name), buf_ptr(value->value->data.x_enum_literal))); |
| 13322 | add_error_note(ira->codegen, msg, enum_type->data.enumeration.decl_node, | 14395 | add_error_note(ira->codegen, msg, enum_type->data.enumeration.decl_node, |
| 13323 | buf_sprintf("'%s' declared here", buf_ptr(&enum_type->name))); | 14396 | buf_sprintf("'%s' declared here", buf_ptr(&enum_type->name))); |
| 13324 | return ira->codegen->invalid_instruction; | 14397 | return ira->codegen->invalid_inst_gen; |
| 13325 | } | 14398 | } |
| 13326 | IrInstruction *result = ir_const(ira, source_instr, enum_type); | 14399 | IrInstGen *result = ir_const(ira, source_instr, enum_type); |
| 13327 | bigint_init_bigint(&result->value->data.x_enum_tag, &field->value); | 14400 | bigint_init_bigint(&result->value->data.x_enum_tag, &field->value); |
| 13328 | | 14401 | |
| 13329 | return result; | 14402 | return result; |
| 13330 | } | 14403 | } |
| 13331 | | 14404 | |
| 13332 | static IrInstruction *ir_analyze_struct_literal_to_array(IrAnalyze *ira, IrInstruction *source_instr, | 14405 | static IrInstGen *ir_analyze_struct_literal_to_array(IrAnalyze *ira, IrInst* source_instr, |
| 13333 | IrInstruction *value, ZigType *wanted_type) | 14406 | IrInstGen *value, ZigType *wanted_type) |
| 13334 | { | 14407 | { |
| 13335 | ir_add_error(ira, source_instr, buf_sprintf("TODO: type coercion of anon list literal to array")); | 14408 | ir_add_error(ira, source_instr, buf_sprintf("TODO: type coercion of anon list literal to array")); |
| 13336 | return ira->codegen->invalid_instruction; | 14409 | return ira->codegen->invalid_inst_gen; |
| 13337 | } | 14410 | } |
| 13338 | | 14411 | |
| 13339 | static IrInstruction *ir_analyze_struct_literal_to_struct(IrAnalyze *ira, IrInstruction *source_instr, | 14412 | static IrInstGen *ir_analyze_struct_literal_to_struct(IrAnalyze *ira, IrInst* source_instr, |
| 13340 | IrInstruction *value, ZigType *wanted_type) | 14413 | IrInstGen *value, ZigType *wanted_type) |
| 13341 | { | 14414 | { |
| 13342 | ir_add_error(ira, source_instr, buf_sprintf("TODO: type coercion of anon struct literal to struct")); | 14415 | ir_add_error(ira, source_instr, buf_sprintf("TODO: type coercion of anon struct literal to struct")); |
| 13343 | return ira->codegen->invalid_instruction; | 14416 | return ira->codegen->invalid_inst_gen; |
| 13344 | } | 14417 | } |
| 13345 | | 14418 | |
| 13346 | static IrInstruction *ir_analyze_struct_literal_to_union(IrAnalyze *ira, IrInstruction *source_instr, | 14419 | static IrInstGen *ir_analyze_struct_literal_to_union(IrAnalyze *ira, IrInst* source_instr, |
| 13347 | IrInstruction *value, ZigType *wanted_type) | 14420 | IrInstGen *value, ZigType *wanted_type) |
| 13348 | { | 14421 | { |
| 13349 | ir_add_error(ira, source_instr, buf_sprintf("TODO: type coercion of anon struct literal to union")); | 14422 | ir_add_error(ira, source_instr, buf_sprintf("TODO: type coercion of anon struct literal to union")); |
| 13350 | return ira->codegen->invalid_instruction; | 14423 | return ira->codegen->invalid_inst_gen; |
| 13351 | } | 14424 | } |
| 13352 | | 14425 | |
| 13353 | // Add a compile error and return ErrorSemanticAnalyzeFail if the pointer alignment does not work, | 14426 | // Add a compile error and return ErrorSemanticAnalyzeFail if the pointer alignment does not work, |
| 13354 | // otherwise return ErrorNone. Does not emit any instructions. | 14427 | // otherwise return ErrorNone. Does not emit any instructions. |
| 13355 | // Assumes that the pointer types have element types with the same ABI alignment. Avoids resolving the | 14428 | // Assumes that the pointer types have element types with the same ABI alignment. Avoids resolving the |
| 13356 | // pointer types' alignments if both of the pointer types are ABI aligned. | 14429 | // pointer types' alignments if both of the pointer types are ABI aligned. |
| 13357 | static Error ir_cast_ptr_align(IrAnalyze *ira, IrInstruction *source_instr, ZigType *dest_ptr_type, | 14430 | static Error ir_cast_ptr_align(IrAnalyze *ira, IrInst* source_instr, ZigType *dest_ptr_type, |
| 13358 | ZigType *src_ptr_type, AstNode *src_source_node) | 14431 | ZigType *src_ptr_type, AstNode *src_source_node) |
| 13359 | { | 14432 | { |
| 13360 | Error err; | 14433 | Error err; |
| ... | @@ -13388,37 +14461,37 @@ static Error ir_cast_ptr_align(IrAnalyze *ira, IrInstruction *source_instr, ZigT | ... | @@ -13388,37 +14461,37 @@ static Error ir_cast_ptr_align(IrAnalyze *ira, IrInstruction *source_instr, ZigT |
| 13388 | return ErrorNone; | 14461 | return ErrorNone; |
| 13389 | } | 14462 | } |
| 13390 | | 14463 | |
| 13391 | static IrInstruction *ir_analyze_struct_value_field_value(IrAnalyze *ira, IrInstruction *source_instr, | 14464 | static IrInstGen *ir_analyze_struct_value_field_value(IrAnalyze *ira, IrInst* source_instr, |
| 13392 | IrInstruction *struct_operand, TypeStructField *field) | 14465 | IrInstGen *struct_operand, TypeStructField *field) |
| 13393 | { | 14466 | { |
| 13394 | IrInstruction *struct_ptr = ir_get_ref(ira, source_instr, struct_operand, true, false); | 14467 | IrInstGen *struct_ptr = ir_get_ref(ira, source_instr, struct_operand, true, false); |
| 13395 | if (type_is_invalid(struct_ptr->value->type)) | 14468 | if (type_is_invalid(struct_ptr->value->type)) |
| 13396 | return ira->codegen->invalid_instruction; | 14469 | return ira->codegen->invalid_inst_gen; |
| 13397 | IrInstruction *field_ptr = ir_analyze_struct_field_ptr(ira, source_instr, field, struct_ptr, | 14470 | IrInstGen *field_ptr = ir_analyze_struct_field_ptr(ira, source_instr, field, struct_ptr, |
| 13398 | struct_operand->value->type, false); | 14471 | struct_operand->value->type, false); |
| 13399 | if (type_is_invalid(field_ptr->value->type)) | 14472 | if (type_is_invalid(field_ptr->value->type)) |
| 13400 | return ira->codegen->invalid_instruction; | 14473 | return ira->codegen->invalid_inst_gen; |
| 13401 | return ir_get_deref(ira, source_instr, field_ptr, nullptr); | 14474 | return ir_get_deref(ira, source_instr, field_ptr, nullptr); |
| 13402 | } | 14475 | } |
| 13403 | | 14476 | |
| 13404 | static IrInstruction *ir_analyze_optional_value_payload_value(IrAnalyze *ira, IrInstruction *source_instr, | 14477 | static IrInstGen *ir_analyze_optional_value_payload_value(IrAnalyze *ira, IrInst* source_instr, |
| 13405 | IrInstruction *optional_operand, bool safety_check_on) | 14478 | IrInstGen *optional_operand, bool safety_check_on) |
| 13406 | { | 14479 | { |
| 13407 | IrInstruction *opt_ptr = ir_get_ref(ira, source_instr, optional_operand, true, false); | 14480 | IrInstGen *opt_ptr = ir_get_ref(ira, source_instr, optional_operand, true, false); |
| 13408 | IrInstruction *payload_ptr = ir_analyze_unwrap_optional_payload(ira, source_instr, opt_ptr, | 14481 | IrInstGen *payload_ptr = ir_analyze_unwrap_optional_payload(ira, source_instr, opt_ptr, |
| 13409 | safety_check_on, false); | 14482 | safety_check_on, false); |
| 13410 | return ir_get_deref(ira, source_instr, payload_ptr, nullptr); | 14483 | return ir_get_deref(ira, source_instr, payload_ptr, nullptr); |
| 13411 | } | 14484 | } |
| 13412 | | 14485 | |
| 13413 | static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_instr, | 14486 | static IrInstGen *ir_analyze_cast(IrAnalyze *ira, IrInst *source_instr, |
| 13414 | ZigType *wanted_type, IrInstruction *value) | 14487 | ZigType *wanted_type, IrInstGen *value) |
| 13415 | { | 14488 | { |
| 13416 | Error err; | 14489 | Error err; |
| 13417 | ZigType *actual_type = value->value->type; | 14490 | ZigType *actual_type = value->value->type; |
| 13418 | AstNode *source_node = source_instr->source_node; | 14491 | AstNode *source_node = source_instr->source_node; |
| 13419 | | 14492 | |
| 13420 | if (type_is_invalid(wanted_type) || type_is_invalid(actual_type)) { | 14493 | if (type_is_invalid(wanted_type) || type_is_invalid(actual_type)) { |
| 13421 | return ira->codegen->invalid_instruction; | 14494 | return ira->codegen->invalid_inst_gen; |
| 13422 | } | 14495 | } |
| 13423 | | 14496 | |
| 13424 | // This means the wanted type is anything. | 14497 | // This means the wanted type is anything. |
| ... | @@ -13430,7 +14503,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13430,7 +14503,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13430 | ConstCastOnly const_cast_result = types_match_const_cast_only(ira, wanted_type, actual_type, | 14503 | ConstCastOnly const_cast_result = types_match_const_cast_only(ira, wanted_type, actual_type, |
| 13431 | source_node, false); | 14504 | source_node, false); |
| 13432 | if (const_cast_result.id == ConstCastResultIdInvalid) | 14505 | if (const_cast_result.id == ConstCastResultIdInvalid) |
| 13433 | return ira->codegen->invalid_instruction; | 14506 | return ira->codegen->invalid_inst_gen; |
| 13434 | if (const_cast_result.id == ConstCastResultIdOk) { | 14507 | if (const_cast_result.id == ConstCastResultIdOk) { |
| 13435 | return ir_resolve_cast(ira, source_instr, value, wanted_type, CastOpNoop); | 14508 | return ir_resolve_cast(ira, source_instr, value, wanted_type, CastOpNoop); |
| 13436 | } | 14509 | } |
| ... | @@ -13464,7 +14537,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13464,7 +14537,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13464 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_child_type, true)) { | 14537 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_child_type, true)) { |
| 13465 | return ir_analyze_optional_wrap(ira, source_instr, value, wanted_type, nullptr); | 14538 | return ir_analyze_optional_wrap(ira, source_instr, value, wanted_type, nullptr); |
| 13466 | } else { | 14539 | } else { |
| 13467 | return ira->codegen->invalid_instruction; | 14540 | return ira->codegen->invalid_inst_gen; |
| 13468 | } | 14541 | } |
| 13469 | } else if ( | 14542 | } else if ( |
| 13470 | wanted_child_type->id == ZigTypeIdPointer && | 14543 | wanted_child_type->id == ZigTypeIdPointer && |
| ... | @@ -13474,18 +14547,18 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13474,18 +14547,18 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13474 | actual_type->data.pointer.child_type->id == ZigTypeIdArray) | 14547 | actual_type->data.pointer.child_type->id == ZigTypeIdArray) |
| 13475 | { | 14548 | { |
| 13476 | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) | 14549 | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) |
| 13477 | return ira->codegen->invalid_instruction; | 14550 | return ira->codegen->invalid_inst_gen; |
| 13478 | if ((err = type_resolve(ira->codegen, wanted_child_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) | 14551 | if ((err = type_resolve(ira->codegen, wanted_child_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) |
| 13479 | return ira->codegen->invalid_instruction; | 14552 | return ira->codegen->invalid_inst_gen; |
| 13480 | if (get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, wanted_child_type) && | 14553 | if (get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, wanted_child_type) && |
| 13481 | types_match_const_cast_only(ira, wanted_child_type->data.pointer.child_type, | 14554 | types_match_const_cast_only(ira, wanted_child_type->data.pointer.child_type, |
| 13482 | actual_type->data.pointer.child_type->data.array.child_type, source_node, | 14555 | actual_type->data.pointer.child_type->data.array.child_type, source_node, |
| 13483 | !wanted_child_type->data.pointer.is_const).id == ConstCastResultIdOk) | 14556 | !wanted_child_type->data.pointer.is_const).id == ConstCastResultIdOk) |
| 13484 | { | 14557 | { |
| 13485 | IrInstruction *cast1 = ir_resolve_ptr_of_array_to_unknown_len_ptr(ira, source_instr, value, | 14558 | IrInstGen *cast1 = ir_resolve_ptr_of_array_to_unknown_len_ptr(ira, source_instr, value, |
| 13486 | wanted_child_type); | 14559 | wanted_child_type); |
| 13487 | if (type_is_invalid(cast1->value->type)) | 14560 | if (type_is_invalid(cast1->value->type)) |
| 13488 | return ira->codegen->invalid_instruction; | 14561 | return ira->codegen->invalid_inst_gen; |
| 13489 | return ir_analyze_optional_wrap(ira, source_instr, cast1, wanted_type, nullptr); | 14562 | return ir_analyze_optional_wrap(ira, source_instr, cast1, wanted_type, nullptr); |
| 13490 | } | 14563 | } |
| 13491 | } | 14564 | } |
| ... | @@ -13503,7 +14576,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13503,7 +14576,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13503 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_type->data.error_union.payload_type, true)) { | 14576 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_type->data.error_union.payload_type, true)) { |
| 13504 | return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type, nullptr); | 14577 | return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type, nullptr); |
| 13505 | } else { | 14578 | } else { |
| 13506 | return ira->codegen->invalid_instruction; | 14579 | return ira->codegen->invalid_inst_gen; |
| 13507 | } | 14580 | } |
| 13508 | } | 14581 | } |
| 13509 | } | 14582 | } |
| ... | @@ -13519,13 +14592,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13519,13 +14592,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13519 | actual_type->id == ZigTypeIdComptimeInt || | 14592 | actual_type->id == ZigTypeIdComptimeInt || |
| 13520 | actual_type->id == ZigTypeIdComptimeFloat) | 14593 | actual_type->id == ZigTypeIdComptimeFloat) |
| 13521 | { | 14594 | { |
| 13522 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); | 14595 | IrInstGen *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); |
| 13523 | if (type_is_invalid(cast1->value->type)) | 14596 | if (type_is_invalid(cast1->value->type)) |
| 13524 | return ira->codegen->invalid_instruction; | 14597 | return ira->codegen->invalid_inst_gen; |
| 13525 | | 14598 | |
| 13526 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 14599 | IrInstGen *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13527 | if (type_is_invalid(cast2->value->type)) | 14600 | if (type_is_invalid(cast2->value->type)) |
| 13528 | return ira->codegen->invalid_instruction; | 14601 | return ira->codegen->invalid_inst_gen; |
| 13529 | | 14602 | |
| 13530 | return cast2; | 14603 | return cast2; |
| 13531 | } | 14604 | } |
| ... | @@ -13540,13 +14613,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13540,13 +14613,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13540 | wanted_type->id == ZigTypeIdFloat || wanted_type->id == ZigTypeIdComptimeFloat)) | 14613 | wanted_type->id == ZigTypeIdFloat || wanted_type->id == ZigTypeIdComptimeFloat)) |
| 13541 | { | 14614 | { |
| 13542 | if (value->value->special == ConstValSpecialUndef) { | 14615 | if (value->value->special == ConstValSpecialUndef) { |
| 13543 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 14616 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 13544 | result->value->special = ConstValSpecialUndef; | 14617 | result->value->special = ConstValSpecialUndef; |
| 13545 | return result; | 14618 | return result; |
| 13546 | } | 14619 | } |
| 13547 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) { | 14620 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) { |
| 13548 | if (wanted_type->id == ZigTypeIdComptimeInt || wanted_type->id == ZigTypeIdInt) { | 14621 | if (wanted_type->id == ZigTypeIdComptimeInt || wanted_type->id == ZigTypeIdInt) { |
| 13549 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 14622 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 13550 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { | 14623 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { |
| 13551 | copy_const_val(result->value, value->value); | 14624 | copy_const_val(result->value, value->value); |
| 13552 | result->value->type = wanted_type; | 14625 | result->value->type = wanted_type; |
| ... | @@ -13555,7 +14628,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13555,7 +14628,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13555 | } | 14628 | } |
| 13556 | return result; | 14629 | return result; |
| 13557 | } else if (wanted_type->id == ZigTypeIdComptimeFloat || wanted_type->id == ZigTypeIdFloat) { | 14630 | } else if (wanted_type->id == ZigTypeIdComptimeFloat || wanted_type->id == ZigTypeIdFloat) { |
| 13558 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 14631 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 13559 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { | 14632 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { |
| 13560 | BigFloat bf; | 14633 | BigFloat bf; |
| 13561 | bigfloat_init_bigint(&bf, &value->value->data.x_bigint); | 14634 | bigfloat_init_bigint(&bf, &value->value->data.x_bigint); |
| ... | @@ -13567,7 +14640,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13567,7 +14640,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13567 | } | 14640 | } |
| 13568 | zig_unreachable(); | 14641 | zig_unreachable(); |
| 13569 | } else { | 14642 | } else { |
| 13570 | return ira->codegen->invalid_instruction; | 14643 | return ira->codegen->invalid_inst_gen; |
| 13571 | } | 14644 | } |
| 13572 | } | 14645 | } |
| 13573 | | 14646 | |
| ... | @@ -13603,13 +14676,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13603,13 +14676,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13603 | actual_type->data.pointer.ptr_len == PtrLenSingle && | 14676 | actual_type->data.pointer.ptr_len == PtrLenSingle && |
| 13604 | actual_type->data.pointer.child_type->id == ZigTypeIdArray) | 14677 | actual_type->data.pointer.child_type->id == ZigTypeIdArray) |
| 13605 | { | 14678 | { |
| 13606 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value); | 14679 | IrInstGen *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value); |
| 13607 | if (type_is_invalid(cast1->value->type)) | 14680 | if (type_is_invalid(cast1->value->type)) |
| 13608 | return ira->codegen->invalid_instruction; | 14681 | return ira->codegen->invalid_inst_gen; |
| 13609 | | 14682 | |
| 13610 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 14683 | IrInstGen *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13611 | if (type_is_invalid(cast2->value->type)) | 14684 | if (type_is_invalid(cast2->value->type)) |
| 13612 | return ira->codegen->invalid_instruction; | 14685 | return ira->codegen->invalid_inst_gen; |
| 13613 | | 14686 | |
| 13614 | return cast2; | 14687 | return cast2; |
| 13615 | } | 14688 | } |
| ... | @@ -13630,9 +14703,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13630,9 +14703,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13630 | actual_array_type->data.array.sentinel))) | 14703 | actual_array_type->data.array.sentinel))) |
| 13631 | { | 14704 | { |
| 13632 | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) | 14705 | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) |
| 13633 | return ira->codegen->invalid_instruction; | 14706 | return ira->codegen->invalid_inst_gen; |
| 13634 | if ((err = type_resolve(ira->codegen, wanted_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) | 14707 | if ((err = type_resolve(ira->codegen, wanted_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) |
| 13635 | return ira->codegen->invalid_instruction; | 14708 | return ira->codegen->invalid_inst_gen; |
| 13636 | if (get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, wanted_type) && | 14709 | if (get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, wanted_type) && |
| 13637 | types_match_const_cast_only(ira, wanted_type->data.pointer.child_type, | 14710 | types_match_const_cast_only(ira, wanted_type->data.pointer.child_type, |
| 13638 | actual_type->data.pointer.child_type->data.array.child_type, source_node, | 14711 | actual_type->data.pointer.child_type->data.array.child_type, source_node, |
| ... | @@ -13673,24 +14746,24 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13673,24 +14746,24 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13673 | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, | 14746 | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, |
| 13674 | ResolveStatusAlignmentKnown))) | 14747 | ResolveStatusAlignmentKnown))) |
| 13675 | { | 14748 | { |
| 13676 | return ira->codegen->invalid_instruction; | 14749 | return ira->codegen->invalid_inst_gen; |
| 13677 | } | 14750 | } |
| 13678 | if ((err = type_resolve(ira->codegen, slice_ptr_type->data.pointer.child_type, | 14751 | if ((err = type_resolve(ira->codegen, slice_ptr_type->data.pointer.child_type, |
| 13679 | ResolveStatusAlignmentKnown))) | 14752 | ResolveStatusAlignmentKnown))) |
| 13680 | { | 14753 | { |
| 13681 | return ira->codegen->invalid_instruction; | 14754 | return ira->codegen->invalid_inst_gen; |
| 13682 | } | 14755 | } |
| 13683 | ok_align = get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, slice_ptr_type); | 14756 | ok_align = get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, slice_ptr_type); |
| 13684 | } | 14757 | } |
| 13685 | if (ok_align) { | 14758 | if (ok_align) { |
| 13686 | if (wanted_type->id == ZigTypeIdErrorUnion) { | 14759 | if (wanted_type->id == ZigTypeIdErrorUnion) { |
| 13687 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, slice_type, value); | 14760 | IrInstGen *cast1 = ir_analyze_cast(ira, source_instr, slice_type, value); |
| 13688 | if (type_is_invalid(cast1->value->type)) | 14761 | if (type_is_invalid(cast1->value->type)) |
| 13689 | return ira->codegen->invalid_instruction; | 14762 | return ira->codegen->invalid_inst_gen; |
| 13690 | | 14763 | |
| 13691 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 14764 | IrInstGen *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13692 | if (type_is_invalid(cast2->value->type)) | 14765 | if (type_is_invalid(cast2->value->type)) |
| 13693 | return ira->codegen->invalid_instruction; | 14766 | return ira->codegen->invalid_inst_gen; |
| 13694 | | 14767 | |
| 13695 | return cast2; | 14768 | return cast2; |
| 13696 | } else { | 14769 | } else { |
| ... | @@ -13725,12 +14798,12 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13725,12 +14798,12 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13725 | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, | 14798 | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, |
| 13726 | ResolveStatusAlignmentKnown))) | 14799 | ResolveStatusAlignmentKnown))) |
| 13727 | { | 14800 | { |
| 13728 | return ira->codegen->invalid_instruction; | 14801 | return ira->codegen->invalid_inst_gen; |
| 13729 | } | 14802 | } |
| 13730 | if ((err = type_resolve(ira->codegen, slice_ptr_type->data.pointer.child_type, | 14803 | if ((err = type_resolve(ira->codegen, slice_ptr_type->data.pointer.child_type, |
| 13731 | ResolveStatusAlignmentKnown))) | 14804 | ResolveStatusAlignmentKnown))) |
| 13732 | { | 14805 | { |
| 13733 | return ira->codegen->invalid_instruction; | 14806 | return ira->codegen->invalid_inst_gen; |
| 13734 | } | 14807 | } |
| 13735 | ok_align = get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, slice_ptr_type); | 14808 | ok_align = get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, slice_ptr_type); |
| 13736 | } | 14809 | } |
| ... | @@ -13771,7 +14844,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13771,7 +14844,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13771 | } | 14844 | } |
| 13772 | } | 14845 | } |
| 13773 | if (ok) { | 14846 | if (ok) { |
| 13774 | IrInstruction *cast1 = ir_analyze_frame_ptr_to_anyframe(ira, source_instr, value, anyframe_type); | 14847 | IrInstGen *cast1 = ir_analyze_frame_ptr_to_anyframe(ira, source_instr, value, anyframe_type); |
| 13775 | if (anyframe_type == wanted_type) | 14848 | if (anyframe_type == wanted_type) |
| 13776 | return cast1; | 14849 | return cast1; |
| 13777 | return ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 14850 | return ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| ... | @@ -13826,28 +14899,28 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13826,28 +14899,28 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13826 | if (actual_type->id == ZigTypeIdEnumLiteral && | 14899 | if (actual_type->id == ZigTypeIdEnumLiteral && |
| 13827 | (wanted_type->id == ZigTypeIdOptional && wanted_type->data.maybe.child_type->id == ZigTypeIdEnum)) | 14900 | (wanted_type->id == ZigTypeIdOptional && wanted_type->data.maybe.child_type->id == ZigTypeIdEnum)) |
| 13828 | { | 14901 | { |
| 13829 | IrInstruction *result = ir_analyze_enum_literal(ira, source_instr, value, wanted_type->data.maybe.child_type); | 14902 | IrInstGen *result = ir_analyze_enum_literal(ira, source_instr, value, wanted_type->data.maybe.child_type); |
| 13830 | if (result == ira->codegen->invalid_instruction) | 14903 | if (type_is_invalid(result->value->type)) |
| 13831 | return result; | 14904 | return result; |
| 13832 | | 14905 | |
| 13833 | return ir_analyze_optional_wrap(ira, result, value, wanted_type, nullptr); | 14906 | return ir_analyze_optional_wrap(ira, source_instr, value, wanted_type, nullptr); |
| 13834 | } | 14907 | } |
| 13835 | | 14908 | |
| 13836 | // cast from enum literal to error union when payload is an enum | 14909 | // cast from enum literal to error union when payload is an enum |
| 13837 | if (actual_type->id == ZigTypeIdEnumLiteral && | 14910 | if (actual_type->id == ZigTypeIdEnumLiteral && |
| 13838 | (wanted_type->id == ZigTypeIdErrorUnion && wanted_type->data.error_union.payload_type->id == ZigTypeIdEnum)) | 14911 | (wanted_type->id == ZigTypeIdErrorUnion && wanted_type->data.error_union.payload_type->id == ZigTypeIdEnum)) |
| 13839 | { | 14912 | { |
| 13840 | IrInstruction *result = ir_analyze_enum_literal(ira, source_instr, value, wanted_type->data.error_union.payload_type); | 14913 | IrInstGen *result = ir_analyze_enum_literal(ira, source_instr, value, wanted_type->data.error_union.payload_type); |
| 13841 | if (result == ira->codegen->invalid_instruction) | 14914 | if (type_is_invalid(result->value->type)) |
| 13842 | return result; | 14915 | return result; |
| 13843 | | 14916 | |
| 13844 | return ir_analyze_err_wrap_payload(ira, result, value, wanted_type, nullptr); | 14917 | return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type, nullptr); |
| 13845 | } | 14918 | } |
| 13846 | | 14919 | |
| 13847 | // cast from union to the enum type of the union | 14920 | // cast from union to the enum type of the union |
| 13848 | if (actual_type->id == ZigTypeIdUnion && wanted_type->id == ZigTypeIdEnum) { | 14921 | if (actual_type->id == ZigTypeIdUnion && wanted_type->id == ZigTypeIdEnum) { |
| 13849 | if ((err = type_resolve(ira->codegen, actual_type, ResolveStatusZeroBitsKnown))) | 14922 | if ((err = type_resolve(ira->codegen, actual_type, ResolveStatusZeroBitsKnown))) |
| 13850 | return ira->codegen->invalid_instruction; | 14923 | return ira->codegen->invalid_inst_gen; |
| 13851 | | 14924 | |
| 13852 | if (actual_type->data.unionation.tag_type == wanted_type) { | 14925 | if (actual_type->data.unionation.tag_type == wanted_type) { |
| 13853 | return ir_analyze_union_to_tag(ira, source_instr, value, wanted_type); | 14926 | return ir_analyze_union_to_tag(ira, source_instr, value, wanted_type); |
| ... | @@ -13875,8 +14948,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13875,8 +14948,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13875 | (!actual_type->data.pointer.is_const || wanted_type->data.pointer.is_const) && | 14948 | (!actual_type->data.pointer.is_const || wanted_type->data.pointer.is_const) && |
| 13876 | (!actual_type->data.pointer.is_volatile || wanted_type->data.pointer.is_volatile)) | 14949 | (!actual_type->data.pointer.is_volatile || wanted_type->data.pointer.is_volatile)) |
| 13877 | { | 14950 | { |
| 13878 | if ((err = ir_cast_ptr_align(ira, source_instr, wanted_type, actual_type, value->source_node))) | 14951 | if ((err = ir_cast_ptr_align(ira, source_instr, wanted_type, actual_type, value->base.source_node))) |
| 13879 | return ira->codegen->invalid_instruction; | 14952 | return ira->codegen->invalid_inst_gen; |
| 13880 | | 14953 | |
| 13881 | return ir_analyze_ptr_to_array(ira, source_instr, value, wanted_type); | 14954 | return ir_analyze_ptr_to_array(ira, source_instr, value, wanted_type); |
| 13882 | } | 14955 | } |
| ... | @@ -13899,7 +14972,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13899,7 +14972,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13899 | slice_ptr_type->data.pointer.sentinel)))) | 14972 | slice_ptr_type->data.pointer.sentinel)))) |
| 13900 | { | 14973 | { |
| 13901 | TypeStructField *ptr_field = actual_type->data.structure.fields[slice_ptr_index]; | 14974 | TypeStructField *ptr_field = actual_type->data.structure.fields[slice_ptr_index]; |
| 13902 | IrInstruction *slice_ptr = ir_analyze_struct_value_field_value(ira, source_instr, value, ptr_field); | 14975 | IrInstGen *slice_ptr = ir_analyze_struct_value_field_value(ira, source_instr, value, ptr_field); |
| 13903 | return ir_implicit_cast2(ira, source_instr, slice_ptr, wanted_type); | 14976 | return ir_implicit_cast2(ira, source_instr, slice_ptr, wanted_type); |
| 13904 | } | 14977 | } |
| 13905 | } | 14978 | } |
| ... | @@ -13930,7 +15003,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13930,7 +15003,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13930 | { | 15003 | { |
| 13931 | bool has_bits; | 15004 | bool has_bits; |
| 13932 | if ((err = type_has_bits2(ira->codegen, actual_type, &has_bits))) | 15005 | if ((err = type_has_bits2(ira->codegen, actual_type, &has_bits))) |
| 13933 | return ira->codegen->invalid_instruction; | 15006 | return ira->codegen->invalid_inst_gen; |
| 13934 | if (!has_bits) { | 15007 | if (!has_bits) { |
| 13935 | return ir_get_ref(ira, source_instr, value, false, false); | 15008 | return ir_get_ref(ira, source_instr, value, false, false); |
| 13936 | } | 15009 | } |
| ... | @@ -13997,9 +15070,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13997,9 +15070,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13997 | | 15070 | |
| 13998 | // T to ?U, where T implicitly casts to U | 15071 | // T to ?U, where T implicitly casts to U |
| 13999 | if (wanted_type->id == ZigTypeIdOptional && actual_type->id != ZigTypeIdOptional) { | 15072 | if (wanted_type->id == ZigTypeIdOptional && actual_type->id != ZigTypeIdOptional) { |
| 14000 | IrInstruction *cast1 = ir_implicit_cast2(ira, source_instr, value, wanted_type->data.maybe.child_type); | 15073 | IrInstGen *cast1 = ir_implicit_cast2(ira, source_instr, value, wanted_type->data.maybe.child_type); |
| 14001 | if (type_is_invalid(cast1->value->type)) | 15074 | if (type_is_invalid(cast1->value->type)) |
| 14002 | return ira->codegen->invalid_instruction; | 15075 | return ira->codegen->invalid_inst_gen; |
| 14003 | return ir_implicit_cast2(ira, source_instr, cast1, wanted_type); | 15076 | return ir_implicit_cast2(ira, source_instr, cast1, wanted_type); |
| 14004 | } | 15077 | } |
| 14005 | | 15078 | |
| ... | @@ -14007,9 +15080,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -14007,9 +15080,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 14007 | if (wanted_type->id == ZigTypeIdErrorUnion && actual_type->id != ZigTypeIdErrorUnion && | 15080 | if (wanted_type->id == ZigTypeIdErrorUnion && actual_type->id != ZigTypeIdErrorUnion && |
| 14008 | actual_type->id != ZigTypeIdErrorSet) | 15081 | actual_type->id != ZigTypeIdErrorSet) |
| 14009 | { | 15082 | { |
| 14010 | IrInstruction *cast1 = ir_implicit_cast2(ira, source_instr, value, wanted_type->data.error_union.payload_type); | 15083 | IrInstGen *cast1 = ir_implicit_cast2(ira, source_instr, value, wanted_type->data.error_union.payload_type); |
| 14011 | if (type_is_invalid(cast1->value->type)) | 15084 | if (type_is_invalid(cast1->value->type)) |
| 14012 | return ira->codegen->invalid_instruction; | 15085 | return ira->codegen->invalid_inst_gen; |
| 14013 | return ir_implicit_cast2(ira, source_instr, cast1, wanted_type); | 15086 | return ir_implicit_cast2(ira, source_instr, cast1, wanted_type); |
| 14014 | } | 15087 | } |
| 14015 | | 15088 | |
| ... | @@ -14018,14 +15091,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -14018,14 +15091,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 14018 | buf_ptr(&wanted_type->name), | 15091 | buf_ptr(&wanted_type->name), |
| 14019 | buf_ptr(&actual_type->name))); | 15092 | buf_ptr(&actual_type->name))); |
| 14020 | report_recursive_error(ira, source_instr->source_node, &const_cast_result, parent_msg); | 15093 | report_recursive_error(ira, source_instr->source_node, &const_cast_result, parent_msg); |
| 14021 | return ira->codegen->invalid_instruction; | 15094 | return ira->codegen->invalid_inst_gen; |
| 14022 | } | 15095 | } |
| 14023 | | 15096 | |
| 14024 | static IrInstruction *ir_implicit_cast2(IrAnalyze *ira, IrInstruction *value_source_instr, | 15097 | static IrInstGen *ir_implicit_cast2(IrAnalyze *ira, IrInst *value_source_instr, |
| 14025 | IrInstruction *value, ZigType *expected_type) | 15098 | IrInstGen *value, ZigType *expected_type) |
| 14026 | { | 15099 | { |
| 14027 | assert(value); | 15100 | assert(value); |
| 14028 | assert(value != ira->codegen->invalid_instruction); | | |
| 14029 | assert(!expected_type || !type_is_invalid(expected_type)); | 15101 | assert(!expected_type || !type_is_invalid(expected_type)); |
| 14030 | assert(value->value->type); | 15102 | assert(value->value->type); |
| 14031 | assert(!type_is_invalid(value->value->type)); | 15103 | assert(!type_is_invalid(value->value->type)); |
| ... | @@ -14039,17 +15111,17 @@ static IrInstruction *ir_implicit_cast2(IrAnalyze *ira, IrInstruction *value_sou | ... | @@ -14039,17 +15111,17 @@ static IrInstruction *ir_implicit_cast2(IrAnalyze *ira, IrInstruction *value_sou |
| 14039 | return ir_analyze_cast(ira, value_source_instr, expected_type, value); | 15111 | return ir_analyze_cast(ira, value_source_instr, expected_type, value); |
| 14040 | } | 15112 | } |
| 14041 | | 15113 | |
| 14042 | static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, ZigType *expected_type) { | 15114 | static IrInstGen *ir_implicit_cast(IrAnalyze *ira, IrInstGen *value, ZigType *expected_type) { |
| 14043 | return ir_implicit_cast2(ira, value, value, expected_type); | 15115 | return ir_implicit_cast2(ira, &value->base, value, expected_type); |
| 14044 | } | 15116 | } |
| 14045 | | 15117 | |
| 14046 | static ZigType *get_ptr_elem_type(CodeGen *g, IrInstruction *ptr) { | 15118 | static ZigType *get_ptr_elem_type(CodeGen *g, IrInstGen *ptr) { |
| 14047 | ir_assert(ptr->value->type->id == ZigTypeIdPointer, ptr); | 15119 | ir_assert_gen(ptr->value->type->id == ZigTypeIdPointer, ptr); |
| 14048 | ZigType *elem_type = ptr->value->type->data.pointer.child_type; | 15120 | ZigType *elem_type = ptr->value->type->data.pointer.child_type; |
| 14049 | if (elem_type != g->builtin_types.entry_var) | 15121 | if (elem_type != g->builtin_types.entry_var) |
| 14050 | return elem_type; | 15122 | return elem_type; |
| 14051 | | 15123 | |
| 14052 | if (ir_resolve_lazy(g, ptr->source_node, ptr->value)) | 15124 | if (ir_resolve_lazy(g, ptr->base.source_node, ptr->value)) |
| 14053 | return g->builtin_types.entry_invalid; | 15125 | return g->builtin_types.entry_invalid; |
| 14054 | | 15126 | |
| 14055 | assert(value_is_comptime(ptr->value)); | 15127 | assert(value_is_comptime(ptr->value)); |
| ... | @@ -14057,28 +15129,28 @@ static ZigType *get_ptr_elem_type(CodeGen *g, IrInstruction *ptr) { | ... | @@ -14057,28 +15129,28 @@ static ZigType *get_ptr_elem_type(CodeGen *g, IrInstruction *ptr) { |
| 14057 | return pointee->type; | 15129 | return pointee->type; |
| 14058 | } | 15130 | } |
| 14059 | | 15131 | |
| 14060 | static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr, | 15132 | static IrInstGen *ir_get_deref(IrAnalyze *ira, IrInst* source_instruction, IrInstGen *ptr, |
| 14061 | ResultLoc *result_loc) | 15133 | ResultLoc *result_loc) |
| 14062 | { | 15134 | { |
| 14063 | Error err; | 15135 | Error err; |
| 14064 | ZigType *ptr_type = ptr->value->type; | 15136 | ZigType *ptr_type = ptr->value->type; |
| 14065 | if (type_is_invalid(ptr_type)) | 15137 | if (type_is_invalid(ptr_type)) |
| 14066 | return ira->codegen->invalid_instruction; | 15138 | return ira->codegen->invalid_inst_gen; |
| 14067 | | 15139 | |
| 14068 | if (ptr_type->id != ZigTypeIdPointer) { | 15140 | if (ptr_type->id != ZigTypeIdPointer) { |
| 14069 | ir_add_error_node(ira, source_instruction->source_node, | 15141 | ir_add_error_node(ira, source_instruction->source_node, |
| 14070 | buf_sprintf("attempt to dereference non-pointer type '%s'", | 15142 | buf_sprintf("attempt to dereference non-pointer type '%s'", |
| 14071 | buf_ptr(&ptr_type->name))); | 15143 | buf_ptr(&ptr_type->name))); |
| 14072 | return ira->codegen->invalid_instruction; | 15144 | return ira->codegen->invalid_inst_gen; |
| 14073 | } | 15145 | } |
| 14074 | | 15146 | |
| 14075 | ZigType *child_type = ptr_type->data.pointer.child_type; | 15147 | ZigType *child_type = ptr_type->data.pointer.child_type; |
| 14076 | if (type_is_invalid(child_type)) | 15148 | if (type_is_invalid(child_type)) |
| 14077 | return ira->codegen->invalid_instruction; | 15149 | return ira->codegen->invalid_inst_gen; |
| 14078 | // if the child type has one possible value, the deref is comptime | 15150 | // if the child type has one possible value, the deref is comptime |
| 14079 | switch (type_has_one_possible_value(ira->codegen, child_type)) { | 15151 | switch (type_has_one_possible_value(ira->codegen, child_type)) { |
| 14080 | case OnePossibleValueInvalid: | 15152 | case OnePossibleValueInvalid: |
| 14081 | return ira->codegen->invalid_instruction; | 15153 | return ira->codegen->invalid_inst_gen; |
| 14082 | case OnePossibleValueYes: | 15154 | case OnePossibleValueYes: |
| 14083 | return ir_const_move(ira, source_instruction, | 15155 | return ir_const_move(ira, source_instruction, |
| 14084 | get_the_one_possible_value(ira->codegen, child_type)); | 15156 | get_the_one_possible_value(ira->codegen, child_type)); |
| ... | @@ -14087,8 +15159,8 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -14087,8 +15159,8 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 14087 | } | 15159 | } |
| 14088 | if (instr_is_comptime(ptr)) { | 15160 | if (instr_is_comptime(ptr)) { |
| 14089 | if (ptr->value->special == ConstValSpecialUndef) { | 15161 | if (ptr->value->special == ConstValSpecialUndef) { |
| 14090 | ir_add_error(ira, ptr, buf_sprintf("attempt to dereference undefined value")); | 15162 | ir_add_error(ira, &ptr->base, buf_sprintf("attempt to dereference undefined value")); |
| 14091 | return ira->codegen->invalid_instruction; | 15163 | return ira->codegen->invalid_inst_gen; |
| 14092 | } | 15164 | } |
| 14093 | if (ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 15165 | if (ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 14094 | ZigValue *pointee = const_ptr_pointee_unchecked(ira->codegen, ptr->value); | 15166 | ZigValue *pointee = const_ptr_pointee_unchecked(ira->codegen, ptr->value); |
| ... | @@ -14096,12 +15168,12 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -14096,12 +15168,12 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 14096 | child_type = pointee->type; | 15168 | child_type = pointee->type; |
| 14097 | } | 15169 | } |
| 14098 | if (pointee->special != ConstValSpecialRuntime) { | 15170 | if (pointee->special != ConstValSpecialRuntime) { |
| 14099 | IrInstruction *result = ir_const(ira, source_instruction, child_type); | 15171 | IrInstGen *result = ir_const(ira, source_instruction, child_type); |
| 14100 | | 15172 | |
| 14101 | if ((err = ir_read_const_ptr(ira, ira->codegen, source_instruction->source_node, result->value, | 15173 | if ((err = ir_read_const_ptr(ira, ira->codegen, source_instruction->source_node, result->value, |
| 14102 | ptr->value))) | 15174 | ptr->value))) |
| 14103 | { | 15175 | { |
| 14104 | return ira->codegen->invalid_instruction; | 15176 | return ira->codegen->invalid_inst_gen; |
| 14105 | } | 15177 | } |
| 14106 | result->value->type = child_type; | 15178 | result->value->type = child_type; |
| 14107 | return result; | 15179 | return result; |
| ... | @@ -14110,38 +15182,37 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -14110,38 +15182,37 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 14110 | } | 15182 | } |
| 14111 | | 15183 | |
| 14112 | // if the instruction is a const ref instruction we can skip it | 15184 | // if the instruction is a const ref instruction we can skip it |
| 14113 | if (ptr->id == IrInstructionIdRef) { | 15185 | if (ptr->id == IrInstGenIdRef) { |
| 14114 | IrInstructionRef *ref_inst = reinterpret_cast<IrInstructionRef *>(ptr); | 15186 | IrInstGenRef *ref_inst = reinterpret_cast<IrInstGenRef *>(ptr); |
| 14115 | return ref_inst->value; | 15187 | return ref_inst->operand; |
| 14116 | } | 15188 | } |
| 14117 | | 15189 | |
| 14118 | // If the instruction is a element pointer instruction to a vector, we emit | 15190 | // If the instruction is a element pointer instruction to a vector, we emit |
| 14119 | // vector element extract instruction rather than load pointer. If the | 15191 | // vector element extract instruction rather than load pointer. If the |
| 14120 | // pointer type has non-VECTOR_INDEX_RUNTIME value, it would have been | 15192 | // pointer type has non-VECTOR_INDEX_RUNTIME value, it would have been |
| 14121 | // possible to implement this in the codegen for IrInstructionLoadPtrGen. | 15193 | // possible to implement this in the codegen for IrInstGenLoadPtr. |
| 14122 | // However if it has VECTOR_INDEX_RUNTIME then we must emit a compile error | 15194 | // However if it has VECTOR_INDEX_RUNTIME then we must emit a compile error |
| 14123 | // if the vector index cannot be determined right here, right now, because | 15195 | // if the vector index cannot be determined right here, right now, because |
| 14124 | // the type information does not contain enough information to actually | 15196 | // the type information does not contain enough information to actually |
| 14125 | // perform a dereference. | 15197 | // perform a dereference. |
| 14126 | if (ptr_type->data.pointer.vector_index == VECTOR_INDEX_RUNTIME) { | 15198 | if (ptr_type->data.pointer.vector_index == VECTOR_INDEX_RUNTIME) { |
| 14127 | if (ptr->id == IrInstructionIdElemPtr) { | 15199 | if (ptr->id == IrInstGenIdElemPtr) { |
| 14128 | IrInstructionElemPtr *elem_ptr = (IrInstructionElemPtr *)ptr; | 15200 | IrInstGenElemPtr *elem_ptr = (IrInstGenElemPtr *)ptr; |
| 14129 | IrInstruction *vector_loaded = ir_get_deref(ira, elem_ptr->array_ptr, | 15201 | IrInstGen *vector_loaded = ir_get_deref(ira, &elem_ptr->array_ptr->base, |
| 14130 | elem_ptr->array_ptr, nullptr); | 15202 | elem_ptr->array_ptr, nullptr); |
| 14131 | IrInstruction *elem_index = elem_ptr->elem_index; | 15203 | IrInstGen *elem_index = elem_ptr->elem_index; |
| 14132 | return ir_build_vector_extract_elem(ira, source_instruction, vector_loaded, elem_index); | 15204 | return ir_build_vector_extract_elem(ira, source_instruction, vector_loaded, elem_index); |
| 14133 | } | 15205 | } |
| 14134 | ir_add_error(ira, ptr, | 15206 | ir_add_error(ira, &ptr->base, |
| 14135 | buf_sprintf("unable to determine vector element index of type '%s'", buf_ptr(&ptr_type->name))); | 15207 | buf_sprintf("unable to determine vector element index of type '%s'", buf_ptr(&ptr_type->name))); |
| 14136 | return ira->codegen->invalid_instruction; | 15208 | return ira->codegen->invalid_inst_gen; |
| 14137 | } | 15209 | } |
| 14138 | | 15210 | |
| 14139 | IrInstruction *result_loc_inst; | 15211 | IrInstGen *result_loc_inst; |
| 14140 | if (ptr_type->data.pointer.host_int_bytes != 0 && handle_is_ptr(child_type)) { | 15212 | if (ptr_type->data.pointer.host_int_bytes != 0 && handle_is_ptr(child_type)) { |
| 14141 | if (result_loc == nullptr) result_loc = no_result_loc(); | 15213 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 14142 | result_loc_inst = ir_resolve_result(ira, source_instruction, result_loc, child_type, nullptr, | 15214 | result_loc_inst = ir_resolve_result(ira, source_instruction, result_loc, child_type, nullptr, true, true); |
| 14143 | true, true); | 15215 | if (type_is_invalid(result_loc_inst->value->type) || result_loc_inst->value->type->id == ZigTypeIdUnreachable) { |
| 14144 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { | | |
| 14145 | return result_loc_inst; | 15216 | return result_loc_inst; |
| 14146 | } | 15217 | } |
| 14147 | } else { | 15218 | } else { |
| ... | @@ -14151,7 +15222,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -14151,7 +15222,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 14151 | return ir_build_load_ptr_gen(ira, source_instruction, ptr, child_type, result_loc_inst); | 15222 | return ir_build_load_ptr_gen(ira, source_instruction, ptr, child_type, result_loc_inst); |
| 14152 | } | 15223 | } |
| 14153 | | 15224 | |
| 14154 | static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, | 15225 | static bool ir_resolve_const_align(CodeGen *codegen, IrExecutableGen *exec, AstNode *source_node, |
| 14155 | ZigValue *const_val, uint32_t *out) | 15226 | ZigValue *const_val, uint32_t *out) |
| 14156 | { | 15227 | { |
| 14157 | Error err; | 15228 | Error err; |
| ... | @@ -14160,12 +15231,12 @@ static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode | ... | @@ -14160,12 +15231,12 @@ static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode |
| 14160 | | 15231 | |
| 14161 | uint32_t align_bytes = bigint_as_u32(&const_val->data.x_bigint); | 15232 | uint32_t align_bytes = bigint_as_u32(&const_val->data.x_bigint); |
| 14162 | if (align_bytes == 0) { | 15233 | if (align_bytes == 0) { |
| 14163 | exec_add_error_node(codegen, exec, source_node, buf_sprintf("alignment must be >= 1")); | 15234 | exec_add_error_node_gen(codegen, exec, source_node, buf_sprintf("alignment must be >= 1")); |
| 14164 | return false; | 15235 | return false; |
| 14165 | } | 15236 | } |
| 14166 | | 15237 | |
| 14167 | if (!is_power_of_2(align_bytes)) { | 15238 | if (!is_power_of_2(align_bytes)) { |
| 14168 | exec_add_error_node(codegen, exec, source_node, | 15239 | exec_add_error_node_gen(codegen, exec, source_node, |
| 14169 | buf_sprintf("alignment value %" PRIu32 " is not a power of 2", align_bytes)); | 15240 | buf_sprintf("alignment value %" PRIu32 " is not a power of 2", align_bytes)); |
| 14170 | return false; | 15241 | return false; |
| 14171 | } | 15242 | } |
| ... | @@ -14174,7 +15245,7 @@ static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode | ... | @@ -14174,7 +15245,7 @@ static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode |
| 14174 | return true; | 15245 | return true; |
| 14175 | } | 15246 | } |
| 14176 | | 15247 | |
| 14177 | static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem_type, uint32_t *out) { | 15248 | static bool ir_resolve_align(IrAnalyze *ira, IrInstGen *value, ZigType *elem_type, uint32_t *out) { |
| 14178 | if (type_is_invalid(value->value->type)) | 15249 | if (type_is_invalid(value->value->type)) |
| 14179 | return false; | 15250 | return false; |
| 14180 | | 15251 | |
| ... | @@ -14195,19 +15266,19 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem | ... | @@ -14195,19 +15266,19 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem |
| 14195 | } | 15266 | } |
| 14196 | } | 15267 | } |
| 14197 | | 15268 | |
| 14198 | IrInstruction *casted_value = ir_implicit_cast(ira, value, get_align_amt_type(ira->codegen)); | 15269 | IrInstGen *casted_value = ir_implicit_cast(ira, value, get_align_amt_type(ira->codegen)); |
| 14199 | if (type_is_invalid(casted_value->value->type)) | 15270 | if (type_is_invalid(casted_value->value->type)) |
| 14200 | return false; | 15271 | return false; |
| 14201 | | 15272 | |
| 14202 | return ir_resolve_const_align(ira->codegen, ira->new_irb.exec, value->source_node, | 15273 | return ir_resolve_const_align(ira->codegen, ira->new_irb.exec, value->base.source_node, |
| 14203 | casted_value->value, out); | 15274 | casted_value->value, out); |
| 14204 | } | 15275 | } |
| 14205 | | 15276 | |
| 14206 | static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *int_type, uint64_t *out) { | 15277 | static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstGen *value, ZigType *int_type, uint64_t *out) { |
| 14207 | if (type_is_invalid(value->value->type)) | 15278 | if (type_is_invalid(value->value->type)) |
| 14208 | return false; | 15279 | return false; |
| 14209 | | 15280 | |
| 14210 | IrInstruction *casted_value = ir_implicit_cast(ira, value, int_type); | 15281 | IrInstGen *casted_value = ir_implicit_cast(ira, value, int_type); |
| 14211 | if (type_is_invalid(casted_value->value->type)) | 15282 | if (type_is_invalid(casted_value->value->type)) |
| 14212 | return false; | 15283 | return false; |
| 14213 | | 15284 | |
| ... | @@ -14219,15 +15290,15 @@ static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *i | ... | @@ -14219,15 +15290,15 @@ static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *i |
| 14219 | return true; | 15290 | return true; |
| 14220 | } | 15291 | } |
| 14221 | | 15292 | |
| 14222 | static bool ir_resolve_usize(IrAnalyze *ira, IrInstruction *value, uint64_t *out) { | 15293 | static bool ir_resolve_usize(IrAnalyze *ira, IrInstGen *value, uint64_t *out) { |
| 14223 | return ir_resolve_unsigned(ira, value, ira->codegen->builtin_types.entry_usize, out); | 15294 | return ir_resolve_unsigned(ira, value, ira->codegen->builtin_types.entry_usize, out); |
| 14224 | } | 15295 | } |
| 14225 | | 15296 | |
| 14226 | static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) { | 15297 | static bool ir_resolve_bool(IrAnalyze *ira, IrInstGen *value, bool *out) { |
| 14227 | if (type_is_invalid(value->value->type)) | 15298 | if (type_is_invalid(value->value->type)) |
| 14228 | return false; | 15299 | return false; |
| 14229 | | 15300 | |
| 14230 | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_bool); | 15301 | IrInstGen *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_bool); |
| 14231 | if (type_is_invalid(casted_value->value->type)) | 15302 | if (type_is_invalid(casted_value->value->type)) |
| 14232 | return false; | 15303 | return false; |
| 14233 | | 15304 | |
| ... | @@ -14239,7 +15310,7 @@ static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) { | ... | @@ -14239,7 +15310,7 @@ static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) { |
| 14239 | return true; | 15310 | return true; |
| 14240 | } | 15311 | } |
| 14241 | | 15312 | |
| 14242 | static bool ir_resolve_comptime(IrAnalyze *ira, IrInstruction *value, bool *out) { | 15313 | static bool ir_resolve_comptime(IrAnalyze *ira, IrInstGen *value, bool *out) { |
| 14243 | if (!value) { | 15314 | if (!value) { |
| 14244 | *out = false; | 15315 | *out = false; |
| 14245 | return true; | 15316 | return true; |
| ... | @@ -14247,13 +15318,13 @@ static bool ir_resolve_comptime(IrAnalyze *ira, IrInstruction *value, bool *out) | ... | @@ -14247,13 +15318,13 @@ static bool ir_resolve_comptime(IrAnalyze *ira, IrInstruction *value, bool *out) |
| 14247 | return ir_resolve_bool(ira, value, out); | 15318 | return ir_resolve_bool(ira, value, out); |
| 14248 | } | 15319 | } |
| 14249 | | 15320 | |
| 14250 | static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, AtomicOrder *out) { | 15321 | static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstGen *value, AtomicOrder *out) { |
| 14251 | if (type_is_invalid(value->value->type)) | 15322 | if (type_is_invalid(value->value->type)) |
| 14252 | return false; | 15323 | return false; |
| 14253 | | 15324 | |
| 14254 | ZigType *atomic_order_type = get_builtin_type(ira->codegen, "AtomicOrder"); | 15325 | ZigType *atomic_order_type = get_builtin_type(ira->codegen, "AtomicOrder"); |
| 14255 | | 15326 | |
| 14256 | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_order_type); | 15327 | IrInstGen *casted_value = ir_implicit_cast(ira, value, atomic_order_type); |
| 14257 | if (type_is_invalid(casted_value->value->type)) | 15328 | if (type_is_invalid(casted_value->value->type)) |
| 14258 | return false; | 15329 | return false; |
| 14259 | | 15330 | |
| ... | @@ -14265,13 +15336,13 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic | ... | @@ -14265,13 +15336,13 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic |
| 14265 | return true; | 15336 | return true; |
| 14266 | } | 15337 | } |
| 14267 | | 15338 | |
| 14268 | static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, AtomicRmwOp *out) { | 15339 | static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstGen *value, AtomicRmwOp *out) { |
| 14269 | if (type_is_invalid(value->value->type)) | 15340 | if (type_is_invalid(value->value->type)) |
| 14270 | return false; | 15341 | return false; |
| 14271 | | 15342 | |
| 14272 | ZigType *atomic_rmw_op_type = get_builtin_type(ira->codegen, "AtomicRmwOp"); | 15343 | ZigType *atomic_rmw_op_type = get_builtin_type(ira->codegen, "AtomicRmwOp"); |
| 14273 | | 15344 | |
| 14274 | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type); | 15345 | IrInstGen *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type); |
| 14275 | if (type_is_invalid(casted_value->value->type)) | 15346 | if (type_is_invalid(casted_value->value->type)) |
| 14276 | return false; | 15347 | return false; |
| 14277 | | 15348 | |
| ... | @@ -14283,13 +15354,13 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi | ... | @@ -14283,13 +15354,13 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi |
| 14283 | return true; | 15354 | return true; |
| 14284 | } | 15355 | } |
| 14285 | | 15356 | |
| 14286 | static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, GlobalLinkageId *out) { | 15357 | static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstGen *value, GlobalLinkageId *out) { |
| 14287 | if (type_is_invalid(value->value->type)) | 15358 | if (type_is_invalid(value->value->type)) |
| 14288 | return false; | 15359 | return false; |
| 14289 | | 15360 | |
| 14290 | ZigType *global_linkage_type = get_builtin_type(ira->codegen, "GlobalLinkage"); | 15361 | ZigType *global_linkage_type = get_builtin_type(ira->codegen, "GlobalLinkage"); |
| 14291 | | 15362 | |
| 14292 | IrInstruction *casted_value = ir_implicit_cast(ira, value, global_linkage_type); | 15363 | IrInstGen *casted_value = ir_implicit_cast(ira, value, global_linkage_type); |
| 14293 | if (type_is_invalid(casted_value->value->type)) | 15364 | if (type_is_invalid(casted_value->value->type)) |
| 14294 | return false; | 15365 | return false; |
| 14295 | | 15366 | |
| ... | @@ -14301,13 +15372,13 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob | ... | @@ -14301,13 +15372,13 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob |
| 14301 | return true; | 15372 | return true; |
| 14302 | } | 15373 | } |
| 14303 | | 15374 | |
| 14304 | static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMode *out) { | 15375 | static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstGen *value, FloatMode *out) { |
| 14305 | if (type_is_invalid(value->value->type)) | 15376 | if (type_is_invalid(value->value->type)) |
| 14306 | return false; | 15377 | return false; |
| 14307 | | 15378 | |
| 14308 | ZigType *float_mode_type = get_builtin_type(ira->codegen, "FloatMode"); | 15379 | ZigType *float_mode_type = get_builtin_type(ira->codegen, "FloatMode"); |
| 14309 | | 15380 | |
| 14310 | IrInstruction *casted_value = ir_implicit_cast(ira, value, float_mode_type); | 15381 | IrInstGen *casted_value = ir_implicit_cast(ira, value, float_mode_type); |
| 14311 | if (type_is_invalid(casted_value->value->type)) | 15382 | if (type_is_invalid(casted_value->value->type)) |
| 14312 | return false; | 15383 | return false; |
| 14313 | | 15384 | |
| ... | @@ -14319,14 +15390,14 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod | ... | @@ -14319,14 +15390,14 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod |
| 14319 | return true; | 15390 | return true; |
| 14320 | } | 15391 | } |
| 14321 | | 15392 | |
| 14322 | static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { | 15393 | static Buf *ir_resolve_str(IrAnalyze *ira, IrInstGen *value) { |
| 14323 | if (type_is_invalid(value->value->type)) | 15394 | if (type_is_invalid(value->value->type)) |
| 14324 | return nullptr; | 15395 | return nullptr; |
| 14325 | | 15396 | |
| 14326 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, | 15397 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 14327 | true, false, PtrLenUnknown, 0, 0, 0, false); | 15398 | true, false, PtrLenUnknown, 0, 0, 0, false); |
| 14328 | ZigType *str_type = get_slice_type(ira->codegen, ptr_type); | 15399 | ZigType *str_type = get_slice_type(ira->codegen, ptr_type); |
| 14329 | IrInstruction *casted_value = ir_implicit_cast(ira, value, str_type); | 15400 | IrInstGen *casted_value = ir_implicit_cast(ira, value, str_type); |
| 14330 | if (type_is_invalid(casted_value->value->type)) | 15401 | if (type_is_invalid(casted_value->value->type)) |
| 14331 | return nullptr; | 15402 | return nullptr; |
| 14332 | | 15403 | |
| ... | @@ -14350,7 +15421,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { | ... | @@ -14350,7 +15421,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { |
| 14350 | size_t new_index = ptr_field->data.x_ptr.data.base_array.elem_index + i; | 15421 | size_t new_index = ptr_field->data.x_ptr.data.base_array.elem_index + i; |
| 14351 | ZigValue *char_val = &array_val->data.x_array.data.s_none.elements[new_index]; | 15422 | ZigValue *char_val = &array_val->data.x_array.data.s_none.elements[new_index]; |
| 14352 | if (char_val->special == ConstValSpecialUndef) { | 15423 | if (char_val->special == ConstValSpecialUndef) { |
| 14353 | ir_add_error(ira, casted_value, buf_sprintf("use of undefined value")); | 15424 | ir_add_error(ira, &casted_value->base, buf_sprintf("use of undefined value")); |
| 14354 | return nullptr; | 15425 | return nullptr; |
| 14355 | } | 15426 | } |
| 14356 | uint64_t big_c = bigint_as_u64(&char_val->data.x_bigint); | 15427 | uint64_t big_c = bigint_as_u64(&char_val->data.x_bigint); |
| ... | @@ -14361,10 +15432,10 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { | ... | @@ -14361,10 +15432,10 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { |
| 14361 | return result; | 15432 | return result; |
| 14362 | } | 15433 | } |
| 14363 | | 15434 | |
| 14364 | static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze *ira, | 15435 | static IrInstGen *ir_analyze_instruction_add_implicit_return_type(IrAnalyze *ira, |
| 14365 | IrInstructionAddImplicitReturnType *instruction) | 15436 | IrInstSrcAddImplicitReturnType *instruction) |
| 14366 | { | 15437 | { |
| 14367 | IrInstruction *value = instruction->value->child; | 15438 | IrInstGen *value = instruction->value->child; |
| 14368 | if (type_is_invalid(value->value->type)) | 15439 | if (type_is_invalid(value->value->type)) |
| 14369 | return ir_unreach_error(ira); | 15440 | return ir_unreach_error(ira); |
| 14370 | | 15441 | |
| ... | @@ -14372,15 +15443,15 @@ static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze | ... | @@ -14372,15 +15443,15 @@ static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze |
| 14372 | ira->src_implicit_return_type_list.append(value); | 15443 | ira->src_implicit_return_type_list.append(value); |
| 14373 | } | 15444 | } |
| 14374 | | 15445 | |
| 14375 | return ir_const_void(ira, &instruction->base); | 15446 | return ir_const_void(ira, &instruction->base.base); |
| 14376 | } | 15447 | } |
| 14377 | | 15448 | |
| 14378 | static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructionReturn *instruction) { | 15449 | static IrInstGen *ir_analyze_instruction_return(IrAnalyze *ira, IrInstSrcReturn *instruction) { |
| 14379 | IrInstruction *operand = instruction->operand->child; | 15450 | IrInstGen *operand = instruction->operand->child; |
| 14380 | if (type_is_invalid(operand->value->type)) | 15451 | if (type_is_invalid(operand->value->type)) |
| 14381 | return ir_unreach_error(ira); | 15452 | return ir_unreach_error(ira); |
| 14382 | | 15453 | |
| 14383 | IrInstruction *casted_operand = ir_implicit_cast(ira, operand, ira->explicit_return_type); | 15454 | IrInstGen *casted_operand = ir_implicit_cast(ira, operand, ira->explicit_return_type); |
| 14384 | if (type_is_invalid(casted_operand->value->type)) { | 15455 | if (type_is_invalid(casted_operand->value->type)) { |
| 14385 | AstNode *source_node = ira->explicit_return_type_source_node; | 15456 | AstNode *source_node = ira->explicit_return_type_source_node; |
| 14386 | if (source_node != nullptr) { | 15457 | if (source_node != nullptr) { |
| ... | @@ -14395,9 +15466,7 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio | ... | @@ -14395,9 +15466,7 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio |
| 14395 | handle_is_ptr(ira->explicit_return_type)) | 15466 | handle_is_ptr(ira->explicit_return_type)) |
| 14396 | { | 15467 | { |
| 14397 | // result location mechanism took care of it. | 15468 | // result location mechanism took care of it. |
| 14398 | IrInstruction *result = ir_build_return(&ira->new_irb, instruction->base.scope, | 15469 | IrInstGen *result = ir_build_return_gen(ira, &instruction->base.base, nullptr); |
| 14399 | instruction->base.source_node, nullptr); | | |
| 14400 | result->value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 14401 | return ir_finish_anal(ira, result); | 15470 | return ir_finish_anal(ira, result); |
| 14402 | } | 15471 | } |
| 14403 | | 15472 | |
| ... | @@ -14405,47 +15474,45 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio | ... | @@ -14405,47 +15474,45 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio |
| 14405 | casted_operand->value->type->id == ZigTypeIdPointer && | 15474 | casted_operand->value->type->id == ZigTypeIdPointer && |
| 14406 | casted_operand->value->data.rh_ptr == RuntimeHintPtrStack) | 15475 | casted_operand->value->data.rh_ptr == RuntimeHintPtrStack) |
| 14407 | { | 15476 | { |
| 14408 | ir_add_error(ira, casted_operand, buf_sprintf("function returns address of local variable")); | 15477 | ir_add_error(ira, &casted_operand->base, buf_sprintf("function returns address of local variable")); |
| 14409 | return ir_unreach_error(ira); | 15478 | return ir_unreach_error(ira); |
| 14410 | } | 15479 | } |
| 14411 | | 15480 | |
| 14412 | IrInstruction *result = ir_build_return(&ira->new_irb, instruction->base.scope, | 15481 | IrInstGen *result = ir_build_return_gen(ira, &instruction->base.base, casted_operand); |
| 14413 | instruction->base.source_node, casted_operand); | | |
| 14414 | result->value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 14415 | return ir_finish_anal(ira, result); | 15482 | return ir_finish_anal(ira, result); |
| 14416 | } | 15483 | } |
| 14417 | | 15484 | |
| 14418 | static IrInstruction *ir_analyze_instruction_const(IrAnalyze *ira, IrInstructionConst *instruction) { | 15485 | static IrInstGen *ir_analyze_instruction_const(IrAnalyze *ira, IrInstSrcConst *instruction) { |
| 14419 | return ir_const_move(ira, &instruction->base, instruction->base.value); | 15486 | return ir_const_move(ira, &instruction->base.base, instruction->value); |
| 14420 | } | 15487 | } |
| 14421 | | 15488 | |
| 14422 | static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { | 15489 | static IrInstGen *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstSrcBinOp *bin_op_instruction) { |
| 14423 | IrInstruction *op1 = bin_op_instruction->op1->child; | 15490 | IrInstGen *op1 = bin_op_instruction->op1->child; |
| 14424 | if (type_is_invalid(op1->value->type)) | 15491 | if (type_is_invalid(op1->value->type)) |
| 14425 | return ira->codegen->invalid_instruction; | 15492 | return ira->codegen->invalid_inst_gen; |
| 14426 | | 15493 | |
| 14427 | IrInstruction *op2 = bin_op_instruction->op2->child; | 15494 | IrInstGen *op2 = bin_op_instruction->op2->child; |
| 14428 | if (type_is_invalid(op2->value->type)) | 15495 | if (type_is_invalid(op2->value->type)) |
| 14429 | return ira->codegen->invalid_instruction; | 15496 | return ira->codegen->invalid_inst_gen; |
| 14430 | | 15497 | |
| 14431 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; | 15498 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| 14432 | | 15499 | |
| 14433 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, bool_type); | 15500 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, bool_type); |
| 14434 | if (casted_op1 == ira->codegen->invalid_instruction) | 15501 | if (type_is_invalid(casted_op1->value->type)) |
| 14435 | return ira->codegen->invalid_instruction; | 15502 | return ira->codegen->invalid_inst_gen; |
| 14436 | | 15503 | |
| 14437 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, bool_type); | 15504 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, bool_type); |
| 14438 | if (casted_op2 == ira->codegen->invalid_instruction) | 15505 | if (type_is_invalid(casted_op2->value->type)) |
| 14439 | return ira->codegen->invalid_instruction; | 15506 | return ira->codegen->invalid_inst_gen; |
| 14440 | | 15507 | |
| 14441 | if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) { | 15508 | if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) { |
| 14442 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); | 15509 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); |
| 14443 | if (op1_val == nullptr) | 15510 | if (op1_val == nullptr) |
| 14444 | return ira->codegen->invalid_instruction; | 15511 | return ira->codegen->invalid_inst_gen; |
| 14445 | | 15512 | |
| 14446 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 15513 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 14447 | if (op2_val == nullptr) | 15514 | if (op2_val == nullptr) |
| 14448 | return ira->codegen->invalid_instruction; | 15515 | return ira->codegen->invalid_inst_gen; |
| 14449 | | 15516 | |
| 14450 | assert(casted_op1->value->type->id == ZigTypeIdBool); | 15517 | assert(casted_op1->value->type->id == ZigTypeIdBool); |
| 14451 | assert(casted_op2->value->type->id == ZigTypeIdBool); | 15518 | assert(casted_op2->value->type->id == ZigTypeIdBool); |
| ... | @@ -14457,14 +15524,11 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -14457,14 +15524,11 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp |
| 14457 | } else { | 15524 | } else { |
| 14458 | zig_unreachable(); | 15525 | zig_unreachable(); |
| 14459 | } | 15526 | } |
| 14460 | return ir_const_bool(ira, &bin_op_instruction->base, result_bool); | 15527 | return ir_const_bool(ira, &bin_op_instruction->base.base, result_bool); |
| 14461 | } | 15528 | } |
| 14462 | | 15529 | |
| 14463 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, | 15530 | return ir_build_bin_op_gen(ira, &bin_op_instruction->base.base, bool_type, |
| 14464 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, | | |
| 14465 | bin_op_instruction->op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on); | 15531 | bin_op_instruction->op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on); |
| 14466 | result->value->type = bool_type; | | |
| 14467 | return result; | | |
| 14468 | } | 15532 | } |
| 14469 | | 15533 | |
| 14470 | static bool resolve_cmp_op_id(IrBinOp op_id, Cmp cmp) { | 15534 | static bool resolve_cmp_op_id(IrBinOp op_id, Cmp cmp) { |
| ... | @@ -14529,12 +15593,13 @@ static void set_optional_payload(ZigValue *opt_val, ZigValue *payload) { | ... | @@ -14529,12 +15593,13 @@ static void set_optional_payload(ZigValue *opt_val, ZigValue *payload) { |
| 14529 | } | 15593 | } |
| 14530 | } | 15594 | } |
| 14531 | | 15595 | |
| 14532 | static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_type, | 15596 | static IrInstGen *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_type, |
| 14533 | ZigValue *op1_val, ZigValue *op2_val, IrInstructionBinOp *bin_op_instruction, IrBinOp op_id, | 15597 | ZigValue *op1_val, ZigValue *op2_val, IrInstSrcBinOp *bin_op_instruction, IrBinOp op_id, |
| 14534 | bool one_possible_value) { | 15598 | bool one_possible_value) |
| | 15599 | { |
| 14535 | if (op1_val->special == ConstValSpecialUndef || | 15600 | if (op1_val->special == ConstValSpecialUndef || |
| 14536 | op2_val->special == ConstValSpecialUndef) | 15601 | op2_val->special == ConstValSpecialUndef) |
| 14537 | return ir_const_undef(ira, &bin_op_instruction->base, resolved_type); | 15602 | return ir_const_undef(ira, &bin_op_instruction->base.base, resolved_type); |
| 14538 | if (resolved_type->id == ZigTypeIdPointer && op_id != IrBinOpCmpEq && op_id != IrBinOpCmpNotEq) { | 15603 | if (resolved_type->id == ZigTypeIdPointer && op_id != IrBinOpCmpEq && op_id != IrBinOpCmpNotEq) { |
| 14539 | if ((op1_val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr || | 15604 | if ((op1_val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr || |
| 14540 | op1_val->data.x_ptr.special == ConstPtrSpecialNull) && | 15605 | op1_val->data.x_ptr.special == ConstPtrSpecialNull) && |
| ... | @@ -14554,7 +15619,7 @@ static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_t | ... | @@ -14554,7 +15619,7 @@ static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_t |
| 14554 | cmp_result = CmpEQ; | 15619 | cmp_result = CmpEQ; |
| 14555 | } | 15620 | } |
| 14556 | bool answer = resolve_cmp_op_id(op_id, cmp_result); | 15621 | bool answer = resolve_cmp_op_id(op_id, cmp_result); |
| 14557 | return ir_const_bool(ira, &bin_op_instruction->base, answer); | 15622 | return ir_const_bool(ira, &bin_op_instruction->base.base, answer); |
| 14558 | } | 15623 | } |
| 14559 | } else { | 15624 | } else { |
| 14560 | bool are_equal = one_possible_value || const_values_equal(ira->codegen, op1_val, op2_val); | 15625 | bool are_equal = one_possible_value || const_values_equal(ira->codegen, op1_val, op2_val); |
| ... | @@ -14566,7 +15631,7 @@ static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_t | ... | @@ -14566,7 +15631,7 @@ static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_t |
| 14566 | } else { | 15631 | } else { |
| 14567 | zig_unreachable(); | 15632 | zig_unreachable(); |
| 14568 | } | 15633 | } |
| 14569 | return ir_const_bool(ira, &bin_op_instruction->base, answer); | 15634 | return ir_const_bool(ira, &bin_op_instruction->base.base, answer); |
| 14570 | } | 15635 | } |
| 14571 | zig_unreachable(); | 15636 | zig_unreachable(); |
| 14572 | } | 15637 | } |
| ... | @@ -14620,7 +15685,7 @@ static Error lazy_cmp_zero(AstNode *source_node, ZigValue *val, Cmp *result) { | ... | @@ -14620,7 +15685,7 @@ static Error lazy_cmp_zero(AstNode *source_node, ZigValue *val, Cmp *result) { |
| 14620 | zig_unreachable(); | 15685 | zig_unreachable(); |
| 14621 | } | 15686 | } |
| 14622 | | 15687 | |
| 14623 | static ErrorMsg *ir_eval_bin_op_cmp_scalar(IrAnalyze *ira, IrInstruction *source_instr, | 15688 | static ErrorMsg *ir_eval_bin_op_cmp_scalar(IrAnalyze *ira, IrInst* source_instr, |
| 14624 | ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val, ZigValue *out_val) | 15689 | ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val, ZigValue *out_val) |
| 14625 | { | 15690 | { |
| 14626 | Error err; | 15691 | Error err; |
| ... | @@ -14698,14 +15763,14 @@ never_mind_just_calculate_it_normally: | ... | @@ -14698,14 +15763,14 @@ never_mind_just_calculate_it_normally: |
| 14698 | return nullptr; | 15763 | return nullptr; |
| 14699 | } | 15764 | } |
| 14700 | if (op1_val->type->id == ZigTypeIdComptimeFloat) { | 15765 | if (op1_val->type->id == ZigTypeIdComptimeFloat) { |
| 14701 | IrInstruction *tmp = ir_const_noval(ira, source_instr); | 15766 | IrInstGen *tmp = ir_const_noval(ira, source_instr); |
| 14702 | tmp->value = op1_val; | 15767 | tmp->value = op1_val; |
| 14703 | IrInstruction *casted = ir_implicit_cast(ira, tmp, op2_val->type); | 15768 | IrInstGen *casted = ir_implicit_cast(ira, tmp, op2_val->type); |
| 14704 | op1_val = casted->value; | 15769 | op1_val = casted->value; |
| 14705 | } else if (op2_val->type->id == ZigTypeIdComptimeFloat) { | 15770 | } else if (op2_val->type->id == ZigTypeIdComptimeFloat) { |
| 14706 | IrInstruction *tmp = ir_const_noval(ira, source_instr); | 15771 | IrInstGen *tmp = ir_const_noval(ira, source_instr); |
| 14707 | tmp->value = op2_val; | 15772 | tmp->value = op2_val; |
| 14708 | IrInstruction *casted = ir_implicit_cast(ira, tmp, op1_val->type); | 15773 | IrInstGen *casted = ir_implicit_cast(ira, tmp, op1_val->type); |
| 14709 | op2_val = casted->value; | 15774 | op2_val = casted->value; |
| 14710 | } | 15775 | } |
| 14711 | Cmp cmp_result = float_cmp(op1_val, op2_val); | 15776 | Cmp cmp_result = float_cmp(op1_val, op2_val); |
| ... | @@ -14747,8 +15812,8 @@ never_mind_just_calculate_it_normally: | ... | @@ -14747,8 +15812,8 @@ never_mind_just_calculate_it_normally: |
| 14747 | return nullptr; | 15812 | return nullptr; |
| 14748 | } | 15813 | } |
| 14749 | | 15814 | |
| 14750 | static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstruction *source_instr, | 15815 | static IrInstGen *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInst *source_instr, |
| 14751 | IrInstruction *op1, IrInstruction *op2, IrBinOp op_id) | 15816 | IrInstGen *op1, IrInstGen *op2, IrBinOp op_id) |
| 14752 | { | 15817 | { |
| 14753 | Error err; | 15818 | Error err; |
| 14754 | | 15819 | |
| ... | @@ -14761,7 +15826,7 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -14761,7 +15826,7 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 14761 | ir_add_error(ira, source_instr, | 15826 | ir_add_error(ira, source_instr, |
| 14762 | buf_sprintf("vector length mismatch: %" PRIu32 " and %" PRIu32, | 15827 | buf_sprintf("vector length mismatch: %" PRIu32 " and %" PRIu32, |
| 14763 | op1->value->type->data.vector.len, op2->value->type->data.vector.len)); | 15828 | op1->value->type->data.vector.len, op2->value->type->data.vector.len)); |
| 14764 | return ira->codegen->invalid_instruction; | 15829 | return ira->codegen->invalid_inst_gen; |
| 14765 | } | 15830 | } |
| 14766 | result_type = get_vector_type(ira->codegen, op1->value->type->data.vector.len, scalar_result_type); | 15831 | result_type = get_vector_type(ira->codegen, op1->value->type->data.vector.len, scalar_result_type); |
| 14767 | op1_scalar_type = op1->value->type->data.vector.elem_type; | 15832 | op1_scalar_type = op1->value->type->data.vector.elem_type; |
| ... | @@ -14770,13 +15835,13 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -14770,13 +15835,13 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 14770 | ir_add_error(ira, source_instr, | 15835 | ir_add_error(ira, source_instr, |
| 14771 | buf_sprintf("mixed scalar and vector operands to comparison operator: '%s' and '%s'", | 15836 | buf_sprintf("mixed scalar and vector operands to comparison operator: '%s' and '%s'", |
| 14772 | buf_ptr(&op1->value->type->name), buf_ptr(&op2->value->type->name))); | 15837 | buf_ptr(&op1->value->type->name), buf_ptr(&op2->value->type->name))); |
| 14773 | return ira->codegen->invalid_instruction; | 15838 | return ira->codegen->invalid_inst_gen; |
| 14774 | } | 15839 | } |
| 14775 | | 15840 | |
| 14776 | bool opv_op1; | 15841 | bool opv_op1; |
| 14777 | switch (type_has_one_possible_value(ira->codegen, op1->value->type)) { | 15842 | switch (type_has_one_possible_value(ira->codegen, op1->value->type)) { |
| 14778 | case OnePossibleValueInvalid: | 15843 | case OnePossibleValueInvalid: |
| 14779 | return ira->codegen->invalid_instruction; | 15844 | return ira->codegen->invalid_inst_gen; |
| 14780 | case OnePossibleValueYes: | 15845 | case OnePossibleValueYes: |
| 14781 | opv_op1 = true; | 15846 | opv_op1 = true; |
| 14782 | break; | 15847 | break; |
| ... | @@ -14787,7 +15852,7 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -14787,7 +15852,7 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 14787 | bool opv_op2; | 15852 | bool opv_op2; |
| 14788 | switch (type_has_one_possible_value(ira->codegen, op2->value->type)) { | 15853 | switch (type_has_one_possible_value(ira->codegen, op2->value->type)) { |
| 14789 | case OnePossibleValueInvalid: | 15854 | case OnePossibleValueInvalid: |
| 14790 | return ira->codegen->invalid_instruction; | 15855 | return ira->codegen->invalid_inst_gen; |
| 14791 | case OnePossibleValueYes: | 15856 | case OnePossibleValueYes: |
| 14792 | opv_op2 = true; | 15857 | opv_op2 = true; |
| 14793 | break; | 15858 | break; |
| ... | @@ -14798,21 +15863,21 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -14798,21 +15863,21 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 14798 | Cmp op1_cmp_zero; | 15863 | Cmp op1_cmp_zero; |
| 14799 | bool have_op1_cmp_zero = false; | 15864 | bool have_op1_cmp_zero = false; |
| 14800 | if ((err = lazy_cmp_zero(source_instr->source_node, op1->value, &op1_cmp_zero))) { | 15865 | if ((err = lazy_cmp_zero(source_instr->source_node, op1->value, &op1_cmp_zero))) { |
| 14801 | if (err != ErrorNotLazy) return ira->codegen->invalid_instruction; | 15866 | if (err != ErrorNotLazy) return ira->codegen->invalid_inst_gen; |
| 14802 | } else { | 15867 | } else { |
| 14803 | have_op1_cmp_zero = true; | 15868 | have_op1_cmp_zero = true; |
| 14804 | } | 15869 | } |
| 14805 | Cmp op2_cmp_zero; | 15870 | Cmp op2_cmp_zero; |
| 14806 | bool have_op2_cmp_zero = false; | 15871 | bool have_op2_cmp_zero = false; |
| 14807 | if ((err = lazy_cmp_zero(source_instr->source_node, op2->value, &op2_cmp_zero))) { | 15872 | if ((err = lazy_cmp_zero(source_instr->source_node, op2->value, &op2_cmp_zero))) { |
| 14808 | if (err != ErrorNotLazy) return ira->codegen->invalid_instruction; | 15873 | if (err != ErrorNotLazy) return ira->codegen->invalid_inst_gen; |
| 14809 | } else { | 15874 | } else { |
| 14810 | have_op2_cmp_zero = true; | 15875 | have_op2_cmp_zero = true; |
| 14811 | } | 15876 | } |
| 14812 | if (((opv_op1 || instr_is_comptime(op1)) && (opv_op2 || instr_is_comptime(op2))) || | 15877 | if (((opv_op1 || instr_is_comptime(op1)) && (opv_op2 || instr_is_comptime(op2))) || |
| 14813 | (have_op1_cmp_zero && have_op2_cmp_zero)) | 15878 | (have_op1_cmp_zero && have_op2_cmp_zero)) |
| 14814 | { | 15879 | { |
| 14815 | IrInstruction *result_instruction = ir_const(ira, source_instr, result_type); | 15880 | IrInstGen *result_instruction = ir_const(ira, source_instr, result_type); |
| 14816 | ZigValue *out_val = result_instruction->value; | 15881 | ZigValue *out_val = result_instruction->value; |
| 14817 | if (result_type->id == ZigTypeIdVector) { | 15882 | if (result_type->id == ZigTypeIdVector) { |
| 14818 | size_t len = result_type->data.vector.len; | 15883 | size_t len = result_type->data.vector.len; |
| ... | @@ -14830,7 +15895,7 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -14830,7 +15895,7 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 14830 | if (msg != nullptr) { | 15895 | if (msg != nullptr) { |
| 14831 | add_error_note(ira->codegen, msg, source_instr->source_node, | 15896 | add_error_note(ira->codegen, msg, source_instr->source_node, |
| 14832 | buf_sprintf("when computing vector element at index %" ZIG_PRI_usize, i)); | 15897 | buf_sprintf("when computing vector element at index %" ZIG_PRI_usize, i)); |
| 14833 | return ira->codegen->invalid_instruction; | 15898 | return ira->codegen->invalid_inst_gen; |
| 14834 | } | 15899 | } |
| 14835 | } | 15900 | } |
| 14836 | out_val->type = result_type; | 15901 | out_val->type = result_type; |
| ... | @@ -14839,7 +15904,7 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -14839,7 +15904,7 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 14839 | if (ir_eval_bin_op_cmp_scalar(ira, source_instr, op1->value, op_id, | 15904 | if (ir_eval_bin_op_cmp_scalar(ira, source_instr, op1->value, op_id, |
| 14840 | op2->value, out_val) != nullptr) | 15905 | op2->value, out_val) != nullptr) |
| 14841 | { | 15906 | { |
| 14842 | return ira->codegen->invalid_instruction; | 15907 | return ira->codegen->invalid_inst_gen; |
| 14843 | } | 15908 | } |
| 14844 | } | 15909 | } |
| 14845 | return result_instruction; | 15910 | return result_instruction; |
| ... | @@ -14933,10 +15998,10 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -14933,10 +15998,10 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 14933 | } | 15998 | } |
| 14934 | ZigType *dest_type = (result_type->id == ZigTypeIdVector) ? | 15999 | ZigType *dest_type = (result_type->id == ZigTypeIdVector) ? |
| 14935 | get_vector_type(ira->codegen, result_type->data.vector.len, dest_scalar_type) : dest_scalar_type; | 16000 | get_vector_type(ira->codegen, result_type->data.vector.len, dest_scalar_type) : dest_scalar_type; |
| 14936 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, dest_type); | 16001 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, dest_type); |
| 14937 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, dest_type); | 16002 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, dest_type); |
| 14938 | if (type_is_invalid(casted_op1->value->type) || type_is_invalid(casted_op2->value->type)) | 16003 | if (type_is_invalid(casted_op1->value->type) || type_is_invalid(casted_op2->value->type)) |
| 14939 | return ira->codegen->invalid_instruction; | 16004 | return ira->codegen->invalid_inst_gen; |
| 14940 | return ir_build_bin_op_gen(ira, source_instr, result_type, op_id, casted_op1, casted_op2, true); | 16005 | return ir_build_bin_op_gen(ira, source_instr, result_type, op_id, casted_op1, casted_op2, true); |
| 14941 | } | 16006 | } |
| 14942 | | 16007 | |
| ... | @@ -14966,12 +16031,12 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -14966,12 +16031,12 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 14966 | if (instr_is_comptime(op1)) { | 16031 | if (instr_is_comptime(op1)) { |
| 14967 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefOk); | 16032 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefOk); |
| 14968 | if (op1_val == nullptr) | 16033 | if (op1_val == nullptr) |
| 14969 | return ira->codegen->invalid_instruction; | 16034 | return ira->codegen->invalid_inst_gen; |
| 14970 | if (op1_val->special == ConstValSpecialUndef) | 16035 | if (op1_val->special == ConstValSpecialUndef) |
| 14971 | return ir_const_undef(ira, source_instr, ira->codegen->builtin_types.entry_bool); | 16036 | return ir_const_undef(ira, source_instr, ira->codegen->builtin_types.entry_bool); |
| 14972 | if (result_type->id == ZigTypeIdVector) { | 16037 | if (result_type->id == ZigTypeIdVector) { |
| 14973 | ir_add_error(ira, op1, buf_sprintf("compiler bug: TODO: support comptime vector here")); | 16038 | ir_add_error(ira, &op1->base, buf_sprintf("compiler bug: TODO: support comptime vector here")); |
| 14974 | return ira->codegen->invalid_instruction; | 16039 | return ira->codegen->invalid_inst_gen; |
| 14975 | } | 16040 | } |
| 14976 | bool is_unsigned; | 16041 | bool is_unsigned; |
| 14977 | if (op1_is_float) { | 16042 | if (op1_is_float) { |
| ... | @@ -15010,12 +16075,12 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -15010,12 +16075,12 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 15010 | if (instr_is_comptime(op2)) { | 16075 | if (instr_is_comptime(op2)) { |
| 15011 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefOk); | 16076 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefOk); |
| 15012 | if (op2_val == nullptr) | 16077 | if (op2_val == nullptr) |
| 15013 | return ira->codegen->invalid_instruction; | 16078 | return ira->codegen->invalid_inst_gen; |
| 15014 | if (op2_val->special == ConstValSpecialUndef) | 16079 | if (op2_val->special == ConstValSpecialUndef) |
| 15015 | return ir_const_undef(ira, source_instr, ira->codegen->builtin_types.entry_bool); | 16080 | return ir_const_undef(ira, source_instr, ira->codegen->builtin_types.entry_bool); |
| 15016 | if (result_type->id == ZigTypeIdVector) { | 16081 | if (result_type->id == ZigTypeIdVector) { |
| 15017 | ir_add_error(ira, op2, buf_sprintf("compiler bug: TODO: support comptime vector here")); | 16082 | ir_add_error(ira, &op2->base, buf_sprintf("compiler bug: TODO: support comptime vector here")); |
| 15018 | return ira->codegen->invalid_instruction; | 16083 | return ira->codegen->invalid_inst_gen; |
| 15019 | } | 16084 | } |
| 15020 | bool is_unsigned; | 16085 | bool is_unsigned; |
| 15021 | if (op2_is_float) { | 16086 | if (op2_is_float) { |
| ... | @@ -15056,35 +16121,35 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -15056,35 +16121,35 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 15056 | ZigType *dest_type = (result_type->id == ZigTypeIdVector) ? | 16121 | ZigType *dest_type = (result_type->id == ZigTypeIdVector) ? |
| 15057 | get_vector_type(ira->codegen, result_type->data.vector.len, dest_scalar_type) : dest_scalar_type; | 16122 | get_vector_type(ira->codegen, result_type->data.vector.len, dest_scalar_type) : dest_scalar_type; |
| 15058 | | 16123 | |
| 15059 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, dest_type); | 16124 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, dest_type); |
| 15060 | if (type_is_invalid(casted_op1->value->type)) | 16125 | if (type_is_invalid(casted_op1->value->type)) |
| 15061 | return ira->codegen->invalid_instruction; | 16126 | return ira->codegen->invalid_inst_gen; |
| 15062 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, dest_type); | 16127 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, dest_type); |
| 15063 | if (type_is_invalid(casted_op2->value->type)) | 16128 | if (type_is_invalid(casted_op2->value->type)) |
| 15064 | return ira->codegen->invalid_instruction; | 16129 | return ira->codegen->invalid_inst_gen; |
| 15065 | return ir_build_bin_op_gen(ira, source_instr, result_type, op_id, casted_op1, casted_op2, true); | 16130 | return ir_build_bin_op_gen(ira, source_instr, result_type, op_id, casted_op1, casted_op2, true); |
| 15066 | } | 16131 | } |
| 15067 | | 16132 | |
| 15068 | static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { | 16133 | static IrInstGen *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstSrcBinOp *bin_op_instruction) { |
| 15069 | IrInstruction *op1 = bin_op_instruction->op1->child; | 16134 | IrInstGen *op1 = bin_op_instruction->op1->child; |
| 15070 | if (type_is_invalid(op1->value->type)) | 16135 | if (type_is_invalid(op1->value->type)) |
| 15071 | return ira->codegen->invalid_instruction; | 16136 | return ira->codegen->invalid_inst_gen; |
| 15072 | | 16137 | |
| 15073 | IrInstruction *op2 = bin_op_instruction->op2->child; | 16138 | IrInstGen *op2 = bin_op_instruction->op2->child; |
| 15074 | if (type_is_invalid(op2->value->type)) | 16139 | if (type_is_invalid(op2->value->type)) |
| 15075 | return ira->codegen->invalid_instruction; | 16140 | return ira->codegen->invalid_inst_gen; |
| 15076 | | 16141 | |
| 15077 | AstNode *source_node = bin_op_instruction->base.source_node; | 16142 | AstNode *source_node = bin_op_instruction->base.base.source_node; |
| 15078 | | 16143 | |
| 15079 | IrBinOp op_id = bin_op_instruction->op_id; | 16144 | IrBinOp op_id = bin_op_instruction->op_id; |
| 15080 | bool is_equality_cmp = (op_id == IrBinOpCmpEq || op_id == IrBinOpCmpNotEq); | 16145 | bool is_equality_cmp = (op_id == IrBinOpCmpEq || op_id == IrBinOpCmpNotEq); |
| 15081 | if (is_equality_cmp && op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdNull) { | 16146 | if (is_equality_cmp && op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdNull) { |
| 15082 | return ir_const_bool(ira, &bin_op_instruction->base, (op_id == IrBinOpCmpEq)); | 16147 | return ir_const_bool(ira, &bin_op_instruction->base.base, (op_id == IrBinOpCmpEq)); |
| 15083 | } else if (is_equality_cmp && | 16148 | } else if (is_equality_cmp && |
| 15084 | ((op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdOptional) || | 16149 | ((op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdOptional) || |
| 15085 | (op2->value->type->id == ZigTypeIdNull && op1->value->type->id == ZigTypeIdOptional))) | 16150 | (op2->value->type->id == ZigTypeIdNull && op1->value->type->id == ZigTypeIdOptional))) |
| 15086 | { | 16151 | { |
| 15087 | IrInstruction *maybe_op; | 16152 | IrInstGen *maybe_op; |
| 15088 | if (op1->value->type->id == ZigTypeIdNull) { | 16153 | if (op1->value->type->id == ZigTypeIdNull) { |
| 15089 | maybe_op = op2; | 16154 | maybe_op = op2; |
| 15090 | } else if (op2->value->type->id == ZigTypeIdNull) { | 16155 | } else if (op2->value->type->id == ZigTypeIdNull) { |
| ... | @@ -15095,21 +16160,16 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15095,21 +16160,16 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15095 | if (instr_is_comptime(maybe_op)) { | 16160 | if (instr_is_comptime(maybe_op)) { |
| 15096 | ZigValue *maybe_val = ir_resolve_const(ira, maybe_op, UndefBad); | 16161 | ZigValue *maybe_val = ir_resolve_const(ira, maybe_op, UndefBad); |
| 15097 | if (!maybe_val) | 16162 | if (!maybe_val) |
| 15098 | return ira->codegen->invalid_instruction; | 16163 | return ira->codegen->invalid_inst_gen; |
| 15099 | bool is_null = optional_value_is_null(maybe_val); | 16164 | bool is_null = optional_value_is_null(maybe_val); |
| 15100 | bool bool_result = (op_id == IrBinOpCmpEq) ? is_null : !is_null; | 16165 | bool bool_result = (op_id == IrBinOpCmpEq) ? is_null : !is_null; |
| 15101 | return ir_const_bool(ira, &bin_op_instruction->base, bool_result); | 16166 | return ir_const_bool(ira, &bin_op_instruction->base.base, bool_result); |
| 15102 | } | 16167 | } |
| 15103 | | 16168 | |
| 15104 | IrInstruction *is_non_null = ir_build_test_nonnull(&ira->new_irb, bin_op_instruction->base.scope, | 16169 | IrInstGen *is_non_null = ir_build_test_non_null_gen(ira, &bin_op_instruction->base.base, maybe_op); |
| 15105 | source_node, maybe_op); | | |
| 15106 | is_non_null->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 15107 | | 16170 | |
| 15108 | if (op_id == IrBinOpCmpEq) { | 16171 | if (op_id == IrBinOpCmpEq) { |
| 15109 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, bin_op_instruction->base.scope, | 16172 | return ir_build_bool_not_gen(ira, &bin_op_instruction->base.base, is_non_null); |
| 15110 | bin_op_instruction->base.source_node, is_non_null); | | |
| 15111 | result->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 15112 | return result; | | |
| 15113 | } else { | 16173 | } else { |
| 15114 | return is_non_null; | 16174 | return is_non_null; |
| 15115 | } | 16175 | } |
| ... | @@ -15119,7 +16179,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15119,7 +16179,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15119 | (op2->value->type->id == ZigTypeIdNull && op1->value->type->id == ZigTypeIdPointer && | 16179 | (op2->value->type->id == ZigTypeIdNull && op1->value->type->id == ZigTypeIdPointer && |
| 15120 | op1->value->type->data.pointer.ptr_len == PtrLenC))) | 16180 | op1->value->type->data.pointer.ptr_len == PtrLenC))) |
| 15121 | { | 16181 | { |
| 15122 | IrInstruction *c_ptr_op; | 16182 | IrInstGen *c_ptr_op; |
| 15123 | if (op1->value->type->id == ZigTypeIdNull) { | 16183 | if (op1->value->type->id == ZigTypeIdNull) { |
| 15124 | c_ptr_op = op2; | 16184 | c_ptr_op = op2; |
| 15125 | } else if (op2->value->type->id == ZigTypeIdNull) { | 16185 | } else if (op2->value->type->id == ZigTypeIdNull) { |
| ... | @@ -15130,24 +16190,19 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15130,24 +16190,19 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15130 | if (instr_is_comptime(c_ptr_op)) { | 16190 | if (instr_is_comptime(c_ptr_op)) { |
| 15131 | ZigValue *c_ptr_val = ir_resolve_const(ira, c_ptr_op, UndefOk); | 16191 | ZigValue *c_ptr_val = ir_resolve_const(ira, c_ptr_op, UndefOk); |
| 15132 | if (!c_ptr_val) | 16192 | if (!c_ptr_val) |
| 15133 | return ira->codegen->invalid_instruction; | 16193 | return ira->codegen->invalid_inst_gen; |
| 15134 | if (c_ptr_val->special == ConstValSpecialUndef) | 16194 | if (c_ptr_val->special == ConstValSpecialUndef) |
| 15135 | return ir_const_undef(ira, &bin_op_instruction->base, ira->codegen->builtin_types.entry_bool); | 16195 | return ir_const_undef(ira, &bin_op_instruction->base.base, ira->codegen->builtin_types.entry_bool); |
| 15136 | bool is_null = c_ptr_val->data.x_ptr.special == ConstPtrSpecialNull || | 16196 | bool is_null = c_ptr_val->data.x_ptr.special == ConstPtrSpecialNull || |
| 15137 | (c_ptr_val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr && | 16197 | (c_ptr_val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr && |
| 15138 | c_ptr_val->data.x_ptr.data.hard_coded_addr.addr == 0); | 16198 | c_ptr_val->data.x_ptr.data.hard_coded_addr.addr == 0); |
| 15139 | bool bool_result = (op_id == IrBinOpCmpEq) ? is_null : !is_null; | 16199 | bool bool_result = (op_id == IrBinOpCmpEq) ? is_null : !is_null; |
| 15140 | return ir_const_bool(ira, &bin_op_instruction->base, bool_result); | 16200 | return ir_const_bool(ira, &bin_op_instruction->base.base, bool_result); |
| 15141 | } | 16201 | } |
| 15142 | IrInstruction *is_non_null = ir_build_test_nonnull(&ira->new_irb, bin_op_instruction->base.scope, | 16202 | IrInstGen *is_non_null = ir_build_test_non_null_gen(ira, &bin_op_instruction->base.base, c_ptr_op); |
| 15143 | source_node, c_ptr_op); | | |
| 15144 | is_non_null->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 15145 | | 16203 | |
| 15146 | if (op_id == IrBinOpCmpEq) { | 16204 | if (op_id == IrBinOpCmpEq) { |
| 15147 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, bin_op_instruction->base.scope, | 16205 | return ir_build_bool_not_gen(ira, &bin_op_instruction->base.base, is_non_null); |
| 15148 | bin_op_instruction->base.source_node, is_non_null); | | |
| 15149 | result->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 15150 | return result; | | |
| 15151 | } else { | 16206 | } else { |
| 15152 | return is_non_null; | 16207 | return is_non_null; |
| 15153 | } | 16208 | } |
| ... | @@ -15155,61 +16210,57 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15155,61 +16210,57 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15155 | ZigType *non_null_type = (op1->value->type->id == ZigTypeIdNull) ? op2->value->type : op1->value->type; | 16210 | ZigType *non_null_type = (op1->value->type->id == ZigTypeIdNull) ? op2->value->type : op1->value->type; |
| 15156 | ir_add_error_node(ira, source_node, buf_sprintf("comparison of '%s' with null", | 16211 | ir_add_error_node(ira, source_node, buf_sprintf("comparison of '%s' with null", |
| 15157 | buf_ptr(&non_null_type->name))); | 16212 | buf_ptr(&non_null_type->name))); |
| 15158 | return ira->codegen->invalid_instruction; | 16213 | return ira->codegen->invalid_inst_gen; |
| 15159 | } else if (is_equality_cmp && ( | 16214 | } else if (is_equality_cmp && ( |
| 15160 | (op1->value->type->id == ZigTypeIdEnumLiteral && op2->value->type->id == ZigTypeIdUnion) || | 16215 | (op1->value->type->id == ZigTypeIdEnumLiteral && op2->value->type->id == ZigTypeIdUnion) || |
| 15161 | (op2->value->type->id == ZigTypeIdEnumLiteral && op1->value->type->id == ZigTypeIdUnion))) | 16216 | (op2->value->type->id == ZigTypeIdEnumLiteral && op1->value->type->id == ZigTypeIdUnion))) |
| 15162 | { | 16217 | { |
| 15163 | // Support equality comparison between a union's tag value and a enum literal | 16218 | // Support equality comparison between a union's tag value and a enum literal |
| 15164 | IrInstruction *union_val = op1->value->type->id == ZigTypeIdUnion ? op1 : op2; | 16219 | IrInstGen *union_val = op1->value->type->id == ZigTypeIdUnion ? op1 : op2; |
| 15165 | IrInstruction *enum_val = op1->value->type->id == ZigTypeIdUnion ? op2 : op1; | 16220 | IrInstGen *enum_val = op1->value->type->id == ZigTypeIdUnion ? op2 : op1; |
| 15166 | | 16221 | |
| 15167 | ZigType *tag_type = union_val->value->type->data.unionation.tag_type; | 16222 | ZigType *tag_type = union_val->value->type->data.unionation.tag_type; |
| 15168 | assert(tag_type != nullptr); | 16223 | assert(tag_type != nullptr); |
| 15169 | | 16224 | |
| 15170 | IrInstruction *casted_union = ir_implicit_cast(ira, union_val, tag_type); | 16225 | IrInstGen *casted_union = ir_implicit_cast(ira, union_val, tag_type); |
| 15171 | if (type_is_invalid(casted_union->value->type)) | 16226 | if (type_is_invalid(casted_union->value->type)) |
| 15172 | return ira->codegen->invalid_instruction; | 16227 | return ira->codegen->invalid_inst_gen; |
| 15173 | | 16228 | |
| 15174 | IrInstruction *casted_val = ir_implicit_cast(ira, enum_val, tag_type); | 16229 | IrInstGen *casted_val = ir_implicit_cast(ira, enum_val, tag_type); |
| 15175 | if (type_is_invalid(casted_val->value->type)) | 16230 | if (type_is_invalid(casted_val->value->type)) |
| 15176 | return ira->codegen->invalid_instruction; | 16231 | return ira->codegen->invalid_inst_gen; |
| 15177 | | 16232 | |
| 15178 | if (instr_is_comptime(casted_union)) { | 16233 | if (instr_is_comptime(casted_union)) { |
| 15179 | ZigValue *const_union_val = ir_resolve_const(ira, casted_union, UndefBad); | 16234 | ZigValue *const_union_val = ir_resolve_const(ira, casted_union, UndefBad); |
| 15180 | if (!const_union_val) | 16235 | if (!const_union_val) |
| 15181 | return ira->codegen->invalid_instruction; | 16236 | return ira->codegen->invalid_inst_gen; |
| 15182 | | 16237 | |
| 15183 | ZigValue *const_enum_val = ir_resolve_const(ira, casted_val, UndefBad); | 16238 | ZigValue *const_enum_val = ir_resolve_const(ira, casted_val, UndefBad); |
| 15184 | if (!const_enum_val) | 16239 | if (!const_enum_val) |
| 15185 | return ira->codegen->invalid_instruction; | 16240 | return ira->codegen->invalid_inst_gen; |
| 15186 | | 16241 | |
| 15187 | Cmp cmp_result = bigint_cmp(&const_union_val->data.x_union.tag, &const_enum_val->data.x_enum_tag); | 16242 | Cmp cmp_result = bigint_cmp(&const_union_val->data.x_union.tag, &const_enum_val->data.x_enum_tag); |
| 15188 | bool bool_result = (op_id == IrBinOpCmpEq) ? cmp_result == CmpEQ : cmp_result != CmpEQ; | 16243 | bool bool_result = (op_id == IrBinOpCmpEq) ? cmp_result == CmpEQ : cmp_result != CmpEQ; |
| 15189 | | 16244 | |
| 15190 | return ir_const_bool(ira, &bin_op_instruction->base, bool_result); | 16245 | return ir_const_bool(ira, &bin_op_instruction->base.base, bool_result); |
| 15191 | } | 16246 | } |
| 15192 | | 16247 | |
| 15193 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, | 16248 | return ir_build_bin_op_gen(ira, &bin_op_instruction->base.base, ira->codegen->builtin_types.entry_bool, |
| 15194 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, | | |
| 15195 | op_id, casted_union, casted_val, bin_op_instruction->safety_check_on); | 16249 | op_id, casted_union, casted_val, bin_op_instruction->safety_check_on); |
| 15196 | result->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 15197 | | | |
| 15198 | return result; | | |
| 15199 | } | 16250 | } |
| 15200 | | 16251 | |
| 15201 | if (op1->value->type->id == ZigTypeIdErrorSet && op2->value->type->id == ZigTypeIdErrorSet) { | 16252 | if (op1->value->type->id == ZigTypeIdErrorSet && op2->value->type->id == ZigTypeIdErrorSet) { |
| 15202 | if (!is_equality_cmp) { | 16253 | if (!is_equality_cmp) { |
| 15203 | ir_add_error_node(ira, source_node, buf_sprintf("operator not allowed for errors")); | 16254 | ir_add_error_node(ira, source_node, buf_sprintf("operator not allowed for errors")); |
| 15204 | return ira->codegen->invalid_instruction; | 16255 | return ira->codegen->invalid_inst_gen; |
| 15205 | } | 16256 | } |
| 15206 | ZigType *intersect_type = get_error_set_intersection(ira, op1->value->type, op2->value->type, source_node); | 16257 | ZigType *intersect_type = get_error_set_intersection(ira, op1->value->type, op2->value->type, source_node); |
| 15207 | if (type_is_invalid(intersect_type)) { | 16258 | if (type_is_invalid(intersect_type)) { |
| 15208 | return ira->codegen->invalid_instruction; | 16259 | return ira->codegen->invalid_inst_gen; |
| 15209 | } | 16260 | } |
| 15210 | | 16261 | |
| 15211 | if (!resolve_inferred_error_set(ira->codegen, intersect_type, source_node)) { | 16262 | if (!resolve_inferred_error_set(ira->codegen, intersect_type, source_node)) { |
| 15212 | return ira->codegen->invalid_instruction; | 16263 | return ira->codegen->invalid_inst_gen; |
| 15213 | } | 16264 | } |
| 15214 | | 16265 | |
| 15215 | // exception if one of the operators has the type of the empty error set, we allow the comparison | 16266 | // exception if one of the operators has the type of the empty error set, we allow the comparison |
| ... | @@ -15226,7 +16277,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15226,7 +16277,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15226 | } else { | 16277 | } else { |
| 15227 | zig_unreachable(); | 16278 | zig_unreachable(); |
| 15228 | } | 16279 | } |
| 15229 | return ir_const_bool(ira, &bin_op_instruction->base, answer); | 16280 | return ir_const_bool(ira, &bin_op_instruction->base.base, answer); |
| 15230 | } | 16281 | } |
| 15231 | | 16282 | |
| 15232 | if (!type_is_global_error_set(intersect_type)) { | 16283 | if (!type_is_global_error_set(intersect_type)) { |
| ... | @@ -15234,7 +16285,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15234,7 +16285,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15234 | ir_add_error_node(ira, source_node, | 16285 | ir_add_error_node(ira, source_node, |
| 15235 | buf_sprintf("error sets '%s' and '%s' have no common errors", | 16286 | buf_sprintf("error sets '%s' and '%s' have no common errors", |
| 15236 | buf_ptr(&op1->value->type->name), buf_ptr(&op2->value->type->name))); | 16287 | buf_ptr(&op1->value->type->name), buf_ptr(&op2->value->type->name))); |
| 15237 | return ira->codegen->invalid_instruction; | 16288 | return ira->codegen->invalid_inst_gen; |
| 15238 | } | 16289 | } |
| 15239 | if (op1->value->type->data.error_set.err_count == 1 && op2->value->type->data.error_set.err_count == 1) { | 16290 | if (op1->value->type->data.error_set.err_count == 1 && op2->value->type->data.error_set.err_count == 1) { |
| 15240 | bool are_equal = true; | 16291 | bool are_equal = true; |
| ... | @@ -15246,17 +16297,17 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15246,17 +16297,17 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15246 | } else { | 16297 | } else { |
| 15247 | zig_unreachable(); | 16298 | zig_unreachable(); |
| 15248 | } | 16299 | } |
| 15249 | return ir_const_bool(ira, &bin_op_instruction->base, answer); | 16300 | return ir_const_bool(ira, &bin_op_instruction->base.base, answer); |
| 15250 | } | 16301 | } |
| 15251 | } | 16302 | } |
| 15252 | | 16303 | |
| 15253 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { | 16304 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { |
| 15254 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 16305 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 15255 | if (op1_val == nullptr) | 16306 | if (op1_val == nullptr) |
| 15256 | return ira->codegen->invalid_instruction; | 16307 | return ira->codegen->invalid_inst_gen; |
| 15257 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 16308 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 15258 | if (op2_val == nullptr) | 16309 | if (op2_val == nullptr) |
| 15259 | return ira->codegen->invalid_instruction; | 16310 | return ira->codegen->invalid_inst_gen; |
| 15260 | | 16311 | |
| 15261 | bool answer; | 16312 | bool answer; |
| 15262 | bool are_equal = op1_val->data.x_err_set->value == op2_val->data.x_err_set->value; | 16313 | bool are_equal = op1_val->data.x_err_set->value == op2_val->data.x_err_set->value; |
| ... | @@ -15268,27 +16319,24 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15268,27 +16319,24 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15268 | zig_unreachable(); | 16319 | zig_unreachable(); |
| 15269 | } | 16320 | } |
| 15270 | | 16321 | |
| 15271 | return ir_const_bool(ira, &bin_op_instruction->base, answer); | 16322 | return ir_const_bool(ira, &bin_op_instruction->base.base, answer); |
| 15272 | } | 16323 | } |
| 15273 | | 16324 | |
| 15274 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, | 16325 | return ir_build_bin_op_gen(ira, &bin_op_instruction->base.base, ira->codegen->builtin_types.entry_bool, |
| 15275 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, | | |
| 15276 | op_id, op1, op2, bin_op_instruction->safety_check_on); | 16326 | op_id, op1, op2, bin_op_instruction->safety_check_on); |
| 15277 | result->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 15278 | return result; | | |
| 15279 | } | 16327 | } |
| 15280 | | 16328 | |
| 15281 | if (type_is_numeric(op1->value->type) && type_is_numeric(op2->value->type)) { | 16329 | if (type_is_numeric(op1->value->type) && type_is_numeric(op2->value->type)) { |
| 15282 | // This operation allows any combination of integer and float types, regardless of the | 16330 | // This operation allows any combination of integer and float types, regardless of the |
| 15283 | // signed-ness, comptime-ness, and bit-width. So peer type resolution is incorrect for | 16331 | // signed-ness, comptime-ness, and bit-width. So peer type resolution is incorrect for |
| 15284 | // numeric types. | 16332 | // numeric types. |
| 15285 | return ir_analyze_bin_op_cmp_numeric(ira, &bin_op_instruction->base, op1, op2, op_id); | 16333 | return ir_analyze_bin_op_cmp_numeric(ira, &bin_op_instruction->base.base, op1, op2, op_id); |
| 15286 | } | 16334 | } |
| 15287 | | 16335 | |
| 15288 | IrInstruction *instructions[] = {op1, op2}; | 16336 | IrInstGen *instructions[] = {op1, op2}; |
| 15289 | ZigType *resolved_type = ir_resolve_peer_types(ira, source_node, nullptr, instructions, 2); | 16337 | ZigType *resolved_type = ir_resolve_peer_types(ira, source_node, nullptr, instructions, 2); |
| 15290 | if (type_is_invalid(resolved_type)) | 16338 | if (type_is_invalid(resolved_type)) |
| 15291 | return ira->codegen->invalid_instruction; | 16339 | return ira->codegen->invalid_inst_gen; |
| 15292 | | 16340 | |
| 15293 | bool operator_allowed; | 16341 | bool operator_allowed; |
| 15294 | switch (resolved_type->id) { | 16342 | switch (resolved_type->id) { |
| ... | @@ -15336,21 +16384,21 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15336,21 +16384,21 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15336 | if (!operator_allowed) { | 16384 | if (!operator_allowed) { |
| 15337 | ir_add_error_node(ira, source_node, | 16385 | ir_add_error_node(ira, source_node, |
| 15338 | buf_sprintf("operator not allowed for type '%s'", buf_ptr(&resolved_type->name))); | 16386 | buf_sprintf("operator not allowed for type '%s'", buf_ptr(&resolved_type->name))); |
| 15339 | return ira->codegen->invalid_instruction; | 16387 | return ira->codegen->invalid_inst_gen; |
| 15340 | } | 16388 | } |
| 15341 | | 16389 | |
| 15342 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); | 16390 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); |
| 15343 | if (casted_op1 == ira->codegen->invalid_instruction) | 16391 | if (type_is_invalid(casted_op1->value->type)) |
| 15344 | return ira->codegen->invalid_instruction; | 16392 | return ira->codegen->invalid_inst_gen; |
| 15345 | | 16393 | |
| 15346 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); | 16394 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); |
| 15347 | if (casted_op2 == ira->codegen->invalid_instruction) | 16395 | if (type_is_invalid(casted_op2->value->type)) |
| 15348 | return ira->codegen->invalid_instruction; | 16396 | return ira->codegen->invalid_inst_gen; |
| 15349 | | 16397 | |
| 15350 | bool one_possible_value; | 16398 | bool one_possible_value; |
| 15351 | switch (type_has_one_possible_value(ira->codegen, resolved_type)) { | 16399 | switch (type_has_one_possible_value(ira->codegen, resolved_type)) { |
| 15352 | case OnePossibleValueInvalid: | 16400 | case OnePossibleValueInvalid: |
| 15353 | return ira->codegen->invalid_instruction; | 16401 | return ira->codegen->invalid_inst_gen; |
| 15354 | case OnePossibleValueYes: | 16402 | case OnePossibleValueYes: |
| 15355 | one_possible_value = true; | 16403 | one_possible_value = true; |
| 15356 | break; | 16404 | break; |
| ... | @@ -15362,20 +16410,20 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15362,20 +16410,20 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15362 | if (one_possible_value || (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2))) { | 16410 | if (one_possible_value || (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2))) { |
| 15363 | ZigValue *op1_val = one_possible_value ? casted_op1->value : ir_resolve_const(ira, casted_op1, UndefBad); | 16411 | ZigValue *op1_val = one_possible_value ? casted_op1->value : ir_resolve_const(ira, casted_op1, UndefBad); |
| 15364 | if (op1_val == nullptr) | 16412 | if (op1_val == nullptr) |
| 15365 | return ira->codegen->invalid_instruction; | 16413 | return ira->codegen->invalid_inst_gen; |
| 15366 | ZigValue *op2_val = one_possible_value ? casted_op2->value : ir_resolve_const(ira, casted_op2, UndefBad); | 16414 | ZigValue *op2_val = one_possible_value ? casted_op2->value : ir_resolve_const(ira, casted_op2, UndefBad); |
| 15367 | if (op2_val == nullptr) | 16415 | if (op2_val == nullptr) |
| 15368 | return ira->codegen->invalid_instruction; | 16416 | return ira->codegen->invalid_inst_gen; |
| 15369 | if (resolved_type->id != ZigTypeIdVector) | 16417 | if (resolved_type->id != ZigTypeIdVector) |
| 15370 | return ir_evaluate_bin_op_cmp(ira, resolved_type, op1_val, op2_val, bin_op_instruction, op_id, one_possible_value); | 16418 | return ir_evaluate_bin_op_cmp(ira, resolved_type, op1_val, op2_val, bin_op_instruction, op_id, one_possible_value); |
| 15371 | IrInstruction *result = ir_const(ira, &bin_op_instruction->base, | 16419 | IrInstGen *result = ir_const(ira, &bin_op_instruction->base.base, |
| 15372 | get_vector_type(ira->codegen, resolved_type->data.vector.len, ira->codegen->builtin_types.entry_bool)); | 16420 | get_vector_type(ira->codegen, resolved_type->data.vector.len, ira->codegen->builtin_types.entry_bool)); |
| 15373 | result->value->data.x_array.data.s_none.elements = | 16421 | result->value->data.x_array.data.s_none.elements = |
| 15374 | create_const_vals(resolved_type->data.vector.len); | 16422 | create_const_vals(resolved_type->data.vector.len); |
| 15375 | | 16423 | |
| 15376 | expand_undef_array(ira->codegen, result->value); | 16424 | expand_undef_array(ira->codegen, result->value); |
| 15377 | for (size_t i = 0;i < resolved_type->data.vector.len;i++) { | 16425 | for (size_t i = 0;i < resolved_type->data.vector.len;i++) { |
| 15378 | IrInstruction *cur_res = ir_evaluate_bin_op_cmp(ira, resolved_type->data.vector.elem_type, | 16426 | IrInstGen *cur_res = ir_evaluate_bin_op_cmp(ira, resolved_type->data.vector.elem_type, |
| 15379 | &op1_val->data.x_array.data.s_none.elements[i], | 16427 | &op1_val->data.x_array.data.s_none.elements[i], |
| 15380 | &op2_val->data.x_array.data.s_none.elements[i], | 16428 | &op2_val->data.x_array.data.s_none.elements[i], |
| 15381 | bin_op_instruction, op_id, one_possible_value); | 16429 | bin_op_instruction, op_id, one_possible_value); |
| ... | @@ -15384,19 +16432,14 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15384,19 +16432,14 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15384 | return result; | 16432 | return result; |
| 15385 | } | 16433 | } |
| 15386 | | 16434 | |
| 15387 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, | 16435 | ZigType *res_type = (resolved_type->id == ZigTypeIdVector) ? |
| 15388 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, | 16436 | get_vector_type(ira->codegen, resolved_type->data.vector.len, ira->codegen->builtin_types.entry_bool) : |
| | 16437 | ira->codegen->builtin_types.entry_bool; |
| | 16438 | return ir_build_bin_op_gen(ira, &bin_op_instruction->base.base, res_type, |
| 15389 | op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on); | 16439 | op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on); |
| 15390 | if (resolved_type->id == ZigTypeIdVector) { | | |
| 15391 | result->value->type = get_vector_type(ira->codegen, resolved_type->data.vector.len, | | |
| 15392 | ira->codegen->builtin_types.entry_bool); | | |
| 15393 | } else { | | |
| 15394 | result->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 15395 | } | | |
| 15396 | return result; | | |
| 15397 | } | 16440 | } |
| 15398 | | 16441 | |
| 15399 | static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_instr, ZigType *type_entry, | 16442 | static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInst* source_instr, ZigType *type_entry, |
| 15400 | ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val, ZigValue *out_val) | 16443 | ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val, ZigValue *out_val) |
| 15401 | { | 16444 | { |
| 15402 | bool is_int; | 16445 | bool is_int; |
| ... | @@ -15576,10 +16619,10 @@ static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -15576,10 +16619,10 @@ static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_in |
| 15576 | } | 16619 | } |
| 15577 | | 16620 | |
| 15578 | // This works on operands that have already been checked to be comptime known. | 16621 | // This works on operands that have already been checked to be comptime known. |
| 15579 | static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_instr, | 16622 | static IrInstGen *ir_analyze_math_op(IrAnalyze *ira, IrInst* source_instr, |
| 15580 | ZigType *type_entry, ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val) | 16623 | ZigType *type_entry, ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val) |
| 15581 | { | 16624 | { |
| 15582 | IrInstruction *result_instruction = ir_const(ira, source_instr, type_entry); | 16625 | IrInstGen *result_instruction = ir_const(ira, source_instr, type_entry); |
| 15583 | ZigValue *out_val = result_instruction->value; | 16626 | ZigValue *out_val = result_instruction->value; |
| 15584 | if (type_entry->id == ZigTypeIdVector) { | 16627 | if (type_entry->id == ZigTypeIdVector) { |
| 15585 | expand_undef_array(ira->codegen, op1_val); | 16628 | expand_undef_array(ira->codegen, op1_val); |
| ... | @@ -15600,43 +16643,43 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -15600,43 +16643,43 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i |
| 15600 | if (msg != nullptr) { | 16643 | if (msg != nullptr) { |
| 15601 | add_error_note(ira->codegen, msg, source_instr->source_node, | 16644 | add_error_note(ira->codegen, msg, source_instr->source_node, |
| 15602 | buf_sprintf("when computing vector element at index %" ZIG_PRI_usize, i)); | 16645 | buf_sprintf("when computing vector element at index %" ZIG_PRI_usize, i)); |
| 15603 | return ira->codegen->invalid_instruction; | 16646 | return ira->codegen->invalid_inst_gen; |
| 15604 | } | 16647 | } |
| 15605 | } | 16648 | } |
| 15606 | out_val->type = type_entry; | 16649 | out_val->type = type_entry; |
| 15607 | out_val->special = ConstValSpecialStatic; | 16650 | out_val->special = ConstValSpecialStatic; |
| 15608 | } else { | 16651 | } else { |
| 15609 | if (ir_eval_math_op_scalar(ira, source_instr, type_entry, op1_val, op_id, op2_val, out_val) != nullptr) { | 16652 | if (ir_eval_math_op_scalar(ira, source_instr, type_entry, op1_val, op_id, op2_val, out_val) != nullptr) { |
| 15610 | return ira->codegen->invalid_instruction; | 16653 | return ira->codegen->invalid_inst_gen; |
| 15611 | } | 16654 | } |
| 15612 | } | 16655 | } |
| 15613 | return ir_implicit_cast(ira, result_instruction, type_entry); | 16656 | return ir_implicit_cast(ira, result_instruction, type_entry); |
| 15614 | } | 16657 | } |
| 15615 | | 16658 | |
| 15616 | static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { | 16659 | static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_instruction) { |
| 15617 | IrInstruction *op1 = bin_op_instruction->op1->child; | 16660 | IrInstGen *op1 = bin_op_instruction->op1->child; |
| 15618 | if (type_is_invalid(op1->value->type)) | 16661 | if (type_is_invalid(op1->value->type)) |
| 15619 | return ira->codegen->invalid_instruction; | 16662 | return ira->codegen->invalid_inst_gen; |
| 15620 | | 16663 | |
| 15621 | if (op1->value->type->id != ZigTypeIdInt && op1->value->type->id != ZigTypeIdComptimeInt) { | 16664 | if (op1->value->type->id != ZigTypeIdInt && op1->value->type->id != ZigTypeIdComptimeInt) { |
| 15622 | ir_add_error(ira, bin_op_instruction->op1, | 16665 | ir_add_error(ira, &bin_op_instruction->op1->base, |
| 15623 | buf_sprintf("bit shifting operation expected integer type, found '%s'", | 16666 | buf_sprintf("bit shifting operation expected integer type, found '%s'", |
| 15624 | buf_ptr(&op1->value->type->name))); | 16667 | buf_ptr(&op1->value->type->name))); |
| 15625 | return ira->codegen->invalid_instruction; | 16668 | return ira->codegen->invalid_inst_gen; |
| 15626 | } | 16669 | } |
| 15627 | | 16670 | |
| 15628 | IrInstruction *op2 = bin_op_instruction->op2->child; | 16671 | IrInstGen *op2 = bin_op_instruction->op2->child; |
| 15629 | if (type_is_invalid(op2->value->type)) | 16672 | if (type_is_invalid(op2->value->type)) |
| 15630 | return ira->codegen->invalid_instruction; | 16673 | return ira->codegen->invalid_inst_gen; |
| 15631 | | 16674 | |
| 15632 | if (op2->value->type->id != ZigTypeIdInt && op2->value->type->id != ZigTypeIdComptimeInt) { | 16675 | if (op2->value->type->id != ZigTypeIdInt && op2->value->type->id != ZigTypeIdComptimeInt) { |
| 15633 | ir_add_error(ira, bin_op_instruction->op2, | 16676 | ir_add_error(ira, &bin_op_instruction->op2->base, |
| 15634 | buf_sprintf("shift amount has to be an integer type, but found '%s'", | 16677 | buf_sprintf("shift amount has to be an integer type, but found '%s'", |
| 15635 | buf_ptr(&op2->value->type->name))); | 16678 | buf_ptr(&op2->value->type->name))); |
| 15636 | return ira->codegen->invalid_instruction; | 16679 | return ira->codegen->invalid_inst_gen; |
| 15637 | } | 16680 | } |
| 15638 | | 16681 | |
| 15639 | IrInstruction *casted_op2; | 16682 | IrInstGen *casted_op2; |
| 15640 | IrBinOp op_id = bin_op_instruction->op_id; | 16683 | IrBinOp op_id = bin_op_instruction->op_id; |
| 15641 | if (op1->value->type->id == ZigTypeIdComptimeInt) { | 16684 | if (op1->value->type->id == ZigTypeIdComptimeInt) { |
| 15642 | casted_op2 = op2; | 16685 | casted_op2 = op2; |
| ... | @@ -15648,8 +16691,8 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b | ... | @@ -15648,8 +16691,8 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b |
| 15648 | if (casted_op2->value->data.x_bigint.is_negative) { | 16691 | if (casted_op2->value->data.x_bigint.is_negative) { |
| 15649 | Buf *val_buf = buf_alloc(); | 16692 | Buf *val_buf = buf_alloc(); |
| 15650 | bigint_append_buf(val_buf, &casted_op2->value->data.x_bigint, 10); | 16693 | bigint_append_buf(val_buf, &casted_op2->value->data.x_bigint, 10); |
| 15651 | ir_add_error(ira, casted_op2, buf_sprintf("shift by negative value %s", buf_ptr(val_buf))); | 16694 | ir_add_error(ira, &casted_op2->base, buf_sprintf("shift by negative value %s", buf_ptr(val_buf))); |
| 15652 | return ira->codegen->invalid_instruction; | 16695 | return ira->codegen->invalid_inst_gen; |
| 15653 | } | 16696 | } |
| 15654 | } else { | 16697 | } else { |
| 15655 | ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, | 16698 | ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, |
| ... | @@ -15659,57 +16702,51 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b | ... | @@ -15659,57 +16702,51 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b |
| 15659 | | 16702 | |
| 15660 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 16703 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 15661 | if (op2_val == nullptr) | 16704 | if (op2_val == nullptr) |
| 15662 | return ira->codegen->invalid_instruction; | 16705 | return ira->codegen->invalid_inst_gen; |
| 15663 | if (!bigint_fits_in_bits(&op2_val->data.x_bigint, | 16706 | if (!bigint_fits_in_bits(&op2_val->data.x_bigint, |
| 15664 | shift_amt_type->data.integral.bit_count, | 16707 | shift_amt_type->data.integral.bit_count, |
| 15665 | op2_val->data.x_bigint.is_negative)) { | 16708 | op2_val->data.x_bigint.is_negative)) { |
| 15666 | Buf *val_buf = buf_alloc(); | 16709 | Buf *val_buf = buf_alloc(); |
| 15667 | bigint_append_buf(val_buf, &op2_val->data.x_bigint, 10); | 16710 | bigint_append_buf(val_buf, &op2_val->data.x_bigint, 10); |
| 15668 | ErrorMsg* msg = ir_add_error(ira, | 16711 | ErrorMsg* msg = ir_add_error(ira, |
| 15669 | &bin_op_instruction->base, | 16712 | &bin_op_instruction->base.base, |
| 15670 | buf_sprintf("RHS of shift is too large for LHS type")); | 16713 | buf_sprintf("RHS of shift is too large for LHS type")); |
| 15671 | add_error_note( | 16714 | add_error_note( |
| 15672 | ira->codegen, | 16715 | ira->codegen, |
| 15673 | msg, | 16716 | msg, |
| 15674 | op2->source_node, | 16717 | op2->base.source_node, |
| 15675 | buf_sprintf("value %s cannot fit into type %s", | 16718 | buf_sprintf("value %s cannot fit into type %s", |
| 15676 | buf_ptr(val_buf), | 16719 | buf_ptr(val_buf), |
| 15677 | buf_ptr(&shift_amt_type->name))); | 16720 | buf_ptr(&shift_amt_type->name))); |
| 15678 | return ira->codegen->invalid_instruction; | 16721 | return ira->codegen->invalid_inst_gen; |
| 15679 | } | 16722 | } |
| 15680 | } | 16723 | } |
| 15681 | | 16724 | |
| 15682 | casted_op2 = ir_implicit_cast(ira, op2, shift_amt_type); | 16725 | casted_op2 = ir_implicit_cast(ira, op2, shift_amt_type); |
| 15683 | if (casted_op2 == ira->codegen->invalid_instruction) | 16726 | if (type_is_invalid(casted_op2->value->type)) |
| 15684 | return ira->codegen->invalid_instruction; | 16727 | return ira->codegen->invalid_inst_gen; |
| 15685 | } | 16728 | } |
| 15686 | | 16729 | |
| 15687 | if (instr_is_comptime(op1) && instr_is_comptime(casted_op2)) { | 16730 | if (instr_is_comptime(op1) && instr_is_comptime(casted_op2)) { |
| 15688 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 16731 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 15689 | if (op1_val == nullptr) | 16732 | if (op1_val == nullptr) |
| 15690 | return ira->codegen->invalid_instruction; | 16733 | return ira->codegen->invalid_inst_gen; |
| 15691 | | 16734 | |
| 15692 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 16735 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 15693 | if (op2_val == nullptr) | 16736 | if (op2_val == nullptr) |
| 15694 | return ira->codegen->invalid_instruction; | 16737 | return ira->codegen->invalid_inst_gen; |
| 15695 | | 16738 | |
| 15696 | return ir_analyze_math_op(ira, &bin_op_instruction->base, op1->value->type, op1_val, op_id, op2_val); | 16739 | return ir_analyze_math_op(ira, &bin_op_instruction->base.base, op1->value->type, op1_val, op_id, op2_val); |
| 15697 | } else if (op1->value->type->id == ZigTypeIdComptimeInt) { | 16740 | } else if (op1->value->type->id == ZigTypeIdComptimeInt) { |
| 15698 | ir_add_error(ira, &bin_op_instruction->base, | 16741 | ir_add_error(ira, &bin_op_instruction->base.base, |
| 15699 | buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known")); | 16742 | buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known")); |
| 15700 | return ira->codegen->invalid_instruction; | 16743 | return ira->codegen->invalid_inst_gen; |
| 15701 | } else if (instr_is_comptime(casted_op2) && bigint_cmp_zero(&casted_op2->value->data.x_bigint) == CmpEQ) { | 16744 | } else if (instr_is_comptime(casted_op2) && bigint_cmp_zero(&casted_op2->value->data.x_bigint) == CmpEQ) { |
| 15702 | IrInstruction *result = ir_build_cast(&ira->new_irb, bin_op_instruction->base.scope, | 16745 | return ir_build_cast(ira, &bin_op_instruction->base.base, op1->value->type, op1, CastOpNoop); |
| 15703 | bin_op_instruction->base.source_node, op1->value->type, op1, CastOpNoop); | | |
| 15704 | result->value->type = op1->value->type; | | |
| 15705 | return result; | | |
| 15706 | } | 16746 | } |
| 15707 | | 16747 | |
| 15708 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, bin_op_instruction->base.scope, | 16748 | return ir_build_bin_op_gen(ira, &bin_op_instruction->base.base, op1->value->type, |
| 15709 | bin_op_instruction->base.source_node, op_id, | 16749 | op_id, op1, casted_op2, bin_op_instruction->safety_check_on); |
| 15710 | op1, casted_op2, bin_op_instruction->safety_check_on); | | |
| 15711 | result->value->type = op1->value->type; | | |
| 15712 | return result; | | |
| 15713 | } | 16750 | } |
| 15714 | | 16751 | |
| 15715 | static bool ok_float_op(IrBinOp op) { | 16752 | static bool ok_float_op(IrBinOp op) { |
| ... | @@ -15773,24 +16810,24 @@ static bool is_pointer_arithmetic_allowed(ZigType *lhs_type, IrBinOp op) { | ... | @@ -15773,24 +16810,24 @@ static bool is_pointer_arithmetic_allowed(ZigType *lhs_type, IrBinOp op) { |
| 15773 | zig_unreachable(); | 16810 | zig_unreachable(); |
| 15774 | } | 16811 | } |
| 15775 | | 16812 | |
| 15776 | static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp *instruction) { | 16813 | static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruction) { |
| 15777 | Error err; | 16814 | Error err; |
| 15778 | | 16815 | |
| 15779 | IrInstruction *op1 = instruction->op1->child; | 16816 | IrInstGen *op1 = instruction->op1->child; |
| 15780 | if (type_is_invalid(op1->value->type)) | 16817 | if (type_is_invalid(op1->value->type)) |
| 15781 | return ira->codegen->invalid_instruction; | 16818 | return ira->codegen->invalid_inst_gen; |
| 15782 | | 16819 | |
| 15783 | IrInstruction *op2 = instruction->op2->child; | 16820 | IrInstGen *op2 = instruction->op2->child; |
| 15784 | if (type_is_invalid(op2->value->type)) | 16821 | if (type_is_invalid(op2->value->type)) |
| 15785 | return ira->codegen->invalid_instruction; | 16822 | return ira->codegen->invalid_inst_gen; |
| 15786 | | 16823 | |
| 15787 | IrBinOp op_id = instruction->op_id; | 16824 | IrBinOp op_id = instruction->op_id; |
| 15788 | | 16825 | |
| 15789 | // look for pointer math | 16826 | // look for pointer math |
| 15790 | if (is_pointer_arithmetic_allowed(op1->value->type, op_id)) { | 16827 | if (is_pointer_arithmetic_allowed(op1->value->type, op_id)) { |
| 15791 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, ira->codegen->builtin_types.entry_usize); | 16828 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, ira->codegen->builtin_types.entry_usize); |
| 15792 | if (type_is_invalid(casted_op2->value->type)) | 16829 | if (type_is_invalid(casted_op2->value->type)) |
| 15793 | return ira->codegen->invalid_instruction; | 16830 | return ira->codegen->invalid_inst_gen; |
| 15794 | | 16831 | |
| 15795 | // If either operand is undef, result is undef. | 16832 | // If either operand is undef, result is undef. |
| 15796 | ZigValue *op1_val = nullptr; | 16833 | ZigValue *op1_val = nullptr; |
| ... | @@ -15798,28 +16835,28 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15798,28 +16835,28 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15798 | if (instr_is_comptime(op1)) { | 16835 | if (instr_is_comptime(op1)) { |
| 15799 | op1_val = ir_resolve_const(ira, op1, UndefOk); | 16836 | op1_val = ir_resolve_const(ira, op1, UndefOk); |
| 15800 | if (op1_val == nullptr) | 16837 | if (op1_val == nullptr) |
| 15801 | return ira->codegen->invalid_instruction; | 16838 | return ira->codegen->invalid_inst_gen; |
| 15802 | if (op1_val->special == ConstValSpecialUndef) | 16839 | if (op1_val->special == ConstValSpecialUndef) |
| 15803 | return ir_const_undef(ira, &instruction->base, op1->value->type); | 16840 | return ir_const_undef(ira, &instruction->base.base, op1->value->type); |
| 15804 | } | 16841 | } |
| 15805 | if (instr_is_comptime(casted_op2)) { | 16842 | if (instr_is_comptime(casted_op2)) { |
| 15806 | op2_val = ir_resolve_const(ira, casted_op2, UndefOk); | 16843 | op2_val = ir_resolve_const(ira, casted_op2, UndefOk); |
| 15807 | if (op2_val == nullptr) | 16844 | if (op2_val == nullptr) |
| 15808 | return ira->codegen->invalid_instruction; | 16845 | return ira->codegen->invalid_inst_gen; |
| 15809 | if (op2_val->special == ConstValSpecialUndef) | 16846 | if (op2_val->special == ConstValSpecialUndef) |
| 15810 | return ir_const_undef(ira, &instruction->base, op1->value->type); | 16847 | return ir_const_undef(ira, &instruction->base.base, op1->value->type); |
| 15811 | } | 16848 | } |
| 15812 | | 16849 | |
| 15813 | ZigType *elem_type = op1->value->type->data.pointer.child_type; | 16850 | ZigType *elem_type = op1->value->type->data.pointer.child_type; |
| 15814 | if ((err = type_resolve(ira->codegen, elem_type, ResolveStatusSizeKnown))) | 16851 | if ((err = type_resolve(ira->codegen, elem_type, ResolveStatusSizeKnown))) |
| 15815 | return ira->codegen->invalid_instruction; | 16852 | return ira->codegen->invalid_inst_gen; |
| 15816 | | 16853 | |
| 15817 | // NOTE: this variable is meaningful iff op2_val is not null! | 16854 | // NOTE: this variable is meaningful iff op2_val is not null! |
| 15818 | uint64_t byte_offset; | 16855 | uint64_t byte_offset; |
| 15819 | if (op2_val != nullptr) { | 16856 | if (op2_val != nullptr) { |
| 15820 | uint64_t elem_offset; | 16857 | uint64_t elem_offset; |
| 15821 | if (!ir_resolve_usize(ira, casted_op2, &elem_offset)) | 16858 | if (!ir_resolve_usize(ira, casted_op2, &elem_offset)) |
| 15822 | return ira->codegen->invalid_instruction; | 16859 | return ira->codegen->invalid_inst_gen; |
| 15823 | | 16860 | |
| 15824 | byte_offset = type_size(ira->codegen, elem_type) * elem_offset; | 16861 | byte_offset = type_size(ira->codegen, elem_type) * elem_offset; |
| 15825 | } | 16862 | } |
| ... | @@ -15834,7 +16871,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15834,7 +16871,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15834 | { | 16871 | { |
| 15835 | uint32_t align_bytes; | 16872 | uint32_t align_bytes; |
| 15836 | if ((err = resolve_ptr_align(ira, op1->value->type, &align_bytes))) | 16873 | if ((err = resolve_ptr_align(ira, op1->value->type, &align_bytes))) |
| 15837 | return ira->codegen->invalid_instruction; | 16874 | return ira->codegen->invalid_inst_gen; |
| 15838 | | 16875 | |
| 15839 | // If the addend is not a comptime-known value we can still count on | 16876 | // If the addend is not a comptime-known value we can still count on |
| 15840 | // it being a multiple of the type size | 16877 | // it being a multiple of the type size |
| ... | @@ -15863,23 +16900,20 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15863,23 +16900,20 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15863 | } else { | 16900 | } else { |
| 15864 | zig_unreachable(); | 16901 | zig_unreachable(); |
| 15865 | } | 16902 | } |
| 15866 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 16903 | IrInstGen *result = ir_const(ira, &instruction->base.base, result_type); |
| 15867 | result->value->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; | 16904 | result->value->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; |
| 15868 | result->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; | 16905 | result->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; |
| 15869 | result->value->data.x_ptr.data.hard_coded_addr.addr = new_addr; | 16906 | result->value->data.x_ptr.data.hard_coded_addr.addr = new_addr; |
| 15870 | return result; | 16907 | return result; |
| 15871 | } | 16908 | } |
| 15872 | | 16909 | |
| 15873 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, instruction->base.scope, | 16910 | return ir_build_bin_op_gen(ira, &instruction->base.base, result_type, op_id, op1, casted_op2, true); |
| 15874 | instruction->base.source_node, op_id, op1, casted_op2, true); | | |
| 15875 | result->value->type = result_type; | | |
| 15876 | return result; | | |
| 15877 | } | 16911 | } |
| 15878 | | 16912 | |
| 15879 | IrInstruction *instructions[] = {op1, op2}; | 16913 | IrInstGen *instructions[] = {op1, op2}; |
| 15880 | ZigType *resolved_type = ir_resolve_peer_types(ira, instruction->base.source_node, nullptr, instructions, 2); | 16914 | ZigType *resolved_type = ir_resolve_peer_types(ira, instruction->base.base.source_node, nullptr, instructions, 2); |
| 15881 | if (type_is_invalid(resolved_type)) | 16915 | if (type_is_invalid(resolved_type)) |
| 15882 | return ira->codegen->invalid_instruction; | 16916 | return ira->codegen->invalid_inst_gen; |
| 15883 | | 16917 | |
| 15884 | bool is_int = resolved_type->id == ZigTypeIdInt || resolved_type->id == ZigTypeIdComptimeInt; | 16918 | bool is_int = resolved_type->id == ZigTypeIdInt || resolved_type->id == ZigTypeIdComptimeInt; |
| 15885 | bool is_float = resolved_type->id == ZigTypeIdFloat || resolved_type->id == ZigTypeIdComptimeFloat; | 16919 | bool is_float = resolved_type->id == ZigTypeIdFloat || resolved_type->id == ZigTypeIdComptimeFloat; |
| ... | @@ -15899,11 +16933,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15899,11 +16933,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15899 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { | 16933 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { |
| 15900 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 16934 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 15901 | if (op1_val == nullptr) | 16935 | if (op1_val == nullptr) |
| 15902 | return ira->codegen->invalid_instruction; | 16936 | return ira->codegen->invalid_inst_gen; |
| 15903 | | 16937 | |
| 15904 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 16938 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 15905 | if (op2_val == nullptr) | 16939 | if (op2_val == nullptr) |
| 15906 | return ira->codegen->invalid_instruction; | 16940 | return ira->codegen->invalid_inst_gen; |
| 15907 | | 16941 | |
| 15908 | if (bigint_cmp_zero(&op2_val->data.x_bigint) == CmpEQ) { | 16942 | if (bigint_cmp_zero(&op2_val->data.x_bigint) == CmpEQ) { |
| 15909 | // the division by zero error will be caught later, but we don't have a | 16943 | // the division by zero error will be caught later, but we don't have a |
| ... | @@ -15922,11 +16956,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15922,11 +16956,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15922 | } | 16956 | } |
| 15923 | } | 16957 | } |
| 15924 | if (!ok) { | 16958 | if (!ok) { |
| 15925 | ir_add_error(ira, &instruction->base, | 16959 | ir_add_error(ira, &instruction->base.base, |
| 15926 | buf_sprintf("division with '%s' and '%s': signed integers must use @divTrunc, @divFloor, or @divExact", | 16960 | buf_sprintf("division with '%s' and '%s': signed integers must use @divTrunc, @divFloor, or @divExact", |
| 15927 | buf_ptr(&op1->value->type->name), | 16961 | buf_ptr(&op1->value->type->name), |
| 15928 | buf_ptr(&op2->value->type->name))); | 16962 | buf_ptr(&op2->value->type->name))); |
| 15929 | return ira->codegen->invalid_instruction; | 16963 | return ira->codegen->invalid_inst_gen; |
| 15930 | } | 16964 | } |
| 15931 | } else { | 16965 | } else { |
| 15932 | op_id = IrBinOpDivTrunc; | 16966 | op_id = IrBinOpDivTrunc; |
| ... | @@ -15937,12 +16971,12 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15937,12 +16971,12 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15937 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { | 16971 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { |
| 15938 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 16972 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 15939 | if (op1_val == nullptr) | 16973 | if (op1_val == nullptr) |
| 15940 | return ira->codegen->invalid_instruction; | 16974 | return ira->codegen->invalid_inst_gen; |
| 15941 | | 16975 | |
| 15942 | if (is_int) { | 16976 | if (is_int) { |
| 15943 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 16977 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 15944 | if (op2_val == nullptr) | 16978 | if (op2_val == nullptr) |
| 15945 | return ira->codegen->invalid_instruction; | 16979 | return ira->codegen->invalid_inst_gen; |
| 15946 | | 16980 | |
| 15947 | if (bigint_cmp_zero(&op2->value->data.x_bigint) == CmpEQ) { | 16981 | if (bigint_cmp_zero(&op2->value->data.x_bigint) == CmpEQ) { |
| 15948 | // the division by zero error will be caught later, but we don't | 16982 | // the division by zero error will be caught later, but we don't |
| ... | @@ -15956,13 +16990,13 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15956,13 +16990,13 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15956 | ok = bigint_cmp(&rem_result, &mod_result) == CmpEQ; | 16990 | ok = bigint_cmp(&rem_result, &mod_result) == CmpEQ; |
| 15957 | } | 16991 | } |
| 15958 | } else { | 16992 | } else { |
| 15959 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); | 16993 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); |
| 15960 | if (casted_op2 == ira->codegen->invalid_instruction) | 16994 | if (type_is_invalid(casted_op2->value->type)) |
| 15961 | return ira->codegen->invalid_instruction; | 16995 | return ira->codegen->invalid_inst_gen; |
| 15962 | | 16996 | |
| 15963 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 16997 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 15964 | if (op2_val == nullptr) | 16998 | if (op2_val == nullptr) |
| 15965 | return ira->codegen->invalid_instruction; | 16999 | return ira->codegen->invalid_inst_gen; |
| 15966 | | 17000 | |
| 15967 | if (float_cmp_zero(casted_op2->value) == CmpEQ) { | 17001 | if (float_cmp_zero(casted_op2->value) == CmpEQ) { |
| 15968 | // the division by zero error will be caught later, but we don't | 17002 | // the division by zero error will be caught later, but we don't |
| ... | @@ -15978,11 +17012,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15978,11 +17012,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15978 | } | 17012 | } |
| 15979 | } | 17013 | } |
| 15980 | if (!ok) { | 17014 | if (!ok) { |
| 15981 | ir_add_error(ira, &instruction->base, | 17015 | ir_add_error(ira, &instruction->base.base, |
| 15982 | buf_sprintf("remainder division with '%s' and '%s': signed integers and floats must use @rem or @mod", | 17016 | buf_sprintf("remainder division with '%s' and '%s': signed integers and floats must use @rem or @mod", |
| 15983 | buf_ptr(&op1->value->type->name), | 17017 | buf_ptr(&op1->value->type->name), |
| 15984 | buf_ptr(&op2->value->type->name))); | 17018 | buf_ptr(&op2->value->type->name))); |
| 15985 | return ira->codegen->invalid_instruction; | 17019 | return ira->codegen->invalid_inst_gen; |
| 15986 | } | 17020 | } |
| 15987 | } | 17021 | } |
| 15988 | op_id = IrBinOpRemRem; | 17022 | op_id = IrBinOpRemRem; |
| ... | @@ -16002,12 +17036,12 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -16002,12 +17036,12 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 16002 | } | 17036 | } |
| 16003 | } | 17037 | } |
| 16004 | if (!ok) { | 17038 | if (!ok) { |
| 16005 | AstNode *source_node = instruction->base.source_node; | 17039 | AstNode *source_node = instruction->base.base.source_node; |
| 16006 | ir_add_error_node(ira, source_node, | 17040 | ir_add_error_node(ira, source_node, |
| 16007 | buf_sprintf("invalid operands to binary expression: '%s' and '%s'", | 17041 | buf_sprintf("invalid operands to binary expression: '%s' and '%s'", |
| 16008 | buf_ptr(&op1->value->type->name), | 17042 | buf_ptr(&op1->value->type->name), |
| 16009 | buf_ptr(&op2->value->type->name))); | 17043 | buf_ptr(&op2->value->type->name))); |
| 16010 | return ira->codegen->invalid_instruction; | 17044 | return ira->codegen->invalid_inst_gen; |
| 16011 | } | 17045 | } |
| 16012 | | 17046 | |
| 16013 | if (resolved_type->id == ZigTypeIdComptimeInt) { | 17047 | if (resolved_type->id == ZigTypeIdComptimeInt) { |
| ... | @@ -16020,33 +17054,31 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -16020,33 +17054,31 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 16020 | } | 17054 | } |
| 16021 | } | 17055 | } |
| 16022 | | 17056 | |
| 16023 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); | 17057 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); |
| 16024 | if (casted_op1 == ira->codegen->invalid_instruction) | 17058 | if (type_is_invalid(casted_op1->value->type)) |
| 16025 | return ira->codegen->invalid_instruction; | 17059 | return ira->codegen->invalid_inst_gen; |
| 16026 | | 17060 | |
| 16027 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); | 17061 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); |
| 16028 | if (casted_op2 == ira->codegen->invalid_instruction) | 17062 | if (type_is_invalid(casted_op2->value->type)) |
| 16029 | return ira->codegen->invalid_instruction; | 17063 | return ira->codegen->invalid_inst_gen; |
| 16030 | | 17064 | |
| 16031 | if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) { | 17065 | if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) { |
| 16032 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); | 17066 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); |
| 16033 | if (op1_val == nullptr) | 17067 | if (op1_val == nullptr) |
| 16034 | return ira->codegen->invalid_instruction; | 17068 | return ira->codegen->invalid_inst_gen; |
| 16035 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 17069 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 16036 | if (op2_val == nullptr) | 17070 | if (op2_val == nullptr) |
| 16037 | return ira->codegen->invalid_instruction; | 17071 | return ira->codegen->invalid_inst_gen; |
| 16038 | | 17072 | |
| 16039 | return ir_analyze_math_op(ira, &instruction->base, resolved_type, op1_val, op_id, op2_val); | 17073 | return ir_analyze_math_op(ira, &instruction->base.base, resolved_type, op1_val, op_id, op2_val); |
| 16040 | } | 17074 | } |
| 16041 | | 17075 | |
| 16042 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, instruction->base.scope, | 17076 | return ir_build_bin_op_gen(ira, &instruction->base.base, resolved_type, |
| 16043 | instruction->base.source_node, op_id, casted_op1, casted_op2, instruction->safety_check_on); | 17077 | op_id, casted_op1, casted_op2, instruction->safety_check_on); |
| 16044 | result->value->type = resolved_type; | | |
| 16045 | return result; | | |
| 16046 | } | 17078 | } |
| 16047 | | 17079 | |
| 16048 | static IrInstruction *ir_analyze_tuple_cat(IrAnalyze *ira, IrInstruction *source_instr, | 17080 | static IrInstGen *ir_analyze_tuple_cat(IrAnalyze *ira, IrInst* source_instr, |
| 16049 | IrInstruction *op1, IrInstruction *op2) | 17081 | IrInstGen *op1, IrInstGen *op2) |
| 16050 | { | 17082 | { |
| 16051 | Error err; | 17083 | Error err; |
| 16052 | ZigType *op1_type = op1->value->type; | 17084 | ZigType *op1_type = op1->value->type; |
| ... | @@ -16063,9 +17095,9 @@ static IrInstruction *ir_analyze_tuple_cat(IrAnalyze *ira, IrInstruction *source | ... | @@ -16063,9 +17095,9 @@ static IrInstruction *ir_analyze_tuple_cat(IrAnalyze *ira, IrInstruction *source |
| 16063 | new_type->data.structure.special = StructSpecialInferredTuple; | 17095 | new_type->data.structure.special = StructSpecialInferredTuple; |
| 16064 | new_type->data.structure.resolve_status = ResolveStatusBeingInferred; | 17096 | new_type->data.structure.resolve_status = ResolveStatusBeingInferred; |
| 16065 | | 17097 | |
| 16066 | bool is_comptime = ir_should_inline(ira->new_irb.exec, source_instr->scope); | 17098 | bool is_comptime = ir_should_inline(ira->old_irb.exec, source_instr->scope); |
| 16067 | | 17099 | |
| 16068 | IrInstruction *new_struct_ptr = ir_resolve_result(ira, source_instr, no_result_loc(), | 17100 | IrInstGen *new_struct_ptr = ir_resolve_result(ira, source_instr, no_result_loc(), |
| 16069 | new_type, nullptr, false, true); | 17101 | new_type, nullptr, false, true); |
| 16070 | uint32_t new_field_count = op1_field_count + op2_field_count; | 17102 | uint32_t new_field_count = op1_field_count + op2_field_count; |
| 16071 | | 17103 | |
| ... | @@ -16089,13 +17121,13 @@ static IrInstruction *ir_analyze_tuple_cat(IrAnalyze *ira, IrInstruction *source | ... | @@ -16089,13 +17121,13 @@ static IrInstruction *ir_analyze_tuple_cat(IrAnalyze *ira, IrInstruction *source |
| 16089 | new_field->is_comptime = src_field->is_comptime; | 17121 | new_field->is_comptime = src_field->is_comptime; |
| 16090 | } | 17122 | } |
| 16091 | if ((err = type_resolve(ira->codegen, new_type, ResolveStatusZeroBitsKnown))) | 17123 | if ((err = type_resolve(ira->codegen, new_type, ResolveStatusZeroBitsKnown))) |
| 16092 | return ira->codegen->invalid_instruction; | 17124 | return ira->codegen->invalid_inst_gen; |
| 16093 | | 17125 | |
| 16094 | ZigList<IrInstruction *> const_ptrs = {}; | 17126 | ZigList<IrInstGen *> const_ptrs = {}; |
| 16095 | IrInstruction *first_non_const_instruction = nullptr; | 17127 | IrInstGen *first_non_const_instruction = nullptr; |
| 16096 | for (uint32_t i = 0; i < new_field_count; i += 1) { | 17128 | for (uint32_t i = 0; i < new_field_count; i += 1) { |
| 16097 | TypeStructField *dst_field = new_type->data.structure.fields[i]; | 17129 | TypeStructField *dst_field = new_type->data.structure.fields[i]; |
| 16098 | IrInstruction *src_struct_op; | 17130 | IrInstGen *src_struct_op; |
| 16099 | TypeStructField *src_field; | 17131 | TypeStructField *src_field; |
| 16100 | if (i < op1_field_count) { | 17132 | if (i < op1_field_count) { |
| 16101 | src_field = op1_type->data.structure.fields[i]; | 17133 | src_field = op1_type->data.structure.fields[i]; |
| ... | @@ -16104,73 +17136,73 @@ static IrInstruction *ir_analyze_tuple_cat(IrAnalyze *ira, IrInstruction *source | ... | @@ -16104,73 +17136,73 @@ static IrInstruction *ir_analyze_tuple_cat(IrAnalyze *ira, IrInstruction *source |
| 16104 | src_field = op2_type->data.structure.fields[i - op1_field_count]; | 17136 | src_field = op2_type->data.structure.fields[i - op1_field_count]; |
| 16105 | src_struct_op = op2; | 17137 | src_struct_op = op2; |
| 16106 | } | 17138 | } |
| 16107 | IrInstruction *field_value = ir_analyze_struct_value_field_value(ira, source_instr, | 17139 | IrInstGen *field_value = ir_analyze_struct_value_field_value(ira, source_instr, |
| 16108 | src_struct_op, src_field); | 17140 | src_struct_op, src_field); |
| 16109 | if (type_is_invalid(field_value->value->type)) | 17141 | if (type_is_invalid(field_value->value->type)) |
| 16110 | return ira->codegen->invalid_instruction; | 17142 | return ira->codegen->invalid_inst_gen; |
| 16111 | IrInstruction *dest_ptr = ir_analyze_struct_field_ptr(ira, source_instr, dst_field, | 17143 | IrInstGen *dest_ptr = ir_analyze_struct_field_ptr(ira, source_instr, dst_field, |
| 16112 | new_struct_ptr, new_type, true); | 17144 | new_struct_ptr, new_type, true); |
| 16113 | if (type_is_invalid(dest_ptr->value->type)) | 17145 | if (type_is_invalid(dest_ptr->value->type)) |
| 16114 | return ira->codegen->invalid_instruction; | 17146 | return ira->codegen->invalid_inst_gen; |
| 16115 | if (instr_is_comptime(field_value)) { | 17147 | if (instr_is_comptime(field_value)) { |
| 16116 | const_ptrs.append(dest_ptr); | 17148 | const_ptrs.append(dest_ptr); |
| 16117 | } else { | 17149 | } else { |
| 16118 | first_non_const_instruction = field_value; | 17150 | first_non_const_instruction = field_value; |
| 16119 | } | 17151 | } |
| 16120 | IrInstruction *store_ptr_inst = ir_analyze_store_ptr(ira, source_instr, dest_ptr, field_value, | 17152 | IrInstGen *store_ptr_inst = ir_analyze_store_ptr(ira, source_instr, dest_ptr, field_value, |
| 16121 | true); | 17153 | true); |
| 16122 | if (type_is_invalid(store_ptr_inst->value->type)) | 17154 | if (type_is_invalid(store_ptr_inst->value->type)) |
| 16123 | return ira->codegen->invalid_instruction; | 17155 | return ira->codegen->invalid_inst_gen; |
| 16124 | } | 17156 | } |
| 16125 | if (const_ptrs.length != new_field_count) { | 17157 | if (const_ptrs.length != new_field_count) { |
| 16126 | new_struct_ptr->value->special = ConstValSpecialRuntime; | 17158 | new_struct_ptr->value->special = ConstValSpecialRuntime; |
| 16127 | for (size_t i = 0; i < const_ptrs.length; i += 1) { | 17159 | for (size_t i = 0; i < const_ptrs.length; i += 1) { |
| 16128 | IrInstruction *elem_result_loc = const_ptrs.at(i); | 17160 | IrInstGen *elem_result_loc = const_ptrs.at(i); |
| 16129 | assert(elem_result_loc->value->special == ConstValSpecialStatic); | 17161 | assert(elem_result_loc->value->special == ConstValSpecialStatic); |
| 16130 | if (elem_result_loc->value->type->data.pointer.inferred_struct_field != nullptr) { | 17162 | if (elem_result_loc->value->type->data.pointer.inferred_struct_field != nullptr) { |
| 16131 | // This field will be generated comptime; no need to do this. | 17163 | // This field will be generated comptime; no need to do this. |
| 16132 | continue; | 17164 | continue; |
| 16133 | } | 17165 | } |
| 16134 | IrInstruction *deref = ir_get_deref(ira, elem_result_loc, elem_result_loc, nullptr); | 17166 | IrInstGen *deref = ir_get_deref(ira, &elem_result_loc->base, elem_result_loc, nullptr); |
| 16135 | elem_result_loc->value->special = ConstValSpecialRuntime; | 17167 | elem_result_loc->value->special = ConstValSpecialRuntime; |
| 16136 | ir_analyze_store_ptr(ira, elem_result_loc, elem_result_loc, deref, false); | 17168 | ir_analyze_store_ptr(ira, &elem_result_loc->base, elem_result_loc, deref, false); |
| 16137 | } | 17169 | } |
| 16138 | } | 17170 | } |
| 16139 | IrInstruction *result = ir_get_deref(ira, source_instr, new_struct_ptr, nullptr); | 17171 | IrInstGen *result = ir_get_deref(ira, source_instr, new_struct_ptr, nullptr); |
| 16140 | if (instr_is_comptime(result)) | 17172 | if (instr_is_comptime(result)) |
| 16141 | return result; | 17173 | return result; |
| 16142 | | 17174 | |
| 16143 | if (is_comptime) { | 17175 | if (is_comptime) { |
| 16144 | ir_add_error_node(ira, first_non_const_instruction->source_node, | 17176 | ir_add_error(ira, &first_non_const_instruction->base, |
| 16145 | buf_sprintf("unable to evaluate constant expression")); | 17177 | buf_sprintf("unable to evaluate constant expression")); |
| 16146 | return ira->codegen->invalid_instruction; | 17178 | return ira->codegen->invalid_inst_gen; |
| 16147 | } | 17179 | } |
| 16148 | | 17180 | |
| 16149 | return result; | 17181 | return result; |
| 16150 | } | 17182 | } |
| 16151 | | 17183 | |
| 16152 | static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruction) { | 17184 | static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instruction) { |
| 16153 | IrInstruction *op1 = instruction->op1->child; | 17185 | IrInstGen *op1 = instruction->op1->child; |
| 16154 | ZigType *op1_type = op1->value->type; | 17186 | ZigType *op1_type = op1->value->type; |
| 16155 | if (type_is_invalid(op1_type)) | 17187 | if (type_is_invalid(op1_type)) |
| 16156 | return ira->codegen->invalid_instruction; | 17188 | return ira->codegen->invalid_inst_gen; |
| 16157 | | 17189 | |
| 16158 | IrInstruction *op2 = instruction->op2->child; | 17190 | IrInstGen *op2 = instruction->op2->child; |
| 16159 | ZigType *op2_type = op2->value->type; | 17191 | ZigType *op2_type = op2->value->type; |
| 16160 | if (type_is_invalid(op2_type)) | 17192 | if (type_is_invalid(op2_type)) |
| 16161 | return ira->codegen->invalid_instruction; | 17193 | return ira->codegen->invalid_inst_gen; |
| 16162 | | 17194 | |
| 16163 | if (is_tuple(op1_type) && is_tuple(op2_type)) { | 17195 | if (is_tuple(op1_type) && is_tuple(op2_type)) { |
| 16164 | return ir_analyze_tuple_cat(ira, &instruction->base, op1, op2); | 17196 | return ir_analyze_tuple_cat(ira, &instruction->base.base, op1, op2); |
| 16165 | } | 17197 | } |
| 16166 | | 17198 | |
| 16167 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 17199 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 16168 | if (!op1_val) | 17200 | if (!op1_val) |
| 16169 | return ira->codegen->invalid_instruction; | 17201 | return ira->codegen->invalid_inst_gen; |
| 16170 | | 17202 | |
| 16171 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 17203 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 16172 | if (!op2_val) | 17204 | if (!op2_val) |
| 16173 | return ira->codegen->invalid_instruction; | 17205 | return ira->codegen->invalid_inst_gen; |
| 16174 | | 17206 | |
| 16175 | ZigValue *sentinel1 = nullptr; | 17207 | ZigValue *sentinel1 = nullptr; |
| 16176 | ZigValue *op1_array_val; | 17208 | ZigValue *op1_array_val; |
| ... | @@ -16208,15 +17240,15 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -16208,15 +17240,15 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 16208 | { | 17240 | { |
| 16209 | ZigType *array_type = op1_type->data.pointer.child_type; | 17241 | ZigType *array_type = op1_type->data.pointer.child_type; |
| 16210 | child_type = array_type->data.array.child_type; | 17242 | child_type = array_type->data.array.child_type; |
| 16211 | op1_array_val = const_ptr_pointee(ira, ira->codegen, op1_val, op1->source_node); | 17243 | op1_array_val = const_ptr_pointee(ira, ira->codegen, op1_val, op1->base.source_node); |
| 16212 | if (op1_array_val == nullptr) | 17244 | if (op1_array_val == nullptr) |
| 16213 | return ira->codegen->invalid_instruction; | 17245 | return ira->codegen->invalid_inst_gen; |
| 16214 | op1_array_index = 0; | 17246 | op1_array_index = 0; |
| 16215 | op1_array_end = array_type->data.array.len; | 17247 | op1_array_end = array_type->data.array.len; |
| 16216 | sentinel1 = array_type->data.array.sentinel; | 17248 | sentinel1 = array_type->data.array.sentinel; |
| 16217 | } else { | 17249 | } else { |
| 16218 | ir_add_error(ira, op1, buf_sprintf("expected array, found '%s'", buf_ptr(&op1->value->type->name))); | 17250 | ir_add_error(ira, &op1->base, buf_sprintf("expected array, found '%s'", buf_ptr(&op1->value->type->name))); |
| 16219 | return ira->codegen->invalid_instruction; | 17251 | return ira->codegen->invalid_inst_gen; |
| 16220 | } | 17252 | } |
| 16221 | | 17253 | |
| 16222 | ZigValue *sentinel2 = nullptr; | 17254 | ZigValue *sentinel2 = nullptr; |
| ... | @@ -16256,23 +17288,23 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -16256,23 +17288,23 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 16256 | { | 17288 | { |
| 16257 | ZigType *array_type = op2_type->data.pointer.child_type; | 17289 | ZigType *array_type = op2_type->data.pointer.child_type; |
| 16258 | op2_type_valid = array_type->data.array.child_type == child_type; | 17290 | op2_type_valid = array_type->data.array.child_type == child_type; |
| 16259 | op2_array_val = const_ptr_pointee(ira, ira->codegen, op2_val, op2->source_node); | 17291 | op2_array_val = const_ptr_pointee(ira, ira->codegen, op2_val, op2->base.source_node); |
| 16260 | if (op2_array_val == nullptr) | 17292 | if (op2_array_val == nullptr) |
| 16261 | return ira->codegen->invalid_instruction; | 17293 | return ira->codegen->invalid_inst_gen; |
| 16262 | op2_array_index = 0; | 17294 | op2_array_index = 0; |
| 16263 | op2_array_end = array_type->data.array.len; | 17295 | op2_array_end = array_type->data.array.len; |
| 16264 | | 17296 | |
| 16265 | sentinel2 = array_type->data.array.sentinel; | 17297 | sentinel2 = array_type->data.array.sentinel; |
| 16266 | } else { | 17298 | } else { |
| 16267 | ir_add_error(ira, op2, | 17299 | ir_add_error(ira, &op2->base, |
| 16268 | buf_sprintf("expected array or C string literal, found '%s'", buf_ptr(&op2->value->type->name))); | 17300 | buf_sprintf("expected array or C string literal, found '%s'", buf_ptr(&op2->value->type->name))); |
| 16269 | return ira->codegen->invalid_instruction; | 17301 | return ira->codegen->invalid_inst_gen; |
| 16270 | } | 17302 | } |
| 16271 | if (!op2_type_valid) { | 17303 | if (!op2_type_valid) { |
| 16272 | ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'", | 17304 | ir_add_error(ira, &op2->base, buf_sprintf("expected array of type '%s', found '%s'", |
| 16273 | buf_ptr(&child_type->name), | 17305 | buf_ptr(&child_type->name), |
| 16274 | buf_ptr(&op2->value->type->name))); | 17306 | buf_ptr(&op2->value->type->name))); |
| 16275 | return ira->codegen->invalid_instruction; | 17307 | return ira->codegen->invalid_inst_gen; |
| 16276 | } | 17308 | } |
| 16277 | | 17309 | |
| 16278 | ZigValue *sentinel; | 17310 | ZigValue *sentinel; |
| ... | @@ -16289,7 +17321,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -16289,7 +17321,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 16289 | } | 17321 | } |
| 16290 | | 17322 | |
| 16291 | // The type of result is populated in the following if blocks | 17323 | // The type of result is populated in the following if blocks |
| 16292 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 17324 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 16293 | ZigValue *out_val = result->value; | 17325 | ZigValue *out_val = result->value; |
| 16294 | | 17326 | |
| 16295 | ZigValue *out_array_val; | 17327 | ZigValue *out_array_val; |
| ... | @@ -16377,14 +17409,14 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -16377,14 +17409,14 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 16377 | return result; | 17409 | return result; |
| 16378 | } | 17410 | } |
| 16379 | | 17411 | |
| 16380 | static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *instruction) { | 17412 | static IrInstGen *ir_analyze_array_mult(IrAnalyze *ira, IrInstSrcBinOp *instruction) { |
| 16381 | IrInstruction *op1 = instruction->op1->child; | 17413 | IrInstGen *op1 = instruction->op1->child; |
| 16382 | if (type_is_invalid(op1->value->type)) | 17414 | if (type_is_invalid(op1->value->type)) |
| 16383 | return ira->codegen->invalid_instruction; | 17415 | return ira->codegen->invalid_inst_gen; |
| 16384 | | 17416 | |
| 16385 | IrInstruction *op2 = instruction->op2->child; | 17417 | IrInstGen *op2 = instruction->op2->child; |
| 16386 | if (type_is_invalid(op2->value->type)) | 17418 | if (type_is_invalid(op2->value->type)) |
| 16387 | return ira->codegen->invalid_instruction; | 17419 | return ira->codegen->invalid_inst_gen; |
| 16388 | | 17420 | |
| 16389 | bool want_ptr_to_array = false; | 17421 | bool want_ptr_to_array = false; |
| 16390 | ZigType *array_type; | 17422 | ZigType *array_type; |
| ... | @@ -16393,49 +17425,49 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -16393,49 +17425,49 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * |
| 16393 | array_type = op1->value->type; | 17425 | array_type = op1->value->type; |
| 16394 | array_val = ir_resolve_const(ira, op1, UndefOk); | 17426 | array_val = ir_resolve_const(ira, op1, UndefOk); |
| 16395 | if (array_val == nullptr) | 17427 | if (array_val == nullptr) |
| 16396 | return ira->codegen->invalid_instruction; | 17428 | return ira->codegen->invalid_inst_gen; |
| 16397 | } else if (op1->value->type->id == ZigTypeIdPointer && op1->value->type->data.pointer.ptr_len == PtrLenSingle && | 17429 | } else if (op1->value->type->id == ZigTypeIdPointer && op1->value->type->data.pointer.ptr_len == PtrLenSingle && |
| 16398 | op1->value->type->data.pointer.child_type->id == ZigTypeIdArray) | 17430 | op1->value->type->data.pointer.child_type->id == ZigTypeIdArray) |
| 16399 | { | 17431 | { |
| 16400 | array_type = op1->value->type->data.pointer.child_type; | 17432 | array_type = op1->value->type->data.pointer.child_type; |
| 16401 | IrInstruction *array_inst = ir_get_deref(ira, op1, op1, nullptr); | 17433 | IrInstGen *array_inst = ir_get_deref(ira, &op1->base, op1, nullptr); |
| 16402 | if (type_is_invalid(array_inst->value->type)) | 17434 | if (type_is_invalid(array_inst->value->type)) |
| 16403 | return ira->codegen->invalid_instruction; | 17435 | return ira->codegen->invalid_inst_gen; |
| 16404 | array_val = ir_resolve_const(ira, array_inst, UndefOk); | 17436 | array_val = ir_resolve_const(ira, array_inst, UndefOk); |
| 16405 | if (array_val == nullptr) | 17437 | if (array_val == nullptr) |
| 16406 | return ira->codegen->invalid_instruction; | 17438 | return ira->codegen->invalid_inst_gen; |
| 16407 | want_ptr_to_array = true; | 17439 | want_ptr_to_array = true; |
| 16408 | } else { | 17440 | } else { |
| 16409 | ir_add_error(ira, op1, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value->type->name))); | 17441 | ir_add_error(ira, &op1->base, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value->type->name))); |
| 16410 | return ira->codegen->invalid_instruction; | 17442 | return ira->codegen->invalid_inst_gen; |
| 16411 | } | 17443 | } |
| 16412 | | 17444 | |
| 16413 | uint64_t mult_amt; | 17445 | uint64_t mult_amt; |
| 16414 | if (!ir_resolve_usize(ira, op2, &mult_amt)) | 17446 | if (!ir_resolve_usize(ira, op2, &mult_amt)) |
| 16415 | return ira->codegen->invalid_instruction; | 17447 | return ira->codegen->invalid_inst_gen; |
| 16416 | | 17448 | |
| 16417 | uint64_t old_array_len = array_type->data.array.len; | 17449 | uint64_t old_array_len = array_type->data.array.len; |
| 16418 | uint64_t new_array_len; | 17450 | uint64_t new_array_len; |
| 16419 | | 17451 | |
| 16420 | if (mul_u64_overflow(old_array_len, mult_amt, &new_array_len)) { | 17452 | if (mul_u64_overflow(old_array_len, mult_amt, &new_array_len)) { |
| 16421 | ir_add_error(ira, &instruction->base, buf_sprintf("operation results in overflow")); | 17453 | ir_add_error(ira, &instruction->base.base, buf_sprintf("operation results in overflow")); |
| 16422 | return ira->codegen->invalid_instruction; | 17454 | return ira->codegen->invalid_inst_gen; |
| 16423 | } | 17455 | } |
| 16424 | | 17456 | |
| 16425 | ZigType *child_type = array_type->data.array.child_type; | 17457 | ZigType *child_type = array_type->data.array.child_type; |
| 16426 | ZigType *result_array_type = get_array_type(ira->codegen, child_type, new_array_len, | 17458 | ZigType *result_array_type = get_array_type(ira->codegen, child_type, new_array_len, |
| 16427 | array_type->data.array.sentinel); | 17459 | array_type->data.array.sentinel); |
| 16428 | | 17460 | |
| 16429 | IrInstruction *array_result; | 17461 | IrInstGen *array_result; |
| 16430 | if (array_val->special == ConstValSpecialUndef || array_val->data.x_array.special == ConstArraySpecialUndef) { | 17462 | if (array_val->special == ConstValSpecialUndef || array_val->data.x_array.special == ConstArraySpecialUndef) { |
| 16431 | array_result = ir_const_undef(ira, &instruction->base, result_array_type); | 17463 | array_result = ir_const_undef(ira, &instruction->base.base, result_array_type); |
| 16432 | } else { | 17464 | } else { |
| 16433 | array_result = ir_const(ira, &instruction->base, result_array_type); | 17465 | array_result = ir_const(ira, &instruction->base.base, result_array_type); |
| 16434 | ZigValue *out_val = array_result->value; | 17466 | ZigValue *out_val = array_result->value; |
| 16435 | | 17467 | |
| 16436 | switch (type_has_one_possible_value(ira->codegen, result_array_type)) { | 17468 | switch (type_has_one_possible_value(ira->codegen, result_array_type)) { |
| 16437 | case OnePossibleValueInvalid: | 17469 | case OnePossibleValueInvalid: |
| 16438 | return ira->codegen->invalid_instruction; | 17470 | return ira->codegen->invalid_inst_gen; |
| 16439 | case OnePossibleValueYes: | 17471 | case OnePossibleValueYes: |
| 16440 | goto skip_computation; | 17472 | goto skip_computation; |
| 16441 | case OnePossibleValueNo: | 17473 | case OnePossibleValueNo: |
| ... | @@ -16471,35 +17503,35 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -16471,35 +17503,35 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * |
| 16471 | } | 17503 | } |
| 16472 | skip_computation: | 17504 | skip_computation: |
| 16473 | if (want_ptr_to_array) { | 17505 | if (want_ptr_to_array) { |
| 16474 | return ir_get_ref(ira, &instruction->base, array_result, true, false); | 17506 | return ir_get_ref(ira, &instruction->base.base, array_result, true, false); |
| 16475 | } else { | 17507 | } else { |
| 16476 | return array_result; | 17508 | return array_result; |
| 16477 | } | 17509 | } |
| 16478 | } | 17510 | } |
| 16479 | | 17511 | |
| 16480 | static IrInstruction *ir_analyze_instruction_merge_err_sets(IrAnalyze *ira, | 17512 | static IrInstGen *ir_analyze_instruction_merge_err_sets(IrAnalyze *ira, |
| 16481 | IrInstructionMergeErrSets *instruction) | 17513 | IrInstSrcMergeErrSets *instruction) |
| 16482 | { | 17514 | { |
| 16483 | ZigType *op1_type = ir_resolve_error_set_type(ira, &instruction->base, instruction->op1->child); | 17515 | ZigType *op1_type = ir_resolve_error_set_type(ira, &instruction->base.base, instruction->op1->child); |
| 16484 | if (type_is_invalid(op1_type)) | 17516 | if (type_is_invalid(op1_type)) |
| 16485 | return ira->codegen->invalid_instruction; | 17517 | return ira->codegen->invalid_inst_gen; |
| 16486 | | 17518 | |
| 16487 | ZigType *op2_type = ir_resolve_error_set_type(ira, &instruction->base, instruction->op2->child); | 17519 | ZigType *op2_type = ir_resolve_error_set_type(ira, &instruction->base.base, instruction->op2->child); |
| 16488 | if (type_is_invalid(op2_type)) | 17520 | if (type_is_invalid(op2_type)) |
| 16489 | return ira->codegen->invalid_instruction; | 17521 | return ira->codegen->invalid_inst_gen; |
| 16490 | | 17522 | |
| 16491 | if (type_is_global_error_set(op1_type) || | 17523 | if (type_is_global_error_set(op1_type) || |
| 16492 | type_is_global_error_set(op2_type)) | 17524 | type_is_global_error_set(op2_type)) |
| 16493 | { | 17525 | { |
| 16494 | return ir_const_type(ira, &instruction->base, ira->codegen->builtin_types.entry_global_error_set); | 17526 | return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_global_error_set); |
| 16495 | } | 17527 | } |
| 16496 | | 17528 | |
| 16497 | if (!resolve_inferred_error_set(ira->codegen, op1_type, instruction->op1->child->source_node)) { | 17529 | if (!resolve_inferred_error_set(ira->codegen, op1_type, instruction->op1->child->base.source_node)) { |
| 16498 | return ira->codegen->invalid_instruction; | 17530 | return ira->codegen->invalid_inst_gen; |
| 16499 | } | 17531 | } |
| 16500 | | 17532 | |
| 16501 | if (!resolve_inferred_error_set(ira->codegen, op2_type, instruction->op2->child->source_node)) { | 17533 | if (!resolve_inferred_error_set(ira->codegen, op2_type, instruction->op2->child->base.source_node)) { |
| 16502 | return ira->codegen->invalid_instruction; | 17534 | return ira->codegen->invalid_inst_gen; |
| 16503 | } | 17535 | } |
| 16504 | | 17536 | |
| 16505 | size_t errors_count = ira->codegen->errors_by_index.length; | 17537 | size_t errors_count = ira->codegen->errors_by_index.length; |
| ... | @@ -16512,11 +17544,11 @@ static IrInstruction *ir_analyze_instruction_merge_err_sets(IrAnalyze *ira, | ... | @@ -16512,11 +17544,11 @@ static IrInstruction *ir_analyze_instruction_merge_err_sets(IrAnalyze *ira, |
| 16512 | ZigType *result_type = get_error_set_union(ira->codegen, errors, op1_type, op2_type, instruction->type_name); | 17544 | ZigType *result_type = get_error_set_union(ira->codegen, errors, op1_type, op2_type, instruction->type_name); |
| 16513 | deallocate(errors, errors_count, "ErrorTableEntry *"); | 17545 | deallocate(errors, errors_count, "ErrorTableEntry *"); |
| 16514 | | 17546 | |
| 16515 | return ir_const_type(ira, &instruction->base, result_type); | 17547 | return ir_const_type(ira, &instruction->base.base, result_type); |
| 16516 | } | 17548 | } |
| 16517 | | 17549 | |
| 16518 | | 17550 | |
| 16519 | static IrInstruction *ir_analyze_instruction_bin_op(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { | 17551 | static IrInstGen *ir_analyze_instruction_bin_op(IrAnalyze *ira, IrInstSrcBinOp *bin_op_instruction) { |
| 16520 | IrBinOp op_id = bin_op_instruction->op_id; | 17552 | IrBinOp op_id = bin_op_instruction->op_id; |
| 16521 | switch (op_id) { | 17553 | switch (op_id) { |
| 16522 | case IrBinOpInvalid: | 17554 | case IrBinOpInvalid: |
| ... | @@ -16561,41 +17593,39 @@ static IrInstruction *ir_analyze_instruction_bin_op(IrAnalyze *ira, IrInstructio | ... | @@ -16561,41 +17593,39 @@ static IrInstruction *ir_analyze_instruction_bin_op(IrAnalyze *ira, IrInstructio |
| 16561 | zig_unreachable(); | 17593 | zig_unreachable(); |
| 16562 | } | 17594 | } |
| 16563 | | 17595 | |
| 16564 | static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | 17596 | static IrInstGen *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstSrcDeclVar *decl_var_instruction) { |
| 16565 | IrInstructionDeclVarSrc *decl_var_instruction) | | |
| 16566 | { | | |
| 16567 | Error err; | 17597 | Error err; |
| 16568 | ZigVar *var = decl_var_instruction->var; | 17598 | ZigVar *var = decl_var_instruction->var; |
| 16569 | | 17599 | |
| 16570 | ZigType *explicit_type = nullptr; | 17600 | ZigType *explicit_type = nullptr; |
| 16571 | IrInstruction *var_type = nullptr; | 17601 | IrInstGen *var_type = nullptr; |
| 16572 | if (decl_var_instruction->var_type != nullptr) { | 17602 | if (decl_var_instruction->var_type != nullptr) { |
| 16573 | var_type = decl_var_instruction->var_type->child; | 17603 | var_type = decl_var_instruction->var_type->child; |
| 16574 | ZigType *proposed_type = ir_resolve_type(ira, var_type); | 17604 | ZigType *proposed_type = ir_resolve_type(ira, var_type); |
| 16575 | explicit_type = validate_var_type(ira->codegen, var_type->source_node, proposed_type); | 17605 | explicit_type = validate_var_type(ira->codegen, var_type->base.source_node, proposed_type); |
| 16576 | if (type_is_invalid(explicit_type)) { | 17606 | if (type_is_invalid(explicit_type)) { |
| 16577 | var->var_type = ira->codegen->builtin_types.entry_invalid; | 17607 | var->var_type = ira->codegen->builtin_types.entry_invalid; |
| 16578 | return ira->codegen->invalid_instruction; | 17608 | return ira->codegen->invalid_inst_gen; |
| 16579 | } | 17609 | } |
| 16580 | } | 17610 | } |
| 16581 | | 17611 | |
| 16582 | AstNode *source_node = decl_var_instruction->base.source_node; | 17612 | AstNode *source_node = decl_var_instruction->base.base.source_node; |
| 16583 | | 17613 | |
| 16584 | bool is_comptime_var = ir_get_var_is_comptime(var); | 17614 | bool is_comptime_var = ir_get_var_is_comptime(var); |
| 16585 | | 17615 | |
| 16586 | bool var_class_requires_const = false; | 17616 | bool var_class_requires_const = false; |
| 16587 | | 17617 | |
| 16588 | IrInstruction *var_ptr = decl_var_instruction->ptr->child; | 17618 | IrInstGen *var_ptr = decl_var_instruction->ptr->child; |
| 16589 | // if this is null, a compiler error happened and did not initialize the variable. | 17619 | // if this is null, a compiler error happened and did not initialize the variable. |
| 16590 | // if there are no compile errors there may be a missing ir_expr_wrap in pass1 IR generation. | 17620 | // if there are no compile errors there may be a missing ir_expr_wrap in pass1 IR generation. |
| 16591 | if (var_ptr == nullptr || type_is_invalid(var_ptr->value->type)) { | 17621 | if (var_ptr == nullptr || type_is_invalid(var_ptr->value->type)) { |
| 16592 | ir_assert(var_ptr != nullptr || ira->codegen->errors.length != 0, &decl_var_instruction->base); | 17622 | ir_assert(var_ptr != nullptr || ira->codegen->errors.length != 0, &decl_var_instruction->base.base); |
| 16593 | var->var_type = ira->codegen->builtin_types.entry_invalid; | 17623 | var->var_type = ira->codegen->builtin_types.entry_invalid; |
| 16594 | return ira->codegen->invalid_instruction; | 17624 | return ira->codegen->invalid_inst_gen; |
| 16595 | } | 17625 | } |
| 16596 | | 17626 | |
| 16597 | // The ir_build_var_decl_src call is supposed to pass a pointer to the allocation, not an initialization value. | 17627 | // The ir_build_var_decl_src call is supposed to pass a pointer to the allocation, not an initialization value. |
| 16598 | ir_assert(var_ptr->value->type->id == ZigTypeIdPointer, &decl_var_instruction->base); | 17628 | ir_assert(var_ptr->value->type->id == ZigTypeIdPointer, &decl_var_instruction->base.base); |
| 16599 | | 17629 | |
| 16600 | ZigType *result_type = var_ptr->value->type->data.pointer.child_type; | 17630 | ZigType *result_type = var_ptr->value->type->data.pointer.child_type; |
| 16601 | if (type_is_invalid(result_type)) { | 17631 | if (type_is_invalid(result_type)) { |
| ... | @@ -16606,7 +17636,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -16606,7 +17636,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 16606 | | 17636 | |
| 16607 | ZigValue *init_val = nullptr; | 17637 | ZigValue *init_val = nullptr; |
| 16608 | if (instr_is_comptime(var_ptr) && var_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 17638 | if (instr_is_comptime(var_ptr) && var_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 16609 | init_val = const_ptr_pointee(ira, ira->codegen, var_ptr->value, decl_var_instruction->base.source_node); | 17639 | init_val = const_ptr_pointee(ira, ira->codegen, var_ptr->value, decl_var_instruction->base.base.source_node); |
| 16610 | if (is_comptime_var) { | 17640 | if (is_comptime_var) { |
| 16611 | if (var->gen_is_const) { | 17641 | if (var->gen_is_const) { |
| 16612 | var->const_value = init_val; | 17642 | var->const_value = init_val; |
| ... | @@ -16633,7 +17663,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -16633,7 +17663,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 16633 | case ReqCompTimeNo: | 17663 | case ReqCompTimeNo: |
| 16634 | if (init_val != nullptr && value_is_comptime(init_val)) { | 17664 | if (init_val != nullptr && value_is_comptime(init_val)) { |
| 16635 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, | 17665 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, |
| 16636 | decl_var_instruction->base.source_node, init_val, UndefOk))) | 17666 | decl_var_instruction->base.base.source_node, init_val, UndefOk))) |
| 16637 | { | 17667 | { |
| 16638 | result_type = ira->codegen->builtin_types.entry_invalid; | 17668 | result_type = ira->codegen->builtin_types.entry_invalid; |
| 16639 | } else if (init_val->type->id == ZigTypeIdFn && | 17669 | } else if (init_val->type->id == ZigTypeIdFn && |
| ... | @@ -16666,13 +17696,13 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -16666,13 +17696,13 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 16666 | assert(var->var_type); | 17696 | assert(var->var_type); |
| 16667 | | 17697 | |
| 16668 | if (type_is_invalid(result_type)) { | 17698 | if (type_is_invalid(result_type)) { |
| 16669 | return ir_const_void(ira, &decl_var_instruction->base); | 17699 | return ir_const_void(ira, &decl_var_instruction->base.base); |
| 16670 | } | 17700 | } |
| 16671 | | 17701 | |
| 16672 | if (decl_var_instruction->align_value == nullptr) { | 17702 | if (decl_var_instruction->align_value == nullptr) { |
| 16673 | if ((err = type_resolve(ira->codegen, result_type, ResolveStatusAlignmentKnown))) { | 17703 | if ((err = type_resolve(ira->codegen, result_type, ResolveStatusAlignmentKnown))) { |
| 16674 | var->var_type = ira->codegen->builtin_types.entry_invalid; | 17704 | var->var_type = ira->codegen->builtin_types.entry_invalid; |
| 16675 | return ir_const_void(ira, &decl_var_instruction->base); | 17705 | return ir_const_void(ira, &decl_var_instruction->base.base); |
| 16676 | } | 17706 | } |
| 16677 | var->align_bytes = get_abi_alignment(ira->codegen, result_type); | 17707 | var->align_bytes = get_abi_alignment(ira->codegen, result_type); |
| 16678 | } else { | 17708 | } else { |
| ... | @@ -16691,98 +17721,96 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -16691,98 +17721,96 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 16691 | // we need a runtime ptr but we have a comptime val. | 17721 | // we need a runtime ptr but we have a comptime val. |
| 16692 | // since it's a comptime val there are no instructions for it. | 17722 | // since it's a comptime val there are no instructions for it. |
| 16693 | // we memcpy the init value here | 17723 | // we memcpy the init value here |
| 16694 | IrInstruction *deref = ir_get_deref(ira, var_ptr, var_ptr, nullptr); | 17724 | IrInstGen *deref = ir_get_deref(ira, &var_ptr->base, var_ptr, nullptr); |
| 16695 | if (type_is_invalid(deref->value->type)) { | 17725 | if (type_is_invalid(deref->value->type)) { |
| 16696 | var->var_type = ira->codegen->builtin_types.entry_invalid; | 17726 | var->var_type = ira->codegen->builtin_types.entry_invalid; |
| 16697 | return ira->codegen->invalid_instruction; | 17727 | return ira->codegen->invalid_inst_gen; |
| 16698 | } | 17728 | } |
| 16699 | // If this assertion trips, something is wrong with the IR instructions, because | 17729 | // If this assertion trips, something is wrong with the IR instructions, because |
| 16700 | // we expected the above deref to return a constant value, but it created a runtime | 17730 | // we expected the above deref to return a constant value, but it created a runtime |
| 16701 | // instruction. | 17731 | // instruction. |
| 16702 | assert(deref->value->special != ConstValSpecialRuntime); | 17732 | assert(deref->value->special != ConstValSpecialRuntime); |
| 16703 | var_ptr->value->special = ConstValSpecialRuntime; | 17733 | var_ptr->value->special = ConstValSpecialRuntime; |
| 16704 | ir_analyze_store_ptr(ira, var_ptr, var_ptr, deref, false); | 17734 | ir_analyze_store_ptr(ira, &var_ptr->base, var_ptr, deref, false); |
| 16705 | } | 17735 | } |
| 16706 | if (instr_is_comptime(var_ptr) && | 17736 | if (instr_is_comptime(var_ptr) && (is_comptime_var || (var_class_requires_const && var->gen_is_const))) { |
| 16707 | (is_comptime_var || (var_class_requires_const && var->gen_is_const))) | 17737 | return ir_const_void(ira, &decl_var_instruction->base.base); |
| 16708 | { | | |
| 16709 | return ir_const_void(ira, &decl_var_instruction->base); | | |
| 16710 | } | 17738 | } |
| 16711 | } else if (is_comptime_var) { | 17739 | } else if (is_comptime_var) { |
| 16712 | ir_add_error(ira, &decl_var_instruction->base, | 17740 | ir_add_error(ira, &decl_var_instruction->base.base, |
| 16713 | buf_sprintf("cannot store runtime value in compile time variable")); | 17741 | buf_sprintf("cannot store runtime value in compile time variable")); |
| 16714 | var->var_type = ira->codegen->builtin_types.entry_invalid; | 17742 | var->var_type = ira->codegen->builtin_types.entry_invalid; |
| 16715 | return ira->codegen->invalid_instruction; | 17743 | return ira->codegen->invalid_inst_gen; |
| 16716 | } | 17744 | } |
| 16717 | | 17745 | |
| 16718 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 17746 | ZigFn *fn_entry = ira->new_irb.exec->fn_entry; |
| 16719 | if (fn_entry) | 17747 | if (fn_entry) |
| 16720 | fn_entry->variable_list.append(var); | 17748 | fn_entry->variable_list.append(var); |
| 16721 | | 17749 | |
| 16722 | return ir_build_var_decl_gen(ira, &decl_var_instruction->base, var, var_ptr); | 17750 | return ir_build_var_decl_gen(ira, &decl_var_instruction->base.base, var, var_ptr); |
| 16723 | } | 17751 | } |
| 16724 | | 17752 | |
| 16725 | static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExport *instruction) { | 17753 | static IrInstGen *ir_analyze_instruction_export(IrAnalyze *ira, IrInstSrcExport *instruction) { |
| 16726 | IrInstruction *target = instruction->target->child; | 17754 | IrInstGen *target = instruction->target->child; |
| 16727 | if (type_is_invalid(target->value->type)) | 17755 | if (type_is_invalid(target->value->type)) |
| 16728 | return ira->codegen->invalid_instruction; | 17756 | return ira->codegen->invalid_inst_gen; |
| 16729 | | 17757 | |
| 16730 | IrInstruction *options = instruction->options->child; | 17758 | IrInstGen *options = instruction->options->child; |
| 16731 | if (type_is_invalid(options->value->type)) | 17759 | if (type_is_invalid(options->value->type)) |
| 16732 | return ira->codegen->invalid_instruction; | 17760 | return ira->codegen->invalid_inst_gen; |
| 16733 | | 17761 | |
| 16734 | ZigType *options_type = options->value->type; | 17762 | ZigType *options_type = options->value->type; |
| 16735 | assert(options_type->id == ZigTypeIdStruct); | 17763 | assert(options_type->id == ZigTypeIdStruct); |
| 16736 | | 17764 | |
| 16737 | TypeStructField *name_field = find_struct_type_field(options_type, buf_create_from_str("name")); | 17765 | TypeStructField *name_field = find_struct_type_field(options_type, buf_create_from_str("name")); |
| 16738 | ir_assert(name_field != nullptr, &instruction->base); | 17766 | ir_assert(name_field != nullptr, &instruction->base.base); |
| 16739 | IrInstruction *name_inst = ir_analyze_struct_value_field_value(ira, &instruction->base, options, name_field); | 17767 | IrInstGen *name_inst = ir_analyze_struct_value_field_value(ira, &instruction->base.base, options, name_field); |
| 16740 | if (type_is_invalid(name_inst->value->type)) | 17768 | if (type_is_invalid(name_inst->value->type)) |
| 16741 | return ira->codegen->invalid_instruction; | 17769 | return ira->codegen->invalid_inst_gen; |
| 16742 | | 17770 | |
| 16743 | TypeStructField *linkage_field = find_struct_type_field(options_type, buf_create_from_str("linkage")); | 17771 | TypeStructField *linkage_field = find_struct_type_field(options_type, buf_create_from_str("linkage")); |
| 16744 | ir_assert(linkage_field != nullptr, &instruction->base); | 17772 | ir_assert(linkage_field != nullptr, &instruction->base.base); |
| 16745 | IrInstruction *linkage_inst = ir_analyze_struct_value_field_value(ira, &instruction->base, options, linkage_field); | 17773 | IrInstGen *linkage_inst = ir_analyze_struct_value_field_value(ira, &instruction->base.base, options, linkage_field); |
| 16746 | if (type_is_invalid(linkage_inst->value->type)) | 17774 | if (type_is_invalid(linkage_inst->value->type)) |
| 16747 | return ira->codegen->invalid_instruction; | 17775 | return ira->codegen->invalid_inst_gen; |
| 16748 | | 17776 | |
| 16749 | TypeStructField *section_field = find_struct_type_field(options_type, buf_create_from_str("section")); | 17777 | TypeStructField *section_field = find_struct_type_field(options_type, buf_create_from_str("section")); |
| 16750 | ir_assert(section_field != nullptr, &instruction->base); | 17778 | ir_assert(section_field != nullptr, &instruction->base.base); |
| 16751 | IrInstruction *section_inst = ir_analyze_struct_value_field_value(ira, &instruction->base, options, section_field); | 17779 | IrInstGen *section_inst = ir_analyze_struct_value_field_value(ira, &instruction->base.base, options, section_field); |
| 16752 | if (type_is_invalid(section_inst->value->type)) | 17780 | if (type_is_invalid(section_inst->value->type)) |
| 16753 | return ira->codegen->invalid_instruction; | 17781 | return ira->codegen->invalid_inst_gen; |
| 16754 | | 17782 | |
| 16755 | // The `section` field is optional, we have to unwrap it first | 17783 | // The `section` field is optional, we have to unwrap it first |
| 16756 | IrInstruction *non_null_check = ir_analyze_test_non_null(ira, &instruction->base, section_inst); | 17784 | IrInstGen *non_null_check = ir_analyze_test_non_null(ira, &instruction->base.base, section_inst); |
| 16757 | bool is_non_null; | 17785 | bool is_non_null; |
| 16758 | if (!ir_resolve_bool(ira, non_null_check, &is_non_null)) | 17786 | if (!ir_resolve_bool(ira, non_null_check, &is_non_null)) |
| 16759 | return ira->codegen->invalid_instruction; | 17787 | return ira->codegen->invalid_inst_gen; |
| 16760 | | 17788 | |
| 16761 | IrInstruction *section_str_inst = nullptr; | 17789 | IrInstGen *section_str_inst = nullptr; |
| 16762 | if (is_non_null) { | 17790 | if (is_non_null) { |
| 16763 | section_str_inst = ir_analyze_optional_value_payload_value(ira, &instruction->base, section_inst, false); | 17791 | section_str_inst = ir_analyze_optional_value_payload_value(ira, &instruction->base.base, section_inst, false); |
| 16764 | if (type_is_invalid(section_str_inst->value->type)) | 17792 | if (type_is_invalid(section_str_inst->value->type)) |
| 16765 | return ira->codegen->invalid_instruction; | 17793 | return ira->codegen->invalid_inst_gen; |
| 16766 | } | 17794 | } |
| 16767 | | 17795 | |
| 16768 | // Resolve all the comptime values | 17796 | // Resolve all the comptime values |
| 16769 | Buf *symbol_name = ir_resolve_str(ira, name_inst); | 17797 | Buf *symbol_name = ir_resolve_str(ira, name_inst); |
| 16770 | if (!symbol_name) | 17798 | if (!symbol_name) |
| 16771 | return ira->codegen->invalid_instruction; | 17799 | return ira->codegen->invalid_inst_gen; |
| 16772 | | 17800 | |
| 16773 | if (buf_len(symbol_name) < 1) { | 17801 | if (buf_len(symbol_name) < 1) { |
| 16774 | ir_add_error(ira, name_inst, | 17802 | ir_add_error(ira, &name_inst->base, |
| 16775 | buf_sprintf("exported symbol name cannot be empty")); | 17803 | buf_sprintf("exported symbol name cannot be empty")); |
| 16776 | return ira->codegen->invalid_instruction; | 17804 | return ira->codegen->invalid_inst_gen; |
| 16777 | } | 17805 | } |
| 16778 | | 17806 | |
| 16779 | GlobalLinkageId global_linkage_id; | 17807 | GlobalLinkageId global_linkage_id; |
| 16780 | if (!ir_resolve_global_linkage(ira, linkage_inst, &global_linkage_id)) | 17808 | if (!ir_resolve_global_linkage(ira, linkage_inst, &global_linkage_id)) |
| 16781 | return ira->codegen->invalid_instruction; | 17809 | return ira->codegen->invalid_inst_gen; |
| 16782 | | 17810 | |
| 16783 | Buf *section_name = nullptr; | 17811 | Buf *section_name = nullptr; |
| 16784 | if (section_str_inst != nullptr && !(section_name = ir_resolve_str(ira, section_str_inst))) | 17812 | if (section_str_inst != nullptr && !(section_name = ir_resolve_str(ira, section_str_inst))) |
| 16785 | return ira->codegen->invalid_instruction; | 17813 | return ira->codegen->invalid_inst_gen; |
| 16786 | | 17814 | |
| 16787 | // TODO: This function needs to be audited. | 17815 | // TODO: This function needs to be audited. |
| 16788 | // It's not clear how all the different types are supposed to be handled. | 17816 | // It's not clear how all the different types are supposed to be handled. |
| ... | @@ -16790,15 +17818,15 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16790,15 +17818,15 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16790 | // in another file. | 17818 | // in another file. |
| 16791 | TldFn *tld_fn = allocate<TldFn>(1); | 17819 | TldFn *tld_fn = allocate<TldFn>(1); |
| 16792 | tld_fn->base.id = TldIdFn; | 17820 | tld_fn->base.id = TldIdFn; |
| 16793 | tld_fn->base.source_node = instruction->base.source_node; | 17821 | tld_fn->base.source_node = instruction->base.base.source_node; |
| 16794 | | 17822 | |
| 16795 | auto entry = ira->codegen->exported_symbol_names.put_unique(symbol_name, &tld_fn->base); | 17823 | auto entry = ira->codegen->exported_symbol_names.put_unique(symbol_name, &tld_fn->base); |
| 16796 | if (entry) { | 17824 | if (entry) { |
| 16797 | AstNode *other_export_node = entry->value->source_node; | 17825 | AstNode *other_export_node = entry->value->source_node; |
| 16798 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, | 17826 | ErrorMsg *msg = ir_add_error(ira, &instruction->base.base, |
| 16799 | buf_sprintf("exported symbol collision: '%s'", buf_ptr(symbol_name))); | 17827 | buf_sprintf("exported symbol collision: '%s'", buf_ptr(symbol_name))); |
| 16800 | add_error_note(ira->codegen, msg, other_export_node, buf_sprintf("other symbol is here")); | 17828 | add_error_note(ira->codegen, msg, other_export_node, buf_sprintf("other symbol is here")); |
| 16801 | return ira->codegen->invalid_instruction; | 17829 | return ira->codegen->invalid_inst_gen; |
| 16802 | } | 17830 | } |
| 16803 | | 17831 | |
| 16804 | Error err; | 17832 | Error err; |
| ... | @@ -16814,12 +17842,12 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16814,12 +17842,12 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16814 | CallingConvention cc = fn_entry->type_entry->data.fn.fn_type_id.cc; | 17842 | CallingConvention cc = fn_entry->type_entry->data.fn.fn_type_id.cc; |
| 16815 | switch (cc) { | 17843 | switch (cc) { |
| 16816 | case CallingConventionUnspecified: { | 17844 | case CallingConventionUnspecified: { |
| 16817 | ErrorMsg *msg = ir_add_error(ira, target, | 17845 | ErrorMsg *msg = ir_add_error(ira, &target->base, |
| 16818 | buf_sprintf("exported function must specify calling convention")); | 17846 | buf_sprintf("exported function must specify calling convention")); |
| 16819 | add_error_note(ira->codegen, msg, fn_entry->proto_node, buf_sprintf("declared here")); | 17847 | add_error_note(ira->codegen, msg, fn_entry->proto_node, buf_sprintf("declared here")); |
| 16820 | } break; | 17848 | } break; |
| 16821 | case CallingConventionAsync: { | 17849 | case CallingConventionAsync: { |
| 16822 | ErrorMsg *msg = ir_add_error(ira, target, | 17850 | ErrorMsg *msg = ir_add_error(ira, &target->base, |
| 16823 | buf_sprintf("exported function cannot be async")); | 17851 | buf_sprintf("exported function cannot be async")); |
| 16824 | add_error_note(ira->codegen, msg, fn_entry->proto_node, buf_sprintf("declared here")); | 17852 | add_error_note(ira->codegen, msg, fn_entry->proto_node, buf_sprintf("declared here")); |
| 16825 | } break; | 17853 | } break; |
| ... | @@ -16842,10 +17870,10 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16842,10 +17870,10 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16842 | } break; | 17870 | } break; |
| 16843 | case ZigTypeIdStruct: | 17871 | case ZigTypeIdStruct: |
| 16844 | if (is_slice(target->value->type)) { | 17872 | if (is_slice(target->value->type)) { |
| 16845 | ir_add_error(ira, target, | 17873 | ir_add_error(ira, &target->base, |
| 16846 | buf_sprintf("unable to export value of type '%s'", buf_ptr(&target->value->type->name))); | 17874 | buf_sprintf("unable to export value of type '%s'", buf_ptr(&target->value->type->name))); |
| 16847 | } else if (target->value->type->data.structure.layout != ContainerLayoutExtern) { | 17875 | } else if (target->value->type->data.structure.layout != ContainerLayoutExtern) { |
| 16848 | ErrorMsg *msg = ir_add_error(ira, target, | 17876 | ErrorMsg *msg = ir_add_error(ira, &target->base, |
| 16849 | buf_sprintf("exported struct value must be declared extern")); | 17877 | buf_sprintf("exported struct value must be declared extern")); |
| 16850 | add_error_note(ira->codegen, msg, target->value->type->data.structure.decl_node, buf_sprintf("declared here")); | 17878 | add_error_note(ira->codegen, msg, target->value->type->data.structure.decl_node, buf_sprintf("declared here")); |
| 16851 | } else { | 17879 | } else { |
| ... | @@ -16854,7 +17882,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16854,7 +17882,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16854 | break; | 17882 | break; |
| 16855 | case ZigTypeIdUnion: | 17883 | case ZigTypeIdUnion: |
| 16856 | if (target->value->type->data.unionation.layout != ContainerLayoutExtern) { | 17884 | if (target->value->type->data.unionation.layout != ContainerLayoutExtern) { |
| 16857 | ErrorMsg *msg = ir_add_error(ira, target, | 17885 | ErrorMsg *msg = ir_add_error(ira, &target->base, |
| 16858 | buf_sprintf("exported union value must be declared extern")); | 17886 | buf_sprintf("exported union value must be declared extern")); |
| 16859 | add_error_note(ira->codegen, msg, target->value->type->data.unionation.decl_node, buf_sprintf("declared here")); | 17887 | add_error_note(ira->codegen, msg, target->value->type->data.unionation.decl_node, buf_sprintf("declared here")); |
| 16860 | } else { | 17888 | } else { |
| ... | @@ -16863,7 +17891,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16863,7 +17891,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16863 | break; | 17891 | break; |
| 16864 | case ZigTypeIdEnum: | 17892 | case ZigTypeIdEnum: |
| 16865 | if (target->value->type->data.enumeration.layout != ContainerLayoutExtern) { | 17893 | if (target->value->type->data.enumeration.layout != ContainerLayoutExtern) { |
| 16866 | ErrorMsg *msg = ir_add_error(ira, target, | 17894 | ErrorMsg *msg = ir_add_error(ira, &target->base, |
| 16867 | buf_sprintf("exported enum value must be declared extern")); | 17895 | buf_sprintf("exported enum value must be declared extern")); |
| 16868 | add_error_note(ira->codegen, msg, target->value->type->data.enumeration.decl_node, buf_sprintf("declared here")); | 17896 | add_error_note(ira->codegen, msg, target->value->type->data.enumeration.decl_node, buf_sprintf("declared here")); |
| 16869 | } else { | 17897 | } else { |
| ... | @@ -16873,10 +17901,10 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16873,10 +17901,10 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16873 | case ZigTypeIdArray: { | 17901 | case ZigTypeIdArray: { |
| 16874 | bool ok_type; | 17902 | bool ok_type; |
| 16875 | if ((err = type_allowed_in_extern(ira->codegen, target->value->type->data.array.child_type, &ok_type))) | 17903 | if ((err = type_allowed_in_extern(ira->codegen, target->value->type->data.array.child_type, &ok_type))) |
| 16876 | return ira->codegen->invalid_instruction; | 17904 | return ira->codegen->invalid_inst_gen; |
| 16877 | | 17905 | |
| 16878 | if (!ok_type) { | 17906 | if (!ok_type) { |
| 16879 | ir_add_error(ira, target, | 17907 | ir_add_error(ira, &target->base, |
| 16880 | buf_sprintf("array element type '%s' not extern-compatible", | 17908 | buf_sprintf("array element type '%s' not extern-compatible", |
| 16881 | buf_ptr(&target->value->type->data.array.child_type->name))); | 17909 | buf_ptr(&target->value->type->data.array.child_type->name))); |
| 16882 | } else { | 17910 | } else { |
| ... | @@ -16891,31 +17919,31 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16891,31 +17919,31 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16891 | zig_unreachable(); | 17919 | zig_unreachable(); |
| 16892 | case ZigTypeIdStruct: | 17920 | case ZigTypeIdStruct: |
| 16893 | if (is_slice(type_value)) { | 17921 | if (is_slice(type_value)) { |
| 16894 | ir_add_error(ira, target, | 17922 | ir_add_error(ira, &target->base, |
| 16895 | buf_sprintf("unable to export type '%s'", buf_ptr(&type_value->name))); | 17923 | buf_sprintf("unable to export type '%s'", buf_ptr(&type_value->name))); |
| 16896 | } else if (type_value->data.structure.layout != ContainerLayoutExtern) { | 17924 | } else if (type_value->data.structure.layout != ContainerLayoutExtern) { |
| 16897 | ErrorMsg *msg = ir_add_error(ira, target, | 17925 | ErrorMsg *msg = ir_add_error(ira, &target->base, |
| 16898 | buf_sprintf("exported struct must be declared extern")); | 17926 | buf_sprintf("exported struct must be declared extern")); |
| 16899 | add_error_note(ira->codegen, msg, type_value->data.structure.decl_node, buf_sprintf("declared here")); | 17927 | add_error_note(ira->codegen, msg, type_value->data.structure.decl_node, buf_sprintf("declared here")); |
| 16900 | } | 17928 | } |
| 16901 | break; | 17929 | break; |
| 16902 | case ZigTypeIdUnion: | 17930 | case ZigTypeIdUnion: |
| 16903 | if (type_value->data.unionation.layout != ContainerLayoutExtern) { | 17931 | if (type_value->data.unionation.layout != ContainerLayoutExtern) { |
| 16904 | ErrorMsg *msg = ir_add_error(ira, target, | 17932 | ErrorMsg *msg = ir_add_error(ira, &target->base, |
| 16905 | buf_sprintf("exported union must be declared extern")); | 17933 | buf_sprintf("exported union must be declared extern")); |
| 16906 | add_error_note(ira->codegen, msg, type_value->data.unionation.decl_node, buf_sprintf("declared here")); | 17934 | add_error_note(ira->codegen, msg, type_value->data.unionation.decl_node, buf_sprintf("declared here")); |
| 16907 | } | 17935 | } |
| 16908 | break; | 17936 | break; |
| 16909 | case ZigTypeIdEnum: | 17937 | case ZigTypeIdEnum: |
| 16910 | if (type_value->data.enumeration.layout != ContainerLayoutExtern) { | 17938 | if (type_value->data.enumeration.layout != ContainerLayoutExtern) { |
| 16911 | ErrorMsg *msg = ir_add_error(ira, target, | 17939 | ErrorMsg *msg = ir_add_error(ira, &target->base, |
| 16912 | buf_sprintf("exported enum must be declared extern")); | 17940 | buf_sprintf("exported enum must be declared extern")); |
| 16913 | add_error_note(ira->codegen, msg, type_value->data.enumeration.decl_node, buf_sprintf("declared here")); | 17941 | add_error_note(ira->codegen, msg, type_value->data.enumeration.decl_node, buf_sprintf("declared here")); |
| 16914 | } | 17942 | } |
| 16915 | break; | 17943 | break; |
| 16916 | case ZigTypeIdFn: { | 17944 | case ZigTypeIdFn: { |
| 16917 | if (type_value->data.fn.fn_type_id.cc == CallingConventionUnspecified) { | 17945 | if (type_value->data.fn.fn_type_id.cc == CallingConventionUnspecified) { |
| 16918 | ir_add_error(ira, target, | 17946 | ir_add_error(ira, &target->base, |
| 16919 | buf_sprintf("exported function type must specify calling convention")); | 17947 | buf_sprintf("exported function type must specify calling convention")); |
| 16920 | } | 17948 | } |
| 16921 | } break; | 17949 | } break; |
| ... | @@ -16941,7 +17969,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16941,7 +17969,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16941 | case ZigTypeIdOpaque: | 17969 | case ZigTypeIdOpaque: |
| 16942 | case ZigTypeIdFnFrame: | 17970 | case ZigTypeIdFnFrame: |
| 16943 | case ZigTypeIdAnyFrame: | 17971 | case ZigTypeIdAnyFrame: |
| 16944 | ir_add_error(ira, target, | 17972 | ir_add_error(ira, &target->base, |
| 16945 | buf_sprintf("invalid export target '%s'", buf_ptr(&type_value->name))); | 17973 | buf_sprintf("invalid export target '%s'", buf_ptr(&type_value->name))); |
| 16946 | break; | 17974 | break; |
| 16947 | } | 17975 | } |
| ... | @@ -16966,61 +17994,55 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16966,61 +17994,55 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16966 | case ZigTypeIdEnumLiteral: | 17994 | case ZigTypeIdEnumLiteral: |
| 16967 | case ZigTypeIdFnFrame: | 17995 | case ZigTypeIdFnFrame: |
| 16968 | case ZigTypeIdAnyFrame: | 17996 | case ZigTypeIdAnyFrame: |
| 16969 | ir_add_error(ira, target, | 17997 | ir_add_error(ira, &target->base, |
| 16970 | buf_sprintf("invalid export target type '%s'", buf_ptr(&target->value->type->name))); | 17998 | buf_sprintf("invalid export target type '%s'", buf_ptr(&target->value->type->name))); |
| 16971 | break; | 17999 | break; |
| 16972 | } | 18000 | } |
| 16973 | | 18001 | |
| 16974 | // TODO audit the various ways to use @export | 18002 | // TODO audit the various ways to use @export |
| 16975 | if (want_var_export && target->id == IrInstructionIdLoadPtrGen) { | 18003 | if (want_var_export && target->id == IrInstGenIdLoadPtr) { |
| 16976 | IrInstructionLoadPtrGen *load_ptr = reinterpret_cast<IrInstructionLoadPtrGen *>(target); | 18004 | IrInstGenLoadPtr *load_ptr = reinterpret_cast<IrInstGenLoadPtr *>(target); |
| 16977 | if (load_ptr->ptr->id == IrInstructionIdVarPtr) { | 18005 | if (load_ptr->ptr->id == IrInstGenIdVarPtr) { |
| 16978 | IrInstructionVarPtr *var_ptr = reinterpret_cast<IrInstructionVarPtr *>(load_ptr->ptr); | 18006 | IrInstGenVarPtr *var_ptr = reinterpret_cast<IrInstGenVarPtr *>(load_ptr->ptr); |
| 16979 | ZigVar *var = var_ptr->var; | 18007 | ZigVar *var = var_ptr->var; |
| 16980 | add_var_export(ira->codegen, var, buf_ptr(symbol_name), global_linkage_id); | 18008 | add_var_export(ira->codegen, var, buf_ptr(symbol_name), global_linkage_id); |
| 16981 | var->section_name = section_name; | 18009 | var->section_name = section_name; |
| 16982 | } | 18010 | } |
| 16983 | } | 18011 | } |
| 16984 | | 18012 | |
| 16985 | return ir_const_void(ira, &instruction->base); | 18013 | return ir_const_void(ira, &instruction->base.base); |
| 16986 | } | 18014 | } |
| 16987 | | 18015 | |
| 16988 | static bool exec_has_err_ret_trace(CodeGen *g, IrExecutable *exec) { | 18016 | static bool exec_has_err_ret_trace(CodeGen *g, IrExecutableSrc *exec) { |
| 16989 | ZigFn *fn_entry = exec_fn_entry(exec); | 18017 | ZigFn *fn_entry = exec_fn_entry(exec); |
| 16990 | return fn_entry != nullptr && fn_entry->calls_or_awaits_errorable_fn && g->have_err_ret_tracing; | 18018 | return fn_entry != nullptr && fn_entry->calls_or_awaits_errorable_fn && g->have_err_ret_tracing; |
| 16991 | } | 18019 | } |
| 16992 | | 18020 | |
| 16993 | static IrInstruction *ir_analyze_instruction_error_return_trace(IrAnalyze *ira, | 18021 | static IrInstGen *ir_analyze_instruction_error_return_trace(IrAnalyze *ira, |
| 16994 | IrInstructionErrorReturnTrace *instruction) | 18022 | IrInstSrcErrorReturnTrace *instruction) |
| 16995 | { | 18023 | { |
| 16996 | ZigType *ptr_to_stack_trace_type = get_pointer_to_type(ira->codegen, get_stack_trace_type(ira->codegen), false); | 18024 | ZigType *ptr_to_stack_trace_type = get_pointer_to_type(ira->codegen, get_stack_trace_type(ira->codegen), false); |
| 16997 | if (instruction->optional == IrInstructionErrorReturnTrace::Null) { | 18025 | if (instruction->optional == IrInstErrorReturnTraceNull) { |
| 16998 | ZigType *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type); | 18026 | ZigType *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type); |
| 16999 | if (!exec_has_err_ret_trace(ira->codegen, ira->new_irb.exec)) { | 18027 | if (!exec_has_err_ret_trace(ira->codegen, ira->old_irb.exec)) { |
| 17000 | IrInstruction *result = ir_const(ira, &instruction->base, optional_type); | 18028 | IrInstGen *result = ir_const(ira, &instruction->base.base, optional_type); |
| 17001 | ZigValue *out_val = result->value; | 18029 | ZigValue *out_val = result->value; |
| 17002 | assert(get_codegen_ptr_type(optional_type) != nullptr); | 18030 | assert(get_codegen_ptr_type(optional_type) != nullptr); |
| 17003 | out_val->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; | 18031 | out_val->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; |
| 17004 | out_val->data.x_ptr.data.hard_coded_addr.addr = 0; | 18032 | out_val->data.x_ptr.data.hard_coded_addr.addr = 0; |
| 17005 | return result; | 18033 | return result; |
| 17006 | } | 18034 | } |
| 17007 | IrInstruction *new_instruction = ir_build_error_return_trace(&ira->new_irb, instruction->base.scope, | 18035 | return ir_build_error_return_trace_gen(ira, instruction->base.base.scope, |
| 17008 | instruction->base.source_node, instruction->optional); | 18036 | instruction->base.base.source_node, instruction->optional, optional_type); |
| 17009 | new_instruction->value->type = optional_type; | | |
| 17010 | return new_instruction; | | |
| 17011 | } else { | 18037 | } else { |
| 17012 | assert(ira->codegen->have_err_ret_tracing); | 18038 | assert(ira->codegen->have_err_ret_tracing); |
| 17013 | IrInstruction *new_instruction = ir_build_error_return_trace(&ira->new_irb, instruction->base.scope, | 18039 | return ir_build_error_return_trace_gen(ira, instruction->base.base.scope, |
| 17014 | instruction->base.source_node, instruction->optional); | 18040 | instruction->base.base.source_node, instruction->optional, ptr_to_stack_trace_type); |
| 17015 | new_instruction->value->type = ptr_to_stack_trace_type; | | |
| 17016 | return new_instruction; | | |
| 17017 | } | 18041 | } |
| 17018 | } | 18042 | } |
| 17019 | | 18043 | |
| 17020 | static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira, | 18044 | static IrInstGen *ir_analyze_instruction_error_union(IrAnalyze *ira, IrInstSrcErrorUnion *instruction) { |
| 17021 | IrInstructionErrorUnion *instruction) | 18045 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 17022 | { | | |
| 17023 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); | | |
| 17024 | result->value->special = ConstValSpecialLazy; | 18046 | result->value->special = ConstValSpecialLazy; |
| 17025 | | 18047 | |
| 17026 | LazyValueErrUnionType *lazy_err_union_type = allocate<LazyValueErrUnionType>(1, "LazyValueErrUnionType"); | 18048 | LazyValueErrUnionType *lazy_err_union_type = allocate<LazyValueErrUnionType>(1, "LazyValueErrUnionType"); |
| ... | @@ -17030,16 +18052,16 @@ static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira, | ... | @@ -17030,16 +18052,16 @@ static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira, |
| 17030 | | 18052 | |
| 17031 | lazy_err_union_type->err_set_type = instruction->err_set->child; | 18053 | lazy_err_union_type->err_set_type = instruction->err_set->child; |
| 17032 | if (ir_resolve_type_lazy(ira, lazy_err_union_type->err_set_type) == nullptr) | 18054 | if (ir_resolve_type_lazy(ira, lazy_err_union_type->err_set_type) == nullptr) |
| 17033 | return ira->codegen->invalid_instruction; | 18055 | return ira->codegen->invalid_inst_gen; |
| 17034 | | 18056 | |
| 17035 | lazy_err_union_type->payload_type = instruction->payload->child; | 18057 | lazy_err_union_type->payload_type = instruction->payload->child; |
| 17036 | if (ir_resolve_type_lazy(ira, lazy_err_union_type->payload_type) == nullptr) | 18058 | if (ir_resolve_type_lazy(ira, lazy_err_union_type->payload_type) == nullptr) |
| 17037 | return ira->codegen->invalid_instruction; | 18059 | return ira->codegen->invalid_inst_gen; |
| 17038 | | 18060 | |
| 17039 | return result; | 18061 | return result; |
| 17040 | } | 18062 | } |
| 17041 | | 18063 | |
| 17042 | static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_inst, ZigType *var_type, | 18064 | static IrInstGen *ir_analyze_alloca(IrAnalyze *ira, IrInst *source_inst, ZigType *var_type, |
| 17043 | uint32_t align, const char *name_hint, bool force_comptime) | 18065 | uint32_t align, const char *name_hint, bool force_comptime) |
| 17044 | { | 18066 | { |
| 17045 | Error err; | 18067 | Error err; |
| ... | @@ -17048,7 +18070,7 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -17048,7 +18070,7 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in |
| 17048 | pointee->special = ConstValSpecialUndef; | 18070 | pointee->special = ConstValSpecialUndef; |
| 17049 | pointee->llvm_align = align; | 18071 | pointee->llvm_align = align; |
| 17050 | | 18072 | |
| 17051 | IrInstructionAllocaGen *result = ir_build_alloca_gen(ira, source_inst, align, name_hint); | 18073 | IrInstGenAlloca *result = ir_build_alloca_gen(ira, source_inst, align, name_hint); |
| 17052 | result->base.value->special = ConstValSpecialStatic; | 18074 | result->base.value->special = ConstValSpecialStatic; |
| 17053 | result->base.value->data.x_ptr.special = ConstPtrSpecialRef; | 18075 | result->base.value->data.x_ptr.special = ConstPtrSpecialRef; |
| 17054 | result->base.value->data.x_ptr.mut = force_comptime ? ConstPtrMutComptimeVar : ConstPtrMutInfer; | 18076 | result->base.value->data.x_ptr.mut = force_comptime ? ConstPtrMutComptimeVar : ConstPtrMutInfer; |
| ... | @@ -17056,15 +18078,15 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -17056,15 +18078,15 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in |
| 17056 | | 18078 | |
| 17057 | bool var_type_has_bits; | 18079 | bool var_type_has_bits; |
| 17058 | if ((err = type_has_bits2(ira->codegen, var_type, &var_type_has_bits))) | 18080 | if ((err = type_has_bits2(ira->codegen, var_type, &var_type_has_bits))) |
| 17059 | return ira->codegen->invalid_instruction; | 18081 | return ira->codegen->invalid_inst_gen; |
| 17060 | if (align != 0) { | 18082 | if (align != 0) { |
| 17061 | if ((err = type_resolve(ira->codegen, var_type, ResolveStatusAlignmentKnown))) | 18083 | if ((err = type_resolve(ira->codegen, var_type, ResolveStatusAlignmentKnown))) |
| 17062 | return ira->codegen->invalid_instruction; | 18084 | return ira->codegen->invalid_inst_gen; |
| 17063 | if (!var_type_has_bits) { | 18085 | if (!var_type_has_bits) { |
| 17064 | ir_add_error(ira, source_inst, | 18086 | ir_add_error(ira, source_inst, |
| 17065 | buf_sprintf("variable '%s' of zero-bit type '%s' has no in-memory representation, it cannot be aligned", | 18087 | buf_sprintf("variable '%s' of zero-bit type '%s' has no in-memory representation, it cannot be aligned", |
| 17066 | name_hint, buf_ptr(&var_type->name))); | 18088 | name_hint, buf_ptr(&var_type->name))); |
| 17067 | return ira->codegen->invalid_instruction; | 18089 | return ira->codegen->invalid_inst_gen; |
| 17068 | } | 18090 | } |
| 17069 | } | 18091 | } |
| 17070 | assert(result->base.value->data.x_ptr.special != ConstPtrSpecialInvalid); | 18092 | assert(result->base.value->data.x_ptr.special != ConstPtrSpecialInvalid); |
| ... | @@ -17074,16 +18096,15 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -17074,16 +18096,15 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in |
| 17074 | PtrLenSingle, align, 0, 0, false); | 18096 | PtrLenSingle, align, 0, 0, false); |
| 17075 | | 18097 | |
| 17076 | if (!force_comptime) { | 18098 | if (!force_comptime) { |
| 17077 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 18099 | ZigFn *fn_entry = ira->new_irb.exec->fn_entry; |
| 17078 | if (fn_entry != nullptr) { | 18100 | if (fn_entry != nullptr) { |
| 17079 | fn_entry->alloca_gen_list.append(result); | 18101 | fn_entry->alloca_gen_list.append(result); |
| 17080 | } | 18102 | } |
| 17081 | } | 18103 | } |
| 17082 | result->base.is_gen = true; | | |
| 17083 | return &result->base; | 18104 | return &result->base; |
| 17084 | } | 18105 | } |
| 17085 | | 18106 | |
| 17086 | static ZigType *ir_result_loc_expected_type(IrAnalyze *ira, IrInstruction *suspend_source_instr, | 18107 | static ZigType *ir_result_loc_expected_type(IrAnalyze *ira, IrInst *suspend_source_instr, |
| 17087 | ResultLoc *result_loc) | 18108 | ResultLoc *result_loc) |
| 17088 | { | 18109 | { |
| 17089 | switch (result_loc->id) { | 18110 | switch (result_loc->id) { |
| ... | @@ -17126,7 +18147,7 @@ static bool type_can_bit_cast(ZigType *t) { | ... | @@ -17126,7 +18147,7 @@ static bool type_can_bit_cast(ZigType *t) { |
| 17126 | } | 18147 | } |
| 17127 | } | 18148 | } |
| 17128 | | 18149 | |
| 17129 | static void set_up_result_loc_for_inferred_comptime(IrInstruction *ptr) { | 18150 | static void set_up_result_loc_for_inferred_comptime(IrInstGen *ptr) { |
| 17130 | ZigValue *undef_child = create_const_vals(1); | 18151 | ZigValue *undef_child = create_const_vals(1); |
| 17131 | undef_child->type = ptr->value->type->data.pointer.child_type; | 18152 | undef_child->type = ptr->value->type->data.pointer.child_type; |
| 17132 | undef_child->special = ConstValSpecialUndef; | 18153 | undef_child->special = ConstValSpecialUndef; |
| ... | @@ -17165,16 +18186,16 @@ static Error ir_result_has_type(IrAnalyze *ira, ResultLoc *result_loc, bool *out | ... | @@ -17165,16 +18186,16 @@ static Error ir_result_has_type(IrAnalyze *ira, ResultLoc *result_loc, bool *out |
| 17165 | zig_unreachable(); | 18186 | zig_unreachable(); |
| 17166 | } | 18187 | } |
| 17167 | | 18188 | |
| 17168 | static IrInstruction *ir_resolve_no_result_loc(IrAnalyze *ira, IrInstruction *suspend_source_instr, | 18189 | static IrInstGen *ir_resolve_no_result_loc(IrAnalyze *ira, IrInst *suspend_source_instr, |
| 17169 | ResultLoc *result_loc, ZigType *value_type) | 18190 | ResultLoc *result_loc, ZigType *value_type) |
| 17170 | { | 18191 | { |
| 17171 | if (type_is_invalid(value_type)) | 18192 | if (type_is_invalid(value_type)) |
| 17172 | return ira->codegen->invalid_instruction; | 18193 | return ira->codegen->invalid_inst_gen; |
| 17173 | IrInstructionAllocaGen *alloca_gen = ir_build_alloca_gen(ira, suspend_source_instr, 0, ""); | 18194 | IrInstGenAlloca *alloca_gen = ir_build_alloca_gen(ira, suspend_source_instr, 0, ""); |
| 17174 | alloca_gen->base.value->type = get_pointer_to_type_extra(ira->codegen, value_type, false, false, | 18195 | alloca_gen->base.value->type = get_pointer_to_type_extra(ira->codegen, value_type, false, false, |
| 17175 | PtrLenSingle, 0, 0, 0, false); | 18196 | PtrLenSingle, 0, 0, 0, false); |
| 17176 | set_up_result_loc_for_inferred_comptime(&alloca_gen->base); | 18197 | set_up_result_loc_for_inferred_comptime(&alloca_gen->base); |
| 17177 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 18198 | ZigFn *fn_entry = ira->new_irb.exec->fn_entry; |
| 17178 | if (fn_entry != nullptr && get_scope_typeof(suspend_source_instr->scope) == nullptr) { | 18199 | if (fn_entry != nullptr && get_scope_typeof(suspend_source_instr->scope) == nullptr) { |
| 17179 | fn_entry->alloca_gen_list.append(alloca_gen); | 18200 | fn_entry->alloca_gen_list.append(alloca_gen); |
| 17180 | } | 18201 | } |
| ... | @@ -17184,8 +18205,8 @@ static IrInstruction *ir_resolve_no_result_loc(IrAnalyze *ira, IrInstruction *su | ... | @@ -17184,8 +18205,8 @@ static IrInstruction *ir_resolve_no_result_loc(IrAnalyze *ira, IrInstruction *su |
| 17184 | } | 18205 | } |
| 17185 | | 18206 | |
| 17186 | // when calling this function, at the callsite must check for result type noreturn and propagate it up | 18207 | // when calling this function, at the callsite must check for result type noreturn and propagate it up |
| 17187 | static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspend_source_instr, | 18208 | static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInst *suspend_source_instr, |
| 17188 | ResultLoc *result_loc, ZigType *value_type, IrInstruction *value, bool force_runtime, | 18209 | ResultLoc *result_loc, ZigType *value_type, IrInstGen *value, bool force_runtime, |
| 17189 | bool allow_discard) | 18210 | bool allow_discard) |
| 17190 | { | 18211 | { |
| 17191 | Error err; | 18212 | Error err; |
| ... | @@ -17210,10 +18231,8 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17210,10 +18231,8 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17210 | } | 18231 | } |
| 17211 | case ResultLocIdVar: { | 18232 | case ResultLocIdVar: { |
| 17212 | ResultLocVar *result_loc_var = reinterpret_cast<ResultLocVar *>(result_loc); | 18233 | ResultLocVar *result_loc_var = reinterpret_cast<ResultLocVar *>(result_loc); |
| 17213 | assert(result_loc->source_instruction->id == IrInstructionIdAllocaSrc); | 18234 | assert(result_loc->source_instruction->id == IrInstSrcIdAlloca); |
| 17214 | | 18235 | IrInstSrcAlloca *alloca_src = reinterpret_cast<IrInstSrcAlloca *>(result_loc->source_instruction); |
| 17215 | IrInstructionAllocaSrc *alloca_src = | | |
| 17216 | reinterpret_cast<IrInstructionAllocaSrc *>(result_loc->source_instruction); | | |
| 17217 | | 18236 | |
| 17218 | ZigVar *var = result_loc_var->var; | 18237 | ZigVar *var = result_loc_var->var; |
| 17219 | if (var->var_type != nullptr && !ir_get_var_is_comptime(var)) { | 18238 | if (var->var_type != nullptr && !ir_get_var_is_comptime(var)) { |
| ... | @@ -17231,26 +18250,26 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17231,26 +18250,26 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17231 | var = new_var; | 18250 | var = new_var; |
| 17232 | } | 18251 | } |
| 17233 | if (value_type->id == ZigTypeIdUnreachable || value_type->id == ZigTypeIdOpaque) { | 18252 | if (value_type->id == ZigTypeIdUnreachable || value_type->id == ZigTypeIdOpaque) { |
| 17234 | ir_add_error(ira, result_loc->source_instruction, | 18253 | ir_add_error(ira, &result_loc->source_instruction->base, |
| 17235 | buf_sprintf("variable of type '%s' not allowed", buf_ptr(&value_type->name))); | 18254 | buf_sprintf("variable of type '%s' not allowed", buf_ptr(&value_type->name))); |
| 17236 | return ira->codegen->invalid_instruction; | 18255 | return ira->codegen->invalid_inst_gen; |
| 17237 | } | 18256 | } |
| 17238 | if (alloca_src->base.child == nullptr || var->ptr_instruction == nullptr) { | 18257 | if (alloca_src->base.child == nullptr || var->ptr_instruction == nullptr) { |
| 17239 | bool force_comptime; | 18258 | bool force_comptime; |
| 17240 | if (!ir_resolve_comptime(ira, alloca_src->is_comptime->child, &force_comptime)) | 18259 | if (!ir_resolve_comptime(ira, alloca_src->is_comptime->child, &force_comptime)) |
| 17241 | return ira->codegen->invalid_instruction; | 18260 | return ira->codegen->invalid_inst_gen; |
| 17242 | uint32_t align = 0; | 18261 | uint32_t align = 0; |
| 17243 | if (alloca_src->align != nullptr && !ir_resolve_align(ira, alloca_src->align->child, nullptr, &align)) { | 18262 | if (alloca_src->align != nullptr && !ir_resolve_align(ira, alloca_src->align->child, nullptr, &align)) { |
| 17244 | return ira->codegen->invalid_instruction; | 18263 | return ira->codegen->invalid_inst_gen; |
| 17245 | } | 18264 | } |
| 17246 | IrInstruction *alloca_gen = ir_analyze_alloca(ira, result_loc->source_instruction, | 18265 | IrInstGen *alloca_gen = ir_analyze_alloca(ira, &result_loc->source_instruction->base, value_type, |
| 17247 | value_type, align, alloca_src->name_hint, force_comptime); | 18266 | align, alloca_src->name_hint, force_comptime); |
| 17248 | if (force_runtime) { | 18267 | if (force_runtime) { |
| 17249 | alloca_gen->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; | 18268 | alloca_gen->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; |
| 17250 | alloca_gen->value->special = ConstValSpecialRuntime; | 18269 | alloca_gen->value->special = ConstValSpecialRuntime; |
| 17251 | } | 18270 | } |
| 17252 | if (alloca_src->base.child != nullptr && !result_loc->written) { | 18271 | if (alloca_src->base.child != nullptr && !result_loc->written) { |
| 17253 | alloca_src->base.child->ref_count = 0; | 18272 | alloca_src->base.child->base.ref_count = 0; |
| 17254 | } | 18273 | } |
| 17255 | alloca_src->base.child = alloca_gen; | 18274 | alloca_src->base.child = alloca_gen; |
| 17256 | var->ptr_instruction = alloca_gen; | 18275 | var->ptr_instruction = alloca_gen; |
| ... | @@ -17278,7 +18297,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17278,7 +18297,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17278 | ResultLocPeerParent *peer_parent = result_peer->parent; | 18297 | ResultLocPeerParent *peer_parent = result_peer->parent; |
| 17279 | | 18298 | |
| 17280 | if (peer_parent->peers.length == 1) { | 18299 | if (peer_parent->peers.length == 1) { |
| 17281 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, | 18300 | IrInstGen *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, |
| 17282 | value_type, value, force_runtime, true); | 18301 | value_type, value, force_runtime, true); |
| 17283 | result_peer->suspend_pos.basic_block_index = SIZE_MAX; | 18302 | result_peer->suspend_pos.basic_block_index = SIZE_MAX; |
| 17284 | result_peer->suspend_pos.instruction_index = SIZE_MAX; | 18303 | result_peer->suspend_pos.instruction_index = SIZE_MAX; |
| ... | @@ -17294,7 +18313,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17294,7 +18313,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17294 | | 18313 | |
| 17295 | bool is_condition_comptime; | 18314 | bool is_condition_comptime; |
| 17296 | if (!ir_resolve_comptime(ira, peer_parent->is_comptime->child, &is_condition_comptime)) | 18315 | if (!ir_resolve_comptime(ira, peer_parent->is_comptime->child, &is_condition_comptime)) |
| 17297 | return ira->codegen->invalid_instruction; | 18316 | return ira->codegen->invalid_inst_gen; |
| 17298 | if (is_condition_comptime) { | 18317 | if (is_condition_comptime) { |
| 17299 | peer_parent->skipped = true; | 18318 | peer_parent->skipped = true; |
| 17300 | return ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, | 18319 | return ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, |
| ... | @@ -17302,10 +18321,10 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17302,10 +18321,10 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17302 | } | 18321 | } |
| 17303 | bool peer_parent_has_type; | 18322 | bool peer_parent_has_type; |
| 17304 | if ((err = ir_result_has_type(ira, peer_parent->parent, &peer_parent_has_type))) | 18323 | if ((err = ir_result_has_type(ira, peer_parent->parent, &peer_parent_has_type))) |
| 17305 | return ira->codegen->invalid_instruction; | 18324 | return ira->codegen->invalid_inst_gen; |
| 17306 | if (peer_parent_has_type) { | 18325 | if (peer_parent_has_type) { |
| 17307 | peer_parent->skipped = true; | 18326 | peer_parent->skipped = true; |
| 17308 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, | 18327 | IrInstGen *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, |
| 17309 | value_type, value, force_runtime || !is_condition_comptime, true); | 18328 | value_type, value, force_runtime || !is_condition_comptime, true); |
| 17310 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || | 18329 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 17311 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) | 18330 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| ... | @@ -17322,7 +18341,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17322,7 +18341,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17322 | if (peer_parent->end_bb->suspend_instruction_ref == nullptr) { | 18341 | if (peer_parent->end_bb->suspend_instruction_ref == nullptr) { |
| 17323 | peer_parent->end_bb->suspend_instruction_ref = suspend_source_instr; | 18342 | peer_parent->end_bb->suspend_instruction_ref = suspend_source_instr; |
| 17324 | } | 18343 | } |
| 17325 | IrInstruction *unreach_inst = ira_suspend(ira, suspend_source_instr, result_peer->next_bb, | 18344 | IrInstGen *unreach_inst = ira_suspend(ira, suspend_source_instr, result_peer->next_bb, |
| 17326 | &result_peer->suspend_pos); | 18345 | &result_peer->suspend_pos); |
| 17327 | if (result_peer->next_bb == nullptr) { | 18346 | if (result_peer->next_bb == nullptr) { |
| 17328 | ir_start_next_bb(ira); | 18347 | ir_start_next_bb(ira); |
| ... | @@ -17330,7 +18349,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17330,7 +18349,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17330 | return unreach_inst; | 18349 | return unreach_inst; |
| 17331 | } | 18350 | } |
| 17332 | | 18351 | |
| 17333 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, | 18352 | IrInstGen *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, |
| 17334 | peer_parent->resolved_type, nullptr, force_runtime, true); | 18353 | peer_parent->resolved_type, nullptr, force_runtime, true); |
| 17335 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || | 18354 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 17336 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) | 18355 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| ... | @@ -17347,23 +18366,23 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17347,23 +18366,23 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17347 | ResultLocCast *result_cast = reinterpret_cast<ResultLocCast *>(result_loc); | 18366 | ResultLocCast *result_cast = reinterpret_cast<ResultLocCast *>(result_loc); |
| 17348 | ZigType *dest_type = ir_resolve_type(ira, result_cast->base.source_instruction->child); | 18367 | ZigType *dest_type = ir_resolve_type(ira, result_cast->base.source_instruction->child); |
| 17349 | if (type_is_invalid(dest_type)) | 18368 | if (type_is_invalid(dest_type)) |
| 17350 | return ira->codegen->invalid_instruction; | 18369 | return ira->codegen->invalid_inst_gen; |
| 17351 | | 18370 | |
| 17352 | if (dest_type == ira->codegen->builtin_types.entry_var) { | 18371 | if (dest_type == ira->codegen->builtin_types.entry_var) { |
| 17353 | return ir_resolve_no_result_loc(ira, suspend_source_instr, result_loc, value_type); | 18372 | return ir_resolve_no_result_loc(ira, suspend_source_instr, result_loc, value_type); |
| 17354 | } | 18373 | } |
| 17355 | | 18374 | |
| 17356 | IrInstruction *casted_value; | 18375 | IrInstGen *casted_value; |
| 17357 | if (value != nullptr) { | 18376 | if (value != nullptr) { |
| 17358 | casted_value = ir_implicit_cast(ira, value, dest_type); | 18377 | casted_value = ir_implicit_cast(ira, value, dest_type); |
| 17359 | if (type_is_invalid(casted_value->value->type)) | 18378 | if (type_is_invalid(casted_value->value->type)) |
| 17360 | return ira->codegen->invalid_instruction; | 18379 | return ira->codegen->invalid_inst_gen; |
| 17361 | dest_type = casted_value->value->type; | 18380 | dest_type = casted_value->value->type; |
| 17362 | } else { | 18381 | } else { |
| 17363 | casted_value = nullptr; | 18382 | casted_value = nullptr; |
| 17364 | } | 18383 | } |
| 17365 | | 18384 | |
| 17366 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_cast->parent, | 18385 | IrInstGen *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_cast->parent, |
| 17367 | dest_type, casted_value, force_runtime, true); | 18386 | dest_type, casted_value, force_runtime, true); |
| 17368 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || | 18387 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 17369 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) | 18388 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| ... | @@ -17377,11 +18396,11 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17377,11 +18396,11 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17377 | if ((err = type_resolve(ira->codegen, parent_ptr_type->data.pointer.child_type, | 18396 | if ((err = type_resolve(ira->codegen, parent_ptr_type->data.pointer.child_type, |
| 17378 | ResolveStatusAlignmentKnown))) | 18397 | ResolveStatusAlignmentKnown))) |
| 17379 | { | 18398 | { |
| 17380 | return ira->codegen->invalid_instruction; | 18399 | return ira->codegen->invalid_inst_gen; |
| 17381 | } | 18400 | } |
| 17382 | uint64_t parent_ptr_align = get_ptr_align(ira->codegen, parent_ptr_type); | 18401 | uint64_t parent_ptr_align = get_ptr_align(ira->codegen, parent_ptr_type); |
| 17383 | if ((err = type_resolve(ira->codegen, value_type, ResolveStatusAlignmentKnown))) { | 18402 | if ((err = type_resolve(ira->codegen, value_type, ResolveStatusAlignmentKnown))) { |
| 17384 | return ira->codegen->invalid_instruction; | 18403 | return ira->codegen->invalid_inst_gen; |
| 17385 | } | 18404 | } |
| 17386 | if (!type_has_bits(value_type)) { | 18405 | if (!type_has_bits(value_type)) { |
| 17387 | parent_ptr_align = 0; | 18406 | parent_ptr_align = 0; |
| ... | @@ -17404,9 +18423,9 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17404,9 +18423,9 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17404 | | 18423 | |
| 17405 | ConstCastOnly const_cast_result = types_match_const_cast_only(ira, | 18424 | ConstCastOnly const_cast_result = types_match_const_cast_only(ira, |
| 17406 | parent_result_loc->value->type, ptr_type, | 18425 | parent_result_loc->value->type, ptr_type, |
| 17407 | result_cast->base.source_instruction->source_node, false); | 18426 | result_cast->base.source_instruction->base.source_node, false); |
| 17408 | if (const_cast_result.id == ConstCastResultIdInvalid) | 18427 | if (const_cast_result.id == ConstCastResultIdInvalid) |
| 17409 | return ira->codegen->invalid_instruction; | 18428 | return ira->codegen->invalid_inst_gen; |
| 17410 | if (const_cast_result.id != ConstCastResultIdOk) { | 18429 | if (const_cast_result.id != ConstCastResultIdOk) { |
| 17411 | if (allow_discard) { | 18430 | if (allow_discard) { |
| 17412 | return parent_result_loc; | 18431 | return parent_result_loc; |
| ... | @@ -17419,42 +18438,42 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17419,42 +18438,42 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17419 | | 18438 | |
| 17420 | result_loc->written = true; | 18439 | result_loc->written = true; |
| 17421 | result_loc->resolved_loc = ir_analyze_ptr_cast(ira, suspend_source_instr, parent_result_loc, | 18440 | result_loc->resolved_loc = ir_analyze_ptr_cast(ira, suspend_source_instr, parent_result_loc, |
| 17422 | ptr_type, result_cast->base.source_instruction, false); | 18441 | ptr_type, &result_cast->base.source_instruction->base, false); |
| 17423 | return result_loc->resolved_loc; | 18442 | return result_loc->resolved_loc; |
| 17424 | } | 18443 | } |
| 17425 | case ResultLocIdBitCast: { | 18444 | case ResultLocIdBitCast: { |
| 17426 | ResultLocBitCast *result_bit_cast = reinterpret_cast<ResultLocBitCast *>(result_loc); | 18445 | ResultLocBitCast *result_bit_cast = reinterpret_cast<ResultLocBitCast *>(result_loc); |
| 17427 | ZigType *dest_type = ir_resolve_type(ira, result_bit_cast->base.source_instruction->child); | 18446 | ZigType *dest_type = ir_resolve_type(ira, result_bit_cast->base.source_instruction->child); |
| 17428 | if (type_is_invalid(dest_type)) | 18447 | if (type_is_invalid(dest_type)) |
| 17429 | return ira->codegen->invalid_instruction; | 18448 | return ira->codegen->invalid_inst_gen; |
| 17430 | | 18449 | |
| 17431 | if (get_codegen_ptr_type(dest_type) != nullptr) { | 18450 | if (get_codegen_ptr_type(dest_type) != nullptr) { |
| 17432 | ir_add_error(ira, result_loc->source_instruction, | 18451 | ir_add_error(ira, &result_loc->source_instruction->base, |
| 17433 | buf_sprintf("unable to @bitCast to pointer type '%s'", buf_ptr(&dest_type->name))); | 18452 | buf_sprintf("unable to @bitCast to pointer type '%s'", buf_ptr(&dest_type->name))); |
| 17434 | return ira->codegen->invalid_instruction; | 18453 | return ira->codegen->invalid_inst_gen; |
| 17435 | } | 18454 | } |
| 17436 | | 18455 | |
| 17437 | if (!type_can_bit_cast(dest_type)) { | 18456 | if (!type_can_bit_cast(dest_type)) { |
| 17438 | ir_add_error(ira, result_loc->source_instruction, | 18457 | ir_add_error(ira, &result_loc->source_instruction->base, |
| 17439 | buf_sprintf("unable to @bitCast to type '%s'", buf_ptr(&dest_type->name))); | 18458 | buf_sprintf("unable to @bitCast to type '%s'", buf_ptr(&dest_type->name))); |
| 17440 | return ira->codegen->invalid_instruction; | 18459 | return ira->codegen->invalid_inst_gen; |
| 17441 | } | 18460 | } |
| 17442 | | 18461 | |
| 17443 | if (get_codegen_ptr_type(value_type) != nullptr) { | 18462 | if (get_codegen_ptr_type(value_type) != nullptr) { |
| 17444 | ir_add_error(ira, suspend_source_instr, | 18463 | ir_add_error(ira, suspend_source_instr, |
| 17445 | buf_sprintf("unable to @bitCast from pointer type '%s'", buf_ptr(&value_type->name))); | 18464 | buf_sprintf("unable to @bitCast from pointer type '%s'", buf_ptr(&value_type->name))); |
| 17446 | return ira->codegen->invalid_instruction; | 18465 | return ira->codegen->invalid_inst_gen; |
| 17447 | } | 18466 | } |
| 17448 | | 18467 | |
| 17449 | if (!type_can_bit_cast(value_type)) { | 18468 | if (!type_can_bit_cast(value_type)) { |
| 17450 | ir_add_error(ira, suspend_source_instr, | 18469 | ir_add_error(ira, suspend_source_instr, |
| 17451 | buf_sprintf("unable to @bitCast from type '%s'", buf_ptr(&value_type->name))); | 18470 | buf_sprintf("unable to @bitCast from type '%s'", buf_ptr(&value_type->name))); |
| 17452 | return ira->codegen->invalid_instruction; | 18471 | return ira->codegen->invalid_inst_gen; |
| 17453 | } | 18472 | } |
| 17454 | | 18473 | |
| 17455 | IrInstruction *bitcasted_value; | 18474 | IrInstGen *bitcasted_value; |
| 17456 | if (value != nullptr) { | 18475 | if (value != nullptr) { |
| 17457 | bitcasted_value = ir_analyze_bit_cast(ira, result_loc->source_instruction, value, dest_type); | 18476 | bitcasted_value = ir_analyze_bit_cast(ira, &result_loc->source_instruction->base, value, dest_type); |
| 17458 | dest_type = bitcasted_value->value->type; | 18477 | dest_type = bitcasted_value->value->type; |
| 17459 | } else { | 18478 | } else { |
| 17460 | bitcasted_value = nullptr; | 18479 | bitcasted_value = nullptr; |
| ... | @@ -17464,7 +18483,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17464,7 +18483,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17464 | return bitcasted_value; | 18483 | return bitcasted_value; |
| 17465 | } | 18484 | } |
| 17466 | | 18485 | |
| 17467 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_bit_cast->parent, | 18486 | IrInstGen *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_bit_cast->parent, |
| 17468 | dest_type, bitcasted_value, force_runtime, true); | 18487 | dest_type, bitcasted_value, force_runtime, true); |
| 17469 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || | 18488 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 17470 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) | 18489 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| ... | @@ -17477,7 +18496,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17477,7 +18496,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17477 | | 18496 | |
| 17478 | bool has_bits; | 18497 | bool has_bits; |
| 17479 | if ((err = type_has_bits2(ira->codegen, child_type, &has_bits))) { | 18498 | if ((err = type_has_bits2(ira->codegen, child_type, &has_bits))) { |
| 17480 | return ira->codegen->invalid_instruction; | 18499 | return ira->codegen->invalid_inst_gen; |
| 17481 | } | 18500 | } |
| 17482 | | 18501 | |
| 17483 | // This happens when the bitCast result is assigned to _ | 18502 | // This happens when the bitCast result is assigned to _ |
| ... | @@ -17487,12 +18506,12 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17487,12 +18506,12 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17487 | } | 18506 | } |
| 17488 | | 18507 | |
| 17489 | if ((err = type_resolve(ira->codegen, child_type, ResolveStatusAlignmentKnown))) { | 18508 | if ((err = type_resolve(ira->codegen, child_type, ResolveStatusAlignmentKnown))) { |
| 17490 | return ira->codegen->invalid_instruction; | 18509 | return ira->codegen->invalid_inst_gen; |
| 17491 | } | 18510 | } |
| 17492 | | 18511 | |
| 17493 | uint64_t parent_ptr_align = get_ptr_align(ira->codegen, parent_ptr_type); | 18512 | uint64_t parent_ptr_align = get_ptr_align(ira->codegen, parent_ptr_type); |
| 17494 | if ((err = type_resolve(ira->codegen, value_type, ResolveStatusAlignmentKnown))) { | 18513 | if ((err = type_resolve(ira->codegen, value_type, ResolveStatusAlignmentKnown))) { |
| 17495 | return ira->codegen->invalid_instruction; | 18514 | return ira->codegen->invalid_inst_gen; |
| 17496 | } | 18515 | } |
| 17497 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, value_type, | 18516 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, value_type, |
| 17498 | parent_ptr_type->data.pointer.is_const, parent_ptr_type->data.pointer.is_volatile, PtrLenSingle, | 18517 | parent_ptr_type->data.pointer.is_const, parent_ptr_type->data.pointer.is_volatile, PtrLenSingle, |
| ... | @@ -17500,30 +18519,37 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17500,30 +18519,37 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17500 | | 18519 | |
| 17501 | result_loc->written = true; | 18520 | result_loc->written = true; |
| 17502 | result_loc->resolved_loc = ir_analyze_ptr_cast(ira, suspend_source_instr, parent_result_loc, | 18521 | result_loc->resolved_loc = ir_analyze_ptr_cast(ira, suspend_source_instr, parent_result_loc, |
| 17503 | ptr_type, result_bit_cast->base.source_instruction, false); | 18522 | ptr_type, &result_bit_cast->base.source_instruction->base, false); |
| 17504 | return result_loc->resolved_loc; | 18523 | return result_loc->resolved_loc; |
| 17505 | } | 18524 | } |
| 17506 | } | 18525 | } |
| 17507 | zig_unreachable(); | 18526 | zig_unreachable(); |
| 17508 | } | 18527 | } |
| 17509 | | 18528 | |
| 17510 | static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_source_instr, | 18529 | static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr, |
| 17511 | ResultLoc *result_loc_pass1, ZigType *value_type, IrInstruction *value, bool force_runtime, | 18530 | ResultLoc *result_loc_pass1, ZigType *value_type, IrInstGen *value, bool force_runtime, |
| 17512 | bool allow_discard) | 18531 | bool allow_discard) |
| 17513 | { | 18532 | { |
| 17514 | Error err; | 18533 | Error err; |
| 17515 | if (!allow_discard && result_loc_pass1->id == ResultLocIdInstruction && | 18534 | if (!allow_discard && result_loc_pass1->id == ResultLocIdInstruction && |
| 17516 | instr_is_comptime(result_loc_pass1->source_instruction) && | 18535 | result_loc_pass1->source_instruction->id == IrInstSrcIdConst) |
| 17517 | result_loc_pass1->source_instruction->value->type->id == ZigTypeIdPointer && | | |
| 17518 | result_loc_pass1->source_instruction->value->data.x_ptr.special == ConstPtrSpecialDiscard) | | |
| 17519 | { | 18536 | { |
| 17520 | result_loc_pass1 = no_result_loc(); | 18537 | IrInstSrcConst *const_inst = reinterpret_cast<IrInstSrcConst *>(result_loc_pass1->source_instruction); |
| | 18538 | if (value_is_comptime(const_inst->value) && |
| | 18539 | const_inst->value->type->id == ZigTypeIdPointer && |
| | 18540 | const_inst->value->data.x_ptr.special == ConstPtrSpecialDiscard) |
| | 18541 | { |
| | 18542 | result_loc_pass1 = no_result_loc(); |
| | 18543 | } |
| 17521 | } | 18544 | } |
| 17522 | bool was_written = result_loc_pass1->written; | 18545 | bool was_written = result_loc_pass1->written; |
| 17523 | IrInstruction *result_loc = ir_resolve_result_raw(ira, suspend_source_instr, result_loc_pass1, value_type, | 18546 | IrInstGen *result_loc = ir_resolve_result_raw(ira, suspend_source_instr, result_loc_pass1, value_type, |
| 17524 | value, force_runtime, allow_discard); | 18547 | value, force_runtime, allow_discard); |
| 17525 | if (result_loc == nullptr || (instr_is_unreachable(result_loc) || type_is_invalid(result_loc->value->type))) | 18548 | if (result_loc == nullptr || result_loc->value->type->id == ZigTypeIdUnreachable || |
| | 18549 | type_is_invalid(result_loc->value->type)) |
| | 18550 | { |
| 17526 | return result_loc; | 18551 | return result_loc; |
| | 18552 | } |
| 17527 | | 18553 | |
| 17528 | if ((force_runtime || (value != nullptr && !instr_is_comptime(value))) && | 18554 | if ((force_runtime || (value != nullptr && !instr_is_comptime(value))) && |
| 17529 | result_loc_pass1->written && result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) | 18555 | result_loc_pass1->written && result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) |
| ... | @@ -17534,7 +18560,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s | ... | @@ -17534,7 +18560,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 17534 | InferredStructField *isf = result_loc->value->type->data.pointer.inferred_struct_field; | 18560 | InferredStructField *isf = result_loc->value->type->data.pointer.inferred_struct_field; |
| 17535 | if (isf != nullptr) { | 18561 | if (isf != nullptr) { |
| 17536 | TypeStructField *field; | 18562 | TypeStructField *field; |
| 17537 | IrInstruction *casted_ptr; | 18563 | IrInstGen *casted_ptr; |
| 17538 | if (isf->already_resolved) { | 18564 | if (isf->already_resolved) { |
| 17539 | field = find_struct_type_field(isf->inferred_struct_type, isf->field_name); | 18565 | field = find_struct_type_field(isf->inferred_struct_type, isf->field_name); |
| 17540 | casted_ptr = result_loc; | 18566 | casted_ptr = result_loc; |
| ... | @@ -17552,11 +18578,11 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s | ... | @@ -17552,11 +18578,11 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 17552 | field->type_entry = value_type; | 18578 | field->type_entry = value_type; |
| 17553 | field->type_val = create_const_type(ira->codegen, field->type_entry); | 18579 | field->type_val = create_const_type(ira->codegen, field->type_entry); |
| 17554 | field->src_index = old_field_count; | 18580 | field->src_index = old_field_count; |
| 17555 | field->decl_node = value ? value->source_node : suspend_source_instr->source_node; | 18581 | field->decl_node = value ? value->base.source_node : suspend_source_instr->source_node; |
| 17556 | if (value && instr_is_comptime(value)) { | 18582 | if (value && instr_is_comptime(value)) { |
| 17557 | ZigValue *val = ir_resolve_const(ira, value, UndefOk); | 18583 | ZigValue *val = ir_resolve_const(ira, value, UndefOk); |
| 17558 | if (!val) | 18584 | if (!val) |
| 17559 | return ira->codegen->invalid_instruction; | 18585 | return ira->codegen->invalid_inst_gen; |
| 17560 | field->is_comptime = true; | 18586 | field->is_comptime = true; |
| 17561 | field->init_val = create_const_vals(1); | 18587 | field->init_val = create_const_vals(1); |
| 17562 | copy_const_val(field->init_val, val); | 18588 | copy_const_val(field->init_val, val); |
| ... | @@ -17574,7 +18600,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s | ... | @@ -17574,7 +18600,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 17574 | if (instr_is_comptime(casted_ptr)) { | 18600 | if (instr_is_comptime(casted_ptr)) { |
| 17575 | ZigValue *ptr_val = ir_resolve_const(ira, casted_ptr, UndefBad); | 18601 | ZigValue *ptr_val = ir_resolve_const(ira, casted_ptr, UndefBad); |
| 17576 | if (!ptr_val) | 18602 | if (!ptr_val) |
| 17577 | return ira->codegen->invalid_instruction; | 18603 | return ira->codegen->invalid_inst_gen; |
| 17578 | if (ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 18604 | if (ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 17579 | ZigValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, | 18605 | ZigValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, |
| 17580 | suspend_source_instr->source_node); | 18606 | suspend_source_instr->source_node); |
| ... | @@ -17610,7 +18636,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s | ... | @@ -17610,7 +18636,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 17610 | if (!same_comptime_repr) { | 18636 | if (!same_comptime_repr) { |
| 17611 | bool has_bits; | 18637 | bool has_bits; |
| 17612 | if ((err = type_has_bits2(ira->codegen, value_type, &has_bits))) | 18638 | if ((err = type_has_bits2(ira->codegen, value_type, &has_bits))) |
| 17613 | return ira->codegen->invalid_instruction; | 18639 | return ira->codegen->invalid_inst_gen; |
| 17614 | if (has_bits) { | 18640 | if (has_bits) { |
| 17615 | result_loc_pass1->written = false; | 18641 | result_loc_pass1->written = false; |
| 17616 | return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true); | 18642 | return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true); |
| ... | @@ -17619,12 +18645,12 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s | ... | @@ -17619,12 +18645,12 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 17619 | } else if (actual_elem_type->id == ZigTypeIdErrorUnion && value_type->id != ZigTypeIdErrorUnion) { | 18645 | } else if (actual_elem_type->id == ZigTypeIdErrorUnion && value_type->id != ZigTypeIdErrorUnion) { |
| 17620 | bool has_bits; | 18646 | bool has_bits; |
| 17621 | if ((err = type_has_bits2(ira->codegen, value_type, &has_bits))) | 18647 | if ((err = type_has_bits2(ira->codegen, value_type, &has_bits))) |
| 17622 | return ira->codegen->invalid_instruction; | 18648 | return ira->codegen->invalid_inst_gen; |
| 17623 | if (has_bits) { | 18649 | if (has_bits) { |
| 17624 | if (value_type->id == ZigTypeIdErrorSet) { | 18650 | if (value_type->id == ZigTypeIdErrorSet) { |
| 17625 | return ir_analyze_unwrap_err_code(ira, suspend_source_instr, result_loc, true); | 18651 | return ir_analyze_unwrap_err_code(ira, suspend_source_instr, result_loc, true); |
| 17626 | } else { | 18652 | } else { |
| 17627 | IrInstruction *unwrapped_err_ptr = ir_analyze_unwrap_error_payload(ira, suspend_source_instr, | 18653 | IrInstGen *unwrapped_err_ptr = ir_analyze_unwrap_error_payload(ira, suspend_source_instr, |
| 17628 | result_loc, false, true); | 18654 | result_loc, false, true); |
| 17629 | ZigType *actual_payload_type = actual_elem_type->data.error_union.payload_type; | 18655 | ZigType *actual_payload_type = actual_elem_type->data.error_union.payload_type; |
| 17630 | if (actual_payload_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional && | 18656 | if (actual_payload_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional && |
| ... | @@ -17640,37 +18666,35 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s | ... | @@ -17640,37 +18666,35 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 17640 | return result_loc; | 18666 | return result_loc; |
| 17641 | } | 18667 | } |
| 17642 | | 18668 | |
| 17643 | static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, | 18669 | static IrInstGen *ir_analyze_instruction_resolve_result(IrAnalyze *ira, IrInstSrcResolveResult *instruction) { |
| 17644 | IrInstructionResolveResult *instruction) | | |
| 17645 | { | | |
| 17646 | ZigType *implicit_elem_type; | 18670 | ZigType *implicit_elem_type; |
| 17647 | if (instruction->ty == nullptr) { | 18671 | if (instruction->ty == nullptr) { |
| 17648 | if (instruction->result_loc->id == ResultLocIdCast) { | 18672 | if (instruction->result_loc->id == ResultLocIdCast) { |
| 17649 | implicit_elem_type = ir_resolve_type(ira, | 18673 | implicit_elem_type = ir_resolve_type(ira, |
| 17650 | instruction->result_loc->source_instruction->child); | 18674 | instruction->result_loc->source_instruction->child); |
| 17651 | if (type_is_invalid(implicit_elem_type)) | 18675 | if (type_is_invalid(implicit_elem_type)) |
| 17652 | return ira->codegen->invalid_instruction; | 18676 | return ira->codegen->invalid_inst_gen; |
| 17653 | } else if (instruction->result_loc->id == ResultLocIdReturn) { | 18677 | } else if (instruction->result_loc->id == ResultLocIdReturn) { |
| 17654 | implicit_elem_type = ira->explicit_return_type; | 18678 | implicit_elem_type = ira->explicit_return_type; |
| 17655 | if (type_is_invalid(implicit_elem_type)) | 18679 | if (type_is_invalid(implicit_elem_type)) |
| 17656 | return ira->codegen->invalid_instruction; | 18680 | return ira->codegen->invalid_inst_gen; |
| 17657 | } else { | 18681 | } else { |
| 17658 | implicit_elem_type = ira->codegen->builtin_types.entry_var; | 18682 | implicit_elem_type = ira->codegen->builtin_types.entry_var; |
| 17659 | } | 18683 | } |
| 17660 | if (implicit_elem_type == ira->codegen->builtin_types.entry_var) { | 18684 | if (implicit_elem_type == ira->codegen->builtin_types.entry_var) { |
| 17661 | Buf *bare_name = buf_alloc(); | 18685 | Buf *bare_name = buf_alloc(); |
| 17662 | Buf *name = get_anon_type_name(ira->codegen, nullptr, container_string(ContainerKindStruct), | 18686 | Buf *name = get_anon_type_name(ira->codegen, nullptr, container_string(ContainerKindStruct), |
| 17663 | instruction->base.scope, instruction->base.source_node, bare_name); | 18687 | instruction->base.base.scope, instruction->base.base.source_node, bare_name); |
| 17664 | | 18688 | |
| 17665 | StructSpecial struct_special = StructSpecialInferredStruct; | 18689 | StructSpecial struct_special = StructSpecialInferredStruct; |
| 17666 | if (instruction->base.source_node->type == NodeTypeContainerInitExpr && | 18690 | if (instruction->base.base.source_node->type == NodeTypeContainerInitExpr && |
| 17667 | instruction->base.source_node->data.container_init_expr.kind == ContainerInitKindArray) | 18691 | instruction->base.base.source_node->data.container_init_expr.kind == ContainerInitKindArray) |
| 17668 | { | 18692 | { |
| 17669 | struct_special = StructSpecialInferredTuple; | 18693 | struct_special = StructSpecialInferredTuple; |
| 17670 | } | 18694 | } |
| 17671 | | 18695 | |
| 17672 | ZigType *inferred_struct_type = get_partial_container_type(ira->codegen, | 18696 | ZigType *inferred_struct_type = get_partial_container_type(ira->codegen, |
| 17673 | instruction->base.scope, ContainerKindStruct, instruction->base.source_node, | 18697 | instruction->base.base.scope, ContainerKindStruct, instruction->base.base.source_node, |
| 17674 | buf_ptr(name), bare_name, ContainerLayoutAuto); | 18698 | buf_ptr(name), bare_name, ContainerLayoutAuto); |
| 17675 | inferred_struct_type->data.structure.special = struct_special; | 18699 | inferred_struct_type->data.structure.special = struct_special; |
| 17676 | inferred_struct_type->data.structure.resolve_status = ResolveStatusBeingInferred; | 18700 | inferred_struct_type->data.structure.resolve_status = ResolveStatusBeingInferred; |
| ... | @@ -17679,21 +18703,21 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, | ... | @@ -17679,21 +18703,21 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, |
| 17679 | } else { | 18703 | } else { |
| 17680 | implicit_elem_type = ir_resolve_type(ira, instruction->ty->child); | 18704 | implicit_elem_type = ir_resolve_type(ira, instruction->ty->child); |
| 17681 | if (type_is_invalid(implicit_elem_type)) | 18705 | if (type_is_invalid(implicit_elem_type)) |
| 17682 | return ira->codegen->invalid_instruction; | 18706 | return ira->codegen->invalid_inst_gen; |
| 17683 | } | 18707 | } |
| 17684 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 18708 | IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base.base, instruction->result_loc, |
| 17685 | implicit_elem_type, nullptr, false, true); | 18709 | implicit_elem_type, nullptr, false, true); |
| 17686 | if (result_loc != nullptr) | 18710 | if (result_loc != nullptr) |
| 17687 | return result_loc; | 18711 | return result_loc; |
| 17688 | | 18712 | |
| 17689 | ZigFn *fn = exec_fn_entry(ira->new_irb.exec); | 18713 | ZigFn *fn = ira->new_irb.exec->fn_entry; |
| 17690 | if (fn != nullptr && fn->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync && | 18714 | if (fn != nullptr && fn->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync && |
| 17691 | instruction->result_loc->id == ResultLocIdReturn) | 18715 | instruction->result_loc->id == ResultLocIdReturn) |
| 17692 | { | 18716 | { |
| 17693 | result_loc = ir_resolve_result(ira, &instruction->base, no_result_loc(), | 18717 | result_loc = ir_resolve_result(ira, &instruction->base.base, no_result_loc(), |
| 17694 | implicit_elem_type, nullptr, false, true); | 18718 | implicit_elem_type, nullptr, false, true); |
| 17695 | if (result_loc != nullptr && | 18719 | if (result_loc != nullptr && |
| 17696 | (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) | 18720 | (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable)) |
| 17697 | { | 18721 | { |
| 17698 | return result_loc; | 18722 | return result_loc; |
| 17699 | } | 18723 | } |
| ... | @@ -17701,9 +18725,9 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, | ... | @@ -17701,9 +18725,9 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, |
| 17701 | return result_loc; | 18725 | return result_loc; |
| 17702 | } | 18726 | } |
| 17703 | | 18727 | |
| 17704 | IrInstruction *result = ir_const(ira, &instruction->base, implicit_elem_type); | 18728 | IrInstGen *result = ir_const(ira, &instruction->base.base, implicit_elem_type); |
| 17705 | result->value->special = ConstValSpecialUndef; | 18729 | result->value->special = ConstValSpecialUndef; |
| 17706 | IrInstruction *ptr = ir_get_ref(ira, &instruction->base, result, false, false); | 18730 | IrInstGen *ptr = ir_get_ref(ira, &instruction->base.base, result, false, false); |
| 17707 | ptr->value->data.x_ptr.mut = ConstPtrMutComptimeVar; | 18731 | ptr->value->data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 17708 | return ptr; | 18732 | return ptr; |
| 17709 | } | 18733 | } |
| ... | @@ -17727,8 +18751,7 @@ static void ir_reset_result(ResultLoc *result_loc) { | ... | @@ -17727,8 +18751,7 @@ static void ir_reset_result(ResultLoc *result_loc) { |
| 17727 | break; | 18751 | break; |
| 17728 | } | 18752 | } |
| 17729 | case ResultLocIdVar: { | 18753 | case ResultLocIdVar: { |
| 17730 | IrInstructionAllocaSrc *alloca_src = | 18754 | IrInstSrcAlloca *alloca_src = reinterpret_cast<IrInstSrcAlloca *>(result_loc->source_instruction); |
| 17731 | reinterpret_cast<IrInstructionAllocaSrc *>(result_loc->source_instruction); | | |
| 17732 | alloca_src->base.child = nullptr; | 18755 | alloca_src->base.child = nullptr; |
| 17733 | break; | 18756 | break; |
| 17734 | } | 18757 | } |
| ... | @@ -17744,18 +18767,18 @@ static void ir_reset_result(ResultLoc *result_loc) { | ... | @@ -17744,18 +18767,18 @@ static void ir_reset_result(ResultLoc *result_loc) { |
| 17744 | } | 18767 | } |
| 17745 | } | 18768 | } |
| 17746 | | 18769 | |
| 17747 | static IrInstruction *ir_analyze_instruction_reset_result(IrAnalyze *ira, IrInstructionResetResult *instruction) { | 18770 | static IrInstGen *ir_analyze_instruction_reset_result(IrAnalyze *ira, IrInstSrcResetResult *instruction) { |
| 17748 | ir_reset_result(instruction->result_loc); | 18771 | ir_reset_result(instruction->result_loc); |
| 17749 | return ir_const_void(ira, &instruction->base); | 18772 | return ir_const_void(ira, &instruction->base.base); |
| 17750 | } | 18773 | } |
| 17751 | | 18774 | |
| 17752 | static IrInstruction *get_async_call_result_loc(IrAnalyze *ira, IrInstruction *source_instr, | 18775 | static IrInstGen *get_async_call_result_loc(IrAnalyze *ira, IrInst* source_instr, |
| 17753 | ZigType *fn_ret_type, bool is_async_call_builtin, IrInstruction **args_ptr, size_t args_len, | 18776 | ZigType *fn_ret_type, bool is_async_call_builtin, IrInstGen **args_ptr, size_t args_len, |
| 17754 | IrInstruction *ret_ptr_uncasted) | 18777 | IrInstGen *ret_ptr_uncasted) |
| 17755 | { | 18778 | { |
| 17756 | ir_assert(is_async_call_builtin, source_instr); | 18779 | ir_assert(is_async_call_builtin, source_instr); |
| 17757 | if (type_is_invalid(ret_ptr_uncasted->value->type)) | 18780 | if (type_is_invalid(ret_ptr_uncasted->value->type)) |
| 17758 | return ira->codegen->invalid_instruction; | 18781 | return ira->codegen->invalid_inst_gen; |
| 17759 | if (ret_ptr_uncasted->value->type->id == ZigTypeIdVoid) { | 18782 | if (ret_ptr_uncasted->value->type->id == ZigTypeIdVoid) { |
| 17760 | // Result location will be inside the async frame. | 18783 | // Result location will be inside the async frame. |
| 17761 | return nullptr; | 18784 | return nullptr; |
| ... | @@ -17763,57 +18786,57 @@ static IrInstruction *get_async_call_result_loc(IrAnalyze *ira, IrInstruction *s | ... | @@ -17763,57 +18786,57 @@ static IrInstruction *get_async_call_result_loc(IrAnalyze *ira, IrInstruction *s |
| 17763 | return ir_implicit_cast(ira, ret_ptr_uncasted, get_pointer_to_type(ira->codegen, fn_ret_type, false)); | 18786 | return ir_implicit_cast(ira, ret_ptr_uncasted, get_pointer_to_type(ira->codegen, fn_ret_type, false)); |
| 17764 | } | 18787 | } |
| 17765 | | 18788 | |
| 17766 | static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstruction *source_instr, ZigFn *fn_entry, | 18789 | static IrInstGen *ir_analyze_async_call(IrAnalyze *ira, IrInst* source_instr, ZigFn *fn_entry, |
| 17767 | ZigType *fn_type, IrInstruction *fn_ref, IrInstruction **casted_args, size_t arg_count, | 18790 | ZigType *fn_type, IrInstGen *fn_ref, IrInstGen **casted_args, size_t arg_count, |
| 17768 | IrInstruction *casted_new_stack, bool is_async_call_builtin, IrInstruction *ret_ptr_uncasted, | 18791 | IrInstGen *casted_new_stack, bool is_async_call_builtin, IrInstGen *ret_ptr_uncasted, |
| 17769 | ResultLoc *call_result_loc) | 18792 | ResultLoc *call_result_loc) |
| 17770 | { | 18793 | { |
| 17771 | if (fn_entry == nullptr) { | 18794 | if (fn_entry == nullptr) { |
| 17772 | if (fn_type->data.fn.fn_type_id.cc != CallingConventionAsync) { | 18795 | if (fn_type->data.fn.fn_type_id.cc != CallingConventionAsync) { |
| 17773 | ir_add_error(ira, fn_ref, | 18796 | ir_add_error(ira, &fn_ref->base, |
| 17774 | buf_sprintf("expected async function, found '%s'", buf_ptr(&fn_type->name))); | 18797 | buf_sprintf("expected async function, found '%s'", buf_ptr(&fn_type->name))); |
| 17775 | return ira->codegen->invalid_instruction; | 18798 | return ira->codegen->invalid_inst_gen; |
| 17776 | } | 18799 | } |
| 17777 | if (casted_new_stack == nullptr) { | 18800 | if (casted_new_stack == nullptr) { |
| 17778 | ir_add_error(ira, fn_ref, buf_sprintf("function is not comptime-known; @asyncCall required")); | 18801 | ir_add_error(ira, &fn_ref->base, buf_sprintf("function is not comptime-known; @asyncCall required")); |
| 17779 | return ira->codegen->invalid_instruction; | 18802 | return ira->codegen->invalid_inst_gen; |
| 17780 | } | 18803 | } |
| 17781 | } | 18804 | } |
| 17782 | if (casted_new_stack != nullptr) { | 18805 | if (casted_new_stack != nullptr) { |
| 17783 | ZigType *fn_ret_type = fn_type->data.fn.fn_type_id.return_type; | 18806 | ZigType *fn_ret_type = fn_type->data.fn.fn_type_id.return_type; |
| 17784 | IrInstruction *ret_ptr = get_async_call_result_loc(ira, source_instr, fn_ret_type, is_async_call_builtin, | 18807 | IrInstGen *ret_ptr = get_async_call_result_loc(ira, source_instr, fn_ret_type, is_async_call_builtin, |
| 17785 | casted_args, arg_count, ret_ptr_uncasted); | 18808 | casted_args, arg_count, ret_ptr_uncasted); |
| 17786 | if (ret_ptr != nullptr && type_is_invalid(ret_ptr->value->type)) | 18809 | if (ret_ptr != nullptr && type_is_invalid(ret_ptr->value->type)) |
| 17787 | return ira->codegen->invalid_instruction; | 18810 | return ira->codegen->invalid_inst_gen; |
| 17788 | | 18811 | |
| 17789 | ZigType *anyframe_type = get_any_frame_type(ira->codegen, fn_ret_type); | 18812 | ZigType *anyframe_type = get_any_frame_type(ira->codegen, fn_ret_type); |
| 17790 | | 18813 | |
| 17791 | IrInstructionCallGen *call_gen = ir_build_call_gen(ira, source_instr, fn_entry, fn_ref, | 18814 | IrInstGenCall *call_gen = ir_build_call_gen(ira, source_instr, fn_entry, fn_ref, |
| 17792 | arg_count, casted_args, CallModifierAsync, casted_new_stack, | 18815 | arg_count, casted_args, CallModifierAsync, casted_new_stack, |
| 17793 | is_async_call_builtin, ret_ptr, anyframe_type); | 18816 | is_async_call_builtin, ret_ptr, anyframe_type); |
| 17794 | return &call_gen->base; | 18817 | return &call_gen->base; |
| 17795 | } else { | 18818 | } else { |
| 17796 | ZigType *frame_type = get_fn_frame_type(ira->codegen, fn_entry); | 18819 | ZigType *frame_type = get_fn_frame_type(ira->codegen, fn_entry); |
| 17797 | IrInstruction *result_loc = ir_resolve_result(ira, source_instr, call_result_loc, | 18820 | IrInstGen *result_loc = ir_resolve_result(ira, source_instr, call_result_loc, |
| 17798 | frame_type, nullptr, true, false); | 18821 | frame_type, nullptr, true, false); |
| 17799 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { | 18822 | if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) { |
| 17800 | return result_loc; | 18823 | return result_loc; |
| 17801 | } | 18824 | } |
| 17802 | result_loc = ir_implicit_cast(ira, result_loc, get_pointer_to_type(ira->codegen, frame_type, false)); | 18825 | result_loc = ir_implicit_cast(ira, result_loc, get_pointer_to_type(ira->codegen, frame_type, false)); |
| 17803 | if (type_is_invalid(result_loc->value->type)) | 18826 | if (type_is_invalid(result_loc->value->type)) |
| 17804 | return ira->codegen->invalid_instruction; | 18827 | return ira->codegen->invalid_inst_gen; |
| 17805 | return &ir_build_call_gen(ira, source_instr, fn_entry, fn_ref, arg_count, | 18828 | return &ir_build_call_gen(ira, source_instr, fn_entry, fn_ref, arg_count, |
| 17806 | casted_args, CallModifierAsync, casted_new_stack, | 18829 | casted_args, CallModifierAsync, casted_new_stack, |
| 17807 | is_async_call_builtin, result_loc, frame_type)->base; | 18830 | is_async_call_builtin, result_loc, frame_type)->base; |
| 17808 | } | 18831 | } |
| 17809 | } | 18832 | } |
| 17810 | static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node, | 18833 | static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node, |
| 17811 | IrInstruction *arg, Scope **exec_scope, size_t *next_proto_i) | 18834 | IrInstGen *arg, Scope **exec_scope, size_t *next_proto_i) |
| 17812 | { | 18835 | { |
| 17813 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(*next_proto_i); | 18836 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(*next_proto_i); |
| 17814 | assert(param_decl_node->type == NodeTypeParamDecl); | 18837 | assert(param_decl_node->type == NodeTypeParamDecl); |
| 17815 | | 18838 | |
| 17816 | IrInstruction *casted_arg; | 18839 | IrInstGen *casted_arg; |
| 17817 | if (param_decl_node->data.param_decl.var_token == nullptr) { | 18840 | if (param_decl_node->data.param_decl.var_token == nullptr) { |
| 17818 | AstNode *param_type_node = param_decl_node->data.param_decl.type; | 18841 | AstNode *param_type_node = param_decl_node->data.param_decl.type; |
| 17819 | ZigType *param_type = ir_analyze_type_expr(ira, *exec_scope, param_type_node); | 18842 | ZigType *param_type = ir_analyze_type_expr(ira, *exec_scope, param_type_node); |
| ... | @@ -17841,15 +18864,15 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node | ... | @@ -17841,15 +18864,15 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node |
| 17841 | } | 18864 | } |
| 17842 | | 18865 | |
| 17843 | static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_node, | 18866 | static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_node, |
| 17844 | IrInstruction *arg, Scope **child_scope, size_t *next_proto_i, | 18867 | IrInstGen *arg, Scope **child_scope, size_t *next_proto_i, |
| 17845 | GenericFnTypeId *generic_id, FnTypeId *fn_type_id, IrInstruction **casted_args, | 18868 | GenericFnTypeId *generic_id, FnTypeId *fn_type_id, IrInstGen **casted_args, |
| 17846 | ZigFn *impl_fn) | 18869 | ZigFn *impl_fn) |
| 17847 | { | 18870 | { |
| 17848 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(*next_proto_i); | 18871 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(*next_proto_i); |
| 17849 | assert(param_decl_node->type == NodeTypeParamDecl); | 18872 | assert(param_decl_node->type == NodeTypeParamDecl); |
| 17850 | bool is_var_args = param_decl_node->data.param_decl.is_var_args; | 18873 | bool is_var_args = param_decl_node->data.param_decl.is_var_args; |
| 17851 | bool arg_part_of_generic_id = false; | 18874 | bool arg_part_of_generic_id = false; |
| 17852 | IrInstruction *casted_arg; | 18875 | IrInstGen *casted_arg; |
| 17853 | if (is_var_args) { | 18876 | if (is_var_args) { |
| 17854 | arg_part_of_generic_id = true; | 18877 | arg_part_of_generic_id = true; |
| 17855 | casted_arg = arg; | 18878 | casted_arg = arg; |
| ... | @@ -17909,7 +18932,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -17909,7 +18932,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 17909 | } else if (casted_arg->value->type->id == ZigTypeIdComptimeInt || | 18932 | } else if (casted_arg->value->type->id == ZigTypeIdComptimeInt || |
| 17910 | casted_arg->value->type->id == ZigTypeIdComptimeFloat) | 18933 | casted_arg->value->type->id == ZigTypeIdComptimeFloat) |
| 17911 | { | 18934 | { |
| 17912 | ir_add_error(ira, casted_arg, | 18935 | ir_add_error(ira, &casted_arg->base, |
| 17913 | buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/ziglang/zig/issues/557")); | 18936 | buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/ziglang/zig/issues/557")); |
| 17914 | return false; | 18937 | return false; |
| 17915 | } | 18938 | } |
| ... | @@ -17926,13 +18949,13 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -17926,13 +18949,13 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 17926 | return true; | 18949 | return true; |
| 17927 | } | 18950 | } |
| 17928 | | 18951 | |
| 17929 | static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, ZigVar *var) { | 18952 | static IrInstGen *ir_get_var_ptr(IrAnalyze *ira, IrInst *source_instr, ZigVar *var) { |
| 17930 | while (var->next_var != nullptr) { | 18953 | while (var->next_var != nullptr) { |
| 17931 | var = var->next_var; | 18954 | var = var->next_var; |
| 17932 | } | 18955 | } |
| 17933 | | 18956 | |
| 17934 | if (var->var_type == nullptr || type_is_invalid(var->var_type)) | 18957 | if (var->var_type == nullptr || type_is_invalid(var->var_type)) |
| 17935 | return ira->codegen->invalid_instruction; | 18958 | return ira->codegen->invalid_inst_gen; |
| 17936 | | 18959 | |
| 17937 | bool is_volatile = false; | 18960 | bool is_volatile = false; |
| 17938 | ZigType *var_ptr_type = get_pointer_to_type_extra(ira->codegen, var->var_type, | 18961 | ZigType *var_ptr_type = get_pointer_to_type_extra(ira->codegen, var->var_type, |
| ... | @@ -17945,8 +18968,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, | ... | @@ -17945,8 +18968,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 17945 | bool comptime_var_mem = ir_get_var_is_comptime(var); | 18968 | bool comptime_var_mem = ir_get_var_is_comptime(var); |
| 17946 | bool linkage_makes_it_runtime = var->decl_node->data.variable_declaration.is_extern; | 18969 | bool linkage_makes_it_runtime = var->decl_node->data.variable_declaration.is_extern; |
| 17947 | | 18970 | |
| 17948 | IrInstruction *result = ir_build_var_ptr(&ira->new_irb, | 18971 | IrInstGen *result = ir_build_var_ptr_gen(ira, source_instr, var); |
| 17949 | instruction->scope, instruction->source_node, var); | | |
| 17950 | result->value->type = var_ptr_type; | 18972 | result->value->type = var_ptr_type; |
| 17951 | | 18973 | |
| 17952 | if (!linkage_makes_it_runtime && !var->is_thread_local && value_is_comptime(var->const_value)) { | 18974 | if (!linkage_makes_it_runtime && !var->is_thread_local && value_is_comptime(var->const_value)) { |
| ... | @@ -17982,7 +19004,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, | ... | @@ -17982,7 +19004,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 17982 | } | 19004 | } |
| 17983 | | 19005 | |
| 17984 | // This function is called when a comptime value becomes accessible at runtime. | 19006 | // This function is called when a comptime value becomes accessible at runtime. |
| 17985 | static void mark_comptime_value_escape(IrAnalyze *ira, IrInstruction *source_instr, ZigValue *val) { | 19007 | static void mark_comptime_value_escape(IrAnalyze *ira, IrInst* source_instr, ZigValue *val) { |
| 17986 | ir_assert(value_is_comptime(val), source_instr); | 19008 | ir_assert(value_is_comptime(val), source_instr); |
| 17987 | if (val->special == ConstValSpecialUndef) | 19009 | if (val->special == ConstValSpecialUndef) |
| 17988 | return; | 19010 | return; |
| ... | @@ -17995,8 +19017,8 @@ static void mark_comptime_value_escape(IrAnalyze *ira, IrInstruction *source_ins | ... | @@ -17995,8 +19017,8 @@ static void mark_comptime_value_escape(IrAnalyze *ira, IrInstruction *source_ins |
| 17995 | } | 19017 | } |
| 17996 | } | 19018 | } |
| 17997 | | 19019 | |
| 17998 | static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source_instr, | 19020 | static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, IrInst* source_instr, |
| 17999 | IrInstruction *ptr, IrInstruction *uncasted_value, bool allow_write_through_const) | 19021 | IrInstGen *ptr, IrInstGen *uncasted_value, bool allow_write_through_const) |
| 18000 | { | 19022 | { |
| 18001 | assert(ptr->value->type->id == ZigTypeIdPointer); | 19023 | assert(ptr->value->type->id == ZigTypeIdPointer); |
| 18002 | | 19024 | |
| ... | @@ -18005,24 +19027,24 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -18005,24 +19027,24 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 18005 | uncasted_value->value->type->id == ZigTypeIdErrorSet) | 19027 | uncasted_value->value->type->id == ZigTypeIdErrorSet) |
| 18006 | { | 19028 | { |
| 18007 | ir_add_error(ira, source_instr, buf_sprintf("error is discarded")); | 19029 | ir_add_error(ira, source_instr, buf_sprintf("error is discarded")); |
| 18008 | return ira->codegen->invalid_instruction; | 19030 | return ira->codegen->invalid_inst_gen; |
| 18009 | } | 19031 | } |
| 18010 | return ir_const_void(ira, source_instr); | 19032 | return ir_const_void(ira, source_instr); |
| 18011 | } | 19033 | } |
| 18012 | | 19034 | |
| 18013 | if (ptr->value->type->data.pointer.is_const && !allow_write_through_const) { | 19035 | if (ptr->value->type->data.pointer.is_const && !allow_write_through_const) { |
| 18014 | ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); | 19036 | ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); |
| 18015 | return ira->codegen->invalid_instruction; | 19037 | return ira->codegen->invalid_inst_gen; |
| 18016 | } | 19038 | } |
| 18017 | | 19039 | |
| 18018 | ZigType *child_type = ptr->value->type->data.pointer.child_type; | 19040 | ZigType *child_type = ptr->value->type->data.pointer.child_type; |
| 18019 | IrInstruction *value = ir_implicit_cast(ira, uncasted_value, child_type); | 19041 | IrInstGen *value = ir_implicit_cast(ira, uncasted_value, child_type); |
| 18020 | if (value == ira->codegen->invalid_instruction) | 19042 | if (type_is_invalid(value->value->type)) |
| 18021 | return ira->codegen->invalid_instruction; | 19043 | return ira->codegen->invalid_inst_gen; |
| 18022 | | 19044 | |
| 18023 | switch (type_has_one_possible_value(ira->codegen, child_type)) { | 19045 | switch (type_has_one_possible_value(ira->codegen, child_type)) { |
| 18024 | case OnePossibleValueInvalid: | 19046 | case OnePossibleValueInvalid: |
| 18025 | return ira->codegen->invalid_instruction; | 19047 | return ira->codegen->invalid_inst_gen; |
| 18026 | case OnePossibleValueYes: | 19048 | case OnePossibleValueYes: |
| 18027 | return ir_const_void(ira, source_instr); | 19049 | return ir_const_void(ira, source_instr); |
| 18028 | case OnePossibleValueNo: | 19050 | case OnePossibleValueNo: |
| ... | @@ -18032,7 +19054,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -18032,7 +19054,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 18032 | if (instr_is_comptime(ptr) && ptr->value->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 19054 | if (instr_is_comptime(ptr) && ptr->value->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 18033 | if (!allow_write_through_const && ptr->value->data.x_ptr.mut == ConstPtrMutComptimeConst) { | 19055 | if (!allow_write_through_const && ptr->value->data.x_ptr.mut == ConstPtrMutComptimeConst) { |
| 18034 | ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); | 19056 | ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); |
| 18035 | return ira->codegen->invalid_instruction; | 19057 | return ira->codegen->invalid_inst_gen; |
| 18036 | } | 19058 | } |
| 18037 | if ((allow_write_through_const && ptr->value->data.x_ptr.mut == ConstPtrMutComptimeConst) || | 19059 | if ((allow_write_through_const && ptr->value->data.x_ptr.mut == ConstPtrMutComptimeConst) || |
| 18038 | ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar || | 19060 | ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar || |
| ... | @@ -18041,7 +19063,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -18041,7 +19063,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 18041 | if (instr_is_comptime(value)) { | 19063 | if (instr_is_comptime(value)) { |
| 18042 | ZigValue *dest_val = const_ptr_pointee(ira, ira->codegen, ptr->value, source_instr->source_node); | 19064 | ZigValue *dest_val = const_ptr_pointee(ira, ira->codegen, ptr->value, source_instr->source_node); |
| 18043 | if (dest_val == nullptr) | 19065 | if (dest_val == nullptr) |
| 18044 | return ira->codegen->invalid_instruction; | 19066 | return ira->codegen->invalid_inst_gen; |
| 18045 | if (dest_val->special != ConstValSpecialRuntime) { | 19067 | if (dest_val->special != ConstValSpecialRuntime) { |
| 18046 | copy_const_val(dest_val, value->value); | 19068 | copy_const_val(dest_val, value->value); |
| 18047 | | 19069 | |
| ... | @@ -18061,7 +19083,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -18061,7 +19083,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 18061 | ZigValue *dest_val = const_ptr_pointee_unchecked(ira->codegen, ptr->value); | 19083 | ZigValue *dest_val = const_ptr_pointee_unchecked(ira->codegen, ptr->value); |
| 18062 | dest_val->type = ira->codegen->builtin_types.entry_invalid; | 19084 | dest_val->type = ira->codegen->builtin_types.entry_invalid; |
| 18063 | | 19085 | |
| 18064 | return ira->codegen->invalid_instruction; | 19086 | return ira->codegen->invalid_inst_gen; |
| 18065 | } | 19087 | } |
| 18066 | } | 19088 | } |
| 18067 | } | 19089 | } |
| ... | @@ -18074,15 +19096,15 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -18074,15 +19096,15 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 18074 | | 19096 | |
| 18075 | switch (type_requires_comptime(ira->codegen, child_type)) { | 19097 | switch (type_requires_comptime(ira->codegen, child_type)) { |
| 18076 | case ReqCompTimeInvalid: | 19098 | case ReqCompTimeInvalid: |
| 18077 | return ira->codegen->invalid_instruction; | 19099 | return ira->codegen->invalid_inst_gen; |
| 18078 | case ReqCompTimeYes: | 19100 | case ReqCompTimeYes: |
| 18079 | switch (type_has_one_possible_value(ira->codegen, ptr->value->type)) { | 19101 | switch (type_has_one_possible_value(ira->codegen, ptr->value->type)) { |
| 18080 | case OnePossibleValueInvalid: | 19102 | case OnePossibleValueInvalid: |
| 18081 | return ira->codegen->invalid_instruction; | 19103 | return ira->codegen->invalid_inst_gen; |
| 18082 | case OnePossibleValueNo: | 19104 | case OnePossibleValueNo: |
| 18083 | ir_add_error(ira, source_instr, | 19105 | ir_add_error(ira, source_instr, |
| 18084 | buf_sprintf("cannot store runtime value in type '%s'", buf_ptr(&child_type->name))); | 19106 | buf_sprintf("cannot store runtime value in type '%s'", buf_ptr(&child_type->name))); |
| 18085 | return ira->codegen->invalid_instruction; | 19107 | return ira->codegen->invalid_inst_gen; |
| 18086 | case OnePossibleValueYes: | 19108 | case OnePossibleValueYes: |
| 18087 | return ir_const_void(ira, source_instr); | 19109 | return ir_const_void(ira, source_instr); |
| 18088 | } | 19110 | } |
| ... | @@ -18096,30 +19118,28 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -18096,30 +19118,28 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 18096 | } | 19118 | } |
| 18097 | | 19119 | |
| 18098 | // If this is a store to a pointer with a runtime-known vector index, | 19120 | // If this is a store to a pointer with a runtime-known vector index, |
| 18099 | // we have to figure out the IrInstruction which represents the index and | 19121 | // we have to figure out the IrInstGen which represents the index and |
| 18100 | // emit a IrInstructionVectorStoreElem, or emit a compile error | 19122 | // emit a IrInstGenVectorStoreElem, or emit a compile error |
| 18101 | // explaining why it is impossible for this store to work. Which is that | 19123 | // explaining why it is impossible for this store to work. Which is that |
| 18102 | // the pointer address is of the vector; without the element index being known | 19124 | // the pointer address is of the vector; without the element index being known |
| 18103 | // we cannot properly perform the insertion. | 19125 | // we cannot properly perform the insertion. |
| 18104 | if (ptr->value->type->data.pointer.vector_index == VECTOR_INDEX_RUNTIME) { | 19126 | if (ptr->value->type->data.pointer.vector_index == VECTOR_INDEX_RUNTIME) { |
| 18105 | if (ptr->id == IrInstructionIdElemPtr) { | 19127 | if (ptr->id == IrInstGenIdElemPtr) { |
| 18106 | IrInstructionElemPtr *elem_ptr = (IrInstructionElemPtr *)ptr; | 19128 | IrInstGenElemPtr *elem_ptr = (IrInstGenElemPtr *)ptr; |
| 18107 | return ir_build_vector_store_elem(ira, source_instr, elem_ptr->array_ptr, | 19129 | return ir_build_vector_store_elem(ira, source_instr, elem_ptr->array_ptr, |
| 18108 | elem_ptr->elem_index, value); | 19130 | elem_ptr->elem_index, value); |
| 18109 | } | 19131 | } |
| 18110 | ir_add_error(ira, ptr, | 19132 | ir_add_error(ira, &ptr->base, |
| 18111 | buf_sprintf("unable to determine vector element index of type '%s'", | 19133 | buf_sprintf("unable to determine vector element index of type '%s'", |
| 18112 | buf_ptr(&ptr->value->type->name))); | 19134 | buf_ptr(&ptr->value->type->name))); |
| 18113 | return ira->codegen->invalid_instruction; | 19135 | return ira->codegen->invalid_inst_gen; |
| 18114 | } | 19136 | } |
| 18115 | | 19137 | |
| 18116 | IrInstructionStorePtr *store_ptr = ir_build_store_ptr(&ira->new_irb, source_instr->scope, | 19138 | return ir_build_store_ptr_gen(ira, source_instr, ptr, value); |
| 18117 | source_instr->source_node, ptr, value); | | |
| 18118 | return &store_ptr->base; | | |
| 18119 | } | 19139 | } |
| 18120 | | 19140 | |
| 18121 | static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstruction *source_instr, | 19141 | static IrInstGen *analyze_casted_new_stack(IrAnalyze *ira, IrInst* source_instr, |
| 18122 | IrInstruction *new_stack, bool is_async_call_builtin, ZigFn *fn_entry) | 19142 | IrInstGen *new_stack, bool is_async_call_builtin, ZigFn *fn_entry) |
| 18123 | { | 19143 | { |
| 18124 | if (new_stack == nullptr) | 19144 | if (new_stack == nullptr) |
| 18125 | return nullptr; | 19145 | return nullptr; |
| ... | @@ -18148,11 +19168,11 @@ static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstruction *so | ... | @@ -18148,11 +19168,11 @@ static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstruction *so |
| 18148 | } | 19168 | } |
| 18149 | } | 19169 | } |
| 18150 | | 19170 | |
| 18151 | static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_instr, | 19171 | static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 18152 | ZigFn *fn_entry, ZigType *fn_type, IrInstruction *fn_ref, | 19172 | ZigFn *fn_entry, ZigType *fn_type, IrInstGen *fn_ref, |
| 18153 | IrInstruction *first_arg_ptr, CallModifier modifier, | 19173 | IrInstGen *first_arg_ptr, CallModifier modifier, |
| 18154 | IrInstruction *new_stack, bool is_async_call_builtin, | 19174 | IrInstGen *new_stack, bool is_async_call_builtin, |
| 18155 | IrInstruction **args_ptr, size_t args_len, IrInstruction *ret_ptr, ResultLoc *call_result_loc) | 19175 | IrInstGen **args_ptr, size_t args_len, IrInstGen *ret_ptr, ResultLoc *call_result_loc) |
| 18156 | { | 19176 | { |
| 18157 | Error err; | 19177 | Error err; |
| 18158 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; | 19178 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; |
| ... | @@ -18173,11 +19193,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18173,11 +19193,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18173 | AstNode *fn_proto_node = fn_entry ? fn_entry->proto_node : nullptr;; | 19193 | AstNode *fn_proto_node = fn_entry ? fn_entry->proto_node : nullptr;; |
| 18174 | | 19194 | |
| 18175 | if (fn_type_id->cc == CallingConventionNaked) { | 19195 | if (fn_type_id->cc == CallingConventionNaked) { |
| 18176 | ErrorMsg *msg = ir_add_error(ira, fn_ref, buf_sprintf("unable to call function with naked calling convention")); | 19196 | ErrorMsg *msg = ir_add_error(ira, &fn_ref->base, buf_sprintf("unable to call function with naked calling convention")); |
| 18177 | if (fn_proto_node) { | 19197 | if (fn_proto_node) { |
| 18178 | add_error_note(ira->codegen, msg, fn_proto_node, buf_sprintf("declared here")); | 19198 | add_error_note(ira->codegen, msg, fn_proto_node, buf_sprintf("declared here")); |
| 18179 | } | 19199 | } |
| 18180 | return ira->codegen->invalid_instruction; | 19200 | return ira->codegen->invalid_inst_gen; |
| 18181 | } | 19201 | } |
| 18182 | | 19202 | |
| 18183 | if (fn_type_id->is_var_args) { | 19203 | if (fn_type_id->is_var_args) { |
| ... | @@ -18188,7 +19208,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18188,7 +19208,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18188 | add_error_note(ira->codegen, msg, fn_proto_node, | 19208 | add_error_note(ira->codegen, msg, fn_proto_node, |
| 18189 | buf_sprintf("declared here")); | 19209 | buf_sprintf("declared here")); |
| 18190 | } | 19210 | } |
| 18191 | return ira->codegen->invalid_instruction; | 19211 | return ira->codegen->invalid_inst_gen; |
| 18192 | } | 19212 | } |
| 18193 | } else if (src_param_count != call_param_count) { | 19213 | } else if (src_param_count != call_param_count) { |
| 18194 | ErrorMsg *msg = ir_add_error_node(ira, source_node, | 19214 | ErrorMsg *msg = ir_add_error_node(ira, source_node, |
| ... | @@ -18197,18 +19217,18 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18197,18 +19217,18 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18197 | add_error_note(ira->codegen, msg, fn_proto_node, | 19217 | add_error_note(ira->codegen, msg, fn_proto_node, |
| 18198 | buf_sprintf("declared here")); | 19218 | buf_sprintf("declared here")); |
| 18199 | } | 19219 | } |
| 18200 | return ira->codegen->invalid_instruction; | 19220 | return ira->codegen->invalid_inst_gen; |
| 18201 | } | 19221 | } |
| 18202 | | 19222 | |
| 18203 | if (modifier == CallModifierCompileTime) { | 19223 | if (modifier == CallModifierCompileTime) { |
| 18204 | // No special handling is needed for compile time evaluation of generic functions. | 19224 | // No special handling is needed for compile time evaluation of generic functions. |
| 18205 | if (!fn_entry || fn_entry->body_node == nullptr) { | 19225 | if (!fn_entry || fn_entry->body_node == nullptr) { |
| 18206 | ir_add_error(ira, fn_ref, buf_sprintf("unable to evaluate constant expression")); | 19226 | ir_add_error(ira, &fn_ref->base, buf_sprintf("unable to evaluate constant expression")); |
| 18207 | return ira->codegen->invalid_instruction; | 19227 | return ira->codegen->invalid_inst_gen; |
| 18208 | } | 19228 | } |
| 18209 | | 19229 | |
| 18210 | if (!ir_emit_backward_branch(ira, source_instr)) | 19230 | if (!ir_emit_backward_branch(ira, source_instr)) |
| 18211 | return ira->codegen->invalid_instruction; | 19231 | return ira->codegen->invalid_inst_gen; |
| 18212 | | 19232 | |
| 18213 | // Fork a scope of the function with known values for the parameters. | 19233 | // Fork a scope of the function with known values for the parameters. |
| 18214 | Scope *exec_scope = &fn_entry->fndef_scope->base; | 19234 | Scope *exec_scope = &fn_entry->fndef_scope->base; |
| ... | @@ -18221,40 +19241,40 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18221,40 +19241,40 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18221 | if (fn_type_id->next_param_index >= 1) { | 19241 | if (fn_type_id->next_param_index >= 1) { |
| 18222 | ZigType *param_type = fn_type_id->param_info[next_proto_i].type; | 19242 | ZigType *param_type = fn_type_id->param_info[next_proto_i].type; |
| 18223 | if (type_is_invalid(param_type)) | 19243 | if (type_is_invalid(param_type)) |
| 18224 | return ira->codegen->invalid_instruction; | 19244 | return ira->codegen->invalid_inst_gen; |
| 18225 | first_arg_known_bare = param_type->id != ZigTypeIdPointer; | 19245 | first_arg_known_bare = param_type->id != ZigTypeIdPointer; |
| 18226 | } | 19246 | } |
| 18227 | | 19247 | |
| 18228 | IrInstruction *first_arg; | 19248 | IrInstGen *first_arg; |
| 18229 | if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) { | 19249 | if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) { |
| 18230 | first_arg = first_arg_ptr; | 19250 | first_arg = first_arg_ptr; |
| 18231 | } else { | 19251 | } else { |
| 18232 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); | 19252 | first_arg = ir_get_deref(ira, &first_arg_ptr->base, first_arg_ptr, nullptr); |
| 18233 | if (type_is_invalid(first_arg->value->type)) | 19253 | if (type_is_invalid(first_arg->value->type)) |
| 18234 | return ira->codegen->invalid_instruction; | 19254 | return ira->codegen->invalid_inst_gen; |
| 18235 | } | 19255 | } |
| 18236 | | 19256 | |
| 18237 | if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, first_arg, &exec_scope, &next_proto_i)) | 19257 | if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, first_arg, &exec_scope, &next_proto_i)) |
| 18238 | return ira->codegen->invalid_instruction; | 19258 | return ira->codegen->invalid_inst_gen; |
| 18239 | } | 19259 | } |
| 18240 | | 19260 | |
| 18241 | for (size_t call_i = 0; call_i < args_len; call_i += 1) { | 19261 | for (size_t call_i = 0; call_i < args_len; call_i += 1) { |
| 18242 | IrInstruction *old_arg = args_ptr[call_i]; | 19262 | IrInstGen *old_arg = args_ptr[call_i]; |
| 18243 | | 19263 | |
| 18244 | if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, old_arg, &exec_scope, &next_proto_i)) | 19264 | if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, old_arg, &exec_scope, &next_proto_i)) |
| 18245 | return ira->codegen->invalid_instruction; | 19265 | return ira->codegen->invalid_inst_gen; |
| 18246 | } | 19266 | } |
| 18247 | | 19267 | |
| 18248 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; | 19268 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; |
| 18249 | ZigType *specified_return_type = ir_analyze_type_expr(ira, exec_scope, return_type_node); | 19269 | ZigType *specified_return_type = ir_analyze_type_expr(ira, exec_scope, return_type_node); |
| 18250 | if (type_is_invalid(specified_return_type)) | 19270 | if (type_is_invalid(specified_return_type)) |
| 18251 | return ira->codegen->invalid_instruction; | 19271 | return ira->codegen->invalid_inst_gen; |
| 18252 | ZigType *return_type; | 19272 | ZigType *return_type; |
| 18253 | ZigType *inferred_err_set_type = nullptr; | 19273 | ZigType *inferred_err_set_type = nullptr; |
| 18254 | if (fn_proto_node->data.fn_proto.auto_err_set) { | 19274 | if (fn_proto_node->data.fn_proto.auto_err_set) { |
| 18255 | inferred_err_set_type = get_auto_err_set_type(ira->codegen, fn_entry); | 19275 | inferred_err_set_type = get_auto_err_set_type(ira->codegen, fn_entry); |
| 18256 | if ((err = type_resolve(ira->codegen, specified_return_type, ResolveStatusSizeKnown))) | 19276 | if ((err = type_resolve(ira->codegen, specified_return_type, ResolveStatusSizeKnown))) |
| 18257 | return ira->codegen->invalid_instruction; | 19277 | return ira->codegen->invalid_inst_gen; |
| 18258 | return_type = get_error_union_type(ira->codegen, inferred_err_set_type, specified_return_type); | 19278 | return_type = get_error_union_type(ira->codegen, inferred_err_set_type, specified_return_type); |
| 18259 | } else { | 19279 | } else { |
| 18260 | return_type = specified_return_type; | 19280 | return_type = specified_return_type; |
| ... | @@ -18278,7 +19298,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18278,7 +19298,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18278 | fn_entry, nullptr, source_instr->source_node, nullptr, ira->new_irb.exec, return_type_node, | 19298 | fn_entry, nullptr, source_instr->source_node, nullptr, ira->new_irb.exec, return_type_node, |
| 18279 | UndefOk))) | 19299 | UndefOk))) |
| 18280 | { | 19300 | { |
| 18281 | return ira->codegen->invalid_instruction; | 19301 | return ira->codegen->invalid_inst_gen; |
| 18282 | } | 19302 | } |
| 18283 | destroy(result_ptr, "ZigValue"); | 19303 | destroy(result_ptr, "ZigValue"); |
| 18284 | result_ptr = nullptr; | 19304 | result_ptr = nullptr; |
| ... | @@ -18306,24 +19326,24 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18306,24 +19326,24 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18306 | } | 19326 | } |
| 18307 | | 19327 | |
| 18308 | if (type_is_invalid(result->type)) { | 19328 | if (type_is_invalid(result->type)) { |
| 18309 | return ira->codegen->invalid_instruction; | 19329 | return ira->codegen->invalid_inst_gen; |
| 18310 | } | 19330 | } |
| 18311 | } | 19331 | } |
| 18312 | | 19332 | |
| 18313 | IrInstruction *new_instruction = ir_const_move(ira, source_instr, result); | 19333 | IrInstGen *new_instruction = ir_const_move(ira, source_instr, result); |
| 18314 | return ir_finish_anal(ira, new_instruction); | 19334 | return ir_finish_anal(ira, new_instruction); |
| 18315 | } | 19335 | } |
| 18316 | | 19336 | |
| 18317 | if (fn_type->data.fn.is_generic) { | 19337 | if (fn_type->data.fn.is_generic) { |
| 18318 | if (!fn_entry) { | 19338 | if (!fn_entry) { |
| 18319 | ir_add_error(ira, fn_ref, | 19339 | ir_add_error(ira, &fn_ref->base, |
| 18320 | buf_sprintf("calling a generic function requires compile-time known function value")); | 19340 | buf_sprintf("calling a generic function requires compile-time known function value")); |
| 18321 | return ira->codegen->invalid_instruction; | 19341 | return ira->codegen->invalid_inst_gen; |
| 18322 | } | 19342 | } |
| 18323 | | 19343 | |
| 18324 | size_t new_fn_arg_count = first_arg_1_or_0 + args_len; | 19344 | size_t new_fn_arg_count = first_arg_1_or_0 + args_len; |
| 18325 | | 19345 | |
| 18326 | IrInstruction **casted_args = allocate<IrInstruction *>(new_fn_arg_count); | 19346 | IrInstGen **casted_args = allocate<IrInstGen *>(new_fn_arg_count); |
| 18327 | | 19347 | |
| 18328 | // Fork a scope of the function with known values for the parameters. | 19348 | // Fork a scope of the function with known values for the parameters. |
| 18329 | Scope *parent_scope = fn_entry->fndef_scope->base.parent; | 19349 | Scope *parent_scope = fn_entry->fndef_scope->base.parent; |
| ... | @@ -18352,30 +19372,30 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18352,30 +19372,30 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18352 | if (fn_type_id->next_param_index >= 1) { | 19372 | if (fn_type_id->next_param_index >= 1) { |
| 18353 | ZigType *param_type = fn_type_id->param_info[next_proto_i].type; | 19373 | ZigType *param_type = fn_type_id->param_info[next_proto_i].type; |
| 18354 | if (type_is_invalid(param_type)) | 19374 | if (type_is_invalid(param_type)) |
| 18355 | return ira->codegen->invalid_instruction; | 19375 | return ira->codegen->invalid_inst_gen; |
| 18356 | first_arg_known_bare = param_type->id != ZigTypeIdPointer; | 19376 | first_arg_known_bare = param_type->id != ZigTypeIdPointer; |
| 18357 | } | 19377 | } |
| 18358 | | 19378 | |
| 18359 | IrInstruction *first_arg; | 19379 | IrInstGen *first_arg; |
| 18360 | if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) { | 19380 | if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) { |
| 18361 | first_arg = first_arg_ptr; | 19381 | first_arg = first_arg_ptr; |
| 18362 | } else { | 19382 | } else { |
| 18363 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); | 19383 | first_arg = ir_get_deref(ira, &first_arg_ptr->base, first_arg_ptr, nullptr); |
| 18364 | if (type_is_invalid(first_arg->value->type)) | 19384 | if (type_is_invalid(first_arg->value->type)) |
| 18365 | return ira->codegen->invalid_instruction; | 19385 | return ira->codegen->invalid_inst_gen; |
| 18366 | } | 19386 | } |
| 18367 | | 19387 | |
| 18368 | if (!ir_analyze_fn_call_generic_arg(ira, fn_proto_node, first_arg, &impl_fn->child_scope, | 19388 | if (!ir_analyze_fn_call_generic_arg(ira, fn_proto_node, first_arg, &impl_fn->child_scope, |
| 18369 | &next_proto_i, generic_id, &inst_fn_type_id, casted_args, impl_fn)) | 19389 | &next_proto_i, generic_id, &inst_fn_type_id, casted_args, impl_fn)) |
| 18370 | { | 19390 | { |
| 18371 | return ira->codegen->invalid_instruction; | 19391 | return ira->codegen->invalid_inst_gen; |
| 18372 | } | 19392 | } |
| 18373 | } | 19393 | } |
| 18374 | | 19394 | |
| 18375 | ZigFn *parent_fn_entry = exec_fn_entry(ira->new_irb.exec); | 19395 | ZigFn *parent_fn_entry = ira->new_irb.exec->fn_entry; |
| 18376 | assert(parent_fn_entry); | 19396 | assert(parent_fn_entry); |
| 18377 | for (size_t call_i = 0; call_i < args_len; call_i += 1) { | 19397 | for (size_t call_i = 0; call_i < args_len; call_i += 1) { |
| 18378 | IrInstruction *arg = args_ptr[call_i]; | 19398 | IrInstGen *arg = args_ptr[call_i]; |
| 18379 | | 19399 | |
| 18380 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(next_proto_i); | 19400 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(next_proto_i); |
| 18381 | assert(param_decl_node->type == NodeTypeParamDecl); | 19401 | assert(param_decl_node->type == NodeTypeParamDecl); |
| ... | @@ -18383,7 +19403,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18383,7 +19403,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18383 | if (!ir_analyze_fn_call_generic_arg(ira, fn_proto_node, arg, &impl_fn->child_scope, | 19403 | if (!ir_analyze_fn_call_generic_arg(ira, fn_proto_node, arg, &impl_fn->child_scope, |
| 18384 | &next_proto_i, generic_id, &inst_fn_type_id, casted_args, impl_fn)) | 19404 | &next_proto_i, generic_id, &inst_fn_type_id, casted_args, impl_fn)) |
| 18385 | { | 19405 | { |
| 18386 | return ira->codegen->invalid_instruction; | 19406 | return ira->codegen->invalid_inst_gen; |
| 18387 | } | 19407 | } |
| 18388 | } | 19408 | } |
| 18389 | | 19409 | |
| ... | @@ -18397,9 +19417,9 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18397,9 +19417,9 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18397 | nullptr, nullptr, fn_proto_node->data.fn_proto.align_expr, nullptr, ira->new_irb.exec, | 19417 | nullptr, nullptr, fn_proto_node->data.fn_proto.align_expr, nullptr, ira->new_irb.exec, |
| 18398 | nullptr, UndefBad))) | 19418 | nullptr, UndefBad))) |
| 18399 | { | 19419 | { |
| 18400 | return ira->codegen->invalid_instruction; | 19420 | return ira->codegen->invalid_inst_gen; |
| 18401 | } | 19421 | } |
| 18402 | IrInstructionConst *const_instruction = ir_create_instruction_noval<IrInstructionConst>(&ira->new_irb, | 19422 | IrInstGenConst *const_instruction = ir_create_inst_noval<IrInstGenConst>(&ira->new_irb, |
| 18403 | impl_fn->child_scope, fn_proto_node->data.fn_proto.align_expr); | 19423 | impl_fn->child_scope, fn_proto_node->data.fn_proto.align_expr); |
| 18404 | const_instruction->base.value = align_result; | 19424 | const_instruction->base.value = align_result; |
| 18405 | destroy(result_ptr, "ZigValue"); | 19425 | destroy(result_ptr, "ZigValue"); |
| ... | @@ -18414,11 +19434,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18414,11 +19434,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18414 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; | 19434 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; |
| 18415 | ZigType *specified_return_type = ir_analyze_type_expr(ira, impl_fn->child_scope, return_type_node); | 19435 | ZigType *specified_return_type = ir_analyze_type_expr(ira, impl_fn->child_scope, return_type_node); |
| 18416 | if (type_is_invalid(specified_return_type)) | 19436 | if (type_is_invalid(specified_return_type)) |
| 18417 | return ira->codegen->invalid_instruction; | 19437 | return ira->codegen->invalid_inst_gen; |
| 18418 | if (fn_proto_node->data.fn_proto.auto_err_set) { | 19438 | if (fn_proto_node->data.fn_proto.auto_err_set) { |
| 18419 | ZigType *inferred_err_set_type = get_auto_err_set_type(ira->codegen, impl_fn); | 19439 | ZigType *inferred_err_set_type = get_auto_err_set_type(ira->codegen, impl_fn); |
| 18420 | if ((err = type_resolve(ira->codegen, specified_return_type, ResolveStatusSizeKnown))) | 19440 | if ((err = type_resolve(ira->codegen, specified_return_type, ResolveStatusSizeKnown))) |
| 18421 | return ira->codegen->invalid_instruction; | 19441 | return ira->codegen->invalid_inst_gen; |
| 18422 | inst_fn_type_id.return_type = get_error_union_type(ira->codegen, inferred_err_set_type, specified_return_type); | 19442 | inst_fn_type_id.return_type = get_error_union_type(ira->codegen, inferred_err_set_type, specified_return_type); |
| 18423 | } else { | 19443 | } else { |
| 18424 | inst_fn_type_id.return_type = specified_return_type; | 19444 | inst_fn_type_id.return_type = specified_return_type; |
| ... | @@ -18431,7 +19451,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18431,7 +19451,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18431 | CallModifierCompileTime, new_stack, is_async_call_builtin, args_ptr, args_len, | 19451 | CallModifierCompileTime, new_stack, is_async_call_builtin, args_ptr, args_len, |
| 18432 | ret_ptr, call_result_loc); | 19452 | ret_ptr, call_result_loc); |
| 18433 | case ReqCompTimeInvalid: | 19453 | case ReqCompTimeInvalid: |
| 18434 | return ira->codegen->invalid_instruction; | 19454 | return ira->codegen->invalid_inst_gen; |
| 18435 | case ReqCompTimeNo: | 19455 | case ReqCompTimeNo: |
| 18436 | break; | 19456 | break; |
| 18437 | } | 19457 | } |
| ... | @@ -18445,7 +19465,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18445,7 +19465,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18445 | // finish instantiating the function | 19465 | // finish instantiating the function |
| 18446 | impl_fn->type_entry = get_fn_type(ira->codegen, &inst_fn_type_id); | 19466 | impl_fn->type_entry = get_fn_type(ira->codegen, &inst_fn_type_id); |
| 18447 | if (type_is_invalid(impl_fn->type_entry)) | 19467 | if (type_is_invalid(impl_fn->type_entry)) |
| 18448 | return ira->codegen->invalid_instruction; | 19468 | return ira->codegen->invalid_inst_gen; |
| 18449 | | 19469 | |
| 18450 | impl_fn->ir_executable->source_node = source_instr->source_node; | 19470 | impl_fn->ir_executable->source_node = source_instr->source_node; |
| 18451 | impl_fn->ir_executable->parent_exec = ira->new_irb.exec; | 19471 | impl_fn->ir_executable->parent_exec = ira->new_irb.exec; |
| ... | @@ -18463,25 +19483,25 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18463,25 +19483,25 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18463 | parent_fn_entry->calls_or_awaits_errorable_fn = true; | 19483 | parent_fn_entry->calls_or_awaits_errorable_fn = true; |
| 18464 | } | 19484 | } |
| 18465 | | 19485 | |
| 18466 | IrInstruction *casted_new_stack = analyze_casted_new_stack(ira, source_instr, new_stack, | 19486 | IrInstGen *casted_new_stack = analyze_casted_new_stack(ira, source_instr, new_stack, |
| 18467 | is_async_call_builtin, impl_fn); | 19487 | is_async_call_builtin, impl_fn); |
| 18468 | if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value->type)) | 19488 | if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value->type)) |
| 18469 | return ira->codegen->invalid_instruction; | 19489 | return ira->codegen->invalid_inst_gen; |
| 18470 | | 19490 | |
| 18471 | size_t impl_param_count = impl_fn_type_id->param_count; | 19491 | size_t impl_param_count = impl_fn_type_id->param_count; |
| 18472 | if (modifier == CallModifierAsync) { | 19492 | if (modifier == CallModifierAsync) { |
| 18473 | IrInstruction *result = ir_analyze_async_call(ira, source_instr, impl_fn, impl_fn->type_entry, | 19493 | IrInstGen *result = ir_analyze_async_call(ira, source_instr, impl_fn, impl_fn->type_entry, |
| 18474 | nullptr, casted_args, impl_param_count, casted_new_stack, is_async_call_builtin, ret_ptr, | 19494 | nullptr, casted_args, impl_param_count, casted_new_stack, is_async_call_builtin, ret_ptr, |
| 18475 | call_result_loc); | 19495 | call_result_loc); |
| 18476 | return ir_finish_anal(ira, result); | 19496 | return ir_finish_anal(ira, result); |
| 18477 | } | 19497 | } |
| 18478 | | 19498 | |
| 18479 | IrInstruction *result_loc; | 19499 | IrInstGen *result_loc; |
| 18480 | if (handle_is_ptr(impl_fn_type_id->return_type)) { | 19500 | if (handle_is_ptr(impl_fn_type_id->return_type)) { |
| 18481 | result_loc = ir_resolve_result(ira, source_instr, call_result_loc, | 19501 | result_loc = ir_resolve_result(ira, source_instr, call_result_loc, |
| 18482 | impl_fn_type_id->return_type, nullptr, true, false); | 19502 | impl_fn_type_id->return_type, nullptr, true, false); |
| 18483 | if (result_loc != nullptr) { | 19503 | if (result_loc != nullptr) { |
| 18484 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { | 19504 | if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) { |
| 18485 | return result_loc; | 19505 | return result_loc; |
| 18486 | } | 19506 | } |
| 18487 | ZigType *res_child_type = result_loc->value->type->data.pointer.child_type; | 19507 | ZigType *res_child_type = result_loc->value->type->data.pointer.child_type; |
| ... | @@ -18497,7 +19517,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18497,7 +19517,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18497 | result_loc = get_async_call_result_loc(ira, source_instr, impl_fn_type_id->return_type, | 19517 | result_loc = get_async_call_result_loc(ira, source_instr, impl_fn_type_id->return_type, |
| 18498 | is_async_call_builtin, args_ptr, args_len, ret_ptr); | 19518 | is_async_call_builtin, args_ptr, args_len, ret_ptr); |
| 18499 | if (result_loc != nullptr && type_is_invalid(result_loc->value->type)) | 19519 | if (result_loc != nullptr && type_is_invalid(result_loc->value->type)) |
| 18500 | return ira->codegen->invalid_instruction; | 19520 | return ira->codegen->invalid_inst_gen; |
| 18501 | } else { | 19521 | } else { |
| 18502 | result_loc = nullptr; | 19522 | result_loc = nullptr; |
| 18503 | } | 19523 | } |
| ... | @@ -18506,11 +19526,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18506,11 +19526,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18506 | parent_fn_entry->inferred_async_node == nullptr && | 19526 | parent_fn_entry->inferred_async_node == nullptr && |
| 18507 | modifier != CallModifierNoAsync) | 19527 | modifier != CallModifierNoAsync) |
| 18508 | { | 19528 | { |
| 18509 | parent_fn_entry->inferred_async_node = fn_ref->source_node; | 19529 | parent_fn_entry->inferred_async_node = fn_ref->base.source_node; |
| 18510 | parent_fn_entry->inferred_async_fn = impl_fn; | 19530 | parent_fn_entry->inferred_async_fn = impl_fn; |
| 18511 | } | 19531 | } |
| 18512 | | 19532 | |
| 18513 | IrInstructionCallGen *new_call_instruction = ir_build_call_gen(ira, source_instr, | 19533 | IrInstGenCall *new_call_instruction = ir_build_call_gen(ira, source_instr, |
| 18514 | impl_fn, nullptr, impl_param_count, casted_args, modifier, casted_new_stack, | 19534 | impl_fn, nullptr, impl_param_count, casted_args, modifier, casted_new_stack, |
| 18515 | is_async_call_builtin, result_loc, impl_fn_type_id->return_type); | 19535 | is_async_call_builtin, result_loc, impl_fn_type_id->return_type); |
| 18516 | | 19536 | |
| ... | @@ -18521,7 +19541,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18521,7 +19541,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18521 | return ir_finish_anal(ira, &new_call_instruction->base); | 19541 | return ir_finish_anal(ira, &new_call_instruction->base); |
| 18522 | } | 19542 | } |
| 18523 | | 19543 | |
| 18524 | ZigFn *parent_fn_entry = exec_fn_entry(ira->new_irb.exec); | 19544 | ZigFn *parent_fn_entry = ira->new_irb.exec->fn_entry; |
| 18525 | assert(fn_type_id->return_type != nullptr); | 19545 | assert(fn_type_id->return_type != nullptr); |
| 18526 | assert(parent_fn_entry != nullptr); | 19546 | assert(parent_fn_entry != nullptr); |
| 18527 | if (fn_type_can_fail(fn_type_id)) { | 19547 | if (fn_type_can_fail(fn_type_id)) { |
| ... | @@ -18529,46 +19549,46 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18529,46 +19549,46 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18529 | } | 19549 | } |
| 18530 | | 19550 | |
| 18531 | | 19551 | |
| 18532 | IrInstruction **casted_args = allocate<IrInstruction *>(call_param_count); | 19552 | IrInstGen **casted_args = allocate<IrInstGen *>(call_param_count); |
| 18533 | size_t next_arg_index = 0; | 19553 | size_t next_arg_index = 0; |
| 18534 | if (first_arg_ptr) { | 19554 | if (first_arg_ptr) { |
| 18535 | assert(first_arg_ptr->value->type->id == ZigTypeIdPointer); | 19555 | assert(first_arg_ptr->value->type->id == ZigTypeIdPointer); |
| 18536 | | 19556 | |
| 18537 | ZigType *param_type = fn_type_id->param_info[next_arg_index].type; | 19557 | ZigType *param_type = fn_type_id->param_info[next_arg_index].type; |
| 18538 | if (type_is_invalid(param_type)) | 19558 | if (type_is_invalid(param_type)) |
| 18539 | return ira->codegen->invalid_instruction; | 19559 | return ira->codegen->invalid_inst_gen; |
| 18540 | | 19560 | |
| 18541 | IrInstruction *first_arg; | 19561 | IrInstGen *first_arg; |
| 18542 | if (param_type->id == ZigTypeIdPointer && | 19562 | if (param_type->id == ZigTypeIdPointer && |
| 18543 | handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) | 19563 | handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) |
| 18544 | { | 19564 | { |
| 18545 | first_arg = first_arg_ptr; | 19565 | first_arg = first_arg_ptr; |
| 18546 | } else { | 19566 | } else { |
| 18547 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); | 19567 | first_arg = ir_get_deref(ira, &first_arg_ptr->base, first_arg_ptr, nullptr); |
| 18548 | if (type_is_invalid(first_arg->value->type)) | 19568 | if (type_is_invalid(first_arg->value->type)) |
| 18549 | return ira->codegen->invalid_instruction; | 19569 | return ira->codegen->invalid_inst_gen; |
| 18550 | } | 19570 | } |
| 18551 | | 19571 | |
| 18552 | IrInstruction *casted_arg = ir_implicit_cast(ira, first_arg, param_type); | 19572 | IrInstGen *casted_arg = ir_implicit_cast(ira, first_arg, param_type); |
| 18553 | if (type_is_invalid(casted_arg->value->type)) | 19573 | if (type_is_invalid(casted_arg->value->type)) |
| 18554 | return ira->codegen->invalid_instruction; | 19574 | return ira->codegen->invalid_inst_gen; |
| 18555 | | 19575 | |
| 18556 | casted_args[next_arg_index] = casted_arg; | 19576 | casted_args[next_arg_index] = casted_arg; |
| 18557 | next_arg_index += 1; | 19577 | next_arg_index += 1; |
| 18558 | } | 19578 | } |
| 18559 | for (size_t call_i = 0; call_i < args_len; call_i += 1) { | 19579 | for (size_t call_i = 0; call_i < args_len; call_i += 1) { |
| 18560 | IrInstruction *old_arg = args_ptr[call_i]; | 19580 | IrInstGen *old_arg = args_ptr[call_i]; |
| 18561 | if (type_is_invalid(old_arg->value->type)) | 19581 | if (type_is_invalid(old_arg->value->type)) |
| 18562 | return ira->codegen->invalid_instruction; | 19582 | return ira->codegen->invalid_inst_gen; |
| 18563 | | 19583 | |
| 18564 | IrInstruction *casted_arg; | 19584 | IrInstGen *casted_arg; |
| 18565 | if (next_arg_index < src_param_count) { | 19585 | if (next_arg_index < src_param_count) { |
| 18566 | ZigType *param_type = fn_type_id->param_info[next_arg_index].type; | 19586 | ZigType *param_type = fn_type_id->param_info[next_arg_index].type; |
| 18567 | if (type_is_invalid(param_type)) | 19587 | if (type_is_invalid(param_type)) |
| 18568 | return ira->codegen->invalid_instruction; | 19588 | return ira->codegen->invalid_inst_gen; |
| 18569 | casted_arg = ir_implicit_cast(ira, old_arg, param_type); | 19589 | casted_arg = ir_implicit_cast(ira, old_arg, param_type); |
| 18570 | if (type_is_invalid(casted_arg->value->type)) | 19590 | if (type_is_invalid(casted_arg->value->type)) |
| 18571 | return ira->codegen->invalid_instruction; | 19591 | return ira->codegen->invalid_inst_gen; |
| 18572 | } else { | 19592 | } else { |
| 18573 | casted_arg = old_arg; | 19593 | casted_arg = old_arg; |
| 18574 | } | 19594 | } |
| ... | @@ -18581,21 +19601,21 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18581,21 +19601,21 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18581 | | 19601 | |
| 18582 | ZigType *return_type = fn_type_id->return_type; | 19602 | ZigType *return_type = fn_type_id->return_type; |
| 18583 | if (type_is_invalid(return_type)) | 19603 | if (type_is_invalid(return_type)) |
| 18584 | return ira->codegen->invalid_instruction; | 19604 | return ira->codegen->invalid_inst_gen; |
| 18585 | | 19605 | |
| 18586 | if (fn_entry != nullptr && fn_entry->fn_inline == FnInlineAlways && modifier == CallModifierNeverInline) { | 19606 | if (fn_entry != nullptr && fn_entry->fn_inline == FnInlineAlways && modifier == CallModifierNeverInline) { |
| 18587 | ir_add_error(ira, source_instr, | 19607 | ir_add_error(ira, source_instr, |
| 18588 | buf_sprintf("no-inline call of inline function")); | 19608 | buf_sprintf("no-inline call of inline function")); |
| 18589 | return ira->codegen->invalid_instruction; | 19609 | return ira->codegen->invalid_inst_gen; |
| 18590 | } | 19610 | } |
| 18591 | | 19611 | |
| 18592 | IrInstruction *casted_new_stack = analyze_casted_new_stack(ira, source_instr, new_stack, | 19612 | IrInstGen *casted_new_stack = analyze_casted_new_stack(ira, source_instr, new_stack, |
| 18593 | is_async_call_builtin, fn_entry); | 19613 | is_async_call_builtin, fn_entry); |
| 18594 | if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value->type)) | 19614 | if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value->type)) |
| 18595 | return ira->codegen->invalid_instruction; | 19615 | return ira->codegen->invalid_inst_gen; |
| 18596 | | 19616 | |
| 18597 | if (modifier == CallModifierAsync) { | 19617 | if (modifier == CallModifierAsync) { |
| 18598 | IrInstruction *result = ir_analyze_async_call(ira, source_instr, fn_entry, fn_type, fn_ref, | 19618 | IrInstGen *result = ir_analyze_async_call(ira, source_instr, fn_entry, fn_type, fn_ref, |
| 18599 | casted_args, call_param_count, casted_new_stack, is_async_call_builtin, ret_ptr, call_result_loc); | 19619 | casted_args, call_param_count, casted_new_stack, is_async_call_builtin, ret_ptr, call_result_loc); |
| 18600 | return ir_finish_anal(ira, result); | 19620 | return ir_finish_anal(ira, result); |
| 18601 | } | 19621 | } |
| ... | @@ -18604,16 +19624,16 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18604,16 +19624,16 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18604 | parent_fn_entry->inferred_async_node == nullptr && | 19624 | parent_fn_entry->inferred_async_node == nullptr && |
| 18605 | modifier != CallModifierNoAsync) | 19625 | modifier != CallModifierNoAsync) |
| 18606 | { | 19626 | { |
| 18607 | parent_fn_entry->inferred_async_node = fn_ref->source_node; | 19627 | parent_fn_entry->inferred_async_node = fn_ref->base.source_node; |
| 18608 | parent_fn_entry->inferred_async_fn = fn_entry; | 19628 | parent_fn_entry->inferred_async_fn = fn_entry; |
| 18609 | } | 19629 | } |
| 18610 | | 19630 | |
| 18611 | IrInstruction *result_loc; | 19631 | IrInstGen *result_loc; |
| 18612 | if (handle_is_ptr(return_type)) { | 19632 | if (handle_is_ptr(return_type)) { |
| 18613 | result_loc = ir_resolve_result(ira, source_instr, call_result_loc, | 19633 | result_loc = ir_resolve_result(ira, source_instr, call_result_loc, |
| 18614 | return_type, nullptr, true, false); | 19634 | return_type, nullptr, true, false); |
| 18615 | if (result_loc != nullptr) { | 19635 | if (result_loc != nullptr) { |
| 18616 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { | 19636 | if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) { |
| 18617 | return result_loc; | 19637 | return result_loc; |
| 18618 | } | 19638 | } |
| 18619 | ZigType *res_child_type = result_loc->value->type->data.pointer.child_type; | 19639 | ZigType *res_child_type = result_loc->value->type->data.pointer.child_type; |
| ... | @@ -18629,12 +19649,12 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18629,12 +19649,12 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18629 | result_loc = get_async_call_result_loc(ira, source_instr, return_type, is_async_call_builtin, | 19649 | result_loc = get_async_call_result_loc(ira, source_instr, return_type, is_async_call_builtin, |
| 18630 | args_ptr, args_len, ret_ptr); | 19650 | args_ptr, args_len, ret_ptr); |
| 18631 | if (result_loc != nullptr && type_is_invalid(result_loc->value->type)) | 19651 | if (result_loc != nullptr && type_is_invalid(result_loc->value->type)) |
| 18632 | return ira->codegen->invalid_instruction; | 19652 | return ira->codegen->invalid_inst_gen; |
| 18633 | } else { | 19653 | } else { |
| 18634 | result_loc = nullptr; | 19654 | result_loc = nullptr; |
| 18635 | } | 19655 | } |
| 18636 | | 19656 | |
| 18637 | IrInstructionCallGen *new_call_instruction = ir_build_call_gen(ira, source_instr, fn_entry, fn_ref, | 19657 | IrInstGenCall *new_call_instruction = ir_build_call_gen(ira, source_instr, fn_entry, fn_ref, |
| 18638 | call_param_count, casted_args, modifier, casted_new_stack, | 19658 | call_param_count, casted_args, modifier, casted_new_stack, |
| 18639 | is_async_call_builtin, result_loc, return_type); | 19659 | is_async_call_builtin, result_loc, return_type); |
| 18640 | if (get_scope_typeof(source_instr->scope) == nullptr) { | 19660 | if (get_scope_typeof(source_instr->scope) == nullptr) { |
| ... | @@ -18643,62 +19663,62 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18643,62 +19663,62 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18643 | return ir_finish_anal(ira, &new_call_instruction->base); | 19663 | return ir_finish_anal(ira, &new_call_instruction->base); |
| 18644 | } | 19664 | } |
| 18645 | | 19665 | |
| 18646 | static IrInstruction *ir_analyze_fn_call_src(IrAnalyze *ira, IrInstructionCallSrc *call_instruction, | 19666 | static IrInstGen *ir_analyze_fn_call_src(IrAnalyze *ira, IrInstSrcCall *call_instruction, |
| 18647 | ZigFn *fn_entry, ZigType *fn_type, IrInstruction *fn_ref, | 19667 | ZigFn *fn_entry, ZigType *fn_type, IrInstGen *fn_ref, |
| 18648 | IrInstruction *first_arg_ptr, CallModifier modifier) | 19668 | IrInstGen *first_arg_ptr, CallModifier modifier) |
| 18649 | { | 19669 | { |
| 18650 | IrInstruction *new_stack = nullptr; | 19670 | IrInstGen *new_stack = nullptr; |
| 18651 | if (call_instruction->new_stack) { | 19671 | if (call_instruction->new_stack) { |
| 18652 | new_stack = call_instruction->new_stack->child; | 19672 | new_stack = call_instruction->new_stack->child; |
| 18653 | if (type_is_invalid(new_stack->value->type)) | 19673 | if (type_is_invalid(new_stack->value->type)) |
| 18654 | return ira->codegen->invalid_instruction; | 19674 | return ira->codegen->invalid_inst_gen; |
| 18655 | } | 19675 | } |
| 18656 | IrInstruction **args_ptr = allocate<IrInstruction *>(call_instruction->arg_count, "IrInstruction *"); | 19676 | IrInstGen **args_ptr = allocate<IrInstGen *>(call_instruction->arg_count, "IrInstGen *"); |
| 18657 | for (size_t i = 0; i < call_instruction->arg_count; i += 1) { | 19677 | for (size_t i = 0; i < call_instruction->arg_count; i += 1) { |
| 18658 | args_ptr[i] = call_instruction->args[i]->child; | 19678 | args_ptr[i] = call_instruction->args[i]->child; |
| 18659 | if (type_is_invalid(args_ptr[i]->value->type)) | 19679 | if (type_is_invalid(args_ptr[i]->value->type)) |
| 18660 | return ira->codegen->invalid_instruction; | 19680 | return ira->codegen->invalid_inst_gen; |
| 18661 | } | 19681 | } |
| 18662 | IrInstruction *ret_ptr = nullptr; | 19682 | IrInstGen *ret_ptr = nullptr; |
| 18663 | if (call_instruction->ret_ptr != nullptr) { | 19683 | if (call_instruction->ret_ptr != nullptr) { |
| 18664 | ret_ptr = call_instruction->ret_ptr->child; | 19684 | ret_ptr = call_instruction->ret_ptr->child; |
| 18665 | if (type_is_invalid(ret_ptr->value->type)) | 19685 | if (type_is_invalid(ret_ptr->value->type)) |
| 18666 | return ira->codegen->invalid_instruction; | 19686 | return ira->codegen->invalid_inst_gen; |
| 18667 | } | 19687 | } |
| 18668 | IrInstruction *result = ir_analyze_fn_call(ira, &call_instruction->base, fn_entry, fn_type, fn_ref, | 19688 | IrInstGen *result = ir_analyze_fn_call(ira, &call_instruction->base.base, fn_entry, fn_type, fn_ref, |
| 18669 | first_arg_ptr, modifier, new_stack, call_instruction->is_async_call_builtin, | 19689 | first_arg_ptr, modifier, new_stack, call_instruction->is_async_call_builtin, |
| 18670 | args_ptr, call_instruction->arg_count, ret_ptr, call_instruction->result_loc); | 19690 | args_ptr, call_instruction->arg_count, ret_ptr, call_instruction->result_loc); |
| 18671 | deallocate(args_ptr, call_instruction->arg_count, "IrInstruction *"); | 19691 | deallocate(args_ptr, call_instruction->arg_count, "IrInstGen *"); |
| 18672 | return result; | 19692 | return result; |
| 18673 | } | 19693 | } |
| 18674 | | 19694 | |
| 18675 | static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *source_instr, | 19695 | static IrInstGen *ir_analyze_call_extra(IrAnalyze *ira, IrInst* source_instr, |
| 18676 | IrInstruction *pass1_options, IrInstruction *pass1_fn_ref, IrInstruction **args_ptr, size_t args_len, | 19696 | IrInstSrc *pass1_options, IrInstSrc *pass1_fn_ref, IrInstGen **args_ptr, size_t args_len, |
| 18677 | ResultLoc *result_loc) | 19697 | ResultLoc *result_loc) |
| 18678 | { | 19698 | { |
| 18679 | IrInstruction *options = pass1_options->child; | 19699 | IrInstGen *options = pass1_options->child; |
| 18680 | if (type_is_invalid(options->value->type)) | 19700 | if (type_is_invalid(options->value->type)) |
| 18681 | return ira->codegen->invalid_instruction; | 19701 | return ira->codegen->invalid_inst_gen; |
| 18682 | | 19702 | |
| 18683 | IrInstruction *fn_ref = pass1_fn_ref->child; | 19703 | IrInstGen *fn_ref = pass1_fn_ref->child; |
| 18684 | if (type_is_invalid(fn_ref->value->type)) | 19704 | if (type_is_invalid(fn_ref->value->type)) |
| 18685 | return ira->codegen->invalid_instruction; | 19705 | return ira->codegen->invalid_inst_gen; |
| 18686 | | 19706 | |
| 18687 | TypeStructField *modifier_field = find_struct_type_field(options->value->type, buf_create_from_str("modifier")); | 19707 | TypeStructField *modifier_field = find_struct_type_field(options->value->type, buf_create_from_str("modifier")); |
| 18688 | ir_assert(modifier_field != nullptr, source_instr); | 19708 | ir_assert(modifier_field != nullptr, source_instr); |
| 18689 | IrInstruction *modifier_inst = ir_analyze_struct_value_field_value(ira, source_instr, options, modifier_field); | 19709 | IrInstGen *modifier_inst = ir_analyze_struct_value_field_value(ira, source_instr, options, modifier_field); |
| 18690 | ZigValue *modifier_val = ir_resolve_const(ira, modifier_inst, UndefBad); | 19710 | ZigValue *modifier_val = ir_resolve_const(ira, modifier_inst, UndefBad); |
| 18691 | if (modifier_val == nullptr) | 19711 | if (modifier_val == nullptr) |
| 18692 | return ira->codegen->invalid_instruction; | 19712 | return ira->codegen->invalid_inst_gen; |
| 18693 | CallModifier modifier = (CallModifier)bigint_as_u32(&modifier_val->data.x_enum_tag); | 19713 | CallModifier modifier = (CallModifier)bigint_as_u32(&modifier_val->data.x_enum_tag); |
| 18694 | | 19714 | |
| 18695 | if (ir_should_inline(ira->new_irb.exec, source_instr->scope)) { | 19715 | if (ir_should_inline(ira->old_irb.exec, source_instr->scope)) { |
| 18696 | switch (modifier) { | 19716 | switch (modifier) { |
| 18697 | case CallModifierBuiltin: | 19717 | case CallModifierBuiltin: |
| 18698 | zig_unreachable(); | 19718 | zig_unreachable(); |
| 18699 | case CallModifierAsync: | 19719 | case CallModifierAsync: |
| 18700 | ir_add_error(ira, source_instr, buf_sprintf("TODO: comptime @call with async modifier")); | 19720 | ir_add_error(ira, source_instr, buf_sprintf("TODO: comptime @call with async modifier")); |
| 18701 | return ira->codegen->invalid_instruction; | 19721 | return ira->codegen->invalid_inst_gen; |
| 18702 | case CallModifierCompileTime: | 19722 | case CallModifierCompileTime: |
| 18703 | case CallModifierNone: | 19723 | case CallModifierNone: |
| 18704 | case CallModifierAlwaysInline: | 19724 | case CallModifierAlwaysInline: |
| ... | @@ -18709,15 +19729,15 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -18709,15 +19729,15 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc |
| 18709 | case CallModifierNeverInline: | 19729 | case CallModifierNeverInline: |
| 18710 | ir_add_error(ira, source_instr, | 19730 | ir_add_error(ira, source_instr, |
| 18711 | buf_sprintf("unable to perform 'never_inline' call at compile-time")); | 19731 | buf_sprintf("unable to perform 'never_inline' call at compile-time")); |
| 18712 | return ira->codegen->invalid_instruction; | 19732 | return ira->codegen->invalid_inst_gen; |
| 18713 | case CallModifierNeverTail: | 19733 | case CallModifierNeverTail: |
| 18714 | ir_add_error(ira, source_instr, | 19734 | ir_add_error(ira, source_instr, |
| 18715 | buf_sprintf("unable to perform 'never_tail' call at compile-time")); | 19735 | buf_sprintf("unable to perform 'never_tail' call at compile-time")); |
| 18716 | return ira->codegen->invalid_instruction; | 19736 | return ira->codegen->invalid_inst_gen; |
| 18717 | } | 19737 | } |
| 18718 | } | 19738 | } |
| 18719 | | 19739 | |
| 18720 | IrInstruction *first_arg_ptr = nullptr; | 19740 | IrInstGen *first_arg_ptr = nullptr; |
| 18721 | ZigFn *fn = nullptr; | 19741 | ZigFn *fn = nullptr; |
| 18722 | if (instr_is_comptime(fn_ref)) { | 19742 | if (instr_is_comptime(fn_ref)) { |
| 18723 | if (fn_ref->value->type->id == ZigTypeIdBoundFn) { | 19743 | if (fn_ref->value->type->id == ZigTypeIdBoundFn) { |
| ... | @@ -18725,7 +19745,7 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -18725,7 +19745,7 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc |
| 18725 | fn = fn_ref->value->data.x_bound_fn.fn; | 19745 | fn = fn_ref->value->data.x_bound_fn.fn; |
| 18726 | first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; | 19746 | first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; |
| 18727 | if (type_is_invalid(first_arg_ptr->value->type)) | 19747 | if (type_is_invalid(first_arg_ptr->value->type)) |
| 18728 | return ira->codegen->invalid_instruction; | 19748 | return ira->codegen->invalid_inst_gen; |
| 18729 | } else { | 19749 | } else { |
| 18730 | fn = ir_resolve_fn(ira, fn_ref); | 19750 | fn = ir_resolve_fn(ira, fn_ref); |
| 18731 | } | 19751 | } |
| ... | @@ -18737,9 +19757,9 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -18737,9 +19757,9 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc |
| 18737 | case CallModifierAlwaysInline: | 19757 | case CallModifierAlwaysInline: |
| 18738 | case CallModifierAsync: | 19758 | case CallModifierAsync: |
| 18739 | if (fn == nullptr) { | 19759 | if (fn == nullptr) { |
| 18740 | ir_add_error(ira, modifier_inst, | 19760 | ir_add_error(ira, &modifier_inst->base, |
| 18741 | buf_sprintf("the specified modifier requires a comptime-known function")); | 19761 | buf_sprintf("the specified modifier requires a comptime-known function")); |
| 18742 | return ira->codegen->invalid_instruction; | 19762 | return ira->codegen->invalid_inst_gen; |
| 18743 | } | 19763 | } |
| 18744 | default: | 19764 | default: |
| 18745 | break; | 19765 | break; |
| ... | @@ -18749,93 +19769,93 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -18749,93 +19769,93 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc |
| 18749 | | 19769 | |
| 18750 | TypeStructField *stack_field = find_struct_type_field(options->value->type, buf_create_from_str("stack")); | 19770 | TypeStructField *stack_field = find_struct_type_field(options->value->type, buf_create_from_str("stack")); |
| 18751 | ir_assert(stack_field != nullptr, source_instr); | 19771 | ir_assert(stack_field != nullptr, source_instr); |
| 18752 | IrInstruction *opt_stack = ir_analyze_struct_value_field_value(ira, source_instr, options, stack_field); | 19772 | IrInstGen *opt_stack = ir_analyze_struct_value_field_value(ira, source_instr, options, stack_field); |
| 18753 | if (type_is_invalid(opt_stack->value->type)) | 19773 | if (type_is_invalid(opt_stack->value->type)) |
| 18754 | return ira->codegen->invalid_instruction; | 19774 | return ira->codegen->invalid_inst_gen; |
| 18755 | | 19775 | |
| 18756 | IrInstruction *stack_is_non_null_inst = ir_analyze_test_non_null(ira, source_instr, opt_stack); | 19776 | IrInstGen *stack_is_non_null_inst = ir_analyze_test_non_null(ira, source_instr, opt_stack); |
| 18757 | bool stack_is_non_null; | 19777 | bool stack_is_non_null; |
| 18758 | if (!ir_resolve_bool(ira, stack_is_non_null_inst, &stack_is_non_null)) | 19778 | if (!ir_resolve_bool(ira, stack_is_non_null_inst, &stack_is_non_null)) |
| 18759 | return ira->codegen->invalid_instruction; | 19779 | return ira->codegen->invalid_inst_gen; |
| 18760 | | 19780 | |
| 18761 | IrInstruction *stack = nullptr; | 19781 | IrInstGen *stack = nullptr; |
| 18762 | if (stack_is_non_null) { | 19782 | if (stack_is_non_null) { |
| 18763 | stack = ir_analyze_optional_value_payload_value(ira, source_instr, opt_stack, false); | 19783 | stack = ir_analyze_optional_value_payload_value(ira, source_instr, opt_stack, false); |
| 18764 | if (type_is_invalid(stack->value->type)) | 19784 | if (type_is_invalid(stack->value->type)) |
| 18765 | return ira->codegen->invalid_instruction; | 19785 | return ira->codegen->invalid_inst_gen; |
| 18766 | } | 19786 | } |
| 18767 | | 19787 | |
| 18768 | return ir_analyze_fn_call(ira, source_instr, fn, fn_type, fn_ref, first_arg_ptr, | 19788 | return ir_analyze_fn_call(ira, source_instr, fn, fn_type, fn_ref, first_arg_ptr, |
| 18769 | modifier, stack, false, args_ptr, args_len, nullptr, result_loc); | 19789 | modifier, stack, false, args_ptr, args_len, nullptr, result_loc); |
| 18770 | } | 19790 | } |
| 18771 | | 19791 | |
| 18772 | static IrInstruction *ir_analyze_instruction_call_extra(IrAnalyze *ira, IrInstructionCallExtra *instruction) { | 19792 | static IrInstGen *ir_analyze_instruction_call_extra(IrAnalyze *ira, IrInstSrcCallExtra *instruction) { |
| 18773 | IrInstruction *args = instruction->args->child; | 19793 | IrInstGen *args = instruction->args->child; |
| 18774 | ZigType *args_type = args->value->type; | 19794 | ZigType *args_type = args->value->type; |
| 18775 | if (type_is_invalid(args_type)) | 19795 | if (type_is_invalid(args_type)) |
| 18776 | return ira->codegen->invalid_instruction; | 19796 | return ira->codegen->invalid_inst_gen; |
| 18777 | | 19797 | |
| 18778 | if (args_type->id != ZigTypeIdStruct) { | 19798 | if (args_type->id != ZigTypeIdStruct) { |
| 18779 | ir_add_error(ira, args, | 19799 | ir_add_error(ira, &args->base, |
| 18780 | buf_sprintf("expected tuple or struct, found '%s'", buf_ptr(&args_type->name))); | 19800 | buf_sprintf("expected tuple or struct, found '%s'", buf_ptr(&args_type->name))); |
| 18781 | return ira->codegen->invalid_instruction; | 19801 | return ira->codegen->invalid_inst_gen; |
| 18782 | } | 19802 | } |
| 18783 | | 19803 | |
| 18784 | IrInstruction **args_ptr = nullptr; | 19804 | IrInstGen **args_ptr = nullptr; |
| 18785 | size_t args_len = 0; | 19805 | size_t args_len = 0; |
| 18786 | | 19806 | |
| 18787 | if (is_tuple(args_type)) { | 19807 | if (is_tuple(args_type)) { |
| 18788 | args_len = args_type->data.structure.src_field_count; | 19808 | args_len = args_type->data.structure.src_field_count; |
| 18789 | args_ptr = allocate<IrInstruction *>(args_len, "IrInstruction *"); | 19809 | args_ptr = allocate<IrInstGen *>(args_len, "IrInstGen *"); |
| 18790 | for (size_t i = 0; i < args_len; i += 1) { | 19810 | for (size_t i = 0; i < args_len; i += 1) { |
| 18791 | TypeStructField *arg_field = args_type->data.structure.fields[i]; | 19811 | TypeStructField *arg_field = args_type->data.structure.fields[i]; |
| 18792 | args_ptr[i] = ir_analyze_struct_value_field_value(ira, &instruction->base, args, arg_field); | 19812 | args_ptr[i] = ir_analyze_struct_value_field_value(ira, &instruction->base.base, args, arg_field); |
| 18793 | if (type_is_invalid(args_ptr[i]->value->type)) | 19813 | if (type_is_invalid(args_ptr[i]->value->type)) |
| 18794 | return ira->codegen->invalid_instruction; | 19814 | return ira->codegen->invalid_inst_gen; |
| 18795 | } | 19815 | } |
| 18796 | } else { | 19816 | } else { |
| 18797 | ir_add_error(ira, args, buf_sprintf("TODO: struct args")); | 19817 | ir_add_error(ira, &args->base, buf_sprintf("TODO: struct args")); |
| 18798 | return ira->codegen->invalid_instruction; | 19818 | return ira->codegen->invalid_inst_gen; |
| 18799 | } | 19819 | } |
| 18800 | IrInstruction *result = ir_analyze_call_extra(ira, &instruction->base, instruction->options, | 19820 | IrInstGen *result = ir_analyze_call_extra(ira, &instruction->base.base, instruction->options, |
| 18801 | instruction->fn_ref, args_ptr, args_len, instruction->result_loc); | 19821 | instruction->fn_ref, args_ptr, args_len, instruction->result_loc); |
| 18802 | deallocate(args_ptr, args_len, "IrInstruction *"); | 19822 | deallocate(args_ptr, args_len, "IrInstGen *"); |
| 18803 | return result; | 19823 | return result; |
| 18804 | } | 19824 | } |
| 18805 | | 19825 | |
| 18806 | static IrInstruction *ir_analyze_instruction_call_args(IrAnalyze *ira, IrInstructionCallSrcArgs *instruction) { | 19826 | static IrInstGen *ir_analyze_instruction_call_args(IrAnalyze *ira, IrInstSrcCallArgs *instruction) { |
| 18807 | IrInstruction **args_ptr = allocate<IrInstruction *>(instruction->args_len, "IrInstruction *"); | 19827 | IrInstGen **args_ptr = allocate<IrInstGen *>(instruction->args_len, "IrInstGen *"); |
| 18808 | for (size_t i = 0; i < instruction->args_len; i += 1) { | 19828 | for (size_t i = 0; i < instruction->args_len; i += 1) { |
| 18809 | args_ptr[i] = instruction->args_ptr[i]->child; | 19829 | args_ptr[i] = instruction->args_ptr[i]->child; |
| 18810 | if (type_is_invalid(args_ptr[i]->value->type)) | 19830 | if (type_is_invalid(args_ptr[i]->value->type)) |
| 18811 | return ira->codegen->invalid_instruction; | 19831 | return ira->codegen->invalid_inst_gen; |
| 18812 | } | 19832 | } |
| 18813 | | 19833 | |
| 18814 | IrInstruction *result = ir_analyze_call_extra(ira, &instruction->base, instruction->options, | 19834 | IrInstGen *result = ir_analyze_call_extra(ira, &instruction->base.base, instruction->options, |
| 18815 | instruction->fn_ref, args_ptr, instruction->args_len, instruction->result_loc); | 19835 | instruction->fn_ref, args_ptr, instruction->args_len, instruction->result_loc); |
| 18816 | deallocate(args_ptr, instruction->args_len, "IrInstruction *"); | 19836 | deallocate(args_ptr, instruction->args_len, "IrInstGen *"); |
| 18817 | return result; | 19837 | return result; |
| 18818 | } | 19838 | } |
| 18819 | | 19839 | |
| 18820 | static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCallSrc *call_instruction) { | 19840 | static IrInstGen *ir_analyze_instruction_call(IrAnalyze *ira, IrInstSrcCall *call_instruction) { |
| 18821 | IrInstruction *fn_ref = call_instruction->fn_ref->child; | 19841 | IrInstGen *fn_ref = call_instruction->fn_ref->child; |
| 18822 | if (type_is_invalid(fn_ref->value->type)) | 19842 | if (type_is_invalid(fn_ref->value->type)) |
| 18823 | return ira->codegen->invalid_instruction; | 19843 | return ira->codegen->invalid_inst_gen; |
| 18824 | | 19844 | |
| 18825 | bool is_comptime = (call_instruction->modifier == CallModifierCompileTime) || | 19845 | bool is_comptime = (call_instruction->modifier == CallModifierCompileTime) || |
| 18826 | ir_should_inline(ira->new_irb.exec, call_instruction->base.scope); | 19846 | ir_should_inline(ira->old_irb.exec, call_instruction->base.base.scope); |
| 18827 | CallModifier modifier = is_comptime ? CallModifierCompileTime : call_instruction->modifier; | 19847 | CallModifier modifier = is_comptime ? CallModifierCompileTime : call_instruction->modifier; |
| 18828 | | 19848 | |
| 18829 | if (is_comptime || instr_is_comptime(fn_ref)) { | 19849 | if (is_comptime || instr_is_comptime(fn_ref)) { |
| 18830 | if (fn_ref->value->type->id == ZigTypeIdMetaType) { | 19850 | if (fn_ref->value->type->id == ZigTypeIdMetaType) { |
| 18831 | ZigType *ty = ir_resolve_type(ira, fn_ref); | 19851 | ZigType *ty = ir_resolve_type(ira, fn_ref); |
| 18832 | if (ty == nullptr) | 19852 | if (ty == nullptr) |
| 18833 | return ira->codegen->invalid_instruction; | 19853 | return ira->codegen->invalid_inst_gen; |
| 18834 | ErrorMsg *msg = ir_add_error_node(ira, fn_ref->source_node, | 19854 | ErrorMsg *msg = ir_add_error(ira, &fn_ref->base, |
| 18835 | buf_sprintf("type '%s' not a function", buf_ptr(&ty->name))); | 19855 | buf_sprintf("type '%s' not a function", buf_ptr(&ty->name))); |
| 18836 | add_error_note(ira->codegen, msg, call_instruction->base.source_node, | 19856 | add_error_note(ira->codegen, msg, call_instruction->base.base.source_node, |
| 18837 | buf_sprintf("use @as builtin for type coercion")); | 19857 | buf_sprintf("use @as builtin for type coercion")); |
| 18838 | return ira->codegen->invalid_instruction; | 19858 | return ira->codegen->invalid_inst_gen; |
| 18839 | } else if (fn_ref->value->type->id == ZigTypeIdFn) { | 19859 | } else if (fn_ref->value->type->id == ZigTypeIdFn) { |
| 18840 | ZigFn *fn_table_entry = ir_resolve_fn(ira, fn_ref); | 19860 | ZigFn *fn_table_entry = ir_resolve_fn(ira, fn_ref); |
| 18841 | ZigType *fn_type = fn_table_entry ? fn_table_entry->type_entry : fn_ref->value->type; | 19861 | ZigType *fn_type = fn_table_entry ? fn_table_entry->type_entry : fn_ref->value->type; |
| ... | @@ -18845,14 +19865,14 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC | ... | @@ -18845,14 +19865,14 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC |
| 18845 | } else if (fn_ref->value->type->id == ZigTypeIdBoundFn) { | 19865 | } else if (fn_ref->value->type->id == ZigTypeIdBoundFn) { |
| 18846 | assert(fn_ref->value->special == ConstValSpecialStatic); | 19866 | assert(fn_ref->value->special == ConstValSpecialStatic); |
| 18847 | ZigFn *fn_table_entry = fn_ref->value->data.x_bound_fn.fn; | 19867 | ZigFn *fn_table_entry = fn_ref->value->data.x_bound_fn.fn; |
| 18848 | IrInstruction *first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; | 19868 | IrInstGen *first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; |
| 18849 | CallModifier modifier = is_comptime ? CallModifierCompileTime : call_instruction->modifier; | 19869 | CallModifier modifier = is_comptime ? CallModifierCompileTime : call_instruction->modifier; |
| 18850 | return ir_analyze_fn_call_src(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, | 19870 | return ir_analyze_fn_call_src(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, |
| 18851 | fn_ref, first_arg_ptr, modifier); | 19871 | fn_ref, first_arg_ptr, modifier); |
| 18852 | } else { | 19872 | } else { |
| 18853 | ir_add_error_node(ira, fn_ref->source_node, | 19873 | ir_add_error(ira, &fn_ref->base, |
| 18854 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name))); | 19874 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name))); |
| 18855 | return ira->codegen->invalid_instruction; | 19875 | return ira->codegen->invalid_inst_gen; |
| 18856 | } | 19876 | } |
| 18857 | } | 19877 | } |
| 18858 | | 19878 | |
| ... | @@ -18860,9 +19880,9 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC | ... | @@ -18860,9 +19880,9 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC |
| 18860 | return ir_analyze_fn_call_src(ira, call_instruction, nullptr, fn_ref->value->type, | 19880 | return ir_analyze_fn_call_src(ira, call_instruction, nullptr, fn_ref->value->type, |
| 18861 | fn_ref, nullptr, modifier); | 19881 | fn_ref, nullptr, modifier); |
| 18862 | } else { | 19882 | } else { |
| 18863 | ir_add_error_node(ira, fn_ref->source_node, | 19883 | ir_add_error(ira, &fn_ref->base, |
| 18864 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name))); | 19884 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name))); |
| 18865 | return ira->codegen->invalid_instruction; | 19885 | return ira->codegen->invalid_inst_gen; |
| 18866 | } | 19886 | } |
| 18867 | } | 19887 | } |
| 18868 | | 19888 | |
| ... | @@ -18951,8 +19971,8 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source | ... | @@ -18951,8 +19971,8 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source |
| 18951 | zig_unreachable(); | 19971 | zig_unreachable(); |
| 18952 | } | 19972 | } |
| 18953 | | 19973 | |
| 18954 | static IrInstruction *ir_analyze_optional_type(IrAnalyze *ira, IrInstructionUnOp *instruction) { | 19974 | static IrInstGen *ir_analyze_optional_type(IrAnalyze *ira, IrInstSrcUnOp *instruction) { |
| 18955 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); | 19975 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 18956 | result->value->special = ConstValSpecialLazy; | 19976 | result->value->special = ConstValSpecialLazy; |
| 18957 | | 19977 | |
| 18958 | LazyValueOptType *lazy_opt_type = allocate<LazyValueOptType>(1, "LazyValueOptType"); | 19978 | LazyValueOptType *lazy_opt_type = allocate<LazyValueOptType>(1, "LazyValueOptType"); |
| ... | @@ -18962,12 +19982,12 @@ static IrInstruction *ir_analyze_optional_type(IrAnalyze *ira, IrInstructionUnOp | ... | @@ -18962,12 +19982,12 @@ static IrInstruction *ir_analyze_optional_type(IrAnalyze *ira, IrInstructionUnOp |
| 18962 | | 19982 | |
| 18963 | lazy_opt_type->payload_type = instruction->value->child; | 19983 | lazy_opt_type->payload_type = instruction->value->child; |
| 18964 | if (ir_resolve_type_lazy(ira, lazy_opt_type->payload_type) == nullptr) | 19984 | if (ir_resolve_type_lazy(ira, lazy_opt_type->payload_type) == nullptr) |
| 18965 | return ira->codegen->invalid_instruction; | 19985 | return ira->codegen->invalid_inst_gen; |
| 18966 | | 19986 | |
| 18967 | return result; | 19987 | return result; |
| 18968 | } | 19988 | } |
| 18969 | | 19989 | |
| 18970 | static ErrorMsg *ir_eval_negation_scalar(IrAnalyze *ira, IrInstruction *source_instr, ZigType *scalar_type, | 19990 | static ErrorMsg *ir_eval_negation_scalar(IrAnalyze *ira, IrInst* source_instr, ZigType *scalar_type, |
| 18971 | ZigValue *operand_val, ZigValue *scalar_out_val, bool is_wrap_op) | 19991 | ZigValue *operand_val, ZigValue *scalar_out_val, bool is_wrap_op) |
| 18972 | { | 19992 | { |
| 18973 | bool is_float = (scalar_type->id == ZigTypeIdFloat || scalar_type->id == ZigTypeIdComptimeFloat); | 19993 | bool is_float = (scalar_type->id == ZigTypeIdFloat || scalar_type->id == ZigTypeIdComptimeFloat); |
| ... | @@ -19002,19 +20022,19 @@ static ErrorMsg *ir_eval_negation_scalar(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -19002,19 +20022,19 @@ static ErrorMsg *ir_eval_negation_scalar(IrAnalyze *ira, IrInstruction *source_i |
| 19002 | return nullptr; | 20022 | return nullptr; |
| 19003 | } | 20023 | } |
| 19004 | | 20024 | |
| 19005 | static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *instruction) { | 20025 | static IrInstGen *ir_analyze_negation(IrAnalyze *ira, IrInstSrcUnOp *instruction) { |
| 19006 | IrInstruction *value = instruction->value->child; | 20026 | IrInstGen *value = instruction->value->child; |
| 19007 | ZigType *expr_type = value->value->type; | 20027 | ZigType *expr_type = value->value->type; |
| 19008 | if (type_is_invalid(expr_type)) | 20028 | if (type_is_invalid(expr_type)) |
| 19009 | return ira->codegen->invalid_instruction; | 20029 | return ira->codegen->invalid_inst_gen; |
| 19010 | | 20030 | |
| 19011 | if (!(expr_type->id == ZigTypeIdInt || expr_type->id == ZigTypeIdComptimeInt || | 20031 | if (!(expr_type->id == ZigTypeIdInt || expr_type->id == ZigTypeIdComptimeInt || |
| 19012 | expr_type->id == ZigTypeIdFloat || expr_type->id == ZigTypeIdComptimeFloat || | 20032 | expr_type->id == ZigTypeIdFloat || expr_type->id == ZigTypeIdComptimeFloat || |
| 19013 | expr_type->id == ZigTypeIdVector)) | 20033 | expr_type->id == ZigTypeIdVector)) |
| 19014 | { | 20034 | { |
| 19015 | ir_add_error(ira, &instruction->base, | 20035 | ir_add_error(ira, &instruction->base.base, |
| 19016 | buf_sprintf("negation of type '%s'", buf_ptr(&expr_type->name))); | 20036 | buf_sprintf("negation of type '%s'", buf_ptr(&expr_type->name))); |
| 19017 | return ira->codegen->invalid_instruction; | 20037 | return ira->codegen->invalid_inst_gen; |
| 19018 | } | 20038 | } |
| 19019 | | 20039 | |
| 19020 | bool is_wrap_op = (instruction->op_id == IrUnOpNegationWrap); | 20040 | bool is_wrap_op = (instruction->op_id == IrUnOpNegationWrap); |
| ... | @@ -19024,9 +20044,9 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins | ... | @@ -19024,9 +20044,9 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins |
| 19024 | if (instr_is_comptime(value)) { | 20044 | if (instr_is_comptime(value)) { |
| 19025 | ZigValue *operand_val = ir_resolve_const(ira, value, UndefBad); | 20045 | ZigValue *operand_val = ir_resolve_const(ira, value, UndefBad); |
| 19026 | if (!operand_val) | 20046 | if (!operand_val) |
| 19027 | return ira->codegen->invalid_instruction; | 20047 | return ira->codegen->invalid_inst_gen; |
| 19028 | | 20048 | |
| 19029 | IrInstruction *result_instruction = ir_const(ira, &instruction->base, expr_type); | 20049 | IrInstGen *result_instruction = ir_const(ira, &instruction->base.base, expr_type); |
| 19030 | ZigValue *out_val = result_instruction->value; | 20050 | ZigValue *out_val = result_instruction->value; |
| 19031 | if (expr_type->id == ZigTypeIdVector) { | 20051 | if (expr_type->id == ZigTypeIdVector) { |
| 19032 | expand_undef_array(ira->codegen, operand_val); | 20052 | expand_undef_array(ira->codegen, operand_val); |
| ... | @@ -19038,63 +20058,60 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins | ... | @@ -19038,63 +20058,60 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins |
| 19038 | ZigValue *scalar_out_val = &out_val->data.x_array.data.s_none.elements[i]; | 20058 | ZigValue *scalar_out_val = &out_val->data.x_array.data.s_none.elements[i]; |
| 19039 | assert(scalar_operand_val->type == scalar_type); | 20059 | assert(scalar_operand_val->type == scalar_type); |
| 19040 | assert(scalar_out_val->type == scalar_type); | 20060 | assert(scalar_out_val->type == scalar_type); |
| 19041 | ErrorMsg *msg = ir_eval_negation_scalar(ira, &instruction->base, scalar_type, | 20061 | ErrorMsg *msg = ir_eval_negation_scalar(ira, &instruction->base.base, scalar_type, |
| 19042 | scalar_operand_val, scalar_out_val, is_wrap_op); | 20062 | scalar_operand_val, scalar_out_val, is_wrap_op); |
| 19043 | if (msg != nullptr) { | 20063 | if (msg != nullptr) { |
| 19044 | add_error_note(ira->codegen, msg, instruction->base.source_node, | 20064 | add_error_note(ira->codegen, msg, instruction->base.base.source_node, |
| 19045 | buf_sprintf("when computing vector element at index %" ZIG_PRI_usize, i)); | 20065 | buf_sprintf("when computing vector element at index %" ZIG_PRI_usize, i)); |
| 19046 | return ira->codegen->invalid_instruction; | 20066 | return ira->codegen->invalid_inst_gen; |
| 19047 | } | 20067 | } |
| 19048 | } | 20068 | } |
| 19049 | out_val->type = expr_type; | 20069 | out_val->type = expr_type; |
| 19050 | out_val->special = ConstValSpecialStatic; | 20070 | out_val->special = ConstValSpecialStatic; |
| 19051 | } else { | 20071 | } else { |
| 19052 | if (ir_eval_negation_scalar(ira, &instruction->base, scalar_type, operand_val, out_val, | 20072 | if (ir_eval_negation_scalar(ira, &instruction->base.base, scalar_type, operand_val, out_val, |
| 19053 | is_wrap_op) != nullptr) | 20073 | is_wrap_op) != nullptr) |
| 19054 | { | 20074 | { |
| 19055 | return ira->codegen->invalid_instruction; | 20075 | return ira->codegen->invalid_inst_gen; |
| 19056 | } | 20076 | } |
| 19057 | } | 20077 | } |
| 19058 | return result_instruction; | 20078 | return result_instruction; |
| 19059 | } | 20079 | } |
| 19060 | | 20080 | |
| 19061 | IrInstruction *result = ir_build_un_op(&ira->new_irb, | 20081 | if (is_wrap_op) { |
| 19062 | instruction->base.scope, instruction->base.source_node, | 20082 | return ir_build_negation_wrapping(ira, &instruction->base.base, value, expr_type); |
| 19063 | instruction->op_id, value); | 20083 | } else { |
| 19064 | result->value->type = expr_type; | 20084 | return ir_build_negation(ira, &instruction->base.base, value, expr_type); |
| 19065 | return result; | 20085 | } |
| 19066 | } | 20086 | } |
| 19067 | | 20087 | |
| 19068 | static IrInstruction *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *instruction) { | 20088 | static IrInstGen *ir_analyze_bin_not(IrAnalyze *ira, IrInstSrcUnOp *instruction) { |
| 19069 | IrInstruction *value = instruction->value->child; | 20089 | IrInstGen *value = instruction->value->child; |
| 19070 | ZigType *expr_type = value->value->type; | 20090 | ZigType *expr_type = value->value->type; |
| 19071 | if (type_is_invalid(expr_type)) | 20091 | if (type_is_invalid(expr_type)) |
| 19072 | return ira->codegen->invalid_instruction; | 20092 | return ira->codegen->invalid_inst_gen; |
| 19073 | | 20093 | |
| 19074 | if (expr_type->id == ZigTypeIdInt) { | 20094 | if (expr_type->id == ZigTypeIdInt) { |
| 19075 | if (instr_is_comptime(value)) { | 20095 | if (instr_is_comptime(value)) { |
| 19076 | ZigValue *target_const_val = ir_resolve_const(ira, value, UndefBad); | 20096 | ZigValue *target_const_val = ir_resolve_const(ira, value, UndefBad); |
| 19077 | if (target_const_val == nullptr) | 20097 | if (target_const_val == nullptr) |
| 19078 | return ira->codegen->invalid_instruction; | 20098 | return ira->codegen->invalid_inst_gen; |
| 19079 | | 20099 | |
| 19080 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); | 20100 | IrInstGen *result = ir_const(ira, &instruction->base.base, expr_type); |
| 19081 | bigint_not(&result->value->data.x_bigint, &target_const_val->data.x_bigint, | 20101 | bigint_not(&result->value->data.x_bigint, &target_const_val->data.x_bigint, |
| 19082 | expr_type->data.integral.bit_count, expr_type->data.integral.is_signed); | 20102 | expr_type->data.integral.bit_count, expr_type->data.integral.is_signed); |
| 19083 | return result; | 20103 | return result; |
| 19084 | } | 20104 | } |
| 19085 | | 20105 | |
| 19086 | IrInstruction *result = ir_build_un_op(&ira->new_irb, instruction->base.scope, | 20106 | return ir_build_binary_not(ira, &instruction->base.base, value, expr_type); |
| 19087 | instruction->base.source_node, IrUnOpBinNot, value); | | |
| 19088 | result->value->type = expr_type; | | |
| 19089 | return result; | | |
| 19090 | } | 20107 | } |
| 19091 | | 20108 | |
| 19092 | ir_add_error(ira, &instruction->base, | 20109 | ir_add_error(ira, &instruction->base.base, |
| 19093 | buf_sprintf("unable to perform binary not operation on type '%s'", buf_ptr(&expr_type->name))); | 20110 | buf_sprintf("unable to perform binary not operation on type '%s'", buf_ptr(&expr_type->name))); |
| 19094 | return ira->codegen->invalid_instruction; | 20111 | return ira->codegen->invalid_inst_gen; |
| 19095 | } | 20112 | } |
| 19096 | | 20113 | |
| 19097 | static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstructionUnOp *instruction) { | 20114 | static IrInstGen *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstSrcUnOp *instruction) { |
| 19098 | IrUnOp op_id = instruction->op_id; | 20115 | IrUnOp op_id = instruction->op_id; |
| 19099 | switch (op_id) { | 20116 | switch (op_id) { |
| 19100 | case IrUnOpInvalid: | 20117 | case IrUnOpInvalid: |
| ... | @@ -19105,26 +20122,26 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction | ... | @@ -19105,26 +20122,26 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction |
| 19105 | case IrUnOpNegationWrap: | 20122 | case IrUnOpNegationWrap: |
| 19106 | return ir_analyze_negation(ira, instruction); | 20123 | return ir_analyze_negation(ira, instruction); |
| 19107 | case IrUnOpDereference: { | 20124 | case IrUnOpDereference: { |
| 19108 | IrInstruction *ptr = instruction->value->child; | 20125 | IrInstGen *ptr = instruction->value->child; |
| 19109 | if (type_is_invalid(ptr->value->type)) | 20126 | if (type_is_invalid(ptr->value->type)) |
| 19110 | return ira->codegen->invalid_instruction; | 20127 | return ira->codegen->invalid_inst_gen; |
| 19111 | ZigType *ptr_type = ptr->value->type; | 20128 | ZigType *ptr_type = ptr->value->type; |
| 19112 | if (ptr_type->id == ZigTypeIdPointer && ptr_type->data.pointer.ptr_len == PtrLenUnknown) { | 20129 | if (ptr_type->id == ZigTypeIdPointer && ptr_type->data.pointer.ptr_len == PtrLenUnknown) { |
| 19113 | ir_add_error_node(ira, instruction->base.source_node, | 20130 | ir_add_error_node(ira, instruction->base.base.source_node, |
| 19114 | buf_sprintf("index syntax required for unknown-length pointer type '%s'", | 20131 | buf_sprintf("index syntax required for unknown-length pointer type '%s'", |
| 19115 | buf_ptr(&ptr_type->name))); | 20132 | buf_ptr(&ptr_type->name))); |
| 19116 | return ira->codegen->invalid_instruction; | 20133 | return ira->codegen->invalid_inst_gen; |
| 19117 | } | 20134 | } |
| 19118 | | 20135 | |
| 19119 | IrInstruction *result = ir_get_deref(ira, &instruction->base, ptr, instruction->result_loc); | 20136 | IrInstGen *result = ir_get_deref(ira, &instruction->base.base, ptr, instruction->result_loc); |
| 19120 | if (result == ira->codegen->invalid_instruction) | 20137 | if (type_is_invalid(result->value->type)) |
| 19121 | return ira->codegen->invalid_instruction; | 20138 | return ira->codegen->invalid_inst_gen; |
| 19122 | | 20139 | |
| 19123 | // If the result needs to be an lvalue, type check it | 20140 | // If the result needs to be an lvalue, type check it |
| 19124 | if (instruction->lval == LValPtr && result->value->type->id != ZigTypeIdPointer) { | 20141 | if (instruction->lval == LValPtr && result->value->type->id != ZigTypeIdPointer) { |
| 19125 | ir_add_error(ira, &instruction->base, | 20142 | ir_add_error(ira, &instruction->base.base, |
| 19126 | buf_sprintf("attempt to dereference non-pointer type '%s'", buf_ptr(&result->value->type->name))); | 20143 | buf_sprintf("attempt to dereference non-pointer type '%s'", buf_ptr(&result->value->type->name))); |
| 19127 | return ira->codegen->invalid_instruction; | 20144 | return ira->codegen->invalid_inst_gen; |
| 19128 | } | 20145 | } |
| 19129 | | 20146 | |
| 19130 | return result; | 20147 | return result; |
| ... | @@ -19136,42 +20153,40 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction | ... | @@ -19136,42 +20153,40 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction |
| 19136 | } | 20153 | } |
| 19137 | | 20154 | |
| 19138 | static void ir_push_resume(IrAnalyze *ira, IrSuspendPosition pos) { | 20155 | static void ir_push_resume(IrAnalyze *ira, IrSuspendPosition pos) { |
| 19139 | IrBasicBlock *old_bb = ira->old_irb.exec->basic_block_list.at(pos.basic_block_index); | 20156 | IrBasicBlockSrc *old_bb = ira->old_irb.exec->basic_block_list.at(pos.basic_block_index); |
| 19140 | if (old_bb->in_resume_stack) return; | 20157 | if (old_bb->in_resume_stack) return; |
| 19141 | ira->resume_stack.append(pos); | 20158 | ira->resume_stack.append(pos); |
| 19142 | old_bb->in_resume_stack = true; | 20159 | old_bb->in_resume_stack = true; |
| 19143 | } | 20160 | } |
| 19144 | | 20161 | |
| 19145 | static void ir_push_resume_block(IrAnalyze *ira, IrBasicBlock *old_bb) { | 20162 | static void ir_push_resume_block(IrAnalyze *ira, IrBasicBlockSrc *old_bb) { |
| 19146 | if (ira->resume_stack.length != 0) { | 20163 | if (ira->resume_stack.length != 0) { |
| 19147 | ir_push_resume(ira, {old_bb->index, 0}); | 20164 | ir_push_resume(ira, {old_bb->index, 0}); |
| 19148 | } | 20165 | } |
| 19149 | } | 20166 | } |
| 19150 | | 20167 | |
| 19151 | static IrInstruction *ir_analyze_instruction_br(IrAnalyze *ira, IrInstructionBr *br_instruction) { | 20168 | static IrInstGen *ir_analyze_instruction_br(IrAnalyze *ira, IrInstSrcBr *br_instruction) { |
| 19152 | IrBasicBlock *old_dest_block = br_instruction->dest_block; | 20169 | IrBasicBlockSrc *old_dest_block = br_instruction->dest_block; |
| 19153 | | 20170 | |
| 19154 | bool is_comptime; | 20171 | bool is_comptime; |
| 19155 | if (!ir_resolve_comptime(ira, br_instruction->is_comptime->child, &is_comptime)) | 20172 | if (!ir_resolve_comptime(ira, br_instruction->is_comptime->child, &is_comptime)) |
| 19156 | return ir_unreach_error(ira); | 20173 | return ir_unreach_error(ira); |
| 19157 | | 20174 | |
| 19158 | if (is_comptime || (old_dest_block->ref_count == 1 && old_dest_block->suspend_instruction_ref == nullptr)) | 20175 | if (is_comptime || (old_dest_block->ref_count == 1 && old_dest_block->suspend_instruction_ref == nullptr)) |
| 19159 | return ir_inline_bb(ira, &br_instruction->base, old_dest_block); | 20176 | return ir_inline_bb(ira, &br_instruction->base.base, old_dest_block); |
| 19160 | | 20177 | |
| 19161 | IrBasicBlock *new_bb = ir_get_new_bb_runtime(ira, old_dest_block, &br_instruction->base); | 20178 | IrBasicBlockGen *new_bb = ir_get_new_bb_runtime(ira, old_dest_block, &br_instruction->base.base); |
| 19162 | if (new_bb == nullptr) | 20179 | if (new_bb == nullptr) |
| 19163 | return ir_unreach_error(ira); | 20180 | return ir_unreach_error(ira); |
| 19164 | | 20181 | |
| 19165 | ir_push_resume_block(ira, old_dest_block); | 20182 | ir_push_resume_block(ira, old_dest_block); |
| 19166 | | 20183 | |
| 19167 | IrInstruction *result = ir_build_br(&ira->new_irb, | 20184 | IrInstGen *result = ir_build_br_gen(ira, &br_instruction->base.base, new_bb); |
| 19168 | br_instruction->base.scope, br_instruction->base.source_node, new_bb, nullptr); | | |
| 19169 | result->value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 19170 | return ir_finish_anal(ira, result); | 20185 | return ir_finish_anal(ira, result); |
| 19171 | } | 20186 | } |
| 19172 | | 20187 | |
| 19173 | static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructionCondBr *cond_br_instruction) { | 20188 | static IrInstGen *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstSrcCondBr *cond_br_instruction) { |
| 19174 | IrInstruction *condition = cond_br_instruction->condition->child; | 20189 | IrInstGen *condition = cond_br_instruction->condition->child; |
| 19175 | if (type_is_invalid(condition->value->type)) | 20190 | if (type_is_invalid(condition->value->type)) |
| 19176 | return ir_unreach_error(ira); | 20191 | return ir_unreach_error(ira); |
| 19177 | | 20192 | |
| ... | @@ -19180,7 +20195,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi | ... | @@ -19180,7 +20195,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi |
| 19180 | return ir_unreach_error(ira); | 20195 | return ir_unreach_error(ira); |
| 19181 | | 20196 | |
| 19182 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; | 20197 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| 19183 | IrInstruction *casted_condition = ir_implicit_cast(ira, condition, bool_type); | 20198 | IrInstGen *casted_condition = ir_implicit_cast(ira, condition, bool_type); |
| 19184 | if (type_is_invalid(casted_condition->value->type)) | 20199 | if (type_is_invalid(casted_condition->value->type)) |
| 19185 | return ir_unreach_error(ira); | 20200 | return ir_unreach_error(ira); |
| 19186 | | 20201 | |
| ... | @@ -19189,67 +20204,61 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi | ... | @@ -19189,67 +20204,61 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi |
| 19189 | if (!ir_resolve_bool(ira, casted_condition, &cond_is_true)) | 20204 | if (!ir_resolve_bool(ira, casted_condition, &cond_is_true)) |
| 19190 | return ir_unreach_error(ira); | 20205 | return ir_unreach_error(ira); |
| 19191 | | 20206 | |
| 19192 | IrBasicBlock *old_dest_block = cond_is_true ? | 20207 | IrBasicBlockSrc *old_dest_block = cond_is_true ? |
| 19193 | cond_br_instruction->then_block : cond_br_instruction->else_block; | 20208 | cond_br_instruction->then_block : cond_br_instruction->else_block; |
| 19194 | | 20209 | |
| 19195 | if (is_comptime || (old_dest_block->ref_count == 1 && old_dest_block->suspend_instruction_ref == nullptr)) | 20210 | if (is_comptime || (old_dest_block->ref_count == 1 && old_dest_block->suspend_instruction_ref == nullptr)) |
| 19196 | return ir_inline_bb(ira, &cond_br_instruction->base, old_dest_block); | 20211 | return ir_inline_bb(ira, &cond_br_instruction->base.base, old_dest_block); |
| 19197 | | 20212 | |
| 19198 | IrBasicBlock *new_dest_block = ir_get_new_bb_runtime(ira, old_dest_block, &cond_br_instruction->base); | 20213 | IrBasicBlockGen *new_dest_block = ir_get_new_bb_runtime(ira, old_dest_block, &cond_br_instruction->base.base); |
| 19199 | if (new_dest_block == nullptr) | 20214 | if (new_dest_block == nullptr) |
| 19200 | return ir_unreach_error(ira); | 20215 | return ir_unreach_error(ira); |
| 19201 | | 20216 | |
| 19202 | ir_push_resume_block(ira, old_dest_block); | 20217 | ir_push_resume_block(ira, old_dest_block); |
| 19203 | | 20218 | |
| 19204 | IrInstruction *result = ir_build_br(&ira->new_irb, | 20219 | IrInstGen *result = ir_build_br_gen(ira, &cond_br_instruction->base.base, new_dest_block); |
| 19205 | cond_br_instruction->base.scope, cond_br_instruction->base.source_node, new_dest_block, nullptr); | | |
| 19206 | result->value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 19207 | return ir_finish_anal(ira, result); | 20220 | return ir_finish_anal(ira, result); |
| 19208 | } | 20221 | } |
| 19209 | | 20222 | |
| 19210 | assert(cond_br_instruction->then_block != cond_br_instruction->else_block); | 20223 | assert(cond_br_instruction->then_block != cond_br_instruction->else_block); |
| 19211 | IrBasicBlock *new_then_block = ir_get_new_bb_runtime(ira, cond_br_instruction->then_block, &cond_br_instruction->base); | 20224 | IrBasicBlockGen *new_then_block = ir_get_new_bb_runtime(ira, cond_br_instruction->then_block, &cond_br_instruction->base.base); |
| 19212 | if (new_then_block == nullptr) | 20225 | if (new_then_block == nullptr) |
| 19213 | return ir_unreach_error(ira); | 20226 | return ir_unreach_error(ira); |
| 19214 | | 20227 | |
| 19215 | IrBasicBlock *new_else_block = ir_get_new_bb_runtime(ira, cond_br_instruction->else_block, &cond_br_instruction->base); | 20228 | IrBasicBlockGen *new_else_block = ir_get_new_bb_runtime(ira, cond_br_instruction->else_block, &cond_br_instruction->base.base); |
| 19216 | if (new_else_block == nullptr) | 20229 | if (new_else_block == nullptr) |
| 19217 | return ir_unreach_error(ira); | 20230 | return ir_unreach_error(ira); |
| 19218 | | 20231 | |
| 19219 | ir_push_resume_block(ira, cond_br_instruction->else_block); | 20232 | ir_push_resume_block(ira, cond_br_instruction->else_block); |
| 19220 | ir_push_resume_block(ira, cond_br_instruction->then_block); | 20233 | ir_push_resume_block(ira, cond_br_instruction->then_block); |
| 19221 | | 20234 | |
| 19222 | IrInstruction *result = ir_build_cond_br(&ira->new_irb, | 20235 | IrInstGen *result = ir_build_cond_br_gen(ira, &cond_br_instruction->base.base, |
| 19223 | cond_br_instruction->base.scope, cond_br_instruction->base.source_node, | 20236 | casted_condition, new_then_block, new_else_block); |
| 19224 | casted_condition, new_then_block, new_else_block, nullptr); | | |
| 19225 | result->value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 19226 | return ir_finish_anal(ira, result); | 20237 | return ir_finish_anal(ira, result); |
| 19227 | } | 20238 | } |
| 19228 | | 20239 | |
| 19229 | static IrInstruction *ir_analyze_instruction_unreachable(IrAnalyze *ira, | 20240 | static IrInstGen *ir_analyze_instruction_unreachable(IrAnalyze *ira, |
| 19230 | IrInstructionUnreachable *unreachable_instruction) | 20241 | IrInstSrcUnreachable *unreachable_instruction) |
| 19231 | { | 20242 | { |
| 19232 | IrInstruction *result = ir_build_unreachable(&ira->new_irb, | 20243 | IrInstGen *result = ir_build_unreachable_gen(ira, &unreachable_instruction->base.base); |
| 19233 | unreachable_instruction->base.scope, unreachable_instruction->base.source_node); | | |
| 19234 | result->value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 19235 | return ir_finish_anal(ira, result); | 20244 | return ir_finish_anal(ira, result); |
| 19236 | } | 20245 | } |
| 19237 | | 20246 | |
| 19238 | static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPhi *phi_instruction) { | 20247 | static IrInstGen *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstSrcPhi *phi_instruction) { |
| 19239 | Error err; | 20248 | Error err; |
| 19240 | | 20249 | |
| 19241 | if (ira->const_predecessor_bb) { | 20250 | if (ira->const_predecessor_bb) { |
| 19242 | for (size_t i = 0; i < phi_instruction->incoming_count; i += 1) { | 20251 | for (size_t i = 0; i < phi_instruction->incoming_count; i += 1) { |
| 19243 | IrBasicBlock *predecessor = phi_instruction->incoming_blocks[i]; | 20252 | IrBasicBlockSrc *predecessor = phi_instruction->incoming_blocks[i]; |
| 19244 | if (predecessor != ira->const_predecessor_bb) | 20253 | if (predecessor != ira->const_predecessor_bb) |
| 19245 | continue; | 20254 | continue; |
| 19246 | IrInstruction *value = phi_instruction->incoming_values[i]->child; | 20255 | IrInstGen *value = phi_instruction->incoming_values[i]->child; |
| 19247 | assert(value->value->type); | 20256 | assert(value->value->type); |
| 19248 | if (type_is_invalid(value->value->type)) | 20257 | if (type_is_invalid(value->value->type)) |
| 19249 | return ira->codegen->invalid_instruction; | 20258 | return ira->codegen->invalid_inst_gen; |
| 19250 | | 20259 | |
| 19251 | if (value->value->special != ConstValSpecialRuntime) { | 20260 | if (value->value->special != ConstValSpecialRuntime) { |
| 19252 | IrInstruction *result = ir_const(ira, &phi_instruction->base, nullptr); | 20261 | IrInstGen *result = ir_const(ira, &phi_instruction->base.base, nullptr); |
| 19253 | copy_const_val(result->value, value->value); | 20262 | copy_const_val(result->value, value->value); |
| 19254 | return result; | 20263 | return result; |
| 19255 | } else { | 20264 | } else { |
| ... | @@ -19264,17 +20273,17 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19264,17 +20273,17 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19264 | peer_parent->peers.length >= 2) | 20273 | peer_parent->peers.length >= 2) |
| 19265 | { | 20274 | { |
| 19266 | if (peer_parent->resolved_type == nullptr) { | 20275 | if (peer_parent->resolved_type == nullptr) { |
| 19267 | IrInstruction **instructions = allocate<IrInstruction *>(peer_parent->peers.length); | 20276 | IrInstGen **instructions = allocate<IrInstGen *>(peer_parent->peers.length); |
| 19268 | for (size_t i = 0; i < peer_parent->peers.length; i += 1) { | 20277 | for (size_t i = 0; i < peer_parent->peers.length; i += 1) { |
| 19269 | ResultLocPeer *this_peer = peer_parent->peers.at(i); | 20278 | ResultLocPeer *this_peer = peer_parent->peers.at(i); |
| 19270 | | 20279 | |
| 19271 | IrInstruction *gen_instruction = this_peer->base.gen_instruction; | 20280 | IrInstGen *gen_instruction = this_peer->base.gen_instruction; |
| 19272 | if (gen_instruction == nullptr) { | 20281 | if (gen_instruction == nullptr) { |
| 19273 | // unreachable instructions will cause implicit_elem_type to be null | 20282 | // unreachable instructions will cause implicit_elem_type to be null |
| 19274 | if (this_peer->base.implicit_elem_type == nullptr) { | 20283 | if (this_peer->base.implicit_elem_type == nullptr) { |
| 19275 | instructions[i] = ir_const_unreachable(ira, this_peer->base.source_instruction); | 20284 | instructions[i] = ir_const_unreachable(ira, &this_peer->base.source_instruction->base); |
| 19276 | } else { | 20285 | } else { |
| 19277 | instructions[i] = ir_const(ira, this_peer->base.source_instruction, | 20286 | instructions[i] = ir_const(ira, &this_peer->base.source_instruction->base, |
| 19278 | this_peer->base.implicit_elem_type); | 20287 | this_peer->base.implicit_elem_type); |
| 19279 | instructions[i]->value->special = ConstValSpecialRuntime; | 20288 | instructions[i]->value->special = ConstValSpecialRuntime; |
| 19280 | } | 20289 | } |
| ... | @@ -19283,34 +20292,34 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19283,34 +20292,34 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19283 | } | 20292 | } |
| 19284 | | 20293 | |
| 19285 | } | 20294 | } |
| 19286 | ZigType *expected_type = ir_result_loc_expected_type(ira, &phi_instruction->base, peer_parent->parent); | 20295 | ZigType *expected_type = ir_result_loc_expected_type(ira, &phi_instruction->base.base, peer_parent->parent); |
| 19287 | peer_parent->resolved_type = ir_resolve_peer_types(ira, | 20296 | peer_parent->resolved_type = ir_resolve_peer_types(ira, |
| 19288 | peer_parent->base.source_instruction->source_node, expected_type, instructions, | 20297 | peer_parent->base.source_instruction->base.source_node, expected_type, instructions, |
| 19289 | peer_parent->peers.length); | 20298 | peer_parent->peers.length); |
| 19290 | if (type_is_invalid(peer_parent->resolved_type)) | 20299 | if (type_is_invalid(peer_parent->resolved_type)) |
| 19291 | return ira->codegen->invalid_instruction; | 20300 | return ira->codegen->invalid_inst_gen; |
| 19292 | | 20301 | |
| 19293 | // the logic below assumes there are no instructions in the new current basic block yet | 20302 | // the logic below assumes there are no instructions in the new current basic block yet |
| 19294 | ir_assert(ira->new_irb.current_basic_block->instruction_list.length == 0, &phi_instruction->base); | 20303 | ir_assert(ira->new_irb.current_basic_block->instruction_list.length == 0, &phi_instruction->base.base); |
| 19295 | | 20304 | |
| 19296 | // In case resolving the parent activates a suspend, do it now | 20305 | // In case resolving the parent activates a suspend, do it now |
| 19297 | IrInstruction *parent_result_loc = ir_resolve_result(ira, &phi_instruction->base, peer_parent->parent, | 20306 | IrInstGen *parent_result_loc = ir_resolve_result(ira, &phi_instruction->base.base, peer_parent->parent, |
| 19298 | peer_parent->resolved_type, nullptr, false, true); | 20307 | peer_parent->resolved_type, nullptr, false, true); |
| 19299 | if (parent_result_loc != nullptr && | 20308 | if (parent_result_loc != nullptr && |
| 19300 | (type_is_invalid(parent_result_loc->value->type) || instr_is_unreachable(parent_result_loc))) | 20309 | (type_is_invalid(parent_result_loc->value->type) || parent_result_loc->value->type->id == ZigTypeIdUnreachable)) |
| 19301 | { | 20310 | { |
| 19302 | return parent_result_loc; | 20311 | return parent_result_loc; |
| 19303 | } | 20312 | } |
| 19304 | // If the above code generated any instructions in the current basic block, we need | 20313 | // If the above code generated any instructions in the current basic block, we need |
| 19305 | // to move them to the peer parent predecessor. | 20314 | // to move them to the peer parent predecessor. |
| 19306 | ZigList<IrInstruction *> instrs_to_move = {}; | 20315 | ZigList<IrInstGen *> instrs_to_move = {}; |
| 19307 | while (ira->new_irb.current_basic_block->instruction_list.length != 0) { | 20316 | while (ira->new_irb.current_basic_block->instruction_list.length != 0) { |
| 19308 | instrs_to_move.append(ira->new_irb.current_basic_block->instruction_list.pop()); | 20317 | instrs_to_move.append(ira->new_irb.current_basic_block->instruction_list.pop()); |
| 19309 | } | 20318 | } |
| 19310 | if (instrs_to_move.length != 0) { | 20319 | if (instrs_to_move.length != 0) { |
| 19311 | IrBasicBlock *predecessor = peer_parent->base.source_instruction->child->owner_bb; | 20320 | IrBasicBlockGen *predecessor = peer_parent->base.source_instruction->child->owner_bb; |
| 19312 | IrInstruction *branch_instruction = predecessor->instruction_list.pop(); | 20321 | IrInstGen *branch_instruction = predecessor->instruction_list.pop(); |
| 19313 | ir_assert(branch_instruction->value->type->id == ZigTypeIdUnreachable, &phi_instruction->base); | 20322 | ir_assert(branch_instruction->value->type->id == ZigTypeIdUnreachable, &phi_instruction->base.base); |
| 19314 | while (instrs_to_move.length != 0) { | 20323 | while (instrs_to_move.length != 0) { |
| 19315 | predecessor->instruction_list.append(instrs_to_move.pop()); | 20324 | predecessor->instruction_list.append(instrs_to_move.pop()); |
| 19316 | } | 20325 | } |
| ... | @@ -19319,7 +20328,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19319,7 +20328,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19319 | } | 20328 | } |
| 19320 | | 20329 | |
| 19321 | IrSuspendPosition suspend_pos; | 20330 | IrSuspendPosition suspend_pos; |
| 19322 | ira_suspend(ira, &phi_instruction->base, nullptr, &suspend_pos); | 20331 | ira_suspend(ira, &phi_instruction->base.base, nullptr, &suspend_pos); |
| 19323 | ir_push_resume(ira, suspend_pos); | 20332 | ir_push_resume(ira, suspend_pos); |
| 19324 | | 20333 | |
| 19325 | for (size_t i = 0; i < peer_parent->peers.length; i += 1) { | 20334 | for (size_t i = 0; i < peer_parent->peers.length; i += 1) { |
| ... | @@ -19335,34 +20344,32 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19335,34 +20344,32 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19335 | return ira_resume(ira); | 20344 | return ira_resume(ira); |
| 19336 | } | 20345 | } |
| 19337 | | 20346 | |
| 19338 | ZigList<IrBasicBlock*> new_incoming_blocks = {0}; | 20347 | ZigList<IrBasicBlockGen*> new_incoming_blocks = {0}; |
| 19339 | ZigList<IrInstruction*> new_incoming_values = {0}; | 20348 | ZigList<IrInstGen*> new_incoming_values = {0}; |
| 19340 | | 20349 | |
| 19341 | for (size_t i = 0; i < phi_instruction->incoming_count; i += 1) { | 20350 | for (size_t i = 0; i < phi_instruction->incoming_count; i += 1) { |
| 19342 | IrBasicBlock *predecessor = phi_instruction->incoming_blocks[i]; | 20351 | IrBasicBlockSrc *predecessor = phi_instruction->incoming_blocks[i]; |
| 19343 | if (predecessor->ref_count == 0) | 20352 | if (predecessor->ref_count == 0) |
| 19344 | continue; | 20353 | continue; |
| 19345 | | 20354 | |
| 19346 | | 20355 | |
| 19347 | IrInstruction *old_value = phi_instruction->incoming_values[i]; | 20356 | IrInstSrc *old_value = phi_instruction->incoming_values[i]; |
| 19348 | assert(old_value); | 20357 | assert(old_value); |
| 19349 | IrInstruction *new_value = old_value->child; | 20358 | IrInstGen *new_value = old_value->child; |
| 19350 | if (!new_value || new_value->value->type->id == ZigTypeIdUnreachable || predecessor->other == nullptr) | 20359 | if (!new_value || new_value->value->type->id == ZigTypeIdUnreachable || predecessor->child == nullptr) |
| 19351 | continue; | 20360 | continue; |
| 19352 | | 20361 | |
| 19353 | if (type_is_invalid(new_value->value->type)) | 20362 | if (type_is_invalid(new_value->value->type)) |
| 19354 | return ira->codegen->invalid_instruction; | 20363 | return ira->codegen->invalid_inst_gen; |
| 19355 | | 20364 | |
| 19356 | | 20365 | |
| 19357 | assert(predecessor->other); | 20366 | assert(predecessor->child); |
| 19358 | new_incoming_blocks.append(predecessor->other); | 20367 | new_incoming_blocks.append(predecessor->child); |
| 19359 | new_incoming_values.append(new_value); | 20368 | new_incoming_values.append(new_value); |
| 19360 | } | 20369 | } |
| 19361 | | 20370 | |
| 19362 | if (new_incoming_blocks.length == 0) { | 20371 | if (new_incoming_blocks.length == 0) { |
| 19363 | IrInstruction *result = ir_build_unreachable(&ira->new_irb, | 20372 | IrInstGen *result = ir_build_unreachable_gen(ira, &phi_instruction->base.base); |
| 19364 | phi_instruction->base.scope, phi_instruction->base.source_node); | | |
| 19365 | result->value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 19366 | return ir_finish_anal(ira, result); | 20373 | return ir_finish_anal(ira, result); |
| 19367 | } | 20374 | } |
| 19368 | | 20375 | |
| ... | @@ -19374,7 +20381,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19374,7 +20381,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19374 | if (peer_parent != nullptr) { | 20381 | if (peer_parent != nullptr) { |
| 19375 | bool peer_parent_has_type; | 20382 | bool peer_parent_has_type; |
| 19376 | if ((err = ir_result_has_type(ira, peer_parent->parent, &peer_parent_has_type))) | 20383 | if ((err = ir_result_has_type(ira, peer_parent->parent, &peer_parent_has_type))) |
| 19377 | return ira->codegen->invalid_instruction; | 20384 | return ira->codegen->invalid_inst_gen; |
| 19378 | if (peer_parent_has_type) { | 20385 | if (peer_parent_has_type) { |
| 19379 | if (peer_parent->parent->id == ResultLocIdReturn) { | 20386 | if (peer_parent->parent->id == ResultLocIdReturn) { |
| 19380 | resolved_type = ira->explicit_return_type; | 20387 | resolved_type = ira->explicit_return_type; |
| ... | @@ -19382,27 +20389,27 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19382,27 +20389,27 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19382 | resolved_type = ir_resolve_type(ira, peer_parent->parent->source_instruction->child); | 20389 | resolved_type = ir_resolve_type(ira, peer_parent->parent->source_instruction->child); |
| 19383 | } else if (peer_parent->parent->resolved_loc) { | 20390 | } else if (peer_parent->parent->resolved_loc) { |
| 19384 | ZigType *resolved_loc_ptr_type = peer_parent->parent->resolved_loc->value->type; | 20391 | ZigType *resolved_loc_ptr_type = peer_parent->parent->resolved_loc->value->type; |
| 19385 | ir_assert(resolved_loc_ptr_type->id == ZigTypeIdPointer, &phi_instruction->base); | 20392 | ir_assert(resolved_loc_ptr_type->id == ZigTypeIdPointer, &phi_instruction->base.base); |
| 19386 | resolved_type = resolved_loc_ptr_type->data.pointer.child_type; | 20393 | resolved_type = resolved_loc_ptr_type->data.pointer.child_type; |
| 19387 | } | 20394 | } |
| 19388 | | 20395 | |
| 19389 | if (resolved_type != nullptr && type_is_invalid(resolved_type)) | 20396 | if (resolved_type != nullptr && type_is_invalid(resolved_type)) |
| 19390 | return ira->codegen->invalid_instruction; | 20397 | return ira->codegen->invalid_inst_gen; |
| 19391 | } | 20398 | } |
| 19392 | } | 20399 | } |
| 19393 | | 20400 | |
| 19394 | if (resolved_type == nullptr) { | 20401 | if (resolved_type == nullptr) { |
| 19395 | resolved_type = ir_resolve_peer_types(ira, phi_instruction->base.source_node, nullptr, | 20402 | resolved_type = ir_resolve_peer_types(ira, phi_instruction->base.base.source_node, nullptr, |
| 19396 | new_incoming_values.items, new_incoming_values.length); | 20403 | new_incoming_values.items, new_incoming_values.length); |
| 19397 | if (type_is_invalid(resolved_type)) | 20404 | if (type_is_invalid(resolved_type)) |
| 19398 | return ira->codegen->invalid_instruction; | 20405 | return ira->codegen->invalid_inst_gen; |
| 19399 | } | 20406 | } |
| 19400 | | 20407 | |
| 19401 | switch (type_has_one_possible_value(ira->codegen, resolved_type)) { | 20408 | switch (type_has_one_possible_value(ira->codegen, resolved_type)) { |
| 19402 | case OnePossibleValueInvalid: | 20409 | case OnePossibleValueInvalid: |
| 19403 | return ira->codegen->invalid_instruction; | 20410 | return ira->codegen->invalid_inst_gen; |
| 19404 | case OnePossibleValueYes: | 20411 | case OnePossibleValueYes: |
| 19405 | return ir_const_move(ira, &phi_instruction->base, | 20412 | return ir_const_move(ira, &phi_instruction->base.base, |
| 19406 | get_the_one_possible_value(ira->codegen, resolved_type)); | 20413 | get_the_one_possible_value(ira->codegen, resolved_type)); |
| 19407 | case OnePossibleValueNo: | 20414 | case OnePossibleValueNo: |
| 19408 | break; | 20415 | break; |
| ... | @@ -19410,11 +20417,11 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19410,11 +20417,11 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19410 | | 20417 | |
| 19411 | switch (type_requires_comptime(ira->codegen, resolved_type)) { | 20418 | switch (type_requires_comptime(ira->codegen, resolved_type)) { |
| 19412 | case ReqCompTimeInvalid: | 20419 | case ReqCompTimeInvalid: |
| 19413 | return ira->codegen->invalid_instruction; | 20420 | return ira->codegen->invalid_inst_gen; |
| 19414 | case ReqCompTimeYes: | 20421 | case ReqCompTimeYes: |
| 19415 | ir_add_error_node(ira, phi_instruction->base.source_node, | 20422 | ir_add_error(ira, &phi_instruction->base.base, |
| 19416 | buf_sprintf("values of type '%s' must be comptime known", buf_ptr(&resolved_type->name))); | 20423 | buf_sprintf("values of type '%s' must be comptime known", buf_ptr(&resolved_type->name))); |
| 19417 | return ira->codegen->invalid_instruction; | 20424 | return ira->codegen->invalid_inst_gen; |
| 19418 | case ReqCompTimeNo: | 20425 | case ReqCompTimeNo: |
| 19419 | break; | 20426 | break; |
| 19420 | } | 20427 | } |
| ... | @@ -19424,16 +20431,16 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19424,16 +20431,16 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19424 | // cast all values to the resolved type. however we can't put cast instructions in front of the phi instruction. | 20431 | // cast all values to the resolved type. however we can't put cast instructions in front of the phi instruction. |
| 19425 | // so we go back and insert the casts as the last instruction in the corresponding predecessor blocks, and | 20432 | // so we go back and insert the casts as the last instruction in the corresponding predecessor blocks, and |
| 19426 | // then make sure the branch instruction is preserved. | 20433 | // then make sure the branch instruction is preserved. |
| 19427 | IrBasicBlock *cur_bb = ira->new_irb.current_basic_block; | 20434 | IrBasicBlockGen *cur_bb = ira->new_irb.current_basic_block; |
| 19428 | for (size_t i = 0; i < new_incoming_values.length; i += 1) { | 20435 | for (size_t i = 0; i < new_incoming_values.length; i += 1) { |
| 19429 | IrInstruction *new_value = new_incoming_values.at(i); | 20436 | IrInstGen *new_value = new_incoming_values.at(i); |
| 19430 | IrBasicBlock *predecessor = new_incoming_blocks.at(i); | 20437 | IrBasicBlockGen *predecessor = new_incoming_blocks.at(i); |
| 19431 | ir_assert(predecessor->instruction_list.length != 0, &phi_instruction->base); | 20438 | ir_assert(predecessor->instruction_list.length != 0, &phi_instruction->base.base); |
| 19432 | IrInstruction *branch_instruction = predecessor->instruction_list.pop(); | 20439 | IrInstGen *branch_instruction = predecessor->instruction_list.pop(); |
| 19433 | ir_set_cursor_at_end(&ira->new_irb, predecessor); | 20440 | ir_set_cursor_at_end_gen(&ira->new_irb, predecessor); |
| 19434 | IrInstruction *casted_value = ir_implicit_cast(ira, new_value, resolved_type); | 20441 | IrInstGen *casted_value = ir_implicit_cast(ira, new_value, resolved_type); |
| 19435 | if (type_is_invalid(casted_value->value->type)) { | 20442 | if (type_is_invalid(casted_value->value->type)) { |
| 19436 | return ira->codegen->invalid_instruction; | 20443 | return ira->codegen->invalid_inst_gen; |
| 19437 | } | 20444 | } |
| 19438 | new_incoming_values.items[i] = casted_value; | 20445 | new_incoming_values.items[i] = casted_value; |
| 19439 | predecessor->instruction_list.append(branch_instruction); | 20446 | predecessor->instruction_list.append(branch_instruction); |
| ... | @@ -19444,12 +20451,10 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19444,12 +20451,10 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19444 | all_stack_ptrs = false; | 20451 | all_stack_ptrs = false; |
| 19445 | } | 20452 | } |
| 19446 | } | 20453 | } |
| 19447 | ir_set_cursor_at_end(&ira->new_irb, cur_bb); | 20454 | ir_set_cursor_at_end_gen(&ira->new_irb, cur_bb); |
| 19448 | | 20455 | |
| 19449 | IrInstruction *result = ir_build_phi(&ira->new_irb, | 20456 | IrInstGen *result = ir_build_phi_gen(ira, &phi_instruction->base.base, |
| 19450 | phi_instruction->base.scope, phi_instruction->base.source_node, | 20457 | new_incoming_blocks.length, new_incoming_blocks.items, new_incoming_values.items, resolved_type); |
| 19451 | new_incoming_blocks.length, new_incoming_blocks.items, new_incoming_values.items, nullptr); | | |
| 19452 | result->value->type = resolved_type; | | |
| 19453 | | 20458 | |
| 19454 | if (all_stack_ptrs) { | 20459 | if (all_stack_ptrs) { |
| 19455 | assert(result->value->special == ConstValSpecialRuntime); | 20460 | assert(result->value->special == ConstValSpecialRuntime); |
| ... | @@ -19459,17 +20464,17 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19459,17 +20464,17 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19459 | return result; | 20464 | return result; |
| 19460 | } | 20465 | } |
| 19461 | | 20466 | |
| 19462 | static IrInstruction *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstructionVarPtr *instruction) { | 20467 | static IrInstGen *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstSrcVarPtr *instruction) { |
| 19463 | ZigVar *var = instruction->var; | 20468 | ZigVar *var = instruction->var; |
| 19464 | IrInstruction *result = ir_get_var_ptr(ira, &instruction->base, var); | 20469 | IrInstGen *result = ir_get_var_ptr(ira, &instruction->base.base, var); |
| 19465 | if (instruction->crossed_fndef_scope != nullptr && !instr_is_comptime(result)) { | 20470 | if (instruction->crossed_fndef_scope != nullptr && !instr_is_comptime(result)) { |
| 19466 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, | 20471 | ErrorMsg *msg = ir_add_error(ira, &instruction->base.base, |
| 19467 | buf_sprintf("'%s' not accessible from inner function", var->name)); | 20472 | buf_sprintf("'%s' not accessible from inner function", var->name)); |
| 19468 | add_error_note(ira->codegen, msg, instruction->crossed_fndef_scope->base.source_node, | 20473 | add_error_note(ira->codegen, msg, instruction->crossed_fndef_scope->base.source_node, |
| 19469 | buf_sprintf("crossed function definition here")); | 20474 | buf_sprintf("crossed function definition here")); |
| 19470 | add_error_note(ira->codegen, msg, var->decl_node, | 20475 | add_error_note(ira->codegen, msg, var->decl_node, |
| 19471 | buf_sprintf("declared here")); | 20476 | buf_sprintf("declared here")); |
| 19472 | return ira->codegen->invalid_instruction; | 20477 | return ira->codegen->invalid_inst_gen; |
| 19473 | } | 20478 | } |
| 19474 | return result; | 20479 | return result; |
| 19475 | } | 20480 | } |
| ... | @@ -19520,17 +20525,17 @@ static ZigType *adjust_ptr_len(CodeGen *g, ZigType *ptr_type, PtrLen ptr_len) { | ... | @@ -19520,17 +20525,17 @@ static ZigType *adjust_ptr_len(CodeGen *g, ZigType *ptr_type, PtrLen ptr_len) { |
| 19520 | ptr_type->data.pointer.allow_zero); | 20525 | ptr_type->data.pointer.allow_zero); |
| 19521 | } | 20526 | } |
| 19522 | | 20527 | |
| 19523 | static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionElemPtr *elem_ptr_instruction) { | 20528 | static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemPtr *elem_ptr_instruction) { |
| 19524 | Error err; | 20529 | Error err; |
| 19525 | IrInstruction *array_ptr = elem_ptr_instruction->array_ptr->child; | 20530 | IrInstGen *array_ptr = elem_ptr_instruction->array_ptr->child; |
| 19526 | if (type_is_invalid(array_ptr->value->type)) | 20531 | if (type_is_invalid(array_ptr->value->type)) |
| 19527 | return ira->codegen->invalid_instruction; | 20532 | return ira->codegen->invalid_inst_gen; |
| 19528 | | 20533 | |
| 19529 | ZigValue *orig_array_ptr_val = array_ptr->value; | 20534 | ZigValue *orig_array_ptr_val = array_ptr->value; |
| 19530 | | 20535 | |
| 19531 | IrInstruction *elem_index = elem_ptr_instruction->elem_index->child; | 20536 | IrInstGen *elem_index = elem_ptr_instruction->elem_index->child; |
| 19532 | if (type_is_invalid(elem_index->value->type)) | 20537 | if (type_is_invalid(elem_index->value->type)) |
| 19533 | return ira->codegen->invalid_instruction; | 20538 | return ira->codegen->invalid_inst_gen; |
| 19534 | | 20539 | |
| 19535 | ZigType *ptr_type = orig_array_ptr_val->type; | 20540 | ZigType *ptr_type = orig_array_ptr_val->type; |
| 19536 | assert(ptr_type->id == ZigTypeIdPointer); | 20541 | assert(ptr_type->id == ZigTypeIdPointer); |
| ... | @@ -19542,7 +20547,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19542,7 +20547,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19542 | ZigType *return_type; | 20547 | ZigType *return_type; |
| 19543 | | 20548 | |
| 19544 | if (type_is_invalid(array_type)) { | 20549 | if (type_is_invalid(array_type)) { |
| 19545 | return ira->codegen->invalid_instruction; | 20550 | return ira->codegen->invalid_inst_gen; |
| 19546 | } else if (array_type->id == ZigTypeIdArray || | 20551 | } else if (array_type->id == ZigTypeIdArray || |
| 19547 | (array_type->id == ZigTypeIdPointer && | 20552 | (array_type->id == ZigTypeIdPointer && |
| 19548 | array_type->data.pointer.ptr_len == PtrLenSingle && | 20553 | array_type->data.pointer.ptr_len == PtrLenSingle && |
| ... | @@ -19553,15 +20558,15 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19553,15 +20558,15 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19553 | ptr_type = ptr_type->data.pointer.child_type; | 20558 | ptr_type = ptr_type->data.pointer.child_type; |
| 19554 | if (orig_array_ptr_val->special != ConstValSpecialRuntime) { | 20559 | if (orig_array_ptr_val->special != ConstValSpecialRuntime) { |
| 19555 | orig_array_ptr_val = const_ptr_pointee(ira, ira->codegen, orig_array_ptr_val, | 20560 | orig_array_ptr_val = const_ptr_pointee(ira, ira->codegen, orig_array_ptr_val, |
| 19556 | elem_ptr_instruction->base.source_node); | 20561 | elem_ptr_instruction->base.base.source_node); |
| 19557 | if (orig_array_ptr_val == nullptr) | 20562 | if (orig_array_ptr_val == nullptr) |
| 19558 | return ira->codegen->invalid_instruction; | 20563 | return ira->codegen->invalid_inst_gen; |
| 19559 | } | 20564 | } |
| 19560 | } | 20565 | } |
| 19561 | if (array_type->data.array.len == 0) { | 20566 | if (array_type->data.array.len == 0) { |
| 19562 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, | 20567 | ir_add_error_node(ira, elem_ptr_instruction->base.base.source_node, |
| 19563 | buf_sprintf("index 0 outside array of size 0")); | 20568 | buf_sprintf("index 0 outside array of size 0")); |
| 19564 | return ira->codegen->invalid_instruction; | 20569 | return ira->codegen->invalid_inst_gen; |
| 19565 | } | 20570 | } |
| 19566 | ZigType *child_type = array_type->data.array.child_type; | 20571 | ZigType *child_type = array_type->data.array.child_type; |
| 19567 | if (ptr_type->data.pointer.host_int_bytes == 0) { | 20572 | if (ptr_type->data.pointer.host_int_bytes == 0) { |
| ... | @@ -19572,7 +20577,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19572,7 +20577,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19572 | } else { | 20577 | } else { |
| 19573 | uint64_t elem_val_scalar; | 20578 | uint64_t elem_val_scalar; |
| 19574 | if (!ir_resolve_usize(ira, elem_index, &elem_val_scalar)) | 20579 | if (!ir_resolve_usize(ira, elem_index, &elem_val_scalar)) |
| 19575 | return ira->codegen->invalid_instruction; | 20580 | return ira->codegen->invalid_inst_gen; |
| 19576 | | 20581 | |
| 19577 | size_t bit_width = type_size_bits(ira->codegen, child_type); | 20582 | size_t bit_width = type_size_bits(ira->codegen, child_type); |
| 19578 | size_t bit_offset = bit_width * elem_val_scalar; | 20583 | size_t bit_offset = bit_width * elem_val_scalar; |
| ... | @@ -19584,9 +20589,9 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19584,9 +20589,9 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19584 | } | 20589 | } |
| 19585 | } else if (array_type->id == ZigTypeIdPointer) { | 20590 | } else if (array_type->id == ZigTypeIdPointer) { |
| 19586 | if (array_type->data.pointer.ptr_len == PtrLenSingle) { | 20591 | if (array_type->data.pointer.ptr_len == PtrLenSingle) { |
| 19587 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, | 20592 | ir_add_error_node(ira, elem_ptr_instruction->base.base.source_node, |
| 19588 | buf_sprintf("index of single-item pointer")); | 20593 | buf_sprintf("index of single-item pointer")); |
| 19589 | return ira->codegen->invalid_instruction; | 20594 | return ira->codegen->invalid_inst_gen; |
| 19590 | } | 20595 | } |
| 19591 | return_type = adjust_ptr_len(ira->codegen, array_type, elem_ptr_instruction->ptr_len); | 20596 | return_type = adjust_ptr_len(ira->codegen, array_type, elem_ptr_instruction->ptr_len); |
| 19592 | } else if (is_slice(array_type)) { | 20597 | } else if (is_slice(array_type)) { |
| ... | @@ -19600,38 +20605,38 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19600,38 +20605,38 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19600 | array_type->data.structure.resolve_status == ResolveStatusBeingInferred) | 20605 | array_type->data.structure.resolve_status == ResolveStatusBeingInferred) |
| 19601 | { | 20606 | { |
| 19602 | ZigType *usize = ira->codegen->builtin_types.entry_usize; | 20607 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 19603 | IrInstruction *casted_elem_index = ir_implicit_cast(ira, elem_index, usize); | 20608 | IrInstGen *casted_elem_index = ir_implicit_cast(ira, elem_index, usize); |
| 19604 | if (type_is_invalid(casted_elem_index->value->type)) | 20609 | if (type_is_invalid(casted_elem_index->value->type)) |
| 19605 | return ira->codegen->invalid_instruction; | 20610 | return ira->codegen->invalid_inst_gen; |
| 19606 | ir_assert(instr_is_comptime(casted_elem_index), &elem_ptr_instruction->base); | 20611 | ir_assert(instr_is_comptime(casted_elem_index), &elem_ptr_instruction->base.base); |
| 19607 | Buf *field_name = buf_alloc(); | 20612 | Buf *field_name = buf_alloc(); |
| 19608 | bigint_append_buf(field_name, &casted_elem_index->value->data.x_bigint, 10); | 20613 | bigint_append_buf(field_name, &casted_elem_index->value->data.x_bigint, 10); |
| 19609 | return ir_analyze_inferred_field_ptr(ira, field_name, &elem_ptr_instruction->base, | 20614 | return ir_analyze_inferred_field_ptr(ira, field_name, &elem_ptr_instruction->base.base, |
| 19610 | array_ptr, array_type); | 20615 | array_ptr, array_type); |
| 19611 | } else if (is_tuple(array_type)) { | 20616 | } else if (is_tuple(array_type)) { |
| 19612 | uint64_t elem_index_scalar; | 20617 | uint64_t elem_index_scalar; |
| 19613 | if (!ir_resolve_usize(ira, elem_index, &elem_index_scalar)) | 20618 | if (!ir_resolve_usize(ira, elem_index, &elem_index_scalar)) |
| 19614 | return ira->codegen->invalid_instruction; | 20619 | return ira->codegen->invalid_inst_gen; |
| 19615 | if (elem_index_scalar >= array_type->data.structure.src_field_count) { | 20620 | if (elem_index_scalar >= array_type->data.structure.src_field_count) { |
| 19616 | ir_add_error(ira, &elem_ptr_instruction->base, buf_sprintf( | 20621 | ir_add_error(ira, &elem_ptr_instruction->base.base, buf_sprintf( |
| 19617 | "field index %" ZIG_PRI_u64 " outside tuple '%s' which has %" PRIu32 " fields", | 20622 | "field index %" ZIG_PRI_u64 " outside tuple '%s' which has %" PRIu32 " fields", |
| 19618 | elem_index_scalar, buf_ptr(&array_type->name), | 20623 | elem_index_scalar, buf_ptr(&array_type->name), |
| 19619 | array_type->data.structure.src_field_count)); | 20624 | array_type->data.structure.src_field_count)); |
| 19620 | return ira->codegen->invalid_instruction; | 20625 | return ira->codegen->invalid_inst_gen; |
| 19621 | } | 20626 | } |
| 19622 | TypeStructField *field = array_type->data.structure.fields[elem_index_scalar]; | 20627 | TypeStructField *field = array_type->data.structure.fields[elem_index_scalar]; |
| 19623 | return ir_analyze_struct_field_ptr(ira, &elem_ptr_instruction->base, field, array_ptr, | 20628 | return ir_analyze_struct_field_ptr(ira, &elem_ptr_instruction->base.base, field, array_ptr, |
| 19624 | array_type, false); | 20629 | array_type, false); |
| 19625 | } else { | 20630 | } else { |
| 19626 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, | 20631 | ir_add_error_node(ira, elem_ptr_instruction->base.base.source_node, |
| 19627 | buf_sprintf("array access of non-array type '%s'", buf_ptr(&array_type->name))); | 20632 | buf_sprintf("array access of non-array type '%s'", buf_ptr(&array_type->name))); |
| 19628 | return ira->codegen->invalid_instruction; | 20633 | return ira->codegen->invalid_inst_gen; |
| 19629 | } | 20634 | } |
| 19630 | | 20635 | |
| 19631 | ZigType *usize = ira->codegen->builtin_types.entry_usize; | 20636 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 19632 | IrInstruction *casted_elem_index = ir_implicit_cast(ira, elem_index, usize); | 20637 | IrInstGen *casted_elem_index = ir_implicit_cast(ira, elem_index, usize); |
| 19633 | if (casted_elem_index == ira->codegen->invalid_instruction) | 20638 | if (type_is_invalid(casted_elem_index->value->type)) |
| 19634 | return ira->codegen->invalid_instruction; | 20639 | return ira->codegen->invalid_inst_gen; |
| 19635 | | 20640 | |
| 19636 | bool safety_check_on = elem_ptr_instruction->safety_check_on; | 20641 | bool safety_check_on = elem_ptr_instruction->safety_check_on; |
| 19637 | if (instr_is_comptime(casted_elem_index)) { | 20642 | if (instr_is_comptime(casted_elem_index)) { |
| ... | @@ -19640,15 +20645,15 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19640,15 +20645,15 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19640 | uint64_t array_len = array_type->data.array.len; | 20645 | uint64_t array_len = array_type->data.array.len; |
| 19641 | if (index == array_len && array_type->data.array.sentinel != nullptr) { | 20646 | if (index == array_len && array_type->data.array.sentinel != nullptr) { |
| 19642 | ZigType *elem_type = array_type->data.array.child_type; | 20647 | ZigType *elem_type = array_type->data.array.child_type; |
| 19643 | IrInstruction *sentinel_elem = ir_const(ira, &elem_ptr_instruction->base, elem_type); | 20648 | IrInstGen *sentinel_elem = ir_const(ira, &elem_ptr_instruction->base.base, elem_type); |
| 19644 | copy_const_val(sentinel_elem->value, array_type->data.array.sentinel); | 20649 | copy_const_val(sentinel_elem->value, array_type->data.array.sentinel); |
| 19645 | return ir_get_ref(ira, &elem_ptr_instruction->base, sentinel_elem, true, false); | 20650 | return ir_get_ref(ira, &elem_ptr_instruction->base.base, sentinel_elem, true, false); |
| 19646 | } | 20651 | } |
| 19647 | if (index >= array_len) { | 20652 | if (index >= array_len) { |
| 19648 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, | 20653 | ir_add_error_node(ira, elem_ptr_instruction->base.base.source_node, |
| 19649 | buf_sprintf("index %" ZIG_PRI_u64 " outside array of size %" ZIG_PRI_u64, | 20654 | buf_sprintf("index %" ZIG_PRI_u64 " outside array of size %" ZIG_PRI_u64, |
| 19650 | index, array_len)); | 20655 | index, array_len)); |
| 19651 | return ira->codegen->invalid_instruction; | 20656 | return ira->codegen->invalid_inst_gen; |
| 19652 | } | 20657 | } |
| 19653 | safety_check_on = false; | 20658 | safety_check_on = false; |
| 19654 | } | 20659 | } |
| ... | @@ -19664,7 +20669,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19664,7 +20669,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19664 | // figure out the largest alignment possible | 20669 | // figure out the largest alignment possible |
| 19665 | | 20670 | |
| 19666 | if ((err = type_resolve(ira->codegen, return_type->data.pointer.child_type, ResolveStatusSizeKnown))) | 20671 | if ((err = type_resolve(ira->codegen, return_type->data.pointer.child_type, ResolveStatusSizeKnown))) |
| 19667 | return ira->codegen->invalid_instruction; | 20672 | return ira->codegen->invalid_inst_gen; |
| 19668 | | 20673 | |
| 19669 | uint64_t elem_size = type_size(ira->codegen, return_type->data.pointer.child_type); | 20674 | uint64_t elem_size = type_size(ira->codegen, return_type->data.pointer.child_type); |
| 19670 | uint64_t abi_align = get_abi_alignment(ira->codegen, return_type->data.pointer.child_type); | 20675 | uint64_t abi_align = get_abi_alignment(ira->codegen, return_type->data.pointer.child_type); |
| ... | @@ -19696,9 +20701,9 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19696,9 +20701,9 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19696 | (orig_array_ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar || array_type->id == ZigTypeIdArray)) | 20701 | (orig_array_ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar || array_type->id == ZigTypeIdArray)) |
| 19697 | { | 20702 | { |
| 19698 | ZigValue *array_ptr_val = const_ptr_pointee(ira, ira->codegen, orig_array_ptr_val, | 20703 | ZigValue *array_ptr_val = const_ptr_pointee(ira, ira->codegen, orig_array_ptr_val, |
| 19699 | elem_ptr_instruction->base.source_node); | 20704 | elem_ptr_instruction->base.base.source_node); |
| 19700 | if (array_ptr_val == nullptr) | 20705 | if (array_ptr_val == nullptr) |
| 19701 | return ira->codegen->invalid_instruction; | 20706 | return ira->codegen->invalid_inst_gen; |
| 19702 | | 20707 | |
| 19703 | if (array_ptr_val->special == ConstValSpecialUndef && | 20708 | if (array_ptr_val->special == ConstValSpecialUndef && |
| 19704 | elem_ptr_instruction->init_array_type_source_node != nullptr) | 20709 | elem_ptr_instruction->init_array_type_source_node != nullptr) |
| ... | @@ -19716,16 +20721,16 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19716,16 +20721,16 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19716 | elem_val->parent.data.p_array.elem_index = i; | 20721 | elem_val->parent.data.p_array.elem_index = i; |
| 19717 | } | 20722 | } |
| 19718 | } else if (is_slice(array_type)) { | 20723 | } else if (is_slice(array_type)) { |
| 19719 | ir_assert(array_ptr->value->type->id == ZigTypeIdPointer, &elem_ptr_instruction->base); | 20724 | ir_assert(array_ptr->value->type->id == ZigTypeIdPointer, &elem_ptr_instruction->base.base); |
| 19720 | ZigType *actual_array_type = array_ptr->value->type->data.pointer.child_type; | 20725 | ZigType *actual_array_type = array_ptr->value->type->data.pointer.child_type; |
| 19721 | | 20726 | |
| 19722 | if (type_is_invalid(actual_array_type)) | 20727 | if (type_is_invalid(actual_array_type)) |
| 19723 | return ira->codegen->invalid_instruction; | 20728 | return ira->codegen->invalid_inst_gen; |
| 19724 | if (actual_array_type->id != ZigTypeIdArray) { | 20729 | if (actual_array_type->id != ZigTypeIdArray) { |
| 19725 | ir_add_error_node(ira, elem_ptr_instruction->init_array_type_source_node, | 20730 | ir_add_error_node(ira, elem_ptr_instruction->init_array_type_source_node, |
| 19726 | buf_sprintf("array literal requires address-of operator to coerce to slice type '%s'", | 20731 | buf_sprintf("array literal requires address-of operator to coerce to slice type '%s'", |
| 19727 | buf_ptr(&actual_array_type->name))); | 20732 | buf_ptr(&actual_array_type->name))); |
| 19728 | return ira->codegen->invalid_instruction; | 20733 | return ira->codegen->invalid_inst_gen; |
| 19729 | } | 20734 | } |
| 19730 | | 20735 | |
| 19731 | ZigValue *array_init_val = create_const_vals(1); | 20736 | ZigValue *array_init_val = create_const_vals(1); |
| ... | @@ -19750,7 +20755,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19750,7 +20755,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19750 | ir_add_error_node(ira, elem_ptr_instruction->init_array_type_source_node, | 20755 | ir_add_error_node(ira, elem_ptr_instruction->init_array_type_source_node, |
| 19751 | buf_sprintf("expected array type or [_], found '%s'", | 20756 | buf_sprintf("expected array type or [_], found '%s'", |
| 19752 | buf_ptr(&array_type->name))); | 20757 | buf_ptr(&array_type->name))); |
| 19753 | return ira->codegen->invalid_instruction; | 20758 | return ira->codegen->invalid_inst_gen; |
| 19754 | } | 20759 | } |
| 19755 | } | 20760 | } |
| 19756 | | 20761 | |
| ... | @@ -19759,12 +20764,12 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19759,12 +20764,12 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19759 | array_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr)) | 20764 | array_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr)) |
| 19760 | { | 20765 | { |
| 19761 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, | 20766 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, |
| 19762 | elem_ptr_instruction->base.source_node, array_ptr_val, UndefOk))) | 20767 | elem_ptr_instruction->base.base.source_node, array_ptr_val, UndefOk))) |
| 19763 | { | 20768 | { |
| 19764 | return ira->codegen->invalid_instruction; | 20769 | return ira->codegen->invalid_inst_gen; |
| 19765 | } | 20770 | } |
| 19766 | if (array_type->id == ZigTypeIdPointer) { | 20771 | if (array_type->id == ZigTypeIdPointer) { |
| 19767 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); | 20772 | IrInstGen *result = ir_const(ira, &elem_ptr_instruction->base.base, return_type); |
| 19768 | ZigValue *out_val = result->value; | 20773 | ZigValue *out_val = result->value; |
| 19769 | out_val->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; | 20774 | out_val->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; |
| 19770 | size_t new_index; | 20775 | size_t new_index; |
| ... | @@ -19833,33 +20838,31 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19833,33 +20838,31 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19833 | zig_panic("TODO elem ptr on a null pointer"); | 20838 | zig_panic("TODO elem ptr on a null pointer"); |
| 19834 | } | 20839 | } |
| 19835 | if (new_index >= mem_size) { | 20840 | if (new_index >= mem_size) { |
| 19836 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, | 20841 | ir_add_error_node(ira, elem_ptr_instruction->base.base.source_node, |
| 19837 | buf_sprintf("index %" ZIG_PRI_u64 " outside pointer of size %" ZIG_PRI_usize "", index, old_size)); | 20842 | buf_sprintf("index %" ZIG_PRI_u64 " outside pointer of size %" ZIG_PRI_usize "", index, old_size)); |
| 19838 | return ira->codegen->invalid_instruction; | 20843 | return ira->codegen->invalid_inst_gen; |
| 19839 | } | 20844 | } |
| 19840 | return result; | 20845 | return result; |
| 19841 | } else if (is_slice(array_type)) { | 20846 | } else if (is_slice(array_type)) { |
| 19842 | ZigValue *ptr_field = array_ptr_val->data.x_struct.fields[slice_ptr_index]; | 20847 | ZigValue *ptr_field = array_ptr_val->data.x_struct.fields[slice_ptr_index]; |
| 19843 | ir_assert(ptr_field != nullptr, &elem_ptr_instruction->base); | 20848 | ir_assert(ptr_field != nullptr, &elem_ptr_instruction->base.base); |
| 19844 | if (ptr_field->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { | 20849 | if (ptr_field->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { |
| 19845 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, | 20850 | return ir_build_elem_ptr_gen(ira, elem_ptr_instruction->base.base.scope, |
| 19846 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, false, | 20851 | elem_ptr_instruction->base.base.source_node, array_ptr, casted_elem_index, false, |
| 19847 | elem_ptr_instruction->ptr_len, nullptr); | 20852 | return_type); |
| 19848 | result->value->type = return_type; | | |
| 19849 | return result; | | |
| 19850 | } | 20853 | } |
| 19851 | ZigValue *len_field = array_ptr_val->data.x_struct.fields[slice_len_index]; | 20854 | ZigValue *len_field = array_ptr_val->data.x_struct.fields[slice_len_index]; |
| 19852 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); | 20855 | IrInstGen *result = ir_const(ira, &elem_ptr_instruction->base.base, return_type); |
| 19853 | ZigValue *out_val = result->value; | 20856 | ZigValue *out_val = result->value; |
| 19854 | ZigType *slice_ptr_type = array_type->data.structure.fields[slice_ptr_index]->type_entry; | 20857 | ZigType *slice_ptr_type = array_type->data.structure.fields[slice_ptr_index]->type_entry; |
| 19855 | uint64_t slice_len = bigint_as_u64(&len_field->data.x_bigint); | 20858 | uint64_t slice_len = bigint_as_u64(&len_field->data.x_bigint); |
| 19856 | uint64_t full_slice_len = slice_len + | 20859 | uint64_t full_slice_len = slice_len + |
| 19857 | ((slice_ptr_type->data.pointer.sentinel != nullptr) ? 1 : 0); | 20860 | ((slice_ptr_type->data.pointer.sentinel != nullptr) ? 1 : 0); |
| 19858 | if (index >= full_slice_len) { | 20861 | if (index >= full_slice_len) { |
| 19859 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, | 20862 | ir_add_error_node(ira, elem_ptr_instruction->base.base.source_node, |
| 19860 | buf_sprintf("index %" ZIG_PRI_u64 " outside slice of size %" ZIG_PRI_u64, | 20863 | buf_sprintf("index %" ZIG_PRI_u64 " outside slice of size %" ZIG_PRI_u64, |
| 19861 | index, slice_len)); | 20864 | index, slice_len)); |
| 19862 | return ira->codegen->invalid_instruction; | 20865 | return ira->codegen->invalid_inst_gen; |
| 19863 | } | 20866 | } |
| 19864 | out_val->data.x_ptr.mut = ptr_field->data.x_ptr.mut; | 20867 | out_val->data.x_ptr.mut = ptr_field->data.x_ptr.mut; |
| 19865 | switch (ptr_field->data.x_ptr.special) { | 20868 | switch (ptr_field->data.x_ptr.special) { |
| ... | @@ -19879,7 +20882,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19879,7 +20882,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19879 | { | 20882 | { |
| 19880 | ir_assert(new_index < | 20883 | ir_assert(new_index < |
| 19881 | ptr_field->data.x_ptr.data.base_array.array_val->type->data.array.len, | 20884 | ptr_field->data.x_ptr.data.base_array.array_val->type->data.array.len, |
| 19882 | &elem_ptr_instruction->base); | 20885 | &elem_ptr_instruction->base.base); |
| 19883 | } | 20886 | } |
| 19884 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; | 20887 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; |
| 19885 | out_val->data.x_ptr.data.base_array.array_val = | 20888 | out_val->data.x_ptr.data.base_array.array_val = |
| ... | @@ -19904,15 +20907,14 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19904,15 +20907,14 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19904 | } | 20907 | } |
| 19905 | return result; | 20908 | return result; |
| 19906 | } else if (array_type->id == ZigTypeIdArray || array_type->id == ZigTypeIdVector) { | 20909 | } else if (array_type->id == ZigTypeIdArray || array_type->id == ZigTypeIdVector) { |
| 19907 | IrInstruction *result; | 20910 | IrInstGen *result; |
| 19908 | if (orig_array_ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 20911 | if (orig_array_ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 19909 | result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, | 20912 | result = ir_build_elem_ptr_gen(ira, elem_ptr_instruction->base.base.scope, |
| 19910 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, | 20913 | elem_ptr_instruction->base.base.source_node, array_ptr, casted_elem_index, |
| 19911 | false, elem_ptr_instruction->ptr_len, nullptr); | 20914 | false, return_type); |
| 19912 | result->value->type = return_type; | | |
| 19913 | result->value->special = ConstValSpecialStatic; | 20915 | result->value->special = ConstValSpecialStatic; |
| 19914 | } else { | 20916 | } else { |
| 19915 | result = ir_const(ira, &elem_ptr_instruction->base, return_type); | 20917 | result = ir_const(ira, &elem_ptr_instruction->base.base, return_type); |
| 19916 | } | 20918 | } |
| 19917 | ZigValue *out_val = result->value; | 20919 | ZigValue *out_val = result->value; |
| 19918 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; | 20920 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; |
| ... | @@ -19938,19 +20940,19 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19938,19 +20940,19 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19938 | // runtime known element index | 20940 | // runtime known element index |
| 19939 | switch (type_requires_comptime(ira->codegen, return_type)) { | 20941 | switch (type_requires_comptime(ira->codegen, return_type)) { |
| 19940 | case ReqCompTimeYes: | 20942 | case ReqCompTimeYes: |
| 19941 | ir_add_error(ira, elem_index, | 20943 | ir_add_error(ira, &elem_index->base, |
| 19942 | buf_sprintf("values of type '%s' must be comptime known, but index value is runtime known", | 20944 | buf_sprintf("values of type '%s' must be comptime known, but index value is runtime known", |
| 19943 | buf_ptr(&return_type->data.pointer.child_type->name))); | 20945 | buf_ptr(&return_type->data.pointer.child_type->name))); |
| 19944 | return ira->codegen->invalid_instruction; | 20946 | return ira->codegen->invalid_inst_gen; |
| 19945 | case ReqCompTimeInvalid: | 20947 | case ReqCompTimeInvalid: |
| 19946 | return ira->codegen->invalid_instruction; | 20948 | return ira->codegen->invalid_inst_gen; |
| 19947 | case ReqCompTimeNo: | 20949 | case ReqCompTimeNo: |
| 19948 | break; | 20950 | break; |
| 19949 | } | 20951 | } |
| 19950 | | 20952 | |
| 19951 | if (return_type->data.pointer.explicit_alignment != 0) { | 20953 | if (return_type->data.pointer.explicit_alignment != 0) { |
| 19952 | if ((err = type_resolve(ira->codegen, return_type->data.pointer.child_type, ResolveStatusSizeKnown))) | 20954 | if ((err = type_resolve(ira->codegen, return_type->data.pointer.child_type, ResolveStatusSizeKnown))) |
| 19953 | return ira->codegen->invalid_instruction; | 20955 | return ira->codegen->invalid_inst_gen; |
| 19954 | | 20956 | |
| 19955 | uint64_t elem_size = type_size(ira->codegen, return_type->data.pointer.child_type); | 20957 | uint64_t elem_size = type_size(ira->codegen, return_type->data.pointer.child_type); |
| 19956 | uint64_t abi_align = get_abi_alignment(ira->codegen, return_type->data.pointer.child_type); | 20958 | uint64_t abi_align = get_abi_alignment(ira->codegen, return_type->data.pointer.child_type); |
| ... | @@ -19968,16 +20970,13 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19968,16 +20970,13 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19968 | } | 20970 | } |
| 19969 | } | 20971 | } |
| 19970 | | 20972 | |
| 19971 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, | 20973 | return ir_build_elem_ptr_gen(ira, elem_ptr_instruction->base.base.scope, |
| 19972 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, safety_check_on, | 20974 | elem_ptr_instruction->base.base.source_node, array_ptr, casted_elem_index, safety_check_on, return_type); |
| 19973 | elem_ptr_instruction->ptr_len, nullptr); | | |
| 19974 | result->value->type = return_type; | | |
| 19975 | return result; | | |
| 19976 | } | 20975 | } |
| 19977 | | 20976 | |
| 19978 | static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, | 20977 | static IrInstGen *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 19979 | ZigType *bare_struct_type, Buf *field_name, IrInstruction *source_instr, | 20978 | ZigType *bare_struct_type, Buf *field_name, IrInst* source_instr, |
| 19980 | IrInstruction *container_ptr, ZigType *container_type) | 20979 | IrInstGen *container_ptr, ZigType *container_type) |
| 19981 | { | 20980 | { |
| 19982 | if (!is_slice(bare_struct_type)) { | 20981 | if (!is_slice(bare_struct_type)) { |
| 19983 | ScopeDecls *container_scope = get_container_scope(bare_struct_type); | 20982 | ScopeDecls *container_scope = get_container_scope(bare_struct_type); |
| ... | @@ -19987,29 +20986,37 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, | ... | @@ -19987,29 +20986,37 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 19987 | if (tld->id == TldIdFn) { | 20986 | if (tld->id == TldIdFn) { |
| 19988 | resolve_top_level_decl(ira->codegen, tld, source_instr->source_node, false); | 20987 | resolve_top_level_decl(ira->codegen, tld, source_instr->source_node, false); |
| 19989 | if (tld->resolution == TldResolutionInvalid) | 20988 | if (tld->resolution == TldResolutionInvalid) |
| 19990 | return ira->codegen->invalid_instruction; | 20989 | return ira->codegen->invalid_inst_gen; |
| | 20990 | if (tld->resolution == TldResolutionResolving) |
| | 20991 | return ir_error_dependency_loop(ira, source_instr); |
| | 20992 | |
| 19991 | TldFn *tld_fn = (TldFn *)tld; | 20993 | TldFn *tld_fn = (TldFn *)tld; |
| 19992 | ZigFn *fn_entry = tld_fn->fn_entry; | 20994 | ZigFn *fn_entry = tld_fn->fn_entry; |
| | 20995 | assert(fn_entry != nullptr); |
| | 20996 | |
| 19993 | if (type_is_invalid(fn_entry->type_entry)) | 20997 | if (type_is_invalid(fn_entry->type_entry)) |
| 19994 | return ira->codegen->invalid_instruction; | 20998 | return ira->codegen->invalid_inst_gen; |
| 19995 | | 20999 | |
| 19996 | IrInstruction *bound_fn_value = ir_build_const_bound_fn(&ira->new_irb, source_instr->scope, | 21000 | IrInstGen *bound_fn_value = ir_const_bound_fn(ira, source_instr, fn_entry, container_ptr); |
| 19997 | source_instr->source_node, fn_entry, container_ptr); | | |
| 19998 | return ir_get_ref(ira, source_instr, bound_fn_value, true, false); | 21001 | return ir_get_ref(ira, source_instr, bound_fn_value, true, false); |
| 19999 | } else if (tld->id == TldIdVar) { | 21002 | } else if (tld->id == TldIdVar) { |
| 20000 | resolve_top_level_decl(ira->codegen, tld, source_instr->source_node, false); | 21003 | resolve_top_level_decl(ira->codegen, tld, source_instr->source_node, false); |
| 20001 | if (tld->resolution == TldResolutionInvalid) | 21004 | if (tld->resolution == TldResolutionInvalid) |
| 20002 | return ira->codegen->invalid_instruction; | 21005 | return ira->codegen->invalid_inst_gen; |
| | 21006 | if (tld->resolution == TldResolutionResolving) |
| | 21007 | return ir_error_dependency_loop(ira, source_instr); |
| | 21008 | |
| 20003 | TldVar *tld_var = (TldVar *)tld; | 21009 | TldVar *tld_var = (TldVar *)tld; |
| 20004 | ZigVar *var = tld_var->var; | 21010 | ZigVar *var = tld_var->var; |
| | 21011 | assert(var != nullptr); |
| | 21012 | |
| 20005 | if (type_is_invalid(var->var_type)) | 21013 | if (type_is_invalid(var->var_type)) |
| 20006 | return ira->codegen->invalid_instruction; | 21014 | return ira->codegen->invalid_inst_gen; |
| 20007 | | 21015 | |
| 20008 | if (var->const_value->type->id == ZigTypeIdFn) { | 21016 | if (var->const_value->type->id == ZigTypeIdFn) { |
| 20009 | ir_assert(var->const_value->data.x_ptr.special == ConstPtrSpecialFunction, source_instr); | 21017 | ir_assert(var->const_value->data.x_ptr.special == ConstPtrSpecialFunction, source_instr); |
| 20010 | ZigFn *fn = var->const_value->data.x_ptr.data.fn.fn_entry; | 21018 | ZigFn *fn = var->const_value->data.x_ptr.data.fn.fn_entry; |
| 20011 | IrInstruction *bound_fn_value = ir_build_const_bound_fn(&ira->new_irb, source_instr->scope, | 21019 | IrInstGen *bound_fn_value = ir_const_bound_fn(ira, source_instr, fn, container_ptr); |
| 20012 | source_instr->source_node, fn, container_ptr); | | |
| 20013 | return ir_get_ref(ira, source_instr, bound_fn_value, true, false); | 21020 | return ir_get_ref(ira, source_instr, bound_fn_value, true, false); |
| 20014 | } | 21021 | } |
| 20015 | } | 21022 | } |
| ... | @@ -20029,7 +21036,7 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, | ... | @@ -20029,7 +21036,7 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 20029 | } | 21036 | } |
| 20030 | ir_add_error_node(ira, source_instr->source_node, | 21037 | ir_add_error_node(ira, source_instr->source_node, |
| 20031 | buf_sprintf("no member named '%s' in %s'%s'", buf_ptr(field_name), prefix_name, buf_ptr(&bare_struct_type->name))); | 21038 | buf_sprintf("no member named '%s' in %s'%s'", buf_ptr(field_name), prefix_name, buf_ptr(&bare_struct_type->name))); |
| 20032 | return ira->codegen->invalid_instruction; | 21039 | return ira->codegen->invalid_inst_gen; |
| 20033 | } | 21040 | } |
| 20034 | | 21041 | |
| 20035 | static void memoize_field_init_val(CodeGen *codegen, ZigType *container_type, TypeStructField *field) { | 21042 | static void memoize_field_init_val(CodeGen *codegen, ZigType *container_type, TypeStructField *field) { |
| ... | @@ -20044,24 +21051,24 @@ static void memoize_field_init_val(CodeGen *codegen, ZigType *container_type, Ty | ... | @@ -20044,24 +21051,24 @@ static void memoize_field_init_val(CodeGen *codegen, ZigType *container_type, Ty |
| 20044 | field->type_entry, nullptr, UndefOk); | 21051 | field->type_entry, nullptr, UndefOk); |
| 20045 | } | 21052 | } |
| 20046 | | 21053 | |
| 20047 | static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction *source_instr, | 21054 | static IrInstGen *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInst* source_instr, |
| 20048 | TypeStructField *field, IrInstruction *struct_ptr, ZigType *struct_type, bool initializing) | 21055 | TypeStructField *field, IrInstGen *struct_ptr, ZigType *struct_type, bool initializing) |
| 20049 | { | 21056 | { |
| 20050 | Error err; | 21057 | Error err; |
| 20051 | ZigType *field_type = resolve_struct_field_type(ira->codegen, field); | 21058 | ZigType *field_type = resolve_struct_field_type(ira->codegen, field); |
| 20052 | if (field_type == nullptr) | 21059 | if (field_type == nullptr) |
| 20053 | return ira->codegen->invalid_instruction; | 21060 | return ira->codegen->invalid_inst_gen; |
| 20054 | if (field->is_comptime) { | 21061 | if (field->is_comptime) { |
| 20055 | IrInstruction *elem = ir_const(ira, source_instr, field_type); | 21062 | IrInstGen *elem = ir_const(ira, source_instr, field_type); |
| 20056 | memoize_field_init_val(ira->codegen, struct_type, field); | 21063 | memoize_field_init_val(ira->codegen, struct_type, field); |
| 20057 | copy_const_val(elem->value, field->init_val); | 21064 | copy_const_val(elem->value, field->init_val); |
| 20058 | return ir_get_ref(ira, source_instr, elem, true, false); | 21065 | return ir_get_ref(ira, source_instr, elem, true, false); |
| 20059 | } | 21066 | } |
| 20060 | switch (type_has_one_possible_value(ira->codegen, field_type)) { | 21067 | switch (type_has_one_possible_value(ira->codegen, field_type)) { |
| 20061 | case OnePossibleValueInvalid: | 21068 | case OnePossibleValueInvalid: |
| 20062 | return ira->codegen->invalid_instruction; | 21069 | return ira->codegen->invalid_inst_gen; |
| 20063 | case OnePossibleValueYes: { | 21070 | case OnePossibleValueYes: { |
| 20064 | IrInstruction *elem = ir_const_move(ira, source_instr, | 21071 | IrInstGen *elem = ir_const_move(ira, source_instr, |
| 20065 | get_the_one_possible_value(ira->codegen, field_type)); | 21072 | get_the_one_possible_value(ira->codegen, field_type)); |
| 20066 | return ir_get_ref(ira, source_instr, elem, false, false); | 21073 | return ir_get_ref(ira, source_instr, elem, false, false); |
| 20067 | } | 21074 | } |
| ... | @@ -20079,7 +21086,7 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -20079,7 +21086,7 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 20079 | (struct_type->data.structure.layout == ContainerLayoutAuto) ? | 21086 | (struct_type->data.structure.layout == ContainerLayoutAuto) ? |
| 20080 | ResolveStatusZeroBitsKnown : ResolveStatusSizeKnown; | 21087 | ResolveStatusZeroBitsKnown : ResolveStatusSizeKnown; |
| 20081 | if ((err = type_resolve(ira->codegen, struct_type, needed_resolve_status))) | 21088 | if ((err = type_resolve(ira->codegen, struct_type, needed_resolve_status))) |
| 20082 | return ira->codegen->invalid_instruction; | 21089 | return ira->codegen->invalid_inst_gen; |
| 20083 | assert(struct_ptr->value->type->id == ZigTypeIdPointer); | 21090 | assert(struct_ptr->value->type->id == ZigTypeIdPointer); |
| 20084 | uint32_t ptr_bit_offset = struct_ptr->value->type->data.pointer.bit_offset_in_host; | 21091 | uint32_t ptr_bit_offset = struct_ptr->value->type->data.pointer.bit_offset_in_host; |
| 20085 | uint32_t ptr_host_int_bytes = struct_ptr->value->type->data.pointer.host_int_bytes; | 21092 | uint32_t ptr_host_int_bytes = struct_ptr->value->type->data.pointer.host_int_bytes; |
| ... | @@ -20093,14 +21100,14 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -20093,14 +21100,14 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 20093 | if (instr_is_comptime(struct_ptr)) { | 21100 | if (instr_is_comptime(struct_ptr)) { |
| 20094 | ZigValue *ptr_val = ir_resolve_const(ira, struct_ptr, UndefBad); | 21101 | ZigValue *ptr_val = ir_resolve_const(ira, struct_ptr, UndefBad); |
| 20095 | if (!ptr_val) | 21102 | if (!ptr_val) |
| 20096 | return ira->codegen->invalid_instruction; | 21103 | return ira->codegen->invalid_inst_gen; |
| 20097 | | 21104 | |
| 20098 | if (ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 21105 | if (ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 20099 | ZigValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 21106 | ZigValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 20100 | if (struct_val == nullptr) | 21107 | if (struct_val == nullptr) |
| 20101 | return ira->codegen->invalid_instruction; | 21108 | return ira->codegen->invalid_inst_gen; |
| 20102 | if (type_is_invalid(struct_val->type)) | 21109 | if (type_is_invalid(struct_val->type)) |
| 20103 | return ira->codegen->invalid_instruction; | 21110 | return ira->codegen->invalid_inst_gen; |
| 20104 | if (initializing && struct_val->special == ConstValSpecialUndef) { | 21111 | if (initializing && struct_val->special == ConstValSpecialUndef) { |
| 20105 | struct_val->data.x_struct.fields = alloc_const_vals_ptrs(struct_type->data.structure.src_field_count); | 21112 | struct_val->data.x_struct.fields = alloc_const_vals_ptrs(struct_type->data.structure.src_field_count); |
| 20106 | struct_val->special = ConstValSpecialStatic; | 21113 | struct_val->special = ConstValSpecialStatic; |
| ... | @@ -20114,11 +21121,9 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -20114,11 +21121,9 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 20114 | field_val->parent.data.p_struct.field_index = i; | 21121 | field_val->parent.data.p_struct.field_index = i; |
| 20115 | } | 21122 | } |
| 20116 | } | 21123 | } |
| 20117 | IrInstruction *result; | 21124 | IrInstGen *result; |
| 20118 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 21125 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 20119 | result = ir_build_struct_field_ptr(&ira->new_irb, source_instr->scope, | 21126 | result = ir_build_struct_field_ptr(ira, source_instr, struct_ptr, field, ptr_type); |
| 20120 | source_instr->source_node, struct_ptr, field); | | |
| 20121 | result->value->type = ptr_type; | | |
| 20122 | result->value->special = ConstValSpecialStatic; | 21127 | result->value->special = ConstValSpecialStatic; |
| 20123 | } else { | 21128 | } else { |
| 20124 | result = ir_const(ira, source_instr, ptr_type); | 21129 | result = ir_const(ira, source_instr, ptr_type); |
| ... | @@ -20131,14 +21136,11 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -20131,14 +21136,11 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 20131 | return result; | 21136 | return result; |
| 20132 | } | 21137 | } |
| 20133 | } | 21138 | } |
| 20134 | IrInstruction *result = ir_build_struct_field_ptr(&ira->new_irb, source_instr->scope, source_instr->source_node, | 21139 | return ir_build_struct_field_ptr(ira, source_instr, struct_ptr, field, ptr_type); |
| 20135 | struct_ptr, field); | | |
| 20136 | result->value->type = ptr_type; | | |
| 20137 | return result; | | |
| 20138 | } | 21140 | } |
| 20139 | | 21141 | |
| 20140 | static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, | 21142 | static IrInstGen *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, |
| 20141 | IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type) | 21143 | IrInst* source_instr, IrInstGen *container_ptr, ZigType *container_type) |
| 20142 | { | 21144 | { |
| 20143 | // The type of the field is not available until a store using this pointer happens. | 21145 | // The type of the field is not available until a store using this pointer happens. |
| 20144 | // So, here we create a special pointer type which has the inferred struct type and | 21146 | // So, here we create a special pointer type which has the inferred struct type and |
| ... | @@ -20161,12 +21163,11 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n | ... | @@ -20161,12 +21163,11 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n |
| 20161 | if (instr_is_comptime(container_ptr)) { | 21163 | if (instr_is_comptime(container_ptr)) { |
| 20162 | ZigValue *ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); | 21164 | ZigValue *ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); |
| 20163 | if (ptr_val == nullptr) | 21165 | if (ptr_val == nullptr) |
| 20164 | return ira->codegen->invalid_instruction; | 21166 | return ira->codegen->invalid_inst_gen; |
| 20165 | | 21167 | |
| 20166 | IrInstruction *result; | 21168 | IrInstGen *result; |
| 20167 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 21169 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 20168 | result = ir_build_cast(&ira->new_irb, source_instr->scope, | 21170 | result = ir_build_cast(ira, source_instr, container_ptr_type, container_ptr, CastOpNoop); |
| 20169 | source_instr->source_node, container_ptr_type, container_ptr, CastOpNoop); | | |
| 20170 | } else { | 21171 | } else { |
| 20171 | result = ir_const(ira, source_instr, field_ptr_type); | 21172 | result = ir_const(ira, source_instr, field_ptr_type); |
| 20172 | } | 21173 | } |
| ... | @@ -20175,14 +21176,11 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n | ... | @@ -20175,14 +21176,11 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n |
| 20175 | return result; | 21176 | return result; |
| 20176 | } | 21177 | } |
| 20177 | | 21178 | |
| 20178 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, | 21179 | return ir_build_cast(ira, source_instr, field_ptr_type, container_ptr, CastOpNoop); |
| 20179 | source_instr->source_node, field_ptr_type, container_ptr, CastOpNoop); | | |
| 20180 | result->value->type = field_ptr_type; | | |
| 20181 | return result; | | |
| 20182 | } | 21180 | } |
| 20183 | | 21181 | |
| 20184 | static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name, | 21182 | static IrInstGen *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name, |
| 20185 | IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type, bool initializing) | 21183 | IrInst* source_instr, IrInstGen *container_ptr, ZigType *container_type, bool initializing) |
| 20186 | { | 21184 | { |
| 20187 | Error err; | 21185 | Error err; |
| 20188 | | 21186 | |
| ... | @@ -20195,7 +21193,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -20195,7 +21193,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 20195 | } | 21193 | } |
| 20196 | | 21194 | |
| 20197 | if ((err = type_resolve(ira->codegen, bare_type, ResolveStatusZeroBitsKnown))) | 21195 | if ((err = type_resolve(ira->codegen, bare_type, ResolveStatusZeroBitsKnown))) |
| 20198 | return ira->codegen->invalid_instruction; | 21196 | return ira->codegen->invalid_inst_gen; |
| 20199 | | 21197 | |
| 20200 | assert(container_ptr->value->type->id == ZigTypeIdPointer); | 21198 | assert(container_ptr->value->type->id == ZigTypeIdPointer); |
| 20201 | if (bare_type->id == ZigTypeIdStruct) { | 21199 | if (bare_type->id == ZigTypeIdStruct) { |
| ... | @@ -20225,22 +21223,22 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -20225,22 +21223,22 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 20225 | | 21223 | |
| 20226 | ZigType *field_type = resolve_union_field_type(ira->codegen, field); | 21224 | ZigType *field_type = resolve_union_field_type(ira->codegen, field); |
| 20227 | if (field_type == nullptr) | 21225 | if (field_type == nullptr) |
| 20228 | return ira->codegen->invalid_instruction; | 21226 | return ira->codegen->invalid_inst_gen; |
| 20229 | | 21227 | |
| 20230 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, field_type, | 21228 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, field_type, |
| 20231 | is_const, is_volatile, PtrLenSingle, 0, 0, 0, false); | 21229 | is_const, is_volatile, PtrLenSingle, 0, 0, 0, false); |
| 20232 | if (instr_is_comptime(container_ptr)) { | 21230 | if (instr_is_comptime(container_ptr)) { |
| 20233 | ZigValue *ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); | 21231 | ZigValue *ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); |
| 20234 | if (!ptr_val) | 21232 | if (!ptr_val) |
| 20235 | return ira->codegen->invalid_instruction; | 21233 | return ira->codegen->invalid_inst_gen; |
| 20236 | | 21234 | |
| 20237 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar && | 21235 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar && |
| 20238 | ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 21236 | ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 20239 | ZigValue *union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 21237 | ZigValue *union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 20240 | if (union_val == nullptr) | 21238 | if (union_val == nullptr) |
| 20241 | return ira->codegen->invalid_instruction; | 21239 | return ira->codegen->invalid_inst_gen; |
| 20242 | if (type_is_invalid(union_val->type)) | 21240 | if (type_is_invalid(union_val->type)) |
| 20243 | return ira->codegen->invalid_instruction; | 21241 | return ira->codegen->invalid_inst_gen; |
| 20244 | | 21242 | |
| 20245 | if (initializing) { | 21243 | if (initializing) { |
| 20246 | ZigValue *payload_val = create_const_vals(1); | 21244 | ZigValue *payload_val = create_const_vals(1); |
| ... | @@ -20261,17 +21259,16 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -20261,17 +21259,16 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 20261 | ir_add_error_node(ira, source_instr->source_node, | 21259 | ir_add_error_node(ira, source_instr->source_node, |
| 20262 | buf_sprintf("accessing union field '%s' while field '%s' is set", buf_ptr(field_name), | 21260 | buf_sprintf("accessing union field '%s' while field '%s' is set", buf_ptr(field_name), |
| 20263 | buf_ptr(actual_field->name))); | 21261 | buf_ptr(actual_field->name))); |
| 20264 | return ira->codegen->invalid_instruction; | 21262 | return ira->codegen->invalid_inst_gen; |
| 20265 | } | 21263 | } |
| 20266 | } | 21264 | } |
| 20267 | | 21265 | |
| 20268 | ZigValue *payload_val = union_val->data.x_union.payload; | 21266 | ZigValue *payload_val = union_val->data.x_union.payload; |
| 20269 | | 21267 | |
| 20270 | IrInstruction *result; | 21268 | IrInstGen *result; |
| 20271 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 21269 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 20272 | result = ir_build_union_field_ptr(&ira->new_irb, source_instr->scope, | 21270 | result = ir_build_union_field_ptr(ira, source_instr, container_ptr, field, true, |
| 20273 | source_instr->source_node, container_ptr, field, true, initializing); | 21271 | initializing, ptr_type); |
| 20274 | result->value->type = ptr_type; | | |
| 20275 | result->value->special = ConstValSpecialStatic; | 21272 | result->value->special = ConstValSpecialStatic; |
| 20276 | } else { | 21273 | } else { |
| 20277 | result = ir_const(ira, source_instr, ptr_type); | 21274 | result = ir_const(ira, source_instr, ptr_type); |
| ... | @@ -20284,10 +21281,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -20284,10 +21281,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 20284 | } | 21281 | } |
| 20285 | } | 21282 | } |
| 20286 | | 21283 | |
| 20287 | IrInstruction *result = ir_build_union_field_ptr(&ira->new_irb, source_instr->scope, | 21284 | return ir_build_union_field_ptr(ira, source_instr, container_ptr, field, true, initializing, ptr_type); |
| 20288 | source_instr->source_node, container_ptr, field, true, initializing); | | |
| 20289 | result->value->type = ptr_type; | | |
| 20290 | return result; | | |
| 20291 | } | 21285 | } |
| 20292 | | 21286 | |
| 20293 | zig_unreachable(); | 21287 | zig_unreachable(); |
| ... | @@ -20328,16 +21322,18 @@ static void add_link_lib_symbol(IrAnalyze *ira, Buf *lib_name, Buf *symbol_name, | ... | @@ -20328,16 +21322,18 @@ static void add_link_lib_symbol(IrAnalyze *ira, Buf *lib_name, Buf *symbol_name, |
| 20328 | link_lib->symbols.append(symbol_name); | 21322 | link_lib->symbols.append(symbol_name); |
| 20329 | } | 21323 | } |
| 20330 | | 21324 | |
| 20331 | static IrInstruction *ir_error_dependency_loop(IrAnalyze *ira, IrInstruction *source_instr) { | 21325 | static IrInstGen *ir_error_dependency_loop(IrAnalyze *ira, IrInst* source_instr) { |
| 20332 | ir_add_error(ira, source_instr, buf_sprintf("dependency loop detected")); | 21326 | ir_add_error(ira, source_instr, buf_sprintf("dependency loop detected")); |
| 20333 | return ira->codegen->invalid_instruction; | 21327 | return ira->codegen->invalid_inst_gen; |
| 20334 | } | 21328 | } |
| 20335 | | 21329 | |
| 20336 | static IrInstruction *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instruction, Tld *tld) { | 21330 | static IrInstGen *ir_analyze_decl_ref(IrAnalyze *ira, IrInst* source_instruction, Tld *tld) { |
| 20337 | resolve_top_level_decl(ira->codegen, tld, source_instruction->source_node, true); | 21331 | resolve_top_level_decl(ira->codegen, tld, source_instruction->source_node, true); |
| 20338 | if (tld->resolution == TldResolutionInvalid) { | 21332 | if (tld->resolution == TldResolutionInvalid) { |
| 20339 | return ira->codegen->invalid_instruction; | 21333 | return ira->codegen->invalid_inst_gen; |
| 20340 | } | 21334 | } |
| | 21335 | if (tld->resolution == TldResolutionResolving) |
| | 21336 | return ir_error_dependency_loop(ira, source_instruction); |
| 20341 | | 21337 | |
| 20342 | switch (tld->id) { | 21338 | switch (tld->id) { |
| 20343 | case TldIdContainer: | 21339 | case TldIdContainer: |
| ... | @@ -20347,9 +21343,8 @@ static IrInstruction *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -20347,9 +21343,8 @@ static IrInstruction *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_ |
| 20347 | case TldIdVar: { | 21343 | case TldIdVar: { |
| 20348 | TldVar *tld_var = (TldVar *)tld; | 21344 | TldVar *tld_var = (TldVar *)tld; |
| 20349 | ZigVar *var = tld_var->var; | 21345 | ZigVar *var = tld_var->var; |
| 20350 | if (var == nullptr) { | 21346 | assert(var != nullptr); |
| 20351 | return ir_error_dependency_loop(ira, source_instruction); | 21347 | |
| 20352 | } | | |
| 20353 | if (tld_var->extern_lib_name != nullptr) { | 21348 | if (tld_var->extern_lib_name != nullptr) { |
| 20354 | add_link_lib_symbol(ira, tld_var->extern_lib_name, buf_create_from_str(var->name), | 21349 | add_link_lib_symbol(ira, tld_var->extern_lib_name, buf_create_from_str(var->name), |
| 20355 | source_instruction->source_node); | 21350 | source_instruction->source_node); |
| ... | @@ -20360,17 +21355,16 @@ static IrInstruction *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -20360,17 +21355,16 @@ static IrInstruction *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_ |
| 20360 | case TldIdFn: { | 21355 | case TldIdFn: { |
| 20361 | TldFn *tld_fn = (TldFn *)tld; | 21356 | TldFn *tld_fn = (TldFn *)tld; |
| 20362 | ZigFn *fn_entry = tld_fn->fn_entry; | 21357 | ZigFn *fn_entry = tld_fn->fn_entry; |
| 20363 | assert(fn_entry->type_entry); | 21358 | assert(fn_entry->type_entry != nullptr); |
| 20364 | | 21359 | |
| 20365 | if (type_is_invalid(fn_entry->type_entry)) | 21360 | if (type_is_invalid(fn_entry->type_entry)) |
| 20366 | return ira->codegen->invalid_instruction; | 21361 | return ira->codegen->invalid_inst_gen; |
| 20367 | | 21362 | |
| 20368 | if (tld_fn->extern_lib_name != nullptr) { | 21363 | if (tld_fn->extern_lib_name != nullptr) { |
| 20369 | add_link_lib_symbol(ira, tld_fn->extern_lib_name, &fn_entry->symbol_name, source_instruction->source_node); | 21364 | add_link_lib_symbol(ira, tld_fn->extern_lib_name, &fn_entry->symbol_name, source_instruction->source_node); |
| 20370 | } | 21365 | } |
| 20371 | | 21366 | |
| 20372 | IrInstruction *fn_inst = ir_create_const_fn(&ira->new_irb, source_instruction->scope, | 21367 | IrInstGen *fn_inst = ir_const_fn(ira, source_instruction, fn_entry); |
| 20373 | source_instruction->source_node, fn_entry); | | |
| 20374 | return ir_get_ref(ira, source_instruction, fn_inst, true, false); | 21368 | return ir_get_ref(ira, source_instruction, fn_inst, true, false); |
| 20375 | } | 21369 | } |
| 20376 | } | 21370 | } |
| ... | @@ -20388,40 +21382,40 @@ static ErrorTableEntry *find_err_table_entry(ZigType *err_set_type, Buf *field_n | ... | @@ -20388,40 +21382,40 @@ static ErrorTableEntry *find_err_table_entry(ZigType *err_set_type, Buf *field_n |
| 20388 | return nullptr; | 21382 | return nullptr; |
| 20389 | } | 21383 | } |
| 20390 | | 21384 | |
| 20391 | static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFieldPtr *field_ptr_instruction) { | 21385 | static IrInstGen *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstSrcFieldPtr *field_ptr_instruction) { |
| 20392 | Error err; | 21386 | Error err; |
| 20393 | IrInstruction *container_ptr = field_ptr_instruction->container_ptr->child; | 21387 | IrInstGen *container_ptr = field_ptr_instruction->container_ptr->child; |
| 20394 | if (type_is_invalid(container_ptr->value->type)) | 21388 | if (type_is_invalid(container_ptr->value->type)) |
| 20395 | return ira->codegen->invalid_instruction; | 21389 | return ira->codegen->invalid_inst_gen; |
| 20396 | | 21390 | |
| 20397 | ZigType *container_type = container_ptr->value->type->data.pointer.child_type; | 21391 | ZigType *container_type = container_ptr->value->type->data.pointer.child_type; |
| 20398 | | 21392 | |
| 20399 | Buf *field_name = field_ptr_instruction->field_name_buffer; | 21393 | Buf *field_name = field_ptr_instruction->field_name_buffer; |
| 20400 | if (!field_name) { | 21394 | if (!field_name) { |
| 20401 | IrInstruction *field_name_expr = field_ptr_instruction->field_name_expr->child; | 21395 | IrInstGen *field_name_expr = field_ptr_instruction->field_name_expr->child; |
| 20402 | field_name = ir_resolve_str(ira, field_name_expr); | 21396 | field_name = ir_resolve_str(ira, field_name_expr); |
| 20403 | if (!field_name) | 21397 | if (!field_name) |
| 20404 | return ira->codegen->invalid_instruction; | 21398 | return ira->codegen->invalid_inst_gen; |
| 20405 | } | 21399 | } |
| 20406 | | 21400 | |
| 20407 | | 21401 | |
| 20408 | AstNode *source_node = field_ptr_instruction->base.source_node; | 21402 | AstNode *source_node = field_ptr_instruction->base.base.source_node; |
| 20409 | | 21403 | |
| 20410 | if (type_is_invalid(container_type)) { | 21404 | if (type_is_invalid(container_type)) { |
| 20411 | return ira->codegen->invalid_instruction; | 21405 | return ira->codegen->invalid_inst_gen; |
| 20412 | } else if (is_tuple(container_type) && !field_ptr_instruction->initializing && buf_eql_str(field_name, "len")) { | 21406 | } else if (is_tuple(container_type) && !field_ptr_instruction->initializing && buf_eql_str(field_name, "len")) { |
| 20413 | IrInstruction *len_inst = ir_const_unsigned(ira, &field_ptr_instruction->base, | 21407 | IrInstGen *len_inst = ir_const_unsigned(ira, &field_ptr_instruction->base.base, |
| 20414 | container_type->data.structure.src_field_count); | 21408 | container_type->data.structure.src_field_count); |
| 20415 | return ir_get_ref(ira, &field_ptr_instruction->base, len_inst, true, false); | 21409 | return ir_get_ref(ira, &field_ptr_instruction->base.base, len_inst, true, false); |
| 20416 | } else if (is_slice(container_type) || is_container_ref(container_type)) { | 21410 | } else if (is_slice(container_type) || is_container_ref(container_type)) { |
| 20417 | assert(container_ptr->value->type->id == ZigTypeIdPointer); | 21411 | assert(container_ptr->value->type->id == ZigTypeIdPointer); |
| 20418 | if (container_type->id == ZigTypeIdPointer) { | 21412 | if (container_type->id == ZigTypeIdPointer) { |
| 20419 | ZigType *bare_type = container_ref_type(container_type); | 21413 | ZigType *bare_type = container_ref_type(container_type); |
| 20420 | IrInstruction *container_child = ir_get_deref(ira, &field_ptr_instruction->base, container_ptr, nullptr); | 21414 | IrInstGen *container_child = ir_get_deref(ira, &field_ptr_instruction->base.base, container_ptr, nullptr); |
| 20421 | IrInstruction *result = ir_analyze_container_field_ptr(ira, field_name, &field_ptr_instruction->base, container_child, bare_type, field_ptr_instruction->initializing); | 21415 | IrInstGen *result = ir_analyze_container_field_ptr(ira, field_name, &field_ptr_instruction->base.base, container_child, bare_type, field_ptr_instruction->initializing); |
| 20422 | return result; | 21416 | return result; |
| 20423 | } else { | 21417 | } else { |
| 20424 | IrInstruction *result = ir_analyze_container_field_ptr(ira, field_name, &field_ptr_instruction->base, container_ptr, container_type, field_ptr_instruction->initializing); | 21418 | IrInstGen *result = ir_analyze_container_field_ptr(ira, field_name, &field_ptr_instruction->base.base, container_ptr, container_type, field_ptr_instruction->initializing); |
| 20425 | return result; | 21419 | return result; |
| 20426 | } | 21420 | } |
| 20427 | } else if (is_array_ref(container_type) && !field_ptr_instruction->initializing) { | 21421 | } else if (is_array_ref(container_type) && !field_ptr_instruction->initializing) { |
| ... | @@ -20436,42 +21430,42 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -20436,42 +21430,42 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 20436 | ZigType *usize = ira->codegen->builtin_types.entry_usize; | 21430 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 20437 | bool ptr_is_const = true; | 21431 | bool ptr_is_const = true; |
| 20438 | bool ptr_is_volatile = false; | 21432 | bool ptr_is_volatile = false; |
| 20439 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, len_val, | 21433 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, len_val, |
| 20440 | usize, ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21434 | usize, ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20441 | } else { | 21435 | } else { |
| 20442 | ir_add_error_node(ira, source_node, | 21436 | ir_add_error_node(ira, source_node, |
| 20443 | buf_sprintf("no member named '%s' in '%s'", buf_ptr(field_name), | 21437 | buf_sprintf("no member named '%s' in '%s'", buf_ptr(field_name), |
| 20444 | buf_ptr(&container_type->name))); | 21438 | buf_ptr(&container_type->name))); |
| 20445 | return ira->codegen->invalid_instruction; | 21439 | return ira->codegen->invalid_inst_gen; |
| 20446 | } | 21440 | } |
| 20447 | } else if (container_type->id == ZigTypeIdMetaType) { | 21441 | } else if (container_type->id == ZigTypeIdMetaType) { |
| 20448 | ZigValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); | 21442 | ZigValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); |
| 20449 | if (!container_ptr_val) | 21443 | if (!container_ptr_val) |
| 20450 | return ira->codegen->invalid_instruction; | 21444 | return ira->codegen->invalid_inst_gen; |
| 20451 | | 21445 | |
| 20452 | assert(container_ptr->value->type->id == ZigTypeIdPointer); | 21446 | assert(container_ptr->value->type->id == ZigTypeIdPointer); |
| 20453 | ZigValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node); | 21447 | ZigValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node); |
| 20454 | if (child_val == nullptr) | 21448 | if (child_val == nullptr) |
| 20455 | return ira->codegen->invalid_instruction; | 21449 | return ira->codegen->invalid_inst_gen; |
| 20456 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, | 21450 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, |
| 20457 | field_ptr_instruction->base.source_node, child_val, UndefBad))) | 21451 | field_ptr_instruction->base.base.source_node, child_val, UndefBad))) |
| 20458 | { | 21452 | { |
| 20459 | return ira->codegen->invalid_instruction; | 21453 | return ira->codegen->invalid_inst_gen; |
| 20460 | } | 21454 | } |
| 20461 | ZigType *child_type = child_val->data.x_type; | 21455 | ZigType *child_type = child_val->data.x_type; |
| 20462 | | 21456 | |
| 20463 | if (type_is_invalid(child_type)) { | 21457 | if (type_is_invalid(child_type)) { |
| 20464 | return ira->codegen->invalid_instruction; | 21458 | return ira->codegen->invalid_inst_gen; |
| 20465 | } else if (is_container(child_type)) { | 21459 | } else if (is_container(child_type)) { |
| 20466 | if (child_type->id == ZigTypeIdEnum) { | 21460 | if (child_type->id == ZigTypeIdEnum) { |
| 20467 | if ((err = type_resolve(ira->codegen, child_type, ResolveStatusSizeKnown))) | 21461 | if ((err = type_resolve(ira->codegen, child_type, ResolveStatusSizeKnown))) |
| 20468 | return ira->codegen->invalid_instruction; | 21462 | return ira->codegen->invalid_inst_gen; |
| 20469 | | 21463 | |
| 20470 | TypeEnumField *field = find_enum_type_field(child_type, field_name); | 21464 | TypeEnumField *field = find_enum_type_field(child_type, field_name); |
| 20471 | if (field) { | 21465 | if (field) { |
| 20472 | bool ptr_is_const = true; | 21466 | bool ptr_is_const = true; |
| 20473 | bool ptr_is_volatile = false; | 21467 | bool ptr_is_volatile = false; |
| 20474 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21468 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20475 | create_const_enum(child_type, &field->value), child_type, | 21469 | create_const_enum(child_type, &field->value), child_type, |
| 20476 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21470 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20477 | } | 21471 | } |
| ... | @@ -20480,37 +21474,37 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -20480,37 +21474,37 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 20480 | Tld *tld = find_container_decl(ira->codegen, container_scope, field_name); | 21474 | Tld *tld = find_container_decl(ira->codegen, container_scope, field_name); |
| 20481 | if (tld) { | 21475 | if (tld) { |
| 20482 | if (tld->visib_mod == VisibModPrivate && | 21476 | if (tld->visib_mod == VisibModPrivate && |
| 20483 | tld->import != get_scope_import(field_ptr_instruction->base.scope)) | 21477 | tld->import != get_scope_import(field_ptr_instruction->base.base.scope)) |
| 20484 | { | 21478 | { |
| 20485 | ErrorMsg *msg = ir_add_error(ira, &field_ptr_instruction->base, | 21479 | ErrorMsg *msg = ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20486 | buf_sprintf("'%s' is private", buf_ptr(field_name))); | 21480 | buf_sprintf("'%s' is private", buf_ptr(field_name))); |
| 20487 | add_error_note(ira->codegen, msg, tld->source_node, buf_sprintf("declared here")); | 21481 | add_error_note(ira->codegen, msg, tld->source_node, buf_sprintf("declared here")); |
| 20488 | return ira->codegen->invalid_instruction; | 21482 | return ira->codegen->invalid_inst_gen; |
| 20489 | } | 21483 | } |
| 20490 | return ir_analyze_decl_ref(ira, &field_ptr_instruction->base, tld); | 21484 | return ir_analyze_decl_ref(ira, &field_ptr_instruction->base.base, tld); |
| 20491 | } | 21485 | } |
| 20492 | if (child_type->id == ZigTypeIdUnion && | 21486 | if (child_type->id == ZigTypeIdUnion && |
| 20493 | (child_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr || | 21487 | (child_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr || |
| 20494 | child_type->data.unionation.decl_node->data.container_decl.auto_enum)) | 21488 | child_type->data.unionation.decl_node->data.container_decl.auto_enum)) |
| 20495 | { | 21489 | { |
| 20496 | if ((err = type_resolve(ira->codegen, child_type, ResolveStatusSizeKnown))) | 21490 | if ((err = type_resolve(ira->codegen, child_type, ResolveStatusSizeKnown))) |
| 20497 | return ira->codegen->invalid_instruction; | 21491 | return ira->codegen->invalid_inst_gen; |
| 20498 | TypeUnionField *field = find_union_type_field(child_type, field_name); | 21492 | TypeUnionField *field = find_union_type_field(child_type, field_name); |
| 20499 | if (field) { | 21493 | if (field) { |
| 20500 | ZigType *enum_type = child_type->data.unionation.tag_type; | 21494 | ZigType *enum_type = child_type->data.unionation.tag_type; |
| 20501 | bool ptr_is_const = true; | 21495 | bool ptr_is_const = true; |
| 20502 | bool ptr_is_volatile = false; | 21496 | bool ptr_is_volatile = false; |
| 20503 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21497 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20504 | create_const_enum(enum_type, &field->enum_field->value), enum_type, | 21498 | create_const_enum(enum_type, &field->enum_field->value), enum_type, |
| 20505 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21499 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20506 | } | 21500 | } |
| 20507 | } | 21501 | } |
| 20508 | const char *container_name = (child_type == ira->codegen->root_import) ? | 21502 | const char *container_name = (child_type == ira->codegen->root_import) ? |
| 20509 | "root source file" : buf_ptr(buf_sprintf("container '%s'", buf_ptr(&child_type->name))); | 21503 | "root source file" : buf_ptr(buf_sprintf("container '%s'", buf_ptr(&child_type->name))); |
| 20510 | ir_add_error(ira, &field_ptr_instruction->base, | 21504 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20511 | buf_sprintf("%s has no member called '%s'", | 21505 | buf_sprintf("%s has no member called '%s'", |
| 20512 | container_name, buf_ptr(field_name))); | 21506 | container_name, buf_ptr(field_name))); |
| 20513 | return ira->codegen->invalid_instruction; | 21507 | return ira->codegen->invalid_inst_gen; |
| 20514 | } else if (child_type->id == ZigTypeIdErrorSet) { | 21508 | } else if (child_type->id == ZigTypeIdErrorSet) { |
| 20515 | ErrorTableEntry *err_entry; | 21509 | ErrorTableEntry *err_entry; |
| 20516 | ZigType *err_set_type; | 21510 | ZigType *err_set_type; |
| ... | @@ -20520,7 +21514,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -20520,7 +21514,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 20520 | err_entry = existing_entry->value; | 21514 | err_entry = existing_entry->value; |
| 20521 | } else { | 21515 | } else { |
| 20522 | err_entry = allocate<ErrorTableEntry>(1); | 21516 | err_entry = allocate<ErrorTableEntry>(1); |
| 20523 | err_entry->decl_node = field_ptr_instruction->base.source_node; | 21517 | err_entry->decl_node = field_ptr_instruction->base.base.source_node; |
| 20524 | buf_init_from_buf(&err_entry->name, field_name); | 21518 | buf_init_from_buf(&err_entry->name, field_name); |
| 20525 | size_t error_value_count = ira->codegen->errors_by_index.length; | 21519 | size_t error_value_count = ira->codegen->errors_by_index.length; |
| 20526 | assert((uint32_t)error_value_count < (((uint32_t)1) << (uint32_t)ira->codegen->err_tag_type->data.integral.bit_count)); | 21520 | assert((uint32_t)error_value_count < (((uint32_t)1) << (uint32_t)ira->codegen->err_tag_type->data.integral.bit_count)); |
| ... | @@ -20530,19 +21524,19 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -20530,19 +21524,19 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 20530 | } | 21524 | } |
| 20531 | if (err_entry->set_with_only_this_in_it == nullptr) { | 21525 | if (err_entry->set_with_only_this_in_it == nullptr) { |
| 20532 | err_entry->set_with_only_this_in_it = make_err_set_with_one_item(ira->codegen, | 21526 | err_entry->set_with_only_this_in_it = make_err_set_with_one_item(ira->codegen, |
| 20533 | field_ptr_instruction->base.scope, field_ptr_instruction->base.source_node, | 21527 | field_ptr_instruction->base.base.scope, field_ptr_instruction->base.base.source_node, |
| 20534 | err_entry); | 21528 | err_entry); |
| 20535 | } | 21529 | } |
| 20536 | err_set_type = err_entry->set_with_only_this_in_it; | 21530 | err_set_type = err_entry->set_with_only_this_in_it; |
| 20537 | } else { | 21531 | } else { |
| 20538 | if (!resolve_inferred_error_set(ira->codegen, child_type, field_ptr_instruction->base.source_node)) { | 21532 | if (!resolve_inferred_error_set(ira->codegen, child_type, field_ptr_instruction->base.base.source_node)) { |
| 20539 | return ira->codegen->invalid_instruction; | 21533 | return ira->codegen->invalid_inst_gen; |
| 20540 | } | 21534 | } |
| 20541 | err_entry = find_err_table_entry(child_type, field_name); | 21535 | err_entry = find_err_table_entry(child_type, field_name); |
| 20542 | if (err_entry == nullptr) { | 21536 | if (err_entry == nullptr) { |
| 20543 | ir_add_error(ira, &field_ptr_instruction->base, | 21537 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20544 | buf_sprintf("no error named '%s' in '%s'", buf_ptr(field_name), buf_ptr(&child_type->name))); | 21538 | buf_sprintf("no error named '%s' in '%s'", buf_ptr(field_name), buf_ptr(&child_type->name))); |
| 20545 | return ira->codegen->invalid_instruction; | 21539 | return ira->codegen->invalid_inst_gen; |
| 20546 | } | 21540 | } |
| 20547 | err_set_type = child_type; | 21541 | err_set_type = child_type; |
| 20548 | } | 21542 | } |
| ... | @@ -20553,13 +21547,13 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -20553,13 +21547,13 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 20553 | | 21547 | |
| 20554 | bool ptr_is_const = true; | 21548 | bool ptr_is_const = true; |
| 20555 | bool ptr_is_volatile = false; | 21549 | bool ptr_is_volatile = false; |
| 20556 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, const_val, | 21550 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, const_val, |
| 20557 | err_set_type, ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21551 | err_set_type, ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20558 | } else if (child_type->id == ZigTypeIdInt) { | 21552 | } else if (child_type->id == ZigTypeIdInt) { |
| 20559 | if (buf_eql_str(field_name, "bit_count")) { | 21553 | if (buf_eql_str(field_name, "bit_count")) { |
| 20560 | bool ptr_is_const = true; | 21554 | bool ptr_is_const = true; |
| 20561 | bool ptr_is_volatile = false; | 21555 | bool ptr_is_volatile = false; |
| 20562 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21556 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20563 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, | 21557 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, |
| 20564 | child_type->data.integral.bit_count, false), | 21558 | child_type->data.integral.bit_count, false), |
| 20565 | ira->codegen->builtin_types.entry_num_lit_int, | 21559 | ira->codegen->builtin_types.entry_num_lit_int, |
| ... | @@ -20567,36 +21561,36 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -20567,36 +21561,36 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 20567 | } else if (buf_eql_str(field_name, "is_signed")) { | 21561 | } else if (buf_eql_str(field_name, "is_signed")) { |
| 20568 | bool ptr_is_const = true; | 21562 | bool ptr_is_const = true; |
| 20569 | bool ptr_is_volatile = false; | 21563 | bool ptr_is_volatile = false; |
| 20570 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21564 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20571 | create_const_bool(ira->codegen, child_type->data.integral.is_signed), | 21565 | create_const_bool(ira->codegen, child_type->data.integral.is_signed), |
| 20572 | ira->codegen->builtin_types.entry_bool, | 21566 | ira->codegen->builtin_types.entry_bool, |
| 20573 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21567 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20574 | } else { | 21568 | } else { |
| 20575 | ir_add_error(ira, &field_ptr_instruction->base, | 21569 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20576 | buf_sprintf("type '%s' has no member called '%s'", | 21570 | buf_sprintf("type '%s' has no member called '%s'", |
| 20577 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 21571 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 20578 | return ira->codegen->invalid_instruction; | 21572 | return ira->codegen->invalid_inst_gen; |
| 20579 | } | 21573 | } |
| 20580 | } else if (child_type->id == ZigTypeIdFloat) { | 21574 | } else if (child_type->id == ZigTypeIdFloat) { |
| 20581 | if (buf_eql_str(field_name, "bit_count")) { | 21575 | if (buf_eql_str(field_name, "bit_count")) { |
| 20582 | bool ptr_is_const = true; | 21576 | bool ptr_is_const = true; |
| 20583 | bool ptr_is_volatile = false; | 21577 | bool ptr_is_volatile = false; |
| 20584 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21578 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20585 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, | 21579 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, |
| 20586 | child_type->data.floating.bit_count, false), | 21580 | child_type->data.floating.bit_count, false), |
| 20587 | ira->codegen->builtin_types.entry_num_lit_int, | 21581 | ira->codegen->builtin_types.entry_num_lit_int, |
| 20588 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21582 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20589 | } else { | 21583 | } else { |
| 20590 | ir_add_error(ira, &field_ptr_instruction->base, | 21584 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20591 | buf_sprintf("type '%s' has no member called '%s'", | 21585 | buf_sprintf("type '%s' has no member called '%s'", |
| 20592 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 21586 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 20593 | return ira->codegen->invalid_instruction; | 21587 | return ira->codegen->invalid_inst_gen; |
| 20594 | } | 21588 | } |
| 20595 | } else if (child_type->id == ZigTypeIdPointer) { | 21589 | } else if (child_type->id == ZigTypeIdPointer) { |
| 20596 | if (buf_eql_str(field_name, "Child")) { | 21590 | if (buf_eql_str(field_name, "Child")) { |
| 20597 | bool ptr_is_const = true; | 21591 | bool ptr_is_const = true; |
| 20598 | bool ptr_is_volatile = false; | 21592 | bool ptr_is_volatile = false; |
| 20599 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21593 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20600 | create_const_type(ira->codegen, child_type->data.pointer.child_type), | 21594 | create_const_type(ira->codegen, child_type->data.pointer.child_type), |
| 20601 | ira->codegen->builtin_types.entry_type, | 21595 | ira->codegen->builtin_types.entry_type, |
| 20602 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21596 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| ... | @@ -20606,75 +21600,75 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -20606,75 +21600,75 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 20606 | if ((err = type_resolve(ira->codegen, child_type->data.pointer.child_type, | 21600 | if ((err = type_resolve(ira->codegen, child_type->data.pointer.child_type, |
| 20607 | ResolveStatusAlignmentKnown))) | 21601 | ResolveStatusAlignmentKnown))) |
| 20608 | { | 21602 | { |
| 20609 | return ira->codegen->invalid_instruction; | 21603 | return ira->codegen->invalid_inst_gen; |
| 20610 | } | 21604 | } |
| 20611 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21605 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20612 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, | 21606 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, |
| 20613 | get_ptr_align(ira->codegen, child_type), false), | 21607 | get_ptr_align(ira->codegen, child_type), false), |
| 20614 | ira->codegen->builtin_types.entry_num_lit_int, | 21608 | ira->codegen->builtin_types.entry_num_lit_int, |
| 20615 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21609 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20616 | } else { | 21610 | } else { |
| 20617 | ir_add_error(ira, &field_ptr_instruction->base, | 21611 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20618 | buf_sprintf("type '%s' has no member called '%s'", | 21612 | buf_sprintf("type '%s' has no member called '%s'", |
| 20619 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 21613 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 20620 | return ira->codegen->invalid_instruction; | 21614 | return ira->codegen->invalid_inst_gen; |
| 20621 | } | 21615 | } |
| 20622 | } else if (child_type->id == ZigTypeIdArray) { | 21616 | } else if (child_type->id == ZigTypeIdArray) { |
| 20623 | if (buf_eql_str(field_name, "Child")) { | 21617 | if (buf_eql_str(field_name, "Child")) { |
| 20624 | bool ptr_is_const = true; | 21618 | bool ptr_is_const = true; |
| 20625 | bool ptr_is_volatile = false; | 21619 | bool ptr_is_volatile = false; |
| 20626 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21620 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20627 | create_const_type(ira->codegen, child_type->data.array.child_type), | 21621 | create_const_type(ira->codegen, child_type->data.array.child_type), |
| 20628 | ira->codegen->builtin_types.entry_type, | 21622 | ira->codegen->builtin_types.entry_type, |
| 20629 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21623 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20630 | } else if (buf_eql_str(field_name, "len")) { | 21624 | } else if (buf_eql_str(field_name, "len")) { |
| 20631 | bool ptr_is_const = true; | 21625 | bool ptr_is_const = true; |
| 20632 | bool ptr_is_volatile = false; | 21626 | bool ptr_is_volatile = false; |
| 20633 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21627 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20634 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, | 21628 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, |
| 20635 | child_type->data.array.len, false), | 21629 | child_type->data.array.len, false), |
| 20636 | ira->codegen->builtin_types.entry_num_lit_int, | 21630 | ira->codegen->builtin_types.entry_num_lit_int, |
| 20637 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21631 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20638 | } else { | 21632 | } else { |
| 20639 | ir_add_error(ira, &field_ptr_instruction->base, | 21633 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20640 | buf_sprintf("type '%s' has no member called '%s'", | 21634 | buf_sprintf("type '%s' has no member called '%s'", |
| 20641 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 21635 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 20642 | return ira->codegen->invalid_instruction; | 21636 | return ira->codegen->invalid_inst_gen; |
| 20643 | } | 21637 | } |
| 20644 | } else if (child_type->id == ZigTypeIdErrorUnion) { | 21638 | } else if (child_type->id == ZigTypeIdErrorUnion) { |
| 20645 | if (buf_eql_str(field_name, "Payload")) { | 21639 | if (buf_eql_str(field_name, "Payload")) { |
| 20646 | bool ptr_is_const = true; | 21640 | bool ptr_is_const = true; |
| 20647 | bool ptr_is_volatile = false; | 21641 | bool ptr_is_volatile = false; |
| 20648 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21642 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20649 | create_const_type(ira->codegen, child_type->data.error_union.payload_type), | 21643 | create_const_type(ira->codegen, child_type->data.error_union.payload_type), |
| 20650 | ira->codegen->builtin_types.entry_type, | 21644 | ira->codegen->builtin_types.entry_type, |
| 20651 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21645 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20652 | } else if (buf_eql_str(field_name, "ErrorSet")) { | 21646 | } else if (buf_eql_str(field_name, "ErrorSet")) { |
| 20653 | bool ptr_is_const = true; | 21647 | bool ptr_is_const = true; |
| 20654 | bool ptr_is_volatile = false; | 21648 | bool ptr_is_volatile = false; |
| 20655 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21649 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20656 | create_const_type(ira->codegen, child_type->data.error_union.err_set_type), | 21650 | create_const_type(ira->codegen, child_type->data.error_union.err_set_type), |
| 20657 | ira->codegen->builtin_types.entry_type, | 21651 | ira->codegen->builtin_types.entry_type, |
| 20658 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21652 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20659 | } else { | 21653 | } else { |
| 20660 | ir_add_error(ira, &field_ptr_instruction->base, | 21654 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20661 | buf_sprintf("type '%s' has no member called '%s'", | 21655 | buf_sprintf("type '%s' has no member called '%s'", |
| 20662 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 21656 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 20663 | return ira->codegen->invalid_instruction; | 21657 | return ira->codegen->invalid_inst_gen; |
| 20664 | } | 21658 | } |
| 20665 | } else if (child_type->id == ZigTypeIdOptional) { | 21659 | } else if (child_type->id == ZigTypeIdOptional) { |
| 20666 | if (buf_eql_str(field_name, "Child")) { | 21660 | if (buf_eql_str(field_name, "Child")) { |
| 20667 | bool ptr_is_const = true; | 21661 | bool ptr_is_const = true; |
| 20668 | bool ptr_is_volatile = false; | 21662 | bool ptr_is_volatile = false; |
| 20669 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21663 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20670 | create_const_type(ira->codegen, child_type->data.maybe.child_type), | 21664 | create_const_type(ira->codegen, child_type->data.maybe.child_type), |
| 20671 | ira->codegen->builtin_types.entry_type, | 21665 | ira->codegen->builtin_types.entry_type, |
| 20672 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21666 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20673 | } else { | 21667 | } else { |
| 20674 | ir_add_error(ira, &field_ptr_instruction->base, | 21668 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20675 | buf_sprintf("type '%s' has no member called '%s'", | 21669 | buf_sprintf("type '%s' has no member called '%s'", |
| 20676 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 21670 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 20677 | return ira->codegen->invalid_instruction; | 21671 | return ira->codegen->invalid_inst_gen; |
| 20678 | } | 21672 | } |
| 20679 | } else if (child_type->id == ZigTypeIdFn) { | 21673 | } else if (child_type->id == ZigTypeIdFn) { |
| 20680 | if (buf_eql_str(field_name, "ReturnType")) { | 21674 | if (buf_eql_str(field_name, "ReturnType")) { |
| ... | @@ -20682,121 +21676,121 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -20682,121 +21676,121 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 20682 | // Return type can only ever be null, if the function is generic | 21676 | // Return type can only ever be null, if the function is generic |
| 20683 | assert(child_type->data.fn.is_generic); | 21677 | assert(child_type->data.fn.is_generic); |
| 20684 | | 21678 | |
| 20685 | ir_add_error(ira, &field_ptr_instruction->base, | 21679 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20686 | buf_sprintf("ReturnType has not been resolved because '%s' is generic", buf_ptr(&child_type->name))); | 21680 | buf_sprintf("ReturnType has not been resolved because '%s' is generic", buf_ptr(&child_type->name))); |
| 20687 | return ira->codegen->invalid_instruction; | 21681 | return ira->codegen->invalid_inst_gen; |
| 20688 | } | 21682 | } |
| 20689 | | 21683 | |
| 20690 | bool ptr_is_const = true; | 21684 | bool ptr_is_const = true; |
| 20691 | bool ptr_is_volatile = false; | 21685 | bool ptr_is_volatile = false; |
| 20692 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21686 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20693 | create_const_type(ira->codegen, child_type->data.fn.fn_type_id.return_type), | 21687 | create_const_type(ira->codegen, child_type->data.fn.fn_type_id.return_type), |
| 20694 | ira->codegen->builtin_types.entry_type, | 21688 | ira->codegen->builtin_types.entry_type, |
| 20695 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21689 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20696 | } else if (buf_eql_str(field_name, "is_var_args")) { | 21690 | } else if (buf_eql_str(field_name, "is_var_args")) { |
| 20697 | bool ptr_is_const = true; | 21691 | bool ptr_is_const = true; |
| 20698 | bool ptr_is_volatile = false; | 21692 | bool ptr_is_volatile = false; |
| 20699 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21693 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20700 | create_const_bool(ira->codegen, child_type->data.fn.fn_type_id.is_var_args), | 21694 | create_const_bool(ira->codegen, child_type->data.fn.fn_type_id.is_var_args), |
| 20701 | ira->codegen->builtin_types.entry_bool, | 21695 | ira->codegen->builtin_types.entry_bool, |
| 20702 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21696 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20703 | } else if (buf_eql_str(field_name, "arg_count")) { | 21697 | } else if (buf_eql_str(field_name, "arg_count")) { |
| 20704 | bool ptr_is_const = true; | 21698 | bool ptr_is_const = true; |
| 20705 | bool ptr_is_volatile = false; | 21699 | bool ptr_is_volatile = false; |
| 20706 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21700 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20707 | create_const_usize(ira->codegen, child_type->data.fn.fn_type_id.param_count), | 21701 | create_const_usize(ira->codegen, child_type->data.fn.fn_type_id.param_count), |
| 20708 | ira->codegen->builtin_types.entry_usize, | 21702 | ira->codegen->builtin_types.entry_usize, |
| 20709 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21703 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20710 | } else { | 21704 | } else { |
| 20711 | ir_add_error(ira, &field_ptr_instruction->base, | 21705 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20712 | buf_sprintf("type '%s' has no member called '%s'", | 21706 | buf_sprintf("type '%s' has no member called '%s'", |
| 20713 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 21707 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 20714 | return ira->codegen->invalid_instruction; | 21708 | return ira->codegen->invalid_inst_gen; |
| 20715 | } | 21709 | } |
| 20716 | } else { | 21710 | } else { |
| 20717 | ir_add_error(ira, &field_ptr_instruction->base, | 21711 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20718 | buf_sprintf("type '%s' does not support field access", buf_ptr(&child_type->name))); | 21712 | buf_sprintf("type '%s' does not support field access", buf_ptr(&child_type->name))); |
| 20719 | return ira->codegen->invalid_instruction; | 21713 | return ira->codegen->invalid_inst_gen; |
| 20720 | } | 21714 | } |
| 20721 | } else if (field_ptr_instruction->initializing) { | 21715 | } else if (field_ptr_instruction->initializing) { |
| 20722 | ir_add_error(ira, &field_ptr_instruction->base, | 21716 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20723 | buf_sprintf("type '%s' does not support struct initialization syntax", buf_ptr(&container_type->name))); | 21717 | buf_sprintf("type '%s' does not support struct initialization syntax", buf_ptr(&container_type->name))); |
| 20724 | return ira->codegen->invalid_instruction; | 21718 | return ira->codegen->invalid_inst_gen; |
| 20725 | } else { | 21719 | } else { |
| 20726 | ir_add_error_node(ira, field_ptr_instruction->base.source_node, | 21720 | ir_add_error_node(ira, field_ptr_instruction->base.base.source_node, |
| 20727 | buf_sprintf("type '%s' does not support field access", buf_ptr(&container_type->name))); | 21721 | buf_sprintf("type '%s' does not support field access", buf_ptr(&container_type->name))); |
| 20728 | return ira->codegen->invalid_instruction; | 21722 | return ira->codegen->invalid_inst_gen; |
| 20729 | } | 21723 | } |
| 20730 | } | 21724 | } |
| 20731 | | 21725 | |
| 20732 | static IrInstruction *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstructionStorePtr *instruction) { | 21726 | static IrInstGen *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstSrcStorePtr *instruction) { |
| 20733 | IrInstruction *ptr = instruction->ptr->child; | 21727 | IrInstGen *ptr = instruction->ptr->child; |
| 20734 | if (type_is_invalid(ptr->value->type)) | 21728 | if (type_is_invalid(ptr->value->type)) |
| 20735 | return ira->codegen->invalid_instruction; | 21729 | return ira->codegen->invalid_inst_gen; |
| 20736 | | 21730 | |
| 20737 | IrInstruction *value = instruction->value->child; | 21731 | IrInstGen *value = instruction->value->child; |
| 20738 | if (type_is_invalid(value->value->type)) | 21732 | if (type_is_invalid(value->value->type)) |
| 20739 | return ira->codegen->invalid_instruction; | 21733 | return ira->codegen->invalid_inst_gen; |
| 20740 | | 21734 | |
| 20741 | return ir_analyze_store_ptr(ira, &instruction->base, ptr, value, instruction->allow_write_through_const); | 21735 | return ir_analyze_store_ptr(ira, &instruction->base.base, ptr, value, instruction->allow_write_through_const); |
| 20742 | } | 21736 | } |
| 20743 | | 21737 | |
| 20744 | static IrInstruction *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstructionLoadPtr *instruction) { | 21738 | static IrInstGen *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstSrcLoadPtr *instruction) { |
| 20745 | IrInstruction *ptr = instruction->ptr->child; | 21739 | IrInstGen *ptr = instruction->ptr->child; |
| 20746 | if (type_is_invalid(ptr->value->type)) | 21740 | if (type_is_invalid(ptr->value->type)) |
| 20747 | return ira->codegen->invalid_instruction; | 21741 | return ira->codegen->invalid_inst_gen; |
| 20748 | return ir_get_deref(ira, &instruction->base, ptr, nullptr); | 21742 | return ir_get_deref(ira, &instruction->base.base, ptr, nullptr); |
| 20749 | } | 21743 | } |
| 20750 | | 21744 | |
| 20751 | static IrInstruction *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructionTypeOf *typeof_instruction) { | 21745 | static IrInstGen *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstSrcTypeOf *typeof_instruction) { |
| 20752 | IrInstruction *expr_value = typeof_instruction->value->child; | 21746 | IrInstGen *expr_value = typeof_instruction->value->child; |
| 20753 | ZigType *type_entry = expr_value->value->type; | 21747 | ZigType *type_entry = expr_value->value->type; |
| 20754 | if (type_is_invalid(type_entry)) | 21748 | if (type_is_invalid(type_entry)) |
| 20755 | return ira->codegen->invalid_instruction; | 21749 | return ira->codegen->invalid_inst_gen; |
| 20756 | return ir_const_type(ira, &typeof_instruction->base, type_entry); | 21750 | return ir_const_type(ira, &typeof_instruction->base.base, type_entry); |
| 20757 | } | 21751 | } |
| 20758 | | 21752 | |
| 20759 | static IrInstruction *ir_analyze_instruction_set_cold(IrAnalyze *ira, IrInstructionSetCold *instruction) { | 21753 | static IrInstGen *ir_analyze_instruction_set_cold(IrAnalyze *ira, IrInstSrcSetCold *instruction) { |
| 20760 | if (ira->new_irb.exec->is_inline) { | 21754 | if (ira->new_irb.exec->is_inline) { |
| 20761 | // ignore setCold when running functions at compile time | 21755 | // ignore setCold when running functions at compile time |
| 20762 | return ir_const_void(ira, &instruction->base); | 21756 | return ir_const_void(ira, &instruction->base.base); |
| 20763 | } | 21757 | } |
| 20764 | | 21758 | |
| 20765 | IrInstruction *is_cold_value = instruction->is_cold->child; | 21759 | IrInstGen *is_cold_value = instruction->is_cold->child; |
| 20766 | bool want_cold; | 21760 | bool want_cold; |
| 20767 | if (!ir_resolve_bool(ira, is_cold_value, &want_cold)) | 21761 | if (!ir_resolve_bool(ira, is_cold_value, &want_cold)) |
| 20768 | return ira->codegen->invalid_instruction; | 21762 | return ira->codegen->invalid_inst_gen; |
| 20769 | | 21763 | |
| 20770 | ZigFn *fn_entry = scope_fn_entry(instruction->base.scope); | 21764 | ZigFn *fn_entry = scope_fn_entry(instruction->base.base.scope); |
| 20771 | if (fn_entry == nullptr) { | 21765 | if (fn_entry == nullptr) { |
| 20772 | ir_add_error(ira, &instruction->base, buf_sprintf("@setCold outside function")); | 21766 | ir_add_error(ira, &instruction->base.base, buf_sprintf("@setCold outside function")); |
| 20773 | return ira->codegen->invalid_instruction; | 21767 | return ira->codegen->invalid_inst_gen; |
| 20774 | } | 21768 | } |
| 20775 | | 21769 | |
| 20776 | if (fn_entry->set_cold_node != nullptr) { | 21770 | if (fn_entry->set_cold_node != nullptr) { |
| 20777 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, buf_sprintf("cold set twice in same function")); | 21771 | ErrorMsg *msg = ir_add_error(ira, &instruction->base.base, buf_sprintf("cold set twice in same function")); |
| 20778 | add_error_note(ira->codegen, msg, fn_entry->set_cold_node, buf_sprintf("first set here")); | 21772 | add_error_note(ira->codegen, msg, fn_entry->set_cold_node, buf_sprintf("first set here")); |
| 20779 | return ira->codegen->invalid_instruction; | 21773 | return ira->codegen->invalid_inst_gen; |
| 20780 | } | 21774 | } |
| 20781 | | 21775 | |
| 20782 | fn_entry->set_cold_node = instruction->base.source_node; | 21776 | fn_entry->set_cold_node = instruction->base.base.source_node; |
| 20783 | fn_entry->is_cold = want_cold; | 21777 | fn_entry->is_cold = want_cold; |
| 20784 | | 21778 | |
| 20785 | return ir_const_void(ira, &instruction->base); | 21779 | return ir_const_void(ira, &instruction->base.base); |
| 20786 | } | 21780 | } |
| 20787 | | 21781 | |
| 20788 | static IrInstruction *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira, | 21782 | static IrInstGen *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira, |
| 20789 | IrInstructionSetRuntimeSafety *set_runtime_safety_instruction) | 21783 | IrInstSrcSetRuntimeSafety *set_runtime_safety_instruction) |
| 20790 | { | 21784 | { |
| 20791 | if (ira->new_irb.exec->is_inline) { | 21785 | if (ira->new_irb.exec->is_inline) { |
| 20792 | // ignore setRuntimeSafety when running functions at compile time | 21786 | // ignore setRuntimeSafety when running functions at compile time |
| 20793 | return ir_const_void(ira, &set_runtime_safety_instruction->base); | 21787 | return ir_const_void(ira, &set_runtime_safety_instruction->base.base); |
| 20794 | } | 21788 | } |
| 20795 | | 21789 | |
| 20796 | bool *safety_off_ptr; | 21790 | bool *safety_off_ptr; |
| 20797 | AstNode **safety_set_node_ptr; | 21791 | AstNode **safety_set_node_ptr; |
| 20798 | | 21792 | |
| 20799 | Scope *scope = set_runtime_safety_instruction->base.scope; | 21793 | Scope *scope = set_runtime_safety_instruction->base.base.scope; |
| 20800 | while (scope != nullptr) { | 21794 | while (scope != nullptr) { |
| 20801 | if (scope->id == ScopeIdBlock) { | 21795 | if (scope->id == ScopeIdBlock) { |
| 20802 | ScopeBlock *block_scope = (ScopeBlock *)scope; | 21796 | ScopeBlock *block_scope = (ScopeBlock *)scope; |
| ... | @@ -20822,36 +21816,36 @@ static IrInstruction *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira, | ... | @@ -20822,36 +21816,36 @@ static IrInstruction *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira, |
| 20822 | } | 21816 | } |
| 20823 | assert(scope != nullptr); | 21817 | assert(scope != nullptr); |
| 20824 | | 21818 | |
| 20825 | IrInstruction *safety_on_value = set_runtime_safety_instruction->safety_on->child; | 21819 | IrInstGen *safety_on_value = set_runtime_safety_instruction->safety_on->child; |
| 20826 | bool want_runtime_safety; | 21820 | bool want_runtime_safety; |
| 20827 | if (!ir_resolve_bool(ira, safety_on_value, &want_runtime_safety)) | 21821 | if (!ir_resolve_bool(ira, safety_on_value, &want_runtime_safety)) |
| 20828 | return ira->codegen->invalid_instruction; | 21822 | return ira->codegen->invalid_inst_gen; |
| 20829 | | 21823 | |
| 20830 | AstNode *source_node = set_runtime_safety_instruction->base.source_node; | 21824 | AstNode *source_node = set_runtime_safety_instruction->base.base.source_node; |
| 20831 | if (*safety_set_node_ptr) { | 21825 | if (*safety_set_node_ptr) { |
| 20832 | ErrorMsg *msg = ir_add_error_node(ira, source_node, | 21826 | ErrorMsg *msg = ir_add_error_node(ira, source_node, |
| 20833 | buf_sprintf("runtime safety set twice for same scope")); | 21827 | buf_sprintf("runtime safety set twice for same scope")); |
| 20834 | add_error_note(ira->codegen, msg, *safety_set_node_ptr, buf_sprintf("first set here")); | 21828 | add_error_note(ira->codegen, msg, *safety_set_node_ptr, buf_sprintf("first set here")); |
| 20835 | return ira->codegen->invalid_instruction; | 21829 | return ira->codegen->invalid_inst_gen; |
| 20836 | } | 21830 | } |
| 20837 | *safety_set_node_ptr = source_node; | 21831 | *safety_set_node_ptr = source_node; |
| 20838 | *safety_off_ptr = !want_runtime_safety; | 21832 | *safety_off_ptr = !want_runtime_safety; |
| 20839 | | 21833 | |
| 20840 | return ir_const_void(ira, &set_runtime_safety_instruction->base); | 21834 | return ir_const_void(ira, &set_runtime_safety_instruction->base.base); |
| 20841 | } | 21835 | } |
| 20842 | | 21836 | |
| 20843 | static IrInstruction *ir_analyze_instruction_set_float_mode(IrAnalyze *ira, | 21837 | static IrInstGen *ir_analyze_instruction_set_float_mode(IrAnalyze *ira, |
| 20844 | IrInstructionSetFloatMode *instruction) | 21838 | IrInstSrcSetFloatMode *instruction) |
| 20845 | { | 21839 | { |
| 20846 | if (ira->new_irb.exec->is_inline) { | 21840 | if (ira->new_irb.exec->is_inline) { |
| 20847 | // ignore setFloatMode when running functions at compile time | 21841 | // ignore setFloatMode when running functions at compile time |
| 20848 | return ir_const_void(ira, &instruction->base); | 21842 | return ir_const_void(ira, &instruction->base.base); |
| 20849 | } | 21843 | } |
| 20850 | | 21844 | |
| 20851 | bool *fast_math_on_ptr; | 21845 | bool *fast_math_on_ptr; |
| 20852 | AstNode **fast_math_set_node_ptr; | 21846 | AstNode **fast_math_set_node_ptr; |
| 20853 | | 21847 | |
| 20854 | Scope *scope = instruction->base.scope; | 21848 | Scope *scope = instruction->base.base.scope; |
| 20855 | while (scope != nullptr) { | 21849 | while (scope != nullptr) { |
| 20856 | if (scope->id == ScopeIdBlock) { | 21850 | if (scope->id == ScopeIdBlock) { |
| 20857 | ScopeBlock *block_scope = (ScopeBlock *)scope; | 21851 | ScopeBlock *block_scope = (ScopeBlock *)scope; |
| ... | @@ -20877,42 +21871,38 @@ static IrInstruction *ir_analyze_instruction_set_float_mode(IrAnalyze *ira, | ... | @@ -20877,42 +21871,38 @@ static IrInstruction *ir_analyze_instruction_set_float_mode(IrAnalyze *ira, |
| 20877 | } | 21871 | } |
| 20878 | assert(scope != nullptr); | 21872 | assert(scope != nullptr); |
| 20879 | | 21873 | |
| 20880 | IrInstruction *float_mode_value = instruction->mode_value->child; | 21874 | IrInstGen *float_mode_value = instruction->mode_value->child; |
| 20881 | FloatMode float_mode_scalar; | 21875 | FloatMode float_mode_scalar; |
| 20882 | if (!ir_resolve_float_mode(ira, float_mode_value, &float_mode_scalar)) | 21876 | if (!ir_resolve_float_mode(ira, float_mode_value, &float_mode_scalar)) |
| 20883 | return ira->codegen->invalid_instruction; | 21877 | return ira->codegen->invalid_inst_gen; |
| 20884 | | 21878 | |
| 20885 | AstNode *source_node = instruction->base.source_node; | 21879 | AstNode *source_node = instruction->base.base.source_node; |
| 20886 | if (*fast_math_set_node_ptr) { | 21880 | if (*fast_math_set_node_ptr) { |
| 20887 | ErrorMsg *msg = ir_add_error_node(ira, source_node, | 21881 | ErrorMsg *msg = ir_add_error_node(ira, source_node, |
| 20888 | buf_sprintf("float mode set twice for same scope")); | 21882 | buf_sprintf("float mode set twice for same scope")); |
| 20889 | add_error_note(ira->codegen, msg, *fast_math_set_node_ptr, buf_sprintf("first set here")); | 21883 | add_error_note(ira->codegen, msg, *fast_math_set_node_ptr, buf_sprintf("first set here")); |
| 20890 | return ira->codegen->invalid_instruction; | 21884 | return ira->codegen->invalid_inst_gen; |
| 20891 | } | 21885 | } |
| 20892 | *fast_math_set_node_ptr = source_node; | 21886 | *fast_math_set_node_ptr = source_node; |
| 20893 | *fast_math_on_ptr = (float_mode_scalar == FloatModeOptimized); | 21887 | *fast_math_on_ptr = (float_mode_scalar == FloatModeOptimized); |
| 20894 | | 21888 | |
| 20895 | return ir_const_void(ira, &instruction->base); | 21889 | return ir_const_void(ira, &instruction->base.base); |
| 20896 | } | 21890 | } |
| 20897 | | 21891 | |
| 20898 | static IrInstruction *ir_analyze_instruction_any_frame_type(IrAnalyze *ira, | 21892 | static IrInstGen *ir_analyze_instruction_any_frame_type(IrAnalyze *ira, IrInstSrcAnyFrameType *instruction) { |
| 20899 | IrInstructionAnyFrameType *instruction) | | |
| 20900 | { | | |
| 20901 | ZigType *payload_type = nullptr; | 21893 | ZigType *payload_type = nullptr; |
| 20902 | if (instruction->payload_type != nullptr) { | 21894 | if (instruction->payload_type != nullptr) { |
| 20903 | payload_type = ir_resolve_type(ira, instruction->payload_type->child); | 21895 | payload_type = ir_resolve_type(ira, instruction->payload_type->child); |
| 20904 | if (type_is_invalid(payload_type)) | 21896 | if (type_is_invalid(payload_type)) |
| 20905 | return ira->codegen->invalid_instruction; | 21897 | return ira->codegen->invalid_inst_gen; |
| 20906 | } | 21898 | } |
| 20907 | | 21899 | |
| 20908 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, payload_type); | 21900 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, payload_type); |
| 20909 | return ir_const_type(ira, &instruction->base, any_frame_type); | 21901 | return ir_const_type(ira, &instruction->base.base, any_frame_type); |
| 20910 | } | 21902 | } |
| 20911 | | 21903 | |
| 20912 | static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, | 21904 | static IrInstGen *ir_analyze_instruction_slice_type(IrAnalyze *ira, IrInstSrcSliceType *slice_type_instruction) { |
| 20913 | IrInstructionSliceType *slice_type_instruction) | 21905 | IrInstGen *result = ir_const(ira, &slice_type_instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 20914 | { | | |
| 20915 | IrInstruction *result = ir_const(ira, &slice_type_instruction->base, ira->codegen->builtin_types.entry_type); | | |
| 20916 | result->value->special = ConstValSpecialLazy; | 21906 | result->value->special = ConstValSpecialLazy; |
| 20917 | | 21907 | |
| 20918 | LazyValueSliceType *lazy_slice_type = allocate<LazyValueSliceType>(1, "LazyValueSliceType"); | 21908 | LazyValueSliceType *lazy_slice_type = allocate<LazyValueSliceType>(1, "LazyValueSliceType"); |
| ... | @@ -20923,18 +21913,18 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, | ... | @@ -20923,18 +21913,18 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, |
| 20923 | if (slice_type_instruction->align_value != nullptr) { | 21913 | if (slice_type_instruction->align_value != nullptr) { |
| 20924 | lazy_slice_type->align_inst = slice_type_instruction->align_value->child; | 21914 | lazy_slice_type->align_inst = slice_type_instruction->align_value->child; |
| 20925 | if (ir_resolve_const(ira, lazy_slice_type->align_inst, LazyOk) == nullptr) | 21915 | if (ir_resolve_const(ira, lazy_slice_type->align_inst, LazyOk) == nullptr) |
| 20926 | return ira->codegen->invalid_instruction; | 21916 | return ira->codegen->invalid_inst_gen; |
| 20927 | } | 21917 | } |
| 20928 | | 21918 | |
| 20929 | if (slice_type_instruction->sentinel != nullptr) { | 21919 | if (slice_type_instruction->sentinel != nullptr) { |
| 20930 | lazy_slice_type->sentinel = slice_type_instruction->sentinel->child; | 21920 | lazy_slice_type->sentinel = slice_type_instruction->sentinel->child; |
| 20931 | if (ir_resolve_const(ira, lazy_slice_type->sentinel, LazyOk) == nullptr) | 21921 | if (ir_resolve_const(ira, lazy_slice_type->sentinel, LazyOk) == nullptr) |
| 20932 | return ira->codegen->invalid_instruction; | 21922 | return ira->codegen->invalid_inst_gen; |
| 20933 | } | 21923 | } |
| 20934 | | 21924 | |
| 20935 | lazy_slice_type->elem_type = slice_type_instruction->child_type->child; | 21925 | lazy_slice_type->elem_type = slice_type_instruction->child_type->child; |
| 20936 | if (ir_resolve_type_lazy(ira, lazy_slice_type->elem_type) == nullptr) | 21926 | if (ir_resolve_type_lazy(ira, lazy_slice_type->elem_type) == nullptr) |
| 20937 | return ira->codegen->invalid_instruction; | 21927 | return ira->codegen->invalid_inst_gen; |
| 20938 | | 21928 | |
| 20939 | lazy_slice_type->is_const = slice_type_instruction->is_const; | 21929 | lazy_slice_type->is_const = slice_type_instruction->is_const; |
| 20940 | lazy_slice_type->is_volatile = slice_type_instruction->is_volatile; | 21930 | lazy_slice_type->is_volatile = slice_type_instruction->is_volatile; |
| ... | @@ -20943,31 +21933,31 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, | ... | @@ -20943,31 +21933,31 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, |
| 20943 | return result; | 21933 | return result; |
| 20944 | } | 21934 | } |
| 20945 | | 21935 | |
| 20946 | static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAsmSrc *asm_instruction) { | 21936 | static IrInstGen *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstSrcAsm *asm_instruction) { |
| 20947 | Error err; | 21937 | Error err; |
| 20948 | | 21938 | |
| 20949 | assert(asm_instruction->base.source_node->type == NodeTypeAsmExpr); | 21939 | assert(asm_instruction->base.base.source_node->type == NodeTypeAsmExpr); |
| 20950 | | 21940 | |
| 20951 | AstNode *node = asm_instruction->base.source_node; | 21941 | AstNode *node = asm_instruction->base.base.source_node; |
| 20952 | AstNodeAsmExpr *asm_expr = &asm_instruction->base.source_node->data.asm_expr; | 21942 | AstNodeAsmExpr *asm_expr = &asm_instruction->base.base.source_node->data.asm_expr; |
| 20953 | | 21943 | |
| 20954 | Buf *template_buf = ir_resolve_str(ira, asm_instruction->asm_template->child); | 21944 | Buf *template_buf = ir_resolve_str(ira, asm_instruction->asm_template->child); |
| 20955 | if (template_buf == nullptr) | 21945 | if (template_buf == nullptr) |
| 20956 | return ira->codegen->invalid_instruction; | 21946 | return ira->codegen->invalid_inst_gen; |
| 20957 | | 21947 | |
| 20958 | if (asm_instruction->is_global) { | 21948 | if (asm_instruction->is_global) { |
| 20959 | buf_append_char(&ira->codegen->global_asm, '\n'); | 21949 | buf_append_char(&ira->codegen->global_asm, '\n'); |
| 20960 | buf_append_buf(&ira->codegen->global_asm, template_buf); | 21950 | buf_append_buf(&ira->codegen->global_asm, template_buf); |
| 20961 | | 21951 | |
| 20962 | return ir_const_void(ira, &asm_instruction->base); | 21952 | return ir_const_void(ira, &asm_instruction->base.base); |
| 20963 | } | 21953 | } |
| 20964 | | 21954 | |
| 20965 | if (!ir_emit_global_runtime_side_effect(ira, &asm_instruction->base)) | 21955 | if (!ir_emit_global_runtime_side_effect(ira, &asm_instruction->base.base)) |
| 20966 | return ira->codegen->invalid_instruction; | 21956 | return ira->codegen->invalid_inst_gen; |
| 20967 | | 21957 | |
| 20968 | ZigList<AsmToken> tok_list = {}; | 21958 | ZigList<AsmToken> tok_list = {}; |
| 20969 | if ((err = parse_asm_template(ira, node, template_buf, &tok_list))) { | 21959 | if ((err = parse_asm_template(ira, node, template_buf, &tok_list))) { |
| 20970 | return ira->codegen->invalid_instruction; | 21960 | return ira->codegen->invalid_inst_gen; |
| 20971 | } | 21961 | } |
| 20972 | | 21962 | |
| 20973 | for (size_t token_i = 0; token_i < tok_list.length; token_i += 1) { | 21963 | for (size_t token_i = 0; token_i < tok_list.length; token_i += 1) { |
| ... | @@ -20981,15 +21971,15 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs | ... | @@ -20981,15 +21971,15 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs |
| 20981 | add_node_error(ira->codegen, node, | 21971 | add_node_error(ira->codegen, node, |
| 20982 | buf_sprintf("could not find '%.*s' in the inputs or outputs", | 21972 | buf_sprintf("could not find '%.*s' in the inputs or outputs", |
| 20983 | len, ptr)); | 21973 | len, ptr)); |
| 20984 | return ira->codegen->invalid_instruction; | 21974 | return ira->codegen->invalid_inst_gen; |
| 20985 | } | 21975 | } |
| 20986 | } | 21976 | } |
| 20987 | } | 21977 | } |
| 20988 | | 21978 | |
| 20989 | // TODO validate the output types and variable types | 21979 | // TODO validate the output types and variable types |
| 20990 | | 21980 | |
| 20991 | IrInstruction **input_list = allocate<IrInstruction *>(asm_expr->input_list.length); | 21981 | IrInstGen **input_list = allocate<IrInstGen *>(asm_expr->input_list.length); |
| 20992 | IrInstruction **output_types = allocate<IrInstruction *>(asm_expr->output_list.length); | 21982 | IrInstGen **output_types = allocate<IrInstGen *>(asm_expr->output_list.length); |
| 20993 | | 21983 | |
| 20994 | ZigType *return_type = ira->codegen->builtin_types.entry_void; | 21984 | ZigType *return_type = ira->codegen->builtin_types.entry_void; |
| 20995 | for (size_t i = 0; i < asm_expr->output_list.length; i += 1) { | 21985 | for (size_t i = 0; i < asm_expr->output_list.length; i += 1) { |
| ... | @@ -20998,39 +21988,34 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs | ... | @@ -20998,39 +21988,34 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs |
| 20998 | output_types[i] = asm_instruction->output_types[i]->child; | 21988 | output_types[i] = asm_instruction->output_types[i]->child; |
| 20999 | return_type = ir_resolve_type(ira, output_types[i]); | 21989 | return_type = ir_resolve_type(ira, output_types[i]); |
| 21000 | if (type_is_invalid(return_type)) | 21990 | if (type_is_invalid(return_type)) |
| 21001 | return ira->codegen->invalid_instruction; | 21991 | return ira->codegen->invalid_inst_gen; |
| 21002 | } | 21992 | } |
| 21003 | } | 21993 | } |
| 21004 | | 21994 | |
| 21005 | for (size_t i = 0; i < asm_expr->input_list.length; i += 1) { | 21995 | for (size_t i = 0; i < asm_expr->input_list.length; i += 1) { |
| 21006 | IrInstruction *const input_value = asm_instruction->input_list[i]->child; | 21996 | IrInstGen *const input_value = asm_instruction->input_list[i]->child; |
| 21007 | if (type_is_invalid(input_value->value->type)) | 21997 | if (type_is_invalid(input_value->value->type)) |
| 21008 | return ira->codegen->invalid_instruction; | 21998 | return ira->codegen->invalid_inst_gen; |
| 21009 | | 21999 | |
| 21010 | if (instr_is_comptime(input_value) && | 22000 | if (instr_is_comptime(input_value) && |
| 21011 | (input_value->value->type->id == ZigTypeIdComptimeInt || | 22001 | (input_value->value->type->id == ZigTypeIdComptimeInt || |
| 21012 | input_value->value->type->id == ZigTypeIdComptimeFloat)) { | 22002 | input_value->value->type->id == ZigTypeIdComptimeFloat)) { |
| 21013 | ir_add_error_node(ira, input_value->source_node, | 22003 | ir_add_error(ira, &input_value->base, |
| 21014 | buf_sprintf("expected sized integer or sized float, found %s", buf_ptr(&input_value->value->type->name))); | 22004 | buf_sprintf("expected sized integer or sized float, found %s", buf_ptr(&input_value->value->type->name))); |
| 21015 | return ira->codegen->invalid_instruction; | 22005 | return ira->codegen->invalid_inst_gen; |
| 21016 | } | 22006 | } |
| 21017 | | 22007 | |
| 21018 | input_list[i] = input_value; | 22008 | input_list[i] = input_value; |
| 21019 | } | 22009 | } |
| 21020 | | 22010 | |
| 21021 | IrInstruction *result = ir_build_asm_gen(ira, | 22011 | return ir_build_asm_gen(ira, &asm_instruction->base.base, |
| 21022 | asm_instruction->base.scope, asm_instruction->base.source_node, | | |
| 21023 | template_buf, tok_list.items, tok_list.length, | 22012 | template_buf, tok_list.items, tok_list.length, |
| 21024 | input_list, output_types, asm_instruction->output_vars, asm_instruction->return_count, | 22013 | input_list, output_types, asm_instruction->output_vars, asm_instruction->return_count, |
| 21025 | asm_instruction->has_side_effects); | 22014 | asm_instruction->has_side_effects, return_type); |
| 21026 | result->value->type = return_type; | | |
| 21027 | return result; | | |
| 21028 | } | 22015 | } |
| 21029 | | 22016 | |
| 21030 | static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, | 22017 | static IrInstGen *ir_analyze_instruction_array_type(IrAnalyze *ira, IrInstSrcArrayType *array_type_instruction) { |
| 21031 | IrInstructionArrayType *array_type_instruction) | 22018 | IrInstGen *result = ir_const(ira, &array_type_instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 21032 | { | | |
| 21033 | IrInstruction *result = ir_const(ira, &array_type_instruction->base, ira->codegen->builtin_types.entry_type); | | |
| 21034 | result->value->special = ConstValSpecialLazy; | 22019 | result->value->special = ConstValSpecialLazy; |
| 21035 | | 22020 | |
| 21036 | LazyValueArrayType *lazy_array_type = allocate<LazyValueArrayType>(1, "LazyValueArrayType"); | 22021 | LazyValueArrayType *lazy_array_type = allocate<LazyValueArrayType>(1, "LazyValueArrayType"); |
| ... | @@ -21040,22 +22025,22 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, | ... | @@ -21040,22 +22025,22 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, |
| 21040 | | 22025 | |
| 21041 | lazy_array_type->elem_type = array_type_instruction->child_type->child; | 22026 | lazy_array_type->elem_type = array_type_instruction->child_type->child; |
| 21042 | if (ir_resolve_type_lazy(ira, lazy_array_type->elem_type) == nullptr) | 22027 | if (ir_resolve_type_lazy(ira, lazy_array_type->elem_type) == nullptr) |
| 21043 | return ira->codegen->invalid_instruction; | 22028 | return ira->codegen->invalid_inst_gen; |
| 21044 | | 22029 | |
| 21045 | if (!ir_resolve_usize(ira, array_type_instruction->size->child, &lazy_array_type->length)) | 22030 | if (!ir_resolve_usize(ira, array_type_instruction->size->child, &lazy_array_type->length)) |
| 21046 | return ira->codegen->invalid_instruction; | 22031 | return ira->codegen->invalid_inst_gen; |
| 21047 | | 22032 | |
| 21048 | if (array_type_instruction->sentinel != nullptr) { | 22033 | if (array_type_instruction->sentinel != nullptr) { |
| 21049 | lazy_array_type->sentinel = array_type_instruction->sentinel->child; | 22034 | lazy_array_type->sentinel = array_type_instruction->sentinel->child; |
| 21050 | if (ir_resolve_const(ira, lazy_array_type->sentinel, LazyOk) == nullptr) | 22035 | if (ir_resolve_const(ira, lazy_array_type->sentinel, LazyOk) == nullptr) |
| 21051 | return ira->codegen->invalid_instruction; | 22036 | return ira->codegen->invalid_inst_gen; |
| 21052 | } | 22037 | } |
| 21053 | | 22038 | |
| 21054 | return result; | 22039 | return result; |
| 21055 | } | 22040 | } |
| 21056 | | 22041 | |
| 21057 | static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstructionSizeOf *instruction) { | 22042 | static IrInstGen *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstSrcSizeOf *instruction) { |
| 21058 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 22043 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_num_lit_int); |
| 21059 | result->value->special = ConstValSpecialLazy; | 22044 | result->value->special = ConstValSpecialLazy; |
| 21060 | | 22045 | |
| 21061 | LazyValueSizeOf *lazy_size_of = allocate<LazyValueSizeOf>(1, "LazyValueSizeOf"); | 22046 | LazyValueSizeOf *lazy_size_of = allocate<LazyValueSizeOf>(1, "LazyValueSizeOf"); |
| ... | @@ -21066,19 +22051,19 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstructi | ... | @@ -21066,19 +22051,19 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstructi |
| 21066 | | 22051 | |
| 21067 | lazy_size_of->target_type = instruction->type_value->child; | 22052 | lazy_size_of->target_type = instruction->type_value->child; |
| 21068 | if (ir_resolve_type_lazy(ira, lazy_size_of->target_type) == nullptr) | 22053 | if (ir_resolve_type_lazy(ira, lazy_size_of->target_type) == nullptr) |
| 21069 | return ira->codegen->invalid_instruction; | 22054 | return ira->codegen->invalid_inst_gen; |
| 21070 | | 22055 | |
| 21071 | return result; | 22056 | return result; |
| 21072 | } | 22057 | } |
| 21073 | | 22058 | |
| 21074 | static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *source_inst, IrInstruction *value) { | 22059 | static IrInstGen *ir_analyze_test_non_null(IrAnalyze *ira, IrInst *source_inst, IrInstGen *value) { |
| 21075 | ZigType *type_entry = value->value->type; | 22060 | ZigType *type_entry = value->value->type; |
| 21076 | | 22061 | |
| 21077 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.allow_zero) { | 22062 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.allow_zero) { |
| 21078 | if (instr_is_comptime(value)) { | 22063 | if (instr_is_comptime(value)) { |
| 21079 | ZigValue *c_ptr_val = ir_resolve_const(ira, value, UndefOk); | 22064 | ZigValue *c_ptr_val = ir_resolve_const(ira, value, UndefOk); |
| 21080 | if (c_ptr_val == nullptr) | 22065 | if (c_ptr_val == nullptr) |
| 21081 | return ira->codegen->invalid_instruction; | 22066 | return ira->codegen->invalid_inst_gen; |
| 21082 | if (c_ptr_val->special == ConstValSpecialUndef) | 22067 | if (c_ptr_val->special == ConstValSpecialUndef) |
| 21083 | return ir_const_undef(ira, source_inst, ira->codegen->builtin_types.entry_bool); | 22068 | return ir_const_undef(ira, source_inst, ira->codegen->builtin_types.entry_bool); |
| 21084 | bool is_null = c_ptr_val->data.x_ptr.special == ConstPtrSpecialNull || | 22069 | bool is_null = c_ptr_val->data.x_ptr.special == ConstPtrSpecialNull || |
| ... | @@ -21087,25 +22072,19 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so | ... | @@ -21087,25 +22072,19 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so |
| 21087 | return ir_const_bool(ira, source_inst, !is_null); | 22072 | return ir_const_bool(ira, source_inst, !is_null); |
| 21088 | } | 22073 | } |
| 21089 | | 22074 | |
| 21090 | IrInstruction *result = ir_build_test_nonnull(&ira->new_irb, | 22075 | return ir_build_test_non_null_gen(ira, source_inst, value); |
| 21091 | source_inst->scope, source_inst->source_node, value); | | |
| 21092 | result->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 21093 | return result; | | |
| 21094 | } else if (type_entry->id == ZigTypeIdOptional) { | 22076 | } else if (type_entry->id == ZigTypeIdOptional) { |
| 21095 | if (instr_is_comptime(value)) { | 22077 | if (instr_is_comptime(value)) { |
| 21096 | ZigValue *maybe_val = ir_resolve_const(ira, value, UndefOk); | 22078 | ZigValue *maybe_val = ir_resolve_const(ira, value, UndefOk); |
| 21097 | if (maybe_val == nullptr) | 22079 | if (maybe_val == nullptr) |
| 21098 | return ira->codegen->invalid_instruction; | 22080 | return ira->codegen->invalid_inst_gen; |
| 21099 | if (maybe_val->special == ConstValSpecialUndef) | 22081 | if (maybe_val->special == ConstValSpecialUndef) |
| 21100 | return ir_const_undef(ira, source_inst, ira->codegen->builtin_types.entry_bool); | 22082 | return ir_const_undef(ira, source_inst, ira->codegen->builtin_types.entry_bool); |
| 21101 | | 22083 | |
| 21102 | return ir_const_bool(ira, source_inst, !optional_value_is_null(maybe_val)); | 22084 | return ir_const_bool(ira, source_inst, !optional_value_is_null(maybe_val)); |
| 21103 | } | 22085 | } |
| 21104 | | 22086 | |
| 21105 | IrInstruction *result = ir_build_test_nonnull(&ira->new_irb, | 22087 | return ir_build_test_non_null_gen(ira, source_inst, value); |
| 21106 | source_inst->scope, source_inst->source_node, value); | | |
| 21107 | result->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 21108 | return result; | | |
| 21109 | } else if (type_entry->id == ZigTypeIdNull) { | 22088 | } else if (type_entry->id == ZigTypeIdNull) { |
| 21110 | return ir_const_bool(ira, source_inst, false); | 22089 | return ir_const_bool(ira, source_inst, false); |
| 21111 | } else { | 22090 | } else { |
| ... | @@ -21113,53 +22092,53 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so | ... | @@ -21113,53 +22092,53 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so |
| 21113 | } | 22092 | } |
| 21114 | } | 22093 | } |
| 21115 | | 22094 | |
| 21116 | static IrInstruction *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstructionTestNonNull *instruction) { | 22095 | static IrInstGen *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstSrcTestNonNull *instruction) { |
| 21117 | IrInstruction *value = instruction->value->child; | 22096 | IrInstGen *value = instruction->value->child; |
| 21118 | if (type_is_invalid(value->value->type)) | 22097 | if (type_is_invalid(value->value->type)) |
| 21119 | return ira->codegen->invalid_instruction; | 22098 | return ira->codegen->invalid_inst_gen; |
| 21120 | | 22099 | |
| 21121 | return ir_analyze_test_non_null(ira, &instruction->base, value); | 22100 | return ir_analyze_test_non_null(ira, &instruction->base.base, value); |
| 21122 | } | 22101 | } |
| 21123 | | 22102 | |
| 21124 | static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstruction *source_instr, | 22103 | static IrInstGen *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInst* source_instr, |
| 21125 | IrInstruction *base_ptr, bool safety_check_on, bool initializing) | 22104 | IrInstGen *base_ptr, bool safety_check_on, bool initializing) |
| 21126 | { | 22105 | { |
| 21127 | Error err; | 22106 | Error err; |
| 21128 | | 22107 | |
| 21129 | ZigType *type_entry = get_ptr_elem_type(ira->codegen, base_ptr); | 22108 | ZigType *type_entry = get_ptr_elem_type(ira->codegen, base_ptr); |
| 21130 | if (type_is_invalid(type_entry)) | 22109 | if (type_is_invalid(type_entry)) |
| 21131 | return ira->codegen->invalid_instruction; | 22110 | return ira->codegen->invalid_inst_gen; |
| 21132 | | 22111 | |
| 21133 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.ptr_len == PtrLenC) { | 22112 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.ptr_len == PtrLenC) { |
| 21134 | if (instr_is_comptime(base_ptr)) { | 22113 | if (instr_is_comptime(base_ptr)) { |
| 21135 | ZigValue *val = ir_resolve_const(ira, base_ptr, UndefBad); | 22114 | ZigValue *val = ir_resolve_const(ira, base_ptr, UndefBad); |
| 21136 | if (!val) | 22115 | if (!val) |
| 21137 | return ira->codegen->invalid_instruction; | 22116 | return ira->codegen->invalid_inst_gen; |
| 21138 | if (val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 22117 | if (val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 21139 | ZigValue *c_ptr_val = const_ptr_pointee(ira, ira->codegen, val, source_instr->source_node); | 22118 | ZigValue *c_ptr_val = const_ptr_pointee(ira, ira->codegen, val, source_instr->source_node); |
| 21140 | if (c_ptr_val == nullptr) | 22119 | if (c_ptr_val == nullptr) |
| 21141 | return ira->codegen->invalid_instruction; | 22120 | return ira->codegen->invalid_inst_gen; |
| 21142 | bool is_null = c_ptr_val->data.x_ptr.special == ConstPtrSpecialNull || | 22121 | bool is_null = c_ptr_val->data.x_ptr.special == ConstPtrSpecialNull || |
| 21143 | (c_ptr_val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr && | 22122 | (c_ptr_val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr && |
| 21144 | c_ptr_val->data.x_ptr.data.hard_coded_addr.addr == 0); | 22123 | c_ptr_val->data.x_ptr.data.hard_coded_addr.addr == 0); |
| 21145 | if (is_null) { | 22124 | if (is_null) { |
| 21146 | ir_add_error(ira, source_instr, buf_sprintf("unable to unwrap null")); | 22125 | ir_add_error(ira, source_instr, buf_sprintf("unable to unwrap null")); |
| 21147 | return ira->codegen->invalid_instruction; | 22126 | return ira->codegen->invalid_inst_gen; |
| 21148 | } | 22127 | } |
| 21149 | return base_ptr; | 22128 | return base_ptr; |
| 21150 | } | 22129 | } |
| 21151 | } | 22130 | } |
| 21152 | if (!safety_check_on) | 22131 | if (!safety_check_on) |
| 21153 | return base_ptr; | 22132 | return base_ptr; |
| 21154 | IrInstruction *c_ptr_val = ir_get_deref(ira, source_instr, base_ptr, nullptr); | 22133 | IrInstGen *c_ptr_val = ir_get_deref(ira, source_instr, base_ptr, nullptr); |
| 21155 | ir_build_assert_non_null(ira, source_instr, c_ptr_val); | 22134 | ir_build_assert_non_null(ira, source_instr, c_ptr_val); |
| 21156 | return base_ptr; | 22135 | return base_ptr; |
| 21157 | } | 22136 | } |
| 21158 | | 22137 | |
| 21159 | if (type_entry->id != ZigTypeIdOptional) { | 22138 | if (type_entry->id != ZigTypeIdOptional) { |
| 21160 | ir_add_error_node(ira, base_ptr->source_node, | 22139 | ir_add_error(ira, &base_ptr->base, |
| 21161 | buf_sprintf("expected optional type, found '%s'", buf_ptr(&type_entry->name))); | 22140 | buf_sprintf("expected optional type, found '%s'", buf_ptr(&type_entry->name))); |
| 21162 | return ira->codegen->invalid_instruction; | 22141 | return ira->codegen->invalid_inst_gen; |
| 21163 | } | 22142 | } |
| 21164 | | 22143 | |
| 21165 | ZigType *child_type = type_entry->data.maybe.child_type; | 22144 | ZigType *child_type = type_entry->data.maybe.child_type; |
| ... | @@ -21172,16 +22151,16 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -21172,16 +22151,16 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 21172 | if (instr_is_comptime(base_ptr)) { | 22151 | if (instr_is_comptime(base_ptr)) { |
| 21173 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); | 22152 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); |
| 21174 | if (ptr_val == nullptr) | 22153 | if (ptr_val == nullptr) |
| 21175 | return ira->codegen->invalid_instruction; | 22154 | return ira->codegen->invalid_inst_gen; |
| 21176 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 22155 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 21177 | ZigValue *optional_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 22156 | ZigValue *optional_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 21178 | if (optional_val == nullptr) | 22157 | if (optional_val == nullptr) |
| 21179 | return ira->codegen->invalid_instruction; | 22158 | return ira->codegen->invalid_inst_gen; |
| 21180 | | 22159 | |
| 21181 | if (initializing) { | 22160 | if (initializing) { |
| 21182 | switch (type_has_one_possible_value(ira->codegen, child_type)) { | 22161 | switch (type_has_one_possible_value(ira->codegen, child_type)) { |
| 21183 | case OnePossibleValueInvalid: | 22162 | case OnePossibleValueInvalid: |
| 21184 | return ira->codegen->invalid_instruction; | 22163 | return ira->codegen->invalid_inst_gen; |
| 21185 | case OnePossibleValueNo: | 22164 | case OnePossibleValueNo: |
| 21186 | if (!same_comptime_repr) { | 22165 | if (!same_comptime_repr) { |
| 21187 | ZigValue *payload_val = create_const_vals(1); | 22166 | ZigValue *payload_val = create_const_vals(1); |
| ... | @@ -21209,18 +22188,17 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -21209,18 +22188,17 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 21209 | } else { | 22188 | } else { |
| 21210 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, | 22189 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, |
| 21211 | source_instr->source_node, optional_val, UndefBad))) | 22190 | source_instr->source_node, optional_val, UndefBad))) |
| 21212 | return ira->codegen->invalid_instruction; | 22191 | return ira->codegen->invalid_inst_gen; |
| 21213 | if (optional_value_is_null(optional_val)) { | 22192 | if (optional_value_is_null(optional_val)) { |
| 21214 | ir_add_error(ira, source_instr, buf_sprintf("unable to unwrap null")); | 22193 | ir_add_error(ira, source_instr, buf_sprintf("unable to unwrap null")); |
| 21215 | return ira->codegen->invalid_instruction; | 22194 | return ira->codegen->invalid_inst_gen; |
| 21216 | } | 22195 | } |
| 21217 | } | 22196 | } |
| 21218 | | 22197 | |
| 21219 | IrInstruction *result; | 22198 | IrInstGen *result; |
| 21220 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 22199 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 21221 | result = ir_build_optional_unwrap_ptr(&ira->new_irb, source_instr->scope, | 22200 | result = ir_build_optional_unwrap_ptr_gen(ira, source_instr, base_ptr, false, |
| 21222 | source_instr->source_node, base_ptr, false, initializing); | 22201 | initializing, result_type); |
| 21223 | result->value->type = result_type; | | |
| 21224 | result->value->special = ConstValSpecialStatic; | 22202 | result->value->special = ConstValSpecialStatic; |
| 21225 | } else { | 22203 | } else { |
| 21226 | result = ir_const(ira, source_instr, result_type); | 22204 | result = ir_const(ira, source_instr, result_type); |
| ... | @@ -21230,7 +22208,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -21230,7 +22208,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 21230 | result_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; | 22208 | result_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; |
| 21231 | switch (type_has_one_possible_value(ira->codegen, child_type)) { | 22209 | switch (type_has_one_possible_value(ira->codegen, child_type)) { |
| 21232 | case OnePossibleValueInvalid: | 22210 | case OnePossibleValueInvalid: |
| 21233 | return ira->codegen->invalid_instruction; | 22211 | return ira->codegen->invalid_inst_gen; |
| 21234 | case OnePossibleValueNo: | 22212 | case OnePossibleValueNo: |
| 21235 | if (same_comptime_repr) { | 22213 | if (same_comptime_repr) { |
| 21236 | result_val->data.x_ptr.data.ref.pointee = optional_val; | 22214 | result_val->data.x_ptr.data.ref.pointee = optional_val; |
| ... | @@ -21248,135 +22226,120 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -21248,135 +22226,120 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 21248 | } | 22226 | } |
| 21249 | } | 22227 | } |
| 21250 | | 22228 | |
| 21251 | IrInstruction *result = ir_build_optional_unwrap_ptr(&ira->new_irb, source_instr->scope, | 22229 | return ir_build_optional_unwrap_ptr_gen(ira, source_instr, base_ptr, safety_check_on, |
| 21252 | source_instr->source_node, base_ptr, safety_check_on, initializing); | 22230 | initializing, result_type); |
| 21253 | result->value->type = result_type; | | |
| 21254 | return result; | | |
| 21255 | } | 22231 | } |
| 21256 | | 22232 | |
| 21257 | static IrInstruction *ir_analyze_instruction_optional_unwrap_ptr(IrAnalyze *ira, | 22233 | static IrInstGen *ir_analyze_instruction_optional_unwrap_ptr(IrAnalyze *ira, |
| 21258 | IrInstructionOptionalUnwrapPtr *instruction) | 22234 | IrInstSrcOptionalUnwrapPtr *instruction) |
| 21259 | { | 22235 | { |
| 21260 | IrInstruction *base_ptr = instruction->base_ptr->child; | 22236 | IrInstGen *base_ptr = instruction->base_ptr->child; |
| 21261 | if (type_is_invalid(base_ptr->value->type)) | 22237 | if (type_is_invalid(base_ptr->value->type)) |
| 21262 | return ira->codegen->invalid_instruction; | 22238 | return ira->codegen->invalid_inst_gen; |
| 21263 | | 22239 | |
| 21264 | return ir_analyze_unwrap_optional_payload(ira, &instruction->base, base_ptr, | 22240 | return ir_analyze_unwrap_optional_payload(ira, &instruction->base.base, base_ptr, |
| 21265 | instruction->safety_check_on, false); | 22241 | instruction->safety_check_on, false); |
| 21266 | } | 22242 | } |
| 21267 | | 22243 | |
| 21268 | static IrInstruction *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCtz *instruction) { | 22244 | static IrInstGen *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstSrcCtz *instruction) { |
| 21269 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); | 22245 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); |
| 21270 | if (type_is_invalid(int_type)) | 22246 | if (type_is_invalid(int_type)) |
| 21271 | return ira->codegen->invalid_instruction; | 22247 | return ira->codegen->invalid_inst_gen; |
| 21272 | | 22248 | |
| 21273 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); | 22249 | IrInstGen *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 21274 | if (type_is_invalid(op->value->type)) | 22250 | if (type_is_invalid(op->value->type)) |
| 21275 | return ira->codegen->invalid_instruction; | 22251 | return ira->codegen->invalid_inst_gen; |
| 21276 | | 22252 | |
| 21277 | if (int_type->data.integral.bit_count == 0) | 22253 | if (int_type->data.integral.bit_count == 0) |
| 21278 | return ir_const_unsigned(ira, &instruction->base, 0); | 22254 | return ir_const_unsigned(ira, &instruction->base.base, 0); |
| 21279 | | 22255 | |
| 21280 | if (instr_is_comptime(op)) { | 22256 | if (instr_is_comptime(op)) { |
| 21281 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); | 22257 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 21282 | if (val == nullptr) | 22258 | if (val == nullptr) |
| 21283 | return ira->codegen->invalid_instruction; | 22259 | return ira->codegen->invalid_inst_gen; |
| 21284 | if (val->special == ConstValSpecialUndef) | 22260 | if (val->special == ConstValSpecialUndef) |
| 21285 | return ir_const_undef(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 22261 | return ir_const_undef(ira, &instruction->base.base, ira->codegen->builtin_types.entry_num_lit_int); |
| 21286 | size_t result_usize = bigint_ctz(&op->value->data.x_bigint, int_type->data.integral.bit_count); | 22262 | size_t result_usize = bigint_ctz(&op->value->data.x_bigint, int_type->data.integral.bit_count); |
| 21287 | return ir_const_unsigned(ira, &instruction->base, result_usize); | 22263 | return ir_const_unsigned(ira, &instruction->base.base, result_usize); |
| 21288 | } | 22264 | } |
| 21289 | | 22265 | |
| 21290 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); | 22266 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); |
| 21291 | IrInstruction *result = ir_build_ctz(&ira->new_irb, instruction->base.scope, | 22267 | return ir_build_ctz_gen(ira, &instruction->base.base, return_type, op); |
| 21292 | instruction->base.source_node, nullptr, op); | | |
| 21293 | result->value->type = return_type; | | |
| 21294 | return result; | | |
| 21295 | } | 22268 | } |
| 21296 | | 22269 | |
| 21297 | static IrInstruction *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionClz *instruction) { | 22270 | static IrInstGen *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstSrcClz *instruction) { |
| 21298 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); | 22271 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); |
| 21299 | if (type_is_invalid(int_type)) | 22272 | if (type_is_invalid(int_type)) |
| 21300 | return ira->codegen->invalid_instruction; | 22273 | return ira->codegen->invalid_inst_gen; |
| 21301 | | 22274 | |
| 21302 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); | 22275 | IrInstGen *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 21303 | if (type_is_invalid(op->value->type)) | 22276 | if (type_is_invalid(op->value->type)) |
| 21304 | return ira->codegen->invalid_instruction; | 22277 | return ira->codegen->invalid_inst_gen; |
| 21305 | | 22278 | |
| 21306 | if (int_type->data.integral.bit_count == 0) | 22279 | if (int_type->data.integral.bit_count == 0) |
| 21307 | return ir_const_unsigned(ira, &instruction->base, 0); | 22280 | return ir_const_unsigned(ira, &instruction->base.base, 0); |
| 21308 | | 22281 | |
| 21309 | if (instr_is_comptime(op)) { | 22282 | if (instr_is_comptime(op)) { |
| 21310 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); | 22283 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 21311 | if (val == nullptr) | 22284 | if (val == nullptr) |
| 21312 | return ira->codegen->invalid_instruction; | 22285 | return ira->codegen->invalid_inst_gen; |
| 21313 | if (val->special == ConstValSpecialUndef) | 22286 | if (val->special == ConstValSpecialUndef) |
| 21314 | return ir_const_undef(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 22287 | return ir_const_undef(ira, &instruction->base.base, ira->codegen->builtin_types.entry_num_lit_int); |
| 21315 | size_t result_usize = bigint_clz(&op->value->data.x_bigint, int_type->data.integral.bit_count); | 22288 | size_t result_usize = bigint_clz(&op->value->data.x_bigint, int_type->data.integral.bit_count); |
| 21316 | return ir_const_unsigned(ira, &instruction->base, result_usize); | 22289 | return ir_const_unsigned(ira, &instruction->base.base, result_usize); |
| 21317 | } | 22290 | } |
| 21318 | | 22291 | |
| 21319 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); | 22292 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); |
| 21320 | IrInstruction *result = ir_build_clz(&ira->new_irb, instruction->base.scope, | 22293 | return ir_build_clz_gen(ira, &instruction->base.base, return_type, op); |
| 21321 | instruction->base.source_node, nullptr, op); | | |
| 21322 | result->value->type = return_type; | | |
| 21323 | return result; | | |
| 21324 | } | 22294 | } |
| 21325 | | 22295 | |
| 21326 | static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstructionPopCount *instruction) { | 22296 | static IrInstGen *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstSrcPopCount *instruction) { |
| 21327 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); | 22297 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); |
| 21328 | if (type_is_invalid(int_type)) | 22298 | if (type_is_invalid(int_type)) |
| 21329 | return ira->codegen->invalid_instruction; | 22299 | return ira->codegen->invalid_inst_gen; |
| 21330 | | 22300 | |
| 21331 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); | 22301 | IrInstGen *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 21332 | if (type_is_invalid(op->value->type)) | 22302 | if (type_is_invalid(op->value->type)) |
| 21333 | return ira->codegen->invalid_instruction; | 22303 | return ira->codegen->invalid_inst_gen; |
| 21334 | | 22304 | |
| 21335 | if (int_type->data.integral.bit_count == 0) | 22305 | if (int_type->data.integral.bit_count == 0) |
| 21336 | return ir_const_unsigned(ira, &instruction->base, 0); | 22306 | return ir_const_unsigned(ira, &instruction->base.base, 0); |
| 21337 | | 22307 | |
| 21338 | if (instr_is_comptime(op)) { | 22308 | if (instr_is_comptime(op)) { |
| 21339 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); | 22309 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 21340 | if (val == nullptr) | 22310 | if (val == nullptr) |
| 21341 | return ira->codegen->invalid_instruction; | 22311 | return ira->codegen->invalid_inst_gen; |
| 21342 | if (val->special == ConstValSpecialUndef) | 22312 | if (val->special == ConstValSpecialUndef) |
| 21343 | return ir_const_undef(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 22313 | return ir_const_undef(ira, &instruction->base.base, ira->codegen->builtin_types.entry_num_lit_int); |
| 21344 | | 22314 | |
| 21345 | if (bigint_cmp_zero(&val->data.x_bigint) != CmpLT) { | 22315 | if (bigint_cmp_zero(&val->data.x_bigint) != CmpLT) { |
| 21346 | size_t result = bigint_popcount_unsigned(&val->data.x_bigint); | 22316 | size_t result = bigint_popcount_unsigned(&val->data.x_bigint); |
| 21347 | return ir_const_unsigned(ira, &instruction->base, result); | 22317 | return ir_const_unsigned(ira, &instruction->base.base, result); |
| 21348 | } | 22318 | } |
| 21349 | size_t result = bigint_popcount_signed(&val->data.x_bigint, int_type->data.integral.bit_count); | 22319 | size_t result = bigint_popcount_signed(&val->data.x_bigint, int_type->data.integral.bit_count); |
| 21350 | return ir_const_unsigned(ira, &instruction->base, result); | 22320 | return ir_const_unsigned(ira, &instruction->base.base, result); |
| 21351 | } | 22321 | } |
| 21352 | | 22322 | |
| 21353 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); | 22323 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); |
| 21354 | IrInstruction *result = ir_build_pop_count(&ira->new_irb, instruction->base.scope, | 22324 | return ir_build_pop_count_gen(ira, &instruction->base.base, return_type, op); |
| 21355 | instruction->base.source_node, nullptr, op); | | |
| 21356 | result->value->type = return_type; | | |
| 21357 | return result; | | |
| 21358 | } | 22325 | } |
| 21359 | | 22326 | |
| 21360 | static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value) { | 22327 | static IrInstGen *ir_analyze_union_tag(IrAnalyze *ira, IrInst* source_instr, IrInstGen *value, bool is_gen) { |
| 21361 | if (type_is_invalid(value->value->type)) | 22328 | if (type_is_invalid(value->value->type)) |
| 21362 | return ira->codegen->invalid_instruction; | 22329 | return ira->codegen->invalid_inst_gen; |
| 21363 | | | |
| 21364 | if (value->value->type->id == ZigTypeIdEnum) { | | |
| 21365 | return value; | | |
| 21366 | } | | |
| 21367 | | 22330 | |
| 21368 | if (value->value->type->id != ZigTypeIdUnion) { | 22331 | if (value->value->type->id != ZigTypeIdUnion) { |
| 21369 | ir_add_error(ira, value, | 22332 | ir_add_error(ira, &value->base, |
| 21370 | buf_sprintf("expected enum or union type, found '%s'", buf_ptr(&value->value->type->name))); | 22333 | buf_sprintf("expected enum or union type, found '%s'", buf_ptr(&value->value->type->name))); |
| 21371 | return ira->codegen->invalid_instruction; | 22334 | return ira->codegen->invalid_inst_gen; |
| 21372 | } | 22335 | } |
| 21373 | if (!value->value->type->data.unionation.have_explicit_tag_type && !source_instr->is_gen) { | 22336 | if (!value->value->type->data.unionation.have_explicit_tag_type && !is_gen) { |
| 21374 | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("union has no associated enum")); | 22337 | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("union has no associated enum")); |
| 21375 | if (value->value->type->data.unionation.decl_node != nullptr) { | 22338 | if (value->value->type->data.unionation.decl_node != nullptr) { |
| 21376 | add_error_note(ira->codegen, msg, value->value->type->data.unionation.decl_node, | 22339 | add_error_note(ira->codegen, msg, value->value->type->data.unionation.decl_node, |
| 21377 | buf_sprintf("declared here")); | 22340 | buf_sprintf("declared here")); |
| 21378 | } | 22341 | } |
| 21379 | return ira->codegen->invalid_instruction; | 22342 | return ira->codegen->invalid_inst_gen; |
| 21380 | } | 22343 | } |
| 21381 | | 22344 | |
| 21382 | ZigType *tag_type = value->value->type->data.unionation.tag_type; | 22345 | ZigType *tag_type = value->value->type->data.unionation.tag_type; |
| ... | @@ -21385,9 +22348,9 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source | ... | @@ -21385,9 +22348,9 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source |
| 21385 | if (instr_is_comptime(value)) { | 22348 | if (instr_is_comptime(value)) { |
| 21386 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); | 22349 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 21387 | if (!val) | 22350 | if (!val) |
| 21388 | return ira->codegen->invalid_instruction; | 22351 | return ira->codegen->invalid_inst_gen; |
| 21389 | | 22352 | |
| 21390 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 22353 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, |
| 21391 | source_instr->scope, source_instr->source_node); | 22354 | source_instr->scope, source_instr->source_node); |
| 21392 | const_instruction->base.value->type = tag_type; | 22355 | const_instruction->base.value->type = tag_type; |
| 21393 | const_instruction->base.value->special = ConstValSpecialStatic; | 22356 | const_instruction->base.value->special = ConstValSpecialStatic; |
| ... | @@ -21395,15 +22358,13 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source | ... | @@ -21395,15 +22358,13 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source |
| 21395 | return &const_instruction->base; | 22358 | return &const_instruction->base; |
| 21396 | } | 22359 | } |
| 21397 | | 22360 | |
| 21398 | IrInstruction *result = ir_build_union_tag(&ira->new_irb, source_instr->scope, source_instr->source_node, value); | 22361 | return ir_build_union_tag(ira, source_instr, value, tag_type); |
| 21399 | result->value->type = tag_type; | | |
| 21400 | return result; | | |
| 21401 | } | 22362 | } |
| 21402 | | 22363 | |
| 21403 | static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | 22364 | static IrInstGen *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 21404 | IrInstructionSwitchBr *switch_br_instruction) | 22365 | IrInstSrcSwitchBr *switch_br_instruction) |
| 21405 | { | 22366 | { |
| 21406 | IrInstruction *target_value = switch_br_instruction->target_value->child; | 22367 | IrInstGen *target_value = switch_br_instruction->target_value->child; |
| 21407 | if (type_is_invalid(target_value->value->type)) | 22368 | if (type_is_invalid(target_value->value->type)) |
| 21408 | return ir_unreach_error(ira); | 22369 | return ir_unreach_error(ira); |
| 21409 | | 22370 | |
| ... | @@ -21418,27 +22379,21 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -21418,27 +22379,21 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 21418 | | 22379 | |
| 21419 | bool is_comptime; | 22380 | bool is_comptime; |
| 21420 | if (!ir_resolve_comptime(ira, switch_br_instruction->is_comptime->child, &is_comptime)) | 22381 | if (!ir_resolve_comptime(ira, switch_br_instruction->is_comptime->child, &is_comptime)) |
| 21421 | return ira->codegen->invalid_instruction; | 22382 | return ira->codegen->invalid_inst_gen; |
| 21422 | | 22383 | |
| 21423 | if (is_comptime || instr_is_comptime(target_value)) { | 22384 | if (is_comptime || instr_is_comptime(target_value)) { |
| 21424 | ZigValue *target_val = ir_resolve_const(ira, target_value, UndefBad); | 22385 | ZigValue *target_val = ir_resolve_const(ira, target_value, UndefBad); |
| 21425 | if (!target_val) | 22386 | if (!target_val) |
| 21426 | return ir_unreach_error(ira); | 22387 | return ir_unreach_error(ira); |
| 21427 | | 22388 | |
| 21428 | IrBasicBlock *old_dest_block = switch_br_instruction->else_block; | 22389 | IrBasicBlockSrc *old_dest_block = switch_br_instruction->else_block; |
| 21429 | for (size_t i = 0; i < case_count; i += 1) { | 22390 | for (size_t i = 0; i < case_count; i += 1) { |
| 21430 | IrInstructionSwitchBrCase *old_case = &switch_br_instruction->cases[i]; | 22391 | IrInstSrcSwitchBrCase *old_case = &switch_br_instruction->cases[i]; |
| 21431 | IrInstruction *case_value = old_case->value->child; | 22392 | IrInstGen *case_value = old_case->value->child; |
| 21432 | if (type_is_invalid(case_value->value->type)) | 22393 | if (type_is_invalid(case_value->value->type)) |
| 21433 | return ir_unreach_error(ira); | 22394 | return ir_unreach_error(ira); |
| 21434 | | 22395 | |
| 21435 | if (case_value->value->type->id == ZigTypeIdEnum) { | 22396 | IrInstGen *casted_case_value = ir_implicit_cast(ira, case_value, target_value->value->type); |
| 21436 | case_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, case_value); | | |
| 21437 | if (type_is_invalid(case_value->value->type)) | | |
| 21438 | return ir_unreach_error(ira); | | |
| 21439 | } | | |
| 21440 | | | |
| 21441 | IrInstruction *casted_case_value = ir_implicit_cast(ira, case_value, target_value->value->type); | | |
| 21442 | if (type_is_invalid(casted_case_value->value->type)) | 22397 | if (type_is_invalid(casted_case_value->value->type)) |
| 21443 | return ir_unreach_error(ira); | 22398 | return ir_unreach_error(ira); |
| 21444 | | 22399 | |
| ... | @@ -21453,23 +22408,20 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -21453,23 +22408,20 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 21453 | } | 22408 | } |
| 21454 | | 22409 | |
| 21455 | if (is_comptime || old_dest_block->ref_count == 1) { | 22410 | if (is_comptime || old_dest_block->ref_count == 1) { |
| 21456 | return ir_inline_bb(ira, &switch_br_instruction->base, old_dest_block); | 22411 | return ir_inline_bb(ira, &switch_br_instruction->base.base, old_dest_block); |
| 21457 | } else { | 22412 | } else { |
| 21458 | IrBasicBlock *new_dest_block = ir_get_new_bb(ira, old_dest_block, &switch_br_instruction->base); | 22413 | IrBasicBlockGen *new_dest_block = ir_get_new_bb(ira, old_dest_block, &switch_br_instruction->base.base); |
| 21459 | IrInstruction *result = ir_build_br(&ira->new_irb, | 22414 | IrInstGen *result = ir_build_br_gen(ira, &switch_br_instruction->base.base, new_dest_block); |
| 21460 | switch_br_instruction->base.scope, switch_br_instruction->base.source_node, | | |
| 21461 | new_dest_block, nullptr); | | |
| 21462 | result->value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 21463 | return ir_finish_anal(ira, result); | 22415 | return ir_finish_anal(ira, result); |
| 21464 | } | 22416 | } |
| 21465 | } | 22417 | } |
| 21466 | | 22418 | |
| 21467 | IrInstructionSwitchBrCase *cases = allocate<IrInstructionSwitchBrCase>(case_count); | 22419 | IrInstGenSwitchBrCase *cases = allocate<IrInstGenSwitchBrCase>(case_count); |
| 21468 | for (size_t i = 0; i < case_count; i += 1) { | 22420 | for (size_t i = 0; i < case_count; i += 1) { |
| 21469 | IrInstructionSwitchBrCase *old_case = &switch_br_instruction->cases[i]; | 22421 | IrInstSrcSwitchBrCase *old_case = &switch_br_instruction->cases[i]; |
| 21470 | IrInstructionSwitchBrCase *new_case = &cases[i]; | 22422 | IrInstGenSwitchBrCase *new_case = &cases[i]; |
| 21471 | new_case->block = ir_get_new_bb(ira, old_case->block, &switch_br_instruction->base); | 22423 | new_case->block = ir_get_new_bb(ira, old_case->block, &switch_br_instruction->base.base); |
| 21472 | new_case->value = ira->codegen->invalid_instruction; | 22424 | new_case->value = ira->codegen->invalid_inst_gen; |
| 21473 | | 22425 | |
| 21474 | // Calling ir_get_new_bb set the ref_instruction on the new basic block. | 22426 | // Calling ir_get_new_bb set the ref_instruction on the new basic block. |
| 21475 | // However a switch br may branch to the same basic block which would trigger an | 22427 | // However a switch br may branch to the same basic block which would trigger an |
| ... | @@ -21477,18 +22429,12 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -21477,18 +22429,12 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 21477 | // it back after the loop. | 22429 | // it back after the loop. |
| 21478 | new_case->block->ref_instruction = nullptr; | 22430 | new_case->block->ref_instruction = nullptr; |
| 21479 | | 22431 | |
| 21480 | IrInstruction *old_value = old_case->value; | 22432 | IrInstSrc *old_value = old_case->value; |
| 21481 | IrInstruction *new_value = old_value->child; | 22433 | IrInstGen *new_value = old_value->child; |
| 21482 | if (type_is_invalid(new_value->value->type)) | 22434 | if (type_is_invalid(new_value->value->type)) |
| 21483 | continue; | 22435 | continue; |
| 21484 | | 22436 | |
| 21485 | if (new_value->value->type->id == ZigTypeIdEnum) { | 22437 | IrInstGen *casted_new_value = ir_implicit_cast(ira, new_value, target_value->value->type); |
| 21486 | new_value = ir_analyze_union_tag(ira, &switch_br_instruction->base, new_value); | | |
| 21487 | if (type_is_invalid(new_value->value->type)) | | |
| 21488 | continue; | | |
| 21489 | } | | |
| 21490 | | | |
| 21491 | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, target_value->value->type); | | |
| 21492 | if (type_is_invalid(casted_new_value->value->type)) | 22438 | if (type_is_invalid(casted_new_value->value->type)) |
| 21493 | continue; | 22439 | continue; |
| 21494 | | 22440 | |
| ... | @@ -21499,47 +22445,45 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -21499,47 +22445,45 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 21499 | } | 22445 | } |
| 21500 | | 22446 | |
| 21501 | for (size_t i = 0; i < case_count; i += 1) { | 22447 | for (size_t i = 0; i < case_count; i += 1) { |
| 21502 | IrInstructionSwitchBrCase *new_case = &cases[i]; | 22448 | IrInstGenSwitchBrCase *new_case = &cases[i]; |
| 21503 | if (new_case->value == ira->codegen->invalid_instruction) | 22449 | if (type_is_invalid(new_case->value->value->type)) |
| 21504 | return ir_unreach_error(ira); | 22450 | return ir_unreach_error(ira); |
| 21505 | new_case->block->ref_instruction = &switch_br_instruction->base; | 22451 | new_case->block->ref_instruction = &switch_br_instruction->base.base; |
| 21506 | } | 22452 | } |
| 21507 | | 22453 | |
| 21508 | IrBasicBlock *new_else_block = ir_get_new_bb(ira, switch_br_instruction->else_block, &switch_br_instruction->base); | 22454 | IrBasicBlockGen *new_else_block = ir_get_new_bb(ira, switch_br_instruction->else_block, &switch_br_instruction->base.base); |
| 21509 | IrInstructionSwitchBr *switch_br = ir_build_switch_br(&ira->new_irb, | 22455 | IrInstGenSwitchBr *switch_br = ir_build_switch_br_gen(ira, &switch_br_instruction->base.base, |
| 21510 | switch_br_instruction->base.scope, switch_br_instruction->base.source_node, | 22456 | target_value, new_else_block, case_count, cases); |
| 21511 | target_value, new_else_block, case_count, cases, nullptr, nullptr); | | |
| 21512 | switch_br->base.value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 21513 | return ir_finish_anal(ira, &switch_br->base); | 22457 | return ir_finish_anal(ira, &switch_br->base); |
| 21514 | } | 22458 | } |
| 21515 | | 22459 | |
| 21516 | static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | 22460 | static IrInstGen *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 21517 | IrInstructionSwitchTarget *switch_target_instruction) | 22461 | IrInstSrcSwitchTarget *switch_target_instruction) |
| 21518 | { | 22462 | { |
| 21519 | Error err; | 22463 | Error err; |
| 21520 | IrInstruction *target_value_ptr = switch_target_instruction->target_value_ptr->child; | 22464 | IrInstGen *target_value_ptr = switch_target_instruction->target_value_ptr->child; |
| 21521 | if (type_is_invalid(target_value_ptr->value->type)) | 22465 | if (type_is_invalid(target_value_ptr->value->type)) |
| 21522 | return ira->codegen->invalid_instruction; | 22466 | return ira->codegen->invalid_inst_gen; |
| 21523 | | 22467 | |
| 21524 | if (target_value_ptr->value->type->id == ZigTypeIdMetaType) { | 22468 | if (target_value_ptr->value->type->id == ZigTypeIdMetaType) { |
| 21525 | assert(instr_is_comptime(target_value_ptr)); | 22469 | assert(instr_is_comptime(target_value_ptr)); |
| 21526 | ZigType *ptr_type = target_value_ptr->value->data.x_type; | 22470 | ZigType *ptr_type = target_value_ptr->value->data.x_type; |
| 21527 | assert(ptr_type->id == ZigTypeIdPointer); | 22471 | assert(ptr_type->id == ZigTypeIdPointer); |
| 21528 | return ir_const_type(ira, &switch_target_instruction->base, ptr_type->data.pointer.child_type); | 22472 | return ir_const_type(ira, &switch_target_instruction->base.base, ptr_type->data.pointer.child_type); |
| 21529 | } | 22473 | } |
| 21530 | | 22474 | |
| 21531 | ZigType *target_type = target_value_ptr->value->type->data.pointer.child_type; | 22475 | ZigType *target_type = target_value_ptr->value->type->data.pointer.child_type; |
| 21532 | ZigValue *pointee_val = nullptr; | 22476 | ZigValue *pointee_val = nullptr; |
| 21533 | if (instr_is_comptime(target_value_ptr) && target_value_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 22477 | if (instr_is_comptime(target_value_ptr) && target_value_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 21534 | pointee_val = const_ptr_pointee(ira, ira->codegen, target_value_ptr->value, target_value_ptr->source_node); | 22478 | pointee_val = const_ptr_pointee(ira, ira->codegen, target_value_ptr->value, target_value_ptr->base.source_node); |
| 21535 | if (pointee_val == nullptr) | 22479 | if (pointee_val == nullptr) |
| 21536 | return ira->codegen->invalid_instruction; | 22480 | return ira->codegen->invalid_inst_gen; |
| 21537 | | 22481 | |
| 21538 | if (pointee_val->special == ConstValSpecialRuntime) | 22482 | if (pointee_val->special == ConstValSpecialRuntime) |
| 21539 | pointee_val = nullptr; | 22483 | pointee_val = nullptr; |
| 21540 | } | 22484 | } |
| 21541 | if ((err = type_resolve(ira->codegen, target_type, ResolveStatusSizeKnown))) | 22485 | if ((err = type_resolve(ira->codegen, target_type, ResolveStatusSizeKnown))) |
| 21542 | return ira->codegen->invalid_instruction; | 22486 | return ira->codegen->invalid_inst_gen; |
| 21543 | | 22487 | |
| 21544 | switch (target_type->id) { | 22488 | switch (target_type->id) { |
| 21545 | case ZigTypeIdInvalid: | 22489 | case ZigTypeIdInvalid: |
| ... | @@ -21556,13 +22500,13 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -21556,13 +22500,13 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 21556 | case ZigTypeIdFn: | 22500 | case ZigTypeIdFn: |
| 21557 | case ZigTypeIdErrorSet: { | 22501 | case ZigTypeIdErrorSet: { |
| 21558 | if (pointee_val) { | 22502 | if (pointee_val) { |
| 21559 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, nullptr); | 22503 | IrInstGen *result = ir_const(ira, &switch_target_instruction->base.base, nullptr); |
| 21560 | copy_const_val(result->value, pointee_val); | 22504 | copy_const_val(result->value, pointee_val); |
| 21561 | result->value->type = target_type; | 22505 | result->value->type = target_type; |
| 21562 | return result; | 22506 | return result; |
| 21563 | } | 22507 | } |
| 21564 | | 22508 | |
| 21565 | IrInstruction *result = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); | 22509 | IrInstGen *result = ir_get_deref(ira, &switch_target_instruction->base.base, target_value_ptr, nullptr); |
| 21566 | result->value->type = target_type; | 22510 | result->value->type = target_type; |
| 21567 | return result; | 22511 | return result; |
| 21568 | } | 22512 | } |
| ... | @@ -21571,52 +22515,49 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -21571,52 +22515,49 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 21571 | if (!decl_node->data.container_decl.auto_enum && | 22515 | if (!decl_node->data.container_decl.auto_enum && |
| 21572 | decl_node->data.container_decl.init_arg_expr == nullptr) | 22516 | decl_node->data.container_decl.init_arg_expr == nullptr) |
| 21573 | { | 22517 | { |
| 21574 | ErrorMsg *msg = ir_add_error(ira, target_value_ptr, | 22518 | ErrorMsg *msg = ir_add_error(ira, &target_value_ptr->base, |
| 21575 | buf_sprintf("switch on union which has no attached enum")); | 22519 | buf_sprintf("switch on union which has no attached enum")); |
| 21576 | add_error_note(ira->codegen, msg, decl_node, | 22520 | add_error_note(ira->codegen, msg, decl_node, |
| 21577 | buf_sprintf("consider 'union(enum)' here")); | 22521 | buf_sprintf("consider 'union(enum)' here")); |
| 21578 | return ira->codegen->invalid_instruction; | 22522 | return ira->codegen->invalid_inst_gen; |
| 21579 | } | 22523 | } |
| 21580 | ZigType *tag_type = target_type->data.unionation.tag_type; | 22524 | ZigType *tag_type = target_type->data.unionation.tag_type; |
| 21581 | assert(tag_type != nullptr); | 22525 | assert(tag_type != nullptr); |
| 21582 | assert(tag_type->id == ZigTypeIdEnum); | 22526 | assert(tag_type->id == ZigTypeIdEnum); |
| 21583 | if (pointee_val) { | 22527 | if (pointee_val) { |
| 21584 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, tag_type); | 22528 | IrInstGen *result = ir_const(ira, &switch_target_instruction->base.base, tag_type); |
| 21585 | bigint_init_bigint(&result->value->data.x_enum_tag, &pointee_val->data.x_union.tag); | 22529 | bigint_init_bigint(&result->value->data.x_enum_tag, &pointee_val->data.x_union.tag); |
| 21586 | return result; | 22530 | return result; |
| 21587 | } | 22531 | } |
| 21588 | if (tag_type->data.enumeration.src_field_count == 1) { | 22532 | if (tag_type->data.enumeration.src_field_count == 1) { |
| 21589 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, tag_type); | 22533 | IrInstGen *result = ir_const(ira, &switch_target_instruction->base.base, tag_type); |
| 21590 | TypeEnumField *only_field = &tag_type->data.enumeration.fields[0]; | 22534 | TypeEnumField *only_field = &tag_type->data.enumeration.fields[0]; |
| 21591 | bigint_init_bigint(&result->value->data.x_enum_tag, &only_field->value); | 22535 | bigint_init_bigint(&result->value->data.x_enum_tag, &only_field->value); |
| 21592 | return result; | 22536 | return result; |
| 21593 | } | 22537 | } |
| 21594 | | 22538 | |
| 21595 | IrInstruction *union_value = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); | 22539 | IrInstGen *union_value = ir_get_deref(ira, &switch_target_instruction->base.base, target_value_ptr, nullptr); |
| 21596 | union_value->value->type = target_type; | 22540 | union_value->value->type = target_type; |
| 21597 | | 22541 | |
| 21598 | IrInstruction *union_tag_inst = ir_build_union_tag(&ira->new_irb, switch_target_instruction->base.scope, | 22542 | return ir_build_union_tag(ira, &switch_target_instruction->base.base, union_value, tag_type); |
| 21599 | switch_target_instruction->base.source_node, union_value); | | |
| 21600 | union_tag_inst->value->type = tag_type; | | |
| 21601 | return union_tag_inst; | | |
| 21602 | } | 22543 | } |
| 21603 | case ZigTypeIdEnum: { | 22544 | case ZigTypeIdEnum: { |
| 21604 | if ((err = type_resolve(ira->codegen, target_type, ResolveStatusZeroBitsKnown))) | 22545 | if ((err = type_resolve(ira->codegen, target_type, ResolveStatusZeroBitsKnown))) |
| 21605 | return ira->codegen->invalid_instruction; | 22546 | return ira->codegen->invalid_inst_gen; |
| 21606 | if (target_type->data.enumeration.src_field_count < 2) { | 22547 | if (target_type->data.enumeration.src_field_count == 1) { |
| 21607 | TypeEnumField *only_field = &target_type->data.enumeration.fields[0]; | 22548 | TypeEnumField *only_field = &target_type->data.enumeration.fields[0]; |
| 21608 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, target_type); | 22549 | IrInstGen *result = ir_const(ira, &switch_target_instruction->base.base, target_type); |
| 21609 | bigint_init_bigint(&result->value->data.x_enum_tag, &only_field->value); | 22550 | bigint_init_bigint(&result->value->data.x_enum_tag, &only_field->value); |
| 21610 | return result; | 22551 | return result; |
| 21611 | } | 22552 | } |
| 21612 | | 22553 | |
| 21613 | if (pointee_val) { | 22554 | if (pointee_val) { |
| 21614 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, target_type); | 22555 | IrInstGen *result = ir_const(ira, &switch_target_instruction->base.base, target_type); |
| 21615 | bigint_init_bigint(&result->value->data.x_enum_tag, &pointee_val->data.x_enum_tag); | 22556 | bigint_init_bigint(&result->value->data.x_enum_tag, &pointee_val->data.x_enum_tag); |
| 21616 | return result; | 22557 | return result; |
| 21617 | } | 22558 | } |
| 21618 | | 22559 | |
| 21619 | IrInstruction *enum_value = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); | 22560 | IrInstGen *enum_value = ir_get_deref(ira, &switch_target_instruction->base.base, target_value_ptr, nullptr); |
| 21620 | enum_value->value->type = target_type; | 22561 | enum_value->value->type = target_type; |
| 21621 | return enum_value; | 22562 | return enum_value; |
| 21622 | } | 22563 | } |
| ... | @@ -21632,17 +22573,17 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -21632,17 +22573,17 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 21632 | case ZigTypeIdVector: | 22573 | case ZigTypeIdVector: |
| 21633 | case ZigTypeIdFnFrame: | 22574 | case ZigTypeIdFnFrame: |
| 21634 | case ZigTypeIdAnyFrame: | 22575 | case ZigTypeIdAnyFrame: |
| 21635 | ir_add_error(ira, &switch_target_instruction->base, | 22576 | ir_add_error(ira, &switch_target_instruction->base.base, |
| 21636 | buf_sprintf("invalid switch target type '%s'", buf_ptr(&target_type->name))); | 22577 | buf_sprintf("invalid switch target type '%s'", buf_ptr(&target_type->name))); |
| 21637 | return ira->codegen->invalid_instruction; | 22578 | return ira->codegen->invalid_inst_gen; |
| 21638 | } | 22579 | } |
| 21639 | zig_unreachable(); | 22580 | zig_unreachable(); |
| 21640 | } | 22581 | } |
| 21641 | | 22582 | |
| 21642 | static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstructionSwitchVar *instruction) { | 22583 | static IrInstGen *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstSrcSwitchVar *instruction) { |
| 21643 | IrInstruction *target_value_ptr = instruction->target_value_ptr->child; | 22584 | IrInstGen *target_value_ptr = instruction->target_value_ptr->child; |
| 21644 | if (type_is_invalid(target_value_ptr->value->type)) | 22585 | if (type_is_invalid(target_value_ptr->value->type)) |
| 21645 | return ira->codegen->invalid_instruction; | 22586 | return ira->codegen->invalid_inst_gen; |
| 21646 | | 22587 | |
| 21647 | ZigType *ref_type = target_value_ptr->value->type; | 22588 | ZigType *ref_type = target_value_ptr->value->type; |
| 21648 | assert(ref_type->id == ZigTypeIdPointer); | 22589 | assert(ref_type->id == ZigTypeIdPointer); |
| ... | @@ -21653,62 +22594,62 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -21653,62 +22594,62 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 21653 | assert(enum_type->id == ZigTypeIdEnum); | 22594 | assert(enum_type->id == ZigTypeIdEnum); |
| 21654 | assert(instruction->prongs_len > 0); | 22595 | assert(instruction->prongs_len > 0); |
| 21655 | | 22596 | |
| 21656 | IrInstruction *first_prong_value = instruction->prongs_ptr[0]->child; | 22597 | IrInstGen *first_prong_value = instruction->prongs_ptr[0]->child; |
| 21657 | if (type_is_invalid(first_prong_value->value->type)) | 22598 | if (type_is_invalid(first_prong_value->value->type)) |
| 21658 | return ira->codegen->invalid_instruction; | 22599 | return ira->codegen->invalid_inst_gen; |
| 21659 | | 22600 | |
| 21660 | IrInstruction *first_casted_prong_value = ir_implicit_cast(ira, first_prong_value, enum_type); | 22601 | IrInstGen *first_casted_prong_value = ir_implicit_cast(ira, first_prong_value, enum_type); |
| 21661 | if (type_is_invalid(first_casted_prong_value->value->type)) | 22602 | if (type_is_invalid(first_casted_prong_value->value->type)) |
| 21662 | return ira->codegen->invalid_instruction; | 22603 | return ira->codegen->invalid_inst_gen; |
| 21663 | | 22604 | |
| 21664 | ZigValue *first_prong_val = ir_resolve_const(ira, first_casted_prong_value, UndefBad); | 22605 | ZigValue *first_prong_val = ir_resolve_const(ira, first_casted_prong_value, UndefBad); |
| 21665 | if (first_prong_val == nullptr) | 22606 | if (first_prong_val == nullptr) |
| 21666 | return ira->codegen->invalid_instruction; | 22607 | return ira->codegen->invalid_inst_gen; |
| 21667 | | 22608 | |
| 21668 | TypeUnionField *first_field = find_union_field_by_tag(target_type, &first_prong_val->data.x_enum_tag); | 22609 | TypeUnionField *first_field = find_union_field_by_tag(target_type, &first_prong_val->data.x_enum_tag); |
| 21669 | | 22610 | |
| 21670 | ErrorMsg *invalid_payload_msg = nullptr; | 22611 | ErrorMsg *invalid_payload_msg = nullptr; |
| 21671 | for (size_t prong_i = 1; prong_i < instruction->prongs_len; prong_i += 1) { | 22612 | for (size_t prong_i = 1; prong_i < instruction->prongs_len; prong_i += 1) { |
| 21672 | IrInstruction *this_prong_inst = instruction->prongs_ptr[prong_i]->child; | 22613 | IrInstGen *this_prong_inst = instruction->prongs_ptr[prong_i]->child; |
| 21673 | if (type_is_invalid(this_prong_inst->value->type)) | 22614 | if (type_is_invalid(this_prong_inst->value->type)) |
| 21674 | return ira->codegen->invalid_instruction; | 22615 | return ira->codegen->invalid_inst_gen; |
| 21675 | | 22616 | |
| 21676 | IrInstruction *this_casted_prong_value = ir_implicit_cast(ira, this_prong_inst, enum_type); | 22617 | IrInstGen *this_casted_prong_value = ir_implicit_cast(ira, this_prong_inst, enum_type); |
| 21677 | if (type_is_invalid(this_casted_prong_value->value->type)) | 22618 | if (type_is_invalid(this_casted_prong_value->value->type)) |
| 21678 | return ira->codegen->invalid_instruction; | 22619 | return ira->codegen->invalid_inst_gen; |
| 21679 | | 22620 | |
| 21680 | ZigValue *this_prong = ir_resolve_const(ira, this_casted_prong_value, UndefBad); | 22621 | ZigValue *this_prong = ir_resolve_const(ira, this_casted_prong_value, UndefBad); |
| 21681 | if (this_prong == nullptr) | 22622 | if (this_prong == nullptr) |
| 21682 | return ira->codegen->invalid_instruction; | 22623 | return ira->codegen->invalid_inst_gen; |
| 21683 | | 22624 | |
| 21684 | TypeUnionField *payload_field = find_union_field_by_tag(target_type, &this_prong->data.x_enum_tag); | 22625 | TypeUnionField *payload_field = find_union_field_by_tag(target_type, &this_prong->data.x_enum_tag); |
| 21685 | ZigType *payload_type = payload_field->type_entry; | 22626 | ZigType *payload_type = payload_field->type_entry; |
| 21686 | if (first_field->type_entry != payload_type) { | 22627 | if (first_field->type_entry != payload_type) { |
| 21687 | if (invalid_payload_msg == nullptr) { | 22628 | if (invalid_payload_msg == nullptr) { |
| 21688 | invalid_payload_msg = ir_add_error(ira, &instruction->base, | 22629 | invalid_payload_msg = ir_add_error(ira, &instruction->base.base, |
| 21689 | buf_sprintf("capture group with incompatible types")); | 22630 | buf_sprintf("capture group with incompatible types")); |
| 21690 | add_error_note(ira->codegen, invalid_payload_msg, first_prong_value->source_node, | 22631 | add_error_note(ira->codegen, invalid_payload_msg, first_prong_value->base.source_node, |
| 21691 | buf_sprintf("type '%s' here", buf_ptr(&first_field->type_entry->name))); | 22632 | buf_sprintf("type '%s' here", buf_ptr(&first_field->type_entry->name))); |
| 21692 | } | 22633 | } |
| 21693 | add_error_note(ira->codegen, invalid_payload_msg, this_prong_inst->source_node, | 22634 | add_error_note(ira->codegen, invalid_payload_msg, this_prong_inst->base.source_node, |
| 21694 | buf_sprintf("type '%s' here", buf_ptr(&payload_field->type_entry->name))); | 22635 | buf_sprintf("type '%s' here", buf_ptr(&payload_field->type_entry->name))); |
| 21695 | } | 22636 | } |
| 21696 | } | 22637 | } |
| 21697 | | 22638 | |
| 21698 | if (invalid_payload_msg != nullptr) { | 22639 | if (invalid_payload_msg != nullptr) { |
| 21699 | return ira->codegen->invalid_instruction; | 22640 | return ira->codegen->invalid_inst_gen; |
| 21700 | } | 22641 | } |
| 21701 | | 22642 | |
| 21702 | if (instr_is_comptime(target_value_ptr)) { | 22643 | if (instr_is_comptime(target_value_ptr)) { |
| 21703 | ZigValue *target_val_ptr = ir_resolve_const(ira, target_value_ptr, UndefBad); | 22644 | ZigValue *target_val_ptr = ir_resolve_const(ira, target_value_ptr, UndefBad); |
| 21704 | if (!target_value_ptr) | 22645 | if (!target_value_ptr) |
| 21705 | return ira->codegen->invalid_instruction; | 22646 | return ira->codegen->invalid_inst_gen; |
| 21706 | | 22647 | |
| 21707 | ZigValue *pointee_val = const_ptr_pointee(ira, ira->codegen, target_val_ptr, instruction->base.source_node); | 22648 | ZigValue *pointee_val = const_ptr_pointee(ira, ira->codegen, target_val_ptr, instruction->base.base.source_node); |
| 21708 | if (pointee_val == nullptr) | 22649 | if (pointee_val == nullptr) |
| 21709 | return ira->codegen->invalid_instruction; | 22650 | return ira->codegen->invalid_inst_gen; |
| 21710 | | 22651 | |
| 21711 | IrInstruction *result = ir_const(ira, &instruction->base, | 22652 | IrInstGen *result = ir_const(ira, &instruction->base.base, |
| 21712 | get_pointer_to_type(ira->codegen, first_field->type_entry, | 22653 | get_pointer_to_type(ira->codegen, first_field->type_entry, |
| 21713 | target_val_ptr->type->data.pointer.is_const)); | 22654 | target_val_ptr->type->data.pointer.is_const)); |
| 21714 | ZigValue *out_val = result->value; | 22655 | ZigValue *out_val = result->value; |
| ... | @@ -21718,11 +22659,10 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -21718,11 +22659,10 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 21718 | return result; | 22659 | return result; |
| 21719 | } | 22660 | } |
| 21720 | | 22661 | |
| 21721 | IrInstruction *result = ir_build_union_field_ptr(&ira->new_irb, | 22662 | ZigType *result_type = get_pointer_to_type(ira->codegen, first_field->type_entry, |
| 21722 | instruction->base.scope, instruction->base.source_node, target_value_ptr, first_field, false, false); | | |
| 21723 | result->value->type = get_pointer_to_type(ira->codegen, first_field->type_entry, | | |
| 21724 | target_value_ptr->value->type->data.pointer.is_const); | 22663 | target_value_ptr->value->type->data.pointer.is_const); |
| 21725 | return result; | 22664 | return ir_build_union_field_ptr(ira, &instruction->base.base, target_value_ptr, first_field, |
| | 22665 | false, false, result_type); |
| 21726 | } else if (target_type->id == ZigTypeIdErrorSet) { | 22666 | } else if (target_type->id == ZigTypeIdErrorSet) { |
| 21727 | // construct an error set from the prong values | 22667 | // construct an error set from the prong values |
| 21728 | ZigType *err_set_type = new_type_table_entry(ZigTypeIdErrorSet); | 22668 | ZigType *err_set_type = new_type_table_entry(ZigTypeIdErrorSet); |
| ... | @@ -21735,7 +22675,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -21735,7 +22675,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 21735 | for (size_t i = 0; i < instruction->prongs_len; i += 1) { | 22675 | for (size_t i = 0; i < instruction->prongs_len; i += 1) { |
| 21736 | ErrorTableEntry *err = ir_resolve_error(ira, instruction->prongs_ptr[i]->child); | 22676 | ErrorTableEntry *err = ir_resolve_error(ira, instruction->prongs_ptr[i]->child); |
| 21737 | if (err == nullptr) | 22677 | if (err == nullptr) |
| 21738 | return ira->codegen->invalid_instruction; | 22678 | return ira->codegen->invalid_inst_gen; |
| 21739 | error_list.append(err); | 22679 | error_list.append(err); |
| 21740 | buf_appendf(&err_set_type->name, "%s,", buf_ptr(&err->name)); | 22680 | buf_appendf(&err_set_type->name, "%s,", buf_ptr(&err->name)); |
| 21741 | } | 22681 | } |
| ... | @@ -21751,29 +22691,29 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -21751,29 +22691,29 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 21751 | ref_type->data.pointer.explicit_alignment, | 22691 | ref_type->data.pointer.explicit_alignment, |
| 21752 | ref_type->data.pointer.bit_offset_in_host, ref_type->data.pointer.host_int_bytes, | 22692 | ref_type->data.pointer.bit_offset_in_host, ref_type->data.pointer.host_int_bytes, |
| 21753 | ref_type->data.pointer.allow_zero); | 22693 | ref_type->data.pointer.allow_zero); |
| 21754 | return ir_analyze_ptr_cast(ira, &instruction->base, target_value_ptr, new_target_value_ptr_type, | 22694 | return ir_analyze_ptr_cast(ira, &instruction->base.base, target_value_ptr, new_target_value_ptr_type, |
| 21755 | &instruction->base, false); | 22695 | &instruction->base.base, false); |
| 21756 | } else { | 22696 | } else { |
| 21757 | ir_add_error(ira, &instruction->base, | 22697 | ir_add_error(ira, &instruction->base.base, |
| 21758 | buf_sprintf("switch on type '%s' provides no expression parameter", buf_ptr(&target_type->name))); | 22698 | buf_sprintf("switch on type '%s' provides no expression parameter", buf_ptr(&target_type->name))); |
| 21759 | return ira->codegen->invalid_instruction; | 22699 | return ira->codegen->invalid_inst_gen; |
| 21760 | } | 22700 | } |
| 21761 | } | 22701 | } |
| 21762 | | 22702 | |
| 21763 | static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, | 22703 | static IrInstGen *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, |
| 21764 | IrInstructionSwitchElseVar *instruction) | 22704 | IrInstSrcSwitchElseVar *instruction) |
| 21765 | { | 22705 | { |
| 21766 | IrInstruction *target_value_ptr = instruction->target_value_ptr->child; | 22706 | IrInstGen *target_value_ptr = instruction->target_value_ptr->child; |
| 21767 | if (type_is_invalid(target_value_ptr->value->type)) | 22707 | if (type_is_invalid(target_value_ptr->value->type)) |
| 21768 | return ira->codegen->invalid_instruction; | 22708 | return ira->codegen->invalid_inst_gen; |
| 21769 | | 22709 | |
| 21770 | ZigType *ref_type = target_value_ptr->value->type; | 22710 | ZigType *ref_type = target_value_ptr->value->type; |
| 21771 | assert(ref_type->id == ZigTypeIdPointer); | 22711 | assert(ref_type->id == ZigTypeIdPointer); |
| 21772 | ZigType *target_type = target_value_ptr->value->type->data.pointer.child_type; | 22712 | ZigType *target_type = target_value_ptr->value->type->data.pointer.child_type; |
| 21773 | if (target_type->id == ZigTypeIdErrorSet) { | 22713 | if (target_type->id == ZigTypeIdErrorSet) { |
| 21774 | // make a new set that has the other cases removed | 22714 | // make a new set that has the other cases removed |
| 21775 | if (!resolve_inferred_error_set(ira->codegen, target_type, instruction->base.source_node)) { | 22715 | if (!resolve_inferred_error_set(ira->codegen, target_type, instruction->base.base.source_node)) { |
| 21776 | return ira->codegen->invalid_instruction; | 22716 | return ira->codegen->invalid_inst_gen; |
| 21777 | } | 22717 | } |
| 21778 | if (type_is_global_error_set(target_type)) { | 22718 | if (type_is_global_error_set(target_type)) { |
| 21779 | // the type of the else capture variable still has to be the global error set. | 22719 | // the type of the else capture variable still has to be the global error set. |
| ... | @@ -21783,17 +22723,17 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, | ... | @@ -21783,17 +22723,17 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, |
| 21783 | // Make note of the errors handled by other cases | 22723 | // Make note of the errors handled by other cases |
| 21784 | ErrorTableEntry **errors = allocate<ErrorTableEntry *>(ira->codegen->errors_by_index.length); | 22724 | ErrorTableEntry **errors = allocate<ErrorTableEntry *>(ira->codegen->errors_by_index.length); |
| 21785 | for (size_t case_i = 0; case_i < instruction->switch_br->case_count; case_i += 1) { | 22725 | for (size_t case_i = 0; case_i < instruction->switch_br->case_count; case_i += 1) { |
| 21786 | IrInstructionSwitchBrCase *br_case = &instruction->switch_br->cases[case_i]; | 22726 | IrInstSrcSwitchBrCase *br_case = &instruction->switch_br->cases[case_i]; |
| 21787 | IrInstruction *case_expr = br_case->value->child; | 22727 | IrInstGen *case_expr = br_case->value->child; |
| 21788 | if (case_expr->value->type->id == ZigTypeIdErrorSet) { | 22728 | if (case_expr->value->type->id == ZigTypeIdErrorSet) { |
| 21789 | ErrorTableEntry *err = ir_resolve_error(ira, case_expr); | 22729 | ErrorTableEntry *err = ir_resolve_error(ira, case_expr); |
| 21790 | if (err == nullptr) | 22730 | if (err == nullptr) |
| 21791 | return ira->codegen->invalid_instruction; | 22731 | return ira->codegen->invalid_inst_gen; |
| 21792 | errors[err->value] = err; | 22732 | errors[err->value] = err; |
| 21793 | } else if (case_expr->value->type->id == ZigTypeIdMetaType) { | 22733 | } else if (case_expr->value->type->id == ZigTypeIdMetaType) { |
| 21794 | ZigType *err_set_type = ir_resolve_type(ira, case_expr); | 22734 | ZigType *err_set_type = ir_resolve_type(ira, case_expr); |
| 21795 | if (type_is_invalid(err_set_type)) | 22735 | if (type_is_invalid(err_set_type)) |
| 21796 | return ira->codegen->invalid_instruction; | 22736 | return ira->codegen->invalid_inst_gen; |
| 21797 | populate_error_set_table(errors, err_set_type); | 22737 | populate_error_set_table(errors, err_set_type); |
| 21798 | } else { | 22738 | } else { |
| 21799 | zig_unreachable(); | 22739 | zig_unreachable(); |
| ... | @@ -21832,27 +22772,22 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, | ... | @@ -21832,27 +22772,22 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, |
| 21832 | ref_type->data.pointer.explicit_alignment, | 22772 | ref_type->data.pointer.explicit_alignment, |
| 21833 | ref_type->data.pointer.bit_offset_in_host, ref_type->data.pointer.host_int_bytes, | 22773 | ref_type->data.pointer.bit_offset_in_host, ref_type->data.pointer.host_int_bytes, |
| 21834 | ref_type->data.pointer.allow_zero); | 22774 | ref_type->data.pointer.allow_zero); |
| 21835 | return ir_analyze_ptr_cast(ira, &instruction->base, target_value_ptr, new_target_value_ptr_type, | 22775 | return ir_analyze_ptr_cast(ira, &instruction->base.base, target_value_ptr, new_target_value_ptr_type, |
| 21836 | &instruction->base, false); | 22776 | &instruction->base.base, false); |
| 21837 | } | 22777 | } |
| 21838 | | 22778 | |
| 21839 | return target_value_ptr; | 22779 | return target_value_ptr; |
| 21840 | } | 22780 | } |
| 21841 | | 22781 | |
| 21842 | static IrInstruction *ir_analyze_instruction_union_tag(IrAnalyze *ira, IrInstructionUnionTag *instruction) { | 22782 | static IrInstGen *ir_analyze_instruction_import(IrAnalyze *ira, IrInstSrcImport *import_instruction) { |
| 21843 | IrInstruction *value = instruction->value->child; | | |
| 21844 | return ir_analyze_union_tag(ira, &instruction->base, value); | | |
| 21845 | } | | |
| 21846 | | | |
| 21847 | static IrInstruction *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructionImport *import_instruction) { | | |
| 21848 | Error err; | 22783 | Error err; |
| 21849 | | 22784 | |
| 21850 | IrInstruction *name_value = import_instruction->name->child; | 22785 | IrInstGen *name_value = import_instruction->name->child; |
| 21851 | Buf *import_target_str = ir_resolve_str(ira, name_value); | 22786 | Buf *import_target_str = ir_resolve_str(ira, name_value); |
| 21852 | if (!import_target_str) | 22787 | if (!import_target_str) |
| 21853 | return ira->codegen->invalid_instruction; | 22788 | return ira->codegen->invalid_inst_gen; |
| 21854 | | 22789 | |
| 21855 | AstNode *source_node = import_instruction->base.source_node; | 22790 | AstNode *source_node = import_instruction->base.base.source_node; |
| 21856 | ZigType *import = source_node->owner; | 22791 | ZigType *import = source_node->owner; |
| 21857 | | 22792 | |
| 21858 | ZigType *target_import; | 22793 | ZigType *target_import; |
| ... | @@ -21865,48 +22800,48 @@ static IrInstruction *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructio | ... | @@ -21865,48 +22800,48 @@ static IrInstruction *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructio |
| 21865 | ir_add_error_node(ira, source_node, | 22800 | ir_add_error_node(ira, source_node, |
| 21866 | buf_sprintf("import of file outside package path: '%s'", | 22801 | buf_sprintf("import of file outside package path: '%s'", |
| 21867 | buf_ptr(import_target_path))); | 22802 | buf_ptr(import_target_path))); |
| 21868 | return ira->codegen->invalid_instruction; | 22803 | return ira->codegen->invalid_inst_gen; |
| 21869 | } else if (err == ErrorFileNotFound) { | 22804 | } else if (err == ErrorFileNotFound) { |
| 21870 | ir_add_error_node(ira, source_node, | 22805 | ir_add_error_node(ira, source_node, |
| 21871 | buf_sprintf("unable to find '%s'", buf_ptr(import_target_path))); | 22806 | buf_sprintf("unable to find '%s'", buf_ptr(import_target_path))); |
| 21872 | return ira->codegen->invalid_instruction; | 22807 | return ira->codegen->invalid_inst_gen; |
| 21873 | } else { | 22808 | } else { |
| 21874 | ir_add_error_node(ira, source_node, | 22809 | ir_add_error_node(ira, source_node, |
| 21875 | buf_sprintf("unable to open '%s': %s", buf_ptr(&full_path), err_str(err))); | 22810 | buf_sprintf("unable to open '%s': %s", buf_ptr(&full_path), err_str(err))); |
| 21876 | return ira->codegen->invalid_instruction; | 22811 | return ira->codegen->invalid_inst_gen; |
| 21877 | } | 22812 | } |
| 21878 | } | 22813 | } |
| 21879 | | 22814 | |
| 21880 | return ir_const_type(ira, &import_instruction->base, target_import); | 22815 | return ir_const_type(ira, &import_instruction->base.base, target_import); |
| 21881 | } | 22816 | } |
| 21882 | | 22817 | |
| 21883 | static IrInstruction *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstructionRef *ref_instruction) { | 22818 | static IrInstGen *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstSrcRef *ref_instruction) { |
| 21884 | IrInstruction *value = ref_instruction->value->child; | 22819 | IrInstGen *value = ref_instruction->value->child; |
| 21885 | if (type_is_invalid(value->value->type)) | 22820 | if (type_is_invalid(value->value->type)) |
| 21886 | return ira->codegen->invalid_instruction; | 22821 | return ira->codegen->invalid_inst_gen; |
| 21887 | return ir_get_ref(ira, &ref_instruction->base, value, ref_instruction->is_const, ref_instruction->is_volatile); | 22822 | return ir_get_ref(ira, &ref_instruction->base.base, value, ref_instruction->is_const, ref_instruction->is_volatile); |
| 21888 | } | 22823 | } |
| 21889 | | 22824 | |
| 21890 | static IrInstruction *ir_analyze_union_init(IrAnalyze *ira, IrInstruction *source_instruction, | 22825 | static IrInstGen *ir_analyze_union_init(IrAnalyze *ira, IrInst* source_instruction, |
| 21891 | AstNode *field_source_node, ZigType *union_type, Buf *field_name, IrInstruction *field_result_loc, | 22826 | AstNode *field_source_node, ZigType *union_type, Buf *field_name, IrInstGen *field_result_loc, |
| 21892 | IrInstruction *result_loc) | 22827 | IrInstGen *result_loc) |
| 21893 | { | 22828 | { |
| 21894 | Error err; | 22829 | Error err; |
| 21895 | assert(union_type->id == ZigTypeIdUnion); | 22830 | assert(union_type->id == ZigTypeIdUnion); |
| 21896 | | 22831 | |
| 21897 | if ((err = type_resolve(ira->codegen, union_type, ResolveStatusSizeKnown))) | 22832 | if ((err = type_resolve(ira->codegen, union_type, ResolveStatusSizeKnown))) |
| 21898 | return ira->codegen->invalid_instruction; | 22833 | return ira->codegen->invalid_inst_gen; |
| 21899 | | 22834 | |
| 21900 | TypeUnionField *type_field = find_union_type_field(union_type, field_name); | 22835 | TypeUnionField *type_field = find_union_type_field(union_type, field_name); |
| 21901 | if (type_field == nullptr) { | 22836 | if (type_field == nullptr) { |
| 21902 | ir_add_error_node(ira, field_source_node, | 22837 | ir_add_error_node(ira, field_source_node, |
| 21903 | buf_sprintf("no member named '%s' in union '%s'", | 22838 | buf_sprintf("no member named '%s' in union '%s'", |
| 21904 | buf_ptr(field_name), buf_ptr(&union_type->name))); | 22839 | buf_ptr(field_name), buf_ptr(&union_type->name))); |
| 21905 | return ira->codegen->invalid_instruction; | 22840 | return ira->codegen->invalid_inst_gen; |
| 21906 | } | 22841 | } |
| 21907 | | 22842 | |
| 21908 | if (type_is_invalid(type_field->type_entry)) | 22843 | if (type_is_invalid(type_field->type_entry)) |
| 21909 | return ira->codegen->invalid_instruction; | 22844 | return ira->codegen->invalid_inst_gen; |
| 21910 | | 22845 | |
| 21911 | if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) { | 22846 | if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) { |
| 21912 | if (instr_is_comptime(field_result_loc) && | 22847 | if (instr_is_comptime(field_result_loc) && |
| ... | @@ -21918,42 +22853,42 @@ static IrInstruction *ir_analyze_union_init(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -21918,42 +22853,42 @@ static IrInstruction *ir_analyze_union_init(IrAnalyze *ira, IrInstruction *sourc |
| 21918 | } | 22853 | } |
| 21919 | } | 22854 | } |
| 21920 | | 22855 | |
| 21921 | bool is_comptime = ir_should_inline(ira->new_irb.exec, source_instruction->scope) | 22856 | bool is_comptime = ir_should_inline(ira->old_irb.exec, source_instruction->scope) |
| 21922 | || type_requires_comptime(ira->codegen, union_type) == ReqCompTimeYes; | 22857 | || type_requires_comptime(ira->codegen, union_type) == ReqCompTimeYes; |
| 21923 | | 22858 | |
| 21924 | IrInstruction *result = ir_get_deref(ira, source_instruction, result_loc, nullptr); | 22859 | IrInstGen *result = ir_get_deref(ira, source_instruction, result_loc, nullptr); |
| 21925 | if (is_comptime && !instr_is_comptime(result)) { | 22860 | if (is_comptime && !instr_is_comptime(result)) { |
| 21926 | ir_add_error(ira, field_result_loc, | 22861 | ir_add_error(ira, &field_result_loc->base, |
| 21927 | buf_sprintf("unable to evaluate constant expression")); | 22862 | buf_sprintf("unable to evaluate constant expression")); |
| 21928 | return ira->codegen->invalid_instruction; | 22863 | return ira->codegen->invalid_inst_gen; |
| 21929 | } | 22864 | } |
| 21930 | return result; | 22865 | return result; |
| 21931 | } | 22866 | } |
| 21932 | | 22867 | |
| 21933 | static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruction *instruction, | 22868 | static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, IrInst *source_instr, |
| 21934 | ZigType *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields, | 22869 | ZigType *container_type, size_t instr_field_count, IrInstSrcContainerInitFieldsField *fields, |
| 21935 | IrInstruction *result_loc) | 22870 | IrInstGen *result_loc) |
| 21936 | { | 22871 | { |
| 21937 | Error err; | 22872 | Error err; |
| 21938 | if (container_type->id == ZigTypeIdUnion) { | 22873 | if (container_type->id == ZigTypeIdUnion) { |
| 21939 | if (instr_field_count != 1) { | 22874 | if (instr_field_count != 1) { |
| 21940 | ir_add_error(ira, instruction, | 22875 | ir_add_error(ira, source_instr, |
| 21941 | buf_sprintf("union initialization expects exactly one field")); | 22876 | buf_sprintf("union initialization expects exactly one field")); |
| 21942 | return ira->codegen->invalid_instruction; | 22877 | return ira->codegen->invalid_inst_gen; |
| 21943 | } | 22878 | } |
| 21944 | IrInstructionContainerInitFieldsField *field = &fields[0]; | 22879 | IrInstSrcContainerInitFieldsField *field = &fields[0]; |
| 21945 | IrInstruction *field_result_loc = field->result_loc->child; | 22880 | IrInstGen *field_result_loc = field->result_loc->child; |
| 21946 | if (type_is_invalid(field_result_loc->value->type)) | 22881 | if (type_is_invalid(field_result_loc->value->type)) |
| 21947 | return ira->codegen->invalid_instruction; | 22882 | return ira->codegen->invalid_inst_gen; |
| 21948 | | 22883 | |
| 21949 | return ir_analyze_union_init(ira, instruction, field->source_node, container_type, field->name, | 22884 | return ir_analyze_union_init(ira, source_instr, field->source_node, container_type, field->name, |
| 21950 | field_result_loc, result_loc); | 22885 | field_result_loc, result_loc); |
| 21951 | } | 22886 | } |
| 21952 | if (container_type->id != ZigTypeIdStruct || is_slice(container_type)) { | 22887 | if (container_type->id != ZigTypeIdStruct || is_slice(container_type)) { |
| 21953 | ir_add_error(ira, instruction, | 22888 | ir_add_error(ira, source_instr, |
| 21954 | buf_sprintf("type '%s' does not support struct initialization syntax", | 22889 | buf_sprintf("type '%s' does not support struct initialization syntax", |
| 21955 | buf_ptr(&container_type->name))); | 22890 | buf_ptr(&container_type->name))); |
| 21956 | return ira->codegen->invalid_instruction; | 22891 | return ira->codegen->invalid_inst_gen; |
| 21957 | } | 22892 | } |
| 21958 | | 22893 | |
| 21959 | if (container_type->data.structure.resolve_status == ResolveStatusBeingInferred) { | 22894 | if (container_type->data.structure.resolve_status == ResolveStatusBeingInferred) { |
| ... | @@ -21962,16 +22897,16 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -21962,16 +22897,16 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 21962 | } | 22897 | } |
| 21963 | | 22898 | |
| 21964 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) | 22899 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) |
| 21965 | return ira->codegen->invalid_instruction; | 22900 | return ira->codegen->invalid_inst_gen; |
| 21966 | | 22901 | |
| 21967 | size_t actual_field_count = container_type->data.structure.src_field_count; | 22902 | size_t actual_field_count = container_type->data.structure.src_field_count; |
| 21968 | | 22903 | |
| 21969 | IrInstruction *first_non_const_instruction = nullptr; | 22904 | IrInstGen *first_non_const_instruction = nullptr; |
| 21970 | | 22905 | |
| 21971 | AstNode **field_assign_nodes = allocate<AstNode *>(actual_field_count); | 22906 | AstNode **field_assign_nodes = allocate<AstNode *>(actual_field_count); |
| 21972 | ZigList<IrInstruction *> const_ptrs = {}; | 22907 | ZigList<IrInstGen *> const_ptrs = {}; |
| 21973 | | 22908 | |
| 21974 | bool is_comptime = ir_should_inline(ira->new_irb.exec, instruction->scope) | 22909 | bool is_comptime = ir_should_inline(ira->old_irb.exec, source_instr->scope) |
| 21975 | || type_requires_comptime(ira->codegen, container_type) == ReqCompTimeYes; | 22910 | || type_requires_comptime(ira->codegen, container_type) == ReqCompTimeYes; |
| 21976 | | 22911 | |
| 21977 | | 22912 | |
| ... | @@ -21987,29 +22922,29 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -21987,29 +22922,29 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 21987 | // comptime-known values. | 22922 | // comptime-known values. |
| 21988 | | 22923 | |
| 21989 | for (size_t i = 0; i < instr_field_count; i += 1) { | 22924 | for (size_t i = 0; i < instr_field_count; i += 1) { |
| 21990 | IrInstructionContainerInitFieldsField *field = &fields[i]; | 22925 | IrInstSrcContainerInitFieldsField *field = &fields[i]; |
| 21991 | | 22926 | |
| 21992 | IrInstruction *field_result_loc = field->result_loc->child; | 22927 | IrInstGen *field_result_loc = field->result_loc->child; |
| 21993 | if (type_is_invalid(field_result_loc->value->type)) | 22928 | if (type_is_invalid(field_result_loc->value->type)) |
| 21994 | return ira->codegen->invalid_instruction; | 22929 | return ira->codegen->invalid_inst_gen; |
| 21995 | | 22930 | |
| 21996 | TypeStructField *type_field = find_struct_type_field(container_type, field->name); | 22931 | TypeStructField *type_field = find_struct_type_field(container_type, field->name); |
| 21997 | if (!type_field) { | 22932 | if (!type_field) { |
| 21998 | ir_add_error_node(ira, field->source_node, | 22933 | ir_add_error_node(ira, field->source_node, |
| 21999 | buf_sprintf("no member named '%s' in struct '%s'", | 22934 | buf_sprintf("no member named '%s' in struct '%s'", |
| 22000 | buf_ptr(field->name), buf_ptr(&container_type->name))); | 22935 | buf_ptr(field->name), buf_ptr(&container_type->name))); |
| 22001 | return ira->codegen->invalid_instruction; | 22936 | return ira->codegen->invalid_inst_gen; |
| 22002 | } | 22937 | } |
| 22003 | | 22938 | |
| 22004 | if (type_is_invalid(type_field->type_entry)) | 22939 | if (type_is_invalid(type_field->type_entry)) |
| 22005 | return ira->codegen->invalid_instruction; | 22940 | return ira->codegen->invalid_inst_gen; |
| 22006 | | 22941 | |
| 22007 | size_t field_index = type_field->src_index; | 22942 | size_t field_index = type_field->src_index; |
| 22008 | AstNode *existing_assign_node = field_assign_nodes[field_index]; | 22943 | AstNode *existing_assign_node = field_assign_nodes[field_index]; |
| 22009 | if (existing_assign_node) { | 22944 | if (existing_assign_node) { |
| 22010 | ErrorMsg *msg = ir_add_error_node(ira, field->source_node, buf_sprintf("duplicate field")); | 22945 | ErrorMsg *msg = ir_add_error_node(ira, field->source_node, buf_sprintf("duplicate field")); |
| 22011 | add_error_note(ira->codegen, msg, existing_assign_node, buf_sprintf("other field here")); | 22946 | add_error_note(ira->codegen, msg, existing_assign_node, buf_sprintf("other field here")); |
| 22012 | return ira->codegen->invalid_instruction; | 22947 | return ira->codegen->invalid_inst_gen; |
| 22013 | } | 22948 | } |
| 22014 | field_assign_nodes[field_index] = field->source_node; | 22949 | field_assign_nodes[field_index] = field->source_node; |
| 22015 | | 22950 | |
| ... | @@ -22030,20 +22965,20 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -22030,20 +22965,20 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 22030 | TypeStructField *field = container_type->data.structure.fields[i]; | 22965 | TypeStructField *field = container_type->data.structure.fields[i]; |
| 22031 | memoize_field_init_val(ira->codegen, container_type, field); | 22966 | memoize_field_init_val(ira->codegen, container_type, field); |
| 22032 | if (field->init_val == nullptr) { | 22967 | if (field->init_val == nullptr) { |
| 22033 | ir_add_error_node(ira, instruction->source_node, | 22968 | ir_add_error(ira, source_instr, |
| 22034 | buf_sprintf("missing field: '%s'", buf_ptr(container_type->data.structure.fields[i]->name))); | 22969 | buf_sprintf("missing field: '%s'", buf_ptr(container_type->data.structure.fields[i]->name))); |
| 22035 | any_missing = true; | 22970 | any_missing = true; |
| 22036 | continue; | 22971 | continue; |
| 22037 | } | 22972 | } |
| 22038 | if (type_is_invalid(field->init_val->type)) | 22973 | if (type_is_invalid(field->init_val->type)) |
| 22039 | return ira->codegen->invalid_instruction; | 22974 | return ira->codegen->invalid_inst_gen; |
| 22040 | | 22975 | |
| 22041 | IrInstruction *runtime_inst = ir_const(ira, instruction, field->init_val->type); | 22976 | IrInstGen *runtime_inst = ir_const(ira, source_instr, field->init_val->type); |
| 22042 | copy_const_val(runtime_inst->value, field->init_val); | 22977 | copy_const_val(runtime_inst->value, field->init_val); |
| 22043 | | 22978 | |
| 22044 | IrInstruction *field_ptr = ir_analyze_struct_field_ptr(ira, instruction, field, result_loc, | 22979 | IrInstGen *field_ptr = ir_analyze_struct_field_ptr(ira, source_instr, field, result_loc, |
| 22045 | container_type, true); | 22980 | container_type, true); |
| 22046 | ir_analyze_store_ptr(ira, instruction, field_ptr, runtime_inst, false); | 22981 | ir_analyze_store_ptr(ira, source_instr, field_ptr, runtime_inst, false); |
| 22047 | if (instr_is_comptime(field_ptr) && field_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 22982 | if (instr_is_comptime(field_ptr) && field_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 22048 | const_ptrs.append(field_ptr); | 22983 | const_ptrs.append(field_ptr); |
| 22049 | } else { | 22984 | } else { |
| ... | @@ -22051,39 +22986,39 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -22051,39 +22986,39 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 22051 | } | 22986 | } |
| 22052 | } | 22987 | } |
| 22053 | if (any_missing) | 22988 | if (any_missing) |
| 22054 | return ira->codegen->invalid_instruction; | 22989 | return ira->codegen->invalid_inst_gen; |
| 22055 | | 22990 | |
| 22056 | if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) { | 22991 | if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) { |
| 22057 | if (const_ptrs.length != actual_field_count) { | 22992 | if (const_ptrs.length != actual_field_count) { |
| 22058 | result_loc->value->special = ConstValSpecialRuntime; | 22993 | result_loc->value->special = ConstValSpecialRuntime; |
| 22059 | for (size_t i = 0; i < const_ptrs.length; i += 1) { | 22994 | for (size_t i = 0; i < const_ptrs.length; i += 1) { |
| 22060 | IrInstruction *field_result_loc = const_ptrs.at(i); | 22995 | IrInstGen *field_result_loc = const_ptrs.at(i); |
| 22061 | IrInstruction *deref = ir_get_deref(ira, field_result_loc, field_result_loc, nullptr); | 22996 | IrInstGen *deref = ir_get_deref(ira, &field_result_loc->base, field_result_loc, nullptr); |
| 22062 | field_result_loc->value->special = ConstValSpecialRuntime; | 22997 | field_result_loc->value->special = ConstValSpecialRuntime; |
| 22063 | ir_analyze_store_ptr(ira, field_result_loc, field_result_loc, deref, false); | 22998 | ir_analyze_store_ptr(ira, &field_result_loc->base, field_result_loc, deref, false); |
| 22064 | } | 22999 | } |
| 22065 | } | 23000 | } |
| 22066 | } | 23001 | } |
| 22067 | | 23002 | |
| 22068 | IrInstruction *result = ir_get_deref(ira, instruction, result_loc, nullptr); | 23003 | IrInstGen *result = ir_get_deref(ira, source_instr, result_loc, nullptr); |
| 22069 | | 23004 | |
| 22070 | if (is_comptime && !instr_is_comptime(result)) { | 23005 | if (is_comptime && !instr_is_comptime(result)) { |
| 22071 | ir_add_error_node(ira, first_non_const_instruction->source_node, | 23006 | ir_add_error_node(ira, first_non_const_instruction->base.source_node, |
| 22072 | buf_sprintf("unable to evaluate constant expression")); | 23007 | buf_sprintf("unable to evaluate constant expression")); |
| 22073 | return ira->codegen->invalid_instruction; | 23008 | return ira->codegen->invalid_inst_gen; |
| 22074 | } | 23009 | } |
| 22075 | | 23010 | |
| 22076 | return result; | 23011 | return result; |
| 22077 | } | 23012 | } |
| 22078 | | 23013 | |
| 22079 | static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | 23014 | static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 22080 | IrInstructionContainerInitList *instruction) | 23015 | IrInstSrcContainerInitList *instruction) |
| 22081 | { | 23016 | { |
| 22082 | ir_assert(instruction->result_loc != nullptr, &instruction->base); | 23017 | ir_assert(instruction->result_loc != nullptr, &instruction->base.base); |
| 22083 | IrInstruction *result_loc = instruction->result_loc->child; | 23018 | IrInstGen *result_loc = instruction->result_loc->child; |
| 22084 | if (type_is_invalid(result_loc->value->type)) | 23019 | if (type_is_invalid(result_loc->value->type)) |
| 22085 | return result_loc; | 23020 | return result_loc; |
| 22086 | ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base); | 23021 | ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base.base); |
| 22087 | | 23022 | |
| 22088 | ZigType *container_type = result_loc->value->type->data.pointer.child_type; | 23023 | ZigType *container_type = result_loc->value->type->data.pointer.child_type; |
| 22089 | | 23024 | |
| ... | @@ -22093,24 +23028,24 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -22093,24 +23028,24 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 22093 | ir_add_error_node(ira, instruction->init_array_type_source_node, | 23028 | ir_add_error_node(ira, instruction->init_array_type_source_node, |
| 22094 | buf_sprintf("array literal requires address-of operator to coerce to slice type '%s'", | 23029 | buf_sprintf("array literal requires address-of operator to coerce to slice type '%s'", |
| 22095 | buf_ptr(&container_type->name))); | 23030 | buf_ptr(&container_type->name))); |
| 22096 | return ira->codegen->invalid_instruction; | 23031 | return ira->codegen->invalid_inst_gen; |
| 22097 | } | 23032 | } |
| 22098 | | 23033 | |
| 22099 | if (container_type->id == ZigTypeIdVoid) { | 23034 | if (container_type->id == ZigTypeIdVoid) { |
| 22100 | if (elem_count != 0) { | 23035 | if (elem_count != 0) { |
| 22101 | ir_add_error_node(ira, instruction->base.source_node, | 23036 | ir_add_error_node(ira, instruction->base.base.source_node, |
| 22102 | buf_sprintf("void expression expects no arguments")); | 23037 | buf_sprintf("void expression expects no arguments")); |
| 22103 | return ira->codegen->invalid_instruction; | 23038 | return ira->codegen->invalid_inst_gen; |
| 22104 | } | 23039 | } |
| 22105 | return ir_const_void(ira, &instruction->base); | 23040 | return ir_const_void(ira, &instruction->base.base); |
| 22106 | } | 23041 | } |
| 22107 | | 23042 | |
| 22108 | if (container_type->id == ZigTypeIdStruct && elem_count == 0) { | 23043 | if (container_type->id == ZigTypeIdStruct && elem_count == 0) { |
| 22109 | ir_assert(instruction->result_loc != nullptr, &instruction->base); | 23044 | ir_assert(instruction->result_loc != nullptr, &instruction->base.base); |
| 22110 | IrInstruction *result_loc = instruction->result_loc->child; | 23045 | IrInstGen *result_loc = instruction->result_loc->child; |
| 22111 | if (type_is_invalid(result_loc->value->type)) | 23046 | if (type_is_invalid(result_loc->value->type)) |
| 22112 | return result_loc; | 23047 | return result_loc; |
| 22113 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, 0, nullptr, result_loc); | 23048 | return ir_analyze_container_init_fields(ira, &instruction->base.base, container_type, 0, nullptr, result_loc); |
| 22114 | } | 23049 | } |
| 22115 | | 23050 | |
| 22116 | if (container_type->id == ZigTypeIdArray) { | 23051 | if (container_type->id == ZigTypeIdArray) { |
| ... | @@ -22118,10 +23053,10 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -22118,10 +23053,10 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 22118 | if (container_type->data.array.len != elem_count) { | 23053 | if (container_type->data.array.len != elem_count) { |
| 22119 | ZigType *literal_type = get_array_type(ira->codegen, child_type, elem_count, nullptr); | 23054 | ZigType *literal_type = get_array_type(ira->codegen, child_type, elem_count, nullptr); |
| 22120 | | 23055 | |
| 22121 | ir_add_error(ira, &instruction->base, | 23056 | ir_add_error(ira, &instruction->base.base, |
| 22122 | buf_sprintf("expected %s literal, found %s literal", | 23057 | buf_sprintf("expected %s literal, found %s literal", |
| 22123 | buf_ptr(&container_type->name), buf_ptr(&literal_type->name))); | 23058 | buf_ptr(&container_type->name), buf_ptr(&literal_type->name))); |
| 22124 | return ira->codegen->invalid_instruction; | 23059 | return ira->codegen->invalid_inst_gen; |
| 22125 | } | 23060 | } |
| 22126 | } else if (container_type->id == ZigTypeIdStruct && | 23061 | } else if (container_type->id == ZigTypeIdStruct && |
| 22127 | container_type->data.structure.resolve_status == ResolveStatusBeingInferred) | 23062 | container_type->data.structure.resolve_status == ResolveStatusBeingInferred) |
| ... | @@ -22131,17 +23066,17 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -22131,17 +23066,17 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 22131 | } else if (container_type->id == ZigTypeIdVector) { | 23066 | } else if (container_type->id == ZigTypeIdVector) { |
| 22132 | // OK | 23067 | // OK |
| 22133 | } else { | 23068 | } else { |
| 22134 | ir_add_error_node(ira, instruction->base.source_node, | 23069 | ir_add_error(ira, &instruction->base.base, |
| 22135 | buf_sprintf("type '%s' does not support array initialization", | 23070 | buf_sprintf("type '%s' does not support array initialization", |
| 22136 | buf_ptr(&container_type->name))); | 23071 | buf_ptr(&container_type->name))); |
| 22137 | return ira->codegen->invalid_instruction; | 23072 | return ira->codegen->invalid_inst_gen; |
| 22138 | } | 23073 | } |
| 22139 | | 23074 | |
| 22140 | switch (type_has_one_possible_value(ira->codegen, container_type)) { | 23075 | switch (type_has_one_possible_value(ira->codegen, container_type)) { |
| 22141 | case OnePossibleValueInvalid: | 23076 | case OnePossibleValueInvalid: |
| 22142 | return ira->codegen->invalid_instruction; | 23077 | return ira->codegen->invalid_inst_gen; |
| 22143 | case OnePossibleValueYes: | 23078 | case OnePossibleValueYes: |
| 22144 | return ir_const_move(ira, &instruction->base, | 23079 | return ir_const_move(ira, &instruction->base.base, |
| 22145 | get_the_one_possible_value(ira->codegen, container_type)); | 23080 | get_the_one_possible_value(ira->codegen, container_type)); |
| 22146 | case OnePossibleValueNo: | 23081 | case OnePossibleValueNo: |
| 22147 | break; | 23082 | break; |
| ... | @@ -22150,16 +23085,16 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -22150,16 +23085,16 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 22150 | bool is_comptime; | 23085 | bool is_comptime; |
| 22151 | switch (type_requires_comptime(ira->codegen, container_type)) { | 23086 | switch (type_requires_comptime(ira->codegen, container_type)) { |
| 22152 | case ReqCompTimeInvalid: | 23087 | case ReqCompTimeInvalid: |
| 22153 | return ira->codegen->invalid_instruction; | 23088 | return ira->codegen->invalid_inst_gen; |
| 22154 | case ReqCompTimeNo: | 23089 | case ReqCompTimeNo: |
| 22155 | is_comptime = ir_should_inline(ira->new_irb.exec, instruction->base.scope); | 23090 | is_comptime = ir_should_inline(ira->old_irb.exec, instruction->base.base.scope); |
| 22156 | break; | 23091 | break; |
| 22157 | case ReqCompTimeYes: | 23092 | case ReqCompTimeYes: |
| 22158 | is_comptime = true; | 23093 | is_comptime = true; |
| 22159 | break; | 23094 | break; |
| 22160 | } | 23095 | } |
| 22161 | | 23096 | |
| 22162 | IrInstruction *first_non_const_instruction = nullptr; | 23097 | IrInstGen *first_non_const_instruction = nullptr; |
| 22163 | | 23098 | |
| 22164 | // The Result Location Mechanism has already emitted runtime instructions to | 23099 | // The Result Location Mechanism has already emitted runtime instructions to |
| 22165 | // initialize runtime elements and has omitted instructions for the comptime | 23100 | // initialize runtime elements and has omitted instructions for the comptime |
| ... | @@ -22168,12 +23103,12 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -22168,12 +23103,12 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 22168 | // array initialization can be a comptime value, overwrite ConstPtrMutInfer with | 23103 | // array initialization can be a comptime value, overwrite ConstPtrMutInfer with |
| 22169 | // ConstPtrMutComptimeConst. Otherwise, emit instructions to runtime-initialize the | 23104 | // ConstPtrMutComptimeConst. Otherwise, emit instructions to runtime-initialize the |
| 22170 | // elements that have comptime-known values. | 23105 | // elements that have comptime-known values. |
| 22171 | ZigList<IrInstruction *> const_ptrs = {}; | 23106 | ZigList<IrInstGen *> const_ptrs = {}; |
| 22172 | | 23107 | |
| 22173 | for (size_t i = 0; i < elem_count; i += 1) { | 23108 | for (size_t i = 0; i < elem_count; i += 1) { |
| 22174 | IrInstruction *elem_result_loc = instruction->elem_result_loc_list[i]->child; | 23109 | IrInstGen *elem_result_loc = instruction->elem_result_loc_list[i]->child; |
| 22175 | if (type_is_invalid(elem_result_loc->value->type)) | 23110 | if (type_is_invalid(elem_result_loc->value->type)) |
| 22176 | return ira->codegen->invalid_instruction; | 23111 | return ira->codegen->invalid_inst_gen; |
| 22177 | | 23112 | |
| 22178 | assert(elem_result_loc->value->type->id == ZigTypeIdPointer); | 23113 | assert(elem_result_loc->value->type->id == ZigTypeIdPointer); |
| 22179 | | 23114 | |
| ... | @@ -22190,81 +23125,79 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -22190,81 +23125,79 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 22190 | if (const_ptrs.length != elem_count) { | 23125 | if (const_ptrs.length != elem_count) { |
| 22191 | result_loc->value->special = ConstValSpecialRuntime; | 23126 | result_loc->value->special = ConstValSpecialRuntime; |
| 22192 | for (size_t i = 0; i < const_ptrs.length; i += 1) { | 23127 | for (size_t i = 0; i < const_ptrs.length; i += 1) { |
| 22193 | IrInstruction *elem_result_loc = const_ptrs.at(i); | 23128 | IrInstGen *elem_result_loc = const_ptrs.at(i); |
| 22194 | assert(elem_result_loc->value->special == ConstValSpecialStatic); | 23129 | assert(elem_result_loc->value->special == ConstValSpecialStatic); |
| 22195 | if (elem_result_loc->value->type->data.pointer.inferred_struct_field != nullptr) { | 23130 | if (elem_result_loc->value->type->data.pointer.inferred_struct_field != nullptr) { |
| 22196 | // This field will be generated comptime; no need to do this. | 23131 | // This field will be generated comptime; no need to do this. |
| 22197 | continue; | 23132 | continue; |
| 22198 | } | 23133 | } |
| 22199 | IrInstruction *deref = ir_get_deref(ira, elem_result_loc, elem_result_loc, nullptr); | 23134 | IrInstGen *deref = ir_get_deref(ira, &elem_result_loc->base, elem_result_loc, nullptr); |
| 22200 | elem_result_loc->value->special = ConstValSpecialRuntime; | 23135 | elem_result_loc->value->special = ConstValSpecialRuntime; |
| 22201 | ir_analyze_store_ptr(ira, elem_result_loc, elem_result_loc, deref, false); | 23136 | ir_analyze_store_ptr(ira, &elem_result_loc->base, elem_result_loc, deref, false); |
| 22202 | } | 23137 | } |
| 22203 | } | 23138 | } |
| 22204 | } | 23139 | } |
| 22205 | | 23140 | |
| 22206 | IrInstruction *result = ir_get_deref(ira, &instruction->base, result_loc, nullptr); | 23141 | IrInstGen *result = ir_get_deref(ira, &instruction->base.base, result_loc, nullptr); |
| 22207 | if (instr_is_comptime(result)) | 23142 | if (instr_is_comptime(result)) |
| 22208 | return result; | 23143 | return result; |
| 22209 | | 23144 | |
| 22210 | if (is_comptime) { | 23145 | if (is_comptime) { |
| 22211 | ir_add_error_node(ira, first_non_const_instruction->source_node, | 23146 | ir_add_error(ira, &first_non_const_instruction->base, |
| 22212 | buf_sprintf("unable to evaluate constant expression")); | 23147 | buf_sprintf("unable to evaluate constant expression")); |
| 22213 | return ira->codegen->invalid_instruction; | 23148 | return ira->codegen->invalid_inst_gen; |
| 22214 | } | 23149 | } |
| 22215 | | 23150 | |
| 22216 | ZigType *result_elem_type = result_loc->value->type->data.pointer.child_type; | 23151 | ZigType *result_elem_type = result_loc->value->type->data.pointer.child_type; |
| 22217 | if (is_slice(result_elem_type)) { | 23152 | if (is_slice(result_elem_type)) { |
| 22218 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, | 23153 | ErrorMsg *msg = ir_add_error(ira, &instruction->base.base, |
| 22219 | buf_sprintf("runtime-initialized array cannot be casted to slice type '%s'", | 23154 | buf_sprintf("runtime-initialized array cannot be casted to slice type '%s'", |
| 22220 | buf_ptr(&result_elem_type->name))); | 23155 | buf_ptr(&result_elem_type->name))); |
| 22221 | add_error_note(ira->codegen, msg, first_non_const_instruction->source_node, | 23156 | add_error_note(ira->codegen, msg, first_non_const_instruction->base.source_node, |
| 22222 | buf_sprintf("this value is not comptime-known")); | 23157 | buf_sprintf("this value is not comptime-known")); |
| 22223 | return ira->codegen->invalid_instruction; | 23158 | return ira->codegen->invalid_inst_gen; |
| 22224 | } | 23159 | } |
| 22225 | return result; | 23160 | return result; |
| 22226 | } | 23161 | } |
| 22227 | | 23162 | |
| 22228 | static IrInstruction *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, | 23163 | static IrInstGen *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, |
| 22229 | IrInstructionContainerInitFields *instruction) | 23164 | IrInstSrcContainerInitFields *instruction) |
| 22230 | { | 23165 | { |
| 22231 | ir_assert(instruction->result_loc != nullptr, &instruction->base); | 23166 | ir_assert(instruction->result_loc != nullptr, &instruction->base.base); |
| 22232 | IrInstruction *result_loc = instruction->result_loc->child; | 23167 | IrInstGen *result_loc = instruction->result_loc->child; |
| 22233 | if (type_is_invalid(result_loc->value->type)) | 23168 | if (type_is_invalid(result_loc->value->type)) |
| 22234 | return result_loc; | 23169 | return result_loc; |
| 22235 | | 23170 | |
| 22236 | ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base); | 23171 | ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base.base); |
| 22237 | ZigType *container_type = result_loc->value->type->data.pointer.child_type; | 23172 | ZigType *container_type = result_loc->value->type->data.pointer.child_type; |
| 22238 | | 23173 | |
| 22239 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, | 23174 | return ir_analyze_container_init_fields(ira, &instruction->base.base, container_type, |
| 22240 | instruction->field_count, instruction->fields, result_loc); | 23175 | instruction->field_count, instruction->fields, result_loc); |
| 22241 | } | 23176 | } |
| 22242 | | 23177 | |
| 22243 | static IrInstruction *ir_analyze_instruction_compile_err(IrAnalyze *ira, | 23178 | static IrInstGen *ir_analyze_instruction_compile_err(IrAnalyze *ira, IrInstSrcCompileErr *instruction) { |
| 22244 | IrInstructionCompileErr *instruction) | 23179 | IrInstGen *msg_value = instruction->msg->child; |
| 22245 | { | | |
| 22246 | IrInstruction *msg_value = instruction->msg->child; | | |
| 22247 | Buf *msg_buf = ir_resolve_str(ira, msg_value); | 23180 | Buf *msg_buf = ir_resolve_str(ira, msg_value); |
| 22248 | if (!msg_buf) | 23181 | if (!msg_buf) |
| 22249 | return ira->codegen->invalid_instruction; | 23182 | return ira->codegen->invalid_inst_gen; |
| 22250 | | 23183 | |
| 22251 | ir_add_error(ira, &instruction->base, msg_buf); | 23184 | ir_add_error(ira, &instruction->base.base, msg_buf); |
| 22252 | | 23185 | |
| 22253 | return ira->codegen->invalid_instruction; | 23186 | return ira->codegen->invalid_inst_gen; |
| 22254 | } | 23187 | } |
| 22255 | | 23188 | |
| 22256 | static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstructionCompileLog *instruction) { | 23189 | static IrInstGen *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstSrcCompileLog *instruction) { |
| 22257 | Buf buf = BUF_INIT; | 23190 | Buf buf = BUF_INIT; |
| 22258 | fprintf(stderr, "| "); | 23191 | fprintf(stderr, "| "); |
| 22259 | for (size_t i = 0; i < instruction->msg_count; i += 1) { | 23192 | for (size_t i = 0; i < instruction->msg_count; i += 1) { |
| 22260 | IrInstruction *msg = instruction->msg_list[i]->child; | 23193 | IrInstGen *msg = instruction->msg_list[i]->child; |
| 22261 | if (type_is_invalid(msg->value->type)) | 23194 | if (type_is_invalid(msg->value->type)) |
| 22262 | return ira->codegen->invalid_instruction; | 23195 | return ira->codegen->invalid_inst_gen; |
| 22263 | buf_resize(&buf, 0); | 23196 | buf_resize(&buf, 0); |
| 22264 | if (msg->value->special == ConstValSpecialLazy) { | 23197 | if (msg->value->special == ConstValSpecialLazy) { |
| 22265 | // Resolve any lazy value that's passed, we need its value | 23198 | // Resolve any lazy value that's passed, we need its value |
| 22266 | if (ir_resolve_lazy(ira->codegen, msg->source_node, msg->value)) | 23199 | if (ir_resolve_lazy(ira->codegen, msg->base.source_node, msg->value)) |
| 22267 | return ira->codegen->invalid_instruction; | 23200 | return ira->codegen->invalid_inst_gen; |
| 22268 | } | 23201 | } |
| 22269 | render_const_value(ira->codegen, &buf, msg->value); | 23202 | render_const_value(ira->codegen, &buf, msg->value); |
| 22270 | const char *comma_str = (i != 0) ? ", " : ""; | 23203 | const char *comma_str = (i != 0) ? ", " : ""; |
| ... | @@ -22272,25 +23205,25 @@ static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstr | ... | @@ -22272,25 +23205,25 @@ static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstr |
| 22272 | } | 23205 | } |
| 22273 | fprintf(stderr, "\n"); | 23206 | fprintf(stderr, "\n"); |
| 22274 | | 23207 | |
| 22275 | auto *expr = &instruction->base.source_node->data.fn_call_expr; | 23208 | auto *expr = &instruction->base.base.source_node->data.fn_call_expr; |
| 22276 | if (!expr->seen) { | 23209 | if (!expr->seen) { |
| 22277 | // Here we bypass higher level functions such as ir_add_error because we do not want | 23210 | // Here we bypass higher level functions such as ir_add_error because we do not want |
| 22278 | // invalidate_exec to be called. | 23211 | // invalidate_exec to be called. |
| 22279 | add_node_error(ira->codegen, instruction->base.source_node, buf_sprintf("found compile log statement")); | 23212 | add_node_error(ira->codegen, instruction->base.base.source_node, buf_sprintf("found compile log statement")); |
| 22280 | } | 23213 | } |
| 22281 | expr->seen = true; | 23214 | expr->seen = true; |
| 22282 | | 23215 | |
| 22283 | return ir_const_void(ira, &instruction->base); | 23216 | return ir_const_void(ira, &instruction->base.base); |
| 22284 | } | 23217 | } |
| 22285 | | 23218 | |
| 22286 | static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstructionErrName *instruction) { | 23219 | static IrInstGen *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstSrcErrName *instruction) { |
| 22287 | IrInstruction *value = instruction->value->child; | 23220 | IrInstGen *value = instruction->value->child; |
| 22288 | if (type_is_invalid(value->value->type)) | 23221 | if (type_is_invalid(value->value->type)) |
| 22289 | return ira->codegen->invalid_instruction; | 23222 | return ira->codegen->invalid_inst_gen; |
| 22290 | | 23223 | |
| 22291 | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_global_error_set); | 23224 | IrInstGen *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_global_error_set); |
| 22292 | if (type_is_invalid(casted_value->value->type)) | 23225 | if (type_is_invalid(casted_value->value->type)) |
| 22293 | return ira->codegen->invalid_instruction; | 23226 | return ira->codegen->invalid_inst_gen; |
| 22294 | | 23227 | |
| 22295 | ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, | 23228 | ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 22296 | true, false, PtrLenUnknown, 0, 0, 0, false); | 23229 | true, false, PtrLenUnknown, 0, 0, 0, false); |
| ... | @@ -22298,13 +23231,13 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct | ... | @@ -22298,13 +23231,13 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct |
| 22298 | if (instr_is_comptime(casted_value)) { | 23231 | if (instr_is_comptime(casted_value)) { |
| 22299 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); | 23232 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); |
| 22300 | if (val == nullptr) | 23233 | if (val == nullptr) |
| 22301 | return ira->codegen->invalid_instruction; | 23234 | return ira->codegen->invalid_inst_gen; |
| 22302 | ErrorTableEntry *err = casted_value->value->data.x_err_set; | 23235 | ErrorTableEntry *err = casted_value->value->data.x_err_set; |
| 22303 | if (!err->cached_error_name_val) { | 23236 | if (!err->cached_error_name_val) { |
| 22304 | ZigValue *array_val = create_const_str_lit(ira->codegen, &err->name)->data.x_ptr.data.ref.pointee; | 23237 | ZigValue *array_val = create_const_str_lit(ira->codegen, &err->name)->data.x_ptr.data.ref.pointee; |
| 22305 | err->cached_error_name_val = create_const_slice(ira->codegen, array_val, 0, buf_len(&err->name), true); | 23238 | err->cached_error_name_val = create_const_slice(ira->codegen, array_val, 0, buf_len(&err->name), true); |
| 22306 | } | 23239 | } |
| 22307 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 23240 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 22308 | copy_const_val(result->value, err->cached_error_name_val); | 23241 | copy_const_val(result->value, err->cached_error_name_val); |
| 22309 | result->value->type = str_type; | 23242 | result->value->type = str_type; |
| 22310 | return result; | 23243 | return result; |
| ... | @@ -22312,79 +23245,106 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct | ... | @@ -22312,79 +23245,106 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct |
| 22312 | | 23245 | |
| 22313 | ira->codegen->generate_error_name_table = true; | 23246 | ira->codegen->generate_error_name_table = true; |
| 22314 | | 23247 | |
| 22315 | IrInstruction *result = ir_build_err_name(&ira->new_irb, | 23248 | return ir_build_err_name_gen(ira, &instruction->base.base, value, str_type); |
| 22316 | instruction->base.scope, instruction->base.source_node, value); | | |
| 22317 | result->value->type = str_type; | | |
| 22318 | return result; | | |
| 22319 | } | 23249 | } |
| 22320 | | 23250 | |
| 22321 | static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstructionTagName *instruction) { | 23251 | static IrInstGen *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstSrcTagName *instruction) { |
| 22322 | Error err; | 23252 | Error err; |
| 22323 | IrInstruction *target = instruction->target->child; | 23253 | IrInstGen *target = instruction->target->child; |
| 22324 | if (type_is_invalid(target->value->type)) | 23254 | if (type_is_invalid(target->value->type)) |
| 22325 | return ira->codegen->invalid_instruction; | 23255 | return ira->codegen->invalid_inst_gen; |
| | 23256 | |
| | 23257 | if (target->value->type->id == ZigTypeIdEnumLiteral) { |
| | 23258 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| | 23259 | Buf *field_name = target->value->data.x_enum_literal; |
| | 23260 | ZigValue *array_val = create_const_str_lit(ira->codegen, field_name)->data.x_ptr.data.ref.pointee; |
| | 23261 | init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(field_name), true); |
| | 23262 | return result; |
| | 23263 | } |
| | 23264 | |
| | 23265 | if (target->value->type->id == ZigTypeIdUnion) { |
| | 23266 | target = ir_analyze_union_tag(ira, &instruction->base.base, target, instruction->base.is_gen); |
| | 23267 | if (type_is_invalid(target->value->type)) |
| | 23268 | return ira->codegen->invalid_inst_gen; |
| | 23269 | } |
| | 23270 | |
| | 23271 | if (target->value->type->id != ZigTypeIdEnum) { |
| | 23272 | ir_add_error(ira, &target->base, |
| | 23273 | buf_sprintf("expected enum tag, found '%s'", buf_ptr(&target->value->type->name))); |
| | 23274 | return ira->codegen->invalid_inst_gen; |
| | 23275 | } |
| 22326 | | 23276 | |
| 22327 | assert(target->value->type->id == ZigTypeIdEnum); | 23277 | if (target->value->type->data.enumeration.src_field_count == 1 && |
| | 23278 | !target->value->type->data.enumeration.non_exhaustive) { |
| | 23279 | TypeEnumField *only_field = &target->value->type->data.enumeration.fields[0]; |
| | 23280 | ZigValue *array_val = create_const_str_lit(ira->codegen, only_field->name)->data.x_ptr.data.ref.pointee; |
| | 23281 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| | 23282 | init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(only_field->name), true); |
| | 23283 | return result; |
| | 23284 | } |
| 22328 | | 23285 | |
| 22329 | if (instr_is_comptime(target)) { | 23286 | if (instr_is_comptime(target)) { |
| 22330 | if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusZeroBitsKnown))) | 23287 | if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusZeroBitsKnown))) |
| 22331 | return ira->codegen->invalid_instruction; | 23288 | return ira->codegen->invalid_inst_gen; |
| | 23289 | if (target->value->type->data.enumeration.non_exhaustive) { |
| | 23290 | ir_add_error(ira, &instruction->base.base, |
| | 23291 | buf_sprintf("TODO @tagName on non-exhaustive enum https://github.com/ziglang/zig/issues/3991")); |
| | 23292 | return ira->codegen->invalid_inst_gen; |
| | 23293 | } |
| 22332 | TypeEnumField *field = find_enum_field_by_tag(target->value->type, &target->value->data.x_bigint); | 23294 | TypeEnumField *field = find_enum_field_by_tag(target->value->type, &target->value->data.x_bigint); |
| 22333 | ZigValue *array_val = create_const_str_lit(ira->codegen, field->name)->data.x_ptr.data.ref.pointee; | 23295 | ZigValue *array_val = create_const_str_lit(ira->codegen, field->name)->data.x_ptr.data.ref.pointee; |
| 22334 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 23296 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 22335 | init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(field->name), true); | 23297 | init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(field->name), true); |
| 22336 | return result; | 23298 | return result; |
| 22337 | } | 23299 | } |
| 22338 | | 23300 | |
| 22339 | IrInstruction *result = ir_build_tag_name(&ira->new_irb, instruction->base.scope, | | |
| 22340 | instruction->base.source_node, target); | | |
| 22341 | ZigType *u8_ptr_type = get_pointer_to_type_extra( | 23301 | ZigType *u8_ptr_type = get_pointer_to_type_extra( |
| 22342 | ira->codegen, ira->codegen->builtin_types.entry_u8, | 23302 | ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 22343 | true, false, PtrLenUnknown, | 23303 | true, false, PtrLenUnknown, |
| 22344 | 0, 0, 0, false); | 23304 | 0, 0, 0, false); |
| 22345 | result->value->type = get_slice_type(ira->codegen, u8_ptr_type); | 23305 | ZigType *result_type = get_slice_type(ira->codegen, u8_ptr_type); |
| 22346 | return result; | 23306 | return ir_build_tag_name_gen(ira, &instruction->base.base, target, result_type); |
| 22347 | } | 23307 | } |
| 22348 | | 23308 | |
| 22349 | static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | 23309 | static IrInstGen *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 22350 | IrInstructionFieldParentPtr *instruction) | 23310 | IrInstSrcFieldParentPtr *instruction) |
| 22351 | { | 23311 | { |
| 22352 | Error err; | 23312 | Error err; |
| 22353 | IrInstruction *type_value = instruction->type_value->child; | 23313 | IrInstGen *type_value = instruction->type_value->child; |
| 22354 | ZigType *container_type = ir_resolve_type(ira, type_value); | 23314 | ZigType *container_type = ir_resolve_type(ira, type_value); |
| 22355 | if (type_is_invalid(container_type)) | 23315 | if (type_is_invalid(container_type)) |
| 22356 | return ira->codegen->invalid_instruction; | 23316 | return ira->codegen->invalid_inst_gen; |
| 22357 | | 23317 | |
| 22358 | IrInstruction *field_name_value = instruction->field_name->child; | 23318 | IrInstGen *field_name_value = instruction->field_name->child; |
| 22359 | Buf *field_name = ir_resolve_str(ira, field_name_value); | 23319 | Buf *field_name = ir_resolve_str(ira, field_name_value); |
| 22360 | if (!field_name) | 23320 | if (!field_name) |
| 22361 | return ira->codegen->invalid_instruction; | 23321 | return ira->codegen->invalid_inst_gen; |
| 22362 | | 23322 | |
| 22363 | IrInstruction *field_ptr = instruction->field_ptr->child; | 23323 | IrInstGen *field_ptr = instruction->field_ptr->child; |
| 22364 | if (type_is_invalid(field_ptr->value->type)) | 23324 | if (type_is_invalid(field_ptr->value->type)) |
| 22365 | return ira->codegen->invalid_instruction; | 23325 | return ira->codegen->invalid_inst_gen; |
| 22366 | | 23326 | |
| 22367 | if (container_type->id != ZigTypeIdStruct) { | 23327 | if (container_type->id != ZigTypeIdStruct) { |
| 22368 | ir_add_error(ira, type_value, | 23328 | ir_add_error(ira, &type_value->base, |
| 22369 | buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name))); | 23329 | buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name))); |
| 22370 | return ira->codegen->invalid_instruction; | 23330 | return ira->codegen->invalid_inst_gen; |
| 22371 | } | 23331 | } |
| 22372 | | 23332 | |
| 22373 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) | 23333 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) |
| 22374 | return ira->codegen->invalid_instruction; | 23334 | return ira->codegen->invalid_inst_gen; |
| 22375 | | 23335 | |
| 22376 | TypeStructField *field = find_struct_type_field(container_type, field_name); | 23336 | TypeStructField *field = find_struct_type_field(container_type, field_name); |
| 22377 | if (field == nullptr) { | 23337 | if (field == nullptr) { |
| 22378 | ir_add_error(ira, field_name_value, | 23338 | ir_add_error(ira, &field_name_value->base, |
| 22379 | buf_sprintf("struct '%s' has no field '%s'", | 23339 | buf_sprintf("struct '%s' has no field '%s'", |
| 22380 | buf_ptr(&container_type->name), buf_ptr(field_name))); | 23340 | buf_ptr(&container_type->name), buf_ptr(field_name))); |
| 22381 | return ira->codegen->invalid_instruction; | 23341 | return ira->codegen->invalid_inst_gen; |
| 22382 | } | 23342 | } |
| 22383 | | 23343 | |
| 22384 | if (field_ptr->value->type->id != ZigTypeIdPointer) { | 23344 | if (field_ptr->value->type->id != ZigTypeIdPointer) { |
| 22385 | ir_add_error(ira, field_ptr, | 23345 | ir_add_error(ira, &field_ptr->base, |
| 22386 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&field_ptr->value->type->name))); | 23346 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&field_ptr->value->type->name))); |
| 22387 | return ira->codegen->invalid_instruction; | 23347 | return ira->codegen->invalid_inst_gen; |
| 22388 | } | 23348 | } |
| 22389 | | 23349 | |
| 22390 | bool is_packed = (container_type->data.structure.layout == ContainerLayoutPacked); | 23350 | bool is_packed = (container_type->data.structure.layout == ContainerLayoutPacked); |
| ... | @@ -22396,9 +23356,9 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -22396,9 +23356,9 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 22396 | field_ptr->value->type->data.pointer.is_volatile, | 23356 | field_ptr->value->type->data.pointer.is_volatile, |
| 22397 | PtrLenSingle, | 23357 | PtrLenSingle, |
| 22398 | field_ptr_align, 0, 0, false); | 23358 | field_ptr_align, 0, 0, false); |
| 22399 | IrInstruction *casted_field_ptr = ir_implicit_cast(ira, field_ptr, field_ptr_type); | 23359 | IrInstGen *casted_field_ptr = ir_implicit_cast(ira, field_ptr, field_ptr_type); |
| 22400 | if (type_is_invalid(casted_field_ptr->value->type)) | 23360 | if (type_is_invalid(casted_field_ptr->value->type)) |
| 22401 | return ira->codegen->invalid_instruction; | 23361 | return ira->codegen->invalid_inst_gen; |
| 22402 | | 23362 | |
| 22403 | ZigType *result_type = get_pointer_to_type_extra(ira->codegen, container_type, | 23363 | ZigType *result_type = get_pointer_to_type_extra(ira->codegen, container_type, |
| 22404 | casted_field_ptr->value->type->data.pointer.is_const, | 23364 | casted_field_ptr->value->type->data.pointer.is_const, |
| ... | @@ -22409,23 +23369,23 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -22409,23 +23369,23 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 22409 | if (instr_is_comptime(casted_field_ptr)) { | 23369 | if (instr_is_comptime(casted_field_ptr)) { |
| 22410 | ZigValue *field_ptr_val = ir_resolve_const(ira, casted_field_ptr, UndefBad); | 23370 | ZigValue *field_ptr_val = ir_resolve_const(ira, casted_field_ptr, UndefBad); |
| 22411 | if (!field_ptr_val) | 23371 | if (!field_ptr_val) |
| 22412 | return ira->codegen->invalid_instruction; | 23372 | return ira->codegen->invalid_inst_gen; |
| 22413 | | 23373 | |
| 22414 | if (field_ptr_val->data.x_ptr.special != ConstPtrSpecialBaseStruct) { | 23374 | if (field_ptr_val->data.x_ptr.special != ConstPtrSpecialBaseStruct) { |
| 22415 | ir_add_error(ira, field_ptr, buf_sprintf("pointer value not based on parent struct")); | 23375 | ir_add_error(ira, &field_ptr->base, buf_sprintf("pointer value not based on parent struct")); |
| 22416 | return ira->codegen->invalid_instruction; | 23376 | return ira->codegen->invalid_inst_gen; |
| 22417 | } | 23377 | } |
| 22418 | | 23378 | |
| 22419 | size_t ptr_field_index = field_ptr_val->data.x_ptr.data.base_struct.field_index; | 23379 | size_t ptr_field_index = field_ptr_val->data.x_ptr.data.base_struct.field_index; |
| 22420 | if (ptr_field_index != field->src_index) { | 23380 | if (ptr_field_index != field->src_index) { |
| 22421 | ir_add_error(ira, &instruction->base, | 23381 | ir_add_error(ira, &instruction->base.base, |
| 22422 | buf_sprintf("field '%s' has index %" ZIG_PRI_usize " but pointer value is index %" ZIG_PRI_usize " of struct '%s'", | 23382 | buf_sprintf("field '%s' has index %" ZIG_PRI_usize " but pointer value is index %" ZIG_PRI_usize " of struct '%s'", |
| 22423 | buf_ptr(field->name), field->src_index, | 23383 | buf_ptr(field->name), field->src_index, |
| 22424 | ptr_field_index, buf_ptr(&container_type->name))); | 23384 | ptr_field_index, buf_ptr(&container_type->name))); |
| 22425 | return ira->codegen->invalid_instruction; | 23385 | return ira->codegen->invalid_inst_gen; |
| 22426 | } | 23386 | } |
| 22427 | | 23387 | |
| 22428 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 23388 | IrInstGen *result = ir_const(ira, &instruction->base.base, result_type); |
| 22429 | ZigValue *out_val = result->value; | 23389 | ZigValue *out_val = result->value; |
| 22430 | out_val->data.x_ptr.special = ConstPtrSpecialRef; | 23390 | out_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 22431 | out_val->data.x_ptr.data.ref.pointee = field_ptr_val->data.x_ptr.data.base_struct.struct_val; | 23391 | out_val->data.x_ptr.data.ref.pointee = field_ptr_val->data.x_ptr.data.base_struct.struct_val; |
| ... | @@ -22433,15 +23393,12 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -22433,15 +23393,12 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 22433 | return result; | 23393 | return result; |
| 22434 | } | 23394 | } |
| 22435 | | 23395 | |
| 22436 | IrInstruction *result = ir_build_field_parent_ptr(&ira->new_irb, instruction->base.scope, | 23396 | return ir_build_field_parent_ptr_gen(ira, &instruction->base.base, casted_field_ptr, field, result_type); |
| 22437 | instruction->base.source_node, type_value, field_name_value, casted_field_ptr, field); | | |
| 22438 | result->value->type = result_type; | | |
| 22439 | return result; | | |
| 22440 | } | 23397 | } |
| 22441 | | 23398 | |
| 22442 | static TypeStructField *validate_byte_offset(IrAnalyze *ira, | 23399 | static TypeStructField *validate_byte_offset(IrAnalyze *ira, |
| 22443 | IrInstruction *type_value, | 23400 | IrInstGen *type_value, |
| 22444 | IrInstruction *field_name_value, | 23401 | IrInstGen *field_name_value, |
| 22445 | size_t *byte_offset) | 23402 | size_t *byte_offset) |
| 22446 | { | 23403 | { |
| 22447 | ZigType *container_type = ir_resolve_type(ira, type_value); | 23404 | ZigType *container_type = ir_resolve_type(ira, type_value); |
| ... | @@ -22457,21 +23414,21 @@ static TypeStructField *validate_byte_offset(IrAnalyze *ira, | ... | @@ -22457,21 +23414,21 @@ static TypeStructField *validate_byte_offset(IrAnalyze *ira, |
| 22457 | return nullptr; | 23414 | return nullptr; |
| 22458 | | 23415 | |
| 22459 | if (container_type->id != ZigTypeIdStruct) { | 23416 | if (container_type->id != ZigTypeIdStruct) { |
| 22460 | ir_add_error(ira, type_value, | 23417 | ir_add_error(ira, &type_value->base, |
| 22461 | buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name))); | 23418 | buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name))); |
| 22462 | return nullptr; | 23419 | return nullptr; |
| 22463 | } | 23420 | } |
| 22464 | | 23421 | |
| 22465 | TypeStructField *field = find_struct_type_field(container_type, field_name); | 23422 | TypeStructField *field = find_struct_type_field(container_type, field_name); |
| 22466 | if (field == nullptr) { | 23423 | if (field == nullptr) { |
| 22467 | ir_add_error(ira, field_name_value, | 23424 | ir_add_error(ira, &field_name_value->base, |
| 22468 | buf_sprintf("struct '%s' has no field '%s'", | 23425 | buf_sprintf("struct '%s' has no field '%s'", |
| 22469 | buf_ptr(&container_type->name), buf_ptr(field_name))); | 23426 | buf_ptr(&container_type->name), buf_ptr(field_name))); |
| 22470 | return nullptr; | 23427 | return nullptr; |
| 22471 | } | 23428 | } |
| 22472 | | 23429 | |
| 22473 | if (!type_has_bits(field->type_entry)) { | 23430 | if (!type_has_bits(field->type_entry)) { |
| 22474 | ir_add_error(ira, field_name_value, | 23431 | ir_add_error(ira, &field_name_value->base, |
| 22475 | buf_sprintf("zero-bit field '%s' in struct '%s' has no offset", | 23432 | buf_sprintf("zero-bit field '%s' in struct '%s' has no offset", |
| 22476 | buf_ptr(field_name), buf_ptr(&container_type->name))); | 23433 | buf_ptr(field_name), buf_ptr(&container_type->name))); |
| 22477 | return nullptr; | 23434 | return nullptr; |
| ... | @@ -22481,36 +23438,32 @@ static TypeStructField *validate_byte_offset(IrAnalyze *ira, | ... | @@ -22481,36 +23438,32 @@ static TypeStructField *validate_byte_offset(IrAnalyze *ira, |
| 22481 | return field; | 23438 | return field; |
| 22482 | } | 23439 | } |
| 22483 | | 23440 | |
| 22484 | static IrInstruction *ir_analyze_instruction_byte_offset_of(IrAnalyze *ira, | 23441 | static IrInstGen *ir_analyze_instruction_byte_offset_of(IrAnalyze *ira, IrInstSrcByteOffsetOf *instruction) { |
| 22485 | IrInstructionByteOffsetOf *instruction) | 23442 | IrInstGen *type_value = instruction->type_value->child; |
| 22486 | { | | |
| 22487 | IrInstruction *type_value = instruction->type_value->child; | | |
| 22488 | if (type_is_invalid(type_value->value->type)) | 23443 | if (type_is_invalid(type_value->value->type)) |
| 22489 | return ira->codegen->invalid_instruction; | 23444 | return ira->codegen->invalid_inst_gen; |
| 22490 | | 23445 | |
| 22491 | IrInstruction *field_name_value = instruction->field_name->child; | 23446 | IrInstGen *field_name_value = instruction->field_name->child; |
| 22492 | size_t byte_offset = 0; | 23447 | size_t byte_offset = 0; |
| 22493 | if (!validate_byte_offset(ira, type_value, field_name_value, &byte_offset)) | 23448 | if (!validate_byte_offset(ira, type_value, field_name_value, &byte_offset)) |
| 22494 | return ira->codegen->invalid_instruction; | 23449 | return ira->codegen->invalid_inst_gen; |
| 22495 | | 23450 | |
| 22496 | | 23451 | |
| 22497 | return ir_const_unsigned(ira, &instruction->base, byte_offset); | 23452 | return ir_const_unsigned(ira, &instruction->base.base, byte_offset); |
| 22498 | } | 23453 | } |
| 22499 | | 23454 | |
| 22500 | static IrInstruction *ir_analyze_instruction_bit_offset_of(IrAnalyze *ira, | 23455 | static IrInstGen *ir_analyze_instruction_bit_offset_of(IrAnalyze *ira, IrInstSrcBitOffsetOf *instruction) { |
| 22501 | IrInstructionBitOffsetOf *instruction) | 23456 | IrInstGen *type_value = instruction->type_value->child; |
| 22502 | { | | |
| 22503 | IrInstruction *type_value = instruction->type_value->child; | | |
| 22504 | if (type_is_invalid(type_value->value->type)) | 23457 | if (type_is_invalid(type_value->value->type)) |
| 22505 | return ira->codegen->invalid_instruction; | 23458 | return ira->codegen->invalid_inst_gen; |
| 22506 | IrInstruction *field_name_value = instruction->field_name->child; | 23459 | IrInstGen *field_name_value = instruction->field_name->child; |
| 22507 | size_t byte_offset = 0; | 23460 | size_t byte_offset = 0; |
| 22508 | TypeStructField *field = nullptr; | 23461 | TypeStructField *field = nullptr; |
| 22509 | if (!(field = validate_byte_offset(ira, type_value, field_name_value, &byte_offset))) | 23462 | if (!(field = validate_byte_offset(ira, type_value, field_name_value, &byte_offset))) |
| 22510 | return ira->codegen->invalid_instruction; | 23463 | return ira->codegen->invalid_inst_gen; |
| 22511 | | 23464 | |
| 22512 | size_t bit_offset = byte_offset * 8 + field->bit_offset_in_host; | 23465 | size_t bit_offset = byte_offset * 8 + field->bit_offset_in_host; |
| 22513 | return ir_const_unsigned(ira, &instruction->base, bit_offset); | 23466 | return ir_const_unsigned(ira, &instruction->base.base, bit_offset); |
| 22514 | } | 23467 | } |
| 22515 | | 23468 | |
| 22516 | static void ensure_field_index(ZigType *type, const char *field_name, size_t index) { | 23469 | static void ensure_field_index(ZigType *type, const char *field_name, size_t index) { |
| ... | @@ -22558,7 +23511,7 @@ static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, Zig | ... | @@ -22558,7 +23511,7 @@ static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, Zig |
| 22558 | return ir_resolve_const_type(ira->codegen, ira->new_irb.exec, nullptr, var->const_value); | 23511 | return ir_resolve_const_type(ira->codegen, ira->new_irb.exec, nullptr, var->const_value); |
| 22559 | } | 23512 | } |
| 22560 | | 23513 | |
| 22561 | static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr, ZigValue *out_val, | 23514 | static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigValue *out_val, |
| 22562 | ScopeDecls *decls_scope) | 23515 | ScopeDecls *decls_scope) |
| 22563 | { | 23516 | { |
| 22564 | Error err; | 23517 | Error err; |
| ... | @@ -22589,11 +23542,14 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22589,11 +23542,14 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 22589 | | 23542 | |
| 22590 | while ((curr_entry = decl_it.next()) != nullptr) { | 23543 | while ((curr_entry = decl_it.next()) != nullptr) { |
| 22591 | // If the declaration is unresolved, force it to be resolved again. | 23544 | // If the declaration is unresolved, force it to be resolved again. |
| 22592 | if (curr_entry->value->resolution == TldResolutionUnresolved) { | 23545 | resolve_top_level_decl(ira->codegen, curr_entry->value, curr_entry->value->source_node, false); |
| 22593 | resolve_top_level_decl(ira->codegen, curr_entry->value, curr_entry->value->source_node, false); | 23546 | if (curr_entry->value->resolution == TldResolutionInvalid) { |
| 22594 | if (curr_entry->value->resolution != TldResolutionOk) { | 23547 | return ErrorSemanticAnalyzeFail; |
| 22595 | return ErrorSemanticAnalyzeFail; | 23548 | } |
| 22596 | } | 23549 | |
| | 23550 | if (curr_entry->value->resolution == TldResolutionResolving) { |
| | 23551 | ir_error_dependency_loop(ira, source_instr); |
| | 23552 | return ErrorSemanticAnalyzeFail; |
| 22597 | } | 23553 | } |
| 22598 | | 23554 | |
| 22599 | // Skip comptime blocks and test functions. | 23555 | // Skip comptime blocks and test functions. |
| ... | @@ -22650,6 +23606,8 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22650,6 +23606,8 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 22650 | case TldIdVar: | 23606 | case TldIdVar: |
| 22651 | { | 23607 | { |
| 22652 | ZigVar *var = ((TldVar *)curr_entry->value)->var; | 23608 | ZigVar *var = ((TldVar *)curr_entry->value)->var; |
| | 23609 | assert(var != nullptr); |
| | 23610 | |
| 22653 | if ((err = type_resolve(ira->codegen, var->const_value->type, ResolveStatusSizeKnown))) | 23611 | if ((err = type_resolve(ira->codegen, var->const_value->type, ResolveStatusSizeKnown))) |
| 22654 | return ErrorSemanticAnalyzeFail; | 23612 | return ErrorSemanticAnalyzeFail; |
| 22655 | | 23613 | |
| ... | @@ -22680,11 +23638,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -22680,11 +23638,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 22680 | | 23638 | |
| 22681 | ZigFn *fn_entry = ((TldFn *)curr_entry->value)->fn_entry; | 23639 | ZigFn *fn_entry = ((TldFn *)curr_entry->value)->fn_entry; |
| 22682 | assert(!fn_entry->is_test); | 23640 | assert(!fn_entry->is_test); |
| 22683 | | 23641 | assert(fn_entry->type_entry != nullptr); |
| 22684 | if (fn_entry->type_entry == nullptr) { | | |
| 22685 | ir_error_dependency_loop(ira, source_instr); | | |
| 22686 | return ErrorSemanticAnalyzeFail; | | |
| 22687 | } | | |
| 22688 | | 23642 | |
| 22689 | AstNodeFnProto *fn_node = &fn_entry->proto_node->data.fn_proto; | 23643 | AstNodeFnProto *fn_node = &fn_entry->proto_node->data.fn_proto; |
| 22690 | | 23644 | |
| ... | @@ -22916,7 +23870,7 @@ static void make_enum_field_val(IrAnalyze *ira, ZigValue *enum_field_val, TypeEn | ... | @@ -22916,7 +23870,7 @@ static void make_enum_field_val(IrAnalyze *ira, ZigValue *enum_field_val, TypeEn |
| 22916 | enum_field_val->data.x_struct.fields = inner_fields; | 23870 | enum_field_val->data.x_struct.fields = inner_fields; |
| 22917 | } | 23871 | } |
| 22918 | | 23872 | |
| 22919 | static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr, ZigType *type_entry, | 23873 | static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigType *type_entry, |
| 22920 | ZigValue **out) | 23874 | ZigValue **out) |
| 22921 | { | 23875 | { |
| 22922 | Error err; | 23876 | Error err; |
| ... | @@ -23079,7 +24033,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -23079,7 +24033,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 23079 | result->special = ConstValSpecialStatic; | 24033 | result->special = ConstValSpecialStatic; |
| 23080 | result->type = ir_type_info_get_type(ira, "Enum", nullptr); | 24034 | result->type = ir_type_info_get_type(ira, "Enum", nullptr); |
| 23081 | | 24035 | |
| 23082 | ZigValue **fields = alloc_const_vals_ptrs(4); | 24036 | ZigValue **fields = alloc_const_vals_ptrs(5); |
| 23083 | result->data.x_struct.fields = fields; | 24037 | result->data.x_struct.fields = fields; |
| 23084 | | 24038 | |
| 23085 | // layout: ContainerLayout | 24039 | // layout: ContainerLayout |
| ... | @@ -23125,6 +24079,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -23125,6 +24079,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 23125 | { | 24079 | { |
| 23126 | return err; | 24080 | return err; |
| 23127 | } | 24081 | } |
| | 24082 | // is_exhaustive: bool |
| | 24083 | ensure_field_index(result->type, "is_exhaustive", 4); |
| | 24084 | fields[4]->special = ConstValSpecialStatic; |
| | 24085 | fields[4]->type = ira->codegen->builtin_types.entry_bool; |
| | 24086 | fields[4]->data.x_bool = !type_entry->data.enumeration.non_exhaustive; |
| 23128 | | 24087 | |
| 23129 | break; | 24088 | break; |
| 23130 | } | 24089 | } |
| ... | @@ -23499,22 +24458,20 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -23499,22 +24458,20 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 23499 | return ErrorNone; | 24458 | return ErrorNone; |
| 23500 | } | 24459 | } |
| 23501 | | 24460 | |
| 23502 | static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, | 24461 | static IrInstGen *ir_analyze_instruction_type_info(IrAnalyze *ira, IrInstSrcTypeInfo *instruction) { |
| 23503 | IrInstructionTypeInfo *instruction) | | |
| 23504 | { | | |
| 23505 | Error err; | 24462 | Error err; |
| 23506 | IrInstruction *type_value = instruction->type_value->child; | 24463 | IrInstGen *type_value = instruction->type_value->child; |
| 23507 | ZigType *type_entry = ir_resolve_type(ira, type_value); | 24464 | ZigType *type_entry = ir_resolve_type(ira, type_value); |
| 23508 | if (type_is_invalid(type_entry)) | 24465 | if (type_is_invalid(type_entry)) |
| 23509 | return ira->codegen->invalid_instruction; | 24466 | return ira->codegen->invalid_inst_gen; |
| 23510 | | 24467 | |
| 23511 | ZigType *result_type = ir_type_info_get_type(ira, nullptr, nullptr); | 24468 | ZigType *result_type = ir_type_info_get_type(ira, nullptr, nullptr); |
| 23512 | | 24469 | |
| 23513 | ZigValue *payload; | 24470 | ZigValue *payload; |
| 23514 | if ((err = ir_make_type_info_value(ira, &instruction->base, type_entry, &payload))) | 24471 | if ((err = ir_make_type_info_value(ira, &instruction->base.base, type_entry, &payload))) |
| 23515 | return ira->codegen->invalid_instruction; | 24472 | return ira->codegen->invalid_inst_gen; |
| 23516 | | 24473 | |
| 23517 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 24474 | IrInstGen *result = ir_const(ira, &instruction->base.base, result_type); |
| 23518 | ZigValue *out_val = result->value; | 24475 | ZigValue *out_val = result->value; |
| 23519 | bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry)); | 24476 | bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry)); |
| 23520 | out_val->data.x_union.payload = payload; | 24477 | out_val->data.x_union.payload = payload; |
| ... | @@ -23538,15 +24495,15 @@ static ZigValue *get_const_field(IrAnalyze *ira, AstNode *source_node, ZigValue | ... | @@ -23538,15 +24495,15 @@ static ZigValue *get_const_field(IrAnalyze *ira, AstNode *source_node, ZigValue |
| 23538 | return val; | 24495 | return val; |
| 23539 | } | 24496 | } |
| 23540 | | 24497 | |
| 23541 | static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_instr, ZigValue *struct_value, | 24498 | static Error get_const_field_sentinel(IrAnalyze *ira, IrInst* source_instr, ZigValue *struct_value, |
| 23542 | const char *name, size_t field_index, ZigType *elem_type, ZigValue **result) | 24499 | const char *name, size_t field_index, ZigType *elem_type, ZigValue **result) |
| 23543 | { | 24500 | { |
| 23544 | ZigValue *field_val = get_const_field(ira, source_instr->source_node, struct_value, name, field_index); | 24501 | ZigValue *field_val = get_const_field(ira, source_instr->source_node, struct_value, name, field_index); |
| 23545 | if (field_val == nullptr) | 24502 | if (field_val == nullptr) |
| 23546 | return ErrorSemanticAnalyzeFail; | 24503 | return ErrorSemanticAnalyzeFail; |
| 23547 | | 24504 | |
| 23548 | IrInstruction *field_inst = ir_const_move(ira, source_instr, field_val); | 24505 | IrInstGen *field_inst = ir_const_move(ira, source_instr, field_val); |
| 23549 | IrInstruction *casted_field_inst = ir_implicit_cast(ira, field_inst, | 24506 | IrInstGen *casted_field_inst = ir_implicit_cast(ira, field_inst, |
| 23550 | get_optional_type(ira->codegen, elem_type)); | 24507 | get_optional_type(ira->codegen, elem_type)); |
| 23551 | if (type_is_invalid(casted_field_inst->value->type)) | 24508 | if (type_is_invalid(casted_field_inst->value->type)) |
| 23552 | return ErrorSemanticAnalyzeFail; | 24509 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -23585,12 +24542,12 @@ static ZigType *get_const_field_meta_type(IrAnalyze *ira, AstNode *source_node, | ... | @@ -23585,12 +24542,12 @@ static ZigType *get_const_field_meta_type(IrAnalyze *ira, AstNode *source_node, |
| 23585 | { | 24542 | { |
| 23586 | ZigValue *value = get_const_field(ira, source_node, struct_value, name, field_index); | 24543 | ZigValue *value = get_const_field(ira, source_node, struct_value, name, field_index); |
| 23587 | if (value == nullptr) | 24544 | if (value == nullptr) |
| 23588 | return ira->codegen->invalid_instruction->value->type; | 24545 | return ira->codegen->invalid_inst_gen->value->type; |
| 23589 | assert(value->type == ira->codegen->builtin_types.entry_type); | 24546 | assert(value->type == ira->codegen->builtin_types.entry_type); |
| 23590 | return value->data.x_type; | 24547 | return value->data.x_type; |
| 23591 | } | 24548 | } |
| 23592 | | 24549 | |
| 23593 | static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, ZigTypeId tagTypeId, ZigValue *payload) { | 24550 | static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeId tagTypeId, ZigValue *payload) { |
| 23594 | Error err; | 24551 | Error err; |
| 23595 | switch (tagTypeId) { | 24552 | switch (tagTypeId) { |
| 23596 | case ZigTypeIdInvalid: | 24553 | case ZigTypeIdInvalid: |
| ... | @@ -23606,21 +24563,21 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi | ... | @@ -23606,21 +24563,21 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 23606 | case ZigTypeIdInt: { | 24563 | case ZigTypeIdInt: { |
| 23607 | assert(payload->special == ConstValSpecialStatic); | 24564 | assert(payload->special == ConstValSpecialStatic); |
| 23608 | assert(payload->type == ir_type_info_get_type(ira, "Int", nullptr)); | 24565 | assert(payload->type == ir_type_info_get_type(ira, "Int", nullptr)); |
| 23609 | BigInt *bi = get_const_field_lit_int(ira, instruction->source_node, payload, "bits", 1); | 24566 | BigInt *bi = get_const_field_lit_int(ira, source_instr->source_node, payload, "bits", 1); |
| 23610 | if (bi == nullptr) | 24567 | if (bi == nullptr) |
| 23611 | return ira->codegen->invalid_instruction->value->type; | 24568 | return ira->codegen->invalid_inst_gen->value->type; |
| 23612 | bool is_signed; | 24569 | bool is_signed; |
| 23613 | if ((err = get_const_field_bool(ira, instruction->source_node, payload, "is_signed", 0, &is_signed))) | 24570 | if ((err = get_const_field_bool(ira, source_instr->source_node, payload, "is_signed", 0, &is_signed))) |
| 23614 | return ira->codegen->invalid_instruction->value->type; | 24571 | return ira->codegen->invalid_inst_gen->value->type; |
| 23615 | return get_int_type(ira->codegen, is_signed, bigint_as_u32(bi)); | 24572 | return get_int_type(ira->codegen, is_signed, bigint_as_u32(bi)); |
| 23616 | } | 24573 | } |
| 23617 | case ZigTypeIdFloat: | 24574 | case ZigTypeIdFloat: |
| 23618 | { | 24575 | { |
| 23619 | assert(payload->special == ConstValSpecialStatic); | 24576 | assert(payload->special == ConstValSpecialStatic); |
| 23620 | assert(payload->type == ir_type_info_get_type(ira, "Float", nullptr)); | 24577 | assert(payload->type == ir_type_info_get_type(ira, "Float", nullptr)); |
| 23621 | BigInt *bi = get_const_field_lit_int(ira, instruction->source_node, payload, "bits", 0); | 24578 | BigInt *bi = get_const_field_lit_int(ira, source_instr->source_node, payload, "bits", 0); |
| 23622 | if (bi == nullptr) | 24579 | if (bi == nullptr) |
| 23623 | return ira->codegen->invalid_instruction->value->type; | 24580 | return ira->codegen->invalid_inst_gen->value->type; |
| 23624 | uint32_t bits = bigint_as_u32(bi); | 24581 | uint32_t bits = bigint_as_u32(bi); |
| 23625 | switch (bits) { | 24582 | switch (bits) { |
| 23626 | case 16: return ira->codegen->builtin_types.entry_f16; | 24583 | case 16: return ira->codegen->builtin_types.entry_f16; |
| ... | @@ -23628,48 +24585,47 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi | ... | @@ -23628,48 +24585,47 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 23628 | case 64: return ira->codegen->builtin_types.entry_f64; | 24585 | case 64: return ira->codegen->builtin_types.entry_f64; |
| 23629 | case 128: return ira->codegen->builtin_types.entry_f128; | 24586 | case 128: return ira->codegen->builtin_types.entry_f128; |
| 23630 | } | 24587 | } |
| 23631 | ir_add_error(ira, instruction, | 24588 | ir_add_error(ira, source_instr, buf_sprintf("%d-bit float unsupported", bits)); |
| 23632 | buf_sprintf("%d-bit float unsupported", bits)); | 24589 | return ira->codegen->invalid_inst_gen->value->type; |
| 23633 | return ira->codegen->invalid_instruction->value->type; | | |
| 23634 | } | 24590 | } |
| 23635 | case ZigTypeIdPointer: | 24591 | case ZigTypeIdPointer: |
| 23636 | { | 24592 | { |
| 23637 | ZigType *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr); | 24593 | ZigType *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr); |
| 23638 | assert(payload->special == ConstValSpecialStatic); | 24594 | assert(payload->special == ConstValSpecialStatic); |
| 23639 | assert(payload->type == type_info_pointer_type); | 24595 | assert(payload->type == type_info_pointer_type); |
| 23640 | ZigValue *size_value = get_const_field(ira, instruction->source_node, payload, "size", 0); | 24596 | ZigValue *size_value = get_const_field(ira, source_instr->source_node, payload, "size", 0); |
| 23641 | assert(size_value->type == ir_type_info_get_type(ira, "Size", type_info_pointer_type)); | 24597 | assert(size_value->type == ir_type_info_get_type(ira, "Size", type_info_pointer_type)); |
| 23642 | BuiltinPtrSize size_enum_index = (BuiltinPtrSize)bigint_as_u32(&size_value->data.x_enum_tag); | 24598 | BuiltinPtrSize size_enum_index = (BuiltinPtrSize)bigint_as_u32(&size_value->data.x_enum_tag); |
| 23643 | PtrLen ptr_len = size_enum_index_to_ptr_len(size_enum_index); | 24599 | PtrLen ptr_len = size_enum_index_to_ptr_len(size_enum_index); |
| 23644 | ZigType *elem_type = get_const_field_meta_type(ira, instruction->source_node, payload, "child", 4); | 24600 | ZigType *elem_type = get_const_field_meta_type(ira, source_instr->source_node, payload, "child", 4); |
| 23645 | if (type_is_invalid(elem_type)) | 24601 | if (type_is_invalid(elem_type)) |
| 23646 | return ira->codegen->invalid_instruction->value->type; | 24602 | return ira->codegen->invalid_inst_gen->value->type; |
| 23647 | ZigValue *sentinel; | 24603 | ZigValue *sentinel; |
| 23648 | if ((err = get_const_field_sentinel(ira, instruction, payload, "sentinel", 6, | 24604 | if ((err = get_const_field_sentinel(ira, source_instr, payload, "sentinel", 6, |
| 23649 | elem_type, &sentinel))) | 24605 | elem_type, &sentinel))) |
| 23650 | { | 24606 | { |
| 23651 | return ira->codegen->invalid_instruction->value->type; | 24607 | return ira->codegen->invalid_inst_gen->value->type; |
| 23652 | } | 24608 | } |
| 23653 | BigInt *bi = get_const_field_lit_int(ira, instruction->source_node, payload, "alignment", 3); | 24609 | BigInt *bi = get_const_field_lit_int(ira, source_instr->source_node, payload, "alignment", 3); |
| 23654 | if (bi == nullptr) | 24610 | if (bi == nullptr) |
| 23655 | return ira->codegen->invalid_instruction->value->type; | 24611 | return ira->codegen->invalid_inst_gen->value->type; |
| 23656 | | 24612 | |
| 23657 | bool is_const; | 24613 | bool is_const; |
| 23658 | if ((err = get_const_field_bool(ira, instruction->source_node, payload, "is_const", 1, &is_const))) | 24614 | if ((err = get_const_field_bool(ira, source_instr->source_node, payload, "is_const", 1, &is_const))) |
| 23659 | return ira->codegen->invalid_instruction->value->type; | 24615 | return ira->codegen->invalid_inst_gen->value->type; |
| 23660 | | 24616 | |
| 23661 | bool is_volatile; | 24617 | bool is_volatile; |
| 23662 | if ((err = get_const_field_bool(ira, instruction->source_node, payload, "is_volatile", 2, | 24618 | if ((err = get_const_field_bool(ira, source_instr->source_node, payload, "is_volatile", 2, |
| 23663 | &is_volatile))) | 24619 | &is_volatile))) |
| 23664 | { | 24620 | { |
| 23665 | return ira->codegen->invalid_instruction->value->type; | 24621 | return ira->codegen->invalid_inst_gen->value->type; |
| 23666 | } | 24622 | } |
| 23667 | | 24623 | |
| 23668 | bool is_allowzero; | 24624 | bool is_allowzero; |
| 23669 | if ((err = get_const_field_bool(ira, instruction->source_node, payload, "is_allowzero", 5, | 24625 | if ((err = get_const_field_bool(ira, source_instr->source_node, payload, "is_allowzero", 5, |
| 23670 | &is_allowzero))) | 24626 | &is_allowzero))) |
| 23671 | { | 24627 | { |
| 23672 | return ira->codegen->invalid_instruction->value->type; | 24628 | return ira->codegen->invalid_inst_gen->value->type; |
| 23673 | } | 24629 | } |
| 23674 | | 24630 | |
| 23675 | | 24631 | |
| ... | @@ -23690,18 +24646,18 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi | ... | @@ -23690,18 +24646,18 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 23690 | case ZigTypeIdArray: { | 24646 | case ZigTypeIdArray: { |
| 23691 | assert(payload->special == ConstValSpecialStatic); | 24647 | assert(payload->special == ConstValSpecialStatic); |
| 23692 | assert(payload->type == ir_type_info_get_type(ira, "Array", nullptr)); | 24648 | assert(payload->type == ir_type_info_get_type(ira, "Array", nullptr)); |
| 23693 | ZigType *elem_type = get_const_field_meta_type(ira, instruction->source_node, payload, "child", 1); | 24649 | ZigType *elem_type = get_const_field_meta_type(ira, source_instr->source_node, payload, "child", 1); |
| 23694 | if (type_is_invalid(elem_type)) | 24650 | if (type_is_invalid(elem_type)) |
| 23695 | return ira->codegen->invalid_instruction->value->type; | 24651 | return ira->codegen->invalid_inst_gen->value->type; |
| 23696 | ZigValue *sentinel; | 24652 | ZigValue *sentinel; |
| 23697 | if ((err = get_const_field_sentinel(ira, instruction, payload, "sentinel", 2, | 24653 | if ((err = get_const_field_sentinel(ira, source_instr, payload, "sentinel", 2, |
| 23698 | elem_type, &sentinel))) | 24654 | elem_type, &sentinel))) |
| 23699 | { | 24655 | { |
| 23700 | return ira->codegen->invalid_instruction->value->type; | 24656 | return ira->codegen->invalid_inst_gen->value->type; |
| 23701 | } | 24657 | } |
| 23702 | BigInt *bi = get_const_field_lit_int(ira, instruction->source_node, payload, "len", 0); | 24658 | BigInt *bi = get_const_field_lit_int(ira, source_instr->source_node, payload, "len", 0); |
| 23703 | if (bi == nullptr) | 24659 | if (bi == nullptr) |
| 23704 | return ira->codegen->invalid_instruction->value->type; | 24660 | return ira->codegen->invalid_inst_gen->value->type; |
| 23705 | return get_array_type(ira->codegen, elem_type, bigint_as_u64(bi), sentinel); | 24661 | return get_array_type(ira->codegen, elem_type, bigint_as_u64(bi), sentinel); |
| 23706 | } | 24662 | } |
| 23707 | case ZigTypeIdComptimeFloat: | 24663 | case ZigTypeIdComptimeFloat: |
| ... | @@ -23721,78 +24677,77 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi | ... | @@ -23721,78 +24677,77 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 23721 | case ZigTypeIdAnyFrame: | 24677 | case ZigTypeIdAnyFrame: |
| 23722 | case ZigTypeIdVector: | 24678 | case ZigTypeIdVector: |
| 23723 | case ZigTypeIdEnumLiteral: | 24679 | case ZigTypeIdEnumLiteral: |
| 23724 | ir_add_error(ira, instruction, buf_sprintf( | 24680 | ir_add_error(ira, source_instr, buf_sprintf( |
| 23725 | "TODO implement @Type for 'TypeInfo.%s': see https://github.com/ziglang/zig/issues/2907", type_id_name(tagTypeId))); | 24681 | "TODO implement @Type for 'TypeInfo.%s': see https://github.com/ziglang/zig/issues/2907", type_id_name(tagTypeId))); |
| 23726 | return ira->codegen->invalid_instruction->value->type; | 24682 | return ira->codegen->invalid_inst_gen->value->type; |
| 23727 | case ZigTypeIdUnion: | 24683 | case ZigTypeIdUnion: |
| 23728 | case ZigTypeIdFn: | 24684 | case ZigTypeIdFn: |
| 23729 | case ZigTypeIdBoundFn: | 24685 | case ZigTypeIdBoundFn: |
| 23730 | case ZigTypeIdStruct: | 24686 | case ZigTypeIdStruct: |
| 23731 | ir_add_error(ira, instruction, buf_sprintf( | 24687 | ir_add_error(ira, source_instr, buf_sprintf( |
| 23732 | "@Type not availble for 'TypeInfo.%s'", type_id_name(tagTypeId))); | 24688 | "@Type not availble for 'TypeInfo.%s'", type_id_name(tagTypeId))); |
| 23733 | return ira->codegen->invalid_instruction->value->type; | 24689 | return ira->codegen->invalid_inst_gen->value->type; |
| 23734 | } | 24690 | } |
| 23735 | zig_unreachable(); | 24691 | zig_unreachable(); |
| 23736 | } | 24692 | } |
| 23737 | | 24693 | |
| 23738 | static IrInstruction *ir_analyze_instruction_type(IrAnalyze *ira, IrInstructionType *instruction) { | 24694 | static IrInstGen *ir_analyze_instruction_type(IrAnalyze *ira, IrInstSrcType *instruction) { |
| 23739 | IrInstruction *type_info_ir = instruction->type_info->child; | 24695 | IrInstGen *uncasted_type_info = instruction->type_info->child; |
| 23740 | if (type_is_invalid(type_info_ir->value->type)) | 24696 | if (type_is_invalid(uncasted_type_info->value->type)) |
| 23741 | return ira->codegen->invalid_instruction; | 24697 | return ira->codegen->invalid_inst_gen; |
| 23742 | | 24698 | |
| 23743 | IrInstruction *casted_ir = ir_implicit_cast(ira, type_info_ir, ir_type_info_get_type(ira, nullptr, nullptr)); | 24699 | IrInstGen *type_info = ir_implicit_cast(ira, uncasted_type_info, ir_type_info_get_type(ira, nullptr, nullptr)); |
| 23744 | if (type_is_invalid(casted_ir->value->type)) | 24700 | if (type_is_invalid(type_info->value->type)) |
| 23745 | return ira->codegen->invalid_instruction; | 24701 | return ira->codegen->invalid_inst_gen; |
| 23746 | | 24702 | |
| 23747 | ZigValue *type_info_value = ir_resolve_const(ira, casted_ir, UndefBad); | 24703 | ZigValue *type_info_val = ir_resolve_const(ira, type_info, UndefBad); |
| 23748 | if (!type_info_value) | 24704 | if (type_info_val == nullptr) |
| 23749 | return ira->codegen->invalid_instruction; | 24705 | return ira->codegen->invalid_inst_gen; |
| 23750 | ZigTypeId typeId = type_id_at_index(bigint_as_usize(&type_info_value->data.x_union.tag)); | 24706 | ZigTypeId type_id_tag = type_id_at_index(bigint_as_usize(&type_info_val->data.x_union.tag)); |
| 23751 | ZigType *type = type_info_to_type(ira, type_info_ir, typeId, type_info_value->data.x_union.payload); | 24707 | ZigType *type = type_info_to_type(ira, &uncasted_type_info->base, type_id_tag, |
| | 24708 | type_info_val->data.x_union.payload); |
| 23752 | if (type_is_invalid(type)) | 24709 | if (type_is_invalid(type)) |
| 23753 | return ira->codegen->invalid_instruction; | 24710 | return ira->codegen->invalid_inst_gen; |
| 23754 | return ir_const_type(ira, &instruction->base, type); | 24711 | return ir_const_type(ira, &instruction->base.base, type); |
| 23755 | } | 24712 | } |
| 23756 | | 24713 | |
| 23757 | static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira, | 24714 | static IrInstGen *ir_analyze_instruction_type_id(IrAnalyze *ira, IrInstSrcTypeId *instruction) { |
| 23758 | IrInstructionTypeId *instruction) | 24715 | IrInstGen *type_value = instruction->type_value->child; |
| 23759 | { | | |
| 23760 | IrInstruction *type_value = instruction->type_value->child; | | |
| 23761 | ZigType *type_entry = ir_resolve_type(ira, type_value); | 24716 | ZigType *type_entry = ir_resolve_type(ira, type_value); |
| 23762 | if (type_is_invalid(type_entry)) | 24717 | if (type_is_invalid(type_entry)) |
| 23763 | return ira->codegen->invalid_instruction; | 24718 | return ira->codegen->invalid_inst_gen; |
| 23764 | | 24719 | |
| 23765 | ZigType *result_type = get_builtin_type(ira->codegen, "TypeId"); | 24720 | ZigType *result_type = get_builtin_type(ira->codegen, "TypeId"); |
| 23766 | | 24721 | |
| 23767 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 24722 | IrInstGen *result = ir_const(ira, &instruction->base.base, result_type); |
| 23768 | bigint_init_unsigned(&result->value->data.x_enum_tag, type_id_index(type_entry)); | 24723 | bigint_init_unsigned(&result->value->data.x_enum_tag, type_id_index(type_entry)); |
| 23769 | return result; | 24724 | return result; |
| 23770 | } | 24725 | } |
| 23771 | | 24726 | |
| 23772 | static IrInstruction *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira, | 24727 | static IrInstGen *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira, |
| 23773 | IrInstructionSetEvalBranchQuota *instruction) | 24728 | IrInstSrcSetEvalBranchQuota *instruction) |
| 23774 | { | 24729 | { |
| 23775 | uint64_t new_quota; | 24730 | uint64_t new_quota; |
| 23776 | if (!ir_resolve_usize(ira, instruction->new_quota->child, &new_quota)) | 24731 | if (!ir_resolve_usize(ira, instruction->new_quota->child, &new_quota)) |
| 23777 | return ira->codegen->invalid_instruction; | 24732 | return ira->codegen->invalid_inst_gen; |
| 23778 | | 24733 | |
| 23779 | if (new_quota > *ira->new_irb.exec->backward_branch_quota) { | 24734 | if (new_quota > *ira->new_irb.exec->backward_branch_quota) { |
| 23780 | *ira->new_irb.exec->backward_branch_quota = new_quota; | 24735 | *ira->new_irb.exec->backward_branch_quota = new_quota; |
| 23781 | } | 24736 | } |
| 23782 | | 24737 | |
| 23783 | return ir_const_void(ira, &instruction->base); | 24738 | return ir_const_void(ira, &instruction->base.base); |
| 23784 | } | 24739 | } |
| 23785 | | 24740 | |
| 23786 | static IrInstruction *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstructionTypeName *instruction) { | 24741 | static IrInstGen *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstSrcTypeName *instruction) { |
| 23787 | IrInstruction *type_value = instruction->type_value->child; | 24742 | IrInstGen *type_value = instruction->type_value->child; |
| 23788 | ZigType *type_entry = ir_resolve_type(ira, type_value); | 24743 | ZigType *type_entry = ir_resolve_type(ira, type_value); |
| 23789 | if (type_is_invalid(type_entry)) | 24744 | if (type_is_invalid(type_entry)) |
| 23790 | return ira->codegen->invalid_instruction; | 24745 | return ira->codegen->invalid_inst_gen; |
| 23791 | | 24746 | |
| 23792 | if (!type_entry->cached_const_name_val) { | 24747 | if (!type_entry->cached_const_name_val) { |
| 23793 | type_entry->cached_const_name_val = create_const_str_lit(ira->codegen, type_bare_name(type_entry)); | 24748 | type_entry->cached_const_name_val = create_const_str_lit(ira->codegen, type_bare_name(type_entry)); |
| 23794 | } | 24749 | } |
| 23795 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 24750 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 23796 | copy_const_val(result->value, type_entry->cached_const_name_val); | 24751 | copy_const_val(result->value, type_entry->cached_const_name_val); |
| 23797 | return result; | 24752 | return result; |
| 23798 | } | 24753 | } |
| ... | @@ -23804,13 +24759,13 @@ static void ir_cimport_cache_paths(Buf *cache_dir, Buf *tmp_c_file_digest, Buf * | ... | @@ -23804,13 +24759,13 @@ static void ir_cimport_cache_paths(Buf *cache_dir, Buf *tmp_c_file_digest, Buf * |
| 23804 | buf_ptr(cache_dir), buf_ptr(tmp_c_file_digest)); | 24759 | buf_ptr(cache_dir), buf_ptr(tmp_c_file_digest)); |
| 23805 | buf_appendf(out_zig_path, "%s" OS_SEP "cimport.zig", buf_ptr(out_zig_dir)); | 24760 | buf_appendf(out_zig_path, "%s" OS_SEP "cimport.zig", buf_ptr(out_zig_dir)); |
| 23806 | } | 24761 | } |
| 23807 | static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstructionCImport *instruction) { | 24762 | static IrInstGen *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstSrcCImport *instruction) { |
| 23808 | Error err; | 24763 | Error err; |
| 23809 | AstNode *node = instruction->base.source_node; | 24764 | AstNode *node = instruction->base.base.source_node; |
| 23810 | assert(node->type == NodeTypeFnCallExpr); | 24765 | assert(node->type == NodeTypeFnCallExpr); |
| 23811 | AstNode *block_node = node->data.fn_call_expr.params.at(0); | 24766 | AstNode *block_node = node->data.fn_call_expr.params.at(0); |
| 23812 | | 24767 | |
| 23813 | ScopeCImport *cimport_scope = create_cimport_scope(ira->codegen, node, instruction->base.scope); | 24768 | ScopeCImport *cimport_scope = create_cimport_scope(ira->codegen, node, instruction->base.base.scope); |
| 23814 | | 24769 | |
| 23815 | // Execute the C import block like an inline function | 24770 | // Execute the C import block like an inline function |
| 23816 | ZigType *void_type = ira->codegen->builtin_types.entry_void; | 24771 | ZigType *void_type = ira->codegen->builtin_types.entry_void; |
| ... | @@ -23821,13 +24776,13 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -23821,13 +24776,13 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 23821 | ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, nullptr, | 24776 | ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, nullptr, |
| 23822 | &cimport_scope->buf, block_node, nullptr, nullptr, nullptr, UndefBad))) | 24777 | &cimport_scope->buf, block_node, nullptr, nullptr, nullptr, UndefBad))) |
| 23823 | { | 24778 | { |
| 23824 | return ira->codegen->invalid_instruction; | 24779 | return ira->codegen->invalid_inst_gen; |
| 23825 | } | 24780 | } |
| 23826 | if (type_is_invalid(cimport_result->type)) | 24781 | if (type_is_invalid(cimport_result->type)) |
| 23827 | return ira->codegen->invalid_instruction; | 24782 | return ira->codegen->invalid_inst_gen; |
| 23828 | destroy(result_ptr, "ZigValue"); | 24783 | destroy(result_ptr, "ZigValue"); |
| 23829 | | 24784 | |
| 23830 | ZigPackage *cur_scope_pkg = scope_package(instruction->base.scope); | 24785 | ZigPackage *cur_scope_pkg = scope_package(instruction->base.base.scope); |
| 23831 | Buf *namespace_name = buf_sprintf("%s.cimport:%" ZIG_PRI_usize ":%" ZIG_PRI_usize, | 24786 | Buf *namespace_name = buf_sprintf("%s.cimport:%" ZIG_PRI_usize ":%" ZIG_PRI_usize, |
| 23832 | buf_ptr(&cur_scope_pkg->pkg_path), node->line + 1, node->column + 1); | 24787 | buf_ptr(&cur_scope_pkg->pkg_path), node->line + 1, node->column + 1); |
| 23833 | | 24788 | |
| ... | @@ -23839,7 +24794,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -23839,7 +24794,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 23839 | CacheHash *cache_hash; | 24794 | CacheHash *cache_hash; |
| 23840 | if ((err = create_c_object_cache(ira->codegen, &cache_hash, false))) { | 24795 | if ((err = create_c_object_cache(ira->codegen, &cache_hash, false))) { |
| 23841 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to create cache: %s", err_str(err))); | 24796 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to create cache: %s", err_str(err))); |
| 23842 | return ira->codegen->invalid_instruction; | 24797 | return ira->codegen->invalid_inst_gen; |
| 23843 | } | 24798 | } |
| 23844 | cache_buf(cache_hash, &cimport_scope->buf); | 24799 | cache_buf(cache_hash, &cimport_scope->buf); |
| 23845 | | 24800 | |
| ... | @@ -23851,7 +24806,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -23851,7 +24806,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 23851 | if ((err = cache_hit(cache_hash, &tmp_c_file_digest))) { | 24806 | if ((err = cache_hit(cache_hash, &tmp_c_file_digest))) { |
| 23852 | if (err != ErrorInvalidFormat) { | 24807 | if (err != ErrorInvalidFormat) { |
| 23853 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to check cache: %s", err_str(err))); | 24808 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to check cache: %s", err_str(err))); |
| 23854 | return ira->codegen->invalid_instruction; | 24809 | return ira->codegen->invalid_inst_gen; |
| 23855 | } | 24810 | } |
| 23856 | } | 24811 | } |
| 23857 | ira->codegen->caches_to_release.append(cache_hash); | 24812 | ira->codegen->caches_to_release.append(cache_hash); |
| ... | @@ -23870,12 +24825,12 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -23870,12 +24825,12 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 23870 | | 24825 | |
| 23871 | if ((err = os_make_path(tmp_c_file_dir))) { | 24826 | if ((err = os_make_path(tmp_c_file_dir))) { |
| 23872 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to make dir: %s", err_str(err))); | 24827 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to make dir: %s", err_str(err))); |
| 23873 | return ira->codegen->invalid_instruction; | 24828 | return ira->codegen->invalid_inst_gen; |
| 23874 | } | 24829 | } |
| 23875 | | 24830 | |
| 23876 | if ((err = os_write_file(&tmp_c_file_path, &cimport_scope->buf))) { | 24831 | if ((err = os_write_file(&tmp_c_file_path, &cimport_scope->buf))) { |
| 23877 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to write .h file: %s", err_str(err))); | 24832 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to write .h file: %s", err_str(err))); |
| 23878 | return ira->codegen->invalid_instruction; | 24833 | return ira->codegen->invalid_inst_gen; |
| 23879 | } | 24834 | } |
| 23880 | if (ira->codegen->verbose_cimport) { | 24835 | if (ira->codegen->verbose_cimport) { |
| 23881 | fprintf(stderr, "@cImport source: %s\n", buf_ptr(&tmp_c_file_path)); | 24836 | fprintf(stderr, "@cImport source: %s\n", buf_ptr(&tmp_c_file_path)); |
| ... | @@ -23910,7 +24865,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -23910,7 +24865,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 23910 | { | 24865 | { |
| 23911 | if (err != ErrorCCompileErrors) { | 24866 | if (err != ErrorCCompileErrors) { |
| 23912 | ir_add_error_node(ira, node, buf_sprintf("C import failed: %s", err_str(err))); | 24867 | ir_add_error_node(ira, node, buf_sprintf("C import failed: %s", err_str(err))); |
| 23913 | return ira->codegen->invalid_instruction; | 24868 | return ira->codegen->invalid_inst_gen; |
| 23914 | } | 24869 | } |
| 23915 | | 24870 | |
| 23916 | ErrorMsg *parent_err_msg = ir_add_error_node(ira, node, buf_sprintf("C import failed")); | 24871 | ErrorMsg *parent_err_msg = ir_add_error_node(ira, node, buf_sprintf("C import failed")); |
| ... | @@ -23931,7 +24886,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -23931,7 +24886,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 23931 | } | 24886 | } |
| 23932 | } | 24887 | } |
| 23933 | | 24888 | |
| 23934 | return ira->codegen->invalid_instruction; | 24889 | return ira->codegen->invalid_inst_gen; |
| 23935 | } | 24890 | } |
| 23936 | if (ira->codegen->verbose_cimport) { | 24891 | if (ira->codegen->verbose_cimport) { |
| 23937 | fprintf(stderr, "@cImport .d file: %s\n", buf_ptr(tmp_dep_file)); | 24892 | fprintf(stderr, "@cImport .d file: %s\n", buf_ptr(tmp_dep_file)); |
| ... | @@ -23939,29 +24894,29 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -23939,29 +24894,29 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 23939 | | 24894 | |
| 23940 | if ((err = cache_add_dep_file(cache_hash, tmp_dep_file, false))) { | 24895 | if ((err = cache_add_dep_file(cache_hash, tmp_dep_file, false))) { |
| 23941 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to parse .d file: %s", err_str(err))); | 24896 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to parse .d file: %s", err_str(err))); |
| 23942 | return ira->codegen->invalid_instruction; | 24897 | return ira->codegen->invalid_inst_gen; |
| 23943 | } | 24898 | } |
| 23944 | if ((err = cache_final(cache_hash, &tmp_c_file_digest))) { | 24899 | if ((err = cache_final(cache_hash, &tmp_c_file_digest))) { |
| 23945 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to finalize cache: %s", err_str(err))); | 24900 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to finalize cache: %s", err_str(err))); |
| 23946 | return ira->codegen->invalid_instruction; | 24901 | return ira->codegen->invalid_inst_gen; |
| 23947 | } | 24902 | } |
| 23948 | | 24903 | |
| 23949 | ir_cimport_cache_paths(ira->codegen->cache_dir, &tmp_c_file_digest, out_zig_dir, out_zig_path); | 24904 | ir_cimport_cache_paths(ira->codegen->cache_dir, &tmp_c_file_digest, out_zig_dir, out_zig_path); |
| 23950 | if ((err = os_make_path(out_zig_dir))) { | 24905 | if ((err = os_make_path(out_zig_dir))) { |
| 23951 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to make output dir: %s", err_str(err))); | 24906 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to make output dir: %s", err_str(err))); |
| 23952 | return ira->codegen->invalid_instruction; | 24907 | return ira->codegen->invalid_inst_gen; |
| 23953 | } | 24908 | } |
| 23954 | FILE *out_file = fopen(buf_ptr(out_zig_path), "wb"); | 24909 | FILE *out_file = fopen(buf_ptr(out_zig_path), "wb"); |
| 23955 | if (out_file == nullptr) { | 24910 | if (out_file == nullptr) { |
| 23956 | ir_add_error_node(ira, node, | 24911 | ir_add_error_node(ira, node, |
| 23957 | buf_sprintf("C import failed: unable to open output file: %s", strerror(errno))); | 24912 | buf_sprintf("C import failed: unable to open output file: %s", strerror(errno))); |
| 23958 | return ira->codegen->invalid_instruction; | 24913 | return ira->codegen->invalid_inst_gen; |
| 23959 | } | 24914 | } |
| 23960 | stage2_render_ast(ast, out_file); | 24915 | stage2_render_ast(ast, out_file); |
| 23961 | if (fclose(out_file) != 0) { | 24916 | if (fclose(out_file) != 0) { |
| 23962 | ir_add_error_node(ira, node, | 24917 | ir_add_error_node(ira, node, |
| 23963 | buf_sprintf("C import failed: unable to write to output file: %s", strerror(errno))); | 24918 | buf_sprintf("C import failed: unable to write to output file: %s", strerror(errno))); |
| 23964 | return ira->codegen->invalid_instruction; | 24919 | return ira->codegen->invalid_inst_gen; |
| 23965 | } | 24920 | } |
| 23966 | | 24921 | |
| 23967 | if (ira->codegen->verbose_cimport) { | 24922 | if (ira->codegen->verbose_cimport) { |
| ... | @@ -23980,90 +24935,90 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -23980,90 +24935,90 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 23980 | if ((err = file_fetch(ira->codegen, out_zig_path, import_code))) { | 24935 | if ((err = file_fetch(ira->codegen, out_zig_path, import_code))) { |
| 23981 | ir_add_error_node(ira, node, | 24936 | ir_add_error_node(ira, node, |
| 23982 | buf_sprintf("unable to open '%s': %s", buf_ptr(out_zig_path), err_str(err))); | 24937 | buf_sprintf("unable to open '%s': %s", buf_ptr(out_zig_path), err_str(err))); |
| 23983 | return ira->codegen->invalid_instruction; | 24938 | return ira->codegen->invalid_inst_gen; |
| 23984 | } | 24939 | } |
| 23985 | ZigType *child_import = add_source_file(ira->codegen, cimport_pkg, out_zig_path, | 24940 | ZigType *child_import = add_source_file(ira->codegen, cimport_pkg, out_zig_path, |
| 23986 | import_code, SourceKindCImport); | 24941 | import_code, SourceKindCImport); |
| 23987 | return ir_const_type(ira, &instruction->base, child_import); | 24942 | return ir_const_type(ira, &instruction->base.base, child_import); |
| 23988 | } | 24943 | } |
| 23989 | | 24944 | |
| 23990 | static IrInstruction *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstructionCInclude *instruction) { | 24945 | static IrInstGen *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstSrcCInclude *instruction) { |
| 23991 | IrInstruction *name_value = instruction->name->child; | 24946 | IrInstGen *name_value = instruction->name->child; |
| 23992 | if (type_is_invalid(name_value->value->type)) | 24947 | if (type_is_invalid(name_value->value->type)) |
| 23993 | return ira->codegen->invalid_instruction; | 24948 | return ira->codegen->invalid_inst_gen; |
| 23994 | | 24949 | |
| 23995 | Buf *include_name = ir_resolve_str(ira, name_value); | 24950 | Buf *include_name = ir_resolve_str(ira, name_value); |
| 23996 | if (!include_name) | 24951 | if (!include_name) |
| 23997 | return ira->codegen->invalid_instruction; | 24952 | return ira->codegen->invalid_inst_gen; |
| 23998 | | 24953 | |
| 23999 | Buf *c_import_buf = exec_c_import_buf(ira->new_irb.exec); | 24954 | Buf *c_import_buf = ira->new_irb.exec->c_import_buf; |
| 24000 | // We check for this error in pass1 | 24955 | // We check for this error in pass1 |
| 24001 | assert(c_import_buf); | 24956 | assert(c_import_buf); |
| 24002 | | 24957 | |
| 24003 | buf_appendf(c_import_buf, "#include <%s>\n", buf_ptr(include_name)); | 24958 | buf_appendf(c_import_buf, "#include <%s>\n", buf_ptr(include_name)); |
| 24004 | | 24959 | |
| 24005 | return ir_const_void(ira, &instruction->base); | 24960 | return ir_const_void(ira, &instruction->base.base); |
| 24006 | } | 24961 | } |
| 24007 | | 24962 | |
| 24008 | static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstructionCDefine *instruction) { | 24963 | static IrInstGen *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstSrcCDefine *instruction) { |
| 24009 | IrInstruction *name = instruction->name->child; | 24964 | IrInstGen *name = instruction->name->child; |
| 24010 | if (type_is_invalid(name->value->type)) | 24965 | if (type_is_invalid(name->value->type)) |
| 24011 | return ira->codegen->invalid_instruction; | 24966 | return ira->codegen->invalid_inst_gen; |
| 24012 | | 24967 | |
| 24013 | Buf *define_name = ir_resolve_str(ira, name); | 24968 | Buf *define_name = ir_resolve_str(ira, name); |
| 24014 | if (!define_name) | 24969 | if (!define_name) |
| 24015 | return ira->codegen->invalid_instruction; | 24970 | return ira->codegen->invalid_inst_gen; |
| 24016 | | 24971 | |
| 24017 | IrInstruction *value = instruction->value->child; | 24972 | IrInstGen *value = instruction->value->child; |
| 24018 | if (type_is_invalid(value->value->type)) | 24973 | if (type_is_invalid(value->value->type)) |
| 24019 | return ira->codegen->invalid_instruction; | 24974 | return ira->codegen->invalid_inst_gen; |
| 24020 | | 24975 | |
| 24021 | Buf *define_value = nullptr; | 24976 | Buf *define_value = nullptr; |
| 24022 | // The second parameter is either a string or void (equivalent to "") | 24977 | // The second parameter is either a string or void (equivalent to "") |
| 24023 | if (value->value->type->id != ZigTypeIdVoid) { | 24978 | if (value->value->type->id != ZigTypeIdVoid) { |
| 24024 | define_value = ir_resolve_str(ira, value); | 24979 | define_value = ir_resolve_str(ira, value); |
| 24025 | if (!define_value) | 24980 | if (!define_value) |
| 24026 | return ira->codegen->invalid_instruction; | 24981 | return ira->codegen->invalid_inst_gen; |
| 24027 | } | 24982 | } |
| 24028 | | 24983 | |
| 24029 | Buf *c_import_buf = exec_c_import_buf(ira->new_irb.exec); | 24984 | Buf *c_import_buf = ira->new_irb.exec->c_import_buf; |
| 24030 | // We check for this error in pass1 | 24985 | // We check for this error in pass1 |
| 24031 | assert(c_import_buf); | 24986 | assert(c_import_buf); |
| 24032 | | 24987 | |
| 24033 | buf_appendf(c_import_buf, "#define %s %s\n", buf_ptr(define_name), | 24988 | buf_appendf(c_import_buf, "#define %s %s\n", buf_ptr(define_name), |
| 24034 | define_value ? buf_ptr(define_value) : ""); | 24989 | define_value ? buf_ptr(define_value) : ""); |
| 24035 | | 24990 | |
| 24036 | return ir_const_void(ira, &instruction->base); | 24991 | return ir_const_void(ira, &instruction->base.base); |
| 24037 | } | 24992 | } |
| 24038 | | 24993 | |
| 24039 | static IrInstruction *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstructionCUndef *instruction) { | 24994 | static IrInstGen *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstSrcCUndef *instruction) { |
| 24040 | IrInstruction *name = instruction->name->child; | 24995 | IrInstGen *name = instruction->name->child; |
| 24041 | if (type_is_invalid(name->value->type)) | 24996 | if (type_is_invalid(name->value->type)) |
| 24042 | return ira->codegen->invalid_instruction; | 24997 | return ira->codegen->invalid_inst_gen; |
| 24043 | | 24998 | |
| 24044 | Buf *undef_name = ir_resolve_str(ira, name); | 24999 | Buf *undef_name = ir_resolve_str(ira, name); |
| 24045 | if (!undef_name) | 25000 | if (!undef_name) |
| 24046 | return ira->codegen->invalid_instruction; | 25001 | return ira->codegen->invalid_inst_gen; |
| 24047 | | 25002 | |
| 24048 | Buf *c_import_buf = exec_c_import_buf(ira->new_irb.exec); | 25003 | Buf *c_import_buf = ira->new_irb.exec->c_import_buf; |
| 24049 | // We check for this error in pass1 | 25004 | // We check for this error in pass1 |
| 24050 | assert(c_import_buf); | 25005 | assert(c_import_buf); |
| 24051 | | 25006 | |
| 24052 | buf_appendf(c_import_buf, "#undef %s\n", buf_ptr(undef_name)); | 25007 | buf_appendf(c_import_buf, "#undef %s\n", buf_ptr(undef_name)); |
| 24053 | | 25008 | |
| 24054 | return ir_const_void(ira, &instruction->base); | 25009 | return ir_const_void(ira, &instruction->base.base); |
| 24055 | } | 25010 | } |
| 24056 | | 25011 | |
| 24057 | static IrInstruction *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstructionEmbedFile *instruction) { | 25012 | static IrInstGen *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstSrcEmbedFile *instruction) { |
| 24058 | IrInstruction *name = instruction->name->child; | 25013 | IrInstGen *name = instruction->name->child; |
| 24059 | if (type_is_invalid(name->value->type)) | 25014 | if (type_is_invalid(name->value->type)) |
| 24060 | return ira->codegen->invalid_instruction; | 25015 | return ira->codegen->invalid_inst_gen; |
| 24061 | | 25016 | |
| 24062 | Buf *rel_file_path = ir_resolve_str(ira, name); | 25017 | Buf *rel_file_path = ir_resolve_str(ira, name); |
| 24063 | if (!rel_file_path) | 25018 | if (!rel_file_path) |
| 24064 | return ira->codegen->invalid_instruction; | 25019 | return ira->codegen->invalid_inst_gen; |
| 24065 | | 25020 | |
| 24066 | ZigType *import = get_scope_import(instruction->base.scope); | 25021 | ZigType *import = get_scope_import(instruction->base.base.scope); |
| 24067 | // figure out absolute path to resource | 25022 | // figure out absolute path to resource |
| 24068 | Buf source_dir_path = BUF_INIT; | 25023 | Buf source_dir_path = BUF_INIT; |
| 24069 | os_path_dirname(import->data.structure.root_struct->path, &source_dir_path); | 25024 | os_path_dirname(import->data.structure.root_struct->path, &source_dir_path); |
| ... | @@ -24080,93 +25035,95 @@ static IrInstruction *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstru | ... | @@ -24080,93 +25035,95 @@ static IrInstruction *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstru |
| 24080 | Error err; | 25035 | Error err; |
| 24081 | if ((err = file_fetch(ira->codegen, file_path, file_contents))) { | 25036 | if ((err = file_fetch(ira->codegen, file_path, file_contents))) { |
| 24082 | if (err == ErrorFileNotFound) { | 25037 | if (err == ErrorFileNotFound) { |
| 24083 | ir_add_error(ira, instruction->name, buf_sprintf("unable to find '%s'", buf_ptr(file_path))); | 25038 | ir_add_error(ira, &instruction->name->base, |
| 24084 | return ira->codegen->invalid_instruction; | 25039 | buf_sprintf("unable to find '%s'", buf_ptr(file_path))); |
| | 25040 | return ira->codegen->invalid_inst_gen; |
| 24085 | } else { | 25041 | } else { |
| 24086 | ir_add_error(ira, instruction->name, buf_sprintf("unable to open '%s': %s", buf_ptr(file_path), err_str(err))); | 25042 | ir_add_error(ira, &instruction->name->base, |
| 24087 | return ira->codegen->invalid_instruction; | 25043 | buf_sprintf("unable to open '%s': %s", buf_ptr(file_path), err_str(err))); |
| | 25044 | return ira->codegen->invalid_inst_gen; |
| 24088 | } | 25045 | } |
| 24089 | } | 25046 | } |
| 24090 | | 25047 | |
| 24091 | ZigType *result_type = get_array_type(ira->codegen, | 25048 | ZigType *result_type = get_array_type(ira->codegen, |
| 24092 | ira->codegen->builtin_types.entry_u8, buf_len(file_contents), nullptr); | 25049 | ira->codegen->builtin_types.entry_u8, buf_len(file_contents), nullptr); |
| 24093 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 25050 | IrInstGen *result = ir_const(ira, &instruction->base.base, result_type); |
| 24094 | init_const_str_lit(ira->codegen, result->value, file_contents); | 25051 | init_const_str_lit(ira->codegen, result->value, file_contents); |
| 24095 | return result; | 25052 | return result; |
| 24096 | } | 25053 | } |
| 24097 | | 25054 | |
| 24098 | static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructionCmpxchgSrc *instruction) { | 25055 | static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxchg *instruction) { |
| 24099 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->type_value->child); | 25056 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->type_value->child); |
| 24100 | if (type_is_invalid(operand_type)) | 25057 | if (type_is_invalid(operand_type)) |
| 24101 | return ira->codegen->invalid_instruction; | 25058 | return ira->codegen->invalid_inst_gen; |
| 24102 | | 25059 | |
| 24103 | if (operand_type->id == ZigTypeIdFloat) { | 25060 | if (operand_type->id == ZigTypeIdFloat) { |
| 24104 | ir_add_error(ira, instruction->type_value->child, | 25061 | ir_add_error(ira, &instruction->type_value->child->base, |
| 24105 | buf_sprintf("expected integer, enum or pointer type, found '%s'", buf_ptr(&operand_type->name))); | 25062 | buf_sprintf("expected integer, enum or pointer type, found '%s'", buf_ptr(&operand_type->name))); |
| 24106 | return ira->codegen->invalid_instruction; | 25063 | return ira->codegen->invalid_inst_gen; |
| 24107 | } | 25064 | } |
| 24108 | | 25065 | |
| 24109 | IrInstruction *ptr = instruction->ptr->child; | 25066 | IrInstGen *ptr = instruction->ptr->child; |
| 24110 | if (type_is_invalid(ptr->value->type)) | 25067 | if (type_is_invalid(ptr->value->type)) |
| 24111 | return ira->codegen->invalid_instruction; | 25068 | return ira->codegen->invalid_inst_gen; |
| 24112 | | 25069 | |
| 24113 | // TODO let this be volatile | 25070 | // TODO let this be volatile |
| 24114 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); | 25071 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 24115 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr, ptr_type); | 25072 | IrInstGen *casted_ptr = ir_implicit_cast(ira, ptr, ptr_type); |
| 24116 | if (type_is_invalid(casted_ptr->value->type)) | 25073 | if (type_is_invalid(casted_ptr->value->type)) |
| 24117 | return ira->codegen->invalid_instruction; | 25074 | return ira->codegen->invalid_inst_gen; |
| 24118 | | 25075 | |
| 24119 | IrInstruction *cmp_value = instruction->cmp_value->child; | 25076 | IrInstGen *cmp_value = instruction->cmp_value->child; |
| 24120 | if (type_is_invalid(cmp_value->value->type)) | 25077 | if (type_is_invalid(cmp_value->value->type)) |
| 24121 | return ira->codegen->invalid_instruction; | 25078 | return ira->codegen->invalid_inst_gen; |
| 24122 | | 25079 | |
| 24123 | IrInstruction *new_value = instruction->new_value->child; | 25080 | IrInstGen *new_value = instruction->new_value->child; |
| 24124 | if (type_is_invalid(new_value->value->type)) | 25081 | if (type_is_invalid(new_value->value->type)) |
| 24125 | return ira->codegen->invalid_instruction; | 25082 | return ira->codegen->invalid_inst_gen; |
| 24126 | | 25083 | |
| 24127 | IrInstruction *success_order_value = instruction->success_order_value->child; | 25084 | IrInstGen *success_order_value = instruction->success_order_value->child; |
| 24128 | if (type_is_invalid(success_order_value->value->type)) | 25085 | if (type_is_invalid(success_order_value->value->type)) |
| 24129 | return ira->codegen->invalid_instruction; | 25086 | return ira->codegen->invalid_inst_gen; |
| 24130 | | 25087 | |
| 24131 | AtomicOrder success_order; | 25088 | AtomicOrder success_order; |
| 24132 | if (!ir_resolve_atomic_order(ira, success_order_value, &success_order)) | 25089 | if (!ir_resolve_atomic_order(ira, success_order_value, &success_order)) |
| 24133 | return ira->codegen->invalid_instruction; | 25090 | return ira->codegen->invalid_inst_gen; |
| 24134 | | 25091 | |
| 24135 | IrInstruction *failure_order_value = instruction->failure_order_value->child; | 25092 | IrInstGen *failure_order_value = instruction->failure_order_value->child; |
| 24136 | if (type_is_invalid(failure_order_value->value->type)) | 25093 | if (type_is_invalid(failure_order_value->value->type)) |
| 24137 | return ira->codegen->invalid_instruction; | 25094 | return ira->codegen->invalid_inst_gen; |
| 24138 | | 25095 | |
| 24139 | AtomicOrder failure_order; | 25096 | AtomicOrder failure_order; |
| 24140 | if (!ir_resolve_atomic_order(ira, failure_order_value, &failure_order)) | 25097 | if (!ir_resolve_atomic_order(ira, failure_order_value, &failure_order)) |
| 24141 | return ira->codegen->invalid_instruction; | 25098 | return ira->codegen->invalid_inst_gen; |
| 24142 | | 25099 | |
| 24143 | IrInstruction *casted_cmp_value = ir_implicit_cast(ira, cmp_value, operand_type); | 25100 | IrInstGen *casted_cmp_value = ir_implicit_cast(ira, cmp_value, operand_type); |
| 24144 | if (type_is_invalid(casted_cmp_value->value->type)) | 25101 | if (type_is_invalid(casted_cmp_value->value->type)) |
| 24145 | return ira->codegen->invalid_instruction; | 25102 | return ira->codegen->invalid_inst_gen; |
| 24146 | | 25103 | |
| 24147 | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, operand_type); | 25104 | IrInstGen *casted_new_value = ir_implicit_cast(ira, new_value, operand_type); |
| 24148 | if (type_is_invalid(casted_new_value->value->type)) | 25105 | if (type_is_invalid(casted_new_value->value->type)) |
| 24149 | return ira->codegen->invalid_instruction; | 25106 | return ira->codegen->invalid_inst_gen; |
| 24150 | | 25107 | |
| 24151 | if (success_order < AtomicOrderMonotonic) { | 25108 | if (success_order < AtomicOrderMonotonic) { |
| 24152 | ir_add_error(ira, success_order_value, | 25109 | ir_add_error(ira, &success_order_value->base, |
| 24153 | buf_sprintf("success atomic ordering must be Monotonic or stricter")); | 25110 | buf_sprintf("success atomic ordering must be Monotonic or stricter")); |
| 24154 | return ira->codegen->invalid_instruction; | 25111 | return ira->codegen->invalid_inst_gen; |
| 24155 | } | 25112 | } |
| 24156 | if (failure_order < AtomicOrderMonotonic) { | 25113 | if (failure_order < AtomicOrderMonotonic) { |
| 24157 | ir_add_error(ira, failure_order_value, | 25114 | ir_add_error(ira, &failure_order_value->base, |
| 24158 | buf_sprintf("failure atomic ordering must be Monotonic or stricter")); | 25115 | buf_sprintf("failure atomic ordering must be Monotonic or stricter")); |
| 24159 | return ira->codegen->invalid_instruction; | 25116 | return ira->codegen->invalid_inst_gen; |
| 24160 | } | 25117 | } |
| 24161 | if (failure_order > success_order) { | 25118 | if (failure_order > success_order) { |
| 24162 | ir_add_error(ira, failure_order_value, | 25119 | ir_add_error(ira, &failure_order_value->base, |
| 24163 | buf_sprintf("failure atomic ordering must be no stricter than success")); | 25120 | buf_sprintf("failure atomic ordering must be no stricter than success")); |
| 24164 | return ira->codegen->invalid_instruction; | 25121 | return ira->codegen->invalid_inst_gen; |
| 24165 | } | 25122 | } |
| 24166 | if (failure_order == AtomicOrderRelease || failure_order == AtomicOrderAcqRel) { | 25123 | if (failure_order == AtomicOrderRelease || failure_order == AtomicOrderAcqRel) { |
| 24167 | ir_add_error(ira, failure_order_value, | 25124 | ir_add_error(ira, &failure_order_value->base, |
| 24168 | buf_sprintf("failure atomic ordering must not be Release or AcqRel")); | 25125 | buf_sprintf("failure atomic ordering must not be Release or AcqRel")); |
| 24169 | return ira->codegen->invalid_instruction; | 25126 | return ira->codegen->invalid_inst_gen; |
| 24170 | } | 25127 | } |
| 24171 | | 25128 | |
| 24172 | if (instr_is_comptime(casted_ptr) && casted_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar && | 25129 | if (instr_is_comptime(casted_ptr) && casted_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar && |
| ... | @@ -24175,66 +25132,63 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi | ... | @@ -24175,66 +25132,63 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi |
| 24175 | } | 25132 | } |
| 24176 | | 25133 | |
| 24177 | ZigType *result_type = get_optional_type(ira->codegen, operand_type); | 25134 | ZigType *result_type = get_optional_type(ira->codegen, operand_type); |
| 24178 | IrInstruction *result_loc; | 25135 | IrInstGen *result_loc; |
| 24179 | if (handle_is_ptr(result_type)) { | 25136 | if (handle_is_ptr(result_type)) { |
| 24180 | result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 25137 | result_loc = ir_resolve_result(ira, &instruction->base.base, instruction->result_loc, |
| 24181 | result_type, nullptr, true, true); | 25138 | result_type, nullptr, true, true); |
| 24182 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { | 25139 | if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) { |
| 24183 | return result_loc; | 25140 | return result_loc; |
| 24184 | } | 25141 | } |
| 24185 | } else { | 25142 | } else { |
| 24186 | result_loc = nullptr; | 25143 | result_loc = nullptr; |
| 24187 | } | 25144 | } |
| 24188 | | 25145 | |
| 24189 | return ir_build_cmpxchg_gen(ira, &instruction->base, result_type, | 25146 | return ir_build_cmpxchg_gen(ira, &instruction->base.base, result_type, |
| 24190 | casted_ptr, casted_cmp_value, casted_new_value, | 25147 | casted_ptr, casted_cmp_value, casted_new_value, |
| 24191 | success_order, failure_order, instruction->is_weak, result_loc); | 25148 | success_order, failure_order, instruction->is_weak, result_loc); |
| 24192 | } | 25149 | } |
| 24193 | | 25150 | |
| 24194 | static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstructionFence *instruction) { | 25151 | static IrInstGen *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstSrcFence *instruction) { |
| 24195 | IrInstruction *order_value = instruction->order_value->child; | 25152 | IrInstGen *order_inst = instruction->order->child; |
| 24196 | if (type_is_invalid(order_value->value->type)) | 25153 | if (type_is_invalid(order_inst->value->type)) |
| 24197 | return ira->codegen->invalid_instruction; | 25154 | return ira->codegen->invalid_inst_gen; |
| 24198 | | 25155 | |
| 24199 | AtomicOrder order; | 25156 | AtomicOrder order; |
| 24200 | if (!ir_resolve_atomic_order(ira, order_value, &order)) | 25157 | if (!ir_resolve_atomic_order(ira, order_inst, &order)) |
| 24201 | return ira->codegen->invalid_instruction; | 25158 | return ira->codegen->invalid_inst_gen; |
| 24202 | | 25159 | |
| 24203 | if (order < AtomicOrderAcquire) { | 25160 | if (order < AtomicOrderAcquire) { |
| 24204 | ir_add_error(ira, order_value, | 25161 | ir_add_error(ira, &order_inst->base, |
| 24205 | buf_sprintf("atomic ordering must be Acquire or stricter")); | 25162 | buf_sprintf("atomic ordering must be Acquire or stricter")); |
| 24206 | return ira->codegen->invalid_instruction; | 25163 | return ira->codegen->invalid_inst_gen; |
| 24207 | } | 25164 | } |
| 24208 | | 25165 | |
| 24209 | IrInstruction *result = ir_build_fence(&ira->new_irb, | 25166 | return ir_build_fence_gen(ira, &instruction->base.base, order); |
| 24210 | instruction->base.scope, instruction->base.source_node, order_value, order); | | |
| 24211 | result->value->type = ira->codegen->builtin_types.entry_void; | | |
| 24212 | return result; | | |
| 24213 | } | 25167 | } |
| 24214 | | 25168 | |
| 24215 | static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTruncate *instruction) { | 25169 | static IrInstGen *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstSrcTruncate *instruction) { |
| 24216 | IrInstruction *dest_type_value = instruction->dest_type->child; | 25170 | IrInstGen *dest_type_value = instruction->dest_type->child; |
| 24217 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); | 25171 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); |
| 24218 | if (type_is_invalid(dest_type)) | 25172 | if (type_is_invalid(dest_type)) |
| 24219 | return ira->codegen->invalid_instruction; | 25173 | return ira->codegen->invalid_inst_gen; |
| 24220 | | 25174 | |
| 24221 | if (dest_type->id != ZigTypeIdInt && | 25175 | if (dest_type->id != ZigTypeIdInt && |
| 24222 | dest_type->id != ZigTypeIdComptimeInt) | 25176 | dest_type->id != ZigTypeIdComptimeInt) |
| 24223 | { | 25177 | { |
| 24224 | ir_add_error(ira, dest_type_value, buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); | 25178 | ir_add_error(ira, &dest_type_value->base, buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); |
| 24225 | return ira->codegen->invalid_instruction; | 25179 | return ira->codegen->invalid_inst_gen; |
| 24226 | } | 25180 | } |
| 24227 | | 25181 | |
| 24228 | IrInstruction *target = instruction->target->child; | 25182 | IrInstGen *target = instruction->target->child; |
| 24229 | ZigType *src_type = target->value->type; | 25183 | ZigType *src_type = target->value->type; |
| 24230 | if (type_is_invalid(src_type)) | 25184 | if (type_is_invalid(src_type)) |
| 24231 | return ira->codegen->invalid_instruction; | 25185 | return ira->codegen->invalid_inst_gen; |
| 24232 | | 25186 | |
| 24233 | if (src_type->id != ZigTypeIdInt && | 25187 | if (src_type->id != ZigTypeIdInt && |
| 24234 | src_type->id != ZigTypeIdComptimeInt) | 25188 | src_type->id != ZigTypeIdComptimeInt) |
| 24235 | { | 25189 | { |
| 24236 | ir_add_error(ira, target, buf_sprintf("expected integer type, found '%s'", buf_ptr(&src_type->name))); | 25190 | ir_add_error(ira, &target->base, buf_sprintf("expected integer type, found '%s'", buf_ptr(&src_type->name))); |
| 24237 | return ira->codegen->invalid_instruction; | 25191 | return ira->codegen->invalid_inst_gen; |
| 24238 | } | 25192 | } |
| 24239 | | 25193 | |
| 24240 | if (dest_type->id == ZigTypeIdComptimeInt) { | 25194 | if (dest_type->id == ZigTypeIdComptimeInt) { |
| ... | @@ -24244,54 +25198,51 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct | ... | @@ -24244,54 +25198,51 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct |
| 24244 | if (instr_is_comptime(target)) { | 25198 | if (instr_is_comptime(target)) { |
| 24245 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 25199 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 24246 | if (val == nullptr) | 25200 | if (val == nullptr) |
| 24247 | return ira->codegen->invalid_instruction; | 25201 | return ira->codegen->invalid_inst_gen; |
| 24248 | | 25202 | |
| 24249 | IrInstruction *result = ir_const(ira, &instruction->base, dest_type); | 25203 | IrInstGen *result = ir_const(ira, &instruction->base.base, dest_type); |
| 24250 | bigint_truncate(&result->value->data.x_bigint, &val->data.x_bigint, | 25204 | bigint_truncate(&result->value->data.x_bigint, &val->data.x_bigint, |
| 24251 | dest_type->data.integral.bit_count, dest_type->data.integral.is_signed); | 25205 | dest_type->data.integral.bit_count, dest_type->data.integral.is_signed); |
| 24252 | return result; | 25206 | return result; |
| 24253 | } | 25207 | } |
| 24254 | | 25208 | |
| 24255 | if (src_type->data.integral.bit_count == 0 || dest_type->data.integral.bit_count == 0) { | 25209 | if (src_type->data.integral.bit_count == 0 || dest_type->data.integral.bit_count == 0) { |
| 24256 | IrInstruction *result = ir_const(ira, &instruction->base, dest_type); | 25210 | IrInstGen *result = ir_const(ira, &instruction->base.base, dest_type); |
| 24257 | bigint_init_unsigned(&result->value->data.x_bigint, 0); | 25211 | bigint_init_unsigned(&result->value->data.x_bigint, 0); |
| 24258 | return result; | 25212 | return result; |
| 24259 | } | 25213 | } |
| 24260 | | 25214 | |
| 24261 | if (src_type->data.integral.is_signed != dest_type->data.integral.is_signed) { | 25215 | if (src_type->data.integral.is_signed != dest_type->data.integral.is_signed) { |
| 24262 | const char *sign_str = dest_type->data.integral.is_signed ? "signed" : "unsigned"; | 25216 | const char *sign_str = dest_type->data.integral.is_signed ? "signed" : "unsigned"; |
| 24263 | ir_add_error(ira, target, buf_sprintf("expected %s integer type, found '%s'", sign_str, buf_ptr(&src_type->name))); | 25217 | ir_add_error(ira, &target->base, buf_sprintf("expected %s integer type, found '%s'", sign_str, buf_ptr(&src_type->name))); |
| 24264 | return ira->codegen->invalid_instruction; | 25218 | return ira->codegen->invalid_inst_gen; |
| 24265 | } else if (src_type->data.integral.bit_count < dest_type->data.integral.bit_count) { | 25219 | } else if (src_type->data.integral.bit_count < dest_type->data.integral.bit_count) { |
| 24266 | ir_add_error(ira, target, buf_sprintf("type '%s' has fewer bits than destination type '%s'", | 25220 | ir_add_error(ira, &target->base, buf_sprintf("type '%s' has fewer bits than destination type '%s'", |
| 24267 | buf_ptr(&src_type->name), buf_ptr(&dest_type->name))); | 25221 | buf_ptr(&src_type->name), buf_ptr(&dest_type->name))); |
| 24268 | return ira->codegen->invalid_instruction; | 25222 | return ira->codegen->invalid_inst_gen; |
| 24269 | } | 25223 | } |
| 24270 | | 25224 | |
| 24271 | IrInstruction *new_instruction = ir_build_truncate(&ira->new_irb, instruction->base.scope, | 25225 | return ir_build_truncate_gen(ira, &instruction->base.base, dest_type, target); |
| 24272 | instruction->base.source_node, dest_type_value, target); | | |
| 24273 | new_instruction->value->type = dest_type; | | |
| 24274 | return new_instruction; | | |
| 24275 | } | 25226 | } |
| 24276 | | 25227 | |
| 24277 | static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionIntCast *instruction) { | 25228 | static IrInstGen *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstSrcIntCast *instruction) { |
| 24278 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); | 25229 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 24279 | if (type_is_invalid(dest_type)) | 25230 | if (type_is_invalid(dest_type)) |
| 24280 | return ira->codegen->invalid_instruction; | 25231 | return ira->codegen->invalid_inst_gen; |
| 24281 | | 25232 | |
| 24282 | if (dest_type->id != ZigTypeIdInt && dest_type->id != ZigTypeIdComptimeInt) { | 25233 | if (dest_type->id != ZigTypeIdInt && dest_type->id != ZigTypeIdComptimeInt) { |
| 24283 | ir_add_error(ira, instruction->dest_type, buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); | 25234 | ir_add_error(ira, &instruction->dest_type->base, buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); |
| 24284 | return ira->codegen->invalid_instruction; | 25235 | return ira->codegen->invalid_inst_gen; |
| 24285 | } | 25236 | } |
| 24286 | | 25237 | |
| 24287 | IrInstruction *target = instruction->target->child; | 25238 | IrInstGen *target = instruction->target->child; |
| 24288 | if (type_is_invalid(target->value->type)) | 25239 | if (type_is_invalid(target->value->type)) |
| 24289 | return ira->codegen->invalid_instruction; | 25240 | return ira->codegen->invalid_inst_gen; |
| 24290 | | 25241 | |
| 24291 | if (target->value->type->id != ZigTypeIdInt && target->value->type->id != ZigTypeIdComptimeInt) { | 25242 | if (target->value->type->id != ZigTypeIdInt && target->value->type->id != ZigTypeIdComptimeInt) { |
| 24292 | ir_add_error(ira, instruction->target, buf_sprintf("expected integer type, found '%s'", | 25243 | ir_add_error(ira, &instruction->target->base, buf_sprintf("expected integer type, found '%s'", |
| 24293 | buf_ptr(&target->value->type->name))); | 25244 | buf_ptr(&target->value->type->name))); |
| 24294 | return ira->codegen->invalid_instruction; | 25245 | return ira->codegen->invalid_inst_gen; |
| 24295 | } | 25246 | } |
| 24296 | | 25247 | |
| 24297 | if (instr_is_comptime(target)) { | 25248 | if (instr_is_comptime(target)) { |
| ... | @@ -24299,28 +25250,28 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct | ... | @@ -24299,28 +25250,28 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct |
| 24299 | } | 25250 | } |
| 24300 | | 25251 | |
| 24301 | if (dest_type->id == ZigTypeIdComptimeInt) { | 25252 | if (dest_type->id == ZigTypeIdComptimeInt) { |
| 24302 | ir_add_error(ira, instruction->target, buf_sprintf("attempt to cast runtime value to '%s'", | 25253 | ir_add_error(ira, &instruction->target->base, buf_sprintf("attempt to cast runtime value to '%s'", |
| 24303 | buf_ptr(&dest_type->name))); | 25254 | buf_ptr(&dest_type->name))); |
| 24304 | return ira->codegen->invalid_instruction; | 25255 | return ira->codegen->invalid_inst_gen; |
| 24305 | } | 25256 | } |
| 24306 | | 25257 | |
| 24307 | return ir_analyze_widen_or_shorten(ira, &instruction->base, target, dest_type); | 25258 | return ir_analyze_widen_or_shorten(ira, &instruction->base.base, target, dest_type); |
| 24308 | } | 25259 | } |
| 24309 | | 25260 | |
| 24310 | static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionFloatCast *instruction) { | 25261 | static IrInstGen *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstSrcFloatCast *instruction) { |
| 24311 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); | 25262 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 24312 | if (type_is_invalid(dest_type)) | 25263 | if (type_is_invalid(dest_type)) |
| 24313 | return ira->codegen->invalid_instruction; | 25264 | return ira->codegen->invalid_inst_gen; |
| 24314 | | 25265 | |
| 24315 | if (dest_type->id != ZigTypeIdFloat) { | 25266 | if (dest_type->id != ZigTypeIdFloat) { |
| 24316 | ir_add_error(ira, instruction->dest_type, | 25267 | ir_add_error(ira, &instruction->dest_type->base, |
| 24317 | buf_sprintf("expected float type, found '%s'", buf_ptr(&dest_type->name))); | 25268 | buf_sprintf("expected float type, found '%s'", buf_ptr(&dest_type->name))); |
| 24318 | return ira->codegen->invalid_instruction; | 25269 | return ira->codegen->invalid_inst_gen; |
| 24319 | } | 25270 | } |
| 24320 | | 25271 | |
| 24321 | IrInstruction *target = instruction->target->child; | 25272 | IrInstGen *target = instruction->target->child; |
| 24322 | if (type_is_invalid(target->value->type)) | 25273 | if (type_is_invalid(target->value->type)) |
| 24323 | return ira->codegen->invalid_instruction; | 25274 | return ira->codegen->invalid_inst_gen; |
| 24324 | | 25275 | |
| 24325 | if (target->value->type->id == ZigTypeIdComptimeInt || | 25276 | if (target->value->type->id == ZigTypeIdComptimeInt || |
| 24326 | target->value->type->id == ZigTypeIdComptimeFloat) | 25277 | target->value->type->id == ZigTypeIdComptimeFloat) |
| ... | @@ -24332,55 +25283,55 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru | ... | @@ -24332,55 +25283,55 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru |
| 24332 | } else { | 25283 | } else { |
| 24333 | op = CastOpNumLitToConcrete; | 25284 | op = CastOpNumLitToConcrete; |
| 24334 | } | 25285 | } |
| 24335 | return ir_resolve_cast(ira, &instruction->base, target, dest_type, op); | 25286 | return ir_resolve_cast(ira, &instruction->base.base, target, dest_type, op); |
| 24336 | } else { | 25287 | } else { |
| 24337 | return ira->codegen->invalid_instruction; | 25288 | return ira->codegen->invalid_inst_gen; |
| 24338 | } | 25289 | } |
| 24339 | } | 25290 | } |
| 24340 | | 25291 | |
| 24341 | if (target->value->type->id != ZigTypeIdFloat) { | 25292 | if (target->value->type->id != ZigTypeIdFloat) { |
| 24342 | ir_add_error(ira, instruction->target, buf_sprintf("expected float type, found '%s'", | 25293 | ir_add_error(ira, &instruction->target->base, buf_sprintf("expected float type, found '%s'", |
| 24343 | buf_ptr(&target->value->type->name))); | 25294 | buf_ptr(&target->value->type->name))); |
| 24344 | return ira->codegen->invalid_instruction; | 25295 | return ira->codegen->invalid_inst_gen; |
| 24345 | } | 25296 | } |
| 24346 | | 25297 | |
| 24347 | return ir_analyze_widen_or_shorten(ira, &instruction->base, target, dest_type); | 25298 | return ir_analyze_widen_or_shorten(ira, &instruction->base.base, target, dest_type); |
| 24348 | } | 25299 | } |
| 24349 | | 25300 | |
| 24350 | static IrInstruction *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstructionErrSetCast *instruction) { | 25301 | static IrInstGen *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstSrcErrSetCast *instruction) { |
| 24351 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); | 25302 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 24352 | if (type_is_invalid(dest_type)) | 25303 | if (type_is_invalid(dest_type)) |
| 24353 | return ira->codegen->invalid_instruction; | 25304 | return ira->codegen->invalid_inst_gen; |
| 24354 | | 25305 | |
| 24355 | if (dest_type->id != ZigTypeIdErrorSet) { | 25306 | if (dest_type->id != ZigTypeIdErrorSet) { |
| 24356 | ir_add_error(ira, instruction->dest_type, | 25307 | ir_add_error(ira, &instruction->dest_type->base, |
| 24357 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&dest_type->name))); | 25308 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&dest_type->name))); |
| 24358 | return ira->codegen->invalid_instruction; | 25309 | return ira->codegen->invalid_inst_gen; |
| 24359 | } | 25310 | } |
| 24360 | | 25311 | |
| 24361 | IrInstruction *target = instruction->target->child; | 25312 | IrInstGen *target = instruction->target->child; |
| 24362 | if (type_is_invalid(target->value->type)) | 25313 | if (type_is_invalid(target->value->type)) |
| 24363 | return ira->codegen->invalid_instruction; | 25314 | return ira->codegen->invalid_inst_gen; |
| 24364 | | 25315 | |
| 24365 | if (target->value->type->id != ZigTypeIdErrorSet) { | 25316 | if (target->value->type->id != ZigTypeIdErrorSet) { |
| 24366 | ir_add_error(ira, instruction->target, | 25317 | ir_add_error(ira, &instruction->target->base, |
| 24367 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&target->value->type->name))); | 25318 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&target->value->type->name))); |
| 24368 | return ira->codegen->invalid_instruction; | 25319 | return ira->codegen->invalid_inst_gen; |
| 24369 | } | 25320 | } |
| 24370 | | 25321 | |
| 24371 | return ir_analyze_err_set_cast(ira, &instruction->base, target, dest_type); | 25322 | return ir_analyze_err_set_cast(ira, &instruction->base.base, target, dest_type); |
| 24372 | } | 25323 | } |
| 24373 | | 25324 | |
| 24374 | static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionFromBytes *instruction) { | 25325 | static IrInstGen *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstSrcFromBytes *instruction) { |
| 24375 | Error err; | 25326 | Error err; |
| 24376 | | 25327 | |
| 24377 | ZigType *dest_child_type = ir_resolve_type(ira, instruction->dest_child_type->child); | 25328 | ZigType *dest_child_type = ir_resolve_type(ira, instruction->dest_child_type->child); |
| 24378 | if (type_is_invalid(dest_child_type)) | 25329 | if (type_is_invalid(dest_child_type)) |
| 24379 | return ira->codegen->invalid_instruction; | 25330 | return ira->codegen->invalid_inst_gen; |
| 24380 | | 25331 | |
| 24381 | IrInstruction *target = instruction->target->child; | 25332 | IrInstGen *target = instruction->target->child; |
| 24382 | if (type_is_invalid(target->value->type)) | 25333 | if (type_is_invalid(target->value->type)) |
| 24383 | return ira->codegen->invalid_instruction; | 25334 | return ira->codegen->invalid_inst_gen; |
| 24384 | | 25335 | |
| 24385 | bool src_ptr_const; | 25336 | bool src_ptr_const; |
| 24386 | bool src_ptr_volatile; | 25337 | bool src_ptr_volatile; |
| ... | @@ -24390,27 +25341,27 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -24390,27 +25341,27 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 24390 | src_ptr_volatile = target->value->type->data.pointer.is_volatile; | 25341 | src_ptr_volatile = target->value->type->data.pointer.is_volatile; |
| 24391 | | 25342 | |
| 24392 | if ((err = resolve_ptr_align(ira, target->value->type, &src_ptr_align))) | 25343 | if ((err = resolve_ptr_align(ira, target->value->type, &src_ptr_align))) |
| 24393 | return ira->codegen->invalid_instruction; | 25344 | return ira->codegen->invalid_inst_gen; |
| 24394 | } else if (is_slice(target->value->type)) { | 25345 | } else if (is_slice(target->value->type)) { |
| 24395 | ZigType *src_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry; | 25346 | ZigType *src_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry; |
| 24396 | src_ptr_const = src_ptr_type->data.pointer.is_const; | 25347 | src_ptr_const = src_ptr_type->data.pointer.is_const; |
| 24397 | src_ptr_volatile = src_ptr_type->data.pointer.is_volatile; | 25348 | src_ptr_volatile = src_ptr_type->data.pointer.is_volatile; |
| 24398 | | 25349 | |
| 24399 | if ((err = resolve_ptr_align(ira, src_ptr_type, &src_ptr_align))) | 25350 | if ((err = resolve_ptr_align(ira, src_ptr_type, &src_ptr_align))) |
| 24400 | return ira->codegen->invalid_instruction; | 25351 | return ira->codegen->invalid_inst_gen; |
| 24401 | } else { | 25352 | } else { |
| 24402 | src_ptr_const = true; | 25353 | src_ptr_const = true; |
| 24403 | src_ptr_volatile = false; | 25354 | src_ptr_volatile = false; |
| 24404 | | 25355 | |
| 24405 | if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusAlignmentKnown))) | 25356 | if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusAlignmentKnown))) |
| 24406 | return ira->codegen->invalid_instruction; | 25357 | return ira->codegen->invalid_inst_gen; |
| 24407 | | 25358 | |
| 24408 | src_ptr_align = get_abi_alignment(ira->codegen, target->value->type); | 25359 | src_ptr_align = get_abi_alignment(ira->codegen, target->value->type); |
| 24409 | } | 25360 | } |
| 24410 | | 25361 | |
| 24411 | if (src_ptr_align != 0) { | 25362 | if (src_ptr_align != 0) { |
| 24412 | if ((err = type_resolve(ira->codegen, dest_child_type, ResolveStatusAlignmentKnown))) | 25363 | if ((err = type_resolve(ira->codegen, dest_child_type, ResolveStatusAlignmentKnown))) |
| 24413 | return ira->codegen->invalid_instruction; | 25364 | return ira->codegen->invalid_inst_gen; |
| 24414 | } | 25365 | } |
| 24415 | | 25366 | |
| 24416 | ZigType *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_child_type, | 25367 | ZigType *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_child_type, |
| ... | @@ -24423,9 +25374,9 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -24423,9 +25374,9 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 24423 | src_ptr_align, 0, 0, false); | 25374 | src_ptr_align, 0, 0, false); |
| 24424 | ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr); | 25375 | ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr); |
| 24425 | | 25376 | |
| 24426 | IrInstruction *casted_value = ir_implicit_cast(ira, target, u8_slice); | 25377 | IrInstGen *casted_value = ir_implicit_cast(ira, target, u8_slice); |
| 24427 | if (type_is_invalid(casted_value->value->type)) | 25378 | if (type_is_invalid(casted_value->value->type)) |
| 24428 | return ira->codegen->invalid_instruction; | 25379 | return ira->codegen->invalid_inst_gen; |
| 24429 | | 25380 | |
| 24430 | bool have_known_len = false; | 25381 | bool have_known_len = false; |
| 24431 | uint64_t known_len; | 25382 | uint64_t known_len; |
| ... | @@ -24433,7 +25384,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -24433,7 +25384,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 24433 | if (instr_is_comptime(casted_value)) { | 25384 | if (instr_is_comptime(casted_value)) { |
| 24434 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); | 25385 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); |
| 24435 | if (!val) | 25386 | if (!val) |
| 24436 | return ira->codegen->invalid_instruction; | 25387 | return ira->codegen->invalid_inst_gen; |
| 24437 | | 25388 | |
| 24438 | ZigValue *len_val = val->data.x_struct.fields[slice_len_index]; | 25389 | ZigValue *len_val = val->data.x_struct.fields[slice_len_index]; |
| 24439 | if (value_is_comptime(len_val)) { | 25390 | if (value_is_comptime(len_val)) { |
| ... | @@ -24442,9 +25393,9 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -24442,9 +25393,9 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 24442 | } | 25393 | } |
| 24443 | } | 25394 | } |
| 24444 | | 25395 | |
| 24445 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 25396 | IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base.base, instruction->result_loc, |
| 24446 | dest_slice_type, nullptr, true, true); | 25397 | dest_slice_type, nullptr, true, true); |
| 24447 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) { | 25398 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable)) { |
| 24448 | return result_loc; | 25399 | return result_loc; |
| 24449 | } | 25400 | } |
| 24450 | | 25401 | |
| ... | @@ -24461,41 +25412,41 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -24461,41 +25412,41 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 24461 | | 25412 | |
| 24462 | if (have_known_len) { | 25413 | if (have_known_len) { |
| 24463 | if ((err = type_resolve(ira->codegen, dest_child_type, ResolveStatusSizeKnown))) | 25414 | if ((err = type_resolve(ira->codegen, dest_child_type, ResolveStatusSizeKnown))) |
| 24464 | return ira->codegen->invalid_instruction; | 25415 | return ira->codegen->invalid_inst_gen; |
| 24465 | uint64_t child_type_size = type_size(ira->codegen, dest_child_type); | 25416 | uint64_t child_type_size = type_size(ira->codegen, dest_child_type); |
| 24466 | uint64_t remainder = known_len % child_type_size; | 25417 | uint64_t remainder = known_len % child_type_size; |
| 24467 | if (remainder != 0) { | 25418 | if (remainder != 0) { |
| 24468 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, | 25419 | ErrorMsg *msg = ir_add_error(ira, &instruction->base.base, |
| 24469 | buf_sprintf("unable to convert [%" ZIG_PRI_u64 "]u8 to %s: size mismatch", | 25420 | buf_sprintf("unable to convert [%" ZIG_PRI_u64 "]u8 to %s: size mismatch", |
| 24470 | known_len, buf_ptr(&dest_slice_type->name))); | 25421 | known_len, buf_ptr(&dest_slice_type->name))); |
| 24471 | add_error_note(ira->codegen, msg, instruction->dest_child_type->source_node, | 25422 | add_error_note(ira->codegen, msg, instruction->dest_child_type->base.source_node, |
| 24472 | buf_sprintf("%s has size %" ZIG_PRI_u64 "; remaining bytes: %" ZIG_PRI_u64, | 25423 | buf_sprintf("%s has size %" ZIG_PRI_u64 "; remaining bytes: %" ZIG_PRI_u64, |
| 24473 | buf_ptr(&dest_child_type->name), child_type_size, remainder)); | 25424 | buf_ptr(&dest_child_type->name), child_type_size, remainder)); |
| 24474 | return ira->codegen->invalid_instruction; | 25425 | return ira->codegen->invalid_inst_gen; |
| 24475 | } | 25426 | } |
| 24476 | } | 25427 | } |
| 24477 | | 25428 | |
| 24478 | return ir_build_resize_slice(ira, &instruction->base, casted_value, dest_slice_type, result_loc); | 25429 | return ir_build_resize_slice(ira, &instruction->base.base, casted_value, dest_slice_type, result_loc); |
| 24479 | } | 25430 | } |
| 24480 | | 25431 | |
| 24481 | static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstructionToBytes *instruction) { | 25432 | static IrInstGen *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstSrcToBytes *instruction) { |
| 24482 | Error err; | 25433 | Error err; |
| 24483 | | 25434 | |
| 24484 | IrInstruction *target = instruction->target->child; | 25435 | IrInstGen *target = instruction->target->child; |
| 24485 | if (type_is_invalid(target->value->type)) | 25436 | if (type_is_invalid(target->value->type)) |
| 24486 | return ira->codegen->invalid_instruction; | 25437 | return ira->codegen->invalid_inst_gen; |
| 24487 | | 25438 | |
| 24488 | if (!is_slice(target->value->type)) { | 25439 | if (!is_slice(target->value->type)) { |
| 24489 | ir_add_error(ira, instruction->target, | 25440 | ir_add_error(ira, &instruction->target->base, |
| 24490 | buf_sprintf("expected slice, found '%s'", buf_ptr(&target->value->type->name))); | 25441 | buf_sprintf("expected slice, found '%s'", buf_ptr(&target->value->type->name))); |
| 24491 | return ira->codegen->invalid_instruction; | 25442 | return ira->codegen->invalid_inst_gen; |
| 24492 | } | 25443 | } |
| 24493 | | 25444 | |
| 24494 | ZigType *src_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry; | 25445 | ZigType *src_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry; |
| 24495 | | 25446 | |
| 24496 | uint32_t alignment; | 25447 | uint32_t alignment; |
| 24497 | if ((err = resolve_ptr_align(ira, src_ptr_type, &alignment))) | 25448 | if ((err = resolve_ptr_align(ira, src_ptr_type, &alignment))) |
| 24498 | return ira->codegen->invalid_instruction; | 25449 | return ira->codegen->invalid_inst_gen; |
| 24499 | | 25450 | |
| 24500 | ZigType *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, | 25451 | ZigType *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 24501 | src_ptr_type->data.pointer.is_const, src_ptr_type->data.pointer.is_volatile, PtrLenUnknown, | 25452 | src_ptr_type->data.pointer.is_const, src_ptr_type->data.pointer.is_volatile, PtrLenUnknown, |
| ... | @@ -24505,9 +25456,9 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct | ... | @@ -24505,9 +25456,9 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct |
| 24505 | if (instr_is_comptime(target)) { | 25456 | if (instr_is_comptime(target)) { |
| 24506 | ZigValue *target_val = ir_resolve_const(ira, target, UndefBad); | 25457 | ZigValue *target_val = ir_resolve_const(ira, target, UndefBad); |
| 24507 | if (target_val == nullptr) | 25458 | if (target_val == nullptr) |
| 24508 | return ira->codegen->invalid_instruction; | 25459 | return ira->codegen->invalid_inst_gen; |
| 24509 | | 25460 | |
| 24510 | IrInstruction *result = ir_const(ira, &instruction->base, dest_slice_type); | 25461 | IrInstGen *result = ir_const(ira, &instruction->base.base, dest_slice_type); |
| 24511 | result->value->data.x_struct.fields = alloc_const_vals_ptrs(2); | 25462 | result->value->data.x_struct.fields = alloc_const_vals_ptrs(2); |
| 24512 | | 25463 | |
| 24513 | ZigValue *ptr_val = result->value->data.x_struct.fields[slice_ptr_index]; | 25464 | ZigValue *ptr_val = result->value->data.x_struct.fields[slice_ptr_index]; |
| ... | @@ -24527,13 +25478,13 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct | ... | @@ -24527,13 +25478,13 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct |
| 24527 | return result; | 25478 | return result; |
| 24528 | } | 25479 | } |
| 24529 | | 25480 | |
| 24530 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 25481 | IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base.base, instruction->result_loc, |
| 24531 | dest_slice_type, nullptr, true, true); | 25482 | dest_slice_type, nullptr, true, true); |
| 24532 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { | 25483 | if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) { |
| 24533 | return result_loc; | 25484 | return result_loc; |
| 24534 | } | 25485 | } |
| 24535 | | 25486 | |
| 24536 | return ir_build_resize_slice(ira, &instruction->base, target, dest_slice_type, result_loc); | 25487 | return ir_build_resize_slice(ira, &instruction->base.base, target, dest_slice_type, result_loc); |
| 24537 | } | 25488 | } |
| 24538 | | 25489 | |
| 24539 | static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_align) { | 25490 | static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_align) { |
| ... | @@ -24550,26 +25501,26 @@ static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_ali | ... | @@ -24550,26 +25501,26 @@ static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_ali |
| 24550 | return ErrorNone; | 25501 | return ErrorNone; |
| 24551 | } | 25502 | } |
| 24552 | | 25503 | |
| 24553 | static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstructionIntToFloat *instruction) { | 25504 | static IrInstGen *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstSrcIntToFloat *instruction) { |
| 24554 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); | 25505 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 24555 | if (type_is_invalid(dest_type)) | 25506 | if (type_is_invalid(dest_type)) |
| 24556 | return ira->codegen->invalid_instruction; | 25507 | return ira->codegen->invalid_inst_gen; |
| 24557 | | 25508 | |
| 24558 | IrInstruction *target = instruction->target->child; | 25509 | IrInstGen *target = instruction->target->child; |
| 24559 | if (type_is_invalid(target->value->type)) | 25510 | if (type_is_invalid(target->value->type)) |
| 24560 | return ira->codegen->invalid_instruction; | 25511 | return ira->codegen->invalid_inst_gen; |
| 24561 | | 25512 | |
| 24562 | if (target->value->type->id != ZigTypeIdInt && target->value->type->id != ZigTypeIdComptimeInt) { | 25513 | if (target->value->type->id != ZigTypeIdInt && target->value->type->id != ZigTypeIdComptimeInt) { |
| 24563 | ir_add_error(ira, instruction->target, buf_sprintf("expected int type, found '%s'", | 25514 | ir_add_error(ira, &instruction->target->base, buf_sprintf("expected int type, found '%s'", |
| 24564 | buf_ptr(&target->value->type->name))); | 25515 | buf_ptr(&target->value->type->name))); |
| 24565 | return ira->codegen->invalid_instruction; | 25516 | return ira->codegen->invalid_inst_gen; |
| 24566 | } | 25517 | } |
| 24567 | | 25518 | |
| 24568 | return ir_resolve_cast(ira, &instruction->base, target, dest_type, CastOpIntToFloat); | 25519 | return ir_resolve_cast(ira, &instruction->base.base, target, dest_type, CastOpIntToFloat); |
| 24569 | } | 25520 | } |
| 24570 | | 25521 | |
| 24571 | static IrInstruction *ir_analyze_float_to_int(IrAnalyze *ira, IrInstruction *source_instr, | 25522 | static IrInstGen *ir_analyze_float_to_int(IrAnalyze *ira, IrInst* source_instr, |
| 24572 | ZigType *dest_type, IrInstruction *operand, AstNode *operand_source_node) | 25523 | ZigType *dest_type, IrInstGen *operand, AstNode *operand_source_node) |
| 24573 | { | 25524 | { |
| 24574 | if (operand->value->type->id == ZigTypeIdComptimeInt) { | 25525 | if (operand->value->type->id == ZigTypeIdComptimeInt) { |
| 24575 | return ir_implicit_cast(ira, operand, dest_type); | 25526 | return ir_implicit_cast(ira, operand, dest_type); |
| ... | @@ -24578,106 +25529,107 @@ static IrInstruction *ir_analyze_float_to_int(IrAnalyze *ira, IrInstruction *sou | ... | @@ -24578,106 +25529,107 @@ static IrInstruction *ir_analyze_float_to_int(IrAnalyze *ira, IrInstruction *sou |
| 24578 | if (operand->value->type->id != ZigTypeIdFloat && operand->value->type->id != ZigTypeIdComptimeFloat) { | 25529 | if (operand->value->type->id != ZigTypeIdFloat && operand->value->type->id != ZigTypeIdComptimeFloat) { |
| 24579 | ir_add_error_node(ira, operand_source_node, buf_sprintf("expected float type, found '%s'", | 25530 | ir_add_error_node(ira, operand_source_node, buf_sprintf("expected float type, found '%s'", |
| 24580 | buf_ptr(&operand->value->type->name))); | 25531 | buf_ptr(&operand->value->type->name))); |
| 24581 | return ira->codegen->invalid_instruction; | 25532 | return ira->codegen->invalid_inst_gen; |
| 24582 | } | 25533 | } |
| 24583 | | 25534 | |
| 24584 | return ir_resolve_cast(ira, source_instr, operand, dest_type, CastOpFloatToInt); | 25535 | return ir_resolve_cast(ira, source_instr, operand, dest_type, CastOpFloatToInt); |
| 24585 | } | 25536 | } |
| 24586 | | 25537 | |
| 24587 | static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructionFloatToInt *instruction) { | 25538 | static IrInstGen *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstSrcFloatToInt *instruction) { |
| 24588 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); | 25539 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 24589 | if (type_is_invalid(dest_type)) | 25540 | if (type_is_invalid(dest_type)) |
| 24590 | return ira->codegen->invalid_instruction; | 25541 | return ira->codegen->invalid_inst_gen; |
| 24591 | | 25542 | |
| 24592 | IrInstruction *operand = instruction->target->child; | 25543 | IrInstGen *operand = instruction->target->child; |
| 24593 | if (type_is_invalid(operand->value->type)) | 25544 | if (type_is_invalid(operand->value->type)) |
| 24594 | return ira->codegen->invalid_instruction; | 25545 | return ira->codegen->invalid_inst_gen; |
| 24595 | | 25546 | |
| 24596 | return ir_analyze_float_to_int(ira, &instruction->base, dest_type, operand, instruction->target->source_node); | 25547 | return ir_analyze_float_to_int(ira, &instruction->base.base, dest_type, operand, |
| | 25548 | instruction->target->base.source_node); |
| 24597 | } | 25549 | } |
| 24598 | | 25550 | |
| 24599 | static IrInstruction *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstructionErrToInt *instruction) { | 25551 | static IrInstGen *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstSrcErrToInt *instruction) { |
| 24600 | IrInstruction *target = instruction->target->child; | 25552 | IrInstGen *target = instruction->target->child; |
| 24601 | if (type_is_invalid(target->value->type)) | 25553 | if (type_is_invalid(target->value->type)) |
| 24602 | return ira->codegen->invalid_instruction; | 25554 | return ira->codegen->invalid_inst_gen; |
| 24603 | | 25555 | |
| 24604 | IrInstruction *casted_target; | 25556 | IrInstGen *casted_target; |
| 24605 | if (target->value->type->id == ZigTypeIdErrorSet) { | 25557 | if (target->value->type->id == ZigTypeIdErrorSet) { |
| 24606 | casted_target = target; | 25558 | casted_target = target; |
| 24607 | } else { | 25559 | } else { |
| 24608 | casted_target = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_global_error_set); | 25560 | casted_target = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_global_error_set); |
| 24609 | if (type_is_invalid(casted_target->value->type)) | 25561 | if (type_is_invalid(casted_target->value->type)) |
| 24610 | return ira->codegen->invalid_instruction; | 25562 | return ira->codegen->invalid_inst_gen; |
| 24611 | } | 25563 | } |
| 24612 | | 25564 | |
| 24613 | return ir_analyze_err_to_int(ira, &instruction->base, casted_target, ira->codegen->err_tag_type); | 25565 | return ir_analyze_err_to_int(ira, &instruction->base.base, casted_target, ira->codegen->err_tag_type); |
| 24614 | } | 25566 | } |
| 24615 | | 25567 | |
| 24616 | static IrInstruction *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstructionIntToErr *instruction) { | 25568 | static IrInstGen *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstSrcIntToErr *instruction) { |
| 24617 | IrInstruction *target = instruction->target->child; | 25569 | IrInstGen *target = instruction->target->child; |
| 24618 | if (type_is_invalid(target->value->type)) | 25570 | if (type_is_invalid(target->value->type)) |
| 24619 | return ira->codegen->invalid_instruction; | 25571 | return ira->codegen->invalid_inst_gen; |
| 24620 | | 25572 | |
| 24621 | IrInstruction *casted_target = ir_implicit_cast(ira, target, ira->codegen->err_tag_type); | 25573 | IrInstGen *casted_target = ir_implicit_cast(ira, target, ira->codegen->err_tag_type); |
| 24622 | if (type_is_invalid(casted_target->value->type)) | 25574 | if (type_is_invalid(casted_target->value->type)) |
| 24623 | return ira->codegen->invalid_instruction; | 25575 | return ira->codegen->invalid_inst_gen; |
| 24624 | | 25576 | |
| 24625 | return ir_analyze_int_to_err(ira, &instruction->base, casted_target, ira->codegen->builtin_types.entry_global_error_set); | 25577 | return ir_analyze_int_to_err(ira, &instruction->base.base, casted_target, ira->codegen->builtin_types.entry_global_error_set); |
| 24626 | } | 25578 | } |
| 24627 | | 25579 | |
| 24628 | static IrInstruction *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstructionBoolToInt *instruction) { | 25580 | static IrInstGen *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstSrcBoolToInt *instruction) { |
| 24629 | IrInstruction *target = instruction->target->child; | 25581 | IrInstGen *target = instruction->target->child; |
| 24630 | if (type_is_invalid(target->value->type)) | 25582 | if (type_is_invalid(target->value->type)) |
| 24631 | return ira->codegen->invalid_instruction; | 25583 | return ira->codegen->invalid_inst_gen; |
| 24632 | | 25584 | |
| 24633 | if (target->value->type->id != ZigTypeIdBool) { | 25585 | if (target->value->type->id != ZigTypeIdBool) { |
| 24634 | ir_add_error(ira, instruction->target, buf_sprintf("expected bool, found '%s'", | 25586 | ir_add_error(ira, &instruction->target->base, buf_sprintf("expected bool, found '%s'", |
| 24635 | buf_ptr(&target->value->type->name))); | 25587 | buf_ptr(&target->value->type->name))); |
| 24636 | return ira->codegen->invalid_instruction; | 25588 | return ira->codegen->invalid_inst_gen; |
| 24637 | } | 25589 | } |
| 24638 | | 25590 | |
| 24639 | if (instr_is_comptime(target)) { | 25591 | if (instr_is_comptime(target)) { |
| 24640 | bool is_true; | 25592 | bool is_true; |
| 24641 | if (!ir_resolve_bool(ira, target, &is_true)) | 25593 | if (!ir_resolve_bool(ira, target, &is_true)) |
| 24642 | return ira->codegen->invalid_instruction; | 25594 | return ira->codegen->invalid_inst_gen; |
| 24643 | | 25595 | |
| 24644 | return ir_const_unsigned(ira, &instruction->base, is_true ? 1 : 0); | 25596 | return ir_const_unsigned(ira, &instruction->base.base, is_true ? 1 : 0); |
| 24645 | } | 25597 | } |
| 24646 | | 25598 | |
| 24647 | ZigType *u1_type = get_int_type(ira->codegen, false, 1); | 25599 | ZigType *u1_type = get_int_type(ira->codegen, false, 1); |
| 24648 | return ir_resolve_cast(ira, &instruction->base, target, u1_type, CastOpBoolToInt); | 25600 | return ir_resolve_cast(ira, &instruction->base.base, target, u1_type, CastOpBoolToInt); |
| 24649 | } | 25601 | } |
| 24650 | | 25602 | |
| 24651 | static IrInstruction *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstructionIntType *instruction) { | 25603 | static IrInstGen *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstSrcIntType *instruction) { |
| 24652 | IrInstruction *is_signed_value = instruction->is_signed->child; | 25604 | IrInstGen *is_signed_value = instruction->is_signed->child; |
| 24653 | bool is_signed; | 25605 | bool is_signed; |
| 24654 | if (!ir_resolve_bool(ira, is_signed_value, &is_signed)) | 25606 | if (!ir_resolve_bool(ira, is_signed_value, &is_signed)) |
| 24655 | return ira->codegen->invalid_instruction; | 25607 | return ira->codegen->invalid_inst_gen; |
| 24656 | | 25608 | |
| 24657 | IrInstruction *bit_count_value = instruction->bit_count->child; | 25609 | IrInstGen *bit_count_value = instruction->bit_count->child; |
| 24658 | uint64_t bit_count; | 25610 | uint64_t bit_count; |
| 24659 | if (!ir_resolve_unsigned(ira, bit_count_value, ira->codegen->builtin_types.entry_u16, &bit_count)) | 25611 | if (!ir_resolve_unsigned(ira, bit_count_value, ira->codegen->builtin_types.entry_u16, &bit_count)) |
| 24660 | return ira->codegen->invalid_instruction; | 25612 | return ira->codegen->invalid_inst_gen; |
| 24661 | | 25613 | |
| 24662 | return ir_const_type(ira, &instruction->base, get_int_type(ira->codegen, is_signed, (uint32_t)bit_count)); | 25614 | return ir_const_type(ira, &instruction->base.base, get_int_type(ira->codegen, is_signed, (uint32_t)bit_count)); |
| 24663 | } | 25615 | } |
| 24664 | | 25616 | |
| 24665 | static IrInstruction *ir_analyze_instruction_vector_type(IrAnalyze *ira, IrInstructionVectorType *instruction) { | 25617 | static IrInstGen *ir_analyze_instruction_vector_type(IrAnalyze *ira, IrInstSrcVectorType *instruction) { |
| 24666 | uint64_t len; | 25618 | uint64_t len; |
| 24667 | if (!ir_resolve_unsigned(ira, instruction->len->child, ira->codegen->builtin_types.entry_u32, &len)) | 25619 | if (!ir_resolve_unsigned(ira, instruction->len->child, ira->codegen->builtin_types.entry_u32, &len)) |
| 24668 | return ira->codegen->invalid_instruction; | 25620 | return ira->codegen->invalid_inst_gen; |
| 24669 | | 25621 | |
| 24670 | ZigType *elem_type = ir_resolve_vector_elem_type(ira, instruction->elem_type->child); | 25622 | ZigType *elem_type = ir_resolve_vector_elem_type(ira, instruction->elem_type->child); |
| 24671 | if (type_is_invalid(elem_type)) | 25623 | if (type_is_invalid(elem_type)) |
| 24672 | return ira->codegen->invalid_instruction; | 25624 | return ira->codegen->invalid_inst_gen; |
| 24673 | | 25625 | |
| 24674 | ZigType *vector_type = get_vector_type(ira->codegen, len, elem_type); | 25626 | ZigType *vector_type = get_vector_type(ira->codegen, len, elem_type); |
| 24675 | | 25627 | |
| 24676 | return ir_const_type(ira, &instruction->base, vector_type); | 25628 | return ir_const_type(ira, &instruction->base.base, vector_type); |
| 24677 | } | 25629 | } |
| 24678 | | 25630 | |
| 24679 | static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *source_instr, | 25631 | static IrInstGen *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInst* source_instr, |
| 24680 | ZigType *scalar_type, IrInstruction *a, IrInstruction *b, IrInstruction *mask) | 25632 | ZigType *scalar_type, IrInstGen *a, IrInstGen *b, IrInstGen *mask) |
| 24681 | { | 25633 | { |
| 24682 | ir_assert(source_instr && scalar_type && a && b && mask, source_instr); | 25634 | ir_assert(source_instr && scalar_type && a && b && mask, source_instr); |
| 24683 | ir_assert(is_valid_vector_elem_type(scalar_type), source_instr); | 25635 | ir_assert(is_valid_vector_elem_type(scalar_type), source_instr); |
| ... | @@ -24688,15 +25640,15 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24688,15 +25640,15 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24688 | } else if (mask->value->type->id == ZigTypeIdArray) { | 25640 | } else if (mask->value->type->id == ZigTypeIdArray) { |
| 24689 | len_mask = mask->value->type->data.array.len; | 25641 | len_mask = mask->value->type->data.array.len; |
| 24690 | } else { | 25642 | } else { |
| 24691 | ir_add_error(ira, mask, | 25643 | ir_add_error(ira, &mask->base, |
| 24692 | buf_sprintf("expected vector or array, found '%s'", | 25644 | buf_sprintf("expected vector or array, found '%s'", |
| 24693 | buf_ptr(&mask->value->type->name))); | 25645 | buf_ptr(&mask->value->type->name))); |
| 24694 | return ira->codegen->invalid_instruction; | 25646 | return ira->codegen->invalid_inst_gen; |
| 24695 | } | 25647 | } |
| 24696 | mask = ir_implicit_cast(ira, mask, get_vector_type(ira->codegen, len_mask, | 25648 | mask = ir_implicit_cast(ira, mask, get_vector_type(ira->codegen, len_mask, |
| 24697 | ira->codegen->builtin_types.entry_i32)); | 25649 | ira->codegen->builtin_types.entry_i32)); |
| 24698 | if (type_is_invalid(mask->value->type)) | 25650 | if (type_is_invalid(mask->value->type)) |
| 24699 | return ira->codegen->invalid_instruction; | 25651 | return ira->codegen->invalid_inst_gen; |
| 24700 | | 25652 | |
| 24701 | uint32_t len_a; | 25653 | uint32_t len_a; |
| 24702 | if (a->value->type->id == ZigTypeIdVector) { | 25654 | if (a->value->type->id == ZigTypeIdVector) { |
| ... | @@ -24706,11 +25658,11 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24706,11 +25658,11 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24706 | } else if (a->value->type->id == ZigTypeIdUndefined) { | 25658 | } else if (a->value->type->id == ZigTypeIdUndefined) { |
| 24707 | len_a = UINT32_MAX; | 25659 | len_a = UINT32_MAX; |
| 24708 | } else { | 25660 | } else { |
| 24709 | ir_add_error(ira, a, | 25661 | ir_add_error(ira, &a->base, |
| 24710 | buf_sprintf("expected vector or array with element type '%s', found '%s'", | 25662 | buf_sprintf("expected vector or array with element type '%s', found '%s'", |
| 24711 | buf_ptr(&scalar_type->name), | 25663 | buf_ptr(&scalar_type->name), |
| 24712 | buf_ptr(&a->value->type->name))); | 25664 | buf_ptr(&a->value->type->name))); |
| 24713 | return ira->codegen->invalid_instruction; | 25665 | return ira->codegen->invalid_inst_gen; |
| 24714 | } | 25666 | } |
| 24715 | | 25667 | |
| 24716 | uint32_t len_b; | 25668 | uint32_t len_b; |
| ... | @@ -24721,38 +25673,38 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24721,38 +25673,38 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24721 | } else if (b->value->type->id == ZigTypeIdUndefined) { | 25673 | } else if (b->value->type->id == ZigTypeIdUndefined) { |
| 24722 | len_b = UINT32_MAX; | 25674 | len_b = UINT32_MAX; |
| 24723 | } else { | 25675 | } else { |
| 24724 | ir_add_error(ira, b, | 25676 | ir_add_error(ira, &b->base, |
| 24725 | buf_sprintf("expected vector or array with element type '%s', found '%s'", | 25677 | buf_sprintf("expected vector or array with element type '%s', found '%s'", |
| 24726 | buf_ptr(&scalar_type->name), | 25678 | buf_ptr(&scalar_type->name), |
| 24727 | buf_ptr(&b->value->type->name))); | 25679 | buf_ptr(&b->value->type->name))); |
| 24728 | return ira->codegen->invalid_instruction; | 25680 | return ira->codegen->invalid_inst_gen; |
| 24729 | } | 25681 | } |
| 24730 | | 25682 | |
| 24731 | if (len_a == UINT32_MAX && len_b == UINT32_MAX) { | 25683 | if (len_a == UINT32_MAX && len_b == UINT32_MAX) { |
| 24732 | return ir_const_undef(ira, a, get_vector_type(ira->codegen, len_mask, scalar_type)); | 25684 | return ir_const_undef(ira, &a->base, get_vector_type(ira->codegen, len_mask, scalar_type)); |
| 24733 | } | 25685 | } |
| 24734 | | 25686 | |
| 24735 | if (len_a == UINT32_MAX) { | 25687 | if (len_a == UINT32_MAX) { |
| 24736 | len_a = len_b; | 25688 | len_a = len_b; |
| 24737 | a = ir_const_undef(ira, a, get_vector_type(ira->codegen, len_a, scalar_type)); | 25689 | a = ir_const_undef(ira, &a->base, get_vector_type(ira->codegen, len_a, scalar_type)); |
| 24738 | } else { | 25690 | } else { |
| 24739 | a = ir_implicit_cast(ira, a, get_vector_type(ira->codegen, len_a, scalar_type)); | 25691 | a = ir_implicit_cast(ira, a, get_vector_type(ira->codegen, len_a, scalar_type)); |
| 24740 | if (type_is_invalid(a->value->type)) | 25692 | if (type_is_invalid(a->value->type)) |
| 24741 | return ira->codegen->invalid_instruction; | 25693 | return ira->codegen->invalid_inst_gen; |
| 24742 | } | 25694 | } |
| 24743 | | 25695 | |
| 24744 | if (len_b == UINT32_MAX) { | 25696 | if (len_b == UINT32_MAX) { |
| 24745 | len_b = len_a; | 25697 | len_b = len_a; |
| 24746 | b = ir_const_undef(ira, b, get_vector_type(ira->codegen, len_b, scalar_type)); | 25698 | b = ir_const_undef(ira, &b->base, get_vector_type(ira->codegen, len_b, scalar_type)); |
| 24747 | } else { | 25699 | } else { |
| 24748 | b = ir_implicit_cast(ira, b, get_vector_type(ira->codegen, len_b, scalar_type)); | 25700 | b = ir_implicit_cast(ira, b, get_vector_type(ira->codegen, len_b, scalar_type)); |
| 24749 | if (type_is_invalid(b->value->type)) | 25701 | if (type_is_invalid(b->value->type)) |
| 24750 | return ira->codegen->invalid_instruction; | 25702 | return ira->codegen->invalid_inst_gen; |
| 24751 | } | 25703 | } |
| 24752 | | 25704 | |
| 24753 | ZigValue *mask_val = ir_resolve_const(ira, mask, UndefOk); | 25705 | ZigValue *mask_val = ir_resolve_const(ira, mask, UndefOk); |
| 24754 | if (mask_val == nullptr) | 25706 | if (mask_val == nullptr) |
| 24755 | return ira->codegen->invalid_instruction; | 25707 | return ira->codegen->invalid_inst_gen; |
| 24756 | | 25708 | |
| 24757 | expand_undef_array(ira->codegen, mask_val); | 25709 | expand_undef_array(ira->codegen, mask_val); |
| 24758 | | 25710 | |
| ... | @@ -24762,7 +25714,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24762,7 +25714,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24762 | continue; | 25714 | continue; |
| 24763 | int32_t v_i32 = bigint_as_signed(&mask_elem_val->data.x_bigint); | 25715 | int32_t v_i32 = bigint_as_signed(&mask_elem_val->data.x_bigint); |
| 24764 | uint32_t v; | 25716 | uint32_t v; |
| 24765 | IrInstruction *chosen_operand; | 25717 | IrInstGen *chosen_operand; |
| 24766 | if (v_i32 >= 0) { | 25718 | if (v_i32 >= 0) { |
| 24767 | v = (uint32_t)v_i32; | 25719 | v = (uint32_t)v_i32; |
| 24768 | chosen_operand = a; | 25720 | chosen_operand = a; |
| ... | @@ -24771,16 +25723,16 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24771,16 +25723,16 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24771 | chosen_operand = b; | 25723 | chosen_operand = b; |
| 24772 | } | 25724 | } |
| 24773 | if (v >= chosen_operand->value->type->data.vector.len) { | 25725 | if (v >= chosen_operand->value->type->data.vector.len) { |
| 24774 | ErrorMsg *msg = ir_add_error(ira, mask, | 25726 | ErrorMsg *msg = ir_add_error(ira, &mask->base, |
| 24775 | buf_sprintf("mask index '%u' has out-of-bounds selection", i)); | 25727 | buf_sprintf("mask index '%u' has out-of-bounds selection", i)); |
| 24776 | add_error_note(ira->codegen, msg, chosen_operand->source_node, | 25728 | add_error_note(ira->codegen, msg, chosen_operand->base.source_node, |
| 24777 | buf_sprintf("selected index '%u' out of bounds of %s", v, | 25729 | buf_sprintf("selected index '%u' out of bounds of %s", v, |
| 24778 | buf_ptr(&chosen_operand->value->type->name))); | 25730 | buf_ptr(&chosen_operand->value->type->name))); |
| 24779 | if (chosen_operand == a && v < len_a + len_b) { | 25731 | if (chosen_operand == a && v < len_a + len_b) { |
| 24780 | add_error_note(ira->codegen, msg, b->source_node, | 25732 | add_error_note(ira->codegen, msg, b->base.source_node, |
| 24781 | buf_create_from_str("selections from the second vector are specified with negative numbers")); | 25733 | buf_create_from_str("selections from the second vector are specified with negative numbers")); |
| 24782 | } | 25734 | } |
| 24783 | return ira->codegen->invalid_instruction; | 25735 | return ira->codegen->invalid_inst_gen; |
| 24784 | } | 25736 | } |
| 24785 | } | 25737 | } |
| 24786 | | 25738 | |
| ... | @@ -24788,16 +25740,16 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24788,16 +25740,16 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24788 | if (instr_is_comptime(a) && instr_is_comptime(b)) { | 25740 | if (instr_is_comptime(a) && instr_is_comptime(b)) { |
| 24789 | ZigValue *a_val = ir_resolve_const(ira, a, UndefOk); | 25741 | ZigValue *a_val = ir_resolve_const(ira, a, UndefOk); |
| 24790 | if (a_val == nullptr) | 25742 | if (a_val == nullptr) |
| 24791 | return ira->codegen->invalid_instruction; | 25743 | return ira->codegen->invalid_inst_gen; |
| 24792 | | 25744 | |
| 24793 | ZigValue *b_val = ir_resolve_const(ira, b, UndefOk); | 25745 | ZigValue *b_val = ir_resolve_const(ira, b, UndefOk); |
| 24794 | if (b_val == nullptr) | 25746 | if (b_val == nullptr) |
| 24795 | return ira->codegen->invalid_instruction; | 25747 | return ira->codegen->invalid_inst_gen; |
| 24796 | | 25748 | |
| 24797 | expand_undef_array(ira->codegen, a_val); | 25749 | expand_undef_array(ira->codegen, a_val); |
| 24798 | expand_undef_array(ira->codegen, b_val); | 25750 | expand_undef_array(ira->codegen, b_val); |
| 24799 | | 25751 | |
| 24800 | IrInstruction *result = ir_const(ira, source_instr, result_type); | 25752 | IrInstGen *result = ir_const(ira, source_instr, result_type); |
| 24801 | result->value->data.x_array.data.s_none.elements = create_const_vals(len_mask); | 25753 | result->value->data.x_array.data.s_none.elements = create_const_vals(len_mask); |
| 24802 | for (uint32_t i = 0; i < mask_val->type->data.vector.len; i += 1) { | 25754 | for (uint32_t i = 0; i < mask_val->type->data.vector.len; i += 1) { |
| 24803 | ZigValue *mask_elem_val = &mask_val->data.x_array.data.s_none.elements[i]; | 25755 | ZigValue *mask_elem_val = &mask_val->data.x_array.data.s_none.elements[i]; |
| ... | @@ -24829,7 +25781,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24829,7 +25781,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24829 | uint32_t len_min = min(len_a, len_b); | 25781 | uint32_t len_min = min(len_a, len_b); |
| 24830 | uint32_t len_max = max(len_a, len_b); | 25782 | uint32_t len_max = max(len_a, len_b); |
| 24831 | | 25783 | |
| 24832 | IrInstruction *expand_mask = ir_const(ira, mask, | 25784 | IrInstGen *expand_mask = ir_const(ira, &mask->base, |
| 24833 | get_vector_type(ira->codegen, len_max, ira->codegen->builtin_types.entry_i32)); | 25785 | get_vector_type(ira->codegen, len_max, ira->codegen->builtin_types.entry_i32)); |
| 24834 | expand_mask->value->data.x_array.data.s_none.elements = create_const_vals(len_max); | 25786 | expand_mask->value->data.x_array.data.s_none.elements = create_const_vals(len_max); |
| 24835 | uint32_t i = 0; | 25787 | uint32_t i = 0; |
| ... | @@ -24838,7 +25790,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24838,7 +25790,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24838 | for (; i < len_max; i += 1) | 25790 | for (; i < len_max; i += 1) |
| 24839 | bigint_init_signed(&expand_mask->value->data.x_array.data.s_none.elements[i].data.x_bigint, -1); | 25791 | bigint_init_signed(&expand_mask->value->data.x_array.data.s_none.elements[i].data.x_bigint, -1); |
| 24840 | | 25792 | |
| 24841 | IrInstruction *undef = ir_const_undef(ira, source_instr, | 25793 | IrInstGen *undef = ir_const_undef(ira, source_instr, |
| 24842 | get_vector_type(ira->codegen, len_min, scalar_type)); | 25794 | get_vector_type(ira->codegen, len_min, scalar_type)); |
| 24843 | | 25795 | |
| 24844 | if (len_b < len_a) { | 25796 | if (len_b < len_a) { |
| ... | @@ -24848,62 +25800,59 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24848,62 +25800,59 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24848 | } | 25800 | } |
| 24849 | } | 25801 | } |
| 24850 | | 25802 | |
| 24851 | IrInstruction *result = ir_build_shuffle_vector(&ira->new_irb, | 25803 | return ir_build_shuffle_vector_gen(ira, source_instr->scope, source_instr->source_node, |
| 24852 | source_instr->scope, source_instr->source_node, | 25804 | result_type, a, b, mask); |
| 24853 | nullptr, a, b, mask); | | |
| 24854 | result->value->type = result_type; | | |
| 24855 | return result; | | |
| 24856 | } | 25805 | } |
| 24857 | | 25806 | |
| 24858 | static IrInstruction *ir_analyze_instruction_shuffle_vector(IrAnalyze *ira, IrInstructionShuffleVector *instruction) { | 25807 | static IrInstGen *ir_analyze_instruction_shuffle_vector(IrAnalyze *ira, IrInstSrcShuffleVector *instruction) { |
| 24859 | ZigType *scalar_type = ir_resolve_vector_elem_type(ira, instruction->scalar_type); | 25808 | ZigType *scalar_type = ir_resolve_vector_elem_type(ira, instruction->scalar_type->child); |
| 24860 | if (type_is_invalid(scalar_type)) | 25809 | if (type_is_invalid(scalar_type)) |
| 24861 | return ira->codegen->invalid_instruction; | 25810 | return ira->codegen->invalid_inst_gen; |
| 24862 | | 25811 | |
| 24863 | IrInstruction *a = instruction->a->child; | 25812 | IrInstGen *a = instruction->a->child; |
| 24864 | if (type_is_invalid(a->value->type)) | 25813 | if (type_is_invalid(a->value->type)) |
| 24865 | return ira->codegen->invalid_instruction; | 25814 | return ira->codegen->invalid_inst_gen; |
| 24866 | | 25815 | |
| 24867 | IrInstruction *b = instruction->b->child; | 25816 | IrInstGen *b = instruction->b->child; |
| 24868 | if (type_is_invalid(b->value->type)) | 25817 | if (type_is_invalid(b->value->type)) |
| 24869 | return ira->codegen->invalid_instruction; | 25818 | return ira->codegen->invalid_inst_gen; |
| 24870 | | 25819 | |
| 24871 | IrInstruction *mask = instruction->mask->child; | 25820 | IrInstGen *mask = instruction->mask->child; |
| 24872 | if (type_is_invalid(mask->value->type)) | 25821 | if (type_is_invalid(mask->value->type)) |
| 24873 | return ira->codegen->invalid_instruction; | 25822 | return ira->codegen->invalid_inst_gen; |
| 24874 | | 25823 | |
| 24875 | return ir_analyze_shuffle_vector(ira, &instruction->base, scalar_type, a, b, mask); | 25824 | return ir_analyze_shuffle_vector(ira, &instruction->base.base, scalar_type, a, b, mask); |
| 24876 | } | 25825 | } |
| 24877 | | 25826 | |
| 24878 | static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstructionSplatSrc *instruction) { | 25827 | static IrInstGen *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstSrcSplat *instruction) { |
| 24879 | Error err; | 25828 | Error err; |
| 24880 | | 25829 | |
| 24881 | IrInstruction *len = instruction->len->child; | 25830 | IrInstGen *len = instruction->len->child; |
| 24882 | if (type_is_invalid(len->value->type)) | 25831 | if (type_is_invalid(len->value->type)) |
| 24883 | return ira->codegen->invalid_instruction; | 25832 | return ira->codegen->invalid_inst_gen; |
| 24884 | | 25833 | |
| 24885 | IrInstruction *scalar = instruction->scalar->child; | 25834 | IrInstGen *scalar = instruction->scalar->child; |
| 24886 | if (type_is_invalid(scalar->value->type)) | 25835 | if (type_is_invalid(scalar->value->type)) |
| 24887 | return ira->codegen->invalid_instruction; | 25836 | return ira->codegen->invalid_inst_gen; |
| 24888 | | 25837 | |
| 24889 | uint64_t len_u64; | 25838 | uint64_t len_u64; |
| 24890 | if (!ir_resolve_unsigned(ira, len, ira->codegen->builtin_types.entry_u32, &len_u64)) | 25839 | if (!ir_resolve_unsigned(ira, len, ira->codegen->builtin_types.entry_u32, &len_u64)) |
| 24891 | return ira->codegen->invalid_instruction; | 25840 | return ira->codegen->invalid_inst_gen; |
| 24892 | uint32_t len_int = len_u64; | 25841 | uint32_t len_int = len_u64; |
| 24893 | | 25842 | |
| 24894 | if ((err = ir_validate_vector_elem_type(ira, scalar, scalar->value->type))) | 25843 | if ((err = ir_validate_vector_elem_type(ira, scalar->base.source_node, scalar->value->type))) |
| 24895 | return ira->codegen->invalid_instruction; | 25844 | return ira->codegen->invalid_inst_gen; |
| 24896 | | 25845 | |
| 24897 | ZigType *return_type = get_vector_type(ira->codegen, len_int, scalar->value->type); | 25846 | ZigType *return_type = get_vector_type(ira->codegen, len_int, scalar->value->type); |
| 24898 | | 25847 | |
| 24899 | if (instr_is_comptime(scalar)) { | 25848 | if (instr_is_comptime(scalar)) { |
| 24900 | ZigValue *scalar_val = ir_resolve_const(ira, scalar, UndefOk); | 25849 | ZigValue *scalar_val = ir_resolve_const(ira, scalar, UndefOk); |
| 24901 | if (scalar_val == nullptr) | 25850 | if (scalar_val == nullptr) |
| 24902 | return ira->codegen->invalid_instruction; | 25851 | return ira->codegen->invalid_inst_gen; |
| 24903 | if (scalar_val->special == ConstValSpecialUndef) | 25852 | if (scalar_val->special == ConstValSpecialUndef) |
| 24904 | return ir_const_undef(ira, &instruction->base, return_type); | 25853 | return ir_const_undef(ira, &instruction->base.base, return_type); |
| 24905 | | 25854 | |
| 24906 | IrInstruction *result = ir_const(ira, &instruction->base, return_type); | 25855 | IrInstGen *result = ir_const(ira, &instruction->base.base, return_type); |
| 24907 | result->value->data.x_array.data.s_none.elements = create_const_vals(len_int); | 25856 | result->value->data.x_array.data.s_none.elements = create_const_vals(len_int); |
| 24908 | for (uint32_t i = 0; i < len_int; i += 1) { | 25857 | for (uint32_t i = 0; i < len_int; i += 1) { |
| 24909 | copy_const_val(&result->value->data.x_array.data.s_none.elements[i], scalar_val); | 25858 | copy_const_val(&result->value->data.x_array.data.s_none.elements[i], scalar_val); |
| ... | @@ -24911,48 +25860,45 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction | ... | @@ -24911,48 +25860,45 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction |
| 24911 | return result; | 25860 | return result; |
| 24912 | } | 25861 | } |
| 24913 | | 25862 | |
| 24914 | return ir_build_splat_gen(ira, &instruction->base, return_type, scalar); | 25863 | return ir_build_splat_gen(ira, &instruction->base.base, return_type, scalar); |
| 24915 | } | 25864 | } |
| 24916 | | 25865 | |
| 24917 | static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstructionBoolNot *instruction) { | 25866 | static IrInstGen *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstSrcBoolNot *instruction) { |
| 24918 | IrInstruction *value = instruction->value->child; | 25867 | IrInstGen *value = instruction->value->child; |
| 24919 | if (type_is_invalid(value->value->type)) | 25868 | if (type_is_invalid(value->value->type)) |
| 24920 | return ira->codegen->invalid_instruction; | 25869 | return ira->codegen->invalid_inst_gen; |
| 24921 | | 25870 | |
| 24922 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; | 25871 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| 24923 | | 25872 | |
| 24924 | IrInstruction *casted_value = ir_implicit_cast(ira, value, bool_type); | 25873 | IrInstGen *casted_value = ir_implicit_cast(ira, value, bool_type); |
| 24925 | if (type_is_invalid(casted_value->value->type)) | 25874 | if (type_is_invalid(casted_value->value->type)) |
| 24926 | return ira->codegen->invalid_instruction; | 25875 | return ira->codegen->invalid_inst_gen; |
| 24927 | | 25876 | |
| 24928 | if (instr_is_comptime(casted_value)) { | 25877 | if (instr_is_comptime(casted_value)) { |
| 24929 | ZigValue *value = ir_resolve_const(ira, casted_value, UndefBad); | 25878 | ZigValue *value = ir_resolve_const(ira, casted_value, UndefBad); |
| 24930 | if (value == nullptr) | 25879 | if (value == nullptr) |
| 24931 | return ira->codegen->invalid_instruction; | 25880 | return ira->codegen->invalid_inst_gen; |
| 24932 | | 25881 | |
| 24933 | return ir_const_bool(ira, &instruction->base, !value->data.x_bool); | 25882 | return ir_const_bool(ira, &instruction->base.base, !value->data.x_bool); |
| 24934 | } | 25883 | } |
| 24935 | | 25884 | |
| 24936 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, instruction->base.scope, | 25885 | return ir_build_bool_not_gen(ira, &instruction->base.base, casted_value); |
| 24937 | instruction->base.source_node, casted_value); | | |
| 24938 | result->value->type = bool_type; | | |
| 24939 | return result; | | |
| 24940 | } | 25886 | } |
| 24941 | | 25887 | |
| 24942 | static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructionMemset *instruction) { | 25888 | static IrInstGen *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstSrcMemset *instruction) { |
| 24943 | Error err; | 25889 | Error err; |
| 24944 | | 25890 | |
| 24945 | IrInstruction *dest_ptr = instruction->dest_ptr->child; | 25891 | IrInstGen *dest_ptr = instruction->dest_ptr->child; |
| 24946 | if (type_is_invalid(dest_ptr->value->type)) | 25892 | if (type_is_invalid(dest_ptr->value->type)) |
| 24947 | return ira->codegen->invalid_instruction; | 25893 | return ira->codegen->invalid_inst_gen; |
| 24948 | | 25894 | |
| 24949 | IrInstruction *byte_value = instruction->byte->child; | 25895 | IrInstGen *byte_value = instruction->byte->child; |
| 24950 | if (type_is_invalid(byte_value->value->type)) | 25896 | if (type_is_invalid(byte_value->value->type)) |
| 24951 | return ira->codegen->invalid_instruction; | 25897 | return ira->codegen->invalid_inst_gen; |
| 24952 | | 25898 | |
| 24953 | IrInstruction *count_value = instruction->count->child; | 25899 | IrInstGen *count_value = instruction->count->child; |
| 24954 | if (type_is_invalid(count_value->value->type)) | 25900 | if (type_is_invalid(count_value->value->type)) |
| 24955 | return ira->codegen->invalid_instruction; | 25901 | return ira->codegen->invalid_inst_gen; |
| 24956 | | 25902 | |
| 24957 | ZigType *dest_uncasted_type = dest_ptr->value->type; | 25903 | ZigType *dest_uncasted_type = dest_ptr->value->type; |
| 24958 | bool dest_is_volatile = (dest_uncasted_type->id == ZigTypeIdPointer) && | 25904 | bool dest_is_volatile = (dest_uncasted_type->id == ZigTypeIdPointer) && |
| ... | @@ -24963,24 +25909,24 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio | ... | @@ -24963,24 +25909,24 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 24963 | uint32_t dest_align; | 25909 | uint32_t dest_align; |
| 24964 | if (dest_uncasted_type->id == ZigTypeIdPointer) { | 25910 | if (dest_uncasted_type->id == ZigTypeIdPointer) { |
| 24965 | if ((err = resolve_ptr_align(ira, dest_uncasted_type, &dest_align))) | 25911 | if ((err = resolve_ptr_align(ira, dest_uncasted_type, &dest_align))) |
| 24966 | return ira->codegen->invalid_instruction; | 25912 | return ira->codegen->invalid_inst_gen; |
| 24967 | } else { | 25913 | } else { |
| 24968 | dest_align = get_abi_alignment(ira->codegen, u8); | 25914 | dest_align = get_abi_alignment(ira->codegen, u8); |
| 24969 | } | 25915 | } |
| 24970 | ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile, | 25916 | ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile, |
| 24971 | PtrLenUnknown, dest_align, 0, 0, false); | 25917 | PtrLenUnknown, dest_align, 0, 0, false); |
| 24972 | | 25918 | |
| 24973 | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr); | 25919 | IrInstGen *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr); |
| 24974 | if (type_is_invalid(casted_dest_ptr->value->type)) | 25920 | if (type_is_invalid(casted_dest_ptr->value->type)) |
| 24975 | return ira->codegen->invalid_instruction; | 25921 | return ira->codegen->invalid_inst_gen; |
| 24976 | | 25922 | |
| 24977 | IrInstruction *casted_byte = ir_implicit_cast(ira, byte_value, u8); | 25923 | IrInstGen *casted_byte = ir_implicit_cast(ira, byte_value, u8); |
| 24978 | if (type_is_invalid(casted_byte->value->type)) | 25924 | if (type_is_invalid(casted_byte->value->type)) |
| 24979 | return ira->codegen->invalid_instruction; | 25925 | return ira->codegen->invalid_inst_gen; |
| 24980 | | 25926 | |
| 24981 | IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize); | 25927 | IrInstGen *casted_count = ir_implicit_cast(ira, count_value, usize); |
| 24982 | if (type_is_invalid(casted_count->value->type)) | 25928 | if (type_is_invalid(casted_count->value->type)) |
| 24983 | return ira->codegen->invalid_instruction; | 25929 | return ira->codegen->invalid_inst_gen; |
| 24984 | | 25930 | |
| 24985 | // TODO test this at comptime with u8 and non-u8 types | 25931 | // TODO test this at comptime with u8 and non-u8 types |
| 24986 | if (instr_is_comptime(casted_dest_ptr) && | 25932 | if (instr_is_comptime(casted_dest_ptr) && |
| ... | @@ -24989,15 +25935,15 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio | ... | @@ -24989,15 +25935,15 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 24989 | { | 25935 | { |
| 24990 | ZigValue *dest_ptr_val = ir_resolve_const(ira, casted_dest_ptr, UndefBad); | 25936 | ZigValue *dest_ptr_val = ir_resolve_const(ira, casted_dest_ptr, UndefBad); |
| 24991 | if (dest_ptr_val == nullptr) | 25937 | if (dest_ptr_val == nullptr) |
| 24992 | return ira->codegen->invalid_instruction; | 25938 | return ira->codegen->invalid_inst_gen; |
| 24993 | | 25939 | |
| 24994 | ZigValue *byte_val = ir_resolve_const(ira, casted_byte, UndefOk); | 25940 | ZigValue *byte_val = ir_resolve_const(ira, casted_byte, UndefOk); |
| 24995 | if (byte_val == nullptr) | 25941 | if (byte_val == nullptr) |
| 24996 | return ira->codegen->invalid_instruction; | 25942 | return ira->codegen->invalid_inst_gen; |
| 24997 | | 25943 | |
| 24998 | ZigValue *count_val = ir_resolve_const(ira, casted_count, UndefBad); | 25944 | ZigValue *count_val = ir_resolve_const(ira, casted_count, UndefBad); |
| 24999 | if (count_val == nullptr) | 25945 | if (count_val == nullptr) |
| 25000 | return ira->codegen->invalid_instruction; | 25946 | return ira->codegen->invalid_inst_gen; |
| 25001 | | 25947 | |
| 25002 | if (casted_dest_ptr->value->data.x_ptr.special != ConstPtrSpecialHardCodedAddr && | 25948 | if (casted_dest_ptr->value->data.x_ptr.special != ConstPtrSpecialHardCodedAddr && |
| 25003 | casted_dest_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) | 25949 | casted_dest_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) |
| ... | @@ -25042,38 +25988,35 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio | ... | @@ -25042,38 +25988,35 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 25042 | size_t count = bigint_as_usize(&count_val->data.x_bigint); | 25988 | size_t count = bigint_as_usize(&count_val->data.x_bigint); |
| 25043 | size_t end = start + count; | 25989 | size_t end = start + count; |
| 25044 | if (end > bound_end) { | 25990 | if (end > bound_end) { |
| 25045 | ir_add_error(ira, count_value, buf_sprintf("out of bounds pointer access")); | 25991 | ir_add_error(ira, &count_value->base, buf_sprintf("out of bounds pointer access")); |
| 25046 | return ira->codegen->invalid_instruction; | 25992 | return ira->codegen->invalid_inst_gen; |
| 25047 | } | 25993 | } |
| 25048 | | 25994 | |
| 25049 | for (size_t i = start; i < end; i += 1) { | 25995 | for (size_t i = start; i < end; i += 1) { |
| 25050 | copy_const_val(&dest_elements[i], byte_val); | 25996 | copy_const_val(&dest_elements[i], byte_val); |
| 25051 | } | 25997 | } |
| 25052 | | 25998 | |
| 25053 | return ir_const_void(ira, &instruction->base); | 25999 | return ir_const_void(ira, &instruction->base.base); |
| 25054 | } | 26000 | } |
| 25055 | } | 26001 | } |
| 25056 | | 26002 | |
| 25057 | IrInstruction *result = ir_build_memset(&ira->new_irb, instruction->base.scope, instruction->base.source_node, | 26003 | return ir_build_memset_gen(ira, &instruction->base.base, casted_dest_ptr, casted_byte, casted_count); |
| 25058 | casted_dest_ptr, casted_byte, casted_count); | | |
| 25059 | result->value->type = ira->codegen->builtin_types.entry_void; | | |
| 25060 | return result; | | |
| 25061 | } | 26004 | } |
| 25062 | | 26005 | |
| 25063 | static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructionMemcpy *instruction) { | 26006 | static IrInstGen *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstSrcMemcpy *instruction) { |
| 25064 | Error err; | 26007 | Error err; |
| 25065 | | 26008 | |
| 25066 | IrInstruction *dest_ptr = instruction->dest_ptr->child; | 26009 | IrInstGen *dest_ptr = instruction->dest_ptr->child; |
| 25067 | if (type_is_invalid(dest_ptr->value->type)) | 26010 | if (type_is_invalid(dest_ptr->value->type)) |
| 25068 | return ira->codegen->invalid_instruction; | 26011 | return ira->codegen->invalid_inst_gen; |
| 25069 | | 26012 | |
| 25070 | IrInstruction *src_ptr = instruction->src_ptr->child; | 26013 | IrInstGen *src_ptr = instruction->src_ptr->child; |
| 25071 | if (type_is_invalid(src_ptr->value->type)) | 26014 | if (type_is_invalid(src_ptr->value->type)) |
| 25072 | return ira->codegen->invalid_instruction; | 26015 | return ira->codegen->invalid_inst_gen; |
| 25073 | | 26016 | |
| 25074 | IrInstruction *count_value = instruction->count->child; | 26017 | IrInstGen *count_value = instruction->count->child; |
| 25075 | if (type_is_invalid(count_value->value->type)) | 26018 | if (type_is_invalid(count_value->value->type)) |
| 25076 | return ira->codegen->invalid_instruction; | 26019 | return ira->codegen->invalid_inst_gen; |
| 25077 | | 26020 | |
| 25078 | ZigType *u8 = ira->codegen->builtin_types.entry_u8; | 26021 | ZigType *u8 = ira->codegen->builtin_types.entry_u8; |
| 25079 | ZigType *dest_uncasted_type = dest_ptr->value->type; | 26022 | ZigType *dest_uncasted_type = dest_ptr->value->type; |
| ... | @@ -25086,7 +26029,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -25086,7 +26029,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 25086 | uint32_t dest_align; | 26029 | uint32_t dest_align; |
| 25087 | if (dest_uncasted_type->id == ZigTypeIdPointer) { | 26030 | if (dest_uncasted_type->id == ZigTypeIdPointer) { |
| 25088 | if ((err = resolve_ptr_align(ira, dest_uncasted_type, &dest_align))) | 26031 | if ((err = resolve_ptr_align(ira, dest_uncasted_type, &dest_align))) |
| 25089 | return ira->codegen->invalid_instruction; | 26032 | return ira->codegen->invalid_inst_gen; |
| 25090 | } else { | 26033 | } else { |
| 25091 | dest_align = get_abi_alignment(ira->codegen, u8); | 26034 | dest_align = get_abi_alignment(ira->codegen, u8); |
| 25092 | } | 26035 | } |
| ... | @@ -25094,7 +26037,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -25094,7 +26037,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 25094 | uint32_t src_align; | 26037 | uint32_t src_align; |
| 25095 | if (src_uncasted_type->id == ZigTypeIdPointer) { | 26038 | if (src_uncasted_type->id == ZigTypeIdPointer) { |
| 25096 | if ((err = resolve_ptr_align(ira, src_uncasted_type, &src_align))) | 26039 | if ((err = resolve_ptr_align(ira, src_uncasted_type, &src_align))) |
| 25097 | return ira->codegen->invalid_instruction; | 26040 | return ira->codegen->invalid_inst_gen; |
| 25098 | } else { | 26041 | } else { |
| 25099 | src_align = get_abi_alignment(ira->codegen, u8); | 26042 | src_align = get_abi_alignment(ira->codegen, u8); |
| 25100 | } | 26043 | } |
| ... | @@ -25105,17 +26048,17 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -25105,17 +26048,17 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 25105 | ZigType *u8_ptr_const = get_pointer_to_type_extra(ira->codegen, u8, true, src_is_volatile, | 26048 | ZigType *u8_ptr_const = get_pointer_to_type_extra(ira->codegen, u8, true, src_is_volatile, |
| 25106 | PtrLenUnknown, src_align, 0, 0, false); | 26049 | PtrLenUnknown, src_align, 0, 0, false); |
| 25107 | | 26050 | |
| 25108 | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut); | 26051 | IrInstGen *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut); |
| 25109 | if (type_is_invalid(casted_dest_ptr->value->type)) | 26052 | if (type_is_invalid(casted_dest_ptr->value->type)) |
| 25110 | return ira->codegen->invalid_instruction; | 26053 | return ira->codegen->invalid_inst_gen; |
| 25111 | | 26054 | |
| 25112 | IrInstruction *casted_src_ptr = ir_implicit_cast(ira, src_ptr, u8_ptr_const); | 26055 | IrInstGen *casted_src_ptr = ir_implicit_cast(ira, src_ptr, u8_ptr_const); |
| 25113 | if (type_is_invalid(casted_src_ptr->value->type)) | 26056 | if (type_is_invalid(casted_src_ptr->value->type)) |
| 25114 | return ira->codegen->invalid_instruction; | 26057 | return ira->codegen->invalid_inst_gen; |
| 25115 | | 26058 | |
| 25116 | IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize); | 26059 | IrInstGen *casted_count = ir_implicit_cast(ira, count_value, usize); |
| 25117 | if (type_is_invalid(casted_count->value->type)) | 26060 | if (type_is_invalid(casted_count->value->type)) |
| 25118 | return ira->codegen->invalid_instruction; | 26061 | return ira->codegen->invalid_inst_gen; |
| 25119 | | 26062 | |
| 25120 | // TODO test this at comptime with u8 and non-u8 types | 26063 | // TODO test this at comptime with u8 and non-u8 types |
| 25121 | // TODO test with dest ptr being a global runtime variable | 26064 | // TODO test with dest ptr being a global runtime variable |
| ... | @@ -25125,15 +26068,15 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -25125,15 +26068,15 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 25125 | { | 26068 | { |
| 25126 | ZigValue *dest_ptr_val = ir_resolve_const(ira, casted_dest_ptr, UndefBad); | 26069 | ZigValue *dest_ptr_val = ir_resolve_const(ira, casted_dest_ptr, UndefBad); |
| 25127 | if (dest_ptr_val == nullptr) | 26070 | if (dest_ptr_val == nullptr) |
| 25128 | return ira->codegen->invalid_instruction; | 26071 | return ira->codegen->invalid_inst_gen; |
| 25129 | | 26072 | |
| 25130 | ZigValue *src_ptr_val = ir_resolve_const(ira, casted_src_ptr, UndefBad); | 26073 | ZigValue *src_ptr_val = ir_resolve_const(ira, casted_src_ptr, UndefBad); |
| 25131 | if (src_ptr_val == nullptr) | 26074 | if (src_ptr_val == nullptr) |
| 25132 | return ira->codegen->invalid_instruction; | 26075 | return ira->codegen->invalid_inst_gen; |
| 25133 | | 26076 | |
| 25134 | ZigValue *count_val = ir_resolve_const(ira, casted_count, UndefBad); | 26077 | ZigValue *count_val = ir_resolve_const(ira, casted_count, UndefBad); |
| 25135 | if (count_val == nullptr) | 26078 | if (count_val == nullptr) |
| 25136 | return ira->codegen->invalid_instruction; | 26079 | return ira->codegen->invalid_inst_gen; |
| 25137 | | 26080 | |
| 25138 | if (dest_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 26081 | if (dest_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 25139 | size_t count = bigint_as_usize(&count_val->data.x_bigint); | 26082 | size_t count = bigint_as_usize(&count_val->data.x_bigint); |
| ... | @@ -25176,8 +26119,8 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -25176,8 +26119,8 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 25176 | } | 26119 | } |
| 25177 | | 26120 | |
| 25178 | if (dest_start + count > dest_end) { | 26121 | if (dest_start + count > dest_end) { |
| 25179 | ir_add_error(ira, &instruction->base, buf_sprintf("out of bounds pointer access")); | 26122 | ir_add_error(ira, &instruction->base.base, buf_sprintf("out of bounds pointer access")); |
| 25180 | return ira->codegen->invalid_instruction; | 26123 | return ira->codegen->invalid_inst_gen; |
| 25181 | } | 26124 | } |
| 25182 | | 26125 | |
| 25183 | ZigValue *src_elements; | 26126 | ZigValue *src_elements; |
| ... | @@ -25219,8 +26162,8 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -25219,8 +26162,8 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 25219 | } | 26162 | } |
| 25220 | | 26163 | |
| 25221 | if (src_start + count > src_end) { | 26164 | if (src_start + count > src_end) { |
| 25222 | ir_add_error(ira, &instruction->base, buf_sprintf("out of bounds pointer access")); | 26165 | ir_add_error(ira, &instruction->base.base, buf_sprintf("out of bounds pointer access")); |
| 25223 | return ira->codegen->invalid_instruction; | 26166 | return ira->codegen->invalid_inst_gen; |
| 25224 | } | 26167 | } |
| 25225 | | 26168 | |
| 25226 | // TODO check for noalias violations - this should be generalized to work for any function | 26169 | // TODO check for noalias violations - this should be generalized to work for any function |
| ... | @@ -25229,42 +26172,39 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -25229,42 +26172,39 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 25229 | copy_const_val(&dest_elements[dest_start + i], &src_elements[src_start + i]); | 26172 | copy_const_val(&dest_elements[dest_start + i], &src_elements[src_start + i]); |
| 25230 | } | 26173 | } |
| 25231 | | 26174 | |
| 25232 | return ir_const_void(ira, &instruction->base); | 26175 | return ir_const_void(ira, &instruction->base.base); |
| 25233 | } | 26176 | } |
| 25234 | } | 26177 | } |
| 25235 | | 26178 | |
| 25236 | IrInstruction *result = ir_build_memcpy(&ira->new_irb, instruction->base.scope, instruction->base.source_node, | 26179 | return ir_build_memcpy_gen(ira, &instruction->base.base, casted_dest_ptr, casted_src_ptr, casted_count); |
| 25237 | casted_dest_ptr, casted_src_ptr, casted_count); | | |
| 25238 | result->value->type = ira->codegen->builtin_types.entry_void; | | |
| 25239 | return result; | | |
| 25240 | } | 26180 | } |
| 25241 | | 26181 | |
| 25242 | static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSliceSrc *instruction) { | 26182 | static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *instruction) { |
| 25243 | IrInstruction *ptr_ptr = instruction->ptr->child; | 26183 | IrInstGen *ptr_ptr = instruction->ptr->child; |
| 25244 | if (type_is_invalid(ptr_ptr->value->type)) | 26184 | if (type_is_invalid(ptr_ptr->value->type)) |
| 25245 | return ira->codegen->invalid_instruction; | 26185 | return ira->codegen->invalid_inst_gen; |
| 25246 | | 26186 | |
| 25247 | ZigType *ptr_ptr_type = ptr_ptr->value->type; | 26187 | ZigType *ptr_ptr_type = ptr_ptr->value->type; |
| 25248 | assert(ptr_ptr_type->id == ZigTypeIdPointer); | 26188 | assert(ptr_ptr_type->id == ZigTypeIdPointer); |
| 25249 | ZigType *array_type = ptr_ptr_type->data.pointer.child_type; | 26189 | ZigType *array_type = ptr_ptr_type->data.pointer.child_type; |
| 25250 | | 26190 | |
| 25251 | IrInstruction *start = instruction->start->child; | 26191 | IrInstGen *start = instruction->start->child; |
| 25252 | if (type_is_invalid(start->value->type)) | 26192 | if (type_is_invalid(start->value->type)) |
| 25253 | return ira->codegen->invalid_instruction; | 26193 | return ira->codegen->invalid_inst_gen; |
| 25254 | | 26194 | |
| 25255 | ZigType *usize = ira->codegen->builtin_types.entry_usize; | 26195 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 25256 | IrInstruction *casted_start = ir_implicit_cast(ira, start, usize); | 26196 | IrInstGen *casted_start = ir_implicit_cast(ira, start, usize); |
| 25257 | if (type_is_invalid(casted_start->value->type)) | 26197 | if (type_is_invalid(casted_start->value->type)) |
| 25258 | return ira->codegen->invalid_instruction; | 26198 | return ira->codegen->invalid_inst_gen; |
| 25259 | | 26199 | |
| 25260 | IrInstruction *end; | 26200 | IrInstGen *end; |
| 25261 | if (instruction->end) { | 26201 | if (instruction->end) { |
| 25262 | end = instruction->end->child; | 26202 | end = instruction->end->child; |
| 25263 | if (type_is_invalid(end->value->type)) | 26203 | if (type_is_invalid(end->value->type)) |
| 25264 | return ira->codegen->invalid_instruction; | 26204 | return ira->codegen->invalid_inst_gen; |
| 25265 | end = ir_implicit_cast(ira, end, usize); | 26205 | end = ir_implicit_cast(ira, end, usize); |
| 25266 | if (type_is_invalid(end->value->type)) | 26206 | if (type_is_invalid(end->value->type)) |
| 25267 | return ira->codegen->invalid_instruction; | 26207 | return ira->codegen->invalid_inst_gen; |
| 25268 | } else { | 26208 | } else { |
| 25269 | end = nullptr; | 26209 | end = nullptr; |
| 25270 | } | 26210 | } |
| ... | @@ -25292,8 +26232,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -25292,8 +26232,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 25292 | PtrLenUnknown, | 26232 | PtrLenUnknown, |
| 25293 | array_type->data.pointer.explicit_alignment, 0, 0, false); | 26233 | array_type->data.pointer.explicit_alignment, 0, 0, false); |
| 25294 | } else { | 26234 | } else { |
| 25295 | ir_add_error(ira, &instruction->base, buf_sprintf("slice of single-item pointer")); | 26235 | ir_add_error(ira, &instruction->base.base, buf_sprintf("slice of single-item pointer")); |
| 25296 | return ira->codegen->invalid_instruction; | 26236 | return ira->codegen->invalid_inst_gen; |
| 25297 | } | 26237 | } |
| 25298 | } else { | 26238 | } else { |
| 25299 | elem_type = array_type->data.pointer.child_type; | 26239 | elem_type = array_type->data.pointer.child_type; |
| ... | @@ -25303,8 +26243,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -25303,8 +26243,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 25303 | ZigType *maybe_sentineled_slice_ptr_type = array_type; | 26243 | ZigType *maybe_sentineled_slice_ptr_type = array_type; |
| 25304 | non_sentinel_slice_ptr_type = adjust_ptr_sentinel(ira->codegen, maybe_sentineled_slice_ptr_type, nullptr); | 26244 | non_sentinel_slice_ptr_type = adjust_ptr_sentinel(ira->codegen, maybe_sentineled_slice_ptr_type, nullptr); |
| 25305 | if (!end) { | 26245 | if (!end) { |
| 25306 | ir_add_error(ira, &instruction->base, buf_sprintf("slice of pointer must include end value")); | 26246 | ir_add_error(ira, &instruction->base.base, buf_sprintf("slice of pointer must include end value")); |
| 25307 | return ira->codegen->invalid_instruction; | 26247 | return ira->codegen->invalid_inst_gen; |
| 25308 | } | 26248 | } |
| 25309 | } | 26249 | } |
| 25310 | } else if (is_slice(array_type)) { | 26250 | } else if (is_slice(array_type)) { |
| ... | @@ -25312,23 +26252,23 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -25312,23 +26252,23 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 25312 | non_sentinel_slice_ptr_type = adjust_ptr_sentinel(ira->codegen, maybe_sentineled_slice_ptr_type, nullptr); | 26252 | non_sentinel_slice_ptr_type = adjust_ptr_sentinel(ira->codegen, maybe_sentineled_slice_ptr_type, nullptr); |
| 25313 | elem_type = non_sentinel_slice_ptr_type->data.pointer.child_type; | 26253 | elem_type = non_sentinel_slice_ptr_type->data.pointer.child_type; |
| 25314 | } else { | 26254 | } else { |
| 25315 | ir_add_error(ira, &instruction->base, | 26255 | ir_add_error(ira, &instruction->base.base, |
| 25316 | buf_sprintf("slice of non-array type '%s'", buf_ptr(&array_type->name))); | 26256 | buf_sprintf("slice of non-array type '%s'", buf_ptr(&array_type->name))); |
| 25317 | return ira->codegen->invalid_instruction; | 26257 | return ira->codegen->invalid_inst_gen; |
| 25318 | } | 26258 | } |
| 25319 | | 26259 | |
| 25320 | ZigType *return_type; | 26260 | ZigType *return_type; |
| 25321 | ZigValue *sentinel_val = nullptr; | 26261 | ZigValue *sentinel_val = nullptr; |
| 25322 | if (instruction->sentinel) { | 26262 | if (instruction->sentinel) { |
| 25323 | IrInstruction *uncasted_sentinel = instruction->sentinel->child; | 26263 | IrInstGen *uncasted_sentinel = instruction->sentinel->child; |
| 25324 | if (type_is_invalid(uncasted_sentinel->value->type)) | 26264 | if (type_is_invalid(uncasted_sentinel->value->type)) |
| 25325 | return ira->codegen->invalid_instruction; | 26265 | return ira->codegen->invalid_inst_gen; |
| 25326 | IrInstruction *sentinel = ir_implicit_cast(ira, uncasted_sentinel, elem_type); | 26266 | IrInstGen *sentinel = ir_implicit_cast(ira, uncasted_sentinel, elem_type); |
| 25327 | if (type_is_invalid(sentinel->value->type)) | 26267 | if (type_is_invalid(sentinel->value->type)) |
| 25328 | return ira->codegen->invalid_instruction; | 26268 | return ira->codegen->invalid_inst_gen; |
| 25329 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); | 26269 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| 25330 | if (sentinel_val == nullptr) | 26270 | if (sentinel_val == nullptr) |
| 25331 | return ira->codegen->invalid_instruction; | 26271 | return ira->codegen->invalid_inst_gen; |
| 25332 | ZigType *slice_ptr_type = adjust_ptr_sentinel(ira->codegen, non_sentinel_slice_ptr_type, sentinel_val); | 26272 | ZigType *slice_ptr_type = adjust_ptr_sentinel(ira->codegen, non_sentinel_slice_ptr_type, sentinel_val); |
| 25333 | return_type = get_slice_type(ira->codegen, slice_ptr_type); | 26273 | return_type = get_slice_type(ira->codegen, slice_ptr_type); |
| 25334 | } else { | 26274 | } else { |
| ... | @@ -25350,9 +26290,9 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -25350,9 +26290,9 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 25350 | if (array_type->id == ZigTypeIdPointer) { | 26290 | if (array_type->id == ZigTypeIdPointer) { |
| 25351 | ZigType *child_array_type = array_type->data.pointer.child_type; | 26291 | ZigType *child_array_type = array_type->data.pointer.child_type; |
| 25352 | assert(child_array_type->id == ZigTypeIdArray); | 26292 | assert(child_array_type->id == ZigTypeIdArray); |
| 25353 | parent_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node); | 26293 | parent_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.base.source_node); |
| 25354 | if (parent_ptr == nullptr) | 26294 | if (parent_ptr == nullptr) |
| 25355 | return ira->codegen->invalid_instruction; | 26295 | return ira->codegen->invalid_inst_gen; |
| 25356 | | 26296 | |
| 25357 | | 26297 | |
| 25358 | if (parent_ptr->special == ConstValSpecialUndef) { | 26298 | if (parent_ptr->special == ConstValSpecialUndef) { |
| ... | @@ -25361,26 +26301,26 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -25361,26 +26301,26 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 25361 | rel_end = SIZE_MAX; | 26301 | rel_end = SIZE_MAX; |
| 25362 | ptr_is_undef = true; | 26302 | ptr_is_undef = true; |
| 25363 | } else { | 26303 | } else { |
| 25364 | array_val = const_ptr_pointee(ira, ira->codegen, parent_ptr, instruction->base.source_node); | 26304 | array_val = const_ptr_pointee(ira, ira->codegen, parent_ptr, instruction->base.base.source_node); |
| 25365 | if (array_val == nullptr) | 26305 | if (array_val == nullptr) |
| 25366 | return ira->codegen->invalid_instruction; | 26306 | return ira->codegen->invalid_inst_gen; |
| 25367 | | 26307 | |
| 25368 | rel_end = child_array_type->data.array.len; | 26308 | rel_end = child_array_type->data.array.len; |
| 25369 | abs_offset = 0; | 26309 | abs_offset = 0; |
| 25370 | } | 26310 | } |
| 25371 | } else { | 26311 | } else { |
| 25372 | array_val = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node); | 26312 | array_val = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.base.source_node); |
| 25373 | if (array_val == nullptr) | 26313 | if (array_val == nullptr) |
| 25374 | return ira->codegen->invalid_instruction; | 26314 | return ira->codegen->invalid_inst_gen; |
| 25375 | rel_end = array_type->data.array.len; | 26315 | rel_end = array_type->data.array.len; |
| 25376 | parent_ptr = nullptr; | 26316 | parent_ptr = nullptr; |
| 25377 | abs_offset = 0; | 26317 | abs_offset = 0; |
| 25378 | } | 26318 | } |
| 25379 | } else if (array_type->id == ZigTypeIdPointer) { | 26319 | } else if (array_type->id == ZigTypeIdPointer) { |
| 25380 | assert(array_type->data.pointer.ptr_len == PtrLenUnknown); | 26320 | assert(array_type->data.pointer.ptr_len == PtrLenUnknown); |
| 25381 | parent_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node); | 26321 | parent_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.base.source_node); |
| 25382 | if (parent_ptr == nullptr) | 26322 | if (parent_ptr == nullptr) |
| 25383 | return ira->codegen->invalid_instruction; | 26323 | return ira->codegen->invalid_inst_gen; |
| 25384 | | 26324 | |
| 25385 | if (parent_ptr->special == ConstValSpecialUndef) { | 26325 | if (parent_ptr->special == ConstValSpecialUndef) { |
| 25386 | array_val = nullptr; | 26326 | array_val = nullptr; |
| ... | @@ -25426,19 +26366,19 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -25426,19 +26366,19 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 25426 | zig_panic("TODO slice of null ptr"); | 26366 | zig_panic("TODO slice of null ptr"); |
| 25427 | } | 26367 | } |
| 25428 | } else if (is_slice(array_type)) { | 26368 | } else if (is_slice(array_type)) { |
| 25429 | ZigValue *slice_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node); | 26369 | ZigValue *slice_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.base.source_node); |
| 25430 | if (slice_ptr == nullptr) | 26370 | if (slice_ptr == nullptr) |
| 25431 | return ira->codegen->invalid_instruction; | 26371 | return ira->codegen->invalid_inst_gen; |
| 25432 | | 26372 | |
| 25433 | if (slice_ptr->special == ConstValSpecialUndef) { | 26373 | if (slice_ptr->special == ConstValSpecialUndef) { |
| 25434 | ir_add_error(ira, &instruction->base, buf_sprintf("slice of undefined")); | 26374 | ir_add_error(ira, &instruction->base.base, buf_sprintf("slice of undefined")); |
| 25435 | return ira->codegen->invalid_instruction; | 26375 | return ira->codegen->invalid_inst_gen; |
| 25436 | } | 26376 | } |
| 25437 | | 26377 | |
| 25438 | parent_ptr = slice_ptr->data.x_struct.fields[slice_ptr_index]; | 26378 | parent_ptr = slice_ptr->data.x_struct.fields[slice_ptr_index]; |
| 25439 | if (parent_ptr->special == ConstValSpecialUndef) { | 26379 | if (parent_ptr->special == ConstValSpecialUndef) { |
| 25440 | ir_add_error(ira, &instruction->base, buf_sprintf("slice of undefined")); | 26380 | ir_add_error(ira, &instruction->base.base, buf_sprintf("slice of undefined")); |
| 25441 | return ira->codegen->invalid_instruction; | 26381 | return ira->codegen->invalid_inst_gen; |
| 25442 | } | 26382 | } |
| 25443 | | 26383 | |
| 25444 | ZigValue *len_val = slice_ptr->data.x_struct.fields[slice_len_index]; | 26384 | ZigValue *len_val = slice_ptr->data.x_struct.fields[slice_len_index]; |
| ... | @@ -25481,37 +26421,37 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -25481,37 +26421,37 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 25481 | | 26421 | |
| 25482 | ZigValue *start_val = ir_resolve_const(ira, casted_start, UndefBad); | 26422 | ZigValue *start_val = ir_resolve_const(ira, casted_start, UndefBad); |
| 25483 | if (!start_val) | 26423 | if (!start_val) |
| 25484 | return ira->codegen->invalid_instruction; | 26424 | return ira->codegen->invalid_inst_gen; |
| 25485 | | 26425 | |
| 25486 | uint64_t start_scalar = bigint_as_u64(&start_val->data.x_bigint); | 26426 | uint64_t start_scalar = bigint_as_u64(&start_val->data.x_bigint); |
| 25487 | if (!ptr_is_undef && start_scalar > rel_end) { | 26427 | if (!ptr_is_undef && start_scalar > rel_end) { |
| 25488 | ir_add_error(ira, &instruction->base, buf_sprintf("out of bounds slice")); | 26428 | ir_add_error(ira, &instruction->base.base, buf_sprintf("out of bounds slice")); |
| 25489 | return ira->codegen->invalid_instruction; | 26429 | return ira->codegen->invalid_inst_gen; |
| 25490 | } | 26430 | } |
| 25491 | | 26431 | |
| 25492 | uint64_t end_scalar = rel_end; | 26432 | uint64_t end_scalar = rel_end; |
| 25493 | if (end) { | 26433 | if (end) { |
| 25494 | ZigValue *end_val = ir_resolve_const(ira, end, UndefBad); | 26434 | ZigValue *end_val = ir_resolve_const(ira, end, UndefBad); |
| 25495 | if (!end_val) | 26435 | if (!end_val) |
| 25496 | return ira->codegen->invalid_instruction; | 26436 | return ira->codegen->invalid_inst_gen; |
| 25497 | end_scalar = bigint_as_u64(&end_val->data.x_bigint); | 26437 | end_scalar = bigint_as_u64(&end_val->data.x_bigint); |
| 25498 | } | 26438 | } |
| 25499 | if (!ptr_is_undef) { | 26439 | if (!ptr_is_undef) { |
| 25500 | if (end_scalar > rel_end) { | 26440 | if (end_scalar > rel_end) { |
| 25501 | ir_add_error(ira, &instruction->base, buf_sprintf("out of bounds slice")); | 26441 | ir_add_error(ira, &instruction->base.base, buf_sprintf("out of bounds slice")); |
| 25502 | return ira->codegen->invalid_instruction; | 26442 | return ira->codegen->invalid_inst_gen; |
| 25503 | } | 26443 | } |
| 25504 | if (start_scalar > end_scalar) { | 26444 | if (start_scalar > end_scalar) { |
| 25505 | ir_add_error(ira, &instruction->base, buf_sprintf("slice start is greater than end")); | 26445 | ir_add_error(ira, &instruction->base.base, buf_sprintf("slice start is greater than end")); |
| 25506 | return ira->codegen->invalid_instruction; | 26446 | return ira->codegen->invalid_inst_gen; |
| 25507 | } | 26447 | } |
| 25508 | } | 26448 | } |
| 25509 | if (ptr_is_undef && start_scalar != end_scalar) { | 26449 | if (ptr_is_undef && start_scalar != end_scalar) { |
| 25510 | ir_add_error(ira, &instruction->base, buf_sprintf("non-zero length slice of undefined pointer")); | 26450 | ir_add_error(ira, &instruction->base.base, buf_sprintf("non-zero length slice of undefined pointer")); |
| 25511 | return ira->codegen->invalid_instruction; | 26451 | return ira->codegen->invalid_inst_gen; |
| 25512 | } | 26452 | } |
| 25513 | | 26453 | |
| 25514 | IrInstruction *result = ir_const(ira, &instruction->base, return_type); | 26454 | IrInstGen *result = ir_const(ira, &instruction->base.base, return_type); |
| 25515 | ZigValue *out_val = result->value; | 26455 | ZigValue *out_val = result->value; |
| 25516 | out_val->data.x_struct.fields = alloc_const_vals_ptrs(2); | 26456 | out_val->data.x_struct.fields = alloc_const_vals_ptrs(2); |
| 25517 | | 26457 | |
| ... | @@ -25568,28 +26508,28 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -25568,28 +26508,28 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 25568 | return result; | 26508 | return result; |
| 25569 | } | 26509 | } |
| 25570 | | 26510 | |
| 25571 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 26511 | IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base.base, instruction->result_loc, |
| 25572 | return_type, nullptr, true, true); | 26512 | return_type, nullptr, true, true); |
| 25573 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { | 26513 | if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) { |
| 25574 | return result_loc; | 26514 | return result_loc; |
| 25575 | } | 26515 | } |
| 25576 | return ir_build_slice_gen(ira, &instruction->base, return_type, | 26516 | return ir_build_slice_gen(ira, &instruction->base.base, return_type, |
| 25577 | ptr_ptr, casted_start, end, instruction->safety_check_on, result_loc); | 26517 | ptr_ptr, casted_start, end, instruction->safety_check_on, result_loc); |
| 25578 | } | 26518 | } |
| 25579 | | 26519 | |
| 25580 | static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInstructionMemberCount *instruction) { | 26520 | static IrInstGen *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInstSrcMemberCount *instruction) { |
| 25581 | Error err; | 26521 | Error err; |
| 25582 | IrInstruction *container = instruction->container->child; | 26522 | IrInstGen *container = instruction->container->child; |
| 25583 | if (type_is_invalid(container->value->type)) | 26523 | if (type_is_invalid(container->value->type)) |
| 25584 | return ira->codegen->invalid_instruction; | 26524 | return ira->codegen->invalid_inst_gen; |
| 25585 | ZigType *container_type = ir_resolve_type(ira, container); | 26525 | ZigType *container_type = ir_resolve_type(ira, container); |
| 25586 | | 26526 | |
| 25587 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) | 26527 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) |
| 25588 | return ira->codegen->invalid_instruction; | 26528 | return ira->codegen->invalid_inst_gen; |
| 25589 | | 26529 | |
| 25590 | uint64_t result; | 26530 | uint64_t result; |
| 25591 | if (type_is_invalid(container_type)) { | 26531 | if (type_is_invalid(container_type)) { |
| 25592 | return ira->codegen->invalid_instruction; | 26532 | return ira->codegen->invalid_inst_gen; |
| 25593 | } else if (container_type->id == ZigTypeIdEnum) { | 26533 | } else if (container_type->id == ZigTypeIdEnum) { |
| 25594 | result = container_type->data.enumeration.src_field_count; | 26534 | result = container_type->data.enumeration.src_field_count; |
| 25595 | } else if (container_type->id == ZigTypeIdStruct) { | 26535 | } else if (container_type->id == ZigTypeIdStruct) { |
| ... | @@ -25597,135 +26537,135 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst | ... | @@ -25597,135 +26537,135 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst |
| 25597 | } else if (container_type->id == ZigTypeIdUnion) { | 26537 | } else if (container_type->id == ZigTypeIdUnion) { |
| 25598 | result = container_type->data.unionation.src_field_count; | 26538 | result = container_type->data.unionation.src_field_count; |
| 25599 | } else if (container_type->id == ZigTypeIdErrorSet) { | 26539 | } else if (container_type->id == ZigTypeIdErrorSet) { |
| 25600 | if (!resolve_inferred_error_set(ira->codegen, container_type, instruction->base.source_node)) { | 26540 | if (!resolve_inferred_error_set(ira->codegen, container_type, instruction->base.base.source_node)) { |
| 25601 | return ira->codegen->invalid_instruction; | 26541 | return ira->codegen->invalid_inst_gen; |
| 25602 | } | 26542 | } |
| 25603 | if (type_is_global_error_set(container_type)) { | 26543 | if (type_is_global_error_set(container_type)) { |
| 25604 | ir_add_error(ira, &instruction->base, buf_sprintf("global error set member count not available at comptime")); | 26544 | ir_add_error(ira, &instruction->base.base, buf_sprintf("global error set member count not available at comptime")); |
| 25605 | return ira->codegen->invalid_instruction; | 26545 | return ira->codegen->invalid_inst_gen; |
| 25606 | } | 26546 | } |
| 25607 | result = container_type->data.error_set.err_count; | 26547 | result = container_type->data.error_set.err_count; |
| 25608 | } else { | 26548 | } else { |
| 25609 | ir_add_error(ira, &instruction->base, buf_sprintf("no value count available for type '%s'", buf_ptr(&container_type->name))); | 26549 | ir_add_error(ira, &instruction->base.base, buf_sprintf("no value count available for type '%s'", buf_ptr(&container_type->name))); |
| 25610 | return ira->codegen->invalid_instruction; | 26550 | return ira->codegen->invalid_inst_gen; |
| 25611 | } | 26551 | } |
| 25612 | | 26552 | |
| 25613 | return ir_const_unsigned(ira, &instruction->base, result); | 26553 | return ir_const_unsigned(ira, &instruction->base.base, result); |
| 25614 | } | 26554 | } |
| 25615 | | 26555 | |
| 25616 | static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstructionMemberType *instruction) { | 26556 | static IrInstGen *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstSrcMemberType *instruction) { |
| 25617 | Error err; | 26557 | Error err; |
| 25618 | IrInstruction *container_type_value = instruction->container_type->child; | 26558 | IrInstGen *container_type_value = instruction->container_type->child; |
| 25619 | ZigType *container_type = ir_resolve_type(ira, container_type_value); | 26559 | ZigType *container_type = ir_resolve_type(ira, container_type_value); |
| 25620 | if (type_is_invalid(container_type)) | 26560 | if (type_is_invalid(container_type)) |
| 25621 | return ira->codegen->invalid_instruction; | 26561 | return ira->codegen->invalid_inst_gen; |
| 25622 | | 26562 | |
| 25623 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) | 26563 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) |
| 25624 | return ira->codegen->invalid_instruction; | 26564 | return ira->codegen->invalid_inst_gen; |
| 25625 | | 26565 | |
| 25626 | | 26566 | |
| 25627 | uint64_t member_index; | 26567 | uint64_t member_index; |
| 25628 | IrInstruction *index_value = instruction->member_index->child; | 26568 | IrInstGen *index_value = instruction->member_index->child; |
| 25629 | if (!ir_resolve_usize(ira, index_value, &member_index)) | 26569 | if (!ir_resolve_usize(ira, index_value, &member_index)) |
| 25630 | return ira->codegen->invalid_instruction; | 26570 | return ira->codegen->invalid_inst_gen; |
| 25631 | | 26571 | |
| 25632 | if (container_type->id == ZigTypeIdStruct) { | 26572 | if (container_type->id == ZigTypeIdStruct) { |
| 25633 | if (member_index >= container_type->data.structure.src_field_count) { | 26573 | if (member_index >= container_type->data.structure.src_field_count) { |
| 25634 | ir_add_error(ira, index_value, | 26574 | ir_add_error(ira, &index_value->base, |
| 25635 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", | 26575 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", |
| 25636 | member_index, buf_ptr(&container_type->name), container_type->data.structure.src_field_count)); | 26576 | member_index, buf_ptr(&container_type->name), container_type->data.structure.src_field_count)); |
| 25637 | return ira->codegen->invalid_instruction; | 26577 | return ira->codegen->invalid_inst_gen; |
| 25638 | } | 26578 | } |
| 25639 | TypeStructField *field = container_type->data.structure.fields[member_index]; | 26579 | TypeStructField *field = container_type->data.structure.fields[member_index]; |
| 25640 | | 26580 | |
| 25641 | return ir_const_type(ira, &instruction->base, field->type_entry); | 26581 | return ir_const_type(ira, &instruction->base.base, field->type_entry); |
| 25642 | } else if (container_type->id == ZigTypeIdUnion) { | 26582 | } else if (container_type->id == ZigTypeIdUnion) { |
| 25643 | if (member_index >= container_type->data.unionation.src_field_count) { | 26583 | if (member_index >= container_type->data.unionation.src_field_count) { |
| 25644 | ir_add_error(ira, index_value, | 26584 | ir_add_error(ira, &index_value->base, |
| 25645 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", | 26585 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", |
| 25646 | member_index, buf_ptr(&container_type->name), container_type->data.unionation.src_field_count)); | 26586 | member_index, buf_ptr(&container_type->name), container_type->data.unionation.src_field_count)); |
| 25647 | return ira->codegen->invalid_instruction; | 26587 | return ira->codegen->invalid_inst_gen; |
| 25648 | } | 26588 | } |
| 25649 | TypeUnionField *field = &container_type->data.unionation.fields[member_index]; | 26589 | TypeUnionField *field = &container_type->data.unionation.fields[member_index]; |
| 25650 | | 26590 | |
| 25651 | return ir_const_type(ira, &instruction->base, field->type_entry); | 26591 | return ir_const_type(ira, &instruction->base.base, field->type_entry); |
| 25652 | } else { | 26592 | } else { |
| 25653 | ir_add_error(ira, container_type_value, | 26593 | ir_add_error(ira, &container_type_value->base, |
| 25654 | buf_sprintf("type '%s' does not support @memberType", buf_ptr(&container_type->name))); | 26594 | buf_sprintf("type '%s' does not support @memberType", buf_ptr(&container_type->name))); |
| 25655 | return ira->codegen->invalid_instruction; | 26595 | return ira->codegen->invalid_inst_gen; |
| 25656 | } | 26596 | } |
| 25657 | } | 26597 | } |
| 25658 | | 26598 | |
| 25659 | static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstructionMemberName *instruction) { | 26599 | static IrInstGen *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstSrcMemberName *instruction) { |
| 25660 | Error err; | 26600 | Error err; |
| 25661 | IrInstruction *container_type_value = instruction->container_type->child; | 26601 | IrInstGen *container_type_value = instruction->container_type->child; |
| 25662 | ZigType *container_type = ir_resolve_type(ira, container_type_value); | 26602 | ZigType *container_type = ir_resolve_type(ira, container_type_value); |
| 25663 | if (type_is_invalid(container_type)) | 26603 | if (type_is_invalid(container_type)) |
| 25664 | return ira->codegen->invalid_instruction; | 26604 | return ira->codegen->invalid_inst_gen; |
| 25665 | | 26605 | |
| 25666 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) | 26606 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) |
| 25667 | return ira->codegen->invalid_instruction; | 26607 | return ira->codegen->invalid_inst_gen; |
| 25668 | | 26608 | |
| 25669 | uint64_t member_index; | 26609 | uint64_t member_index; |
| 25670 | IrInstruction *index_value = instruction->member_index->child; | 26610 | IrInstGen *index_value = instruction->member_index->child; |
| 25671 | if (!ir_resolve_usize(ira, index_value, &member_index)) | 26611 | if (!ir_resolve_usize(ira, index_value, &member_index)) |
| 25672 | return ira->codegen->invalid_instruction; | 26612 | return ira->codegen->invalid_inst_gen; |
| 25673 | | 26613 | |
| 25674 | if (container_type->id == ZigTypeIdStruct) { | 26614 | if (container_type->id == ZigTypeIdStruct) { |
| 25675 | if (member_index >= container_type->data.structure.src_field_count) { | 26615 | if (member_index >= container_type->data.structure.src_field_count) { |
| 25676 | ir_add_error(ira, index_value, | 26616 | ir_add_error(ira, &index_value->base, |
| 25677 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", | 26617 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", |
| 25678 | member_index, buf_ptr(&container_type->name), container_type->data.structure.src_field_count)); | 26618 | member_index, buf_ptr(&container_type->name), container_type->data.structure.src_field_count)); |
| 25679 | return ira->codegen->invalid_instruction; | 26619 | return ira->codegen->invalid_inst_gen; |
| 25680 | } | 26620 | } |
| 25681 | TypeStructField *field = container_type->data.structure.fields[member_index]; | 26621 | TypeStructField *field = container_type->data.structure.fields[member_index]; |
| 25682 | | 26622 | |
| 25683 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 26623 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 25684 | init_const_str_lit(ira->codegen, result->value, field->name); | 26624 | init_const_str_lit(ira->codegen, result->value, field->name); |
| 25685 | return result; | 26625 | return result; |
| 25686 | } else if (container_type->id == ZigTypeIdEnum) { | 26626 | } else if (container_type->id == ZigTypeIdEnum) { |
| 25687 | if (member_index >= container_type->data.enumeration.src_field_count) { | 26627 | if (member_index >= container_type->data.enumeration.src_field_count) { |
| 25688 | ir_add_error(ira, index_value, | 26628 | ir_add_error(ira, &index_value->base, |
| 25689 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", | 26629 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", |
| 25690 | member_index, buf_ptr(&container_type->name), container_type->data.enumeration.src_field_count)); | 26630 | member_index, buf_ptr(&container_type->name), container_type->data.enumeration.src_field_count)); |
| 25691 | return ira->codegen->invalid_instruction; | 26631 | return ira->codegen->invalid_inst_gen; |
| 25692 | } | 26632 | } |
| 25693 | TypeEnumField *field = &container_type->data.enumeration.fields[member_index]; | 26633 | TypeEnumField *field = &container_type->data.enumeration.fields[member_index]; |
| 25694 | | 26634 | |
| 25695 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 26635 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 25696 | init_const_str_lit(ira->codegen, result->value, field->name); | 26636 | init_const_str_lit(ira->codegen, result->value, field->name); |
| 25697 | return result; | 26637 | return result; |
| 25698 | } else if (container_type->id == ZigTypeIdUnion) { | 26638 | } else if (container_type->id == ZigTypeIdUnion) { |
| 25699 | if (member_index >= container_type->data.unionation.src_field_count) { | 26639 | if (member_index >= container_type->data.unionation.src_field_count) { |
| 25700 | ir_add_error(ira, index_value, | 26640 | ir_add_error(ira, &index_value->base, |
| 25701 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", | 26641 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", |
| 25702 | member_index, buf_ptr(&container_type->name), container_type->data.unionation.src_field_count)); | 26642 | member_index, buf_ptr(&container_type->name), container_type->data.unionation.src_field_count)); |
| 25703 | return ira->codegen->invalid_instruction; | 26643 | return ira->codegen->invalid_inst_gen; |
| 25704 | } | 26644 | } |
| 25705 | TypeUnionField *field = &container_type->data.unionation.fields[member_index]; | 26645 | TypeUnionField *field = &container_type->data.unionation.fields[member_index]; |
| 25706 | | 26646 | |
| 25707 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 26647 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 25708 | init_const_str_lit(ira->codegen, result->value, field->name); | 26648 | init_const_str_lit(ira->codegen, result->value, field->name); |
| 25709 | return result; | 26649 | return result; |
| 25710 | } else { | 26650 | } else { |
| 25711 | ir_add_error(ira, container_type_value, | 26651 | ir_add_error(ira, &container_type_value->base, |
| 25712 | buf_sprintf("type '%s' does not support @memberName", buf_ptr(&container_type->name))); | 26652 | buf_sprintf("type '%s' does not support @memberName", buf_ptr(&container_type->name))); |
| 25713 | return ira->codegen->invalid_instruction; | 26653 | return ira->codegen->invalid_inst_gen; |
| 25714 | } | 26654 | } |
| 25715 | } | 26655 | } |
| 25716 | | 26656 | |
| 25717 | static IrInstruction *ir_analyze_instruction_has_field(IrAnalyze *ira, IrInstructionHasField *instruction) { | 26657 | static IrInstGen *ir_analyze_instruction_has_field(IrAnalyze *ira, IrInstSrcHasField *instruction) { |
| 25718 | Error err; | 26658 | Error err; |
| 25719 | ZigType *container_type = ir_resolve_type(ira, instruction->container_type->child); | 26659 | ZigType *container_type = ir_resolve_type(ira, instruction->container_type->child); |
| 25720 | if (type_is_invalid(container_type)) | 26660 | if (type_is_invalid(container_type)) |
| 25721 | return ira->codegen->invalid_instruction; | 26661 | return ira->codegen->invalid_inst_gen; |
| 25722 | | 26662 | |
| 25723 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusZeroBitsKnown))) | 26663 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusZeroBitsKnown))) |
| 25724 | return ira->codegen->invalid_instruction; | 26664 | return ira->codegen->invalid_inst_gen; |
| 25725 | | 26665 | |
| 25726 | Buf *field_name = ir_resolve_str(ira, instruction->field_name->child); | 26666 | Buf *field_name = ir_resolve_str(ira, instruction->field_name->child); |
| 25727 | if (field_name == nullptr) | 26667 | if (field_name == nullptr) |
| 25728 | return ira->codegen->invalid_instruction; | 26668 | return ira->codegen->invalid_inst_gen; |
| 25729 | | 26669 | |
| 25730 | bool result; | 26670 | bool result; |
| 25731 | if (container_type->id == ZigTypeIdStruct) { | 26671 | if (container_type->id == ZigTypeIdStruct) { |
| ... | @@ -25735,91 +26675,77 @@ static IrInstruction *ir_analyze_instruction_has_field(IrAnalyze *ira, IrInstruc | ... | @@ -25735,91 +26675,77 @@ static IrInstruction *ir_analyze_instruction_has_field(IrAnalyze *ira, IrInstruc |
| 25735 | } else if (container_type->id == ZigTypeIdUnion) { | 26675 | } else if (container_type->id == ZigTypeIdUnion) { |
| 25736 | result = find_union_type_field(container_type, field_name) != nullptr; | 26676 | result = find_union_type_field(container_type, field_name) != nullptr; |
| 25737 | } else { | 26677 | } else { |
| 25738 | ir_add_error(ira, instruction->container_type, | 26678 | ir_add_error(ira, &instruction->container_type->base, |
| 25739 | buf_sprintf("type '%s' does not support @hasField", buf_ptr(&container_type->name))); | 26679 | buf_sprintf("type '%s' does not support @hasField", buf_ptr(&container_type->name))); |
| 25740 | return ira->codegen->invalid_instruction; | 26680 | return ira->codegen->invalid_inst_gen; |
| 25741 | } | 26681 | } |
| 25742 | return ir_const_bool(ira, &instruction->base, result); | 26682 | return ir_const_bool(ira, &instruction->base.base, result); |
| 25743 | } | 26683 | } |
| 25744 | | 26684 | |
| 25745 | static IrInstruction *ir_analyze_instruction_breakpoint(IrAnalyze *ira, IrInstructionBreakpoint *instruction) { | 26685 | static IrInstGen *ir_analyze_instruction_breakpoint(IrAnalyze *ira, IrInstSrcBreakpoint *instruction) { |
| 25746 | IrInstruction *result = ir_build_breakpoint(&ira->new_irb, | 26686 | return ir_build_breakpoint_gen(ira, &instruction->base.base); |
| 25747 | instruction->base.scope, instruction->base.source_node); | | |
| 25748 | result->value->type = ira->codegen->builtin_types.entry_void; | | |
| 25749 | return result; | | |
| 25750 | } | 26687 | } |
| 25751 | | 26688 | |
| 25752 | static IrInstruction *ir_analyze_instruction_return_address(IrAnalyze *ira, IrInstructionReturnAddress *instruction) { | 26689 | static IrInstGen *ir_analyze_instruction_return_address(IrAnalyze *ira, IrInstSrcReturnAddress *instruction) { |
| 25753 | IrInstruction *result = ir_build_return_address(&ira->new_irb, | 26690 | return ir_build_return_address_gen(ira, &instruction->base.base); |
| 25754 | instruction->base.scope, instruction->base.source_node); | | |
| 25755 | result->value->type = ira->codegen->builtin_types.entry_usize; | | |
| 25756 | return result; | | |
| 25757 | } | 26691 | } |
| 25758 | | 26692 | |
| 25759 | static IrInstruction *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstructionFrameAddress *instruction) { | 26693 | static IrInstGen *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstSrcFrameAddress *instruction) { |
| 25760 | IrInstruction *result = ir_build_frame_address(&ira->new_irb, | 26694 | return ir_build_frame_address_gen(ira, &instruction->base.base); |
| 25761 | instruction->base.scope, instruction->base.source_node); | | |
| 25762 | result->value->type = ira->codegen->builtin_types.entry_usize; | | |
| 25763 | return result; | | |
| 25764 | } | 26695 | } |
| 25765 | | 26696 | |
| 25766 | static IrInstruction *ir_analyze_instruction_frame_handle(IrAnalyze *ira, IrInstructionFrameHandle *instruction) { | 26697 | static IrInstGen *ir_analyze_instruction_frame_handle(IrAnalyze *ira, IrInstSrcFrameHandle *instruction) { |
| 25767 | ZigFn *fn = exec_fn_entry(ira->new_irb.exec); | 26698 | ZigFn *fn = ira->new_irb.exec->fn_entry; |
| 25768 | ir_assert(fn != nullptr, &instruction->base); | 26699 | ir_assert(fn != nullptr, &instruction->base.base); |
| 25769 | | 26700 | |
| 25770 | if (fn->inferred_async_node == nullptr) { | 26701 | if (fn->inferred_async_node == nullptr) { |
| 25771 | fn->inferred_async_node = instruction->base.source_node; | 26702 | fn->inferred_async_node = instruction->base.base.source_node; |
| 25772 | } | 26703 | } |
| 25773 | | 26704 | |
| 25774 | ZigType *frame_type = get_fn_frame_type(ira->codegen, fn); | 26705 | ZigType *frame_type = get_fn_frame_type(ira->codegen, fn); |
| 25775 | ZigType *ptr_frame_type = get_pointer_to_type(ira->codegen, frame_type, false); | 26706 | ZigType *ptr_frame_type = get_pointer_to_type(ira->codegen, frame_type, false); |
| 25776 | | 26707 | |
| 25777 | IrInstruction *result = ir_build_handle(&ira->new_irb, instruction->base.scope, instruction->base.source_node); | 26708 | return ir_build_handle_gen(ira, &instruction->base.base, ptr_frame_type); |
| 25778 | result->value->type = ptr_frame_type; | | |
| 25779 | return result; | | |
| 25780 | } | 26709 | } |
| 25781 | | 26710 | |
| 25782 | static IrInstruction *ir_analyze_instruction_frame_type(IrAnalyze *ira, IrInstructionFrameType *instruction) { | 26711 | static IrInstGen *ir_analyze_instruction_frame_type(IrAnalyze *ira, IrInstSrcFrameType *instruction) { |
| 25783 | ZigFn *fn = ir_resolve_fn(ira, instruction->fn->child); | 26712 | ZigFn *fn = ir_resolve_fn(ira, instruction->fn->child); |
| 25784 | if (fn == nullptr) | 26713 | if (fn == nullptr) |
| 25785 | return ira->codegen->invalid_instruction; | 26714 | return ira->codegen->invalid_inst_gen; |
| 25786 | | 26715 | |
| 25787 | if (fn->type_entry->data.fn.is_generic) { | 26716 | if (fn->type_entry->data.fn.is_generic) { |
| 25788 | ir_add_error(ira, &instruction->base, | 26717 | ir_add_error(ira, &instruction->base.base, |
| 25789 | buf_sprintf("@Frame() of generic function")); | 26718 | buf_sprintf("@Frame() of generic function")); |
| 25790 | return ira->codegen->invalid_instruction; | 26719 | return ira->codegen->invalid_inst_gen; |
| 25791 | } | 26720 | } |
| 25792 | | 26721 | |
| 25793 | ZigType *ty = get_fn_frame_type(ira->codegen, fn); | 26722 | ZigType *ty = get_fn_frame_type(ira->codegen, fn); |
| 25794 | return ir_const_type(ira, &instruction->base, ty); | 26723 | return ir_const_type(ira, &instruction->base.base, ty); |
| 25795 | } | 26724 | } |
| 25796 | | 26725 | |
| 25797 | static IrInstruction *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstructionFrameSizeSrc *instruction) { | 26726 | static IrInstGen *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstSrcFrameSize *instruction) { |
| 25798 | IrInstruction *fn = instruction->fn->child; | 26727 | IrInstGen *fn = instruction->fn->child; |
| 25799 | if (type_is_invalid(fn->value->type)) | 26728 | if (type_is_invalid(fn->value->type)) |
| 25800 | return ira->codegen->invalid_instruction; | 26729 | return ira->codegen->invalid_inst_gen; |
| 25801 | | 26730 | |
| 25802 | if (fn->value->type->id != ZigTypeIdFn) { | 26731 | if (fn->value->type->id != ZigTypeIdFn) { |
| 25803 | ir_add_error(ira, fn, | 26732 | ir_add_error(ira, &fn->base, |
| 25804 | buf_sprintf("expected function, found '%s'", buf_ptr(&fn->value->type->name))); | 26733 | buf_sprintf("expected function, found '%s'", buf_ptr(&fn->value->type->name))); |
| 25805 | return ira->codegen->invalid_instruction; | 26734 | return ira->codegen->invalid_inst_gen; |
| 25806 | } | 26735 | } |
| 25807 | | 26736 | |
| 25808 | ira->codegen->need_frame_size_prefix_data = true; | 26737 | ira->codegen->need_frame_size_prefix_data = true; |
| 25809 | | 26738 | |
| 25810 | IrInstruction *result = ir_build_frame_size_gen(&ira->new_irb, instruction->base.scope, | 26739 | return ir_build_frame_size_gen(ira, &instruction->base.base, fn); |
| 25811 | instruction->base.source_node, fn); | | |
| 25812 | result->value->type = ira->codegen->builtin_types.entry_usize; | | |
| 25813 | return result; | | |
| 25814 | } | 26740 | } |
| 25815 | | 26741 | |
| 25816 | static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstructionAlignOf *instruction) { | 26742 | static IrInstGen *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstSrcAlignOf *instruction) { |
| 25817 | // Here we create a lazy value in order to avoid resolving the alignment of the type | 26743 | // Here we create a lazy value in order to avoid resolving the alignment of the type |
| 25818 | // immediately. This avoids false positive dependency loops such as: | 26744 | // immediately. This avoids false positive dependency loops such as: |
| 25819 | // const Node = struct { | 26745 | // const Node = struct { |
| 25820 | // field: []align(@alignOf(Node)) Node, | 26746 | // field: []align(@alignOf(Node)) Node, |
| 25821 | // }; | 26747 | // }; |
| 25822 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 26748 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_num_lit_int); |
| 25823 | result->value->special = ConstValSpecialLazy; | 26749 | result->value->special = ConstValSpecialLazy; |
| 25824 | | 26750 | |
| 25825 | LazyValueAlignOf *lazy_align_of = allocate<LazyValueAlignOf>(1, "LazyValueAlignOf"); | 26751 | LazyValueAlignOf *lazy_align_of = allocate<LazyValueAlignOf>(1, "LazyValueAlignOf"); |
| ... | @@ -25829,41 +26755,41 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct | ... | @@ -25829,41 +26755,41 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct |
| 25829 | | 26755 | |
| 25830 | lazy_align_of->target_type = instruction->type_value->child; | 26756 | lazy_align_of->target_type = instruction->type_value->child; |
| 25831 | if (ir_resolve_type_lazy(ira, lazy_align_of->target_type) == nullptr) | 26757 | if (ir_resolve_type_lazy(ira, lazy_align_of->target_type) == nullptr) |
| 25832 | return ira->codegen->invalid_instruction; | 26758 | return ira->codegen->invalid_inst_gen; |
| 25833 | | 26759 | |
| 25834 | return result; | 26760 | return result; |
| 25835 | } | 26761 | } |
| 25836 | | 26762 | |
| 25837 | static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstructionOverflowOp *instruction) { | 26763 | static IrInstGen *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstSrcOverflowOp *instruction) { |
| 25838 | Error err; | 26764 | Error err; |
| 25839 | | 26765 | |
| 25840 | IrInstruction *type_value = instruction->type_value->child; | 26766 | IrInstGen *type_value = instruction->type_value->child; |
| 25841 | if (type_is_invalid(type_value->value->type)) | 26767 | if (type_is_invalid(type_value->value->type)) |
| 25842 | return ira->codegen->invalid_instruction; | 26768 | return ira->codegen->invalid_inst_gen; |
| 25843 | | 26769 | |
| 25844 | ZigType *dest_type = ir_resolve_type(ira, type_value); | 26770 | ZigType *dest_type = ir_resolve_type(ira, type_value); |
| 25845 | if (type_is_invalid(dest_type)) | 26771 | if (type_is_invalid(dest_type)) |
| 25846 | return ira->codegen->invalid_instruction; | 26772 | return ira->codegen->invalid_inst_gen; |
| 25847 | | 26773 | |
| 25848 | if (dest_type->id != ZigTypeIdInt) { | 26774 | if (dest_type->id != ZigTypeIdInt) { |
| 25849 | ir_add_error(ira, type_value, | 26775 | ir_add_error(ira, &type_value->base, |
| 25850 | buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); | 26776 | buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); |
| 25851 | return ira->codegen->invalid_instruction; | 26777 | return ira->codegen->invalid_inst_gen; |
| 25852 | } | 26778 | } |
| 25853 | | 26779 | |
| 25854 | IrInstruction *op1 = instruction->op1->child; | 26780 | IrInstGen *op1 = instruction->op1->child; |
| 25855 | if (type_is_invalid(op1->value->type)) | 26781 | if (type_is_invalid(op1->value->type)) |
| 25856 | return ira->codegen->invalid_instruction; | 26782 | return ira->codegen->invalid_inst_gen; |
| 25857 | | 26783 | |
| 25858 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, dest_type); | 26784 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, dest_type); |
| 25859 | if (type_is_invalid(casted_op1->value->type)) | 26785 | if (type_is_invalid(casted_op1->value->type)) |
| 25860 | return ira->codegen->invalid_instruction; | 26786 | return ira->codegen->invalid_inst_gen; |
| 25861 | | 26787 | |
| 25862 | IrInstruction *op2 = instruction->op2->child; | 26788 | IrInstGen *op2 = instruction->op2->child; |
| 25863 | if (type_is_invalid(op2->value->type)) | 26789 | if (type_is_invalid(op2->value->type)) |
| 25864 | return ira->codegen->invalid_instruction; | 26790 | return ira->codegen->invalid_inst_gen; |
| 25865 | | 26791 | |
| 25866 | IrInstruction *casted_op2; | 26792 | IrInstGen *casted_op2; |
| 25867 | if (instruction->op == IrOverflowOpShl) { | 26793 | if (instruction->op == IrOverflowOpShl) { |
| 25868 | ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, | 26794 | ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, |
| 25869 | dest_type->data.integral.bit_count - 1); | 26795 | dest_type->data.integral.bit_count - 1); |
| ... | @@ -25872,17 +26798,17 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -25872,17 +26798,17 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 25872 | casted_op2 = ir_implicit_cast(ira, op2, dest_type); | 26798 | casted_op2 = ir_implicit_cast(ira, op2, dest_type); |
| 25873 | } | 26799 | } |
| 25874 | if (type_is_invalid(casted_op2->value->type)) | 26800 | if (type_is_invalid(casted_op2->value->type)) |
| 25875 | return ira->codegen->invalid_instruction; | 26801 | return ira->codegen->invalid_inst_gen; |
| 25876 | | 26802 | |
| 25877 | IrInstruction *result_ptr = instruction->result_ptr->child; | 26803 | IrInstGen *result_ptr = instruction->result_ptr->child; |
| 25878 | if (type_is_invalid(result_ptr->value->type)) | 26804 | if (type_is_invalid(result_ptr->value->type)) |
| 25879 | return ira->codegen->invalid_instruction; | 26805 | return ira->codegen->invalid_inst_gen; |
| 25880 | | 26806 | |
| 25881 | ZigType *expected_ptr_type; | 26807 | ZigType *expected_ptr_type; |
| 25882 | if (result_ptr->value->type->id == ZigTypeIdPointer) { | 26808 | if (result_ptr->value->type->id == ZigTypeIdPointer) { |
| 25883 | uint32_t alignment; | 26809 | uint32_t alignment; |
| 25884 | if ((err = resolve_ptr_align(ira, result_ptr->value->type, &alignment))) | 26810 | if ((err = resolve_ptr_align(ira, result_ptr->value->type, &alignment))) |
| 25885 | return ira->codegen->invalid_instruction; | 26811 | return ira->codegen->invalid_inst_gen; |
| 25886 | expected_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_type, | 26812 | expected_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_type, |
| 25887 | false, result_ptr->value->type->data.pointer.is_volatile, | 26813 | false, result_ptr->value->type->data.pointer.is_volatile, |
| 25888 | PtrLenSingle, | 26814 | PtrLenSingle, |
| ... | @@ -25891,9 +26817,9 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -25891,9 +26817,9 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 25891 | expected_ptr_type = get_pointer_to_type(ira->codegen, dest_type, false); | 26817 | expected_ptr_type = get_pointer_to_type(ira->codegen, dest_type, false); |
| 25892 | } | 26818 | } |
| 25893 | | 26819 | |
| 25894 | IrInstruction *casted_result_ptr = ir_implicit_cast(ira, result_ptr, expected_ptr_type); | 26820 | IrInstGen *casted_result_ptr = ir_implicit_cast(ira, result_ptr, expected_ptr_type); |
| 25895 | if (type_is_invalid(casted_result_ptr->value->type)) | 26821 | if (type_is_invalid(casted_result_ptr->value->type)) |
| 25896 | return ira->codegen->invalid_instruction; | 26822 | return ira->codegen->invalid_inst_gen; |
| 25897 | | 26823 | |
| 25898 | if (instr_is_comptime(casted_op1) && | 26824 | if (instr_is_comptime(casted_op1) && |
| 25899 | instr_is_comptime(casted_op2) && | 26825 | instr_is_comptime(casted_op2) && |
| ... | @@ -25901,22 +26827,22 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -25901,22 +26827,22 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 25901 | { | 26827 | { |
| 25902 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); | 26828 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); |
| 25903 | if (op1_val == nullptr) | 26829 | if (op1_val == nullptr) |
| 25904 | return ira->codegen->invalid_instruction; | 26830 | return ira->codegen->invalid_inst_gen; |
| 25905 | | 26831 | |
| 25906 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 26832 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 25907 | if (op2_val == nullptr) | 26833 | if (op2_val == nullptr) |
| 25908 | return ira->codegen->invalid_instruction; | 26834 | return ira->codegen->invalid_inst_gen; |
| 25909 | | 26835 | |
| 25910 | ZigValue *result_val = ir_resolve_const(ira, casted_result_ptr, UndefBad); | 26836 | ZigValue *result_val = ir_resolve_const(ira, casted_result_ptr, UndefBad); |
| 25911 | if (result_val == nullptr) | 26837 | if (result_val == nullptr) |
| 25912 | return ira->codegen->invalid_instruction; | 26838 | return ira->codegen->invalid_inst_gen; |
| 25913 | | 26839 | |
| 25914 | BigInt *op1_bigint = &op1_val->data.x_bigint; | 26840 | BigInt *op1_bigint = &op1_val->data.x_bigint; |
| 25915 | BigInt *op2_bigint = &op2_val->data.x_bigint; | 26841 | BigInt *op2_bigint = &op2_val->data.x_bigint; |
| 25916 | ZigValue *pointee_val = const_ptr_pointee(ira, ira->codegen, result_val, | 26842 | ZigValue *pointee_val = const_ptr_pointee(ira, ira->codegen, result_val, |
| 25917 | casted_result_ptr->source_node); | 26843 | casted_result_ptr->base.source_node); |
| 25918 | if (pointee_val == nullptr) | 26844 | if (pointee_val == nullptr) |
| 25919 | return ira->codegen->invalid_instruction; | 26845 | return ira->codegen->invalid_inst_gen; |
| 25920 | BigInt *dest_bigint = &pointee_val->data.x_bigint; | 26846 | BigInt *dest_bigint = &pointee_val->data.x_bigint; |
| 25921 | switch (instruction->op) { | 26847 | switch (instruction->op) { |
| 25922 | case IrOverflowOpAdd: | 26848 | case IrOverflowOpAdd: |
| ... | @@ -25943,17 +26869,14 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -25943,17 +26869,14 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 25943 | dest_type->data.integral.is_signed); | 26869 | dest_type->data.integral.is_signed); |
| 25944 | } | 26870 | } |
| 25945 | pointee_val->special = ConstValSpecialStatic; | 26871 | pointee_val->special = ConstValSpecialStatic; |
| 25946 | return ir_const_bool(ira, &instruction->base, result_bool); | 26872 | return ir_const_bool(ira, &instruction->base.base, result_bool); |
| 25947 | } | 26873 | } |
| 25948 | | 26874 | |
| 25949 | IrInstruction *result = ir_build_overflow_op(&ira->new_irb, | 26875 | return ir_build_overflow_op_gen(ira, &instruction->base.base, instruction->op, |
| 25950 | instruction->base.scope, instruction->base.source_node, | 26876 | casted_op1, casted_op2, casted_result_ptr, dest_type); |
| 25951 | instruction->op, type_value, casted_op1, casted_op2, casted_result_ptr, dest_type); | | |
| 25952 | result->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 25953 | return result; | | |
| 25954 | } | 26877 | } |
| 25955 | | 26878 | |
| 25956 | static void ir_eval_mul_add(IrAnalyze *ira, IrInstructionMulAdd *source_instr, ZigType *float_type, | 26879 | static void ir_eval_mul_add(IrAnalyze *ira, IrInstSrcMulAdd *source_instr, ZigType *float_type, |
| 25957 | ZigValue *op1, ZigValue *op2, ZigValue *op3, ZigValue *out_val) { | 26880 | ZigValue *op1, ZigValue *op2, ZigValue *op3, ZigValue *out_val) { |
| 25958 | if (float_type->id == ZigTypeIdComptimeFloat) { | 26881 | if (float_type->id == ZigTypeIdComptimeFloat) { |
| 25959 | f128M_mulAdd(&out_val->data.x_bigfloat.value, &op1->data.x_bigfloat.value, &op2->data.x_bigfloat.value, | 26882 | f128M_mulAdd(&out_val->data.x_bigfloat.value, &op1->data.x_bigfloat.value, &op2->data.x_bigfloat.value, |
| ... | @@ -25980,61 +26903,61 @@ static void ir_eval_mul_add(IrAnalyze *ira, IrInstructionMulAdd *source_instr, Z | ... | @@ -25980,61 +26903,61 @@ static void ir_eval_mul_add(IrAnalyze *ira, IrInstructionMulAdd *source_instr, Z |
| 25980 | } | 26903 | } |
| 25981 | } | 26904 | } |
| 25982 | | 26905 | |
| 25983 | static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructionMulAdd *instruction) { | 26906 | static IrInstGen *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstSrcMulAdd *instruction) { |
| 25984 | IrInstruction *type_value = instruction->type_value->child; | 26907 | IrInstGen *type_value = instruction->type_value->child; |
| 25985 | if (type_is_invalid(type_value->value->type)) | 26908 | if (type_is_invalid(type_value->value->type)) |
| 25986 | return ira->codegen->invalid_instruction; | 26909 | return ira->codegen->invalid_inst_gen; |
| 25987 | | 26910 | |
| 25988 | ZigType *expr_type = ir_resolve_type(ira, type_value); | 26911 | ZigType *expr_type = ir_resolve_type(ira, type_value); |
| 25989 | if (type_is_invalid(expr_type)) | 26912 | if (type_is_invalid(expr_type)) |
| 25990 | return ira->codegen->invalid_instruction; | 26913 | return ira->codegen->invalid_inst_gen; |
| 25991 | | 26914 | |
| 25992 | // Only allow float types, and vectors of floats. | 26915 | // Only allow float types, and vectors of floats. |
| 25993 | ZigType *float_type = (expr_type->id == ZigTypeIdVector) ? expr_type->data.vector.elem_type : expr_type; | 26916 | ZigType *float_type = (expr_type->id == ZigTypeIdVector) ? expr_type->data.vector.elem_type : expr_type; |
| 25994 | if (float_type->id != ZigTypeIdFloat) { | 26917 | if (float_type->id != ZigTypeIdFloat) { |
| 25995 | ir_add_error(ira, type_value, | 26918 | ir_add_error(ira, &type_value->base, |
| 25996 | buf_sprintf("expected float or vector of float type, found '%s'", buf_ptr(&float_type->name))); | 26919 | buf_sprintf("expected float or vector of float type, found '%s'", buf_ptr(&float_type->name))); |
| 25997 | return ira->codegen->invalid_instruction; | 26920 | return ira->codegen->invalid_inst_gen; |
| 25998 | } | 26921 | } |
| 25999 | | 26922 | |
| 26000 | IrInstruction *op1 = instruction->op1->child; | 26923 | IrInstGen *op1 = instruction->op1->child; |
| 26001 | if (type_is_invalid(op1->value->type)) | 26924 | if (type_is_invalid(op1->value->type)) |
| 26002 | return ira->codegen->invalid_instruction; | 26925 | return ira->codegen->invalid_inst_gen; |
| 26003 | | 26926 | |
| 26004 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, expr_type); | 26927 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, expr_type); |
| 26005 | if (type_is_invalid(casted_op1->value->type)) | 26928 | if (type_is_invalid(casted_op1->value->type)) |
| 26006 | return ira->codegen->invalid_instruction; | 26929 | return ira->codegen->invalid_inst_gen; |
| 26007 | | 26930 | |
| 26008 | IrInstruction *op2 = instruction->op2->child; | 26931 | IrInstGen *op2 = instruction->op2->child; |
| 26009 | if (type_is_invalid(op2->value->type)) | 26932 | if (type_is_invalid(op2->value->type)) |
| 26010 | return ira->codegen->invalid_instruction; | 26933 | return ira->codegen->invalid_inst_gen; |
| 26011 | | 26934 | |
| 26012 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, expr_type); | 26935 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, expr_type); |
| 26013 | if (type_is_invalid(casted_op2->value->type)) | 26936 | if (type_is_invalid(casted_op2->value->type)) |
| 26014 | return ira->codegen->invalid_instruction; | 26937 | return ira->codegen->invalid_inst_gen; |
| 26015 | | 26938 | |
| 26016 | IrInstruction *op3 = instruction->op3->child; | 26939 | IrInstGen *op3 = instruction->op3->child; |
| 26017 | if (type_is_invalid(op3->value->type)) | 26940 | if (type_is_invalid(op3->value->type)) |
| 26018 | return ira->codegen->invalid_instruction; | 26941 | return ira->codegen->invalid_inst_gen; |
| 26019 | | 26942 | |
| 26020 | IrInstruction *casted_op3 = ir_implicit_cast(ira, op3, expr_type); | 26943 | IrInstGen *casted_op3 = ir_implicit_cast(ira, op3, expr_type); |
| 26021 | if (type_is_invalid(casted_op3->value->type)) | 26944 | if (type_is_invalid(casted_op3->value->type)) |
| 26022 | return ira->codegen->invalid_instruction; | 26945 | return ira->codegen->invalid_inst_gen; |
| 26023 | | 26946 | |
| 26024 | if (instr_is_comptime(casted_op1) && | 26947 | if (instr_is_comptime(casted_op1) && |
| 26025 | instr_is_comptime(casted_op2) && | 26948 | instr_is_comptime(casted_op2) && |
| 26026 | instr_is_comptime(casted_op3)) { | 26949 | instr_is_comptime(casted_op3)) { |
| 26027 | ZigValue *op1_const = ir_resolve_const(ira, casted_op1, UndefBad); | 26950 | ZigValue *op1_const = ir_resolve_const(ira, casted_op1, UndefBad); |
| 26028 | if (!op1_const) | 26951 | if (!op1_const) |
| 26029 | return ira->codegen->invalid_instruction; | 26952 | return ira->codegen->invalid_inst_gen; |
| 26030 | ZigValue *op2_const = ir_resolve_const(ira, casted_op2, UndefBad); | 26953 | ZigValue *op2_const = ir_resolve_const(ira, casted_op2, UndefBad); |
| 26031 | if (!op2_const) | 26954 | if (!op2_const) |
| 26032 | return ira->codegen->invalid_instruction; | 26955 | return ira->codegen->invalid_inst_gen; |
| 26033 | ZigValue *op3_const = ir_resolve_const(ira, casted_op3, UndefBad); | 26956 | ZigValue *op3_const = ir_resolve_const(ira, casted_op3, UndefBad); |
| 26034 | if (!op3_const) | 26957 | if (!op3_const) |
| 26035 | return ira->codegen->invalid_instruction; | 26958 | return ira->codegen->invalid_inst_gen; |
| 26036 | | 26959 | |
| 26037 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); | 26960 | IrInstGen *result = ir_const(ira, &instruction->base.base, expr_type); |
| 26038 | ZigValue *out_val = result->value; | 26961 | ZigValue *out_val = result->value; |
| 26039 | | 26962 | |
| 26040 | if (expr_type->id == ZigTypeIdVector) { | 26963 | if (expr_type->id == ZigTypeIdVector) { |
| ... | @@ -26065,63 +26988,59 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi | ... | @@ -26065,63 +26988,59 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi |
| 26065 | return result; | 26988 | return result; |
| 26066 | } | 26989 | } |
| 26067 | | 26990 | |
| 26068 | IrInstruction *result = ir_build_mul_add(&ira->new_irb, | 26991 | return ir_build_mul_add_gen(ira, &instruction->base.base, casted_op1, casted_op2, casted_op3, expr_type); |
| 26069 | instruction->base.scope, instruction->base.source_node, | | |
| 26070 | type_value, casted_op1, casted_op2, casted_op3); | | |
| 26071 | result->value->type = expr_type; | | |
| 26072 | return result; | | |
| 26073 | } | 26992 | } |
| 26074 | | 26993 | |
| 26075 | static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstructionTestErrSrc *instruction) { | 26994 | static IrInstGen *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstSrcTestErr *instruction) { |
| 26076 | IrInstruction *base_ptr = instruction->base_ptr->child; | 26995 | IrInstGen *base_ptr = instruction->base_ptr->child; |
| 26077 | if (type_is_invalid(base_ptr->value->type)) | 26996 | if (type_is_invalid(base_ptr->value->type)) |
| 26078 | return ira->codegen->invalid_instruction; | 26997 | return ira->codegen->invalid_inst_gen; |
| 26079 | | 26998 | |
| 26080 | IrInstruction *value; | 26999 | IrInstGen *value; |
| 26081 | if (instruction->base_ptr_is_payload) { | 27000 | if (instruction->base_ptr_is_payload) { |
| 26082 | value = base_ptr; | 27001 | value = base_ptr; |
| 26083 | } else { | 27002 | } else { |
| 26084 | value = ir_get_deref(ira, &instruction->base, base_ptr, nullptr); | 27003 | value = ir_get_deref(ira, &instruction->base.base, base_ptr, nullptr); |
| 26085 | } | 27004 | } |
| 26086 | | 27005 | |
| 26087 | ZigType *type_entry = value->value->type; | 27006 | ZigType *type_entry = value->value->type; |
| 26088 | if (type_is_invalid(type_entry)) | 27007 | if (type_is_invalid(type_entry)) |
| 26089 | return ira->codegen->invalid_instruction; | 27008 | return ira->codegen->invalid_inst_gen; |
| 26090 | if (type_entry->id == ZigTypeIdErrorUnion) { | 27009 | if (type_entry->id == ZigTypeIdErrorUnion) { |
| 26091 | if (instr_is_comptime(value)) { | 27010 | if (instr_is_comptime(value)) { |
| 26092 | ZigValue *err_union_val = ir_resolve_const(ira, value, UndefBad); | 27011 | ZigValue *err_union_val = ir_resolve_const(ira, value, UndefBad); |
| 26093 | if (!err_union_val) | 27012 | if (!err_union_val) |
| 26094 | return ira->codegen->invalid_instruction; | 27013 | return ira->codegen->invalid_inst_gen; |
| 26095 | | 27014 | |
| 26096 | if (err_union_val->special != ConstValSpecialRuntime) { | 27015 | if (err_union_val->special != ConstValSpecialRuntime) { |
| 26097 | ErrorTableEntry *err = err_union_val->data.x_err_union.error_set->data.x_err_set; | 27016 | ErrorTableEntry *err = err_union_val->data.x_err_union.error_set->data.x_err_set; |
| 26098 | return ir_const_bool(ira, &instruction->base, (err != nullptr)); | 27017 | return ir_const_bool(ira, &instruction->base.base, (err != nullptr)); |
| 26099 | } | 27018 | } |
| 26100 | } | 27019 | } |
| 26101 | | 27020 | |
| 26102 | if (instruction->resolve_err_set) { | 27021 | if (instruction->resolve_err_set) { |
| 26103 | ZigType *err_set_type = type_entry->data.error_union.err_set_type; | 27022 | ZigType *err_set_type = type_entry->data.error_union.err_set_type; |
| 26104 | if (!resolve_inferred_error_set(ira->codegen, err_set_type, instruction->base.source_node)) { | 27023 | if (!resolve_inferred_error_set(ira->codegen, err_set_type, instruction->base.base.source_node)) { |
| 26105 | return ira->codegen->invalid_instruction; | 27024 | return ira->codegen->invalid_inst_gen; |
| 26106 | } | 27025 | } |
| 26107 | if (!type_is_global_error_set(err_set_type) && | 27026 | if (!type_is_global_error_set(err_set_type) && |
| 26108 | err_set_type->data.error_set.err_count == 0) | 27027 | err_set_type->data.error_set.err_count == 0) |
| 26109 | { | 27028 | { |
| 26110 | assert(!err_set_type->data.error_set.incomplete); | 27029 | assert(!err_set_type->data.error_set.incomplete); |
| 26111 | return ir_const_bool(ira, &instruction->base, false); | 27030 | return ir_const_bool(ira, &instruction->base.base, false); |
| 26112 | } | 27031 | } |
| 26113 | } | 27032 | } |
| 26114 | | 27033 | |
| 26115 | return ir_build_test_err_gen(ira, &instruction->base, value); | 27034 | return ir_build_test_err_gen(ira, &instruction->base.base, value); |
| 26116 | } else if (type_entry->id == ZigTypeIdErrorSet) { | 27035 | } else if (type_entry->id == ZigTypeIdErrorSet) { |
| 26117 | return ir_const_bool(ira, &instruction->base, true); | 27036 | return ir_const_bool(ira, &instruction->base.base, true); |
| 26118 | } else { | 27037 | } else { |
| 26119 | return ir_const_bool(ira, &instruction->base, false); | 27038 | return ir_const_bool(ira, &instruction->base.base, false); |
| 26120 | } | 27039 | } |
| 26121 | } | 27040 | } |
| 26122 | | 27041 | |
| 26123 | static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction *source_instr, | 27042 | static IrInstGen *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInst* source_instr, |
| 26124 | IrInstruction *base_ptr, bool initializing) | 27043 | IrInstGen *base_ptr, bool initializing) |
| 26125 | { | 27044 | { |
| 26126 | ZigType *ptr_type = base_ptr->value->type; | 27045 | ZigType *ptr_type = base_ptr->value->type; |
| 26127 | | 27046 | |
| ... | @@ -26130,12 +27049,12 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * | ... | @@ -26130,12 +27049,12 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * |
| 26130 | | 27049 | |
| 26131 | ZigType *type_entry = ptr_type->data.pointer.child_type; | 27050 | ZigType *type_entry = ptr_type->data.pointer.child_type; |
| 26132 | if (type_is_invalid(type_entry)) | 27051 | if (type_is_invalid(type_entry)) |
| 26133 | return ira->codegen->invalid_instruction; | 27052 | return ira->codegen->invalid_inst_gen; |
| 26134 | | 27053 | |
| 26135 | if (type_entry->id != ZigTypeIdErrorUnion) { | 27054 | if (type_entry->id != ZigTypeIdErrorUnion) { |
| 26136 | ir_add_error(ira, base_ptr, | 27055 | ir_add_error(ira, &base_ptr->base, |
| 26137 | buf_sprintf("expected error union type, found '%s'", buf_ptr(&type_entry->name))); | 27056 | buf_sprintf("expected error union type, found '%s'", buf_ptr(&type_entry->name))); |
| 26138 | return ira->codegen->invalid_instruction; | 27057 | return ira->codegen->invalid_inst_gen; |
| 26139 | } | 27058 | } |
| 26140 | | 27059 | |
| 26141 | ZigType *err_set_type = type_entry->data.error_union.err_set_type; | 27060 | ZigType *err_set_type = type_entry->data.error_union.err_set_type; |
| ... | @@ -26146,13 +27065,13 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * | ... | @@ -26146,13 +27065,13 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * |
| 26146 | if (instr_is_comptime(base_ptr)) { | 27065 | if (instr_is_comptime(base_ptr)) { |
| 26147 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); | 27066 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); |
| 26148 | if (!ptr_val) | 27067 | if (!ptr_val) |
| 26149 | return ira->codegen->invalid_instruction; | 27068 | return ira->codegen->invalid_inst_gen; |
| 26150 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar && | 27069 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar && |
| 26151 | ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) | 27070 | ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) |
| 26152 | { | 27071 | { |
| 26153 | ZigValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 27072 | ZigValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 26154 | if (err_union_val == nullptr) | 27073 | if (err_union_val == nullptr) |
| 26155 | return ira->codegen->invalid_instruction; | 27074 | return ira->codegen->invalid_inst_gen; |
| 26156 | | 27075 | |
| 26157 | if (initializing && err_union_val->special == ConstValSpecialUndef) { | 27076 | if (initializing && err_union_val->special == ConstValSpecialUndef) { |
| 26158 | ZigValue *vals = create_const_vals(2); | 27077 | ZigValue *vals = create_const_vals(2); |
| ... | @@ -26175,11 +27094,10 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * | ... | @@ -26175,11 +27094,10 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * |
| 26175 | } | 27094 | } |
| 26176 | ir_assert(err_union_val->special != ConstValSpecialRuntime, source_instr); | 27095 | ir_assert(err_union_val->special != ConstValSpecialRuntime, source_instr); |
| 26177 | | 27096 | |
| 26178 | IrInstruction *result; | 27097 | IrInstGen *result; |
| 26179 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 27098 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 26180 | result = ir_build_unwrap_err_code(&ira->new_irb, source_instr->scope, | 27099 | result = ir_build_unwrap_err_code_gen(ira, source_instr->scope, |
| 26181 | source_instr->source_node, base_ptr); | 27100 | source_instr->source_node, base_ptr, result_type); |
| 26182 | result->value->type = result_type; | | |
| 26183 | result->value->special = ConstValSpecialStatic; | 27101 | result->value->special = ConstValSpecialStatic; |
| 26184 | } else { | 27102 | } else { |
| 26185 | result = ir_const(ira, source_instr, result_type); | 27103 | result = ir_const(ira, source_instr, result_type); |
| ... | @@ -26192,23 +27110,18 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * | ... | @@ -26192,23 +27110,18 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * |
| 26192 | } | 27110 | } |
| 26193 | } | 27111 | } |
| 26194 | | 27112 | |
| 26195 | IrInstruction *result = ir_build_unwrap_err_code(&ira->new_irb, | 27113 | return ir_build_unwrap_err_code_gen(ira, source_instr->scope, source_instr->source_node, base_ptr, result_type); |
| 26196 | source_instr->scope, source_instr->source_node, base_ptr); | | |
| 26197 | result->value->type = result_type; | | |
| 26198 | return result; | | |
| 26199 | } | 27114 | } |
| 26200 | | 27115 | |
| 26201 | static IrInstruction *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, | 27116 | static IrInstGen *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, IrInstSrcUnwrapErrCode *instruction) { |
| 26202 | IrInstructionUnwrapErrCode *instruction) | 27117 | IrInstGen *base_ptr = instruction->err_union_ptr->child; |
| 26203 | { | | |
| 26204 | IrInstruction *base_ptr = instruction->err_union_ptr->child; | | |
| 26205 | if (type_is_invalid(base_ptr->value->type)) | 27118 | if (type_is_invalid(base_ptr->value->type)) |
| 26206 | return ira->codegen->invalid_instruction; | 27119 | return ira->codegen->invalid_inst_gen; |
| 26207 | return ir_analyze_unwrap_err_code(ira, &instruction->base, base_ptr, false); | 27120 | return ir_analyze_unwrap_err_code(ira, &instruction->base.base, base_ptr, false); |
| 26208 | } | 27121 | } |
| 26209 | | 27122 | |
| 26210 | static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruction *source_instr, | 27123 | static IrInstGen *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInst* source_instr, |
| 26211 | IrInstruction *base_ptr, bool safety_check_on, bool initializing) | 27124 | IrInstGen *base_ptr, bool safety_check_on, bool initializing) |
| 26212 | { | 27125 | { |
| 26213 | ZigType *ptr_type = base_ptr->value->type; | 27126 | ZigType *ptr_type = base_ptr->value->type; |
| 26214 | | 27127 | |
| ... | @@ -26217,17 +27130,17 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct | ... | @@ -26217,17 +27130,17 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct |
| 26217 | | 27130 | |
| 26218 | ZigType *type_entry = ptr_type->data.pointer.child_type; | 27131 | ZigType *type_entry = ptr_type->data.pointer.child_type; |
| 26219 | if (type_is_invalid(type_entry)) | 27132 | if (type_is_invalid(type_entry)) |
| 26220 | return ira->codegen->invalid_instruction; | 27133 | return ira->codegen->invalid_inst_gen; |
| 26221 | | 27134 | |
| 26222 | if (type_entry->id != ZigTypeIdErrorUnion) { | 27135 | if (type_entry->id != ZigTypeIdErrorUnion) { |
| 26223 | ir_add_error(ira, base_ptr, | 27136 | ir_add_error(ira, &base_ptr->base, |
| 26224 | buf_sprintf("expected error union type, found '%s'", buf_ptr(&type_entry->name))); | 27137 | buf_sprintf("expected error union type, found '%s'", buf_ptr(&type_entry->name))); |
| 26225 | return ira->codegen->invalid_instruction; | 27138 | return ira->codegen->invalid_inst_gen; |
| 26226 | } | 27139 | } |
| 26227 | | 27140 | |
| 26228 | ZigType *payload_type = type_entry->data.error_union.payload_type; | 27141 | ZigType *payload_type = type_entry->data.error_union.payload_type; |
| 26229 | if (type_is_invalid(payload_type)) | 27142 | if (type_is_invalid(payload_type)) |
| 26230 | return ira->codegen->invalid_instruction; | 27143 | return ira->codegen->invalid_inst_gen; |
| 26231 | | 27144 | |
| 26232 | ZigType *result_type = get_pointer_to_type_extra(ira->codegen, payload_type, | 27145 | ZigType *result_type = get_pointer_to_type_extra(ira->codegen, payload_type, |
| 26233 | ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile, | 27146 | ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile, |
| ... | @@ -26236,11 +27149,11 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct | ... | @@ -26236,11 +27149,11 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct |
| 26236 | if (instr_is_comptime(base_ptr)) { | 27149 | if (instr_is_comptime(base_ptr)) { |
| 26237 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); | 27150 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); |
| 26238 | if (!ptr_val) | 27151 | if (!ptr_val) |
| 26239 | return ira->codegen->invalid_instruction; | 27152 | return ira->codegen->invalid_inst_gen; |
| 26240 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 27153 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 26241 | ZigValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 27154 | ZigValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 26242 | if (err_union_val == nullptr) | 27155 | if (err_union_val == nullptr) |
| 26243 | return ira->codegen->invalid_instruction; | 27156 | return ira->codegen->invalid_inst_gen; |
| 26244 | if (initializing && err_union_val->special == ConstValSpecialUndef) { | 27157 | if (initializing && err_union_val->special == ConstValSpecialUndef) { |
| 26245 | ZigValue *vals = create_const_vals(2); | 27158 | ZigValue *vals = create_const_vals(2); |
| 26246 | ZigValue *err_set_val = &vals[0]; | 27159 | ZigValue *err_set_val = &vals[0]; |
| ... | @@ -26263,14 +27176,13 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct | ... | @@ -26263,14 +27176,13 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct |
| 26263 | if (err != nullptr) { | 27176 | if (err != nullptr) { |
| 26264 | ir_add_error(ira, source_instr, | 27177 | ir_add_error(ira, source_instr, |
| 26265 | buf_sprintf("caught unexpected error '%s'", buf_ptr(&err->name))); | 27178 | buf_sprintf("caught unexpected error '%s'", buf_ptr(&err->name))); |
| 26266 | return ira->codegen->invalid_instruction; | 27179 | return ira->codegen->invalid_inst_gen; |
| 26267 | } | 27180 | } |
| 26268 | | 27181 | |
| 26269 | IrInstruction *result; | 27182 | IrInstGen *result; |
| 26270 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 27183 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 26271 | result = ir_build_unwrap_err_payload(&ira->new_irb, source_instr->scope, | 27184 | result = ir_build_unwrap_err_payload_gen(ira, source_instr->scope, |
| 26272 | source_instr->source_node, base_ptr, safety_check_on, initializing); | 27185 | source_instr->source_node, base_ptr, safety_check_on, initializing, result_type); |
| 26273 | result->value->type = result_type; | | |
| 26274 | result->value->special = ConstValSpecialStatic; | 27186 | result->value->special = ConstValSpecialStatic; |
| 26275 | } else { | 27187 | } else { |
| 26276 | result = ir_const(ira, source_instr, result_type); | 27188 | result = ir_const(ira, source_instr, result_type); |
| ... | @@ -26283,28 +27195,26 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct | ... | @@ -26283,28 +27195,26 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct |
| 26283 | } | 27195 | } |
| 26284 | } | 27196 | } |
| 26285 | | 27197 | |
| 26286 | IrInstruction *result = ir_build_unwrap_err_payload(&ira->new_irb, source_instr->scope, | 27198 | return ir_build_unwrap_err_payload_gen(ira, source_instr->scope, source_instr->source_node, |
| 26287 | source_instr->source_node, base_ptr, safety_check_on, initializing); | 27199 | base_ptr, safety_check_on, initializing, result_type); |
| 26288 | result->value->type = result_type; | | |
| 26289 | return result; | | |
| 26290 | } | 27200 | } |
| 26291 | | 27201 | |
| 26292 | static IrInstruction *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, | 27202 | static IrInstGen *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, |
| 26293 | IrInstructionUnwrapErrPayload *instruction) | 27203 | IrInstSrcUnwrapErrPayload *instruction) |
| 26294 | { | 27204 | { |
| 26295 | assert(instruction->value->child); | 27205 | assert(instruction->value->child); |
| 26296 | IrInstruction *value = instruction->value->child; | 27206 | IrInstGen *value = instruction->value->child; |
| 26297 | if (type_is_invalid(value->value->type)) | 27207 | if (type_is_invalid(value->value->type)) |
| 26298 | return ira->codegen->invalid_instruction; | 27208 | return ira->codegen->invalid_inst_gen; |
| 26299 | | 27209 | |
| 26300 | return ir_analyze_unwrap_error_payload(ira, &instruction->base, value, instruction->safety_check_on, false); | 27210 | return ir_analyze_unwrap_error_payload(ira, &instruction->base.base, value, instruction->safety_check_on, false); |
| 26301 | } | 27211 | } |
| 26302 | | 27212 | |
| 26303 | static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstructionFnProto *instruction) { | 27213 | static IrInstGen *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstSrcFnProto *instruction) { |
| 26304 | AstNode *proto_node = instruction->base.source_node; | 27214 | AstNode *proto_node = instruction->base.base.source_node; |
| 26305 | assert(proto_node->type == NodeTypeFnProto); | 27215 | assert(proto_node->type == NodeTypeFnProto); |
| 26306 | | 27216 | |
| 26307 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); | 27217 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 26308 | result->value->special = ConstValSpecialLazy; | 27218 | result->value->special = ConstValSpecialLazy; |
| 26309 | | 27219 | |
| 26310 | LazyValueFnType *lazy_fn_type = allocate<LazyValueFnType>(1, "LazyValueFnType"); | 27220 | LazyValueFnType *lazy_fn_type = allocate<LazyValueFnType>(1, "LazyValueFnType"); |
| ... | @@ -26313,29 +27223,29 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -26313,29 +27223,29 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 26313 | lazy_fn_type->base.id = LazyValueIdFnType; | 27223 | lazy_fn_type->base.id = LazyValueIdFnType; |
| 26314 | | 27224 | |
| 26315 | if (proto_node->data.fn_proto.auto_err_set) { | 27225 | if (proto_node->data.fn_proto.auto_err_set) { |
| 26316 | ir_add_error(ira, &instruction->base, | 27226 | ir_add_error(ira, &instruction->base.base, |
| 26317 | buf_sprintf("inferring error set of return type valid only for function definitions")); | 27227 | buf_sprintf("inferring error set of return type valid only for function definitions")); |
| 26318 | return ira->codegen->invalid_instruction; | 27228 | return ira->codegen->invalid_inst_gen; |
| 26319 | } | 27229 | } |
| 26320 | | 27230 | |
| 26321 | lazy_fn_type->cc = cc_from_fn_proto(&proto_node->data.fn_proto); | 27231 | lazy_fn_type->cc = cc_from_fn_proto(&proto_node->data.fn_proto); |
| 26322 | if (instruction->callconv_value != nullptr) { | 27232 | if (instruction->callconv_value != nullptr) { |
| 26323 | ZigType *cc_enum_type = get_builtin_type(ira->codegen, "CallingConvention"); | 27233 | ZigType *cc_enum_type = get_builtin_type(ira->codegen, "CallingConvention"); |
| 26324 | | 27234 | |
| 26325 | IrInstruction *casted_value = ir_implicit_cast(ira, instruction->callconv_value, cc_enum_type); | 27235 | IrInstGen *casted_value = ir_implicit_cast(ira, instruction->callconv_value->child, cc_enum_type); |
| 26326 | if (type_is_invalid(casted_value->value->type)) | 27236 | if (type_is_invalid(casted_value->value->type)) |
| 26327 | return ira->codegen->invalid_instruction; | 27237 | return ira->codegen->invalid_inst_gen; |
| 26328 | | 27238 | |
| 26329 | ZigValue *const_value = ir_resolve_const(ira, casted_value, UndefBad); | 27239 | ZigValue *const_value = ir_resolve_const(ira, casted_value, UndefBad); |
| 26330 | if (const_value == nullptr) | 27240 | if (const_value == nullptr) |
| 26331 | return ira->codegen->invalid_instruction; | 27241 | return ira->codegen->invalid_inst_gen; |
| 26332 | | 27242 | |
| 26333 | lazy_fn_type->cc = (CallingConvention)bigint_as_u32(&const_value->data.x_enum_tag); | 27243 | lazy_fn_type->cc = (CallingConvention)bigint_as_u32(&const_value->data.x_enum_tag); |
| 26334 | } | 27244 | } |
| 26335 | | 27245 | |
| 26336 | size_t param_count = proto_node->data.fn_proto.params.length; | 27246 | size_t param_count = proto_node->data.fn_proto.params.length; |
| 26337 | lazy_fn_type->proto_node = proto_node; | 27247 | lazy_fn_type->proto_node = proto_node; |
| 26338 | lazy_fn_type->param_types = allocate<IrInstruction *>(param_count); | 27248 | lazy_fn_type->param_types = allocate<IrInstGen *>(param_count); |
| 26339 | | 27249 | |
| 26340 | for (size_t param_index = 0; param_index < param_count; param_index += 1) { | 27250 | for (size_t param_index = 0; param_index < param_count; param_index += 1) { |
| 26341 | AstNode *param_node = proto_node->data.fn_proto.params.at(param_index); | 27251 | AstNode *param_node = proto_node->data.fn_proto.params.at(param_index); |
| ... | @@ -26360,63 +27270,63 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -26360,63 +27270,63 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 26360 | return result; | 27270 | return result; |
| 26361 | } | 27271 | } |
| 26362 | | 27272 | |
| 26363 | IrInstruction *param_type_value = instruction->param_types[param_index]->child; | 27273 | IrInstGen *param_type_value = instruction->param_types[param_index]->child; |
| 26364 | if (type_is_invalid(param_type_value->value->type)) | 27274 | if (type_is_invalid(param_type_value->value->type)) |
| 26365 | return ira->codegen->invalid_instruction; | 27275 | return ira->codegen->invalid_inst_gen; |
| 26366 | if (ir_resolve_const(ira, param_type_value, LazyOk) == nullptr) | 27276 | if (ir_resolve_const(ira, param_type_value, LazyOk) == nullptr) |
| 26367 | return ira->codegen->invalid_instruction; | 27277 | return ira->codegen->invalid_inst_gen; |
| 26368 | lazy_fn_type->param_types[param_index] = param_type_value; | 27278 | lazy_fn_type->param_types[param_index] = param_type_value; |
| 26369 | } | 27279 | } |
| 26370 | | 27280 | |
| 26371 | if (instruction->align_value != nullptr) { | 27281 | if (instruction->align_value != nullptr) { |
| 26372 | lazy_fn_type->align_inst = instruction->align_value->child; | 27282 | lazy_fn_type->align_inst = instruction->align_value->child; |
| 26373 | if (ir_resolve_const(ira, lazy_fn_type->align_inst, LazyOk) == nullptr) | 27283 | if (ir_resolve_const(ira, lazy_fn_type->align_inst, LazyOk) == nullptr) |
| 26374 | return ira->codegen->invalid_instruction; | 27284 | return ira->codegen->invalid_inst_gen; |
| 26375 | } | 27285 | } |
| 26376 | | 27286 | |
| 26377 | lazy_fn_type->return_type = instruction->return_type->child; | 27287 | lazy_fn_type->return_type = instruction->return_type->child; |
| 26378 | if (ir_resolve_const(ira, lazy_fn_type->return_type, LazyOk) == nullptr) | 27288 | if (ir_resolve_const(ira, lazy_fn_type->return_type, LazyOk) == nullptr) |
| 26379 | return ira->codegen->invalid_instruction; | 27289 | return ira->codegen->invalid_inst_gen; |
| 26380 | | 27290 | |
| 26381 | return result; | 27291 | return result; |
| 26382 | } | 27292 | } |
| 26383 | | 27293 | |
| 26384 | static IrInstruction *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrInstructionTestComptime *instruction) { | 27294 | static IrInstGen *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrInstSrcTestComptime *instruction) { |
| 26385 | IrInstruction *value = instruction->value->child; | 27295 | IrInstGen *value = instruction->value->child; |
| 26386 | if (type_is_invalid(value->value->type)) | 27296 | if (type_is_invalid(value->value->type)) |
| 26387 | return ira->codegen->invalid_instruction; | 27297 | return ira->codegen->invalid_inst_gen; |
| 26388 | | 27298 | |
| 26389 | return ir_const_bool(ira, &instruction->base, instr_is_comptime(value)); | 27299 | return ir_const_bool(ira, &instruction->base.base, instr_is_comptime(value)); |
| 26390 | } | 27300 | } |
| 26391 | | 27301 | |
| 26392 | static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | 27302 | static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 26393 | IrInstructionCheckSwitchProngs *instruction) | 27303 | IrInstSrcCheckSwitchProngs *instruction) |
| 26394 | { | 27304 | { |
| 26395 | IrInstruction *target_value = instruction->target_value->child; | 27305 | IrInstGen *target_value = instruction->target_value->child; |
| 26396 | ZigType *switch_type = target_value->value->type; | 27306 | ZigType *switch_type = target_value->value->type; |
| 26397 | if (type_is_invalid(switch_type)) | 27307 | if (type_is_invalid(switch_type)) |
| 26398 | return ira->codegen->invalid_instruction; | 27308 | return ira->codegen->invalid_inst_gen; |
| 26399 | | 27309 | |
| 26400 | if (switch_type->id == ZigTypeIdEnum) { | 27310 | if (switch_type->id == ZigTypeIdEnum) { |
| 26401 | HashMap<BigInt, AstNode *, bigint_hash, bigint_eql> field_prev_uses = {}; | 27311 | HashMap<BigInt, AstNode *, bigint_hash, bigint_eql> field_prev_uses = {}; |
| 26402 | field_prev_uses.init(switch_type->data.enumeration.src_field_count); | 27312 | field_prev_uses.init(switch_type->data.enumeration.src_field_count); |
| 26403 | | 27313 | |
| 26404 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { | 27314 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { |
| 26405 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | 27315 | IrInstSrcCheckSwitchProngsRange *range = &instruction->ranges[range_i]; |
| 26406 | | 27316 | |
| 26407 | IrInstruction *start_value_uncasted = range->start->child; | 27317 | IrInstGen *start_value_uncasted = range->start->child; |
| 26408 | if (type_is_invalid(start_value_uncasted->value->type)) | 27318 | if (type_is_invalid(start_value_uncasted->value->type)) |
| 26409 | return ira->codegen->invalid_instruction; | 27319 | return ira->codegen->invalid_inst_gen; |
| 26410 | IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); | 27320 | IrInstGen *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); |
| 26411 | if (type_is_invalid(start_value->value->type)) | 27321 | if (type_is_invalid(start_value->value->type)) |
| 26412 | return ira->codegen->invalid_instruction; | 27322 | return ira->codegen->invalid_inst_gen; |
| 26413 | | 27323 | |
| 26414 | IrInstruction *end_value_uncasted = range->end->child; | 27324 | IrInstGen *end_value_uncasted = range->end->child; |
| 26415 | if (type_is_invalid(end_value_uncasted->value->type)) | 27325 | if (type_is_invalid(end_value_uncasted->value->type)) |
| 26416 | return ira->codegen->invalid_instruction; | 27326 | return ira->codegen->invalid_inst_gen; |
| 26417 | IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); | 27327 | IrInstGen *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); |
| 26418 | if (type_is_invalid(end_value->value->type)) | 27328 | if (type_is_invalid(end_value->value->type)) |
| 26419 | return ira->codegen->invalid_instruction; | 27329 | return ira->codegen->invalid_inst_gen; |
| 26420 | | 27330 | |
| 26421 | assert(start_value->value->type->id == ZigTypeIdEnum); | 27331 | assert(start_value->value->type->id == ZigTypeIdEnum); |
| 26422 | BigInt start_index; | 27332 | BigInt start_index; |
| ... | @@ -26427,7 +27337,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -26427,7 +27337,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 26427 | bigint_init_bigint(&end_index, &end_value->value->data.x_enum_tag); | 27337 | bigint_init_bigint(&end_index, &end_value->value->data.x_enum_tag); |
| 26428 | | 27338 | |
| 26429 | if (bigint_cmp(&start_index, &end_index) == CmpGT) { | 27339 | if (bigint_cmp(&start_index, &end_index) == CmpGT) { |
| 26430 | ir_add_error(ira, start_value, | 27340 | ir_add_error(ira, &start_value->base, |
| 26431 | buf_sprintf("range start value is greater than the end value")); | 27341 | buf_sprintf("range start value is greater than the end value")); |
| 26432 | } | 27342 | } |
| 26433 | | 27343 | |
| ... | @@ -26438,12 +27348,12 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -26438,12 +27348,12 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 26438 | if (cmp == CmpGT) { | 27348 | if (cmp == CmpGT) { |
| 26439 | break; | 27349 | break; |
| 26440 | } | 27350 | } |
| 26441 | auto entry = field_prev_uses.put_unique(field_index, start_value->source_node); | 27351 | auto entry = field_prev_uses.put_unique(field_index, start_value->base.source_node); |
| 26442 | if (entry) { | 27352 | if (entry) { |
| 26443 | AstNode *prev_node = entry->value; | 27353 | AstNode *prev_node = entry->value; |
| 26444 | TypeEnumField *enum_field = find_enum_field_by_tag(switch_type, &field_index); | 27354 | TypeEnumField *enum_field = find_enum_field_by_tag(switch_type, &field_index); |
| 26445 | assert(enum_field != nullptr); | 27355 | assert(enum_field != nullptr); |
| 26446 | ErrorMsg *msg = ir_add_error(ira, start_value, | 27356 | ErrorMsg *msg = ir_add_error(ira, &start_value->base, |
| 26447 | buf_sprintf("duplicate switch value: '%s.%s'", buf_ptr(&switch_type->name), | 27357 | buf_sprintf("duplicate switch value: '%s.%s'", buf_ptr(&switch_type->name), |
| 26448 | buf_ptr(enum_field->name))); | 27358 | buf_ptr(enum_field->name))); |
| 26449 | add_error_note(ira->codegen, msg, prev_node, buf_sprintf("other value is here")); | 27359 | add_error_note(ira->codegen, msg, prev_node, buf_sprintf("other value is here")); |
| ... | @@ -26451,79 +27361,96 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -26451,79 +27361,96 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 26451 | bigint_incr(&field_index); | 27361 | bigint_incr(&field_index); |
| 26452 | } | 27362 | } |
| 26453 | } | 27363 | } |
| 26454 | if (!instruction->have_else_prong) { | 27364 | if (instruction->have_underscore_prong) { |
| 26455 | if (switch_type->data.enumeration.layout == ContainerLayoutExtern) { | 27365 | if (!switch_type->data.enumeration.non_exhaustive){ |
| 26456 | ir_add_error(ira, &instruction->base, | 27366 | ir_add_error(ira, &instruction->base.base, |
| 26457 | buf_sprintf("switch on an extern enum must have an else prong")); | 27367 | buf_sprintf("switch on non-exhaustive enum has `_` prong")); |
| | 27368 | } |
| | 27369 | for (uint32_t i = 0; i < switch_type->data.enumeration.src_field_count; i += 1) { |
| | 27370 | TypeEnumField *enum_field = &switch_type->data.enumeration.fields[i]; |
| | 27371 | if (buf_eql_str(enum_field->name, "_")) |
| | 27372 | continue; |
| | 27373 | |
| | 27374 | auto entry = field_prev_uses.maybe_get(enum_field->value); |
| | 27375 | if (!entry) { |
| | 27376 | ir_add_error(ira, &instruction->base.base, |
| | 27377 | buf_sprintf("enumeration value '%s.%s' not handled in switch", buf_ptr(&switch_type->name), |
| | 27378 | buf_ptr(enum_field->name))); |
| | 27379 | } |
| | 27380 | } |
| | 27381 | } else if (!instruction->have_else_prong) { |
| | 27382 | if (switch_type->data.enumeration.non_exhaustive) { |
| | 27383 | ir_add_error(ira, &instruction->base.base, |
| | 27384 | buf_sprintf("switch on non-exhaustive enum must include `else` or `_` prong")); |
| 26458 | } | 27385 | } |
| 26459 | for (uint32_t i = 0; i < switch_type->data.enumeration.src_field_count; i += 1) { | 27386 | for (uint32_t i = 0; i < switch_type->data.enumeration.src_field_count; i += 1) { |
| 26460 | TypeEnumField *enum_field = &switch_type->data.enumeration.fields[i]; | 27387 | TypeEnumField *enum_field = &switch_type->data.enumeration.fields[i]; |
| 26461 | | 27388 | |
| 26462 | auto entry = field_prev_uses.maybe_get(enum_field->value); | 27389 | auto entry = field_prev_uses.maybe_get(enum_field->value); |
| 26463 | if (!entry) { | 27390 | if (!entry) { |
| 26464 | ir_add_error(ira, &instruction->base, | 27391 | ir_add_error(ira, &instruction->base.base, |
| 26465 | buf_sprintf("enumeration value '%s.%s' not handled in switch", buf_ptr(&switch_type->name), | 27392 | buf_sprintf("enumeration value '%s.%s' not handled in switch", buf_ptr(&switch_type->name), |
| 26466 | buf_ptr(enum_field->name))); | 27393 | buf_ptr(enum_field->name))); |
| 26467 | } | 27394 | } |
| 26468 | } | 27395 | } |
| 26469 | } | 27396 | } |
| 26470 | } else if (switch_type->id == ZigTypeIdErrorSet) { | 27397 | } else if (switch_type->id == ZigTypeIdErrorSet) { |
| 26471 | if (!resolve_inferred_error_set(ira->codegen, switch_type, target_value->source_node)) { | 27398 | if (!resolve_inferred_error_set(ira->codegen, switch_type, target_value->base.source_node)) { |
| 26472 | return ira->codegen->invalid_instruction; | 27399 | return ira->codegen->invalid_inst_gen; |
| 26473 | } | 27400 | } |
| 26474 | | 27401 | |
| 26475 | size_t field_prev_uses_count = ira->codegen->errors_by_index.length; | 27402 | size_t field_prev_uses_count = ira->codegen->errors_by_index.length; |
| 26476 | AstNode **field_prev_uses = allocate<AstNode *>(field_prev_uses_count, "AstNode *"); | 27403 | AstNode **field_prev_uses = allocate<AstNode *>(field_prev_uses_count, "AstNode *"); |
| 26477 | | 27404 | |
| 26478 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { | 27405 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { |
| 26479 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | 27406 | IrInstSrcCheckSwitchProngsRange *range = &instruction->ranges[range_i]; |
| 26480 | | 27407 | |
| 26481 | IrInstruction *start_value_uncasted = range->start->child; | 27408 | IrInstGen *start_value_uncasted = range->start->child; |
| 26482 | if (type_is_invalid(start_value_uncasted->value->type)) | 27409 | if (type_is_invalid(start_value_uncasted->value->type)) |
| 26483 | return ira->codegen->invalid_instruction; | 27410 | return ira->codegen->invalid_inst_gen; |
| 26484 | IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); | 27411 | IrInstGen *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); |
| 26485 | if (type_is_invalid(start_value->value->type)) | 27412 | if (type_is_invalid(start_value->value->type)) |
| 26486 | return ira->codegen->invalid_instruction; | 27413 | return ira->codegen->invalid_inst_gen; |
| 26487 | | 27414 | |
| 26488 | IrInstruction *end_value_uncasted = range->end->child; | 27415 | IrInstGen *end_value_uncasted = range->end->child; |
| 26489 | if (type_is_invalid(end_value_uncasted->value->type)) | 27416 | if (type_is_invalid(end_value_uncasted->value->type)) |
| 26490 | return ira->codegen->invalid_instruction; | 27417 | return ira->codegen->invalid_inst_gen; |
| 26491 | IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); | 27418 | IrInstGen *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); |
| 26492 | if (type_is_invalid(end_value->value->type)) | 27419 | if (type_is_invalid(end_value->value->type)) |
| 26493 | return ira->codegen->invalid_instruction; | 27420 | return ira->codegen->invalid_inst_gen; |
| 26494 | | 27421 | |
| 26495 | ir_assert(start_value->value->type->id == ZigTypeIdErrorSet, &instruction->base); | 27422 | ir_assert(start_value->value->type->id == ZigTypeIdErrorSet, &instruction->base.base); |
| 26496 | uint32_t start_index = start_value->value->data.x_err_set->value; | 27423 | uint32_t start_index = start_value->value->data.x_err_set->value; |
| 26497 | | 27424 | |
| 26498 | ir_assert(end_value->value->type->id == ZigTypeIdErrorSet, &instruction->base); | 27425 | ir_assert(end_value->value->type->id == ZigTypeIdErrorSet, &instruction->base.base); |
| 26499 | uint32_t end_index = end_value->value->data.x_err_set->value; | 27426 | uint32_t end_index = end_value->value->data.x_err_set->value; |
| 26500 | | 27427 | |
| 26501 | if (start_index != end_index) { | 27428 | if (start_index != end_index) { |
| 26502 | ir_add_error(ira, end_value, buf_sprintf("ranges not allowed when switching on errors")); | 27429 | ir_add_error(ira, &end_value->base, buf_sprintf("ranges not allowed when switching on errors")); |
| 26503 | return ira->codegen->invalid_instruction; | 27430 | return ira->codegen->invalid_inst_gen; |
| 26504 | } | 27431 | } |
| 26505 | | 27432 | |
| 26506 | AstNode *prev_node = field_prev_uses[start_index]; | 27433 | AstNode *prev_node = field_prev_uses[start_index]; |
| 26507 | if (prev_node != nullptr) { | 27434 | if (prev_node != nullptr) { |
| 26508 | Buf *err_name = &ira->codegen->errors_by_index.at(start_index)->name; | 27435 | Buf *err_name = &ira->codegen->errors_by_index.at(start_index)->name; |
| 26509 | ErrorMsg *msg = ir_add_error(ira, start_value, | 27436 | ErrorMsg *msg = ir_add_error(ira, &start_value->base, |
| 26510 | buf_sprintf("duplicate switch value: '%s.%s'", buf_ptr(&switch_type->name), buf_ptr(err_name))); | 27437 | buf_sprintf("duplicate switch value: '%s.%s'", buf_ptr(&switch_type->name), buf_ptr(err_name))); |
| 26511 | add_error_note(ira->codegen, msg, prev_node, buf_sprintf("other value is here")); | 27438 | add_error_note(ira->codegen, msg, prev_node, buf_sprintf("other value is here")); |
| 26512 | } | 27439 | } |
| 26513 | field_prev_uses[start_index] = start_value->source_node; | 27440 | field_prev_uses[start_index] = start_value->base.source_node; |
| 26514 | } | 27441 | } |
| 26515 | if (!instruction->have_else_prong) { | 27442 | if (!instruction->have_else_prong) { |
| 26516 | if (type_is_global_error_set(switch_type)) { | 27443 | if (type_is_global_error_set(switch_type)) { |
| 26517 | ir_add_error(ira, &instruction->base, | 27444 | ir_add_error(ira, &instruction->base.base, |
| 26518 | buf_sprintf("else prong required when switching on type 'anyerror'")); | 27445 | buf_sprintf("else prong required when switching on type 'anyerror'")); |
| 26519 | return ira->codegen->invalid_instruction; | 27446 | return ira->codegen->invalid_inst_gen; |
| 26520 | } else { | 27447 | } else { |
| 26521 | for (uint32_t i = 0; i < switch_type->data.error_set.err_count; i += 1) { | 27448 | for (uint32_t i = 0; i < switch_type->data.error_set.err_count; i += 1) { |
| 26522 | ErrorTableEntry *err_entry = switch_type->data.error_set.errors[i]; | 27449 | ErrorTableEntry *err_entry = switch_type->data.error_set.errors[i]; |
| 26523 | | 27450 | |
| 26524 | AstNode *prev_node = field_prev_uses[err_entry->value]; | 27451 | AstNode *prev_node = field_prev_uses[err_entry->value]; |
| 26525 | if (prev_node == nullptr) { | 27452 | if (prev_node == nullptr) { |
| 26526 | ir_add_error(ira, &instruction->base, | 27453 | ir_add_error(ira, &instruction->base.base, |
| 26527 | buf_sprintf("error.%s not handled in switch", buf_ptr(&err_entry->name))); | 27454 | buf_sprintf("error.%s not handled in switch", buf_ptr(&err_entry->name))); |
| 26528 | } | 27455 | } |
| 26529 | } | 27456 | } |
| ... | @@ -26534,44 +27461,44 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -26534,44 +27461,44 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 26534 | } else if (switch_type->id == ZigTypeIdInt) { | 27461 | } else if (switch_type->id == ZigTypeIdInt) { |
| 26535 | RangeSet rs = {0}; | 27462 | RangeSet rs = {0}; |
| 26536 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { | 27463 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { |
| 26537 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | 27464 | IrInstSrcCheckSwitchProngsRange *range = &instruction->ranges[range_i]; |
| 26538 | | 27465 | |
| 26539 | IrInstruction *start_value = range->start->child; | 27466 | IrInstGen *start_value = range->start->child; |
| 26540 | if (type_is_invalid(start_value->value->type)) | 27467 | if (type_is_invalid(start_value->value->type)) |
| 26541 | return ira->codegen->invalid_instruction; | 27468 | return ira->codegen->invalid_inst_gen; |
| 26542 | IrInstruction *casted_start_value = ir_implicit_cast(ira, start_value, switch_type); | 27469 | IrInstGen *casted_start_value = ir_implicit_cast(ira, start_value, switch_type); |
| 26543 | if (type_is_invalid(casted_start_value->value->type)) | 27470 | if (type_is_invalid(casted_start_value->value->type)) |
| 26544 | return ira->codegen->invalid_instruction; | 27471 | return ira->codegen->invalid_inst_gen; |
| 26545 | | 27472 | |
| 26546 | IrInstruction *end_value = range->end->child; | 27473 | IrInstGen *end_value = range->end->child; |
| 26547 | if (type_is_invalid(end_value->value->type)) | 27474 | if (type_is_invalid(end_value->value->type)) |
| 26548 | return ira->codegen->invalid_instruction; | 27475 | return ira->codegen->invalid_inst_gen; |
| 26549 | IrInstruction *casted_end_value = ir_implicit_cast(ira, end_value, switch_type); | 27476 | IrInstGen *casted_end_value = ir_implicit_cast(ira, end_value, switch_type); |
| 26550 | if (type_is_invalid(casted_end_value->value->type)) | 27477 | if (type_is_invalid(casted_end_value->value->type)) |
| 26551 | return ira->codegen->invalid_instruction; | 27478 | return ira->codegen->invalid_inst_gen; |
| 26552 | | 27479 | |
| 26553 | ZigValue *start_val = ir_resolve_const(ira, casted_start_value, UndefBad); | 27480 | ZigValue *start_val = ir_resolve_const(ira, casted_start_value, UndefBad); |
| 26554 | if (!start_val) | 27481 | if (!start_val) |
| 26555 | return ira->codegen->invalid_instruction; | 27482 | return ira->codegen->invalid_inst_gen; |
| 26556 | | 27483 | |
| 26557 | ZigValue *end_val = ir_resolve_const(ira, casted_end_value, UndefBad); | 27484 | ZigValue *end_val = ir_resolve_const(ira, casted_end_value, UndefBad); |
| 26558 | if (!end_val) | 27485 | if (!end_val) |
| 26559 | return ira->codegen->invalid_instruction; | 27486 | return ira->codegen->invalid_inst_gen; |
| 26560 | | 27487 | |
| 26561 | assert(start_val->type->id == ZigTypeIdInt || start_val->type->id == ZigTypeIdComptimeInt); | 27488 | assert(start_val->type->id == ZigTypeIdInt || start_val->type->id == ZigTypeIdComptimeInt); |
| 26562 | assert(end_val->type->id == ZigTypeIdInt || end_val->type->id == ZigTypeIdComptimeInt); | 27489 | assert(end_val->type->id == ZigTypeIdInt || end_val->type->id == ZigTypeIdComptimeInt); |
| 26563 | | 27490 | |
| 26564 | if (bigint_cmp(&start_val->data.x_bigint, &end_val->data.x_bigint) == CmpGT) { | 27491 | if (bigint_cmp(&start_val->data.x_bigint, &end_val->data.x_bigint) == CmpGT) { |
| 26565 | ir_add_error(ira, start_value, | 27492 | ir_add_error(ira, &start_value->base, |
| 26566 | buf_sprintf("range start value is greater than the end value")); | 27493 | buf_sprintf("range start value is greater than the end value")); |
| 26567 | } | 27494 | } |
| 26568 | | 27495 | |
| 26569 | AstNode *prev_node = rangeset_add_range(&rs, &start_val->data.x_bigint, &end_val->data.x_bigint, | 27496 | AstNode *prev_node = rangeset_add_range(&rs, &start_val->data.x_bigint, &end_val->data.x_bigint, |
| 26570 | start_value->source_node); | 27497 | start_value->base.source_node); |
| 26571 | if (prev_node != nullptr) { | 27498 | if (prev_node != nullptr) { |
| 26572 | ErrorMsg *msg = ir_add_error(ira, start_value, buf_sprintf("duplicate switch value")); | 27499 | ErrorMsg *msg = ir_add_error(ira, &start_value->base, buf_sprintf("duplicate switch value")); |
| 26573 | add_error_note(ira->codegen, msg, prev_node, buf_sprintf("previous value is here")); | 27500 | add_error_note(ira->codegen, msg, prev_node, buf_sprintf("previous value is here")); |
| 26574 | return ira->codegen->invalid_instruction; | 27501 | return ira->codegen->invalid_inst_gen; |
| 26575 | } | 27502 | } |
| 26576 | } | 27503 | } |
| 26577 | if (!instruction->have_else_prong) { | 27504 | if (!instruction->have_else_prong) { |
| ... | @@ -26580,25 +27507,25 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -26580,25 +27507,25 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 26580 | BigInt max_val; | 27507 | BigInt max_val; |
| 26581 | eval_min_max_value_int(ira->codegen, switch_type, &max_val, true); | 27508 | eval_min_max_value_int(ira->codegen, switch_type, &max_val, true); |
| 26582 | if (!rangeset_spans(&rs, &min_val, &max_val)) { | 27509 | if (!rangeset_spans(&rs, &min_val, &max_val)) { |
| 26583 | ir_add_error(ira, &instruction->base, buf_sprintf("switch must handle all possibilities")); | 27510 | ir_add_error(ira, &instruction->base.base, buf_sprintf("switch must handle all possibilities")); |
| 26584 | return ira->codegen->invalid_instruction; | 27511 | return ira->codegen->invalid_inst_gen; |
| 26585 | } | 27512 | } |
| 26586 | } | 27513 | } |
| 26587 | } else if (switch_type->id == ZigTypeIdBool) { | 27514 | } else if (switch_type->id == ZigTypeIdBool) { |
| 26588 | int seenTrue = 0; | 27515 | int seenTrue = 0; |
| 26589 | int seenFalse = 0; | 27516 | int seenFalse = 0; |
| 26590 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { | 27517 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { |
| 26591 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | 27518 | IrInstSrcCheckSwitchProngsRange *range = &instruction->ranges[range_i]; |
| 26592 | | 27519 | |
| 26593 | IrInstruction *value = range->start->child; | 27520 | IrInstGen *value = range->start->child; |
| 26594 | | 27521 | |
| 26595 | IrInstruction *casted_value = ir_implicit_cast(ira, value, switch_type); | 27522 | IrInstGen *casted_value = ir_implicit_cast(ira, value, switch_type); |
| 26596 | if (type_is_invalid(casted_value->value->type)) | 27523 | if (type_is_invalid(casted_value->value->type)) |
| 26597 | return ira->codegen->invalid_instruction; | 27524 | return ira->codegen->invalid_inst_gen; |
| 26598 | | 27525 | |
| 26599 | ZigValue *const_expr_val = ir_resolve_const(ira, casted_value, UndefBad); | 27526 | ZigValue *const_expr_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 26600 | if (!const_expr_val) | 27527 | if (!const_expr_val) |
| 26601 | return ira->codegen->invalid_instruction; | 27528 | return ira->codegen->invalid_inst_gen; |
| 26602 | | 27529 | |
| 26603 | assert(const_expr_val->type->id == ZigTypeIdBool); | 27530 | assert(const_expr_val->type->id == ZigTypeIdBool); |
| 26604 | | 27531 | |
| ... | @@ -26609,60 +27536,59 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -26609,60 +27536,59 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 26609 | } | 27536 | } |
| 26610 | | 27537 | |
| 26611 | if ((seenTrue > 1) || (seenFalse > 1)) { | 27538 | if ((seenTrue > 1) || (seenFalse > 1)) { |
| 26612 | ir_add_error(ira, value, buf_sprintf("duplicate switch value")); | 27539 | ir_add_error(ira, &value->base, buf_sprintf("duplicate switch value")); |
| 26613 | return ira->codegen->invalid_instruction; | 27540 | return ira->codegen->invalid_inst_gen; |
| 26614 | } | 27541 | } |
| 26615 | } | 27542 | } |
| 26616 | if (((seenTrue < 1) || (seenFalse < 1)) && !instruction->have_else_prong) { | 27543 | if (((seenTrue < 1) || (seenFalse < 1)) && !instruction->have_else_prong) { |
| 26617 | ir_add_error(ira, &instruction->base, buf_sprintf("switch must handle all possibilities")); | 27544 | ir_add_error(ira, &instruction->base.base, buf_sprintf("switch must handle all possibilities")); |
| 26618 | return ira->codegen->invalid_instruction; | 27545 | return ira->codegen->invalid_inst_gen; |
| 26619 | } | 27546 | } |
| 26620 | } else if (!instruction->have_else_prong) { | 27547 | } else if (!instruction->have_else_prong) { |
| 26621 | ir_add_error(ira, &instruction->base, | 27548 | ir_add_error(ira, &instruction->base.base, |
| 26622 | buf_sprintf("else prong required when switching on type '%s'", buf_ptr(&switch_type->name))); | 27549 | buf_sprintf("else prong required when switching on type '%s'", buf_ptr(&switch_type->name))); |
| 26623 | return ira->codegen->invalid_instruction; | 27550 | return ira->codegen->invalid_inst_gen; |
| 26624 | } | 27551 | } |
| 26625 | return ir_const_void(ira, &instruction->base); | 27552 | return ir_const_void(ira, &instruction->base.base); |
| 26626 | } | 27553 | } |
| 26627 | | 27554 | |
| 26628 | static IrInstruction *ir_analyze_instruction_check_statement_is_void(IrAnalyze *ira, | 27555 | static IrInstGen *ir_analyze_instruction_check_statement_is_void(IrAnalyze *ira, |
| 26629 | IrInstructionCheckStatementIsVoid *instruction) | 27556 | IrInstSrcCheckStatementIsVoid *instruction) |
| 26630 | { | 27557 | { |
| 26631 | IrInstruction *statement_value = instruction->statement_value->child; | 27558 | IrInstGen *statement_value = instruction->statement_value->child; |
| 26632 | ZigType *statement_type = statement_value->value->type; | 27559 | ZigType *statement_type = statement_value->value->type; |
| 26633 | if (type_is_invalid(statement_type)) | 27560 | if (type_is_invalid(statement_type)) |
| 26634 | return ira->codegen->invalid_instruction; | 27561 | return ira->codegen->invalid_inst_gen; |
| 26635 | | 27562 | |
| 26636 | if (statement_type->id != ZigTypeIdVoid && statement_type->id != ZigTypeIdUnreachable) { | 27563 | if (statement_type->id != ZigTypeIdVoid && statement_type->id != ZigTypeIdUnreachable) { |
| 26637 | ir_add_error(ira, &instruction->base, buf_sprintf("expression value is ignored")); | 27564 | ir_add_error(ira, &instruction->base.base, buf_sprintf("expression value is ignored")); |
| 26638 | } | 27565 | } |
| 26639 | | 27566 | |
| 26640 | return ir_const_void(ira, &instruction->base); | 27567 | return ir_const_void(ira, &instruction->base.base); |
| 26641 | } | 27568 | } |
| 26642 | | 27569 | |
| 26643 | static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructionPanic *instruction) { | 27570 | static IrInstGen *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstSrcPanic *instruction) { |
| 26644 | IrInstruction *msg = instruction->msg->child; | 27571 | IrInstGen *msg = instruction->msg->child; |
| 26645 | if (type_is_invalid(msg->value->type)) | 27572 | if (type_is_invalid(msg->value->type)) |
| 26646 | return ir_unreach_error(ira); | 27573 | return ir_unreach_error(ira); |
| 26647 | | 27574 | |
| 26648 | if (ir_should_inline(ira->new_irb.exec, instruction->base.scope)) { | 27575 | if (ir_should_inline(ira->old_irb.exec, instruction->base.base.scope)) { |
| 26649 | ir_add_error(ira, &instruction->base, buf_sprintf("encountered @panic at compile-time")); | 27576 | ir_add_error(ira, &instruction->base.base, buf_sprintf("encountered @panic at compile-time")); |
| 26650 | return ir_unreach_error(ira); | 27577 | return ir_unreach_error(ira); |
| 26651 | } | 27578 | } |
| 26652 | | 27579 | |
| 26653 | ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, | 27580 | ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 26654 | true, false, PtrLenUnknown, 0, 0, 0, false); | 27581 | true, false, PtrLenUnknown, 0, 0, 0, false); |
| 26655 | ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); | 27582 | ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); |
| 26656 | IrInstruction *casted_msg = ir_implicit_cast(ira, msg, str_type); | 27583 | IrInstGen *casted_msg = ir_implicit_cast(ira, msg, str_type); |
| 26657 | if (type_is_invalid(casted_msg->value->type)) | 27584 | if (type_is_invalid(casted_msg->value->type)) |
| 26658 | return ir_unreach_error(ira); | 27585 | return ir_unreach_error(ira); |
| 26659 | | 27586 | |
| 26660 | IrInstruction *new_instruction = ir_build_panic(&ira->new_irb, instruction->base.scope, | 27587 | IrInstGen *new_instruction = ir_build_panic_gen(ira, &instruction->base.base, casted_msg); |
| 26661 | instruction->base.source_node, casted_msg); | | |
| 26662 | return ir_finish_anal(ira, new_instruction); | 27588 | return ir_finish_anal(ira, new_instruction); |
| 26663 | } | 27589 | } |
| 26664 | | 27590 | |
| 26665 | static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint32_t align_bytes, bool safety_check_on) { | 27591 | static IrInstGen *ir_align_cast(IrAnalyze *ira, IrInstGen *target, uint32_t align_bytes, bool safety_check_on) { |
| 26666 | Error err; | 27592 | Error err; |
| 26667 | | 27593 | |
| 26668 | ZigType *target_type = target->value->type; | 27594 | ZigType *target_type = target->value->type; |
| ... | @@ -26674,7 +27600,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 | ... | @@ -26674,7 +27600,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 |
| 26674 | if (target_type->id == ZigTypeIdPointer) { | 27600 | if (target_type->id == ZigTypeIdPointer) { |
| 26675 | result_type = adjust_ptr_align(ira->codegen, target_type, align_bytes); | 27601 | result_type = adjust_ptr_align(ira->codegen, target_type, align_bytes); |
| 26676 | if ((err = resolve_ptr_align(ira, target_type, &old_align_bytes))) | 27602 | if ((err = resolve_ptr_align(ira, target_type, &old_align_bytes))) |
| 26677 | return ira->codegen->invalid_instruction; | 27603 | return ira->codegen->invalid_inst_gen; |
| 26678 | } else if (target_type->id == ZigTypeIdFn) { | 27604 | } else if (target_type->id == ZigTypeIdFn) { |
| 26679 | FnTypeId fn_type_id = target_type->data.fn.fn_type_id; | 27605 | FnTypeId fn_type_id = target_type->data.fn.fn_type_id; |
| 26680 | old_align_bytes = fn_type_id.alignment; | 27606 | old_align_bytes = fn_type_id.alignment; |
| ... | @@ -26685,7 +27611,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 | ... | @@ -26685,7 +27611,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 |
| 26685 | { | 27611 | { |
| 26686 | ZigType *ptr_type = target_type->data.maybe.child_type; | 27612 | ZigType *ptr_type = target_type->data.maybe.child_type; |
| 26687 | if ((err = resolve_ptr_align(ira, ptr_type, &old_align_bytes))) | 27613 | if ((err = resolve_ptr_align(ira, ptr_type, &old_align_bytes))) |
| 26688 | return ira->codegen->invalid_instruction; | 27614 | return ira->codegen->invalid_inst_gen; |
| 26689 | ZigType *better_ptr_type = adjust_ptr_align(ira->codegen, ptr_type, align_bytes); | 27615 | ZigType *better_ptr_type = adjust_ptr_align(ira->codegen, ptr_type, align_bytes); |
| 26690 | | 27616 | |
| 26691 | result_type = get_optional_type(ira->codegen, better_ptr_type); | 27617 | result_type = get_optional_type(ira->codegen, better_ptr_type); |
| ... | @@ -26700,47 +27626,44 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 | ... | @@ -26700,47 +27626,44 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 |
| 26700 | } else if (is_slice(target_type)) { | 27626 | } else if (is_slice(target_type)) { |
| 26701 | ZigType *slice_ptr_type = target_type->data.structure.fields[slice_ptr_index]->type_entry; | 27627 | ZigType *slice_ptr_type = target_type->data.structure.fields[slice_ptr_index]->type_entry; |
| 26702 | if ((err = resolve_ptr_align(ira, slice_ptr_type, &old_align_bytes))) | 27628 | if ((err = resolve_ptr_align(ira, slice_ptr_type, &old_align_bytes))) |
| 26703 | return ira->codegen->invalid_instruction; | 27629 | return ira->codegen->invalid_inst_gen; |
| 26704 | ZigType *result_ptr_type = adjust_ptr_align(ira->codegen, slice_ptr_type, align_bytes); | 27630 | ZigType *result_ptr_type = adjust_ptr_align(ira->codegen, slice_ptr_type, align_bytes); |
| 26705 | result_type = get_slice_type(ira->codegen, result_ptr_type); | 27631 | result_type = get_slice_type(ira->codegen, result_ptr_type); |
| 26706 | } else { | 27632 | } else { |
| 26707 | ir_add_error(ira, target, | 27633 | ir_add_error(ira, &target->base, |
| 26708 | buf_sprintf("expected pointer or slice, found '%s'", buf_ptr(&target_type->name))); | 27634 | buf_sprintf("expected pointer or slice, found '%s'", buf_ptr(&target_type->name))); |
| 26709 | return ira->codegen->invalid_instruction; | 27635 | return ira->codegen->invalid_inst_gen; |
| 26710 | } | 27636 | } |
| 26711 | | 27637 | |
| 26712 | if (instr_is_comptime(target)) { | 27638 | if (instr_is_comptime(target)) { |
| 26713 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 27639 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 26714 | if (!val) | 27640 | if (!val) |
| 26715 | return ira->codegen->invalid_instruction; | 27641 | return ira->codegen->invalid_inst_gen; |
| 26716 | | 27642 | |
| 26717 | if (val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr && | 27643 | if (val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr && |
| 26718 | val->data.x_ptr.data.hard_coded_addr.addr % align_bytes != 0) | 27644 | val->data.x_ptr.data.hard_coded_addr.addr % align_bytes != 0) |
| 26719 | { | 27645 | { |
| 26720 | ir_add_error(ira, target, | 27646 | ir_add_error(ira, &target->base, |
| 26721 | buf_sprintf("pointer address 0x%" ZIG_PRI_x64 " is not aligned to %" PRIu32 " bytes", | 27647 | buf_sprintf("pointer address 0x%" ZIG_PRI_x64 " is not aligned to %" PRIu32 " bytes", |
| 26722 | val->data.x_ptr.data.hard_coded_addr.addr, align_bytes)); | 27648 | val->data.x_ptr.data.hard_coded_addr.addr, align_bytes)); |
| 26723 | return ira->codegen->invalid_instruction; | 27649 | return ira->codegen->invalid_inst_gen; |
| 26724 | } | 27650 | } |
| 26725 | | 27651 | |
| 26726 | IrInstruction *result = ir_const(ira, target, result_type); | 27652 | IrInstGen *result = ir_const(ira, &target->base, result_type); |
| 26727 | copy_const_val(result->value, val); | 27653 | copy_const_val(result->value, val); |
| 26728 | result->value->type = result_type; | 27654 | result->value->type = result_type; |
| 26729 | return result; | 27655 | return result; |
| 26730 | } | 27656 | } |
| 26731 | | 27657 | |
| 26732 | IrInstruction *result; | | |
| 26733 | if (safety_check_on && align_bytes > old_align_bytes && align_bytes != 1) { | 27658 | if (safety_check_on && align_bytes > old_align_bytes && align_bytes != 1) { |
| 26734 | result = ir_build_align_cast(&ira->new_irb, target->scope, target->source_node, nullptr, target); | 27659 | return ir_build_align_cast_gen(ira, target->base.scope, target->base.source_node, target, result_type); |
| 26735 | } else { | 27660 | } else { |
| 26736 | result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, result_type, target, CastOpNoop); | 27661 | return ir_build_cast(ira, &target->base, result_type, target, CastOpNoop); |
| 26737 | } | 27662 | } |
| 26738 | result->value->type = result_type; | | |
| 26739 | return result; | | |
| 26740 | } | 27663 | } |
| 26741 | | 27664 | |
| 26742 | static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *ptr, | 27665 | static IrInstGen *ir_analyze_ptr_cast(IrAnalyze *ira, IrInst* source_instr, IrInstGen *ptr, |
| 26743 | ZigType *dest_type, IrInstruction *dest_type_src, bool safety_check_on) | 27666 | ZigType *dest_type, IrInst *dest_type_src, bool safety_check_on) |
| 26744 | { | 27667 | { |
| 26745 | Error err; | 27668 | Error err; |
| 26746 | | 27669 | |
| ... | @@ -26756,44 +27679,44 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -26756,44 +27679,44 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 26756 | | 27679 | |
| 26757 | ZigType *src_ptr_type = get_src_ptr_type(src_type); | 27680 | ZigType *src_ptr_type = get_src_ptr_type(src_type); |
| 26758 | if (src_ptr_type == nullptr) { | 27681 | if (src_ptr_type == nullptr) { |
| 26759 | ir_add_error(ira, ptr, buf_sprintf("expected pointer, found '%s'", buf_ptr(&src_type->name))); | 27682 | ir_add_error(ira, &ptr->base, buf_sprintf("expected pointer, found '%s'", buf_ptr(&src_type->name))); |
| 26760 | return ira->codegen->invalid_instruction; | 27683 | return ira->codegen->invalid_inst_gen; |
| 26761 | } | 27684 | } |
| 26762 | | 27685 | |
| 26763 | ZigType *dest_ptr_type = get_src_ptr_type(dest_type); | 27686 | ZigType *dest_ptr_type = get_src_ptr_type(dest_type); |
| 26764 | if (dest_ptr_type == nullptr) { | 27687 | if (dest_ptr_type == nullptr) { |
| 26765 | ir_add_error(ira, dest_type_src, | 27688 | ir_add_error(ira, dest_type_src, |
| 26766 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&dest_type->name))); | 27689 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&dest_type->name))); |
| 26767 | return ira->codegen->invalid_instruction; | 27690 | return ira->codegen->invalid_inst_gen; |
| 26768 | } | 27691 | } |
| 26769 | | 27692 | |
| 26770 | if (get_ptr_const(src_type) && !get_ptr_const(dest_type)) { | 27693 | if (get_ptr_const(src_type) && !get_ptr_const(dest_type)) { |
| 26771 | ir_add_error(ira, source_instr, buf_sprintf("cast discards const qualifier")); | 27694 | ir_add_error(ira, source_instr, buf_sprintf("cast discards const qualifier")); |
| 26772 | return ira->codegen->invalid_instruction; | 27695 | return ira->codegen->invalid_inst_gen; |
| 26773 | } | 27696 | } |
| 26774 | uint32_t src_align_bytes; | 27697 | uint32_t src_align_bytes; |
| 26775 | if ((err = resolve_ptr_align(ira, src_type, &src_align_bytes))) | 27698 | if ((err = resolve_ptr_align(ira, src_type, &src_align_bytes))) |
| 26776 | return ira->codegen->invalid_instruction; | 27699 | return ira->codegen->invalid_inst_gen; |
| 26777 | | 27700 | |
| 26778 | uint32_t dest_align_bytes; | 27701 | uint32_t dest_align_bytes; |
| 26779 | if ((err = resolve_ptr_align(ira, dest_type, &dest_align_bytes))) | 27702 | if ((err = resolve_ptr_align(ira, dest_type, &dest_align_bytes))) |
| 26780 | return ira->codegen->invalid_instruction; | 27703 | return ira->codegen->invalid_inst_gen; |
| 26781 | | 27704 | |
| 26782 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) | 27705 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) |
| 26783 | return ira->codegen->invalid_instruction; | 27706 | return ira->codegen->invalid_inst_gen; |
| 26784 | | 27707 | |
| 26785 | if ((err = type_resolve(ira->codegen, src_type, ResolveStatusZeroBitsKnown))) | 27708 | if ((err = type_resolve(ira->codegen, src_type, ResolveStatusZeroBitsKnown))) |
| 26786 | return ira->codegen->invalid_instruction; | 27709 | return ira->codegen->invalid_inst_gen; |
| 26787 | | 27710 | |
| 26788 | if (type_has_bits(dest_type) && !type_has_bits(src_type)) { | 27711 | if (type_has_bits(dest_type) && !type_has_bits(src_type)) { |
| 26789 | ErrorMsg *msg = ir_add_error(ira, source_instr, | 27712 | ErrorMsg *msg = ir_add_error(ira, source_instr, |
| 26790 | buf_sprintf("'%s' and '%s' do not have the same in-memory representation", | 27713 | buf_sprintf("'%s' and '%s' do not have the same in-memory representation", |
| 26791 | buf_ptr(&src_type->name), buf_ptr(&dest_type->name))); | 27714 | buf_ptr(&src_type->name), buf_ptr(&dest_type->name))); |
| 26792 | add_error_note(ira->codegen, msg, ptr->source_node, | 27715 | add_error_note(ira->codegen, msg, ptr->base.source_node, |
| 26793 | buf_sprintf("'%s' has no in-memory bits", buf_ptr(&src_type->name))); | 27716 | buf_sprintf("'%s' has no in-memory bits", buf_ptr(&src_type->name))); |
| 26794 | add_error_note(ira->codegen, msg, dest_type_src->source_node, | 27717 | add_error_note(ira->codegen, msg, dest_type_src->source_node, |
| 26795 | buf_sprintf("'%s' has in-memory bits", buf_ptr(&dest_type->name))); | 27718 | buf_sprintf("'%s' has in-memory bits", buf_ptr(&dest_type->name))); |
| 26796 | return ira->codegen->invalid_instruction; | 27719 | return ira->codegen->invalid_inst_gen; |
| 26797 | } | 27720 | } |
| 26798 | | 27721 | |
| 26799 | if (instr_is_comptime(ptr)) { | 27722 | if (instr_is_comptime(ptr)) { |
| ... | @@ -26801,7 +27724,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -26801,7 +27724,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 26801 | UndefAllowed is_undef_allowed = dest_allows_addr_zero ? UndefOk : UndefBad; | 27724 | UndefAllowed is_undef_allowed = dest_allows_addr_zero ? UndefOk : UndefBad; |
| 26802 | ZigValue *val = ir_resolve_const(ira, ptr, is_undef_allowed); | 27725 | ZigValue *val = ir_resolve_const(ira, ptr, is_undef_allowed); |
| 26803 | if (!val) | 27726 | if (!val) |
| 26804 | return ira->codegen->invalid_instruction; | 27727 | return ira->codegen->invalid_inst_gen; |
| 26805 | | 27728 | |
| 26806 | if (value_is_comptime(val) && val->special != ConstValSpecialUndef) { | 27729 | if (value_is_comptime(val) && val->special != ConstValSpecialUndef) { |
| 26807 | bool is_addr_zero = val->data.x_ptr.special == ConstPtrSpecialNull || | 27730 | bool is_addr_zero = val->data.x_ptr.special == ConstPtrSpecialNull || |
| ... | @@ -26810,16 +27733,16 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -26810,16 +27733,16 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 26810 | if (is_addr_zero && !dest_allows_addr_zero) { | 27733 | if (is_addr_zero && !dest_allows_addr_zero) { |
| 26811 | ir_add_error(ira, source_instr, | 27734 | ir_add_error(ira, source_instr, |
| 26812 | buf_sprintf("null pointer casted to type '%s'", buf_ptr(&dest_type->name))); | 27735 | buf_sprintf("null pointer casted to type '%s'", buf_ptr(&dest_type->name))); |
| 26813 | return ira->codegen->invalid_instruction; | 27736 | return ira->codegen->invalid_inst_gen; |
| 26814 | } | 27737 | } |
| 26815 | } | 27738 | } |
| 26816 | | 27739 | |
| 26817 | IrInstruction *result; | 27740 | IrInstGen *result; |
| 26818 | if (ptr->value->data.x_ptr.mut == ConstPtrMutInfer) { | 27741 | if (ptr->value->data.x_ptr.mut == ConstPtrMutInfer) { |
| 26819 | result = ir_build_ptr_cast_gen(ira, source_instr, dest_type, ptr, safety_check_on); | 27742 | result = ir_build_ptr_cast_gen(ira, source_instr, dest_type, ptr, safety_check_on); |
| 26820 | | 27743 | |
| 26821 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) | 27744 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) |
| 26822 | return ira->codegen->invalid_instruction; | 27745 | return ira->codegen->invalid_inst_gen; |
| 26823 | } else { | 27746 | } else { |
| 26824 | result = ir_const(ira, source_instr, dest_type); | 27747 | result = ir_const(ira, source_instr, dest_type); |
| 26825 | } | 27748 | } |
| ... | @@ -26837,40 +27760,40 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -26837,40 +27760,40 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 26837 | | 27760 | |
| 26838 | if (dest_align_bytes > src_align_bytes) { | 27761 | if (dest_align_bytes > src_align_bytes) { |
| 26839 | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("cast increases pointer alignment")); | 27762 | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("cast increases pointer alignment")); |
| 26840 | add_error_note(ira->codegen, msg, ptr->source_node, | 27763 | add_error_note(ira->codegen, msg, ptr->base.source_node, |
| 26841 | buf_sprintf("'%s' has alignment %" PRIu32, buf_ptr(&src_type->name), src_align_bytes)); | 27764 | buf_sprintf("'%s' has alignment %" PRIu32, buf_ptr(&src_type->name), src_align_bytes)); |
| 26842 | add_error_note(ira->codegen, msg, dest_type_src->source_node, | 27765 | add_error_note(ira->codegen, msg, dest_type_src->source_node, |
| 26843 | buf_sprintf("'%s' has alignment %" PRIu32, buf_ptr(&dest_type->name), dest_align_bytes)); | 27766 | buf_sprintf("'%s' has alignment %" PRIu32, buf_ptr(&dest_type->name), dest_align_bytes)); |
| 26844 | return ira->codegen->invalid_instruction; | 27767 | return ira->codegen->invalid_inst_gen; |
| 26845 | } | 27768 | } |
| 26846 | | 27769 | |
| 26847 | IrInstruction *casted_ptr = ir_build_ptr_cast_gen(ira, source_instr, dest_type, ptr, safety_check_on); | 27770 | IrInstGen *casted_ptr = ir_build_ptr_cast_gen(ira, source_instr, dest_type, ptr, safety_check_on); |
| 26848 | | 27771 | |
| 26849 | // Keep the bigger alignment, it can only help- | 27772 | // Keep the bigger alignment, it can only help- |
| 26850 | // unless the target is zero bits. | 27773 | // unless the target is zero bits. |
| 26851 | IrInstruction *result; | 27774 | IrInstGen *result; |
| 26852 | if (src_align_bytes > dest_align_bytes && type_has_bits(dest_type)) { | 27775 | if (src_align_bytes > dest_align_bytes && type_has_bits(dest_type)) { |
| 26853 | result = ir_align_cast(ira, casted_ptr, src_align_bytes, false); | 27776 | result = ir_align_cast(ira, casted_ptr, src_align_bytes, false); |
| 26854 | if (type_is_invalid(result->value->type)) | 27777 | if (type_is_invalid(result->value->type)) |
| 26855 | return ira->codegen->invalid_instruction; | 27778 | return ira->codegen->invalid_inst_gen; |
| 26856 | } else { | 27779 | } else { |
| 26857 | result = casted_ptr; | 27780 | result = casted_ptr; |
| 26858 | } | 27781 | } |
| 26859 | return result; | 27782 | return result; |
| 26860 | } | 27783 | } |
| 26861 | | 27784 | |
| 26862 | static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstructionPtrCastSrc *instruction) { | 27785 | static IrInstGen *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstSrcPtrCast *instruction) { |
| 26863 | IrInstruction *dest_type_value = instruction->dest_type->child; | 27786 | IrInstGen *dest_type_value = instruction->dest_type->child; |
| 26864 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); | 27787 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); |
| 26865 | if (type_is_invalid(dest_type)) | 27788 | if (type_is_invalid(dest_type)) |
| 26866 | return ira->codegen->invalid_instruction; | 27789 | return ira->codegen->invalid_inst_gen; |
| 26867 | | 27790 | |
| 26868 | IrInstruction *ptr = instruction->ptr->child; | 27791 | IrInstGen *ptr = instruction->ptr->child; |
| 26869 | ZigType *src_type = ptr->value->type; | 27792 | ZigType *src_type = ptr->value->type; |
| 26870 | if (type_is_invalid(src_type)) | 27793 | if (type_is_invalid(src_type)) |
| 26871 | return ira->codegen->invalid_instruction; | 27794 | return ira->codegen->invalid_inst_gen; |
| 26872 | | 27795 | |
| 26873 | return ir_analyze_ptr_cast(ira, &instruction->base, ptr, dest_type, dest_type_value, | 27796 | return ir_analyze_ptr_cast(ira, &instruction->base.base, ptr, dest_type, &dest_type_value->base, |
| 26874 | instruction->safety_check_on); | 27797 | instruction->safety_check_on); |
| 26875 | } | 27798 | } |
| 26876 | | 27799 | |
| ... | @@ -27201,7 +28124,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou | ... | @@ -27201,7 +28124,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 27201 | zig_unreachable(); | 28124 | zig_unreachable(); |
| 27202 | } | 28125 | } |
| 27203 | | 28126 | |
| 27204 | static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 28127 | static IrInstGen *ir_analyze_bit_cast(IrAnalyze *ira, IrInst* source_instr, IrInstGen *value, |
| 27205 | ZigType *dest_type) | 28128 | ZigType *dest_type) |
| 27206 | { | 28129 | { |
| 27207 | Error err; | 28130 | Error err; |
| ... | @@ -27217,14 +28140,14 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -27217,14 +28140,14 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 27217 | buf_sprintf("cannot cast a value of type '%s'", buf_ptr(&dest_type->name))); | 28140 | buf_sprintf("cannot cast a value of type '%s'", buf_ptr(&dest_type->name))); |
| 27218 | add_error_note(ira->codegen, msg, source_instr->source_node, | 28141 | add_error_note(ira->codegen, msg, source_instr->source_node, |
| 27219 | buf_sprintf("use @intToEnum for type coercion")); | 28142 | buf_sprintf("use @intToEnum for type coercion")); |
| 27220 | return ira->codegen->invalid_instruction; | 28143 | return ira->codegen->invalid_inst_gen; |
| 27221 | } | 28144 | } |
| 27222 | | 28145 | |
| 27223 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusSizeKnown))) | 28146 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusSizeKnown))) |
| 27224 | return ira->codegen->invalid_instruction; | 28147 | return ira->codegen->invalid_inst_gen; |
| 27225 | | 28148 | |
| 27226 | if ((err = type_resolve(ira->codegen, src_type, ResolveStatusSizeKnown))) | 28149 | if ((err = type_resolve(ira->codegen, src_type, ResolveStatusSizeKnown))) |
| 27227 | return ira->codegen->invalid_instruction; | 28150 | return ira->codegen->invalid_inst_gen; |
| 27228 | | 28151 | |
| 27229 | uint64_t dest_size_bytes = type_size(ira->codegen, dest_type); | 28152 | uint64_t dest_size_bytes = type_size(ira->codegen, dest_type); |
| 27230 | uint64_t src_size_bytes = type_size(ira->codegen, src_type); | 28153 | uint64_t src_size_bytes = type_size(ira->codegen, src_type); |
| ... | @@ -27233,7 +28156,7 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -27233,7 +28156,7 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 27233 | buf_sprintf("destination type '%s' has size %" ZIG_PRI_u64 " but source type '%s' has size %" ZIG_PRI_u64, | 28156 | buf_sprintf("destination type '%s' has size %" ZIG_PRI_u64 " but source type '%s' has size %" ZIG_PRI_u64, |
| 27234 | buf_ptr(&dest_type->name), dest_size_bytes, | 28157 | buf_ptr(&dest_type->name), dest_size_bytes, |
| 27235 | buf_ptr(&src_type->name), src_size_bytes)); | 28158 | buf_ptr(&src_type->name), src_size_bytes)); |
| 27236 | return ira->codegen->invalid_instruction; | 28159 | return ira->codegen->invalid_inst_gen; |
| 27237 | } | 28160 | } |
| 27238 | | 28161 | |
| 27239 | uint64_t dest_size_bits = type_size_bits(ira->codegen, dest_type); | 28162 | uint64_t dest_size_bits = type_size_bits(ira->codegen, dest_type); |
| ... | @@ -27243,26 +28166,26 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -27243,26 +28166,26 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 27243 | buf_sprintf("destination type '%s' has %" ZIG_PRI_u64 " bits but source type '%s' has %" ZIG_PRI_u64 " bits", | 28166 | buf_sprintf("destination type '%s' has %" ZIG_PRI_u64 " bits but source type '%s' has %" ZIG_PRI_u64 " bits", |
| 27244 | buf_ptr(&dest_type->name), dest_size_bits, | 28167 | buf_ptr(&dest_type->name), dest_size_bits, |
| 27245 | buf_ptr(&src_type->name), src_size_bits)); | 28168 | buf_ptr(&src_type->name), src_size_bits)); |
| 27246 | return ira->codegen->invalid_instruction; | 28169 | return ira->codegen->invalid_inst_gen; |
| 27247 | } | 28170 | } |
| 27248 | | 28171 | |
| 27249 | if (instr_is_comptime(value)) { | 28172 | if (instr_is_comptime(value)) { |
| 27250 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); | 28173 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 27251 | if (!val) | 28174 | if (!val) |
| 27252 | return ira->codegen->invalid_instruction; | 28175 | return ira->codegen->invalid_inst_gen; |
| 27253 | | 28176 | |
| 27254 | IrInstruction *result = ir_const(ira, source_instr, dest_type); | 28177 | IrInstGen *result = ir_const(ira, source_instr, dest_type); |
| 27255 | uint8_t *buf = allocate_nonzero<uint8_t>(src_size_bytes); | 28178 | uint8_t *buf = allocate_nonzero<uint8_t>(src_size_bytes); |
| 27256 | buf_write_value_bytes(ira->codegen, buf, val); | 28179 | buf_write_value_bytes(ira->codegen, buf, val); |
| 27257 | if ((err = buf_read_value_bytes(ira, ira->codegen, source_instr->source_node, buf, result->value))) | 28180 | if ((err = buf_read_value_bytes(ira, ira->codegen, source_instr->source_node, buf, result->value))) |
| 27258 | return ira->codegen->invalid_instruction; | 28181 | return ira->codegen->invalid_inst_gen; |
| 27259 | return result; | 28182 | return result; |
| 27260 | } | 28183 | } |
| 27261 | | 28184 | |
| 27262 | return ir_build_bit_cast_gen(ira, source_instr, value, dest_type); | 28185 | return ir_build_bit_cast_gen(ira, source_instr, value, dest_type); |
| 27263 | } | 28186 | } |
| 27264 | | 28187 | |
| 27265 | static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, | 28188 | static IrInstGen *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInst* source_instr, IrInstGen *target, |
| 27266 | ZigType *ptr_type) | 28189 | ZigType *ptr_type) |
| 27267 | { | 28190 | { |
| 27268 | Error err; | 28191 | Error err; |
| ... | @@ -27270,136 +28193,128 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -27270,136 +28193,128 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc |
| 27270 | ir_assert(get_src_ptr_type(ptr_type) != nullptr, source_instr); | 28193 | ir_assert(get_src_ptr_type(ptr_type) != nullptr, source_instr); |
| 27271 | ir_assert(type_has_bits(ptr_type), source_instr); | 28194 | ir_assert(type_has_bits(ptr_type), source_instr); |
| 27272 | | 28195 | |
| 27273 | IrInstruction *casted_int = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_usize); | 28196 | IrInstGen *casted_int = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_usize); |
| 27274 | if (type_is_invalid(casted_int->value->type)) | 28197 | if (type_is_invalid(casted_int->value->type)) |
| 27275 | return ira->codegen->invalid_instruction; | 28198 | return ira->codegen->invalid_inst_gen; |
| 27276 | | 28199 | |
| 27277 | if (instr_is_comptime(casted_int)) { | 28200 | if (instr_is_comptime(casted_int)) { |
| 27278 | ZigValue *val = ir_resolve_const(ira, casted_int, UndefBad); | 28201 | ZigValue *val = ir_resolve_const(ira, casted_int, UndefBad); |
| 27279 | if (!val) | 28202 | if (!val) |
| 27280 | return ira->codegen->invalid_instruction; | 28203 | return ira->codegen->invalid_inst_gen; |
| 27281 | | 28204 | |
| 27282 | uint64_t addr = bigint_as_u64(&val->data.x_bigint); | 28205 | uint64_t addr = bigint_as_u64(&val->data.x_bigint); |
| 27283 | if (!ptr_allows_addr_zero(ptr_type) && addr == 0) { | 28206 | if (!ptr_allows_addr_zero(ptr_type) && addr == 0) { |
| 27284 | ir_add_error(ira, source_instr, | 28207 | ir_add_error(ira, source_instr, |
| 27285 | buf_sprintf("pointer type '%s' does not allow address zero", buf_ptr(&ptr_type->name))); | 28208 | buf_sprintf("pointer type '%s' does not allow address zero", buf_ptr(&ptr_type->name))); |
| 27286 | return ira->codegen->invalid_instruction; | 28209 | return ira->codegen->invalid_inst_gen; |
| 27287 | } | 28210 | } |
| 27288 | | 28211 | |
| 27289 | uint32_t align_bytes; | 28212 | uint32_t align_bytes; |
| 27290 | if ((err = resolve_ptr_align(ira, ptr_type, &align_bytes))) | 28213 | if ((err = resolve_ptr_align(ira, ptr_type, &align_bytes))) |
| 27291 | return ira->codegen->invalid_instruction; | 28214 | return ira->codegen->invalid_inst_gen; |
| 27292 | | 28215 | |
| 27293 | if (addr != 0 && addr % align_bytes != 0) { | 28216 | if (addr != 0 && addr % align_bytes != 0) { |
| 27294 | ir_add_error(ira, source_instr, | 28217 | ir_add_error(ira, source_instr, |
| 27295 | buf_sprintf("pointer type '%s' requires aligned address", | 28218 | buf_sprintf("pointer type '%s' requires aligned address", |
| 27296 | buf_ptr(&ptr_type->name))); | 28219 | buf_ptr(&ptr_type->name))); |
| 27297 | return ira->codegen->invalid_instruction; | 28220 | return ira->codegen->invalid_inst_gen; |
| 27298 | } | 28221 | } |
| 27299 | | 28222 | |
| 27300 | IrInstruction *result = ir_const(ira, source_instr, ptr_type); | 28223 | IrInstGen *result = ir_const(ira, source_instr, ptr_type); |
| 27301 | result->value->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; | 28224 | result->value->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; |
| 27302 | result->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; | 28225 | result->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; |
| 27303 | result->value->data.x_ptr.data.hard_coded_addr.addr = addr; | 28226 | result->value->data.x_ptr.data.hard_coded_addr.addr = addr; |
| 27304 | return result; | 28227 | return result; |
| 27305 | } | 28228 | } |
| 27306 | | 28229 | |
| 27307 | IrInstruction *result = ir_build_int_to_ptr(&ira->new_irb, source_instr->scope, | 28230 | return ir_build_int_to_ptr_gen(ira, source_instr->scope, source_instr->source_node, casted_int, ptr_type); |
| 27308 | source_instr->source_node, nullptr, casted_int); | | |
| 27309 | result->value->type = ptr_type; | | |
| 27310 | return result; | | |
| 27311 | } | 28231 | } |
| 27312 | | 28232 | |
| 27313 | static IrInstruction *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstructionIntToPtr *instruction) { | 28233 | static IrInstGen *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstSrcIntToPtr *instruction) { |
| 27314 | Error err; | 28234 | Error err; |
| 27315 | IrInstruction *dest_type_value = instruction->dest_type->child; | 28235 | IrInstGen *dest_type_value = instruction->dest_type->child; |
| 27316 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); | 28236 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); |
| 27317 | if (type_is_invalid(dest_type)) | 28237 | if (type_is_invalid(dest_type)) |
| 27318 | return ira->codegen->invalid_instruction; | 28238 | return ira->codegen->invalid_inst_gen; |
| 27319 | | 28239 | |
| 27320 | // We explicitly check for the size, so we can use get_src_ptr_type | 28240 | // We explicitly check for the size, so we can use get_src_ptr_type |
| 27321 | if (get_src_ptr_type(dest_type) == nullptr) { | 28241 | if (get_src_ptr_type(dest_type) == nullptr) { |
| 27322 | ir_add_error(ira, dest_type_value, buf_sprintf("expected pointer, found '%s'", buf_ptr(&dest_type->name))); | 28242 | ir_add_error(ira, &dest_type_value->base, buf_sprintf("expected pointer, found '%s'", buf_ptr(&dest_type->name))); |
| 27323 | return ira->codegen->invalid_instruction; | 28243 | return ira->codegen->invalid_inst_gen; |
| 27324 | } | 28244 | } |
| 27325 | | 28245 | |
| 27326 | bool has_bits; | 28246 | bool has_bits; |
| 27327 | if ((err = type_has_bits2(ira->codegen, dest_type, &has_bits))) | 28247 | if ((err = type_has_bits2(ira->codegen, dest_type, &has_bits))) |
| 27328 | return ira->codegen->invalid_instruction; | 28248 | return ira->codegen->invalid_inst_gen; |
| 27329 | | 28249 | |
| 27330 | if (!has_bits) { | 28250 | if (!has_bits) { |
| 27331 | ir_add_error(ira, dest_type_value, | 28251 | ir_add_error(ira, &dest_type_value->base, |
| 27332 | buf_sprintf("type '%s' has 0 bits and cannot store information", buf_ptr(&dest_type->name))); | 28252 | buf_sprintf("type '%s' has 0 bits and cannot store information", buf_ptr(&dest_type->name))); |
| 27333 | return ira->codegen->invalid_instruction; | 28253 | return ira->codegen->invalid_inst_gen; |
| 27334 | } | 28254 | } |
| 27335 | | 28255 | |
| 27336 | IrInstruction *target = instruction->target->child; | 28256 | IrInstGen *target = instruction->target->child; |
| 27337 | if (type_is_invalid(target->value->type)) | 28257 | if (type_is_invalid(target->value->type)) |
| 27338 | return ira->codegen->invalid_instruction; | 28258 | return ira->codegen->invalid_inst_gen; |
| 27339 | | 28259 | |
| 27340 | return ir_analyze_int_to_ptr(ira, &instruction->base, target, dest_type); | 28260 | return ir_analyze_int_to_ptr(ira, &instruction->base.base, target, dest_type); |
| 27341 | } | 28261 | } |
| 27342 | | 28262 | |
| 27343 | static IrInstruction *ir_analyze_instruction_decl_ref(IrAnalyze *ira, | 28263 | static IrInstGen *ir_analyze_instruction_decl_ref(IrAnalyze *ira, IrInstSrcDeclRef *instruction) { |
| 27344 | IrInstructionDeclRef *instruction) | 28264 | IrInstGen *ref_instruction = ir_analyze_decl_ref(ira, &instruction->base.base, instruction->tld); |
| 27345 | { | | |
| 27346 | IrInstruction *ref_instruction = ir_analyze_decl_ref(ira, &instruction->base, instruction->tld); | | |
| 27347 | if (type_is_invalid(ref_instruction->value->type)) { | 28265 | if (type_is_invalid(ref_instruction->value->type)) { |
| 27348 | return ira->codegen->invalid_instruction; | 28266 | return ira->codegen->invalid_inst_gen; |
| 27349 | } | 28267 | } |
| 27350 | | 28268 | |
| 27351 | if (instruction->lval == LValPtr) { | 28269 | if (instruction->lval == LValPtr) { |
| 27352 | return ref_instruction; | 28270 | return ref_instruction; |
| 27353 | } else { | 28271 | } else { |
| 27354 | return ir_get_deref(ira, &instruction->base, ref_instruction, nullptr); | 28272 | return ir_get_deref(ira, &instruction->base.base, ref_instruction, nullptr); |
| 27355 | } | 28273 | } |
| 27356 | } | 28274 | } |
| 27357 | | 28275 | |
| 27358 | static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstructionPtrToInt *instruction) { | 28276 | static IrInstGen *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstSrcPtrToInt *instruction) { |
| 27359 | Error err; | 28277 | Error err; |
| 27360 | IrInstruction *target = instruction->target->child; | 28278 | IrInstGen *target = instruction->target->child; |
| 27361 | if (type_is_invalid(target->value->type)) | 28279 | if (type_is_invalid(target->value->type)) |
| 27362 | return ira->codegen->invalid_instruction; | 28280 | return ira->codegen->invalid_inst_gen; |
| 27363 | | 28281 | |
| 27364 | ZigType *usize = ira->codegen->builtin_types.entry_usize; | 28282 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 27365 | | 28283 | |
| 27366 | // We check size explicitly so we can use get_src_ptr_type here. | 28284 | // We check size explicitly so we can use get_src_ptr_type here. |
| 27367 | if (get_src_ptr_type(target->value->type) == nullptr) { | 28285 | if (get_src_ptr_type(target->value->type) == nullptr) { |
| 27368 | ir_add_error(ira, target, | 28286 | ir_add_error(ira, &target->base, |
| 27369 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&target->value->type->name))); | 28287 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&target->value->type->name))); |
| 27370 | return ira->codegen->invalid_instruction; | 28288 | return ira->codegen->invalid_inst_gen; |
| 27371 | } | 28289 | } |
| 27372 | | 28290 | |
| 27373 | bool has_bits; | 28291 | bool has_bits; |
| 27374 | if ((err = type_has_bits2(ira->codegen, target->value->type, &has_bits))) | 28292 | if ((err = type_has_bits2(ira->codegen, target->value->type, &has_bits))) |
| 27375 | return ira->codegen->invalid_instruction; | 28293 | return ira->codegen->invalid_inst_gen; |
| 27376 | | 28294 | |
| 27377 | if (!has_bits) { | 28295 | if (!has_bits) { |
| 27378 | ir_add_error(ira, target, | 28296 | ir_add_error(ira, &target->base, |
| 27379 | buf_sprintf("pointer to size 0 type has no address")); | 28297 | buf_sprintf("pointer to size 0 type has no address")); |
| 27380 | return ira->codegen->invalid_instruction; | 28298 | return ira->codegen->invalid_inst_gen; |
| 27381 | } | 28299 | } |
| 27382 | | 28300 | |
| 27383 | if (instr_is_comptime(target)) { | 28301 | if (instr_is_comptime(target)) { |
| 27384 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 28302 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 27385 | if (!val) | 28303 | if (!val) |
| 27386 | return ira->codegen->invalid_instruction; | 28304 | return ira->codegen->invalid_inst_gen; |
| 27387 | if (val->type->id == ZigTypeIdPointer && val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { | 28305 | if (val->type->id == ZigTypeIdPointer && val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { |
| 27388 | IrInstruction *result = ir_const(ira, &instruction->base, usize); | 28306 | IrInstGen *result = ir_const(ira, &instruction->base.base, usize); |
| 27389 | bigint_init_unsigned(&result->value->data.x_bigint, val->data.x_ptr.data.hard_coded_addr.addr); | 28307 | bigint_init_unsigned(&result->value->data.x_bigint, val->data.x_ptr.data.hard_coded_addr.addr); |
| 27390 | result->value->type = usize; | 28308 | result->value->type = usize; |
| 27391 | return result; | 28309 | return result; |
| 27392 | } | 28310 | } |
| 27393 | } | 28311 | } |
| 27394 | | 28312 | |
| 27395 | IrInstruction *result = ir_build_ptr_to_int(&ira->new_irb, instruction->base.scope, | 28313 | return ir_build_ptr_to_int_gen(ira, &instruction->base.base, target); |
| 27396 | instruction->base.source_node, target); | | |
| 27397 | result->value->type = usize; | | |
| 27398 | return result; | | |
| 27399 | } | 28314 | } |
| 27400 | | 28315 | |
| 27401 | static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) { | 28316 | static IrInstGen *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstSrcPtrType *instruction) { |
| 27402 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); | 28317 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 27403 | result->value->special = ConstValSpecialLazy; | 28318 | result->value->special = ConstValSpecialLazy; |
| 27404 | | 28319 | |
| 27405 | LazyValuePtrType *lazy_ptr_type = allocate<LazyValuePtrType>(1, "LazyValuePtrType"); | 28320 | LazyValuePtrType *lazy_ptr_type = allocate<LazyValuePtrType>(1, "LazyValuePtrType"); |
| ... | @@ -27410,17 +28325,17 @@ static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruct | ... | @@ -27410,17 +28325,17 @@ static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruct |
| 27410 | if (instruction->sentinel != nullptr) { | 28325 | if (instruction->sentinel != nullptr) { |
| 27411 | lazy_ptr_type->sentinel = instruction->sentinel->child; | 28326 | lazy_ptr_type->sentinel = instruction->sentinel->child; |
| 27412 | if (ir_resolve_const(ira, lazy_ptr_type->sentinel, LazyOk) == nullptr) | 28327 | if (ir_resolve_const(ira, lazy_ptr_type->sentinel, LazyOk) == nullptr) |
| 27413 | return ira->codegen->invalid_instruction; | 28328 | return ira->codegen->invalid_inst_gen; |
| 27414 | } | 28329 | } |
| 27415 | | 28330 | |
| 27416 | lazy_ptr_type->elem_type = instruction->child_type->child; | 28331 | lazy_ptr_type->elem_type = instruction->child_type->child; |
| 27417 | if (ir_resolve_type_lazy(ira, lazy_ptr_type->elem_type) == nullptr) | 28332 | if (ir_resolve_type_lazy(ira, lazy_ptr_type->elem_type) == nullptr) |
| 27418 | return ira->codegen->invalid_instruction; | 28333 | return ira->codegen->invalid_inst_gen; |
| 27419 | | 28334 | |
| 27420 | if (instruction->align_value != nullptr) { | 28335 | if (instruction->align_value != nullptr) { |
| 27421 | lazy_ptr_type->align_inst = instruction->align_value->child; | 28336 | lazy_ptr_type->align_inst = instruction->align_value->child; |
| 27422 | if (ir_resolve_const(ira, lazy_ptr_type->align_inst, LazyOk) == nullptr) | 28337 | if (ir_resolve_const(ira, lazy_ptr_type->align_inst, LazyOk) == nullptr) |
| 27423 | return ira->codegen->invalid_instruction; | 28338 | return ira->codegen->invalid_inst_gen; |
| 27424 | } | 28339 | } |
| 27425 | | 28340 | |
| 27426 | lazy_ptr_type->ptr_len = instruction->ptr_len; | 28341 | lazy_ptr_type->ptr_len = instruction->ptr_len; |
| ... | @@ -27433,10 +28348,10 @@ static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruct | ... | @@ -27433,10 +28348,10 @@ static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruct |
| 27433 | return result; | 28348 | return result; |
| 27434 | } | 28349 | } |
| 27435 | | 28350 | |
| 27436 | static IrInstruction *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstructionAlignCast *instruction) { | 28351 | static IrInstGen *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstSrcAlignCast *instruction) { |
| 27437 | IrInstruction *target = instruction->target->child; | 28352 | IrInstGen *target = instruction->target->child; |
| 27438 | if (type_is_invalid(target->value->type)) | 28353 | if (type_is_invalid(target->value->type)) |
| 27439 | return ira->codegen->invalid_instruction; | 28354 | return ira->codegen->invalid_inst_gen; |
| 27440 | | 28355 | |
| 27441 | ZigType *elem_type = nullptr; | 28356 | ZigType *elem_type = nullptr; |
| 27442 | if (is_slice(target->value->type)) { | 28357 | if (is_slice(target->value->type)) { |
| ... | @@ -27447,192 +28362,192 @@ static IrInstruction *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstru | ... | @@ -27447,192 +28362,192 @@ static IrInstruction *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstru |
| 27447 | } | 28362 | } |
| 27448 | | 28363 | |
| 27449 | uint32_t align_bytes; | 28364 | uint32_t align_bytes; |
| 27450 | IrInstruction *align_bytes_inst = instruction->align_bytes->child; | 28365 | IrInstGen *align_bytes_inst = instruction->align_bytes->child; |
| 27451 | if (!ir_resolve_align(ira, align_bytes_inst, elem_type, &align_bytes)) | 28366 | if (!ir_resolve_align(ira, align_bytes_inst, elem_type, &align_bytes)) |
| 27452 | return ira->codegen->invalid_instruction; | 28367 | return ira->codegen->invalid_inst_gen; |
| 27453 | | 28368 | |
| 27454 | IrInstruction *result = ir_align_cast(ira, target, align_bytes, true); | 28369 | IrInstGen *result = ir_align_cast(ira, target, align_bytes, true); |
| 27455 | if (type_is_invalid(result->value->type)) | 28370 | if (type_is_invalid(result->value->type)) |
| 27456 | return ira->codegen->invalid_instruction; | 28371 | return ira->codegen->invalid_inst_gen; |
| 27457 | | 28372 | |
| 27458 | return result; | 28373 | return result; |
| 27459 | } | 28374 | } |
| 27460 | | 28375 | |
| 27461 | static IrInstruction *ir_analyze_instruction_opaque_type(IrAnalyze *ira, IrInstructionOpaqueType *instruction) { | 28376 | static IrInstGen *ir_analyze_instruction_opaque_type(IrAnalyze *ira, IrInstSrcOpaqueType *instruction) { |
| 27462 | Buf *bare_name = buf_alloc(); | 28377 | Buf *bare_name = buf_alloc(); |
| 27463 | Buf *full_name = get_anon_type_name(ira->codegen, ira->new_irb.exec, "opaque", | 28378 | Buf *full_name = get_anon_type_name(ira->codegen, ira->old_irb.exec, "opaque", |
| 27464 | instruction->base.scope, instruction->base.source_node, bare_name); | 28379 | instruction->base.base.scope, instruction->base.base.source_node, bare_name); |
| 27465 | ZigType *result_type = get_opaque_type(ira->codegen, instruction->base.scope, instruction->base.source_node, | 28380 | ZigType *result_type = get_opaque_type(ira->codegen, instruction->base.base.scope, |
| 27466 | buf_ptr(full_name), bare_name); | 28381 | instruction->base.base.source_node, buf_ptr(full_name), bare_name); |
| 27467 | return ir_const_type(ira, &instruction->base, result_type); | 28382 | return ir_const_type(ira, &instruction->base.base, result_type); |
| 27468 | } | 28383 | } |
| 27469 | | 28384 | |
| 27470 | static IrInstruction *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstructionSetAlignStack *instruction) { | 28385 | static IrInstGen *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstSrcSetAlignStack *instruction) { |
| 27471 | uint32_t align_bytes; | 28386 | uint32_t align_bytes; |
| 27472 | IrInstruction *align_bytes_inst = instruction->align_bytes->child; | 28387 | IrInstGen *align_bytes_inst = instruction->align_bytes->child; |
| 27473 | if (!ir_resolve_align(ira, align_bytes_inst, nullptr, &align_bytes)) | 28388 | if (!ir_resolve_align(ira, align_bytes_inst, nullptr, &align_bytes)) |
| 27474 | return ira->codegen->invalid_instruction; | 28389 | return ira->codegen->invalid_inst_gen; |
| 27475 | | 28390 | |
| 27476 | if (align_bytes > 256) { | 28391 | if (align_bytes > 256) { |
| 27477 | ir_add_error(ira, &instruction->base, buf_sprintf("attempt to @setAlignStack(%" PRIu32 "); maximum is 256", align_bytes)); | 28392 | ir_add_error(ira, &instruction->base.base, buf_sprintf("attempt to @setAlignStack(%" PRIu32 "); maximum is 256", align_bytes)); |
| 27478 | return ira->codegen->invalid_instruction; | 28393 | return ira->codegen->invalid_inst_gen; |
| 27479 | } | 28394 | } |
| 27480 | | 28395 | |
| 27481 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 28396 | ZigFn *fn_entry = ira->new_irb.exec->fn_entry; |
| 27482 | if (fn_entry == nullptr) { | 28397 | if (fn_entry == nullptr) { |
| 27483 | ir_add_error(ira, &instruction->base, buf_sprintf("@setAlignStack outside function")); | 28398 | ir_add_error(ira, &instruction->base.base, buf_sprintf("@setAlignStack outside function")); |
| 27484 | return ira->codegen->invalid_instruction; | 28399 | return ira->codegen->invalid_inst_gen; |
| 27485 | } | 28400 | } |
| 27486 | if (fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionNaked) { | 28401 | if (fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionNaked) { |
| 27487 | ir_add_error(ira, &instruction->base, buf_sprintf("@setAlignStack in naked function")); | 28402 | ir_add_error(ira, &instruction->base.base, buf_sprintf("@setAlignStack in naked function")); |
| 27488 | return ira->codegen->invalid_instruction; | 28403 | return ira->codegen->invalid_inst_gen; |
| 27489 | } | 28404 | } |
| 27490 | | 28405 | |
| 27491 | if (fn_entry->fn_inline == FnInlineAlways) { | 28406 | if (fn_entry->fn_inline == FnInlineAlways) { |
| 27492 | ir_add_error(ira, &instruction->base, buf_sprintf("@setAlignStack in inline function")); | 28407 | ir_add_error(ira, &instruction->base.base, buf_sprintf("@setAlignStack in inline function")); |
| 27493 | return ira->codegen->invalid_instruction; | 28408 | return ira->codegen->invalid_inst_gen; |
| 27494 | } | 28409 | } |
| 27495 | | 28410 | |
| 27496 | if (fn_entry->set_alignstack_node != nullptr) { | 28411 | if (fn_entry->set_alignstack_node != nullptr) { |
| 27497 | ErrorMsg *msg = ir_add_error_node(ira, instruction->base.source_node, | 28412 | ErrorMsg *msg = ir_add_error(ira, &instruction->base.base, |
| 27498 | buf_sprintf("alignstack set twice")); | 28413 | buf_sprintf("alignstack set twice")); |
| 27499 | add_error_note(ira->codegen, msg, fn_entry->set_alignstack_node, buf_sprintf("first set here")); | 28414 | add_error_note(ira->codegen, msg, fn_entry->set_alignstack_node, buf_sprintf("first set here")); |
| 27500 | return ira->codegen->invalid_instruction; | 28415 | return ira->codegen->invalid_inst_gen; |
| 27501 | } | 28416 | } |
| 27502 | | 28417 | |
| 27503 | fn_entry->set_alignstack_node = instruction->base.source_node; | 28418 | fn_entry->set_alignstack_node = instruction->base.base.source_node; |
| 27504 | fn_entry->alignstack_value = align_bytes; | 28419 | fn_entry->alignstack_value = align_bytes; |
| 27505 | | 28420 | |
| 27506 | return ir_const_void(ira, &instruction->base); | 28421 | return ir_const_void(ira, &instruction->base.base); |
| 27507 | } | 28422 | } |
| 27508 | | 28423 | |
| 27509 | static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstructionArgType *instruction) { | 28424 | static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgType *instruction) { |
| 27510 | IrInstruction *fn_type_inst = instruction->fn_type->child; | 28425 | IrInstGen *fn_type_inst = instruction->fn_type->child; |
| 27511 | ZigType *fn_type = ir_resolve_type(ira, fn_type_inst); | 28426 | ZigType *fn_type = ir_resolve_type(ira, fn_type_inst); |
| 27512 | if (type_is_invalid(fn_type)) | 28427 | if (type_is_invalid(fn_type)) |
| 27513 | return ira->codegen->invalid_instruction; | 28428 | return ira->codegen->invalid_inst_gen; |
| 27514 | | 28429 | |
| 27515 | IrInstruction *arg_index_inst = instruction->arg_index->child; | 28430 | IrInstGen *arg_index_inst = instruction->arg_index->child; |
| 27516 | uint64_t arg_index; | 28431 | uint64_t arg_index; |
| 27517 | if (!ir_resolve_usize(ira, arg_index_inst, &arg_index)) | 28432 | if (!ir_resolve_usize(ira, arg_index_inst, &arg_index)) |
| 27518 | return ira->codegen->invalid_instruction; | 28433 | return ira->codegen->invalid_inst_gen; |
| 27519 | | 28434 | |
| 27520 | if (fn_type->id == ZigTypeIdBoundFn) { | 28435 | if (fn_type->id == ZigTypeIdBoundFn) { |
| 27521 | fn_type = fn_type->data.bound_fn.fn_type; | 28436 | fn_type = fn_type->data.bound_fn.fn_type; |
| 27522 | arg_index += 1; | 28437 | arg_index += 1; |
| 27523 | } | 28438 | } |
| 27524 | if (fn_type->id != ZigTypeIdFn) { | 28439 | if (fn_type->id != ZigTypeIdFn) { |
| 27525 | ir_add_error(ira, fn_type_inst, buf_sprintf("expected function, found '%s'", buf_ptr(&fn_type->name))); | 28440 | ir_add_error(ira, &fn_type_inst->base, buf_sprintf("expected function, found '%s'", buf_ptr(&fn_type->name))); |
| 27526 | return ira->codegen->invalid_instruction; | 28441 | return ira->codegen->invalid_inst_gen; |
| 27527 | } | 28442 | } |
| 27528 | | 28443 | |
| 27529 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; | 28444 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; |
| 27530 | if (arg_index >= fn_type_id->param_count) { | 28445 | if (arg_index >= fn_type_id->param_count) { |
| 27531 | if (instruction->allow_var) { | 28446 | if (instruction->allow_var) { |
| 27532 | // TODO remove this with var args | 28447 | // TODO remove this with var args |
| 27533 | return ir_const_type(ira, &instruction->base, ira->codegen->builtin_types.entry_var); | 28448 | return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_var); |
| 27534 | } | 28449 | } |
| 27535 | ir_add_error(ira, arg_index_inst, | 28450 | ir_add_error(ira, &arg_index_inst->base, |
| 27536 | buf_sprintf("arg index %" ZIG_PRI_u64 " out of bounds; '%s' has %" ZIG_PRI_usize " arguments", | 28451 | buf_sprintf("arg index %" ZIG_PRI_u64 " out of bounds; '%s' has %" ZIG_PRI_usize " arguments", |
| 27537 | arg_index, buf_ptr(&fn_type->name), fn_type_id->param_count)); | 28452 | arg_index, buf_ptr(&fn_type->name), fn_type_id->param_count)); |
| 27538 | return ira->codegen->invalid_instruction; | 28453 | return ira->codegen->invalid_inst_gen; |
| 27539 | } | 28454 | } |
| 27540 | | 28455 | |
| 27541 | ZigType *result_type = fn_type_id->param_info[arg_index].type; | 28456 | ZigType *result_type = fn_type_id->param_info[arg_index].type; |
| 27542 | if (result_type == nullptr) { | 28457 | if (result_type == nullptr) { |
| 27543 | // Args are only unresolved if our function is generic. | 28458 | // Args are only unresolved if our function is generic. |
| 27544 | ir_assert(fn_type->data.fn.is_generic, &instruction->base); | 28459 | ir_assert(fn_type->data.fn.is_generic, &instruction->base.base); |
| 27545 | | 28460 | |
| 27546 | if (instruction->allow_var) { | 28461 | if (instruction->allow_var) { |
| 27547 | return ir_const_type(ira, &instruction->base, ira->codegen->builtin_types.entry_var); | 28462 | return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_var); |
| 27548 | } else { | 28463 | } else { |
| 27549 | ir_add_error(ira, arg_index_inst, | 28464 | ir_add_error(ira, &arg_index_inst->base, |
| 27550 | buf_sprintf("@ArgType could not resolve the type of arg %" ZIG_PRI_u64 " because '%s' is generic", | 28465 | buf_sprintf("@ArgType could not resolve the type of arg %" ZIG_PRI_u64 " because '%s' is generic", |
| 27551 | arg_index, buf_ptr(&fn_type->name))); | 28466 | arg_index, buf_ptr(&fn_type->name))); |
| 27552 | return ira->codegen->invalid_instruction; | 28467 | return ira->codegen->invalid_inst_gen; |
| 27553 | } | 28468 | } |
| 27554 | } | 28469 | } |
| 27555 | return ir_const_type(ira, &instruction->base, result_type); | 28470 | return ir_const_type(ira, &instruction->base.base, result_type); |
| 27556 | } | 28471 | } |
| 27557 | | 28472 | |
| 27558 | static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstructionTagType *instruction) { | 28473 | static IrInstGen *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstSrcTagType *instruction) { |
| 27559 | Error err; | 28474 | Error err; |
| 27560 | IrInstruction *target_inst = instruction->target->child; | 28475 | IrInstGen *target_inst = instruction->target->child; |
| 27561 | ZigType *enum_type = ir_resolve_type(ira, target_inst); | 28476 | ZigType *enum_type = ir_resolve_type(ira, target_inst); |
| 27562 | if (type_is_invalid(enum_type)) | 28477 | if (type_is_invalid(enum_type)) |
| 27563 | return ira->codegen->invalid_instruction; | 28478 | return ira->codegen->invalid_inst_gen; |
| 27564 | | 28479 | |
| 27565 | if (enum_type->id == ZigTypeIdEnum) { | 28480 | if (enum_type->id == ZigTypeIdEnum) { |
| 27566 | if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusSizeKnown))) | 28481 | if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusSizeKnown))) |
| 27567 | return ira->codegen->invalid_instruction; | 28482 | return ira->codegen->invalid_inst_gen; |
| 27568 | | 28483 | |
| 27569 | return ir_const_type(ira, &instruction->base, enum_type->data.enumeration.tag_int_type); | 28484 | return ir_const_type(ira, &instruction->base.base, enum_type->data.enumeration.tag_int_type); |
| 27570 | } else if (enum_type->id == ZigTypeIdUnion) { | 28485 | } else if (enum_type->id == ZigTypeIdUnion) { |
| 27571 | ZigType *tag_type = ir_resolve_union_tag_type(ira, instruction->target, enum_type); | 28486 | ZigType *tag_type = ir_resolve_union_tag_type(ira, instruction->target->base.source_node, enum_type); |
| 27572 | if (type_is_invalid(tag_type)) | 28487 | if (type_is_invalid(tag_type)) |
| 27573 | return ira->codegen->invalid_instruction; | 28488 | return ira->codegen->invalid_inst_gen; |
| 27574 | return ir_const_type(ira, &instruction->base, tag_type); | 28489 | return ir_const_type(ira, &instruction->base.base, tag_type); |
| 27575 | } else { | 28490 | } else { |
| 27576 | ir_add_error(ira, target_inst, buf_sprintf("expected enum or union, found '%s'", | 28491 | ir_add_error(ira, &target_inst->base, buf_sprintf("expected enum or union, found '%s'", |
| 27577 | buf_ptr(&enum_type->name))); | 28492 | buf_ptr(&enum_type->name))); |
| 27578 | return ira->codegen->invalid_instruction; | 28493 | return ira->codegen->invalid_inst_gen; |
| 27579 | } | 28494 | } |
| 27580 | } | 28495 | } |
| 27581 | | 28496 | |
| 27582 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op) { | 28497 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstGen *op) { |
| 27583 | ZigType *operand_type = ir_resolve_type(ira, op); | 28498 | ZigType *operand_type = ir_resolve_type(ira, op); |
| 27584 | if (type_is_invalid(operand_type)) | 28499 | if (type_is_invalid(operand_type)) |
| 27585 | return ira->codegen->builtin_types.entry_invalid; | 28500 | return ira->codegen->builtin_types.entry_invalid; |
| 27586 | | 28501 | |
| 27587 | if (operand_type->id == ZigTypeIdInt) { | 28502 | if (operand_type->id == ZigTypeIdInt) { |
| 27588 | if (operand_type->data.integral.bit_count < 8) { | 28503 | if (operand_type->data.integral.bit_count < 8) { |
| 27589 | ir_add_error(ira, op, | 28504 | ir_add_error(ira, &op->base, |
| 27590 | buf_sprintf("expected integer type 8 bits or larger, found %" PRIu32 "-bit integer type", | 28505 | buf_sprintf("expected integer type 8 bits or larger, found %" PRIu32 "-bit integer type", |
| 27591 | operand_type->data.integral.bit_count)); | 28506 | operand_type->data.integral.bit_count)); |
| 27592 | return ira->codegen->builtin_types.entry_invalid; | 28507 | return ira->codegen->builtin_types.entry_invalid; |
| 27593 | } | 28508 | } |
| 27594 | uint32_t max_atomic_bits = target_arch_largest_atomic_bits(ira->codegen->zig_target->arch); | 28509 | uint32_t max_atomic_bits = target_arch_largest_atomic_bits(ira->codegen->zig_target->arch); |
| 27595 | if (operand_type->data.integral.bit_count > max_atomic_bits) { | 28510 | if (operand_type->data.integral.bit_count > max_atomic_bits) { |
| 27596 | ir_add_error(ira, op, | 28511 | ir_add_error(ira, &op->base, |
| 27597 | buf_sprintf("expected %" PRIu32 "-bit integer type or smaller, found %" PRIu32 "-bit integer type", | 28512 | buf_sprintf("expected %" PRIu32 "-bit integer type or smaller, found %" PRIu32 "-bit integer type", |
| 27598 | max_atomic_bits, operand_type->data.integral.bit_count)); | 28513 | max_atomic_bits, operand_type->data.integral.bit_count)); |
| 27599 | return ira->codegen->builtin_types.entry_invalid; | 28514 | return ira->codegen->builtin_types.entry_invalid; |
| 27600 | } | 28515 | } |
| 27601 | if (!is_power_of_2(operand_type->data.integral.bit_count)) { | 28516 | if (!is_power_of_2(operand_type->data.integral.bit_count)) { |
| 27602 | ir_add_error(ira, op, | 28517 | ir_add_error(ira, &op->base, |
| 27603 | buf_sprintf("%" PRIu32 "-bit integer type is not a power of 2", operand_type->data.integral.bit_count)); | 28518 | buf_sprintf("%" PRIu32 "-bit integer type is not a power of 2", operand_type->data.integral.bit_count)); |
| 27604 | return ira->codegen->builtin_types.entry_invalid; | 28519 | return ira->codegen->builtin_types.entry_invalid; |
| 27605 | } | 28520 | } |
| 27606 | } else if (operand_type->id == ZigTypeIdEnum) { | 28521 | } else if (operand_type->id == ZigTypeIdEnum) { |
| 27607 | ZigType *int_type = operand_type->data.enumeration.tag_int_type; | 28522 | ZigType *int_type = operand_type->data.enumeration.tag_int_type; |
| 27608 | if (int_type->data.integral.bit_count < 8) { | 28523 | if (int_type->data.integral.bit_count < 8) { |
| 27609 | ir_add_error(ira, op, | 28524 | ir_add_error(ira, &op->base, |
| 27610 | buf_sprintf("expected enum tag type 8 bits or larger, found %" PRIu32 "-bit tag type", | 28525 | buf_sprintf("expected enum tag type 8 bits or larger, found %" PRIu32 "-bit tag type", |
| 27611 | int_type->data.integral.bit_count)); | 28526 | int_type->data.integral.bit_count)); |
| 27612 | return ira->codegen->builtin_types.entry_invalid; | 28527 | return ira->codegen->builtin_types.entry_invalid; |
| 27613 | } | 28528 | } |
| 27614 | uint32_t max_atomic_bits = target_arch_largest_atomic_bits(ira->codegen->zig_target->arch); | 28529 | uint32_t max_atomic_bits = target_arch_largest_atomic_bits(ira->codegen->zig_target->arch); |
| 27615 | if (int_type->data.integral.bit_count > max_atomic_bits) { | 28530 | if (int_type->data.integral.bit_count > max_atomic_bits) { |
| 27616 | ir_add_error(ira, op, | 28531 | ir_add_error(ira, &op->base, |
| 27617 | buf_sprintf("expected %" PRIu32 "-bit enum tag type or smaller, found %" PRIu32 "-bit tag type", | 28532 | buf_sprintf("expected %" PRIu32 "-bit enum tag type or smaller, found %" PRIu32 "-bit tag type", |
| 27618 | max_atomic_bits, int_type->data.integral.bit_count)); | 28533 | max_atomic_bits, int_type->data.integral.bit_count)); |
| 27619 | return ira->codegen->builtin_types.entry_invalid; | 28534 | return ira->codegen->builtin_types.entry_invalid; |
| 27620 | } | 28535 | } |
| 27621 | if (!is_power_of_2(int_type->data.integral.bit_count)) { | 28536 | if (!is_power_of_2(int_type->data.integral.bit_count)) { |
| 27622 | ir_add_error(ira, op, | 28537 | ir_add_error(ira, &op->base, |
| 27623 | buf_sprintf("%" PRIu32 "-bit enum tag type is not a power of 2", int_type->data.integral.bit_count)); | 28538 | buf_sprintf("%" PRIu32 "-bit enum tag type is not a power of 2", int_type->data.integral.bit_count)); |
| 27624 | return ira->codegen->builtin_types.entry_invalid; | 28539 | return ira->codegen->builtin_types.entry_invalid; |
| 27625 | } | 28540 | } |
| 27626 | } else if (operand_type->id == ZigTypeIdFloat) { | 28541 | } else if (operand_type->id == ZigTypeIdFloat) { |
| 27627 | uint32_t max_atomic_bits = target_arch_largest_atomic_bits(ira->codegen->zig_target->arch); | 28542 | uint32_t max_atomic_bits = target_arch_largest_atomic_bits(ira->codegen->zig_target->arch); |
| 27628 | if (operand_type->data.floating.bit_count > max_atomic_bits) { | 28543 | if (operand_type->data.floating.bit_count > max_atomic_bits) { |
| 27629 | ir_add_error(ira, op, | 28544 | ir_add_error(ira, &op->base, |
| 27630 | buf_sprintf("expected %" PRIu32 "-bit float or smaller, found %" PRIu32 "-bit float", | 28545 | buf_sprintf("expected %" PRIu32 "-bit float or smaller, found %" PRIu32 "-bit float", |
| 27631 | max_atomic_bits, (uint32_t) operand_type->data.floating.bit_count)); | 28546 | max_atomic_bits, (uint32_t) operand_type->data.floating.bit_count)); |
| 27632 | return ira->codegen->builtin_types.entry_invalid; | 28547 | return ira->codegen->builtin_types.entry_invalid; |
| 27633 | } | 28548 | } |
| 27634 | } else if (get_codegen_ptr_type(operand_type) == nullptr) { | 28549 | } else if (get_codegen_ptr_type(operand_type) == nullptr) { |
| 27635 | ir_add_error(ira, op, | 28550 | ir_add_error(ira, &op->base, |
| 27636 | buf_sprintf("expected integer, float, enum or pointer type, found '%s'", buf_ptr(&operand_type->name))); | 28551 | buf_sprintf("expected integer, float, enum or pointer type, found '%s'", buf_ptr(&operand_type->name))); |
| 27637 | return ira->codegen->builtin_types.entry_invalid; | 28552 | return ira->codegen->builtin_types.entry_invalid; |
| 27638 | } | 28553 | } |
| ... | @@ -27640,172 +28555,146 @@ static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op | ... | @@ -27640,172 +28555,146 @@ static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op |
| 27640 | return operand_type; | 28555 | return operand_type; |
| 27641 | } | 28556 | } |
| 27642 | | 28557 | |
| 27643 | static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstructionAtomicRmw *instruction) { | 28558 | static IrInstGen *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstSrcAtomicRmw *instruction) { |
| 27644 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->child); | 28559 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->child); |
| 27645 | if (type_is_invalid(operand_type)) | 28560 | if (type_is_invalid(operand_type)) |
| 27646 | return ira->codegen->invalid_instruction; | 28561 | return ira->codegen->invalid_inst_gen; |
| 27647 | | 28562 | |
| 27648 | IrInstruction *ptr_inst = instruction->ptr->child; | 28563 | IrInstGen *ptr_inst = instruction->ptr->child; |
| 27649 | if (type_is_invalid(ptr_inst->value->type)) | 28564 | if (type_is_invalid(ptr_inst->value->type)) |
| 27650 | return ira->codegen->invalid_instruction; | 28565 | return ira->codegen->invalid_inst_gen; |
| 27651 | | 28566 | |
| 27652 | // TODO let this be volatile | 28567 | // TODO let this be volatile |
| 27653 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); | 28568 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 27654 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | 28569 | IrInstGen *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); |
| 27655 | if (type_is_invalid(casted_ptr->value->type)) | 28570 | if (type_is_invalid(casted_ptr->value->type)) |
| 27656 | return ira->codegen->invalid_instruction; | 28571 | return ira->codegen->invalid_inst_gen; |
| 27657 | | 28572 | |
| 27658 | AtomicRmwOp op; | 28573 | AtomicRmwOp op; |
| 27659 | if (instruction->op == nullptr) { | 28574 | if (!ir_resolve_atomic_rmw_op(ira, instruction->op->child, &op)) { |
| 27660 | op = instruction->resolved_op; | 28575 | return ira->codegen->invalid_inst_gen; |
| 27661 | } else { | | |
| 27662 | if (!ir_resolve_atomic_rmw_op(ira, instruction->op->child, &op)) { | | |
| 27663 | return ira->codegen->invalid_instruction; | | |
| 27664 | } | | |
| 27665 | } | 28576 | } |
| 27666 | | 28577 | |
| 27667 | if (operand_type->id == ZigTypeIdEnum && op != AtomicRmwOp_xchg) { | 28578 | if (operand_type->id == ZigTypeIdEnum && op != AtomicRmwOp_xchg) { |
| 27668 | ir_add_error(ira, instruction->op, | 28579 | ir_add_error(ira, &instruction->op->base, |
| 27669 | buf_sprintf("@atomicRmw on enum only works with .Xchg")); | 28580 | buf_sprintf("@atomicRmw on enum only works with .Xchg")); |
| 27670 | return ira->codegen->invalid_instruction; | 28581 | return ira->codegen->invalid_inst_gen; |
| 27671 | } else if (operand_type->id == ZigTypeIdFloat && op > AtomicRmwOp_sub) { | 28582 | } else if (operand_type->id == ZigTypeIdFloat && op > AtomicRmwOp_sub) { |
| 27672 | ir_add_error(ira, instruction->op, | 28583 | ir_add_error(ira, &instruction->op->base, |
| 27673 | buf_sprintf("@atomicRmw with float only works with .Xchg, .Add and .Sub")); | 28584 | buf_sprintf("@atomicRmw with float only works with .Xchg, .Add and .Sub")); |
| 27674 | return ira->codegen->invalid_instruction; | 28585 | return ira->codegen->invalid_inst_gen; |
| 27675 | } | 28586 | } |
| 27676 | | 28587 | |
| 27677 | IrInstruction *operand = instruction->operand->child; | 28588 | IrInstGen *operand = instruction->operand->child; |
| 27678 | if (type_is_invalid(operand->value->type)) | 28589 | if (type_is_invalid(operand->value->type)) |
| 27679 | return ira->codegen->invalid_instruction; | 28590 | return ira->codegen->invalid_inst_gen; |
| 27680 | | 28591 | |
| 27681 | IrInstruction *casted_operand = ir_implicit_cast(ira, operand, operand_type); | 28592 | IrInstGen *casted_operand = ir_implicit_cast(ira, operand, operand_type); |
| 27682 | if (type_is_invalid(casted_operand->value->type)) | 28593 | if (type_is_invalid(casted_operand->value->type)) |
| 27683 | return ira->codegen->invalid_instruction; | 28594 | return ira->codegen->invalid_inst_gen; |
| 27684 | | 28595 | |
| 27685 | AtomicOrder ordering; | 28596 | AtomicOrder ordering; |
| 27686 | if (instruction->ordering == nullptr) { | 28597 | if (!ir_resolve_atomic_order(ira, instruction->ordering->child, &ordering)) |
| 27687 | ordering = instruction->resolved_ordering; | 28598 | return ira->codegen->invalid_inst_gen; |
| 27688 | } else { | 28599 | if (ordering == AtomicOrderUnordered) { |
| 27689 | if (!ir_resolve_atomic_order(ira, instruction->ordering->child, &ordering)) | 28600 | ir_add_error(ira, &instruction->ordering->base, |
| 27690 | return ira->codegen->invalid_instruction; | 28601 | buf_sprintf("@atomicRmw atomic ordering must not be Unordered")); |
| 27691 | if (ordering == AtomicOrderUnordered) { | 28602 | return ira->codegen->invalid_inst_gen; |
| 27692 | ir_add_error(ira, instruction->ordering, | | |
| 27693 | buf_sprintf("@atomicRmw atomic ordering must not be Unordered")); | | |
| 27694 | return ira->codegen->invalid_instruction; | | |
| 27695 | } | | |
| 27696 | } | 28603 | } |
| 27697 | | 28604 | |
| 27698 | if (instr_is_comptime(casted_operand) && instr_is_comptime(casted_ptr) && casted_ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar) | 28605 | if (instr_is_comptime(casted_operand) && instr_is_comptime(casted_ptr) && casted_ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar) |
| 27699 | { | 28606 | { |
| 27700 | zig_panic("TODO compile-time execution of atomicRmw"); | 28607 | ir_add_error(ira, &instruction->base.base, |
| | 28608 | buf_sprintf("compiler bug: TODO compile-time execution of @atomicRmw")); |
| | 28609 | return ira->codegen->invalid_inst_gen; |
| 27701 | } | 28610 | } |
| 27702 | | 28611 | |
| 27703 | IrInstruction *result = ir_build_atomic_rmw(&ira->new_irb, instruction->base.scope, | 28612 | return ir_build_atomic_rmw_gen(ira, &instruction->base.base, casted_ptr, casted_operand, op, |
| 27704 | instruction->base.source_node, nullptr, casted_ptr, nullptr, casted_operand, nullptr, | 28613 | ordering, operand_type); |
| 27705 | op, ordering); | | |
| 27706 | result->value->type = operand_type; | | |
| 27707 | return result; | | |
| 27708 | } | 28614 | } |
| 27709 | | 28615 | |
| 27710 | static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstructionAtomicLoad *instruction) { | 28616 | static IrInstGen *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstSrcAtomicLoad *instruction) { |
| 27711 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->child); | 28617 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->child); |
| 27712 | if (type_is_invalid(operand_type)) | 28618 | if (type_is_invalid(operand_type)) |
| 27713 | return ira->codegen->invalid_instruction; | 28619 | return ira->codegen->invalid_inst_gen; |
| 27714 | | 28620 | |
| 27715 | IrInstruction *ptr_inst = instruction->ptr->child; | 28621 | IrInstGen *ptr_inst = instruction->ptr->child; |
| 27716 | if (type_is_invalid(ptr_inst->value->type)) | 28622 | if (type_is_invalid(ptr_inst->value->type)) |
| 27717 | return ira->codegen->invalid_instruction; | 28623 | return ira->codegen->invalid_inst_gen; |
| 27718 | | 28624 | |
| 27719 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, true); | 28625 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, true); |
| 27720 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | 28626 | IrInstGen *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); |
| 27721 | if (type_is_invalid(casted_ptr->value->type)) | 28627 | if (type_is_invalid(casted_ptr->value->type)) |
| 27722 | return ira->codegen->invalid_instruction; | 28628 | return ira->codegen->invalid_inst_gen; |
| 27723 | | 28629 | |
| 27724 | AtomicOrder ordering; | 28630 | AtomicOrder ordering; |
| 27725 | if (instruction->ordering == nullptr) { | 28631 | if (!ir_resolve_atomic_order(ira, instruction->ordering->child, &ordering)) |
| 27726 | ordering = instruction->resolved_ordering; | 28632 | return ira->codegen->invalid_inst_gen; |
| 27727 | } else { | | |
| 27728 | if (!ir_resolve_atomic_order(ira, instruction->ordering->child, &ordering)) | | |
| 27729 | return ira->codegen->invalid_instruction; | | |
| 27730 | } | | |
| 27731 | | 28633 | |
| 27732 | if (ordering == AtomicOrderRelease || ordering == AtomicOrderAcqRel) { | 28634 | if (ordering == AtomicOrderRelease || ordering == AtomicOrderAcqRel) { |
| 27733 | ir_assert(instruction->ordering != nullptr, &instruction->base); | 28635 | ir_assert(instruction->ordering != nullptr, &instruction->base.base); |
| 27734 | ir_add_error(ira, instruction->ordering, | 28636 | ir_add_error(ira, &instruction->ordering->base, |
| 27735 | buf_sprintf("@atomicLoad atomic ordering must not be Release or AcqRel")); | 28637 | buf_sprintf("@atomicLoad atomic ordering must not be Release or AcqRel")); |
| 27736 | return ira->codegen->invalid_instruction; | 28638 | return ira->codegen->invalid_inst_gen; |
| 27737 | } | 28639 | } |
| 27738 | | 28640 | |
| 27739 | if (instr_is_comptime(casted_ptr)) { | 28641 | if (instr_is_comptime(casted_ptr)) { |
| 27740 | IrInstruction *result = ir_get_deref(ira, &instruction->base, casted_ptr, nullptr); | 28642 | IrInstGen *result = ir_get_deref(ira, &instruction->base.base, casted_ptr, nullptr); |
| 27741 | ir_assert(result->value->type != nullptr, &instruction->base); | 28643 | ir_assert(result->value->type != nullptr, &instruction->base.base); |
| 27742 | return result; | 28644 | return result; |
| 27743 | } | 28645 | } |
| 27744 | | 28646 | |
| 27745 | IrInstruction *result = ir_build_atomic_load(&ira->new_irb, instruction->base.scope, | 28647 | return ir_build_atomic_load_gen(ira, &instruction->base.base, casted_ptr, ordering, operand_type); |
| 27746 | instruction->base.source_node, nullptr, casted_ptr, nullptr, ordering); | | |
| 27747 | result->value->type = operand_type; | | |
| 27748 | return result; | | |
| 27749 | } | 28648 | } |
| 27750 | | 28649 | |
| 27751 | static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInstructionAtomicStore *instruction) { | 28650 | static IrInstGen *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInstSrcAtomicStore *instruction) { |
| 27752 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->child); | 28651 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->child); |
| 27753 | if (type_is_invalid(operand_type)) | 28652 | if (type_is_invalid(operand_type)) |
| 27754 | return ira->codegen->invalid_instruction; | 28653 | return ira->codegen->invalid_inst_gen; |
| 27755 | | 28654 | |
| 27756 | IrInstruction *ptr_inst = instruction->ptr->child; | 28655 | IrInstGen *ptr_inst = instruction->ptr->child; |
| 27757 | if (type_is_invalid(ptr_inst->value->type)) | 28656 | if (type_is_invalid(ptr_inst->value->type)) |
| 27758 | return ira->codegen->invalid_instruction; | 28657 | return ira->codegen->invalid_inst_gen; |
| 27759 | | 28658 | |
| 27760 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); | 28659 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 27761 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | 28660 | IrInstGen *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); |
| 27762 | if (type_is_invalid(casted_ptr->value->type)) | 28661 | if (type_is_invalid(casted_ptr->value->type)) |
| 27763 | return ira->codegen->invalid_instruction; | 28662 | return ira->codegen->invalid_inst_gen; |
| 27764 | | 28663 | |
| 27765 | IrInstruction *value = instruction->value->child; | 28664 | IrInstGen *value = instruction->value->child; |
| 27766 | if (type_is_invalid(value->value->type)) | 28665 | if (type_is_invalid(value->value->type)) |
| 27767 | return ira->codegen->invalid_instruction; | 28666 | return ira->codegen->invalid_inst_gen; |
| 27768 | | 28667 | |
| 27769 | IrInstruction *casted_value = ir_implicit_cast(ira, value, operand_type); | 28668 | IrInstGen *casted_value = ir_implicit_cast(ira, value, operand_type); |
| 27770 | if (type_is_invalid(casted_value->value->type)) | 28669 | if (type_is_invalid(casted_value->value->type)) |
| 27771 | return ira->codegen->invalid_instruction; | 28670 | return ira->codegen->invalid_inst_gen; |
| 27772 | | 28671 | |
| 27773 | | 28672 | |
| 27774 | AtomicOrder ordering; | 28673 | AtomicOrder ordering; |
| 27775 | if (instruction->ordering == nullptr) { | 28674 | if (!ir_resolve_atomic_order(ira, instruction->ordering->child, &ordering)) |
| 27776 | ordering = instruction->resolved_ordering; | 28675 | return ira->codegen->invalid_inst_gen; |
| 27777 | } else { | | |
| 27778 | if (!ir_resolve_atomic_order(ira, instruction->ordering->child, &ordering)) | | |
| 27779 | return ira->codegen->invalid_instruction; | | |
| 27780 | } | | |
| 27781 | | 28676 | |
| 27782 | if (ordering == AtomicOrderAcquire || ordering == AtomicOrderAcqRel) { | 28677 | if (ordering == AtomicOrderAcquire || ordering == AtomicOrderAcqRel) { |
| 27783 | ir_assert(instruction->ordering != nullptr, &instruction->base); | 28678 | ir_assert(instruction->ordering != nullptr, &instruction->base.base); |
| 27784 | ir_add_error(ira, instruction->ordering, | 28679 | ir_add_error(ira, &instruction->ordering->base, |
| 27785 | buf_sprintf("@atomicStore atomic ordering must not be Acquire or AcqRel")); | 28680 | buf_sprintf("@atomicStore atomic ordering must not be Acquire or AcqRel")); |
| 27786 | return ira->codegen->invalid_instruction; | 28681 | return ira->codegen->invalid_inst_gen; |
| 27787 | } | 28682 | } |
| 27788 | | 28683 | |
| 27789 | if (instr_is_comptime(casted_value) && instr_is_comptime(casted_ptr)) { | 28684 | if (instr_is_comptime(casted_value) && instr_is_comptime(casted_ptr)) { |
| 27790 | IrInstruction *result = ir_analyze_store_ptr(ira, &instruction->base, casted_ptr, value, false); | 28685 | IrInstGen *result = ir_analyze_store_ptr(ira, &instruction->base.base, casted_ptr, value, false); |
| 27791 | result->value->type = ira->codegen->builtin_types.entry_void; | 28686 | result->value->type = ira->codegen->builtin_types.entry_void; |
| 27792 | return result; | 28687 | return result; |
| 27793 | } | 28688 | } |
| 27794 | | 28689 | |
| 27795 | IrInstruction *result = ir_build_atomic_store(&ira->new_irb, instruction->base.scope, | 28690 | return ir_build_atomic_store_gen(ira, &instruction->base.base, casted_ptr, casted_value, ordering); |
| 27796 | instruction->base.source_node, nullptr, casted_ptr, casted_value, nullptr, ordering); | | |
| 27797 | result->value->type = ira->codegen->builtin_types.entry_void; | | |
| 27798 | return result; | | |
| 27799 | } | 28691 | } |
| 27800 | | 28692 | |
| 27801 | static IrInstruction *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira, IrInstructionSaveErrRetAddr *instruction) { | 28693 | static IrInstGen *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira, IrInstSrcSaveErrRetAddr *instruction) { |
| 27802 | IrInstruction *result = ir_build_save_err_ret_addr(&ira->new_irb, instruction->base.scope, | 28694 | return ir_build_save_err_ret_addr_gen(ira, &instruction->base.base); |
| 27803 | instruction->base.source_node); | | |
| 27804 | result->value->type = ira->codegen->builtin_types.entry_void; | | |
| 27805 | return result; | | |
| 27806 | } | 28695 | } |
| 27807 | | 28696 | |
| 27808 | static ErrorMsg *ir_eval_float_op(IrAnalyze *ira, IrInstruction *source_instr, BuiltinFnId fop, ZigType *float_type, | 28697 | static ErrorMsg *ir_eval_float_op(IrAnalyze *ira, IrInst* source_instr, BuiltinFnId fop, ZigType *float_type, |
| 27809 | ZigValue *op, ZigValue *out_val) | 28698 | ZigValue *op, ZigValue *out_val) |
| 27810 | { | 28699 | { |
| 27811 | assert(ira && source_instr && float_type && out_val && op); | 28700 | assert(ira && source_instr && float_type && out_val && op); |
| ... | @@ -28018,30 +28907,30 @@ static ErrorMsg *ir_eval_float_op(IrAnalyze *ira, IrInstruction *source_instr, B | ... | @@ -28018,30 +28907,30 @@ static ErrorMsg *ir_eval_float_op(IrAnalyze *ira, IrInstruction *source_instr, B |
| 28018 | return nullptr; | 28907 | return nullptr; |
| 28019 | } | 28908 | } |
| 28020 | | 28909 | |
| 28021 | static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstructionFloatOp *instruction) { | 28910 | static IrInstGen *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstSrcFloatOp *instruction) { |
| 28022 | IrInstruction *operand = instruction->operand->child; | 28911 | IrInstGen *operand = instruction->operand->child; |
| 28023 | ZigType *operand_type = operand->value->type; | 28912 | ZigType *operand_type = operand->value->type; |
| 28024 | if (type_is_invalid(operand_type)) | 28913 | if (type_is_invalid(operand_type)) |
| 28025 | return ira->codegen->invalid_instruction; | 28914 | return ira->codegen->invalid_inst_gen; |
| 28026 | | 28915 | |
| 28027 | // This instruction accepts floats and vectors of floats. | 28916 | // This instruction accepts floats and vectors of floats. |
| 28028 | ZigType *scalar_type = (operand_type->id == ZigTypeIdVector) ? | 28917 | ZigType *scalar_type = (operand_type->id == ZigTypeIdVector) ? |
| 28029 | operand_type->data.vector.elem_type : operand_type; | 28918 | operand_type->data.vector.elem_type : operand_type; |
| 28030 | | 28919 | |
| 28031 | if (scalar_type->id != ZigTypeIdFloat && scalar_type->id != ZigTypeIdComptimeFloat) { | 28920 | if (scalar_type->id != ZigTypeIdFloat && scalar_type->id != ZigTypeIdComptimeFloat) { |
| 28032 | ir_add_error(ira, operand, | 28921 | ir_add_error(ira, &operand->base, |
| 28033 | buf_sprintf("expected float type, found '%s'", buf_ptr(&scalar_type->name))); | 28922 | buf_sprintf("expected float type, found '%s'", buf_ptr(&scalar_type->name))); |
| 28034 | return ira->codegen->invalid_instruction; | 28923 | return ira->codegen->invalid_inst_gen; |
| 28035 | } | 28924 | } |
| 28036 | | 28925 | |
| 28037 | if (instr_is_comptime(operand)) { | 28926 | if (instr_is_comptime(operand)) { |
| 28038 | ZigValue *operand_val = ir_resolve_const(ira, operand, UndefOk); | 28927 | ZigValue *operand_val = ir_resolve_const(ira, operand, UndefOk); |
| 28039 | if (operand_val == nullptr) | 28928 | if (operand_val == nullptr) |
| 28040 | return ira->codegen->invalid_instruction; | 28929 | return ira->codegen->invalid_inst_gen; |
| 28041 | if (operand_val->special == ConstValSpecialUndef) | 28930 | if (operand_val->special == ConstValSpecialUndef) |
| 28042 | return ir_const_undef(ira, &instruction->base, operand_type); | 28931 | return ir_const_undef(ira, &instruction->base.base, operand_type); |
| 28043 | | 28932 | |
| 28044 | IrInstruction *result = ir_const(ira, &instruction->base, operand_type); | 28933 | IrInstGen *result = ir_const(ira, &instruction->base.base, operand_type); |
| 28045 | ZigValue *out_val = result->value; | 28934 | ZigValue *out_val = result->value; |
| 28046 | | 28935 | |
| 28047 | if (operand_type->id == ZigTypeIdVector) { | 28936 | if (operand_type->id == ZigTypeIdVector) { |
| ... | @@ -28052,47 +28941,44 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct | ... | @@ -28052,47 +28941,44 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct |
| 28052 | for (size_t i = 0; i < len; i += 1) { | 28941 | for (size_t i = 0; i < len; i += 1) { |
| 28053 | ZigValue *elem_operand = &operand_val->data.x_array.data.s_none.elements[i]; | 28942 | ZigValue *elem_operand = &operand_val->data.x_array.data.s_none.elements[i]; |
| 28054 | ZigValue *float_out_val = &out_val->data.x_array.data.s_none.elements[i]; | 28943 | ZigValue *float_out_val = &out_val->data.x_array.data.s_none.elements[i]; |
| 28055 | ir_assert(elem_operand->type == scalar_type, &instruction->base); | 28944 | ir_assert(elem_operand->type == scalar_type, &instruction->base.base); |
| 28056 | ir_assert(float_out_val->type == scalar_type, &instruction->base); | 28945 | ir_assert(float_out_val->type == scalar_type, &instruction->base.base); |
| 28057 | ErrorMsg *msg = ir_eval_float_op(ira, &instruction->base, instruction->fn_id, scalar_type, | 28946 | ErrorMsg *msg = ir_eval_float_op(ira, &instruction->base.base, instruction->fn_id, scalar_type, |
| 28058 | elem_operand, float_out_val); | 28947 | elem_operand, float_out_val); |
| 28059 | if (msg != nullptr) { | 28948 | if (msg != nullptr) { |
| 28060 | add_error_note(ira->codegen, msg, instruction->base.source_node, | 28949 | add_error_note(ira->codegen, msg, instruction->base.base.source_node, |
| 28061 | buf_sprintf("when computing vector element at index %" ZIG_PRI_usize, i)); | 28950 | buf_sprintf("when computing vector element at index %" ZIG_PRI_usize, i)); |
| 28062 | return ira->codegen->invalid_instruction; | 28951 | return ira->codegen->invalid_inst_gen; |
| 28063 | } | 28952 | } |
| 28064 | float_out_val->type = scalar_type; | 28953 | float_out_val->type = scalar_type; |
| 28065 | } | 28954 | } |
| 28066 | out_val->type = operand_type; | 28955 | out_val->type = operand_type; |
| 28067 | out_val->special = ConstValSpecialStatic; | 28956 | out_val->special = ConstValSpecialStatic; |
| 28068 | } else { | 28957 | } else { |
| 28069 | if (ir_eval_float_op(ira, &instruction->base, instruction->fn_id, scalar_type, | 28958 | if (ir_eval_float_op(ira, &instruction->base.base, instruction->fn_id, scalar_type, |
| 28070 | operand_val, out_val) != nullptr) | 28959 | operand_val, out_val) != nullptr) |
| 28071 | { | 28960 | { |
| 28072 | return ira->codegen->invalid_instruction; | 28961 | return ira->codegen->invalid_inst_gen; |
| 28073 | } | 28962 | } |
| 28074 | } | 28963 | } |
| 28075 | return result; | 28964 | return result; |
| 28076 | } | 28965 | } |
| 28077 | | 28966 | |
| 28078 | ir_assert(scalar_type->id == ZigTypeIdFloat, &instruction->base); | 28967 | ir_assert(scalar_type->id == ZigTypeIdFloat, &instruction->base.base); |
| 28079 | | 28968 | |
| 28080 | IrInstruction *result = ir_build_float_op(&ira->new_irb, instruction->base.scope, | 28969 | return ir_build_float_op_gen(ira, &instruction->base.base, operand, instruction->fn_id, operand_type); |
| 28081 | instruction->base.source_node, operand, instruction->fn_id); | | |
| 28082 | result->value->type = operand_type; | | |
| 28083 | return result; | | |
| 28084 | } | 28970 | } |
| 28085 | | 28971 | |
| 28086 | static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstructionBswap *instruction) { | 28972 | static IrInstGen *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstSrcBswap *instruction) { |
| 28087 | Error err; | 28973 | Error err; |
| 28088 | | 28974 | |
| 28089 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); | 28975 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); |
| 28090 | if (type_is_invalid(int_type)) | 28976 | if (type_is_invalid(int_type)) |
| 28091 | return ira->codegen->invalid_instruction; | 28977 | return ira->codegen->invalid_inst_gen; |
| 28092 | | 28978 | |
| 28093 | IrInstruction *uncasted_op = instruction->op->child; | 28979 | IrInstGen *uncasted_op = instruction->op->child; |
| 28094 | if (type_is_invalid(uncasted_op->value->type)) | 28980 | if (type_is_invalid(uncasted_op->value->type)) |
| 28095 | return ira->codegen->invalid_instruction; | 28981 | return ira->codegen->invalid_inst_gen; |
| 28096 | | 28982 | |
| 28097 | uint32_t vector_len; // UINT32_MAX means not a vector | 28983 | uint32_t vector_len; // UINT32_MAX means not a vector |
| 28098 | if (uncasted_op->value->type->id == ZigTypeIdArray && | 28984 | if (uncasted_op->value->type->id == ZigTypeIdArray && |
| ... | @@ -28108,28 +28994,28 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -28108,28 +28994,28 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 28108 | bool is_vector = (vector_len != UINT32_MAX); | 28994 | bool is_vector = (vector_len != UINT32_MAX); |
| 28109 | ZigType *op_type = is_vector ? get_vector_type(ira->codegen, vector_len, int_type) : int_type; | 28995 | ZigType *op_type = is_vector ? get_vector_type(ira->codegen, vector_len, int_type) : int_type; |
| 28110 | | 28996 | |
| 28111 | IrInstruction *op = ir_implicit_cast(ira, uncasted_op, op_type); | 28997 | IrInstGen *op = ir_implicit_cast(ira, uncasted_op, op_type); |
| 28112 | if (type_is_invalid(op->value->type)) | 28998 | if (type_is_invalid(op->value->type)) |
| 28113 | return ira->codegen->invalid_instruction; | 28999 | return ira->codegen->invalid_inst_gen; |
| 28114 | | 29000 | |
| 28115 | if (int_type->data.integral.bit_count == 8 || int_type->data.integral.bit_count == 0) | 29001 | if (int_type->data.integral.bit_count == 8 || int_type->data.integral.bit_count == 0) |
| 28116 | return op; | 29002 | return op; |
| 28117 | | 29003 | |
| 28118 | if (int_type->data.integral.bit_count % 8 != 0) { | 29004 | if (int_type->data.integral.bit_count % 8 != 0) { |
| 28119 | ir_add_error(ira, instruction->op, | 29005 | ir_add_error(ira, &instruction->op->base, |
| 28120 | buf_sprintf("@byteSwap integer type '%s' has %" PRIu32 " bits which is not evenly divisible by 8", | 29006 | buf_sprintf("@byteSwap integer type '%s' has %" PRIu32 " bits which is not evenly divisible by 8", |
| 28121 | buf_ptr(&int_type->name), int_type->data.integral.bit_count)); | 29007 | buf_ptr(&int_type->name), int_type->data.integral.bit_count)); |
| 28122 | return ira->codegen->invalid_instruction; | 29008 | return ira->codegen->invalid_inst_gen; |
| 28123 | } | 29009 | } |
| 28124 | | 29010 | |
| 28125 | if (instr_is_comptime(op)) { | 29011 | if (instr_is_comptime(op)) { |
| 28126 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); | 29012 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 28127 | if (val == nullptr) | 29013 | if (val == nullptr) |
| 28128 | return ira->codegen->invalid_instruction; | 29014 | return ira->codegen->invalid_inst_gen; |
| 28129 | if (val->special == ConstValSpecialUndef) | 29015 | if (val->special == ConstValSpecialUndef) |
| 28130 | return ir_const_undef(ira, &instruction->base, op_type); | 29016 | return ir_const_undef(ira, &instruction->base.base, op_type); |
| 28131 | | 29017 | |
| 28132 | IrInstruction *result = ir_const(ira, &instruction->base, op_type); | 29018 | IrInstGen *result = ir_const(ira, &instruction->base.base, op_type); |
| 28133 | size_t buf_size = int_type->data.integral.bit_count / 8; | 29019 | size_t buf_size = int_type->data.integral.bit_count / 8; |
| 28134 | uint8_t *buf = allocate_nonzero<uint8_t>(buf_size); | 29020 | uint8_t *buf = allocate_nonzero<uint8_t>(buf_size); |
| 28135 | if (is_vector) { | 29021 | if (is_vector) { |
| ... | @@ -28137,10 +29023,10 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -28137,10 +29023,10 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 28137 | result->value->data.x_array.data.s_none.elements = create_const_vals(op_type->data.vector.len); | 29023 | result->value->data.x_array.data.s_none.elements = create_const_vals(op_type->data.vector.len); |
| 28138 | for (unsigned i = 0; i < op_type->data.vector.len; i += 1) { | 29024 | for (unsigned i = 0; i < op_type->data.vector.len; i += 1) { |
| 28139 | ZigValue *op_elem_val = &val->data.x_array.data.s_none.elements[i]; | 29025 | ZigValue *op_elem_val = &val->data.x_array.data.s_none.elements[i]; |
| 28140 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, instruction->base.source_node, | 29026 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, instruction->base.base.source_node, |
| 28141 | op_elem_val, UndefOk))) | 29027 | op_elem_val, UndefOk))) |
| 28142 | { | 29028 | { |
| 28143 | return ira->codegen->invalid_instruction; | 29029 | return ira->codegen->invalid_inst_gen; |
| 28144 | } | 29030 | } |
| 28145 | ZigValue *result_elem_val = &result->value->data.x_array.data.s_none.elements[i]; | 29031 | ZigValue *result_elem_val = &result->value->data.x_array.data.s_none.elements[i]; |
| 28146 | result_elem_val->type = int_type; | 29032 | result_elem_val->type = int_type; |
| ... | @@ -28162,23 +29048,20 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -28162,23 +29048,20 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 28162 | return result; | 29048 | return result; |
| 28163 | } | 29049 | } |
| 28164 | | 29050 | |
| 28165 | IrInstruction *result = ir_build_bswap(&ira->new_irb, instruction->base.scope, | 29051 | return ir_build_bswap_gen(ira, &instruction->base.base, op_type, op); |
| 28166 | instruction->base.source_node, nullptr, op); | | |
| 28167 | result->value->type = op_type; | | |
| 28168 | return result; | | |
| 28169 | } | 29052 | } |
| 28170 | | 29053 | |
| 28171 | static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstructionBitReverse *instruction) { | 29054 | static IrInstGen *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstSrcBitReverse *instruction) { |
| 28172 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); | 29055 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); |
| 28173 | if (type_is_invalid(int_type)) | 29056 | if (type_is_invalid(int_type)) |
| 28174 | return ira->codegen->invalid_instruction; | 29057 | return ira->codegen->invalid_inst_gen; |
| 28175 | | 29058 | |
| 28176 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); | 29059 | IrInstGen *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 28177 | if (type_is_invalid(op->value->type)) | 29060 | if (type_is_invalid(op->value->type)) |
| 28178 | return ira->codegen->invalid_instruction; | 29061 | return ira->codegen->invalid_inst_gen; |
| 28179 | | 29062 | |
| 28180 | if (int_type->data.integral.bit_count == 0) { | 29063 | if (int_type->data.integral.bit_count == 0) { |
| 28181 | IrInstruction *result = ir_const(ira, &instruction->base, int_type); | 29064 | IrInstGen *result = ir_const(ira, &instruction->base.base, int_type); |
| 28182 | bigint_init_unsigned(&result->value->data.x_bigint, 0); | 29065 | bigint_init_unsigned(&result->value->data.x_bigint, 0); |
| 28183 | return result; | 29066 | return result; |
| 28184 | } | 29067 | } |
| ... | @@ -28186,11 +29069,11 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr | ... | @@ -28186,11 +29069,11 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr |
| 28186 | if (instr_is_comptime(op)) { | 29069 | if (instr_is_comptime(op)) { |
| 28187 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); | 29070 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 28188 | if (val == nullptr) | 29071 | if (val == nullptr) |
| 28189 | return ira->codegen->invalid_instruction; | 29072 | return ira->codegen->invalid_inst_gen; |
| 28190 | if (val->special == ConstValSpecialUndef) | 29073 | if (val->special == ConstValSpecialUndef) |
| 28191 | return ir_const_undef(ira, &instruction->base, int_type); | 29074 | return ir_const_undef(ira, &instruction->base.base, int_type); |
| 28192 | | 29075 | |
| 28193 | IrInstruction *result = ir_const(ira, &instruction->base, int_type); | 29076 | IrInstGen *result = ir_const(ira, &instruction->base.base, int_type); |
| 28194 | size_t num_bits = int_type->data.integral.bit_count; | 29077 | size_t num_bits = int_type->data.integral.bit_count; |
| 28195 | size_t buf_size = (num_bits + 7) / 8; | 29078 | size_t buf_size = (num_bits + 7) / 8; |
| 28196 | uint8_t *comptime_buf = allocate_nonzero<uint8_t>(buf_size); | 29079 | uint8_t *comptime_buf = allocate_nonzero<uint8_t>(buf_size); |
| ... | @@ -28217,128 +29100,125 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr | ... | @@ -28217,128 +29100,125 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr |
| 28217 | return result; | 29100 | return result; |
| 28218 | } | 29101 | } |
| 28219 | | 29102 | |
| 28220 | IrInstruction *result = ir_build_bit_reverse(&ira->new_irb, instruction->base.scope, | 29103 | return ir_build_bit_reverse_gen(ira, &instruction->base.base, int_type, op); |
| 28221 | instruction->base.source_node, nullptr, op); | | |
| 28222 | result->value->type = int_type; | | |
| 28223 | return result; | | |
| 28224 | } | 29104 | } |
| 28225 | | 29105 | |
| 28226 | | 29106 | |
| 28227 | static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstructionEnumToInt *instruction) { | 29107 | static IrInstGen *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstSrcEnumToInt *instruction) { |
| 28228 | IrInstruction *target = instruction->target->child; | 29108 | IrInstGen *target = instruction->target->child; |
| 28229 | if (type_is_invalid(target->value->type)) | 29109 | if (type_is_invalid(target->value->type)) |
| 28230 | return ira->codegen->invalid_instruction; | 29110 | return ira->codegen->invalid_inst_gen; |
| 28231 | | 29111 | |
| 28232 | return ir_analyze_enum_to_int(ira, &instruction->base, target); | 29112 | return ir_analyze_enum_to_int(ira, &instruction->base.base, target); |
| 28233 | } | 29113 | } |
| 28234 | | 29114 | |
| 28235 | static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstructionIntToEnum *instruction) { | 29115 | static IrInstGen *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstSrcIntToEnum *instruction) { |
| 28236 | Error err; | 29116 | Error err; |
| 28237 | IrInstruction *dest_type_value = instruction->dest_type->child; | 29117 | IrInstGen *dest_type_value = instruction->dest_type->child; |
| 28238 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); | 29118 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); |
| 28239 | if (type_is_invalid(dest_type)) | 29119 | if (type_is_invalid(dest_type)) |
| 28240 | return ira->codegen->invalid_instruction; | 29120 | return ira->codegen->invalid_inst_gen; |
| 28241 | | 29121 | |
| 28242 | if (dest_type->id != ZigTypeIdEnum) { | 29122 | if (dest_type->id != ZigTypeIdEnum) { |
| 28243 | ir_add_error(ira, instruction->dest_type, | 29123 | ir_add_error(ira, &instruction->dest_type->base, |
| 28244 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&dest_type->name))); | 29124 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&dest_type->name))); |
| 28245 | return ira->codegen->invalid_instruction; | 29125 | return ira->codegen->invalid_inst_gen; |
| 28246 | } | 29126 | } |
| 28247 | | 29127 | |
| 28248 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) | 29128 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) |
| 28249 | return ira->codegen->invalid_instruction; | 29129 | return ira->codegen->invalid_inst_gen; |
| 28250 | | 29130 | |
| 28251 | ZigType *tag_type = dest_type->data.enumeration.tag_int_type; | 29131 | ZigType *tag_type = dest_type->data.enumeration.tag_int_type; |
| 28252 | | 29132 | |
| 28253 | IrInstruction *target = instruction->target->child; | 29133 | IrInstGen *target = instruction->target->child; |
| 28254 | if (type_is_invalid(target->value->type)) | 29134 | if (type_is_invalid(target->value->type)) |
| 28255 | return ira->codegen->invalid_instruction; | 29135 | return ira->codegen->invalid_inst_gen; |
| 28256 | | 29136 | |
| 28257 | IrInstruction *casted_target = ir_implicit_cast(ira, target, tag_type); | 29137 | IrInstGen *casted_target = ir_implicit_cast(ira, target, tag_type); |
| 28258 | if (type_is_invalid(casted_target->value->type)) | 29138 | if (type_is_invalid(casted_target->value->type)) |
| 28259 | return ira->codegen->invalid_instruction; | 29139 | return ira->codegen->invalid_inst_gen; |
| 28260 | | 29140 | |
| 28261 | return ir_analyze_int_to_enum(ira, &instruction->base, casted_target, dest_type); | 29141 | return ir_analyze_int_to_enum(ira, &instruction->base.base, casted_target, dest_type); |
| 28262 | } | 29142 | } |
| 28263 | | 29143 | |
| 28264 | static IrInstruction *ir_analyze_instruction_check_runtime_scope(IrAnalyze *ira, IrInstructionCheckRuntimeScope *instruction) { | 29144 | static IrInstGen *ir_analyze_instruction_check_runtime_scope(IrAnalyze *ira, IrInstSrcCheckRuntimeScope *instruction) { |
| 28265 | IrInstruction *block_comptime_inst = instruction->scope_is_comptime->child; | 29145 | IrInstGen *block_comptime_inst = instruction->scope_is_comptime->child; |
| 28266 | bool scope_is_comptime; | 29146 | bool scope_is_comptime; |
| 28267 | if (!ir_resolve_bool(ira, block_comptime_inst, &scope_is_comptime)) | 29147 | if (!ir_resolve_bool(ira, block_comptime_inst, &scope_is_comptime)) |
| 28268 | return ira->codegen->invalid_instruction; | 29148 | return ira->codegen->invalid_inst_gen; |
| 28269 | | 29149 | |
| 28270 | IrInstruction *is_comptime_inst = instruction->is_comptime->child; | 29150 | IrInstGen *is_comptime_inst = instruction->is_comptime->child; |
| 28271 | bool is_comptime; | 29151 | bool is_comptime; |
| 28272 | if (!ir_resolve_bool(ira, is_comptime_inst, &is_comptime)) | 29152 | if (!ir_resolve_bool(ira, is_comptime_inst, &is_comptime)) |
| 28273 | return ira->codegen->invalid_instruction; | 29153 | return ira->codegen->invalid_inst_gen; |
| 28274 | | 29154 | |
| 28275 | if (!scope_is_comptime && is_comptime) { | 29155 | if (!scope_is_comptime && is_comptime) { |
| 28276 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, | 29156 | ErrorMsg *msg = ir_add_error(ira, &instruction->base.base, |
| 28277 | buf_sprintf("comptime control flow inside runtime block")); | 29157 | buf_sprintf("comptime control flow inside runtime block")); |
| 28278 | add_error_note(ira->codegen, msg, block_comptime_inst->source_node, | 29158 | add_error_note(ira->codegen, msg, block_comptime_inst->base.source_node, |
| 28279 | buf_sprintf("runtime block created here")); | 29159 | buf_sprintf("runtime block created here")); |
| 28280 | return ira->codegen->invalid_instruction; | 29160 | return ira->codegen->invalid_inst_gen; |
| 28281 | } | 29161 | } |
| 28282 | | 29162 | |
| 28283 | return ir_const_void(ira, &instruction->base); | 29163 | return ir_const_void(ira, &instruction->base.base); |
| 28284 | } | 29164 | } |
| 28285 | | 29165 | |
| 28286 | static IrInstruction *ir_analyze_instruction_has_decl(IrAnalyze *ira, IrInstructionHasDecl *instruction) { | 29166 | static IrInstGen *ir_analyze_instruction_has_decl(IrAnalyze *ira, IrInstSrcHasDecl *instruction) { |
| 28287 | ZigType *container_type = ir_resolve_type(ira, instruction->container->child); | 29167 | ZigType *container_type = ir_resolve_type(ira, instruction->container->child); |
| 28288 | if (type_is_invalid(container_type)) | 29168 | if (type_is_invalid(container_type)) |
| 28289 | return ira->codegen->invalid_instruction; | 29169 | return ira->codegen->invalid_inst_gen; |
| 28290 | | 29170 | |
| 28291 | Buf *name = ir_resolve_str(ira, instruction->name->child); | 29171 | Buf *name = ir_resolve_str(ira, instruction->name->child); |
| 28292 | if (name == nullptr) | 29172 | if (name == nullptr) |
| 28293 | return ira->codegen->invalid_instruction; | 29173 | return ira->codegen->invalid_inst_gen; |
| 28294 | | 29174 | |
| 28295 | if (!is_container(container_type)) { | 29175 | if (!is_container(container_type)) { |
| 28296 | ir_add_error(ira, instruction->container, | 29176 | ir_add_error(ira, &instruction->container->base, |
| 28297 | buf_sprintf("expected struct, enum, or union; found '%s'", buf_ptr(&container_type->name))); | 29177 | buf_sprintf("expected struct, enum, or union; found '%s'", buf_ptr(&container_type->name))); |
| 28298 | return ira->codegen->invalid_instruction; | 29178 | return ira->codegen->invalid_inst_gen; |
| 28299 | } | 29179 | } |
| 28300 | | 29180 | |
| 28301 | ScopeDecls *container_scope = get_container_scope(container_type); | 29181 | ScopeDecls *container_scope = get_container_scope(container_type); |
| 28302 | Tld *tld = find_container_decl(ira->codegen, container_scope, name); | 29182 | Tld *tld = find_container_decl(ira->codegen, container_scope, name); |
| 28303 | if (tld == nullptr) | 29183 | if (tld == nullptr) |
| 28304 | return ir_const_bool(ira, &instruction->base, false); | 29184 | return ir_const_bool(ira, &instruction->base.base, false); |
| 28305 | | 29185 | |
| 28306 | if (tld->visib_mod == VisibModPrivate && tld->import != get_scope_import(instruction->base.scope)) { | 29186 | if (tld->visib_mod == VisibModPrivate && tld->import != get_scope_import(instruction->base.base.scope)) { |
| 28307 | return ir_const_bool(ira, &instruction->base, false); | 29187 | return ir_const_bool(ira, &instruction->base.base, false); |
| 28308 | } | 29188 | } |
| 28309 | | 29189 | |
| 28310 | return ir_const_bool(ira, &instruction->base, true); | 29190 | return ir_const_bool(ira, &instruction->base.base, true); |
| 28311 | } | 29191 | } |
| 28312 | | 29192 | |
| 28313 | static IrInstruction *ir_analyze_instruction_undeclared_ident(IrAnalyze *ira, IrInstructionUndeclaredIdent *instruction) { | 29193 | static IrInstGen *ir_analyze_instruction_undeclared_ident(IrAnalyze *ira, IrInstSrcUndeclaredIdent *instruction) { |
| 28314 | // put a variable of same name with invalid type in global scope | 29194 | // put a variable of same name with invalid type in global scope |
| 28315 | // so that future references to this same name will find a variable with an invalid type | 29195 | // so that future references to this same name will find a variable with an invalid type |
| 28316 | populate_invalid_variable_in_scope(ira->codegen, instruction->base.scope, instruction->base.source_node, | 29196 | populate_invalid_variable_in_scope(ira->codegen, instruction->base.base.scope, |
| 28317 | instruction->name); | 29197 | instruction->base.base.source_node, instruction->name); |
| 28318 | ir_add_error(ira, &instruction->base, | 29198 | ir_add_error(ira, &instruction->base.base, |
| 28319 | buf_sprintf("use of undeclared identifier '%s'", buf_ptr(instruction->name))); | 29199 | buf_sprintf("use of undeclared identifier '%s'", buf_ptr(instruction->name))); |
| 28320 | return ira->codegen->invalid_instruction; | 29200 | return ira->codegen->invalid_inst_gen; |
| 28321 | } | 29201 | } |
| 28322 | | 29202 | |
| 28323 | static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstructionEndExpr *instruction) { | 29203 | static IrInstGen *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstSrcEndExpr *instruction) { |
| 28324 | IrInstruction *value = instruction->value->child; | 29204 | IrInstGen *value = instruction->value->child; |
| 28325 | if (type_is_invalid(value->value->type)) | 29205 | if (type_is_invalid(value->value->type)) |
| 28326 | return ira->codegen->invalid_instruction; | 29206 | return ira->codegen->invalid_inst_gen; |
| 28327 | | 29207 | |
| 28328 | bool was_written = instruction->result_loc->written; | 29208 | bool was_written = instruction->result_loc->written; |
| 28329 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 29209 | IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base.base, instruction->result_loc, |
| 28330 | value->value->type, value, false, true); | 29210 | value->value->type, value, false, true); |
| 28331 | if (result_loc != nullptr) { | 29211 | if (result_loc != nullptr) { |
| 28332 | if (type_is_invalid(result_loc->value->type)) | 29212 | if (type_is_invalid(result_loc->value->type)) |
| 28333 | return ira->codegen->invalid_instruction; | 29213 | return ira->codegen->invalid_inst_gen; |
| 28334 | if (result_loc->value->type->id == ZigTypeIdUnreachable) | 29214 | if (result_loc->value->type->id == ZigTypeIdUnreachable) |
| 28335 | return result_loc; | 29215 | return result_loc; |
| 28336 | | 29216 | |
| 28337 | if (!was_written || instruction->result_loc->id == ResultLocIdPeer) { | 29217 | if (!was_written || instruction->result_loc->id == ResultLocIdPeer) { |
| 28338 | IrInstruction *store_ptr = ir_analyze_store_ptr(ira, &instruction->base, result_loc, value, | 29218 | IrInstGen *store_ptr = ir_analyze_store_ptr(ira, &instruction->base.base, result_loc, value, |
| 28339 | instruction->result_loc->allow_write_through_const); | 29219 | instruction->result_loc->allow_write_through_const); |
| 28340 | if (type_is_invalid(store_ptr->value->type)) { | 29220 | if (type_is_invalid(store_ptr->value->type)) { |
| 28341 | return ira->codegen->invalid_instruction; | 29221 | return ira->codegen->invalid_inst_gen; |
| 28342 | } | 29222 | } |
| 28343 | } | 29223 | } |
| 28344 | | 29224 | |
| ... | @@ -28353,101 +29233,100 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct | ... | @@ -28353,101 +29233,100 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct |
| 28353 | } | 29233 | } |
| 28354 | } | 29234 | } |
| 28355 | | 29235 | |
| 28356 | return ir_const_void(ira, &instruction->base); | 29236 | return ir_const_void(ira, &instruction->base.base); |
| 28357 | } | 29237 | } |
| 28358 | | 29238 | |
| 28359 | static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrInstructionImplicitCast *instruction) { | 29239 | static IrInstGen *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrInstSrcImplicitCast *instruction) { |
| 28360 | IrInstruction *operand = instruction->operand->child; | 29240 | IrInstGen *operand = instruction->operand->child; |
| 28361 | if (type_is_invalid(operand->value->type)) | 29241 | if (type_is_invalid(operand->value->type)) |
| 28362 | return operand; | 29242 | return operand; |
| 28363 | | 29243 | |
| 28364 | ZigType *dest_type = ir_resolve_type(ira, instruction->result_loc_cast->base.source_instruction->child); | 29244 | ZigType *dest_type = ir_resolve_type(ira, instruction->result_loc_cast->base.source_instruction->child); |
| 28365 | if (type_is_invalid(dest_type)) | 29245 | if (type_is_invalid(dest_type)) |
| 28366 | return ira->codegen->invalid_instruction; | 29246 | return ira->codegen->invalid_inst_gen; |
| 28367 | return ir_implicit_cast2(ira, &instruction->base, operand, dest_type); | 29247 | return ir_implicit_cast2(ira, &instruction->base.base, operand, dest_type); |
| 28368 | } | 29248 | } |
| 28369 | | 29249 | |
| 28370 | static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInstructionBitCastSrc *instruction) { | 29250 | static IrInstGen *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInstSrcBitCast *instruction) { |
| 28371 | IrInstruction *operand = instruction->operand->child; | 29251 | IrInstGen *operand = instruction->operand->child; |
| 28372 | if (type_is_invalid(operand->value->type)) | 29252 | if (type_is_invalid(operand->value->type)) |
| 28373 | return operand; | 29253 | return operand; |
| 28374 | | 29254 | |
| 28375 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, | 29255 | IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base.base, |
| 28376 | &instruction->result_loc_bit_cast->base, operand->value->type, operand, false, true); | 29256 | &instruction->result_loc_bit_cast->base, operand->value->type, operand, false, true); |
| 28377 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) | 29257 | if (result_loc != nullptr && |
| | 29258 | (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable)) |
| | 29259 | { |
| 28378 | return result_loc; | 29260 | return result_loc; |
| | 29261 | } |
| 28379 | | 29262 | |
| 28380 | ZigType *dest_type = ir_resolve_type(ira, | 29263 | ZigType *dest_type = ir_resolve_type(ira, |
| 28381 | instruction->result_loc_bit_cast->base.source_instruction->child); | 29264 | instruction->result_loc_bit_cast->base.source_instruction->child); |
| 28382 | if (type_is_invalid(dest_type)) | 29265 | if (type_is_invalid(dest_type)) |
| 28383 | return ira->codegen->invalid_instruction; | 29266 | return ira->codegen->invalid_inst_gen; |
| 28384 | return ir_analyze_bit_cast(ira, &instruction->base, operand, dest_type); | 29267 | return ir_analyze_bit_cast(ira, &instruction->base.base, operand, dest_type); |
| 28385 | } | 29268 | } |
| 28386 | | 29269 | |
| 28387 | static IrInstruction *ir_analyze_instruction_union_init_named_field(IrAnalyze *ira, | 29270 | static IrInstGen *ir_analyze_instruction_union_init_named_field(IrAnalyze *ira, |
| 28388 | IrInstructionUnionInitNamedField *instruction) | 29271 | IrInstSrcUnionInitNamedField *instruction) |
| 28389 | { | 29272 | { |
| 28390 | ZigType *union_type = ir_resolve_type(ira, instruction->union_type->child); | 29273 | ZigType *union_type = ir_resolve_type(ira, instruction->union_type->child); |
| 28391 | if (type_is_invalid(union_type)) | 29274 | if (type_is_invalid(union_type)) |
| 28392 | return ira->codegen->invalid_instruction; | 29275 | return ira->codegen->invalid_inst_gen; |
| 28393 | | 29276 | |
| 28394 | if (union_type->id != ZigTypeIdUnion) { | 29277 | if (union_type->id != ZigTypeIdUnion) { |
| 28395 | ir_add_error(ira, instruction->union_type, | 29278 | ir_add_error(ira, &instruction->union_type->base, |
| 28396 | buf_sprintf("non-union type '%s' passed to @unionInit", buf_ptr(&union_type->name))); | 29279 | buf_sprintf("non-union type '%s' passed to @unionInit", buf_ptr(&union_type->name))); |
| 28397 | return ira->codegen->invalid_instruction; | 29280 | return ira->codegen->invalid_inst_gen; |
| 28398 | } | 29281 | } |
| 28399 | | 29282 | |
| 28400 | Buf *field_name = ir_resolve_str(ira, instruction->field_name->child); | 29283 | Buf *field_name = ir_resolve_str(ira, instruction->field_name->child); |
| 28401 | if (field_name == nullptr) | 29284 | if (field_name == nullptr) |
| 28402 | return ira->codegen->invalid_instruction; | 29285 | return ira->codegen->invalid_inst_gen; |
| 28403 | | 29286 | |
| 28404 | IrInstruction *field_result_loc = instruction->field_result_loc->child; | 29287 | IrInstGen *field_result_loc = instruction->field_result_loc->child; |
| 28405 | if (type_is_invalid(field_result_loc->value->type)) | 29288 | if (type_is_invalid(field_result_loc->value->type)) |
| 28406 | return ira->codegen->invalid_instruction; | 29289 | return ira->codegen->invalid_inst_gen; |
| 28407 | | 29290 | |
| 28408 | IrInstruction *result_loc = instruction->result_loc->child; | 29291 | IrInstGen *result_loc = instruction->result_loc->child; |
| 28409 | if (type_is_invalid(result_loc->value->type)) | 29292 | if (type_is_invalid(result_loc->value->type)) |
| 28410 | return ira->codegen->invalid_instruction; | 29293 | return ira->codegen->invalid_inst_gen; |
| 28411 | | 29294 | |
| 28412 | return ir_analyze_union_init(ira, &instruction->base, instruction->base.source_node, | 29295 | return ir_analyze_union_init(ira, &instruction->base.base, instruction->base.base.source_node, |
| 28413 | union_type, field_name, field_result_loc, result_loc); | 29296 | union_type, field_name, field_result_loc, result_loc); |
| 28414 | } | 29297 | } |
| 28415 | | 29298 | |
| 28416 | static IrInstruction *ir_analyze_instruction_suspend_begin(IrAnalyze *ira, IrInstructionSuspendBegin *instruction) { | 29299 | static IrInstGen *ir_analyze_instruction_suspend_begin(IrAnalyze *ira, IrInstSrcSuspendBegin *instruction) { |
| 28417 | IrInstructionSuspendBegin *result = ir_build_suspend_begin(&ira->new_irb, instruction->base.scope, | 29300 | return ir_build_suspend_begin_gen(ira, &instruction->base.base); |
| 28418 | instruction->base.source_node); | | |
| 28419 | return &result->base; | | |
| 28420 | } | 29301 | } |
| 28421 | | 29302 | |
| 28422 | static IrInstruction *ir_analyze_instruction_suspend_finish(IrAnalyze *ira, | 29303 | static IrInstGen *ir_analyze_instruction_suspend_finish(IrAnalyze *ira, IrInstSrcSuspendFinish *instruction) { |
| 28423 | IrInstructionSuspendFinish *instruction) | 29304 | IrInstGen *begin_base = instruction->begin->base.child; |
| 28424 | { | | |
| 28425 | IrInstruction *begin_base = instruction->begin->base.child; | | |
| 28426 | if (type_is_invalid(begin_base->value->type)) | 29305 | if (type_is_invalid(begin_base->value->type)) |
| 28427 | return ira->codegen->invalid_instruction; | 29306 | return ira->codegen->invalid_inst_gen; |
| 28428 | ir_assert(begin_base->id == IrInstructionIdSuspendBegin, &instruction->base); | 29307 | ir_assert(begin_base->id == IrInstGenIdSuspendBegin, &instruction->base.base); |
| 28429 | IrInstructionSuspendBegin *begin = reinterpret_cast<IrInstructionSuspendBegin *>(begin_base); | 29308 | IrInstGenSuspendBegin *begin = reinterpret_cast<IrInstGenSuspendBegin *>(begin_base); |
| 28430 | | 29309 | |
| 28431 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 29310 | ZigFn *fn_entry = ira->new_irb.exec->fn_entry; |
| 28432 | ir_assert(fn_entry != nullptr, &instruction->base); | 29311 | ir_assert(fn_entry != nullptr, &instruction->base.base); |
| 28433 | | 29312 | |
| 28434 | if (fn_entry->inferred_async_node == nullptr) { | 29313 | if (fn_entry->inferred_async_node == nullptr) { |
| 28435 | fn_entry->inferred_async_node = instruction->base.source_node; | 29314 | fn_entry->inferred_async_node = instruction->base.base.source_node; |
| 28436 | } | 29315 | } |
| 28437 | | 29316 | |
| 28438 | return ir_build_suspend_finish(&ira->new_irb, instruction->base.scope, instruction->base.source_node, begin); | 29317 | return ir_build_suspend_finish_gen(ira, &instruction->base.base, begin); |
| 28439 | } | 29318 | } |
| 28440 | | 29319 | |
| 28441 | static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruction *source_instr, | 29320 | static IrInstGen *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInst* source_instr, |
| 28442 | IrInstruction *frame_ptr, ZigFn **target_fn) | 29321 | IrInstGen *frame_ptr, ZigFn **target_fn) |
| 28443 | { | 29322 | { |
| 28444 | if (type_is_invalid(frame_ptr->value->type)) | 29323 | if (type_is_invalid(frame_ptr->value->type)) |
| 28445 | return ira->codegen->invalid_instruction; | 29324 | return ira->codegen->invalid_inst_gen; |
| 28446 | | 29325 | |
| 28447 | *target_fn = nullptr; | 29326 | *target_fn = nullptr; |
| 28448 | | 29327 | |
| 28449 | ZigType *result_type; | 29328 | ZigType *result_type; |
| 28450 | IrInstruction *frame; | 29329 | IrInstGen *frame; |
| 28451 | if (frame_ptr->value->type->id == ZigTypeIdPointer && | 29330 | if (frame_ptr->value->type->id == ZigTypeIdPointer && |
| 28452 | frame_ptr->value->type->data.pointer.ptr_len == PtrLenSingle && | 29331 | frame_ptr->value->type->data.pointer.ptr_len == PtrLenSingle && |
| 28453 | frame_ptr->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) | 29332 | frame_ptr->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) |
| ... | @@ -28470,38 +29349,38 @@ static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruct | ... | @@ -28470,38 +29349,38 @@ static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruct |
| 28470 | { | 29349 | { |
| 28471 | ir_add_error(ira, source_instr, | 29350 | ir_add_error(ira, source_instr, |
| 28472 | buf_sprintf("expected anyframe->T, found '%s'", buf_ptr(&frame->value->type->name))); | 29351 | buf_sprintf("expected anyframe->T, found '%s'", buf_ptr(&frame->value->type->name))); |
| 28473 | return ira->codegen->invalid_instruction; | 29352 | return ira->codegen->invalid_inst_gen; |
| 28474 | } else { | 29353 | } else { |
| 28475 | result_type = frame->value->type->data.any_frame.result_type; | 29354 | result_type = frame->value->type->data.any_frame.result_type; |
| 28476 | } | 29355 | } |
| 28477 | } | 29356 | } |
| 28478 | | 29357 | |
| 28479 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, result_type); | 29358 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, result_type); |
| 28480 | IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); | 29359 | IrInstGen *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); |
| 28481 | if (type_is_invalid(casted_frame->value->type)) | 29360 | if (type_is_invalid(casted_frame->value->type)) |
| 28482 | return ira->codegen->invalid_instruction; | 29361 | return ira->codegen->invalid_inst_gen; |
| 28483 | | 29362 | |
| 28484 | return casted_frame; | 29363 | return casted_frame; |
| 28485 | } | 29364 | } |
| 28486 | | 29365 | |
| 28487 | static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstructionAwaitSrc *instruction) { | 29366 | static IrInstGen *ir_analyze_instruction_await(IrAnalyze *ira, IrInstSrcAwait *instruction) { |
| 28488 | IrInstruction *operand = instruction->frame->child; | 29367 | IrInstGen *operand = instruction->frame->child; |
| 28489 | if (type_is_invalid(operand->value->type)) | 29368 | if (type_is_invalid(operand->value->type)) |
| 28490 | return ira->codegen->invalid_instruction; | 29369 | return ira->codegen->invalid_inst_gen; |
| 28491 | ZigFn *target_fn; | 29370 | ZigFn *target_fn; |
| 28492 | IrInstruction *frame = analyze_frame_ptr_to_anyframe_T(ira, &instruction->base, operand, &target_fn); | 29371 | IrInstGen *frame = analyze_frame_ptr_to_anyframe_T(ira, &instruction->base.base, operand, &target_fn); |
| 28493 | if (type_is_invalid(frame->value->type)) | 29372 | if (type_is_invalid(frame->value->type)) |
| 28494 | return ira->codegen->invalid_instruction; | 29373 | return ira->codegen->invalid_inst_gen; |
| 28495 | | 29374 | |
| 28496 | ZigType *result_type = frame->value->type->data.any_frame.result_type; | 29375 | ZigType *result_type = frame->value->type->data.any_frame.result_type; |
| 28497 | | 29376 | |
| 28498 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 29377 | ZigFn *fn_entry = ira->new_irb.exec->fn_entry; |
| 28499 | ir_assert(fn_entry != nullptr, &instruction->base); | 29378 | ir_assert(fn_entry != nullptr, &instruction->base.base); |
| 28500 | | 29379 | |
| 28501 | // If it's not @Frame(func) then it's definitely a suspend point | 29380 | // If it's not @Frame(func) then it's definitely a suspend point |
| 28502 | if (target_fn == nullptr) { | 29381 | if (target_fn == nullptr) { |
| 28503 | if (fn_entry->inferred_async_node == nullptr) { | 29382 | if (fn_entry->inferred_async_node == nullptr) { |
| 28504 | fn_entry->inferred_async_node = instruction->base.source_node; | 29383 | fn_entry->inferred_async_node = instruction->base.base.source_node; |
| 28505 | } | 29384 | } |
| 28506 | } | 29385 | } |
| 28507 | | 29386 | |
| ... | @@ -28509,401 +29388,367 @@ static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstruction | ... | @@ -28509,401 +29388,367 @@ static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstruction |
| 28509 | fn_entry->calls_or_awaits_errorable_fn = true; | 29388 | fn_entry->calls_or_awaits_errorable_fn = true; |
| 28510 | } | 29389 | } |
| 28511 | | 29390 | |
| 28512 | IrInstruction *result_loc; | 29391 | IrInstGen *result_loc; |
| 28513 | if (type_has_bits(result_type)) { | 29392 | if (type_has_bits(result_type)) { |
| 28514 | result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 29393 | result_loc = ir_resolve_result(ira, &instruction->base.base, instruction->result_loc, |
| 28515 | result_type, nullptr, true, true); | 29394 | result_type, nullptr, true, true); |
| 28516 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) | 29395 | if (result_loc != nullptr && |
| | 29396 | (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable)) |
| | 29397 | { |
| 28517 | return result_loc; | 29398 | return result_loc; |
| | 29399 | } |
| 28518 | } else { | 29400 | } else { |
| 28519 | result_loc = nullptr; | 29401 | result_loc = nullptr; |
| 28520 | } | 29402 | } |
| 28521 | | 29403 | |
| 28522 | IrInstructionAwaitGen *result = ir_build_await_gen(ira, &instruction->base, frame, result_type, result_loc); | 29404 | IrInstGenAwait *result = ir_build_await_gen(ira, &instruction->base.base, frame, result_type, result_loc); |
| 28523 | result->target_fn = target_fn; | 29405 | result->target_fn = target_fn; |
| 28524 | fn_entry->await_list.append(result); | 29406 | fn_entry->await_list.append(result); |
| 28525 | return ir_finish_anal(ira, &result->base); | 29407 | return ir_finish_anal(ira, &result->base); |
| 28526 | } | 29408 | } |
| 28527 | | 29409 | |
| 28528 | static IrInstruction *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstructionResume *instruction) { | 29410 | static IrInstGen *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstSrcResume *instruction) { |
| 28529 | IrInstruction *frame_ptr = instruction->frame->child; | 29411 | IrInstGen *frame_ptr = instruction->frame->child; |
| 28530 | if (type_is_invalid(frame_ptr->value->type)) | 29412 | if (type_is_invalid(frame_ptr->value->type)) |
| 28531 | return ira->codegen->invalid_instruction; | 29413 | return ira->codegen->invalid_inst_gen; |
| 28532 | | 29414 | |
| 28533 | IrInstruction *frame; | 29415 | IrInstGen *frame; |
| 28534 | if (frame_ptr->value->type->id == ZigTypeIdPointer && | 29416 | if (frame_ptr->value->type->id == ZigTypeIdPointer && |
| 28535 | frame_ptr->value->type->data.pointer.ptr_len == PtrLenSingle && | 29417 | frame_ptr->value->type->data.pointer.ptr_len == PtrLenSingle && |
| 28536 | frame_ptr->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) | 29418 | frame_ptr->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) |
| 28537 | { | 29419 | { |
| 28538 | frame = frame_ptr; | 29420 | frame = frame_ptr; |
| 28539 | } else { | 29421 | } else { |
| 28540 | frame = ir_get_deref(ira, &instruction->base, frame_ptr, nullptr); | 29422 | frame = ir_get_deref(ira, &instruction->base.base, frame_ptr, nullptr); |
| 28541 | } | 29423 | } |
| 28542 | | 29424 | |
| 28543 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, nullptr); | 29425 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, nullptr); |
| 28544 | IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); | 29426 | IrInstGen *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); |
| 28545 | if (type_is_invalid(casted_frame->value->type)) | 29427 | if (type_is_invalid(casted_frame->value->type)) |
| 28546 | return ira->codegen->invalid_instruction; | 29428 | return ira->codegen->invalid_inst_gen; |
| 28547 | | 29429 | |
| 28548 | return ir_build_resume(&ira->new_irb, instruction->base.scope, instruction->base.source_node, casted_frame); | 29430 | return ir_build_resume_gen(ira, &instruction->base.base, casted_frame); |
| 28549 | } | 29431 | } |
| 28550 | | 29432 | |
| 28551 | static IrInstruction *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstructionSpillBegin *instruction) { | 29433 | static IrInstGen *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstSrcSpillBegin *instruction) { |
| 28552 | if (ir_should_inline(ira->new_irb.exec, instruction->base.scope)) | 29434 | if (ir_should_inline(ira->old_irb.exec, instruction->base.base.scope)) |
| 28553 | return ir_const_void(ira, &instruction->base); | 29435 | return ir_const_void(ira, &instruction->base.base); |
| 28554 | | 29436 | |
| 28555 | IrInstruction *operand = instruction->operand->child; | 29437 | IrInstGen *operand = instruction->operand->child; |
| 28556 | if (type_is_invalid(operand->value->type)) | 29438 | if (type_is_invalid(operand->value->type)) |
| 28557 | return ira->codegen->invalid_instruction; | 29439 | return ira->codegen->invalid_inst_gen; |
| 28558 | | 29440 | |
| 28559 | if (!type_has_bits(operand->value->type)) | 29441 | if (!type_has_bits(operand->value->type)) |
| 28560 | return ir_const_void(ira, &instruction->base); | 29442 | return ir_const_void(ira, &instruction->base.base); |
| 28561 | | 29443 | |
| 28562 | ir_assert(instruction->spill_id == SpillIdRetErrCode, &instruction->base); | 29444 | ir_assert(instruction->spill_id == SpillIdRetErrCode, &instruction->base.base); |
| 28563 | ira->new_irb.exec->need_err_code_spill = true; | 29445 | ira->new_irb.exec->need_err_code_spill = true; |
| 28564 | | 29446 | |
| 28565 | IrInstructionSpillBegin *result = ir_build_spill_begin(&ira->new_irb, instruction->base.scope, | 29447 | return ir_build_spill_begin_gen(ira, &instruction->base.base, operand, instruction->spill_id); |
| 28566 | instruction->base.source_node, operand, instruction->spill_id); | | |
| 28567 | return &result->base; | | |
| 28568 | } | 29448 | } |
| 28569 | | 29449 | |
| 28570 | static IrInstruction *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstructionSpillEnd *instruction) { | 29450 | static IrInstGen *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstSrcSpillEnd *instruction) { |
| 28571 | IrInstruction *operand = instruction->begin->operand->child; | 29451 | IrInstGen *operand = instruction->begin->operand->child; |
| 28572 | if (type_is_invalid(operand->value->type)) | 29452 | if (type_is_invalid(operand->value->type)) |
| 28573 | return ira->codegen->invalid_instruction; | 29453 | return ira->codegen->invalid_inst_gen; |
| 28574 | | 29454 | |
| 28575 | if (ir_should_inline(ira->new_irb.exec, instruction->base.scope) || !type_has_bits(operand->value->type)) | 29455 | if (ir_should_inline(ira->old_irb.exec, instruction->base.base.scope) || !type_has_bits(operand->value->type)) |
| 28576 | return operand; | 29456 | return operand; |
| 28577 | | 29457 | |
| 28578 | ir_assert(instruction->begin->base.child->id == IrInstructionIdSpillBegin, &instruction->base); | 29458 | ir_assert(instruction->begin->base.child->id == IrInstGenIdSpillBegin, &instruction->base.base); |
| 28579 | IrInstructionSpillBegin *begin = reinterpret_cast<IrInstructionSpillBegin *>(instruction->begin->base.child); | 29459 | IrInstGenSpillBegin *begin = reinterpret_cast<IrInstGenSpillBegin *>(instruction->begin->base.child); |
| 28580 | | 29460 | |
| 28581 | IrInstruction *result = ir_build_spill_end(&ira->new_irb, instruction->base.scope, | 29461 | return ir_build_spill_end_gen(ira, &instruction->base.base, begin, operand->value->type); |
| 28582 | instruction->base.source_node, begin); | | |
| 28583 | result->value->type = operand->value->type; | | |
| 28584 | return result; | | |
| 28585 | } | 29462 | } |
| 28586 | | 29463 | |
| 28587 | static IrInstruction *ir_analyze_instruction_base(IrAnalyze *ira, IrInstruction *instruction) { | 29464 | static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruction) { |
| 28588 | switch (instruction->id) { | 29465 | switch (instruction->id) { |
| 28589 | case IrInstructionIdInvalid: | 29466 | case IrInstSrcIdInvalid: |
| 28590 | case IrInstructionIdWidenOrShorten: | | |
| 28591 | case IrInstructionIdStructFieldPtr: | | |
| 28592 | case IrInstructionIdUnionFieldPtr: | | |
| 28593 | case IrInstructionIdOptionalWrap: | | |
| 28594 | case IrInstructionIdErrWrapCode: | | |
| 28595 | case IrInstructionIdErrWrapPayload: | | |
| 28596 | case IrInstructionIdCast: | | |
| 28597 | case IrInstructionIdDeclVarGen: | | |
| 28598 | case IrInstructionIdPtrCastGen: | | |
| 28599 | case IrInstructionIdCmpxchgGen: | | |
| 28600 | case IrInstructionIdArrayToVector: | | |
| 28601 | case IrInstructionIdVectorToArray: | | |
| 28602 | case IrInstructionIdPtrOfArrayToSlice: | | |
| 28603 | case IrInstructionIdAssertZero: | | |
| 28604 | case IrInstructionIdAssertNonNull: | | |
| 28605 | case IrInstructionIdResizeSlice: | | |
| 28606 | case IrInstructionIdLoadPtrGen: | | |
| 28607 | case IrInstructionIdBitCastGen: | | |
| 28608 | case IrInstructionIdCallGen: | | |
| 28609 | case IrInstructionIdReturnPtr: | | |
| 28610 | case IrInstructionIdAllocaGen: | | |
| 28611 | case IrInstructionIdSliceGen: | | |
| 28612 | case IrInstructionIdRefGen: | | |
| 28613 | case IrInstructionIdTestErrGen: | | |
| 28614 | case IrInstructionIdFrameSizeGen: | | |
| 28615 | case IrInstructionIdAwaitGen: | | |
| 28616 | case IrInstructionIdSplatGen: | | |
| 28617 | case IrInstructionIdVectorExtractElem: | | |
| 28618 | case IrInstructionIdVectorStoreElem: | | |
| 28619 | case IrInstructionIdAsmGen: | | |
| 28620 | zig_unreachable(); | 29467 | zig_unreachable(); |
| 28621 | | 29468 | |
| 28622 | case IrInstructionIdReturn: | 29469 | case IrInstSrcIdReturn: |
| 28623 | return ir_analyze_instruction_return(ira, (IrInstructionReturn *)instruction); | 29470 | return ir_analyze_instruction_return(ira, (IrInstSrcReturn *)instruction); |
| 28624 | case IrInstructionIdConst: | 29471 | case IrInstSrcIdConst: |
| 28625 | return ir_analyze_instruction_const(ira, (IrInstructionConst *)instruction); | 29472 | return ir_analyze_instruction_const(ira, (IrInstSrcConst *)instruction); |
| 28626 | case IrInstructionIdUnOp: | 29473 | case IrInstSrcIdUnOp: |
| 28627 | return ir_analyze_instruction_un_op(ira, (IrInstructionUnOp *)instruction); | 29474 | return ir_analyze_instruction_un_op(ira, (IrInstSrcUnOp *)instruction); |
| 28628 | case IrInstructionIdBinOp: | 29475 | case IrInstSrcIdBinOp: |
| 28629 | return ir_analyze_instruction_bin_op(ira, (IrInstructionBinOp *)instruction); | 29476 | return ir_analyze_instruction_bin_op(ira, (IrInstSrcBinOp *)instruction); |
| 28630 | case IrInstructionIdMergeErrSets: | 29477 | case IrInstSrcIdMergeErrSets: |
| 28631 | return ir_analyze_instruction_merge_err_sets(ira, (IrInstructionMergeErrSets *)instruction); | 29478 | return ir_analyze_instruction_merge_err_sets(ira, (IrInstSrcMergeErrSets *)instruction); |
| 28632 | case IrInstructionIdDeclVarSrc: | 29479 | case IrInstSrcIdDeclVar: |
| 28633 | return ir_analyze_instruction_decl_var(ira, (IrInstructionDeclVarSrc *)instruction); | 29480 | return ir_analyze_instruction_decl_var(ira, (IrInstSrcDeclVar *)instruction); |
| 28634 | case IrInstructionIdLoadPtr: | 29481 | case IrInstSrcIdLoadPtr: |
| 28635 | return ir_analyze_instruction_load_ptr(ira, (IrInstructionLoadPtr *)instruction); | 29482 | return ir_analyze_instruction_load_ptr(ira, (IrInstSrcLoadPtr *)instruction); |
| 28636 | case IrInstructionIdStorePtr: | 29483 | case IrInstSrcIdStorePtr: |
| 28637 | return ir_analyze_instruction_store_ptr(ira, (IrInstructionStorePtr *)instruction); | 29484 | return ir_analyze_instruction_store_ptr(ira, (IrInstSrcStorePtr *)instruction); |
| 28638 | case IrInstructionIdElemPtr: | 29485 | case IrInstSrcIdElemPtr: |
| 28639 | return ir_analyze_instruction_elem_ptr(ira, (IrInstructionElemPtr *)instruction); | 29486 | return ir_analyze_instruction_elem_ptr(ira, (IrInstSrcElemPtr *)instruction); |
| 28640 | case IrInstructionIdVarPtr: | 29487 | case IrInstSrcIdVarPtr: |
| 28641 | return ir_analyze_instruction_var_ptr(ira, (IrInstructionVarPtr *)instruction); | 29488 | return ir_analyze_instruction_var_ptr(ira, (IrInstSrcVarPtr *)instruction); |
| 28642 | case IrInstructionIdFieldPtr: | 29489 | case IrInstSrcIdFieldPtr: |
| 28643 | return ir_analyze_instruction_field_ptr(ira, (IrInstructionFieldPtr *)instruction); | 29490 | return ir_analyze_instruction_field_ptr(ira, (IrInstSrcFieldPtr *)instruction); |
| 28644 | case IrInstructionIdCallSrc: | 29491 | case IrInstSrcIdCall: |
| 28645 | return ir_analyze_instruction_call(ira, (IrInstructionCallSrc *)instruction); | 29492 | return ir_analyze_instruction_call(ira, (IrInstSrcCall *)instruction); |
| 28646 | case IrInstructionIdCallSrcArgs: | 29493 | case IrInstSrcIdCallArgs: |
| 28647 | return ir_analyze_instruction_call_args(ira, (IrInstructionCallSrcArgs *)instruction); | 29494 | return ir_analyze_instruction_call_args(ira, (IrInstSrcCallArgs *)instruction); |
| 28648 | case IrInstructionIdCallExtra: | 29495 | case IrInstSrcIdCallExtra: |
| 28649 | return ir_analyze_instruction_call_extra(ira, (IrInstructionCallExtra *)instruction); | 29496 | return ir_analyze_instruction_call_extra(ira, (IrInstSrcCallExtra *)instruction); |
| 28650 | case IrInstructionIdBr: | 29497 | case IrInstSrcIdBr: |
| 28651 | return ir_analyze_instruction_br(ira, (IrInstructionBr *)instruction); | 29498 | return ir_analyze_instruction_br(ira, (IrInstSrcBr *)instruction); |
| 28652 | case IrInstructionIdCondBr: | 29499 | case IrInstSrcIdCondBr: |
| 28653 | return ir_analyze_instruction_cond_br(ira, (IrInstructionCondBr *)instruction); | 29500 | return ir_analyze_instruction_cond_br(ira, (IrInstSrcCondBr *)instruction); |
| 28654 | case IrInstructionIdUnreachable: | 29501 | case IrInstSrcIdUnreachable: |
| 28655 | return ir_analyze_instruction_unreachable(ira, (IrInstructionUnreachable *)instruction); | 29502 | return ir_analyze_instruction_unreachable(ira, (IrInstSrcUnreachable *)instruction); |
| 28656 | case IrInstructionIdPhi: | 29503 | case IrInstSrcIdPhi: |
| 28657 | return ir_analyze_instruction_phi(ira, (IrInstructionPhi *)instruction); | 29504 | return ir_analyze_instruction_phi(ira, (IrInstSrcPhi *)instruction); |
| 28658 | case IrInstructionIdTypeOf: | 29505 | case IrInstSrcIdTypeOf: |
| 28659 | return ir_analyze_instruction_typeof(ira, (IrInstructionTypeOf *)instruction); | 29506 | return ir_analyze_instruction_typeof(ira, (IrInstSrcTypeOf *)instruction); |
| 28660 | case IrInstructionIdSetCold: | 29507 | case IrInstSrcIdSetCold: |
| 28661 | return ir_analyze_instruction_set_cold(ira, (IrInstructionSetCold *)instruction); | 29508 | return ir_analyze_instruction_set_cold(ira, (IrInstSrcSetCold *)instruction); |
| 28662 | case IrInstructionIdSetRuntimeSafety: | 29509 | case IrInstSrcIdSetRuntimeSafety: |
| 28663 | return ir_analyze_instruction_set_runtime_safety(ira, (IrInstructionSetRuntimeSafety *)instruction); | 29510 | return ir_analyze_instruction_set_runtime_safety(ira, (IrInstSrcSetRuntimeSafety *)instruction); |
| 28664 | case IrInstructionIdSetFloatMode: | 29511 | case IrInstSrcIdSetFloatMode: |
| 28665 | return ir_analyze_instruction_set_float_mode(ira, (IrInstructionSetFloatMode *)instruction); | 29512 | return ir_analyze_instruction_set_float_mode(ira, (IrInstSrcSetFloatMode *)instruction); |
| 28666 | case IrInstructionIdAnyFrameType: | 29513 | case IrInstSrcIdAnyFrameType: |
| 28667 | return ir_analyze_instruction_any_frame_type(ira, (IrInstructionAnyFrameType *)instruction); | 29514 | return ir_analyze_instruction_any_frame_type(ira, (IrInstSrcAnyFrameType *)instruction); |
| 28668 | case IrInstructionIdSliceType: | 29515 | case IrInstSrcIdSliceType: |
| 28669 | return ir_analyze_instruction_slice_type(ira, (IrInstructionSliceType *)instruction); | 29516 | return ir_analyze_instruction_slice_type(ira, (IrInstSrcSliceType *)instruction); |
| 28670 | case IrInstructionIdAsmSrc: | 29517 | case IrInstSrcIdAsm: |
| 28671 | return ir_analyze_instruction_asm(ira, (IrInstructionAsmSrc *)instruction); | 29518 | return ir_analyze_instruction_asm(ira, (IrInstSrcAsm *)instruction); |
| 28672 | case IrInstructionIdArrayType: | 29519 | case IrInstSrcIdArrayType: |
| 28673 | return ir_analyze_instruction_array_type(ira, (IrInstructionArrayType *)instruction); | 29520 | return ir_analyze_instruction_array_type(ira, (IrInstSrcArrayType *)instruction); |
| 28674 | case IrInstructionIdSizeOf: | 29521 | case IrInstSrcIdSizeOf: |
| 28675 | return ir_analyze_instruction_size_of(ira, (IrInstructionSizeOf *)instruction); | 29522 | return ir_analyze_instruction_size_of(ira, (IrInstSrcSizeOf *)instruction); |
| 28676 | case IrInstructionIdTestNonNull: | 29523 | case IrInstSrcIdTestNonNull: |
| 28677 | return ir_analyze_instruction_test_non_null(ira, (IrInstructionTestNonNull *)instruction); | 29524 | return ir_analyze_instruction_test_non_null(ira, (IrInstSrcTestNonNull *)instruction); |
| 28678 | case IrInstructionIdOptionalUnwrapPtr: | 29525 | case IrInstSrcIdOptionalUnwrapPtr: |
| 28679 | return ir_analyze_instruction_optional_unwrap_ptr(ira, (IrInstructionOptionalUnwrapPtr *)instruction); | 29526 | return ir_analyze_instruction_optional_unwrap_ptr(ira, (IrInstSrcOptionalUnwrapPtr *)instruction); |
| 28680 | case IrInstructionIdClz: | 29527 | case IrInstSrcIdClz: |
| 28681 | return ir_analyze_instruction_clz(ira, (IrInstructionClz *)instruction); | 29528 | return ir_analyze_instruction_clz(ira, (IrInstSrcClz *)instruction); |
| 28682 | case IrInstructionIdCtz: | 29529 | case IrInstSrcIdCtz: |
| 28683 | return ir_analyze_instruction_ctz(ira, (IrInstructionCtz *)instruction); | 29530 | return ir_analyze_instruction_ctz(ira, (IrInstSrcCtz *)instruction); |
| 28684 | case IrInstructionIdPopCount: | 29531 | case IrInstSrcIdPopCount: |
| 28685 | return ir_analyze_instruction_pop_count(ira, (IrInstructionPopCount *)instruction); | 29532 | return ir_analyze_instruction_pop_count(ira, (IrInstSrcPopCount *)instruction); |
| 28686 | case IrInstructionIdBswap: | 29533 | case IrInstSrcIdBswap: |
| 28687 | return ir_analyze_instruction_bswap(ira, (IrInstructionBswap *)instruction); | 29534 | return ir_analyze_instruction_bswap(ira, (IrInstSrcBswap *)instruction); |
| 28688 | case IrInstructionIdBitReverse: | 29535 | case IrInstSrcIdBitReverse: |
| 28689 | return ir_analyze_instruction_bit_reverse(ira, (IrInstructionBitReverse *)instruction); | 29536 | return ir_analyze_instruction_bit_reverse(ira, (IrInstSrcBitReverse *)instruction); |
| 28690 | case IrInstructionIdSwitchBr: | 29537 | case IrInstSrcIdSwitchBr: |
| 28691 | return ir_analyze_instruction_switch_br(ira, (IrInstructionSwitchBr *)instruction); | 29538 | return ir_analyze_instruction_switch_br(ira, (IrInstSrcSwitchBr *)instruction); |
| 28692 | case IrInstructionIdSwitchTarget: | 29539 | case IrInstSrcIdSwitchTarget: |
| 28693 | return ir_analyze_instruction_switch_target(ira, (IrInstructionSwitchTarget *)instruction); | 29540 | return ir_analyze_instruction_switch_target(ira, (IrInstSrcSwitchTarget *)instruction); |
| 28694 | case IrInstructionIdSwitchVar: | 29541 | case IrInstSrcIdSwitchVar: |
| 28695 | return ir_analyze_instruction_switch_var(ira, (IrInstructionSwitchVar *)instruction); | 29542 | return ir_analyze_instruction_switch_var(ira, (IrInstSrcSwitchVar *)instruction); |
| 28696 | case IrInstructionIdSwitchElseVar: | 29543 | case IrInstSrcIdSwitchElseVar: |
| 28697 | return ir_analyze_instruction_switch_else_var(ira, (IrInstructionSwitchElseVar *)instruction); | 29544 | return ir_analyze_instruction_switch_else_var(ira, (IrInstSrcSwitchElseVar *)instruction); |
| 28698 | case IrInstructionIdUnionTag: | 29545 | case IrInstSrcIdImport: |
| 28699 | return ir_analyze_instruction_union_tag(ira, (IrInstructionUnionTag *)instruction); | 29546 | return ir_analyze_instruction_import(ira, (IrInstSrcImport *)instruction); |
| 28700 | case IrInstructionIdImport: | 29547 | case IrInstSrcIdRef: |
| 28701 | return ir_analyze_instruction_import(ira, (IrInstructionImport *)instruction); | 29548 | return ir_analyze_instruction_ref(ira, (IrInstSrcRef *)instruction); |
| 28702 | case IrInstructionIdRef: | 29549 | case IrInstSrcIdContainerInitList: |
| 28703 | return ir_analyze_instruction_ref(ira, (IrInstructionRef *)instruction); | 29550 | return ir_analyze_instruction_container_init_list(ira, (IrInstSrcContainerInitList *)instruction); |
| 28704 | case IrInstructionIdContainerInitList: | 29551 | case IrInstSrcIdContainerInitFields: |
| 28705 | return ir_analyze_instruction_container_init_list(ira, (IrInstructionContainerInitList *)instruction); | 29552 | return ir_analyze_instruction_container_init_fields(ira, (IrInstSrcContainerInitFields *)instruction); |
| 28706 | case IrInstructionIdContainerInitFields: | 29553 | case IrInstSrcIdCompileErr: |
| 28707 | return ir_analyze_instruction_container_init_fields(ira, (IrInstructionContainerInitFields *)instruction); | 29554 | return ir_analyze_instruction_compile_err(ira, (IrInstSrcCompileErr *)instruction); |
| 28708 | case IrInstructionIdCompileErr: | 29555 | case IrInstSrcIdCompileLog: |
| 28709 | return ir_analyze_instruction_compile_err(ira, (IrInstructionCompileErr *)instruction); | 29556 | return ir_analyze_instruction_compile_log(ira, (IrInstSrcCompileLog *)instruction); |
| 28710 | case IrInstructionIdCompileLog: | 29557 | case IrInstSrcIdErrName: |
| 28711 | return ir_analyze_instruction_compile_log(ira, (IrInstructionCompileLog *)instruction); | 29558 | return ir_analyze_instruction_err_name(ira, (IrInstSrcErrName *)instruction); |
| 28712 | case IrInstructionIdErrName: | 29559 | case IrInstSrcIdTypeName: |
| 28713 | return ir_analyze_instruction_err_name(ira, (IrInstructionErrName *)instruction); | 29560 | return ir_analyze_instruction_type_name(ira, (IrInstSrcTypeName *)instruction); |
| 28714 | case IrInstructionIdTypeName: | 29561 | case IrInstSrcIdCImport: |
| 28715 | return ir_analyze_instruction_type_name(ira, (IrInstructionTypeName *)instruction); | 29562 | return ir_analyze_instruction_c_import(ira, (IrInstSrcCImport *)instruction); |
| 28716 | case IrInstructionIdCImport: | 29563 | case IrInstSrcIdCInclude: |
| 28717 | return ir_analyze_instruction_c_import(ira, (IrInstructionCImport *)instruction); | 29564 | return ir_analyze_instruction_c_include(ira, (IrInstSrcCInclude *)instruction); |
| 28718 | case IrInstructionIdCInclude: | 29565 | case IrInstSrcIdCDefine: |
| 28719 | return ir_analyze_instruction_c_include(ira, (IrInstructionCInclude *)instruction); | 29566 | return ir_analyze_instruction_c_define(ira, (IrInstSrcCDefine *)instruction); |
| 28720 | case IrInstructionIdCDefine: | 29567 | case IrInstSrcIdCUndef: |
| 28721 | return ir_analyze_instruction_c_define(ira, (IrInstructionCDefine *)instruction); | 29568 | return ir_analyze_instruction_c_undef(ira, (IrInstSrcCUndef *)instruction); |
| 28722 | case IrInstructionIdCUndef: | 29569 | case IrInstSrcIdEmbedFile: |
| 28723 | return ir_analyze_instruction_c_undef(ira, (IrInstructionCUndef *)instruction); | 29570 | return ir_analyze_instruction_embed_file(ira, (IrInstSrcEmbedFile *)instruction); |
| 28724 | case IrInstructionIdEmbedFile: | 29571 | case IrInstSrcIdCmpxchg: |
| 28725 | return ir_analyze_instruction_embed_file(ira, (IrInstructionEmbedFile *)instruction); | 29572 | return ir_analyze_instruction_cmpxchg(ira, (IrInstSrcCmpxchg *)instruction); |
| 28726 | case IrInstructionIdCmpxchgSrc: | 29573 | case IrInstSrcIdFence: |
| 28727 | return ir_analyze_instruction_cmpxchg(ira, (IrInstructionCmpxchgSrc *)instruction); | 29574 | return ir_analyze_instruction_fence(ira, (IrInstSrcFence *)instruction); |
| 28728 | case IrInstructionIdFence: | 29575 | case IrInstSrcIdTruncate: |
| 28729 | return ir_analyze_instruction_fence(ira, (IrInstructionFence *)instruction); | 29576 | return ir_analyze_instruction_truncate(ira, (IrInstSrcTruncate *)instruction); |
| 28730 | case IrInstructionIdTruncate: | 29577 | case IrInstSrcIdIntCast: |
| 28731 | return ir_analyze_instruction_truncate(ira, (IrInstructionTruncate *)instruction); | 29578 | return ir_analyze_instruction_int_cast(ira, (IrInstSrcIntCast *)instruction); |
| 28732 | case IrInstructionIdIntCast: | 29579 | case IrInstSrcIdFloatCast: |
| 28733 | return ir_analyze_instruction_int_cast(ira, (IrInstructionIntCast *)instruction); | 29580 | return ir_analyze_instruction_float_cast(ira, (IrInstSrcFloatCast *)instruction); |
| 28734 | case IrInstructionIdFloatCast: | 29581 | case IrInstSrcIdErrSetCast: |
| 28735 | return ir_analyze_instruction_float_cast(ira, (IrInstructionFloatCast *)instruction); | 29582 | return ir_analyze_instruction_err_set_cast(ira, (IrInstSrcErrSetCast *)instruction); |
| 28736 | case IrInstructionIdErrSetCast: | 29583 | case IrInstSrcIdFromBytes: |
| 28737 | return ir_analyze_instruction_err_set_cast(ira, (IrInstructionErrSetCast *)instruction); | 29584 | return ir_analyze_instruction_from_bytes(ira, (IrInstSrcFromBytes *)instruction); |
| 28738 | case IrInstructionIdFromBytes: | 29585 | case IrInstSrcIdToBytes: |
| 28739 | return ir_analyze_instruction_from_bytes(ira, (IrInstructionFromBytes *)instruction); | 29586 | return ir_analyze_instruction_to_bytes(ira, (IrInstSrcToBytes *)instruction); |
| 28740 | case IrInstructionIdToBytes: | 29587 | case IrInstSrcIdIntToFloat: |
| 28741 | return ir_analyze_instruction_to_bytes(ira, (IrInstructionToBytes *)instruction); | 29588 | return ir_analyze_instruction_int_to_float(ira, (IrInstSrcIntToFloat *)instruction); |
| 28742 | case IrInstructionIdIntToFloat: | 29589 | case IrInstSrcIdFloatToInt: |
| 28743 | return ir_analyze_instruction_int_to_float(ira, (IrInstructionIntToFloat *)instruction); | 29590 | return ir_analyze_instruction_float_to_int(ira, (IrInstSrcFloatToInt *)instruction); |
| 28744 | case IrInstructionIdFloatToInt: | 29591 | case IrInstSrcIdBoolToInt: |
| 28745 | return ir_analyze_instruction_float_to_int(ira, (IrInstructionFloatToInt *)instruction); | 29592 | return ir_analyze_instruction_bool_to_int(ira, (IrInstSrcBoolToInt *)instruction); |
| 28746 | case IrInstructionIdBoolToInt: | 29593 | case IrInstSrcIdIntType: |
| 28747 | return ir_analyze_instruction_bool_to_int(ira, (IrInstructionBoolToInt *)instruction); | 29594 | return ir_analyze_instruction_int_type(ira, (IrInstSrcIntType *)instruction); |
| 28748 | case IrInstructionIdIntType: | 29595 | case IrInstSrcIdVectorType: |
| 28749 | return ir_analyze_instruction_int_type(ira, (IrInstructionIntType *)instruction); | 29596 | return ir_analyze_instruction_vector_type(ira, (IrInstSrcVectorType *)instruction); |
| 28750 | case IrInstructionIdVectorType: | 29597 | case IrInstSrcIdShuffleVector: |
| 28751 | return ir_analyze_instruction_vector_type(ira, (IrInstructionVectorType *)instruction); | 29598 | return ir_analyze_instruction_shuffle_vector(ira, (IrInstSrcShuffleVector *)instruction); |
| 28752 | case IrInstructionIdShuffleVector: | 29599 | case IrInstSrcIdSplat: |
| 28753 | return ir_analyze_instruction_shuffle_vector(ira, (IrInstructionShuffleVector *)instruction); | 29600 | return ir_analyze_instruction_splat(ira, (IrInstSrcSplat *)instruction); |
| 28754 | case IrInstructionIdSplatSrc: | 29601 | case IrInstSrcIdBoolNot: |
| 28755 | return ir_analyze_instruction_splat(ira, (IrInstructionSplatSrc *)instruction); | 29602 | return ir_analyze_instruction_bool_not(ira, (IrInstSrcBoolNot *)instruction); |
| 28756 | case IrInstructionIdBoolNot: | 29603 | case IrInstSrcIdMemset: |
| 28757 | return ir_analyze_instruction_bool_not(ira, (IrInstructionBoolNot *)instruction); | 29604 | return ir_analyze_instruction_memset(ira, (IrInstSrcMemset *)instruction); |
| 28758 | case IrInstructionIdMemset: | 29605 | case IrInstSrcIdMemcpy: |
| 28759 | return ir_analyze_instruction_memset(ira, (IrInstructionMemset *)instruction); | 29606 | return ir_analyze_instruction_memcpy(ira, (IrInstSrcMemcpy *)instruction); |
| 28760 | case IrInstructionIdMemcpy: | 29607 | case IrInstSrcIdSlice: |
| 28761 | return ir_analyze_instruction_memcpy(ira, (IrInstructionMemcpy *)instruction); | 29608 | return ir_analyze_instruction_slice(ira, (IrInstSrcSlice *)instruction); |
| 28762 | case IrInstructionIdSliceSrc: | 29609 | case IrInstSrcIdMemberCount: |
| 28763 | return ir_analyze_instruction_slice(ira, (IrInstructionSliceSrc *)instruction); | 29610 | return ir_analyze_instruction_member_count(ira, (IrInstSrcMemberCount *)instruction); |
| 28764 | case IrInstructionIdMemberCount: | 29611 | case IrInstSrcIdMemberType: |
| 28765 | return ir_analyze_instruction_member_count(ira, (IrInstructionMemberCount *)instruction); | 29612 | return ir_analyze_instruction_member_type(ira, (IrInstSrcMemberType *)instruction); |
| 28766 | case IrInstructionIdMemberType: | 29613 | case IrInstSrcIdMemberName: |
| 28767 | return ir_analyze_instruction_member_type(ira, (IrInstructionMemberType *)instruction); | 29614 | return ir_analyze_instruction_member_name(ira, (IrInstSrcMemberName *)instruction); |
| 28768 | case IrInstructionIdMemberName: | 29615 | case IrInstSrcIdBreakpoint: |
| 28769 | return ir_analyze_instruction_member_name(ira, (IrInstructionMemberName *)instruction); | 29616 | return ir_analyze_instruction_breakpoint(ira, (IrInstSrcBreakpoint *)instruction); |
| 28770 | case IrInstructionIdBreakpoint: | 29617 | case IrInstSrcIdReturnAddress: |
| 28771 | return ir_analyze_instruction_breakpoint(ira, (IrInstructionBreakpoint *)instruction); | 29618 | return ir_analyze_instruction_return_address(ira, (IrInstSrcReturnAddress *)instruction); |
| 28772 | case IrInstructionIdReturnAddress: | 29619 | case IrInstSrcIdFrameAddress: |
| 28773 | return ir_analyze_instruction_return_address(ira, (IrInstructionReturnAddress *)instruction); | 29620 | return ir_analyze_instruction_frame_address(ira, (IrInstSrcFrameAddress *)instruction); |
| 28774 | case IrInstructionIdFrameAddress: | 29621 | case IrInstSrcIdFrameHandle: |
| 28775 | return ir_analyze_instruction_frame_address(ira, (IrInstructionFrameAddress *)instruction); | 29622 | return ir_analyze_instruction_frame_handle(ira, (IrInstSrcFrameHandle *)instruction); |
| 28776 | case IrInstructionIdFrameHandle: | 29623 | case IrInstSrcIdFrameType: |
| 28777 | return ir_analyze_instruction_frame_handle(ira, (IrInstructionFrameHandle *)instruction); | 29624 | return ir_analyze_instruction_frame_type(ira, (IrInstSrcFrameType *)instruction); |
| 28778 | case IrInstructionIdFrameType: | 29625 | case IrInstSrcIdFrameSize: |
| 28779 | return ir_analyze_instruction_frame_type(ira, (IrInstructionFrameType *)instruction); | 29626 | return ir_analyze_instruction_frame_size(ira, (IrInstSrcFrameSize *)instruction); |
| 28780 | case IrInstructionIdFrameSizeSrc: | 29627 | case IrInstSrcIdAlignOf: |
| 28781 | return ir_analyze_instruction_frame_size(ira, (IrInstructionFrameSizeSrc *)instruction); | 29628 | return ir_analyze_instruction_align_of(ira, (IrInstSrcAlignOf *)instruction); |
| 28782 | case IrInstructionIdAlignOf: | 29629 | case IrInstSrcIdOverflowOp: |
| 28783 | return ir_analyze_instruction_align_of(ira, (IrInstructionAlignOf *)instruction); | 29630 | return ir_analyze_instruction_overflow_op(ira, (IrInstSrcOverflowOp *)instruction); |
| 28784 | case IrInstructionIdOverflowOp: | 29631 | case IrInstSrcIdTestErr: |
| 28785 | return ir_analyze_instruction_overflow_op(ira, (IrInstructionOverflowOp *)instruction); | 29632 | return ir_analyze_instruction_test_err(ira, (IrInstSrcTestErr *)instruction); |
| 28786 | case IrInstructionIdTestErrSrc: | 29633 | case IrInstSrcIdUnwrapErrCode: |
| 28787 | return ir_analyze_instruction_test_err(ira, (IrInstructionTestErrSrc *)instruction); | 29634 | return ir_analyze_instruction_unwrap_err_code(ira, (IrInstSrcUnwrapErrCode *)instruction); |
| 28788 | case IrInstructionIdUnwrapErrCode: | 29635 | case IrInstSrcIdUnwrapErrPayload: |
| 28789 | return ir_analyze_instruction_unwrap_err_code(ira, (IrInstructionUnwrapErrCode *)instruction); | 29636 | return ir_analyze_instruction_unwrap_err_payload(ira, (IrInstSrcUnwrapErrPayload *)instruction); |
| 28790 | case IrInstructionIdUnwrapErrPayload: | 29637 | case IrInstSrcIdFnProto: |
| 28791 | return ir_analyze_instruction_unwrap_err_payload(ira, (IrInstructionUnwrapErrPayload *)instruction); | 29638 | return ir_analyze_instruction_fn_proto(ira, (IrInstSrcFnProto *)instruction); |
| 28792 | case IrInstructionIdFnProto: | 29639 | case IrInstSrcIdTestComptime: |
| 28793 | return ir_analyze_instruction_fn_proto(ira, (IrInstructionFnProto *)instruction); | 29640 | return ir_analyze_instruction_test_comptime(ira, (IrInstSrcTestComptime *)instruction); |
| 28794 | case IrInstructionIdTestComptime: | 29641 | case IrInstSrcIdCheckSwitchProngs: |
| 28795 | return ir_analyze_instruction_test_comptime(ira, (IrInstructionTestComptime *)instruction); | 29642 | return ir_analyze_instruction_check_switch_prongs(ira, (IrInstSrcCheckSwitchProngs *)instruction); |
| 28796 | case IrInstructionIdCheckSwitchProngs: | 29643 | case IrInstSrcIdCheckStatementIsVoid: |
| 28797 | return ir_analyze_instruction_check_switch_prongs(ira, (IrInstructionCheckSwitchProngs *)instruction); | 29644 | return ir_analyze_instruction_check_statement_is_void(ira, (IrInstSrcCheckStatementIsVoid *)instruction); |
| 28798 | case IrInstructionIdCheckStatementIsVoid: | 29645 | case IrInstSrcIdDeclRef: |
| 28799 | return ir_analyze_instruction_check_statement_is_void(ira, (IrInstructionCheckStatementIsVoid *)instruction); | 29646 | return ir_analyze_instruction_decl_ref(ira, (IrInstSrcDeclRef *)instruction); |
| 28800 | case IrInstructionIdDeclRef: | 29647 | case IrInstSrcIdPanic: |
| 28801 | return ir_analyze_instruction_decl_ref(ira, (IrInstructionDeclRef *)instruction); | 29648 | return ir_analyze_instruction_panic(ira, (IrInstSrcPanic *)instruction); |
| 28802 | case IrInstructionIdPanic: | 29649 | case IrInstSrcIdPtrCast: |
| 28803 | return ir_analyze_instruction_panic(ira, (IrInstructionPanic *)instruction); | 29650 | return ir_analyze_instruction_ptr_cast(ira, (IrInstSrcPtrCast *)instruction); |
| 28804 | case IrInstructionIdPtrCastSrc: | 29651 | case IrInstSrcIdIntToPtr: |
| 28805 | return ir_analyze_instruction_ptr_cast(ira, (IrInstructionPtrCastSrc *)instruction); | 29652 | return ir_analyze_instruction_int_to_ptr(ira, (IrInstSrcIntToPtr *)instruction); |
| 28806 | case IrInstructionIdIntToPtr: | 29653 | case IrInstSrcIdPtrToInt: |
| 28807 | return ir_analyze_instruction_int_to_ptr(ira, (IrInstructionIntToPtr *)instruction); | 29654 | return ir_analyze_instruction_ptr_to_int(ira, (IrInstSrcPtrToInt *)instruction); |
| 28808 | case IrInstructionIdPtrToInt: | 29655 | case IrInstSrcIdTagName: |
| 28809 | return ir_analyze_instruction_ptr_to_int(ira, (IrInstructionPtrToInt *)instruction); | 29656 | return ir_analyze_instruction_enum_tag_name(ira, (IrInstSrcTagName *)instruction); |
| 28810 | case IrInstructionIdTagName: | 29657 | case IrInstSrcIdFieldParentPtr: |
| 28811 | return ir_analyze_instruction_enum_tag_name(ira, (IrInstructionTagName *)instruction); | 29658 | return ir_analyze_instruction_field_parent_ptr(ira, (IrInstSrcFieldParentPtr *)instruction); |
| 28812 | case IrInstructionIdFieldParentPtr: | 29659 | case IrInstSrcIdByteOffsetOf: |
| 28813 | return ir_analyze_instruction_field_parent_ptr(ira, (IrInstructionFieldParentPtr *)instruction); | 29660 | return ir_analyze_instruction_byte_offset_of(ira, (IrInstSrcByteOffsetOf *)instruction); |
| 28814 | case IrInstructionIdByteOffsetOf: | 29661 | case IrInstSrcIdBitOffsetOf: |
| 28815 | return ir_analyze_instruction_byte_offset_of(ira, (IrInstructionByteOffsetOf *)instruction); | 29662 | return ir_analyze_instruction_bit_offset_of(ira, (IrInstSrcBitOffsetOf *)instruction); |
| 28816 | case IrInstructionIdBitOffsetOf: | 29663 | case IrInstSrcIdTypeInfo: |
| 28817 | return ir_analyze_instruction_bit_offset_of(ira, (IrInstructionBitOffsetOf *)instruction); | 29664 | return ir_analyze_instruction_type_info(ira, (IrInstSrcTypeInfo *) instruction); |
| 28818 | case IrInstructionIdTypeInfo: | 29665 | case IrInstSrcIdType: |
| 28819 | return ir_analyze_instruction_type_info(ira, (IrInstructionTypeInfo *) instruction); | 29666 | return ir_analyze_instruction_type(ira, (IrInstSrcType *)instruction); |
| 28820 | case IrInstructionIdType: | 29667 | case IrInstSrcIdHasField: |
| 28821 | return ir_analyze_instruction_type(ira, (IrInstructionType *)instruction); | 29668 | return ir_analyze_instruction_has_field(ira, (IrInstSrcHasField *) instruction); |
| 28822 | case IrInstructionIdHasField: | 29669 | case IrInstSrcIdTypeId: |
| 28823 | return ir_analyze_instruction_has_field(ira, (IrInstructionHasField *) instruction); | 29670 | return ir_analyze_instruction_type_id(ira, (IrInstSrcTypeId *)instruction); |
| 28824 | case IrInstructionIdTypeId: | 29671 | case IrInstSrcIdSetEvalBranchQuota: |
| 28825 | return ir_analyze_instruction_type_id(ira, (IrInstructionTypeId *)instruction); | 29672 | return ir_analyze_instruction_set_eval_branch_quota(ira, (IrInstSrcSetEvalBranchQuota *)instruction); |
| 28826 | case IrInstructionIdSetEvalBranchQuota: | 29673 | case IrInstSrcIdPtrType: |
| 28827 | return ir_analyze_instruction_set_eval_branch_quota(ira, (IrInstructionSetEvalBranchQuota *)instruction); | 29674 | return ir_analyze_instruction_ptr_type(ira, (IrInstSrcPtrType *)instruction); |
| 28828 | case IrInstructionIdPtrType: | 29675 | case IrInstSrcIdAlignCast: |
| 28829 | return ir_analyze_instruction_ptr_type(ira, (IrInstructionPtrType *)instruction); | 29676 | return ir_analyze_instruction_align_cast(ira, (IrInstSrcAlignCast *)instruction); |
| 28830 | case IrInstructionIdAlignCast: | 29677 | case IrInstSrcIdImplicitCast: |
| 28831 | return ir_analyze_instruction_align_cast(ira, (IrInstructionAlignCast *)instruction); | 29678 | return ir_analyze_instruction_implicit_cast(ira, (IrInstSrcImplicitCast *)instruction); |
| 28832 | case IrInstructionIdImplicitCast: | 29679 | case IrInstSrcIdResolveResult: |
| 28833 | return ir_analyze_instruction_implicit_cast(ira, (IrInstructionImplicitCast *)instruction); | 29680 | return ir_analyze_instruction_resolve_result(ira, (IrInstSrcResolveResult *)instruction); |
| 28834 | case IrInstructionIdResolveResult: | 29681 | case IrInstSrcIdResetResult: |
| 28835 | return ir_analyze_instruction_resolve_result(ira, (IrInstructionResolveResult *)instruction); | 29682 | return ir_analyze_instruction_reset_result(ira, (IrInstSrcResetResult *)instruction); |
| 28836 | case IrInstructionIdResetResult: | 29683 | case IrInstSrcIdOpaqueType: |
| 28837 | return ir_analyze_instruction_reset_result(ira, (IrInstructionResetResult *)instruction); | 29684 | return ir_analyze_instruction_opaque_type(ira, (IrInstSrcOpaqueType *)instruction); |
| 28838 | case IrInstructionIdOpaqueType: | 29685 | case IrInstSrcIdSetAlignStack: |
| 28839 | return ir_analyze_instruction_opaque_type(ira, (IrInstructionOpaqueType *)instruction); | 29686 | return ir_analyze_instruction_set_align_stack(ira, (IrInstSrcSetAlignStack *)instruction); |
| 28840 | case IrInstructionIdSetAlignStack: | 29687 | case IrInstSrcIdArgType: |
| 28841 | return ir_analyze_instruction_set_align_stack(ira, (IrInstructionSetAlignStack *)instruction); | 29688 | return ir_analyze_instruction_arg_type(ira, (IrInstSrcArgType *)instruction); |
| 28842 | case IrInstructionIdArgType: | 29689 | case IrInstSrcIdTagType: |
| 28843 | return ir_analyze_instruction_arg_type(ira, (IrInstructionArgType *)instruction); | 29690 | return ir_analyze_instruction_tag_type(ira, (IrInstSrcTagType *)instruction); |
| 28844 | case IrInstructionIdTagType: | 29691 | case IrInstSrcIdExport: |
| 28845 | return ir_analyze_instruction_tag_type(ira, (IrInstructionTagType *)instruction); | 29692 | return ir_analyze_instruction_export(ira, (IrInstSrcExport *)instruction); |
| 28846 | case IrInstructionIdExport: | 29693 | case IrInstSrcIdErrorReturnTrace: |
| 28847 | return ir_analyze_instruction_export(ira, (IrInstructionExport *)instruction); | 29694 | return ir_analyze_instruction_error_return_trace(ira, (IrInstSrcErrorReturnTrace *)instruction); |
| 28848 | case IrInstructionIdErrorReturnTrace: | 29695 | case IrInstSrcIdErrorUnion: |
| 28849 | return ir_analyze_instruction_error_return_trace(ira, (IrInstructionErrorReturnTrace *)instruction); | 29696 | return ir_analyze_instruction_error_union(ira, (IrInstSrcErrorUnion *)instruction); |
| 28850 | case IrInstructionIdErrorUnion: | 29697 | case IrInstSrcIdAtomicRmw: |
| 28851 | return ir_analyze_instruction_error_union(ira, (IrInstructionErrorUnion *)instruction); | 29698 | return ir_analyze_instruction_atomic_rmw(ira, (IrInstSrcAtomicRmw *)instruction); |
| 28852 | case IrInstructionIdAtomicRmw: | 29699 | case IrInstSrcIdAtomicLoad: |
| 28853 | return ir_analyze_instruction_atomic_rmw(ira, (IrInstructionAtomicRmw *)instruction); | 29700 | return ir_analyze_instruction_atomic_load(ira, (IrInstSrcAtomicLoad *)instruction); |
| 28854 | case IrInstructionIdAtomicLoad: | 29701 | case IrInstSrcIdAtomicStore: |
| 28855 | return ir_analyze_instruction_atomic_load(ira, (IrInstructionAtomicLoad *)instruction); | 29702 | return ir_analyze_instruction_atomic_store(ira, (IrInstSrcAtomicStore *)instruction); |
| 28856 | case IrInstructionIdAtomicStore: | 29703 | case IrInstSrcIdSaveErrRetAddr: |
| 28857 | return ir_analyze_instruction_atomic_store(ira, (IrInstructionAtomicStore *)instruction); | 29704 | return ir_analyze_instruction_save_err_ret_addr(ira, (IrInstSrcSaveErrRetAddr *)instruction); |
| 28858 | case IrInstructionIdSaveErrRetAddr: | 29705 | case IrInstSrcIdAddImplicitReturnType: |
| 28859 | return ir_analyze_instruction_save_err_ret_addr(ira, (IrInstructionSaveErrRetAddr *)instruction); | 29706 | return ir_analyze_instruction_add_implicit_return_type(ira, (IrInstSrcAddImplicitReturnType *)instruction); |
| 28860 | case IrInstructionIdAddImplicitReturnType: | 29707 | case IrInstSrcIdFloatOp: |
| 28861 | return ir_analyze_instruction_add_implicit_return_type(ira, (IrInstructionAddImplicitReturnType *)instruction); | 29708 | return ir_analyze_instruction_float_op(ira, (IrInstSrcFloatOp *)instruction); |
| 28862 | case IrInstructionIdFloatOp: | 29709 | case IrInstSrcIdMulAdd: |
| 28863 | return ir_analyze_instruction_float_op(ira, (IrInstructionFloatOp *)instruction); | 29710 | return ir_analyze_instruction_mul_add(ira, (IrInstSrcMulAdd *)instruction); |
| 28864 | case IrInstructionIdMulAdd: | 29711 | case IrInstSrcIdIntToErr: |
| 28865 | return ir_analyze_instruction_mul_add(ira, (IrInstructionMulAdd *)instruction); | 29712 | return ir_analyze_instruction_int_to_err(ira, (IrInstSrcIntToErr *)instruction); |
| 28866 | case IrInstructionIdIntToErr: | 29713 | case IrInstSrcIdErrToInt: |
| 28867 | return ir_analyze_instruction_int_to_err(ira, (IrInstructionIntToErr *)instruction); | 29714 | return ir_analyze_instruction_err_to_int(ira, (IrInstSrcErrToInt *)instruction); |
| 28868 | case IrInstructionIdErrToInt: | 29715 | case IrInstSrcIdIntToEnum: |
| 28869 | return ir_analyze_instruction_err_to_int(ira, (IrInstructionErrToInt *)instruction); | 29716 | return ir_analyze_instruction_int_to_enum(ira, (IrInstSrcIntToEnum *)instruction); |
| 28870 | case IrInstructionIdIntToEnum: | 29717 | case IrInstSrcIdEnumToInt: |
| 28871 | return ir_analyze_instruction_int_to_enum(ira, (IrInstructionIntToEnum *)instruction); | 29718 | return ir_analyze_instruction_enum_to_int(ira, (IrInstSrcEnumToInt *)instruction); |
| 28872 | case IrInstructionIdEnumToInt: | 29719 | case IrInstSrcIdCheckRuntimeScope: |
| 28873 | return ir_analyze_instruction_enum_to_int(ira, (IrInstructionEnumToInt *)instruction); | 29720 | return ir_analyze_instruction_check_runtime_scope(ira, (IrInstSrcCheckRuntimeScope *)instruction); |
| 28874 | case IrInstructionIdCheckRuntimeScope: | 29721 | case IrInstSrcIdHasDecl: |
| 28875 | return ir_analyze_instruction_check_runtime_scope(ira, (IrInstructionCheckRuntimeScope *)instruction); | 29722 | return ir_analyze_instruction_has_decl(ira, (IrInstSrcHasDecl *)instruction); |
| 28876 | case IrInstructionIdHasDecl: | 29723 | case IrInstSrcIdUndeclaredIdent: |
| 28877 | return ir_analyze_instruction_has_decl(ira, (IrInstructionHasDecl *)instruction); | 29724 | return ir_analyze_instruction_undeclared_ident(ira, (IrInstSrcUndeclaredIdent *)instruction); |
| 28878 | case IrInstructionIdUndeclaredIdent: | 29725 | case IrInstSrcIdAlloca: |
| 28879 | return ir_analyze_instruction_undeclared_ident(ira, (IrInstructionUndeclaredIdent *)instruction); | | |
| 28880 | case IrInstructionIdAllocaSrc: | | |
| 28881 | return nullptr; | 29726 | return nullptr; |
| 28882 | case IrInstructionIdEndExpr: | 29727 | case IrInstSrcIdEndExpr: |
| 28883 | return ir_analyze_instruction_end_expr(ira, (IrInstructionEndExpr *)instruction); | 29728 | return ir_analyze_instruction_end_expr(ira, (IrInstSrcEndExpr *)instruction); |
| 28884 | case IrInstructionIdBitCastSrc: | 29729 | case IrInstSrcIdBitCast: |
| 28885 | return ir_analyze_instruction_bit_cast_src(ira, (IrInstructionBitCastSrc *)instruction); | 29730 | return ir_analyze_instruction_bit_cast_src(ira, (IrInstSrcBitCast *)instruction); |
| 28886 | case IrInstructionIdUnionInitNamedField: | 29731 | case IrInstSrcIdUnionInitNamedField: |
| 28887 | return ir_analyze_instruction_union_init_named_field(ira, (IrInstructionUnionInitNamedField *)instruction); | 29732 | return ir_analyze_instruction_union_init_named_field(ira, (IrInstSrcUnionInitNamedField *)instruction); |
| 28888 | case IrInstructionIdSuspendBegin: | 29733 | case IrInstSrcIdSuspendBegin: |
| 28889 | return ir_analyze_instruction_suspend_begin(ira, (IrInstructionSuspendBegin *)instruction); | 29734 | return ir_analyze_instruction_suspend_begin(ira, (IrInstSrcSuspendBegin *)instruction); |
| 28890 | case IrInstructionIdSuspendFinish: | 29735 | case IrInstSrcIdSuspendFinish: |
| 28891 | return ir_analyze_instruction_suspend_finish(ira, (IrInstructionSuspendFinish *)instruction); | 29736 | return ir_analyze_instruction_suspend_finish(ira, (IrInstSrcSuspendFinish *)instruction); |
| 28892 | case IrInstructionIdResume: | 29737 | case IrInstSrcIdResume: |
| 28893 | return ir_analyze_instruction_resume(ira, (IrInstructionResume *)instruction); | 29738 | return ir_analyze_instruction_resume(ira, (IrInstSrcResume *)instruction); |
| 28894 | case IrInstructionIdAwaitSrc: | 29739 | case IrInstSrcIdAwait: |
| 28895 | return ir_analyze_instruction_await(ira, (IrInstructionAwaitSrc *)instruction); | 29740 | return ir_analyze_instruction_await(ira, (IrInstSrcAwait *)instruction); |
| 28896 | case IrInstructionIdSpillBegin: | 29741 | case IrInstSrcIdSpillBegin: |
| 28897 | return ir_analyze_instruction_spill_begin(ira, (IrInstructionSpillBegin *)instruction); | 29742 | return ir_analyze_instruction_spill_begin(ira, (IrInstSrcSpillBegin *)instruction); |
| 28898 | case IrInstructionIdSpillEnd: | 29743 | case IrInstSrcIdSpillEnd: |
| 28899 | return ir_analyze_instruction_spill_end(ira, (IrInstructionSpillEnd *)instruction); | 29744 | return ir_analyze_instruction_spill_end(ira, (IrInstSrcSpillEnd *)instruction); |
| 28900 | } | 29745 | } |
| 28901 | zig_unreachable(); | 29746 | zig_unreachable(); |
| 28902 | } | 29747 | } |
| 28903 | | 29748 | |
| 28904 | // This function attempts to evaluate IR code while doing type checking and other analysis. | 29749 | // This function attempts to evaluate IR code while doing type checking and other analysis. |
| 28905 | // It emits a new IrExecutable which is partially evaluated IR code. | 29750 | // It emits to a new IrExecutableGen which is partially evaluated IR code. |
| 28906 | ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_exec, | 29751 | ZigType *ir_analyze(CodeGen *codegen, IrExecutableSrc *old_exec, IrExecutableGen *new_exec, |
| 28907 | ZigType *expected_type, AstNode *expected_type_source_node, ZigValue *result_ptr) | 29752 | ZigType *expected_type, AstNode *expected_type_source_node, ZigValue *result_ptr) |
| 28908 | { | 29753 | { |
| 28909 | assert(old_exec->first_err_trace_msg == nullptr); | 29754 | assert(old_exec->first_err_trace_msg == nullptr); |
| ... | @@ -28923,9 +29768,9 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -28923,9 +29768,9 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 28923 | ira->new_irb.codegen = codegen; | 29768 | ira->new_irb.codegen = codegen; |
| 28924 | ira->new_irb.exec = new_exec; | 29769 | ira->new_irb.exec = new_exec; |
| 28925 | | 29770 | |
| 28926 | IrBasicBlock *old_entry_bb = ira->old_irb.exec->basic_block_list.at(0); | 29771 | IrBasicBlockSrc *old_entry_bb = ira->old_irb.exec->basic_block_list.at(0); |
| 28927 | IrBasicBlock *new_entry_bb = ir_get_new_bb(ira, old_entry_bb, nullptr); | 29772 | IrBasicBlockGen *new_entry_bb = ir_get_new_bb(ira, old_entry_bb, nullptr); |
| 28928 | ir_ref_bb(new_entry_bb); | 29773 | ir_ref_bb_gen(new_entry_bb); |
| 28929 | ira->new_irb.current_basic_block = new_entry_bb; | 29774 | ira->new_irb.current_basic_block = new_entry_bb; |
| 28930 | ira->old_bb_index = 0; | 29775 | ira->old_bb_index = 0; |
| 28931 | | 29776 | |
| ... | @@ -28933,7 +29778,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -28933,7 +29778,7 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 28933 | | 29778 | |
| 28934 | if (result_ptr != nullptr) { | 29779 | if (result_ptr != nullptr) { |
| 28935 | assert(result_ptr->type->id == ZigTypeIdPointer); | 29780 | assert(result_ptr->type->id == ZigTypeIdPointer); |
| 28936 | IrInstructionConst *const_inst = ir_create_instruction<IrInstructionConst>( | 29781 | IrInstGenConst *const_inst = ir_create_inst_noval<IrInstGenConst>( |
| 28937 | &ira->new_irb, new_exec->begin_scope, new_exec->source_node); | 29782 | &ira->new_irb, new_exec->begin_scope, new_exec->source_node); |
| 28938 | const_inst->base.value = result_ptr; | 29783 | const_inst->base.value = result_ptr; |
| 28939 | ira->return_ptr = &const_inst->base; | 29784 | ira->return_ptr = &const_inst->base; |
| ... | @@ -28945,9 +29790,9 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -28945,9 +29790,9 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 28945 | } | 29790 | } |
| 28946 | | 29791 | |
| 28947 | while (ira->old_bb_index < ira->old_irb.exec->basic_block_list.length) { | 29792 | while (ira->old_bb_index < ira->old_irb.exec->basic_block_list.length) { |
| 28948 | IrInstruction *old_instruction = ira->old_irb.current_basic_block->instruction_list.at(ira->instruction_index); | 29793 | IrInstSrc *old_instruction = ira->old_irb.current_basic_block->instruction_list.at(ira->instruction_index); |
| 28949 | | 29794 | |
| 28950 | if (old_instruction->ref_count == 0 && !ir_has_side_effects(old_instruction)) { | 29795 | if (old_instruction->base.ref_count == 0 && !ir_inst_src_has_side_effects(old_instruction)) { |
| 28951 | ira->instruction_index += 1; | 29796 | ira->instruction_index += 1; |
| 28952 | continue; | 29797 | continue; |
| 28953 | } | 29798 | } |
| ... | @@ -28956,14 +29801,14 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -28956,14 +29801,14 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 28956 | fprintf(stderr, "~ "); | 29801 | fprintf(stderr, "~ "); |
| 28957 | old_instruction->src(); | 29802 | old_instruction->src(); |
| 28958 | fprintf(stderr, "~ "); | 29803 | fprintf(stderr, "~ "); |
| 28959 | ir_print_instruction(codegen, stderr, old_instruction, 0, IrPassSrc); | 29804 | ir_print_inst_src(codegen, stderr, old_instruction, 0); |
| 28960 | bool want_break = false; | 29805 | bool want_break = false; |
| 28961 | if (ira->break_debug_id == old_instruction->debug_id) { | 29806 | if (ira->break_debug_id == old_instruction->base.debug_id) { |
| 28962 | want_break = true; | 29807 | want_break = true; |
| 28963 | } else if (old_instruction->source_node != nullptr) { | 29808 | } else if (old_instruction->base.source_node != nullptr) { |
| 28964 | for (size_t i = 0; i < dbg_ir_breakpoints_count; i += 1) { | 29809 | for (size_t i = 0; i < dbg_ir_breakpoints_count; i += 1) { |
| 28965 | if (dbg_ir_breakpoints_buf[i].line == old_instruction->source_node->line + 1 && | 29810 | if (dbg_ir_breakpoints_buf[i].line == old_instruction->base.source_node->line + 1 && |
| 28966 | buf_ends_with_str(old_instruction->source_node->owner->data.structure.root_struct->path, | 29811 | buf_ends_with_str(old_instruction->base.source_node->owner->data.structure.root_struct->path, |
| 28967 | dbg_ir_breakpoints_buf[i].src_file)) | 29812 | dbg_ir_breakpoints_buf[i].src_file)) |
| 28968 | { | 29813 | { |
| 28969 | want_break = true; | 29814 | want_break = true; |
| ... | @@ -28972,9 +29817,9 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -28972,9 +29817,9 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 28972 | } | 29817 | } |
| 28973 | if (want_break) BREAKPOINT; | 29818 | if (want_break) BREAKPOINT; |
| 28974 | } | 29819 | } |
| 28975 | IrInstruction *new_instruction = ir_analyze_instruction_base(ira, old_instruction); | 29820 | IrInstGen *new_instruction = ir_analyze_instruction_base(ira, old_instruction); |
| 28976 | if (new_instruction != nullptr) { | 29821 | if (new_instruction != nullptr) { |
| 28977 | ir_assert(new_instruction->value->type != nullptr || new_instruction->value->type != nullptr, old_instruction); | 29822 | ir_assert(new_instruction->value->type != nullptr || new_instruction->value->type != nullptr, &old_instruction->base); |
| 28978 | old_instruction->child = new_instruction; | 29823 | old_instruction->child = new_instruction; |
| 28979 | | 29824 | |
| 28980 | if (type_is_invalid(new_instruction->value->type)) { | 29825 | if (type_is_invalid(new_instruction->value->type)) { |
| ... | @@ -28988,19 +29833,19 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -28988,19 +29833,19 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 28988 | new_exec->first_err_trace_msg = ira->codegen->trace_err; | 29833 | new_exec->first_err_trace_msg = ira->codegen->trace_err; |
| 28989 | } | 29834 | } |
| 28990 | if (new_exec->first_err_trace_msg != nullptr && | 29835 | if (new_exec->first_err_trace_msg != nullptr && |
| 28991 | !old_instruction->source_node->already_traced_this_node) | 29836 | !old_instruction->base.source_node->already_traced_this_node) |
| 28992 | { | 29837 | { |
| 28993 | old_instruction->source_node->already_traced_this_node = true; | 29838 | old_instruction->base.source_node->already_traced_this_node = true; |
| 28994 | new_exec->first_err_trace_msg = add_error_note(ira->codegen, new_exec->first_err_trace_msg, | 29839 | new_exec->first_err_trace_msg = add_error_note(ira->codegen, new_exec->first_err_trace_msg, |
| 28995 | old_instruction->source_node, buf_create_from_str("referenced here")); | 29840 | old_instruction->base.source_node, buf_create_from_str("referenced here")); |
| 28996 | } | 29841 | } |
| 28997 | return ira->codegen->builtin_types.entry_invalid; | 29842 | return ira->codegen->builtin_types.entry_invalid; |
| 28998 | } else if (ira->codegen->verbose_ir) { | 29843 | } else if (ira->codegen->verbose_ir) { |
| 28999 | fprintf(stderr, "-> "); | 29844 | fprintf(stderr, "-> "); |
| 29000 | if (instr_is_unreachable(new_instruction)) { | 29845 | if (new_instruction->value->type->id == ZigTypeIdUnreachable) { |
| 29001 | fprintf(stderr, "(noreturn)\n"); | 29846 | fprintf(stderr, "(noreturn)\n"); |
| 29002 | } else { | 29847 | } else { |
| 29003 | ir_print_instruction(codegen, stderr, new_instruction, 0, IrPassGen); | 29848 | ir_print_inst_gen(codegen, stderr, new_instruction, 0); |
| 29004 | } | 29849 | } |
| 29005 | } | 29850 | } |
| 29006 | | 29851 | |
| ... | @@ -29040,204 +29885,279 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -29040,204 +29885,279 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 29040 | return res_type; | 29885 | return res_type; |
| 29041 | } | 29886 | } |
| 29042 | | 29887 | |
| 29043 | bool ir_has_side_effects(IrInstruction *instruction) { | 29888 | bool ir_inst_gen_has_side_effects(IrInstGen *instruction) { |
| 29044 | switch (instruction->id) { | 29889 | switch (instruction->id) { |
| 29045 | case IrInstructionIdInvalid: | 29890 | case IrInstGenIdInvalid: |
| 29046 | zig_unreachable(); | 29891 | zig_unreachable(); |
| 29047 | case IrInstructionIdBr: | 29892 | case IrInstGenIdBr: |
| 29048 | case IrInstructionIdCondBr: | 29893 | case IrInstGenIdCondBr: |
| 29049 | case IrInstructionIdSwitchBr: | 29894 | case IrInstGenIdSwitchBr: |
| 29050 | case IrInstructionIdDeclVarSrc: | 29895 | case IrInstGenIdDeclVar: |
| 29051 | case IrInstructionIdDeclVarGen: | 29896 | case IrInstGenIdStorePtr: |
| 29052 | case IrInstructionIdStorePtr: | 29897 | case IrInstGenIdVectorStoreElem: |
| 29053 | case IrInstructionIdVectorStoreElem: | 29898 | case IrInstGenIdCall: |
| 29054 | case IrInstructionIdCallExtra: | 29899 | case IrInstGenIdReturn: |
| 29055 | case IrInstructionIdCallSrc: | 29900 | case IrInstGenIdUnreachable: |
| 29056 | case IrInstructionIdCallSrcArgs: | 29901 | case IrInstGenIdFence: |
| 29057 | case IrInstructionIdCallGen: | 29902 | case IrInstGenIdMemset: |
| 29058 | case IrInstructionIdReturn: | 29903 | case IrInstGenIdMemcpy: |
| 29059 | case IrInstructionIdUnreachable: | 29904 | case IrInstGenIdBreakpoint: |
| 29060 | case IrInstructionIdSetCold: | 29905 | case IrInstGenIdOverflowOp: // TODO when we support multiple returns this can be side effect free |
| 29061 | case IrInstructionIdSetRuntimeSafety: | 29906 | case IrInstGenIdPanic: |
| 29062 | case IrInstructionIdSetFloatMode: | 29907 | case IrInstGenIdSaveErrRetAddr: |
| 29063 | case IrInstructionIdImport: | 29908 | case IrInstGenIdAtomicRmw: |
| 29064 | case IrInstructionIdCompileErr: | 29909 | case IrInstGenIdAtomicStore: |
| 29065 | case IrInstructionIdCompileLog: | 29910 | case IrInstGenIdCmpxchg: |
| 29066 | case IrInstructionIdCImport: | 29911 | case IrInstGenIdAssertZero: |
| 29067 | case IrInstructionIdCInclude: | 29912 | case IrInstGenIdAssertNonNull: |
| 29068 | case IrInstructionIdCDefine: | 29913 | case IrInstGenIdResizeSlice: |
| 29069 | case IrInstructionIdCUndef: | 29914 | case IrInstGenIdPtrOfArrayToSlice: |
| 29070 | case IrInstructionIdFence: | 29915 | case IrInstGenIdSlice: |
| 29071 | case IrInstructionIdMemset: | 29916 | case IrInstGenIdOptionalWrap: |
| 29072 | case IrInstructionIdMemcpy: | 29917 | case IrInstGenIdVectorToArray: |
| 29073 | case IrInstructionIdBreakpoint: | 29918 | case IrInstGenIdSuspendBegin: |
| 29074 | case IrInstructionIdOverflowOp: // TODO when we support multiple returns this can be side effect free | 29919 | case IrInstGenIdSuspendFinish: |
| 29075 | case IrInstructionIdCheckSwitchProngs: | 29920 | case IrInstGenIdResume: |
| 29076 | case IrInstructionIdCheckStatementIsVoid: | 29921 | case IrInstGenIdAwait: |
| 29077 | case IrInstructionIdCheckRuntimeScope: | 29922 | case IrInstGenIdSpillBegin: |
| 29078 | case IrInstructionIdPanic: | | |
| 29079 | case IrInstructionIdSetEvalBranchQuota: | | |
| 29080 | case IrInstructionIdPtrType: | | |
| 29081 | case IrInstructionIdSetAlignStack: | | |
| 29082 | case IrInstructionIdExport: | | |
| 29083 | case IrInstructionIdSaveErrRetAddr: | | |
| 29084 | case IrInstructionIdAddImplicitReturnType: | | |
| 29085 | case IrInstructionIdAtomicRmw: | | |
| 29086 | case IrInstructionIdAtomicStore: | | |
| 29087 | case IrInstructionIdCmpxchgGen: | | |
| 29088 | case IrInstructionIdCmpxchgSrc: | | |
| 29089 | case IrInstructionIdAssertZero: | | |
| 29090 | case IrInstructionIdAssertNonNull: | | |
| 29091 | case IrInstructionIdResizeSlice: | | |
| 29092 | case IrInstructionIdUndeclaredIdent: | | |
| 29093 | case IrInstructionIdEndExpr: | | |
| 29094 | case IrInstructionIdPtrOfArrayToSlice: | | |
| 29095 | case IrInstructionIdSliceGen: | | |
| 29096 | case IrInstructionIdOptionalWrap: | | |
| 29097 | case IrInstructionIdVectorToArray: | | |
| 29098 | case IrInstructionIdResetResult: | | |
| 29099 | case IrInstructionIdSuspendBegin: | | |
| 29100 | case IrInstructionIdSuspendFinish: | | |
| 29101 | case IrInstructionIdResume: | | |
| 29102 | case IrInstructionIdAwaitSrc: | | |
| 29103 | case IrInstructionIdAwaitGen: | | |
| 29104 | case IrInstructionIdSpillBegin: | | |
| 29105 | return true; | 29923 | return true; |
| 29106 | | 29924 | |
| 29107 | case IrInstructionIdPhi: | 29925 | case IrInstGenIdPhi: |
| 29108 | case IrInstructionIdUnOp: | 29926 | case IrInstGenIdBinOp: |
| 29109 | case IrInstructionIdBinOp: | 29927 | case IrInstGenIdConst: |
| 29110 | case IrInstructionIdMergeErrSets: | 29928 | case IrInstGenIdCast: |
| 29111 | case IrInstructionIdLoadPtr: | 29929 | case IrInstGenIdElemPtr: |
| 29112 | case IrInstructionIdConst: | 29930 | case IrInstGenIdVarPtr: |
| 29113 | case IrInstructionIdCast: | 29931 | case IrInstGenIdReturnPtr: |
| 29114 | case IrInstructionIdContainerInitList: | 29932 | case IrInstGenIdStructFieldPtr: |
| 29115 | case IrInstructionIdContainerInitFields: | 29933 | case IrInstGenIdTestNonNull: |
| 29116 | case IrInstructionIdUnionInitNamedField: | 29934 | case IrInstGenIdOptionalUnwrapPtr: |
| 29117 | case IrInstructionIdFieldPtr: | 29935 | case IrInstGenIdClz: |
| 29118 | case IrInstructionIdElemPtr: | 29936 | case IrInstGenIdCtz: |
| 29119 | case IrInstructionIdVarPtr: | 29937 | case IrInstGenIdPopCount: |
| 29120 | case IrInstructionIdReturnPtr: | 29938 | case IrInstGenIdBswap: |
| 29121 | case IrInstructionIdTypeOf: | 29939 | case IrInstGenIdBitReverse: |
| 29122 | case IrInstructionIdStructFieldPtr: | 29940 | case IrInstGenIdUnionTag: |
| 29123 | case IrInstructionIdArrayType: | 29941 | case IrInstGenIdTruncate: |
| 29124 | case IrInstructionIdSliceType: | 29942 | case IrInstGenIdShuffleVector: |
| 29125 | case IrInstructionIdAnyFrameType: | 29943 | case IrInstGenIdSplat: |
| 29126 | case IrInstructionIdSizeOf: | 29944 | case IrInstGenIdBoolNot: |
| 29127 | case IrInstructionIdTestNonNull: | 29945 | case IrInstGenIdReturnAddress: |
| 29128 | case IrInstructionIdOptionalUnwrapPtr: | 29946 | case IrInstGenIdFrameAddress: |
| 29129 | case IrInstructionIdClz: | 29947 | case IrInstGenIdFrameHandle: |
| 29130 | case IrInstructionIdCtz: | 29948 | case IrInstGenIdFrameSize: |
| 29131 | case IrInstructionIdPopCount: | 29949 | case IrInstGenIdTestErr: |
| 29132 | case IrInstructionIdBswap: | 29950 | case IrInstGenIdPtrCast: |
| 29133 | case IrInstructionIdBitReverse: | 29951 | case IrInstGenIdBitCast: |
| 29134 | case IrInstructionIdSwitchVar: | 29952 | case IrInstGenIdWidenOrShorten: |
| 29135 | case IrInstructionIdSwitchElseVar: | 29953 | case IrInstGenIdPtrToInt: |
| 29136 | case IrInstructionIdSwitchTarget: | 29954 | case IrInstGenIdIntToPtr: |
| 29137 | case IrInstructionIdUnionTag: | 29955 | case IrInstGenIdIntToEnum: |
| 29138 | case IrInstructionIdRef: | 29956 | case IrInstGenIdIntToErr: |
| 29139 | case IrInstructionIdEmbedFile: | 29957 | case IrInstGenIdErrToInt: |
| 29140 | case IrInstructionIdTruncate: | 29958 | case IrInstGenIdErrName: |
| 29141 | case IrInstructionIdIntType: | 29959 | case IrInstGenIdTagName: |
| 29142 | case IrInstructionIdVectorType: | 29960 | case IrInstGenIdFieldParentPtr: |
| 29143 | case IrInstructionIdShuffleVector: | 29961 | case IrInstGenIdAlignCast: |
| 29144 | case IrInstructionIdSplatSrc: | 29962 | case IrInstGenIdErrorReturnTrace: |
| 29145 | case IrInstructionIdSplatGen: | 29963 | case IrInstGenIdFloatOp: |
| 29146 | case IrInstructionIdBoolNot: | 29964 | case IrInstGenIdMulAdd: |
| 29147 | case IrInstructionIdSliceSrc: | 29965 | case IrInstGenIdAtomicLoad: |
| 29148 | case IrInstructionIdMemberCount: | 29966 | case IrInstGenIdArrayToVector: |
| 29149 | case IrInstructionIdMemberType: | 29967 | case IrInstGenIdAlloca: |
| 29150 | case IrInstructionIdMemberName: | 29968 | case IrInstGenIdSpillEnd: |
| 29151 | case IrInstructionIdAlignOf: | 29969 | case IrInstGenIdVectorExtractElem: |
| 29152 | case IrInstructionIdReturnAddress: | 29970 | case IrInstGenIdBinaryNot: |
| 29153 | case IrInstructionIdFrameAddress: | 29971 | case IrInstGenIdNegation: |
| 29154 | case IrInstructionIdFrameHandle: | 29972 | case IrInstGenIdNegationWrapping: |
| 29155 | case IrInstructionIdFrameType: | | |
| 29156 | case IrInstructionIdFrameSizeSrc: | | |
| 29157 | case IrInstructionIdFrameSizeGen: | | |
| 29158 | case IrInstructionIdTestErrSrc: | | |
| 29159 | case IrInstructionIdTestErrGen: | | |
| 29160 | case IrInstructionIdFnProto: | | |
| 29161 | case IrInstructionIdTestComptime: | | |
| 29162 | case IrInstructionIdPtrCastSrc: | | |
| 29163 | case IrInstructionIdPtrCastGen: | | |
| 29164 | case IrInstructionIdBitCastSrc: | | |
| 29165 | case IrInstructionIdBitCastGen: | | |
| 29166 | case IrInstructionIdWidenOrShorten: | | |
| 29167 | case IrInstructionIdPtrToInt: | | |
| 29168 | case IrInstructionIdIntToPtr: | | |
| 29169 | case IrInstructionIdIntToEnum: | | |
| 29170 | case IrInstructionIdIntToErr: | | |
| 29171 | case IrInstructionIdErrToInt: | | |
| 29172 | case IrInstructionIdDeclRef: | | |
| 29173 | case IrInstructionIdErrName: | | |
| 29174 | case IrInstructionIdTypeName: | | |
| 29175 | case IrInstructionIdTagName: | | |
| 29176 | case IrInstructionIdFieldParentPtr: | | |
| 29177 | case IrInstructionIdByteOffsetOf: | | |
| 29178 | case IrInstructionIdBitOffsetOf: | | |
| 29179 | case IrInstructionIdTypeInfo: | | |
| 29180 | case IrInstructionIdType: | | |
| 29181 | case IrInstructionIdHasField: | | |
| 29182 | case IrInstructionIdTypeId: | | |
| 29183 | case IrInstructionIdAlignCast: | | |
| 29184 | case IrInstructionIdImplicitCast: | | |
| 29185 | case IrInstructionIdResolveResult: | | |
| 29186 | case IrInstructionIdOpaqueType: | | |
| 29187 | case IrInstructionIdArgType: | | |
| 29188 | case IrInstructionIdTagType: | | |
| 29189 | case IrInstructionIdErrorReturnTrace: | | |
| 29190 | case IrInstructionIdErrorUnion: | | |
| 29191 | case IrInstructionIdFloatOp: | | |
| 29192 | case IrInstructionIdMulAdd: | | |
| 29193 | case IrInstructionIdAtomicLoad: | | |
| 29194 | case IrInstructionIdIntCast: | | |
| 29195 | case IrInstructionIdFloatCast: | | |
| 29196 | case IrInstructionIdErrSetCast: | | |
| 29197 | case IrInstructionIdIntToFloat: | | |
| 29198 | case IrInstructionIdFloatToInt: | | |
| 29199 | case IrInstructionIdBoolToInt: | | |
| 29200 | case IrInstructionIdFromBytes: | | |
| 29201 | case IrInstructionIdToBytes: | | |
| 29202 | case IrInstructionIdEnumToInt: | | |
| 29203 | case IrInstructionIdArrayToVector: | | |
| 29204 | case IrInstructionIdHasDecl: | | |
| 29205 | case IrInstructionIdAllocaSrc: | | |
| 29206 | case IrInstructionIdAllocaGen: | | |
| 29207 | case IrInstructionIdSpillEnd: | | |
| 29208 | case IrInstructionIdVectorExtractElem: | | |
| 29209 | return false; | 29973 | return false; |
| 29210 | | 29974 | |
| 29211 | case IrInstructionIdAsmSrc: | 29975 | case IrInstGenIdAsm: |
| 29212 | { | 29976 | { |
| 29213 | IrInstructionAsmSrc *asm_instruction = (IrInstructionAsmSrc *)instruction; | 29977 | IrInstGenAsm *asm_instruction = (IrInstGenAsm *)instruction; |
| 29214 | return asm_instruction->has_side_effects; | 29978 | return asm_instruction->has_side_effects; |
| 29215 | } | 29979 | } |
| | 29980 | case IrInstGenIdUnwrapErrPayload: |
| | 29981 | { |
| | 29982 | IrInstGenUnwrapErrPayload *unwrap_err_payload_instruction = |
| | 29983 | (IrInstGenUnwrapErrPayload *)instruction; |
| | 29984 | return unwrap_err_payload_instruction->safety_check_on || |
| | 29985 | unwrap_err_payload_instruction->initializing; |
| | 29986 | } |
| | 29987 | case IrInstGenIdUnwrapErrCode: |
| | 29988 | return reinterpret_cast<IrInstGenUnwrapErrCode *>(instruction)->initializing; |
| | 29989 | case IrInstGenIdUnionFieldPtr: |
| | 29990 | return reinterpret_cast<IrInstGenUnionFieldPtr *>(instruction)->initializing; |
| | 29991 | case IrInstGenIdErrWrapPayload: |
| | 29992 | return reinterpret_cast<IrInstGenErrWrapPayload *>(instruction)->result_loc != nullptr; |
| | 29993 | case IrInstGenIdErrWrapCode: |
| | 29994 | return reinterpret_cast<IrInstGenErrWrapCode *>(instruction)->result_loc != nullptr; |
| | 29995 | case IrInstGenIdLoadPtr: |
| | 29996 | return reinterpret_cast<IrInstGenLoadPtr *>(instruction)->result_loc != nullptr; |
| | 29997 | case IrInstGenIdRef: |
| | 29998 | return reinterpret_cast<IrInstGenRef *>(instruction)->result_loc != nullptr; |
| | 29999 | } |
| | 30000 | zig_unreachable(); |
| | 30001 | } |
| | 30002 | |
| | 30003 | bool ir_inst_src_has_side_effects(IrInstSrc *instruction) { |
| | 30004 | switch (instruction->id) { |
| | 30005 | case IrInstSrcIdInvalid: |
| | 30006 | zig_unreachable(); |
| | 30007 | case IrInstSrcIdBr: |
| | 30008 | case IrInstSrcIdCondBr: |
| | 30009 | case IrInstSrcIdSwitchBr: |
| | 30010 | case IrInstSrcIdDeclVar: |
| | 30011 | case IrInstSrcIdStorePtr: |
| | 30012 | case IrInstSrcIdCallExtra: |
| | 30013 | case IrInstSrcIdCall: |
| | 30014 | case IrInstSrcIdCallArgs: |
| | 30015 | case IrInstSrcIdReturn: |
| | 30016 | case IrInstSrcIdUnreachable: |
| | 30017 | case IrInstSrcIdSetCold: |
| | 30018 | case IrInstSrcIdSetRuntimeSafety: |
| | 30019 | case IrInstSrcIdSetFloatMode: |
| | 30020 | case IrInstSrcIdImport: |
| | 30021 | case IrInstSrcIdCompileErr: |
| | 30022 | case IrInstSrcIdCompileLog: |
| | 30023 | case IrInstSrcIdCImport: |
| | 30024 | case IrInstSrcIdCInclude: |
| | 30025 | case IrInstSrcIdCDefine: |
| | 30026 | case IrInstSrcIdCUndef: |
| | 30027 | case IrInstSrcIdFence: |
| | 30028 | case IrInstSrcIdMemset: |
| | 30029 | case IrInstSrcIdMemcpy: |
| | 30030 | case IrInstSrcIdBreakpoint: |
| | 30031 | case IrInstSrcIdOverflowOp: // TODO when we support multiple returns this can be side effect free |
| | 30032 | case IrInstSrcIdCheckSwitchProngs: |
| | 30033 | case IrInstSrcIdCheckStatementIsVoid: |
| | 30034 | case IrInstSrcIdCheckRuntimeScope: |
| | 30035 | case IrInstSrcIdPanic: |
| | 30036 | case IrInstSrcIdSetEvalBranchQuota: |
| | 30037 | case IrInstSrcIdPtrType: |
| | 30038 | case IrInstSrcIdSetAlignStack: |
| | 30039 | case IrInstSrcIdExport: |
| | 30040 | case IrInstSrcIdSaveErrRetAddr: |
| | 30041 | case IrInstSrcIdAddImplicitReturnType: |
| | 30042 | case IrInstSrcIdAtomicRmw: |
| | 30043 | case IrInstSrcIdAtomicStore: |
| | 30044 | case IrInstSrcIdCmpxchg: |
| | 30045 | case IrInstSrcIdUndeclaredIdent: |
| | 30046 | case IrInstSrcIdEndExpr: |
| | 30047 | case IrInstSrcIdResetResult: |
| | 30048 | case IrInstSrcIdSuspendBegin: |
| | 30049 | case IrInstSrcIdSuspendFinish: |
| | 30050 | case IrInstSrcIdResume: |
| | 30051 | case IrInstSrcIdAwait: |
| | 30052 | case IrInstSrcIdSpillBegin: |
| | 30053 | return true; |
| | 30054 | |
| | 30055 | case IrInstSrcIdPhi: |
| | 30056 | case IrInstSrcIdUnOp: |
| | 30057 | case IrInstSrcIdBinOp: |
| | 30058 | case IrInstSrcIdMergeErrSets: |
| | 30059 | case IrInstSrcIdLoadPtr: |
| | 30060 | case IrInstSrcIdConst: |
| | 30061 | case IrInstSrcIdContainerInitList: |
| | 30062 | case IrInstSrcIdContainerInitFields: |
| | 30063 | case IrInstSrcIdUnionInitNamedField: |
| | 30064 | case IrInstSrcIdFieldPtr: |
| | 30065 | case IrInstSrcIdElemPtr: |
| | 30066 | case IrInstSrcIdVarPtr: |
| | 30067 | case IrInstSrcIdTypeOf: |
| | 30068 | case IrInstSrcIdArrayType: |
| | 30069 | case IrInstSrcIdSliceType: |
| | 30070 | case IrInstSrcIdAnyFrameType: |
| | 30071 | case IrInstSrcIdSizeOf: |
| | 30072 | case IrInstSrcIdTestNonNull: |
| | 30073 | case IrInstSrcIdOptionalUnwrapPtr: |
| | 30074 | case IrInstSrcIdClz: |
| | 30075 | case IrInstSrcIdCtz: |
| | 30076 | case IrInstSrcIdPopCount: |
| | 30077 | case IrInstSrcIdBswap: |
| | 30078 | case IrInstSrcIdBitReverse: |
| | 30079 | case IrInstSrcIdSwitchVar: |
| | 30080 | case IrInstSrcIdSwitchElseVar: |
| | 30081 | case IrInstSrcIdSwitchTarget: |
| | 30082 | case IrInstSrcIdRef: |
| | 30083 | case IrInstSrcIdEmbedFile: |
| | 30084 | case IrInstSrcIdTruncate: |
| | 30085 | case IrInstSrcIdIntType: |
| | 30086 | case IrInstSrcIdVectorType: |
| | 30087 | case IrInstSrcIdShuffleVector: |
| | 30088 | case IrInstSrcIdSplat: |
| | 30089 | case IrInstSrcIdBoolNot: |
| | 30090 | case IrInstSrcIdSlice: |
| | 30091 | case IrInstSrcIdMemberCount: |
| | 30092 | case IrInstSrcIdMemberType: |
| | 30093 | case IrInstSrcIdMemberName: |
| | 30094 | case IrInstSrcIdAlignOf: |
| | 30095 | case IrInstSrcIdReturnAddress: |
| | 30096 | case IrInstSrcIdFrameAddress: |
| | 30097 | case IrInstSrcIdFrameHandle: |
| | 30098 | case IrInstSrcIdFrameType: |
| | 30099 | case IrInstSrcIdFrameSize: |
| | 30100 | case IrInstSrcIdTestErr: |
| | 30101 | case IrInstSrcIdFnProto: |
| | 30102 | case IrInstSrcIdTestComptime: |
| | 30103 | case IrInstSrcIdPtrCast: |
| | 30104 | case IrInstSrcIdBitCast: |
| | 30105 | case IrInstSrcIdPtrToInt: |
| | 30106 | case IrInstSrcIdIntToPtr: |
| | 30107 | case IrInstSrcIdIntToEnum: |
| | 30108 | case IrInstSrcIdIntToErr: |
| | 30109 | case IrInstSrcIdErrToInt: |
| | 30110 | case IrInstSrcIdDeclRef: |
| | 30111 | case IrInstSrcIdErrName: |
| | 30112 | case IrInstSrcIdTypeName: |
| | 30113 | case IrInstSrcIdTagName: |
| | 30114 | case IrInstSrcIdFieldParentPtr: |
| | 30115 | case IrInstSrcIdByteOffsetOf: |
| | 30116 | case IrInstSrcIdBitOffsetOf: |
| | 30117 | case IrInstSrcIdTypeInfo: |
| | 30118 | case IrInstSrcIdType: |
| | 30119 | case IrInstSrcIdHasField: |
| | 30120 | case IrInstSrcIdTypeId: |
| | 30121 | case IrInstSrcIdAlignCast: |
| | 30122 | case IrInstSrcIdImplicitCast: |
| | 30123 | case IrInstSrcIdResolveResult: |
| | 30124 | case IrInstSrcIdOpaqueType: |
| | 30125 | case IrInstSrcIdArgType: |
| | 30126 | case IrInstSrcIdTagType: |
| | 30127 | case IrInstSrcIdErrorReturnTrace: |
| | 30128 | case IrInstSrcIdErrorUnion: |
| | 30129 | case IrInstSrcIdFloatOp: |
| | 30130 | case IrInstSrcIdMulAdd: |
| | 30131 | case IrInstSrcIdAtomicLoad: |
| | 30132 | case IrInstSrcIdIntCast: |
| | 30133 | case IrInstSrcIdFloatCast: |
| | 30134 | case IrInstSrcIdErrSetCast: |
| | 30135 | case IrInstSrcIdIntToFloat: |
| | 30136 | case IrInstSrcIdFloatToInt: |
| | 30137 | case IrInstSrcIdBoolToInt: |
| | 30138 | case IrInstSrcIdFromBytes: |
| | 30139 | case IrInstSrcIdToBytes: |
| | 30140 | case IrInstSrcIdEnumToInt: |
| | 30141 | case IrInstSrcIdHasDecl: |
| | 30142 | case IrInstSrcIdAlloca: |
| | 30143 | case IrInstSrcIdSpillEnd: |
| | 30144 | return false; |
| 29216 | | 30145 | |
| 29217 | case IrInstructionIdAsmGen: | 30146 | case IrInstSrcIdAsm: |
| 29218 | { | 30147 | { |
| 29219 | IrInstructionAsmGen *asm_instruction = (IrInstructionAsmGen *)instruction; | 30148 | IrInstSrcAsm *asm_instruction = (IrInstSrcAsm *)instruction; |
| 29220 | return asm_instruction->has_side_effects; | 30149 | return asm_instruction->has_side_effects; |
| 29221 | } | 30150 | } |
| 29222 | case IrInstructionIdUnwrapErrPayload: | 30151 | |
| | 30152 | case IrInstSrcIdUnwrapErrPayload: |
| 29223 | { | 30153 | { |
| 29224 | IrInstructionUnwrapErrPayload *unwrap_err_payload_instruction = | 30154 | IrInstSrcUnwrapErrPayload *unwrap_err_payload_instruction = |
| 29225 | (IrInstructionUnwrapErrPayload *)instruction; | 30155 | (IrInstSrcUnwrapErrPayload *)instruction; |
| 29226 | return unwrap_err_payload_instruction->safety_check_on || | 30156 | return unwrap_err_payload_instruction->safety_check_on || |
| 29227 | unwrap_err_payload_instruction->initializing; | 30157 | unwrap_err_payload_instruction->initializing; |
| 29228 | } | 30158 | } |
| 29229 | case IrInstructionIdUnwrapErrCode: | 30159 | case IrInstSrcIdUnwrapErrCode: |
| 29230 | return reinterpret_cast<IrInstructionUnwrapErrCode *>(instruction)->initializing; | 30160 | return reinterpret_cast<IrInstSrcUnwrapErrCode *>(instruction)->initializing; |
| 29231 | case IrInstructionIdUnionFieldPtr: | | |
| 29232 | return reinterpret_cast<IrInstructionUnionFieldPtr *>(instruction)->initializing; | | |
| 29233 | case IrInstructionIdErrWrapPayload: | | |
| 29234 | return reinterpret_cast<IrInstructionErrWrapPayload *>(instruction)->result_loc != nullptr; | | |
| 29235 | case IrInstructionIdErrWrapCode: | | |
| 29236 | return reinterpret_cast<IrInstructionErrWrapCode *>(instruction)->result_loc != nullptr; | | |
| 29237 | case IrInstructionIdLoadPtrGen: | | |
| 29238 | return reinterpret_cast<IrInstructionLoadPtrGen *>(instruction)->result_loc != nullptr; | | |
| 29239 | case IrInstructionIdRefGen: | | |
| 29240 | return reinterpret_cast<IrInstructionRefGen *>(instruction)->result_loc != nullptr; | | |
| 29241 | } | 30161 | } |
| 29242 | zig_unreachable(); | 30162 | zig_unreachable(); |
| 29243 | } | 30163 | } |
| ... | @@ -29271,14 +30191,14 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La | ... | @@ -29271,14 +30191,14 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La |
| 29271 | param_info->type = nullptr; | 30191 | param_info->type = nullptr; |
| 29272 | return get_generic_fn_type(ira->codegen, &fn_type_id); | 30192 | return get_generic_fn_type(ira->codegen, &fn_type_id); |
| 29273 | } else { | 30193 | } else { |
| 29274 | IrInstruction *param_type_inst = lazy_fn_type->param_types[fn_type_id.next_param_index]; | 30194 | IrInstGen *param_type_inst = lazy_fn_type->param_types[fn_type_id.next_param_index]; |
| 29275 | ZigType *param_type = ir_resolve_type(ira, param_type_inst); | 30195 | ZigType *param_type = ir_resolve_type(ira, param_type_inst); |
| 29276 | if (type_is_invalid(param_type)) | 30196 | if (type_is_invalid(param_type)) |
| 29277 | return nullptr; | 30197 | return nullptr; |
| 29278 | switch (type_requires_comptime(ira->codegen, param_type)) { | 30198 | switch (type_requires_comptime(ira->codegen, param_type)) { |
| 29279 | case ReqCompTimeYes: | 30199 | case ReqCompTimeYes: |
| 29280 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { | 30200 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { |
| 29281 | ir_add_error(ira, param_type_inst, | 30201 | ir_add_error(ira, &param_type_inst->base, |
| 29282 | buf_sprintf("parameter of type '%s' not allowed in function with calling convention '%s'", | 30202 | buf_sprintf("parameter of type '%s' not allowed in function with calling convention '%s'", |
| 29283 | buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc))); | 30203 | buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc))); |
| 29284 | return nullptr; | 30204 | return nullptr; |
| ... | @@ -29296,7 +30216,7 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La | ... | @@ -29296,7 +30216,7 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La |
| 29296 | if ((err = type_has_bits2(ira->codegen, param_type, &has_bits))) | 30216 | if ((err = type_has_bits2(ira->codegen, param_type, &has_bits))) |
| 29297 | return nullptr; | 30217 | return nullptr; |
| 29298 | if (!has_bits) { | 30218 | if (!has_bits) { |
| 29299 | ir_add_error(ira, param_type_inst, | 30219 | ir_add_error(ira, &param_type_inst->base, |
| 29300 | buf_sprintf("parameter of type '%s' has 0 bits; not allowed in function with calling convention '%s'", | 30220 | buf_sprintf("parameter of type '%s' has 0 bits; not allowed in function with calling convention '%s'", |
| 29301 | buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc))); | 30221 | buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc))); |
| 29302 | return nullptr; | 30222 | return nullptr; |
| ... | @@ -29315,7 +30235,7 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La | ... | @@ -29315,7 +30235,7 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La |
| 29315 | if (type_is_invalid(fn_type_id.return_type)) | 30235 | if (type_is_invalid(fn_type_id.return_type)) |
| 29316 | return nullptr; | 30236 | return nullptr; |
| 29317 | if (fn_type_id.return_type->id == ZigTypeIdOpaque) { | 30237 | if (fn_type_id.return_type->id == ZigTypeIdOpaque) { |
| 29318 | ir_add_error(ira, lazy_fn_type->return_type, buf_create_from_str("return type cannot be opaque")); | 30238 | ir_add_error(ira, &lazy_fn_type->return_type->base, buf_create_from_str("return type cannot be opaque")); |
| 29319 | return nullptr; | 30239 | return nullptr; |
| 29320 | } | 30240 | } |
| 29321 | | 30241 | |
| ... | @@ -29347,7 +30267,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29347,7 +30267,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29347 | case ZigTypeIdBoundFn: | 30267 | case ZigTypeIdBoundFn: |
| 29348 | case ZigTypeIdVoid: | 30268 | case ZigTypeIdVoid: |
| 29349 | case ZigTypeIdOpaque: | 30269 | case ZigTypeIdOpaque: |
| 29350 | ir_add_error(ira, lazy_align_of->target_type, | 30270 | ir_add_error(ira, &lazy_align_of->target_type->base, |
| 29351 | buf_sprintf("no align available for type '%s'", | 30271 | buf_sprintf("no align available for type '%s'", |
| 29352 | buf_ptr(&lazy_align_of->target_type->value->data.x_type->name))); | 30272 | buf_ptr(&lazy_align_of->target_type->value->data.x_type->name))); |
| 29353 | return ErrorSemanticAnalyzeFail; | 30273 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -29397,7 +30317,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29397,7 +30317,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29397 | case ZigTypeIdNull: | 30317 | case ZigTypeIdNull: |
| 29398 | case ZigTypeIdBoundFn: | 30318 | case ZigTypeIdBoundFn: |
| 29399 | case ZigTypeIdOpaque: | 30319 | case ZigTypeIdOpaque: |
| 29400 | ir_add_error(ira, lazy_size_of->target_type, | 30320 | ir_add_error(ira, &lazy_size_of->target_type->base, |
| 29401 | buf_sprintf("no size available for type '%s'", | 30321 | buf_sprintf("no size available for type '%s'", |
| 29402 | buf_ptr(&lazy_size_of->target_type->value->data.x_type->name))); | 30322 | buf_ptr(&lazy_size_of->target_type->value->data.x_type->name))); |
| 29403 | return ErrorSemanticAnalyzeFail; | 30323 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -29455,7 +30375,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29455,7 +30375,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29455 | if (lazy_slice_type->sentinel != nullptr) { | 30375 | if (lazy_slice_type->sentinel != nullptr) { |
| 29456 | if (type_is_invalid(lazy_slice_type->sentinel->value->type)) | 30376 | if (type_is_invalid(lazy_slice_type->sentinel->value->type)) |
| 29457 | return ErrorSemanticAnalyzeFail; | 30377 | return ErrorSemanticAnalyzeFail; |
| 29458 | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_slice_type->sentinel, elem_type); | 30378 | IrInstGen *sentinel = ir_implicit_cast(ira, lazy_slice_type->sentinel, elem_type); |
| 29459 | if (type_is_invalid(sentinel->value->type)) | 30379 | if (type_is_invalid(sentinel->value->type)) |
| 29460 | return ErrorSemanticAnalyzeFail; | 30380 | return ErrorSemanticAnalyzeFail; |
| 29461 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); | 30381 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| ... | @@ -29478,7 +30398,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29478,7 +30398,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29478 | case ZigTypeIdUndefined: | 30398 | case ZigTypeIdUndefined: |
| 29479 | case ZigTypeIdNull: | 30399 | case ZigTypeIdNull: |
| 29480 | case ZigTypeIdOpaque: | 30400 | case ZigTypeIdOpaque: |
| 29481 | ir_add_error(ira, lazy_slice_type->elem_type, | 30401 | ir_add_error(ira, &lazy_slice_type->elem_type->base, |
| 29482 | buf_sprintf("slice of type '%s' not allowed", buf_ptr(&elem_type->name))); | 30402 | buf_sprintf("slice of type '%s' not allowed", buf_ptr(&elem_type->name))); |
| 29483 | return ErrorSemanticAnalyzeFail; | 30403 | return ErrorSemanticAnalyzeFail; |
| 29484 | case ZigTypeIdMetaType: | 30404 | case ZigTypeIdMetaType: |
| ... | @@ -29534,7 +30454,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29534,7 +30454,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29534 | if (lazy_ptr_type->sentinel != nullptr) { | 30454 | if (lazy_ptr_type->sentinel != nullptr) { |
| 29535 | if (type_is_invalid(lazy_ptr_type->sentinel->value->type)) | 30455 | if (type_is_invalid(lazy_ptr_type->sentinel->value->type)) |
| 29536 | return ErrorSemanticAnalyzeFail; | 30456 | return ErrorSemanticAnalyzeFail; |
| 29537 | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_ptr_type->sentinel, elem_type); | 30457 | IrInstGen *sentinel = ir_implicit_cast(ira, lazy_ptr_type->sentinel, elem_type); |
| 29538 | if (type_is_invalid(sentinel->value->type)) | 30458 | if (type_is_invalid(sentinel->value->type)) |
| 29539 | return ErrorSemanticAnalyzeFail; | 30459 | return ErrorSemanticAnalyzeFail; |
| 29540 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); | 30460 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| ... | @@ -29551,11 +30471,11 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29551,11 +30471,11 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29551 | } | 30471 | } |
| 29552 | | 30472 | |
| 29553 | if (elem_type->id == ZigTypeIdUnreachable) { | 30473 | if (elem_type->id == ZigTypeIdUnreachable) { |
| 29554 | ir_add_error(ira, lazy_ptr_type->elem_type, | 30474 | ir_add_error(ira, &lazy_ptr_type->elem_type->base, |
| 29555 | buf_create_from_str("pointer to noreturn not allowed")); | 30475 | buf_create_from_str("pointer to noreturn not allowed")); |
| 29556 | return ErrorSemanticAnalyzeFail; | 30476 | return ErrorSemanticAnalyzeFail; |
| 29557 | } else if (elem_type->id == ZigTypeIdOpaque && lazy_ptr_type->ptr_len == PtrLenUnknown) { | 30477 | } else if (elem_type->id == ZigTypeIdOpaque && lazy_ptr_type->ptr_len == PtrLenUnknown) { |
| 29558 | ir_add_error(ira, lazy_ptr_type->elem_type, | 30478 | ir_add_error(ira, &lazy_ptr_type->elem_type->base, |
| 29559 | buf_create_from_str("unknown-length pointer to opaque")); | 30479 | buf_create_from_str("unknown-length pointer to opaque")); |
| 29560 | return ErrorSemanticAnalyzeFail; | 30480 | return ErrorSemanticAnalyzeFail; |
| 29561 | } else if (lazy_ptr_type->ptr_len == PtrLenC) { | 30481 | } else if (lazy_ptr_type->ptr_len == PtrLenC) { |
| ... | @@ -29563,16 +30483,16 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29563,16 +30483,16 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29563 | if ((err = type_allowed_in_extern(ira->codegen, elem_type, &ok_type))) | 30483 | if ((err = type_allowed_in_extern(ira->codegen, elem_type, &ok_type))) |
| 29564 | return err; | 30484 | return err; |
| 29565 | if (!ok_type) { | 30485 | if (!ok_type) { |
| 29566 | ir_add_error(ira, lazy_ptr_type->elem_type, | 30486 | ir_add_error(ira, &lazy_ptr_type->elem_type->base, |
| 29567 | buf_sprintf("C pointers cannot point to non-C-ABI-compatible type '%s'", | 30487 | buf_sprintf("C pointers cannot point to non-C-ABI-compatible type '%s'", |
| 29568 | buf_ptr(&elem_type->name))); | 30488 | buf_ptr(&elem_type->name))); |
| 29569 | return ErrorSemanticAnalyzeFail; | 30489 | return ErrorSemanticAnalyzeFail; |
| 29570 | } else if (elem_type->id == ZigTypeIdOpaque) { | 30490 | } else if (elem_type->id == ZigTypeIdOpaque) { |
| 29571 | ir_add_error(ira, lazy_ptr_type->elem_type, | 30491 | ir_add_error(ira, &lazy_ptr_type->elem_type->base, |
| 29572 | buf_sprintf("C pointers cannot point opaque types")); | 30492 | buf_sprintf("C pointers cannot point opaque types")); |
| 29573 | return ErrorSemanticAnalyzeFail; | 30493 | return ErrorSemanticAnalyzeFail; |
| 29574 | } else if (lazy_ptr_type->is_allowzero) { | 30494 | } else if (lazy_ptr_type->is_allowzero) { |
| 29575 | ir_add_error(ira, lazy_ptr_type->elem_type, | 30495 | ir_add_error(ira, &lazy_ptr_type->elem_type->base, |
| 29576 | buf_sprintf("C pointers always allow address zero")); | 30496 | buf_sprintf("C pointers always allow address zero")); |
| 29577 | return ErrorSemanticAnalyzeFail; | 30497 | return ErrorSemanticAnalyzeFail; |
| 29578 | } | 30498 | } |
| ... | @@ -29610,7 +30530,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29610,7 +30530,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29610 | case ZigTypeIdUndefined: | 30530 | case ZigTypeIdUndefined: |
| 29611 | case ZigTypeIdNull: | 30531 | case ZigTypeIdNull: |
| 29612 | case ZigTypeIdOpaque: | 30532 | case ZigTypeIdOpaque: |
| 29613 | ir_add_error(ira, lazy_array_type->elem_type, | 30533 | ir_add_error(ira, &lazy_array_type->elem_type->base, |
| 29614 | buf_sprintf("array of type '%s' not allowed", | 30534 | buf_sprintf("array of type '%s' not allowed", |
| 29615 | buf_ptr(&elem_type->name))); | 30535 | buf_ptr(&elem_type->name))); |
| 29616 | return ErrorSemanticAnalyzeFail; | 30536 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -29645,7 +30565,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29645,7 +30565,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29645 | if (lazy_array_type->sentinel != nullptr) { | 30565 | if (lazy_array_type->sentinel != nullptr) { |
| 29646 | if (type_is_invalid(lazy_array_type->sentinel->value->type)) | 30566 | if (type_is_invalid(lazy_array_type->sentinel->value->type)) |
| 29647 | return ErrorSemanticAnalyzeFail; | 30567 | return ErrorSemanticAnalyzeFail; |
| 29648 | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_array_type->sentinel, elem_type); | 30568 | IrInstGen *sentinel = ir_implicit_cast(ira, lazy_array_type->sentinel, elem_type); |
| 29649 | if (type_is_invalid(sentinel->value->type)) | 30569 | if (type_is_invalid(sentinel->value->type)) |
| 29650 | return ErrorSemanticAnalyzeFail; | 30570 | return ErrorSemanticAnalyzeFail; |
| 29651 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); | 30571 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| ... | @@ -29669,7 +30589,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29669,7 +30589,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29669 | return ErrorSemanticAnalyzeFail; | 30589 | return ErrorSemanticAnalyzeFail; |
| 29670 | | 30590 | |
| 29671 | if (payload_type->id == ZigTypeIdOpaque || payload_type->id == ZigTypeIdUnreachable) { | 30591 | if (payload_type->id == ZigTypeIdOpaque || payload_type->id == ZigTypeIdUnreachable) { |
| 29672 | ir_add_error(ira, lazy_opt_type->payload_type, | 30592 | ir_add_error(ira, &lazy_opt_type->payload_type->base, |
| 29673 | buf_sprintf("type '%s' cannot be optional", buf_ptr(&payload_type->name))); | 30593 | buf_sprintf("type '%s' cannot be optional", buf_ptr(&payload_type->name))); |
| 29674 | return ErrorSemanticAnalyzeFail; | 30594 | return ErrorSemanticAnalyzeFail; |
| 29675 | } | 30595 | } |
| ... | @@ -29711,7 +30631,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29711,7 +30631,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29711 | return ErrorSemanticAnalyzeFail; | 30631 | return ErrorSemanticAnalyzeFail; |
| 29712 | | 30632 | |
| 29713 | if (err_set_type->id != ZigTypeIdErrorSet) { | 30633 | if (err_set_type->id != ZigTypeIdErrorSet) { |
| 29714 | ir_add_error(ira, lazy_err_union_type->err_set_type, | 30634 | ir_add_error(ira, &lazy_err_union_type->err_set_type->base, |
| 29715 | buf_sprintf("expected error set type, found type '%s'", | 30635 | buf_sprintf("expected error set type, found type '%s'", |
| 29716 | buf_ptr(&err_set_type->name))); | 30636 | buf_ptr(&err_set_type->name))); |
| 29717 | return ErrorSemanticAnalyzeFail; | 30637 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -29747,8 +30667,8 @@ Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ZigValue *val) { | ... | @@ -29747,8 +30667,8 @@ Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ZigValue *val) { |
| 29747 | return ErrorNone; | 30667 | return ErrorNone; |
| 29748 | } | 30668 | } |
| 29749 | | 30669 | |
| 29750 | void IrInstruction::src() { | 30670 | void IrInst::src() { |
| 29751 | IrInstruction *inst = this; | 30671 | IrInst *inst = this; |
| 29752 | if (inst->source_node != nullptr) { | 30672 | if (inst->source_node != nullptr) { |
| 29753 | inst->source_node->src(); | 30673 | inst->source_node->src(); |
| 29754 | } else { | 30674 | } else { |
| ... | @@ -29756,26 +30676,45 @@ void IrInstruction::src() { | ... | @@ -29756,26 +30676,45 @@ void IrInstruction::src() { |
| 29756 | } | 30676 | } |
| 29757 | } | 30677 | } |
| 29758 | | 30678 | |
| 29759 | void IrInstruction::dump() { | 30679 | void IrInst::dump() { |
| 29760 | IrInstruction *inst = this; | 30680 | this->src(); |
| | 30681 | fprintf(stderr, "IrInst(#%" PRIu32 ")\n", this->debug_id); |
| | 30682 | } |
| | 30683 | |
| | 30684 | void IrInstSrc::src() { |
| | 30685 | this->base.src(); |
| | 30686 | } |
| | 30687 | |
| | 30688 | void IrInstGen::src() { |
| | 30689 | this->base.src(); |
| | 30690 | } |
| | 30691 | |
| | 30692 | void IrInstSrc::dump() { |
| | 30693 | IrInstSrc *inst = this; |
| 29761 | inst->src(); | 30694 | inst->src(); |
| 29762 | IrPass pass = (inst->child == nullptr) ? IrPassGen : IrPassSrc; | 30695 | if (inst->base.scope == nullptr) { |
| 29763 | if (inst->scope == nullptr) { | | |
| 29764 | fprintf(stderr, "(null scope)\n"); | 30696 | fprintf(stderr, "(null scope)\n"); |
| 29765 | } else { | 30697 | } else { |
| 29766 | ir_print_instruction(inst->scope->codegen, stderr, inst, 0, pass); | 30698 | ir_print_inst_src(inst->base.scope->codegen, stderr, inst, 0); |
| 29767 | if (pass == IrPassSrc) { | 30699 | fprintf(stderr, "-> "); |
| 29768 | fprintf(stderr, "-> "); | 30700 | ir_print_inst_gen(inst->base.scope->codegen, stderr, inst->child, 0); |
| 29769 | ir_print_instruction(inst->scope->codegen, stderr, inst->child, 0, IrPassGen); | 30701 | } |
| 29770 | } | 30702 | } |
| | 30703 | void IrInstGen::dump() { |
| | 30704 | IrInstGen *inst = this; |
| | 30705 | inst->src(); |
| | 30706 | if (inst->base.scope == nullptr) { |
| | 30707 | fprintf(stderr, "(null scope)\n"); |
| | 30708 | } else { |
| | 30709 | ir_print_inst_gen(inst->base.scope->codegen, stderr, inst, 0); |
| 29771 | } | 30710 | } |
| 29772 | } | 30711 | } |
| 29773 | | 30712 | |
| 29774 | void IrAnalyze::dump() { | 30713 | void IrAnalyze::dump() { |
| 29775 | ir_print(this->codegen, stderr, this->new_irb.exec, 0, IrPassGen); | 30714 | ir_print_gen(this->codegen, stderr, this->new_irb.exec, 0); |
| 29776 | if (this->new_irb.current_basic_block != nullptr) { | 30715 | if (this->new_irb.current_basic_block != nullptr) { |
| 29777 | fprintf(stderr, "Current basic block:\n"); | 30716 | fprintf(stderr, "Current basic block:\n"); |
| 29778 | ir_print_basic_block(this->codegen, stderr, this->new_irb.current_basic_block, 1, IrPassGen); | 30717 | ir_print_basic_block_gen(this->codegen, stderr, this->new_irb.current_basic_block, 1); |
| 29779 | } | 30718 | } |
| 29780 | } | 30719 | } |
| 29781 | | 30720 | |