| ... | @@ -21,25 +21,31 @@ struct IrExecContext { | ... | @@ -21,25 +21,31 @@ struct IrExecContext { |
| 21 | ZigList<ZigValue *> mem_slot_list; | 21 | ZigList<ZigValue *> mem_slot_list; |
| 22 | }; | 22 | }; |
| 23 | | 23 | |
| 24 | struct IrBuilder { | 24 | struct IrBuilderSrc { |
| 25 | CodeGen *codegen; | 25 | CodeGen *codegen; |
| 26 | IrExecutable *exec; | 26 | IrExecutableSrc *exec; |
| 27 | IrBasicBlock *current_basic_block; | 27 | IrBasicBlockSrc *current_basic_block; |
| 28 | AstNode *main_block_node; | 28 | AstNode *main_block_node; |
| 29 | }; | 29 | }; |
| 30 | | 30 | |
| | 31 | struct IrBuilderGen { |
| | 32 | CodeGen *codegen; |
| | 33 | IrExecutableGen *exec; |
| | 34 | IrBasicBlockGen *current_basic_block; |
| | 35 | }; |
| | 36 | |
| 31 | struct IrAnalyze { | 37 | struct IrAnalyze { |
| 32 | CodeGen *codegen; | 38 | CodeGen *codegen; |
| 33 | IrBuilder old_irb; | 39 | IrBuilderSrc old_irb; |
| 34 | IrBuilder new_irb; | 40 | IrBuilderGen new_irb; |
| 35 | IrExecContext exec_context; | 41 | IrExecContext exec_context; |
| 36 | size_t old_bb_index; | 42 | size_t old_bb_index; |
| 37 | size_t instruction_index; | 43 | size_t instruction_index; |
| 38 | ZigType *explicit_return_type; | 44 | ZigType *explicit_return_type; |
| 39 | AstNode *explicit_return_type_source_node; | 45 | AstNode *explicit_return_type_source_node; |
| 40 | ZigList<IrInstruction *> src_implicit_return_type_list; | 46 | ZigList<IrInstGen *> src_implicit_return_type_list; |
| 41 | ZigList<IrSuspendPosition> resume_stack; | 47 | ZigList<IrSuspendPosition> resume_stack; |
| 42 | IrBasicBlock *const_predecessor_bb; | 48 | IrBasicBlockSrc *const_predecessor_bb; |
| 43 | size_t ref_count; | 49 | size_t ref_count; |
| 44 | size_t break_debug_id; // for debugging purposes | 50 | size_t break_debug_id; // for debugging purposes |
| 45 | | 51 | |
| ... | @@ -206,412 +212,538 @@ struct DbgIrBreakPoint { | ... | @@ -206,412 +212,538 @@ struct DbgIrBreakPoint { |
| 206 | DbgIrBreakPoint dbg_ir_breakpoints_buf[20]; | 212 | DbgIrBreakPoint dbg_ir_breakpoints_buf[20]; |
| 207 | size_t dbg_ir_breakpoints_count = 0; | 213 | size_t dbg_ir_breakpoints_count = 0; |
| 208 | | 214 | |
| 209 | static IrInstruction *ir_gen_node(IrBuilder *irb, AstNode *node, Scope *scope); | 215 | static IrInstSrc *ir_gen_node(IrBuilderSrc *irb, AstNode *node, Scope *scope); |
| 210 | static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *scope, LVal lval, | 216 | static IrInstSrc *ir_gen_node_extra(IrBuilderSrc *irb, AstNode *node, Scope *scope, LVal lval, |
| 211 | ResultLoc *result_loc); | 217 | ResultLoc *result_loc); |
| 212 | static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, ZigType *expected_type); | 218 | static IrInstGen *ir_implicit_cast(IrAnalyze *ira, IrInstGen *value, ZigType *expected_type); |
| 213 | static IrInstruction *ir_implicit_cast2(IrAnalyze *ira, IrInstruction *value_source_instr, | 219 | static IrInstGen *ir_implicit_cast2(IrAnalyze *ira, IrInst *value_source_instr, |
| 214 | IrInstruction *value, ZigType *expected_type); | 220 | IrInstGen *value, ZigType *expected_type); |
| 215 | static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr, | 221 | static IrInstGen *ir_get_deref(IrAnalyze *ira, IrInst *source_instr, IrInstGen *ptr, |
| 216 | ResultLoc *result_loc); | 222 | ResultLoc *result_loc); |
| 217 | static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, Buf *msg); | 223 | static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutableSrc *exec, AstNode *source_node, Buf *msg); |
| 218 | static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name, | 224 | static IrInstGen *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name, |
| 219 | IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type, bool initializing); | 225 | IrInst* source_instr, IrInstGen *container_ptr, ZigType *container_type, bool initializing); |
| 220 | static void ir_assert(bool ok, IrInstruction *source_instruction); | 226 | static void ir_assert(bool ok, IrInst* source_instruction); |
| 221 | static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, ZigVar *var); | 227 | static void ir_assert_gen(bool ok, IrInstGen *source_instruction); |
| 222 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op); | 228 | static IrInstGen *ir_get_var_ptr(IrAnalyze *ira, IrInst *source_instr, ZigVar *var); |
| 223 | static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction *value, LVal lval, ResultLoc *result_loc); | 229 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstGen *op); |
| 224 | static IrInstruction *ir_expr_wrap(IrBuilder *irb, Scope *scope, IrInstruction *inst, ResultLoc *result_loc); | 230 | static IrInstSrc *ir_lval_wrap(IrBuilderSrc *irb, Scope *scope, IrInstSrc *value, LVal lval, ResultLoc *result_loc); |
| | 231 | static IrInstSrc *ir_expr_wrap(IrBuilderSrc *irb, Scope *scope, IrInstSrc *inst, ResultLoc *result_loc); |
| 225 | static ZigType *adjust_ptr_align(CodeGen *g, ZigType *ptr_type, uint32_t new_align); | 232 | static ZigType *adjust_ptr_align(CodeGen *g, ZigType *ptr_type, uint32_t new_align); |
| 226 | static ZigType *adjust_slice_align(CodeGen *g, ZigType *slice_type, uint32_t new_align); | 233 | static ZigType *adjust_slice_align(CodeGen *g, ZigType *slice_type, uint32_t new_align); |
| 227 | static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, ZigValue *val); | 234 | static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, ZigValue *val); |
| 228 | static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ZigValue *val); | 235 | static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ZigValue *val); |
| 229 | static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, | 236 | static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, |
| 230 | ZigValue *out_val, ZigValue *ptr_val); | 237 | ZigValue *out_val, ZigValue *ptr_val); |
| 231 | static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *ptr, | 238 | static IrInstGen *ir_analyze_ptr_cast(IrAnalyze *ira, IrInst* source_instr, IrInstGen *ptr, |
| 232 | ZigType *dest_type, IrInstruction *dest_type_src, bool safety_check_on); | 239 | ZigType *dest_type, IrInst *dest_type_src, bool safety_check_on); |
| 233 | static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed); | 240 | static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstGen *value, UndefAllowed undef_allowed); |
| 234 | static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_align); | 241 | static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_align); |
| 235 | static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, | 242 | static IrInstGen *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInst* source_instr, IrInstGen *target, |
| 236 | ZigType *ptr_type); | 243 | ZigType *ptr_type); |
| 237 | static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 244 | static IrInstGen *ir_analyze_bit_cast(IrAnalyze *ira, IrInst* source_instr, IrInstGen *value, |
| 238 | ZigType *dest_type); | 245 | ZigType *dest_type); |
| 239 | static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspend_source_instr, | 246 | static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInst *suspend_source_instr, |
| 240 | ResultLoc *result_loc, ZigType *value_type, IrInstruction *value, bool force_runtime, | 247 | ResultLoc *result_loc, ZigType *value_type, IrInstGen *value, bool force_runtime, |
| 241 | bool non_null_comptime, bool allow_discard); | 248 | bool non_null_comptime, bool allow_discard); |
| 242 | static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_source_instr, | 249 | static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr, |
| 243 | ResultLoc *result_loc, ZigType *value_type, IrInstruction *value, bool force_runtime, | 250 | ResultLoc *result_loc, ZigType *value_type, IrInstGen *value, bool force_runtime, |
| 244 | bool non_null_comptime, bool allow_discard); | 251 | bool non_null_comptime, bool allow_discard); |
| 245 | static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstruction *source_instr, | 252 | static IrInstGen *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInst* source_instr, |
| 246 | IrInstruction *base_ptr, bool safety_check_on, bool initializing); | 253 | IrInstGen *base_ptr, bool safety_check_on, bool initializing); |
| 247 | static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruction *source_instr, | 254 | static IrInstGen *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInst* source_instr, |
| 248 | IrInstruction *base_ptr, bool safety_check_on, bool initializing); | 255 | IrInstGen *base_ptr, bool safety_check_on, bool initializing); |
| 249 | static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction *source_instr, | 256 | static IrInstGen *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInst* source_instr, |
| 250 | IrInstruction *base_ptr, bool initializing); | 257 | IrInstGen *base_ptr, bool initializing); |
| 251 | static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source_instr, | 258 | static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, IrInst* source_instr, |
| 252 | IrInstruction *ptr, IrInstruction *uncasted_value, bool allow_write_through_const); | 259 | IrInstGen *ptr, IrInstGen *uncasted_value, bool allow_write_through_const); |
| 253 | static IrInstruction *ir_gen_union_init_expr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 260 | static IrInstSrc *ir_gen_union_init_expr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 254 | IrInstruction *union_type, IrInstruction *field_name, AstNode *expr_node, | 261 | IrInstSrc *union_type, IrInstSrc *field_name, AstNode *expr_node, |
| 255 | LVal lval, ResultLoc *parent_result_loc); | 262 | LVal lval, ResultLoc *parent_result_loc); |
| 256 | static void ir_reset_result(ResultLoc *result_loc); | 263 | static void ir_reset_result(ResultLoc *result_loc); |
| 257 | static Buf *get_anon_type_name(CodeGen *codegen, IrExecutable *exec, const char *kind_name, | 264 | static Buf *get_anon_type_name(CodeGen *codegen, IrExecutableSrc *exec, const char *kind_name, |
| 258 | Scope *scope, AstNode *source_node, Buf *out_bare_name); | 265 | Scope *scope, AstNode *source_node, Buf *out_bare_name); |
| 259 | static ResultLocCast *ir_build_cast_result_loc(IrBuilder *irb, IrInstruction *dest_type, | 266 | static ResultLocCast *ir_build_cast_result_loc(IrBuilderSrc *irb, IrInstSrc *dest_type, |
| 260 | ResultLoc *parent_result_loc); | 267 | ResultLoc *parent_result_loc); |
| 261 | static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction *source_instr, | 268 | static IrInstGen *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInst* source_instr, |
| 262 | TypeStructField *field, IrInstruction *struct_ptr, ZigType *struct_type, bool initializing); | 269 | TypeStructField *field, IrInstGen *struct_ptr, ZigType *struct_type, bool initializing); |
| 263 | static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, | 270 | static IrInstGen *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, |
| 264 | IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type); | 271 | IrInst* source_instr, IrInstGen *container_ptr, ZigType *container_type); |
| 265 | static ResultLoc *no_result_loc(void); | 272 | static ResultLoc *no_result_loc(void); |
| 266 | static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *source_inst, IrInstruction *value); | 273 | static IrInstGen *ir_analyze_test_non_null(IrAnalyze *ira, IrInst *source_inst, IrInstGen *value); |
| | 274 | |
| | 275 | static void destroy_instruction_src(IrInstSrc *inst) { |
| | 276 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| | 277 | const char *name = ir_inst_src_type_str(inst->id); |
| | 278 | #else |
| | 279 | const char *name = nullptr; |
| | 280 | #endif |
| | 281 | switch (inst->id) { |
| | 282 | case IrInstSrcIdInvalid: |
| | 283 | zig_unreachable(); |
| | 284 | case IrInstSrcIdReturn: |
| | 285 | return destroy(reinterpret_cast<IrInstSrcReturn *>(inst), name); |
| | 286 | case IrInstSrcIdConst: |
| | 287 | return destroy(reinterpret_cast<IrInstSrcConst *>(inst), name); |
| | 288 | case IrInstSrcIdBinOp: |
| | 289 | return destroy(reinterpret_cast<IrInstSrcBinOp *>(inst), name); |
| | 290 | case IrInstSrcIdMergeErrSets: |
| | 291 | return destroy(reinterpret_cast<IrInstSrcMergeErrSets *>(inst), name); |
| | 292 | case IrInstSrcIdDeclVar: |
| | 293 | return destroy(reinterpret_cast<IrInstSrcDeclVar *>(inst), name); |
| | 294 | case IrInstSrcIdCall: |
| | 295 | return destroy(reinterpret_cast<IrInstSrcCall *>(inst), name); |
| | 296 | case IrInstSrcIdCallExtra: |
| | 297 | return destroy(reinterpret_cast<IrInstSrcCallExtra *>(inst), name); |
| | 298 | case IrInstSrcIdUnOp: |
| | 299 | return destroy(reinterpret_cast<IrInstSrcUnOp *>(inst), name); |
| | 300 | case IrInstSrcIdCondBr: |
| | 301 | return destroy(reinterpret_cast<IrInstSrcCondBr *>(inst), name); |
| | 302 | case IrInstSrcIdBr: |
| | 303 | return destroy(reinterpret_cast<IrInstSrcBr *>(inst), name); |
| | 304 | case IrInstSrcIdPhi: |
| | 305 | return destroy(reinterpret_cast<IrInstSrcPhi *>(inst), name); |
| | 306 | case IrInstSrcIdContainerInitList: |
| | 307 | return destroy(reinterpret_cast<IrInstSrcContainerInitList *>(inst), name); |
| | 308 | case IrInstSrcIdContainerInitFields: |
| | 309 | return destroy(reinterpret_cast<IrInstSrcContainerInitFields *>(inst), name); |
| | 310 | case IrInstSrcIdUnreachable: |
| | 311 | return destroy(reinterpret_cast<IrInstSrcUnreachable *>(inst), name); |
| | 312 | case IrInstSrcIdElemPtr: |
| | 313 | return destroy(reinterpret_cast<IrInstSrcElemPtr *>(inst), name); |
| | 314 | case IrInstSrcIdVarPtr: |
| | 315 | return destroy(reinterpret_cast<IrInstSrcVarPtr *>(inst), name); |
| | 316 | case IrInstSrcIdLoadPtr: |
| | 317 | return destroy(reinterpret_cast<IrInstSrcLoadPtr *>(inst), name); |
| | 318 | case IrInstSrcIdStorePtr: |
| | 319 | return destroy(reinterpret_cast<IrInstSrcStorePtr *>(inst), name); |
| | 320 | case IrInstSrcIdTypeOf: |
| | 321 | return destroy(reinterpret_cast<IrInstSrcTypeOf *>(inst), name); |
| | 322 | case IrInstSrcIdFieldPtr: |
| | 323 | return destroy(reinterpret_cast<IrInstSrcFieldPtr *>(inst), name); |
| | 324 | case IrInstSrcIdSetCold: |
| | 325 | return destroy(reinterpret_cast<IrInstSrcSetCold *>(inst), name); |
| | 326 | case IrInstSrcIdSetRuntimeSafety: |
| | 327 | return destroy(reinterpret_cast<IrInstSrcSetRuntimeSafety *>(inst), name); |
| | 328 | case IrInstSrcIdSetFloatMode: |
| | 329 | return destroy(reinterpret_cast<IrInstSrcSetFloatMode *>(inst), name); |
| | 330 | case IrInstSrcIdArrayType: |
| | 331 | return destroy(reinterpret_cast<IrInstSrcArrayType *>(inst), name); |
| | 332 | case IrInstSrcIdSliceType: |
| | 333 | return destroy(reinterpret_cast<IrInstSrcSliceType *>(inst), name); |
| | 334 | case IrInstSrcIdAnyFrameType: |
| | 335 | return destroy(reinterpret_cast<IrInstSrcAnyFrameType *>(inst), name); |
| | 336 | case IrInstSrcIdAsm: |
| | 337 | return destroy(reinterpret_cast<IrInstSrcAsm *>(inst), name); |
| | 338 | case IrInstSrcIdSizeOf: |
| | 339 | return destroy(reinterpret_cast<IrInstSrcSizeOf *>(inst), name); |
| | 340 | case IrInstSrcIdTestNonNull: |
| | 341 | return destroy(reinterpret_cast<IrInstSrcTestNonNull *>(inst), name); |
| | 342 | case IrInstSrcIdOptionalUnwrapPtr: |
| | 343 | return destroy(reinterpret_cast<IrInstSrcOptionalUnwrapPtr *>(inst), name); |
| | 344 | case IrInstSrcIdPopCount: |
| | 345 | return destroy(reinterpret_cast<IrInstSrcPopCount *>(inst), name); |
| | 346 | case IrInstSrcIdClz: |
| | 347 | return destroy(reinterpret_cast<IrInstSrcClz *>(inst), name); |
| | 348 | case IrInstSrcIdCtz: |
| | 349 | return destroy(reinterpret_cast<IrInstSrcCtz *>(inst), name); |
| | 350 | case IrInstSrcIdBswap: |
| | 351 | return destroy(reinterpret_cast<IrInstSrcBswap *>(inst), name); |
| | 352 | case IrInstSrcIdBitReverse: |
| | 353 | return destroy(reinterpret_cast<IrInstSrcBitReverse *>(inst), name); |
| | 354 | case IrInstSrcIdSwitchBr: |
| | 355 | return destroy(reinterpret_cast<IrInstSrcSwitchBr *>(inst), name); |
| | 356 | case IrInstSrcIdSwitchVar: |
| | 357 | return destroy(reinterpret_cast<IrInstSrcSwitchVar *>(inst), name); |
| | 358 | case IrInstSrcIdSwitchElseVar: |
| | 359 | return destroy(reinterpret_cast<IrInstSrcSwitchElseVar *>(inst), name); |
| | 360 | case IrInstSrcIdSwitchTarget: |
| | 361 | return destroy(reinterpret_cast<IrInstSrcSwitchTarget *>(inst), name); |
| | 362 | case IrInstSrcIdImport: |
| | 363 | return destroy(reinterpret_cast<IrInstSrcImport *>(inst), name); |
| | 364 | case IrInstSrcIdRef: |
| | 365 | return destroy(reinterpret_cast<IrInstSrcRef *>(inst), name); |
| | 366 | case IrInstSrcIdCompileErr: |
| | 367 | return destroy(reinterpret_cast<IrInstSrcCompileErr *>(inst), name); |
| | 368 | case IrInstSrcIdCompileLog: |
| | 369 | return destroy(reinterpret_cast<IrInstSrcCompileLog *>(inst), name); |
| | 370 | case IrInstSrcIdErrName: |
| | 371 | return destroy(reinterpret_cast<IrInstSrcErrName *>(inst), name); |
| | 372 | case IrInstSrcIdCImport: |
| | 373 | return destroy(reinterpret_cast<IrInstSrcCImport *>(inst), name); |
| | 374 | case IrInstSrcIdCInclude: |
| | 375 | return destroy(reinterpret_cast<IrInstSrcCInclude *>(inst), name); |
| | 376 | case IrInstSrcIdCDefine: |
| | 377 | return destroy(reinterpret_cast<IrInstSrcCDefine *>(inst), name); |
| | 378 | case IrInstSrcIdCUndef: |
| | 379 | return destroy(reinterpret_cast<IrInstSrcCUndef *>(inst), name); |
| | 380 | case IrInstSrcIdEmbedFile: |
| | 381 | return destroy(reinterpret_cast<IrInstSrcEmbedFile *>(inst), name); |
| | 382 | case IrInstSrcIdCmpxchg: |
| | 383 | return destroy(reinterpret_cast<IrInstSrcCmpxchg *>(inst), name); |
| | 384 | case IrInstSrcIdFence: |
| | 385 | return destroy(reinterpret_cast<IrInstSrcFence *>(inst), name); |
| | 386 | case IrInstSrcIdTruncate: |
| | 387 | return destroy(reinterpret_cast<IrInstSrcTruncate *>(inst), name); |
| | 388 | case IrInstSrcIdIntCast: |
| | 389 | return destroy(reinterpret_cast<IrInstSrcIntCast *>(inst), name); |
| | 390 | case IrInstSrcIdFloatCast: |
| | 391 | return destroy(reinterpret_cast<IrInstSrcFloatCast *>(inst), name); |
| | 392 | case IrInstSrcIdErrSetCast: |
| | 393 | return destroy(reinterpret_cast<IrInstSrcErrSetCast *>(inst), name); |
| | 394 | case IrInstSrcIdFromBytes: |
| | 395 | return destroy(reinterpret_cast<IrInstSrcFromBytes *>(inst), name); |
| | 396 | case IrInstSrcIdToBytes: |
| | 397 | return destroy(reinterpret_cast<IrInstSrcToBytes *>(inst), name); |
| | 398 | case IrInstSrcIdIntToFloat: |
| | 399 | return destroy(reinterpret_cast<IrInstSrcIntToFloat *>(inst), name); |
| | 400 | case IrInstSrcIdFloatToInt: |
| | 401 | return destroy(reinterpret_cast<IrInstSrcFloatToInt *>(inst), name); |
| | 402 | case IrInstSrcIdBoolToInt: |
| | 403 | return destroy(reinterpret_cast<IrInstSrcBoolToInt *>(inst), name); |
| | 404 | case IrInstSrcIdIntType: |
| | 405 | return destroy(reinterpret_cast<IrInstSrcIntType *>(inst), name); |
| | 406 | case IrInstSrcIdVectorType: |
| | 407 | return destroy(reinterpret_cast<IrInstSrcVectorType *>(inst), name); |
| | 408 | case IrInstSrcIdShuffleVector: |
| | 409 | return destroy(reinterpret_cast<IrInstSrcShuffleVector *>(inst), name); |
| | 410 | case IrInstSrcIdSplat: |
| | 411 | return destroy(reinterpret_cast<IrInstSrcSplat *>(inst), name); |
| | 412 | case IrInstSrcIdBoolNot: |
| | 413 | return destroy(reinterpret_cast<IrInstSrcBoolNot *>(inst), name); |
| | 414 | case IrInstSrcIdMemset: |
| | 415 | return destroy(reinterpret_cast<IrInstSrcMemset *>(inst), name); |
| | 416 | case IrInstSrcIdMemcpy: |
| | 417 | return destroy(reinterpret_cast<IrInstSrcMemcpy *>(inst), name); |
| | 418 | case IrInstSrcIdSlice: |
| | 419 | return destroy(reinterpret_cast<IrInstSrcSlice *>(inst), name); |
| | 420 | case IrInstSrcIdMemberCount: |
| | 421 | return destroy(reinterpret_cast<IrInstSrcMemberCount *>(inst), name); |
| | 422 | case IrInstSrcIdMemberType: |
| | 423 | return destroy(reinterpret_cast<IrInstSrcMemberType *>(inst), name); |
| | 424 | case IrInstSrcIdMemberName: |
| | 425 | return destroy(reinterpret_cast<IrInstSrcMemberName *>(inst), name); |
| | 426 | case IrInstSrcIdBreakpoint: |
| | 427 | return destroy(reinterpret_cast<IrInstSrcBreakpoint *>(inst), name); |
| | 428 | case IrInstSrcIdReturnAddress: |
| | 429 | return destroy(reinterpret_cast<IrInstSrcReturnAddress *>(inst), name); |
| | 430 | case IrInstSrcIdFrameAddress: |
| | 431 | return destroy(reinterpret_cast<IrInstSrcFrameAddress *>(inst), name); |
| | 432 | case IrInstSrcIdFrameHandle: |
| | 433 | return destroy(reinterpret_cast<IrInstSrcFrameHandle *>(inst), name); |
| | 434 | case IrInstSrcIdFrameType: |
| | 435 | return destroy(reinterpret_cast<IrInstSrcFrameType *>(inst), name); |
| | 436 | case IrInstSrcIdFrameSize: |
| | 437 | return destroy(reinterpret_cast<IrInstSrcFrameSize *>(inst), name); |
| | 438 | case IrInstSrcIdAlignOf: |
| | 439 | return destroy(reinterpret_cast<IrInstSrcAlignOf *>(inst), name); |
| | 440 | case IrInstSrcIdOverflowOp: |
| | 441 | return destroy(reinterpret_cast<IrInstSrcOverflowOp *>(inst), name); |
| | 442 | case IrInstSrcIdTestErr: |
| | 443 | return destroy(reinterpret_cast<IrInstSrcTestErr *>(inst), name); |
| | 444 | case IrInstSrcIdUnwrapErrCode: |
| | 445 | return destroy(reinterpret_cast<IrInstSrcUnwrapErrCode *>(inst), name); |
| | 446 | case IrInstSrcIdUnwrapErrPayload: |
| | 447 | return destroy(reinterpret_cast<IrInstSrcUnwrapErrPayload *>(inst), name); |
| | 448 | case IrInstSrcIdFnProto: |
| | 449 | return destroy(reinterpret_cast<IrInstSrcFnProto *>(inst), name); |
| | 450 | case IrInstSrcIdTestComptime: |
| | 451 | return destroy(reinterpret_cast<IrInstSrcTestComptime *>(inst), name); |
| | 452 | case IrInstSrcIdPtrCast: |
| | 453 | return destroy(reinterpret_cast<IrInstSrcPtrCast *>(inst), name); |
| | 454 | case IrInstSrcIdBitCast: |
| | 455 | return destroy(reinterpret_cast<IrInstSrcBitCast *>(inst), name); |
| | 456 | case IrInstSrcIdPtrToInt: |
| | 457 | return destroy(reinterpret_cast<IrInstSrcPtrToInt *>(inst), name); |
| | 458 | case IrInstSrcIdIntToPtr: |
| | 459 | return destroy(reinterpret_cast<IrInstSrcIntToPtr *>(inst), name); |
| | 460 | case IrInstSrcIdIntToEnum: |
| | 461 | return destroy(reinterpret_cast<IrInstSrcIntToEnum *>(inst), name); |
| | 462 | case IrInstSrcIdIntToErr: |
| | 463 | return destroy(reinterpret_cast<IrInstSrcIntToErr *>(inst), name); |
| | 464 | case IrInstSrcIdErrToInt: |
| | 465 | return destroy(reinterpret_cast<IrInstSrcErrToInt *>(inst), name); |
| | 466 | case IrInstSrcIdCheckSwitchProngs: |
| | 467 | return destroy(reinterpret_cast<IrInstSrcCheckSwitchProngs *>(inst), name); |
| | 468 | case IrInstSrcIdCheckStatementIsVoid: |
| | 469 | return destroy(reinterpret_cast<IrInstSrcCheckStatementIsVoid *>(inst), name); |
| | 470 | case IrInstSrcIdTypeName: |
| | 471 | return destroy(reinterpret_cast<IrInstSrcTypeName *>(inst), name); |
| | 472 | case IrInstSrcIdTagName: |
| | 473 | return destroy(reinterpret_cast<IrInstSrcTagName *>(inst), name); |
| | 474 | case IrInstSrcIdPtrType: |
| | 475 | return destroy(reinterpret_cast<IrInstSrcPtrType *>(inst), name); |
| | 476 | case IrInstSrcIdDeclRef: |
| | 477 | return destroy(reinterpret_cast<IrInstSrcDeclRef *>(inst), name); |
| | 478 | case IrInstSrcIdPanic: |
| | 479 | return destroy(reinterpret_cast<IrInstSrcPanic *>(inst), name); |
| | 480 | case IrInstSrcIdFieldParentPtr: |
| | 481 | return destroy(reinterpret_cast<IrInstSrcFieldParentPtr *>(inst), name); |
| | 482 | case IrInstSrcIdByteOffsetOf: |
| | 483 | return destroy(reinterpret_cast<IrInstSrcByteOffsetOf *>(inst), name); |
| | 484 | case IrInstSrcIdBitOffsetOf: |
| | 485 | return destroy(reinterpret_cast<IrInstSrcBitOffsetOf *>(inst), name); |
| | 486 | case IrInstSrcIdTypeInfo: |
| | 487 | return destroy(reinterpret_cast<IrInstSrcTypeInfo *>(inst), name); |
| | 488 | case IrInstSrcIdType: |
| | 489 | return destroy(reinterpret_cast<IrInstSrcType *>(inst), name); |
| | 490 | case IrInstSrcIdHasField: |
| | 491 | return destroy(reinterpret_cast<IrInstSrcHasField *>(inst), name); |
| | 492 | case IrInstSrcIdTypeId: |
| | 493 | return destroy(reinterpret_cast<IrInstSrcTypeId *>(inst), name); |
| | 494 | case IrInstSrcIdSetEvalBranchQuota: |
| | 495 | return destroy(reinterpret_cast<IrInstSrcSetEvalBranchQuota *>(inst), name); |
| | 496 | case IrInstSrcIdAlignCast: |
| | 497 | return destroy(reinterpret_cast<IrInstSrcAlignCast *>(inst), name); |
| | 498 | case IrInstSrcIdImplicitCast: |
| | 499 | return destroy(reinterpret_cast<IrInstSrcImplicitCast *>(inst), name); |
| | 500 | case IrInstSrcIdResolveResult: |
| | 501 | return destroy(reinterpret_cast<IrInstSrcResolveResult *>(inst), name); |
| | 502 | case IrInstSrcIdResetResult: |
| | 503 | return destroy(reinterpret_cast<IrInstSrcResetResult *>(inst), name); |
| | 504 | case IrInstSrcIdOpaqueType: |
| | 505 | return destroy(reinterpret_cast<IrInstSrcOpaqueType *>(inst), name); |
| | 506 | case IrInstSrcIdSetAlignStack: |
| | 507 | return destroy(reinterpret_cast<IrInstSrcSetAlignStack *>(inst), name); |
| | 508 | case IrInstSrcIdArgType: |
| | 509 | return destroy(reinterpret_cast<IrInstSrcArgType *>(inst), name); |
| | 510 | case IrInstSrcIdTagType: |
| | 511 | return destroy(reinterpret_cast<IrInstSrcTagType *>(inst), name); |
| | 512 | case IrInstSrcIdExport: |
| | 513 | return destroy(reinterpret_cast<IrInstSrcExport *>(inst), name); |
| | 514 | case IrInstSrcIdErrorReturnTrace: |
| | 515 | return destroy(reinterpret_cast<IrInstSrcErrorReturnTrace *>(inst), name); |
| | 516 | case IrInstSrcIdErrorUnion: |
| | 517 | return destroy(reinterpret_cast<IrInstSrcErrorUnion *>(inst), name); |
| | 518 | case IrInstSrcIdAtomicRmw: |
| | 519 | return destroy(reinterpret_cast<IrInstSrcAtomicRmw *>(inst), name); |
| | 520 | case IrInstSrcIdSaveErrRetAddr: |
| | 521 | return destroy(reinterpret_cast<IrInstSrcSaveErrRetAddr *>(inst), name); |
| | 522 | case IrInstSrcIdAddImplicitReturnType: |
| | 523 | return destroy(reinterpret_cast<IrInstSrcAddImplicitReturnType *>(inst), name); |
| | 524 | case IrInstSrcIdFloatOp: |
| | 525 | return destroy(reinterpret_cast<IrInstSrcFloatOp *>(inst), name); |
| | 526 | case IrInstSrcIdMulAdd: |
| | 527 | return destroy(reinterpret_cast<IrInstSrcMulAdd *>(inst), name); |
| | 528 | case IrInstSrcIdAtomicLoad: |
| | 529 | return destroy(reinterpret_cast<IrInstSrcAtomicLoad *>(inst), name); |
| | 530 | case IrInstSrcIdAtomicStore: |
| | 531 | return destroy(reinterpret_cast<IrInstSrcAtomicStore *>(inst), name); |
| | 532 | case IrInstSrcIdEnumToInt: |
| | 533 | return destroy(reinterpret_cast<IrInstSrcEnumToInt *>(inst), name); |
| | 534 | case IrInstSrcIdCheckRuntimeScope: |
| | 535 | return destroy(reinterpret_cast<IrInstSrcCheckRuntimeScope *>(inst), name); |
| | 536 | case IrInstSrcIdHasDecl: |
| | 537 | return destroy(reinterpret_cast<IrInstSrcHasDecl *>(inst), name); |
| | 538 | case IrInstSrcIdUndeclaredIdent: |
| | 539 | return destroy(reinterpret_cast<IrInstSrcUndeclaredIdent *>(inst), name); |
| | 540 | case IrInstSrcIdAlloca: |
| | 541 | return destroy(reinterpret_cast<IrInstSrcAlloca *>(inst), name); |
| | 542 | case IrInstSrcIdEndExpr: |
| | 543 | return destroy(reinterpret_cast<IrInstSrcEndExpr *>(inst), name); |
| | 544 | case IrInstSrcIdUnionInitNamedField: |
| | 545 | return destroy(reinterpret_cast<IrInstSrcUnionInitNamedField *>(inst), name); |
| | 546 | case IrInstSrcIdSuspendBegin: |
| | 547 | return destroy(reinterpret_cast<IrInstSrcSuspendBegin *>(inst), name); |
| | 548 | case IrInstSrcIdSuspendFinish: |
| | 549 | return destroy(reinterpret_cast<IrInstSrcSuspendFinish *>(inst), name); |
| | 550 | case IrInstSrcIdResume: |
| | 551 | return destroy(reinterpret_cast<IrInstSrcResume *>(inst), name); |
| | 552 | case IrInstSrcIdAwait: |
| | 553 | return destroy(reinterpret_cast<IrInstSrcAwait *>(inst), name); |
| | 554 | case IrInstSrcIdSpillBegin: |
| | 555 | return destroy(reinterpret_cast<IrInstSrcSpillBegin *>(inst), name); |
| | 556 | case IrInstSrcIdSpillEnd: |
| | 557 | return destroy(reinterpret_cast<IrInstSrcSpillEnd *>(inst), name); |
| | 558 | case IrInstSrcIdCallArgs: |
| | 559 | return destroy(reinterpret_cast<IrInstSrcCallArgs *>(inst), name); |
| | 560 | } |
| | 561 | zig_unreachable(); |
| | 562 | } |
| 267 | | 563 | |
| 268 | static void destroy_instruction(IrInstruction *inst) { | 564 | void destroy_instruction_gen(IrInstGen *inst) { |
| 269 | #ifdef ZIG_ENABLE_MEM_PROFILE | 565 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| 270 | const char *name = ir_instruction_type_str(inst->id); | 566 | const char *name = ir_inst_gen_type_str(inst->id); |
| 271 | #else | 567 | #else |
| 272 | const char *name = nullptr; | 568 | const char *name = nullptr; |
| 273 | #endif | 569 | #endif |
| 274 | switch (inst->id) { | 570 | switch (inst->id) { |
| 275 | case IrInstructionIdInvalid: | 571 | case IrInstGenIdInvalid: |
| 276 | zig_unreachable(); | 572 | zig_unreachable(); |
| 277 | case IrInstructionIdReturn: | 573 | case IrInstGenIdReturn: |
| 278 | return destroy(reinterpret_cast<IrInstructionReturn *>(inst), name); | 574 | return destroy(reinterpret_cast<IrInstGenReturn *>(inst), name); |
| 279 | case IrInstructionIdConst: | 575 | case IrInstGenIdConst: |
| 280 | return destroy(reinterpret_cast<IrInstructionConst *>(inst), name); | 576 | return destroy(reinterpret_cast<IrInstGenConst *>(inst), name); |
| 281 | case IrInstructionIdBinOp: | 577 | case IrInstGenIdBinOp: |
| 282 | return destroy(reinterpret_cast<IrInstructionBinOp *>(inst), name); | 578 | return destroy(reinterpret_cast<IrInstGenBinOp *>(inst), name); |
| 283 | case IrInstructionIdMergeErrSets: | 579 | case IrInstGenIdCast: |
| 284 | return destroy(reinterpret_cast<IrInstructionMergeErrSets *>(inst), name); | 580 | return destroy(reinterpret_cast<IrInstGenCast *>(inst), name); |
| 285 | case IrInstructionIdDeclVarSrc: | 581 | case IrInstGenIdCall: |
| 286 | return destroy(reinterpret_cast<IrInstructionDeclVarSrc *>(inst), name); | 582 | return destroy(reinterpret_cast<IrInstGenCall *>(inst), name); |
| 287 | case IrInstructionIdCast: | 583 | case IrInstGenIdCondBr: |
| 288 | return destroy(reinterpret_cast<IrInstructionCast *>(inst), name); | 584 | return destroy(reinterpret_cast<IrInstGenCondBr *>(inst), name); |
| 289 | case IrInstructionIdCallSrc: | 585 | case IrInstGenIdBr: |
| 290 | return destroy(reinterpret_cast<IrInstructionCallSrc *>(inst), name); | 586 | return destroy(reinterpret_cast<IrInstGenBr *>(inst), name); |
| 291 | case IrInstructionIdCallSrcArgs: | 587 | case IrInstGenIdPhi: |
| 292 | return destroy(reinterpret_cast<IrInstructionCallSrcArgs *>(inst), name); | 588 | return destroy(reinterpret_cast<IrInstGenPhi *>(inst), name); |
| 293 | case IrInstructionIdCallExtra: | 589 | case IrInstGenIdUnreachable: |
| 294 | return destroy(reinterpret_cast<IrInstructionCallExtra *>(inst), name); | 590 | return destroy(reinterpret_cast<IrInstGenUnreachable *>(inst), name); |
| 295 | case IrInstructionIdCallGen: | 591 | case IrInstGenIdElemPtr: |
| 296 | return destroy(reinterpret_cast<IrInstructionCallGen *>(inst), name); | 592 | return destroy(reinterpret_cast<IrInstGenElemPtr *>(inst), name); |
| 297 | case IrInstructionIdUnOp: | 593 | case IrInstGenIdVarPtr: |
| 298 | return destroy(reinterpret_cast<IrInstructionUnOp *>(inst), name); | 594 | return destroy(reinterpret_cast<IrInstGenVarPtr *>(inst), name); |
| 299 | case IrInstructionIdCondBr: | 595 | case IrInstGenIdReturnPtr: |
| 300 | return destroy(reinterpret_cast<IrInstructionCondBr *>(inst), name); | 596 | return destroy(reinterpret_cast<IrInstGenReturnPtr *>(inst), name); |
| 301 | case IrInstructionIdBr: | 597 | case IrInstGenIdLoadPtr: |
| 302 | return destroy(reinterpret_cast<IrInstructionBr *>(inst), name); | 598 | return destroy(reinterpret_cast<IrInstGenLoadPtr *>(inst), name); |
| 303 | case IrInstructionIdPhi: | 599 | case IrInstGenIdStorePtr: |
| 304 | return destroy(reinterpret_cast<IrInstructionPhi *>(inst), name); | 600 | return destroy(reinterpret_cast<IrInstGenStorePtr *>(inst), name); |
| 305 | case IrInstructionIdContainerInitList: | 601 | case IrInstGenIdVectorStoreElem: |
| 306 | return destroy(reinterpret_cast<IrInstructionContainerInitList *>(inst), name); | 602 | return destroy(reinterpret_cast<IrInstGenVectorStoreElem *>(inst), name); |
| 307 | case IrInstructionIdContainerInitFields: | 603 | case IrInstGenIdStructFieldPtr: |
| 308 | return destroy(reinterpret_cast<IrInstructionContainerInitFields *>(inst), name); | 604 | return destroy(reinterpret_cast<IrInstGenStructFieldPtr *>(inst), name); |
| 309 | case IrInstructionIdUnreachable: | 605 | case IrInstGenIdUnionFieldPtr: |
| 310 | return destroy(reinterpret_cast<IrInstructionUnreachable *>(inst), name); | 606 | return destroy(reinterpret_cast<IrInstGenUnionFieldPtr *>(inst), name); |
| 311 | case IrInstructionIdElemPtr: | 607 | case IrInstGenIdAsm: |
| 312 | return destroy(reinterpret_cast<IrInstructionElemPtr *>(inst), name); | 608 | return destroy(reinterpret_cast<IrInstGenAsm *>(inst), name); |
| 313 | case IrInstructionIdVarPtr: | 609 | case IrInstGenIdTestNonNull: |
| 314 | return destroy(reinterpret_cast<IrInstructionVarPtr *>(inst), name); | 610 | return destroy(reinterpret_cast<IrInstGenTestNonNull *>(inst), name); |
| 315 | case IrInstructionIdReturnPtr: | 611 | case IrInstGenIdOptionalUnwrapPtr: |
| 316 | return destroy(reinterpret_cast<IrInstructionReturnPtr *>(inst), name); | 612 | return destroy(reinterpret_cast<IrInstGenOptionalUnwrapPtr *>(inst), name); |
| 317 | case IrInstructionIdLoadPtr: | 613 | case IrInstGenIdPopCount: |
| 318 | return destroy(reinterpret_cast<IrInstructionLoadPtr *>(inst), name); | 614 | return destroy(reinterpret_cast<IrInstGenPopCount *>(inst), name); |
| 319 | case IrInstructionIdLoadPtrGen: | 615 | case IrInstGenIdClz: |
| 320 | return destroy(reinterpret_cast<IrInstructionLoadPtrGen *>(inst), name); | 616 | return destroy(reinterpret_cast<IrInstGenClz *>(inst), name); |
| 321 | case IrInstructionIdStorePtr: | 617 | case IrInstGenIdCtz: |
| 322 | return destroy(reinterpret_cast<IrInstructionStorePtr *>(inst), name); | 618 | return destroy(reinterpret_cast<IrInstGenCtz *>(inst), name); |
| 323 | case IrInstructionIdVectorStoreElem: | 619 | case IrInstGenIdBswap: |
| 324 | return destroy(reinterpret_cast<IrInstructionVectorStoreElem *>(inst), name); | 620 | return destroy(reinterpret_cast<IrInstGenBswap *>(inst), name); |
| 325 | case IrInstructionIdTypeOf: | 621 | case IrInstGenIdBitReverse: |
| 326 | return destroy(reinterpret_cast<IrInstructionTypeOf *>(inst), name); | 622 | return destroy(reinterpret_cast<IrInstGenBitReverse *>(inst), name); |
| 327 | case IrInstructionIdFieldPtr: | 623 | case IrInstGenIdSwitchBr: |
| 328 | return destroy(reinterpret_cast<IrInstructionFieldPtr *>(inst), name); | 624 | return destroy(reinterpret_cast<IrInstGenSwitchBr *>(inst), name); |
| 329 | case IrInstructionIdStructFieldPtr: | 625 | case IrInstGenIdUnionTag: |
| 330 | return destroy(reinterpret_cast<IrInstructionStructFieldPtr *>(inst), name); | 626 | return destroy(reinterpret_cast<IrInstGenUnionTag *>(inst), name); |
| 331 | case IrInstructionIdUnionFieldPtr: | 627 | case IrInstGenIdRef: |
| 332 | return destroy(reinterpret_cast<IrInstructionUnionFieldPtr *>(inst), name); | 628 | return destroy(reinterpret_cast<IrInstGenRef *>(inst), name); |
| 333 | case IrInstructionIdSetCold: | 629 | case IrInstGenIdErrName: |
| 334 | return destroy(reinterpret_cast<IrInstructionSetCold *>(inst), name); | 630 | return destroy(reinterpret_cast<IrInstGenErrName *>(inst), name); |
| 335 | case IrInstructionIdSetRuntimeSafety: | 631 | case IrInstGenIdCmpxchg: |
| 336 | return destroy(reinterpret_cast<IrInstructionSetRuntimeSafety *>(inst), name); | 632 | return destroy(reinterpret_cast<IrInstGenCmpxchg *>(inst), name); |
| 337 | case IrInstructionIdSetFloatMode: | 633 | case IrInstGenIdFence: |
| 338 | return destroy(reinterpret_cast<IrInstructionSetFloatMode *>(inst), name); | 634 | return destroy(reinterpret_cast<IrInstGenFence *>(inst), name); |
| 339 | case IrInstructionIdArrayType: | 635 | case IrInstGenIdTruncate: |
| 340 | return destroy(reinterpret_cast<IrInstructionArrayType *>(inst), name); | 636 | return destroy(reinterpret_cast<IrInstGenTruncate *>(inst), name); |
| 341 | case IrInstructionIdSliceType: | 637 | case IrInstGenIdShuffleVector: |
| 342 | return destroy(reinterpret_cast<IrInstructionSliceType *>(inst), name); | 638 | return destroy(reinterpret_cast<IrInstGenShuffleVector *>(inst), name); |
| 343 | case IrInstructionIdAnyFrameType: | 639 | case IrInstGenIdSplat: |
| 344 | return destroy(reinterpret_cast<IrInstructionAnyFrameType *>(inst), name); | 640 | return destroy(reinterpret_cast<IrInstGenSplat *>(inst), name); |
| 345 | case IrInstructionIdAsmSrc: | 641 | case IrInstGenIdBoolNot: |
| 346 | return destroy(reinterpret_cast<IrInstructionAsmSrc *>(inst), name); | 642 | return destroy(reinterpret_cast<IrInstGenBoolNot *>(inst), name); |
| 347 | case IrInstructionIdAsmGen: | 643 | case IrInstGenIdMemset: |
| 348 | return destroy(reinterpret_cast<IrInstructionAsmGen *>(inst), name); | 644 | return destroy(reinterpret_cast<IrInstGenMemset *>(inst), name); |
| 349 | case IrInstructionIdSizeOf: | 645 | case IrInstGenIdMemcpy: |
| 350 | return destroy(reinterpret_cast<IrInstructionSizeOf *>(inst), name); | 646 | return destroy(reinterpret_cast<IrInstGenMemcpy *>(inst), name); |
| 351 | case IrInstructionIdTestNonNull: | 647 | case IrInstGenIdSlice: |
| 352 | return destroy(reinterpret_cast<IrInstructionTestNonNull *>(inst), name); | 648 | return destroy(reinterpret_cast<IrInstGenSlice *>(inst), name); |
| 353 | case IrInstructionIdOptionalUnwrapPtr: | 649 | case IrInstGenIdBreakpoint: |
| 354 | return destroy(reinterpret_cast<IrInstructionOptionalUnwrapPtr *>(inst), name); | 650 | return destroy(reinterpret_cast<IrInstGenBreakpoint *>(inst), name); |
| 355 | case IrInstructionIdPopCount: | 651 | case IrInstGenIdReturnAddress: |
| 356 | return destroy(reinterpret_cast<IrInstructionPopCount *>(inst), name); | 652 | return destroy(reinterpret_cast<IrInstGenReturnAddress *>(inst), name); |
| 357 | case IrInstructionIdClz: | 653 | case IrInstGenIdFrameAddress: |
| 358 | return destroy(reinterpret_cast<IrInstructionClz *>(inst), name); | 654 | return destroy(reinterpret_cast<IrInstGenFrameAddress *>(inst), name); |
| 359 | case IrInstructionIdCtz: | 655 | case IrInstGenIdFrameHandle: |
| 360 | return destroy(reinterpret_cast<IrInstructionCtz *>(inst), name); | 656 | return destroy(reinterpret_cast<IrInstGenFrameHandle *>(inst), name); |
| 361 | case IrInstructionIdBswap: | 657 | case IrInstGenIdFrameSize: |
| 362 | return destroy(reinterpret_cast<IrInstructionBswap *>(inst), name); | 658 | return destroy(reinterpret_cast<IrInstGenFrameSize *>(inst), name); |
| 363 | case IrInstructionIdBitReverse: | 659 | case IrInstGenIdOverflowOp: |
| 364 | return destroy(reinterpret_cast<IrInstructionBitReverse *>(inst), name); | 660 | return destroy(reinterpret_cast<IrInstGenOverflowOp *>(inst), name); |
| 365 | case IrInstructionIdSwitchBr: | 661 | case IrInstGenIdTestErr: |
| 366 | return destroy(reinterpret_cast<IrInstructionSwitchBr *>(inst), name); | 662 | return destroy(reinterpret_cast<IrInstGenTestErr *>(inst), name); |
| 367 | case IrInstructionIdSwitchVar: | 663 | case IrInstGenIdUnwrapErrCode: |
| 368 | return destroy(reinterpret_cast<IrInstructionSwitchVar *>(inst), name); | 664 | return destroy(reinterpret_cast<IrInstGenUnwrapErrCode *>(inst), name); |
| 369 | case IrInstructionIdSwitchElseVar: | 665 | case IrInstGenIdUnwrapErrPayload: |
| 370 | return destroy(reinterpret_cast<IrInstructionSwitchElseVar *>(inst), name); | 666 | return destroy(reinterpret_cast<IrInstGenUnwrapErrPayload *>(inst), name); |
| 371 | case IrInstructionIdSwitchTarget: | 667 | case IrInstGenIdOptionalWrap: |
| 372 | return destroy(reinterpret_cast<IrInstructionSwitchTarget *>(inst), name); | 668 | return destroy(reinterpret_cast<IrInstGenOptionalWrap *>(inst), name); |
| 373 | case IrInstructionIdUnionTag: | 669 | case IrInstGenIdErrWrapCode: |
| 374 | return destroy(reinterpret_cast<IrInstructionUnionTag *>(inst), name); | 670 | return destroy(reinterpret_cast<IrInstGenErrWrapCode *>(inst), name); |
| 375 | case IrInstructionIdImport: | 671 | case IrInstGenIdErrWrapPayload: |
| 376 | return destroy(reinterpret_cast<IrInstructionImport *>(inst), name); | 672 | return destroy(reinterpret_cast<IrInstGenErrWrapPayload *>(inst), name); |
| 377 | case IrInstructionIdRef: | 673 | case IrInstGenIdPtrCast: |
| 378 | return destroy(reinterpret_cast<IrInstructionRef *>(inst), name); | 674 | return destroy(reinterpret_cast<IrInstGenPtrCast *>(inst), name); |
| 379 | case IrInstructionIdRefGen: | 675 | case IrInstGenIdBitCast: |
| 380 | return destroy(reinterpret_cast<IrInstructionRefGen *>(inst), name); | 676 | return destroy(reinterpret_cast<IrInstGenBitCast *>(inst), name); |
| 381 | case IrInstructionIdCompileErr: | 677 | case IrInstGenIdWidenOrShorten: |
| 382 | return destroy(reinterpret_cast<IrInstructionCompileErr *>(inst), name); | 678 | return destroy(reinterpret_cast<IrInstGenWidenOrShorten *>(inst), name); |
| 383 | case IrInstructionIdCompileLog: | 679 | case IrInstGenIdPtrToInt: |
| 384 | return destroy(reinterpret_cast<IrInstructionCompileLog *>(inst), name); | 680 | return destroy(reinterpret_cast<IrInstGenPtrToInt *>(inst), name); |
| 385 | case IrInstructionIdErrName: | 681 | case IrInstGenIdIntToPtr: |
| 386 | return destroy(reinterpret_cast<IrInstructionErrName *>(inst), name); | 682 | return destroy(reinterpret_cast<IrInstGenIntToPtr *>(inst), name); |
| 387 | case IrInstructionIdCImport: | 683 | case IrInstGenIdIntToEnum: |
| 388 | return destroy(reinterpret_cast<IrInstructionCImport *>(inst), name); | 684 | return destroy(reinterpret_cast<IrInstGenIntToEnum *>(inst), name); |
| 389 | case IrInstructionIdCInclude: | 685 | case IrInstGenIdIntToErr: |
| 390 | return destroy(reinterpret_cast<IrInstructionCInclude *>(inst), name); | 686 | return destroy(reinterpret_cast<IrInstGenIntToErr *>(inst), name); |
| 391 | case IrInstructionIdCDefine: | 687 | case IrInstGenIdErrToInt: |
| 392 | return destroy(reinterpret_cast<IrInstructionCDefine *>(inst), name); | 688 | return destroy(reinterpret_cast<IrInstGenErrToInt *>(inst), name); |
| 393 | case IrInstructionIdCUndef: | 689 | case IrInstGenIdTagName: |
| 394 | return destroy(reinterpret_cast<IrInstructionCUndef *>(inst), name); | 690 | return destroy(reinterpret_cast<IrInstGenTagName *>(inst), name); |
| 395 | case IrInstructionIdEmbedFile: | 691 | case IrInstGenIdPanic: |
| 396 | return destroy(reinterpret_cast<IrInstructionEmbedFile *>(inst), name); | 692 | return destroy(reinterpret_cast<IrInstGenPanic *>(inst), name); |
| 397 | case IrInstructionIdCmpxchgSrc: | 693 | case IrInstGenIdFieldParentPtr: |
| 398 | return destroy(reinterpret_cast<IrInstructionCmpxchgSrc *>(inst), name); | 694 | return destroy(reinterpret_cast<IrInstGenFieldParentPtr *>(inst), name); |
| 399 | case IrInstructionIdCmpxchgGen: | 695 | case IrInstGenIdAlignCast: |
| 400 | return destroy(reinterpret_cast<IrInstructionCmpxchgGen *>(inst), name); | 696 | return destroy(reinterpret_cast<IrInstGenAlignCast *>(inst), name); |
| 401 | case IrInstructionIdFence: | 697 | case IrInstGenIdErrorReturnTrace: |
| 402 | return destroy(reinterpret_cast<IrInstructionFence *>(inst), name); | 698 | return destroy(reinterpret_cast<IrInstGenErrorReturnTrace *>(inst), name); |
| 403 | case IrInstructionIdTruncate: | 699 | case IrInstGenIdAtomicRmw: |
| 404 | return destroy(reinterpret_cast<IrInstructionTruncate *>(inst), name); | 700 | return destroy(reinterpret_cast<IrInstGenAtomicRmw *>(inst), name); |
| 405 | case IrInstructionIdIntCast: | 701 | case IrInstGenIdSaveErrRetAddr: |
| 406 | return destroy(reinterpret_cast<IrInstructionIntCast *>(inst), name); | 702 | return destroy(reinterpret_cast<IrInstGenSaveErrRetAddr *>(inst), name); |
| 407 | case IrInstructionIdFloatCast: | 703 | case IrInstGenIdFloatOp: |
| 408 | return destroy(reinterpret_cast<IrInstructionFloatCast *>(inst), name); | 704 | return destroy(reinterpret_cast<IrInstGenFloatOp *>(inst), name); |
| 409 | case IrInstructionIdErrSetCast: | 705 | case IrInstGenIdMulAdd: |
| 410 | return destroy(reinterpret_cast<IrInstructionErrSetCast *>(inst), name); | 706 | return destroy(reinterpret_cast<IrInstGenMulAdd *>(inst), name); |
| 411 | case IrInstructionIdFromBytes: | 707 | case IrInstGenIdAtomicLoad: |
| 412 | return destroy(reinterpret_cast<IrInstructionFromBytes *>(inst), name); | 708 | return destroy(reinterpret_cast<IrInstGenAtomicLoad *>(inst), name); |
| 413 | case IrInstructionIdToBytes: | 709 | case IrInstGenIdAtomicStore: |
| 414 | return destroy(reinterpret_cast<IrInstructionToBytes *>(inst), name); | 710 | return destroy(reinterpret_cast<IrInstGenAtomicStore *>(inst), name); |
| 415 | case IrInstructionIdIntToFloat: | 711 | case IrInstGenIdDeclVar: |
| 416 | return destroy(reinterpret_cast<IrInstructionIntToFloat *>(inst), name); | 712 | return destroy(reinterpret_cast<IrInstGenDeclVar *>(inst), name); |
| 417 | case IrInstructionIdFloatToInt: | 713 | case IrInstGenIdArrayToVector: |
| 418 | return destroy(reinterpret_cast<IrInstructionFloatToInt *>(inst), name); | 714 | return destroy(reinterpret_cast<IrInstGenArrayToVector *>(inst), name); |
| 419 | case IrInstructionIdBoolToInt: | 715 | case IrInstGenIdVectorToArray: |
| 420 | return destroy(reinterpret_cast<IrInstructionBoolToInt *>(inst), name); | 716 | return destroy(reinterpret_cast<IrInstGenVectorToArray *>(inst), name); |
| 421 | case IrInstructionIdIntType: | 717 | case IrInstGenIdPtrOfArrayToSlice: |
| 422 | return destroy(reinterpret_cast<IrInstructionIntType *>(inst), name); | 718 | return destroy(reinterpret_cast<IrInstGenPtrOfArrayToSlice *>(inst), name); |
| 423 | case IrInstructionIdVectorType: | 719 | case IrInstGenIdAssertZero: |
| 424 | return destroy(reinterpret_cast<IrInstructionVectorType *>(inst), name); | 720 | return destroy(reinterpret_cast<IrInstGenAssertZero *>(inst), name); |
| 425 | case IrInstructionIdShuffleVector: | 721 | case IrInstGenIdAssertNonNull: |
| 426 | return destroy(reinterpret_cast<IrInstructionShuffleVector *>(inst), name); | 722 | return destroy(reinterpret_cast<IrInstGenAssertNonNull *>(inst), name); |
| 427 | case IrInstructionIdSplatSrc: | 723 | case IrInstGenIdResizeSlice: |
| 428 | return destroy(reinterpret_cast<IrInstructionSplatSrc *>(inst), name); | 724 | return destroy(reinterpret_cast<IrInstGenResizeSlice *>(inst), name); |
| 429 | case IrInstructionIdSplatGen: | 725 | case IrInstGenIdAlloca: |
| 430 | return destroy(reinterpret_cast<IrInstructionSplatGen *>(inst), name); | 726 | return destroy(reinterpret_cast<IrInstGenAlloca *>(inst), name); |
| 431 | case IrInstructionIdBoolNot: | 727 | case IrInstGenIdSuspendBegin: |
| 432 | return destroy(reinterpret_cast<IrInstructionBoolNot *>(inst), name); | 728 | return destroy(reinterpret_cast<IrInstGenSuspendBegin *>(inst), name); |
| 433 | case IrInstructionIdMemset: | 729 | case IrInstGenIdSuspendFinish: |
| 434 | return destroy(reinterpret_cast<IrInstructionMemset *>(inst), name); | 730 | return destroy(reinterpret_cast<IrInstGenSuspendFinish *>(inst), name); |
| 435 | case IrInstructionIdMemcpy: | 731 | case IrInstGenIdResume: |
| 436 | return destroy(reinterpret_cast<IrInstructionMemcpy *>(inst), name); | 732 | return destroy(reinterpret_cast<IrInstGenResume *>(inst), name); |
| 437 | case IrInstructionIdSliceSrc: | 733 | case IrInstGenIdAwait: |
| 438 | return destroy(reinterpret_cast<IrInstructionSliceSrc *>(inst), name); | 734 | return destroy(reinterpret_cast<IrInstGenAwait *>(inst), name); |
| 439 | case IrInstructionIdSliceGen: | 735 | case IrInstGenIdSpillBegin: |
| 440 | return destroy(reinterpret_cast<IrInstructionSliceGen *>(inst), name); | 736 | return destroy(reinterpret_cast<IrInstGenSpillBegin *>(inst), name); |
| 441 | case IrInstructionIdMemberCount: | 737 | case IrInstGenIdSpillEnd: |
| 442 | return destroy(reinterpret_cast<IrInstructionMemberCount *>(inst), name); | 738 | return destroy(reinterpret_cast<IrInstGenSpillEnd *>(inst), name); |
| 443 | case IrInstructionIdMemberType: | 739 | case IrInstGenIdVectorExtractElem: |
| 444 | return destroy(reinterpret_cast<IrInstructionMemberType *>(inst), name); | 740 | return destroy(reinterpret_cast<IrInstGenVectorExtractElem *>(inst), name); |
| 445 | case IrInstructionIdMemberName: | 741 | case IrInstGenIdBinaryNot: |
| 446 | return destroy(reinterpret_cast<IrInstructionMemberName *>(inst), name); | 742 | return destroy(reinterpret_cast<IrInstGenBinaryNot *>(inst), name); |
| 447 | case IrInstructionIdBreakpoint: | 743 | case IrInstGenIdNegation: |
| 448 | return destroy(reinterpret_cast<IrInstructionBreakpoint *>(inst), name); | 744 | return destroy(reinterpret_cast<IrInstGenNegation *>(inst), name); |
| 449 | case IrInstructionIdReturnAddress: | 745 | case IrInstGenIdNegationWrapping: |
| 450 | return destroy(reinterpret_cast<IrInstructionReturnAddress *>(inst), name); | 746 | return destroy(reinterpret_cast<IrInstGenNegationWrapping *>(inst), name); |
| 451 | case IrInstructionIdFrameAddress: | | |
| 452 | return destroy(reinterpret_cast<IrInstructionFrameAddress *>(inst), name); | | |
| 453 | case IrInstructionIdFrameHandle: | | |
| 454 | return destroy(reinterpret_cast<IrInstructionFrameHandle *>(inst), name); | | |
| 455 | case IrInstructionIdFrameType: | | |
| 456 | return destroy(reinterpret_cast<IrInstructionFrameType *>(inst), name); | | |
| 457 | case IrInstructionIdFrameSizeSrc: | | |
| 458 | return destroy(reinterpret_cast<IrInstructionFrameSizeSrc *>(inst), name); | | |
| 459 | case IrInstructionIdFrameSizeGen: | | |
| 460 | return destroy(reinterpret_cast<IrInstructionFrameSizeGen *>(inst), name); | | |
| 461 | case IrInstructionIdAlignOf: | | |
| 462 | return destroy(reinterpret_cast<IrInstructionAlignOf *>(inst), name); | | |
| 463 | case IrInstructionIdOverflowOp: | | |
| 464 | return destroy(reinterpret_cast<IrInstructionOverflowOp *>(inst), name); | | |
| 465 | case IrInstructionIdTestErrSrc: | | |
| 466 | return destroy(reinterpret_cast<IrInstructionTestErrSrc *>(inst), name); | | |
| 467 | case IrInstructionIdTestErrGen: | | |
| 468 | return destroy(reinterpret_cast<IrInstructionTestErrGen *>(inst), name); | | |
| 469 | case IrInstructionIdUnwrapErrCode: | | |
| 470 | return destroy(reinterpret_cast<IrInstructionUnwrapErrCode *>(inst), name); | | |
| 471 | case IrInstructionIdUnwrapErrPayload: | | |
| 472 | return destroy(reinterpret_cast<IrInstructionUnwrapErrPayload *>(inst), name); | | |
| 473 | case IrInstructionIdOptionalWrap: | | |
| 474 | return destroy(reinterpret_cast<IrInstructionOptionalWrap *>(inst), name); | | |
| 475 | case IrInstructionIdErrWrapCode: | | |
| 476 | return destroy(reinterpret_cast<IrInstructionErrWrapCode *>(inst), name); | | |
| 477 | case IrInstructionIdErrWrapPayload: | | |
| 478 | return destroy(reinterpret_cast<IrInstructionErrWrapPayload *>(inst), name); | | |
| 479 | case IrInstructionIdFnProto: | | |
| 480 | return destroy(reinterpret_cast<IrInstructionFnProto *>(inst), name); | | |
| 481 | case IrInstructionIdTestComptime: | | |
| 482 | return destroy(reinterpret_cast<IrInstructionTestComptime *>(inst), name); | | |
| 483 | case IrInstructionIdPtrCastSrc: | | |
| 484 | return destroy(reinterpret_cast<IrInstructionPtrCastSrc *>(inst), name); | | |
| 485 | case IrInstructionIdPtrCastGen: | | |
| 486 | return destroy(reinterpret_cast<IrInstructionPtrCastGen *>(inst), name); | | |
| 487 | case IrInstructionIdBitCastSrc: | | |
| 488 | return destroy(reinterpret_cast<IrInstructionBitCastSrc *>(inst), name); | | |
| 489 | case IrInstructionIdBitCastGen: | | |
| 490 | return destroy(reinterpret_cast<IrInstructionBitCastGen *>(inst), name); | | |
| 491 | case IrInstructionIdWidenOrShorten: | | |
| 492 | return destroy(reinterpret_cast<IrInstructionWidenOrShorten *>(inst), name); | | |
| 493 | case IrInstructionIdPtrToInt: | | |
| 494 | return destroy(reinterpret_cast<IrInstructionPtrToInt *>(inst), name); | | |
| 495 | case IrInstructionIdIntToPtr: | | |
| 496 | return destroy(reinterpret_cast<IrInstructionIntToPtr *>(inst), name); | | |
| 497 | case IrInstructionIdIntToEnum: | | |
| 498 | return destroy(reinterpret_cast<IrInstructionIntToEnum *>(inst), name); | | |
| 499 | case IrInstructionIdIntToErr: | | |
| 500 | return destroy(reinterpret_cast<IrInstructionIntToErr *>(inst), name); | | |
| 501 | case IrInstructionIdErrToInt: | | |
| 502 | return destroy(reinterpret_cast<IrInstructionErrToInt *>(inst), name); | | |
| 503 | case IrInstructionIdCheckSwitchProngs: | | |
| 504 | return destroy(reinterpret_cast<IrInstructionCheckSwitchProngs *>(inst), name); | | |
| 505 | case IrInstructionIdCheckStatementIsVoid: | | |
| 506 | return destroy(reinterpret_cast<IrInstructionCheckStatementIsVoid *>(inst), name); | | |
| 507 | case IrInstructionIdTypeName: | | |
| 508 | return destroy(reinterpret_cast<IrInstructionTypeName *>(inst), name); | | |
| 509 | case IrInstructionIdTagName: | | |
| 510 | return destroy(reinterpret_cast<IrInstructionTagName *>(inst), name); | | |
| 511 | case IrInstructionIdPtrType: | | |
| 512 | return destroy(reinterpret_cast<IrInstructionPtrType *>(inst), name); | | |
| 513 | case IrInstructionIdDeclRef: | | |
| 514 | return destroy(reinterpret_cast<IrInstructionDeclRef *>(inst), name); | | |
| 515 | case IrInstructionIdPanic: | | |
| 516 | return destroy(reinterpret_cast<IrInstructionPanic *>(inst), name); | | |
| 517 | case IrInstructionIdFieldParentPtr: | | |
| 518 | return destroy(reinterpret_cast<IrInstructionFieldParentPtr *>(inst), name); | | |
| 519 | case IrInstructionIdByteOffsetOf: | | |
| 520 | return destroy(reinterpret_cast<IrInstructionByteOffsetOf *>(inst), name); | | |
| 521 | case IrInstructionIdBitOffsetOf: | | |
| 522 | return destroy(reinterpret_cast<IrInstructionBitOffsetOf *>(inst), name); | | |
| 523 | case IrInstructionIdTypeInfo: | | |
| 524 | return destroy(reinterpret_cast<IrInstructionTypeInfo *>(inst), name); | | |
| 525 | case IrInstructionIdType: | | |
| 526 | return destroy(reinterpret_cast<IrInstructionType *>(inst), name); | | |
| 527 | case IrInstructionIdHasField: | | |
| 528 | return destroy(reinterpret_cast<IrInstructionHasField *>(inst), name); | | |
| 529 | case IrInstructionIdTypeId: | | |
| 530 | return destroy(reinterpret_cast<IrInstructionTypeId *>(inst), name); | | |
| 531 | case IrInstructionIdSetEvalBranchQuota: | | |
| 532 | return destroy(reinterpret_cast<IrInstructionSetEvalBranchQuota *>(inst), name); | | |
| 533 | case IrInstructionIdAlignCast: | | |
| 534 | return destroy(reinterpret_cast<IrInstructionAlignCast *>(inst), name); | | |
| 535 | case IrInstructionIdImplicitCast: | | |
| 536 | return destroy(reinterpret_cast<IrInstructionImplicitCast *>(inst), name); | | |
| 537 | case IrInstructionIdResolveResult: | | |
| 538 | return destroy(reinterpret_cast<IrInstructionResolveResult *>(inst), name); | | |
| 539 | case IrInstructionIdResetResult: | | |
| 540 | return destroy(reinterpret_cast<IrInstructionResetResult *>(inst), name); | | |
| 541 | case IrInstructionIdOpaqueType: | | |
| 542 | return destroy(reinterpret_cast<IrInstructionOpaqueType *>(inst), name); | | |
| 543 | case IrInstructionIdSetAlignStack: | | |
| 544 | return destroy(reinterpret_cast<IrInstructionSetAlignStack *>(inst), name); | | |
| 545 | case IrInstructionIdArgType: | | |
| 546 | return destroy(reinterpret_cast<IrInstructionArgType *>(inst), name); | | |
| 547 | case IrInstructionIdTagType: | | |
| 548 | return destroy(reinterpret_cast<IrInstructionTagType *>(inst), name); | | |
| 549 | case IrInstructionIdExport: | | |
| 550 | return destroy(reinterpret_cast<IrInstructionExport *>(inst), name); | | |
| 551 | case IrInstructionIdErrorReturnTrace: | | |
| 552 | return destroy(reinterpret_cast<IrInstructionErrorReturnTrace *>(inst), name); | | |
| 553 | case IrInstructionIdErrorUnion: | | |
| 554 | return destroy(reinterpret_cast<IrInstructionErrorUnion *>(inst), name); | | |
| 555 | case IrInstructionIdAtomicRmw: | | |
| 556 | return destroy(reinterpret_cast<IrInstructionAtomicRmw *>(inst), name); | | |
| 557 | case IrInstructionIdSaveErrRetAddr: | | |
| 558 | return destroy(reinterpret_cast<IrInstructionSaveErrRetAddr *>(inst), name); | | |
| 559 | case IrInstructionIdAddImplicitReturnType: | | |
| 560 | return destroy(reinterpret_cast<IrInstructionAddImplicitReturnType *>(inst), name); | | |
| 561 | case IrInstructionIdFloatOp: | | |
| 562 | return destroy(reinterpret_cast<IrInstructionFloatOp *>(inst), name); | | |
| 563 | case IrInstructionIdMulAdd: | | |
| 564 | return destroy(reinterpret_cast<IrInstructionMulAdd *>(inst), name); | | |
| 565 | case IrInstructionIdAtomicLoad: | | |
| 566 | return destroy(reinterpret_cast<IrInstructionAtomicLoad *>(inst), name); | | |
| 567 | case IrInstructionIdAtomicStore: | | |
| 568 | return destroy(reinterpret_cast<IrInstructionAtomicStore *>(inst), name); | | |
| 569 | case IrInstructionIdEnumToInt: | | |
| 570 | return destroy(reinterpret_cast<IrInstructionEnumToInt *>(inst), name); | | |
| 571 | case IrInstructionIdCheckRuntimeScope: | | |
| 572 | return destroy(reinterpret_cast<IrInstructionCheckRuntimeScope *>(inst), name); | | |
| 573 | case IrInstructionIdDeclVarGen: | | |
| 574 | return destroy(reinterpret_cast<IrInstructionDeclVarGen *>(inst), name); | | |
| 575 | case IrInstructionIdArrayToVector: | | |
| 576 | return destroy(reinterpret_cast<IrInstructionArrayToVector *>(inst), name); | | |
| 577 | case IrInstructionIdVectorToArray: | | |
| 578 | return destroy(reinterpret_cast<IrInstructionVectorToArray *>(inst), name); | | |
| 579 | case IrInstructionIdPtrOfArrayToSlice: | | |
| 580 | return destroy(reinterpret_cast<IrInstructionPtrOfArrayToSlice *>(inst), name); | | |
| 581 | case IrInstructionIdAssertZero: | | |
| 582 | return destroy(reinterpret_cast<IrInstructionAssertZero *>(inst), name); | | |
| 583 | case IrInstructionIdAssertNonNull: | | |
| 584 | return destroy(reinterpret_cast<IrInstructionAssertNonNull *>(inst), name); | | |
| 585 | case IrInstructionIdResizeSlice: | | |
| 586 | return destroy(reinterpret_cast<IrInstructionResizeSlice *>(inst), name); | | |
| 587 | case IrInstructionIdHasDecl: | | |
| 588 | return destroy(reinterpret_cast<IrInstructionHasDecl *>(inst), name); | | |
| 589 | case IrInstructionIdUndeclaredIdent: | | |
| 590 | return destroy(reinterpret_cast<IrInstructionUndeclaredIdent *>(inst), name); | | |
| 591 | case IrInstructionIdAllocaSrc: | | |
| 592 | return destroy(reinterpret_cast<IrInstructionAllocaSrc *>(inst), name); | | |
| 593 | case IrInstructionIdAllocaGen: | | |
| 594 | return destroy(reinterpret_cast<IrInstructionAllocaGen *>(inst), name); | | |
| 595 | case IrInstructionIdEndExpr: | | |
| 596 | return destroy(reinterpret_cast<IrInstructionEndExpr *>(inst), name); | | |
| 597 | case IrInstructionIdUnionInitNamedField: | | |
| 598 | return destroy(reinterpret_cast<IrInstructionUnionInitNamedField *>(inst), name); | | |
| 599 | case IrInstructionIdSuspendBegin: | | |
| 600 | return destroy(reinterpret_cast<IrInstructionSuspendBegin *>(inst), name); | | |
| 601 | case IrInstructionIdSuspendFinish: | | |
| 602 | return destroy(reinterpret_cast<IrInstructionSuspendFinish *>(inst), name); | | |
| 603 | case IrInstructionIdResume: | | |
| 604 | return destroy(reinterpret_cast<IrInstructionResume *>(inst), name); | | |
| 605 | case IrInstructionIdAwaitSrc: | | |
| 606 | return destroy(reinterpret_cast<IrInstructionAwaitSrc *>(inst), name); | | |
| 607 | case IrInstructionIdAwaitGen: | | |
| 608 | return destroy(reinterpret_cast<IrInstructionAwaitGen *>(inst), name); | | |
| 609 | case IrInstructionIdSpillBegin: | | |
| 610 | return destroy(reinterpret_cast<IrInstructionSpillBegin *>(inst), name); | | |
| 611 | case IrInstructionIdSpillEnd: | | |
| 612 | return destroy(reinterpret_cast<IrInstructionSpillEnd *>(inst), name); | | |
| 613 | case IrInstructionIdVectorExtractElem: | | |
| 614 | return destroy(reinterpret_cast<IrInstructionVectorExtractElem *>(inst), name); | | |
| 615 | } | 747 | } |
| 616 | zig_unreachable(); | 748 | zig_unreachable(); |
| 617 | } | 749 | } |
| ... | @@ -627,17 +759,17 @@ static void ira_deref(IrAnalyze *ira) { | ... | @@ -627,17 +759,17 @@ static void ira_deref(IrAnalyze *ira) { |
| 627 | assert(ira->ref_count != 0); | 759 | assert(ira->ref_count != 0); |
| 628 | | 760 | |
| 629 | for (size_t bb_i = 0; bb_i < ira->old_irb.exec->basic_block_list.length; bb_i += 1) { | 761 | for (size_t bb_i = 0; bb_i < ira->old_irb.exec->basic_block_list.length; bb_i += 1) { |
| 630 | IrBasicBlock *pass1_bb = ira->old_irb.exec->basic_block_list.items[bb_i]; | 762 | IrBasicBlockSrc *pass1_bb = ira->old_irb.exec->basic_block_list.items[bb_i]; |
| 631 | for (size_t inst_i = 0; inst_i < pass1_bb->instruction_list.length; inst_i += 1) { | 763 | for (size_t inst_i = 0; inst_i < pass1_bb->instruction_list.length; inst_i += 1) { |
| 632 | IrInstruction *pass1_inst = pass1_bb->instruction_list.items[inst_i]; | 764 | IrInstSrc *pass1_inst = pass1_bb->instruction_list.items[inst_i]; |
| 633 | destroy_instruction(pass1_inst); | 765 | destroy_instruction_src(pass1_inst); |
| 634 | } | 766 | } |
| 635 | destroy(pass1_bb, "IrBasicBlock"); | 767 | destroy(pass1_bb, "IrBasicBlockSrc"); |
| 636 | } | 768 | } |
| 637 | ira->old_irb.exec->basic_block_list.deinit(); | 769 | ira->old_irb.exec->basic_block_list.deinit(); |
| 638 | ira->old_irb.exec->tld_list.deinit(); | 770 | ira->old_irb.exec->tld_list.deinit(); |
| 639 | // cannot destroy here because of var->owner_exec | 771 | // cannot destroy here because of var->owner_exec |
| 640 | //destroy(ira->old_irb.exec, "IrExecutablePass1"); | 772 | //destroy(ira->old_irb.exec, "IrExecutableSrc"); |
| 641 | ira->src_implicit_return_type_list.deinit(); | 773 | ira->src_implicit_return_type_list.deinit(); |
| 642 | ira->resume_stack.deinit(); | 774 | ira->resume_stack.deinit(); |
| 643 | ira->exec_context.mem_slot_list.deinit(); | 775 | ira->exec_context.mem_slot_list.deinit(); |
| ... | @@ -785,7 +917,7 @@ static bool types_have_same_zig_comptime_repr(CodeGen *codegen, ZigType *expecte | ... | @@ -785,7 +917,7 @@ static bool types_have_same_zig_comptime_repr(CodeGen *codegen, ZigType *expecte |
| 785 | zig_unreachable(); | 917 | zig_unreachable(); |
| 786 | } | 918 | } |
| 787 | | 919 | |
| 788 | static bool ir_should_inline(IrExecutable *exec, Scope *scope) { | 920 | static bool ir_should_inline(IrExecutableSrc *exec, Scope *scope) { |
| 789 | if (exec->is_inline) | 921 | if (exec->is_inline) |
| 790 | return true; | 922 | return true; |
| 791 | | 923 | |
| ... | @@ -801,29 +933,41 @@ static bool ir_should_inline(IrExecutable *exec, Scope *scope) { | ... | @@ -801,29 +933,41 @@ static bool ir_should_inline(IrExecutable *exec, Scope *scope) { |
| 801 | return false; | 933 | return false; |
| 802 | } | 934 | } |
| 803 | | 935 | |
| 804 | static void ir_instruction_append(IrBasicBlock *basic_block, IrInstruction *instruction) { | 936 | static void ir_instruction_append(IrBasicBlockSrc *basic_block, IrInstSrc *instruction) { |
| | 937 | assert(basic_block); |
| | 938 | assert(instruction); |
| | 939 | basic_block->instruction_list.append(instruction); |
| | 940 | } |
| | 941 | |
| | 942 | static void ir_inst_gen_append(IrBasicBlockGen *basic_block, IrInstGen *instruction) { |
| 805 | assert(basic_block); | 943 | assert(basic_block); |
| 806 | assert(instruction); | 944 | assert(instruction); |
| 807 | basic_block->instruction_list.append(instruction); | 945 | basic_block->instruction_list.append(instruction); |
| 808 | } | 946 | } |
| 809 | | 947 | |
| 810 | static size_t exec_next_debug_id(IrExecutable *exec) { | 948 | static size_t exec_next_debug_id(IrExecutableSrc *exec) { |
| | 949 | size_t result = exec->next_debug_id; |
| | 950 | exec->next_debug_id += 1; |
| | 951 | return result; |
| | 952 | } |
| | 953 | |
| | 954 | static size_t exec_next_debug_id_gen(IrExecutableGen *exec) { |
| 811 | size_t result = exec->next_debug_id; | 955 | size_t result = exec->next_debug_id; |
| 812 | exec->next_debug_id += 1; | 956 | exec->next_debug_id += 1; |
| 813 | return result; | 957 | return result; |
| 814 | } | 958 | } |
| 815 | | 959 | |
| 816 | static size_t exec_next_mem_slot(IrExecutable *exec) { | 960 | static size_t exec_next_mem_slot(IrExecutableSrc *exec) { |
| 817 | size_t result = exec->mem_slot_count; | 961 | size_t result = exec->mem_slot_count; |
| 818 | exec->mem_slot_count += 1; | 962 | exec->mem_slot_count += 1; |
| 819 | return result; | 963 | return result; |
| 820 | } | 964 | } |
| 821 | | 965 | |
| 822 | static ZigFn *exec_fn_entry(IrExecutable *exec) { | 966 | static ZigFn *exec_fn_entry(IrExecutableSrc *exec) { |
| 823 | return exec->fn_entry; | 967 | return exec->fn_entry; |
| 824 | } | 968 | } |
| 825 | | 969 | |
| 826 | static Buf *exec_c_import_buf(IrExecutable *exec) { | 970 | static Buf *exec_c_import_buf(IrExecutableSrc *exec) { |
| 827 | return exec->c_import_buf; | 971 | return exec->c_import_buf; |
| 828 | } | 972 | } |
| 829 | | 973 | |
| ... | @@ -831,28 +975,42 @@ static bool value_is_comptime(ZigValue *const_val) { | ... | @@ -831,28 +975,42 @@ static bool value_is_comptime(ZigValue *const_val) { |
| 831 | return const_val->special != ConstValSpecialRuntime; | 975 | return const_val->special != ConstValSpecialRuntime; |
| 832 | } | 976 | } |
| 833 | | 977 | |
| 834 | static bool instr_is_comptime(IrInstruction *instruction) { | 978 | static bool instr_is_comptime(IrInstGen *instruction) { |
| 835 | return value_is_comptime(instruction->value); | 979 | return value_is_comptime(instruction->value); |
| 836 | } | 980 | } |
| 837 | | 981 | |
| 838 | static bool instr_is_unreachable(IrInstruction *instruction) { | 982 | static bool instr_is_unreachable(IrInstSrc *instruction) { |
| 839 | return instruction->value->type && instruction->value->type->id == ZigTypeIdUnreachable; | 983 | return instruction->is_noreturn; |
| 840 | } | 984 | } |
| 841 | | 985 | |
| 842 | static void ir_link_new_bb(IrBasicBlock *new_bb, IrBasicBlock *old_bb) { | 986 | static void ir_link_new_bb(IrBasicBlockGen *new_bb, IrBasicBlockSrc *old_bb) { |
| 843 | new_bb->other = old_bb; | 987 | new_bb->parent = old_bb; |
| 844 | old_bb->other = new_bb; | 988 | old_bb->child = new_bb; |
| 845 | } | 989 | } |
| 846 | | 990 | |
| 847 | static void ir_ref_bb(IrBasicBlock *bb) { | 991 | static void ir_ref_bb(IrBasicBlockSrc *bb) { |
| 848 | bb->ref_count += 1; | 992 | bb->ref_count += 1; |
| 849 | } | 993 | } |
| 850 | | 994 | |
| 851 | static void ir_ref_instruction(IrInstruction *instruction, IrBasicBlock *cur_bb) { | 995 | static void ir_ref_bb_gen(IrBasicBlockGen *bb) { |
| 852 | assert(instruction->id != IrInstructionIdInvalid); | 996 | bb->ref_count += 1; |
| 853 | instruction->ref_count += 1; | 997 | } |
| 854 | if (instruction->owner_bb != cur_bb && !instr_is_comptime(instruction)) | 998 | |
| | 999 | static void ir_ref_instruction(IrInstSrc *instruction, IrBasicBlockSrc *cur_bb) { |
| | 1000 | assert(instruction->id != IrInstSrcIdInvalid); |
| | 1001 | instruction->base.ref_count += 1; |
| | 1002 | if (instruction->owner_bb != cur_bb && !instr_is_unreachable(instruction) |
| | 1003 | && instruction->id != IrInstSrcIdConst) |
| | 1004 | { |
| 855 | ir_ref_bb(instruction->owner_bb); | 1005 | ir_ref_bb(instruction->owner_bb); |
| | 1006 | } |
| | 1007 | } |
| | 1008 | |
| | 1009 | static void ir_ref_inst_gen(IrInstGen *instruction, IrBasicBlockGen *cur_bb) { |
| | 1010 | assert(instruction->id != IrInstGenIdInvalid); |
| | 1011 | instruction->base.ref_count += 1; |
| | 1012 | if (instruction->owner_bb != cur_bb && !instr_is_comptime(instruction)) |
| | 1013 | ir_ref_bb_gen(instruction->owner_bb); |
| 856 | } | 1014 | } |
| 857 | | 1015 | |
| 858 | static void ir_ref_var(ZigVar *var) { | 1016 | static void ir_ref_var(ZigVar *var) { |
| ... | @@ -871,962 +1029,1259 @@ ZigType *ir_analyze_type_expr(IrAnalyze *ira, Scope *scope, AstNode *node) { | ... | @@ -871,962 +1029,1259 @@ ZigType *ir_analyze_type_expr(IrAnalyze *ira, Scope *scope, AstNode *node) { |
| 871 | return result->data.x_type; | 1029 | return result->data.x_type; |
| 872 | } | 1030 | } |
| 873 | | 1031 | |
| 874 | static IrBasicBlock *ir_create_basic_block(IrBuilder *irb, Scope *scope, const char *name_hint) { | 1032 | static IrBasicBlockSrc *ir_create_basic_block(IrBuilderSrc *irb, Scope *scope, const char *name_hint) { |
| 875 | IrBasicBlock *result = allocate<IrBasicBlock>(1, "IrBasicBlock"); | 1033 | IrBasicBlockSrc *result = allocate<IrBasicBlockSrc>(1, "IrBasicBlockSrc"); |
| 876 | result->scope = scope; | 1034 | result->scope = scope; |
| 877 | result->name_hint = name_hint; | 1035 | result->name_hint = name_hint; |
| 878 | result->debug_id = exec_next_debug_id(irb->exec); | 1036 | result->debug_id = exec_next_debug_id(irb->exec); |
| 879 | result->index = SIZE_MAX; // set later | 1037 | result->index = UINT32_MAX; // set later |
| 880 | return result; | 1038 | return result; |
| 881 | } | 1039 | } |
| 882 | | 1040 | |
| 883 | static IrBasicBlock *ir_build_bb_from(IrBuilder *irb, IrBasicBlock *other_bb) { | 1041 | static IrBasicBlockGen *ir_create_basic_block_gen(IrAnalyze *ira, Scope *scope, const char *name_hint) { |
| 884 | IrBasicBlock *new_bb = ir_create_basic_block(irb, other_bb->scope, other_bb->name_hint); | 1042 | IrBasicBlockGen *result = allocate<IrBasicBlockGen>(1, "IrBasicBlockGen"); |
| | 1043 | result->scope = scope; |
| | 1044 | result->name_hint = name_hint; |
| | 1045 | result->debug_id = exec_next_debug_id_gen(ira->new_irb.exec); |
| | 1046 | result->index = UINT32_MAX; // set later |
| | 1047 | return result; |
| | 1048 | } |
| | 1049 | |
| | 1050 | static IrBasicBlockGen *ir_build_bb_from(IrAnalyze *ira, IrBasicBlockSrc *other_bb) { |
| | 1051 | IrBasicBlockGen *new_bb = ir_create_basic_block_gen(ira, other_bb->scope, other_bb->name_hint); |
| 885 | ir_link_new_bb(new_bb, other_bb); | 1052 | ir_link_new_bb(new_bb, other_bb); |
| 886 | return new_bb; | 1053 | return new_bb; |
| 887 | } | 1054 | } |
| 888 | | 1055 | |
| 889 | static constexpr IrInstructionId ir_instruction_id(IrInstructionDeclVarSrc *) { | 1056 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcDeclVar *) { |
| 890 | return IrInstructionIdDeclVarSrc; | 1057 | return IrInstSrcIdDeclVar; |
| | 1058 | } |
| | 1059 | |
| | 1060 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBr *) { |
| | 1061 | return IrInstSrcIdBr; |
| | 1062 | } |
| | 1063 | |
| | 1064 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCondBr *) { |
| | 1065 | return IrInstSrcIdCondBr; |
| | 1066 | } |
| | 1067 | |
| | 1068 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSwitchBr *) { |
| | 1069 | return IrInstSrcIdSwitchBr; |
| | 1070 | } |
| | 1071 | |
| | 1072 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSwitchVar *) { |
| | 1073 | return IrInstSrcIdSwitchVar; |
| | 1074 | } |
| | 1075 | |
| | 1076 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSwitchElseVar *) { |
| | 1077 | return IrInstSrcIdSwitchElseVar; |
| | 1078 | } |
| | 1079 | |
| | 1080 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSwitchTarget *) { |
| | 1081 | return IrInstSrcIdSwitchTarget; |
| | 1082 | } |
| | 1083 | |
| | 1084 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPhi *) { |
| | 1085 | return IrInstSrcIdPhi; |
| | 1086 | } |
| | 1087 | |
| | 1088 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUnOp *) { |
| | 1089 | return IrInstSrcIdUnOp; |
| | 1090 | } |
| | 1091 | |
| | 1092 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBinOp *) { |
| | 1093 | return IrInstSrcIdBinOp; |
| | 1094 | } |
| | 1095 | |
| | 1096 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMergeErrSets *) { |
| | 1097 | return IrInstSrcIdMergeErrSets; |
| | 1098 | } |
| | 1099 | |
| | 1100 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcLoadPtr *) { |
| | 1101 | return IrInstSrcIdLoadPtr; |
| | 1102 | } |
| | 1103 | |
| | 1104 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcStorePtr *) { |
| | 1105 | return IrInstSrcIdStorePtr; |
| | 1106 | } |
| | 1107 | |
| | 1108 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFieldPtr *) { |
| | 1109 | return IrInstSrcIdFieldPtr; |
| | 1110 | } |
| | 1111 | |
| | 1112 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcElemPtr *) { |
| | 1113 | return IrInstSrcIdElemPtr; |
| | 1114 | } |
| | 1115 | |
| | 1116 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcVarPtr *) { |
| | 1117 | return IrInstSrcIdVarPtr; |
| | 1118 | } |
| | 1119 | |
| | 1120 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCall *) { |
| | 1121 | return IrInstSrcIdCall; |
| | 1122 | } |
| | 1123 | |
| | 1124 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCallArgs *) { |
| | 1125 | return IrInstSrcIdCallArgs; |
| | 1126 | } |
| | 1127 | |
| | 1128 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCallExtra *) { |
| | 1129 | return IrInstSrcIdCallExtra; |
| | 1130 | } |
| | 1131 | |
| | 1132 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcConst *) { |
| | 1133 | return IrInstSrcIdConst; |
| | 1134 | } |
| | 1135 | |
| | 1136 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcReturn *) { |
| | 1137 | return IrInstSrcIdReturn; |
| | 1138 | } |
| | 1139 | |
| | 1140 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcContainerInitList *) { |
| | 1141 | return IrInstSrcIdContainerInitList; |
| | 1142 | } |
| | 1143 | |
| | 1144 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcContainerInitFields *) { |
| | 1145 | return IrInstSrcIdContainerInitFields; |
| | 1146 | } |
| | 1147 | |
| | 1148 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUnreachable *) { |
| | 1149 | return IrInstSrcIdUnreachable; |
| | 1150 | } |
| | 1151 | |
| | 1152 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTypeOf *) { |
| | 1153 | return IrInstSrcIdTypeOf; |
| | 1154 | } |
| | 1155 | |
| | 1156 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetCold *) { |
| | 1157 | return IrInstSrcIdSetCold; |
| | 1158 | } |
| | 1159 | |
| | 1160 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetRuntimeSafety *) { |
| | 1161 | return IrInstSrcIdSetRuntimeSafety; |
| | 1162 | } |
| | 1163 | |
| | 1164 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetFloatMode *) { |
| | 1165 | return IrInstSrcIdSetFloatMode; |
| | 1166 | } |
| | 1167 | |
| | 1168 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcArrayType *) { |
| | 1169 | return IrInstSrcIdArrayType; |
| | 1170 | } |
| | 1171 | |
| | 1172 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAnyFrameType *) { |
| | 1173 | return IrInstSrcIdAnyFrameType; |
| | 1174 | } |
| | 1175 | |
| | 1176 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSliceType *) { |
| | 1177 | return IrInstSrcIdSliceType; |
| | 1178 | } |
| | 1179 | |
| | 1180 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAsm *) { |
| | 1181 | return IrInstSrcIdAsm; |
| | 1182 | } |
| | 1183 | |
| | 1184 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSizeOf *) { |
| | 1185 | return IrInstSrcIdSizeOf; |
| | 1186 | } |
| | 1187 | |
| | 1188 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTestNonNull *) { |
| | 1189 | return IrInstSrcIdTestNonNull; |
| | 1190 | } |
| | 1191 | |
| | 1192 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcOptionalUnwrapPtr *) { |
| | 1193 | return IrInstSrcIdOptionalUnwrapPtr; |
| | 1194 | } |
| | 1195 | |
| | 1196 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcClz *) { |
| | 1197 | return IrInstSrcIdClz; |
| | 1198 | } |
| | 1199 | |
| | 1200 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCtz *) { |
| | 1201 | return IrInstSrcIdCtz; |
| | 1202 | } |
| | 1203 | |
| | 1204 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPopCount *) { |
| | 1205 | return IrInstSrcIdPopCount; |
| | 1206 | } |
| | 1207 | |
| | 1208 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBswap *) { |
| | 1209 | return IrInstSrcIdBswap; |
| | 1210 | } |
| | 1211 | |
| | 1212 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBitReverse *) { |
| | 1213 | return IrInstSrcIdBitReverse; |
| | 1214 | } |
| | 1215 | |
| | 1216 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcImport *) { |
| | 1217 | return IrInstSrcIdImport; |
| | 1218 | } |
| | 1219 | |
| | 1220 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCImport *) { |
| | 1221 | return IrInstSrcIdCImport; |
| | 1222 | } |
| | 1223 | |
| | 1224 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCInclude *) { |
| | 1225 | return IrInstSrcIdCInclude; |
| | 1226 | } |
| | 1227 | |
| | 1228 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCDefine *) { |
| | 1229 | return IrInstSrcIdCDefine; |
| | 1230 | } |
| | 1231 | |
| | 1232 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCUndef *) { |
| | 1233 | return IrInstSrcIdCUndef; |
| | 1234 | } |
| | 1235 | |
| | 1236 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcRef *) { |
| | 1237 | return IrInstSrcIdRef; |
| | 1238 | } |
| | 1239 | |
| | 1240 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCompileErr *) { |
| | 1241 | return IrInstSrcIdCompileErr; |
| | 1242 | } |
| | 1243 | |
| | 1244 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCompileLog *) { |
| | 1245 | return IrInstSrcIdCompileLog; |
| | 1246 | } |
| | 1247 | |
| | 1248 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrName *) { |
| | 1249 | return IrInstSrcIdErrName; |
| | 1250 | } |
| | 1251 | |
| | 1252 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcEmbedFile *) { |
| | 1253 | return IrInstSrcIdEmbedFile; |
| | 1254 | } |
| | 1255 | |
| | 1256 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCmpxchg *) { |
| | 1257 | return IrInstSrcIdCmpxchg; |
| | 1258 | } |
| | 1259 | |
| | 1260 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFence *) { |
| | 1261 | return IrInstSrcIdFence; |
| | 1262 | } |
| | 1263 | |
| | 1264 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTruncate *) { |
| | 1265 | return IrInstSrcIdTruncate; |
| | 1266 | } |
| | 1267 | |
| | 1268 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntCast *) { |
| | 1269 | return IrInstSrcIdIntCast; |
| | 1270 | } |
| | 1271 | |
| | 1272 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFloatCast *) { |
| | 1273 | return IrInstSrcIdFloatCast; |
| | 1274 | } |
| | 1275 | |
| | 1276 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntToFloat *) { |
| | 1277 | return IrInstSrcIdIntToFloat; |
| | 1278 | } |
| | 1279 | |
| | 1280 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFloatToInt *) { |
| | 1281 | return IrInstSrcIdFloatToInt; |
| | 1282 | } |
| | 1283 | |
| | 1284 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBoolToInt *) { |
| | 1285 | return IrInstSrcIdBoolToInt; |
| 891 | } | 1286 | } |
| 892 | | 1287 | |
| 893 | static constexpr IrInstructionId ir_instruction_id(IrInstructionDeclVarGen *) { | 1288 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntType *) { |
| 894 | return IrInstructionIdDeclVarGen; | 1289 | return IrInstSrcIdIntType; |
| 895 | } | 1290 | } |
| 896 | | 1291 | |
| 897 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCondBr *) { | 1292 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcVectorType *) { |
| 898 | return IrInstructionIdCondBr; | 1293 | return IrInstSrcIdVectorType; |
| 899 | } | 1294 | } |
| 900 | | 1295 | |
| 901 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBr *) { | 1296 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcShuffleVector *) { |
| 902 | return IrInstructionIdBr; | 1297 | return IrInstSrcIdShuffleVector; |
| 903 | } | 1298 | } |
| 904 | | 1299 | |
| 905 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSwitchBr *) { | 1300 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSplat *) { |
| 906 | return IrInstructionIdSwitchBr; | 1301 | return IrInstSrcIdSplat; |
| 907 | } | 1302 | } |
| 908 | | 1303 | |
| 909 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSwitchVar *) { | 1304 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBoolNot *) { |
| 910 | return IrInstructionIdSwitchVar; | 1305 | return IrInstSrcIdBoolNot; |
| 911 | } | 1306 | } |
| 912 | | 1307 | |
| 913 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSwitchElseVar *) { | 1308 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMemset *) { |
| 914 | return IrInstructionIdSwitchElseVar; | 1309 | return IrInstSrcIdMemset; |
| 915 | } | 1310 | } |
| 916 | | 1311 | |
| 917 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSwitchTarget *) { | 1312 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMemcpy *) { |
| 918 | return IrInstructionIdSwitchTarget; | 1313 | return IrInstSrcIdMemcpy; |
| 919 | } | 1314 | } |
| 920 | | 1315 | |
| 921 | static constexpr IrInstructionId ir_instruction_id(IrInstructionPhi *) { | 1316 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSlice *) { |
| 922 | return IrInstructionIdPhi; | 1317 | return IrInstSrcIdSlice; |
| 923 | } | 1318 | } |
| 924 | | 1319 | |
| 925 | static constexpr IrInstructionId ir_instruction_id(IrInstructionUnOp *) { | 1320 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMemberCount *) { |
| 926 | return IrInstructionIdUnOp; | 1321 | return IrInstSrcIdMemberCount; |
| 927 | } | 1322 | } |
| 928 | | 1323 | |
| 929 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBinOp *) { | 1324 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMemberType *) { |
| 930 | return IrInstructionIdBinOp; | 1325 | return IrInstSrcIdMemberType; |
| 931 | } | 1326 | } |
| 932 | | 1327 | |
| 933 | static constexpr IrInstructionId ir_instruction_id(IrInstructionMergeErrSets *) { | 1328 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMemberName *) { |
| 934 | return IrInstructionIdMergeErrSets; | 1329 | return IrInstSrcIdMemberName; |
| 935 | } | 1330 | } |
| 936 | | 1331 | |
| 937 | static constexpr IrInstructionId ir_instruction_id(IrInstructionExport *) { | 1332 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBreakpoint *) { |
| 938 | return IrInstructionIdExport; | 1333 | return IrInstSrcIdBreakpoint; |
| 939 | } | 1334 | } |
| 940 | | 1335 | |
| 941 | static constexpr IrInstructionId ir_instruction_id(IrInstructionLoadPtr *) { | 1336 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcReturnAddress *) { |
| 942 | return IrInstructionIdLoadPtr; | 1337 | return IrInstSrcIdReturnAddress; |
| 943 | } | 1338 | } |
| 944 | | 1339 | |
| 945 | static constexpr IrInstructionId ir_instruction_id(IrInstructionLoadPtrGen *) { | 1340 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFrameAddress *) { |
| 946 | return IrInstructionIdLoadPtrGen; | 1341 | return IrInstSrcIdFrameAddress; |
| 947 | } | 1342 | } |
| 948 | | 1343 | |
| 949 | static constexpr IrInstructionId ir_instruction_id(IrInstructionStorePtr *) { | 1344 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFrameHandle *) { |
| 950 | return IrInstructionIdStorePtr; | 1345 | return IrInstSrcIdFrameHandle; |
| 951 | } | 1346 | } |
| 952 | | 1347 | |
| 953 | static constexpr IrInstructionId ir_instruction_id(IrInstructionVectorStoreElem *) { | 1348 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFrameType *) { |
| 954 | return IrInstructionIdVectorStoreElem; | 1349 | return IrInstSrcIdFrameType; |
| 955 | } | 1350 | } |
| 956 | | 1351 | |
| 957 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFieldPtr *) { | 1352 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFrameSize *) { |
| 958 | return IrInstructionIdFieldPtr; | 1353 | return IrInstSrcIdFrameSize; |
| 959 | } | 1354 | } |
| 960 | | 1355 | |
| 961 | static constexpr IrInstructionId ir_instruction_id(IrInstructionStructFieldPtr *) { | 1356 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAlignOf *) { |
| 962 | return IrInstructionIdStructFieldPtr; | 1357 | return IrInstSrcIdAlignOf; |
| 963 | } | 1358 | } |
| 964 | | 1359 | |
| 965 | static constexpr IrInstructionId ir_instruction_id(IrInstructionUnionFieldPtr *) { | 1360 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcOverflowOp *) { |
| 966 | return IrInstructionIdUnionFieldPtr; | 1361 | return IrInstSrcIdOverflowOp; |
| 967 | } | 1362 | } |
| 968 | | 1363 | |
| 969 | static constexpr IrInstructionId ir_instruction_id(IrInstructionElemPtr *) { | 1364 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTestErr *) { |
| 970 | return IrInstructionIdElemPtr; | 1365 | return IrInstSrcIdTestErr; |
| 971 | } | 1366 | } |
| 972 | | 1367 | |
| 973 | static constexpr IrInstructionId ir_instruction_id(IrInstructionVarPtr *) { | 1368 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcMulAdd *) { |
| 974 | return IrInstructionIdVarPtr; | 1369 | return IrInstSrcIdMulAdd; |
| 975 | } | 1370 | } |
| 976 | | 1371 | |
| 977 | static constexpr IrInstructionId ir_instruction_id(IrInstructionReturnPtr *) { | 1372 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFloatOp *) { |
| 978 | return IrInstructionIdReturnPtr; | 1373 | return IrInstSrcIdFloatOp; |
| 979 | } | 1374 | } |
| 980 | | 1375 | |
| 981 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCallSrc *) { | 1376 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUnwrapErrCode *) { |
| 982 | return IrInstructionIdCallSrc; | 1377 | return IrInstSrcIdUnwrapErrCode; |
| 983 | } | 1378 | } |
| 984 | | 1379 | |
| 985 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCallSrcArgs *) { | 1380 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUnwrapErrPayload *) { |
| 986 | return IrInstructionIdCallSrcArgs; | 1381 | return IrInstSrcIdUnwrapErrPayload; |
| 987 | } | 1382 | } |
| 988 | | 1383 | |
| 989 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCallExtra *) { | 1384 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFnProto *) { |
| 990 | return IrInstructionIdCallExtra; | 1385 | return IrInstSrcIdFnProto; |
| 991 | } | 1386 | } |
| 992 | | 1387 | |
| 993 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCallGen *) { | 1388 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTestComptime *) { |
| 994 | return IrInstructionIdCallGen; | 1389 | return IrInstSrcIdTestComptime; |
| 995 | } | 1390 | } |
| 996 | | 1391 | |
| 997 | static constexpr IrInstructionId ir_instruction_id(IrInstructionConst *) { | 1392 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPtrCast *) { |
| 998 | return IrInstructionIdConst; | 1393 | return IrInstSrcIdPtrCast; |
| 999 | } | 1394 | } |
| 1000 | | 1395 | |
| 1001 | static constexpr IrInstructionId ir_instruction_id(IrInstructionReturn *) { | 1396 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBitCast *) { |
| 1002 | return IrInstructionIdReturn; | 1397 | return IrInstSrcIdBitCast; |
| 1003 | } | 1398 | } |
| 1004 | | 1399 | |
| 1005 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCast *) { | 1400 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntToPtr *) { |
| 1006 | return IrInstructionIdCast; | 1401 | return IrInstSrcIdIntToPtr; |
| 1007 | } | 1402 | } |
| 1008 | | 1403 | |
| 1009 | static constexpr IrInstructionId ir_instruction_id(IrInstructionResizeSlice *) { | 1404 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPtrToInt *) { |
| 1010 | return IrInstructionIdResizeSlice; | 1405 | return IrInstSrcIdPtrToInt; |
| 1011 | } | 1406 | } |
| 1012 | | 1407 | |
| 1013 | static constexpr IrInstructionId ir_instruction_id(IrInstructionContainerInitList *) { | 1408 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntToEnum *) { |
| 1014 | return IrInstructionIdContainerInitList; | 1409 | return IrInstSrcIdIntToEnum; |
| 1015 | } | 1410 | } |
| 1016 | | 1411 | |
| 1017 | static constexpr IrInstructionId ir_instruction_id(IrInstructionContainerInitFields *) { | 1412 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcEnumToInt *) { |
| 1018 | return IrInstructionIdContainerInitFields; | 1413 | return IrInstSrcIdEnumToInt; |
| 1019 | } | 1414 | } |
| 1020 | | 1415 | |
| 1021 | static constexpr IrInstructionId ir_instruction_id(IrInstructionUnreachable *) { | 1416 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntToErr *) { |
| 1022 | return IrInstructionIdUnreachable; | 1417 | return IrInstSrcIdIntToErr; |
| 1023 | } | 1418 | } |
| 1024 | | 1419 | |
| 1025 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTypeOf *) { | 1420 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrToInt *) { |
| 1026 | return IrInstructionIdTypeOf; | 1421 | return IrInstSrcIdErrToInt; |
| 1027 | } | 1422 | } |
| 1028 | | 1423 | |
| 1029 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSetCold *) { | 1424 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCheckSwitchProngs *) { |
| 1030 | return IrInstructionIdSetCold; | 1425 | return IrInstSrcIdCheckSwitchProngs; |
| 1031 | } | 1426 | } |
| 1032 | | 1427 | |
| 1033 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSetRuntimeSafety *) { | 1428 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCheckStatementIsVoid *) { |
| 1034 | return IrInstructionIdSetRuntimeSafety; | 1429 | return IrInstSrcIdCheckStatementIsVoid; |
| 1035 | } | 1430 | } |
| 1036 | | 1431 | |
| 1037 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSetFloatMode *) { | 1432 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTypeName *) { |
| 1038 | return IrInstructionIdSetFloatMode; | 1433 | return IrInstSrcIdTypeName; |
| 1039 | } | 1434 | } |
| 1040 | | 1435 | |
| 1041 | static constexpr IrInstructionId ir_instruction_id(IrInstructionArrayType *) { | 1436 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcDeclRef *) { |
| 1042 | return IrInstructionIdArrayType; | 1437 | return IrInstSrcIdDeclRef; |
| 1043 | } | 1438 | } |
| 1044 | | 1439 | |
| 1045 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAnyFrameType *) { | 1440 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPanic *) { |
| 1046 | return IrInstructionIdAnyFrameType; | 1441 | return IrInstSrcIdPanic; |
| 1047 | } | 1442 | } |
| 1048 | | 1443 | |
| 1049 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSliceType *) { | 1444 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTagName *) { |
| 1050 | return IrInstructionIdSliceType; | 1445 | return IrInstSrcIdTagName; |
| 1051 | } | 1446 | } |
| 1052 | | 1447 | |
| 1053 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAsmSrc *) { | 1448 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTagType *) { |
| 1054 | return IrInstructionIdAsmSrc; | 1449 | return IrInstSrcIdTagType; |
| 1055 | } | 1450 | } |
| 1056 | | 1451 | |
| 1057 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAsmGen *) { | 1452 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFieldParentPtr *) { |
| 1058 | return IrInstructionIdAsmGen; | 1453 | return IrInstSrcIdFieldParentPtr; |
| 1059 | } | 1454 | } |
| 1060 | | 1455 | |
| 1061 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSizeOf *) { | 1456 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcByteOffsetOf *) { |
| 1062 | return IrInstructionIdSizeOf; | 1457 | return IrInstSrcIdByteOffsetOf; |
| 1063 | } | 1458 | } |
| 1064 | | 1459 | |
| 1065 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTestNonNull *) { | 1460 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcBitOffsetOf *) { |
| 1066 | return IrInstructionIdTestNonNull; | 1461 | return IrInstSrcIdBitOffsetOf; |
| 1067 | } | 1462 | } |
| 1068 | | 1463 | |
| 1069 | static constexpr IrInstructionId ir_instruction_id(IrInstructionOptionalUnwrapPtr *) { | 1464 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTypeInfo *) { |
| 1070 | return IrInstructionIdOptionalUnwrapPtr; | 1465 | return IrInstSrcIdTypeInfo; |
| 1071 | } | 1466 | } |
| 1072 | | 1467 | |
| 1073 | static constexpr IrInstructionId ir_instruction_id(IrInstructionClz *) { | 1468 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcType *) { |
| 1074 | return IrInstructionIdClz; | 1469 | return IrInstSrcIdType; |
| 1075 | } | 1470 | } |
| 1076 | | 1471 | |
| 1077 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCtz *) { | 1472 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcHasField *) { |
| 1078 | return IrInstructionIdCtz; | 1473 | return IrInstSrcIdHasField; |
| 1079 | } | 1474 | } |
| 1080 | | 1475 | |
| 1081 | static constexpr IrInstructionId ir_instruction_id(IrInstructionPopCount *) { | 1476 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcTypeId *) { |
| 1082 | return IrInstructionIdPopCount; | 1477 | return IrInstSrcIdTypeId; |
| 1083 | } | 1478 | } |
| 1084 | | 1479 | |
| 1085 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBswap *) { | 1480 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetEvalBranchQuota *) { |
| 1086 | return IrInstructionIdBswap; | 1481 | return IrInstSrcIdSetEvalBranchQuota; |
| 1087 | } | 1482 | } |
| 1088 | | 1483 | |
| 1089 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBitReverse *) { | 1484 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcPtrType *) { |
| 1090 | return IrInstructionIdBitReverse; | 1485 | return IrInstSrcIdPtrType; |
| 1091 | } | 1486 | } |
| 1092 | | 1487 | |
| 1093 | static constexpr IrInstructionId ir_instruction_id(IrInstructionUnionTag *) { | 1488 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAlignCast *) { |
| 1094 | return IrInstructionIdUnionTag; | 1489 | return IrInstSrcIdAlignCast; |
| 1095 | } | 1490 | } |
| 1096 | | 1491 | |
| 1097 | static constexpr IrInstructionId ir_instruction_id(IrInstructionImport *) { | 1492 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcImplicitCast *) { |
| 1098 | return IrInstructionIdImport; | 1493 | return IrInstSrcIdImplicitCast; |
| 1099 | } | 1494 | } |
| 1100 | | 1495 | |
| 1101 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCImport *) { | 1496 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcResolveResult *) { |
| 1102 | return IrInstructionIdCImport; | 1497 | return IrInstSrcIdResolveResult; |
| 1103 | } | 1498 | } |
| 1104 | | 1499 | |
| 1105 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCInclude *) { | 1500 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcResetResult *) { |
| 1106 | return IrInstructionIdCInclude; | 1501 | return IrInstSrcIdResetResult; |
| 1107 | } | 1502 | } |
| 1108 | | 1503 | |
| 1109 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCDefine *) { | 1504 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcOpaqueType *) { |
| 1110 | return IrInstructionIdCDefine; | 1505 | return IrInstSrcIdOpaqueType; |
| 1111 | } | 1506 | } |
| 1112 | | 1507 | |
| 1113 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCUndef *) { | 1508 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetAlignStack *) { |
| 1114 | return IrInstructionIdCUndef; | 1509 | return IrInstSrcIdSetAlignStack; |
| 1115 | } | 1510 | } |
| 1116 | | 1511 | |
| 1117 | static constexpr IrInstructionId ir_instruction_id(IrInstructionRef *) { | 1512 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcArgType *) { |
| 1118 | return IrInstructionIdRef; | 1513 | return IrInstSrcIdArgType; |
| 1119 | } | 1514 | } |
| 1120 | | 1515 | |
| 1121 | static constexpr IrInstructionId ir_instruction_id(IrInstructionRefGen *) { | 1516 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcExport *) { |
| 1122 | return IrInstructionIdRefGen; | 1517 | return IrInstSrcIdExport; |
| 1123 | } | 1518 | } |
| 1124 | | 1519 | |
| 1125 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCompileErr *) { | 1520 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrorReturnTrace *) { |
| 1126 | return IrInstructionIdCompileErr; | 1521 | return IrInstSrcIdErrorReturnTrace; |
| 1127 | } | 1522 | } |
| 1128 | | 1523 | |
| 1129 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCompileLog *) { | 1524 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrorUnion *) { |
| 1130 | return IrInstructionIdCompileLog; | 1525 | return IrInstSrcIdErrorUnion; |
| 1131 | } | 1526 | } |
| 1132 | | 1527 | |
| 1133 | static constexpr IrInstructionId ir_instruction_id(IrInstructionErrName *) { | 1528 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAtomicRmw *) { |
| 1134 | return IrInstructionIdErrName; | 1529 | return IrInstSrcIdAtomicRmw; |
| 1135 | } | 1530 | } |
| 1136 | | 1531 | |
| 1137 | static constexpr IrInstructionId ir_instruction_id(IrInstructionEmbedFile *) { | 1532 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAtomicLoad *) { |
| 1138 | return IrInstructionIdEmbedFile; | 1533 | return IrInstSrcIdAtomicLoad; |
| 1139 | } | 1534 | } |
| 1140 | | 1535 | |
| 1141 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCmpxchgSrc *) { | 1536 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAtomicStore *) { |
| 1142 | return IrInstructionIdCmpxchgSrc; | 1537 | return IrInstSrcIdAtomicStore; |
| 1143 | } | 1538 | } |
| 1144 | | 1539 | |
| 1145 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCmpxchgGen *) { | 1540 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSaveErrRetAddr *) { |
| 1146 | return IrInstructionIdCmpxchgGen; | 1541 | return IrInstSrcIdSaveErrRetAddr; |
| 1147 | } | 1542 | } |
| 1148 | | 1543 | |
| 1149 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFence *) { | 1544 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAddImplicitReturnType *) { |
| 1150 | return IrInstructionIdFence; | 1545 | return IrInstSrcIdAddImplicitReturnType; |
| 1151 | } | 1546 | } |
| 1152 | | 1547 | |
| 1153 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTruncate *) { | 1548 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrSetCast *) { |
| 1154 | return IrInstructionIdTruncate; | 1549 | return IrInstSrcIdErrSetCast; |
| 1155 | } | 1550 | } |
| 1156 | | 1551 | |
| 1157 | static constexpr IrInstructionId ir_instruction_id(IrInstructionIntCast *) { | 1552 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcToBytes *) { |
| 1158 | return IrInstructionIdIntCast; | 1553 | return IrInstSrcIdToBytes; |
| 1159 | } | 1554 | } |
| 1160 | | 1555 | |
| 1161 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFloatCast *) { | 1556 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcFromBytes *) { |
| 1162 | return IrInstructionIdFloatCast; | 1557 | return IrInstSrcIdFromBytes; |
| 1163 | } | 1558 | } |
| 1164 | | 1559 | |
| 1165 | static constexpr IrInstructionId ir_instruction_id(IrInstructionErrSetCast *) { | 1560 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCheckRuntimeScope *) { |
| 1166 | return IrInstructionIdErrSetCast; | 1561 | return IrInstSrcIdCheckRuntimeScope; |
| 1167 | } | 1562 | } |
| 1168 | | 1563 | |
| 1169 | static constexpr IrInstructionId ir_instruction_id(IrInstructionToBytes *) { | 1564 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcHasDecl *) { |
| 1170 | return IrInstructionIdToBytes; | 1565 | return IrInstSrcIdHasDecl; |
| 1171 | } | 1566 | } |
| 1172 | | 1567 | |
| 1173 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFromBytes *) { | 1568 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUndeclaredIdent *) { |
| 1174 | return IrInstructionIdFromBytes; | 1569 | return IrInstSrcIdUndeclaredIdent; |
| 1175 | } | 1570 | } |
| 1176 | | 1571 | |
| 1177 | static constexpr IrInstructionId ir_instruction_id(IrInstructionIntToFloat *) { | 1572 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAlloca *) { |
| 1178 | return IrInstructionIdIntToFloat; | 1573 | return IrInstSrcIdAlloca; |
| 1179 | } | 1574 | } |
| 1180 | | 1575 | |
| 1181 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFloatToInt *) { | 1576 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcEndExpr *) { |
| 1182 | return IrInstructionIdFloatToInt; | 1577 | return IrInstSrcIdEndExpr; |
| 1183 | } | 1578 | } |
| 1184 | | 1579 | |
| 1185 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBoolToInt *) { | 1580 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcUnionInitNamedField *) { |
| 1186 | return IrInstructionIdBoolToInt; | 1581 | return IrInstSrcIdUnionInitNamedField; |
| 1187 | } | 1582 | } |
| 1188 | | 1583 | |
| 1189 | static constexpr IrInstructionId ir_instruction_id(IrInstructionIntType *) { | 1584 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSuspendBegin *) { |
| 1190 | return IrInstructionIdIntType; | 1585 | return IrInstSrcIdSuspendBegin; |
| 1191 | } | 1586 | } |
| 1192 | | 1587 | |
| 1193 | static constexpr IrInstructionId ir_instruction_id(IrInstructionVectorType *) { | 1588 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSuspendFinish *) { |
| 1194 | return IrInstructionIdVectorType; | 1589 | return IrInstSrcIdSuspendFinish; |
| 1195 | } | 1590 | } |
| 1196 | | 1591 | |
| 1197 | static constexpr IrInstructionId ir_instruction_id(IrInstructionShuffleVector *) { | 1592 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcAwait *) { |
| 1198 | return IrInstructionIdShuffleVector; | 1593 | return IrInstSrcIdAwait; |
| 1199 | } | 1594 | } |
| 1200 | | 1595 | |
| 1201 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSplatSrc *) { | 1596 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcResume *) { |
| 1202 | return IrInstructionIdSplatSrc; | 1597 | return IrInstSrcIdResume; |
| 1203 | } | 1598 | } |
| 1204 | | 1599 | |
| 1205 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSplatGen *) { | 1600 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSpillBegin *) { |
| 1206 | return IrInstructionIdSplatGen; | 1601 | return IrInstSrcIdSpillBegin; |
| 1207 | } | 1602 | } |
| 1208 | | 1603 | |
| 1209 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBoolNot *) { | 1604 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcSpillEnd *) { |
| 1210 | return IrInstructionIdBoolNot; | 1605 | return IrInstSrcIdSpillEnd; |
| 1211 | } | 1606 | } |
| 1212 | | 1607 | |
| 1213 | static constexpr IrInstructionId ir_instruction_id(IrInstructionMemset *) { | 1608 | |
| 1214 | return IrInstructionIdMemset; | 1609 | static constexpr IrInstGenId ir_inst_id(IrInstGenDeclVar *) { |
| | 1610 | return IrInstGenIdDeclVar; |
| 1215 | } | 1611 | } |
| 1216 | | 1612 | |
| 1217 | static constexpr IrInstructionId ir_instruction_id(IrInstructionMemcpy *) { | 1613 | static constexpr IrInstGenId ir_inst_id(IrInstGenBr *) { |
| 1218 | return IrInstructionIdMemcpy; | 1614 | return IrInstGenIdBr; |
| 1219 | } | 1615 | } |
| 1220 | | 1616 | |
| 1221 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSliceSrc *) { | 1617 | static constexpr IrInstGenId ir_inst_id(IrInstGenCondBr *) { |
| 1222 | return IrInstructionIdSliceSrc; | 1618 | return IrInstGenIdCondBr; |
| 1223 | } | 1619 | } |
| 1224 | | 1620 | |
| 1225 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSliceGen *) { | 1621 | static constexpr IrInstGenId ir_inst_id(IrInstGenSwitchBr *) { |
| 1226 | return IrInstructionIdSliceGen; | 1622 | return IrInstGenIdSwitchBr; |
| 1227 | } | 1623 | } |
| 1228 | | 1624 | |
| 1229 | static constexpr IrInstructionId ir_instruction_id(IrInstructionMemberCount *) { | 1625 | static constexpr IrInstGenId ir_inst_id(IrInstGenPhi *) { |
| 1230 | return IrInstructionIdMemberCount; | 1626 | return IrInstGenIdPhi; |
| 1231 | } | 1627 | } |
| 1232 | | 1628 | |
| 1233 | static constexpr IrInstructionId ir_instruction_id(IrInstructionMemberType *) { | 1629 | static constexpr IrInstGenId ir_inst_id(IrInstGenBinaryNot *) { |
| 1234 | return IrInstructionIdMemberType; | 1630 | return IrInstGenIdBinaryNot; |
| 1235 | } | 1631 | } |
| 1236 | | 1632 | |
| 1237 | static constexpr IrInstructionId ir_instruction_id(IrInstructionMemberName *) { | 1633 | static constexpr IrInstGenId ir_inst_id(IrInstGenNegation *) { |
| 1238 | return IrInstructionIdMemberName; | 1634 | return IrInstGenIdNegation; |
| 1239 | } | 1635 | } |
| 1240 | | 1636 | |
| 1241 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBreakpoint *) { | 1637 | static constexpr IrInstGenId ir_inst_id(IrInstGenNegationWrapping *) { |
| 1242 | return IrInstructionIdBreakpoint; | 1638 | return IrInstGenIdNegationWrapping; |
| 1243 | } | 1639 | } |
| 1244 | | 1640 | |
| 1245 | static constexpr IrInstructionId ir_instruction_id(IrInstructionReturnAddress *) { | 1641 | static constexpr IrInstGenId ir_inst_id(IrInstGenBinOp *) { |
| 1246 | return IrInstructionIdReturnAddress; | 1642 | return IrInstGenIdBinOp; |
| 1247 | } | 1643 | } |
| 1248 | | 1644 | |
| 1249 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFrameAddress *) { | 1645 | static constexpr IrInstGenId ir_inst_id(IrInstGenLoadPtr *) { |
| 1250 | return IrInstructionIdFrameAddress; | 1646 | return IrInstGenIdLoadPtr; |
| 1251 | } | 1647 | } |
| 1252 | | 1648 | |
| 1253 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFrameHandle *) { | 1649 | static constexpr IrInstGenId ir_inst_id(IrInstGenStorePtr *) { |
| 1254 | return IrInstructionIdFrameHandle; | 1650 | return IrInstGenIdStorePtr; |
| 1255 | } | 1651 | } |
| 1256 | | 1652 | |
| 1257 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFrameType *) { | 1653 | static constexpr IrInstGenId ir_inst_id(IrInstGenVectorStoreElem *) { |
| 1258 | return IrInstructionIdFrameType; | 1654 | return IrInstGenIdVectorStoreElem; |
| 1259 | } | 1655 | } |
| 1260 | | 1656 | |
| 1261 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFrameSizeSrc *) { | 1657 | static constexpr IrInstGenId ir_inst_id(IrInstGenStructFieldPtr *) { |
| 1262 | return IrInstructionIdFrameSizeSrc; | 1658 | return IrInstGenIdStructFieldPtr; |
| 1263 | } | 1659 | } |
| 1264 | | 1660 | |
| 1265 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFrameSizeGen *) { | 1661 | static constexpr IrInstGenId ir_inst_id(IrInstGenUnionFieldPtr *) { |
| 1266 | return IrInstructionIdFrameSizeGen; | 1662 | return IrInstGenIdUnionFieldPtr; |
| 1267 | } | 1663 | } |
| 1268 | | 1664 | |
| 1269 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAlignOf *) { | 1665 | static constexpr IrInstGenId ir_inst_id(IrInstGenElemPtr *) { |
| 1270 | return IrInstructionIdAlignOf; | 1666 | return IrInstGenIdElemPtr; |
| 1271 | } | 1667 | } |
| 1272 | | 1668 | |
| 1273 | static constexpr IrInstructionId ir_instruction_id(IrInstructionOverflowOp *) { | 1669 | static constexpr IrInstGenId ir_inst_id(IrInstGenVarPtr *) { |
| 1274 | return IrInstructionIdOverflowOp; | 1670 | return IrInstGenIdVarPtr; |
| 1275 | } | 1671 | } |
| 1276 | | 1672 | |
| 1277 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTestErrSrc *) { | 1673 | static constexpr IrInstGenId ir_inst_id(IrInstGenReturnPtr *) { |
| 1278 | return IrInstructionIdTestErrSrc; | 1674 | return IrInstGenIdReturnPtr; |
| 1279 | } | 1675 | } |
| 1280 | | 1676 | |
| 1281 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTestErrGen *) { | 1677 | static constexpr IrInstGenId ir_inst_id(IrInstGenCall *) { |
| 1282 | return IrInstructionIdTestErrGen; | 1678 | return IrInstGenIdCall; |
| 1283 | } | 1679 | } |
| 1284 | | 1680 | |
| 1285 | static constexpr IrInstructionId ir_instruction_id(IrInstructionMulAdd *) { | 1681 | static constexpr IrInstGenId ir_inst_id(IrInstGenReturn *) { |
| 1286 | return IrInstructionIdMulAdd; | 1682 | return IrInstGenIdReturn; |
| 1287 | } | 1683 | } |
| 1288 | | 1684 | |
| 1289 | static constexpr IrInstructionId ir_instruction_id(IrInstructionUnwrapErrCode *) { | 1685 | static constexpr IrInstGenId ir_inst_id(IrInstGenCast *) { |
| 1290 | return IrInstructionIdUnwrapErrCode; | 1686 | return IrInstGenIdCast; |
| 1291 | } | 1687 | } |
| 1292 | | 1688 | |
| 1293 | static constexpr IrInstructionId ir_instruction_id(IrInstructionUnwrapErrPayload *) { | 1689 | static constexpr IrInstGenId ir_inst_id(IrInstGenResizeSlice *) { |
| 1294 | return IrInstructionIdUnwrapErrPayload; | 1690 | return IrInstGenIdResizeSlice; |
| 1295 | } | 1691 | } |
| 1296 | | 1692 | |
| 1297 | static constexpr IrInstructionId ir_instruction_id(IrInstructionOptionalWrap *) { | 1693 | static constexpr IrInstGenId ir_inst_id(IrInstGenUnreachable *) { |
| 1298 | return IrInstructionIdOptionalWrap; | 1694 | return IrInstGenIdUnreachable; |
| 1299 | } | 1695 | } |
| 1300 | | 1696 | |
| 1301 | static constexpr IrInstructionId ir_instruction_id(IrInstructionErrWrapPayload *) { | 1697 | static constexpr IrInstGenId ir_inst_id(IrInstGenAsm *) { |
| 1302 | return IrInstructionIdErrWrapPayload; | 1698 | return IrInstGenIdAsm; |
| 1303 | } | 1699 | } |
| 1304 | | 1700 | |
| 1305 | static constexpr IrInstructionId ir_instruction_id(IrInstructionErrWrapCode *) { | 1701 | static constexpr IrInstGenId ir_inst_id(IrInstGenTestNonNull *) { |
| 1306 | return IrInstructionIdErrWrapCode; | 1702 | return IrInstGenIdTestNonNull; |
| 1307 | } | 1703 | } |
| 1308 | | 1704 | |
| 1309 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFnProto *) { | 1705 | static constexpr IrInstGenId ir_inst_id(IrInstGenOptionalUnwrapPtr *) { |
| 1310 | return IrInstructionIdFnProto; | 1706 | return IrInstGenIdOptionalUnwrapPtr; |
| 1311 | } | 1707 | } |
| 1312 | | 1708 | |
| 1313 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTestComptime *) { | 1709 | static constexpr IrInstGenId ir_inst_id(IrInstGenOptionalWrap *) { |
| 1314 | return IrInstructionIdTestComptime; | 1710 | return IrInstGenIdOptionalWrap; |
| 1315 | } | 1711 | } |
| 1316 | | 1712 | |
| 1317 | static constexpr IrInstructionId ir_instruction_id(IrInstructionPtrCastSrc *) { | 1713 | static constexpr IrInstGenId ir_inst_id(IrInstGenUnionTag *) { |
| 1318 | return IrInstructionIdPtrCastSrc; | 1714 | return IrInstGenIdUnionTag; |
| 1319 | } | 1715 | } |
| 1320 | | 1716 | |
| 1321 | static constexpr IrInstructionId ir_instruction_id(IrInstructionPtrCastGen *) { | 1717 | static constexpr IrInstGenId ir_inst_id(IrInstGenClz *) { |
| 1322 | return IrInstructionIdPtrCastGen; | 1718 | return IrInstGenIdClz; |
| 1323 | } | 1719 | } |
| 1324 | | 1720 | |
| 1325 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBitCastSrc *) { | 1721 | static constexpr IrInstGenId ir_inst_id(IrInstGenCtz *) { |
| 1326 | return IrInstructionIdBitCastSrc; | 1722 | return IrInstGenIdCtz; |
| 1327 | } | 1723 | } |
| 1328 | | 1724 | |
| 1329 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBitCastGen *) { | 1725 | static constexpr IrInstGenId ir_inst_id(IrInstGenPopCount *) { |
| 1330 | return IrInstructionIdBitCastGen; | 1726 | return IrInstGenIdPopCount; |
| 1331 | } | 1727 | } |
| 1332 | | 1728 | |
| 1333 | static constexpr IrInstructionId ir_instruction_id(IrInstructionWidenOrShorten *) { | 1729 | static constexpr IrInstGenId ir_inst_id(IrInstGenBswap *) { |
| 1334 | return IrInstructionIdWidenOrShorten; | 1730 | return IrInstGenIdBswap; |
| 1335 | } | 1731 | } |
| 1336 | | 1732 | |
| 1337 | static constexpr IrInstructionId ir_instruction_id(IrInstructionPtrToInt *) { | 1733 | static constexpr IrInstGenId ir_inst_id(IrInstGenBitReverse *) { |
| 1338 | return IrInstructionIdPtrToInt; | 1734 | return IrInstGenIdBitReverse; |
| 1339 | } | 1735 | } |
| 1340 | | 1736 | |
| 1341 | static constexpr IrInstructionId ir_instruction_id(IrInstructionIntToPtr *) { | 1737 | static constexpr IrInstGenId ir_inst_id(IrInstGenRef *) { |
| 1342 | return IrInstructionIdIntToPtr; | 1738 | return IrInstGenIdRef; |
| 1343 | } | 1739 | } |
| 1344 | | 1740 | |
| 1345 | static constexpr IrInstructionId ir_instruction_id(IrInstructionIntToEnum *) { | 1741 | static constexpr IrInstGenId ir_inst_id(IrInstGenErrName *) { |
| 1346 | return IrInstructionIdIntToEnum; | 1742 | return IrInstGenIdErrName; |
| 1347 | } | 1743 | } |
| 1348 | | 1744 | |
| 1349 | static constexpr IrInstructionId ir_instruction_id(IrInstructionEnumToInt *) { | 1745 | static constexpr IrInstGenId ir_inst_id(IrInstGenCmpxchg *) { |
| 1350 | return IrInstructionIdEnumToInt; | 1746 | return IrInstGenIdCmpxchg; |
| 1351 | } | 1747 | } |
| 1352 | | 1748 | |
| 1353 | static constexpr IrInstructionId ir_instruction_id(IrInstructionIntToErr *) { | 1749 | static constexpr IrInstGenId ir_inst_id(IrInstGenFence *) { |
| 1354 | return IrInstructionIdIntToErr; | 1750 | return IrInstGenIdFence; |
| 1355 | } | 1751 | } |
| 1356 | | 1752 | |
| 1357 | static constexpr IrInstructionId ir_instruction_id(IrInstructionErrToInt *) { | 1753 | static constexpr IrInstGenId ir_inst_id(IrInstGenTruncate *) { |
| 1358 | return IrInstructionIdErrToInt; | 1754 | return IrInstGenIdTruncate; |
| 1359 | } | 1755 | } |
| 1360 | | 1756 | |
| 1361 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCheckSwitchProngs *) { | 1757 | static constexpr IrInstGenId ir_inst_id(IrInstGenShuffleVector *) { |
| 1362 | return IrInstructionIdCheckSwitchProngs; | 1758 | return IrInstGenIdShuffleVector; |
| 1363 | } | 1759 | } |
| 1364 | | 1760 | |
| 1365 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCheckStatementIsVoid *) { | 1761 | static constexpr IrInstGenId ir_inst_id(IrInstGenSplat *) { |
| 1366 | return IrInstructionIdCheckStatementIsVoid; | 1762 | return IrInstGenIdSplat; |
| 1367 | } | 1763 | } |
| 1368 | | 1764 | |
| 1369 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTypeName *) { | 1765 | static constexpr IrInstGenId ir_inst_id(IrInstGenBoolNot *) { |
| 1370 | return IrInstructionIdTypeName; | 1766 | return IrInstGenIdBoolNot; |
| 1371 | } | 1767 | } |
| 1372 | | 1768 | |
| 1373 | static constexpr IrInstructionId ir_instruction_id(IrInstructionDeclRef *) { | 1769 | static constexpr IrInstGenId ir_inst_id(IrInstGenMemset *) { |
| 1374 | return IrInstructionIdDeclRef; | 1770 | return IrInstGenIdMemset; |
| 1375 | } | 1771 | } |
| 1376 | | 1772 | |
| 1377 | static constexpr IrInstructionId ir_instruction_id(IrInstructionPanic *) { | 1773 | static constexpr IrInstGenId ir_inst_id(IrInstGenMemcpy *) { |
| 1378 | return IrInstructionIdPanic; | 1774 | return IrInstGenIdMemcpy; |
| 1379 | } | 1775 | } |
| 1380 | | 1776 | |
| 1381 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTagName *) { | 1777 | static constexpr IrInstGenId ir_inst_id(IrInstGenSlice *) { |
| 1382 | return IrInstructionIdTagName; | 1778 | return IrInstGenIdSlice; |
| 1383 | } | 1779 | } |
| 1384 | | 1780 | |
| 1385 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTagType *) { | 1781 | static constexpr IrInstGenId ir_inst_id(IrInstGenBreakpoint *) { |
| 1386 | return IrInstructionIdTagType; | 1782 | return IrInstGenIdBreakpoint; |
| 1387 | } | 1783 | } |
| 1388 | | 1784 | |
| 1389 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFieldParentPtr *) { | 1785 | static constexpr IrInstGenId ir_inst_id(IrInstGenReturnAddress *) { |
| 1390 | return IrInstructionIdFieldParentPtr; | 1786 | return IrInstGenIdReturnAddress; |
| 1391 | } | 1787 | } |
| 1392 | | 1788 | |
| 1393 | static constexpr IrInstructionId ir_instruction_id(IrInstructionByteOffsetOf *) { | 1789 | static constexpr IrInstGenId ir_inst_id(IrInstGenFrameAddress *) { |
| 1394 | return IrInstructionIdByteOffsetOf; | 1790 | return IrInstGenIdFrameAddress; |
| 1395 | } | 1791 | } |
| 1396 | | 1792 | |
| 1397 | static constexpr IrInstructionId ir_instruction_id(IrInstructionBitOffsetOf *) { | 1793 | static constexpr IrInstGenId ir_inst_id(IrInstGenFrameHandle *) { |
| 1398 | return IrInstructionIdBitOffsetOf; | 1794 | return IrInstGenIdFrameHandle; |
| 1399 | } | 1795 | } |
| 1400 | | 1796 | |
| 1401 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTypeInfo *) { | 1797 | static constexpr IrInstGenId ir_inst_id(IrInstGenFrameSize *) { |
| 1402 | return IrInstructionIdTypeInfo; | 1798 | return IrInstGenIdFrameSize; |
| 1403 | } | 1799 | } |
| 1404 | | 1800 | |
| 1405 | static constexpr IrInstructionId ir_instruction_id(IrInstructionType *) { | 1801 | static constexpr IrInstGenId ir_inst_id(IrInstGenOverflowOp *) { |
| 1406 | return IrInstructionIdType; | 1802 | return IrInstGenIdOverflowOp; |
| 1407 | } | 1803 | } |
| 1408 | | 1804 | |
| 1409 | static constexpr IrInstructionId ir_instruction_id(IrInstructionHasField *) { | 1805 | static constexpr IrInstGenId ir_inst_id(IrInstGenTestErr *) { |
| 1410 | return IrInstructionIdHasField; | 1806 | return IrInstGenIdTestErr; |
| 1411 | } | 1807 | } |
| 1412 | | 1808 | |
| 1413 | static constexpr IrInstructionId ir_instruction_id(IrInstructionTypeId *) { | 1809 | static constexpr IrInstGenId ir_inst_id(IrInstGenMulAdd *) { |
| 1414 | return IrInstructionIdTypeId; | 1810 | return IrInstGenIdMulAdd; |
| 1415 | } | 1811 | } |
| 1416 | | 1812 | |
| 1417 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSetEvalBranchQuota *) { | 1813 | static constexpr IrInstGenId ir_inst_id(IrInstGenFloatOp *) { |
| 1418 | return IrInstructionIdSetEvalBranchQuota; | 1814 | return IrInstGenIdFloatOp; |
| 1419 | } | 1815 | } |
| 1420 | | 1816 | |
| 1421 | static constexpr IrInstructionId ir_instruction_id(IrInstructionPtrType *) { | 1817 | static constexpr IrInstGenId ir_inst_id(IrInstGenUnwrapErrCode *) { |
| 1422 | return IrInstructionIdPtrType; | 1818 | return IrInstGenIdUnwrapErrCode; |
| 1423 | } | 1819 | } |
| 1424 | | 1820 | |
| 1425 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAlignCast *) { | 1821 | static constexpr IrInstGenId ir_inst_id(IrInstGenUnwrapErrPayload *) { |
| 1426 | return IrInstructionIdAlignCast; | 1822 | return IrInstGenIdUnwrapErrPayload; |
| 1427 | } | 1823 | } |
| 1428 | | 1824 | |
| 1429 | static constexpr IrInstructionId ir_instruction_id(IrInstructionImplicitCast *) { | 1825 | static constexpr IrInstGenId ir_inst_id(IrInstGenErrWrapCode *) { |
| 1430 | return IrInstructionIdImplicitCast; | 1826 | return IrInstGenIdErrWrapCode; |
| 1431 | } | 1827 | } |
| 1432 | | 1828 | |
| 1433 | static constexpr IrInstructionId ir_instruction_id(IrInstructionResolveResult *) { | 1829 | static constexpr IrInstGenId ir_inst_id(IrInstGenErrWrapPayload *) { |
| 1434 | return IrInstructionIdResolveResult; | 1830 | return IrInstGenIdErrWrapPayload; |
| 1435 | } | 1831 | } |
| 1436 | | 1832 | |
| 1437 | static constexpr IrInstructionId ir_instruction_id(IrInstructionResetResult *) { | 1833 | static constexpr IrInstGenId ir_inst_id(IrInstGenPtrCast *) { |
| 1438 | return IrInstructionIdResetResult; | 1834 | return IrInstGenIdPtrCast; |
| 1439 | } | 1835 | } |
| 1440 | | 1836 | |
| 1441 | static constexpr IrInstructionId ir_instruction_id(IrInstructionPtrOfArrayToSlice *) { | 1837 | static constexpr IrInstGenId ir_inst_id(IrInstGenBitCast *) { |
| 1442 | return IrInstructionIdPtrOfArrayToSlice; | 1838 | return IrInstGenIdBitCast; |
| 1443 | } | 1839 | } |
| 1444 | | 1840 | |
| 1445 | static constexpr IrInstructionId ir_instruction_id(IrInstructionOpaqueType *) { | 1841 | static constexpr IrInstGenId ir_inst_id(IrInstGenWidenOrShorten *) { |
| 1446 | return IrInstructionIdOpaqueType; | 1842 | return IrInstGenIdWidenOrShorten; |
| 1447 | } | 1843 | } |
| 1448 | | 1844 | |
| 1449 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSetAlignStack *) { | 1845 | static constexpr IrInstGenId ir_inst_id(IrInstGenIntToPtr *) { |
| 1450 | return IrInstructionIdSetAlignStack; | 1846 | return IrInstGenIdIntToPtr; |
| 1451 | } | 1847 | } |
| 1452 | | 1848 | |
| 1453 | static constexpr IrInstructionId ir_instruction_id(IrInstructionArgType *) { | 1849 | static constexpr IrInstGenId ir_inst_id(IrInstGenPtrToInt *) { |
| 1454 | return IrInstructionIdArgType; | 1850 | return IrInstGenIdPtrToInt; |
| 1455 | } | 1851 | } |
| 1456 | | 1852 | |
| 1457 | static constexpr IrInstructionId ir_instruction_id(IrInstructionErrorReturnTrace *) { | 1853 | static constexpr IrInstGenId ir_inst_id(IrInstGenIntToEnum *) { |
| 1458 | return IrInstructionIdErrorReturnTrace; | 1854 | return IrInstGenIdIntToEnum; |
| 1459 | } | 1855 | } |
| 1460 | | 1856 | |
| 1461 | static constexpr IrInstructionId ir_instruction_id(IrInstructionErrorUnion *) { | 1857 | static constexpr IrInstGenId ir_inst_id(IrInstGenIntToErr *) { |
| 1462 | return IrInstructionIdErrorUnion; | 1858 | return IrInstGenIdIntToErr; |
| 1463 | } | 1859 | } |
| 1464 | | 1860 | |
| 1465 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAtomicRmw *) { | 1861 | static constexpr IrInstGenId ir_inst_id(IrInstGenErrToInt *) { |
| 1466 | return IrInstructionIdAtomicRmw; | 1862 | return IrInstGenIdErrToInt; |
| 1467 | } | 1863 | } |
| 1468 | | 1864 | |
| 1469 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAtomicLoad *) { | 1865 | static constexpr IrInstGenId ir_inst_id(IrInstGenPanic *) { |
| 1470 | return IrInstructionIdAtomicLoad; | 1866 | return IrInstGenIdPanic; |
| 1471 | } | 1867 | } |
| 1472 | | 1868 | |
| 1473 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAtomicStore *) { | 1869 | static constexpr IrInstGenId ir_inst_id(IrInstGenTagName *) { |
| 1474 | return IrInstructionIdAtomicStore; | 1870 | return IrInstGenIdTagName; |
| 1475 | } | 1871 | } |
| 1476 | | 1872 | |
| 1477 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSaveErrRetAddr *) { | 1873 | static constexpr IrInstGenId ir_inst_id(IrInstGenFieldParentPtr *) { |
| 1478 | return IrInstructionIdSaveErrRetAddr; | 1874 | return IrInstGenIdFieldParentPtr; |
| 1479 | } | 1875 | } |
| 1480 | | 1876 | |
| 1481 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAddImplicitReturnType *) { | 1877 | static constexpr IrInstGenId ir_inst_id(IrInstGenAlignCast *) { |
| 1482 | return IrInstructionIdAddImplicitReturnType; | 1878 | return IrInstGenIdAlignCast; |
| 1483 | } | 1879 | } |
| 1484 | | 1880 | |
| 1485 | static constexpr IrInstructionId ir_instruction_id(IrInstructionFloatOp *) { | 1881 | static constexpr IrInstGenId ir_inst_id(IrInstGenErrorReturnTrace *) { |
| 1486 | return IrInstructionIdFloatOp; | 1882 | return IrInstGenIdErrorReturnTrace; |
| 1487 | } | 1883 | } |
| 1488 | | 1884 | |
| 1489 | static constexpr IrInstructionId ir_instruction_id(IrInstructionCheckRuntimeScope *) { | 1885 | static constexpr IrInstGenId ir_inst_id(IrInstGenAtomicRmw *) { |
| 1490 | return IrInstructionIdCheckRuntimeScope; | 1886 | return IrInstGenIdAtomicRmw; |
| 1491 | } | 1887 | } |
| 1492 | | 1888 | |
| 1493 | static constexpr IrInstructionId ir_instruction_id(IrInstructionVectorToArray *) { | 1889 | static constexpr IrInstGenId ir_inst_id(IrInstGenAtomicLoad *) { |
| 1494 | return IrInstructionIdVectorToArray; | 1890 | return IrInstGenIdAtomicLoad; |
| 1495 | } | 1891 | } |
| 1496 | | 1892 | |
| 1497 | static constexpr IrInstructionId ir_instruction_id(IrInstructionArrayToVector *) { | 1893 | static constexpr IrInstGenId ir_inst_id(IrInstGenAtomicStore *) { |
| 1498 | return IrInstructionIdArrayToVector; | 1894 | return IrInstGenIdAtomicStore; |
| 1499 | } | 1895 | } |
| 1500 | | 1896 | |
| 1501 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAssertZero *) { | 1897 | static constexpr IrInstGenId ir_inst_id(IrInstGenSaveErrRetAddr *) { |
| 1502 | return IrInstructionIdAssertZero; | 1898 | return IrInstGenIdSaveErrRetAddr; |
| 1503 | } | 1899 | } |
| 1504 | | 1900 | |
| 1505 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAssertNonNull *) { | 1901 | static constexpr IrInstGenId ir_inst_id(IrInstGenVectorToArray *) { |
| 1506 | return IrInstructionIdAssertNonNull; | 1902 | return IrInstGenIdVectorToArray; |
| 1507 | } | 1903 | } |
| 1508 | | 1904 | |
| 1509 | static constexpr IrInstructionId ir_instruction_id(IrInstructionHasDecl *) { | 1905 | static constexpr IrInstGenId ir_inst_id(IrInstGenArrayToVector *) { |
| 1510 | return IrInstructionIdHasDecl; | 1906 | return IrInstGenIdArrayToVector; |
| 1511 | } | 1907 | } |
| 1512 | | 1908 | |
| 1513 | static constexpr IrInstructionId ir_instruction_id(IrInstructionUndeclaredIdent *) { | 1909 | static constexpr IrInstGenId ir_inst_id(IrInstGenAssertZero *) { |
| 1514 | return IrInstructionIdUndeclaredIdent; | 1910 | return IrInstGenIdAssertZero; |
| 1515 | } | 1911 | } |
| 1516 | | 1912 | |
| 1517 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAllocaSrc *) { | 1913 | static constexpr IrInstGenId ir_inst_id(IrInstGenAssertNonNull *) { |
| 1518 | return IrInstructionIdAllocaSrc; | 1914 | return IrInstGenIdAssertNonNull; |
| 1519 | } | 1915 | } |
| 1520 | | 1916 | |
| 1521 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAllocaGen *) { | 1917 | static constexpr IrInstGenId ir_inst_id(IrInstGenPtrOfArrayToSlice *) { |
| 1522 | return IrInstructionIdAllocaGen; | 1918 | return IrInstGenIdPtrOfArrayToSlice; |
| 1523 | } | 1919 | } |
| 1524 | | 1920 | |
| 1525 | static constexpr IrInstructionId ir_instruction_id(IrInstructionEndExpr *) { | 1921 | static constexpr IrInstGenId ir_inst_id(IrInstGenSuspendBegin *) { |
| 1526 | return IrInstructionIdEndExpr; | 1922 | return IrInstGenIdSuspendBegin; |
| 1527 | } | 1923 | } |
| 1528 | | 1924 | |
| 1529 | static constexpr IrInstructionId ir_instruction_id(IrInstructionUnionInitNamedField *) { | 1925 | static constexpr IrInstGenId ir_inst_id(IrInstGenSuspendFinish *) { |
| 1530 | return IrInstructionIdUnionInitNamedField; | 1926 | return IrInstGenIdSuspendFinish; |
| 1531 | } | 1927 | } |
| 1532 | | 1928 | |
| 1533 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSuspendBegin *) { | 1929 | static constexpr IrInstGenId ir_inst_id(IrInstGenAwait *) { |
| 1534 | return IrInstructionIdSuspendBegin; | 1930 | return IrInstGenIdAwait; |
| 1535 | } | 1931 | } |
| 1536 | | 1932 | |
| 1537 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSuspendFinish *) { | 1933 | static constexpr IrInstGenId ir_inst_id(IrInstGenResume *) { |
| 1538 | return IrInstructionIdSuspendFinish; | 1934 | return IrInstGenIdResume; |
| 1539 | } | 1935 | } |
| 1540 | | 1936 | |
| 1541 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAwaitSrc *) { | 1937 | static constexpr IrInstGenId ir_inst_id(IrInstGenSpillBegin *) { |
| 1542 | return IrInstructionIdAwaitSrc; | 1938 | return IrInstGenIdSpillBegin; |
| 1543 | } | 1939 | } |
| 1544 | | 1940 | |
| 1545 | static constexpr IrInstructionId ir_instruction_id(IrInstructionAwaitGen *) { | 1941 | static constexpr IrInstGenId ir_inst_id(IrInstGenSpillEnd *) { |
| 1546 | return IrInstructionIdAwaitGen; | 1942 | return IrInstGenIdSpillEnd; |
| 1547 | } | 1943 | } |
| 1548 | | 1944 | |
| 1549 | static constexpr IrInstructionId ir_instruction_id(IrInstructionResume *) { | 1945 | static constexpr IrInstGenId ir_inst_id(IrInstGenVectorExtractElem *) { |
| 1550 | return IrInstructionIdResume; | 1946 | return IrInstGenIdVectorExtractElem; |
| 1551 | } | 1947 | } |
| 1552 | | 1948 | |
| 1553 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSpillBegin *) { | 1949 | static constexpr IrInstGenId ir_inst_id(IrInstGenAlloca *) { |
| 1554 | return IrInstructionIdSpillBegin; | 1950 | return IrInstGenIdAlloca; |
| 1555 | } | 1951 | } |
| 1556 | | 1952 | |
| 1557 | static constexpr IrInstructionId ir_instruction_id(IrInstructionSpillEnd *) { | 1953 | static constexpr IrInstGenId ir_inst_id(IrInstGenConst *) { |
| 1558 | return IrInstructionIdSpillEnd; | 1954 | return IrInstGenIdConst; |
| 1559 | } | 1955 | } |
| 1560 | | 1956 | |
| 1561 | static constexpr IrInstructionId ir_instruction_id(IrInstructionVectorExtractElem *) { | 1957 | template<typename T> |
| 1562 | return IrInstructionIdVectorExtractElem; | 1958 | static T *ir_create_instruction(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| | 1959 | const char *name = nullptr; |
| | 1960 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| | 1961 | T *dummy = nullptr; |
| | 1962 | name = ir_inst_src_type_str(ir_inst_id(dummy)); |
| | 1963 | #endif |
| | 1964 | T *special_instruction = allocate<T>(1, name); |
| | 1965 | special_instruction->base.id = ir_inst_id(special_instruction); |
| | 1966 | special_instruction->base.base.scope = scope; |
| | 1967 | special_instruction->base.base.source_node = source_node; |
| | 1968 | special_instruction->base.base.debug_id = exec_next_debug_id(irb->exec); |
| | 1969 | special_instruction->base.owner_bb = irb->current_basic_block; |
| | 1970 | return special_instruction; |
| 1563 | } | 1971 | } |
| 1564 | | 1972 | |
| 1565 | template<typename T> | 1973 | template<typename T> |
| 1566 | static T *ir_create_instruction(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 1974 | static T *ir_create_inst_gen(IrBuilderGen *irb, Scope *scope, AstNode *source_node) { |
| 1567 | const char *name = nullptr; | 1975 | const char *name = nullptr; |
| 1568 | #ifdef ZIG_ENABLE_MEM_PROFILE | 1976 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| 1569 | T *dummy = nullptr; | 1977 | T *dummy = nullptr; |
| 1570 | name = ir_instruction_type_str(ir_instruction_id(dummy)); | 1978 | name = ir_inst_gen_type_str(ir_inst_id(dummy)); |
| 1571 | #endif | 1979 | #endif |
| 1572 | T *special_instruction = allocate<T>(1, name); | 1980 | T *special_instruction = allocate<T>(1, name); |
| 1573 | special_instruction->base.id = ir_instruction_id(special_instruction); | 1981 | special_instruction->base.id = ir_inst_id(special_instruction); |
| 1574 | special_instruction->base.scope = scope; | 1982 | special_instruction->base.base.scope = scope; |
| 1575 | special_instruction->base.source_node = source_node; | 1983 | special_instruction->base.base.source_node = source_node; |
| 1576 | special_instruction->base.debug_id = exec_next_debug_id(irb->exec); | 1984 | special_instruction->base.base.debug_id = exec_next_debug_id_gen(irb->exec); |
| 1577 | special_instruction->base.owner_bb = irb->current_basic_block; | 1985 | special_instruction->base.owner_bb = irb->current_basic_block; |
| 1578 | special_instruction->base.value = allocate<ZigValue>(1, "ZigValue"); | 1986 | special_instruction->base.value = allocate<ZigValue>(1, "ZigValue"); |
| 1579 | return special_instruction; | 1987 | return special_instruction; |
| 1580 | } | 1988 | } |
| 1581 | | 1989 | |
| 1582 | template<typename T> | 1990 | template<typename T> |
| 1583 | static T *ir_create_instruction_noval(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 1991 | static T *ir_create_inst_noval(IrBuilderGen *irb, Scope *scope, AstNode *source_node) { |
| 1584 | const char *name = nullptr; | 1992 | const char *name = nullptr; |
| 1585 | #ifdef ZIG_ENABLE_MEM_PROFILE | 1993 | #ifdef ZIG_ENABLE_MEM_PROFILE |
| 1586 | T *dummy = nullptr; | 1994 | T *dummy = nullptr; |
| 1587 | name = ir_instruction_type_str(ir_instruction_id(dummy)); | 1995 | name = ir_inst_gen_type_str(ir_inst_id(dummy)); |
| 1588 | #endif | 1996 | #endif |
| 1589 | T *special_instruction = allocate<T>(1, name); | 1997 | T *special_instruction = allocate<T>(1, name); |
| 1590 | special_instruction->base.id = ir_instruction_id(special_instruction); | 1998 | special_instruction->base.id = ir_inst_id(special_instruction); |
| 1591 | special_instruction->base.scope = scope; | 1999 | special_instruction->base.base.scope = scope; |
| 1592 | special_instruction->base.source_node = source_node; | 2000 | special_instruction->base.base.source_node = source_node; |
| 1593 | special_instruction->base.debug_id = exec_next_debug_id(irb->exec); | 2001 | special_instruction->base.base.debug_id = exec_next_debug_id_gen(irb->exec); |
| 1594 | special_instruction->base.owner_bb = irb->current_basic_block; | 2002 | special_instruction->base.owner_bb = irb->current_basic_block; |
| 1595 | return special_instruction; | 2003 | return special_instruction; |
| 1596 | } | 2004 | } |
| 1597 | | 2005 | |
| 1598 | template<typename T> | 2006 | template<typename T> |
| 1599 | static T *ir_build_instruction(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 2007 | static T *ir_build_instruction(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 1600 | T *special_instruction = ir_create_instruction<T>(irb, scope, source_node); | 2008 | T *special_instruction = ir_create_instruction<T>(irb, scope, source_node); |
| 1601 | ir_instruction_append(irb->current_basic_block, &special_instruction->base); | 2009 | ir_instruction_append(irb->current_basic_block, &special_instruction->base); |
| 1602 | return special_instruction; | 2010 | return special_instruction; |
| 1603 | } | 2011 | } |
| 1604 | | 2012 | |
| 1605 | static IrInstruction *ir_build_cast(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigType *dest_type, | 2013 | template<typename T> |
| 1606 | IrInstruction *value, CastOp cast_op) | 2014 | static T *ir_build_inst_gen(IrBuilderGen *irb, Scope *scope, AstNode *source_node) { |
| | 2015 | T *special_instruction = ir_create_inst_gen<T>(irb, scope, source_node); |
| | 2016 | ir_inst_gen_append(irb->current_basic_block, &special_instruction->base); |
| | 2017 | return special_instruction; |
| | 2018 | } |
| | 2019 | |
| | 2020 | template<typename T> |
| | 2021 | static T *ir_build_inst_noreturn(IrBuilderGen *irb, Scope *scope, AstNode *source_node) { |
| | 2022 | T *special_instruction = ir_create_inst_noval<T>(irb, scope, source_node); |
| | 2023 | special_instruction->base.value = irb->codegen->intern.for_unreachable(); |
| | 2024 | ir_inst_gen_append(irb->current_basic_block, &special_instruction->base); |
| | 2025 | return special_instruction; |
| | 2026 | } |
| | 2027 | |
| | 2028 | template<typename T> |
| | 2029 | static T *ir_build_inst_void(IrBuilderGen *irb, Scope *scope, AstNode *source_node) { |
| | 2030 | T *special_instruction = ir_create_inst_noval<T>(irb, scope, source_node); |
| | 2031 | special_instruction->base.value = irb->codegen->intern.for_void(); |
| | 2032 | ir_inst_gen_append(irb->current_basic_block, &special_instruction->base); |
| | 2033 | return special_instruction; |
| | 2034 | } |
| | 2035 | |
| | 2036 | IrInstGen *ir_create_alloca(CodeGen *g, Scope *scope, AstNode *source_node, ZigFn *fn, |
| | 2037 | ZigType *var_type, const char *name_hint) |
| 1607 | { | 2038 | { |
| 1608 | IrInstructionCast *cast_instruction = ir_build_instruction<IrInstructionCast>(irb, scope, source_node); | 2039 | IrInstGenAlloca *alloca_gen = allocate<IrInstGenAlloca>(1); |
| 1609 | cast_instruction->dest_type = dest_type; | 2040 | alloca_gen->base.id = IrInstGenIdAlloca; |
| 1610 | cast_instruction->value = value; | 2041 | alloca_gen->base.base.source_node = source_node; |
| 1611 | cast_instruction->cast_op = cast_op; | 2042 | alloca_gen->base.base.scope = scope; |
| | 2043 | alloca_gen->base.value = allocate<ZigValue>(1, "ZigValue"); |
| | 2044 | alloca_gen->base.value->type = get_pointer_to_type(g, var_type, false); |
| | 2045 | alloca_gen->base.base.ref_count = 1; |
| | 2046 | alloca_gen->name_hint = name_hint; |
| | 2047 | fn->alloca_gen_list.append(alloca_gen); |
| | 2048 | return &alloca_gen->base; |
| | 2049 | } |
| 1612 | | 2050 | |
| 1613 | ir_ref_instruction(value, irb->current_basic_block); | 2051 | static IrInstGen *ir_build_cast(IrAnalyze *ira, IrInst *source_instr,ZigType *dest_type, |
| | 2052 | IrInstGen *value, CastOp cast_op) |
| | 2053 | { |
| | 2054 | IrInstGenCast *inst = ir_build_inst_gen<IrInstGenCast>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| | 2055 | inst->base.value->type = dest_type; |
| | 2056 | inst->value = value; |
| | 2057 | inst->cast_op = cast_op; |
| 1614 | | 2058 | |
| 1615 | return &cast_instruction->base; | 2059 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| | 2060 | |
| | 2061 | return &inst->base; |
| 1616 | } | 2062 | } |
| 1617 | | 2063 | |
| 1618 | static IrInstruction *ir_build_cond_br(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *condition, | 2064 | static IrInstSrc *ir_build_cond_br(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *condition, |
| 1619 | IrBasicBlock *then_block, IrBasicBlock *else_block, IrInstruction *is_comptime) | 2065 | IrBasicBlockSrc *then_block, IrBasicBlockSrc *else_block, IrInstSrc *is_comptime) |
| 1620 | { | 2066 | { |
| 1621 | IrInstructionCondBr *cond_br_instruction = ir_build_instruction<IrInstructionCondBr>(irb, scope, source_node); | 2067 | IrInstSrcCondBr *inst = ir_build_instruction<IrInstSrcCondBr>(irb, scope, source_node); |
| 1622 | cond_br_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; | 2068 | inst->base.is_noreturn = true; |
| 1623 | cond_br_instruction->base.value->special = ConstValSpecialStatic; | 2069 | inst->condition = condition; |
| 1624 | cond_br_instruction->condition = condition; | 2070 | inst->then_block = then_block; |
| 1625 | cond_br_instruction->then_block = then_block; | 2071 | inst->else_block = else_block; |
| 1626 | cond_br_instruction->else_block = else_block; | 2072 | inst->is_comptime = is_comptime; |
| 1627 | cond_br_instruction->is_comptime = is_comptime; | | |
| 1628 | | 2073 | |
| 1629 | ir_ref_instruction(condition, irb->current_basic_block); | 2074 | ir_ref_instruction(condition, irb->current_basic_block); |
| 1630 | ir_ref_bb(then_block); | 2075 | ir_ref_bb(then_block); |
| 1631 | ir_ref_bb(else_block); | 2076 | ir_ref_bb(else_block); |
| 1632 | if (is_comptime != nullptr) ir_ref_instruction(is_comptime, irb->current_basic_block); | 2077 | if (is_comptime != nullptr) ir_ref_instruction(is_comptime, irb->current_basic_block); |
| 1633 | | 2078 | |
| 1634 | return &cond_br_instruction->base; | 2079 | return &inst->base; |
| 1635 | } | 2080 | } |
| 1636 | | 2081 | |
| 1637 | static IrInstruction *ir_build_return(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2082 | static IrInstGen *ir_build_cond_br_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *condition, |
| 1638 | IrInstruction *operand) | 2083 | IrBasicBlockGen *then_block, IrBasicBlockGen *else_block) |
| 1639 | { | 2084 | { |
| 1640 | IrInstructionReturn *return_instruction = ir_build_instruction<IrInstructionReturn>(irb, scope, source_node); | 2085 | IrInstGenCondBr *inst = ir_build_inst_noreturn<IrInstGenCondBr>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| 1641 | return_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; | 2086 | inst->condition = condition; |
| 1642 | return_instruction->base.value->special = ConstValSpecialStatic; | 2087 | inst->then_block = then_block; |
| 1643 | return_instruction->operand = operand; | 2088 | inst->else_block = else_block; |
| | 2089 | |
| | 2090 | ir_ref_inst_gen(condition, ira->new_irb.current_basic_block); |
| | 2091 | ir_ref_bb_gen(then_block); |
| | 2092 | ir_ref_bb_gen(else_block); |
| | 2093 | |
| | 2094 | return &inst->base; |
| | 2095 | } |
| | 2096 | |
| | 2097 | static IrInstSrc *ir_build_return_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *operand) { |
| | 2098 | IrInstSrcReturn *inst = ir_build_instruction<IrInstSrcReturn>(irb, scope, source_node); |
| | 2099 | inst->base.is_noreturn = true; |
| | 2100 | inst->operand = operand; |
| 1644 | | 2101 | |
| 1645 | if (operand != nullptr) ir_ref_instruction(operand, irb->current_basic_block); | 2102 | if (operand != nullptr) ir_ref_instruction(operand, irb->current_basic_block); |
| 1646 | | 2103 | |
| 1647 | return &return_instruction->base; | 2104 | return &inst->base; |
| | 2105 | } |
| | 2106 | |
| | 2107 | static IrInstGen *ir_build_return_gen(IrAnalyze *ira, IrInst *source_inst, IrInstGen *operand) { |
| | 2108 | IrInstGenReturn *inst = ir_build_inst_noreturn<IrInstGenReturn>(&ira->new_irb, |
| | 2109 | source_inst->scope, source_inst->source_node); |
| | 2110 | inst->operand = operand; |
| | 2111 | |
| | 2112 | if (operand != nullptr) ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| | 2113 | |
| | 2114 | return &inst->base; |
| 1648 | } | 2115 | } |
| 1649 | | 2116 | |
| 1650 | static IrInstruction *ir_build_const_void(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 2117 | static IrInstSrc *ir_build_const_void(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 1651 | IrInstructionConst *const_instruction = ir_create_instruction_noval<IrInstructionConst>(irb, scope, source_node); | 2118 | IrInstSrcConst *const_instruction = ir_create_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1652 | ir_instruction_append(irb->current_basic_block, &const_instruction->base); | 2119 | ir_instruction_append(irb->current_basic_block, &const_instruction->base); |
| 1653 | const_instruction->base.value = irb->codegen->intern.for_void(); | 2120 | const_instruction->value = irb->codegen->intern.for_void(); |
| 1654 | return &const_instruction->base; | 2121 | return &const_instruction->base; |
| 1655 | } | 2122 | } |
| 1656 | | 2123 | |
| 1657 | static IrInstruction *ir_build_const_undefined(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 2124 | static IrInstSrc *ir_build_const_undefined(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 1658 | IrInstructionConst *const_instruction = ir_create_instruction_noval<IrInstructionConst>(irb, scope, source_node); | 2125 | IrInstSrcConst *const_instruction = ir_create_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1659 | ir_instruction_append(irb->current_basic_block, &const_instruction->base); | 2126 | ir_instruction_append(irb->current_basic_block, &const_instruction->base); |
| 1660 | const_instruction->base.value = irb->codegen->intern.for_undefined(); | 2127 | const_instruction->value = irb->codegen->intern.for_undefined(); |
| 1661 | return &const_instruction->base; | 2128 | return &const_instruction->base; |
| 1662 | } | 2129 | } |
| 1663 | | 2130 | |
| 1664 | static IrInstruction *ir_build_const_uint(IrBuilder *irb, Scope *scope, AstNode *source_node, uint64_t value) { | 2131 | static IrInstSrc *ir_build_const_uint(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, uint64_t value) { |
| 1665 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 2132 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1666 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_num_lit_int; | 2133 | const_instruction->value = create_const_vals(1); |
| 1667 | const_instruction->base.value->special = ConstValSpecialStatic; | 2134 | const_instruction->value->type = irb->codegen->builtin_types.entry_num_lit_int; |
| 1668 | bigint_init_unsigned(&const_instruction->base.value->data.x_bigint, value); | 2135 | const_instruction->value->special = ConstValSpecialStatic; |
| | 2136 | bigint_init_unsigned(&const_instruction->value->data.x_bigint, value); |
| 1669 | return &const_instruction->base; | 2137 | return &const_instruction->base; |
| 1670 | } | 2138 | } |
| 1671 | | 2139 | |
| 1672 | static IrInstruction *ir_build_const_bigint(IrBuilder *irb, Scope *scope, AstNode *source_node, BigInt *bigint) { | 2140 | static IrInstSrc *ir_build_const_bigint(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, BigInt *bigint) { |
| 1673 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 2141 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1674 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_num_lit_int; | 2142 | const_instruction->value = create_const_vals(1); |
| 1675 | const_instruction->base.value->special = ConstValSpecialStatic; | 2143 | const_instruction->value->type = irb->codegen->builtin_types.entry_num_lit_int; |
| 1676 | bigint_init_bigint(&const_instruction->base.value->data.x_bigint, bigint); | 2144 | const_instruction->value->special = ConstValSpecialStatic; |
| | 2145 | bigint_init_bigint(&const_instruction->value->data.x_bigint, bigint); |
| 1677 | return &const_instruction->base; | 2146 | return &const_instruction->base; |
| 1678 | } | 2147 | } |
| 1679 | | 2148 | |
| 1680 | static IrInstruction *ir_build_const_bigfloat(IrBuilder *irb, Scope *scope, AstNode *source_node, BigFloat *bigfloat) { | 2149 | static IrInstSrc *ir_build_const_bigfloat(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, BigFloat *bigfloat) { |
| 1681 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 2150 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1682 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_num_lit_float; | 2151 | const_instruction->value = create_const_vals(1); |
| 1683 | const_instruction->base.value->special = ConstValSpecialStatic; | 2152 | const_instruction->value->type = irb->codegen->builtin_types.entry_num_lit_float; |
| 1684 | bigfloat_init_bigfloat(&const_instruction->base.value->data.x_bigfloat, bigfloat); | 2153 | const_instruction->value->special = ConstValSpecialStatic; |
| | 2154 | bigfloat_init_bigfloat(&const_instruction->value->data.x_bigfloat, bigfloat); |
| 1685 | return &const_instruction->base; | 2155 | return &const_instruction->base; |
| 1686 | } | 2156 | } |
| 1687 | | 2157 | |
| 1688 | static IrInstruction *ir_build_const_null(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 2158 | static IrInstSrc *ir_build_const_null(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 1689 | IrInstructionConst *const_instruction = ir_create_instruction_noval<IrInstructionConst>(irb, scope, source_node); | 2159 | IrInstSrcConst *const_instruction = ir_create_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1690 | ir_instruction_append(irb->current_basic_block, &const_instruction->base); | 2160 | ir_instruction_append(irb->current_basic_block, &const_instruction->base); |
| 1691 | const_instruction->base.value = irb->codegen->intern.for_null(); | 2161 | const_instruction->value = irb->codegen->intern.for_null(); |
| 1692 | return &const_instruction->base; | 2162 | return &const_instruction->base; |
| 1693 | } | 2163 | } |
| 1694 | | 2164 | |
| 1695 | static IrInstruction *ir_build_const_usize(IrBuilder *irb, Scope *scope, AstNode *source_node, uint64_t value) { | 2165 | static IrInstSrc *ir_build_const_usize(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, uint64_t value) { |
| 1696 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 2166 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1697 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_usize; | 2167 | const_instruction->value = create_const_vals(1); |
| 1698 | const_instruction->base.value->special = ConstValSpecialStatic; | 2168 | const_instruction->value->type = irb->codegen->builtin_types.entry_usize; |
| 1699 | bigint_init_unsigned(&const_instruction->base.value->data.x_bigint, value); | 2169 | const_instruction->value->special = ConstValSpecialStatic; |
| | 2170 | bigint_init_unsigned(&const_instruction->value->data.x_bigint, value); |
| 1700 | return &const_instruction->base; | 2171 | return &const_instruction->base; |
| 1701 | } | 2172 | } |
| 1702 | | 2173 | |
| 1703 | static IrInstruction *ir_create_const_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2174 | static IrInstSrc *ir_create_const_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1704 | ZigType *type_entry) | 2175 | ZigType *type_entry) |
| 1705 | { | 2176 | { |
| 1706 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); | 2177 | IrInstSrcConst *const_instruction = ir_create_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1707 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_type; | 2178 | const_instruction->value = create_const_vals(1); |
| 1708 | const_instruction->base.value->special = ConstValSpecialStatic; | 2179 | const_instruction->value->type = irb->codegen->builtin_types.entry_type; |
| 1709 | const_instruction->base.value->data.x_type = type_entry; | 2180 | const_instruction->value->special = ConstValSpecialStatic; |
| | 2181 | const_instruction->value->data.x_type = type_entry; |
| 1710 | return &const_instruction->base; | 2182 | return &const_instruction->base; |
| 1711 | } | 2183 | } |
| 1712 | | 2184 | |
| 1713 | static IrInstruction *ir_build_const_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2185 | static IrInstSrc *ir_build_const_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1714 | ZigType *type_entry) | 2186 | ZigType *type_entry) |
| 1715 | { | 2187 | { |
| 1716 | IrInstruction *instruction = ir_create_const_type(irb, scope, source_node, type_entry); | 2188 | IrInstSrc *instruction = ir_create_const_type(irb, scope, source_node, type_entry); |
| 1717 | ir_instruction_append(irb->current_basic_block, instruction); | 2189 | ir_instruction_append(irb->current_basic_block, instruction); |
| 1718 | return instruction; | 2190 | return instruction; |
| 1719 | } | 2191 | } |
| 1720 | | 2192 | |
| 1721 | static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigFn *fn_entry) { | 2193 | static IrInstSrc *ir_build_const_import(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, ZigType *import) { |
| 1722 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); | 2194 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1723 | const_instruction->base.value->type = fn_entry->type_entry; | 2195 | const_instruction->value = create_const_vals(1); |
| 1724 | const_instruction->base.value->special = ConstValSpecialStatic; | 2196 | const_instruction->value->type = irb->codegen->builtin_types.entry_type; |
| 1725 | const_instruction->base.value->data.x_ptr.data.fn.fn_entry = fn_entry; | 2197 | const_instruction->value->special = ConstValSpecialStatic; |
| 1726 | const_instruction->base.value->data.x_ptr.mut = ConstPtrMutComptimeConst; | 2198 | const_instruction->value->data.x_type = import; |
| 1727 | const_instruction->base.value->data.x_ptr.special = ConstPtrSpecialFunction; | | |
| 1728 | return &const_instruction->base; | | |
| 1729 | } | | |
| 1730 | | | |
| 1731 | static IrInstruction *ir_build_const_import(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigType *import) { | | |
| 1732 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | | |
| 1733 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_type; | | |
| 1734 | const_instruction->base.value->special = ConstValSpecialStatic; | | |
| 1735 | const_instruction->base.value->data.x_type = import; | | |
| 1736 | return &const_instruction->base; | | |
| 1737 | } | | |
| 1738 | | | |
| 1739 | static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode *source_node, bool value) { | | |
| 1740 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | | |
| 1741 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_bool; | | |
| 1742 | const_instruction->base.value->special = ConstValSpecialStatic; | | |
| 1743 | const_instruction->base.value->data.x_bool = value; | | |
| 1744 | return &const_instruction->base; | 2199 | return &const_instruction->base; |
| 1745 | } | 2200 | } |
| 1746 | | 2201 | |
| 1747 | static IrInstruction *ir_build_const_enum_literal(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *name) { | 2202 | static IrInstSrc *ir_build_const_bool(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, bool value) { |
| 1748 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 2203 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1749 | const_instruction->base.value->type = irb->codegen->builtin_types.entry_enum_literal; | 2204 | const_instruction->value = create_const_vals(1); |
| 1750 | const_instruction->base.value->special = ConstValSpecialStatic; | 2205 | const_instruction->value->type = irb->codegen->builtin_types.entry_bool; |
| 1751 | const_instruction->base.value->data.x_enum_literal = name; | 2206 | const_instruction->value->special = ConstValSpecialStatic; |
| | 2207 | const_instruction->value->data.x_bool = value; |
| 1752 | return &const_instruction->base; | 2208 | return &const_instruction->base; |
| 1753 | } | 2209 | } |
| 1754 | | 2210 | |
| 1755 | static IrInstruction *ir_build_const_bound_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2211 | static IrInstSrc *ir_build_const_enum_literal(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, Buf *name) { |
| 1756 | ZigFn *fn_entry, IrInstruction *first_arg) | 2212 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1757 | { | 2213 | const_instruction->value = create_const_vals(1); |
| 1758 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | 2214 | const_instruction->value->type = irb->codegen->builtin_types.entry_enum_literal; |
| 1759 | const_instruction->base.value->type = get_bound_fn_type(irb->codegen, fn_entry); | 2215 | const_instruction->value->special = ConstValSpecialStatic; |
| 1760 | const_instruction->base.value->special = ConstValSpecialStatic; | 2216 | const_instruction->value->data.x_enum_literal = name; |
| 1761 | const_instruction->base.value->data.x_bound_fn.fn = fn_entry; | | |
| 1762 | const_instruction->base.value->data.x_bound_fn.first_arg = first_arg; | | |
| 1763 | return &const_instruction->base; | 2217 | return &const_instruction->base; |
| 1764 | } | 2218 | } |
| 1765 | | 2219 | |
| 1766 | static IrInstruction *ir_create_const_str_lit(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *str) { | 2220 | static IrInstSrc *ir_create_const_str_lit(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, Buf *str) { |
| 1767 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(irb, scope, source_node); | 2221 | IrInstSrcConst *const_instruction = ir_create_instruction<IrInstSrcConst>(irb, scope, source_node); |
| 1768 | init_const_str_lit(irb->codegen, const_instruction->base.value, str); | 2222 | const_instruction->value = create_const_vals(1); |
| | 2223 | init_const_str_lit(irb->codegen, const_instruction->value, str); |
| 1769 | | 2224 | |
| 1770 | return &const_instruction->base; | 2225 | return &const_instruction->base; |
| 1771 | } | 2226 | } |
| 1772 | | 2227 | |
| 1773 | static IrInstruction *ir_build_const_str_lit(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *str) { | 2228 | static IrInstSrc *ir_build_const_str_lit(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, Buf *str) { |
| 1774 | IrInstruction *instruction = ir_create_const_str_lit(irb, scope, source_node, str); | 2229 | IrInstSrc *instruction = ir_create_const_str_lit(irb, scope, source_node, str); |
| 1775 | ir_instruction_append(irb->current_basic_block, instruction); | 2230 | ir_instruction_append(irb->current_basic_block, instruction); |
| 1776 | return instruction; | 2231 | return instruction; |
| 1777 | } | 2232 | } |
| 1778 | | 2233 | |
| 1779 | static IrInstruction *ir_build_bin_op(IrBuilder *irb, Scope *scope, AstNode *source_node, IrBinOp op_id, | 2234 | static IrInstSrc *ir_build_bin_op(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrBinOp op_id, |
| 1780 | IrInstruction *op1, IrInstruction *op2, bool safety_check_on) | 2235 | IrInstSrc *op1, IrInstSrc *op2, bool safety_check_on) |
| 1781 | { | 2236 | { |
| 1782 | IrInstructionBinOp *bin_op_instruction = ir_build_instruction<IrInstructionBinOp>(irb, scope, source_node); | 2237 | IrInstSrcBinOp *inst = ir_build_instruction<IrInstSrcBinOp>(irb, scope, source_node); |
| 1783 | bin_op_instruction->op_id = op_id; | 2238 | inst->op_id = op_id; |
| 1784 | bin_op_instruction->op1 = op1; | 2239 | inst->op1 = op1; |
| 1785 | bin_op_instruction->op2 = op2; | 2240 | inst->op2 = op2; |
| 1786 | bin_op_instruction->safety_check_on = safety_check_on; | 2241 | inst->safety_check_on = safety_check_on; |
| 1787 | | 2242 | |
| 1788 | ir_ref_instruction(op1, irb->current_basic_block); | 2243 | ir_ref_instruction(op1, irb->current_basic_block); |
| 1789 | ir_ref_instruction(op2, irb->current_basic_block); | 2244 | ir_ref_instruction(op2, irb->current_basic_block); |
| 1790 | | 2245 | |
| 1791 | return &bin_op_instruction->base; | 2246 | return &inst->base; |
| 1792 | } | 2247 | } |
| 1793 | | 2248 | |
| 1794 | static IrInstruction *ir_build_bin_op_gen(IrAnalyze *ira, IrInstruction *source_instr, ZigType *res_type, | 2249 | static IrInstGen *ir_build_bin_op_gen(IrAnalyze *ira, IrInst *source_instr, ZigType *res_type, |
| 1795 | IrBinOp op_id, IrInstruction *op1, IrInstruction *op2, bool safety_check_on) | 2250 | IrBinOp op_id, IrInstGen *op1, IrInstGen *op2, bool safety_check_on) |
| 1796 | { | 2251 | { |
| 1797 | IrInstructionBinOp *bin_op_instruction = ir_build_instruction<IrInstructionBinOp>(&ira->new_irb, | 2252 | IrInstGenBinOp *inst = ir_build_inst_gen<IrInstGenBinOp>(&ira->new_irb, |
| 1798 | source_instr->scope, source_instr->source_node); | 2253 | source_instr->scope, source_instr->source_node); |
| 1799 | bin_op_instruction->base.value->type = res_type; | 2254 | inst->base.value->type = res_type; |
| 1800 | bin_op_instruction->op_id = op_id; | 2255 | inst->op_id = op_id; |
| 1801 | bin_op_instruction->op1 = op1; | 2256 | inst->op1 = op1; |
| 1802 | bin_op_instruction->op2 = op2; | 2257 | inst->op2 = op2; |
| 1803 | bin_op_instruction->safety_check_on = safety_check_on; | 2258 | inst->safety_check_on = safety_check_on; |
| 1804 | | 2259 | |
| 1805 | ir_ref_instruction(op1, ira->new_irb.current_basic_block); | 2260 | ir_ref_inst_gen(op1, ira->new_irb.current_basic_block); |
| 1806 | ir_ref_instruction(op2, ira->new_irb.current_basic_block); | 2261 | ir_ref_inst_gen(op2, ira->new_irb.current_basic_block); |
| 1807 | | 2262 | |
| 1808 | return &bin_op_instruction->base; | 2263 | return &inst->base; |
| 1809 | } | 2264 | } |
| 1810 | | 2265 | |
| 1811 | | 2266 | |
| 1812 | static IrInstruction *ir_build_merge_err_sets(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2267 | static IrInstSrc *ir_build_merge_err_sets(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1813 | IrInstruction *op1, IrInstruction *op2, Buf *type_name) | 2268 | IrInstSrc *op1, IrInstSrc *op2, Buf *type_name) |
| 1814 | { | 2269 | { |
| 1815 | IrInstructionMergeErrSets *merge_err_sets_instruction = ir_build_instruction<IrInstructionMergeErrSets>(irb, scope, source_node); | 2270 | IrInstSrcMergeErrSets *inst = ir_build_instruction<IrInstSrcMergeErrSets>(irb, scope, source_node); |
| 1816 | merge_err_sets_instruction->op1 = op1; | 2271 | inst->op1 = op1; |
| 1817 | merge_err_sets_instruction->op2 = op2; | 2272 | inst->op2 = op2; |
| 1818 | merge_err_sets_instruction->type_name = type_name; | 2273 | inst->type_name = type_name; |
| 1819 | | 2274 | |
| 1820 | ir_ref_instruction(op1, irb->current_basic_block); | 2275 | ir_ref_instruction(op1, irb->current_basic_block); |
| 1821 | ir_ref_instruction(op2, irb->current_basic_block); | 2276 | ir_ref_instruction(op2, irb->current_basic_block); |
| 1822 | | 2277 | |
| 1823 | return &merge_err_sets_instruction->base; | 2278 | return &inst->base; |
| 1824 | } | 2279 | } |
| 1825 | | 2280 | |
| 1826 | static IrInstruction *ir_build_var_ptr_x(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigVar *var, | 2281 | static IrInstSrc *ir_build_var_ptr_x(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, ZigVar *var, |
| 1827 | ScopeFnDef *crossed_fndef_scope) | 2282 | ScopeFnDef *crossed_fndef_scope) |
| 1828 | { | 2283 | { |
| 1829 | IrInstructionVarPtr *instruction = ir_build_instruction<IrInstructionVarPtr>(irb, scope, source_node); | 2284 | IrInstSrcVarPtr *instruction = ir_build_instruction<IrInstSrcVarPtr>(irb, scope, source_node); |
| 1830 | instruction->var = var; | 2285 | instruction->var = var; |
| 1831 | instruction->crossed_fndef_scope = crossed_fndef_scope; | 2286 | instruction->crossed_fndef_scope = crossed_fndef_scope; |
| 1832 | | 2287 | |
| ... | @@ -1835,22 +2290,31 @@ static IrInstruction *ir_build_var_ptr_x(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -1835,22 +2290,31 @@ static IrInstruction *ir_build_var_ptr_x(IrBuilder *irb, Scope *scope, AstNode * |
| 1835 | return &instruction->base; | 2290 | return &instruction->base; |
| 1836 | } | 2291 | } |
| 1837 | | 2292 | |
| 1838 | static IrInstruction *ir_build_var_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigVar *var) { | 2293 | static IrInstSrc *ir_build_var_ptr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, ZigVar *var) { |
| 1839 | return ir_build_var_ptr_x(irb, scope, source_node, var, nullptr); | 2294 | return ir_build_var_ptr_x(irb, scope, source_node, var, nullptr); |
| 1840 | } | 2295 | } |
| 1841 | | 2296 | |
| 1842 | static IrInstruction *ir_build_return_ptr(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) { | 2297 | static IrInstGen *ir_build_var_ptr_gen(IrAnalyze *ira, IrInst *source_instr, ZigVar *var) { |
| 1843 | IrInstructionReturnPtr *instruction = ir_build_instruction<IrInstructionReturnPtr>(&ira->new_irb, | 2298 | IrInstGenVarPtr *instruction = ir_build_inst_gen<IrInstGenVarPtr>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| | 2299 | instruction->var = var; |
| | 2300 | |
| | 2301 | ir_ref_var(var); |
| | 2302 | |
| | 2303 | return &instruction->base; |
| | 2304 | } |
| | 2305 | |
| | 2306 | static IrInstGen *ir_build_return_ptr(IrAnalyze *ira, IrInst *source_instruction, ZigType *ty) { |
| | 2307 | IrInstGenReturnPtr *instruction = ir_build_inst_gen<IrInstGenReturnPtr>(&ira->new_irb, |
| 1844 | source_instruction->scope, source_instruction->source_node); | 2308 | source_instruction->scope, source_instruction->source_node); |
| 1845 | instruction->base.value->type = ty; | 2309 | instruction->base.value->type = ty; |
| 1846 | return &instruction->base; | 2310 | return &instruction->base; |
| 1847 | } | 2311 | } |
| 1848 | | 2312 | |
| 1849 | static IrInstruction *ir_build_elem_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2313 | static IrInstSrc *ir_build_elem_ptr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1850 | IrInstruction *array_ptr, IrInstruction *elem_index, bool safety_check_on, PtrLen ptr_len, | 2314 | IrInstSrc *array_ptr, IrInstSrc *elem_index, bool safety_check_on, PtrLen ptr_len, |
| 1851 | AstNode *init_array_type_source_node) | 2315 | AstNode *init_array_type_source_node) |
| 1852 | { | 2316 | { |
| 1853 | IrInstructionElemPtr *instruction = ir_build_instruction<IrInstructionElemPtr>(irb, scope, source_node); | 2317 | IrInstSrcElemPtr *instruction = ir_build_instruction<IrInstSrcElemPtr>(irb, scope, source_node); |
| 1854 | instruction->array_ptr = array_ptr; | 2318 | instruction->array_ptr = array_ptr; |
| 1855 | instruction->elem_index = elem_index; | 2319 | instruction->elem_index = elem_index; |
| 1856 | instruction->safety_check_on = safety_check_on; | 2320 | instruction->safety_check_on = safety_check_on; |
| ... | @@ -1863,10 +2327,25 @@ static IrInstruction *ir_build_elem_ptr(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -1863,10 +2327,25 @@ static IrInstruction *ir_build_elem_ptr(IrBuilder *irb, Scope *scope, AstNode *s |
| 1863 | return &instruction->base; | 2327 | return &instruction->base; |
| 1864 | } | 2328 | } |
| 1865 | | 2329 | |
| 1866 | static IrInstruction *ir_build_field_ptr_instruction(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2330 | static IrInstGen *ir_build_elem_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, |
| 1867 | IrInstruction *container_ptr, IrInstruction *field_name_expr, bool initializing) | 2331 | IrInstGen *array_ptr, IrInstGen *elem_index, bool safety_check_on, ZigType *return_type) |
| | 2332 | { |
| | 2333 | IrInstGenElemPtr *instruction = ir_build_inst_gen<IrInstGenElemPtr>(&ira->new_irb, scope, source_node); |
| | 2334 | instruction->base.value->type = return_type; |
| | 2335 | instruction->array_ptr = array_ptr; |
| | 2336 | instruction->elem_index = elem_index; |
| | 2337 | instruction->safety_check_on = safety_check_on; |
| | 2338 | |
| | 2339 | ir_ref_inst_gen(array_ptr, ira->new_irb.current_basic_block); |
| | 2340 | ir_ref_inst_gen(elem_index, ira->new_irb.current_basic_block); |
| | 2341 | |
| | 2342 | return &instruction->base; |
| | 2343 | } |
| | 2344 | |
| | 2345 | static IrInstSrc *ir_build_field_ptr_instruction(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 2346 | IrInstSrc *container_ptr, IrInstSrc *field_name_expr, bool initializing) |
| 1868 | { | 2347 | { |
| 1869 | IrInstructionFieldPtr *instruction = ir_build_instruction<IrInstructionFieldPtr>(irb, scope, source_node); | 2348 | IrInstSrcFieldPtr *instruction = ir_build_instruction<IrInstSrcFieldPtr>(irb, scope, source_node); |
| 1870 | instruction->container_ptr = container_ptr; | 2349 | instruction->container_ptr = container_ptr; |
| 1871 | instruction->field_name_buffer = nullptr; | 2350 | instruction->field_name_buffer = nullptr; |
| 1872 | instruction->field_name_expr = field_name_expr; | 2351 | instruction->field_name_expr = field_name_expr; |
| ... | @@ -1878,10 +2357,10 @@ static IrInstruction *ir_build_field_ptr_instruction(IrBuilder *irb, Scope *scop | ... | @@ -1878,10 +2357,10 @@ static IrInstruction *ir_build_field_ptr_instruction(IrBuilder *irb, Scope *scop |
| 1878 | return &instruction->base; | 2357 | return &instruction->base; |
| 1879 | } | 2358 | } |
| 1880 | | 2359 | |
| 1881 | static IrInstruction *ir_build_field_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2360 | static IrInstSrc *ir_build_field_ptr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1882 | IrInstruction *container_ptr, Buf *field_name, bool initializing) | 2361 | IrInstSrc *container_ptr, Buf *field_name, bool initializing) |
| 1883 | { | 2362 | { |
| 1884 | IrInstructionFieldPtr *instruction = ir_build_instruction<IrInstructionFieldPtr>(irb, scope, source_node); | 2363 | IrInstSrcFieldPtr *instruction = ir_build_instruction<IrInstSrcFieldPtr>(irb, scope, source_node); |
| 1885 | instruction->container_ptr = container_ptr; | 2364 | instruction->container_ptr = container_ptr; |
| 1886 | instruction->field_name_buffer = field_name; | 2365 | instruction->field_name_buffer = field_name; |
| 1887 | instruction->field_name_expr = nullptr; | 2366 | instruction->field_name_expr = nullptr; |
| ... | @@ -1892,10 +2371,10 @@ static IrInstruction *ir_build_field_ptr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -1892,10 +2371,10 @@ static IrInstruction *ir_build_field_ptr(IrBuilder *irb, Scope *scope, AstNode * |
| 1892 | return &instruction->base; | 2371 | return &instruction->base; |
| 1893 | } | 2372 | } |
| 1894 | | 2373 | |
| 1895 | static IrInstruction *ir_build_has_field(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2374 | static IrInstSrc *ir_build_has_field(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1896 | IrInstruction *container_type, IrInstruction *field_name) | 2375 | IrInstSrc *container_type, IrInstSrc *field_name) |
| 1897 | { | 2376 | { |
| 1898 | IrInstructionHasField *instruction = ir_build_instruction<IrInstructionHasField>(irb, scope, source_node); | 2377 | IrInstSrcHasField *instruction = ir_build_instruction<IrInstSrcHasField>(irb, scope, source_node); |
| 1899 | instruction->container_type = container_type; | 2378 | instruction->container_type = container_type; |
| 1900 | instruction->field_name = field_name; | 2379 | instruction->field_name = field_name; |
| 1901 | | 2380 | |
| ... | @@ -1905,36 +2384,39 @@ static IrInstruction *ir_build_has_field(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -1905,36 +2384,39 @@ static IrInstruction *ir_build_has_field(IrBuilder *irb, Scope *scope, AstNode * |
| 1905 | return &instruction->base; | 2384 | return &instruction->base; |
| 1906 | } | 2385 | } |
| 1907 | | 2386 | |
| 1908 | static IrInstruction *ir_build_struct_field_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2387 | static IrInstGen *ir_build_struct_field_ptr(IrAnalyze *ira, IrInst *source_instr, |
| 1909 | IrInstruction *struct_ptr, TypeStructField *field) | 2388 | IrInstGen *struct_ptr, TypeStructField *field, ZigType *ptr_type) |
| 1910 | { | 2389 | { |
| 1911 | IrInstructionStructFieldPtr *instruction = ir_build_instruction<IrInstructionStructFieldPtr>(irb, scope, source_node); | 2390 | IrInstGenStructFieldPtr *inst = ir_build_inst_gen<IrInstGenStructFieldPtr>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| 1912 | instruction->struct_ptr = struct_ptr; | 2391 | inst->base.value->type = ptr_type; |
| 1913 | instruction->field = field; | 2392 | inst->struct_ptr = struct_ptr; |
| | 2393 | inst->field = field; |
| 1914 | | 2394 | |
| 1915 | ir_ref_instruction(struct_ptr, irb->current_basic_block); | 2395 | ir_ref_inst_gen(struct_ptr, ira->new_irb.current_basic_block); |
| 1916 | | 2396 | |
| 1917 | return &instruction->base; | 2397 | return &inst->base; |
| 1918 | } | 2398 | } |
| 1919 | | 2399 | |
| 1920 | static IrInstruction *ir_build_union_field_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2400 | static IrInstGen *ir_build_union_field_ptr(IrAnalyze *ira, IrInst *source_instr, |
| 1921 | IrInstruction *union_ptr, TypeUnionField *field, bool safety_check_on, bool initializing) | 2401 | IrInstGen *union_ptr, TypeUnionField *field, bool safety_check_on, bool initializing, ZigType *ptr_type) |
| 1922 | { | 2402 | { |
| 1923 | IrInstructionUnionFieldPtr *instruction = ir_build_instruction<IrInstructionUnionFieldPtr>(irb, scope, source_node); | 2403 | IrInstGenUnionFieldPtr *inst = ir_build_inst_gen<IrInstGenUnionFieldPtr>(&ira->new_irb, |
| 1924 | instruction->initializing = initializing; | 2404 | source_instr->scope, source_instr->source_node); |
| 1925 | instruction->safety_check_on = safety_check_on; | 2405 | inst->base.value->type = ptr_type; |
| 1926 | instruction->union_ptr = union_ptr; | 2406 | inst->initializing = initializing; |
| 1927 | instruction->field = field; | 2407 | inst->safety_check_on = safety_check_on; |
| | 2408 | inst->union_ptr = union_ptr; |
| | 2409 | inst->field = field; |
| 1928 | | 2410 | |
| 1929 | ir_ref_instruction(union_ptr, irb->current_basic_block); | 2411 | ir_ref_inst_gen(union_ptr, ira->new_irb.current_basic_block); |
| 1930 | | 2412 | |
| 1931 | return &instruction->base; | 2413 | return &inst->base; |
| 1932 | } | 2414 | } |
| 1933 | | 2415 | |
| 1934 | static IrInstruction *ir_build_call_extra(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2416 | static IrInstSrc *ir_build_call_extra(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1935 | IrInstruction *options, IrInstruction *fn_ref, IrInstruction *args, ResultLoc *result_loc) | 2417 | IrInstSrc *options, IrInstSrc *fn_ref, IrInstSrc *args, ResultLoc *result_loc) |
| 1936 | { | 2418 | { |
| 1937 | IrInstructionCallExtra *call_instruction = ir_build_instruction<IrInstructionCallExtra>(irb, scope, source_node); | 2419 | IrInstSrcCallExtra *call_instruction = ir_build_instruction<IrInstSrcCallExtra>(irb, scope, source_node); |
| 1938 | call_instruction->options = options; | 2420 | call_instruction->options = options; |
| 1939 | call_instruction->fn_ref = fn_ref; | 2421 | call_instruction->fn_ref = fn_ref; |
| 1940 | call_instruction->args = args; | 2422 | call_instruction->args = args; |
| ... | @@ -1947,11 +2429,11 @@ static IrInstruction *ir_build_call_extra(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -1947,11 +2429,11 @@ static IrInstruction *ir_build_call_extra(IrBuilder *irb, Scope *scope, AstNode |
| 1947 | return &call_instruction->base; | 2429 | return &call_instruction->base; |
| 1948 | } | 2430 | } |
| 1949 | | 2431 | |
| 1950 | static IrInstruction *ir_build_call_src_args(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2432 | static IrInstSrc *ir_build_call_args(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1951 | IrInstruction *options, IrInstruction *fn_ref, IrInstruction **args_ptr, size_t args_len, | 2433 | IrInstSrc *options, IrInstSrc *fn_ref, IrInstSrc **args_ptr, size_t args_len, |
| 1952 | ResultLoc *result_loc) | 2434 | ResultLoc *result_loc) |
| 1953 | { | 2435 | { |
| 1954 | IrInstructionCallSrcArgs *call_instruction = ir_build_instruction<IrInstructionCallSrcArgs>(irb, scope, source_node); | 2436 | IrInstSrcCallArgs *call_instruction = ir_build_instruction<IrInstSrcCallArgs>(irb, scope, source_node); |
| 1955 | call_instruction->options = options; | 2437 | call_instruction->options = options; |
| 1956 | call_instruction->fn_ref = fn_ref; | 2438 | call_instruction->fn_ref = fn_ref; |
| 1957 | call_instruction->args_ptr = args_ptr; | 2439 | call_instruction->args_ptr = args_ptr; |
| ... | @@ -1966,12 +2448,12 @@ static IrInstruction *ir_build_call_src_args(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -1966,12 +2448,12 @@ static IrInstruction *ir_build_call_src_args(IrBuilder *irb, Scope *scope, AstNo |
| 1966 | return &call_instruction->base; | 2448 | return &call_instruction->base; |
| 1967 | } | 2449 | } |
| 1968 | | 2450 | |
| 1969 | static IrInstruction *ir_build_call_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2451 | static IrInstSrc *ir_build_call_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 1970 | ZigFn *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args, | 2452 | ZigFn *fn_entry, IrInstSrc *fn_ref, size_t arg_count, IrInstSrc **args, |
| 1971 | IrInstruction *ret_ptr, CallModifier modifier, bool is_async_call_builtin, | 2453 | IrInstSrc *ret_ptr, CallModifier modifier, bool is_async_call_builtin, |
| 1972 | IrInstruction *new_stack, ResultLoc *result_loc) | 2454 | IrInstSrc *new_stack, ResultLoc *result_loc) |
| 1973 | { | 2455 | { |
| 1974 | IrInstructionCallSrc *call_instruction = ir_build_instruction<IrInstructionCallSrc>(irb, scope, source_node); | 2456 | IrInstSrcCall *call_instruction = ir_build_instruction<IrInstSrcCall>(irb, scope, source_node); |
| 1975 | call_instruction->fn_entry = fn_entry; | 2457 | call_instruction->fn_entry = fn_entry; |
| 1976 | call_instruction->fn_ref = fn_ref; | 2458 | call_instruction->fn_ref = fn_ref; |
| 1977 | call_instruction->args = args; | 2459 | call_instruction->args = args; |
| ... | @@ -1991,12 +2473,12 @@ static IrInstruction *ir_build_call_src(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -1991,12 +2473,12 @@ static IrInstruction *ir_build_call_src(IrBuilder *irb, Scope *scope, AstNode *s |
| 1991 | return &call_instruction->base; | 2473 | return &call_instruction->base; |
| 1992 | } | 2474 | } |
| 1993 | | 2475 | |
| 1994 | static IrInstructionCallGen *ir_build_call_gen(IrAnalyze *ira, IrInstruction *source_instruction, | 2476 | static IrInstGenCall *ir_build_call_gen(IrAnalyze *ira, IrInst *source_instruction, |
| 1995 | ZigFn *fn_entry, IrInstruction *fn_ref, size_t arg_count, IrInstruction **args, | 2477 | ZigFn *fn_entry, IrInstGen *fn_ref, size_t arg_count, IrInstGen **args, |
| 1996 | CallModifier modifier, IrInstruction *new_stack, bool is_async_call_builtin, | 2478 | CallModifier modifier, IrInstGen *new_stack, bool is_async_call_builtin, |
| 1997 | IrInstruction *result_loc, ZigType *return_type) | 2479 | IrInstGen *result_loc, ZigType *return_type) |
| 1998 | { | 2480 | { |
| 1999 | IrInstructionCallGen *call_instruction = ir_build_instruction<IrInstructionCallGen>(&ira->new_irb, | 2481 | IrInstGenCall *call_instruction = ir_build_inst_gen<IrInstGenCall>(&ira->new_irb, |
| 2000 | source_instruction->scope, source_instruction->source_node); | 2482 | source_instruction->scope, source_instruction->source_node); |
| 2001 | call_instruction->base.value->type = return_type; | 2483 | call_instruction->base.value->type = return_type; |
| 2002 | call_instruction->fn_entry = fn_entry; | 2484 | call_instruction->fn_entry = fn_entry; |
| ... | @@ -2008,23 +2490,23 @@ static IrInstructionCallGen *ir_build_call_gen(IrAnalyze *ira, IrInstruction *so | ... | @@ -2008,23 +2490,23 @@ static IrInstructionCallGen *ir_build_call_gen(IrAnalyze *ira, IrInstruction *so |
| 2008 | call_instruction->new_stack = new_stack; | 2490 | call_instruction->new_stack = new_stack; |
| 2009 | call_instruction->result_loc = result_loc; | 2491 | call_instruction->result_loc = result_loc; |
| 2010 | | 2492 | |
| 2011 | if (fn_ref != nullptr) ir_ref_instruction(fn_ref, ira->new_irb.current_basic_block); | 2493 | if (fn_ref != nullptr) ir_ref_inst_gen(fn_ref, ira->new_irb.current_basic_block); |
| 2012 | for (size_t i = 0; i < arg_count; i += 1) | 2494 | for (size_t i = 0; i < arg_count; i += 1) |
| 2013 | ir_ref_instruction(args[i], ira->new_irb.current_basic_block); | 2495 | ir_ref_inst_gen(args[i], ira->new_irb.current_basic_block); |
| 2014 | if (new_stack != nullptr) ir_ref_instruction(new_stack, ira->new_irb.current_basic_block); | 2496 | if (new_stack != nullptr) ir_ref_inst_gen(new_stack, ira->new_irb.current_basic_block); |
| 2015 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 2497 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 2016 | | 2498 | |
| 2017 | return call_instruction; | 2499 | return call_instruction; |
| 2018 | } | 2500 | } |
| 2019 | | 2501 | |
| 2020 | static IrInstruction *ir_build_phi(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2502 | static IrInstSrc *ir_build_phi(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2021 | size_t incoming_count, IrBasicBlock **incoming_blocks, IrInstruction **incoming_values, | 2503 | size_t incoming_count, IrBasicBlockSrc **incoming_blocks, IrInstSrc **incoming_values, |
| 2022 | ResultLocPeerParent *peer_parent) | 2504 | ResultLocPeerParent *peer_parent) |
| 2023 | { | 2505 | { |
| 2024 | assert(incoming_count != 0); | 2506 | assert(incoming_count != 0); |
| 2025 | assert(incoming_count != SIZE_MAX); | 2507 | assert(incoming_count != SIZE_MAX); |
| 2026 | | 2508 | |
| 2027 | IrInstructionPhi *phi_instruction = ir_build_instruction<IrInstructionPhi>(irb, scope, source_node); | 2509 | IrInstSrcPhi *phi_instruction = ir_build_instruction<IrInstSrcPhi>(irb, scope, source_node); |
| 2028 | phi_instruction->incoming_count = incoming_count; | 2510 | phi_instruction->incoming_count = incoming_count; |
| 2029 | phi_instruction->incoming_blocks = incoming_blocks; | 2511 | phi_instruction->incoming_blocks = incoming_blocks; |
| 2030 | phi_instruction->incoming_values = incoming_values; | 2512 | phi_instruction->incoming_values = incoming_values; |
| ... | @@ -2038,56 +2520,77 @@ static IrInstruction *ir_build_phi(IrBuilder *irb, Scope *scope, AstNode *source | ... | @@ -2038,56 +2520,77 @@ static IrInstruction *ir_build_phi(IrBuilder *irb, Scope *scope, AstNode *source |
| 2038 | return &phi_instruction->base; | 2520 | return &phi_instruction->base; |
| 2039 | } | 2521 | } |
| 2040 | | 2522 | |
| 2041 | static IrInstruction *ir_create_br(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2523 | static IrInstGen *ir_build_phi_gen(IrAnalyze *ira, IrInst *source_instr, size_t incoming_count, |
| 2042 | IrBasicBlock *dest_block, IrInstruction *is_comptime) | 2524 | IrBasicBlockGen **incoming_blocks, IrInstGen **incoming_values, ZigType *result_type) |
| | 2525 | { |
| | 2526 | assert(incoming_count != 0); |
| | 2527 | assert(incoming_count != SIZE_MAX); |
| | 2528 | |
| | 2529 | IrInstGenPhi *phi_instruction = ir_build_inst_gen<IrInstGenPhi>(&ira->new_irb, |
| | 2530 | source_instr->scope, source_instr->source_node); |
| | 2531 | phi_instruction->base.value->type = result_type; |
| | 2532 | phi_instruction->incoming_count = incoming_count; |
| | 2533 | phi_instruction->incoming_blocks = incoming_blocks; |
| | 2534 | phi_instruction->incoming_values = incoming_values; |
| | 2535 | |
| | 2536 | for (size_t i = 0; i < incoming_count; i += 1) { |
| | 2537 | ir_ref_bb_gen(incoming_blocks[i]); |
| | 2538 | ir_ref_inst_gen(incoming_values[i], ira->new_irb.current_basic_block); |
| | 2539 | } |
| | 2540 | |
| | 2541 | return &phi_instruction->base; |
| | 2542 | } |
| | 2543 | |
| | 2544 | static IrInstSrc *ir_build_br(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 2545 | IrBasicBlockSrc *dest_block, IrInstSrc *is_comptime) |
| 2043 | { | 2546 | { |
| 2044 | IrInstructionBr *br_instruction = ir_create_instruction<IrInstructionBr>(irb, scope, source_node); | 2547 | IrInstSrcBr *inst = ir_build_instruction<IrInstSrcBr>(irb, scope, source_node); |
| 2045 | br_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; | 2548 | inst->base.is_noreturn = true; |
| 2046 | br_instruction->base.value->special = ConstValSpecialStatic; | 2549 | inst->dest_block = dest_block; |
| 2047 | br_instruction->dest_block = dest_block; | 2550 | inst->is_comptime = is_comptime; |
| 2048 | br_instruction->is_comptime = is_comptime; | | |
| 2049 | | 2551 | |
| 2050 | ir_ref_bb(dest_block); | 2552 | ir_ref_bb(dest_block); |
| 2051 | if (is_comptime) ir_ref_instruction(is_comptime, irb->current_basic_block); | 2553 | if (is_comptime) ir_ref_instruction(is_comptime, irb->current_basic_block); |
| 2052 | | 2554 | |
| 2053 | return &br_instruction->base; | 2555 | return &inst->base; |
| 2054 | } | 2556 | } |
| 2055 | | 2557 | |
| 2056 | static IrInstruction *ir_build_br(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2558 | static IrInstGen *ir_build_br_gen(IrAnalyze *ira, IrInst *source_instr, IrBasicBlockGen *dest_block) { |
| 2057 | IrBasicBlock *dest_block, IrInstruction *is_comptime) | 2559 | IrInstGenBr *inst = ir_build_inst_noreturn<IrInstGenBr>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| 2058 | { | 2560 | inst->dest_block = dest_block; |
| 2059 | IrInstruction *instruction = ir_create_br(irb, scope, source_node, dest_block, is_comptime); | 2561 | |
| 2060 | ir_instruction_append(irb->current_basic_block, instruction); | 2562 | ir_ref_bb_gen(dest_block); |
| 2061 | return instruction; | 2563 | |
| | 2564 | return &inst->base; |
| 2062 | } | 2565 | } |
| 2063 | | 2566 | |
| 2064 | static IrInstruction *ir_build_ptr_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2567 | static IrInstSrc *ir_build_ptr_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2065 | IrInstruction *child_type, bool is_const, bool is_volatile, PtrLen ptr_len, | 2568 | IrInstSrc *child_type, bool is_const, bool is_volatile, PtrLen ptr_len, |
| 2066 | IrInstruction *sentinel, IrInstruction *align_value, | 2569 | IrInstSrc *sentinel, IrInstSrc *align_value, |
| 2067 | uint32_t bit_offset_start, uint32_t host_int_bytes, bool is_allow_zero) | 2570 | uint32_t bit_offset_start, uint32_t host_int_bytes, bool is_allow_zero) |
| 2068 | { | 2571 | { |
| 2069 | IrInstructionPtrType *ptr_type_of_instruction = ir_build_instruction<IrInstructionPtrType>(irb, scope, source_node); | 2572 | IrInstSrcPtrType *inst = ir_build_instruction<IrInstSrcPtrType>(irb, scope, source_node); |
| 2070 | ptr_type_of_instruction->sentinel = sentinel; | 2573 | inst->sentinel = sentinel; |
| 2071 | ptr_type_of_instruction->align_value = align_value; | 2574 | inst->align_value = align_value; |
| 2072 | ptr_type_of_instruction->child_type = child_type; | 2575 | inst->child_type = child_type; |
| 2073 | ptr_type_of_instruction->is_const = is_const; | 2576 | inst->is_const = is_const; |
| 2074 | ptr_type_of_instruction->is_volatile = is_volatile; | 2577 | inst->is_volatile = is_volatile; |
| 2075 | ptr_type_of_instruction->ptr_len = ptr_len; | 2578 | inst->ptr_len = ptr_len; |
| 2076 | ptr_type_of_instruction->bit_offset_start = bit_offset_start; | 2579 | inst->bit_offset_start = bit_offset_start; |
| 2077 | ptr_type_of_instruction->host_int_bytes = host_int_bytes; | 2580 | inst->host_int_bytes = host_int_bytes; |
| 2078 | ptr_type_of_instruction->is_allow_zero = is_allow_zero; | 2581 | inst->is_allow_zero = is_allow_zero; |
| 2079 | | 2582 | |
| 2080 | if (sentinel) ir_ref_instruction(sentinel, irb->current_basic_block); | 2583 | if (sentinel) ir_ref_instruction(sentinel, irb->current_basic_block); |
| 2081 | if (align_value) ir_ref_instruction(align_value, irb->current_basic_block); | 2584 | if (align_value) ir_ref_instruction(align_value, irb->current_basic_block); |
| 2082 | ir_ref_instruction(child_type, irb->current_basic_block); | 2585 | ir_ref_instruction(child_type, irb->current_basic_block); |
| 2083 | | 2586 | |
| 2084 | return &ptr_type_of_instruction->base; | 2587 | return &inst->base; |
| 2085 | } | 2588 | } |
| 2086 | | 2589 | |
| 2087 | static IrInstruction *ir_build_un_op_lval(IrBuilder *irb, Scope *scope, AstNode *source_node, IrUnOp op_id, | 2590 | static IrInstSrc *ir_build_un_op_lval(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrUnOp op_id, |
| 2088 | IrInstruction *value, LVal lval, ResultLoc *result_loc) | 2591 | IrInstSrc *value, LVal lval, ResultLoc *result_loc) |
| 2089 | { | 2592 | { |
| 2090 | IrInstructionUnOp *instruction = ir_build_instruction<IrInstructionUnOp>(irb, scope, source_node); | 2593 | IrInstSrcUnOp *instruction = ir_build_instruction<IrInstSrcUnOp>(irb, scope, source_node); |
| 2091 | instruction->op_id = op_id; | 2594 | instruction->op_id = op_id; |
| 2092 | instruction->value = value; | 2595 | instruction->value = value; |
| 2093 | instruction->lval = lval; | 2596 | instruction->lval = lval; |
| ... | @@ -2098,36 +2601,73 @@ static IrInstruction *ir_build_un_op_lval(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2098,36 +2601,73 @@ static IrInstruction *ir_build_un_op_lval(IrBuilder *irb, Scope *scope, AstNode |
| 2098 | return &instruction->base; | 2601 | return &instruction->base; |
| 2099 | } | 2602 | } |
| 2100 | | 2603 | |
| 2101 | static IrInstruction *ir_build_un_op(IrBuilder *irb, Scope *scope, AstNode *source_node, IrUnOp op_id, | 2604 | static IrInstSrc *ir_build_un_op(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrUnOp op_id, |
| 2102 | IrInstruction *value) | 2605 | IrInstSrc *value) |
| 2103 | { | 2606 | { |
| 2104 | return ir_build_un_op_lval(irb, scope, source_node, op_id, value, LValNone, nullptr); | 2607 | return ir_build_un_op_lval(irb, scope, source_node, op_id, value, LValNone, nullptr); |
| 2105 | } | 2608 | } |
| 2106 | | 2609 | |
| 2107 | static IrInstruction *ir_build_container_init_list(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2610 | static IrInstGen *ir_build_negation(IrAnalyze *ira, IrInst *source_instr, IrInstGen *operand, ZigType *expr_type) { |
| 2108 | size_t item_count, IrInstruction **elem_result_loc_list, IrInstruction *result_loc, | 2611 | IrInstGenNegation *instruction = ir_build_inst_gen<IrInstGenNegation>(&ira->new_irb, |
| 2109 | AstNode *init_array_type_source_node) | 2612 | source_instr->scope, source_instr->source_node); |
| 2110 | { | 2613 | instruction->base.value->type = expr_type; |
| 2111 | IrInstructionContainerInitList *container_init_list_instruction = | 2614 | instruction->operand = operand; |
| 2112 | ir_build_instruction<IrInstructionContainerInitList>(irb, scope, source_node); | | |
| 2113 | container_init_list_instruction->item_count = item_count; | | |
| 2114 | container_init_list_instruction->elem_result_loc_list = elem_result_loc_list; | | |
| 2115 | container_init_list_instruction->result_loc = result_loc; | | |
| 2116 | container_init_list_instruction->init_array_type_source_node = init_array_type_source_node; | | |
| 2117 | | 2615 | |
| 2118 | for (size_t i = 0; i < item_count; i += 1) { | 2616 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 2119 | ir_ref_instruction(elem_result_loc_list[i], irb->current_basic_block); | 2617 | |
| | 2618 | return &instruction->base; |
| | 2619 | } |
| | 2620 | |
| | 2621 | static IrInstGen *ir_build_negation_wrapping(IrAnalyze *ira, IrInst *source_instr, IrInstGen *operand, |
| | 2622 | ZigType *expr_type) |
| | 2623 | { |
| | 2624 | IrInstGenNegationWrapping *instruction = ir_build_inst_gen<IrInstGenNegationWrapping>(&ira->new_irb, |
| | 2625 | source_instr->scope, source_instr->source_node); |
| | 2626 | instruction->base.value->type = expr_type; |
| | 2627 | instruction->operand = operand; |
| | 2628 | |
| | 2629 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| | 2630 | |
| | 2631 | return &instruction->base; |
| | 2632 | } |
| | 2633 | |
| | 2634 | static IrInstGen *ir_build_binary_not(IrAnalyze *ira, IrInst *source_instr, IrInstGen *operand, |
| | 2635 | ZigType *expr_type) |
| | 2636 | { |
| | 2637 | IrInstGenBinaryNot *instruction = ir_build_inst_gen<IrInstGenBinaryNot>(&ira->new_irb, |
| | 2638 | source_instr->scope, source_instr->source_node); |
| | 2639 | instruction->base.value->type = expr_type; |
| | 2640 | instruction->operand = operand; |
| | 2641 | |
| | 2642 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| | 2643 | |
| | 2644 | return &instruction->base; |
| | 2645 | } |
| | 2646 | |
| | 2647 | static IrInstSrc *ir_build_container_init_list(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 2648 | size_t item_count, IrInstSrc **elem_result_loc_list, IrInstSrc *result_loc, |
| | 2649 | AstNode *init_array_type_source_node) |
| | 2650 | { |
| | 2651 | IrInstSrcContainerInitList *container_init_list_instruction = |
| | 2652 | ir_build_instruction<IrInstSrcContainerInitList>(irb, scope, source_node); |
| | 2653 | container_init_list_instruction->item_count = item_count; |
| | 2654 | container_init_list_instruction->elem_result_loc_list = elem_result_loc_list; |
| | 2655 | container_init_list_instruction->result_loc = result_loc; |
| | 2656 | container_init_list_instruction->init_array_type_source_node = init_array_type_source_node; |
| | 2657 | |
| | 2658 | for (size_t i = 0; i < item_count; i += 1) { |
| | 2659 | ir_ref_instruction(elem_result_loc_list[i], irb->current_basic_block); |
| 2120 | } | 2660 | } |
| 2121 | if (result_loc != nullptr) ir_ref_instruction(result_loc, irb->current_basic_block); | 2661 | if (result_loc != nullptr) ir_ref_instruction(result_loc, irb->current_basic_block); |
| 2122 | | 2662 | |
| 2123 | return &container_init_list_instruction->base; | 2663 | return &container_init_list_instruction->base; |
| 2124 | } | 2664 | } |
| 2125 | | 2665 | |
| 2126 | static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2666 | static IrInstSrc *ir_build_container_init_fields(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2127 | size_t field_count, IrInstructionContainerInitFieldsField *fields, IrInstruction *result_loc) | 2667 | size_t field_count, IrInstSrcContainerInitFieldsField *fields, IrInstSrc *result_loc) |
| 2128 | { | 2668 | { |
| 2129 | IrInstructionContainerInitFields *container_init_fields_instruction = | 2669 | IrInstSrcContainerInitFields *container_init_fields_instruction = |
| 2130 | ir_build_instruction<IrInstructionContainerInitFields>(irb, scope, source_node); | 2670 | ir_build_instruction<IrInstSrcContainerInitFields>(irb, scope, source_node); |
| 2131 | container_init_fields_instruction->field_count = field_count; | 2671 | container_init_fields_instruction->field_count = field_count; |
| 2132 | container_init_fields_instruction->fields = fields; | 2672 | container_init_fields_instruction->fields = fields; |
| 2133 | container_init_fields_instruction->result_loc = result_loc; | 2673 | container_init_fields_instruction->result_loc = result_loc; |
| ... | @@ -2140,20 +2680,21 @@ static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scop | ... | @@ -2140,20 +2680,21 @@ static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scop |
| 2140 | return &container_init_fields_instruction->base; | 2680 | return &container_init_fields_instruction->base; |
| 2141 | } | 2681 | } |
| 2142 | | 2682 | |
| 2143 | static IrInstruction *ir_build_unreachable(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 2683 | static IrInstSrc *ir_build_unreachable(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 2144 | IrInstructionUnreachable *unreachable_instruction = | 2684 | IrInstSrcUnreachable *inst = ir_build_instruction<IrInstSrcUnreachable>(irb, scope, source_node); |
| 2145 | ir_build_instruction<IrInstructionUnreachable>(irb, scope, source_node); | 2685 | inst->base.is_noreturn = true; |
| 2146 | unreachable_instruction->base.value->special = ConstValSpecialStatic; | 2686 | return &inst->base; |
| 2147 | unreachable_instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; | 2687 | } |
| 2148 | return &unreachable_instruction->base; | 2688 | |
| | 2689 | static IrInstGen *ir_build_unreachable_gen(IrAnalyze *ira, IrInst *source_instr) { |
| | 2690 | IrInstGenUnreachable *inst = ir_build_inst_noreturn<IrInstGenUnreachable>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| | 2691 | return &inst->base; |
| 2149 | } | 2692 | } |
| 2150 | | 2693 | |
| 2151 | static IrInstructionStorePtr *ir_build_store_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2694 | static IrInstSrcStorePtr *ir_build_store_ptr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2152 | IrInstruction *ptr, IrInstruction *value) | 2695 | IrInstSrc *ptr, IrInstSrc *value) |
| 2153 | { | 2696 | { |
| 2154 | IrInstructionStorePtr *instruction = ir_build_instruction<IrInstructionStorePtr>(irb, scope, source_node); | 2697 | IrInstSrcStorePtr *instruction = ir_build_instruction<IrInstSrcStorePtr>(irb, scope, source_node); |
| 2155 | instruction->base.value->special = ConstValSpecialStatic; | | |
| 2156 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; | | |
| 2157 | instruction->ptr = ptr; | 2698 | instruction->ptr = ptr; |
| 2158 | instruction->value = value; | 2699 | instruction->value = value; |
| 2159 | | 2700 | |
| ... | @@ -2163,76 +2704,83 @@ static IrInstructionStorePtr *ir_build_store_ptr(IrBuilder *irb, Scope *scope, A | ... | @@ -2163,76 +2704,83 @@ static IrInstructionStorePtr *ir_build_store_ptr(IrBuilder *irb, Scope *scope, A |
| 2163 | return instruction; | 2704 | return instruction; |
| 2164 | } | 2705 | } |
| 2165 | | 2706 | |
| 2166 | static IrInstruction *ir_build_vector_store_elem(IrAnalyze *ira, IrInstruction *source_instruction, | 2707 | static IrInstGen *ir_build_store_ptr_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *ptr, IrInstGen *value) { |
| 2167 | IrInstruction *vector_ptr, IrInstruction *index, IrInstruction *value) | 2708 | IrInstGenStorePtr *instruction = ir_build_inst_void<IrInstGenStorePtr>(&ira->new_irb, |
| | 2709 | source_instr->scope, source_instr->source_node); |
| | 2710 | instruction->ptr = ptr; |
| | 2711 | instruction->value = value; |
| | 2712 | |
| | 2713 | ir_ref_inst_gen(ptr, ira->new_irb.current_basic_block); |
| | 2714 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| | 2715 | |
| | 2716 | return &instruction->base; |
| | 2717 | } |
| | 2718 | |
| | 2719 | static IrInstGen *ir_build_vector_store_elem(IrAnalyze *ira, IrInst *src_inst, |
| | 2720 | IrInstGen *vector_ptr, IrInstGen *index, IrInstGen *value) |
| 2168 | { | 2721 | { |
| 2169 | IrInstructionVectorStoreElem *inst = ir_build_instruction<IrInstructionVectorStoreElem>( | 2722 | IrInstGenVectorStoreElem *inst = ir_build_inst_void<IrInstGenVectorStoreElem>( |
| 2170 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 2723 | &ira->new_irb, src_inst->scope, src_inst->source_node); |
| 2171 | inst->base.value->type = ira->codegen->builtin_types.entry_void; | | |
| 2172 | inst->vector_ptr = vector_ptr; | 2724 | inst->vector_ptr = vector_ptr; |
| 2173 | inst->index = index; | 2725 | inst->index = index; |
| 2174 | inst->value = value; | 2726 | inst->value = value; |
| 2175 | | 2727 | |
| 2176 | ir_ref_instruction(vector_ptr, ira->new_irb.current_basic_block); | 2728 | ir_ref_inst_gen(vector_ptr, ira->new_irb.current_basic_block); |
| 2177 | ir_ref_instruction(index, ira->new_irb.current_basic_block); | 2729 | ir_ref_inst_gen(index, ira->new_irb.current_basic_block); |
| 2178 | ir_ref_instruction(value, ira->new_irb.current_basic_block); | 2730 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| 2179 | | 2731 | |
| 2180 | return &inst->base; | 2732 | return &inst->base; |
| 2181 | } | 2733 | } |
| 2182 | | 2734 | |
| 2183 | static IrInstruction *ir_build_var_decl_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2735 | static IrInstSrc *ir_build_var_decl_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2184 | ZigVar *var, IrInstruction *align_value, IrInstruction *ptr) | 2736 | ZigVar *var, IrInstSrc *align_value, IrInstSrc *ptr) |
| 2185 | { | 2737 | { |
| 2186 | IrInstructionDeclVarSrc *decl_var_instruction = ir_build_instruction<IrInstructionDeclVarSrc>(irb, scope, source_node); | 2738 | IrInstSrcDeclVar *inst = ir_build_instruction<IrInstSrcDeclVar>(irb, scope, source_node); |
| 2187 | decl_var_instruction->base.value->special = ConstValSpecialStatic; | 2739 | inst->var = var; |
| 2188 | decl_var_instruction->base.value->type = irb->codegen->builtin_types.entry_void; | 2740 | inst->align_value = align_value; |
| 2189 | decl_var_instruction->var = var; | 2741 | inst->ptr = ptr; |
| 2190 | decl_var_instruction->align_value = align_value; | | |
| 2191 | decl_var_instruction->ptr = ptr; | | |
| 2192 | | 2742 | |
| 2193 | if (align_value != nullptr) ir_ref_instruction(align_value, irb->current_basic_block); | 2743 | if (align_value != nullptr) ir_ref_instruction(align_value, irb->current_basic_block); |
| 2194 | ir_ref_instruction(ptr, irb->current_basic_block); | 2744 | ir_ref_instruction(ptr, irb->current_basic_block); |
| 2195 | | 2745 | |
| 2196 | return &decl_var_instruction->base; | 2746 | return &inst->base; |
| 2197 | } | 2747 | } |
| 2198 | | 2748 | |
| 2199 | static IrInstruction *ir_build_var_decl_gen(IrAnalyze *ira, IrInstruction *source_instruction, | 2749 | static IrInstGen *ir_build_var_decl_gen(IrAnalyze *ira, IrInst *source_instruction, |
| 2200 | ZigVar *var, IrInstruction *var_ptr) | 2750 | ZigVar *var, IrInstGen *var_ptr) |
| 2201 | { | 2751 | { |
| 2202 | IrInstructionDeclVarGen *decl_var_instruction = ir_build_instruction<IrInstructionDeclVarGen>(&ira->new_irb, | 2752 | IrInstGenDeclVar *inst = ir_build_inst_gen<IrInstGenDeclVar>(&ira->new_irb, |
| 2203 | source_instruction->scope, source_instruction->source_node); | 2753 | source_instruction->scope, source_instruction->source_node); |
| 2204 | decl_var_instruction->base.value->special = ConstValSpecialStatic; | 2754 | inst->base.value->special = ConstValSpecialStatic; |
| 2205 | decl_var_instruction->base.value->type = ira->codegen->builtin_types.entry_void; | 2755 | inst->base.value->type = ira->codegen->builtin_types.entry_void; |
| 2206 | decl_var_instruction->var = var; | 2756 | inst->var = var; |
| 2207 | decl_var_instruction->var_ptr = var_ptr; | 2757 | inst->var_ptr = var_ptr; |
| 2208 | | 2758 | |
| 2209 | ir_ref_instruction(var_ptr, ira->new_irb.current_basic_block); | 2759 | ir_ref_inst_gen(var_ptr, ira->new_irb.current_basic_block); |
| 2210 | | 2760 | |
| 2211 | return &decl_var_instruction->base; | 2761 | return &inst->base; |
| 2212 | } | 2762 | } |
| 2213 | | 2763 | |
| 2214 | static IrInstruction *ir_build_resize_slice(IrAnalyze *ira, IrInstruction *source_instruction, | 2764 | static IrInstGen *ir_build_resize_slice(IrAnalyze *ira, IrInst *source_instruction, |
| 2215 | IrInstruction *operand, ZigType *ty, IrInstruction *result_loc) | 2765 | IrInstGen *operand, ZigType *ty, IrInstGen *result_loc) |
| 2216 | { | 2766 | { |
| 2217 | IrInstructionResizeSlice *instruction = ir_build_instruction<IrInstructionResizeSlice>(&ira->new_irb, | 2767 | IrInstGenResizeSlice *instruction = ir_build_inst_gen<IrInstGenResizeSlice>(&ira->new_irb, |
| 2218 | source_instruction->scope, source_instruction->source_node); | 2768 | source_instruction->scope, source_instruction->source_node); |
| 2219 | instruction->base.value->type = ty; | 2769 | instruction->base.value->type = ty; |
| 2220 | instruction->operand = operand; | 2770 | instruction->operand = operand; |
| 2221 | instruction->result_loc = result_loc; | 2771 | instruction->result_loc = result_loc; |
| 2222 | | 2772 | |
| 2223 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); | 2773 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 2224 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 2774 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 2225 | | 2775 | |
| 2226 | return &instruction->base; | 2776 | return &instruction->base; |
| 2227 | } | 2777 | } |
| 2228 | | 2778 | |
| 2229 | static IrInstruction *ir_build_export(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2779 | static IrInstSrc *ir_build_export(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2230 | IrInstruction *target, IrInstruction *options) | 2780 | IrInstSrc *target, IrInstSrc *options) |
| 2231 | { | 2781 | { |
| 2232 | IrInstructionExport *export_instruction = ir_build_instruction<IrInstructionExport>( | 2782 | IrInstSrcExport *export_instruction = ir_build_instruction<IrInstSrcExport>( |
| 2233 | irb, scope, source_node); | 2783 | irb, scope, source_node); |
| 2234 | export_instruction->base.value->special = ConstValSpecialStatic; | | |
| 2235 | export_instruction->base.value->type = irb->codegen->builtin_types.entry_void; | | |
| 2236 | export_instruction->target = target; | 2784 | export_instruction->target = target; |
| 2237 | export_instruction->options = options; | 2785 | export_instruction->options = options; |
| 2238 | | 2786 | |
| ... | @@ -2242,8 +2790,8 @@ static IrInstruction *ir_build_export(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -2242,8 +2790,8 @@ static IrInstruction *ir_build_export(IrBuilder *irb, Scope *scope, AstNode *sou |
| 2242 | return &export_instruction->base; | 2790 | return &export_instruction->base; |
| 2243 | } | 2791 | } |
| 2244 | | 2792 | |
| 2245 | static IrInstruction *ir_build_load_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *ptr) { | 2793 | static IrInstSrc *ir_build_load_ptr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *ptr) { |
| 2246 | IrInstructionLoadPtr *instruction = ir_build_instruction<IrInstructionLoadPtr>(irb, scope, source_node); | 2794 | IrInstSrcLoadPtr *instruction = ir_build_instruction<IrInstSrcLoadPtr>(irb, scope, source_node); |
| 2247 | instruction->ptr = ptr; | 2795 | instruction->ptr = ptr; |
| 2248 | | 2796 | |
| 2249 | ir_ref_instruction(ptr, irb->current_basic_block); | 2797 | ir_ref_instruction(ptr, irb->current_basic_block); |
| ... | @@ -2251,8 +2799,23 @@ static IrInstruction *ir_build_load_ptr(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2251,8 +2799,23 @@ static IrInstruction *ir_build_load_ptr(IrBuilder *irb, Scope *scope, AstNode *s |
| 2251 | return &instruction->base; | 2799 | return &instruction->base; |
| 2252 | } | 2800 | } |
| 2253 | | 2801 | |
| 2254 | static IrInstruction *ir_build_typeof(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *value) { | 2802 | static IrInstGen *ir_build_load_ptr_gen(IrAnalyze *ira, IrInst *source_instruction, |
| 2255 | IrInstructionTypeOf *instruction = ir_build_instruction<IrInstructionTypeOf>(irb, scope, source_node); | 2803 | IrInstGen *ptr, ZigType *ty, IrInstGen *result_loc) |
| | 2804 | { |
| | 2805 | IrInstGenLoadPtr *instruction = ir_build_inst_gen<IrInstGenLoadPtr>( |
| | 2806 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| | 2807 | instruction->base.value->type = ty; |
| | 2808 | instruction->ptr = ptr; |
| | 2809 | instruction->result_loc = result_loc; |
| | 2810 | |
| | 2811 | ir_ref_inst_gen(ptr, ira->new_irb.current_basic_block); |
| | 2812 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| | 2813 | |
| | 2814 | return &instruction->base; |
| | 2815 | } |
| | 2816 | |
| | 2817 | static IrInstSrc *ir_build_typeof(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *value) { |
| | 2818 | IrInstSrcTypeOf *instruction = ir_build_instruction<IrInstSrcTypeOf>(irb, scope, source_node); |
| 2256 | instruction->value = value; | 2819 | instruction->value = value; |
| 2257 | | 2820 | |
| 2258 | ir_ref_instruction(value, irb->current_basic_block); | 2821 | ir_ref_instruction(value, irb->current_basic_block); |
| ... | @@ -2260,8 +2823,8 @@ static IrInstruction *ir_build_typeof(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -2260,8 +2823,8 @@ static IrInstruction *ir_build_typeof(IrBuilder *irb, Scope *scope, AstNode *sou |
| 2260 | return &instruction->base; | 2823 | return &instruction->base; |
| 2261 | } | 2824 | } |
| 2262 | | 2825 | |
| 2263 | static IrInstruction *ir_build_set_cold(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *is_cold) { | 2826 | static IrInstSrc *ir_build_set_cold(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *is_cold) { |
| 2264 | IrInstructionSetCold *instruction = ir_build_instruction<IrInstructionSetCold>(irb, scope, source_node); | 2827 | IrInstSrcSetCold *instruction = ir_build_instruction<IrInstSrcSetCold>(irb, scope, source_node); |
| 2265 | instruction->is_cold = is_cold; | 2828 | instruction->is_cold = is_cold; |
| 2266 | | 2829 | |
| 2267 | ir_ref_instruction(is_cold, irb->current_basic_block); | 2830 | ir_ref_instruction(is_cold, irb->current_basic_block); |
| ... | @@ -2269,21 +2832,21 @@ static IrInstruction *ir_build_set_cold(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2269,21 +2832,21 @@ static IrInstruction *ir_build_set_cold(IrBuilder *irb, Scope *scope, AstNode *s |
| 2269 | return &instruction->base; | 2832 | return &instruction->base; |
| 2270 | } | 2833 | } |
| 2271 | | 2834 | |
| 2272 | static IrInstruction *ir_build_set_runtime_safety(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2835 | static IrInstSrc *ir_build_set_runtime_safety(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2273 | IrInstruction *safety_on) | 2836 | IrInstSrc *safety_on) |
| 2274 | { | 2837 | { |
| 2275 | IrInstructionSetRuntimeSafety *instruction = ir_build_instruction<IrInstructionSetRuntimeSafety>(irb, scope, source_node); | 2838 | IrInstSrcSetRuntimeSafety *inst = ir_build_instruction<IrInstSrcSetRuntimeSafety>(irb, scope, source_node); |
| 2276 | instruction->safety_on = safety_on; | 2839 | inst->safety_on = safety_on; |
| 2277 | | 2840 | |
| 2278 | ir_ref_instruction(safety_on, irb->current_basic_block); | 2841 | ir_ref_instruction(safety_on, irb->current_basic_block); |
| 2279 | | 2842 | |
| 2280 | return &instruction->base; | 2843 | return &inst->base; |
| 2281 | } | 2844 | } |
| 2282 | | 2845 | |
| 2283 | static IrInstruction *ir_build_set_float_mode(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2846 | static IrInstSrc *ir_build_set_float_mode(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2284 | IrInstruction *mode_value) | 2847 | IrInstSrc *mode_value) |
| 2285 | { | 2848 | { |
| 2286 | IrInstructionSetFloatMode *instruction = ir_build_instruction<IrInstructionSetFloatMode>(irb, scope, source_node); | 2849 | IrInstSrcSetFloatMode *instruction = ir_build_instruction<IrInstSrcSetFloatMode>(irb, scope, source_node); |
| 2287 | instruction->mode_value = mode_value; | 2850 | instruction->mode_value = mode_value; |
| 2288 | | 2851 | |
| 2289 | ir_ref_instruction(mode_value, irb->current_basic_block); | 2852 | ir_ref_instruction(mode_value, irb->current_basic_block); |
| ... | @@ -2291,10 +2854,10 @@ static IrInstruction *ir_build_set_float_mode(IrBuilder *irb, Scope *scope, AstN | ... | @@ -2291,10 +2854,10 @@ static IrInstruction *ir_build_set_float_mode(IrBuilder *irb, Scope *scope, AstN |
| 2291 | return &instruction->base; | 2854 | return &instruction->base; |
| 2292 | } | 2855 | } |
| 2293 | | 2856 | |
| 2294 | static IrInstruction *ir_build_array_type(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *size, | 2857 | static IrInstSrc *ir_build_array_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *size, |
| 2295 | IrInstruction *sentinel, IrInstruction *child_type) | 2858 | IrInstSrc *sentinel, IrInstSrc *child_type) |
| 2296 | { | 2859 | { |
| 2297 | IrInstructionArrayType *instruction = ir_build_instruction<IrInstructionArrayType>(irb, scope, source_node); | 2860 | IrInstSrcArrayType *instruction = ir_build_instruction<IrInstSrcArrayType>(irb, scope, source_node); |
| 2298 | instruction->size = size; | 2861 | instruction->size = size; |
| 2299 | instruction->sentinel = sentinel; | 2862 | instruction->sentinel = sentinel; |
| 2300 | instruction->child_type = child_type; | 2863 | instruction->child_type = child_type; |
| ... | @@ -2306,10 +2869,10 @@ static IrInstruction *ir_build_array_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2306,10 +2869,10 @@ static IrInstruction *ir_build_array_type(IrBuilder *irb, Scope *scope, AstNode |
| 2306 | return &instruction->base; | 2869 | return &instruction->base; |
| 2307 | } | 2870 | } |
| 2308 | | 2871 | |
| 2309 | static IrInstruction *ir_build_anyframe_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2872 | static IrInstSrc *ir_build_anyframe_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2310 | IrInstruction *payload_type) | 2873 | IrInstSrc *payload_type) |
| 2311 | { | 2874 | { |
| 2312 | IrInstructionAnyFrameType *instruction = ir_build_instruction<IrInstructionAnyFrameType>(irb, scope, source_node); | 2875 | IrInstSrcAnyFrameType *instruction = ir_build_instruction<IrInstSrcAnyFrameType>(irb, scope, source_node); |
| 2313 | instruction->payload_type = payload_type; | 2876 | instruction->payload_type = payload_type; |
| 2314 | | 2877 | |
| 2315 | if (payload_type != nullptr) ir_ref_instruction(payload_type, irb->current_basic_block); | 2878 | if (payload_type != nullptr) ir_ref_instruction(payload_type, irb->current_basic_block); |
| ... | @@ -2317,11 +2880,11 @@ static IrInstruction *ir_build_anyframe_type(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -2317,11 +2880,11 @@ static IrInstruction *ir_build_anyframe_type(IrBuilder *irb, Scope *scope, AstNo |
| 2317 | return &instruction->base; | 2880 | return &instruction->base; |
| 2318 | } | 2881 | } |
| 2319 | | 2882 | |
| 2320 | static IrInstruction *ir_build_slice_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2883 | static IrInstSrc *ir_build_slice_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2321 | IrInstruction *child_type, bool is_const, bool is_volatile, | 2884 | IrInstSrc *child_type, bool is_const, bool is_volatile, |
| 2322 | IrInstruction *sentinel, IrInstruction *align_value, bool is_allow_zero) | 2885 | IrInstSrc *sentinel, IrInstSrc *align_value, bool is_allow_zero) |
| 2323 | { | 2886 | { |
| 2324 | IrInstructionSliceType *instruction = ir_build_instruction<IrInstructionSliceType>(irb, scope, source_node); | 2887 | IrInstSrcSliceType *instruction = ir_build_instruction<IrInstSrcSliceType>(irb, scope, source_node); |
| 2325 | instruction->is_const = is_const; | 2888 | instruction->is_const = is_const; |
| 2326 | instruction->is_volatile = is_volatile; | 2889 | instruction->is_volatile = is_volatile; |
| 2327 | instruction->child_type = child_type; | 2890 | instruction->child_type = child_type; |
| ... | @@ -2336,11 +2899,11 @@ static IrInstruction *ir_build_slice_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2336,11 +2899,11 @@ static IrInstruction *ir_build_slice_type(IrBuilder *irb, Scope *scope, AstNode |
| 2336 | return &instruction->base; | 2899 | return &instruction->base; |
| 2337 | } | 2900 | } |
| 2338 | | 2901 | |
| 2339 | static IrInstruction *ir_build_asm_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2902 | static IrInstSrc *ir_build_asm_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2340 | IrInstruction *asm_template, IrInstruction **input_list, IrInstruction **output_types, | 2903 | IrInstSrc *asm_template, IrInstSrc **input_list, IrInstSrc **output_types, |
| 2341 | ZigVar **output_vars, size_t return_count, bool has_side_effects, bool is_global) | 2904 | ZigVar **output_vars, size_t return_count, bool has_side_effects, bool is_global) |
| 2342 | { | 2905 | { |
| 2343 | IrInstructionAsmSrc *instruction = ir_build_instruction<IrInstructionAsmSrc>(irb, scope, source_node); | 2906 | IrInstSrcAsm *instruction = ir_build_instruction<IrInstSrcAsm>(irb, scope, source_node); |
| 2344 | instruction->asm_template = asm_template; | 2907 | instruction->asm_template = asm_template; |
| 2345 | instruction->input_list = input_list; | 2908 | instruction->input_list = input_list; |
| 2346 | instruction->output_types = output_types; | 2909 | instruction->output_types = output_types; |
| ... | @@ -2351,24 +2914,25 @@ static IrInstruction *ir_build_asm_src(IrBuilder *irb, Scope *scope, AstNode *so | ... | @@ -2351,24 +2914,25 @@ static IrInstruction *ir_build_asm_src(IrBuilder *irb, Scope *scope, AstNode *so |
| 2351 | | 2914 | |
| 2352 | assert(source_node->type == NodeTypeAsmExpr); | 2915 | assert(source_node->type == NodeTypeAsmExpr); |
| 2353 | for (size_t i = 0; i < source_node->data.asm_expr.output_list.length; i += 1) { | 2916 | for (size_t i = 0; i < source_node->data.asm_expr.output_list.length; i += 1) { |
| 2354 | IrInstruction *output_type = output_types[i]; | 2917 | IrInstSrc *output_type = output_types[i]; |
| 2355 | if (output_type) ir_ref_instruction(output_type, irb->current_basic_block); | 2918 | if (output_type) ir_ref_instruction(output_type, irb->current_basic_block); |
| 2356 | } | 2919 | } |
| 2357 | | 2920 | |
| 2358 | for (size_t i = 0; i < source_node->data.asm_expr.input_list.length; i += 1) { | 2921 | for (size_t i = 0; i < source_node->data.asm_expr.input_list.length; i += 1) { |
| 2359 | IrInstruction *input_value = input_list[i]; | 2922 | IrInstSrc *input_value = input_list[i]; |
| 2360 | ir_ref_instruction(input_value, irb->current_basic_block); | 2923 | ir_ref_instruction(input_value, irb->current_basic_block); |
| 2361 | } | 2924 | } |
| 2362 | | 2925 | |
| 2363 | return &instruction->base; | 2926 | return &instruction->base; |
| 2364 | } | 2927 | } |
| 2365 | | 2928 | |
| 2366 | static IrInstruction *ir_build_asm_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, | 2929 | static IrInstGen *ir_build_asm_gen(IrAnalyze *ira, IrInst *source_instr, |
| 2367 | Buf *asm_template, AsmToken *token_list, size_t token_list_len, | 2930 | Buf *asm_template, AsmToken *token_list, size_t token_list_len, |
| 2368 | IrInstruction **input_list, IrInstruction **output_types, ZigVar **output_vars, size_t return_count, | 2931 | IrInstGen **input_list, IrInstGen **output_types, ZigVar **output_vars, size_t return_count, |
| 2369 | bool has_side_effects) | 2932 | bool has_side_effects, ZigType *return_type) |
| 2370 | { | 2933 | { |
| 2371 | IrInstructionAsmGen *instruction = ir_build_instruction<IrInstructionAsmGen>(&ira->new_irb, scope, source_node); | 2934 | IrInstGenAsm *instruction = ir_build_inst_gen<IrInstGenAsm>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| | 2935 | instruction->base.value->type = return_type; |
| 2372 | instruction->asm_template = asm_template; | 2936 | instruction->asm_template = asm_template; |
| 2373 | instruction->token_list = token_list; | 2937 | instruction->token_list = token_list; |
| 2374 | instruction->token_list_len = token_list_len; | 2938 | instruction->token_list_len = token_list_len; |
| ... | @@ -2378,22 +2942,24 @@ static IrInstruction *ir_build_asm_gen(IrAnalyze *ira, Scope *scope, AstNode *so | ... | @@ -2378,22 +2942,24 @@ static IrInstruction *ir_build_asm_gen(IrAnalyze *ira, Scope *scope, AstNode *so |
| 2378 | instruction->return_count = return_count; | 2942 | instruction->return_count = return_count; |
| 2379 | instruction->has_side_effects = has_side_effects; | 2943 | instruction->has_side_effects = has_side_effects; |
| 2380 | | 2944 | |
| 2381 | assert(source_node->type == NodeTypeAsmExpr); | 2945 | assert(source_instr->source_node->type == NodeTypeAsmExpr); |
| 2382 | for (size_t i = 0; i < source_node->data.asm_expr.output_list.length; i += 1) { | 2946 | for (size_t i = 0; i < source_instr->source_node->data.asm_expr.output_list.length; i += 1) { |
| 2383 | IrInstruction *output_type = output_types[i]; | 2947 | IrInstGen *output_type = output_types[i]; |
| 2384 | if (output_type) ir_ref_instruction(output_type, ira->new_irb.current_basic_block); | 2948 | if (output_type) ir_ref_inst_gen(output_type, ira->new_irb.current_basic_block); |
| 2385 | } | 2949 | } |
| 2386 | | 2950 | |
| 2387 | for (size_t i = 0; i < source_node->data.asm_expr.input_list.length; i += 1) { | 2951 | for (size_t i = 0; i < source_instr->source_node->data.asm_expr.input_list.length; i += 1) { |
| 2388 | IrInstruction *input_value = input_list[i]; | 2952 | IrInstGen *input_value = input_list[i]; |
| 2389 | ir_ref_instruction(input_value, ira->new_irb.current_basic_block); | 2953 | ir_ref_inst_gen(input_value, ira->new_irb.current_basic_block); |
| 2390 | } | 2954 | } |
| 2391 | | 2955 | |
| 2392 | return &instruction->base; | 2956 | return &instruction->base; |
| 2393 | } | 2957 | } |
| 2394 | | 2958 | |
| 2395 | static IrInstruction *ir_build_size_of(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *type_value, bool bit_size) { | 2959 | static IrInstSrc *ir_build_size_of(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type_value, |
| 2396 | IrInstructionSizeOf *instruction = ir_build_instruction<IrInstructionSizeOf>(irb, scope, source_node); | 2960 | bool bit_size) |
| | 2961 | { |
| | 2962 | IrInstSrcSizeOf *instruction = ir_build_instruction<IrInstSrcSizeOf>(irb, scope, source_node); |
| 2397 | instruction->type_value = type_value; | 2963 | instruction->type_value = type_value; |
| 2398 | instruction->bit_size = bit_size; | 2964 | instruction->bit_size = bit_size; |
| 2399 | | 2965 | |
| ... | @@ -2402,8 +2968,10 @@ static IrInstruction *ir_build_size_of(IrBuilder *irb, Scope *scope, AstNode *so | ... | @@ -2402,8 +2968,10 @@ static IrInstruction *ir_build_size_of(IrBuilder *irb, Scope *scope, AstNode *so |
| 2402 | return &instruction->base; | 2968 | return &instruction->base; |
| 2403 | } | 2969 | } |
| 2404 | | 2970 | |
| 2405 | static IrInstruction *ir_build_test_nonnull(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *value) { | 2971 | static IrInstSrc *ir_build_test_non_null_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2406 | IrInstructionTestNonNull *instruction = ir_build_instruction<IrInstructionTestNonNull>(irb, scope, source_node); | 2972 | IrInstSrc *value) |
| | 2973 | { |
| | 2974 | IrInstSrcTestNonNull *instruction = ir_build_instruction<IrInstSrcTestNonNull>(irb, scope, source_node); |
| 2407 | instruction->value = value; | 2975 | instruction->value = value; |
| 2408 | | 2976 | |
| 2409 | ir_ref_instruction(value, irb->current_basic_block); | 2977 | ir_ref_instruction(value, irb->current_basic_block); |
| ... | @@ -2411,10 +2979,21 @@ static IrInstruction *ir_build_test_nonnull(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -2411,10 +2979,21 @@ static IrInstruction *ir_build_test_nonnull(IrBuilder *irb, Scope *scope, AstNod |
| 2411 | return &instruction->base; | 2979 | return &instruction->base; |
| 2412 | } | 2980 | } |
| 2413 | | 2981 | |
| 2414 | static IrInstruction *ir_build_optional_unwrap_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 2982 | static IrInstGen *ir_build_test_non_null_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *value) { |
| 2415 | IrInstruction *base_ptr, bool safety_check_on, bool initializing) | 2983 | IrInstGenTestNonNull *inst = ir_build_inst_gen<IrInstGenTestNonNull>(&ira->new_irb, |
| | 2984 | source_instr->scope, source_instr->source_node); |
| | 2985 | inst->base.value->type = ira->codegen->builtin_types.entry_bool; |
| | 2986 | inst->value = value; |
| | 2987 | |
| | 2988 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| | 2989 | |
| | 2990 | return &inst->base; |
| | 2991 | } |
| | 2992 | |
| | 2993 | static IrInstSrc *ir_build_optional_unwrap_ptr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 2994 | IrInstSrc *base_ptr, bool safety_check_on, bool initializing) |
| 2416 | { | 2995 | { |
| 2417 | IrInstructionOptionalUnwrapPtr *instruction = ir_build_instruction<IrInstructionOptionalUnwrapPtr>(irb, scope, source_node); | 2996 | IrInstSrcOptionalUnwrapPtr *instruction = ir_build_instruction<IrInstSrcOptionalUnwrapPtr>(irb, scope, source_node); |
| 2418 | instruction->base_ptr = base_ptr; | 2997 | instruction->base_ptr = base_ptr; |
| 2419 | instruction->safety_check_on = safety_check_on; | 2998 | instruction->safety_check_on = safety_check_on; |
| 2420 | instruction->initializing = initializing; | 2999 | instruction->initializing = initializing; |
| ... | @@ -2424,113 +3003,198 @@ static IrInstruction *ir_build_optional_unwrap_ptr(IrBuilder *irb, Scope *scope, | ... | @@ -2424,113 +3003,198 @@ static IrInstruction *ir_build_optional_unwrap_ptr(IrBuilder *irb, Scope *scope, |
| 2424 | return &instruction->base; | 3003 | return &instruction->base; |
| 2425 | } | 3004 | } |
| 2426 | | 3005 | |
| 2427 | static IrInstruction *ir_build_optional_wrap(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *result_ty, | 3006 | static IrInstGen *ir_build_optional_unwrap_ptr_gen(IrAnalyze *ira, IrInst *source_instr, |
| 2428 | IrInstruction *operand, IrInstruction *result_loc) | 3007 | IrInstGen *base_ptr, bool safety_check_on, bool initializing, ZigType *result_type) |
| 2429 | { | 3008 | { |
| 2430 | IrInstructionOptionalWrap *instruction = ir_build_instruction<IrInstructionOptionalWrap>( | 3009 | IrInstGenOptionalUnwrapPtr *inst = ir_build_inst_gen<IrInstGenOptionalUnwrapPtr>(&ira->new_irb, |
| | 3010 | source_instr->scope, source_instr->source_node); |
| | 3011 | inst->base.value->type = result_type; |
| | 3012 | inst->base_ptr = base_ptr; |
| | 3013 | inst->safety_check_on = safety_check_on; |
| | 3014 | inst->initializing = initializing; |
| | 3015 | |
| | 3016 | ir_ref_inst_gen(base_ptr, ira->new_irb.current_basic_block); |
| | 3017 | |
| | 3018 | return &inst->base; |
| | 3019 | } |
| | 3020 | |
| | 3021 | static IrInstGen *ir_build_optional_wrap(IrAnalyze *ira, IrInst *source_instruction, ZigType *result_ty, |
| | 3022 | IrInstGen *operand, IrInstGen *result_loc) |
| | 3023 | { |
| | 3024 | IrInstGenOptionalWrap *instruction = ir_build_inst_gen<IrInstGenOptionalWrap>( |
| 2431 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 3025 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2432 | instruction->base.value->type = result_ty; | 3026 | instruction->base.value->type = result_ty; |
| 2433 | instruction->operand = operand; | 3027 | instruction->operand = operand; |
| 2434 | instruction->result_loc = result_loc; | 3028 | instruction->result_loc = result_loc; |
| 2435 | | 3029 | |
| 2436 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); | 3030 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 2437 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 3031 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 2438 | | 3032 | |
| 2439 | return &instruction->base; | 3033 | return &instruction->base; |
| 2440 | } | 3034 | } |
| 2441 | | 3035 | |
| 2442 | static IrInstruction *ir_build_err_wrap_payload(IrAnalyze *ira, IrInstruction *source_instruction, | 3036 | static IrInstGen *ir_build_err_wrap_payload(IrAnalyze *ira, IrInst *source_instruction, |
| 2443 | ZigType *result_type, IrInstruction *operand, IrInstruction *result_loc) | 3037 | ZigType *result_type, IrInstGen *operand, IrInstGen *result_loc) |
| 2444 | { | 3038 | { |
| 2445 | IrInstructionErrWrapPayload *instruction = ir_build_instruction<IrInstructionErrWrapPayload>( | 3039 | IrInstGenErrWrapPayload *instruction = ir_build_inst_gen<IrInstGenErrWrapPayload>( |
| 2446 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 3040 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2447 | instruction->base.value->type = result_type; | 3041 | instruction->base.value->type = result_type; |
| 2448 | instruction->operand = operand; | 3042 | instruction->operand = operand; |
| 2449 | instruction->result_loc = result_loc; | 3043 | instruction->result_loc = result_loc; |
| 2450 | | 3044 | |
| 2451 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); | 3045 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 2452 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 3046 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 2453 | | 3047 | |
| 2454 | return &instruction->base; | 3048 | return &instruction->base; |
| 2455 | } | 3049 | } |
| 2456 | | 3050 | |
| 2457 | static IrInstruction *ir_build_err_wrap_code(IrAnalyze *ira, IrInstruction *source_instruction, | 3051 | static IrInstGen *ir_build_err_wrap_code(IrAnalyze *ira, IrInst *source_instruction, |
| 2458 | ZigType *result_type, IrInstruction *operand, IrInstruction *result_loc) | 3052 | ZigType *result_type, IrInstGen *operand, IrInstGen *result_loc) |
| 2459 | { | 3053 | { |
| 2460 | IrInstructionErrWrapCode *instruction = ir_build_instruction<IrInstructionErrWrapCode>( | 3054 | IrInstGenErrWrapCode *instruction = ir_build_inst_gen<IrInstGenErrWrapCode>( |
| 2461 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 3055 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 2462 | instruction->base.value->type = result_type; | 3056 | instruction->base.value->type = result_type; |
| 2463 | instruction->operand = operand; | 3057 | instruction->operand = operand; |
| 2464 | instruction->result_loc = result_loc; | 3058 | instruction->result_loc = result_loc; |
| 2465 | | 3059 | |
| 2466 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); | 3060 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 2467 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 3061 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 2468 | | 3062 | |
| 2469 | return &instruction->base; | 3063 | return &instruction->base; |
| 2470 | } | 3064 | } |
| 2471 | | 3065 | |
| 2472 | static IrInstruction *ir_build_clz(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *type, IrInstruction *op) { | 3066 | static IrInstSrc *ir_build_clz(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type, |
| 2473 | IrInstructionClz *instruction = ir_build_instruction<IrInstructionClz>(irb, scope, source_node); | 3067 | IrInstSrc *op) |
| | 3068 | { |
| | 3069 | IrInstSrcClz *instruction = ir_build_instruction<IrInstSrcClz>(irb, scope, source_node); |
| 2474 | instruction->type = type; | 3070 | instruction->type = type; |
| 2475 | instruction->op = op; | 3071 | instruction->op = op; |
| 2476 | | 3072 | |
| 2477 | if (type != nullptr) ir_ref_instruction(type, irb->current_basic_block); | 3073 | ir_ref_instruction(type, irb->current_basic_block); |
| 2478 | ir_ref_instruction(op, irb->current_basic_block); | 3074 | ir_ref_instruction(op, irb->current_basic_block); |
| 2479 | | 3075 | |
| 2480 | return &instruction->base; | 3076 | return &instruction->base; |
| 2481 | } | 3077 | } |
| 2482 | | 3078 | |
| 2483 | static IrInstruction *ir_build_ctz(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *type, IrInstruction *op) { | 3079 | static IrInstGen *ir_build_clz_gen(IrAnalyze *ira, IrInst *source_instr, ZigType *result_type, IrInstGen *op) { |
| 2484 | IrInstructionCtz *instruction = ir_build_instruction<IrInstructionCtz>(irb, scope, source_node); | 3080 | IrInstGenClz *instruction = ir_build_inst_gen<IrInstGenClz>(&ira->new_irb, |
| | 3081 | source_instr->scope, source_instr->source_node); |
| | 3082 | instruction->base.value->type = result_type; |
| | 3083 | instruction->op = op; |
| | 3084 | |
| | 3085 | ir_ref_inst_gen(op, ira->new_irb.current_basic_block); |
| | 3086 | |
| | 3087 | return &instruction->base; |
| | 3088 | } |
| | 3089 | |
| | 3090 | static IrInstSrc *ir_build_ctz(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type, |
| | 3091 | IrInstSrc *op) |
| | 3092 | { |
| | 3093 | IrInstSrcCtz *instruction = ir_build_instruction<IrInstSrcCtz>(irb, scope, source_node); |
| 2485 | instruction->type = type; | 3094 | instruction->type = type; |
| 2486 | instruction->op = op; | 3095 | instruction->op = op; |
| 2487 | | 3096 | |
| 2488 | if (type != nullptr) ir_ref_instruction(type, irb->current_basic_block); | 3097 | ir_ref_instruction(type, irb->current_basic_block); |
| 2489 | ir_ref_instruction(op, irb->current_basic_block); | 3098 | ir_ref_instruction(op, irb->current_basic_block); |
| 2490 | | 3099 | |
| 2491 | return &instruction->base; | 3100 | return &instruction->base; |
| 2492 | } | 3101 | } |
| 2493 | | 3102 | |
| 2494 | static IrInstruction *ir_build_pop_count(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *type, IrInstruction *op) { | 3103 | static IrInstGen *ir_build_ctz_gen(IrAnalyze *ira, IrInst *source_instr, ZigType *result_type, IrInstGen *op) { |
| 2495 | IrInstructionPopCount *instruction = ir_build_instruction<IrInstructionPopCount>(irb, scope, source_node); | 3104 | IrInstGenCtz *instruction = ir_build_inst_gen<IrInstGenCtz>(&ira->new_irb, |
| | 3105 | source_instr->scope, source_instr->source_node); |
| | 3106 | instruction->base.value->type = result_type; |
| | 3107 | instruction->op = op; |
| | 3108 | |
| | 3109 | ir_ref_inst_gen(op, ira->new_irb.current_basic_block); |
| | 3110 | |
| | 3111 | return &instruction->base; |
| | 3112 | } |
| | 3113 | |
| | 3114 | static IrInstSrc *ir_build_pop_count(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type, |
| | 3115 | IrInstSrc *op) |
| | 3116 | { |
| | 3117 | IrInstSrcPopCount *instruction = ir_build_instruction<IrInstSrcPopCount>(irb, scope, source_node); |
| 2496 | instruction->type = type; | 3118 | instruction->type = type; |
| 2497 | instruction->op = op; | 3119 | instruction->op = op; |
| 2498 | | 3120 | |
| 2499 | if (type != nullptr) ir_ref_instruction(type, irb->current_basic_block); | 3121 | ir_ref_instruction(type, irb->current_basic_block); |
| 2500 | ir_ref_instruction(op, irb->current_basic_block); | 3122 | ir_ref_instruction(op, irb->current_basic_block); |
| 2501 | | 3123 | |
| 2502 | return &instruction->base; | 3124 | return &instruction->base; |
| 2503 | } | 3125 | } |
| 2504 | | 3126 | |
| 2505 | static IrInstruction *ir_build_bswap(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *type, IrInstruction *op) { | 3127 | static IrInstGen *ir_build_pop_count_gen(IrAnalyze *ira, IrInst *source_instr, ZigType *result_type, |
| 2506 | IrInstructionBswap *instruction = ir_build_instruction<IrInstructionBswap>(irb, scope, source_node); | 3128 | IrInstGen *op) |
| | 3129 | { |
| | 3130 | IrInstGenPopCount *instruction = ir_build_inst_gen<IrInstGenPopCount>(&ira->new_irb, |
| | 3131 | source_instr->scope, source_instr->source_node); |
| | 3132 | instruction->base.value->type = result_type; |
| | 3133 | instruction->op = op; |
| | 3134 | |
| | 3135 | ir_ref_inst_gen(op, ira->new_irb.current_basic_block); |
| | 3136 | |
| | 3137 | return &instruction->base; |
| | 3138 | } |
| | 3139 | |
| | 3140 | static IrInstSrc *ir_build_bswap(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type, |
| | 3141 | IrInstSrc *op) |
| | 3142 | { |
| | 3143 | IrInstSrcBswap *instruction = ir_build_instruction<IrInstSrcBswap>(irb, scope, source_node); |
| 2507 | instruction->type = type; | 3144 | instruction->type = type; |
| 2508 | instruction->op = op; | 3145 | instruction->op = op; |
| 2509 | | 3146 | |
| 2510 | if (type != nullptr) ir_ref_instruction(type, irb->current_basic_block); | 3147 | ir_ref_instruction(type, irb->current_basic_block); |
| 2511 | ir_ref_instruction(op, irb->current_basic_block); | 3148 | ir_ref_instruction(op, irb->current_basic_block); |
| 2512 | | 3149 | |
| 2513 | return &instruction->base; | 3150 | return &instruction->base; |
| 2514 | } | 3151 | } |
| 2515 | | 3152 | |
| 2516 | static IrInstruction *ir_build_bit_reverse(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *type, IrInstruction *op) { | 3153 | static IrInstGen *ir_build_bswap_gen(IrAnalyze *ira, IrInst *source_instr, ZigType *op_type, |
| 2517 | IrInstructionBitReverse *instruction = ir_build_instruction<IrInstructionBitReverse>(irb, scope, source_node); | 3154 | IrInstGen *op) |
| | 3155 | { |
| | 3156 | IrInstGenBswap *instruction = ir_build_inst_gen<IrInstGenBswap>(&ira->new_irb, |
| | 3157 | source_instr->scope, source_instr->source_node); |
| | 3158 | instruction->base.value->type = op_type; |
| | 3159 | instruction->op = op; |
| | 3160 | |
| | 3161 | ir_ref_inst_gen(op, ira->new_irb.current_basic_block); |
| | 3162 | |
| | 3163 | return &instruction->base; |
| | 3164 | } |
| | 3165 | |
| | 3166 | static IrInstSrc *ir_build_bit_reverse(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type, |
| | 3167 | IrInstSrc *op) |
| | 3168 | { |
| | 3169 | IrInstSrcBitReverse *instruction = ir_build_instruction<IrInstSrcBitReverse>(irb, scope, source_node); |
| 2518 | instruction->type = type; | 3170 | instruction->type = type; |
| 2519 | instruction->op = op; | 3171 | instruction->op = op; |
| 2520 | | 3172 | |
| 2521 | if (type != nullptr) ir_ref_instruction(type, irb->current_basic_block); | 3173 | ir_ref_instruction(type, irb->current_basic_block); |
| 2522 | ir_ref_instruction(op, irb->current_basic_block); | 3174 | ir_ref_instruction(op, irb->current_basic_block); |
| 2523 | | 3175 | |
| 2524 | return &instruction->base; | 3176 | return &instruction->base; |
| 2525 | } | 3177 | } |
| 2526 | | 3178 | |
| 2527 | static IrInstructionSwitchBr *ir_build_switch_br(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *target_value, | 3179 | static IrInstGen *ir_build_bit_reverse_gen(IrAnalyze *ira, IrInst *source_instr, ZigType *int_type, |
| 2528 | IrBasicBlock *else_block, size_t case_count, IrInstructionSwitchBrCase *cases, IrInstruction *is_comptime, | 3180 | IrInstGen *op) |
| 2529 | IrInstruction *switch_prongs_void) | | |
| 2530 | { | 3181 | { |
| 2531 | IrInstructionSwitchBr *instruction = ir_build_instruction<IrInstructionSwitchBr>(irb, scope, source_node); | 3182 | IrInstGenBitReverse *instruction = ir_build_inst_gen<IrInstGenBitReverse>(&ira->new_irb, |
| 2532 | instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; | 3183 | source_instr->scope, source_instr->source_node); |
| 2533 | instruction->base.value->special = ConstValSpecialStatic; | 3184 | instruction->base.value->type = int_type; |
| | 3185 | instruction->op = op; |
| | 3186 | |
| | 3187 | ir_ref_inst_gen(op, ira->new_irb.current_basic_block); |
| | 3188 | |
| | 3189 | return &instruction->base; |
| | 3190 | } |
| | 3191 | |
| | 3192 | static IrInstSrcSwitchBr *ir_build_switch_br_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 3193 | IrInstSrc *target_value, IrBasicBlockSrc *else_block, size_t case_count, IrInstSrcSwitchBrCase *cases, |
| | 3194 | IrInstSrc *is_comptime, IrInstSrc *switch_prongs_void) |
| | 3195 | { |
| | 3196 | IrInstSrcSwitchBr *instruction = ir_build_instruction<IrInstSrcSwitchBr>(irb, scope, source_node); |
| | 3197 | instruction->base.is_noreturn = true; |
| 2534 | instruction->target_value = target_value; | 3198 | instruction->target_value = target_value; |
| 2535 | instruction->else_block = else_block; | 3199 | instruction->else_block = else_block; |
| 2536 | instruction->case_count = case_count; | 3200 | instruction->case_count = case_count; |
| ... | @@ -2539,9 +3203,9 @@ static IrInstructionSwitchBr *ir_build_switch_br(IrBuilder *irb, Scope *scope, A | ... | @@ -2539,9 +3203,9 @@ static IrInstructionSwitchBr *ir_build_switch_br(IrBuilder *irb, Scope *scope, A |
| 2539 | instruction->switch_prongs_void = switch_prongs_void; | 3203 | instruction->switch_prongs_void = switch_prongs_void; |
| 2540 | | 3204 | |
| 2541 | ir_ref_instruction(target_value, irb->current_basic_block); | 3205 | ir_ref_instruction(target_value, irb->current_basic_block); |
| 2542 | if (is_comptime) ir_ref_instruction(is_comptime, irb->current_basic_block); | 3206 | ir_ref_instruction(is_comptime, irb->current_basic_block); |
| 2543 | ir_ref_bb(else_block); | 3207 | ir_ref_bb(else_block); |
| 2544 | if (switch_prongs_void) ir_ref_instruction(switch_prongs_void, irb->current_basic_block); | 3208 | ir_ref_instruction(switch_prongs_void, irb->current_basic_block); |
| 2545 | | 3209 | |
| 2546 | for (size_t i = 0; i < case_count; i += 1) { | 3210 | for (size_t i = 0; i < case_count; i += 1) { |
| 2547 | ir_ref_instruction(cases[i].value, irb->current_basic_block); | 3211 | ir_ref_instruction(cases[i].value, irb->current_basic_block); |
| ... | @@ -2551,10 +3215,31 @@ static IrInstructionSwitchBr *ir_build_switch_br(IrBuilder *irb, Scope *scope, A | ... | @@ -2551,10 +3215,31 @@ static IrInstructionSwitchBr *ir_build_switch_br(IrBuilder *irb, Scope *scope, A |
| 2551 | return instruction; | 3215 | return instruction; |
| 2552 | } | 3216 | } |
| 2553 | | 3217 | |
| 2554 | static IrInstruction *ir_build_switch_target(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3218 | static IrInstGenSwitchBr *ir_build_switch_br_gen(IrAnalyze *ira, IrInst *source_instr, |
| 2555 | IrInstruction *target_value_ptr) | 3219 | IrInstGen *target_value, IrBasicBlockGen *else_block, size_t case_count, IrInstGenSwitchBrCase *cases) |
| 2556 | { | 3220 | { |
| 2557 | IrInstructionSwitchTarget *instruction = ir_build_instruction<IrInstructionSwitchTarget>(irb, scope, source_node); | 3221 | IrInstGenSwitchBr *instruction = ir_build_inst_noreturn<IrInstGenSwitchBr>(&ira->new_irb, |
| | 3222 | source_instr->scope, source_instr->source_node); |
| | 3223 | instruction->target_value = target_value; |
| | 3224 | instruction->else_block = else_block; |
| | 3225 | instruction->case_count = case_count; |
| | 3226 | instruction->cases = cases; |
| | 3227 | |
| | 3228 | ir_ref_inst_gen(target_value, ira->new_irb.current_basic_block); |
| | 3229 | ir_ref_bb_gen(else_block); |
| | 3230 | |
| | 3231 | for (size_t i = 0; i < case_count; i += 1) { |
| | 3232 | ir_ref_inst_gen(cases[i].value, ira->new_irb.current_basic_block); |
| | 3233 | ir_ref_bb_gen(cases[i].block); |
| | 3234 | } |
| | 3235 | |
| | 3236 | return instruction; |
| | 3237 | } |
| | 3238 | |
| | 3239 | static IrInstSrc *ir_build_switch_target(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 3240 | IrInstSrc *target_value_ptr) |
| | 3241 | { |
| | 3242 | IrInstSrcSwitchTarget *instruction = ir_build_instruction<IrInstSrcSwitchTarget>(irb, scope, source_node); |
| 2558 | instruction->target_value_ptr = target_value_ptr; | 3243 | instruction->target_value_ptr = target_value_ptr; |
| 2559 | | 3244 | |
| 2560 | ir_ref_instruction(target_value_ptr, irb->current_basic_block); | 3245 | ir_ref_instruction(target_value_ptr, irb->current_basic_block); |
| ... | @@ -2562,10 +3247,10 @@ static IrInstruction *ir_build_switch_target(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -2562,10 +3247,10 @@ static IrInstruction *ir_build_switch_target(IrBuilder *irb, Scope *scope, AstNo |
| 2562 | return &instruction->base; | 3247 | return &instruction->base; |
| 2563 | } | 3248 | } |
| 2564 | | 3249 | |
| 2565 | static IrInstruction *ir_build_switch_var(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3250 | static IrInstSrc *ir_build_switch_var(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2566 | IrInstruction *target_value_ptr, IrInstruction **prongs_ptr, size_t prongs_len) | 3251 | IrInstSrc *target_value_ptr, IrInstSrc **prongs_ptr, size_t prongs_len) |
| 2567 | { | 3252 | { |
| 2568 | IrInstructionSwitchVar *instruction = ir_build_instruction<IrInstructionSwitchVar>(irb, scope, source_node); | 3253 | IrInstSrcSwitchVar *instruction = ir_build_instruction<IrInstSrcSwitchVar>(irb, scope, source_node); |
| 2569 | instruction->target_value_ptr = target_value_ptr; | 3254 | instruction->target_value_ptr = target_value_ptr; |
| 2570 | instruction->prongs_ptr = prongs_ptr; | 3255 | instruction->prongs_ptr = prongs_ptr; |
| 2571 | instruction->prongs_len = prongs_len; | 3256 | instruction->prongs_len = prongs_len; |
| ... | @@ -2579,10 +3264,10 @@ static IrInstruction *ir_build_switch_var(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2579,10 +3264,10 @@ static IrInstruction *ir_build_switch_var(IrBuilder *irb, Scope *scope, AstNode |
| 2579 | } | 3264 | } |
| 2580 | | 3265 | |
| 2581 | // For this instruction the switch_br must be set later. | 3266 | // For this instruction the switch_br must be set later. |
| 2582 | static IrInstructionSwitchElseVar *ir_build_switch_else_var(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3267 | static IrInstSrcSwitchElseVar *ir_build_switch_else_var(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2583 | IrInstruction *target_value_ptr) | 3268 | IrInstSrc *target_value_ptr) |
| 2584 | { | 3269 | { |
| 2585 | IrInstructionSwitchElseVar *instruction = ir_build_instruction<IrInstructionSwitchElseVar>(irb, scope, source_node); | 3270 | IrInstSrcSwitchElseVar *instruction = ir_build_instruction<IrInstSrcSwitchElseVar>(irb, scope, source_node); |
| 2586 | instruction->target_value_ptr = target_value_ptr; | 3271 | instruction->target_value_ptr = target_value_ptr; |
| 2587 | | 3272 | |
| 2588 | ir_ref_instruction(target_value_ptr, irb->current_basic_block); | 3273 | ir_ref_instruction(target_value_ptr, irb->current_basic_block); |
| ... | @@ -2590,17 +3275,21 @@ static IrInstructionSwitchElseVar *ir_build_switch_else_var(IrBuilder *irb, Scop | ... | @@ -2590,17 +3275,21 @@ static IrInstructionSwitchElseVar *ir_build_switch_else_var(IrBuilder *irb, Scop |
| 2590 | return instruction; | 3275 | return instruction; |
| 2591 | } | 3276 | } |
| 2592 | | 3277 | |
| 2593 | static IrInstruction *ir_build_union_tag(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *value) { | 3278 | static IrInstGen *ir_build_union_tag(IrAnalyze *ira, IrInst *source_instr, IrInstGen *value, |
| 2594 | IrInstructionUnionTag *instruction = ir_build_instruction<IrInstructionUnionTag>(irb, scope, source_node); | 3279 | ZigType *tag_type) |
| | 3280 | { |
| | 3281 | IrInstGenUnionTag *instruction = ir_build_inst_gen<IrInstGenUnionTag>(&ira->new_irb, |
| | 3282 | source_instr->scope, source_instr->source_node); |
| 2595 | instruction->value = value; | 3283 | instruction->value = value; |
| | 3284 | instruction->base.value->type = tag_type; |
| 2596 | | 3285 | |
| 2597 | ir_ref_instruction(value, irb->current_basic_block); | 3286 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| 2598 | | 3287 | |
| 2599 | return &instruction->base; | 3288 | return &instruction->base; |
| 2600 | } | 3289 | } |
| 2601 | | 3290 | |
| 2602 | static IrInstruction *ir_build_import(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *name) { | 3291 | static IrInstSrc *ir_build_import(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *name) { |
| 2603 | IrInstructionImport *instruction = ir_build_instruction<IrInstructionImport>(irb, scope, source_node); | 3292 | IrInstSrcImport *instruction = ir_build_instruction<IrInstSrcImport>(irb, scope, source_node); |
| 2604 | instruction->name = name; | 3293 | instruction->name = name; |
| 2605 | | 3294 | |
| 2606 | ir_ref_instruction(name, irb->current_basic_block); | 3295 | ir_ref_instruction(name, irb->current_basic_block); |
| ... | @@ -2608,10 +3297,10 @@ static IrInstruction *ir_build_import(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -2608,10 +3297,10 @@ static IrInstruction *ir_build_import(IrBuilder *irb, Scope *scope, AstNode *sou |
| 2608 | return &instruction->base; | 3297 | return &instruction->base; |
| 2609 | } | 3298 | } |
| 2610 | | 3299 | |
| 2611 | static IrInstruction *ir_build_ref(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *value, | 3300 | static IrInstSrc *ir_build_ref_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *value, |
| 2612 | bool is_const, bool is_volatile) | 3301 | bool is_const, bool is_volatile) |
| 2613 | { | 3302 | { |
| 2614 | IrInstructionRef *instruction = ir_build_instruction<IrInstructionRef>(irb, scope, source_node); | 3303 | IrInstSrcRef *instruction = ir_build_instruction<IrInstSrcRef>(irb, scope, source_node); |
| 2615 | instruction->value = value; | 3304 | instruction->value = value; |
| 2616 | instruction->is_const = is_const; | 3305 | instruction->is_const = is_const; |
| 2617 | instruction->is_volatile = is_volatile; | 3306 | instruction->is_volatile = is_volatile; |
| ... | @@ -2621,23 +3310,23 @@ static IrInstruction *ir_build_ref(IrBuilder *irb, Scope *scope, AstNode *source | ... | @@ -2621,23 +3310,23 @@ static IrInstruction *ir_build_ref(IrBuilder *irb, Scope *scope, AstNode *source |
| 2621 | return &instruction->base; | 3310 | return &instruction->base; |
| 2622 | } | 3311 | } |
| 2623 | | 3312 | |
| 2624 | static IrInstruction *ir_build_ref_gen(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *result_type, | 3313 | static IrInstGen *ir_build_ref_gen(IrAnalyze *ira, IrInst *source_instruction, ZigType *result_type, |
| 2625 | IrInstruction *operand, IrInstruction *result_loc) | 3314 | IrInstGen *operand, IrInstGen *result_loc) |
| 2626 | { | 3315 | { |
| 2627 | IrInstructionRefGen *instruction = ir_build_instruction<IrInstructionRefGen>(&ira->new_irb, | 3316 | IrInstGenRef *instruction = ir_build_inst_gen<IrInstGenRef>(&ira->new_irb, |
| 2628 | source_instruction->scope, source_instruction->source_node); | 3317 | source_instruction->scope, source_instruction->source_node); |
| 2629 | instruction->base.value->type = result_type; | 3318 | instruction->base.value->type = result_type; |
| 2630 | instruction->operand = operand; | 3319 | instruction->operand = operand; |
| 2631 | instruction->result_loc = result_loc; | 3320 | instruction->result_loc = result_loc; |
| 2632 | | 3321 | |
| 2633 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); | 3322 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 2634 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 3323 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 2635 | | 3324 | |
| 2636 | return &instruction->base; | 3325 | return &instruction->base; |
| 2637 | } | 3326 | } |
| 2638 | | 3327 | |
| 2639 | static IrInstruction *ir_build_compile_err(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *msg) { | 3328 | static IrInstSrc *ir_build_compile_err(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *msg) { |
| 2640 | IrInstructionCompileErr *instruction = ir_build_instruction<IrInstructionCompileErr>(irb, scope, source_node); | 3329 | IrInstSrcCompileErr *instruction = ir_build_instruction<IrInstSrcCompileErr>(irb, scope, source_node); |
| 2641 | instruction->msg = msg; | 3330 | instruction->msg = msg; |
| 2642 | | 3331 | |
| 2643 | ir_ref_instruction(msg, irb->current_basic_block); | 3332 | ir_ref_instruction(msg, irb->current_basic_block); |
| ... | @@ -2645,10 +3334,10 @@ static IrInstruction *ir_build_compile_err(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2645,10 +3334,10 @@ static IrInstruction *ir_build_compile_err(IrBuilder *irb, Scope *scope, AstNode |
| 2645 | return &instruction->base; | 3334 | return &instruction->base; |
| 2646 | } | 3335 | } |
| 2647 | | 3336 | |
| 2648 | static IrInstruction *ir_build_compile_log(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3337 | static IrInstSrc *ir_build_compile_log(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2649 | size_t msg_count, IrInstruction **msg_list) | 3338 | size_t msg_count, IrInstSrc **msg_list) |
| 2650 | { | 3339 | { |
| 2651 | IrInstructionCompileLog *instruction = ir_build_instruction<IrInstructionCompileLog>(irb, scope, source_node); | 3340 | IrInstSrcCompileLog *instruction = ir_build_instruction<IrInstSrcCompileLog>(irb, scope, source_node); |
| 2652 | instruction->msg_count = msg_count; | 3341 | instruction->msg_count = msg_count; |
| 2653 | instruction->msg_list = msg_list; | 3342 | instruction->msg_list = msg_list; |
| 2654 | | 3343 | |
| ... | @@ -2659,8 +3348,8 @@ static IrInstruction *ir_build_compile_log(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2659,8 +3348,8 @@ static IrInstruction *ir_build_compile_log(IrBuilder *irb, Scope *scope, AstNode |
| 2659 | return &instruction->base; | 3348 | return &instruction->base; |
| 2660 | } | 3349 | } |
| 2661 | | 3350 | |
| 2662 | static IrInstruction *ir_build_err_name(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *value) { | 3351 | static IrInstSrc *ir_build_err_name(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *value) { |
| 2663 | IrInstructionErrName *instruction = ir_build_instruction<IrInstructionErrName>(irb, scope, source_node); | 3352 | IrInstSrcErrName *instruction = ir_build_instruction<IrInstSrcErrName>(irb, scope, source_node); |
| 2664 | instruction->value = value; | 3353 | instruction->value = value; |
| 2665 | | 3354 | |
| 2666 | ir_ref_instruction(value, irb->current_basic_block); | 3355 | ir_ref_instruction(value, irb->current_basic_block); |
| ... | @@ -2668,13 +3357,26 @@ static IrInstruction *ir_build_err_name(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2668,13 +3357,26 @@ static IrInstruction *ir_build_err_name(IrBuilder *irb, Scope *scope, AstNode *s |
| 2668 | return &instruction->base; | 3357 | return &instruction->base; |
| 2669 | } | 3358 | } |
| 2670 | | 3359 | |
| 2671 | static IrInstruction *ir_build_c_import(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 3360 | static IrInstGen *ir_build_err_name_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *value, |
| 2672 | IrInstructionCImport *instruction = ir_build_instruction<IrInstructionCImport>(irb, scope, source_node); | 3361 | ZigType *str_type) |
| | 3362 | { |
| | 3363 | IrInstGenErrName *instruction = ir_build_inst_gen<IrInstGenErrName>(&ira->new_irb, |
| | 3364 | source_instr->scope, source_instr->source_node); |
| | 3365 | instruction->base.value->type = str_type; |
| | 3366 | instruction->value = value; |
| | 3367 | |
| | 3368 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| | 3369 | |
| | 3370 | return &instruction->base; |
| | 3371 | } |
| | 3372 | |
| | 3373 | static IrInstSrc *ir_build_c_import(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| | 3374 | IrInstSrcCImport *instruction = ir_build_instruction<IrInstSrcCImport>(irb, scope, source_node); |
| 2673 | return &instruction->base; | 3375 | return &instruction->base; |
| 2674 | } | 3376 | } |
| 2675 | | 3377 | |
| 2676 | static IrInstruction *ir_build_c_include(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *name) { | 3378 | static IrInstSrc *ir_build_c_include(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *name) { |
| 2677 | IrInstructionCInclude *instruction = ir_build_instruction<IrInstructionCInclude>(irb, scope, source_node); | 3379 | IrInstSrcCInclude *instruction = ir_build_instruction<IrInstSrcCInclude>(irb, scope, source_node); |
| 2678 | instruction->name = name; | 3380 | instruction->name = name; |
| 2679 | | 3381 | |
| 2680 | ir_ref_instruction(name, irb->current_basic_block); | 3382 | ir_ref_instruction(name, irb->current_basic_block); |
| ... | @@ -2682,8 +3384,8 @@ static IrInstruction *ir_build_c_include(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -2682,8 +3384,8 @@ static IrInstruction *ir_build_c_include(IrBuilder *irb, Scope *scope, AstNode * |
| 2682 | return &instruction->base; | 3384 | return &instruction->base; |
| 2683 | } | 3385 | } |
| 2684 | | 3386 | |
| 2685 | static IrInstruction *ir_build_c_define(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *name, IrInstruction *value) { | 3387 | static IrInstSrc *ir_build_c_define(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *name, IrInstSrc *value) { |
| 2686 | IrInstructionCDefine *instruction = ir_build_instruction<IrInstructionCDefine>(irb, scope, source_node); | 3388 | IrInstSrcCDefine *instruction = ir_build_instruction<IrInstSrcCDefine>(irb, scope, source_node); |
| 2687 | instruction->name = name; | 3389 | instruction->name = name; |
| 2688 | instruction->value = value; | 3390 | instruction->value = value; |
| 2689 | | 3391 | |
| ... | @@ -2693,8 +3395,8 @@ static IrInstruction *ir_build_c_define(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2693,8 +3395,8 @@ static IrInstruction *ir_build_c_define(IrBuilder *irb, Scope *scope, AstNode *s |
| 2693 | return &instruction->base; | 3395 | return &instruction->base; |
| 2694 | } | 3396 | } |
| 2695 | | 3397 | |
| 2696 | static IrInstruction *ir_build_c_undef(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *name) { | 3398 | static IrInstSrc *ir_build_c_undef(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *name) { |
| 2697 | IrInstructionCUndef *instruction = ir_build_instruction<IrInstructionCUndef>(irb, scope, source_node); | 3399 | IrInstSrcCUndef *instruction = ir_build_instruction<IrInstSrcCUndef>(irb, scope, source_node); |
| 2698 | instruction->name = name; | 3400 | instruction->name = name; |
| 2699 | | 3401 | |
| 2700 | ir_ref_instruction(name, irb->current_basic_block); | 3402 | ir_ref_instruction(name, irb->current_basic_block); |
| ... | @@ -2702,8 +3404,8 @@ static IrInstruction *ir_build_c_undef(IrBuilder *irb, Scope *scope, AstNode *so | ... | @@ -2702,8 +3404,8 @@ static IrInstruction *ir_build_c_undef(IrBuilder *irb, Scope *scope, AstNode *so |
| 2702 | return &instruction->base; | 3404 | return &instruction->base; |
| 2703 | } | 3405 | } |
| 2704 | | 3406 | |
| 2705 | static IrInstruction *ir_build_embed_file(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *name) { | 3407 | static IrInstSrc *ir_build_embed_file(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *name) { |
| 2706 | IrInstructionEmbedFile *instruction = ir_build_instruction<IrInstructionEmbedFile>(irb, scope, source_node); | 3408 | IrInstSrcEmbedFile *instruction = ir_build_instruction<IrInstSrcEmbedFile>(irb, scope, source_node); |
| 2707 | instruction->name = name; | 3409 | instruction->name = name; |
| 2708 | | 3410 | |
| 2709 | ir_ref_instruction(name, irb->current_basic_block); | 3411 | ir_ref_instruction(name, irb->current_basic_block); |
| ... | @@ -2711,11 +3413,11 @@ static IrInstruction *ir_build_embed_file(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2711,11 +3413,11 @@ static IrInstruction *ir_build_embed_file(IrBuilder *irb, Scope *scope, AstNode |
| 2711 | return &instruction->base; | 3413 | return &instruction->base; |
| 2712 | } | 3414 | } |
| 2713 | | 3415 | |
| 2714 | static IrInstruction *ir_build_cmpxchg_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3416 | static IrInstSrc *ir_build_cmpxchg_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2715 | IrInstruction *type_value, IrInstruction *ptr, IrInstruction *cmp_value, IrInstruction *new_value, | 3417 | IrInstSrc *type_value, IrInstSrc *ptr, IrInstSrc *cmp_value, IrInstSrc *new_value, |
| 2716 | IrInstruction *success_order_value, IrInstruction *failure_order_value, bool is_weak, ResultLoc *result_loc) | 3418 | IrInstSrc *success_order_value, IrInstSrc *failure_order_value, bool is_weak, ResultLoc *result_loc) |
| 2717 | { | 3419 | { |
| 2718 | IrInstructionCmpxchgSrc *instruction = ir_build_instruction<IrInstructionCmpxchgSrc>(irb, scope, source_node); | 3420 | IrInstSrcCmpxchg *instruction = ir_build_instruction<IrInstSrcCmpxchg>(irb, scope, source_node); |
| 2719 | instruction->type_value = type_value; | 3421 | instruction->type_value = type_value; |
| 2720 | instruction->ptr = ptr; | 3422 | instruction->ptr = ptr; |
| 2721 | instruction->cmp_value = cmp_value; | 3423 | instruction->cmp_value = cmp_value; |
| ... | @@ -2735,11 +3437,11 @@ static IrInstruction *ir_build_cmpxchg_src(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2735,11 +3437,11 @@ static IrInstruction *ir_build_cmpxchg_src(IrBuilder *irb, Scope *scope, AstNode |
| 2735 | return &instruction->base; | 3437 | return &instruction->base; |
| 2736 | } | 3438 | } |
| 2737 | | 3439 | |
| 2738 | static IrInstruction *ir_build_cmpxchg_gen(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *result_type, | 3440 | static IrInstGen *ir_build_cmpxchg_gen(IrAnalyze *ira, IrInst *source_instruction, ZigType *result_type, |
| 2739 | IrInstruction *ptr, IrInstruction *cmp_value, IrInstruction *new_value, | 3441 | IrInstGen *ptr, IrInstGen *cmp_value, IrInstGen *new_value, |
| 2740 | AtomicOrder success_order, AtomicOrder failure_order, bool is_weak, IrInstruction *result_loc) | 3442 | AtomicOrder success_order, AtomicOrder failure_order, bool is_weak, IrInstGen *result_loc) |
| 2741 | { | 3443 | { |
| 2742 | IrInstructionCmpxchgGen *instruction = ir_build_instruction<IrInstructionCmpxchgGen>(&ira->new_irb, | 3444 | IrInstGenCmpxchg *instruction = ir_build_inst_gen<IrInstGenCmpxchg>(&ira->new_irb, |
| 2743 | source_instruction->scope, source_instruction->source_node); | 3445 | source_instruction->scope, source_instruction->source_node); |
| 2744 | instruction->base.value->type = result_type; | 3446 | instruction->base.value->type = result_type; |
| 2745 | instruction->ptr = ptr; | 3447 | instruction->ptr = ptr; |
| ... | @@ -2750,26 +3452,35 @@ static IrInstruction *ir_build_cmpxchg_gen(IrAnalyze *ira, IrInstruction *source | ... | @@ -2750,26 +3452,35 @@ static IrInstruction *ir_build_cmpxchg_gen(IrAnalyze *ira, IrInstruction *source |
| 2750 | instruction->is_weak = is_weak; | 3452 | instruction->is_weak = is_weak; |
| 2751 | instruction->result_loc = result_loc; | 3453 | instruction->result_loc = result_loc; |
| 2752 | | 3454 | |
| 2753 | ir_ref_instruction(ptr, ira->new_irb.current_basic_block); | 3455 | ir_ref_inst_gen(ptr, ira->new_irb.current_basic_block); |
| 2754 | ir_ref_instruction(cmp_value, ira->new_irb.current_basic_block); | 3456 | ir_ref_inst_gen(cmp_value, ira->new_irb.current_basic_block); |
| 2755 | ir_ref_instruction(new_value, ira->new_irb.current_basic_block); | 3457 | ir_ref_inst_gen(new_value, ira->new_irb.current_basic_block); |
| 2756 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 3458 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 2757 | | 3459 | |
| 2758 | return &instruction->base; | 3460 | return &instruction->base; |
| 2759 | } | 3461 | } |
| 2760 | | 3462 | |
| 2761 | static IrInstruction *ir_build_fence(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *order_value, AtomicOrder order) { | 3463 | static IrInstSrc *ir_build_fence(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *order) { |
| 2762 | IrInstructionFence *instruction = ir_build_instruction<IrInstructionFence>(irb, scope, source_node); | 3464 | IrInstSrcFence *instruction = ir_build_instruction<IrInstSrcFence>(irb, scope, source_node); |
| 2763 | instruction->order_value = order_value; | | |
| 2764 | instruction->order = order; | 3465 | instruction->order = order; |
| 2765 | | 3466 | |
| 2766 | ir_ref_instruction(order_value, irb->current_basic_block); | 3467 | ir_ref_instruction(order, irb->current_basic_block); |
| | 3468 | |
| | 3469 | return &instruction->base; |
| | 3470 | } |
| | 3471 | |
| | 3472 | static IrInstGen *ir_build_fence_gen(IrAnalyze *ira, IrInst *source_instr, AtomicOrder order) { |
| | 3473 | IrInstGenFence *instruction = ir_build_inst_void<IrInstGenFence>(&ira->new_irb, |
| | 3474 | source_instr->scope, source_instr->source_node); |
| | 3475 | instruction->order = order; |
| 2767 | | 3476 | |
| 2768 | return &instruction->base; | 3477 | return &instruction->base; |
| 2769 | } | 3478 | } |
| 2770 | | 3479 | |
| 2771 | static IrInstruction *ir_build_truncate(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *dest_type, IrInstruction *target) { | 3480 | static IrInstSrc *ir_build_truncate(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2772 | IrInstructionTruncate *instruction = ir_build_instruction<IrInstructionTruncate>(irb, scope, source_node); | 3481 | IrInstSrc *dest_type, IrInstSrc *target) |
| | 3482 | { |
| | 3483 | IrInstSrcTruncate *instruction = ir_build_instruction<IrInstSrcTruncate>(irb, scope, source_node); |
| 2773 | instruction->dest_type = dest_type; | 3484 | instruction->dest_type = dest_type; |
| 2774 | instruction->target = target; | 3485 | instruction->target = target; |
| 2775 | | 3486 | |
| ... | @@ -2779,8 +3490,23 @@ static IrInstruction *ir_build_truncate(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2779,8 +3490,23 @@ static IrInstruction *ir_build_truncate(IrBuilder *irb, Scope *scope, AstNode *s |
| 2779 | return &instruction->base; | 3490 | return &instruction->base; |
| 2780 | } | 3491 | } |
| 2781 | | 3492 | |
| 2782 | static IrInstruction *ir_build_int_cast(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *dest_type, IrInstruction *target) { | 3493 | static IrInstGen *ir_build_truncate_gen(IrAnalyze *ira, IrInst *source_instr, ZigType *dest_type, |
| 2783 | IrInstructionIntCast *instruction = ir_build_instruction<IrInstructionIntCast>(irb, scope, source_node); | 3494 | IrInstGen *target) |
| | 3495 | { |
| | 3496 | IrInstGenTruncate *instruction = ir_build_inst_gen<IrInstGenTruncate>(&ira->new_irb, |
| | 3497 | source_instr->scope, source_instr->source_node); |
| | 3498 | instruction->base.value->type = dest_type; |
| | 3499 | instruction->target = target; |
| | 3500 | |
| | 3501 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| | 3502 | |
| | 3503 | return &instruction->base; |
| | 3504 | } |
| | 3505 | |
| | 3506 | static IrInstSrc *ir_build_int_cast(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *dest_type, |
| | 3507 | IrInstSrc *target) |
| | 3508 | { |
| | 3509 | IrInstSrcIntCast *instruction = ir_build_instruction<IrInstSrcIntCast>(irb, scope, source_node); |
| 2784 | instruction->dest_type = dest_type; | 3510 | instruction->dest_type = dest_type; |
| 2785 | instruction->target = target; | 3511 | instruction->target = target; |
| 2786 | | 3512 | |
| ... | @@ -2790,8 +3516,10 @@ static IrInstruction *ir_build_int_cast(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2790,8 +3516,10 @@ static IrInstruction *ir_build_int_cast(IrBuilder *irb, Scope *scope, AstNode *s |
| 2790 | return &instruction->base; | 3516 | return &instruction->base; |
| 2791 | } | 3517 | } |
| 2792 | | 3518 | |
| 2793 | static IrInstruction *ir_build_float_cast(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *dest_type, IrInstruction *target) { | 3519 | static IrInstSrc *ir_build_float_cast(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *dest_type, |
| 2794 | IrInstructionFloatCast *instruction = ir_build_instruction<IrInstructionFloatCast>(irb, scope, source_node); | 3520 | IrInstSrc *target) |
| | 3521 | { |
| | 3522 | IrInstSrcFloatCast *instruction = ir_build_instruction<IrInstSrcFloatCast>(irb, scope, source_node); |
| 2795 | instruction->dest_type = dest_type; | 3523 | instruction->dest_type = dest_type; |
| 2796 | instruction->target = target; | 3524 | instruction->target = target; |
| 2797 | | 3525 | |
| ... | @@ -2801,8 +3529,10 @@ static IrInstruction *ir_build_float_cast(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2801,8 +3529,10 @@ static IrInstruction *ir_build_float_cast(IrBuilder *irb, Scope *scope, AstNode |
| 2801 | return &instruction->base; | 3529 | return &instruction->base; |
| 2802 | } | 3530 | } |
| 2803 | | 3531 | |
| 2804 | static IrInstruction *ir_build_err_set_cast(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *dest_type, IrInstruction *target) { | 3532 | static IrInstSrc *ir_build_err_set_cast(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2805 | IrInstructionErrSetCast *instruction = ir_build_instruction<IrInstructionErrSetCast>(irb, scope, source_node); | 3533 | IrInstSrc *dest_type, IrInstSrc *target) |
| | 3534 | { |
| | 3535 | IrInstSrcErrSetCast *instruction = ir_build_instruction<IrInstSrcErrSetCast>(irb, scope, source_node); |
| 2806 | instruction->dest_type = dest_type; | 3536 | instruction->dest_type = dest_type; |
| 2807 | instruction->target = target; | 3537 | instruction->target = target; |
| 2808 | | 3538 | |
| ... | @@ -2812,10 +3542,10 @@ static IrInstruction *ir_build_err_set_cast(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -2812,10 +3542,10 @@ static IrInstruction *ir_build_err_set_cast(IrBuilder *irb, Scope *scope, AstNod |
| 2812 | return &instruction->base; | 3542 | return &instruction->base; |
| 2813 | } | 3543 | } |
| 2814 | | 3544 | |
| 2815 | static IrInstruction *ir_build_to_bytes(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *target, | 3545 | static IrInstSrc *ir_build_to_bytes(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *target, |
| 2816 | ResultLoc *result_loc) | 3546 | ResultLoc *result_loc) |
| 2817 | { | 3547 | { |
| 2818 | IrInstructionToBytes *instruction = ir_build_instruction<IrInstructionToBytes>(irb, scope, source_node); | 3548 | IrInstSrcToBytes *instruction = ir_build_instruction<IrInstSrcToBytes>(irb, scope, source_node); |
| 2819 | instruction->target = target; | 3549 | instruction->target = target; |
| 2820 | instruction->result_loc = result_loc; | 3550 | instruction->result_loc = result_loc; |
| 2821 | | 3551 | |
| ... | @@ -2824,10 +3554,10 @@ static IrInstruction *ir_build_to_bytes(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2824,10 +3554,10 @@ static IrInstruction *ir_build_to_bytes(IrBuilder *irb, Scope *scope, AstNode *s |
| 2824 | return &instruction->base; | 3554 | return &instruction->base; |
| 2825 | } | 3555 | } |
| 2826 | | 3556 | |
| 2827 | static IrInstruction *ir_build_from_bytes(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3557 | static IrInstSrc *ir_build_from_bytes(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2828 | IrInstruction *dest_child_type, IrInstruction *target, ResultLoc *result_loc) | 3558 | IrInstSrc *dest_child_type, IrInstSrc *target, ResultLoc *result_loc) |
| 2829 | { | 3559 | { |
| 2830 | IrInstructionFromBytes *instruction = ir_build_instruction<IrInstructionFromBytes>(irb, scope, source_node); | 3560 | IrInstSrcFromBytes *instruction = ir_build_instruction<IrInstSrcFromBytes>(irb, scope, source_node); |
| 2831 | instruction->dest_child_type = dest_child_type; | 3561 | instruction->dest_child_type = dest_child_type; |
| 2832 | instruction->target = target; | 3562 | instruction->target = target; |
| 2833 | instruction->result_loc = result_loc; | 3563 | instruction->result_loc = result_loc; |
| ... | @@ -2838,8 +3568,10 @@ static IrInstruction *ir_build_from_bytes(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2838,8 +3568,10 @@ static IrInstruction *ir_build_from_bytes(IrBuilder *irb, Scope *scope, AstNode |
| 2838 | return &instruction->base; | 3568 | return &instruction->base; |
| 2839 | } | 3569 | } |
| 2840 | | 3570 | |
| 2841 | static IrInstruction *ir_build_int_to_float(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *dest_type, IrInstruction *target) { | 3571 | static IrInstSrc *ir_build_int_to_float(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2842 | IrInstructionIntToFloat *instruction = ir_build_instruction<IrInstructionIntToFloat>(irb, scope, source_node); | 3572 | IrInstSrc *dest_type, IrInstSrc *target) |
| | 3573 | { |
| | 3574 | IrInstSrcIntToFloat *instruction = ir_build_instruction<IrInstSrcIntToFloat>(irb, scope, source_node); |
| 2843 | instruction->dest_type = dest_type; | 3575 | instruction->dest_type = dest_type; |
| 2844 | instruction->target = target; | 3576 | instruction->target = target; |
| 2845 | | 3577 | |
| ... | @@ -2849,8 +3581,10 @@ static IrInstruction *ir_build_int_to_float(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -2849,8 +3581,10 @@ static IrInstruction *ir_build_int_to_float(IrBuilder *irb, Scope *scope, AstNod |
| 2849 | return &instruction->base; | 3581 | return &instruction->base; |
| 2850 | } | 3582 | } |
| 2851 | | 3583 | |
| 2852 | static IrInstruction *ir_build_float_to_int(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *dest_type, IrInstruction *target) { | 3584 | static IrInstSrc *ir_build_float_to_int(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2853 | IrInstructionFloatToInt *instruction = ir_build_instruction<IrInstructionFloatToInt>(irb, scope, source_node); | 3585 | IrInstSrc *dest_type, IrInstSrc *target) |
| | 3586 | { |
| | 3587 | IrInstSrcFloatToInt *instruction = ir_build_instruction<IrInstSrcFloatToInt>(irb, scope, source_node); |
| 2854 | instruction->dest_type = dest_type; | 3588 | instruction->dest_type = dest_type; |
| 2855 | instruction->target = target; | 3589 | instruction->target = target; |
| 2856 | | 3590 | |
| ... | @@ -2860,8 +3594,8 @@ static IrInstruction *ir_build_float_to_int(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -2860,8 +3594,8 @@ static IrInstruction *ir_build_float_to_int(IrBuilder *irb, Scope *scope, AstNod |
| 2860 | return &instruction->base; | 3594 | return &instruction->base; |
| 2861 | } | 3595 | } |
| 2862 | | 3596 | |
| 2863 | static IrInstruction *ir_build_bool_to_int(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *target) { | 3597 | static IrInstSrc *ir_build_bool_to_int(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *target) { |
| 2864 | IrInstructionBoolToInt *instruction = ir_build_instruction<IrInstructionBoolToInt>(irb, scope, source_node); | 3598 | IrInstSrcBoolToInt *instruction = ir_build_instruction<IrInstSrcBoolToInt>(irb, scope, source_node); |
| 2865 | instruction->target = target; | 3599 | instruction->target = target; |
| 2866 | | 3600 | |
| 2867 | ir_ref_instruction(target, irb->current_basic_block); | 3601 | ir_ref_instruction(target, irb->current_basic_block); |
| ... | @@ -2869,8 +3603,10 @@ static IrInstruction *ir_build_bool_to_int(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2869,8 +3603,10 @@ static IrInstruction *ir_build_bool_to_int(IrBuilder *irb, Scope *scope, AstNode |
| 2869 | return &instruction->base; | 3603 | return &instruction->base; |
| 2870 | } | 3604 | } |
| 2871 | | 3605 | |
| 2872 | static IrInstruction *ir_build_int_type(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *is_signed, IrInstruction *bit_count) { | 3606 | static IrInstSrc *ir_build_int_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *is_signed, |
| 2873 | IrInstructionIntType *instruction = ir_build_instruction<IrInstructionIntType>(irb, scope, source_node); | 3607 | IrInstSrc *bit_count) |
| | 3608 | { |
| | 3609 | IrInstSrcIntType *instruction = ir_build_instruction<IrInstSrcIntType>(irb, scope, source_node); |
| 2874 | instruction->is_signed = is_signed; | 3610 | instruction->is_signed = is_signed; |
| 2875 | instruction->bit_count = bit_count; | 3611 | instruction->bit_count = bit_count; |
| 2876 | | 3612 | |
| ... | @@ -2880,10 +3616,10 @@ static IrInstruction *ir_build_int_type(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2880,10 +3616,10 @@ static IrInstruction *ir_build_int_type(IrBuilder *irb, Scope *scope, AstNode *s |
| 2880 | return &instruction->base; | 3616 | return &instruction->base; |
| 2881 | } | 3617 | } |
| 2882 | | 3618 | |
| 2883 | static IrInstruction *ir_build_vector_type(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *len, | 3619 | static IrInstSrc *ir_build_vector_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *len, |
| 2884 | IrInstruction *elem_type) | 3620 | IrInstSrc *elem_type) |
| 2885 | { | 3621 | { |
| 2886 | IrInstructionVectorType *instruction = ir_build_instruction<IrInstructionVectorType>(irb, scope, source_node); | 3622 | IrInstSrcVectorType *instruction = ir_build_instruction<IrInstSrcVectorType>(irb, scope, source_node); |
| 2887 | instruction->len = len; | 3623 | instruction->len = len; |
| 2888 | instruction->elem_type = elem_type; | 3624 | instruction->elem_type = elem_type; |
| 2889 | | 3625 | |
| ... | @@ -2893,18 +3629,16 @@ static IrInstruction *ir_build_vector_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -2893,18 +3629,16 @@ static IrInstruction *ir_build_vector_type(IrBuilder *irb, Scope *scope, AstNode |
| 2893 | return &instruction->base; | 3629 | return &instruction->base; |
| 2894 | } | 3630 | } |
| 2895 | | 3631 | |
| 2896 | static IrInstruction *ir_build_shuffle_vector(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3632 | static IrInstSrc *ir_build_shuffle_vector(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 2897 | IrInstruction *scalar_type, IrInstruction *a, IrInstruction *b, IrInstruction *mask) | 3633 | IrInstSrc *scalar_type, IrInstSrc *a, IrInstSrc *b, IrInstSrc *mask) |
| 2898 | { | 3634 | { |
| 2899 | IrInstructionShuffleVector *instruction = ir_build_instruction<IrInstructionShuffleVector>(irb, scope, source_node); | 3635 | IrInstSrcShuffleVector *instruction = ir_build_instruction<IrInstSrcShuffleVector>(irb, scope, source_node); |
| 2900 | instruction->scalar_type = scalar_type; | 3636 | instruction->scalar_type = scalar_type; |
| 2901 | instruction->a = a; | 3637 | instruction->a = a; |
| 2902 | instruction->b = b; | 3638 | instruction->b = b; |
| 2903 | instruction->mask = mask; | 3639 | instruction->mask = mask; |
| 2904 | | 3640 | |
| 2905 | if (scalar_type != nullptr) { | 3641 | if (scalar_type != nullptr) ir_ref_instruction(scalar_type, irb->current_basic_block); |
| 2906 | ir_ref_instruction(scalar_type, irb->current_basic_block); | | |
| 2907 | } | | |
| 2908 | ir_ref_instruction(a, irb->current_basic_block); | 3642 | ir_ref_instruction(a, irb->current_basic_block); |
| 2909 | ir_ref_instruction(b, irb->current_basic_block); | 3643 | ir_ref_instruction(b, irb->current_basic_block); |
| 2910 | ir_ref_instruction(mask, irb->current_basic_block); | 3644 | ir_ref_instruction(mask, irb->current_basic_block); |
| ... | @@ -2912,10 +3646,26 @@ static IrInstruction *ir_build_shuffle_vector(IrBuilder *irb, Scope *scope, AstN | ... | @@ -2912,10 +3646,26 @@ static IrInstruction *ir_build_shuffle_vector(IrBuilder *irb, Scope *scope, AstN |
| 2912 | return &instruction->base; | 3646 | return &instruction->base; |
| 2913 | } | 3647 | } |
| 2914 | | 3648 | |
| 2915 | static IrInstruction *ir_build_splat_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3649 | static IrInstGen *ir_build_shuffle_vector_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, |
| 2916 | IrInstruction *len, IrInstruction *scalar) | 3650 | ZigType *result_type, IrInstGen *a, IrInstGen *b, IrInstGen *mask) |
| 2917 | { | 3651 | { |
| 2918 | IrInstructionSplatSrc *instruction = ir_build_instruction<IrInstructionSplatSrc>(irb, scope, source_node); | 3652 | IrInstGenShuffleVector *inst = ir_build_inst_gen<IrInstGenShuffleVector>(&ira->new_irb, scope, source_node); |
| | 3653 | inst->base.value->type = result_type; |
| | 3654 | inst->a = a; |
| | 3655 | inst->b = b; |
| | 3656 | inst->mask = mask; |
| | 3657 | |
| | 3658 | ir_ref_inst_gen(a, ira->new_irb.current_basic_block); |
| | 3659 | ir_ref_inst_gen(b, ira->new_irb.current_basic_block); |
| | 3660 | ir_ref_inst_gen(mask, ira->new_irb.current_basic_block); |
| | 3661 | |
| | 3662 | return &inst->base; |
| | 3663 | } |
| | 3664 | |
| | 3665 | static IrInstSrc *ir_build_splat_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 3666 | IrInstSrc *len, IrInstSrc *scalar) |
| | 3667 | { |
| | 3668 | IrInstSrcSplat *instruction = ir_build_instruction<IrInstSrcSplat>(irb, scope, source_node); |
| 2919 | instruction->len = len; | 3669 | instruction->len = len; |
| 2920 | instruction->scalar = scalar; | 3670 | instruction->scalar = scalar; |
| 2921 | | 3671 | |
| ... | @@ -2925,8 +3675,21 @@ static IrInstruction *ir_build_splat_src(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -2925,8 +3675,21 @@ static IrInstruction *ir_build_splat_src(IrBuilder *irb, Scope *scope, AstNode * |
| 2925 | return &instruction->base; | 3675 | return &instruction->base; |
| 2926 | } | 3676 | } |
| 2927 | | 3677 | |
| 2928 | static IrInstruction *ir_build_bool_not(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *value) { | 3678 | static IrInstGen *ir_build_splat_gen(IrAnalyze *ira, IrInst *source_instruction, ZigType *result_type, |
| 2929 | IrInstructionBoolNot *instruction = ir_build_instruction<IrInstructionBoolNot>(irb, scope, source_node); | 3679 | IrInstGen *scalar) |
| | 3680 | { |
| | 3681 | IrInstGenSplat *instruction = ir_build_inst_gen<IrInstGenSplat>( |
| | 3682 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| | 3683 | instruction->base.value->type = result_type; |
| | 3684 | instruction->scalar = scalar; |
| | 3685 | |
| | 3686 | ir_ref_inst_gen(scalar, ira->new_irb.current_basic_block); |
| | 3687 | |
| | 3688 | return &instruction->base; |
| | 3689 | } |
| | 3690 | |
| | 3691 | static IrInstSrc *ir_build_bool_not(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *value) { |
| | 3692 | IrInstSrcBoolNot *instruction = ir_build_instruction<IrInstSrcBoolNot>(irb, scope, source_node); |
| 2930 | instruction->value = value; | 3693 | instruction->value = value; |
| 2931 | | 3694 | |
| 2932 | ir_ref_instruction(value, irb->current_basic_block); | 3695 | ir_ref_instruction(value, irb->current_basic_block); |
| ... | @@ -2934,10 +3697,21 @@ static IrInstruction *ir_build_bool_not(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -2934,10 +3697,21 @@ static IrInstruction *ir_build_bool_not(IrBuilder *irb, Scope *scope, AstNode *s |
| 2934 | return &instruction->base; | 3697 | return &instruction->base; |
| 2935 | } | 3698 | } |
| 2936 | | 3699 | |
| 2937 | static IrInstruction *ir_build_memset(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3700 | static IrInstGen *ir_build_bool_not_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *value) { |
| 2938 | IrInstruction *dest_ptr, IrInstruction *byte, IrInstruction *count) | 3701 | IrInstGenBoolNot *instruction = ir_build_inst_gen<IrInstGenBoolNot>(&ira->new_irb, |
| | 3702 | source_instr->scope, source_instr->source_node); |
| | 3703 | instruction->base.value->type = ira->codegen->builtin_types.entry_bool; |
| | 3704 | instruction->value = value; |
| | 3705 | |
| | 3706 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| | 3707 | |
| | 3708 | return &instruction->base; |
| | 3709 | } |
| | 3710 | |
| | 3711 | static IrInstSrc *ir_build_memset_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 3712 | IrInstSrc *dest_ptr, IrInstSrc *byte, IrInstSrc *count) |
| 2939 | { | 3713 | { |
| 2940 | IrInstructionMemset *instruction = ir_build_instruction<IrInstructionMemset>(irb, scope, source_node); | 3714 | IrInstSrcMemset *instruction = ir_build_instruction<IrInstSrcMemset>(irb, scope, source_node); |
| 2941 | instruction->dest_ptr = dest_ptr; | 3715 | instruction->dest_ptr = dest_ptr; |
| 2942 | instruction->byte = byte; | 3716 | instruction->byte = byte; |
| 2943 | instruction->count = count; | 3717 | instruction->count = count; |
| ... | @@ -2949,10 +3723,26 @@ static IrInstruction *ir_build_memset(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -2949,10 +3723,26 @@ static IrInstruction *ir_build_memset(IrBuilder *irb, Scope *scope, AstNode *sou |
| 2949 | return &instruction->base; | 3723 | return &instruction->base; |
| 2950 | } | 3724 | } |
| 2951 | | 3725 | |
| 2952 | static IrInstruction *ir_build_memcpy(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3726 | static IrInstGen *ir_build_memset_gen(IrAnalyze *ira, IrInst *source_instr, |
| 2953 | IrInstruction *dest_ptr, IrInstruction *src_ptr, IrInstruction *count) | 3727 | IrInstGen *dest_ptr, IrInstGen *byte, IrInstGen *count) |
| | 3728 | { |
| | 3729 | IrInstGenMemset *instruction = ir_build_inst_void<IrInstGenMemset>(&ira->new_irb, |
| | 3730 | source_instr->scope, source_instr->source_node); |
| | 3731 | instruction->dest_ptr = dest_ptr; |
| | 3732 | instruction->byte = byte; |
| | 3733 | instruction->count = count; |
| | 3734 | |
| | 3735 | ir_ref_inst_gen(dest_ptr, ira->new_irb.current_basic_block); |
| | 3736 | ir_ref_inst_gen(byte, ira->new_irb.current_basic_block); |
| | 3737 | ir_ref_inst_gen(count, ira->new_irb.current_basic_block); |
| | 3738 | |
| | 3739 | return &instruction->base; |
| | 3740 | } |
| | 3741 | |
| | 3742 | static IrInstSrc *ir_build_memcpy_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 3743 | IrInstSrc *dest_ptr, IrInstSrc *src_ptr, IrInstSrc *count) |
| 2954 | { | 3744 | { |
| 2955 | IrInstructionMemcpy *instruction = ir_build_instruction<IrInstructionMemcpy>(irb, scope, source_node); | 3745 | IrInstSrcMemcpy *instruction = ir_build_instruction<IrInstSrcMemcpy>(irb, scope, source_node); |
| 2956 | instruction->dest_ptr = dest_ptr; | 3746 | instruction->dest_ptr = dest_ptr; |
| 2957 | instruction->src_ptr = src_ptr; | 3747 | instruction->src_ptr = src_ptr; |
| 2958 | instruction->count = count; | 3748 | instruction->count = count; |
| ... | @@ -2964,11 +3754,27 @@ static IrInstruction *ir_build_memcpy(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -2964,11 +3754,27 @@ static IrInstruction *ir_build_memcpy(IrBuilder *irb, Scope *scope, AstNode *sou |
| 2964 | return &instruction->base; | 3754 | return &instruction->base; |
| 2965 | } | 3755 | } |
| 2966 | | 3756 | |
| 2967 | static IrInstruction *ir_build_slice_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3757 | static IrInstGen *ir_build_memcpy_gen(IrAnalyze *ira, IrInst *source_instr, |
| 2968 | IrInstruction *ptr, IrInstruction *start, IrInstruction *end, IrInstruction *sentinel, | 3758 | IrInstGen *dest_ptr, IrInstGen *src_ptr, IrInstGen *count) |
| | 3759 | { |
| | 3760 | IrInstGenMemcpy *instruction = ir_build_inst_void<IrInstGenMemcpy>(&ira->new_irb, |
| | 3761 | source_instr->scope, source_instr->source_node); |
| | 3762 | instruction->dest_ptr = dest_ptr; |
| | 3763 | instruction->src_ptr = src_ptr; |
| | 3764 | instruction->count = count; |
| | 3765 | |
| | 3766 | ir_ref_inst_gen(dest_ptr, ira->new_irb.current_basic_block); |
| | 3767 | ir_ref_inst_gen(src_ptr, ira->new_irb.current_basic_block); |
| | 3768 | ir_ref_inst_gen(count, ira->new_irb.current_basic_block); |
| | 3769 | |
| | 3770 | return &instruction->base; |
| | 3771 | } |
| | 3772 | |
| | 3773 | static IrInstSrc *ir_build_slice_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 3774 | IrInstSrc *ptr, IrInstSrc *start, IrInstSrc *end, IrInstSrc *sentinel, |
| 2969 | bool safety_check_on, ResultLoc *result_loc) | 3775 | bool safety_check_on, ResultLoc *result_loc) |
| 2970 | { | 3776 | { |
| 2971 | IrInstructionSliceSrc *instruction = ir_build_instruction<IrInstructionSliceSrc>(irb, scope, source_node); | 3777 | IrInstSrcSlice *instruction = ir_build_instruction<IrInstSrcSlice>(irb, scope, source_node); |
| 2972 | instruction->ptr = ptr; | 3778 | instruction->ptr = ptr; |
| 2973 | instruction->start = start; | 3779 | instruction->start = start; |
| 2974 | instruction->end = end; | 3780 | instruction->end = end; |
| ... | @@ -2984,23 +3790,10 @@ static IrInstruction *ir_build_slice_src(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -2984,23 +3790,10 @@ static IrInstruction *ir_build_slice_src(IrBuilder *irb, Scope *scope, AstNode * |
| 2984 | return &instruction->base; | 3790 | return &instruction->base; |
| 2985 | } | 3791 | } |
| 2986 | | 3792 | |
| 2987 | static IrInstruction *ir_build_splat_gen(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *result_type, | 3793 | static IrInstGen *ir_build_slice_gen(IrAnalyze *ira, IrInst *source_instruction, ZigType *slice_type, |
| 2988 | IrInstruction *scalar) | 3794 | IrInstGen *ptr, IrInstGen *start, IrInstGen *end, bool safety_check_on, IrInstGen *result_loc) |
| 2989 | { | | |
| 2990 | IrInstructionSplatGen *instruction = ir_build_instruction<IrInstructionSplatGen>( | | |
| 2991 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | | |
| 2992 | instruction->base.value->type = result_type; | | |
| 2993 | instruction->scalar = scalar; | | |
| 2994 | | | |
| 2995 | ir_ref_instruction(scalar, ira->new_irb.current_basic_block); | | |
| 2996 | | | |
| 2997 | return &instruction->base; | | |
| 2998 | } | | |
| 2999 | | | |
| 3000 | static IrInstruction *ir_build_slice_gen(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *slice_type, | | |
| 3001 | IrInstruction *ptr, IrInstruction *start, IrInstruction *end, bool safety_check_on, IrInstruction *result_loc) | | |
| 3002 | { | 3795 | { |
| 3003 | IrInstructionSliceGen *instruction = ir_build_instruction<IrInstructionSliceGen>( | 3796 | IrInstGenSlice *instruction = ir_build_inst_gen<IrInstGenSlice>( |
| 3004 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 3797 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 3005 | instruction->base.value->type = slice_type; | 3798 | instruction->base.value->type = slice_type; |
| 3006 | instruction->ptr = ptr; | 3799 | instruction->ptr = ptr; |
| ... | @@ -3009,16 +3802,16 @@ static IrInstruction *ir_build_slice_gen(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -3009,16 +3802,16 @@ static IrInstruction *ir_build_slice_gen(IrAnalyze *ira, IrInstruction *source_i |
| 3009 | instruction->safety_check_on = safety_check_on; | 3802 | instruction->safety_check_on = safety_check_on; |
| 3010 | instruction->result_loc = result_loc; | 3803 | instruction->result_loc = result_loc; |
| 3011 | | 3804 | |
| 3012 | ir_ref_instruction(ptr, ira->new_irb.current_basic_block); | 3805 | ir_ref_inst_gen(ptr, ira->new_irb.current_basic_block); |
| 3013 | ir_ref_instruction(start, ira->new_irb.current_basic_block); | 3806 | ir_ref_inst_gen(start, ira->new_irb.current_basic_block); |
| 3014 | if (end) ir_ref_instruction(end, ira->new_irb.current_basic_block); | 3807 | if (end) ir_ref_inst_gen(end, ira->new_irb.current_basic_block); |
| 3015 | ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 3808 | ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 3016 | | 3809 | |
| 3017 | return &instruction->base; | 3810 | return &instruction->base; |
| 3018 | } | 3811 | } |
| 3019 | | 3812 | |
| 3020 | static IrInstruction *ir_build_member_count(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *container) { | 3813 | static IrInstSrc *ir_build_member_count(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *container) { |
| 3021 | IrInstructionMemberCount *instruction = ir_build_instruction<IrInstructionMemberCount>(irb, scope, source_node); | 3814 | IrInstSrcMemberCount *instruction = ir_build_instruction<IrInstSrcMemberCount>(irb, scope, source_node); |
| 3022 | instruction->container = container; | 3815 | instruction->container = container; |
| 3023 | | 3816 | |
| 3024 | ir_ref_instruction(container, irb->current_basic_block); | 3817 | ir_ref_instruction(container, irb->current_basic_block); |
| ... | @@ -3026,10 +3819,10 @@ static IrInstruction *ir_build_member_count(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -3026,10 +3819,10 @@ static IrInstruction *ir_build_member_count(IrBuilder *irb, Scope *scope, AstNod |
| 3026 | return &instruction->base; | 3819 | return &instruction->base; |
| 3027 | } | 3820 | } |
| 3028 | | 3821 | |
| 3029 | static IrInstruction *ir_build_member_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3822 | static IrInstSrc *ir_build_member_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3030 | IrInstruction *container_type, IrInstruction *member_index) | 3823 | IrInstSrc *container_type, IrInstSrc *member_index) |
| 3031 | { | 3824 | { |
| 3032 | IrInstructionMemberType *instruction = ir_build_instruction<IrInstructionMemberType>(irb, scope, source_node); | 3825 | IrInstSrcMemberType *instruction = ir_build_instruction<IrInstSrcMemberType>(irb, scope, source_node); |
| 3033 | instruction->container_type = container_type; | 3826 | instruction->container_type = container_type; |
| 3034 | instruction->member_index = member_index; | 3827 | instruction->member_index = member_index; |
| 3035 | | 3828 | |
| ... | @@ -3039,10 +3832,10 @@ static IrInstruction *ir_build_member_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3039,10 +3832,10 @@ static IrInstruction *ir_build_member_type(IrBuilder *irb, Scope *scope, AstNode |
| 3039 | return &instruction->base; | 3832 | return &instruction->base; |
| 3040 | } | 3833 | } |
| 3041 | | 3834 | |
| 3042 | static IrInstruction *ir_build_member_name(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3835 | static IrInstSrc *ir_build_member_name(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3043 | IrInstruction *container_type, IrInstruction *member_index) | 3836 | IrInstSrc *container_type, IrInstSrc *member_index) |
| 3044 | { | 3837 | { |
| 3045 | IrInstructionMemberName *instruction = ir_build_instruction<IrInstructionMemberName>(irb, scope, source_node); | 3838 | IrInstSrcMemberName *instruction = ir_build_instruction<IrInstSrcMemberName>(irb, scope, source_node); |
| 3046 | instruction->container_type = container_type; | 3839 | instruction->container_type = container_type; |
| 3047 | instruction->member_index = member_index; | 3840 | instruction->member_index = member_index; |
| 3048 | | 3841 | |
| ... | @@ -3052,65 +3845,88 @@ static IrInstruction *ir_build_member_name(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3052,65 +3845,88 @@ static IrInstruction *ir_build_member_name(IrBuilder *irb, Scope *scope, AstNode |
| 3052 | return &instruction->base; | 3845 | return &instruction->base; |
| 3053 | } | 3846 | } |
| 3054 | | 3847 | |
| 3055 | static IrInstruction *ir_build_breakpoint(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 3848 | static IrInstSrc *ir_build_breakpoint(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 3056 | IrInstructionBreakpoint *instruction = ir_build_instruction<IrInstructionBreakpoint>(irb, scope, source_node); | 3849 | IrInstSrcBreakpoint *instruction = ir_build_instruction<IrInstSrcBreakpoint>(irb, scope, source_node); |
| 3057 | return &instruction->base; | 3850 | return &instruction->base; |
| 3058 | } | 3851 | } |
| 3059 | | 3852 | |
| 3060 | static IrInstruction *ir_build_return_address(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 3853 | static IrInstGen *ir_build_breakpoint_gen(IrAnalyze *ira, IrInst *source_instr) { |
| 3061 | IrInstructionReturnAddress *instruction = ir_build_instruction<IrInstructionReturnAddress>(irb, scope, source_node); | 3854 | IrInstGenBreakpoint *instruction = ir_build_inst_void<IrInstGenBreakpoint>(&ira->new_irb, |
| | 3855 | source_instr->scope, source_instr->source_node); |
| 3062 | return &instruction->base; | 3856 | return &instruction->base; |
| 3063 | } | 3857 | } |
| 3064 | | 3858 | |
| 3065 | static IrInstruction *ir_build_frame_address(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 3859 | static IrInstSrc *ir_build_return_address_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 3066 | IrInstructionFrameAddress *instruction = ir_build_instruction<IrInstructionFrameAddress>(irb, scope, source_node); | 3860 | IrInstSrcReturnAddress *instruction = ir_build_instruction<IrInstSrcReturnAddress>(irb, scope, source_node); |
| 3067 | return &instruction->base; | 3861 | return &instruction->base; |
| 3068 | } | 3862 | } |
| 3069 | | 3863 | |
| 3070 | static IrInstruction *ir_build_handle(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 3864 | static IrInstGen *ir_build_return_address_gen(IrAnalyze *ira, IrInst *source_instr) { |
| 3071 | IrInstructionFrameHandle *instruction = ir_build_instruction<IrInstructionFrameHandle>(irb, scope, source_node); | 3865 | IrInstGenReturnAddress *inst = ir_build_inst_gen<IrInstGenReturnAddress>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| 3072 | return &instruction->base; | 3866 | inst->base.value->type = ira->codegen->builtin_types.entry_usize; |
| | 3867 | return &inst->base; |
| | 3868 | } |
| | 3869 | |
| | 3870 | static IrInstSrc *ir_build_frame_address_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| | 3871 | IrInstSrcFrameAddress *inst = ir_build_instruction<IrInstSrcFrameAddress>(irb, scope, source_node); |
| | 3872 | return &inst->base; |
| | 3873 | } |
| | 3874 | |
| | 3875 | static IrInstGen *ir_build_frame_address_gen(IrAnalyze *ira, IrInst *source_instr) { |
| | 3876 | IrInstGenFrameAddress *inst = ir_build_inst_gen<IrInstGenFrameAddress>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| | 3877 | inst->base.value->type = ira->codegen->builtin_types.entry_usize; |
| | 3878 | return &inst->base; |
| | 3879 | } |
| | 3880 | |
| | 3881 | static IrInstSrc *ir_build_handle_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| | 3882 | IrInstSrcFrameHandle *inst = ir_build_instruction<IrInstSrcFrameHandle>(irb, scope, source_node); |
| | 3883 | return &inst->base; |
| | 3884 | } |
| | 3885 | |
| | 3886 | static IrInstGen *ir_build_handle_gen(IrAnalyze *ira, IrInst *source_instr, ZigType *ty) { |
| | 3887 | IrInstGenFrameHandle *inst = ir_build_inst_gen<IrInstGenFrameHandle>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| | 3888 | inst->base.value->type = ty; |
| | 3889 | return &inst->base; |
| 3073 | } | 3890 | } |
| 3074 | | 3891 | |
| 3075 | static IrInstruction *ir_build_frame_type(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *fn) { | 3892 | static IrInstSrc *ir_build_frame_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *fn) { |
| 3076 | IrInstructionFrameType *instruction = ir_build_instruction<IrInstructionFrameType>(irb, scope, source_node); | 3893 | IrInstSrcFrameType *inst = ir_build_instruction<IrInstSrcFrameType>(irb, scope, source_node); |
| 3077 | instruction->fn = fn; | 3894 | inst->fn = fn; |
| 3078 | | 3895 | |
| 3079 | ir_ref_instruction(fn, irb->current_basic_block); | 3896 | ir_ref_instruction(fn, irb->current_basic_block); |
| 3080 | | 3897 | |
| 3081 | return &instruction->base; | 3898 | return &inst->base; |
| 3082 | } | 3899 | } |
| 3083 | | 3900 | |
| 3084 | static IrInstruction *ir_build_frame_size_src(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *fn) { | 3901 | static IrInstSrc *ir_build_frame_size_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *fn) { |
| 3085 | IrInstructionFrameSizeSrc *instruction = ir_build_instruction<IrInstructionFrameSizeSrc>(irb, scope, source_node); | 3902 | IrInstSrcFrameSize *inst = ir_build_instruction<IrInstSrcFrameSize>(irb, scope, source_node); |
| 3086 | instruction->fn = fn; | 3903 | inst->fn = fn; |
| 3087 | | 3904 | |
| 3088 | ir_ref_instruction(fn, irb->current_basic_block); | 3905 | ir_ref_instruction(fn, irb->current_basic_block); |
| 3089 | | 3906 | |
| 3090 | return &instruction->base; | 3907 | return &inst->base; |
| 3091 | } | 3908 | } |
| 3092 | | 3909 | |
| 3093 | static IrInstruction *ir_build_frame_size_gen(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *fn) | 3910 | static IrInstGen *ir_build_frame_size_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *fn) |
| 3094 | { | 3911 | { |
| 3095 | IrInstructionFrameSizeGen *instruction = ir_build_instruction<IrInstructionFrameSizeGen>(irb, scope, source_node); | 3912 | IrInstGenFrameSize *inst = ir_build_inst_gen<IrInstGenFrameSize>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| 3096 | instruction->fn = fn; | 3913 | inst->base.value->type = ira->codegen->builtin_types.entry_usize; |
| | 3914 | inst->fn = fn; |
| 3097 | | 3915 | |
| 3098 | ir_ref_instruction(fn, irb->current_basic_block); | 3916 | ir_ref_inst_gen(fn, ira->new_irb.current_basic_block); |
| 3099 | | 3917 | |
| 3100 | return &instruction->base; | 3918 | return &inst->base; |
| 3101 | } | 3919 | } |
| 3102 | | 3920 | |
| 3103 | static IrInstruction *ir_build_overflow_op(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3921 | static IrInstSrc *ir_build_overflow_op_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3104 | IrOverflowOp op, IrInstruction *type_value, IrInstruction *op1, IrInstruction *op2, | 3922 | IrOverflowOp op, IrInstSrc *type_value, IrInstSrc *op1, IrInstSrc *op2, IrInstSrc *result_ptr) |
| 3105 | IrInstruction *result_ptr, ZigType *result_ptr_type) | | |
| 3106 | { | 3923 | { |
| 3107 | IrInstructionOverflowOp *instruction = ir_build_instruction<IrInstructionOverflowOp>(irb, scope, source_node); | 3924 | IrInstSrcOverflowOp *instruction = ir_build_instruction<IrInstSrcOverflowOp>(irb, scope, source_node); |
| 3108 | instruction->op = op; | 3925 | instruction->op = op; |
| 3109 | instruction->type_value = type_value; | 3926 | instruction->type_value = type_value; |
| 3110 | instruction->op1 = op1; | 3927 | instruction->op1 = op1; |
| 3111 | instruction->op2 = op2; | 3928 | instruction->op2 = op2; |
| 3112 | instruction->result_ptr = result_ptr; | 3929 | instruction->result_ptr = result_ptr; |
| 3113 | instruction->result_ptr_type = result_ptr_type; | | |
| 3114 | | 3930 | |
| 3115 | ir_ref_instruction(type_value, irb->current_basic_block); | 3931 | ir_ref_instruction(type_value, irb->current_basic_block); |
| 3116 | ir_ref_instruction(op1, irb->current_basic_block); | 3932 | ir_ref_instruction(op1, irb->current_basic_block); |
| ... | @@ -3120,49 +3936,30 @@ static IrInstruction *ir_build_overflow_op(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3120,49 +3936,30 @@ static IrInstruction *ir_build_overflow_op(IrBuilder *irb, Scope *scope, AstNode |
| 3120 | return &instruction->base; | 3936 | return &instruction->base; |
| 3121 | } | 3937 | } |
| 3122 | | 3938 | |
| | 3939 | static IrInstGen *ir_build_overflow_op_gen(IrAnalyze *ira, IrInst *source_instr, |
| | 3940 | IrOverflowOp op, IrInstGen *op1, IrInstGen *op2, IrInstGen *result_ptr, |
| | 3941 | ZigType *result_ptr_type) |
| | 3942 | { |
| | 3943 | IrInstGenOverflowOp *instruction = ir_build_inst_gen<IrInstGenOverflowOp>(&ira->new_irb, |
| | 3944 | source_instr->scope, source_instr->source_node); |
| | 3945 | instruction->base.value->type = ira->codegen->builtin_types.entry_bool; |
| | 3946 | instruction->op = op; |
| | 3947 | instruction->op1 = op1; |
| | 3948 | instruction->op2 = op2; |
| | 3949 | instruction->result_ptr = result_ptr; |
| | 3950 | instruction->result_ptr_type = result_ptr_type; |
| 3123 | | 3951 | |
| 3124 | //TODO Powi, Pow, minnum, maxnum, maximum, minimum, copysign, | 3952 | ir_ref_inst_gen(op1, ira->new_irb.current_basic_block); |
| 3125 | // lround, llround, lrint, llrint | 3953 | ir_ref_inst_gen(op2, ira->new_irb.current_basic_block); |
| 3126 | // So far this is only non-complicated type functions. | 3954 | ir_ref_inst_gen(result_ptr, ira->new_irb.current_basic_block); |
| 3127 | const char *float_op_to_name(BuiltinFnId op) { | 3955 | |
| 3128 | switch (op) { | 3956 | return &instruction->base; |
| 3129 | case BuiltinFnIdSqrt: | | |
| 3130 | return "sqrt"; | | |
| 3131 | case BuiltinFnIdSin: | | |
| 3132 | return "sin"; | | |
| 3133 | case BuiltinFnIdCos: | | |
| 3134 | return "cos"; | | |
| 3135 | case BuiltinFnIdExp: | | |
| 3136 | return "exp"; | | |
| 3137 | case BuiltinFnIdExp2: | | |
| 3138 | return "exp2"; | | |
| 3139 | case BuiltinFnIdLog: | | |
| 3140 | return "log"; | | |
| 3141 | case BuiltinFnIdLog10: | | |
| 3142 | return "log10"; | | |
| 3143 | case BuiltinFnIdLog2: | | |
| 3144 | return "log2"; | | |
| 3145 | case BuiltinFnIdFabs: | | |
| 3146 | return "fabs"; | | |
| 3147 | case BuiltinFnIdFloor: | | |
| 3148 | return "floor"; | | |
| 3149 | case BuiltinFnIdCeil: | | |
| 3150 | return "ceil"; | | |
| 3151 | case BuiltinFnIdTrunc: | | |
| 3152 | return "trunc"; | | |
| 3153 | case BuiltinFnIdNearbyInt: | | |
| 3154 | return "nearbyint"; | | |
| 3155 | case BuiltinFnIdRound: | | |
| 3156 | return "round"; | | |
| 3157 | default: | | |
| 3158 | zig_unreachable(); | | |
| 3159 | } | | |
| 3160 | } | 3957 | } |
| 3161 | | 3958 | |
| 3162 | static IrInstruction *ir_build_float_op(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *operand, | 3959 | static IrInstSrc *ir_build_float_op_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *operand, |
| 3163 | BuiltinFnId fn_id) | 3960 | BuiltinFnId fn_id) |
| 3164 | { | 3961 | { |
| 3165 | IrInstructionFloatOp *instruction = ir_build_instruction<IrInstructionFloatOp>(irb, scope, source_node); | 3962 | IrInstSrcFloatOp *instruction = ir_build_instruction<IrInstSrcFloatOp>(irb, scope, source_node); |
| 3166 | instruction->operand = operand; | 3963 | instruction->operand = operand; |
| 3167 | instruction->fn_id = fn_id; | 3964 | instruction->fn_id = fn_id; |
| 3168 | | 3965 | |
| ... | @@ -3171,9 +3968,24 @@ static IrInstruction *ir_build_float_op(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -3171,9 +3968,24 @@ static IrInstruction *ir_build_float_op(IrBuilder *irb, Scope *scope, AstNode *s |
| 3171 | return &instruction->base; | 3968 | return &instruction->base; |
| 3172 | } | 3969 | } |
| 3173 | | 3970 | |
| 3174 | static IrInstruction *ir_build_mul_add(IrBuilder *irb, Scope *scope, AstNode *source_node, | 3971 | static IrInstGen *ir_build_float_op_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *operand, |
| 3175 | IrInstruction *type_value, IrInstruction *op1, IrInstruction *op2, IrInstruction *op3) { | 3972 | BuiltinFnId fn_id, ZigType *operand_type) |
| 3176 | IrInstructionMulAdd *instruction = ir_build_instruction<IrInstructionMulAdd>(irb, scope, source_node); | 3973 | { |
| | 3974 | IrInstGenFloatOp *instruction = ir_build_inst_gen<IrInstGenFloatOp>(&ira->new_irb, |
| | 3975 | source_instr->scope, source_instr->source_node); |
| | 3976 | instruction->base.value->type = operand_type; |
| | 3977 | instruction->operand = operand; |
| | 3978 | instruction->fn_id = fn_id; |
| | 3979 | |
| | 3980 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| | 3981 | |
| | 3982 | return &instruction->base; |
| | 3983 | } |
| | 3984 | |
| | 3985 | static IrInstSrc *ir_build_mul_add_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 3986 | IrInstSrc *type_value, IrInstSrc *op1, IrInstSrc *op2, IrInstSrc *op3) |
| | 3987 | { |
| | 3988 | IrInstSrcMulAdd *instruction = ir_build_instruction<IrInstSrcMulAdd>(irb, scope, source_node); |
| 3177 | instruction->type_value = type_value; | 3989 | instruction->type_value = type_value; |
| 3178 | instruction->op1 = op1; | 3990 | instruction->op1 = op1; |
| 3179 | instruction->op2 = op2; | 3991 | instruction->op2 = op2; |
| ... | @@ -3187,8 +3999,25 @@ static IrInstruction *ir_build_mul_add(IrBuilder *irb, Scope *scope, AstNode *so | ... | @@ -3187,8 +3999,25 @@ static IrInstruction *ir_build_mul_add(IrBuilder *irb, Scope *scope, AstNode *so |
| 3187 | return &instruction->base; | 3999 | return &instruction->base; |
| 3188 | } | 4000 | } |
| 3189 | | 4001 | |
| 3190 | static IrInstruction *ir_build_align_of(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *type_value) { | 4002 | static IrInstGen *ir_build_mul_add_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *op1, IrInstGen *op2, |
| 3191 | IrInstructionAlignOf *instruction = ir_build_instruction<IrInstructionAlignOf>(irb, scope, source_node); | 4003 | IrInstGen *op3, ZigType *expr_type) |
| | 4004 | { |
| | 4005 | IrInstGenMulAdd *instruction = ir_build_inst_gen<IrInstGenMulAdd>(&ira->new_irb, |
| | 4006 | source_instr->scope, source_instr->source_node); |
| | 4007 | instruction->base.value->type = expr_type; |
| | 4008 | instruction->op1 = op1; |
| | 4009 | instruction->op2 = op2; |
| | 4010 | instruction->op3 = op3; |
| | 4011 | |
| | 4012 | ir_ref_inst_gen(op1, ira->new_irb.current_basic_block); |
| | 4013 | ir_ref_inst_gen(op2, ira->new_irb.current_basic_block); |
| | 4014 | ir_ref_inst_gen(op3, ira->new_irb.current_basic_block); |
| | 4015 | |
| | 4016 | return &instruction->base; |
| | 4017 | } |
| | 4018 | |
| | 4019 | static IrInstSrc *ir_build_align_of(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type_value) { |
| | 4020 | IrInstSrcAlignOf *instruction = ir_build_instruction<IrInstSrcAlignOf>(irb, scope, source_node); |
| 3192 | instruction->type_value = type_value; | 4021 | instruction->type_value = type_value; |
| 3193 | | 4022 | |
| 3194 | ir_ref_instruction(type_value, irb->current_basic_block); | 4023 | ir_ref_instruction(type_value, irb->current_basic_block); |
| ... | @@ -3196,10 +4025,10 @@ static IrInstruction *ir_build_align_of(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -3196,10 +4025,10 @@ static IrInstruction *ir_build_align_of(IrBuilder *irb, Scope *scope, AstNode *s |
| 3196 | return &instruction->base; | 4025 | return &instruction->base; |
| 3197 | } | 4026 | } |
| 3198 | | 4027 | |
| 3199 | static IrInstruction *ir_build_test_err_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4028 | static IrInstSrc *ir_build_test_err_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3200 | IrInstruction *base_ptr, bool resolve_err_set, bool base_ptr_is_payload) | 4029 | IrInstSrc *base_ptr, bool resolve_err_set, bool base_ptr_is_payload) |
| 3201 | { | 4030 | { |
| 3202 | IrInstructionTestErrSrc *instruction = ir_build_instruction<IrInstructionTestErrSrc>(irb, scope, source_node); | 4031 | IrInstSrcTestErr *instruction = ir_build_instruction<IrInstSrcTestErr>(irb, scope, source_node); |
| 3203 | instruction->base_ptr = base_ptr; | 4032 | instruction->base_ptr = base_ptr; |
| 3204 | instruction->resolve_err_set = resolve_err_set; | 4033 | instruction->resolve_err_set = resolve_err_set; |
| 3205 | instruction->base_ptr_is_payload = base_ptr_is_payload; | 4034 | instruction->base_ptr_is_payload = base_ptr_is_payload; |
| ... | @@ -3209,48 +4038,72 @@ static IrInstruction *ir_build_test_err_src(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -3209,48 +4038,72 @@ static IrInstruction *ir_build_test_err_src(IrBuilder *irb, Scope *scope, AstNod |
| 3209 | return &instruction->base; | 4038 | return &instruction->base; |
| 3210 | } | 4039 | } |
| 3211 | | 4040 | |
| 3212 | static IrInstruction *ir_build_test_err_gen(IrAnalyze *ira, IrInstruction *source_instruction, | 4041 | static IrInstGen *ir_build_test_err_gen(IrAnalyze *ira, IrInst *source_instruction, IrInstGen *err_union) { |
| 3213 | IrInstruction *err_union) | 4042 | IrInstGenTestErr *instruction = ir_build_inst_gen<IrInstGenTestErr>( |
| 3214 | { | | |
| 3215 | IrInstructionTestErrGen *instruction = ir_build_instruction<IrInstructionTestErrGen>( | | |
| 3216 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 4043 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 3217 | instruction->base.value->type = ira->codegen->builtin_types.entry_bool; | 4044 | instruction->base.value->type = ira->codegen->builtin_types.entry_bool; |
| 3218 | instruction->err_union = err_union; | 4045 | instruction->err_union = err_union; |
| 3219 | | 4046 | |
| 3220 | ir_ref_instruction(err_union, ira->new_irb.current_basic_block); | 4047 | ir_ref_inst_gen(err_union, ira->new_irb.current_basic_block); |
| 3221 | | 4048 | |
| 3222 | return &instruction->base; | 4049 | return &instruction->base; |
| 3223 | } | 4050 | } |
| 3224 | | 4051 | |
| 3225 | static IrInstruction *ir_build_unwrap_err_code(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4052 | static IrInstSrc *ir_build_unwrap_err_code_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3226 | IrInstruction *err_union_ptr) | 4053 | IrInstSrc *err_union_ptr) |
| 3227 | { | 4054 | { |
| 3228 | IrInstructionUnwrapErrCode *instruction = ir_build_instruction<IrInstructionUnwrapErrCode>(irb, scope, source_node); | 4055 | IrInstSrcUnwrapErrCode *inst = ir_build_instruction<IrInstSrcUnwrapErrCode>(irb, scope, source_node); |
| 3229 | instruction->err_union_ptr = err_union_ptr; | 4056 | inst->err_union_ptr = err_union_ptr; |
| 3230 | | 4057 | |
| 3231 | ir_ref_instruction(err_union_ptr, irb->current_basic_block); | 4058 | ir_ref_instruction(err_union_ptr, irb->current_basic_block); |
| 3232 | | 4059 | |
| 3233 | return &instruction->base; | 4060 | return &inst->base; |
| 3234 | } | 4061 | } |
| 3235 | | 4062 | |
| 3236 | static IrInstruction *ir_build_unwrap_err_payload(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4063 | static IrInstGen *ir_build_unwrap_err_code_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, |
| 3237 | IrInstruction *value, bool safety_check_on, bool initializing) | 4064 | IrInstGen *err_union_ptr, ZigType *result_type) |
| 3238 | { | 4065 | { |
| 3239 | IrInstructionUnwrapErrPayload *instruction = ir_build_instruction<IrInstructionUnwrapErrPayload>(irb, scope, source_node); | 4066 | IrInstGenUnwrapErrCode *inst = ir_build_inst_gen<IrInstGenUnwrapErrCode>(&ira->new_irb, scope, source_node); |
| 3240 | instruction->value = value; | 4067 | inst->base.value->type = result_type; |
| 3241 | instruction->safety_check_on = safety_check_on; | 4068 | inst->err_union_ptr = err_union_ptr; |
| 3242 | instruction->initializing = initializing; | 4069 | |
| | 4070 | ir_ref_inst_gen(err_union_ptr, ira->new_irb.current_basic_block); |
| | 4071 | |
| | 4072 | return &inst->base; |
| | 4073 | } |
| | 4074 | |
| | 4075 | static IrInstSrc *ir_build_unwrap_err_payload_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 4076 | IrInstSrc *value, bool safety_check_on, bool initializing) |
| | 4077 | { |
| | 4078 | IrInstSrcUnwrapErrPayload *inst = ir_build_instruction<IrInstSrcUnwrapErrPayload>(irb, scope, source_node); |
| | 4079 | inst->value = value; |
| | 4080 | inst->safety_check_on = safety_check_on; |
| | 4081 | inst->initializing = initializing; |
| 3243 | | 4082 | |
| 3244 | ir_ref_instruction(value, irb->current_basic_block); | 4083 | ir_ref_instruction(value, irb->current_basic_block); |
| 3245 | | 4084 | |
| 3246 | return &instruction->base; | 4085 | return &inst->base; |
| | 4086 | } |
| | 4087 | |
| | 4088 | static IrInstGen *ir_build_unwrap_err_payload_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, |
| | 4089 | IrInstGen *value, bool safety_check_on, bool initializing, ZigType *result_type) |
| | 4090 | { |
| | 4091 | IrInstGenUnwrapErrPayload *inst = ir_build_inst_gen<IrInstGenUnwrapErrPayload>(&ira->new_irb, scope, source_node); |
| | 4092 | inst->base.value->type = result_type; |
| | 4093 | inst->value = value; |
| | 4094 | inst->safety_check_on = safety_check_on; |
| | 4095 | inst->initializing = initializing; |
| | 4096 | |
| | 4097 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| | 4098 | |
| | 4099 | return &inst->base; |
| 3247 | } | 4100 | } |
| 3248 | | 4101 | |
| 3249 | static IrInstruction *ir_build_fn_proto(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4102 | static IrInstSrc *ir_build_fn_proto(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3250 | IrInstruction **param_types, IrInstruction *align_value, IrInstruction *callconv_value, | 4103 | IrInstSrc **param_types, IrInstSrc *align_value, IrInstSrc *callconv_value, |
| 3251 | IrInstruction *return_type, bool is_var_args) | 4104 | IrInstSrc *return_type, bool is_var_args) |
| 3252 | { | 4105 | { |
| 3253 | IrInstructionFnProto *instruction = ir_build_instruction<IrInstructionFnProto>(irb, scope, source_node); | 4106 | IrInstSrcFnProto *instruction = ir_build_instruction<IrInstSrcFnProto>(irb, scope, source_node); |
| 3254 | instruction->param_types = param_types; | 4107 | instruction->param_types = param_types; |
| 3255 | instruction->align_value = align_value; | 4108 | instruction->align_value = align_value; |
| 3256 | instruction->callconv_value = callconv_value; | 4109 | instruction->callconv_value = callconv_value; |
| ... | @@ -3270,8 +4123,8 @@ static IrInstruction *ir_build_fn_proto(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -3270,8 +4123,8 @@ static IrInstruction *ir_build_fn_proto(IrBuilder *irb, Scope *scope, AstNode *s |
| 3270 | return &instruction->base; | 4123 | return &instruction->base; |
| 3271 | } | 4124 | } |
| 3272 | | 4125 | |
| 3273 | static IrInstruction *ir_build_test_comptime(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *value) { | 4126 | static IrInstSrc *ir_build_test_comptime(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *value) { |
| 3274 | IrInstructionTestComptime *instruction = ir_build_instruction<IrInstructionTestComptime>(irb, scope, source_node); | 4127 | IrInstSrcTestComptime *instruction = ir_build_instruction<IrInstSrcTestComptime>(irb, scope, source_node); |
| 3275 | instruction->value = value; | 4128 | instruction->value = value; |
| 3276 | | 4129 | |
| 3277 | ir_ref_instruction(value, irb->current_basic_block); | 4130 | ir_ref_instruction(value, irb->current_basic_block); |
| ... | @@ -3279,10 +4132,10 @@ static IrInstruction *ir_build_test_comptime(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3279,10 +4132,10 @@ static IrInstruction *ir_build_test_comptime(IrBuilder *irb, Scope *scope, AstNo |
| 3279 | return &instruction->base; | 4132 | return &instruction->base; |
| 3280 | } | 4133 | } |
| 3281 | | 4134 | |
| 3282 | static IrInstruction *ir_build_ptr_cast_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4135 | static IrInstSrc *ir_build_ptr_cast_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3283 | IrInstruction *dest_type, IrInstruction *ptr, bool safety_check_on) | 4136 | IrInstSrc *dest_type, IrInstSrc *ptr, bool safety_check_on) |
| 3284 | { | 4137 | { |
| 3285 | IrInstructionPtrCastSrc *instruction = ir_build_instruction<IrInstructionPtrCastSrc>( | 4138 | IrInstSrcPtrCast *instruction = ir_build_instruction<IrInstSrcPtrCast>( |
| 3286 | irb, scope, source_node); | 4139 | irb, scope, source_node); |
| 3287 | instruction->dest_type = dest_type; | 4140 | instruction->dest_type = dest_type; |
| 3288 | instruction->ptr = ptr; | 4141 | instruction->ptr = ptr; |
| ... | @@ -3294,39 +4147,24 @@ static IrInstruction *ir_build_ptr_cast_src(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -3294,39 +4147,24 @@ static IrInstruction *ir_build_ptr_cast_src(IrBuilder *irb, Scope *scope, AstNod |
| 3294 | return &instruction->base; | 4147 | return &instruction->base; |
| 3295 | } | 4148 | } |
| 3296 | | 4149 | |
| 3297 | static IrInstruction *ir_build_ptr_cast_gen(IrAnalyze *ira, IrInstruction *source_instruction, | 4150 | static IrInstGen *ir_build_ptr_cast_gen(IrAnalyze *ira, IrInst *source_instruction, |
| 3298 | ZigType *ptr_type, IrInstruction *ptr, bool safety_check_on) | 4151 | ZigType *ptr_type, IrInstGen *ptr, bool safety_check_on) |
| 3299 | { | 4152 | { |
| 3300 | IrInstructionPtrCastGen *instruction = ir_build_instruction<IrInstructionPtrCastGen>( | 4153 | IrInstGenPtrCast *instruction = ir_build_inst_gen<IrInstGenPtrCast>( |
| 3301 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 4154 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 3302 | instruction->base.value->type = ptr_type; | 4155 | instruction->base.value->type = ptr_type; |
| 3303 | instruction->ptr = ptr; | 4156 | instruction->ptr = ptr; |
| 3304 | instruction->safety_check_on = safety_check_on; | 4157 | instruction->safety_check_on = safety_check_on; |
| 3305 | | 4158 | |
| 3306 | ir_ref_instruction(ptr, ira->new_irb.current_basic_block); | 4159 | ir_ref_inst_gen(ptr, ira->new_irb.current_basic_block); |
| 3307 | | 4160 | |
| 3308 | return &instruction->base; | 4161 | return &instruction->base; |
| 3309 | } | 4162 | } |
| 3310 | | 4163 | |
| 3311 | static IrInstruction *ir_build_load_ptr_gen(IrAnalyze *ira, IrInstruction *source_instruction, | 4164 | static IrInstSrc *ir_build_implicit_cast(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3312 | IrInstruction *ptr, ZigType *ty, IrInstruction *result_loc) | 4165 | IrInstSrc *operand, ResultLocCast *result_loc_cast) |
| 3313 | { | 4166 | { |
| 3314 | IrInstructionLoadPtrGen *instruction = ir_build_instruction<IrInstructionLoadPtrGen>( | 4167 | IrInstSrcImplicitCast *instruction = ir_build_instruction<IrInstSrcImplicitCast>(irb, scope, source_node); |
| 3315 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | | |
| 3316 | instruction->base.value->type = ty; | | |
| 3317 | instruction->ptr = ptr; | | |
| 3318 | instruction->result_loc = result_loc; | | |
| 3319 | | | |
| 3320 | ir_ref_instruction(ptr, ira->new_irb.current_basic_block); | | |
| 3321 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | | |
| 3322 | | | |
| 3323 | return &instruction->base; | | |
| 3324 | } | | |
| 3325 | | | |
| 3326 | static IrInstruction *ir_build_implicit_cast(IrBuilder *irb, Scope *scope, AstNode *source_node, | | |
| 3327 | IrInstruction *operand, ResultLocCast *result_loc_cast) | | |
| 3328 | { | | |
| 3329 | IrInstructionImplicitCast *instruction = ir_build_instruction<IrInstructionImplicitCast>(irb, scope, source_node); | | |
| 3330 | instruction->operand = operand; | 4168 | instruction->operand = operand; |
| 3331 | instruction->result_loc_cast = result_loc_cast; | 4169 | instruction->result_loc_cast = result_loc_cast; |
| 3332 | | 4170 | |
| ... | @@ -3335,10 +4173,10 @@ static IrInstruction *ir_build_implicit_cast(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3335,10 +4173,10 @@ static IrInstruction *ir_build_implicit_cast(IrBuilder *irb, Scope *scope, AstNo |
| 3335 | return &instruction->base; | 4173 | return &instruction->base; |
| 3336 | } | 4174 | } |
| 3337 | | 4175 | |
| 3338 | static IrInstruction *ir_build_bit_cast_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4176 | static IrInstSrc *ir_build_bit_cast_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3339 | IrInstruction *operand, ResultLocBitCast *result_loc_bit_cast) | 4177 | IrInstSrc *operand, ResultLocBitCast *result_loc_bit_cast) |
| 3340 | { | 4178 | { |
| 3341 | IrInstructionBitCastSrc *instruction = ir_build_instruction<IrInstructionBitCastSrc>(irb, scope, source_node); | 4179 | IrInstSrcBitCast *instruction = ir_build_instruction<IrInstSrcBitCast>(irb, scope, source_node); |
| 3342 | instruction->operand = operand; | 4180 | instruction->operand = operand; |
| 3343 | instruction->result_loc_bit_cast = result_loc_bit_cast; | 4181 | instruction->result_loc_bit_cast = result_loc_bit_cast; |
| 3344 | | 4182 | |
| ... | @@ -3347,62 +4185,81 @@ static IrInstruction *ir_build_bit_cast_src(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -3347,62 +4185,81 @@ static IrInstruction *ir_build_bit_cast_src(IrBuilder *irb, Scope *scope, AstNod |
| 3347 | return &instruction->base; | 4185 | return &instruction->base; |
| 3348 | } | 4186 | } |
| 3349 | | 4187 | |
| 3350 | static IrInstruction *ir_build_bit_cast_gen(IrAnalyze *ira, IrInstruction *source_instruction, | 4188 | static IrInstGen *ir_build_bit_cast_gen(IrAnalyze *ira, IrInst *source_instruction, |
| 3351 | IrInstruction *operand, ZigType *ty) | 4189 | IrInstGen *operand, ZigType *ty) |
| 3352 | { | 4190 | { |
| 3353 | IrInstructionBitCastGen *instruction = ir_build_instruction<IrInstructionBitCastGen>( | 4191 | IrInstGenBitCast *instruction = ir_build_inst_gen<IrInstGenBitCast>( |
| 3354 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 4192 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 3355 | instruction->base.value->type = ty; | 4193 | instruction->base.value->type = ty; |
| 3356 | instruction->operand = operand; | 4194 | instruction->operand = operand; |
| 3357 | | 4195 | |
| 3358 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); | 4196 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 3359 | | 4197 | |
| 3360 | return &instruction->base; | 4198 | return &instruction->base; |
| 3361 | } | 4199 | } |
| 3362 | | 4200 | |
| 3363 | static IrInstruction *ir_build_widen_or_shorten(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4201 | static IrInstGen *ir_build_widen_or_shorten(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, |
| 3364 | IrInstruction *target) | 4202 | ZigType *result_type) |
| 3365 | { | 4203 | { |
| 3366 | IrInstructionWidenOrShorten *instruction = ir_build_instruction<IrInstructionWidenOrShorten>( | 4204 | IrInstGenWidenOrShorten *inst = ir_build_inst_gen<IrInstGenWidenOrShorten>(&ira->new_irb, scope, source_node); |
| 3367 | irb, scope, source_node); | 4205 | inst->base.value->type = result_type; |
| 3368 | instruction->target = target; | 4206 | inst->target = target; |
| 3369 | | 4207 | |
| 3370 | ir_ref_instruction(target, irb->current_basic_block); | 4208 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| 3371 | | 4209 | |
| 3372 | return &instruction->base; | 4210 | return &inst->base; |
| 3373 | } | 4211 | } |
| 3374 | | 4212 | |
| 3375 | static IrInstruction *ir_build_int_to_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4213 | static IrInstSrc *ir_build_int_to_ptr_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3376 | IrInstruction *dest_type, IrInstruction *target) | 4214 | IrInstSrc *dest_type, IrInstSrc *target) |
| 3377 | { | 4215 | { |
| 3378 | IrInstructionIntToPtr *instruction = ir_build_instruction<IrInstructionIntToPtr>( | 4216 | IrInstSrcIntToPtr *instruction = ir_build_instruction<IrInstSrcIntToPtr>(irb, scope, source_node); |
| 3379 | irb, scope, source_node); | | |
| 3380 | instruction->dest_type = dest_type; | 4217 | instruction->dest_type = dest_type; |
| 3381 | instruction->target = target; | 4218 | instruction->target = target; |
| 3382 | | 4219 | |
| 3383 | if (dest_type) ir_ref_instruction(dest_type, irb->current_basic_block); | 4220 | ir_ref_instruction(dest_type, irb->current_basic_block); |
| 3384 | ir_ref_instruction(target, irb->current_basic_block); | 4221 | ir_ref_instruction(target, irb->current_basic_block); |
| 3385 | | 4222 | |
| 3386 | return &instruction->base; | 4223 | return &instruction->base; |
| 3387 | } | 4224 | } |
| 3388 | | 4225 | |
| 3389 | static IrInstruction *ir_build_ptr_to_int(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4226 | static IrInstGen *ir_build_int_to_ptr_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, |
| 3390 | IrInstruction *target) | 4227 | IrInstGen *target, ZigType *ptr_type) |
| 3391 | { | 4228 | { |
| 3392 | IrInstructionPtrToInt *instruction = ir_build_instruction<IrInstructionPtrToInt>( | 4229 | IrInstGenIntToPtr *instruction = ir_build_inst_gen<IrInstGenIntToPtr>(&ira->new_irb, scope, source_node); |
| 3393 | irb, scope, source_node); | 4230 | instruction->base.value->type = ptr_type; |
| 3394 | instruction->target = target; | 4231 | instruction->target = target; |
| 3395 | | 4232 | |
| 3396 | ir_ref_instruction(target, irb->current_basic_block); | 4233 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| 3397 | | 4234 | |
| 3398 | return &instruction->base; | 4235 | return &instruction->base; |
| 3399 | } | 4236 | } |
| 3400 | | 4237 | |
| 3401 | static IrInstruction *ir_build_int_to_enum(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4238 | static IrInstSrc *ir_build_ptr_to_int_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3402 | IrInstruction *dest_type, IrInstruction *target) | 4239 | IrInstSrc *target) |
| 3403 | { | 4240 | { |
| 3404 | IrInstructionIntToEnum *instruction = ir_build_instruction<IrInstructionIntToEnum>( | 4241 | IrInstSrcPtrToInt *inst = ir_build_instruction<IrInstSrcPtrToInt>(irb, scope, source_node); |
| 3405 | irb, scope, source_node); | 4242 | inst->target = target; |
| | 4243 | |
| | 4244 | ir_ref_instruction(target, irb->current_basic_block); |
| | 4245 | |
| | 4246 | return &inst->base; |
| | 4247 | } |
| | 4248 | |
| | 4249 | static IrInstGen *ir_build_ptr_to_int_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *target) { |
| | 4250 | IrInstGenPtrToInt *inst = ir_build_inst_gen<IrInstGenPtrToInt>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| | 4251 | inst->base.value->type = ira->codegen->builtin_types.entry_usize; |
| | 4252 | inst->target = target; |
| | 4253 | |
| | 4254 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| | 4255 | |
| | 4256 | return &inst->base; |
| | 4257 | } |
| | 4258 | |
| | 4259 | static IrInstSrc *ir_build_int_to_enum_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 4260 | IrInstSrc *dest_type, IrInstSrc *target) |
| | 4261 | { |
| | 4262 | IrInstSrcIntToEnum *instruction = ir_build_instruction<IrInstSrcIntToEnum>(irb, scope, source_node); |
| 3406 | instruction->dest_type = dest_type; | 4263 | instruction->dest_type = dest_type; |
| 3407 | instruction->target = target; | 4264 | instruction->target = target; |
| 3408 | | 4265 | |
| ... | @@ -3412,12 +4269,22 @@ static IrInstruction *ir_build_int_to_enum(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3412,12 +4269,22 @@ static IrInstruction *ir_build_int_to_enum(IrBuilder *irb, Scope *scope, AstNode |
| 3412 | return &instruction->base; | 4269 | return &instruction->base; |
| 3413 | } | 4270 | } |
| 3414 | | 4271 | |
| | 4272 | static IrInstGen *ir_build_int_to_enum_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, |
| | 4273 | ZigType *dest_type, IrInstGen *target) |
| | 4274 | { |
| | 4275 | IrInstGenIntToEnum *instruction = ir_build_inst_gen<IrInstGenIntToEnum>(&ira->new_irb, scope, source_node); |
| | 4276 | instruction->base.value->type = dest_type; |
| | 4277 | instruction->target = target; |
| | 4278 | |
| | 4279 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| 3415 | | 4280 | |
| | 4281 | return &instruction->base; |
| | 4282 | } |
| 3416 | | 4283 | |
| 3417 | static IrInstruction *ir_build_enum_to_int(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4284 | static IrInstSrc *ir_build_enum_to_int(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3418 | IrInstruction *target) | 4285 | IrInstSrc *target) |
| 3419 | { | 4286 | { |
| 3420 | IrInstructionEnumToInt *instruction = ir_build_instruction<IrInstructionEnumToInt>( | 4287 | IrInstSrcEnumToInt *instruction = ir_build_instruction<IrInstSrcEnumToInt>( |
| 3421 | irb, scope, source_node); | 4288 | irb, scope, source_node); |
| 3422 | instruction->target = target; | 4289 | instruction->target = target; |
| 3423 | | 4290 | |
| ... | @@ -3426,11 +4293,10 @@ static IrInstruction *ir_build_enum_to_int(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3426,11 +4293,10 @@ static IrInstruction *ir_build_enum_to_int(IrBuilder *irb, Scope *scope, AstNode |
| 3426 | return &instruction->base; | 4293 | return &instruction->base; |
| 3427 | } | 4294 | } |
| 3428 | | 4295 | |
| 3429 | static IrInstruction *ir_build_int_to_err(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4296 | static IrInstSrc *ir_build_int_to_err_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3430 | IrInstruction *target) | 4297 | IrInstSrc *target) |
| 3431 | { | 4298 | { |
| 3432 | IrInstructionIntToErr *instruction = ir_build_instruction<IrInstructionIntToErr>( | 4299 | IrInstSrcIntToErr *instruction = ir_build_instruction<IrInstSrcIntToErr>(irb, scope, source_node); |
| 3433 | irb, scope, source_node); | | |
| 3434 | instruction->target = target; | 4300 | instruction->target = target; |
| 3435 | | 4301 | |
| 3436 | ir_ref_instruction(target, irb->current_basic_block); | 4302 | ir_ref_instruction(target, irb->current_basic_block); |
| ... | @@ -3438,10 +4304,22 @@ static IrInstruction *ir_build_int_to_err(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3438,10 +4304,22 @@ static IrInstruction *ir_build_int_to_err(IrBuilder *irb, Scope *scope, AstNode |
| 3438 | return &instruction->base; | 4304 | return &instruction->base; |
| 3439 | } | 4305 | } |
| 3440 | | 4306 | |
| 3441 | static IrInstruction *ir_build_err_to_int(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4307 | static IrInstGen *ir_build_int_to_err_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, |
| 3442 | IrInstruction *target) | 4308 | ZigType *wanted_type) |
| | 4309 | { |
| | 4310 | IrInstGenIntToErr *instruction = ir_build_inst_gen<IrInstGenIntToErr>(&ira->new_irb, scope, source_node); |
| | 4311 | instruction->base.value->type = wanted_type; |
| | 4312 | instruction->target = target; |
| | 4313 | |
| | 4314 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| | 4315 | |
| | 4316 | return &instruction->base; |
| | 4317 | } |
| | 4318 | |
| | 4319 | static IrInstSrc *ir_build_err_to_int_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 4320 | IrInstSrc *target) |
| 3443 | { | 4321 | { |
| 3444 | IrInstructionErrToInt *instruction = ir_build_instruction<IrInstructionErrToInt>( | 4322 | IrInstSrcErrToInt *instruction = ir_build_instruction<IrInstSrcErrToInt>( |
| 3445 | irb, scope, source_node); | 4323 | irb, scope, source_node); |
| 3446 | instruction->target = target; | 4324 | instruction->target = target; |
| 3447 | | 4325 | |
| ... | @@ -3450,11 +4328,23 @@ static IrInstruction *ir_build_err_to_int(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3450,11 +4328,23 @@ static IrInstruction *ir_build_err_to_int(IrBuilder *irb, Scope *scope, AstNode |
| 3450 | return &instruction->base; | 4328 | return &instruction->base; |
| 3451 | } | 4329 | } |
| 3452 | | 4330 | |
| 3453 | static IrInstruction *ir_build_check_switch_prongs(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4331 | static IrInstGen *ir_build_err_to_int_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, |
| 3454 | IrInstruction *target_value, IrInstructionCheckSwitchProngsRange *ranges, size_t range_count, | 4332 | ZigType *wanted_type) |
| | 4333 | { |
| | 4334 | IrInstGenErrToInt *instruction = ir_build_inst_gen<IrInstGenErrToInt>(&ira->new_irb, scope, source_node); |
| | 4335 | instruction->base.value->type = wanted_type; |
| | 4336 | instruction->target = target; |
| | 4337 | |
| | 4338 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| | 4339 | |
| | 4340 | return &instruction->base; |
| | 4341 | } |
| | 4342 | |
| | 4343 | static IrInstSrc *ir_build_check_switch_prongs(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 4344 | IrInstSrc *target_value, IrInstSrcCheckSwitchProngsRange *ranges, size_t range_count, |
| 3455 | bool have_else_prong, bool have_underscore_prong) | 4345 | bool have_else_prong, bool have_underscore_prong) |
| 3456 | { | 4346 | { |
| 3457 | IrInstructionCheckSwitchProngs *instruction = ir_build_instruction<IrInstructionCheckSwitchProngs>( | 4347 | IrInstSrcCheckSwitchProngs *instruction = ir_build_instruction<IrInstSrcCheckSwitchProngs>( |
| 3458 | irb, scope, source_node); | 4348 | irb, scope, source_node); |
| 3459 | instruction->target_value = target_value; | 4349 | instruction->target_value = target_value; |
| 3460 | instruction->ranges = ranges; | 4350 | instruction->ranges = ranges; |
| ... | @@ -3471,10 +4361,10 @@ static IrInstruction *ir_build_check_switch_prongs(IrBuilder *irb, Scope *scope, | ... | @@ -3471,10 +4361,10 @@ static IrInstruction *ir_build_check_switch_prongs(IrBuilder *irb, Scope *scope, |
| 3471 | return &instruction->base; | 4361 | return &instruction->base; |
| 3472 | } | 4362 | } |
| 3473 | | 4363 | |
| 3474 | static IrInstruction *ir_build_check_statement_is_void(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4364 | static IrInstSrc *ir_build_check_statement_is_void(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3475 | IrInstruction* statement_value) | 4365 | IrInstSrc* statement_value) |
| 3476 | { | 4366 | { |
| 3477 | IrInstructionCheckStatementIsVoid *instruction = ir_build_instruction<IrInstructionCheckStatementIsVoid>( | 4367 | IrInstSrcCheckStatementIsVoid *instruction = ir_build_instruction<IrInstSrcCheckStatementIsVoid>( |
| 3478 | irb, scope, source_node); | 4368 | irb, scope, source_node); |
| 3479 | instruction->statement_value = statement_value; | 4369 | instruction->statement_value = statement_value; |
| 3480 | | 4370 | |
| ... | @@ -3483,11 +4373,10 @@ static IrInstruction *ir_build_check_statement_is_void(IrBuilder *irb, Scope *sc | ... | @@ -3483,11 +4373,10 @@ static IrInstruction *ir_build_check_statement_is_void(IrBuilder *irb, Scope *sc |
| 3483 | return &instruction->base; | 4373 | return &instruction->base; |
| 3484 | } | 4374 | } |
| 3485 | | 4375 | |
| 3486 | static IrInstruction *ir_build_type_name(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4376 | static IrInstSrc *ir_build_type_name(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3487 | IrInstruction *type_value) | 4377 | IrInstSrc *type_value) |
| 3488 | { | 4378 | { |
| 3489 | IrInstructionTypeName *instruction = ir_build_instruction<IrInstructionTypeName>( | 4379 | IrInstSrcTypeName *instruction = ir_build_instruction<IrInstSrcTypeName>(irb, scope, source_node); |
| 3490 | irb, scope, source_node); | | |
| 3491 | instruction->type_value = type_value; | 4380 | instruction->type_value = type_value; |
| 3492 | | 4381 | |
| 3493 | ir_ref_instruction(type_value, irb->current_basic_block); | 4382 | ir_ref_instruction(type_value, irb->current_basic_block); |
| ... | @@ -3495,40 +4384,60 @@ static IrInstruction *ir_build_type_name(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -3495,40 +4384,60 @@ static IrInstruction *ir_build_type_name(IrBuilder *irb, Scope *scope, AstNode * |
| 3495 | return &instruction->base; | 4384 | return &instruction->base; |
| 3496 | } | 4385 | } |
| 3497 | | 4386 | |
| 3498 | static IrInstruction *ir_build_decl_ref(IrBuilder *irb, Scope *scope, AstNode *source_node, Tld *tld, LVal lval) { | 4387 | static IrInstSrc *ir_build_decl_ref(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, Tld *tld, LVal lval) { |
| 3499 | IrInstructionDeclRef *instruction = ir_build_instruction<IrInstructionDeclRef>(irb, scope, source_node); | 4388 | IrInstSrcDeclRef *instruction = ir_build_instruction<IrInstSrcDeclRef>(irb, scope, source_node); |
| 3500 | instruction->tld = tld; | 4389 | instruction->tld = tld; |
| 3501 | instruction->lval = lval; | 4390 | instruction->lval = lval; |
| | 4391 | |
| | 4392 | return &instruction->base; |
| | 4393 | } |
| | 4394 | |
| | 4395 | static IrInstSrc *ir_build_panic_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *msg) { |
| | 4396 | IrInstSrcPanic *instruction = ir_build_instruction<IrInstSrcPanic>(irb, scope, source_node); |
| | 4397 | instruction->base.is_noreturn = true; |
| | 4398 | instruction->msg = msg; |
| | 4399 | |
| | 4400 | ir_ref_instruction(msg, irb->current_basic_block); |
| | 4401 | |
| | 4402 | return &instruction->base; |
| | 4403 | } |
| | 4404 | |
| | 4405 | static IrInstGen *ir_build_panic_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *msg) { |
| | 4406 | IrInstGenPanic *instruction = ir_build_inst_noreturn<IrInstGenPanic>(&ira->new_irb, |
| | 4407 | source_instr->scope, source_instr->source_node); |
| | 4408 | instruction->msg = msg; |
| | 4409 | |
| | 4410 | ir_ref_inst_gen(msg, ira->new_irb.current_basic_block); |
| 3502 | | 4411 | |
| 3503 | return &instruction->base; | 4412 | return &instruction->base; |
| 3504 | } | 4413 | } |
| 3505 | | 4414 | |
| 3506 | static IrInstruction *ir_build_panic(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *msg) { | 4415 | static IrInstSrc *ir_build_tag_name_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *target) { |
| 3507 | IrInstructionPanic *instruction = ir_build_instruction<IrInstructionPanic>(irb, scope, source_node); | 4416 | IrInstSrcTagName *instruction = ir_build_instruction<IrInstSrcTagName>(irb, scope, source_node); |
| 3508 | instruction->base.value->special = ConstValSpecialStatic; | 4417 | instruction->target = target; |
| 3509 | instruction->base.value->type = irb->codegen->builtin_types.entry_unreachable; | | |
| 3510 | instruction->msg = msg; | | |
| 3511 | | 4418 | |
| 3512 | ir_ref_instruction(msg, irb->current_basic_block); | 4419 | ir_ref_instruction(target, irb->current_basic_block); |
| 3513 | | 4420 | |
| 3514 | return &instruction->base; | 4421 | return &instruction->base; |
| 3515 | } | 4422 | } |
| 3516 | | 4423 | |
| 3517 | static IrInstruction *ir_build_tag_name(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4424 | static IrInstGen *ir_build_tag_name_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *target, |
| 3518 | IrInstruction *target) | 4425 | ZigType *result_type) |
| 3519 | { | 4426 | { |
| 3520 | IrInstructionTagName *instruction = ir_build_instruction<IrInstructionTagName>(irb, scope, source_node); | 4427 | IrInstGenTagName *instruction = ir_build_inst_gen<IrInstGenTagName>(&ira->new_irb, |
| | 4428 | source_instr->scope, source_instr->source_node); |
| | 4429 | instruction->base.value->type = result_type; |
| 3521 | instruction->target = target; | 4430 | instruction->target = target; |
| 3522 | | 4431 | |
| 3523 | ir_ref_instruction(target, irb->current_basic_block); | 4432 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| 3524 | | 4433 | |
| 3525 | return &instruction->base; | 4434 | return &instruction->base; |
| 3526 | } | 4435 | } |
| 3527 | | 4436 | |
| 3528 | static IrInstruction *ir_build_tag_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4437 | static IrInstSrc *ir_build_tag_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3529 | IrInstruction *target) | 4438 | IrInstSrc *target) |
| 3530 | { | 4439 | { |
| 3531 | IrInstructionTagType *instruction = ir_build_instruction<IrInstructionTagType>(irb, scope, source_node); | 4440 | IrInstSrcTagType *instruction = ir_build_instruction<IrInstSrcTagType>(irb, scope, source_node); |
| 3532 | instruction->target = target; | 4441 | instruction->target = target; |
| 3533 | | 4442 | |
| 3534 | ir_ref_instruction(target, irb->current_basic_block); | 4443 | ir_ref_instruction(target, irb->current_basic_block); |
| ... | @@ -3536,27 +4445,40 @@ static IrInstruction *ir_build_tag_type(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -3536,27 +4445,40 @@ static IrInstruction *ir_build_tag_type(IrBuilder *irb, Scope *scope, AstNode *s |
| 3536 | return &instruction->base; | 4445 | return &instruction->base; |
| 3537 | } | 4446 | } |
| 3538 | | 4447 | |
| 3539 | static IrInstruction *ir_build_field_parent_ptr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4448 | static IrInstSrc *ir_build_field_parent_ptr_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3540 | IrInstruction *type_value, IrInstruction *field_name, IrInstruction *field_ptr, TypeStructField *field) | 4449 | IrInstSrc *type_value, IrInstSrc *field_name, IrInstSrc *field_ptr) |
| 3541 | { | 4450 | { |
| 3542 | IrInstructionFieldParentPtr *instruction = ir_build_instruction<IrInstructionFieldParentPtr>( | 4451 | IrInstSrcFieldParentPtr *inst = ir_build_instruction<IrInstSrcFieldParentPtr>( |
| 3543 | irb, scope, source_node); | 4452 | irb, scope, source_node); |
| 3544 | instruction->type_value = type_value; | 4453 | inst->type_value = type_value; |
| 3545 | instruction->field_name = field_name; | 4454 | inst->field_name = field_name; |
| 3546 | instruction->field_ptr = field_ptr; | 4455 | inst->field_ptr = field_ptr; |
| 3547 | instruction->field = field; | | |
| 3548 | | 4456 | |
| 3549 | ir_ref_instruction(type_value, irb->current_basic_block); | 4457 | ir_ref_instruction(type_value, irb->current_basic_block); |
| 3550 | ir_ref_instruction(field_name, irb->current_basic_block); | 4458 | ir_ref_instruction(field_name, irb->current_basic_block); |
| 3551 | ir_ref_instruction(field_ptr, irb->current_basic_block); | 4459 | ir_ref_instruction(field_ptr, irb->current_basic_block); |
| 3552 | | 4460 | |
| 3553 | return &instruction->base; | 4461 | return &inst->base; |
| | 4462 | } |
| | 4463 | |
| | 4464 | static IrInstGen *ir_build_field_parent_ptr_gen(IrAnalyze *ira, IrInst *source_instr, |
| | 4465 | IrInstGen *field_ptr, TypeStructField *field, ZigType *result_type) |
| | 4466 | { |
| | 4467 | IrInstGenFieldParentPtr *inst = ir_build_inst_gen<IrInstGenFieldParentPtr>(&ira->new_irb, |
| | 4468 | source_instr->scope, source_instr->source_node); |
| | 4469 | inst->base.value->type = result_type; |
| | 4470 | inst->field_ptr = field_ptr; |
| | 4471 | inst->field = field; |
| | 4472 | |
| | 4473 | ir_ref_inst_gen(field_ptr, ira->new_irb.current_basic_block); |
| | 4474 | |
| | 4475 | return &inst->base; |
| 3554 | } | 4476 | } |
| 3555 | | 4477 | |
| 3556 | static IrInstruction *ir_build_byte_offset_of(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4478 | static IrInstSrc *ir_build_byte_offset_of(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3557 | IrInstruction *type_value, IrInstruction *field_name) | 4479 | IrInstSrc *type_value, IrInstSrc *field_name) |
| 3558 | { | 4480 | { |
| 3559 | IrInstructionByteOffsetOf *instruction = ir_build_instruction<IrInstructionByteOffsetOf>(irb, scope, source_node); | 4481 | IrInstSrcByteOffsetOf *instruction = ir_build_instruction<IrInstSrcByteOffsetOf>(irb, scope, source_node); |
| 3560 | instruction->type_value = type_value; | 4482 | instruction->type_value = type_value; |
| 3561 | instruction->field_name = field_name; | 4483 | instruction->field_name = field_name; |
| 3562 | | 4484 | |
| ... | @@ -3566,10 +4488,10 @@ static IrInstruction *ir_build_byte_offset_of(IrBuilder *irb, Scope *scope, AstN | ... | @@ -3566,10 +4488,10 @@ static IrInstruction *ir_build_byte_offset_of(IrBuilder *irb, Scope *scope, AstN |
| 3566 | return &instruction->base; | 4488 | return &instruction->base; |
| 3567 | } | 4489 | } |
| 3568 | | 4490 | |
| 3569 | static IrInstruction *ir_build_bit_offset_of(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4491 | static IrInstSrc *ir_build_bit_offset_of(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3570 | IrInstruction *type_value, IrInstruction *field_name) | 4492 | IrInstSrc *type_value, IrInstSrc *field_name) |
| 3571 | { | 4493 | { |
| 3572 | IrInstructionBitOffsetOf *instruction = ir_build_instruction<IrInstructionBitOffsetOf>(irb, scope, source_node); | 4494 | IrInstSrcBitOffsetOf *instruction = ir_build_instruction<IrInstSrcBitOffsetOf>(irb, scope, source_node); |
| 3573 | instruction->type_value = type_value; | 4495 | instruction->type_value = type_value; |
| 3574 | instruction->field_name = field_name; | 4496 | instruction->field_name = field_name; |
| 3575 | | 4497 | |
| ... | @@ -3579,9 +4501,8 @@ static IrInstruction *ir_build_bit_offset_of(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -3579,9 +4501,8 @@ static IrInstruction *ir_build_bit_offset_of(IrBuilder *irb, Scope *scope, AstNo |
| 3579 | return &instruction->base; | 4501 | return &instruction->base; |
| 3580 | } | 4502 | } |
| 3581 | | 4503 | |
| 3582 | static IrInstruction *ir_build_type_info(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4504 | static IrInstSrc *ir_build_type_info(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type_value) { |
| 3583 | IrInstruction *type_value) { | 4505 | IrInstSrcTypeInfo *instruction = ir_build_instruction<IrInstSrcTypeInfo>(irb, scope, source_node); |
| 3584 | IrInstructionTypeInfo *instruction = ir_build_instruction<IrInstructionTypeInfo>(irb, scope, source_node); | | |
| 3585 | instruction->type_value = type_value; | 4506 | instruction->type_value = type_value; |
| 3586 | | 4507 | |
| 3587 | ir_ref_instruction(type_value, irb->current_basic_block); | 4508 | ir_ref_instruction(type_value, irb->current_basic_block); |
| ... | @@ -3589,8 +4510,8 @@ static IrInstruction *ir_build_type_info(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -3589,8 +4510,8 @@ static IrInstruction *ir_build_type_info(IrBuilder *irb, Scope *scope, AstNode * |
| 3589 | return &instruction->base; | 4510 | return &instruction->base; |
| 3590 | } | 4511 | } |
| 3591 | | 4512 | |
| 3592 | static IrInstruction *ir_build_type(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *type_info) { | 4513 | static IrInstSrc *ir_build_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type_info) { |
| 3593 | IrInstructionType *instruction = ir_build_instruction<IrInstructionType>(irb, scope, source_node); | 4514 | IrInstSrcType *instruction = ir_build_instruction<IrInstSrcType>(irb, scope, source_node); |
| 3594 | instruction->type_info = type_info; | 4515 | instruction->type_info = type_info; |
| 3595 | | 4516 | |
| 3596 | ir_ref_instruction(type_info, irb->current_basic_block); | 4517 | ir_ref_instruction(type_info, irb->current_basic_block); |
| ... | @@ -3598,10 +4519,8 @@ static IrInstruction *ir_build_type(IrBuilder *irb, Scope *scope, AstNode *sourc | ... | @@ -3598,10 +4519,8 @@ static IrInstruction *ir_build_type(IrBuilder *irb, Scope *scope, AstNode *sourc |
| 3598 | return &instruction->base; | 4519 | return &instruction->base; |
| 3599 | } | 4520 | } |
| 3600 | | 4521 | |
| 3601 | static IrInstruction *ir_build_type_id(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4522 | static IrInstSrc *ir_build_type_id(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type_value) { |
| 3602 | IrInstruction *type_value) | 4523 | IrInstSrcTypeId *instruction = ir_build_instruction<IrInstSrcTypeId>(irb, scope, source_node); |
| 3603 | { | | |
| 3604 | IrInstructionTypeId *instruction = ir_build_instruction<IrInstructionTypeId>(irb, scope, source_node); | | |
| 3605 | instruction->type_value = type_value; | 4524 | instruction->type_value = type_value; |
| 3606 | | 4525 | |
| 3607 | ir_ref_instruction(type_value, irb->current_basic_block); | 4526 | ir_ref_instruction(type_value, irb->current_basic_block); |
| ... | @@ -3609,10 +4528,10 @@ static IrInstruction *ir_build_type_id(IrBuilder *irb, Scope *scope, AstNode *so | ... | @@ -3609,10 +4528,10 @@ static IrInstruction *ir_build_type_id(IrBuilder *irb, Scope *scope, AstNode *so |
| 3609 | return &instruction->base; | 4528 | return &instruction->base; |
| 3610 | } | 4529 | } |
| 3611 | | 4530 | |
| 3612 | static IrInstruction *ir_build_set_eval_branch_quota(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4531 | static IrInstSrc *ir_build_set_eval_branch_quota(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3613 | IrInstruction *new_quota) | 4532 | IrInstSrc *new_quota) |
| 3614 | { | 4533 | { |
| 3615 | IrInstructionSetEvalBranchQuota *instruction = ir_build_instruction<IrInstructionSetEvalBranchQuota>(irb, scope, source_node); | 4534 | IrInstSrcSetEvalBranchQuota *instruction = ir_build_instruction<IrInstSrcSetEvalBranchQuota>(irb, scope, source_node); |
| 3616 | instruction->new_quota = new_quota; | 4535 | instruction->new_quota = new_quota; |
| 3617 | | 4536 | |
| 3618 | ir_ref_instruction(new_quota, irb->current_basic_block); | 4537 | ir_ref_instruction(new_quota, irb->current_basic_block); |
| ... | @@ -3620,23 +4539,35 @@ static IrInstruction *ir_build_set_eval_branch_quota(IrBuilder *irb, Scope *scop | ... | @@ -3620,23 +4539,35 @@ static IrInstruction *ir_build_set_eval_branch_quota(IrBuilder *irb, Scope *scop |
| 3620 | return &instruction->base; | 4539 | return &instruction->base; |
| 3621 | } | 4540 | } |
| 3622 | | 4541 | |
| 3623 | static IrInstruction *ir_build_align_cast(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4542 | static IrInstSrc *ir_build_align_cast_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3624 | IrInstruction *align_bytes, IrInstruction *target) | 4543 | IrInstSrc *align_bytes, IrInstSrc *target) |
| 3625 | { | 4544 | { |
| 3626 | IrInstructionAlignCast *instruction = ir_build_instruction<IrInstructionAlignCast>(irb, scope, source_node); | 4545 | IrInstSrcAlignCast *instruction = ir_build_instruction<IrInstSrcAlignCast>(irb, scope, source_node); |
| 3627 | instruction->align_bytes = align_bytes; | 4546 | instruction->align_bytes = align_bytes; |
| 3628 | instruction->target = target; | 4547 | instruction->target = target; |
| 3629 | | 4548 | |
| 3630 | if (align_bytes) ir_ref_instruction(align_bytes, irb->current_basic_block); | 4549 | ir_ref_instruction(align_bytes, irb->current_basic_block); |
| 3631 | ir_ref_instruction(target, irb->current_basic_block); | 4550 | ir_ref_instruction(target, irb->current_basic_block); |
| 3632 | | 4551 | |
| 3633 | return &instruction->base; | 4552 | return &instruction->base; |
| 3634 | } | 4553 | } |
| 3635 | | 4554 | |
| 3636 | static IrInstruction *ir_build_resolve_result(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4555 | static IrInstGen *ir_build_align_cast_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, IrInstGen *target, |
| 3637 | ResultLoc *result_loc, IrInstruction *ty) | 4556 | ZigType *result_type) |
| | 4557 | { |
| | 4558 | IrInstGenAlignCast *instruction = ir_build_inst_gen<IrInstGenAlignCast>(&ira->new_irb, scope, source_node); |
| | 4559 | instruction->base.value->type = result_type; |
| | 4560 | instruction->target = target; |
| | 4561 | |
| | 4562 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| | 4563 | |
| | 4564 | return &instruction->base; |
| | 4565 | } |
| | 4566 | |
| | 4567 | static IrInstSrc *ir_build_resolve_result(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 4568 | ResultLoc *result_loc, IrInstSrc *ty) |
| 3638 | { | 4569 | { |
| 3639 | IrInstructionResolveResult *instruction = ir_build_instruction<IrInstructionResolveResult>(irb, scope, source_node); | 4570 | IrInstSrcResolveResult *instruction = ir_build_instruction<IrInstSrcResolveResult>(irb, scope, source_node); |
| 3640 | instruction->result_loc = result_loc; | 4571 | instruction->result_loc = result_loc; |
| 3641 | instruction->ty = ty; | 4572 | instruction->ty = ty; |
| 3642 | | 4573 | |
| ... | @@ -3645,25 +4576,25 @@ static IrInstruction *ir_build_resolve_result(IrBuilder *irb, Scope *scope, AstN | ... | @@ -3645,25 +4576,25 @@ static IrInstruction *ir_build_resolve_result(IrBuilder *irb, Scope *scope, AstN |
| 3645 | return &instruction->base; | 4576 | return &instruction->base; |
| 3646 | } | 4577 | } |
| 3647 | | 4578 | |
| 3648 | static IrInstruction *ir_build_reset_result(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4579 | static IrInstSrc *ir_build_reset_result(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3649 | ResultLoc *result_loc) | 4580 | ResultLoc *result_loc) |
| 3650 | { | 4581 | { |
| 3651 | IrInstructionResetResult *instruction = ir_build_instruction<IrInstructionResetResult>(irb, scope, source_node); | 4582 | IrInstSrcResetResult *instruction = ir_build_instruction<IrInstSrcResetResult>(irb, scope, source_node); |
| 3652 | instruction->result_loc = result_loc; | 4583 | instruction->result_loc = result_loc; |
| 3653 | | 4584 | |
| 3654 | return &instruction->base; | 4585 | return &instruction->base; |
| 3655 | } | 4586 | } |
| 3656 | | 4587 | |
| 3657 | static IrInstruction *ir_build_opaque_type(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 4588 | static IrInstSrc *ir_build_opaque_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 3658 | IrInstructionOpaqueType *instruction = ir_build_instruction<IrInstructionOpaqueType>(irb, scope, source_node); | 4589 | IrInstSrcOpaqueType *instruction = ir_build_instruction<IrInstSrcOpaqueType>(irb, scope, source_node); |
| 3659 | | 4590 | |
| 3660 | return &instruction->base; | 4591 | return &instruction->base; |
| 3661 | } | 4592 | } |
| 3662 | | 4593 | |
| 3663 | static IrInstruction *ir_build_set_align_stack(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4594 | static IrInstSrc *ir_build_set_align_stack(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3664 | IrInstruction *align_bytes) | 4595 | IrInstSrc *align_bytes) |
| 3665 | { | 4596 | { |
| 3666 | IrInstructionSetAlignStack *instruction = ir_build_instruction<IrInstructionSetAlignStack>(irb, scope, source_node); | 4597 | IrInstSrcSetAlignStack *instruction = ir_build_instruction<IrInstSrcSetAlignStack>(irb, scope, source_node); |
| 3667 | instruction->align_bytes = align_bytes; | 4598 | instruction->align_bytes = align_bytes; |
| 3668 | | 4599 | |
| 3669 | ir_ref_instruction(align_bytes, irb->current_basic_block); | 4600 | ir_ref_instruction(align_bytes, irb->current_basic_block); |
| ... | @@ -3671,10 +4602,10 @@ static IrInstruction *ir_build_set_align_stack(IrBuilder *irb, Scope *scope, Ast | ... | @@ -3671,10 +4602,10 @@ static IrInstruction *ir_build_set_align_stack(IrBuilder *irb, Scope *scope, Ast |
| 3671 | return &instruction->base; | 4602 | return &instruction->base; |
| 3672 | } | 4603 | } |
| 3673 | | 4604 | |
| 3674 | static IrInstruction *ir_build_arg_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4605 | static IrInstSrc *ir_build_arg_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3675 | IrInstruction *fn_type, IrInstruction *arg_index, bool allow_var) | 4606 | IrInstSrc *fn_type, IrInstSrc *arg_index, bool allow_var) |
| 3676 | { | 4607 | { |
| 3677 | IrInstructionArgType *instruction = ir_build_instruction<IrInstructionArgType>(irb, scope, source_node); | 4608 | IrInstSrcArgType *instruction = ir_build_instruction<IrInstSrcArgType>(irb, scope, source_node); |
| 3678 | instruction->fn_type = fn_type; | 4609 | instruction->fn_type = fn_type; |
| 3679 | instruction->arg_index = arg_index; | 4610 | instruction->arg_index = arg_index; |
| 3680 | instruction->allow_var = allow_var; | 4611 | instruction->allow_var = allow_var; |
| ... | @@ -3685,17 +4616,29 @@ static IrInstruction *ir_build_arg_type(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -3685,17 +4616,29 @@ static IrInstruction *ir_build_arg_type(IrBuilder *irb, Scope *scope, AstNode *s |
| 3685 | return &instruction->base; | 4616 | return &instruction->base; |
| 3686 | } | 4617 | } |
| 3687 | | 4618 | |
| 3688 | static IrInstruction *ir_build_error_return_trace(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstructionErrorReturnTrace::Optional optional) { | 4619 | static IrInstSrc *ir_build_error_return_trace_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3689 | IrInstructionErrorReturnTrace *instruction = ir_build_instruction<IrInstructionErrorReturnTrace>(irb, scope, source_node); | 4620 | IrInstErrorReturnTraceOptional optional) |
| 3690 | instruction->optional = optional; | 4621 | { |
| | 4622 | IrInstSrcErrorReturnTrace *inst = ir_build_instruction<IrInstSrcErrorReturnTrace>(irb, scope, source_node); |
| | 4623 | inst->optional = optional; |
| 3691 | | 4624 | |
| 3692 | return &instruction->base; | 4625 | return &inst->base; |
| | 4626 | } |
| | 4627 | |
| | 4628 | static IrInstGen *ir_build_error_return_trace_gen(IrAnalyze *ira, Scope *scope, AstNode *source_node, |
| | 4629 | IrInstErrorReturnTraceOptional optional, ZigType *result_type) |
| | 4630 | { |
| | 4631 | IrInstGenErrorReturnTrace *inst = ir_build_inst_gen<IrInstGenErrorReturnTrace>(&ira->new_irb, scope, source_node); |
| | 4632 | inst->base.value->type = result_type; |
| | 4633 | inst->optional = optional; |
| | 4634 | |
| | 4635 | return &inst->base; |
| 3693 | } | 4636 | } |
| 3694 | | 4637 | |
| 3695 | static IrInstruction *ir_build_error_union(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4638 | static IrInstSrc *ir_build_error_union(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3696 | IrInstruction *err_set, IrInstruction *payload) | 4639 | IrInstSrc *err_set, IrInstSrc *payload) |
| 3697 | { | 4640 | { |
| 3698 | IrInstructionErrorUnion *instruction = ir_build_instruction<IrInstructionErrorUnion>(irb, scope, source_node); | 4641 | IrInstSrcErrorUnion *instruction = ir_build_instruction<IrInstSrcErrorUnion>(irb, scope, source_node); |
| 3699 | instruction->err_set = err_set; | 4642 | instruction->err_set = err_set; |
| 3700 | instruction->payload = payload; | 4643 | instruction->payload = payload; |
| 3701 | | 4644 | |
| ... | @@ -3705,85 +4648,130 @@ static IrInstruction *ir_build_error_union(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3705,85 +4648,130 @@ static IrInstruction *ir_build_error_union(IrBuilder *irb, Scope *scope, AstNode |
| 3705 | return &instruction->base; | 4648 | return &instruction->base; |
| 3706 | } | 4649 | } |
| 3707 | | 4650 | |
| 3708 | static IrInstruction *ir_build_atomic_rmw(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4651 | static IrInstSrc *ir_build_atomic_rmw_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3709 | IrInstruction *operand_type, IrInstruction *ptr, IrInstruction *op, IrInstruction *operand, | 4652 | IrInstSrc *operand_type, IrInstSrc *ptr, IrInstSrc *op, IrInstSrc *operand, |
| 3710 | IrInstruction *ordering, AtomicRmwOp resolved_op, AtomicOrder resolved_ordering) | 4653 | IrInstSrc *ordering) |
| 3711 | { | 4654 | { |
| 3712 | IrInstructionAtomicRmw *instruction = ir_build_instruction<IrInstructionAtomicRmw>(irb, scope, source_node); | 4655 | IrInstSrcAtomicRmw *instruction = ir_build_instruction<IrInstSrcAtomicRmw>(irb, scope, source_node); |
| 3713 | instruction->operand_type = operand_type; | 4656 | instruction->operand_type = operand_type; |
| 3714 | instruction->ptr = ptr; | 4657 | instruction->ptr = ptr; |
| 3715 | instruction->op = op; | 4658 | instruction->op = op; |
| 3716 | instruction->operand = operand; | 4659 | instruction->operand = operand; |
| 3717 | instruction->ordering = ordering; | 4660 | instruction->ordering = ordering; |
| 3718 | instruction->resolved_op = resolved_op; | | |
| 3719 | instruction->resolved_ordering = resolved_ordering; | | |
| 3720 | | 4661 | |
| 3721 | if (operand_type != nullptr) ir_ref_instruction(operand_type, irb->current_basic_block); | 4662 | ir_ref_instruction(operand_type, irb->current_basic_block); |
| 3722 | ir_ref_instruction(ptr, irb->current_basic_block); | 4663 | ir_ref_instruction(ptr, irb->current_basic_block); |
| 3723 | if (op != nullptr) ir_ref_instruction(op, irb->current_basic_block); | 4664 | ir_ref_instruction(op, irb->current_basic_block); |
| 3724 | ir_ref_instruction(operand, irb->current_basic_block); | 4665 | ir_ref_instruction(operand, irb->current_basic_block); |
| 3725 | if (ordering != nullptr) ir_ref_instruction(ordering, irb->current_basic_block); | 4666 | ir_ref_instruction(ordering, irb->current_basic_block); |
| | 4667 | |
| | 4668 | return &instruction->base; |
| | 4669 | } |
| | 4670 | |
| | 4671 | static IrInstGen *ir_build_atomic_rmw_gen(IrAnalyze *ira, IrInst *source_instr, |
| | 4672 | IrInstGen *ptr, IrInstGen *operand, AtomicRmwOp op, AtomicOrder ordering, ZigType *operand_type) |
| | 4673 | { |
| | 4674 | IrInstGenAtomicRmw *instruction = ir_build_inst_gen<IrInstGenAtomicRmw>(&ira->new_irb, source_instr->scope, source_instr->source_node); |
| | 4675 | instruction->base.value->type = operand_type; |
| | 4676 | instruction->ptr = ptr; |
| | 4677 | instruction->op = op; |
| | 4678 | instruction->operand = operand; |
| | 4679 | instruction->ordering = ordering; |
| | 4680 | |
| | 4681 | ir_ref_inst_gen(ptr, ira->new_irb.current_basic_block); |
| | 4682 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 3726 | | 4683 | |
| 3727 | return &instruction->base; | 4684 | return &instruction->base; |
| 3728 | } | 4685 | } |
| 3729 | | 4686 | |
| 3730 | static IrInstruction *ir_build_atomic_load(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4687 | static IrInstSrc *ir_build_atomic_load_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3731 | IrInstruction *operand_type, IrInstruction *ptr, | 4688 | IrInstSrc *operand_type, IrInstSrc *ptr, IrInstSrc *ordering) |
| 3732 | IrInstruction *ordering, AtomicOrder resolved_ordering) | | |
| 3733 | { | 4689 | { |
| 3734 | IrInstructionAtomicLoad *instruction = ir_build_instruction<IrInstructionAtomicLoad>(irb, scope, source_node); | 4690 | IrInstSrcAtomicLoad *instruction = ir_build_instruction<IrInstSrcAtomicLoad>(irb, scope, source_node); |
| 3735 | instruction->operand_type = operand_type; | 4691 | instruction->operand_type = operand_type; |
| 3736 | instruction->ptr = ptr; | 4692 | instruction->ptr = ptr; |
| 3737 | instruction->ordering = ordering; | 4693 | instruction->ordering = ordering; |
| 3738 | instruction->resolved_ordering = resolved_ordering; | | |
| 3739 | | 4694 | |
| 3740 | if (operand_type != nullptr) ir_ref_instruction(operand_type, irb->current_basic_block); | 4695 | ir_ref_instruction(operand_type, irb->current_basic_block); |
| 3741 | ir_ref_instruction(ptr, irb->current_basic_block); | 4696 | ir_ref_instruction(ptr, irb->current_basic_block); |
| 3742 | if (ordering != nullptr) ir_ref_instruction(ordering, irb->current_basic_block); | 4697 | ir_ref_instruction(ordering, irb->current_basic_block); |
| | 4698 | |
| | 4699 | return &instruction->base; |
| | 4700 | } |
| | 4701 | |
| | 4702 | static IrInstGen *ir_build_atomic_load_gen(IrAnalyze *ira, IrInst *source_instr, |
| | 4703 | IrInstGen *ptr, AtomicOrder ordering, ZigType *operand_type) |
| | 4704 | { |
| | 4705 | IrInstGenAtomicLoad *instruction = ir_build_inst_gen<IrInstGenAtomicLoad>(&ira->new_irb, |
| | 4706 | source_instr->scope, source_instr->source_node); |
| | 4707 | instruction->base.value->type = operand_type; |
| | 4708 | instruction->ptr = ptr; |
| | 4709 | instruction->ordering = ordering; |
| | 4710 | |
| | 4711 | ir_ref_inst_gen(ptr, ira->new_irb.current_basic_block); |
| 3743 | | 4712 | |
| 3744 | return &instruction->base; | 4713 | return &instruction->base; |
| 3745 | } | 4714 | } |
| 3746 | | 4715 | |
| 3747 | static IrInstruction *ir_build_atomic_store(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4716 | static IrInstSrc *ir_build_atomic_store_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3748 | IrInstruction *operand_type, IrInstruction *ptr, IrInstruction *value, | 4717 | IrInstSrc *operand_type, IrInstSrc *ptr, IrInstSrc *value, IrInstSrc *ordering) |
| 3749 | IrInstruction *ordering, AtomicOrder resolved_ordering) | | |
| 3750 | { | 4718 | { |
| 3751 | IrInstructionAtomicStore *instruction = ir_build_instruction<IrInstructionAtomicStore>(irb, scope, source_node); | 4719 | IrInstSrcAtomicStore *instruction = ir_build_instruction<IrInstSrcAtomicStore>(irb, scope, source_node); |
| 3752 | instruction->operand_type = operand_type; | 4720 | instruction->operand_type = operand_type; |
| 3753 | instruction->ptr = ptr; | 4721 | instruction->ptr = ptr; |
| 3754 | instruction->value = value; | 4722 | instruction->value = value; |
| 3755 | instruction->ordering = ordering; | 4723 | instruction->ordering = ordering; |
| 3756 | instruction->resolved_ordering = resolved_ordering; | | |
| 3757 | | 4724 | |
| 3758 | if (operand_type != nullptr) ir_ref_instruction(operand_type, irb->current_basic_block); | 4725 | ir_ref_instruction(operand_type, irb->current_basic_block); |
| 3759 | ir_ref_instruction(ptr, irb->current_basic_block); | 4726 | ir_ref_instruction(ptr, irb->current_basic_block); |
| 3760 | ir_ref_instruction(value, irb->current_basic_block); | 4727 | ir_ref_instruction(value, irb->current_basic_block); |
| 3761 | if (ordering != nullptr) ir_ref_instruction(ordering, irb->current_basic_block); | 4728 | ir_ref_instruction(ordering, irb->current_basic_block); |
| 3762 | | 4729 | |
| 3763 | return &instruction->base; | 4730 | return &instruction->base; |
| 3764 | } | 4731 | } |
| 3765 | | 4732 | |
| 3766 | static IrInstruction *ir_build_save_err_ret_addr(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 4733 | static IrInstGen *ir_build_atomic_store_gen(IrAnalyze *ira, IrInst *source_instr, |
| 3767 | IrInstructionSaveErrRetAddr *instruction = ir_build_instruction<IrInstructionSaveErrRetAddr>(irb, scope, source_node); | 4734 | IrInstGen *ptr, IrInstGen *value, AtomicOrder ordering) |
| | 4735 | { |
| | 4736 | IrInstGenAtomicStore *instruction = ir_build_inst_void<IrInstGenAtomicStore>(&ira->new_irb, |
| | 4737 | source_instr->scope, source_instr->source_node); |
| | 4738 | instruction->ptr = ptr; |
| | 4739 | instruction->value = value; |
| | 4740 | instruction->ordering = ordering; |
| | 4741 | |
| | 4742 | ir_ref_inst_gen(ptr, ira->new_irb.current_basic_block); |
| | 4743 | ir_ref_inst_gen(value, ira->new_irb.current_basic_block); |
| | 4744 | |
| 3768 | return &instruction->base; | 4745 | return &instruction->base; |
| 3769 | } | 4746 | } |
| 3770 | | 4747 | |
| 3771 | static IrInstruction *ir_build_add_implicit_return_type(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4748 | static IrInstSrc *ir_build_save_err_ret_addr_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 3772 | IrInstruction *value, ResultLocReturn *result_loc_ret) | 4749 | IrInstSrcSaveErrRetAddr *inst = ir_build_instruction<IrInstSrcSaveErrRetAddr>(irb, scope, source_node); |
| | 4750 | return &inst->base; |
| | 4751 | } |
| | 4752 | |
| | 4753 | static IrInstGen *ir_build_save_err_ret_addr_gen(IrAnalyze *ira, IrInst *source_instr) { |
| | 4754 | IrInstGenSaveErrRetAddr *inst = ir_build_inst_void<IrInstGenSaveErrRetAddr>(&ira->new_irb, |
| | 4755 | source_instr->scope, source_instr->source_node); |
| | 4756 | return &inst->base; |
| | 4757 | } |
| | 4758 | |
| | 4759 | static IrInstSrc *ir_build_add_implicit_return_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 4760 | IrInstSrc *value, ResultLocReturn *result_loc_ret) |
| 3773 | { | 4761 | { |
| 3774 | IrInstructionAddImplicitReturnType *instruction = ir_build_instruction<IrInstructionAddImplicitReturnType>(irb, scope, source_node); | 4762 | IrInstSrcAddImplicitReturnType *inst = ir_build_instruction<IrInstSrcAddImplicitReturnType>(irb, scope, source_node); |
| 3775 | instruction->value = value; | 4763 | inst->value = value; |
| 3776 | instruction->result_loc_ret = result_loc_ret; | 4764 | inst->result_loc_ret = result_loc_ret; |
| 3777 | | 4765 | |
| 3778 | ir_ref_instruction(value, irb->current_basic_block); | 4766 | ir_ref_instruction(value, irb->current_basic_block); |
| 3779 | | 4767 | |
| 3780 | return &instruction->base; | 4768 | return &inst->base; |
| 3781 | } | 4769 | } |
| 3782 | | 4770 | |
| 3783 | static IrInstruction *ir_build_has_decl(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4771 | static IrInstSrc *ir_build_has_decl(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3784 | IrInstruction *container, IrInstruction *name) | 4772 | IrInstSrc *container, IrInstSrc *name) |
| 3785 | { | 4773 | { |
| 3786 | IrInstructionHasDecl *instruction = ir_build_instruction<IrInstructionHasDecl>(irb, scope, source_node); | 4774 | IrInstSrcHasDecl *instruction = ir_build_instruction<IrInstSrcHasDecl>(irb, scope, source_node); |
| 3787 | instruction->container = container; | 4775 | instruction->container = container; |
| 3788 | instruction->name = name; | 4776 | instruction->name = name; |
| 3789 | | 4777 | |
| ... | @@ -3793,17 +4781,15 @@ static IrInstruction *ir_build_has_decl(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -3793,17 +4781,15 @@ static IrInstruction *ir_build_has_decl(IrBuilder *irb, Scope *scope, AstNode *s |
| 3793 | return &instruction->base; | 4781 | return &instruction->base; |
| 3794 | } | 4782 | } |
| 3795 | | 4783 | |
| 3796 | static IrInstruction *ir_build_undeclared_identifier(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4784 | static IrInstSrc *ir_build_undeclared_identifier(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, Buf *name) { |
| 3797 | Buf *name) | 4785 | IrInstSrcUndeclaredIdent *instruction = ir_build_instruction<IrInstSrcUndeclaredIdent>(irb, scope, source_node); |
| 3798 | { | | |
| 3799 | IrInstructionUndeclaredIdent *instruction = ir_build_instruction<IrInstructionUndeclaredIdent>(irb, scope, source_node); | | |
| 3800 | instruction->name = name; | 4786 | instruction->name = name; |
| 3801 | | 4787 | |
| 3802 | return &instruction->base; | 4788 | return &instruction->base; |
| 3803 | } | 4789 | } |
| 3804 | | 4790 | |
| 3805 | static IrInstruction *ir_build_check_runtime_scope(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *scope_is_comptime, IrInstruction *is_comptime) { | 4791 | static IrInstSrc *ir_build_check_runtime_scope(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *scope_is_comptime, IrInstSrc *is_comptime) { |
| 3806 | IrInstructionCheckRuntimeScope *instruction = ir_build_instruction<IrInstructionCheckRuntimeScope>(irb, scope, source_node); | 4792 | IrInstSrcCheckRuntimeScope *instruction = ir_build_instruction<IrInstSrcCheckRuntimeScope>(irb, scope, source_node); |
| 3807 | instruction->scope_is_comptime = scope_is_comptime; | 4793 | instruction->scope_is_comptime = scope_is_comptime; |
| 3808 | instruction->is_comptime = is_comptime; | 4794 | instruction->is_comptime = is_comptime; |
| 3809 | | 4795 | |
| ... | @@ -3813,10 +4799,10 @@ static IrInstruction *ir_build_check_runtime_scope(IrBuilder *irb, Scope *scope, | ... | @@ -3813,10 +4799,10 @@ static IrInstruction *ir_build_check_runtime_scope(IrBuilder *irb, Scope *scope, |
| 3813 | return &instruction->base; | 4799 | return &instruction->base; |
| 3814 | } | 4800 | } |
| 3815 | | 4801 | |
| 3816 | static IrInstruction *ir_build_union_init_named_field(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4802 | static IrInstSrc *ir_build_union_init_named_field(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3817 | IrInstruction *union_type, IrInstruction *field_name, IrInstruction *field_result_loc, IrInstruction *result_loc) | 4803 | IrInstSrc *union_type, IrInstSrc *field_name, IrInstSrc *field_result_loc, IrInstSrc *result_loc) |
| 3818 | { | 4804 | { |
| 3819 | IrInstructionUnionInitNamedField *instruction = ir_build_instruction<IrInstructionUnionInitNamedField>(irb, scope, source_node); | 4805 | IrInstSrcUnionInitNamedField *instruction = ir_build_instruction<IrInstSrcUnionInitNamedField>(irb, scope, source_node); |
| 3820 | instruction->union_type = union_type; | 4806 | instruction->union_type = union_type; |
| 3821 | instruction->field_name = field_name; | 4807 | instruction->field_name = field_name; |
| 3822 | instruction->field_result_loc = field_result_loc; | 4808 | instruction->field_result_loc = field_result_loc; |
| ... | @@ -3831,79 +4817,79 @@ static IrInstruction *ir_build_union_init_named_field(IrBuilder *irb, Scope *sco | ... | @@ -3831,79 +4817,79 @@ static IrInstruction *ir_build_union_init_named_field(IrBuilder *irb, Scope *sco |
| 3831 | } | 4817 | } |
| 3832 | | 4818 | |
| 3833 | | 4819 | |
| 3834 | static IrInstruction *ir_build_vector_to_array(IrAnalyze *ira, IrInstruction *source_instruction, | 4820 | static IrInstGen *ir_build_vector_to_array(IrAnalyze *ira, IrInst *source_instruction, |
| 3835 | ZigType *result_type, IrInstruction *vector, IrInstruction *result_loc) | 4821 | ZigType *result_type, IrInstGen *vector, IrInstGen *result_loc) |
| 3836 | { | 4822 | { |
| 3837 | IrInstructionVectorToArray *instruction = ir_build_instruction<IrInstructionVectorToArray>(&ira->new_irb, | 4823 | IrInstGenVectorToArray *instruction = ir_build_inst_gen<IrInstGenVectorToArray>(&ira->new_irb, |
| 3838 | source_instruction->scope, source_instruction->source_node); | 4824 | source_instruction->scope, source_instruction->source_node); |
| 3839 | instruction->base.value->type = result_type; | 4825 | instruction->base.value->type = result_type; |
| 3840 | instruction->vector = vector; | 4826 | instruction->vector = vector; |
| 3841 | instruction->result_loc = result_loc; | 4827 | instruction->result_loc = result_loc; |
| 3842 | | 4828 | |
| 3843 | ir_ref_instruction(vector, ira->new_irb.current_basic_block); | 4829 | ir_ref_inst_gen(vector, ira->new_irb.current_basic_block); |
| 3844 | ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 4830 | ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 3845 | | 4831 | |
| 3846 | return &instruction->base; | 4832 | return &instruction->base; |
| 3847 | } | 4833 | } |
| 3848 | | 4834 | |
| 3849 | static IrInstruction *ir_build_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruction *source_instruction, | 4835 | static IrInstGen *ir_build_ptr_of_array_to_slice(IrAnalyze *ira, IrInst *source_instruction, |
| 3850 | ZigType *result_type, IrInstruction *operand, IrInstruction *result_loc) | 4836 | ZigType *result_type, IrInstGen *operand, IrInstGen *result_loc) |
| 3851 | { | 4837 | { |
| 3852 | IrInstructionPtrOfArrayToSlice *instruction = ir_build_instruction<IrInstructionPtrOfArrayToSlice>(&ira->new_irb, | 4838 | IrInstGenPtrOfArrayToSlice *instruction = ir_build_inst_gen<IrInstGenPtrOfArrayToSlice>(&ira->new_irb, |
| 3853 | source_instruction->scope, source_instruction->source_node); | 4839 | source_instruction->scope, source_instruction->source_node); |
| 3854 | instruction->base.value->type = result_type; | 4840 | instruction->base.value->type = result_type; |
| 3855 | instruction->operand = operand; | 4841 | instruction->operand = operand; |
| 3856 | instruction->result_loc = result_loc; | 4842 | instruction->result_loc = result_loc; |
| 3857 | | 4843 | |
| 3858 | ir_ref_instruction(operand, ira->new_irb.current_basic_block); | 4844 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| 3859 | ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 4845 | ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 3860 | | 4846 | |
| 3861 | return &instruction->base; | 4847 | return &instruction->base; |
| 3862 | } | 4848 | } |
| 3863 | | 4849 | |
| 3864 | static IrInstruction *ir_build_array_to_vector(IrAnalyze *ira, IrInstruction *source_instruction, | 4850 | static IrInstGen *ir_build_array_to_vector(IrAnalyze *ira, IrInst *source_instruction, |
| 3865 | IrInstruction *array, ZigType *result_type) | 4851 | IrInstGen *array, ZigType *result_type) |
| 3866 | { | 4852 | { |
| 3867 | IrInstructionArrayToVector *instruction = ir_build_instruction<IrInstructionArrayToVector>(&ira->new_irb, | 4853 | IrInstGenArrayToVector *instruction = ir_build_inst_gen<IrInstGenArrayToVector>(&ira->new_irb, |
| 3868 | source_instruction->scope, source_instruction->source_node); | 4854 | source_instruction->scope, source_instruction->source_node); |
| 3869 | instruction->base.value->type = result_type; | 4855 | instruction->base.value->type = result_type; |
| 3870 | instruction->array = array; | 4856 | instruction->array = array; |
| 3871 | | 4857 | |
| 3872 | ir_ref_instruction(array, ira->new_irb.current_basic_block); | 4858 | ir_ref_inst_gen(array, ira->new_irb.current_basic_block); |
| 3873 | | 4859 | |
| 3874 | return &instruction->base; | 4860 | return &instruction->base; |
| 3875 | } | 4861 | } |
| 3876 | | 4862 | |
| 3877 | static IrInstruction *ir_build_assert_zero(IrAnalyze *ira, IrInstruction *source_instruction, | 4863 | static IrInstGen *ir_build_assert_zero(IrAnalyze *ira, IrInst *source_instruction, |
| 3878 | IrInstruction *target) | 4864 | IrInstGen *target) |
| 3879 | { | 4865 | { |
| 3880 | IrInstructionAssertZero *instruction = ir_build_instruction<IrInstructionAssertZero>(&ira->new_irb, | 4866 | IrInstGenAssertZero *instruction = ir_build_inst_gen<IrInstGenAssertZero>(&ira->new_irb, |
| 3881 | source_instruction->scope, source_instruction->source_node); | 4867 | source_instruction->scope, source_instruction->source_node); |
| 3882 | instruction->base.value->type = ira->codegen->builtin_types.entry_void; | 4868 | instruction->base.value->type = ira->codegen->builtin_types.entry_void; |
| 3883 | instruction->target = target; | 4869 | instruction->target = target; |
| 3884 | | 4870 | |
| 3885 | ir_ref_instruction(target, ira->new_irb.current_basic_block); | 4871 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| 3886 | | 4872 | |
| 3887 | return &instruction->base; | 4873 | return &instruction->base; |
| 3888 | } | 4874 | } |
| 3889 | | 4875 | |
| 3890 | static IrInstruction *ir_build_assert_non_null(IrAnalyze *ira, IrInstruction *source_instruction, | 4876 | static IrInstGen *ir_build_assert_non_null(IrAnalyze *ira, IrInst *source_instruction, |
| 3891 | IrInstruction *target) | 4877 | IrInstGen *target) |
| 3892 | { | 4878 | { |
| 3893 | IrInstructionAssertNonNull *instruction = ir_build_instruction<IrInstructionAssertNonNull>(&ira->new_irb, | 4879 | IrInstGenAssertNonNull *instruction = ir_build_inst_gen<IrInstGenAssertNonNull>(&ira->new_irb, |
| 3894 | source_instruction->scope, source_instruction->source_node); | 4880 | source_instruction->scope, source_instruction->source_node); |
| 3895 | instruction->base.value->type = ira->codegen->builtin_types.entry_void; | 4881 | instruction->base.value->type = ira->codegen->builtin_types.entry_void; |
| 3896 | instruction->target = target; | 4882 | instruction->target = target; |
| 3897 | | 4883 | |
| 3898 | ir_ref_instruction(target, ira->new_irb.current_basic_block); | 4884 | ir_ref_inst_gen(target, ira->new_irb.current_basic_block); |
| 3899 | | 4885 | |
| 3900 | return &instruction->base; | 4886 | return &instruction->base; |
| 3901 | } | 4887 | } |
| 3902 | | 4888 | |
| 3903 | static IrInstruction *ir_build_alloca_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4889 | static IrInstSrc *ir_build_alloca_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3904 | IrInstruction *align, const char *name_hint, IrInstruction *is_comptime) | 4890 | IrInstSrc *align, const char *name_hint, IrInstSrc *is_comptime) |
| 3905 | { | 4891 | { |
| 3906 | IrInstructionAllocaSrc *instruction = ir_build_instruction<IrInstructionAllocaSrc>(irb, scope, source_node); | 4892 | IrInstSrcAlloca *instruction = ir_build_instruction<IrInstSrcAlloca>(irb, scope, source_node); |
| 3907 | instruction->base.is_gen = true; | 4893 | instruction->base.is_gen = true; |
| 3908 | instruction->align = align; | 4894 | instruction->align = align; |
| 3909 | instruction->name_hint = name_hint; | 4895 | instruction->name_hint = name_hint; |
| ... | @@ -3915,10 +4901,10 @@ static IrInstruction *ir_build_alloca_src(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -3915,10 +4901,10 @@ static IrInstruction *ir_build_alloca_src(IrBuilder *irb, Scope *scope, AstNode |
| 3915 | return &instruction->base; | 4901 | return &instruction->base; |
| 3916 | } | 4902 | } |
| 3917 | | 4903 | |
| 3918 | static IrInstructionAllocaGen *ir_build_alloca_gen(IrAnalyze *ira, IrInstruction *source_instruction, | 4904 | static IrInstGenAlloca *ir_build_alloca_gen(IrAnalyze *ira, IrInst *source_instruction, |
| 3919 | uint32_t align, const char *name_hint) | 4905 | uint32_t align, const char *name_hint) |
| 3920 | { | 4906 | { |
| 3921 | IrInstructionAllocaGen *instruction = ir_create_instruction<IrInstructionAllocaGen>(&ira->new_irb, | 4907 | IrInstGenAlloca *instruction = ir_create_inst_gen<IrInstGenAlloca>(&ira->new_irb, |
| 3922 | source_instruction->scope, source_instruction->source_node); | 4908 | source_instruction->scope, source_instruction->source_node); |
| 3923 | instruction->align = align; | 4909 | instruction->align = align; |
| 3924 | instruction->name_hint = name_hint; | 4910 | instruction->name_hint = name_hint; |
| ... | @@ -3926,10 +4912,10 @@ static IrInstructionAllocaGen *ir_build_alloca_gen(IrAnalyze *ira, IrInstruction | ... | @@ -3926,10 +4912,10 @@ static IrInstructionAllocaGen *ir_build_alloca_gen(IrAnalyze *ira, IrInstruction |
| 3926 | return instruction; | 4912 | return instruction; |
| 3927 | } | 4913 | } |
| 3928 | | 4914 | |
| 3929 | static IrInstruction *ir_build_end_expr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4915 | static IrInstSrc *ir_build_end_expr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3930 | IrInstruction *value, ResultLoc *result_loc) | 4916 | IrInstSrc *value, ResultLoc *result_loc) |
| 3931 | { | 4917 | { |
| 3932 | IrInstructionEndExpr *instruction = ir_build_instruction<IrInstructionEndExpr>(irb, scope, source_node); | 4918 | IrInstSrcEndExpr *instruction = ir_build_instruction<IrInstSrcEndExpr>(irb, scope, source_node); |
| 3933 | instruction->base.is_gen = true; | 4919 | instruction->base.is_gen = true; |
| 3934 | instruction->value = value; | 4920 | instruction->value = value; |
| 3935 | instruction->result_loc = result_loc; | 4921 | instruction->result_loc = result_loc; |
| ... | @@ -3939,29 +4925,41 @@ static IrInstruction *ir_build_end_expr(IrBuilder *irb, Scope *scope, AstNode *s | ... | @@ -3939,29 +4925,41 @@ static IrInstruction *ir_build_end_expr(IrBuilder *irb, Scope *scope, AstNode *s |
| 3939 | return &instruction->base; | 4925 | return &instruction->base; |
| 3940 | } | 4926 | } |
| 3941 | | 4927 | |
| 3942 | static IrInstructionSuspendBegin *ir_build_suspend_begin(IrBuilder *irb, Scope *scope, AstNode *source_node) { | 4928 | static IrInstSrcSuspendBegin *ir_build_suspend_begin_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) { |
| 3943 | IrInstructionSuspendBegin *instruction = ir_build_instruction<IrInstructionSuspendBegin>(irb, scope, source_node); | 4929 | return ir_build_instruction<IrInstSrcSuspendBegin>(irb, scope, source_node); |
| 3944 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; | 4930 | } |
| 3945 | | 4931 | |
| 3946 | return instruction; | 4932 | static IrInstGen *ir_build_suspend_begin_gen(IrAnalyze *ira, IrInst *source_instr) { |
| | 4933 | IrInstGenSuspendBegin *inst = ir_build_inst_void<IrInstGenSuspendBegin>(&ira->new_irb, |
| | 4934 | source_instr->scope, source_instr->source_node); |
| | 4935 | return &inst->base; |
| 3947 | } | 4936 | } |
| 3948 | | 4937 | |
| 3949 | static IrInstruction *ir_build_suspend_finish(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4938 | static IrInstSrc *ir_build_suspend_finish_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3950 | IrInstructionSuspendBegin *begin) | 4939 | IrInstSrcSuspendBegin *begin) |
| 3951 | { | 4940 | { |
| 3952 | IrInstructionSuspendFinish *instruction = ir_build_instruction<IrInstructionSuspendFinish>(irb, scope, source_node); | 4941 | IrInstSrcSuspendFinish *inst = ir_build_instruction<IrInstSrcSuspendFinish>(irb, scope, source_node); |
| 3953 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; | 4942 | inst->begin = begin; |
| 3954 | instruction->begin = begin; | | |
| 3955 | | 4943 | |
| 3956 | ir_ref_instruction(&begin->base, irb->current_basic_block); | 4944 | ir_ref_instruction(&begin->base, irb->current_basic_block); |
| 3957 | | 4945 | |
| 3958 | return &instruction->base; | 4946 | return &inst->base; |
| | 4947 | } |
| | 4948 | |
| | 4949 | static IrInstGen *ir_build_suspend_finish_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGenSuspendBegin *begin) { |
| | 4950 | IrInstGenSuspendFinish *inst = ir_build_inst_void<IrInstGenSuspendFinish>(&ira->new_irb, |
| | 4951 | source_instr->scope, source_instr->source_node); |
| | 4952 | inst->begin = begin; |
| | 4953 | |
| | 4954 | ir_ref_inst_gen(&begin->base, ira->new_irb.current_basic_block); |
| | 4955 | |
| | 4956 | return &inst->base; |
| 3959 | } | 4957 | } |
| 3960 | | 4958 | |
| 3961 | static IrInstruction *ir_build_await_src(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4959 | static IrInstSrc *ir_build_await_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 3962 | IrInstruction *frame, ResultLoc *result_loc) | 4960 | IrInstSrc *frame, ResultLoc *result_loc) |
| 3963 | { | 4961 | { |
| 3964 | IrInstructionAwaitSrc *instruction = ir_build_instruction<IrInstructionAwaitSrc>(irb, scope, source_node); | 4962 | IrInstSrcAwait *instruction = ir_build_instruction<IrInstSrcAwait>(irb, scope, source_node); |
| 3965 | instruction->frame = frame; | 4963 | instruction->frame = frame; |
| 3966 | instruction->result_loc = result_loc; | 4964 | instruction->result_loc = result_loc; |
| 3967 | | 4965 | |
| ... | @@ -3970,24 +4968,23 @@ static IrInstruction *ir_build_await_src(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -3970,24 +4968,23 @@ static IrInstruction *ir_build_await_src(IrBuilder *irb, Scope *scope, AstNode * |
| 3970 | return &instruction->base; | 4968 | return &instruction->base; |
| 3971 | } | 4969 | } |
| 3972 | | 4970 | |
| 3973 | static IrInstructionAwaitGen *ir_build_await_gen(IrAnalyze *ira, IrInstruction *source_instruction, | 4971 | static IrInstGenAwait *ir_build_await_gen(IrAnalyze *ira, IrInst *source_instruction, |
| 3974 | IrInstruction *frame, ZigType *result_type, IrInstruction *result_loc) | 4972 | IrInstGen *frame, ZigType *result_type, IrInstGen *result_loc) |
| 3975 | { | 4973 | { |
| 3976 | IrInstructionAwaitGen *instruction = ir_build_instruction<IrInstructionAwaitGen>(&ira->new_irb, | 4974 | IrInstGenAwait *instruction = ir_build_inst_gen<IrInstGenAwait>(&ira->new_irb, |
| 3977 | source_instruction->scope, source_instruction->source_node); | 4975 | source_instruction->scope, source_instruction->source_node); |
| 3978 | instruction->base.value->type = result_type; | 4976 | instruction->base.value->type = result_type; |
| 3979 | instruction->frame = frame; | 4977 | instruction->frame = frame; |
| 3980 | instruction->result_loc = result_loc; | 4978 | instruction->result_loc = result_loc; |
| 3981 | | 4979 | |
| 3982 | ir_ref_instruction(frame, ira->new_irb.current_basic_block); | 4980 | ir_ref_inst_gen(frame, ira->new_irb.current_basic_block); |
| 3983 | if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); | 4981 | if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block); |
| 3984 | | 4982 | |
| 3985 | return instruction; | 4983 | return instruction; |
| 3986 | } | 4984 | } |
| 3987 | | 4985 | |
| 3988 | static IrInstruction *ir_build_resume(IrBuilder *irb, Scope *scope, AstNode *source_node, IrInstruction *frame) { | 4986 | static IrInstSrc *ir_build_resume_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *frame) { |
| 3989 | IrInstructionResume *instruction = ir_build_instruction<IrInstructionResume>(irb, scope, source_node); | 4987 | IrInstSrcResume *instruction = ir_build_instruction<IrInstSrcResume>(irb, scope, source_node); |
| 3990 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; | | |
| 3991 | instruction->frame = frame; | 4988 | instruction->frame = frame; |
| 3992 | | 4989 | |
| 3993 | ir_ref_instruction(frame, irb->current_basic_block); | 4990 | ir_ref_instruction(frame, irb->current_basic_block); |
| ... | @@ -3995,12 +4992,20 @@ static IrInstruction *ir_build_resume(IrBuilder *irb, Scope *scope, AstNode *sou | ... | @@ -3995,12 +4992,20 @@ static IrInstruction *ir_build_resume(IrBuilder *irb, Scope *scope, AstNode *sou |
| 3995 | return &instruction->base; | 4992 | return &instruction->base; |
| 3996 | } | 4993 | } |
| 3997 | | 4994 | |
| 3998 | static IrInstructionSpillBegin *ir_build_spill_begin(IrBuilder *irb, Scope *scope, AstNode *source_node, | 4995 | static IrInstGen *ir_build_resume_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *frame) { |
| 3999 | IrInstruction *operand, SpillId spill_id) | 4996 | IrInstGenResume *instruction = ir_build_inst_void<IrInstGenResume>(&ira->new_irb, |
| | 4997 | source_instr->scope, source_instr->source_node); |
| | 4998 | instruction->frame = frame; |
| | 4999 | |
| | 5000 | ir_ref_inst_gen(frame, ira->new_irb.current_basic_block); |
| | 5001 | |
| | 5002 | return &instruction->base; |
| | 5003 | } |
| | 5004 | |
| | 5005 | static IrInstSrcSpillBegin *ir_build_spill_begin_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 5006 | IrInstSrc *operand, SpillId spill_id) |
| 4000 | { | 5007 | { |
| 4001 | IrInstructionSpillBegin *instruction = ir_build_instruction<IrInstructionSpillBegin>(irb, scope, source_node); | 5008 | IrInstSrcSpillBegin *instruction = ir_build_instruction<IrInstSrcSpillBegin>(irb, scope, source_node); |
| 4002 | instruction->base.value->special = ConstValSpecialStatic; | | |
| 4003 | instruction->base.value->type = irb->codegen->builtin_types.entry_void; | | |
| 4004 | instruction->operand = operand; | 5009 | instruction->operand = operand; |
| 4005 | instruction->spill_id = spill_id; | 5010 | instruction->spill_id = spill_id; |
| 4006 | | 5011 | |
| ... | @@ -4009,10 +5014,23 @@ static IrInstructionSpillBegin *ir_build_spill_begin(IrBuilder *irb, Scope *scop | ... | @@ -4009,10 +5014,23 @@ static IrInstructionSpillBegin *ir_build_spill_begin(IrBuilder *irb, Scope *scop |
| 4009 | return instruction; | 5014 | return instruction; |
| 4010 | } | 5015 | } |
| 4011 | | 5016 | |
| 4012 | static IrInstruction *ir_build_spill_end(IrBuilder *irb, Scope *scope, AstNode *source_node, | 5017 | static IrInstGen *ir_build_spill_begin_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGen *operand, |
| 4013 | IrInstructionSpillBegin *begin) | 5018 | SpillId spill_id) |
| | 5019 | { |
| | 5020 | IrInstGenSpillBegin *instruction = ir_build_inst_void<IrInstGenSpillBegin>(&ira->new_irb, |
| | 5021 | source_instr->scope, source_instr->source_node); |
| | 5022 | instruction->operand = operand; |
| | 5023 | instruction->spill_id = spill_id; |
| | 5024 | |
| | 5025 | ir_ref_inst_gen(operand, ira->new_irb.current_basic_block); |
| | 5026 | |
| | 5027 | return &instruction->base; |
| | 5028 | } |
| | 5029 | |
| | 5030 | static IrInstSrc *ir_build_spill_end_src(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| | 5031 | IrInstSrcSpillBegin *begin) |
| 4014 | { | 5032 | { |
| 4015 | IrInstructionSpillEnd *instruction = ir_build_instruction<IrInstructionSpillEnd>(irb, scope, source_node); | 5033 | IrInstSrcSpillEnd *instruction = ir_build_instruction<IrInstSrcSpillEnd>(irb, scope, source_node); |
| 4016 | instruction->begin = begin; | 5034 | instruction->begin = begin; |
| 4017 | | 5035 | |
| 4018 | ir_ref_instruction(&begin->base, irb->current_basic_block); | 5036 | ir_ref_instruction(&begin->base, irb->current_basic_block); |
| ... | @@ -4020,22 +5038,35 @@ static IrInstruction *ir_build_spill_end(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -4020,22 +5038,35 @@ static IrInstruction *ir_build_spill_end(IrBuilder *irb, Scope *scope, AstNode * |
| 4020 | return &instruction->base; | 5038 | return &instruction->base; |
| 4021 | } | 5039 | } |
| 4022 | | 5040 | |
| 4023 | static IrInstruction *ir_build_vector_extract_elem(IrAnalyze *ira, IrInstruction *source_instruction, | 5041 | static IrInstGen *ir_build_spill_end_gen(IrAnalyze *ira, IrInst *source_instr, IrInstGenSpillBegin *begin, |
| 4024 | IrInstruction *vector, IrInstruction *index) | 5042 | ZigType *result_type) |
| | 5043 | { |
| | 5044 | IrInstGenSpillEnd *instruction = ir_build_inst_gen<IrInstGenSpillEnd>(&ira->new_irb, |
| | 5045 | source_instr->scope, source_instr->source_node); |
| | 5046 | instruction->base.value->type = result_type; |
| | 5047 | instruction->begin = begin; |
| | 5048 | |
| | 5049 | ir_ref_inst_gen(&begin->base, ira->new_irb.current_basic_block); |
| | 5050 | |
| | 5051 | return &instruction->base; |
| | 5052 | } |
| | 5053 | |
| | 5054 | static IrInstGen *ir_build_vector_extract_elem(IrAnalyze *ira, IrInst *source_instruction, |
| | 5055 | IrInstGen *vector, IrInstGen *index) |
| 4025 | { | 5056 | { |
| 4026 | IrInstructionVectorExtractElem *instruction = ir_build_instruction<IrInstructionVectorExtractElem>( | 5057 | IrInstGenVectorExtractElem *instruction = ir_build_inst_gen<IrInstGenVectorExtractElem>( |
| 4027 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); | 5058 | &ira->new_irb, source_instruction->scope, source_instruction->source_node); |
| 4028 | instruction->base.value->type = vector->value->type->data.vector.elem_type; | 5059 | instruction->base.value->type = vector->value->type->data.vector.elem_type; |
| 4029 | instruction->vector = vector; | 5060 | instruction->vector = vector; |
| 4030 | instruction->index = index; | 5061 | instruction->index = index; |
| 4031 | | 5062 | |
| 4032 | ir_ref_instruction(vector, ira->new_irb.current_basic_block); | 5063 | ir_ref_inst_gen(vector, ira->new_irb.current_basic_block); |
| 4033 | ir_ref_instruction(index, ira->new_irb.current_basic_block); | 5064 | ir_ref_inst_gen(index, ira->new_irb.current_basic_block); |
| 4034 | | 5065 | |
| 4035 | return &instruction->base; | 5066 | return &instruction->base; |
| 4036 | } | 5067 | } |
| 4037 | | 5068 | |
| 4038 | static void ir_count_defers(IrBuilder *irb, Scope *inner_scope, Scope *outer_scope, size_t *results) { | 5069 | static void ir_count_defers(IrBuilderSrc *irb, Scope *inner_scope, Scope *outer_scope, size_t *results) { |
| 4039 | results[ReturnKindUnconditional] = 0; | 5070 | results[ReturnKindUnconditional] = 0; |
| 4040 | results[ReturnKindError] = 0; | 5071 | results[ReturnKindError] = 0; |
| 4041 | | 5072 | |
| ... | @@ -4072,12 +5103,12 @@ static void ir_count_defers(IrBuilder *irb, Scope *inner_scope, Scope *outer_sco | ... | @@ -4072,12 +5103,12 @@ static void ir_count_defers(IrBuilder *irb, Scope *inner_scope, Scope *outer_sco |
| 4072 | } | 5103 | } |
| 4073 | } | 5104 | } |
| 4074 | | 5105 | |
| 4075 | static IrInstruction *ir_mark_gen(IrInstruction *instruction) { | 5106 | static IrInstSrc *ir_mark_gen(IrInstSrc *instruction) { |
| 4076 | instruction->is_gen = true; | 5107 | instruction->is_gen = true; |
| 4077 | return instruction; | 5108 | return instruction; |
| 4078 | } | 5109 | } |
| 4079 | | 5110 | |
| 4080 | static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *outer_scope, bool gen_error_defers) { | 5111 | static bool ir_gen_defers_for_block(IrBuilderSrc *irb, Scope *inner_scope, Scope *outer_scope, bool gen_error_defers) { |
| 4081 | Scope *scope = inner_scope; | 5112 | Scope *scope = inner_scope; |
| 4082 | bool is_noreturn = false; | 5113 | bool is_noreturn = false; |
| 4083 | while (scope != outer_scope) { | 5114 | while (scope != outer_scope) { |
| ... | @@ -4094,11 +5125,9 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o | ... | @@ -4094,11 +5125,9 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o |
| 4094 | { | 5125 | { |
| 4095 | AstNode *defer_expr_node = defer_node->data.defer.expr; | 5126 | AstNode *defer_expr_node = defer_node->data.defer.expr; |
| 4096 | Scope *defer_expr_scope = defer_node->data.defer.expr_scope; | 5127 | Scope *defer_expr_scope = defer_node->data.defer.expr_scope; |
| 4097 | IrInstruction *defer_expr_value = ir_gen_node(irb, defer_expr_node, defer_expr_scope); | 5128 | IrInstSrc *defer_expr_value = ir_gen_node(irb, defer_expr_node, defer_expr_scope); |
| 4098 | if (defer_expr_value != irb->codegen->invalid_instruction) { | 5129 | if (defer_expr_value != irb->codegen->invalid_inst_src) { |
| 4099 | if (defer_expr_value->value->type != nullptr && | 5130 | if (defer_expr_value->is_noreturn) { |
| 4100 | defer_expr_value->value->type->id == ZigTypeIdUnreachable) | | |
| 4101 | { | | |
| 4102 | is_noreturn = true; | 5131 | is_noreturn = true; |
| 4103 | } else { | 5132 | } else { |
| 4104 | ir_mark_gen(ir_build_check_statement_is_void(irb, defer_expr_scope, defer_expr_node, | 5133 | ir_mark_gen(ir_build_check_statement_is_void(irb, defer_expr_scope, defer_expr_node, |
| ... | @@ -4130,13 +5159,17 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o | ... | @@ -4130,13 +5159,17 @@ static bool ir_gen_defers_for_block(IrBuilder *irb, Scope *inner_scope, Scope *o |
| 4130 | return is_noreturn; | 5159 | return is_noreturn; |
| 4131 | } | 5160 | } |
| 4132 | | 5161 | |
| 4133 | static void ir_set_cursor_at_end(IrBuilder *irb, IrBasicBlock *basic_block) { | 5162 | static void ir_set_cursor_at_end_gen(IrBuilderGen *irb, IrBasicBlockGen *basic_block) { |
| 4134 | assert(basic_block); | 5163 | assert(basic_block); |
| | 5164 | irb->current_basic_block = basic_block; |
| | 5165 | } |
| 4135 | | 5166 | |
| | 5167 | static void ir_set_cursor_at_end(IrBuilderSrc *irb, IrBasicBlockSrc *basic_block) { |
| | 5168 | assert(basic_block); |
| 4136 | irb->current_basic_block = basic_block; | 5169 | irb->current_basic_block = basic_block; |
| 4137 | } | 5170 | } |
| 4138 | | 5171 | |
| 4139 | static void ir_set_cursor_at_end_and_append_block(IrBuilder *irb, IrBasicBlock *basic_block) { | 5172 | static void ir_set_cursor_at_end_and_append_block(IrBuilderSrc *irb, IrBasicBlockSrc *basic_block) { |
| 4140 | basic_block->index = irb->exec->basic_block_list.length; | 5173 | basic_block->index = irb->exec->basic_block_list.length; |
| 4141 | irb->exec->basic_block_list.append(basic_block); | 5174 | irb->exec->basic_block_list.append(basic_block); |
| 4142 | ir_set_cursor_at_end(irb, basic_block); | 5175 | ir_set_cursor_at_end(irb, basic_block); |
| ... | @@ -4166,13 +5199,13 @@ static ScopeDeferExpr *get_scope_defer_expr(Scope *scope) { | ... | @@ -4166,13 +5199,13 @@ static ScopeDeferExpr *get_scope_defer_expr(Scope *scope) { |
| 4166 | return nullptr; | 5199 | return nullptr; |
| 4167 | } | 5200 | } |
| 4168 | | 5201 | |
| 4169 | static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { | 5202 | static IrInstSrc *ir_gen_return(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { |
| 4170 | assert(node->type == NodeTypeReturnExpr); | 5203 | assert(node->type == NodeTypeReturnExpr); |
| 4171 | | 5204 | |
| 4172 | ZigFn *fn_entry = exec_fn_entry(irb->exec); | 5205 | ZigFn *fn_entry = exec_fn_entry(irb->exec); |
| 4173 | if (!fn_entry) { | 5206 | if (!fn_entry) { |
| 4174 | add_node_error(irb->codegen, node, buf_sprintf("return expression outside function definition")); | 5207 | add_node_error(irb->codegen, node, buf_sprintf("return expression outside function definition")); |
| 4175 | return irb->codegen->invalid_instruction; | 5208 | return irb->codegen->invalid_inst_src; |
| 4176 | } | 5209 | } |
| 4177 | | 5210 | |
| 4178 | ScopeDeferExpr *scope_defer_expr = get_scope_defer_expr(scope); | 5211 | ScopeDeferExpr *scope_defer_expr = get_scope_defer_expr(scope); |
| ... | @@ -4181,7 +5214,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4181,7 +5214,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4181 | add_node_error(irb->codegen, node, buf_sprintf("cannot return from defer expression")); | 5214 | add_node_error(irb->codegen, node, buf_sprintf("cannot return from defer expression")); |
| 4182 | scope_defer_expr->reported_err = true; | 5215 | scope_defer_expr->reported_err = true; |
| 4183 | } | 5216 | } |
| 4184 | return irb->codegen->invalid_instruction; | 5217 | return irb->codegen->invalid_inst_src; |
| 4185 | } | 5218 | } |
| 4186 | | 5219 | |
| 4187 | Scope *outer_scope = irb->exec->begin_scope; | 5220 | Scope *outer_scope = irb->exec->begin_scope; |
| ... | @@ -4194,15 +5227,15 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4194,15 +5227,15 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4194 | result_loc_ret->base.id = ResultLocIdReturn; | 5227 | result_loc_ret->base.id = ResultLocIdReturn; |
| 4195 | ir_build_reset_result(irb, scope, node, &result_loc_ret->base); | 5228 | ir_build_reset_result(irb, scope, node, &result_loc_ret->base); |
| 4196 | | 5229 | |
| 4197 | IrInstruction *return_value; | 5230 | IrInstSrc *return_value; |
| 4198 | if (expr_node) { | 5231 | if (expr_node) { |
| 4199 | // Temporarily set this so that if we return a type it gets the name of the function | 5232 | // Temporarily set this so that if we return a type it gets the name of the function |
| 4200 | ZigFn *prev_name_fn = irb->exec->name_fn; | 5233 | ZigFn *prev_name_fn = irb->exec->name_fn; |
| 4201 | irb->exec->name_fn = exec_fn_entry(irb->exec); | 5234 | irb->exec->name_fn = exec_fn_entry(irb->exec); |
| 4202 | return_value = ir_gen_node_extra(irb, expr_node, scope, LValNone, &result_loc_ret->base); | 5235 | return_value = ir_gen_node_extra(irb, expr_node, scope, LValNone, &result_loc_ret->base); |
| 4203 | irb->exec->name_fn = prev_name_fn; | 5236 | irb->exec->name_fn = prev_name_fn; |
| 4204 | if (return_value == irb->codegen->invalid_instruction) | 5237 | if (return_value == irb->codegen->invalid_inst_src) |
| 4205 | return irb->codegen->invalid_instruction; | 5238 | return irb->codegen->invalid_inst_src; |
| 4206 | } else { | 5239 | } else { |
| 4207 | return_value = ir_build_const_void(irb, scope, node); | 5240 | return_value = ir_build_const_void(irb, scope, node); |
| 4208 | } | 5241 | } |
| ... | @@ -4215,22 +5248,22 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4215,22 +5248,22 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4215 | if (!have_err_defers && !irb->codegen->have_err_ret_tracing) { | 5248 | if (!have_err_defers && !irb->codegen->have_err_ret_tracing) { |
| 4216 | // only generate unconditional defers | 5249 | // only generate unconditional defers |
| 4217 | ir_gen_defers_for_block(irb, scope, outer_scope, false); | 5250 | ir_gen_defers_for_block(irb, scope, outer_scope, false); |
| 4218 | IrInstruction *result = ir_build_return(irb, scope, node, return_value); | 5251 | IrInstSrc *result = ir_build_return_src(irb, scope, node, return_value); |
| 4219 | result_loc_ret->base.source_instruction = result; | 5252 | result_loc_ret->base.source_instruction = result; |
| 4220 | return result; | 5253 | return result; |
| 4221 | } | 5254 | } |
| 4222 | bool should_inline = ir_should_inline(irb->exec, scope); | 5255 | bool should_inline = ir_should_inline(irb->exec, scope); |
| 4223 | | 5256 | |
| 4224 | IrBasicBlock *err_block = ir_create_basic_block(irb, scope, "ErrRetErr"); | 5257 | IrBasicBlockSrc *err_block = ir_create_basic_block(irb, scope, "ErrRetErr"); |
| 4225 | IrBasicBlock *ok_block = ir_create_basic_block(irb, scope, "ErrRetOk"); | 5258 | IrBasicBlockSrc *ok_block = ir_create_basic_block(irb, scope, "ErrRetOk"); |
| 4226 | | 5259 | |
| 4227 | if (!have_err_defers) { | 5260 | if (!have_err_defers) { |
| 4228 | ir_gen_defers_for_block(irb, scope, outer_scope, false); | 5261 | ir_gen_defers_for_block(irb, scope, outer_scope, false); |
| 4229 | } | 5262 | } |
| 4230 | | 5263 | |
| 4231 | IrInstruction *is_err = ir_build_test_err_src(irb, scope, node, return_value, false, true); | 5264 | IrInstSrc *is_err = ir_build_test_err_src(irb, scope, node, return_value, false, true); |
| 4232 | | 5265 | |
| 4233 | IrInstruction *is_comptime; | 5266 | IrInstSrc *is_comptime; |
| 4234 | if (should_inline) { | 5267 | if (should_inline) { |
| 4235 | is_comptime = ir_build_const_bool(irb, scope, node, should_inline); | 5268 | is_comptime = ir_build_const_bool(irb, scope, node, should_inline); |
| 4236 | } else { | 5269 | } else { |
| ... | @@ -4238,14 +5271,14 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4238,14 +5271,14 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4238 | } | 5271 | } |
| 4239 | | 5272 | |
| 4240 | ir_mark_gen(ir_build_cond_br(irb, scope, node, is_err, err_block, ok_block, is_comptime)); | 5273 | ir_mark_gen(ir_build_cond_br(irb, scope, node, is_err, err_block, ok_block, is_comptime)); |
| 4241 | IrBasicBlock *ret_stmt_block = ir_create_basic_block(irb, scope, "RetStmt"); | 5274 | IrBasicBlockSrc *ret_stmt_block = ir_create_basic_block(irb, scope, "RetStmt"); |
| 4242 | | 5275 | |
| 4243 | ir_set_cursor_at_end_and_append_block(irb, err_block); | 5276 | ir_set_cursor_at_end_and_append_block(irb, err_block); |
| 4244 | if (have_err_defers) { | 5277 | if (have_err_defers) { |
| 4245 | ir_gen_defers_for_block(irb, scope, outer_scope, true); | 5278 | ir_gen_defers_for_block(irb, scope, outer_scope, true); |
| 4246 | } | 5279 | } |
| 4247 | if (irb->codegen->have_err_ret_tracing && !should_inline) { | 5280 | if (irb->codegen->have_err_ret_tracing && !should_inline) { |
| 4248 | ir_build_save_err_ret_addr(irb, scope, node); | 5281 | ir_build_save_err_ret_addr_src(irb, scope, node); |
| 4249 | } | 5282 | } |
| 4250 | ir_build_br(irb, scope, node, ret_stmt_block, is_comptime); | 5283 | ir_build_br(irb, scope, node, ret_stmt_block, is_comptime); |
| 4251 | | 5284 | |
| ... | @@ -4256,21 +5289,21 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4256,21 +5289,21 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4256 | ir_build_br(irb, scope, node, ret_stmt_block, is_comptime); | 5289 | ir_build_br(irb, scope, node, ret_stmt_block, is_comptime); |
| 4257 | | 5290 | |
| 4258 | ir_set_cursor_at_end_and_append_block(irb, ret_stmt_block); | 5291 | ir_set_cursor_at_end_and_append_block(irb, ret_stmt_block); |
| 4259 | IrInstruction *result = ir_build_return(irb, scope, node, return_value); | 5292 | IrInstSrc *result = ir_build_return_src(irb, scope, node, return_value); |
| 4260 | result_loc_ret->base.source_instruction = result; | 5293 | result_loc_ret->base.source_instruction = result; |
| 4261 | return result; | 5294 | return result; |
| 4262 | } | 5295 | } |
| 4263 | case ReturnKindError: | 5296 | case ReturnKindError: |
| 4264 | { | 5297 | { |
| 4265 | assert(expr_node); | 5298 | assert(expr_node); |
| 4266 | IrInstruction *err_union_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); | 5299 | IrInstSrc *err_union_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); |
| 4267 | if (err_union_ptr == irb->codegen->invalid_instruction) | 5300 | if (err_union_ptr == irb->codegen->invalid_inst_src) |
| 4268 | return irb->codegen->invalid_instruction; | 5301 | return irb->codegen->invalid_inst_src; |
| 4269 | IrInstruction *is_err_val = ir_build_test_err_src(irb, scope, node, err_union_ptr, true, false); | 5302 | IrInstSrc *is_err_val = ir_build_test_err_src(irb, scope, node, err_union_ptr, true, false); |
| 4270 | | 5303 | |
| 4271 | IrBasicBlock *return_block = ir_create_basic_block(irb, scope, "ErrRetReturn"); | 5304 | IrBasicBlockSrc *return_block = ir_create_basic_block(irb, scope, "ErrRetReturn"); |
| 4272 | IrBasicBlock *continue_block = ir_create_basic_block(irb, scope, "ErrRetContinue"); | 5305 | IrBasicBlockSrc *continue_block = ir_create_basic_block(irb, scope, "ErrRetContinue"); |
| 4273 | IrInstruction *is_comptime; | 5306 | IrInstSrc *is_comptime; |
| 4274 | bool should_inline = ir_should_inline(irb->exec, scope); | 5307 | bool should_inline = ir_should_inline(irb->exec, scope); |
| 4275 | if (should_inline) { | 5308 | if (should_inline) { |
| 4276 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 5309 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| ... | @@ -4280,10 +5313,10 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4280,10 +5313,10 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4280 | ir_mark_gen(ir_build_cond_br(irb, scope, node, is_err_val, return_block, continue_block, is_comptime)); | 5313 | ir_mark_gen(ir_build_cond_br(irb, scope, node, is_err_val, return_block, continue_block, is_comptime)); |
| 4281 | | 5314 | |
| 4282 | ir_set_cursor_at_end_and_append_block(irb, return_block); | 5315 | ir_set_cursor_at_end_and_append_block(irb, return_block); |
| 4283 | IrInstruction *err_val_ptr = ir_build_unwrap_err_code(irb, scope, node, err_union_ptr); | 5316 | IrInstSrc *err_val_ptr = ir_build_unwrap_err_code_src(irb, scope, node, err_union_ptr); |
| 4284 | IrInstruction *err_val = ir_build_load_ptr(irb, scope, node, err_val_ptr); | 5317 | IrInstSrc *err_val = ir_build_load_ptr(irb, scope, node, err_val_ptr); |
| 4285 | ir_mark_gen(ir_build_add_implicit_return_type(irb, scope, node, err_val, nullptr)); | 5318 | ir_mark_gen(ir_build_add_implicit_return_type(irb, scope, node, err_val, nullptr)); |
| 4286 | IrInstructionSpillBegin *spill_begin = ir_build_spill_begin(irb, scope, node, err_val, | 5319 | IrInstSrcSpillBegin *spill_begin = ir_build_spill_begin_src(irb, scope, node, err_val, |
| 4287 | SpillIdRetErrCode); | 5320 | SpillIdRetErrCode); |
| 4288 | ResultLocReturn *result_loc_ret = allocate<ResultLocReturn>(1, "ResultLocReturn"); | 5321 | ResultLocReturn *result_loc_ret = allocate<ResultLocReturn>(1, "ResultLocReturn"); |
| 4289 | result_loc_ret->base.id = ResultLocIdReturn; | 5322 | result_loc_ret->base.id = ResultLocIdReturn; |
| ... | @@ -4291,15 +5324,15 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4291,15 +5324,15 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4291 | ir_build_end_expr(irb, scope, node, err_val, &result_loc_ret->base); | 5324 | ir_build_end_expr(irb, scope, node, err_val, &result_loc_ret->base); |
| 4292 | if (!ir_gen_defers_for_block(irb, scope, outer_scope, true)) { | 5325 | if (!ir_gen_defers_for_block(irb, scope, outer_scope, true)) { |
| 4293 | if (irb->codegen->have_err_ret_tracing && !should_inline) { | 5326 | if (irb->codegen->have_err_ret_tracing && !should_inline) { |
| 4294 | ir_build_save_err_ret_addr(irb, scope, node); | 5327 | ir_build_save_err_ret_addr_src(irb, scope, node); |
| 4295 | } | 5328 | } |
| 4296 | err_val = ir_build_spill_end(irb, scope, node, spill_begin); | 5329 | err_val = ir_build_spill_end_src(irb, scope, node, spill_begin); |
| 4297 | IrInstruction *ret_inst = ir_build_return(irb, scope, node, err_val); | 5330 | IrInstSrc *ret_inst = ir_build_return_src(irb, scope, node, err_val); |
| 4298 | result_loc_ret->base.source_instruction = ret_inst; | 5331 | result_loc_ret->base.source_instruction = ret_inst; |
| 4299 | } | 5332 | } |
| 4300 | | 5333 | |
| 4301 | ir_set_cursor_at_end_and_append_block(irb, continue_block); | 5334 | ir_set_cursor_at_end_and_append_block(irb, continue_block); |
| 4302 | IrInstruction *unwrapped_ptr = ir_build_unwrap_err_payload(irb, scope, node, err_union_ptr, false, false); | 5335 | IrInstSrc *unwrapped_ptr = ir_build_unwrap_err_payload_src(irb, scope, node, err_union_ptr, false, false); |
| 4303 | if (lval == LValPtr) | 5336 | if (lval == LValPtr) |
| 4304 | return unwrapped_ptr; | 5337 | return unwrapped_ptr; |
| 4305 | else | 5338 | else |
| ... | @@ -4310,7 +5343,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4310,7 +5343,7 @@ static IrInstruction *ir_gen_return(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4310 | } | 5343 | } |
| 4311 | | 5344 | |
| 4312 | static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_scope, | 5345 | static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_scope, |
| 4313 | Buf *name, bool src_is_const, bool gen_is_const, bool is_shadowable, IrInstruction *is_comptime, | 5346 | Buf *name, bool src_is_const, bool gen_is_const, bool is_shadowable, IrInstSrc *is_comptime, |
| 4314 | bool skip_name_check) | 5347 | bool skip_name_check) |
| 4315 | { | 5348 | { |
| 4316 | ZigVar *variable_entry = allocate<ZigVar>(1, "ZigVar"); | 5349 | ZigVar *variable_entry = allocate<ZigVar>(1, "ZigVar"); |
| ... | @@ -4322,7 +5355,7 @@ static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_s | ... | @@ -4322,7 +5355,7 @@ static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_s |
| 4322 | variable_entry->const_value = create_const_vals(1); | 5355 | variable_entry->const_value = create_const_vals(1); |
| 4323 | | 5356 | |
| 4324 | if (is_comptime != nullptr) { | 5357 | if (is_comptime != nullptr) { |
| 4325 | is_comptime->ref_count += 1; | 5358 | is_comptime->base.ref_count += 1; |
| 4326 | } | 5359 | } |
| 4327 | | 5360 | |
| 4328 | if (name) { | 5361 | if (name) { |
| ... | @@ -4372,8 +5405,8 @@ static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_s | ... | @@ -4372,8 +5405,8 @@ static ZigVar *create_local_var(CodeGen *codegen, AstNode *node, Scope *parent_s |
| 4372 | | 5405 | |
| 4373 | // Set name to nullptr to make the variable anonymous (not visible to programmer). | 5406 | // Set name to nullptr to make the variable anonymous (not visible to programmer). |
| 4374 | // After you call this function var->child_scope has the variable in scope | 5407 | // After you call this function var->child_scope has the variable in scope |
| 4375 | static ZigVar *ir_create_var(IrBuilder *irb, AstNode *node, Scope *scope, Buf *name, | 5408 | static ZigVar *ir_create_var(IrBuilderSrc *irb, AstNode *node, Scope *scope, Buf *name, |
| 4376 | bool src_is_const, bool gen_is_const, bool is_shadowable, IrInstruction *is_comptime) | 5409 | bool src_is_const, bool gen_is_const, bool is_shadowable, IrInstSrc *is_comptime) |
| 4377 | { | 5410 | { |
| 4378 | bool is_underscored = name ? buf_eql_str(name, "_") : false; | 5411 | bool is_underscored = name ? buf_eql_str(name, "_") : false; |
| 4379 | ZigVar *var = create_local_var(irb->codegen, node, scope, | 5412 | ZigVar *var = create_local_var(irb->codegen, node, scope, |
| ... | @@ -4396,13 +5429,13 @@ static ResultLocPeer *create_peer_result(ResultLocPeerParent *peer_parent) { | ... | @@ -4396,13 +5429,13 @@ static ResultLocPeer *create_peer_result(ResultLocPeerParent *peer_parent) { |
| 4396 | return result; | 5429 | return result; |
| 4397 | } | 5430 | } |
| 4398 | | 5431 | |
| 4399 | static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode *block_node, LVal lval, | 5432 | static IrInstSrc *ir_gen_block(IrBuilderSrc *irb, Scope *parent_scope, AstNode *block_node, LVal lval, |
| 4400 | ResultLoc *result_loc) | 5433 | ResultLoc *result_loc) |
| 4401 | { | 5434 | { |
| 4402 | assert(block_node->type == NodeTypeBlock); | 5435 | assert(block_node->type == NodeTypeBlock); |
| 4403 | | 5436 | |
| 4404 | ZigList<IrInstruction *> incoming_values = {0}; | 5437 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 4405 | ZigList<IrBasicBlock *> incoming_blocks = {0}; | 5438 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; |
| 4406 | | 5439 | |
| 4407 | ScopeBlock *scope_block = create_block_scope(irb->codegen, block_node, parent_scope); | 5440 | ScopeBlock *scope_block = create_block_scope(irb->codegen, block_node, parent_scope); |
| 4408 | | 5441 | |
| ... | @@ -4438,11 +5471,11 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -4438,11 +5471,11 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode |
| 4438 | } | 5471 | } |
| 4439 | | 5472 | |
| 4440 | bool is_continuation_unreachable = false; | 5473 | bool is_continuation_unreachable = false; |
| 4441 | IrInstruction *noreturn_return_value = nullptr; | 5474 | IrInstSrc *noreturn_return_value = nullptr; |
| 4442 | for (size_t i = 0; i < block_node->data.block.statements.length; i += 1) { | 5475 | for (size_t i = 0; i < block_node->data.block.statements.length; i += 1) { |
| 4443 | AstNode *statement_node = block_node->data.block.statements.at(i); | 5476 | AstNode *statement_node = block_node->data.block.statements.at(i); |
| 4444 | | 5477 | |
| 4445 | IrInstruction *statement_value = ir_gen_node(irb, statement_node, child_scope); | 5478 | IrInstSrc *statement_value = ir_gen_node(irb, statement_node, child_scope); |
| 4446 | is_continuation_unreachable = instr_is_unreachable(statement_value); | 5479 | is_continuation_unreachable = instr_is_unreachable(statement_value); |
| 4447 | if (is_continuation_unreachable) { | 5480 | if (is_continuation_unreachable) { |
| 4448 | // keep the last noreturn statement value around in case we need to return it | 5481 | // keep the last noreturn statement value around in case we need to return it |
| ... | @@ -4450,15 +5483,15 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -4450,15 +5483,15 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode |
| 4450 | } | 5483 | } |
| 4451 | // This logic must be kept in sync with | 5484 | // This logic must be kept in sync with |
| 4452 | // [STMT_EXPR_TEST_THING] <--- (search this token) | 5485 | // [STMT_EXPR_TEST_THING] <--- (search this token) |
| 4453 | if (statement_node->type == NodeTypeDefer && statement_value != irb->codegen->invalid_instruction) { | 5486 | if (statement_node->type == NodeTypeDefer && statement_value != irb->codegen->invalid_inst_src) { |
| 4454 | // defer starts a new scope | 5487 | // defer starts a new scope |
| 4455 | child_scope = statement_node->data.defer.child_scope; | 5488 | child_scope = statement_node->data.defer.child_scope; |
| 4456 | assert(child_scope); | 5489 | assert(child_scope); |
| 4457 | } else if (statement_value->id == IrInstructionIdDeclVarSrc) { | 5490 | } else if (statement_value->id == IrInstSrcIdDeclVar) { |
| 4458 | // variable declarations start a new scope | 5491 | // variable declarations start a new scope |
| 4459 | IrInstructionDeclVarSrc *decl_var_instruction = (IrInstructionDeclVarSrc *)statement_value; | 5492 | IrInstSrcDeclVar *decl_var_instruction = (IrInstSrcDeclVar *)statement_value; |
| 4460 | child_scope = decl_var_instruction->var->child_scope; | 5493 | child_scope = decl_var_instruction->var->child_scope; |
| 4461 | } else if (statement_value != irb->codegen->invalid_instruction && !is_continuation_unreachable) { | 5494 | } else if (statement_value != irb->codegen->invalid_inst_src && !is_continuation_unreachable) { |
| 4462 | // this statement's value must be void | 5495 | // this statement's value must be void |
| 4463 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, statement_node, statement_value)); | 5496 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, statement_node, statement_value)); |
| 4464 | } | 5497 | } |
| ... | @@ -4474,12 +5507,12 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -4474,12 +5507,12 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode |
| 4474 | scope_block->peer_parent->peers.last()->next_bb = scope_block->end_block; | 5507 | scope_block->peer_parent->peers.last()->next_bb = scope_block->end_block; |
| 4475 | } | 5508 | } |
| 4476 | ir_set_cursor_at_end_and_append_block(irb, scope_block->end_block); | 5509 | ir_set_cursor_at_end_and_append_block(irb, scope_block->end_block); |
| 4477 | IrInstruction *phi = ir_build_phi(irb, parent_scope, block_node, incoming_blocks.length, | 5510 | IrInstSrc *phi = ir_build_phi(irb, parent_scope, block_node, incoming_blocks.length, |
| 4478 | incoming_blocks.items, incoming_values.items, scope_block->peer_parent); | 5511 | incoming_blocks.items, incoming_values.items, scope_block->peer_parent); |
| 4479 | return ir_expr_wrap(irb, parent_scope, phi, result_loc); | 5512 | return ir_expr_wrap(irb, parent_scope, phi, result_loc); |
| 4480 | } else { | 5513 | } else { |
| 4481 | incoming_blocks.append(irb->current_basic_block); | 5514 | incoming_blocks.append(irb->current_basic_block); |
| 4482 | IrInstruction *else_expr_result = ir_mark_gen(ir_build_const_void(irb, parent_scope, block_node)); | 5515 | IrInstSrc *else_expr_result = ir_mark_gen(ir_build_const_void(irb, parent_scope, block_node)); |
| 4483 | | 5516 | |
| 4484 | if (scope_block->peer_parent != nullptr) { | 5517 | if (scope_block->peer_parent != nullptr) { |
| 4485 | ResultLocPeer *peer_result = create_peer_result(scope_block->peer_parent); | 5518 | ResultLocPeer *peer_result = create_peer_result(scope_block->peer_parent); |
| ... | @@ -4499,15 +5532,15 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -4499,15 +5532,15 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode |
| 4499 | ir_gen_defers_for_block(irb, child_scope, outer_block_scope, false); | 5532 | ir_gen_defers_for_block(irb, child_scope, outer_block_scope, false); |
| 4500 | } | 5533 | } |
| 4501 | | 5534 | |
| 4502 | IrInstruction *result; | 5535 | IrInstSrc *result; |
| 4503 | if (block_node->data.block.name != nullptr) { | 5536 | if (block_node->data.block.name != nullptr) { |
| 4504 | ir_mark_gen(ir_build_br(irb, parent_scope, block_node, scope_block->end_block, scope_block->is_comptime)); | 5537 | ir_mark_gen(ir_build_br(irb, parent_scope, block_node, scope_block->end_block, scope_block->is_comptime)); |
| 4505 | ir_set_cursor_at_end_and_append_block(irb, scope_block->end_block); | 5538 | ir_set_cursor_at_end_and_append_block(irb, scope_block->end_block); |
| 4506 | IrInstruction *phi = ir_build_phi(irb, parent_scope, block_node, incoming_blocks.length, | 5539 | IrInstSrc *phi = ir_build_phi(irb, parent_scope, block_node, incoming_blocks.length, |
| 4507 | incoming_blocks.items, incoming_values.items, scope_block->peer_parent); | 5540 | incoming_blocks.items, incoming_values.items, scope_block->peer_parent); |
| 4508 | result = ir_expr_wrap(irb, parent_scope, phi, result_loc); | 5541 | result = ir_expr_wrap(irb, parent_scope, phi, result_loc); |
| 4509 | } else { | 5542 | } else { |
| 4510 | IrInstruction *void_inst = ir_mark_gen(ir_build_const_void(irb, child_scope, block_node)); | 5543 | IrInstSrc *void_inst = ir_mark_gen(ir_build_const_void(irb, child_scope, block_node)); |
| 4511 | result = ir_lval_wrap(irb, parent_scope, void_inst, lval, result_loc); | 5544 | result = ir_lval_wrap(irb, parent_scope, void_inst, lval, result_loc); |
| 4512 | } | 5545 | } |
| 4513 | if (!is_return_from_fn) | 5546 | if (!is_return_from_fn) |
| ... | @@ -4518,30 +5551,30 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -4518,30 +5551,30 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode |
| 4518 | | 5551 | |
| 4519 | ir_mark_gen(ir_build_add_implicit_return_type(irb, child_scope, block_node, result, nullptr)); | 5552 | ir_mark_gen(ir_build_add_implicit_return_type(irb, child_scope, block_node, result, nullptr)); |
| 4520 | ir_gen_defers_for_block(irb, child_scope, outer_block_scope, false); | 5553 | ir_gen_defers_for_block(irb, child_scope, outer_block_scope, false); |
| 4521 | return ir_mark_gen(ir_build_return(irb, child_scope, result->source_node, result)); | 5554 | return ir_mark_gen(ir_build_return_src(irb, child_scope, result->base.source_node, result)); |
| 4522 | } | 5555 | } |
| 4523 | | 5556 | |
| 4524 | static IrInstruction *ir_gen_bin_op_id(IrBuilder *irb, Scope *scope, AstNode *node, IrBinOp op_id) { | 5557 | static IrInstSrc *ir_gen_bin_op_id(IrBuilderSrc *irb, Scope *scope, AstNode *node, IrBinOp op_id) { |
| 4525 | Scope *inner_scope = scope; | 5558 | Scope *inner_scope = scope; |
| 4526 | if (op_id == IrBinOpArrayCat || op_id == IrBinOpArrayMult) { | 5559 | if (op_id == IrBinOpArrayCat || op_id == IrBinOpArrayMult) { |
| 4527 | inner_scope = create_comptime_scope(irb->codegen, node, scope); | 5560 | inner_scope = create_comptime_scope(irb->codegen, node, scope); |
| 4528 | } | 5561 | } |
| 4529 | | 5562 | |
| 4530 | IrInstruction *op1 = ir_gen_node(irb, node->data.bin_op_expr.op1, inner_scope); | 5563 | IrInstSrc *op1 = ir_gen_node(irb, node->data.bin_op_expr.op1, inner_scope); |
| 4531 | IrInstruction *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, inner_scope); | 5564 | IrInstSrc *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, inner_scope); |
| 4532 | | 5565 | |
| 4533 | if (op1 == irb->codegen->invalid_instruction || op2 == irb->codegen->invalid_instruction) | 5566 | if (op1 == irb->codegen->invalid_inst_src || op2 == irb->codegen->invalid_inst_src) |
| 4534 | return irb->codegen->invalid_instruction; | 5567 | return irb->codegen->invalid_inst_src; |
| 4535 | | 5568 | |
| 4536 | return ir_build_bin_op(irb, scope, node, op_id, op1, op2, true); | 5569 | return ir_build_bin_op(irb, scope, node, op_id, op1, op2, true); |
| 4537 | } | 5570 | } |
| 4538 | | 5571 | |
| 4539 | static IrInstruction *ir_gen_merge_err_sets(IrBuilder *irb, Scope *scope, AstNode *node) { | 5572 | static IrInstSrc *ir_gen_merge_err_sets(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4540 | IrInstruction *op1 = ir_gen_node(irb, node->data.bin_op_expr.op1, scope); | 5573 | IrInstSrc *op1 = ir_gen_node(irb, node->data.bin_op_expr.op1, scope); |
| 4541 | IrInstruction *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); | 5574 | IrInstSrc *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); |
| 4542 | | 5575 | |
| 4543 | if (op1 == irb->codegen->invalid_instruction || op2 == irb->codegen->invalid_instruction) | 5576 | if (op1 == irb->codegen->invalid_inst_src || op2 == irb->codegen->invalid_inst_src) |
| 4544 | return irb->codegen->invalid_instruction; | 5577 | return irb->codegen->invalid_inst_src; |
| 4545 | | 5578 | |
| 4546 | // TODO only pass type_name when the || operator is the top level AST node in the var decl expr | 5579 | // TODO only pass type_name when the || operator is the top level AST node in the var decl expr |
| 4547 | Buf bare_name = BUF_INIT; | 5580 | Buf bare_name = BUF_INIT; |
| ... | @@ -4550,10 +5583,10 @@ static IrInstruction *ir_gen_merge_err_sets(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -4550,10 +5583,10 @@ static IrInstruction *ir_gen_merge_err_sets(IrBuilder *irb, Scope *scope, AstNod |
| 4550 | return ir_build_merge_err_sets(irb, scope, node, op1, op2, type_name); | 5583 | return ir_build_merge_err_sets(irb, scope, node, op1, op2, type_name); |
| 4551 | } | 5584 | } |
| 4552 | | 5585 | |
| 4553 | static IrInstruction *ir_gen_assign(IrBuilder *irb, Scope *scope, AstNode *node) { | 5586 | static IrInstSrc *ir_gen_assign(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4554 | IrInstruction *lvalue = ir_gen_node_extra(irb, node->data.bin_op_expr.op1, scope, LValPtr, nullptr); | 5587 | IrInstSrc *lvalue = ir_gen_node_extra(irb, node->data.bin_op_expr.op1, scope, LValPtr, nullptr); |
| 4555 | if (lvalue == irb->codegen->invalid_instruction) | 5588 | if (lvalue == irb->codegen->invalid_inst_src) |
| 4556 | return irb->codegen->invalid_instruction; | 5589 | return irb->codegen->invalid_inst_src; |
| 4557 | | 5590 | |
| 4558 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1, "ResultLocInstruction"); | 5591 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1, "ResultLocInstruction"); |
| 4559 | result_loc_inst->base.id = ResultLocIdInstruction; | 5592 | result_loc_inst->base.id = ResultLocIdInstruction; |
| ... | @@ -4561,49 +5594,49 @@ static IrInstruction *ir_gen_assign(IrBuilder *irb, Scope *scope, AstNode *node) | ... | @@ -4561,49 +5594,49 @@ static IrInstruction *ir_gen_assign(IrBuilder *irb, Scope *scope, AstNode *node) |
| 4561 | ir_ref_instruction(lvalue, irb->current_basic_block); | 5594 | ir_ref_instruction(lvalue, irb->current_basic_block); |
| 4562 | ir_build_reset_result(irb, scope, node, &result_loc_inst->base); | 5595 | ir_build_reset_result(irb, scope, node, &result_loc_inst->base); |
| 4563 | | 5596 | |
| 4564 | IrInstruction *rvalue = ir_gen_node_extra(irb, node->data.bin_op_expr.op2, scope, LValNone, | 5597 | IrInstSrc *rvalue = ir_gen_node_extra(irb, node->data.bin_op_expr.op2, scope, LValNone, |
| 4565 | &result_loc_inst->base); | 5598 | &result_loc_inst->base); |
| 4566 | if (rvalue == irb->codegen->invalid_instruction) | 5599 | if (rvalue == irb->codegen->invalid_inst_src) |
| 4567 | return irb->codegen->invalid_instruction; | 5600 | return irb->codegen->invalid_inst_src; |
| 4568 | | 5601 | |
| 4569 | return ir_build_const_void(irb, scope, node); | 5602 | return ir_build_const_void(irb, scope, node); |
| 4570 | } | 5603 | } |
| 4571 | | 5604 | |
| 4572 | static IrInstruction *ir_gen_assign_merge_err_sets(IrBuilder *irb, Scope *scope, AstNode *node) { | 5605 | static IrInstSrc *ir_gen_assign_merge_err_sets(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4573 | IrInstruction *lvalue = ir_gen_node_extra(irb, node->data.bin_op_expr.op1, scope, LValPtr, nullptr); | 5606 | IrInstSrc *lvalue = ir_gen_node_extra(irb, node->data.bin_op_expr.op1, scope, LValPtr, nullptr); |
| 4574 | if (lvalue == irb->codegen->invalid_instruction) | 5607 | if (lvalue == irb->codegen->invalid_inst_src) |
| 4575 | return lvalue; | 5608 | return lvalue; |
| 4576 | IrInstruction *op1 = ir_build_load_ptr(irb, scope, node->data.bin_op_expr.op1, lvalue); | 5609 | IrInstSrc *op1 = ir_build_load_ptr(irb, scope, node->data.bin_op_expr.op1, lvalue); |
| 4577 | IrInstruction *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); | 5610 | IrInstSrc *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); |
| 4578 | if (op2 == irb->codegen->invalid_instruction) | 5611 | if (op2 == irb->codegen->invalid_inst_src) |
| 4579 | return op2; | 5612 | return op2; |
| 4580 | IrInstruction *result = ir_build_merge_err_sets(irb, scope, node, op1, op2, nullptr); | 5613 | IrInstSrc *result = ir_build_merge_err_sets(irb, scope, node, op1, op2, nullptr); |
| 4581 | ir_build_store_ptr(irb, scope, node, lvalue, result); | 5614 | ir_build_store_ptr(irb, scope, node, lvalue, result); |
| 4582 | return ir_build_const_void(irb, scope, node); | 5615 | return ir_build_const_void(irb, scope, node); |
| 4583 | } | 5616 | } |
| 4584 | | 5617 | |
| 4585 | static IrInstruction *ir_gen_assign_op(IrBuilder *irb, Scope *scope, AstNode *node, IrBinOp op_id) { | 5618 | static IrInstSrc *ir_gen_assign_op(IrBuilderSrc *irb, Scope *scope, AstNode *node, IrBinOp op_id) { |
| 4586 | IrInstruction *lvalue = ir_gen_node_extra(irb, node->data.bin_op_expr.op1, scope, LValPtr, nullptr); | 5619 | IrInstSrc *lvalue = ir_gen_node_extra(irb, node->data.bin_op_expr.op1, scope, LValPtr, nullptr); |
| 4587 | if (lvalue == irb->codegen->invalid_instruction) | 5620 | if (lvalue == irb->codegen->invalid_inst_src) |
| 4588 | return lvalue; | 5621 | return lvalue; |
| 4589 | IrInstruction *op1 = ir_build_load_ptr(irb, scope, node->data.bin_op_expr.op1, lvalue); | 5622 | IrInstSrc *op1 = ir_build_load_ptr(irb, scope, node->data.bin_op_expr.op1, lvalue); |
| 4590 | IrInstruction *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); | 5623 | IrInstSrc *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); |
| 4591 | if (op2 == irb->codegen->invalid_instruction) | 5624 | if (op2 == irb->codegen->invalid_inst_src) |
| 4592 | return op2; | 5625 | return op2; |
| 4593 | IrInstruction *result = ir_build_bin_op(irb, scope, node, op_id, op1, op2, true); | 5626 | IrInstSrc *result = ir_build_bin_op(irb, scope, node, op_id, op1, op2, true); |
| 4594 | ir_build_store_ptr(irb, scope, node, lvalue, result); | 5627 | ir_build_store_ptr(irb, scope, node, lvalue, result); |
| 4595 | return ir_build_const_void(irb, scope, node); | 5628 | return ir_build_const_void(irb, scope, node); |
| 4596 | } | 5629 | } |
| 4597 | | 5630 | |
| 4598 | static IrInstruction *ir_gen_bool_or(IrBuilder *irb, Scope *scope, AstNode *node) { | 5631 | static IrInstSrc *ir_gen_bool_or(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4599 | assert(node->type == NodeTypeBinOpExpr); | 5632 | assert(node->type == NodeTypeBinOpExpr); |
| 4600 | | 5633 | |
| 4601 | IrInstruction *val1 = ir_gen_node(irb, node->data.bin_op_expr.op1, scope); | 5634 | IrInstSrc *val1 = ir_gen_node(irb, node->data.bin_op_expr.op1, scope); |
| 4602 | if (val1 == irb->codegen->invalid_instruction) | 5635 | if (val1 == irb->codegen->invalid_inst_src) |
| 4603 | return irb->codegen->invalid_instruction; | 5636 | return irb->codegen->invalid_inst_src; |
| 4604 | IrBasicBlock *post_val1_block = irb->current_basic_block; | 5637 | IrBasicBlockSrc *post_val1_block = irb->current_basic_block; |
| 4605 | | 5638 | |
| 4606 | IrInstruction *is_comptime; | 5639 | IrInstSrc *is_comptime; |
| 4607 | if (ir_should_inline(irb->exec, scope)) { | 5640 | if (ir_should_inline(irb->exec, scope)) { |
| 4608 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 5641 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 4609 | } else { | 5642 | } else { |
| ... | @@ -4611,41 +5644,41 @@ static IrInstruction *ir_gen_bool_or(IrBuilder *irb, Scope *scope, AstNode *node | ... | @@ -4611,41 +5644,41 @@ static IrInstruction *ir_gen_bool_or(IrBuilder *irb, Scope *scope, AstNode *node |
| 4611 | } | 5644 | } |
| 4612 | | 5645 | |
| 4613 | // block for when val1 == false | 5646 | // block for when val1 == false |
| 4614 | IrBasicBlock *false_block = ir_create_basic_block(irb, scope, "BoolOrFalse"); | 5647 | IrBasicBlockSrc *false_block = ir_create_basic_block(irb, scope, "BoolOrFalse"); |
| 4615 | // block for when val1 == true (don't even evaluate the second part) | 5648 | // block for when val1 == true (don't even evaluate the second part) |
| 4616 | IrBasicBlock *true_block = ir_create_basic_block(irb, scope, "BoolOrTrue"); | 5649 | IrBasicBlockSrc *true_block = ir_create_basic_block(irb, scope, "BoolOrTrue"); |
| 4617 | | 5650 | |
| 4618 | ir_build_cond_br(irb, scope, node, val1, true_block, false_block, is_comptime); | 5651 | ir_build_cond_br(irb, scope, node, val1, true_block, false_block, is_comptime); |
| 4619 | | 5652 | |
| 4620 | ir_set_cursor_at_end_and_append_block(irb, false_block); | 5653 | ir_set_cursor_at_end_and_append_block(irb, false_block); |
| 4621 | IrInstruction *val2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); | 5654 | IrInstSrc *val2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); |
| 4622 | if (val2 == irb->codegen->invalid_instruction) | 5655 | if (val2 == irb->codegen->invalid_inst_src) |
| 4623 | return irb->codegen->invalid_instruction; | 5656 | return irb->codegen->invalid_inst_src; |
| 4624 | IrBasicBlock *post_val2_block = irb->current_basic_block; | 5657 | IrBasicBlockSrc *post_val2_block = irb->current_basic_block; |
| 4625 | | 5658 | |
| 4626 | ir_build_br(irb, scope, node, true_block, is_comptime); | 5659 | ir_build_br(irb, scope, node, true_block, is_comptime); |
| 4627 | | 5660 | |
| 4628 | ir_set_cursor_at_end_and_append_block(irb, true_block); | 5661 | ir_set_cursor_at_end_and_append_block(irb, true_block); |
| 4629 | | 5662 | |
| 4630 | IrInstruction **incoming_values = allocate<IrInstruction *>(2, "IrInstruction *"); | 5663 | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2, "IrInstSrc *"); |
| 4631 | incoming_values[0] = val1; | 5664 | incoming_values[0] = val1; |
| 4632 | incoming_values[1] = val2; | 5665 | incoming_values[1] = val2; |
| 4633 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); | 5666 | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 4634 | incoming_blocks[0] = post_val1_block; | 5667 | incoming_blocks[0] = post_val1_block; |
| 4635 | incoming_blocks[1] = post_val2_block; | 5668 | incoming_blocks[1] = post_val2_block; |
| 4636 | | 5669 | |
| 4637 | return ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, nullptr); | 5670 | return ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, nullptr); |
| 4638 | } | 5671 | } |
| 4639 | | 5672 | |
| 4640 | static IrInstruction *ir_gen_bool_and(IrBuilder *irb, Scope *scope, AstNode *node) { | 5673 | static IrInstSrc *ir_gen_bool_and(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4641 | assert(node->type == NodeTypeBinOpExpr); | 5674 | assert(node->type == NodeTypeBinOpExpr); |
| 4642 | | 5675 | |
| 4643 | IrInstruction *val1 = ir_gen_node(irb, node->data.bin_op_expr.op1, scope); | 5676 | IrInstSrc *val1 = ir_gen_node(irb, node->data.bin_op_expr.op1, scope); |
| 4644 | if (val1 == irb->codegen->invalid_instruction) | 5677 | if (val1 == irb->codegen->invalid_inst_src) |
| 4645 | return irb->codegen->invalid_instruction; | 5678 | return irb->codegen->invalid_inst_src; |
| 4646 | IrBasicBlock *post_val1_block = irb->current_basic_block; | 5679 | IrBasicBlockSrc *post_val1_block = irb->current_basic_block; |
| 4647 | | 5680 | |
| 4648 | IrInstruction *is_comptime; | 5681 | IrInstSrc *is_comptime; |
| 4649 | if (ir_should_inline(irb->exec, scope)) { | 5682 | if (ir_should_inline(irb->exec, scope)) { |
| 4650 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 5683 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 4651 | } else { | 5684 | } else { |
| ... | @@ -4653,34 +5686,34 @@ static IrInstruction *ir_gen_bool_and(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -4653,34 +5686,34 @@ static IrInstruction *ir_gen_bool_and(IrBuilder *irb, Scope *scope, AstNode *nod |
| 4653 | } | 5686 | } |
| 4654 | | 5687 | |
| 4655 | // block for when val1 == true | 5688 | // block for when val1 == true |
| 4656 | IrBasicBlock *true_block = ir_create_basic_block(irb, scope, "BoolAndTrue"); | 5689 | IrBasicBlockSrc *true_block = ir_create_basic_block(irb, scope, "BoolAndTrue"); |
| 4657 | // block for when val1 == false (don't even evaluate the second part) | 5690 | // block for when val1 == false (don't even evaluate the second part) |
| 4658 | IrBasicBlock *false_block = ir_create_basic_block(irb, scope, "BoolAndFalse"); | 5691 | IrBasicBlockSrc *false_block = ir_create_basic_block(irb, scope, "BoolAndFalse"); |
| 4659 | | 5692 | |
| 4660 | ir_build_cond_br(irb, scope, node, val1, true_block, false_block, is_comptime); | 5693 | ir_build_cond_br(irb, scope, node, val1, true_block, false_block, is_comptime); |
| 4661 | | 5694 | |
| 4662 | ir_set_cursor_at_end_and_append_block(irb, true_block); | 5695 | ir_set_cursor_at_end_and_append_block(irb, true_block); |
| 4663 | IrInstruction *val2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); | 5696 | IrInstSrc *val2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); |
| 4664 | if (val2 == irb->codegen->invalid_instruction) | 5697 | if (val2 == irb->codegen->invalid_inst_src) |
| 4665 | return irb->codegen->invalid_instruction; | 5698 | return irb->codegen->invalid_inst_src; |
| 4666 | IrBasicBlock *post_val2_block = irb->current_basic_block; | 5699 | IrBasicBlockSrc *post_val2_block = irb->current_basic_block; |
| 4667 | | 5700 | |
| 4668 | ir_build_br(irb, scope, node, false_block, is_comptime); | 5701 | ir_build_br(irb, scope, node, false_block, is_comptime); |
| 4669 | | 5702 | |
| 4670 | ir_set_cursor_at_end_and_append_block(irb, false_block); | 5703 | ir_set_cursor_at_end_and_append_block(irb, false_block); |
| 4671 | | 5704 | |
| 4672 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 5705 | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 4673 | incoming_values[0] = val1; | 5706 | incoming_values[0] = val1; |
| 4674 | incoming_values[1] = val2; | 5707 | incoming_values[1] = val2; |
| 4675 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); | 5708 | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 4676 | incoming_blocks[0] = post_val1_block; | 5709 | incoming_blocks[0] = post_val1_block; |
| 4677 | incoming_blocks[1] = post_val2_block; | 5710 | incoming_blocks[1] = post_val2_block; |
| 4678 | | 5711 | |
| 4679 | return ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, nullptr); | 5712 | return ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, nullptr); |
| 4680 | } | 5713 | } |
| 4681 | | 5714 | |
| 4682 | static ResultLocPeerParent *ir_build_result_peers(IrBuilder *irb, IrInstruction *cond_br_inst, | 5715 | static ResultLocPeerParent *ir_build_result_peers(IrBuilderSrc *irb, IrInstSrc *cond_br_inst, |
| 4683 | IrBasicBlock *end_block, ResultLoc *parent, IrInstruction *is_comptime) | 5716 | IrBasicBlockSrc *end_block, ResultLoc *parent, IrInstSrc *is_comptime) |
| 4684 | { | 5717 | { |
| 4685 | ResultLocPeerParent *peer_parent = allocate<ResultLocPeerParent>(1); | 5718 | ResultLocPeerParent *peer_parent = allocate<ResultLocPeerParent>(1); |
| 4686 | peer_parent->base.id = ResultLocIdPeerParent; | 5719 | peer_parent->base.id = ResultLocIdPeerParent; |
| ... | @@ -4690,17 +5723,17 @@ static ResultLocPeerParent *ir_build_result_peers(IrBuilder *irb, IrInstruction | ... | @@ -4690,17 +5723,17 @@ static ResultLocPeerParent *ir_build_result_peers(IrBuilder *irb, IrInstruction |
| 4690 | peer_parent->is_comptime = is_comptime; | 5723 | peer_parent->is_comptime = is_comptime; |
| 4691 | peer_parent->parent = parent; | 5724 | peer_parent->parent = parent; |
| 4692 | | 5725 | |
| 4693 | IrInstruction *popped_inst = irb->current_basic_block->instruction_list.pop(); | 5726 | IrInstSrc *popped_inst = irb->current_basic_block->instruction_list.pop(); |
| 4694 | ir_assert(popped_inst == cond_br_inst, cond_br_inst); | 5727 | ir_assert(popped_inst == cond_br_inst, &cond_br_inst->base); |
| 4695 | | 5728 | |
| 4696 | ir_build_reset_result(irb, cond_br_inst->scope, cond_br_inst->source_node, &peer_parent->base); | 5729 | ir_build_reset_result(irb, cond_br_inst->base.scope, cond_br_inst->base.source_node, &peer_parent->base); |
| 4697 | irb->current_basic_block->instruction_list.append(popped_inst); | 5730 | irb->current_basic_block->instruction_list.append(popped_inst); |
| 4698 | | 5731 | |
| 4699 | return peer_parent; | 5732 | return peer_parent; |
| 4700 | } | 5733 | } |
| 4701 | | 5734 | |
| 4702 | static ResultLocPeerParent *ir_build_binary_result_peers(IrBuilder *irb, IrInstruction *cond_br_inst, | 5735 | static ResultLocPeerParent *ir_build_binary_result_peers(IrBuilderSrc *irb, IrInstSrc *cond_br_inst, |
| 4703 | IrBasicBlock *else_block, IrBasicBlock *end_block, ResultLoc *parent, IrInstruction *is_comptime) | 5736 | IrBasicBlockSrc *else_block, IrBasicBlockSrc *end_block, ResultLoc *parent, IrInstSrc *is_comptime) |
| 4704 | { | 5737 | { |
| 4705 | ResultLocPeerParent *peer_parent = ir_build_result_peers(irb, cond_br_inst, end_block, parent, is_comptime); | 5738 | ResultLocPeerParent *peer_parent = ir_build_result_peers(irb, cond_br_inst, end_block, parent, is_comptime); |
| 4706 | | 5739 | |
| ... | @@ -4713,7 +5746,7 @@ static ResultLocPeerParent *ir_build_binary_result_peers(IrBuilder *irb, IrInstr | ... | @@ -4713,7 +5746,7 @@ static ResultLocPeerParent *ir_build_binary_result_peers(IrBuilder *irb, IrInstr |
| 4713 | return peer_parent; | 5746 | return peer_parent; |
| 4714 | } | 5747 | } |
| 4715 | | 5748 | |
| 4716 | static IrInstruction *ir_gen_orelse(IrBuilder *irb, Scope *parent_scope, AstNode *node, LVal lval, | 5749 | static IrInstSrc *ir_gen_orelse(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node, LVal lval, |
| 4717 | ResultLoc *result_loc) | 5750 | ResultLoc *result_loc) |
| 4718 | { | 5751 | { |
| 4719 | assert(node->type == NodeTypeBinOpExpr); | 5752 | assert(node->type == NodeTypeBinOpExpr); |
| ... | @@ -4721,73 +5754,73 @@ static IrInstruction *ir_gen_orelse(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -4721,73 +5754,73 @@ static IrInstruction *ir_gen_orelse(IrBuilder *irb, Scope *parent_scope, AstNode |
| 4721 | AstNode *op1_node = node->data.bin_op_expr.op1; | 5754 | AstNode *op1_node = node->data.bin_op_expr.op1; |
| 4722 | AstNode *op2_node = node->data.bin_op_expr.op2; | 5755 | AstNode *op2_node = node->data.bin_op_expr.op2; |
| 4723 | | 5756 | |
| 4724 | IrInstruction *maybe_ptr = ir_gen_node_extra(irb, op1_node, parent_scope, LValPtr, nullptr); | 5757 | IrInstSrc *maybe_ptr = ir_gen_node_extra(irb, op1_node, parent_scope, LValPtr, nullptr); |
| 4725 | if (maybe_ptr == irb->codegen->invalid_instruction) | 5758 | if (maybe_ptr == irb->codegen->invalid_inst_src) |
| 4726 | return irb->codegen->invalid_instruction; | 5759 | return irb->codegen->invalid_inst_src; |
| 4727 | | 5760 | |
| 4728 | IrInstruction *maybe_val = ir_build_load_ptr(irb, parent_scope, node, maybe_ptr); | 5761 | IrInstSrc *maybe_val = ir_build_load_ptr(irb, parent_scope, node, maybe_ptr); |
| 4729 | IrInstruction *is_non_null = ir_build_test_nonnull(irb, parent_scope, node, maybe_val); | 5762 | IrInstSrc *is_non_null = ir_build_test_non_null_src(irb, parent_scope, node, maybe_val); |
| 4730 | | 5763 | |
| 4731 | IrInstruction *is_comptime; | 5764 | IrInstSrc *is_comptime; |
| 4732 | if (ir_should_inline(irb->exec, parent_scope)) { | 5765 | if (ir_should_inline(irb->exec, parent_scope)) { |
| 4733 | is_comptime = ir_build_const_bool(irb, parent_scope, node, true); | 5766 | is_comptime = ir_build_const_bool(irb, parent_scope, node, true); |
| 4734 | } else { | 5767 | } else { |
| 4735 | is_comptime = ir_build_test_comptime(irb, parent_scope, node, is_non_null); | 5768 | is_comptime = ir_build_test_comptime(irb, parent_scope, node, is_non_null); |
| 4736 | } | 5769 | } |
| 4737 | | 5770 | |
| 4738 | IrBasicBlock *ok_block = ir_create_basic_block(irb, parent_scope, "OptionalNonNull"); | 5771 | IrBasicBlockSrc *ok_block = ir_create_basic_block(irb, parent_scope, "OptionalNonNull"); |
| 4739 | IrBasicBlock *null_block = ir_create_basic_block(irb, parent_scope, "OptionalNull"); | 5772 | IrBasicBlockSrc *null_block = ir_create_basic_block(irb, parent_scope, "OptionalNull"); |
| 4740 | IrBasicBlock *end_block = ir_create_basic_block(irb, parent_scope, "OptionalEnd"); | 5773 | IrBasicBlockSrc *end_block = ir_create_basic_block(irb, parent_scope, "OptionalEnd"); |
| 4741 | IrInstruction *cond_br_inst = ir_build_cond_br(irb, parent_scope, node, is_non_null, ok_block, null_block, is_comptime); | 5774 | IrInstSrc *cond_br_inst = ir_build_cond_br(irb, parent_scope, node, is_non_null, ok_block, null_block, is_comptime); |
| 4742 | | 5775 | |
| 4743 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, ok_block, end_block, | 5776 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, ok_block, end_block, |
| 4744 | result_loc, is_comptime); | 5777 | result_loc, is_comptime); |
| 4745 | | 5778 | |
| 4746 | ir_set_cursor_at_end_and_append_block(irb, null_block); | 5779 | ir_set_cursor_at_end_and_append_block(irb, null_block); |
| 4747 | IrInstruction *null_result = ir_gen_node_extra(irb, op2_node, parent_scope, LValNone, | 5780 | IrInstSrc *null_result = ir_gen_node_extra(irb, op2_node, parent_scope, LValNone, |
| 4748 | &peer_parent->peers.at(0)->base); | 5781 | &peer_parent->peers.at(0)->base); |
| 4749 | if (null_result == irb->codegen->invalid_instruction) | 5782 | if (null_result == irb->codegen->invalid_inst_src) |
| 4750 | return irb->codegen->invalid_instruction; | 5783 | return irb->codegen->invalid_inst_src; |
| 4751 | IrBasicBlock *after_null_block = irb->current_basic_block; | 5784 | IrBasicBlockSrc *after_null_block = irb->current_basic_block; |
| 4752 | if (!instr_is_unreachable(null_result)) | 5785 | if (!instr_is_unreachable(null_result)) |
| 4753 | ir_mark_gen(ir_build_br(irb, parent_scope, node, end_block, is_comptime)); | 5786 | ir_mark_gen(ir_build_br(irb, parent_scope, node, end_block, is_comptime)); |
| 4754 | | 5787 | |
| 4755 | ir_set_cursor_at_end_and_append_block(irb, ok_block); | 5788 | ir_set_cursor_at_end_and_append_block(irb, ok_block); |
| 4756 | IrInstruction *unwrapped_ptr = ir_build_optional_unwrap_ptr(irb, parent_scope, node, maybe_ptr, false, false); | 5789 | IrInstSrc *unwrapped_ptr = ir_build_optional_unwrap_ptr(irb, parent_scope, node, maybe_ptr, false, false); |
| 4757 | IrInstruction *unwrapped_payload = ir_build_load_ptr(irb, parent_scope, node, unwrapped_ptr); | 5790 | IrInstSrc *unwrapped_payload = ir_build_load_ptr(irb, parent_scope, node, unwrapped_ptr); |
| 4758 | ir_build_end_expr(irb, parent_scope, node, unwrapped_payload, &peer_parent->peers.at(1)->base); | 5791 | ir_build_end_expr(irb, parent_scope, node, unwrapped_payload, &peer_parent->peers.at(1)->base); |
| 4759 | IrBasicBlock *after_ok_block = irb->current_basic_block; | 5792 | IrBasicBlockSrc *after_ok_block = irb->current_basic_block; |
| 4760 | ir_build_br(irb, parent_scope, node, end_block, is_comptime); | 5793 | ir_build_br(irb, parent_scope, node, end_block, is_comptime); |
| 4761 | | 5794 | |
| 4762 | ir_set_cursor_at_end_and_append_block(irb, end_block); | 5795 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 4763 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 5796 | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 4764 | incoming_values[0] = null_result; | 5797 | incoming_values[0] = null_result; |
| 4765 | incoming_values[1] = unwrapped_payload; | 5798 | incoming_values[1] = unwrapped_payload; |
| 4766 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); | 5799 | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 4767 | incoming_blocks[0] = after_null_block; | 5800 | incoming_blocks[0] = after_null_block; |
| 4768 | incoming_blocks[1] = after_ok_block; | 5801 | incoming_blocks[1] = after_ok_block; |
| 4769 | IrInstruction *phi = ir_build_phi(irb, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); | 5802 | IrInstSrc *phi = ir_build_phi(irb, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); |
| 4770 | return ir_lval_wrap(irb, parent_scope, phi, lval, result_loc); | 5803 | return ir_lval_wrap(irb, parent_scope, phi, lval, result_loc); |
| 4771 | } | 5804 | } |
| 4772 | | 5805 | |
| 4773 | static IrInstruction *ir_gen_error_union(IrBuilder *irb, Scope *parent_scope, AstNode *node) { | 5806 | static IrInstSrc *ir_gen_error_union(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node) { |
| 4774 | assert(node->type == NodeTypeBinOpExpr); | 5807 | assert(node->type == NodeTypeBinOpExpr); |
| 4775 | | 5808 | |
| 4776 | AstNode *op1_node = node->data.bin_op_expr.op1; | 5809 | AstNode *op1_node = node->data.bin_op_expr.op1; |
| 4777 | AstNode *op2_node = node->data.bin_op_expr.op2; | 5810 | AstNode *op2_node = node->data.bin_op_expr.op2; |
| 4778 | | 5811 | |
| 4779 | IrInstruction *err_set = ir_gen_node(irb, op1_node, parent_scope); | 5812 | IrInstSrc *err_set = ir_gen_node(irb, op1_node, parent_scope); |
| 4780 | if (err_set == irb->codegen->invalid_instruction) | 5813 | if (err_set == irb->codegen->invalid_inst_src) |
| 4781 | return irb->codegen->invalid_instruction; | 5814 | return irb->codegen->invalid_inst_src; |
| 4782 | | 5815 | |
| 4783 | IrInstruction *payload = ir_gen_node(irb, op2_node, parent_scope); | 5816 | IrInstSrc *payload = ir_gen_node(irb, op2_node, parent_scope); |
| 4784 | if (payload == irb->codegen->invalid_instruction) | 5817 | if (payload == irb->codegen->invalid_inst_src) |
| 4785 | return irb->codegen->invalid_instruction; | 5818 | return irb->codegen->invalid_inst_src; |
| 4786 | | 5819 | |
| 4787 | return ir_build_error_union(irb, parent_scope, node, err_set, payload); | 5820 | return ir_build_error_union(irb, parent_scope, node, err_set, payload); |
| 4788 | } | 5821 | } |
| 4789 | | 5822 | |
| 4790 | static IrInstruction *ir_gen_bin_op(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { | 5823 | static IrInstSrc *ir_gen_bin_op(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { |
| 4791 | assert(node->type == NodeTypeBinOpExpr); | 5824 | assert(node->type == NodeTypeBinOpExpr); |
| 4792 | | 5825 | |
| 4793 | BinOpType bin_op_type = node->data.bin_op_expr.bin_op; | 5826 | BinOpType bin_op_type = node->data.bin_op_expr.bin_op; |
| ... | @@ -4880,30 +5913,30 @@ static IrInstruction *ir_gen_bin_op(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4880,30 +5913,30 @@ static IrInstruction *ir_gen_bin_op(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4880 | zig_unreachable(); | 5913 | zig_unreachable(); |
| 4881 | } | 5914 | } |
| 4882 | | 5915 | |
| 4883 | static IrInstruction *ir_gen_int_lit(IrBuilder *irb, Scope *scope, AstNode *node) { | 5916 | static IrInstSrc *ir_gen_int_lit(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4884 | assert(node->type == NodeTypeIntLiteral); | 5917 | assert(node->type == NodeTypeIntLiteral); |
| 4885 | | 5918 | |
| 4886 | return ir_build_const_bigint(irb, scope, node, node->data.int_literal.bigint); | 5919 | return ir_build_const_bigint(irb, scope, node, node->data.int_literal.bigint); |
| 4887 | } | 5920 | } |
| 4888 | | 5921 | |
| 4889 | static IrInstruction *ir_gen_float_lit(IrBuilder *irb, Scope *scope, AstNode *node) { | 5922 | static IrInstSrc *ir_gen_float_lit(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4890 | assert(node->type == NodeTypeFloatLiteral); | 5923 | assert(node->type == NodeTypeFloatLiteral); |
| 4891 | | 5924 | |
| 4892 | if (node->data.float_literal.overflow) { | 5925 | if (node->data.float_literal.overflow) { |
| 4893 | add_node_error(irb->codegen, node, buf_sprintf("float literal out of range of any type")); | 5926 | add_node_error(irb->codegen, node, buf_sprintf("float literal out of range of any type")); |
| 4894 | return irb->codegen->invalid_instruction; | 5927 | return irb->codegen->invalid_inst_src; |
| 4895 | } | 5928 | } |
| 4896 | | 5929 | |
| 4897 | return ir_build_const_bigfloat(irb, scope, node, node->data.float_literal.bigfloat); | 5930 | return ir_build_const_bigfloat(irb, scope, node, node->data.float_literal.bigfloat); |
| 4898 | } | 5931 | } |
| 4899 | | 5932 | |
| 4900 | static IrInstruction *ir_gen_char_lit(IrBuilder *irb, Scope *scope, AstNode *node) { | 5933 | static IrInstSrc *ir_gen_char_lit(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4901 | assert(node->type == NodeTypeCharLiteral); | 5934 | assert(node->type == NodeTypeCharLiteral); |
| 4902 | | 5935 | |
| 4903 | return ir_build_const_uint(irb, scope, node, node->data.char_literal.value); | 5936 | return ir_build_const_uint(irb, scope, node, node->data.char_literal.value); |
| 4904 | } | 5937 | } |
| 4905 | | 5938 | |
| 4906 | static IrInstruction *ir_gen_null_literal(IrBuilder *irb, Scope *scope, AstNode *node) { | 5939 | static IrInstSrc *ir_gen_null_literal(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 4907 | assert(node->type == NodeTypeNullLiteral); | 5940 | assert(node->type == NodeTypeNullLiteral); |
| 4908 | | 5941 | |
| 4909 | return ir_build_const_null(irb, scope, node); | 5942 | return ir_build_const_null(irb, scope, node); |
| ... | @@ -4921,11 +5954,11 @@ static void populate_invalid_variable_in_scope(CodeGen *g, Scope *scope, AstNode | ... | @@ -4921,11 +5954,11 @@ static void populate_invalid_variable_in_scope(CodeGen *g, Scope *scope, AstNode |
| 4921 | init_tld(&tld_var->base, TldIdVar, var_name, VisibModPub, node, &scope_decls->base); | 5954 | init_tld(&tld_var->base, TldIdVar, var_name, VisibModPub, node, &scope_decls->base); |
| 4922 | tld_var->base.resolution = TldResolutionInvalid; | 5955 | tld_var->base.resolution = TldResolutionInvalid; |
| 4923 | tld_var->var = add_variable(g, node, &scope_decls->base, var_name, false, | 5956 | tld_var->var = add_variable(g, node, &scope_decls->base, var_name, false, |
| 4924 | g->invalid_instruction->value, &tld_var->base, g->builtin_types.entry_invalid); | 5957 | g->invalid_inst_gen->value, &tld_var->base, g->builtin_types.entry_invalid); |
| 4925 | scope_decls->decl_table.put(var_name, &tld_var->base); | 5958 | scope_decls->decl_table.put(var_name, &tld_var->base); |
| 4926 | } | 5959 | } |
| 4927 | | 5960 | |
| 4928 | static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { | 5961 | static IrInstSrc *ir_gen_symbol(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { |
| 4929 | Error err; | 5962 | Error err; |
| 4930 | assert(node->type == NodeTypeSymbol); | 5963 | assert(node->type == NodeTypeSymbol); |
| 4931 | | 5964 | |
| ... | @@ -4933,15 +5966,16 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4933,15 +5966,16 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4933 | | 5966 | |
| 4934 | if (buf_eql_str(variable_name, "_")) { | 5967 | if (buf_eql_str(variable_name, "_")) { |
| 4935 | if (lval == LValPtr) { | 5968 | if (lval == LValPtr) { |
| 4936 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, node); | 5969 | IrInstSrcConst *const_instruction = ir_build_instruction<IrInstSrcConst>(irb, scope, node); |
| 4937 | const_instruction->base.value->type = get_pointer_to_type(irb->codegen, | 5970 | const_instruction->value = create_const_vals(1); |
| | 5971 | const_instruction->value->type = get_pointer_to_type(irb->codegen, |
| 4938 | irb->codegen->builtin_types.entry_void, false); | 5972 | irb->codegen->builtin_types.entry_void, false); |
| 4939 | const_instruction->base.value->special = ConstValSpecialStatic; | 5973 | const_instruction->value->special = ConstValSpecialStatic; |
| 4940 | const_instruction->base.value->data.x_ptr.special = ConstPtrSpecialDiscard; | 5974 | const_instruction->value->data.x_ptr.special = ConstPtrSpecialDiscard; |
| 4941 | return &const_instruction->base; | 5975 | return &const_instruction->base; |
| 4942 | } else { | 5976 | } else { |
| 4943 | add_node_error(irb->codegen, node, buf_sprintf("`_` may only be used to assign things to")); | 5977 | add_node_error(irb->codegen, node, buf_sprintf("`_` may only be used to assign things to")); |
| 4944 | return irb->codegen->invalid_instruction; | 5978 | return irb->codegen->invalid_inst_src; |
| 4945 | } | 5979 | } |
| 4946 | } | 5980 | } |
| 4947 | | 5981 | |
| ... | @@ -4951,13 +5985,13 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4951,13 +5985,13 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4951 | add_node_error(irb->codegen, node, | 5985 | add_node_error(irb->codegen, node, |
| 4952 | buf_sprintf("primitive integer type '%s' exceeds maximum bit width of 65535", | 5986 | buf_sprintf("primitive integer type '%s' exceeds maximum bit width of 65535", |
| 4953 | buf_ptr(variable_name))); | 5987 | buf_ptr(variable_name))); |
| 4954 | return irb->codegen->invalid_instruction; | 5988 | return irb->codegen->invalid_inst_src; |
| 4955 | } | 5989 | } |
| 4956 | assert(err == ErrorPrimitiveTypeNotFound); | 5990 | assert(err == ErrorPrimitiveTypeNotFound); |
| 4957 | } else { | 5991 | } else { |
| 4958 | IrInstruction *value = ir_build_const_type(irb, scope, node, primitive_type); | 5992 | IrInstSrc *value = ir_build_const_type(irb, scope, node, primitive_type); |
| 4959 | if (lval == LValPtr) { | 5993 | if (lval == LValPtr) { |
| 4960 | return ir_build_ref(irb, scope, node, value, false, false); | 5994 | return ir_build_ref_src(irb, scope, node, value, false, false); |
| 4961 | } else { | 5995 | } else { |
| 4962 | return ir_expr_wrap(irb, scope, value, result_loc); | 5996 | return ir_expr_wrap(irb, scope, value, result_loc); |
| 4963 | } | 5997 | } |
| ... | @@ -4966,7 +6000,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4966,7 +6000,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4966 | ScopeFnDef *crossed_fndef_scope; | 6000 | ScopeFnDef *crossed_fndef_scope; |
| 4967 | ZigVar *var = find_variable(irb->codegen, scope, variable_name, &crossed_fndef_scope); | 6001 | ZigVar *var = find_variable(irb->codegen, scope, variable_name, &crossed_fndef_scope); |
| 4968 | if (var) { | 6002 | if (var) { |
| 4969 | IrInstruction *var_ptr = ir_build_var_ptr_x(irb, scope, node, var, crossed_fndef_scope); | 6003 | IrInstSrc *var_ptr = ir_build_var_ptr_x(irb, scope, node, var, crossed_fndef_scope); |
| 4970 | if (lval == LValPtr) { | 6004 | if (lval == LValPtr) { |
| 4971 | return var_ptr; | 6005 | return var_ptr; |
| 4972 | } else { | 6006 | } else { |
| ... | @@ -4976,7 +6010,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4976,7 +6010,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4976 | | 6010 | |
| 4977 | Tld *tld = find_decl(irb->codegen, scope, variable_name); | 6011 | Tld *tld = find_decl(irb->codegen, scope, variable_name); |
| 4978 | if (tld) { | 6012 | if (tld) { |
| 4979 | IrInstruction *decl_ref = ir_build_decl_ref(irb, scope, node, tld, lval); | 6013 | IrInstSrc *decl_ref = ir_build_decl_ref(irb, scope, node, tld, lval); |
| 4980 | if (lval == LValPtr) { | 6014 | if (lval == LValPtr) { |
| 4981 | return decl_ref; | 6015 | return decl_ref; |
| 4982 | } else { | 6016 | } else { |
| ... | @@ -4987,50 +6021,50 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -4987,50 +6021,50 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node, |
| 4987 | if (get_container_scope(node->owner)->any_imports_failed) { | 6021 | if (get_container_scope(node->owner)->any_imports_failed) { |
| 4988 | // skip the error message since we had a failing import in this file | 6022 | // skip the error message since we had a failing import in this file |
| 4989 | // if an import breaks we don't need redundant undeclared identifier errors | 6023 | // if an import breaks we don't need redundant undeclared identifier errors |
| 4990 | return irb->codegen->invalid_instruction; | 6024 | return irb->codegen->invalid_inst_src; |
| 4991 | } | 6025 | } |
| 4992 | | 6026 | |
| 4993 | return ir_build_undeclared_identifier(irb, scope, node, variable_name); | 6027 | return ir_build_undeclared_identifier(irb, scope, node, variable_name); |
| 4994 | } | 6028 | } |
| 4995 | | 6029 | |
| 4996 | static IrInstruction *ir_gen_array_access(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 6030 | static IrInstSrc *ir_gen_array_access(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 4997 | ResultLoc *result_loc) | 6031 | ResultLoc *result_loc) |
| 4998 | { | 6032 | { |
| 4999 | assert(node->type == NodeTypeArrayAccessExpr); | 6033 | assert(node->type == NodeTypeArrayAccessExpr); |
| 5000 | | 6034 | |
| 5001 | AstNode *array_ref_node = node->data.array_access_expr.array_ref_expr; | 6035 | AstNode *array_ref_node = node->data.array_access_expr.array_ref_expr; |
| 5002 | IrInstruction *array_ref_instruction = ir_gen_node_extra(irb, array_ref_node, scope, LValPtr, nullptr); | 6036 | IrInstSrc *array_ref_instruction = ir_gen_node_extra(irb, array_ref_node, scope, LValPtr, nullptr); |
| 5003 | if (array_ref_instruction == irb->codegen->invalid_instruction) | 6037 | if (array_ref_instruction == irb->codegen->invalid_inst_src) |
| 5004 | return array_ref_instruction; | 6038 | return array_ref_instruction; |
| 5005 | | 6039 | |
| 5006 | AstNode *subscript_node = node->data.array_access_expr.subscript; | 6040 | AstNode *subscript_node = node->data.array_access_expr.subscript; |
| 5007 | IrInstruction *subscript_instruction = ir_gen_node(irb, subscript_node, scope); | 6041 | IrInstSrc *subscript_instruction = ir_gen_node(irb, subscript_node, scope); |
| 5008 | if (subscript_instruction == irb->codegen->invalid_instruction) | 6042 | if (subscript_instruction == irb->codegen->invalid_inst_src) |
| 5009 | return subscript_instruction; | 6043 | return subscript_instruction; |
| 5010 | | 6044 | |
| 5011 | IrInstruction *ptr_instruction = ir_build_elem_ptr(irb, scope, node, array_ref_instruction, | 6045 | IrInstSrc *ptr_instruction = ir_build_elem_ptr(irb, scope, node, array_ref_instruction, |
| 5012 | subscript_instruction, true, PtrLenSingle, nullptr); | 6046 | subscript_instruction, true, PtrLenSingle, nullptr); |
| 5013 | if (lval == LValPtr) | 6047 | if (lval == LValPtr) |
| 5014 | return ptr_instruction; | 6048 | return ptr_instruction; |
| 5015 | | 6049 | |
| 5016 | IrInstruction *load_ptr = ir_build_load_ptr(irb, scope, node, ptr_instruction); | 6050 | IrInstSrc *load_ptr = ir_build_load_ptr(irb, scope, node, ptr_instruction); |
| 5017 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); | 6051 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); |
| 5018 | } | 6052 | } |
| 5019 | | 6053 | |
| 5020 | static IrInstruction *ir_gen_field_access(IrBuilder *irb, Scope *scope, AstNode *node) { | 6054 | static IrInstSrc *ir_gen_field_access(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 5021 | assert(node->type == NodeTypeFieldAccessExpr); | 6055 | assert(node->type == NodeTypeFieldAccessExpr); |
| 5022 | | 6056 | |
| 5023 | AstNode *container_ref_node = node->data.field_access_expr.struct_expr; | 6057 | AstNode *container_ref_node = node->data.field_access_expr.struct_expr; |
| 5024 | Buf *field_name = node->data.field_access_expr.field_name; | 6058 | Buf *field_name = node->data.field_access_expr.field_name; |
| 5025 | | 6059 | |
| 5026 | IrInstruction *container_ref_instruction = ir_gen_node_extra(irb, container_ref_node, scope, LValPtr, nullptr); | 6060 | IrInstSrc *container_ref_instruction = ir_gen_node_extra(irb, container_ref_node, scope, LValPtr, nullptr); |
| 5027 | if (container_ref_instruction == irb->codegen->invalid_instruction) | 6061 | if (container_ref_instruction == irb->codegen->invalid_inst_src) |
| 5028 | return container_ref_instruction; | 6062 | return container_ref_instruction; |
| 5029 | | 6063 | |
| 5030 | return ir_build_field_ptr(irb, scope, node, container_ref_instruction, field_name, false); | 6064 | return ir_build_field_ptr(irb, scope, node, container_ref_instruction, field_name, false); |
| 5031 | } | 6065 | } |
| 5032 | | 6066 | |
| 5033 | static IrInstruction *ir_gen_overflow_op(IrBuilder *irb, Scope *scope, AstNode *node, IrOverflowOp op) { | 6067 | static IrInstSrc *ir_gen_overflow_op(IrBuilderSrc *irb, Scope *scope, AstNode *node, IrOverflowOp op) { |
| 5034 | assert(node->type == NodeTypeFnCallExpr); | 6068 | assert(node->type == NodeTypeFnCallExpr); |
| 5035 | | 6069 | |
| 5036 | AstNode *type_node = node->data.fn_call_expr.params.at(0); | 6070 | AstNode *type_node = node->data.fn_call_expr.params.at(0); |
| ... | @@ -5039,26 +6073,26 @@ static IrInstruction *ir_gen_overflow_op(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -5039,26 +6073,26 @@ static IrInstruction *ir_gen_overflow_op(IrBuilder *irb, Scope *scope, AstNode * |
| 5039 | AstNode *result_ptr_node = node->data.fn_call_expr.params.at(3); | 6073 | AstNode *result_ptr_node = node->data.fn_call_expr.params.at(3); |
| 5040 | | 6074 | |
| 5041 | | 6075 | |
| 5042 | IrInstruction *type_value = ir_gen_node(irb, type_node, scope); | 6076 | IrInstSrc *type_value = ir_gen_node(irb, type_node, scope); |
| 5043 | if (type_value == irb->codegen->invalid_instruction) | 6077 | if (type_value == irb->codegen->invalid_inst_src) |
| 5044 | return irb->codegen->invalid_instruction; | 6078 | return irb->codegen->invalid_inst_src; |
| 5045 | | 6079 | |
| 5046 | IrInstruction *op1 = ir_gen_node(irb, op1_node, scope); | 6080 | IrInstSrc *op1 = ir_gen_node(irb, op1_node, scope); |
| 5047 | if (op1 == irb->codegen->invalid_instruction) | 6081 | if (op1 == irb->codegen->invalid_inst_src) |
| 5048 | return irb->codegen->invalid_instruction; | 6082 | return irb->codegen->invalid_inst_src; |
| 5049 | | 6083 | |
| 5050 | IrInstruction *op2 = ir_gen_node(irb, op2_node, scope); | 6084 | IrInstSrc *op2 = ir_gen_node(irb, op2_node, scope); |
| 5051 | if (op2 == irb->codegen->invalid_instruction) | 6085 | if (op2 == irb->codegen->invalid_inst_src) |
| 5052 | return irb->codegen->invalid_instruction; | 6086 | return irb->codegen->invalid_inst_src; |
| 5053 | | 6087 | |
| 5054 | IrInstruction *result_ptr = ir_gen_node(irb, result_ptr_node, scope); | 6088 | IrInstSrc *result_ptr = ir_gen_node(irb, result_ptr_node, scope); |
| 5055 | if (result_ptr == irb->codegen->invalid_instruction) | 6089 | if (result_ptr == irb->codegen->invalid_inst_src) |
| 5056 | return irb->codegen->invalid_instruction; | 6090 | return irb->codegen->invalid_inst_src; |
| 5057 | | 6091 | |
| 5058 | return ir_build_overflow_op(irb, scope, node, op, type_value, op1, op2, result_ptr, nullptr); | 6092 | return ir_build_overflow_op_src(irb, scope, node, op, type_value, op1, op2, result_ptr); |
| 5059 | } | 6093 | } |
| 5060 | | 6094 | |
| 5061 | static IrInstruction *ir_gen_mul_add(IrBuilder *irb, Scope *scope, AstNode *node) { | 6095 | static IrInstSrc *ir_gen_mul_add(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 5062 | assert(node->type == NodeTypeFnCallExpr); | 6096 | assert(node->type == NodeTypeFnCallExpr); |
| 5063 | | 6097 | |
| 5064 | AstNode *type_node = node->data.fn_call_expr.params.at(0); | 6098 | AstNode *type_node = node->data.fn_call_expr.params.at(0); |
| ... | @@ -5066,26 +6100,26 @@ static IrInstruction *ir_gen_mul_add(IrBuilder *irb, Scope *scope, AstNode *node | ... | @@ -5066,26 +6100,26 @@ static IrInstruction *ir_gen_mul_add(IrBuilder *irb, Scope *scope, AstNode *node |
| 5066 | AstNode *op2_node = node->data.fn_call_expr.params.at(2); | 6100 | AstNode *op2_node = node->data.fn_call_expr.params.at(2); |
| 5067 | AstNode *op3_node = node->data.fn_call_expr.params.at(3); | 6101 | AstNode *op3_node = node->data.fn_call_expr.params.at(3); |
| 5068 | | 6102 | |
| 5069 | IrInstruction *type_value = ir_gen_node(irb, type_node, scope); | 6103 | IrInstSrc *type_value = ir_gen_node(irb, type_node, scope); |
| 5070 | if (type_value == irb->codegen->invalid_instruction) | 6104 | if (type_value == irb->codegen->invalid_inst_src) |
| 5071 | return irb->codegen->invalid_instruction; | 6105 | return irb->codegen->invalid_inst_src; |
| 5072 | | 6106 | |
| 5073 | IrInstruction *op1 = ir_gen_node(irb, op1_node, scope); | 6107 | IrInstSrc *op1 = ir_gen_node(irb, op1_node, scope); |
| 5074 | if (op1 == irb->codegen->invalid_instruction) | 6108 | if (op1 == irb->codegen->invalid_inst_src) |
| 5075 | return irb->codegen->invalid_instruction; | 6109 | return irb->codegen->invalid_inst_src; |
| 5076 | | 6110 | |
| 5077 | IrInstruction *op2 = ir_gen_node(irb, op2_node, scope); | 6111 | IrInstSrc *op2 = ir_gen_node(irb, op2_node, scope); |
| 5078 | if (op2 == irb->codegen->invalid_instruction) | 6112 | if (op2 == irb->codegen->invalid_inst_src) |
| 5079 | return irb->codegen->invalid_instruction; | 6113 | return irb->codegen->invalid_inst_src; |
| 5080 | | 6114 | |
| 5081 | IrInstruction *op3 = ir_gen_node(irb, op3_node, scope); | 6115 | IrInstSrc *op3 = ir_gen_node(irb, op3_node, scope); |
| 5082 | if (op3 == irb->codegen->invalid_instruction) | 6116 | if (op3 == irb->codegen->invalid_inst_src) |
| 5083 | return irb->codegen->invalid_instruction; | 6117 | return irb->codegen->invalid_inst_src; |
| 5084 | | 6118 | |
| 5085 | return ir_build_mul_add(irb, scope, node, type_value, op1, op2, op3); | 6119 | return ir_build_mul_add_src(irb, scope, node, type_value, op1, op2, op3); |
| 5086 | } | 6120 | } |
| 5087 | | 6121 | |
| 5088 | static IrInstruction *ir_gen_this(IrBuilder *irb, Scope *orig_scope, AstNode *node) { | 6122 | static IrInstSrc *ir_gen_this(IrBuilderSrc *irb, Scope *orig_scope, AstNode *node) { |
| 5089 | for (Scope *it_scope = orig_scope; it_scope != nullptr; it_scope = it_scope->parent) { | 6123 | for (Scope *it_scope = orig_scope; it_scope != nullptr; it_scope = it_scope->parent) { |
| 5090 | if (it_scope->id == ScopeIdDecls) { | 6124 | if (it_scope->id == ScopeIdDecls) { |
| 5091 | ScopeDecls *decls_scope = (ScopeDecls *)it_scope; | 6125 | ScopeDecls *decls_scope = (ScopeDecls *)it_scope; |
| ... | @@ -5100,7 +6134,7 @@ static IrInstruction *ir_gen_this(IrBuilder *irb, Scope *orig_scope, AstNode *no | ... | @@ -5100,7 +6134,7 @@ static IrInstruction *ir_gen_this(IrBuilder *irb, Scope *orig_scope, AstNode *no |
| 5100 | zig_unreachable(); | 6134 | zig_unreachable(); |
| 5101 | } | 6135 | } |
| 5102 | | 6136 | |
| 5103 | static IrInstruction *ir_gen_async_call(IrBuilder *irb, Scope *scope, AstNode *await_node, AstNode *call_node, | 6137 | static IrInstSrc *ir_gen_async_call(IrBuilderSrc *irb, Scope *scope, AstNode *await_node, AstNode *call_node, |
| 5104 | LVal lval, ResultLoc *result_loc) | 6138 | LVal lval, ResultLoc *result_loc) |
| 5105 | { | 6139 | { |
| 5106 | size_t arg_offset = 3; | 6140 | size_t arg_offset = 3; |
| ... | @@ -5108,71 +6142,71 @@ static IrInstruction *ir_gen_async_call(IrBuilder *irb, Scope *scope, AstNode *a | ... | @@ -5108,71 +6142,71 @@ static IrInstruction *ir_gen_async_call(IrBuilder *irb, Scope *scope, AstNode *a |
| 5108 | add_node_error(irb->codegen, call_node, | 6142 | add_node_error(irb->codegen, call_node, |
| 5109 | buf_sprintf("expected at least %" ZIG_PRI_usize " arguments, found %" ZIG_PRI_usize, | 6143 | buf_sprintf("expected at least %" ZIG_PRI_usize " arguments, found %" ZIG_PRI_usize, |
| 5110 | arg_offset, call_node->data.fn_call_expr.params.length)); | 6144 | arg_offset, call_node->data.fn_call_expr.params.length)); |
| 5111 | return irb->codegen->invalid_instruction; | 6145 | return irb->codegen->invalid_inst_src; |
| 5112 | } | 6146 | } |
| 5113 | | 6147 | |
| 5114 | AstNode *bytes_node = call_node->data.fn_call_expr.params.at(0); | 6148 | AstNode *bytes_node = call_node->data.fn_call_expr.params.at(0); |
| 5115 | IrInstruction *bytes = ir_gen_node(irb, bytes_node, scope); | 6149 | IrInstSrc *bytes = ir_gen_node(irb, bytes_node, scope); |
| 5116 | if (bytes == irb->codegen->invalid_instruction) | 6150 | if (bytes == irb->codegen->invalid_inst_src) |
| 5117 | return bytes; | 6151 | return bytes; |
| 5118 | | 6152 | |
| 5119 | AstNode *ret_ptr_node = call_node->data.fn_call_expr.params.at(1); | 6153 | AstNode *ret_ptr_node = call_node->data.fn_call_expr.params.at(1); |
| 5120 | IrInstruction *ret_ptr = ir_gen_node(irb, ret_ptr_node, scope); | 6154 | IrInstSrc *ret_ptr = ir_gen_node(irb, ret_ptr_node, scope); |
| 5121 | if (ret_ptr == irb->codegen->invalid_instruction) | 6155 | if (ret_ptr == irb->codegen->invalid_inst_src) |
| 5122 | return ret_ptr; | 6156 | return ret_ptr; |
| 5123 | | 6157 | |
| 5124 | AstNode *fn_ref_node = call_node->data.fn_call_expr.params.at(2); | 6158 | AstNode *fn_ref_node = call_node->data.fn_call_expr.params.at(2); |
| 5125 | IrInstruction *fn_ref = ir_gen_node(irb, fn_ref_node, scope); | 6159 | IrInstSrc *fn_ref = ir_gen_node(irb, fn_ref_node, scope); |
| 5126 | if (fn_ref == irb->codegen->invalid_instruction) | 6160 | if (fn_ref == irb->codegen->invalid_inst_src) |
| 5127 | return fn_ref; | 6161 | return fn_ref; |
| 5128 | | 6162 | |
| 5129 | size_t arg_count = call_node->data.fn_call_expr.params.length - arg_offset; | 6163 | size_t arg_count = call_node->data.fn_call_expr.params.length - arg_offset; |
| 5130 | IrInstruction **args = allocate<IrInstruction*>(arg_count); | 6164 | IrInstSrc **args = allocate<IrInstSrc*>(arg_count); |
| 5131 | for (size_t i = 0; i < arg_count; i += 1) { | 6165 | for (size_t i = 0; i < arg_count; i += 1) { |
| 5132 | AstNode *arg_node = call_node->data.fn_call_expr.params.at(i + arg_offset); | 6166 | AstNode *arg_node = call_node->data.fn_call_expr.params.at(i + arg_offset); |
| 5133 | IrInstruction *arg = ir_gen_node(irb, arg_node, scope); | 6167 | IrInstSrc *arg = ir_gen_node(irb, arg_node, scope); |
| 5134 | if (arg == irb->codegen->invalid_instruction) | 6168 | if (arg == irb->codegen->invalid_inst_src) |
| 5135 | return arg; | 6169 | return arg; |
| 5136 | args[i] = arg; | 6170 | args[i] = arg; |
| 5137 | } | 6171 | } |
| 5138 | | 6172 | |
| 5139 | CallModifier modifier = (await_node == nullptr) ? CallModifierAsync : CallModifierNone; | 6173 | CallModifier modifier = (await_node == nullptr) ? CallModifierAsync : CallModifierNone; |
| 5140 | bool is_async_call_builtin = true; | 6174 | bool is_async_call_builtin = true; |
| 5141 | IrInstruction *call = ir_build_call_src(irb, scope, call_node, nullptr, fn_ref, arg_count, args, | 6175 | IrInstSrc *call = ir_build_call_src(irb, scope, call_node, nullptr, fn_ref, arg_count, args, |
| 5142 | ret_ptr, modifier, is_async_call_builtin, bytes, result_loc); | 6176 | ret_ptr, modifier, is_async_call_builtin, bytes, result_loc); |
| 5143 | return ir_lval_wrap(irb, scope, call, lval, result_loc); | 6177 | return ir_lval_wrap(irb, scope, call, lval, result_loc); |
| 5144 | } | 6178 | } |
| 5145 | | 6179 | |
| 5146 | static IrInstruction *ir_gen_fn_call_with_args(IrBuilder *irb, Scope *scope, AstNode *source_node, | 6180 | static IrInstSrc *ir_gen_fn_call_with_args(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 5147 | AstNode *fn_ref_node, CallModifier modifier, IrInstruction *options, | 6181 | AstNode *fn_ref_node, CallModifier modifier, IrInstSrc *options, |
| 5148 | AstNode **args_ptr, size_t args_len, LVal lval, ResultLoc *result_loc) | 6182 | AstNode **args_ptr, size_t args_len, LVal lval, ResultLoc *result_loc) |
| 5149 | { | 6183 | { |
| 5150 | IrInstruction *fn_ref = ir_gen_node(irb, fn_ref_node, scope); | 6184 | IrInstSrc *fn_ref = ir_gen_node(irb, fn_ref_node, scope); |
| 5151 | if (fn_ref == irb->codegen->invalid_instruction) | 6185 | if (fn_ref == irb->codegen->invalid_inst_src) |
| 5152 | return fn_ref; | 6186 | return fn_ref; |
| 5153 | | 6187 | |
| 5154 | IrInstruction *fn_type = ir_build_typeof(irb, scope, source_node, fn_ref); | 6188 | IrInstSrc *fn_type = ir_build_typeof(irb, scope, source_node, fn_ref); |
| 5155 | | 6189 | |
| 5156 | IrInstruction **args = allocate<IrInstruction*>(args_len); | 6190 | IrInstSrc **args = allocate<IrInstSrc*>(args_len); |
| 5157 | for (size_t i = 0; i < args_len; i += 1) { | 6191 | for (size_t i = 0; i < args_len; i += 1) { |
| 5158 | AstNode *arg_node = args_ptr[i]; | 6192 | AstNode *arg_node = args_ptr[i]; |
| 5159 | | 6193 | |
| 5160 | IrInstruction *arg_index = ir_build_const_usize(irb, scope, arg_node, i); | 6194 | IrInstSrc *arg_index = ir_build_const_usize(irb, scope, arg_node, i); |
| 5161 | IrInstruction *arg_type = ir_build_arg_type(irb, scope, source_node, fn_type, arg_index, true); | 6195 | IrInstSrc *arg_type = ir_build_arg_type(irb, scope, source_node, fn_type, arg_index, true); |
| 5162 | ResultLoc *no_result = no_result_loc(); | 6196 | ResultLoc *no_result = no_result_loc(); |
| 5163 | ir_build_reset_result(irb, scope, source_node, no_result); | 6197 | ir_build_reset_result(irb, scope, source_node, no_result); |
| 5164 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, arg_type, no_result); | 6198 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, arg_type, no_result); |
| 5165 | | 6199 | |
| 5166 | IrInstruction *arg = ir_gen_node_extra(irb, arg_node, scope, LValNone, &result_loc_cast->base); | 6200 | IrInstSrc *arg = ir_gen_node_extra(irb, arg_node, scope, LValNone, &result_loc_cast->base); |
| 5167 | if (arg == irb->codegen->invalid_instruction) | 6201 | if (arg == irb->codegen->invalid_inst_src) |
| 5168 | return arg; | 6202 | return arg; |
| 5169 | | 6203 | |
| 5170 | args[i] = ir_build_implicit_cast(irb, scope, arg_node, arg, result_loc_cast); | 6204 | args[i] = ir_build_implicit_cast(irb, scope, arg_node, arg, result_loc_cast); |
| 5171 | } | 6205 | } |
| 5172 | | 6206 | |
| 5173 | IrInstruction *fn_call; | 6207 | IrInstSrc *fn_call; |
| 5174 | if (options != nullptr) { | 6208 | if (options != nullptr) { |
| 5175 | fn_call = ir_build_call_src_args(irb, scope, source_node, options, fn_ref, args, args_len, result_loc); | 6209 | fn_call = ir_build_call_args(irb, scope, source_node, options, fn_ref, args, args_len, result_loc); |
| 5176 | } else { | 6210 | } else { |
| 5177 | fn_call = ir_build_call_src(irb, scope, source_node, nullptr, fn_ref, args_len, args, nullptr, | 6211 | fn_call = ir_build_call_src(irb, scope, source_node, nullptr, fn_ref, args_len, args, nullptr, |
| 5178 | modifier, false, nullptr, result_loc); | 6212 | modifier, false, nullptr, result_loc); |
| ... | @@ -5180,7 +6214,7 @@ static IrInstruction *ir_gen_fn_call_with_args(IrBuilder *irb, Scope *scope, Ast | ... | @@ -5180,7 +6214,7 @@ static IrInstruction *ir_gen_fn_call_with_args(IrBuilder *irb, Scope *scope, Ast |
| 5180 | return ir_lval_wrap(irb, scope, fn_call, lval, result_loc); | 6214 | return ir_lval_wrap(irb, scope, fn_call, lval, result_loc); |
| 5181 | } | 6215 | } |
| 5182 | | 6216 | |
| 5183 | static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 6217 | static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 5184 | ResultLoc *result_loc) | 6218 | ResultLoc *result_loc) |
| 5185 | { | 6219 | { |
| 5186 | assert(node->type == NodeTypeFnCallExpr); | 6220 | assert(node->type == NodeTypeFnCallExpr); |
| ... | @@ -5192,7 +6226,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -5192,7 +6226,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 5192 | if (!entry) { | 6226 | if (!entry) { |
| 5193 | add_node_error(irb->codegen, node, | 6227 | add_node_error(irb->codegen, node, |
| 5194 | buf_sprintf("invalid builtin function: '%s'", buf_ptr(name))); | 6228 | buf_sprintf("invalid builtin function: '%s'", buf_ptr(name))); |
| 5195 | return irb->codegen->invalid_instruction; | 6229 | return irb->codegen->invalid_inst_src; |
| 5196 | } | 6230 | } |
| 5197 | | 6231 | |
| 5198 | BuiltinFnEntry *builtin_fn = entry->value; | 6232 | BuiltinFnEntry *builtin_fn = entry->value; |
| ... | @@ -5202,7 +6236,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -5202,7 +6236,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 5202 | add_node_error(irb->codegen, node, | 6236 | add_node_error(irb->codegen, node, |
| 5203 | buf_sprintf("expected %" ZIG_PRI_usize " arguments, found %" ZIG_PRI_usize, | 6237 | buf_sprintf("expected %" ZIG_PRI_usize " arguments, found %" ZIG_PRI_usize, |
| 5204 | builtin_fn->param_count, actual_param_count)); | 6238 | builtin_fn->param_count, actual_param_count)); |
| 5205 | return irb->codegen->invalid_instruction; | 6239 | return irb->codegen->invalid_inst_src; |
| 5206 | } | 6240 | } |
| 5207 | | 6241 | |
| 5208 | switch (builtin_fn->id) { | 6242 | switch (builtin_fn->id) { |
| ... | @@ -5213,197 +6247,197 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -5213,197 +6247,197 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 5213 | Scope *sub_scope = create_typeof_scope(irb->codegen, node, scope); | 6247 | Scope *sub_scope = create_typeof_scope(irb->codegen, node, scope); |
| 5214 | | 6248 | |
| 5215 | AstNode *arg_node = node->data.fn_call_expr.params.at(0); | 6249 | AstNode *arg_node = node->data.fn_call_expr.params.at(0); |
| 5216 | IrInstruction *arg = ir_gen_node(irb, arg_node, sub_scope); | 6250 | IrInstSrc *arg = ir_gen_node(irb, arg_node, sub_scope); |
| 5217 | if (arg == irb->codegen->invalid_instruction) | 6251 | if (arg == irb->codegen->invalid_inst_src) |
| 5218 | return arg; | 6252 | return arg; |
| 5219 | | 6253 | |
| 5220 | IrInstruction *type_of = ir_build_typeof(irb, scope, node, arg); | 6254 | IrInstSrc *type_of = ir_build_typeof(irb, scope, node, arg); |
| 5221 | return ir_lval_wrap(irb, scope, type_of, lval, result_loc); | 6255 | return ir_lval_wrap(irb, scope, type_of, lval, result_loc); |
| 5222 | } | 6256 | } |
| 5223 | case BuiltinFnIdSetCold: | 6257 | case BuiltinFnIdSetCold: |
| 5224 | { | 6258 | { |
| 5225 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6259 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5226 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6260 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5227 | if (arg0_value == irb->codegen->invalid_instruction) | 6261 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5228 | return arg0_value; | 6262 | return arg0_value; |
| 5229 | | 6263 | |
| 5230 | IrInstruction *set_cold = ir_build_set_cold(irb, scope, node, arg0_value); | 6264 | IrInstSrc *set_cold = ir_build_set_cold(irb, scope, node, arg0_value); |
| 5231 | return ir_lval_wrap(irb, scope, set_cold, lval, result_loc); | 6265 | return ir_lval_wrap(irb, scope, set_cold, lval, result_loc); |
| 5232 | } | 6266 | } |
| 5233 | case BuiltinFnIdSetRuntimeSafety: | 6267 | case BuiltinFnIdSetRuntimeSafety: |
| 5234 | { | 6268 | { |
| 5235 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6269 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5236 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6270 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5237 | if (arg0_value == irb->codegen->invalid_instruction) | 6271 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5238 | return arg0_value; | 6272 | return arg0_value; |
| 5239 | | 6273 | |
| 5240 | IrInstruction *set_safety = ir_build_set_runtime_safety(irb, scope, node, arg0_value); | 6274 | IrInstSrc *set_safety = ir_build_set_runtime_safety(irb, scope, node, arg0_value); |
| 5241 | return ir_lval_wrap(irb, scope, set_safety, lval, result_loc); | 6275 | return ir_lval_wrap(irb, scope, set_safety, lval, result_loc); |
| 5242 | } | 6276 | } |
| 5243 | case BuiltinFnIdSetFloatMode: | 6277 | case BuiltinFnIdSetFloatMode: |
| 5244 | { | 6278 | { |
| 5245 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6279 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5246 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6280 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5247 | if (arg0_value == irb->codegen->invalid_instruction) | 6281 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5248 | return arg0_value; | 6282 | return arg0_value; |
| 5249 | | 6283 | |
| 5250 | IrInstruction *set_float_mode = ir_build_set_float_mode(irb, scope, node, arg0_value); | 6284 | IrInstSrc *set_float_mode = ir_build_set_float_mode(irb, scope, node, arg0_value); |
| 5251 | return ir_lval_wrap(irb, scope, set_float_mode, lval, result_loc); | 6285 | return ir_lval_wrap(irb, scope, set_float_mode, lval, result_loc); |
| 5252 | } | 6286 | } |
| 5253 | case BuiltinFnIdSizeof: | 6287 | case BuiltinFnIdSizeof: |
| 5254 | case BuiltinFnIdBitSizeof: | 6288 | case BuiltinFnIdBitSizeof: |
| 5255 | { | 6289 | { |
| 5256 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6290 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5257 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6291 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5258 | if (arg0_value == irb->codegen->invalid_instruction) | 6292 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5259 | return arg0_value; | 6293 | return arg0_value; |
| 5260 | | 6294 | |
| 5261 | IrInstruction *size_of = ir_build_size_of(irb, scope, node, arg0_value, builtin_fn->id == BuiltinFnIdBitSizeof); | 6295 | IrInstSrc *size_of = ir_build_size_of(irb, scope, node, arg0_value, builtin_fn->id == BuiltinFnIdBitSizeof); |
| 5262 | return ir_lval_wrap(irb, scope, size_of, lval, result_loc); | 6296 | return ir_lval_wrap(irb, scope, size_of, lval, result_loc); |
| 5263 | } | 6297 | } |
| 5264 | case BuiltinFnIdImport: | 6298 | case BuiltinFnIdImport: |
| 5265 | { | 6299 | { |
| 5266 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6300 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5267 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6301 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5268 | if (arg0_value == irb->codegen->invalid_instruction) | 6302 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5269 | return arg0_value; | 6303 | return arg0_value; |
| 5270 | | 6304 | |
| 5271 | IrInstruction *import = ir_build_import(irb, scope, node, arg0_value); | 6305 | IrInstSrc *import = ir_build_import(irb, scope, node, arg0_value); |
| 5272 | return ir_lval_wrap(irb, scope, import, lval, result_loc); | 6306 | return ir_lval_wrap(irb, scope, import, lval, result_loc); |
| 5273 | } | 6307 | } |
| 5274 | case BuiltinFnIdCImport: | 6308 | case BuiltinFnIdCImport: |
| 5275 | { | 6309 | { |
| 5276 | IrInstruction *c_import = ir_build_c_import(irb, scope, node); | 6310 | IrInstSrc *c_import = ir_build_c_import(irb, scope, node); |
| 5277 | return ir_lval_wrap(irb, scope, c_import, lval, result_loc); | 6311 | return ir_lval_wrap(irb, scope, c_import, lval, result_loc); |
| 5278 | } | 6312 | } |
| 5279 | case BuiltinFnIdCInclude: | 6313 | case BuiltinFnIdCInclude: |
| 5280 | { | 6314 | { |
| 5281 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6315 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5282 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6316 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5283 | if (arg0_value == irb->codegen->invalid_instruction) | 6317 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5284 | return arg0_value; | 6318 | return arg0_value; |
| 5285 | | 6319 | |
| 5286 | if (!exec_c_import_buf(irb->exec)) { | 6320 | if (!exec_c_import_buf(irb->exec)) { |
| 5287 | add_node_error(irb->codegen, node, buf_sprintf("C include valid only inside C import block")); | 6321 | add_node_error(irb->codegen, node, buf_sprintf("C include valid only inside C import block")); |
| 5288 | return irb->codegen->invalid_instruction; | 6322 | return irb->codegen->invalid_inst_src; |
| 5289 | } | 6323 | } |
| 5290 | | 6324 | |
| 5291 | IrInstruction *c_include = ir_build_c_include(irb, scope, node, arg0_value); | 6325 | IrInstSrc *c_include = ir_build_c_include(irb, scope, node, arg0_value); |
| 5292 | return ir_lval_wrap(irb, scope, c_include, lval, result_loc); | 6326 | return ir_lval_wrap(irb, scope, c_include, lval, result_loc); |
| 5293 | } | 6327 | } |
| 5294 | case BuiltinFnIdCDefine: | 6328 | case BuiltinFnIdCDefine: |
| 5295 | { | 6329 | { |
| 5296 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6330 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5297 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6331 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5298 | if (arg0_value == irb->codegen->invalid_instruction) | 6332 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5299 | return arg0_value; | 6333 | return arg0_value; |
| 5300 | | 6334 | |
| 5301 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6335 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5302 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6336 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5303 | if (arg1_value == irb->codegen->invalid_instruction) | 6337 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5304 | return arg1_value; | 6338 | return arg1_value; |
| 5305 | | 6339 | |
| 5306 | if (!exec_c_import_buf(irb->exec)) { | 6340 | if (!exec_c_import_buf(irb->exec)) { |
| 5307 | add_node_error(irb->codegen, node, buf_sprintf("C define valid only inside C import block")); | 6341 | add_node_error(irb->codegen, node, buf_sprintf("C define valid only inside C import block")); |
| 5308 | return irb->codegen->invalid_instruction; | 6342 | return irb->codegen->invalid_inst_src; |
| 5309 | } | 6343 | } |
| 5310 | | 6344 | |
| 5311 | IrInstruction *c_define = ir_build_c_define(irb, scope, node, arg0_value, arg1_value); | 6345 | IrInstSrc *c_define = ir_build_c_define(irb, scope, node, arg0_value, arg1_value); |
| 5312 | return ir_lval_wrap(irb, scope, c_define, lval, result_loc); | 6346 | return ir_lval_wrap(irb, scope, c_define, lval, result_loc); |
| 5313 | } | 6347 | } |
| 5314 | case BuiltinFnIdCUndef: | 6348 | case BuiltinFnIdCUndef: |
| 5315 | { | 6349 | { |
| 5316 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6350 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5317 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6351 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5318 | if (arg0_value == irb->codegen->invalid_instruction) | 6352 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5319 | return arg0_value; | 6353 | return arg0_value; |
| 5320 | | 6354 | |
| 5321 | if (!exec_c_import_buf(irb->exec)) { | 6355 | if (!exec_c_import_buf(irb->exec)) { |
| 5322 | add_node_error(irb->codegen, node, buf_sprintf("C undef valid only inside C import block")); | 6356 | add_node_error(irb->codegen, node, buf_sprintf("C undef valid only inside C import block")); |
| 5323 | return irb->codegen->invalid_instruction; | 6357 | return irb->codegen->invalid_inst_src; |
| 5324 | } | 6358 | } |
| 5325 | | 6359 | |
| 5326 | IrInstruction *c_undef = ir_build_c_undef(irb, scope, node, arg0_value); | 6360 | IrInstSrc *c_undef = ir_build_c_undef(irb, scope, node, arg0_value); |
| 5327 | return ir_lval_wrap(irb, scope, c_undef, lval, result_loc); | 6361 | return ir_lval_wrap(irb, scope, c_undef, lval, result_loc); |
| 5328 | } | 6362 | } |
| 5329 | case BuiltinFnIdCompileErr: | 6363 | case BuiltinFnIdCompileErr: |
| 5330 | { | 6364 | { |
| 5331 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6365 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5332 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6366 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5333 | if (arg0_value == irb->codegen->invalid_instruction) | 6367 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5334 | return arg0_value; | 6368 | return arg0_value; |
| 5335 | | 6369 | |
| 5336 | IrInstruction *compile_err = ir_build_compile_err(irb, scope, node, arg0_value); | 6370 | IrInstSrc *compile_err = ir_build_compile_err(irb, scope, node, arg0_value); |
| 5337 | return ir_lval_wrap(irb, scope, compile_err, lval, result_loc); | 6371 | return ir_lval_wrap(irb, scope, compile_err, lval, result_loc); |
| 5338 | } | 6372 | } |
| 5339 | case BuiltinFnIdCompileLog: | 6373 | case BuiltinFnIdCompileLog: |
| 5340 | { | 6374 | { |
| 5341 | IrInstruction **args = allocate<IrInstruction*>(actual_param_count); | 6375 | IrInstSrc **args = allocate<IrInstSrc*>(actual_param_count); |
| 5342 | | 6376 | |
| 5343 | for (size_t i = 0; i < actual_param_count; i += 1) { | 6377 | for (size_t i = 0; i < actual_param_count; i += 1) { |
| 5344 | AstNode *arg_node = node->data.fn_call_expr.params.at(i); | 6378 | AstNode *arg_node = node->data.fn_call_expr.params.at(i); |
| 5345 | args[i] = ir_gen_node(irb, arg_node, scope); | 6379 | args[i] = ir_gen_node(irb, arg_node, scope); |
| 5346 | if (args[i] == irb->codegen->invalid_instruction) | 6380 | if (args[i] == irb->codegen->invalid_inst_src) |
| 5347 | return irb->codegen->invalid_instruction; | 6381 | return irb->codegen->invalid_inst_src; |
| 5348 | } | 6382 | } |
| 5349 | | 6383 | |
| 5350 | IrInstruction *compile_log = ir_build_compile_log(irb, scope, node, actual_param_count, args); | 6384 | IrInstSrc *compile_log = ir_build_compile_log(irb, scope, node, actual_param_count, args); |
| 5351 | return ir_lval_wrap(irb, scope, compile_log, lval, result_loc); | 6385 | return ir_lval_wrap(irb, scope, compile_log, lval, result_loc); |
| 5352 | } | 6386 | } |
| 5353 | case BuiltinFnIdErrName: | 6387 | case BuiltinFnIdErrName: |
| 5354 | { | 6388 | { |
| 5355 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6389 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5356 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6390 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5357 | if (arg0_value == irb->codegen->invalid_instruction) | 6391 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5358 | return arg0_value; | 6392 | return arg0_value; |
| 5359 | | 6393 | |
| 5360 | IrInstruction *err_name = ir_build_err_name(irb, scope, node, arg0_value); | 6394 | IrInstSrc *err_name = ir_build_err_name(irb, scope, node, arg0_value); |
| 5361 | return ir_lval_wrap(irb, scope, err_name, lval, result_loc); | 6395 | return ir_lval_wrap(irb, scope, err_name, lval, result_loc); |
| 5362 | } | 6396 | } |
| 5363 | case BuiltinFnIdEmbedFile: | 6397 | case BuiltinFnIdEmbedFile: |
| 5364 | { | 6398 | { |
| 5365 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6399 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5366 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6400 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5367 | if (arg0_value == irb->codegen->invalid_instruction) | 6401 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5368 | return arg0_value; | 6402 | return arg0_value; |
| 5369 | | 6403 | |
| 5370 | IrInstruction *embed_file = ir_build_embed_file(irb, scope, node, arg0_value); | 6404 | IrInstSrc *embed_file = ir_build_embed_file(irb, scope, node, arg0_value); |
| 5371 | return ir_lval_wrap(irb, scope, embed_file, lval, result_loc); | 6405 | return ir_lval_wrap(irb, scope, embed_file, lval, result_loc); |
| 5372 | } | 6406 | } |
| 5373 | case BuiltinFnIdCmpxchgWeak: | 6407 | case BuiltinFnIdCmpxchgWeak: |
| 5374 | case BuiltinFnIdCmpxchgStrong: | 6408 | case BuiltinFnIdCmpxchgStrong: |
| 5375 | { | 6409 | { |
| 5376 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6410 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5377 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6411 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5378 | if (arg0_value == irb->codegen->invalid_instruction) | 6412 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5379 | return arg0_value; | 6413 | return arg0_value; |
| 5380 | | 6414 | |
| 5381 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6415 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5382 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6416 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5383 | if (arg1_value == irb->codegen->invalid_instruction) | 6417 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5384 | return arg1_value; | 6418 | return arg1_value; |
| 5385 | | 6419 | |
| 5386 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); | 6420 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 5387 | IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope); | 6421 | IrInstSrc *arg2_value = ir_gen_node(irb, arg2_node, scope); |
| 5388 | if (arg2_value == irb->codegen->invalid_instruction) | 6422 | if (arg2_value == irb->codegen->invalid_inst_src) |
| 5389 | return arg2_value; | 6423 | return arg2_value; |
| 5390 | | 6424 | |
| 5391 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); | 6425 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); |
| 5392 | IrInstruction *arg3_value = ir_gen_node(irb, arg3_node, scope); | 6426 | IrInstSrc *arg3_value = ir_gen_node(irb, arg3_node, scope); |
| 5393 | if (arg3_value == irb->codegen->invalid_instruction) | 6427 | if (arg3_value == irb->codegen->invalid_inst_src) |
| 5394 | return arg3_value; | 6428 | return arg3_value; |
| 5395 | | 6429 | |
| 5396 | AstNode *arg4_node = node->data.fn_call_expr.params.at(4); | 6430 | AstNode *arg4_node = node->data.fn_call_expr.params.at(4); |
| 5397 | IrInstruction *arg4_value = ir_gen_node(irb, arg4_node, scope); | 6431 | IrInstSrc *arg4_value = ir_gen_node(irb, arg4_node, scope); |
| 5398 | if (arg4_value == irb->codegen->invalid_instruction) | 6432 | if (arg4_value == irb->codegen->invalid_inst_src) |
| 5399 | return arg4_value; | 6433 | return arg4_value; |
| 5400 | | 6434 | |
| 5401 | AstNode *arg5_node = node->data.fn_call_expr.params.at(5); | 6435 | AstNode *arg5_node = node->data.fn_call_expr.params.at(5); |
| 5402 | IrInstruction *arg5_value = ir_gen_node(irb, arg5_node, scope); | 6436 | IrInstSrc *arg5_value = ir_gen_node(irb, arg5_node, scope); |
| 5403 | if (arg5_value == irb->codegen->invalid_instruction) | 6437 | if (arg5_value == irb->codegen->invalid_inst_src) |
| 5404 | return arg5_value; | 6438 | return arg5_value; |
| 5405 | | 6439 | |
| 5406 | IrInstruction *cmpxchg = ir_build_cmpxchg_src(irb, scope, node, arg0_value, arg1_value, | 6440 | IrInstSrc *cmpxchg = ir_build_cmpxchg_src(irb, scope, node, arg0_value, arg1_value, |
| 5407 | arg2_value, arg3_value, arg4_value, arg5_value, (builtin_fn->id == BuiltinFnIdCmpxchgWeak), | 6441 | arg2_value, arg3_value, arg4_value, arg5_value, (builtin_fn->id == BuiltinFnIdCmpxchgWeak), |
| 5408 | result_loc); | 6442 | result_loc); |
| 5409 | return ir_lval_wrap(irb, scope, cmpxchg, lval, result_loc); | 6443 | return ir_lval_wrap(irb, scope, cmpxchg, lval, result_loc); |
| ... | @@ -5411,86 +6445,86 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -5411,86 +6445,86 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 5411 | case BuiltinFnIdFence: | 6445 | case BuiltinFnIdFence: |
| 5412 | { | 6446 | { |
| 5413 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6447 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5414 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6448 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5415 | if (arg0_value == irb->codegen->invalid_instruction) | 6449 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5416 | return arg0_value; | 6450 | return arg0_value; |
| 5417 | | 6451 | |
| 5418 | IrInstruction *fence = ir_build_fence(irb, scope, node, arg0_value, AtomicOrderUnordered); | 6452 | IrInstSrc *fence = ir_build_fence(irb, scope, node, arg0_value); |
| 5419 | return ir_lval_wrap(irb, scope, fence, lval, result_loc); | 6453 | return ir_lval_wrap(irb, scope, fence, lval, result_loc); |
| 5420 | } | 6454 | } |
| 5421 | case BuiltinFnIdDivExact: | 6455 | case BuiltinFnIdDivExact: |
| 5422 | { | 6456 | { |
| 5423 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6457 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5424 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6458 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5425 | if (arg0_value == irb->codegen->invalid_instruction) | 6459 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5426 | return arg0_value; | 6460 | return arg0_value; |
| 5427 | | 6461 | |
| 5428 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6462 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5429 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6463 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5430 | if (arg1_value == irb->codegen->invalid_instruction) | 6464 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5431 | return arg1_value; | 6465 | return arg1_value; |
| 5432 | | 6466 | |
| 5433 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpDivExact, arg0_value, arg1_value, true); | 6467 | IrInstSrc *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpDivExact, arg0_value, arg1_value, true); |
| 5434 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); | 6468 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); |
| 5435 | } | 6469 | } |
| 5436 | case BuiltinFnIdDivTrunc: | 6470 | case BuiltinFnIdDivTrunc: |
| 5437 | { | 6471 | { |
| 5438 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6472 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5439 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6473 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5440 | if (arg0_value == irb->codegen->invalid_instruction) | 6474 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5441 | return arg0_value; | 6475 | return arg0_value; |
| 5442 | | 6476 | |
| 5443 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6477 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5444 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6478 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5445 | if (arg1_value == irb->codegen->invalid_instruction) | 6479 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5446 | return arg1_value; | 6480 | return arg1_value; |
| 5447 | | 6481 | |
| 5448 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpDivTrunc, arg0_value, arg1_value, true); | 6482 | IrInstSrc *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpDivTrunc, arg0_value, arg1_value, true); |
| 5449 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); | 6483 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); |
| 5450 | } | 6484 | } |
| 5451 | case BuiltinFnIdDivFloor: | 6485 | case BuiltinFnIdDivFloor: |
| 5452 | { | 6486 | { |
| 5453 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6487 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5454 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6488 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5455 | if (arg0_value == irb->codegen->invalid_instruction) | 6489 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5456 | return arg0_value; | 6490 | return arg0_value; |
| 5457 | | 6491 | |
| 5458 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6492 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5459 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6493 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5460 | if (arg1_value == irb->codegen->invalid_instruction) | 6494 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5461 | return arg1_value; | 6495 | return arg1_value; |
| 5462 | | 6496 | |
| 5463 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpDivFloor, arg0_value, arg1_value, true); | 6497 | IrInstSrc *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpDivFloor, arg0_value, arg1_value, true); |
| 5464 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); | 6498 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); |
| 5465 | } | 6499 | } |
| 5466 | case BuiltinFnIdRem: | 6500 | case BuiltinFnIdRem: |
| 5467 | { | 6501 | { |
| 5468 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6502 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5469 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6503 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5470 | if (arg0_value == irb->codegen->invalid_instruction) | 6504 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5471 | return arg0_value; | 6505 | return arg0_value; |
| 5472 | | 6506 | |
| 5473 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6507 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5474 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6508 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5475 | if (arg1_value == irb->codegen->invalid_instruction) | 6509 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5476 | return arg1_value; | 6510 | return arg1_value; |
| 5477 | | 6511 | |
| 5478 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpRemRem, arg0_value, arg1_value, true); | 6512 | IrInstSrc *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpRemRem, arg0_value, arg1_value, true); |
| 5479 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); | 6513 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); |
| 5480 | } | 6514 | } |
| 5481 | case BuiltinFnIdMod: | 6515 | case BuiltinFnIdMod: |
| 5482 | { | 6516 | { |
| 5483 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6517 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5484 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6518 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5485 | if (arg0_value == irb->codegen->invalid_instruction) | 6519 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5486 | return arg0_value; | 6520 | return arg0_value; |
| 5487 | | 6521 | |
| 5488 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6522 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5489 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6523 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5490 | if (arg1_value == irb->codegen->invalid_instruction) | 6524 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5491 | return arg1_value; | 6525 | return arg1_value; |
| 5492 | | 6526 | |
| 5493 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpRemMod, arg0_value, arg1_value, true); | 6527 | IrInstSrc *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpRemMod, arg0_value, arg1_value, true); |
| 5494 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); | 6528 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); |
| 5495 | } | 6529 | } |
| 5496 | case BuiltinFnIdSqrt: | 6530 | case BuiltinFnIdSqrt: |
| ... | @@ -5509,406 +6543,406 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -5509,406 +6543,406 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 5509 | case BuiltinFnIdRound: | 6543 | case BuiltinFnIdRound: |
| 5510 | { | 6544 | { |
| 5511 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6545 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5512 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6546 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5513 | if (arg0_value == irb->codegen->invalid_instruction) | 6547 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5514 | return arg0_value; | 6548 | return arg0_value; |
| 5515 | | 6549 | |
| 5516 | IrInstruction *inst = ir_build_float_op(irb, scope, node, arg0_value, builtin_fn->id); | 6550 | IrInstSrc *inst = ir_build_float_op_src(irb, scope, node, arg0_value, builtin_fn->id); |
| 5517 | return ir_lval_wrap(irb, scope, inst, lval, result_loc); | 6551 | return ir_lval_wrap(irb, scope, inst, lval, result_loc); |
| 5518 | } | 6552 | } |
| 5519 | case BuiltinFnIdTruncate: | 6553 | case BuiltinFnIdTruncate: |
| 5520 | { | 6554 | { |
| 5521 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6555 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5522 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6556 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5523 | if (arg0_value == irb->codegen->invalid_instruction) | 6557 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5524 | return arg0_value; | 6558 | return arg0_value; |
| 5525 | | 6559 | |
| 5526 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6560 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5527 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6561 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5528 | if (arg1_value == irb->codegen->invalid_instruction) | 6562 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5529 | return arg1_value; | 6563 | return arg1_value; |
| 5530 | | 6564 | |
| 5531 | IrInstruction *truncate = ir_build_truncate(irb, scope, node, arg0_value, arg1_value); | 6565 | IrInstSrc *truncate = ir_build_truncate(irb, scope, node, arg0_value, arg1_value); |
| 5532 | return ir_lval_wrap(irb, scope, truncate, lval, result_loc); | 6566 | return ir_lval_wrap(irb, scope, truncate, lval, result_loc); |
| 5533 | } | 6567 | } |
| 5534 | case BuiltinFnIdIntCast: | 6568 | case BuiltinFnIdIntCast: |
| 5535 | { | 6569 | { |
| 5536 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6570 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5537 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6571 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5538 | if (arg0_value == irb->codegen->invalid_instruction) | 6572 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5539 | return arg0_value; | 6573 | return arg0_value; |
| 5540 | | 6574 | |
| 5541 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6575 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5542 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6576 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5543 | if (arg1_value == irb->codegen->invalid_instruction) | 6577 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5544 | return arg1_value; | 6578 | return arg1_value; |
| 5545 | | 6579 | |
| 5546 | IrInstruction *result = ir_build_int_cast(irb, scope, node, arg0_value, arg1_value); | 6580 | IrInstSrc *result = ir_build_int_cast(irb, scope, node, arg0_value, arg1_value); |
| 5547 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6581 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5548 | } | 6582 | } |
| 5549 | case BuiltinFnIdFloatCast: | 6583 | case BuiltinFnIdFloatCast: |
| 5550 | { | 6584 | { |
| 5551 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6585 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5552 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6586 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5553 | if (arg0_value == irb->codegen->invalid_instruction) | 6587 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5554 | return arg0_value; | 6588 | return arg0_value; |
| 5555 | | 6589 | |
| 5556 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6590 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5557 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6591 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5558 | if (arg1_value == irb->codegen->invalid_instruction) | 6592 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5559 | return arg1_value; | 6593 | return arg1_value; |
| 5560 | | 6594 | |
| 5561 | IrInstruction *result = ir_build_float_cast(irb, scope, node, arg0_value, arg1_value); | 6595 | IrInstSrc *result = ir_build_float_cast(irb, scope, node, arg0_value, arg1_value); |
| 5562 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6596 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5563 | } | 6597 | } |
| 5564 | case BuiltinFnIdErrSetCast: | 6598 | case BuiltinFnIdErrSetCast: |
| 5565 | { | 6599 | { |
| 5566 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6600 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5567 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6601 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5568 | if (arg0_value == irb->codegen->invalid_instruction) | 6602 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5569 | return arg0_value; | 6603 | return arg0_value; |
| 5570 | | 6604 | |
| 5571 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6605 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5572 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6606 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5573 | if (arg1_value == irb->codegen->invalid_instruction) | 6607 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5574 | return arg1_value; | 6608 | return arg1_value; |
| 5575 | | 6609 | |
| 5576 | IrInstruction *result = ir_build_err_set_cast(irb, scope, node, arg0_value, arg1_value); | 6610 | IrInstSrc *result = ir_build_err_set_cast(irb, scope, node, arg0_value, arg1_value); |
| 5577 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6611 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5578 | } | 6612 | } |
| 5579 | case BuiltinFnIdFromBytes: | 6613 | case BuiltinFnIdFromBytes: |
| 5580 | { | 6614 | { |
| 5581 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6615 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5582 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6616 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5583 | if (arg0_value == irb->codegen->invalid_instruction) | 6617 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5584 | return arg0_value; | 6618 | return arg0_value; |
| 5585 | | 6619 | |
| 5586 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6620 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5587 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6621 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5588 | if (arg1_value == irb->codegen->invalid_instruction) | 6622 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5589 | return arg1_value; | 6623 | return arg1_value; |
| 5590 | | 6624 | |
| 5591 | IrInstruction *result = ir_build_from_bytes(irb, scope, node, arg0_value, arg1_value, result_loc); | 6625 | IrInstSrc *result = ir_build_from_bytes(irb, scope, node, arg0_value, arg1_value, result_loc); |
| 5592 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6626 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5593 | } | 6627 | } |
| 5594 | case BuiltinFnIdToBytes: | 6628 | case BuiltinFnIdToBytes: |
| 5595 | { | 6629 | { |
| 5596 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6630 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5597 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6631 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5598 | if (arg0_value == irb->codegen->invalid_instruction) | 6632 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5599 | return arg0_value; | 6633 | return arg0_value; |
| 5600 | | 6634 | |
| 5601 | IrInstruction *result = ir_build_to_bytes(irb, scope, node, arg0_value, result_loc); | 6635 | IrInstSrc *result = ir_build_to_bytes(irb, scope, node, arg0_value, result_loc); |
| 5602 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6636 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5603 | } | 6637 | } |
| 5604 | case BuiltinFnIdIntToFloat: | 6638 | case BuiltinFnIdIntToFloat: |
| 5605 | { | 6639 | { |
| 5606 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6640 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5607 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6641 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5608 | if (arg0_value == irb->codegen->invalid_instruction) | 6642 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5609 | return arg0_value; | 6643 | return arg0_value; |
| 5610 | | 6644 | |
| 5611 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6645 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5612 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6646 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5613 | if (arg1_value == irb->codegen->invalid_instruction) | 6647 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5614 | return arg1_value; | 6648 | return arg1_value; |
| 5615 | | 6649 | |
| 5616 | IrInstruction *result = ir_build_int_to_float(irb, scope, node, arg0_value, arg1_value); | 6650 | IrInstSrc *result = ir_build_int_to_float(irb, scope, node, arg0_value, arg1_value); |
| 5617 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6651 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5618 | } | 6652 | } |
| 5619 | case BuiltinFnIdFloatToInt: | 6653 | case BuiltinFnIdFloatToInt: |
| 5620 | { | 6654 | { |
| 5621 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6655 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5622 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6656 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5623 | if (arg0_value == irb->codegen->invalid_instruction) | 6657 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5624 | return arg0_value; | 6658 | return arg0_value; |
| 5625 | | 6659 | |
| 5626 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6660 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5627 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6661 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5628 | if (arg1_value == irb->codegen->invalid_instruction) | 6662 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5629 | return arg1_value; | 6663 | return arg1_value; |
| 5630 | | 6664 | |
| 5631 | IrInstruction *result = ir_build_float_to_int(irb, scope, node, arg0_value, arg1_value); | 6665 | IrInstSrc *result = ir_build_float_to_int(irb, scope, node, arg0_value, arg1_value); |
| 5632 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6666 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5633 | } | 6667 | } |
| 5634 | case BuiltinFnIdErrToInt: | 6668 | case BuiltinFnIdErrToInt: |
| 5635 | { | 6669 | { |
| 5636 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6670 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5637 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6671 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5638 | if (arg0_value == irb->codegen->invalid_instruction) | 6672 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5639 | return arg0_value; | 6673 | return arg0_value; |
| 5640 | | 6674 | |
| 5641 | IrInstruction *result = ir_build_err_to_int(irb, scope, node, arg0_value); | 6675 | IrInstSrc *result = ir_build_err_to_int_src(irb, scope, node, arg0_value); |
| 5642 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6676 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5643 | } | 6677 | } |
| 5644 | case BuiltinFnIdIntToErr: | 6678 | case BuiltinFnIdIntToErr: |
| 5645 | { | 6679 | { |
| 5646 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6680 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5647 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6681 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5648 | if (arg0_value == irb->codegen->invalid_instruction) | 6682 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5649 | return arg0_value; | 6683 | return arg0_value; |
| 5650 | | 6684 | |
| 5651 | IrInstruction *result = ir_build_int_to_err(irb, scope, node, arg0_value); | 6685 | IrInstSrc *result = ir_build_int_to_err_src(irb, scope, node, arg0_value); |
| 5652 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6686 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5653 | } | 6687 | } |
| 5654 | case BuiltinFnIdBoolToInt: | 6688 | case BuiltinFnIdBoolToInt: |
| 5655 | { | 6689 | { |
| 5656 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6690 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5657 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6691 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5658 | if (arg0_value == irb->codegen->invalid_instruction) | 6692 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5659 | return arg0_value; | 6693 | return arg0_value; |
| 5660 | | 6694 | |
| 5661 | IrInstruction *result = ir_build_bool_to_int(irb, scope, node, arg0_value); | 6695 | IrInstSrc *result = ir_build_bool_to_int(irb, scope, node, arg0_value); |
| 5662 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 6696 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 5663 | } | 6697 | } |
| 5664 | case BuiltinFnIdIntType: | 6698 | case BuiltinFnIdIntType: |
| 5665 | { | 6699 | { |
| 5666 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6700 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5667 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6701 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5668 | if (arg0_value == irb->codegen->invalid_instruction) | 6702 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5669 | return arg0_value; | 6703 | return arg0_value; |
| 5670 | | 6704 | |
| 5671 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6705 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5672 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6706 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5673 | if (arg1_value == irb->codegen->invalid_instruction) | 6707 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5674 | return arg1_value; | 6708 | return arg1_value; |
| 5675 | | 6709 | |
| 5676 | IrInstruction *int_type = ir_build_int_type(irb, scope, node, arg0_value, arg1_value); | 6710 | IrInstSrc *int_type = ir_build_int_type(irb, scope, node, arg0_value, arg1_value); |
| 5677 | return ir_lval_wrap(irb, scope, int_type, lval, result_loc); | 6711 | return ir_lval_wrap(irb, scope, int_type, lval, result_loc); |
| 5678 | } | 6712 | } |
| 5679 | case BuiltinFnIdVectorType: | 6713 | case BuiltinFnIdVectorType: |
| 5680 | { | 6714 | { |
| 5681 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6715 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5682 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6716 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5683 | if (arg0_value == irb->codegen->invalid_instruction) | 6717 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5684 | return arg0_value; | 6718 | return arg0_value; |
| 5685 | | 6719 | |
| 5686 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6720 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5687 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6721 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5688 | if (arg1_value == irb->codegen->invalid_instruction) | 6722 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5689 | return arg1_value; | 6723 | return arg1_value; |
| 5690 | | 6724 | |
| 5691 | IrInstruction *vector_type = ir_build_vector_type(irb, scope, node, arg0_value, arg1_value); | 6725 | IrInstSrc *vector_type = ir_build_vector_type(irb, scope, node, arg0_value, arg1_value); |
| 5692 | return ir_lval_wrap(irb, scope, vector_type, lval, result_loc); | 6726 | return ir_lval_wrap(irb, scope, vector_type, lval, result_loc); |
| 5693 | } | 6727 | } |
| 5694 | case BuiltinFnIdShuffle: | 6728 | case BuiltinFnIdShuffle: |
| 5695 | { | 6729 | { |
| 5696 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6730 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5697 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6731 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5698 | if (arg0_value == irb->codegen->invalid_instruction) | 6732 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5699 | return arg0_value; | 6733 | return arg0_value; |
| 5700 | | 6734 | |
| 5701 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6735 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5702 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6736 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5703 | if (arg1_value == irb->codegen->invalid_instruction) | 6737 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5704 | return arg1_value; | 6738 | return arg1_value; |
| 5705 | | 6739 | |
| 5706 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); | 6740 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 5707 | IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope); | 6741 | IrInstSrc *arg2_value = ir_gen_node(irb, arg2_node, scope); |
| 5708 | if (arg2_value == irb->codegen->invalid_instruction) | 6742 | if (arg2_value == irb->codegen->invalid_inst_src) |
| 5709 | return arg2_value; | 6743 | return arg2_value; |
| 5710 | | 6744 | |
| 5711 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); | 6745 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); |
| 5712 | IrInstruction *arg3_value = ir_gen_node(irb, arg3_node, scope); | 6746 | IrInstSrc *arg3_value = ir_gen_node(irb, arg3_node, scope); |
| 5713 | if (arg3_value == irb->codegen->invalid_instruction) | 6747 | if (arg3_value == irb->codegen->invalid_inst_src) |
| 5714 | return arg3_value; | 6748 | return arg3_value; |
| 5715 | | 6749 | |
| 5716 | IrInstruction *shuffle_vector = ir_build_shuffle_vector(irb, scope, node, | 6750 | IrInstSrc *shuffle_vector = ir_build_shuffle_vector(irb, scope, node, |
| 5717 | arg0_value, arg1_value, arg2_value, arg3_value); | 6751 | arg0_value, arg1_value, arg2_value, arg3_value); |
| 5718 | return ir_lval_wrap(irb, scope, shuffle_vector, lval, result_loc); | 6752 | return ir_lval_wrap(irb, scope, shuffle_vector, lval, result_loc); |
| 5719 | } | 6753 | } |
| 5720 | case BuiltinFnIdSplat: | 6754 | case BuiltinFnIdSplat: |
| 5721 | { | 6755 | { |
| 5722 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6756 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5723 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6757 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5724 | if (arg0_value == irb->codegen->invalid_instruction) | 6758 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5725 | return arg0_value; | 6759 | return arg0_value; |
| 5726 | | 6760 | |
| 5727 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6761 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5728 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6762 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5729 | if (arg1_value == irb->codegen->invalid_instruction) | 6763 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5730 | return arg1_value; | 6764 | return arg1_value; |
| 5731 | | 6765 | |
| 5732 | IrInstruction *splat = ir_build_splat_src(irb, scope, node, | 6766 | IrInstSrc *splat = ir_build_splat_src(irb, scope, node, |
| 5733 | arg0_value, arg1_value); | 6767 | arg0_value, arg1_value); |
| 5734 | return ir_lval_wrap(irb, scope, splat, lval, result_loc); | 6768 | return ir_lval_wrap(irb, scope, splat, lval, result_loc); |
| 5735 | } | 6769 | } |
| 5736 | case BuiltinFnIdMemcpy: | 6770 | case BuiltinFnIdMemcpy: |
| 5737 | { | 6771 | { |
| 5738 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6772 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5739 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6773 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5740 | if (arg0_value == irb->codegen->invalid_instruction) | 6774 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5741 | return arg0_value; | 6775 | return arg0_value; |
| 5742 | | 6776 | |
| 5743 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6777 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5744 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6778 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5745 | if (arg1_value == irb->codegen->invalid_instruction) | 6779 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5746 | return arg1_value; | 6780 | return arg1_value; |
| 5747 | | 6781 | |
| 5748 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); | 6782 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 5749 | IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope); | 6783 | IrInstSrc *arg2_value = ir_gen_node(irb, arg2_node, scope); |
| 5750 | if (arg2_value == irb->codegen->invalid_instruction) | 6784 | if (arg2_value == irb->codegen->invalid_inst_src) |
| 5751 | return arg2_value; | 6785 | return arg2_value; |
| 5752 | | 6786 | |
| 5753 | IrInstruction *ir_memcpy = ir_build_memcpy(irb, scope, node, arg0_value, arg1_value, arg2_value); | 6787 | IrInstSrc *ir_memcpy = ir_build_memcpy_src(irb, scope, node, arg0_value, arg1_value, arg2_value); |
| 5754 | return ir_lval_wrap(irb, scope, ir_memcpy, lval, result_loc); | 6788 | return ir_lval_wrap(irb, scope, ir_memcpy, lval, result_loc); |
| 5755 | } | 6789 | } |
| 5756 | case BuiltinFnIdMemset: | 6790 | case BuiltinFnIdMemset: |
| 5757 | { | 6791 | { |
| 5758 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6792 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5759 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6793 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5760 | if (arg0_value == irb->codegen->invalid_instruction) | 6794 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5761 | return arg0_value; | 6795 | return arg0_value; |
| 5762 | | 6796 | |
| 5763 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6797 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5764 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6798 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5765 | if (arg1_value == irb->codegen->invalid_instruction) | 6799 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5766 | return arg1_value; | 6800 | return arg1_value; |
| 5767 | | 6801 | |
| 5768 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); | 6802 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 5769 | IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope); | 6803 | IrInstSrc *arg2_value = ir_gen_node(irb, arg2_node, scope); |
| 5770 | if (arg2_value == irb->codegen->invalid_instruction) | 6804 | if (arg2_value == irb->codegen->invalid_inst_src) |
| 5771 | return arg2_value; | 6805 | return arg2_value; |
| 5772 | | 6806 | |
| 5773 | IrInstruction *ir_memset = ir_build_memset(irb, scope, node, arg0_value, arg1_value, arg2_value); | 6807 | IrInstSrc *ir_memset = ir_build_memset_src(irb, scope, node, arg0_value, arg1_value, arg2_value); |
| 5774 | return ir_lval_wrap(irb, scope, ir_memset, lval, result_loc); | 6808 | return ir_lval_wrap(irb, scope, ir_memset, lval, result_loc); |
| 5775 | } | 6809 | } |
| 5776 | case BuiltinFnIdMemberCount: | 6810 | case BuiltinFnIdMemberCount: |
| 5777 | { | 6811 | { |
| 5778 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6812 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5779 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6813 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5780 | if (arg0_value == irb->codegen->invalid_instruction) | 6814 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5781 | return arg0_value; | 6815 | return arg0_value; |
| 5782 | | 6816 | |
| 5783 | IrInstruction *member_count = ir_build_member_count(irb, scope, node, arg0_value); | 6817 | IrInstSrc *member_count = ir_build_member_count(irb, scope, node, arg0_value); |
| 5784 | return ir_lval_wrap(irb, scope, member_count, lval, result_loc); | 6818 | return ir_lval_wrap(irb, scope, member_count, lval, result_loc); |
| 5785 | } | 6819 | } |
| 5786 | case BuiltinFnIdMemberType: | 6820 | case BuiltinFnIdMemberType: |
| 5787 | { | 6821 | { |
| 5788 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6822 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5789 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6823 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5790 | if (arg0_value == irb->codegen->invalid_instruction) | 6824 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5791 | return arg0_value; | 6825 | return arg0_value; |
| 5792 | | 6826 | |
| 5793 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6827 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5794 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6828 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5795 | if (arg1_value == irb->codegen->invalid_instruction) | 6829 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5796 | return arg1_value; | 6830 | return arg1_value; |
| 5797 | | 6831 | |
| 5798 | | 6832 | |
| 5799 | IrInstruction *member_type = ir_build_member_type(irb, scope, node, arg0_value, arg1_value); | 6833 | IrInstSrc *member_type = ir_build_member_type(irb, scope, node, arg0_value, arg1_value); |
| 5800 | return ir_lval_wrap(irb, scope, member_type, lval, result_loc); | 6834 | return ir_lval_wrap(irb, scope, member_type, lval, result_loc); |
| 5801 | } | 6835 | } |
| 5802 | case BuiltinFnIdMemberName: | 6836 | case BuiltinFnIdMemberName: |
| 5803 | { | 6837 | { |
| 5804 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6838 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5805 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6839 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5806 | if (arg0_value == irb->codegen->invalid_instruction) | 6840 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5807 | return arg0_value; | 6841 | return arg0_value; |
| 5808 | | 6842 | |
| 5809 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6843 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5810 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6844 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5811 | if (arg1_value == irb->codegen->invalid_instruction) | 6845 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5812 | return arg1_value; | 6846 | return arg1_value; |
| 5813 | | 6847 | |
| 5814 | | 6848 | |
| 5815 | IrInstruction *member_name = ir_build_member_name(irb, scope, node, arg0_value, arg1_value); | 6849 | IrInstSrc *member_name = ir_build_member_name(irb, scope, node, arg0_value, arg1_value); |
| 5816 | return ir_lval_wrap(irb, scope, member_name, lval, result_loc); | 6850 | return ir_lval_wrap(irb, scope, member_name, lval, result_loc); |
| 5817 | } | 6851 | } |
| 5818 | case BuiltinFnIdField: | 6852 | case BuiltinFnIdField: |
| 5819 | { | 6853 | { |
| 5820 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6854 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5821 | IrInstruction *arg0_value = ir_gen_node_extra(irb, arg0_node, scope, LValPtr, nullptr); | 6855 | IrInstSrc *arg0_value = ir_gen_node_extra(irb, arg0_node, scope, LValPtr, nullptr); |
| 5822 | if (arg0_value == irb->codegen->invalid_instruction) | 6856 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5823 | return arg0_value; | 6857 | return arg0_value; |
| 5824 | | 6858 | |
| 5825 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6859 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5826 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6860 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5827 | if (arg1_value == irb->codegen->invalid_instruction) | 6861 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5828 | return arg1_value; | 6862 | return arg1_value; |
| 5829 | | 6863 | |
| 5830 | IrInstruction *ptr_instruction = ir_build_field_ptr_instruction(irb, scope, node, | 6864 | IrInstSrc *ptr_instruction = ir_build_field_ptr_instruction(irb, scope, node, |
| 5831 | arg0_value, arg1_value, false); | 6865 | arg0_value, arg1_value, false); |
| 5832 | | 6866 | |
| 5833 | if (lval == LValPtr) | 6867 | if (lval == LValPtr) |
| 5834 | return ptr_instruction; | 6868 | return ptr_instruction; |
| 5835 | | 6869 | |
| 5836 | IrInstruction *load_ptr = ir_build_load_ptr(irb, scope, node, ptr_instruction); | 6870 | IrInstSrc *load_ptr = ir_build_load_ptr(irb, scope, node, ptr_instruction); |
| 5837 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); | 6871 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); |
| 5838 | } | 6872 | } |
| 5839 | case BuiltinFnIdHasField: | 6873 | case BuiltinFnIdHasField: |
| 5840 | { | 6874 | { |
| 5841 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6875 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5842 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6876 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5843 | if (arg0_value == irb->codegen->invalid_instruction) | 6877 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5844 | return arg0_value; | 6878 | return arg0_value; |
| 5845 | | 6879 | |
| 5846 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6880 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5847 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6881 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5848 | if (arg1_value == irb->codegen->invalid_instruction) | 6882 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5849 | return arg1_value; | 6883 | return arg1_value; |
| 5850 | | 6884 | |
| 5851 | IrInstruction *type_info = ir_build_has_field(irb, scope, node, arg0_value, arg1_value); | 6885 | IrInstSrc *type_info = ir_build_has_field(irb, scope, node, arg0_value, arg1_value); |
| 5852 | return ir_lval_wrap(irb, scope, type_info, lval, result_loc); | 6886 | return ir_lval_wrap(irb, scope, type_info, lval, result_loc); |
| 5853 | } | 6887 | } |
| 5854 | case BuiltinFnIdTypeInfo: | 6888 | case BuiltinFnIdTypeInfo: |
| 5855 | { | 6889 | { |
| 5856 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6890 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5857 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6891 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5858 | if (arg0_value == irb->codegen->invalid_instruction) | 6892 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5859 | return arg0_value; | 6893 | return arg0_value; |
| 5860 | | 6894 | |
| 5861 | IrInstruction *type_info = ir_build_type_info(irb, scope, node, arg0_value); | 6895 | IrInstSrc *type_info = ir_build_type_info(irb, scope, node, arg0_value); |
| 5862 | return ir_lval_wrap(irb, scope, type_info, lval, result_loc); | 6896 | return ir_lval_wrap(irb, scope, type_info, lval, result_loc); |
| 5863 | } | 6897 | } |
| 5864 | case BuiltinFnIdType: | 6898 | case BuiltinFnIdType: |
| 5865 | { | 6899 | { |
| 5866 | AstNode *arg_node = node->data.fn_call_expr.params.at(0); | 6900 | AstNode *arg_node = node->data.fn_call_expr.params.at(0); |
| 5867 | IrInstruction *arg = ir_gen_node(irb, arg_node, scope); | 6901 | IrInstSrc *arg = ir_gen_node(irb, arg_node, scope); |
| 5868 | if (arg == irb->codegen->invalid_instruction) | 6902 | if (arg == irb->codegen->invalid_inst_src) |
| 5869 | return arg; | 6903 | return arg; |
| 5870 | | 6904 | |
| 5871 | IrInstruction *type = ir_build_type(irb, scope, node, arg); | 6905 | IrInstSrc *type = ir_build_type(irb, scope, node, arg); |
| 5872 | return ir_lval_wrap(irb, scope, type, lval, result_loc); | 6906 | return ir_lval_wrap(irb, scope, type, lval, result_loc); |
| 5873 | } | 6907 | } |
| 5874 | case BuiltinFnIdBreakpoint: | 6908 | case BuiltinFnIdBreakpoint: |
| 5875 | return ir_lval_wrap(irb, scope, ir_build_breakpoint(irb, scope, node), lval, result_loc); | 6909 | return ir_lval_wrap(irb, scope, ir_build_breakpoint(irb, scope, node), lval, result_loc); |
| 5876 | case BuiltinFnIdReturnAddress: | 6910 | case BuiltinFnIdReturnAddress: |
| 5877 | return ir_lval_wrap(irb, scope, ir_build_return_address(irb, scope, node), lval, result_loc); | 6911 | return ir_lval_wrap(irb, scope, ir_build_return_address_src(irb, scope, node), lval, result_loc); |
| 5878 | case BuiltinFnIdFrameAddress: | 6912 | case BuiltinFnIdFrameAddress: |
| 5879 | return ir_lval_wrap(irb, scope, ir_build_frame_address(irb, scope, node), lval, result_loc); | 6913 | return ir_lval_wrap(irb, scope, ir_build_frame_address_src(irb, scope, node), lval, result_loc); |
| 5880 | case BuiltinFnIdFrameHandle: | 6914 | case BuiltinFnIdFrameHandle: |
| 5881 | if (!irb->exec->fn_entry) { | 6915 | if (!irb->exec->fn_entry) { |
| 5882 | add_node_error(irb->codegen, node, buf_sprintf("@frame() called outside of function definition")); | 6916 | add_node_error(irb->codegen, node, buf_sprintf("@frame() called outside of function definition")); |
| 5883 | return irb->codegen->invalid_instruction; | 6917 | return irb->codegen->invalid_inst_src; |
| 5884 | } | 6918 | } |
| 5885 | return ir_lval_wrap(irb, scope, ir_build_handle(irb, scope, node), lval, result_loc); | 6919 | return ir_lval_wrap(irb, scope, ir_build_handle_src(irb, scope, node), lval, result_loc); |
| 5886 | case BuiltinFnIdFrameType: { | 6920 | case BuiltinFnIdFrameType: { |
| 5887 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6921 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5888 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6922 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5889 | if (arg0_value == irb->codegen->invalid_instruction) | 6923 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5890 | return arg0_value; | 6924 | return arg0_value; |
| 5891 | | 6925 | |
| 5892 | IrInstruction *frame_type = ir_build_frame_type(irb, scope, node, arg0_value); | 6926 | IrInstSrc *frame_type = ir_build_frame_type(irb, scope, node, arg0_value); |
| 5893 | return ir_lval_wrap(irb, scope, frame_type, lval, result_loc); | 6927 | return ir_lval_wrap(irb, scope, frame_type, lval, result_loc); |
| 5894 | } | 6928 | } |
| 5895 | case BuiltinFnIdFrameSize: { | 6929 | case BuiltinFnIdFrameSize: { |
| 5896 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6930 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5897 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6931 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5898 | if (arg0_value == irb->codegen->invalid_instruction) | 6932 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5899 | return arg0_value; | 6933 | return arg0_value; |
| 5900 | | 6934 | |
| 5901 | IrInstruction *frame_size = ir_build_frame_size_src(irb, scope, node, arg0_value); | 6935 | IrInstSrc *frame_size = ir_build_frame_size_src(irb, scope, node, arg0_value); |
| 5902 | return ir_lval_wrap(irb, scope, frame_size, lval, result_loc); | 6936 | return ir_lval_wrap(irb, scope, frame_size, lval, result_loc); |
| 5903 | } | 6937 | } |
| 5904 | case BuiltinFnIdAlignOf: | 6938 | case BuiltinFnIdAlignOf: |
| 5905 | { | 6939 | { |
| 5906 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6940 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5907 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6941 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5908 | if (arg0_value == irb->codegen->invalid_instruction) | 6942 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5909 | return arg0_value; | 6943 | return arg0_value; |
| 5910 | | 6944 | |
| 5911 | IrInstruction *align_of = ir_build_align_of(irb, scope, node, arg0_value); | 6945 | IrInstSrc *align_of = ir_build_align_of(irb, scope, node, arg0_value); |
| 5912 | return ir_lval_wrap(irb, scope, align_of, lval, result_loc); | 6946 | return ir_lval_wrap(irb, scope, align_of, lval, result_loc); |
| 5913 | } | 6947 | } |
| 5914 | case BuiltinFnIdAddWithOverflow: | 6948 | case BuiltinFnIdAddWithOverflow: |
| ... | @@ -5924,43 +6958,43 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -5924,43 +6958,43 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 5924 | case BuiltinFnIdTypeName: | 6958 | case BuiltinFnIdTypeName: |
| 5925 | { | 6959 | { |
| 5926 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6960 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5927 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6961 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5928 | if (arg0_value == irb->codegen->invalid_instruction) | 6962 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5929 | return arg0_value; | 6963 | return arg0_value; |
| 5930 | | 6964 | |
| 5931 | IrInstruction *type_name = ir_build_type_name(irb, scope, node, arg0_value); | 6965 | IrInstSrc *type_name = ir_build_type_name(irb, scope, node, arg0_value); |
| 5932 | return ir_lval_wrap(irb, scope, type_name, lval, result_loc); | 6966 | return ir_lval_wrap(irb, scope, type_name, lval, result_loc); |
| 5933 | } | 6967 | } |
| 5934 | case BuiltinFnIdPanic: | 6968 | case BuiltinFnIdPanic: |
| 5935 | { | 6969 | { |
| 5936 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6970 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5937 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6971 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5938 | if (arg0_value == irb->codegen->invalid_instruction) | 6972 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5939 | return arg0_value; | 6973 | return arg0_value; |
| 5940 | | 6974 | |
| 5941 | IrInstruction *panic = ir_build_panic(irb, scope, node, arg0_value); | 6975 | IrInstSrc *panic = ir_build_panic_src(irb, scope, node, arg0_value); |
| 5942 | return ir_lval_wrap(irb, scope, panic, lval, result_loc); | 6976 | return ir_lval_wrap(irb, scope, panic, lval, result_loc); |
| 5943 | } | 6977 | } |
| 5944 | case BuiltinFnIdPtrCast: | 6978 | case BuiltinFnIdPtrCast: |
| 5945 | { | 6979 | { |
| 5946 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 6980 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 5947 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 6981 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 5948 | if (arg0_value == irb->codegen->invalid_instruction) | 6982 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 5949 | return arg0_value; | 6983 | return arg0_value; |
| 5950 | | 6984 | |
| 5951 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 6985 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5952 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 6986 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 5953 | if (arg1_value == irb->codegen->invalid_instruction) | 6987 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5954 | return arg1_value; | 6988 | return arg1_value; |
| 5955 | | 6989 | |
| 5956 | IrInstruction *ptr_cast = ir_build_ptr_cast_src(irb, scope, node, arg0_value, arg1_value, true); | 6990 | IrInstSrc *ptr_cast = ir_build_ptr_cast_src(irb, scope, node, arg0_value, arg1_value, true); |
| 5957 | return ir_lval_wrap(irb, scope, ptr_cast, lval, result_loc); | 6991 | return ir_lval_wrap(irb, scope, ptr_cast, lval, result_loc); |
| 5958 | } | 6992 | } |
| 5959 | case BuiltinFnIdBitCast: | 6993 | case BuiltinFnIdBitCast: |
| 5960 | { | 6994 | { |
| 5961 | AstNode *dest_type_node = node->data.fn_call_expr.params.at(0); | 6995 | AstNode *dest_type_node = node->data.fn_call_expr.params.at(0); |
| 5962 | IrInstruction *dest_type = ir_gen_node(irb, dest_type_node, scope); | 6996 | IrInstSrc *dest_type = ir_gen_node(irb, dest_type_node, scope); |
| 5963 | if (dest_type == irb->codegen->invalid_instruction) | 6997 | if (dest_type == irb->codegen->invalid_inst_src) |
| 5964 | return dest_type; | 6998 | return dest_type; |
| 5965 | | 6999 | |
| 5966 | ResultLocBitCast *result_loc_bit_cast = allocate<ResultLocBitCast>(1); | 7000 | ResultLocBitCast *result_loc_bit_cast = allocate<ResultLocBitCast>(1); |
| ... | @@ -5972,125 +7006,126 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -5972,125 +7006,126 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 5972 | ir_build_reset_result(irb, scope, node, &result_loc_bit_cast->base); | 7006 | ir_build_reset_result(irb, scope, node, &result_loc_bit_cast->base); |
| 5973 | | 7007 | |
| 5974 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7008 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5975 | IrInstruction *arg1_value = ir_gen_node_extra(irb, arg1_node, scope, LValNone, | 7009 | IrInstSrc *arg1_value = ir_gen_node_extra(irb, arg1_node, scope, LValNone, |
| 5976 | &result_loc_bit_cast->base); | 7010 | &result_loc_bit_cast->base); |
| 5977 | if (arg1_value == irb->codegen->invalid_instruction) | 7011 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5978 | return arg1_value; | 7012 | return arg1_value; |
| 5979 | | 7013 | |
| 5980 | IrInstruction *bitcast = ir_build_bit_cast_src(irb, scope, arg1_node, arg1_value, result_loc_bit_cast); | 7014 | IrInstSrc *bitcast = ir_build_bit_cast_src(irb, scope, arg1_node, arg1_value, result_loc_bit_cast); |
| 5981 | return ir_lval_wrap(irb, scope, bitcast, lval, result_loc); | 7015 | return ir_lval_wrap(irb, scope, bitcast, lval, result_loc); |
| 5982 | } | 7016 | } |
| 5983 | case BuiltinFnIdAs: | 7017 | case BuiltinFnIdAs: |
| 5984 | { | 7018 | { |
| 5985 | AstNode *dest_type_node = node->data.fn_call_expr.params.at(0); | 7019 | AstNode *dest_type_node = node->data.fn_call_expr.params.at(0); |
| 5986 | IrInstruction *dest_type = ir_gen_node(irb, dest_type_node, scope); | 7020 | IrInstSrc *dest_type = ir_gen_node(irb, dest_type_node, scope); |
| 5987 | if (dest_type == irb->codegen->invalid_instruction) | 7021 | if (dest_type == irb->codegen->invalid_inst_src) |
| 5988 | return dest_type; | 7022 | return dest_type; |
| 5989 | | 7023 | |
| 5990 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, dest_type, result_loc); | 7024 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, dest_type, result_loc); |
| 5991 | | 7025 | |
| 5992 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7026 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 5993 | IrInstruction *arg1_value = ir_gen_node_extra(irb, arg1_node, scope, LValNone, | 7027 | IrInstSrc *arg1_value = ir_gen_node_extra(irb, arg1_node, scope, LValNone, |
| 5994 | &result_loc_cast->base); | 7028 | &result_loc_cast->base); |
| 5995 | if (arg1_value == irb->codegen->invalid_instruction) | 7029 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 5996 | return arg1_value; | 7030 | return arg1_value; |
| 5997 | | 7031 | |
| 5998 | IrInstruction *result = ir_build_implicit_cast(irb, scope, node, arg1_value, result_loc_cast); | 7032 | IrInstSrc *result = ir_build_implicit_cast(irb, scope, node, arg1_value, result_loc_cast); |
| 5999 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 7033 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 6000 | } | 7034 | } |
| 6001 | case BuiltinFnIdIntToPtr: | 7035 | case BuiltinFnIdIntToPtr: |
| 6002 | { | 7036 | { |
| 6003 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7037 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6004 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7038 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6005 | if (arg0_value == irb->codegen->invalid_instruction) | 7039 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6006 | return arg0_value; | 7040 | return arg0_value; |
| 6007 | | 7041 | |
| 6008 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7042 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6009 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7043 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6010 | if (arg1_value == irb->codegen->invalid_instruction) | 7044 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6011 | return arg1_value; | 7045 | return arg1_value; |
| 6012 | | 7046 | |
| 6013 | IrInstruction *int_to_ptr = ir_build_int_to_ptr(irb, scope, node, arg0_value, arg1_value); | 7047 | IrInstSrc *int_to_ptr = ir_build_int_to_ptr_src(irb, scope, node, arg0_value, arg1_value); |
| 6014 | return ir_lval_wrap(irb, scope, int_to_ptr, lval, result_loc); | 7048 | return ir_lval_wrap(irb, scope, int_to_ptr, lval, result_loc); |
| 6015 | } | 7049 | } |
| 6016 | case BuiltinFnIdPtrToInt: | 7050 | case BuiltinFnIdPtrToInt: |
| 6017 | { | 7051 | { |
| 6018 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7052 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6019 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7053 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6020 | if (arg0_value == irb->codegen->invalid_instruction) | 7054 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6021 | return arg0_value; | 7055 | return arg0_value; |
| 6022 | | 7056 | |
| 6023 | IrInstruction *ptr_to_int = ir_build_ptr_to_int(irb, scope, node, arg0_value); | 7057 | IrInstSrc *ptr_to_int = ir_build_ptr_to_int_src(irb, scope, node, arg0_value); |
| 6024 | return ir_lval_wrap(irb, scope, ptr_to_int, lval, result_loc); | 7058 | return ir_lval_wrap(irb, scope, ptr_to_int, lval, result_loc); |
| 6025 | } | 7059 | } |
| 6026 | case BuiltinFnIdTagName: | 7060 | case BuiltinFnIdTagName: |
| 6027 | { | 7061 | { |
| 6028 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7062 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6029 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7063 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6030 | if (arg0_value == irb->codegen->invalid_instruction) | 7064 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6031 | return arg0_value; | 7065 | return arg0_value; |
| 6032 | | 7066 | |
| 6033 | IrInstruction *tag_name = ir_build_tag_name(irb, scope, node, arg0_value); | 7067 | IrInstSrc *tag_name = ir_build_tag_name_src(irb, scope, node, arg0_value); |
| 6034 | return ir_lval_wrap(irb, scope, tag_name, lval, result_loc); | 7068 | return ir_lval_wrap(irb, scope, tag_name, lval, result_loc); |
| 6035 | } | 7069 | } |
| 6036 | case BuiltinFnIdTagType: | 7070 | case BuiltinFnIdTagType: |
| 6037 | { | 7071 | { |
| 6038 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7072 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6039 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7073 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6040 | if (arg0_value == irb->codegen->invalid_instruction) | 7074 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6041 | return arg0_value; | 7075 | return arg0_value; |
| 6042 | | 7076 | |
| 6043 | IrInstruction *tag_type = ir_build_tag_type(irb, scope, node, arg0_value); | 7077 | IrInstSrc *tag_type = ir_build_tag_type(irb, scope, node, arg0_value); |
| 6044 | return ir_lval_wrap(irb, scope, tag_type, lval, result_loc); | 7078 | return ir_lval_wrap(irb, scope, tag_type, lval, result_loc); |
| 6045 | } | 7079 | } |
| 6046 | case BuiltinFnIdFieldParentPtr: | 7080 | case BuiltinFnIdFieldParentPtr: |
| 6047 | { | 7081 | { |
| 6048 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7082 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6049 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7083 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6050 | if (arg0_value == irb->codegen->invalid_instruction) | 7084 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6051 | return arg0_value; | 7085 | return arg0_value; |
| 6052 | | 7086 | |
| 6053 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7087 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6054 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7088 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6055 | if (arg1_value == irb->codegen->invalid_instruction) | 7089 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6056 | return arg1_value; | 7090 | return arg1_value; |
| 6057 | | 7091 | |
| 6058 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); | 7092 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 6059 | IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope); | 7093 | IrInstSrc *arg2_value = ir_gen_node(irb, arg2_node, scope); |
| 6060 | if (arg2_value == irb->codegen->invalid_instruction) | 7094 | if (arg2_value == irb->codegen->invalid_inst_src) |
| 6061 | return arg2_value; | 7095 | return arg2_value; |
| 6062 | | 7096 | |
| 6063 | IrInstruction *field_parent_ptr = ir_build_field_parent_ptr(irb, scope, node, arg0_value, arg1_value, arg2_value, nullptr); | 7097 | IrInstSrc *field_parent_ptr = ir_build_field_parent_ptr_src(irb, scope, node, |
| | 7098 | arg0_value, arg1_value, arg2_value); |
| 6064 | return ir_lval_wrap(irb, scope, field_parent_ptr, lval, result_loc); | 7099 | return ir_lval_wrap(irb, scope, field_parent_ptr, lval, result_loc); |
| 6065 | } | 7100 | } |
| 6066 | case BuiltinFnIdByteOffsetOf: | 7101 | case BuiltinFnIdByteOffsetOf: |
| 6067 | { | 7102 | { |
| 6068 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7103 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6069 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7104 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6070 | if (arg0_value == irb->codegen->invalid_instruction) | 7105 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6071 | return arg0_value; | 7106 | return arg0_value; |
| 6072 | | 7107 | |
| 6073 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7108 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6074 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7109 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6075 | if (arg1_value == irb->codegen->invalid_instruction) | 7110 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6076 | return arg1_value; | 7111 | return arg1_value; |
| 6077 | | 7112 | |
| 6078 | IrInstruction *offset_of = ir_build_byte_offset_of(irb, scope, node, arg0_value, arg1_value); | 7113 | IrInstSrc *offset_of = ir_build_byte_offset_of(irb, scope, node, arg0_value, arg1_value); |
| 6079 | return ir_lval_wrap(irb, scope, offset_of, lval, result_loc); | 7114 | return ir_lval_wrap(irb, scope, offset_of, lval, result_loc); |
| 6080 | } | 7115 | } |
| 6081 | case BuiltinFnIdBitOffsetOf: | 7116 | case BuiltinFnIdBitOffsetOf: |
| 6082 | { | 7117 | { |
| 6083 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7118 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6084 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7119 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6085 | if (arg0_value == irb->codegen->invalid_instruction) | 7120 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6086 | return arg0_value; | 7121 | return arg0_value; |
| 6087 | | 7122 | |
| 6088 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7123 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6089 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7124 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6090 | if (arg1_value == irb->codegen->invalid_instruction) | 7125 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6091 | return arg1_value; | 7126 | return arg1_value; |
| 6092 | | 7127 | |
| 6093 | IrInstruction *offset_of = ir_build_bit_offset_of(irb, scope, node, arg0_value, arg1_value); | 7128 | IrInstSrc *offset_of = ir_build_bit_offset_of(irb, scope, node, arg0_value, arg1_value); |
| 6094 | return ir_lval_wrap(irb, scope, offset_of, lval, result_loc); | 7129 | return ir_lval_wrap(irb, scope, offset_of, lval, result_loc); |
| 6095 | } | 7130 | } |
| 6096 | case BuiltinFnIdNewStackCall: | 7131 | case BuiltinFnIdNewStackCall: |
| ... | @@ -6099,45 +7134,45 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -6099,45 +7134,45 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 6099 | add_node_error(irb->codegen, node, | 7134 | add_node_error(irb->codegen, node, |
| 6100 | buf_sprintf("expected at least 2 arguments, found %" ZIG_PRI_usize, | 7135 | buf_sprintf("expected at least 2 arguments, found %" ZIG_PRI_usize, |
| 6101 | node->data.fn_call_expr.params.length)); | 7136 | node->data.fn_call_expr.params.length)); |
| 6102 | return irb->codegen->invalid_instruction; | 7137 | return irb->codegen->invalid_inst_src; |
| 6103 | } | 7138 | } |
| 6104 | | 7139 | |
| 6105 | AstNode *new_stack_node = node->data.fn_call_expr.params.at(0); | 7140 | AstNode *new_stack_node = node->data.fn_call_expr.params.at(0); |
| 6106 | IrInstruction *new_stack = ir_gen_node(irb, new_stack_node, scope); | 7141 | IrInstSrc *new_stack = ir_gen_node(irb, new_stack_node, scope); |
| 6107 | if (new_stack == irb->codegen->invalid_instruction) | 7142 | if (new_stack == irb->codegen->invalid_inst_src) |
| 6108 | return new_stack; | 7143 | return new_stack; |
| 6109 | | 7144 | |
| 6110 | AstNode *fn_ref_node = node->data.fn_call_expr.params.at(1); | 7145 | AstNode *fn_ref_node = node->data.fn_call_expr.params.at(1); |
| 6111 | IrInstruction *fn_ref = ir_gen_node(irb, fn_ref_node, scope); | 7146 | IrInstSrc *fn_ref = ir_gen_node(irb, fn_ref_node, scope); |
| 6112 | if (fn_ref == irb->codegen->invalid_instruction) | 7147 | if (fn_ref == irb->codegen->invalid_inst_src) |
| 6113 | return fn_ref; | 7148 | return fn_ref; |
| 6114 | | 7149 | |
| 6115 | size_t arg_count = node->data.fn_call_expr.params.length - 2; | 7150 | size_t arg_count = node->data.fn_call_expr.params.length - 2; |
| 6116 | | 7151 | |
| 6117 | IrInstruction **args = allocate<IrInstruction*>(arg_count); | 7152 | IrInstSrc **args = allocate<IrInstSrc*>(arg_count); |
| 6118 | for (size_t i = 0; i < arg_count; i += 1) { | 7153 | for (size_t i = 0; i < arg_count; i += 1) { |
| 6119 | AstNode *arg_node = node->data.fn_call_expr.params.at(i + 2); | 7154 | AstNode *arg_node = node->data.fn_call_expr.params.at(i + 2); |
| 6120 | args[i] = ir_gen_node(irb, arg_node, scope); | 7155 | args[i] = ir_gen_node(irb, arg_node, scope); |
| 6121 | if (args[i] == irb->codegen->invalid_instruction) | 7156 | if (args[i] == irb->codegen->invalid_inst_src) |
| 6122 | return args[i]; | 7157 | return args[i]; |
| 6123 | } | 7158 | } |
| 6124 | | 7159 | |
| 6125 | IrInstruction *call = ir_build_call_src(irb, scope, node, nullptr, fn_ref, arg_count, args, | 7160 | IrInstSrc *call = ir_build_call_src(irb, scope, node, nullptr, fn_ref, arg_count, args, |
| 6126 | nullptr, CallModifierNone, false, new_stack, result_loc); | 7161 | nullptr, CallModifierNone, false, new_stack, result_loc); |
| 6127 | return ir_lval_wrap(irb, scope, call, lval, result_loc); | 7162 | return ir_lval_wrap(irb, scope, call, lval, result_loc); |
| 6128 | } | 7163 | } |
| 6129 | case BuiltinFnIdCall: { | 7164 | case BuiltinFnIdCall: { |
| 6130 | // Cast the options parameter to the options type | 7165 | // Cast the options parameter to the options type |
| 6131 | ZigType *options_type = get_builtin_type(irb->codegen, "CallOptions"); | 7166 | ZigType *options_type = get_builtin_type(irb->codegen, "CallOptions"); |
| 6132 | IrInstruction *options_type_inst = ir_build_const_type(irb, scope, node, options_type); | 7167 | IrInstSrc *options_type_inst = ir_build_const_type(irb, scope, node, options_type); |
| 6133 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, options_type_inst, no_result_loc()); | 7168 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, options_type_inst, no_result_loc()); |
| 6134 | | 7169 | |
| 6135 | AstNode *options_node = node->data.fn_call_expr.params.at(0); | 7170 | AstNode *options_node = node->data.fn_call_expr.params.at(0); |
| 6136 | IrInstruction *options_inner = ir_gen_node_extra(irb, options_node, scope, | 7171 | IrInstSrc *options_inner = ir_gen_node_extra(irb, options_node, scope, |
| 6137 | LValNone, &result_loc_cast->base); | 7172 | LValNone, &result_loc_cast->base); |
| 6138 | if (options_inner == irb->codegen->invalid_instruction) | 7173 | if (options_inner == irb->codegen->invalid_inst_src) |
| 6139 | return options_inner; | 7174 | return options_inner; |
| 6140 | IrInstruction *options = ir_build_implicit_cast(irb, scope, options_node, options_inner, result_loc_cast); | 7175 | IrInstSrc *options = ir_build_implicit_cast(irb, scope, options_node, options_inner, result_loc_cast); |
| 6141 | | 7176 | |
| 6142 | AstNode *fn_ref_node = node->data.fn_call_expr.params.at(1); | 7177 | AstNode *fn_ref_node = node->data.fn_call_expr.params.at(1); |
| 6143 | AstNode *args_node = node->data.fn_call_expr.params.at(2); | 7178 | AstNode *args_node = node->data.fn_call_expr.params.at(2); |
| ... | @@ -6153,18 +7188,18 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -6153,18 +7188,18 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 6153 | } else { | 7188 | } else { |
| 6154 | exec_add_error_node(irb->codegen, irb->exec, args_node, | 7189 | exec_add_error_node(irb->codegen, irb->exec, args_node, |
| 6155 | buf_sprintf("TODO: @call with anon struct literal")); | 7190 | buf_sprintf("TODO: @call with anon struct literal")); |
| 6156 | return irb->codegen->invalid_instruction; | 7191 | return irb->codegen->invalid_inst_src; |
| 6157 | } | 7192 | } |
| 6158 | } else { | 7193 | } else { |
| 6159 | IrInstruction *fn_ref = ir_gen_node(irb, fn_ref_node, scope); | 7194 | IrInstSrc *fn_ref = ir_gen_node(irb, fn_ref_node, scope); |
| 6160 | if (fn_ref == irb->codegen->invalid_instruction) | 7195 | if (fn_ref == irb->codegen->invalid_inst_src) |
| 6161 | return fn_ref; | 7196 | return fn_ref; |
| 6162 | | 7197 | |
| 6163 | IrInstruction *args = ir_gen_node(irb, args_node, scope); | 7198 | IrInstSrc *args = ir_gen_node(irb, args_node, scope); |
| 6164 | if (args == irb->codegen->invalid_instruction) | 7199 | if (args == irb->codegen->invalid_inst_src) |
| 6165 | return args; | 7200 | return args; |
| 6166 | | 7201 | |
| 6167 | IrInstruction *call = ir_build_call_extra(irb, scope, node, options, fn_ref, args, result_loc); | 7202 | IrInstSrc *call = ir_build_call_extra(irb, scope, node, options, fn_ref, args, result_loc); |
| 6168 | return ir_lval_wrap(irb, scope, call, lval, result_loc); | 7203 | return ir_lval_wrap(irb, scope, call, lval, result_loc); |
| 6169 | } | 7204 | } |
| 6170 | } | 7205 | } |
| ... | @@ -6173,237 +7208,233 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -6173,237 +7208,233 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 6173 | case BuiltinFnIdTypeId: | 7208 | case BuiltinFnIdTypeId: |
| 6174 | { | 7209 | { |
| 6175 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7210 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6176 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7211 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6177 | if (arg0_value == irb->codegen->invalid_instruction) | 7212 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6178 | return arg0_value; | 7213 | return arg0_value; |
| 6179 | | 7214 | |
| 6180 | IrInstruction *type_id = ir_build_type_id(irb, scope, node, arg0_value); | 7215 | IrInstSrc *type_id = ir_build_type_id(irb, scope, node, arg0_value); |
| 6181 | return ir_lval_wrap(irb, scope, type_id, lval, result_loc); | 7216 | return ir_lval_wrap(irb, scope, type_id, lval, result_loc); |
| 6182 | } | 7217 | } |
| 6183 | case BuiltinFnIdShlExact: | 7218 | case BuiltinFnIdShlExact: |
| 6184 | { | 7219 | { |
| 6185 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7220 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6186 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7221 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6187 | if (arg0_value == irb->codegen->invalid_instruction) | 7222 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6188 | return arg0_value; | 7223 | return arg0_value; |
| 6189 | | 7224 | |
| 6190 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7225 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6191 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7226 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6192 | if (arg1_value == irb->codegen->invalid_instruction) | 7227 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6193 | return arg1_value; | 7228 | return arg1_value; |
| 6194 | | 7229 | |
| 6195 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpBitShiftLeftExact, arg0_value, arg1_value, true); | 7230 | IrInstSrc *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpBitShiftLeftExact, arg0_value, arg1_value, true); |
| 6196 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); | 7231 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); |
| 6197 | } | 7232 | } |
| 6198 | case BuiltinFnIdShrExact: | 7233 | case BuiltinFnIdShrExact: |
| 6199 | { | 7234 | { |
| 6200 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7235 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6201 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7236 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6202 | if (arg0_value == irb->codegen->invalid_instruction) | 7237 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6203 | return arg0_value; | 7238 | return arg0_value; |
| 6204 | | 7239 | |
| 6205 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7240 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6206 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7241 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6207 | if (arg1_value == irb->codegen->invalid_instruction) | 7242 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6208 | return arg1_value; | 7243 | return arg1_value; |
| 6209 | | 7244 | |
| 6210 | IrInstruction *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpBitShiftRightExact, arg0_value, arg1_value, true); | 7245 | IrInstSrc *bin_op = ir_build_bin_op(irb, scope, node, IrBinOpBitShiftRightExact, arg0_value, arg1_value, true); |
| 6211 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); | 7246 | return ir_lval_wrap(irb, scope, bin_op, lval, result_loc); |
| 6212 | } | 7247 | } |
| 6213 | case BuiltinFnIdSetEvalBranchQuota: | 7248 | case BuiltinFnIdSetEvalBranchQuota: |
| 6214 | { | 7249 | { |
| 6215 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7250 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6216 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7251 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6217 | if (arg0_value == irb->codegen->invalid_instruction) | 7252 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6218 | return arg0_value; | 7253 | return arg0_value; |
| 6219 | | 7254 | |
| 6220 | IrInstruction *set_eval_branch_quota = ir_build_set_eval_branch_quota(irb, scope, node, arg0_value); | 7255 | IrInstSrc *set_eval_branch_quota = ir_build_set_eval_branch_quota(irb, scope, node, arg0_value); |
| 6221 | return ir_lval_wrap(irb, scope, set_eval_branch_quota, lval, result_loc); | 7256 | return ir_lval_wrap(irb, scope, set_eval_branch_quota, lval, result_loc); |
| 6222 | } | 7257 | } |
| 6223 | case BuiltinFnIdAlignCast: | 7258 | case BuiltinFnIdAlignCast: |
| 6224 | { | 7259 | { |
| 6225 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7260 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6226 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7261 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6227 | if (arg0_value == irb->codegen->invalid_instruction) | 7262 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6228 | return arg0_value; | 7263 | return arg0_value; |
| 6229 | | 7264 | |
| 6230 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7265 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6231 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7266 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6232 | if (arg1_value == irb->codegen->invalid_instruction) | 7267 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6233 | return arg1_value; | 7268 | return arg1_value; |
| 6234 | | 7269 | |
| 6235 | IrInstruction *align_cast = ir_build_align_cast(irb, scope, node, arg0_value, arg1_value); | 7270 | IrInstSrc *align_cast = ir_build_align_cast_src(irb, scope, node, arg0_value, arg1_value); |
| 6236 | return ir_lval_wrap(irb, scope, align_cast, lval, result_loc); | 7271 | return ir_lval_wrap(irb, scope, align_cast, lval, result_loc); |
| 6237 | } | 7272 | } |
| 6238 | case BuiltinFnIdOpaqueType: | 7273 | case BuiltinFnIdOpaqueType: |
| 6239 | { | 7274 | { |
| 6240 | IrInstruction *opaque_type = ir_build_opaque_type(irb, scope, node); | 7275 | IrInstSrc *opaque_type = ir_build_opaque_type(irb, scope, node); |
| 6241 | return ir_lval_wrap(irb, scope, opaque_type, lval, result_loc); | 7276 | return ir_lval_wrap(irb, scope, opaque_type, lval, result_loc); |
| 6242 | } | 7277 | } |
| 6243 | case BuiltinFnIdThis: | 7278 | case BuiltinFnIdThis: |
| 6244 | { | 7279 | { |
| 6245 | IrInstruction *this_inst = ir_gen_this(irb, scope, node); | 7280 | IrInstSrc *this_inst = ir_gen_this(irb, scope, node); |
| 6246 | return ir_lval_wrap(irb, scope, this_inst, lval, result_loc); | 7281 | return ir_lval_wrap(irb, scope, this_inst, lval, result_loc); |
| 6247 | } | 7282 | } |
| 6248 | case BuiltinFnIdSetAlignStack: | 7283 | case BuiltinFnIdSetAlignStack: |
| 6249 | { | 7284 | { |
| 6250 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7285 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6251 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7286 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6252 | if (arg0_value == irb->codegen->invalid_instruction) | 7287 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6253 | return arg0_value; | 7288 | return arg0_value; |
| 6254 | | 7289 | |
| 6255 | IrInstruction *set_align_stack = ir_build_set_align_stack(irb, scope, node, arg0_value); | 7290 | IrInstSrc *set_align_stack = ir_build_set_align_stack(irb, scope, node, arg0_value); |
| 6256 | return ir_lval_wrap(irb, scope, set_align_stack, lval, result_loc); | 7291 | return ir_lval_wrap(irb, scope, set_align_stack, lval, result_loc); |
| 6257 | } | 7292 | } |
| 6258 | case BuiltinFnIdArgType: | 7293 | case BuiltinFnIdArgType: |
| 6259 | { | 7294 | { |
| 6260 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7295 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6261 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7296 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6262 | if (arg0_value == irb->codegen->invalid_instruction) | 7297 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6263 | return arg0_value; | 7298 | return arg0_value; |
| 6264 | | 7299 | |
| 6265 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7300 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6266 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7301 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6267 | if (arg1_value == irb->codegen->invalid_instruction) | 7302 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6268 | return arg1_value; | 7303 | return arg1_value; |
| 6269 | | 7304 | |
| 6270 | IrInstruction *arg_type = ir_build_arg_type(irb, scope, node, arg0_value, arg1_value, false); | 7305 | IrInstSrc *arg_type = ir_build_arg_type(irb, scope, node, arg0_value, arg1_value, false); |
| 6271 | return ir_lval_wrap(irb, scope, arg_type, lval, result_loc); | 7306 | return ir_lval_wrap(irb, scope, arg_type, lval, result_loc); |
| 6272 | } | 7307 | } |
| 6273 | case BuiltinFnIdExport: | 7308 | case BuiltinFnIdExport: |
| 6274 | { | 7309 | { |
| 6275 | // Cast the options parameter to the options type | 7310 | // Cast the options parameter to the options type |
| 6276 | ZigType *options_type = get_builtin_type(irb->codegen, "ExportOptions"); | 7311 | ZigType *options_type = get_builtin_type(irb->codegen, "ExportOptions"); |
| 6277 | IrInstruction *options_type_inst = ir_build_const_type(irb, scope, node, options_type); | 7312 | IrInstSrc *options_type_inst = ir_build_const_type(irb, scope, node, options_type); |
| 6278 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, options_type_inst, no_result_loc()); | 7313 | ResultLocCast *result_loc_cast = ir_build_cast_result_loc(irb, options_type_inst, no_result_loc()); |
| 6279 | | 7314 | |
| 6280 | AstNode *target_node = node->data.fn_call_expr.params.at(0); | 7315 | AstNode *target_node = node->data.fn_call_expr.params.at(0); |
| 6281 | IrInstruction *target_value = ir_gen_node(irb, target_node, scope); | 7316 | IrInstSrc *target_value = ir_gen_node(irb, target_node, scope); |
| 6282 | if (target_value == irb->codegen->invalid_instruction) | 7317 | if (target_value == irb->codegen->invalid_inst_src) |
| 6283 | return target_value; | 7318 | return target_value; |
| 6284 | | 7319 | |
| 6285 | AstNode *options_node = node->data.fn_call_expr.params.at(1); | 7320 | AstNode *options_node = node->data.fn_call_expr.params.at(1); |
| 6286 | IrInstruction *options_value = ir_gen_node_extra(irb, options_node, | 7321 | IrInstSrc *options_value = ir_gen_node_extra(irb, options_node, |
| 6287 | scope, LValNone, &result_loc_cast->base); | 7322 | scope, LValNone, &result_loc_cast->base); |
| 6288 | if (options_value == irb->codegen->invalid_instruction) | 7323 | if (options_value == irb->codegen->invalid_inst_src) |
| 6289 | return options_value; | 7324 | return options_value; |
| 6290 | | 7325 | |
| 6291 | IrInstruction *casted_options_value = ir_build_implicit_cast( | 7326 | IrInstSrc *casted_options_value = ir_build_implicit_cast( |
| 6292 | irb, scope, options_node, options_value, result_loc_cast); | 7327 | irb, scope, options_node, options_value, result_loc_cast); |
| 6293 | | 7328 | |
| 6294 | IrInstruction *ir_export = ir_build_export(irb, scope, node, target_value, casted_options_value); | 7329 | IrInstSrc *ir_export = ir_build_export(irb, scope, node, target_value, casted_options_value); |
| 6295 | return ir_lval_wrap(irb, scope, ir_export, lval, result_loc); | 7330 | return ir_lval_wrap(irb, scope, ir_export, lval, result_loc); |
| 6296 | } | 7331 | } |
| 6297 | case BuiltinFnIdErrorReturnTrace: | 7332 | case BuiltinFnIdErrorReturnTrace: |
| 6298 | { | 7333 | { |
| 6299 | IrInstruction *error_return_trace = ir_build_error_return_trace(irb, scope, node, IrInstructionErrorReturnTrace::Null); | 7334 | IrInstSrc *error_return_trace = ir_build_error_return_trace_src(irb, scope, node, |
| | 7335 | IrInstErrorReturnTraceNull); |
| 6300 | return ir_lval_wrap(irb, scope, error_return_trace, lval, result_loc); | 7336 | return ir_lval_wrap(irb, scope, error_return_trace, lval, result_loc); |
| 6301 | } | 7337 | } |
| 6302 | case BuiltinFnIdAtomicRmw: | 7338 | case BuiltinFnIdAtomicRmw: |
| 6303 | { | 7339 | { |
| 6304 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7340 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6305 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7341 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6306 | if (arg0_value == irb->codegen->invalid_instruction) | 7342 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6307 | return arg0_value; | 7343 | return arg0_value; |
| 6308 | | 7344 | |
| 6309 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7345 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6310 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7346 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6311 | if (arg1_value == irb->codegen->invalid_instruction) | 7347 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6312 | return arg1_value; | 7348 | return arg1_value; |
| 6313 | | 7349 | |
| 6314 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); | 7350 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 6315 | IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope); | 7351 | IrInstSrc *arg2_value = ir_gen_node(irb, arg2_node, scope); |
| 6316 | if (arg2_value == irb->codegen->invalid_instruction) | 7352 | if (arg2_value == irb->codegen->invalid_inst_src) |
| 6317 | return arg2_value; | 7353 | return arg2_value; |
| 6318 | | 7354 | |
| 6319 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); | 7355 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); |
| 6320 | IrInstruction *arg3_value = ir_gen_node(irb, arg3_node, scope); | 7356 | IrInstSrc *arg3_value = ir_gen_node(irb, arg3_node, scope); |
| 6321 | if (arg3_value == irb->codegen->invalid_instruction) | 7357 | if (arg3_value == irb->codegen->invalid_inst_src) |
| 6322 | return arg3_value; | 7358 | return arg3_value; |
| 6323 | | 7359 | |
| 6324 | AstNode *arg4_node = node->data.fn_call_expr.params.at(4); | 7360 | AstNode *arg4_node = node->data.fn_call_expr.params.at(4); |
| 6325 | IrInstruction *arg4_value = ir_gen_node(irb, arg4_node, scope); | 7361 | IrInstSrc *arg4_value = ir_gen_node(irb, arg4_node, scope); |
| 6326 | if (arg4_value == irb->codegen->invalid_instruction) | 7362 | if (arg4_value == irb->codegen->invalid_inst_src) |
| 6327 | return arg4_value; | 7363 | return arg4_value; |
| 6328 | | 7364 | |
| 6329 | IrInstruction *inst = ir_build_atomic_rmw(irb, scope, node, arg0_value, arg1_value, arg2_value, arg3_value, | 7365 | IrInstSrc *inst = ir_build_atomic_rmw_src(irb, scope, node, |
| 6330 | arg4_value, | 7366 | arg0_value, arg1_value, arg2_value, arg3_value, arg4_value); |
| 6331 | // these 2 values don't mean anything since we passed non-null values for other args | | |
| 6332 | AtomicRmwOp_xchg, AtomicOrderMonotonic); | | |
| 6333 | return ir_lval_wrap(irb, scope, inst, lval, result_loc); | 7367 | return ir_lval_wrap(irb, scope, inst, lval, result_loc); |
| 6334 | } | 7368 | } |
| 6335 | case BuiltinFnIdAtomicLoad: | 7369 | case BuiltinFnIdAtomicLoad: |
| 6336 | { | 7370 | { |
| 6337 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7371 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6338 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7372 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6339 | if (arg0_value == irb->codegen->invalid_instruction) | 7373 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6340 | return arg0_value; | 7374 | return arg0_value; |
| 6341 | | 7375 | |
| 6342 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7376 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6343 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7377 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6344 | if (arg1_value == irb->codegen->invalid_instruction) | 7378 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6345 | return arg1_value; | 7379 | return arg1_value; |
| 6346 | | 7380 | |
| 6347 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); | 7381 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 6348 | IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope); | 7382 | IrInstSrc *arg2_value = ir_gen_node(irb, arg2_node, scope); |
| 6349 | if (arg2_value == irb->codegen->invalid_instruction) | 7383 | if (arg2_value == irb->codegen->invalid_inst_src) |
| 6350 | return arg2_value; | 7384 | return arg2_value; |
| 6351 | | 7385 | |
| 6352 | IrInstruction *inst = ir_build_atomic_load(irb, scope, node, arg0_value, arg1_value, arg2_value, | 7386 | IrInstSrc *inst = ir_build_atomic_load_src(irb, scope, node, arg0_value, arg1_value, arg2_value); |
| 6353 | // this value does not mean anything since we passed non-null values for other arg | | |
| 6354 | AtomicOrderMonotonic); | | |
| 6355 | return ir_lval_wrap(irb, scope, inst, lval, result_loc); | 7387 | return ir_lval_wrap(irb, scope, inst, lval, result_loc); |
| 6356 | } | 7388 | } |
| 6357 | case BuiltinFnIdAtomicStore: | 7389 | case BuiltinFnIdAtomicStore: |
| 6358 | { | 7390 | { |
| 6359 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7391 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6360 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7392 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6361 | if (arg0_value == irb->codegen->invalid_instruction) | 7393 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6362 | return arg0_value; | 7394 | return arg0_value; |
| 6363 | | 7395 | |
| 6364 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7396 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6365 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7397 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6366 | if (arg1_value == irb->codegen->invalid_instruction) | 7398 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6367 | return arg1_value; | 7399 | return arg1_value; |
| 6368 | | 7400 | |
| 6369 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); | 7401 | AstNode *arg2_node = node->data.fn_call_expr.params.at(2); |
| 6370 | IrInstruction *arg2_value = ir_gen_node(irb, arg2_node, scope); | 7402 | IrInstSrc *arg2_value = ir_gen_node(irb, arg2_node, scope); |
| 6371 | if (arg2_value == irb->codegen->invalid_instruction) | 7403 | if (arg2_value == irb->codegen->invalid_inst_src) |
| 6372 | return arg2_value; | 7404 | return arg2_value; |
| 6373 | | 7405 | |
| 6374 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); | 7406 | AstNode *arg3_node = node->data.fn_call_expr.params.at(3); |
| 6375 | IrInstruction *arg3_value = ir_gen_node(irb, arg3_node, scope); | 7407 | IrInstSrc *arg3_value = ir_gen_node(irb, arg3_node, scope); |
| 6376 | if (arg3_value == irb->codegen->invalid_instruction) | 7408 | if (arg3_value == irb->codegen->invalid_inst_src) |
| 6377 | return arg3_value; | 7409 | return arg3_value; |
| 6378 | | 7410 | |
| 6379 | IrInstruction *inst = ir_build_atomic_store(irb, scope, node, arg0_value, arg1_value, arg2_value, arg3_value, | 7411 | IrInstSrc *inst = ir_build_atomic_store_src(irb, scope, node, arg0_value, arg1_value, |
| 6380 | // this value does not mean anything since we passed non-null values for other arg | 7412 | arg2_value, arg3_value); |
| 6381 | AtomicOrderMonotonic); | | |
| 6382 | return ir_lval_wrap(irb, scope, inst, lval, result_loc); | 7413 | return ir_lval_wrap(irb, scope, inst, lval, result_loc); |
| 6383 | } | 7414 | } |
| 6384 | case BuiltinFnIdIntToEnum: | 7415 | case BuiltinFnIdIntToEnum: |
| 6385 | { | 7416 | { |
| 6386 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7417 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6387 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7418 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6388 | if (arg0_value == irb->codegen->invalid_instruction) | 7419 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6389 | return arg0_value; | 7420 | return arg0_value; |
| 6390 | | 7421 | |
| 6391 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7422 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6392 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7423 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6393 | if (arg1_value == irb->codegen->invalid_instruction) | 7424 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6394 | return arg1_value; | 7425 | return arg1_value; |
| 6395 | | 7426 | |
| 6396 | IrInstruction *result = ir_build_int_to_enum(irb, scope, node, arg0_value, arg1_value); | 7427 | IrInstSrc *result = ir_build_int_to_enum_src(irb, scope, node, arg0_value, arg1_value); |
| 6397 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 7428 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 6398 | } | 7429 | } |
| 6399 | case BuiltinFnIdEnumToInt: | 7430 | case BuiltinFnIdEnumToInt: |
| 6400 | { | 7431 | { |
| 6401 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7432 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6402 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7433 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6403 | if (arg0_value == irb->codegen->invalid_instruction) | 7434 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6404 | return arg0_value; | 7435 | return arg0_value; |
| 6405 | | 7436 | |
| 6406 | IrInstruction *result = ir_build_enum_to_int(irb, scope, node, arg0_value); | 7437 | IrInstSrc *result = ir_build_enum_to_int(irb, scope, node, arg0_value); |
| 6407 | return ir_lval_wrap(irb, scope, result, lval, result_loc); | 7438 | return ir_lval_wrap(irb, scope, result, lval, result_loc); |
| 6408 | } | 7439 | } |
| 6409 | case BuiltinFnIdCtz: | 7440 | case BuiltinFnIdCtz: |
| ... | @@ -6413,16 +7444,16 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -6413,16 +7444,16 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 6413 | case BuiltinFnIdBitReverse: | 7444 | case BuiltinFnIdBitReverse: |
| 6414 | { | 7445 | { |
| 6415 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7446 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6416 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7447 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6417 | if (arg0_value == irb->codegen->invalid_instruction) | 7448 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6418 | return arg0_value; | 7449 | return arg0_value; |
| 6419 | | 7450 | |
| 6420 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7451 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6421 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7452 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6422 | if (arg1_value == irb->codegen->invalid_instruction) | 7453 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6423 | return arg1_value; | 7454 | return arg1_value; |
| 6424 | | 7455 | |
| 6425 | IrInstruction *result; | 7456 | IrInstSrc *result; |
| 6426 | switch (builtin_fn->id) { | 7457 | switch (builtin_fn->id) { |
| 6427 | case BuiltinFnIdCtz: | 7458 | case BuiltinFnIdCtz: |
| 6428 | result = ir_build_ctz(irb, scope, node, arg0_value, arg1_value); | 7459 | result = ir_build_ctz(irb, scope, node, arg0_value, arg1_value); |
| ... | @@ -6447,28 +7478,28 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -6447,28 +7478,28 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 6447 | case BuiltinFnIdHasDecl: | 7478 | case BuiltinFnIdHasDecl: |
| 6448 | { | 7479 | { |
| 6449 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); | 7480 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| 6450 | IrInstruction *arg0_value = ir_gen_node(irb, arg0_node, scope); | 7481 | IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope); |
| 6451 | if (arg0_value == irb->codegen->invalid_instruction) | 7482 | if (arg0_value == irb->codegen->invalid_inst_src) |
| 6452 | return arg0_value; | 7483 | return arg0_value; |
| 6453 | | 7484 | |
| 6454 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); | 7485 | AstNode *arg1_node = node->data.fn_call_expr.params.at(1); |
| 6455 | IrInstruction *arg1_value = ir_gen_node(irb, arg1_node, scope); | 7486 | IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope); |
| 6456 | if (arg1_value == irb->codegen->invalid_instruction) | 7487 | if (arg1_value == irb->codegen->invalid_inst_src) |
| 6457 | return arg1_value; | 7488 | return arg1_value; |
| 6458 | | 7489 | |
| 6459 | IrInstruction *has_decl = ir_build_has_decl(irb, scope, node, arg0_value, arg1_value); | 7490 | IrInstSrc *has_decl = ir_build_has_decl(irb, scope, node, arg0_value, arg1_value); |
| 6460 | return ir_lval_wrap(irb, scope, has_decl, lval, result_loc); | 7491 | return ir_lval_wrap(irb, scope, has_decl, lval, result_loc); |
| 6461 | } | 7492 | } |
| 6462 | case BuiltinFnIdUnionInit: | 7493 | case BuiltinFnIdUnionInit: |
| 6463 | { | 7494 | { |
| 6464 | AstNode *union_type_node = node->data.fn_call_expr.params.at(0); | 7495 | AstNode *union_type_node = node->data.fn_call_expr.params.at(0); |
| 6465 | IrInstruction *union_type_inst = ir_gen_node(irb, union_type_node, scope); | 7496 | IrInstSrc *union_type_inst = ir_gen_node(irb, union_type_node, scope); |
| 6466 | if (union_type_inst == irb->codegen->invalid_instruction) | 7497 | if (union_type_inst == irb->codegen->invalid_inst_src) |
| 6467 | return union_type_inst; | 7498 | return union_type_inst; |
| 6468 | | 7499 | |
| 6469 | AstNode *name_node = node->data.fn_call_expr.params.at(1); | 7500 | AstNode *name_node = node->data.fn_call_expr.params.at(1); |
| 6470 | IrInstruction *name_inst = ir_gen_node(irb, name_node, scope); | 7501 | IrInstSrc *name_inst = ir_gen_node(irb, name_node, scope); |
| 6471 | if (name_inst == irb->codegen->invalid_instruction) | 7502 | if (name_inst == irb->codegen->invalid_inst_src) |
| 6472 | return name_inst; | 7503 | return name_inst; |
| 6473 | | 7504 | |
| 6474 | AstNode *init_node = node->data.fn_call_expr.params.at(2); | 7505 | AstNode *init_node = node->data.fn_call_expr.params.at(2); |
| ... | @@ -6480,7 +7511,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -6480,7 +7511,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 6480 | zig_unreachable(); | 7511 | zig_unreachable(); |
| 6481 | } | 7512 | } |
| 6482 | | 7513 | |
| 6483 | static IrInstruction *ir_gen_fn_call(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 7514 | static IrInstSrc *ir_gen_fn_call(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 6484 | ResultLoc *result_loc) | 7515 | ResultLoc *result_loc) |
| 6485 | { | 7516 | { |
| 6486 | assert(node->type == NodeTypeFnCallExpr); | 7517 | assert(node->type == NodeTypeFnCallExpr); |
| ... | @@ -6493,16 +7524,16 @@ static IrInstruction *ir_gen_fn_call(IrBuilder *irb, Scope *scope, AstNode *node | ... | @@ -6493,16 +7524,16 @@ static IrInstruction *ir_gen_fn_call(IrBuilder *irb, Scope *scope, AstNode *node |
| 6493 | nullptr, node->data.fn_call_expr.params.items, node->data.fn_call_expr.params.length, lval, result_loc); | 7524 | nullptr, node->data.fn_call_expr.params.items, node->data.fn_call_expr.params.length, lval, result_loc); |
| 6494 | } | 7525 | } |
| 6495 | | 7526 | |
| 6496 | static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 7527 | static IrInstSrc *ir_gen_if_bool_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 6497 | ResultLoc *result_loc) | 7528 | ResultLoc *result_loc) |
| 6498 | { | 7529 | { |
| 6499 | assert(node->type == NodeTypeIfBoolExpr); | 7530 | assert(node->type == NodeTypeIfBoolExpr); |
| 6500 | | 7531 | |
| 6501 | IrInstruction *condition = ir_gen_node(irb, node->data.if_bool_expr.condition, scope); | 7532 | IrInstSrc *condition = ir_gen_node(irb, node->data.if_bool_expr.condition, scope); |
| 6502 | if (condition == irb->codegen->invalid_instruction) | 7533 | if (condition == irb->codegen->invalid_inst_src) |
| 6503 | return irb->codegen->invalid_instruction; | 7534 | return irb->codegen->invalid_inst_src; |
| 6504 | | 7535 | |
| 6505 | IrInstruction *is_comptime; | 7536 | IrInstSrc *is_comptime; |
| 6506 | if (ir_should_inline(irb->exec, scope)) { | 7537 | if (ir_should_inline(irb->exec, scope)) { |
| 6507 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 7538 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 6508 | } else { | 7539 | } else { |
| ... | @@ -6512,11 +7543,11 @@ static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -6512,11 +7543,11 @@ static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode |
| 6512 | AstNode *then_node = node->data.if_bool_expr.then_block; | 7543 | AstNode *then_node = node->data.if_bool_expr.then_block; |
| 6513 | AstNode *else_node = node->data.if_bool_expr.else_node; | 7544 | AstNode *else_node = node->data.if_bool_expr.else_node; |
| 6514 | | 7545 | |
| 6515 | IrBasicBlock *then_block = ir_create_basic_block(irb, scope, "Then"); | 7546 | IrBasicBlockSrc *then_block = ir_create_basic_block(irb, scope, "Then"); |
| 6516 | IrBasicBlock *else_block = ir_create_basic_block(irb, scope, "Else"); | 7547 | IrBasicBlockSrc *else_block = ir_create_basic_block(irb, scope, "Else"); |
| 6517 | IrBasicBlock *endif_block = ir_create_basic_block(irb, scope, "EndIf"); | 7548 | IrBasicBlockSrc *endif_block = ir_create_basic_block(irb, scope, "EndIf"); |
| 6518 | | 7549 | |
| 6519 | IrInstruction *cond_br_inst = ir_build_cond_br(irb, scope, node, condition, | 7550 | IrInstSrc *cond_br_inst = ir_build_cond_br(irb, scope, node, condition, |
| 6520 | then_block, else_block, is_comptime); | 7551 | then_block, else_block, is_comptime); |
| 6521 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, else_block, endif_block, | 7552 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, else_block, endif_block, |
| 6522 | result_loc, is_comptime); | 7553 | result_loc, is_comptime); |
| ... | @@ -6524,70 +7555,70 @@ static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -6524,70 +7555,70 @@ static IrInstruction *ir_gen_if_bool_expr(IrBuilder *irb, Scope *scope, AstNode |
| 6524 | ir_set_cursor_at_end_and_append_block(irb, then_block); | 7555 | ir_set_cursor_at_end_and_append_block(irb, then_block); |
| 6525 | | 7556 | |
| 6526 | Scope *subexpr_scope = create_runtime_scope(irb->codegen, node, scope, is_comptime); | 7557 | Scope *subexpr_scope = create_runtime_scope(irb->codegen, node, scope, is_comptime); |
| 6527 | IrInstruction *then_expr_result = ir_gen_node_extra(irb, then_node, subexpr_scope, lval, | 7558 | IrInstSrc *then_expr_result = ir_gen_node_extra(irb, then_node, subexpr_scope, lval, |
| 6528 | &peer_parent->peers.at(0)->base); | 7559 | &peer_parent->peers.at(0)->base); |
| 6529 | if (then_expr_result == irb->codegen->invalid_instruction) | 7560 | if (then_expr_result == irb->codegen->invalid_inst_src) |
| 6530 | return irb->codegen->invalid_instruction; | 7561 | return irb->codegen->invalid_inst_src; |
| 6531 | IrBasicBlock *after_then_block = irb->current_basic_block; | 7562 | IrBasicBlockSrc *after_then_block = irb->current_basic_block; |
| 6532 | if (!instr_is_unreachable(then_expr_result)) | 7563 | if (!instr_is_unreachable(then_expr_result)) |
| 6533 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); | 7564 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); |
| 6534 | | 7565 | |
| 6535 | ir_set_cursor_at_end_and_append_block(irb, else_block); | 7566 | ir_set_cursor_at_end_and_append_block(irb, else_block); |
| 6536 | IrInstruction *else_expr_result; | 7567 | IrInstSrc *else_expr_result; |
| 6537 | if (else_node) { | 7568 | if (else_node) { |
| 6538 | else_expr_result = ir_gen_node_extra(irb, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base); | 7569 | else_expr_result = ir_gen_node_extra(irb, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base); |
| 6539 | if (else_expr_result == irb->codegen->invalid_instruction) | 7570 | if (else_expr_result == irb->codegen->invalid_inst_src) |
| 6540 | return irb->codegen->invalid_instruction; | 7571 | return irb->codegen->invalid_inst_src; |
| 6541 | } else { | 7572 | } else { |
| 6542 | else_expr_result = ir_build_const_void(irb, scope, node); | 7573 | else_expr_result = ir_build_const_void(irb, scope, node); |
| 6543 | ir_build_end_expr(irb, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); | 7574 | ir_build_end_expr(irb, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); |
| 6544 | } | 7575 | } |
| 6545 | IrBasicBlock *after_else_block = irb->current_basic_block; | 7576 | IrBasicBlockSrc *after_else_block = irb->current_basic_block; |
| 6546 | if (!instr_is_unreachable(else_expr_result)) | 7577 | if (!instr_is_unreachable(else_expr_result)) |
| 6547 | 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)); |
| 6548 | | 7579 | |
| 6549 | ir_set_cursor_at_end_and_append_block(irb, endif_block); | 7580 | ir_set_cursor_at_end_and_append_block(irb, endif_block); |
| 6550 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 7581 | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 6551 | incoming_values[0] = then_expr_result; | 7582 | incoming_values[0] = then_expr_result; |
| 6552 | incoming_values[1] = else_expr_result; | 7583 | incoming_values[1] = else_expr_result; |
| 6553 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); | 7584 | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 6554 | incoming_blocks[0] = after_then_block; | 7585 | incoming_blocks[0] = after_then_block; |
| 6555 | incoming_blocks[1] = after_else_block; | 7586 | incoming_blocks[1] = after_else_block; |
| 6556 | | 7587 | |
| 6557 | IrInstruction *phi = ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, peer_parent); | 7588 | IrInstSrc *phi = ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, peer_parent); |
| 6558 | return ir_expr_wrap(irb, scope, phi, result_loc); | 7589 | return ir_expr_wrap(irb, scope, phi, result_loc); |
| 6559 | } | 7590 | } |
| 6560 | | 7591 | |
| 6561 | static IrInstruction *ir_gen_prefix_op_id_lval(IrBuilder *irb, Scope *scope, AstNode *node, IrUnOp op_id, LVal lval) { | 7592 | static IrInstSrc *ir_gen_prefix_op_id_lval(IrBuilderSrc *irb, Scope *scope, AstNode *node, IrUnOp op_id, LVal lval) { |
| 6562 | assert(node->type == NodeTypePrefixOpExpr); | 7593 | assert(node->type == NodeTypePrefixOpExpr); |
| 6563 | AstNode *expr_node = node->data.prefix_op_expr.primary_expr; | 7594 | AstNode *expr_node = node->data.prefix_op_expr.primary_expr; |
| 6564 | | 7595 | |
| 6565 | IrInstruction *value = ir_gen_node_extra(irb, expr_node, scope, lval, nullptr); | 7596 | IrInstSrc *value = ir_gen_node_extra(irb, expr_node, scope, lval, nullptr); |
| 6566 | if (value == irb->codegen->invalid_instruction) | 7597 | if (value == irb->codegen->invalid_inst_src) |
| 6567 | return value; | 7598 | return value; |
| 6568 | | 7599 | |
| 6569 | return ir_build_un_op(irb, scope, node, op_id, value); | 7600 | return ir_build_un_op(irb, scope, node, op_id, value); |
| 6570 | } | 7601 | } |
| 6571 | | 7602 | |
| 6572 | static IrInstruction *ir_gen_prefix_op_id(IrBuilder *irb, Scope *scope, AstNode *node, IrUnOp op_id) { | 7603 | static IrInstSrc *ir_gen_prefix_op_id(IrBuilderSrc *irb, Scope *scope, AstNode *node, IrUnOp op_id) { |
| 6573 | return ir_gen_prefix_op_id_lval(irb, scope, node, op_id, LValNone); | 7604 | return ir_gen_prefix_op_id_lval(irb, scope, node, op_id, LValNone); |
| 6574 | } | 7605 | } |
| 6575 | | 7606 | |
| 6576 | static IrInstruction *ir_expr_wrap(IrBuilder *irb, Scope *scope, IrInstruction *inst, ResultLoc *result_loc) { | 7607 | static IrInstSrc *ir_expr_wrap(IrBuilderSrc *irb, Scope *scope, IrInstSrc *inst, ResultLoc *result_loc) { |
| 6577 | if (inst == irb->codegen->invalid_instruction) return inst; | 7608 | if (inst == irb->codegen->invalid_inst_src) return inst; |
| 6578 | ir_build_end_expr(irb, scope, inst->source_node, inst, result_loc); | 7609 | ir_build_end_expr(irb, scope, inst->base.source_node, inst, result_loc); |
| 6579 | return inst; | 7610 | return inst; |
| 6580 | } | 7611 | } |
| 6581 | | 7612 | |
| 6582 | static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction *value, LVal lval, | 7613 | static IrInstSrc *ir_lval_wrap(IrBuilderSrc *irb, Scope *scope, IrInstSrc *value, LVal lval, |
| 6583 | ResultLoc *result_loc) | 7614 | ResultLoc *result_loc) |
| 6584 | { | 7615 | { |
| 6585 | // This logic must be kept in sync with | 7616 | // This logic must be kept in sync with |
| 6586 | // [STMT_EXPR_TEST_THING] <--- (search this token) | 7617 | // [STMT_EXPR_TEST_THING] <--- (search this token) |
| 6587 | if (value == irb->codegen->invalid_instruction || | 7618 | if (value == irb->codegen->invalid_inst_src || |
| 6588 | instr_is_unreachable(value) || | 7619 | instr_is_unreachable(value) || |
| 6589 | value->source_node->type == NodeTypeDefer || | 7620 | value->base.source_node->type == NodeTypeDefer || |
| 6590 | value->id == IrInstructionIdDeclVarSrc) | 7621 | value->id == IrInstSrcIdDeclVar) |
| 6591 | { | 7622 | { |
| 6592 | return value; | 7623 | return value; |
| 6593 | } | 7624 | } |
| ... | @@ -6595,7 +7626,7 @@ static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction * | ... | @@ -6595,7 +7626,7 @@ static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction * |
| 6595 | if (lval == LValPtr) { | 7626 | if (lval == LValPtr) { |
| 6596 | // We needed a pointer to a value, but we got a value. So we create | 7627 | // We needed a pointer to a value, but we got a value. So we create |
| 6597 | // an instruction which just makes a pointer of it. | 7628 | // an instruction which just makes a pointer of it. |
| 6598 | return ir_build_ref(irb, scope, value->source_node, value, false, false); | 7629 | return ir_build_ref_src(irb, scope, value->base.source_node, value, false, false); |
| 6599 | } else if (result_loc != nullptr) { | 7630 | } else if (result_loc != nullptr) { |
| 6600 | return ir_expr_wrap(irb, scope, value, result_loc); | 7631 | return ir_expr_wrap(irb, scope, value, result_loc); |
| 6601 | } else { | 7632 | } else { |
| ... | @@ -6618,7 +7649,7 @@ static PtrLen star_token_to_ptr_len(TokenId token_id) { | ... | @@ -6618,7 +7649,7 @@ static PtrLen star_token_to_ptr_len(TokenId token_id) { |
| 6618 | } | 7649 | } |
| 6619 | } | 7650 | } |
| 6620 | | 7651 | |
| 6621 | static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode *node) { | 7652 | static IrInstSrc *ir_gen_pointer_type(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 6622 | assert(node->type == NodeTypePointerType); | 7653 | assert(node->type == NodeTypePointerType); |
| 6623 | | 7654 | |
| 6624 | PtrLen ptr_len = star_token_to_ptr_len(node->data.pointer_type.star_token->id); | 7655 | PtrLen ptr_len = star_token_to_ptr_len(node->data.pointer_type.star_token->id); |
| ... | @@ -6630,26 +7661,26 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -6630,26 +7661,26 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode |
| 6630 | AstNode *expr_node = node->data.pointer_type.op_expr; | 7661 | AstNode *expr_node = node->data.pointer_type.op_expr; |
| 6631 | AstNode *align_expr = node->data.pointer_type.align_expr; | 7662 | AstNode *align_expr = node->data.pointer_type.align_expr; |
| 6632 | | 7663 | |
| 6633 | IrInstruction *sentinel; | 7664 | IrInstSrc *sentinel; |
| 6634 | if (sentinel_expr != nullptr) { | 7665 | if (sentinel_expr != nullptr) { |
| 6635 | sentinel = ir_gen_node(irb, sentinel_expr, scope); | 7666 | sentinel = ir_gen_node(irb, sentinel_expr, scope); |
| 6636 | if (sentinel == irb->codegen->invalid_instruction) | 7667 | if (sentinel == irb->codegen->invalid_inst_src) |
| 6637 | return sentinel; | 7668 | return sentinel; |
| 6638 | } else { | 7669 | } else { |
| 6639 | sentinel = nullptr; | 7670 | sentinel = nullptr; |
| 6640 | } | 7671 | } |
| 6641 | | 7672 | |
| 6642 | IrInstruction *align_value; | 7673 | IrInstSrc *align_value; |
| 6643 | if (align_expr != nullptr) { | 7674 | if (align_expr != nullptr) { |
| 6644 | align_value = ir_gen_node(irb, align_expr, scope); | 7675 | align_value = ir_gen_node(irb, align_expr, scope); |
| 6645 | if (align_value == irb->codegen->invalid_instruction) | 7676 | if (align_value == irb->codegen->invalid_inst_src) |
| 6646 | return align_value; | 7677 | return align_value; |
| 6647 | } else { | 7678 | } else { |
| 6648 | align_value = nullptr; | 7679 | align_value = nullptr; |
| 6649 | } | 7680 | } |
| 6650 | | 7681 | |
| 6651 | IrInstruction *child_type = ir_gen_node(irb, expr_node, scope); | 7682 | IrInstSrc *child_type = ir_gen_node(irb, expr_node, scope); |
| 6652 | if (child_type == irb->codegen->invalid_instruction) | 7683 | if (child_type == irb->codegen->invalid_inst_src) |
| 6653 | return child_type; | 7684 | return child_type; |
| 6654 | | 7685 | |
| 6655 | uint32_t bit_offset_start = 0; | 7686 | uint32_t bit_offset_start = 0; |
| ... | @@ -6659,7 +7690,7 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -6659,7 +7690,7 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode |
| 6659 | bigint_append_buf(val_buf, node->data.pointer_type.bit_offset_start, 10); | 7690 | bigint_append_buf(val_buf, node->data.pointer_type.bit_offset_start, 10); |
| 6660 | exec_add_error_node(irb->codegen, irb->exec, node, | 7691 | exec_add_error_node(irb->codegen, irb->exec, node, |
| 6661 | buf_sprintf("value %s too large for u32 bit offset", buf_ptr(val_buf))); | 7692 | buf_sprintf("value %s too large for u32 bit offset", buf_ptr(val_buf))); |
| 6662 | return irb->codegen->invalid_instruction; | 7693 | return irb->codegen->invalid_inst_src; |
| 6663 | } | 7694 | } |
| 6664 | bit_offset_start = bigint_as_u32(node->data.pointer_type.bit_offset_start); | 7695 | bit_offset_start = bigint_as_u32(node->data.pointer_type.bit_offset_start); |
| 6665 | } | 7696 | } |
| ... | @@ -6671,7 +7702,7 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -6671,7 +7702,7 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode |
| 6671 | bigint_append_buf(val_buf, node->data.pointer_type.host_int_bytes, 10); | 7702 | bigint_append_buf(val_buf, node->data.pointer_type.host_int_bytes, 10); |
| 6672 | exec_add_error_node(irb->codegen, irb->exec, node, | 7703 | exec_add_error_node(irb->codegen, irb->exec, node, |
| 6673 | buf_sprintf("value %s too large for u32 byte count", buf_ptr(val_buf))); | 7704 | buf_sprintf("value %s too large for u32 byte count", buf_ptr(val_buf))); |
| 6674 | return irb->codegen->invalid_instruction; | 7705 | return irb->codegen->invalid_inst_src; |
| 6675 | } | 7706 | } |
| 6676 | host_int_bytes = bigint_as_u32(node->data.pointer_type.host_int_bytes); | 7707 | host_int_bytes = bigint_as_u32(node->data.pointer_type.host_int_bytes); |
| 6677 | } | 7708 | } |
| ... | @@ -6679,43 +7710,43 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -6679,43 +7710,43 @@ static IrInstruction *ir_gen_pointer_type(IrBuilder *irb, Scope *scope, AstNode |
| 6679 | if (host_int_bytes != 0 && bit_offset_start >= host_int_bytes * 8) { | 7710 | if (host_int_bytes != 0 && bit_offset_start >= host_int_bytes * 8) { |
| 6680 | exec_add_error_node(irb->codegen, irb->exec, node, | 7711 | exec_add_error_node(irb->codegen, irb->exec, node, |
| 6681 | buf_sprintf("bit offset starts after end of host integer")); | 7712 | buf_sprintf("bit offset starts after end of host integer")); |
| 6682 | return irb->codegen->invalid_instruction; | 7713 | return irb->codegen->invalid_inst_src; |
| 6683 | } | 7714 | } |
| 6684 | | 7715 | |
| 6685 | return ir_build_ptr_type(irb, scope, node, child_type, is_const, is_volatile, | 7716 | return ir_build_ptr_type(irb, scope, node, child_type, is_const, is_volatile, |
| 6686 | ptr_len, sentinel, align_value, bit_offset_start, host_int_bytes, is_allow_zero); | 7717 | ptr_len, sentinel, align_value, bit_offset_start, host_int_bytes, is_allow_zero); |
| 6687 | } | 7718 | } |
| 6688 | | 7719 | |
| 6689 | static IrInstruction *ir_gen_catch_unreachable(IrBuilder *irb, Scope *scope, AstNode *source_node, | 7720 | static IrInstSrc *ir_gen_catch_unreachable(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 6690 | AstNode *expr_node, LVal lval, ResultLoc *result_loc) | 7721 | AstNode *expr_node, LVal lval, ResultLoc *result_loc) |
| 6691 | { | 7722 | { |
| 6692 | IrInstruction *err_union_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); | 7723 | IrInstSrc *err_union_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); |
| 6693 | if (err_union_ptr == irb->codegen->invalid_instruction) | 7724 | if (err_union_ptr == irb->codegen->invalid_inst_src) |
| 6694 | return irb->codegen->invalid_instruction; | 7725 | return irb->codegen->invalid_inst_src; |
| 6695 | | 7726 | |
| 6696 | IrInstruction *payload_ptr = ir_build_unwrap_err_payload(irb, scope, source_node, err_union_ptr, true, false); | 7727 | IrInstSrc *payload_ptr = ir_build_unwrap_err_payload_src(irb, scope, source_node, err_union_ptr, true, false); |
| 6697 | if (payload_ptr == irb->codegen->invalid_instruction) | 7728 | if (payload_ptr == irb->codegen->invalid_inst_src) |
| 6698 | return irb->codegen->invalid_instruction; | 7729 | return irb->codegen->invalid_inst_src; |
| 6699 | | 7730 | |
| 6700 | if (lval == LValPtr) | 7731 | if (lval == LValPtr) |
| 6701 | return payload_ptr; | 7732 | return payload_ptr; |
| 6702 | | 7733 | |
| 6703 | IrInstruction *load_ptr = ir_build_load_ptr(irb, scope, source_node, payload_ptr); | 7734 | IrInstSrc *load_ptr = ir_build_load_ptr(irb, scope, source_node, payload_ptr); |
| 6704 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); | 7735 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); |
| 6705 | } | 7736 | } |
| 6706 | | 7737 | |
| 6707 | static IrInstruction *ir_gen_bool_not(IrBuilder *irb, Scope *scope, AstNode *node) { | 7738 | static IrInstSrc *ir_gen_bool_not(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 6708 | assert(node->type == NodeTypePrefixOpExpr); | 7739 | assert(node->type == NodeTypePrefixOpExpr); |
| 6709 | AstNode *expr_node = node->data.prefix_op_expr.primary_expr; | 7740 | AstNode *expr_node = node->data.prefix_op_expr.primary_expr; |
| 6710 | | 7741 | |
| 6711 | IrInstruction *value = ir_gen_node(irb, expr_node, scope); | 7742 | IrInstSrc *value = ir_gen_node(irb, expr_node, scope); |
| 6712 | if (value == irb->codegen->invalid_instruction) | 7743 | if (value == irb->codegen->invalid_inst_src) |
| 6713 | return irb->codegen->invalid_instruction; | 7744 | return irb->codegen->invalid_inst_src; |
| 6714 | | 7745 | |
| 6715 | return ir_build_bool_not(irb, scope, node, value); | 7746 | return ir_build_bool_not(irb, scope, node, value); |
| 6716 | } | 7747 | } |
| 6717 | | 7748 | |
| 6718 | static IrInstruction *ir_gen_prefix_op_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 7749 | static IrInstSrc *ir_gen_prefix_op_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 6719 | ResultLoc *result_loc) | 7750 | ResultLoc *result_loc) |
| 6720 | { | 7751 | { |
| 6721 | assert(node->type == NodeTypePrefixOpExpr); | 7752 | assert(node->type == NodeTypePrefixOpExpr); |
| ... | @@ -6743,12 +7774,12 @@ static IrInstruction *ir_gen_prefix_op_expr(IrBuilder *irb, Scope *scope, AstNod | ... | @@ -6743,12 +7774,12 @@ static IrInstruction *ir_gen_prefix_op_expr(IrBuilder *irb, Scope *scope, AstNod |
| 6743 | zig_unreachable(); | 7774 | zig_unreachable(); |
| 6744 | } | 7775 | } |
| 6745 | | 7776 | |
| 6746 | static IrInstruction *ir_gen_union_init_expr(IrBuilder *irb, Scope *scope, AstNode *source_node, | 7777 | static IrInstSrc *ir_gen_union_init_expr(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, |
| 6747 | IrInstruction *union_type, IrInstruction *field_name, AstNode *expr_node, | 7778 | IrInstSrc *union_type, IrInstSrc *field_name, AstNode *expr_node, |
| 6748 | LVal lval, ResultLoc *parent_result_loc) | 7779 | LVal lval, ResultLoc *parent_result_loc) |
| 6749 | { | 7780 | { |
| 6750 | IrInstruction *container_ptr = ir_build_resolve_result(irb, scope, source_node, parent_result_loc, union_type); | 7781 | IrInstSrc *container_ptr = ir_build_resolve_result(irb, scope, source_node, parent_result_loc, union_type); |
| 6751 | IrInstruction *field_ptr = ir_build_field_ptr_instruction(irb, scope, source_node, container_ptr, | 7782 | IrInstSrc *field_ptr = ir_build_field_ptr_instruction(irb, scope, source_node, container_ptr, |
| 6752 | field_name, true); | 7783 | field_name, true); |
| 6753 | | 7784 | |
| 6754 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); | 7785 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); |
| ... | @@ -6757,18 +7788,18 @@ static IrInstruction *ir_gen_union_init_expr(IrBuilder *irb, Scope *scope, AstNo | ... | @@ -6757,18 +7788,18 @@ static IrInstruction *ir_gen_union_init_expr(IrBuilder *irb, Scope *scope, AstNo |
| 6757 | ir_ref_instruction(field_ptr, irb->current_basic_block); | 7788 | ir_ref_instruction(field_ptr, irb->current_basic_block); |
| 6758 | ir_build_reset_result(irb, scope, expr_node, &result_loc_inst->base); | 7789 | ir_build_reset_result(irb, scope, expr_node, &result_loc_inst->base); |
| 6759 | | 7790 | |
| 6760 | IrInstruction *expr_value = ir_gen_node_extra(irb, expr_node, scope, LValNone, | 7791 | IrInstSrc *expr_value = ir_gen_node_extra(irb, expr_node, scope, LValNone, |
| 6761 | &result_loc_inst->base); | 7792 | &result_loc_inst->base); |
| 6762 | if (expr_value == irb->codegen->invalid_instruction) | 7793 | if (expr_value == irb->codegen->invalid_inst_src) |
| 6763 | return expr_value; | 7794 | return expr_value; |
| 6764 | | 7795 | |
| 6765 | IrInstruction *init_union = ir_build_union_init_named_field(irb, scope, source_node, union_type, | 7796 | IrInstSrc *init_union = ir_build_union_init_named_field(irb, scope, source_node, union_type, |
| 6766 | field_name, field_ptr, container_ptr); | 7797 | field_name, field_ptr, container_ptr); |
| 6767 | | 7798 | |
| 6768 | return ir_lval_wrap(irb, scope, init_union, lval, parent_result_loc); | 7799 | return ir_lval_wrap(irb, scope, init_union, lval, parent_result_loc); |
| 6769 | } | 7800 | } |
| 6770 | | 7801 | |
| 6771 | static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 7802 | static IrInstSrc *ir_gen_container_init_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 6772 | ResultLoc *parent_result_loc) | 7803 | ResultLoc *parent_result_loc) |
| 6773 | { | 7804 | { |
| 6774 | assert(node->type == NodeTypeContainerInitExpr); | 7805 | assert(node->type == NodeTypeContainerInitExpr); |
| ... | @@ -6780,42 +7811,42 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A | ... | @@ -6780,42 +7811,42 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 6780 | ResultLoc *child_result_loc; | 7811 | ResultLoc *child_result_loc; |
| 6781 | AstNode *init_array_type_source_node; | 7812 | AstNode *init_array_type_source_node; |
| 6782 | if (container_init_expr->type != nullptr) { | 7813 | if (container_init_expr->type != nullptr) { |
| 6783 | IrInstruction *container_type; | 7814 | IrInstSrc *container_type; |
| 6784 | if (container_init_expr->type->type == NodeTypeInferredArrayType) { | 7815 | if (container_init_expr->type->type == NodeTypeInferredArrayType) { |
| 6785 | if (kind == ContainerInitKindStruct) { | 7816 | if (kind == ContainerInitKindStruct) { |
| 6786 | add_node_error(irb->codegen, container_init_expr->type, | 7817 | add_node_error(irb->codegen, container_init_expr->type, |
| 6787 | buf_sprintf("initializing array with struct syntax")); | 7818 | buf_sprintf("initializing array with struct syntax")); |
| 6788 | return irb->codegen->invalid_instruction; | 7819 | return irb->codegen->invalid_inst_src; |
| 6789 | } | 7820 | } |
| 6790 | IrInstruction *sentinel; | 7821 | IrInstSrc *sentinel; |
| 6791 | if (container_init_expr->type->data.inferred_array_type.sentinel != nullptr) { | 7822 | if (container_init_expr->type->data.inferred_array_type.sentinel != nullptr) { |
| 6792 | sentinel = ir_gen_node(irb, container_init_expr->type->data.inferred_array_type.sentinel, scope); | 7823 | sentinel = ir_gen_node(irb, container_init_expr->type->data.inferred_array_type.sentinel, scope); |
| 6793 | if (sentinel == irb->codegen->invalid_instruction) | 7824 | if (sentinel == irb->codegen->invalid_inst_src) |
| 6794 | return sentinel; | 7825 | return sentinel; |
| 6795 | } else { | 7826 | } else { |
| 6796 | sentinel = nullptr; | 7827 | sentinel = nullptr; |
| 6797 | } | 7828 | } |
| 6798 | | 7829 | |
| 6799 | IrInstruction *elem_type = ir_gen_node(irb, | 7830 | IrInstSrc *elem_type = ir_gen_node(irb, |
| 6800 | container_init_expr->type->data.inferred_array_type.child_type, scope); | 7831 | container_init_expr->type->data.inferred_array_type.child_type, scope); |
| 6801 | if (elem_type == irb->codegen->invalid_instruction) | 7832 | if (elem_type == irb->codegen->invalid_inst_src) |
| 6802 | return elem_type; | 7833 | return elem_type; |
| 6803 | size_t item_count = container_init_expr->entries.length; | 7834 | size_t item_count = container_init_expr->entries.length; |
| 6804 | IrInstruction *item_count_inst = ir_build_const_usize(irb, scope, node, item_count); | 7835 | IrInstSrc *item_count_inst = ir_build_const_usize(irb, scope, node, item_count); |
| 6805 | container_type = ir_build_array_type(irb, scope, node, item_count_inst, sentinel, elem_type); | 7836 | container_type = ir_build_array_type(irb, scope, node, item_count_inst, sentinel, elem_type); |
| 6806 | } else { | 7837 | } else { |
| 6807 | container_type = ir_gen_node(irb, container_init_expr->type, scope); | 7838 | container_type = ir_gen_node(irb, container_init_expr->type, scope); |
| 6808 | if (container_type == irb->codegen->invalid_instruction) | 7839 | if (container_type == irb->codegen->invalid_inst_src) |
| 6809 | return container_type; | 7840 | return container_type; |
| 6810 | } | 7841 | } |
| 6811 | | 7842 | |
| 6812 | result_loc_cast = ir_build_cast_result_loc(irb, container_type, parent_result_loc); | 7843 | result_loc_cast = ir_build_cast_result_loc(irb, container_type, parent_result_loc); |
| 6813 | child_result_loc = &result_loc_cast->base; | 7844 | child_result_loc = &result_loc_cast->base; |
| 6814 | init_array_type_source_node = container_type->source_node; | 7845 | init_array_type_source_node = container_type->base.source_node; |
| 6815 | } else { | 7846 | } else { |
| 6816 | child_result_loc = parent_result_loc; | 7847 | child_result_loc = parent_result_loc; |
| 6817 | if (parent_result_loc->source_instruction != nullptr) { | 7848 | if (parent_result_loc->source_instruction != nullptr) { |
| 6818 | init_array_type_source_node = parent_result_loc->source_instruction->source_node; | 7849 | init_array_type_source_node = parent_result_loc->source_instruction->base.source_node; |
| 6819 | } else { | 7850 | } else { |
| 6820 | init_array_type_source_node = node; | 7851 | init_array_type_source_node = node; |
| 6821 | } | 7852 | } |
| ... | @@ -6823,11 +7854,11 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A | ... | @@ -6823,11 +7854,11 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 6823 | | 7854 | |
| 6824 | switch (kind) { | 7855 | switch (kind) { |
| 6825 | case ContainerInitKindStruct: { | 7856 | case ContainerInitKindStruct: { |
| 6826 | IrInstruction *container_ptr = ir_build_resolve_result(irb, scope, node, child_result_loc, | 7857 | IrInstSrc *container_ptr = ir_build_resolve_result(irb, scope, node, child_result_loc, |
| 6827 | nullptr); | 7858 | nullptr); |
| 6828 | | 7859 | |
| 6829 | size_t field_count = container_init_expr->entries.length; | 7860 | size_t field_count = container_init_expr->entries.length; |
| 6830 | IrInstructionContainerInitFieldsField *fields = allocate<IrInstructionContainerInitFieldsField>(field_count); | 7861 | IrInstSrcContainerInitFieldsField *fields = allocate<IrInstSrcContainerInitFieldsField>(field_count); |
| 6831 | for (size_t i = 0; i < field_count; i += 1) { | 7862 | for (size_t i = 0; i < field_count; i += 1) { |
| 6832 | AstNode *entry_node = container_init_expr->entries.at(i); | 7863 | AstNode *entry_node = container_init_expr->entries.at(i); |
| 6833 | assert(entry_node->type == NodeTypeStructValueField); | 7864 | assert(entry_node->type == NodeTypeStructValueField); |
| ... | @@ -6835,7 +7866,7 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A | ... | @@ -6835,7 +7866,7 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 6835 | Buf *name = entry_node->data.struct_val_field.name; | 7866 | Buf *name = entry_node->data.struct_val_field.name; |
| 6836 | AstNode *expr_node = entry_node->data.struct_val_field.expr; | 7867 | AstNode *expr_node = entry_node->data.struct_val_field.expr; |
| 6837 | | 7868 | |
| 6838 | IrInstruction *field_ptr = ir_build_field_ptr(irb, scope, entry_node, container_ptr, name, true); | 7869 | IrInstSrc *field_ptr = ir_build_field_ptr(irb, scope, entry_node, container_ptr, name, true); |
| 6839 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); | 7870 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); |
| 6840 | result_loc_inst->base.id = ResultLocIdInstruction; | 7871 | result_loc_inst->base.id = ResultLocIdInstruction; |
| 6841 | result_loc_inst->base.source_instruction = field_ptr; | 7872 | result_loc_inst->base.source_instruction = field_ptr; |
| ... | @@ -6843,16 +7874,16 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A | ... | @@ -6843,16 +7874,16 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 6843 | ir_ref_instruction(field_ptr, irb->current_basic_block); | 7874 | ir_ref_instruction(field_ptr, irb->current_basic_block); |
| 6844 | ir_build_reset_result(irb, scope, expr_node, &result_loc_inst->base); | 7875 | ir_build_reset_result(irb, scope, expr_node, &result_loc_inst->base); |
| 6845 | | 7876 | |
| 6846 | IrInstruction *expr_value = ir_gen_node_extra(irb, expr_node, scope, LValNone, | 7877 | IrInstSrc *expr_value = ir_gen_node_extra(irb, expr_node, scope, LValNone, |
| 6847 | &result_loc_inst->base); | 7878 | &result_loc_inst->base); |
| 6848 | if (expr_value == irb->codegen->invalid_instruction) | 7879 | if (expr_value == irb->codegen->invalid_inst_src) |
| 6849 | return expr_value; | 7880 | return expr_value; |
| 6850 | | 7881 | |
| 6851 | fields[i].name = name; | 7882 | fields[i].name = name; |
| 6852 | fields[i].source_node = entry_node; | 7883 | fields[i].source_node = entry_node; |
| 6853 | fields[i].result_loc = field_ptr; | 7884 | fields[i].result_loc = field_ptr; |
| 6854 | } | 7885 | } |
| 6855 | IrInstruction *result = ir_build_container_init_fields(irb, scope, node, field_count, | 7886 | IrInstSrc *result = ir_build_container_init_fields(irb, scope, node, field_count, |
| 6856 | fields, container_ptr); | 7887 | fields, container_ptr); |
| 6857 | | 7888 | |
| 6858 | if (result_loc_cast != nullptr) { | 7889 | if (result_loc_cast != nullptr) { |
| ... | @@ -6863,15 +7894,15 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A | ... | @@ -6863,15 +7894,15 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 6863 | case ContainerInitKindArray: { | 7894 | case ContainerInitKindArray: { |
| 6864 | size_t item_count = container_init_expr->entries.length; | 7895 | size_t item_count = container_init_expr->entries.length; |
| 6865 | | 7896 | |
| 6866 | IrInstruction *container_ptr = ir_build_resolve_result(irb, scope, node, child_result_loc, | 7897 | IrInstSrc *container_ptr = ir_build_resolve_result(irb, scope, node, child_result_loc, |
| 6867 | nullptr); | 7898 | nullptr); |
| 6868 | | 7899 | |
| 6869 | IrInstruction **result_locs = allocate<IrInstruction *>(item_count); | 7900 | IrInstSrc **result_locs = allocate<IrInstSrc *>(item_count); |
| 6870 | for (size_t i = 0; i < item_count; i += 1) { | 7901 | for (size_t i = 0; i < item_count; i += 1) { |
| 6871 | AstNode *expr_node = container_init_expr->entries.at(i); | 7902 | AstNode *expr_node = container_init_expr->entries.at(i); |
| 6872 | | 7903 | |
| 6873 | IrInstruction *elem_index = ir_build_const_usize(irb, scope, expr_node, i); | 7904 | IrInstSrc *elem_index = ir_build_const_usize(irb, scope, expr_node, i); |
| 6874 | IrInstruction *elem_ptr = ir_build_elem_ptr(irb, scope, expr_node, container_ptr, | 7905 | IrInstSrc *elem_ptr = ir_build_elem_ptr(irb, scope, expr_node, container_ptr, |
| 6875 | elem_index, false, PtrLenSingle, init_array_type_source_node); | 7906 | elem_index, false, PtrLenSingle, init_array_type_source_node); |
| 6876 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); | 7907 | ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1); |
| 6877 | result_loc_inst->base.id = ResultLocIdInstruction; | 7908 | result_loc_inst->base.id = ResultLocIdInstruction; |
| ... | @@ -6880,14 +7911,14 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A | ... | @@ -6880,14 +7911,14 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 6880 | ir_ref_instruction(elem_ptr, irb->current_basic_block); | 7911 | ir_ref_instruction(elem_ptr, irb->current_basic_block); |
| 6881 | ir_build_reset_result(irb, scope, expr_node, &result_loc_inst->base); | 7912 | ir_build_reset_result(irb, scope, expr_node, &result_loc_inst->base); |
| 6882 | | 7913 | |
| 6883 | IrInstruction *expr_value = ir_gen_node_extra(irb, expr_node, scope, LValNone, | 7914 | IrInstSrc *expr_value = ir_gen_node_extra(irb, expr_node, scope, LValNone, |
| 6884 | &result_loc_inst->base); | 7915 | &result_loc_inst->base); |
| 6885 | if (expr_value == irb->codegen->invalid_instruction) | 7916 | if (expr_value == irb->codegen->invalid_inst_src) |
| 6886 | return expr_value; | 7917 | return expr_value; |
| 6887 | | 7918 | |
| 6888 | result_locs[i] = elem_ptr; | 7919 | result_locs[i] = elem_ptr; |
| 6889 | } | 7920 | } |
| 6890 | IrInstruction *result = ir_build_container_init_list(irb, scope, node, item_count, | 7921 | IrInstSrc *result = ir_build_container_init_list(irb, scope, node, item_count, |
| 6891 | result_locs, container_ptr, init_array_type_source_node); | 7922 | result_locs, container_ptr, init_array_type_source_node); |
| 6892 | if (result_loc_cast != nullptr) { | 7923 | if (result_loc_cast != nullptr) { |
| 6893 | result = ir_build_implicit_cast(irb, scope, node, result, result_loc_cast); | 7924 | result = ir_build_implicit_cast(irb, scope, node, result, result_loc_cast); |
| ... | @@ -6898,19 +7929,19 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A | ... | @@ -6898,19 +7929,19 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A |
| 6898 | zig_unreachable(); | 7929 | zig_unreachable(); |
| 6899 | } | 7930 | } |
| 6900 | | 7931 | |
| 6901 | static ResultLocVar *ir_build_var_result_loc(IrBuilder *irb, IrInstruction *alloca, ZigVar *var) { | 7932 | static ResultLocVar *ir_build_var_result_loc(IrBuilderSrc *irb, IrInstSrc *alloca, ZigVar *var) { |
| 6902 | ResultLocVar *result_loc_var = allocate<ResultLocVar>(1); | 7933 | ResultLocVar *result_loc_var = allocate<ResultLocVar>(1); |
| 6903 | result_loc_var->base.id = ResultLocIdVar; | 7934 | result_loc_var->base.id = ResultLocIdVar; |
| 6904 | result_loc_var->base.source_instruction = alloca; | 7935 | result_loc_var->base.source_instruction = alloca; |
| 6905 | result_loc_var->base.allow_write_through_const = true; | 7936 | result_loc_var->base.allow_write_through_const = true; |
| 6906 | result_loc_var->var = var; | 7937 | result_loc_var->var = var; |
| 6907 | | 7938 | |
| 6908 | ir_build_reset_result(irb, alloca->scope, alloca->source_node, &result_loc_var->base); | 7939 | ir_build_reset_result(irb, alloca->base.scope, alloca->base.source_node, &result_loc_var->base); |
| 6909 | | 7940 | |
| 6910 | return result_loc_var; | 7941 | return result_loc_var; |
| 6911 | } | 7942 | } |
| 6912 | | 7943 | |
| 6913 | static ResultLocCast *ir_build_cast_result_loc(IrBuilder *irb, IrInstruction *dest_type, | 7944 | static ResultLocCast *ir_build_cast_result_loc(IrBuilderSrc *irb, IrInstSrc *dest_type, |
| 6914 | ResultLoc *parent_result_loc) | 7945 | ResultLoc *parent_result_loc) |
| 6915 | { | 7946 | { |
| 6916 | ResultLocCast *result_loc_cast = allocate<ResultLocCast>(1); | 7947 | ResultLocCast *result_loc_cast = allocate<ResultLocCast>(1); |
| ... | @@ -6920,37 +7951,37 @@ static ResultLocCast *ir_build_cast_result_loc(IrBuilder *irb, IrInstruction *de | ... | @@ -6920,37 +7951,37 @@ static ResultLocCast *ir_build_cast_result_loc(IrBuilder *irb, IrInstruction *de |
| 6920 | ir_ref_instruction(dest_type, irb->current_basic_block); | 7951 | ir_ref_instruction(dest_type, irb->current_basic_block); |
| 6921 | result_loc_cast->parent = parent_result_loc; | 7952 | result_loc_cast->parent = parent_result_loc; |
| 6922 | | 7953 | |
| 6923 | ir_build_reset_result(irb, dest_type->scope, dest_type->source_node, &result_loc_cast->base); | 7954 | ir_build_reset_result(irb, dest_type->base.scope, dest_type->base.source_node, &result_loc_cast->base); |
| 6924 | | 7955 | |
| 6925 | return result_loc_cast; | 7956 | return result_loc_cast; |
| 6926 | } | 7957 | } |
| 6927 | | 7958 | |
| 6928 | static void build_decl_var_and_init(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigVar *var, | 7959 | static void build_decl_var_and_init(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, ZigVar *var, |
| 6929 | IrInstruction *init, const char *name_hint, IrInstruction *is_comptime) | 7960 | IrInstSrc *init, const char *name_hint, IrInstSrc *is_comptime) |
| 6930 | { | 7961 | { |
| 6931 | IrInstruction *alloca = ir_build_alloca_src(irb, scope, source_node, nullptr, name_hint, is_comptime); | 7962 | IrInstSrc *alloca = ir_build_alloca_src(irb, scope, source_node, nullptr, name_hint, is_comptime); |
| 6932 | ResultLocVar *var_result_loc = ir_build_var_result_loc(irb, alloca, var); | 7963 | ResultLocVar *var_result_loc = ir_build_var_result_loc(irb, alloca, var); |
| 6933 | ir_build_end_expr(irb, scope, source_node, init, &var_result_loc->base); | 7964 | ir_build_end_expr(irb, scope, source_node, init, &var_result_loc->base); |
| 6934 | ir_build_var_decl_src(irb, scope, source_node, var, nullptr, alloca); | 7965 | ir_build_var_decl_src(irb, scope, source_node, var, nullptr, alloca); |
| 6935 | } | 7966 | } |
| 6936 | | 7967 | |
| 6937 | static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *node) { | 7968 | static IrInstSrc *ir_gen_var_decl(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 6938 | assert(node->type == NodeTypeVariableDeclaration); | 7969 | assert(node->type == NodeTypeVariableDeclaration); |
| 6939 | | 7970 | |
| 6940 | AstNodeVariableDeclaration *variable_declaration = &node->data.variable_declaration; | 7971 | AstNodeVariableDeclaration *variable_declaration = &node->data.variable_declaration; |
| 6941 | | 7972 | |
| 6942 | if (buf_eql_str(variable_declaration->symbol, "_")) { | 7973 | if (buf_eql_str(variable_declaration->symbol, "_")) { |
| 6943 | add_node_error(irb->codegen, node, buf_sprintf("`_` is not a declarable symbol")); | 7974 | add_node_error(irb->codegen, node, buf_sprintf("`_` is not a declarable symbol")); |
| 6944 | return irb->codegen->invalid_instruction; | 7975 | return irb->codegen->invalid_inst_src; |
| 6945 | } | 7976 | } |
| 6946 | | 7977 | |
| 6947 | // Used for the type expr and the align expr | 7978 | // Used for the type expr and the align expr |
| 6948 | Scope *comptime_scope = create_comptime_scope(irb->codegen, node, scope); | 7979 | Scope *comptime_scope = create_comptime_scope(irb->codegen, node, scope); |
| 6949 | | 7980 | |
| 6950 | IrInstruction *type_instruction; | 7981 | IrInstSrc *type_instruction; |
| 6951 | if (variable_declaration->type != nullptr) { | 7982 | if (variable_declaration->type != nullptr) { |
| 6952 | type_instruction = ir_gen_node(irb, variable_declaration->type, comptime_scope); | 7983 | type_instruction = ir_gen_node(irb, variable_declaration->type, comptime_scope); |
| 6953 | if (type_instruction == irb->codegen->invalid_instruction) | 7984 | if (type_instruction == irb->codegen->invalid_inst_src) |
| 6954 | return type_instruction; | 7985 | return type_instruction; |
| 6955 | } else { | 7986 | } else { |
| 6956 | type_instruction = nullptr; | 7987 | type_instruction = nullptr; |
| ... | @@ -6961,22 +7992,22 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -6961,22 +7992,22 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod |
| 6961 | bool is_extern = variable_declaration->is_extern; | 7992 | bool is_extern = variable_declaration->is_extern; |
| 6962 | | 7993 | |
| 6963 | bool is_comptime_scalar = ir_should_inline(irb->exec, scope) || variable_declaration->is_comptime; | 7994 | bool is_comptime_scalar = ir_should_inline(irb->exec, scope) || variable_declaration->is_comptime; |
| 6964 | IrInstruction *is_comptime = ir_build_const_bool(irb, scope, node, is_comptime_scalar); | 7995 | IrInstSrc *is_comptime = ir_build_const_bool(irb, scope, node, is_comptime_scalar); |
| 6965 | ZigVar *var = ir_create_var(irb, node, scope, variable_declaration->symbol, | 7996 | ZigVar *var = ir_create_var(irb, node, scope, variable_declaration->symbol, |
| 6966 | is_const, is_const, is_shadowable, is_comptime); | 7997 | is_const, is_const, is_shadowable, is_comptime); |
| 6967 | // we detect IrInstructionIdDeclVarSrc in gen_block to make sure the next node | 7998 | // we detect IrInstSrcDeclVar in gen_block to make sure the next node |
| 6968 | // is inside var->child_scope | 7999 | // is inside var->child_scope |
| 6969 | | 8000 | |
| 6970 | if (!is_extern && !variable_declaration->expr) { | 8001 | if (!is_extern && !variable_declaration->expr) { |
| 6971 | var->var_type = irb->codegen->builtin_types.entry_invalid; | 8002 | var->var_type = irb->codegen->builtin_types.entry_invalid; |
| 6972 | add_node_error(irb->codegen, node, buf_sprintf("variables must be initialized")); | 8003 | add_node_error(irb->codegen, node, buf_sprintf("variables must be initialized")); |
| 6973 | return irb->codegen->invalid_instruction; | 8004 | return irb->codegen->invalid_inst_src; |
| 6974 | } | 8005 | } |
| 6975 | | 8006 | |
| 6976 | IrInstruction *align_value = nullptr; | 8007 | IrInstSrc *align_value = nullptr; |
| 6977 | if (variable_declaration->align_expr != nullptr) { | 8008 | if (variable_declaration->align_expr != nullptr) { |
| 6978 | align_value = ir_gen_node(irb, variable_declaration->align_expr, comptime_scope); | 8009 | align_value = ir_gen_node(irb, variable_declaration->align_expr, comptime_scope); |
| 6979 | if (align_value == irb->codegen->invalid_instruction) | 8010 | if (align_value == irb->codegen->invalid_inst_src) |
| 6980 | return align_value; | 8011 | return align_value; |
| 6981 | } | 8012 | } |
| 6982 | | 8013 | |
| ... | @@ -6988,7 +8019,7 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -6988,7 +8019,7 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod |
| 6988 | // Parser should ensure that this never happens | 8019 | // Parser should ensure that this never happens |
| 6989 | assert(variable_declaration->threadlocal_tok == nullptr); | 8020 | assert(variable_declaration->threadlocal_tok == nullptr); |
| 6990 | | 8021 | |
| 6991 | IrInstruction *alloca = ir_build_alloca_src(irb, scope, node, align_value, | 8022 | IrInstSrc *alloca = ir_build_alloca_src(irb, scope, node, align_value, |
| 6992 | buf_ptr(variable_declaration->symbol), is_comptime); | 8023 | buf_ptr(variable_declaration->symbol), is_comptime); |
| 6993 | | 8024 | |
| 6994 | // Create a result location for the initialization expression. | 8025 | // Create a result location for the initialization expression. |
| ... | @@ -7006,19 +8037,19 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -7006,19 +8037,19 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod |
| 7006 | Scope *init_scope = is_comptime_scalar ? | 8037 | Scope *init_scope = is_comptime_scalar ? |
| 7007 | create_comptime_scope(irb->codegen, variable_declaration->expr, scope) : scope; | 8038 | create_comptime_scope(irb->codegen, variable_declaration->expr, scope) : scope; |
| 7008 | | 8039 | |
| 7009 | // Temporarily set the name of the IrExecutable to the VariableDeclaration | 8040 | // Temporarily set the name of the IrExecutableSrc to the VariableDeclaration |
| 7010 | // so that the struct or enum from the init expression inherits the name. | 8041 | // so that the struct or enum from the init expression inherits the name. |
| 7011 | Buf *old_exec_name = irb->exec->name; | 8042 | Buf *old_exec_name = irb->exec->name; |
| 7012 | irb->exec->name = variable_declaration->symbol; | 8043 | irb->exec->name = variable_declaration->symbol; |
| 7013 | IrInstruction *init_value = ir_gen_node_extra(irb, variable_declaration->expr, init_scope, | 8044 | IrInstSrc *init_value = ir_gen_node_extra(irb, variable_declaration->expr, init_scope, |
| 7014 | LValNone, init_result_loc); | 8045 | LValNone, init_result_loc); |
| 7015 | irb->exec->name = old_exec_name; | 8046 | irb->exec->name = old_exec_name; |
| 7016 | | 8047 | |
| 7017 | if (init_value == irb->codegen->invalid_instruction) | 8048 | if (init_value == irb->codegen->invalid_inst_src) |
| 7018 | return irb->codegen->invalid_instruction; | 8049 | return irb->codegen->invalid_inst_src; |
| 7019 | | 8050 | |
| 7020 | if (result_loc_cast != nullptr) { | 8051 | if (result_loc_cast != nullptr) { |
| 7021 | IrInstruction *implicit_cast = ir_build_implicit_cast(irb, scope, init_value->source_node, | 8052 | IrInstSrc *implicit_cast = ir_build_implicit_cast(irb, scope, init_value->base.source_node, |
| 7022 | init_value, result_loc_cast); | 8053 | init_value, result_loc_cast); |
| 7023 | ir_build_end_expr(irb, scope, node, implicit_cast, &result_loc_var->base); | 8054 | ir_build_end_expr(irb, scope, node, implicit_cast, &result_loc_var->base); |
| 7024 | } | 8055 | } |
| ... | @@ -7026,7 +8057,7 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -7026,7 +8057,7 @@ static IrInstruction *ir_gen_var_decl(IrBuilder *irb, Scope *scope, AstNode *nod |
| 7026 | return ir_build_var_decl_src(irb, scope, node, var, align_value, alloca); | 8057 | return ir_build_var_decl_src(irb, scope, node, var, align_value, alloca); |
| 7027 | } | 8058 | } |
| 7028 | | 8059 | |
| 7029 | static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 8060 | static IrInstSrc *ir_gen_while_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 7030 | ResultLoc *result_loc) | 8061 | ResultLoc *result_loc) |
| 7031 | { | 8062 | { |
| 7032 | assert(node->type == NodeTypeWhileExpr); | 8063 | assert(node->type == NodeTypeWhileExpr); |
| ... | @@ -7034,15 +8065,15 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7034,15 +8065,15 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7034 | AstNode *continue_expr_node = node->data.while_expr.continue_expr; | 8065 | AstNode *continue_expr_node = node->data.while_expr.continue_expr; |
| 7035 | AstNode *else_node = node->data.while_expr.else_node; | 8066 | AstNode *else_node = node->data.while_expr.else_node; |
| 7036 | | 8067 | |
| 7037 | IrBasicBlock *cond_block = ir_create_basic_block(irb, scope, "WhileCond"); | 8068 | IrBasicBlockSrc *cond_block = ir_create_basic_block(irb, scope, "WhileCond"); |
| 7038 | IrBasicBlock *body_block = ir_create_basic_block(irb, scope, "WhileBody"); | 8069 | IrBasicBlockSrc *body_block = ir_create_basic_block(irb, scope, "WhileBody"); |
| 7039 | IrBasicBlock *continue_block = continue_expr_node ? | 8070 | IrBasicBlockSrc *continue_block = continue_expr_node ? |
| 7040 | ir_create_basic_block(irb, scope, "WhileContinue") : cond_block; | 8071 | ir_create_basic_block(irb, scope, "WhileContinue") : cond_block; |
| 7041 | IrBasicBlock *end_block = ir_create_basic_block(irb, scope, "WhileEnd"); | 8072 | IrBasicBlockSrc *end_block = ir_create_basic_block(irb, scope, "WhileEnd"); |
| 7042 | IrBasicBlock *else_block = else_node ? | 8073 | IrBasicBlockSrc *else_block = else_node ? |
| 7043 | ir_create_basic_block(irb, scope, "WhileElse") : end_block; | 8074 | ir_create_basic_block(irb, scope, "WhileElse") : end_block; |
| 7044 | | 8075 | |
| 7045 | IrInstruction *is_comptime = ir_build_const_bool(irb, scope, node, | 8076 | IrInstSrc *is_comptime = ir_build_const_bool(irb, scope, node, |
| 7046 | ir_should_inline(irb->exec, scope) || node->data.while_expr.is_inline); | 8077 | ir_should_inline(irb->exec, scope) || node->data.while_expr.is_inline); |
| 7047 | ir_build_br(irb, scope, node, cond_block, is_comptime); | 8078 | ir_build_br(irb, scope, node, cond_block, is_comptime); |
| 7048 | | 8079 | |
| ... | @@ -7063,15 +8094,15 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7063,15 +8094,15 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7063 | } else { | 8094 | } else { |
| 7064 | payload_scope = subexpr_scope; | 8095 | payload_scope = subexpr_scope; |
| 7065 | } | 8096 | } |
| 7066 | IrInstruction *err_val_ptr = ir_gen_node_extra(irb, node->data.while_expr.condition, subexpr_scope, | 8097 | IrInstSrc *err_val_ptr = ir_gen_node_extra(irb, node->data.while_expr.condition, subexpr_scope, |
| 7067 | LValPtr, nullptr); | 8098 | LValPtr, nullptr); |
| 7068 | if (err_val_ptr == irb->codegen->invalid_instruction) | 8099 | if (err_val_ptr == irb->codegen->invalid_inst_src) |
| 7069 | return err_val_ptr; | 8100 | return err_val_ptr; |
| 7070 | IrInstruction *is_err = ir_build_test_err_src(irb, scope, node->data.while_expr.condition, err_val_ptr, | 8101 | IrInstSrc *is_err = ir_build_test_err_src(irb, scope, node->data.while_expr.condition, err_val_ptr, |
| 7071 | true, false); | 8102 | true, false); |
| 7072 | IrBasicBlock *after_cond_block = irb->current_basic_block; | 8103 | IrBasicBlockSrc *after_cond_block = irb->current_basic_block; |
| 7073 | IrInstruction *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, scope, node)); | 8104 | IrInstSrc *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, scope, node)); |
| 7074 | IrInstruction *cond_br_inst; | 8105 | IrInstSrc *cond_br_inst; |
| 7075 | if (!instr_is_unreachable(is_err)) { | 8106 | if (!instr_is_unreachable(is_err)) { |
| 7076 | cond_br_inst = ir_build_cond_br(irb, scope, node->data.while_expr.condition, is_err, | 8107 | cond_br_inst = ir_build_cond_br(irb, scope, node->data.while_expr.condition, is_err, |
| 7077 | else_block, body_block, is_comptime); | 8108 | else_block, body_block, is_comptime); |
| ... | @@ -7086,15 +8117,15 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7086,15 +8117,15 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7086 | | 8117 | |
| 7087 | ir_set_cursor_at_end_and_append_block(irb, body_block); | 8118 | ir_set_cursor_at_end_and_append_block(irb, body_block); |
| 7088 | if (var_symbol) { | 8119 | if (var_symbol) { |
| 7089 | IrInstruction *payload_ptr = ir_build_unwrap_err_payload(irb, payload_scope, symbol_node, | 8120 | IrInstSrc *payload_ptr = ir_build_unwrap_err_payload_src(irb, payload_scope, symbol_node, |
| 7090 | err_val_ptr, false, false); | 8121 | err_val_ptr, false, false); |
| 7091 | IrInstruction *var_ptr = node->data.while_expr.var_is_ptr ? | 8122 | IrInstSrc *var_ptr = node->data.while_expr.var_is_ptr ? |
| 7092 | ir_build_ref(irb, payload_scope, symbol_node, payload_ptr, true, false) : payload_ptr; | 8123 | ir_build_ref_src(irb, payload_scope, symbol_node, payload_ptr, true, false) : payload_ptr; |
| 7093 | ir_build_var_decl_src(irb, payload_scope, symbol_node, payload_var, nullptr, var_ptr); | 8124 | ir_build_var_decl_src(irb, payload_scope, symbol_node, payload_var, nullptr, var_ptr); |
| 7094 | } | 8125 | } |
| 7095 | | 8126 | |
| 7096 | ZigList<IrInstruction *> incoming_values = {0}; | 8127 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 7097 | ZigList<IrBasicBlock *> incoming_blocks = {0}; | 8128 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; |
| 7098 | | 8129 | |
| 7099 | ScopeLoop *loop_scope = create_loop_scope(irb->codegen, node, payload_scope); | 8130 | ScopeLoop *loop_scope = create_loop_scope(irb->codegen, node, payload_scope); |
| 7100 | loop_scope->break_block = end_block; | 8131 | loop_scope->break_block = end_block; |
| ... | @@ -7108,8 +8139,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7108,8 +8139,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7108 | // Note the body block of the loop is not the place that lval and result_loc are used - | 8139 | // Note the body block of the loop is not the place that lval and result_loc are used - |
| 7109 | // it's actually in break statements, handled similarly to return statements. | 8140 | // it's actually in break statements, handled similarly to return statements. |
| 7110 | // That is why we set those values in loop_scope above and not in this ir_gen_node call. | 8141 | // That is why we set those values in loop_scope above and not in this ir_gen_node call. |
| 7111 | IrInstruction *body_result = ir_gen_node(irb, node->data.while_expr.body, &loop_scope->base); | 8142 | IrInstSrc *body_result = ir_gen_node(irb, node->data.while_expr.body, &loop_scope->base); |
| 7112 | if (body_result == irb->codegen->invalid_instruction) | 8143 | if (body_result == irb->codegen->invalid_inst_src) |
| 7113 | return body_result; | 8144 | return body_result; |
| 7114 | | 8145 | |
| 7115 | if (!instr_is_unreachable(body_result)) { | 8146 | if (!instr_is_unreachable(body_result)) { |
| ... | @@ -7119,8 +8150,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7119,8 +8150,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7119 | | 8150 | |
| 7120 | if (continue_expr_node) { | 8151 | if (continue_expr_node) { |
| 7121 | ir_set_cursor_at_end_and_append_block(irb, continue_block); | 8152 | ir_set_cursor_at_end_and_append_block(irb, continue_block); |
| 7122 | IrInstruction *expr_result = ir_gen_node(irb, continue_expr_node, payload_scope); | 8153 | IrInstSrc *expr_result = ir_gen_node(irb, continue_expr_node, payload_scope); |
| 7123 | if (expr_result == irb->codegen->invalid_instruction) | 8154 | if (expr_result == irb->codegen->invalid_inst_src) |
| 7124 | return expr_result; | 8155 | return expr_result; |
| 7125 | if (!instr_is_unreachable(expr_result)) { | 8156 | if (!instr_is_unreachable(expr_result)) { |
| 7126 | ir_mark_gen(ir_build_check_statement_is_void(irb, payload_scope, continue_expr_node, expr_result)); | 8157 | ir_mark_gen(ir_build_check_statement_is_void(irb, payload_scope, continue_expr_node, expr_result)); |
| ... | @@ -7136,7 +8167,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7136,7 +8167,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7136 | ZigVar *err_var = ir_create_var(irb, err_symbol_node, scope, err_symbol, | 8167 | ZigVar *err_var = ir_create_var(irb, err_symbol_node, scope, err_symbol, |
| 7137 | true, false, false, is_comptime); | 8168 | true, false, false, is_comptime); |
| 7138 | Scope *err_scope = err_var->child_scope; | 8169 | Scope *err_scope = err_var->child_scope; |
| 7139 | IrInstruction *err_ptr = ir_build_unwrap_err_code(irb, err_scope, err_symbol_node, err_val_ptr); | 8170 | IrInstSrc *err_ptr = ir_build_unwrap_err_code_src(irb, err_scope, err_symbol_node, err_val_ptr); |
| 7140 | ir_build_var_decl_src(irb, err_scope, symbol_node, err_var, nullptr, err_ptr); | 8171 | ir_build_var_decl_src(irb, err_scope, symbol_node, err_var, nullptr, err_ptr); |
| 7141 | | 8172 | |
| 7142 | if (peer_parent->peers.length != 0) { | 8173 | if (peer_parent->peers.length != 0) { |
| ... | @@ -7144,12 +8175,12 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7144,12 +8175,12 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7144 | } | 8175 | } |
| 7145 | ResultLocPeer *peer_result = create_peer_result(peer_parent); | 8176 | ResultLocPeer *peer_result = create_peer_result(peer_parent); |
| 7146 | peer_parent->peers.append(peer_result); | 8177 | peer_parent->peers.append(peer_result); |
| 7147 | IrInstruction *else_result = ir_gen_node_extra(irb, else_node, err_scope, lval, &peer_result->base); | 8178 | IrInstSrc *else_result = ir_gen_node_extra(irb, else_node, err_scope, lval, &peer_result->base); |
| 7148 | if (else_result == irb->codegen->invalid_instruction) | 8179 | if (else_result == irb->codegen->invalid_inst_src) |
| 7149 | return else_result; | 8180 | return else_result; |
| 7150 | if (!instr_is_unreachable(else_result)) | 8181 | if (!instr_is_unreachable(else_result)) |
| 7151 | ir_mark_gen(ir_build_br(irb, scope, node, end_block, is_comptime)); | 8182 | ir_mark_gen(ir_build_br(irb, scope, node, end_block, is_comptime)); |
| 7152 | IrBasicBlock *after_else_block = irb->current_basic_block; | 8183 | IrBasicBlockSrc *after_else_block = irb->current_basic_block; |
| 7153 | ir_set_cursor_at_end_and_append_block(irb, end_block); | 8184 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 7154 | if (else_result) { | 8185 | if (else_result) { |
| 7155 | incoming_blocks.append(after_else_block); | 8186 | incoming_blocks.append(after_else_block); |
| ... | @@ -7162,7 +8193,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7162,7 +8193,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7162 | peer_parent->peers.last()->next_bb = end_block; | 8193 | peer_parent->peers.last()->next_bb = end_block; |
| 7163 | } | 8194 | } |
| 7164 | | 8195 | |
| 7165 | IrInstruction *phi = ir_build_phi(irb, scope, node, incoming_blocks.length, | 8196 | IrInstSrc *phi = ir_build_phi(irb, scope, node, incoming_blocks.length, |
| 7166 | incoming_blocks.items, incoming_values.items, peer_parent); | 8197 | incoming_blocks.items, incoming_values.items, peer_parent); |
| 7167 | return ir_expr_wrap(irb, scope, phi, result_loc); | 8198 | return ir_expr_wrap(irb, scope, phi, result_loc); |
| 7168 | } else if (var_symbol != nullptr) { | 8199 | } else if (var_symbol != nullptr) { |
| ... | @@ -7174,15 +8205,15 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7174,15 +8205,15 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7174 | ZigVar *payload_var = ir_create_var(irb, symbol_node, subexpr_scope, var_symbol, | 8205 | ZigVar *payload_var = ir_create_var(irb, symbol_node, subexpr_scope, var_symbol, |
| 7175 | true, false, false, is_comptime); | 8206 | true, false, false, is_comptime); |
| 7176 | Scope *child_scope = payload_var->child_scope; | 8207 | Scope *child_scope = payload_var->child_scope; |
| 7177 | IrInstruction *maybe_val_ptr = ir_gen_node_extra(irb, node->data.while_expr.condition, subexpr_scope, | 8208 | IrInstSrc *maybe_val_ptr = ir_gen_node_extra(irb, node->data.while_expr.condition, subexpr_scope, |
| 7178 | LValPtr, nullptr); | 8209 | LValPtr, nullptr); |
| 7179 | if (maybe_val_ptr == irb->codegen->invalid_instruction) | 8210 | if (maybe_val_ptr == irb->codegen->invalid_inst_src) |
| 7180 | return maybe_val_ptr; | 8211 | return maybe_val_ptr; |
| 7181 | IrInstruction *maybe_val = ir_build_load_ptr(irb, scope, node->data.while_expr.condition, maybe_val_ptr); | 8212 | IrInstSrc *maybe_val = ir_build_load_ptr(irb, scope, node->data.while_expr.condition, maybe_val_ptr); |
| 7182 | IrInstruction *is_non_null = ir_build_test_nonnull(irb, scope, node->data.while_expr.condition, maybe_val); | 8213 | IrInstSrc *is_non_null = ir_build_test_non_null_src(irb, scope, node->data.while_expr.condition, maybe_val); |
| 7183 | IrBasicBlock *after_cond_block = irb->current_basic_block; | 8214 | IrBasicBlockSrc *after_cond_block = irb->current_basic_block; |
| 7184 | IrInstruction *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, scope, node)); | 8215 | IrInstSrc *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, scope, node)); |
| 7185 | IrInstruction *cond_br_inst; | 8216 | IrInstSrc *cond_br_inst; |
| 7186 | if (!instr_is_unreachable(is_non_null)) { | 8217 | if (!instr_is_unreachable(is_non_null)) { |
| 7187 | cond_br_inst = ir_build_cond_br(irb, scope, node->data.while_expr.condition, is_non_null, | 8218 | cond_br_inst = ir_build_cond_br(irb, scope, node->data.while_expr.condition, is_non_null, |
| 7188 | body_block, else_block, is_comptime); | 8219 | body_block, else_block, is_comptime); |
| ... | @@ -7196,13 +8227,13 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7196,13 +8227,13 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7196 | is_comptime); | 8227 | is_comptime); |
| 7197 | | 8228 | |
| 7198 | ir_set_cursor_at_end_and_append_block(irb, body_block); | 8229 | ir_set_cursor_at_end_and_append_block(irb, body_block); |
| 7199 | IrInstruction *payload_ptr = ir_build_optional_unwrap_ptr(irb, child_scope, symbol_node, maybe_val_ptr, false, false); | 8230 | IrInstSrc *payload_ptr = ir_build_optional_unwrap_ptr(irb, child_scope, symbol_node, maybe_val_ptr, false, false); |
| 7200 | IrInstruction *var_ptr = node->data.while_expr.var_is_ptr ? | 8231 | IrInstSrc *var_ptr = node->data.while_expr.var_is_ptr ? |
| 7201 | ir_build_ref(irb, child_scope, symbol_node, payload_ptr, true, false) : payload_ptr; | 8232 | ir_build_ref_src(irb, child_scope, symbol_node, payload_ptr, true, false) : payload_ptr; |
| 7202 | ir_build_var_decl_src(irb, child_scope, symbol_node, payload_var, nullptr, var_ptr); | 8233 | ir_build_var_decl_src(irb, child_scope, symbol_node, payload_var, nullptr, var_ptr); |
| 7203 | | 8234 | |
| 7204 | ZigList<IrInstruction *> incoming_values = {0}; | 8235 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 7205 | ZigList<IrBasicBlock *> incoming_blocks = {0}; | 8236 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; |
| 7206 | | 8237 | |
| 7207 | ScopeLoop *loop_scope = create_loop_scope(irb->codegen, node, child_scope); | 8238 | ScopeLoop *loop_scope = create_loop_scope(irb->codegen, node, child_scope); |
| 7208 | loop_scope->break_block = end_block; | 8239 | loop_scope->break_block = end_block; |
| ... | @@ -7216,8 +8247,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7216,8 +8247,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7216 | // Note the body block of the loop is not the place that lval and result_loc are used - | 8247 | // Note the body block of the loop is not the place that lval and result_loc are used - |
| 7217 | // it's actually in break statements, handled similarly to return statements. | 8248 | // it's actually in break statements, handled similarly to return statements. |
| 7218 | // That is why we set those values in loop_scope above and not in this ir_gen_node call. | 8249 | // That is why we set those values in loop_scope above and not in this ir_gen_node call. |
| 7219 | IrInstruction *body_result = ir_gen_node(irb, node->data.while_expr.body, &loop_scope->base); | 8250 | IrInstSrc *body_result = ir_gen_node(irb, node->data.while_expr.body, &loop_scope->base); |
| 7220 | if (body_result == irb->codegen->invalid_instruction) | 8251 | if (body_result == irb->codegen->invalid_inst_src) |
| 7221 | return body_result; | 8252 | return body_result; |
| 7222 | | 8253 | |
| 7223 | if (!instr_is_unreachable(body_result)) { | 8254 | if (!instr_is_unreachable(body_result)) { |
| ... | @@ -7227,8 +8258,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7227,8 +8258,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7227 | | 8258 | |
| 7228 | if (continue_expr_node) { | 8259 | if (continue_expr_node) { |
| 7229 | ir_set_cursor_at_end_and_append_block(irb, continue_block); | 8260 | ir_set_cursor_at_end_and_append_block(irb, continue_block); |
| 7230 | IrInstruction *expr_result = ir_gen_node(irb, continue_expr_node, child_scope); | 8261 | IrInstSrc *expr_result = ir_gen_node(irb, continue_expr_node, child_scope); |
| 7231 | if (expr_result == irb->codegen->invalid_instruction) | 8262 | if (expr_result == irb->codegen->invalid_inst_src) |
| 7232 | return expr_result; | 8263 | return expr_result; |
| 7233 | if (!instr_is_unreachable(expr_result)) { | 8264 | if (!instr_is_unreachable(expr_result)) { |
| 7234 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, continue_expr_node, expr_result)); | 8265 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, continue_expr_node, expr_result)); |
| ... | @@ -7236,7 +8267,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7236,7 +8267,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7236 | } | 8267 | } |
| 7237 | } | 8268 | } |
| 7238 | | 8269 | |
| 7239 | IrInstruction *else_result = nullptr; | 8270 | IrInstSrc *else_result = nullptr; |
| 7240 | if (else_node) { | 8271 | if (else_node) { |
| 7241 | ir_set_cursor_at_end_and_append_block(irb, else_block); | 8272 | ir_set_cursor_at_end_and_append_block(irb, else_block); |
| 7242 | | 8273 | |
| ... | @@ -7246,12 +8277,12 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7246,12 +8277,12 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7246 | ResultLocPeer *peer_result = create_peer_result(peer_parent); | 8277 | ResultLocPeer *peer_result = create_peer_result(peer_parent); |
| 7247 | peer_parent->peers.append(peer_result); | 8278 | peer_parent->peers.append(peer_result); |
| 7248 | else_result = ir_gen_node_extra(irb, else_node, scope, lval, &peer_result->base); | 8279 | else_result = ir_gen_node_extra(irb, else_node, scope, lval, &peer_result->base); |
| 7249 | if (else_result == irb->codegen->invalid_instruction) | 8280 | if (else_result == irb->codegen->invalid_inst_src) |
| 7250 | return else_result; | 8281 | return else_result; |
| 7251 | if (!instr_is_unreachable(else_result)) | 8282 | if (!instr_is_unreachable(else_result)) |
| 7252 | ir_mark_gen(ir_build_br(irb, scope, node, end_block, is_comptime)); | 8283 | ir_mark_gen(ir_build_br(irb, scope, node, end_block, is_comptime)); |
| 7253 | } | 8284 | } |
| 7254 | IrBasicBlock *after_else_block = irb->current_basic_block; | 8285 | IrBasicBlockSrc *after_else_block = irb->current_basic_block; |
| 7255 | ir_set_cursor_at_end_and_append_block(irb, end_block); | 8286 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 7256 | if (else_result) { | 8287 | if (else_result) { |
| 7257 | incoming_blocks.append(after_else_block); | 8288 | incoming_blocks.append(after_else_block); |
| ... | @@ -7264,17 +8295,17 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7264,17 +8295,17 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7264 | peer_parent->peers.last()->next_bb = end_block; | 8295 | peer_parent->peers.last()->next_bb = end_block; |
| 7265 | } | 8296 | } |
| 7266 | | 8297 | |
| 7267 | IrInstruction *phi = ir_build_phi(irb, scope, node, incoming_blocks.length, | 8298 | IrInstSrc *phi = ir_build_phi(irb, scope, node, incoming_blocks.length, |
| 7268 | incoming_blocks.items, incoming_values.items, peer_parent); | 8299 | incoming_blocks.items, incoming_values.items, peer_parent); |
| 7269 | return ir_expr_wrap(irb, scope, phi, result_loc); | 8300 | return ir_expr_wrap(irb, scope, phi, result_loc); |
| 7270 | } else { | 8301 | } else { |
| 7271 | ir_set_cursor_at_end_and_append_block(irb, cond_block); | 8302 | ir_set_cursor_at_end_and_append_block(irb, cond_block); |
| 7272 | IrInstruction *cond_val = ir_gen_node(irb, node->data.while_expr.condition, scope); | 8303 | IrInstSrc *cond_val = ir_gen_node(irb, node->data.while_expr.condition, scope); |
| 7273 | if (cond_val == irb->codegen->invalid_instruction) | 8304 | if (cond_val == irb->codegen->invalid_inst_src) |
| 7274 | return cond_val; | 8305 | return cond_val; |
| 7275 | IrBasicBlock *after_cond_block = irb->current_basic_block; | 8306 | IrBasicBlockSrc *after_cond_block = irb->current_basic_block; |
| 7276 | IrInstruction *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, scope, node)); | 8307 | IrInstSrc *void_else_result = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, scope, node)); |
| 7277 | IrInstruction *cond_br_inst; | 8308 | IrInstSrc *cond_br_inst; |
| 7278 | if (!instr_is_unreachable(cond_val)) { | 8309 | if (!instr_is_unreachable(cond_val)) { |
| 7279 | cond_br_inst = ir_build_cond_br(irb, scope, node->data.while_expr.condition, cond_val, | 8310 | cond_br_inst = ir_build_cond_br(irb, scope, node->data.while_expr.condition, cond_val, |
| 7280 | body_block, else_block, is_comptime); | 8311 | body_block, else_block, is_comptime); |
| ... | @@ -7288,8 +8319,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7288,8 +8319,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7288 | is_comptime); | 8319 | is_comptime); |
| 7289 | ir_set_cursor_at_end_and_append_block(irb, body_block); | 8320 | ir_set_cursor_at_end_and_append_block(irb, body_block); |
| 7290 | | 8321 | |
| 7291 | ZigList<IrInstruction *> incoming_values = {0}; | 8322 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 7292 | ZigList<IrBasicBlock *> incoming_blocks = {0}; | 8323 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; |
| 7293 | | 8324 | |
| 7294 | Scope *subexpr_scope = create_runtime_scope(irb->codegen, node, scope, is_comptime); | 8325 | Scope *subexpr_scope = create_runtime_scope(irb->codegen, node, scope, is_comptime); |
| 7295 | | 8326 | |
| ... | @@ -7305,8 +8336,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7305,8 +8336,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7305 | // Note the body block of the loop is not the place that lval and result_loc are used - | 8336 | // Note the body block of the loop is not the place that lval and result_loc are used - |
| 7306 | // it's actually in break statements, handled similarly to return statements. | 8337 | // it's actually in break statements, handled similarly to return statements. |
| 7307 | // That is why we set those values in loop_scope above and not in this ir_gen_node call. | 8338 | // That is why we set those values in loop_scope above and not in this ir_gen_node call. |
| 7308 | IrInstruction *body_result = ir_gen_node(irb, node->data.while_expr.body, &loop_scope->base); | 8339 | IrInstSrc *body_result = ir_gen_node(irb, node->data.while_expr.body, &loop_scope->base); |
| 7309 | if (body_result == irb->codegen->invalid_instruction) | 8340 | if (body_result == irb->codegen->invalid_inst_src) |
| 7310 | return body_result; | 8341 | return body_result; |
| 7311 | | 8342 | |
| 7312 | if (!instr_is_unreachable(body_result)) { | 8343 | if (!instr_is_unreachable(body_result)) { |
| ... | @@ -7316,8 +8347,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7316,8 +8347,8 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7316 | | 8347 | |
| 7317 | if (continue_expr_node) { | 8348 | if (continue_expr_node) { |
| 7318 | ir_set_cursor_at_end_and_append_block(irb, continue_block); | 8349 | ir_set_cursor_at_end_and_append_block(irb, continue_block); |
| 7319 | IrInstruction *expr_result = ir_gen_node(irb, continue_expr_node, subexpr_scope); | 8350 | IrInstSrc *expr_result = ir_gen_node(irb, continue_expr_node, subexpr_scope); |
| 7320 | if (expr_result == irb->codegen->invalid_instruction) | 8351 | if (expr_result == irb->codegen->invalid_inst_src) |
| 7321 | return expr_result; | 8352 | return expr_result; |
| 7322 | if (!instr_is_unreachable(expr_result)) { | 8353 | if (!instr_is_unreachable(expr_result)) { |
| 7323 | ir_mark_gen(ir_build_check_statement_is_void(irb, scope, continue_expr_node, expr_result)); | 8354 | ir_mark_gen(ir_build_check_statement_is_void(irb, scope, continue_expr_node, expr_result)); |
| ... | @@ -7325,7 +8356,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7325,7 +8356,7 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7325 | } | 8356 | } |
| 7326 | } | 8357 | } |
| 7327 | | 8358 | |
| 7328 | IrInstruction *else_result = nullptr; | 8359 | IrInstSrc *else_result = nullptr; |
| 7329 | if (else_node) { | 8360 | if (else_node) { |
| 7330 | ir_set_cursor_at_end_and_append_block(irb, else_block); | 8361 | ir_set_cursor_at_end_and_append_block(irb, else_block); |
| 7331 | | 8362 | |
| ... | @@ -7336,12 +8367,12 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7336,12 +8367,12 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7336 | peer_parent->peers.append(peer_result); | 8367 | peer_parent->peers.append(peer_result); |
| 7337 | | 8368 | |
| 7338 | else_result = ir_gen_node_extra(irb, else_node, subexpr_scope, lval, &peer_result->base); | 8369 | else_result = ir_gen_node_extra(irb, else_node, subexpr_scope, lval, &peer_result->base); |
| 7339 | if (else_result == irb->codegen->invalid_instruction) | 8370 | if (else_result == irb->codegen->invalid_inst_src) |
| 7340 | return else_result; | 8371 | return else_result; |
| 7341 | if (!instr_is_unreachable(else_result)) | 8372 | if (!instr_is_unreachable(else_result)) |
| 7342 | ir_mark_gen(ir_build_br(irb, scope, node, end_block, is_comptime)); | 8373 | ir_mark_gen(ir_build_br(irb, scope, node, end_block, is_comptime)); |
| 7343 | } | 8374 | } |
| 7344 | IrBasicBlock *after_else_block = irb->current_basic_block; | 8375 | IrBasicBlockSrc *after_else_block = irb->current_basic_block; |
| 7345 | ir_set_cursor_at_end_and_append_block(irb, end_block); | 8376 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 7346 | if (else_result) { | 8377 | if (else_result) { |
| 7347 | incoming_blocks.append(after_else_block); | 8378 | incoming_blocks.append(after_else_block); |
| ... | @@ -7354,13 +8385,13 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7354,13 +8385,13 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 7354 | peer_parent->peers.last()->next_bb = end_block; | 8385 | peer_parent->peers.last()->next_bb = end_block; |
| 7355 | } | 8386 | } |
| 7356 | | 8387 | |
| 7357 | IrInstruction *phi = ir_build_phi(irb, scope, node, incoming_blocks.length, | 8388 | IrInstSrc *phi = ir_build_phi(irb, scope, node, incoming_blocks.length, |
| 7358 | incoming_blocks.items, incoming_values.items, peer_parent); | 8389 | incoming_blocks.items, incoming_values.items, peer_parent); |
| 7359 | return ir_expr_wrap(irb, scope, phi, result_loc); | 8390 | return ir_expr_wrap(irb, scope, phi, result_loc); |
| 7360 | } | 8391 | } |
| 7361 | } | 8392 | } |
| 7362 | | 8393 | |
| 7363 | static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNode *node, LVal lval, | 8394 | static IrInstSrc *ir_gen_for_expr(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node, LVal lval, |
| 7364 | ResultLoc *result_loc) | 8395 | ResultLoc *result_loc) |
| 7365 | { | 8396 | { |
| 7366 | assert(node->type == NodeTypeForExpr); | 8397 | assert(node->type == NodeTypeForExpr); |
| ... | @@ -7373,17 +8404,17 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -7373,17 +8404,17 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo |
| 7373 | | 8404 | |
| 7374 | if (!elem_node) { | 8405 | if (!elem_node) { |
| 7375 | add_node_error(irb->codegen, node, buf_sprintf("for loop expression missing element parameter")); | 8406 | add_node_error(irb->codegen, node, buf_sprintf("for loop expression missing element parameter")); |
| 7376 | return irb->codegen->invalid_instruction; | 8407 | return irb->codegen->invalid_inst_src; |
| 7377 | } | 8408 | } |
| 7378 | assert(elem_node->type == NodeTypeSymbol); | 8409 | assert(elem_node->type == NodeTypeSymbol); |
| 7379 | | 8410 | |
| 7380 | ScopeExpr *spill_scope = create_expr_scope(irb->codegen, node, parent_scope); | 8411 | ScopeExpr *spill_scope = create_expr_scope(irb->codegen, node, parent_scope); |
| 7381 | | 8412 | |
| 7382 | IrInstruction *array_val_ptr = ir_gen_node_extra(irb, array_node, &spill_scope->base, LValPtr, nullptr); | 8413 | IrInstSrc *array_val_ptr = ir_gen_node_extra(irb, array_node, &spill_scope->base, LValPtr, nullptr); |
| 7383 | if (array_val_ptr == irb->codegen->invalid_instruction) | 8414 | if (array_val_ptr == irb->codegen->invalid_inst_src) |
| 7384 | return array_val_ptr; | 8415 | return array_val_ptr; |
| 7385 | | 8416 | |
| 7386 | IrInstruction *is_comptime = ir_build_const_bool(irb, parent_scope, node, | 8417 | IrInstSrc *is_comptime = ir_build_const_bool(irb, parent_scope, node, |
| 7387 | ir_should_inline(irb->exec, parent_scope) || node->data.for_expr.is_inline); | 8418 | ir_should_inline(irb->exec, parent_scope) || node->data.for_expr.is_inline); |
| 7388 | | 8419 | |
| 7389 | AstNode *index_var_source_node; | 8420 | AstNode *index_var_source_node; |
| ... | @@ -7400,50 +8431,50 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -7400,50 +8431,50 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo |
| 7400 | index_var_name = "i"; | 8431 | index_var_name = "i"; |
| 7401 | } | 8432 | } |
| 7402 | | 8433 | |
| 7403 | IrInstruction *zero = ir_build_const_usize(irb, parent_scope, node, 0); | 8434 | IrInstSrc *zero = ir_build_const_usize(irb, parent_scope, node, 0); |
| 7404 | build_decl_var_and_init(irb, parent_scope, index_var_source_node, index_var, zero, index_var_name, is_comptime); | 8435 | build_decl_var_and_init(irb, parent_scope, index_var_source_node, index_var, zero, index_var_name, is_comptime); |
| 7405 | parent_scope = index_var->child_scope; | 8436 | parent_scope = index_var->child_scope; |
| 7406 | | 8437 | |
| 7407 | IrInstruction *one = ir_build_const_usize(irb, parent_scope, node, 1); | 8438 | IrInstSrc *one = ir_build_const_usize(irb, parent_scope, node, 1); |
| 7408 | IrInstruction *index_ptr = ir_build_var_ptr(irb, parent_scope, node, index_var); | 8439 | IrInstSrc *index_ptr = ir_build_var_ptr(irb, parent_scope, node, index_var); |
| 7409 | | 8440 | |
| 7410 | | 8441 | |
| 7411 | IrBasicBlock *cond_block = ir_create_basic_block(irb, parent_scope, "ForCond"); | 8442 | IrBasicBlockSrc *cond_block = ir_create_basic_block(irb, parent_scope, "ForCond"); |
| 7412 | IrBasicBlock *body_block = ir_create_basic_block(irb, parent_scope, "ForBody"); | 8443 | IrBasicBlockSrc *body_block = ir_create_basic_block(irb, parent_scope, "ForBody"); |
| 7413 | IrBasicBlock *end_block = ir_create_basic_block(irb, parent_scope, "ForEnd"); | 8444 | IrBasicBlockSrc *end_block = ir_create_basic_block(irb, parent_scope, "ForEnd"); |
| 7414 | IrBasicBlock *else_block = else_node ? ir_create_basic_block(irb, parent_scope, "ForElse") : end_block; | 8445 | IrBasicBlockSrc *else_block = else_node ? ir_create_basic_block(irb, parent_scope, "ForElse") : end_block; |
| 7415 | IrBasicBlock *continue_block = ir_create_basic_block(irb, parent_scope, "ForContinue"); | 8446 | IrBasicBlockSrc *continue_block = ir_create_basic_block(irb, parent_scope, "ForContinue"); |
| 7416 | | 8447 | |
| 7417 | Buf *len_field_name = buf_create_from_str("len"); | 8448 | Buf *len_field_name = buf_create_from_str("len"); |
| 7418 | IrInstruction *len_ref = ir_build_field_ptr(irb, parent_scope, node, array_val_ptr, len_field_name, false); | 8449 | IrInstSrc *len_ref = ir_build_field_ptr(irb, parent_scope, node, array_val_ptr, len_field_name, false); |
| 7419 | IrInstruction *len_val = ir_build_load_ptr(irb, &spill_scope->base, node, len_ref); | 8450 | IrInstSrc *len_val = ir_build_load_ptr(irb, &spill_scope->base, node, len_ref); |
| 7420 | ir_build_br(irb, parent_scope, node, cond_block, is_comptime); | 8451 | ir_build_br(irb, parent_scope, node, cond_block, is_comptime); |
| 7421 | | 8452 | |
| 7422 | ir_set_cursor_at_end_and_append_block(irb, cond_block); | 8453 | ir_set_cursor_at_end_and_append_block(irb, cond_block); |
| 7423 | IrInstruction *index_val = ir_build_load_ptr(irb, &spill_scope->base, node, index_ptr); | 8454 | IrInstSrc *index_val = ir_build_load_ptr(irb, &spill_scope->base, node, index_ptr); |
| 7424 | IrInstruction *cond = ir_build_bin_op(irb, parent_scope, node, IrBinOpCmpLessThan, index_val, len_val, false); | 8455 | IrInstSrc *cond = ir_build_bin_op(irb, parent_scope, node, IrBinOpCmpLessThan, index_val, len_val, false); |
| 7425 | IrBasicBlock *after_cond_block = irb->current_basic_block; | 8456 | IrBasicBlockSrc *after_cond_block = irb->current_basic_block; |
| 7426 | IrInstruction *void_else_value = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, parent_scope, node)); | 8457 | IrInstSrc *void_else_value = else_node ? nullptr : ir_mark_gen(ir_build_const_void(irb, parent_scope, node)); |
| 7427 | IrInstruction *cond_br_inst = ir_mark_gen(ir_build_cond_br(irb, parent_scope, node, cond, | 8458 | IrInstSrc *cond_br_inst = ir_mark_gen(ir_build_cond_br(irb, parent_scope, node, cond, |
| 7428 | body_block, else_block, is_comptime)); | 8459 | body_block, else_block, is_comptime)); |
| 7429 | | 8460 | |
| 7430 | ResultLocPeerParent *peer_parent = ir_build_result_peers(irb, cond_br_inst, end_block, result_loc, is_comptime); | 8461 | ResultLocPeerParent *peer_parent = ir_build_result_peers(irb, cond_br_inst, end_block, result_loc, is_comptime); |
| 7431 | | 8462 | |
| 7432 | ir_set_cursor_at_end_and_append_block(irb, body_block); | 8463 | ir_set_cursor_at_end_and_append_block(irb, body_block); |
| 7433 | Scope *elem_ptr_scope = node->data.for_expr.elem_is_ptr ? parent_scope : &spill_scope->base; | 8464 | Scope *elem_ptr_scope = node->data.for_expr.elem_is_ptr ? parent_scope : &spill_scope->base; |
| 7434 | IrInstruction *elem_ptr = ir_build_elem_ptr(irb, elem_ptr_scope, node, array_val_ptr, index_val, false, | 8465 | IrInstSrc *elem_ptr = ir_build_elem_ptr(irb, elem_ptr_scope, node, array_val_ptr, index_val, false, |
| 7435 | PtrLenSingle, nullptr); | 8466 | PtrLenSingle, nullptr); |
| 7436 | // TODO make it an error to write to element variable or i variable. | 8467 | // TODO make it an error to write to element variable or i variable. |
| 7437 | Buf *elem_var_name = elem_node->data.symbol_expr.symbol; | 8468 | Buf *elem_var_name = elem_node->data.symbol_expr.symbol; |
| 7438 | ZigVar *elem_var = ir_create_var(irb, elem_node, parent_scope, elem_var_name, true, false, false, is_comptime); | 8469 | ZigVar *elem_var = ir_create_var(irb, elem_node, parent_scope, elem_var_name, true, false, false, is_comptime); |
| 7439 | Scope *child_scope = elem_var->child_scope; | 8470 | Scope *child_scope = elem_var->child_scope; |
| 7440 | | 8471 | |
| 7441 | IrInstruction *var_ptr = node->data.for_expr.elem_is_ptr ? | 8472 | IrInstSrc *var_ptr = node->data.for_expr.elem_is_ptr ? |
| 7442 | ir_build_ref(irb, &spill_scope->base, elem_node, elem_ptr, true, false) : elem_ptr; | 8473 | ir_build_ref_src(irb, &spill_scope->base, elem_node, elem_ptr, true, false) : elem_ptr; |
| 7443 | ir_build_var_decl_src(irb, parent_scope, elem_node, elem_var, nullptr, var_ptr); | 8474 | ir_build_var_decl_src(irb, parent_scope, elem_node, elem_var, nullptr, var_ptr); |
| 7444 | | 8475 | |
| 7445 | ZigList<IrInstruction *> incoming_values = {0}; | 8476 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 7446 | ZigList<IrBasicBlock *> incoming_blocks = {0}; | 8477 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; |
| 7447 | ScopeLoop *loop_scope = create_loop_scope(irb->codegen, node, child_scope); | 8478 | ScopeLoop *loop_scope = create_loop_scope(irb->codegen, node, child_scope); |
| 7448 | loop_scope->break_block = end_block; | 8479 | loop_scope->break_block = end_block; |
| 7449 | loop_scope->continue_block = continue_block; | 8480 | loop_scope->continue_block = continue_block; |
| ... | @@ -7457,9 +8488,9 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -7457,9 +8488,9 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo |
| 7457 | // Note the body block of the loop is not the place that lval and result_loc are used - | 8488 | // Note the body block of the loop is not the place that lval and result_loc are used - |
| 7458 | // it's actually in break statements, handled similarly to return statements. | 8489 | // it's actually in break statements, handled similarly to return statements. |
| 7459 | // That is why we set those values in loop_scope above and not in this ir_gen_node call. | 8490 | // That is why we set those values in loop_scope above and not in this ir_gen_node call. |
| 7460 | IrInstruction *body_result = ir_gen_node(irb, body_node, &loop_scope->base); | 8491 | IrInstSrc *body_result = ir_gen_node(irb, body_node, &loop_scope->base); |
| 7461 | if (body_result == irb->codegen->invalid_instruction) | 8492 | if (body_result == irb->codegen->invalid_inst_src) |
| 7462 | return irb->codegen->invalid_instruction; | 8493 | return irb->codegen->invalid_inst_src; |
| 7463 | | 8494 | |
| 7464 | if (!instr_is_unreachable(body_result)) { | 8495 | if (!instr_is_unreachable(body_result)) { |
| 7465 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, node->data.for_expr.body, body_result)); | 8496 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, node->data.for_expr.body, body_result)); |
| ... | @@ -7467,11 +8498,11 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -7467,11 +8498,11 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo |
| 7467 | } | 8498 | } |
| 7468 | | 8499 | |
| 7469 | ir_set_cursor_at_end_and_append_block(irb, continue_block); | 8500 | ir_set_cursor_at_end_and_append_block(irb, continue_block); |
| 7470 | IrInstruction *new_index_val = ir_build_bin_op(irb, child_scope, node, IrBinOpAdd, index_val, one, false); | 8501 | IrInstSrc *new_index_val = ir_build_bin_op(irb, child_scope, node, IrBinOpAdd, index_val, one, false); |
| 7471 | ir_build_store_ptr(irb, child_scope, node, index_ptr, new_index_val)->allow_write_through_const = true; | 8502 | ir_build_store_ptr(irb, child_scope, node, index_ptr, new_index_val)->allow_write_through_const = true; |
| 7472 | ir_build_br(irb, child_scope, node, cond_block, is_comptime); | 8503 | ir_build_br(irb, child_scope, node, cond_block, is_comptime); |
| 7473 | | 8504 | |
| 7474 | IrInstruction *else_result = nullptr; | 8505 | IrInstSrc *else_result = nullptr; |
| 7475 | if (else_node) { | 8506 | if (else_node) { |
| 7476 | ir_set_cursor_at_end_and_append_block(irb, else_block); | 8507 | ir_set_cursor_at_end_and_append_block(irb, else_block); |
| 7477 | | 8508 | |
| ... | @@ -7481,12 +8512,12 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -7481,12 +8512,12 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo |
| 7481 | ResultLocPeer *peer_result = create_peer_result(peer_parent); | 8512 | ResultLocPeer *peer_result = create_peer_result(peer_parent); |
| 7482 | peer_parent->peers.append(peer_result); | 8513 | peer_parent->peers.append(peer_result); |
| 7483 | else_result = ir_gen_node_extra(irb, else_node, parent_scope, LValNone, &peer_result->base); | 8514 | else_result = ir_gen_node_extra(irb, else_node, parent_scope, LValNone, &peer_result->base); |
| 7484 | if (else_result == irb->codegen->invalid_instruction) | 8515 | if (else_result == irb->codegen->invalid_inst_src) |
| 7485 | return else_result; | 8516 | return else_result; |
| 7486 | if (!instr_is_unreachable(else_result)) | 8517 | if (!instr_is_unreachable(else_result)) |
| 7487 | ir_mark_gen(ir_build_br(irb, parent_scope, node, end_block, is_comptime)); | 8518 | ir_mark_gen(ir_build_br(irb, parent_scope, node, end_block, is_comptime)); |
| 7488 | } | 8519 | } |
| 7489 | IrBasicBlock *after_else_block = irb->current_basic_block; | 8520 | IrBasicBlockSrc *after_else_block = irb->current_basic_block; |
| 7490 | ir_set_cursor_at_end_and_append_block(irb, end_block); | 8521 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 7491 | | 8522 | |
| 7492 | if (else_result) { | 8523 | if (else_result) { |
| ... | @@ -7500,29 +8531,29 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -7500,29 +8531,29 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo |
| 7500 | peer_parent->peers.last()->next_bb = end_block; | 8531 | peer_parent->peers.last()->next_bb = end_block; |
| 7501 | } | 8532 | } |
| 7502 | | 8533 | |
| 7503 | IrInstruction *phi = ir_build_phi(irb, parent_scope, node, incoming_blocks.length, | 8534 | IrInstSrc *phi = ir_build_phi(irb, parent_scope, node, incoming_blocks.length, |
| 7504 | incoming_blocks.items, incoming_values.items, peer_parent); | 8535 | incoming_blocks.items, incoming_values.items, peer_parent); |
| 7505 | return ir_lval_wrap(irb, parent_scope, phi, lval, result_loc); | 8536 | return ir_lval_wrap(irb, parent_scope, phi, lval, result_loc); |
| 7506 | } | 8537 | } |
| 7507 | | 8538 | |
| 7508 | static IrInstruction *ir_gen_bool_literal(IrBuilder *irb, Scope *scope, AstNode *node) { | 8539 | static IrInstSrc *ir_gen_bool_literal(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 7509 | assert(node->type == NodeTypeBoolLiteral); | 8540 | assert(node->type == NodeTypeBoolLiteral); |
| 7510 | return ir_build_const_bool(irb, scope, node, node->data.bool_literal.value); | 8541 | return ir_build_const_bool(irb, scope, node, node->data.bool_literal.value); |
| 7511 | } | 8542 | } |
| 7512 | | 8543 | |
| 7513 | static IrInstruction *ir_gen_enum_literal(IrBuilder *irb, Scope *scope, AstNode *node) { | 8544 | static IrInstSrc *ir_gen_enum_literal(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 7514 | assert(node->type == NodeTypeEnumLiteral); | 8545 | assert(node->type == NodeTypeEnumLiteral); |
| 7515 | Buf *name = &node->data.enum_literal.identifier->data.str_lit.str; | 8546 | Buf *name = &node->data.enum_literal.identifier->data.str_lit.str; |
| 7516 | return ir_build_const_enum_literal(irb, scope, node, name); | 8547 | return ir_build_const_enum_literal(irb, scope, node, name); |
| 7517 | } | 8548 | } |
| 7518 | | 8549 | |
| 7519 | static IrInstruction *ir_gen_string_literal(IrBuilder *irb, Scope *scope, AstNode *node) { | 8550 | static IrInstSrc *ir_gen_string_literal(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 7520 | assert(node->type == NodeTypeStringLiteral); | 8551 | assert(node->type == NodeTypeStringLiteral); |
| 7521 | | 8552 | |
| 7522 | return ir_build_const_str_lit(irb, scope, node, node->data.string_literal.buf); | 8553 | return ir_build_const_str_lit(irb, scope, node, node->data.string_literal.buf); |
| 7523 | } | 8554 | } |
| 7524 | | 8555 | |
| 7525 | static IrInstruction *ir_gen_array_type(IrBuilder *irb, Scope *scope, AstNode *node) { | 8556 | static IrInstSrc *ir_gen_array_type(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 7526 | assert(node->type == NodeTypeArrayType); | 8557 | assert(node->type == NodeTypeArrayType); |
| 7527 | | 8558 | |
| 7528 | AstNode *size_node = node->data.array_type.size; | 8559 | AstNode *size_node = node->data.array_type.size; |
| ... | @@ -7535,10 +8566,10 @@ static IrInstruction *ir_gen_array_type(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7535,10 +8566,10 @@ static IrInstruction *ir_gen_array_type(IrBuilder *irb, Scope *scope, AstNode *n |
| 7535 | | 8566 | |
| 7536 | Scope *comptime_scope = create_comptime_scope(irb->codegen, node, scope); | 8567 | Scope *comptime_scope = create_comptime_scope(irb->codegen, node, scope); |
| 7537 | | 8568 | |
| 7538 | IrInstruction *sentinel; | 8569 | IrInstSrc *sentinel; |
| 7539 | if (sentinel_expr != nullptr) { | 8570 | if (sentinel_expr != nullptr) { |
| 7540 | sentinel = ir_gen_node(irb, sentinel_expr, comptime_scope); | 8571 | sentinel = ir_gen_node(irb, sentinel_expr, comptime_scope); |
| 7541 | if (sentinel == irb->codegen->invalid_instruction) | 8572 | if (sentinel == irb->codegen->invalid_inst_src) |
| 7542 | return sentinel; | 8573 | return sentinel; |
| 7543 | } else { | 8574 | } else { |
| 7544 | sentinel = nullptr; | 8575 | sentinel = nullptr; |
| ... | @@ -7547,42 +8578,42 @@ static IrInstruction *ir_gen_array_type(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7547,42 +8578,42 @@ static IrInstruction *ir_gen_array_type(IrBuilder *irb, Scope *scope, AstNode *n |
| 7547 | if (size_node) { | 8578 | if (size_node) { |
| 7548 | if (is_const) { | 8579 | if (is_const) { |
| 7549 | add_node_error(irb->codegen, node, buf_create_from_str("const qualifier invalid on array type")); | 8580 | add_node_error(irb->codegen, node, buf_create_from_str("const qualifier invalid on array type")); |
| 7550 | return irb->codegen->invalid_instruction; | 8581 | return irb->codegen->invalid_inst_src; |
| 7551 | } | 8582 | } |
| 7552 | if (is_volatile) { | 8583 | if (is_volatile) { |
| 7553 | add_node_error(irb->codegen, node, buf_create_from_str("volatile qualifier invalid on array type")); | 8584 | add_node_error(irb->codegen, node, buf_create_from_str("volatile qualifier invalid on array type")); |
| 7554 | return irb->codegen->invalid_instruction; | 8585 | return irb->codegen->invalid_inst_src; |
| 7555 | } | 8586 | } |
| 7556 | if (is_allow_zero) { | 8587 | if (is_allow_zero) { |
| 7557 | add_node_error(irb->codegen, node, buf_create_from_str("allowzero qualifier invalid on array type")); | 8588 | add_node_error(irb->codegen, node, buf_create_from_str("allowzero qualifier invalid on array type")); |
| 7558 | return irb->codegen->invalid_instruction; | 8589 | return irb->codegen->invalid_inst_src; |
| 7559 | } | 8590 | } |
| 7560 | if (align_expr != nullptr) { | 8591 | if (align_expr != nullptr) { |
| 7561 | add_node_error(irb->codegen, node, buf_create_from_str("align qualifier invalid on array type")); | 8592 | add_node_error(irb->codegen, node, buf_create_from_str("align qualifier invalid on array type")); |
| 7562 | return irb->codegen->invalid_instruction; | 8593 | return irb->codegen->invalid_inst_src; |
| 7563 | } | 8594 | } |
| 7564 | | 8595 | |
| 7565 | IrInstruction *size_value = ir_gen_node(irb, size_node, comptime_scope); | 8596 | IrInstSrc *size_value = ir_gen_node(irb, size_node, comptime_scope); |
| 7566 | if (size_value == irb->codegen->invalid_instruction) | 8597 | if (size_value == irb->codegen->invalid_inst_src) |
| 7567 | return size_value; | 8598 | return size_value; |
| 7568 | | 8599 | |
| 7569 | IrInstruction *child_type = ir_gen_node(irb, child_type_node, comptime_scope); | 8600 | IrInstSrc *child_type = ir_gen_node(irb, child_type_node, comptime_scope); |
| 7570 | if (child_type == irb->codegen->invalid_instruction) | 8601 | if (child_type == irb->codegen->invalid_inst_src) |
| 7571 | return child_type; | 8602 | return child_type; |
| 7572 | | 8603 | |
| 7573 | return ir_build_array_type(irb, scope, node, size_value, sentinel, child_type); | 8604 | return ir_build_array_type(irb, scope, node, size_value, sentinel, child_type); |
| 7574 | } else { | 8605 | } else { |
| 7575 | IrInstruction *align_value; | 8606 | IrInstSrc *align_value; |
| 7576 | if (align_expr != nullptr) { | 8607 | if (align_expr != nullptr) { |
| 7577 | align_value = ir_gen_node(irb, align_expr, comptime_scope); | 8608 | align_value = ir_gen_node(irb, align_expr, comptime_scope); |
| 7578 | if (align_value == irb->codegen->invalid_instruction) | 8609 | if (align_value == irb->codegen->invalid_inst_src) |
| 7579 | return align_value; | 8610 | return align_value; |
| 7580 | } else { | 8611 | } else { |
| 7581 | align_value = nullptr; | 8612 | align_value = nullptr; |
| 7582 | } | 8613 | } |
| 7583 | | 8614 | |
| 7584 | IrInstruction *child_type = ir_gen_node(irb, child_type_node, comptime_scope); | 8615 | IrInstSrc *child_type = ir_gen_node(irb, child_type_node, comptime_scope); |
| 7585 | if (child_type == irb->codegen->invalid_instruction) | 8616 | if (child_type == irb->codegen->invalid_inst_src) |
| 7586 | return child_type; | 8617 | return child_type; |
| 7587 | | 8618 | |
| 7588 | return ir_build_slice_type(irb, scope, node, child_type, is_const, is_volatile, sentinel, | 8619 | return ir_build_slice_type(irb, scope, node, child_type, is_const, is_volatile, sentinel, |
| ... | @@ -7590,15 +8621,15 @@ static IrInstruction *ir_gen_array_type(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -7590,15 +8621,15 @@ static IrInstruction *ir_gen_array_type(IrBuilder *irb, Scope *scope, AstNode *n |
| 7590 | } | 8621 | } |
| 7591 | } | 8622 | } |
| 7592 | | 8623 | |
| 7593 | static IrInstruction *ir_gen_anyframe_type(IrBuilder *irb, Scope *scope, AstNode *node) { | 8624 | static IrInstSrc *ir_gen_anyframe_type(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 7594 | assert(node->type == NodeTypeAnyFrameType); | 8625 | assert(node->type == NodeTypeAnyFrameType); |
| 7595 | | 8626 | |
| 7596 | AstNode *payload_type_node = node->data.anyframe_type.payload_type; | 8627 | AstNode *payload_type_node = node->data.anyframe_type.payload_type; |
| 7597 | IrInstruction *payload_type_value = nullptr; | 8628 | IrInstSrc *payload_type_value = nullptr; |
| 7598 | | 8629 | |
| 7599 | if (payload_type_node != nullptr) { | 8630 | if (payload_type_node != nullptr) { |
| 7600 | payload_type_value = ir_gen_node(irb, payload_type_node, scope); | 8631 | payload_type_value = ir_gen_node(irb, payload_type_node, scope); |
| 7601 | if (payload_type_value == irb->codegen->invalid_instruction) | 8632 | if (payload_type_value == irb->codegen->invalid_inst_src) |
| 7602 | return payload_type_value; | 8633 | return payload_type_value; |
| 7603 | | 8634 | |
| 7604 | } | 8635 | } |
| ... | @@ -7606,7 +8637,7 @@ static IrInstruction *ir_gen_anyframe_type(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -7606,7 +8637,7 @@ static IrInstruction *ir_gen_anyframe_type(IrBuilder *irb, Scope *scope, AstNode |
| 7606 | return ir_build_anyframe_type(irb, scope, node, payload_type_value); | 8637 | return ir_build_anyframe_type(irb, scope, node, payload_type_value); |
| 7607 | } | 8638 | } |
| 7608 | | 8639 | |
| 7609 | static IrInstruction *ir_gen_undefined_literal(IrBuilder *irb, Scope *scope, AstNode *node) { | 8640 | static IrInstSrc *ir_gen_undefined_literal(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 7610 | assert(node->type == NodeTypeUndefinedLiteral); | 8641 | assert(node->type == NodeTypeUndefinedLiteral); |
| 7611 | return ir_build_const_undefined(irb, scope, node); | 8642 | return ir_build_const_undefined(irb, scope, node); |
| 7612 | } | 8643 | } |
| ... | @@ -7723,13 +8754,13 @@ static size_t find_asm_index(CodeGen *g, AstNode *node, AsmToken *tok, Buf *src_ | ... | @@ -7723,13 +8754,13 @@ static size_t find_asm_index(CodeGen *g, AstNode *node, AsmToken *tok, Buf *src_ |
| 7723 | return SIZE_MAX; | 8754 | return SIZE_MAX; |
| 7724 | } | 8755 | } |
| 7725 | | 8756 | |
| 7726 | static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *node) { | 8757 | static IrInstSrc *ir_gen_asm_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 7727 | assert(node->type == NodeTypeAsmExpr); | 8758 | assert(node->type == NodeTypeAsmExpr); |
| 7728 | AstNodeAsmExpr *asm_expr = &node->data.asm_expr; | 8759 | AstNodeAsmExpr *asm_expr = &node->data.asm_expr; |
| 7729 | | 8760 | |
| 7730 | IrInstruction *asm_template = ir_gen_node(irb, asm_expr->asm_template, scope); | 8761 | IrInstSrc *asm_template = ir_gen_node(irb, asm_expr->asm_template, scope); |
| 7731 | if (asm_template == irb->codegen->invalid_instruction) | 8762 | if (asm_template == irb->codegen->invalid_inst_src) |
| 7732 | return irb->codegen->invalid_instruction; | 8763 | return irb->codegen->invalid_inst_src; |
| 7733 | | 8764 | |
| 7734 | bool is_volatile = asm_expr->volatile_token != nullptr; | 8765 | bool is_volatile = asm_expr->volatile_token != nullptr; |
| 7735 | bool in_fn_scope = (scope_fn_entry(scope) != nullptr); | 8766 | bool in_fn_scope = (scope_fn_entry(scope) != nullptr); |
| ... | @@ -7738,7 +8769,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -7738,7 +8769,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod |
| 7738 | if (is_volatile) { | 8769 | if (is_volatile) { |
| 7739 | add_token_error(irb->codegen, node->owner, asm_expr->volatile_token, | 8770 | add_token_error(irb->codegen, node->owner, asm_expr->volatile_token, |
| 7740 | buf_sprintf("volatile is meaningless on global assembly")); | 8771 | buf_sprintf("volatile is meaningless on global assembly")); |
| 7741 | return irb->codegen->invalid_instruction; | 8772 | return irb->codegen->invalid_inst_src; |
| 7742 | } | 8773 | } |
| 7743 | | 8774 | |
| 7744 | if (asm_expr->output_list.length != 0 || asm_expr->input_list.length != 0 || | 8775 | if (asm_expr->output_list.length != 0 || asm_expr->input_list.length != 0 || |
| ... | @@ -7746,34 +8777,34 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -7746,34 +8777,34 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod |
| 7746 | { | 8777 | { |
| 7747 | add_node_error(irb->codegen, node, | 8778 | add_node_error(irb->codegen, node, |
| 7748 | buf_sprintf("global assembly cannot have inputs, outputs, or clobbers")); | 8779 | buf_sprintf("global assembly cannot have inputs, outputs, or clobbers")); |
| 7749 | return irb->codegen->invalid_instruction; | 8780 | return irb->codegen->invalid_inst_src; |
| 7750 | } | 8781 | } |
| 7751 | | 8782 | |
| 7752 | return ir_build_asm_src(irb, scope, node, asm_template, nullptr, nullptr, | 8783 | return ir_build_asm_src(irb, scope, node, asm_template, nullptr, nullptr, |
| 7753 | nullptr, 0, is_volatile, true); | 8784 | nullptr, 0, is_volatile, true); |
| 7754 | } | 8785 | } |
| 7755 | | 8786 | |
| 7756 | IrInstruction **input_list = allocate<IrInstruction *>(asm_expr->input_list.length); | 8787 | IrInstSrc **input_list = allocate<IrInstSrc *>(asm_expr->input_list.length); |
| 7757 | IrInstruction **output_types = allocate<IrInstruction *>(asm_expr->output_list.length); | 8788 | IrInstSrc **output_types = allocate<IrInstSrc *>(asm_expr->output_list.length); |
| 7758 | ZigVar **output_vars = allocate<ZigVar *>(asm_expr->output_list.length); | 8789 | ZigVar **output_vars = allocate<ZigVar *>(asm_expr->output_list.length); |
| 7759 | size_t return_count = 0; | 8790 | size_t return_count = 0; |
| 7760 | if (!is_volatile && asm_expr->output_list.length == 0) { | 8791 | if (!is_volatile && asm_expr->output_list.length == 0) { |
| 7761 | add_node_error(irb->codegen, node, | 8792 | add_node_error(irb->codegen, node, |
| 7762 | buf_sprintf("assembly expression with no output must be marked volatile")); | 8793 | buf_sprintf("assembly expression with no output must be marked volatile")); |
| 7763 | return irb->codegen->invalid_instruction; | 8794 | return irb->codegen->invalid_inst_src; |
| 7764 | } | 8795 | } |
| 7765 | for (size_t i = 0; i < asm_expr->output_list.length; i += 1) { | 8796 | for (size_t i = 0; i < asm_expr->output_list.length; i += 1) { |
| 7766 | AsmOutput *asm_output = asm_expr->output_list.at(i); | 8797 | AsmOutput *asm_output = asm_expr->output_list.at(i); |
| 7767 | if (asm_output->return_type) { | 8798 | if (asm_output->return_type) { |
| 7768 | return_count += 1; | 8799 | return_count += 1; |
| 7769 | | 8800 | |
| 7770 | IrInstruction *return_type = ir_gen_node(irb, asm_output->return_type, scope); | 8801 | IrInstSrc *return_type = ir_gen_node(irb, asm_output->return_type, scope); |
| 7771 | if (return_type == irb->codegen->invalid_instruction) | 8802 | if (return_type == irb->codegen->invalid_inst_src) |
| 7772 | return irb->codegen->invalid_instruction; | 8803 | return irb->codegen->invalid_inst_src; |
| 7773 | if (return_count > 1) { | 8804 | if (return_count > 1) { |
| 7774 | add_node_error(irb->codegen, node, | 8805 | add_node_error(irb->codegen, node, |
| 7775 | buf_sprintf("inline assembly allows up to one output value")); | 8806 | buf_sprintf("inline assembly allows up to one output value")); |
| 7776 | return irb->codegen->invalid_instruction; | 8807 | return irb->codegen->invalid_inst_src; |
| 7777 | } | 8808 | } |
| 7778 | output_types[i] = return_type; | 8809 | output_types[i] = return_type; |
| 7779 | } else { | 8810 | } else { |
| ... | @@ -7786,7 +8817,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -7786,7 +8817,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod |
| 7786 | } else { | 8817 | } else { |
| 7787 | add_node_error(irb->codegen, node, | 8818 | add_node_error(irb->codegen, node, |
| 7788 | buf_sprintf("use of undeclared identifier '%s'", buf_ptr(variable_name))); | 8819 | buf_sprintf("use of undeclared identifier '%s'", buf_ptr(variable_name))); |
| 7789 | return irb->codegen->invalid_instruction; | 8820 | return irb->codegen->invalid_inst_src; |
| 7790 | } | 8821 | } |
| 7791 | } | 8822 | } |
| 7792 | | 8823 | |
| ... | @@ -7796,14 +8827,14 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -7796,14 +8827,14 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod |
| 7796 | buf_sprintf("invalid modifier starting output constraint for '%s': '%c', only '=' is supported." | 8827 | buf_sprintf("invalid modifier starting output constraint for '%s': '%c', only '=' is supported." |
| 7797 | " Compiler TODO: see https://github.com/ziglang/zig/issues/215", | 8828 | " Compiler TODO: see https://github.com/ziglang/zig/issues/215", |
| 7798 | buf_ptr(asm_output->asm_symbolic_name), modifier)); | 8829 | buf_ptr(asm_output->asm_symbolic_name), modifier)); |
| 7799 | return irb->codegen->invalid_instruction; | 8830 | return irb->codegen->invalid_inst_src; |
| 7800 | } | 8831 | } |
| 7801 | } | 8832 | } |
| 7802 | for (size_t i = 0; i < asm_expr->input_list.length; i += 1) { | 8833 | for (size_t i = 0; i < asm_expr->input_list.length; i += 1) { |
| 7803 | AsmInput *asm_input = asm_expr->input_list.at(i); | 8834 | AsmInput *asm_input = asm_expr->input_list.at(i); |
| 7804 | IrInstruction *input_value = ir_gen_node(irb, asm_input->expr, scope); | 8835 | IrInstSrc *input_value = ir_gen_node(irb, asm_input->expr, scope); |
| 7805 | if (input_value == irb->codegen->invalid_instruction) | 8836 | if (input_value == irb->codegen->invalid_inst_src) |
| 7806 | return irb->codegen->invalid_instruction; | 8837 | return irb->codegen->invalid_inst_src; |
| 7807 | | 8838 | |
| 7808 | input_list[i] = input_value; | 8839 | input_list[i] = input_value; |
| 7809 | } | 8840 | } |
| ... | @@ -7812,7 +8843,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod | ... | @@ -7812,7 +8843,7 @@ static IrInstruction *ir_gen_asm_expr(IrBuilder *irb, Scope *scope, AstNode *nod |
| 7812 | output_vars, return_count, is_volatile, false); | 8843 | output_vars, return_count, is_volatile, false); |
| 7813 | } | 8844 | } |
| 7814 | | 8845 | |
| 7815 | static IrInstruction *ir_gen_if_optional_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 8846 | static IrInstSrc *ir_gen_if_optional_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 7816 | ResultLoc *result_loc) | 8847 | ResultLoc *result_loc) |
| 7817 | { | 8848 | { |
| 7818 | assert(node->type == NodeTypeIfOptional); | 8849 | assert(node->type == NodeTypeIfOptional); |
| ... | @@ -7823,24 +8854,24 @@ static IrInstruction *ir_gen_if_optional_expr(IrBuilder *irb, Scope *scope, AstN | ... | @@ -7823,24 +8854,24 @@ static IrInstruction *ir_gen_if_optional_expr(IrBuilder *irb, Scope *scope, AstN |
| 7823 | AstNode *else_node = node->data.test_expr.else_node; | 8854 | AstNode *else_node = node->data.test_expr.else_node; |
| 7824 | bool var_is_ptr = node->data.test_expr.var_is_ptr; | 8855 | bool var_is_ptr = node->data.test_expr.var_is_ptr; |
| 7825 | | 8856 | |
| 7826 | IrInstruction *maybe_val_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); | 8857 | IrInstSrc *maybe_val_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); |
| 7827 | if (maybe_val_ptr == irb->codegen->invalid_instruction) | 8858 | if (maybe_val_ptr == irb->codegen->invalid_inst_src) |
| 7828 | return maybe_val_ptr; | 8859 | return maybe_val_ptr; |
| 7829 | | 8860 | |
| 7830 | IrInstruction *maybe_val = ir_build_load_ptr(irb, scope, node, maybe_val_ptr); | 8861 | IrInstSrc *maybe_val = ir_build_load_ptr(irb, scope, node, maybe_val_ptr); |
| 7831 | IrInstruction *is_non_null = ir_build_test_nonnull(irb, scope, node, maybe_val); | 8862 | IrInstSrc *is_non_null = ir_build_test_non_null_src(irb, scope, node, maybe_val); |
| 7832 | | 8863 | |
| 7833 | IrBasicBlock *then_block = ir_create_basic_block(irb, scope, "OptionalThen"); | 8864 | IrBasicBlockSrc *then_block = ir_create_basic_block(irb, scope, "OptionalThen"); |
| 7834 | IrBasicBlock *else_block = ir_create_basic_block(irb, scope, "OptionalElse"); | 8865 | IrBasicBlockSrc *else_block = ir_create_basic_block(irb, scope, "OptionalElse"); |
| 7835 | IrBasicBlock *endif_block = ir_create_basic_block(irb, scope, "OptionalEndIf"); | 8866 | IrBasicBlockSrc *endif_block = ir_create_basic_block(irb, scope, "OptionalEndIf"); |
| 7836 | | 8867 | |
| 7837 | IrInstruction *is_comptime; | 8868 | IrInstSrc *is_comptime; |
| 7838 | if (ir_should_inline(irb->exec, scope)) { | 8869 | if (ir_should_inline(irb->exec, scope)) { |
| 7839 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 8870 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 7840 | } else { | 8871 | } else { |
| 7841 | is_comptime = ir_build_test_comptime(irb, scope, node, is_non_null); | 8872 | is_comptime = ir_build_test_comptime(irb, scope, node, is_non_null); |
| 7842 | } | 8873 | } |
| 7843 | IrInstruction *cond_br_inst = ir_build_cond_br(irb, scope, node, is_non_null, | 8874 | IrInstSrc *cond_br_inst = ir_build_cond_br(irb, scope, node, is_non_null, |
| 7844 | then_block, else_block, is_comptime); | 8875 | then_block, else_block, is_comptime); |
| 7845 | | 8876 | |
| 7846 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, else_block, endif_block, | 8877 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, else_block, endif_block, |
| ... | @@ -7856,48 +8887,48 @@ static IrInstruction *ir_gen_if_optional_expr(IrBuilder *irb, Scope *scope, AstN | ... | @@ -7856,48 +8887,48 @@ static IrInstruction *ir_gen_if_optional_expr(IrBuilder *irb, Scope *scope, AstN |
| 7856 | ZigVar *var = ir_create_var(irb, node, subexpr_scope, | 8887 | ZigVar *var = ir_create_var(irb, node, subexpr_scope, |
| 7857 | var_symbol, is_const, is_const, is_shadowable, is_comptime); | 8888 | var_symbol, is_const, is_const, is_shadowable, is_comptime); |
| 7858 | | 8889 | |
| 7859 | IrInstruction *payload_ptr = ir_build_optional_unwrap_ptr(irb, subexpr_scope, node, maybe_val_ptr, false, false); | 8890 | IrInstSrc *payload_ptr = ir_build_optional_unwrap_ptr(irb, subexpr_scope, node, maybe_val_ptr, false, false); |
| 7860 | IrInstruction *var_ptr = var_is_ptr ? ir_build_ref(irb, subexpr_scope, node, payload_ptr, true, false) : payload_ptr; | 8891 | IrInstSrc *var_ptr = var_is_ptr ? ir_build_ref_src(irb, subexpr_scope, node, payload_ptr, true, false) : payload_ptr; |
| 7861 | ir_build_var_decl_src(irb, subexpr_scope, node, var, nullptr, var_ptr); | 8892 | ir_build_var_decl_src(irb, subexpr_scope, node, var, nullptr, var_ptr); |
| 7862 | var_scope = var->child_scope; | 8893 | var_scope = var->child_scope; |
| 7863 | } else { | 8894 | } else { |
| 7864 | var_scope = subexpr_scope; | 8895 | var_scope = subexpr_scope; |
| 7865 | } | 8896 | } |
| 7866 | IrInstruction *then_expr_result = ir_gen_node_extra(irb, then_node, var_scope, lval, | 8897 | IrInstSrc *then_expr_result = ir_gen_node_extra(irb, then_node, var_scope, lval, |
| 7867 | &peer_parent->peers.at(0)->base); | 8898 | &peer_parent->peers.at(0)->base); |
| 7868 | if (then_expr_result == irb->codegen->invalid_instruction) | 8899 | if (then_expr_result == irb->codegen->invalid_inst_src) |
| 7869 | return then_expr_result; | 8900 | return then_expr_result; |
| 7870 | IrBasicBlock *after_then_block = irb->current_basic_block; | 8901 | IrBasicBlockSrc *after_then_block = irb->current_basic_block; |
| 7871 | if (!instr_is_unreachable(then_expr_result)) | 8902 | if (!instr_is_unreachable(then_expr_result)) |
| 7872 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); | 8903 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); |
| 7873 | | 8904 | |
| 7874 | ir_set_cursor_at_end_and_append_block(irb, else_block); | 8905 | ir_set_cursor_at_end_and_append_block(irb, else_block); |
| 7875 | IrInstruction *else_expr_result; | 8906 | IrInstSrc *else_expr_result; |
| 7876 | if (else_node) { | 8907 | if (else_node) { |
| 7877 | else_expr_result = ir_gen_node_extra(irb, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base); | 8908 | else_expr_result = ir_gen_node_extra(irb, else_node, subexpr_scope, lval, &peer_parent->peers.at(1)->base); |
| 7878 | if (else_expr_result == irb->codegen->invalid_instruction) | 8909 | if (else_expr_result == irb->codegen->invalid_inst_src) |
| 7879 | return else_expr_result; | 8910 | return else_expr_result; |
| 7880 | } else { | 8911 | } else { |
| 7881 | else_expr_result = ir_build_const_void(irb, scope, node); | 8912 | else_expr_result = ir_build_const_void(irb, scope, node); |
| 7882 | ir_build_end_expr(irb, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); | 8913 | ir_build_end_expr(irb, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); |
| 7883 | } | 8914 | } |
| 7884 | IrBasicBlock *after_else_block = irb->current_basic_block; | 8915 | IrBasicBlockSrc *after_else_block = irb->current_basic_block; |
| 7885 | if (!instr_is_unreachable(else_expr_result)) | 8916 | if (!instr_is_unreachable(else_expr_result)) |
| 7886 | 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)); |
| 7887 | | 8918 | |
| 7888 | ir_set_cursor_at_end_and_append_block(irb, endif_block); | 8919 | ir_set_cursor_at_end_and_append_block(irb, endif_block); |
| 7889 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 8920 | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 7890 | incoming_values[0] = then_expr_result; | 8921 | incoming_values[0] = then_expr_result; |
| 7891 | incoming_values[1] = else_expr_result; | 8922 | incoming_values[1] = else_expr_result; |
| 7892 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); | 8923 | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 7893 | incoming_blocks[0] = after_then_block; | 8924 | incoming_blocks[0] = after_then_block; |
| 7894 | incoming_blocks[1] = after_else_block; | 8925 | incoming_blocks[1] = after_else_block; |
| 7895 | | 8926 | |
| 7896 | IrInstruction *phi = ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, peer_parent); | 8927 | IrInstSrc *phi = ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, peer_parent); |
| 7897 | return ir_expr_wrap(irb, scope, phi, result_loc); | 8928 | return ir_expr_wrap(irb, scope, phi, result_loc); |
| 7898 | } | 8929 | } |
| 7899 | | 8930 | |
| 7900 | static IrInstruction *ir_gen_if_err_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 8931 | static IrInstSrc *ir_gen_if_err_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 7901 | ResultLoc *result_loc) | 8932 | ResultLoc *result_loc) |
| 7902 | { | 8933 | { |
| 7903 | assert(node->type == NodeTypeIfErrorExpr); | 8934 | assert(node->type == NodeTypeIfErrorExpr); |
| ... | @@ -7910,20 +8941,20 @@ static IrInstruction *ir_gen_if_err_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -7910,20 +8941,20 @@ static IrInstruction *ir_gen_if_err_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 7910 | Buf *var_symbol = node->data.if_err_expr.var_symbol; | 8941 | Buf *var_symbol = node->data.if_err_expr.var_symbol; |
| 7911 | Buf *err_symbol = node->data.if_err_expr.err_symbol; | 8942 | Buf *err_symbol = node->data.if_err_expr.err_symbol; |
| 7912 | | 8943 | |
| 7913 | IrInstruction *err_val_ptr = ir_gen_node_extra(irb, target_node, scope, LValPtr, nullptr); | 8944 | IrInstSrc *err_val_ptr = ir_gen_node_extra(irb, target_node, scope, LValPtr, nullptr); |
| 7914 | if (err_val_ptr == irb->codegen->invalid_instruction) | 8945 | if (err_val_ptr == irb->codegen->invalid_inst_src) |
| 7915 | return err_val_ptr; | 8946 | return err_val_ptr; |
| 7916 | | 8947 | |
| 7917 | IrInstruction *err_val = ir_build_load_ptr(irb, scope, node, err_val_ptr); | 8948 | IrInstSrc *err_val = ir_build_load_ptr(irb, scope, node, err_val_ptr); |
| 7918 | IrInstruction *is_err = ir_build_test_err_src(irb, scope, node, err_val_ptr, true, false); | 8949 | IrInstSrc *is_err = ir_build_test_err_src(irb, scope, node, err_val_ptr, true, false); |
| 7919 | | 8950 | |
| 7920 | IrBasicBlock *ok_block = ir_create_basic_block(irb, scope, "TryOk"); | 8951 | IrBasicBlockSrc *ok_block = ir_create_basic_block(irb, scope, "TryOk"); |
| 7921 | IrBasicBlock *else_block = ir_create_basic_block(irb, scope, "TryElse"); | 8952 | IrBasicBlockSrc *else_block = ir_create_basic_block(irb, scope, "TryElse"); |
| 7922 | IrBasicBlock *endif_block = ir_create_basic_block(irb, scope, "TryEnd"); | 8953 | IrBasicBlockSrc *endif_block = ir_create_basic_block(irb, scope, "TryEnd"); |
| 7923 | | 8954 | |
| 7924 | bool force_comptime = ir_should_inline(irb->exec, scope); | 8955 | bool force_comptime = ir_should_inline(irb->exec, scope); |
| 7925 | IrInstruction *is_comptime = force_comptime ? ir_build_const_bool(irb, scope, node, true) : ir_build_test_comptime(irb, scope, node, is_err); | 8956 | IrInstSrc *is_comptime = force_comptime ? ir_build_const_bool(irb, scope, node, true) : ir_build_test_comptime(irb, scope, node, is_err); |
| 7926 | IrInstruction *cond_br_inst = ir_build_cond_br(irb, scope, node, is_err, else_block, ok_block, is_comptime); | 8957 | IrInstSrc *cond_br_inst = ir_build_cond_br(irb, scope, node, is_err, else_block, ok_block, is_comptime); |
| 7927 | | 8958 | |
| 7928 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, else_block, endif_block, | 8959 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, else_block, endif_block, |
| 7929 | result_loc, is_comptime); | 8960 | result_loc, is_comptime); |
| ... | @@ -7934,29 +8965,29 @@ static IrInstruction *ir_gen_if_err_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -7934,29 +8965,29 @@ static IrInstruction *ir_gen_if_err_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 7934 | Scope *var_scope; | 8965 | Scope *var_scope; |
| 7935 | if (var_symbol) { | 8966 | if (var_symbol) { |
| 7936 | bool is_shadowable = false; | 8967 | bool is_shadowable = false; |
| 7937 | 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); | 8968 | 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); |
| 7938 | ZigVar *var = ir_create_var(irb, node, subexpr_scope, | 8969 | ZigVar *var = ir_create_var(irb, node, subexpr_scope, |
| 7939 | var_symbol, var_is_const, var_is_const, is_shadowable, var_is_comptime); | 8970 | var_symbol, var_is_const, var_is_const, is_shadowable, var_is_comptime); |
| 7940 | | 8971 | |
| 7941 | IrInstruction *payload_ptr = ir_build_unwrap_err_payload(irb, subexpr_scope, node, err_val_ptr, false, false); | 8972 | IrInstSrc *payload_ptr = ir_build_unwrap_err_payload_src(irb, subexpr_scope, node, err_val_ptr, false, false); |
| 7942 | IrInstruction *var_ptr = var_is_ptr ? | 8973 | IrInstSrc *var_ptr = var_is_ptr ? |
| 7943 | ir_build_ref(irb, subexpr_scope, node, payload_ptr, true, false) : payload_ptr; | 8974 | ir_build_ref_src(irb, subexpr_scope, node, payload_ptr, true, false) : payload_ptr; |
| 7944 | ir_build_var_decl_src(irb, subexpr_scope, node, var, nullptr, var_ptr); | 8975 | ir_build_var_decl_src(irb, subexpr_scope, node, var, nullptr, var_ptr); |
| 7945 | var_scope = var->child_scope; | 8976 | var_scope = var->child_scope; |
| 7946 | } else { | 8977 | } else { |
| 7947 | var_scope = subexpr_scope; | 8978 | var_scope = subexpr_scope; |
| 7948 | } | 8979 | } |
| 7949 | IrInstruction *then_expr_result = ir_gen_node_extra(irb, then_node, var_scope, lval, | 8980 | IrInstSrc *then_expr_result = ir_gen_node_extra(irb, then_node, var_scope, lval, |
| 7950 | &peer_parent->peers.at(0)->base); | 8981 | &peer_parent->peers.at(0)->base); |
| 7951 | if (then_expr_result == irb->codegen->invalid_instruction) | 8982 | if (then_expr_result == irb->codegen->invalid_inst_src) |
| 7952 | return then_expr_result; | 8983 | return then_expr_result; |
| 7953 | IrBasicBlock *after_then_block = irb->current_basic_block; | 8984 | IrBasicBlockSrc *after_then_block = irb->current_basic_block; |
| 7954 | if (!instr_is_unreachable(then_expr_result)) | 8985 | if (!instr_is_unreachable(then_expr_result)) |
| 7955 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); | 8986 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); |
| 7956 | | 8987 | |
| 7957 | ir_set_cursor_at_end_and_append_block(irb, else_block); | 8988 | ir_set_cursor_at_end_and_append_block(irb, else_block); |
| 7958 | | 8989 | |
| 7959 | IrInstruction *else_expr_result; | 8990 | IrInstSrc *else_expr_result; |
| 7960 | if (else_node) { | 8991 | if (else_node) { |
| 7961 | Scope *err_var_scope; | 8992 | Scope *err_var_scope; |
| 7962 | if (err_symbol) { | 8993 | if (err_symbol) { |
| ... | @@ -7965,40 +8996,40 @@ static IrInstruction *ir_gen_if_err_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -7965,40 +8996,40 @@ static IrInstruction *ir_gen_if_err_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 7965 | ZigVar *var = ir_create_var(irb, node, subexpr_scope, | 8996 | ZigVar *var = ir_create_var(irb, node, subexpr_scope, |
| 7966 | err_symbol, is_const, is_const, is_shadowable, is_comptime); | 8997 | err_symbol, is_const, is_const, is_shadowable, is_comptime); |
| 7967 | | 8998 | |
| 7968 | IrInstruction *err_ptr = ir_build_unwrap_err_code(irb, subexpr_scope, node, err_val_ptr); | 8999 | IrInstSrc *err_ptr = ir_build_unwrap_err_code_src(irb, subexpr_scope, node, err_val_ptr); |
| 7969 | ir_build_var_decl_src(irb, subexpr_scope, node, var, nullptr, err_ptr); | 9000 | ir_build_var_decl_src(irb, subexpr_scope, node, var, nullptr, err_ptr); |
| 7970 | err_var_scope = var->child_scope; | 9001 | err_var_scope = var->child_scope; |
| 7971 | } else { | 9002 | } else { |
| 7972 | err_var_scope = subexpr_scope; | 9003 | err_var_scope = subexpr_scope; |
| 7973 | } | 9004 | } |
| 7974 | else_expr_result = ir_gen_node_extra(irb, else_node, err_var_scope, lval, &peer_parent->peers.at(1)->base); | 9005 | else_expr_result = ir_gen_node_extra(irb, else_node, err_var_scope, lval, &peer_parent->peers.at(1)->base); |
| 7975 | if (else_expr_result == irb->codegen->invalid_instruction) | 9006 | if (else_expr_result == irb->codegen->invalid_inst_src) |
| 7976 | return else_expr_result; | 9007 | return else_expr_result; |
| 7977 | } else { | 9008 | } else { |
| 7978 | else_expr_result = ir_build_const_void(irb, scope, node); | 9009 | else_expr_result = ir_build_const_void(irb, scope, node); |
| 7979 | ir_build_end_expr(irb, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); | 9010 | ir_build_end_expr(irb, scope, node, else_expr_result, &peer_parent->peers.at(1)->base); |
| 7980 | } | 9011 | } |
| 7981 | IrBasicBlock *after_else_block = irb->current_basic_block; | 9012 | IrBasicBlockSrc *after_else_block = irb->current_basic_block; |
| 7982 | if (!instr_is_unreachable(else_expr_result)) | 9013 | if (!instr_is_unreachable(else_expr_result)) |
| 7983 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); | 9014 | ir_mark_gen(ir_build_br(irb, scope, node, endif_block, is_comptime)); |
| 7984 | | 9015 | |
| 7985 | ir_set_cursor_at_end_and_append_block(irb, endif_block); | 9016 | ir_set_cursor_at_end_and_append_block(irb, endif_block); |
| 7986 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 9017 | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 7987 | incoming_values[0] = then_expr_result; | 9018 | incoming_values[0] = then_expr_result; |
| 7988 | incoming_values[1] = else_expr_result; | 9019 | incoming_values[1] = else_expr_result; |
| 7989 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); | 9020 | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 7990 | incoming_blocks[0] = after_then_block; | 9021 | incoming_blocks[0] = after_then_block; |
| 7991 | incoming_blocks[1] = after_else_block; | 9022 | incoming_blocks[1] = after_else_block; |
| 7992 | | 9023 | |
| 7993 | IrInstruction *phi = ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, peer_parent); | 9024 | IrInstSrc *phi = ir_build_phi(irb, scope, node, 2, incoming_blocks, incoming_values, peer_parent); |
| 7994 | return ir_expr_wrap(irb, scope, phi, result_loc); | 9025 | return ir_expr_wrap(irb, scope, phi, result_loc); |
| 7995 | } | 9026 | } |
| 7996 | | 9027 | |
| 7997 | static bool ir_gen_switch_prong_expr(IrBuilder *irb, Scope *scope, AstNode *switch_node, AstNode *prong_node, | 9028 | static bool ir_gen_switch_prong_expr(IrBuilderSrc *irb, Scope *scope, AstNode *switch_node, AstNode *prong_node, |
| 7998 | IrBasicBlock *end_block, IrInstruction *is_comptime, IrInstruction *var_is_comptime, | 9029 | IrBasicBlockSrc *end_block, IrInstSrc *is_comptime, IrInstSrc *var_is_comptime, |
| 7999 | IrInstruction *target_value_ptr, IrInstruction **prong_values, size_t prong_values_len, | 9030 | IrInstSrc *target_value_ptr, IrInstSrc **prong_values, size_t prong_values_len, |
| 8000 | ZigList<IrBasicBlock *> *incoming_blocks, ZigList<IrInstruction *> *incoming_values, | 9031 | ZigList<IrBasicBlockSrc *> *incoming_blocks, ZigList<IrInstSrc *> *incoming_values, |
| 8001 | IrInstructionSwitchElseVar **out_switch_else_var, LVal lval, ResultLoc *result_loc) | 9032 | IrInstSrcSwitchElseVar **out_switch_else_var, LVal lval, ResultLoc *result_loc) |
| 8002 | { | 9033 | { |
| 8003 | assert(switch_node->type == NodeTypeSwitchExpr); | 9034 | assert(switch_node->type == NodeTypeSwitchExpr); |
| 8004 | assert(prong_node->type == NodeTypeSwitchProng); | 9035 | assert(prong_node->type == NodeTypeSwitchProng); |
| ... | @@ -8016,28 +9047,28 @@ static bool ir_gen_switch_prong_expr(IrBuilder *irb, Scope *scope, AstNode *swit | ... | @@ -8016,28 +9047,28 @@ static bool ir_gen_switch_prong_expr(IrBuilder *irb, Scope *scope, AstNode *swit |
| 8016 | ZigVar *var = ir_create_var(irb, var_symbol_node, scope, | 9047 | ZigVar *var = ir_create_var(irb, var_symbol_node, scope, |
| 8017 | var_name, is_const, is_const, is_shadowable, var_is_comptime); | 9048 | var_name, is_const, is_const, is_shadowable, var_is_comptime); |
| 8018 | child_scope = var->child_scope; | 9049 | child_scope = var->child_scope; |
| 8019 | IrInstruction *var_ptr; | 9050 | IrInstSrc *var_ptr; |
| 8020 | if (out_switch_else_var != nullptr) { | 9051 | if (out_switch_else_var != nullptr) { |
| 8021 | IrInstructionSwitchElseVar *switch_else_var = ir_build_switch_else_var(irb, scope, var_symbol_node, | 9052 | IrInstSrcSwitchElseVar *switch_else_var = ir_build_switch_else_var(irb, scope, var_symbol_node, |
| 8022 | target_value_ptr); | 9053 | target_value_ptr); |
| 8023 | *out_switch_else_var = switch_else_var; | 9054 | *out_switch_else_var = switch_else_var; |
| 8024 | IrInstruction *payload_ptr = &switch_else_var->base; | 9055 | IrInstSrc *payload_ptr = &switch_else_var->base; |
| 8025 | var_ptr = var_is_ptr ? ir_build_ref(irb, scope, var_symbol_node, payload_ptr, true, false) : payload_ptr; | 9056 | var_ptr = var_is_ptr ? ir_build_ref_src(irb, scope, var_symbol_node, payload_ptr, true, false) : payload_ptr; |
| 8026 | } else if (prong_values != nullptr) { | 9057 | } else if (prong_values != nullptr) { |
| 8027 | IrInstruction *payload_ptr = ir_build_switch_var(irb, scope, var_symbol_node, target_value_ptr, | 9058 | IrInstSrc *payload_ptr = ir_build_switch_var(irb, scope, var_symbol_node, target_value_ptr, |
| 8028 | prong_values, prong_values_len); | 9059 | prong_values, prong_values_len); |
| 8029 | var_ptr = var_is_ptr ? ir_build_ref(irb, scope, var_symbol_node, payload_ptr, true, false) : payload_ptr; | 9060 | var_ptr = var_is_ptr ? ir_build_ref_src(irb, scope, var_symbol_node, payload_ptr, true, false) : payload_ptr; |
| 8030 | } else { | 9061 | } else { |
| 8031 | var_ptr = var_is_ptr ? | 9062 | var_ptr = var_is_ptr ? |
| 8032 | ir_build_ref(irb, scope, var_symbol_node, target_value_ptr, true, false) : target_value_ptr; | 9063 | ir_build_ref_src(irb, scope, var_symbol_node, target_value_ptr, true, false) : target_value_ptr; |
| 8033 | } | 9064 | } |
| 8034 | ir_build_var_decl_src(irb, scope, var_symbol_node, var, nullptr, var_ptr); | 9065 | ir_build_var_decl_src(irb, scope, var_symbol_node, var, nullptr, var_ptr); |
| 8035 | } else { | 9066 | } else { |
| 8036 | child_scope = scope; | 9067 | child_scope = scope; |
| 8037 | } | 9068 | } |
| 8038 | | 9069 | |
| 8039 | IrInstruction *expr_result = ir_gen_node_extra(irb, expr_node, child_scope, lval, result_loc); | 9070 | IrInstSrc *expr_result = ir_gen_node_extra(irb, expr_node, child_scope, lval, result_loc); |
| 8040 | if (expr_result == irb->codegen->invalid_instruction) | 9071 | if (expr_result == irb->codegen->invalid_inst_src) |
| 8041 | return false; | 9072 | return false; |
| 8042 | if (!instr_is_unreachable(expr_result)) | 9073 | if (!instr_is_unreachable(expr_result)) |
| 8043 | ir_mark_gen(ir_build_br(irb, scope, switch_node, end_block, is_comptime)); | 9074 | ir_mark_gen(ir_build_br(irb, scope, switch_node, end_block, is_comptime)); |
| ... | @@ -8046,25 +9077,25 @@ static bool ir_gen_switch_prong_expr(IrBuilder *irb, Scope *scope, AstNode *swit | ... | @@ -8046,25 +9077,25 @@ static bool ir_gen_switch_prong_expr(IrBuilder *irb, Scope *scope, AstNode *swit |
| 8046 | return true; | 9077 | return true; |
| 8047 | } | 9078 | } |
| 8048 | | 9079 | |
| 8049 | static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 9080 | static IrInstSrc *ir_gen_switch_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 8050 | ResultLoc *result_loc) | 9081 | ResultLoc *result_loc) |
| 8051 | { | 9082 | { |
| 8052 | assert(node->type == NodeTypeSwitchExpr); | 9083 | assert(node->type == NodeTypeSwitchExpr); |
| 8053 | | 9084 | |
| 8054 | AstNode *target_node = node->data.switch_expr.expr; | 9085 | AstNode *target_node = node->data.switch_expr.expr; |
| 8055 | IrInstruction *target_value_ptr = ir_gen_node_extra(irb, target_node, scope, LValPtr, nullptr); | 9086 | IrInstSrc *target_value_ptr = ir_gen_node_extra(irb, target_node, scope, LValPtr, nullptr); |
| 8056 | if (target_value_ptr == irb->codegen->invalid_instruction) | 9087 | if (target_value_ptr == irb->codegen->invalid_inst_src) |
| 8057 | return target_value_ptr; | 9088 | return target_value_ptr; |
| 8058 | IrInstruction *target_value = ir_build_switch_target(irb, scope, node, target_value_ptr); | 9089 | IrInstSrc *target_value = ir_build_switch_target(irb, scope, node, target_value_ptr); |
| 8059 | | 9090 | |
| 8060 | IrBasicBlock *else_block = ir_create_basic_block(irb, scope, "SwitchElse"); | 9091 | IrBasicBlockSrc *else_block = ir_create_basic_block(irb, scope, "SwitchElse"); |
| 8061 | IrBasicBlock *end_block = ir_create_basic_block(irb, scope, "SwitchEnd"); | 9092 | IrBasicBlockSrc *end_block = ir_create_basic_block(irb, scope, "SwitchEnd"); |
| 8062 | | 9093 | |
| 8063 | size_t prong_count = node->data.switch_expr.prongs.length; | 9094 | size_t prong_count = node->data.switch_expr.prongs.length; |
| 8064 | ZigList<IrInstructionSwitchBrCase> cases = {0}; | 9095 | ZigList<IrInstSrcSwitchBrCase> cases = {0}; |
| 8065 | | 9096 | |
| 8066 | IrInstruction *is_comptime; | 9097 | IrInstSrc *is_comptime; |
| 8067 | IrInstruction *var_is_comptime; | 9098 | IrInstSrc *var_is_comptime; |
| 8068 | if (ir_should_inline(irb->exec, scope)) { | 9099 | if (ir_should_inline(irb->exec, scope)) { |
| 8069 | is_comptime = ir_build_const_bool(irb, scope, node, true); | 9100 | is_comptime = ir_build_const_bool(irb, scope, node, true); |
| 8070 | var_is_comptime = is_comptime; | 9101 | var_is_comptime = is_comptime; |
| ... | @@ -8073,11 +9104,11 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8073,11 +9104,11 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8073 | var_is_comptime = ir_build_test_comptime(irb, scope, node, target_value_ptr); | 9104 | var_is_comptime = ir_build_test_comptime(irb, scope, node, target_value_ptr); |
| 8074 | } | 9105 | } |
| 8075 | | 9106 | |
| 8076 | ZigList<IrInstruction *> incoming_values = {0}; | 9107 | ZigList<IrInstSrc *> incoming_values = {0}; |
| 8077 | ZigList<IrBasicBlock *> incoming_blocks = {0}; | 9108 | ZigList<IrBasicBlockSrc *> incoming_blocks = {0}; |
| 8078 | ZigList<IrInstructionCheckSwitchProngsRange> check_ranges = {0}; | 9109 | ZigList<IrInstSrcCheckSwitchProngsRange> check_ranges = {0}; |
| 8079 | | 9110 | |
| 8080 | IrInstructionSwitchElseVar *switch_else_var = nullptr; | 9111 | IrInstSrcSwitchElseVar *switch_else_var = nullptr; |
| 8081 | | 9112 | |
| 8082 | ResultLocPeerParent *peer_parent = allocate<ResultLocPeerParent>(1); | 9113 | ResultLocPeerParent *peer_parent = allocate<ResultLocPeerParent>(1); |
| 8083 | peer_parent->base.id = ResultLocIdPeerParent; | 9114 | peer_parent->base.id = ResultLocIdPeerParent; |
| ... | @@ -8099,7 +9130,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8099,7 +9130,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8099 | if (prong_node->data.switch_prong.any_items_are_range) { | 9130 | if (prong_node->data.switch_prong.any_items_are_range) { |
| 8100 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); | 9131 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); |
| 8101 | | 9132 | |
| 8102 | IrInstruction *ok_bit = nullptr; | 9133 | IrInstSrc *ok_bit = nullptr; |
| 8103 | AstNode *last_item_node = nullptr; | 9134 | AstNode *last_item_node = nullptr; |
| 8104 | for (size_t item_i = 0; item_i < prong_item_count; item_i += 1) { | 9135 | for (size_t item_i = 0; item_i < prong_item_count; item_i += 1) { |
| 8105 | AstNode *item_node = prong_node->data.switch_prong.items.at(item_i); | 9136 | AstNode *item_node = prong_node->data.switch_prong.items.at(item_i); |
| ... | @@ -8108,23 +9139,23 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8108,23 +9139,23 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8108 | AstNode *start_node = item_node->data.switch_range.start; | 9139 | AstNode *start_node = item_node->data.switch_range.start; |
| 8109 | AstNode *end_node = item_node->data.switch_range.end; | 9140 | AstNode *end_node = item_node->data.switch_range.end; |
| 8110 | | 9141 | |
| 8111 | IrInstruction *start_value = ir_gen_node(irb, start_node, comptime_scope); | 9142 | IrInstSrc *start_value = ir_gen_node(irb, start_node, comptime_scope); |
| 8112 | if (start_value == irb->codegen->invalid_instruction) | 9143 | if (start_value == irb->codegen->invalid_inst_src) |
| 8113 | return irb->codegen->invalid_instruction; | 9144 | return irb->codegen->invalid_inst_src; |
| 8114 | | 9145 | |
| 8115 | IrInstruction *end_value = ir_gen_node(irb, end_node, comptime_scope); | 9146 | IrInstSrc *end_value = ir_gen_node(irb, end_node, comptime_scope); |
| 8116 | if (end_value == irb->codegen->invalid_instruction) | 9147 | if (end_value == irb->codegen->invalid_inst_src) |
| 8117 | return irb->codegen->invalid_instruction; | 9148 | return irb->codegen->invalid_inst_src; |
| 8118 | | 9149 | |
| 8119 | IrInstructionCheckSwitchProngsRange *check_range = check_ranges.add_one(); | 9150 | IrInstSrcCheckSwitchProngsRange *check_range = check_ranges.add_one(); |
| 8120 | check_range->start = start_value; | 9151 | check_range->start = start_value; |
| 8121 | check_range->end = end_value; | 9152 | check_range->end = end_value; |
| 8122 | | 9153 | |
| 8123 | IrInstruction *lower_range_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpCmpGreaterOrEq, | 9154 | IrInstSrc *lower_range_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpCmpGreaterOrEq, |
| 8124 | target_value, start_value, false); | 9155 | target_value, start_value, false); |
| 8125 | IrInstruction *upper_range_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpCmpLessOrEq, | 9156 | IrInstSrc *upper_range_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpCmpLessOrEq, |
| 8126 | target_value, end_value, false); | 9157 | target_value, end_value, false); |
| 8127 | IrInstruction *both_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpBoolAnd, | 9158 | IrInstSrc *both_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpBoolAnd, |
| 8128 | lower_range_ok, upper_range_ok, false); | 9159 | lower_range_ok, upper_range_ok, false); |
| 8129 | if (ok_bit) { | 9160 | if (ok_bit) { |
| 8130 | ok_bit = ir_build_bin_op(irb, scope, item_node, IrBinOpBoolOr, both_ok, ok_bit, false); | 9161 | ok_bit = ir_build_bin_op(irb, scope, item_node, IrBinOpBoolOr, both_ok, ok_bit, false); |
| ... | @@ -8132,15 +9163,15 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8132,15 +9163,15 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8132 | ok_bit = both_ok; | 9163 | ok_bit = both_ok; |
| 8133 | } | 9164 | } |
| 8134 | } else { | 9165 | } else { |
| 8135 | IrInstruction *item_value = ir_gen_node(irb, item_node, comptime_scope); | 9166 | IrInstSrc *item_value = ir_gen_node(irb, item_node, comptime_scope); |
| 8136 | if (item_value == irb->codegen->invalid_instruction) | 9167 | if (item_value == irb->codegen->invalid_inst_src) |
| 8137 | return irb->codegen->invalid_instruction; | 9168 | return irb->codegen->invalid_inst_src; |
| 8138 | | 9169 | |
| 8139 | IrInstructionCheckSwitchProngsRange *check_range = check_ranges.add_one(); | 9170 | IrInstSrcCheckSwitchProngsRange *check_range = check_ranges.add_one(); |
| 8140 | check_range->start = item_value; | 9171 | check_range->start = item_value; |
| 8141 | check_range->end = item_value; | 9172 | check_range->end = item_value; |
| 8142 | | 9173 | |
| 8143 | IrInstruction *cmp_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpCmpEq, | 9174 | IrInstSrc *cmp_ok = ir_build_bin_op(irb, scope, item_node, IrBinOpCmpEq, |
| 8144 | item_value, target_value, false); | 9175 | item_value, target_value, false); |
| 8145 | if (ok_bit) { | 9176 | if (ok_bit) { |
| 8146 | ok_bit = ir_build_bin_op(irb, scope, item_node, IrBinOpBoolOr, cmp_ok, ok_bit, false); | 9177 | ok_bit = ir_build_bin_op(irb, scope, item_node, IrBinOpBoolOr, cmp_ok, ok_bit, false); |
| ... | @@ -8150,12 +9181,12 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8150,12 +9181,12 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8150 | } | 9181 | } |
| 8151 | } | 9182 | } |
| 8152 | | 9183 | |
| 8153 | IrBasicBlock *range_block_yes = ir_create_basic_block(irb, scope, "SwitchRangeYes"); | 9184 | IrBasicBlockSrc *range_block_yes = ir_create_basic_block(irb, scope, "SwitchRangeYes"); |
| 8154 | IrBasicBlock *range_block_no = ir_create_basic_block(irb, scope, "SwitchRangeNo"); | 9185 | IrBasicBlockSrc *range_block_no = ir_create_basic_block(irb, scope, "SwitchRangeNo"); |
| 8155 | | 9186 | |
| 8156 | assert(ok_bit); | 9187 | assert(ok_bit); |
| 8157 | assert(last_item_node); | 9188 | assert(last_item_node); |
| 8158 | IrInstruction *br_inst = ir_mark_gen(ir_build_cond_br(irb, scope, last_item_node, ok_bit, | 9189 | IrInstSrc *br_inst = ir_mark_gen(ir_build_cond_br(irb, scope, last_item_node, ok_bit, |
| 8159 | range_block_yes, range_block_no, is_comptime)); | 9190 | range_block_yes, range_block_no, is_comptime)); |
| 8160 | if (peer_parent->base.source_instruction == nullptr) { | 9191 | if (peer_parent->base.source_instruction == nullptr) { |
| 8161 | peer_parent->base.source_instruction = br_inst; | 9192 | peer_parent->base.source_instruction = br_inst; |
| ... | @@ -8170,7 +9201,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8170,7 +9201,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8170 | is_comptime, var_is_comptime, target_value_ptr, nullptr, 0, | 9201 | is_comptime, var_is_comptime, target_value_ptr, nullptr, 0, |
| 8171 | &incoming_blocks, &incoming_values, nullptr, LValNone, &this_peer_result_loc->base)) | 9202 | &incoming_blocks, &incoming_values, nullptr, LValNone, &this_peer_result_loc->base)) |
| 8172 | { | 9203 | { |
| 8173 | return irb->codegen->invalid_instruction; | 9204 | return irb->codegen->invalid_inst_src; |
| 8174 | } | 9205 | } |
| 8175 | | 9206 | |
| 8176 | ir_set_cursor_at_end_and_append_block(irb, range_block_no); | 9207 | ir_set_cursor_at_end_and_append_block(irb, range_block_no); |
| ... | @@ -8181,7 +9212,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8181,7 +9212,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8181 | buf_sprintf("multiple else prongs in switch expression")); | 9212 | buf_sprintf("multiple else prongs in switch expression")); |
| 8182 | add_error_note(irb->codegen, msg, else_prong, | 9213 | add_error_note(irb->codegen, msg, else_prong, |
| 8183 | buf_sprintf("previous else prong is here")); | 9214 | buf_sprintf("previous else prong is here")); |
| 8184 | return irb->codegen->invalid_instruction; | 9215 | return irb->codegen->invalid_inst_src; |
| 8185 | } | 9216 | } |
| 8186 | else_prong = prong_node; | 9217 | else_prong = prong_node; |
| 8187 | } else if (prong_item_count == 1 && | 9218 | } else if (prong_item_count == 1 && |
| ... | @@ -8192,7 +9223,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8192,7 +9223,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8192 | buf_sprintf("multiple '_' prongs in switch expression")); | 9223 | buf_sprintf("multiple '_' prongs in switch expression")); |
| 8193 | add_error_note(irb->codegen, msg, underscore_prong, | 9224 | add_error_note(irb->codegen, msg, underscore_prong, |
| 8194 | buf_sprintf("previous '_' prong is here")); | 9225 | buf_sprintf("previous '_' prong is here")); |
| 8195 | return irb->codegen->invalid_instruction; | 9226 | return irb->codegen->invalid_inst_src; |
| 8196 | } | 9227 | } |
| 8197 | underscore_prong = prong_node; | 9228 | underscore_prong = prong_node; |
| 8198 | } else { | 9229 | } else { |
| ... | @@ -8207,11 +9238,11 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8207,11 +9238,11 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8207 | else | 9238 | else |
| 8208 | add_error_note(irb->codegen, msg, underscore_prong, | 9239 | add_error_note(irb->codegen, msg, underscore_prong, |
| 8209 | buf_sprintf("'_' prong is here")); | 9240 | buf_sprintf("'_' prong is here")); |
| 8210 | return irb->codegen->invalid_instruction; | 9241 | return irb->codegen->invalid_inst_src; |
| 8211 | } | 9242 | } |
| 8212 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); | 9243 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); |
| 8213 | | 9244 | |
| 8214 | IrBasicBlock *prev_block = irb->current_basic_block; | 9245 | IrBasicBlockSrc *prev_block = irb->current_basic_block; |
| 8215 | if (peer_parent->peers.length > 0) { | 9246 | if (peer_parent->peers.length > 0) { |
| 8216 | peer_parent->peers.last()->next_bb = else_block; | 9247 | peer_parent->peers.last()->next_bb = else_block; |
| 8217 | } | 9248 | } |
| ... | @@ -8221,7 +9252,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8221,7 +9252,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8221 | is_comptime, var_is_comptime, target_value_ptr, nullptr, 0, &incoming_blocks, &incoming_values, | 9252 | is_comptime, var_is_comptime, target_value_ptr, nullptr, 0, &incoming_blocks, &incoming_values, |
| 8222 | &switch_else_var, LValNone, &this_peer_result_loc->base)) | 9253 | &switch_else_var, LValNone, &this_peer_result_loc->base)) |
| 8223 | { | 9254 | { |
| 8224 | return irb->codegen->invalid_instruction; | 9255 | return irb->codegen->invalid_inst_src; |
| 8225 | } | 9256 | } |
| 8226 | ir_set_cursor_at_end(irb, prev_block); | 9257 | ir_set_cursor_at_end(irb, prev_block); |
| 8227 | } | 9258 | } |
| ... | @@ -8240,29 +9271,29 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8240,29 +9271,29 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8240 | | 9271 | |
| 8241 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); | 9272 | ResultLocPeer *this_peer_result_loc = create_peer_result(peer_parent); |
| 8242 | | 9273 | |
| 8243 | IrBasicBlock *prong_block = ir_create_basic_block(irb, scope, "SwitchProng"); | 9274 | IrBasicBlockSrc *prong_block = ir_create_basic_block(irb, scope, "SwitchProng"); |
| 8244 | IrInstruction **items = allocate<IrInstruction *>(prong_item_count); | 9275 | IrInstSrc **items = allocate<IrInstSrc *>(prong_item_count); |
| 8245 | | 9276 | |
| 8246 | for (size_t item_i = 0; item_i < prong_item_count; item_i += 1) { | 9277 | for (size_t item_i = 0; item_i < prong_item_count; item_i += 1) { |
| 8247 | AstNode *item_node = prong_node->data.switch_prong.items.at(item_i); | 9278 | AstNode *item_node = prong_node->data.switch_prong.items.at(item_i); |
| 8248 | assert(item_node->type != NodeTypeSwitchRange); | 9279 | assert(item_node->type != NodeTypeSwitchRange); |
| 8249 | | 9280 | |
| 8250 | IrInstruction *item_value = ir_gen_node(irb, item_node, comptime_scope); | 9281 | IrInstSrc *item_value = ir_gen_node(irb, item_node, comptime_scope); |
| 8251 | if (item_value == irb->codegen->invalid_instruction) | 9282 | if (item_value == irb->codegen->invalid_inst_src) |
| 8252 | return irb->codegen->invalid_instruction; | 9283 | return irb->codegen->invalid_inst_src; |
| 8253 | | 9284 | |
| 8254 | IrInstructionCheckSwitchProngsRange *check_range = check_ranges.add_one(); | 9285 | IrInstSrcCheckSwitchProngsRange *check_range = check_ranges.add_one(); |
| 8255 | check_range->start = item_value; | 9286 | check_range->start = item_value; |
| 8256 | check_range->end = item_value; | 9287 | check_range->end = item_value; |
| 8257 | | 9288 | |
| 8258 | IrInstructionSwitchBrCase *this_case = cases.add_one(); | 9289 | IrInstSrcSwitchBrCase *this_case = cases.add_one(); |
| 8259 | this_case->value = item_value; | 9290 | this_case->value = item_value; |
| 8260 | this_case->block = prong_block; | 9291 | this_case->block = prong_block; |
| 8261 | | 9292 | |
| 8262 | items[item_i] = item_value; | 9293 | items[item_i] = item_value; |
| 8263 | } | 9294 | } |
| 8264 | | 9295 | |
| 8265 | IrBasicBlock *prev_block = irb->current_basic_block; | 9296 | IrBasicBlockSrc *prev_block = irb->current_basic_block; |
| 8266 | if (peer_parent->peers.length > 0) { | 9297 | if (peer_parent->peers.length > 0) { |
| 8267 | peer_parent->peers.last()->next_bb = prong_block; | 9298 | peer_parent->peers.last()->next_bb = prong_block; |
| 8268 | } | 9299 | } |
| ... | @@ -8272,21 +9303,21 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8272,21 +9303,21 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8272 | is_comptime, var_is_comptime, target_value_ptr, items, prong_item_count, | 9303 | is_comptime, var_is_comptime, target_value_ptr, items, prong_item_count, |
| 8273 | &incoming_blocks, &incoming_values, nullptr, LValNone, &this_peer_result_loc->base)) | 9304 | &incoming_blocks, &incoming_values, nullptr, LValNone, &this_peer_result_loc->base)) |
| 8274 | { | 9305 | { |
| 8275 | return irb->codegen->invalid_instruction; | 9306 | return irb->codegen->invalid_inst_src; |
| 8276 | } | 9307 | } |
| 8277 | | 9308 | |
| 8278 | ir_set_cursor_at_end(irb, prev_block); | 9309 | ir_set_cursor_at_end(irb, prev_block); |
| 8279 | | 9310 | |
| 8280 | } | 9311 | } |
| 8281 | | 9312 | |
| 8282 | IrInstruction *switch_prongs_void = ir_build_check_switch_prongs(irb, scope, node, target_value, | 9313 | IrInstSrc *switch_prongs_void = ir_build_check_switch_prongs(irb, scope, node, target_value, |
| 8283 | check_ranges.items, check_ranges.length, else_prong != nullptr, underscore_prong != nullptr); | 9314 | check_ranges.items, check_ranges.length, else_prong != nullptr, underscore_prong != nullptr); |
| 8284 | | 9315 | |
| 8285 | IrInstruction *br_instruction; | 9316 | IrInstSrc *br_instruction; |
| 8286 | if (cases.length == 0) { | 9317 | if (cases.length == 0) { |
| 8287 | br_instruction = ir_build_br(irb, scope, node, else_block, is_comptime); | 9318 | br_instruction = ir_build_br(irb, scope, node, else_block, is_comptime); |
| 8288 | } else { | 9319 | } else { |
| 8289 | IrInstructionSwitchBr *switch_br = ir_build_switch_br(irb, scope, node, target_value, else_block, | 9320 | IrInstSrcSwitchBr *switch_br = ir_build_switch_br_src(irb, scope, node, target_value, else_block, |
| 8290 | cases.length, cases.items, is_comptime, switch_prongs_void); | 9321 | cases.length, cases.items, is_comptime, switch_prongs_void); |
| 8291 | if (switch_else_var != nullptr) { | 9322 | if (switch_else_var != nullptr) { |
| 8292 | switch_else_var->switch_br = switch_br; | 9323 | switch_else_var->switch_br = switch_br; |
| ... | @@ -8314,7 +9345,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8314,7 +9345,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8314 | | 9345 | |
| 8315 | ir_set_cursor_at_end_and_append_block(irb, end_block); | 9346 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 8316 | assert(incoming_blocks.length == incoming_values.length); | 9347 | assert(incoming_blocks.length == incoming_values.length); |
| 8317 | IrInstruction *result_instruction; | 9348 | IrInstSrc *result_instruction; |
| 8318 | if (incoming_blocks.length == 0) { | 9349 | if (incoming_blocks.length == 0) { |
| 8319 | result_instruction = ir_build_const_void(irb, scope, node); | 9350 | result_instruction = ir_build_const_void(irb, scope, node); |
| 8320 | } else { | 9351 | } else { |
| ... | @@ -8324,7 +9355,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -8324,7 +9355,7 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 8324 | return ir_lval_wrap(irb, scope, result_instruction, lval, result_loc); | 9355 | return ir_lval_wrap(irb, scope, result_instruction, lval, result_loc); |
| 8325 | } | 9356 | } |
| 8326 | | 9357 | |
| 8327 | static IrInstruction *ir_gen_comptime(IrBuilder *irb, Scope *parent_scope, AstNode *node, LVal lval) { | 9358 | static IrInstSrc *ir_gen_comptime(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node, LVal lval) { |
| 8328 | assert(node->type == NodeTypeCompTime); | 9359 | assert(node->type == NodeTypeCompTime); |
| 8329 | | 9360 | |
| 8330 | Scope *child_scope = create_comptime_scope(irb->codegen, node, parent_scope); | 9361 | Scope *child_scope = create_comptime_scope(irb->codegen, node, parent_scope); |
| ... | @@ -8332,28 +9363,28 @@ static IrInstruction *ir_gen_comptime(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -8332,28 +9363,28 @@ static IrInstruction *ir_gen_comptime(IrBuilder *irb, Scope *parent_scope, AstNo |
| 8332 | return ir_gen_node_extra(irb, node->data.comptime_expr.expr, child_scope, lval, nullptr); | 9363 | return ir_gen_node_extra(irb, node->data.comptime_expr.expr, child_scope, lval, nullptr); |
| 8333 | } | 9364 | } |
| 8334 | | 9365 | |
| 8335 | static IrInstruction *ir_gen_return_from_block(IrBuilder *irb, Scope *break_scope, AstNode *node, ScopeBlock *block_scope) { | 9366 | static IrInstSrc *ir_gen_return_from_block(IrBuilderSrc *irb, Scope *break_scope, AstNode *node, ScopeBlock *block_scope) { |
| 8336 | IrInstruction *is_comptime; | 9367 | IrInstSrc *is_comptime; |
| 8337 | if (ir_should_inline(irb->exec, break_scope)) { | 9368 | if (ir_should_inline(irb->exec, break_scope)) { |
| 8338 | is_comptime = ir_build_const_bool(irb, break_scope, node, true); | 9369 | is_comptime = ir_build_const_bool(irb, break_scope, node, true); |
| 8339 | } else { | 9370 | } else { |
| 8340 | is_comptime = block_scope->is_comptime; | 9371 | is_comptime = block_scope->is_comptime; |
| 8341 | } | 9372 | } |
| 8342 | | 9373 | |
| 8343 | IrInstruction *result_value; | 9374 | IrInstSrc *result_value; |
| 8344 | if (node->data.break_expr.expr) { | 9375 | if (node->data.break_expr.expr) { |
| 8345 | ResultLocPeer *peer_result = create_peer_result(block_scope->peer_parent); | 9376 | ResultLocPeer *peer_result = create_peer_result(block_scope->peer_parent); |
| 8346 | block_scope->peer_parent->peers.append(peer_result); | 9377 | block_scope->peer_parent->peers.append(peer_result); |
| 8347 | | 9378 | |
| 8348 | result_value = ir_gen_node_extra(irb, node->data.break_expr.expr, break_scope, block_scope->lval, | 9379 | result_value = ir_gen_node_extra(irb, node->data.break_expr.expr, break_scope, block_scope->lval, |
| 8349 | &peer_result->base); | 9380 | &peer_result->base); |
| 8350 | if (result_value == irb->codegen->invalid_instruction) | 9381 | if (result_value == irb->codegen->invalid_inst_src) |
| 8351 | return irb->codegen->invalid_instruction; | 9382 | return irb->codegen->invalid_inst_src; |
| 8352 | } else { | 9383 | } else { |
| 8353 | result_value = ir_build_const_void(irb, break_scope, node); | 9384 | result_value = ir_build_const_void(irb, break_scope, node); |
| 8354 | } | 9385 | } |
| 8355 | | 9386 | |
| 8356 | IrBasicBlock *dest_block = block_scope->end_block; | 9387 | IrBasicBlockSrc *dest_block = block_scope->end_block; |
| 8357 | ir_gen_defers_for_block(irb, break_scope, dest_block->scope, false); | 9388 | ir_gen_defers_for_block(irb, break_scope, dest_block->scope, false); |
| 8358 | | 9389 | |
| 8359 | block_scope->incoming_blocks->append(irb->current_basic_block); | 9390 | block_scope->incoming_blocks->append(irb->current_basic_block); |
| ... | @@ -8361,7 +9392,7 @@ static IrInstruction *ir_gen_return_from_block(IrBuilder *irb, Scope *break_scop | ... | @@ -8361,7 +9392,7 @@ static IrInstruction *ir_gen_return_from_block(IrBuilder *irb, Scope *break_scop |
| 8361 | return ir_build_br(irb, break_scope, node, dest_block, is_comptime); | 9392 | return ir_build_br(irb, break_scope, node, dest_block, is_comptime); |
| 8362 | } | 9393 | } |
| 8363 | | 9394 | |
| 8364 | static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *break_scope, AstNode *node) { | 9395 | static IrInstSrc *ir_gen_break(IrBuilderSrc *irb, Scope *break_scope, AstNode *node) { |
| 8365 | assert(node->type == NodeTypeBreak); | 9396 | assert(node->type == NodeTypeBreak); |
| 8366 | | 9397 | |
| 8367 | // Search up the scope. We'll find one of these things first: | 9398 | // Search up the scope. We'll find one of these things first: |
| ... | @@ -8376,14 +9407,14 @@ static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *break_scope, AstNode * | ... | @@ -8376,14 +9407,14 @@ static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *break_scope, AstNode * |
| 8376 | if (search_scope == nullptr || search_scope->id == ScopeIdFnDef) { | 9407 | if (search_scope == nullptr || search_scope->id == ScopeIdFnDef) { |
| 8377 | if (node->data.break_expr.name != nullptr) { | 9408 | if (node->data.break_expr.name != nullptr) { |
| 8378 | add_node_error(irb->codegen, node, buf_sprintf("label not found: '%s'", buf_ptr(node->data.break_expr.name))); | 9409 | add_node_error(irb->codegen, node, buf_sprintf("label not found: '%s'", buf_ptr(node->data.break_expr.name))); |
| 8379 | return irb->codegen->invalid_instruction; | 9410 | return irb->codegen->invalid_inst_src; |
| 8380 | } else { | 9411 | } else { |
| 8381 | add_node_error(irb->codegen, node, buf_sprintf("break expression outside loop")); | 9412 | add_node_error(irb->codegen, node, buf_sprintf("break expression outside loop")); |
| 8382 | return irb->codegen->invalid_instruction; | 9413 | return irb->codegen->invalid_inst_src; |
| 8383 | } | 9414 | } |
| 8384 | } else if (search_scope->id == ScopeIdDeferExpr) { | 9415 | } else if (search_scope->id == ScopeIdDeferExpr) { |
| 8385 | add_node_error(irb->codegen, node, buf_sprintf("cannot break out of defer expression")); | 9416 | add_node_error(irb->codegen, node, buf_sprintf("cannot break out of defer expression")); |
| 8386 | return irb->codegen->invalid_instruction; | 9417 | return irb->codegen->invalid_inst_src; |
| 8387 | } else if (search_scope->id == ScopeIdLoop) { | 9418 | } else if (search_scope->id == ScopeIdLoop) { |
| 8388 | ScopeLoop *this_loop_scope = (ScopeLoop *)search_scope; | 9419 | ScopeLoop *this_loop_scope = (ScopeLoop *)search_scope; |
| 8389 | if (node->data.break_expr.name == nullptr || | 9420 | if (node->data.break_expr.name == nullptr || |
| ... | @@ -8402,32 +9433,32 @@ static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *break_scope, AstNode * | ... | @@ -8402,32 +9433,32 @@ static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *break_scope, AstNode * |
| 8402 | } | 9433 | } |
| 8403 | } else if (search_scope->id == ScopeIdSuspend) { | 9434 | } else if (search_scope->id == ScopeIdSuspend) { |
| 8404 | add_node_error(irb->codegen, node, buf_sprintf("cannot break out of suspend block")); | 9435 | add_node_error(irb->codegen, node, buf_sprintf("cannot break out of suspend block")); |
| 8405 | return irb->codegen->invalid_instruction; | 9436 | return irb->codegen->invalid_inst_src; |
| 8406 | } | 9437 | } |
| 8407 | search_scope = search_scope->parent; | 9438 | search_scope = search_scope->parent; |
| 8408 | } | 9439 | } |
| 8409 | | 9440 | |
| 8410 | IrInstruction *is_comptime; | 9441 | IrInstSrc *is_comptime; |
| 8411 | if (ir_should_inline(irb->exec, break_scope)) { | 9442 | if (ir_should_inline(irb->exec, break_scope)) { |
| 8412 | is_comptime = ir_build_const_bool(irb, break_scope, node, true); | 9443 | is_comptime = ir_build_const_bool(irb, break_scope, node, true); |
| 8413 | } else { | 9444 | } else { |
| 8414 | is_comptime = loop_scope->is_comptime; | 9445 | is_comptime = loop_scope->is_comptime; |
| 8415 | } | 9446 | } |
| 8416 | | 9447 | |
| 8417 | IrInstruction *result_value; | 9448 | IrInstSrc *result_value; |
| 8418 | if (node->data.break_expr.expr) { | 9449 | if (node->data.break_expr.expr) { |
| 8419 | ResultLocPeer *peer_result = create_peer_result(loop_scope->peer_parent); | 9450 | ResultLocPeer *peer_result = create_peer_result(loop_scope->peer_parent); |
| 8420 | loop_scope->peer_parent->peers.append(peer_result); | 9451 | loop_scope->peer_parent->peers.append(peer_result); |
| 8421 | | 9452 | |
| 8422 | result_value = ir_gen_node_extra(irb, node->data.break_expr.expr, break_scope, | 9453 | result_value = ir_gen_node_extra(irb, node->data.break_expr.expr, break_scope, |
| 8423 | loop_scope->lval, &peer_result->base); | 9454 | loop_scope->lval, &peer_result->base); |
| 8424 | if (result_value == irb->codegen->invalid_instruction) | 9455 | if (result_value == irb->codegen->invalid_inst_src) |
| 8425 | return irb->codegen->invalid_instruction; | 9456 | return irb->codegen->invalid_inst_src; |
| 8426 | } else { | 9457 | } else { |
| 8427 | result_value = ir_build_const_void(irb, break_scope, node); | 9458 | result_value = ir_build_const_void(irb, break_scope, node); |
| 8428 | } | 9459 | } |
| 8429 | | 9460 | |
| 8430 | IrBasicBlock *dest_block = loop_scope->break_block; | 9461 | IrBasicBlockSrc *dest_block = loop_scope->break_block; |
| 8431 | ir_gen_defers_for_block(irb, break_scope, dest_block->scope, false); | 9462 | ir_gen_defers_for_block(irb, break_scope, dest_block->scope, false); |
| 8432 | | 9463 | |
| 8433 | loop_scope->incoming_blocks->append(irb->current_basic_block); | 9464 | loop_scope->incoming_blocks->append(irb->current_basic_block); |
| ... | @@ -8435,7 +9466,7 @@ static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *break_scope, AstNode * | ... | @@ -8435,7 +9466,7 @@ static IrInstruction *ir_gen_break(IrBuilder *irb, Scope *break_scope, AstNode * |
| 8435 | return ir_build_br(irb, break_scope, node, dest_block, is_comptime); | 9466 | return ir_build_br(irb, break_scope, node, dest_block, is_comptime); |
| 8436 | } | 9467 | } |
| 8437 | | 9468 | |
| 8438 | static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *continue_scope, AstNode *node) { | 9469 | static IrInstSrc *ir_gen_continue(IrBuilderSrc *irb, Scope *continue_scope, AstNode *node) { |
| 8439 | assert(node->type == NodeTypeContinue); | 9470 | assert(node->type == NodeTypeContinue); |
| 8440 | | 9471 | |
| 8441 | // Search up the scope. We'll find one of these things first: | 9472 | // Search up the scope. We'll find one of these things first: |
| ... | @@ -8451,14 +9482,14 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *continue_scope, Ast | ... | @@ -8451,14 +9482,14 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *continue_scope, Ast |
| 8451 | if (search_scope == nullptr || search_scope->id == ScopeIdFnDef) { | 9482 | if (search_scope == nullptr || search_scope->id == ScopeIdFnDef) { |
| 8452 | if (node->data.continue_expr.name != nullptr) { | 9483 | if (node->data.continue_expr.name != nullptr) { |
| 8453 | add_node_error(irb->codegen, node, buf_sprintf("labeled loop not found: '%s'", buf_ptr(node->data.continue_expr.name))); | 9484 | add_node_error(irb->codegen, node, buf_sprintf("labeled loop not found: '%s'", buf_ptr(node->data.continue_expr.name))); |
| 8454 | return irb->codegen->invalid_instruction; | 9485 | return irb->codegen->invalid_inst_src; |
| 8455 | } else { | 9486 | } else { |
| 8456 | add_node_error(irb->codegen, node, buf_sprintf("continue expression outside loop")); | 9487 | add_node_error(irb->codegen, node, buf_sprintf("continue expression outside loop")); |
| 8457 | return irb->codegen->invalid_instruction; | 9488 | return irb->codegen->invalid_inst_src; |
| 8458 | } | 9489 | } |
| 8459 | } else if (search_scope->id == ScopeIdDeferExpr) { | 9490 | } else if (search_scope->id == ScopeIdDeferExpr) { |
| 8460 | add_node_error(irb->codegen, node, buf_sprintf("cannot continue out of defer expression")); | 9491 | add_node_error(irb->codegen, node, buf_sprintf("cannot continue out of defer expression")); |
| 8461 | return irb->codegen->invalid_instruction; | 9492 | return irb->codegen->invalid_inst_src; |
| 8462 | } else if (search_scope->id == ScopeIdLoop) { | 9493 | } else if (search_scope->id == ScopeIdLoop) { |
| 8463 | ScopeLoop *this_loop_scope = (ScopeLoop *)search_scope; | 9494 | ScopeLoop *this_loop_scope = (ScopeLoop *)search_scope; |
| 8464 | if (node->data.continue_expr.name == nullptr || | 9495 | if (node->data.continue_expr.name == nullptr || |
| ... | @@ -8474,7 +9505,7 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *continue_scope, Ast | ... | @@ -8474,7 +9505,7 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *continue_scope, Ast |
| 8474 | search_scope = search_scope->parent; | 9505 | search_scope = search_scope->parent; |
| 8475 | } | 9506 | } |
| 8476 | | 9507 | |
| 8477 | IrInstruction *is_comptime; | 9508 | IrInstSrc *is_comptime; |
| 8478 | if (ir_should_inline(irb->exec, continue_scope)) { | 9509 | if (ir_should_inline(irb->exec, continue_scope)) { |
| 8479 | is_comptime = ir_build_const_bool(irb, continue_scope, node, true); | 9510 | is_comptime = ir_build_const_bool(irb, continue_scope, node, true); |
| 8480 | } else { | 9511 | } else { |
| ... | @@ -8486,17 +9517,17 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *continue_scope, Ast | ... | @@ -8486,17 +9517,17 @@ static IrInstruction *ir_gen_continue(IrBuilder *irb, Scope *continue_scope, Ast |
| 8486 | ir_mark_gen(ir_build_check_runtime_scope(irb, continue_scope, node, scope_runtime->is_comptime, is_comptime)); | 9517 | ir_mark_gen(ir_build_check_runtime_scope(irb, continue_scope, node, scope_runtime->is_comptime, is_comptime)); |
| 8487 | } | 9518 | } |
| 8488 | | 9519 | |
| 8489 | IrBasicBlock *dest_block = loop_scope->continue_block; | 9520 | IrBasicBlockSrc *dest_block = loop_scope->continue_block; |
| 8490 | ir_gen_defers_for_block(irb, continue_scope, dest_block->scope, false); | 9521 | ir_gen_defers_for_block(irb, continue_scope, dest_block->scope, false); |
| 8491 | return ir_mark_gen(ir_build_br(irb, continue_scope, node, dest_block, is_comptime)); | 9522 | return ir_mark_gen(ir_build_br(irb, continue_scope, node, dest_block, is_comptime)); |
| 8492 | } | 9523 | } |
| 8493 | | 9524 | |
| 8494 | static IrInstruction *ir_gen_error_type(IrBuilder *irb, Scope *scope, AstNode *node) { | 9525 | static IrInstSrc *ir_gen_error_type(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 8495 | assert(node->type == NodeTypeErrorType); | 9526 | assert(node->type == NodeTypeErrorType); |
| 8496 | return ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_global_error_set); | 9527 | return ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_global_error_set); |
| 8497 | } | 9528 | } |
| 8498 | | 9529 | |
| 8499 | static IrInstruction *ir_gen_defer(IrBuilder *irb, Scope *parent_scope, AstNode *node) { | 9530 | static IrInstSrc *ir_gen_defer(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node) { |
| 8500 | assert(node->type == NodeTypeDefer); | 9531 | assert(node->type == NodeTypeDefer); |
| 8501 | | 9532 | |
| 8502 | ScopeDefer *defer_child_scope = create_defer_scope(irb->codegen, node, parent_scope); | 9533 | ScopeDefer *defer_child_scope = create_defer_scope(irb->codegen, node, parent_scope); |
| ... | @@ -8508,7 +9539,7 @@ static IrInstruction *ir_gen_defer(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -8508,7 +9539,7 @@ static IrInstruction *ir_gen_defer(IrBuilder *irb, Scope *parent_scope, AstNode |
| 8508 | return ir_build_const_void(irb, parent_scope, node); | 9539 | return ir_build_const_void(irb, parent_scope, node); |
| 8509 | } | 9540 | } |
| 8510 | | 9541 | |
| 8511 | static IrInstruction *ir_gen_slice(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { | 9542 | static IrInstSrc *ir_gen_slice(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, ResultLoc *result_loc) { |
| 8512 | assert(node->type == NodeTypeSliceExpr); | 9543 | assert(node->type == NodeTypeSliceExpr); |
| 8513 | | 9544 | |
| 8514 | AstNodeSliceExpr *slice_expr = &node->data.slice_expr; | 9545 | AstNodeSliceExpr *slice_expr = &node->data.slice_expr; |
| ... | @@ -8517,38 +9548,38 @@ static IrInstruction *ir_gen_slice(IrBuilder *irb, Scope *scope, AstNode *node, | ... | @@ -8517,38 +9548,38 @@ static IrInstruction *ir_gen_slice(IrBuilder *irb, Scope *scope, AstNode *node, |
| 8517 | AstNode *end_node = slice_expr->end; | 9548 | AstNode *end_node = slice_expr->end; |
| 8518 | AstNode *sentinel_node = slice_expr->sentinel; | 9549 | AstNode *sentinel_node = slice_expr->sentinel; |
| 8519 | | 9550 | |
| 8520 | IrInstruction *ptr_value = ir_gen_node_extra(irb, array_node, scope, LValPtr, nullptr); | 9551 | IrInstSrc *ptr_value = ir_gen_node_extra(irb, array_node, scope, LValPtr, nullptr); |
| 8521 | if (ptr_value == irb->codegen->invalid_instruction) | 9552 | if (ptr_value == irb->codegen->invalid_inst_src) |
| 8522 | return irb->codegen->invalid_instruction; | 9553 | return irb->codegen->invalid_inst_src; |
| 8523 | | 9554 | |
| 8524 | IrInstruction *start_value = ir_gen_node(irb, start_node, scope); | 9555 | IrInstSrc *start_value = ir_gen_node(irb, start_node, scope); |
| 8525 | if (start_value == irb->codegen->invalid_instruction) | 9556 | if (start_value == irb->codegen->invalid_inst_src) |
| 8526 | return irb->codegen->invalid_instruction; | 9557 | return irb->codegen->invalid_inst_src; |
| 8527 | | 9558 | |
| 8528 | IrInstruction *end_value; | 9559 | IrInstSrc *end_value; |
| 8529 | if (end_node) { | 9560 | if (end_node) { |
| 8530 | end_value = ir_gen_node(irb, end_node, scope); | 9561 | end_value = ir_gen_node(irb, end_node, scope); |
| 8531 | if (end_value == irb->codegen->invalid_instruction) | 9562 | if (end_value == irb->codegen->invalid_inst_src) |
| 8532 | return irb->codegen->invalid_instruction; | 9563 | return irb->codegen->invalid_inst_src; |
| 8533 | } else { | 9564 | } else { |
| 8534 | end_value = nullptr; | 9565 | end_value = nullptr; |
| 8535 | } | 9566 | } |
| 8536 | | 9567 | |
| 8537 | IrInstruction *sentinel_value; | 9568 | IrInstSrc *sentinel_value; |
| 8538 | if (sentinel_node) { | 9569 | if (sentinel_node) { |
| 8539 | sentinel_value = ir_gen_node(irb, sentinel_node, scope); | 9570 | sentinel_value = ir_gen_node(irb, sentinel_node, scope); |
| 8540 | if (sentinel_value == irb->codegen->invalid_instruction) | 9571 | if (sentinel_value == irb->codegen->invalid_inst_src) |
| 8541 | return irb->codegen->invalid_instruction; | 9572 | return irb->codegen->invalid_inst_src; |
| 8542 | } else { | 9573 | } else { |
| 8543 | sentinel_value = nullptr; | 9574 | sentinel_value = nullptr; |
| 8544 | } | 9575 | } |
| 8545 | | 9576 | |
| 8546 | IrInstruction *slice = ir_build_slice_src(irb, scope, node, ptr_value, start_value, end_value, | 9577 | IrInstSrc *slice = ir_build_slice_src(irb, scope, node, ptr_value, start_value, end_value, |
| 8547 | sentinel_value, true, result_loc); | 9578 | sentinel_value, true, result_loc); |
| 8548 | return ir_lval_wrap(irb, scope, slice, lval, result_loc); | 9579 | return ir_lval_wrap(irb, scope, slice, lval, result_loc); |
| 8549 | } | 9580 | } |
| 8550 | | 9581 | |
| 8551 | static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode *node, LVal lval, | 9582 | static IrInstSrc *ir_gen_catch(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node, LVal lval, |
| 8552 | ResultLoc *result_loc) | 9583 | ResultLoc *result_loc) |
| 8553 | { | 9584 | { |
| 8554 | assert(node->type == NodeTypeCatchExpr); | 9585 | assert(node->type == NodeTypeCatchExpr); |
| ... | @@ -8562,29 +9593,29 @@ static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -8562,29 +9593,29 @@ static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode |
| 8562 | assert(var_node->type == NodeTypeSymbol); | 9593 | assert(var_node->type == NodeTypeSymbol); |
| 8563 | Buf *var_name = var_node->data.symbol_expr.symbol; | 9594 | Buf *var_name = var_node->data.symbol_expr.symbol; |
| 8564 | add_node_error(irb->codegen, var_node, buf_sprintf("unused variable: '%s'", buf_ptr(var_name))); | 9595 | add_node_error(irb->codegen, var_node, buf_sprintf("unused variable: '%s'", buf_ptr(var_name))); |
| 8565 | return irb->codegen->invalid_instruction; | 9596 | return irb->codegen->invalid_inst_src; |
| 8566 | } | 9597 | } |
| 8567 | return ir_gen_catch_unreachable(irb, parent_scope, node, op1_node, lval, result_loc); | 9598 | return ir_gen_catch_unreachable(irb, parent_scope, node, op1_node, lval, result_loc); |
| 8568 | } | 9599 | } |
| 8569 | | 9600 | |
| 8570 | | 9601 | |
| 8571 | IrInstruction *err_union_ptr = ir_gen_node_extra(irb, op1_node, parent_scope, LValPtr, nullptr); | 9602 | IrInstSrc *err_union_ptr = ir_gen_node_extra(irb, op1_node, parent_scope, LValPtr, nullptr); |
| 8572 | if (err_union_ptr == irb->codegen->invalid_instruction) | 9603 | if (err_union_ptr == irb->codegen->invalid_inst_src) |
| 8573 | return irb->codegen->invalid_instruction; | 9604 | return irb->codegen->invalid_inst_src; |
| 8574 | | 9605 | |
| 8575 | IrInstruction *is_err = ir_build_test_err_src(irb, parent_scope, node, err_union_ptr, true, false); | 9606 | IrInstSrc *is_err = ir_build_test_err_src(irb, parent_scope, node, err_union_ptr, true, false); |
| 8576 | | 9607 | |
| 8577 | IrInstruction *is_comptime; | 9608 | IrInstSrc *is_comptime; |
| 8578 | if (ir_should_inline(irb->exec, parent_scope)) { | 9609 | if (ir_should_inline(irb->exec, parent_scope)) { |
| 8579 | is_comptime = ir_build_const_bool(irb, parent_scope, node, true); | 9610 | is_comptime = ir_build_const_bool(irb, parent_scope, node, true); |
| 8580 | } else { | 9611 | } else { |
| 8581 | is_comptime = ir_build_test_comptime(irb, parent_scope, node, is_err); | 9612 | is_comptime = ir_build_test_comptime(irb, parent_scope, node, is_err); |
| 8582 | } | 9613 | } |
| 8583 | | 9614 | |
| 8584 | IrBasicBlock *ok_block = ir_create_basic_block(irb, parent_scope, "UnwrapErrOk"); | 9615 | IrBasicBlockSrc *ok_block = ir_create_basic_block(irb, parent_scope, "UnwrapErrOk"); |
| 8585 | IrBasicBlock *err_block = ir_create_basic_block(irb, parent_scope, "UnwrapErrError"); | 9616 | IrBasicBlockSrc *err_block = ir_create_basic_block(irb, parent_scope, "UnwrapErrError"); |
| 8586 | IrBasicBlock *end_block = ir_create_basic_block(irb, parent_scope, "UnwrapErrEnd"); | 9617 | IrBasicBlockSrc *end_block = ir_create_basic_block(irb, parent_scope, "UnwrapErrEnd"); |
| 8587 | IrInstruction *cond_br_inst = ir_build_cond_br(irb, parent_scope, node, is_err, err_block, ok_block, is_comptime); | 9618 | IrInstSrc *cond_br_inst = ir_build_cond_br(irb, parent_scope, node, is_err, err_block, ok_block, is_comptime); |
| 8588 | | 9619 | |
| 8589 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, ok_block, end_block, result_loc, | 9620 | ResultLocPeerParent *peer_parent = ir_build_binary_result_peers(irb, cond_br_inst, ok_block, end_block, result_loc, |
| 8590 | is_comptime); | 9621 | is_comptime); |
| ... | @@ -8600,33 +9631,33 @@ static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode | ... | @@ -8600,33 +9631,33 @@ static IrInstruction *ir_gen_catch(IrBuilder *irb, Scope *parent_scope, AstNode |
| 8600 | ZigVar *var = ir_create_var(irb, node, subexpr_scope, var_name, | 9631 | ZigVar *var = ir_create_var(irb, node, subexpr_scope, var_name, |
| 8601 | is_const, is_const, is_shadowable, is_comptime); | 9632 | is_const, is_const, is_shadowable, is_comptime); |
| 8602 | err_scope = var->child_scope; | 9633 | err_scope = var->child_scope; |
| 8603 | IrInstruction *err_ptr = ir_build_unwrap_err_code(irb, err_scope, node, err_union_ptr); | 9634 | IrInstSrc *err_ptr = ir_build_unwrap_err_code_src(irb, err_scope, node, err_union_ptr); |
| 8604 | ir_build_var_decl_src(irb, err_scope, var_node, var, nullptr, err_ptr); | 9635 | ir_build_var_decl_src(irb, err_scope, var_node, var, nullptr, err_ptr); |
| 8605 | } else { | 9636 | } else { |
| 8606 | err_scope = subexpr_scope; | 9637 | err_scope = subexpr_scope; |
| 8607 | } | 9638 | } |
| 8608 | IrInstruction *err_result = ir_gen_node_extra(irb, op2_node, err_scope, LValNone, &peer_parent->peers.at(0)->base); | 9639 | IrInstSrc *err_result = ir_gen_node_extra(irb, op2_node, err_scope, LValNone, &peer_parent->peers.at(0)->base); |
| 8609 | if (err_result == irb->codegen->invalid_instruction) | 9640 | if (err_result == irb->codegen->invalid_inst_src) |
| 8610 | return irb->codegen->invalid_instruction; | 9641 | return irb->codegen->invalid_inst_src; |
| 8611 | IrBasicBlock *after_err_block = irb->current_basic_block; | 9642 | IrBasicBlockSrc *after_err_block = irb->current_basic_block; |
| 8612 | if (!instr_is_unreachable(err_result)) | 9643 | if (!instr_is_unreachable(err_result)) |
| 8613 | ir_mark_gen(ir_build_br(irb, parent_scope, node, end_block, is_comptime)); | 9644 | ir_mark_gen(ir_build_br(irb, parent_scope, node, end_block, is_comptime)); |
| 8614 | | 9645 | |
| 8615 | ir_set_cursor_at_end_and_append_block(irb, ok_block); | 9646 | ir_set_cursor_at_end_and_append_block(irb, ok_block); |
| 8616 | IrInstruction *unwrapped_ptr = ir_build_unwrap_err_payload(irb, parent_scope, node, err_union_ptr, false, false); | 9647 | IrInstSrc *unwrapped_ptr = ir_build_unwrap_err_payload_src(irb, parent_scope, node, err_union_ptr, false, false); |
| 8617 | IrInstruction *unwrapped_payload = ir_build_load_ptr(irb, parent_scope, node, unwrapped_ptr); | 9648 | IrInstSrc *unwrapped_payload = ir_build_load_ptr(irb, parent_scope, node, unwrapped_ptr); |
| 8618 | ir_build_end_expr(irb, parent_scope, node, unwrapped_payload, &peer_parent->peers.at(1)->base); | 9649 | ir_build_end_expr(irb, parent_scope, node, unwrapped_payload, &peer_parent->peers.at(1)->base); |
| 8619 | IrBasicBlock *after_ok_block = irb->current_basic_block; | 9650 | IrBasicBlockSrc *after_ok_block = irb->current_basic_block; |
| 8620 | ir_build_br(irb, parent_scope, node, end_block, is_comptime); | 9651 | ir_build_br(irb, parent_scope, node, end_block, is_comptime); |
| 8621 | | 9652 | |
| 8622 | ir_set_cursor_at_end_and_append_block(irb, end_block); | 9653 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 8623 | IrInstruction **incoming_values = allocate<IrInstruction *>(2); | 9654 | IrInstSrc **incoming_values = allocate<IrInstSrc *>(2); |
| 8624 | incoming_values[0] = err_result; | 9655 | incoming_values[0] = err_result; |
| 8625 | incoming_values[1] = unwrapped_payload; | 9656 | incoming_values[1] = unwrapped_payload; |
| 8626 | IrBasicBlock **incoming_blocks = allocate<IrBasicBlock *>(2, "IrBasicBlock *"); | 9657 | IrBasicBlockSrc **incoming_blocks = allocate<IrBasicBlockSrc *>(2, "IrBasicBlockSrc *"); |
| 8627 | incoming_blocks[0] = after_err_block; | 9658 | incoming_blocks[0] = after_err_block; |
| 8628 | incoming_blocks[1] = after_ok_block; | 9659 | incoming_blocks[1] = after_ok_block; |
| 8629 | IrInstruction *phi = ir_build_phi(irb, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); | 9660 | IrInstSrc *phi = ir_build_phi(irb, parent_scope, node, 2, incoming_blocks, incoming_values, peer_parent); |
| 8630 | return ir_lval_wrap(irb, parent_scope, phi, lval, result_loc); | 9661 | return ir_lval_wrap(irb, parent_scope, phi, lval, result_loc); |
| 8631 | } | 9662 | } |
| 8632 | | 9663 | |
| ... | @@ -8644,7 +9675,7 @@ static bool render_instance_name_recursive(CodeGen *codegen, Buf *name, Scope *o | ... | @@ -8644,7 +9675,7 @@ static bool render_instance_name_recursive(CodeGen *codegen, Buf *name, Scope *o |
| 8644 | return true; | 9675 | return true; |
| 8645 | } | 9676 | } |
| 8646 | | 9677 | |
| 8647 | static Buf *get_anon_type_name(CodeGen *codegen, IrExecutable *exec, const char *kind_name, | 9678 | static Buf *get_anon_type_name(CodeGen *codegen, IrExecutableSrc *exec, const char *kind_name, |
| 8648 | Scope *scope, AstNode *source_node, Buf *out_bare_name) | 9679 | Scope *scope, AstNode *source_node, Buf *out_bare_name) |
| 8649 | { | 9680 | { |
| 8650 | if (exec != nullptr && exec->name) { | 9681 | if (exec != nullptr && exec->name) { |
| ... | @@ -8673,7 +9704,7 @@ static Buf *get_anon_type_name(CodeGen *codegen, IrExecutable *exec, const char | ... | @@ -8673,7 +9704,7 @@ static Buf *get_anon_type_name(CodeGen *codegen, IrExecutable *exec, const char |
| 8673 | } | 9704 | } |
| 8674 | } | 9705 | } |
| 8675 | | 9706 | |
| 8676 | static IrInstruction *ir_gen_container_decl(IrBuilder *irb, Scope *parent_scope, AstNode *node) { | 9707 | static IrInstSrc *ir_gen_container_decl(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node) { |
| 8677 | assert(node->type == NodeTypeContainerDecl); | 9708 | assert(node->type == NodeTypeContainerDecl); |
| 8678 | | 9709 | |
| 8679 | ContainerKind kind = node->data.container_decl.kind; | 9710 | ContainerKind kind = node->data.container_decl.kind; |
| ... | @@ -8798,7 +9829,7 @@ static AstNode *ast_field_to_symbol_node(AstNode *err_set_field_node) { | ... | @@ -8798,7 +9829,7 @@ static AstNode *ast_field_to_symbol_node(AstNode *err_set_field_node) { |
| 8798 | } | 9829 | } |
| 8799 | } | 9830 | } |
| 8800 | | 9831 | |
| 8801 | static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, AstNode *node) { | 9832 | static IrInstSrc *ir_gen_err_set_decl(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node) { |
| 8802 | assert(node->type == NodeTypeErrorSetDecl); | 9833 | assert(node->type == NodeTypeErrorSetDecl); |
| 8803 | | 9834 | |
| 8804 | uint32_t err_count = node->data.err_set_decl.decls.length; | 9835 | uint32_t err_count = node->data.err_set_decl.decls.length; |
| ... | @@ -8841,7 +9872,7 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A | ... | @@ -8841,7 +9872,7 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A |
| 8841 | buf_sprintf("duplicate error: '%s'", buf_ptr(&err->name))); | 9872 | buf_sprintf("duplicate error: '%s'", buf_ptr(&err->name))); |
| 8842 | add_error_note(irb->codegen, msg, ast_field_to_symbol_node(prev_err->decl_node), | 9873 | add_error_note(irb->codegen, msg, ast_field_to_symbol_node(prev_err->decl_node), |
| 8843 | buf_sprintf("other error here")); | 9874 | buf_sprintf("other error here")); |
| 8844 | return irb->codegen->invalid_instruction; | 9875 | return irb->codegen->invalid_inst_src; |
| 8845 | } | 9876 | } |
| 8846 | errors[err->value] = err; | 9877 | errors[err->value] = err; |
| 8847 | } | 9878 | } |
| ... | @@ -8849,11 +9880,11 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A | ... | @@ -8849,11 +9880,11 @@ static IrInstruction *ir_gen_err_set_decl(IrBuilder *irb, Scope *parent_scope, A |
| 8849 | return ir_build_const_type(irb, parent_scope, node, err_set_type); | 9880 | return ir_build_const_type(irb, parent_scope, node, err_set_type); |
| 8850 | } | 9881 | } |
| 8851 | | 9882 | |
| 8852 | static IrInstruction *ir_gen_fn_proto(IrBuilder *irb, Scope *parent_scope, AstNode *node) { | 9883 | static IrInstSrc *ir_gen_fn_proto(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node) { |
| 8853 | assert(node->type == NodeTypeFnProto); | 9884 | assert(node->type == NodeTypeFnProto); |
| 8854 | | 9885 | |
| 8855 | size_t param_count = node->data.fn_proto.params.length; | 9886 | size_t param_count = node->data.fn_proto.params.length; |
| 8856 | IrInstruction **param_types = allocate<IrInstruction*>(param_count); | 9887 | IrInstSrc **param_types = allocate<IrInstSrc*>(param_count); |
| 8857 | | 9888 | |
| 8858 | bool is_var_args = false; | 9889 | bool is_var_args = false; |
| 8859 | for (size_t i = 0; i < param_count; i += 1) { | 9890 | for (size_t i = 0; i < param_count; i += 1) { |
| ... | @@ -8864,59 +9895,59 @@ static IrInstruction *ir_gen_fn_proto(IrBuilder *irb, Scope *parent_scope, AstNo | ... | @@ -8864,59 +9895,59 @@ static IrInstruction *ir_gen_fn_proto(IrBuilder *irb, Scope *parent_scope, AstNo |
| 8864 | } | 9895 | } |
| 8865 | if (param_node->data.param_decl.var_token == nullptr) { | 9896 | if (param_node->data.param_decl.var_token == nullptr) { |
| 8866 | AstNode *type_node = param_node->data.param_decl.type; | 9897 | AstNode *type_node = param_node->data.param_decl.type; |
| 8867 | IrInstruction *type_value = ir_gen_node(irb, type_node, parent_scope); | 9898 | IrInstSrc *type_value = ir_gen_node(irb, type_node, parent_scope); |
| 8868 | if (type_value == irb->codegen->invalid_instruction) | 9899 | if (type_value == irb->codegen->invalid_inst_src) |
| 8869 | return irb->codegen->invalid_instruction; | 9900 | return irb->codegen->invalid_inst_src; |
| 8870 | param_types[i] = type_value; | 9901 | param_types[i] = type_value; |
| 8871 | } else { | 9902 | } else { |
| 8872 | param_types[i] = nullptr; | 9903 | param_types[i] = nullptr; |
| 8873 | } | 9904 | } |
| 8874 | } | 9905 | } |
| 8875 | | 9906 | |
| 8876 | IrInstruction *align_value = nullptr; | 9907 | IrInstSrc *align_value = nullptr; |
| 8877 | if (node->data.fn_proto.align_expr != nullptr) { | 9908 | if (node->data.fn_proto.align_expr != nullptr) { |
| 8878 | align_value = ir_gen_node(irb, node->data.fn_proto.align_expr, parent_scope); | 9909 | align_value = ir_gen_node(irb, node->data.fn_proto.align_expr, parent_scope); |
| 8879 | if (align_value == irb->codegen->invalid_instruction) | 9910 | if (align_value == irb->codegen->invalid_inst_src) |
| 8880 | return irb->codegen->invalid_instruction; | 9911 | return irb->codegen->invalid_inst_src; |
| 8881 | } | 9912 | } |
| 8882 | | 9913 | |
| 8883 | IrInstruction *callconv_value = nullptr; | 9914 | IrInstSrc *callconv_value = nullptr; |
| 8884 | if (node->data.fn_proto.callconv_expr != nullptr) { | 9915 | if (node->data.fn_proto.callconv_expr != nullptr) { |
| 8885 | callconv_value = ir_gen_node(irb, node->data.fn_proto.callconv_expr, parent_scope); | 9916 | callconv_value = ir_gen_node(irb, node->data.fn_proto.callconv_expr, parent_scope); |
| 8886 | if (callconv_value == irb->codegen->invalid_instruction) | 9917 | if (callconv_value == irb->codegen->invalid_inst_src) |
| 8887 | return irb->codegen->invalid_instruction; | 9918 | return irb->codegen->invalid_inst_src; |
| 8888 | } | 9919 | } |
| 8889 | | 9920 | |
| 8890 | IrInstruction *return_type; | 9921 | IrInstSrc *return_type; |
| 8891 | if (node->data.fn_proto.return_var_token == nullptr) { | 9922 | if (node->data.fn_proto.return_var_token == nullptr) { |
| 8892 | if (node->data.fn_proto.return_type == nullptr) { | 9923 | if (node->data.fn_proto.return_type == nullptr) { |
| 8893 | return_type = ir_build_const_type(irb, parent_scope, node, irb->codegen->builtin_types.entry_void); | 9924 | return_type = ir_build_const_type(irb, parent_scope, node, irb->codegen->builtin_types.entry_void); |
| 8894 | } else { | 9925 | } else { |
| 8895 | return_type = ir_gen_node(irb, node->data.fn_proto.return_type, parent_scope); | 9926 | return_type = ir_gen_node(irb, node->data.fn_proto.return_type, parent_scope); |
| 8896 | if (return_type == irb->codegen->invalid_instruction) | 9927 | if (return_type == irb->codegen->invalid_inst_src) |
| 8897 | return irb->codegen->invalid_instruction; | 9928 | return irb->codegen->invalid_inst_src; |
| 8898 | } | 9929 | } |
| 8899 | } else { | 9930 | } else { |
| 8900 | add_node_error(irb->codegen, node, | 9931 | add_node_error(irb->codegen, node, |
| 8901 | buf_sprintf("TODO implement inferred return types https://github.com/ziglang/zig/issues/447")); | 9932 | buf_sprintf("TODO implement inferred return types https://github.com/ziglang/zig/issues/447")); |
| 8902 | return irb->codegen->invalid_instruction; | 9933 | return irb->codegen->invalid_inst_src; |
| 8903 | //return_type = nullptr; | 9934 | //return_type = nullptr; |
| 8904 | } | 9935 | } |
| 8905 | | 9936 | |
| 8906 | return ir_build_fn_proto(irb, parent_scope, node, param_types, align_value, callconv_value, return_type, is_var_args); | 9937 | return ir_build_fn_proto(irb, parent_scope, node, param_types, align_value, callconv_value, return_type, is_var_args); |
| 8907 | } | 9938 | } |
| 8908 | | 9939 | |
| 8909 | static IrInstruction *ir_gen_resume(IrBuilder *irb, Scope *scope, AstNode *node) { | 9940 | static IrInstSrc *ir_gen_resume(IrBuilderSrc *irb, Scope *scope, AstNode *node) { |
| 8910 | assert(node->type == NodeTypeResume); | 9941 | assert(node->type == NodeTypeResume); |
| 8911 | | 9942 | |
| 8912 | IrInstruction *target_inst = ir_gen_node_extra(irb, node->data.resume_expr.expr, scope, LValPtr, nullptr); | 9943 | IrInstSrc *target_inst = ir_gen_node_extra(irb, node->data.resume_expr.expr, scope, LValPtr, nullptr); |
| 8913 | if (target_inst == irb->codegen->invalid_instruction) | 9944 | if (target_inst == irb->codegen->invalid_inst_src) |
| 8914 | return irb->codegen->invalid_instruction; | 9945 | return irb->codegen->invalid_inst_src; |
| 8915 | | 9946 | |
| 8916 | return ir_build_resume(irb, scope, node, target_inst); | 9947 | return ir_build_resume_src(irb, scope, node, target_inst); |
| 8917 | } | 9948 | } |
| 8918 | | 9949 | |
| 8919 | static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval, | 9950 | static IrInstSrc *ir_gen_await_expr(IrBuilderSrc *irb, Scope *scope, AstNode *node, LVal lval, |
| 8920 | ResultLoc *result_loc) | 9951 | ResultLoc *result_loc) |
| 8921 | { | 9952 | { |
| 8922 | assert(node->type == NodeTypeAwaitExpr); | 9953 | assert(node->type == NodeTypeAwaitExpr); |
| ... | @@ -8937,7 +9968,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -8937,7 +9968,7 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 8937 | ZigFn *fn_entry = exec_fn_entry(irb->exec); | 9968 | ZigFn *fn_entry = exec_fn_entry(irb->exec); |
| 8938 | if (!fn_entry) { | 9969 | if (!fn_entry) { |
| 8939 | add_node_error(irb->codegen, node, buf_sprintf("await outside function definition")); | 9970 | add_node_error(irb->codegen, node, buf_sprintf("await outside function definition")); |
| 8940 | return irb->codegen->invalid_instruction; | 9971 | return irb->codegen->invalid_inst_src; |
| 8941 | } | 9972 | } |
| 8942 | ScopeSuspend *existing_suspend_scope = get_scope_suspend(scope); | 9973 | ScopeSuspend *existing_suspend_scope = get_scope_suspend(scope); |
| 8943 | if (existing_suspend_scope) { | 9974 | if (existing_suspend_scope) { |
| ... | @@ -8946,24 +9977,24 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n | ... | @@ -8946,24 +9977,24 @@ static IrInstruction *ir_gen_await_expr(IrBuilder *irb, Scope *scope, AstNode *n |
| 8946 | add_error_note(irb->codegen, msg, existing_suspend_scope->base.source_node, buf_sprintf("suspend block here")); | 9977 | add_error_note(irb->codegen, msg, existing_suspend_scope->base.source_node, buf_sprintf("suspend block here")); |
| 8947 | existing_suspend_scope->reported_err = true; | 9978 | existing_suspend_scope->reported_err = true; |
| 8948 | } | 9979 | } |
| 8949 | return irb->codegen->invalid_instruction; | 9980 | return irb->codegen->invalid_inst_src; |
| 8950 | } | 9981 | } |
| 8951 | | 9982 | |
| 8952 | IrInstruction *target_inst = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); | 9983 | IrInstSrc *target_inst = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); |
| 8953 | if (target_inst == irb->codegen->invalid_instruction) | 9984 | if (target_inst == irb->codegen->invalid_inst_src) |
| 8954 | return irb->codegen->invalid_instruction; | 9985 | return irb->codegen->invalid_inst_src; |
| 8955 | | 9986 | |
| 8956 | IrInstruction *await_inst = ir_build_await_src(irb, scope, node, target_inst, result_loc); | 9987 | IrInstSrc *await_inst = ir_build_await_src(irb, scope, node, target_inst, result_loc); |
| 8957 | return ir_lval_wrap(irb, scope, await_inst, lval, result_loc); | 9988 | return ir_lval_wrap(irb, scope, await_inst, lval, result_loc); |
| 8958 | } | 9989 | } |
| 8959 | | 9990 | |
| 8960 | static IrInstruction *ir_gen_suspend(IrBuilder *irb, Scope *parent_scope, AstNode *node) { | 9991 | static IrInstSrc *ir_gen_suspend(IrBuilderSrc *irb, Scope *parent_scope, AstNode *node) { |
| 8961 | assert(node->type == NodeTypeSuspend); | 9992 | assert(node->type == NodeTypeSuspend); |
| 8962 | | 9993 | |
| 8963 | ZigFn *fn_entry = exec_fn_entry(irb->exec); | 9994 | ZigFn *fn_entry = exec_fn_entry(irb->exec); |
| 8964 | if (!fn_entry) { | 9995 | if (!fn_entry) { |
| 8965 | add_node_error(irb->codegen, node, buf_sprintf("suspend outside function definition")); | 9996 | add_node_error(irb->codegen, node, buf_sprintf("suspend outside function definition")); |
| 8966 | return irb->codegen->invalid_instruction; | 9997 | return irb->codegen->invalid_inst_src; |
| 8967 | } | 9998 | } |
| 8968 | ScopeSuspend *existing_suspend_scope = get_scope_suspend(parent_scope); | 9999 | ScopeSuspend *existing_suspend_scope = get_scope_suspend(parent_scope); |
| 8969 | if (existing_suspend_scope) { | 10000 | if (existing_suspend_scope) { |
| ... | @@ -8972,21 +10003,21 @@ static IrInstruction *ir_gen_suspend(IrBuilder *irb, Scope *parent_scope, AstNod | ... | @@ -8972,21 +10003,21 @@ static IrInstruction *ir_gen_suspend(IrBuilder *irb, Scope *parent_scope, AstNod |
| 8972 | add_error_note(irb->codegen, msg, existing_suspend_scope->base.source_node, buf_sprintf("other suspend block here")); | 10003 | add_error_note(irb->codegen, msg, existing_suspend_scope->base.source_node, buf_sprintf("other suspend block here")); |
| 8973 | existing_suspend_scope->reported_err = true; | 10004 | existing_suspend_scope->reported_err = true; |
| 8974 | } | 10005 | } |
| 8975 | return irb->codegen->invalid_instruction; | 10006 | return irb->codegen->invalid_inst_src; |
| 8976 | } | 10007 | } |
| 8977 | | 10008 | |
| 8978 | IrInstructionSuspendBegin *begin = ir_build_suspend_begin(irb, parent_scope, node); | 10009 | IrInstSrcSuspendBegin *begin = ir_build_suspend_begin_src(irb, parent_scope, node); |
| 8979 | if (node->data.suspend.block != nullptr) { | 10010 | if (node->data.suspend.block != nullptr) { |
| 8980 | ScopeSuspend *suspend_scope = create_suspend_scope(irb->codegen, node, parent_scope); | 10011 | ScopeSuspend *suspend_scope = create_suspend_scope(irb->codegen, node, parent_scope); |
| 8981 | Scope *child_scope = &suspend_scope->base; | 10012 | Scope *child_scope = &suspend_scope->base; |
| 8982 | IrInstruction *susp_res = ir_gen_node(irb, node->data.suspend.block, child_scope); | 10013 | IrInstSrc *susp_res = ir_gen_node(irb, node->data.suspend.block, child_scope); |
| 8983 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, node->data.suspend.block, susp_res)); | 10014 | ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, node->data.suspend.block, susp_res)); |
| 8984 | } | 10015 | } |
| 8985 | | 10016 | |
| 8986 | return ir_mark_gen(ir_build_suspend_finish(irb, parent_scope, node, begin)); | 10017 | return ir_mark_gen(ir_build_suspend_finish_src(irb, parent_scope, node, begin)); |
| 8987 | } | 10018 | } |
| 8988 | | 10019 | |
| 8989 | static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scope, | 10020 | static IrInstSrc *ir_gen_node_raw(IrBuilderSrc *irb, AstNode *node, Scope *scope, |
| 8990 | LVal lval, ResultLoc *result_loc) | 10021 | LVal lval, ResultLoc *result_loc) |
| 8991 | { | 10022 | { |
| 8992 | assert(scope); | 10023 | assert(scope); |
| ... | @@ -9035,39 +10066,39 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop | ... | @@ -9035,39 +10066,39 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop |
| 9035 | return ir_gen_return(irb, scope, node, lval, result_loc); | 10066 | return ir_gen_return(irb, scope, node, lval, result_loc); |
| 9036 | case NodeTypeFieldAccessExpr: | 10067 | case NodeTypeFieldAccessExpr: |
| 9037 | { | 10068 | { |
| 9038 | IrInstruction *ptr_instruction = ir_gen_field_access(irb, scope, node); | 10069 | IrInstSrc *ptr_instruction = ir_gen_field_access(irb, scope, node); |
| 9039 | if (ptr_instruction == irb->codegen->invalid_instruction) | 10070 | if (ptr_instruction == irb->codegen->invalid_inst_src) |
| 9040 | return ptr_instruction; | 10071 | return ptr_instruction; |
| 9041 | if (lval == LValPtr) | 10072 | if (lval == LValPtr) |
| 9042 | return ptr_instruction; | 10073 | return ptr_instruction; |
| 9043 | | 10074 | |
| 9044 | IrInstruction *load_ptr = ir_build_load_ptr(irb, scope, node, ptr_instruction); | 10075 | IrInstSrc *load_ptr = ir_build_load_ptr(irb, scope, node, ptr_instruction); |
| 9045 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); | 10076 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); |
| 9046 | } | 10077 | } |
| 9047 | case NodeTypePtrDeref: { | 10078 | case NodeTypePtrDeref: { |
| 9048 | AstNode *expr_node = node->data.ptr_deref_expr.target; | 10079 | AstNode *expr_node = node->data.ptr_deref_expr.target; |
| 9049 | IrInstruction *value = ir_gen_node_extra(irb, expr_node, scope, lval, nullptr); | 10080 | IrInstSrc *value = ir_gen_node_extra(irb, expr_node, scope, lval, nullptr); |
| 9050 | if (value == irb->codegen->invalid_instruction) | 10081 | if (value == irb->codegen->invalid_inst_src) |
| 9051 | return value; | 10082 | return value; |
| 9052 | | 10083 | |
| 9053 | // We essentially just converted any lvalue from &(x.*) to (&x).*; | 10084 | // We essentially just converted any lvalue from &(x.*) to (&x).*; |
| 9054 | // this inhibits checking that x is a pointer later, so we directly | 10085 | // this inhibits checking that x is a pointer later, so we directly |
| 9055 | // record whether the pointer check is needed | 10086 | // record whether the pointer check is needed |
| 9056 | IrInstruction *un_op = ir_build_un_op_lval(irb, scope, node, IrUnOpDereference, value, lval, result_loc); | 10087 | IrInstSrc *un_op = ir_build_un_op_lval(irb, scope, node, IrUnOpDereference, value, lval, result_loc); |
| 9057 | return ir_expr_wrap(irb, scope, un_op, result_loc); | 10088 | return ir_expr_wrap(irb, scope, un_op, result_loc); |
| 9058 | } | 10089 | } |
| 9059 | case NodeTypeUnwrapOptional: { | 10090 | case NodeTypeUnwrapOptional: { |
| 9060 | AstNode *expr_node = node->data.unwrap_optional.expr; | 10091 | AstNode *expr_node = node->data.unwrap_optional.expr; |
| 9061 | | 10092 | |
| 9062 | IrInstruction *maybe_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); | 10093 | IrInstSrc *maybe_ptr = ir_gen_node_extra(irb, expr_node, scope, LValPtr, nullptr); |
| 9063 | if (maybe_ptr == irb->codegen->invalid_instruction) | 10094 | if (maybe_ptr == irb->codegen->invalid_inst_src) |
| 9064 | return irb->codegen->invalid_instruction; | 10095 | return irb->codegen->invalid_inst_src; |
| 9065 | | 10096 | |
| 9066 | IrInstruction *unwrapped_ptr = ir_build_optional_unwrap_ptr(irb, scope, node, maybe_ptr, true, false); | 10097 | IrInstSrc *unwrapped_ptr = ir_build_optional_unwrap_ptr(irb, scope, node, maybe_ptr, true, false); |
| 9067 | if (lval == LValPtr) | 10098 | if (lval == LValPtr) |
| 9068 | return unwrapped_ptr; | 10099 | return unwrapped_ptr; |
| 9069 | | 10100 | |
| 9070 | IrInstruction *load_ptr = ir_build_load_ptr(irb, scope, node, unwrapped_ptr); | 10101 | IrInstSrc *load_ptr = ir_build_load_ptr(irb, scope, node, unwrapped_ptr); |
| 9071 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); | 10102 | return ir_expr_wrap(irb, scope, load_ptr, result_loc); |
| 9072 | } | 10103 | } |
| 9073 | case NodeTypeBoolLiteral: | 10104 | case NodeTypeBoolLiteral: |
| ... | @@ -9125,7 +10156,7 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop | ... | @@ -9125,7 +10156,7 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop |
| 9125 | case NodeTypeInferredArrayType: | 10156 | case NodeTypeInferredArrayType: |
| 9126 | add_node_error(irb->codegen, node, | 10157 | add_node_error(irb->codegen, node, |
| 9127 | buf_sprintf("inferred array size invalid here")); | 10158 | buf_sprintf("inferred array size invalid here")); |
| 9128 | return irb->codegen->invalid_instruction; | 10159 | return irb->codegen->invalid_inst_src; |
| 9129 | case NodeTypeVarFieldType: | 10160 | case NodeTypeVarFieldType: |
| 9130 | return ir_lval_wrap(irb, scope, | 10161 | return ir_lval_wrap(irb, scope, |
| 9131 | ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_var), lval, result_loc); | 10162 | ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_var), lval, result_loc); |
| ... | @@ -9139,7 +10170,7 @@ static ResultLoc *no_result_loc(void) { | ... | @@ -9139,7 +10170,7 @@ static ResultLoc *no_result_loc(void) { |
| 9139 | return &result_loc_none->base; | 10170 | return &result_loc_none->base; |
| 9140 | } | 10171 | } |
| 9141 | | 10172 | |
| 9142 | static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *scope, LVal lval, | 10173 | static IrInstSrc *ir_gen_node_extra(IrBuilderSrc *irb, AstNode *node, Scope *scope, LVal lval, |
| 9143 | ResultLoc *result_loc) | 10174 | ResultLoc *result_loc) |
| 9144 | { | 10175 | { |
| 9145 | if (result_loc == nullptr) { | 10176 | if (result_loc == nullptr) { |
| ... | @@ -9156,8 +10187,8 @@ static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *sc | ... | @@ -9156,8 +10187,8 @@ static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *sc |
| 9156 | } else { | 10187 | } else { |
| 9157 | child_scope = &create_expr_scope(irb->codegen, node, scope)->base; | 10188 | child_scope = &create_expr_scope(irb->codegen, node, scope)->base; |
| 9158 | } | 10189 | } |
| 9159 | IrInstruction *result = ir_gen_node_raw(irb, node, child_scope, lval, result_loc); | 10190 | IrInstSrc *result = ir_gen_node_raw(irb, node, child_scope, lval, result_loc); |
| 9160 | if (result == irb->codegen->invalid_instruction) { | 10191 | if (result == irb->codegen->invalid_inst_src) { |
| 9161 | if (irb->exec->first_err_trace_msg == nullptr) { | 10192 | if (irb->exec->first_err_trace_msg == nullptr) { |
| 9162 | irb->exec->first_err_trace_msg = irb->codegen->trace_err; | 10193 | irb->exec->first_err_trace_msg = irb->codegen->trace_err; |
| 9163 | } | 10194 | } |
| ... | @@ -9165,11 +10196,22 @@ static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *sc | ... | @@ -9165,11 +10196,22 @@ static IrInstruction *ir_gen_node_extra(IrBuilder *irb, AstNode *node, Scope *sc |
| 9165 | return result; | 10196 | return result; |
| 9166 | } | 10197 | } |
| 9167 | | 10198 | |
| 9168 | static IrInstruction *ir_gen_node(IrBuilder *irb, AstNode *node, Scope *scope) { | 10199 | static IrInstSrc *ir_gen_node(IrBuilderSrc *irb, AstNode *node, Scope *scope) { |
| 9169 | return ir_gen_node_extra(irb, node, scope, LValNone, nullptr); | 10200 | return ir_gen_node_extra(irb, node, scope, LValNone, nullptr); |
| 9170 | } | 10201 | } |
| 9171 | | 10202 | |
| 9172 | static void invalidate_exec(IrExecutable *exec, ErrorMsg *msg) { | 10203 | static void invalidate_exec(IrExecutableSrc *exec, ErrorMsg *msg) { |
| | 10204 | if (exec->first_err_trace_msg != nullptr) |
| | 10205 | return; |
| | 10206 | |
| | 10207 | exec->first_err_trace_msg = msg; |
| | 10208 | |
| | 10209 | for (size_t i = 0; i < exec->tld_list.length; i += 1) { |
| | 10210 | exec->tld_list.items[i]->resolution = TldResolutionInvalid; |
| | 10211 | } |
| | 10212 | } |
| | 10213 | |
| | 10214 | static void invalidate_exec_gen(IrExecutableGen *exec, ErrorMsg *msg) { |
| 9173 | if (exec->first_err_trace_msg != nullptr) | 10215 | if (exec->first_err_trace_msg != nullptr) |
| 9174 | return; | 10216 | return; |
| 9175 | | 10217 | |
| ... | @@ -9183,24 +10225,25 @@ static void invalidate_exec(IrExecutable *exec, ErrorMsg *msg) { | ... | @@ -9183,24 +10225,25 @@ static void invalidate_exec(IrExecutable *exec, ErrorMsg *msg) { |
| 9183 | invalidate_exec(exec->source_exec, msg); | 10225 | invalidate_exec(exec->source_exec, msg); |
| 9184 | } | 10226 | } |
| 9185 | | 10227 | |
| 9186 | bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_executable) { | 10228 | |
| | 10229 | bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutableSrc *ir_executable) { |
| 9187 | assert(node->owner); | 10230 | assert(node->owner); |
| 9188 | | 10231 | |
| 9189 | IrBuilder ir_builder = {0}; | 10232 | IrBuilderSrc ir_builder = {0}; |
| 9190 | IrBuilder *irb = &ir_builder; | 10233 | IrBuilderSrc *irb = &ir_builder; |
| 9191 | | 10234 | |
| 9192 | irb->codegen = codegen; | 10235 | irb->codegen = codegen; |
| 9193 | irb->exec = ir_executable; | 10236 | irb->exec = ir_executable; |
| 9194 | irb->main_block_node = node; | 10237 | irb->main_block_node = node; |
| 9195 | | 10238 | |
| 9196 | IrBasicBlock *entry_block = ir_create_basic_block(irb, scope, "Entry"); | 10239 | IrBasicBlockSrc *entry_block = ir_create_basic_block(irb, scope, "Entry"); |
| 9197 | ir_set_cursor_at_end_and_append_block(irb, entry_block); | 10240 | ir_set_cursor_at_end_and_append_block(irb, entry_block); |
| 9198 | // Entry block gets a reference because we enter it to begin. | 10241 | // Entry block gets a reference because we enter it to begin. |
| 9199 | ir_ref_bb(irb->current_basic_block); | 10242 | ir_ref_bb(irb->current_basic_block); |
| 9200 | | 10243 | |
| 9201 | IrInstruction *result = ir_gen_node_extra(irb, node, scope, LValNone, nullptr); | 10244 | IrInstSrc *result = ir_gen_node_extra(irb, node, scope, LValNone, nullptr); |
| 9202 | | 10245 | |
| 9203 | if (result == irb->codegen->invalid_instruction) | 10246 | if (result == irb->codegen->invalid_inst_src) |
| 9204 | return false; | 10247 | return false; |
| 9205 | | 10248 | |
| 9206 | if (irb->exec->first_err_trace_msg != nullptr) { | 10249 | if (irb->exec->first_err_trace_msg != nullptr) { |
| ... | @@ -9209,9 +10252,9 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec | ... | @@ -9209,9 +10252,9 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec |
| 9209 | } | 10252 | } |
| 9210 | | 10253 | |
| 9211 | if (!instr_is_unreachable(result)) { | 10254 | if (!instr_is_unreachable(result)) { |
| 9212 | ir_mark_gen(ir_build_add_implicit_return_type(irb, scope, result->source_node, result, nullptr)); | 10255 | ir_mark_gen(ir_build_add_implicit_return_type(irb, scope, result->base.source_node, result, nullptr)); |
| 9213 | // no need for save_err_ret_addr because this cannot return error | 10256 | // no need for save_err_ret_addr because this cannot return error |
| 9214 | ir_mark_gen(ir_build_return(irb, scope, result->source_node, result)); | 10257 | ir_mark_gen(ir_build_return_src(irb, scope, result->base.source_node, result)); |
| 9215 | } | 10258 | } |
| 9216 | | 10259 | |
| 9217 | return true; | 10260 | return true; |
| ... | @@ -9220,7 +10263,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec | ... | @@ -9220,7 +10263,7 @@ bool ir_gen(CodeGen *codegen, AstNode *node, Scope *scope, IrExecutable *ir_exec |
| 9220 | bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) { | 10263 | bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) { |
| 9221 | assert(fn_entry); | 10264 | assert(fn_entry); |
| 9222 | | 10265 | |
| 9223 | IrExecutable *ir_executable = fn_entry->ir_executable; | 10266 | IrExecutableSrc *ir_executable = fn_entry->ir_executable; |
| 9224 | AstNode *body_node = fn_entry->body_node; | 10267 | AstNode *body_node = fn_entry->body_node; |
| 9225 | | 10268 | |
| 9226 | assert(fn_entry->child_scope); | 10269 | assert(fn_entry->child_scope); |
| ... | @@ -9228,14 +10271,21 @@ bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) { | ... | @@ -9228,14 +10271,21 @@ bool ir_gen_fn(CodeGen *codegen, ZigFn *fn_entry) { |
| 9228 | return ir_gen(codegen, body_node, fn_entry->child_scope, ir_executable); | 10271 | return ir_gen(codegen, body_node, fn_entry->child_scope, ir_executable); |
| 9229 | } | 10272 | } |
| 9230 | | 10273 | |
| 9231 | static void ir_add_call_stack_errors(CodeGen *codegen, IrExecutable *exec, ErrorMsg *err_msg, int limit) { | 10274 | static void ir_add_call_stack_errors_gen(CodeGen *codegen, IrExecutableGen *exec, ErrorMsg *err_msg, int limit) { |
| | 10275 | if (!exec || !exec->source_node || limit < 0) return; |
| | 10276 | add_error_note(codegen, err_msg, exec->source_node, buf_sprintf("called from here")); |
| | 10277 | |
| | 10278 | ir_add_call_stack_errors_gen(codegen, exec->parent_exec, err_msg, limit - 1); |
| | 10279 | } |
| | 10280 | |
| | 10281 | static void ir_add_call_stack_errors(CodeGen *codegen, IrExecutableSrc *exec, ErrorMsg *err_msg, int limit) { |
| 9232 | if (!exec || !exec->source_node || limit < 0) return; | 10282 | if (!exec || !exec->source_node || limit < 0) return; |
| 9233 | add_error_note(codegen, err_msg, exec->source_node, buf_sprintf("called from here")); | 10283 | add_error_note(codegen, err_msg, exec->source_node, buf_sprintf("called from here")); |
| 9234 | | 10284 | |
| 9235 | ir_add_call_stack_errors(codegen, exec->parent_exec, err_msg, limit - 1); | 10285 | ir_add_call_stack_errors_gen(codegen, exec->parent_exec, err_msg, limit - 1); |
| 9236 | } | 10286 | } |
| 9237 | | 10287 | |
| 9238 | static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, Buf *msg) { | 10288 | static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutableSrc *exec, AstNode *source_node, Buf *msg) { |
| 9239 | ErrorMsg *err_msg = add_node_error(codegen, source_node, msg); | 10289 | ErrorMsg *err_msg = add_node_error(codegen, source_node, msg); |
| 9240 | invalidate_exec(exec, err_msg); | 10290 | invalidate_exec(exec, err_msg); |
| 9241 | if (exec->parent_exec) { | 10291 | if (exec->parent_exec) { |
| ... | @@ -9244,26 +10294,40 @@ static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutable *exec, AstNo | ... | @@ -9244,26 +10294,40 @@ static ErrorMsg *exec_add_error_node(CodeGen *codegen, IrExecutable *exec, AstNo |
| 9244 | return err_msg; | 10294 | return err_msg; |
| 9245 | } | 10295 | } |
| 9246 | | 10296 | |
| | 10297 | static ErrorMsg *exec_add_error_node_gen(CodeGen *codegen, IrExecutableGen *exec, AstNode *source_node, Buf *msg) { |
| | 10298 | ErrorMsg *err_msg = add_node_error(codegen, source_node, msg); |
| | 10299 | invalidate_exec_gen(exec, err_msg); |
| | 10300 | if (exec->parent_exec) { |
| | 10301 | ir_add_call_stack_errors_gen(codegen, exec, err_msg, 10); |
| | 10302 | } |
| | 10303 | return err_msg; |
| | 10304 | } |
| | 10305 | |
| 9247 | static ErrorMsg *ir_add_error_node(IrAnalyze *ira, AstNode *source_node, Buf *msg) { | 10306 | static ErrorMsg *ir_add_error_node(IrAnalyze *ira, AstNode *source_node, Buf *msg) { |
| 9248 | return exec_add_error_node(ira->codegen, ira->new_irb.exec, source_node, msg); | 10307 | return exec_add_error_node_gen(ira->codegen, ira->new_irb.exec, source_node, msg); |
| 9249 | } | 10308 | } |
| 9250 | | 10309 | |
| 9251 | static ErrorMsg *opt_ir_add_error_node(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, Buf *msg) { | 10310 | static ErrorMsg *opt_ir_add_error_node(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, Buf *msg) { |
| 9252 | if (ira != nullptr) | 10311 | if (ira != nullptr) |
| 9253 | return exec_add_error_node(codegen, ira->new_irb.exec, source_node, msg); | 10312 | return exec_add_error_node_gen(codegen, ira->new_irb.exec, source_node, msg); |
| 9254 | else | 10313 | else |
| 9255 | return add_node_error(codegen, source_node, msg); | 10314 | return add_node_error(codegen, source_node, msg); |
| 9256 | } | 10315 | } |
| 9257 | | 10316 | |
| 9258 | static ErrorMsg *ir_add_error(IrAnalyze *ira, IrInstruction *source_instruction, Buf *msg) { | 10317 | static ErrorMsg *ir_add_error(IrAnalyze *ira, IrInst *source_instruction, Buf *msg) { |
| 9259 | return ir_add_error_node(ira, source_instruction->source_node, msg); | 10318 | return ir_add_error_node(ira, source_instruction->source_node, msg); |
| 9260 | } | 10319 | } |
| 9261 | | 10320 | |
| 9262 | static void ir_assert(bool ok, IrInstruction *source_instruction) { | 10321 | static void ir_assert(bool ok, IrInst *source_instruction) { |
| 9263 | if (ok) return; | 10322 | if (ok) return; |
| 9264 | src_assert(ok, source_instruction->source_node); | 10323 | src_assert(ok, source_instruction->source_node); |
| 9265 | } | 10324 | } |
| 9266 | | 10325 | |
| | 10326 | static void ir_assert_gen(bool ok, IrInstGen *source_instruction) { |
| | 10327 | if (ok) return; |
| | 10328 | src_assert(ok, source_instruction->base.source_node); |
| | 10329 | } |
| | 10330 | |
| 9267 | // This function takes a comptime ptr and makes the child const value conform to the type | 10331 | // This function takes a comptime ptr and makes the child const value conform to the type |
| 9268 | // described by the pointer. | 10332 | // described by the pointer. |
| 9269 | static Error eval_comptime_ptr_reinterpret(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, | 10333 | static Error eval_comptime_ptr_reinterpret(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, |
| ... | @@ -9309,43 +10373,43 @@ ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_va | ... | @@ -9309,43 +10373,43 @@ ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_va |
| 9309 | return val; | 10373 | return val; |
| 9310 | } | 10374 | } |
| 9311 | | 10375 | |
| 9312 | static ZigValue *ir_exec_const_result(CodeGen *codegen, IrExecutable *exec) { | 10376 | static ZigValue *ir_exec_const_result(CodeGen *codegen, IrExecutableGen *exec) { |
| 9313 | IrBasicBlock *bb = exec->basic_block_list.at(0); | 10377 | IrBasicBlockGen *bb = exec->basic_block_list.at(0); |
| 9314 | for (size_t i = 0; i < bb->instruction_list.length; i += 1) { | 10378 | for (size_t i = 0; i < bb->instruction_list.length; i += 1) { |
| 9315 | IrInstruction *instruction = bb->instruction_list.at(i); | 10379 | IrInstGen *instruction = bb->instruction_list.at(i); |
| 9316 | if (instruction->id == IrInstructionIdReturn) { | 10380 | if (instruction->id == IrInstGenIdReturn) { |
| 9317 | IrInstructionReturn *ret_inst = (IrInstructionReturn *)instruction; | 10381 | IrInstGenReturn *ret_inst = (IrInstGenReturn *)instruction; |
| 9318 | IrInstruction *operand = ret_inst->operand; | 10382 | IrInstGen *operand = ret_inst->operand; |
| 9319 | if (operand->value->special == ConstValSpecialRuntime) { | 10383 | if (operand->value->special == ConstValSpecialRuntime) { |
| 9320 | exec_add_error_node(codegen, exec, operand->source_node, | 10384 | exec_add_error_node_gen(codegen, exec, operand->base.source_node, |
| 9321 | buf_sprintf("unable to evaluate constant expression")); | 10385 | buf_sprintf("unable to evaluate constant expression")); |
| 9322 | return codegen->invalid_instruction->value; | 10386 | return codegen->invalid_inst_gen->value; |
| 9323 | } | 10387 | } |
| 9324 | return operand->value; | 10388 | return operand->value; |
| 9325 | } else if (ir_has_side_effects(instruction)) { | 10389 | } else if (ir_inst_gen_has_side_effects(instruction)) { |
| 9326 | if (instr_is_comptime(instruction)) { | 10390 | if (instr_is_comptime(instruction)) { |
| 9327 | switch (instruction->id) { | 10391 | switch (instruction->id) { |
| 9328 | case IrInstructionIdUnwrapErrPayload: | 10392 | case IrInstGenIdUnwrapErrPayload: |
| 9329 | case IrInstructionIdUnionFieldPtr: | 10393 | case IrInstGenIdUnionFieldPtr: |
| 9330 | continue; | 10394 | continue; |
| 9331 | default: | 10395 | default: |
| 9332 | break; | 10396 | break; |
| 9333 | } | 10397 | } |
| 9334 | } | 10398 | } |
| 9335 | if (get_scope_typeof(instruction->scope) != nullptr) { | 10399 | if (get_scope_typeof(instruction->base.scope) != nullptr) { |
| 9336 | // doesn't count, it's inside a @TypeOf() | 10400 | // doesn't count, it's inside a @TypeOf() |
| 9337 | continue; | 10401 | continue; |
| 9338 | } | 10402 | } |
| 9339 | exec_add_error_node(codegen, exec, instruction->source_node, | 10403 | exec_add_error_node_gen(codegen, exec, instruction->base.source_node, |
| 9340 | buf_sprintf("unable to evaluate constant expression")); | 10404 | buf_sprintf("unable to evaluate constant expression")); |
| 9341 | return codegen->invalid_instruction->value; | 10405 | return codegen->invalid_inst_gen->value; |
| 9342 | } | 10406 | } |
| 9343 | } | 10407 | } |
| 9344 | zig_unreachable(); | 10408 | zig_unreachable(); |
| 9345 | } | 10409 | } |
| 9346 | | 10410 | |
| 9347 | static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *source_instruction) { | 10411 | static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInst* source_instruction) { |
| 9348 | if (ir_should_inline(ira->new_irb.exec, source_instruction->scope)) { | 10412 | if (ir_should_inline(ira->old_irb.exec, source_instruction->scope)) { |
| 9349 | ir_add_error(ira, source_instruction, buf_sprintf("unable to evaluate constant expression")); | 10413 | ir_add_error(ira, source_instruction, buf_sprintf("unable to evaluate constant expression")); |
| 9350 | return false; | 10414 | return false; |
| 9351 | } | 10415 | } |
| ... | @@ -10079,7 +11143,7 @@ void float_read_ieee597(ZigValue *val, uint8_t *buf, bool is_big_endian) { | ... | @@ -10079,7 +11143,7 @@ void float_read_ieee597(ZigValue *val, uint8_t *buf, bool is_big_endian) { |
| 10079 | } | 11143 | } |
| 10080 | } | 11144 | } |
| 10081 | | 11145 | |
| 10082 | static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruction, ZigType *other_type, | 11146 | static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstGen *instruction, ZigType *other_type, |
| 10083 | bool explicit_cast) | 11147 | bool explicit_cast) |
| 10084 | { | 11148 | { |
| 10085 | if (type_is_invalid(other_type)) { | 11149 | if (type_is_invalid(other_type)) { |
| ... | @@ -10173,7 +11237,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -10173,7 +11237,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 10173 | } | 11237 | } |
| 10174 | Buf *val_buf = buf_alloc(); | 11238 | Buf *val_buf = buf_alloc(); |
| 10175 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); | 11239 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); |
| 10176 | ir_add_error(ira, instruction, | 11240 | ir_add_error_node(ira, instruction->base.source_node, |
| 10177 | buf_sprintf("integer value %s has no representation in type '%s'", | 11241 | buf_sprintf("integer value %s has no representation in type '%s'", |
| 10178 | buf_ptr(val_buf), | 11242 | buf_ptr(val_buf), |
| 10179 | buf_ptr(&other_type->name))); | 11243 | buf_ptr(&other_type->name))); |
| ... | @@ -10268,7 +11332,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -10268,7 +11332,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 10268 | } | 11332 | } |
| 10269 | Buf *val_buf = buf_alloc(); | 11333 | Buf *val_buf = buf_alloc(); |
| 10270 | float_append_buf(val_buf, const_val); | 11334 | float_append_buf(val_buf, const_val); |
| 10271 | ir_add_error(ira, instruction, | 11335 | ir_add_error_node(ira, instruction->base.source_node, |
| 10272 | buf_sprintf("cast of value %s to type '%s' loses information", | 11336 | buf_sprintf("cast of value %s to type '%s' loses information", |
| 10273 | buf_ptr(val_buf), | 11337 | buf_ptr(val_buf), |
| 10274 | buf_ptr(&other_type->name))); | 11338 | buf_ptr(&other_type->name))); |
| ... | @@ -10277,7 +11341,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -10277,7 +11341,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 10277 | if (!other_type->data.integral.is_signed && const_val->data.x_bigint.is_negative) { | 11341 | if (!other_type->data.integral.is_signed && const_val->data.x_bigint.is_negative) { |
| 10278 | Buf *val_buf = buf_alloc(); | 11342 | Buf *val_buf = buf_alloc(); |
| 10279 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); | 11343 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); |
| 10280 | ir_add_error(ira, instruction, | 11344 | ir_add_error_node(ira, instruction->base.source_node, |
| 10281 | buf_sprintf("cannot cast negative value %s to unsigned integer type '%s'", | 11345 | buf_sprintf("cannot cast negative value %s to unsigned integer type '%s'", |
| 10282 | buf_ptr(val_buf), | 11346 | buf_ptr(val_buf), |
| 10283 | buf_ptr(&other_type->name))); | 11347 | buf_ptr(&other_type->name))); |
| ... | @@ -10298,7 +11362,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -10298,7 +11362,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 10298 | if (!child_type->data.integral.is_signed && const_val->data.x_bigint.is_negative) { | 11362 | if (!child_type->data.integral.is_signed && const_val->data.x_bigint.is_negative) { |
| 10299 | Buf *val_buf = buf_alloc(); | 11363 | Buf *val_buf = buf_alloc(); |
| 10300 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); | 11364 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); |
| 10301 | ir_add_error(ira, instruction, | 11365 | ir_add_error_node(ira, instruction->base.source_node, |
| 10302 | buf_sprintf("cannot cast negative value %s to unsigned integer type '%s'", | 11366 | buf_sprintf("cannot cast negative value %s to unsigned integer type '%s'", |
| 10303 | buf_ptr(val_buf), | 11367 | buf_ptr(val_buf), |
| 10304 | buf_ptr(&child_type->name))); | 11368 | buf_ptr(&child_type->name))); |
| ... | @@ -10321,7 +11385,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -10321,7 +11385,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 10321 | Buf *val_buf = buf_alloc(); | 11385 | Buf *val_buf = buf_alloc(); |
| 10322 | float_append_buf(val_buf, const_val); | 11386 | float_append_buf(val_buf, const_val); |
| 10323 | | 11387 | |
| 10324 | ir_add_error(ira, instruction, | 11388 | ir_add_error_node(ira, instruction->base.source_node, |
| 10325 | buf_sprintf("fractional component prevents float value %s from being casted to type '%s'", | 11389 | buf_sprintf("fractional component prevents float value %s from being casted to type '%s'", |
| 10326 | buf_ptr(val_buf), | 11390 | buf_ptr(val_buf), |
| 10327 | buf_ptr(&other_type->name))); | 11391 | buf_ptr(&other_type->name))); |
| ... | @@ -10351,7 +11415,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc | ... | @@ -10351,7 +11415,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 10351 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); | 11415 | bigint_append_buf(val_buf, &const_val->data.x_bigint, 10); |
| 10352 | } | 11416 | } |
| 10353 | | 11417 | |
| 10354 | ir_add_error(ira, instruction, | 11418 | ir_add_error_node(ira, instruction->base.source_node, |
| 10355 | buf_sprintf("%s value %s cannot be coerced to type '%s'", | 11419 | buf_sprintf("%s value %s cannot be coerced to type '%s'", |
| 10356 | num_lit_str, | 11420 | num_lit_str, |
| 10357 | buf_ptr(val_buf), | 11421 | buf_ptr(val_buf), |
| ... | @@ -10805,11 +11869,11 @@ static void update_errors_helper(CodeGen *g, ErrorTableEntry ***errors, size_t * | ... | @@ -10805,11 +11869,11 @@ static void update_errors_helper(CodeGen *g, ErrorTableEntry ***errors, size_t * |
| 10805 | } | 11869 | } |
| 10806 | | 11870 | |
| 10807 | static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigType *expected_type, | 11871 | static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigType *expected_type, |
| 10808 | IrInstruction **instructions, size_t instruction_count) | 11872 | IrInstGen **instructions, size_t instruction_count) |
| 10809 | { | 11873 | { |
| 10810 | Error err; | 11874 | Error err; |
| 10811 | assert(instruction_count >= 1); | 11875 | assert(instruction_count >= 1); |
| 10812 | IrInstruction *prev_inst; | 11876 | IrInstGen *prev_inst; |
| 10813 | size_t i = 0; | 11877 | size_t i = 0; |
| 10814 | for (;;) { | 11878 | for (;;) { |
| 10815 | prev_inst = instructions[i]; | 11879 | prev_inst = instructions[i]; |
| ... | @@ -10829,7 +11893,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10829,7 +11893,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10829 | size_t errors_count = 0; | 11893 | size_t errors_count = 0; |
| 10830 | ZigType *err_set_type = nullptr; | 11894 | ZigType *err_set_type = nullptr; |
| 10831 | if (prev_inst->value->type->id == ZigTypeIdErrorSet) { | 11895 | if (prev_inst->value->type->id == ZigTypeIdErrorSet) { |
| 10832 | if (!resolve_inferred_error_set(ira->codegen, prev_inst->value->type, prev_inst->source_node)) { | 11896 | if (!resolve_inferred_error_set(ira->codegen, prev_inst->value->type, prev_inst->base.source_node)) { |
| 10833 | return ira->codegen->builtin_types.entry_invalid; | 11897 | return ira->codegen->builtin_types.entry_invalid; |
| 10834 | } | 11898 | } |
| 10835 | if (type_is_global_error_set(prev_inst->value->type)) { | 11899 | if (type_is_global_error_set(prev_inst->value->type)) { |
| ... | @@ -10849,7 +11913,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10849,7 +11913,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10849 | bool any_are_null = (prev_inst->value->type->id == ZigTypeIdNull); | 11913 | bool any_are_null = (prev_inst->value->type->id == ZigTypeIdNull); |
| 10850 | bool convert_to_const_slice = false; | 11914 | bool convert_to_const_slice = false; |
| 10851 | for (; i < instruction_count; i += 1) { | 11915 | for (; i < instruction_count; i += 1) { |
| 10852 | IrInstruction *cur_inst = instructions[i]; | 11916 | IrInstGen *cur_inst = instructions[i]; |
| 10853 | ZigType *cur_type = cur_inst->value->type; | 11917 | ZigType *cur_type = cur_inst->value->type; |
| 10854 | ZigType *prev_type = prev_inst->value->type; | 11918 | ZigType *prev_type = prev_inst->value->type; |
| 10855 | | 11919 | |
| ... | @@ -10871,14 +11935,14 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10871,14 +11935,14 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10871 | } | 11935 | } |
| 10872 | | 11936 | |
| 10873 | if (prev_type->id == ZigTypeIdErrorSet) { | 11937 | if (prev_type->id == ZigTypeIdErrorSet) { |
| 10874 | ir_assert(err_set_type != nullptr, prev_inst); | 11938 | ir_assert_gen(err_set_type != nullptr, prev_inst); |
| 10875 | if (cur_type->id == ZigTypeIdErrorSet) { | 11939 | if (cur_type->id == ZigTypeIdErrorSet) { |
| 10876 | if (type_is_global_error_set(err_set_type)) { | 11940 | if (type_is_global_error_set(err_set_type)) { |
| 10877 | continue; | 11941 | continue; |
| 10878 | } | 11942 | } |
| 10879 | bool allow_infer = cur_type->data.error_set.infer_fn != nullptr && | 11943 | bool allow_infer = cur_type->data.error_set.infer_fn != nullptr && |
| 10880 | cur_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; | 11944 | cur_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; |
| 10881 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, cur_type, cur_inst->source_node)) { | 11945 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, cur_type, cur_inst->base.source_node)) { |
| 10882 | return ira->codegen->builtin_types.entry_invalid; | 11946 | return ira->codegen->builtin_types.entry_invalid; |
| 10883 | } | 11947 | } |
| 10884 | if (!allow_infer && type_is_global_error_set(cur_type)) { | 11948 | if (!allow_infer && type_is_global_error_set(cur_type)) { |
| ... | @@ -10946,7 +12010,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -10946,7 +12010,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 10946 | ZigType *cur_err_set_type = cur_type->data.error_union.err_set_type; | 12010 | ZigType *cur_err_set_type = cur_type->data.error_union.err_set_type; |
| 10947 | bool allow_infer = cur_err_set_type->data.error_set.infer_fn != nullptr && | 12011 | bool allow_infer = cur_err_set_type->data.error_set.infer_fn != nullptr && |
| 10948 | cur_err_set_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; | 12012 | cur_err_set_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; |
| 10949 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->source_node)) { | 12013 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->base.source_node)) { |
| 10950 | return ira->codegen->builtin_types.entry_invalid; | 12014 | return ira->codegen->builtin_types.entry_invalid; |
| 10951 | } | 12015 | } |
| 10952 | if (!allow_infer && type_is_global_error_set(cur_err_set_type)) { | 12016 | if (!allow_infer && type_is_global_error_set(cur_err_set_type)) { |
| ... | @@ -11001,7 +12065,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -11001,7 +12065,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 11001 | if (cur_type->id == ZigTypeIdErrorSet) { | 12065 | if (cur_type->id == ZigTypeIdErrorSet) { |
| 11002 | bool allow_infer = cur_type->data.error_set.infer_fn != nullptr && | 12066 | bool allow_infer = cur_type->data.error_set.infer_fn != nullptr && |
| 11003 | cur_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; | 12067 | cur_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; |
| 11004 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, cur_type, cur_inst->source_node)) { | 12068 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, cur_type, cur_inst->base.source_node)) { |
| 11005 | return ira->codegen->builtin_types.entry_invalid; | 12069 | return ira->codegen->builtin_types.entry_invalid; |
| 11006 | } | 12070 | } |
| 11007 | if (!allow_infer && type_is_global_error_set(cur_type)) { | 12071 | if (!allow_infer && type_is_global_error_set(cur_type)) { |
| ... | @@ -11024,7 +12088,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -11024,7 +12088,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 11024 | err_set_type = cur_type; | 12088 | err_set_type = cur_type; |
| 11025 | } | 12089 | } |
| 11026 | | 12090 | |
| 11027 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, err_set_type, cur_inst->source_node)) { | 12091 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, err_set_type, cur_inst->base.source_node)) { |
| 11028 | return ira->codegen->builtin_types.entry_invalid; | 12092 | return ira->codegen->builtin_types.entry_invalid; |
| 11029 | } | 12093 | } |
| 11030 | | 12094 | |
| ... | @@ -11087,11 +12151,11 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -11087,11 +12151,11 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 11087 | bool allow_infer_cur = cur_err_set_type->data.error_set.infer_fn != nullptr && | 12151 | bool allow_infer_cur = cur_err_set_type->data.error_set.infer_fn != nullptr && |
| 11088 | cur_err_set_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; | 12152 | cur_err_set_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; |
| 11089 | | 12153 | |
| 11090 | if (!allow_infer_prev && !resolve_inferred_error_set(ira->codegen, prev_err_set_type, cur_inst->source_node)) { | 12154 | if (!allow_infer_prev && !resolve_inferred_error_set(ira->codegen, prev_err_set_type, cur_inst->base.source_node)) { |
| 11091 | return ira->codegen->builtin_types.entry_invalid; | 12155 | return ira->codegen->builtin_types.entry_invalid; |
| 11092 | } | 12156 | } |
| 11093 | | 12157 | |
| 11094 | if (!allow_infer_cur && !resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->source_node)) { | 12158 | if (!allow_infer_cur && !resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->base.source_node)) { |
| 11095 | return ira->codegen->builtin_types.entry_invalid; | 12159 | return ira->codegen->builtin_types.entry_invalid; |
| 11096 | } | 12160 | } |
| 11097 | | 12161 | |
| ... | @@ -11268,7 +12332,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -11268,7 +12332,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 11268 | ZigType *cur_err_set_type = cur_type->data.error_union.err_set_type; | 12332 | ZigType *cur_err_set_type = cur_type->data.error_union.err_set_type; |
| 11269 | bool allow_infer = cur_err_set_type->data.error_set.infer_fn != nullptr && | 12333 | bool allow_infer = cur_err_set_type->data.error_set.infer_fn != nullptr && |
| 11270 | cur_err_set_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; | 12334 | cur_err_set_type->data.error_set.infer_fn == ira->new_irb.exec->fn_entry; |
| 11271 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->source_node)) { | 12335 | if (!allow_infer && !resolve_inferred_error_set(ira->codegen, cur_err_set_type, cur_inst->base.source_node)) { |
| 11272 | return ira->codegen->builtin_types.entry_invalid; | 12336 | return ira->codegen->builtin_types.entry_invalid; |
| 11273 | } | 12337 | } |
| 11274 | if ((!allow_infer && type_is_global_error_set(cur_err_set_type)) || | 12338 | if ((!allow_infer && type_is_global_error_set(cur_err_set_type)) || |
| ... | @@ -11463,9 +12527,9 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -11463,9 +12527,9 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 11463 | ErrorMsg *msg = ir_add_error_node(ira, source_node, | 12527 | ErrorMsg *msg = ir_add_error_node(ira, source_node, |
| 11464 | buf_sprintf("incompatible types: '%s' and '%s'", | 12528 | buf_sprintf("incompatible types: '%s' and '%s'", |
| 11465 | buf_ptr(&prev_type->name), buf_ptr(&cur_type->name))); | 12529 | buf_ptr(&prev_type->name), buf_ptr(&cur_type->name))); |
| 11466 | add_error_note(ira->codegen, msg, prev_inst->source_node, | 12530 | add_error_note(ira->codegen, msg, prev_inst->base.source_node, |
| 11467 | buf_sprintf("type '%s' here", buf_ptr(&prev_type->name))); | 12531 | buf_sprintf("type '%s' here", buf_ptr(&prev_type->name))); |
| 11468 | add_error_note(ira->codegen, msg, cur_inst->source_node, | 12532 | add_error_note(ira->codegen, msg, cur_inst->base.source_node, |
| 11469 | buf_sprintf("type '%s' here", buf_ptr(&cur_type->name))); | 12533 | buf_sprintf("type '%s' here", buf_ptr(&cur_type->name))); |
| 11470 | | 12534 | |
| 11471 | return ira->codegen->builtin_types.entry_invalid; | 12535 | return ira->codegen->builtin_types.entry_invalid; |
| ... | @@ -11535,7 +12599,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT | ... | @@ -11535,7 +12599,7 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT |
| 11535 | } | 12599 | } |
| 11536 | } | 12600 | } |
| 11537 | | 12601 | |
| 11538 | static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_instr, | 12602 | static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInst *source_instr, |
| 11539 | CastOp cast_op, | 12603 | CastOp cast_op, |
| 11540 | ZigValue *other_val, ZigType *other_type, | 12604 | ZigValue *other_val, ZigType *other_type, |
| 11541 | ZigValue *const_val, ZigType *new_type) | 12605 | ZigValue *const_val, ZigType *new_type) |
| ... | @@ -11635,58 +12699,56 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -11635,58 +12699,56 @@ static bool eval_const_expr_implicit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 11635 | return true; | 12699 | return true; |
| 11636 | } | 12700 | } |
| 11637 | | 12701 | |
| 11638 | static IrInstruction *ir_const(IrAnalyze *ira, IrInstruction *old_instruction, ZigType *ty) { | 12702 | static IrInstGen *ir_const(IrAnalyze *ira, IrInst *inst, ZigType *ty) { |
| 11639 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 12703 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, |
| 11640 | old_instruction->scope, old_instruction->source_node); | 12704 | inst->scope, inst->source_node); |
| 11641 | IrInstruction *new_instruction = &const_instruction->base; | 12705 | IrInstGen *new_instruction = &const_instruction->base; |
| 11642 | new_instruction->value->type = ty; | 12706 | new_instruction->value->type = ty; |
| 11643 | new_instruction->value->special = ConstValSpecialStatic; | 12707 | new_instruction->value->special = ConstValSpecialStatic; |
| 11644 | return new_instruction; | 12708 | return new_instruction; |
| 11645 | } | 12709 | } |
| 11646 | | 12710 | |
| 11647 | static IrInstruction *ir_const_noval(IrAnalyze *ira, IrInstruction *old_instruction) { | 12711 | static IrInstGen *ir_const_noval(IrAnalyze *ira, IrInst *old_instruction) { |
| 11648 | IrInstructionConst *const_instruction = ir_create_instruction_noval<IrInstructionConst>(&ira->new_irb, | 12712 | IrInstGenConst *const_instruction = ir_create_inst_noval<IrInstGenConst>(&ira->new_irb, |
| 11649 | old_instruction->scope, old_instruction->source_node); | 12713 | old_instruction->scope, old_instruction->source_node); |
| 11650 | return &const_instruction->base; | 12714 | return &const_instruction->base; |
| 11651 | } | 12715 | } |
| 11652 | | 12716 | |
| 11653 | // This function initializes the new IrInstruction with the provided ZigValue, | 12717 | // This function initializes the new IrInstGen with the provided ZigValue, |
| 11654 | // rather than creating a new one. | 12718 | // rather than creating a new one. |
| 11655 | static IrInstruction *ir_const_move(IrAnalyze *ira, IrInstruction *old_instruction, ZigValue *val) { | 12719 | static IrInstGen *ir_const_move(IrAnalyze *ira, IrInst *old_instruction, ZigValue *val) { |
| 11656 | IrInstruction *result = ir_const_noval(ira, old_instruction); | 12720 | IrInstGen *result = ir_const_noval(ira, old_instruction); |
| 11657 | result->value = val; | 12721 | result->value = val; |
| 11658 | return result; | 12722 | return result; |
| 11659 | } | 12723 | } |
| 11660 | | 12724 | |
| 11661 | static IrInstruction *ir_resolve_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 12725 | static IrInstGen *ir_resolve_cast(IrAnalyze *ira, IrInst *source_instr, IrInstGen *value, |
| 11662 | ZigType *wanted_type, CastOp cast_op) | 12726 | ZigType *wanted_type, CastOp cast_op) |
| 11663 | { | 12727 | { |
| 11664 | if (instr_is_comptime(value) || !type_has_bits(wanted_type)) { | 12728 | if (instr_is_comptime(value) || !type_has_bits(wanted_type)) { |
| 11665 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12729 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 11666 | if (!eval_const_expr_implicit_cast(ira, source_instr, cast_op, value->value, value->value->type, | 12730 | if (!eval_const_expr_implicit_cast(ira, source_instr, cast_op, value->value, value->value->type, |
| 11667 | result->value, wanted_type)) | 12731 | result->value, wanted_type)) |
| 11668 | { | 12732 | { |
| 11669 | return ira->codegen->invalid_instruction; | 12733 | return ira->codegen->invalid_inst_gen; |
| 11670 | } | 12734 | } |
| 11671 | return result; | 12735 | return result; |
| 11672 | } else { | 12736 | } else { |
| 11673 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, wanted_type, value, cast_op); | 12737 | return ir_build_cast(ira, source_instr, wanted_type, value, cast_op); |
| 11674 | result->value->type = wanted_type; | | |
| 11675 | return result; | | |
| 11676 | } | 12738 | } |
| 11677 | } | 12739 | } |
| 11678 | | 12740 | |
| 11679 | static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, IrInstruction *source_instr, | 12741 | static IrInstGen *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, IrInst* source_instr, |
| 11680 | IrInstruction *value, ZigType *wanted_type) | 12742 | IrInstGen *value, ZigType *wanted_type) |
| 11681 | { | 12743 | { |
| 11682 | assert(value->value->type->id == ZigTypeIdPointer); | 12744 | ir_assert(value->value->type->id == ZigTypeIdPointer, source_instr); |
| 11683 | | 12745 | |
| 11684 | Error err; | 12746 | Error err; |
| 11685 | | 12747 | |
| 11686 | if ((err = type_resolve(ira->codegen, value->value->type->data.pointer.child_type, | 12748 | if ((err = type_resolve(ira->codegen, value->value->type->data.pointer.child_type, |
| 11687 | ResolveStatusAlignmentKnown))) | 12749 | ResolveStatusAlignmentKnown))) |
| 11688 | { | 12750 | { |
| 11689 | return ira->codegen->invalid_instruction; | 12751 | return ira->codegen->invalid_inst_gen; |
| 11690 | } | 12752 | } |
| 11691 | | 12753 | |
| 11692 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, value->value->type)); | 12754 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, value->value->type)); |
| ... | @@ -11694,9 +12756,9 @@ static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, | ... | @@ -11694,9 +12756,9 @@ static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, |
| 11694 | if (instr_is_comptime(value)) { | 12756 | if (instr_is_comptime(value)) { |
| 11695 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, value->value, source_instr->source_node); | 12757 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, value->value, source_instr->source_node); |
| 11696 | if (pointee == nullptr) | 12758 | if (pointee == nullptr) |
| 11697 | return ira->codegen->invalid_instruction; | 12759 | return ira->codegen->invalid_inst_gen; |
| 11698 | if (pointee->special != ConstValSpecialRuntime) { | 12760 | if (pointee->special != ConstValSpecialRuntime) { |
| 11699 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12761 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 11700 | result->value->data.x_ptr.special = ConstPtrSpecialBaseArray; | 12762 | result->value->data.x_ptr.special = ConstPtrSpecialBaseArray; |
| 11701 | result->value->data.x_ptr.mut = value->value->data.x_ptr.mut; | 12763 | result->value->data.x_ptr.mut = value->value->data.x_ptr.mut; |
| 11702 | result->value->data.x_ptr.data.base_array.array_val = pointee; | 12764 | result->value->data.x_ptr.data.base_array.array_val = pointee; |
| ... | @@ -11705,21 +12767,18 @@ static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, | ... | @@ -11705,21 +12767,18 @@ static IrInstruction *ir_resolve_ptr_of_array_to_unknown_len_ptr(IrAnalyze *ira, |
| 11705 | } | 12767 | } |
| 11706 | } | 12768 | } |
| 11707 | | 12769 | |
| 11708 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, | 12770 | return ir_build_cast(ira, source_instr, wanted_type, value, CastOpBitCast); |
| 11709 | wanted_type, value, CastOpBitCast); | | |
| 11710 | result->value->type = wanted_type; | | |
| 11711 | return result; | | |
| 11712 | } | 12771 | } |
| 11713 | | 12772 | |
| 11714 | static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruction *source_instr, | 12773 | static IrInstGen *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInst* source_instr, |
| 11715 | IrInstruction *array_ptr, ZigType *wanted_type, ResultLoc *result_loc) | 12774 | IrInstGen *array_ptr, ZigType *wanted_type, ResultLoc *result_loc) |
| 11716 | { | 12775 | { |
| 11717 | Error err; | 12776 | Error err; |
| 11718 | | 12777 | |
| 11719 | if ((err = type_resolve(ira->codegen, array_ptr->value->type->data.pointer.child_type, | 12778 | if ((err = type_resolve(ira->codegen, array_ptr->value->type->data.pointer.child_type, |
| 11720 | ResolveStatusAlignmentKnown))) | 12779 | ResolveStatusAlignmentKnown))) |
| 11721 | { | 12780 | { |
| 11722 | return ira->codegen->invalid_instruction; | 12781 | return ira->codegen->invalid_inst_gen; |
| 11723 | } | 12782 | } |
| 11724 | | 12783 | |
| 11725 | wanted_type = adjust_slice_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, array_ptr->value->type)); | 12784 | wanted_type = adjust_slice_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, array_ptr->value->type)); |
| ... | @@ -11727,14 +12786,14 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc | ... | @@ -11727,14 +12786,14 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc |
| 11727 | if (instr_is_comptime(array_ptr)) { | 12786 | if (instr_is_comptime(array_ptr)) { |
| 11728 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, array_ptr->value, source_instr->source_node); | 12787 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, array_ptr->value, source_instr->source_node); |
| 11729 | if (pointee == nullptr) | 12788 | if (pointee == nullptr) |
| 11730 | return ira->codegen->invalid_instruction; | 12789 | return ira->codegen->invalid_inst_gen; |
| 11731 | if (pointee->special != ConstValSpecialRuntime) { | 12790 | if (pointee->special != ConstValSpecialRuntime) { |
| 11732 | assert(array_ptr->value->type->id == ZigTypeIdPointer); | 12791 | assert(array_ptr->value->type->id == ZigTypeIdPointer); |
| 11733 | ZigType *array_type = array_ptr->value->type->data.pointer.child_type; | 12792 | ZigType *array_type = array_ptr->value->type->data.pointer.child_type; |
| 11734 | assert(is_slice(wanted_type)); | 12793 | assert(is_slice(wanted_type)); |
| 11735 | bool is_const = wanted_type->data.structure.fields[slice_ptr_index]->type_entry->data.pointer.is_const; | 12794 | bool is_const = wanted_type->data.structure.fields[slice_ptr_index]->type_entry->data.pointer.is_const; |
| 11736 | | 12795 | |
| 11737 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 12796 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 11738 | init_const_slice(ira->codegen, result->value, pointee, 0, array_type->data.array.len, is_const); | 12797 | init_const_slice(ira->codegen, result->value, pointee, 0, array_type->data.array.len, is_const); |
| 11739 | result->value->data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = array_ptr->value->data.x_ptr.mut; | 12798 | result->value->data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = array_ptr->value->data.x_ptr.mut; |
| 11740 | result->value->type = wanted_type; | 12799 | result->value->type = wanted_type; |
| ... | @@ -11743,32 +12802,34 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc | ... | @@ -11743,32 +12802,34 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc |
| 11743 | } | 12802 | } |
| 11744 | | 12803 | |
| 11745 | if (result_loc == nullptr) result_loc = no_result_loc(); | 12804 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 11746 | IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, | 12805 | IrInstGen *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, |
| 11747 | false, true); | 12806 | false, true); |
| 11748 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { | 12807 | if (type_is_invalid(result_loc_inst->value->type) || |
| | 12808 | result_loc_inst->value->type->id == ZigTypeIdUnreachable) |
| | 12809 | { |
| 11749 | return result_loc_inst; | 12810 | return result_loc_inst; |
| 11750 | } | 12811 | } |
| 11751 | return ir_build_ptr_of_array_to_slice(ira, source_instr, wanted_type, array_ptr, result_loc_inst); | 12812 | return ir_build_ptr_of_array_to_slice(ira, source_instr, wanted_type, array_ptr, result_loc_inst); |
| 11752 | } | 12813 | } |
| 11753 | | 12814 | |
| 11754 | static IrBasicBlock *ir_get_new_bb(IrAnalyze *ira, IrBasicBlock *old_bb, IrInstruction *ref_old_instruction) { | 12815 | static IrBasicBlockGen *ir_get_new_bb(IrAnalyze *ira, IrBasicBlockSrc *old_bb, IrInst *ref_old_instruction) { |
| 11755 | assert(old_bb); | 12816 | assert(old_bb); |
| 11756 | | 12817 | |
| 11757 | if (old_bb->other) { | 12818 | if (old_bb->child) { |
| 11758 | if (ref_old_instruction == nullptr || old_bb->other->ref_instruction != ref_old_instruction) { | 12819 | if (ref_old_instruction == nullptr || old_bb->child->ref_instruction != ref_old_instruction) { |
| 11759 | return old_bb->other; | 12820 | return old_bb->child; |
| 11760 | } | 12821 | } |
| 11761 | } | 12822 | } |
| 11762 | | 12823 | |
| 11763 | IrBasicBlock *new_bb = ir_build_bb_from(&ira->new_irb, old_bb); | 12824 | IrBasicBlockGen *new_bb = ir_build_bb_from(ira, old_bb); |
| 11764 | new_bb->ref_instruction = ref_old_instruction; | 12825 | new_bb->ref_instruction = ref_old_instruction; |
| 11765 | | 12826 | |
| 11766 | return new_bb; | 12827 | return new_bb; |
| 11767 | } | 12828 | } |
| 11768 | | 12829 | |
| 11769 | static IrBasicBlock *ir_get_new_bb_runtime(IrAnalyze *ira, IrBasicBlock *old_bb, IrInstruction *ref_old_instruction) { | 12830 | static IrBasicBlockGen *ir_get_new_bb_runtime(IrAnalyze *ira, IrBasicBlockSrc *old_bb, IrInst *ref_old_instruction) { |
| 11770 | assert(ref_old_instruction != nullptr); | 12831 | assert(ref_old_instruction != nullptr); |
| 11771 | IrBasicBlock *new_bb = ir_get_new_bb(ira, old_bb, ref_old_instruction); | 12832 | IrBasicBlockGen *new_bb = ir_get_new_bb(ira, old_bb, ref_old_instruction); |
| 11772 | if (new_bb->must_be_comptime_source_instr) { | 12833 | if (new_bb->must_be_comptime_source_instr) { |
| 11773 | ErrorMsg *msg = ir_add_error(ira, ref_old_instruction, | 12834 | ErrorMsg *msg = ir_add_error(ira, ref_old_instruction, |
| 11774 | buf_sprintf("control flow attempts to use compile-time variable at runtime")); | 12835 | buf_sprintf("control flow attempts to use compile-time variable at runtime")); |
| ... | @@ -11779,24 +12840,24 @@ static IrBasicBlock *ir_get_new_bb_runtime(IrAnalyze *ira, IrBasicBlock *old_bb, | ... | @@ -11779,24 +12840,24 @@ static IrBasicBlock *ir_get_new_bb_runtime(IrAnalyze *ira, IrBasicBlock *old_bb, |
| 11779 | return new_bb; | 12840 | return new_bb; |
| 11780 | } | 12841 | } |
| 11781 | | 12842 | |
| 11782 | static void ir_start_bb(IrAnalyze *ira, IrBasicBlock *old_bb, IrBasicBlock *const_predecessor_bb) { | 12843 | static void ir_start_bb(IrAnalyze *ira, IrBasicBlockSrc *old_bb, IrBasicBlockSrc *const_predecessor_bb) { |
| 11783 | ir_assert(!old_bb->suspended, (old_bb->instruction_list.length != 0) ? old_bb->instruction_list.at(0) : nullptr); | 12844 | ir_assert(!old_bb->suspended, (old_bb->instruction_list.length != 0) ? &old_bb->instruction_list.at(0)->base : nullptr); |
| 11784 | ira->instruction_index = 0; | 12845 | ira->instruction_index = 0; |
| 11785 | ira->old_irb.current_basic_block = old_bb; | 12846 | ira->old_irb.current_basic_block = old_bb; |
| 11786 | ira->const_predecessor_bb = const_predecessor_bb; | 12847 | ira->const_predecessor_bb = const_predecessor_bb; |
| 11787 | ira->old_bb_index = old_bb->index; | 12848 | ira->old_bb_index = old_bb->index; |
| 11788 | } | 12849 | } |
| 11789 | | 12850 | |
| 11790 | static IrInstruction *ira_suspend(IrAnalyze *ira, IrInstruction *old_instruction, IrBasicBlock *next_bb, | 12851 | static IrInstGen *ira_suspend(IrAnalyze *ira, IrInst *old_instruction, IrBasicBlockSrc *next_bb, |
| 11791 | IrSuspendPosition *suspend_pos) | 12852 | IrSuspendPosition *suspend_pos) |
| 11792 | { | 12853 | { |
| 11793 | if (ira->codegen->verbose_ir) { | 12854 | if (ira->codegen->verbose_ir) { |
| 11794 | fprintf(stderr, "suspend %s_%zu %s_%zu #%" PRIu32 " (%zu,%zu)\n", | 12855 | fprintf(stderr, "suspend %s_%" PRIu32 " %s_%" PRIu32 " #%" PRIu32 " (%zu,%zu)\n", |
| 11795 | ira->old_irb.current_basic_block->name_hint, | 12856 | ira->old_irb.current_basic_block->name_hint, |
| 11796 | ira->old_irb.current_basic_block->debug_id, | 12857 | ira->old_irb.current_basic_block->debug_id, |
| 11797 | ira->old_irb.exec->basic_block_list.at(ira->old_bb_index)->name_hint, | 12858 | ira->old_irb.exec->basic_block_list.at(ira->old_bb_index)->name_hint, |
| 11798 | ira->old_irb.exec->basic_block_list.at(ira->old_bb_index)->debug_id, | 12859 | ira->old_irb.exec->basic_block_list.at(ira->old_bb_index)->debug_id, |
| 11799 | ira->old_irb.current_basic_block->instruction_list.at(ira->instruction_index)->debug_id, | 12860 | ira->old_irb.current_basic_block->instruction_list.at(ira->instruction_index)->base.debug_id, |
| 11800 | ira->old_bb_index, ira->instruction_index); | 12861 | ira->old_bb_index, ira->instruction_index); |
| 11801 | } | 12862 | } |
| 11802 | suspend_pos->basic_block_index = ira->old_bb_index; | 12863 | suspend_pos->basic_block_index = ira->old_bb_index; |
| ... | @@ -11811,13 +12872,13 @@ static IrInstruction *ira_suspend(IrAnalyze *ira, IrInstruction *old_instruction | ... | @@ -11811,13 +12872,13 @@ static IrInstruction *ira_suspend(IrAnalyze *ira, IrInstruction *old_instruction |
| 11811 | assert(ira->old_irb.current_basic_block == next_bb); | 12872 | assert(ira->old_irb.current_basic_block == next_bb); |
| 11812 | ira->instruction_index = 0; | 12873 | ira->instruction_index = 0; |
| 11813 | ira->const_predecessor_bb = nullptr; | 12874 | ira->const_predecessor_bb = nullptr; |
| 11814 | next_bb->other = ir_get_new_bb_runtime(ira, next_bb, old_instruction); | 12875 | next_bb->child = ir_get_new_bb_runtime(ira, next_bb, old_instruction); |
| 11815 | ira->new_irb.current_basic_block = next_bb->other; | 12876 | ira->new_irb.current_basic_block = next_bb->child; |
| 11816 | } | 12877 | } |
| 11817 | return ira->codegen->unreach_instruction; | 12878 | return ira->codegen->unreach_instruction; |
| 11818 | } | 12879 | } |
| 11819 | | 12880 | |
| 11820 | static IrInstruction *ira_resume(IrAnalyze *ira) { | 12881 | static IrInstGen *ira_resume(IrAnalyze *ira) { |
| 11821 | IrSuspendPosition pos = ira->resume_stack.pop(); | 12882 | IrSuspendPosition pos = ira->resume_stack.pop(); |
| 11822 | if (ira->codegen->verbose_ir) { | 12883 | if (ira->codegen->verbose_ir) { |
| 11823 | fprintf(stderr, "resume (%zu,%zu) ", pos.basic_block_index, pos.instruction_index); | 12884 | fprintf(stderr, "resume (%zu,%zu) ", pos.basic_block_index, pos.instruction_index); |
| ... | @@ -11830,12 +12891,12 @@ static IrInstruction *ira_resume(IrAnalyze *ira) { | ... | @@ -11830,12 +12891,12 @@ static IrInstruction *ira_resume(IrAnalyze *ira) { |
| 11830 | ira->instruction_index = pos.instruction_index; | 12891 | ira->instruction_index = pos.instruction_index; |
| 11831 | assert(pos.instruction_index < ira->old_irb.current_basic_block->instruction_list.length); | 12892 | assert(pos.instruction_index < ira->old_irb.current_basic_block->instruction_list.length); |
| 11832 | if (ira->codegen->verbose_ir) { | 12893 | if (ira->codegen->verbose_ir) { |
| 11833 | fprintf(stderr, "%s_%zu #%" PRIu32 "\n", ira->old_irb.current_basic_block->name_hint, | 12894 | fprintf(stderr, "%s_%" PRIu32 " #%" PRIu32 "\n", ira->old_irb.current_basic_block->name_hint, |
| 11834 | ira->old_irb.current_basic_block->debug_id, | 12895 | ira->old_irb.current_basic_block->debug_id, |
| 11835 | ira->old_irb.current_basic_block->instruction_list.at(pos.instruction_index)->debug_id); | 12896 | ira->old_irb.current_basic_block->instruction_list.at(pos.instruction_index)->base.debug_id); |
| 11836 | } | 12897 | } |
| 11837 | ira->const_predecessor_bb = nullptr; | 12898 | ira->const_predecessor_bb = nullptr; |
| 11838 | ira->new_irb.current_basic_block = ira->old_irb.current_basic_block->other; | 12899 | ira->new_irb.current_basic_block = ira->old_irb.current_basic_block->child; |
| 11839 | assert(ira->new_irb.current_basic_block != nullptr); | 12900 | assert(ira->new_irb.current_basic_block != nullptr); |
| 11840 | return ira->codegen->unreach_instruction; | 12901 | return ira->codegen->unreach_instruction; |
| 11841 | } | 12902 | } |
| ... | @@ -11846,8 +12907,8 @@ static void ir_start_next_bb(IrAnalyze *ira) { | ... | @@ -11846,8 +12907,8 @@ static void ir_start_next_bb(IrAnalyze *ira) { |
| 11846 | bool need_repeat = true; | 12907 | bool need_repeat = true; |
| 11847 | for (;;) { | 12908 | for (;;) { |
| 11848 | while (ira->old_bb_index < ira->old_irb.exec->basic_block_list.length) { | 12909 | while (ira->old_bb_index < ira->old_irb.exec->basic_block_list.length) { |
| 11849 | IrBasicBlock *old_bb = ira->old_irb.exec->basic_block_list.at(ira->old_bb_index); | 12910 | IrBasicBlockSrc *old_bb = ira->old_irb.exec->basic_block_list.at(ira->old_bb_index); |
| 11850 | if (old_bb->other == nullptr && old_bb->suspend_instruction_ref == nullptr) { | 12911 | if (old_bb->child == nullptr && old_bb->suspend_instruction_ref == nullptr) { |
| 11851 | ira->old_bb_index += 1; | 12912 | ira->old_bb_index += 1; |
| 11852 | continue; | 12913 | continue; |
| 11853 | } | 12914 | } |
| ... | @@ -11855,8 +12916,8 @@ static void ir_start_next_bb(IrAnalyze *ira) { | ... | @@ -11855,8 +12916,8 @@ static void ir_start_next_bb(IrAnalyze *ira) { |
| 11855 | // if it's a suspended block, | 12916 | // if it's a suspended block, |
| 11856 | // then skip it | 12917 | // then skip it |
| 11857 | if (old_bb->suspended || | 12918 | if (old_bb->suspended || |
| 11858 | (old_bb->other != nullptr && old_bb->other->instruction_list.length != 0) || | 12919 | (old_bb->child != nullptr && old_bb->child->instruction_list.length != 0) || |
| 11859 | (old_bb->other != nullptr && old_bb->other->already_appended)) | 12920 | (old_bb->child != nullptr && old_bb->child->already_appended)) |
| 11860 | { | 12921 | { |
| 11861 | ira->old_bb_index += 1; | 12922 | ira->old_bb_index += 1; |
| 11862 | continue; | 12923 | continue; |
| ... | @@ -11870,10 +12931,10 @@ static void ir_start_next_bb(IrAnalyze *ira) { | ... | @@ -11870,10 +12931,10 @@ static void ir_start_next_bb(IrAnalyze *ira) { |
| 11870 | return; | 12931 | return; |
| 11871 | } | 12932 | } |
| 11872 | | 12933 | |
| 11873 | if (old_bb->other == nullptr) { | 12934 | if (old_bb->child == nullptr) { |
| 11874 | old_bb->other = ir_get_new_bb_runtime(ira, old_bb, old_bb->suspend_instruction_ref); | 12935 | old_bb->child = ir_get_new_bb_runtime(ira, old_bb, old_bb->suspend_instruction_ref); |
| 11875 | } | 12936 | } |
| 11876 | ira->new_irb.current_basic_block = old_bb->other; | 12937 | ira->new_irb.current_basic_block = old_bb->child; |
| 11877 | ir_start_bb(ira, old_bb, nullptr); | 12938 | ir_start_bb(ira, old_bb, nullptr); |
| 11878 | return; | 12939 | return; |
| 11879 | } | 12940 | } |
| ... | @@ -11893,16 +12954,16 @@ static void ir_finish_bb(IrAnalyze *ira) { | ... | @@ -11893,16 +12954,16 @@ static void ir_finish_bb(IrAnalyze *ira) { |
| 11893 | if (!ira->new_irb.current_basic_block->already_appended) { | 12954 | if (!ira->new_irb.current_basic_block->already_appended) { |
| 11894 | ira->new_irb.current_basic_block->already_appended = true; | 12955 | ira->new_irb.current_basic_block->already_appended = true; |
| 11895 | if (ira->codegen->verbose_ir) { | 12956 | if (ira->codegen->verbose_ir) { |
| 11896 | fprintf(stderr, "append new bb %s_%zu\n", ira->new_irb.current_basic_block->name_hint, | 12957 | fprintf(stderr, "append new bb %s_%" PRIu32 "\n", ira->new_irb.current_basic_block->name_hint, |
| 11897 | ira->new_irb.current_basic_block->debug_id); | 12958 | ira->new_irb.current_basic_block->debug_id); |
| 11898 | } | 12959 | } |
| 11899 | ira->new_irb.exec->basic_block_list.append(ira->new_irb.current_basic_block); | 12960 | ira->new_irb.exec->basic_block_list.append(ira->new_irb.current_basic_block); |
| 11900 | } | 12961 | } |
| 11901 | ira->instruction_index += 1; | 12962 | ira->instruction_index += 1; |
| 11902 | while (ira->instruction_index < ira->old_irb.current_basic_block->instruction_list.length) { | 12963 | while (ira->instruction_index < ira->old_irb.current_basic_block->instruction_list.length) { |
| 11903 | IrInstruction *next_instruction = ira->old_irb.current_basic_block->instruction_list.at(ira->instruction_index); | 12964 | IrInstSrc *next_instruction = ira->old_irb.current_basic_block->instruction_list.at(ira->instruction_index); |
| 11904 | if (!next_instruction->is_gen) { | 12965 | if (!next_instruction->is_gen) { |
| 11905 | ir_add_error(ira, next_instruction, buf_sprintf("unreachable code")); | 12966 | ir_add_error(ira, &next_instruction->base, buf_sprintf("unreachable code")); |
| 11906 | break; | 12967 | break; |
| 11907 | } | 12968 | } |
| 11908 | ira->instruction_index += 1; | 12969 | ira->instruction_index += 1; |
| ... | @@ -11911,7 +12972,7 @@ static void ir_finish_bb(IrAnalyze *ira) { | ... | @@ -11911,7 +12972,7 @@ static void ir_finish_bb(IrAnalyze *ira) { |
| 11911 | ir_start_next_bb(ira); | 12972 | ir_start_next_bb(ira); |
| 11912 | } | 12973 | } |
| 11913 | | 12974 | |
| 11914 | static IrInstruction *ir_unreach_error(IrAnalyze *ira) { | 12975 | static IrInstGen *ir_unreach_error(IrAnalyze *ira) { |
| 11915 | ira->old_bb_index = SIZE_MAX; | 12976 | ira->old_bb_index = SIZE_MAX; |
| 11916 | if (ira->new_irb.exec->first_err_trace_msg == nullptr) { | 12977 | if (ira->new_irb.exec->first_err_trace_msg == nullptr) { |
| 11917 | ira->new_irb.exec->first_err_trace_msg = ira->codegen->trace_err; | 12978 | ira->new_irb.exec->first_err_trace_msg = ira->codegen->trace_err; |
| ... | @@ -11919,7 +12980,7 @@ static IrInstruction *ir_unreach_error(IrAnalyze *ira) { | ... | @@ -11919,7 +12980,7 @@ static IrInstruction *ir_unreach_error(IrAnalyze *ira) { |
| 11919 | return ira->codegen->unreach_instruction; | 12980 | return ira->codegen->unreach_instruction; |
| 11920 | } | 12981 | } |
| 11921 | | 12982 | |
| 11922 | static bool ir_emit_backward_branch(IrAnalyze *ira, IrInstruction *source_instruction) { | 12983 | static bool ir_emit_backward_branch(IrAnalyze *ira, IrInst* source_instruction) { |
| 11923 | size_t *bbc = ira->new_irb.exec->backward_branch_count; | 12984 | size_t *bbc = ira->new_irb.exec->backward_branch_count; |
| 11924 | size_t *quota = ira->new_irb.exec->backward_branch_quota; | 12985 | size_t *quota = ira->new_irb.exec->backward_branch_quota; |
| 11925 | | 12986 | |
| ... | @@ -11938,66 +12999,82 @@ static bool ir_emit_backward_branch(IrAnalyze *ira, IrInstruction *source_instru | ... | @@ -11938,66 +12999,82 @@ static bool ir_emit_backward_branch(IrAnalyze *ira, IrInstruction *source_instru |
| 11938 | return true; | 12999 | return true; |
| 11939 | } | 13000 | } |
| 11940 | | 13001 | |
| 11941 | static IrInstruction *ir_inline_bb(IrAnalyze *ira, IrInstruction *source_instruction, IrBasicBlock *old_bb) { | 13002 | static IrInstGen *ir_inline_bb(IrAnalyze *ira, IrInst* source_instruction, IrBasicBlockSrc *old_bb) { |
| 11942 | if (old_bb->debug_id <= ira->old_irb.current_basic_block->debug_id) { | 13003 | if (old_bb->debug_id <= ira->old_irb.current_basic_block->debug_id) { |
| 11943 | if (!ir_emit_backward_branch(ira, source_instruction)) | 13004 | if (!ir_emit_backward_branch(ira, source_instruction)) |
| 11944 | return ir_unreach_error(ira); | 13005 | return ir_unreach_error(ira); |
| 11945 | } | 13006 | } |
| 11946 | | 13007 | |
| 11947 | old_bb->other = ira->old_irb.current_basic_block->other; | 13008 | old_bb->child = ira->old_irb.current_basic_block->child; |
| 11948 | ir_start_bb(ira, old_bb, ira->old_irb.current_basic_block); | 13009 | ir_start_bb(ira, old_bb, ira->old_irb.current_basic_block); |
| 11949 | return ira->codegen->unreach_instruction; | 13010 | return ira->codegen->unreach_instruction; |
| 11950 | } | 13011 | } |
| 11951 | | 13012 | |
| 11952 | static IrInstruction *ir_finish_anal(IrAnalyze *ira, IrInstruction *instruction) { | 13013 | static IrInstGen *ir_finish_anal(IrAnalyze *ira, IrInstGen *instruction) { |
| 11953 | if (instruction->value->type->id == ZigTypeIdUnreachable) | 13014 | if (instruction->value->type->id == ZigTypeIdUnreachable) |
| 11954 | ir_finish_bb(ira); | 13015 | ir_finish_bb(ira); |
| 11955 | return instruction; | 13016 | return instruction; |
| 11956 | } | 13017 | } |
| 11957 | | 13018 | |
| 11958 | static IrInstruction *ir_const_type(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) { | 13019 | static IrInstGen *ir_const_fn(IrAnalyze *ira, IrInst *source_instr, ZigFn *fn_entry) { |
| 11959 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_type); | 13020 | IrInstGen *result = ir_const(ira, source_instr, fn_entry->type_entry); |
| | 13021 | result->value->special = ConstValSpecialStatic; |
| | 13022 | result->value->data.x_ptr.data.fn.fn_entry = fn_entry; |
| | 13023 | result->value->data.x_ptr.mut = ConstPtrMutComptimeConst; |
| | 13024 | result->value->data.x_ptr.special = ConstPtrSpecialFunction; |
| | 13025 | return result; |
| | 13026 | } |
| | 13027 | |
| | 13028 | static IrInstGen *ir_const_bound_fn(IrAnalyze *ira, IrInst *src_inst, ZigFn *fn_entry, IrInstGen *first_arg) { |
| | 13029 | IrInstGen *result = ir_const(ira, src_inst, get_bound_fn_type(ira->codegen, fn_entry)); |
| | 13030 | result->value->data.x_bound_fn.fn = fn_entry; |
| | 13031 | result->value->data.x_bound_fn.first_arg = first_arg; |
| | 13032 | return result; |
| | 13033 | } |
| | 13034 | |
| | 13035 | static IrInstGen *ir_const_type(IrAnalyze *ira, IrInst *source_instruction, ZigType *ty) { |
| | 13036 | IrInstGen *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_type); |
| 11960 | result->value->data.x_type = ty; | 13037 | result->value->data.x_type = ty; |
| 11961 | return result; | 13038 | return result; |
| 11962 | } | 13039 | } |
| 11963 | | 13040 | |
| 11964 | static IrInstruction *ir_const_bool(IrAnalyze *ira, IrInstruction *source_instruction, bool value) { | 13041 | static IrInstGen *ir_const_bool(IrAnalyze *ira, IrInst *source_instruction, bool value) { |
| 11965 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_bool); | 13042 | IrInstGen *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_bool); |
| 11966 | result->value->data.x_bool = value; | 13043 | result->value->data.x_bool = value; |
| 11967 | return result; | 13044 | return result; |
| 11968 | } | 13045 | } |
| 11969 | | 13046 | |
| 11970 | static IrInstruction *ir_const_undef(IrAnalyze *ira, IrInstruction *source_instruction, ZigType *ty) { | 13047 | static IrInstGen *ir_const_undef(IrAnalyze *ira, IrInst *source_instruction, ZigType *ty) { |
| 11971 | IrInstruction *result = ir_const(ira, source_instruction, ty); | 13048 | IrInstGen *result = ir_const(ira, source_instruction, ty); |
| 11972 | result->value->special = ConstValSpecialUndef; | 13049 | result->value->special = ConstValSpecialUndef; |
| 11973 | return result; | 13050 | return result; |
| 11974 | } | 13051 | } |
| 11975 | | 13052 | |
| 11976 | static IrInstruction *ir_const_unreachable(IrAnalyze *ira, IrInstruction *source_instruction) { | 13053 | static IrInstGen *ir_const_unreachable(IrAnalyze *ira, IrInst *source_instruction) { |
| 11977 | IrInstruction *result = ir_const_noval(ira, source_instruction); | 13054 | IrInstGen *result = ir_const_noval(ira, source_instruction); |
| 11978 | result->value = ira->codegen->intern.for_unreachable(); | 13055 | result->value = ira->codegen->intern.for_unreachable(); |
| 11979 | return result; | 13056 | return result; |
| 11980 | } | 13057 | } |
| 11981 | | 13058 | |
| 11982 | static IrInstruction *ir_const_void(IrAnalyze *ira, IrInstruction *source_instruction) { | 13059 | static IrInstGen *ir_const_void(IrAnalyze *ira, IrInst *source_instruction) { |
| 11983 | IrInstruction *result = ir_const_noval(ira, source_instruction); | 13060 | IrInstGen *result = ir_const_noval(ira, source_instruction); |
| 11984 | result->value = ira->codegen->intern.for_void(); | 13061 | result->value = ira->codegen->intern.for_void(); |
| 11985 | return result; | 13062 | return result; |
| 11986 | } | 13063 | } |
| 11987 | | 13064 | |
| 11988 | static IrInstruction *ir_const_unsigned(IrAnalyze *ira, IrInstruction *source_instruction, uint64_t value) { | 13065 | static IrInstGen *ir_const_unsigned(IrAnalyze *ira, IrInst *source_instruction, uint64_t value) { |
| 11989 | IrInstruction *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_num_lit_int); | 13066 | IrInstGen *result = ir_const(ira, source_instruction, ira->codegen->builtin_types.entry_num_lit_int); |
| 11990 | bigint_init_unsigned(&result->value->data.x_bigint, value); | 13067 | bigint_init_unsigned(&result->value->data.x_bigint, value); |
| 11991 | return result; | 13068 | return result; |
| 11992 | } | 13069 | } |
| 11993 | | 13070 | |
| 11994 | static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instruction, | 13071 | static IrInstGen *ir_get_const_ptr(IrAnalyze *ira, IrInst *instruction, |
| 11995 | ZigValue *pointee, ZigType *pointee_type, | 13072 | ZigValue *pointee, ZigType *pointee_type, |
| 11996 | ConstPtrMut ptr_mut, bool ptr_is_const, bool ptr_is_volatile, uint32_t ptr_align) | 13073 | ConstPtrMut ptr_mut, bool ptr_is_const, bool ptr_is_volatile, uint32_t ptr_align) |
| 11997 | { | 13074 | { |
| 11998 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type, | 13075 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, pointee_type, |
| 11999 | ptr_is_const, ptr_is_volatile, PtrLenSingle, ptr_align, 0, 0, false); | 13076 | ptr_is_const, ptr_is_volatile, PtrLenSingle, ptr_align, 0, 0, false); |
| 12000 | IrInstruction *const_instr = ir_const(ira, instruction, ptr_type); | 13077 | IrInstGen *const_instr = ir_const(ira, instruction, ptr_type); |
| 12001 | ZigValue *const_val = const_instr->value; | 13078 | ZigValue *const_val = const_instr->value; |
| 12002 | const_val->data.x_ptr.special = ConstPtrSpecialRef; | 13079 | const_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 12003 | const_val->data.x_ptr.mut = ptr_mut; | 13080 | const_val->data.x_ptr.mut = ptr_mut; |
| ... | @@ -12005,7 +13082,7 @@ static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instructio | ... | @@ -12005,7 +13082,7 @@ static IrInstruction *ir_get_const_ptr(IrAnalyze *ira, IrInstruction *instructio |
| 12005 | return const_instr; | 13082 | return const_instr; |
| 12006 | } | 13083 | } |
| 12007 | | 13084 | |
| 12008 | static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, | 13085 | static Error ir_resolve_const_val(CodeGen *codegen, IrExecutableGen *exec, AstNode *source_node, |
| 12009 | ZigValue *val, UndefAllowed undef_allowed) | 13086 | ZigValue *val, UndefAllowed undef_allowed) |
| 12010 | { | 13087 | { |
| 12011 | Error err; | 13088 | Error err; |
| ... | @@ -12017,14 +13094,14 @@ static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode | ... | @@ -12017,14 +13094,14 @@ static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode |
| 12017 | if (!type_has_bits(val->type)) | 13094 | if (!type_has_bits(val->type)) |
| 12018 | return ErrorNone; | 13095 | return ErrorNone; |
| 12019 | | 13096 | |
| 12020 | exec_add_error_node(codegen, exec, source_node, | 13097 | exec_add_error_node_gen(codegen, exec, source_node, |
| 12021 | buf_sprintf("unable to evaluate constant expression")); | 13098 | buf_sprintf("unable to evaluate constant expression")); |
| 12022 | return ErrorSemanticAnalyzeFail; | 13099 | return ErrorSemanticAnalyzeFail; |
| 12023 | case ConstValSpecialUndef: | 13100 | case ConstValSpecialUndef: |
| 12024 | if (undef_allowed == UndefOk || undef_allowed == LazyOk) | 13101 | if (undef_allowed == UndefOk || undef_allowed == LazyOk) |
| 12025 | return ErrorNone; | 13102 | return ErrorNone; |
| 12026 | | 13103 | |
| 12027 | exec_add_error_node(codegen, exec, source_node, | 13104 | exec_add_error_node_gen(codegen, exec, source_node, |
| 12028 | buf_sprintf("use of undefined value here causes undefined behavior")); | 13105 | buf_sprintf("use of undefined value here causes undefined behavior")); |
| 12029 | return ErrorSemanticAnalyzeFail; | 13106 | return ErrorSemanticAnalyzeFail; |
| 12030 | case ConstValSpecialLazy: | 13107 | case ConstValSpecialLazy: |
| ... | @@ -12039,9 +13116,9 @@ static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode | ... | @@ -12039,9 +13116,9 @@ static Error ir_resolve_const_val(CodeGen *codegen, IrExecutable *exec, AstNode |
| 12039 | } | 13116 | } |
| 12040 | } | 13117 | } |
| 12041 | | 13118 | |
| 12042 | static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAllowed undef_allowed) { | 13119 | static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstGen *value, UndefAllowed undef_allowed) { |
| 12043 | Error err; | 13120 | Error err; |
| 12044 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, value->source_node, | 13121 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, value->base.source_node, |
| 12045 | value->value, undef_allowed))) | 13122 | value->value, undef_allowed))) |
| 12046 | { | 13123 | { |
| 12047 | return nullptr; | 13124 | return nullptr; |
| ... | @@ -12052,14 +13129,14 @@ static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAll | ... | @@ -12052,14 +13129,14 @@ static ZigValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, UndefAll |
| 12052 | ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | 13129 | ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 12053 | ZigType *expected_type, size_t *backward_branch_count, size_t *backward_branch_quota, | 13130 | ZigType *expected_type, size_t *backward_branch_count, size_t *backward_branch_quota, |
| 12054 | ZigFn *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name, | 13131 | ZigFn *fn_entry, Buf *c_import_buf, AstNode *source_node, Buf *exec_name, |
| 12055 | IrExecutable *parent_exec, AstNode *expected_type_source_node, UndefAllowed undef_allowed) | 13132 | IrExecutableGen *parent_exec, AstNode *expected_type_source_node, UndefAllowed undef_allowed) |
| 12056 | { | 13133 | { |
| 12057 | Error err; | 13134 | Error err; |
| 12058 | | 13135 | |
| 12059 | if (expected_type != nullptr && type_is_invalid(expected_type)) | 13136 | if (expected_type != nullptr && type_is_invalid(expected_type)) |
| 12060 | return codegen->invalid_instruction->value; | 13137 | return codegen->invalid_inst_gen->value; |
| 12061 | | 13138 | |
| 12062 | IrExecutable *ir_executable = allocate<IrExecutable>(1, "IrExecutablePass1"); | 13139 | IrExecutableSrc *ir_executable = allocate<IrExecutableSrc>(1, "IrExecutableSrc"); |
| 12063 | ir_executable->source_node = source_node; | 13140 | ir_executable->source_node = source_node; |
| 12064 | ir_executable->parent_exec = parent_exec; | 13141 | ir_executable->parent_exec = parent_exec; |
| 12065 | ir_executable->name = exec_name; | 13142 | ir_executable->name = exec_name; |
| ... | @@ -12069,21 +13146,21 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | ... | @@ -12069,21 +13146,21 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 12069 | ir_executable->begin_scope = scope; | 13146 | ir_executable->begin_scope = scope; |
| 12070 | | 13147 | |
| 12071 | if (!ir_gen(codegen, node, scope, ir_executable)) | 13148 | if (!ir_gen(codegen, node, scope, ir_executable)) |
| 12072 | return codegen->invalid_instruction->value; | 13149 | return codegen->invalid_inst_gen->value; |
| 12073 | | 13150 | |
| 12074 | if (ir_executable->first_err_trace_msg != nullptr) { | 13151 | if (ir_executable->first_err_trace_msg != nullptr) { |
| 12075 | codegen->trace_err = ir_executable->first_err_trace_msg; | 13152 | codegen->trace_err = ir_executable->first_err_trace_msg; |
| 12076 | return codegen->invalid_instruction->value; | 13153 | return codegen->invalid_inst_gen->value; |
| 12077 | } | 13154 | } |
| 12078 | | 13155 | |
| 12079 | if (codegen->verbose_ir) { | 13156 | if (codegen->verbose_ir) { |
| 12080 | fprintf(stderr, "\nSource: "); | 13157 | fprintf(stderr, "\nSource: "); |
| 12081 | ast_render(stderr, node, 4); | 13158 | ast_render(stderr, node, 4); |
| 12082 | fprintf(stderr, "\n{ // (IR)\n"); | 13159 | fprintf(stderr, "\n{ // (IR)\n"); |
| 12083 | ir_print(codegen, stderr, ir_executable, 2, IrPassSrc); | 13160 | ir_print_src(codegen, stderr, ir_executable, 2); |
| 12084 | fprintf(stderr, "}\n"); | 13161 | fprintf(stderr, "}\n"); |
| 12085 | } | 13162 | } |
| 12086 | IrExecutable *analyzed_executable = allocate<IrExecutable>(1, "IrExecutablePass2"); | 13163 | IrExecutableGen *analyzed_executable = allocate<IrExecutableGen>(1, "IrExecutableGen"); |
| 12087 | analyzed_executable->source_node = source_node; | 13164 | analyzed_executable->source_node = source_node; |
| 12088 | analyzed_executable->parent_exec = parent_exec; | 13165 | analyzed_executable->parent_exec = parent_exec; |
| 12089 | analyzed_executable->source_exec = ir_executable; | 13166 | analyzed_executable->source_exec = ir_executable; |
| ... | @@ -12096,31 +13173,31 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, | ... | @@ -12096,31 +13173,31 @@ ZigValue *ir_eval_const_value(CodeGen *codegen, Scope *scope, AstNode *node, |
| 12096 | analyzed_executable->begin_scope = scope; | 13173 | analyzed_executable->begin_scope = scope; |
| 12097 | ZigType *result_type = ir_analyze(codegen, ir_executable, analyzed_executable, expected_type, expected_type_source_node); | 13174 | ZigType *result_type = ir_analyze(codegen, ir_executable, analyzed_executable, expected_type, expected_type_source_node); |
| 12098 | if (type_is_invalid(result_type)) { | 13175 | if (type_is_invalid(result_type)) { |
| 12099 | return codegen->invalid_instruction->value; | 13176 | return codegen->invalid_inst_gen->value; |
| 12100 | } | 13177 | } |
| 12101 | | 13178 | |
| 12102 | if (codegen->verbose_ir) { | 13179 | if (codegen->verbose_ir) { |
| 12103 | fprintf(stderr, "{ // (analyzed)\n"); | 13180 | fprintf(stderr, "{ // (analyzed)\n"); |
| 12104 | ir_print(codegen, stderr, analyzed_executable, 2, IrPassGen); | 13181 | ir_print_gen(codegen, stderr, analyzed_executable, 2); |
| 12105 | fprintf(stderr, "}\n"); | 13182 | fprintf(stderr, "}\n"); |
| 12106 | } | 13183 | } |
| 12107 | | 13184 | |
| 12108 | ZigValue *result = ir_exec_const_result(codegen, analyzed_executable); | 13185 | ZigValue *result = ir_exec_const_result(codegen, analyzed_executable); |
| 12109 | if (type_is_invalid(result->type)) | 13186 | if (type_is_invalid(result->type)) |
| 12110 | return codegen->invalid_instruction->value; | 13187 | return codegen->invalid_inst_gen->value; |
| 12111 | | 13188 | |
| 12112 | if ((err = ir_resolve_const_val(codegen, analyzed_executable, node, result, undef_allowed))) | 13189 | if ((err = ir_resolve_const_val(codegen, analyzed_executable, node, result, undef_allowed))) |
| 12113 | return codegen->invalid_instruction->value; | 13190 | return codegen->invalid_inst_gen->value; |
| 12114 | | 13191 | |
| 12115 | return result; | 13192 | return result; |
| 12116 | } | 13193 | } |
| 12117 | | 13194 | |
| 12118 | static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_value) { | 13195 | static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstGen *err_value) { |
| 12119 | if (type_is_invalid(err_value->value->type)) | 13196 | if (type_is_invalid(err_value->value->type)) |
| 12120 | return nullptr; | 13197 | return nullptr; |
| 12121 | | 13198 | |
| 12122 | if (err_value->value->type->id != ZigTypeIdErrorSet) { | 13199 | if (err_value->value->type->id != ZigTypeIdErrorSet) { |
| 12123 | ir_add_error(ira, err_value, | 13200 | ir_add_error_node(ira, err_value->base.source_node, |
| 12124 | buf_sprintf("expected error, found '%s'", buf_ptr(&err_value->value->type->name))); | 13201 | buf_sprintf("expected error, found '%s'", buf_ptr(&err_value->value->type->name))); |
| 12125 | return nullptr; | 13202 | return nullptr; |
| 12126 | } | 13203 | } |
| ... | @@ -12133,7 +13210,7 @@ static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_valu | ... | @@ -12133,7 +13210,7 @@ static ErrorTableEntry *ir_resolve_error(IrAnalyze *ira, IrInstruction *err_valu |
| 12133 | return const_val->data.x_err_set; | 13210 | return const_val->data.x_err_set; |
| 12134 | } | 13211 | } |
| 12135 | | 13212 | |
| 12136 | static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, | 13213 | static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutableGen *exec, AstNode *source_node, |
| 12137 | ZigValue *val) | 13214 | ZigValue *val) |
| 12138 | { | 13215 | { |
| 12139 | Error err; | 13216 | Error err; |
| ... | @@ -12144,18 +13221,18 @@ static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstN | ... | @@ -12144,18 +13221,18 @@ static ZigType *ir_resolve_const_type(CodeGen *codegen, IrExecutable *exec, AstN |
| 12144 | return val->data.x_type; | 13221 | return val->data.x_type; |
| 12145 | } | 13222 | } |
| 12146 | | 13223 | |
| 12147 | static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_value) { | 13224 | static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstGen *type_value) { |
| 12148 | if (type_is_invalid(type_value->value->type)) | 13225 | if (type_is_invalid(type_value->value->type)) |
| 12149 | return nullptr; | 13226 | return nullptr; |
| 12150 | | 13227 | |
| 12151 | if (type_value->value->type->id != ZigTypeIdMetaType) { | 13228 | if (type_value->value->type->id != ZigTypeIdMetaType) { |
| 12152 | ir_add_error(ira, type_value, | 13229 | ir_add_error_node(ira, type_value->base.source_node, |
| 12153 | buf_sprintf("expected type 'type', found '%s'", buf_ptr(&type_value->value->type->name))); | 13230 | buf_sprintf("expected type 'type', found '%s'", buf_ptr(&type_value->value->type->name))); |
| 12154 | return nullptr; | 13231 | return nullptr; |
| 12155 | } | 13232 | } |
| 12156 | | 13233 | |
| 12157 | Error err; | 13234 | Error err; |
| 12158 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, type_value->source_node, | 13235 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, type_value->base.source_node, |
| 12159 | type_value->value, LazyOk))) | 13236 | type_value->value, LazyOk))) |
| 12160 | { | 13237 | { |
| 12161 | return nullptr; | 13238 | return nullptr; |
| ... | @@ -12164,17 +13241,17 @@ static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_value) | ... | @@ -12164,17 +13241,17 @@ static ZigValue *ir_resolve_type_lazy(IrAnalyze *ira, IrInstruction *type_value) |
| 12164 | return type_value->value; | 13241 | return type_value->value; |
| 12165 | } | 13242 | } |
| 12166 | | 13243 | |
| 12167 | static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstruction *type_value) { | 13244 | static ZigType *ir_resolve_type(IrAnalyze *ira, IrInstGen *type_value) { |
| 12168 | ZigValue *val = ir_resolve_type_lazy(ira, type_value); | 13245 | ZigValue *val = ir_resolve_type_lazy(ira, type_value); |
| 12169 | if (val == nullptr) | 13246 | if (val == nullptr) |
| 12170 | return ira->codegen->builtin_types.entry_invalid; | 13247 | return ira->codegen->builtin_types.entry_invalid; |
| 12171 | | 13248 | |
| 12172 | return ir_resolve_const_type(ira->codegen, ira->new_irb.exec, type_value->source_node, val); | 13249 | return ir_resolve_const_type(ira->codegen, ira->new_irb.exec, type_value->base.source_node, val); |
| 12173 | } | 13250 | } |
| 12174 | | 13251 | |
| 12175 | static Error ir_validate_vector_elem_type(IrAnalyze *ira, IrInstruction *source_instr, ZigType *elem_type) { | 13252 | static Error ir_validate_vector_elem_type(IrAnalyze *ira, AstNode *source_node, ZigType *elem_type) { |
| 12176 | if (!is_valid_vector_elem_type(elem_type)) { | 13253 | if (!is_valid_vector_elem_type(elem_type)) { |
| 12177 | ir_add_error(ira, source_instr, | 13254 | ir_add_error_node(ira, source_node, |
| 12178 | buf_sprintf("vector element type must be integer, float, bool, or pointer; '%s' is invalid", | 13255 | buf_sprintf("vector element type must be integer, float, bool, or pointer; '%s' is invalid", |
| 12179 | buf_ptr(&elem_type->name))); | 13256 | buf_ptr(&elem_type->name))); |
| 12180 | return ErrorSemanticAnalyzeFail; | 13257 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -12182,28 +13259,28 @@ static Error ir_validate_vector_elem_type(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -12182,28 +13259,28 @@ static Error ir_validate_vector_elem_type(IrAnalyze *ira, IrInstruction *source_ |
| 12182 | return ErrorNone; | 13259 | return ErrorNone; |
| 12183 | } | 13260 | } |
| 12184 | | 13261 | |
| 12185 | static ZigType *ir_resolve_vector_elem_type(IrAnalyze *ira, IrInstruction *elem_type_value) { | 13262 | static ZigType *ir_resolve_vector_elem_type(IrAnalyze *ira, IrInstGen *elem_type_value) { |
| 12186 | Error err; | 13263 | Error err; |
| 12187 | ZigType *elem_type = ir_resolve_type(ira, elem_type_value); | 13264 | ZigType *elem_type = ir_resolve_type(ira, elem_type_value); |
| 12188 | if (type_is_invalid(elem_type)) | 13265 | if (type_is_invalid(elem_type)) |
| 12189 | return ira->codegen->builtin_types.entry_invalid; | 13266 | return ira->codegen->builtin_types.entry_invalid; |
| 12190 | if ((err = ir_validate_vector_elem_type(ira, elem_type_value, elem_type))) | 13267 | if ((err = ir_validate_vector_elem_type(ira, elem_type_value->base.source_node, elem_type))) |
| 12191 | return ira->codegen->builtin_types.entry_invalid; | 13268 | return ira->codegen->builtin_types.entry_invalid; |
| 12192 | return elem_type; | 13269 | return elem_type; |
| 12193 | } | 13270 | } |
| 12194 | | 13271 | |
| 12195 | static ZigType *ir_resolve_int_type(IrAnalyze *ira, IrInstruction *type_value) { | 13272 | static ZigType *ir_resolve_int_type(IrAnalyze *ira, IrInstGen *type_value) { |
| 12196 | ZigType *ty = ir_resolve_type(ira, type_value); | 13273 | ZigType *ty = ir_resolve_type(ira, type_value); |
| 12197 | if (type_is_invalid(ty)) | 13274 | if (type_is_invalid(ty)) |
| 12198 | return ira->codegen->builtin_types.entry_invalid; | 13275 | return ira->codegen->builtin_types.entry_invalid; |
| 12199 | | 13276 | |
| 12200 | if (ty->id != ZigTypeIdInt) { | 13277 | if (ty->id != ZigTypeIdInt) { |
| 12201 | ErrorMsg *msg = ir_add_error(ira, type_value, | 13278 | ErrorMsg *msg = ir_add_error_node(ira, type_value->base.source_node, |
| 12202 | buf_sprintf("expected integer type, found '%s'", buf_ptr(&ty->name))); | 13279 | buf_sprintf("expected integer type, found '%s'", buf_ptr(&ty->name))); |
| 12203 | if (ty->id == ZigTypeIdVector && | 13280 | if (ty->id == ZigTypeIdVector && |
| 12204 | ty->data.vector.elem_type->id == ZigTypeIdInt) | 13281 | ty->data.vector.elem_type->id == ZigTypeIdInt) |
| 12205 | { | 13282 | { |
| 12206 | add_error_note(ira->codegen, msg, type_value->source_node, | 13283 | add_error_note(ira->codegen, msg, type_value->base.source_node, |
| 12207 | buf_sprintf("represent vectors with their element types, i.e. '%s'", | 13284 | buf_sprintf("represent vectors with their element types, i.e. '%s'", |
| 12208 | buf_ptr(&ty->data.vector.elem_type->name))); | 13285 | buf_ptr(&ty->data.vector.elem_type->name))); |
| 12209 | } | 13286 | } |
| ... | @@ -12213,12 +13290,12 @@ static ZigType *ir_resolve_int_type(IrAnalyze *ira, IrInstruction *type_value) { | ... | @@ -12213,12 +13290,12 @@ static ZigType *ir_resolve_int_type(IrAnalyze *ira, IrInstruction *type_value) { |
| 12213 | return ty; | 13290 | return ty; |
| 12214 | } | 13291 | } |
| 12215 | | 13292 | |
| 12216 | static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_source, IrInstruction *type_value) { | 13293 | static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInst *op_source, IrInstGen *type_value) { |
| 12217 | if (type_is_invalid(type_value->value->type)) | 13294 | if (type_is_invalid(type_value->value->type)) |
| 12218 | return ira->codegen->builtin_types.entry_invalid; | 13295 | return ira->codegen->builtin_types.entry_invalid; |
| 12219 | | 13296 | |
| 12220 | if (type_value->value->type->id != ZigTypeIdMetaType) { | 13297 | if (type_value->value->type->id != ZigTypeIdMetaType) { |
| 12221 | ErrorMsg *msg = ir_add_error(ira, type_value, | 13298 | ErrorMsg *msg = ir_add_error_node(ira, type_value->base.source_node, |
| 12222 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&type_value->value->type->name))); | 13299 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&type_value->value->type->name))); |
| 12223 | add_error_note(ira->codegen, msg, op_source->source_node, | 13300 | add_error_note(ira->codegen, msg, op_source->source_node, |
| 12224 | buf_sprintf("`||` merges error sets; `or` performs boolean OR")); | 13301 | buf_sprintf("`||` merges error sets; `or` performs boolean OR")); |
| ... | @@ -12232,7 +13309,7 @@ static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_sour | ... | @@ -12232,7 +13309,7 @@ static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_sour |
| 12232 | assert(const_val->data.x_type != nullptr); | 13309 | assert(const_val->data.x_type != nullptr); |
| 12233 | ZigType *result_type = const_val->data.x_type; | 13310 | ZigType *result_type = const_val->data.x_type; |
| 12234 | if (result_type->id != ZigTypeIdErrorSet) { | 13311 | if (result_type->id != ZigTypeIdErrorSet) { |
| 12235 | ErrorMsg *msg = ir_add_error(ira, type_value, | 13312 | ErrorMsg *msg = ir_add_error_node(ira, type_value->base.source_node, |
| 12236 | buf_sprintf("expected error set type, found type '%s'", buf_ptr(&result_type->name))); | 13313 | buf_sprintf("expected error set type, found type '%s'", buf_ptr(&result_type->name))); |
| 12237 | add_error_note(ira->codegen, msg, op_source->source_node, | 13314 | add_error_note(ira->codegen, msg, op_source->source_node, |
| 12238 | buf_sprintf("`||` merges error sets; `or` performs boolean OR")); | 13315 | buf_sprintf("`||` merges error sets; `or` performs boolean OR")); |
| ... | @@ -12241,15 +13318,12 @@ static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_sour | ... | @@ -12241,15 +13318,12 @@ static ZigType *ir_resolve_error_set_type(IrAnalyze *ira, IrInstruction *op_sour |
| 12241 | return result_type; | 13318 | return result_type; |
| 12242 | } | 13319 | } |
| 12243 | | 13320 | |
| 12244 | static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { | 13321 | static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstGen *fn_value) { |
| 12245 | if (fn_value == ira->codegen->invalid_instruction) | | |
| 12246 | return nullptr; | | |
| 12247 | | | |
| 12248 | if (type_is_invalid(fn_value->value->type)) | 13322 | if (type_is_invalid(fn_value->value->type)) |
| 12249 | return nullptr; | 13323 | return nullptr; |
| 12250 | | 13324 | |
| 12251 | if (fn_value->value->type->id != ZigTypeIdFn) { | 13325 | if (fn_value->value->type->id != ZigTypeIdFn) { |
| 12252 | ir_add_error_node(ira, fn_value->source_node, | 13326 | ir_add_error_node(ira, fn_value->base.source_node, |
| 12253 | buf_sprintf("expected function type, found '%s'", buf_ptr(&fn_value->value->type->name))); | 13327 | buf_sprintf("expected function type, found '%s'", buf_ptr(&fn_value->value->type->name))); |
| 12254 | return nullptr; | 13328 | return nullptr; |
| 12255 | } | 13329 | } |
| ... | @@ -12265,22 +13339,22 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { | ... | @@ -12265,22 +13339,22 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { |
| 12265 | return const_val->data.x_ptr.data.fn.fn_entry; | 13339 | return const_val->data.x_ptr.data.fn.fn_entry; |
| 12266 | } | 13340 | } |
| 12267 | | 13341 | |
| 12268 | static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 13342 | static IrInstGen *ir_analyze_optional_wrap(IrAnalyze *ira, IrInst* source_instr, |
| 12269 | ZigType *wanted_type, ResultLoc *result_loc) | 13343 | IrInstGen *value, ZigType *wanted_type, ResultLoc *result_loc) |
| 12270 | { | 13344 | { |
| 12271 | assert(wanted_type->id == ZigTypeIdOptional); | 13345 | assert(wanted_type->id == ZigTypeIdOptional); |
| 12272 | | 13346 | |
| 12273 | if (instr_is_comptime(value)) { | 13347 | if (instr_is_comptime(value)) { |
| 12274 | ZigType *payload_type = wanted_type->data.maybe.child_type; | 13348 | ZigType *payload_type = wanted_type->data.maybe.child_type; |
| 12275 | IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type); | 13349 | IrInstGen *casted_payload = ir_implicit_cast(ira, value, payload_type); |
| 12276 | if (type_is_invalid(casted_payload->value->type)) | 13350 | if (type_is_invalid(casted_payload->value->type)) |
| 12277 | return ira->codegen->invalid_instruction; | 13351 | return ira->codegen->invalid_inst_gen; |
| 12278 | | 13352 | |
| 12279 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefOk); | 13353 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefOk); |
| 12280 | if (!val) | 13354 | if (!val) |
| 12281 | return ira->codegen->invalid_instruction; | 13355 | return ira->codegen->invalid_inst_gen; |
| 12282 | | 13356 | |
| 12283 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 13357 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, |
| 12284 | source_instr->scope, source_instr->source_node); | 13358 | source_instr->scope, source_instr->source_node); |
| 12285 | const_instruction->base.value->special = ConstValSpecialStatic; | 13359 | const_instruction->base.value->special = ConstValSpecialStatic; |
| 12286 | if (types_have_same_zig_comptime_repr(ira->codegen, wanted_type, payload_type)) { | 13360 | if (types_have_same_zig_comptime_repr(ira->codegen, wanted_type, payload_type)) { |
| ... | @@ -12295,40 +13369,42 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so | ... | @@ -12295,40 +13369,42 @@ static IrInstruction *ir_analyze_optional_wrap(IrAnalyze *ira, IrInstruction *so |
| 12295 | if (result_loc == nullptr && handle_is_ptr(wanted_type)) { | 13369 | if (result_loc == nullptr && handle_is_ptr(wanted_type)) { |
| 12296 | result_loc = no_result_loc(); | 13370 | result_loc = no_result_loc(); |
| 12297 | } | 13371 | } |
| 12298 | IrInstruction *result_loc_inst = nullptr; | 13372 | IrInstGen *result_loc_inst = nullptr; |
| 12299 | if (result_loc != nullptr) { | 13373 | if (result_loc != nullptr) { |
| 12300 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true); | 13374 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true); |
| 12301 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { | 13375 | if (type_is_invalid(result_loc_inst->value->type) || |
| | 13376 | result_loc_inst->value->type->id == ZigTypeIdUnreachable) |
| | 13377 | { |
| 12302 | return result_loc_inst; | 13378 | return result_loc_inst; |
| 12303 | } | 13379 | } |
| 12304 | } | 13380 | } |
| 12305 | IrInstruction *result = ir_build_optional_wrap(ira, source_instr, wanted_type, value, result_loc_inst); | 13381 | IrInstGen *result = ir_build_optional_wrap(ira, source_instr, wanted_type, value, result_loc_inst); |
| 12306 | result->value->data.rh_maybe = RuntimeHintOptionalNonNull; | 13382 | result->value->data.rh_maybe = RuntimeHintOptionalNonNull; |
| 12307 | return result; | 13383 | return result; |
| 12308 | } | 13384 | } |
| 12309 | | 13385 | |
| 12310 | static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction *source_instr, | 13386 | static IrInstGen *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInst* source_instr, |
| 12311 | IrInstruction *value, ZigType *wanted_type, ResultLoc *result_loc) | 13387 | IrInstGen *value, ZigType *wanted_type, ResultLoc *result_loc) |
| 12312 | { | 13388 | { |
| 12313 | assert(wanted_type->id == ZigTypeIdErrorUnion); | 13389 | assert(wanted_type->id == ZigTypeIdErrorUnion); |
| 12314 | | 13390 | |
| 12315 | ZigType *payload_type = wanted_type->data.error_union.payload_type; | 13391 | ZigType *payload_type = wanted_type->data.error_union.payload_type; |
| 12316 | ZigType *err_set_type = wanted_type->data.error_union.err_set_type; | 13392 | ZigType *err_set_type = wanted_type->data.error_union.err_set_type; |
| 12317 | if (instr_is_comptime(value)) { | 13393 | if (instr_is_comptime(value)) { |
| 12318 | IrInstruction *casted_payload = ir_implicit_cast(ira, value, payload_type); | 13394 | IrInstGen *casted_payload = ir_implicit_cast(ira, value, payload_type); |
| 12319 | if (type_is_invalid(casted_payload->value->type)) | 13395 | if (type_is_invalid(casted_payload->value->type)) |
| 12320 | return ira->codegen->invalid_instruction; | 13396 | return ira->codegen->invalid_inst_gen; |
| 12321 | | 13397 | |
| 12322 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefBad); | 13398 | ZigValue *val = ir_resolve_const(ira, casted_payload, UndefBad); |
| 12323 | if (!val) | 13399 | if (!val) |
| 12324 | return ira->codegen->invalid_instruction; | 13400 | return ira->codegen->invalid_inst_gen; |
| 12325 | | 13401 | |
| 12326 | ZigValue *err_set_val = create_const_vals(1); | 13402 | ZigValue *err_set_val = create_const_vals(1); |
| 12327 | err_set_val->type = err_set_type; | 13403 | err_set_val->type = err_set_type; |
| 12328 | err_set_val->special = ConstValSpecialStatic; | 13404 | err_set_val->special = ConstValSpecialStatic; |
| 12329 | err_set_val->data.x_err_set = nullptr; | 13405 | err_set_val->data.x_err_set = nullptr; |
| 12330 | | 13406 | |
| 12331 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 13407 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, |
| 12332 | source_instr->scope, source_instr->source_node); | 13408 | source_instr->scope, source_instr->source_node); |
| 12333 | const_instruction->base.value->type = wanted_type; | 13409 | const_instruction->base.value->type = wanted_type; |
| 12334 | const_instruction->base.value->special = ConstValSpecialStatic; | 13410 | const_instruction->base.value->special = ConstValSpecialStatic; |
| ... | @@ -12337,23 +13413,24 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction | ... | @@ -12337,23 +13413,24 @@ static IrInstruction *ir_analyze_err_wrap_payload(IrAnalyze *ira, IrInstruction |
| 12337 | return &const_instruction->base; | 13413 | return &const_instruction->base; |
| 12338 | } | 13414 | } |
| 12339 | | 13415 | |
| 12340 | IrInstruction *result_loc_inst; | 13416 | IrInstGen *result_loc_inst; |
| 12341 | if (handle_is_ptr(wanted_type)) { | 13417 | if (handle_is_ptr(wanted_type)) { |
| 12342 | if (result_loc == nullptr) result_loc = no_result_loc(); | 13418 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 12343 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true); | 13419 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true); |
| 12344 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { | 13420 | if (type_is_invalid(result_loc_inst->value->type) || |
| | 13421 | result_loc_inst->value->type->id == ZigTypeIdUnreachable) { |
| 12345 | return result_loc_inst; | 13422 | return result_loc_inst; |
| 12346 | } | 13423 | } |
| 12347 | } else { | 13424 | } else { |
| 12348 | result_loc_inst = nullptr; | 13425 | result_loc_inst = nullptr; |
| 12349 | } | 13426 | } |
| 12350 | | 13427 | |
| 12351 | IrInstruction *result = ir_build_err_wrap_payload(ira, source_instr, wanted_type, value, result_loc_inst); | 13428 | IrInstGen *result = ir_build_err_wrap_payload(ira, source_instr, wanted_type, value, result_loc_inst); |
| 12352 | result->value->data.rh_error_union = RuntimeHintErrorUnionNonError; | 13429 | result->value->data.rh_error_union = RuntimeHintErrorUnionNonError; |
| 12353 | return result; | 13430 | return result; |
| 12354 | } | 13431 | } |
| 12355 | | 13432 | |
| 12356 | static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 13433 | static IrInstGen *ir_analyze_err_set_cast(IrAnalyze *ira, IrInst* source_instr, IrInstGen *value, |
| 12357 | ZigType *wanted_type) | 13434 | ZigType *wanted_type) |
| 12358 | { | 13435 | { |
| 12359 | assert(value->value->type->id == ZigTypeIdErrorSet); | 13436 | assert(value->value->type->id == ZigTypeIdErrorSet); |
| ... | @@ -12362,10 +13439,10 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12362,10 +13439,10 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou |
| 12362 | if (instr_is_comptime(value)) { | 13439 | if (instr_is_comptime(value)) { |
| 12363 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); | 13440 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 12364 | if (!val) | 13441 | if (!val) |
| 12365 | return ira->codegen->invalid_instruction; | 13442 | return ira->codegen->invalid_inst_gen; |
| 12366 | | 13443 | |
| 12367 | if (!resolve_inferred_error_set(ira->codegen, wanted_type, source_instr->source_node)) { | 13444 | if (!resolve_inferred_error_set(ira->codegen, wanted_type, source_instr->source_node)) { |
| 12368 | return ira->codegen->invalid_instruction; | 13445 | return ira->codegen->invalid_inst_gen; |
| 12369 | } | 13446 | } |
| 12370 | if (!type_is_global_error_set(wanted_type)) { | 13447 | if (!type_is_global_error_set(wanted_type)) { |
| 12371 | bool subset = false; | 13448 | bool subset = false; |
| ... | @@ -12379,11 +13456,11 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12379,11 +13456,11 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou |
| 12379 | ir_add_error(ira, source_instr, | 13456 | ir_add_error(ira, source_instr, |
| 12380 | buf_sprintf("error.%s not a member of error set '%s'", | 13457 | buf_sprintf("error.%s not a member of error set '%s'", |
| 12381 | buf_ptr(&val->data.x_err_set->name), buf_ptr(&wanted_type->name))); | 13458 | buf_ptr(&val->data.x_err_set->name), buf_ptr(&wanted_type->name))); |
| 12382 | return ira->codegen->invalid_instruction; | 13459 | return ira->codegen->invalid_inst_gen; |
| 12383 | } | 13460 | } |
| 12384 | } | 13461 | } |
| 12385 | | 13462 | |
| 12386 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 13463 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, |
| 12387 | source_instr->scope, source_instr->source_node); | 13464 | source_instr->scope, source_instr->source_node); |
| 12388 | const_instruction->base.value->type = wanted_type; | 13465 | const_instruction->base.value->type = wanted_type; |
| 12389 | const_instruction->base.value->special = ConstValSpecialStatic; | 13466 | const_instruction->base.value->special = ConstValSpecialStatic; |
| ... | @@ -12391,18 +13468,16 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12391,18 +13468,16 @@ static IrInstruction *ir_analyze_err_set_cast(IrAnalyze *ira, IrInstruction *sou |
| 12391 | return &const_instruction->base; | 13468 | return &const_instruction->base; |
| 12392 | } | 13469 | } |
| 12393 | | 13470 | |
| 12394 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, wanted_type, value, CastOpErrSet); | 13471 | return ir_build_cast(ira, source_instr, wanted_type, value, CastOpErrSet); |
| 12395 | result->value->type = wanted_type; | | |
| 12396 | return result; | | |
| 12397 | } | 13472 | } |
| 12398 | | 13473 | |
| 12399 | static IrInstruction *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInstruction *source_instr, | 13474 | static IrInstGen *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInst* source_instr, |
| 12400 | IrInstruction *frame_ptr, ZigType *wanted_type) | 13475 | IrInstGen *frame_ptr, ZigType *wanted_type) |
| 12401 | { | 13476 | { |
| 12402 | if (instr_is_comptime(frame_ptr)) { | 13477 | if (instr_is_comptime(frame_ptr)) { |
| 12403 | ZigValue *ptr_val = ir_resolve_const(ira, frame_ptr, UndefBad); | 13478 | ZigValue *ptr_val = ir_resolve_const(ira, frame_ptr, UndefBad); |
| 12404 | if (ptr_val == nullptr) | 13479 | if (ptr_val == nullptr) |
| 12405 | return ira->codegen->invalid_instruction; | 13480 | return ira->codegen->invalid_inst_gen; |
| 12406 | | 13481 | |
| 12407 | ir_assert(ptr_val->type->id == ZigTypeIdPointer, source_instr); | 13482 | ir_assert(ptr_val->type->id == ZigTypeIdPointer, source_instr); |
| 12408 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 13483 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| ... | @@ -12410,44 +13485,38 @@ static IrInstruction *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInstruc | ... | @@ -12410,44 +13485,38 @@ static IrInstruction *ir_analyze_frame_ptr_to_anyframe(IrAnalyze *ira, IrInstruc |
| 12410 | } | 13485 | } |
| 12411 | } | 13486 | } |
| 12412 | | 13487 | |
| 12413 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, | 13488 | return ir_build_cast(ira, source_instr, wanted_type, frame_ptr, CastOpBitCast); |
| 12414 | wanted_type, frame_ptr, CastOpBitCast); | | |
| 12415 | result->value->type = wanted_type; | | |
| 12416 | return result; | | |
| 12417 | } | 13489 | } |
| 12418 | | 13490 | |
| 12419 | static IrInstruction *ir_analyze_anyframe_to_anyframe(IrAnalyze *ira, IrInstruction *source_instr, | 13491 | static IrInstGen *ir_analyze_anyframe_to_anyframe(IrAnalyze *ira, IrInst* source_instr, |
| 12420 | IrInstruction *value, ZigType *wanted_type) | 13492 | IrInstGen *value, ZigType *wanted_type) |
| 12421 | { | 13493 | { |
| 12422 | if (instr_is_comptime(value)) { | 13494 | if (instr_is_comptime(value)) { |
| 12423 | zig_panic("TODO comptime anyframe->T to anyframe"); | 13495 | zig_panic("TODO comptime anyframe->T to anyframe"); |
| 12424 | } | 13496 | } |
| 12425 | | 13497 | |
| 12426 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, source_instr->source_node, | 13498 | return ir_build_cast(ira, source_instr, wanted_type, value, CastOpBitCast); |
| 12427 | wanted_type, value, CastOpBitCast); | | |
| 12428 | result->value->type = wanted_type; | | |
| 12429 | return result; | | |
| 12430 | } | 13499 | } |
| 12431 | | 13500 | |
| 12432 | | 13501 | |
| 12433 | static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 13502 | static IrInstGen *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInst* source_instr, IrInstGen *value, |
| 12434 | ZigType *wanted_type, ResultLoc *result_loc) | 13503 | ZigType *wanted_type, ResultLoc *result_loc) |
| 12435 | { | 13504 | { |
| 12436 | assert(wanted_type->id == ZigTypeIdErrorUnion); | 13505 | assert(wanted_type->id == ZigTypeIdErrorUnion); |
| 12437 | | 13506 | |
| 12438 | IrInstruction *casted_value = ir_implicit_cast(ira, value, wanted_type->data.error_union.err_set_type); | 13507 | IrInstGen *casted_value = ir_implicit_cast(ira, value, wanted_type->data.error_union.err_set_type); |
| 12439 | | 13508 | |
| 12440 | if (instr_is_comptime(casted_value)) { | 13509 | if (instr_is_comptime(casted_value)) { |
| 12441 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); | 13510 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); |
| 12442 | if (!val) | 13511 | if (!val) |
| 12443 | return ira->codegen->invalid_instruction; | 13512 | return ira->codegen->invalid_inst_gen; |
| 12444 | | 13513 | |
| 12445 | ZigValue *err_set_val = create_const_vals(1); | 13514 | ZigValue *err_set_val = create_const_vals(1); |
| 12446 | err_set_val->special = ConstValSpecialStatic; | 13515 | err_set_val->special = ConstValSpecialStatic; |
| 12447 | err_set_val->type = wanted_type->data.error_union.err_set_type; | 13516 | err_set_val->type = wanted_type->data.error_union.err_set_type; |
| 12448 | err_set_val->data.x_err_set = val->data.x_err_set; | 13517 | err_set_val->data.x_err_set = val->data.x_err_set; |
| 12449 | | 13518 | |
| 12450 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 13519 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, |
| 12451 | source_instr->scope, source_instr->source_node); | 13520 | source_instr->scope, source_instr->source_node); |
| 12452 | const_instruction->base.value->type = wanted_type; | 13521 | const_instruction->base.value->type = wanted_type; |
| 12453 | const_instruction->base.value->special = ConstValSpecialStatic; | 13522 | const_instruction->base.value->special = ConstValSpecialStatic; |
| ... | @@ -12456,11 +13525,13 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so | ... | @@ -12456,11 +13525,13 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so |
| 12456 | return &const_instruction->base; | 13525 | return &const_instruction->base; |
| 12457 | } | 13526 | } |
| 12458 | | 13527 | |
| 12459 | IrInstruction *result_loc_inst; | 13528 | IrInstGen *result_loc_inst; |
| 12460 | if (handle_is_ptr(wanted_type)) { | 13529 | if (handle_is_ptr(wanted_type)) { |
| 12461 | if (result_loc == nullptr) result_loc = no_result_loc(); | 13530 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 12462 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true); | 13531 | result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, wanted_type, nullptr, true, false, true); |
| 12463 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { | 13532 | if (type_is_invalid(result_loc_inst->value->type) || |
| | 13533 | result_loc_inst->value->type->id == ZigTypeIdUnreachable) |
| | 13534 | { |
| 12464 | return result_loc_inst; | 13535 | return result_loc_inst; |
| 12465 | } | 13536 | } |
| 12466 | } else { | 13537 | } else { |
| ... | @@ -12468,19 +13539,19 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so | ... | @@ -12468,19 +13539,19 @@ static IrInstruction *ir_analyze_err_wrap_code(IrAnalyze *ira, IrInstruction *so |
| 12468 | } | 13539 | } |
| 12469 | | 13540 | |
| 12470 | | 13541 | |
| 12471 | IrInstruction *result = ir_build_err_wrap_code(ira, source_instr, wanted_type, value, result_loc_inst); | 13542 | IrInstGen *result = ir_build_err_wrap_code(ira, source_instr, wanted_type, value, result_loc_inst); |
| 12472 | result->value->data.rh_error_union = RuntimeHintErrorUnionError; | 13543 | result->value->data.rh_error_union = RuntimeHintErrorUnionError; |
| 12473 | return result; | 13544 | return result; |
| 12474 | } | 13545 | } |
| 12475 | | 13546 | |
| 12476 | static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, ZigType *wanted_type) { | 13547 | static IrInstGen *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInst *source_instr, IrInstGen *value, ZigType *wanted_type) { |
| 12477 | assert(wanted_type->id == ZigTypeIdOptional); | 13548 | assert(wanted_type->id == ZigTypeIdOptional); |
| 12478 | assert(instr_is_comptime(value)); | 13549 | assert(instr_is_comptime(value)); |
| 12479 | | 13550 | |
| 12480 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); | 13551 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 12481 | assert(val != nullptr); | 13552 | assert(val != nullptr); |
| 12482 | | 13553 | |
| 12483 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13554 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12484 | result->value->special = ConstValSpecialStatic; | 13555 | result->value->special = ConstValSpecialStatic; |
| 12485 | if (get_codegen_ptr_type(wanted_type) != nullptr) { | 13556 | if (get_codegen_ptr_type(wanted_type) != nullptr) { |
| 12486 | result->value->data.x_ptr.special = ConstPtrSpecialNull; | 13557 | result->value->data.x_ptr.special = ConstPtrSpecialNull; |
| ... | @@ -12492,8 +13563,8 @@ static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *so | ... | @@ -12492,8 +13563,8 @@ static IrInstruction *ir_analyze_null_to_maybe(IrAnalyze *ira, IrInstruction *so |
| 12492 | return result; | 13563 | return result; |
| 12493 | } | 13564 | } |
| 12494 | | 13565 | |
| 12495 | static IrInstruction *ir_analyze_null_to_c_pointer(IrAnalyze *ira, IrInstruction *source_instr, | 13566 | static IrInstGen *ir_analyze_null_to_c_pointer(IrAnalyze *ira, IrInst *source_instr, |
| 12496 | IrInstruction *value, ZigType *wanted_type) | 13567 | IrInstGen *value, ZigType *wanted_type) |
| 12497 | { | 13568 | { |
| 12498 | assert(wanted_type->id == ZigTypeIdPointer); | 13569 | assert(wanted_type->id == ZigTypeIdPointer); |
| 12499 | assert(wanted_type->data.pointer.ptr_len == PtrLenC); | 13570 | assert(wanted_type->data.pointer.ptr_len == PtrLenC); |
| ... | @@ -12502,24 +13573,24 @@ static IrInstruction *ir_analyze_null_to_c_pointer(IrAnalyze *ira, IrInstruction | ... | @@ -12502,24 +13573,24 @@ static IrInstruction *ir_analyze_null_to_c_pointer(IrAnalyze *ira, IrInstruction |
| 12502 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); | 13573 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 12503 | assert(val != nullptr); | 13574 | assert(val != nullptr); |
| 12504 | | 13575 | |
| 12505 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13576 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12506 | result->value->data.x_ptr.special = ConstPtrSpecialNull; | 13577 | result->value->data.x_ptr.special = ConstPtrSpecialNull; |
| 12507 | result->value->data.x_ptr.mut = ConstPtrMutComptimeConst; | 13578 | result->value->data.x_ptr.mut = ConstPtrMutComptimeConst; |
| 12508 | return result; | 13579 | return result; |
| 12509 | } | 13580 | } |
| 12510 | | 13581 | |
| 12511 | static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *value, | 13582 | static IrInstGen *ir_get_ref(IrAnalyze *ira, IrInst* source_instruction, IrInstGen *value, |
| 12512 | bool is_const, bool is_volatile) | 13583 | bool is_const, bool is_volatile) |
| 12513 | { | 13584 | { |
| 12514 | Error err; | 13585 | Error err; |
| 12515 | | 13586 | |
| 12516 | if (type_is_invalid(value->value->type)) | 13587 | if (type_is_invalid(value->value->type)) |
| 12517 | return ira->codegen->invalid_instruction; | 13588 | return ira->codegen->invalid_inst_gen; |
| 12518 | | 13589 | |
| 12519 | if (instr_is_comptime(value)) { | 13590 | if (instr_is_comptime(value)) { |
| 12520 | ZigValue *val = ir_resolve_const(ira, value, LazyOk); | 13591 | ZigValue *val = ir_resolve_const(ira, value, LazyOk); |
| 12521 | if (!val) | 13592 | if (!val) |
| 12522 | return ira->codegen->invalid_instruction; | 13593 | return ira->codegen->invalid_inst_gen; |
| 12523 | return ir_get_const_ptr(ira, source_instruction, val, value->value->type, | 13594 | return ir_get_const_ptr(ira, source_instruction, val, value->value->type, |
| 12524 | ConstPtrMutComptimeConst, is_const, is_volatile, 0); | 13595 | ConstPtrMutComptimeConst, is_const, is_volatile, 0); |
| 12525 | } | 13596 | } |
| ... | @@ -12528,9 +13599,9 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi | ... | @@ -12528,9 +13599,9 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi |
| 12528 | is_const, is_volatile, PtrLenSingle, 0, 0, 0, false); | 13599 | is_const, is_volatile, PtrLenSingle, 0, 0, 0, false); |
| 12529 | | 13600 | |
| 12530 | if ((err = type_resolve(ira->codegen, ptr_type, ResolveStatusZeroBitsKnown))) | 13601 | if ((err = type_resolve(ira->codegen, ptr_type, ResolveStatusZeroBitsKnown))) |
| 12531 | return ira->codegen->invalid_instruction; | 13602 | return ira->codegen->invalid_inst_gen; |
| 12532 | | 13603 | |
| 12533 | IrInstruction *result_loc; | 13604 | IrInstGen *result_loc; |
| 12534 | if (type_has_bits(ptr_type) && !handle_is_ptr(value->value->type)) { | 13605 | if (type_has_bits(ptr_type) && !handle_is_ptr(value->value->type)) { |
| 12535 | result_loc = ir_resolve_result(ira, source_instruction, no_result_loc(), value->value->type, nullptr, true, | 13606 | result_loc = ir_resolve_result(ira, source_instruction, no_result_loc(), value->value->type, nullptr, true, |
| 12536 | false, true); | 13607 | false, true); |
| ... | @@ -12538,12 +13609,12 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi | ... | @@ -12538,12 +13609,12 @@ static IrInstruction *ir_get_ref(IrAnalyze *ira, IrInstruction *source_instructi |
| 12538 | result_loc = nullptr; | 13609 | result_loc = nullptr; |
| 12539 | } | 13610 | } |
| 12540 | | 13611 | |
| 12541 | IrInstruction *new_instruction = ir_build_ref_gen(ira, source_instruction, ptr_type, value, result_loc); | 13612 | IrInstGen *new_instruction = ir_build_ref_gen(ira, source_instruction, ptr_type, value, result_loc); |
| 12542 | new_instruction->value->data.rh_ptr = RuntimeHintPtrStack; | 13613 | new_instruction->value->data.rh_ptr = RuntimeHintPtrStack; |
| 12543 | return new_instruction; | 13614 | return new_instruction; |
| 12544 | } | 13615 | } |
| 12545 | | 13616 | |
| 12546 | static ZigType *ir_resolve_union_tag_type(IrAnalyze *ira, IrInstruction *source_instr, ZigType *union_type) { | 13617 | static ZigType *ir_resolve_union_tag_type(IrAnalyze *ira, AstNode *source_node, ZigType *union_type) { |
| 12547 | assert(union_type->id == ZigTypeIdUnion); | 13618 | assert(union_type->id == ZigTypeIdUnion); |
| 12548 | | 13619 | |
| 12549 | Error err; | 13620 | Error err; |
| ... | @@ -12555,36 +13626,36 @@ static ZigType *ir_resolve_union_tag_type(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -12555,36 +13626,36 @@ static ZigType *ir_resolve_union_tag_type(IrAnalyze *ira, IrInstruction *source_ |
| 12555 | assert(union_type->data.unionation.tag_type != nullptr); | 13626 | assert(union_type->data.unionation.tag_type != nullptr); |
| 12556 | return union_type->data.unionation.tag_type; | 13627 | return union_type->data.unionation.tag_type; |
| 12557 | } else { | 13628 | } else { |
| 12558 | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("union '%s' has no tag", | 13629 | ErrorMsg *msg = ir_add_error_node(ira, source_node, buf_sprintf("union '%s' has no tag", |
| 12559 | buf_ptr(&union_type->name))); | 13630 | buf_ptr(&union_type->name))); |
| 12560 | add_error_note(ira->codegen, msg, decl_node, buf_sprintf("consider 'union(enum)' here")); | 13631 | add_error_note(ira->codegen, msg, decl_node, buf_sprintf("consider 'union(enum)' here")); |
| 12561 | return ira->codegen->builtin_types.entry_invalid; | 13632 | return ira->codegen->builtin_types.entry_invalid; |
| 12562 | } | 13633 | } |
| 12563 | } | 13634 | } |
| 12564 | | 13635 | |
| 12565 | static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target) { | 13636 | static IrInstGen *ir_analyze_enum_to_int(IrAnalyze *ira, IrInst *source_instr, IrInstGen *target) { |
| 12566 | Error err; | 13637 | Error err; |
| 12567 | | 13638 | |
| 12568 | IrInstruction *enum_target; | 13639 | IrInstGen *enum_target; |
| 12569 | ZigType *enum_type; | 13640 | ZigType *enum_type; |
| 12570 | if (target->value->type->id == ZigTypeIdUnion) { | 13641 | if (target->value->type->id == ZigTypeIdUnion) { |
| 12571 | enum_type = ir_resolve_union_tag_type(ira, target, target->value->type); | 13642 | enum_type = ir_resolve_union_tag_type(ira, target->base.source_node, target->value->type); |
| 12572 | if (type_is_invalid(enum_type)) | 13643 | if (type_is_invalid(enum_type)) |
| 12573 | return ira->codegen->invalid_instruction; | 13644 | return ira->codegen->invalid_inst_gen; |
| 12574 | enum_target = ir_implicit_cast(ira, target, enum_type); | 13645 | enum_target = ir_implicit_cast(ira, target, enum_type); |
| 12575 | if (type_is_invalid(enum_target->value->type)) | 13646 | if (type_is_invalid(enum_target->value->type)) |
| 12576 | return ira->codegen->invalid_instruction; | 13647 | return ira->codegen->invalid_inst_gen; |
| 12577 | } else if (target->value->type->id == ZigTypeIdEnum) { | 13648 | } else if (target->value->type->id == ZigTypeIdEnum) { |
| 12578 | enum_target = target; | 13649 | enum_target = target; |
| 12579 | enum_type = target->value->type; | 13650 | enum_type = target->value->type; |
| 12580 | } else { | 13651 | } else { |
| 12581 | ir_add_error(ira, target, | 13652 | ir_add_error_node(ira, target->base.source_node, |
| 12582 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&target->value->type->name))); | 13653 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&target->value->type->name))); |
| 12583 | return ira->codegen->invalid_instruction; | 13654 | return ira->codegen->invalid_inst_gen; |
| 12584 | } | 13655 | } |
| 12585 | | 13656 | |
| 12586 | if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusSizeKnown))) | 13657 | if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusSizeKnown))) |
| 12587 | return ira->codegen->invalid_instruction; | 13658 | return ira->codegen->invalid_inst_gen; |
| 12588 | | 13659 | |
| 12589 | ZigType *tag_type = enum_type->data.enumeration.tag_int_type; | 13660 | ZigType *tag_type = enum_type->data.enumeration.tag_int_type; |
| 12590 | assert(tag_type->id == ZigTypeIdInt || tag_type->id == ZigTypeIdComptimeInt); | 13661 | assert(tag_type->id == ZigTypeIdInt || tag_type->id == ZigTypeIdComptimeInt); |
| ... | @@ -12593,7 +13664,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12593,7 +13664,7 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 12593 | if (enum_type->data.enumeration.layout == ContainerLayoutAuto && | 13664 | if (enum_type->data.enumeration.layout == ContainerLayoutAuto && |
| 12594 | enum_type->data.enumeration.src_field_count == 1) | 13665 | enum_type->data.enumeration.src_field_count == 1) |
| 12595 | { | 13666 | { |
| 12596 | IrInstruction *result = ir_const(ira, source_instr, tag_type); | 13667 | IrInstGen *result = ir_const(ira, source_instr, tag_type); |
| 12597 | init_const_bigint(result->value, tag_type, | 13668 | init_const_bigint(result->value, tag_type, |
| 12598 | &enum_type->data.enumeration.fields[0].value); | 13669 | &enum_type->data.enumeration.fields[0].value); |
| 12599 | return result; | 13670 | return result; |
| ... | @@ -12602,20 +13673,17 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12602,20 +13673,17 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 12602 | if (instr_is_comptime(enum_target)) { | 13673 | if (instr_is_comptime(enum_target)) { |
| 12603 | ZigValue *val = ir_resolve_const(ira, enum_target, UndefBad); | 13674 | ZigValue *val = ir_resolve_const(ira, enum_target, UndefBad); |
| 12604 | if (!val) | 13675 | if (!val) |
| 12605 | return ira->codegen->invalid_instruction; | 13676 | return ira->codegen->invalid_inst_gen; |
| 12606 | IrInstruction *result = ir_const(ira, source_instr, tag_type); | 13677 | IrInstGen *result = ir_const(ira, source_instr, tag_type); |
| 12607 | init_const_bigint(result->value, tag_type, &val->data.x_enum_tag); | 13678 | init_const_bigint(result->value, tag_type, &val->data.x_enum_tag); |
| 12608 | return result; | 13679 | return result; |
| 12609 | } | 13680 | } |
| 12610 | | 13681 | |
| 12611 | IrInstruction *result = ir_build_widen_or_shorten(&ira->new_irb, source_instr->scope, | 13682 | return ir_build_widen_or_shorten(ira, source_instr->scope, source_instr->source_node, enum_target, tag_type); |
| 12612 | source_instr->source_node, enum_target); | | |
| 12613 | result->value->type = tag_type; | | |
| 12614 | return result; | | |
| 12615 | } | 13683 | } |
| 12616 | | 13684 | |
| 12617 | static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *source_instr, | 13685 | static IrInstGen *ir_analyze_union_to_tag(IrAnalyze *ira, IrInst* source_instr, |
| 12618 | IrInstruction *target, ZigType *wanted_type) | 13686 | IrInstGen *target, ZigType *wanted_type) |
| 12619 | { | 13687 | { |
| 12620 | assert(target->value->type->id == ZigTypeIdUnion); | 13688 | assert(target->value->type->id == ZigTypeIdUnion); |
| 12621 | assert(wanted_type->id == ZigTypeIdEnum); | 13689 | assert(wanted_type->id == ZigTypeIdEnum); |
| ... | @@ -12624,8 +13692,8 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12624,8 +13692,8 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou |
| 12624 | if (instr_is_comptime(target)) { | 13692 | if (instr_is_comptime(target)) { |
| 12625 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 13693 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12626 | if (!val) | 13694 | if (!val) |
| 12627 | return ira->codegen->invalid_instruction; | 13695 | return ira->codegen->invalid_inst_gen; |
| 12628 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13696 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12629 | result->value->special = ConstValSpecialStatic; | 13697 | result->value->special = ConstValSpecialStatic; |
| 12630 | result->value->type = wanted_type; | 13698 | result->value->type = wanted_type; |
| 12631 | bigint_init_bigint(&result->value->data.x_enum_tag, &val->data.x_union.tag); | 13699 | bigint_init_bigint(&result->value->data.x_enum_tag, &val->data.x_union.tag); |
| ... | @@ -12636,7 +13704,7 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12636,7 +13704,7 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou |
| 12636 | if (wanted_type->data.enumeration.layout == ContainerLayoutAuto && | 13704 | if (wanted_type->data.enumeration.layout == ContainerLayoutAuto && |
| 12637 | wanted_type->data.enumeration.src_field_count == 1) | 13705 | wanted_type->data.enumeration.src_field_count == 1) |
| 12638 | { | 13706 | { |
| 12639 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13707 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12640 | result->value->special = ConstValSpecialStatic; | 13708 | result->value->special = ConstValSpecialStatic; |
| 12641 | result->value->type = wanted_type; | 13709 | result->value->type = wanted_type; |
| 12642 | TypeEnumField *enum_field = target->value->type->data.unionation.fields[0].enum_field; | 13710 | TypeEnumField *enum_field = target->value->type->data.unionation.fields[0].enum_field; |
| ... | @@ -12644,48 +13712,45 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou | ... | @@ -12644,48 +13712,45 @@ static IrInstruction *ir_analyze_union_to_tag(IrAnalyze *ira, IrInstruction *sou |
| 12644 | return result; | 13712 | return result; |
| 12645 | } | 13713 | } |
| 12646 | | 13714 | |
| 12647 | IrInstruction *result = ir_build_union_tag(&ira->new_irb, source_instr->scope, | 13715 | return ir_build_union_tag(ira, source_instr, target, wanted_type); |
| 12648 | source_instr->source_node, target); | | |
| 12649 | result->value->type = wanted_type; | | |
| 12650 | return result; | | |
| 12651 | } | 13716 | } |
| 12652 | | 13717 | |
| 12653 | static IrInstruction *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInstruction *source_instr, | 13718 | static IrInstGen *ir_analyze_undefined_to_anything(IrAnalyze *ira, IrInst* source_instr, |
| 12654 | IrInstruction *target, ZigType *wanted_type) | 13719 | IrInstGen *target, ZigType *wanted_type) |
| 12655 | { | 13720 | { |
| 12656 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13721 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12657 | result->value->special = ConstValSpecialUndef; | 13722 | result->value->special = ConstValSpecialUndef; |
| 12658 | return result; | 13723 | return result; |
| 12659 | } | 13724 | } |
| 12660 | | 13725 | |
| 12661 | static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *source_instr, | 13726 | static IrInstGen *ir_analyze_enum_to_union(IrAnalyze *ira, IrInst* source_instr, |
| 12662 | IrInstruction *uncasted_target, ZigType *wanted_type) | 13727 | IrInstGen *uncasted_target, ZigType *wanted_type) |
| 12663 | { | 13728 | { |
| 12664 | Error err; | 13729 | Error err; |
| 12665 | assert(wanted_type->id == ZigTypeIdUnion); | 13730 | assert(wanted_type->id == ZigTypeIdUnion); |
| 12666 | | 13731 | |
| 12667 | if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusZeroBitsKnown))) | 13732 | if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusZeroBitsKnown))) |
| 12668 | return ira->codegen->invalid_instruction; | 13733 | return ira->codegen->invalid_inst_gen; |
| 12669 | | 13734 | |
| 12670 | IrInstruction *target = ir_implicit_cast(ira, uncasted_target, wanted_type->data.unionation.tag_type); | 13735 | IrInstGen *target = ir_implicit_cast(ira, uncasted_target, wanted_type->data.unionation.tag_type); |
| 12671 | if (type_is_invalid(target->value->type)) | 13736 | if (type_is_invalid(target->value->type)) |
| 12672 | return ira->codegen->invalid_instruction; | 13737 | return ira->codegen->invalid_inst_gen; |
| 12673 | | 13738 | |
| 12674 | if (instr_is_comptime(target)) { | 13739 | if (instr_is_comptime(target)) { |
| 12675 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 13740 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12676 | if (!val) | 13741 | if (!val) |
| 12677 | return ira->codegen->invalid_instruction; | 13742 | return ira->codegen->invalid_inst_gen; |
| 12678 | TypeUnionField *union_field = find_union_field_by_tag(wanted_type, &val->data.x_enum_tag); | 13743 | TypeUnionField *union_field = find_union_field_by_tag(wanted_type, &val->data.x_enum_tag); |
| 12679 | assert(union_field != nullptr); | 13744 | assert(union_field != nullptr); |
| 12680 | ZigType *field_type = resolve_union_field_type(ira->codegen, union_field); | 13745 | ZigType *field_type = resolve_union_field_type(ira->codegen, union_field); |
| 12681 | if (field_type == nullptr) | 13746 | if (field_type == nullptr) |
| 12682 | return ira->codegen->invalid_instruction; | 13747 | return ira->codegen->invalid_inst_gen; |
| 12683 | if ((err = type_resolve(ira->codegen, field_type, ResolveStatusZeroBitsKnown))) | 13748 | if ((err = type_resolve(ira->codegen, field_type, ResolveStatusZeroBitsKnown))) |
| 12684 | return ira->codegen->invalid_instruction; | 13749 | return ira->codegen->invalid_inst_gen; |
| 12685 | | 13750 | |
| 12686 | switch (type_has_one_possible_value(ira->codegen, field_type)) { | 13751 | switch (type_has_one_possible_value(ira->codegen, field_type)) { |
| 12687 | case OnePossibleValueInvalid: | 13752 | case OnePossibleValueInvalid: |
| 12688 | return ira->codegen->invalid_instruction; | 13753 | return ira->codegen->invalid_inst_gen; |
| 12689 | case OnePossibleValueNo: { | 13754 | case OnePossibleValueNo: { |
| 12690 | AstNode *field_node = wanted_type->data.unionation.decl_node->data.container_decl.fields.at( | 13755 | AstNode *field_node = wanted_type->data.unionation.decl_node->data.container_decl.fields.at( |
| 12691 | union_field->enum_field->decl_index); | 13756 | union_field->enum_field->decl_index); |
| ... | @@ -12696,13 +13761,13 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -12696,13 +13761,13 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 12696 | buf_ptr(union_field->name))); | 13761 | buf_ptr(union_field->name))); |
| 12697 | add_error_note(ira->codegen, msg, field_node, | 13762 | add_error_note(ira->codegen, msg, field_node, |
| 12698 | buf_sprintf("field '%s' declared here", buf_ptr(union_field->name))); | 13763 | buf_sprintf("field '%s' declared here", buf_ptr(union_field->name))); |
| 12699 | return ira->codegen->invalid_instruction; | 13764 | return ira->codegen->invalid_inst_gen; |
| 12700 | } | 13765 | } |
| 12701 | case OnePossibleValueYes: | 13766 | case OnePossibleValueYes: |
| 12702 | break; | 13767 | break; |
| 12703 | } | 13768 | } |
| 12704 | | 13769 | |
| 12705 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13770 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12706 | result->value->special = ConstValSpecialStatic; | 13771 | result->value->special = ConstValSpecialStatic; |
| 12707 | result->value->type = wanted_type; | 13772 | result->value->type = wanted_type; |
| 12708 | bigint_init_bigint(&result->value->data.x_union.tag, &val->data.x_enum_tag); | 13773 | bigint_init_bigint(&result->value->data.x_union.tag, &val->data.x_enum_tag); |
| ... | @@ -12715,9 +13780,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -12715,9 +13780,7 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 12715 | // if the union has all fields 0 bits, we can do it | 13780 | // if the union has all fields 0 bits, we can do it |
| 12716 | // and in fact it's a noop cast because the union value is just the enum value | 13781 | // and in fact it's a noop cast because the union value is just the enum value |
| 12717 | if (wanted_type->data.unionation.gen_field_count == 0) { | 13782 | if (wanted_type->data.unionation.gen_field_count == 0) { |
| 12718 | IrInstruction *result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, wanted_type, target, CastOpNoop); | 13783 | return ir_build_cast(ira, &target->base, wanted_type, target, CastOpNoop); |
| 12719 | result->value->type = wanted_type; | | |
| 12720 | return result; | | |
| 12721 | } | 13784 | } |
| 12722 | | 13785 | |
| 12723 | ErrorMsg *msg = ir_add_error(ira, source_instr, | 13786 | ErrorMsg *msg = ir_add_error(ira, source_instr, |
| ... | @@ -12727,10 +13790,10 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -12727,10 +13790,10 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 12727 | TypeUnionField *union_field = &wanted_type->data.unionation.fields[i]; | 13790 | TypeUnionField *union_field = &wanted_type->data.unionation.fields[i]; |
| 12728 | ZigType *field_type = resolve_union_field_type(ira->codegen, union_field); | 13791 | ZigType *field_type = resolve_union_field_type(ira->codegen, union_field); |
| 12729 | if (field_type == nullptr) | 13792 | if (field_type == nullptr) |
| 12730 | return ira->codegen->invalid_instruction; | 13793 | return ira->codegen->invalid_inst_gen; |
| 12731 | bool has_bits; | 13794 | bool has_bits; |
| 12732 | if ((err = type_has_bits2(ira->codegen, field_type, &has_bits))) | 13795 | if ((err = type_has_bits2(ira->codegen, field_type, &has_bits))) |
| 12733 | return ira->codegen->invalid_instruction; | 13796 | return ira->codegen->invalid_inst_gen; |
| 12734 | if (has_bits) { | 13797 | if (has_bits) { |
| 12735 | AstNode *field_node = wanted_type->data.unionation.decl_node->data.container_decl.fields.at(i); | 13798 | AstNode *field_node = wanted_type->data.unionation.decl_node->data.container_decl.fields.at(i); |
| 12736 | add_error_note(ira->codegen, msg, field_node, | 13799 | add_error_note(ira->codegen, msg, field_node, |
| ... | @@ -12739,23 +13802,23 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so | ... | @@ -12739,23 +13802,23 @@ static IrInstruction *ir_analyze_enum_to_union(IrAnalyze *ira, IrInstruction *so |
| 12739 | buf_ptr(&field_type->name))); | 13802 | buf_ptr(&field_type->name))); |
| 12740 | } | 13803 | } |
| 12741 | } | 13804 | } |
| 12742 | return ira->codegen->invalid_instruction; | 13805 | return ira->codegen->invalid_inst_gen; |
| 12743 | } | 13806 | } |
| 12744 | | 13807 | |
| 12745 | static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction *source_instr, | 13808 | static IrInstGen *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInst* source_instr, |
| 12746 | IrInstruction *target, ZigType *wanted_type) | 13809 | IrInstGen *target, ZigType *wanted_type) |
| 12747 | { | 13810 | { |
| 12748 | assert(wanted_type->id == ZigTypeIdInt || wanted_type->id == ZigTypeIdFloat); | 13811 | assert(wanted_type->id == ZigTypeIdInt || wanted_type->id == ZigTypeIdFloat); |
| 12749 | | 13812 | |
| 12750 | if (instr_is_comptime(target)) { | 13813 | if (instr_is_comptime(target)) { |
| 12751 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 13814 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12752 | if (!val) | 13815 | if (!val) |
| 12753 | return ira->codegen->invalid_instruction; | 13816 | return ira->codegen->invalid_inst_gen; |
| 12754 | if (wanted_type->id == ZigTypeIdInt) { | 13817 | if (wanted_type->id == ZigTypeIdInt) { |
| 12755 | if (bigint_cmp_zero(&val->data.x_bigint) == CmpLT && !wanted_type->data.integral.is_signed) { | 13818 | if (bigint_cmp_zero(&val->data.x_bigint) == CmpLT && !wanted_type->data.integral.is_signed) { |
| 12756 | ir_add_error(ira, source_instr, | 13819 | ir_add_error(ira, source_instr, |
| 12757 | buf_sprintf("attempt to cast negative value to unsigned integer")); | 13820 | buf_sprintf("attempt to cast negative value to unsigned integer")); |
| 12758 | return ira->codegen->invalid_instruction; | 13821 | return ira->codegen->invalid_inst_gen; |
| 12759 | } | 13822 | } |
| 12760 | if (!bigint_fits_in_bits(&val->data.x_bigint, wanted_type->data.integral.bit_count, | 13823 | if (!bigint_fits_in_bits(&val->data.x_bigint, wanted_type->data.integral.bit_count, |
| 12761 | wanted_type->data.integral.is_signed)) | 13824 | wanted_type->data.integral.is_signed)) |
| ... | @@ -12763,10 +13826,10 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction | ... | @@ -12763,10 +13826,10 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction |
| 12763 | ir_add_error(ira, source_instr, | 13826 | ir_add_error(ira, source_instr, |
| 12764 | buf_sprintf("cast from '%s' to '%s' truncates bits", | 13827 | buf_sprintf("cast from '%s' to '%s' truncates bits", |
| 12765 | buf_ptr(&target->value->type->name), buf_ptr(&wanted_type->name))); | 13828 | buf_ptr(&target->value->type->name), buf_ptr(&wanted_type->name))); |
| 12766 | return ira->codegen->invalid_instruction; | 13829 | return ira->codegen->invalid_inst_gen; |
| 12767 | } | 13830 | } |
| 12768 | } | 13831 | } |
| 12769 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13832 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12770 | result->value->type = wanted_type; | 13833 | result->value->type = wanted_type; |
| 12771 | if (wanted_type->id == ZigTypeIdInt) { | 13834 | if (wanted_type->id == ZigTypeIdInt) { |
| 12772 | bigint_init_bigint(&result->value->data.x_bigint, &val->data.x_bigint); | 13835 | bigint_init_bigint(&result->value->data.x_bigint, &val->data.x_bigint); |
| ... | @@ -12783,19 +13846,16 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction | ... | @@ -12783,19 +13846,16 @@ static IrInstruction *ir_analyze_widen_or_shorten(IrAnalyze *ira, IrInstruction |
| 12783 | assert(wanted_type->id == ZigTypeIdInt); | 13846 | assert(wanted_type->id == ZigTypeIdInt); |
| 12784 | assert(type_has_bits(target->value->type)); | 13847 | assert(type_has_bits(target->value->type)); |
| 12785 | ir_build_assert_zero(ira, source_instr, target); | 13848 | ir_build_assert_zero(ira, source_instr, target); |
| 12786 | IrInstruction *result = ir_const_unsigned(ira, source_instr, 0); | 13849 | IrInstGen *result = ir_const_unsigned(ira, source_instr, 0); |
| 12787 | result->value->type = wanted_type; | 13850 | result->value->type = wanted_type; |
| 12788 | return result; | 13851 | return result; |
| 12789 | } | 13852 | } |
| 12790 | | 13853 | |
| 12791 | IrInstruction *result = ir_build_widen_or_shorten(&ira->new_irb, source_instr->scope, | 13854 | return ir_build_widen_or_shorten(ira, source_instr->scope, source_instr->source_node, target, wanted_type); |
| 12792 | source_instr->source_node, target); | | |
| 12793 | result->value->type = wanted_type; | | |
| 12794 | return result; | | |
| 12795 | } | 13855 | } |
| 12796 | | 13856 | |
| 12797 | static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *source_instr, | 13857 | static IrInstGen *ir_analyze_int_to_enum(IrAnalyze *ira, IrInst* source_instr, |
| 12798 | IrInstruction *target, ZigType *wanted_type) | 13858 | IrInstGen *target, ZigType *wanted_type) |
| 12799 | { | 13859 | { |
| 12800 | Error err; | 13860 | Error err; |
| 12801 | assert(wanted_type->id == ZigTypeIdEnum); | 13861 | assert(wanted_type->id == ZigTypeIdEnum); |
| ... | @@ -12803,14 +13863,14 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12803,14 +13863,14 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 12803 | ZigType *actual_type = target->value->type; | 13863 | ZigType *actual_type = target->value->type; |
| 12804 | | 13864 | |
| 12805 | if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusSizeKnown))) | 13865 | if ((err = type_resolve(ira->codegen, wanted_type, ResolveStatusSizeKnown))) |
| 12806 | return ira->codegen->invalid_instruction; | 13866 | return ira->codegen->invalid_inst_gen; |
| 12807 | | 13867 | |
| 12808 | if (actual_type != wanted_type->data.enumeration.tag_int_type) { | 13868 | if (actual_type != wanted_type->data.enumeration.tag_int_type) { |
| 12809 | ir_add_error(ira, source_instr, | 13869 | ir_add_error(ira, source_instr, |
| 12810 | buf_sprintf("integer to enum cast from '%s' instead of its tag type, '%s'", | 13870 | buf_sprintf("integer to enum cast from '%s' instead of its tag type, '%s'", |
| 12811 | buf_ptr(&actual_type->name), | 13871 | buf_ptr(&actual_type->name), |
| 12812 | buf_ptr(&wanted_type->data.enumeration.tag_int_type->name))); | 13872 | buf_ptr(&wanted_type->data.enumeration.tag_int_type->name))); |
| 12813 | return ira->codegen->invalid_instruction; | 13873 | return ira->codegen->invalid_inst_gen; |
| 12814 | } | 13874 | } |
| 12815 | | 13875 | |
| 12816 | assert(actual_type->id == ZigTypeIdInt || actual_type->id == ZigTypeIdComptimeInt); | 13876 | assert(actual_type->id == ZigTypeIdInt || actual_type->id == ZigTypeIdComptimeInt); |
| ... | @@ -12818,7 +13878,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12818,7 +13878,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 12818 | if (instr_is_comptime(target)) { | 13878 | if (instr_is_comptime(target)) { |
| 12819 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 13879 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12820 | if (!val) | 13880 | if (!val) |
| 12821 | return ira->codegen->invalid_instruction; | 13881 | return ira->codegen->invalid_inst_gen; |
| 12822 | | 13882 | |
| 12823 | TypeEnumField *field = find_enum_field_by_tag(wanted_type, &val->data.x_bigint); | 13883 | TypeEnumField *field = find_enum_field_by_tag(wanted_type, &val->data.x_bigint); |
| 12824 | if (field == nullptr && !wanted_type->data.enumeration.non_exhaustive) { | 13884 | if (field == nullptr && !wanted_type->data.enumeration.non_exhaustive) { |
| ... | @@ -12829,28 +13889,25 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour | ... | @@ -12829,28 +13889,25 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour |
| 12829 | buf_ptr(&wanted_type->name), buf_ptr(val_buf))); | 13889 | buf_ptr(&wanted_type->name), buf_ptr(val_buf))); |
| 12830 | add_error_note(ira->codegen, msg, wanted_type->data.enumeration.decl_node, | 13890 | add_error_note(ira->codegen, msg, wanted_type->data.enumeration.decl_node, |
| 12831 | buf_sprintf("'%s' declared here", buf_ptr(&wanted_type->name))); | 13891 | buf_sprintf("'%s' declared here", buf_ptr(&wanted_type->name))); |
| 12832 | return ira->codegen->invalid_instruction; | 13892 | return ira->codegen->invalid_inst_gen; |
| 12833 | } | 13893 | } |
| 12834 | | 13894 | |
| 12835 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13895 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12836 | bigint_init_bigint(&result->value->data.x_enum_tag, &val->data.x_bigint); | 13896 | bigint_init_bigint(&result->value->data.x_enum_tag, &val->data.x_bigint); |
| 12837 | return result; | 13897 | return result; |
| 12838 | } | 13898 | } |
| 12839 | | 13899 | |
| 12840 | IrInstruction *result = ir_build_int_to_enum(&ira->new_irb, source_instr->scope, | 13900 | return ir_build_int_to_enum_gen(ira, source_instr->scope, source_instr->source_node, wanted_type, target); |
| 12841 | source_instr->source_node, nullptr, target); | | |
| 12842 | result->value->type = wanted_type; | | |
| 12843 | return result; | | |
| 12844 | } | 13901 | } |
| 12845 | | 13902 | |
| 12846 | static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction *source_instr, | 13903 | static IrInstGen *ir_analyze_number_to_literal(IrAnalyze *ira, IrInst* source_instr, |
| 12847 | IrInstruction *target, ZigType *wanted_type) | 13904 | IrInstGen *target, ZigType *wanted_type) |
| 12848 | { | 13905 | { |
| 12849 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 13906 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12850 | if (!val) | 13907 | if (!val) |
| 12851 | return ira->codegen->invalid_instruction; | 13908 | return ira->codegen->invalid_inst_gen; |
| 12852 | | 13909 | |
| 12853 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13910 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12854 | if (wanted_type->id == ZigTypeIdComptimeFloat) { | 13911 | if (wanted_type->id == ZigTypeIdComptimeFloat) { |
| 12855 | float_init_float(result->value, val); | 13912 | float_init_float(result->value, val); |
| 12856 | } else if (wanted_type->id == ZigTypeIdComptimeInt) { | 13913 | } else if (wanted_type->id == ZigTypeIdComptimeInt) { |
| ... | @@ -12861,7 +13918,7 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction | ... | @@ -12861,7 +13918,7 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction |
| 12861 | return result; | 13918 | return result; |
| 12862 | } | 13919 | } |
| 12863 | | 13920 | |
| 12864 | static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, | 13921 | static IrInstGen *ir_analyze_int_to_err(IrAnalyze *ira, IrInst* source_instr, IrInstGen *target, |
| 12865 | ZigType *wanted_type) | 13922 | ZigType *wanted_type) |
| 12866 | { | 13923 | { |
| 12867 | assert(target->value->type->id == ZigTypeIdInt); | 13924 | assert(target->value->type->id == ZigTypeIdInt); |
| ... | @@ -12871,12 +13928,12 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12871,12 +13928,12 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc |
| 12871 | if (instr_is_comptime(target)) { | 13928 | if (instr_is_comptime(target)) { |
| 12872 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 13929 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12873 | if (!val) | 13930 | if (!val) |
| 12874 | return ira->codegen->invalid_instruction; | 13931 | return ira->codegen->invalid_inst_gen; |
| 12875 | | 13932 | |
| 12876 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13933 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12877 | | 13934 | |
| 12878 | if (!resolve_inferred_error_set(ira->codegen, wanted_type, source_instr->source_node)) { | 13935 | if (!resolve_inferred_error_set(ira->codegen, wanted_type, source_instr->source_node)) { |
| 12879 | return ira->codegen->invalid_instruction; | 13936 | return ira->codegen->invalid_inst_gen; |
| 12880 | } | 13937 | } |
| 12881 | | 13938 | |
| 12882 | if (type_is_global_error_set(wanted_type)) { | 13939 | if (type_is_global_error_set(wanted_type)) { |
| ... | @@ -12888,7 +13945,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12888,7 +13945,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc |
| 12888 | bigint_append_buf(val_buf, &val->data.x_bigint, 10); | 13945 | bigint_append_buf(val_buf, &val->data.x_bigint, 10); |
| 12889 | ir_add_error(ira, source_instr, | 13946 | ir_add_error(ira, source_instr, |
| 12890 | buf_sprintf("integer value %s represents no error", buf_ptr(val_buf))); | 13947 | buf_sprintf("integer value %s represents no error", buf_ptr(val_buf))); |
| 12891 | return ira->codegen->invalid_instruction; | 13948 | return ira->codegen->invalid_inst_gen; |
| 12892 | } | 13949 | } |
| 12893 | | 13950 | |
| 12894 | size_t index = bigint_as_usize(&val->data.x_bigint); | 13951 | size_t index = bigint_as_usize(&val->data.x_bigint); |
| ... | @@ -12912,7 +13969,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12912,7 +13969,7 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc |
| 12912 | bigint_append_buf(val_buf, &val->data.x_bigint, 10); | 13969 | bigint_append_buf(val_buf, &val->data.x_bigint, 10); |
| 12913 | ir_add_error(ira, source_instr, | 13970 | ir_add_error(ira, source_instr, |
| 12914 | buf_sprintf("integer value %s represents no error in '%s'", buf_ptr(val_buf), buf_ptr(&wanted_type->name))); | 13971 | buf_sprintf("integer value %s represents no error in '%s'", buf_ptr(val_buf), buf_ptr(&wanted_type->name))); |
| 12915 | return ira->codegen->invalid_instruction; | 13972 | return ira->codegen->invalid_inst_gen; |
| 12916 | } | 13973 | } |
| 12917 | | 13974 | |
| 12918 | result->value->data.x_err_set = err; | 13975 | result->value->data.x_err_set = err; |
| ... | @@ -12920,12 +13977,10 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12920,12 +13977,10 @@ static IrInstruction *ir_analyze_int_to_err(IrAnalyze *ira, IrInstruction *sourc |
| 12920 | } | 13977 | } |
| 12921 | } | 13978 | } |
| 12922 | | 13979 | |
| 12923 | IrInstruction *result = ir_build_int_to_err(&ira->new_irb, source_instr->scope, source_instr->source_node, target); | 13980 | return ir_build_int_to_err_gen(ira, source_instr->scope, source_instr->source_node, target, wanted_type); |
| 12924 | result->value->type = wanted_type; | | |
| 12925 | return result; | | |
| 12926 | } | 13981 | } |
| 12927 | | 13982 | |
| 12928 | static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, | 13983 | static IrInstGen *ir_analyze_err_to_int(IrAnalyze *ira, IrInst* source_instr, IrInstGen *target, |
| 12929 | ZigType *wanted_type) | 13984 | ZigType *wanted_type) |
| 12930 | { | 13985 | { |
| 12931 | assert(wanted_type->id == ZigTypeIdInt); | 13986 | assert(wanted_type->id == ZigTypeIdInt); |
| ... | @@ -12935,9 +13990,9 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12935,9 +13990,9 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 12935 | if (instr_is_comptime(target)) { | 13990 | if (instr_is_comptime(target)) { |
| 12936 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 13991 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 12937 | if (!val) | 13992 | if (!val) |
| 12938 | return ira->codegen->invalid_instruction; | 13993 | return ira->codegen->invalid_inst_gen; |
| 12939 | | 13994 | |
| 12940 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 13995 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12941 | | 13996 | |
| 12942 | ErrorTableEntry *err; | 13997 | ErrorTableEntry *err; |
| 12943 | if (err_type->id == ZigTypeIdErrorUnion) { | 13998 | if (err_type->id == ZigTypeIdErrorUnion) { |
| ... | @@ -12957,7 +14012,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12957,7 +14012,7 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 12957 | ir_add_error_node(ira, source_instr->source_node, | 14012 | ir_add_error_node(ira, source_instr->source_node, |
| 12958 | buf_sprintf("error code '%s' does not fit in '%s'", | 14013 | buf_sprintf("error code '%s' does not fit in '%s'", |
| 12959 | buf_ptr(&err->name), buf_ptr(&wanted_type->name))); | 14014 | buf_ptr(&err->name), buf_ptr(&wanted_type->name))); |
| 12960 | return ira->codegen->invalid_instruction; | 14015 | return ira->codegen->invalid_inst_gen; |
| 12961 | } | 14016 | } |
| 12962 | | 14017 | |
| 12963 | return result; | 14018 | return result; |
| ... | @@ -12973,14 +14028,14 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12973,14 +14028,14 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 12973 | } | 14028 | } |
| 12974 | if (!type_is_global_error_set(err_set_type)) { | 14029 | if (!type_is_global_error_set(err_set_type)) { |
| 12975 | if (!resolve_inferred_error_set(ira->codegen, err_set_type, source_instr->source_node)) { | 14030 | if (!resolve_inferred_error_set(ira->codegen, err_set_type, source_instr->source_node)) { |
| 12976 | return ira->codegen->invalid_instruction; | 14031 | return ira->codegen->invalid_inst_gen; |
| 12977 | } | 14032 | } |
| 12978 | if (err_set_type->data.error_set.err_count == 0) { | 14033 | if (err_set_type->data.error_set.err_count == 0) { |
| 12979 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 14034 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12980 | bigint_init_unsigned(&result->value->data.x_bigint, 0); | 14035 | bigint_init_unsigned(&result->value->data.x_bigint, 0); |
| 12981 | return result; | 14036 | return result; |
| 12982 | } else if (err_set_type->data.error_set.err_count == 1) { | 14037 | } else if (err_set_type->data.error_set.err_count == 1) { |
| 12983 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 14038 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 12984 | ErrorTableEntry *err = err_set_type->data.error_set.errors[0]; | 14039 | ErrorTableEntry *err = err_set_type->data.error_set.errors[0]; |
| 12985 | bigint_init_unsigned(&result->value->data.x_bigint, err->value); | 14040 | bigint_init_unsigned(&result->value->data.x_bigint, err->value); |
| 12986 | return result; | 14041 | return result; |
| ... | @@ -12992,21 +14047,19 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -12992,21 +14047,19 @@ static IrInstruction *ir_analyze_err_to_int(IrAnalyze *ira, IrInstruction *sourc |
| 12992 | if (!bigint_fits_in_bits(&bn, wanted_type->data.integral.bit_count, wanted_type->data.integral.is_signed)) { | 14047 | if (!bigint_fits_in_bits(&bn, wanted_type->data.integral.bit_count, wanted_type->data.integral.is_signed)) { |
| 12993 | ir_add_error_node(ira, source_instr->source_node, | 14048 | ir_add_error_node(ira, source_instr->source_node, |
| 12994 | buf_sprintf("too many error values to fit in '%s'", buf_ptr(&wanted_type->name))); | 14049 | buf_sprintf("too many error values to fit in '%s'", buf_ptr(&wanted_type->name))); |
| 12995 | return ira->codegen->invalid_instruction; | 14050 | return ira->codegen->invalid_inst_gen; |
| 12996 | } | 14051 | } |
| 12997 | | 14052 | |
| 12998 | IrInstruction *result = ir_build_err_to_int(&ira->new_irb, source_instr->scope, source_instr->source_node, target); | 14053 | return ir_build_err_to_int_gen(ira, source_instr->scope, source_instr->source_node, target, wanted_type); |
| 12999 | result->value->type = wanted_type; | | |
| 13000 | return result; | | |
| 13001 | } | 14054 | } |
| 13002 | | 14055 | |
| 13003 | static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, | 14056 | static IrInstGen *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInst* source_instr, IrInstGen *target, |
| 13004 | ZigType *wanted_type) | 14057 | ZigType *wanted_type) |
| 13005 | { | 14058 | { |
| 13006 | assert(wanted_type->id == ZigTypeIdPointer); | 14059 | assert(wanted_type->id == ZigTypeIdPointer); |
| 13007 | Error err; | 14060 | Error err; |
| 13008 | if ((err = type_resolve(ira->codegen, target->value->type->data.pointer.child_type, ResolveStatusAlignmentKnown))) | 14061 | if ((err = type_resolve(ira->codegen, target->value->type->data.pointer.child_type, ResolveStatusAlignmentKnown))) |
| 13009 | return ira->codegen->invalid_instruction; | 14062 | return ira->codegen->invalid_inst_gen; |
| 13010 | assert((wanted_type->data.pointer.is_const && target->value->type->data.pointer.is_const) || !target->value->type->data.pointer.is_const); | 14063 | assert((wanted_type->data.pointer.is_const && target->value->type->data.pointer.is_const) || !target->value->type->data.pointer.is_const); |
| 13011 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, target->value->type)); | 14064 | wanted_type = adjust_ptr_align(ira->codegen, wanted_type, get_ptr_align(ira->codegen, target->value->type)); |
| 13012 | ZigType *array_type = wanted_type->data.pointer.child_type; | 14065 | ZigType *array_type = wanted_type->data.pointer.child_type; |
| ... | @@ -13016,12 +14069,12 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou | ... | @@ -13016,12 +14069,12 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou |
| 13016 | if (instr_is_comptime(target)) { | 14069 | if (instr_is_comptime(target)) { |
| 13017 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 14070 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 13018 | if (!val) | 14071 | if (!val) |
| 13019 | return ira->codegen->invalid_instruction; | 14072 | return ira->codegen->invalid_inst_gen; |
| 13020 | | 14073 | |
| 13021 | assert(val->type->id == ZigTypeIdPointer); | 14074 | assert(val->type->id == ZigTypeIdPointer); |
| 13022 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, val, source_instr->source_node); | 14075 | ZigValue *pointee = const_ptr_pointee(ira, ira->codegen, val, source_instr->source_node); |
| 13023 | if (pointee == nullptr) | 14076 | if (pointee == nullptr) |
| 13024 | return ira->codegen->invalid_instruction; | 14077 | return ira->codegen->invalid_inst_gen; |
| 13025 | if (pointee->special != ConstValSpecialRuntime) { | 14078 | if (pointee->special != ConstValSpecialRuntime) { |
| 13026 | ZigValue *array_val = create_const_vals(1); | 14079 | ZigValue *array_val = create_const_vals(1); |
| 13027 | array_val->special = ConstValSpecialStatic; | 14080 | array_val->special = ConstValSpecialStatic; |
| ... | @@ -13031,7 +14084,7 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou | ... | @@ -13031,7 +14084,7 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou |
| 13031 | array_val->parent.id = ConstParentIdScalar; | 14084 | array_val->parent.id = ConstParentIdScalar; |
| 13032 | array_val->parent.data.p_scalar.scalar_val = pointee; | 14085 | array_val->parent.data.p_scalar.scalar_val = pointee; |
| 13033 | | 14086 | |
| 13034 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 14087 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, |
| 13035 | source_instr->scope, source_instr->source_node); | 14088 | source_instr->scope, source_instr->source_node); |
| 13036 | const_instruction->base.value->type = wanted_type; | 14089 | const_instruction->base.value->type = wanted_type; |
| 13037 | const_instruction->base.value->special = ConstValSpecialStatic; | 14090 | const_instruction->base.value->special = ConstValSpecialStatic; |
| ... | @@ -13043,10 +14096,7 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou | ... | @@ -13043,10 +14096,7 @@ static IrInstruction *ir_analyze_ptr_to_array(IrAnalyze *ira, IrInstruction *sou |
| 13043 | } | 14096 | } |
| 13044 | | 14097 | |
| 13045 | // pointer to array and pointer to single item are represented the same way at runtime | 14098 | // pointer to array and pointer to single item are represented the same way at runtime |
| 13046 | IrInstruction *result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, | 14099 | return ir_build_cast(ira, &target->base, wanted_type, target, CastOpBitCast); |
| 13047 | wanted_type, target, CastOpBitCast); | | |
| 13048 | result->value->type = wanted_type; | | |
| 13049 | return result; | | |
| 13050 | } | 14100 | } |
| 13051 | | 14101 | |
| 13052 | static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCastOnly *cast_result, | 14102 | static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCastOnly *cast_result, |
| ... | @@ -13234,12 +14284,12 @@ static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCa | ... | @@ -13234,12 +14284,12 @@ static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCa |
| 13234 | } | 14284 | } |
| 13235 | } | 14285 | } |
| 13236 | | 14286 | |
| 13237 | static IrInstruction *ir_analyze_array_to_vector(IrAnalyze *ira, IrInstruction *source_instr, | 14287 | static IrInstGen *ir_analyze_array_to_vector(IrAnalyze *ira, IrInst* source_instr, |
| 13238 | IrInstruction *array, ZigType *vector_type) | 14288 | IrInstGen *array, ZigType *vector_type) |
| 13239 | { | 14289 | { |
| 13240 | if (instr_is_comptime(array)) { | 14290 | if (instr_is_comptime(array)) { |
| 13241 | // arrays and vectors have the same ZigValue representation | 14291 | // arrays and vectors have the same ZigValue representation |
| 13242 | IrInstruction *result = ir_const(ira, source_instr, vector_type); | 14292 | IrInstGen *result = ir_const(ira, source_instr, vector_type); |
| 13243 | copy_const_val(result->value, array->value); | 14293 | copy_const_val(result->value, array->value); |
| 13244 | result->value->type = vector_type; | 14294 | result->value->type = vector_type; |
| 13245 | return result; | 14295 | return result; |
| ... | @@ -13247,12 +14297,12 @@ static IrInstruction *ir_analyze_array_to_vector(IrAnalyze *ira, IrInstruction * | ... | @@ -13247,12 +14297,12 @@ static IrInstruction *ir_analyze_array_to_vector(IrAnalyze *ira, IrInstruction * |
| 13247 | return ir_build_array_to_vector(ira, source_instr, array, vector_type); | 14297 | return ir_build_array_to_vector(ira, source_instr, array, vector_type); |
| 13248 | } | 14298 | } |
| 13249 | | 14299 | |
| 13250 | static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction *source_instr, | 14300 | static IrInstGen *ir_analyze_vector_to_array(IrAnalyze *ira, IrInst* source_instr, |
| 13251 | IrInstruction *vector, ZigType *array_type, ResultLoc *result_loc) | 14301 | IrInstGen *vector, ZigType *array_type, ResultLoc *result_loc) |
| 13252 | { | 14302 | { |
| 13253 | if (instr_is_comptime(vector)) { | 14303 | if (instr_is_comptime(vector)) { |
| 13254 | // arrays and vectors have the same ZigValue representation | 14304 | // arrays and vectors have the same ZigValue representation |
| 13255 | IrInstruction *result = ir_const(ira, source_instr, array_type); | 14305 | IrInstGen *result = ir_const(ira, source_instr, array_type); |
| 13256 | copy_const_val(result->value, vector->value); | 14306 | copy_const_val(result->value, vector->value); |
| 13257 | result->value->type = array_type; | 14307 | result->value->type = array_type; |
| 13258 | return result; | 14308 | return result; |
| ... | @@ -13260,18 +14310,18 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction * | ... | @@ -13260,18 +14310,18 @@ static IrInstruction *ir_analyze_vector_to_array(IrAnalyze *ira, IrInstruction * |
| 13260 | if (result_loc == nullptr) { | 14310 | if (result_loc == nullptr) { |
| 13261 | result_loc = no_result_loc(); | 14311 | result_loc = no_result_loc(); |
| 13262 | } | 14312 | } |
| 13263 | IrInstruction *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, array_type, nullptr, | 14313 | IrInstGen *result_loc_inst = ir_resolve_result(ira, source_instr, result_loc, array_type, nullptr, |
| 13264 | true, false, true); | 14314 | true, false, true); |
| 13265 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { | 14315 | if (type_is_invalid(result_loc_inst->value->type) || result_loc_inst->value->type->id == ZigTypeIdUnreachable) { |
| 13266 | return result_loc_inst; | 14316 | return result_loc_inst; |
| 13267 | } | 14317 | } |
| 13268 | return ir_build_vector_to_array(ira, source_instr, array_type, vector, result_loc_inst); | 14318 | return ir_build_vector_to_array(ira, source_instr, array_type, vector, result_loc_inst); |
| 13269 | } | 14319 | } |
| 13270 | | 14320 | |
| 13271 | static IrInstruction *ir_analyze_int_to_c_ptr(IrAnalyze *ira, IrInstruction *source_instr, | 14321 | static IrInstGen *ir_analyze_int_to_c_ptr(IrAnalyze *ira, IrInst* source_instr, |
| 13272 | IrInstruction *integer, ZigType *dest_type) | 14322 | IrInstGen *integer, ZigType *dest_type) |
| 13273 | { | 14323 | { |
| 13274 | IrInstruction *unsigned_integer; | 14324 | IrInstGen *unsigned_integer; |
| 13275 | if (instr_is_comptime(integer)) { | 14325 | if (instr_is_comptime(integer)) { |
| 13276 | unsigned_integer = integer; | 14326 | unsigned_integer = integer; |
| 13277 | } else { | 14327 | } else { |
| ... | @@ -13284,7 +14334,7 @@ static IrInstruction *ir_analyze_int_to_c_ptr(IrAnalyze *ira, IrInstruction *sou | ... | @@ -13284,7 +14334,7 @@ static IrInstruction *ir_analyze_int_to_c_ptr(IrAnalyze *ira, IrInstruction *sou |
| 13284 | buf_sprintf("integer type '%s' too big for implicit @intToPtr to type '%s'", | 14334 | buf_sprintf("integer type '%s' too big for implicit @intToPtr to type '%s'", |
| 13285 | buf_ptr(&integer->value->type->name), | 14335 | buf_ptr(&integer->value->type->name), |
| 13286 | buf_ptr(&dest_type->name))); | 14336 | buf_ptr(&dest_type->name))); |
| 13287 | return ira->codegen->invalid_instruction; | 14337 | return ira->codegen->invalid_inst_gen; |
| 13288 | } | 14338 | } |
| 13289 | | 14339 | |
| 13290 | if (integer->value->type->data.integral.is_signed) { | 14340 | if (integer->value->type->data.integral.is_signed) { |
| ... | @@ -13292,7 +14342,7 @@ static IrInstruction *ir_analyze_int_to_c_ptr(IrAnalyze *ira, IrInstruction *sou | ... | @@ -13292,7 +14342,7 @@ static IrInstruction *ir_analyze_int_to_c_ptr(IrAnalyze *ira, IrInstruction *sou |
| 13292 | integer->value->type->data.integral.bit_count); | 14342 | integer->value->type->data.integral.bit_count); |
| 13293 | unsigned_integer = ir_analyze_bit_cast(ira, source_instr, integer, unsigned_int_type); | 14343 | unsigned_integer = ir_analyze_bit_cast(ira, source_instr, integer, unsigned_int_type); |
| 13294 | if (type_is_invalid(unsigned_integer->value->type)) | 14344 | if (type_is_invalid(unsigned_integer->value->type)) |
| 13295 | return ira->codegen->invalid_instruction; | 14345 | return ira->codegen->invalid_inst_gen; |
| 13296 | } else { | 14346 | } else { |
| 13297 | unsigned_integer = integer; | 14347 | unsigned_integer = integer; |
| 13298 | } | 14348 | } |
| ... | @@ -13312,14 +14362,14 @@ static bool is_pointery_and_elem_is_not_pointery(ZigType *ty) { | ... | @@ -13312,14 +14362,14 @@ static bool is_pointery_and_elem_is_not_pointery(ZigType *ty) { |
| 13312 | return false; | 14362 | return false; |
| 13313 | } | 14363 | } |
| 13314 | | 14364 | |
| 13315 | static IrInstruction *ir_analyze_enum_literal(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 14365 | static IrInstGen *ir_analyze_enum_literal(IrAnalyze *ira, IrInst* source_instr, IrInstGen *value, |
| 13316 | ZigType *enum_type) | 14366 | ZigType *enum_type) |
| 13317 | { | 14367 | { |
| 13318 | assert(enum_type->id == ZigTypeIdEnum); | 14368 | assert(enum_type->id == ZigTypeIdEnum); |
| 13319 | | 14369 | |
| 13320 | Error err; | 14370 | Error err; |
| 13321 | if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusZeroBitsKnown))) | 14371 | if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusZeroBitsKnown))) |
| 13322 | return ira->codegen->invalid_instruction; | 14372 | return ira->codegen->invalid_inst_gen; |
| 13323 | | 14373 | |
| 13324 | TypeEnumField *field = find_enum_type_field(enum_type, value->value->data.x_enum_literal); | 14374 | TypeEnumField *field = find_enum_type_field(enum_type, value->value->data.x_enum_literal); |
| 13325 | if (field == nullptr) { | 14375 | if (field == nullptr) { |
| ... | @@ -13327,40 +14377,40 @@ static IrInstruction *ir_analyze_enum_literal(IrAnalyze *ira, IrInstruction *sou | ... | @@ -13327,40 +14377,40 @@ static IrInstruction *ir_analyze_enum_literal(IrAnalyze *ira, IrInstruction *sou |
| 13327 | buf_ptr(&enum_type->name), buf_ptr(value->value->data.x_enum_literal))); | 14377 | buf_ptr(&enum_type->name), buf_ptr(value->value->data.x_enum_literal))); |
| 13328 | add_error_note(ira->codegen, msg, enum_type->data.enumeration.decl_node, | 14378 | add_error_note(ira->codegen, msg, enum_type->data.enumeration.decl_node, |
| 13329 | buf_sprintf("'%s' declared here", buf_ptr(&enum_type->name))); | 14379 | buf_sprintf("'%s' declared here", buf_ptr(&enum_type->name))); |
| 13330 | return ira->codegen->invalid_instruction; | 14380 | return ira->codegen->invalid_inst_gen; |
| 13331 | } | 14381 | } |
| 13332 | IrInstruction *result = ir_const(ira, source_instr, enum_type); | 14382 | IrInstGen *result = ir_const(ira, source_instr, enum_type); |
| 13333 | bigint_init_bigint(&result->value->data.x_enum_tag, &field->value); | 14383 | bigint_init_bigint(&result->value->data.x_enum_tag, &field->value); |
| 13334 | | 14384 | |
| 13335 | return result; | 14385 | return result; |
| 13336 | } | 14386 | } |
| 13337 | | 14387 | |
| 13338 | static IrInstruction *ir_analyze_struct_literal_to_array(IrAnalyze *ira, IrInstruction *source_instr, | 14388 | static IrInstGen *ir_analyze_struct_literal_to_array(IrAnalyze *ira, IrInst* source_instr, |
| 13339 | IrInstruction *value, ZigType *wanted_type) | 14389 | IrInstGen *value, ZigType *wanted_type) |
| 13340 | { | 14390 | { |
| 13341 | ir_add_error(ira, source_instr, buf_sprintf("TODO: type coercion of anon list literal to array")); | 14391 | ir_add_error(ira, source_instr, buf_sprintf("TODO: type coercion of anon list literal to array")); |
| 13342 | return ira->codegen->invalid_instruction; | 14392 | return ira->codegen->invalid_inst_gen; |
| 13343 | } | 14393 | } |
| 13344 | | 14394 | |
| 13345 | static IrInstruction *ir_analyze_struct_literal_to_struct(IrAnalyze *ira, IrInstruction *source_instr, | 14395 | static IrInstGen *ir_analyze_struct_literal_to_struct(IrAnalyze *ira, IrInst* source_instr, |
| 13346 | IrInstruction *value, ZigType *wanted_type) | 14396 | IrInstGen *value, ZigType *wanted_type) |
| 13347 | { | 14397 | { |
| 13348 | ir_add_error(ira, source_instr, buf_sprintf("TODO: type coercion of anon struct literal to struct")); | 14398 | ir_add_error(ira, source_instr, buf_sprintf("TODO: type coercion of anon struct literal to struct")); |
| 13349 | return ira->codegen->invalid_instruction; | 14399 | return ira->codegen->invalid_inst_gen; |
| 13350 | } | 14400 | } |
| 13351 | | 14401 | |
| 13352 | static IrInstruction *ir_analyze_struct_literal_to_union(IrAnalyze *ira, IrInstruction *source_instr, | 14402 | static IrInstGen *ir_analyze_struct_literal_to_union(IrAnalyze *ira, IrInst* source_instr, |
| 13353 | IrInstruction *value, ZigType *wanted_type) | 14403 | IrInstGen *value, ZigType *wanted_type) |
| 13354 | { | 14404 | { |
| 13355 | ir_add_error(ira, source_instr, buf_sprintf("TODO: type coercion of anon struct literal to union")); | 14405 | ir_add_error(ira, source_instr, buf_sprintf("TODO: type coercion of anon struct literal to union")); |
| 13356 | return ira->codegen->invalid_instruction; | 14406 | return ira->codegen->invalid_inst_gen; |
| 13357 | } | 14407 | } |
| 13358 | | 14408 | |
| 13359 | // Add a compile error and return ErrorSemanticAnalyzeFail if the pointer alignment does not work, | 14409 | // Add a compile error and return ErrorSemanticAnalyzeFail if the pointer alignment does not work, |
| 13360 | // otherwise return ErrorNone. Does not emit any instructions. | 14410 | // otherwise return ErrorNone. Does not emit any instructions. |
| 13361 | // Assumes that the pointer types have element types with the same ABI alignment. Avoids resolving the | 14411 | // Assumes that the pointer types have element types with the same ABI alignment. Avoids resolving the |
| 13362 | // pointer types' alignments if both of the pointer types are ABI aligned. | 14412 | // pointer types' alignments if both of the pointer types are ABI aligned. |
| 13363 | static Error ir_cast_ptr_align(IrAnalyze *ira, IrInstruction *source_instr, ZigType *dest_ptr_type, | 14413 | static Error ir_cast_ptr_align(IrAnalyze *ira, IrInst* source_instr, ZigType *dest_ptr_type, |
| 13364 | ZigType *src_ptr_type, AstNode *src_source_node) | 14414 | ZigType *src_ptr_type, AstNode *src_source_node) |
| 13365 | { | 14415 | { |
| 13366 | Error err; | 14416 | Error err; |
| ... | @@ -13394,37 +14444,37 @@ static Error ir_cast_ptr_align(IrAnalyze *ira, IrInstruction *source_instr, ZigT | ... | @@ -13394,37 +14444,37 @@ static Error ir_cast_ptr_align(IrAnalyze *ira, IrInstruction *source_instr, ZigT |
| 13394 | return ErrorNone; | 14444 | return ErrorNone; |
| 13395 | } | 14445 | } |
| 13396 | | 14446 | |
| 13397 | static IrInstruction *ir_analyze_struct_value_field_value(IrAnalyze *ira, IrInstruction *source_instr, | 14447 | static IrInstGen *ir_analyze_struct_value_field_value(IrAnalyze *ira, IrInst* source_instr, |
| 13398 | IrInstruction *struct_operand, TypeStructField *field) | 14448 | IrInstGen *struct_operand, TypeStructField *field) |
| 13399 | { | 14449 | { |
| 13400 | IrInstruction *struct_ptr = ir_get_ref(ira, source_instr, struct_operand, true, false); | 14450 | IrInstGen *struct_ptr = ir_get_ref(ira, source_instr, struct_operand, true, false); |
| 13401 | if (type_is_invalid(struct_ptr->value->type)) | 14451 | if (type_is_invalid(struct_ptr->value->type)) |
| 13402 | return ira->codegen->invalid_instruction; | 14452 | return ira->codegen->invalid_inst_gen; |
| 13403 | IrInstruction *field_ptr = ir_analyze_struct_field_ptr(ira, source_instr, field, struct_ptr, | 14453 | IrInstGen *field_ptr = ir_analyze_struct_field_ptr(ira, source_instr, field, struct_ptr, |
| 13404 | struct_operand->value->type, false); | 14454 | struct_operand->value->type, false); |
| 13405 | if (type_is_invalid(field_ptr->value->type)) | 14455 | if (type_is_invalid(field_ptr->value->type)) |
| 13406 | return ira->codegen->invalid_instruction; | 14456 | return ira->codegen->invalid_inst_gen; |
| 13407 | return ir_get_deref(ira, source_instr, field_ptr, nullptr); | 14457 | return ir_get_deref(ira, source_instr, field_ptr, nullptr); |
| 13408 | } | 14458 | } |
| 13409 | | 14459 | |
| 13410 | static IrInstruction *ir_analyze_optional_value_payload_value(IrAnalyze *ira, IrInstruction *source_instr, | 14460 | static IrInstGen *ir_analyze_optional_value_payload_value(IrAnalyze *ira, IrInst* source_instr, |
| 13411 | IrInstruction *optional_operand, bool safety_check_on) | 14461 | IrInstGen *optional_operand, bool safety_check_on) |
| 13412 | { | 14462 | { |
| 13413 | IrInstruction *opt_ptr = ir_get_ref(ira, source_instr, optional_operand, true, false); | 14463 | IrInstGen *opt_ptr = ir_get_ref(ira, source_instr, optional_operand, true, false); |
| 13414 | IrInstruction *payload_ptr = ir_analyze_unwrap_optional_payload(ira, source_instr, opt_ptr, | 14464 | IrInstGen *payload_ptr = ir_analyze_unwrap_optional_payload(ira, source_instr, opt_ptr, |
| 13415 | safety_check_on, false); | 14465 | safety_check_on, false); |
| 13416 | return ir_get_deref(ira, source_instr, payload_ptr, nullptr); | 14466 | return ir_get_deref(ira, source_instr, payload_ptr, nullptr); |
| 13417 | } | 14467 | } |
| 13418 | | 14468 | |
| 13419 | static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_instr, | 14469 | static IrInstGen *ir_analyze_cast(IrAnalyze *ira, IrInst *source_instr, |
| 13420 | ZigType *wanted_type, IrInstruction *value) | 14470 | ZigType *wanted_type, IrInstGen *value) |
| 13421 | { | 14471 | { |
| 13422 | Error err; | 14472 | Error err; |
| 13423 | ZigType *actual_type = value->value->type; | 14473 | ZigType *actual_type = value->value->type; |
| 13424 | AstNode *source_node = source_instr->source_node; | 14474 | AstNode *source_node = source_instr->source_node; |
| 13425 | | 14475 | |
| 13426 | if (type_is_invalid(wanted_type) || type_is_invalid(actual_type)) { | 14476 | if (type_is_invalid(wanted_type) || type_is_invalid(actual_type)) { |
| 13427 | return ira->codegen->invalid_instruction; | 14477 | return ira->codegen->invalid_inst_gen; |
| 13428 | } | 14478 | } |
| 13429 | | 14479 | |
| 13430 | // This means the wanted type is anything. | 14480 | // This means the wanted type is anything. |
| ... | @@ -13436,7 +14486,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13436,7 +14486,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13436 | ConstCastOnly const_cast_result = types_match_const_cast_only(ira, wanted_type, actual_type, | 14486 | ConstCastOnly const_cast_result = types_match_const_cast_only(ira, wanted_type, actual_type, |
| 13437 | source_node, false); | 14487 | source_node, false); |
| 13438 | if (const_cast_result.id == ConstCastResultIdInvalid) | 14488 | if (const_cast_result.id == ConstCastResultIdInvalid) |
| 13439 | return ira->codegen->invalid_instruction; | 14489 | return ira->codegen->invalid_inst_gen; |
| 13440 | if (const_cast_result.id == ConstCastResultIdOk) { | 14490 | if (const_cast_result.id == ConstCastResultIdOk) { |
| 13441 | return ir_resolve_cast(ira, source_instr, value, wanted_type, CastOpNoop); | 14491 | return ir_resolve_cast(ira, source_instr, value, wanted_type, CastOpNoop); |
| 13442 | } | 14492 | } |
| ... | @@ -13470,7 +14520,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13470,7 +14520,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13470 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_child_type, true)) { | 14520 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_child_type, true)) { |
| 13471 | return ir_analyze_optional_wrap(ira, source_instr, value, wanted_type, nullptr); | 14521 | return ir_analyze_optional_wrap(ira, source_instr, value, wanted_type, nullptr); |
| 13472 | } else { | 14522 | } else { |
| 13473 | return ira->codegen->invalid_instruction; | 14523 | return ira->codegen->invalid_inst_gen; |
| 13474 | } | 14524 | } |
| 13475 | } else if ( | 14525 | } else if ( |
| 13476 | wanted_child_type->id == ZigTypeIdPointer && | 14526 | wanted_child_type->id == ZigTypeIdPointer && |
| ... | @@ -13480,18 +14530,18 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13480,18 +14530,18 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13480 | actual_type->data.pointer.child_type->id == ZigTypeIdArray) | 14530 | actual_type->data.pointer.child_type->id == ZigTypeIdArray) |
| 13481 | { | 14531 | { |
| 13482 | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) | 14532 | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) |
| 13483 | return ira->codegen->invalid_instruction; | 14533 | return ira->codegen->invalid_inst_gen; |
| 13484 | if ((err = type_resolve(ira->codegen, wanted_child_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) | 14534 | if ((err = type_resolve(ira->codegen, wanted_child_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) |
| 13485 | return ira->codegen->invalid_instruction; | 14535 | return ira->codegen->invalid_inst_gen; |
| 13486 | if (get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, wanted_child_type) && | 14536 | if (get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, wanted_child_type) && |
| 13487 | types_match_const_cast_only(ira, wanted_child_type->data.pointer.child_type, | 14537 | types_match_const_cast_only(ira, wanted_child_type->data.pointer.child_type, |
| 13488 | actual_type->data.pointer.child_type->data.array.child_type, source_node, | 14538 | actual_type->data.pointer.child_type->data.array.child_type, source_node, |
| 13489 | !wanted_child_type->data.pointer.is_const).id == ConstCastResultIdOk) | 14539 | !wanted_child_type->data.pointer.is_const).id == ConstCastResultIdOk) |
| 13490 | { | 14540 | { |
| 13491 | IrInstruction *cast1 = ir_resolve_ptr_of_array_to_unknown_len_ptr(ira, source_instr, value, | 14541 | IrInstGen *cast1 = ir_resolve_ptr_of_array_to_unknown_len_ptr(ira, source_instr, value, |
| 13492 | wanted_child_type); | 14542 | wanted_child_type); |
| 13493 | if (type_is_invalid(cast1->value->type)) | 14543 | if (type_is_invalid(cast1->value->type)) |
| 13494 | return ira->codegen->invalid_instruction; | 14544 | return ira->codegen->invalid_inst_gen; |
| 13495 | return ir_analyze_optional_wrap(ira, source_instr, cast1, wanted_type, nullptr); | 14545 | return ir_analyze_optional_wrap(ira, source_instr, cast1, wanted_type, nullptr); |
| 13496 | } | 14546 | } |
| 13497 | } | 14547 | } |
| ... | @@ -13509,7 +14559,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13509,7 +14559,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13509 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_type->data.error_union.payload_type, true)) { | 14559 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_type->data.error_union.payload_type, true)) { |
| 13510 | return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type, nullptr); | 14560 | return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type, nullptr); |
| 13511 | } else { | 14561 | } else { |
| 13512 | return ira->codegen->invalid_instruction; | 14562 | return ira->codegen->invalid_inst_gen; |
| 13513 | } | 14563 | } |
| 13514 | } | 14564 | } |
| 13515 | } | 14565 | } |
| ... | @@ -13525,13 +14575,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13525,13 +14575,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13525 | actual_type->id == ZigTypeIdComptimeInt || | 14575 | actual_type->id == ZigTypeIdComptimeInt || |
| 13526 | actual_type->id == ZigTypeIdComptimeFloat) | 14576 | actual_type->id == ZigTypeIdComptimeFloat) |
| 13527 | { | 14577 | { |
| 13528 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); | 14578 | IrInstGen *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); |
| 13529 | if (type_is_invalid(cast1->value->type)) | 14579 | if (type_is_invalid(cast1->value->type)) |
| 13530 | return ira->codegen->invalid_instruction; | 14580 | return ira->codegen->invalid_inst_gen; |
| 13531 | | 14581 | |
| 13532 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 14582 | IrInstGen *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13533 | if (type_is_invalid(cast2->value->type)) | 14583 | if (type_is_invalid(cast2->value->type)) |
| 13534 | return ira->codegen->invalid_instruction; | 14584 | return ira->codegen->invalid_inst_gen; |
| 13535 | | 14585 | |
| 13536 | return cast2; | 14586 | return cast2; |
| 13537 | } | 14587 | } |
| ... | @@ -13546,13 +14596,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13546,13 +14596,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13546 | wanted_type->id == ZigTypeIdFloat || wanted_type->id == ZigTypeIdComptimeFloat)) | 14596 | wanted_type->id == ZigTypeIdFloat || wanted_type->id == ZigTypeIdComptimeFloat)) |
| 13547 | { | 14597 | { |
| 13548 | if (value->value->special == ConstValSpecialUndef) { | 14598 | if (value->value->special == ConstValSpecialUndef) { |
| 13549 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 14599 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 13550 | result->value->special = ConstValSpecialUndef; | 14600 | result->value->special = ConstValSpecialUndef; |
| 13551 | return result; | 14601 | return result; |
| 13552 | } | 14602 | } |
| 13553 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) { | 14603 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) { |
| 13554 | if (wanted_type->id == ZigTypeIdComptimeInt || wanted_type->id == ZigTypeIdInt) { | 14604 | if (wanted_type->id == ZigTypeIdComptimeInt || wanted_type->id == ZigTypeIdInt) { |
| 13555 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 14605 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 13556 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { | 14606 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { |
| 13557 | copy_const_val(result->value, value->value); | 14607 | copy_const_val(result->value, value->value); |
| 13558 | result->value->type = wanted_type; | 14608 | result->value->type = wanted_type; |
| ... | @@ -13561,7 +14611,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13561,7 +14611,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13561 | } | 14611 | } |
| 13562 | return result; | 14612 | return result; |
| 13563 | } else if (wanted_type->id == ZigTypeIdComptimeFloat || wanted_type->id == ZigTypeIdFloat) { | 14613 | } else if (wanted_type->id == ZigTypeIdComptimeFloat || wanted_type->id == ZigTypeIdFloat) { |
| 13564 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 14614 | IrInstGen *result = ir_const(ira, source_instr, wanted_type); |
| 13565 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { | 14615 | if (actual_type->id == ZigTypeIdComptimeInt || actual_type->id == ZigTypeIdInt) { |
| 13566 | BigFloat bf; | 14616 | BigFloat bf; |
| 13567 | bigfloat_init_bigint(&bf, &value->value->data.x_bigint); | 14617 | bigfloat_init_bigint(&bf, &value->value->data.x_bigint); |
| ... | @@ -13573,7 +14623,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13573,7 +14623,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13573 | } | 14623 | } |
| 13574 | zig_unreachable(); | 14624 | zig_unreachable(); |
| 13575 | } else { | 14625 | } else { |
| 13576 | return ira->codegen->invalid_instruction; | 14626 | return ira->codegen->invalid_inst_gen; |
| 13577 | } | 14627 | } |
| 13578 | } | 14628 | } |
| 13579 | | 14629 | |
| ... | @@ -13609,13 +14659,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13609,13 +14659,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13609 | actual_type->data.pointer.ptr_len == PtrLenSingle && | 14659 | actual_type->data.pointer.ptr_len == PtrLenSingle && |
| 13610 | actual_type->data.pointer.child_type->id == ZigTypeIdArray) | 14660 | actual_type->data.pointer.child_type->id == ZigTypeIdArray) |
| 13611 | { | 14661 | { |
| 13612 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value); | 14662 | IrInstGen *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.maybe.child_type, value); |
| 13613 | if (type_is_invalid(cast1->value->type)) | 14663 | if (type_is_invalid(cast1->value->type)) |
| 13614 | return ira->codegen->invalid_instruction; | 14664 | return ira->codegen->invalid_inst_gen; |
| 13615 | | 14665 | |
| 13616 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 14666 | IrInstGen *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13617 | if (type_is_invalid(cast2->value->type)) | 14667 | if (type_is_invalid(cast2->value->type)) |
| 13618 | return ira->codegen->invalid_instruction; | 14668 | return ira->codegen->invalid_inst_gen; |
| 13619 | | 14669 | |
| 13620 | return cast2; | 14670 | return cast2; |
| 13621 | } | 14671 | } |
| ... | @@ -13636,9 +14686,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13636,9 +14686,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13636 | actual_array_type->data.array.sentinel))) | 14686 | actual_array_type->data.array.sentinel))) |
| 13637 | { | 14687 | { |
| 13638 | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) | 14688 | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) |
| 13639 | return ira->codegen->invalid_instruction; | 14689 | return ira->codegen->invalid_inst_gen; |
| 13640 | if ((err = type_resolve(ira->codegen, wanted_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) | 14690 | if ((err = type_resolve(ira->codegen, wanted_type->data.pointer.child_type, ResolveStatusAlignmentKnown))) |
| 13641 | return ira->codegen->invalid_instruction; | 14691 | return ira->codegen->invalid_inst_gen; |
| 13642 | if (get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, wanted_type) && | 14692 | if (get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, wanted_type) && |
| 13643 | types_match_const_cast_only(ira, wanted_type->data.pointer.child_type, | 14693 | types_match_const_cast_only(ira, wanted_type->data.pointer.child_type, |
| 13644 | actual_type->data.pointer.child_type->data.array.child_type, source_node, | 14694 | actual_type->data.pointer.child_type->data.array.child_type, source_node, |
| ... | @@ -13679,24 +14729,24 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13679,24 +14729,24 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13679 | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, | 14729 | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, |
| 13680 | ResolveStatusAlignmentKnown))) | 14730 | ResolveStatusAlignmentKnown))) |
| 13681 | { | 14731 | { |
| 13682 | return ira->codegen->invalid_instruction; | 14732 | return ira->codegen->invalid_inst_gen; |
| 13683 | } | 14733 | } |
| 13684 | if ((err = type_resolve(ira->codegen, slice_ptr_type->data.pointer.child_type, | 14734 | if ((err = type_resolve(ira->codegen, slice_ptr_type->data.pointer.child_type, |
| 13685 | ResolveStatusAlignmentKnown))) | 14735 | ResolveStatusAlignmentKnown))) |
| 13686 | { | 14736 | { |
| 13687 | return ira->codegen->invalid_instruction; | 14737 | return ira->codegen->invalid_inst_gen; |
| 13688 | } | 14738 | } |
| 13689 | ok_align = get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, slice_ptr_type); | 14739 | ok_align = get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, slice_ptr_type); |
| 13690 | } | 14740 | } |
| 13691 | if (ok_align) { | 14741 | if (ok_align) { |
| 13692 | if (wanted_type->id == ZigTypeIdErrorUnion) { | 14742 | if (wanted_type->id == ZigTypeIdErrorUnion) { |
| 13693 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, slice_type, value); | 14743 | IrInstGen *cast1 = ir_analyze_cast(ira, source_instr, slice_type, value); |
| 13694 | if (type_is_invalid(cast1->value->type)) | 14744 | if (type_is_invalid(cast1->value->type)) |
| 13695 | return ira->codegen->invalid_instruction; | 14745 | return ira->codegen->invalid_inst_gen; |
| 13696 | | 14746 | |
| 13697 | IrInstruction *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 14747 | IrInstGen *cast2 = ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| 13698 | if (type_is_invalid(cast2->value->type)) | 14748 | if (type_is_invalid(cast2->value->type)) |
| 13699 | return ira->codegen->invalid_instruction; | 14749 | return ira->codegen->invalid_inst_gen; |
| 13700 | | 14750 | |
| 13701 | return cast2; | 14751 | return cast2; |
| 13702 | } else { | 14752 | } else { |
| ... | @@ -13731,12 +14781,12 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13731,12 +14781,12 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13731 | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, | 14781 | if ((err = type_resolve(ira->codegen, actual_type->data.pointer.child_type, |
| 13732 | ResolveStatusAlignmentKnown))) | 14782 | ResolveStatusAlignmentKnown))) |
| 13733 | { | 14783 | { |
| 13734 | return ira->codegen->invalid_instruction; | 14784 | return ira->codegen->invalid_inst_gen; |
| 13735 | } | 14785 | } |
| 13736 | if ((err = type_resolve(ira->codegen, slice_ptr_type->data.pointer.child_type, | 14786 | if ((err = type_resolve(ira->codegen, slice_ptr_type->data.pointer.child_type, |
| 13737 | ResolveStatusAlignmentKnown))) | 14787 | ResolveStatusAlignmentKnown))) |
| 13738 | { | 14788 | { |
| 13739 | return ira->codegen->invalid_instruction; | 14789 | return ira->codegen->invalid_inst_gen; |
| 13740 | } | 14790 | } |
| 13741 | ok_align = get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, slice_ptr_type); | 14791 | ok_align = get_ptr_align(ira->codegen, actual_type) >= get_ptr_align(ira->codegen, slice_ptr_type); |
| 13742 | } | 14792 | } |
| ... | @@ -13777,7 +14827,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13777,7 +14827,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13777 | } | 14827 | } |
| 13778 | } | 14828 | } |
| 13779 | if (ok) { | 14829 | if (ok) { |
| 13780 | IrInstruction *cast1 = ir_analyze_frame_ptr_to_anyframe(ira, source_instr, value, anyframe_type); | 14830 | IrInstGen *cast1 = ir_analyze_frame_ptr_to_anyframe(ira, source_instr, value, anyframe_type); |
| 13781 | if (anyframe_type == wanted_type) | 14831 | if (anyframe_type == wanted_type) |
| 13782 | return cast1; | 14832 | return cast1; |
| 13783 | return ir_analyze_cast(ira, source_instr, wanted_type, cast1); | 14833 | return ir_analyze_cast(ira, source_instr, wanted_type, cast1); |
| ... | @@ -13832,28 +14882,28 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13832,28 +14882,28 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13832 | if (actual_type->id == ZigTypeIdEnumLiteral && | 14882 | if (actual_type->id == ZigTypeIdEnumLiteral && |
| 13833 | (wanted_type->id == ZigTypeIdOptional && wanted_type->data.maybe.child_type->id == ZigTypeIdEnum)) | 14883 | (wanted_type->id == ZigTypeIdOptional && wanted_type->data.maybe.child_type->id == ZigTypeIdEnum)) |
| 13834 | { | 14884 | { |
| 13835 | IrInstruction *result = ir_analyze_enum_literal(ira, source_instr, value, wanted_type->data.maybe.child_type); | 14885 | IrInstGen *result = ir_analyze_enum_literal(ira, source_instr, value, wanted_type->data.maybe.child_type); |
| 13836 | if (result == ira->codegen->invalid_instruction) | 14886 | if (type_is_invalid(result->value->type)) |
| 13837 | return result; | 14887 | return result; |
| 13838 | | 14888 | |
| 13839 | return ir_analyze_optional_wrap(ira, result, value, wanted_type, nullptr); | 14889 | return ir_analyze_optional_wrap(ira, source_instr, value, wanted_type, nullptr); |
| 13840 | } | 14890 | } |
| 13841 | | 14891 | |
| 13842 | // cast from enum literal to error union when payload is an enum | 14892 | // cast from enum literal to error union when payload is an enum |
| 13843 | if (actual_type->id == ZigTypeIdEnumLiteral && | 14893 | if (actual_type->id == ZigTypeIdEnumLiteral && |
| 13844 | (wanted_type->id == ZigTypeIdErrorUnion && wanted_type->data.error_union.payload_type->id == ZigTypeIdEnum)) | 14894 | (wanted_type->id == ZigTypeIdErrorUnion && wanted_type->data.error_union.payload_type->id == ZigTypeIdEnum)) |
| 13845 | { | 14895 | { |
| 13846 | IrInstruction *result = ir_analyze_enum_literal(ira, source_instr, value, wanted_type->data.error_union.payload_type); | 14896 | IrInstGen *result = ir_analyze_enum_literal(ira, source_instr, value, wanted_type->data.error_union.payload_type); |
| 13847 | if (result == ira->codegen->invalid_instruction) | 14897 | if (type_is_invalid(result->value->type)) |
| 13848 | return result; | 14898 | return result; |
| 13849 | | 14899 | |
| 13850 | return ir_analyze_err_wrap_payload(ira, result, value, wanted_type, nullptr); | 14900 | return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type, nullptr); |
| 13851 | } | 14901 | } |
| 13852 | | 14902 | |
| 13853 | // cast from union to the enum type of the union | 14903 | // cast from union to the enum type of the union |
| 13854 | if (actual_type->id == ZigTypeIdUnion && wanted_type->id == ZigTypeIdEnum) { | 14904 | if (actual_type->id == ZigTypeIdUnion && wanted_type->id == ZigTypeIdEnum) { |
| 13855 | if ((err = type_resolve(ira->codegen, actual_type, ResolveStatusZeroBitsKnown))) | 14905 | if ((err = type_resolve(ira->codegen, actual_type, ResolveStatusZeroBitsKnown))) |
| 13856 | return ira->codegen->invalid_instruction; | 14906 | return ira->codegen->invalid_inst_gen; |
| 13857 | | 14907 | |
| 13858 | if (actual_type->data.unionation.tag_type == wanted_type) { | 14908 | if (actual_type->data.unionation.tag_type == wanted_type) { |
| 13859 | return ir_analyze_union_to_tag(ira, source_instr, value, wanted_type); | 14909 | return ir_analyze_union_to_tag(ira, source_instr, value, wanted_type); |
| ... | @@ -13881,8 +14931,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13881,8 +14931,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13881 | (!actual_type->data.pointer.is_const || wanted_type->data.pointer.is_const) && | 14931 | (!actual_type->data.pointer.is_const || wanted_type->data.pointer.is_const) && |
| 13882 | (!actual_type->data.pointer.is_volatile || wanted_type->data.pointer.is_volatile)) | 14932 | (!actual_type->data.pointer.is_volatile || wanted_type->data.pointer.is_volatile)) |
| 13883 | { | 14933 | { |
| 13884 | if ((err = ir_cast_ptr_align(ira, source_instr, wanted_type, actual_type, value->source_node))) | 14934 | if ((err = ir_cast_ptr_align(ira, source_instr, wanted_type, actual_type, value->base.source_node))) |
| 13885 | return ira->codegen->invalid_instruction; | 14935 | return ira->codegen->invalid_inst_gen; |
| 13886 | | 14936 | |
| 13887 | return ir_analyze_ptr_to_array(ira, source_instr, value, wanted_type); | 14937 | return ir_analyze_ptr_to_array(ira, source_instr, value, wanted_type); |
| 13888 | } | 14938 | } |
| ... | @@ -13905,7 +14955,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13905,7 +14955,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13905 | slice_ptr_type->data.pointer.sentinel)))) | 14955 | slice_ptr_type->data.pointer.sentinel)))) |
| 13906 | { | 14956 | { |
| 13907 | TypeStructField *ptr_field = actual_type->data.structure.fields[slice_ptr_index]; | 14957 | TypeStructField *ptr_field = actual_type->data.structure.fields[slice_ptr_index]; |
| 13908 | IrInstruction *slice_ptr = ir_analyze_struct_value_field_value(ira, source_instr, value, ptr_field); | 14958 | IrInstGen *slice_ptr = ir_analyze_struct_value_field_value(ira, source_instr, value, ptr_field); |
| 13909 | return ir_implicit_cast2(ira, source_instr, slice_ptr, wanted_type); | 14959 | return ir_implicit_cast2(ira, source_instr, slice_ptr, wanted_type); |
| 13910 | } | 14960 | } |
| 13911 | } | 14961 | } |
| ... | @@ -13936,7 +14986,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -13936,7 +14986,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 13936 | { | 14986 | { |
| 13937 | bool has_bits; | 14987 | bool has_bits; |
| 13938 | if ((err = type_has_bits2(ira->codegen, actual_type, &has_bits))) | 14988 | if ((err = type_has_bits2(ira->codegen, actual_type, &has_bits))) |
| 13939 | return ira->codegen->invalid_instruction; | 14989 | return ira->codegen->invalid_inst_gen; |
| 13940 | if (!has_bits) { | 14990 | if (!has_bits) { |
| 13941 | return ir_get_ref(ira, source_instr, value, false, false); | 14991 | return ir_get_ref(ira, source_instr, value, false, false); |
| 13942 | } | 14992 | } |
| ... | @@ -14003,9 +15053,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -14003,9 +15053,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 14003 | | 15053 | |
| 14004 | // T to ?U, where T implicitly casts to U | 15054 | // T to ?U, where T implicitly casts to U |
| 14005 | if (wanted_type->id == ZigTypeIdOptional && actual_type->id != ZigTypeIdOptional) { | 15055 | if (wanted_type->id == ZigTypeIdOptional && actual_type->id != ZigTypeIdOptional) { |
| 14006 | IrInstruction *cast1 = ir_implicit_cast2(ira, source_instr, value, wanted_type->data.maybe.child_type); | 15056 | IrInstGen *cast1 = ir_implicit_cast2(ira, source_instr, value, wanted_type->data.maybe.child_type); |
| 14007 | if (type_is_invalid(cast1->value->type)) | 15057 | if (type_is_invalid(cast1->value->type)) |
| 14008 | return ira->codegen->invalid_instruction; | 15058 | return ira->codegen->invalid_inst_gen; |
| 14009 | return ir_implicit_cast2(ira, source_instr, cast1, wanted_type); | 15059 | return ir_implicit_cast2(ira, source_instr, cast1, wanted_type); |
| 14010 | } | 15060 | } |
| 14011 | | 15061 | |
| ... | @@ -14013,9 +15063,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -14013,9 +15063,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 14013 | if (wanted_type->id == ZigTypeIdErrorUnion && actual_type->id != ZigTypeIdErrorUnion && | 15063 | if (wanted_type->id == ZigTypeIdErrorUnion && actual_type->id != ZigTypeIdErrorUnion && |
| 14014 | actual_type->id != ZigTypeIdErrorSet) | 15064 | actual_type->id != ZigTypeIdErrorSet) |
| 14015 | { | 15065 | { |
| 14016 | IrInstruction *cast1 = ir_implicit_cast2(ira, source_instr, value, wanted_type->data.error_union.payload_type); | 15066 | IrInstGen *cast1 = ir_implicit_cast2(ira, source_instr, value, wanted_type->data.error_union.payload_type); |
| 14017 | if (type_is_invalid(cast1->value->type)) | 15067 | if (type_is_invalid(cast1->value->type)) |
| 14018 | return ira->codegen->invalid_instruction; | 15068 | return ira->codegen->invalid_inst_gen; |
| 14019 | return ir_implicit_cast2(ira, source_instr, cast1, wanted_type); | 15069 | return ir_implicit_cast2(ira, source_instr, cast1, wanted_type); |
| 14020 | } | 15070 | } |
| 14021 | | 15071 | |
| ... | @@ -14024,14 +15074,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst | ... | @@ -14024,14 +15074,13 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 14024 | buf_ptr(&wanted_type->name), | 15074 | buf_ptr(&wanted_type->name), |
| 14025 | buf_ptr(&actual_type->name))); | 15075 | buf_ptr(&actual_type->name))); |
| 14026 | report_recursive_error(ira, source_instr->source_node, &const_cast_result, parent_msg); | 15076 | report_recursive_error(ira, source_instr->source_node, &const_cast_result, parent_msg); |
| 14027 | return ira->codegen->invalid_instruction; | 15077 | return ira->codegen->invalid_inst_gen; |
| 14028 | } | 15078 | } |
| 14029 | | 15079 | |
| 14030 | static IrInstruction *ir_implicit_cast2(IrAnalyze *ira, IrInstruction *value_source_instr, | 15080 | static IrInstGen *ir_implicit_cast2(IrAnalyze *ira, IrInst *value_source_instr, |
| 14031 | IrInstruction *value, ZigType *expected_type) | 15081 | IrInstGen *value, ZigType *expected_type) |
| 14032 | { | 15082 | { |
| 14033 | assert(value); | 15083 | assert(value); |
| 14034 | assert(value != ira->codegen->invalid_instruction); | | |
| 14035 | assert(!expected_type || !type_is_invalid(expected_type)); | 15084 | assert(!expected_type || !type_is_invalid(expected_type)); |
| 14036 | assert(value->value->type); | 15085 | assert(value->value->type); |
| 14037 | assert(!type_is_invalid(value->value->type)); | 15086 | assert(!type_is_invalid(value->value->type)); |
| ... | @@ -14045,17 +15094,17 @@ static IrInstruction *ir_implicit_cast2(IrAnalyze *ira, IrInstruction *value_sou | ... | @@ -14045,17 +15094,17 @@ static IrInstruction *ir_implicit_cast2(IrAnalyze *ira, IrInstruction *value_sou |
| 14045 | return ir_analyze_cast(ira, value_source_instr, expected_type, value); | 15094 | return ir_analyze_cast(ira, value_source_instr, expected_type, value); |
| 14046 | } | 15095 | } |
| 14047 | | 15096 | |
| 14048 | static IrInstruction *ir_implicit_cast(IrAnalyze *ira, IrInstruction *value, ZigType *expected_type) { | 15097 | static IrInstGen *ir_implicit_cast(IrAnalyze *ira, IrInstGen *value, ZigType *expected_type) { |
| 14049 | return ir_implicit_cast2(ira, value, value, expected_type); | 15098 | return ir_implicit_cast2(ira, &value->base, value, expected_type); |
| 14050 | } | 15099 | } |
| 14051 | | 15100 | |
| 14052 | static ZigType *get_ptr_elem_type(CodeGen *g, IrInstruction *ptr) { | 15101 | static ZigType *get_ptr_elem_type(CodeGen *g, IrInstGen *ptr) { |
| 14053 | ir_assert(ptr->value->type->id == ZigTypeIdPointer, ptr); | 15102 | ir_assert_gen(ptr->value->type->id == ZigTypeIdPointer, ptr); |
| 14054 | ZigType *elem_type = ptr->value->type->data.pointer.child_type; | 15103 | ZigType *elem_type = ptr->value->type->data.pointer.child_type; |
| 14055 | if (elem_type != g->builtin_types.entry_var) | 15104 | if (elem_type != g->builtin_types.entry_var) |
| 14056 | return elem_type; | 15105 | return elem_type; |
| 14057 | | 15106 | |
| 14058 | if (ir_resolve_lazy(g, ptr->source_node, ptr->value)) | 15107 | if (ir_resolve_lazy(g, ptr->base.source_node, ptr->value)) |
| 14059 | return g->builtin_types.entry_invalid; | 15108 | return g->builtin_types.entry_invalid; |
| 14060 | | 15109 | |
| 14061 | assert(value_is_comptime(ptr->value)); | 15110 | assert(value_is_comptime(ptr->value)); |
| ... | @@ -14063,28 +15112,28 @@ static ZigType *get_ptr_elem_type(CodeGen *g, IrInstruction *ptr) { | ... | @@ -14063,28 +15112,28 @@ static ZigType *get_ptr_elem_type(CodeGen *g, IrInstruction *ptr) { |
| 14063 | return pointee->type; | 15112 | return pointee->type; |
| 14064 | } | 15113 | } |
| 14065 | | 15114 | |
| 14066 | static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruction, IrInstruction *ptr, | 15115 | static IrInstGen *ir_get_deref(IrAnalyze *ira, IrInst* source_instruction, IrInstGen *ptr, |
| 14067 | ResultLoc *result_loc) | 15116 | ResultLoc *result_loc) |
| 14068 | { | 15117 | { |
| 14069 | Error err; | 15118 | Error err; |
| 14070 | ZigType *ptr_type = ptr->value->type; | 15119 | ZigType *ptr_type = ptr->value->type; |
| 14071 | if (type_is_invalid(ptr_type)) | 15120 | if (type_is_invalid(ptr_type)) |
| 14072 | return ira->codegen->invalid_instruction; | 15121 | return ira->codegen->invalid_inst_gen; |
| 14073 | | 15122 | |
| 14074 | if (ptr_type->id != ZigTypeIdPointer) { | 15123 | if (ptr_type->id != ZigTypeIdPointer) { |
| 14075 | ir_add_error_node(ira, source_instruction->source_node, | 15124 | ir_add_error_node(ira, source_instruction->source_node, |
| 14076 | buf_sprintf("attempt to dereference non-pointer type '%s'", | 15125 | buf_sprintf("attempt to dereference non-pointer type '%s'", |
| 14077 | buf_ptr(&ptr_type->name))); | 15126 | buf_ptr(&ptr_type->name))); |
| 14078 | return ira->codegen->invalid_instruction; | 15127 | return ira->codegen->invalid_inst_gen; |
| 14079 | } | 15128 | } |
| 14080 | | 15129 | |
| 14081 | ZigType *child_type = ptr_type->data.pointer.child_type; | 15130 | ZigType *child_type = ptr_type->data.pointer.child_type; |
| 14082 | if (type_is_invalid(child_type)) | 15131 | if (type_is_invalid(child_type)) |
| 14083 | return ira->codegen->invalid_instruction; | 15132 | return ira->codegen->invalid_inst_gen; |
| 14084 | // if the child type has one possible value, the deref is comptime | 15133 | // if the child type has one possible value, the deref is comptime |
| 14085 | switch (type_has_one_possible_value(ira->codegen, child_type)) { | 15134 | switch (type_has_one_possible_value(ira->codegen, child_type)) { |
| 14086 | case OnePossibleValueInvalid: | 15135 | case OnePossibleValueInvalid: |
| 14087 | return ira->codegen->invalid_instruction; | 15136 | return ira->codegen->invalid_inst_gen; |
| 14088 | case OnePossibleValueYes: | 15137 | case OnePossibleValueYes: |
| 14089 | return ir_const_move(ira, source_instruction, | 15138 | return ir_const_move(ira, source_instruction, |
| 14090 | get_the_one_possible_value(ira->codegen, child_type)); | 15139 | get_the_one_possible_value(ira->codegen, child_type)); |
| ... | @@ -14093,8 +15142,8 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -14093,8 +15142,8 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 14093 | } | 15142 | } |
| 14094 | if (instr_is_comptime(ptr)) { | 15143 | if (instr_is_comptime(ptr)) { |
| 14095 | if (ptr->value->special == ConstValSpecialUndef) { | 15144 | if (ptr->value->special == ConstValSpecialUndef) { |
| 14096 | ir_add_error(ira, ptr, buf_sprintf("attempt to dereference undefined value")); | 15145 | ir_add_error(ira, &ptr->base, buf_sprintf("attempt to dereference undefined value")); |
| 14097 | return ira->codegen->invalid_instruction; | 15146 | return ira->codegen->invalid_inst_gen; |
| 14098 | } | 15147 | } |
| 14099 | if (ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 15148 | if (ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 14100 | ZigValue *pointee = const_ptr_pointee_unchecked(ira->codegen, ptr->value); | 15149 | ZigValue *pointee = const_ptr_pointee_unchecked(ira->codegen, ptr->value); |
| ... | @@ -14102,12 +15151,12 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -14102,12 +15151,12 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 14102 | child_type = pointee->type; | 15151 | child_type = pointee->type; |
| 14103 | } | 15152 | } |
| 14104 | if (pointee->special != ConstValSpecialRuntime) { | 15153 | if (pointee->special != ConstValSpecialRuntime) { |
| 14105 | IrInstruction *result = ir_const(ira, source_instruction, child_type); | 15154 | IrInstGen *result = ir_const(ira, source_instruction, child_type); |
| 14106 | | 15155 | |
| 14107 | if ((err = ir_read_const_ptr(ira, ira->codegen, source_instruction->source_node, result->value, | 15156 | if ((err = ir_read_const_ptr(ira, ira->codegen, source_instruction->source_node, result->value, |
| 14108 | ptr->value))) | 15157 | ptr->value))) |
| 14109 | { | 15158 | { |
| 14110 | return ira->codegen->invalid_instruction; | 15159 | return ira->codegen->invalid_inst_gen; |
| 14111 | } | 15160 | } |
| 14112 | result->value->type = child_type; | 15161 | result->value->type = child_type; |
| 14113 | return result; | 15162 | return result; |
| ... | @@ -14116,38 +15165,38 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -14116,38 +15165,38 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 14116 | } | 15165 | } |
| 14117 | | 15166 | |
| 14118 | // if the instruction is a const ref instruction we can skip it | 15167 | // if the instruction is a const ref instruction we can skip it |
| 14119 | if (ptr->id == IrInstructionIdRef) { | 15168 | if (ptr->id == IrInstGenIdRef) { |
| 14120 | IrInstructionRef *ref_inst = reinterpret_cast<IrInstructionRef *>(ptr); | 15169 | IrInstGenRef *ref_inst = reinterpret_cast<IrInstGenRef *>(ptr); |
| 14121 | return ref_inst->value; | 15170 | return ref_inst->operand; |
| 14122 | } | 15171 | } |
| 14123 | | 15172 | |
| 14124 | // If the instruction is a element pointer instruction to a vector, we emit | 15173 | // If the instruction is a element pointer instruction to a vector, we emit |
| 14125 | // vector element extract instruction rather than load pointer. If the | 15174 | // vector element extract instruction rather than load pointer. If the |
| 14126 | // pointer type has non-VECTOR_INDEX_RUNTIME value, it would have been | 15175 | // pointer type has non-VECTOR_INDEX_RUNTIME value, it would have been |
| 14127 | // possible to implement this in the codegen for IrInstructionLoadPtrGen. | 15176 | // possible to implement this in the codegen for IrInstGenLoadPtr. |
| 14128 | // However if it has VECTOR_INDEX_RUNTIME then we must emit a compile error | 15177 | // However if it has VECTOR_INDEX_RUNTIME then we must emit a compile error |
| 14129 | // if the vector index cannot be determined right here, right now, because | 15178 | // if the vector index cannot be determined right here, right now, because |
| 14130 | // the type information does not contain enough information to actually | 15179 | // the type information does not contain enough information to actually |
| 14131 | // perform a dereference. | 15180 | // perform a dereference. |
| 14132 | if (ptr_type->data.pointer.vector_index == VECTOR_INDEX_RUNTIME) { | 15181 | if (ptr_type->data.pointer.vector_index == VECTOR_INDEX_RUNTIME) { |
| 14133 | if (ptr->id == IrInstructionIdElemPtr) { | 15182 | if (ptr->id == IrInstGenIdElemPtr) { |
| 14134 | IrInstructionElemPtr *elem_ptr = (IrInstructionElemPtr *)ptr; | 15183 | IrInstGenElemPtr *elem_ptr = (IrInstGenElemPtr *)ptr; |
| 14135 | IrInstruction *vector_loaded = ir_get_deref(ira, elem_ptr->array_ptr, | 15184 | IrInstGen *vector_loaded = ir_get_deref(ira, &elem_ptr->array_ptr->base, |
| 14136 | elem_ptr->array_ptr, nullptr); | 15185 | elem_ptr->array_ptr, nullptr); |
| 14137 | IrInstruction *elem_index = elem_ptr->elem_index; | 15186 | IrInstGen *elem_index = elem_ptr->elem_index; |
| 14138 | return ir_build_vector_extract_elem(ira, source_instruction, vector_loaded, elem_index); | 15187 | return ir_build_vector_extract_elem(ira, source_instruction, vector_loaded, elem_index); |
| 14139 | } | 15188 | } |
| 14140 | ir_add_error(ira, ptr, | 15189 | ir_add_error(ira, &ptr->base, |
| 14141 | buf_sprintf("unable to determine vector element index of type '%s'", buf_ptr(&ptr_type->name))); | 15190 | buf_sprintf("unable to determine vector element index of type '%s'", buf_ptr(&ptr_type->name))); |
| 14142 | return ira->codegen->invalid_instruction; | 15191 | return ira->codegen->invalid_inst_gen; |
| 14143 | } | 15192 | } |
| 14144 | | 15193 | |
| 14145 | IrInstruction *result_loc_inst; | 15194 | IrInstGen *result_loc_inst; |
| 14146 | if (ptr_type->data.pointer.host_int_bytes != 0 && handle_is_ptr(child_type)) { | 15195 | if (ptr_type->data.pointer.host_int_bytes != 0 && handle_is_ptr(child_type)) { |
| 14147 | if (result_loc == nullptr) result_loc = no_result_loc(); | 15196 | if (result_loc == nullptr) result_loc = no_result_loc(); |
| 14148 | result_loc_inst = ir_resolve_result(ira, source_instruction, result_loc, child_type, nullptr, | 15197 | result_loc_inst = ir_resolve_result(ira, source_instruction, result_loc, child_type, nullptr, |
| 14149 | true, false, true); | 15198 | true, false, true); |
| 14150 | if (type_is_invalid(result_loc_inst->value->type) || instr_is_unreachable(result_loc_inst)) { | 15199 | if (type_is_invalid(result_loc_inst->value->type) || result_loc_inst->value->type->id == ZigTypeIdUnreachable) { |
| 14151 | return result_loc_inst; | 15200 | return result_loc_inst; |
| 14152 | } | 15201 | } |
| 14153 | } else { | 15202 | } else { |
| ... | @@ -14157,7 +15206,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc | ... | @@ -14157,7 +15206,7 @@ static IrInstruction *ir_get_deref(IrAnalyze *ira, IrInstruction *source_instruc |
| 14157 | return ir_build_load_ptr_gen(ira, source_instruction, ptr, child_type, result_loc_inst); | 15206 | return ir_build_load_ptr_gen(ira, source_instruction, ptr, child_type, result_loc_inst); |
| 14158 | } | 15207 | } |
| 14159 | | 15208 | |
| 14160 | static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode *source_node, | 15209 | static bool ir_resolve_const_align(CodeGen *codegen, IrExecutableGen *exec, AstNode *source_node, |
| 14161 | ZigValue *const_val, uint32_t *out) | 15210 | ZigValue *const_val, uint32_t *out) |
| 14162 | { | 15211 | { |
| 14163 | Error err; | 15212 | Error err; |
| ... | @@ -14166,12 +15215,12 @@ static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode | ... | @@ -14166,12 +15215,12 @@ static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode |
| 14166 | | 15215 | |
| 14167 | uint32_t align_bytes = bigint_as_u32(&const_val->data.x_bigint); | 15216 | uint32_t align_bytes = bigint_as_u32(&const_val->data.x_bigint); |
| 14168 | if (align_bytes == 0) { | 15217 | if (align_bytes == 0) { |
| 14169 | exec_add_error_node(codegen, exec, source_node, buf_sprintf("alignment must be >= 1")); | 15218 | exec_add_error_node_gen(codegen, exec, source_node, buf_sprintf("alignment must be >= 1")); |
| 14170 | return false; | 15219 | return false; |
| 14171 | } | 15220 | } |
| 14172 | | 15221 | |
| 14173 | if (!is_power_of_2(align_bytes)) { | 15222 | if (!is_power_of_2(align_bytes)) { |
| 14174 | exec_add_error_node(codegen, exec, source_node, | 15223 | exec_add_error_node_gen(codegen, exec, source_node, |
| 14175 | buf_sprintf("alignment value %" PRIu32 " is not a power of 2", align_bytes)); | 15224 | buf_sprintf("alignment value %" PRIu32 " is not a power of 2", align_bytes)); |
| 14176 | return false; | 15225 | return false; |
| 14177 | } | 15226 | } |
| ... | @@ -14180,7 +15229,7 @@ static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode | ... | @@ -14180,7 +15229,7 @@ static bool ir_resolve_const_align(CodeGen *codegen, IrExecutable *exec, AstNode |
| 14180 | return true; | 15229 | return true; |
| 14181 | } | 15230 | } |
| 14182 | | 15231 | |
| 14183 | static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem_type, uint32_t *out) { | 15232 | static bool ir_resolve_align(IrAnalyze *ira, IrInstGen *value, ZigType *elem_type, uint32_t *out) { |
| 14184 | if (type_is_invalid(value->value->type)) | 15233 | if (type_is_invalid(value->value->type)) |
| 14185 | return false; | 15234 | return false; |
| 14186 | | 15235 | |
| ... | @@ -14201,19 +15250,19 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem | ... | @@ -14201,19 +15250,19 @@ static bool ir_resolve_align(IrAnalyze *ira, IrInstruction *value, ZigType *elem |
| 14201 | } | 15250 | } |
| 14202 | } | 15251 | } |
| 14203 | | 15252 | |
| 14204 | IrInstruction *casted_value = ir_implicit_cast(ira, value, get_align_amt_type(ira->codegen)); | 15253 | IrInstGen *casted_value = ir_implicit_cast(ira, value, get_align_amt_type(ira->codegen)); |
| 14205 | if (type_is_invalid(casted_value->value->type)) | 15254 | if (type_is_invalid(casted_value->value->type)) |
| 14206 | return false; | 15255 | return false; |
| 14207 | | 15256 | |
| 14208 | return ir_resolve_const_align(ira->codegen, ira->new_irb.exec, value->source_node, | 15257 | return ir_resolve_const_align(ira->codegen, ira->new_irb.exec, value->base.source_node, |
| 14209 | casted_value->value, out); | 15258 | casted_value->value, out); |
| 14210 | } | 15259 | } |
| 14211 | | 15260 | |
| 14212 | static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *int_type, uint64_t *out) { | 15261 | static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstGen *value, ZigType *int_type, uint64_t *out) { |
| 14213 | if (type_is_invalid(value->value->type)) | 15262 | if (type_is_invalid(value->value->type)) |
| 14214 | return false; | 15263 | return false; |
| 14215 | | 15264 | |
| 14216 | IrInstruction *casted_value = ir_implicit_cast(ira, value, int_type); | 15265 | IrInstGen *casted_value = ir_implicit_cast(ira, value, int_type); |
| 14217 | if (type_is_invalid(casted_value->value->type)) | 15266 | if (type_is_invalid(casted_value->value->type)) |
| 14218 | return false; | 15267 | return false; |
| 14219 | | 15268 | |
| ... | @@ -14225,15 +15274,15 @@ static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *i | ... | @@ -14225,15 +15274,15 @@ static bool ir_resolve_unsigned(IrAnalyze *ira, IrInstruction *value, ZigType *i |
| 14225 | return true; | 15274 | return true; |
| 14226 | } | 15275 | } |
| 14227 | | 15276 | |
| 14228 | static bool ir_resolve_usize(IrAnalyze *ira, IrInstruction *value, uint64_t *out) { | 15277 | static bool ir_resolve_usize(IrAnalyze *ira, IrInstGen *value, uint64_t *out) { |
| 14229 | return ir_resolve_unsigned(ira, value, ira->codegen->builtin_types.entry_usize, out); | 15278 | return ir_resolve_unsigned(ira, value, ira->codegen->builtin_types.entry_usize, out); |
| 14230 | } | 15279 | } |
| 14231 | | 15280 | |
| 14232 | static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) { | 15281 | static bool ir_resolve_bool(IrAnalyze *ira, IrInstGen *value, bool *out) { |
| 14233 | if (type_is_invalid(value->value->type)) | 15282 | if (type_is_invalid(value->value->type)) |
| 14234 | return false; | 15283 | return false; |
| 14235 | | 15284 | |
| 14236 | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_bool); | 15285 | IrInstGen *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_bool); |
| 14237 | if (type_is_invalid(casted_value->value->type)) | 15286 | if (type_is_invalid(casted_value->value->type)) |
| 14238 | return false; | 15287 | return false; |
| 14239 | | 15288 | |
| ... | @@ -14245,7 +15294,7 @@ static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) { | ... | @@ -14245,7 +15294,7 @@ static bool ir_resolve_bool(IrAnalyze *ira, IrInstruction *value, bool *out) { |
| 14245 | return true; | 15294 | return true; |
| 14246 | } | 15295 | } |
| 14247 | | 15296 | |
| 14248 | static bool ir_resolve_comptime(IrAnalyze *ira, IrInstruction *value, bool *out) { | 15297 | static bool ir_resolve_comptime(IrAnalyze *ira, IrInstGen *value, bool *out) { |
| 14249 | if (!value) { | 15298 | if (!value) { |
| 14250 | *out = false; | 15299 | *out = false; |
| 14251 | return true; | 15300 | return true; |
| ... | @@ -14253,13 +15302,13 @@ static bool ir_resolve_comptime(IrAnalyze *ira, IrInstruction *value, bool *out) | ... | @@ -14253,13 +15302,13 @@ static bool ir_resolve_comptime(IrAnalyze *ira, IrInstruction *value, bool *out) |
| 14253 | return ir_resolve_bool(ira, value, out); | 15302 | return ir_resolve_bool(ira, value, out); |
| 14254 | } | 15303 | } |
| 14255 | | 15304 | |
| 14256 | static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, AtomicOrder *out) { | 15305 | static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstGen *value, AtomicOrder *out) { |
| 14257 | if (type_is_invalid(value->value->type)) | 15306 | if (type_is_invalid(value->value->type)) |
| 14258 | return false; | 15307 | return false; |
| 14259 | | 15308 | |
| 14260 | ZigType *atomic_order_type = get_builtin_type(ira->codegen, "AtomicOrder"); | 15309 | ZigType *atomic_order_type = get_builtin_type(ira->codegen, "AtomicOrder"); |
| 14261 | | 15310 | |
| 14262 | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_order_type); | 15311 | IrInstGen *casted_value = ir_implicit_cast(ira, value, atomic_order_type); |
| 14263 | if (type_is_invalid(casted_value->value->type)) | 15312 | if (type_is_invalid(casted_value->value->type)) |
| 14264 | return false; | 15313 | return false; |
| 14265 | | 15314 | |
| ... | @@ -14271,13 +15320,13 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic | ... | @@ -14271,13 +15320,13 @@ static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, Atomic |
| 14271 | return true; | 15320 | return true; |
| 14272 | } | 15321 | } |
| 14273 | | 15322 | |
| 14274 | static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, AtomicRmwOp *out) { | 15323 | static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstGen *value, AtomicRmwOp *out) { |
| 14275 | if (type_is_invalid(value->value->type)) | 15324 | if (type_is_invalid(value->value->type)) |
| 14276 | return false; | 15325 | return false; |
| 14277 | | 15326 | |
| 14278 | ZigType *atomic_rmw_op_type = get_builtin_type(ira->codegen, "AtomicRmwOp"); | 15327 | ZigType *atomic_rmw_op_type = get_builtin_type(ira->codegen, "AtomicRmwOp"); |
| 14279 | | 15328 | |
| 14280 | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type); | 15329 | IrInstGen *casted_value = ir_implicit_cast(ira, value, atomic_rmw_op_type); |
| 14281 | if (type_is_invalid(casted_value->value->type)) | 15330 | if (type_is_invalid(casted_value->value->type)) |
| 14282 | return false; | 15331 | return false; |
| 14283 | | 15332 | |
| ... | @@ -14289,13 +15338,13 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi | ... | @@ -14289,13 +15338,13 @@ static bool ir_resolve_atomic_rmw_op(IrAnalyze *ira, IrInstruction *value, Atomi |
| 14289 | return true; | 15338 | return true; |
| 14290 | } | 15339 | } |
| 14291 | | 15340 | |
| 14292 | static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, GlobalLinkageId *out) { | 15341 | static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstGen *value, GlobalLinkageId *out) { |
| 14293 | if (type_is_invalid(value->value->type)) | 15342 | if (type_is_invalid(value->value->type)) |
| 14294 | return false; | 15343 | return false; |
| 14295 | | 15344 | |
| 14296 | ZigType *global_linkage_type = get_builtin_type(ira->codegen, "GlobalLinkage"); | 15345 | ZigType *global_linkage_type = get_builtin_type(ira->codegen, "GlobalLinkage"); |
| 14297 | | 15346 | |
| 14298 | IrInstruction *casted_value = ir_implicit_cast(ira, value, global_linkage_type); | 15347 | IrInstGen *casted_value = ir_implicit_cast(ira, value, global_linkage_type); |
| 14299 | if (type_is_invalid(casted_value->value->type)) | 15348 | if (type_is_invalid(casted_value->value->type)) |
| 14300 | return false; | 15349 | return false; |
| 14301 | | 15350 | |
| ... | @@ -14307,13 +15356,13 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob | ... | @@ -14307,13 +15356,13 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob |
| 14307 | return true; | 15356 | return true; |
| 14308 | } | 15357 | } |
| 14309 | | 15358 | |
| 14310 | static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMode *out) { | 15359 | static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstGen *value, FloatMode *out) { |
| 14311 | if (type_is_invalid(value->value->type)) | 15360 | if (type_is_invalid(value->value->type)) |
| 14312 | return false; | 15361 | return false; |
| 14313 | | 15362 | |
| 14314 | ZigType *float_mode_type = get_builtin_type(ira->codegen, "FloatMode"); | 15363 | ZigType *float_mode_type = get_builtin_type(ira->codegen, "FloatMode"); |
| 14315 | | 15364 | |
| 14316 | IrInstruction *casted_value = ir_implicit_cast(ira, value, float_mode_type); | 15365 | IrInstGen *casted_value = ir_implicit_cast(ira, value, float_mode_type); |
| 14317 | if (type_is_invalid(casted_value->value->type)) | 15366 | if (type_is_invalid(casted_value->value->type)) |
| 14318 | return false; | 15367 | return false; |
| 14319 | | 15368 | |
| ... | @@ -14325,14 +15374,14 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod | ... | @@ -14325,14 +15374,14 @@ static bool ir_resolve_float_mode(IrAnalyze *ira, IrInstruction *value, FloatMod |
| 14325 | return true; | 15374 | return true; |
| 14326 | } | 15375 | } |
| 14327 | | 15376 | |
| 14328 | static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { | 15377 | static Buf *ir_resolve_str(IrAnalyze *ira, IrInstGen *value) { |
| 14329 | if (type_is_invalid(value->value->type)) | 15378 | if (type_is_invalid(value->value->type)) |
| 14330 | return nullptr; | 15379 | return nullptr; |
| 14331 | | 15380 | |
| 14332 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, | 15381 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 14333 | true, false, PtrLenUnknown, 0, 0, 0, false); | 15382 | true, false, PtrLenUnknown, 0, 0, 0, false); |
| 14334 | ZigType *str_type = get_slice_type(ira->codegen, ptr_type); | 15383 | ZigType *str_type = get_slice_type(ira->codegen, ptr_type); |
| 14335 | IrInstruction *casted_value = ir_implicit_cast(ira, value, str_type); | 15384 | IrInstGen *casted_value = ir_implicit_cast(ira, value, str_type); |
| 14336 | if (type_is_invalid(casted_value->value->type)) | 15385 | if (type_is_invalid(casted_value->value->type)) |
| 14337 | return nullptr; | 15386 | return nullptr; |
| 14338 | | 15387 | |
| ... | @@ -14356,7 +15405,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { | ... | @@ -14356,7 +15405,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { |
| 14356 | size_t new_index = ptr_field->data.x_ptr.data.base_array.elem_index + i; | 15405 | size_t new_index = ptr_field->data.x_ptr.data.base_array.elem_index + i; |
| 14357 | ZigValue *char_val = &array_val->data.x_array.data.s_none.elements[new_index]; | 15406 | ZigValue *char_val = &array_val->data.x_array.data.s_none.elements[new_index]; |
| 14358 | if (char_val->special == ConstValSpecialUndef) { | 15407 | if (char_val->special == ConstValSpecialUndef) { |
| 14359 | ir_add_error(ira, casted_value, buf_sprintf("use of undefined value")); | 15408 | ir_add_error(ira, &casted_value->base, buf_sprintf("use of undefined value")); |
| 14360 | return nullptr; | 15409 | return nullptr; |
| 14361 | } | 15410 | } |
| 14362 | uint64_t big_c = bigint_as_u64(&char_val->data.x_bigint); | 15411 | uint64_t big_c = bigint_as_u64(&char_val->data.x_bigint); |
| ... | @@ -14367,10 +15416,10 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { | ... | @@ -14367,10 +15416,10 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { |
| 14367 | return result; | 15416 | return result; |
| 14368 | } | 15417 | } |
| 14369 | | 15418 | |
| 14370 | static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze *ira, | 15419 | static IrInstGen *ir_analyze_instruction_add_implicit_return_type(IrAnalyze *ira, |
| 14371 | IrInstructionAddImplicitReturnType *instruction) | 15420 | IrInstSrcAddImplicitReturnType *instruction) |
| 14372 | { | 15421 | { |
| 14373 | IrInstruction *value = instruction->value->child; | 15422 | IrInstGen *value = instruction->value->child; |
| 14374 | if (type_is_invalid(value->value->type)) | 15423 | if (type_is_invalid(value->value->type)) |
| 14375 | return ir_unreach_error(ira); | 15424 | return ir_unreach_error(ira); |
| 14376 | | 15425 | |
| ... | @@ -14378,15 +15427,15 @@ static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze | ... | @@ -14378,15 +15427,15 @@ static IrInstruction *ir_analyze_instruction_add_implicit_return_type(IrAnalyze |
| 14378 | ira->src_implicit_return_type_list.append(value); | 15427 | ira->src_implicit_return_type_list.append(value); |
| 14379 | } | 15428 | } |
| 14380 | | 15429 | |
| 14381 | return ir_const_void(ira, &instruction->base); | 15430 | return ir_const_void(ira, &instruction->base.base); |
| 14382 | } | 15431 | } |
| 14383 | | 15432 | |
| 14384 | static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructionReturn *instruction) { | 15433 | static IrInstGen *ir_analyze_instruction_return(IrAnalyze *ira, IrInstSrcReturn *instruction) { |
| 14385 | IrInstruction *operand = instruction->operand->child; | 15434 | IrInstGen *operand = instruction->operand->child; |
| 14386 | if (type_is_invalid(operand->value->type)) | 15435 | if (type_is_invalid(operand->value->type)) |
| 14387 | return ir_unreach_error(ira); | 15436 | return ir_unreach_error(ira); |
| 14388 | | 15437 | |
| 14389 | IrInstruction *casted_operand = ir_implicit_cast(ira, operand, ira->explicit_return_type); | 15438 | IrInstGen *casted_operand = ir_implicit_cast(ira, operand, ira->explicit_return_type); |
| 14390 | if (type_is_invalid(casted_operand->value->type)) { | 15439 | if (type_is_invalid(casted_operand->value->type)) { |
| 14391 | AstNode *source_node = ira->explicit_return_type_source_node; | 15440 | AstNode *source_node = ira->explicit_return_type_source_node; |
| 14392 | if (source_node != nullptr) { | 15441 | if (source_node != nullptr) { |
| ... | @@ -14401,9 +15450,7 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio | ... | @@ -14401,9 +15450,7 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio |
| 14401 | handle_is_ptr(ira->explicit_return_type)) | 15450 | handle_is_ptr(ira->explicit_return_type)) |
| 14402 | { | 15451 | { |
| 14403 | // result location mechanism took care of it. | 15452 | // result location mechanism took care of it. |
| 14404 | IrInstruction *result = ir_build_return(&ira->new_irb, instruction->base.scope, | 15453 | IrInstGen *result = ir_build_return_gen(ira, &instruction->base.base, nullptr); |
| 14405 | instruction->base.source_node, nullptr); | | |
| 14406 | result->value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 14407 | return ir_finish_anal(ira, result); | 15454 | return ir_finish_anal(ira, result); |
| 14408 | } | 15455 | } |
| 14409 | | 15456 | |
| ... | @@ -14411,47 +15458,45 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio | ... | @@ -14411,47 +15458,45 @@ static IrInstruction *ir_analyze_instruction_return(IrAnalyze *ira, IrInstructio |
| 14411 | casted_operand->value->type->id == ZigTypeIdPointer && | 15458 | casted_operand->value->type->id == ZigTypeIdPointer && |
| 14412 | casted_operand->value->data.rh_ptr == RuntimeHintPtrStack) | 15459 | casted_operand->value->data.rh_ptr == RuntimeHintPtrStack) |
| 14413 | { | 15460 | { |
| 14414 | ir_add_error(ira, casted_operand, buf_sprintf("function returns address of local variable")); | 15461 | ir_add_error(ira, &casted_operand->base, buf_sprintf("function returns address of local variable")); |
| 14415 | return ir_unreach_error(ira); | 15462 | return ir_unreach_error(ira); |
| 14416 | } | 15463 | } |
| 14417 | | 15464 | |
| 14418 | IrInstruction *result = ir_build_return(&ira->new_irb, instruction->base.scope, | 15465 | IrInstGen *result = ir_build_return_gen(ira, &instruction->base.base, casted_operand); |
| 14419 | instruction->base.source_node, casted_operand); | | |
| 14420 | result->value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 14421 | return ir_finish_anal(ira, result); | 15466 | return ir_finish_anal(ira, result); |
| 14422 | } | 15467 | } |
| 14423 | | 15468 | |
| 14424 | static IrInstruction *ir_analyze_instruction_const(IrAnalyze *ira, IrInstructionConst *instruction) { | 15469 | static IrInstGen *ir_analyze_instruction_const(IrAnalyze *ira, IrInstSrcConst *instruction) { |
| 14425 | return ir_const_move(ira, &instruction->base, instruction->base.value); | 15470 | return ir_const_move(ira, &instruction->base.base, instruction->value); |
| 14426 | } | 15471 | } |
| 14427 | | 15472 | |
| 14428 | static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { | 15473 | static IrInstGen *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstSrcBinOp *bin_op_instruction) { |
| 14429 | IrInstruction *op1 = bin_op_instruction->op1->child; | 15474 | IrInstGen *op1 = bin_op_instruction->op1->child; |
| 14430 | if (type_is_invalid(op1->value->type)) | 15475 | if (type_is_invalid(op1->value->type)) |
| 14431 | return ira->codegen->invalid_instruction; | 15476 | return ira->codegen->invalid_inst_gen; |
| 14432 | | 15477 | |
| 14433 | IrInstruction *op2 = bin_op_instruction->op2->child; | 15478 | IrInstGen *op2 = bin_op_instruction->op2->child; |
| 14434 | if (type_is_invalid(op2->value->type)) | 15479 | if (type_is_invalid(op2->value->type)) |
| 14435 | return ira->codegen->invalid_instruction; | 15480 | return ira->codegen->invalid_inst_gen; |
| 14436 | | 15481 | |
| 14437 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; | 15482 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| 14438 | | 15483 | |
| 14439 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, bool_type); | 15484 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, bool_type); |
| 14440 | if (casted_op1 == ira->codegen->invalid_instruction) | 15485 | if (type_is_invalid(casted_op1->value->type)) |
| 14441 | return ira->codegen->invalid_instruction; | 15486 | return ira->codegen->invalid_inst_gen; |
| 14442 | | 15487 | |
| 14443 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, bool_type); | 15488 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, bool_type); |
| 14444 | if (casted_op2 == ira->codegen->invalid_instruction) | 15489 | if (type_is_invalid(casted_op2->value->type)) |
| 14445 | return ira->codegen->invalid_instruction; | 15490 | return ira->codegen->invalid_inst_gen; |
| 14446 | | 15491 | |
| 14447 | if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) { | 15492 | if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) { |
| 14448 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); | 15493 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); |
| 14449 | if (op1_val == nullptr) | 15494 | if (op1_val == nullptr) |
| 14450 | return ira->codegen->invalid_instruction; | 15495 | return ira->codegen->invalid_inst_gen; |
| 14451 | | 15496 | |
| 14452 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 15497 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 14453 | if (op2_val == nullptr) | 15498 | if (op2_val == nullptr) |
| 14454 | return ira->codegen->invalid_instruction; | 15499 | return ira->codegen->invalid_inst_gen; |
| 14455 | | 15500 | |
| 14456 | assert(casted_op1->value->type->id == ZigTypeIdBool); | 15501 | assert(casted_op1->value->type->id == ZigTypeIdBool); |
| 14457 | assert(casted_op2->value->type->id == ZigTypeIdBool); | 15502 | assert(casted_op2->value->type->id == ZigTypeIdBool); |
| ... | @@ -14463,14 +15508,11 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -14463,14 +15508,11 @@ static IrInstruction *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp |
| 14463 | } else { | 15508 | } else { |
| 14464 | zig_unreachable(); | 15509 | zig_unreachable(); |
| 14465 | } | 15510 | } |
| 14466 | return ir_const_bool(ira, &bin_op_instruction->base, result_bool); | 15511 | return ir_const_bool(ira, &bin_op_instruction->base.base, result_bool); |
| 14467 | } | 15512 | } |
| 14468 | | 15513 | |
| 14469 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, | 15514 | return ir_build_bin_op_gen(ira, &bin_op_instruction->base.base, bool_type, |
| 14470 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, | | |
| 14471 | bin_op_instruction->op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on); | 15515 | bin_op_instruction->op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on); |
| 14472 | result->value->type = bool_type; | | |
| 14473 | return result; | | |
| 14474 | } | 15516 | } |
| 14475 | | 15517 | |
| 14476 | static bool resolve_cmp_op_id(IrBinOp op_id, Cmp cmp) { | 15518 | static bool resolve_cmp_op_id(IrBinOp op_id, Cmp cmp) { |
| ... | @@ -14535,12 +15577,13 @@ static void set_optional_payload(ZigValue *opt_val, ZigValue *payload) { | ... | @@ -14535,12 +15577,13 @@ static void set_optional_payload(ZigValue *opt_val, ZigValue *payload) { |
| 14535 | } | 15577 | } |
| 14536 | } | 15578 | } |
| 14537 | | 15579 | |
| 14538 | static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_type, | 15580 | static IrInstGen *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_type, |
| 14539 | ZigValue *op1_val, ZigValue *op2_val, IrInstructionBinOp *bin_op_instruction, IrBinOp op_id, | 15581 | ZigValue *op1_val, ZigValue *op2_val, IrInstSrcBinOp *bin_op_instruction, IrBinOp op_id, |
| 14540 | bool one_possible_value) { | 15582 | bool one_possible_value) |
| | 15583 | { |
| 14541 | if (op1_val->special == ConstValSpecialUndef || | 15584 | if (op1_val->special == ConstValSpecialUndef || |
| 14542 | op2_val->special == ConstValSpecialUndef) | 15585 | op2_val->special == ConstValSpecialUndef) |
| 14543 | return ir_const_undef(ira, &bin_op_instruction->base, resolved_type); | 15586 | return ir_const_undef(ira, &bin_op_instruction->base.base, resolved_type); |
| 14544 | if (resolved_type->id == ZigTypeIdPointer && op_id != IrBinOpCmpEq && op_id != IrBinOpCmpNotEq) { | 15587 | if (resolved_type->id == ZigTypeIdPointer && op_id != IrBinOpCmpEq && op_id != IrBinOpCmpNotEq) { |
| 14545 | if ((op1_val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr || | 15588 | if ((op1_val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr || |
| 14546 | op1_val->data.x_ptr.special == ConstPtrSpecialNull) && | 15589 | op1_val->data.x_ptr.special == ConstPtrSpecialNull) && |
| ... | @@ -14560,7 +15603,7 @@ static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_t | ... | @@ -14560,7 +15603,7 @@ static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_t |
| 14560 | cmp_result = CmpEQ; | 15603 | cmp_result = CmpEQ; |
| 14561 | } | 15604 | } |
| 14562 | bool answer = resolve_cmp_op_id(op_id, cmp_result); | 15605 | bool answer = resolve_cmp_op_id(op_id, cmp_result); |
| 14563 | return ir_const_bool(ira, &bin_op_instruction->base, answer); | 15606 | return ir_const_bool(ira, &bin_op_instruction->base.base, answer); |
| 14564 | } | 15607 | } |
| 14565 | } else { | 15608 | } else { |
| 14566 | bool are_equal = one_possible_value || const_values_equal(ira->codegen, op1_val, op2_val); | 15609 | bool are_equal = one_possible_value || const_values_equal(ira->codegen, op1_val, op2_val); |
| ... | @@ -14572,7 +15615,7 @@ static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_t | ... | @@ -14572,7 +15615,7 @@ static IrInstruction *ir_evaluate_bin_op_cmp(IrAnalyze *ira, ZigType *resolved_t |
| 14572 | } else { | 15615 | } else { |
| 14573 | zig_unreachable(); | 15616 | zig_unreachable(); |
| 14574 | } | 15617 | } |
| 14575 | return ir_const_bool(ira, &bin_op_instruction->base, answer); | 15618 | return ir_const_bool(ira, &bin_op_instruction->base.base, answer); |
| 14576 | } | 15619 | } |
| 14577 | zig_unreachable(); | 15620 | zig_unreachable(); |
| 14578 | } | 15621 | } |
| ... | @@ -14626,7 +15669,7 @@ static Error lazy_cmp_zero(AstNode *source_node, ZigValue *val, Cmp *result) { | ... | @@ -14626,7 +15669,7 @@ static Error lazy_cmp_zero(AstNode *source_node, ZigValue *val, Cmp *result) { |
| 14626 | zig_unreachable(); | 15669 | zig_unreachable(); |
| 14627 | } | 15670 | } |
| 14628 | | 15671 | |
| 14629 | static ErrorMsg *ir_eval_bin_op_cmp_scalar(IrAnalyze *ira, IrInstruction *source_instr, | 15672 | static ErrorMsg *ir_eval_bin_op_cmp_scalar(IrAnalyze *ira, IrInst* source_instr, |
| 14630 | ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val, ZigValue *out_val) | 15673 | ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val, ZigValue *out_val) |
| 14631 | { | 15674 | { |
| 14632 | Error err; | 15675 | Error err; |
| ... | @@ -14704,14 +15747,14 @@ never_mind_just_calculate_it_normally: | ... | @@ -14704,14 +15747,14 @@ never_mind_just_calculate_it_normally: |
| 14704 | return nullptr; | 15747 | return nullptr; |
| 14705 | } | 15748 | } |
| 14706 | if (op1_val->type->id == ZigTypeIdComptimeFloat) { | 15749 | if (op1_val->type->id == ZigTypeIdComptimeFloat) { |
| 14707 | IrInstruction *tmp = ir_const_noval(ira, source_instr); | 15750 | IrInstGen *tmp = ir_const_noval(ira, source_instr); |
| 14708 | tmp->value = op1_val; | 15751 | tmp->value = op1_val; |
| 14709 | IrInstruction *casted = ir_implicit_cast(ira, tmp, op2_val->type); | 15752 | IrInstGen *casted = ir_implicit_cast(ira, tmp, op2_val->type); |
| 14710 | op1_val = casted->value; | 15753 | op1_val = casted->value; |
| 14711 | } else if (op2_val->type->id == ZigTypeIdComptimeFloat) { | 15754 | } else if (op2_val->type->id == ZigTypeIdComptimeFloat) { |
| 14712 | IrInstruction *tmp = ir_const_noval(ira, source_instr); | 15755 | IrInstGen *tmp = ir_const_noval(ira, source_instr); |
| 14713 | tmp->value = op2_val; | 15756 | tmp->value = op2_val; |
| 14714 | IrInstruction *casted = ir_implicit_cast(ira, tmp, op1_val->type); | 15757 | IrInstGen *casted = ir_implicit_cast(ira, tmp, op1_val->type); |
| 14715 | op2_val = casted->value; | 15758 | op2_val = casted->value; |
| 14716 | } | 15759 | } |
| 14717 | Cmp cmp_result = float_cmp(op1_val, op2_val); | 15760 | Cmp cmp_result = float_cmp(op1_val, op2_val); |
| ... | @@ -14753,8 +15796,8 @@ never_mind_just_calculate_it_normally: | ... | @@ -14753,8 +15796,8 @@ never_mind_just_calculate_it_normally: |
| 14753 | return nullptr; | 15796 | return nullptr; |
| 14754 | } | 15797 | } |
| 14755 | | 15798 | |
| 14756 | static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstruction *source_instr, | 15799 | static IrInstGen *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInst *source_instr, |
| 14757 | IrInstruction *op1, IrInstruction *op2, IrBinOp op_id) | 15800 | IrInstGen *op1, IrInstGen *op2, IrBinOp op_id) |
| 14758 | { | 15801 | { |
| 14759 | Error err; | 15802 | Error err; |
| 14760 | | 15803 | |
| ... | @@ -14767,7 +15810,7 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -14767,7 +15810,7 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 14767 | ir_add_error(ira, source_instr, | 15810 | ir_add_error(ira, source_instr, |
| 14768 | buf_sprintf("vector length mismatch: %" PRIu32 " and %" PRIu32, | 15811 | buf_sprintf("vector length mismatch: %" PRIu32 " and %" PRIu32, |
| 14769 | op1->value->type->data.vector.len, op2->value->type->data.vector.len)); | 15812 | op1->value->type->data.vector.len, op2->value->type->data.vector.len)); |
| 14770 | return ira->codegen->invalid_instruction; | 15813 | return ira->codegen->invalid_inst_gen; |
| 14771 | } | 15814 | } |
| 14772 | result_type = get_vector_type(ira->codegen, op1->value->type->data.vector.len, scalar_result_type); | 15815 | result_type = get_vector_type(ira->codegen, op1->value->type->data.vector.len, scalar_result_type); |
| 14773 | op1_scalar_type = op1->value->type->data.vector.elem_type; | 15816 | op1_scalar_type = op1->value->type->data.vector.elem_type; |
| ... | @@ -14776,13 +15819,13 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -14776,13 +15819,13 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 14776 | ir_add_error(ira, source_instr, | 15819 | ir_add_error(ira, source_instr, |
| 14777 | buf_sprintf("mixed scalar and vector operands to comparison operator: '%s' and '%s'", | 15820 | buf_sprintf("mixed scalar and vector operands to comparison operator: '%s' and '%s'", |
| 14778 | buf_ptr(&op1->value->type->name), buf_ptr(&op2->value->type->name))); | 15821 | buf_ptr(&op1->value->type->name), buf_ptr(&op2->value->type->name))); |
| 14779 | return ira->codegen->invalid_instruction; | 15822 | return ira->codegen->invalid_inst_gen; |
| 14780 | } | 15823 | } |
| 14781 | | 15824 | |
| 14782 | bool opv_op1; | 15825 | bool opv_op1; |
| 14783 | switch (type_has_one_possible_value(ira->codegen, op1->value->type)) { | 15826 | switch (type_has_one_possible_value(ira->codegen, op1->value->type)) { |
| 14784 | case OnePossibleValueInvalid: | 15827 | case OnePossibleValueInvalid: |
| 14785 | return ira->codegen->invalid_instruction; | 15828 | return ira->codegen->invalid_inst_gen; |
| 14786 | case OnePossibleValueYes: | 15829 | case OnePossibleValueYes: |
| 14787 | opv_op1 = true; | 15830 | opv_op1 = true; |
| 14788 | break; | 15831 | break; |
| ... | @@ -14793,7 +15836,7 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -14793,7 +15836,7 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 14793 | bool opv_op2; | 15836 | bool opv_op2; |
| 14794 | switch (type_has_one_possible_value(ira->codegen, op2->value->type)) { | 15837 | switch (type_has_one_possible_value(ira->codegen, op2->value->type)) { |
| 14795 | case OnePossibleValueInvalid: | 15838 | case OnePossibleValueInvalid: |
| 14796 | return ira->codegen->invalid_instruction; | 15839 | return ira->codegen->invalid_inst_gen; |
| 14797 | case OnePossibleValueYes: | 15840 | case OnePossibleValueYes: |
| 14798 | opv_op2 = true; | 15841 | opv_op2 = true; |
| 14799 | break; | 15842 | break; |
| ... | @@ -14804,21 +15847,21 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -14804,21 +15847,21 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 14804 | Cmp op1_cmp_zero; | 15847 | Cmp op1_cmp_zero; |
| 14805 | bool have_op1_cmp_zero = false; | 15848 | bool have_op1_cmp_zero = false; |
| 14806 | if ((err = lazy_cmp_zero(source_instr->source_node, op1->value, &op1_cmp_zero))) { | 15849 | if ((err = lazy_cmp_zero(source_instr->source_node, op1->value, &op1_cmp_zero))) { |
| 14807 | if (err != ErrorNotLazy) return ira->codegen->invalid_instruction; | 15850 | if (err != ErrorNotLazy) return ira->codegen->invalid_inst_gen; |
| 14808 | } else { | 15851 | } else { |
| 14809 | have_op1_cmp_zero = true; | 15852 | have_op1_cmp_zero = true; |
| 14810 | } | 15853 | } |
| 14811 | Cmp op2_cmp_zero; | 15854 | Cmp op2_cmp_zero; |
| 14812 | bool have_op2_cmp_zero = false; | 15855 | bool have_op2_cmp_zero = false; |
| 14813 | if ((err = lazy_cmp_zero(source_instr->source_node, op2->value, &op2_cmp_zero))) { | 15856 | if ((err = lazy_cmp_zero(source_instr->source_node, op2->value, &op2_cmp_zero))) { |
| 14814 | if (err != ErrorNotLazy) return ira->codegen->invalid_instruction; | 15857 | if (err != ErrorNotLazy) return ira->codegen->invalid_inst_gen; |
| 14815 | } else { | 15858 | } else { |
| 14816 | have_op2_cmp_zero = true; | 15859 | have_op2_cmp_zero = true; |
| 14817 | } | 15860 | } |
| 14818 | if (((opv_op1 || instr_is_comptime(op1)) && (opv_op2 || instr_is_comptime(op2))) || | 15861 | if (((opv_op1 || instr_is_comptime(op1)) && (opv_op2 || instr_is_comptime(op2))) || |
| 14819 | (have_op1_cmp_zero && have_op2_cmp_zero)) | 15862 | (have_op1_cmp_zero && have_op2_cmp_zero)) |
| 14820 | { | 15863 | { |
| 14821 | IrInstruction *result_instruction = ir_const(ira, source_instr, result_type); | 15864 | IrInstGen *result_instruction = ir_const(ira, source_instr, result_type); |
| 14822 | ZigValue *out_val = result_instruction->value; | 15865 | ZigValue *out_val = result_instruction->value; |
| 14823 | if (result_type->id == ZigTypeIdVector) { | 15866 | if (result_type->id == ZigTypeIdVector) { |
| 14824 | size_t len = result_type->data.vector.len; | 15867 | size_t len = result_type->data.vector.len; |
| ... | @@ -14836,7 +15879,7 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -14836,7 +15879,7 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 14836 | if (msg != nullptr) { | 15879 | if (msg != nullptr) { |
| 14837 | add_error_note(ira->codegen, msg, source_instr->source_node, | 15880 | add_error_note(ira->codegen, msg, source_instr->source_node, |
| 14838 | buf_sprintf("when computing vector element at index %" ZIG_PRI_usize, i)); | 15881 | buf_sprintf("when computing vector element at index %" ZIG_PRI_usize, i)); |
| 14839 | return ira->codegen->invalid_instruction; | 15882 | return ira->codegen->invalid_inst_gen; |
| 14840 | } | 15883 | } |
| 14841 | } | 15884 | } |
| 14842 | out_val->type = result_type; | 15885 | out_val->type = result_type; |
| ... | @@ -14845,7 +15888,7 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -14845,7 +15888,7 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 14845 | if (ir_eval_bin_op_cmp_scalar(ira, source_instr, op1->value, op_id, | 15888 | if (ir_eval_bin_op_cmp_scalar(ira, source_instr, op1->value, op_id, |
| 14846 | op2->value, out_val) != nullptr) | 15889 | op2->value, out_val) != nullptr) |
| 14847 | { | 15890 | { |
| 14848 | return ira->codegen->invalid_instruction; | 15891 | return ira->codegen->invalid_inst_gen; |
| 14849 | } | 15892 | } |
| 14850 | } | 15893 | } |
| 14851 | return result_instruction; | 15894 | return result_instruction; |
| ... | @@ -14939,10 +15982,10 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -14939,10 +15982,10 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 14939 | } | 15982 | } |
| 14940 | ZigType *dest_type = (result_type->id == ZigTypeIdVector) ? | 15983 | ZigType *dest_type = (result_type->id == ZigTypeIdVector) ? |
| 14941 | get_vector_type(ira->codegen, result_type->data.vector.len, dest_scalar_type) : dest_scalar_type; | 15984 | get_vector_type(ira->codegen, result_type->data.vector.len, dest_scalar_type) : dest_scalar_type; |
| 14942 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, dest_type); | 15985 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, dest_type); |
| 14943 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, dest_type); | 15986 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, dest_type); |
| 14944 | if (type_is_invalid(casted_op1->value->type) || type_is_invalid(casted_op2->value->type)) | 15987 | if (type_is_invalid(casted_op1->value->type) || type_is_invalid(casted_op2->value->type)) |
| 14945 | return ira->codegen->invalid_instruction; | 15988 | return ira->codegen->invalid_inst_gen; |
| 14946 | return ir_build_bin_op_gen(ira, source_instr, result_type, op_id, casted_op1, casted_op2, true); | 15989 | return ir_build_bin_op_gen(ira, source_instr, result_type, op_id, casted_op1, casted_op2, true); |
| 14947 | } | 15990 | } |
| 14948 | | 15991 | |
| ... | @@ -14972,12 +16015,12 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -14972,12 +16015,12 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 14972 | if (instr_is_comptime(op1)) { | 16015 | if (instr_is_comptime(op1)) { |
| 14973 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefOk); | 16016 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefOk); |
| 14974 | if (op1_val == nullptr) | 16017 | if (op1_val == nullptr) |
| 14975 | return ira->codegen->invalid_instruction; | 16018 | return ira->codegen->invalid_inst_gen; |
| 14976 | if (op1_val->special == ConstValSpecialUndef) | 16019 | if (op1_val->special == ConstValSpecialUndef) |
| 14977 | return ir_const_undef(ira, source_instr, ira->codegen->builtin_types.entry_bool); | 16020 | return ir_const_undef(ira, source_instr, ira->codegen->builtin_types.entry_bool); |
| 14978 | if (result_type->id == ZigTypeIdVector) { | 16021 | if (result_type->id == ZigTypeIdVector) { |
| 14979 | ir_add_error(ira, op1, buf_sprintf("compiler bug: TODO: support comptime vector here")); | 16022 | ir_add_error(ira, &op1->base, buf_sprintf("compiler bug: TODO: support comptime vector here")); |
| 14980 | return ira->codegen->invalid_instruction; | 16023 | return ira->codegen->invalid_inst_gen; |
| 14981 | } | 16024 | } |
| 14982 | bool is_unsigned; | 16025 | bool is_unsigned; |
| 14983 | if (op1_is_float) { | 16026 | if (op1_is_float) { |
| ... | @@ -15016,12 +16059,12 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -15016,12 +16059,12 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 15016 | if (instr_is_comptime(op2)) { | 16059 | if (instr_is_comptime(op2)) { |
| 15017 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefOk); | 16060 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefOk); |
| 15018 | if (op2_val == nullptr) | 16061 | if (op2_val == nullptr) |
| 15019 | return ira->codegen->invalid_instruction; | 16062 | return ira->codegen->invalid_inst_gen; |
| 15020 | if (op2_val->special == ConstValSpecialUndef) | 16063 | if (op2_val->special == ConstValSpecialUndef) |
| 15021 | return ir_const_undef(ira, source_instr, ira->codegen->builtin_types.entry_bool); | 16064 | return ir_const_undef(ira, source_instr, ira->codegen->builtin_types.entry_bool); |
| 15022 | if (result_type->id == ZigTypeIdVector) { | 16065 | if (result_type->id == ZigTypeIdVector) { |
| 15023 | ir_add_error(ira, op2, buf_sprintf("compiler bug: TODO: support comptime vector here")); | 16066 | ir_add_error(ira, &op2->base, buf_sprintf("compiler bug: TODO: support comptime vector here")); |
| 15024 | return ira->codegen->invalid_instruction; | 16067 | return ira->codegen->invalid_inst_gen; |
| 15025 | } | 16068 | } |
| 15026 | bool is_unsigned; | 16069 | bool is_unsigned; |
| 15027 | if (op2_is_float) { | 16070 | if (op2_is_float) { |
| ... | @@ -15062,35 +16105,35 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio | ... | @@ -15062,35 +16105,35 @@ static IrInstruction *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInstructio |
| 15062 | ZigType *dest_type = (result_type->id == ZigTypeIdVector) ? | 16105 | ZigType *dest_type = (result_type->id == ZigTypeIdVector) ? |
| 15063 | get_vector_type(ira->codegen, result_type->data.vector.len, dest_scalar_type) : dest_scalar_type; | 16106 | get_vector_type(ira->codegen, result_type->data.vector.len, dest_scalar_type) : dest_scalar_type; |
| 15064 | | 16107 | |
| 15065 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, dest_type); | 16108 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, dest_type); |
| 15066 | if (type_is_invalid(casted_op1->value->type)) | 16109 | if (type_is_invalid(casted_op1->value->type)) |
| 15067 | return ira->codegen->invalid_instruction; | 16110 | return ira->codegen->invalid_inst_gen; |
| 15068 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, dest_type); | 16111 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, dest_type); |
| 15069 | if (type_is_invalid(casted_op2->value->type)) | 16112 | if (type_is_invalid(casted_op2->value->type)) |
| 15070 | return ira->codegen->invalid_instruction; | 16113 | return ira->codegen->invalid_inst_gen; |
| 15071 | return ir_build_bin_op_gen(ira, source_instr, result_type, op_id, casted_op1, casted_op2, true); | 16114 | return ir_build_bin_op_gen(ira, source_instr, result_type, op_id, casted_op1, casted_op2, true); |
| 15072 | } | 16115 | } |
| 15073 | | 16116 | |
| 15074 | static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { | 16117 | static IrInstGen *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstSrcBinOp *bin_op_instruction) { |
| 15075 | IrInstruction *op1 = bin_op_instruction->op1->child; | 16118 | IrInstGen *op1 = bin_op_instruction->op1->child; |
| 15076 | if (type_is_invalid(op1->value->type)) | 16119 | if (type_is_invalid(op1->value->type)) |
| 15077 | return ira->codegen->invalid_instruction; | 16120 | return ira->codegen->invalid_inst_gen; |
| 15078 | | 16121 | |
| 15079 | IrInstruction *op2 = bin_op_instruction->op2->child; | 16122 | IrInstGen *op2 = bin_op_instruction->op2->child; |
| 15080 | if (type_is_invalid(op2->value->type)) | 16123 | if (type_is_invalid(op2->value->type)) |
| 15081 | return ira->codegen->invalid_instruction; | 16124 | return ira->codegen->invalid_inst_gen; |
| 15082 | | 16125 | |
| 15083 | AstNode *source_node = bin_op_instruction->base.source_node; | 16126 | AstNode *source_node = bin_op_instruction->base.base.source_node; |
| 15084 | | 16127 | |
| 15085 | IrBinOp op_id = bin_op_instruction->op_id; | 16128 | IrBinOp op_id = bin_op_instruction->op_id; |
| 15086 | bool is_equality_cmp = (op_id == IrBinOpCmpEq || op_id == IrBinOpCmpNotEq); | 16129 | bool is_equality_cmp = (op_id == IrBinOpCmpEq || op_id == IrBinOpCmpNotEq); |
| 15087 | if (is_equality_cmp && op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdNull) { | 16130 | if (is_equality_cmp && op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdNull) { |
| 15088 | return ir_const_bool(ira, &bin_op_instruction->base, (op_id == IrBinOpCmpEq)); | 16131 | return ir_const_bool(ira, &bin_op_instruction->base.base, (op_id == IrBinOpCmpEq)); |
| 15089 | } else if (is_equality_cmp && | 16132 | } else if (is_equality_cmp && |
| 15090 | ((op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdOptional) || | 16133 | ((op1->value->type->id == ZigTypeIdNull && op2->value->type->id == ZigTypeIdOptional) || |
| 15091 | (op2->value->type->id == ZigTypeIdNull && op1->value->type->id == ZigTypeIdOptional))) | 16134 | (op2->value->type->id == ZigTypeIdNull && op1->value->type->id == ZigTypeIdOptional))) |
| 15092 | { | 16135 | { |
| 15093 | IrInstruction *maybe_op; | 16136 | IrInstGen *maybe_op; |
| 15094 | if (op1->value->type->id == ZigTypeIdNull) { | 16137 | if (op1->value->type->id == ZigTypeIdNull) { |
| 15095 | maybe_op = op2; | 16138 | maybe_op = op2; |
| 15096 | } else if (op2->value->type->id == ZigTypeIdNull) { | 16139 | } else if (op2->value->type->id == ZigTypeIdNull) { |
| ... | @@ -15101,21 +16144,16 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15101,21 +16144,16 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15101 | if (instr_is_comptime(maybe_op)) { | 16144 | if (instr_is_comptime(maybe_op)) { |
| 15102 | ZigValue *maybe_val = ir_resolve_const(ira, maybe_op, UndefBad); | 16145 | ZigValue *maybe_val = ir_resolve_const(ira, maybe_op, UndefBad); |
| 15103 | if (!maybe_val) | 16146 | if (!maybe_val) |
| 15104 | return ira->codegen->invalid_instruction; | 16147 | return ira->codegen->invalid_inst_gen; |
| 15105 | bool is_null = optional_value_is_null(maybe_val); | 16148 | bool is_null = optional_value_is_null(maybe_val); |
| 15106 | bool bool_result = (op_id == IrBinOpCmpEq) ? is_null : !is_null; | 16149 | bool bool_result = (op_id == IrBinOpCmpEq) ? is_null : !is_null; |
| 15107 | return ir_const_bool(ira, &bin_op_instruction->base, bool_result); | 16150 | return ir_const_bool(ira, &bin_op_instruction->base.base, bool_result); |
| 15108 | } | 16151 | } |
| 15109 | | 16152 | |
| 15110 | IrInstruction *is_non_null = ir_build_test_nonnull(&ira->new_irb, bin_op_instruction->base.scope, | 16153 | IrInstGen *is_non_null = ir_build_test_non_null_gen(ira, &bin_op_instruction->base.base, maybe_op); |
| 15111 | source_node, maybe_op); | | |
| 15112 | is_non_null->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 15113 | | 16154 | |
| 15114 | if (op_id == IrBinOpCmpEq) { | 16155 | if (op_id == IrBinOpCmpEq) { |
| 15115 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, bin_op_instruction->base.scope, | 16156 | return ir_build_bool_not_gen(ira, &bin_op_instruction->base.base, is_non_null); |
| 15116 | bin_op_instruction->base.source_node, is_non_null); | | |
| 15117 | result->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 15118 | return result; | | |
| 15119 | } else { | 16157 | } else { |
| 15120 | return is_non_null; | 16158 | return is_non_null; |
| 15121 | } | 16159 | } |
| ... | @@ -15125,7 +16163,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15125,7 +16163,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15125 | (op2->value->type->id == ZigTypeIdNull && op1->value->type->id == ZigTypeIdPointer && | 16163 | (op2->value->type->id == ZigTypeIdNull && op1->value->type->id == ZigTypeIdPointer && |
| 15126 | op1->value->type->data.pointer.ptr_len == PtrLenC))) | 16164 | op1->value->type->data.pointer.ptr_len == PtrLenC))) |
| 15127 | { | 16165 | { |
| 15128 | IrInstruction *c_ptr_op; | 16166 | IrInstGen *c_ptr_op; |
| 15129 | if (op1->value->type->id == ZigTypeIdNull) { | 16167 | if (op1->value->type->id == ZigTypeIdNull) { |
| 15130 | c_ptr_op = op2; | 16168 | c_ptr_op = op2; |
| 15131 | } else if (op2->value->type->id == ZigTypeIdNull) { | 16169 | } else if (op2->value->type->id == ZigTypeIdNull) { |
| ... | @@ -15136,24 +16174,19 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15136,24 +16174,19 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15136 | if (instr_is_comptime(c_ptr_op)) { | 16174 | if (instr_is_comptime(c_ptr_op)) { |
| 15137 | ZigValue *c_ptr_val = ir_resolve_const(ira, c_ptr_op, UndefOk); | 16175 | ZigValue *c_ptr_val = ir_resolve_const(ira, c_ptr_op, UndefOk); |
| 15138 | if (!c_ptr_val) | 16176 | if (!c_ptr_val) |
| 15139 | return ira->codegen->invalid_instruction; | 16177 | return ira->codegen->invalid_inst_gen; |
| 15140 | if (c_ptr_val->special == ConstValSpecialUndef) | 16178 | if (c_ptr_val->special == ConstValSpecialUndef) |
| 15141 | return ir_const_undef(ira, &bin_op_instruction->base, ira->codegen->builtin_types.entry_bool); | 16179 | return ir_const_undef(ira, &bin_op_instruction->base.base, ira->codegen->builtin_types.entry_bool); |
| 15142 | bool is_null = c_ptr_val->data.x_ptr.special == ConstPtrSpecialNull || | 16180 | bool is_null = c_ptr_val->data.x_ptr.special == ConstPtrSpecialNull || |
| 15143 | (c_ptr_val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr && | 16181 | (c_ptr_val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr && |
| 15144 | c_ptr_val->data.x_ptr.data.hard_coded_addr.addr == 0); | 16182 | c_ptr_val->data.x_ptr.data.hard_coded_addr.addr == 0); |
| 15145 | bool bool_result = (op_id == IrBinOpCmpEq) ? is_null : !is_null; | 16183 | bool bool_result = (op_id == IrBinOpCmpEq) ? is_null : !is_null; |
| 15146 | return ir_const_bool(ira, &bin_op_instruction->base, bool_result); | 16184 | return ir_const_bool(ira, &bin_op_instruction->base.base, bool_result); |
| 15147 | } | 16185 | } |
| 15148 | IrInstruction *is_non_null = ir_build_test_nonnull(&ira->new_irb, bin_op_instruction->base.scope, | 16186 | IrInstGen *is_non_null = ir_build_test_non_null_gen(ira, &bin_op_instruction->base.base, c_ptr_op); |
| 15149 | source_node, c_ptr_op); | | |
| 15150 | is_non_null->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 15151 | | 16187 | |
| 15152 | if (op_id == IrBinOpCmpEq) { | 16188 | if (op_id == IrBinOpCmpEq) { |
| 15153 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, bin_op_instruction->base.scope, | 16189 | return ir_build_bool_not_gen(ira, &bin_op_instruction->base.base, is_non_null); |
| 15154 | bin_op_instruction->base.source_node, is_non_null); | | |
| 15155 | result->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 15156 | return result; | | |
| 15157 | } else { | 16190 | } else { |
| 15158 | return is_non_null; | 16191 | return is_non_null; |
| 15159 | } | 16192 | } |
| ... | @@ -15161,61 +16194,57 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15161,61 +16194,57 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15161 | ZigType *non_null_type = (op1->value->type->id == ZigTypeIdNull) ? op2->value->type : op1->value->type; | 16194 | ZigType *non_null_type = (op1->value->type->id == ZigTypeIdNull) ? op2->value->type : op1->value->type; |
| 15162 | ir_add_error_node(ira, source_node, buf_sprintf("comparison of '%s' with null", | 16195 | ir_add_error_node(ira, source_node, buf_sprintf("comparison of '%s' with null", |
| 15163 | buf_ptr(&non_null_type->name))); | 16196 | buf_ptr(&non_null_type->name))); |
| 15164 | return ira->codegen->invalid_instruction; | 16197 | return ira->codegen->invalid_inst_gen; |
| 15165 | } else if (is_equality_cmp && ( | 16198 | } else if (is_equality_cmp && ( |
| 15166 | (op1->value->type->id == ZigTypeIdEnumLiteral && op2->value->type->id == ZigTypeIdUnion) || | 16199 | (op1->value->type->id == ZigTypeIdEnumLiteral && op2->value->type->id == ZigTypeIdUnion) || |
| 15167 | (op2->value->type->id == ZigTypeIdEnumLiteral && op1->value->type->id == ZigTypeIdUnion))) | 16200 | (op2->value->type->id == ZigTypeIdEnumLiteral && op1->value->type->id == ZigTypeIdUnion))) |
| 15168 | { | 16201 | { |
| 15169 | // Support equality comparison between a union's tag value and a enum literal | 16202 | // Support equality comparison between a union's tag value and a enum literal |
| 15170 | IrInstruction *union_val = op1->value->type->id == ZigTypeIdUnion ? op1 : op2; | 16203 | IrInstGen *union_val = op1->value->type->id == ZigTypeIdUnion ? op1 : op2; |
| 15171 | IrInstruction *enum_val = op1->value->type->id == ZigTypeIdUnion ? op2 : op1; | 16204 | IrInstGen *enum_val = op1->value->type->id == ZigTypeIdUnion ? op2 : op1; |
| 15172 | | 16205 | |
| 15173 | ZigType *tag_type = union_val->value->type->data.unionation.tag_type; | 16206 | ZigType *tag_type = union_val->value->type->data.unionation.tag_type; |
| 15174 | assert(tag_type != nullptr); | 16207 | assert(tag_type != nullptr); |
| 15175 | | 16208 | |
| 15176 | IrInstruction *casted_union = ir_implicit_cast(ira, union_val, tag_type); | 16209 | IrInstGen *casted_union = ir_implicit_cast(ira, union_val, tag_type); |
| 15177 | if (type_is_invalid(casted_union->value->type)) | 16210 | if (type_is_invalid(casted_union->value->type)) |
| 15178 | return ira->codegen->invalid_instruction; | 16211 | return ira->codegen->invalid_inst_gen; |
| 15179 | | 16212 | |
| 15180 | IrInstruction *casted_val = ir_implicit_cast(ira, enum_val, tag_type); | 16213 | IrInstGen *casted_val = ir_implicit_cast(ira, enum_val, tag_type); |
| 15181 | if (type_is_invalid(casted_val->value->type)) | 16214 | if (type_is_invalid(casted_val->value->type)) |
| 15182 | return ira->codegen->invalid_instruction; | 16215 | return ira->codegen->invalid_inst_gen; |
| 15183 | | 16216 | |
| 15184 | if (instr_is_comptime(casted_union)) { | 16217 | if (instr_is_comptime(casted_union)) { |
| 15185 | ZigValue *const_union_val = ir_resolve_const(ira, casted_union, UndefBad); | 16218 | ZigValue *const_union_val = ir_resolve_const(ira, casted_union, UndefBad); |
| 15186 | if (!const_union_val) | 16219 | if (!const_union_val) |
| 15187 | return ira->codegen->invalid_instruction; | 16220 | return ira->codegen->invalid_inst_gen; |
| 15188 | | 16221 | |
| 15189 | ZigValue *const_enum_val = ir_resolve_const(ira, casted_val, UndefBad); | 16222 | ZigValue *const_enum_val = ir_resolve_const(ira, casted_val, UndefBad); |
| 15190 | if (!const_enum_val) | 16223 | if (!const_enum_val) |
| 15191 | return ira->codegen->invalid_instruction; | 16224 | return ira->codegen->invalid_inst_gen; |
| 15192 | | 16225 | |
| 15193 | Cmp cmp_result = bigint_cmp(&const_union_val->data.x_union.tag, &const_enum_val->data.x_enum_tag); | 16226 | Cmp cmp_result = bigint_cmp(&const_union_val->data.x_union.tag, &const_enum_val->data.x_enum_tag); |
| 15194 | bool bool_result = (op_id == IrBinOpCmpEq) ? cmp_result == CmpEQ : cmp_result != CmpEQ; | 16227 | bool bool_result = (op_id == IrBinOpCmpEq) ? cmp_result == CmpEQ : cmp_result != CmpEQ; |
| 15195 | | 16228 | |
| 15196 | return ir_const_bool(ira, &bin_op_instruction->base, bool_result); | 16229 | return ir_const_bool(ira, &bin_op_instruction->base.base, bool_result); |
| 15197 | } | 16230 | } |
| 15198 | | 16231 | |
| 15199 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, | 16232 | return ir_build_bin_op_gen(ira, &bin_op_instruction->base.base, ira->codegen->builtin_types.entry_bool, |
| 15200 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, | | |
| 15201 | op_id, casted_union, casted_val, bin_op_instruction->safety_check_on); | 16233 | op_id, casted_union, casted_val, bin_op_instruction->safety_check_on); |
| 15202 | result->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 15203 | | | |
| 15204 | return result; | | |
| 15205 | } | 16234 | } |
| 15206 | | 16235 | |
| 15207 | if (op1->value->type->id == ZigTypeIdErrorSet && op2->value->type->id == ZigTypeIdErrorSet) { | 16236 | if (op1->value->type->id == ZigTypeIdErrorSet && op2->value->type->id == ZigTypeIdErrorSet) { |
| 15208 | if (!is_equality_cmp) { | 16237 | if (!is_equality_cmp) { |
| 15209 | ir_add_error_node(ira, source_node, buf_sprintf("operator not allowed for errors")); | 16238 | ir_add_error_node(ira, source_node, buf_sprintf("operator not allowed for errors")); |
| 15210 | return ira->codegen->invalid_instruction; | 16239 | return ira->codegen->invalid_inst_gen; |
| 15211 | } | 16240 | } |
| 15212 | ZigType *intersect_type = get_error_set_intersection(ira, op1->value->type, op2->value->type, source_node); | 16241 | ZigType *intersect_type = get_error_set_intersection(ira, op1->value->type, op2->value->type, source_node); |
| 15213 | if (type_is_invalid(intersect_type)) { | 16242 | if (type_is_invalid(intersect_type)) { |
| 15214 | return ira->codegen->invalid_instruction; | 16243 | return ira->codegen->invalid_inst_gen; |
| 15215 | } | 16244 | } |
| 15216 | | 16245 | |
| 15217 | if (!resolve_inferred_error_set(ira->codegen, intersect_type, source_node)) { | 16246 | if (!resolve_inferred_error_set(ira->codegen, intersect_type, source_node)) { |
| 15218 | return ira->codegen->invalid_instruction; | 16247 | return ira->codegen->invalid_inst_gen; |
| 15219 | } | 16248 | } |
| 15220 | | 16249 | |
| 15221 | // exception if one of the operators has the type of the empty error set, we allow the comparison | 16250 | // exception if one of the operators has the type of the empty error set, we allow the comparison |
| ... | @@ -15232,7 +16261,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15232,7 +16261,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15232 | } else { | 16261 | } else { |
| 15233 | zig_unreachable(); | 16262 | zig_unreachable(); |
| 15234 | } | 16263 | } |
| 15235 | return ir_const_bool(ira, &bin_op_instruction->base, answer); | 16264 | return ir_const_bool(ira, &bin_op_instruction->base.base, answer); |
| 15236 | } | 16265 | } |
| 15237 | | 16266 | |
| 15238 | if (!type_is_global_error_set(intersect_type)) { | 16267 | if (!type_is_global_error_set(intersect_type)) { |
| ... | @@ -15240,7 +16269,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15240,7 +16269,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15240 | ir_add_error_node(ira, source_node, | 16269 | ir_add_error_node(ira, source_node, |
| 15241 | buf_sprintf("error sets '%s' and '%s' have no common errors", | 16270 | buf_sprintf("error sets '%s' and '%s' have no common errors", |
| 15242 | buf_ptr(&op1->value->type->name), buf_ptr(&op2->value->type->name))); | 16271 | buf_ptr(&op1->value->type->name), buf_ptr(&op2->value->type->name))); |
| 15243 | return ira->codegen->invalid_instruction; | 16272 | return ira->codegen->invalid_inst_gen; |
| 15244 | } | 16273 | } |
| 15245 | if (op1->value->type->data.error_set.err_count == 1 && op2->value->type->data.error_set.err_count == 1) { | 16274 | if (op1->value->type->data.error_set.err_count == 1 && op2->value->type->data.error_set.err_count == 1) { |
| 15246 | bool are_equal = true; | 16275 | bool are_equal = true; |
| ... | @@ -15252,17 +16281,17 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15252,17 +16281,17 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15252 | } else { | 16281 | } else { |
| 15253 | zig_unreachable(); | 16282 | zig_unreachable(); |
| 15254 | } | 16283 | } |
| 15255 | return ir_const_bool(ira, &bin_op_instruction->base, answer); | 16284 | return ir_const_bool(ira, &bin_op_instruction->base.base, answer); |
| 15256 | } | 16285 | } |
| 15257 | } | 16286 | } |
| 15258 | | 16287 | |
| 15259 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { | 16288 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { |
| 15260 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 16289 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 15261 | if (op1_val == nullptr) | 16290 | if (op1_val == nullptr) |
| 15262 | return ira->codegen->invalid_instruction; | 16291 | return ira->codegen->invalid_inst_gen; |
| 15263 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 16292 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 15264 | if (op2_val == nullptr) | 16293 | if (op2_val == nullptr) |
| 15265 | return ira->codegen->invalid_instruction; | 16294 | return ira->codegen->invalid_inst_gen; |
| 15266 | | 16295 | |
| 15267 | bool answer; | 16296 | bool answer; |
| 15268 | bool are_equal = op1_val->data.x_err_set->value == op2_val->data.x_err_set->value; | 16297 | bool are_equal = op1_val->data.x_err_set->value == op2_val->data.x_err_set->value; |
| ... | @@ -15274,27 +16303,24 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15274,27 +16303,24 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15274 | zig_unreachable(); | 16303 | zig_unreachable(); |
| 15275 | } | 16304 | } |
| 15276 | | 16305 | |
| 15277 | return ir_const_bool(ira, &bin_op_instruction->base, answer); | 16306 | return ir_const_bool(ira, &bin_op_instruction->base.base, answer); |
| 15278 | } | 16307 | } |
| 15279 | | 16308 | |
| 15280 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, | 16309 | return ir_build_bin_op_gen(ira, &bin_op_instruction->base.base, ira->codegen->builtin_types.entry_bool, |
| 15281 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, | | |
| 15282 | op_id, op1, op2, bin_op_instruction->safety_check_on); | 16310 | op_id, op1, op2, bin_op_instruction->safety_check_on); |
| 15283 | result->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 15284 | return result; | | |
| 15285 | } | 16311 | } |
| 15286 | | 16312 | |
| 15287 | if (type_is_numeric(op1->value->type) && type_is_numeric(op2->value->type)) { | 16313 | if (type_is_numeric(op1->value->type) && type_is_numeric(op2->value->type)) { |
| 15288 | // This operation allows any combination of integer and float types, regardless of the | 16314 | // This operation allows any combination of integer and float types, regardless of the |
| 15289 | // signed-ness, comptime-ness, and bit-width. So peer type resolution is incorrect for | 16315 | // signed-ness, comptime-ness, and bit-width. So peer type resolution is incorrect for |
| 15290 | // numeric types. | 16316 | // numeric types. |
| 15291 | return ir_analyze_bin_op_cmp_numeric(ira, &bin_op_instruction->base, op1, op2, op_id); | 16317 | return ir_analyze_bin_op_cmp_numeric(ira, &bin_op_instruction->base.base, op1, op2, op_id); |
| 15292 | } | 16318 | } |
| 15293 | | 16319 | |
| 15294 | IrInstruction *instructions[] = {op1, op2}; | 16320 | IrInstGen *instructions[] = {op1, op2}; |
| 15295 | ZigType *resolved_type = ir_resolve_peer_types(ira, source_node, nullptr, instructions, 2); | 16321 | ZigType *resolved_type = ir_resolve_peer_types(ira, source_node, nullptr, instructions, 2); |
| 15296 | if (type_is_invalid(resolved_type)) | 16322 | if (type_is_invalid(resolved_type)) |
| 15297 | return ira->codegen->invalid_instruction; | 16323 | return ira->codegen->invalid_inst_gen; |
| 15298 | | 16324 | |
| 15299 | bool operator_allowed; | 16325 | bool operator_allowed; |
| 15300 | switch (resolved_type->id) { | 16326 | switch (resolved_type->id) { |
| ... | @@ -15342,21 +16368,21 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15342,21 +16368,21 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15342 | if (!operator_allowed) { | 16368 | if (!operator_allowed) { |
| 15343 | ir_add_error_node(ira, source_node, | 16369 | ir_add_error_node(ira, source_node, |
| 15344 | buf_sprintf("operator not allowed for type '%s'", buf_ptr(&resolved_type->name))); | 16370 | buf_sprintf("operator not allowed for type '%s'", buf_ptr(&resolved_type->name))); |
| 15345 | return ira->codegen->invalid_instruction; | 16371 | return ira->codegen->invalid_inst_gen; |
| 15346 | } | 16372 | } |
| 15347 | | 16373 | |
| 15348 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); | 16374 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); |
| 15349 | if (casted_op1 == ira->codegen->invalid_instruction) | 16375 | if (type_is_invalid(casted_op1->value->type)) |
| 15350 | return ira->codegen->invalid_instruction; | 16376 | return ira->codegen->invalid_inst_gen; |
| 15351 | | 16377 | |
| 15352 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); | 16378 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); |
| 15353 | if (casted_op2 == ira->codegen->invalid_instruction) | 16379 | if (type_is_invalid(casted_op2->value->type)) |
| 15354 | return ira->codegen->invalid_instruction; | 16380 | return ira->codegen->invalid_inst_gen; |
| 15355 | | 16381 | |
| 15356 | bool one_possible_value; | 16382 | bool one_possible_value; |
| 15357 | switch (type_has_one_possible_value(ira->codegen, resolved_type)) { | 16383 | switch (type_has_one_possible_value(ira->codegen, resolved_type)) { |
| 15358 | case OnePossibleValueInvalid: | 16384 | case OnePossibleValueInvalid: |
| 15359 | return ira->codegen->invalid_instruction; | 16385 | return ira->codegen->invalid_inst_gen; |
| 15360 | case OnePossibleValueYes: | 16386 | case OnePossibleValueYes: |
| 15361 | one_possible_value = true; | 16387 | one_possible_value = true; |
| 15362 | break; | 16388 | break; |
| ... | @@ -15368,20 +16394,20 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15368,20 +16394,20 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15368 | if (one_possible_value || (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2))) { | 16394 | if (one_possible_value || (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2))) { |
| 15369 | ZigValue *op1_val = one_possible_value ? casted_op1->value : ir_resolve_const(ira, casted_op1, UndefBad); | 16395 | ZigValue *op1_val = one_possible_value ? casted_op1->value : ir_resolve_const(ira, casted_op1, UndefBad); |
| 15370 | if (op1_val == nullptr) | 16396 | if (op1_val == nullptr) |
| 15371 | return ira->codegen->invalid_instruction; | 16397 | return ira->codegen->invalid_inst_gen; |
| 15372 | ZigValue *op2_val = one_possible_value ? casted_op2->value : ir_resolve_const(ira, casted_op2, UndefBad); | 16398 | ZigValue *op2_val = one_possible_value ? casted_op2->value : ir_resolve_const(ira, casted_op2, UndefBad); |
| 15373 | if (op2_val == nullptr) | 16399 | if (op2_val == nullptr) |
| 15374 | return ira->codegen->invalid_instruction; | 16400 | return ira->codegen->invalid_inst_gen; |
| 15375 | if (resolved_type->id != ZigTypeIdVector) | 16401 | if (resolved_type->id != ZigTypeIdVector) |
| 15376 | return ir_evaluate_bin_op_cmp(ira, resolved_type, op1_val, op2_val, bin_op_instruction, op_id, one_possible_value); | 16402 | return ir_evaluate_bin_op_cmp(ira, resolved_type, op1_val, op2_val, bin_op_instruction, op_id, one_possible_value); |
| 15377 | IrInstruction *result = ir_const(ira, &bin_op_instruction->base, | 16403 | IrInstGen *result = ir_const(ira, &bin_op_instruction->base.base, |
| 15378 | get_vector_type(ira->codegen, resolved_type->data.vector.len, ira->codegen->builtin_types.entry_bool)); | 16404 | get_vector_type(ira->codegen, resolved_type->data.vector.len, ira->codegen->builtin_types.entry_bool)); |
| 15379 | result->value->data.x_array.data.s_none.elements = | 16405 | result->value->data.x_array.data.s_none.elements = |
| 15380 | create_const_vals(resolved_type->data.vector.len); | 16406 | create_const_vals(resolved_type->data.vector.len); |
| 15381 | | 16407 | |
| 15382 | expand_undef_array(ira->codegen, result->value); | 16408 | expand_undef_array(ira->codegen, result->value); |
| 15383 | for (size_t i = 0;i < resolved_type->data.vector.len;i++) { | 16409 | for (size_t i = 0;i < resolved_type->data.vector.len;i++) { |
| 15384 | IrInstruction *cur_res = ir_evaluate_bin_op_cmp(ira, resolved_type->data.vector.elem_type, | 16410 | IrInstGen *cur_res = ir_evaluate_bin_op_cmp(ira, resolved_type->data.vector.elem_type, |
| 15385 | &op1_val->data.x_array.data.s_none.elements[i], | 16411 | &op1_val->data.x_array.data.s_none.elements[i], |
| 15386 | &op2_val->data.x_array.data.s_none.elements[i], | 16412 | &op2_val->data.x_array.data.s_none.elements[i], |
| 15387 | bin_op_instruction, op_id, one_possible_value); | 16413 | bin_op_instruction, op_id, one_possible_value); |
| ... | @@ -15390,19 +16416,14 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -15390,19 +16416,14 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 15390 | return result; | 16416 | return result; |
| 15391 | } | 16417 | } |
| 15392 | | 16418 | |
| 15393 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, | 16419 | ZigType *res_type = (resolved_type->id == ZigTypeIdVector) ? |
| 15394 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, | 16420 | get_vector_type(ira->codegen, resolved_type->data.vector.len, ira->codegen->builtin_types.entry_bool) : |
| | 16421 | ira->codegen->builtin_types.entry_bool; |
| | 16422 | return ir_build_bin_op_gen(ira, &bin_op_instruction->base.base, res_type, |
| 15395 | op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on); | 16423 | op_id, casted_op1, casted_op2, bin_op_instruction->safety_check_on); |
| 15396 | if (resolved_type->id == ZigTypeIdVector) { | | |
| 15397 | result->value->type = get_vector_type(ira->codegen, resolved_type->data.vector.len, | | |
| 15398 | ira->codegen->builtin_types.entry_bool); | | |
| 15399 | } else { | | |
| 15400 | result->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 15401 | } | | |
| 15402 | return result; | | |
| 15403 | } | 16424 | } |
| 15404 | | 16425 | |
| 15405 | static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_instr, ZigType *type_entry, | 16426 | static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInst* source_instr, ZigType *type_entry, |
| 15406 | ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val, ZigValue *out_val) | 16427 | ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val, ZigValue *out_val) |
| 15407 | { | 16428 | { |
| 15408 | bool is_int; | 16429 | bool is_int; |
| ... | @@ -15582,10 +16603,10 @@ static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -15582,10 +16603,10 @@ static ErrorMsg *ir_eval_math_op_scalar(IrAnalyze *ira, IrInstruction *source_in |
| 15582 | } | 16603 | } |
| 15583 | | 16604 | |
| 15584 | // This works on operands that have already been checked to be comptime known. | 16605 | // This works on operands that have already been checked to be comptime known. |
| 15585 | static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_instr, | 16606 | static IrInstGen *ir_analyze_math_op(IrAnalyze *ira, IrInst* source_instr, |
| 15586 | ZigType *type_entry, ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val) | 16607 | ZigType *type_entry, ZigValue *op1_val, IrBinOp op_id, ZigValue *op2_val) |
| 15587 | { | 16608 | { |
| 15588 | IrInstruction *result_instruction = ir_const(ira, source_instr, type_entry); | 16609 | IrInstGen *result_instruction = ir_const(ira, source_instr, type_entry); |
| 15589 | ZigValue *out_val = result_instruction->value; | 16610 | ZigValue *out_val = result_instruction->value; |
| 15590 | if (type_entry->id == ZigTypeIdVector) { | 16611 | if (type_entry->id == ZigTypeIdVector) { |
| 15591 | expand_undef_array(ira->codegen, op1_val); | 16612 | expand_undef_array(ira->codegen, op1_val); |
| ... | @@ -15606,43 +16627,43 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -15606,43 +16627,43 @@ static IrInstruction *ir_analyze_math_op(IrAnalyze *ira, IrInstruction *source_i |
| 15606 | if (msg != nullptr) { | 16627 | if (msg != nullptr) { |
| 15607 | add_error_note(ira->codegen, msg, source_instr->source_node, | 16628 | add_error_note(ira->codegen, msg, source_instr->source_node, |
| 15608 | buf_sprintf("when computing vector element at index %" ZIG_PRI_usize, i)); | 16629 | buf_sprintf("when computing vector element at index %" ZIG_PRI_usize, i)); |
| 15609 | return ira->codegen->invalid_instruction; | 16630 | return ira->codegen->invalid_inst_gen; |
| 15610 | } | 16631 | } |
| 15611 | } | 16632 | } |
| 15612 | out_val->type = type_entry; | 16633 | out_val->type = type_entry; |
| 15613 | out_val->special = ConstValSpecialStatic; | 16634 | out_val->special = ConstValSpecialStatic; |
| 15614 | } else { | 16635 | } else { |
| 15615 | if (ir_eval_math_op_scalar(ira, source_instr, type_entry, op1_val, op_id, op2_val, out_val) != nullptr) { | 16636 | if (ir_eval_math_op_scalar(ira, source_instr, type_entry, op1_val, op_id, op2_val, out_val) != nullptr) { |
| 15616 | return ira->codegen->invalid_instruction; | 16637 | return ira->codegen->invalid_inst_gen; |
| 15617 | } | 16638 | } |
| 15618 | } | 16639 | } |
| 15619 | return ir_implicit_cast(ira, result_instruction, type_entry); | 16640 | return ir_implicit_cast(ira, result_instruction, type_entry); |
| 15620 | } | 16641 | } |
| 15621 | | 16642 | |
| 15622 | static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { | 16643 | static IrInstGen *ir_analyze_bit_shift(IrAnalyze *ira, IrInstSrcBinOp *bin_op_instruction) { |
| 15623 | IrInstruction *op1 = bin_op_instruction->op1->child; | 16644 | IrInstGen *op1 = bin_op_instruction->op1->child; |
| 15624 | if (type_is_invalid(op1->value->type)) | 16645 | if (type_is_invalid(op1->value->type)) |
| 15625 | return ira->codegen->invalid_instruction; | 16646 | return ira->codegen->invalid_inst_gen; |
| 15626 | | 16647 | |
| 15627 | if (op1->value->type->id != ZigTypeIdInt && op1->value->type->id != ZigTypeIdComptimeInt) { | 16648 | if (op1->value->type->id != ZigTypeIdInt && op1->value->type->id != ZigTypeIdComptimeInt) { |
| 15628 | ir_add_error(ira, bin_op_instruction->op1, | 16649 | ir_add_error(ira, &bin_op_instruction->op1->base, |
| 15629 | buf_sprintf("bit shifting operation expected integer type, found '%s'", | 16650 | buf_sprintf("bit shifting operation expected integer type, found '%s'", |
| 15630 | buf_ptr(&op1->value->type->name))); | 16651 | buf_ptr(&op1->value->type->name))); |
| 15631 | return ira->codegen->invalid_instruction; | 16652 | return ira->codegen->invalid_inst_gen; |
| 15632 | } | 16653 | } |
| 15633 | | 16654 | |
| 15634 | IrInstruction *op2 = bin_op_instruction->op2->child; | 16655 | IrInstGen *op2 = bin_op_instruction->op2->child; |
| 15635 | if (type_is_invalid(op2->value->type)) | 16656 | if (type_is_invalid(op2->value->type)) |
| 15636 | return ira->codegen->invalid_instruction; | 16657 | return ira->codegen->invalid_inst_gen; |
| 15637 | | 16658 | |
| 15638 | if (op2->value->type->id != ZigTypeIdInt && op2->value->type->id != ZigTypeIdComptimeInt) { | 16659 | if (op2->value->type->id != ZigTypeIdInt && op2->value->type->id != ZigTypeIdComptimeInt) { |
| 15639 | ir_add_error(ira, bin_op_instruction->op2, | 16660 | ir_add_error(ira, &bin_op_instruction->op2->base, |
| 15640 | buf_sprintf("shift amount has to be an integer type, but found '%s'", | 16661 | buf_sprintf("shift amount has to be an integer type, but found '%s'", |
| 15641 | buf_ptr(&op2->value->type->name))); | 16662 | buf_ptr(&op2->value->type->name))); |
| 15642 | return ira->codegen->invalid_instruction; | 16663 | return ira->codegen->invalid_inst_gen; |
| 15643 | } | 16664 | } |
| 15644 | | 16665 | |
| 15645 | IrInstruction *casted_op2; | 16666 | IrInstGen *casted_op2; |
| 15646 | IrBinOp op_id = bin_op_instruction->op_id; | 16667 | IrBinOp op_id = bin_op_instruction->op_id; |
| 15647 | if (op1->value->type->id == ZigTypeIdComptimeInt) { | 16668 | if (op1->value->type->id == ZigTypeIdComptimeInt) { |
| 15648 | casted_op2 = op2; | 16669 | casted_op2 = op2; |
| ... | @@ -15654,8 +16675,8 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b | ... | @@ -15654,8 +16675,8 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b |
| 15654 | if (casted_op2->value->data.x_bigint.is_negative) { | 16675 | if (casted_op2->value->data.x_bigint.is_negative) { |
| 15655 | Buf *val_buf = buf_alloc(); | 16676 | Buf *val_buf = buf_alloc(); |
| 15656 | bigint_append_buf(val_buf, &casted_op2->value->data.x_bigint, 10); | 16677 | bigint_append_buf(val_buf, &casted_op2->value->data.x_bigint, 10); |
| 15657 | ir_add_error(ira, casted_op2, buf_sprintf("shift by negative value %s", buf_ptr(val_buf))); | 16678 | ir_add_error(ira, &casted_op2->base, buf_sprintf("shift by negative value %s", buf_ptr(val_buf))); |
| 15658 | return ira->codegen->invalid_instruction; | 16679 | return ira->codegen->invalid_inst_gen; |
| 15659 | } | 16680 | } |
| 15660 | } else { | 16681 | } else { |
| 15661 | ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, | 16682 | ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, |
| ... | @@ -15665,57 +16686,51 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b | ... | @@ -15665,57 +16686,51 @@ static IrInstruction *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *b |
| 15665 | | 16686 | |
| 15666 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 16687 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 15667 | if (op2_val == nullptr) | 16688 | if (op2_val == nullptr) |
| 15668 | return ira->codegen->invalid_instruction; | 16689 | return ira->codegen->invalid_inst_gen; |
| 15669 | if (!bigint_fits_in_bits(&op2_val->data.x_bigint, | 16690 | if (!bigint_fits_in_bits(&op2_val->data.x_bigint, |
| 15670 | shift_amt_type->data.integral.bit_count, | 16691 | shift_amt_type->data.integral.bit_count, |
| 15671 | op2_val->data.x_bigint.is_negative)) { | 16692 | op2_val->data.x_bigint.is_negative)) { |
| 15672 | Buf *val_buf = buf_alloc(); | 16693 | Buf *val_buf = buf_alloc(); |
| 15673 | bigint_append_buf(val_buf, &op2_val->data.x_bigint, 10); | 16694 | bigint_append_buf(val_buf, &op2_val->data.x_bigint, 10); |
| 15674 | ErrorMsg* msg = ir_add_error(ira, | 16695 | ErrorMsg* msg = ir_add_error(ira, |
| 15675 | &bin_op_instruction->base, | 16696 | &bin_op_instruction->base.base, |
| 15676 | buf_sprintf("RHS of shift is too large for LHS type")); | 16697 | buf_sprintf("RHS of shift is too large for LHS type")); |
| 15677 | add_error_note( | 16698 | add_error_note( |
| 15678 | ira->codegen, | 16699 | ira->codegen, |
| 15679 | msg, | 16700 | msg, |
| 15680 | op2->source_node, | 16701 | op2->base.source_node, |
| 15681 | buf_sprintf("value %s cannot fit into type %s", | 16702 | buf_sprintf("value %s cannot fit into type %s", |
| 15682 | buf_ptr(val_buf), | 16703 | buf_ptr(val_buf), |
| 15683 | buf_ptr(&shift_amt_type->name))); | 16704 | buf_ptr(&shift_amt_type->name))); |
| 15684 | return ira->codegen->invalid_instruction; | 16705 | return ira->codegen->invalid_inst_gen; |
| 15685 | } | 16706 | } |
| 15686 | } | 16707 | } |
| 15687 | | 16708 | |
| 15688 | casted_op2 = ir_implicit_cast(ira, op2, shift_amt_type); | 16709 | casted_op2 = ir_implicit_cast(ira, op2, shift_amt_type); |
| 15689 | if (casted_op2 == ira->codegen->invalid_instruction) | 16710 | if (type_is_invalid(casted_op2->value->type)) |
| 15690 | return ira->codegen->invalid_instruction; | 16711 | return ira->codegen->invalid_inst_gen; |
| 15691 | } | 16712 | } |
| 15692 | | 16713 | |
| 15693 | if (instr_is_comptime(op1) && instr_is_comptime(casted_op2)) { | 16714 | if (instr_is_comptime(op1) && instr_is_comptime(casted_op2)) { |
| 15694 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 16715 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 15695 | if (op1_val == nullptr) | 16716 | if (op1_val == nullptr) |
| 15696 | return ira->codegen->invalid_instruction; | 16717 | return ira->codegen->invalid_inst_gen; |
| 15697 | | 16718 | |
| 15698 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 16719 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 15699 | if (op2_val == nullptr) | 16720 | if (op2_val == nullptr) |
| 15700 | return ira->codegen->invalid_instruction; | 16721 | return ira->codegen->invalid_inst_gen; |
| 15701 | | 16722 | |
| 15702 | return ir_analyze_math_op(ira, &bin_op_instruction->base, op1->value->type, op1_val, op_id, op2_val); | 16723 | return ir_analyze_math_op(ira, &bin_op_instruction->base.base, op1->value->type, op1_val, op_id, op2_val); |
| 15703 | } else if (op1->value->type->id == ZigTypeIdComptimeInt) { | 16724 | } else if (op1->value->type->id == ZigTypeIdComptimeInt) { |
| 15704 | ir_add_error(ira, &bin_op_instruction->base, | 16725 | ir_add_error(ira, &bin_op_instruction->base.base, |
| 15705 | buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known")); | 16726 | buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known")); |
| 15706 | return ira->codegen->invalid_instruction; | 16727 | return ira->codegen->invalid_inst_gen; |
| 15707 | } else if (instr_is_comptime(casted_op2) && bigint_cmp_zero(&casted_op2->value->data.x_bigint) == CmpEQ) { | 16728 | } else if (instr_is_comptime(casted_op2) && bigint_cmp_zero(&casted_op2->value->data.x_bigint) == CmpEQ) { |
| 15708 | IrInstruction *result = ir_build_cast(&ira->new_irb, bin_op_instruction->base.scope, | 16729 | return ir_build_cast(ira, &bin_op_instruction->base.base, op1->value->type, op1, CastOpNoop); |
| 15709 | bin_op_instruction->base.source_node, op1->value->type, op1, CastOpNoop); | | |
| 15710 | result->value->type = op1->value->type; | | |
| 15711 | return result; | | |
| 15712 | } | 16730 | } |
| 15713 | | 16731 | |
| 15714 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, bin_op_instruction->base.scope, | 16732 | return ir_build_bin_op_gen(ira, &bin_op_instruction->base.base, op1->value->type, |
| 15715 | bin_op_instruction->base.source_node, op_id, | 16733 | op_id, op1, casted_op2, bin_op_instruction->safety_check_on); |
| 15716 | op1, casted_op2, bin_op_instruction->safety_check_on); | | |
| 15717 | result->value->type = op1->value->type; | | |
| 15718 | return result; | | |
| 15719 | } | 16734 | } |
| 15720 | | 16735 | |
| 15721 | static bool ok_float_op(IrBinOp op) { | 16736 | static bool ok_float_op(IrBinOp op) { |
| ... | @@ -15779,24 +16794,24 @@ static bool is_pointer_arithmetic_allowed(ZigType *lhs_type, IrBinOp op) { | ... | @@ -15779,24 +16794,24 @@ static bool is_pointer_arithmetic_allowed(ZigType *lhs_type, IrBinOp op) { |
| 15779 | zig_unreachable(); | 16794 | zig_unreachable(); |
| 15780 | } | 16795 | } |
| 15781 | | 16796 | |
| 15782 | static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp *instruction) { | 16797 | static IrInstGen *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstSrcBinOp *instruction) { |
| 15783 | Error err; | 16798 | Error err; |
| 15784 | | 16799 | |
| 15785 | IrInstruction *op1 = instruction->op1->child; | 16800 | IrInstGen *op1 = instruction->op1->child; |
| 15786 | if (type_is_invalid(op1->value->type)) | 16801 | if (type_is_invalid(op1->value->type)) |
| 15787 | return ira->codegen->invalid_instruction; | 16802 | return ira->codegen->invalid_inst_gen; |
| 15788 | | 16803 | |
| 15789 | IrInstruction *op2 = instruction->op2->child; | 16804 | IrInstGen *op2 = instruction->op2->child; |
| 15790 | if (type_is_invalid(op2->value->type)) | 16805 | if (type_is_invalid(op2->value->type)) |
| 15791 | return ira->codegen->invalid_instruction; | 16806 | return ira->codegen->invalid_inst_gen; |
| 15792 | | 16807 | |
| 15793 | IrBinOp op_id = instruction->op_id; | 16808 | IrBinOp op_id = instruction->op_id; |
| 15794 | | 16809 | |
| 15795 | // look for pointer math | 16810 | // look for pointer math |
| 15796 | if (is_pointer_arithmetic_allowed(op1->value->type, op_id)) { | 16811 | if (is_pointer_arithmetic_allowed(op1->value->type, op_id)) { |
| 15797 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, ira->codegen->builtin_types.entry_usize); | 16812 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, ira->codegen->builtin_types.entry_usize); |
| 15798 | if (type_is_invalid(casted_op2->value->type)) | 16813 | if (type_is_invalid(casted_op2->value->type)) |
| 15799 | return ira->codegen->invalid_instruction; | 16814 | return ira->codegen->invalid_inst_gen; |
| 15800 | | 16815 | |
| 15801 | // If either operand is undef, result is undef. | 16816 | // If either operand is undef, result is undef. |
| 15802 | ZigValue *op1_val = nullptr; | 16817 | ZigValue *op1_val = nullptr; |
| ... | @@ -15804,28 +16819,28 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15804,28 +16819,28 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15804 | if (instr_is_comptime(op1)) { | 16819 | if (instr_is_comptime(op1)) { |
| 15805 | op1_val = ir_resolve_const(ira, op1, UndefOk); | 16820 | op1_val = ir_resolve_const(ira, op1, UndefOk); |
| 15806 | if (op1_val == nullptr) | 16821 | if (op1_val == nullptr) |
| 15807 | return ira->codegen->invalid_instruction; | 16822 | return ira->codegen->invalid_inst_gen; |
| 15808 | if (op1_val->special == ConstValSpecialUndef) | 16823 | if (op1_val->special == ConstValSpecialUndef) |
| 15809 | return ir_const_undef(ira, &instruction->base, op1->value->type); | 16824 | return ir_const_undef(ira, &instruction->base.base, op1->value->type); |
| 15810 | } | 16825 | } |
| 15811 | if (instr_is_comptime(casted_op2)) { | 16826 | if (instr_is_comptime(casted_op2)) { |
| 15812 | op2_val = ir_resolve_const(ira, casted_op2, UndefOk); | 16827 | op2_val = ir_resolve_const(ira, casted_op2, UndefOk); |
| 15813 | if (op2_val == nullptr) | 16828 | if (op2_val == nullptr) |
| 15814 | return ira->codegen->invalid_instruction; | 16829 | return ira->codegen->invalid_inst_gen; |
| 15815 | if (op2_val->special == ConstValSpecialUndef) | 16830 | if (op2_val->special == ConstValSpecialUndef) |
| 15816 | return ir_const_undef(ira, &instruction->base, op1->value->type); | 16831 | return ir_const_undef(ira, &instruction->base.base, op1->value->type); |
| 15817 | } | 16832 | } |
| 15818 | | 16833 | |
| 15819 | ZigType *elem_type = op1->value->type->data.pointer.child_type; | 16834 | ZigType *elem_type = op1->value->type->data.pointer.child_type; |
| 15820 | if ((err = type_resolve(ira->codegen, elem_type, ResolveStatusSizeKnown))) | 16835 | if ((err = type_resolve(ira->codegen, elem_type, ResolveStatusSizeKnown))) |
| 15821 | return ira->codegen->invalid_instruction; | 16836 | return ira->codegen->invalid_inst_gen; |
| 15822 | | 16837 | |
| 15823 | // NOTE: this variable is meaningful iff op2_val is not null! | 16838 | // NOTE: this variable is meaningful iff op2_val is not null! |
| 15824 | uint64_t byte_offset; | 16839 | uint64_t byte_offset; |
| 15825 | if (op2_val != nullptr) { | 16840 | if (op2_val != nullptr) { |
| 15826 | uint64_t elem_offset; | 16841 | uint64_t elem_offset; |
| 15827 | if (!ir_resolve_usize(ira, casted_op2, &elem_offset)) | 16842 | if (!ir_resolve_usize(ira, casted_op2, &elem_offset)) |
| 15828 | return ira->codegen->invalid_instruction; | 16843 | return ira->codegen->invalid_inst_gen; |
| 15829 | | 16844 | |
| 15830 | byte_offset = type_size(ira->codegen, elem_type) * elem_offset; | 16845 | byte_offset = type_size(ira->codegen, elem_type) * elem_offset; |
| 15831 | } | 16846 | } |
| ... | @@ -15840,7 +16855,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15840,7 +16855,7 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15840 | { | 16855 | { |
| 15841 | uint32_t align_bytes; | 16856 | uint32_t align_bytes; |
| 15842 | if ((err = resolve_ptr_align(ira, op1->value->type, &align_bytes))) | 16857 | if ((err = resolve_ptr_align(ira, op1->value->type, &align_bytes))) |
| 15843 | return ira->codegen->invalid_instruction; | 16858 | return ira->codegen->invalid_inst_gen; |
| 15844 | | 16859 | |
| 15845 | // If the addend is not a comptime-known value we can still count on | 16860 | // If the addend is not a comptime-known value we can still count on |
| 15846 | // it being a multiple of the type size | 16861 | // it being a multiple of the type size |
| ... | @@ -15869,23 +16884,20 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15869,23 +16884,20 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15869 | } else { | 16884 | } else { |
| 15870 | zig_unreachable(); | 16885 | zig_unreachable(); |
| 15871 | } | 16886 | } |
| 15872 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 16887 | IrInstGen *result = ir_const(ira, &instruction->base.base, result_type); |
| 15873 | result->value->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; | 16888 | result->value->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; |
| 15874 | result->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; | 16889 | result->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; |
| 15875 | result->value->data.x_ptr.data.hard_coded_addr.addr = new_addr; | 16890 | result->value->data.x_ptr.data.hard_coded_addr.addr = new_addr; |
| 15876 | return result; | 16891 | return result; |
| 15877 | } | 16892 | } |
| 15878 | | 16893 | |
| 15879 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, instruction->base.scope, | 16894 | return ir_build_bin_op_gen(ira, &instruction->base.base, result_type, op_id, op1, casted_op2, true); |
| 15880 | instruction->base.source_node, op_id, op1, casted_op2, true); | | |
| 15881 | result->value->type = result_type; | | |
| 15882 | return result; | | |
| 15883 | } | 16895 | } |
| 15884 | | 16896 | |
| 15885 | IrInstruction *instructions[] = {op1, op2}; | 16897 | IrInstGen *instructions[] = {op1, op2}; |
| 15886 | ZigType *resolved_type = ir_resolve_peer_types(ira, instruction->base.source_node, nullptr, instructions, 2); | 16898 | ZigType *resolved_type = ir_resolve_peer_types(ira, instruction->base.base.source_node, nullptr, instructions, 2); |
| 15887 | if (type_is_invalid(resolved_type)) | 16899 | if (type_is_invalid(resolved_type)) |
| 15888 | return ira->codegen->invalid_instruction; | 16900 | return ira->codegen->invalid_inst_gen; |
| 15889 | | 16901 | |
| 15890 | bool is_int = resolved_type->id == ZigTypeIdInt || resolved_type->id == ZigTypeIdComptimeInt; | 16902 | bool is_int = resolved_type->id == ZigTypeIdInt || resolved_type->id == ZigTypeIdComptimeInt; |
| 15891 | bool is_float = resolved_type->id == ZigTypeIdFloat || resolved_type->id == ZigTypeIdComptimeFloat; | 16903 | bool is_float = resolved_type->id == ZigTypeIdFloat || resolved_type->id == ZigTypeIdComptimeFloat; |
| ... | @@ -15905,11 +16917,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15905,11 +16917,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15905 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { | 16917 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { |
| 15906 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 16918 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 15907 | if (op1_val == nullptr) | 16919 | if (op1_val == nullptr) |
| 15908 | return ira->codegen->invalid_instruction; | 16920 | return ira->codegen->invalid_inst_gen; |
| 15909 | | 16921 | |
| 15910 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 16922 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 15911 | if (op2_val == nullptr) | 16923 | if (op2_val == nullptr) |
| 15912 | return ira->codegen->invalid_instruction; | 16924 | return ira->codegen->invalid_inst_gen; |
| 15913 | | 16925 | |
| 15914 | if (bigint_cmp_zero(&op2_val->data.x_bigint) == CmpEQ) { | 16926 | if (bigint_cmp_zero(&op2_val->data.x_bigint) == CmpEQ) { |
| 15915 | // the division by zero error will be caught later, but we don't have a | 16927 | // the division by zero error will be caught later, but we don't have a |
| ... | @@ -15928,11 +16940,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15928,11 +16940,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15928 | } | 16940 | } |
| 15929 | } | 16941 | } |
| 15930 | if (!ok) { | 16942 | if (!ok) { |
| 15931 | ir_add_error(ira, &instruction->base, | 16943 | ir_add_error(ira, &instruction->base.base, |
| 15932 | buf_sprintf("division with '%s' and '%s': signed integers must use @divTrunc, @divFloor, or @divExact", | 16944 | buf_sprintf("division with '%s' and '%s': signed integers must use @divTrunc, @divFloor, or @divExact", |
| 15933 | buf_ptr(&op1->value->type->name), | 16945 | buf_ptr(&op1->value->type->name), |
| 15934 | buf_ptr(&op2->value->type->name))); | 16946 | buf_ptr(&op2->value->type->name))); |
| 15935 | return ira->codegen->invalid_instruction; | 16947 | return ira->codegen->invalid_inst_gen; |
| 15936 | } | 16948 | } |
| 15937 | } else { | 16949 | } else { |
| 15938 | op_id = IrBinOpDivTrunc; | 16950 | op_id = IrBinOpDivTrunc; |
| ... | @@ -15943,12 +16955,12 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15943,12 +16955,12 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15943 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { | 16955 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { |
| 15944 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 16956 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 15945 | if (op1_val == nullptr) | 16957 | if (op1_val == nullptr) |
| 15946 | return ira->codegen->invalid_instruction; | 16958 | return ira->codegen->invalid_inst_gen; |
| 15947 | | 16959 | |
| 15948 | if (is_int) { | 16960 | if (is_int) { |
| 15949 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 16961 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 15950 | if (op2_val == nullptr) | 16962 | if (op2_val == nullptr) |
| 15951 | return ira->codegen->invalid_instruction; | 16963 | return ira->codegen->invalid_inst_gen; |
| 15952 | | 16964 | |
| 15953 | if (bigint_cmp_zero(&op2->value->data.x_bigint) == CmpEQ) { | 16965 | if (bigint_cmp_zero(&op2->value->data.x_bigint) == CmpEQ) { |
| 15954 | // the division by zero error will be caught later, but we don't | 16966 | // the division by zero error will be caught later, but we don't |
| ... | @@ -15962,13 +16974,13 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15962,13 +16974,13 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15962 | ok = bigint_cmp(&rem_result, &mod_result) == CmpEQ; | 16974 | ok = bigint_cmp(&rem_result, &mod_result) == CmpEQ; |
| 15963 | } | 16975 | } |
| 15964 | } else { | 16976 | } else { |
| 15965 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); | 16977 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); |
| 15966 | if (casted_op2 == ira->codegen->invalid_instruction) | 16978 | if (type_is_invalid(casted_op2->value->type)) |
| 15967 | return ira->codegen->invalid_instruction; | 16979 | return ira->codegen->invalid_inst_gen; |
| 15968 | | 16980 | |
| 15969 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 16981 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 15970 | if (op2_val == nullptr) | 16982 | if (op2_val == nullptr) |
| 15971 | return ira->codegen->invalid_instruction; | 16983 | return ira->codegen->invalid_inst_gen; |
| 15972 | | 16984 | |
| 15973 | if (float_cmp_zero(casted_op2->value) == CmpEQ) { | 16985 | if (float_cmp_zero(casted_op2->value) == CmpEQ) { |
| 15974 | // the division by zero error will be caught later, but we don't | 16986 | // the division by zero error will be caught later, but we don't |
| ... | @@ -15984,11 +16996,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -15984,11 +16996,11 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 15984 | } | 16996 | } |
| 15985 | } | 16997 | } |
| 15986 | if (!ok) { | 16998 | if (!ok) { |
| 15987 | ir_add_error(ira, &instruction->base, | 16999 | ir_add_error(ira, &instruction->base.base, |
| 15988 | buf_sprintf("remainder division with '%s' and '%s': signed integers and floats must use @rem or @mod", | 17000 | buf_sprintf("remainder division with '%s' and '%s': signed integers and floats must use @rem or @mod", |
| 15989 | buf_ptr(&op1->value->type->name), | 17001 | buf_ptr(&op1->value->type->name), |
| 15990 | buf_ptr(&op2->value->type->name))); | 17002 | buf_ptr(&op2->value->type->name))); |
| 15991 | return ira->codegen->invalid_instruction; | 17003 | return ira->codegen->invalid_inst_gen; |
| 15992 | } | 17004 | } |
| 15993 | } | 17005 | } |
| 15994 | op_id = IrBinOpRemRem; | 17006 | op_id = IrBinOpRemRem; |
| ... | @@ -16008,12 +17020,12 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -16008,12 +17020,12 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 16008 | } | 17020 | } |
| 16009 | } | 17021 | } |
| 16010 | if (!ok) { | 17022 | if (!ok) { |
| 16011 | AstNode *source_node = instruction->base.source_node; | 17023 | AstNode *source_node = instruction->base.base.source_node; |
| 16012 | ir_add_error_node(ira, source_node, | 17024 | ir_add_error_node(ira, source_node, |
| 16013 | buf_sprintf("invalid operands to binary expression: '%s' and '%s'", | 17025 | buf_sprintf("invalid operands to binary expression: '%s' and '%s'", |
| 16014 | buf_ptr(&op1->value->type->name), | 17026 | buf_ptr(&op1->value->type->name), |
| 16015 | buf_ptr(&op2->value->type->name))); | 17027 | buf_ptr(&op2->value->type->name))); |
| 16016 | return ira->codegen->invalid_instruction; | 17028 | return ira->codegen->invalid_inst_gen; |
| 16017 | } | 17029 | } |
| 16018 | | 17030 | |
| 16019 | if (resolved_type->id == ZigTypeIdComptimeInt) { | 17031 | if (resolved_type->id == ZigTypeIdComptimeInt) { |
| ... | @@ -16026,33 +17038,31 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp | ... | @@ -16026,33 +17038,31 @@ static IrInstruction *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 16026 | } | 17038 | } |
| 16027 | } | 17039 | } |
| 16028 | | 17040 | |
| 16029 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); | 17041 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, resolved_type); |
| 16030 | if (casted_op1 == ira->codegen->invalid_instruction) | 17042 | if (type_is_invalid(casted_op1->value->type)) |
| 16031 | return ira->codegen->invalid_instruction; | 17043 | return ira->codegen->invalid_inst_gen; |
| 16032 | | 17044 | |
| 16033 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); | 17045 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, resolved_type); |
| 16034 | if (casted_op2 == ira->codegen->invalid_instruction) | 17046 | if (type_is_invalid(casted_op2->value->type)) |
| 16035 | return ira->codegen->invalid_instruction; | 17047 | return ira->codegen->invalid_inst_gen; |
| 16036 | | 17048 | |
| 16037 | if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) { | 17049 | if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) { |
| 16038 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); | 17050 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); |
| 16039 | if (op1_val == nullptr) | 17051 | if (op1_val == nullptr) |
| 16040 | return ira->codegen->invalid_instruction; | 17052 | return ira->codegen->invalid_inst_gen; |
| 16041 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 17053 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 16042 | if (op2_val == nullptr) | 17054 | if (op2_val == nullptr) |
| 16043 | return ira->codegen->invalid_instruction; | 17055 | return ira->codegen->invalid_inst_gen; |
| 16044 | | 17056 | |
| 16045 | return ir_analyze_math_op(ira, &instruction->base, resolved_type, op1_val, op_id, op2_val); | 17057 | return ir_analyze_math_op(ira, &instruction->base.base, resolved_type, op1_val, op_id, op2_val); |
| 16046 | } | 17058 | } |
| 16047 | | 17059 | |
| 16048 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, instruction->base.scope, | 17060 | return ir_build_bin_op_gen(ira, &instruction->base.base, resolved_type, |
| 16049 | instruction->base.source_node, op_id, casted_op1, casted_op2, instruction->safety_check_on); | 17061 | op_id, casted_op1, casted_op2, instruction->safety_check_on); |
| 16050 | result->value->type = resolved_type; | | |
| 16051 | return result; | | |
| 16052 | } | 17062 | } |
| 16053 | | 17063 | |
| 16054 | static IrInstruction *ir_analyze_tuple_cat(IrAnalyze *ira, IrInstruction *source_instr, | 17064 | static IrInstGen *ir_analyze_tuple_cat(IrAnalyze *ira, IrInst* source_instr, |
| 16055 | IrInstruction *op1, IrInstruction *op2) | 17065 | IrInstGen *op1, IrInstGen *op2) |
| 16056 | { | 17066 | { |
| 16057 | Error err; | 17067 | Error err; |
| 16058 | ZigType *op1_type = op1->value->type; | 17068 | ZigType *op1_type = op1->value->type; |
| ... | @@ -16069,9 +17079,9 @@ static IrInstruction *ir_analyze_tuple_cat(IrAnalyze *ira, IrInstruction *source | ... | @@ -16069,9 +17079,9 @@ static IrInstruction *ir_analyze_tuple_cat(IrAnalyze *ira, IrInstruction *source |
| 16069 | new_type->data.structure.special = StructSpecialInferredTuple; | 17079 | new_type->data.structure.special = StructSpecialInferredTuple; |
| 16070 | new_type->data.structure.resolve_status = ResolveStatusBeingInferred; | 17080 | new_type->data.structure.resolve_status = ResolveStatusBeingInferred; |
| 16071 | | 17081 | |
| 16072 | bool is_comptime = ir_should_inline(ira->new_irb.exec, source_instr->scope); | 17082 | bool is_comptime = ir_should_inline(ira->old_irb.exec, source_instr->scope); |
| 16073 | | 17083 | |
| 16074 | IrInstruction *new_struct_ptr = ir_resolve_result(ira, source_instr, no_result_loc(), | 17084 | IrInstGen *new_struct_ptr = ir_resolve_result(ira, source_instr, no_result_loc(), |
| 16075 | new_type, nullptr, false, false, true); | 17085 | new_type, nullptr, false, false, true); |
| 16076 | uint32_t new_field_count = op1_field_count + op2_field_count; | 17086 | uint32_t new_field_count = op1_field_count + op2_field_count; |
| 16077 | | 17087 | |
| ... | @@ -16095,13 +17105,13 @@ static IrInstruction *ir_analyze_tuple_cat(IrAnalyze *ira, IrInstruction *source | ... | @@ -16095,13 +17105,13 @@ static IrInstruction *ir_analyze_tuple_cat(IrAnalyze *ira, IrInstruction *source |
| 16095 | new_field->is_comptime = src_field->is_comptime; | 17105 | new_field->is_comptime = src_field->is_comptime; |
| 16096 | } | 17106 | } |
| 16097 | if ((err = type_resolve(ira->codegen, new_type, ResolveStatusZeroBitsKnown))) | 17107 | if ((err = type_resolve(ira->codegen, new_type, ResolveStatusZeroBitsKnown))) |
| 16098 | return ira->codegen->invalid_instruction; | 17108 | return ira->codegen->invalid_inst_gen; |
| 16099 | | 17109 | |
| 16100 | ZigList<IrInstruction *> const_ptrs = {}; | 17110 | ZigList<IrInstGen *> const_ptrs = {}; |
| 16101 | IrInstruction *first_non_const_instruction = nullptr; | 17111 | IrInstGen *first_non_const_instruction = nullptr; |
| 16102 | for (uint32_t i = 0; i < new_field_count; i += 1) { | 17112 | for (uint32_t i = 0; i < new_field_count; i += 1) { |
| 16103 | TypeStructField *dst_field = new_type->data.structure.fields[i]; | 17113 | TypeStructField *dst_field = new_type->data.structure.fields[i]; |
| 16104 | IrInstruction *src_struct_op; | 17114 | IrInstGen *src_struct_op; |
| 16105 | TypeStructField *src_field; | 17115 | TypeStructField *src_field; |
| 16106 | if (i < op1_field_count) { | 17116 | if (i < op1_field_count) { |
| 16107 | src_field = op1_type->data.structure.fields[i]; | 17117 | src_field = op1_type->data.structure.fields[i]; |
| ... | @@ -16110,73 +17120,73 @@ static IrInstruction *ir_analyze_tuple_cat(IrAnalyze *ira, IrInstruction *source | ... | @@ -16110,73 +17120,73 @@ static IrInstruction *ir_analyze_tuple_cat(IrAnalyze *ira, IrInstruction *source |
| 16110 | src_field = op2_type->data.structure.fields[i - op1_field_count]; | 17120 | src_field = op2_type->data.structure.fields[i - op1_field_count]; |
| 16111 | src_struct_op = op2; | 17121 | src_struct_op = op2; |
| 16112 | } | 17122 | } |
| 16113 | IrInstruction *field_value = ir_analyze_struct_value_field_value(ira, source_instr, | 17123 | IrInstGen *field_value = ir_analyze_struct_value_field_value(ira, source_instr, |
| 16114 | src_struct_op, src_field); | 17124 | src_struct_op, src_field); |
| 16115 | if (type_is_invalid(field_value->value->type)) | 17125 | if (type_is_invalid(field_value->value->type)) |
| 16116 | return ira->codegen->invalid_instruction; | 17126 | return ira->codegen->invalid_inst_gen; |
| 16117 | IrInstruction *dest_ptr = ir_analyze_struct_field_ptr(ira, source_instr, dst_field, | 17127 | IrInstGen *dest_ptr = ir_analyze_struct_field_ptr(ira, source_instr, dst_field, |
| 16118 | new_struct_ptr, new_type, true); | 17128 | new_struct_ptr, new_type, true); |
| 16119 | if (type_is_invalid(dest_ptr->value->type)) | 17129 | if (type_is_invalid(dest_ptr->value->type)) |
| 16120 | return ira->codegen->invalid_instruction; | 17130 | return ira->codegen->invalid_inst_gen; |
| 16121 | if (instr_is_comptime(field_value)) { | 17131 | if (instr_is_comptime(field_value)) { |
| 16122 | const_ptrs.append(dest_ptr); | 17132 | const_ptrs.append(dest_ptr); |
| 16123 | } else { | 17133 | } else { |
| 16124 | first_non_const_instruction = field_value; | 17134 | first_non_const_instruction = field_value; |
| 16125 | } | 17135 | } |
| 16126 | IrInstruction *store_ptr_inst = ir_analyze_store_ptr(ira, source_instr, dest_ptr, field_value, | 17136 | IrInstGen *store_ptr_inst = ir_analyze_store_ptr(ira, source_instr, dest_ptr, field_value, |
| 16127 | true); | 17137 | true); |
| 16128 | if (type_is_invalid(store_ptr_inst->value->type)) | 17138 | if (type_is_invalid(store_ptr_inst->value->type)) |
| 16129 | return ira->codegen->invalid_instruction; | 17139 | return ira->codegen->invalid_inst_gen; |
| 16130 | } | 17140 | } |
| 16131 | if (const_ptrs.length != new_field_count) { | 17141 | if (const_ptrs.length != new_field_count) { |
| 16132 | new_struct_ptr->value->special = ConstValSpecialRuntime; | 17142 | new_struct_ptr->value->special = ConstValSpecialRuntime; |
| 16133 | for (size_t i = 0; i < const_ptrs.length; i += 1) { | 17143 | for (size_t i = 0; i < const_ptrs.length; i += 1) { |
| 16134 | IrInstruction *elem_result_loc = const_ptrs.at(i); | 17144 | IrInstGen *elem_result_loc = const_ptrs.at(i); |
| 16135 | assert(elem_result_loc->value->special == ConstValSpecialStatic); | 17145 | assert(elem_result_loc->value->special == ConstValSpecialStatic); |
| 16136 | if (elem_result_loc->value->type->data.pointer.inferred_struct_field != nullptr) { | 17146 | if (elem_result_loc->value->type->data.pointer.inferred_struct_field != nullptr) { |
| 16137 | // This field will be generated comptime; no need to do this. | 17147 | // This field will be generated comptime; no need to do this. |
| 16138 | continue; | 17148 | continue; |
| 16139 | } | 17149 | } |
| 16140 | IrInstruction *deref = ir_get_deref(ira, elem_result_loc, elem_result_loc, nullptr); | 17150 | IrInstGen *deref = ir_get_deref(ira, &elem_result_loc->base, elem_result_loc, nullptr); |
| 16141 | elem_result_loc->value->special = ConstValSpecialRuntime; | 17151 | elem_result_loc->value->special = ConstValSpecialRuntime; |
| 16142 | ir_analyze_store_ptr(ira, elem_result_loc, elem_result_loc, deref, false); | 17152 | ir_analyze_store_ptr(ira, &elem_result_loc->base, elem_result_loc, deref, false); |
| 16143 | } | 17153 | } |
| 16144 | } | 17154 | } |
| 16145 | IrInstruction *result = ir_get_deref(ira, source_instr, new_struct_ptr, nullptr); | 17155 | IrInstGen *result = ir_get_deref(ira, source_instr, new_struct_ptr, nullptr); |
| 16146 | if (instr_is_comptime(result)) | 17156 | if (instr_is_comptime(result)) |
| 16147 | return result; | 17157 | return result; |
| 16148 | | 17158 | |
| 16149 | if (is_comptime) { | 17159 | if (is_comptime) { |
| 16150 | ir_add_error_node(ira, first_non_const_instruction->source_node, | 17160 | ir_add_error(ira, &first_non_const_instruction->base, |
| 16151 | buf_sprintf("unable to evaluate constant expression")); | 17161 | buf_sprintf("unable to evaluate constant expression")); |
| 16152 | return ira->codegen->invalid_instruction; | 17162 | return ira->codegen->invalid_inst_gen; |
| 16153 | } | 17163 | } |
| 16154 | | 17164 | |
| 16155 | return result; | 17165 | return result; |
| 16156 | } | 17166 | } |
| 16157 | | 17167 | |
| 16158 | static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *instruction) { | 17168 | static IrInstGen *ir_analyze_array_cat(IrAnalyze *ira, IrInstSrcBinOp *instruction) { |
| 16159 | IrInstruction *op1 = instruction->op1->child; | 17169 | IrInstGen *op1 = instruction->op1->child; |
| 16160 | ZigType *op1_type = op1->value->type; | 17170 | ZigType *op1_type = op1->value->type; |
| 16161 | if (type_is_invalid(op1_type)) | 17171 | if (type_is_invalid(op1_type)) |
| 16162 | return ira->codegen->invalid_instruction; | 17172 | return ira->codegen->invalid_inst_gen; |
| 16163 | | 17173 | |
| 16164 | IrInstruction *op2 = instruction->op2->child; | 17174 | IrInstGen *op2 = instruction->op2->child; |
| 16165 | ZigType *op2_type = op2->value->type; | 17175 | ZigType *op2_type = op2->value->type; |
| 16166 | if (type_is_invalid(op2_type)) | 17176 | if (type_is_invalid(op2_type)) |
| 16167 | return ira->codegen->invalid_instruction; | 17177 | return ira->codegen->invalid_inst_gen; |
| 16168 | | 17178 | |
| 16169 | if (is_tuple(op1_type) && is_tuple(op2_type)) { | 17179 | if (is_tuple(op1_type) && is_tuple(op2_type)) { |
| 16170 | return ir_analyze_tuple_cat(ira, &instruction->base, op1, op2); | 17180 | return ir_analyze_tuple_cat(ira, &instruction->base.base, op1, op2); |
| 16171 | } | 17181 | } |
| 16172 | | 17182 | |
| 16173 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); | 17183 | ZigValue *op1_val = ir_resolve_const(ira, op1, UndefBad); |
| 16174 | if (!op1_val) | 17184 | if (!op1_val) |
| 16175 | return ira->codegen->invalid_instruction; | 17185 | return ira->codegen->invalid_inst_gen; |
| 16176 | | 17186 | |
| 16177 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); | 17187 | ZigValue *op2_val = ir_resolve_const(ira, op2, UndefBad); |
| 16178 | if (!op2_val) | 17188 | if (!op2_val) |
| 16179 | return ira->codegen->invalid_instruction; | 17189 | return ira->codegen->invalid_inst_gen; |
| 16180 | | 17190 | |
| 16181 | ZigValue *sentinel1 = nullptr; | 17191 | ZigValue *sentinel1 = nullptr; |
| 16182 | ZigValue *op1_array_val; | 17192 | ZigValue *op1_array_val; |
| ... | @@ -16214,15 +17224,15 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -16214,15 +17224,15 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 16214 | { | 17224 | { |
| 16215 | ZigType *array_type = op1_type->data.pointer.child_type; | 17225 | ZigType *array_type = op1_type->data.pointer.child_type; |
| 16216 | child_type = array_type->data.array.child_type; | 17226 | child_type = array_type->data.array.child_type; |
| 16217 | op1_array_val = const_ptr_pointee(ira, ira->codegen, op1_val, op1->source_node); | 17227 | op1_array_val = const_ptr_pointee(ira, ira->codegen, op1_val, op1->base.source_node); |
| 16218 | if (op1_array_val == nullptr) | 17228 | if (op1_array_val == nullptr) |
| 16219 | return ira->codegen->invalid_instruction; | 17229 | return ira->codegen->invalid_inst_gen; |
| 16220 | op1_array_index = 0; | 17230 | op1_array_index = 0; |
| 16221 | op1_array_end = array_type->data.array.len; | 17231 | op1_array_end = array_type->data.array.len; |
| 16222 | sentinel1 = array_type->data.array.sentinel; | 17232 | sentinel1 = array_type->data.array.sentinel; |
| 16223 | } else { | 17233 | } else { |
| 16224 | ir_add_error(ira, op1, buf_sprintf("expected array, found '%s'", buf_ptr(&op1->value->type->name))); | 17234 | ir_add_error(ira, &op1->base, buf_sprintf("expected array, found '%s'", buf_ptr(&op1->value->type->name))); |
| 16225 | return ira->codegen->invalid_instruction; | 17235 | return ira->codegen->invalid_inst_gen; |
| 16226 | } | 17236 | } |
| 16227 | | 17237 | |
| 16228 | ZigValue *sentinel2 = nullptr; | 17238 | ZigValue *sentinel2 = nullptr; |
| ... | @@ -16262,23 +17272,23 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -16262,23 +17272,23 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 16262 | { | 17272 | { |
| 16263 | ZigType *array_type = op2_type->data.pointer.child_type; | 17273 | ZigType *array_type = op2_type->data.pointer.child_type; |
| 16264 | op2_type_valid = array_type->data.array.child_type == child_type; | 17274 | op2_type_valid = array_type->data.array.child_type == child_type; |
| 16265 | op2_array_val = const_ptr_pointee(ira, ira->codegen, op2_val, op2->source_node); | 17275 | op2_array_val = const_ptr_pointee(ira, ira->codegen, op2_val, op2->base.source_node); |
| 16266 | if (op2_array_val == nullptr) | 17276 | if (op2_array_val == nullptr) |
| 16267 | return ira->codegen->invalid_instruction; | 17277 | return ira->codegen->invalid_inst_gen; |
| 16268 | op2_array_index = 0; | 17278 | op2_array_index = 0; |
| 16269 | op2_array_end = array_type->data.array.len; | 17279 | op2_array_end = array_type->data.array.len; |
| 16270 | | 17280 | |
| 16271 | sentinel2 = array_type->data.array.sentinel; | 17281 | sentinel2 = array_type->data.array.sentinel; |
| 16272 | } else { | 17282 | } else { |
| 16273 | ir_add_error(ira, op2, | 17283 | ir_add_error(ira, &op2->base, |
| 16274 | buf_sprintf("expected array or C string literal, found '%s'", buf_ptr(&op2->value->type->name))); | 17284 | buf_sprintf("expected array or C string literal, found '%s'", buf_ptr(&op2->value->type->name))); |
| 16275 | return ira->codegen->invalid_instruction; | 17285 | return ira->codegen->invalid_inst_gen; |
| 16276 | } | 17286 | } |
| 16277 | if (!op2_type_valid) { | 17287 | if (!op2_type_valid) { |
| 16278 | ir_add_error(ira, op2, buf_sprintf("expected array of type '%s', found '%s'", | 17288 | ir_add_error(ira, &op2->base, buf_sprintf("expected array of type '%s', found '%s'", |
| 16279 | buf_ptr(&child_type->name), | 17289 | buf_ptr(&child_type->name), |
| 16280 | buf_ptr(&op2->value->type->name))); | 17290 | buf_ptr(&op2->value->type->name))); |
| 16281 | return ira->codegen->invalid_instruction; | 17291 | return ira->codegen->invalid_inst_gen; |
| 16282 | } | 17292 | } |
| 16283 | | 17293 | |
| 16284 | ZigValue *sentinel; | 17294 | ZigValue *sentinel; |
| ... | @@ -16295,7 +17305,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -16295,7 +17305,7 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 16295 | } | 17305 | } |
| 16296 | | 17306 | |
| 16297 | // The type of result is populated in the following if blocks | 17307 | // The type of result is populated in the following if blocks |
| 16298 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 17308 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 16299 | ZigValue *out_val = result->value; | 17309 | ZigValue *out_val = result->value; |
| 16300 | | 17310 | |
| 16301 | ZigValue *out_array_val; | 17311 | ZigValue *out_array_val; |
| ... | @@ -16383,14 +17393,14 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -16383,14 +17393,14 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 16383 | return result; | 17393 | return result; |
| 16384 | } | 17394 | } |
| 16385 | | 17395 | |
| 16386 | static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp *instruction) { | 17396 | static IrInstGen *ir_analyze_array_mult(IrAnalyze *ira, IrInstSrcBinOp *instruction) { |
| 16387 | IrInstruction *op1 = instruction->op1->child; | 17397 | IrInstGen *op1 = instruction->op1->child; |
| 16388 | if (type_is_invalid(op1->value->type)) | 17398 | if (type_is_invalid(op1->value->type)) |
| 16389 | return ira->codegen->invalid_instruction; | 17399 | return ira->codegen->invalid_inst_gen; |
| 16390 | | 17400 | |
| 16391 | IrInstruction *op2 = instruction->op2->child; | 17401 | IrInstGen *op2 = instruction->op2->child; |
| 16392 | if (type_is_invalid(op2->value->type)) | 17402 | if (type_is_invalid(op2->value->type)) |
| 16393 | return ira->codegen->invalid_instruction; | 17403 | return ira->codegen->invalid_inst_gen; |
| 16394 | | 17404 | |
| 16395 | bool want_ptr_to_array = false; | 17405 | bool want_ptr_to_array = false; |
| 16396 | ZigType *array_type; | 17406 | ZigType *array_type; |
| ... | @@ -16399,49 +17409,49 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -16399,49 +17409,49 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * |
| 16399 | array_type = op1->value->type; | 17409 | array_type = op1->value->type; |
| 16400 | array_val = ir_resolve_const(ira, op1, UndefOk); | 17410 | array_val = ir_resolve_const(ira, op1, UndefOk); |
| 16401 | if (array_val == nullptr) | 17411 | if (array_val == nullptr) |
| 16402 | return ira->codegen->invalid_instruction; | 17412 | return ira->codegen->invalid_inst_gen; |
| 16403 | } else if (op1->value->type->id == ZigTypeIdPointer && op1->value->type->data.pointer.ptr_len == PtrLenSingle && | 17413 | } else if (op1->value->type->id == ZigTypeIdPointer && op1->value->type->data.pointer.ptr_len == PtrLenSingle && |
| 16404 | op1->value->type->data.pointer.child_type->id == ZigTypeIdArray) | 17414 | op1->value->type->data.pointer.child_type->id == ZigTypeIdArray) |
| 16405 | { | 17415 | { |
| 16406 | array_type = op1->value->type->data.pointer.child_type; | 17416 | array_type = op1->value->type->data.pointer.child_type; |
| 16407 | IrInstruction *array_inst = ir_get_deref(ira, op1, op1, nullptr); | 17417 | IrInstGen *array_inst = ir_get_deref(ira, &op1->base, op1, nullptr); |
| 16408 | if (type_is_invalid(array_inst->value->type)) | 17418 | if (type_is_invalid(array_inst->value->type)) |
| 16409 | return ira->codegen->invalid_instruction; | 17419 | return ira->codegen->invalid_inst_gen; |
| 16410 | array_val = ir_resolve_const(ira, array_inst, UndefOk); | 17420 | array_val = ir_resolve_const(ira, array_inst, UndefOk); |
| 16411 | if (array_val == nullptr) | 17421 | if (array_val == nullptr) |
| 16412 | return ira->codegen->invalid_instruction; | 17422 | return ira->codegen->invalid_inst_gen; |
| 16413 | want_ptr_to_array = true; | 17423 | want_ptr_to_array = true; |
| 16414 | } else { | 17424 | } else { |
| 16415 | ir_add_error(ira, op1, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value->type->name))); | 17425 | ir_add_error(ira, &op1->base, buf_sprintf("expected array type, found '%s'", buf_ptr(&op1->value->type->name))); |
| 16416 | return ira->codegen->invalid_instruction; | 17426 | return ira->codegen->invalid_inst_gen; |
| 16417 | } | 17427 | } |
| 16418 | | 17428 | |
| 16419 | uint64_t mult_amt; | 17429 | uint64_t mult_amt; |
| 16420 | if (!ir_resolve_usize(ira, op2, &mult_amt)) | 17430 | if (!ir_resolve_usize(ira, op2, &mult_amt)) |
| 16421 | return ira->codegen->invalid_instruction; | 17431 | return ira->codegen->invalid_inst_gen; |
| 16422 | | 17432 | |
| 16423 | uint64_t old_array_len = array_type->data.array.len; | 17433 | uint64_t old_array_len = array_type->data.array.len; |
| 16424 | uint64_t new_array_len; | 17434 | uint64_t new_array_len; |
| 16425 | | 17435 | |
| 16426 | if (mul_u64_overflow(old_array_len, mult_amt, &new_array_len)) { | 17436 | if (mul_u64_overflow(old_array_len, mult_amt, &new_array_len)) { |
| 16427 | ir_add_error(ira, &instruction->base, buf_sprintf("operation results in overflow")); | 17437 | ir_add_error(ira, &instruction->base.base, buf_sprintf("operation results in overflow")); |
| 16428 | return ira->codegen->invalid_instruction; | 17438 | return ira->codegen->invalid_inst_gen; |
| 16429 | } | 17439 | } |
| 16430 | | 17440 | |
| 16431 | ZigType *child_type = array_type->data.array.child_type; | 17441 | ZigType *child_type = array_type->data.array.child_type; |
| 16432 | ZigType *result_array_type = get_array_type(ira->codegen, child_type, new_array_len, | 17442 | ZigType *result_array_type = get_array_type(ira->codegen, child_type, new_array_len, |
| 16433 | array_type->data.array.sentinel); | 17443 | array_type->data.array.sentinel); |
| 16434 | | 17444 | |
| 16435 | IrInstruction *array_result; | 17445 | IrInstGen *array_result; |
| 16436 | if (array_val->special == ConstValSpecialUndef || array_val->data.x_array.special == ConstArraySpecialUndef) { | 17446 | if (array_val->special == ConstValSpecialUndef || array_val->data.x_array.special == ConstArraySpecialUndef) { |
| 16437 | array_result = ir_const_undef(ira, &instruction->base, result_array_type); | 17447 | array_result = ir_const_undef(ira, &instruction->base.base, result_array_type); |
| 16438 | } else { | 17448 | } else { |
| 16439 | array_result = ir_const(ira, &instruction->base, result_array_type); | 17449 | array_result = ir_const(ira, &instruction->base.base, result_array_type); |
| 16440 | ZigValue *out_val = array_result->value; | 17450 | ZigValue *out_val = array_result->value; |
| 16441 | | 17451 | |
| 16442 | switch (type_has_one_possible_value(ira->codegen, result_array_type)) { | 17452 | switch (type_has_one_possible_value(ira->codegen, result_array_type)) { |
| 16443 | case OnePossibleValueInvalid: | 17453 | case OnePossibleValueInvalid: |
| 16444 | return ira->codegen->invalid_instruction; | 17454 | return ira->codegen->invalid_inst_gen; |
| 16445 | case OnePossibleValueYes: | 17455 | case OnePossibleValueYes: |
| 16446 | goto skip_computation; | 17456 | goto skip_computation; |
| 16447 | case OnePossibleValueNo: | 17457 | case OnePossibleValueNo: |
| ... | @@ -16477,35 +17487,35 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -16477,35 +17487,35 @@ static IrInstruction *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp * |
| 16477 | } | 17487 | } |
| 16478 | skip_computation: | 17488 | skip_computation: |
| 16479 | if (want_ptr_to_array) { | 17489 | if (want_ptr_to_array) { |
| 16480 | return ir_get_ref(ira, &instruction->base, array_result, true, false); | 17490 | return ir_get_ref(ira, &instruction->base.base, array_result, true, false); |
| 16481 | } else { | 17491 | } else { |
| 16482 | return array_result; | 17492 | return array_result; |
| 16483 | } | 17493 | } |
| 16484 | } | 17494 | } |
| 16485 | | 17495 | |
| 16486 | static IrInstruction *ir_analyze_instruction_merge_err_sets(IrAnalyze *ira, | 17496 | static IrInstGen *ir_analyze_instruction_merge_err_sets(IrAnalyze *ira, |
| 16487 | IrInstructionMergeErrSets *instruction) | 17497 | IrInstSrcMergeErrSets *instruction) |
| 16488 | { | 17498 | { |
| 16489 | ZigType *op1_type = ir_resolve_error_set_type(ira, &instruction->base, instruction->op1->child); | 17499 | ZigType *op1_type = ir_resolve_error_set_type(ira, &instruction->base.base, instruction->op1->child); |
| 16490 | if (type_is_invalid(op1_type)) | 17500 | if (type_is_invalid(op1_type)) |
| 16491 | return ira->codegen->invalid_instruction; | 17501 | return ira->codegen->invalid_inst_gen; |
| 16492 | | 17502 | |
| 16493 | ZigType *op2_type = ir_resolve_error_set_type(ira, &instruction->base, instruction->op2->child); | 17503 | ZigType *op2_type = ir_resolve_error_set_type(ira, &instruction->base.base, instruction->op2->child); |
| 16494 | if (type_is_invalid(op2_type)) | 17504 | if (type_is_invalid(op2_type)) |
| 16495 | return ira->codegen->invalid_instruction; | 17505 | return ira->codegen->invalid_inst_gen; |
| 16496 | | 17506 | |
| 16497 | if (type_is_global_error_set(op1_type) || | 17507 | if (type_is_global_error_set(op1_type) || |
| 16498 | type_is_global_error_set(op2_type)) | 17508 | type_is_global_error_set(op2_type)) |
| 16499 | { | 17509 | { |
| 16500 | return ir_const_type(ira, &instruction->base, ira->codegen->builtin_types.entry_global_error_set); | 17510 | return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_global_error_set); |
| 16501 | } | 17511 | } |
| 16502 | | 17512 | |
| 16503 | if (!resolve_inferred_error_set(ira->codegen, op1_type, instruction->op1->child->source_node)) { | 17513 | if (!resolve_inferred_error_set(ira->codegen, op1_type, instruction->op1->child->base.source_node)) { |
| 16504 | return ira->codegen->invalid_instruction; | 17514 | return ira->codegen->invalid_inst_gen; |
| 16505 | } | 17515 | } |
| 16506 | | 17516 | |
| 16507 | if (!resolve_inferred_error_set(ira->codegen, op2_type, instruction->op2->child->source_node)) { | 17517 | if (!resolve_inferred_error_set(ira->codegen, op2_type, instruction->op2->child->base.source_node)) { |
| 16508 | return ira->codegen->invalid_instruction; | 17518 | return ira->codegen->invalid_inst_gen; |
| 16509 | } | 17519 | } |
| 16510 | | 17520 | |
| 16511 | size_t errors_count = ira->codegen->errors_by_index.length; | 17521 | size_t errors_count = ira->codegen->errors_by_index.length; |
| ... | @@ -16518,11 +17528,11 @@ static IrInstruction *ir_analyze_instruction_merge_err_sets(IrAnalyze *ira, | ... | @@ -16518,11 +17528,11 @@ static IrInstruction *ir_analyze_instruction_merge_err_sets(IrAnalyze *ira, |
| 16518 | ZigType *result_type = get_error_set_union(ira->codegen, errors, op1_type, op2_type, instruction->type_name); | 17528 | ZigType *result_type = get_error_set_union(ira->codegen, errors, op1_type, op2_type, instruction->type_name); |
| 16519 | deallocate(errors, errors_count, "ErrorTableEntry *"); | 17529 | deallocate(errors, errors_count, "ErrorTableEntry *"); |
| 16520 | | 17530 | |
| 16521 | return ir_const_type(ira, &instruction->base, result_type); | 17531 | return ir_const_type(ira, &instruction->base.base, result_type); |
| 16522 | } | 17532 | } |
| 16523 | | 17533 | |
| 16524 | | 17534 | |
| 16525 | static IrInstruction *ir_analyze_instruction_bin_op(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { | 17535 | static IrInstGen *ir_analyze_instruction_bin_op(IrAnalyze *ira, IrInstSrcBinOp *bin_op_instruction) { |
| 16526 | IrBinOp op_id = bin_op_instruction->op_id; | 17536 | IrBinOp op_id = bin_op_instruction->op_id; |
| 16527 | switch (op_id) { | 17537 | switch (op_id) { |
| 16528 | case IrBinOpInvalid: | 17538 | case IrBinOpInvalid: |
| ... | @@ -16567,41 +17577,39 @@ static IrInstruction *ir_analyze_instruction_bin_op(IrAnalyze *ira, IrInstructio | ... | @@ -16567,41 +17577,39 @@ static IrInstruction *ir_analyze_instruction_bin_op(IrAnalyze *ira, IrInstructio |
| 16567 | zig_unreachable(); | 17577 | zig_unreachable(); |
| 16568 | } | 17578 | } |
| 16569 | | 17579 | |
| 16570 | static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | 17580 | static IrInstGen *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstSrcDeclVar *decl_var_instruction) { |
| 16571 | IrInstructionDeclVarSrc *decl_var_instruction) | | |
| 16572 | { | | |
| 16573 | Error err; | 17581 | Error err; |
| 16574 | ZigVar *var = decl_var_instruction->var; | 17582 | ZigVar *var = decl_var_instruction->var; |
| 16575 | | 17583 | |
| 16576 | ZigType *explicit_type = nullptr; | 17584 | ZigType *explicit_type = nullptr; |
| 16577 | IrInstruction *var_type = nullptr; | 17585 | IrInstGen *var_type = nullptr; |
| 16578 | if (decl_var_instruction->var_type != nullptr) { | 17586 | if (decl_var_instruction->var_type != nullptr) { |
| 16579 | var_type = decl_var_instruction->var_type->child; | 17587 | var_type = decl_var_instruction->var_type->child; |
| 16580 | ZigType *proposed_type = ir_resolve_type(ira, var_type); | 17588 | ZigType *proposed_type = ir_resolve_type(ira, var_type); |
| 16581 | explicit_type = validate_var_type(ira->codegen, var_type->source_node, proposed_type); | 17589 | explicit_type = validate_var_type(ira->codegen, var_type->base.source_node, proposed_type); |
| 16582 | if (type_is_invalid(explicit_type)) { | 17590 | if (type_is_invalid(explicit_type)) { |
| 16583 | var->var_type = ira->codegen->builtin_types.entry_invalid; | 17591 | var->var_type = ira->codegen->builtin_types.entry_invalid; |
| 16584 | return ira->codegen->invalid_instruction; | 17592 | return ira->codegen->invalid_inst_gen; |
| 16585 | } | 17593 | } |
| 16586 | } | 17594 | } |
| 16587 | | 17595 | |
| 16588 | AstNode *source_node = decl_var_instruction->base.source_node; | 17596 | AstNode *source_node = decl_var_instruction->base.base.source_node; |
| 16589 | | 17597 | |
| 16590 | bool is_comptime_var = ir_get_var_is_comptime(var); | 17598 | bool is_comptime_var = ir_get_var_is_comptime(var); |
| 16591 | | 17599 | |
| 16592 | bool var_class_requires_const = false; | 17600 | bool var_class_requires_const = false; |
| 16593 | | 17601 | |
| 16594 | IrInstruction *var_ptr = decl_var_instruction->ptr->child; | 17602 | IrInstGen *var_ptr = decl_var_instruction->ptr->child; |
| 16595 | // if this is null, a compiler error happened and did not initialize the variable. | 17603 | // if this is null, a compiler error happened and did not initialize the variable. |
| 16596 | // if there are no compile errors there may be a missing ir_expr_wrap in pass1 IR generation. | 17604 | // if there are no compile errors there may be a missing ir_expr_wrap in pass1 IR generation. |
| 16597 | if (var_ptr == nullptr || type_is_invalid(var_ptr->value->type)) { | 17605 | if (var_ptr == nullptr || type_is_invalid(var_ptr->value->type)) { |
| 16598 | ir_assert(var_ptr != nullptr || ira->codegen->errors.length != 0, &decl_var_instruction->base); | 17606 | ir_assert(var_ptr != nullptr || ira->codegen->errors.length != 0, &decl_var_instruction->base.base); |
| 16599 | var->var_type = ira->codegen->builtin_types.entry_invalid; | 17607 | var->var_type = ira->codegen->builtin_types.entry_invalid; |
| 16600 | return ira->codegen->invalid_instruction; | 17608 | return ira->codegen->invalid_inst_gen; |
| 16601 | } | 17609 | } |
| 16602 | | 17610 | |
| 16603 | // The ir_build_var_decl_src call is supposed to pass a pointer to the allocation, not an initialization value. | 17611 | // The ir_build_var_decl_src call is supposed to pass a pointer to the allocation, not an initialization value. |
| 16604 | ir_assert(var_ptr->value->type->id == ZigTypeIdPointer, &decl_var_instruction->base); | 17612 | ir_assert(var_ptr->value->type->id == ZigTypeIdPointer, &decl_var_instruction->base.base); |
| 16605 | | 17613 | |
| 16606 | ZigType *result_type = var_ptr->value->type->data.pointer.child_type; | 17614 | ZigType *result_type = var_ptr->value->type->data.pointer.child_type; |
| 16607 | if (type_is_invalid(result_type)) { | 17615 | if (type_is_invalid(result_type)) { |
| ... | @@ -16612,7 +17620,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -16612,7 +17620,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 16612 | | 17620 | |
| 16613 | ZigValue *init_val = nullptr; | 17621 | ZigValue *init_val = nullptr; |
| 16614 | if (instr_is_comptime(var_ptr) && var_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 17622 | if (instr_is_comptime(var_ptr) && var_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 16615 | init_val = const_ptr_pointee(ira, ira->codegen, var_ptr->value, decl_var_instruction->base.source_node); | 17623 | init_val = const_ptr_pointee(ira, ira->codegen, var_ptr->value, decl_var_instruction->base.base.source_node); |
| 16616 | if (is_comptime_var) { | 17624 | if (is_comptime_var) { |
| 16617 | if (var->gen_is_const) { | 17625 | if (var->gen_is_const) { |
| 16618 | var->const_value = init_val; | 17626 | var->const_value = init_val; |
| ... | @@ -16639,7 +17647,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -16639,7 +17647,7 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 16639 | case ReqCompTimeNo: | 17647 | case ReqCompTimeNo: |
| 16640 | if (init_val != nullptr && value_is_comptime(init_val)) { | 17648 | if (init_val != nullptr && value_is_comptime(init_val)) { |
| 16641 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, | 17649 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, |
| 16642 | decl_var_instruction->base.source_node, init_val, UndefOk))) | 17650 | decl_var_instruction->base.base.source_node, init_val, UndefOk))) |
| 16643 | { | 17651 | { |
| 16644 | result_type = ira->codegen->builtin_types.entry_invalid; | 17652 | result_type = ira->codegen->builtin_types.entry_invalid; |
| 16645 | } else if (init_val->type->id == ZigTypeIdFn && | 17653 | } else if (init_val->type->id == ZigTypeIdFn && |
| ... | @@ -16687,13 +17695,13 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -16687,13 +17695,13 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 16687 | assert(var->var_type); | 17695 | assert(var->var_type); |
| 16688 | | 17696 | |
| 16689 | if (type_is_invalid(result_type)) { | 17697 | if (type_is_invalid(result_type)) { |
| 16690 | return ir_const_void(ira, &decl_var_instruction->base); | 17698 | return ir_const_void(ira, &decl_var_instruction->base.base); |
| 16691 | } | 17699 | } |
| 16692 | | 17700 | |
| 16693 | if (decl_var_instruction->align_value == nullptr) { | 17701 | if (decl_var_instruction->align_value == nullptr) { |
| 16694 | if ((err = type_resolve(ira->codegen, result_type, ResolveStatusAlignmentKnown))) { | 17702 | if ((err = type_resolve(ira->codegen, result_type, ResolveStatusAlignmentKnown))) { |
| 16695 | var->var_type = ira->codegen->builtin_types.entry_invalid; | 17703 | var->var_type = ira->codegen->builtin_types.entry_invalid; |
| 16696 | return ir_const_void(ira, &decl_var_instruction->base); | 17704 | return ir_const_void(ira, &decl_var_instruction->base.base); |
| 16697 | } | 17705 | } |
| 16698 | var->align_bytes = get_abi_alignment(ira->codegen, result_type); | 17706 | var->align_bytes = get_abi_alignment(ira->codegen, result_type); |
| 16699 | } else { | 17707 | } else { |
| ... | @@ -16712,17 +17720,17 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -16712,17 +17720,17 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 16712 | // we need a runtime ptr but we have a comptime val. | 17720 | // we need a runtime ptr but we have a comptime val. |
| 16713 | // since it's a comptime val there are no instructions for it. | 17721 | // since it's a comptime val there are no instructions for it. |
| 16714 | // we memcpy the init value here | 17722 | // we memcpy the init value here |
| 16715 | IrInstruction *deref = ir_get_deref(ira, var_ptr, var_ptr, nullptr); | 17723 | IrInstGen *deref = ir_get_deref(ira, &var_ptr->base, var_ptr, nullptr); |
| 16716 | if (type_is_invalid(deref->value->type)) { | 17724 | if (type_is_invalid(deref->value->type)) { |
| 16717 | var->var_type = ira->codegen->builtin_types.entry_invalid; | 17725 | var->var_type = ira->codegen->builtin_types.entry_invalid; |
| 16718 | return ira->codegen->invalid_instruction; | 17726 | return ira->codegen->invalid_inst_gen; |
| 16719 | } | 17727 | } |
| 16720 | // If this assertion trips, something is wrong with the IR instructions, because | 17728 | // If this assertion trips, something is wrong with the IR instructions, because |
| 16721 | // we expected the above deref to return a constant value, but it created a runtime | 17729 | // we expected the above deref to return a constant value, but it created a runtime |
| 16722 | // instruction. | 17730 | // instruction. |
| 16723 | assert(deref->value->special != ConstValSpecialRuntime); | 17731 | assert(deref->value->special != ConstValSpecialRuntime); |
| 16724 | var_ptr->value->special = ConstValSpecialRuntime; | 17732 | var_ptr->value->special = ConstValSpecialRuntime; |
| 16725 | ir_analyze_store_ptr(ira, var_ptr, var_ptr, deref, false); | 17733 | ir_analyze_store_ptr(ira, &var_ptr->base, var_ptr, deref, false); |
| 16726 | } | 17734 | } |
| 16727 | | 17735 | |
| 16728 | if (instr_is_comptime(var_ptr) && var->mem_slot_index != SIZE_MAX) { | 17736 | if (instr_is_comptime(var_ptr) && var->mem_slot_index != SIZE_MAX) { |
| ... | @@ -16732,84 +17740,84 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, | ... | @@ -16732,84 +17740,84 @@ static IrInstruction *ir_analyze_instruction_decl_var(IrAnalyze *ira, |
| 16732 | ira_ref(var->owner_exec->analysis); | 17740 | ira_ref(var->owner_exec->analysis); |
| 16733 | | 17741 | |
| 16734 | if (is_comptime_var || (var_class_requires_const && var->gen_is_const)) { | 17742 | if (is_comptime_var || (var_class_requires_const && var->gen_is_const)) { |
| 16735 | return ir_const_void(ira, &decl_var_instruction->base); | 17743 | return ir_const_void(ira, &decl_var_instruction->base.base); |
| 16736 | } | 17744 | } |
| 16737 | } | 17745 | } |
| 16738 | } else if (is_comptime_var) { | 17746 | } else if (is_comptime_var) { |
| 16739 | ir_add_error(ira, &decl_var_instruction->base, | 17747 | ir_add_error(ira, &decl_var_instruction->base.base, |
| 16740 | buf_sprintf("cannot store runtime value in compile time variable")); | 17748 | buf_sprintf("cannot store runtime value in compile time variable")); |
| 16741 | var->var_type = ira->codegen->builtin_types.entry_invalid; | 17749 | var->var_type = ira->codegen->builtin_types.entry_invalid; |
| 16742 | return ira->codegen->invalid_instruction; | 17750 | return ira->codegen->invalid_inst_gen; |
| 16743 | } | 17751 | } |
| 16744 | | 17752 | |
| 16745 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 17753 | ZigFn *fn_entry = ira->new_irb.exec->fn_entry; |
| 16746 | if (fn_entry) | 17754 | if (fn_entry) |
| 16747 | fn_entry->variable_list.append(var); | 17755 | fn_entry->variable_list.append(var); |
| 16748 | | 17756 | |
| 16749 | return ir_build_var_decl_gen(ira, &decl_var_instruction->base, var, var_ptr); | 17757 | return ir_build_var_decl_gen(ira, &decl_var_instruction->base.base, var, var_ptr); |
| 16750 | } | 17758 | } |
| 16751 | | 17759 | |
| 16752 | static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExport *instruction) { | 17760 | static IrInstGen *ir_analyze_instruction_export(IrAnalyze *ira, IrInstSrcExport *instruction) { |
| 16753 | IrInstruction *target = instruction->target->child; | 17761 | IrInstGen *target = instruction->target->child; |
| 16754 | if (type_is_invalid(target->value->type)) | 17762 | if (type_is_invalid(target->value->type)) |
| 16755 | return ira->codegen->invalid_instruction; | 17763 | return ira->codegen->invalid_inst_gen; |
| 16756 | | 17764 | |
| 16757 | IrInstruction *options = instruction->options->child; | 17765 | IrInstGen *options = instruction->options->child; |
| 16758 | if (type_is_invalid(options->value->type)) | 17766 | if (type_is_invalid(options->value->type)) |
| 16759 | return ira->codegen->invalid_instruction; | 17767 | return ira->codegen->invalid_inst_gen; |
| 16760 | | 17768 | |
| 16761 | ZigType *options_type = options->value->type; | 17769 | ZigType *options_type = options->value->type; |
| 16762 | assert(options_type->id == ZigTypeIdStruct); | 17770 | assert(options_type->id == ZigTypeIdStruct); |
| 16763 | | 17771 | |
| 16764 | TypeStructField *name_field = find_struct_type_field(options_type, buf_create_from_str("name")); | 17772 | TypeStructField *name_field = find_struct_type_field(options_type, buf_create_from_str("name")); |
| 16765 | ir_assert(name_field != nullptr, &instruction->base); | 17773 | ir_assert(name_field != nullptr, &instruction->base.base); |
| 16766 | IrInstruction *name_inst = ir_analyze_struct_value_field_value(ira, &instruction->base, options, name_field); | 17774 | IrInstGen *name_inst = ir_analyze_struct_value_field_value(ira, &instruction->base.base, options, name_field); |
| 16767 | if (type_is_invalid(name_inst->value->type)) | 17775 | if (type_is_invalid(name_inst->value->type)) |
| 16768 | return ira->codegen->invalid_instruction; | 17776 | return ira->codegen->invalid_inst_gen; |
| 16769 | | 17777 | |
| 16770 | TypeStructField *linkage_field = find_struct_type_field(options_type, buf_create_from_str("linkage")); | 17778 | TypeStructField *linkage_field = find_struct_type_field(options_type, buf_create_from_str("linkage")); |
| 16771 | ir_assert(linkage_field != nullptr, &instruction->base); | 17779 | ir_assert(linkage_field != nullptr, &instruction->base.base); |
| 16772 | IrInstruction *linkage_inst = ir_analyze_struct_value_field_value(ira, &instruction->base, options, linkage_field); | 17780 | IrInstGen *linkage_inst = ir_analyze_struct_value_field_value(ira, &instruction->base.base, options, linkage_field); |
| 16773 | if (type_is_invalid(linkage_inst->value->type)) | 17781 | if (type_is_invalid(linkage_inst->value->type)) |
| 16774 | return ira->codegen->invalid_instruction; | 17782 | return ira->codegen->invalid_inst_gen; |
| 16775 | | 17783 | |
| 16776 | TypeStructField *section_field = find_struct_type_field(options_type, buf_create_from_str("section")); | 17784 | TypeStructField *section_field = find_struct_type_field(options_type, buf_create_from_str("section")); |
| 16777 | ir_assert(section_field != nullptr, &instruction->base); | 17785 | ir_assert(section_field != nullptr, &instruction->base.base); |
| 16778 | IrInstruction *section_inst = ir_analyze_struct_value_field_value(ira, &instruction->base, options, section_field); | 17786 | IrInstGen *section_inst = ir_analyze_struct_value_field_value(ira, &instruction->base.base, options, section_field); |
| 16779 | if (type_is_invalid(section_inst->value->type)) | 17787 | if (type_is_invalid(section_inst->value->type)) |
| 16780 | return ira->codegen->invalid_instruction; | 17788 | return ira->codegen->invalid_inst_gen; |
| 16781 | | 17789 | |
| 16782 | // The `section` field is optional, we have to unwrap it first | 17790 | // The `section` field is optional, we have to unwrap it first |
| 16783 | IrInstruction *non_null_check = ir_analyze_test_non_null(ira, &instruction->base, section_inst); | 17791 | IrInstGen *non_null_check = ir_analyze_test_non_null(ira, &instruction->base.base, section_inst); |
| 16784 | bool is_non_null; | 17792 | bool is_non_null; |
| 16785 | if (!ir_resolve_bool(ira, non_null_check, &is_non_null)) | 17793 | if (!ir_resolve_bool(ira, non_null_check, &is_non_null)) |
| 16786 | return ira->codegen->invalid_instruction; | 17794 | return ira->codegen->invalid_inst_gen; |
| 16787 | | 17795 | |
| 16788 | IrInstruction *section_str_inst = nullptr; | 17796 | IrInstGen *section_str_inst = nullptr; |
| 16789 | if (is_non_null) { | 17797 | if (is_non_null) { |
| 16790 | section_str_inst = ir_analyze_optional_value_payload_value(ira, &instruction->base, section_inst, false); | 17798 | section_str_inst = ir_analyze_optional_value_payload_value(ira, &instruction->base.base, section_inst, false); |
| 16791 | if (type_is_invalid(section_str_inst->value->type)) | 17799 | if (type_is_invalid(section_str_inst->value->type)) |
| 16792 | return ira->codegen->invalid_instruction; | 17800 | return ira->codegen->invalid_inst_gen; |
| 16793 | } | 17801 | } |
| 16794 | | 17802 | |
| 16795 | // Resolve all the comptime values | 17803 | // Resolve all the comptime values |
| 16796 | Buf *symbol_name = ir_resolve_str(ira, name_inst); | 17804 | Buf *symbol_name = ir_resolve_str(ira, name_inst); |
| 16797 | if (!symbol_name) | 17805 | if (!symbol_name) |
| 16798 | return ira->codegen->invalid_instruction; | 17806 | return ira->codegen->invalid_inst_gen; |
| 16799 | | 17807 | |
| 16800 | if (buf_len(symbol_name) < 1) { | 17808 | if (buf_len(symbol_name) < 1) { |
| 16801 | ir_add_error(ira, name_inst, | 17809 | ir_add_error(ira, &name_inst->base, |
| 16802 | buf_sprintf("exported symbol name cannot be empty")); | 17810 | buf_sprintf("exported symbol name cannot be empty")); |
| 16803 | return ira->codegen->invalid_instruction; | 17811 | return ira->codegen->invalid_inst_gen; |
| 16804 | } | 17812 | } |
| 16805 | | 17813 | |
| 16806 | GlobalLinkageId global_linkage_id; | 17814 | GlobalLinkageId global_linkage_id; |
| 16807 | if (!ir_resolve_global_linkage(ira, linkage_inst, &global_linkage_id)) | 17815 | if (!ir_resolve_global_linkage(ira, linkage_inst, &global_linkage_id)) |
| 16808 | return ira->codegen->invalid_instruction; | 17816 | return ira->codegen->invalid_inst_gen; |
| 16809 | | 17817 | |
| 16810 | Buf *section_name = nullptr; | 17818 | Buf *section_name = nullptr; |
| 16811 | if (section_str_inst != nullptr && !(section_name = ir_resolve_str(ira, section_str_inst))) | 17819 | if (section_str_inst != nullptr && !(section_name = ir_resolve_str(ira, section_str_inst))) |
| 16812 | return ira->codegen->invalid_instruction; | 17820 | return ira->codegen->invalid_inst_gen; |
| 16813 | | 17821 | |
| 16814 | // TODO: This function needs to be audited. | 17822 | // TODO: This function needs to be audited. |
| 16815 | // It's not clear how all the different types are supposed to be handled. | 17823 | // It's not clear how all the different types are supposed to be handled. |
| ... | @@ -16817,15 +17825,15 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16817,15 +17825,15 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16817 | // in another file. | 17825 | // in another file. |
| 16818 | TldFn *tld_fn = allocate<TldFn>(1); | 17826 | TldFn *tld_fn = allocate<TldFn>(1); |
| 16819 | tld_fn->base.id = TldIdFn; | 17827 | tld_fn->base.id = TldIdFn; |
| 16820 | tld_fn->base.source_node = instruction->base.source_node; | 17828 | tld_fn->base.source_node = instruction->base.base.source_node; |
| 16821 | | 17829 | |
| 16822 | auto entry = ira->codegen->exported_symbol_names.put_unique(symbol_name, &tld_fn->base); | 17830 | auto entry = ira->codegen->exported_symbol_names.put_unique(symbol_name, &tld_fn->base); |
| 16823 | if (entry) { | 17831 | if (entry) { |
| 16824 | AstNode *other_export_node = entry->value->source_node; | 17832 | AstNode *other_export_node = entry->value->source_node; |
| 16825 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, | 17833 | ErrorMsg *msg = ir_add_error(ira, &instruction->base.base, |
| 16826 | buf_sprintf("exported symbol collision: '%s'", buf_ptr(symbol_name))); | 17834 | buf_sprintf("exported symbol collision: '%s'", buf_ptr(symbol_name))); |
| 16827 | add_error_note(ira->codegen, msg, other_export_node, buf_sprintf("other symbol is here")); | 17835 | add_error_note(ira->codegen, msg, other_export_node, buf_sprintf("other symbol is here")); |
| 16828 | return ira->codegen->invalid_instruction; | 17836 | return ira->codegen->invalid_inst_gen; |
| 16829 | } | 17837 | } |
| 16830 | | 17838 | |
| 16831 | Error err; | 17839 | Error err; |
| ... | @@ -16841,12 +17849,12 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16841,12 +17849,12 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16841 | CallingConvention cc = fn_entry->type_entry->data.fn.fn_type_id.cc; | 17849 | CallingConvention cc = fn_entry->type_entry->data.fn.fn_type_id.cc; |
| 16842 | switch (cc) { | 17850 | switch (cc) { |
| 16843 | case CallingConventionUnspecified: { | 17851 | case CallingConventionUnspecified: { |
| 16844 | ErrorMsg *msg = ir_add_error(ira, target, | 17852 | ErrorMsg *msg = ir_add_error(ira, &target->base, |
| 16845 | buf_sprintf("exported function must specify calling convention")); | 17853 | buf_sprintf("exported function must specify calling convention")); |
| 16846 | add_error_note(ira->codegen, msg, fn_entry->proto_node, buf_sprintf("declared here")); | 17854 | add_error_note(ira->codegen, msg, fn_entry->proto_node, buf_sprintf("declared here")); |
| 16847 | } break; | 17855 | } break; |
| 16848 | case CallingConventionAsync: { | 17856 | case CallingConventionAsync: { |
| 16849 | ErrorMsg *msg = ir_add_error(ira, target, | 17857 | ErrorMsg *msg = ir_add_error(ira, &target->base, |
| 16850 | buf_sprintf("exported function cannot be async")); | 17858 | buf_sprintf("exported function cannot be async")); |
| 16851 | add_error_note(ira->codegen, msg, fn_entry->proto_node, buf_sprintf("declared here")); | 17859 | add_error_note(ira->codegen, msg, fn_entry->proto_node, buf_sprintf("declared here")); |
| 16852 | } break; | 17860 | } break; |
| ... | @@ -16869,10 +17877,10 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16869,10 +17877,10 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16869 | } break; | 17877 | } break; |
| 16870 | case ZigTypeIdStruct: | 17878 | case ZigTypeIdStruct: |
| 16871 | if (is_slice(target->value->type)) { | 17879 | if (is_slice(target->value->type)) { |
| 16872 | ir_add_error(ira, target, | 17880 | ir_add_error(ira, &target->base, |
| 16873 | buf_sprintf("unable to export value of type '%s'", buf_ptr(&target->value->type->name))); | 17881 | buf_sprintf("unable to export value of type '%s'", buf_ptr(&target->value->type->name))); |
| 16874 | } else if (target->value->type->data.structure.layout != ContainerLayoutExtern) { | 17882 | } else if (target->value->type->data.structure.layout != ContainerLayoutExtern) { |
| 16875 | ErrorMsg *msg = ir_add_error(ira, target, | 17883 | ErrorMsg *msg = ir_add_error(ira, &target->base, |
| 16876 | buf_sprintf("exported struct value must be declared extern")); | 17884 | buf_sprintf("exported struct value must be declared extern")); |
| 16877 | add_error_note(ira->codegen, msg, target->value->type->data.structure.decl_node, buf_sprintf("declared here")); | 17885 | add_error_note(ira->codegen, msg, target->value->type->data.structure.decl_node, buf_sprintf("declared here")); |
| 16878 | } else { | 17886 | } else { |
| ... | @@ -16881,7 +17889,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16881,7 +17889,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16881 | break; | 17889 | break; |
| 16882 | case ZigTypeIdUnion: | 17890 | case ZigTypeIdUnion: |
| 16883 | if (target->value->type->data.unionation.layout != ContainerLayoutExtern) { | 17891 | if (target->value->type->data.unionation.layout != ContainerLayoutExtern) { |
| 16884 | ErrorMsg *msg = ir_add_error(ira, target, | 17892 | ErrorMsg *msg = ir_add_error(ira, &target->base, |
| 16885 | buf_sprintf("exported union value must be declared extern")); | 17893 | buf_sprintf("exported union value must be declared extern")); |
| 16886 | add_error_note(ira->codegen, msg, target->value->type->data.unionation.decl_node, buf_sprintf("declared here")); | 17894 | add_error_note(ira->codegen, msg, target->value->type->data.unionation.decl_node, buf_sprintf("declared here")); |
| 16887 | } else { | 17895 | } else { |
| ... | @@ -16890,7 +17898,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16890,7 +17898,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16890 | break; | 17898 | break; |
| 16891 | case ZigTypeIdEnum: | 17899 | case ZigTypeIdEnum: |
| 16892 | if (target->value->type->data.enumeration.layout != ContainerLayoutExtern) { | 17900 | if (target->value->type->data.enumeration.layout != ContainerLayoutExtern) { |
| 16893 | ErrorMsg *msg = ir_add_error(ira, target, | 17901 | ErrorMsg *msg = ir_add_error(ira, &target->base, |
| 16894 | buf_sprintf("exported enum value must be declared extern")); | 17902 | buf_sprintf("exported enum value must be declared extern")); |
| 16895 | add_error_note(ira->codegen, msg, target->value->type->data.enumeration.decl_node, buf_sprintf("declared here")); | 17903 | add_error_note(ira->codegen, msg, target->value->type->data.enumeration.decl_node, buf_sprintf("declared here")); |
| 16896 | } else { | 17904 | } else { |
| ... | @@ -16900,10 +17908,10 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16900,10 +17908,10 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16900 | case ZigTypeIdArray: { | 17908 | case ZigTypeIdArray: { |
| 16901 | bool ok_type; | 17909 | bool ok_type; |
| 16902 | if ((err = type_allowed_in_extern(ira->codegen, target->value->type->data.array.child_type, &ok_type))) | 17910 | if ((err = type_allowed_in_extern(ira->codegen, target->value->type->data.array.child_type, &ok_type))) |
| 16903 | return ira->codegen->invalid_instruction; | 17911 | return ira->codegen->invalid_inst_gen; |
| 16904 | | 17912 | |
| 16905 | if (!ok_type) { | 17913 | if (!ok_type) { |
| 16906 | ir_add_error(ira, target, | 17914 | ir_add_error(ira, &target->base, |
| 16907 | buf_sprintf("array element type '%s' not extern-compatible", | 17915 | buf_sprintf("array element type '%s' not extern-compatible", |
| 16908 | buf_ptr(&target->value->type->data.array.child_type->name))); | 17916 | buf_ptr(&target->value->type->data.array.child_type->name))); |
| 16909 | } else { | 17917 | } else { |
| ... | @@ -16918,31 +17926,31 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16918,31 +17926,31 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16918 | zig_unreachable(); | 17926 | zig_unreachable(); |
| 16919 | case ZigTypeIdStruct: | 17927 | case ZigTypeIdStruct: |
| 16920 | if (is_slice(type_value)) { | 17928 | if (is_slice(type_value)) { |
| 16921 | ir_add_error(ira, target, | 17929 | ir_add_error(ira, &target->base, |
| 16922 | buf_sprintf("unable to export type '%s'", buf_ptr(&type_value->name))); | 17930 | buf_sprintf("unable to export type '%s'", buf_ptr(&type_value->name))); |
| 16923 | } else if (type_value->data.structure.layout != ContainerLayoutExtern) { | 17931 | } else if (type_value->data.structure.layout != ContainerLayoutExtern) { |
| 16924 | ErrorMsg *msg = ir_add_error(ira, target, | 17932 | ErrorMsg *msg = ir_add_error(ira, &target->base, |
| 16925 | buf_sprintf("exported struct must be declared extern")); | 17933 | buf_sprintf("exported struct must be declared extern")); |
| 16926 | add_error_note(ira->codegen, msg, type_value->data.structure.decl_node, buf_sprintf("declared here")); | 17934 | add_error_note(ira->codegen, msg, type_value->data.structure.decl_node, buf_sprintf("declared here")); |
| 16927 | } | 17935 | } |
| 16928 | break; | 17936 | break; |
| 16929 | case ZigTypeIdUnion: | 17937 | case ZigTypeIdUnion: |
| 16930 | if (type_value->data.unionation.layout != ContainerLayoutExtern) { | 17938 | if (type_value->data.unionation.layout != ContainerLayoutExtern) { |
| 16931 | ErrorMsg *msg = ir_add_error(ira, target, | 17939 | ErrorMsg *msg = ir_add_error(ira, &target->base, |
| 16932 | buf_sprintf("exported union must be declared extern")); | 17940 | buf_sprintf("exported union must be declared extern")); |
| 16933 | add_error_note(ira->codegen, msg, type_value->data.unionation.decl_node, buf_sprintf("declared here")); | 17941 | add_error_note(ira->codegen, msg, type_value->data.unionation.decl_node, buf_sprintf("declared here")); |
| 16934 | } | 17942 | } |
| 16935 | break; | 17943 | break; |
| 16936 | case ZigTypeIdEnum: | 17944 | case ZigTypeIdEnum: |
| 16937 | if (type_value->data.enumeration.layout != ContainerLayoutExtern) { | 17945 | if (type_value->data.enumeration.layout != ContainerLayoutExtern) { |
| 16938 | ErrorMsg *msg = ir_add_error(ira, target, | 17946 | ErrorMsg *msg = ir_add_error(ira, &target->base, |
| 16939 | buf_sprintf("exported enum must be declared extern")); | 17947 | buf_sprintf("exported enum must be declared extern")); |
| 16940 | add_error_note(ira->codegen, msg, type_value->data.enumeration.decl_node, buf_sprintf("declared here")); | 17948 | add_error_note(ira->codegen, msg, type_value->data.enumeration.decl_node, buf_sprintf("declared here")); |
| 16941 | } | 17949 | } |
| 16942 | break; | 17950 | break; |
| 16943 | case ZigTypeIdFn: { | 17951 | case ZigTypeIdFn: { |
| 16944 | if (type_value->data.fn.fn_type_id.cc == CallingConventionUnspecified) { | 17952 | if (type_value->data.fn.fn_type_id.cc == CallingConventionUnspecified) { |
| 16945 | ir_add_error(ira, target, | 17953 | ir_add_error(ira, &target->base, |
| 16946 | buf_sprintf("exported function type must specify calling convention")); | 17954 | buf_sprintf("exported function type must specify calling convention")); |
| 16947 | } | 17955 | } |
| 16948 | } break; | 17956 | } break; |
| ... | @@ -16968,7 +17976,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16968,7 +17976,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16968 | case ZigTypeIdOpaque: | 17976 | case ZigTypeIdOpaque: |
| 16969 | case ZigTypeIdFnFrame: | 17977 | case ZigTypeIdFnFrame: |
| 16970 | case ZigTypeIdAnyFrame: | 17978 | case ZigTypeIdAnyFrame: |
| 16971 | ir_add_error(ira, target, | 17979 | ir_add_error(ira, &target->base, |
| 16972 | buf_sprintf("invalid export target '%s'", buf_ptr(&type_value->name))); | 17980 | buf_sprintf("invalid export target '%s'", buf_ptr(&type_value->name))); |
| 16973 | break; | 17981 | break; |
| 16974 | } | 17982 | } |
| ... | @@ -16993,61 +18001,55 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16993,61 +18001,55 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16993 | case ZigTypeIdEnumLiteral: | 18001 | case ZigTypeIdEnumLiteral: |
| 16994 | case ZigTypeIdFnFrame: | 18002 | case ZigTypeIdFnFrame: |
| 16995 | case ZigTypeIdAnyFrame: | 18003 | case ZigTypeIdAnyFrame: |
| 16996 | ir_add_error(ira, target, | 18004 | ir_add_error(ira, &target->base, |
| 16997 | buf_sprintf("invalid export target type '%s'", buf_ptr(&target->value->type->name))); | 18005 | buf_sprintf("invalid export target type '%s'", buf_ptr(&target->value->type->name))); |
| 16998 | break; | 18006 | break; |
| 16999 | } | 18007 | } |
| 17000 | | 18008 | |
| 17001 | // TODO audit the various ways to use @export | 18009 | // TODO audit the various ways to use @export |
| 17002 | if (want_var_export && target->id == IrInstructionIdLoadPtrGen) { | 18010 | if (want_var_export && target->id == IrInstGenIdLoadPtr) { |
| 17003 | IrInstructionLoadPtrGen *load_ptr = reinterpret_cast<IrInstructionLoadPtrGen *>(target); | 18011 | IrInstGenLoadPtr *load_ptr = reinterpret_cast<IrInstGenLoadPtr *>(target); |
| 17004 | if (load_ptr->ptr->id == IrInstructionIdVarPtr) { | 18012 | if (load_ptr->ptr->id == IrInstGenIdVarPtr) { |
| 17005 | IrInstructionVarPtr *var_ptr = reinterpret_cast<IrInstructionVarPtr *>(load_ptr->ptr); | 18013 | IrInstGenVarPtr *var_ptr = reinterpret_cast<IrInstGenVarPtr *>(load_ptr->ptr); |
| 17006 | ZigVar *var = var_ptr->var; | 18014 | ZigVar *var = var_ptr->var; |
| 17007 | add_var_export(ira->codegen, var, buf_ptr(symbol_name), global_linkage_id); | 18015 | add_var_export(ira->codegen, var, buf_ptr(symbol_name), global_linkage_id); |
| 17008 | var->section_name = section_name; | 18016 | var->section_name = section_name; |
| 17009 | } | 18017 | } |
| 17010 | } | 18018 | } |
| 17011 | | 18019 | |
| 17012 | return ir_const_void(ira, &instruction->base); | 18020 | return ir_const_void(ira, &instruction->base.base); |
| 17013 | } | 18021 | } |
| 17014 | | 18022 | |
| 17015 | static bool exec_has_err_ret_trace(CodeGen *g, IrExecutable *exec) { | 18023 | static bool exec_has_err_ret_trace(CodeGen *g, IrExecutableSrc *exec) { |
| 17016 | ZigFn *fn_entry = exec_fn_entry(exec); | 18024 | ZigFn *fn_entry = exec_fn_entry(exec); |
| 17017 | return fn_entry != nullptr && fn_entry->calls_or_awaits_errorable_fn && g->have_err_ret_tracing; | 18025 | return fn_entry != nullptr && fn_entry->calls_or_awaits_errorable_fn && g->have_err_ret_tracing; |
| 17018 | } | 18026 | } |
| 17019 | | 18027 | |
| 17020 | static IrInstruction *ir_analyze_instruction_error_return_trace(IrAnalyze *ira, | 18028 | static IrInstGen *ir_analyze_instruction_error_return_trace(IrAnalyze *ira, |
| 17021 | IrInstructionErrorReturnTrace *instruction) | 18029 | IrInstSrcErrorReturnTrace *instruction) |
| 17022 | { | 18030 | { |
| 17023 | ZigType *ptr_to_stack_trace_type = get_pointer_to_type(ira->codegen, get_stack_trace_type(ira->codegen), false); | 18031 | ZigType *ptr_to_stack_trace_type = get_pointer_to_type(ira->codegen, get_stack_trace_type(ira->codegen), false); |
| 17024 | if (instruction->optional == IrInstructionErrorReturnTrace::Null) { | 18032 | if (instruction->optional == IrInstErrorReturnTraceNull) { |
| 17025 | ZigType *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type); | 18033 | ZigType *optional_type = get_optional_type(ira->codegen, ptr_to_stack_trace_type); |
| 17026 | if (!exec_has_err_ret_trace(ira->codegen, ira->new_irb.exec)) { | 18034 | if (!exec_has_err_ret_trace(ira->codegen, ira->old_irb.exec)) { |
| 17027 | IrInstruction *result = ir_const(ira, &instruction->base, optional_type); | 18035 | IrInstGen *result = ir_const(ira, &instruction->base.base, optional_type); |
| 17028 | ZigValue *out_val = result->value; | 18036 | ZigValue *out_val = result->value; |
| 17029 | assert(get_codegen_ptr_type(optional_type) != nullptr); | 18037 | assert(get_codegen_ptr_type(optional_type) != nullptr); |
| 17030 | out_val->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; | 18038 | out_val->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; |
| 17031 | out_val->data.x_ptr.data.hard_coded_addr.addr = 0; | 18039 | out_val->data.x_ptr.data.hard_coded_addr.addr = 0; |
| 17032 | return result; | 18040 | return result; |
| 17033 | } | 18041 | } |
| 17034 | IrInstruction *new_instruction = ir_build_error_return_trace(&ira->new_irb, instruction->base.scope, | 18042 | return ir_build_error_return_trace_gen(ira, instruction->base.base.scope, |
| 17035 | instruction->base.source_node, instruction->optional); | 18043 | instruction->base.base.source_node, instruction->optional, optional_type); |
| 17036 | new_instruction->value->type = optional_type; | | |
| 17037 | return new_instruction; | | |
| 17038 | } else { | 18044 | } else { |
| 17039 | assert(ira->codegen->have_err_ret_tracing); | 18045 | assert(ira->codegen->have_err_ret_tracing); |
| 17040 | IrInstruction *new_instruction = ir_build_error_return_trace(&ira->new_irb, instruction->base.scope, | 18046 | return ir_build_error_return_trace_gen(ira, instruction->base.base.scope, |
| 17041 | instruction->base.source_node, instruction->optional); | 18047 | instruction->base.base.source_node, instruction->optional, ptr_to_stack_trace_type); |
| 17042 | new_instruction->value->type = ptr_to_stack_trace_type; | | |
| 17043 | return new_instruction; | | |
| 17044 | } | 18048 | } |
| 17045 | } | 18049 | } |
| 17046 | | 18050 | |
| 17047 | static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira, | 18051 | static IrInstGen *ir_analyze_instruction_error_union(IrAnalyze *ira, IrInstSrcErrorUnion *instruction) { |
| 17048 | IrInstructionErrorUnion *instruction) | 18052 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 17049 | { | | |
| 17050 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); | | |
| 17051 | result->value->special = ConstValSpecialLazy; | 18053 | result->value->special = ConstValSpecialLazy; |
| 17052 | | 18054 | |
| 17053 | LazyValueErrUnionType *lazy_err_union_type = allocate<LazyValueErrUnionType>(1, "LazyValueErrUnionType"); | 18055 | LazyValueErrUnionType *lazy_err_union_type = allocate<LazyValueErrUnionType>(1, "LazyValueErrUnionType"); |
| ... | @@ -17057,16 +18059,16 @@ static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira, | ... | @@ -17057,16 +18059,16 @@ static IrInstruction *ir_analyze_instruction_error_union(IrAnalyze *ira, |
| 17057 | | 18059 | |
| 17058 | lazy_err_union_type->err_set_type = instruction->err_set->child; | 18060 | lazy_err_union_type->err_set_type = instruction->err_set->child; |
| 17059 | if (ir_resolve_type_lazy(ira, lazy_err_union_type->err_set_type) == nullptr) | 18061 | if (ir_resolve_type_lazy(ira, lazy_err_union_type->err_set_type) == nullptr) |
| 17060 | return ira->codegen->invalid_instruction; | 18062 | return ira->codegen->invalid_inst_gen; |
| 17061 | | 18063 | |
| 17062 | lazy_err_union_type->payload_type = instruction->payload->child; | 18064 | lazy_err_union_type->payload_type = instruction->payload->child; |
| 17063 | if (ir_resolve_type_lazy(ira, lazy_err_union_type->payload_type) == nullptr) | 18065 | if (ir_resolve_type_lazy(ira, lazy_err_union_type->payload_type) == nullptr) |
| 17064 | return ira->codegen->invalid_instruction; | 18066 | return ira->codegen->invalid_inst_gen; |
| 17065 | | 18067 | |
| 17066 | return result; | 18068 | return result; |
| 17067 | } | 18069 | } |
| 17068 | | 18070 | |
| 17069 | static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_inst, ZigType *var_type, | 18071 | static IrInstGen *ir_analyze_alloca(IrAnalyze *ira, IrInst *source_inst, ZigType *var_type, |
| 17070 | uint32_t align, const char *name_hint, bool force_comptime) | 18072 | uint32_t align, const char *name_hint, bool force_comptime) |
| 17071 | { | 18073 | { |
| 17072 | Error err; | 18074 | Error err; |
| ... | @@ -17074,7 +18076,7 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -17074,7 +18076,7 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in |
| 17074 | ZigValue *pointee = create_const_vals(1); | 18076 | ZigValue *pointee = create_const_vals(1); |
| 17075 | pointee->special = ConstValSpecialUndef; | 18077 | pointee->special = ConstValSpecialUndef; |
| 17076 | | 18078 | |
| 17077 | IrInstructionAllocaGen *result = ir_build_alloca_gen(ira, source_inst, align, name_hint); | 18079 | IrInstGenAlloca *result = ir_build_alloca_gen(ira, source_inst, align, name_hint); |
| 17078 | result->base.value->special = ConstValSpecialStatic; | 18080 | result->base.value->special = ConstValSpecialStatic; |
| 17079 | result->base.value->data.x_ptr.special = ConstPtrSpecialRef; | 18081 | result->base.value->data.x_ptr.special = ConstPtrSpecialRef; |
| 17080 | result->base.value->data.x_ptr.mut = force_comptime ? ConstPtrMutComptimeVar : ConstPtrMutInfer; | 18082 | result->base.value->data.x_ptr.mut = force_comptime ? ConstPtrMutComptimeVar : ConstPtrMutInfer; |
| ... | @@ -17082,15 +18084,15 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -17082,15 +18084,15 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in |
| 17082 | | 18084 | |
| 17083 | bool var_type_has_bits; | 18085 | bool var_type_has_bits; |
| 17084 | if ((err = type_has_bits2(ira->codegen, var_type, &var_type_has_bits))) | 18086 | if ((err = type_has_bits2(ira->codegen, var_type, &var_type_has_bits))) |
| 17085 | return ira->codegen->invalid_instruction; | 18087 | return ira->codegen->invalid_inst_gen; |
| 17086 | if (align != 0) { | 18088 | if (align != 0) { |
| 17087 | if ((err = type_resolve(ira->codegen, var_type, ResolveStatusAlignmentKnown))) | 18089 | if ((err = type_resolve(ira->codegen, var_type, ResolveStatusAlignmentKnown))) |
| 17088 | return ira->codegen->invalid_instruction; | 18090 | return ira->codegen->invalid_inst_gen; |
| 17089 | if (!var_type_has_bits) { | 18091 | if (!var_type_has_bits) { |
| 17090 | ir_add_error(ira, source_inst, | 18092 | ir_add_error(ira, source_inst, |
| 17091 | buf_sprintf("variable '%s' of zero-bit type '%s' has no in-memory representation, it cannot be aligned", | 18093 | buf_sprintf("variable '%s' of zero-bit type '%s' has no in-memory representation, it cannot be aligned", |
| 17092 | name_hint, buf_ptr(&var_type->name))); | 18094 | name_hint, buf_ptr(&var_type->name))); |
| 17093 | return ira->codegen->invalid_instruction; | 18095 | return ira->codegen->invalid_inst_gen; |
| 17094 | } | 18096 | } |
| 17095 | } | 18097 | } |
| 17096 | assert(result->base.value->data.x_ptr.special != ConstPtrSpecialInvalid); | 18098 | assert(result->base.value->data.x_ptr.special != ConstPtrSpecialInvalid); |
| ... | @@ -17099,15 +18101,14 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in | ... | @@ -17099,15 +18101,14 @@ static IrInstruction *ir_analyze_alloca(IrAnalyze *ira, IrInstruction *source_in |
| 17099 | result->base.value->type = get_pointer_to_type_extra(ira->codegen, var_type, false, false, | 18101 | result->base.value->type = get_pointer_to_type_extra(ira->codegen, var_type, false, false, |
| 17100 | PtrLenSingle, align, 0, 0, false); | 18102 | PtrLenSingle, align, 0, 0, false); |
| 17101 | | 18103 | |
| 17102 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 18104 | ZigFn *fn_entry = ira->new_irb.exec->fn_entry; |
| 17103 | if (fn_entry != nullptr) { | 18105 | if (fn_entry != nullptr) { |
| 17104 | fn_entry->alloca_gen_list.append(result); | 18106 | fn_entry->alloca_gen_list.append(result); |
| 17105 | } | 18107 | } |
| 17106 | result->base.is_gen = true; | | |
| 17107 | return &result->base; | 18108 | return &result->base; |
| 17108 | } | 18109 | } |
| 17109 | | 18110 | |
| 17110 | static ZigType *ir_result_loc_expected_type(IrAnalyze *ira, IrInstruction *suspend_source_instr, | 18111 | static ZigType *ir_result_loc_expected_type(IrAnalyze *ira, IrInst *suspend_source_instr, |
| 17111 | ResultLoc *result_loc) | 18112 | ResultLoc *result_loc) |
| 17112 | { | 18113 | { |
| 17113 | switch (result_loc->id) { | 18114 | switch (result_loc->id) { |
| ... | @@ -17150,7 +18151,7 @@ static bool type_can_bit_cast(ZigType *t) { | ... | @@ -17150,7 +18151,7 @@ static bool type_can_bit_cast(ZigType *t) { |
| 17150 | } | 18151 | } |
| 17151 | } | 18152 | } |
| 17152 | | 18153 | |
| 17153 | static void set_up_result_loc_for_inferred_comptime(IrInstruction *ptr) { | 18154 | static void set_up_result_loc_for_inferred_comptime(IrInstGen *ptr) { |
| 17154 | ZigValue *undef_child = create_const_vals(1); | 18155 | ZigValue *undef_child = create_const_vals(1); |
| 17155 | undef_child->type = ptr->value->type->data.pointer.child_type; | 18156 | undef_child->type = ptr->value->type->data.pointer.child_type; |
| 17156 | undef_child->special = ConstValSpecialUndef; | 18157 | undef_child->special = ConstValSpecialUndef; |
| ... | @@ -17189,16 +18190,16 @@ static Error ir_result_has_type(IrAnalyze *ira, ResultLoc *result_loc, bool *out | ... | @@ -17189,16 +18190,16 @@ static Error ir_result_has_type(IrAnalyze *ira, ResultLoc *result_loc, bool *out |
| 17189 | zig_unreachable(); | 18190 | zig_unreachable(); |
| 17190 | } | 18191 | } |
| 17191 | | 18192 | |
| 17192 | static IrInstruction *ir_resolve_no_result_loc(IrAnalyze *ira, IrInstruction *suspend_source_instr, | 18193 | static IrInstGen *ir_resolve_no_result_loc(IrAnalyze *ira, IrInst *suspend_source_instr, |
| 17193 | ResultLoc *result_loc, ZigType *value_type, bool force_runtime, bool non_null_comptime) | 18194 | ResultLoc *result_loc, ZigType *value_type, bool force_runtime, bool non_null_comptime) |
| 17194 | { | 18195 | { |
| 17195 | if (type_is_invalid(value_type)) | 18196 | if (type_is_invalid(value_type)) |
| 17196 | return ira->codegen->invalid_instruction; | 18197 | return ira->codegen->invalid_inst_gen; |
| 17197 | IrInstructionAllocaGen *alloca_gen = ir_build_alloca_gen(ira, suspend_source_instr, 0, ""); | 18198 | IrInstGenAlloca *alloca_gen = ir_build_alloca_gen(ira, suspend_source_instr, 0, ""); |
| 17198 | alloca_gen->base.value->type = get_pointer_to_type_extra(ira->codegen, value_type, false, false, | 18199 | alloca_gen->base.value->type = get_pointer_to_type_extra(ira->codegen, value_type, false, false, |
| 17199 | PtrLenSingle, 0, 0, 0, false); | 18200 | PtrLenSingle, 0, 0, 0, false); |
| 17200 | set_up_result_loc_for_inferred_comptime(&alloca_gen->base); | 18201 | set_up_result_loc_for_inferred_comptime(&alloca_gen->base); |
| 17201 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 18202 | ZigFn *fn_entry = ira->new_irb.exec->fn_entry; |
| 17202 | if (fn_entry != nullptr && get_scope_typeof(suspend_source_instr->scope) == nullptr) { | 18203 | if (fn_entry != nullptr && get_scope_typeof(suspend_source_instr->scope) == nullptr) { |
| 17203 | fn_entry->alloca_gen_list.append(alloca_gen); | 18204 | fn_entry->alloca_gen_list.append(alloca_gen); |
| 17204 | } | 18205 | } |
| ... | @@ -17208,8 +18209,8 @@ static IrInstruction *ir_resolve_no_result_loc(IrAnalyze *ira, IrInstruction *su | ... | @@ -17208,8 +18209,8 @@ static IrInstruction *ir_resolve_no_result_loc(IrAnalyze *ira, IrInstruction *su |
| 17208 | } | 18209 | } |
| 17209 | | 18210 | |
| 17210 | // when calling this function, at the callsite must check for result type noreturn and propagate it up | 18211 | // when calling this function, at the callsite must check for result type noreturn and propagate it up |
| 17211 | static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspend_source_instr, | 18212 | static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInst *suspend_source_instr, |
| 17212 | ResultLoc *result_loc, ZigType *value_type, IrInstruction *value, bool force_runtime, | 18213 | ResultLoc *result_loc, ZigType *value_type, IrInstGen *value, bool force_runtime, |
| 17213 | bool non_null_comptime, bool allow_discard) | 18214 | bool non_null_comptime, bool allow_discard) |
| 17214 | { | 18215 | { |
| 17215 | Error err; | 18216 | Error err; |
| ... | @@ -17235,35 +18236,34 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17235,35 +18236,34 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17235 | } | 18236 | } |
| 17236 | case ResultLocIdVar: { | 18237 | case ResultLocIdVar: { |
| 17237 | ResultLocVar *result_loc_var = reinterpret_cast<ResultLocVar *>(result_loc); | 18238 | ResultLocVar *result_loc_var = reinterpret_cast<ResultLocVar *>(result_loc); |
| 17238 | assert(result_loc->source_instruction->id == IrInstructionIdAllocaSrc); | 18239 | assert(result_loc->source_instruction->id == IrInstSrcIdAlloca); |
| 17239 | | 18240 | |
| 17240 | if (value_type->id == ZigTypeIdUnreachable || value_type->id == ZigTypeIdOpaque) { | 18241 | if (value_type->id == ZigTypeIdUnreachable || value_type->id == ZigTypeIdOpaque) { |
| 17241 | ir_add_error(ira, result_loc->source_instruction, | 18242 | ir_add_error(ira, &result_loc->source_instruction->base, |
| 17242 | buf_sprintf("variable of type '%s' not allowed", buf_ptr(&value_type->name))); | 18243 | buf_sprintf("variable of type '%s' not allowed", buf_ptr(&value_type->name))); |
| 17243 | return ira->codegen->invalid_instruction; | 18244 | return ira->codegen->invalid_inst_gen; |
| 17244 | } | 18245 | } |
| 17245 | | 18246 | |
| 17246 | IrInstructionAllocaSrc *alloca_src = | 18247 | IrInstSrcAlloca *alloca_src = reinterpret_cast<IrInstSrcAlloca *>(result_loc->source_instruction); |
| 17247 | reinterpret_cast<IrInstructionAllocaSrc *>(result_loc->source_instruction); | | |
| 17248 | bool force_comptime; | 18248 | bool force_comptime; |
| 17249 | if (!ir_resolve_comptime(ira, alloca_src->is_comptime->child, &force_comptime)) | 18249 | if (!ir_resolve_comptime(ira, alloca_src->is_comptime->child, &force_comptime)) |
| 17250 | return ira->codegen->invalid_instruction; | 18250 | return ira->codegen->invalid_inst_gen; |
| 17251 | bool is_comptime = force_comptime || (!force_runtime && value != nullptr && | 18251 | bool is_comptime = force_comptime || (!force_runtime && value != nullptr && |
| 17252 | value->value->special != ConstValSpecialRuntime && result_loc_var->var->gen_is_const); | 18252 | value->value->special != ConstValSpecialRuntime && result_loc_var->var->gen_is_const); |
| 17253 | | 18253 | |
| 17254 | if (alloca_src->base.child == nullptr || is_comptime) { | 18254 | if (alloca_src->base.child == nullptr || is_comptime) { |
| 17255 | uint32_t align = 0; | 18255 | uint32_t align = 0; |
| 17256 | if (alloca_src->align != nullptr && !ir_resolve_align(ira, alloca_src->align->child, nullptr, &align)) { | 18256 | if (alloca_src->align != nullptr && !ir_resolve_align(ira, alloca_src->align->child, nullptr, &align)) { |
| 17257 | return ira->codegen->invalid_instruction; | 18257 | return ira->codegen->invalid_inst_gen; |
| 17258 | } | 18258 | } |
| 17259 | IrInstruction *alloca_gen; | 18259 | IrInstGen *alloca_gen; |
| 17260 | if (is_comptime && value != nullptr) { | 18260 | if (is_comptime && value != nullptr) { |
| 17261 | if (align > value->value->llvm_align) { | 18261 | if (align > value->value->llvm_align) { |
| 17262 | value->value->llvm_align = align; | 18262 | value->value->llvm_align = align; |
| 17263 | } | 18263 | } |
| 17264 | alloca_gen = ir_get_ref(ira, result_loc->source_instruction, value, true, false); | 18264 | alloca_gen = ir_get_ref(ira, &result_loc->source_instruction->base, value, true, false); |
| 17265 | } else { | 18265 | } else { |
| 17266 | alloca_gen = ir_analyze_alloca(ira, result_loc->source_instruction, value_type, align, | 18266 | alloca_gen = ir_analyze_alloca(ira, &result_loc->source_instruction->base, value_type, align, |
| 17267 | alloca_src->name_hint, force_comptime); | 18267 | alloca_src->name_hint, force_comptime); |
| 17268 | if (force_runtime) { | 18268 | if (force_runtime) { |
| 17269 | alloca_gen->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; | 18269 | alloca_gen->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; |
| ... | @@ -17271,7 +18271,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17271,7 +18271,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17271 | } | 18271 | } |
| 17272 | } | 18272 | } |
| 17273 | if (alloca_src->base.child != nullptr && !result_loc->written) { | 18273 | if (alloca_src->base.child != nullptr && !result_loc->written) { |
| 17274 | alloca_src->base.child->ref_count = 0; | 18274 | alloca_src->base.child->base.ref_count = 0; |
| 17275 | } | 18275 | } |
| 17276 | alloca_src->base.child = alloca_gen; | 18276 | alloca_src->base.child = alloca_gen; |
| 17277 | } | 18277 | } |
| ... | @@ -17296,9 +18296,9 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17296,9 +18296,9 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17296 | } | 18296 | } |
| 17297 | bool has_bits; | 18297 | bool has_bits; |
| 17298 | if ((err = type_has_bits2(ira->codegen, ira->explicit_return_type, &has_bits))) | 18298 | if ((err = type_has_bits2(ira->codegen, ira->explicit_return_type, &has_bits))) |
| 17299 | return ira->codegen->invalid_instruction; | 18299 | return ira->codegen->invalid_inst_gen; |
| 17300 | if (!has_bits || !handle_is_ptr(ira->explicit_return_type)) { | 18300 | if (!has_bits || !handle_is_ptr(ira->explicit_return_type)) { |
| 17301 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 18301 | ZigFn *fn_entry = ira->new_irb.exec->fn_entry; |
| 17302 | if (fn_entry == nullptr || fn_entry->inferred_async_node == nullptr) { | 18302 | if (fn_entry == nullptr || fn_entry->inferred_async_node == nullptr) { |
| 17303 | return nullptr; | 18303 | return nullptr; |
| 17304 | } | 18304 | } |
| ... | @@ -17306,8 +18306,8 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17306,8 +18306,8 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17306 | | 18306 | |
| 17307 | ZigType *ptr_return_type = get_pointer_to_type(ira->codegen, ira->explicit_return_type, false); | 18307 | ZigType *ptr_return_type = get_pointer_to_type(ira->codegen, ira->explicit_return_type, false); |
| 17308 | result_loc->written = true; | 18308 | result_loc->written = true; |
| 17309 | result_loc->resolved_loc = ir_build_return_ptr(ira, result_loc->source_instruction, ptr_return_type); | 18309 | result_loc->resolved_loc = ir_build_return_ptr(ira, &result_loc->source_instruction->base, ptr_return_type); |
| 17310 | if (ir_should_inline(ira->old_irb.exec, result_loc->source_instruction->scope)) { | 18310 | if (ir_should_inline(ira->old_irb.exec, result_loc->source_instruction->base.scope)) { |
| 17311 | set_up_result_loc_for_inferred_comptime(result_loc->resolved_loc); | 18311 | set_up_result_loc_for_inferred_comptime(result_loc->resolved_loc); |
| 17312 | } | 18312 | } |
| 17313 | return result_loc->resolved_loc; | 18313 | return result_loc->resolved_loc; |
| ... | @@ -17317,7 +18317,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17317,7 +18317,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17317 | ResultLocPeerParent *peer_parent = result_peer->parent; | 18317 | ResultLocPeerParent *peer_parent = result_peer->parent; |
| 17318 | | 18318 | |
| 17319 | if (peer_parent->peers.length == 1) { | 18319 | if (peer_parent->peers.length == 1) { |
| 17320 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, | 18320 | IrInstGen *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, |
| 17321 | value_type, value, force_runtime, non_null_comptime, true); | 18321 | value_type, value, force_runtime, non_null_comptime, true); |
| 17322 | result_peer->suspend_pos.basic_block_index = SIZE_MAX; | 18322 | result_peer->suspend_pos.basic_block_index = SIZE_MAX; |
| 17323 | result_peer->suspend_pos.instruction_index = SIZE_MAX; | 18323 | result_peer->suspend_pos.instruction_index = SIZE_MAX; |
| ... | @@ -17333,7 +18333,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17333,7 +18333,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17333 | | 18333 | |
| 17334 | bool is_condition_comptime; | 18334 | bool is_condition_comptime; |
| 17335 | if (!ir_resolve_comptime(ira, peer_parent->is_comptime->child, &is_condition_comptime)) | 18335 | if (!ir_resolve_comptime(ira, peer_parent->is_comptime->child, &is_condition_comptime)) |
| 17336 | return ira->codegen->invalid_instruction; | 18336 | return ira->codegen->invalid_inst_gen; |
| 17337 | if (is_condition_comptime) { | 18337 | if (is_condition_comptime) { |
| 17338 | peer_parent->skipped = true; | 18338 | peer_parent->skipped = true; |
| 17339 | if (non_null_comptime) { | 18339 | if (non_null_comptime) { |
| ... | @@ -17344,10 +18344,10 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17344,10 +18344,10 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17344 | } | 18344 | } |
| 17345 | bool peer_parent_has_type; | 18345 | bool peer_parent_has_type; |
| 17346 | if ((err = ir_result_has_type(ira, peer_parent->parent, &peer_parent_has_type))) | 18346 | if ((err = ir_result_has_type(ira, peer_parent->parent, &peer_parent_has_type))) |
| 17347 | return ira->codegen->invalid_instruction; | 18347 | return ira->codegen->invalid_inst_gen; |
| 17348 | if (peer_parent_has_type) { | 18348 | if (peer_parent_has_type) { |
| 17349 | peer_parent->skipped = true; | 18349 | peer_parent->skipped = true; |
| 17350 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, | 18350 | IrInstGen *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, |
| 17351 | value_type, value, force_runtime || !is_condition_comptime, true, true); | 18351 | value_type, value, force_runtime || !is_condition_comptime, true, true); |
| 17352 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || | 18352 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 17353 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) | 18353 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| ... | @@ -17364,7 +18364,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17364,7 +18364,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17364 | if (peer_parent->end_bb->suspend_instruction_ref == nullptr) { | 18364 | if (peer_parent->end_bb->suspend_instruction_ref == nullptr) { |
| 17365 | peer_parent->end_bb->suspend_instruction_ref = suspend_source_instr; | 18365 | peer_parent->end_bb->suspend_instruction_ref = suspend_source_instr; |
| 17366 | } | 18366 | } |
| 17367 | IrInstruction *unreach_inst = ira_suspend(ira, suspend_source_instr, result_peer->next_bb, | 18367 | IrInstGen *unreach_inst = ira_suspend(ira, suspend_source_instr, result_peer->next_bb, |
| 17368 | &result_peer->suspend_pos); | 18368 | &result_peer->suspend_pos); |
| 17369 | if (result_peer->next_bb == nullptr) { | 18369 | if (result_peer->next_bb == nullptr) { |
| 17370 | ir_start_next_bb(ira); | 18370 | ir_start_next_bb(ira); |
| ... | @@ -17372,7 +18372,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17372,7 +18372,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17372 | return unreach_inst; | 18372 | return unreach_inst; |
| 17373 | } | 18373 | } |
| 17374 | | 18374 | |
| 17375 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, | 18375 | IrInstGen *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, peer_parent->parent, |
| 17376 | peer_parent->resolved_type, nullptr, force_runtime, non_null_comptime, true); | 18376 | peer_parent->resolved_type, nullptr, force_runtime, non_null_comptime, true); |
| 17377 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || | 18377 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 17378 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) | 18378 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| ... | @@ -17391,24 +18391,24 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17391,24 +18391,24 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17391 | ResultLocCast *result_cast = reinterpret_cast<ResultLocCast *>(result_loc); | 18391 | ResultLocCast *result_cast = reinterpret_cast<ResultLocCast *>(result_loc); |
| 17392 | ZigType *dest_type = ir_resolve_type(ira, result_cast->base.source_instruction->child); | 18392 | ZigType *dest_type = ir_resolve_type(ira, result_cast->base.source_instruction->child); |
| 17393 | if (type_is_invalid(dest_type)) | 18393 | if (type_is_invalid(dest_type)) |
| 17394 | return ira->codegen->invalid_instruction; | 18394 | return ira->codegen->invalid_inst_gen; |
| 17395 | | 18395 | |
| 17396 | if (dest_type == ira->codegen->builtin_types.entry_var) { | 18396 | if (dest_type == ira->codegen->builtin_types.entry_var) { |
| 17397 | return ir_resolve_no_result_loc(ira, suspend_source_instr, result_loc, value_type, | 18397 | return ir_resolve_no_result_loc(ira, suspend_source_instr, result_loc, value_type, |
| 17398 | force_runtime, non_null_comptime); | 18398 | force_runtime, non_null_comptime); |
| 17399 | } | 18399 | } |
| 17400 | | 18400 | |
| 17401 | IrInstruction *casted_value; | 18401 | IrInstGen *casted_value; |
| 17402 | if (value != nullptr) { | 18402 | if (value != nullptr) { |
| 17403 | casted_value = ir_implicit_cast(ira, value, dest_type); | 18403 | casted_value = ir_implicit_cast(ira, value, dest_type); |
| 17404 | if (type_is_invalid(casted_value->value->type)) | 18404 | if (type_is_invalid(casted_value->value->type)) |
| 17405 | return ira->codegen->invalid_instruction; | 18405 | return ira->codegen->invalid_inst_gen; |
| 17406 | dest_type = casted_value->value->type; | 18406 | dest_type = casted_value->value->type; |
| 17407 | } else { | 18407 | } else { |
| 17408 | casted_value = nullptr; | 18408 | casted_value = nullptr; |
| 17409 | } | 18409 | } |
| 17410 | | 18410 | |
| 17411 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_cast->parent, | 18411 | IrInstGen *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_cast->parent, |
| 17412 | dest_type, casted_value, force_runtime, non_null_comptime, true); | 18412 | dest_type, casted_value, force_runtime, non_null_comptime, true); |
| 17413 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || | 18413 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 17414 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) | 18414 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| ... | @@ -17422,11 +18422,11 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17422,11 +18422,11 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17422 | if ((err = type_resolve(ira->codegen, parent_ptr_type->data.pointer.child_type, | 18422 | if ((err = type_resolve(ira->codegen, parent_ptr_type->data.pointer.child_type, |
| 17423 | ResolveStatusAlignmentKnown))) | 18423 | ResolveStatusAlignmentKnown))) |
| 17424 | { | 18424 | { |
| 17425 | return ira->codegen->invalid_instruction; | 18425 | return ira->codegen->invalid_inst_gen; |
| 17426 | } | 18426 | } |
| 17427 | uint64_t parent_ptr_align = get_ptr_align(ira->codegen, parent_ptr_type); | 18427 | uint64_t parent_ptr_align = get_ptr_align(ira->codegen, parent_ptr_type); |
| 17428 | if ((err = type_resolve(ira->codegen, value_type, ResolveStatusAlignmentKnown))) { | 18428 | if ((err = type_resolve(ira->codegen, value_type, ResolveStatusAlignmentKnown))) { |
| 17429 | return ira->codegen->invalid_instruction; | 18429 | return ira->codegen->invalid_inst_gen; |
| 17430 | } | 18430 | } |
| 17431 | if (!type_has_bits(value_type)) { | 18431 | if (!type_has_bits(value_type)) { |
| 17432 | parent_ptr_align = 0; | 18432 | parent_ptr_align = 0; |
| ... | @@ -17449,9 +18449,9 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17449,9 +18449,9 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17449 | | 18449 | |
| 17450 | ConstCastOnly const_cast_result = types_match_const_cast_only(ira, | 18450 | ConstCastOnly const_cast_result = types_match_const_cast_only(ira, |
| 17451 | parent_result_loc->value->type, ptr_type, | 18451 | parent_result_loc->value->type, ptr_type, |
| 17452 | result_cast->base.source_instruction->source_node, false); | 18452 | result_cast->base.source_instruction->base.source_node, false); |
| 17453 | if (const_cast_result.id == ConstCastResultIdInvalid) | 18453 | if (const_cast_result.id == ConstCastResultIdInvalid) |
| 17454 | return ira->codegen->invalid_instruction; | 18454 | return ira->codegen->invalid_inst_gen; |
| 17455 | if (const_cast_result.id != ConstCastResultIdOk) { | 18455 | if (const_cast_result.id != ConstCastResultIdOk) { |
| 17456 | if (allow_discard) { | 18456 | if (allow_discard) { |
| 17457 | return parent_result_loc; | 18457 | return parent_result_loc; |
| ... | @@ -17465,42 +18465,42 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17465,42 +18465,42 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17465 | | 18465 | |
| 17466 | result_loc->written = true; | 18466 | result_loc->written = true; |
| 17467 | result_loc->resolved_loc = ir_analyze_ptr_cast(ira, suspend_source_instr, parent_result_loc, | 18467 | result_loc->resolved_loc = ir_analyze_ptr_cast(ira, suspend_source_instr, parent_result_loc, |
| 17468 | ptr_type, result_cast->base.source_instruction, false); | 18468 | ptr_type, &result_cast->base.source_instruction->base, false); |
| 17469 | return result_loc->resolved_loc; | 18469 | return result_loc->resolved_loc; |
| 17470 | } | 18470 | } |
| 17471 | case ResultLocIdBitCast: { | 18471 | case ResultLocIdBitCast: { |
| 17472 | ResultLocBitCast *result_bit_cast = reinterpret_cast<ResultLocBitCast *>(result_loc); | 18472 | ResultLocBitCast *result_bit_cast = reinterpret_cast<ResultLocBitCast *>(result_loc); |
| 17473 | ZigType *dest_type = ir_resolve_type(ira, result_bit_cast->base.source_instruction->child); | 18473 | ZigType *dest_type = ir_resolve_type(ira, result_bit_cast->base.source_instruction->child); |
| 17474 | if (type_is_invalid(dest_type)) | 18474 | if (type_is_invalid(dest_type)) |
| 17475 | return ira->codegen->invalid_instruction; | 18475 | return ira->codegen->invalid_inst_gen; |
| 17476 | | 18476 | |
| 17477 | if (get_codegen_ptr_type(dest_type) != nullptr) { | 18477 | if (get_codegen_ptr_type(dest_type) != nullptr) { |
| 17478 | ir_add_error(ira, result_loc->source_instruction, | 18478 | ir_add_error(ira, &result_loc->source_instruction->base, |
| 17479 | buf_sprintf("unable to @bitCast to pointer type '%s'", buf_ptr(&dest_type->name))); | 18479 | buf_sprintf("unable to @bitCast to pointer type '%s'", buf_ptr(&dest_type->name))); |
| 17480 | return ira->codegen->invalid_instruction; | 18480 | return ira->codegen->invalid_inst_gen; |
| 17481 | } | 18481 | } |
| 17482 | | 18482 | |
| 17483 | if (!type_can_bit_cast(dest_type)) { | 18483 | if (!type_can_bit_cast(dest_type)) { |
| 17484 | ir_add_error(ira, result_loc->source_instruction, | 18484 | ir_add_error(ira, &result_loc->source_instruction->base, |
| 17485 | buf_sprintf("unable to @bitCast to type '%s'", buf_ptr(&dest_type->name))); | 18485 | buf_sprintf("unable to @bitCast to type '%s'", buf_ptr(&dest_type->name))); |
| 17486 | return ira->codegen->invalid_instruction; | 18486 | return ira->codegen->invalid_inst_gen; |
| 17487 | } | 18487 | } |
| 17488 | | 18488 | |
| 17489 | if (get_codegen_ptr_type(value_type) != nullptr) { | 18489 | if (get_codegen_ptr_type(value_type) != nullptr) { |
| 17490 | ir_add_error(ira, suspend_source_instr, | 18490 | ir_add_error(ira, suspend_source_instr, |
| 17491 | buf_sprintf("unable to @bitCast from pointer type '%s'", buf_ptr(&value_type->name))); | 18491 | buf_sprintf("unable to @bitCast from pointer type '%s'", buf_ptr(&value_type->name))); |
| 17492 | return ira->codegen->invalid_instruction; | 18492 | return ira->codegen->invalid_inst_gen; |
| 17493 | } | 18493 | } |
| 17494 | | 18494 | |
| 17495 | if (!type_can_bit_cast(value_type)) { | 18495 | if (!type_can_bit_cast(value_type)) { |
| 17496 | ir_add_error(ira, suspend_source_instr, | 18496 | ir_add_error(ira, suspend_source_instr, |
| 17497 | buf_sprintf("unable to @bitCast from type '%s'", buf_ptr(&value_type->name))); | 18497 | buf_sprintf("unable to @bitCast from type '%s'", buf_ptr(&value_type->name))); |
| 17498 | return ira->codegen->invalid_instruction; | 18498 | return ira->codegen->invalid_inst_gen; |
| 17499 | } | 18499 | } |
| 17500 | | 18500 | |
| 17501 | IrInstruction *bitcasted_value; | 18501 | IrInstGen *bitcasted_value; |
| 17502 | if (value != nullptr) { | 18502 | if (value != nullptr) { |
| 17503 | bitcasted_value = ir_analyze_bit_cast(ira, result_loc->source_instruction, value, dest_type); | 18503 | bitcasted_value = ir_analyze_bit_cast(ira, &result_loc->source_instruction->base, value, dest_type); |
| 17504 | dest_type = bitcasted_value->value->type; | 18504 | dest_type = bitcasted_value->value->type; |
| 17505 | } else { | 18505 | } else { |
| 17506 | bitcasted_value = nullptr; | 18506 | bitcasted_value = nullptr; |
| ... | @@ -17510,7 +18510,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17510,7 +18510,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17510 | return bitcasted_value; | 18510 | return bitcasted_value; |
| 17511 | } | 18511 | } |
| 17512 | | 18512 | |
| 17513 | IrInstruction *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_bit_cast->parent, | 18513 | IrInstGen *parent_result_loc = ir_resolve_result(ira, suspend_source_instr, result_bit_cast->parent, |
| 17514 | dest_type, bitcasted_value, force_runtime, non_null_comptime, true); | 18514 | dest_type, bitcasted_value, force_runtime, non_null_comptime, true); |
| 17515 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || | 18515 | if (parent_result_loc == nullptr || type_is_invalid(parent_result_loc->value->type) || |
| 17516 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) | 18516 | parent_result_loc->value->type->id == ZigTypeIdUnreachable) |
| ... | @@ -17523,7 +18523,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17523,7 +18523,7 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17523 | | 18523 | |
| 17524 | bool has_bits; | 18524 | bool has_bits; |
| 17525 | if ((err = type_has_bits2(ira->codegen, child_type, &has_bits))) { | 18525 | if ((err = type_has_bits2(ira->codegen, child_type, &has_bits))) { |
| 17526 | return ira->codegen->invalid_instruction; | 18526 | return ira->codegen->invalid_inst_gen; |
| 17527 | } | 18527 | } |
| 17528 | | 18528 | |
| 17529 | // This happens when the bitCast result is assigned to _ | 18529 | // This happens when the bitCast result is assigned to _ |
| ... | @@ -17533,12 +18533,12 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17533,12 +18533,12 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17533 | } | 18533 | } |
| 17534 | | 18534 | |
| 17535 | if ((err = type_resolve(ira->codegen, child_type, ResolveStatusAlignmentKnown))) { | 18535 | if ((err = type_resolve(ira->codegen, child_type, ResolveStatusAlignmentKnown))) { |
| 17536 | return ira->codegen->invalid_instruction; | 18536 | return ira->codegen->invalid_inst_gen; |
| 17537 | } | 18537 | } |
| 17538 | | 18538 | |
| 17539 | uint64_t parent_ptr_align = get_ptr_align(ira->codegen, parent_ptr_type); | 18539 | uint64_t parent_ptr_align = get_ptr_align(ira->codegen, parent_ptr_type); |
| 17540 | if ((err = type_resolve(ira->codegen, value_type, ResolveStatusAlignmentKnown))) { | 18540 | if ((err = type_resolve(ira->codegen, value_type, ResolveStatusAlignmentKnown))) { |
| 17541 | return ira->codegen->invalid_instruction; | 18541 | return ira->codegen->invalid_inst_gen; |
| 17542 | } | 18542 | } |
| 17543 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, value_type, | 18543 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, value_type, |
| 17544 | parent_ptr_type->data.pointer.is_const, parent_ptr_type->data.pointer.is_volatile, PtrLenSingle, | 18544 | parent_ptr_type->data.pointer.is_const, parent_ptr_type->data.pointer.is_volatile, PtrLenSingle, |
| ... | @@ -17546,29 +18546,33 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe | ... | @@ -17546,29 +18546,33 @@ static IrInstruction *ir_resolve_result_raw(IrAnalyze *ira, IrInstruction *suspe |
| 17546 | | 18546 | |
| 17547 | result_loc->written = true; | 18547 | result_loc->written = true; |
| 17548 | result_loc->resolved_loc = ir_analyze_ptr_cast(ira, suspend_source_instr, parent_result_loc, | 18548 | result_loc->resolved_loc = ir_analyze_ptr_cast(ira, suspend_source_instr, parent_result_loc, |
| 17549 | ptr_type, result_bit_cast->base.source_instruction, false); | 18549 | ptr_type, &result_bit_cast->base.source_instruction->base, false); |
| 17550 | return result_loc->resolved_loc; | 18550 | return result_loc->resolved_loc; |
| 17551 | } | 18551 | } |
| 17552 | } | 18552 | } |
| 17553 | zig_unreachable(); | 18553 | zig_unreachable(); |
| 17554 | } | 18554 | } |
| 17555 | | 18555 | |
| 17556 | static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_source_instr, | 18556 | static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr, |
| 17557 | ResultLoc *result_loc_pass1, ZigType *value_type, IrInstruction *value, bool force_runtime, | 18557 | ResultLoc *result_loc_pass1, ZigType *value_type, IrInstGen *value, bool force_runtime, |
| 17558 | bool non_null_comptime, bool allow_discard) | 18558 | bool non_null_comptime, bool allow_discard) |
| 17559 | { | 18559 | { |
| 17560 | Error err; | 18560 | Error err; |
| 17561 | if (!allow_discard && result_loc_pass1->id == ResultLocIdInstruction && | 18561 | if (!allow_discard && result_loc_pass1->id == ResultLocIdInstruction && |
| 17562 | instr_is_comptime(result_loc_pass1->source_instruction) && | 18562 | result_loc_pass1->source_instruction->id == IrInstSrcIdConst) |
| 17563 | result_loc_pass1->source_instruction->value->type->id == ZigTypeIdPointer && | | |
| 17564 | result_loc_pass1->source_instruction->value->data.x_ptr.special == ConstPtrSpecialDiscard) | | |
| 17565 | { | 18563 | { |
| 17566 | result_loc_pass1 = no_result_loc(); | 18564 | IrInstSrcConst *const_inst = reinterpret_cast<IrInstSrcConst *>(result_loc_pass1->source_instruction); |
| | 18565 | if (value_is_comptime(const_inst->value) && |
| | 18566 | const_inst->value->type->id == ZigTypeIdPointer && |
| | 18567 | const_inst->value->data.x_ptr.special == ConstPtrSpecialDiscard) |
| | 18568 | { |
| | 18569 | result_loc_pass1 = no_result_loc(); |
| | 18570 | } |
| 17567 | } | 18571 | } |
| 17568 | bool was_already_resolved = result_loc_pass1->resolved_loc != nullptr; | 18572 | bool was_already_resolved = result_loc_pass1->resolved_loc != nullptr; |
| 17569 | IrInstruction *result_loc = ir_resolve_result_raw(ira, suspend_source_instr, result_loc_pass1, value_type, | 18573 | IrInstGen *result_loc = ir_resolve_result_raw(ira, suspend_source_instr, result_loc_pass1, value_type, |
| 17570 | value, force_runtime, non_null_comptime, allow_discard); | 18574 | value, force_runtime, non_null_comptime, allow_discard); |
| 17571 | if (result_loc == nullptr || (instr_is_unreachable(result_loc) || type_is_invalid(result_loc->value->type))) | 18575 | if (result_loc == nullptr || (result_loc->value->type->id == ZigTypeIdUnreachable || type_is_invalid(result_loc->value->type))) |
| 17572 | return result_loc; | 18576 | return result_loc; |
| 17573 | | 18577 | |
| 17574 | if ((force_runtime || (value != nullptr && !instr_is_comptime(value))) && | 18578 | if ((force_runtime || (value != nullptr && !instr_is_comptime(value))) && |
| ... | @@ -17591,11 +18595,11 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s | ... | @@ -17591,11 +18595,11 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 17591 | field->type_entry = value_type; | 18595 | field->type_entry = value_type; |
| 17592 | field->type_val = create_const_type(ira->codegen, field->type_entry); | 18596 | field->type_val = create_const_type(ira->codegen, field->type_entry); |
| 17593 | field->src_index = old_field_count; | 18597 | field->src_index = old_field_count; |
| 17594 | field->decl_node = value ? value->source_node : suspend_source_instr->source_node; | 18598 | field->decl_node = value ? value->base.source_node : suspend_source_instr->source_node; |
| 17595 | if (value && instr_is_comptime(value)) { | 18599 | if (value && instr_is_comptime(value)) { |
| 17596 | ZigValue *val = ir_resolve_const(ira, value, UndefOk); | 18600 | ZigValue *val = ir_resolve_const(ira, value, UndefOk); |
| 17597 | if (!val) | 18601 | if (!val) |
| 17598 | return ira->codegen->invalid_instruction; | 18602 | return ira->codegen->invalid_inst_gen; |
| 17599 | field->is_comptime = true; | 18603 | field->is_comptime = true; |
| 17600 | field->init_val = create_const_vals(1); | 18604 | field->init_val = create_const_vals(1); |
| 17601 | copy_const_val(field->init_val, val); | 18605 | copy_const_val(field->init_val, val); |
| ... | @@ -17603,7 +18607,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s | ... | @@ -17603,7 +18607,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 17603 | } | 18607 | } |
| 17604 | | 18608 | |
| 17605 | ZigType *struct_ptr_type = get_pointer_to_type(ira->codegen, isf->inferred_struct_type, false); | 18609 | ZigType *struct_ptr_type = get_pointer_to_type(ira->codegen, isf->inferred_struct_type, false); |
| 17606 | IrInstruction *casted_ptr; | 18610 | IrInstGen *casted_ptr; |
| 17607 | if (instr_is_comptime(result_loc)) { | 18611 | if (instr_is_comptime(result_loc)) { |
| 17608 | casted_ptr = ir_const(ira, suspend_source_instr, struct_ptr_type); | 18612 | casted_ptr = ir_const(ira, suspend_source_instr, struct_ptr_type); |
| 17609 | copy_const_val(casted_ptr->value, result_loc->value); | 18613 | copy_const_val(casted_ptr->value, result_loc->value); |
| ... | @@ -17614,7 +18618,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s | ... | @@ -17614,7 +18618,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 17614 | if (instr_is_comptime(casted_ptr)) { | 18618 | if (instr_is_comptime(casted_ptr)) { |
| 17615 | ZigValue *ptr_val = ir_resolve_const(ira, casted_ptr, UndefBad); | 18619 | ZigValue *ptr_val = ir_resolve_const(ira, casted_ptr, UndefBad); |
| 17616 | if (!ptr_val) | 18620 | if (!ptr_val) |
| 17617 | return ira->codegen->invalid_instruction; | 18621 | return ira->codegen->invalid_inst_gen; |
| 17618 | if (ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 18622 | if (ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 17619 | ZigValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, | 18623 | ZigValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, |
| 17620 | suspend_source_instr->source_node); | 18624 | suspend_source_instr->source_node); |
| ... | @@ -17644,7 +18648,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s | ... | @@ -17644,7 +18648,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 17644 | { | 18648 | { |
| 17645 | bool has_bits; | 18649 | bool has_bits; |
| 17646 | if ((err = type_has_bits2(ira->codegen, value_type, &has_bits))) | 18650 | if ((err = type_has_bits2(ira->codegen, value_type, &has_bits))) |
| 17647 | return ira->codegen->invalid_instruction; | 18651 | return ira->codegen->invalid_inst_gen; |
| 17648 | if (has_bits) { | 18652 | if (has_bits) { |
| 17649 | result_loc_pass1->written = false; | 18653 | result_loc_pass1->written = false; |
| 17650 | return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true); | 18654 | return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true); |
| ... | @@ -17652,12 +18656,12 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s | ... | @@ -17652,12 +18656,12 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 17652 | } else if (actual_elem_type->id == ZigTypeIdErrorUnion && value_type->id != ZigTypeIdErrorUnion) { | 18656 | } else if (actual_elem_type->id == ZigTypeIdErrorUnion && value_type->id != ZigTypeIdErrorUnion) { |
| 17653 | bool has_bits; | 18657 | bool has_bits; |
| 17654 | if ((err = type_has_bits2(ira->codegen, value_type, &has_bits))) | 18658 | if ((err = type_has_bits2(ira->codegen, value_type, &has_bits))) |
| 17655 | return ira->codegen->invalid_instruction; | 18659 | return ira->codegen->invalid_inst_gen; |
| 17656 | if (has_bits) { | 18660 | if (has_bits) { |
| 17657 | if (value_type->id == ZigTypeIdErrorSet) { | 18661 | if (value_type->id == ZigTypeIdErrorSet) { |
| 17658 | return ir_analyze_unwrap_err_code(ira, suspend_source_instr, result_loc, true); | 18662 | return ir_analyze_unwrap_err_code(ira, suspend_source_instr, result_loc, true); |
| 17659 | } else { | 18663 | } else { |
| 17660 | IrInstruction *unwrapped_err_ptr = ir_analyze_unwrap_error_payload(ira, suspend_source_instr, | 18664 | IrInstGen *unwrapped_err_ptr = ir_analyze_unwrap_error_payload(ira, suspend_source_instr, |
| 17661 | result_loc, false, true); | 18665 | result_loc, false, true); |
| 17662 | ZigType *actual_payload_type = actual_elem_type->data.error_union.payload_type; | 18666 | ZigType *actual_payload_type = actual_elem_type->data.error_union.payload_type; |
| 17663 | if (actual_payload_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional && | 18667 | if (actual_payload_type->id == ZigTypeIdOptional && value_type->id != ZigTypeIdOptional && |
| ... | @@ -17672,37 +18676,35 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s | ... | @@ -17672,37 +18676,35 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s |
| 17672 | return result_loc; | 18676 | return result_loc; |
| 17673 | } | 18677 | } |
| 17674 | | 18678 | |
| 17675 | static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, | 18679 | static IrInstGen *ir_analyze_instruction_resolve_result(IrAnalyze *ira, IrInstSrcResolveResult *instruction) { |
| 17676 | IrInstructionResolveResult *instruction) | | |
| 17677 | { | | |
| 17678 | ZigType *implicit_elem_type; | 18680 | ZigType *implicit_elem_type; |
| 17679 | if (instruction->ty == nullptr) { | 18681 | if (instruction->ty == nullptr) { |
| 17680 | if (instruction->result_loc->id == ResultLocIdCast) { | 18682 | if (instruction->result_loc->id == ResultLocIdCast) { |
| 17681 | implicit_elem_type = ir_resolve_type(ira, | 18683 | implicit_elem_type = ir_resolve_type(ira, |
| 17682 | instruction->result_loc->source_instruction->child); | 18684 | instruction->result_loc->source_instruction->child); |
| 17683 | if (type_is_invalid(implicit_elem_type)) | 18685 | if (type_is_invalid(implicit_elem_type)) |
| 17684 | return ira->codegen->invalid_instruction; | 18686 | return ira->codegen->invalid_inst_gen; |
| 17685 | } else if (instruction->result_loc->id == ResultLocIdReturn) { | 18687 | } else if (instruction->result_loc->id == ResultLocIdReturn) { |
| 17686 | implicit_elem_type = ira->explicit_return_type; | 18688 | implicit_elem_type = ira->explicit_return_type; |
| 17687 | if (type_is_invalid(implicit_elem_type)) | 18689 | if (type_is_invalid(implicit_elem_type)) |
| 17688 | return ira->codegen->invalid_instruction; | 18690 | return ira->codegen->invalid_inst_gen; |
| 17689 | } else { | 18691 | } else { |
| 17690 | implicit_elem_type = ira->codegen->builtin_types.entry_var; | 18692 | implicit_elem_type = ira->codegen->builtin_types.entry_var; |
| 17691 | } | 18693 | } |
| 17692 | if (implicit_elem_type == ira->codegen->builtin_types.entry_var) { | 18694 | if (implicit_elem_type == ira->codegen->builtin_types.entry_var) { |
| 17693 | Buf *bare_name = buf_alloc(); | 18695 | Buf *bare_name = buf_alloc(); |
| 17694 | Buf *name = get_anon_type_name(ira->codegen, nullptr, container_string(ContainerKindStruct), | 18696 | Buf *name = get_anon_type_name(ira->codegen, nullptr, container_string(ContainerKindStruct), |
| 17695 | instruction->base.scope, instruction->base.source_node, bare_name); | 18697 | instruction->base.base.scope, instruction->base.base.source_node, bare_name); |
| 17696 | | 18698 | |
| 17697 | StructSpecial struct_special = StructSpecialInferredStruct; | 18699 | StructSpecial struct_special = StructSpecialInferredStruct; |
| 17698 | if (instruction->base.source_node->type == NodeTypeContainerInitExpr && | 18700 | if (instruction->base.base.source_node->type == NodeTypeContainerInitExpr && |
| 17699 | instruction->base.source_node->data.container_init_expr.kind == ContainerInitKindArray) | 18701 | instruction->base.base.source_node->data.container_init_expr.kind == ContainerInitKindArray) |
| 17700 | { | 18702 | { |
| 17701 | struct_special = StructSpecialInferredTuple; | 18703 | struct_special = StructSpecialInferredTuple; |
| 17702 | } | 18704 | } |
| 17703 | | 18705 | |
| 17704 | ZigType *inferred_struct_type = get_partial_container_type(ira->codegen, | 18706 | ZigType *inferred_struct_type = get_partial_container_type(ira->codegen, |
| 17705 | instruction->base.scope, ContainerKindStruct, instruction->base.source_node, | 18707 | instruction->base.base.scope, ContainerKindStruct, instruction->base.base.source_node, |
| 17706 | buf_ptr(name), bare_name, ContainerLayoutAuto); | 18708 | buf_ptr(name), bare_name, ContainerLayoutAuto); |
| 17707 | inferred_struct_type->data.structure.special = struct_special; | 18709 | inferred_struct_type->data.structure.special = struct_special; |
| 17708 | inferred_struct_type->data.structure.resolve_status = ResolveStatusBeingInferred; | 18710 | inferred_struct_type->data.structure.resolve_status = ResolveStatusBeingInferred; |
| ... | @@ -17711,21 +18713,21 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, | ... | @@ -17711,21 +18713,21 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, |
| 17711 | } else { | 18713 | } else { |
| 17712 | implicit_elem_type = ir_resolve_type(ira, instruction->ty->child); | 18714 | implicit_elem_type = ir_resolve_type(ira, instruction->ty->child); |
| 17713 | if (type_is_invalid(implicit_elem_type)) | 18715 | if (type_is_invalid(implicit_elem_type)) |
| 17714 | return ira->codegen->invalid_instruction; | 18716 | return ira->codegen->invalid_inst_gen; |
| 17715 | } | 18717 | } |
| 17716 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 18718 | IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base.base, instruction->result_loc, |
| 17717 | implicit_elem_type, nullptr, false, true, true); | 18719 | implicit_elem_type, nullptr, false, true, true); |
| 17718 | if (result_loc != nullptr) | 18720 | if (result_loc != nullptr) |
| 17719 | return result_loc; | 18721 | return result_loc; |
| 17720 | | 18722 | |
| 17721 | ZigFn *fn = exec_fn_entry(ira->new_irb.exec); | 18723 | ZigFn *fn = ira->new_irb.exec->fn_entry; |
| 17722 | if (fn != nullptr && fn->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync && | 18724 | if (fn != nullptr && fn->type_entry->data.fn.fn_type_id.cc == CallingConventionAsync && |
| 17723 | instruction->result_loc->id == ResultLocIdReturn) | 18725 | instruction->result_loc->id == ResultLocIdReturn) |
| 17724 | { | 18726 | { |
| 17725 | result_loc = ir_resolve_result(ira, &instruction->base, no_result_loc(), | 18727 | result_loc = ir_resolve_result(ira, &instruction->base.base, no_result_loc(), |
| 17726 | implicit_elem_type, nullptr, false, true, true); | 18728 | implicit_elem_type, nullptr, false, true, true); |
| 17727 | if (result_loc != nullptr && | 18729 | if (result_loc != nullptr && |
| 17728 | (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) | 18730 | (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable)) |
| 17729 | { | 18731 | { |
| 17730 | return result_loc; | 18732 | return result_loc; |
| 17731 | } | 18733 | } |
| ... | @@ -17733,9 +18735,9 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, | ... | @@ -17733,9 +18735,9 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, |
| 17733 | return result_loc; | 18735 | return result_loc; |
| 17734 | } | 18736 | } |
| 17735 | | 18737 | |
| 17736 | IrInstruction *result = ir_const(ira, &instruction->base, implicit_elem_type); | 18738 | IrInstGen *result = ir_const(ira, &instruction->base.base, implicit_elem_type); |
| 17737 | result->value->special = ConstValSpecialUndef; | 18739 | result->value->special = ConstValSpecialUndef; |
| 17738 | IrInstruction *ptr = ir_get_ref(ira, &instruction->base, result, false, false); | 18740 | IrInstGen *ptr = ir_get_ref(ira, &instruction->base.base, result, false, false); |
| 17739 | ptr->value->data.x_ptr.mut = ConstPtrMutComptimeVar; | 18741 | ptr->value->data.x_ptr.mut = ConstPtrMutComptimeVar; |
| 17740 | return ptr; | 18742 | return ptr; |
| 17741 | } | 18743 | } |
| ... | @@ -17759,8 +18761,7 @@ static void ir_reset_result(ResultLoc *result_loc) { | ... | @@ -17759,8 +18761,7 @@ static void ir_reset_result(ResultLoc *result_loc) { |
| 17759 | break; | 18761 | break; |
| 17760 | } | 18762 | } |
| 17761 | case ResultLocIdVar: { | 18763 | case ResultLocIdVar: { |
| 17762 | IrInstructionAllocaSrc *alloca_src = | 18764 | IrInstSrcAlloca *alloca_src = reinterpret_cast<IrInstSrcAlloca *>(result_loc->source_instruction); |
| 17763 | reinterpret_cast<IrInstructionAllocaSrc *>(result_loc->source_instruction); | | |
| 17764 | alloca_src->base.child = nullptr; | 18765 | alloca_src->base.child = nullptr; |
| 17765 | break; | 18766 | break; |
| 17766 | } | 18767 | } |
| ... | @@ -17776,18 +18777,18 @@ static void ir_reset_result(ResultLoc *result_loc) { | ... | @@ -17776,18 +18777,18 @@ static void ir_reset_result(ResultLoc *result_loc) { |
| 17776 | } | 18777 | } |
| 17777 | } | 18778 | } |
| 17778 | | 18779 | |
| 17779 | static IrInstruction *ir_analyze_instruction_reset_result(IrAnalyze *ira, IrInstructionResetResult *instruction) { | 18780 | static IrInstGen *ir_analyze_instruction_reset_result(IrAnalyze *ira, IrInstSrcResetResult *instruction) { |
| 17780 | ir_reset_result(instruction->result_loc); | 18781 | ir_reset_result(instruction->result_loc); |
| 17781 | return ir_const_void(ira, &instruction->base); | 18782 | return ir_const_void(ira, &instruction->base.base); |
| 17782 | } | 18783 | } |
| 17783 | | 18784 | |
| 17784 | static IrInstruction *get_async_call_result_loc(IrAnalyze *ira, IrInstruction *source_instr, | 18785 | static IrInstGen *get_async_call_result_loc(IrAnalyze *ira, IrInst* source_instr, |
| 17785 | ZigType *fn_ret_type, bool is_async_call_builtin, IrInstruction **args_ptr, size_t args_len, | 18786 | ZigType *fn_ret_type, bool is_async_call_builtin, IrInstGen **args_ptr, size_t args_len, |
| 17786 | IrInstruction *ret_ptr_uncasted) | 18787 | IrInstGen *ret_ptr_uncasted) |
| 17787 | { | 18788 | { |
| 17788 | ir_assert(is_async_call_builtin, source_instr); | 18789 | ir_assert(is_async_call_builtin, source_instr); |
| 17789 | if (type_is_invalid(ret_ptr_uncasted->value->type)) | 18790 | if (type_is_invalid(ret_ptr_uncasted->value->type)) |
| 17790 | return ira->codegen->invalid_instruction; | 18791 | return ira->codegen->invalid_inst_gen; |
| 17791 | if (ret_ptr_uncasted->value->type->id == ZigTypeIdVoid) { | 18792 | if (ret_ptr_uncasted->value->type->id == ZigTypeIdVoid) { |
| 17792 | // Result location will be inside the async frame. | 18793 | // Result location will be inside the async frame. |
| 17793 | return nullptr; | 18794 | return nullptr; |
| ... | @@ -17795,57 +18796,57 @@ static IrInstruction *get_async_call_result_loc(IrAnalyze *ira, IrInstruction *s | ... | @@ -17795,57 +18796,57 @@ static IrInstruction *get_async_call_result_loc(IrAnalyze *ira, IrInstruction *s |
| 17795 | return ir_implicit_cast(ira, ret_ptr_uncasted, get_pointer_to_type(ira->codegen, fn_ret_type, false)); | 18796 | return ir_implicit_cast(ira, ret_ptr_uncasted, get_pointer_to_type(ira->codegen, fn_ret_type, false)); |
| 17796 | } | 18797 | } |
| 17797 | | 18798 | |
| 17798 | static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstruction *source_instr, ZigFn *fn_entry, | 18799 | static IrInstGen *ir_analyze_async_call(IrAnalyze *ira, IrInst* source_instr, ZigFn *fn_entry, |
| 17799 | ZigType *fn_type, IrInstruction *fn_ref, IrInstruction **casted_args, size_t arg_count, | 18800 | ZigType *fn_type, IrInstGen *fn_ref, IrInstGen **casted_args, size_t arg_count, |
| 17800 | IrInstruction *casted_new_stack, bool is_async_call_builtin, IrInstruction *ret_ptr_uncasted, | 18801 | IrInstGen *casted_new_stack, bool is_async_call_builtin, IrInstGen *ret_ptr_uncasted, |
| 17801 | ResultLoc *call_result_loc) | 18802 | ResultLoc *call_result_loc) |
| 17802 | { | 18803 | { |
| 17803 | if (fn_entry == nullptr) { | 18804 | if (fn_entry == nullptr) { |
| 17804 | if (fn_type->data.fn.fn_type_id.cc != CallingConventionAsync) { | 18805 | if (fn_type->data.fn.fn_type_id.cc != CallingConventionAsync) { |
| 17805 | ir_add_error(ira, fn_ref, | 18806 | ir_add_error(ira, &fn_ref->base, |
| 17806 | buf_sprintf("expected async function, found '%s'", buf_ptr(&fn_type->name))); | 18807 | buf_sprintf("expected async function, found '%s'", buf_ptr(&fn_type->name))); |
| 17807 | return ira->codegen->invalid_instruction; | 18808 | return ira->codegen->invalid_inst_gen; |
| 17808 | } | 18809 | } |
| 17809 | if (casted_new_stack == nullptr) { | 18810 | if (casted_new_stack == nullptr) { |
| 17810 | ir_add_error(ira, fn_ref, buf_sprintf("function is not comptime-known; @asyncCall required")); | 18811 | ir_add_error(ira, &fn_ref->base, buf_sprintf("function is not comptime-known; @asyncCall required")); |
| 17811 | return ira->codegen->invalid_instruction; | 18812 | return ira->codegen->invalid_inst_gen; |
| 17812 | } | 18813 | } |
| 17813 | } | 18814 | } |
| 17814 | if (casted_new_stack != nullptr) { | 18815 | if (casted_new_stack != nullptr) { |
| 17815 | ZigType *fn_ret_type = fn_type->data.fn.fn_type_id.return_type; | 18816 | ZigType *fn_ret_type = fn_type->data.fn.fn_type_id.return_type; |
| 17816 | IrInstruction *ret_ptr = get_async_call_result_loc(ira, source_instr, fn_ret_type, is_async_call_builtin, | 18817 | IrInstGen *ret_ptr = get_async_call_result_loc(ira, source_instr, fn_ret_type, is_async_call_builtin, |
| 17817 | casted_args, arg_count, ret_ptr_uncasted); | 18818 | casted_args, arg_count, ret_ptr_uncasted); |
| 17818 | if (ret_ptr != nullptr && type_is_invalid(ret_ptr->value->type)) | 18819 | if (ret_ptr != nullptr && type_is_invalid(ret_ptr->value->type)) |
| 17819 | return ira->codegen->invalid_instruction; | 18820 | return ira->codegen->invalid_inst_gen; |
| 17820 | | 18821 | |
| 17821 | ZigType *anyframe_type = get_any_frame_type(ira->codegen, fn_ret_type); | 18822 | ZigType *anyframe_type = get_any_frame_type(ira->codegen, fn_ret_type); |
| 17822 | | 18823 | |
| 17823 | IrInstructionCallGen *call_gen = ir_build_call_gen(ira, source_instr, fn_entry, fn_ref, | 18824 | IrInstGenCall *call_gen = ir_build_call_gen(ira, source_instr, fn_entry, fn_ref, |
| 17824 | arg_count, casted_args, CallModifierAsync, casted_new_stack, | 18825 | arg_count, casted_args, CallModifierAsync, casted_new_stack, |
| 17825 | is_async_call_builtin, ret_ptr, anyframe_type); | 18826 | is_async_call_builtin, ret_ptr, anyframe_type); |
| 17826 | return &call_gen->base; | 18827 | return &call_gen->base; |
| 17827 | } else { | 18828 | } else { |
| 17828 | ZigType *frame_type = get_fn_frame_type(ira->codegen, fn_entry); | 18829 | ZigType *frame_type = get_fn_frame_type(ira->codegen, fn_entry); |
| 17829 | IrInstruction *result_loc = ir_resolve_result(ira, source_instr, call_result_loc, | 18830 | IrInstGen *result_loc = ir_resolve_result(ira, source_instr, call_result_loc, |
| 17830 | frame_type, nullptr, true, true, false); | 18831 | frame_type, nullptr, true, true, false); |
| 17831 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { | 18832 | if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) { |
| 17832 | return result_loc; | 18833 | return result_loc; |
| 17833 | } | 18834 | } |
| 17834 | result_loc = ir_implicit_cast(ira, result_loc, get_pointer_to_type(ira->codegen, frame_type, false)); | 18835 | result_loc = ir_implicit_cast(ira, result_loc, get_pointer_to_type(ira->codegen, frame_type, false)); |
| 17835 | if (type_is_invalid(result_loc->value->type)) | 18836 | if (type_is_invalid(result_loc->value->type)) |
| 17836 | return ira->codegen->invalid_instruction; | 18837 | return ira->codegen->invalid_inst_gen; |
| 17837 | return &ir_build_call_gen(ira, source_instr, fn_entry, fn_ref, arg_count, | 18838 | return &ir_build_call_gen(ira, source_instr, fn_entry, fn_ref, arg_count, |
| 17838 | casted_args, CallModifierAsync, casted_new_stack, | 18839 | casted_args, CallModifierAsync, casted_new_stack, |
| 17839 | is_async_call_builtin, result_loc, frame_type)->base; | 18840 | is_async_call_builtin, result_loc, frame_type)->base; |
| 17840 | } | 18841 | } |
| 17841 | } | 18842 | } |
| 17842 | static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node, | 18843 | static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node, |
| 17843 | IrInstruction *arg, Scope **exec_scope, size_t *next_proto_i) | 18844 | IrInstGen *arg, Scope **exec_scope, size_t *next_proto_i) |
| 17844 | { | 18845 | { |
| 17845 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(*next_proto_i); | 18846 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(*next_proto_i); |
| 17846 | assert(param_decl_node->type == NodeTypeParamDecl); | 18847 | assert(param_decl_node->type == NodeTypeParamDecl); |
| 17847 | | 18848 | |
| 17848 | IrInstruction *casted_arg; | 18849 | IrInstGen *casted_arg; |
| 17849 | if (param_decl_node->data.param_decl.var_token == nullptr) { | 18850 | if (param_decl_node->data.param_decl.var_token == nullptr) { |
| 17850 | AstNode *param_type_node = param_decl_node->data.param_decl.type; | 18851 | AstNode *param_type_node = param_decl_node->data.param_decl.type; |
| 17851 | ZigType *param_type = ir_analyze_type_expr(ira, *exec_scope, param_type_node); | 18852 | ZigType *param_type = ir_analyze_type_expr(ira, *exec_scope, param_type_node); |
| ... | @@ -17873,15 +18874,15 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node | ... | @@ -17873,15 +18874,15 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node |
| 17873 | } | 18874 | } |
| 17874 | | 18875 | |
| 17875 | static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_node, | 18876 | static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_node, |
| 17876 | IrInstruction *arg, Scope **child_scope, size_t *next_proto_i, | 18877 | IrInstGen *arg, Scope **child_scope, size_t *next_proto_i, |
| 17877 | GenericFnTypeId *generic_id, FnTypeId *fn_type_id, IrInstruction **casted_args, | 18878 | GenericFnTypeId *generic_id, FnTypeId *fn_type_id, IrInstGen **casted_args, |
| 17878 | ZigFn *impl_fn) | 18879 | ZigFn *impl_fn) |
| 17879 | { | 18880 | { |
| 17880 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(*next_proto_i); | 18881 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(*next_proto_i); |
| 17881 | assert(param_decl_node->type == NodeTypeParamDecl); | 18882 | assert(param_decl_node->type == NodeTypeParamDecl); |
| 17882 | bool is_var_args = param_decl_node->data.param_decl.is_var_args; | 18883 | bool is_var_args = param_decl_node->data.param_decl.is_var_args; |
| 17883 | bool arg_part_of_generic_id = false; | 18884 | bool arg_part_of_generic_id = false; |
| 17884 | IrInstruction *casted_arg; | 18885 | IrInstGen *casted_arg; |
| 17885 | if (is_var_args) { | 18886 | if (is_var_args) { |
| 17886 | arg_part_of_generic_id = true; | 18887 | arg_part_of_generic_id = true; |
| 17887 | casted_arg = arg; | 18888 | casted_arg = arg; |
| ... | @@ -17941,7 +18942,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -17941,7 +18942,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 17941 | } else if (casted_arg->value->type->id == ZigTypeIdComptimeInt || | 18942 | } else if (casted_arg->value->type->id == ZigTypeIdComptimeInt || |
| 17942 | casted_arg->value->type->id == ZigTypeIdComptimeFloat) | 18943 | casted_arg->value->type->id == ZigTypeIdComptimeFloat) |
| 17943 | { | 18944 | { |
| 17944 | ir_add_error(ira, casted_arg, | 18945 | ir_add_error(ira, &casted_arg->base, |
| 17945 | buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/ziglang/zig/issues/557")); | 18946 | buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/ziglang/zig/issues/557")); |
| 17946 | return false; | 18947 | return false; |
| 17947 | } | 18948 | } |
| ... | @@ -17958,17 +18959,17 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -17958,17 +18959,17 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 17958 | return true; | 18959 | return true; |
| 17959 | } | 18960 | } |
| 17960 | | 18961 | |
| 17961 | static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, ZigVar *var) { | 18962 | static IrInstGen *ir_get_var_ptr(IrAnalyze *ira, IrInst *source_instr, ZigVar *var) { |
| 17962 | while (var->next_var != nullptr) { | 18963 | while (var->next_var != nullptr) { |
| 17963 | var = var->next_var; | 18964 | var = var->next_var; |
| 17964 | } | 18965 | } |
| 17965 | | 18966 | |
| 17966 | if (var->mem_slot_index != SIZE_MAX && var->owner_exec->analysis == nullptr) { | 18967 | if (var->mem_slot_index != SIZE_MAX && var->owner_exec->analysis == nullptr) { |
| 17967 | assert(ira->codegen->errors.length != 0); | 18968 | assert(ira->codegen->errors.length != 0); |
| 17968 | return ira->codegen->invalid_instruction; | 18969 | return ira->codegen->invalid_inst_gen; |
| 17969 | } | 18970 | } |
| 17970 | if (var->var_type == nullptr || type_is_invalid(var->var_type)) | 18971 | if (var->var_type == nullptr || type_is_invalid(var->var_type)) |
| 17971 | return ira->codegen->invalid_instruction; | 18972 | return ira->codegen->invalid_inst_gen; |
| 17972 | | 18973 | |
| 17973 | ZigValue *mem_slot = nullptr; | 18974 | ZigValue *mem_slot = nullptr; |
| 17974 | | 18975 | |
| ... | @@ -17976,8 +18977,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, | ... | @@ -17976,8 +18977,7 @@ static IrInstruction *ir_get_var_ptr(IrAnalyze *ira, IrInstruction *instruction, |
| 17976 | bool linkage_makes_it_runtime = var->decl_node->data.variable_declaration.is_extern; | 18977 | bool linkage_makes_it_runtime = var->decl_node->data.variable_declaration.is_extern; |
| 17977 | bool is_volatile = false; | 18978 | bool is_volatile = false; |
| 17978 | | 18979 | |
| 17979 | IrInstruction *result = ir_build_var_ptr(&ira->new_irb, | 18980 | IrInstGen *result = ir_build_var_ptr_gen(ira, source_instr, var); |
| 17980 | instruction->scope, instruction->source_node, var); | | |
| 17981 | result->value->type = get_pointer_to_type_extra(ira->codegen, var->var_type, | 18981 | result->value->type = get_pointer_to_type_extra(ira->codegen, var->var_type, |
| 17982 | var->src_is_const, is_volatile, PtrLenSingle, var->align_bytes, 0, 0, false); | 18982 | var->src_is_const, is_volatile, PtrLenSingle, var->align_bytes, 0, 0, false); |
| 17983 | | 18983 | |
| ... | @@ -18030,7 +19030,7 @@ no_mem_slot: | ... | @@ -18030,7 +19030,7 @@ no_mem_slot: |
| 18030 | } | 19030 | } |
| 18031 | | 19031 | |
| 18032 | // This function is called when a comptime value becomes accessible at runtime. | 19032 | // This function is called when a comptime value becomes accessible at runtime. |
| 18033 | static void mark_comptime_value_escape(IrAnalyze *ira, IrInstruction *source_instr, ZigValue *val) { | 19033 | static void mark_comptime_value_escape(IrAnalyze *ira, IrInst* source_instr, ZigValue *val) { |
| 18034 | ir_assert(value_is_comptime(val), source_instr); | 19034 | ir_assert(value_is_comptime(val), source_instr); |
| 18035 | if (val->special == ConstValSpecialUndef) | 19035 | if (val->special == ConstValSpecialUndef) |
| 18036 | return; | 19036 | return; |
| ... | @@ -18043,8 +19043,8 @@ static void mark_comptime_value_escape(IrAnalyze *ira, IrInstruction *source_ins | ... | @@ -18043,8 +19043,8 @@ static void mark_comptime_value_escape(IrAnalyze *ira, IrInstruction *source_ins |
| 18043 | } | 19043 | } |
| 18044 | } | 19044 | } |
| 18045 | | 19045 | |
| 18046 | static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source_instr, | 19046 | static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, IrInst* source_instr, |
| 18047 | IrInstruction *ptr, IrInstruction *uncasted_value, bool allow_write_through_const) | 19047 | IrInstGen *ptr, IrInstGen *uncasted_value, bool allow_write_through_const) |
| 18048 | { | 19048 | { |
| 18049 | assert(ptr->value->type->id == ZigTypeIdPointer); | 19049 | assert(ptr->value->type->id == ZigTypeIdPointer); |
| 18050 | | 19050 | |
| ... | @@ -18053,24 +19053,24 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -18053,24 +19053,24 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 18053 | uncasted_value->value->type->id == ZigTypeIdErrorSet) | 19053 | uncasted_value->value->type->id == ZigTypeIdErrorSet) |
| 18054 | { | 19054 | { |
| 18055 | ir_add_error(ira, source_instr, buf_sprintf("error is discarded")); | 19055 | ir_add_error(ira, source_instr, buf_sprintf("error is discarded")); |
| 18056 | return ira->codegen->invalid_instruction; | 19056 | return ira->codegen->invalid_inst_gen; |
| 18057 | } | 19057 | } |
| 18058 | return ir_const_void(ira, source_instr); | 19058 | return ir_const_void(ira, source_instr); |
| 18059 | } | 19059 | } |
| 18060 | | 19060 | |
| 18061 | if (ptr->value->type->data.pointer.is_const && !allow_write_through_const) { | 19061 | if (ptr->value->type->data.pointer.is_const && !allow_write_through_const) { |
| 18062 | ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); | 19062 | ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); |
| 18063 | return ira->codegen->invalid_instruction; | 19063 | return ira->codegen->invalid_inst_gen; |
| 18064 | } | 19064 | } |
| 18065 | | 19065 | |
| 18066 | ZigType *child_type = ptr->value->type->data.pointer.child_type; | 19066 | ZigType *child_type = ptr->value->type->data.pointer.child_type; |
| 18067 | IrInstruction *value = ir_implicit_cast(ira, uncasted_value, child_type); | 19067 | IrInstGen *value = ir_implicit_cast(ira, uncasted_value, child_type); |
| 18068 | if (value == ira->codegen->invalid_instruction) | 19068 | if (type_is_invalid(value->value->type)) |
| 18069 | return ira->codegen->invalid_instruction; | 19069 | return ira->codegen->invalid_inst_gen; |
| 18070 | | 19070 | |
| 18071 | switch (type_has_one_possible_value(ira->codegen, child_type)) { | 19071 | switch (type_has_one_possible_value(ira->codegen, child_type)) { |
| 18072 | case OnePossibleValueInvalid: | 19072 | case OnePossibleValueInvalid: |
| 18073 | return ira->codegen->invalid_instruction; | 19073 | return ira->codegen->invalid_inst_gen; |
| 18074 | case OnePossibleValueYes: | 19074 | case OnePossibleValueYes: |
| 18075 | return ir_const_void(ira, source_instr); | 19075 | return ir_const_void(ira, source_instr); |
| 18076 | case OnePossibleValueNo: | 19076 | case OnePossibleValueNo: |
| ... | @@ -18080,7 +19080,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -18080,7 +19080,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 18080 | if (instr_is_comptime(ptr) && ptr->value->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 19080 | if (instr_is_comptime(ptr) && ptr->value->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 18081 | if (!allow_write_through_const && ptr->value->data.x_ptr.mut == ConstPtrMutComptimeConst) { | 19081 | if (!allow_write_through_const && ptr->value->data.x_ptr.mut == ConstPtrMutComptimeConst) { |
| 18082 | ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); | 19082 | ir_add_error(ira, source_instr, buf_sprintf("cannot assign to constant")); |
| 18083 | return ira->codegen->invalid_instruction; | 19083 | return ira->codegen->invalid_inst_gen; |
| 18084 | } | 19084 | } |
| 18085 | if ((allow_write_through_const && ptr->value->data.x_ptr.mut == ConstPtrMutComptimeConst) || | 19085 | if ((allow_write_through_const && ptr->value->data.x_ptr.mut == ConstPtrMutComptimeConst) || |
| 18086 | ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar || | 19086 | ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar || |
| ... | @@ -18089,7 +19089,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -18089,7 +19089,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 18089 | if (instr_is_comptime(value)) { | 19089 | if (instr_is_comptime(value)) { |
| 18090 | ZigValue *dest_val = const_ptr_pointee(ira, ira->codegen, ptr->value, source_instr->source_node); | 19090 | ZigValue *dest_val = const_ptr_pointee(ira, ira->codegen, ptr->value, source_instr->source_node); |
| 18091 | if (dest_val == nullptr) | 19091 | if (dest_val == nullptr) |
| 18092 | return ira->codegen->invalid_instruction; | 19092 | return ira->codegen->invalid_inst_gen; |
| 18093 | if (dest_val->special != ConstValSpecialRuntime) { | 19093 | if (dest_val->special != ConstValSpecialRuntime) { |
| 18094 | copy_const_val(dest_val, value->value); | 19094 | copy_const_val(dest_val, value->value); |
| 18095 | | 19095 | |
| ... | @@ -18109,7 +19109,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -18109,7 +19109,7 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 18109 | ZigValue *dest_val = const_ptr_pointee_unchecked(ira->codegen, ptr->value); | 19109 | ZigValue *dest_val = const_ptr_pointee_unchecked(ira->codegen, ptr->value); |
| 18110 | dest_val->type = ira->codegen->builtin_types.entry_invalid; | 19110 | dest_val->type = ira->codegen->builtin_types.entry_invalid; |
| 18111 | | 19111 | |
| 18112 | return ira->codegen->invalid_instruction; | 19112 | return ira->codegen->invalid_inst_gen; |
| 18113 | } | 19113 | } |
| 18114 | } | 19114 | } |
| 18115 | } | 19115 | } |
| ... | @@ -18122,15 +19122,15 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -18122,15 +19122,15 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 18122 | | 19122 | |
| 18123 | switch (type_requires_comptime(ira->codegen, child_type)) { | 19123 | switch (type_requires_comptime(ira->codegen, child_type)) { |
| 18124 | case ReqCompTimeInvalid: | 19124 | case ReqCompTimeInvalid: |
| 18125 | return ira->codegen->invalid_instruction; | 19125 | return ira->codegen->invalid_inst_gen; |
| 18126 | case ReqCompTimeYes: | 19126 | case ReqCompTimeYes: |
| 18127 | switch (type_has_one_possible_value(ira->codegen, ptr->value->type)) { | 19127 | switch (type_has_one_possible_value(ira->codegen, ptr->value->type)) { |
| 18128 | case OnePossibleValueInvalid: | 19128 | case OnePossibleValueInvalid: |
| 18129 | return ira->codegen->invalid_instruction; | 19129 | return ira->codegen->invalid_inst_gen; |
| 18130 | case OnePossibleValueNo: | 19130 | case OnePossibleValueNo: |
| 18131 | ir_add_error(ira, source_instr, | 19131 | ir_add_error(ira, source_instr, |
| 18132 | buf_sprintf("cannot store runtime value in type '%s'", buf_ptr(&child_type->name))); | 19132 | buf_sprintf("cannot store runtime value in type '%s'", buf_ptr(&child_type->name))); |
| 18133 | return ira->codegen->invalid_instruction; | 19133 | return ira->codegen->invalid_inst_gen; |
| 18134 | case OnePossibleValueYes: | 19134 | case OnePossibleValueYes: |
| 18135 | return ir_const_void(ira, source_instr); | 19135 | return ir_const_void(ira, source_instr); |
| 18136 | } | 19136 | } |
| ... | @@ -18144,30 +19144,28 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -18144,30 +19144,28 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 18144 | } | 19144 | } |
| 18145 | | 19145 | |
| 18146 | // If this is a store to a pointer with a runtime-known vector index, | 19146 | // If this is a store to a pointer with a runtime-known vector index, |
| 18147 | // we have to figure out the IrInstruction which represents the index and | 19147 | // we have to figure out the IrInstGen which represents the index and |
| 18148 | // emit a IrInstructionVectorStoreElem, or emit a compile error | 19148 | // emit a IrInstGenVectorStoreElem, or emit a compile error |
| 18149 | // explaining why it is impossible for this store to work. Which is that | 19149 | // explaining why it is impossible for this store to work. Which is that |
| 18150 | // the pointer address is of the vector; without the element index being known | 19150 | // the pointer address is of the vector; without the element index being known |
| 18151 | // we cannot properly perform the insertion. | 19151 | // we cannot properly perform the insertion. |
| 18152 | if (ptr->value->type->data.pointer.vector_index == VECTOR_INDEX_RUNTIME) { | 19152 | if (ptr->value->type->data.pointer.vector_index == VECTOR_INDEX_RUNTIME) { |
| 18153 | if (ptr->id == IrInstructionIdElemPtr) { | 19153 | if (ptr->id == IrInstGenIdElemPtr) { |
| 18154 | IrInstructionElemPtr *elem_ptr = (IrInstructionElemPtr *)ptr; | 19154 | IrInstGenElemPtr *elem_ptr = (IrInstGenElemPtr *)ptr; |
| 18155 | return ir_build_vector_store_elem(ira, source_instr, elem_ptr->array_ptr, | 19155 | return ir_build_vector_store_elem(ira, source_instr, elem_ptr->array_ptr, |
| 18156 | elem_ptr->elem_index, value); | 19156 | elem_ptr->elem_index, value); |
| 18157 | } | 19157 | } |
| 18158 | ir_add_error(ira, ptr, | 19158 | ir_add_error(ira, &ptr->base, |
| 18159 | buf_sprintf("unable to determine vector element index of type '%s'", | 19159 | buf_sprintf("unable to determine vector element index of type '%s'", |
| 18160 | buf_ptr(&ptr->value->type->name))); | 19160 | buf_ptr(&ptr->value->type->name))); |
| 18161 | return ira->codegen->invalid_instruction; | 19161 | return ira->codegen->invalid_inst_gen; |
| 18162 | } | 19162 | } |
| 18163 | | 19163 | |
| 18164 | IrInstructionStorePtr *store_ptr = ir_build_store_ptr(&ira->new_irb, source_instr->scope, | 19164 | return ir_build_store_ptr_gen(ira, source_instr, ptr, value); |
| 18165 | source_instr->source_node, ptr, value); | | |
| 18166 | return &store_ptr->base; | | |
| 18167 | } | 19165 | } |
| 18168 | | 19166 | |
| 18169 | static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstruction *source_instr, | 19167 | static IrInstGen *analyze_casted_new_stack(IrAnalyze *ira, IrInst* source_instr, |
| 18170 | IrInstruction *new_stack, bool is_async_call_builtin, ZigFn *fn_entry) | 19168 | IrInstGen *new_stack, bool is_async_call_builtin, ZigFn *fn_entry) |
| 18171 | { | 19169 | { |
| 18172 | if (new_stack == nullptr) | 19170 | if (new_stack == nullptr) |
| 18173 | return nullptr; | 19171 | return nullptr; |
| ... | @@ -18196,11 +19194,11 @@ static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstruction *so | ... | @@ -18196,11 +19194,11 @@ static IrInstruction *analyze_casted_new_stack(IrAnalyze *ira, IrInstruction *so |
| 18196 | } | 19194 | } |
| 18197 | } | 19195 | } |
| 18198 | | 19196 | |
| 18199 | static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_instr, | 19197 | static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 18200 | ZigFn *fn_entry, ZigType *fn_type, IrInstruction *fn_ref, | 19198 | ZigFn *fn_entry, ZigType *fn_type, IrInstGen *fn_ref, |
| 18201 | IrInstruction *first_arg_ptr, CallModifier modifier, | 19199 | IrInstGen *first_arg_ptr, CallModifier modifier, |
| 18202 | IrInstruction *new_stack, bool is_async_call_builtin, | 19200 | IrInstGen *new_stack, bool is_async_call_builtin, |
| 18203 | IrInstruction **args_ptr, size_t args_len, IrInstruction *ret_ptr, ResultLoc *call_result_loc) | 19201 | IrInstGen **args_ptr, size_t args_len, IrInstGen *ret_ptr, ResultLoc *call_result_loc) |
| 18204 | { | 19202 | { |
| 18205 | Error err; | 19203 | Error err; |
| 18206 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; | 19204 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; |
| ... | @@ -18221,11 +19219,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18221,11 +19219,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18221 | AstNode *fn_proto_node = fn_entry ? fn_entry->proto_node : nullptr;; | 19219 | AstNode *fn_proto_node = fn_entry ? fn_entry->proto_node : nullptr;; |
| 18222 | | 19220 | |
| 18223 | if (fn_type_id->cc == CallingConventionNaked) { | 19221 | if (fn_type_id->cc == CallingConventionNaked) { |
| 18224 | ErrorMsg *msg = ir_add_error(ira, fn_ref, buf_sprintf("unable to call function with naked calling convention")); | 19222 | ErrorMsg *msg = ir_add_error(ira, &fn_ref->base, buf_sprintf("unable to call function with naked calling convention")); |
| 18225 | if (fn_proto_node) { | 19223 | if (fn_proto_node) { |
| 18226 | add_error_note(ira->codegen, msg, fn_proto_node, buf_sprintf("declared here")); | 19224 | add_error_note(ira->codegen, msg, fn_proto_node, buf_sprintf("declared here")); |
| 18227 | } | 19225 | } |
| 18228 | return ira->codegen->invalid_instruction; | 19226 | return ira->codegen->invalid_inst_gen; |
| 18229 | } | 19227 | } |
| 18230 | | 19228 | |
| 18231 | if (fn_type_id->is_var_args) { | 19229 | if (fn_type_id->is_var_args) { |
| ... | @@ -18236,7 +19234,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18236,7 +19234,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18236 | add_error_note(ira->codegen, msg, fn_proto_node, | 19234 | add_error_note(ira->codegen, msg, fn_proto_node, |
| 18237 | buf_sprintf("declared here")); | 19235 | buf_sprintf("declared here")); |
| 18238 | } | 19236 | } |
| 18239 | return ira->codegen->invalid_instruction; | 19237 | return ira->codegen->invalid_inst_gen; |
| 18240 | } | 19238 | } |
| 18241 | } else if (src_param_count != call_param_count) { | 19239 | } else if (src_param_count != call_param_count) { |
| 18242 | ErrorMsg *msg = ir_add_error_node(ira, source_node, | 19240 | ErrorMsg *msg = ir_add_error_node(ira, source_node, |
| ... | @@ -18245,18 +19243,18 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18245,18 +19243,18 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18245 | add_error_note(ira->codegen, msg, fn_proto_node, | 19243 | add_error_note(ira->codegen, msg, fn_proto_node, |
| 18246 | buf_sprintf("declared here")); | 19244 | buf_sprintf("declared here")); |
| 18247 | } | 19245 | } |
| 18248 | return ira->codegen->invalid_instruction; | 19246 | return ira->codegen->invalid_inst_gen; |
| 18249 | } | 19247 | } |
| 18250 | | 19248 | |
| 18251 | if (modifier == CallModifierCompileTime) { | 19249 | if (modifier == CallModifierCompileTime) { |
| 18252 | // No special handling is needed for compile time evaluation of generic functions. | 19250 | // No special handling is needed for compile time evaluation of generic functions. |
| 18253 | if (!fn_entry || fn_entry->body_node == nullptr) { | 19251 | if (!fn_entry || fn_entry->body_node == nullptr) { |
| 18254 | ir_add_error(ira, fn_ref, buf_sprintf("unable to evaluate constant expression")); | 19252 | ir_add_error(ira, &fn_ref->base, buf_sprintf("unable to evaluate constant expression")); |
| 18255 | return ira->codegen->invalid_instruction; | 19253 | return ira->codegen->invalid_inst_gen; |
| 18256 | } | 19254 | } |
| 18257 | | 19255 | |
| 18258 | if (!ir_emit_backward_branch(ira, source_instr)) | 19256 | if (!ir_emit_backward_branch(ira, source_instr)) |
| 18259 | return ira->codegen->invalid_instruction; | 19257 | return ira->codegen->invalid_inst_gen; |
| 18260 | | 19258 | |
| 18261 | // Fork a scope of the function with known values for the parameters. | 19259 | // Fork a scope of the function with known values for the parameters. |
| 18262 | Scope *exec_scope = &fn_entry->fndef_scope->base; | 19260 | Scope *exec_scope = &fn_entry->fndef_scope->base; |
| ... | @@ -18269,47 +19267,47 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18269,47 +19267,47 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18269 | if (fn_type_id->next_param_index >= 1) { | 19267 | if (fn_type_id->next_param_index >= 1) { |
| 18270 | ZigType *param_type = fn_type_id->param_info[next_proto_i].type; | 19268 | ZigType *param_type = fn_type_id->param_info[next_proto_i].type; |
| 18271 | if (type_is_invalid(param_type)) | 19269 | if (type_is_invalid(param_type)) |
| 18272 | return ira->codegen->invalid_instruction; | 19270 | return ira->codegen->invalid_inst_gen; |
| 18273 | first_arg_known_bare = param_type->id != ZigTypeIdPointer; | 19271 | first_arg_known_bare = param_type->id != ZigTypeIdPointer; |
| 18274 | } | 19272 | } |
| 18275 | | 19273 | |
| 18276 | IrInstruction *first_arg; | 19274 | IrInstGen *first_arg; |
| 18277 | if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) { | 19275 | if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) { |
| 18278 | first_arg = first_arg_ptr; | 19276 | first_arg = first_arg_ptr; |
| 18279 | } else { | 19277 | } else { |
| 18280 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); | 19278 | first_arg = ir_get_deref(ira, &first_arg_ptr->base, first_arg_ptr, nullptr); |
| 18281 | if (type_is_invalid(first_arg->value->type)) | 19279 | if (type_is_invalid(first_arg->value->type)) |
| 18282 | return ira->codegen->invalid_instruction; | 19280 | return ira->codegen->invalid_inst_gen; |
| 18283 | } | 19281 | } |
| 18284 | | 19282 | |
| 18285 | if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, first_arg, &exec_scope, &next_proto_i)) | 19283 | if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, first_arg, &exec_scope, &next_proto_i)) |
| 18286 | return ira->codegen->invalid_instruction; | 19284 | return ira->codegen->invalid_inst_gen; |
| 18287 | } | 19285 | } |
| 18288 | | 19286 | |
| 18289 | if (fn_proto_node->data.fn_proto.is_var_args) { | 19287 | if (fn_proto_node->data.fn_proto.is_var_args) { |
| 18290 | ir_add_error(ira, source_instr, | 19288 | ir_add_error(ira, source_instr, |
| 18291 | buf_sprintf("compiler bug: unable to call var args function at compile time. https://github.com/ziglang/zig/issues/313")); | 19289 | buf_sprintf("compiler bug: unable to call var args function at compile time. https://github.com/ziglang/zig/issues/313")); |
| 18292 | return ira->codegen->invalid_instruction; | 19290 | return ira->codegen->invalid_inst_gen; |
| 18293 | } | 19291 | } |
| 18294 | | 19292 | |
| 18295 | | 19293 | |
| 18296 | for (size_t call_i = 0; call_i < args_len; call_i += 1) { | 19294 | for (size_t call_i = 0; call_i < args_len; call_i += 1) { |
| 18297 | IrInstruction *old_arg = args_ptr[call_i]; | 19295 | IrInstGen *old_arg = args_ptr[call_i]; |
| 18298 | | 19296 | |
| 18299 | if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, old_arg, &exec_scope, &next_proto_i)) | 19297 | if (!ir_analyze_fn_call_inline_arg(ira, fn_proto_node, old_arg, &exec_scope, &next_proto_i)) |
| 18300 | return ira->codegen->invalid_instruction; | 19298 | return ira->codegen->invalid_inst_gen; |
| 18301 | } | 19299 | } |
| 18302 | | 19300 | |
| 18303 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; | 19301 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; |
| 18304 | ZigType *specified_return_type = ir_analyze_type_expr(ira, exec_scope, return_type_node); | 19302 | ZigType *specified_return_type = ir_analyze_type_expr(ira, exec_scope, return_type_node); |
| 18305 | if (type_is_invalid(specified_return_type)) | 19303 | if (type_is_invalid(specified_return_type)) |
| 18306 | return ira->codegen->invalid_instruction; | 19304 | return ira->codegen->invalid_inst_gen; |
| 18307 | ZigType *return_type; | 19305 | ZigType *return_type; |
| 18308 | ZigType *inferred_err_set_type = nullptr; | 19306 | ZigType *inferred_err_set_type = nullptr; |
| 18309 | if (fn_proto_node->data.fn_proto.auto_err_set) { | 19307 | if (fn_proto_node->data.fn_proto.auto_err_set) { |
| 18310 | inferred_err_set_type = get_auto_err_set_type(ira->codegen, fn_entry); | 19308 | inferred_err_set_type = get_auto_err_set_type(ira->codegen, fn_entry); |
| 18311 | if ((err = type_resolve(ira->codegen, specified_return_type, ResolveStatusSizeKnown))) | 19309 | if ((err = type_resolve(ira->codegen, specified_return_type, ResolveStatusSizeKnown))) |
| 18312 | return ira->codegen->invalid_instruction; | 19310 | return ira->codegen->invalid_inst_gen; |
| 18313 | return_type = get_error_union_type(ira->codegen, inferred_err_set_type, specified_return_type); | 19311 | return_type = get_error_union_type(ira->codegen, inferred_err_set_type, specified_return_type); |
| 18314 | } else { | 19312 | } else { |
| 18315 | return_type = specified_return_type; | 19313 | return_type = specified_return_type; |
| ... | @@ -18354,24 +19352,24 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18354,24 +19352,24 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18354 | } | 19352 | } |
| 18355 | | 19353 | |
| 18356 | if (type_is_invalid(result->type)) { | 19354 | if (type_is_invalid(result->type)) { |
| 18357 | return ira->codegen->invalid_instruction; | 19355 | return ira->codegen->invalid_inst_gen; |
| 18358 | } | 19356 | } |
| 18359 | } | 19357 | } |
| 18360 | | 19358 | |
| 18361 | IrInstruction *new_instruction = ir_const_move(ira, source_instr, result); | 19359 | IrInstGen *new_instruction = ir_const_move(ira, source_instr, result); |
| 18362 | return ir_finish_anal(ira, new_instruction); | 19360 | return ir_finish_anal(ira, new_instruction); |
| 18363 | } | 19361 | } |
| 18364 | | 19362 | |
| 18365 | if (fn_type->data.fn.is_generic) { | 19363 | if (fn_type->data.fn.is_generic) { |
| 18366 | if (!fn_entry) { | 19364 | if (!fn_entry) { |
| 18367 | ir_add_error(ira, fn_ref, | 19365 | ir_add_error(ira, &fn_ref->base, |
| 18368 | buf_sprintf("calling a generic function requires compile-time known function value")); | 19366 | buf_sprintf("calling a generic function requires compile-time known function value")); |
| 18369 | return ira->codegen->invalid_instruction; | 19367 | return ira->codegen->invalid_inst_gen; |
| 18370 | } | 19368 | } |
| 18371 | | 19369 | |
| 18372 | size_t new_fn_arg_count = first_arg_1_or_0 + args_len; | 19370 | size_t new_fn_arg_count = first_arg_1_or_0 + args_len; |
| 18373 | | 19371 | |
| 18374 | IrInstruction **casted_args = allocate<IrInstruction *>(new_fn_arg_count); | 19372 | IrInstGen **casted_args = allocate<IrInstGen *>(new_fn_arg_count); |
| 18375 | | 19373 | |
| 18376 | // Fork a scope of the function with known values for the parameters. | 19374 | // Fork a scope of the function with known values for the parameters. |
| 18377 | Scope *parent_scope = fn_entry->fndef_scope->base.parent; | 19375 | Scope *parent_scope = fn_entry->fndef_scope->base.parent; |
| ... | @@ -18400,30 +19398,30 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18400,30 +19398,30 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18400 | if (fn_type_id->next_param_index >= 1) { | 19398 | if (fn_type_id->next_param_index >= 1) { |
| 18401 | ZigType *param_type = fn_type_id->param_info[next_proto_i].type; | 19399 | ZigType *param_type = fn_type_id->param_info[next_proto_i].type; |
| 18402 | if (type_is_invalid(param_type)) | 19400 | if (type_is_invalid(param_type)) |
| 18403 | return ira->codegen->invalid_instruction; | 19401 | return ira->codegen->invalid_inst_gen; |
| 18404 | first_arg_known_bare = param_type->id != ZigTypeIdPointer; | 19402 | first_arg_known_bare = param_type->id != ZigTypeIdPointer; |
| 18405 | } | 19403 | } |
| 18406 | | 19404 | |
| 18407 | IrInstruction *first_arg; | 19405 | IrInstGen *first_arg; |
| 18408 | if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) { | 19406 | if (!first_arg_known_bare && handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) { |
| 18409 | first_arg = first_arg_ptr; | 19407 | first_arg = first_arg_ptr; |
| 18410 | } else { | 19408 | } else { |
| 18411 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); | 19409 | first_arg = ir_get_deref(ira, &first_arg_ptr->base, first_arg_ptr, nullptr); |
| 18412 | if (type_is_invalid(first_arg->value->type)) | 19410 | if (type_is_invalid(first_arg->value->type)) |
| 18413 | return ira->codegen->invalid_instruction; | 19411 | return ira->codegen->invalid_inst_gen; |
| 18414 | } | 19412 | } |
| 18415 | | 19413 | |
| 18416 | if (!ir_analyze_fn_call_generic_arg(ira, fn_proto_node, first_arg, &impl_fn->child_scope, | 19414 | if (!ir_analyze_fn_call_generic_arg(ira, fn_proto_node, first_arg, &impl_fn->child_scope, |
| 18417 | &next_proto_i, generic_id, &inst_fn_type_id, casted_args, impl_fn)) | 19415 | &next_proto_i, generic_id, &inst_fn_type_id, casted_args, impl_fn)) |
| 18418 | { | 19416 | { |
| 18419 | return ira->codegen->invalid_instruction; | 19417 | return ira->codegen->invalid_inst_gen; |
| 18420 | } | 19418 | } |
| 18421 | } | 19419 | } |
| 18422 | | 19420 | |
| 18423 | ZigFn *parent_fn_entry = exec_fn_entry(ira->new_irb.exec); | 19421 | ZigFn *parent_fn_entry = ira->new_irb.exec->fn_entry; |
| 18424 | assert(parent_fn_entry); | 19422 | assert(parent_fn_entry); |
| 18425 | for (size_t call_i = 0; call_i < args_len; call_i += 1) { | 19423 | for (size_t call_i = 0; call_i < args_len; call_i += 1) { |
| 18426 | IrInstruction *arg = args_ptr[call_i]; | 19424 | IrInstGen *arg = args_ptr[call_i]; |
| 18427 | | 19425 | |
| 18428 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(next_proto_i); | 19426 | AstNode *param_decl_node = fn_proto_node->data.fn_proto.params.at(next_proto_i); |
| 18429 | assert(param_decl_node->type == NodeTypeParamDecl); | 19427 | assert(param_decl_node->type == NodeTypeParamDecl); |
| ... | @@ -18431,7 +19429,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18431,7 +19429,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18431 | if (!ir_analyze_fn_call_generic_arg(ira, fn_proto_node, arg, &impl_fn->child_scope, | 19429 | if (!ir_analyze_fn_call_generic_arg(ira, fn_proto_node, arg, &impl_fn->child_scope, |
| 18432 | &next_proto_i, generic_id, &inst_fn_type_id, casted_args, impl_fn)) | 19430 | &next_proto_i, generic_id, &inst_fn_type_id, casted_args, impl_fn)) |
| 18433 | { | 19431 | { |
| 18434 | return ira->codegen->invalid_instruction; | 19432 | return ira->codegen->invalid_inst_gen; |
| 18435 | } | 19433 | } |
| 18436 | } | 19434 | } |
| 18437 | | 19435 | |
| ... | @@ -18441,7 +19439,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18441,7 +19439,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18441 | ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, | 19439 | ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, |
| 18442 | nullptr, nullptr, fn_proto_node->data.fn_proto.align_expr, nullptr, ira->new_irb.exec, | 19440 | nullptr, nullptr, fn_proto_node->data.fn_proto.align_expr, nullptr, ira->new_irb.exec, |
| 18443 | nullptr, UndefBad); | 19441 | nullptr, UndefBad); |
| 18444 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 19442 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, |
| 18445 | impl_fn->child_scope, fn_proto_node->data.fn_proto.align_expr); | 19443 | impl_fn->child_scope, fn_proto_node->data.fn_proto.align_expr); |
| 18446 | copy_const_val(const_instruction->base.value, align_result); | 19444 | copy_const_val(const_instruction->base.value, align_result); |
| 18447 | | 19445 | |
| ... | @@ -18455,11 +19453,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18455,11 +19453,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18455 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; | 19453 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; |
| 18456 | ZigType *specified_return_type = ir_analyze_type_expr(ira, impl_fn->child_scope, return_type_node); | 19454 | ZigType *specified_return_type = ir_analyze_type_expr(ira, impl_fn->child_scope, return_type_node); |
| 18457 | if (type_is_invalid(specified_return_type)) | 19455 | if (type_is_invalid(specified_return_type)) |
| 18458 | return ira->codegen->invalid_instruction; | 19456 | return ira->codegen->invalid_inst_gen; |
| 18459 | if (fn_proto_node->data.fn_proto.auto_err_set) { | 19457 | if (fn_proto_node->data.fn_proto.auto_err_set) { |
| 18460 | ZigType *inferred_err_set_type = get_auto_err_set_type(ira->codegen, impl_fn); | 19458 | ZigType *inferred_err_set_type = get_auto_err_set_type(ira->codegen, impl_fn); |
| 18461 | if ((err = type_resolve(ira->codegen, specified_return_type, ResolveStatusSizeKnown))) | 19459 | if ((err = type_resolve(ira->codegen, specified_return_type, ResolveStatusSizeKnown))) |
| 18462 | return ira->codegen->invalid_instruction; | 19460 | return ira->codegen->invalid_inst_gen; |
| 18463 | inst_fn_type_id.return_type = get_error_union_type(ira->codegen, inferred_err_set_type, specified_return_type); | 19461 | inst_fn_type_id.return_type = get_error_union_type(ira->codegen, inferred_err_set_type, specified_return_type); |
| 18464 | } else { | 19462 | } else { |
| 18465 | inst_fn_type_id.return_type = specified_return_type; | 19463 | inst_fn_type_id.return_type = specified_return_type; |
| ... | @@ -18472,7 +19470,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18472,7 +19470,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18472 | CallModifierCompileTime, new_stack, is_async_call_builtin, args_ptr, args_len, | 19470 | CallModifierCompileTime, new_stack, is_async_call_builtin, args_ptr, args_len, |
| 18473 | ret_ptr, call_result_loc); | 19471 | ret_ptr, call_result_loc); |
| 18474 | case ReqCompTimeInvalid: | 19472 | case ReqCompTimeInvalid: |
| 18475 | return ira->codegen->invalid_instruction; | 19473 | return ira->codegen->invalid_inst_gen; |
| 18476 | case ReqCompTimeNo: | 19474 | case ReqCompTimeNo: |
| 18477 | break; | 19475 | break; |
| 18478 | } | 19476 | } |
| ... | @@ -18486,7 +19484,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18486,7 +19484,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18486 | // finish instantiating the function | 19484 | // finish instantiating the function |
| 18487 | impl_fn->type_entry = get_fn_type(ira->codegen, &inst_fn_type_id); | 19485 | impl_fn->type_entry = get_fn_type(ira->codegen, &inst_fn_type_id); |
| 18488 | if (type_is_invalid(impl_fn->type_entry)) | 19486 | if (type_is_invalid(impl_fn->type_entry)) |
| 18489 | return ira->codegen->invalid_instruction; | 19487 | return ira->codegen->invalid_inst_gen; |
| 18490 | | 19488 | |
| 18491 | impl_fn->ir_executable->source_node = source_instr->source_node; | 19489 | impl_fn->ir_executable->source_node = source_instr->source_node; |
| 18492 | impl_fn->ir_executable->parent_exec = ira->new_irb.exec; | 19490 | impl_fn->ir_executable->parent_exec = ira->new_irb.exec; |
| ... | @@ -18504,25 +19502,25 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18504,25 +19502,25 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18504 | parent_fn_entry->calls_or_awaits_errorable_fn = true; | 19502 | parent_fn_entry->calls_or_awaits_errorable_fn = true; |
| 18505 | } | 19503 | } |
| 18506 | | 19504 | |
| 18507 | IrInstruction *casted_new_stack = analyze_casted_new_stack(ira, source_instr, new_stack, | 19505 | IrInstGen *casted_new_stack = analyze_casted_new_stack(ira, source_instr, new_stack, |
| 18508 | is_async_call_builtin, impl_fn); | 19506 | is_async_call_builtin, impl_fn); |
| 18509 | if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value->type)) | 19507 | if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value->type)) |
| 18510 | return ira->codegen->invalid_instruction; | 19508 | return ira->codegen->invalid_inst_gen; |
| 18511 | | 19509 | |
| 18512 | size_t impl_param_count = impl_fn_type_id->param_count; | 19510 | size_t impl_param_count = impl_fn_type_id->param_count; |
| 18513 | if (modifier == CallModifierAsync) { | 19511 | if (modifier == CallModifierAsync) { |
| 18514 | IrInstruction *result = ir_analyze_async_call(ira, source_instr, impl_fn, impl_fn->type_entry, | 19512 | IrInstGen *result = ir_analyze_async_call(ira, source_instr, impl_fn, impl_fn->type_entry, |
| 18515 | nullptr, casted_args, impl_param_count, casted_new_stack, is_async_call_builtin, ret_ptr, | 19513 | nullptr, casted_args, impl_param_count, casted_new_stack, is_async_call_builtin, ret_ptr, |
| 18516 | call_result_loc); | 19514 | call_result_loc); |
| 18517 | return ir_finish_anal(ira, result); | 19515 | return ir_finish_anal(ira, result); |
| 18518 | } | 19516 | } |
| 18519 | | 19517 | |
| 18520 | IrInstruction *result_loc; | 19518 | IrInstGen *result_loc; |
| 18521 | if (handle_is_ptr(impl_fn_type_id->return_type)) { | 19519 | if (handle_is_ptr(impl_fn_type_id->return_type)) { |
| 18522 | result_loc = ir_resolve_result(ira, source_instr, call_result_loc, | 19520 | result_loc = ir_resolve_result(ira, source_instr, call_result_loc, |
| 18523 | impl_fn_type_id->return_type, nullptr, true, true, false); | 19521 | impl_fn_type_id->return_type, nullptr, true, true, false); |
| 18524 | if (result_loc != nullptr) { | 19522 | if (result_loc != nullptr) { |
| 18525 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { | 19523 | if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) { |
| 18526 | return result_loc; | 19524 | return result_loc; |
| 18527 | } | 19525 | } |
| 18528 | ZigType *res_child_type = result_loc->value->type->data.pointer.child_type; | 19526 | ZigType *res_child_type = result_loc->value->type->data.pointer.child_type; |
| ... | @@ -18538,7 +19536,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18538,7 +19536,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18538 | result_loc = get_async_call_result_loc(ira, source_instr, impl_fn_type_id->return_type, | 19536 | result_loc = get_async_call_result_loc(ira, source_instr, impl_fn_type_id->return_type, |
| 18539 | is_async_call_builtin, args_ptr, args_len, ret_ptr); | 19537 | is_async_call_builtin, args_ptr, args_len, ret_ptr); |
| 18540 | if (result_loc != nullptr && type_is_invalid(result_loc->value->type)) | 19538 | if (result_loc != nullptr && type_is_invalid(result_loc->value->type)) |
| 18541 | return ira->codegen->invalid_instruction; | 19539 | return ira->codegen->invalid_inst_gen; |
| 18542 | } else { | 19540 | } else { |
| 18543 | result_loc = nullptr; | 19541 | result_loc = nullptr; |
| 18544 | } | 19542 | } |
| ... | @@ -18547,11 +19545,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18547,11 +19545,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18547 | parent_fn_entry->inferred_async_node == nullptr && | 19545 | parent_fn_entry->inferred_async_node == nullptr && |
| 18548 | modifier != CallModifierNoAsync) | 19546 | modifier != CallModifierNoAsync) |
| 18549 | { | 19547 | { |
| 18550 | parent_fn_entry->inferred_async_node = fn_ref->source_node; | 19548 | parent_fn_entry->inferred_async_node = fn_ref->base.source_node; |
| 18551 | parent_fn_entry->inferred_async_fn = impl_fn; | 19549 | parent_fn_entry->inferred_async_fn = impl_fn; |
| 18552 | } | 19550 | } |
| 18553 | | 19551 | |
| 18554 | IrInstructionCallGen *new_call_instruction = ir_build_call_gen(ira, source_instr, | 19552 | IrInstGenCall *new_call_instruction = ir_build_call_gen(ira, source_instr, |
| 18555 | impl_fn, nullptr, impl_param_count, casted_args, modifier, casted_new_stack, | 19553 | impl_fn, nullptr, impl_param_count, casted_args, modifier, casted_new_stack, |
| 18556 | is_async_call_builtin, result_loc, impl_fn_type_id->return_type); | 19554 | is_async_call_builtin, result_loc, impl_fn_type_id->return_type); |
| 18557 | | 19555 | |
| ... | @@ -18562,7 +19560,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18562,7 +19560,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18562 | return ir_finish_anal(ira, &new_call_instruction->base); | 19560 | return ir_finish_anal(ira, &new_call_instruction->base); |
| 18563 | } | 19561 | } |
| 18564 | | 19562 | |
| 18565 | ZigFn *parent_fn_entry = exec_fn_entry(ira->new_irb.exec); | 19563 | ZigFn *parent_fn_entry = ira->new_irb.exec->fn_entry; |
| 18566 | assert(fn_type_id->return_type != nullptr); | 19564 | assert(fn_type_id->return_type != nullptr); |
| 18567 | assert(parent_fn_entry != nullptr); | 19565 | assert(parent_fn_entry != nullptr); |
| 18568 | if (fn_type_can_fail(fn_type_id)) { | 19566 | if (fn_type_can_fail(fn_type_id)) { |
| ... | @@ -18570,46 +19568,46 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18570,46 +19568,46 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18570 | } | 19568 | } |
| 18571 | | 19569 | |
| 18572 | | 19570 | |
| 18573 | IrInstruction **casted_args = allocate<IrInstruction *>(call_param_count); | 19571 | IrInstGen **casted_args = allocate<IrInstGen *>(call_param_count); |
| 18574 | size_t next_arg_index = 0; | 19572 | size_t next_arg_index = 0; |
| 18575 | if (first_arg_ptr) { | 19573 | if (first_arg_ptr) { |
| 18576 | assert(first_arg_ptr->value->type->id == ZigTypeIdPointer); | 19574 | assert(first_arg_ptr->value->type->id == ZigTypeIdPointer); |
| 18577 | | 19575 | |
| 18578 | ZigType *param_type = fn_type_id->param_info[next_arg_index].type; | 19576 | ZigType *param_type = fn_type_id->param_info[next_arg_index].type; |
| 18579 | if (type_is_invalid(param_type)) | 19577 | if (type_is_invalid(param_type)) |
| 18580 | return ira->codegen->invalid_instruction; | 19578 | return ira->codegen->invalid_inst_gen; |
| 18581 | | 19579 | |
| 18582 | IrInstruction *first_arg; | 19580 | IrInstGen *first_arg; |
| 18583 | if (param_type->id == ZigTypeIdPointer && | 19581 | if (param_type->id == ZigTypeIdPointer && |
| 18584 | handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) | 19582 | handle_is_ptr(first_arg_ptr->value->type->data.pointer.child_type)) |
| 18585 | { | 19583 | { |
| 18586 | first_arg = first_arg_ptr; | 19584 | first_arg = first_arg_ptr; |
| 18587 | } else { | 19585 | } else { |
| 18588 | first_arg = ir_get_deref(ira, first_arg_ptr, first_arg_ptr, nullptr); | 19586 | first_arg = ir_get_deref(ira, &first_arg_ptr->base, first_arg_ptr, nullptr); |
| 18589 | if (type_is_invalid(first_arg->value->type)) | 19587 | if (type_is_invalid(first_arg->value->type)) |
| 18590 | return ira->codegen->invalid_instruction; | 19588 | return ira->codegen->invalid_inst_gen; |
| 18591 | } | 19589 | } |
| 18592 | | 19590 | |
| 18593 | IrInstruction *casted_arg = ir_implicit_cast(ira, first_arg, param_type); | 19591 | IrInstGen *casted_arg = ir_implicit_cast(ira, first_arg, param_type); |
| 18594 | if (type_is_invalid(casted_arg->value->type)) | 19592 | if (type_is_invalid(casted_arg->value->type)) |
| 18595 | return ira->codegen->invalid_instruction; | 19593 | return ira->codegen->invalid_inst_gen; |
| 18596 | | 19594 | |
| 18597 | casted_args[next_arg_index] = casted_arg; | 19595 | casted_args[next_arg_index] = casted_arg; |
| 18598 | next_arg_index += 1; | 19596 | next_arg_index += 1; |
| 18599 | } | 19597 | } |
| 18600 | for (size_t call_i = 0; call_i < args_len; call_i += 1) { | 19598 | for (size_t call_i = 0; call_i < args_len; call_i += 1) { |
| 18601 | IrInstruction *old_arg = args_ptr[call_i]; | 19599 | IrInstGen *old_arg = args_ptr[call_i]; |
| 18602 | if (type_is_invalid(old_arg->value->type)) | 19600 | if (type_is_invalid(old_arg->value->type)) |
| 18603 | return ira->codegen->invalid_instruction; | 19601 | return ira->codegen->invalid_inst_gen; |
| 18604 | | 19602 | |
| 18605 | IrInstruction *casted_arg; | 19603 | IrInstGen *casted_arg; |
| 18606 | if (next_arg_index < src_param_count) { | 19604 | if (next_arg_index < src_param_count) { |
| 18607 | ZigType *param_type = fn_type_id->param_info[next_arg_index].type; | 19605 | ZigType *param_type = fn_type_id->param_info[next_arg_index].type; |
| 18608 | if (type_is_invalid(param_type)) | 19606 | if (type_is_invalid(param_type)) |
| 18609 | return ira->codegen->invalid_instruction; | 19607 | return ira->codegen->invalid_inst_gen; |
| 18610 | casted_arg = ir_implicit_cast(ira, old_arg, param_type); | 19608 | casted_arg = ir_implicit_cast(ira, old_arg, param_type); |
| 18611 | if (type_is_invalid(casted_arg->value->type)) | 19609 | if (type_is_invalid(casted_arg->value->type)) |
| 18612 | return ira->codegen->invalid_instruction; | 19610 | return ira->codegen->invalid_inst_gen; |
| 18613 | } else { | 19611 | } else { |
| 18614 | casted_arg = old_arg; | 19612 | casted_arg = old_arg; |
| 18615 | } | 19613 | } |
| ... | @@ -18622,21 +19620,21 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18622,21 +19620,21 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18622 | | 19620 | |
| 18623 | ZigType *return_type = fn_type_id->return_type; | 19621 | ZigType *return_type = fn_type_id->return_type; |
| 18624 | if (type_is_invalid(return_type)) | 19622 | if (type_is_invalid(return_type)) |
| 18625 | return ira->codegen->invalid_instruction; | 19623 | return ira->codegen->invalid_inst_gen; |
| 18626 | | 19624 | |
| 18627 | if (fn_entry != nullptr && fn_entry->fn_inline == FnInlineAlways && modifier == CallModifierNeverInline) { | 19625 | if (fn_entry != nullptr && fn_entry->fn_inline == FnInlineAlways && modifier == CallModifierNeverInline) { |
| 18628 | ir_add_error(ira, source_instr, | 19626 | ir_add_error(ira, source_instr, |
| 18629 | buf_sprintf("no-inline call of inline function")); | 19627 | buf_sprintf("no-inline call of inline function")); |
| 18630 | return ira->codegen->invalid_instruction; | 19628 | return ira->codegen->invalid_inst_gen; |
| 18631 | } | 19629 | } |
| 18632 | | 19630 | |
| 18633 | IrInstruction *casted_new_stack = analyze_casted_new_stack(ira, source_instr, new_stack, | 19631 | IrInstGen *casted_new_stack = analyze_casted_new_stack(ira, source_instr, new_stack, |
| 18634 | is_async_call_builtin, fn_entry); | 19632 | is_async_call_builtin, fn_entry); |
| 18635 | if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value->type)) | 19633 | if (casted_new_stack != nullptr && type_is_invalid(casted_new_stack->value->type)) |
| 18636 | return ira->codegen->invalid_instruction; | 19634 | return ira->codegen->invalid_inst_gen; |
| 18637 | | 19635 | |
| 18638 | if (modifier == CallModifierAsync) { | 19636 | if (modifier == CallModifierAsync) { |
| 18639 | IrInstruction *result = ir_analyze_async_call(ira, source_instr, fn_entry, fn_type, fn_ref, | 19637 | IrInstGen *result = ir_analyze_async_call(ira, source_instr, fn_entry, fn_type, fn_ref, |
| 18640 | casted_args, call_param_count, casted_new_stack, is_async_call_builtin, ret_ptr, call_result_loc); | 19638 | casted_args, call_param_count, casted_new_stack, is_async_call_builtin, ret_ptr, call_result_loc); |
| 18641 | return ir_finish_anal(ira, result); | 19639 | return ir_finish_anal(ira, result); |
| 18642 | } | 19640 | } |
| ... | @@ -18645,16 +19643,16 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18645,16 +19643,16 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18645 | parent_fn_entry->inferred_async_node == nullptr && | 19643 | parent_fn_entry->inferred_async_node == nullptr && |
| 18646 | modifier != CallModifierNoAsync) | 19644 | modifier != CallModifierNoAsync) |
| 18647 | { | 19645 | { |
| 18648 | parent_fn_entry->inferred_async_node = fn_ref->source_node; | 19646 | parent_fn_entry->inferred_async_node = fn_ref->base.source_node; |
| 18649 | parent_fn_entry->inferred_async_fn = fn_entry; | 19647 | parent_fn_entry->inferred_async_fn = fn_entry; |
| 18650 | } | 19648 | } |
| 18651 | | 19649 | |
| 18652 | IrInstruction *result_loc; | 19650 | IrInstGen *result_loc; |
| 18653 | if (handle_is_ptr(return_type)) { | 19651 | if (handle_is_ptr(return_type)) { |
| 18654 | result_loc = ir_resolve_result(ira, source_instr, call_result_loc, | 19652 | result_loc = ir_resolve_result(ira, source_instr, call_result_loc, |
| 18655 | return_type, nullptr, true, true, false); | 19653 | return_type, nullptr, true, true, false); |
| 18656 | if (result_loc != nullptr) { | 19654 | if (result_loc != nullptr) { |
| 18657 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { | 19655 | if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) { |
| 18658 | return result_loc; | 19656 | return result_loc; |
| 18659 | } | 19657 | } |
| 18660 | ZigType *res_child_type = result_loc->value->type->data.pointer.child_type; | 19658 | ZigType *res_child_type = result_loc->value->type->data.pointer.child_type; |
| ... | @@ -18670,12 +19668,12 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18670,12 +19668,12 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18670 | result_loc = get_async_call_result_loc(ira, source_instr, return_type, is_async_call_builtin, | 19668 | result_loc = get_async_call_result_loc(ira, source_instr, return_type, is_async_call_builtin, |
| 18671 | args_ptr, args_len, ret_ptr); | 19669 | args_ptr, args_len, ret_ptr); |
| 18672 | if (result_loc != nullptr && type_is_invalid(result_loc->value->type)) | 19670 | if (result_loc != nullptr && type_is_invalid(result_loc->value->type)) |
| 18673 | return ira->codegen->invalid_instruction; | 19671 | return ira->codegen->invalid_inst_gen; |
| 18674 | } else { | 19672 | } else { |
| 18675 | result_loc = nullptr; | 19673 | result_loc = nullptr; |
| 18676 | } | 19674 | } |
| 18677 | | 19675 | |
| 18678 | IrInstructionCallGen *new_call_instruction = ir_build_call_gen(ira, source_instr, fn_entry, fn_ref, | 19676 | IrInstGenCall *new_call_instruction = ir_build_call_gen(ira, source_instr, fn_entry, fn_ref, |
| 18679 | call_param_count, casted_args, modifier, casted_new_stack, | 19677 | call_param_count, casted_args, modifier, casted_new_stack, |
| 18680 | is_async_call_builtin, result_loc, return_type); | 19678 | is_async_call_builtin, result_loc, return_type); |
| 18681 | if (get_scope_typeof(source_instr->scope) == nullptr) { | 19679 | if (get_scope_typeof(source_instr->scope) == nullptr) { |
| ... | @@ -18684,62 +19682,62 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -18684,62 +19682,62 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18684 | return ir_finish_anal(ira, &new_call_instruction->base); | 19682 | return ir_finish_anal(ira, &new_call_instruction->base); |
| 18685 | } | 19683 | } |
| 18686 | | 19684 | |
| 18687 | static IrInstruction *ir_analyze_fn_call_src(IrAnalyze *ira, IrInstructionCallSrc *call_instruction, | 19685 | static IrInstGen *ir_analyze_fn_call_src(IrAnalyze *ira, IrInstSrcCall *call_instruction, |
| 18688 | ZigFn *fn_entry, ZigType *fn_type, IrInstruction *fn_ref, | 19686 | ZigFn *fn_entry, ZigType *fn_type, IrInstGen *fn_ref, |
| 18689 | IrInstruction *first_arg_ptr, CallModifier modifier) | 19687 | IrInstGen *first_arg_ptr, CallModifier modifier) |
| 18690 | { | 19688 | { |
| 18691 | IrInstruction *new_stack = nullptr; | 19689 | IrInstGen *new_stack = nullptr; |
| 18692 | if (call_instruction->new_stack) { | 19690 | if (call_instruction->new_stack) { |
| 18693 | new_stack = call_instruction->new_stack->child; | 19691 | new_stack = call_instruction->new_stack->child; |
| 18694 | if (type_is_invalid(new_stack->value->type)) | 19692 | if (type_is_invalid(new_stack->value->type)) |
| 18695 | return ira->codegen->invalid_instruction; | 19693 | return ira->codegen->invalid_inst_gen; |
| 18696 | } | 19694 | } |
| 18697 | IrInstruction **args_ptr = allocate<IrInstruction *>(call_instruction->arg_count, "IrInstruction *"); | 19695 | IrInstGen **args_ptr = allocate<IrInstGen *>(call_instruction->arg_count, "IrInstGen *"); |
| 18698 | for (size_t i = 0; i < call_instruction->arg_count; i += 1) { | 19696 | for (size_t i = 0; i < call_instruction->arg_count; i += 1) { |
| 18699 | args_ptr[i] = call_instruction->args[i]->child; | 19697 | args_ptr[i] = call_instruction->args[i]->child; |
| 18700 | if (type_is_invalid(args_ptr[i]->value->type)) | 19698 | if (type_is_invalid(args_ptr[i]->value->type)) |
| 18701 | return ira->codegen->invalid_instruction; | 19699 | return ira->codegen->invalid_inst_gen; |
| 18702 | } | 19700 | } |
| 18703 | IrInstruction *ret_ptr = nullptr; | 19701 | IrInstGen *ret_ptr = nullptr; |
| 18704 | if (call_instruction->ret_ptr != nullptr) { | 19702 | if (call_instruction->ret_ptr != nullptr) { |
| 18705 | ret_ptr = call_instruction->ret_ptr->child; | 19703 | ret_ptr = call_instruction->ret_ptr->child; |
| 18706 | if (type_is_invalid(ret_ptr->value->type)) | 19704 | if (type_is_invalid(ret_ptr->value->type)) |
| 18707 | return ira->codegen->invalid_instruction; | 19705 | return ira->codegen->invalid_inst_gen; |
| 18708 | } | 19706 | } |
| 18709 | IrInstruction *result = ir_analyze_fn_call(ira, &call_instruction->base, fn_entry, fn_type, fn_ref, | 19707 | IrInstGen *result = ir_analyze_fn_call(ira, &call_instruction->base.base, fn_entry, fn_type, fn_ref, |
| 18710 | first_arg_ptr, modifier, new_stack, call_instruction->is_async_call_builtin, | 19708 | first_arg_ptr, modifier, new_stack, call_instruction->is_async_call_builtin, |
| 18711 | args_ptr, call_instruction->arg_count, ret_ptr, call_instruction->result_loc); | 19709 | args_ptr, call_instruction->arg_count, ret_ptr, call_instruction->result_loc); |
| 18712 | deallocate(args_ptr, call_instruction->arg_count, "IrInstruction *"); | 19710 | deallocate(args_ptr, call_instruction->arg_count, "IrInstGen *"); |
| 18713 | return result; | 19711 | return result; |
| 18714 | } | 19712 | } |
| 18715 | | 19713 | |
| 18716 | static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *source_instr, | 19714 | static IrInstGen *ir_analyze_call_extra(IrAnalyze *ira, IrInst* source_instr, |
| 18717 | IrInstruction *pass1_options, IrInstruction *pass1_fn_ref, IrInstruction **args_ptr, size_t args_len, | 19715 | IrInstSrc *pass1_options, IrInstSrc *pass1_fn_ref, IrInstGen **args_ptr, size_t args_len, |
| 18718 | ResultLoc *result_loc) | 19716 | ResultLoc *result_loc) |
| 18719 | { | 19717 | { |
| 18720 | IrInstruction *options = pass1_options->child; | 19718 | IrInstGen *options = pass1_options->child; |
| 18721 | if (type_is_invalid(options->value->type)) | 19719 | if (type_is_invalid(options->value->type)) |
| 18722 | return ira->codegen->invalid_instruction; | 19720 | return ira->codegen->invalid_inst_gen; |
| 18723 | | 19721 | |
| 18724 | IrInstruction *fn_ref = pass1_fn_ref->child; | 19722 | IrInstGen *fn_ref = pass1_fn_ref->child; |
| 18725 | if (type_is_invalid(fn_ref->value->type)) | 19723 | if (type_is_invalid(fn_ref->value->type)) |
| 18726 | return ira->codegen->invalid_instruction; | 19724 | return ira->codegen->invalid_inst_gen; |
| 18727 | | 19725 | |
| 18728 | TypeStructField *modifier_field = find_struct_type_field(options->value->type, buf_create_from_str("modifier")); | 19726 | TypeStructField *modifier_field = find_struct_type_field(options->value->type, buf_create_from_str("modifier")); |
| 18729 | ir_assert(modifier_field != nullptr, source_instr); | 19727 | ir_assert(modifier_field != nullptr, source_instr); |
| 18730 | IrInstruction *modifier_inst = ir_analyze_struct_value_field_value(ira, source_instr, options, modifier_field); | 19728 | IrInstGen *modifier_inst = ir_analyze_struct_value_field_value(ira, source_instr, options, modifier_field); |
| 18731 | ZigValue *modifier_val = ir_resolve_const(ira, modifier_inst, UndefBad); | 19729 | ZigValue *modifier_val = ir_resolve_const(ira, modifier_inst, UndefBad); |
| 18732 | if (modifier_val == nullptr) | 19730 | if (modifier_val == nullptr) |
| 18733 | return ira->codegen->invalid_instruction; | 19731 | return ira->codegen->invalid_inst_gen; |
| 18734 | CallModifier modifier = (CallModifier)bigint_as_u32(&modifier_val->data.x_enum_tag); | 19732 | CallModifier modifier = (CallModifier)bigint_as_u32(&modifier_val->data.x_enum_tag); |
| 18735 | | 19733 | |
| 18736 | if (ir_should_inline(ira->new_irb.exec, source_instr->scope)) { | 19734 | if (ir_should_inline(ira->old_irb.exec, source_instr->scope)) { |
| 18737 | switch (modifier) { | 19735 | switch (modifier) { |
| 18738 | case CallModifierBuiltin: | 19736 | case CallModifierBuiltin: |
| 18739 | zig_unreachable(); | 19737 | zig_unreachable(); |
| 18740 | case CallModifierAsync: | 19738 | case CallModifierAsync: |
| 18741 | ir_add_error(ira, source_instr, buf_sprintf("TODO: comptime @call with async modifier")); | 19739 | ir_add_error(ira, source_instr, buf_sprintf("TODO: comptime @call with async modifier")); |
| 18742 | return ira->codegen->invalid_instruction; | 19740 | return ira->codegen->invalid_inst_gen; |
| 18743 | case CallModifierCompileTime: | 19741 | case CallModifierCompileTime: |
| 18744 | case CallModifierNone: | 19742 | case CallModifierNone: |
| 18745 | case CallModifierAlwaysInline: | 19743 | case CallModifierAlwaysInline: |
| ... | @@ -18750,15 +19748,15 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -18750,15 +19748,15 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc |
| 18750 | case CallModifierNeverInline: | 19748 | case CallModifierNeverInline: |
| 18751 | ir_add_error(ira, source_instr, | 19749 | ir_add_error(ira, source_instr, |
| 18752 | buf_sprintf("unable to perform 'never_inline' call at compile-time")); | 19750 | buf_sprintf("unable to perform 'never_inline' call at compile-time")); |
| 18753 | return ira->codegen->invalid_instruction; | 19751 | return ira->codegen->invalid_inst_gen; |
| 18754 | case CallModifierNeverTail: | 19752 | case CallModifierNeverTail: |
| 18755 | ir_add_error(ira, source_instr, | 19753 | ir_add_error(ira, source_instr, |
| 18756 | buf_sprintf("unable to perform 'never_tail' call at compile-time")); | 19754 | buf_sprintf("unable to perform 'never_tail' call at compile-time")); |
| 18757 | return ira->codegen->invalid_instruction; | 19755 | return ira->codegen->invalid_inst_gen; |
| 18758 | } | 19756 | } |
| 18759 | } | 19757 | } |
| 18760 | | 19758 | |
| 18761 | IrInstruction *first_arg_ptr = nullptr; | 19759 | IrInstGen *first_arg_ptr = nullptr; |
| 18762 | ZigFn *fn = nullptr; | 19760 | ZigFn *fn = nullptr; |
| 18763 | if (instr_is_comptime(fn_ref)) { | 19761 | if (instr_is_comptime(fn_ref)) { |
| 18764 | if (fn_ref->value->type->id == ZigTypeIdBoundFn) { | 19762 | if (fn_ref->value->type->id == ZigTypeIdBoundFn) { |
| ... | @@ -18766,7 +19764,7 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -18766,7 +19764,7 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc |
| 18766 | fn = fn_ref->value->data.x_bound_fn.fn; | 19764 | fn = fn_ref->value->data.x_bound_fn.fn; |
| 18767 | first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; | 19765 | first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; |
| 18768 | if (type_is_invalid(first_arg_ptr->value->type)) | 19766 | if (type_is_invalid(first_arg_ptr->value->type)) |
| 18769 | return ira->codegen->invalid_instruction; | 19767 | return ira->codegen->invalid_inst_gen; |
| 18770 | } else { | 19768 | } else { |
| 18771 | fn = ir_resolve_fn(ira, fn_ref); | 19769 | fn = ir_resolve_fn(ira, fn_ref); |
| 18772 | } | 19770 | } |
| ... | @@ -18778,9 +19776,9 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -18778,9 +19776,9 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc |
| 18778 | case CallModifierAlwaysInline: | 19776 | case CallModifierAlwaysInline: |
| 18779 | case CallModifierAsync: | 19777 | case CallModifierAsync: |
| 18780 | if (fn == nullptr) { | 19778 | if (fn == nullptr) { |
| 18781 | ir_add_error(ira, modifier_inst, | 19779 | ir_add_error(ira, &modifier_inst->base, |
| 18782 | buf_sprintf("the specified modifier requires a comptime-known function")); | 19780 | buf_sprintf("the specified modifier requires a comptime-known function")); |
| 18783 | return ira->codegen->invalid_instruction; | 19781 | return ira->codegen->invalid_inst_gen; |
| 18784 | } | 19782 | } |
| 18785 | default: | 19783 | default: |
| 18786 | break; | 19784 | break; |
| ... | @@ -18790,93 +19788,93 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -18790,93 +19788,93 @@ static IrInstruction *ir_analyze_call_extra(IrAnalyze *ira, IrInstruction *sourc |
| 18790 | | 19788 | |
| 18791 | TypeStructField *stack_field = find_struct_type_field(options->value->type, buf_create_from_str("stack")); | 19789 | TypeStructField *stack_field = find_struct_type_field(options->value->type, buf_create_from_str("stack")); |
| 18792 | ir_assert(stack_field != nullptr, source_instr); | 19790 | ir_assert(stack_field != nullptr, source_instr); |
| 18793 | IrInstruction *opt_stack = ir_analyze_struct_value_field_value(ira, source_instr, options, stack_field); | 19791 | IrInstGen *opt_stack = ir_analyze_struct_value_field_value(ira, source_instr, options, stack_field); |
| 18794 | if (type_is_invalid(opt_stack->value->type)) | 19792 | if (type_is_invalid(opt_stack->value->type)) |
| 18795 | return ira->codegen->invalid_instruction; | 19793 | return ira->codegen->invalid_inst_gen; |
| 18796 | | 19794 | |
| 18797 | IrInstruction *stack_is_non_null_inst = ir_analyze_test_non_null(ira, source_instr, opt_stack); | 19795 | IrInstGen *stack_is_non_null_inst = ir_analyze_test_non_null(ira, source_instr, opt_stack); |
| 18798 | bool stack_is_non_null; | 19796 | bool stack_is_non_null; |
| 18799 | if (!ir_resolve_bool(ira, stack_is_non_null_inst, &stack_is_non_null)) | 19797 | if (!ir_resolve_bool(ira, stack_is_non_null_inst, &stack_is_non_null)) |
| 18800 | return ira->codegen->invalid_instruction; | 19798 | return ira->codegen->invalid_inst_gen; |
| 18801 | | 19799 | |
| 18802 | IrInstruction *stack = nullptr; | 19800 | IrInstGen *stack = nullptr; |
| 18803 | if (stack_is_non_null) { | 19801 | if (stack_is_non_null) { |
| 18804 | stack = ir_analyze_optional_value_payload_value(ira, source_instr, opt_stack, false); | 19802 | stack = ir_analyze_optional_value_payload_value(ira, source_instr, opt_stack, false); |
| 18805 | if (type_is_invalid(stack->value->type)) | 19803 | if (type_is_invalid(stack->value->type)) |
| 18806 | return ira->codegen->invalid_instruction; | 19804 | return ira->codegen->invalid_inst_gen; |
| 18807 | } | 19805 | } |
| 18808 | | 19806 | |
| 18809 | return ir_analyze_fn_call(ira, source_instr, fn, fn_type, fn_ref, first_arg_ptr, | 19807 | return ir_analyze_fn_call(ira, source_instr, fn, fn_type, fn_ref, first_arg_ptr, |
| 18810 | modifier, stack, false, args_ptr, args_len, nullptr, result_loc); | 19808 | modifier, stack, false, args_ptr, args_len, nullptr, result_loc); |
| 18811 | } | 19809 | } |
| 18812 | | 19810 | |
| 18813 | static IrInstruction *ir_analyze_instruction_call_extra(IrAnalyze *ira, IrInstructionCallExtra *instruction) { | 19811 | static IrInstGen *ir_analyze_instruction_call_extra(IrAnalyze *ira, IrInstSrcCallExtra *instruction) { |
| 18814 | IrInstruction *args = instruction->args->child; | 19812 | IrInstGen *args = instruction->args->child; |
| 18815 | ZigType *args_type = args->value->type; | 19813 | ZigType *args_type = args->value->type; |
| 18816 | if (type_is_invalid(args_type)) | 19814 | if (type_is_invalid(args_type)) |
| 18817 | return ira->codegen->invalid_instruction; | 19815 | return ira->codegen->invalid_inst_gen; |
| 18818 | | 19816 | |
| 18819 | if (args_type->id != ZigTypeIdStruct) { | 19817 | if (args_type->id != ZigTypeIdStruct) { |
| 18820 | ir_add_error(ira, args, | 19818 | ir_add_error(ira, &args->base, |
| 18821 | buf_sprintf("expected tuple or struct, found '%s'", buf_ptr(&args_type->name))); | 19819 | buf_sprintf("expected tuple or struct, found '%s'", buf_ptr(&args_type->name))); |
| 18822 | return ira->codegen->invalid_instruction; | 19820 | return ira->codegen->invalid_inst_gen; |
| 18823 | } | 19821 | } |
| 18824 | | 19822 | |
| 18825 | IrInstruction **args_ptr = nullptr; | 19823 | IrInstGen **args_ptr = nullptr; |
| 18826 | size_t args_len = 0; | 19824 | size_t args_len = 0; |
| 18827 | | 19825 | |
| 18828 | if (is_tuple(args_type)) { | 19826 | if (is_tuple(args_type)) { |
| 18829 | args_len = args_type->data.structure.src_field_count; | 19827 | args_len = args_type->data.structure.src_field_count; |
| 18830 | args_ptr = allocate<IrInstruction *>(args_len, "IrInstruction *"); | 19828 | args_ptr = allocate<IrInstGen *>(args_len, "IrInstGen *"); |
| 18831 | for (size_t i = 0; i < args_len; i += 1) { | 19829 | for (size_t i = 0; i < args_len; i += 1) { |
| 18832 | TypeStructField *arg_field = args_type->data.structure.fields[i]; | 19830 | TypeStructField *arg_field = args_type->data.structure.fields[i]; |
| 18833 | args_ptr[i] = ir_analyze_struct_value_field_value(ira, &instruction->base, args, arg_field); | 19831 | args_ptr[i] = ir_analyze_struct_value_field_value(ira, &instruction->base.base, args, arg_field); |
| 18834 | if (type_is_invalid(args_ptr[i]->value->type)) | 19832 | if (type_is_invalid(args_ptr[i]->value->type)) |
| 18835 | return ira->codegen->invalid_instruction; | 19833 | return ira->codegen->invalid_inst_gen; |
| 18836 | } | 19834 | } |
| 18837 | } else { | 19835 | } else { |
| 18838 | ir_add_error(ira, args, buf_sprintf("TODO: struct args")); | 19836 | ir_add_error(ira, &args->base, buf_sprintf("TODO: struct args")); |
| 18839 | return ira->codegen->invalid_instruction; | 19837 | return ira->codegen->invalid_inst_gen; |
| 18840 | } | 19838 | } |
| 18841 | IrInstruction *result = ir_analyze_call_extra(ira, &instruction->base, instruction->options, | 19839 | IrInstGen *result = ir_analyze_call_extra(ira, &instruction->base.base, instruction->options, |
| 18842 | instruction->fn_ref, args_ptr, args_len, instruction->result_loc); | 19840 | instruction->fn_ref, args_ptr, args_len, instruction->result_loc); |
| 18843 | deallocate(args_ptr, args_len, "IrInstruction *"); | 19841 | deallocate(args_ptr, args_len, "IrInstGen *"); |
| 18844 | return result; | 19842 | return result; |
| 18845 | } | 19843 | } |
| 18846 | | 19844 | |
| 18847 | static IrInstruction *ir_analyze_instruction_call_args(IrAnalyze *ira, IrInstructionCallSrcArgs *instruction) { | 19845 | static IrInstGen *ir_analyze_instruction_call_args(IrAnalyze *ira, IrInstSrcCallArgs *instruction) { |
| 18848 | IrInstruction **args_ptr = allocate<IrInstruction *>(instruction->args_len, "IrInstruction *"); | 19846 | IrInstGen **args_ptr = allocate<IrInstGen *>(instruction->args_len, "IrInstGen *"); |
| 18849 | for (size_t i = 0; i < instruction->args_len; i += 1) { | 19847 | for (size_t i = 0; i < instruction->args_len; i += 1) { |
| 18850 | args_ptr[i] = instruction->args_ptr[i]->child; | 19848 | args_ptr[i] = instruction->args_ptr[i]->child; |
| 18851 | if (type_is_invalid(args_ptr[i]->value->type)) | 19849 | if (type_is_invalid(args_ptr[i]->value->type)) |
| 18852 | return ira->codegen->invalid_instruction; | 19850 | return ira->codegen->invalid_inst_gen; |
| 18853 | } | 19851 | } |
| 18854 | | 19852 | |
| 18855 | IrInstruction *result = ir_analyze_call_extra(ira, &instruction->base, instruction->options, | 19853 | IrInstGen *result = ir_analyze_call_extra(ira, &instruction->base.base, instruction->options, |
| 18856 | instruction->fn_ref, args_ptr, instruction->args_len, instruction->result_loc); | 19854 | instruction->fn_ref, args_ptr, instruction->args_len, instruction->result_loc); |
| 18857 | deallocate(args_ptr, instruction->args_len, "IrInstruction *"); | 19855 | deallocate(args_ptr, instruction->args_len, "IrInstGen *"); |
| 18858 | return result; | 19856 | return result; |
| 18859 | } | 19857 | } |
| 18860 | | 19858 | |
| 18861 | static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionCallSrc *call_instruction) { | 19859 | static IrInstGen *ir_analyze_instruction_call(IrAnalyze *ira, IrInstSrcCall *call_instruction) { |
| 18862 | IrInstruction *fn_ref = call_instruction->fn_ref->child; | 19860 | IrInstGen *fn_ref = call_instruction->fn_ref->child; |
| 18863 | if (type_is_invalid(fn_ref->value->type)) | 19861 | if (type_is_invalid(fn_ref->value->type)) |
| 18864 | return ira->codegen->invalid_instruction; | 19862 | return ira->codegen->invalid_inst_gen; |
| 18865 | | 19863 | |
| 18866 | bool is_comptime = (call_instruction->modifier == CallModifierCompileTime) || | 19864 | bool is_comptime = (call_instruction->modifier == CallModifierCompileTime) || |
| 18867 | ir_should_inline(ira->new_irb.exec, call_instruction->base.scope); | 19865 | ir_should_inline(ira->old_irb.exec, call_instruction->base.base.scope); |
| 18868 | CallModifier modifier = is_comptime ? CallModifierCompileTime : call_instruction->modifier; | 19866 | CallModifier modifier = is_comptime ? CallModifierCompileTime : call_instruction->modifier; |
| 18869 | | 19867 | |
| 18870 | if (is_comptime || instr_is_comptime(fn_ref)) { | 19868 | if (is_comptime || instr_is_comptime(fn_ref)) { |
| 18871 | if (fn_ref->value->type->id == ZigTypeIdMetaType) { | 19869 | if (fn_ref->value->type->id == ZigTypeIdMetaType) { |
| 18872 | ZigType *ty = ir_resolve_type(ira, fn_ref); | 19870 | ZigType *ty = ir_resolve_type(ira, fn_ref); |
| 18873 | if (ty == nullptr) | 19871 | if (ty == nullptr) |
| 18874 | return ira->codegen->invalid_instruction; | 19872 | return ira->codegen->invalid_inst_gen; |
| 18875 | ErrorMsg *msg = ir_add_error_node(ira, fn_ref->source_node, | 19873 | ErrorMsg *msg = ir_add_error(ira, &fn_ref->base, |
| 18876 | buf_sprintf("type '%s' not a function", buf_ptr(&ty->name))); | 19874 | buf_sprintf("type '%s' not a function", buf_ptr(&ty->name))); |
| 18877 | add_error_note(ira->codegen, msg, call_instruction->base.source_node, | 19875 | add_error_note(ira->codegen, msg, call_instruction->base.base.source_node, |
| 18878 | buf_sprintf("use @as builtin for type coercion")); | 19876 | buf_sprintf("use @as builtin for type coercion")); |
| 18879 | return ira->codegen->invalid_instruction; | 19877 | return ira->codegen->invalid_inst_gen; |
| 18880 | } else if (fn_ref->value->type->id == ZigTypeIdFn) { | 19878 | } else if (fn_ref->value->type->id == ZigTypeIdFn) { |
| 18881 | ZigFn *fn_table_entry = ir_resolve_fn(ira, fn_ref); | 19879 | ZigFn *fn_table_entry = ir_resolve_fn(ira, fn_ref); |
| 18882 | ZigType *fn_type = fn_table_entry ? fn_table_entry->type_entry : fn_ref->value->type; | 19880 | ZigType *fn_type = fn_table_entry ? fn_table_entry->type_entry : fn_ref->value->type; |
| ... | @@ -18886,14 +19884,14 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC | ... | @@ -18886,14 +19884,14 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC |
| 18886 | } else if (fn_ref->value->type->id == ZigTypeIdBoundFn) { | 19884 | } else if (fn_ref->value->type->id == ZigTypeIdBoundFn) { |
| 18887 | assert(fn_ref->value->special == ConstValSpecialStatic); | 19885 | assert(fn_ref->value->special == ConstValSpecialStatic); |
| 18888 | ZigFn *fn_table_entry = fn_ref->value->data.x_bound_fn.fn; | 19886 | ZigFn *fn_table_entry = fn_ref->value->data.x_bound_fn.fn; |
| 18889 | IrInstruction *first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; | 19887 | IrInstGen *first_arg_ptr = fn_ref->value->data.x_bound_fn.first_arg; |
| 18890 | CallModifier modifier = is_comptime ? CallModifierCompileTime : call_instruction->modifier; | 19888 | CallModifier modifier = is_comptime ? CallModifierCompileTime : call_instruction->modifier; |
| 18891 | return ir_analyze_fn_call_src(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, | 19889 | return ir_analyze_fn_call_src(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, |
| 18892 | fn_ref, first_arg_ptr, modifier); | 19890 | fn_ref, first_arg_ptr, modifier); |
| 18893 | } else { | 19891 | } else { |
| 18894 | ir_add_error_node(ira, fn_ref->source_node, | 19892 | ir_add_error(ira, &fn_ref->base, |
| 18895 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name))); | 19893 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name))); |
| 18896 | return ira->codegen->invalid_instruction; | 19894 | return ira->codegen->invalid_inst_gen; |
| 18897 | } | 19895 | } |
| 18898 | } | 19896 | } |
| 18899 | | 19897 | |
| ... | @@ -18901,9 +19899,9 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC | ... | @@ -18901,9 +19899,9 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC |
| 18901 | return ir_analyze_fn_call_src(ira, call_instruction, nullptr, fn_ref->value->type, | 19899 | return ir_analyze_fn_call_src(ira, call_instruction, nullptr, fn_ref->value->type, |
| 18902 | fn_ref, nullptr, modifier); | 19900 | fn_ref, nullptr, modifier); |
| 18903 | } else { | 19901 | } else { |
| 18904 | ir_add_error_node(ira, fn_ref->source_node, | 19902 | ir_add_error(ira, &fn_ref->base, |
| 18905 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name))); | 19903 | buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value->type->name))); |
| 18906 | return ira->codegen->invalid_instruction; | 19904 | return ira->codegen->invalid_inst_gen; |
| 18907 | } | 19905 | } |
| 18908 | } | 19906 | } |
| 18909 | | 19907 | |
| ... | @@ -18992,8 +19990,8 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source | ... | @@ -18992,8 +19990,8 @@ static Error ir_read_const_ptr(IrAnalyze *ira, CodeGen *codegen, AstNode *source |
| 18992 | zig_unreachable(); | 19990 | zig_unreachable(); |
| 18993 | } | 19991 | } |
| 18994 | | 19992 | |
| 18995 | static IrInstruction *ir_analyze_optional_type(IrAnalyze *ira, IrInstructionUnOp *instruction) { | 19993 | static IrInstGen *ir_analyze_optional_type(IrAnalyze *ira, IrInstSrcUnOp *instruction) { |
| 18996 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); | 19994 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 18997 | result->value->special = ConstValSpecialLazy; | 19995 | result->value->special = ConstValSpecialLazy; |
| 18998 | | 19996 | |
| 18999 | LazyValueOptType *lazy_opt_type = allocate<LazyValueOptType>(1, "LazyValueOptType"); | 19997 | LazyValueOptType *lazy_opt_type = allocate<LazyValueOptType>(1, "LazyValueOptType"); |
| ... | @@ -19003,12 +20001,12 @@ static IrInstruction *ir_analyze_optional_type(IrAnalyze *ira, IrInstructionUnOp | ... | @@ -19003,12 +20001,12 @@ static IrInstruction *ir_analyze_optional_type(IrAnalyze *ira, IrInstructionUnOp |
| 19003 | | 20001 | |
| 19004 | lazy_opt_type->payload_type = instruction->value->child; | 20002 | lazy_opt_type->payload_type = instruction->value->child; |
| 19005 | if (ir_resolve_type_lazy(ira, lazy_opt_type->payload_type) == nullptr) | 20003 | if (ir_resolve_type_lazy(ira, lazy_opt_type->payload_type) == nullptr) |
| 19006 | return ira->codegen->invalid_instruction; | 20004 | return ira->codegen->invalid_inst_gen; |
| 19007 | | 20005 | |
| 19008 | return result; | 20006 | return result; |
| 19009 | } | 20007 | } |
| 19010 | | 20008 | |
| 19011 | static ErrorMsg *ir_eval_negation_scalar(IrAnalyze *ira, IrInstruction *source_instr, ZigType *scalar_type, | 20009 | static ErrorMsg *ir_eval_negation_scalar(IrAnalyze *ira, IrInst* source_instr, ZigType *scalar_type, |
| 19012 | ZigValue *operand_val, ZigValue *scalar_out_val, bool is_wrap_op) | 20010 | ZigValue *operand_val, ZigValue *scalar_out_val, bool is_wrap_op) |
| 19013 | { | 20011 | { |
| 19014 | bool is_float = (scalar_type->id == ZigTypeIdFloat || scalar_type->id == ZigTypeIdComptimeFloat); | 20012 | bool is_float = (scalar_type->id == ZigTypeIdFloat || scalar_type->id == ZigTypeIdComptimeFloat); |
| ... | @@ -19043,19 +20041,19 @@ static ErrorMsg *ir_eval_negation_scalar(IrAnalyze *ira, IrInstruction *source_i | ... | @@ -19043,19 +20041,19 @@ static ErrorMsg *ir_eval_negation_scalar(IrAnalyze *ira, IrInstruction *source_i |
| 19043 | return nullptr; | 20041 | return nullptr; |
| 19044 | } | 20042 | } |
| 19045 | | 20043 | |
| 19046 | static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *instruction) { | 20044 | static IrInstGen *ir_analyze_negation(IrAnalyze *ira, IrInstSrcUnOp *instruction) { |
| 19047 | IrInstruction *value = instruction->value->child; | 20045 | IrInstGen *value = instruction->value->child; |
| 19048 | ZigType *expr_type = value->value->type; | 20046 | ZigType *expr_type = value->value->type; |
| 19049 | if (type_is_invalid(expr_type)) | 20047 | if (type_is_invalid(expr_type)) |
| 19050 | return ira->codegen->invalid_instruction; | 20048 | return ira->codegen->invalid_inst_gen; |
| 19051 | | 20049 | |
| 19052 | if (!(expr_type->id == ZigTypeIdInt || expr_type->id == ZigTypeIdComptimeInt || | 20050 | if (!(expr_type->id == ZigTypeIdInt || expr_type->id == ZigTypeIdComptimeInt || |
| 19053 | expr_type->id == ZigTypeIdFloat || expr_type->id == ZigTypeIdComptimeFloat || | 20051 | expr_type->id == ZigTypeIdFloat || expr_type->id == ZigTypeIdComptimeFloat || |
| 19054 | expr_type->id == ZigTypeIdVector)) | 20052 | expr_type->id == ZigTypeIdVector)) |
| 19055 | { | 20053 | { |
| 19056 | ir_add_error(ira, &instruction->base, | 20054 | ir_add_error(ira, &instruction->base.base, |
| 19057 | buf_sprintf("negation of type '%s'", buf_ptr(&expr_type->name))); | 20055 | buf_sprintf("negation of type '%s'", buf_ptr(&expr_type->name))); |
| 19058 | return ira->codegen->invalid_instruction; | 20056 | return ira->codegen->invalid_inst_gen; |
| 19059 | } | 20057 | } |
| 19060 | | 20058 | |
| 19061 | bool is_wrap_op = (instruction->op_id == IrUnOpNegationWrap); | 20059 | bool is_wrap_op = (instruction->op_id == IrUnOpNegationWrap); |
| ... | @@ -19065,9 +20063,9 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins | ... | @@ -19065,9 +20063,9 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins |
| 19065 | if (instr_is_comptime(value)) { | 20063 | if (instr_is_comptime(value)) { |
| 19066 | ZigValue *operand_val = ir_resolve_const(ira, value, UndefBad); | 20064 | ZigValue *operand_val = ir_resolve_const(ira, value, UndefBad); |
| 19067 | if (!operand_val) | 20065 | if (!operand_val) |
| 19068 | return ira->codegen->invalid_instruction; | 20066 | return ira->codegen->invalid_inst_gen; |
| 19069 | | 20067 | |
| 19070 | IrInstruction *result_instruction = ir_const(ira, &instruction->base, expr_type); | 20068 | IrInstGen *result_instruction = ir_const(ira, &instruction->base.base, expr_type); |
| 19071 | ZigValue *out_val = result_instruction->value; | 20069 | ZigValue *out_val = result_instruction->value; |
| 19072 | if (expr_type->id == ZigTypeIdVector) { | 20070 | if (expr_type->id == ZigTypeIdVector) { |
| 19073 | expand_undef_array(ira->codegen, operand_val); | 20071 | expand_undef_array(ira->codegen, operand_val); |
| ... | @@ -19079,63 +20077,60 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins | ... | @@ -19079,63 +20077,60 @@ static IrInstruction *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *ins |
| 19079 | ZigValue *scalar_out_val = &out_val->data.x_array.data.s_none.elements[i]; | 20077 | ZigValue *scalar_out_val = &out_val->data.x_array.data.s_none.elements[i]; |
| 19080 | assert(scalar_operand_val->type == scalar_type); | 20078 | assert(scalar_operand_val->type == scalar_type); |
| 19081 | assert(scalar_out_val->type == scalar_type); | 20079 | assert(scalar_out_val->type == scalar_type); |
| 19082 | ErrorMsg *msg = ir_eval_negation_scalar(ira, &instruction->base, scalar_type, | 20080 | ErrorMsg *msg = ir_eval_negation_scalar(ira, &instruction->base.base, scalar_type, |
| 19083 | scalar_operand_val, scalar_out_val, is_wrap_op); | 20081 | scalar_operand_val, scalar_out_val, is_wrap_op); |
| 19084 | if (msg != nullptr) { | 20082 | if (msg != nullptr) { |
| 19085 | add_error_note(ira->codegen, msg, instruction->base.source_node, | 20083 | add_error_note(ira->codegen, msg, instruction->base.base.source_node, |
| 19086 | buf_sprintf("when computing vector element at index %" ZIG_PRI_usize, i)); | 20084 | buf_sprintf("when computing vector element at index %" ZIG_PRI_usize, i)); |
| 19087 | return ira->codegen->invalid_instruction; | 20085 | return ira->codegen->invalid_inst_gen; |
| 19088 | } | 20086 | } |
| 19089 | } | 20087 | } |
| 19090 | out_val->type = expr_type; | 20088 | out_val->type = expr_type; |
| 19091 | out_val->special = ConstValSpecialStatic; | 20089 | out_val->special = ConstValSpecialStatic; |
| 19092 | } else { | 20090 | } else { |
| 19093 | if (ir_eval_negation_scalar(ira, &instruction->base, scalar_type, operand_val, out_val, | 20091 | if (ir_eval_negation_scalar(ira, &instruction->base.base, scalar_type, operand_val, out_val, |
| 19094 | is_wrap_op) != nullptr) | 20092 | is_wrap_op) != nullptr) |
| 19095 | { | 20093 | { |
| 19096 | return ira->codegen->invalid_instruction; | 20094 | return ira->codegen->invalid_inst_gen; |
| 19097 | } | 20095 | } |
| 19098 | } | 20096 | } |
| 19099 | return result_instruction; | 20097 | return result_instruction; |
| 19100 | } | 20098 | } |
| 19101 | | 20099 | |
| 19102 | IrInstruction *result = ir_build_un_op(&ira->new_irb, | 20100 | if (is_wrap_op) { |
| 19103 | instruction->base.scope, instruction->base.source_node, | 20101 | return ir_build_negation_wrapping(ira, &instruction->base.base, value, expr_type); |
| 19104 | instruction->op_id, value); | 20102 | } else { |
| 19105 | result->value->type = expr_type; | 20103 | return ir_build_negation(ira, &instruction->base.base, value, expr_type); |
| 19106 | return result; | 20104 | } |
| 19107 | } | 20105 | } |
| 19108 | | 20106 | |
| 19109 | static IrInstruction *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *instruction) { | 20107 | static IrInstGen *ir_analyze_bin_not(IrAnalyze *ira, IrInstSrcUnOp *instruction) { |
| 19110 | IrInstruction *value = instruction->value->child; | 20108 | IrInstGen *value = instruction->value->child; |
| 19111 | ZigType *expr_type = value->value->type; | 20109 | ZigType *expr_type = value->value->type; |
| 19112 | if (type_is_invalid(expr_type)) | 20110 | if (type_is_invalid(expr_type)) |
| 19113 | return ira->codegen->invalid_instruction; | 20111 | return ira->codegen->invalid_inst_gen; |
| 19114 | | 20112 | |
| 19115 | if (expr_type->id == ZigTypeIdInt) { | 20113 | if (expr_type->id == ZigTypeIdInt) { |
| 19116 | if (instr_is_comptime(value)) { | 20114 | if (instr_is_comptime(value)) { |
| 19117 | ZigValue *target_const_val = ir_resolve_const(ira, value, UndefBad); | 20115 | ZigValue *target_const_val = ir_resolve_const(ira, value, UndefBad); |
| 19118 | if (target_const_val == nullptr) | 20116 | if (target_const_val == nullptr) |
| 19119 | return ira->codegen->invalid_instruction; | 20117 | return ira->codegen->invalid_inst_gen; |
| 19120 | | 20118 | |
| 19121 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); | 20119 | IrInstGen *result = ir_const(ira, &instruction->base.base, expr_type); |
| 19122 | bigint_not(&result->value->data.x_bigint, &target_const_val->data.x_bigint, | 20120 | bigint_not(&result->value->data.x_bigint, &target_const_val->data.x_bigint, |
| 19123 | expr_type->data.integral.bit_count, expr_type->data.integral.is_signed); | 20121 | expr_type->data.integral.bit_count, expr_type->data.integral.is_signed); |
| 19124 | return result; | 20122 | return result; |
| 19125 | } | 20123 | } |
| 19126 | | 20124 | |
| 19127 | IrInstruction *result = ir_build_un_op(&ira->new_irb, instruction->base.scope, | 20125 | return ir_build_binary_not(ira, &instruction->base.base, value, expr_type); |
| 19128 | instruction->base.source_node, IrUnOpBinNot, value); | | |
| 19129 | result->value->type = expr_type; | | |
| 19130 | return result; | | |
| 19131 | } | 20126 | } |
| 19132 | | 20127 | |
| 19133 | ir_add_error(ira, &instruction->base, | 20128 | ir_add_error(ira, &instruction->base.base, |
| 19134 | buf_sprintf("unable to perform binary not operation on type '%s'", buf_ptr(&expr_type->name))); | 20129 | buf_sprintf("unable to perform binary not operation on type '%s'", buf_ptr(&expr_type->name))); |
| 19135 | return ira->codegen->invalid_instruction; | 20130 | return ira->codegen->invalid_inst_gen; |
| 19136 | } | 20131 | } |
| 19137 | | 20132 | |
| 19138 | static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstructionUnOp *instruction) { | 20133 | static IrInstGen *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstSrcUnOp *instruction) { |
| 19139 | IrUnOp op_id = instruction->op_id; | 20134 | IrUnOp op_id = instruction->op_id; |
| 19140 | switch (op_id) { | 20135 | switch (op_id) { |
| 19141 | case IrUnOpInvalid: | 20136 | case IrUnOpInvalid: |
| ... | @@ -19146,26 +20141,26 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction | ... | @@ -19146,26 +20141,26 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction |
| 19146 | case IrUnOpNegationWrap: | 20141 | case IrUnOpNegationWrap: |
| 19147 | return ir_analyze_negation(ira, instruction); | 20142 | return ir_analyze_negation(ira, instruction); |
| 19148 | case IrUnOpDereference: { | 20143 | case IrUnOpDereference: { |
| 19149 | IrInstruction *ptr = instruction->value->child; | 20144 | IrInstGen *ptr = instruction->value->child; |
| 19150 | if (type_is_invalid(ptr->value->type)) | 20145 | if (type_is_invalid(ptr->value->type)) |
| 19151 | return ira->codegen->invalid_instruction; | 20146 | return ira->codegen->invalid_inst_gen; |
| 19152 | ZigType *ptr_type = ptr->value->type; | 20147 | ZigType *ptr_type = ptr->value->type; |
| 19153 | if (ptr_type->id == ZigTypeIdPointer && ptr_type->data.pointer.ptr_len == PtrLenUnknown) { | 20148 | if (ptr_type->id == ZigTypeIdPointer && ptr_type->data.pointer.ptr_len == PtrLenUnknown) { |
| 19154 | ir_add_error_node(ira, instruction->base.source_node, | 20149 | ir_add_error_node(ira, instruction->base.base.source_node, |
| 19155 | buf_sprintf("index syntax required for unknown-length pointer type '%s'", | 20150 | buf_sprintf("index syntax required for unknown-length pointer type '%s'", |
| 19156 | buf_ptr(&ptr_type->name))); | 20151 | buf_ptr(&ptr_type->name))); |
| 19157 | return ira->codegen->invalid_instruction; | 20152 | return ira->codegen->invalid_inst_gen; |
| 19158 | } | 20153 | } |
| 19159 | | 20154 | |
| 19160 | IrInstruction *result = ir_get_deref(ira, &instruction->base, ptr, instruction->result_loc); | 20155 | IrInstGen *result = ir_get_deref(ira, &instruction->base.base, ptr, instruction->result_loc); |
| 19161 | if (result == ira->codegen->invalid_instruction) | 20156 | if (type_is_invalid(result->value->type)) |
| 19162 | return ira->codegen->invalid_instruction; | 20157 | return ira->codegen->invalid_inst_gen; |
| 19163 | | 20158 | |
| 19164 | // If the result needs to be an lvalue, type check it | 20159 | // If the result needs to be an lvalue, type check it |
| 19165 | if (instruction->lval == LValPtr && result->value->type->id != ZigTypeIdPointer) { | 20160 | if (instruction->lval == LValPtr && result->value->type->id != ZigTypeIdPointer) { |
| 19166 | ir_add_error(ira, &instruction->base, | 20161 | ir_add_error(ira, &instruction->base.base, |
| 19167 | buf_sprintf("attempt to dereference non-pointer type '%s'", buf_ptr(&result->value->type->name))); | 20162 | buf_sprintf("attempt to dereference non-pointer type '%s'", buf_ptr(&result->value->type->name))); |
| 19168 | return ira->codegen->invalid_instruction; | 20163 | return ira->codegen->invalid_inst_gen; |
| 19169 | } | 20164 | } |
| 19170 | | 20165 | |
| 19171 | return result; | 20166 | return result; |
| ... | @@ -19177,42 +20172,40 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction | ... | @@ -19177,42 +20172,40 @@ static IrInstruction *ir_analyze_instruction_un_op(IrAnalyze *ira, IrInstruction |
| 19177 | } | 20172 | } |
| 19178 | | 20173 | |
| 19179 | static void ir_push_resume(IrAnalyze *ira, IrSuspendPosition pos) { | 20174 | static void ir_push_resume(IrAnalyze *ira, IrSuspendPosition pos) { |
| 19180 | IrBasicBlock *old_bb = ira->old_irb.exec->basic_block_list.at(pos.basic_block_index); | 20175 | IrBasicBlockSrc *old_bb = ira->old_irb.exec->basic_block_list.at(pos.basic_block_index); |
| 19181 | if (old_bb->in_resume_stack) return; | 20176 | if (old_bb->in_resume_stack) return; |
| 19182 | ira->resume_stack.append(pos); | 20177 | ira->resume_stack.append(pos); |
| 19183 | old_bb->in_resume_stack = true; | 20178 | old_bb->in_resume_stack = true; |
| 19184 | } | 20179 | } |
| 19185 | | 20180 | |
| 19186 | static void ir_push_resume_block(IrAnalyze *ira, IrBasicBlock *old_bb) { | 20181 | static void ir_push_resume_block(IrAnalyze *ira, IrBasicBlockSrc *old_bb) { |
| 19187 | if (ira->resume_stack.length != 0) { | 20182 | if (ira->resume_stack.length != 0) { |
| 19188 | ir_push_resume(ira, {old_bb->index, 0}); | 20183 | ir_push_resume(ira, {old_bb->index, 0}); |
| 19189 | } | 20184 | } |
| 19190 | } | 20185 | } |
| 19191 | | 20186 | |
| 19192 | static IrInstruction *ir_analyze_instruction_br(IrAnalyze *ira, IrInstructionBr *br_instruction) { | 20187 | static IrInstGen *ir_analyze_instruction_br(IrAnalyze *ira, IrInstSrcBr *br_instruction) { |
| 19193 | IrBasicBlock *old_dest_block = br_instruction->dest_block; | 20188 | IrBasicBlockSrc *old_dest_block = br_instruction->dest_block; |
| 19194 | | 20189 | |
| 19195 | bool is_comptime; | 20190 | bool is_comptime; |
| 19196 | if (!ir_resolve_comptime(ira, br_instruction->is_comptime->child, &is_comptime)) | 20191 | if (!ir_resolve_comptime(ira, br_instruction->is_comptime->child, &is_comptime)) |
| 19197 | return ir_unreach_error(ira); | 20192 | return ir_unreach_error(ira); |
| 19198 | | 20193 | |
| 19199 | if (is_comptime || (old_dest_block->ref_count == 1 && old_dest_block->suspend_instruction_ref == nullptr)) | 20194 | if (is_comptime || (old_dest_block->ref_count == 1 && old_dest_block->suspend_instruction_ref == nullptr)) |
| 19200 | return ir_inline_bb(ira, &br_instruction->base, old_dest_block); | 20195 | return ir_inline_bb(ira, &br_instruction->base.base, old_dest_block); |
| 19201 | | 20196 | |
| 19202 | IrBasicBlock *new_bb = ir_get_new_bb_runtime(ira, old_dest_block, &br_instruction->base); | 20197 | IrBasicBlockGen *new_bb = ir_get_new_bb_runtime(ira, old_dest_block, &br_instruction->base.base); |
| 19203 | if (new_bb == nullptr) | 20198 | if (new_bb == nullptr) |
| 19204 | return ir_unreach_error(ira); | 20199 | return ir_unreach_error(ira); |
| 19205 | | 20200 | |
| 19206 | ir_push_resume_block(ira, old_dest_block); | 20201 | ir_push_resume_block(ira, old_dest_block); |
| 19207 | | 20202 | |
| 19208 | IrInstruction *result = ir_build_br(&ira->new_irb, | 20203 | IrInstGen *result = ir_build_br_gen(ira, &br_instruction->base.base, new_bb); |
| 19209 | br_instruction->base.scope, br_instruction->base.source_node, new_bb, nullptr); | | |
| 19210 | result->value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 19211 | return ir_finish_anal(ira, result); | 20204 | return ir_finish_anal(ira, result); |
| 19212 | } | 20205 | } |
| 19213 | | 20206 | |
| 19214 | static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructionCondBr *cond_br_instruction) { | 20207 | static IrInstGen *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstSrcCondBr *cond_br_instruction) { |
| 19215 | IrInstruction *condition = cond_br_instruction->condition->child; | 20208 | IrInstGen *condition = cond_br_instruction->condition->child; |
| 19216 | if (type_is_invalid(condition->value->type)) | 20209 | if (type_is_invalid(condition->value->type)) |
| 19217 | return ir_unreach_error(ira); | 20210 | return ir_unreach_error(ira); |
| 19218 | | 20211 | |
| ... | @@ -19221,7 +20214,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi | ... | @@ -19221,7 +20214,7 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi |
| 19221 | return ir_unreach_error(ira); | 20214 | return ir_unreach_error(ira); |
| 19222 | | 20215 | |
| 19223 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; | 20216 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| 19224 | IrInstruction *casted_condition = ir_implicit_cast(ira, condition, bool_type); | 20217 | IrInstGen *casted_condition = ir_implicit_cast(ira, condition, bool_type); |
| 19225 | if (type_is_invalid(casted_condition->value->type)) | 20218 | if (type_is_invalid(casted_condition->value->type)) |
| 19226 | return ir_unreach_error(ira); | 20219 | return ir_unreach_error(ira); |
| 19227 | | 20220 | |
| ... | @@ -19230,67 +20223,61 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi | ... | @@ -19230,67 +20223,61 @@ static IrInstruction *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstructi |
| 19230 | if (!ir_resolve_bool(ira, casted_condition, &cond_is_true)) | 20223 | if (!ir_resolve_bool(ira, casted_condition, &cond_is_true)) |
| 19231 | return ir_unreach_error(ira); | 20224 | return ir_unreach_error(ira); |
| 19232 | | 20225 | |
| 19233 | IrBasicBlock *old_dest_block = cond_is_true ? | 20226 | IrBasicBlockSrc *old_dest_block = cond_is_true ? |
| 19234 | cond_br_instruction->then_block : cond_br_instruction->else_block; | 20227 | cond_br_instruction->then_block : cond_br_instruction->else_block; |
| 19235 | | 20228 | |
| 19236 | if (is_comptime || (old_dest_block->ref_count == 1 && old_dest_block->suspend_instruction_ref == nullptr)) | 20229 | if (is_comptime || (old_dest_block->ref_count == 1 && old_dest_block->suspend_instruction_ref == nullptr)) |
| 19237 | return ir_inline_bb(ira, &cond_br_instruction->base, old_dest_block); | 20230 | return ir_inline_bb(ira, &cond_br_instruction->base.base, old_dest_block); |
| 19238 | | 20231 | |
| 19239 | IrBasicBlock *new_dest_block = ir_get_new_bb_runtime(ira, old_dest_block, &cond_br_instruction->base); | 20232 | IrBasicBlockGen *new_dest_block = ir_get_new_bb_runtime(ira, old_dest_block, &cond_br_instruction->base.base); |
| 19240 | if (new_dest_block == nullptr) | 20233 | if (new_dest_block == nullptr) |
| 19241 | return ir_unreach_error(ira); | 20234 | return ir_unreach_error(ira); |
| 19242 | | 20235 | |
| 19243 | ir_push_resume_block(ira, old_dest_block); | 20236 | ir_push_resume_block(ira, old_dest_block); |
| 19244 | | 20237 | |
| 19245 | IrInstruction *result = ir_build_br(&ira->new_irb, | 20238 | IrInstGen *result = ir_build_br_gen(ira, &cond_br_instruction->base.base, new_dest_block); |
| 19246 | cond_br_instruction->base.scope, cond_br_instruction->base.source_node, new_dest_block, nullptr); | | |
| 19247 | result->value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 19248 | return ir_finish_anal(ira, result); | 20239 | return ir_finish_anal(ira, result); |
| 19249 | } | 20240 | } |
| 19250 | | 20241 | |
| 19251 | assert(cond_br_instruction->then_block != cond_br_instruction->else_block); | 20242 | assert(cond_br_instruction->then_block != cond_br_instruction->else_block); |
| 19252 | IrBasicBlock *new_then_block = ir_get_new_bb_runtime(ira, cond_br_instruction->then_block, &cond_br_instruction->base); | 20243 | IrBasicBlockGen *new_then_block = ir_get_new_bb_runtime(ira, cond_br_instruction->then_block, &cond_br_instruction->base.base); |
| 19253 | if (new_then_block == nullptr) | 20244 | if (new_then_block == nullptr) |
| 19254 | return ir_unreach_error(ira); | 20245 | return ir_unreach_error(ira); |
| 19255 | | 20246 | |
| 19256 | IrBasicBlock *new_else_block = ir_get_new_bb_runtime(ira, cond_br_instruction->else_block, &cond_br_instruction->base); | 20247 | IrBasicBlockGen *new_else_block = ir_get_new_bb_runtime(ira, cond_br_instruction->else_block, &cond_br_instruction->base.base); |
| 19257 | if (new_else_block == nullptr) | 20248 | if (new_else_block == nullptr) |
| 19258 | return ir_unreach_error(ira); | 20249 | return ir_unreach_error(ira); |
| 19259 | | 20250 | |
| 19260 | ir_push_resume_block(ira, cond_br_instruction->else_block); | 20251 | ir_push_resume_block(ira, cond_br_instruction->else_block); |
| 19261 | ir_push_resume_block(ira, cond_br_instruction->then_block); | 20252 | ir_push_resume_block(ira, cond_br_instruction->then_block); |
| 19262 | | 20253 | |
| 19263 | IrInstruction *result = ir_build_cond_br(&ira->new_irb, | 20254 | IrInstGen *result = ir_build_cond_br_gen(ira, &cond_br_instruction->base.base, |
| 19264 | cond_br_instruction->base.scope, cond_br_instruction->base.source_node, | 20255 | casted_condition, new_then_block, new_else_block); |
| 19265 | casted_condition, new_then_block, new_else_block, nullptr); | | |
| 19266 | result->value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 19267 | return ir_finish_anal(ira, result); | 20256 | return ir_finish_anal(ira, result); |
| 19268 | } | 20257 | } |
| 19269 | | 20258 | |
| 19270 | static IrInstruction *ir_analyze_instruction_unreachable(IrAnalyze *ira, | 20259 | static IrInstGen *ir_analyze_instruction_unreachable(IrAnalyze *ira, |
| 19271 | IrInstructionUnreachable *unreachable_instruction) | 20260 | IrInstSrcUnreachable *unreachable_instruction) |
| 19272 | { | 20261 | { |
| 19273 | IrInstruction *result = ir_build_unreachable(&ira->new_irb, | 20262 | IrInstGen *result = ir_build_unreachable_gen(ira, &unreachable_instruction->base.base); |
| 19274 | unreachable_instruction->base.scope, unreachable_instruction->base.source_node); | | |
| 19275 | result->value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 19276 | return ir_finish_anal(ira, result); | 20263 | return ir_finish_anal(ira, result); |
| 19277 | } | 20264 | } |
| 19278 | | 20265 | |
| 19279 | static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPhi *phi_instruction) { | 20266 | static IrInstGen *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstSrcPhi *phi_instruction) { |
| 19280 | Error err; | 20267 | Error err; |
| 19281 | | 20268 | |
| 19282 | if (ira->const_predecessor_bb) { | 20269 | if (ira->const_predecessor_bb) { |
| 19283 | for (size_t i = 0; i < phi_instruction->incoming_count; i += 1) { | 20270 | for (size_t i = 0; i < phi_instruction->incoming_count; i += 1) { |
| 19284 | IrBasicBlock *predecessor = phi_instruction->incoming_blocks[i]; | 20271 | IrBasicBlockSrc *predecessor = phi_instruction->incoming_blocks[i]; |
| 19285 | if (predecessor != ira->const_predecessor_bb) | 20272 | if (predecessor != ira->const_predecessor_bb) |
| 19286 | continue; | 20273 | continue; |
| 19287 | IrInstruction *value = phi_instruction->incoming_values[i]->child; | 20274 | IrInstGen *value = phi_instruction->incoming_values[i]->child; |
| 19288 | assert(value->value->type); | 20275 | assert(value->value->type); |
| 19289 | if (type_is_invalid(value->value->type)) | 20276 | if (type_is_invalid(value->value->type)) |
| 19290 | return ira->codegen->invalid_instruction; | 20277 | return ira->codegen->invalid_inst_gen; |
| 19291 | | 20278 | |
| 19292 | if (value->value->special != ConstValSpecialRuntime) { | 20279 | if (value->value->special != ConstValSpecialRuntime) { |
| 19293 | IrInstruction *result = ir_const(ira, &phi_instruction->base, nullptr); | 20280 | IrInstGen *result = ir_const(ira, &phi_instruction->base.base, nullptr); |
| 19294 | copy_const_val(result->value, value->value); | 20281 | copy_const_val(result->value, value->value); |
| 19295 | return result; | 20282 | return result; |
| 19296 | } else { | 20283 | } else { |
| ... | @@ -19305,17 +20292,17 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19305,17 +20292,17 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19305 | peer_parent->peers.length >= 2) | 20292 | peer_parent->peers.length >= 2) |
| 19306 | { | 20293 | { |
| 19307 | if (peer_parent->resolved_type == nullptr) { | 20294 | if (peer_parent->resolved_type == nullptr) { |
| 19308 | IrInstruction **instructions = allocate<IrInstruction *>(peer_parent->peers.length); | 20295 | IrInstGen **instructions = allocate<IrInstGen *>(peer_parent->peers.length); |
| 19309 | for (size_t i = 0; i < peer_parent->peers.length; i += 1) { | 20296 | for (size_t i = 0; i < peer_parent->peers.length; i += 1) { |
| 19310 | ResultLocPeer *this_peer = peer_parent->peers.at(i); | 20297 | ResultLocPeer *this_peer = peer_parent->peers.at(i); |
| 19311 | | 20298 | |
| 19312 | IrInstruction *gen_instruction = this_peer->base.gen_instruction; | 20299 | IrInstGen *gen_instruction = this_peer->base.gen_instruction; |
| 19313 | if (gen_instruction == nullptr) { | 20300 | if (gen_instruction == nullptr) { |
| 19314 | // unreachable instructions will cause implicit_elem_type to be null | 20301 | // unreachable instructions will cause implicit_elem_type to be null |
| 19315 | if (this_peer->base.implicit_elem_type == nullptr) { | 20302 | if (this_peer->base.implicit_elem_type == nullptr) { |
| 19316 | instructions[i] = ir_const_unreachable(ira, this_peer->base.source_instruction); | 20303 | instructions[i] = ir_const_unreachable(ira, &this_peer->base.source_instruction->base); |
| 19317 | } else { | 20304 | } else { |
| 19318 | instructions[i] = ir_const(ira, this_peer->base.source_instruction, | 20305 | instructions[i] = ir_const(ira, &this_peer->base.source_instruction->base, |
| 19319 | this_peer->base.implicit_elem_type); | 20306 | this_peer->base.implicit_elem_type); |
| 19320 | instructions[i]->value->special = ConstValSpecialRuntime; | 20307 | instructions[i]->value->special = ConstValSpecialRuntime; |
| 19321 | } | 20308 | } |
| ... | @@ -19324,34 +20311,34 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19324,34 +20311,34 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19324 | } | 20311 | } |
| 19325 | | 20312 | |
| 19326 | } | 20313 | } |
| 19327 | ZigType *expected_type = ir_result_loc_expected_type(ira, &phi_instruction->base, peer_parent->parent); | 20314 | ZigType *expected_type = ir_result_loc_expected_type(ira, &phi_instruction->base.base, peer_parent->parent); |
| 19328 | peer_parent->resolved_type = ir_resolve_peer_types(ira, | 20315 | peer_parent->resolved_type = ir_resolve_peer_types(ira, |
| 19329 | peer_parent->base.source_instruction->source_node, expected_type, instructions, | 20316 | peer_parent->base.source_instruction->base.source_node, expected_type, instructions, |
| 19330 | peer_parent->peers.length); | 20317 | peer_parent->peers.length); |
| 19331 | if (type_is_invalid(peer_parent->resolved_type)) | 20318 | if (type_is_invalid(peer_parent->resolved_type)) |
| 19332 | return ira->codegen->invalid_instruction; | 20319 | return ira->codegen->invalid_inst_gen; |
| 19333 | | 20320 | |
| 19334 | // the logic below assumes there are no instructions in the new current basic block yet | 20321 | // the logic below assumes there are no instructions in the new current basic block yet |
| 19335 | ir_assert(ira->new_irb.current_basic_block->instruction_list.length == 0, &phi_instruction->base); | 20322 | ir_assert(ira->new_irb.current_basic_block->instruction_list.length == 0, &phi_instruction->base.base); |
| 19336 | | 20323 | |
| 19337 | // In case resolving the parent activates a suspend, do it now | 20324 | // In case resolving the parent activates a suspend, do it now |
| 19338 | IrInstruction *parent_result_loc = ir_resolve_result(ira, &phi_instruction->base, peer_parent->parent, | 20325 | IrInstGen *parent_result_loc = ir_resolve_result(ira, &phi_instruction->base.base, peer_parent->parent, |
| 19339 | peer_parent->resolved_type, nullptr, false, false, true); | 20326 | peer_parent->resolved_type, nullptr, false, false, true); |
| 19340 | if (parent_result_loc != nullptr && | 20327 | if (parent_result_loc != nullptr && |
| 19341 | (type_is_invalid(parent_result_loc->value->type) || instr_is_unreachable(parent_result_loc))) | 20328 | (type_is_invalid(parent_result_loc->value->type) || parent_result_loc->value->type->id == ZigTypeIdUnreachable)) |
| 19342 | { | 20329 | { |
| 19343 | return parent_result_loc; | 20330 | return parent_result_loc; |
| 19344 | } | 20331 | } |
| 19345 | // If the above code generated any instructions in the current basic block, we need | 20332 | // If the above code generated any instructions in the current basic block, we need |
| 19346 | // to move them to the peer parent predecessor. | 20333 | // to move them to the peer parent predecessor. |
| 19347 | ZigList<IrInstruction *> instrs_to_move = {}; | 20334 | ZigList<IrInstGen *> instrs_to_move = {}; |
| 19348 | while (ira->new_irb.current_basic_block->instruction_list.length != 0) { | 20335 | while (ira->new_irb.current_basic_block->instruction_list.length != 0) { |
| 19349 | instrs_to_move.append(ira->new_irb.current_basic_block->instruction_list.pop()); | 20336 | instrs_to_move.append(ira->new_irb.current_basic_block->instruction_list.pop()); |
| 19350 | } | 20337 | } |
| 19351 | if (instrs_to_move.length != 0) { | 20338 | if (instrs_to_move.length != 0) { |
| 19352 | IrBasicBlock *predecessor = peer_parent->base.source_instruction->child->owner_bb; | 20339 | IrBasicBlockGen *predecessor = peer_parent->base.source_instruction->child->owner_bb; |
| 19353 | IrInstruction *branch_instruction = predecessor->instruction_list.pop(); | 20340 | IrInstGen *branch_instruction = predecessor->instruction_list.pop(); |
| 19354 | ir_assert(branch_instruction->value->type->id == ZigTypeIdUnreachable, &phi_instruction->base); | 20341 | ir_assert(branch_instruction->value->type->id == ZigTypeIdUnreachable, &phi_instruction->base.base); |
| 19355 | while (instrs_to_move.length != 0) { | 20342 | while (instrs_to_move.length != 0) { |
| 19356 | predecessor->instruction_list.append(instrs_to_move.pop()); | 20343 | predecessor->instruction_list.append(instrs_to_move.pop()); |
| 19357 | } | 20344 | } |
| ... | @@ -19360,7 +20347,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19360,7 +20347,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19360 | } | 20347 | } |
| 19361 | | 20348 | |
| 19362 | IrSuspendPosition suspend_pos; | 20349 | IrSuspendPosition suspend_pos; |
| 19363 | ira_suspend(ira, &phi_instruction->base, nullptr, &suspend_pos); | 20350 | ira_suspend(ira, &phi_instruction->base.base, nullptr, &suspend_pos); |
| 19364 | ir_push_resume(ira, suspend_pos); | 20351 | ir_push_resume(ira, suspend_pos); |
| 19365 | | 20352 | |
| 19366 | for (size_t i = 0; i < peer_parent->peers.length; i += 1) { | 20353 | for (size_t i = 0; i < peer_parent->peers.length; i += 1) { |
| ... | @@ -19376,34 +20363,32 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19376,34 +20363,32 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19376 | return ira_resume(ira); | 20363 | return ira_resume(ira); |
| 19377 | } | 20364 | } |
| 19378 | | 20365 | |
| 19379 | ZigList<IrBasicBlock*> new_incoming_blocks = {0}; | 20366 | ZigList<IrBasicBlockGen*> new_incoming_blocks = {0}; |
| 19380 | ZigList<IrInstruction*> new_incoming_values = {0}; | 20367 | ZigList<IrInstGen*> new_incoming_values = {0}; |
| 19381 | | 20368 | |
| 19382 | for (size_t i = 0; i < phi_instruction->incoming_count; i += 1) { | 20369 | for (size_t i = 0; i < phi_instruction->incoming_count; i += 1) { |
| 19383 | IrBasicBlock *predecessor = phi_instruction->incoming_blocks[i]; | 20370 | IrBasicBlockSrc *predecessor = phi_instruction->incoming_blocks[i]; |
| 19384 | if (predecessor->ref_count == 0) | 20371 | if (predecessor->ref_count == 0) |
| 19385 | continue; | 20372 | continue; |
| 19386 | | 20373 | |
| 19387 | | 20374 | |
| 19388 | IrInstruction *old_value = phi_instruction->incoming_values[i]; | 20375 | IrInstSrc *old_value = phi_instruction->incoming_values[i]; |
| 19389 | assert(old_value); | 20376 | assert(old_value); |
| 19390 | IrInstruction *new_value = old_value->child; | 20377 | IrInstGen *new_value = old_value->child; |
| 19391 | if (!new_value || new_value->value->type->id == ZigTypeIdUnreachable || predecessor->other == nullptr) | 20378 | if (!new_value || new_value->value->type->id == ZigTypeIdUnreachable || predecessor->child == nullptr) |
| 19392 | continue; | 20379 | continue; |
| 19393 | | 20380 | |
| 19394 | if (type_is_invalid(new_value->value->type)) | 20381 | if (type_is_invalid(new_value->value->type)) |
| 19395 | return ira->codegen->invalid_instruction; | 20382 | return ira->codegen->invalid_inst_gen; |
| 19396 | | 20383 | |
| 19397 | | 20384 | |
| 19398 | assert(predecessor->other); | 20385 | assert(predecessor->child); |
| 19399 | new_incoming_blocks.append(predecessor->other); | 20386 | new_incoming_blocks.append(predecessor->child); |
| 19400 | new_incoming_values.append(new_value); | 20387 | new_incoming_values.append(new_value); |
| 19401 | } | 20388 | } |
| 19402 | | 20389 | |
| 19403 | if (new_incoming_blocks.length == 0) { | 20390 | if (new_incoming_blocks.length == 0) { |
| 19404 | IrInstruction *result = ir_build_unreachable(&ira->new_irb, | 20391 | IrInstGen *result = ir_build_unreachable_gen(ira, &phi_instruction->base.base); |
| 19405 | phi_instruction->base.scope, phi_instruction->base.source_node); | | |
| 19406 | result->value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 19407 | return ir_finish_anal(ira, result); | 20392 | return ir_finish_anal(ira, result); |
| 19408 | } | 20393 | } |
| 19409 | | 20394 | |
| ... | @@ -19415,7 +20400,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19415,7 +20400,7 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19415 | if (peer_parent != nullptr) { | 20400 | if (peer_parent != nullptr) { |
| 19416 | bool peer_parent_has_type; | 20401 | bool peer_parent_has_type; |
| 19417 | if ((err = ir_result_has_type(ira, peer_parent->parent, &peer_parent_has_type))) | 20402 | if ((err = ir_result_has_type(ira, peer_parent->parent, &peer_parent_has_type))) |
| 19418 | return ira->codegen->invalid_instruction; | 20403 | return ira->codegen->invalid_inst_gen; |
| 19419 | if (peer_parent_has_type) { | 20404 | if (peer_parent_has_type) { |
| 19420 | if (peer_parent->parent->id == ResultLocIdReturn) { | 20405 | if (peer_parent->parent->id == ResultLocIdReturn) { |
| 19421 | resolved_type = ira->explicit_return_type; | 20406 | resolved_type = ira->explicit_return_type; |
| ... | @@ -19423,27 +20408,27 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19423,27 +20408,27 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19423 | resolved_type = ir_resolve_type(ira, peer_parent->parent->source_instruction->child); | 20408 | resolved_type = ir_resolve_type(ira, peer_parent->parent->source_instruction->child); |
| 19424 | } else if (peer_parent->parent->resolved_loc) { | 20409 | } else if (peer_parent->parent->resolved_loc) { |
| 19425 | ZigType *resolved_loc_ptr_type = peer_parent->parent->resolved_loc->value->type; | 20410 | ZigType *resolved_loc_ptr_type = peer_parent->parent->resolved_loc->value->type; |
| 19426 | ir_assert(resolved_loc_ptr_type->id == ZigTypeIdPointer, &phi_instruction->base); | 20411 | ir_assert(resolved_loc_ptr_type->id == ZigTypeIdPointer, &phi_instruction->base.base); |
| 19427 | resolved_type = resolved_loc_ptr_type->data.pointer.child_type; | 20412 | resolved_type = resolved_loc_ptr_type->data.pointer.child_type; |
| 19428 | } | 20413 | } |
| 19429 | | 20414 | |
| 19430 | if (resolved_type != nullptr && type_is_invalid(resolved_type)) | 20415 | if (resolved_type != nullptr && type_is_invalid(resolved_type)) |
| 19431 | return ira->codegen->invalid_instruction; | 20416 | return ira->codegen->invalid_inst_gen; |
| 19432 | } | 20417 | } |
| 19433 | } | 20418 | } |
| 19434 | | 20419 | |
| 19435 | if (resolved_type == nullptr) { | 20420 | if (resolved_type == nullptr) { |
| 19436 | resolved_type = ir_resolve_peer_types(ira, phi_instruction->base.source_node, nullptr, | 20421 | resolved_type = ir_resolve_peer_types(ira, phi_instruction->base.base.source_node, nullptr, |
| 19437 | new_incoming_values.items, new_incoming_values.length); | 20422 | new_incoming_values.items, new_incoming_values.length); |
| 19438 | if (type_is_invalid(resolved_type)) | 20423 | if (type_is_invalid(resolved_type)) |
| 19439 | return ira->codegen->invalid_instruction; | 20424 | return ira->codegen->invalid_inst_gen; |
| 19440 | } | 20425 | } |
| 19441 | | 20426 | |
| 19442 | switch (type_has_one_possible_value(ira->codegen, resolved_type)) { | 20427 | switch (type_has_one_possible_value(ira->codegen, resolved_type)) { |
| 19443 | case OnePossibleValueInvalid: | 20428 | case OnePossibleValueInvalid: |
| 19444 | return ira->codegen->invalid_instruction; | 20429 | return ira->codegen->invalid_inst_gen; |
| 19445 | case OnePossibleValueYes: | 20430 | case OnePossibleValueYes: |
| 19446 | return ir_const_move(ira, &phi_instruction->base, | 20431 | return ir_const_move(ira, &phi_instruction->base.base, |
| 19447 | get_the_one_possible_value(ira->codegen, resolved_type)); | 20432 | get_the_one_possible_value(ira->codegen, resolved_type)); |
| 19448 | case OnePossibleValueNo: | 20433 | case OnePossibleValueNo: |
| 19449 | break; | 20434 | break; |
| ... | @@ -19451,11 +20436,11 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19451,11 +20436,11 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19451 | | 20436 | |
| 19452 | switch (type_requires_comptime(ira->codegen, resolved_type)) { | 20437 | switch (type_requires_comptime(ira->codegen, resolved_type)) { |
| 19453 | case ReqCompTimeInvalid: | 20438 | case ReqCompTimeInvalid: |
| 19454 | return ira->codegen->invalid_instruction; | 20439 | return ira->codegen->invalid_inst_gen; |
| 19455 | case ReqCompTimeYes: | 20440 | case ReqCompTimeYes: |
| 19456 | ir_add_error_node(ira, phi_instruction->base.source_node, | 20441 | ir_add_error(ira, &phi_instruction->base.base, |
| 19457 | buf_sprintf("values of type '%s' must be comptime known", buf_ptr(&resolved_type->name))); | 20442 | buf_sprintf("values of type '%s' must be comptime known", buf_ptr(&resolved_type->name))); |
| 19458 | return ira->codegen->invalid_instruction; | 20443 | return ira->codegen->invalid_inst_gen; |
| 19459 | case ReqCompTimeNo: | 20444 | case ReqCompTimeNo: |
| 19460 | break; | 20445 | break; |
| 19461 | } | 20446 | } |
| ... | @@ -19465,16 +20450,16 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19465,16 +20450,16 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19465 | // cast all values to the resolved type. however we can't put cast instructions in front of the phi instruction. | 20450 | // cast all values to the resolved type. however we can't put cast instructions in front of the phi instruction. |
| 19466 | // so we go back and insert the casts as the last instruction in the corresponding predecessor blocks, and | 20451 | // so we go back and insert the casts as the last instruction in the corresponding predecessor blocks, and |
| 19467 | // then make sure the branch instruction is preserved. | 20452 | // then make sure the branch instruction is preserved. |
| 19468 | IrBasicBlock *cur_bb = ira->new_irb.current_basic_block; | 20453 | IrBasicBlockGen *cur_bb = ira->new_irb.current_basic_block; |
| 19469 | for (size_t i = 0; i < new_incoming_values.length; i += 1) { | 20454 | for (size_t i = 0; i < new_incoming_values.length; i += 1) { |
| 19470 | IrInstruction *new_value = new_incoming_values.at(i); | 20455 | IrInstGen *new_value = new_incoming_values.at(i); |
| 19471 | IrBasicBlock *predecessor = new_incoming_blocks.at(i); | 20456 | IrBasicBlockGen *predecessor = new_incoming_blocks.at(i); |
| 19472 | ir_assert(predecessor->instruction_list.length != 0, &phi_instruction->base); | 20457 | ir_assert(predecessor->instruction_list.length != 0, &phi_instruction->base.base); |
| 19473 | IrInstruction *branch_instruction = predecessor->instruction_list.pop(); | 20458 | IrInstGen *branch_instruction = predecessor->instruction_list.pop(); |
| 19474 | ir_set_cursor_at_end(&ira->new_irb, predecessor); | 20459 | ir_set_cursor_at_end_gen(&ira->new_irb, predecessor); |
| 19475 | IrInstruction *casted_value = ir_implicit_cast(ira, new_value, resolved_type); | 20460 | IrInstGen *casted_value = ir_implicit_cast(ira, new_value, resolved_type); |
| 19476 | if (type_is_invalid(casted_value->value->type)) { | 20461 | if (type_is_invalid(casted_value->value->type)) { |
| 19477 | return ira->codegen->invalid_instruction; | 20462 | return ira->codegen->invalid_inst_gen; |
| 19478 | } | 20463 | } |
| 19479 | new_incoming_values.items[i] = casted_value; | 20464 | new_incoming_values.items[i] = casted_value; |
| 19480 | predecessor->instruction_list.append(branch_instruction); | 20465 | predecessor->instruction_list.append(branch_instruction); |
| ... | @@ -19485,12 +20470,10 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19485,12 +20470,10 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19485 | all_stack_ptrs = false; | 20470 | all_stack_ptrs = false; |
| 19486 | } | 20471 | } |
| 19487 | } | 20472 | } |
| 19488 | ir_set_cursor_at_end(&ira->new_irb, cur_bb); | 20473 | ir_set_cursor_at_end_gen(&ira->new_irb, cur_bb); |
| 19489 | | 20474 | |
| 19490 | IrInstruction *result = ir_build_phi(&ira->new_irb, | 20475 | IrInstGen *result = ir_build_phi_gen(ira, &phi_instruction->base.base, |
| 19491 | phi_instruction->base.scope, phi_instruction->base.source_node, | 20476 | new_incoming_blocks.length, new_incoming_blocks.items, new_incoming_values.items, resolved_type); |
| 19492 | new_incoming_blocks.length, new_incoming_blocks.items, new_incoming_values.items, nullptr); | | |
| 19493 | result->value->type = resolved_type; | | |
| 19494 | | 20477 | |
| 19495 | if (all_stack_ptrs) { | 20478 | if (all_stack_ptrs) { |
| 19496 | assert(result->value->special == ConstValSpecialRuntime); | 20479 | assert(result->value->special == ConstValSpecialRuntime); |
| ... | @@ -19500,17 +20483,17 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh | ... | @@ -19500,17 +20483,17 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh |
| 19500 | return result; | 20483 | return result; |
| 19501 | } | 20484 | } |
| 19502 | | 20485 | |
| 19503 | static IrInstruction *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstructionVarPtr *instruction) { | 20486 | static IrInstGen *ir_analyze_instruction_var_ptr(IrAnalyze *ira, IrInstSrcVarPtr *instruction) { |
| 19504 | ZigVar *var = instruction->var; | 20487 | ZigVar *var = instruction->var; |
| 19505 | IrInstruction *result = ir_get_var_ptr(ira, &instruction->base, var); | 20488 | IrInstGen *result = ir_get_var_ptr(ira, &instruction->base.base, var); |
| 19506 | if (instruction->crossed_fndef_scope != nullptr && !instr_is_comptime(result)) { | 20489 | if (instruction->crossed_fndef_scope != nullptr && !instr_is_comptime(result)) { |
| 19507 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, | 20490 | ErrorMsg *msg = ir_add_error(ira, &instruction->base.base, |
| 19508 | buf_sprintf("'%s' not accessible from inner function", var->name)); | 20491 | buf_sprintf("'%s' not accessible from inner function", var->name)); |
| 19509 | add_error_note(ira->codegen, msg, instruction->crossed_fndef_scope->base.source_node, | 20492 | add_error_note(ira->codegen, msg, instruction->crossed_fndef_scope->base.source_node, |
| 19510 | buf_sprintf("crossed function definition here")); | 20493 | buf_sprintf("crossed function definition here")); |
| 19511 | add_error_note(ira->codegen, msg, var->decl_node, | 20494 | add_error_note(ira->codegen, msg, var->decl_node, |
| 19512 | buf_sprintf("declared here")); | 20495 | buf_sprintf("declared here")); |
| 19513 | return ira->codegen->invalid_instruction; | 20496 | return ira->codegen->invalid_inst_gen; |
| 19514 | } | 20497 | } |
| 19515 | return result; | 20498 | return result; |
| 19516 | } | 20499 | } |
| ... | @@ -19561,17 +20544,17 @@ static ZigType *adjust_ptr_len(CodeGen *g, ZigType *ptr_type, PtrLen ptr_len) { | ... | @@ -19561,17 +20544,17 @@ static ZigType *adjust_ptr_len(CodeGen *g, ZigType *ptr_type, PtrLen ptr_len) { |
| 19561 | ptr_type->data.pointer.allow_zero); | 20544 | ptr_type->data.pointer.allow_zero); |
| 19562 | } | 20545 | } |
| 19563 | | 20546 | |
| 19564 | static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstructionElemPtr *elem_ptr_instruction) { | 20547 | static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemPtr *elem_ptr_instruction) { |
| 19565 | Error err; | 20548 | Error err; |
| 19566 | IrInstruction *array_ptr = elem_ptr_instruction->array_ptr->child; | 20549 | IrInstGen *array_ptr = elem_ptr_instruction->array_ptr->child; |
| 19567 | if (type_is_invalid(array_ptr->value->type)) | 20550 | if (type_is_invalid(array_ptr->value->type)) |
| 19568 | return ira->codegen->invalid_instruction; | 20551 | return ira->codegen->invalid_inst_gen; |
| 19569 | | 20552 | |
| 19570 | ZigValue *orig_array_ptr_val = array_ptr->value; | 20553 | ZigValue *orig_array_ptr_val = array_ptr->value; |
| 19571 | | 20554 | |
| 19572 | IrInstruction *elem_index = elem_ptr_instruction->elem_index->child; | 20555 | IrInstGen *elem_index = elem_ptr_instruction->elem_index->child; |
| 19573 | if (type_is_invalid(elem_index->value->type)) | 20556 | if (type_is_invalid(elem_index->value->type)) |
| 19574 | return ira->codegen->invalid_instruction; | 20557 | return ira->codegen->invalid_inst_gen; |
| 19575 | | 20558 | |
| 19576 | ZigType *ptr_type = orig_array_ptr_val->type; | 20559 | ZigType *ptr_type = orig_array_ptr_val->type; |
| 19577 | assert(ptr_type->id == ZigTypeIdPointer); | 20560 | assert(ptr_type->id == ZigTypeIdPointer); |
| ... | @@ -19583,7 +20566,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19583,7 +20566,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19583 | ZigType *return_type; | 20566 | ZigType *return_type; |
| 19584 | | 20567 | |
| 19585 | if (type_is_invalid(array_type)) { | 20568 | if (type_is_invalid(array_type)) { |
| 19586 | return ira->codegen->invalid_instruction; | 20569 | return ira->codegen->invalid_inst_gen; |
| 19587 | } else if (array_type->id == ZigTypeIdArray || | 20570 | } else if (array_type->id == ZigTypeIdArray || |
| 19588 | (array_type->id == ZigTypeIdPointer && | 20571 | (array_type->id == ZigTypeIdPointer && |
| 19589 | array_type->data.pointer.ptr_len == PtrLenSingle && | 20572 | array_type->data.pointer.ptr_len == PtrLenSingle && |
| ... | @@ -19594,15 +20577,15 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19594,15 +20577,15 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19594 | ptr_type = ptr_type->data.pointer.child_type; | 20577 | ptr_type = ptr_type->data.pointer.child_type; |
| 19595 | if (orig_array_ptr_val->special != ConstValSpecialRuntime) { | 20578 | if (orig_array_ptr_val->special != ConstValSpecialRuntime) { |
| 19596 | orig_array_ptr_val = const_ptr_pointee(ira, ira->codegen, orig_array_ptr_val, | 20579 | orig_array_ptr_val = const_ptr_pointee(ira, ira->codegen, orig_array_ptr_val, |
| 19597 | elem_ptr_instruction->base.source_node); | 20580 | elem_ptr_instruction->base.base.source_node); |
| 19598 | if (orig_array_ptr_val == nullptr) | 20581 | if (orig_array_ptr_val == nullptr) |
| 19599 | return ira->codegen->invalid_instruction; | 20582 | return ira->codegen->invalid_inst_gen; |
| 19600 | } | 20583 | } |
| 19601 | } | 20584 | } |
| 19602 | if (array_type->data.array.len == 0) { | 20585 | if (array_type->data.array.len == 0) { |
| 19603 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, | 20586 | ir_add_error_node(ira, elem_ptr_instruction->base.base.source_node, |
| 19604 | buf_sprintf("index 0 outside array of size 0")); | 20587 | buf_sprintf("index 0 outside array of size 0")); |
| 19605 | return ira->codegen->invalid_instruction; | 20588 | return ira->codegen->invalid_inst_gen; |
| 19606 | } | 20589 | } |
| 19607 | ZigType *child_type = array_type->data.array.child_type; | 20590 | ZigType *child_type = array_type->data.array.child_type; |
| 19608 | if (ptr_type->data.pointer.host_int_bytes == 0) { | 20591 | if (ptr_type->data.pointer.host_int_bytes == 0) { |
| ... | @@ -19613,7 +20596,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19613,7 +20596,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19613 | } else { | 20596 | } else { |
| 19614 | uint64_t elem_val_scalar; | 20597 | uint64_t elem_val_scalar; |
| 19615 | if (!ir_resolve_usize(ira, elem_index, &elem_val_scalar)) | 20598 | if (!ir_resolve_usize(ira, elem_index, &elem_val_scalar)) |
| 19616 | return ira->codegen->invalid_instruction; | 20599 | return ira->codegen->invalid_inst_gen; |
| 19617 | | 20600 | |
| 19618 | size_t bit_width = type_size_bits(ira->codegen, child_type); | 20601 | size_t bit_width = type_size_bits(ira->codegen, child_type); |
| 19619 | size_t bit_offset = bit_width * elem_val_scalar; | 20602 | size_t bit_offset = bit_width * elem_val_scalar; |
| ... | @@ -19625,9 +20608,9 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19625,9 +20608,9 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19625 | } | 20608 | } |
| 19626 | } else if (array_type->id == ZigTypeIdPointer) { | 20609 | } else if (array_type->id == ZigTypeIdPointer) { |
| 19627 | if (array_type->data.pointer.ptr_len == PtrLenSingle) { | 20610 | if (array_type->data.pointer.ptr_len == PtrLenSingle) { |
| 19628 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, | 20611 | ir_add_error_node(ira, elem_ptr_instruction->base.base.source_node, |
| 19629 | buf_sprintf("index of single-item pointer")); | 20612 | buf_sprintf("index of single-item pointer")); |
| 19630 | return ira->codegen->invalid_instruction; | 20613 | return ira->codegen->invalid_inst_gen; |
| 19631 | } | 20614 | } |
| 19632 | return_type = adjust_ptr_len(ira->codegen, array_type, elem_ptr_instruction->ptr_len); | 20615 | return_type = adjust_ptr_len(ira->codegen, array_type, elem_ptr_instruction->ptr_len); |
| 19633 | } else if (is_slice(array_type)) { | 20616 | } else if (is_slice(array_type)) { |
| ... | @@ -19641,38 +20624,38 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19641,38 +20624,38 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19641 | array_type->data.structure.resolve_status == ResolveStatusBeingInferred) | 20624 | array_type->data.structure.resolve_status == ResolveStatusBeingInferred) |
| 19642 | { | 20625 | { |
| 19643 | ZigType *usize = ira->codegen->builtin_types.entry_usize; | 20626 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 19644 | IrInstruction *casted_elem_index = ir_implicit_cast(ira, elem_index, usize); | 20627 | IrInstGen *casted_elem_index = ir_implicit_cast(ira, elem_index, usize); |
| 19645 | if (type_is_invalid(casted_elem_index->value->type)) | 20628 | if (type_is_invalid(casted_elem_index->value->type)) |
| 19646 | return ira->codegen->invalid_instruction; | 20629 | return ira->codegen->invalid_inst_gen; |
| 19647 | ir_assert(instr_is_comptime(casted_elem_index), &elem_ptr_instruction->base); | 20630 | ir_assert(instr_is_comptime(casted_elem_index), &elem_ptr_instruction->base.base); |
| 19648 | Buf *field_name = buf_alloc(); | 20631 | Buf *field_name = buf_alloc(); |
| 19649 | bigint_append_buf(field_name, &casted_elem_index->value->data.x_bigint, 10); | 20632 | bigint_append_buf(field_name, &casted_elem_index->value->data.x_bigint, 10); |
| 19650 | return ir_analyze_inferred_field_ptr(ira, field_name, &elem_ptr_instruction->base, | 20633 | return ir_analyze_inferred_field_ptr(ira, field_name, &elem_ptr_instruction->base.base, |
| 19651 | array_ptr, array_type); | 20634 | array_ptr, array_type); |
| 19652 | } else if (is_tuple(array_type)) { | 20635 | } else if (is_tuple(array_type)) { |
| 19653 | uint64_t elem_index_scalar; | 20636 | uint64_t elem_index_scalar; |
| 19654 | if (!ir_resolve_usize(ira, elem_index, &elem_index_scalar)) | 20637 | if (!ir_resolve_usize(ira, elem_index, &elem_index_scalar)) |
| 19655 | return ira->codegen->invalid_instruction; | 20638 | return ira->codegen->invalid_inst_gen; |
| 19656 | if (elem_index_scalar >= array_type->data.structure.src_field_count) { | 20639 | if (elem_index_scalar >= array_type->data.structure.src_field_count) { |
| 19657 | ir_add_error(ira, &elem_ptr_instruction->base, buf_sprintf( | 20640 | ir_add_error(ira, &elem_ptr_instruction->base.base, buf_sprintf( |
| 19658 | "field index %" ZIG_PRI_u64 " outside tuple '%s' which has %" PRIu32 " fields", | 20641 | "field index %" ZIG_PRI_u64 " outside tuple '%s' which has %" PRIu32 " fields", |
| 19659 | elem_index_scalar, buf_ptr(&array_type->name), | 20642 | elem_index_scalar, buf_ptr(&array_type->name), |
| 19660 | array_type->data.structure.src_field_count)); | 20643 | array_type->data.structure.src_field_count)); |
| 19661 | return ira->codegen->invalid_instruction; | 20644 | return ira->codegen->invalid_inst_gen; |
| 19662 | } | 20645 | } |
| 19663 | TypeStructField *field = array_type->data.structure.fields[elem_index_scalar]; | 20646 | TypeStructField *field = array_type->data.structure.fields[elem_index_scalar]; |
| 19664 | return ir_analyze_struct_field_ptr(ira, &elem_ptr_instruction->base, field, array_ptr, | 20647 | return ir_analyze_struct_field_ptr(ira, &elem_ptr_instruction->base.base, field, array_ptr, |
| 19665 | array_type, false); | 20648 | array_type, false); |
| 19666 | } else { | 20649 | } else { |
| 19667 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, | 20650 | ir_add_error_node(ira, elem_ptr_instruction->base.base.source_node, |
| 19668 | buf_sprintf("array access of non-array type '%s'", buf_ptr(&array_type->name))); | 20651 | buf_sprintf("array access of non-array type '%s'", buf_ptr(&array_type->name))); |
| 19669 | return ira->codegen->invalid_instruction; | 20652 | return ira->codegen->invalid_inst_gen; |
| 19670 | } | 20653 | } |
| 19671 | | 20654 | |
| 19672 | ZigType *usize = ira->codegen->builtin_types.entry_usize; | 20655 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 19673 | IrInstruction *casted_elem_index = ir_implicit_cast(ira, elem_index, usize); | 20656 | IrInstGen *casted_elem_index = ir_implicit_cast(ira, elem_index, usize); |
| 19674 | if (casted_elem_index == ira->codegen->invalid_instruction) | 20657 | if (type_is_invalid(casted_elem_index->value->type)) |
| 19675 | return ira->codegen->invalid_instruction; | 20658 | return ira->codegen->invalid_inst_gen; |
| 19676 | | 20659 | |
| 19677 | bool safety_check_on = elem_ptr_instruction->safety_check_on; | 20660 | bool safety_check_on = elem_ptr_instruction->safety_check_on; |
| 19678 | if (instr_is_comptime(casted_elem_index)) { | 20661 | if (instr_is_comptime(casted_elem_index)) { |
| ... | @@ -19681,15 +20664,15 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19681,15 +20664,15 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19681 | uint64_t array_len = array_type->data.array.len; | 20664 | uint64_t array_len = array_type->data.array.len; |
| 19682 | if (index == array_len && array_type->data.array.sentinel != nullptr) { | 20665 | if (index == array_len && array_type->data.array.sentinel != nullptr) { |
| 19683 | ZigType *elem_type = array_type->data.array.child_type; | 20666 | ZigType *elem_type = array_type->data.array.child_type; |
| 19684 | IrInstruction *sentinel_elem = ir_const(ira, &elem_ptr_instruction->base, elem_type); | 20667 | IrInstGen *sentinel_elem = ir_const(ira, &elem_ptr_instruction->base.base, elem_type); |
| 19685 | copy_const_val(sentinel_elem->value, array_type->data.array.sentinel); | 20668 | copy_const_val(sentinel_elem->value, array_type->data.array.sentinel); |
| 19686 | return ir_get_ref(ira, &elem_ptr_instruction->base, sentinel_elem, true, false); | 20669 | return ir_get_ref(ira, &elem_ptr_instruction->base.base, sentinel_elem, true, false); |
| 19687 | } | 20670 | } |
| 19688 | if (index >= array_len) { | 20671 | if (index >= array_len) { |
| 19689 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, | 20672 | ir_add_error_node(ira, elem_ptr_instruction->base.base.source_node, |
| 19690 | buf_sprintf("index %" ZIG_PRI_u64 " outside array of size %" ZIG_PRI_u64, | 20673 | buf_sprintf("index %" ZIG_PRI_u64 " outside array of size %" ZIG_PRI_u64, |
| 19691 | index, array_len)); | 20674 | index, array_len)); |
| 19692 | return ira->codegen->invalid_instruction; | 20675 | return ira->codegen->invalid_inst_gen; |
| 19693 | } | 20676 | } |
| 19694 | safety_check_on = false; | 20677 | safety_check_on = false; |
| 19695 | } | 20678 | } |
| ... | @@ -19705,7 +20688,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19705,7 +20688,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19705 | // figure out the largest alignment possible | 20688 | // figure out the largest alignment possible |
| 19706 | | 20689 | |
| 19707 | if ((err = type_resolve(ira->codegen, return_type->data.pointer.child_type, ResolveStatusSizeKnown))) | 20690 | if ((err = type_resolve(ira->codegen, return_type->data.pointer.child_type, ResolveStatusSizeKnown))) |
| 19708 | return ira->codegen->invalid_instruction; | 20691 | return ira->codegen->invalid_inst_gen; |
| 19709 | | 20692 | |
| 19710 | uint64_t elem_size = type_size(ira->codegen, return_type->data.pointer.child_type); | 20693 | uint64_t elem_size = type_size(ira->codegen, return_type->data.pointer.child_type); |
| 19711 | uint64_t abi_align = get_abi_alignment(ira->codegen, return_type->data.pointer.child_type); | 20694 | uint64_t abi_align = get_abi_alignment(ira->codegen, return_type->data.pointer.child_type); |
| ... | @@ -19735,9 +20718,9 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19735,9 +20718,9 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19735 | array_type->id == ZigTypeIdArray)) | 20718 | array_type->id == ZigTypeIdArray)) |
| 19736 | { | 20719 | { |
| 19737 | ZigValue *array_ptr_val = const_ptr_pointee(ira, ira->codegen, orig_array_ptr_val, | 20720 | ZigValue *array_ptr_val = const_ptr_pointee(ira, ira->codegen, orig_array_ptr_val, |
| 19738 | elem_ptr_instruction->base.source_node); | 20721 | elem_ptr_instruction->base.base.source_node); |
| 19739 | if (array_ptr_val == nullptr) | 20722 | if (array_ptr_val == nullptr) |
| 19740 | return ira->codegen->invalid_instruction; | 20723 | return ira->codegen->invalid_inst_gen; |
| 19741 | | 20724 | |
| 19742 | if (array_ptr_val->special == ConstValSpecialUndef && | 20725 | if (array_ptr_val->special == ConstValSpecialUndef && |
| 19743 | elem_ptr_instruction->init_array_type_source_node != nullptr) | 20726 | elem_ptr_instruction->init_array_type_source_node != nullptr) |
| ... | @@ -19755,16 +20738,16 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19755,16 +20738,16 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19755 | elem_val->parent.data.p_array.elem_index = i; | 20738 | elem_val->parent.data.p_array.elem_index = i; |
| 19756 | } | 20739 | } |
| 19757 | } else if (is_slice(array_type)) { | 20740 | } else if (is_slice(array_type)) { |
| 19758 | ir_assert(array_ptr->value->type->id == ZigTypeIdPointer, &elem_ptr_instruction->base); | 20741 | ir_assert(array_ptr->value->type->id == ZigTypeIdPointer, &elem_ptr_instruction->base.base); |
| 19759 | ZigType *actual_array_type = array_ptr->value->type->data.pointer.child_type; | 20742 | ZigType *actual_array_type = array_ptr->value->type->data.pointer.child_type; |
| 19760 | | 20743 | |
| 19761 | if (type_is_invalid(actual_array_type)) | 20744 | if (type_is_invalid(actual_array_type)) |
| 19762 | return ira->codegen->invalid_instruction; | 20745 | return ira->codegen->invalid_inst_gen; |
| 19763 | if (actual_array_type->id != ZigTypeIdArray) { | 20746 | if (actual_array_type->id != ZigTypeIdArray) { |
| 19764 | ir_add_error_node(ira, elem_ptr_instruction->init_array_type_source_node, | 20747 | ir_add_error_node(ira, elem_ptr_instruction->init_array_type_source_node, |
| 19765 | buf_sprintf("array literal requires address-of operator to coerce to slice type '%s'", | 20748 | buf_sprintf("array literal requires address-of operator to coerce to slice type '%s'", |
| 19766 | buf_ptr(&actual_array_type->name))); | 20749 | buf_ptr(&actual_array_type->name))); |
| 19767 | return ira->codegen->invalid_instruction; | 20750 | return ira->codegen->invalid_inst_gen; |
| 19768 | } | 20751 | } |
| 19769 | | 20752 | |
| 19770 | ZigValue *array_init_val = create_const_vals(1); | 20753 | ZigValue *array_init_val = create_const_vals(1); |
| ... | @@ -19789,7 +20772,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19789,7 +20772,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19789 | ir_add_error_node(ira, elem_ptr_instruction->init_array_type_source_node, | 20772 | ir_add_error_node(ira, elem_ptr_instruction->init_array_type_source_node, |
| 19790 | buf_sprintf("expected array type or [_], found '%s'", | 20773 | buf_sprintf("expected array type or [_], found '%s'", |
| 19791 | buf_ptr(&array_type->name))); | 20774 | buf_ptr(&array_type->name))); |
| 19792 | return ira->codegen->invalid_instruction; | 20775 | return ira->codegen->invalid_inst_gen; |
| 19793 | } | 20776 | } |
| 19794 | } | 20777 | } |
| 19795 | | 20778 | |
| ... | @@ -19798,7 +20781,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19798,7 +20781,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19798 | array_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr)) | 20781 | array_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr)) |
| 19799 | { | 20782 | { |
| 19800 | if (array_type->id == ZigTypeIdPointer) { | 20783 | if (array_type->id == ZigTypeIdPointer) { |
| 19801 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); | 20784 | IrInstGen *result = ir_const(ira, &elem_ptr_instruction->base.base, return_type); |
| 19802 | ZigValue *out_val = result->value; | 20785 | ZigValue *out_val = result->value; |
| 19803 | out_val->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; | 20786 | out_val->data.x_ptr.mut = array_ptr_val->data.x_ptr.mut; |
| 19804 | size_t new_index; | 20787 | size_t new_index; |
| ... | @@ -19867,33 +20850,31 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19867,33 +20850,31 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19867 | zig_panic("TODO elem ptr on a null pointer"); | 20850 | zig_panic("TODO elem ptr on a null pointer"); |
| 19868 | } | 20851 | } |
| 19869 | if (new_index >= mem_size) { | 20852 | if (new_index >= mem_size) { |
| 19870 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, | 20853 | ir_add_error_node(ira, elem_ptr_instruction->base.base.source_node, |
| 19871 | buf_sprintf("index %" ZIG_PRI_u64 " outside pointer of size %" ZIG_PRI_usize "", index, old_size)); | 20854 | buf_sprintf("index %" ZIG_PRI_u64 " outside pointer of size %" ZIG_PRI_usize "", index, old_size)); |
| 19872 | return ira->codegen->invalid_instruction; | 20855 | return ira->codegen->invalid_inst_gen; |
| 19873 | } | 20856 | } |
| 19874 | return result; | 20857 | return result; |
| 19875 | } else if (is_slice(array_type)) { | 20858 | } else if (is_slice(array_type)) { |
| 19876 | ZigValue *ptr_field = array_ptr_val->data.x_struct.fields[slice_ptr_index]; | 20859 | ZigValue *ptr_field = array_ptr_val->data.x_struct.fields[slice_ptr_index]; |
| 19877 | ir_assert(ptr_field != nullptr, &elem_ptr_instruction->base); | 20860 | ir_assert(ptr_field != nullptr, &elem_ptr_instruction->base.base); |
| 19878 | if (ptr_field->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { | 20861 | if (ptr_field->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { |
| 19879 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, | 20862 | return ir_build_elem_ptr_gen(ira, elem_ptr_instruction->base.base.scope, |
| 19880 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, false, | 20863 | elem_ptr_instruction->base.base.source_node, array_ptr, casted_elem_index, false, |
| 19881 | elem_ptr_instruction->ptr_len, nullptr); | 20864 | return_type); |
| 19882 | result->value->type = return_type; | | |
| 19883 | return result; | | |
| 19884 | } | 20865 | } |
| 19885 | ZigValue *len_field = array_ptr_val->data.x_struct.fields[slice_len_index]; | 20866 | ZigValue *len_field = array_ptr_val->data.x_struct.fields[slice_len_index]; |
| 19886 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); | 20867 | IrInstGen *result = ir_const(ira, &elem_ptr_instruction->base.base, return_type); |
| 19887 | ZigValue *out_val = result->value; | 20868 | ZigValue *out_val = result->value; |
| 19888 | ZigType *slice_ptr_type = array_type->data.structure.fields[slice_ptr_index]->type_entry; | 20869 | ZigType *slice_ptr_type = array_type->data.structure.fields[slice_ptr_index]->type_entry; |
| 19889 | uint64_t slice_len = bigint_as_u64(&len_field->data.x_bigint); | 20870 | uint64_t slice_len = bigint_as_u64(&len_field->data.x_bigint); |
| 19890 | uint64_t full_slice_len = slice_len + | 20871 | uint64_t full_slice_len = slice_len + |
| 19891 | ((slice_ptr_type->data.pointer.sentinel != nullptr) ? 1 : 0); | 20872 | ((slice_ptr_type->data.pointer.sentinel != nullptr) ? 1 : 0); |
| 19892 | if (index >= full_slice_len) { | 20873 | if (index >= full_slice_len) { |
| 19893 | ir_add_error_node(ira, elem_ptr_instruction->base.source_node, | 20874 | ir_add_error_node(ira, elem_ptr_instruction->base.base.source_node, |
| 19894 | buf_sprintf("index %" ZIG_PRI_u64 " outside slice of size %" ZIG_PRI_u64, | 20875 | buf_sprintf("index %" ZIG_PRI_u64 " outside slice of size %" ZIG_PRI_u64, |
| 19895 | index, slice_len)); | 20876 | index, slice_len)); |
| 19896 | return ira->codegen->invalid_instruction; | 20877 | return ira->codegen->invalid_inst_gen; |
| 19897 | } | 20878 | } |
| 19898 | out_val->data.x_ptr.mut = ptr_field->data.x_ptr.mut; | 20879 | out_val->data.x_ptr.mut = ptr_field->data.x_ptr.mut; |
| 19899 | switch (ptr_field->data.x_ptr.special) { | 20880 | switch (ptr_field->data.x_ptr.special) { |
| ... | @@ -19913,7 +20894,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19913,7 +20894,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19913 | { | 20894 | { |
| 19914 | ir_assert(new_index < | 20895 | ir_assert(new_index < |
| 19915 | ptr_field->data.x_ptr.data.base_array.array_val->type->data.array.len, | 20896 | ptr_field->data.x_ptr.data.base_array.array_val->type->data.array.len, |
| 19916 | &elem_ptr_instruction->base); | 20897 | &elem_ptr_instruction->base.base); |
| 19917 | } | 20898 | } |
| 19918 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; | 20899 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; |
| 19919 | out_val->data.x_ptr.data.base_array.array_val = | 20900 | out_val->data.x_ptr.data.base_array.array_val = |
| ... | @@ -19938,15 +20919,14 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19938,15 +20919,14 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19938 | } | 20919 | } |
| 19939 | return result; | 20920 | return result; |
| 19940 | } else if (array_type->id == ZigTypeIdArray || array_type->id == ZigTypeIdVector) { | 20921 | } else if (array_type->id == ZigTypeIdArray || array_type->id == ZigTypeIdVector) { |
| 19941 | IrInstruction *result; | 20922 | IrInstGen *result; |
| 19942 | if (orig_array_ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 20923 | if (orig_array_ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 19943 | result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, | 20924 | result = ir_build_elem_ptr_gen(ira, elem_ptr_instruction->base.base.scope, |
| 19944 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, | 20925 | elem_ptr_instruction->base.base.source_node, array_ptr, casted_elem_index, |
| 19945 | false, elem_ptr_instruction->ptr_len, nullptr); | 20926 | false, return_type); |
| 19946 | result->value->type = return_type; | | |
| 19947 | result->value->special = ConstValSpecialStatic; | 20927 | result->value->special = ConstValSpecialStatic; |
| 19948 | } else { | 20928 | } else { |
| 19949 | result = ir_const(ira, &elem_ptr_instruction->base, return_type); | 20929 | result = ir_const(ira, &elem_ptr_instruction->base.base, return_type); |
| 19950 | } | 20930 | } |
| 19951 | ZigValue *out_val = result->value; | 20931 | ZigValue *out_val = result->value; |
| 19952 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; | 20932 | out_val->data.x_ptr.special = ConstPtrSpecialBaseArray; |
| ... | @@ -19972,19 +20952,19 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -19972,19 +20952,19 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 19972 | // runtime known element index | 20952 | // runtime known element index |
| 19973 | switch (type_requires_comptime(ira->codegen, return_type)) { | 20953 | switch (type_requires_comptime(ira->codegen, return_type)) { |
| 19974 | case ReqCompTimeYes: | 20954 | case ReqCompTimeYes: |
| 19975 | ir_add_error(ira, elem_index, | 20955 | ir_add_error(ira, &elem_index->base, |
| 19976 | buf_sprintf("values of type '%s' must be comptime known, but index value is runtime known", | 20956 | buf_sprintf("values of type '%s' must be comptime known, but index value is runtime known", |
| 19977 | buf_ptr(&return_type->data.pointer.child_type->name))); | 20957 | buf_ptr(&return_type->data.pointer.child_type->name))); |
| 19978 | return ira->codegen->invalid_instruction; | 20958 | return ira->codegen->invalid_inst_gen; |
| 19979 | case ReqCompTimeInvalid: | 20959 | case ReqCompTimeInvalid: |
| 19980 | return ira->codegen->invalid_instruction; | 20960 | return ira->codegen->invalid_inst_gen; |
| 19981 | case ReqCompTimeNo: | 20961 | case ReqCompTimeNo: |
| 19982 | break; | 20962 | break; |
| 19983 | } | 20963 | } |
| 19984 | | 20964 | |
| 19985 | if (return_type->data.pointer.explicit_alignment != 0) { | 20965 | if (return_type->data.pointer.explicit_alignment != 0) { |
| 19986 | if ((err = type_resolve(ira->codegen, return_type->data.pointer.child_type, ResolveStatusSizeKnown))) | 20966 | if ((err = type_resolve(ira->codegen, return_type->data.pointer.child_type, ResolveStatusSizeKnown))) |
| 19987 | return ira->codegen->invalid_instruction; | 20967 | return ira->codegen->invalid_inst_gen; |
| 19988 | | 20968 | |
| 19989 | uint64_t elem_size = type_size(ira->codegen, return_type->data.pointer.child_type); | 20969 | uint64_t elem_size = type_size(ira->codegen, return_type->data.pointer.child_type); |
| 19990 | uint64_t abi_align = get_abi_alignment(ira->codegen, return_type->data.pointer.child_type); | 20970 | uint64_t abi_align = get_abi_alignment(ira->codegen, return_type->data.pointer.child_type); |
| ... | @@ -20002,16 +20982,13 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -20002,16 +20982,13 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 20002 | } | 20982 | } |
| 20003 | } | 20983 | } |
| 20004 | | 20984 | |
| 20005 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, | 20985 | return ir_build_elem_ptr_gen(ira, elem_ptr_instruction->base.base.scope, |
| 20006 | elem_ptr_instruction->base.source_node, array_ptr, casted_elem_index, safety_check_on, | 20986 | elem_ptr_instruction->base.base.source_node, array_ptr, casted_elem_index, safety_check_on, return_type); |
| 20007 | elem_ptr_instruction->ptr_len, nullptr); | | |
| 20008 | result->value->type = return_type; | | |
| 20009 | return result; | | |
| 20010 | } | 20987 | } |
| 20011 | | 20988 | |
| 20012 | static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, | 20989 | static IrInstGen *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 20013 | ZigType *bare_struct_type, Buf *field_name, IrInstruction *source_instr, | 20990 | ZigType *bare_struct_type, Buf *field_name, IrInst* source_instr, |
| 20014 | IrInstruction *container_ptr, ZigType *container_type) | 20991 | IrInstGen *container_ptr, ZigType *container_type) |
| 20015 | { | 20992 | { |
| 20016 | if (!is_slice(bare_struct_type)) { | 20993 | if (!is_slice(bare_struct_type)) { |
| 20017 | ScopeDecls *container_scope = get_container_scope(bare_struct_type); | 20994 | ScopeDecls *container_scope = get_container_scope(bare_struct_type); |
| ... | @@ -20021,29 +20998,27 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, | ... | @@ -20021,29 +20998,27 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 20021 | if (tld->id == TldIdFn) { | 20998 | if (tld->id == TldIdFn) { |
| 20022 | resolve_top_level_decl(ira->codegen, tld, source_instr->source_node, false); | 20999 | resolve_top_level_decl(ira->codegen, tld, source_instr->source_node, false); |
| 20023 | if (tld->resolution == TldResolutionInvalid) | 21000 | if (tld->resolution == TldResolutionInvalid) |
| 20024 | return ira->codegen->invalid_instruction; | 21001 | return ira->codegen->invalid_inst_gen; |
| 20025 | TldFn *tld_fn = (TldFn *)tld; | 21002 | TldFn *tld_fn = (TldFn *)tld; |
| 20026 | ZigFn *fn_entry = tld_fn->fn_entry; | 21003 | ZigFn *fn_entry = tld_fn->fn_entry; |
| 20027 | if (type_is_invalid(fn_entry->type_entry)) | 21004 | if (type_is_invalid(fn_entry->type_entry)) |
| 20028 | return ira->codegen->invalid_instruction; | 21005 | return ira->codegen->invalid_inst_gen; |
| 20029 | | 21006 | |
| 20030 | IrInstruction *bound_fn_value = ir_build_const_bound_fn(&ira->new_irb, source_instr->scope, | 21007 | IrInstGen *bound_fn_value = ir_const_bound_fn(ira, source_instr, fn_entry, container_ptr); |
| 20031 | source_instr->source_node, fn_entry, container_ptr); | | |
| 20032 | return ir_get_ref(ira, source_instr, bound_fn_value, true, false); | 21008 | return ir_get_ref(ira, source_instr, bound_fn_value, true, false); |
| 20033 | } else if (tld->id == TldIdVar) { | 21009 | } else if (tld->id == TldIdVar) { |
| 20034 | resolve_top_level_decl(ira->codegen, tld, source_instr->source_node, false); | 21010 | resolve_top_level_decl(ira->codegen, tld, source_instr->source_node, false); |
| 20035 | if (tld->resolution == TldResolutionInvalid) | 21011 | if (tld->resolution == TldResolutionInvalid) |
| 20036 | return ira->codegen->invalid_instruction; | 21012 | return ira->codegen->invalid_inst_gen; |
| 20037 | TldVar *tld_var = (TldVar *)tld; | 21013 | TldVar *tld_var = (TldVar *)tld; |
| 20038 | ZigVar *var = tld_var->var; | 21014 | ZigVar *var = tld_var->var; |
| 20039 | if (type_is_invalid(var->var_type)) | 21015 | if (type_is_invalid(var->var_type)) |
| 20040 | return ira->codegen->invalid_instruction; | 21016 | return ira->codegen->invalid_inst_gen; |
| 20041 | | 21017 | |
| 20042 | if (var->const_value->type->id == ZigTypeIdFn) { | 21018 | if (var->const_value->type->id == ZigTypeIdFn) { |
| 20043 | ir_assert(var->const_value->data.x_ptr.special == ConstPtrSpecialFunction, source_instr); | 21019 | ir_assert(var->const_value->data.x_ptr.special == ConstPtrSpecialFunction, source_instr); |
| 20044 | ZigFn *fn = var->const_value->data.x_ptr.data.fn.fn_entry; | 21020 | ZigFn *fn = var->const_value->data.x_ptr.data.fn.fn_entry; |
| 20045 | IrInstruction *bound_fn_value = ir_build_const_bound_fn(&ira->new_irb, source_instr->scope, | 21021 | IrInstGen *bound_fn_value = ir_const_bound_fn(ira, source_instr, fn, container_ptr); |
| 20046 | source_instr->source_node, fn, container_ptr); | | |
| 20047 | return ir_get_ref(ira, source_instr, bound_fn_value, true, false); | 21022 | return ir_get_ref(ira, source_instr, bound_fn_value, true, false); |
| 20048 | } | 21023 | } |
| 20049 | } | 21024 | } |
| ... | @@ -20063,7 +21038,7 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, | ... | @@ -20063,7 +21038,7 @@ static IrInstruction *ir_analyze_container_member_access_inner(IrAnalyze *ira, |
| 20063 | } | 21038 | } |
| 20064 | ir_add_error_node(ira, source_instr->source_node, | 21039 | ir_add_error_node(ira, source_instr->source_node, |
| 20065 | buf_sprintf("no member named '%s' in %s'%s'", buf_ptr(field_name), prefix_name, buf_ptr(&bare_struct_type->name))); | 21040 | buf_sprintf("no member named '%s' in %s'%s'", buf_ptr(field_name), prefix_name, buf_ptr(&bare_struct_type->name))); |
| 20066 | return ira->codegen->invalid_instruction; | 21041 | return ira->codegen->invalid_inst_gen; |
| 20067 | } | 21042 | } |
| 20068 | | 21043 | |
| 20069 | static void memoize_field_init_val(CodeGen *codegen, ZigType *container_type, TypeStructField *field) { | 21044 | static void memoize_field_init_val(CodeGen *codegen, ZigType *container_type, TypeStructField *field) { |
| ... | @@ -20078,24 +21053,24 @@ static void memoize_field_init_val(CodeGen *codegen, ZigType *container_type, Ty | ... | @@ -20078,24 +21053,24 @@ static void memoize_field_init_val(CodeGen *codegen, ZigType *container_type, Ty |
| 20078 | field->type_entry, nullptr, UndefOk); | 21053 | field->type_entry, nullptr, UndefOk); |
| 20079 | } | 21054 | } |
| 20080 | | 21055 | |
| 20081 | static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction *source_instr, | 21056 | static IrInstGen *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInst* source_instr, |
| 20082 | TypeStructField *field, IrInstruction *struct_ptr, ZigType *struct_type, bool initializing) | 21057 | TypeStructField *field, IrInstGen *struct_ptr, ZigType *struct_type, bool initializing) |
| 20083 | { | 21058 | { |
| 20084 | Error err; | 21059 | Error err; |
| 20085 | ZigType *field_type = resolve_struct_field_type(ira->codegen, field); | 21060 | ZigType *field_type = resolve_struct_field_type(ira->codegen, field); |
| 20086 | if (field_type == nullptr) | 21061 | if (field_type == nullptr) |
| 20087 | return ira->codegen->invalid_instruction; | 21062 | return ira->codegen->invalid_inst_gen; |
| 20088 | if (field->is_comptime) { | 21063 | if (field->is_comptime) { |
| 20089 | IrInstruction *elem = ir_const(ira, source_instr, field_type); | 21064 | IrInstGen *elem = ir_const(ira, source_instr, field_type); |
| 20090 | memoize_field_init_val(ira->codegen, struct_type, field); | 21065 | memoize_field_init_val(ira->codegen, struct_type, field); |
| 20091 | copy_const_val(elem->value, field->init_val); | 21066 | copy_const_val(elem->value, field->init_val); |
| 20092 | return ir_get_ref(ira, source_instr, elem, true, false); | 21067 | return ir_get_ref(ira, source_instr, elem, true, false); |
| 20093 | } | 21068 | } |
| 20094 | switch (type_has_one_possible_value(ira->codegen, field_type)) { | 21069 | switch (type_has_one_possible_value(ira->codegen, field_type)) { |
| 20095 | case OnePossibleValueInvalid: | 21070 | case OnePossibleValueInvalid: |
| 20096 | return ira->codegen->invalid_instruction; | 21071 | return ira->codegen->invalid_inst_gen; |
| 20097 | case OnePossibleValueYes: { | 21072 | case OnePossibleValueYes: { |
| 20098 | IrInstruction *elem = ir_const_move(ira, source_instr, | 21073 | IrInstGen *elem = ir_const_move(ira, source_instr, |
| 20099 | get_the_one_possible_value(ira->codegen, field_type)); | 21074 | get_the_one_possible_value(ira->codegen, field_type)); |
| 20100 | return ir_get_ref(ira, source_instr, elem, false, false); | 21075 | return ir_get_ref(ira, source_instr, elem, false, false); |
| 20101 | } | 21076 | } |
| ... | @@ -20113,7 +21088,7 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -20113,7 +21088,7 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 20113 | (struct_type->data.structure.layout == ContainerLayoutAuto) ? | 21088 | (struct_type->data.structure.layout == ContainerLayoutAuto) ? |
| 20114 | ResolveStatusZeroBitsKnown : ResolveStatusSizeKnown; | 21089 | ResolveStatusZeroBitsKnown : ResolveStatusSizeKnown; |
| 20115 | if ((err = type_resolve(ira->codegen, struct_type, needed_resolve_status))) | 21090 | if ((err = type_resolve(ira->codegen, struct_type, needed_resolve_status))) |
| 20116 | return ira->codegen->invalid_instruction; | 21091 | return ira->codegen->invalid_inst_gen; |
| 20117 | assert(struct_ptr->value->type->id == ZigTypeIdPointer); | 21092 | assert(struct_ptr->value->type->id == ZigTypeIdPointer); |
| 20118 | uint32_t ptr_bit_offset = struct_ptr->value->type->data.pointer.bit_offset_in_host; | 21093 | uint32_t ptr_bit_offset = struct_ptr->value->type->data.pointer.bit_offset_in_host; |
| 20119 | uint32_t ptr_host_int_bytes = struct_ptr->value->type->data.pointer.host_int_bytes; | 21094 | uint32_t ptr_host_int_bytes = struct_ptr->value->type->data.pointer.host_int_bytes; |
| ... | @@ -20127,14 +21102,14 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -20127,14 +21102,14 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 20127 | if (instr_is_comptime(struct_ptr)) { | 21102 | if (instr_is_comptime(struct_ptr)) { |
| 20128 | ZigValue *ptr_val = ir_resolve_const(ira, struct_ptr, UndefBad); | 21103 | ZigValue *ptr_val = ir_resolve_const(ira, struct_ptr, UndefBad); |
| 20129 | if (!ptr_val) | 21104 | if (!ptr_val) |
| 20130 | return ira->codegen->invalid_instruction; | 21105 | return ira->codegen->invalid_inst_gen; |
| 20131 | | 21106 | |
| 20132 | if (ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 21107 | if (ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 20133 | ZigValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 21108 | ZigValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 20134 | if (struct_val == nullptr) | 21109 | if (struct_val == nullptr) |
| 20135 | return ira->codegen->invalid_instruction; | 21110 | return ira->codegen->invalid_inst_gen; |
| 20136 | if (type_is_invalid(struct_val->type)) | 21111 | if (type_is_invalid(struct_val->type)) |
| 20137 | return ira->codegen->invalid_instruction; | 21112 | return ira->codegen->invalid_inst_gen; |
| 20138 | if (initializing && struct_val->special == ConstValSpecialUndef) { | 21113 | if (initializing && struct_val->special == ConstValSpecialUndef) { |
| 20139 | struct_val->data.x_struct.fields = alloc_const_vals_ptrs(struct_type->data.structure.src_field_count); | 21114 | struct_val->data.x_struct.fields = alloc_const_vals_ptrs(struct_type->data.structure.src_field_count); |
| 20140 | struct_val->special = ConstValSpecialStatic; | 21115 | struct_val->special = ConstValSpecialStatic; |
| ... | @@ -20148,11 +21123,9 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -20148,11 +21123,9 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 20148 | field_val->parent.data.p_struct.field_index = i; | 21123 | field_val->parent.data.p_struct.field_index = i; |
| 20149 | } | 21124 | } |
| 20150 | } | 21125 | } |
| 20151 | IrInstruction *result; | 21126 | IrInstGen *result; |
| 20152 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 21127 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 20153 | result = ir_build_struct_field_ptr(&ira->new_irb, source_instr->scope, | 21128 | result = ir_build_struct_field_ptr(ira, source_instr, struct_ptr, field, ptr_type); |
| 20154 | source_instr->source_node, struct_ptr, field); | | |
| 20155 | result->value->type = ptr_type; | | |
| 20156 | result->value->special = ConstValSpecialStatic; | 21129 | result->value->special = ConstValSpecialStatic; |
| 20157 | } else { | 21130 | } else { |
| 20158 | result = ir_const(ira, source_instr, ptr_type); | 21131 | result = ir_const(ira, source_instr, ptr_type); |
| ... | @@ -20165,14 +21138,11 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -20165,14 +21138,11 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 20165 | return result; | 21138 | return result; |
| 20166 | } | 21139 | } |
| 20167 | } | 21140 | } |
| 20168 | IrInstruction *result = ir_build_struct_field_ptr(&ira->new_irb, source_instr->scope, source_instr->source_node, | 21141 | return ir_build_struct_field_ptr(ira, source_instr, struct_ptr, field, ptr_type); |
| 20169 | struct_ptr, field); | | |
| 20170 | result->value->type = ptr_type; | | |
| 20171 | return result; | | |
| 20172 | } | 21142 | } |
| 20173 | | 21143 | |
| 20174 | static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, | 21144 | static IrInstGen *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, |
| 20175 | IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type) | 21145 | IrInst* source_instr, IrInstGen *container_ptr, ZigType *container_type) |
| 20176 | { | 21146 | { |
| 20177 | // The type of the field is not available until a store using this pointer happens. | 21147 | // The type of the field is not available until a store using this pointer happens. |
| 20178 | // So, here we create a special pointer type which has the inferred struct type and | 21148 | // So, here we create a special pointer type which has the inferred struct type and |
| ... | @@ -20195,12 +21165,11 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n | ... | @@ -20195,12 +21165,11 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n |
| 20195 | if (instr_is_comptime(container_ptr)) { | 21165 | if (instr_is_comptime(container_ptr)) { |
| 20196 | ZigValue *ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); | 21166 | ZigValue *ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); |
| 20197 | if (ptr_val == nullptr) | 21167 | if (ptr_val == nullptr) |
| 20198 | return ira->codegen->invalid_instruction; | 21168 | return ira->codegen->invalid_inst_gen; |
| 20199 | | 21169 | |
| 20200 | IrInstruction *result; | 21170 | IrInstGen *result; |
| 20201 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 21171 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 20202 | result = ir_build_cast(&ira->new_irb, source_instr->scope, | 21172 | result = ir_build_cast(ira, source_instr, container_ptr_type, container_ptr, CastOpNoop); |
| 20203 | source_instr->source_node, container_ptr_type, container_ptr, CastOpNoop); | | |
| 20204 | } else { | 21173 | } else { |
| 20205 | result = ir_const(ira, source_instr, field_ptr_type); | 21174 | result = ir_const(ira, source_instr, field_ptr_type); |
| 20206 | } | 21175 | } |
| ... | @@ -20209,14 +21178,11 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n | ... | @@ -20209,14 +21178,11 @@ static IrInstruction *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_n |
| 20209 | return result; | 21178 | return result; |
| 20210 | } | 21179 | } |
| 20211 | | 21180 | |
| 20212 | IrInstruction *result = ir_build_cast(&ira->new_irb, source_instr->scope, | 21181 | return ir_build_cast(ira, source_instr, field_ptr_type, container_ptr, CastOpNoop); |
| 20213 | source_instr->source_node, field_ptr_type, container_ptr, CastOpNoop); | | |
| 20214 | result->value->type = field_ptr_type; | | |
| 20215 | return result; | | |
| 20216 | } | 21182 | } |
| 20217 | | 21183 | |
| 20218 | static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name, | 21184 | static IrInstGen *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_name, |
| 20219 | IrInstruction *source_instr, IrInstruction *container_ptr, ZigType *container_type, bool initializing) | 21185 | IrInst* source_instr, IrInstGen *container_ptr, ZigType *container_type, bool initializing) |
| 20220 | { | 21186 | { |
| 20221 | Error err; | 21187 | Error err; |
| 20222 | | 21188 | |
| ... | @@ -20229,7 +21195,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -20229,7 +21195,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 20229 | } | 21195 | } |
| 20230 | | 21196 | |
| 20231 | if ((err = type_resolve(ira->codegen, bare_type, ResolveStatusZeroBitsKnown))) | 21197 | if ((err = type_resolve(ira->codegen, bare_type, ResolveStatusZeroBitsKnown))) |
| 20232 | return ira->codegen->invalid_instruction; | 21198 | return ira->codegen->invalid_inst_gen; |
| 20233 | | 21199 | |
| 20234 | assert(container_ptr->value->type->id == ZigTypeIdPointer); | 21200 | assert(container_ptr->value->type->id == ZigTypeIdPointer); |
| 20235 | if (bare_type->id == ZigTypeIdStruct) { | 21201 | if (bare_type->id == ZigTypeIdStruct) { |
| ... | @@ -20259,22 +21225,22 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -20259,22 +21225,22 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 20259 | | 21225 | |
| 20260 | ZigType *field_type = resolve_union_field_type(ira->codegen, field); | 21226 | ZigType *field_type = resolve_union_field_type(ira->codegen, field); |
| 20261 | if (field_type == nullptr) | 21227 | if (field_type == nullptr) |
| 20262 | return ira->codegen->invalid_instruction; | 21228 | return ira->codegen->invalid_inst_gen; |
| 20263 | | 21229 | |
| 20264 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, field_type, | 21230 | ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, field_type, |
| 20265 | is_const, is_volatile, PtrLenSingle, 0, 0, 0, false); | 21231 | is_const, is_volatile, PtrLenSingle, 0, 0, 0, false); |
| 20266 | if (instr_is_comptime(container_ptr)) { | 21232 | if (instr_is_comptime(container_ptr)) { |
| 20267 | ZigValue *ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); | 21233 | ZigValue *ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); |
| 20268 | if (!ptr_val) | 21234 | if (!ptr_val) |
| 20269 | return ira->codegen->invalid_instruction; | 21235 | return ira->codegen->invalid_inst_gen; |
| 20270 | | 21236 | |
| 20271 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar && | 21237 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar && |
| 20272 | ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 21238 | ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 20273 | ZigValue *union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 21239 | ZigValue *union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 20274 | if (union_val == nullptr) | 21240 | if (union_val == nullptr) |
| 20275 | return ira->codegen->invalid_instruction; | 21241 | return ira->codegen->invalid_inst_gen; |
| 20276 | if (type_is_invalid(union_val->type)) | 21242 | if (type_is_invalid(union_val->type)) |
| 20277 | return ira->codegen->invalid_instruction; | 21243 | return ira->codegen->invalid_inst_gen; |
| 20278 | | 21244 | |
| 20279 | if (initializing) { | 21245 | if (initializing) { |
| 20280 | ZigValue *payload_val = create_const_vals(1); | 21246 | ZigValue *payload_val = create_const_vals(1); |
| ... | @@ -20295,17 +21261,16 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -20295,17 +21261,16 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 20295 | ir_add_error_node(ira, source_instr->source_node, | 21261 | ir_add_error_node(ira, source_instr->source_node, |
| 20296 | buf_sprintf("accessing union field '%s' while field '%s' is set", buf_ptr(field_name), | 21262 | buf_sprintf("accessing union field '%s' while field '%s' is set", buf_ptr(field_name), |
| 20297 | buf_ptr(actual_field->name))); | 21263 | buf_ptr(actual_field->name))); |
| 20298 | return ira->codegen->invalid_instruction; | 21264 | return ira->codegen->invalid_inst_gen; |
| 20299 | } | 21265 | } |
| 20300 | } | 21266 | } |
| 20301 | | 21267 | |
| 20302 | ZigValue *payload_val = union_val->data.x_union.payload; | 21268 | ZigValue *payload_val = union_val->data.x_union.payload; |
| 20303 | | 21269 | |
| 20304 | IrInstruction *result; | 21270 | IrInstGen *result; |
| 20305 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 21271 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 20306 | result = ir_build_union_field_ptr(&ira->new_irb, source_instr->scope, | 21272 | result = ir_build_union_field_ptr(ira, source_instr, container_ptr, field, true, |
| 20307 | source_instr->source_node, container_ptr, field, true, initializing); | 21273 | initializing, ptr_type); |
| 20308 | result->value->type = ptr_type; | | |
| 20309 | result->value->special = ConstValSpecialStatic; | 21274 | result->value->special = ConstValSpecialStatic; |
| 20310 | } else { | 21275 | } else { |
| 20311 | result = ir_const(ira, source_instr, ptr_type); | 21276 | result = ir_const(ira, source_instr, ptr_type); |
| ... | @@ -20318,10 +21283,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ | ... | @@ -20318,10 +21283,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 20318 | } | 21283 | } |
| 20319 | } | 21284 | } |
| 20320 | | 21285 | |
| 20321 | IrInstruction *result = ir_build_union_field_ptr(&ira->new_irb, source_instr->scope, | 21286 | return ir_build_union_field_ptr(ira, source_instr, container_ptr, field, true, initializing, ptr_type); |
| 20322 | source_instr->source_node, container_ptr, field, true, initializing); | | |
| 20323 | result->value->type = ptr_type; | | |
| 20324 | return result; | | |
| 20325 | } | 21287 | } |
| 20326 | | 21288 | |
| 20327 | zig_unreachable(); | 21289 | zig_unreachable(); |
| ... | @@ -20362,15 +21324,15 @@ static void add_link_lib_symbol(IrAnalyze *ira, Buf *lib_name, Buf *symbol_name, | ... | @@ -20362,15 +21324,15 @@ static void add_link_lib_symbol(IrAnalyze *ira, Buf *lib_name, Buf *symbol_name, |
| 20362 | link_lib->symbols.append(symbol_name); | 21324 | link_lib->symbols.append(symbol_name); |
| 20363 | } | 21325 | } |
| 20364 | | 21326 | |
| 20365 | static IrInstruction *ir_error_dependency_loop(IrAnalyze *ira, IrInstruction *source_instr) { | 21327 | static IrInstGen *ir_error_dependency_loop(IrAnalyze *ira, IrInst* source_instr) { |
| 20366 | ir_add_error(ira, source_instr, buf_sprintf("dependency loop detected")); | 21328 | ir_add_error(ira, source_instr, buf_sprintf("dependency loop detected")); |
| 20367 | return ira->codegen->invalid_instruction; | 21329 | return ira->codegen->invalid_inst_gen; |
| 20368 | } | 21330 | } |
| 20369 | | 21331 | |
| 20370 | static IrInstruction *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_instruction, Tld *tld) { | 21332 | static IrInstGen *ir_analyze_decl_ref(IrAnalyze *ira, IrInst* source_instruction, Tld *tld) { |
| 20371 | resolve_top_level_decl(ira->codegen, tld, source_instruction->source_node, true); | 21333 | resolve_top_level_decl(ira->codegen, tld, source_instruction->source_node, true); |
| 20372 | if (tld->resolution == TldResolutionInvalid) { | 21334 | if (tld->resolution == TldResolutionInvalid) { |
| 20373 | return ira->codegen->invalid_instruction; | 21335 | return ira->codegen->invalid_inst_gen; |
| 20374 | } | 21336 | } |
| 20375 | | 21337 | |
| 20376 | switch (tld->id) { | 21338 | switch (tld->id) { |
| ... | @@ -20397,14 +21359,13 @@ static IrInstruction *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -20397,14 +21359,13 @@ static IrInstruction *ir_analyze_decl_ref(IrAnalyze *ira, IrInstruction *source_ |
| 20397 | assert(fn_entry->type_entry); | 21359 | assert(fn_entry->type_entry); |
| 20398 | | 21360 | |
| 20399 | if (type_is_invalid(fn_entry->type_entry)) | 21361 | if (type_is_invalid(fn_entry->type_entry)) |
| 20400 | return ira->codegen->invalid_instruction; | 21362 | return ira->codegen->invalid_inst_gen; |
| 20401 | | 21363 | |
| 20402 | if (tld_fn->extern_lib_name != nullptr) { | 21364 | if (tld_fn->extern_lib_name != nullptr) { |
| 20403 | add_link_lib_symbol(ira, tld_fn->extern_lib_name, &fn_entry->symbol_name, source_instruction->source_node); | 21365 | add_link_lib_symbol(ira, tld_fn->extern_lib_name, &fn_entry->symbol_name, source_instruction->source_node); |
| 20404 | } | 21366 | } |
| 20405 | | 21367 | |
| 20406 | IrInstruction *fn_inst = ir_create_const_fn(&ira->new_irb, source_instruction->scope, | 21368 | IrInstGen *fn_inst = ir_const_fn(ira, source_instruction, fn_entry); |
| 20407 | source_instruction->source_node, fn_entry); | | |
| 20408 | return ir_get_ref(ira, source_instruction, fn_inst, true, false); | 21369 | return ir_get_ref(ira, source_instruction, fn_inst, true, false); |
| 20409 | } | 21370 | } |
| 20410 | } | 21371 | } |
| ... | @@ -20422,40 +21383,40 @@ static ErrorTableEntry *find_err_table_entry(ZigType *err_set_type, Buf *field_n | ... | @@ -20422,40 +21383,40 @@ static ErrorTableEntry *find_err_table_entry(ZigType *err_set_type, Buf *field_n |
| 20422 | return nullptr; | 21383 | return nullptr; |
| 20423 | } | 21384 | } |
| 20424 | | 21385 | |
| 20425 | static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstructionFieldPtr *field_ptr_instruction) { | 21386 | static IrInstGen *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstSrcFieldPtr *field_ptr_instruction) { |
| 20426 | Error err; | 21387 | Error err; |
| 20427 | IrInstruction *container_ptr = field_ptr_instruction->container_ptr->child; | 21388 | IrInstGen *container_ptr = field_ptr_instruction->container_ptr->child; |
| 20428 | if (type_is_invalid(container_ptr->value->type)) | 21389 | if (type_is_invalid(container_ptr->value->type)) |
| 20429 | return ira->codegen->invalid_instruction; | 21390 | return ira->codegen->invalid_inst_gen; |
| 20430 | | 21391 | |
| 20431 | ZigType *container_type = container_ptr->value->type->data.pointer.child_type; | 21392 | ZigType *container_type = container_ptr->value->type->data.pointer.child_type; |
| 20432 | | 21393 | |
| 20433 | Buf *field_name = field_ptr_instruction->field_name_buffer; | 21394 | Buf *field_name = field_ptr_instruction->field_name_buffer; |
| 20434 | if (!field_name) { | 21395 | if (!field_name) { |
| 20435 | IrInstruction *field_name_expr = field_ptr_instruction->field_name_expr->child; | 21396 | IrInstGen *field_name_expr = field_ptr_instruction->field_name_expr->child; |
| 20436 | field_name = ir_resolve_str(ira, field_name_expr); | 21397 | field_name = ir_resolve_str(ira, field_name_expr); |
| 20437 | if (!field_name) | 21398 | if (!field_name) |
| 20438 | return ira->codegen->invalid_instruction; | 21399 | return ira->codegen->invalid_inst_gen; |
| 20439 | } | 21400 | } |
| 20440 | | 21401 | |
| 20441 | | 21402 | |
| 20442 | AstNode *source_node = field_ptr_instruction->base.source_node; | 21403 | AstNode *source_node = field_ptr_instruction->base.base.source_node; |
| 20443 | | 21404 | |
| 20444 | if (type_is_invalid(container_type)) { | 21405 | if (type_is_invalid(container_type)) { |
| 20445 | return ira->codegen->invalid_instruction; | 21406 | return ira->codegen->invalid_inst_gen; |
| 20446 | } else if (is_tuple(container_type) && !field_ptr_instruction->initializing && buf_eql_str(field_name, "len")) { | 21407 | } else if (is_tuple(container_type) && !field_ptr_instruction->initializing && buf_eql_str(field_name, "len")) { |
| 20447 | IrInstruction *len_inst = ir_const_unsigned(ira, &field_ptr_instruction->base, | 21408 | IrInstGen *len_inst = ir_const_unsigned(ira, &field_ptr_instruction->base.base, |
| 20448 | container_type->data.structure.src_field_count); | 21409 | container_type->data.structure.src_field_count); |
| 20449 | return ir_get_ref(ira, &field_ptr_instruction->base, len_inst, true, false); | 21410 | return ir_get_ref(ira, &field_ptr_instruction->base.base, len_inst, true, false); |
| 20450 | } else if (is_slice(container_type) || is_container_ref(container_type)) { | 21411 | } else if (is_slice(container_type) || is_container_ref(container_type)) { |
| 20451 | assert(container_ptr->value->type->id == ZigTypeIdPointer); | 21412 | assert(container_ptr->value->type->id == ZigTypeIdPointer); |
| 20452 | if (container_type->id == ZigTypeIdPointer) { | 21413 | if (container_type->id == ZigTypeIdPointer) { |
| 20453 | ZigType *bare_type = container_ref_type(container_type); | 21414 | ZigType *bare_type = container_ref_type(container_type); |
| 20454 | IrInstruction *container_child = ir_get_deref(ira, &field_ptr_instruction->base, container_ptr, nullptr); | 21415 | IrInstGen *container_child = ir_get_deref(ira, &field_ptr_instruction->base.base, container_ptr, nullptr); |
| 20455 | IrInstruction *result = ir_analyze_container_field_ptr(ira, field_name, &field_ptr_instruction->base, container_child, bare_type, field_ptr_instruction->initializing); | 21416 | IrInstGen *result = ir_analyze_container_field_ptr(ira, field_name, &field_ptr_instruction->base.base, container_child, bare_type, field_ptr_instruction->initializing); |
| 20456 | return result; | 21417 | return result; |
| 20457 | } else { | 21418 | } else { |
| 20458 | IrInstruction *result = ir_analyze_container_field_ptr(ira, field_name, &field_ptr_instruction->base, container_ptr, container_type, field_ptr_instruction->initializing); | 21419 | IrInstGen *result = ir_analyze_container_field_ptr(ira, field_name, &field_ptr_instruction->base.base, container_ptr, container_type, field_ptr_instruction->initializing); |
| 20459 | return result; | 21420 | return result; |
| 20460 | } | 21421 | } |
| 20461 | } else if (is_array_ref(container_type) && !field_ptr_instruction->initializing) { | 21422 | } else if (is_array_ref(container_type) && !field_ptr_instruction->initializing) { |
| ... | @@ -20470,42 +21431,42 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -20470,42 +21431,42 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 20470 | ZigType *usize = ira->codegen->builtin_types.entry_usize; | 21431 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 20471 | bool ptr_is_const = true; | 21432 | bool ptr_is_const = true; |
| 20472 | bool ptr_is_volatile = false; | 21433 | bool ptr_is_volatile = false; |
| 20473 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, len_val, | 21434 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, len_val, |
| 20474 | usize, ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21435 | usize, ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20475 | } else { | 21436 | } else { |
| 20476 | ir_add_error_node(ira, source_node, | 21437 | ir_add_error_node(ira, source_node, |
| 20477 | buf_sprintf("no member named '%s' in '%s'", buf_ptr(field_name), | 21438 | buf_sprintf("no member named '%s' in '%s'", buf_ptr(field_name), |
| 20478 | buf_ptr(&container_type->name))); | 21439 | buf_ptr(&container_type->name))); |
| 20479 | return ira->codegen->invalid_instruction; | 21440 | return ira->codegen->invalid_inst_gen; |
| 20480 | } | 21441 | } |
| 20481 | } else if (container_type->id == ZigTypeIdMetaType) { | 21442 | } else if (container_type->id == ZigTypeIdMetaType) { |
| 20482 | ZigValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); | 21443 | ZigValue *container_ptr_val = ir_resolve_const(ira, container_ptr, UndefBad); |
| 20483 | if (!container_ptr_val) | 21444 | if (!container_ptr_val) |
| 20484 | return ira->codegen->invalid_instruction; | 21445 | return ira->codegen->invalid_inst_gen; |
| 20485 | | 21446 | |
| 20486 | assert(container_ptr->value->type->id == ZigTypeIdPointer); | 21447 | assert(container_ptr->value->type->id == ZigTypeIdPointer); |
| 20487 | ZigValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node); | 21448 | ZigValue *child_val = const_ptr_pointee(ira, ira->codegen, container_ptr_val, source_node); |
| 20488 | if (child_val == nullptr) | 21449 | if (child_val == nullptr) |
| 20489 | return ira->codegen->invalid_instruction; | 21450 | return ira->codegen->invalid_inst_gen; |
| 20490 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, | 21451 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, |
| 20491 | field_ptr_instruction->base.source_node, child_val, UndefBad))) | 21452 | field_ptr_instruction->base.base.source_node, child_val, UndefBad))) |
| 20492 | { | 21453 | { |
| 20493 | return ira->codegen->invalid_instruction; | 21454 | return ira->codegen->invalid_inst_gen; |
| 20494 | } | 21455 | } |
| 20495 | ZigType *child_type = child_val->data.x_type; | 21456 | ZigType *child_type = child_val->data.x_type; |
| 20496 | | 21457 | |
| 20497 | if (type_is_invalid(child_type)) { | 21458 | if (type_is_invalid(child_type)) { |
| 20498 | return ira->codegen->invalid_instruction; | 21459 | return ira->codegen->invalid_inst_gen; |
| 20499 | } else if (is_container(child_type)) { | 21460 | } else if (is_container(child_type)) { |
| 20500 | if (child_type->id == ZigTypeIdEnum) { | 21461 | if (child_type->id == ZigTypeIdEnum) { |
| 20501 | if ((err = type_resolve(ira->codegen, child_type, ResolveStatusSizeKnown))) | 21462 | if ((err = type_resolve(ira->codegen, child_type, ResolveStatusSizeKnown))) |
| 20502 | return ira->codegen->invalid_instruction; | 21463 | return ira->codegen->invalid_inst_gen; |
| 20503 | | 21464 | |
| 20504 | TypeEnumField *field = find_enum_type_field(child_type, field_name); | 21465 | TypeEnumField *field = find_enum_type_field(child_type, field_name); |
| 20505 | if (field) { | 21466 | if (field) { |
| 20506 | bool ptr_is_const = true; | 21467 | bool ptr_is_const = true; |
| 20507 | bool ptr_is_volatile = false; | 21468 | bool ptr_is_volatile = false; |
| 20508 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21469 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20509 | create_const_enum(child_type, &field->value), child_type, | 21470 | create_const_enum(child_type, &field->value), child_type, |
| 20510 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21471 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20511 | } | 21472 | } |
| ... | @@ -20514,37 +21475,37 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -20514,37 +21475,37 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 20514 | Tld *tld = find_container_decl(ira->codegen, container_scope, field_name); | 21475 | Tld *tld = find_container_decl(ira->codegen, container_scope, field_name); |
| 20515 | if (tld) { | 21476 | if (tld) { |
| 20516 | if (tld->visib_mod == VisibModPrivate && | 21477 | if (tld->visib_mod == VisibModPrivate && |
| 20517 | tld->import != get_scope_import(field_ptr_instruction->base.scope)) | 21478 | tld->import != get_scope_import(field_ptr_instruction->base.base.scope)) |
| 20518 | { | 21479 | { |
| 20519 | ErrorMsg *msg = ir_add_error(ira, &field_ptr_instruction->base, | 21480 | ErrorMsg *msg = ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20520 | buf_sprintf("'%s' is private", buf_ptr(field_name))); | 21481 | buf_sprintf("'%s' is private", buf_ptr(field_name))); |
| 20521 | add_error_note(ira->codegen, msg, tld->source_node, buf_sprintf("declared here")); | 21482 | add_error_note(ira->codegen, msg, tld->source_node, buf_sprintf("declared here")); |
| 20522 | return ira->codegen->invalid_instruction; | 21483 | return ira->codegen->invalid_inst_gen; |
| 20523 | } | 21484 | } |
| 20524 | return ir_analyze_decl_ref(ira, &field_ptr_instruction->base, tld); | 21485 | return ir_analyze_decl_ref(ira, &field_ptr_instruction->base.base, tld); |
| 20525 | } | 21486 | } |
| 20526 | if (child_type->id == ZigTypeIdUnion && | 21487 | if (child_type->id == ZigTypeIdUnion && |
| 20527 | (child_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr || | 21488 | (child_type->data.unionation.decl_node->data.container_decl.init_arg_expr != nullptr || |
| 20528 | child_type->data.unionation.decl_node->data.container_decl.auto_enum)) | 21489 | child_type->data.unionation.decl_node->data.container_decl.auto_enum)) |
| 20529 | { | 21490 | { |
| 20530 | if ((err = type_resolve(ira->codegen, child_type, ResolveStatusSizeKnown))) | 21491 | if ((err = type_resolve(ira->codegen, child_type, ResolveStatusSizeKnown))) |
| 20531 | return ira->codegen->invalid_instruction; | 21492 | return ira->codegen->invalid_inst_gen; |
| 20532 | TypeUnionField *field = find_union_type_field(child_type, field_name); | 21493 | TypeUnionField *field = find_union_type_field(child_type, field_name); |
| 20533 | if (field) { | 21494 | if (field) { |
| 20534 | ZigType *enum_type = child_type->data.unionation.tag_type; | 21495 | ZigType *enum_type = child_type->data.unionation.tag_type; |
| 20535 | bool ptr_is_const = true; | 21496 | bool ptr_is_const = true; |
| 20536 | bool ptr_is_volatile = false; | 21497 | bool ptr_is_volatile = false; |
| 20537 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21498 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20538 | create_const_enum(enum_type, &field->enum_field->value), enum_type, | 21499 | create_const_enum(enum_type, &field->enum_field->value), enum_type, |
| 20539 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21500 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20540 | } | 21501 | } |
| 20541 | } | 21502 | } |
| 20542 | const char *container_name = (child_type == ira->codegen->root_import) ? | 21503 | const char *container_name = (child_type == ira->codegen->root_import) ? |
| 20543 | "root source file" : buf_ptr(buf_sprintf("container '%s'", buf_ptr(&child_type->name))); | 21504 | "root source file" : buf_ptr(buf_sprintf("container '%s'", buf_ptr(&child_type->name))); |
| 20544 | ir_add_error(ira, &field_ptr_instruction->base, | 21505 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20545 | buf_sprintf("%s has no member called '%s'", | 21506 | buf_sprintf("%s has no member called '%s'", |
| 20546 | container_name, buf_ptr(field_name))); | 21507 | container_name, buf_ptr(field_name))); |
| 20547 | return ira->codegen->invalid_instruction; | 21508 | return ira->codegen->invalid_inst_gen; |
| 20548 | } else if (child_type->id == ZigTypeIdErrorSet) { | 21509 | } else if (child_type->id == ZigTypeIdErrorSet) { |
| 20549 | ErrorTableEntry *err_entry; | 21510 | ErrorTableEntry *err_entry; |
| 20550 | ZigType *err_set_type; | 21511 | ZigType *err_set_type; |
| ... | @@ -20554,7 +21515,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -20554,7 +21515,7 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 20554 | err_entry = existing_entry->value; | 21515 | err_entry = existing_entry->value; |
| 20555 | } else { | 21516 | } else { |
| 20556 | err_entry = allocate<ErrorTableEntry>(1); | 21517 | err_entry = allocate<ErrorTableEntry>(1); |
| 20557 | err_entry->decl_node = field_ptr_instruction->base.source_node; | 21518 | err_entry->decl_node = field_ptr_instruction->base.base.source_node; |
| 20558 | buf_init_from_buf(&err_entry->name, field_name); | 21519 | buf_init_from_buf(&err_entry->name, field_name); |
| 20559 | size_t error_value_count = ira->codegen->errors_by_index.length; | 21520 | size_t error_value_count = ira->codegen->errors_by_index.length; |
| 20560 | assert((uint32_t)error_value_count < (((uint32_t)1) << (uint32_t)ira->codegen->err_tag_type->data.integral.bit_count)); | 21521 | assert((uint32_t)error_value_count < (((uint32_t)1) << (uint32_t)ira->codegen->err_tag_type->data.integral.bit_count)); |
| ... | @@ -20564,19 +21525,19 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -20564,19 +21525,19 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 20564 | } | 21525 | } |
| 20565 | if (err_entry->set_with_only_this_in_it == nullptr) { | 21526 | if (err_entry->set_with_only_this_in_it == nullptr) { |
| 20566 | err_entry->set_with_only_this_in_it = make_err_set_with_one_item(ira->codegen, | 21527 | err_entry->set_with_only_this_in_it = make_err_set_with_one_item(ira->codegen, |
| 20567 | field_ptr_instruction->base.scope, field_ptr_instruction->base.source_node, | 21528 | field_ptr_instruction->base.base.scope, field_ptr_instruction->base.base.source_node, |
| 20568 | err_entry); | 21529 | err_entry); |
| 20569 | } | 21530 | } |
| 20570 | err_set_type = err_entry->set_with_only_this_in_it; | 21531 | err_set_type = err_entry->set_with_only_this_in_it; |
| 20571 | } else { | 21532 | } else { |
| 20572 | if (!resolve_inferred_error_set(ira->codegen, child_type, field_ptr_instruction->base.source_node)) { | 21533 | if (!resolve_inferred_error_set(ira->codegen, child_type, field_ptr_instruction->base.base.source_node)) { |
| 20573 | return ira->codegen->invalid_instruction; | 21534 | return ira->codegen->invalid_inst_gen; |
| 20574 | } | 21535 | } |
| 20575 | err_entry = find_err_table_entry(child_type, field_name); | 21536 | err_entry = find_err_table_entry(child_type, field_name); |
| 20576 | if (err_entry == nullptr) { | 21537 | if (err_entry == nullptr) { |
| 20577 | ir_add_error(ira, &field_ptr_instruction->base, | 21538 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20578 | buf_sprintf("no error named '%s' in '%s'", buf_ptr(field_name), buf_ptr(&child_type->name))); | 21539 | buf_sprintf("no error named '%s' in '%s'", buf_ptr(field_name), buf_ptr(&child_type->name))); |
| 20579 | return ira->codegen->invalid_instruction; | 21540 | return ira->codegen->invalid_inst_gen; |
| 20580 | } | 21541 | } |
| 20581 | err_set_type = child_type; | 21542 | err_set_type = child_type; |
| 20582 | } | 21543 | } |
| ... | @@ -20587,13 +21548,13 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -20587,13 +21548,13 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 20587 | | 21548 | |
| 20588 | bool ptr_is_const = true; | 21549 | bool ptr_is_const = true; |
| 20589 | bool ptr_is_volatile = false; | 21550 | bool ptr_is_volatile = false; |
| 20590 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, const_val, | 21551 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, const_val, |
| 20591 | err_set_type, ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21552 | err_set_type, ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20592 | } else if (child_type->id == ZigTypeIdInt) { | 21553 | } else if (child_type->id == ZigTypeIdInt) { |
| 20593 | if (buf_eql_str(field_name, "bit_count")) { | 21554 | if (buf_eql_str(field_name, "bit_count")) { |
| 20594 | bool ptr_is_const = true; | 21555 | bool ptr_is_const = true; |
| 20595 | bool ptr_is_volatile = false; | 21556 | bool ptr_is_volatile = false; |
| 20596 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21557 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20597 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, | 21558 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, |
| 20598 | child_type->data.integral.bit_count, false), | 21559 | child_type->data.integral.bit_count, false), |
| 20599 | ira->codegen->builtin_types.entry_num_lit_int, | 21560 | ira->codegen->builtin_types.entry_num_lit_int, |
| ... | @@ -20601,36 +21562,36 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -20601,36 +21562,36 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 20601 | } else if (buf_eql_str(field_name, "is_signed")) { | 21562 | } else if (buf_eql_str(field_name, "is_signed")) { |
| 20602 | bool ptr_is_const = true; | 21563 | bool ptr_is_const = true; |
| 20603 | bool ptr_is_volatile = false; | 21564 | bool ptr_is_volatile = false; |
| 20604 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21565 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20605 | create_const_bool(ira->codegen, child_type->data.integral.is_signed), | 21566 | create_const_bool(ira->codegen, child_type->data.integral.is_signed), |
| 20606 | ira->codegen->builtin_types.entry_bool, | 21567 | ira->codegen->builtin_types.entry_bool, |
| 20607 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21568 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20608 | } else { | 21569 | } else { |
| 20609 | ir_add_error(ira, &field_ptr_instruction->base, | 21570 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20610 | buf_sprintf("type '%s' has no member called '%s'", | 21571 | buf_sprintf("type '%s' has no member called '%s'", |
| 20611 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 21572 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 20612 | return ira->codegen->invalid_instruction; | 21573 | return ira->codegen->invalid_inst_gen; |
| 20613 | } | 21574 | } |
| 20614 | } else if (child_type->id == ZigTypeIdFloat) { | 21575 | } else if (child_type->id == ZigTypeIdFloat) { |
| 20615 | if (buf_eql_str(field_name, "bit_count")) { | 21576 | if (buf_eql_str(field_name, "bit_count")) { |
| 20616 | bool ptr_is_const = true; | 21577 | bool ptr_is_const = true; |
| 20617 | bool ptr_is_volatile = false; | 21578 | bool ptr_is_volatile = false; |
| 20618 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21579 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20619 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, | 21580 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, |
| 20620 | child_type->data.floating.bit_count, false), | 21581 | child_type->data.floating.bit_count, false), |
| 20621 | ira->codegen->builtin_types.entry_num_lit_int, | 21582 | ira->codegen->builtin_types.entry_num_lit_int, |
| 20622 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21583 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20623 | } else { | 21584 | } else { |
| 20624 | ir_add_error(ira, &field_ptr_instruction->base, | 21585 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20625 | buf_sprintf("type '%s' has no member called '%s'", | 21586 | buf_sprintf("type '%s' has no member called '%s'", |
| 20626 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 21587 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 20627 | return ira->codegen->invalid_instruction; | 21588 | return ira->codegen->invalid_inst_gen; |
| 20628 | } | 21589 | } |
| 20629 | } else if (child_type->id == ZigTypeIdPointer) { | 21590 | } else if (child_type->id == ZigTypeIdPointer) { |
| 20630 | if (buf_eql_str(field_name, "Child")) { | 21591 | if (buf_eql_str(field_name, "Child")) { |
| 20631 | bool ptr_is_const = true; | 21592 | bool ptr_is_const = true; |
| 20632 | bool ptr_is_volatile = false; | 21593 | bool ptr_is_volatile = false; |
| 20633 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21594 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20634 | create_const_type(ira->codegen, child_type->data.pointer.child_type), | 21595 | create_const_type(ira->codegen, child_type->data.pointer.child_type), |
| 20635 | ira->codegen->builtin_types.entry_type, | 21596 | ira->codegen->builtin_types.entry_type, |
| 20636 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21597 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| ... | @@ -20640,75 +21601,75 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -20640,75 +21601,75 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 20640 | if ((err = type_resolve(ira->codegen, child_type->data.pointer.child_type, | 21601 | if ((err = type_resolve(ira->codegen, child_type->data.pointer.child_type, |
| 20641 | ResolveStatusAlignmentKnown))) | 21602 | ResolveStatusAlignmentKnown))) |
| 20642 | { | 21603 | { |
| 20643 | return ira->codegen->invalid_instruction; | 21604 | return ira->codegen->invalid_inst_gen; |
| 20644 | } | 21605 | } |
| 20645 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21606 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20646 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, | 21607 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, |
| 20647 | get_ptr_align(ira->codegen, child_type), false), | 21608 | get_ptr_align(ira->codegen, child_type), false), |
| 20648 | ira->codegen->builtin_types.entry_num_lit_int, | 21609 | ira->codegen->builtin_types.entry_num_lit_int, |
| 20649 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21610 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20650 | } else { | 21611 | } else { |
| 20651 | ir_add_error(ira, &field_ptr_instruction->base, | 21612 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20652 | buf_sprintf("type '%s' has no member called '%s'", | 21613 | buf_sprintf("type '%s' has no member called '%s'", |
| 20653 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 21614 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 20654 | return ira->codegen->invalid_instruction; | 21615 | return ira->codegen->invalid_inst_gen; |
| 20655 | } | 21616 | } |
| 20656 | } else if (child_type->id == ZigTypeIdArray) { | 21617 | } else if (child_type->id == ZigTypeIdArray) { |
| 20657 | if (buf_eql_str(field_name, "Child")) { | 21618 | if (buf_eql_str(field_name, "Child")) { |
| 20658 | bool ptr_is_const = true; | 21619 | bool ptr_is_const = true; |
| 20659 | bool ptr_is_volatile = false; | 21620 | bool ptr_is_volatile = false; |
| 20660 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21621 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20661 | create_const_type(ira->codegen, child_type->data.array.child_type), | 21622 | create_const_type(ira->codegen, child_type->data.array.child_type), |
| 20662 | ira->codegen->builtin_types.entry_type, | 21623 | ira->codegen->builtin_types.entry_type, |
| 20663 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21624 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20664 | } else if (buf_eql_str(field_name, "len")) { | 21625 | } else if (buf_eql_str(field_name, "len")) { |
| 20665 | bool ptr_is_const = true; | 21626 | bool ptr_is_const = true; |
| 20666 | bool ptr_is_volatile = false; | 21627 | bool ptr_is_volatile = false; |
| 20667 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21628 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20668 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, | 21629 | create_const_unsigned_negative(ira->codegen->builtin_types.entry_num_lit_int, |
| 20669 | child_type->data.array.len, false), | 21630 | child_type->data.array.len, false), |
| 20670 | ira->codegen->builtin_types.entry_num_lit_int, | 21631 | ira->codegen->builtin_types.entry_num_lit_int, |
| 20671 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21632 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20672 | } else { | 21633 | } else { |
| 20673 | ir_add_error(ira, &field_ptr_instruction->base, | 21634 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20674 | buf_sprintf("type '%s' has no member called '%s'", | 21635 | buf_sprintf("type '%s' has no member called '%s'", |
| 20675 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 21636 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 20676 | return ira->codegen->invalid_instruction; | 21637 | return ira->codegen->invalid_inst_gen; |
| 20677 | } | 21638 | } |
| 20678 | } else if (child_type->id == ZigTypeIdErrorUnion) { | 21639 | } else if (child_type->id == ZigTypeIdErrorUnion) { |
| 20679 | if (buf_eql_str(field_name, "Payload")) { | 21640 | if (buf_eql_str(field_name, "Payload")) { |
| 20680 | bool ptr_is_const = true; | 21641 | bool ptr_is_const = true; |
| 20681 | bool ptr_is_volatile = false; | 21642 | bool ptr_is_volatile = false; |
| 20682 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21643 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20683 | create_const_type(ira->codegen, child_type->data.error_union.payload_type), | 21644 | create_const_type(ira->codegen, child_type->data.error_union.payload_type), |
| 20684 | ira->codegen->builtin_types.entry_type, | 21645 | ira->codegen->builtin_types.entry_type, |
| 20685 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21646 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20686 | } else if (buf_eql_str(field_name, "ErrorSet")) { | 21647 | } else if (buf_eql_str(field_name, "ErrorSet")) { |
| 20687 | bool ptr_is_const = true; | 21648 | bool ptr_is_const = true; |
| 20688 | bool ptr_is_volatile = false; | 21649 | bool ptr_is_volatile = false; |
| 20689 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21650 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20690 | create_const_type(ira->codegen, child_type->data.error_union.err_set_type), | 21651 | create_const_type(ira->codegen, child_type->data.error_union.err_set_type), |
| 20691 | ira->codegen->builtin_types.entry_type, | 21652 | ira->codegen->builtin_types.entry_type, |
| 20692 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21653 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20693 | } else { | 21654 | } else { |
| 20694 | ir_add_error(ira, &field_ptr_instruction->base, | 21655 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20695 | buf_sprintf("type '%s' has no member called '%s'", | 21656 | buf_sprintf("type '%s' has no member called '%s'", |
| 20696 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 21657 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 20697 | return ira->codegen->invalid_instruction; | 21658 | return ira->codegen->invalid_inst_gen; |
| 20698 | } | 21659 | } |
| 20699 | } else if (child_type->id == ZigTypeIdOptional) { | 21660 | } else if (child_type->id == ZigTypeIdOptional) { |
| 20700 | if (buf_eql_str(field_name, "Child")) { | 21661 | if (buf_eql_str(field_name, "Child")) { |
| 20701 | bool ptr_is_const = true; | 21662 | bool ptr_is_const = true; |
| 20702 | bool ptr_is_volatile = false; | 21663 | bool ptr_is_volatile = false; |
| 20703 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21664 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20704 | create_const_type(ira->codegen, child_type->data.maybe.child_type), | 21665 | create_const_type(ira->codegen, child_type->data.maybe.child_type), |
| 20705 | ira->codegen->builtin_types.entry_type, | 21666 | ira->codegen->builtin_types.entry_type, |
| 20706 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21667 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20707 | } else { | 21668 | } else { |
| 20708 | ir_add_error(ira, &field_ptr_instruction->base, | 21669 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20709 | buf_sprintf("type '%s' has no member called '%s'", | 21670 | buf_sprintf("type '%s' has no member called '%s'", |
| 20710 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 21671 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 20711 | return ira->codegen->invalid_instruction; | 21672 | return ira->codegen->invalid_inst_gen; |
| 20712 | } | 21673 | } |
| 20713 | } else if (child_type->id == ZigTypeIdFn) { | 21674 | } else if (child_type->id == ZigTypeIdFn) { |
| 20714 | if (buf_eql_str(field_name, "ReturnType")) { | 21675 | if (buf_eql_str(field_name, "ReturnType")) { |
| ... | @@ -20716,121 +21677,121 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc | ... | @@ -20716,121 +21677,121 @@ static IrInstruction *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstruc |
| 20716 | // Return type can only ever be null, if the function is generic | 21677 | // Return type can only ever be null, if the function is generic |
| 20717 | assert(child_type->data.fn.is_generic); | 21678 | assert(child_type->data.fn.is_generic); |
| 20718 | | 21679 | |
| 20719 | ir_add_error(ira, &field_ptr_instruction->base, | 21680 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20720 | buf_sprintf("ReturnType has not been resolved because '%s' is generic", buf_ptr(&child_type->name))); | 21681 | buf_sprintf("ReturnType has not been resolved because '%s' is generic", buf_ptr(&child_type->name))); |
| 20721 | return ira->codegen->invalid_instruction; | 21682 | return ira->codegen->invalid_inst_gen; |
| 20722 | } | 21683 | } |
| 20723 | | 21684 | |
| 20724 | bool ptr_is_const = true; | 21685 | bool ptr_is_const = true; |
| 20725 | bool ptr_is_volatile = false; | 21686 | bool ptr_is_volatile = false; |
| 20726 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21687 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20727 | create_const_type(ira->codegen, child_type->data.fn.fn_type_id.return_type), | 21688 | create_const_type(ira->codegen, child_type->data.fn.fn_type_id.return_type), |
| 20728 | ira->codegen->builtin_types.entry_type, | 21689 | ira->codegen->builtin_types.entry_type, |
| 20729 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21690 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20730 | } else if (buf_eql_str(field_name, "is_var_args")) { | 21691 | } else if (buf_eql_str(field_name, "is_var_args")) { |
| 20731 | bool ptr_is_const = true; | 21692 | bool ptr_is_const = true; |
| 20732 | bool ptr_is_volatile = false; | 21693 | bool ptr_is_volatile = false; |
| 20733 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21694 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20734 | create_const_bool(ira->codegen, child_type->data.fn.fn_type_id.is_var_args), | 21695 | create_const_bool(ira->codegen, child_type->data.fn.fn_type_id.is_var_args), |
| 20735 | ira->codegen->builtin_types.entry_bool, | 21696 | ira->codegen->builtin_types.entry_bool, |
| 20736 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21697 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20737 | } else if (buf_eql_str(field_name, "arg_count")) { | 21698 | } else if (buf_eql_str(field_name, "arg_count")) { |
| 20738 | bool ptr_is_const = true; | 21699 | bool ptr_is_const = true; |
| 20739 | bool ptr_is_volatile = false; | 21700 | bool ptr_is_volatile = false; |
| 20740 | return ir_get_const_ptr(ira, &field_ptr_instruction->base, | 21701 | return ir_get_const_ptr(ira, &field_ptr_instruction->base.base, |
| 20741 | create_const_usize(ira->codegen, child_type->data.fn.fn_type_id.param_count), | 21702 | create_const_usize(ira->codegen, child_type->data.fn.fn_type_id.param_count), |
| 20742 | ira->codegen->builtin_types.entry_usize, | 21703 | ira->codegen->builtin_types.entry_usize, |
| 20743 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); | 21704 | ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile, 0); |
| 20744 | } else { | 21705 | } else { |
| 20745 | ir_add_error(ira, &field_ptr_instruction->base, | 21706 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20746 | buf_sprintf("type '%s' has no member called '%s'", | 21707 | buf_sprintf("type '%s' has no member called '%s'", |
| 20747 | buf_ptr(&child_type->name), buf_ptr(field_name))); | 21708 | buf_ptr(&child_type->name), buf_ptr(field_name))); |
| 20748 | return ira->codegen->invalid_instruction; | 21709 | return ira->codegen->invalid_inst_gen; |
| 20749 | } | 21710 | } |
| 20750 | } else { | 21711 | } else { |
| 20751 | ir_add_error(ira, &field_ptr_instruction->base, | 21712 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20752 | buf_sprintf("type '%s' does not support field access", buf_ptr(&child_type->name))); | 21713 | buf_sprintf("type '%s' does not support field access", buf_ptr(&child_type->name))); |
| 20753 | return ira->codegen->invalid_instruction; | 21714 | return ira->codegen->invalid_inst_gen; |
| 20754 | } | 21715 | } |
| 20755 | } else if (field_ptr_instruction->initializing) { | 21716 | } else if (field_ptr_instruction->initializing) { |
| 20756 | ir_add_error(ira, &field_ptr_instruction->base, | 21717 | ir_add_error(ira, &field_ptr_instruction->base.base, |
| 20757 | buf_sprintf("type '%s' does not support struct initialization syntax", buf_ptr(&container_type->name))); | 21718 | buf_sprintf("type '%s' does not support struct initialization syntax", buf_ptr(&container_type->name))); |
| 20758 | return ira->codegen->invalid_instruction; | 21719 | return ira->codegen->invalid_inst_gen; |
| 20759 | } else { | 21720 | } else { |
| 20760 | ir_add_error_node(ira, field_ptr_instruction->base.source_node, | 21721 | ir_add_error_node(ira, field_ptr_instruction->base.base.source_node, |
| 20761 | buf_sprintf("type '%s' does not support field access", buf_ptr(&container_type->name))); | 21722 | buf_sprintf("type '%s' does not support field access", buf_ptr(&container_type->name))); |
| 20762 | return ira->codegen->invalid_instruction; | 21723 | return ira->codegen->invalid_inst_gen; |
| 20763 | } | 21724 | } |
| 20764 | } | 21725 | } |
| 20765 | | 21726 | |
| 20766 | static IrInstruction *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstructionStorePtr *instruction) { | 21727 | static IrInstGen *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstSrcStorePtr *instruction) { |
| 20767 | IrInstruction *ptr = instruction->ptr->child; | 21728 | IrInstGen *ptr = instruction->ptr->child; |
| 20768 | if (type_is_invalid(ptr->value->type)) | 21729 | if (type_is_invalid(ptr->value->type)) |
| 20769 | return ira->codegen->invalid_instruction; | 21730 | return ira->codegen->invalid_inst_gen; |
| 20770 | | 21731 | |
| 20771 | IrInstruction *value = instruction->value->child; | 21732 | IrInstGen *value = instruction->value->child; |
| 20772 | if (type_is_invalid(value->value->type)) | 21733 | if (type_is_invalid(value->value->type)) |
| 20773 | return ira->codegen->invalid_instruction; | 21734 | return ira->codegen->invalid_inst_gen; |
| 20774 | | 21735 | |
| 20775 | return ir_analyze_store_ptr(ira, &instruction->base, ptr, value, instruction->allow_write_through_const); | 21736 | return ir_analyze_store_ptr(ira, &instruction->base.base, ptr, value, instruction->allow_write_through_const); |
| 20776 | } | 21737 | } |
| 20777 | | 21738 | |
| 20778 | static IrInstruction *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstructionLoadPtr *instruction) { | 21739 | static IrInstGen *ir_analyze_instruction_load_ptr(IrAnalyze *ira, IrInstSrcLoadPtr *instruction) { |
| 20779 | IrInstruction *ptr = instruction->ptr->child; | 21740 | IrInstGen *ptr = instruction->ptr->child; |
| 20780 | if (type_is_invalid(ptr->value->type)) | 21741 | if (type_is_invalid(ptr->value->type)) |
| 20781 | return ira->codegen->invalid_instruction; | 21742 | return ira->codegen->invalid_inst_gen; |
| 20782 | return ir_get_deref(ira, &instruction->base, ptr, nullptr); | 21743 | return ir_get_deref(ira, &instruction->base.base, ptr, nullptr); |
| 20783 | } | 21744 | } |
| 20784 | | 21745 | |
| 20785 | static IrInstruction *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructionTypeOf *typeof_instruction) { | 21746 | static IrInstGen *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstSrcTypeOf *typeof_instruction) { |
| 20786 | IrInstruction *expr_value = typeof_instruction->value->child; | 21747 | IrInstGen *expr_value = typeof_instruction->value->child; |
| 20787 | ZigType *type_entry = expr_value->value->type; | 21748 | ZigType *type_entry = expr_value->value->type; |
| 20788 | if (type_is_invalid(type_entry)) | 21749 | if (type_is_invalid(type_entry)) |
| 20789 | return ira->codegen->invalid_instruction; | 21750 | return ira->codegen->invalid_inst_gen; |
| 20790 | return ir_const_type(ira, &typeof_instruction->base, type_entry); | 21751 | return ir_const_type(ira, &typeof_instruction->base.base, type_entry); |
| 20791 | } | 21752 | } |
| 20792 | | 21753 | |
| 20793 | static IrInstruction *ir_analyze_instruction_set_cold(IrAnalyze *ira, IrInstructionSetCold *instruction) { | 21754 | static IrInstGen *ir_analyze_instruction_set_cold(IrAnalyze *ira, IrInstSrcSetCold *instruction) { |
| 20794 | if (ira->new_irb.exec->is_inline) { | 21755 | if (ira->new_irb.exec->is_inline) { |
| 20795 | // ignore setCold when running functions at compile time | 21756 | // ignore setCold when running functions at compile time |
| 20796 | return ir_const_void(ira, &instruction->base); | 21757 | return ir_const_void(ira, &instruction->base.base); |
| 20797 | } | 21758 | } |
| 20798 | | 21759 | |
| 20799 | IrInstruction *is_cold_value = instruction->is_cold->child; | 21760 | IrInstGen *is_cold_value = instruction->is_cold->child; |
| 20800 | bool want_cold; | 21761 | bool want_cold; |
| 20801 | if (!ir_resolve_bool(ira, is_cold_value, &want_cold)) | 21762 | if (!ir_resolve_bool(ira, is_cold_value, &want_cold)) |
| 20802 | return ira->codegen->invalid_instruction; | 21763 | return ira->codegen->invalid_inst_gen; |
| 20803 | | 21764 | |
| 20804 | ZigFn *fn_entry = scope_fn_entry(instruction->base.scope); | 21765 | ZigFn *fn_entry = scope_fn_entry(instruction->base.base.scope); |
| 20805 | if (fn_entry == nullptr) { | 21766 | if (fn_entry == nullptr) { |
| 20806 | ir_add_error(ira, &instruction->base, buf_sprintf("@setCold outside function")); | 21767 | ir_add_error(ira, &instruction->base.base, buf_sprintf("@setCold outside function")); |
| 20807 | return ira->codegen->invalid_instruction; | 21768 | return ira->codegen->invalid_inst_gen; |
| 20808 | } | 21769 | } |
| 20809 | | 21770 | |
| 20810 | if (fn_entry->set_cold_node != nullptr) { | 21771 | if (fn_entry->set_cold_node != nullptr) { |
| 20811 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, buf_sprintf("cold set twice in same function")); | 21772 | ErrorMsg *msg = ir_add_error(ira, &instruction->base.base, buf_sprintf("cold set twice in same function")); |
| 20812 | add_error_note(ira->codegen, msg, fn_entry->set_cold_node, buf_sprintf("first set here")); | 21773 | add_error_note(ira->codegen, msg, fn_entry->set_cold_node, buf_sprintf("first set here")); |
| 20813 | return ira->codegen->invalid_instruction; | 21774 | return ira->codegen->invalid_inst_gen; |
| 20814 | } | 21775 | } |
| 20815 | | 21776 | |
| 20816 | fn_entry->set_cold_node = instruction->base.source_node; | 21777 | fn_entry->set_cold_node = instruction->base.base.source_node; |
| 20817 | fn_entry->is_cold = want_cold; | 21778 | fn_entry->is_cold = want_cold; |
| 20818 | | 21779 | |
| 20819 | return ir_const_void(ira, &instruction->base); | 21780 | return ir_const_void(ira, &instruction->base.base); |
| 20820 | } | 21781 | } |
| 20821 | | 21782 | |
| 20822 | static IrInstruction *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira, | 21783 | static IrInstGen *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira, |
| 20823 | IrInstructionSetRuntimeSafety *set_runtime_safety_instruction) | 21784 | IrInstSrcSetRuntimeSafety *set_runtime_safety_instruction) |
| 20824 | { | 21785 | { |
| 20825 | if (ira->new_irb.exec->is_inline) { | 21786 | if (ira->new_irb.exec->is_inline) { |
| 20826 | // ignore setRuntimeSafety when running functions at compile time | 21787 | // ignore setRuntimeSafety when running functions at compile time |
| 20827 | return ir_const_void(ira, &set_runtime_safety_instruction->base); | 21788 | return ir_const_void(ira, &set_runtime_safety_instruction->base.base); |
| 20828 | } | 21789 | } |
| 20829 | | 21790 | |
| 20830 | bool *safety_off_ptr; | 21791 | bool *safety_off_ptr; |
| 20831 | AstNode **safety_set_node_ptr; | 21792 | AstNode **safety_set_node_ptr; |
| 20832 | | 21793 | |
| 20833 | Scope *scope = set_runtime_safety_instruction->base.scope; | 21794 | Scope *scope = set_runtime_safety_instruction->base.base.scope; |
| 20834 | while (scope != nullptr) { | 21795 | while (scope != nullptr) { |
| 20835 | if (scope->id == ScopeIdBlock) { | 21796 | if (scope->id == ScopeIdBlock) { |
| 20836 | ScopeBlock *block_scope = (ScopeBlock *)scope; | 21797 | ScopeBlock *block_scope = (ScopeBlock *)scope; |
| ... | @@ -20856,36 +21817,36 @@ static IrInstruction *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira, | ... | @@ -20856,36 +21817,36 @@ static IrInstruction *ir_analyze_instruction_set_runtime_safety(IrAnalyze *ira, |
| 20856 | } | 21817 | } |
| 20857 | assert(scope != nullptr); | 21818 | assert(scope != nullptr); |
| 20858 | | 21819 | |
| 20859 | IrInstruction *safety_on_value = set_runtime_safety_instruction->safety_on->child; | 21820 | IrInstGen *safety_on_value = set_runtime_safety_instruction->safety_on->child; |
| 20860 | bool want_runtime_safety; | 21821 | bool want_runtime_safety; |
| 20861 | if (!ir_resolve_bool(ira, safety_on_value, &want_runtime_safety)) | 21822 | if (!ir_resolve_bool(ira, safety_on_value, &want_runtime_safety)) |
| 20862 | return ira->codegen->invalid_instruction; | 21823 | return ira->codegen->invalid_inst_gen; |
| 20863 | | 21824 | |
| 20864 | AstNode *source_node = set_runtime_safety_instruction->base.source_node; | 21825 | AstNode *source_node = set_runtime_safety_instruction->base.base.source_node; |
| 20865 | if (*safety_set_node_ptr) { | 21826 | if (*safety_set_node_ptr) { |
| 20866 | ErrorMsg *msg = ir_add_error_node(ira, source_node, | 21827 | ErrorMsg *msg = ir_add_error_node(ira, source_node, |
| 20867 | buf_sprintf("runtime safety set twice for same scope")); | 21828 | buf_sprintf("runtime safety set twice for same scope")); |
| 20868 | add_error_note(ira->codegen, msg, *safety_set_node_ptr, buf_sprintf("first set here")); | 21829 | add_error_note(ira->codegen, msg, *safety_set_node_ptr, buf_sprintf("first set here")); |
| 20869 | return ira->codegen->invalid_instruction; | 21830 | return ira->codegen->invalid_inst_gen; |
| 20870 | } | 21831 | } |
| 20871 | *safety_set_node_ptr = source_node; | 21832 | *safety_set_node_ptr = source_node; |
| 20872 | *safety_off_ptr = !want_runtime_safety; | 21833 | *safety_off_ptr = !want_runtime_safety; |
| 20873 | | 21834 | |
| 20874 | return ir_const_void(ira, &set_runtime_safety_instruction->base); | 21835 | return ir_const_void(ira, &set_runtime_safety_instruction->base.base); |
| 20875 | } | 21836 | } |
| 20876 | | 21837 | |
| 20877 | static IrInstruction *ir_analyze_instruction_set_float_mode(IrAnalyze *ira, | 21838 | static IrInstGen *ir_analyze_instruction_set_float_mode(IrAnalyze *ira, |
| 20878 | IrInstructionSetFloatMode *instruction) | 21839 | IrInstSrcSetFloatMode *instruction) |
| 20879 | { | 21840 | { |
| 20880 | if (ira->new_irb.exec->is_inline) { | 21841 | if (ira->new_irb.exec->is_inline) { |
| 20881 | // ignore setFloatMode when running functions at compile time | 21842 | // ignore setFloatMode when running functions at compile time |
| 20882 | return ir_const_void(ira, &instruction->base); | 21843 | return ir_const_void(ira, &instruction->base.base); |
| 20883 | } | 21844 | } |
| 20884 | | 21845 | |
| 20885 | bool *fast_math_on_ptr; | 21846 | bool *fast_math_on_ptr; |
| 20886 | AstNode **fast_math_set_node_ptr; | 21847 | AstNode **fast_math_set_node_ptr; |
| 20887 | | 21848 | |
| 20888 | Scope *scope = instruction->base.scope; | 21849 | Scope *scope = instruction->base.base.scope; |
| 20889 | while (scope != nullptr) { | 21850 | while (scope != nullptr) { |
| 20890 | if (scope->id == ScopeIdBlock) { | 21851 | if (scope->id == ScopeIdBlock) { |
| 20891 | ScopeBlock *block_scope = (ScopeBlock *)scope; | 21852 | ScopeBlock *block_scope = (ScopeBlock *)scope; |
| ... | @@ -20911,42 +21872,38 @@ static IrInstruction *ir_analyze_instruction_set_float_mode(IrAnalyze *ira, | ... | @@ -20911,42 +21872,38 @@ static IrInstruction *ir_analyze_instruction_set_float_mode(IrAnalyze *ira, |
| 20911 | } | 21872 | } |
| 20912 | assert(scope != nullptr); | 21873 | assert(scope != nullptr); |
| 20913 | | 21874 | |
| 20914 | IrInstruction *float_mode_value = instruction->mode_value->child; | 21875 | IrInstGen *float_mode_value = instruction->mode_value->child; |
| 20915 | FloatMode float_mode_scalar; | 21876 | FloatMode float_mode_scalar; |
| 20916 | if (!ir_resolve_float_mode(ira, float_mode_value, &float_mode_scalar)) | 21877 | if (!ir_resolve_float_mode(ira, float_mode_value, &float_mode_scalar)) |
| 20917 | return ira->codegen->invalid_instruction; | 21878 | return ira->codegen->invalid_inst_gen; |
| 20918 | | 21879 | |
| 20919 | AstNode *source_node = instruction->base.source_node; | 21880 | AstNode *source_node = instruction->base.base.source_node; |
| 20920 | if (*fast_math_set_node_ptr) { | 21881 | if (*fast_math_set_node_ptr) { |
| 20921 | ErrorMsg *msg = ir_add_error_node(ira, source_node, | 21882 | ErrorMsg *msg = ir_add_error_node(ira, source_node, |
| 20922 | buf_sprintf("float mode set twice for same scope")); | 21883 | buf_sprintf("float mode set twice for same scope")); |
| 20923 | add_error_note(ira->codegen, msg, *fast_math_set_node_ptr, buf_sprintf("first set here")); | 21884 | add_error_note(ira->codegen, msg, *fast_math_set_node_ptr, buf_sprintf("first set here")); |
| 20924 | return ira->codegen->invalid_instruction; | 21885 | return ira->codegen->invalid_inst_gen; |
| 20925 | } | 21886 | } |
| 20926 | *fast_math_set_node_ptr = source_node; | 21887 | *fast_math_set_node_ptr = source_node; |
| 20927 | *fast_math_on_ptr = (float_mode_scalar == FloatModeOptimized); | 21888 | *fast_math_on_ptr = (float_mode_scalar == FloatModeOptimized); |
| 20928 | | 21889 | |
| 20929 | return ir_const_void(ira, &instruction->base); | 21890 | return ir_const_void(ira, &instruction->base.base); |
| 20930 | } | 21891 | } |
| 20931 | | 21892 | |
| 20932 | static IrInstruction *ir_analyze_instruction_any_frame_type(IrAnalyze *ira, | 21893 | static IrInstGen *ir_analyze_instruction_any_frame_type(IrAnalyze *ira, IrInstSrcAnyFrameType *instruction) { |
| 20933 | IrInstructionAnyFrameType *instruction) | | |
| 20934 | { | | |
| 20935 | ZigType *payload_type = nullptr; | 21894 | ZigType *payload_type = nullptr; |
| 20936 | if (instruction->payload_type != nullptr) { | 21895 | if (instruction->payload_type != nullptr) { |
| 20937 | payload_type = ir_resolve_type(ira, instruction->payload_type->child); | 21896 | payload_type = ir_resolve_type(ira, instruction->payload_type->child); |
| 20938 | if (type_is_invalid(payload_type)) | 21897 | if (type_is_invalid(payload_type)) |
| 20939 | return ira->codegen->invalid_instruction; | 21898 | return ira->codegen->invalid_inst_gen; |
| 20940 | } | 21899 | } |
| 20941 | | 21900 | |
| 20942 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, payload_type); | 21901 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, payload_type); |
| 20943 | return ir_const_type(ira, &instruction->base, any_frame_type); | 21902 | return ir_const_type(ira, &instruction->base.base, any_frame_type); |
| 20944 | } | 21903 | } |
| 20945 | | 21904 | |
| 20946 | static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, | 21905 | static IrInstGen *ir_analyze_instruction_slice_type(IrAnalyze *ira, IrInstSrcSliceType *slice_type_instruction) { |
| 20947 | IrInstructionSliceType *slice_type_instruction) | 21906 | IrInstGen *result = ir_const(ira, &slice_type_instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 20948 | { | | |
| 20949 | IrInstruction *result = ir_const(ira, &slice_type_instruction->base, ira->codegen->builtin_types.entry_type); | | |
| 20950 | result->value->special = ConstValSpecialLazy; | 21907 | result->value->special = ConstValSpecialLazy; |
| 20951 | | 21908 | |
| 20952 | LazyValueSliceType *lazy_slice_type = allocate<LazyValueSliceType>(1, "LazyValueSliceType"); | 21909 | LazyValueSliceType *lazy_slice_type = allocate<LazyValueSliceType>(1, "LazyValueSliceType"); |
| ... | @@ -20957,18 +21914,18 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, | ... | @@ -20957,18 +21914,18 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, |
| 20957 | if (slice_type_instruction->align_value != nullptr) { | 21914 | if (slice_type_instruction->align_value != nullptr) { |
| 20958 | lazy_slice_type->align_inst = slice_type_instruction->align_value->child; | 21915 | lazy_slice_type->align_inst = slice_type_instruction->align_value->child; |
| 20959 | if (ir_resolve_const(ira, lazy_slice_type->align_inst, LazyOk) == nullptr) | 21916 | if (ir_resolve_const(ira, lazy_slice_type->align_inst, LazyOk) == nullptr) |
| 20960 | return ira->codegen->invalid_instruction; | 21917 | return ira->codegen->invalid_inst_gen; |
| 20961 | } | 21918 | } |
| 20962 | | 21919 | |
| 20963 | if (slice_type_instruction->sentinel != nullptr) { | 21920 | if (slice_type_instruction->sentinel != nullptr) { |
| 20964 | lazy_slice_type->sentinel = slice_type_instruction->sentinel->child; | 21921 | lazy_slice_type->sentinel = slice_type_instruction->sentinel->child; |
| 20965 | if (ir_resolve_const(ira, lazy_slice_type->sentinel, LazyOk) == nullptr) | 21922 | if (ir_resolve_const(ira, lazy_slice_type->sentinel, LazyOk) == nullptr) |
| 20966 | return ira->codegen->invalid_instruction; | 21923 | return ira->codegen->invalid_inst_gen; |
| 20967 | } | 21924 | } |
| 20968 | | 21925 | |
| 20969 | lazy_slice_type->elem_type = slice_type_instruction->child_type->child; | 21926 | lazy_slice_type->elem_type = slice_type_instruction->child_type->child; |
| 20970 | if (ir_resolve_type_lazy(ira, lazy_slice_type->elem_type) == nullptr) | 21927 | if (ir_resolve_type_lazy(ira, lazy_slice_type->elem_type) == nullptr) |
| 20971 | return ira->codegen->invalid_instruction; | 21928 | return ira->codegen->invalid_inst_gen; |
| 20972 | | 21929 | |
| 20973 | lazy_slice_type->is_const = slice_type_instruction->is_const; | 21930 | lazy_slice_type->is_const = slice_type_instruction->is_const; |
| 20974 | lazy_slice_type->is_volatile = slice_type_instruction->is_volatile; | 21931 | lazy_slice_type->is_volatile = slice_type_instruction->is_volatile; |
| ... | @@ -20977,31 +21934,31 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, | ... | @@ -20977,31 +21934,31 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, |
| 20977 | return result; | 21934 | return result; |
| 20978 | } | 21935 | } |
| 20979 | | 21936 | |
| 20980 | static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAsmSrc *asm_instruction) { | 21937 | static IrInstGen *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstSrcAsm *asm_instruction) { |
| 20981 | Error err; | 21938 | Error err; |
| 20982 | | 21939 | |
| 20983 | assert(asm_instruction->base.source_node->type == NodeTypeAsmExpr); | 21940 | assert(asm_instruction->base.base.source_node->type == NodeTypeAsmExpr); |
| 20984 | | 21941 | |
| 20985 | AstNode *node = asm_instruction->base.source_node; | 21942 | AstNode *node = asm_instruction->base.base.source_node; |
| 20986 | AstNodeAsmExpr *asm_expr = &asm_instruction->base.source_node->data.asm_expr; | 21943 | AstNodeAsmExpr *asm_expr = &asm_instruction->base.base.source_node->data.asm_expr; |
| 20987 | | 21944 | |
| 20988 | Buf *template_buf = ir_resolve_str(ira, asm_instruction->asm_template->child); | 21945 | Buf *template_buf = ir_resolve_str(ira, asm_instruction->asm_template->child); |
| 20989 | if (template_buf == nullptr) | 21946 | if (template_buf == nullptr) |
| 20990 | return ira->codegen->invalid_instruction; | 21947 | return ira->codegen->invalid_inst_gen; |
| 20991 | | 21948 | |
| 20992 | if (asm_instruction->is_global) { | 21949 | if (asm_instruction->is_global) { |
| 20993 | buf_append_char(&ira->codegen->global_asm, '\n'); | 21950 | buf_append_char(&ira->codegen->global_asm, '\n'); |
| 20994 | buf_append_buf(&ira->codegen->global_asm, template_buf); | 21951 | buf_append_buf(&ira->codegen->global_asm, template_buf); |
| 20995 | | 21952 | |
| 20996 | return ir_const_void(ira, &asm_instruction->base); | 21953 | return ir_const_void(ira, &asm_instruction->base.base); |
| 20997 | } | 21954 | } |
| 20998 | | 21955 | |
| 20999 | if (!ir_emit_global_runtime_side_effect(ira, &asm_instruction->base)) | 21956 | if (!ir_emit_global_runtime_side_effect(ira, &asm_instruction->base.base)) |
| 21000 | return ira->codegen->invalid_instruction; | 21957 | return ira->codegen->invalid_inst_gen; |
| 21001 | | 21958 | |
| 21002 | ZigList<AsmToken> tok_list = {}; | 21959 | ZigList<AsmToken> tok_list = {}; |
| 21003 | if ((err = parse_asm_template(ira, node, template_buf, &tok_list))) { | 21960 | if ((err = parse_asm_template(ira, node, template_buf, &tok_list))) { |
| 21004 | return ira->codegen->invalid_instruction; | 21961 | return ira->codegen->invalid_inst_gen; |
| 21005 | } | 21962 | } |
| 21006 | | 21963 | |
| 21007 | for (size_t token_i = 0; token_i < tok_list.length; token_i += 1) { | 21964 | for (size_t token_i = 0; token_i < tok_list.length; token_i += 1) { |
| ... | @@ -21015,15 +21972,15 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs | ... | @@ -21015,15 +21972,15 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs |
| 21015 | add_node_error(ira->codegen, node, | 21972 | add_node_error(ira->codegen, node, |
| 21016 | buf_sprintf("could not find '%.*s' in the inputs or outputs", | 21973 | buf_sprintf("could not find '%.*s' in the inputs or outputs", |
| 21017 | len, ptr)); | 21974 | len, ptr)); |
| 21018 | return ira->codegen->invalid_instruction; | 21975 | return ira->codegen->invalid_inst_gen; |
| 21019 | } | 21976 | } |
| 21020 | } | 21977 | } |
| 21021 | } | 21978 | } |
| 21022 | | 21979 | |
| 21023 | // TODO validate the output types and variable types | 21980 | // TODO validate the output types and variable types |
| 21024 | | 21981 | |
| 21025 | IrInstruction **input_list = allocate<IrInstruction *>(asm_expr->input_list.length); | 21982 | IrInstGen **input_list = allocate<IrInstGen *>(asm_expr->input_list.length); |
| 21026 | IrInstruction **output_types = allocate<IrInstruction *>(asm_expr->output_list.length); | 21983 | IrInstGen **output_types = allocate<IrInstGen *>(asm_expr->output_list.length); |
| 21027 | | 21984 | |
| 21028 | ZigType *return_type = ira->codegen->builtin_types.entry_void; | 21985 | ZigType *return_type = ira->codegen->builtin_types.entry_void; |
| 21029 | for (size_t i = 0; i < asm_expr->output_list.length; i += 1) { | 21986 | for (size_t i = 0; i < asm_expr->output_list.length; i += 1) { |
| ... | @@ -21032,39 +21989,34 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs | ... | @@ -21032,39 +21989,34 @@ static IrInstruction *ir_analyze_instruction_asm(IrAnalyze *ira, IrInstructionAs |
| 21032 | output_types[i] = asm_instruction->output_types[i]->child; | 21989 | output_types[i] = asm_instruction->output_types[i]->child; |
| 21033 | return_type = ir_resolve_type(ira, output_types[i]); | 21990 | return_type = ir_resolve_type(ira, output_types[i]); |
| 21034 | if (type_is_invalid(return_type)) | 21991 | if (type_is_invalid(return_type)) |
| 21035 | return ira->codegen->invalid_instruction; | 21992 | return ira->codegen->invalid_inst_gen; |
| 21036 | } | 21993 | } |
| 21037 | } | 21994 | } |
| 21038 | | 21995 | |
| 21039 | for (size_t i = 0; i < asm_expr->input_list.length; i += 1) { | 21996 | for (size_t i = 0; i < asm_expr->input_list.length; i += 1) { |
| 21040 | IrInstruction *const input_value = asm_instruction->input_list[i]->child; | 21997 | IrInstGen *const input_value = asm_instruction->input_list[i]->child; |
| 21041 | if (type_is_invalid(input_value->value->type)) | 21998 | if (type_is_invalid(input_value->value->type)) |
| 21042 | return ira->codegen->invalid_instruction; | 21999 | return ira->codegen->invalid_inst_gen; |
| 21043 | | 22000 | |
| 21044 | if (instr_is_comptime(input_value) && | 22001 | if (instr_is_comptime(input_value) && |
| 21045 | (input_value->value->type->id == ZigTypeIdComptimeInt || | 22002 | (input_value->value->type->id == ZigTypeIdComptimeInt || |
| 21046 | input_value->value->type->id == ZigTypeIdComptimeFloat)) { | 22003 | input_value->value->type->id == ZigTypeIdComptimeFloat)) { |
| 21047 | ir_add_error_node(ira, input_value->source_node, | 22004 | ir_add_error(ira, &input_value->base, |
| 21048 | buf_sprintf("expected sized integer or sized float, found %s", buf_ptr(&input_value->value->type->name))); | 22005 | buf_sprintf("expected sized integer or sized float, found %s", buf_ptr(&input_value->value->type->name))); |
| 21049 | return ira->codegen->invalid_instruction; | 22006 | return ira->codegen->invalid_inst_gen; |
| 21050 | } | 22007 | } |
| 21051 | | 22008 | |
| 21052 | input_list[i] = input_value; | 22009 | input_list[i] = input_value; |
| 21053 | } | 22010 | } |
| 21054 | | 22011 | |
| 21055 | IrInstruction *result = ir_build_asm_gen(ira, | 22012 | return ir_build_asm_gen(ira, &asm_instruction->base.base, |
| 21056 | asm_instruction->base.scope, asm_instruction->base.source_node, | | |
| 21057 | template_buf, tok_list.items, tok_list.length, | 22013 | template_buf, tok_list.items, tok_list.length, |
| 21058 | input_list, output_types, asm_instruction->output_vars, asm_instruction->return_count, | 22014 | input_list, output_types, asm_instruction->output_vars, asm_instruction->return_count, |
| 21059 | asm_instruction->has_side_effects); | 22015 | asm_instruction->has_side_effects, return_type); |
| 21060 | result->value->type = return_type; | | |
| 21061 | return result; | | |
| 21062 | } | 22016 | } |
| 21063 | | 22017 | |
| 21064 | static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, | 22018 | static IrInstGen *ir_analyze_instruction_array_type(IrAnalyze *ira, IrInstSrcArrayType *array_type_instruction) { |
| 21065 | IrInstructionArrayType *array_type_instruction) | 22019 | IrInstGen *result = ir_const(ira, &array_type_instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 21066 | { | | |
| 21067 | IrInstruction *result = ir_const(ira, &array_type_instruction->base, ira->codegen->builtin_types.entry_type); | | |
| 21068 | result->value->special = ConstValSpecialLazy; | 22020 | result->value->special = ConstValSpecialLazy; |
| 21069 | | 22021 | |
| 21070 | LazyValueArrayType *lazy_array_type = allocate<LazyValueArrayType>(1, "LazyValueArrayType"); | 22022 | LazyValueArrayType *lazy_array_type = allocate<LazyValueArrayType>(1, "LazyValueArrayType"); |
| ... | @@ -21074,22 +22026,22 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, | ... | @@ -21074,22 +22026,22 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, |
| 21074 | | 22026 | |
| 21075 | lazy_array_type->elem_type = array_type_instruction->child_type->child; | 22027 | lazy_array_type->elem_type = array_type_instruction->child_type->child; |
| 21076 | if (ir_resolve_type_lazy(ira, lazy_array_type->elem_type) == nullptr) | 22028 | if (ir_resolve_type_lazy(ira, lazy_array_type->elem_type) == nullptr) |
| 21077 | return ira->codegen->invalid_instruction; | 22029 | return ira->codegen->invalid_inst_gen; |
| 21078 | | 22030 | |
| 21079 | if (!ir_resolve_usize(ira, array_type_instruction->size->child, &lazy_array_type->length)) | 22031 | if (!ir_resolve_usize(ira, array_type_instruction->size->child, &lazy_array_type->length)) |
| 21080 | return ira->codegen->invalid_instruction; | 22032 | return ira->codegen->invalid_inst_gen; |
| 21081 | | 22033 | |
| 21082 | if (array_type_instruction->sentinel != nullptr) { | 22034 | if (array_type_instruction->sentinel != nullptr) { |
| 21083 | lazy_array_type->sentinel = array_type_instruction->sentinel->child; | 22035 | lazy_array_type->sentinel = array_type_instruction->sentinel->child; |
| 21084 | if (ir_resolve_const(ira, lazy_array_type->sentinel, LazyOk) == nullptr) | 22036 | if (ir_resolve_const(ira, lazy_array_type->sentinel, LazyOk) == nullptr) |
| 21085 | return ira->codegen->invalid_instruction; | 22037 | return ira->codegen->invalid_inst_gen; |
| 21086 | } | 22038 | } |
| 21087 | | 22039 | |
| 21088 | return result; | 22040 | return result; |
| 21089 | } | 22041 | } |
| 21090 | | 22042 | |
| 21091 | static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstructionSizeOf *instruction) { | 22043 | static IrInstGen *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstSrcSizeOf *instruction) { |
| 21092 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 22044 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_num_lit_int); |
| 21093 | result->value->special = ConstValSpecialLazy; | 22045 | result->value->special = ConstValSpecialLazy; |
| 21094 | | 22046 | |
| 21095 | LazyValueSizeOf *lazy_size_of = allocate<LazyValueSizeOf>(1, "LazyValueSizeOf"); | 22047 | LazyValueSizeOf *lazy_size_of = allocate<LazyValueSizeOf>(1, "LazyValueSizeOf"); |
| ... | @@ -21100,19 +22052,19 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstructi | ... | @@ -21100,19 +22052,19 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, IrInstructi |
| 21100 | | 22052 | |
| 21101 | lazy_size_of->target_type = instruction->type_value->child; | 22053 | lazy_size_of->target_type = instruction->type_value->child; |
| 21102 | if (ir_resolve_type_lazy(ira, lazy_size_of->target_type) == nullptr) | 22054 | if (ir_resolve_type_lazy(ira, lazy_size_of->target_type) == nullptr) |
| 21103 | return ira->codegen->invalid_instruction; | 22055 | return ira->codegen->invalid_inst_gen; |
| 21104 | | 22056 | |
| 21105 | return result; | 22057 | return result; |
| 21106 | } | 22058 | } |
| 21107 | | 22059 | |
| 21108 | static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *source_inst, IrInstruction *value) { | 22060 | static IrInstGen *ir_analyze_test_non_null(IrAnalyze *ira, IrInst *source_inst, IrInstGen *value) { |
| 21109 | ZigType *type_entry = value->value->type; | 22061 | ZigType *type_entry = value->value->type; |
| 21110 | | 22062 | |
| 21111 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.allow_zero) { | 22063 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.allow_zero) { |
| 21112 | if (instr_is_comptime(value)) { | 22064 | if (instr_is_comptime(value)) { |
| 21113 | ZigValue *c_ptr_val = ir_resolve_const(ira, value, UndefOk); | 22065 | ZigValue *c_ptr_val = ir_resolve_const(ira, value, UndefOk); |
| 21114 | if (c_ptr_val == nullptr) | 22066 | if (c_ptr_val == nullptr) |
| 21115 | return ira->codegen->invalid_instruction; | 22067 | return ira->codegen->invalid_inst_gen; |
| 21116 | if (c_ptr_val->special == ConstValSpecialUndef) | 22068 | if (c_ptr_val->special == ConstValSpecialUndef) |
| 21117 | return ir_const_undef(ira, source_inst, ira->codegen->builtin_types.entry_bool); | 22069 | return ir_const_undef(ira, source_inst, ira->codegen->builtin_types.entry_bool); |
| 21118 | bool is_null = c_ptr_val->data.x_ptr.special == ConstPtrSpecialNull || | 22070 | bool is_null = c_ptr_val->data.x_ptr.special == ConstPtrSpecialNull || |
| ... | @@ -21121,25 +22073,19 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so | ... | @@ -21121,25 +22073,19 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so |
| 21121 | return ir_const_bool(ira, source_inst, !is_null); | 22073 | return ir_const_bool(ira, source_inst, !is_null); |
| 21122 | } | 22074 | } |
| 21123 | | 22075 | |
| 21124 | IrInstruction *result = ir_build_test_nonnull(&ira->new_irb, | 22076 | return ir_build_test_non_null_gen(ira, source_inst, value); |
| 21125 | source_inst->scope, source_inst->source_node, value); | | |
| 21126 | result->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 21127 | return result; | | |
| 21128 | } else if (type_entry->id == ZigTypeIdOptional) { | 22077 | } else if (type_entry->id == ZigTypeIdOptional) { |
| 21129 | if (instr_is_comptime(value)) { | 22078 | if (instr_is_comptime(value)) { |
| 21130 | ZigValue *maybe_val = ir_resolve_const(ira, value, UndefOk); | 22079 | ZigValue *maybe_val = ir_resolve_const(ira, value, UndefOk); |
| 21131 | if (maybe_val == nullptr) | 22080 | if (maybe_val == nullptr) |
| 21132 | return ira->codegen->invalid_instruction; | 22081 | return ira->codegen->invalid_inst_gen; |
| 21133 | if (maybe_val->special == ConstValSpecialUndef) | 22082 | if (maybe_val->special == ConstValSpecialUndef) |
| 21134 | return ir_const_undef(ira, source_inst, ira->codegen->builtin_types.entry_bool); | 22083 | return ir_const_undef(ira, source_inst, ira->codegen->builtin_types.entry_bool); |
| 21135 | | 22084 | |
| 21136 | return ir_const_bool(ira, source_inst, !optional_value_is_null(maybe_val)); | 22085 | return ir_const_bool(ira, source_inst, !optional_value_is_null(maybe_val)); |
| 21137 | } | 22086 | } |
| 21138 | | 22087 | |
| 21139 | IrInstruction *result = ir_build_test_nonnull(&ira->new_irb, | 22088 | return ir_build_test_non_null_gen(ira, source_inst, value); |
| 21140 | source_inst->scope, source_inst->source_node, value); | | |
| 21141 | result->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 21142 | return result; | | |
| 21143 | } else if (type_entry->id == ZigTypeIdNull) { | 22089 | } else if (type_entry->id == ZigTypeIdNull) { |
| 21144 | return ir_const_bool(ira, source_inst, false); | 22090 | return ir_const_bool(ira, source_inst, false); |
| 21145 | } else { | 22091 | } else { |
| ... | @@ -21147,51 +22093,51 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so | ... | @@ -21147,51 +22093,51 @@ static IrInstruction *ir_analyze_test_non_null(IrAnalyze *ira, IrInstruction *so |
| 21147 | } | 22093 | } |
| 21148 | } | 22094 | } |
| 21149 | | 22095 | |
| 21150 | static IrInstruction *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstructionTestNonNull *instruction) { | 22096 | static IrInstGen *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrInstSrcTestNonNull *instruction) { |
| 21151 | IrInstruction *value = instruction->value->child; | 22097 | IrInstGen *value = instruction->value->child; |
| 21152 | if (type_is_invalid(value->value->type)) | 22098 | if (type_is_invalid(value->value->type)) |
| 21153 | return ira->codegen->invalid_instruction; | 22099 | return ira->codegen->invalid_inst_gen; |
| 21154 | | 22100 | |
| 21155 | return ir_analyze_test_non_null(ira, &instruction->base, value); | 22101 | return ir_analyze_test_non_null(ira, &instruction->base.base, value); |
| 21156 | } | 22102 | } |
| 21157 | | 22103 | |
| 21158 | static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstruction *source_instr, | 22104 | static IrInstGen *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInst* source_instr, |
| 21159 | IrInstruction *base_ptr, bool safety_check_on, bool initializing) | 22105 | IrInstGen *base_ptr, bool safety_check_on, bool initializing) |
| 21160 | { | 22106 | { |
| 21161 | ZigType *type_entry = get_ptr_elem_type(ira->codegen, base_ptr); | 22107 | ZigType *type_entry = get_ptr_elem_type(ira->codegen, base_ptr); |
| 21162 | if (type_is_invalid(type_entry)) | 22108 | if (type_is_invalid(type_entry)) |
| 21163 | return ira->codegen->invalid_instruction; | 22109 | return ira->codegen->invalid_inst_gen; |
| 21164 | | 22110 | |
| 21165 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.ptr_len == PtrLenC) { | 22111 | if (type_entry->id == ZigTypeIdPointer && type_entry->data.pointer.ptr_len == PtrLenC) { |
| 21166 | if (instr_is_comptime(base_ptr)) { | 22112 | if (instr_is_comptime(base_ptr)) { |
| 21167 | ZigValue *val = ir_resolve_const(ira, base_ptr, UndefBad); | 22113 | ZigValue *val = ir_resolve_const(ira, base_ptr, UndefBad); |
| 21168 | if (!val) | 22114 | if (!val) |
| 21169 | return ira->codegen->invalid_instruction; | 22115 | return ira->codegen->invalid_inst_gen; |
| 21170 | if (val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 22116 | if (val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 21171 | ZigValue *c_ptr_val = const_ptr_pointee(ira, ira->codegen, val, source_instr->source_node); | 22117 | ZigValue *c_ptr_val = const_ptr_pointee(ira, ira->codegen, val, source_instr->source_node); |
| 21172 | if (c_ptr_val == nullptr) | 22118 | if (c_ptr_val == nullptr) |
| 21173 | return ira->codegen->invalid_instruction; | 22119 | return ira->codegen->invalid_inst_gen; |
| 21174 | bool is_null = c_ptr_val->data.x_ptr.special == ConstPtrSpecialNull || | 22120 | bool is_null = c_ptr_val->data.x_ptr.special == ConstPtrSpecialNull || |
| 21175 | (c_ptr_val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr && | 22121 | (c_ptr_val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr && |
| 21176 | c_ptr_val->data.x_ptr.data.hard_coded_addr.addr == 0); | 22122 | c_ptr_val->data.x_ptr.data.hard_coded_addr.addr == 0); |
| 21177 | if (is_null) { | 22123 | if (is_null) { |
| 21178 | ir_add_error(ira, source_instr, buf_sprintf("unable to unwrap null")); | 22124 | ir_add_error(ira, source_instr, buf_sprintf("unable to unwrap null")); |
| 21179 | return ira->codegen->invalid_instruction; | 22125 | return ira->codegen->invalid_inst_gen; |
| 21180 | } | 22126 | } |
| 21181 | return base_ptr; | 22127 | return base_ptr; |
| 21182 | } | 22128 | } |
| 21183 | } | 22129 | } |
| 21184 | if (!safety_check_on) | 22130 | if (!safety_check_on) |
| 21185 | return base_ptr; | 22131 | return base_ptr; |
| 21186 | IrInstruction *c_ptr_val = ir_get_deref(ira, source_instr, base_ptr, nullptr); | 22132 | IrInstGen *c_ptr_val = ir_get_deref(ira, source_instr, base_ptr, nullptr); |
| 21187 | ir_build_assert_non_null(ira, source_instr, c_ptr_val); | 22133 | ir_build_assert_non_null(ira, source_instr, c_ptr_val); |
| 21188 | return base_ptr; | 22134 | return base_ptr; |
| 21189 | } | 22135 | } |
| 21190 | | 22136 | |
| 21191 | if (type_entry->id != ZigTypeIdOptional) { | 22137 | if (type_entry->id != ZigTypeIdOptional) { |
| 21192 | ir_add_error_node(ira, base_ptr->source_node, | 22138 | ir_add_error(ira, &base_ptr->base, |
| 21193 | buf_sprintf("expected optional type, found '%s'", buf_ptr(&type_entry->name))); | 22139 | buf_sprintf("expected optional type, found '%s'", buf_ptr(&type_entry->name))); |
| 21194 | return ira->codegen->invalid_instruction; | 22140 | return ira->codegen->invalid_inst_gen; |
| 21195 | } | 22141 | } |
| 21196 | | 22142 | |
| 21197 | ZigType *child_type = type_entry->data.maybe.child_type; | 22143 | ZigType *child_type = type_entry->data.maybe.child_type; |
| ... | @@ -21204,16 +22150,16 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -21204,16 +22150,16 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 21204 | if (instr_is_comptime(base_ptr)) { | 22150 | if (instr_is_comptime(base_ptr)) { |
| 21205 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); | 22151 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); |
| 21206 | if (!ptr_val) | 22152 | if (!ptr_val) |
| 21207 | return ira->codegen->invalid_instruction; | 22153 | return ira->codegen->invalid_inst_gen; |
| 21208 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 22154 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 21209 | ZigValue *optional_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 22155 | ZigValue *optional_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 21210 | if (optional_val == nullptr) | 22156 | if (optional_val == nullptr) |
| 21211 | return ira->codegen->invalid_instruction; | 22157 | return ira->codegen->invalid_inst_gen; |
| 21212 | | 22158 | |
| 21213 | if (initializing) { | 22159 | if (initializing) { |
| 21214 | switch (type_has_one_possible_value(ira->codegen, child_type)) { | 22160 | switch (type_has_one_possible_value(ira->codegen, child_type)) { |
| 21215 | case OnePossibleValueInvalid: | 22161 | case OnePossibleValueInvalid: |
| 21216 | return ira->codegen->invalid_instruction; | 22162 | return ira->codegen->invalid_inst_gen; |
| 21217 | case OnePossibleValueNo: | 22163 | case OnePossibleValueNo: |
| 21218 | if (!same_comptime_repr) { | 22164 | if (!same_comptime_repr) { |
| 21219 | ZigValue *payload_val = create_const_vals(1); | 22165 | ZigValue *payload_val = create_const_vals(1); |
| ... | @@ -21240,14 +22186,13 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -21240,14 +22186,13 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 21240 | } | 22186 | } |
| 21241 | } else if (optional_value_is_null(optional_val)) { | 22187 | } else if (optional_value_is_null(optional_val)) { |
| 21242 | ir_add_error(ira, source_instr, buf_sprintf("unable to unwrap null")); | 22188 | ir_add_error(ira, source_instr, buf_sprintf("unable to unwrap null")); |
| 21243 | return ira->codegen->invalid_instruction; | 22189 | return ira->codegen->invalid_inst_gen; |
| 21244 | } | 22190 | } |
| 21245 | | 22191 | |
| 21246 | IrInstruction *result; | 22192 | IrInstGen *result; |
| 21247 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 22193 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 21248 | result = ir_build_optional_unwrap_ptr(&ira->new_irb, source_instr->scope, | 22194 | result = ir_build_optional_unwrap_ptr_gen(ira, source_instr, base_ptr, false, |
| 21249 | source_instr->source_node, base_ptr, false, initializing); | 22195 | initializing, result_type); |
| 21250 | result->value->type = result_type; | | |
| 21251 | result->value->special = ConstValSpecialStatic; | 22196 | result->value->special = ConstValSpecialStatic; |
| 21252 | } else { | 22197 | } else { |
| 21253 | result = ir_const(ira, source_instr, result_type); | 22198 | result = ir_const(ira, source_instr, result_type); |
| ... | @@ -21257,7 +22202,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -21257,7 +22202,7 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 21257 | result_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; | 22202 | result_val->data.x_ptr.mut = ptr_val->data.x_ptr.mut; |
| 21258 | switch (type_has_one_possible_value(ira->codegen, child_type)) { | 22203 | switch (type_has_one_possible_value(ira->codegen, child_type)) { |
| 21259 | case OnePossibleValueInvalid: | 22204 | case OnePossibleValueInvalid: |
| 21260 | return ira->codegen->invalid_instruction; | 22205 | return ira->codegen->invalid_inst_gen; |
| 21261 | case OnePossibleValueNo: | 22206 | case OnePossibleValueNo: |
| 21262 | if (same_comptime_repr) { | 22207 | if (same_comptime_repr) { |
| 21263 | result_val->data.x_ptr.data.ref.pointee = optional_val; | 22208 | result_val->data.x_ptr.data.ref.pointee = optional_val; |
| ... | @@ -21275,131 +22220,120 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr | ... | @@ -21275,131 +22220,120 @@ static IrInstruction *ir_analyze_unwrap_optional_payload(IrAnalyze *ira, IrInstr |
| 21275 | } | 22220 | } |
| 21276 | } | 22221 | } |
| 21277 | | 22222 | |
| 21278 | IrInstruction *result = ir_build_optional_unwrap_ptr(&ira->new_irb, source_instr->scope, | 22223 | return ir_build_optional_unwrap_ptr_gen(ira, source_instr, base_ptr, safety_check_on, |
| 21279 | source_instr->source_node, base_ptr, safety_check_on, initializing); | 22224 | initializing, result_type); |
| 21280 | result->value->type = result_type; | | |
| 21281 | return result; | | |
| 21282 | } | 22225 | } |
| 21283 | | 22226 | |
| 21284 | static IrInstruction *ir_analyze_instruction_optional_unwrap_ptr(IrAnalyze *ira, | 22227 | static IrInstGen *ir_analyze_instruction_optional_unwrap_ptr(IrAnalyze *ira, |
| 21285 | IrInstructionOptionalUnwrapPtr *instruction) | 22228 | IrInstSrcOptionalUnwrapPtr *instruction) |
| 21286 | { | 22229 | { |
| 21287 | IrInstruction *base_ptr = instruction->base_ptr->child; | 22230 | IrInstGen *base_ptr = instruction->base_ptr->child; |
| 21288 | if (type_is_invalid(base_ptr->value->type)) | 22231 | if (type_is_invalid(base_ptr->value->type)) |
| 21289 | return ira->codegen->invalid_instruction; | 22232 | return ira->codegen->invalid_inst_gen; |
| 21290 | | 22233 | |
| 21291 | return ir_analyze_unwrap_optional_payload(ira, &instruction->base, base_ptr, | 22234 | return ir_analyze_unwrap_optional_payload(ira, &instruction->base.base, base_ptr, |
| 21292 | instruction->safety_check_on, false); | 22235 | instruction->safety_check_on, false); |
| 21293 | } | 22236 | } |
| 21294 | | 22237 | |
| 21295 | static IrInstruction *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstructionCtz *instruction) { | 22238 | static IrInstGen *ir_analyze_instruction_ctz(IrAnalyze *ira, IrInstSrcCtz *instruction) { |
| 21296 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); | 22239 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); |
| 21297 | if (type_is_invalid(int_type)) | 22240 | if (type_is_invalid(int_type)) |
| 21298 | return ira->codegen->invalid_instruction; | 22241 | return ira->codegen->invalid_inst_gen; |
| 21299 | | 22242 | |
| 21300 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); | 22243 | IrInstGen *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 21301 | if (type_is_invalid(op->value->type)) | 22244 | if (type_is_invalid(op->value->type)) |
| 21302 | return ira->codegen->invalid_instruction; | 22245 | return ira->codegen->invalid_inst_gen; |
| 21303 | | 22246 | |
| 21304 | if (int_type->data.integral.bit_count == 0) | 22247 | if (int_type->data.integral.bit_count == 0) |
| 21305 | return ir_const_unsigned(ira, &instruction->base, 0); | 22248 | return ir_const_unsigned(ira, &instruction->base.base, 0); |
| 21306 | | 22249 | |
| 21307 | if (instr_is_comptime(op)) { | 22250 | if (instr_is_comptime(op)) { |
| 21308 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); | 22251 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 21309 | if (val == nullptr) | 22252 | if (val == nullptr) |
| 21310 | return ira->codegen->invalid_instruction; | 22253 | return ira->codegen->invalid_inst_gen; |
| 21311 | if (val->special == ConstValSpecialUndef) | 22254 | if (val->special == ConstValSpecialUndef) |
| 21312 | return ir_const_undef(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 22255 | return ir_const_undef(ira, &instruction->base.base, ira->codegen->builtin_types.entry_num_lit_int); |
| 21313 | size_t result_usize = bigint_ctz(&op->value->data.x_bigint, int_type->data.integral.bit_count); | 22256 | size_t result_usize = bigint_ctz(&op->value->data.x_bigint, int_type->data.integral.bit_count); |
| 21314 | return ir_const_unsigned(ira, &instruction->base, result_usize); | 22257 | return ir_const_unsigned(ira, &instruction->base.base, result_usize); |
| 21315 | } | 22258 | } |
| 21316 | | 22259 | |
| 21317 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); | 22260 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); |
| 21318 | IrInstruction *result = ir_build_ctz(&ira->new_irb, instruction->base.scope, | 22261 | return ir_build_ctz_gen(ira, &instruction->base.base, return_type, op); |
| 21319 | instruction->base.source_node, nullptr, op); | | |
| 21320 | result->value->type = return_type; | | |
| 21321 | return result; | | |
| 21322 | } | 22262 | } |
| 21323 | | 22263 | |
| 21324 | static IrInstruction *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstructionClz *instruction) { | 22264 | static IrInstGen *ir_analyze_instruction_clz(IrAnalyze *ira, IrInstSrcClz *instruction) { |
| 21325 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); | 22265 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); |
| 21326 | if (type_is_invalid(int_type)) | 22266 | if (type_is_invalid(int_type)) |
| 21327 | return ira->codegen->invalid_instruction; | 22267 | return ira->codegen->invalid_inst_gen; |
| 21328 | | 22268 | |
| 21329 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); | 22269 | IrInstGen *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 21330 | if (type_is_invalid(op->value->type)) | 22270 | if (type_is_invalid(op->value->type)) |
| 21331 | return ira->codegen->invalid_instruction; | 22271 | return ira->codegen->invalid_inst_gen; |
| 21332 | | 22272 | |
| 21333 | if (int_type->data.integral.bit_count == 0) | 22273 | if (int_type->data.integral.bit_count == 0) |
| 21334 | return ir_const_unsigned(ira, &instruction->base, 0); | 22274 | return ir_const_unsigned(ira, &instruction->base.base, 0); |
| 21335 | | 22275 | |
| 21336 | if (instr_is_comptime(op)) { | 22276 | if (instr_is_comptime(op)) { |
| 21337 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); | 22277 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 21338 | if (val == nullptr) | 22278 | if (val == nullptr) |
| 21339 | return ira->codegen->invalid_instruction; | 22279 | return ira->codegen->invalid_inst_gen; |
| 21340 | if (val->special == ConstValSpecialUndef) | 22280 | if (val->special == ConstValSpecialUndef) |
| 21341 | return ir_const_undef(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 22281 | return ir_const_undef(ira, &instruction->base.base, ira->codegen->builtin_types.entry_num_lit_int); |
| 21342 | size_t result_usize = bigint_clz(&op->value->data.x_bigint, int_type->data.integral.bit_count); | 22282 | size_t result_usize = bigint_clz(&op->value->data.x_bigint, int_type->data.integral.bit_count); |
| 21343 | return ir_const_unsigned(ira, &instruction->base, result_usize); | 22283 | return ir_const_unsigned(ira, &instruction->base.base, result_usize); |
| 21344 | } | 22284 | } |
| 21345 | | 22285 | |
| 21346 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); | 22286 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); |
| 21347 | IrInstruction *result = ir_build_clz(&ira->new_irb, instruction->base.scope, | 22287 | return ir_build_clz_gen(ira, &instruction->base.base, return_type, op); |
| 21348 | instruction->base.source_node, nullptr, op); | | |
| 21349 | result->value->type = return_type; | | |
| 21350 | return result; | | |
| 21351 | } | 22288 | } |
| 21352 | | 22289 | |
| 21353 | static IrInstruction *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstructionPopCount *instruction) { | 22290 | static IrInstGen *ir_analyze_instruction_pop_count(IrAnalyze *ira, IrInstSrcPopCount *instruction) { |
| 21354 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); | 22291 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); |
| 21355 | if (type_is_invalid(int_type)) | 22292 | if (type_is_invalid(int_type)) |
| 21356 | return ira->codegen->invalid_instruction; | 22293 | return ira->codegen->invalid_inst_gen; |
| 21357 | | 22294 | |
| 21358 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); | 22295 | IrInstGen *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 21359 | if (type_is_invalid(op->value->type)) | 22296 | if (type_is_invalid(op->value->type)) |
| 21360 | return ira->codegen->invalid_instruction; | 22297 | return ira->codegen->invalid_inst_gen; |
| 21361 | | 22298 | |
| 21362 | if (int_type->data.integral.bit_count == 0) | 22299 | if (int_type->data.integral.bit_count == 0) |
| 21363 | return ir_const_unsigned(ira, &instruction->base, 0); | 22300 | return ir_const_unsigned(ira, &instruction->base.base, 0); |
| 21364 | | 22301 | |
| 21365 | if (instr_is_comptime(op)) { | 22302 | if (instr_is_comptime(op)) { |
| 21366 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); | 22303 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 21367 | if (val == nullptr) | 22304 | if (val == nullptr) |
| 21368 | return ira->codegen->invalid_instruction; | 22305 | return ira->codegen->invalid_inst_gen; |
| 21369 | if (val->special == ConstValSpecialUndef) | 22306 | if (val->special == ConstValSpecialUndef) |
| 21370 | return ir_const_undef(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 22307 | return ir_const_undef(ira, &instruction->base.base, ira->codegen->builtin_types.entry_num_lit_int); |
| 21371 | | 22308 | |
| 21372 | if (bigint_cmp_zero(&val->data.x_bigint) != CmpLT) { | 22309 | if (bigint_cmp_zero(&val->data.x_bigint) != CmpLT) { |
| 21373 | size_t result = bigint_popcount_unsigned(&val->data.x_bigint); | 22310 | size_t result = bigint_popcount_unsigned(&val->data.x_bigint); |
| 21374 | return ir_const_unsigned(ira, &instruction->base, result); | 22311 | return ir_const_unsigned(ira, &instruction->base.base, result); |
| 21375 | } | 22312 | } |
| 21376 | size_t result = bigint_popcount_signed(&val->data.x_bigint, int_type->data.integral.bit_count); | 22313 | size_t result = bigint_popcount_signed(&val->data.x_bigint, int_type->data.integral.bit_count); |
| 21377 | return ir_const_unsigned(ira, &instruction->base, result); | 22314 | return ir_const_unsigned(ira, &instruction->base.base, result); |
| 21378 | } | 22315 | } |
| 21379 | | 22316 | |
| 21380 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); | 22317 | ZigType *return_type = get_smallest_unsigned_int_type(ira->codegen, int_type->data.integral.bit_count); |
| 21381 | IrInstruction *result = ir_build_pop_count(&ira->new_irb, instruction->base.scope, | 22318 | return ir_build_pop_count_gen(ira, &instruction->base.base, return_type, op); |
| 21382 | instruction->base.source_node, nullptr, op); | | |
| 21383 | result->value->type = return_type; | | |
| 21384 | return result; | | |
| 21385 | } | 22319 | } |
| 21386 | | 22320 | |
| 21387 | static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value) { | 22321 | static IrInstGen *ir_analyze_union_tag(IrAnalyze *ira, IrInst* source_instr, IrInstGen *value, bool is_gen) { |
| 21388 | if (type_is_invalid(value->value->type)) | 22322 | if (type_is_invalid(value->value->type)) |
| 21389 | return ira->codegen->invalid_instruction; | 22323 | return ira->codegen->invalid_inst_gen; |
| 21390 | | 22324 | |
| 21391 | if (value->value->type->id != ZigTypeIdUnion) { | 22325 | if (value->value->type->id != ZigTypeIdUnion) { |
| 21392 | ir_add_error(ira, value, | 22326 | ir_add_error(ira, &value->base, |
| 21393 | buf_sprintf("expected enum or union type, found '%s'", buf_ptr(&value->value->type->name))); | 22327 | buf_sprintf("expected enum or union type, found '%s'", buf_ptr(&value->value->type->name))); |
| 21394 | return ira->codegen->invalid_instruction; | 22328 | return ira->codegen->invalid_inst_gen; |
| 21395 | } | 22329 | } |
| 21396 | if (!value->value->type->data.unionation.have_explicit_tag_type && !source_instr->is_gen) { | 22330 | if (!value->value->type->data.unionation.have_explicit_tag_type && !is_gen) { |
| 21397 | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("union has no associated enum")); | 22331 | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("union has no associated enum")); |
| 21398 | if (value->value->type->data.unionation.decl_node != nullptr) { | 22332 | if (value->value->type->data.unionation.decl_node != nullptr) { |
| 21399 | add_error_note(ira->codegen, msg, value->value->type->data.unionation.decl_node, | 22333 | add_error_note(ira->codegen, msg, value->value->type->data.unionation.decl_node, |
| 21400 | buf_sprintf("declared here")); | 22334 | buf_sprintf("declared here")); |
| 21401 | } | 22335 | } |
| 21402 | return ira->codegen->invalid_instruction; | 22336 | return ira->codegen->invalid_inst_gen; |
| 21403 | } | 22337 | } |
| 21404 | | 22338 | |
| 21405 | ZigType *tag_type = value->value->type->data.unionation.tag_type; | 22339 | ZigType *tag_type = value->value->type->data.unionation.tag_type; |
| ... | @@ -21408,9 +22342,9 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source | ... | @@ -21408,9 +22342,9 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source |
| 21408 | if (instr_is_comptime(value)) { | 22342 | if (instr_is_comptime(value)) { |
| 21409 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); | 22343 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 21410 | if (!val) | 22344 | if (!val) |
| 21411 | return ira->codegen->invalid_instruction; | 22345 | return ira->codegen->invalid_inst_gen; |
| 21412 | | 22346 | |
| 21413 | IrInstructionConst *const_instruction = ir_create_instruction<IrInstructionConst>(&ira->new_irb, | 22347 | IrInstGenConst *const_instruction = ir_create_inst_gen<IrInstGenConst>(&ira->new_irb, |
| 21414 | source_instr->scope, source_instr->source_node); | 22348 | source_instr->scope, source_instr->source_node); |
| 21415 | const_instruction->base.value->type = tag_type; | 22349 | const_instruction->base.value->type = tag_type; |
| 21416 | const_instruction->base.value->special = ConstValSpecialStatic; | 22350 | const_instruction->base.value->special = ConstValSpecialStatic; |
| ... | @@ -21418,15 +22352,13 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source | ... | @@ -21418,15 +22352,13 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source |
| 21418 | return &const_instruction->base; | 22352 | return &const_instruction->base; |
| 21419 | } | 22353 | } |
| 21420 | | 22354 | |
| 21421 | IrInstruction *result = ir_build_union_tag(&ira->new_irb, source_instr->scope, source_instr->source_node, value); | 22355 | return ir_build_union_tag(ira, source_instr, value, tag_type); |
| 21422 | result->value->type = tag_type; | | |
| 21423 | return result; | | |
| 21424 | } | 22356 | } |
| 21425 | | 22357 | |
| 21426 | static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | 22358 | static IrInstGen *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 21427 | IrInstructionSwitchBr *switch_br_instruction) | 22359 | IrInstSrcSwitchBr *switch_br_instruction) |
| 21428 | { | 22360 | { |
| 21429 | IrInstruction *target_value = switch_br_instruction->target_value->child; | 22361 | IrInstGen *target_value = switch_br_instruction->target_value->child; |
| 21430 | if (type_is_invalid(target_value->value->type)) | 22362 | if (type_is_invalid(target_value->value->type)) |
| 21431 | return ir_unreach_error(ira); | 22363 | return ir_unreach_error(ira); |
| 21432 | | 22364 | |
| ... | @@ -21441,21 +22373,21 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -21441,21 +22373,21 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 21441 | | 22373 | |
| 21442 | bool is_comptime; | 22374 | bool is_comptime; |
| 21443 | if (!ir_resolve_comptime(ira, switch_br_instruction->is_comptime->child, &is_comptime)) | 22375 | if (!ir_resolve_comptime(ira, switch_br_instruction->is_comptime->child, &is_comptime)) |
| 21444 | return ira->codegen->invalid_instruction; | 22376 | return ira->codegen->invalid_inst_gen; |
| 21445 | | 22377 | |
| 21446 | if (is_comptime || instr_is_comptime(target_value)) { | 22378 | if (is_comptime || instr_is_comptime(target_value)) { |
| 21447 | ZigValue *target_val = ir_resolve_const(ira, target_value, UndefBad); | 22379 | ZigValue *target_val = ir_resolve_const(ira, target_value, UndefBad); |
| 21448 | if (!target_val) | 22380 | if (!target_val) |
| 21449 | return ir_unreach_error(ira); | 22381 | return ir_unreach_error(ira); |
| 21450 | | 22382 | |
| 21451 | IrBasicBlock *old_dest_block = switch_br_instruction->else_block; | 22383 | IrBasicBlockSrc *old_dest_block = switch_br_instruction->else_block; |
| 21452 | for (size_t i = 0; i < case_count; i += 1) { | 22384 | for (size_t i = 0; i < case_count; i += 1) { |
| 21453 | IrInstructionSwitchBrCase *old_case = &switch_br_instruction->cases[i]; | 22385 | IrInstSrcSwitchBrCase *old_case = &switch_br_instruction->cases[i]; |
| 21454 | IrInstruction *case_value = old_case->value->child; | 22386 | IrInstGen *case_value = old_case->value->child; |
| 21455 | if (type_is_invalid(case_value->value->type)) | 22387 | if (type_is_invalid(case_value->value->type)) |
| 21456 | return ir_unreach_error(ira); | 22388 | return ir_unreach_error(ira); |
| 21457 | | 22389 | |
| 21458 | IrInstruction *casted_case_value = ir_implicit_cast(ira, case_value, target_value->value->type); | 22390 | IrInstGen *casted_case_value = ir_implicit_cast(ira, case_value, target_value->value->type); |
| 21459 | if (type_is_invalid(casted_case_value->value->type)) | 22391 | if (type_is_invalid(casted_case_value->value->type)) |
| 21460 | return ir_unreach_error(ira); | 22392 | return ir_unreach_error(ira); |
| 21461 | | 22393 | |
| ... | @@ -21470,23 +22402,20 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -21470,23 +22402,20 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 21470 | } | 22402 | } |
| 21471 | | 22403 | |
| 21472 | if (is_comptime || old_dest_block->ref_count == 1) { | 22404 | if (is_comptime || old_dest_block->ref_count == 1) { |
| 21473 | return ir_inline_bb(ira, &switch_br_instruction->base, old_dest_block); | 22405 | return ir_inline_bb(ira, &switch_br_instruction->base.base, old_dest_block); |
| 21474 | } else { | 22406 | } else { |
| 21475 | IrBasicBlock *new_dest_block = ir_get_new_bb(ira, old_dest_block, &switch_br_instruction->base); | 22407 | IrBasicBlockGen *new_dest_block = ir_get_new_bb(ira, old_dest_block, &switch_br_instruction->base.base); |
| 21476 | IrInstruction *result = ir_build_br(&ira->new_irb, | 22408 | IrInstGen *result = ir_build_br_gen(ira, &switch_br_instruction->base.base, new_dest_block); |
| 21477 | switch_br_instruction->base.scope, switch_br_instruction->base.source_node, | | |
| 21478 | new_dest_block, nullptr); | | |
| 21479 | result->value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 21480 | return ir_finish_anal(ira, result); | 22409 | return ir_finish_anal(ira, result); |
| 21481 | } | 22410 | } |
| 21482 | } | 22411 | } |
| 21483 | | 22412 | |
| 21484 | IrInstructionSwitchBrCase *cases = allocate<IrInstructionSwitchBrCase>(case_count); | 22413 | IrInstGenSwitchBrCase *cases = allocate<IrInstGenSwitchBrCase>(case_count); |
| 21485 | for (size_t i = 0; i < case_count; i += 1) { | 22414 | for (size_t i = 0; i < case_count; i += 1) { |
| 21486 | IrInstructionSwitchBrCase *old_case = &switch_br_instruction->cases[i]; | 22415 | IrInstSrcSwitchBrCase *old_case = &switch_br_instruction->cases[i]; |
| 21487 | IrInstructionSwitchBrCase *new_case = &cases[i]; | 22416 | IrInstGenSwitchBrCase *new_case = &cases[i]; |
| 21488 | new_case->block = ir_get_new_bb(ira, old_case->block, &switch_br_instruction->base); | 22417 | new_case->block = ir_get_new_bb(ira, old_case->block, &switch_br_instruction->base.base); |
| 21489 | new_case->value = ira->codegen->invalid_instruction; | 22418 | new_case->value = ira->codegen->invalid_inst_gen; |
| 21490 | | 22419 | |
| 21491 | // Calling ir_get_new_bb set the ref_instruction on the new basic block. | 22420 | // Calling ir_get_new_bb set the ref_instruction on the new basic block. |
| 21492 | // However a switch br may branch to the same basic block which would trigger an | 22421 | // However a switch br may branch to the same basic block which would trigger an |
| ... | @@ -21494,12 +22423,12 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -21494,12 +22423,12 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 21494 | // it back after the loop. | 22423 | // it back after the loop. |
| 21495 | new_case->block->ref_instruction = nullptr; | 22424 | new_case->block->ref_instruction = nullptr; |
| 21496 | | 22425 | |
| 21497 | IrInstruction *old_value = old_case->value; | 22426 | IrInstSrc *old_value = old_case->value; |
| 21498 | IrInstruction *new_value = old_value->child; | 22427 | IrInstGen *new_value = old_value->child; |
| 21499 | if (type_is_invalid(new_value->value->type)) | 22428 | if (type_is_invalid(new_value->value->type)) |
| 21500 | continue; | 22429 | continue; |
| 21501 | | 22430 | |
| 21502 | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, target_value->value->type); | 22431 | IrInstGen *casted_new_value = ir_implicit_cast(ira, new_value, target_value->value->type); |
| 21503 | if (type_is_invalid(casted_new_value->value->type)) | 22432 | if (type_is_invalid(casted_new_value->value->type)) |
| 21504 | continue; | 22433 | continue; |
| 21505 | | 22434 | |
| ... | @@ -21510,47 +22439,45 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, | ... | @@ -21510,47 +22439,45 @@ static IrInstruction *ir_analyze_instruction_switch_br(IrAnalyze *ira, |
| 21510 | } | 22439 | } |
| 21511 | | 22440 | |
| 21512 | for (size_t i = 0; i < case_count; i += 1) { | 22441 | for (size_t i = 0; i < case_count; i += 1) { |
| 21513 | IrInstructionSwitchBrCase *new_case = &cases[i]; | 22442 | IrInstGenSwitchBrCase *new_case = &cases[i]; |
| 21514 | if (new_case->value == ira->codegen->invalid_instruction) | 22443 | if (type_is_invalid(new_case->value->value->type)) |
| 21515 | return ir_unreach_error(ira); | 22444 | return ir_unreach_error(ira); |
| 21516 | new_case->block->ref_instruction = &switch_br_instruction->base; | 22445 | new_case->block->ref_instruction = &switch_br_instruction->base.base; |
| 21517 | } | 22446 | } |
| 21518 | | 22447 | |
| 21519 | IrBasicBlock *new_else_block = ir_get_new_bb(ira, switch_br_instruction->else_block, &switch_br_instruction->base); | 22448 | IrBasicBlockGen *new_else_block = ir_get_new_bb(ira, switch_br_instruction->else_block, &switch_br_instruction->base.base); |
| 21520 | IrInstructionSwitchBr *switch_br = ir_build_switch_br(&ira->new_irb, | 22449 | IrInstGenSwitchBr *switch_br = ir_build_switch_br_gen(ira, &switch_br_instruction->base.base, |
| 21521 | switch_br_instruction->base.scope, switch_br_instruction->base.source_node, | 22450 | target_value, new_else_block, case_count, cases); |
| 21522 | target_value, new_else_block, case_count, cases, nullptr, nullptr); | | |
| 21523 | switch_br->base.value->type = ira->codegen->builtin_types.entry_unreachable; | | |
| 21524 | return ir_finish_anal(ira, &switch_br->base); | 22451 | return ir_finish_anal(ira, &switch_br->base); |
| 21525 | } | 22452 | } |
| 21526 | | 22453 | |
| 21527 | static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | 22454 | static IrInstGen *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 21528 | IrInstructionSwitchTarget *switch_target_instruction) | 22455 | IrInstSrcSwitchTarget *switch_target_instruction) |
| 21529 | { | 22456 | { |
| 21530 | Error err; | 22457 | Error err; |
| 21531 | IrInstruction *target_value_ptr = switch_target_instruction->target_value_ptr->child; | 22458 | IrInstGen *target_value_ptr = switch_target_instruction->target_value_ptr->child; |
| 21532 | if (type_is_invalid(target_value_ptr->value->type)) | 22459 | if (type_is_invalid(target_value_ptr->value->type)) |
| 21533 | return ira->codegen->invalid_instruction; | 22460 | return ira->codegen->invalid_inst_gen; |
| 21534 | | 22461 | |
| 21535 | if (target_value_ptr->value->type->id == ZigTypeIdMetaType) { | 22462 | if (target_value_ptr->value->type->id == ZigTypeIdMetaType) { |
| 21536 | assert(instr_is_comptime(target_value_ptr)); | 22463 | assert(instr_is_comptime(target_value_ptr)); |
| 21537 | ZigType *ptr_type = target_value_ptr->value->data.x_type; | 22464 | ZigType *ptr_type = target_value_ptr->value->data.x_type; |
| 21538 | assert(ptr_type->id == ZigTypeIdPointer); | 22465 | assert(ptr_type->id == ZigTypeIdPointer); |
| 21539 | return ir_const_type(ira, &switch_target_instruction->base, ptr_type->data.pointer.child_type); | 22466 | return ir_const_type(ira, &switch_target_instruction->base.base, ptr_type->data.pointer.child_type); |
| 21540 | } | 22467 | } |
| 21541 | | 22468 | |
| 21542 | ZigType *target_type = target_value_ptr->value->type->data.pointer.child_type; | 22469 | ZigType *target_type = target_value_ptr->value->type->data.pointer.child_type; |
| 21543 | ZigValue *pointee_val = nullptr; | 22470 | ZigValue *pointee_val = nullptr; |
| 21544 | if (instr_is_comptime(target_value_ptr) && target_value_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 22471 | if (instr_is_comptime(target_value_ptr) && target_value_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 21545 | pointee_val = const_ptr_pointee(ira, ira->codegen, target_value_ptr->value, target_value_ptr->source_node); | 22472 | pointee_val = const_ptr_pointee(ira, ira->codegen, target_value_ptr->value, target_value_ptr->base.source_node); |
| 21546 | if (pointee_val == nullptr) | 22473 | if (pointee_val == nullptr) |
| 21547 | return ira->codegen->invalid_instruction; | 22474 | return ira->codegen->invalid_inst_gen; |
| 21548 | | 22475 | |
| 21549 | if (pointee_val->special == ConstValSpecialRuntime) | 22476 | if (pointee_val->special == ConstValSpecialRuntime) |
| 21550 | pointee_val = nullptr; | 22477 | pointee_val = nullptr; |
| 21551 | } | 22478 | } |
| 21552 | if ((err = type_resolve(ira->codegen, target_type, ResolveStatusSizeKnown))) | 22479 | if ((err = type_resolve(ira->codegen, target_type, ResolveStatusSizeKnown))) |
| 21553 | return ira->codegen->invalid_instruction; | 22480 | return ira->codegen->invalid_inst_gen; |
| 21554 | | 22481 | |
| 21555 | switch (target_type->id) { | 22482 | switch (target_type->id) { |
| 21556 | case ZigTypeIdInvalid: | 22483 | case ZigTypeIdInvalid: |
| ... | @@ -21567,13 +22494,13 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -21567,13 +22494,13 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 21567 | case ZigTypeIdFn: | 22494 | case ZigTypeIdFn: |
| 21568 | case ZigTypeIdErrorSet: { | 22495 | case ZigTypeIdErrorSet: { |
| 21569 | if (pointee_val) { | 22496 | if (pointee_val) { |
| 21570 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, nullptr); | 22497 | IrInstGen *result = ir_const(ira, &switch_target_instruction->base.base, nullptr); |
| 21571 | copy_const_val(result->value, pointee_val); | 22498 | copy_const_val(result->value, pointee_val); |
| 21572 | result->value->type = target_type; | 22499 | result->value->type = target_type; |
| 21573 | return result; | 22500 | return result; |
| 21574 | } | 22501 | } |
| 21575 | | 22502 | |
| 21576 | IrInstruction *result = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); | 22503 | IrInstGen *result = ir_get_deref(ira, &switch_target_instruction->base.base, target_value_ptr, nullptr); |
| 21577 | result->value->type = target_type; | 22504 | result->value->type = target_type; |
| 21578 | return result; | 22505 | return result; |
| 21579 | } | 22506 | } |
| ... | @@ -21582,52 +22509,49 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -21582,52 +22509,49 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 21582 | if (!decl_node->data.container_decl.auto_enum && | 22509 | if (!decl_node->data.container_decl.auto_enum && |
| 21583 | decl_node->data.container_decl.init_arg_expr == nullptr) | 22510 | decl_node->data.container_decl.init_arg_expr == nullptr) |
| 21584 | { | 22511 | { |
| 21585 | ErrorMsg *msg = ir_add_error(ira, target_value_ptr, | 22512 | ErrorMsg *msg = ir_add_error(ira, &target_value_ptr->base, |
| 21586 | buf_sprintf("switch on union which has no attached enum")); | 22513 | buf_sprintf("switch on union which has no attached enum")); |
| 21587 | add_error_note(ira->codegen, msg, decl_node, | 22514 | add_error_note(ira->codegen, msg, decl_node, |
| 21588 | buf_sprintf("consider 'union(enum)' here")); | 22515 | buf_sprintf("consider 'union(enum)' here")); |
| 21589 | return ira->codegen->invalid_instruction; | 22516 | return ira->codegen->invalid_inst_gen; |
| 21590 | } | 22517 | } |
| 21591 | ZigType *tag_type = target_type->data.unionation.tag_type; | 22518 | ZigType *tag_type = target_type->data.unionation.tag_type; |
| 21592 | assert(tag_type != nullptr); | 22519 | assert(tag_type != nullptr); |
| 21593 | assert(tag_type->id == ZigTypeIdEnum); | 22520 | assert(tag_type->id == ZigTypeIdEnum); |
| 21594 | if (pointee_val) { | 22521 | if (pointee_val) { |
| 21595 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, tag_type); | 22522 | IrInstGen *result = ir_const(ira, &switch_target_instruction->base.base, tag_type); |
| 21596 | bigint_init_bigint(&result->value->data.x_enum_tag, &pointee_val->data.x_union.tag); | 22523 | bigint_init_bigint(&result->value->data.x_enum_tag, &pointee_val->data.x_union.tag); |
| 21597 | return result; | 22524 | return result; |
| 21598 | } | 22525 | } |
| 21599 | if (tag_type->data.enumeration.src_field_count == 1) { | 22526 | if (tag_type->data.enumeration.src_field_count == 1) { |
| 21600 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, tag_type); | 22527 | IrInstGen *result = ir_const(ira, &switch_target_instruction->base.base, tag_type); |
| 21601 | TypeEnumField *only_field = &tag_type->data.enumeration.fields[0]; | 22528 | TypeEnumField *only_field = &tag_type->data.enumeration.fields[0]; |
| 21602 | bigint_init_bigint(&result->value->data.x_enum_tag, &only_field->value); | 22529 | bigint_init_bigint(&result->value->data.x_enum_tag, &only_field->value); |
| 21603 | return result; | 22530 | return result; |
| 21604 | } | 22531 | } |
| 21605 | | 22532 | |
| 21606 | IrInstruction *union_value = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); | 22533 | IrInstGen *union_value = ir_get_deref(ira, &switch_target_instruction->base.base, target_value_ptr, nullptr); |
| 21607 | union_value->value->type = target_type; | 22534 | union_value->value->type = target_type; |
| 21608 | | 22535 | |
| 21609 | IrInstruction *union_tag_inst = ir_build_union_tag(&ira->new_irb, switch_target_instruction->base.scope, | 22536 | return ir_build_union_tag(ira, &switch_target_instruction->base.base, union_value, tag_type); |
| 21610 | switch_target_instruction->base.source_node, union_value); | | |
| 21611 | union_tag_inst->value->type = tag_type; | | |
| 21612 | return union_tag_inst; | | |
| 21613 | } | 22537 | } |
| 21614 | case ZigTypeIdEnum: { | 22538 | case ZigTypeIdEnum: { |
| 21615 | if ((err = type_resolve(ira->codegen, target_type, ResolveStatusZeroBitsKnown))) | 22539 | if ((err = type_resolve(ira->codegen, target_type, ResolveStatusZeroBitsKnown))) |
| 21616 | return ira->codegen->invalid_instruction; | 22540 | return ira->codegen->invalid_inst_gen; |
| 21617 | if (target_type->data.enumeration.src_field_count == 1) { | 22541 | if (target_type->data.enumeration.src_field_count == 1) { |
| 21618 | TypeEnumField *only_field = &target_type->data.enumeration.fields[0]; | 22542 | TypeEnumField *only_field = &target_type->data.enumeration.fields[0]; |
| 21619 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, target_type); | 22543 | IrInstGen *result = ir_const(ira, &switch_target_instruction->base.base, target_type); |
| 21620 | bigint_init_bigint(&result->value->data.x_enum_tag, &only_field->value); | 22544 | bigint_init_bigint(&result->value->data.x_enum_tag, &only_field->value); |
| 21621 | return result; | 22545 | return result; |
| 21622 | } | 22546 | } |
| 21623 | | 22547 | |
| 21624 | if (pointee_val) { | 22548 | if (pointee_val) { |
| 21625 | IrInstruction *result = ir_const(ira, &switch_target_instruction->base, target_type); | 22549 | IrInstGen *result = ir_const(ira, &switch_target_instruction->base.base, target_type); |
| 21626 | bigint_init_bigint(&result->value->data.x_enum_tag, &pointee_val->data.x_enum_tag); | 22550 | bigint_init_bigint(&result->value->data.x_enum_tag, &pointee_val->data.x_enum_tag); |
| 21627 | return result; | 22551 | return result; |
| 21628 | } | 22552 | } |
| 21629 | | 22553 | |
| 21630 | IrInstruction *enum_value = ir_get_deref(ira, &switch_target_instruction->base, target_value_ptr, nullptr); | 22554 | IrInstGen *enum_value = ir_get_deref(ira, &switch_target_instruction->base.base, target_value_ptr, nullptr); |
| 21631 | enum_value->value->type = target_type; | 22555 | enum_value->value->type = target_type; |
| 21632 | return enum_value; | 22556 | return enum_value; |
| 21633 | } | 22557 | } |
| ... | @@ -21643,17 +22567,17 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -21643,17 +22567,17 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 21643 | case ZigTypeIdVector: | 22567 | case ZigTypeIdVector: |
| 21644 | case ZigTypeIdFnFrame: | 22568 | case ZigTypeIdFnFrame: |
| 21645 | case ZigTypeIdAnyFrame: | 22569 | case ZigTypeIdAnyFrame: |
| 21646 | ir_add_error(ira, &switch_target_instruction->base, | 22570 | ir_add_error(ira, &switch_target_instruction->base.base, |
| 21647 | buf_sprintf("invalid switch target type '%s'", buf_ptr(&target_type->name))); | 22571 | buf_sprintf("invalid switch target type '%s'", buf_ptr(&target_type->name))); |
| 21648 | return ira->codegen->invalid_instruction; | 22572 | return ira->codegen->invalid_inst_gen; |
| 21649 | } | 22573 | } |
| 21650 | zig_unreachable(); | 22574 | zig_unreachable(); |
| 21651 | } | 22575 | } |
| 21652 | | 22576 | |
| 21653 | static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstructionSwitchVar *instruction) { | 22577 | static IrInstGen *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstSrcSwitchVar *instruction) { |
| 21654 | IrInstruction *target_value_ptr = instruction->target_value_ptr->child; | 22578 | IrInstGen *target_value_ptr = instruction->target_value_ptr->child; |
| 21655 | if (type_is_invalid(target_value_ptr->value->type)) | 22579 | if (type_is_invalid(target_value_ptr->value->type)) |
| 21656 | return ira->codegen->invalid_instruction; | 22580 | return ira->codegen->invalid_inst_gen; |
| 21657 | | 22581 | |
| 21658 | ZigType *ref_type = target_value_ptr->value->type; | 22582 | ZigType *ref_type = target_value_ptr->value->type; |
| 21659 | assert(ref_type->id == ZigTypeIdPointer); | 22583 | assert(ref_type->id == ZigTypeIdPointer); |
| ... | @@ -21664,62 +22588,62 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -21664,62 +22588,62 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 21664 | assert(enum_type->id == ZigTypeIdEnum); | 22588 | assert(enum_type->id == ZigTypeIdEnum); |
| 21665 | assert(instruction->prongs_len > 0); | 22589 | assert(instruction->prongs_len > 0); |
| 21666 | | 22590 | |
| 21667 | IrInstruction *first_prong_value = instruction->prongs_ptr[0]->child; | 22591 | IrInstGen *first_prong_value = instruction->prongs_ptr[0]->child; |
| 21668 | if (type_is_invalid(first_prong_value->value->type)) | 22592 | if (type_is_invalid(first_prong_value->value->type)) |
| 21669 | return ira->codegen->invalid_instruction; | 22593 | return ira->codegen->invalid_inst_gen; |
| 21670 | | 22594 | |
| 21671 | IrInstruction *first_casted_prong_value = ir_implicit_cast(ira, first_prong_value, enum_type); | 22595 | IrInstGen *first_casted_prong_value = ir_implicit_cast(ira, first_prong_value, enum_type); |
| 21672 | if (type_is_invalid(first_casted_prong_value->value->type)) | 22596 | if (type_is_invalid(first_casted_prong_value->value->type)) |
| 21673 | return ira->codegen->invalid_instruction; | 22597 | return ira->codegen->invalid_inst_gen; |
| 21674 | | 22598 | |
| 21675 | ZigValue *first_prong_val = ir_resolve_const(ira, first_casted_prong_value, UndefBad); | 22599 | ZigValue *first_prong_val = ir_resolve_const(ira, first_casted_prong_value, UndefBad); |
| 21676 | if (first_prong_val == nullptr) | 22600 | if (first_prong_val == nullptr) |
| 21677 | return ira->codegen->invalid_instruction; | 22601 | return ira->codegen->invalid_inst_gen; |
| 21678 | | 22602 | |
| 21679 | TypeUnionField *first_field = find_union_field_by_tag(target_type, &first_prong_val->data.x_enum_tag); | 22603 | TypeUnionField *first_field = find_union_field_by_tag(target_type, &first_prong_val->data.x_enum_tag); |
| 21680 | | 22604 | |
| 21681 | ErrorMsg *invalid_payload_msg = nullptr; | 22605 | ErrorMsg *invalid_payload_msg = nullptr; |
| 21682 | for (size_t prong_i = 1; prong_i < instruction->prongs_len; prong_i += 1) { | 22606 | for (size_t prong_i = 1; prong_i < instruction->prongs_len; prong_i += 1) { |
| 21683 | IrInstruction *this_prong_inst = instruction->prongs_ptr[prong_i]->child; | 22607 | IrInstGen *this_prong_inst = instruction->prongs_ptr[prong_i]->child; |
| 21684 | if (type_is_invalid(this_prong_inst->value->type)) | 22608 | if (type_is_invalid(this_prong_inst->value->type)) |
| 21685 | return ira->codegen->invalid_instruction; | 22609 | return ira->codegen->invalid_inst_gen; |
| 21686 | | 22610 | |
| 21687 | IrInstruction *this_casted_prong_value = ir_implicit_cast(ira, this_prong_inst, enum_type); | 22611 | IrInstGen *this_casted_prong_value = ir_implicit_cast(ira, this_prong_inst, enum_type); |
| 21688 | if (type_is_invalid(this_casted_prong_value->value->type)) | 22612 | if (type_is_invalid(this_casted_prong_value->value->type)) |
| 21689 | return ira->codegen->invalid_instruction; | 22613 | return ira->codegen->invalid_inst_gen; |
| 21690 | | 22614 | |
| 21691 | ZigValue *this_prong = ir_resolve_const(ira, this_casted_prong_value, UndefBad); | 22615 | ZigValue *this_prong = ir_resolve_const(ira, this_casted_prong_value, UndefBad); |
| 21692 | if (this_prong == nullptr) | 22616 | if (this_prong == nullptr) |
| 21693 | return ira->codegen->invalid_instruction; | 22617 | return ira->codegen->invalid_inst_gen; |
| 21694 | | 22618 | |
| 21695 | TypeUnionField *payload_field = find_union_field_by_tag(target_type, &this_prong->data.x_enum_tag); | 22619 | TypeUnionField *payload_field = find_union_field_by_tag(target_type, &this_prong->data.x_enum_tag); |
| 21696 | ZigType *payload_type = payload_field->type_entry; | 22620 | ZigType *payload_type = payload_field->type_entry; |
| 21697 | if (first_field->type_entry != payload_type) { | 22621 | if (first_field->type_entry != payload_type) { |
| 21698 | if (invalid_payload_msg == nullptr) { | 22622 | if (invalid_payload_msg == nullptr) { |
| 21699 | invalid_payload_msg = ir_add_error(ira, &instruction->base, | 22623 | invalid_payload_msg = ir_add_error(ira, &instruction->base.base, |
| 21700 | buf_sprintf("capture group with incompatible types")); | 22624 | buf_sprintf("capture group with incompatible types")); |
| 21701 | add_error_note(ira->codegen, invalid_payload_msg, first_prong_value->source_node, | 22625 | add_error_note(ira->codegen, invalid_payload_msg, first_prong_value->base.source_node, |
| 21702 | buf_sprintf("type '%s' here", buf_ptr(&first_field->type_entry->name))); | 22626 | buf_sprintf("type '%s' here", buf_ptr(&first_field->type_entry->name))); |
| 21703 | } | 22627 | } |
| 21704 | add_error_note(ira->codegen, invalid_payload_msg, this_prong_inst->source_node, | 22628 | add_error_note(ira->codegen, invalid_payload_msg, this_prong_inst->base.source_node, |
| 21705 | buf_sprintf("type '%s' here", buf_ptr(&payload_field->type_entry->name))); | 22629 | buf_sprintf("type '%s' here", buf_ptr(&payload_field->type_entry->name))); |
| 21706 | } | 22630 | } |
| 21707 | } | 22631 | } |
| 21708 | | 22632 | |
| 21709 | if (invalid_payload_msg != nullptr) { | 22633 | if (invalid_payload_msg != nullptr) { |
| 21710 | return ira->codegen->invalid_instruction; | 22634 | return ira->codegen->invalid_inst_gen; |
| 21711 | } | 22635 | } |
| 21712 | | 22636 | |
| 21713 | if (instr_is_comptime(target_value_ptr)) { | 22637 | if (instr_is_comptime(target_value_ptr)) { |
| 21714 | ZigValue *target_val_ptr = ir_resolve_const(ira, target_value_ptr, UndefBad); | 22638 | ZigValue *target_val_ptr = ir_resolve_const(ira, target_value_ptr, UndefBad); |
| 21715 | if (!target_value_ptr) | 22639 | if (!target_value_ptr) |
| 21716 | return ira->codegen->invalid_instruction; | 22640 | return ira->codegen->invalid_inst_gen; |
| 21717 | | 22641 | |
| 21718 | ZigValue *pointee_val = const_ptr_pointee(ira, ira->codegen, target_val_ptr, instruction->base.source_node); | 22642 | ZigValue *pointee_val = const_ptr_pointee(ira, ira->codegen, target_val_ptr, instruction->base.base.source_node); |
| 21719 | if (pointee_val == nullptr) | 22643 | if (pointee_val == nullptr) |
| 21720 | return ira->codegen->invalid_instruction; | 22644 | return ira->codegen->invalid_inst_gen; |
| 21721 | | 22645 | |
| 21722 | IrInstruction *result = ir_const(ira, &instruction->base, | 22646 | IrInstGen *result = ir_const(ira, &instruction->base.base, |
| 21723 | get_pointer_to_type(ira->codegen, first_field->type_entry, | 22647 | get_pointer_to_type(ira->codegen, first_field->type_entry, |
| 21724 | target_val_ptr->type->data.pointer.is_const)); | 22648 | target_val_ptr->type->data.pointer.is_const)); |
| 21725 | ZigValue *out_val = result->value; | 22649 | ZigValue *out_val = result->value; |
| ... | @@ -21729,11 +22653,10 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -21729,11 +22653,10 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 21729 | return result; | 22653 | return result; |
| 21730 | } | 22654 | } |
| 21731 | | 22655 | |
| 21732 | IrInstruction *result = ir_build_union_field_ptr(&ira->new_irb, | 22656 | ZigType *result_type = get_pointer_to_type(ira->codegen, first_field->type_entry, |
| 21733 | instruction->base.scope, instruction->base.source_node, target_value_ptr, first_field, false, false); | | |
| 21734 | result->value->type = get_pointer_to_type(ira->codegen, first_field->type_entry, | | |
| 21735 | target_value_ptr->value->type->data.pointer.is_const); | 22657 | target_value_ptr->value->type->data.pointer.is_const); |
| 21736 | return result; | 22658 | return ir_build_union_field_ptr(ira, &instruction->base.base, target_value_ptr, first_field, |
| | 22659 | false, false, result_type); |
| 21737 | } else if (target_type->id == ZigTypeIdErrorSet) { | 22660 | } else if (target_type->id == ZigTypeIdErrorSet) { |
| 21738 | // construct an error set from the prong values | 22661 | // construct an error set from the prong values |
| 21739 | ZigType *err_set_type = new_type_table_entry(ZigTypeIdErrorSet); | 22662 | ZigType *err_set_type = new_type_table_entry(ZigTypeIdErrorSet); |
| ... | @@ -21746,7 +22669,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -21746,7 +22669,7 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 21746 | for (size_t i = 0; i < instruction->prongs_len; i += 1) { | 22669 | for (size_t i = 0; i < instruction->prongs_len; i += 1) { |
| 21747 | ErrorTableEntry *err = ir_resolve_error(ira, instruction->prongs_ptr[i]->child); | 22670 | ErrorTableEntry *err = ir_resolve_error(ira, instruction->prongs_ptr[i]->child); |
| 21748 | if (err == nullptr) | 22671 | if (err == nullptr) |
| 21749 | return ira->codegen->invalid_instruction; | 22672 | return ira->codegen->invalid_inst_gen; |
| 21750 | error_list.append(err); | 22673 | error_list.append(err); |
| 21751 | buf_appendf(&err_set_type->name, "%s,", buf_ptr(&err->name)); | 22674 | buf_appendf(&err_set_type->name, "%s,", buf_ptr(&err->name)); |
| 21752 | } | 22675 | } |
| ... | @@ -21762,29 +22685,29 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru | ... | @@ -21762,29 +22685,29 @@ static IrInstruction *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstru |
| 21762 | ref_type->data.pointer.explicit_alignment, | 22685 | ref_type->data.pointer.explicit_alignment, |
| 21763 | ref_type->data.pointer.bit_offset_in_host, ref_type->data.pointer.host_int_bytes, | 22686 | ref_type->data.pointer.bit_offset_in_host, ref_type->data.pointer.host_int_bytes, |
| 21764 | ref_type->data.pointer.allow_zero); | 22687 | ref_type->data.pointer.allow_zero); |
| 21765 | return ir_analyze_ptr_cast(ira, &instruction->base, target_value_ptr, new_target_value_ptr_type, | 22688 | return ir_analyze_ptr_cast(ira, &instruction->base.base, target_value_ptr, new_target_value_ptr_type, |
| 21766 | &instruction->base, false); | 22689 | &instruction->base.base, false); |
| 21767 | } else { | 22690 | } else { |
| 21768 | ir_add_error(ira, &instruction->base, | 22691 | ir_add_error(ira, &instruction->base.base, |
| 21769 | buf_sprintf("switch on type '%s' provides no expression parameter", buf_ptr(&target_type->name))); | 22692 | buf_sprintf("switch on type '%s' provides no expression parameter", buf_ptr(&target_type->name))); |
| 21770 | return ira->codegen->invalid_instruction; | 22693 | return ira->codegen->invalid_inst_gen; |
| 21771 | } | 22694 | } |
| 21772 | } | 22695 | } |
| 21773 | | 22696 | |
| 21774 | static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, | 22697 | static IrInstGen *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, |
| 21775 | IrInstructionSwitchElseVar *instruction) | 22698 | IrInstSrcSwitchElseVar *instruction) |
| 21776 | { | 22699 | { |
| 21777 | IrInstruction *target_value_ptr = instruction->target_value_ptr->child; | 22700 | IrInstGen *target_value_ptr = instruction->target_value_ptr->child; |
| 21778 | if (type_is_invalid(target_value_ptr->value->type)) | 22701 | if (type_is_invalid(target_value_ptr->value->type)) |
| 21779 | return ira->codegen->invalid_instruction; | 22702 | return ira->codegen->invalid_inst_gen; |
| 21780 | | 22703 | |
| 21781 | ZigType *ref_type = target_value_ptr->value->type; | 22704 | ZigType *ref_type = target_value_ptr->value->type; |
| 21782 | assert(ref_type->id == ZigTypeIdPointer); | 22705 | assert(ref_type->id == ZigTypeIdPointer); |
| 21783 | ZigType *target_type = target_value_ptr->value->type->data.pointer.child_type; | 22706 | ZigType *target_type = target_value_ptr->value->type->data.pointer.child_type; |
| 21784 | if (target_type->id == ZigTypeIdErrorSet) { | 22707 | if (target_type->id == ZigTypeIdErrorSet) { |
| 21785 | // make a new set that has the other cases removed | 22708 | // make a new set that has the other cases removed |
| 21786 | if (!resolve_inferred_error_set(ira->codegen, target_type, instruction->base.source_node)) { | 22709 | if (!resolve_inferred_error_set(ira->codegen, target_type, instruction->base.base.source_node)) { |
| 21787 | return ira->codegen->invalid_instruction; | 22710 | return ira->codegen->invalid_inst_gen; |
| 21788 | } | 22711 | } |
| 21789 | if (type_is_global_error_set(target_type)) { | 22712 | if (type_is_global_error_set(target_type)) { |
| 21790 | // the type of the else capture variable still has to be the global error set. | 22713 | // the type of the else capture variable still has to be the global error set. |
| ... | @@ -21794,17 +22717,17 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, | ... | @@ -21794,17 +22717,17 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, |
| 21794 | // Make note of the errors handled by other cases | 22717 | // Make note of the errors handled by other cases |
| 21795 | ErrorTableEntry **errors = allocate<ErrorTableEntry *>(ira->codegen->errors_by_index.length); | 22718 | ErrorTableEntry **errors = allocate<ErrorTableEntry *>(ira->codegen->errors_by_index.length); |
| 21796 | for (size_t case_i = 0; case_i < instruction->switch_br->case_count; case_i += 1) { | 22719 | for (size_t case_i = 0; case_i < instruction->switch_br->case_count; case_i += 1) { |
| 21797 | IrInstructionSwitchBrCase *br_case = &instruction->switch_br->cases[case_i]; | 22720 | IrInstSrcSwitchBrCase *br_case = &instruction->switch_br->cases[case_i]; |
| 21798 | IrInstruction *case_expr = br_case->value->child; | 22721 | IrInstGen *case_expr = br_case->value->child; |
| 21799 | if (case_expr->value->type->id == ZigTypeIdErrorSet) { | 22722 | if (case_expr->value->type->id == ZigTypeIdErrorSet) { |
| 21800 | ErrorTableEntry *err = ir_resolve_error(ira, case_expr); | 22723 | ErrorTableEntry *err = ir_resolve_error(ira, case_expr); |
| 21801 | if (err == nullptr) | 22724 | if (err == nullptr) |
| 21802 | return ira->codegen->invalid_instruction; | 22725 | return ira->codegen->invalid_inst_gen; |
| 21803 | errors[err->value] = err; | 22726 | errors[err->value] = err; |
| 21804 | } else if (case_expr->value->type->id == ZigTypeIdMetaType) { | 22727 | } else if (case_expr->value->type->id == ZigTypeIdMetaType) { |
| 21805 | ZigType *err_set_type = ir_resolve_type(ira, case_expr); | 22728 | ZigType *err_set_type = ir_resolve_type(ira, case_expr); |
| 21806 | if (type_is_invalid(err_set_type)) | 22729 | if (type_is_invalid(err_set_type)) |
| 21807 | return ira->codegen->invalid_instruction; | 22730 | return ira->codegen->invalid_inst_gen; |
| 21808 | populate_error_set_table(errors, err_set_type); | 22731 | populate_error_set_table(errors, err_set_type); |
| 21809 | } else { | 22732 | } else { |
| 21810 | zig_unreachable(); | 22733 | zig_unreachable(); |
| ... | @@ -21843,27 +22766,22 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, | ... | @@ -21843,27 +22766,22 @@ static IrInstruction *ir_analyze_instruction_switch_else_var(IrAnalyze *ira, |
| 21843 | ref_type->data.pointer.explicit_alignment, | 22766 | ref_type->data.pointer.explicit_alignment, |
| 21844 | ref_type->data.pointer.bit_offset_in_host, ref_type->data.pointer.host_int_bytes, | 22767 | ref_type->data.pointer.bit_offset_in_host, ref_type->data.pointer.host_int_bytes, |
| 21845 | ref_type->data.pointer.allow_zero); | 22768 | ref_type->data.pointer.allow_zero); |
| 21846 | return ir_analyze_ptr_cast(ira, &instruction->base, target_value_ptr, new_target_value_ptr_type, | 22769 | return ir_analyze_ptr_cast(ira, &instruction->base.base, target_value_ptr, new_target_value_ptr_type, |
| 21847 | &instruction->base, false); | 22770 | &instruction->base.base, false); |
| 21848 | } | 22771 | } |
| 21849 | | 22772 | |
| 21850 | return target_value_ptr; | 22773 | return target_value_ptr; |
| 21851 | } | 22774 | } |
| 21852 | | 22775 | |
| 21853 | static IrInstruction *ir_analyze_instruction_union_tag(IrAnalyze *ira, IrInstructionUnionTag *instruction) { | 22776 | static IrInstGen *ir_analyze_instruction_import(IrAnalyze *ira, IrInstSrcImport *import_instruction) { |
| 21854 | IrInstruction *value = instruction->value->child; | | |
| 21855 | return ir_analyze_union_tag(ira, &instruction->base, value); | | |
| 21856 | } | | |
| 21857 | | | |
| 21858 | static IrInstruction *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructionImport *import_instruction) { | | |
| 21859 | Error err; | 22777 | Error err; |
| 21860 | | 22778 | |
| 21861 | IrInstruction *name_value = import_instruction->name->child; | 22779 | IrInstGen *name_value = import_instruction->name->child; |
| 21862 | Buf *import_target_str = ir_resolve_str(ira, name_value); | 22780 | Buf *import_target_str = ir_resolve_str(ira, name_value); |
| 21863 | if (!import_target_str) | 22781 | if (!import_target_str) |
| 21864 | return ira->codegen->invalid_instruction; | 22782 | return ira->codegen->invalid_inst_gen; |
| 21865 | | 22783 | |
| 21866 | AstNode *source_node = import_instruction->base.source_node; | 22784 | AstNode *source_node = import_instruction->base.base.source_node; |
| 21867 | ZigType *import = source_node->owner; | 22785 | ZigType *import = source_node->owner; |
| 21868 | | 22786 | |
| 21869 | ZigType *target_import; | 22787 | ZigType *target_import; |
| ... | @@ -21876,48 +22794,48 @@ static IrInstruction *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructio | ... | @@ -21876,48 +22794,48 @@ static IrInstruction *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructio |
| 21876 | ir_add_error_node(ira, source_node, | 22794 | ir_add_error_node(ira, source_node, |
| 21877 | buf_sprintf("import of file outside package path: '%s'", | 22795 | buf_sprintf("import of file outside package path: '%s'", |
| 21878 | buf_ptr(import_target_path))); | 22796 | buf_ptr(import_target_path))); |
| 21879 | return ira->codegen->invalid_instruction; | 22797 | return ira->codegen->invalid_inst_gen; |
| 21880 | } else if (err == ErrorFileNotFound) { | 22798 | } else if (err == ErrorFileNotFound) { |
| 21881 | ir_add_error_node(ira, source_node, | 22799 | ir_add_error_node(ira, source_node, |
| 21882 | buf_sprintf("unable to find '%s'", buf_ptr(import_target_path))); | 22800 | buf_sprintf("unable to find '%s'", buf_ptr(import_target_path))); |
| 21883 | return ira->codegen->invalid_instruction; | 22801 | return ira->codegen->invalid_inst_gen; |
| 21884 | } else { | 22802 | } else { |
| 21885 | ir_add_error_node(ira, source_node, | 22803 | ir_add_error_node(ira, source_node, |
| 21886 | buf_sprintf("unable to open '%s': %s", buf_ptr(&full_path), err_str(err))); | 22804 | buf_sprintf("unable to open '%s': %s", buf_ptr(&full_path), err_str(err))); |
| 21887 | return ira->codegen->invalid_instruction; | 22805 | return ira->codegen->invalid_inst_gen; |
| 21888 | } | 22806 | } |
| 21889 | } | 22807 | } |
| 21890 | | 22808 | |
| 21891 | return ir_const_type(ira, &import_instruction->base, target_import); | 22809 | return ir_const_type(ira, &import_instruction->base.base, target_import); |
| 21892 | } | 22810 | } |
| 21893 | | 22811 | |
| 21894 | static IrInstruction *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstructionRef *ref_instruction) { | 22812 | static IrInstGen *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstSrcRef *ref_instruction) { |
| 21895 | IrInstruction *value = ref_instruction->value->child; | 22813 | IrInstGen *value = ref_instruction->value->child; |
| 21896 | if (type_is_invalid(value->value->type)) | 22814 | if (type_is_invalid(value->value->type)) |
| 21897 | return ira->codegen->invalid_instruction; | 22815 | return ira->codegen->invalid_inst_gen; |
| 21898 | return ir_get_ref(ira, &ref_instruction->base, value, ref_instruction->is_const, ref_instruction->is_volatile); | 22816 | return ir_get_ref(ira, &ref_instruction->base.base, value, ref_instruction->is_const, ref_instruction->is_volatile); |
| 21899 | } | 22817 | } |
| 21900 | | 22818 | |
| 21901 | static IrInstruction *ir_analyze_union_init(IrAnalyze *ira, IrInstruction *source_instruction, | 22819 | static IrInstGen *ir_analyze_union_init(IrAnalyze *ira, IrInst* source_instruction, |
| 21902 | AstNode *field_source_node, ZigType *union_type, Buf *field_name, IrInstruction *field_result_loc, | 22820 | AstNode *field_source_node, ZigType *union_type, Buf *field_name, IrInstGen *field_result_loc, |
| 21903 | IrInstruction *result_loc) | 22821 | IrInstGen *result_loc) |
| 21904 | { | 22822 | { |
| 21905 | Error err; | 22823 | Error err; |
| 21906 | assert(union_type->id == ZigTypeIdUnion); | 22824 | assert(union_type->id == ZigTypeIdUnion); |
| 21907 | | 22825 | |
| 21908 | if ((err = type_resolve(ira->codegen, union_type, ResolveStatusSizeKnown))) | 22826 | if ((err = type_resolve(ira->codegen, union_type, ResolveStatusSizeKnown))) |
| 21909 | return ira->codegen->invalid_instruction; | 22827 | return ira->codegen->invalid_inst_gen; |
| 21910 | | 22828 | |
| 21911 | TypeUnionField *type_field = find_union_type_field(union_type, field_name); | 22829 | TypeUnionField *type_field = find_union_type_field(union_type, field_name); |
| 21912 | if (type_field == nullptr) { | 22830 | if (type_field == nullptr) { |
| 21913 | ir_add_error_node(ira, field_source_node, | 22831 | ir_add_error_node(ira, field_source_node, |
| 21914 | buf_sprintf("no member named '%s' in union '%s'", | 22832 | buf_sprintf("no member named '%s' in union '%s'", |
| 21915 | buf_ptr(field_name), buf_ptr(&union_type->name))); | 22833 | buf_ptr(field_name), buf_ptr(&union_type->name))); |
| 21916 | return ira->codegen->invalid_instruction; | 22834 | return ira->codegen->invalid_inst_gen; |
| 21917 | } | 22835 | } |
| 21918 | | 22836 | |
| 21919 | if (type_is_invalid(type_field->type_entry)) | 22837 | if (type_is_invalid(type_field->type_entry)) |
| 21920 | return ira->codegen->invalid_instruction; | 22838 | return ira->codegen->invalid_inst_gen; |
| 21921 | | 22839 | |
| 21922 | if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) { | 22840 | if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) { |
| 21923 | if (instr_is_comptime(field_result_loc) && | 22841 | if (instr_is_comptime(field_result_loc) && |
| ... | @@ -21929,42 +22847,42 @@ static IrInstruction *ir_analyze_union_init(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -21929,42 +22847,42 @@ static IrInstruction *ir_analyze_union_init(IrAnalyze *ira, IrInstruction *sourc |
| 21929 | } | 22847 | } |
| 21930 | } | 22848 | } |
| 21931 | | 22849 | |
| 21932 | bool is_comptime = ir_should_inline(ira->new_irb.exec, source_instruction->scope) | 22850 | bool is_comptime = ir_should_inline(ira->old_irb.exec, source_instruction->scope) |
| 21933 | || type_requires_comptime(ira->codegen, union_type) == ReqCompTimeYes; | 22851 | || type_requires_comptime(ira->codegen, union_type) == ReqCompTimeYes; |
| 21934 | | 22852 | |
| 21935 | IrInstruction *result = ir_get_deref(ira, source_instruction, result_loc, nullptr); | 22853 | IrInstGen *result = ir_get_deref(ira, source_instruction, result_loc, nullptr); |
| 21936 | if (is_comptime && !instr_is_comptime(result)) { | 22854 | if (is_comptime && !instr_is_comptime(result)) { |
| 21937 | ir_add_error(ira, field_result_loc, | 22855 | ir_add_error(ira, &field_result_loc->base, |
| 21938 | buf_sprintf("unable to evaluate constant expression")); | 22856 | buf_sprintf("unable to evaluate constant expression")); |
| 21939 | return ira->codegen->invalid_instruction; | 22857 | return ira->codegen->invalid_inst_gen; |
| 21940 | } | 22858 | } |
| 21941 | return result; | 22859 | return result; |
| 21942 | } | 22860 | } |
| 21943 | | 22861 | |
| 21944 | static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruction *instruction, | 22862 | static IrInstGen *ir_analyze_container_init_fields(IrAnalyze *ira, IrInst *source_instr, |
| 21945 | ZigType *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields, | 22863 | ZigType *container_type, size_t instr_field_count, IrInstSrcContainerInitFieldsField *fields, |
| 21946 | IrInstruction *result_loc) | 22864 | IrInstGen *result_loc) |
| 21947 | { | 22865 | { |
| 21948 | Error err; | 22866 | Error err; |
| 21949 | if (container_type->id == ZigTypeIdUnion) { | 22867 | if (container_type->id == ZigTypeIdUnion) { |
| 21950 | if (instr_field_count != 1) { | 22868 | if (instr_field_count != 1) { |
| 21951 | ir_add_error(ira, instruction, | 22869 | ir_add_error(ira, source_instr, |
| 21952 | buf_sprintf("union initialization expects exactly one field")); | 22870 | buf_sprintf("union initialization expects exactly one field")); |
| 21953 | return ira->codegen->invalid_instruction; | 22871 | return ira->codegen->invalid_inst_gen; |
| 21954 | } | 22872 | } |
| 21955 | IrInstructionContainerInitFieldsField *field = &fields[0]; | 22873 | IrInstSrcContainerInitFieldsField *field = &fields[0]; |
| 21956 | IrInstruction *field_result_loc = field->result_loc->child; | 22874 | IrInstGen *field_result_loc = field->result_loc->child; |
| 21957 | if (type_is_invalid(field_result_loc->value->type)) | 22875 | if (type_is_invalid(field_result_loc->value->type)) |
| 21958 | return ira->codegen->invalid_instruction; | 22876 | return ira->codegen->invalid_inst_gen; |
| 21959 | | 22877 | |
| 21960 | return ir_analyze_union_init(ira, instruction, field->source_node, container_type, field->name, | 22878 | return ir_analyze_union_init(ira, source_instr, field->source_node, container_type, field->name, |
| 21961 | field_result_loc, result_loc); | 22879 | field_result_loc, result_loc); |
| 21962 | } | 22880 | } |
| 21963 | if (container_type->id != ZigTypeIdStruct || is_slice(container_type)) { | 22881 | if (container_type->id != ZigTypeIdStruct || is_slice(container_type)) { |
| 21964 | ir_add_error(ira, instruction, | 22882 | ir_add_error(ira, source_instr, |
| 21965 | buf_sprintf("type '%s' does not support struct initialization syntax", | 22883 | buf_sprintf("type '%s' does not support struct initialization syntax", |
| 21966 | buf_ptr(&container_type->name))); | 22884 | buf_ptr(&container_type->name))); |
| 21967 | return ira->codegen->invalid_instruction; | 22885 | return ira->codegen->invalid_inst_gen; |
| 21968 | } | 22886 | } |
| 21969 | | 22887 | |
| 21970 | if (container_type->data.structure.resolve_status == ResolveStatusBeingInferred) { | 22888 | if (container_type->data.structure.resolve_status == ResolveStatusBeingInferred) { |
| ... | @@ -21973,16 +22891,16 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -21973,16 +22891,16 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 21973 | } | 22891 | } |
| 21974 | | 22892 | |
| 21975 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) | 22893 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) |
| 21976 | return ira->codegen->invalid_instruction; | 22894 | return ira->codegen->invalid_inst_gen; |
| 21977 | | 22895 | |
| 21978 | size_t actual_field_count = container_type->data.structure.src_field_count; | 22896 | size_t actual_field_count = container_type->data.structure.src_field_count; |
| 21979 | | 22897 | |
| 21980 | IrInstruction *first_non_const_instruction = nullptr; | 22898 | IrInstGen *first_non_const_instruction = nullptr; |
| 21981 | | 22899 | |
| 21982 | AstNode **field_assign_nodes = allocate<AstNode *>(actual_field_count); | 22900 | AstNode **field_assign_nodes = allocate<AstNode *>(actual_field_count); |
| 21983 | ZigList<IrInstruction *> const_ptrs = {}; | 22901 | ZigList<IrInstGen *> const_ptrs = {}; |
| 21984 | | 22902 | |
| 21985 | bool is_comptime = ir_should_inline(ira->new_irb.exec, instruction->scope) | 22903 | bool is_comptime = ir_should_inline(ira->old_irb.exec, source_instr->scope) |
| 21986 | || type_requires_comptime(ira->codegen, container_type) == ReqCompTimeYes; | 22904 | || type_requires_comptime(ira->codegen, container_type) == ReqCompTimeYes; |
| 21987 | | 22905 | |
| 21988 | | 22906 | |
| ... | @@ -21998,29 +22916,29 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -21998,29 +22916,29 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 21998 | // comptime-known values. | 22916 | // comptime-known values. |
| 21999 | | 22917 | |
| 22000 | for (size_t i = 0; i < instr_field_count; i += 1) { | 22918 | for (size_t i = 0; i < instr_field_count; i += 1) { |
| 22001 | IrInstructionContainerInitFieldsField *field = &fields[i]; | 22919 | IrInstSrcContainerInitFieldsField *field = &fields[i]; |
| 22002 | | 22920 | |
| 22003 | IrInstruction *field_result_loc = field->result_loc->child; | 22921 | IrInstGen *field_result_loc = field->result_loc->child; |
| 22004 | if (type_is_invalid(field_result_loc->value->type)) | 22922 | if (type_is_invalid(field_result_loc->value->type)) |
| 22005 | return ira->codegen->invalid_instruction; | 22923 | return ira->codegen->invalid_inst_gen; |
| 22006 | | 22924 | |
| 22007 | TypeStructField *type_field = find_struct_type_field(container_type, field->name); | 22925 | TypeStructField *type_field = find_struct_type_field(container_type, field->name); |
| 22008 | if (!type_field) { | 22926 | if (!type_field) { |
| 22009 | ir_add_error_node(ira, field->source_node, | 22927 | ir_add_error_node(ira, field->source_node, |
| 22010 | buf_sprintf("no member named '%s' in struct '%s'", | 22928 | buf_sprintf("no member named '%s' in struct '%s'", |
| 22011 | buf_ptr(field->name), buf_ptr(&container_type->name))); | 22929 | buf_ptr(field->name), buf_ptr(&container_type->name))); |
| 22012 | return ira->codegen->invalid_instruction; | 22930 | return ira->codegen->invalid_inst_gen; |
| 22013 | } | 22931 | } |
| 22014 | | 22932 | |
| 22015 | if (type_is_invalid(type_field->type_entry)) | 22933 | if (type_is_invalid(type_field->type_entry)) |
| 22016 | return ira->codegen->invalid_instruction; | 22934 | return ira->codegen->invalid_inst_gen; |
| 22017 | | 22935 | |
| 22018 | size_t field_index = type_field->src_index; | 22936 | size_t field_index = type_field->src_index; |
| 22019 | AstNode *existing_assign_node = field_assign_nodes[field_index]; | 22937 | AstNode *existing_assign_node = field_assign_nodes[field_index]; |
| 22020 | if (existing_assign_node) { | 22938 | if (existing_assign_node) { |
| 22021 | ErrorMsg *msg = ir_add_error_node(ira, field->source_node, buf_sprintf("duplicate field")); | 22939 | ErrorMsg *msg = ir_add_error_node(ira, field->source_node, buf_sprintf("duplicate field")); |
| 22022 | add_error_note(ira->codegen, msg, existing_assign_node, buf_sprintf("other field here")); | 22940 | add_error_note(ira->codegen, msg, existing_assign_node, buf_sprintf("other field here")); |
| 22023 | return ira->codegen->invalid_instruction; | 22941 | return ira->codegen->invalid_inst_gen; |
| 22024 | } | 22942 | } |
| 22025 | field_assign_nodes[field_index] = field->source_node; | 22943 | field_assign_nodes[field_index] = field->source_node; |
| 22026 | | 22944 | |
| ... | @@ -22041,20 +22959,20 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -22041,20 +22959,20 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 22041 | TypeStructField *field = container_type->data.structure.fields[i]; | 22959 | TypeStructField *field = container_type->data.structure.fields[i]; |
| 22042 | memoize_field_init_val(ira->codegen, container_type, field); | 22960 | memoize_field_init_val(ira->codegen, container_type, field); |
| 22043 | if (field->init_val == nullptr) { | 22961 | if (field->init_val == nullptr) { |
| 22044 | ir_add_error_node(ira, instruction->source_node, | 22962 | ir_add_error(ira, source_instr, |
| 22045 | buf_sprintf("missing field: '%s'", buf_ptr(container_type->data.structure.fields[i]->name))); | 22963 | buf_sprintf("missing field: '%s'", buf_ptr(container_type->data.structure.fields[i]->name))); |
| 22046 | any_missing = true; | 22964 | any_missing = true; |
| 22047 | continue; | 22965 | continue; |
| 22048 | } | 22966 | } |
| 22049 | if (type_is_invalid(field->init_val->type)) | 22967 | if (type_is_invalid(field->init_val->type)) |
| 22050 | return ira->codegen->invalid_instruction; | 22968 | return ira->codegen->invalid_inst_gen; |
| 22051 | | 22969 | |
| 22052 | IrInstruction *runtime_inst = ir_const(ira, instruction, field->init_val->type); | 22970 | IrInstGen *runtime_inst = ir_const(ira, source_instr, field->init_val->type); |
| 22053 | copy_const_val(runtime_inst->value, field->init_val); | 22971 | copy_const_val(runtime_inst->value, field->init_val); |
| 22054 | | 22972 | |
| 22055 | IrInstruction *field_ptr = ir_analyze_struct_field_ptr(ira, instruction, field, result_loc, | 22973 | IrInstGen *field_ptr = ir_analyze_struct_field_ptr(ira, source_instr, field, result_loc, |
| 22056 | container_type, true); | 22974 | container_type, true); |
| 22057 | ir_analyze_store_ptr(ira, instruction, field_ptr, runtime_inst, false); | 22975 | ir_analyze_store_ptr(ira, source_instr, field_ptr, runtime_inst, false); |
| 22058 | if (instr_is_comptime(field_ptr) && field_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 22976 | if (instr_is_comptime(field_ptr) && field_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 22059 | const_ptrs.append(field_ptr); | 22977 | const_ptrs.append(field_ptr); |
| 22060 | } else { | 22978 | } else { |
| ... | @@ -22062,39 +22980,39 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc | ... | @@ -22062,39 +22980,39 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc |
| 22062 | } | 22980 | } |
| 22063 | } | 22981 | } |
| 22064 | if (any_missing) | 22982 | if (any_missing) |
| 22065 | return ira->codegen->invalid_instruction; | 22983 | return ira->codegen->invalid_inst_gen; |
| 22066 | | 22984 | |
| 22067 | if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) { | 22985 | if (result_loc->value->data.x_ptr.mut == ConstPtrMutInfer) { |
| 22068 | if (const_ptrs.length != actual_field_count) { | 22986 | if (const_ptrs.length != actual_field_count) { |
| 22069 | result_loc->value->special = ConstValSpecialRuntime; | 22987 | result_loc->value->special = ConstValSpecialRuntime; |
| 22070 | for (size_t i = 0; i < const_ptrs.length; i += 1) { | 22988 | for (size_t i = 0; i < const_ptrs.length; i += 1) { |
| 22071 | IrInstruction *field_result_loc = const_ptrs.at(i); | 22989 | IrInstGen *field_result_loc = const_ptrs.at(i); |
| 22072 | IrInstruction *deref = ir_get_deref(ira, field_result_loc, field_result_loc, nullptr); | 22990 | IrInstGen *deref = ir_get_deref(ira, &field_result_loc->base, field_result_loc, nullptr); |
| 22073 | field_result_loc->value->special = ConstValSpecialRuntime; | 22991 | field_result_loc->value->special = ConstValSpecialRuntime; |
| 22074 | ir_analyze_store_ptr(ira, field_result_loc, field_result_loc, deref, false); | 22992 | ir_analyze_store_ptr(ira, &field_result_loc->base, field_result_loc, deref, false); |
| 22075 | } | 22993 | } |
| 22076 | } | 22994 | } |
| 22077 | } | 22995 | } |
| 22078 | | 22996 | |
| 22079 | IrInstruction *result = ir_get_deref(ira, instruction, result_loc, nullptr); | 22997 | IrInstGen *result = ir_get_deref(ira, source_instr, result_loc, nullptr); |
| 22080 | | 22998 | |
| 22081 | if (is_comptime && !instr_is_comptime(result)) { | 22999 | if (is_comptime && !instr_is_comptime(result)) { |
| 22082 | ir_add_error_node(ira, first_non_const_instruction->source_node, | 23000 | ir_add_error_node(ira, first_non_const_instruction->base.source_node, |
| 22083 | buf_sprintf("unable to evaluate constant expression")); | 23001 | buf_sprintf("unable to evaluate constant expression")); |
| 22084 | return ira->codegen->invalid_instruction; | 23002 | return ira->codegen->invalid_inst_gen; |
| 22085 | } | 23003 | } |
| 22086 | | 23004 | |
| 22087 | return result; | 23005 | return result; |
| 22088 | } | 23006 | } |
| 22089 | | 23007 | |
| 22090 | static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | 23008 | static IrInstGen *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 22091 | IrInstructionContainerInitList *instruction) | 23009 | IrInstSrcContainerInitList *instruction) |
| 22092 | { | 23010 | { |
| 22093 | ir_assert(instruction->result_loc != nullptr, &instruction->base); | 23011 | ir_assert(instruction->result_loc != nullptr, &instruction->base.base); |
| 22094 | IrInstruction *result_loc = instruction->result_loc->child; | 23012 | IrInstGen *result_loc = instruction->result_loc->child; |
| 22095 | if (type_is_invalid(result_loc->value->type)) | 23013 | if (type_is_invalid(result_loc->value->type)) |
| 22096 | return result_loc; | 23014 | return result_loc; |
| 22097 | ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base); | 23015 | ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base.base); |
| 22098 | | 23016 | |
| 22099 | ZigType *container_type = result_loc->value->type->data.pointer.child_type; | 23017 | ZigType *container_type = result_loc->value->type->data.pointer.child_type; |
| 22100 | | 23018 | |
| ... | @@ -22104,24 +23022,24 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -22104,24 +23022,24 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 22104 | ir_add_error_node(ira, instruction->init_array_type_source_node, | 23022 | ir_add_error_node(ira, instruction->init_array_type_source_node, |
| 22105 | buf_sprintf("array literal requires address-of operator to coerce to slice type '%s'", | 23023 | buf_sprintf("array literal requires address-of operator to coerce to slice type '%s'", |
| 22106 | buf_ptr(&container_type->name))); | 23024 | buf_ptr(&container_type->name))); |
| 22107 | return ira->codegen->invalid_instruction; | 23025 | return ira->codegen->invalid_inst_gen; |
| 22108 | } | 23026 | } |
| 22109 | | 23027 | |
| 22110 | if (container_type->id == ZigTypeIdVoid) { | 23028 | if (container_type->id == ZigTypeIdVoid) { |
| 22111 | if (elem_count != 0) { | 23029 | if (elem_count != 0) { |
| 22112 | ir_add_error_node(ira, instruction->base.source_node, | 23030 | ir_add_error_node(ira, instruction->base.base.source_node, |
| 22113 | buf_sprintf("void expression expects no arguments")); | 23031 | buf_sprintf("void expression expects no arguments")); |
| 22114 | return ira->codegen->invalid_instruction; | 23032 | return ira->codegen->invalid_inst_gen; |
| 22115 | } | 23033 | } |
| 22116 | return ir_const_void(ira, &instruction->base); | 23034 | return ir_const_void(ira, &instruction->base.base); |
| 22117 | } | 23035 | } |
| 22118 | | 23036 | |
| 22119 | if (container_type->id == ZigTypeIdStruct && elem_count == 0) { | 23037 | if (container_type->id == ZigTypeIdStruct && elem_count == 0) { |
| 22120 | ir_assert(instruction->result_loc != nullptr, &instruction->base); | 23038 | ir_assert(instruction->result_loc != nullptr, &instruction->base.base); |
| 22121 | IrInstruction *result_loc = instruction->result_loc->child; | 23039 | IrInstGen *result_loc = instruction->result_loc->child; |
| 22122 | if (type_is_invalid(result_loc->value->type)) | 23040 | if (type_is_invalid(result_loc->value->type)) |
| 22123 | return result_loc; | 23041 | return result_loc; |
| 22124 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, 0, nullptr, result_loc); | 23042 | return ir_analyze_container_init_fields(ira, &instruction->base.base, container_type, 0, nullptr, result_loc); |
| 22125 | } | 23043 | } |
| 22126 | | 23044 | |
| 22127 | if (container_type->id == ZigTypeIdArray) { | 23045 | if (container_type->id == ZigTypeIdArray) { |
| ... | @@ -22129,10 +23047,10 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -22129,10 +23047,10 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 22129 | if (container_type->data.array.len != elem_count) { | 23047 | if (container_type->data.array.len != elem_count) { |
| 22130 | ZigType *literal_type = get_array_type(ira->codegen, child_type, elem_count, nullptr); | 23048 | ZigType *literal_type = get_array_type(ira->codegen, child_type, elem_count, nullptr); |
| 22131 | | 23049 | |
| 22132 | ir_add_error(ira, &instruction->base, | 23050 | ir_add_error(ira, &instruction->base.base, |
| 22133 | buf_sprintf("expected %s literal, found %s literal", | 23051 | buf_sprintf("expected %s literal, found %s literal", |
| 22134 | buf_ptr(&container_type->name), buf_ptr(&literal_type->name))); | 23052 | buf_ptr(&container_type->name), buf_ptr(&literal_type->name))); |
| 22135 | return ira->codegen->invalid_instruction; | 23053 | return ira->codegen->invalid_inst_gen; |
| 22136 | } | 23054 | } |
| 22137 | } else if (container_type->id == ZigTypeIdStruct && | 23055 | } else if (container_type->id == ZigTypeIdStruct && |
| 22138 | container_type->data.structure.resolve_status == ResolveStatusBeingInferred) | 23056 | container_type->data.structure.resolve_status == ResolveStatusBeingInferred) |
| ... | @@ -22142,17 +23060,17 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -22142,17 +23060,17 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 22142 | } else if (container_type->id == ZigTypeIdVector) { | 23060 | } else if (container_type->id == ZigTypeIdVector) { |
| 22143 | // OK | 23061 | // OK |
| 22144 | } else { | 23062 | } else { |
| 22145 | ir_add_error_node(ira, instruction->base.source_node, | 23063 | ir_add_error(ira, &instruction->base.base, |
| 22146 | buf_sprintf("type '%s' does not support array initialization", | 23064 | buf_sprintf("type '%s' does not support array initialization", |
| 22147 | buf_ptr(&container_type->name))); | 23065 | buf_ptr(&container_type->name))); |
| 22148 | return ira->codegen->invalid_instruction; | 23066 | return ira->codegen->invalid_inst_gen; |
| 22149 | } | 23067 | } |
| 22150 | | 23068 | |
| 22151 | switch (type_has_one_possible_value(ira->codegen, container_type)) { | 23069 | switch (type_has_one_possible_value(ira->codegen, container_type)) { |
| 22152 | case OnePossibleValueInvalid: | 23070 | case OnePossibleValueInvalid: |
| 22153 | return ira->codegen->invalid_instruction; | 23071 | return ira->codegen->invalid_inst_gen; |
| 22154 | case OnePossibleValueYes: | 23072 | case OnePossibleValueYes: |
| 22155 | return ir_const_move(ira, &instruction->base, | 23073 | return ir_const_move(ira, &instruction->base.base, |
| 22156 | get_the_one_possible_value(ira->codegen, container_type)); | 23074 | get_the_one_possible_value(ira->codegen, container_type)); |
| 22157 | case OnePossibleValueNo: | 23075 | case OnePossibleValueNo: |
| 22158 | break; | 23076 | break; |
| ... | @@ -22161,16 +23079,16 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -22161,16 +23079,16 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 22161 | bool is_comptime; | 23079 | bool is_comptime; |
| 22162 | switch (type_requires_comptime(ira->codegen, container_type)) { | 23080 | switch (type_requires_comptime(ira->codegen, container_type)) { |
| 22163 | case ReqCompTimeInvalid: | 23081 | case ReqCompTimeInvalid: |
| 22164 | return ira->codegen->invalid_instruction; | 23082 | return ira->codegen->invalid_inst_gen; |
| 22165 | case ReqCompTimeNo: | 23083 | case ReqCompTimeNo: |
| 22166 | is_comptime = ir_should_inline(ira->new_irb.exec, instruction->base.scope); | 23084 | is_comptime = ir_should_inline(ira->old_irb.exec, instruction->base.base.scope); |
| 22167 | break; | 23085 | break; |
| 22168 | case ReqCompTimeYes: | 23086 | case ReqCompTimeYes: |
| 22169 | is_comptime = true; | 23087 | is_comptime = true; |
| 22170 | break; | 23088 | break; |
| 22171 | } | 23089 | } |
| 22172 | | 23090 | |
| 22173 | IrInstruction *first_non_const_instruction = nullptr; | 23091 | IrInstGen *first_non_const_instruction = nullptr; |
| 22174 | | 23092 | |
| 22175 | // The Result Location Mechanism has already emitted runtime instructions to | 23093 | // The Result Location Mechanism has already emitted runtime instructions to |
| 22176 | // initialize runtime elements and has omitted instructions for the comptime | 23094 | // initialize runtime elements and has omitted instructions for the comptime |
| ... | @@ -22179,12 +23097,12 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -22179,12 +23097,12 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 22179 | // array initialization can be a comptime value, overwrite ConstPtrMutInfer with | 23097 | // array initialization can be a comptime value, overwrite ConstPtrMutInfer with |
| 22180 | // ConstPtrMutComptimeConst. Otherwise, emit instructions to runtime-initialize the | 23098 | // ConstPtrMutComptimeConst. Otherwise, emit instructions to runtime-initialize the |
| 22181 | // elements that have comptime-known values. | 23099 | // elements that have comptime-known values. |
| 22182 | ZigList<IrInstruction *> const_ptrs = {}; | 23100 | ZigList<IrInstGen *> const_ptrs = {}; |
| 22183 | | 23101 | |
| 22184 | for (size_t i = 0; i < elem_count; i += 1) { | 23102 | for (size_t i = 0; i < elem_count; i += 1) { |
| 22185 | IrInstruction *elem_result_loc = instruction->elem_result_loc_list[i]->child; | 23103 | IrInstGen *elem_result_loc = instruction->elem_result_loc_list[i]->child; |
| 22186 | if (type_is_invalid(elem_result_loc->value->type)) | 23104 | if (type_is_invalid(elem_result_loc->value->type)) |
| 22187 | return ira->codegen->invalid_instruction; | 23105 | return ira->codegen->invalid_inst_gen; |
| 22188 | | 23106 | |
| 22189 | assert(elem_result_loc->value->type->id == ZigTypeIdPointer); | 23107 | assert(elem_result_loc->value->type->id == ZigTypeIdPointer); |
| 22190 | | 23108 | |
| ... | @@ -22201,81 +23119,79 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, | ... | @@ -22201,81 +23119,79 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira, |
| 22201 | if (const_ptrs.length != elem_count) { | 23119 | if (const_ptrs.length != elem_count) { |
| 22202 | result_loc->value->special = ConstValSpecialRuntime; | 23120 | result_loc->value->special = ConstValSpecialRuntime; |
| 22203 | for (size_t i = 0; i < const_ptrs.length; i += 1) { | 23121 | for (size_t i = 0; i < const_ptrs.length; i += 1) { |
| 22204 | IrInstruction *elem_result_loc = const_ptrs.at(i); | 23122 | IrInstGen *elem_result_loc = const_ptrs.at(i); |
| 22205 | assert(elem_result_loc->value->special == ConstValSpecialStatic); | 23123 | assert(elem_result_loc->value->special == ConstValSpecialStatic); |
| 22206 | if (elem_result_loc->value->type->data.pointer.inferred_struct_field != nullptr) { | 23124 | if (elem_result_loc->value->type->data.pointer.inferred_struct_field != nullptr) { |
| 22207 | // This field will be generated comptime; no need to do this. | 23125 | // This field will be generated comptime; no need to do this. |
| 22208 | continue; | 23126 | continue; |
| 22209 | } | 23127 | } |
| 22210 | IrInstruction *deref = ir_get_deref(ira, elem_result_loc, elem_result_loc, nullptr); | 23128 | IrInstGen *deref = ir_get_deref(ira, &elem_result_loc->base, elem_result_loc, nullptr); |
| 22211 | elem_result_loc->value->special = ConstValSpecialRuntime; | 23129 | elem_result_loc->value->special = ConstValSpecialRuntime; |
| 22212 | ir_analyze_store_ptr(ira, elem_result_loc, elem_result_loc, deref, false); | 23130 | ir_analyze_store_ptr(ira, &elem_result_loc->base, elem_result_loc, deref, false); |
| 22213 | } | 23131 | } |
| 22214 | } | 23132 | } |
| 22215 | } | 23133 | } |
| 22216 | | 23134 | |
| 22217 | IrInstruction *result = ir_get_deref(ira, &instruction->base, result_loc, nullptr); | 23135 | IrInstGen *result = ir_get_deref(ira, &instruction->base.base, result_loc, nullptr); |
| 22218 | if (instr_is_comptime(result)) | 23136 | if (instr_is_comptime(result)) |
| 22219 | return result; | 23137 | return result; |
| 22220 | | 23138 | |
| 22221 | if (is_comptime) { | 23139 | if (is_comptime) { |
| 22222 | ir_add_error_node(ira, first_non_const_instruction->source_node, | 23140 | ir_add_error(ira, &first_non_const_instruction->base, |
| 22223 | buf_sprintf("unable to evaluate constant expression")); | 23141 | buf_sprintf("unable to evaluate constant expression")); |
| 22224 | return ira->codegen->invalid_instruction; | 23142 | return ira->codegen->invalid_inst_gen; |
| 22225 | } | 23143 | } |
| 22226 | | 23144 | |
| 22227 | ZigType *result_elem_type = result_loc->value->type->data.pointer.child_type; | 23145 | ZigType *result_elem_type = result_loc->value->type->data.pointer.child_type; |
| 22228 | if (is_slice(result_elem_type)) { | 23146 | if (is_slice(result_elem_type)) { |
| 22229 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, | 23147 | ErrorMsg *msg = ir_add_error(ira, &instruction->base.base, |
| 22230 | buf_sprintf("runtime-initialized array cannot be casted to slice type '%s'", | 23148 | buf_sprintf("runtime-initialized array cannot be casted to slice type '%s'", |
| 22231 | buf_ptr(&result_elem_type->name))); | 23149 | buf_ptr(&result_elem_type->name))); |
| 22232 | add_error_note(ira->codegen, msg, first_non_const_instruction->source_node, | 23150 | add_error_note(ira->codegen, msg, first_non_const_instruction->base.source_node, |
| 22233 | buf_sprintf("this value is not comptime-known")); | 23151 | buf_sprintf("this value is not comptime-known")); |
| 22234 | return ira->codegen->invalid_instruction; | 23152 | return ira->codegen->invalid_inst_gen; |
| 22235 | } | 23153 | } |
| 22236 | return result; | 23154 | return result; |
| 22237 | } | 23155 | } |
| 22238 | | 23156 | |
| 22239 | static IrInstruction *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, | 23157 | static IrInstGen *ir_analyze_instruction_container_init_fields(IrAnalyze *ira, |
| 22240 | IrInstructionContainerInitFields *instruction) | 23158 | IrInstSrcContainerInitFields *instruction) |
| 22241 | { | 23159 | { |
| 22242 | ir_assert(instruction->result_loc != nullptr, &instruction->base); | 23160 | ir_assert(instruction->result_loc != nullptr, &instruction->base.base); |
| 22243 | IrInstruction *result_loc = instruction->result_loc->child; | 23161 | IrInstGen *result_loc = instruction->result_loc->child; |
| 22244 | if (type_is_invalid(result_loc->value->type)) | 23162 | if (type_is_invalid(result_loc->value->type)) |
| 22245 | return result_loc; | 23163 | return result_loc; |
| 22246 | | 23164 | |
| 22247 | ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base); | 23165 | ir_assert(result_loc->value->type->id == ZigTypeIdPointer, &instruction->base.base); |
| 22248 | ZigType *container_type = result_loc->value->type->data.pointer.child_type; | 23166 | ZigType *container_type = result_loc->value->type->data.pointer.child_type; |
| 22249 | | 23167 | |
| 22250 | return ir_analyze_container_init_fields(ira, &instruction->base, container_type, | 23168 | return ir_analyze_container_init_fields(ira, &instruction->base.base, container_type, |
| 22251 | instruction->field_count, instruction->fields, result_loc); | 23169 | instruction->field_count, instruction->fields, result_loc); |
| 22252 | } | 23170 | } |
| 22253 | | 23171 | |
| 22254 | static IrInstruction *ir_analyze_instruction_compile_err(IrAnalyze *ira, | 23172 | static IrInstGen *ir_analyze_instruction_compile_err(IrAnalyze *ira, IrInstSrcCompileErr *instruction) { |
| 22255 | IrInstructionCompileErr *instruction) | 23173 | IrInstGen *msg_value = instruction->msg->child; |
| 22256 | { | | |
| 22257 | IrInstruction *msg_value = instruction->msg->child; | | |
| 22258 | Buf *msg_buf = ir_resolve_str(ira, msg_value); | 23174 | Buf *msg_buf = ir_resolve_str(ira, msg_value); |
| 22259 | if (!msg_buf) | 23175 | if (!msg_buf) |
| 22260 | return ira->codegen->invalid_instruction; | 23176 | return ira->codegen->invalid_inst_gen; |
| 22261 | | 23177 | |
| 22262 | ir_add_error(ira, &instruction->base, msg_buf); | 23178 | ir_add_error(ira, &instruction->base.base, msg_buf); |
| 22263 | | 23179 | |
| 22264 | return ira->codegen->invalid_instruction; | 23180 | return ira->codegen->invalid_inst_gen; |
| 22265 | } | 23181 | } |
| 22266 | | 23182 | |
| 22267 | static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstructionCompileLog *instruction) { | 23183 | static IrInstGen *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstSrcCompileLog *instruction) { |
| 22268 | Buf buf = BUF_INIT; | 23184 | Buf buf = BUF_INIT; |
| 22269 | fprintf(stderr, "| "); | 23185 | fprintf(stderr, "| "); |
| 22270 | for (size_t i = 0; i < instruction->msg_count; i += 1) { | 23186 | for (size_t i = 0; i < instruction->msg_count; i += 1) { |
| 22271 | IrInstruction *msg = instruction->msg_list[i]->child; | 23187 | IrInstGen *msg = instruction->msg_list[i]->child; |
| 22272 | if (type_is_invalid(msg->value->type)) | 23188 | if (type_is_invalid(msg->value->type)) |
| 22273 | return ira->codegen->invalid_instruction; | 23189 | return ira->codegen->invalid_inst_gen; |
| 22274 | buf_resize(&buf, 0); | 23190 | buf_resize(&buf, 0); |
| 22275 | if (msg->value->special == ConstValSpecialLazy) { | 23191 | if (msg->value->special == ConstValSpecialLazy) { |
| 22276 | // Resolve any lazy value that's passed, we need its value | 23192 | // Resolve any lazy value that's passed, we need its value |
| 22277 | if (ir_resolve_lazy(ira->codegen, msg->source_node, msg->value)) | 23193 | if (ir_resolve_lazy(ira->codegen, msg->base.source_node, msg->value)) |
| 22278 | return ira->codegen->invalid_instruction; | 23194 | return ira->codegen->invalid_inst_gen; |
| 22279 | } | 23195 | } |
| 22280 | render_const_value(ira->codegen, &buf, msg->value); | 23196 | render_const_value(ira->codegen, &buf, msg->value); |
| 22281 | const char *comma_str = (i != 0) ? ", " : ""; | 23197 | const char *comma_str = (i != 0) ? ", " : ""; |
| ... | @@ -22283,25 +23199,25 @@ static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstr | ... | @@ -22283,25 +23199,25 @@ static IrInstruction *ir_analyze_instruction_compile_log(IrAnalyze *ira, IrInstr |
| 22283 | } | 23199 | } |
| 22284 | fprintf(stderr, "\n"); | 23200 | fprintf(stderr, "\n"); |
| 22285 | | 23201 | |
| 22286 | auto *expr = &instruction->base.source_node->data.fn_call_expr; | 23202 | auto *expr = &instruction->base.base.source_node->data.fn_call_expr; |
| 22287 | if (!expr->seen) { | 23203 | if (!expr->seen) { |
| 22288 | // Here we bypass higher level functions such as ir_add_error because we do not want | 23204 | // Here we bypass higher level functions such as ir_add_error because we do not want |
| 22289 | // invalidate_exec to be called. | 23205 | // invalidate_exec to be called. |
| 22290 | add_node_error(ira->codegen, instruction->base.source_node, buf_sprintf("found compile log statement")); | 23206 | add_node_error(ira->codegen, instruction->base.base.source_node, buf_sprintf("found compile log statement")); |
| 22291 | } | 23207 | } |
| 22292 | expr->seen = true; | 23208 | expr->seen = true; |
| 22293 | | 23209 | |
| 22294 | return ir_const_void(ira, &instruction->base); | 23210 | return ir_const_void(ira, &instruction->base.base); |
| 22295 | } | 23211 | } |
| 22296 | | 23212 | |
| 22297 | static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstructionErrName *instruction) { | 23213 | static IrInstGen *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstSrcErrName *instruction) { |
| 22298 | IrInstruction *value = instruction->value->child; | 23214 | IrInstGen *value = instruction->value->child; |
| 22299 | if (type_is_invalid(value->value->type)) | 23215 | if (type_is_invalid(value->value->type)) |
| 22300 | return ira->codegen->invalid_instruction; | 23216 | return ira->codegen->invalid_inst_gen; |
| 22301 | | 23217 | |
| 22302 | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_global_error_set); | 23218 | IrInstGen *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_global_error_set); |
| 22303 | if (type_is_invalid(casted_value->value->type)) | 23219 | if (type_is_invalid(casted_value->value->type)) |
| 22304 | return ira->codegen->invalid_instruction; | 23220 | return ira->codegen->invalid_inst_gen; |
| 22305 | | 23221 | |
| 22306 | ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, | 23222 | ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 22307 | true, false, PtrLenUnknown, 0, 0, 0, false); | 23223 | true, false, PtrLenUnknown, 0, 0, 0, false); |
| ... | @@ -22309,13 +23225,13 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct | ... | @@ -22309,13 +23225,13 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct |
| 22309 | if (instr_is_comptime(casted_value)) { | 23225 | if (instr_is_comptime(casted_value)) { |
| 22310 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); | 23226 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); |
| 22311 | if (val == nullptr) | 23227 | if (val == nullptr) |
| 22312 | return ira->codegen->invalid_instruction; | 23228 | return ira->codegen->invalid_inst_gen; |
| 22313 | ErrorTableEntry *err = casted_value->value->data.x_err_set; | 23229 | ErrorTableEntry *err = casted_value->value->data.x_err_set; |
| 22314 | if (!err->cached_error_name_val) { | 23230 | if (!err->cached_error_name_val) { |
| 22315 | ZigValue *array_val = create_const_str_lit(ira->codegen, &err->name)->data.x_ptr.data.ref.pointee; | 23231 | ZigValue *array_val = create_const_str_lit(ira->codegen, &err->name)->data.x_ptr.data.ref.pointee; |
| 22316 | err->cached_error_name_val = create_const_slice(ira->codegen, array_val, 0, buf_len(&err->name), true); | 23232 | err->cached_error_name_val = create_const_slice(ira->codegen, array_val, 0, buf_len(&err->name), true); |
| 22317 | } | 23233 | } |
| 22318 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 23234 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 22319 | copy_const_val(result->value, err->cached_error_name_val); | 23235 | copy_const_val(result->value, err->cached_error_name_val); |
| 22320 | result->value->type = str_type; | 23236 | result->value->type = str_type; |
| 22321 | return result; | 23237 | return result; |
| ... | @@ -22323,20 +23239,17 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct | ... | @@ -22323,20 +23239,17 @@ static IrInstruction *ir_analyze_instruction_err_name(IrAnalyze *ira, IrInstruct |
| 22323 | | 23239 | |
| 22324 | ira->codegen->generate_error_name_table = true; | 23240 | ira->codegen->generate_error_name_table = true; |
| 22325 | | 23241 | |
| 22326 | IrInstruction *result = ir_build_err_name(&ira->new_irb, | 23242 | return ir_build_err_name_gen(ira, &instruction->base.base, value, str_type); |
| 22327 | instruction->base.scope, instruction->base.source_node, value); | | |
| 22328 | result->value->type = str_type; | | |
| 22329 | return result; | | |
| 22330 | } | 23243 | } |
| 22331 | | 23244 | |
| 22332 | static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstructionTagName *instruction) { | 23245 | static IrInstGen *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrInstSrcTagName *instruction) { |
| 22333 | Error err; | 23246 | Error err; |
| 22334 | IrInstruction *target = instruction->target->child; | 23247 | IrInstGen *target = instruction->target->child; |
| 22335 | if (type_is_invalid(target->value->type)) | 23248 | if (type_is_invalid(target->value->type)) |
| 22336 | return ira->codegen->invalid_instruction; | 23249 | return ira->codegen->invalid_inst_gen; |
| 22337 | | 23250 | |
| 22338 | if (target->value->type->id == ZigTypeIdEnumLiteral) { | 23251 | if (target->value->type->id == ZigTypeIdEnumLiteral) { |
| 22339 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 23252 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 22340 | Buf *field_name = target->value->data.x_enum_literal; | 23253 | Buf *field_name = target->value->data.x_enum_literal; |
| 22341 | ZigValue *array_val = create_const_str_lit(ira->codegen, field_name)->data.x_ptr.data.ref.pointee; | 23254 | ZigValue *array_val = create_const_str_lit(ira->codegen, field_name)->data.x_ptr.data.ref.pointee; |
| 22342 | init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(field_name), true); | 23255 | init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(field_name), true); |
| ... | @@ -22344,9 +23257,9 @@ static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIns | ... | @@ -22344,9 +23257,9 @@ static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIns |
| 22344 | } | 23257 | } |
| 22345 | | 23258 | |
| 22346 | if (target->value->type->id == ZigTypeIdUnion) { | 23259 | if (target->value->type->id == ZigTypeIdUnion) { |
| 22347 | target = ir_analyze_union_tag(ira, &instruction->base, target); | 23260 | target = ir_analyze_union_tag(ira, &instruction->base.base, target, instruction->base.is_gen); |
| 22348 | if (type_is_invalid(target->value->type)) | 23261 | if (type_is_invalid(target->value->type)) |
| 22349 | return ira->codegen->invalid_instruction; | 23262 | return ira->codegen->invalid_inst_gen; |
| 22350 | } | 23263 | } |
| 22351 | | 23264 | |
| 22352 | if (target->value->type->id != ZigTypeIdEnum) { | 23265 | if (target->value->type->id != ZigTypeIdEnum) { |
| ... | @@ -22359,75 +23272,73 @@ static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIns | ... | @@ -22359,75 +23272,73 @@ static IrInstruction *ir_analyze_instruction_enum_tag_name(IrAnalyze *ira, IrIns |
| 22359 | !target->value->type->data.enumeration.non_exhaustive) { | 23272 | !target->value->type->data.enumeration.non_exhaustive) { |
| 22360 | TypeEnumField *only_field = &target->value->type->data.enumeration.fields[0]; | 23273 | TypeEnumField *only_field = &target->value->type->data.enumeration.fields[0]; |
| 22361 | ZigValue *array_val = create_const_str_lit(ira->codegen, only_field->name)->data.x_ptr.data.ref.pointee; | 23274 | ZigValue *array_val = create_const_str_lit(ira->codegen, only_field->name)->data.x_ptr.data.ref.pointee; |
| 22362 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 23275 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 22363 | init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(only_field->name), true); | 23276 | init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(only_field->name), true); |
| 22364 | return result; | 23277 | return result; |
| 22365 | } | 23278 | } |
| 22366 | | 23279 | |
| 22367 | if (instr_is_comptime(target)) { | 23280 | if (instr_is_comptime(target)) { |
| 22368 | if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusZeroBitsKnown))) | 23281 | if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusZeroBitsKnown))) |
| 22369 | return ira->codegen->invalid_instruction; | 23282 | return ira->codegen->invalid_inst_gen; |
| 22370 | if (target->value->type->data.enumeration.non_exhaustive) { | 23283 | if (target->value->type->data.enumeration.non_exhaustive) { |
| 22371 | add_node_error(ira->codegen, instruction->base.source_node, | 23284 | ir_add_error(ira, &instruction->base.base, |
| 22372 | buf_sprintf("TODO @tagName on non-exhaustive enum https://github.com/ziglang/zig/issues/3991")); | 23285 | buf_sprintf("TODO @tagName on non-exhaustive enum https://github.com/ziglang/zig/issues/3991")); |
| 22373 | return ira->codegen->invalid_instruction; | 23286 | return ira->codegen->invalid_inst_gen; |
| 22374 | } | 23287 | } |
| 22375 | TypeEnumField *field = find_enum_field_by_tag(target->value->type, &target->value->data.x_bigint); | 23288 | TypeEnumField *field = find_enum_field_by_tag(target->value->type, &target->value->data.x_bigint); |
| 22376 | ZigValue *array_val = create_const_str_lit(ira->codegen, field->name)->data.x_ptr.data.ref.pointee; | 23289 | ZigValue *array_val = create_const_str_lit(ira->codegen, field->name)->data.x_ptr.data.ref.pointee; |
| 22377 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 23290 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 22378 | init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(field->name), true); | 23291 | init_const_slice(ira->codegen, result->value, array_val, 0, buf_len(field->name), true); |
| 22379 | return result; | 23292 | return result; |
| 22380 | } | 23293 | } |
| 22381 | | 23294 | |
| 22382 | IrInstruction *result = ir_build_tag_name(&ira->new_irb, instruction->base.scope, | | |
| 22383 | instruction->base.source_node, target); | | |
| 22384 | ZigType *u8_ptr_type = get_pointer_to_type_extra( | 23295 | ZigType *u8_ptr_type = get_pointer_to_type_extra( |
| 22385 | ira->codegen, ira->codegen->builtin_types.entry_u8, | 23296 | ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 22386 | true, false, PtrLenUnknown, | 23297 | true, false, PtrLenUnknown, |
| 22387 | 0, 0, 0, false); | 23298 | 0, 0, 0, false); |
| 22388 | result->value->type = get_slice_type(ira->codegen, u8_ptr_type); | 23299 | ZigType *result_type = get_slice_type(ira->codegen, u8_ptr_type); |
| 22389 | return result; | 23300 | return ir_build_tag_name_gen(ira, &instruction->base.base, target, result_type); |
| 22390 | } | 23301 | } |
| 22391 | | 23302 | |
| 22392 | static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | 23303 | static IrInstGen *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 22393 | IrInstructionFieldParentPtr *instruction) | 23304 | IrInstSrcFieldParentPtr *instruction) |
| 22394 | { | 23305 | { |
| 22395 | Error err; | 23306 | Error err; |
| 22396 | IrInstruction *type_value = instruction->type_value->child; | 23307 | IrInstGen *type_value = instruction->type_value->child; |
| 22397 | ZigType *container_type = ir_resolve_type(ira, type_value); | 23308 | ZigType *container_type = ir_resolve_type(ira, type_value); |
| 22398 | if (type_is_invalid(container_type)) | 23309 | if (type_is_invalid(container_type)) |
| 22399 | return ira->codegen->invalid_instruction; | 23310 | return ira->codegen->invalid_inst_gen; |
| 22400 | | 23311 | |
| 22401 | IrInstruction *field_name_value = instruction->field_name->child; | 23312 | IrInstGen *field_name_value = instruction->field_name->child; |
| 22402 | Buf *field_name = ir_resolve_str(ira, field_name_value); | 23313 | Buf *field_name = ir_resolve_str(ira, field_name_value); |
| 22403 | if (!field_name) | 23314 | if (!field_name) |
| 22404 | return ira->codegen->invalid_instruction; | 23315 | return ira->codegen->invalid_inst_gen; |
| 22405 | | 23316 | |
| 22406 | IrInstruction *field_ptr = instruction->field_ptr->child; | 23317 | IrInstGen *field_ptr = instruction->field_ptr->child; |
| 22407 | if (type_is_invalid(field_ptr->value->type)) | 23318 | if (type_is_invalid(field_ptr->value->type)) |
| 22408 | return ira->codegen->invalid_instruction; | 23319 | return ira->codegen->invalid_inst_gen; |
| 22409 | | 23320 | |
| 22410 | if (container_type->id != ZigTypeIdStruct) { | 23321 | if (container_type->id != ZigTypeIdStruct) { |
| 22411 | ir_add_error(ira, type_value, | 23322 | ir_add_error(ira, &type_value->base, |
| 22412 | buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name))); | 23323 | buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name))); |
| 22413 | return ira->codegen->invalid_instruction; | 23324 | return ira->codegen->invalid_inst_gen; |
| 22414 | } | 23325 | } |
| 22415 | | 23326 | |
| 22416 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) | 23327 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) |
| 22417 | return ira->codegen->invalid_instruction; | 23328 | return ira->codegen->invalid_inst_gen; |
| 22418 | | 23329 | |
| 22419 | TypeStructField *field = find_struct_type_field(container_type, field_name); | 23330 | TypeStructField *field = find_struct_type_field(container_type, field_name); |
| 22420 | if (field == nullptr) { | 23331 | if (field == nullptr) { |
| 22421 | ir_add_error(ira, field_name_value, | 23332 | ir_add_error(ira, &field_name_value->base, |
| 22422 | buf_sprintf("struct '%s' has no field '%s'", | 23333 | buf_sprintf("struct '%s' has no field '%s'", |
| 22423 | buf_ptr(&container_type->name), buf_ptr(field_name))); | 23334 | buf_ptr(&container_type->name), buf_ptr(field_name))); |
| 22424 | return ira->codegen->invalid_instruction; | 23335 | return ira->codegen->invalid_inst_gen; |
| 22425 | } | 23336 | } |
| 22426 | | 23337 | |
| 22427 | if (field_ptr->value->type->id != ZigTypeIdPointer) { | 23338 | if (field_ptr->value->type->id != ZigTypeIdPointer) { |
| 22428 | ir_add_error(ira, field_ptr, | 23339 | ir_add_error(ira, &field_ptr->base, |
| 22429 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&field_ptr->value->type->name))); | 23340 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&field_ptr->value->type->name))); |
| 22430 | return ira->codegen->invalid_instruction; | 23341 | return ira->codegen->invalid_inst_gen; |
| 22431 | } | 23342 | } |
| 22432 | | 23343 | |
| 22433 | bool is_packed = (container_type->data.structure.layout == ContainerLayoutPacked); | 23344 | bool is_packed = (container_type->data.structure.layout == ContainerLayoutPacked); |
| ... | @@ -22439,9 +23350,9 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -22439,9 +23350,9 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 22439 | field_ptr->value->type->data.pointer.is_volatile, | 23350 | field_ptr->value->type->data.pointer.is_volatile, |
| 22440 | PtrLenSingle, | 23351 | PtrLenSingle, |
| 22441 | field_ptr_align, 0, 0, false); | 23352 | field_ptr_align, 0, 0, false); |
| 22442 | IrInstruction *casted_field_ptr = ir_implicit_cast(ira, field_ptr, field_ptr_type); | 23353 | IrInstGen *casted_field_ptr = ir_implicit_cast(ira, field_ptr, field_ptr_type); |
| 22443 | if (type_is_invalid(casted_field_ptr->value->type)) | 23354 | if (type_is_invalid(casted_field_ptr->value->type)) |
| 22444 | return ira->codegen->invalid_instruction; | 23355 | return ira->codegen->invalid_inst_gen; |
| 22445 | | 23356 | |
| 22446 | ZigType *result_type = get_pointer_to_type_extra(ira->codegen, container_type, | 23357 | ZigType *result_type = get_pointer_to_type_extra(ira->codegen, container_type, |
| 22447 | casted_field_ptr->value->type->data.pointer.is_const, | 23358 | casted_field_ptr->value->type->data.pointer.is_const, |
| ... | @@ -22452,23 +23363,23 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -22452,23 +23363,23 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 22452 | if (instr_is_comptime(casted_field_ptr)) { | 23363 | if (instr_is_comptime(casted_field_ptr)) { |
| 22453 | ZigValue *field_ptr_val = ir_resolve_const(ira, casted_field_ptr, UndefBad); | 23364 | ZigValue *field_ptr_val = ir_resolve_const(ira, casted_field_ptr, UndefBad); |
| 22454 | if (!field_ptr_val) | 23365 | if (!field_ptr_val) |
| 22455 | return ira->codegen->invalid_instruction; | 23366 | return ira->codegen->invalid_inst_gen; |
| 22456 | | 23367 | |
| 22457 | if (field_ptr_val->data.x_ptr.special != ConstPtrSpecialBaseStruct) { | 23368 | if (field_ptr_val->data.x_ptr.special != ConstPtrSpecialBaseStruct) { |
| 22458 | ir_add_error(ira, field_ptr, buf_sprintf("pointer value not based on parent struct")); | 23369 | ir_add_error(ira, &field_ptr->base, buf_sprintf("pointer value not based on parent struct")); |
| 22459 | return ira->codegen->invalid_instruction; | 23370 | return ira->codegen->invalid_inst_gen; |
| 22460 | } | 23371 | } |
| 22461 | | 23372 | |
| 22462 | size_t ptr_field_index = field_ptr_val->data.x_ptr.data.base_struct.field_index; | 23373 | size_t ptr_field_index = field_ptr_val->data.x_ptr.data.base_struct.field_index; |
| 22463 | if (ptr_field_index != field->src_index) { | 23374 | if (ptr_field_index != field->src_index) { |
| 22464 | ir_add_error(ira, &instruction->base, | 23375 | ir_add_error(ira, &instruction->base.base, |
| 22465 | buf_sprintf("field '%s' has index %" ZIG_PRI_usize " but pointer value is index %" ZIG_PRI_usize " of struct '%s'", | 23376 | buf_sprintf("field '%s' has index %" ZIG_PRI_usize " but pointer value is index %" ZIG_PRI_usize " of struct '%s'", |
| 22466 | buf_ptr(field->name), field->src_index, | 23377 | buf_ptr(field->name), field->src_index, |
| 22467 | ptr_field_index, buf_ptr(&container_type->name))); | 23378 | ptr_field_index, buf_ptr(&container_type->name))); |
| 22468 | return ira->codegen->invalid_instruction; | 23379 | return ira->codegen->invalid_inst_gen; |
| 22469 | } | 23380 | } |
| 22470 | | 23381 | |
| 22471 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 23382 | IrInstGen *result = ir_const(ira, &instruction->base.base, result_type); |
| 22472 | ZigValue *out_val = result->value; | 23383 | ZigValue *out_val = result->value; |
| 22473 | out_val->data.x_ptr.special = ConstPtrSpecialRef; | 23384 | out_val->data.x_ptr.special = ConstPtrSpecialRef; |
| 22474 | out_val->data.x_ptr.data.ref.pointee = field_ptr_val->data.x_ptr.data.base_struct.struct_val; | 23385 | out_val->data.x_ptr.data.ref.pointee = field_ptr_val->data.x_ptr.data.base_struct.struct_val; |
| ... | @@ -22476,15 +23387,12 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, | ... | @@ -22476,15 +23387,12 @@ static IrInstruction *ir_analyze_instruction_field_parent_ptr(IrAnalyze *ira, |
| 22476 | return result; | 23387 | return result; |
| 22477 | } | 23388 | } |
| 22478 | | 23389 | |
| 22479 | IrInstruction *result = ir_build_field_parent_ptr(&ira->new_irb, instruction->base.scope, | 23390 | return ir_build_field_parent_ptr_gen(ira, &instruction->base.base, casted_field_ptr, field, result_type); |
| 22480 | instruction->base.source_node, type_value, field_name_value, casted_field_ptr, field); | | |
| 22481 | result->value->type = result_type; | | |
| 22482 | return result; | | |
| 22483 | } | 23391 | } |
| 22484 | | 23392 | |
| 22485 | static TypeStructField *validate_byte_offset(IrAnalyze *ira, | 23393 | static TypeStructField *validate_byte_offset(IrAnalyze *ira, |
| 22486 | IrInstruction *type_value, | 23394 | IrInstGen *type_value, |
| 22487 | IrInstruction *field_name_value, | 23395 | IrInstGen *field_name_value, |
| 22488 | size_t *byte_offset) | 23396 | size_t *byte_offset) |
| 22489 | { | 23397 | { |
| 22490 | ZigType *container_type = ir_resolve_type(ira, type_value); | 23398 | ZigType *container_type = ir_resolve_type(ira, type_value); |
| ... | @@ -22500,21 +23408,21 @@ static TypeStructField *validate_byte_offset(IrAnalyze *ira, | ... | @@ -22500,21 +23408,21 @@ static TypeStructField *validate_byte_offset(IrAnalyze *ira, |
| 22500 | return nullptr; | 23408 | return nullptr; |
| 22501 | | 23409 | |
| 22502 | if (container_type->id != ZigTypeIdStruct) { | 23410 | if (container_type->id != ZigTypeIdStruct) { |
| 22503 | ir_add_error(ira, type_value, | 23411 | ir_add_error(ira, &type_value->base, |
| 22504 | buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name))); | 23412 | buf_sprintf("expected struct type, found '%s'", buf_ptr(&container_type->name))); |
| 22505 | return nullptr; | 23413 | return nullptr; |
| 22506 | } | 23414 | } |
| 22507 | | 23415 | |
| 22508 | TypeStructField *field = find_struct_type_field(container_type, field_name); | 23416 | TypeStructField *field = find_struct_type_field(container_type, field_name); |
| 22509 | if (field == nullptr) { | 23417 | if (field == nullptr) { |
| 22510 | ir_add_error(ira, field_name_value, | 23418 | ir_add_error(ira, &field_name_value->base, |
| 22511 | buf_sprintf("struct '%s' has no field '%s'", | 23419 | buf_sprintf("struct '%s' has no field '%s'", |
| 22512 | buf_ptr(&container_type->name), buf_ptr(field_name))); | 23420 | buf_ptr(&container_type->name), buf_ptr(field_name))); |
| 22513 | return nullptr; | 23421 | return nullptr; |
| 22514 | } | 23422 | } |
| 22515 | | 23423 | |
| 22516 | if (!type_has_bits(field->type_entry)) { | 23424 | if (!type_has_bits(field->type_entry)) { |
| 22517 | ir_add_error(ira, field_name_value, | 23425 | ir_add_error(ira, &field_name_value->base, |
| 22518 | buf_sprintf("zero-bit field '%s' in struct '%s' has no offset", | 23426 | buf_sprintf("zero-bit field '%s' in struct '%s' has no offset", |
| 22519 | buf_ptr(field_name), buf_ptr(&container_type->name))); | 23427 | buf_ptr(field_name), buf_ptr(&container_type->name))); |
| 22520 | return nullptr; | 23428 | return nullptr; |
| ... | @@ -22524,36 +23432,32 @@ static TypeStructField *validate_byte_offset(IrAnalyze *ira, | ... | @@ -22524,36 +23432,32 @@ static TypeStructField *validate_byte_offset(IrAnalyze *ira, |
| 22524 | return field; | 23432 | return field; |
| 22525 | } | 23433 | } |
| 22526 | | 23434 | |
| 22527 | static IrInstruction *ir_analyze_instruction_byte_offset_of(IrAnalyze *ira, | 23435 | static IrInstGen *ir_analyze_instruction_byte_offset_of(IrAnalyze *ira, IrInstSrcByteOffsetOf *instruction) { |
| 22528 | IrInstructionByteOffsetOf *instruction) | 23436 | IrInstGen *type_value = instruction->type_value->child; |
| 22529 | { | | |
| 22530 | IrInstruction *type_value = instruction->type_value->child; | | |
| 22531 | if (type_is_invalid(type_value->value->type)) | 23437 | if (type_is_invalid(type_value->value->type)) |
| 22532 | return ira->codegen->invalid_instruction; | 23438 | return ira->codegen->invalid_inst_gen; |
| 22533 | | 23439 | |
| 22534 | IrInstruction *field_name_value = instruction->field_name->child; | 23440 | IrInstGen *field_name_value = instruction->field_name->child; |
| 22535 | size_t byte_offset = 0; | 23441 | size_t byte_offset = 0; |
| 22536 | if (!validate_byte_offset(ira, type_value, field_name_value, &byte_offset)) | 23442 | if (!validate_byte_offset(ira, type_value, field_name_value, &byte_offset)) |
| 22537 | return ira->codegen->invalid_instruction; | 23443 | return ira->codegen->invalid_inst_gen; |
| 22538 | | 23444 | |
| 22539 | | 23445 | |
| 22540 | return ir_const_unsigned(ira, &instruction->base, byte_offset); | 23446 | return ir_const_unsigned(ira, &instruction->base.base, byte_offset); |
| 22541 | } | 23447 | } |
| 22542 | | 23448 | |
| 22543 | static IrInstruction *ir_analyze_instruction_bit_offset_of(IrAnalyze *ira, | 23449 | static IrInstGen *ir_analyze_instruction_bit_offset_of(IrAnalyze *ira, IrInstSrcBitOffsetOf *instruction) { |
| 22544 | IrInstructionBitOffsetOf *instruction) | 23450 | IrInstGen *type_value = instruction->type_value->child; |
| 22545 | { | | |
| 22546 | IrInstruction *type_value = instruction->type_value->child; | | |
| 22547 | if (type_is_invalid(type_value->value->type)) | 23451 | if (type_is_invalid(type_value->value->type)) |
| 22548 | return ira->codegen->invalid_instruction; | 23452 | return ira->codegen->invalid_inst_gen; |
| 22549 | IrInstruction *field_name_value = instruction->field_name->child; | 23453 | IrInstGen *field_name_value = instruction->field_name->child; |
| 22550 | size_t byte_offset = 0; | 23454 | size_t byte_offset = 0; |
| 22551 | TypeStructField *field = nullptr; | 23455 | TypeStructField *field = nullptr; |
| 22552 | if (!(field = validate_byte_offset(ira, type_value, field_name_value, &byte_offset))) | 23456 | if (!(field = validate_byte_offset(ira, type_value, field_name_value, &byte_offset))) |
| 22553 | return ira->codegen->invalid_instruction; | 23457 | return ira->codegen->invalid_inst_gen; |
| 22554 | | 23458 | |
| 22555 | size_t bit_offset = byte_offset * 8 + field->bit_offset_in_host; | 23459 | size_t bit_offset = byte_offset * 8 + field->bit_offset_in_host; |
| 22556 | return ir_const_unsigned(ira, &instruction->base, bit_offset); | 23460 | return ir_const_unsigned(ira, &instruction->base.base, bit_offset); |
| 22557 | } | 23461 | } |
| 22558 | | 23462 | |
| 22559 | static void ensure_field_index(ZigType *type, const char *field_name, size_t index) { | 23463 | static void ensure_field_index(ZigType *type, const char *field_name, size_t index) { |
| ... | @@ -22601,7 +23505,7 @@ static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, Zig | ... | @@ -22601,7 +23505,7 @@ static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, Zig |
| 22601 | return ir_resolve_const_type(ira->codegen, ira->new_irb.exec, nullptr, var->const_value); | 23505 | return ir_resolve_const_type(ira->codegen, ira->new_irb.exec, nullptr, var->const_value); |
| 22602 | } | 23506 | } |
| 22603 | | 23507 | |
| 22604 | static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr, ZigValue *out_val, | 23508 | static Error ir_make_type_info_decls(IrAnalyze *ira, IrInst* source_instr, ZigValue *out_val, |
| 22605 | ScopeDecls *decls_scope) | 23509 | ScopeDecls *decls_scope) |
| 22606 | { | 23510 | { |
| 22607 | Error err; | 23511 | Error err; |
| ... | @@ -22959,7 +23863,7 @@ static void make_enum_field_val(IrAnalyze *ira, ZigValue *enum_field_val, TypeEn | ... | @@ -22959,7 +23863,7 @@ static void make_enum_field_val(IrAnalyze *ira, ZigValue *enum_field_val, TypeEn |
| 22959 | enum_field_val->data.x_struct.fields = inner_fields; | 23863 | enum_field_val->data.x_struct.fields = inner_fields; |
| 22960 | } | 23864 | } |
| 22961 | | 23865 | |
| 22962 | static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr, ZigType *type_entry, | 23866 | static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigType *type_entry, |
| 22963 | ZigValue **out) | 23867 | ZigValue **out) |
| 22964 | { | 23868 | { |
| 22965 | Error err; | 23869 | Error err; |
| ... | @@ -23547,22 +24451,20 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -23547,22 +24451,20 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 23547 | return ErrorNone; | 24451 | return ErrorNone; |
| 23548 | } | 24452 | } |
| 23549 | | 24453 | |
| 23550 | static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, | 24454 | static IrInstGen *ir_analyze_instruction_type_info(IrAnalyze *ira, IrInstSrcTypeInfo *instruction) { |
| 23551 | IrInstructionTypeInfo *instruction) | | |
| 23552 | { | | |
| 23553 | Error err; | 24455 | Error err; |
| 23554 | IrInstruction *type_value = instruction->type_value->child; | 24456 | IrInstGen *type_value = instruction->type_value->child; |
| 23555 | ZigType *type_entry = ir_resolve_type(ira, type_value); | 24457 | ZigType *type_entry = ir_resolve_type(ira, type_value); |
| 23556 | if (type_is_invalid(type_entry)) | 24458 | if (type_is_invalid(type_entry)) |
| 23557 | return ira->codegen->invalid_instruction; | 24459 | return ira->codegen->invalid_inst_gen; |
| 23558 | | 24460 | |
| 23559 | ZigType *result_type = ir_type_info_get_type(ira, nullptr, nullptr); | 24461 | ZigType *result_type = ir_type_info_get_type(ira, nullptr, nullptr); |
| 23560 | | 24462 | |
| 23561 | ZigValue *payload; | 24463 | ZigValue *payload; |
| 23562 | if ((err = ir_make_type_info_value(ira, &instruction->base, type_entry, &payload))) | 24464 | if ((err = ir_make_type_info_value(ira, &instruction->base.base, type_entry, &payload))) |
| 23563 | return ira->codegen->invalid_instruction; | 24465 | return ira->codegen->invalid_inst_gen; |
| 23564 | | 24466 | |
| 23565 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 24467 | IrInstGen *result = ir_const(ira, &instruction->base.base, result_type); |
| 23566 | ZigValue *out_val = result->value; | 24468 | ZigValue *out_val = result->value; |
| 23567 | bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry)); | 24469 | bigint_init_unsigned(&out_val->data.x_union.tag, type_id_index(type_entry)); |
| 23568 | out_val->data.x_union.payload = payload; | 24470 | out_val->data.x_union.payload = payload; |
| ... | @@ -23586,15 +24488,15 @@ static ZigValue *get_const_field(IrAnalyze *ira, AstNode *source_node, ZigValue | ... | @@ -23586,15 +24488,15 @@ static ZigValue *get_const_field(IrAnalyze *ira, AstNode *source_node, ZigValue |
| 23586 | return val; | 24488 | return val; |
| 23587 | } | 24489 | } |
| 23588 | | 24490 | |
| 23589 | static Error get_const_field_sentinel(IrAnalyze *ira, IrInstruction *source_instr, ZigValue *struct_value, | 24491 | static Error get_const_field_sentinel(IrAnalyze *ira, IrInst* source_instr, ZigValue *struct_value, |
| 23590 | const char *name, size_t field_index, ZigType *elem_type, ZigValue **result) | 24492 | const char *name, size_t field_index, ZigType *elem_type, ZigValue **result) |
| 23591 | { | 24493 | { |
| 23592 | ZigValue *field_val = get_const_field(ira, source_instr->source_node, struct_value, name, field_index); | 24494 | ZigValue *field_val = get_const_field(ira, source_instr->source_node, struct_value, name, field_index); |
| 23593 | if (field_val == nullptr) | 24495 | if (field_val == nullptr) |
| 23594 | return ErrorSemanticAnalyzeFail; | 24496 | return ErrorSemanticAnalyzeFail; |
| 23595 | | 24497 | |
| 23596 | IrInstruction *field_inst = ir_const_move(ira, source_instr, field_val); | 24498 | IrInstGen *field_inst = ir_const_move(ira, source_instr, field_val); |
| 23597 | IrInstruction *casted_field_inst = ir_implicit_cast(ira, field_inst, | 24499 | IrInstGen *casted_field_inst = ir_implicit_cast(ira, field_inst, |
| 23598 | get_optional_type(ira->codegen, elem_type)); | 24500 | get_optional_type(ira->codegen, elem_type)); |
| 23599 | if (type_is_invalid(casted_field_inst->value->type)) | 24501 | if (type_is_invalid(casted_field_inst->value->type)) |
| 23600 | return ErrorSemanticAnalyzeFail; | 24502 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -23633,12 +24535,12 @@ static ZigType *get_const_field_meta_type(IrAnalyze *ira, AstNode *source_node, | ... | @@ -23633,12 +24535,12 @@ static ZigType *get_const_field_meta_type(IrAnalyze *ira, AstNode *source_node, |
| 23633 | { | 24535 | { |
| 23634 | ZigValue *value = get_const_field(ira, source_node, struct_value, name, field_index); | 24536 | ZigValue *value = get_const_field(ira, source_node, struct_value, name, field_index); |
| 23635 | if (value == nullptr) | 24537 | if (value == nullptr) |
| 23636 | return ira->codegen->invalid_instruction->value->type; | 24538 | return ira->codegen->invalid_inst_gen->value->type; |
| 23637 | assert(value->type == ira->codegen->builtin_types.entry_type); | 24539 | assert(value->type == ira->codegen->builtin_types.entry_type); |
| 23638 | return value->data.x_type; | 24540 | return value->data.x_type; |
| 23639 | } | 24541 | } |
| 23640 | | 24542 | |
| 23641 | static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, ZigTypeId tagTypeId, ZigValue *payload) { | 24543 | static ZigType *type_info_to_type(IrAnalyze *ira, IrInst *source_instr, ZigTypeId tagTypeId, ZigValue *payload) { |
| 23642 | Error err; | 24544 | Error err; |
| 23643 | switch (tagTypeId) { | 24545 | switch (tagTypeId) { |
| 23644 | case ZigTypeIdInvalid: | 24546 | case ZigTypeIdInvalid: |
| ... | @@ -23654,21 +24556,21 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi | ... | @@ -23654,21 +24556,21 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 23654 | case ZigTypeIdInt: { | 24556 | case ZigTypeIdInt: { |
| 23655 | assert(payload->special == ConstValSpecialStatic); | 24557 | assert(payload->special == ConstValSpecialStatic); |
| 23656 | assert(payload->type == ir_type_info_get_type(ira, "Int", nullptr)); | 24558 | assert(payload->type == ir_type_info_get_type(ira, "Int", nullptr)); |
| 23657 | BigInt *bi = get_const_field_lit_int(ira, instruction->source_node, payload, "bits", 1); | 24559 | BigInt *bi = get_const_field_lit_int(ira, source_instr->source_node, payload, "bits", 1); |
| 23658 | if (bi == nullptr) | 24560 | if (bi == nullptr) |
| 23659 | return ira->codegen->invalid_instruction->value->type; | 24561 | return ira->codegen->invalid_inst_gen->value->type; |
| 23660 | bool is_signed; | 24562 | bool is_signed; |
| 23661 | if ((err = get_const_field_bool(ira, instruction->source_node, payload, "is_signed", 0, &is_signed))) | 24563 | if ((err = get_const_field_bool(ira, source_instr->source_node, payload, "is_signed", 0, &is_signed))) |
| 23662 | return ira->codegen->invalid_instruction->value->type; | 24564 | return ira->codegen->invalid_inst_gen->value->type; |
| 23663 | return get_int_type(ira->codegen, is_signed, bigint_as_u32(bi)); | 24565 | return get_int_type(ira->codegen, is_signed, bigint_as_u32(bi)); |
| 23664 | } | 24566 | } |
| 23665 | case ZigTypeIdFloat: | 24567 | case ZigTypeIdFloat: |
| 23666 | { | 24568 | { |
| 23667 | assert(payload->special == ConstValSpecialStatic); | 24569 | assert(payload->special == ConstValSpecialStatic); |
| 23668 | assert(payload->type == ir_type_info_get_type(ira, "Float", nullptr)); | 24570 | assert(payload->type == ir_type_info_get_type(ira, "Float", nullptr)); |
| 23669 | BigInt *bi = get_const_field_lit_int(ira, instruction->source_node, payload, "bits", 0); | 24571 | BigInt *bi = get_const_field_lit_int(ira, source_instr->source_node, payload, "bits", 0); |
| 23670 | if (bi == nullptr) | 24572 | if (bi == nullptr) |
| 23671 | return ira->codegen->invalid_instruction->value->type; | 24573 | return ira->codegen->invalid_inst_gen->value->type; |
| 23672 | uint32_t bits = bigint_as_u32(bi); | 24574 | uint32_t bits = bigint_as_u32(bi); |
| 23673 | switch (bits) { | 24575 | switch (bits) { |
| 23674 | case 16: return ira->codegen->builtin_types.entry_f16; | 24576 | case 16: return ira->codegen->builtin_types.entry_f16; |
| ... | @@ -23676,48 +24578,47 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi | ... | @@ -23676,48 +24578,47 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 23676 | case 64: return ira->codegen->builtin_types.entry_f64; | 24578 | case 64: return ira->codegen->builtin_types.entry_f64; |
| 23677 | case 128: return ira->codegen->builtin_types.entry_f128; | 24579 | case 128: return ira->codegen->builtin_types.entry_f128; |
| 23678 | } | 24580 | } |
| 23679 | ir_add_error(ira, instruction, | 24581 | ir_add_error(ira, source_instr, buf_sprintf("%d-bit float unsupported", bits)); |
| 23680 | buf_sprintf("%d-bit float unsupported", bits)); | 24582 | return ira->codegen->invalid_inst_gen->value->type; |
| 23681 | return ira->codegen->invalid_instruction->value->type; | | |
| 23682 | } | 24583 | } |
| 23683 | case ZigTypeIdPointer: | 24584 | case ZigTypeIdPointer: |
| 23684 | { | 24585 | { |
| 23685 | ZigType *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr); | 24586 | ZigType *type_info_pointer_type = ir_type_info_get_type(ira, "Pointer", nullptr); |
| 23686 | assert(payload->special == ConstValSpecialStatic); | 24587 | assert(payload->special == ConstValSpecialStatic); |
| 23687 | assert(payload->type == type_info_pointer_type); | 24588 | assert(payload->type == type_info_pointer_type); |
| 23688 | ZigValue *size_value = get_const_field(ira, instruction->source_node, payload, "size", 0); | 24589 | ZigValue *size_value = get_const_field(ira, source_instr->source_node, payload, "size", 0); |
| 23689 | assert(size_value->type == ir_type_info_get_type(ira, "Size", type_info_pointer_type)); | 24590 | assert(size_value->type == ir_type_info_get_type(ira, "Size", type_info_pointer_type)); |
| 23690 | BuiltinPtrSize size_enum_index = (BuiltinPtrSize)bigint_as_u32(&size_value->data.x_enum_tag); | 24591 | BuiltinPtrSize size_enum_index = (BuiltinPtrSize)bigint_as_u32(&size_value->data.x_enum_tag); |
| 23691 | PtrLen ptr_len = size_enum_index_to_ptr_len(size_enum_index); | 24592 | PtrLen ptr_len = size_enum_index_to_ptr_len(size_enum_index); |
| 23692 | ZigType *elem_type = get_const_field_meta_type(ira, instruction->source_node, payload, "child", 4); | 24593 | ZigType *elem_type = get_const_field_meta_type(ira, source_instr->source_node, payload, "child", 4); |
| 23693 | if (type_is_invalid(elem_type)) | 24594 | if (type_is_invalid(elem_type)) |
| 23694 | return ira->codegen->invalid_instruction->value->type; | 24595 | return ira->codegen->invalid_inst_gen->value->type; |
| 23695 | ZigValue *sentinel; | 24596 | ZigValue *sentinel; |
| 23696 | if ((err = get_const_field_sentinel(ira, instruction, payload, "sentinel", 6, | 24597 | if ((err = get_const_field_sentinel(ira, source_instr, payload, "sentinel", 6, |
| 23697 | elem_type, &sentinel))) | 24598 | elem_type, &sentinel))) |
| 23698 | { | 24599 | { |
| 23699 | return ira->codegen->invalid_instruction->value->type; | 24600 | return ira->codegen->invalid_inst_gen->value->type; |
| 23700 | } | 24601 | } |
| 23701 | BigInt *bi = get_const_field_lit_int(ira, instruction->source_node, payload, "alignment", 3); | 24602 | BigInt *bi = get_const_field_lit_int(ira, source_instr->source_node, payload, "alignment", 3); |
| 23702 | if (bi == nullptr) | 24603 | if (bi == nullptr) |
| 23703 | return ira->codegen->invalid_instruction->value->type; | 24604 | return ira->codegen->invalid_inst_gen->value->type; |
| 23704 | | 24605 | |
| 23705 | bool is_const; | 24606 | bool is_const; |
| 23706 | if ((err = get_const_field_bool(ira, instruction->source_node, payload, "is_const", 1, &is_const))) | 24607 | if ((err = get_const_field_bool(ira, source_instr->source_node, payload, "is_const", 1, &is_const))) |
| 23707 | return ira->codegen->invalid_instruction->value->type; | 24608 | return ira->codegen->invalid_inst_gen->value->type; |
| 23708 | | 24609 | |
| 23709 | bool is_volatile; | 24610 | bool is_volatile; |
| 23710 | if ((err = get_const_field_bool(ira, instruction->source_node, payload, "is_volatile", 2, | 24611 | if ((err = get_const_field_bool(ira, source_instr->source_node, payload, "is_volatile", 2, |
| 23711 | &is_volatile))) | 24612 | &is_volatile))) |
| 23712 | { | 24613 | { |
| 23713 | return ira->codegen->invalid_instruction->value->type; | 24614 | return ira->codegen->invalid_inst_gen->value->type; |
| 23714 | } | 24615 | } |
| 23715 | | 24616 | |
| 23716 | bool is_allowzero; | 24617 | bool is_allowzero; |
| 23717 | if ((err = get_const_field_bool(ira, instruction->source_node, payload, "is_allowzero", 5, | 24618 | if ((err = get_const_field_bool(ira, source_instr->source_node, payload, "is_allowzero", 5, |
| 23718 | &is_allowzero))) | 24619 | &is_allowzero))) |
| 23719 | { | 24620 | { |
| 23720 | return ira->codegen->invalid_instruction->value->type; | 24621 | return ira->codegen->invalid_inst_gen->value->type; |
| 23721 | } | 24622 | } |
| 23722 | | 24623 | |
| 23723 | | 24624 | |
| ... | @@ -23738,18 +24639,18 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi | ... | @@ -23738,18 +24639,18 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 23738 | case ZigTypeIdArray: { | 24639 | case ZigTypeIdArray: { |
| 23739 | assert(payload->special == ConstValSpecialStatic); | 24640 | assert(payload->special == ConstValSpecialStatic); |
| 23740 | assert(payload->type == ir_type_info_get_type(ira, "Array", nullptr)); | 24641 | assert(payload->type == ir_type_info_get_type(ira, "Array", nullptr)); |
| 23741 | ZigType *elem_type = get_const_field_meta_type(ira, instruction->source_node, payload, "child", 1); | 24642 | ZigType *elem_type = get_const_field_meta_type(ira, source_instr->source_node, payload, "child", 1); |
| 23742 | if (type_is_invalid(elem_type)) | 24643 | if (type_is_invalid(elem_type)) |
| 23743 | return ira->codegen->invalid_instruction->value->type; | 24644 | return ira->codegen->invalid_inst_gen->value->type; |
| 23744 | ZigValue *sentinel; | 24645 | ZigValue *sentinel; |
| 23745 | if ((err = get_const_field_sentinel(ira, instruction, payload, "sentinel", 2, | 24646 | if ((err = get_const_field_sentinel(ira, source_instr, payload, "sentinel", 2, |
| 23746 | elem_type, &sentinel))) | 24647 | elem_type, &sentinel))) |
| 23747 | { | 24648 | { |
| 23748 | return ira->codegen->invalid_instruction->value->type; | 24649 | return ira->codegen->invalid_inst_gen->value->type; |
| 23749 | } | 24650 | } |
| 23750 | BigInt *bi = get_const_field_lit_int(ira, instruction->source_node, payload, "len", 0); | 24651 | BigInt *bi = get_const_field_lit_int(ira, source_instr->source_node, payload, "len", 0); |
| 23751 | if (bi == nullptr) | 24652 | if (bi == nullptr) |
| 23752 | return ira->codegen->invalid_instruction->value->type; | 24653 | return ira->codegen->invalid_inst_gen->value->type; |
| 23753 | return get_array_type(ira->codegen, elem_type, bigint_as_u64(bi), sentinel); | 24654 | return get_array_type(ira->codegen, elem_type, bigint_as_u64(bi), sentinel); |
| 23754 | } | 24655 | } |
| 23755 | case ZigTypeIdComptimeFloat: | 24656 | case ZigTypeIdComptimeFloat: |
| ... | @@ -23769,78 +24670,77 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi | ... | @@ -23769,78 +24670,77 @@ static ZigType *type_info_to_type(IrAnalyze *ira, IrInstruction *instruction, Zi |
| 23769 | case ZigTypeIdAnyFrame: | 24670 | case ZigTypeIdAnyFrame: |
| 23770 | case ZigTypeIdVector: | 24671 | case ZigTypeIdVector: |
| 23771 | case ZigTypeIdEnumLiteral: | 24672 | case ZigTypeIdEnumLiteral: |
| 23772 | ir_add_error(ira, instruction, buf_sprintf( | 24673 | ir_add_error(ira, source_instr, buf_sprintf( |
| 23773 | "TODO implement @Type for 'TypeInfo.%s': see https://github.com/ziglang/zig/issues/2907", type_id_name(tagTypeId))); | 24674 | "TODO implement @Type for 'TypeInfo.%s': see https://github.com/ziglang/zig/issues/2907", type_id_name(tagTypeId))); |
| 23774 | return ira->codegen->invalid_instruction->value->type; | 24675 | return ira->codegen->invalid_inst_gen->value->type; |
| 23775 | case ZigTypeIdUnion: | 24676 | case ZigTypeIdUnion: |
| 23776 | case ZigTypeIdFn: | 24677 | case ZigTypeIdFn: |
| 23777 | case ZigTypeIdBoundFn: | 24678 | case ZigTypeIdBoundFn: |
| 23778 | case ZigTypeIdStruct: | 24679 | case ZigTypeIdStruct: |
| 23779 | ir_add_error(ira, instruction, buf_sprintf( | 24680 | ir_add_error(ira, source_instr, buf_sprintf( |
| 23780 | "@Type not availble for 'TypeInfo.%s'", type_id_name(tagTypeId))); | 24681 | "@Type not availble for 'TypeInfo.%s'", type_id_name(tagTypeId))); |
| 23781 | return ira->codegen->invalid_instruction->value->type; | 24682 | return ira->codegen->invalid_inst_gen->value->type; |
| 23782 | } | 24683 | } |
| 23783 | zig_unreachable(); | 24684 | zig_unreachable(); |
| 23784 | } | 24685 | } |
| 23785 | | 24686 | |
| 23786 | static IrInstruction *ir_analyze_instruction_type(IrAnalyze *ira, IrInstructionType *instruction) { | 24687 | static IrInstGen *ir_analyze_instruction_type(IrAnalyze *ira, IrInstSrcType *instruction) { |
| 23787 | IrInstruction *type_info_ir = instruction->type_info->child; | 24688 | IrInstGen *uncasted_type_info = instruction->type_info->child; |
| 23788 | if (type_is_invalid(type_info_ir->value->type)) | 24689 | if (type_is_invalid(uncasted_type_info->value->type)) |
| 23789 | return ira->codegen->invalid_instruction; | 24690 | return ira->codegen->invalid_inst_gen; |
| 23790 | | 24691 | |
| 23791 | IrInstruction *casted_ir = ir_implicit_cast(ira, type_info_ir, ir_type_info_get_type(ira, nullptr, nullptr)); | 24692 | IrInstGen *type_info = ir_implicit_cast(ira, uncasted_type_info, ir_type_info_get_type(ira, nullptr, nullptr)); |
| 23792 | if (type_is_invalid(casted_ir->value->type)) | 24693 | if (type_is_invalid(type_info->value->type)) |
| 23793 | return ira->codegen->invalid_instruction; | 24694 | return ira->codegen->invalid_inst_gen; |
| 23794 | | 24695 | |
| 23795 | ZigValue *type_info_value = ir_resolve_const(ira, casted_ir, UndefBad); | 24696 | ZigValue *type_info_val = ir_resolve_const(ira, type_info, UndefBad); |
| 23796 | if (!type_info_value) | 24697 | if (type_info_val == nullptr) |
| 23797 | return ira->codegen->invalid_instruction; | 24698 | return ira->codegen->invalid_inst_gen; |
| 23798 | ZigTypeId typeId = type_id_at_index(bigint_as_usize(&type_info_value->data.x_union.tag)); | 24699 | ZigTypeId type_id_tag = type_id_at_index(bigint_as_usize(&type_info_val->data.x_union.tag)); |
| 23799 | ZigType *type = type_info_to_type(ira, type_info_ir, typeId, type_info_value->data.x_union.payload); | 24700 | ZigType *type = type_info_to_type(ira, &uncasted_type_info->base, type_id_tag, |
| | 24701 | type_info_val->data.x_union.payload); |
| 23800 | if (type_is_invalid(type)) | 24702 | if (type_is_invalid(type)) |
| 23801 | return ira->codegen->invalid_instruction; | 24703 | return ira->codegen->invalid_inst_gen; |
| 23802 | return ir_const_type(ira, &instruction->base, type); | 24704 | return ir_const_type(ira, &instruction->base.base, type); |
| 23803 | } | 24705 | } |
| 23804 | | 24706 | |
| 23805 | static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira, | 24707 | static IrInstGen *ir_analyze_instruction_type_id(IrAnalyze *ira, IrInstSrcTypeId *instruction) { |
| 23806 | IrInstructionTypeId *instruction) | 24708 | IrInstGen *type_value = instruction->type_value->child; |
| 23807 | { | | |
| 23808 | IrInstruction *type_value = instruction->type_value->child; | | |
| 23809 | ZigType *type_entry = ir_resolve_type(ira, type_value); | 24709 | ZigType *type_entry = ir_resolve_type(ira, type_value); |
| 23810 | if (type_is_invalid(type_entry)) | 24710 | if (type_is_invalid(type_entry)) |
| 23811 | return ira->codegen->invalid_instruction; | 24711 | return ira->codegen->invalid_inst_gen; |
| 23812 | | 24712 | |
| 23813 | ZigType *result_type = get_builtin_type(ira->codegen, "TypeId"); | 24713 | ZigType *result_type = get_builtin_type(ira->codegen, "TypeId"); |
| 23814 | | 24714 | |
| 23815 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 24715 | IrInstGen *result = ir_const(ira, &instruction->base.base, result_type); |
| 23816 | bigint_init_unsigned(&result->value->data.x_enum_tag, type_id_index(type_entry)); | 24716 | bigint_init_unsigned(&result->value->data.x_enum_tag, type_id_index(type_entry)); |
| 23817 | return result; | 24717 | return result; |
| 23818 | } | 24718 | } |
| 23819 | | 24719 | |
| 23820 | static IrInstruction *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira, | 24720 | static IrInstGen *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira, |
| 23821 | IrInstructionSetEvalBranchQuota *instruction) | 24721 | IrInstSrcSetEvalBranchQuota *instruction) |
| 23822 | { | 24722 | { |
| 23823 | uint64_t new_quota; | 24723 | uint64_t new_quota; |
| 23824 | if (!ir_resolve_usize(ira, instruction->new_quota->child, &new_quota)) | 24724 | if (!ir_resolve_usize(ira, instruction->new_quota->child, &new_quota)) |
| 23825 | return ira->codegen->invalid_instruction; | 24725 | return ira->codegen->invalid_inst_gen; |
| 23826 | | 24726 | |
| 23827 | if (new_quota > *ira->new_irb.exec->backward_branch_quota) { | 24727 | if (new_quota > *ira->new_irb.exec->backward_branch_quota) { |
| 23828 | *ira->new_irb.exec->backward_branch_quota = new_quota; | 24728 | *ira->new_irb.exec->backward_branch_quota = new_quota; |
| 23829 | } | 24729 | } |
| 23830 | | 24730 | |
| 23831 | return ir_const_void(ira, &instruction->base); | 24731 | return ir_const_void(ira, &instruction->base.base); |
| 23832 | } | 24732 | } |
| 23833 | | 24733 | |
| 23834 | static IrInstruction *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstructionTypeName *instruction) { | 24734 | static IrInstGen *ir_analyze_instruction_type_name(IrAnalyze *ira, IrInstSrcTypeName *instruction) { |
| 23835 | IrInstruction *type_value = instruction->type_value->child; | 24735 | IrInstGen *type_value = instruction->type_value->child; |
| 23836 | ZigType *type_entry = ir_resolve_type(ira, type_value); | 24736 | ZigType *type_entry = ir_resolve_type(ira, type_value); |
| 23837 | if (type_is_invalid(type_entry)) | 24737 | if (type_is_invalid(type_entry)) |
| 23838 | return ira->codegen->invalid_instruction; | 24738 | return ira->codegen->invalid_inst_gen; |
| 23839 | | 24739 | |
| 23840 | if (!type_entry->cached_const_name_val) { | 24740 | if (!type_entry->cached_const_name_val) { |
| 23841 | type_entry->cached_const_name_val = create_const_str_lit(ira->codegen, type_bare_name(type_entry)); | 24741 | type_entry->cached_const_name_val = create_const_str_lit(ira->codegen, type_bare_name(type_entry)); |
| 23842 | } | 24742 | } |
| 23843 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 24743 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 23844 | copy_const_val(result->value, type_entry->cached_const_name_val); | 24744 | copy_const_val(result->value, type_entry->cached_const_name_val); |
| 23845 | return result; | 24745 | return result; |
| 23846 | } | 24746 | } |
| ... | @@ -23852,13 +24752,13 @@ static void ir_cimport_cache_paths(Buf *cache_dir, Buf *tmp_c_file_digest, Buf * | ... | @@ -23852,13 +24752,13 @@ static void ir_cimport_cache_paths(Buf *cache_dir, Buf *tmp_c_file_digest, Buf * |
| 23852 | buf_ptr(cache_dir), buf_ptr(tmp_c_file_digest)); | 24752 | buf_ptr(cache_dir), buf_ptr(tmp_c_file_digest)); |
| 23853 | buf_appendf(out_zig_path, "%s" OS_SEP "cimport.zig", buf_ptr(out_zig_dir)); | 24753 | buf_appendf(out_zig_path, "%s" OS_SEP "cimport.zig", buf_ptr(out_zig_dir)); |
| 23854 | } | 24754 | } |
| 23855 | static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstructionCImport *instruction) { | 24755 | static IrInstGen *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstSrcCImport *instruction) { |
| 23856 | Error err; | 24756 | Error err; |
| 23857 | AstNode *node = instruction->base.source_node; | 24757 | AstNode *node = instruction->base.base.source_node; |
| 23858 | assert(node->type == NodeTypeFnCallExpr); | 24758 | assert(node->type == NodeTypeFnCallExpr); |
| 23859 | AstNode *block_node = node->data.fn_call_expr.params.at(0); | 24759 | AstNode *block_node = node->data.fn_call_expr.params.at(0); |
| 23860 | | 24760 | |
| 23861 | ScopeCImport *cimport_scope = create_cimport_scope(ira->codegen, node, instruction->base.scope); | 24761 | ScopeCImport *cimport_scope = create_cimport_scope(ira->codegen, node, instruction->base.base.scope); |
| 23862 | | 24762 | |
| 23863 | // Execute the C import block like an inline function | 24763 | // Execute the C import block like an inline function |
| 23864 | ZigType *void_type = ira->codegen->builtin_types.entry_void; | 24764 | ZigType *void_type = ira->codegen->builtin_types.entry_void; |
| ... | @@ -23866,9 +24766,9 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -23866,9 +24766,9 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 23866 | ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, nullptr, | 24766 | ira->new_irb.exec->backward_branch_count, ira->new_irb.exec->backward_branch_quota, nullptr, |
| 23867 | &cimport_scope->buf, block_node, nullptr, nullptr, nullptr, UndefBad); | 24767 | &cimport_scope->buf, block_node, nullptr, nullptr, nullptr, UndefBad); |
| 23868 | if (type_is_invalid(cimport_result->type)) | 24768 | if (type_is_invalid(cimport_result->type)) |
| 23869 | return ira->codegen->invalid_instruction; | 24769 | return ira->codegen->invalid_inst_gen; |
| 23870 | | 24770 | |
| 23871 | ZigPackage *cur_scope_pkg = scope_package(instruction->base.scope); | 24771 | ZigPackage *cur_scope_pkg = scope_package(instruction->base.base.scope); |
| 23872 | Buf *namespace_name = buf_sprintf("%s.cimport:%" ZIG_PRI_usize ":%" ZIG_PRI_usize, | 24772 | Buf *namespace_name = buf_sprintf("%s.cimport:%" ZIG_PRI_usize ":%" ZIG_PRI_usize, |
| 23873 | buf_ptr(&cur_scope_pkg->pkg_path), node->line + 1, node->column + 1); | 24773 | buf_ptr(&cur_scope_pkg->pkg_path), node->line + 1, node->column + 1); |
| 23874 | | 24774 | |
| ... | @@ -23880,7 +24780,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -23880,7 +24780,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 23880 | CacheHash *cache_hash; | 24780 | CacheHash *cache_hash; |
| 23881 | if ((err = create_c_object_cache(ira->codegen, &cache_hash, false))) { | 24781 | if ((err = create_c_object_cache(ira->codegen, &cache_hash, false))) { |
| 23882 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to create cache: %s", err_str(err))); | 24782 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to create cache: %s", err_str(err))); |
| 23883 | return ira->codegen->invalid_instruction; | 24783 | return ira->codegen->invalid_inst_gen; |
| 23884 | } | 24784 | } |
| 23885 | cache_buf(cache_hash, &cimport_scope->buf); | 24785 | cache_buf(cache_hash, &cimport_scope->buf); |
| 23886 | | 24786 | |
| ... | @@ -23892,7 +24792,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -23892,7 +24792,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 23892 | if ((err = cache_hit(cache_hash, &tmp_c_file_digest))) { | 24792 | if ((err = cache_hit(cache_hash, &tmp_c_file_digest))) { |
| 23893 | if (err != ErrorInvalidFormat) { | 24793 | if (err != ErrorInvalidFormat) { |
| 23894 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to check cache: %s", err_str(err))); | 24794 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to check cache: %s", err_str(err))); |
| 23895 | return ira->codegen->invalid_instruction; | 24795 | return ira->codegen->invalid_inst_gen; |
| 23896 | } | 24796 | } |
| 23897 | } | 24797 | } |
| 23898 | ira->codegen->caches_to_release.append(cache_hash); | 24798 | ira->codegen->caches_to_release.append(cache_hash); |
| ... | @@ -23911,12 +24811,12 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -23911,12 +24811,12 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 23911 | | 24811 | |
| 23912 | if ((err = os_make_path(tmp_c_file_dir))) { | 24812 | if ((err = os_make_path(tmp_c_file_dir))) { |
| 23913 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to make dir: %s", err_str(err))); | 24813 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to make dir: %s", err_str(err))); |
| 23914 | return ira->codegen->invalid_instruction; | 24814 | return ira->codegen->invalid_inst_gen; |
| 23915 | } | 24815 | } |
| 23916 | | 24816 | |
| 23917 | if ((err = os_write_file(&tmp_c_file_path, &cimport_scope->buf))) { | 24817 | if ((err = os_write_file(&tmp_c_file_path, &cimport_scope->buf))) { |
| 23918 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to write .h file: %s", err_str(err))); | 24818 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to write .h file: %s", err_str(err))); |
| 23919 | return ira->codegen->invalid_instruction; | 24819 | return ira->codegen->invalid_inst_gen; |
| 23920 | } | 24820 | } |
| 23921 | if (ira->codegen->verbose_cimport) { | 24821 | if (ira->codegen->verbose_cimport) { |
| 23922 | fprintf(stderr, "@cImport source: %s\n", buf_ptr(&tmp_c_file_path)); | 24822 | fprintf(stderr, "@cImport source: %s\n", buf_ptr(&tmp_c_file_path)); |
| ... | @@ -23951,7 +24851,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -23951,7 +24851,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 23951 | { | 24851 | { |
| 23952 | if (err != ErrorCCompileErrors) { | 24852 | if (err != ErrorCCompileErrors) { |
| 23953 | ir_add_error_node(ira, node, buf_sprintf("C import failed: %s", err_str(err))); | 24853 | ir_add_error_node(ira, node, buf_sprintf("C import failed: %s", err_str(err))); |
| 23954 | return ira->codegen->invalid_instruction; | 24854 | return ira->codegen->invalid_inst_gen; |
| 23955 | } | 24855 | } |
| 23956 | | 24856 | |
| 23957 | ErrorMsg *parent_err_msg = ir_add_error_node(ira, node, buf_sprintf("C import failed")); | 24857 | ErrorMsg *parent_err_msg = ir_add_error_node(ira, node, buf_sprintf("C import failed")); |
| ... | @@ -23972,7 +24872,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -23972,7 +24872,7 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 23972 | } | 24872 | } |
| 23973 | } | 24873 | } |
| 23974 | | 24874 | |
| 23975 | return ira->codegen->invalid_instruction; | 24875 | return ira->codegen->invalid_inst_gen; |
| 23976 | } | 24876 | } |
| 23977 | if (ira->codegen->verbose_cimport) { | 24877 | if (ira->codegen->verbose_cimport) { |
| 23978 | fprintf(stderr, "@cImport .d file: %s\n", buf_ptr(tmp_dep_file)); | 24878 | fprintf(stderr, "@cImport .d file: %s\n", buf_ptr(tmp_dep_file)); |
| ... | @@ -23980,29 +24880,29 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -23980,29 +24880,29 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 23980 | | 24880 | |
| 23981 | if ((err = cache_add_dep_file(cache_hash, tmp_dep_file, false))) { | 24881 | if ((err = cache_add_dep_file(cache_hash, tmp_dep_file, false))) { |
| 23982 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to parse .d file: %s", err_str(err))); | 24882 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to parse .d file: %s", err_str(err))); |
| 23983 | return ira->codegen->invalid_instruction; | 24883 | return ira->codegen->invalid_inst_gen; |
| 23984 | } | 24884 | } |
| 23985 | if ((err = cache_final(cache_hash, &tmp_c_file_digest))) { | 24885 | if ((err = cache_final(cache_hash, &tmp_c_file_digest))) { |
| 23986 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to finalize cache: %s", err_str(err))); | 24886 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to finalize cache: %s", err_str(err))); |
| 23987 | return ira->codegen->invalid_instruction; | 24887 | return ira->codegen->invalid_inst_gen; |
| 23988 | } | 24888 | } |
| 23989 | | 24889 | |
| 23990 | ir_cimport_cache_paths(ira->codegen->cache_dir, &tmp_c_file_digest, out_zig_dir, out_zig_path); | 24890 | ir_cimport_cache_paths(ira->codegen->cache_dir, &tmp_c_file_digest, out_zig_dir, out_zig_path); |
| 23991 | if ((err = os_make_path(out_zig_dir))) { | 24891 | if ((err = os_make_path(out_zig_dir))) { |
| 23992 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to make output dir: %s", err_str(err))); | 24892 | ir_add_error_node(ira, node, buf_sprintf("C import failed: unable to make output dir: %s", err_str(err))); |
| 23993 | return ira->codegen->invalid_instruction; | 24893 | return ira->codegen->invalid_inst_gen; |
| 23994 | } | 24894 | } |
| 23995 | FILE *out_file = fopen(buf_ptr(out_zig_path), "wb"); | 24895 | FILE *out_file = fopen(buf_ptr(out_zig_path), "wb"); |
| 23996 | if (out_file == nullptr) { | 24896 | if (out_file == nullptr) { |
| 23997 | ir_add_error_node(ira, node, | 24897 | ir_add_error_node(ira, node, |
| 23998 | buf_sprintf("C import failed: unable to open output file: %s", strerror(errno))); | 24898 | buf_sprintf("C import failed: unable to open output file: %s", strerror(errno))); |
| 23999 | return ira->codegen->invalid_instruction; | 24899 | return ira->codegen->invalid_inst_gen; |
| 24000 | } | 24900 | } |
| 24001 | stage2_render_ast(ast, out_file); | 24901 | stage2_render_ast(ast, out_file); |
| 24002 | if (fclose(out_file) != 0) { | 24902 | if (fclose(out_file) != 0) { |
| 24003 | ir_add_error_node(ira, node, | 24903 | ir_add_error_node(ira, node, |
| 24004 | buf_sprintf("C import failed: unable to write to output file: %s", strerror(errno))); | 24904 | buf_sprintf("C import failed: unable to write to output file: %s", strerror(errno))); |
| 24005 | return ira->codegen->invalid_instruction; | 24905 | return ira->codegen->invalid_inst_gen; |
| 24006 | } | 24906 | } |
| 24007 | | 24907 | |
| 24008 | if (ira->codegen->verbose_cimport) { | 24908 | if (ira->codegen->verbose_cimport) { |
| ... | @@ -24021,90 +24921,90 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct | ... | @@ -24021,90 +24921,90 @@ static IrInstruction *ir_analyze_instruction_c_import(IrAnalyze *ira, IrInstruct |
| 24021 | if ((err = file_fetch(ira->codegen, out_zig_path, import_code))) { | 24921 | if ((err = file_fetch(ira->codegen, out_zig_path, import_code))) { |
| 24022 | ir_add_error_node(ira, node, | 24922 | ir_add_error_node(ira, node, |
| 24023 | buf_sprintf("unable to open '%s': %s", buf_ptr(out_zig_path), err_str(err))); | 24923 | buf_sprintf("unable to open '%s': %s", buf_ptr(out_zig_path), err_str(err))); |
| 24024 | return ira->codegen->invalid_instruction; | 24924 | return ira->codegen->invalid_inst_gen; |
| 24025 | } | 24925 | } |
| 24026 | ZigType *child_import = add_source_file(ira->codegen, cimport_pkg, out_zig_path, | 24926 | ZigType *child_import = add_source_file(ira->codegen, cimport_pkg, out_zig_path, |
| 24027 | import_code, SourceKindCImport); | 24927 | import_code, SourceKindCImport); |
| 24028 | return ir_const_type(ira, &instruction->base, child_import); | 24928 | return ir_const_type(ira, &instruction->base.base, child_import); |
| 24029 | } | 24929 | } |
| 24030 | | 24930 | |
| 24031 | static IrInstruction *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstructionCInclude *instruction) { | 24931 | static IrInstGen *ir_analyze_instruction_c_include(IrAnalyze *ira, IrInstSrcCInclude *instruction) { |
| 24032 | IrInstruction *name_value = instruction->name->child; | 24932 | IrInstGen *name_value = instruction->name->child; |
| 24033 | if (type_is_invalid(name_value->value->type)) | 24933 | if (type_is_invalid(name_value->value->type)) |
| 24034 | return ira->codegen->invalid_instruction; | 24934 | return ira->codegen->invalid_inst_gen; |
| 24035 | | 24935 | |
| 24036 | Buf *include_name = ir_resolve_str(ira, name_value); | 24936 | Buf *include_name = ir_resolve_str(ira, name_value); |
| 24037 | if (!include_name) | 24937 | if (!include_name) |
| 24038 | return ira->codegen->invalid_instruction; | 24938 | return ira->codegen->invalid_inst_gen; |
| 24039 | | 24939 | |
| 24040 | Buf *c_import_buf = exec_c_import_buf(ira->new_irb.exec); | 24940 | Buf *c_import_buf = ira->new_irb.exec->c_import_buf; |
| 24041 | // We check for this error in pass1 | 24941 | // We check for this error in pass1 |
| 24042 | assert(c_import_buf); | 24942 | assert(c_import_buf); |
| 24043 | | 24943 | |
| 24044 | buf_appendf(c_import_buf, "#include <%s>\n", buf_ptr(include_name)); | 24944 | buf_appendf(c_import_buf, "#include <%s>\n", buf_ptr(include_name)); |
| 24045 | | 24945 | |
| 24046 | return ir_const_void(ira, &instruction->base); | 24946 | return ir_const_void(ira, &instruction->base.base); |
| 24047 | } | 24947 | } |
| 24048 | | 24948 | |
| 24049 | static IrInstruction *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstructionCDefine *instruction) { | 24949 | static IrInstGen *ir_analyze_instruction_c_define(IrAnalyze *ira, IrInstSrcCDefine *instruction) { |
| 24050 | IrInstruction *name = instruction->name->child; | 24950 | IrInstGen *name = instruction->name->child; |
| 24051 | if (type_is_invalid(name->value->type)) | 24951 | if (type_is_invalid(name->value->type)) |
| 24052 | return ira->codegen->invalid_instruction; | 24952 | return ira->codegen->invalid_inst_gen; |
| 24053 | | 24953 | |
| 24054 | Buf *define_name = ir_resolve_str(ira, name); | 24954 | Buf *define_name = ir_resolve_str(ira, name); |
| 24055 | if (!define_name) | 24955 | if (!define_name) |
| 24056 | return ira->codegen->invalid_instruction; | 24956 | return ira->codegen->invalid_inst_gen; |
| 24057 | | 24957 | |
| 24058 | IrInstruction *value = instruction->value->child; | 24958 | IrInstGen *value = instruction->value->child; |
| 24059 | if (type_is_invalid(value->value->type)) | 24959 | if (type_is_invalid(value->value->type)) |
| 24060 | return ira->codegen->invalid_instruction; | 24960 | return ira->codegen->invalid_inst_gen; |
| 24061 | | 24961 | |
| 24062 | Buf *define_value = nullptr; | 24962 | Buf *define_value = nullptr; |
| 24063 | // The second parameter is either a string or void (equivalent to "") | 24963 | // The second parameter is either a string or void (equivalent to "") |
| 24064 | if (value->value->type->id != ZigTypeIdVoid) { | 24964 | if (value->value->type->id != ZigTypeIdVoid) { |
| 24065 | define_value = ir_resolve_str(ira, value); | 24965 | define_value = ir_resolve_str(ira, value); |
| 24066 | if (!define_value) | 24966 | if (!define_value) |
| 24067 | return ira->codegen->invalid_instruction; | 24967 | return ira->codegen->invalid_inst_gen; |
| 24068 | } | 24968 | } |
| 24069 | | 24969 | |
| 24070 | Buf *c_import_buf = exec_c_import_buf(ira->new_irb.exec); | 24970 | Buf *c_import_buf = ira->new_irb.exec->c_import_buf; |
| 24071 | // We check for this error in pass1 | 24971 | // We check for this error in pass1 |
| 24072 | assert(c_import_buf); | 24972 | assert(c_import_buf); |
| 24073 | | 24973 | |
| 24074 | buf_appendf(c_import_buf, "#define %s %s\n", buf_ptr(define_name), | 24974 | buf_appendf(c_import_buf, "#define %s %s\n", buf_ptr(define_name), |
| 24075 | define_value ? buf_ptr(define_value) : ""); | 24975 | define_value ? buf_ptr(define_value) : ""); |
| 24076 | | 24976 | |
| 24077 | return ir_const_void(ira, &instruction->base); | 24977 | return ir_const_void(ira, &instruction->base.base); |
| 24078 | } | 24978 | } |
| 24079 | | 24979 | |
| 24080 | static IrInstruction *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstructionCUndef *instruction) { | 24980 | static IrInstGen *ir_analyze_instruction_c_undef(IrAnalyze *ira, IrInstSrcCUndef *instruction) { |
| 24081 | IrInstruction *name = instruction->name->child; | 24981 | IrInstGen *name = instruction->name->child; |
| 24082 | if (type_is_invalid(name->value->type)) | 24982 | if (type_is_invalid(name->value->type)) |
| 24083 | return ira->codegen->invalid_instruction; | 24983 | return ira->codegen->invalid_inst_gen; |
| 24084 | | 24984 | |
| 24085 | Buf *undef_name = ir_resolve_str(ira, name); | 24985 | Buf *undef_name = ir_resolve_str(ira, name); |
| 24086 | if (!undef_name) | 24986 | if (!undef_name) |
| 24087 | return ira->codegen->invalid_instruction; | 24987 | return ira->codegen->invalid_inst_gen; |
| 24088 | | 24988 | |
| 24089 | Buf *c_import_buf = exec_c_import_buf(ira->new_irb.exec); | 24989 | Buf *c_import_buf = ira->new_irb.exec->c_import_buf; |
| 24090 | // We check for this error in pass1 | 24990 | // We check for this error in pass1 |
| 24091 | assert(c_import_buf); | 24991 | assert(c_import_buf); |
| 24092 | | 24992 | |
| 24093 | buf_appendf(c_import_buf, "#undef %s\n", buf_ptr(undef_name)); | 24993 | buf_appendf(c_import_buf, "#undef %s\n", buf_ptr(undef_name)); |
| 24094 | | 24994 | |
| 24095 | return ir_const_void(ira, &instruction->base); | 24995 | return ir_const_void(ira, &instruction->base.base); |
| 24096 | } | 24996 | } |
| 24097 | | 24997 | |
| 24098 | static IrInstruction *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstructionEmbedFile *instruction) { | 24998 | static IrInstGen *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstSrcEmbedFile *instruction) { |
| 24099 | IrInstruction *name = instruction->name->child; | 24999 | IrInstGen *name = instruction->name->child; |
| 24100 | if (type_is_invalid(name->value->type)) | 25000 | if (type_is_invalid(name->value->type)) |
| 24101 | return ira->codegen->invalid_instruction; | 25001 | return ira->codegen->invalid_inst_gen; |
| 24102 | | 25002 | |
| 24103 | Buf *rel_file_path = ir_resolve_str(ira, name); | 25003 | Buf *rel_file_path = ir_resolve_str(ira, name); |
| 24104 | if (!rel_file_path) | 25004 | if (!rel_file_path) |
| 24105 | return ira->codegen->invalid_instruction; | 25005 | return ira->codegen->invalid_inst_gen; |
| 24106 | | 25006 | |
| 24107 | ZigType *import = get_scope_import(instruction->base.scope); | 25007 | ZigType *import = get_scope_import(instruction->base.base.scope); |
| 24108 | // figure out absolute path to resource | 25008 | // figure out absolute path to resource |
| 24109 | Buf source_dir_path = BUF_INIT; | 25009 | Buf source_dir_path = BUF_INIT; |
| 24110 | os_path_dirname(import->data.structure.root_struct->path, &source_dir_path); | 25010 | os_path_dirname(import->data.structure.root_struct->path, &source_dir_path); |
| ... | @@ -24121,93 +25021,95 @@ static IrInstruction *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstru | ... | @@ -24121,93 +25021,95 @@ static IrInstruction *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstru |
| 24121 | Error err; | 25021 | Error err; |
| 24122 | if ((err = file_fetch(ira->codegen, file_path, file_contents))) { | 25022 | if ((err = file_fetch(ira->codegen, file_path, file_contents))) { |
| 24123 | if (err == ErrorFileNotFound) { | 25023 | if (err == ErrorFileNotFound) { |
| 24124 | ir_add_error(ira, instruction->name, buf_sprintf("unable to find '%s'", buf_ptr(file_path))); | 25024 | ir_add_error(ira, &instruction->name->base, |
| 24125 | return ira->codegen->invalid_instruction; | 25025 | buf_sprintf("unable to find '%s'", buf_ptr(file_path))); |
| | 25026 | return ira->codegen->invalid_inst_gen; |
| 24126 | } else { | 25027 | } else { |
| 24127 | ir_add_error(ira, instruction->name, buf_sprintf("unable to open '%s': %s", buf_ptr(file_path), err_str(err))); | 25028 | ir_add_error(ira, &instruction->name->base, |
| 24128 | return ira->codegen->invalid_instruction; | 25029 | buf_sprintf("unable to open '%s': %s", buf_ptr(file_path), err_str(err))); |
| | 25030 | return ira->codegen->invalid_inst_gen; |
| 24129 | } | 25031 | } |
| 24130 | } | 25032 | } |
| 24131 | | 25033 | |
| 24132 | ZigType *result_type = get_array_type(ira->codegen, | 25034 | ZigType *result_type = get_array_type(ira->codegen, |
| 24133 | ira->codegen->builtin_types.entry_u8, buf_len(file_contents), nullptr); | 25035 | ira->codegen->builtin_types.entry_u8, buf_len(file_contents), nullptr); |
| 24134 | IrInstruction *result = ir_const(ira, &instruction->base, result_type); | 25036 | IrInstGen *result = ir_const(ira, &instruction->base.base, result_type); |
| 24135 | init_const_str_lit(ira->codegen, result->value, file_contents); | 25037 | init_const_str_lit(ira->codegen, result->value, file_contents); |
| 24136 | return result; | 25038 | return result; |
| 24137 | } | 25039 | } |
| 24138 | | 25040 | |
| 24139 | static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructionCmpxchgSrc *instruction) { | 25041 | static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxchg *instruction) { |
| 24140 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->type_value->child); | 25042 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->type_value->child); |
| 24141 | if (type_is_invalid(operand_type)) | 25043 | if (type_is_invalid(operand_type)) |
| 24142 | return ira->codegen->invalid_instruction; | 25044 | return ira->codegen->invalid_inst_gen; |
| 24143 | | 25045 | |
| 24144 | if (operand_type->id == ZigTypeIdFloat) { | 25046 | if (operand_type->id == ZigTypeIdFloat) { |
| 24145 | ir_add_error(ira, instruction->type_value->child, | 25047 | ir_add_error(ira, &instruction->type_value->child->base, |
| 24146 | buf_sprintf("expected integer, enum or pointer type, found '%s'", buf_ptr(&operand_type->name))); | 25048 | buf_sprintf("expected integer, enum or pointer type, found '%s'", buf_ptr(&operand_type->name))); |
| 24147 | return ira->codegen->invalid_instruction; | 25049 | return ira->codegen->invalid_inst_gen; |
| 24148 | } | 25050 | } |
| 24149 | | 25051 | |
| 24150 | IrInstruction *ptr = instruction->ptr->child; | 25052 | IrInstGen *ptr = instruction->ptr->child; |
| 24151 | if (type_is_invalid(ptr->value->type)) | 25053 | if (type_is_invalid(ptr->value->type)) |
| 24152 | return ira->codegen->invalid_instruction; | 25054 | return ira->codegen->invalid_inst_gen; |
| 24153 | | 25055 | |
| 24154 | // TODO let this be volatile | 25056 | // TODO let this be volatile |
| 24155 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); | 25057 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 24156 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr, ptr_type); | 25058 | IrInstGen *casted_ptr = ir_implicit_cast(ira, ptr, ptr_type); |
| 24157 | if (type_is_invalid(casted_ptr->value->type)) | 25059 | if (type_is_invalid(casted_ptr->value->type)) |
| 24158 | return ira->codegen->invalid_instruction; | 25060 | return ira->codegen->invalid_inst_gen; |
| 24159 | | 25061 | |
| 24160 | IrInstruction *cmp_value = instruction->cmp_value->child; | 25062 | IrInstGen *cmp_value = instruction->cmp_value->child; |
| 24161 | if (type_is_invalid(cmp_value->value->type)) | 25063 | if (type_is_invalid(cmp_value->value->type)) |
| 24162 | return ira->codegen->invalid_instruction; | 25064 | return ira->codegen->invalid_inst_gen; |
| 24163 | | 25065 | |
| 24164 | IrInstruction *new_value = instruction->new_value->child; | 25066 | IrInstGen *new_value = instruction->new_value->child; |
| 24165 | if (type_is_invalid(new_value->value->type)) | 25067 | if (type_is_invalid(new_value->value->type)) |
| 24166 | return ira->codegen->invalid_instruction; | 25068 | return ira->codegen->invalid_inst_gen; |
| 24167 | | 25069 | |
| 24168 | IrInstruction *success_order_value = instruction->success_order_value->child; | 25070 | IrInstGen *success_order_value = instruction->success_order_value->child; |
| 24169 | if (type_is_invalid(success_order_value->value->type)) | 25071 | if (type_is_invalid(success_order_value->value->type)) |
| 24170 | return ira->codegen->invalid_instruction; | 25072 | return ira->codegen->invalid_inst_gen; |
| 24171 | | 25073 | |
| 24172 | AtomicOrder success_order; | 25074 | AtomicOrder success_order; |
| 24173 | if (!ir_resolve_atomic_order(ira, success_order_value, &success_order)) | 25075 | if (!ir_resolve_atomic_order(ira, success_order_value, &success_order)) |
| 24174 | return ira->codegen->invalid_instruction; | 25076 | return ira->codegen->invalid_inst_gen; |
| 24175 | | 25077 | |
| 24176 | IrInstruction *failure_order_value = instruction->failure_order_value->child; | 25078 | IrInstGen *failure_order_value = instruction->failure_order_value->child; |
| 24177 | if (type_is_invalid(failure_order_value->value->type)) | 25079 | if (type_is_invalid(failure_order_value->value->type)) |
| 24178 | return ira->codegen->invalid_instruction; | 25080 | return ira->codegen->invalid_inst_gen; |
| 24179 | | 25081 | |
| 24180 | AtomicOrder failure_order; | 25082 | AtomicOrder failure_order; |
| 24181 | if (!ir_resolve_atomic_order(ira, failure_order_value, &failure_order)) | 25083 | if (!ir_resolve_atomic_order(ira, failure_order_value, &failure_order)) |
| 24182 | return ira->codegen->invalid_instruction; | 25084 | return ira->codegen->invalid_inst_gen; |
| 24183 | | 25085 | |
| 24184 | IrInstruction *casted_cmp_value = ir_implicit_cast(ira, cmp_value, operand_type); | 25086 | IrInstGen *casted_cmp_value = ir_implicit_cast(ira, cmp_value, operand_type); |
| 24185 | if (type_is_invalid(casted_cmp_value->value->type)) | 25087 | if (type_is_invalid(casted_cmp_value->value->type)) |
| 24186 | return ira->codegen->invalid_instruction; | 25088 | return ira->codegen->invalid_inst_gen; |
| 24187 | | 25089 | |
| 24188 | IrInstruction *casted_new_value = ir_implicit_cast(ira, new_value, operand_type); | 25090 | IrInstGen *casted_new_value = ir_implicit_cast(ira, new_value, operand_type); |
| 24189 | if (type_is_invalid(casted_new_value->value->type)) | 25091 | if (type_is_invalid(casted_new_value->value->type)) |
| 24190 | return ira->codegen->invalid_instruction; | 25092 | return ira->codegen->invalid_inst_gen; |
| 24191 | | 25093 | |
| 24192 | if (success_order < AtomicOrderMonotonic) { | 25094 | if (success_order < AtomicOrderMonotonic) { |
| 24193 | ir_add_error(ira, success_order_value, | 25095 | ir_add_error(ira, &success_order_value->base, |
| 24194 | buf_sprintf("success atomic ordering must be Monotonic or stricter")); | 25096 | buf_sprintf("success atomic ordering must be Monotonic or stricter")); |
| 24195 | return ira->codegen->invalid_instruction; | 25097 | return ira->codegen->invalid_inst_gen; |
| 24196 | } | 25098 | } |
| 24197 | if (failure_order < AtomicOrderMonotonic) { | 25099 | if (failure_order < AtomicOrderMonotonic) { |
| 24198 | ir_add_error(ira, failure_order_value, | 25100 | ir_add_error(ira, &failure_order_value->base, |
| 24199 | buf_sprintf("failure atomic ordering must be Monotonic or stricter")); | 25101 | buf_sprintf("failure atomic ordering must be Monotonic or stricter")); |
| 24200 | return ira->codegen->invalid_instruction; | 25102 | return ira->codegen->invalid_inst_gen; |
| 24201 | } | 25103 | } |
| 24202 | if (failure_order > success_order) { | 25104 | if (failure_order > success_order) { |
| 24203 | ir_add_error(ira, failure_order_value, | 25105 | ir_add_error(ira, &failure_order_value->base, |
| 24204 | buf_sprintf("failure atomic ordering must be no stricter than success")); | 25106 | buf_sprintf("failure atomic ordering must be no stricter than success")); |
| 24205 | return ira->codegen->invalid_instruction; | 25107 | return ira->codegen->invalid_inst_gen; |
| 24206 | } | 25108 | } |
| 24207 | if (failure_order == AtomicOrderRelease || failure_order == AtomicOrderAcqRel) { | 25109 | if (failure_order == AtomicOrderRelease || failure_order == AtomicOrderAcqRel) { |
| 24208 | ir_add_error(ira, failure_order_value, | 25110 | ir_add_error(ira, &failure_order_value->base, |
| 24209 | buf_sprintf("failure atomic ordering must not be Release or AcqRel")); | 25111 | buf_sprintf("failure atomic ordering must not be Release or AcqRel")); |
| 24210 | return ira->codegen->invalid_instruction; | 25112 | return ira->codegen->invalid_inst_gen; |
| 24211 | } | 25113 | } |
| 24212 | | 25114 | |
| 24213 | if (instr_is_comptime(casted_ptr) && casted_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar && | 25115 | if (instr_is_comptime(casted_ptr) && casted_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar && |
| ... | @@ -24216,66 +25118,63 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi | ... | @@ -24216,66 +25118,63 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi |
| 24216 | } | 25118 | } |
| 24217 | | 25119 | |
| 24218 | ZigType *result_type = get_optional_type(ira->codegen, operand_type); | 25120 | ZigType *result_type = get_optional_type(ira->codegen, operand_type); |
| 24219 | IrInstruction *result_loc; | 25121 | IrInstGen *result_loc; |
| 24220 | if (handle_is_ptr(result_type)) { | 25122 | if (handle_is_ptr(result_type)) { |
| 24221 | result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 25123 | result_loc = ir_resolve_result(ira, &instruction->base.base, instruction->result_loc, |
| 24222 | result_type, nullptr, true, false, true); | 25124 | result_type, nullptr, true, false, true); |
| 24223 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { | 25125 | if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) { |
| 24224 | return result_loc; | 25126 | return result_loc; |
| 24225 | } | 25127 | } |
| 24226 | } else { | 25128 | } else { |
| 24227 | result_loc = nullptr; | 25129 | result_loc = nullptr; |
| 24228 | } | 25130 | } |
| 24229 | | 25131 | |
| 24230 | return ir_build_cmpxchg_gen(ira, &instruction->base, result_type, | 25132 | return ir_build_cmpxchg_gen(ira, &instruction->base.base, result_type, |
| 24231 | casted_ptr, casted_cmp_value, casted_new_value, | 25133 | casted_ptr, casted_cmp_value, casted_new_value, |
| 24232 | success_order, failure_order, instruction->is_weak, result_loc); | 25134 | success_order, failure_order, instruction->is_weak, result_loc); |
| 24233 | } | 25135 | } |
| 24234 | | 25136 | |
| 24235 | static IrInstruction *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstructionFence *instruction) { | 25137 | static IrInstGen *ir_analyze_instruction_fence(IrAnalyze *ira, IrInstSrcFence *instruction) { |
| 24236 | IrInstruction *order_value = instruction->order_value->child; | 25138 | IrInstGen *order_inst = instruction->order->child; |
| 24237 | if (type_is_invalid(order_value->value->type)) | 25139 | if (type_is_invalid(order_inst->value->type)) |
| 24238 | return ira->codegen->invalid_instruction; | 25140 | return ira->codegen->invalid_inst_gen; |
| 24239 | | 25141 | |
| 24240 | AtomicOrder order; | 25142 | AtomicOrder order; |
| 24241 | if (!ir_resolve_atomic_order(ira, order_value, &order)) | 25143 | if (!ir_resolve_atomic_order(ira, order_inst, &order)) |
| 24242 | return ira->codegen->invalid_instruction; | 25144 | return ira->codegen->invalid_inst_gen; |
| 24243 | | 25145 | |
| 24244 | if (order < AtomicOrderAcquire) { | 25146 | if (order < AtomicOrderAcquire) { |
| 24245 | ir_add_error(ira, order_value, | 25147 | ir_add_error(ira, &order_inst->base, |
| 24246 | buf_sprintf("atomic ordering must be Acquire or stricter")); | 25148 | buf_sprintf("atomic ordering must be Acquire or stricter")); |
| 24247 | return ira->codegen->invalid_instruction; | 25149 | return ira->codegen->invalid_inst_gen; |
| 24248 | } | 25150 | } |
| 24249 | | 25151 | |
| 24250 | IrInstruction *result = ir_build_fence(&ira->new_irb, | 25152 | return ir_build_fence_gen(ira, &instruction->base.base, order); |
| 24251 | instruction->base.scope, instruction->base.source_node, order_value, order); | | |
| 24252 | result->value->type = ira->codegen->builtin_types.entry_void; | | |
| 24253 | return result; | | |
| 24254 | } | 25153 | } |
| 24255 | | 25154 | |
| 24256 | static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstructionTruncate *instruction) { | 25155 | static IrInstGen *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstSrcTruncate *instruction) { |
| 24257 | IrInstruction *dest_type_value = instruction->dest_type->child; | 25156 | IrInstGen *dest_type_value = instruction->dest_type->child; |
| 24258 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); | 25157 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); |
| 24259 | if (type_is_invalid(dest_type)) | 25158 | if (type_is_invalid(dest_type)) |
| 24260 | return ira->codegen->invalid_instruction; | 25159 | return ira->codegen->invalid_inst_gen; |
| 24261 | | 25160 | |
| 24262 | if (dest_type->id != ZigTypeIdInt && | 25161 | if (dest_type->id != ZigTypeIdInt && |
| 24263 | dest_type->id != ZigTypeIdComptimeInt) | 25162 | dest_type->id != ZigTypeIdComptimeInt) |
| 24264 | { | 25163 | { |
| 24265 | ir_add_error(ira, dest_type_value, buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); | 25164 | ir_add_error(ira, &dest_type_value->base, buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); |
| 24266 | return ira->codegen->invalid_instruction; | 25165 | return ira->codegen->invalid_inst_gen; |
| 24267 | } | 25166 | } |
| 24268 | | 25167 | |
| 24269 | IrInstruction *target = instruction->target->child; | 25168 | IrInstGen *target = instruction->target->child; |
| 24270 | ZigType *src_type = target->value->type; | 25169 | ZigType *src_type = target->value->type; |
| 24271 | if (type_is_invalid(src_type)) | 25170 | if (type_is_invalid(src_type)) |
| 24272 | return ira->codegen->invalid_instruction; | 25171 | return ira->codegen->invalid_inst_gen; |
| 24273 | | 25172 | |
| 24274 | if (src_type->id != ZigTypeIdInt && | 25173 | if (src_type->id != ZigTypeIdInt && |
| 24275 | src_type->id != ZigTypeIdComptimeInt) | 25174 | src_type->id != ZigTypeIdComptimeInt) |
| 24276 | { | 25175 | { |
| 24277 | ir_add_error(ira, target, buf_sprintf("expected integer type, found '%s'", buf_ptr(&src_type->name))); | 25176 | ir_add_error(ira, &target->base, buf_sprintf("expected integer type, found '%s'", buf_ptr(&src_type->name))); |
| 24278 | return ira->codegen->invalid_instruction; | 25177 | return ira->codegen->invalid_inst_gen; |
| 24279 | } | 25178 | } |
| 24280 | | 25179 | |
| 24281 | if (dest_type->id == ZigTypeIdComptimeInt) { | 25180 | if (dest_type->id == ZigTypeIdComptimeInt) { |
| ... | @@ -24285,54 +25184,51 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct | ... | @@ -24285,54 +25184,51 @@ static IrInstruction *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruct |
| 24285 | if (instr_is_comptime(target)) { | 25184 | if (instr_is_comptime(target)) { |
| 24286 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 25185 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 24287 | if (val == nullptr) | 25186 | if (val == nullptr) |
| 24288 | return ira->codegen->invalid_instruction; | 25187 | return ira->codegen->invalid_inst_gen; |
| 24289 | | 25188 | |
| 24290 | IrInstruction *result = ir_const(ira, &instruction->base, dest_type); | 25189 | IrInstGen *result = ir_const(ira, &instruction->base.base, dest_type); |
| 24291 | bigint_truncate(&result->value->data.x_bigint, &val->data.x_bigint, | 25190 | bigint_truncate(&result->value->data.x_bigint, &val->data.x_bigint, |
| 24292 | dest_type->data.integral.bit_count, dest_type->data.integral.is_signed); | 25191 | dest_type->data.integral.bit_count, dest_type->data.integral.is_signed); |
| 24293 | return result; | 25192 | return result; |
| 24294 | } | 25193 | } |
| 24295 | | 25194 | |
| 24296 | if (src_type->data.integral.bit_count == 0 || dest_type->data.integral.bit_count == 0) { | 25195 | if (src_type->data.integral.bit_count == 0 || dest_type->data.integral.bit_count == 0) { |
| 24297 | IrInstruction *result = ir_const(ira, &instruction->base, dest_type); | 25196 | IrInstGen *result = ir_const(ira, &instruction->base.base, dest_type); |
| 24298 | bigint_init_unsigned(&result->value->data.x_bigint, 0); | 25197 | bigint_init_unsigned(&result->value->data.x_bigint, 0); |
| 24299 | return result; | 25198 | return result; |
| 24300 | } | 25199 | } |
| 24301 | | 25200 | |
| 24302 | if (src_type->data.integral.is_signed != dest_type->data.integral.is_signed) { | 25201 | if (src_type->data.integral.is_signed != dest_type->data.integral.is_signed) { |
| 24303 | const char *sign_str = dest_type->data.integral.is_signed ? "signed" : "unsigned"; | 25202 | const char *sign_str = dest_type->data.integral.is_signed ? "signed" : "unsigned"; |
| 24304 | ir_add_error(ira, target, buf_sprintf("expected %s integer type, found '%s'", sign_str, buf_ptr(&src_type->name))); | 25203 | ir_add_error(ira, &target->base, buf_sprintf("expected %s integer type, found '%s'", sign_str, buf_ptr(&src_type->name))); |
| 24305 | return ira->codegen->invalid_instruction; | 25204 | return ira->codegen->invalid_inst_gen; |
| 24306 | } else if (src_type->data.integral.bit_count < dest_type->data.integral.bit_count) { | 25205 | } else if (src_type->data.integral.bit_count < dest_type->data.integral.bit_count) { |
| 24307 | ir_add_error(ira, target, buf_sprintf("type '%s' has fewer bits than destination type '%s'", | 25206 | ir_add_error(ira, &target->base, buf_sprintf("type '%s' has fewer bits than destination type '%s'", |
| 24308 | buf_ptr(&src_type->name), buf_ptr(&dest_type->name))); | 25207 | buf_ptr(&src_type->name), buf_ptr(&dest_type->name))); |
| 24309 | return ira->codegen->invalid_instruction; | 25208 | return ira->codegen->invalid_inst_gen; |
| 24310 | } | 25209 | } |
| 24311 | | 25210 | |
| 24312 | IrInstruction *new_instruction = ir_build_truncate(&ira->new_irb, instruction->base.scope, | 25211 | return ir_build_truncate_gen(ira, &instruction->base.base, dest_type, target); |
| 24313 | instruction->base.source_node, dest_type_value, target); | | |
| 24314 | new_instruction->value->type = dest_type; | | |
| 24315 | return new_instruction; | | |
| 24316 | } | 25212 | } |
| 24317 | | 25213 | |
| 24318 | static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstructionIntCast *instruction) { | 25214 | static IrInstGen *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstSrcIntCast *instruction) { |
| 24319 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); | 25215 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 24320 | if (type_is_invalid(dest_type)) | 25216 | if (type_is_invalid(dest_type)) |
| 24321 | return ira->codegen->invalid_instruction; | 25217 | return ira->codegen->invalid_inst_gen; |
| 24322 | | 25218 | |
| 24323 | if (dest_type->id != ZigTypeIdInt && dest_type->id != ZigTypeIdComptimeInt) { | 25219 | if (dest_type->id != ZigTypeIdInt && dest_type->id != ZigTypeIdComptimeInt) { |
| 24324 | ir_add_error(ira, instruction->dest_type, buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); | 25220 | ir_add_error(ira, &instruction->dest_type->base, buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); |
| 24325 | return ira->codegen->invalid_instruction; | 25221 | return ira->codegen->invalid_inst_gen; |
| 24326 | } | 25222 | } |
| 24327 | | 25223 | |
| 24328 | IrInstruction *target = instruction->target->child; | 25224 | IrInstGen *target = instruction->target->child; |
| 24329 | if (type_is_invalid(target->value->type)) | 25225 | if (type_is_invalid(target->value->type)) |
| 24330 | return ira->codegen->invalid_instruction; | 25226 | return ira->codegen->invalid_inst_gen; |
| 24331 | | 25227 | |
| 24332 | if (target->value->type->id != ZigTypeIdInt && target->value->type->id != ZigTypeIdComptimeInt) { | 25228 | if (target->value->type->id != ZigTypeIdInt && target->value->type->id != ZigTypeIdComptimeInt) { |
| 24333 | ir_add_error(ira, instruction->target, buf_sprintf("expected integer type, found '%s'", | 25229 | ir_add_error(ira, &instruction->target->base, buf_sprintf("expected integer type, found '%s'", |
| 24334 | buf_ptr(&target->value->type->name))); | 25230 | buf_ptr(&target->value->type->name))); |
| 24335 | return ira->codegen->invalid_instruction; | 25231 | return ira->codegen->invalid_inst_gen; |
| 24336 | } | 25232 | } |
| 24337 | | 25233 | |
| 24338 | if (instr_is_comptime(target)) { | 25234 | if (instr_is_comptime(target)) { |
| ... | @@ -24340,28 +25236,28 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct | ... | @@ -24340,28 +25236,28 @@ static IrInstruction *ir_analyze_instruction_int_cast(IrAnalyze *ira, IrInstruct |
| 24340 | } | 25236 | } |
| 24341 | | 25237 | |
| 24342 | if (dest_type->id == ZigTypeIdComptimeInt) { | 25238 | if (dest_type->id == ZigTypeIdComptimeInt) { |
| 24343 | ir_add_error(ira, instruction->target, buf_sprintf("attempt to cast runtime value to '%s'", | 25239 | ir_add_error(ira, &instruction->target->base, buf_sprintf("attempt to cast runtime value to '%s'", |
| 24344 | buf_ptr(&dest_type->name))); | 25240 | buf_ptr(&dest_type->name))); |
| 24345 | return ira->codegen->invalid_instruction; | 25241 | return ira->codegen->invalid_inst_gen; |
| 24346 | } | 25242 | } |
| 24347 | | 25243 | |
| 24348 | return ir_analyze_widen_or_shorten(ira, &instruction->base, target, dest_type); | 25244 | return ir_analyze_widen_or_shorten(ira, &instruction->base.base, target, dest_type); |
| 24349 | } | 25245 | } |
| 24350 | | 25246 | |
| 24351 | static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstructionFloatCast *instruction) { | 25247 | static IrInstGen *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstSrcFloatCast *instruction) { |
| 24352 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); | 25248 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 24353 | if (type_is_invalid(dest_type)) | 25249 | if (type_is_invalid(dest_type)) |
| 24354 | return ira->codegen->invalid_instruction; | 25250 | return ira->codegen->invalid_inst_gen; |
| 24355 | | 25251 | |
| 24356 | if (dest_type->id != ZigTypeIdFloat) { | 25252 | if (dest_type->id != ZigTypeIdFloat) { |
| 24357 | ir_add_error(ira, instruction->dest_type, | 25253 | ir_add_error(ira, &instruction->dest_type->base, |
| 24358 | buf_sprintf("expected float type, found '%s'", buf_ptr(&dest_type->name))); | 25254 | buf_sprintf("expected float type, found '%s'", buf_ptr(&dest_type->name))); |
| 24359 | return ira->codegen->invalid_instruction; | 25255 | return ira->codegen->invalid_inst_gen; |
| 24360 | } | 25256 | } |
| 24361 | | 25257 | |
| 24362 | IrInstruction *target = instruction->target->child; | 25258 | IrInstGen *target = instruction->target->child; |
| 24363 | if (type_is_invalid(target->value->type)) | 25259 | if (type_is_invalid(target->value->type)) |
| 24364 | return ira->codegen->invalid_instruction; | 25260 | return ira->codegen->invalid_inst_gen; |
| 24365 | | 25261 | |
| 24366 | if (target->value->type->id == ZigTypeIdComptimeInt || | 25262 | if (target->value->type->id == ZigTypeIdComptimeInt || |
| 24367 | target->value->type->id == ZigTypeIdComptimeFloat) | 25263 | target->value->type->id == ZigTypeIdComptimeFloat) |
| ... | @@ -24373,55 +25269,55 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru | ... | @@ -24373,55 +25269,55 @@ static IrInstruction *ir_analyze_instruction_float_cast(IrAnalyze *ira, IrInstru |
| 24373 | } else { | 25269 | } else { |
| 24374 | op = CastOpNumLitToConcrete; | 25270 | op = CastOpNumLitToConcrete; |
| 24375 | } | 25271 | } |
| 24376 | return ir_resolve_cast(ira, &instruction->base, target, dest_type, op); | 25272 | return ir_resolve_cast(ira, &instruction->base.base, target, dest_type, op); |
| 24377 | } else { | 25273 | } else { |
| 24378 | return ira->codegen->invalid_instruction; | 25274 | return ira->codegen->invalid_inst_gen; |
| 24379 | } | 25275 | } |
| 24380 | } | 25276 | } |
| 24381 | | 25277 | |
| 24382 | if (target->value->type->id != ZigTypeIdFloat) { | 25278 | if (target->value->type->id != ZigTypeIdFloat) { |
| 24383 | ir_add_error(ira, instruction->target, buf_sprintf("expected float type, found '%s'", | 25279 | ir_add_error(ira, &instruction->target->base, buf_sprintf("expected float type, found '%s'", |
| 24384 | buf_ptr(&target->value->type->name))); | 25280 | buf_ptr(&target->value->type->name))); |
| 24385 | return ira->codegen->invalid_instruction; | 25281 | return ira->codegen->invalid_inst_gen; |
| 24386 | } | 25282 | } |
| 24387 | | 25283 | |
| 24388 | return ir_analyze_widen_or_shorten(ira, &instruction->base, target, dest_type); | 25284 | return ir_analyze_widen_or_shorten(ira, &instruction->base.base, target, dest_type); |
| 24389 | } | 25285 | } |
| 24390 | | 25286 | |
| 24391 | static IrInstruction *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstructionErrSetCast *instruction) { | 25287 | static IrInstGen *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstSrcErrSetCast *instruction) { |
| 24392 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); | 25288 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 24393 | if (type_is_invalid(dest_type)) | 25289 | if (type_is_invalid(dest_type)) |
| 24394 | return ira->codegen->invalid_instruction; | 25290 | return ira->codegen->invalid_inst_gen; |
| 24395 | | 25291 | |
| 24396 | if (dest_type->id != ZigTypeIdErrorSet) { | 25292 | if (dest_type->id != ZigTypeIdErrorSet) { |
| 24397 | ir_add_error(ira, instruction->dest_type, | 25293 | ir_add_error(ira, &instruction->dest_type->base, |
| 24398 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&dest_type->name))); | 25294 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&dest_type->name))); |
| 24399 | return ira->codegen->invalid_instruction; | 25295 | return ira->codegen->invalid_inst_gen; |
| 24400 | } | 25296 | } |
| 24401 | | 25297 | |
| 24402 | IrInstruction *target = instruction->target->child; | 25298 | IrInstGen *target = instruction->target->child; |
| 24403 | if (type_is_invalid(target->value->type)) | 25299 | if (type_is_invalid(target->value->type)) |
| 24404 | return ira->codegen->invalid_instruction; | 25300 | return ira->codegen->invalid_inst_gen; |
| 24405 | | 25301 | |
| 24406 | if (target->value->type->id != ZigTypeIdErrorSet) { | 25302 | if (target->value->type->id != ZigTypeIdErrorSet) { |
| 24407 | ir_add_error(ira, instruction->target, | 25303 | ir_add_error(ira, &instruction->target->base, |
| 24408 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&target->value->type->name))); | 25304 | buf_sprintf("expected error set type, found '%s'", buf_ptr(&target->value->type->name))); |
| 24409 | return ira->codegen->invalid_instruction; | 25305 | return ira->codegen->invalid_inst_gen; |
| 24410 | } | 25306 | } |
| 24411 | | 25307 | |
| 24412 | return ir_analyze_err_set_cast(ira, &instruction->base, target, dest_type); | 25308 | return ir_analyze_err_set_cast(ira, &instruction->base.base, target, dest_type); |
| 24413 | } | 25309 | } |
| 24414 | | 25310 | |
| 24415 | static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstructionFromBytes *instruction) { | 25311 | static IrInstGen *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstSrcFromBytes *instruction) { |
| 24416 | Error err; | 25312 | Error err; |
| 24417 | | 25313 | |
| 24418 | ZigType *dest_child_type = ir_resolve_type(ira, instruction->dest_child_type->child); | 25314 | ZigType *dest_child_type = ir_resolve_type(ira, instruction->dest_child_type->child); |
| 24419 | if (type_is_invalid(dest_child_type)) | 25315 | if (type_is_invalid(dest_child_type)) |
| 24420 | return ira->codegen->invalid_instruction; | 25316 | return ira->codegen->invalid_inst_gen; |
| 24421 | | 25317 | |
| 24422 | IrInstruction *target = instruction->target->child; | 25318 | IrInstGen *target = instruction->target->child; |
| 24423 | if (type_is_invalid(target->value->type)) | 25319 | if (type_is_invalid(target->value->type)) |
| 24424 | return ira->codegen->invalid_instruction; | 25320 | return ira->codegen->invalid_inst_gen; |
| 24425 | | 25321 | |
| 24426 | bool src_ptr_const; | 25322 | bool src_ptr_const; |
| 24427 | bool src_ptr_volatile; | 25323 | bool src_ptr_volatile; |
| ... | @@ -24431,27 +25327,27 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -24431,27 +25327,27 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 24431 | src_ptr_volatile = target->value->type->data.pointer.is_volatile; | 25327 | src_ptr_volatile = target->value->type->data.pointer.is_volatile; |
| 24432 | | 25328 | |
| 24433 | if ((err = resolve_ptr_align(ira, target->value->type, &src_ptr_align))) | 25329 | if ((err = resolve_ptr_align(ira, target->value->type, &src_ptr_align))) |
| 24434 | return ira->codegen->invalid_instruction; | 25330 | return ira->codegen->invalid_inst_gen; |
| 24435 | } else if (is_slice(target->value->type)) { | 25331 | } else if (is_slice(target->value->type)) { |
| 24436 | ZigType *src_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry; | 25332 | ZigType *src_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry; |
| 24437 | src_ptr_const = src_ptr_type->data.pointer.is_const; | 25333 | src_ptr_const = src_ptr_type->data.pointer.is_const; |
| 24438 | src_ptr_volatile = src_ptr_type->data.pointer.is_volatile; | 25334 | src_ptr_volatile = src_ptr_type->data.pointer.is_volatile; |
| 24439 | | 25335 | |
| 24440 | if ((err = resolve_ptr_align(ira, src_ptr_type, &src_ptr_align))) | 25336 | if ((err = resolve_ptr_align(ira, src_ptr_type, &src_ptr_align))) |
| 24441 | return ira->codegen->invalid_instruction; | 25337 | return ira->codegen->invalid_inst_gen; |
| 24442 | } else { | 25338 | } else { |
| 24443 | src_ptr_const = true; | 25339 | src_ptr_const = true; |
| 24444 | src_ptr_volatile = false; | 25340 | src_ptr_volatile = false; |
| 24445 | | 25341 | |
| 24446 | if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusAlignmentKnown))) | 25342 | if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusAlignmentKnown))) |
| 24447 | return ira->codegen->invalid_instruction; | 25343 | return ira->codegen->invalid_inst_gen; |
| 24448 | | 25344 | |
| 24449 | src_ptr_align = get_abi_alignment(ira->codegen, target->value->type); | 25345 | src_ptr_align = get_abi_alignment(ira->codegen, target->value->type); |
| 24450 | } | 25346 | } |
| 24451 | | 25347 | |
| 24452 | if (src_ptr_align != 0) { | 25348 | if (src_ptr_align != 0) { |
| 24453 | if ((err = type_resolve(ira->codegen, dest_child_type, ResolveStatusAlignmentKnown))) | 25349 | if ((err = type_resolve(ira->codegen, dest_child_type, ResolveStatusAlignmentKnown))) |
| 24454 | return ira->codegen->invalid_instruction; | 25350 | return ira->codegen->invalid_inst_gen; |
| 24455 | } | 25351 | } |
| 24456 | | 25352 | |
| 24457 | ZigType *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_child_type, | 25353 | ZigType *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_child_type, |
| ... | @@ -24464,9 +25360,9 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -24464,9 +25360,9 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 24464 | src_ptr_align, 0, 0, false); | 25360 | src_ptr_align, 0, 0, false); |
| 24465 | ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr); | 25361 | ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr); |
| 24466 | | 25362 | |
| 24467 | IrInstruction *casted_value = ir_implicit_cast(ira, target, u8_slice); | 25363 | IrInstGen *casted_value = ir_implicit_cast(ira, target, u8_slice); |
| 24468 | if (type_is_invalid(casted_value->value->type)) | 25364 | if (type_is_invalid(casted_value->value->type)) |
| 24469 | return ira->codegen->invalid_instruction; | 25365 | return ira->codegen->invalid_inst_gen; |
| 24470 | | 25366 | |
| 24471 | bool have_known_len = false; | 25367 | bool have_known_len = false; |
| 24472 | uint64_t known_len; | 25368 | uint64_t known_len; |
| ... | @@ -24474,7 +25370,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -24474,7 +25370,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 24474 | if (instr_is_comptime(casted_value)) { | 25370 | if (instr_is_comptime(casted_value)) { |
| 24475 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); | 25371 | ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad); |
| 24476 | if (!val) | 25372 | if (!val) |
| 24477 | return ira->codegen->invalid_instruction; | 25373 | return ira->codegen->invalid_inst_gen; |
| 24478 | | 25374 | |
| 24479 | ZigValue *len_val = val->data.x_struct.fields[slice_len_index]; | 25375 | ZigValue *len_val = val->data.x_struct.fields[slice_len_index]; |
| 24480 | if (value_is_comptime(len_val)) { | 25376 | if (value_is_comptime(len_val)) { |
| ... | @@ -24483,9 +25379,9 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -24483,9 +25379,9 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 24483 | } | 25379 | } |
| 24484 | } | 25380 | } |
| 24485 | | 25381 | |
| 24486 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 25382 | IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base.base, instruction->result_loc, |
| 24487 | dest_slice_type, nullptr, true, false, true); | 25383 | dest_slice_type, nullptr, true, false, true); |
| 24488 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) { | 25384 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable)) { |
| 24489 | return result_loc; | 25385 | return result_loc; |
| 24490 | } | 25386 | } |
| 24491 | | 25387 | |
| ... | @@ -24502,41 +25398,41 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -24502,41 +25398,41 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 24502 | | 25398 | |
| 24503 | if (have_known_len) { | 25399 | if (have_known_len) { |
| 24504 | if ((err = type_resolve(ira->codegen, dest_child_type, ResolveStatusSizeKnown))) | 25400 | if ((err = type_resolve(ira->codegen, dest_child_type, ResolveStatusSizeKnown))) |
| 24505 | return ira->codegen->invalid_instruction; | 25401 | return ira->codegen->invalid_inst_gen; |
| 24506 | uint64_t child_type_size = type_size(ira->codegen, dest_child_type); | 25402 | uint64_t child_type_size = type_size(ira->codegen, dest_child_type); |
| 24507 | uint64_t remainder = known_len % child_type_size; | 25403 | uint64_t remainder = known_len % child_type_size; |
| 24508 | if (remainder != 0) { | 25404 | if (remainder != 0) { |
| 24509 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, | 25405 | ErrorMsg *msg = ir_add_error(ira, &instruction->base.base, |
| 24510 | buf_sprintf("unable to convert [%" ZIG_PRI_u64 "]u8 to %s: size mismatch", | 25406 | buf_sprintf("unable to convert [%" ZIG_PRI_u64 "]u8 to %s: size mismatch", |
| 24511 | known_len, buf_ptr(&dest_slice_type->name))); | 25407 | known_len, buf_ptr(&dest_slice_type->name))); |
| 24512 | add_error_note(ira->codegen, msg, instruction->dest_child_type->source_node, | 25408 | add_error_note(ira->codegen, msg, instruction->dest_child_type->base.source_node, |
| 24513 | buf_sprintf("%s has size %" ZIG_PRI_u64 "; remaining bytes: %" ZIG_PRI_u64, | 25409 | buf_sprintf("%s has size %" ZIG_PRI_u64 "; remaining bytes: %" ZIG_PRI_u64, |
| 24514 | buf_ptr(&dest_child_type->name), child_type_size, remainder)); | 25410 | buf_ptr(&dest_child_type->name), child_type_size, remainder)); |
| 24515 | return ira->codegen->invalid_instruction; | 25411 | return ira->codegen->invalid_inst_gen; |
| 24516 | } | 25412 | } |
| 24517 | } | 25413 | } |
| 24518 | | 25414 | |
| 24519 | return ir_build_resize_slice(ira, &instruction->base, casted_value, dest_slice_type, result_loc); | 25415 | return ir_build_resize_slice(ira, &instruction->base.base, casted_value, dest_slice_type, result_loc); |
| 24520 | } | 25416 | } |
| 24521 | | 25417 | |
| 24522 | static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstructionToBytes *instruction) { | 25418 | static IrInstGen *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstSrcToBytes *instruction) { |
| 24523 | Error err; | 25419 | Error err; |
| 24524 | | 25420 | |
| 24525 | IrInstruction *target = instruction->target->child; | 25421 | IrInstGen *target = instruction->target->child; |
| 24526 | if (type_is_invalid(target->value->type)) | 25422 | if (type_is_invalid(target->value->type)) |
| 24527 | return ira->codegen->invalid_instruction; | 25423 | return ira->codegen->invalid_inst_gen; |
| 24528 | | 25424 | |
| 24529 | if (!is_slice(target->value->type)) { | 25425 | if (!is_slice(target->value->type)) { |
| 24530 | ir_add_error(ira, instruction->target, | 25426 | ir_add_error(ira, &instruction->target->base, |
| 24531 | buf_sprintf("expected slice, found '%s'", buf_ptr(&target->value->type->name))); | 25427 | buf_sprintf("expected slice, found '%s'", buf_ptr(&target->value->type->name))); |
| 24532 | return ira->codegen->invalid_instruction; | 25428 | return ira->codegen->invalid_inst_gen; |
| 24533 | } | 25429 | } |
| 24534 | | 25430 | |
| 24535 | ZigType *src_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry; | 25431 | ZigType *src_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry; |
| 24536 | | 25432 | |
| 24537 | uint32_t alignment; | 25433 | uint32_t alignment; |
| 24538 | if ((err = resolve_ptr_align(ira, src_ptr_type, &alignment))) | 25434 | if ((err = resolve_ptr_align(ira, src_ptr_type, &alignment))) |
| 24539 | return ira->codegen->invalid_instruction; | 25435 | return ira->codegen->invalid_inst_gen; |
| 24540 | | 25436 | |
| 24541 | ZigType *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, | 25437 | ZigType *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 24542 | src_ptr_type->data.pointer.is_const, src_ptr_type->data.pointer.is_volatile, PtrLenUnknown, | 25438 | src_ptr_type->data.pointer.is_const, src_ptr_type->data.pointer.is_volatile, PtrLenUnknown, |
| ... | @@ -24546,9 +25442,9 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct | ... | @@ -24546,9 +25442,9 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct |
| 24546 | if (instr_is_comptime(target)) { | 25442 | if (instr_is_comptime(target)) { |
| 24547 | ZigValue *target_val = ir_resolve_const(ira, target, UndefBad); | 25443 | ZigValue *target_val = ir_resolve_const(ira, target, UndefBad); |
| 24548 | if (target_val == nullptr) | 25444 | if (target_val == nullptr) |
| 24549 | return ira->codegen->invalid_instruction; | 25445 | return ira->codegen->invalid_inst_gen; |
| 24550 | | 25446 | |
| 24551 | IrInstruction *result = ir_const(ira, &instruction->base, dest_slice_type); | 25447 | IrInstGen *result = ir_const(ira, &instruction->base.base, dest_slice_type); |
| 24552 | result->value->data.x_struct.fields = alloc_const_vals_ptrs(2); | 25448 | result->value->data.x_struct.fields = alloc_const_vals_ptrs(2); |
| 24553 | | 25449 | |
| 24554 | ZigValue *ptr_val = result->value->data.x_struct.fields[slice_ptr_index]; | 25450 | ZigValue *ptr_val = result->value->data.x_struct.fields[slice_ptr_index]; |
| ... | @@ -24568,13 +25464,13 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct | ... | @@ -24568,13 +25464,13 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct |
| 24568 | return result; | 25464 | return result; |
| 24569 | } | 25465 | } |
| 24570 | | 25466 | |
| 24571 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 25467 | IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base.base, instruction->result_loc, |
| 24572 | dest_slice_type, nullptr, true, false, true); | 25468 | dest_slice_type, nullptr, true, false, true); |
| 24573 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { | 25469 | if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) { |
| 24574 | return result_loc; | 25470 | return result_loc; |
| 24575 | } | 25471 | } |
| 24576 | | 25472 | |
| 24577 | return ir_build_resize_slice(ira, &instruction->base, target, dest_slice_type, result_loc); | 25473 | return ir_build_resize_slice(ira, &instruction->base.base, target, dest_slice_type, result_loc); |
| 24578 | } | 25474 | } |
| 24579 | | 25475 | |
| 24580 | static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_align) { | 25476 | static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_align) { |
| ... | @@ -24591,26 +25487,26 @@ static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_ali | ... | @@ -24591,26 +25487,26 @@ static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_ali |
| 24591 | return ErrorNone; | 25487 | return ErrorNone; |
| 24592 | } | 25488 | } |
| 24593 | | 25489 | |
| 24594 | static IrInstruction *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstructionIntToFloat *instruction) { | 25490 | static IrInstGen *ir_analyze_instruction_int_to_float(IrAnalyze *ira, IrInstSrcIntToFloat *instruction) { |
| 24595 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); | 25491 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 24596 | if (type_is_invalid(dest_type)) | 25492 | if (type_is_invalid(dest_type)) |
| 24597 | return ira->codegen->invalid_instruction; | 25493 | return ira->codegen->invalid_inst_gen; |
| 24598 | | 25494 | |
| 24599 | IrInstruction *target = instruction->target->child; | 25495 | IrInstGen *target = instruction->target->child; |
| 24600 | if (type_is_invalid(target->value->type)) | 25496 | if (type_is_invalid(target->value->type)) |
| 24601 | return ira->codegen->invalid_instruction; | 25497 | return ira->codegen->invalid_inst_gen; |
| 24602 | | 25498 | |
| 24603 | if (target->value->type->id != ZigTypeIdInt && target->value->type->id != ZigTypeIdComptimeInt) { | 25499 | if (target->value->type->id != ZigTypeIdInt && target->value->type->id != ZigTypeIdComptimeInt) { |
| 24604 | ir_add_error(ira, instruction->target, buf_sprintf("expected int type, found '%s'", | 25500 | ir_add_error(ira, &instruction->target->base, buf_sprintf("expected int type, found '%s'", |
| 24605 | buf_ptr(&target->value->type->name))); | 25501 | buf_ptr(&target->value->type->name))); |
| 24606 | return ira->codegen->invalid_instruction; | 25502 | return ira->codegen->invalid_inst_gen; |
| 24607 | } | 25503 | } |
| 24608 | | 25504 | |
| 24609 | return ir_resolve_cast(ira, &instruction->base, target, dest_type, CastOpIntToFloat); | 25505 | return ir_resolve_cast(ira, &instruction->base.base, target, dest_type, CastOpIntToFloat); |
| 24610 | } | 25506 | } |
| 24611 | | 25507 | |
| 24612 | static IrInstruction *ir_analyze_float_to_int(IrAnalyze *ira, IrInstruction *source_instr, | 25508 | static IrInstGen *ir_analyze_float_to_int(IrAnalyze *ira, IrInst* source_instr, |
| 24613 | ZigType *dest_type, IrInstruction *operand, AstNode *operand_source_node) | 25509 | ZigType *dest_type, IrInstGen *operand, AstNode *operand_source_node) |
| 24614 | { | 25510 | { |
| 24615 | if (operand->value->type->id == ZigTypeIdComptimeInt) { | 25511 | if (operand->value->type->id == ZigTypeIdComptimeInt) { |
| 24616 | return ir_implicit_cast(ira, operand, dest_type); | 25512 | return ir_implicit_cast(ira, operand, dest_type); |
| ... | @@ -24619,106 +25515,107 @@ static IrInstruction *ir_analyze_float_to_int(IrAnalyze *ira, IrInstruction *sou | ... | @@ -24619,106 +25515,107 @@ static IrInstruction *ir_analyze_float_to_int(IrAnalyze *ira, IrInstruction *sou |
| 24619 | if (operand->value->type->id != ZigTypeIdFloat && operand->value->type->id != ZigTypeIdComptimeFloat) { | 25515 | if (operand->value->type->id != ZigTypeIdFloat && operand->value->type->id != ZigTypeIdComptimeFloat) { |
| 24620 | ir_add_error_node(ira, operand_source_node, buf_sprintf("expected float type, found '%s'", | 25516 | ir_add_error_node(ira, operand_source_node, buf_sprintf("expected float type, found '%s'", |
| 24621 | buf_ptr(&operand->value->type->name))); | 25517 | buf_ptr(&operand->value->type->name))); |
| 24622 | return ira->codegen->invalid_instruction; | 25518 | return ira->codegen->invalid_inst_gen; |
| 24623 | } | 25519 | } |
| 24624 | | 25520 | |
| 24625 | return ir_resolve_cast(ira, source_instr, operand, dest_type, CastOpFloatToInt); | 25521 | return ir_resolve_cast(ira, source_instr, operand, dest_type, CastOpFloatToInt); |
| 24626 | } | 25522 | } |
| 24627 | | 25523 | |
| 24628 | static IrInstruction *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstructionFloatToInt *instruction) { | 25524 | static IrInstGen *ir_analyze_instruction_float_to_int(IrAnalyze *ira, IrInstSrcFloatToInt *instruction) { |
| 24629 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); | 25525 | ZigType *dest_type = ir_resolve_type(ira, instruction->dest_type->child); |
| 24630 | if (type_is_invalid(dest_type)) | 25526 | if (type_is_invalid(dest_type)) |
| 24631 | return ira->codegen->invalid_instruction; | 25527 | return ira->codegen->invalid_inst_gen; |
| 24632 | | 25528 | |
| 24633 | IrInstruction *operand = instruction->target->child; | 25529 | IrInstGen *operand = instruction->target->child; |
| 24634 | if (type_is_invalid(operand->value->type)) | 25530 | if (type_is_invalid(operand->value->type)) |
| 24635 | return ira->codegen->invalid_instruction; | 25531 | return ira->codegen->invalid_inst_gen; |
| 24636 | | 25532 | |
| 24637 | return ir_analyze_float_to_int(ira, &instruction->base, dest_type, operand, instruction->target->source_node); | 25533 | return ir_analyze_float_to_int(ira, &instruction->base.base, dest_type, operand, |
| | 25534 | instruction->target->base.source_node); |
| 24638 | } | 25535 | } |
| 24639 | | 25536 | |
| 24640 | static IrInstruction *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstructionErrToInt *instruction) { | 25537 | static IrInstGen *ir_analyze_instruction_err_to_int(IrAnalyze *ira, IrInstSrcErrToInt *instruction) { |
| 24641 | IrInstruction *target = instruction->target->child; | 25538 | IrInstGen *target = instruction->target->child; |
| 24642 | if (type_is_invalid(target->value->type)) | 25539 | if (type_is_invalid(target->value->type)) |
| 24643 | return ira->codegen->invalid_instruction; | 25540 | return ira->codegen->invalid_inst_gen; |
| 24644 | | 25541 | |
| 24645 | IrInstruction *casted_target; | 25542 | IrInstGen *casted_target; |
| 24646 | if (target->value->type->id == ZigTypeIdErrorSet) { | 25543 | if (target->value->type->id == ZigTypeIdErrorSet) { |
| 24647 | casted_target = target; | 25544 | casted_target = target; |
| 24648 | } else { | 25545 | } else { |
| 24649 | casted_target = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_global_error_set); | 25546 | casted_target = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_global_error_set); |
| 24650 | if (type_is_invalid(casted_target->value->type)) | 25547 | if (type_is_invalid(casted_target->value->type)) |
| 24651 | return ira->codegen->invalid_instruction; | 25548 | return ira->codegen->invalid_inst_gen; |
| 24652 | } | 25549 | } |
| 24653 | | 25550 | |
| 24654 | return ir_analyze_err_to_int(ira, &instruction->base, casted_target, ira->codegen->err_tag_type); | 25551 | return ir_analyze_err_to_int(ira, &instruction->base.base, casted_target, ira->codegen->err_tag_type); |
| 24655 | } | 25552 | } |
| 24656 | | 25553 | |
| 24657 | static IrInstruction *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstructionIntToErr *instruction) { | 25554 | static IrInstGen *ir_analyze_instruction_int_to_err(IrAnalyze *ira, IrInstSrcIntToErr *instruction) { |
| 24658 | IrInstruction *target = instruction->target->child; | 25555 | IrInstGen *target = instruction->target->child; |
| 24659 | if (type_is_invalid(target->value->type)) | 25556 | if (type_is_invalid(target->value->type)) |
| 24660 | return ira->codegen->invalid_instruction; | 25557 | return ira->codegen->invalid_inst_gen; |
| 24661 | | 25558 | |
| 24662 | IrInstruction *casted_target = ir_implicit_cast(ira, target, ira->codegen->err_tag_type); | 25559 | IrInstGen *casted_target = ir_implicit_cast(ira, target, ira->codegen->err_tag_type); |
| 24663 | if (type_is_invalid(casted_target->value->type)) | 25560 | if (type_is_invalid(casted_target->value->type)) |
| 24664 | return ira->codegen->invalid_instruction; | 25561 | return ira->codegen->invalid_inst_gen; |
| 24665 | | 25562 | |
| 24666 | return ir_analyze_int_to_err(ira, &instruction->base, casted_target, ira->codegen->builtin_types.entry_global_error_set); | 25563 | return ir_analyze_int_to_err(ira, &instruction->base.base, casted_target, ira->codegen->builtin_types.entry_global_error_set); |
| 24667 | } | 25564 | } |
| 24668 | | 25565 | |
| 24669 | static IrInstruction *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstructionBoolToInt *instruction) { | 25566 | static IrInstGen *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstSrcBoolToInt *instruction) { |
| 24670 | IrInstruction *target = instruction->target->child; | 25567 | IrInstGen *target = instruction->target->child; |
| 24671 | if (type_is_invalid(target->value->type)) | 25568 | if (type_is_invalid(target->value->type)) |
| 24672 | return ira->codegen->invalid_instruction; | 25569 | return ira->codegen->invalid_inst_gen; |
| 24673 | | 25570 | |
| 24674 | if (target->value->type->id != ZigTypeIdBool) { | 25571 | if (target->value->type->id != ZigTypeIdBool) { |
| 24675 | ir_add_error(ira, instruction->target, buf_sprintf("expected bool, found '%s'", | 25572 | ir_add_error(ira, &instruction->target->base, buf_sprintf("expected bool, found '%s'", |
| 24676 | buf_ptr(&target->value->type->name))); | 25573 | buf_ptr(&target->value->type->name))); |
| 24677 | return ira->codegen->invalid_instruction; | 25574 | return ira->codegen->invalid_inst_gen; |
| 24678 | } | 25575 | } |
| 24679 | | 25576 | |
| 24680 | if (instr_is_comptime(target)) { | 25577 | if (instr_is_comptime(target)) { |
| 24681 | bool is_true; | 25578 | bool is_true; |
| 24682 | if (!ir_resolve_bool(ira, target, &is_true)) | 25579 | if (!ir_resolve_bool(ira, target, &is_true)) |
| 24683 | return ira->codegen->invalid_instruction; | 25580 | return ira->codegen->invalid_inst_gen; |
| 24684 | | 25581 | |
| 24685 | return ir_const_unsigned(ira, &instruction->base, is_true ? 1 : 0); | 25582 | return ir_const_unsigned(ira, &instruction->base.base, is_true ? 1 : 0); |
| 24686 | } | 25583 | } |
| 24687 | | 25584 | |
| 24688 | ZigType *u1_type = get_int_type(ira->codegen, false, 1); | 25585 | ZigType *u1_type = get_int_type(ira->codegen, false, 1); |
| 24689 | return ir_resolve_cast(ira, &instruction->base, target, u1_type, CastOpBoolToInt); | 25586 | return ir_resolve_cast(ira, &instruction->base.base, target, u1_type, CastOpBoolToInt); |
| 24690 | } | 25587 | } |
| 24691 | | 25588 | |
| 24692 | static IrInstruction *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstructionIntType *instruction) { | 25589 | static IrInstGen *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstSrcIntType *instruction) { |
| 24693 | IrInstruction *is_signed_value = instruction->is_signed->child; | 25590 | IrInstGen *is_signed_value = instruction->is_signed->child; |
| 24694 | bool is_signed; | 25591 | bool is_signed; |
| 24695 | if (!ir_resolve_bool(ira, is_signed_value, &is_signed)) | 25592 | if (!ir_resolve_bool(ira, is_signed_value, &is_signed)) |
| 24696 | return ira->codegen->invalid_instruction; | 25593 | return ira->codegen->invalid_inst_gen; |
| 24697 | | 25594 | |
| 24698 | IrInstruction *bit_count_value = instruction->bit_count->child; | 25595 | IrInstGen *bit_count_value = instruction->bit_count->child; |
| 24699 | uint64_t bit_count; | 25596 | uint64_t bit_count; |
| 24700 | if (!ir_resolve_unsigned(ira, bit_count_value, ira->codegen->builtin_types.entry_u16, &bit_count)) | 25597 | if (!ir_resolve_unsigned(ira, bit_count_value, ira->codegen->builtin_types.entry_u16, &bit_count)) |
| 24701 | return ira->codegen->invalid_instruction; | 25598 | return ira->codegen->invalid_inst_gen; |
| 24702 | | 25599 | |
| 24703 | return ir_const_type(ira, &instruction->base, get_int_type(ira->codegen, is_signed, (uint32_t)bit_count)); | 25600 | return ir_const_type(ira, &instruction->base.base, get_int_type(ira->codegen, is_signed, (uint32_t)bit_count)); |
| 24704 | } | 25601 | } |
| 24705 | | 25602 | |
| 24706 | static IrInstruction *ir_analyze_instruction_vector_type(IrAnalyze *ira, IrInstructionVectorType *instruction) { | 25603 | static IrInstGen *ir_analyze_instruction_vector_type(IrAnalyze *ira, IrInstSrcVectorType *instruction) { |
| 24707 | uint64_t len; | 25604 | uint64_t len; |
| 24708 | if (!ir_resolve_unsigned(ira, instruction->len->child, ira->codegen->builtin_types.entry_u32, &len)) | 25605 | if (!ir_resolve_unsigned(ira, instruction->len->child, ira->codegen->builtin_types.entry_u32, &len)) |
| 24709 | return ira->codegen->invalid_instruction; | 25606 | return ira->codegen->invalid_inst_gen; |
| 24710 | | 25607 | |
| 24711 | ZigType *elem_type = ir_resolve_vector_elem_type(ira, instruction->elem_type->child); | 25608 | ZigType *elem_type = ir_resolve_vector_elem_type(ira, instruction->elem_type->child); |
| 24712 | if (type_is_invalid(elem_type)) | 25609 | if (type_is_invalid(elem_type)) |
| 24713 | return ira->codegen->invalid_instruction; | 25610 | return ira->codegen->invalid_inst_gen; |
| 24714 | | 25611 | |
| 24715 | ZigType *vector_type = get_vector_type(ira->codegen, len, elem_type); | 25612 | ZigType *vector_type = get_vector_type(ira->codegen, len, elem_type); |
| 24716 | | 25613 | |
| 24717 | return ir_const_type(ira, &instruction->base, vector_type); | 25614 | return ir_const_type(ira, &instruction->base.base, vector_type); |
| 24718 | } | 25615 | } |
| 24719 | | 25616 | |
| 24720 | static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *source_instr, | 25617 | static IrInstGen *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInst* source_instr, |
| 24721 | ZigType *scalar_type, IrInstruction *a, IrInstruction *b, IrInstruction *mask) | 25618 | ZigType *scalar_type, IrInstGen *a, IrInstGen *b, IrInstGen *mask) |
| 24722 | { | 25619 | { |
| 24723 | ir_assert(source_instr && scalar_type && a && b && mask, source_instr); | 25620 | ir_assert(source_instr && scalar_type && a && b && mask, source_instr); |
| 24724 | ir_assert(is_valid_vector_elem_type(scalar_type), source_instr); | 25621 | ir_assert(is_valid_vector_elem_type(scalar_type), source_instr); |
| ... | @@ -24729,15 +25626,15 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24729,15 +25626,15 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24729 | } else if (mask->value->type->id == ZigTypeIdArray) { | 25626 | } else if (mask->value->type->id == ZigTypeIdArray) { |
| 24730 | len_mask = mask->value->type->data.array.len; | 25627 | len_mask = mask->value->type->data.array.len; |
| 24731 | } else { | 25628 | } else { |
| 24732 | ir_add_error(ira, mask, | 25629 | ir_add_error(ira, &mask->base, |
| 24733 | buf_sprintf("expected vector or array, found '%s'", | 25630 | buf_sprintf("expected vector or array, found '%s'", |
| 24734 | buf_ptr(&mask->value->type->name))); | 25631 | buf_ptr(&mask->value->type->name))); |
| 24735 | return ira->codegen->invalid_instruction; | 25632 | return ira->codegen->invalid_inst_gen; |
| 24736 | } | 25633 | } |
| 24737 | mask = ir_implicit_cast(ira, mask, get_vector_type(ira->codegen, len_mask, | 25634 | mask = ir_implicit_cast(ira, mask, get_vector_type(ira->codegen, len_mask, |
| 24738 | ira->codegen->builtin_types.entry_i32)); | 25635 | ira->codegen->builtin_types.entry_i32)); |
| 24739 | if (type_is_invalid(mask->value->type)) | 25636 | if (type_is_invalid(mask->value->type)) |
| 24740 | return ira->codegen->invalid_instruction; | 25637 | return ira->codegen->invalid_inst_gen; |
| 24741 | | 25638 | |
| 24742 | uint32_t len_a; | 25639 | uint32_t len_a; |
| 24743 | if (a->value->type->id == ZigTypeIdVector) { | 25640 | if (a->value->type->id == ZigTypeIdVector) { |
| ... | @@ -24747,11 +25644,11 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24747,11 +25644,11 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24747 | } else if (a->value->type->id == ZigTypeIdUndefined) { | 25644 | } else if (a->value->type->id == ZigTypeIdUndefined) { |
| 24748 | len_a = UINT32_MAX; | 25645 | len_a = UINT32_MAX; |
| 24749 | } else { | 25646 | } else { |
| 24750 | ir_add_error(ira, a, | 25647 | ir_add_error(ira, &a->base, |
| 24751 | buf_sprintf("expected vector or array with element type '%s', found '%s'", | 25648 | buf_sprintf("expected vector or array with element type '%s', found '%s'", |
| 24752 | buf_ptr(&scalar_type->name), | 25649 | buf_ptr(&scalar_type->name), |
| 24753 | buf_ptr(&a->value->type->name))); | 25650 | buf_ptr(&a->value->type->name))); |
| 24754 | return ira->codegen->invalid_instruction; | 25651 | return ira->codegen->invalid_inst_gen; |
| 24755 | } | 25652 | } |
| 24756 | | 25653 | |
| 24757 | uint32_t len_b; | 25654 | uint32_t len_b; |
| ... | @@ -24762,38 +25659,38 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24762,38 +25659,38 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24762 | } else if (b->value->type->id == ZigTypeIdUndefined) { | 25659 | } else if (b->value->type->id == ZigTypeIdUndefined) { |
| 24763 | len_b = UINT32_MAX; | 25660 | len_b = UINT32_MAX; |
| 24764 | } else { | 25661 | } else { |
| 24765 | ir_add_error(ira, b, | 25662 | ir_add_error(ira, &b->base, |
| 24766 | buf_sprintf("expected vector or array with element type '%s', found '%s'", | 25663 | buf_sprintf("expected vector or array with element type '%s', found '%s'", |
| 24767 | buf_ptr(&scalar_type->name), | 25664 | buf_ptr(&scalar_type->name), |
| 24768 | buf_ptr(&b->value->type->name))); | 25665 | buf_ptr(&b->value->type->name))); |
| 24769 | return ira->codegen->invalid_instruction; | 25666 | return ira->codegen->invalid_inst_gen; |
| 24770 | } | 25667 | } |
| 24771 | | 25668 | |
| 24772 | if (len_a == UINT32_MAX && len_b == UINT32_MAX) { | 25669 | if (len_a == UINT32_MAX && len_b == UINT32_MAX) { |
| 24773 | return ir_const_undef(ira, a, get_vector_type(ira->codegen, len_mask, scalar_type)); | 25670 | return ir_const_undef(ira, &a->base, get_vector_type(ira->codegen, len_mask, scalar_type)); |
| 24774 | } | 25671 | } |
| 24775 | | 25672 | |
| 24776 | if (len_a == UINT32_MAX) { | 25673 | if (len_a == UINT32_MAX) { |
| 24777 | len_a = len_b; | 25674 | len_a = len_b; |
| 24778 | a = ir_const_undef(ira, a, get_vector_type(ira->codegen, len_a, scalar_type)); | 25675 | a = ir_const_undef(ira, &a->base, get_vector_type(ira->codegen, len_a, scalar_type)); |
| 24779 | } else { | 25676 | } else { |
| 24780 | a = ir_implicit_cast(ira, a, get_vector_type(ira->codegen, len_a, scalar_type)); | 25677 | a = ir_implicit_cast(ira, a, get_vector_type(ira->codegen, len_a, scalar_type)); |
| 24781 | if (type_is_invalid(a->value->type)) | 25678 | if (type_is_invalid(a->value->type)) |
| 24782 | return ira->codegen->invalid_instruction; | 25679 | return ira->codegen->invalid_inst_gen; |
| 24783 | } | 25680 | } |
| 24784 | | 25681 | |
| 24785 | if (len_b == UINT32_MAX) { | 25682 | if (len_b == UINT32_MAX) { |
| 24786 | len_b = len_a; | 25683 | len_b = len_a; |
| 24787 | b = ir_const_undef(ira, b, get_vector_type(ira->codegen, len_b, scalar_type)); | 25684 | b = ir_const_undef(ira, &b->base, get_vector_type(ira->codegen, len_b, scalar_type)); |
| 24788 | } else { | 25685 | } else { |
| 24789 | b = ir_implicit_cast(ira, b, get_vector_type(ira->codegen, len_b, scalar_type)); | 25686 | b = ir_implicit_cast(ira, b, get_vector_type(ira->codegen, len_b, scalar_type)); |
| 24790 | if (type_is_invalid(b->value->type)) | 25687 | if (type_is_invalid(b->value->type)) |
| 24791 | return ira->codegen->invalid_instruction; | 25688 | return ira->codegen->invalid_inst_gen; |
| 24792 | } | 25689 | } |
| 24793 | | 25690 | |
| 24794 | ZigValue *mask_val = ir_resolve_const(ira, mask, UndefOk); | 25691 | ZigValue *mask_val = ir_resolve_const(ira, mask, UndefOk); |
| 24795 | if (mask_val == nullptr) | 25692 | if (mask_val == nullptr) |
| 24796 | return ira->codegen->invalid_instruction; | 25693 | return ira->codegen->invalid_inst_gen; |
| 24797 | | 25694 | |
| 24798 | expand_undef_array(ira->codegen, mask_val); | 25695 | expand_undef_array(ira->codegen, mask_val); |
| 24799 | | 25696 | |
| ... | @@ -24803,7 +25700,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24803,7 +25700,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24803 | continue; | 25700 | continue; |
| 24804 | int32_t v_i32 = bigint_as_signed(&mask_elem_val->data.x_bigint); | 25701 | int32_t v_i32 = bigint_as_signed(&mask_elem_val->data.x_bigint); |
| 24805 | uint32_t v; | 25702 | uint32_t v; |
| 24806 | IrInstruction *chosen_operand; | 25703 | IrInstGen *chosen_operand; |
| 24807 | if (v_i32 >= 0) { | 25704 | if (v_i32 >= 0) { |
| 24808 | v = (uint32_t)v_i32; | 25705 | v = (uint32_t)v_i32; |
| 24809 | chosen_operand = a; | 25706 | chosen_operand = a; |
| ... | @@ -24812,16 +25709,16 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24812,16 +25709,16 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24812 | chosen_operand = b; | 25709 | chosen_operand = b; |
| 24813 | } | 25710 | } |
| 24814 | if (v >= chosen_operand->value->type->data.vector.len) { | 25711 | if (v >= chosen_operand->value->type->data.vector.len) { |
| 24815 | ErrorMsg *msg = ir_add_error(ira, mask, | 25712 | ErrorMsg *msg = ir_add_error(ira, &mask->base, |
| 24816 | buf_sprintf("mask index '%u' has out-of-bounds selection", i)); | 25713 | buf_sprintf("mask index '%u' has out-of-bounds selection", i)); |
| 24817 | add_error_note(ira->codegen, msg, chosen_operand->source_node, | 25714 | add_error_note(ira->codegen, msg, chosen_operand->base.source_node, |
| 24818 | buf_sprintf("selected index '%u' out of bounds of %s", v, | 25715 | buf_sprintf("selected index '%u' out of bounds of %s", v, |
| 24819 | buf_ptr(&chosen_operand->value->type->name))); | 25716 | buf_ptr(&chosen_operand->value->type->name))); |
| 24820 | if (chosen_operand == a && v < len_a + len_b) { | 25717 | if (chosen_operand == a && v < len_a + len_b) { |
| 24821 | add_error_note(ira->codegen, msg, b->source_node, | 25718 | add_error_note(ira->codegen, msg, b->base.source_node, |
| 24822 | buf_create_from_str("selections from the second vector are specified with negative numbers")); | 25719 | buf_create_from_str("selections from the second vector are specified with negative numbers")); |
| 24823 | } | 25720 | } |
| 24824 | return ira->codegen->invalid_instruction; | 25721 | return ira->codegen->invalid_inst_gen; |
| 24825 | } | 25722 | } |
| 24826 | } | 25723 | } |
| 24827 | | 25724 | |
| ... | @@ -24829,16 +25726,16 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24829,16 +25726,16 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24829 | if (instr_is_comptime(a) && instr_is_comptime(b)) { | 25726 | if (instr_is_comptime(a) && instr_is_comptime(b)) { |
| 24830 | ZigValue *a_val = ir_resolve_const(ira, a, UndefOk); | 25727 | ZigValue *a_val = ir_resolve_const(ira, a, UndefOk); |
| 24831 | if (a_val == nullptr) | 25728 | if (a_val == nullptr) |
| 24832 | return ira->codegen->invalid_instruction; | 25729 | return ira->codegen->invalid_inst_gen; |
| 24833 | | 25730 | |
| 24834 | ZigValue *b_val = ir_resolve_const(ira, b, UndefOk); | 25731 | ZigValue *b_val = ir_resolve_const(ira, b, UndefOk); |
| 24835 | if (b_val == nullptr) | 25732 | if (b_val == nullptr) |
| 24836 | return ira->codegen->invalid_instruction; | 25733 | return ira->codegen->invalid_inst_gen; |
| 24837 | | 25734 | |
| 24838 | expand_undef_array(ira->codegen, a_val); | 25735 | expand_undef_array(ira->codegen, a_val); |
| 24839 | expand_undef_array(ira->codegen, b_val); | 25736 | expand_undef_array(ira->codegen, b_val); |
| 24840 | | 25737 | |
| 24841 | IrInstruction *result = ir_const(ira, source_instr, result_type); | 25738 | IrInstGen *result = ir_const(ira, source_instr, result_type); |
| 24842 | result->value->data.x_array.data.s_none.elements = create_const_vals(len_mask); | 25739 | result->value->data.x_array.data.s_none.elements = create_const_vals(len_mask); |
| 24843 | for (uint32_t i = 0; i < mask_val->type->data.vector.len; i += 1) { | 25740 | for (uint32_t i = 0; i < mask_val->type->data.vector.len; i += 1) { |
| 24844 | ZigValue *mask_elem_val = &mask_val->data.x_array.data.s_none.elements[i]; | 25741 | ZigValue *mask_elem_val = &mask_val->data.x_array.data.s_none.elements[i]; |
| ... | @@ -24870,7 +25767,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24870,7 +25767,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24870 | uint32_t len_min = min(len_a, len_b); | 25767 | uint32_t len_min = min(len_a, len_b); |
| 24871 | uint32_t len_max = max(len_a, len_b); | 25768 | uint32_t len_max = max(len_a, len_b); |
| 24872 | | 25769 | |
| 24873 | IrInstruction *expand_mask = ir_const(ira, mask, | 25770 | IrInstGen *expand_mask = ir_const(ira, &mask->base, |
| 24874 | get_vector_type(ira->codegen, len_max, ira->codegen->builtin_types.entry_i32)); | 25771 | get_vector_type(ira->codegen, len_max, ira->codegen->builtin_types.entry_i32)); |
| 24875 | expand_mask->value->data.x_array.data.s_none.elements = create_const_vals(len_max); | 25772 | expand_mask->value->data.x_array.data.s_none.elements = create_const_vals(len_max); |
| 24876 | uint32_t i = 0; | 25773 | uint32_t i = 0; |
| ... | @@ -24879,7 +25776,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24879,7 +25776,7 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24879 | for (; i < len_max; i += 1) | 25776 | for (; i < len_max; i += 1) |
| 24880 | bigint_init_signed(&expand_mask->value->data.x_array.data.s_none.elements[i].data.x_bigint, -1); | 25777 | bigint_init_signed(&expand_mask->value->data.x_array.data.s_none.elements[i].data.x_bigint, -1); |
| 24881 | | 25778 | |
| 24882 | IrInstruction *undef = ir_const_undef(ira, source_instr, | 25779 | IrInstGen *undef = ir_const_undef(ira, source_instr, |
| 24883 | get_vector_type(ira->codegen, len_min, scalar_type)); | 25780 | get_vector_type(ira->codegen, len_min, scalar_type)); |
| 24884 | | 25781 | |
| 24885 | if (len_b < len_a) { | 25782 | if (len_b < len_a) { |
| ... | @@ -24889,62 +25786,59 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s | ... | @@ -24889,62 +25786,59 @@ static IrInstruction *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInstruction *s |
| 24889 | } | 25786 | } |
| 24890 | } | 25787 | } |
| 24891 | | 25788 | |
| 24892 | IrInstruction *result = ir_build_shuffle_vector(&ira->new_irb, | 25789 | return ir_build_shuffle_vector_gen(ira, source_instr->scope, source_instr->source_node, |
| 24893 | source_instr->scope, source_instr->source_node, | 25790 | result_type, a, b, mask); |
| 24894 | nullptr, a, b, mask); | | |
| 24895 | result->value->type = result_type; | | |
| 24896 | return result; | | |
| 24897 | } | 25791 | } |
| 24898 | | 25792 | |
| 24899 | static IrInstruction *ir_analyze_instruction_shuffle_vector(IrAnalyze *ira, IrInstructionShuffleVector *instruction) { | 25793 | static IrInstGen *ir_analyze_instruction_shuffle_vector(IrAnalyze *ira, IrInstSrcShuffleVector *instruction) { |
| 24900 | ZigType *scalar_type = ir_resolve_vector_elem_type(ira, instruction->scalar_type); | 25794 | ZigType *scalar_type = ir_resolve_vector_elem_type(ira, instruction->scalar_type->child); |
| 24901 | if (type_is_invalid(scalar_type)) | 25795 | if (type_is_invalid(scalar_type)) |
| 24902 | return ira->codegen->invalid_instruction; | 25796 | return ira->codegen->invalid_inst_gen; |
| 24903 | | 25797 | |
| 24904 | IrInstruction *a = instruction->a->child; | 25798 | IrInstGen *a = instruction->a->child; |
| 24905 | if (type_is_invalid(a->value->type)) | 25799 | if (type_is_invalid(a->value->type)) |
| 24906 | return ira->codegen->invalid_instruction; | 25800 | return ira->codegen->invalid_inst_gen; |
| 24907 | | 25801 | |
| 24908 | IrInstruction *b = instruction->b->child; | 25802 | IrInstGen *b = instruction->b->child; |
| 24909 | if (type_is_invalid(b->value->type)) | 25803 | if (type_is_invalid(b->value->type)) |
| 24910 | return ira->codegen->invalid_instruction; | 25804 | return ira->codegen->invalid_inst_gen; |
| 24911 | | 25805 | |
| 24912 | IrInstruction *mask = instruction->mask->child; | 25806 | IrInstGen *mask = instruction->mask->child; |
| 24913 | if (type_is_invalid(mask->value->type)) | 25807 | if (type_is_invalid(mask->value->type)) |
| 24914 | return ira->codegen->invalid_instruction; | 25808 | return ira->codegen->invalid_inst_gen; |
| 24915 | | 25809 | |
| 24916 | return ir_analyze_shuffle_vector(ira, &instruction->base, scalar_type, a, b, mask); | 25810 | return ir_analyze_shuffle_vector(ira, &instruction->base.base, scalar_type, a, b, mask); |
| 24917 | } | 25811 | } |
| 24918 | | 25812 | |
| 24919 | static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstructionSplatSrc *instruction) { | 25813 | static IrInstGen *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstSrcSplat *instruction) { |
| 24920 | Error err; | 25814 | Error err; |
| 24921 | | 25815 | |
| 24922 | IrInstruction *len = instruction->len->child; | 25816 | IrInstGen *len = instruction->len->child; |
| 24923 | if (type_is_invalid(len->value->type)) | 25817 | if (type_is_invalid(len->value->type)) |
| 24924 | return ira->codegen->invalid_instruction; | 25818 | return ira->codegen->invalid_inst_gen; |
| 24925 | | 25819 | |
| 24926 | IrInstruction *scalar = instruction->scalar->child; | 25820 | IrInstGen *scalar = instruction->scalar->child; |
| 24927 | if (type_is_invalid(scalar->value->type)) | 25821 | if (type_is_invalid(scalar->value->type)) |
| 24928 | return ira->codegen->invalid_instruction; | 25822 | return ira->codegen->invalid_inst_gen; |
| 24929 | | 25823 | |
| 24930 | uint64_t len_u64; | 25824 | uint64_t len_u64; |
| 24931 | if (!ir_resolve_unsigned(ira, len, ira->codegen->builtin_types.entry_u32, &len_u64)) | 25825 | if (!ir_resolve_unsigned(ira, len, ira->codegen->builtin_types.entry_u32, &len_u64)) |
| 24932 | return ira->codegen->invalid_instruction; | 25826 | return ira->codegen->invalid_inst_gen; |
| 24933 | uint32_t len_int = len_u64; | 25827 | uint32_t len_int = len_u64; |
| 24934 | | 25828 | |
| 24935 | if ((err = ir_validate_vector_elem_type(ira, scalar, scalar->value->type))) | 25829 | if ((err = ir_validate_vector_elem_type(ira, scalar->base.source_node, scalar->value->type))) |
| 24936 | return ira->codegen->invalid_instruction; | 25830 | return ira->codegen->invalid_inst_gen; |
| 24937 | | 25831 | |
| 24938 | ZigType *return_type = get_vector_type(ira->codegen, len_int, scalar->value->type); | 25832 | ZigType *return_type = get_vector_type(ira->codegen, len_int, scalar->value->type); |
| 24939 | | 25833 | |
| 24940 | if (instr_is_comptime(scalar)) { | 25834 | if (instr_is_comptime(scalar)) { |
| 24941 | ZigValue *scalar_val = ir_resolve_const(ira, scalar, UndefOk); | 25835 | ZigValue *scalar_val = ir_resolve_const(ira, scalar, UndefOk); |
| 24942 | if (scalar_val == nullptr) | 25836 | if (scalar_val == nullptr) |
| 24943 | return ira->codegen->invalid_instruction; | 25837 | return ira->codegen->invalid_inst_gen; |
| 24944 | if (scalar_val->special == ConstValSpecialUndef) | 25838 | if (scalar_val->special == ConstValSpecialUndef) |
| 24945 | return ir_const_undef(ira, &instruction->base, return_type); | 25839 | return ir_const_undef(ira, &instruction->base.base, return_type); |
| 24946 | | 25840 | |
| 24947 | IrInstruction *result = ir_const(ira, &instruction->base, return_type); | 25841 | IrInstGen *result = ir_const(ira, &instruction->base.base, return_type); |
| 24948 | result->value->data.x_array.data.s_none.elements = create_const_vals(len_int); | 25842 | result->value->data.x_array.data.s_none.elements = create_const_vals(len_int); |
| 24949 | for (uint32_t i = 0; i < len_int; i += 1) { | 25843 | for (uint32_t i = 0; i < len_int; i += 1) { |
| 24950 | copy_const_val(&result->value->data.x_array.data.s_none.elements[i], scalar_val); | 25844 | copy_const_val(&result->value->data.x_array.data.s_none.elements[i], scalar_val); |
| ... | @@ -24952,48 +25846,45 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction | ... | @@ -24952,48 +25846,45 @@ static IrInstruction *ir_analyze_instruction_splat(IrAnalyze *ira, IrInstruction |
| 24952 | return result; | 25846 | return result; |
| 24953 | } | 25847 | } |
| 24954 | | 25848 | |
| 24955 | return ir_build_splat_gen(ira, &instruction->base, return_type, scalar); | 25849 | return ir_build_splat_gen(ira, &instruction->base.base, return_type, scalar); |
| 24956 | } | 25850 | } |
| 24957 | | 25851 | |
| 24958 | static IrInstruction *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstructionBoolNot *instruction) { | 25852 | static IrInstGen *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstSrcBoolNot *instruction) { |
| 24959 | IrInstruction *value = instruction->value->child; | 25853 | IrInstGen *value = instruction->value->child; |
| 24960 | if (type_is_invalid(value->value->type)) | 25854 | if (type_is_invalid(value->value->type)) |
| 24961 | return ira->codegen->invalid_instruction; | 25855 | return ira->codegen->invalid_inst_gen; |
| 24962 | | 25856 | |
| 24963 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; | 25857 | ZigType *bool_type = ira->codegen->builtin_types.entry_bool; |
| 24964 | | 25858 | |
| 24965 | IrInstruction *casted_value = ir_implicit_cast(ira, value, bool_type); | 25859 | IrInstGen *casted_value = ir_implicit_cast(ira, value, bool_type); |
| 24966 | if (type_is_invalid(casted_value->value->type)) | 25860 | if (type_is_invalid(casted_value->value->type)) |
| 24967 | return ira->codegen->invalid_instruction; | 25861 | return ira->codegen->invalid_inst_gen; |
| 24968 | | 25862 | |
| 24969 | if (instr_is_comptime(casted_value)) { | 25863 | if (instr_is_comptime(casted_value)) { |
| 24970 | ZigValue *value = ir_resolve_const(ira, casted_value, UndefBad); | 25864 | ZigValue *value = ir_resolve_const(ira, casted_value, UndefBad); |
| 24971 | if (value == nullptr) | 25865 | if (value == nullptr) |
| 24972 | return ira->codegen->invalid_instruction; | 25866 | return ira->codegen->invalid_inst_gen; |
| 24973 | | 25867 | |
| 24974 | return ir_const_bool(ira, &instruction->base, !value->data.x_bool); | 25868 | return ir_const_bool(ira, &instruction->base.base, !value->data.x_bool); |
| 24975 | } | 25869 | } |
| 24976 | | 25870 | |
| 24977 | IrInstruction *result = ir_build_bool_not(&ira->new_irb, instruction->base.scope, | 25871 | return ir_build_bool_not_gen(ira, &instruction->base.base, casted_value); |
| 24978 | instruction->base.source_node, casted_value); | | |
| 24979 | result->value->type = bool_type; | | |
| 24980 | return result; | | |
| 24981 | } | 25872 | } |
| 24982 | | 25873 | |
| 24983 | static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructionMemset *instruction) { | 25874 | static IrInstGen *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstSrcMemset *instruction) { |
| 24984 | Error err; | 25875 | Error err; |
| 24985 | | 25876 | |
| 24986 | IrInstruction *dest_ptr = instruction->dest_ptr->child; | 25877 | IrInstGen *dest_ptr = instruction->dest_ptr->child; |
| 24987 | if (type_is_invalid(dest_ptr->value->type)) | 25878 | if (type_is_invalid(dest_ptr->value->type)) |
| 24988 | return ira->codegen->invalid_instruction; | 25879 | return ira->codegen->invalid_inst_gen; |
| 24989 | | 25880 | |
| 24990 | IrInstruction *byte_value = instruction->byte->child; | 25881 | IrInstGen *byte_value = instruction->byte->child; |
| 24991 | if (type_is_invalid(byte_value->value->type)) | 25882 | if (type_is_invalid(byte_value->value->type)) |
| 24992 | return ira->codegen->invalid_instruction; | 25883 | return ira->codegen->invalid_inst_gen; |
| 24993 | | 25884 | |
| 24994 | IrInstruction *count_value = instruction->count->child; | 25885 | IrInstGen *count_value = instruction->count->child; |
| 24995 | if (type_is_invalid(count_value->value->type)) | 25886 | if (type_is_invalid(count_value->value->type)) |
| 24996 | return ira->codegen->invalid_instruction; | 25887 | return ira->codegen->invalid_inst_gen; |
| 24997 | | 25888 | |
| 24998 | ZigType *dest_uncasted_type = dest_ptr->value->type; | 25889 | ZigType *dest_uncasted_type = dest_ptr->value->type; |
| 24999 | bool dest_is_volatile = (dest_uncasted_type->id == ZigTypeIdPointer) && | 25890 | bool dest_is_volatile = (dest_uncasted_type->id == ZigTypeIdPointer) && |
| ... | @@ -25004,24 +25895,24 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio | ... | @@ -25004,24 +25895,24 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 25004 | uint32_t dest_align; | 25895 | uint32_t dest_align; |
| 25005 | if (dest_uncasted_type->id == ZigTypeIdPointer) { | 25896 | if (dest_uncasted_type->id == ZigTypeIdPointer) { |
| 25006 | if ((err = resolve_ptr_align(ira, dest_uncasted_type, &dest_align))) | 25897 | if ((err = resolve_ptr_align(ira, dest_uncasted_type, &dest_align))) |
| 25007 | return ira->codegen->invalid_instruction; | 25898 | return ira->codegen->invalid_inst_gen; |
| 25008 | } else { | 25899 | } else { |
| 25009 | dest_align = get_abi_alignment(ira->codegen, u8); | 25900 | dest_align = get_abi_alignment(ira->codegen, u8); |
| 25010 | } | 25901 | } |
| 25011 | ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile, | 25902 | ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, u8, false, dest_is_volatile, |
| 25012 | PtrLenUnknown, dest_align, 0, 0, false); | 25903 | PtrLenUnknown, dest_align, 0, 0, false); |
| 25013 | | 25904 | |
| 25014 | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr); | 25905 | IrInstGen *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr); |
| 25015 | if (type_is_invalid(casted_dest_ptr->value->type)) | 25906 | if (type_is_invalid(casted_dest_ptr->value->type)) |
| 25016 | return ira->codegen->invalid_instruction; | 25907 | return ira->codegen->invalid_inst_gen; |
| 25017 | | 25908 | |
| 25018 | IrInstruction *casted_byte = ir_implicit_cast(ira, byte_value, u8); | 25909 | IrInstGen *casted_byte = ir_implicit_cast(ira, byte_value, u8); |
| 25019 | if (type_is_invalid(casted_byte->value->type)) | 25910 | if (type_is_invalid(casted_byte->value->type)) |
| 25020 | return ira->codegen->invalid_instruction; | 25911 | return ira->codegen->invalid_inst_gen; |
| 25021 | | 25912 | |
| 25022 | IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize); | 25913 | IrInstGen *casted_count = ir_implicit_cast(ira, count_value, usize); |
| 25023 | if (type_is_invalid(casted_count->value->type)) | 25914 | if (type_is_invalid(casted_count->value->type)) |
| 25024 | return ira->codegen->invalid_instruction; | 25915 | return ira->codegen->invalid_inst_gen; |
| 25025 | | 25916 | |
| 25026 | // TODO test this at comptime with u8 and non-u8 types | 25917 | // TODO test this at comptime with u8 and non-u8 types |
| 25027 | if (instr_is_comptime(casted_dest_ptr) && | 25918 | if (instr_is_comptime(casted_dest_ptr) && |
| ... | @@ -25030,15 +25921,15 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio | ... | @@ -25030,15 +25921,15 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 25030 | { | 25921 | { |
| 25031 | ZigValue *dest_ptr_val = ir_resolve_const(ira, casted_dest_ptr, UndefBad); | 25922 | ZigValue *dest_ptr_val = ir_resolve_const(ira, casted_dest_ptr, UndefBad); |
| 25032 | if (dest_ptr_val == nullptr) | 25923 | if (dest_ptr_val == nullptr) |
| 25033 | return ira->codegen->invalid_instruction; | 25924 | return ira->codegen->invalid_inst_gen; |
| 25034 | | 25925 | |
| 25035 | ZigValue *byte_val = ir_resolve_const(ira, casted_byte, UndefOk); | 25926 | ZigValue *byte_val = ir_resolve_const(ira, casted_byte, UndefOk); |
| 25036 | if (byte_val == nullptr) | 25927 | if (byte_val == nullptr) |
| 25037 | return ira->codegen->invalid_instruction; | 25928 | return ira->codegen->invalid_inst_gen; |
| 25038 | | 25929 | |
| 25039 | ZigValue *count_val = ir_resolve_const(ira, casted_count, UndefBad); | 25930 | ZigValue *count_val = ir_resolve_const(ira, casted_count, UndefBad); |
| 25040 | if (count_val == nullptr) | 25931 | if (count_val == nullptr) |
| 25041 | return ira->codegen->invalid_instruction; | 25932 | return ira->codegen->invalid_inst_gen; |
| 25042 | | 25933 | |
| 25043 | if (casted_dest_ptr->value->data.x_ptr.special != ConstPtrSpecialHardCodedAddr && | 25934 | if (casted_dest_ptr->value->data.x_ptr.special != ConstPtrSpecialHardCodedAddr && |
| 25044 | casted_dest_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) | 25935 | casted_dest_ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) |
| ... | @@ -25083,38 +25974,35 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio | ... | @@ -25083,38 +25974,35 @@ static IrInstruction *ir_analyze_instruction_memset(IrAnalyze *ira, IrInstructio |
| 25083 | size_t count = bigint_as_usize(&count_val->data.x_bigint); | 25974 | size_t count = bigint_as_usize(&count_val->data.x_bigint); |
| 25084 | size_t end = start + count; | 25975 | size_t end = start + count; |
| 25085 | if (end > bound_end) { | 25976 | if (end > bound_end) { |
| 25086 | ir_add_error(ira, count_value, buf_sprintf("out of bounds pointer access")); | 25977 | ir_add_error(ira, &count_value->base, buf_sprintf("out of bounds pointer access")); |
| 25087 | return ira->codegen->invalid_instruction; | 25978 | return ira->codegen->invalid_inst_gen; |
| 25088 | } | 25979 | } |
| 25089 | | 25980 | |
| 25090 | for (size_t i = start; i < end; i += 1) { | 25981 | for (size_t i = start; i < end; i += 1) { |
| 25091 | copy_const_val(&dest_elements[i], byte_val); | 25982 | copy_const_val(&dest_elements[i], byte_val); |
| 25092 | } | 25983 | } |
| 25093 | | 25984 | |
| 25094 | return ir_const_void(ira, &instruction->base); | 25985 | return ir_const_void(ira, &instruction->base.base); |
| 25095 | } | 25986 | } |
| 25096 | } | 25987 | } |
| 25097 | | 25988 | |
| 25098 | IrInstruction *result = ir_build_memset(&ira->new_irb, instruction->base.scope, instruction->base.source_node, | 25989 | return ir_build_memset_gen(ira, &instruction->base.base, casted_dest_ptr, casted_byte, casted_count); |
| 25099 | casted_dest_ptr, casted_byte, casted_count); | | |
| 25100 | result->value->type = ira->codegen->builtin_types.entry_void; | | |
| 25101 | return result; | | |
| 25102 | } | 25990 | } |
| 25103 | | 25991 | |
| 25104 | static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructionMemcpy *instruction) { | 25992 | static IrInstGen *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstSrcMemcpy *instruction) { |
| 25105 | Error err; | 25993 | Error err; |
| 25106 | | 25994 | |
| 25107 | IrInstruction *dest_ptr = instruction->dest_ptr->child; | 25995 | IrInstGen *dest_ptr = instruction->dest_ptr->child; |
| 25108 | if (type_is_invalid(dest_ptr->value->type)) | 25996 | if (type_is_invalid(dest_ptr->value->type)) |
| 25109 | return ira->codegen->invalid_instruction; | 25997 | return ira->codegen->invalid_inst_gen; |
| 25110 | | 25998 | |
| 25111 | IrInstruction *src_ptr = instruction->src_ptr->child; | 25999 | IrInstGen *src_ptr = instruction->src_ptr->child; |
| 25112 | if (type_is_invalid(src_ptr->value->type)) | 26000 | if (type_is_invalid(src_ptr->value->type)) |
| 25113 | return ira->codegen->invalid_instruction; | 26001 | return ira->codegen->invalid_inst_gen; |
| 25114 | | 26002 | |
| 25115 | IrInstruction *count_value = instruction->count->child; | 26003 | IrInstGen *count_value = instruction->count->child; |
| 25116 | if (type_is_invalid(count_value->value->type)) | 26004 | if (type_is_invalid(count_value->value->type)) |
| 25117 | return ira->codegen->invalid_instruction; | 26005 | return ira->codegen->invalid_inst_gen; |
| 25118 | | 26006 | |
| 25119 | ZigType *u8 = ira->codegen->builtin_types.entry_u8; | 26007 | ZigType *u8 = ira->codegen->builtin_types.entry_u8; |
| 25120 | ZigType *dest_uncasted_type = dest_ptr->value->type; | 26008 | ZigType *dest_uncasted_type = dest_ptr->value->type; |
| ... | @@ -25127,7 +26015,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -25127,7 +26015,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 25127 | uint32_t dest_align; | 26015 | uint32_t dest_align; |
| 25128 | if (dest_uncasted_type->id == ZigTypeIdPointer) { | 26016 | if (dest_uncasted_type->id == ZigTypeIdPointer) { |
| 25129 | if ((err = resolve_ptr_align(ira, dest_uncasted_type, &dest_align))) | 26017 | if ((err = resolve_ptr_align(ira, dest_uncasted_type, &dest_align))) |
| 25130 | return ira->codegen->invalid_instruction; | 26018 | return ira->codegen->invalid_inst_gen; |
| 25131 | } else { | 26019 | } else { |
| 25132 | dest_align = get_abi_alignment(ira->codegen, u8); | 26020 | dest_align = get_abi_alignment(ira->codegen, u8); |
| 25133 | } | 26021 | } |
| ... | @@ -25135,7 +26023,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -25135,7 +26023,7 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 25135 | uint32_t src_align; | 26023 | uint32_t src_align; |
| 25136 | if (src_uncasted_type->id == ZigTypeIdPointer) { | 26024 | if (src_uncasted_type->id == ZigTypeIdPointer) { |
| 25137 | if ((err = resolve_ptr_align(ira, src_uncasted_type, &src_align))) | 26025 | if ((err = resolve_ptr_align(ira, src_uncasted_type, &src_align))) |
| 25138 | return ira->codegen->invalid_instruction; | 26026 | return ira->codegen->invalid_inst_gen; |
| 25139 | } else { | 26027 | } else { |
| 25140 | src_align = get_abi_alignment(ira->codegen, u8); | 26028 | src_align = get_abi_alignment(ira->codegen, u8); |
| 25141 | } | 26029 | } |
| ... | @@ -25146,17 +26034,17 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -25146,17 +26034,17 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 25146 | ZigType *u8_ptr_const = get_pointer_to_type_extra(ira->codegen, u8, true, src_is_volatile, | 26034 | ZigType *u8_ptr_const = get_pointer_to_type_extra(ira->codegen, u8, true, src_is_volatile, |
| 25147 | PtrLenUnknown, src_align, 0, 0, false); | 26035 | PtrLenUnknown, src_align, 0, 0, false); |
| 25148 | | 26036 | |
| 25149 | IrInstruction *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut); | 26037 | IrInstGen *casted_dest_ptr = ir_implicit_cast(ira, dest_ptr, u8_ptr_mut); |
| 25150 | if (type_is_invalid(casted_dest_ptr->value->type)) | 26038 | if (type_is_invalid(casted_dest_ptr->value->type)) |
| 25151 | return ira->codegen->invalid_instruction; | 26039 | return ira->codegen->invalid_inst_gen; |
| 25152 | | 26040 | |
| 25153 | IrInstruction *casted_src_ptr = ir_implicit_cast(ira, src_ptr, u8_ptr_const); | 26041 | IrInstGen *casted_src_ptr = ir_implicit_cast(ira, src_ptr, u8_ptr_const); |
| 25154 | if (type_is_invalid(casted_src_ptr->value->type)) | 26042 | if (type_is_invalid(casted_src_ptr->value->type)) |
| 25155 | return ira->codegen->invalid_instruction; | 26043 | return ira->codegen->invalid_inst_gen; |
| 25156 | | 26044 | |
| 25157 | IrInstruction *casted_count = ir_implicit_cast(ira, count_value, usize); | 26045 | IrInstGen *casted_count = ir_implicit_cast(ira, count_value, usize); |
| 25158 | if (type_is_invalid(casted_count->value->type)) | 26046 | if (type_is_invalid(casted_count->value->type)) |
| 25159 | return ira->codegen->invalid_instruction; | 26047 | return ira->codegen->invalid_inst_gen; |
| 25160 | | 26048 | |
| 25161 | // TODO test this at comptime with u8 and non-u8 types | 26049 | // TODO test this at comptime with u8 and non-u8 types |
| 25162 | // TODO test with dest ptr being a global runtime variable | 26050 | // TODO test with dest ptr being a global runtime variable |
| ... | @@ -25166,15 +26054,15 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -25166,15 +26054,15 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 25166 | { | 26054 | { |
| 25167 | ZigValue *dest_ptr_val = ir_resolve_const(ira, casted_dest_ptr, UndefBad); | 26055 | ZigValue *dest_ptr_val = ir_resolve_const(ira, casted_dest_ptr, UndefBad); |
| 25168 | if (dest_ptr_val == nullptr) | 26056 | if (dest_ptr_val == nullptr) |
| 25169 | return ira->codegen->invalid_instruction; | 26057 | return ira->codegen->invalid_inst_gen; |
| 25170 | | 26058 | |
| 25171 | ZigValue *src_ptr_val = ir_resolve_const(ira, casted_src_ptr, UndefBad); | 26059 | ZigValue *src_ptr_val = ir_resolve_const(ira, casted_src_ptr, UndefBad); |
| 25172 | if (src_ptr_val == nullptr) | 26060 | if (src_ptr_val == nullptr) |
| 25173 | return ira->codegen->invalid_instruction; | 26061 | return ira->codegen->invalid_inst_gen; |
| 25174 | | 26062 | |
| 25175 | ZigValue *count_val = ir_resolve_const(ira, casted_count, UndefBad); | 26063 | ZigValue *count_val = ir_resolve_const(ira, casted_count, UndefBad); |
| 25176 | if (count_val == nullptr) | 26064 | if (count_val == nullptr) |
| 25177 | return ira->codegen->invalid_instruction; | 26065 | return ira->codegen->invalid_inst_gen; |
| 25178 | | 26066 | |
| 25179 | if (dest_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { | 26067 | if (dest_ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) { |
| 25180 | size_t count = bigint_as_usize(&count_val->data.x_bigint); | 26068 | size_t count = bigint_as_usize(&count_val->data.x_bigint); |
| ... | @@ -25217,8 +26105,8 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -25217,8 +26105,8 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 25217 | } | 26105 | } |
| 25218 | | 26106 | |
| 25219 | if (dest_start + count > dest_end) { | 26107 | if (dest_start + count > dest_end) { |
| 25220 | ir_add_error(ira, &instruction->base, buf_sprintf("out of bounds pointer access")); | 26108 | ir_add_error(ira, &instruction->base.base, buf_sprintf("out of bounds pointer access")); |
| 25221 | return ira->codegen->invalid_instruction; | 26109 | return ira->codegen->invalid_inst_gen; |
| 25222 | } | 26110 | } |
| 25223 | | 26111 | |
| 25224 | ZigValue *src_elements; | 26112 | ZigValue *src_elements; |
| ... | @@ -25260,8 +26148,8 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -25260,8 +26148,8 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 25260 | } | 26148 | } |
| 25261 | | 26149 | |
| 25262 | if (src_start + count > src_end) { | 26150 | if (src_start + count > src_end) { |
| 25263 | ir_add_error(ira, &instruction->base, buf_sprintf("out of bounds pointer access")); | 26151 | ir_add_error(ira, &instruction->base.base, buf_sprintf("out of bounds pointer access")); |
| 25264 | return ira->codegen->invalid_instruction; | 26152 | return ira->codegen->invalid_inst_gen; |
| 25265 | } | 26153 | } |
| 25266 | | 26154 | |
| 25267 | // TODO check for noalias violations - this should be generalized to work for any function | 26155 | // TODO check for noalias violations - this should be generalized to work for any function |
| ... | @@ -25270,42 +26158,39 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio | ... | @@ -25270,42 +26158,39 @@ static IrInstruction *ir_analyze_instruction_memcpy(IrAnalyze *ira, IrInstructio |
| 25270 | copy_const_val(&dest_elements[dest_start + i], &src_elements[src_start + i]); | 26158 | copy_const_val(&dest_elements[dest_start + i], &src_elements[src_start + i]); |
| 25271 | } | 26159 | } |
| 25272 | | 26160 | |
| 25273 | return ir_const_void(ira, &instruction->base); | 26161 | return ir_const_void(ira, &instruction->base.base); |
| 25274 | } | 26162 | } |
| 25275 | } | 26163 | } |
| 25276 | | 26164 | |
| 25277 | IrInstruction *result = ir_build_memcpy(&ira->new_irb, instruction->base.scope, instruction->base.source_node, | 26165 | return ir_build_memcpy_gen(ira, &instruction->base.base, casted_dest_ptr, casted_src_ptr, casted_count); |
| 25278 | casted_dest_ptr, casted_src_ptr, casted_count); | | |
| 25279 | result->value->type = ira->codegen->builtin_types.entry_void; | | |
| 25280 | return result; | | |
| 25281 | } | 26166 | } |
| 25282 | | 26167 | |
| 25283 | static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstructionSliceSrc *instruction) { | 26168 | static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *instruction) { |
| 25284 | IrInstruction *ptr_ptr = instruction->ptr->child; | 26169 | IrInstGen *ptr_ptr = instruction->ptr->child; |
| 25285 | if (type_is_invalid(ptr_ptr->value->type)) | 26170 | if (type_is_invalid(ptr_ptr->value->type)) |
| 25286 | return ira->codegen->invalid_instruction; | 26171 | return ira->codegen->invalid_inst_gen; |
| 25287 | | 26172 | |
| 25288 | ZigType *ptr_ptr_type = ptr_ptr->value->type; | 26173 | ZigType *ptr_ptr_type = ptr_ptr->value->type; |
| 25289 | assert(ptr_ptr_type->id == ZigTypeIdPointer); | 26174 | assert(ptr_ptr_type->id == ZigTypeIdPointer); |
| 25290 | ZigType *array_type = ptr_ptr_type->data.pointer.child_type; | 26175 | ZigType *array_type = ptr_ptr_type->data.pointer.child_type; |
| 25291 | | 26176 | |
| 25292 | IrInstruction *start = instruction->start->child; | 26177 | IrInstGen *start = instruction->start->child; |
| 25293 | if (type_is_invalid(start->value->type)) | 26178 | if (type_is_invalid(start->value->type)) |
| 25294 | return ira->codegen->invalid_instruction; | 26179 | return ira->codegen->invalid_inst_gen; |
| 25295 | | 26180 | |
| 25296 | ZigType *usize = ira->codegen->builtin_types.entry_usize; | 26181 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 25297 | IrInstruction *casted_start = ir_implicit_cast(ira, start, usize); | 26182 | IrInstGen *casted_start = ir_implicit_cast(ira, start, usize); |
| 25298 | if (type_is_invalid(casted_start->value->type)) | 26183 | if (type_is_invalid(casted_start->value->type)) |
| 25299 | return ira->codegen->invalid_instruction; | 26184 | return ira->codegen->invalid_inst_gen; |
| 25300 | | 26185 | |
| 25301 | IrInstruction *end; | 26186 | IrInstGen *end; |
| 25302 | if (instruction->end) { | 26187 | if (instruction->end) { |
| 25303 | end = instruction->end->child; | 26188 | end = instruction->end->child; |
| 25304 | if (type_is_invalid(end->value->type)) | 26189 | if (type_is_invalid(end->value->type)) |
| 25305 | return ira->codegen->invalid_instruction; | 26190 | return ira->codegen->invalid_inst_gen; |
| 25306 | end = ir_implicit_cast(ira, end, usize); | 26191 | end = ir_implicit_cast(ira, end, usize); |
| 25307 | if (type_is_invalid(end->value->type)) | 26192 | if (type_is_invalid(end->value->type)) |
| 25308 | return ira->codegen->invalid_instruction; | 26193 | return ira->codegen->invalid_inst_gen; |
| 25309 | } else { | 26194 | } else { |
| 25310 | end = nullptr; | 26195 | end = nullptr; |
| 25311 | } | 26196 | } |
| ... | @@ -25333,8 +26218,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -25333,8 +26218,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 25333 | PtrLenUnknown, | 26218 | PtrLenUnknown, |
| 25334 | array_type->data.pointer.explicit_alignment, 0, 0, false); | 26219 | array_type->data.pointer.explicit_alignment, 0, 0, false); |
| 25335 | } else { | 26220 | } else { |
| 25336 | ir_add_error(ira, &instruction->base, buf_sprintf("slice of single-item pointer")); | 26221 | ir_add_error(ira, &instruction->base.base, buf_sprintf("slice of single-item pointer")); |
| 25337 | return ira->codegen->invalid_instruction; | 26222 | return ira->codegen->invalid_inst_gen; |
| 25338 | } | 26223 | } |
| 25339 | } else { | 26224 | } else { |
| 25340 | elem_type = array_type->data.pointer.child_type; | 26225 | elem_type = array_type->data.pointer.child_type; |
| ... | @@ -25344,8 +26229,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -25344,8 +26229,8 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 25344 | ZigType *maybe_sentineled_slice_ptr_type = array_type; | 26229 | ZigType *maybe_sentineled_slice_ptr_type = array_type; |
| 25345 | non_sentinel_slice_ptr_type = adjust_ptr_sentinel(ira->codegen, maybe_sentineled_slice_ptr_type, nullptr); | 26230 | non_sentinel_slice_ptr_type = adjust_ptr_sentinel(ira->codegen, maybe_sentineled_slice_ptr_type, nullptr); |
| 25346 | if (!end) { | 26231 | if (!end) { |
| 25347 | ir_add_error(ira, &instruction->base, buf_sprintf("slice of pointer must include end value")); | 26232 | ir_add_error(ira, &instruction->base.base, buf_sprintf("slice of pointer must include end value")); |
| 25348 | return ira->codegen->invalid_instruction; | 26233 | return ira->codegen->invalid_inst_gen; |
| 25349 | } | 26234 | } |
| 25350 | } | 26235 | } |
| 25351 | } else if (is_slice(array_type)) { | 26236 | } else if (is_slice(array_type)) { |
| ... | @@ -25353,23 +26238,23 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -25353,23 +26238,23 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 25353 | non_sentinel_slice_ptr_type = adjust_ptr_sentinel(ira->codegen, maybe_sentineled_slice_ptr_type, nullptr); | 26238 | non_sentinel_slice_ptr_type = adjust_ptr_sentinel(ira->codegen, maybe_sentineled_slice_ptr_type, nullptr); |
| 25354 | elem_type = non_sentinel_slice_ptr_type->data.pointer.child_type; | 26239 | elem_type = non_sentinel_slice_ptr_type->data.pointer.child_type; |
| 25355 | } else { | 26240 | } else { |
| 25356 | ir_add_error(ira, &instruction->base, | 26241 | ir_add_error(ira, &instruction->base.base, |
| 25357 | buf_sprintf("slice of non-array type '%s'", buf_ptr(&array_type->name))); | 26242 | buf_sprintf("slice of non-array type '%s'", buf_ptr(&array_type->name))); |
| 25358 | return ira->codegen->invalid_instruction; | 26243 | return ira->codegen->invalid_inst_gen; |
| 25359 | } | 26244 | } |
| 25360 | | 26245 | |
| 25361 | ZigType *return_type; | 26246 | ZigType *return_type; |
| 25362 | ZigValue *sentinel_val = nullptr; | 26247 | ZigValue *sentinel_val = nullptr; |
| 25363 | if (instruction->sentinel) { | 26248 | if (instruction->sentinel) { |
| 25364 | IrInstruction *uncasted_sentinel = instruction->sentinel->child; | 26249 | IrInstGen *uncasted_sentinel = instruction->sentinel->child; |
| 25365 | if (type_is_invalid(uncasted_sentinel->value->type)) | 26250 | if (type_is_invalid(uncasted_sentinel->value->type)) |
| 25366 | return ira->codegen->invalid_instruction; | 26251 | return ira->codegen->invalid_inst_gen; |
| 25367 | IrInstruction *sentinel = ir_implicit_cast(ira, uncasted_sentinel, elem_type); | 26252 | IrInstGen *sentinel = ir_implicit_cast(ira, uncasted_sentinel, elem_type); |
| 25368 | if (type_is_invalid(sentinel->value->type)) | 26253 | if (type_is_invalid(sentinel->value->type)) |
| 25369 | return ira->codegen->invalid_instruction; | 26254 | return ira->codegen->invalid_inst_gen; |
| 25370 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); | 26255 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| 25371 | if (sentinel_val == nullptr) | 26256 | if (sentinel_val == nullptr) |
| 25372 | return ira->codegen->invalid_instruction; | 26257 | return ira->codegen->invalid_inst_gen; |
| 25373 | ZigType *slice_ptr_type = adjust_ptr_sentinel(ira->codegen, non_sentinel_slice_ptr_type, sentinel_val); | 26258 | ZigType *slice_ptr_type = adjust_ptr_sentinel(ira->codegen, non_sentinel_slice_ptr_type, sentinel_val); |
| 25374 | return_type = get_slice_type(ira->codegen, slice_ptr_type); | 26259 | return_type = get_slice_type(ira->codegen, slice_ptr_type); |
| 25375 | } else { | 26260 | } else { |
| ... | @@ -25391,9 +26276,9 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -25391,9 +26276,9 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 25391 | if (array_type->id == ZigTypeIdPointer) { | 26276 | if (array_type->id == ZigTypeIdPointer) { |
| 25392 | ZigType *child_array_type = array_type->data.pointer.child_type; | 26277 | ZigType *child_array_type = array_type->data.pointer.child_type; |
| 25393 | assert(child_array_type->id == ZigTypeIdArray); | 26278 | assert(child_array_type->id == ZigTypeIdArray); |
| 25394 | parent_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node); | 26279 | parent_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.base.source_node); |
| 25395 | if (parent_ptr == nullptr) | 26280 | if (parent_ptr == nullptr) |
| 25396 | return ira->codegen->invalid_instruction; | 26281 | return ira->codegen->invalid_inst_gen; |
| 25397 | | 26282 | |
| 25398 | | 26283 | |
| 25399 | if (parent_ptr->special == ConstValSpecialUndef) { | 26284 | if (parent_ptr->special == ConstValSpecialUndef) { |
| ... | @@ -25402,26 +26287,26 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -25402,26 +26287,26 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 25402 | rel_end = SIZE_MAX; | 26287 | rel_end = SIZE_MAX; |
| 25403 | ptr_is_undef = true; | 26288 | ptr_is_undef = true; |
| 25404 | } else { | 26289 | } else { |
| 25405 | array_val = const_ptr_pointee(ira, ira->codegen, parent_ptr, instruction->base.source_node); | 26290 | array_val = const_ptr_pointee(ira, ira->codegen, parent_ptr, instruction->base.base.source_node); |
| 25406 | if (array_val == nullptr) | 26291 | if (array_val == nullptr) |
| 25407 | return ira->codegen->invalid_instruction; | 26292 | return ira->codegen->invalid_inst_gen; |
| 25408 | | 26293 | |
| 25409 | rel_end = child_array_type->data.array.len; | 26294 | rel_end = child_array_type->data.array.len; |
| 25410 | abs_offset = 0; | 26295 | abs_offset = 0; |
| 25411 | } | 26296 | } |
| 25412 | } else { | 26297 | } else { |
| 25413 | array_val = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node); | 26298 | array_val = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.base.source_node); |
| 25414 | if (array_val == nullptr) | 26299 | if (array_val == nullptr) |
| 25415 | return ira->codegen->invalid_instruction; | 26300 | return ira->codegen->invalid_inst_gen; |
| 25416 | rel_end = array_type->data.array.len; | 26301 | rel_end = array_type->data.array.len; |
| 25417 | parent_ptr = nullptr; | 26302 | parent_ptr = nullptr; |
| 25418 | abs_offset = 0; | 26303 | abs_offset = 0; |
| 25419 | } | 26304 | } |
| 25420 | } else if (array_type->id == ZigTypeIdPointer) { | 26305 | } else if (array_type->id == ZigTypeIdPointer) { |
| 25421 | assert(array_type->data.pointer.ptr_len == PtrLenUnknown); | 26306 | assert(array_type->data.pointer.ptr_len == PtrLenUnknown); |
| 25422 | parent_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node); | 26307 | parent_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.base.source_node); |
| 25423 | if (parent_ptr == nullptr) | 26308 | if (parent_ptr == nullptr) |
| 25424 | return ira->codegen->invalid_instruction; | 26309 | return ira->codegen->invalid_inst_gen; |
| 25425 | | 26310 | |
| 25426 | if (parent_ptr->special == ConstValSpecialUndef) { | 26311 | if (parent_ptr->special == ConstValSpecialUndef) { |
| 25427 | array_val = nullptr; | 26312 | array_val = nullptr; |
| ... | @@ -25467,19 +26352,19 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -25467,19 +26352,19 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 25467 | zig_panic("TODO slice of null ptr"); | 26352 | zig_panic("TODO slice of null ptr"); |
| 25468 | } | 26353 | } |
| 25469 | } else if (is_slice(array_type)) { | 26354 | } else if (is_slice(array_type)) { |
| 25470 | ZigValue *slice_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.source_node); | 26355 | ZigValue *slice_ptr = const_ptr_pointee(ira, ira->codegen, ptr_ptr->value, instruction->base.base.source_node); |
| 25471 | if (slice_ptr == nullptr) | 26356 | if (slice_ptr == nullptr) |
| 25472 | return ira->codegen->invalid_instruction; | 26357 | return ira->codegen->invalid_inst_gen; |
| 25473 | | 26358 | |
| 25474 | if (slice_ptr->special == ConstValSpecialUndef) { | 26359 | if (slice_ptr->special == ConstValSpecialUndef) { |
| 25475 | ir_add_error(ira, &instruction->base, buf_sprintf("slice of undefined")); | 26360 | ir_add_error(ira, &instruction->base.base, buf_sprintf("slice of undefined")); |
| 25476 | return ira->codegen->invalid_instruction; | 26361 | return ira->codegen->invalid_inst_gen; |
| 25477 | } | 26362 | } |
| 25478 | | 26363 | |
| 25479 | parent_ptr = slice_ptr->data.x_struct.fields[slice_ptr_index]; | 26364 | parent_ptr = slice_ptr->data.x_struct.fields[slice_ptr_index]; |
| 25480 | if (parent_ptr->special == ConstValSpecialUndef) { | 26365 | if (parent_ptr->special == ConstValSpecialUndef) { |
| 25481 | ir_add_error(ira, &instruction->base, buf_sprintf("slice of undefined")); | 26366 | ir_add_error(ira, &instruction->base.base, buf_sprintf("slice of undefined")); |
| 25482 | return ira->codegen->invalid_instruction; | 26367 | return ira->codegen->invalid_inst_gen; |
| 25483 | } | 26368 | } |
| 25484 | | 26369 | |
| 25485 | ZigValue *len_val = slice_ptr->data.x_struct.fields[slice_len_index]; | 26370 | ZigValue *len_val = slice_ptr->data.x_struct.fields[slice_len_index]; |
| ... | @@ -25522,37 +26407,37 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -25522,37 +26407,37 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 25522 | | 26407 | |
| 25523 | ZigValue *start_val = ir_resolve_const(ira, casted_start, UndefBad); | 26408 | ZigValue *start_val = ir_resolve_const(ira, casted_start, UndefBad); |
| 25524 | if (!start_val) | 26409 | if (!start_val) |
| 25525 | return ira->codegen->invalid_instruction; | 26410 | return ira->codegen->invalid_inst_gen; |
| 25526 | | 26411 | |
| 25527 | uint64_t start_scalar = bigint_as_u64(&start_val->data.x_bigint); | 26412 | uint64_t start_scalar = bigint_as_u64(&start_val->data.x_bigint); |
| 25528 | if (!ptr_is_undef && start_scalar > rel_end) { | 26413 | if (!ptr_is_undef && start_scalar > rel_end) { |
| 25529 | ir_add_error(ira, &instruction->base, buf_sprintf("out of bounds slice")); | 26414 | ir_add_error(ira, &instruction->base.base, buf_sprintf("out of bounds slice")); |
| 25530 | return ira->codegen->invalid_instruction; | 26415 | return ira->codegen->invalid_inst_gen; |
| 25531 | } | 26416 | } |
| 25532 | | 26417 | |
| 25533 | uint64_t end_scalar = rel_end; | 26418 | uint64_t end_scalar = rel_end; |
| 25534 | if (end) { | 26419 | if (end) { |
| 25535 | ZigValue *end_val = ir_resolve_const(ira, end, UndefBad); | 26420 | ZigValue *end_val = ir_resolve_const(ira, end, UndefBad); |
| 25536 | if (!end_val) | 26421 | if (!end_val) |
| 25537 | return ira->codegen->invalid_instruction; | 26422 | return ira->codegen->invalid_inst_gen; |
| 25538 | end_scalar = bigint_as_u64(&end_val->data.x_bigint); | 26423 | end_scalar = bigint_as_u64(&end_val->data.x_bigint); |
| 25539 | } | 26424 | } |
| 25540 | if (!ptr_is_undef) { | 26425 | if (!ptr_is_undef) { |
| 25541 | if (end_scalar > rel_end) { | 26426 | if (end_scalar > rel_end) { |
| 25542 | ir_add_error(ira, &instruction->base, buf_sprintf("out of bounds slice")); | 26427 | ir_add_error(ira, &instruction->base.base, buf_sprintf("out of bounds slice")); |
| 25543 | return ira->codegen->invalid_instruction; | 26428 | return ira->codegen->invalid_inst_gen; |
| 25544 | } | 26429 | } |
| 25545 | if (start_scalar > end_scalar) { | 26430 | if (start_scalar > end_scalar) { |
| 25546 | ir_add_error(ira, &instruction->base, buf_sprintf("slice start is greater than end")); | 26431 | ir_add_error(ira, &instruction->base.base, buf_sprintf("slice start is greater than end")); |
| 25547 | return ira->codegen->invalid_instruction; | 26432 | return ira->codegen->invalid_inst_gen; |
| 25548 | } | 26433 | } |
| 25549 | } | 26434 | } |
| 25550 | if (ptr_is_undef && start_scalar != end_scalar) { | 26435 | if (ptr_is_undef && start_scalar != end_scalar) { |
| 25551 | ir_add_error(ira, &instruction->base, buf_sprintf("non-zero length slice of undefined pointer")); | 26436 | ir_add_error(ira, &instruction->base.base, buf_sprintf("non-zero length slice of undefined pointer")); |
| 25552 | return ira->codegen->invalid_instruction; | 26437 | return ira->codegen->invalid_inst_gen; |
| 25553 | } | 26438 | } |
| 25554 | | 26439 | |
| 25555 | IrInstruction *result = ir_const(ira, &instruction->base, return_type); | 26440 | IrInstGen *result = ir_const(ira, &instruction->base.base, return_type); |
| 25556 | ZigValue *out_val = result->value; | 26441 | ZigValue *out_val = result->value; |
| 25557 | out_val->data.x_struct.fields = alloc_const_vals_ptrs(2); | 26442 | out_val->data.x_struct.fields = alloc_const_vals_ptrs(2); |
| 25558 | | 26443 | |
| ... | @@ -25609,28 +26494,28 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -25609,28 +26494,28 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 25609 | return result; | 26494 | return result; |
| 25610 | } | 26495 | } |
| 25611 | | 26496 | |
| 25612 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 26497 | IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base.base, instruction->result_loc, |
| 25613 | return_type, nullptr, true, false, true); | 26498 | return_type, nullptr, true, false, true); |
| 25614 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { | 26499 | if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) { |
| 25615 | return result_loc; | 26500 | return result_loc; |
| 25616 | } | 26501 | } |
| 25617 | return ir_build_slice_gen(ira, &instruction->base, return_type, | 26502 | return ir_build_slice_gen(ira, &instruction->base.base, return_type, |
| 25618 | ptr_ptr, casted_start, end, instruction->safety_check_on, result_loc); | 26503 | ptr_ptr, casted_start, end, instruction->safety_check_on, result_loc); |
| 25619 | } | 26504 | } |
| 25620 | | 26505 | |
| 25621 | static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInstructionMemberCount *instruction) { | 26506 | static IrInstGen *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInstSrcMemberCount *instruction) { |
| 25622 | Error err; | 26507 | Error err; |
| 25623 | IrInstruction *container = instruction->container->child; | 26508 | IrInstGen *container = instruction->container->child; |
| 25624 | if (type_is_invalid(container->value->type)) | 26509 | if (type_is_invalid(container->value->type)) |
| 25625 | return ira->codegen->invalid_instruction; | 26510 | return ira->codegen->invalid_inst_gen; |
| 25626 | ZigType *container_type = ir_resolve_type(ira, container); | 26511 | ZigType *container_type = ir_resolve_type(ira, container); |
| 25627 | | 26512 | |
| 25628 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) | 26513 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) |
| 25629 | return ira->codegen->invalid_instruction; | 26514 | return ira->codegen->invalid_inst_gen; |
| 25630 | | 26515 | |
| 25631 | uint64_t result; | 26516 | uint64_t result; |
| 25632 | if (type_is_invalid(container_type)) { | 26517 | if (type_is_invalid(container_type)) { |
| 25633 | return ira->codegen->invalid_instruction; | 26518 | return ira->codegen->invalid_inst_gen; |
| 25634 | } else if (container_type->id == ZigTypeIdEnum) { | 26519 | } else if (container_type->id == ZigTypeIdEnum) { |
| 25635 | result = container_type->data.enumeration.src_field_count; | 26520 | result = container_type->data.enumeration.src_field_count; |
| 25636 | } else if (container_type->id == ZigTypeIdStruct) { | 26521 | } else if (container_type->id == ZigTypeIdStruct) { |
| ... | @@ -25638,135 +26523,135 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst | ... | @@ -25638,135 +26523,135 @@ static IrInstruction *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInst |
| 25638 | } else if (container_type->id == ZigTypeIdUnion) { | 26523 | } else if (container_type->id == ZigTypeIdUnion) { |
| 25639 | result = container_type->data.unionation.src_field_count; | 26524 | result = container_type->data.unionation.src_field_count; |
| 25640 | } else if (container_type->id == ZigTypeIdErrorSet) { | 26525 | } else if (container_type->id == ZigTypeIdErrorSet) { |
| 25641 | if (!resolve_inferred_error_set(ira->codegen, container_type, instruction->base.source_node)) { | 26526 | if (!resolve_inferred_error_set(ira->codegen, container_type, instruction->base.base.source_node)) { |
| 25642 | return ira->codegen->invalid_instruction; | 26527 | return ira->codegen->invalid_inst_gen; |
| 25643 | } | 26528 | } |
| 25644 | if (type_is_global_error_set(container_type)) { | 26529 | if (type_is_global_error_set(container_type)) { |
| 25645 | ir_add_error(ira, &instruction->base, buf_sprintf("global error set member count not available at comptime")); | 26530 | ir_add_error(ira, &instruction->base.base, buf_sprintf("global error set member count not available at comptime")); |
| 25646 | return ira->codegen->invalid_instruction; | 26531 | return ira->codegen->invalid_inst_gen; |
| 25647 | } | 26532 | } |
| 25648 | result = container_type->data.error_set.err_count; | 26533 | result = container_type->data.error_set.err_count; |
| 25649 | } else { | 26534 | } else { |
| 25650 | ir_add_error(ira, &instruction->base, buf_sprintf("no value count available for type '%s'", buf_ptr(&container_type->name))); | 26535 | ir_add_error(ira, &instruction->base.base, buf_sprintf("no value count available for type '%s'", buf_ptr(&container_type->name))); |
| 25651 | return ira->codegen->invalid_instruction; | 26536 | return ira->codegen->invalid_inst_gen; |
| 25652 | } | 26537 | } |
| 25653 | | 26538 | |
| 25654 | return ir_const_unsigned(ira, &instruction->base, result); | 26539 | return ir_const_unsigned(ira, &instruction->base.base, result); |
| 25655 | } | 26540 | } |
| 25656 | | 26541 | |
| 25657 | static IrInstruction *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstructionMemberType *instruction) { | 26542 | static IrInstGen *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstSrcMemberType *instruction) { |
| 25658 | Error err; | 26543 | Error err; |
| 25659 | IrInstruction *container_type_value = instruction->container_type->child; | 26544 | IrInstGen *container_type_value = instruction->container_type->child; |
| 25660 | ZigType *container_type = ir_resolve_type(ira, container_type_value); | 26545 | ZigType *container_type = ir_resolve_type(ira, container_type_value); |
| 25661 | if (type_is_invalid(container_type)) | 26546 | if (type_is_invalid(container_type)) |
| 25662 | return ira->codegen->invalid_instruction; | 26547 | return ira->codegen->invalid_inst_gen; |
| 25663 | | 26548 | |
| 25664 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) | 26549 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) |
| 25665 | return ira->codegen->invalid_instruction; | 26550 | return ira->codegen->invalid_inst_gen; |
| 25666 | | 26551 | |
| 25667 | | 26552 | |
| 25668 | uint64_t member_index; | 26553 | uint64_t member_index; |
| 25669 | IrInstruction *index_value = instruction->member_index->child; | 26554 | IrInstGen *index_value = instruction->member_index->child; |
| 25670 | if (!ir_resolve_usize(ira, index_value, &member_index)) | 26555 | if (!ir_resolve_usize(ira, index_value, &member_index)) |
| 25671 | return ira->codegen->invalid_instruction; | 26556 | return ira->codegen->invalid_inst_gen; |
| 25672 | | 26557 | |
| 25673 | if (container_type->id == ZigTypeIdStruct) { | 26558 | if (container_type->id == ZigTypeIdStruct) { |
| 25674 | if (member_index >= container_type->data.structure.src_field_count) { | 26559 | if (member_index >= container_type->data.structure.src_field_count) { |
| 25675 | ir_add_error(ira, index_value, | 26560 | ir_add_error(ira, &index_value->base, |
| 25676 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", | 26561 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", |
| 25677 | member_index, buf_ptr(&container_type->name), container_type->data.structure.src_field_count)); | 26562 | member_index, buf_ptr(&container_type->name), container_type->data.structure.src_field_count)); |
| 25678 | return ira->codegen->invalid_instruction; | 26563 | return ira->codegen->invalid_inst_gen; |
| 25679 | } | 26564 | } |
| 25680 | TypeStructField *field = container_type->data.structure.fields[member_index]; | 26565 | TypeStructField *field = container_type->data.structure.fields[member_index]; |
| 25681 | | 26566 | |
| 25682 | return ir_const_type(ira, &instruction->base, field->type_entry); | 26567 | return ir_const_type(ira, &instruction->base.base, field->type_entry); |
| 25683 | } else if (container_type->id == ZigTypeIdUnion) { | 26568 | } else if (container_type->id == ZigTypeIdUnion) { |
| 25684 | if (member_index >= container_type->data.unionation.src_field_count) { | 26569 | if (member_index >= container_type->data.unionation.src_field_count) { |
| 25685 | ir_add_error(ira, index_value, | 26570 | ir_add_error(ira, &index_value->base, |
| 25686 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", | 26571 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", |
| 25687 | member_index, buf_ptr(&container_type->name), container_type->data.unionation.src_field_count)); | 26572 | member_index, buf_ptr(&container_type->name), container_type->data.unionation.src_field_count)); |
| 25688 | return ira->codegen->invalid_instruction; | 26573 | return ira->codegen->invalid_inst_gen; |
| 25689 | } | 26574 | } |
| 25690 | TypeUnionField *field = &container_type->data.unionation.fields[member_index]; | 26575 | TypeUnionField *field = &container_type->data.unionation.fields[member_index]; |
| 25691 | | 26576 | |
| 25692 | return ir_const_type(ira, &instruction->base, field->type_entry); | 26577 | return ir_const_type(ira, &instruction->base.base, field->type_entry); |
| 25693 | } else { | 26578 | } else { |
| 25694 | ir_add_error(ira, container_type_value, | 26579 | ir_add_error(ira, &container_type_value->base, |
| 25695 | buf_sprintf("type '%s' does not support @memberType", buf_ptr(&container_type->name))); | 26580 | buf_sprintf("type '%s' does not support @memberType", buf_ptr(&container_type->name))); |
| 25696 | return ira->codegen->invalid_instruction; | 26581 | return ira->codegen->invalid_inst_gen; |
| 25697 | } | 26582 | } |
| 25698 | } | 26583 | } |
| 25699 | | 26584 | |
| 25700 | static IrInstruction *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstructionMemberName *instruction) { | 26585 | static IrInstGen *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstSrcMemberName *instruction) { |
| 25701 | Error err; | 26586 | Error err; |
| 25702 | IrInstruction *container_type_value = instruction->container_type->child; | 26587 | IrInstGen *container_type_value = instruction->container_type->child; |
| 25703 | ZigType *container_type = ir_resolve_type(ira, container_type_value); | 26588 | ZigType *container_type = ir_resolve_type(ira, container_type_value); |
| 25704 | if (type_is_invalid(container_type)) | 26589 | if (type_is_invalid(container_type)) |
| 25705 | return ira->codegen->invalid_instruction; | 26590 | return ira->codegen->invalid_inst_gen; |
| 25706 | | 26591 | |
| 25707 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) | 26592 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown))) |
| 25708 | return ira->codegen->invalid_instruction; | 26593 | return ira->codegen->invalid_inst_gen; |
| 25709 | | 26594 | |
| 25710 | uint64_t member_index; | 26595 | uint64_t member_index; |
| 25711 | IrInstruction *index_value = instruction->member_index->child; | 26596 | IrInstGen *index_value = instruction->member_index->child; |
| 25712 | if (!ir_resolve_usize(ira, index_value, &member_index)) | 26597 | if (!ir_resolve_usize(ira, index_value, &member_index)) |
| 25713 | return ira->codegen->invalid_instruction; | 26598 | return ira->codegen->invalid_inst_gen; |
| 25714 | | 26599 | |
| 25715 | if (container_type->id == ZigTypeIdStruct) { | 26600 | if (container_type->id == ZigTypeIdStruct) { |
| 25716 | if (member_index >= container_type->data.structure.src_field_count) { | 26601 | if (member_index >= container_type->data.structure.src_field_count) { |
| 25717 | ir_add_error(ira, index_value, | 26602 | ir_add_error(ira, &index_value->base, |
| 25718 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", | 26603 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", |
| 25719 | member_index, buf_ptr(&container_type->name), container_type->data.structure.src_field_count)); | 26604 | member_index, buf_ptr(&container_type->name), container_type->data.structure.src_field_count)); |
| 25720 | return ira->codegen->invalid_instruction; | 26605 | return ira->codegen->invalid_inst_gen; |
| 25721 | } | 26606 | } |
| 25722 | TypeStructField *field = container_type->data.structure.fields[member_index]; | 26607 | TypeStructField *field = container_type->data.structure.fields[member_index]; |
| 25723 | | 26608 | |
| 25724 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 26609 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 25725 | init_const_str_lit(ira->codegen, result->value, field->name); | 26610 | init_const_str_lit(ira->codegen, result->value, field->name); |
| 25726 | return result; | 26611 | return result; |
| 25727 | } else if (container_type->id == ZigTypeIdEnum) { | 26612 | } else if (container_type->id == ZigTypeIdEnum) { |
| 25728 | if (member_index >= container_type->data.enumeration.src_field_count) { | 26613 | if (member_index >= container_type->data.enumeration.src_field_count) { |
| 25729 | ir_add_error(ira, index_value, | 26614 | ir_add_error(ira, &index_value->base, |
| 25730 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", | 26615 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", |
| 25731 | member_index, buf_ptr(&container_type->name), container_type->data.enumeration.src_field_count)); | 26616 | member_index, buf_ptr(&container_type->name), container_type->data.enumeration.src_field_count)); |
| 25732 | return ira->codegen->invalid_instruction; | 26617 | return ira->codegen->invalid_inst_gen; |
| 25733 | } | 26618 | } |
| 25734 | TypeEnumField *field = &container_type->data.enumeration.fields[member_index]; | 26619 | TypeEnumField *field = &container_type->data.enumeration.fields[member_index]; |
| 25735 | | 26620 | |
| 25736 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 26621 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 25737 | init_const_str_lit(ira->codegen, result->value, field->name); | 26622 | init_const_str_lit(ira->codegen, result->value, field->name); |
| 25738 | return result; | 26623 | return result; |
| 25739 | } else if (container_type->id == ZigTypeIdUnion) { | 26624 | } else if (container_type->id == ZigTypeIdUnion) { |
| 25740 | if (member_index >= container_type->data.unionation.src_field_count) { | 26625 | if (member_index >= container_type->data.unionation.src_field_count) { |
| 25741 | ir_add_error(ira, index_value, | 26626 | ir_add_error(ira, &index_value->base, |
| 25742 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", | 26627 | buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members", |
| 25743 | member_index, buf_ptr(&container_type->name), container_type->data.unionation.src_field_count)); | 26628 | member_index, buf_ptr(&container_type->name), container_type->data.unionation.src_field_count)); |
| 25744 | return ira->codegen->invalid_instruction; | 26629 | return ira->codegen->invalid_inst_gen; |
| 25745 | } | 26630 | } |
| 25746 | TypeUnionField *field = &container_type->data.unionation.fields[member_index]; | 26631 | TypeUnionField *field = &container_type->data.unionation.fields[member_index]; |
| 25747 | | 26632 | |
| 25748 | IrInstruction *result = ir_const(ira, &instruction->base, nullptr); | 26633 | IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr); |
| 25749 | init_const_str_lit(ira->codegen, result->value, field->name); | 26634 | init_const_str_lit(ira->codegen, result->value, field->name); |
| 25750 | return result; | 26635 | return result; |
| 25751 | } else { | 26636 | } else { |
| 25752 | ir_add_error(ira, container_type_value, | 26637 | ir_add_error(ira, &container_type_value->base, |
| 25753 | buf_sprintf("type '%s' does not support @memberName", buf_ptr(&container_type->name))); | 26638 | buf_sprintf("type '%s' does not support @memberName", buf_ptr(&container_type->name))); |
| 25754 | return ira->codegen->invalid_instruction; | 26639 | return ira->codegen->invalid_inst_gen; |
| 25755 | } | 26640 | } |
| 25756 | } | 26641 | } |
| 25757 | | 26642 | |
| 25758 | static IrInstruction *ir_analyze_instruction_has_field(IrAnalyze *ira, IrInstructionHasField *instruction) { | 26643 | static IrInstGen *ir_analyze_instruction_has_field(IrAnalyze *ira, IrInstSrcHasField *instruction) { |
| 25759 | Error err; | 26644 | Error err; |
| 25760 | ZigType *container_type = ir_resolve_type(ira, instruction->container_type->child); | 26645 | ZigType *container_type = ir_resolve_type(ira, instruction->container_type->child); |
| 25761 | if (type_is_invalid(container_type)) | 26646 | if (type_is_invalid(container_type)) |
| 25762 | return ira->codegen->invalid_instruction; | 26647 | return ira->codegen->invalid_inst_gen; |
| 25763 | | 26648 | |
| 25764 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusZeroBitsKnown))) | 26649 | if ((err = type_resolve(ira->codegen, container_type, ResolveStatusZeroBitsKnown))) |
| 25765 | return ira->codegen->invalid_instruction; | 26650 | return ira->codegen->invalid_inst_gen; |
| 25766 | | 26651 | |
| 25767 | Buf *field_name = ir_resolve_str(ira, instruction->field_name->child); | 26652 | Buf *field_name = ir_resolve_str(ira, instruction->field_name->child); |
| 25768 | if (field_name == nullptr) | 26653 | if (field_name == nullptr) |
| 25769 | return ira->codegen->invalid_instruction; | 26654 | return ira->codegen->invalid_inst_gen; |
| 25770 | | 26655 | |
| 25771 | bool result; | 26656 | bool result; |
| 25772 | if (container_type->id == ZigTypeIdStruct) { | 26657 | if (container_type->id == ZigTypeIdStruct) { |
| ... | @@ -25776,91 +26661,77 @@ static IrInstruction *ir_analyze_instruction_has_field(IrAnalyze *ira, IrInstruc | ... | @@ -25776,91 +26661,77 @@ static IrInstruction *ir_analyze_instruction_has_field(IrAnalyze *ira, IrInstruc |
| 25776 | } else if (container_type->id == ZigTypeIdUnion) { | 26661 | } else if (container_type->id == ZigTypeIdUnion) { |
| 25777 | result = find_union_type_field(container_type, field_name) != nullptr; | 26662 | result = find_union_type_field(container_type, field_name) != nullptr; |
| 25778 | } else { | 26663 | } else { |
| 25779 | ir_add_error(ira, instruction->container_type, | 26664 | ir_add_error(ira, &instruction->container_type->base, |
| 25780 | buf_sprintf("type '%s' does not support @hasField", buf_ptr(&container_type->name))); | 26665 | buf_sprintf("type '%s' does not support @hasField", buf_ptr(&container_type->name))); |
| 25781 | return ira->codegen->invalid_instruction; | 26666 | return ira->codegen->invalid_inst_gen; |
| 25782 | } | 26667 | } |
| 25783 | return ir_const_bool(ira, &instruction->base, result); | 26668 | return ir_const_bool(ira, &instruction->base.base, result); |
| 25784 | } | 26669 | } |
| 25785 | | 26670 | |
| 25786 | static IrInstruction *ir_analyze_instruction_breakpoint(IrAnalyze *ira, IrInstructionBreakpoint *instruction) { | 26671 | static IrInstGen *ir_analyze_instruction_breakpoint(IrAnalyze *ira, IrInstSrcBreakpoint *instruction) { |
| 25787 | IrInstruction *result = ir_build_breakpoint(&ira->new_irb, | 26672 | return ir_build_breakpoint_gen(ira, &instruction->base.base); |
| 25788 | instruction->base.scope, instruction->base.source_node); | | |
| 25789 | result->value->type = ira->codegen->builtin_types.entry_void; | | |
| 25790 | return result; | | |
| 25791 | } | 26673 | } |
| 25792 | | 26674 | |
| 25793 | static IrInstruction *ir_analyze_instruction_return_address(IrAnalyze *ira, IrInstructionReturnAddress *instruction) { | 26675 | static IrInstGen *ir_analyze_instruction_return_address(IrAnalyze *ira, IrInstSrcReturnAddress *instruction) { |
| 25794 | IrInstruction *result = ir_build_return_address(&ira->new_irb, | 26676 | return ir_build_return_address_gen(ira, &instruction->base.base); |
| 25795 | instruction->base.scope, instruction->base.source_node); | | |
| 25796 | result->value->type = ira->codegen->builtin_types.entry_usize; | | |
| 25797 | return result; | | |
| 25798 | } | 26677 | } |
| 25799 | | 26678 | |
| 25800 | static IrInstruction *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstructionFrameAddress *instruction) { | 26679 | static IrInstGen *ir_analyze_instruction_frame_address(IrAnalyze *ira, IrInstSrcFrameAddress *instruction) { |
| 25801 | IrInstruction *result = ir_build_frame_address(&ira->new_irb, | 26680 | return ir_build_frame_address_gen(ira, &instruction->base.base); |
| 25802 | instruction->base.scope, instruction->base.source_node); | | |
| 25803 | result->value->type = ira->codegen->builtin_types.entry_usize; | | |
| 25804 | return result; | | |
| 25805 | } | 26681 | } |
| 25806 | | 26682 | |
| 25807 | static IrInstruction *ir_analyze_instruction_frame_handle(IrAnalyze *ira, IrInstructionFrameHandle *instruction) { | 26683 | static IrInstGen *ir_analyze_instruction_frame_handle(IrAnalyze *ira, IrInstSrcFrameHandle *instruction) { |
| 25808 | ZigFn *fn = exec_fn_entry(ira->new_irb.exec); | 26684 | ZigFn *fn = ira->new_irb.exec->fn_entry; |
| 25809 | ir_assert(fn != nullptr, &instruction->base); | 26685 | ir_assert(fn != nullptr, &instruction->base.base); |
| 25810 | | 26686 | |
| 25811 | if (fn->inferred_async_node == nullptr) { | 26687 | if (fn->inferred_async_node == nullptr) { |
| 25812 | fn->inferred_async_node = instruction->base.source_node; | 26688 | fn->inferred_async_node = instruction->base.base.source_node; |
| 25813 | } | 26689 | } |
| 25814 | | 26690 | |
| 25815 | ZigType *frame_type = get_fn_frame_type(ira->codegen, fn); | 26691 | ZigType *frame_type = get_fn_frame_type(ira->codegen, fn); |
| 25816 | ZigType *ptr_frame_type = get_pointer_to_type(ira->codegen, frame_type, false); | 26692 | ZigType *ptr_frame_type = get_pointer_to_type(ira->codegen, frame_type, false); |
| 25817 | | 26693 | |
| 25818 | IrInstruction *result = ir_build_handle(&ira->new_irb, instruction->base.scope, instruction->base.source_node); | 26694 | return ir_build_handle_gen(ira, &instruction->base.base, ptr_frame_type); |
| 25819 | result->value->type = ptr_frame_type; | | |
| 25820 | return result; | | |
| 25821 | } | 26695 | } |
| 25822 | | 26696 | |
| 25823 | static IrInstruction *ir_analyze_instruction_frame_type(IrAnalyze *ira, IrInstructionFrameType *instruction) { | 26697 | static IrInstGen *ir_analyze_instruction_frame_type(IrAnalyze *ira, IrInstSrcFrameType *instruction) { |
| 25824 | ZigFn *fn = ir_resolve_fn(ira, instruction->fn->child); | 26698 | ZigFn *fn = ir_resolve_fn(ira, instruction->fn->child); |
| 25825 | if (fn == nullptr) | 26699 | if (fn == nullptr) |
| 25826 | return ira->codegen->invalid_instruction; | 26700 | return ira->codegen->invalid_inst_gen; |
| 25827 | | 26701 | |
| 25828 | if (fn->type_entry->data.fn.is_generic) { | 26702 | if (fn->type_entry->data.fn.is_generic) { |
| 25829 | ir_add_error(ira, &instruction->base, | 26703 | ir_add_error(ira, &instruction->base.base, |
| 25830 | buf_sprintf("@Frame() of generic function")); | 26704 | buf_sprintf("@Frame() of generic function")); |
| 25831 | return ira->codegen->invalid_instruction; | 26705 | return ira->codegen->invalid_inst_gen; |
| 25832 | } | 26706 | } |
| 25833 | | 26707 | |
| 25834 | ZigType *ty = get_fn_frame_type(ira->codegen, fn); | 26708 | ZigType *ty = get_fn_frame_type(ira->codegen, fn); |
| 25835 | return ir_const_type(ira, &instruction->base, ty); | 26709 | return ir_const_type(ira, &instruction->base.base, ty); |
| 25836 | } | 26710 | } |
| 25837 | | 26711 | |
| 25838 | static IrInstruction *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstructionFrameSizeSrc *instruction) { | 26712 | static IrInstGen *ir_analyze_instruction_frame_size(IrAnalyze *ira, IrInstSrcFrameSize *instruction) { |
| 25839 | IrInstruction *fn = instruction->fn->child; | 26713 | IrInstGen *fn = instruction->fn->child; |
| 25840 | if (type_is_invalid(fn->value->type)) | 26714 | if (type_is_invalid(fn->value->type)) |
| 25841 | return ira->codegen->invalid_instruction; | 26715 | return ira->codegen->invalid_inst_gen; |
| 25842 | | 26716 | |
| 25843 | if (fn->value->type->id != ZigTypeIdFn) { | 26717 | if (fn->value->type->id != ZigTypeIdFn) { |
| 25844 | ir_add_error(ira, fn, | 26718 | ir_add_error(ira, &fn->base, |
| 25845 | buf_sprintf("expected function, found '%s'", buf_ptr(&fn->value->type->name))); | 26719 | buf_sprintf("expected function, found '%s'", buf_ptr(&fn->value->type->name))); |
| 25846 | return ira->codegen->invalid_instruction; | 26720 | return ira->codegen->invalid_inst_gen; |
| 25847 | } | 26721 | } |
| 25848 | | 26722 | |
| 25849 | ira->codegen->need_frame_size_prefix_data = true; | 26723 | ira->codegen->need_frame_size_prefix_data = true; |
| 25850 | | 26724 | |
| 25851 | IrInstruction *result = ir_build_frame_size_gen(&ira->new_irb, instruction->base.scope, | 26725 | return ir_build_frame_size_gen(ira, &instruction->base.base, fn); |
| 25852 | instruction->base.source_node, fn); | | |
| 25853 | result->value->type = ira->codegen->builtin_types.entry_usize; | | |
| 25854 | return result; | | |
| 25855 | } | 26726 | } |
| 25856 | | 26727 | |
| 25857 | static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstructionAlignOf *instruction) { | 26728 | static IrInstGen *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstSrcAlignOf *instruction) { |
| 25858 | // Here we create a lazy value in order to avoid resolving the alignment of the type | 26729 | // Here we create a lazy value in order to avoid resolving the alignment of the type |
| 25859 | // immediately. This avoids false positive dependency loops such as: | 26730 | // immediately. This avoids false positive dependency loops such as: |
| 25860 | // const Node = struct { | 26731 | // const Node = struct { |
| 25861 | // field: []align(@alignOf(Node)) Node, | 26732 | // field: []align(@alignOf(Node)) Node, |
| 25862 | // }; | 26733 | // }; |
| 25863 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_num_lit_int); | 26734 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_num_lit_int); |
| 25864 | result->value->special = ConstValSpecialLazy; | 26735 | result->value->special = ConstValSpecialLazy; |
| 25865 | | 26736 | |
| 25866 | LazyValueAlignOf *lazy_align_of = allocate<LazyValueAlignOf>(1, "LazyValueAlignOf"); | 26737 | LazyValueAlignOf *lazy_align_of = allocate<LazyValueAlignOf>(1, "LazyValueAlignOf"); |
| ... | @@ -25870,41 +26741,41 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct | ... | @@ -25870,41 +26741,41 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct |
| 25870 | | 26741 | |
| 25871 | lazy_align_of->target_type = instruction->type_value->child; | 26742 | lazy_align_of->target_type = instruction->type_value->child; |
| 25872 | if (ir_resolve_type_lazy(ira, lazy_align_of->target_type) == nullptr) | 26743 | if (ir_resolve_type_lazy(ira, lazy_align_of->target_type) == nullptr) |
| 25873 | return ira->codegen->invalid_instruction; | 26744 | return ira->codegen->invalid_inst_gen; |
| 25874 | | 26745 | |
| 25875 | return result; | 26746 | return result; |
| 25876 | } | 26747 | } |
| 25877 | | 26748 | |
| 25878 | static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstructionOverflowOp *instruction) { | 26749 | static IrInstGen *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstSrcOverflowOp *instruction) { |
| 25879 | Error err; | 26750 | Error err; |
| 25880 | | 26751 | |
| 25881 | IrInstruction *type_value = instruction->type_value->child; | 26752 | IrInstGen *type_value = instruction->type_value->child; |
| 25882 | if (type_is_invalid(type_value->value->type)) | 26753 | if (type_is_invalid(type_value->value->type)) |
| 25883 | return ira->codegen->invalid_instruction; | 26754 | return ira->codegen->invalid_inst_gen; |
| 25884 | | 26755 | |
| 25885 | ZigType *dest_type = ir_resolve_type(ira, type_value); | 26756 | ZigType *dest_type = ir_resolve_type(ira, type_value); |
| 25886 | if (type_is_invalid(dest_type)) | 26757 | if (type_is_invalid(dest_type)) |
| 25887 | return ira->codegen->invalid_instruction; | 26758 | return ira->codegen->invalid_inst_gen; |
| 25888 | | 26759 | |
| 25889 | if (dest_type->id != ZigTypeIdInt) { | 26760 | if (dest_type->id != ZigTypeIdInt) { |
| 25890 | ir_add_error(ira, type_value, | 26761 | ir_add_error(ira, &type_value->base, |
| 25891 | buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); | 26762 | buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); |
| 25892 | return ira->codegen->invalid_instruction; | 26763 | return ira->codegen->invalid_inst_gen; |
| 25893 | } | 26764 | } |
| 25894 | | 26765 | |
| 25895 | IrInstruction *op1 = instruction->op1->child; | 26766 | IrInstGen *op1 = instruction->op1->child; |
| 25896 | if (type_is_invalid(op1->value->type)) | 26767 | if (type_is_invalid(op1->value->type)) |
| 25897 | return ira->codegen->invalid_instruction; | 26768 | return ira->codegen->invalid_inst_gen; |
| 25898 | | 26769 | |
| 25899 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, dest_type); | 26770 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, dest_type); |
| 25900 | if (type_is_invalid(casted_op1->value->type)) | 26771 | if (type_is_invalid(casted_op1->value->type)) |
| 25901 | return ira->codegen->invalid_instruction; | 26772 | return ira->codegen->invalid_inst_gen; |
| 25902 | | 26773 | |
| 25903 | IrInstruction *op2 = instruction->op2->child; | 26774 | IrInstGen *op2 = instruction->op2->child; |
| 25904 | if (type_is_invalid(op2->value->type)) | 26775 | if (type_is_invalid(op2->value->type)) |
| 25905 | return ira->codegen->invalid_instruction; | 26776 | return ira->codegen->invalid_inst_gen; |
| 25906 | | 26777 | |
| 25907 | IrInstruction *casted_op2; | 26778 | IrInstGen *casted_op2; |
| 25908 | if (instruction->op == IrOverflowOpShl) { | 26779 | if (instruction->op == IrOverflowOpShl) { |
| 25909 | ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, | 26780 | ZigType *shift_amt_type = get_smallest_unsigned_int_type(ira->codegen, |
| 25910 | dest_type->data.integral.bit_count - 1); | 26781 | dest_type->data.integral.bit_count - 1); |
| ... | @@ -25913,17 +26784,17 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -25913,17 +26784,17 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 25913 | casted_op2 = ir_implicit_cast(ira, op2, dest_type); | 26784 | casted_op2 = ir_implicit_cast(ira, op2, dest_type); |
| 25914 | } | 26785 | } |
| 25915 | if (type_is_invalid(casted_op2->value->type)) | 26786 | if (type_is_invalid(casted_op2->value->type)) |
| 25916 | return ira->codegen->invalid_instruction; | 26787 | return ira->codegen->invalid_inst_gen; |
| 25917 | | 26788 | |
| 25918 | IrInstruction *result_ptr = instruction->result_ptr->child; | 26789 | IrInstGen *result_ptr = instruction->result_ptr->child; |
| 25919 | if (type_is_invalid(result_ptr->value->type)) | 26790 | if (type_is_invalid(result_ptr->value->type)) |
| 25920 | return ira->codegen->invalid_instruction; | 26791 | return ira->codegen->invalid_inst_gen; |
| 25921 | | 26792 | |
| 25922 | ZigType *expected_ptr_type; | 26793 | ZigType *expected_ptr_type; |
| 25923 | if (result_ptr->value->type->id == ZigTypeIdPointer) { | 26794 | if (result_ptr->value->type->id == ZigTypeIdPointer) { |
| 25924 | uint32_t alignment; | 26795 | uint32_t alignment; |
| 25925 | if ((err = resolve_ptr_align(ira, result_ptr->value->type, &alignment))) | 26796 | if ((err = resolve_ptr_align(ira, result_ptr->value->type, &alignment))) |
| 25926 | return ira->codegen->invalid_instruction; | 26797 | return ira->codegen->invalid_inst_gen; |
| 25927 | expected_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_type, | 26798 | expected_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_type, |
| 25928 | false, result_ptr->value->type->data.pointer.is_volatile, | 26799 | false, result_ptr->value->type->data.pointer.is_volatile, |
| 25929 | PtrLenSingle, | 26800 | PtrLenSingle, |
| ... | @@ -25932,9 +26803,9 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -25932,9 +26803,9 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 25932 | expected_ptr_type = get_pointer_to_type(ira->codegen, dest_type, false); | 26803 | expected_ptr_type = get_pointer_to_type(ira->codegen, dest_type, false); |
| 25933 | } | 26804 | } |
| 25934 | | 26805 | |
| 25935 | IrInstruction *casted_result_ptr = ir_implicit_cast(ira, result_ptr, expected_ptr_type); | 26806 | IrInstGen *casted_result_ptr = ir_implicit_cast(ira, result_ptr, expected_ptr_type); |
| 25936 | if (type_is_invalid(casted_result_ptr->value->type)) | 26807 | if (type_is_invalid(casted_result_ptr->value->type)) |
| 25937 | return ira->codegen->invalid_instruction; | 26808 | return ira->codegen->invalid_inst_gen; |
| 25938 | | 26809 | |
| 25939 | if (instr_is_comptime(casted_op1) && | 26810 | if (instr_is_comptime(casted_op1) && |
| 25940 | instr_is_comptime(casted_op2) && | 26811 | instr_is_comptime(casted_op2) && |
| ... | @@ -25942,22 +26813,22 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -25942,22 +26813,22 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 25942 | { | 26813 | { |
| 25943 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); | 26814 | ZigValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad); |
| 25944 | if (op1_val == nullptr) | 26815 | if (op1_val == nullptr) |
| 25945 | return ira->codegen->invalid_instruction; | 26816 | return ira->codegen->invalid_inst_gen; |
| 25946 | | 26817 | |
| 25947 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); | 26818 | ZigValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad); |
| 25948 | if (op2_val == nullptr) | 26819 | if (op2_val == nullptr) |
| 25949 | return ira->codegen->invalid_instruction; | 26820 | return ira->codegen->invalid_inst_gen; |
| 25950 | | 26821 | |
| 25951 | ZigValue *result_val = ir_resolve_const(ira, casted_result_ptr, UndefBad); | 26822 | ZigValue *result_val = ir_resolve_const(ira, casted_result_ptr, UndefBad); |
| 25952 | if (result_val == nullptr) | 26823 | if (result_val == nullptr) |
| 25953 | return ira->codegen->invalid_instruction; | 26824 | return ira->codegen->invalid_inst_gen; |
| 25954 | | 26825 | |
| 25955 | BigInt *op1_bigint = &op1_val->data.x_bigint; | 26826 | BigInt *op1_bigint = &op1_val->data.x_bigint; |
| 25956 | BigInt *op2_bigint = &op2_val->data.x_bigint; | 26827 | BigInt *op2_bigint = &op2_val->data.x_bigint; |
| 25957 | ZigValue *pointee_val = const_ptr_pointee(ira, ira->codegen, result_val, | 26828 | ZigValue *pointee_val = const_ptr_pointee(ira, ira->codegen, result_val, |
| 25958 | casted_result_ptr->source_node); | 26829 | casted_result_ptr->base.source_node); |
| 25959 | if (pointee_val == nullptr) | 26830 | if (pointee_val == nullptr) |
| 25960 | return ira->codegen->invalid_instruction; | 26831 | return ira->codegen->invalid_inst_gen; |
| 25961 | BigInt *dest_bigint = &pointee_val->data.x_bigint; | 26832 | BigInt *dest_bigint = &pointee_val->data.x_bigint; |
| 25962 | switch (instruction->op) { | 26833 | switch (instruction->op) { |
| 25963 | case IrOverflowOpAdd: | 26834 | case IrOverflowOpAdd: |
| ... | @@ -25984,17 +26855,14 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr | ... | @@ -25984,17 +26855,14 @@ static IrInstruction *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstr |
| 25984 | dest_type->data.integral.is_signed); | 26855 | dest_type->data.integral.is_signed); |
| 25985 | } | 26856 | } |
| 25986 | pointee_val->special = ConstValSpecialStatic; | 26857 | pointee_val->special = ConstValSpecialStatic; |
| 25987 | return ir_const_bool(ira, &instruction->base, result_bool); | 26858 | return ir_const_bool(ira, &instruction->base.base, result_bool); |
| 25988 | } | 26859 | } |
| 25989 | | 26860 | |
| 25990 | IrInstruction *result = ir_build_overflow_op(&ira->new_irb, | 26861 | return ir_build_overflow_op_gen(ira, &instruction->base.base, instruction->op, |
| 25991 | instruction->base.scope, instruction->base.source_node, | 26862 | casted_op1, casted_op2, casted_result_ptr, dest_type); |
| 25992 | instruction->op, type_value, casted_op1, casted_op2, casted_result_ptr, dest_type); | | |
| 25993 | result->value->type = ira->codegen->builtin_types.entry_bool; | | |
| 25994 | return result; | | |
| 25995 | } | 26863 | } |
| 25996 | | 26864 | |
| 25997 | static void ir_eval_mul_add(IrAnalyze *ira, IrInstructionMulAdd *source_instr, ZigType *float_type, | 26865 | static void ir_eval_mul_add(IrAnalyze *ira, IrInstSrcMulAdd *source_instr, ZigType *float_type, |
| 25998 | ZigValue *op1, ZigValue *op2, ZigValue *op3, ZigValue *out_val) { | 26866 | ZigValue *op1, ZigValue *op2, ZigValue *op3, ZigValue *out_val) { |
| 25999 | if (float_type->id == ZigTypeIdComptimeFloat) { | 26867 | if (float_type->id == ZigTypeIdComptimeFloat) { |
| 26000 | f128M_mulAdd(&out_val->data.x_bigfloat.value, &op1->data.x_bigfloat.value, &op2->data.x_bigfloat.value, | 26868 | f128M_mulAdd(&out_val->data.x_bigfloat.value, &op1->data.x_bigfloat.value, &op2->data.x_bigfloat.value, |
| ... | @@ -26021,61 +26889,61 @@ static void ir_eval_mul_add(IrAnalyze *ira, IrInstructionMulAdd *source_instr, Z | ... | @@ -26021,61 +26889,61 @@ static void ir_eval_mul_add(IrAnalyze *ira, IrInstructionMulAdd *source_instr, Z |
| 26021 | } | 26889 | } |
| 26022 | } | 26890 | } |
| 26023 | | 26891 | |
| 26024 | static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructionMulAdd *instruction) { | 26892 | static IrInstGen *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstSrcMulAdd *instruction) { |
| 26025 | IrInstruction *type_value = instruction->type_value->child; | 26893 | IrInstGen *type_value = instruction->type_value->child; |
| 26026 | if (type_is_invalid(type_value->value->type)) | 26894 | if (type_is_invalid(type_value->value->type)) |
| 26027 | return ira->codegen->invalid_instruction; | 26895 | return ira->codegen->invalid_inst_gen; |
| 26028 | | 26896 | |
| 26029 | ZigType *expr_type = ir_resolve_type(ira, type_value); | 26897 | ZigType *expr_type = ir_resolve_type(ira, type_value); |
| 26030 | if (type_is_invalid(expr_type)) | 26898 | if (type_is_invalid(expr_type)) |
| 26031 | return ira->codegen->invalid_instruction; | 26899 | return ira->codegen->invalid_inst_gen; |
| 26032 | | 26900 | |
| 26033 | // Only allow float types, and vectors of floats. | 26901 | // Only allow float types, and vectors of floats. |
| 26034 | ZigType *float_type = (expr_type->id == ZigTypeIdVector) ? expr_type->data.vector.elem_type : expr_type; | 26902 | ZigType *float_type = (expr_type->id == ZigTypeIdVector) ? expr_type->data.vector.elem_type : expr_type; |
| 26035 | if (float_type->id != ZigTypeIdFloat) { | 26903 | if (float_type->id != ZigTypeIdFloat) { |
| 26036 | ir_add_error(ira, type_value, | 26904 | ir_add_error(ira, &type_value->base, |
| 26037 | buf_sprintf("expected float or vector of float type, found '%s'", buf_ptr(&float_type->name))); | 26905 | buf_sprintf("expected float or vector of float type, found '%s'", buf_ptr(&float_type->name))); |
| 26038 | return ira->codegen->invalid_instruction; | 26906 | return ira->codegen->invalid_inst_gen; |
| 26039 | } | 26907 | } |
| 26040 | | 26908 | |
| 26041 | IrInstruction *op1 = instruction->op1->child; | 26909 | IrInstGen *op1 = instruction->op1->child; |
| 26042 | if (type_is_invalid(op1->value->type)) | 26910 | if (type_is_invalid(op1->value->type)) |
| 26043 | return ira->codegen->invalid_instruction; | 26911 | return ira->codegen->invalid_inst_gen; |
| 26044 | | 26912 | |
| 26045 | IrInstruction *casted_op1 = ir_implicit_cast(ira, op1, expr_type); | 26913 | IrInstGen *casted_op1 = ir_implicit_cast(ira, op1, expr_type); |
| 26046 | if (type_is_invalid(casted_op1->value->type)) | 26914 | if (type_is_invalid(casted_op1->value->type)) |
| 26047 | return ira->codegen->invalid_instruction; | 26915 | return ira->codegen->invalid_inst_gen; |
| 26048 | | 26916 | |
| 26049 | IrInstruction *op2 = instruction->op2->child; | 26917 | IrInstGen *op2 = instruction->op2->child; |
| 26050 | if (type_is_invalid(op2->value->type)) | 26918 | if (type_is_invalid(op2->value->type)) |
| 26051 | return ira->codegen->invalid_instruction; | 26919 | return ira->codegen->invalid_inst_gen; |
| 26052 | | 26920 | |
| 26053 | IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, expr_type); | 26921 | IrInstGen *casted_op2 = ir_implicit_cast(ira, op2, expr_type); |
| 26054 | if (type_is_invalid(casted_op2->value->type)) | 26922 | if (type_is_invalid(casted_op2->value->type)) |
| 26055 | return ira->codegen->invalid_instruction; | 26923 | return ira->codegen->invalid_inst_gen; |
| 26056 | | 26924 | |
| 26057 | IrInstruction *op3 = instruction->op3->child; | 26925 | IrInstGen *op3 = instruction->op3->child; |
| 26058 | if (type_is_invalid(op3->value->type)) | 26926 | if (type_is_invalid(op3->value->type)) |
| 26059 | return ira->codegen->invalid_instruction; | 26927 | return ira->codegen->invalid_inst_gen; |
| 26060 | | 26928 | |
| 26061 | IrInstruction *casted_op3 = ir_implicit_cast(ira, op3, expr_type); | 26929 | IrInstGen *casted_op3 = ir_implicit_cast(ira, op3, expr_type); |
| 26062 | if (type_is_invalid(casted_op3->value->type)) | 26930 | if (type_is_invalid(casted_op3->value->type)) |
| 26063 | return ira->codegen->invalid_instruction; | 26931 | return ira->codegen->invalid_inst_gen; |
| 26064 | | 26932 | |
| 26065 | if (instr_is_comptime(casted_op1) && | 26933 | if (instr_is_comptime(casted_op1) && |
| 26066 | instr_is_comptime(casted_op2) && | 26934 | instr_is_comptime(casted_op2) && |
| 26067 | instr_is_comptime(casted_op3)) { | 26935 | instr_is_comptime(casted_op3)) { |
| 26068 | ZigValue *op1_const = ir_resolve_const(ira, casted_op1, UndefBad); | 26936 | ZigValue *op1_const = ir_resolve_const(ira, casted_op1, UndefBad); |
| 26069 | if (!op1_const) | 26937 | if (!op1_const) |
| 26070 | return ira->codegen->invalid_instruction; | 26938 | return ira->codegen->invalid_inst_gen; |
| 26071 | ZigValue *op2_const = ir_resolve_const(ira, casted_op2, UndefBad); | 26939 | ZigValue *op2_const = ir_resolve_const(ira, casted_op2, UndefBad); |
| 26072 | if (!op2_const) | 26940 | if (!op2_const) |
| 26073 | return ira->codegen->invalid_instruction; | 26941 | return ira->codegen->invalid_inst_gen; |
| 26074 | ZigValue *op3_const = ir_resolve_const(ira, casted_op3, UndefBad); | 26942 | ZigValue *op3_const = ir_resolve_const(ira, casted_op3, UndefBad); |
| 26075 | if (!op3_const) | 26943 | if (!op3_const) |
| 26076 | return ira->codegen->invalid_instruction; | 26944 | return ira->codegen->invalid_inst_gen; |
| 26077 | | 26945 | |
| 26078 | IrInstruction *result = ir_const(ira, &instruction->base, expr_type); | 26946 | IrInstGen *result = ir_const(ira, &instruction->base.base, expr_type); |
| 26079 | ZigValue *out_val = result->value; | 26947 | ZigValue *out_val = result->value; |
| 26080 | | 26948 | |
| 26081 | if (expr_type->id == ZigTypeIdVector) { | 26949 | if (expr_type->id == ZigTypeIdVector) { |
| ... | @@ -26106,63 +26974,59 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi | ... | @@ -26106,63 +26974,59 @@ static IrInstruction *ir_analyze_instruction_mul_add(IrAnalyze *ira, IrInstructi |
| 26106 | return result; | 26974 | return result; |
| 26107 | } | 26975 | } |
| 26108 | | 26976 | |
| 26109 | IrInstruction *result = ir_build_mul_add(&ira->new_irb, | 26977 | return ir_build_mul_add_gen(ira, &instruction->base.base, casted_op1, casted_op2, casted_op3, expr_type); |
| 26110 | instruction->base.scope, instruction->base.source_node, | | |
| 26111 | type_value, casted_op1, casted_op2, casted_op3); | | |
| 26112 | result->value->type = expr_type; | | |
| 26113 | return result; | | |
| 26114 | } | 26978 | } |
| 26115 | | 26979 | |
| 26116 | static IrInstruction *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstructionTestErrSrc *instruction) { | 26980 | static IrInstGen *ir_analyze_instruction_test_err(IrAnalyze *ira, IrInstSrcTestErr *instruction) { |
| 26117 | IrInstruction *base_ptr = instruction->base_ptr->child; | 26981 | IrInstGen *base_ptr = instruction->base_ptr->child; |
| 26118 | if (type_is_invalid(base_ptr->value->type)) | 26982 | if (type_is_invalid(base_ptr->value->type)) |
| 26119 | return ira->codegen->invalid_instruction; | 26983 | return ira->codegen->invalid_inst_gen; |
| 26120 | | 26984 | |
| 26121 | IrInstruction *value; | 26985 | IrInstGen *value; |
| 26122 | if (instruction->base_ptr_is_payload) { | 26986 | if (instruction->base_ptr_is_payload) { |
| 26123 | value = base_ptr; | 26987 | value = base_ptr; |
| 26124 | } else { | 26988 | } else { |
| 26125 | value = ir_get_deref(ira, &instruction->base, base_ptr, nullptr); | 26989 | value = ir_get_deref(ira, &instruction->base.base, base_ptr, nullptr); |
| 26126 | } | 26990 | } |
| 26127 | | 26991 | |
| 26128 | ZigType *type_entry = value->value->type; | 26992 | ZigType *type_entry = value->value->type; |
| 26129 | if (type_is_invalid(type_entry)) | 26993 | if (type_is_invalid(type_entry)) |
| 26130 | return ira->codegen->invalid_instruction; | 26994 | return ira->codegen->invalid_inst_gen; |
| 26131 | if (type_entry->id == ZigTypeIdErrorUnion) { | 26995 | if (type_entry->id == ZigTypeIdErrorUnion) { |
| 26132 | if (instr_is_comptime(value)) { | 26996 | if (instr_is_comptime(value)) { |
| 26133 | ZigValue *err_union_val = ir_resolve_const(ira, value, UndefBad); | 26997 | ZigValue *err_union_val = ir_resolve_const(ira, value, UndefBad); |
| 26134 | if (!err_union_val) | 26998 | if (!err_union_val) |
| 26135 | return ira->codegen->invalid_instruction; | 26999 | return ira->codegen->invalid_inst_gen; |
| 26136 | | 27000 | |
| 26137 | if (err_union_val->special != ConstValSpecialRuntime) { | 27001 | if (err_union_val->special != ConstValSpecialRuntime) { |
| 26138 | ErrorTableEntry *err = err_union_val->data.x_err_union.error_set->data.x_err_set; | 27002 | ErrorTableEntry *err = err_union_val->data.x_err_union.error_set->data.x_err_set; |
| 26139 | return ir_const_bool(ira, &instruction->base, (err != nullptr)); | 27003 | return ir_const_bool(ira, &instruction->base.base, (err != nullptr)); |
| 26140 | } | 27004 | } |
| 26141 | } | 27005 | } |
| 26142 | | 27006 | |
| 26143 | if (instruction->resolve_err_set) { | 27007 | if (instruction->resolve_err_set) { |
| 26144 | ZigType *err_set_type = type_entry->data.error_union.err_set_type; | 27008 | ZigType *err_set_type = type_entry->data.error_union.err_set_type; |
| 26145 | if (!resolve_inferred_error_set(ira->codegen, err_set_type, instruction->base.source_node)) { | 27009 | if (!resolve_inferred_error_set(ira->codegen, err_set_type, instruction->base.base.source_node)) { |
| 26146 | return ira->codegen->invalid_instruction; | 27010 | return ira->codegen->invalid_inst_gen; |
| 26147 | } | 27011 | } |
| 26148 | if (!type_is_global_error_set(err_set_type) && | 27012 | if (!type_is_global_error_set(err_set_type) && |
| 26149 | err_set_type->data.error_set.err_count == 0) | 27013 | err_set_type->data.error_set.err_count == 0) |
| 26150 | { | 27014 | { |
| 26151 | assert(!err_set_type->data.error_set.incomplete); | 27015 | assert(!err_set_type->data.error_set.incomplete); |
| 26152 | return ir_const_bool(ira, &instruction->base, false); | 27016 | return ir_const_bool(ira, &instruction->base.base, false); |
| 26153 | } | 27017 | } |
| 26154 | } | 27018 | } |
| 26155 | | 27019 | |
| 26156 | return ir_build_test_err_gen(ira, &instruction->base, value); | 27020 | return ir_build_test_err_gen(ira, &instruction->base.base, value); |
| 26157 | } else if (type_entry->id == ZigTypeIdErrorSet) { | 27021 | } else if (type_entry->id == ZigTypeIdErrorSet) { |
| 26158 | return ir_const_bool(ira, &instruction->base, true); | 27022 | return ir_const_bool(ira, &instruction->base.base, true); |
| 26159 | } else { | 27023 | } else { |
| 26160 | return ir_const_bool(ira, &instruction->base, false); | 27024 | return ir_const_bool(ira, &instruction->base.base, false); |
| 26161 | } | 27025 | } |
| 26162 | } | 27026 | } |
| 26163 | | 27027 | |
| 26164 | static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction *source_instr, | 27028 | static IrInstGen *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInst* source_instr, |
| 26165 | IrInstruction *base_ptr, bool initializing) | 27029 | IrInstGen *base_ptr, bool initializing) |
| 26166 | { | 27030 | { |
| 26167 | ZigType *ptr_type = base_ptr->value->type; | 27031 | ZigType *ptr_type = base_ptr->value->type; |
| 26168 | | 27032 | |
| ... | @@ -26171,12 +27035,12 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * | ... | @@ -26171,12 +27035,12 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * |
| 26171 | | 27035 | |
| 26172 | ZigType *type_entry = ptr_type->data.pointer.child_type; | 27036 | ZigType *type_entry = ptr_type->data.pointer.child_type; |
| 26173 | if (type_is_invalid(type_entry)) | 27037 | if (type_is_invalid(type_entry)) |
| 26174 | return ira->codegen->invalid_instruction; | 27038 | return ira->codegen->invalid_inst_gen; |
| 26175 | | 27039 | |
| 26176 | if (type_entry->id != ZigTypeIdErrorUnion) { | 27040 | if (type_entry->id != ZigTypeIdErrorUnion) { |
| 26177 | ir_add_error(ira, base_ptr, | 27041 | ir_add_error(ira, &base_ptr->base, |
| 26178 | buf_sprintf("expected error union type, found '%s'", buf_ptr(&type_entry->name))); | 27042 | buf_sprintf("expected error union type, found '%s'", buf_ptr(&type_entry->name))); |
| 26179 | return ira->codegen->invalid_instruction; | 27043 | return ira->codegen->invalid_inst_gen; |
| 26180 | } | 27044 | } |
| 26181 | | 27045 | |
| 26182 | ZigType *err_set_type = type_entry->data.error_union.err_set_type; | 27046 | ZigType *err_set_type = type_entry->data.error_union.err_set_type; |
| ... | @@ -26187,13 +27051,13 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * | ... | @@ -26187,13 +27051,13 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * |
| 26187 | if (instr_is_comptime(base_ptr)) { | 27051 | if (instr_is_comptime(base_ptr)) { |
| 26188 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); | 27052 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); |
| 26189 | if (!ptr_val) | 27053 | if (!ptr_val) |
| 26190 | return ira->codegen->invalid_instruction; | 27054 | return ira->codegen->invalid_inst_gen; |
| 26191 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar && | 27055 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar && |
| 26192 | ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) | 27056 | ptr_val->data.x_ptr.special != ConstPtrSpecialHardCodedAddr) |
| 26193 | { | 27057 | { |
| 26194 | ZigValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 27058 | ZigValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 26195 | if (err_union_val == nullptr) | 27059 | if (err_union_val == nullptr) |
| 26196 | return ira->codegen->invalid_instruction; | 27060 | return ira->codegen->invalid_inst_gen; |
| 26197 | | 27061 | |
| 26198 | if (initializing && err_union_val->special == ConstValSpecialUndef) { | 27062 | if (initializing && err_union_val->special == ConstValSpecialUndef) { |
| 26199 | ZigValue *vals = create_const_vals(2); | 27063 | ZigValue *vals = create_const_vals(2); |
| ... | @@ -26216,11 +27080,10 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * | ... | @@ -26216,11 +27080,10 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * |
| 26216 | } | 27080 | } |
| 26217 | ir_assert(err_union_val->special != ConstValSpecialRuntime, source_instr); | 27081 | ir_assert(err_union_val->special != ConstValSpecialRuntime, source_instr); |
| 26218 | | 27082 | |
| 26219 | IrInstruction *result; | 27083 | IrInstGen *result; |
| 26220 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 27084 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 26221 | result = ir_build_unwrap_err_code(&ira->new_irb, source_instr->scope, | 27085 | result = ir_build_unwrap_err_code_gen(ira, source_instr->scope, |
| 26222 | source_instr->source_node, base_ptr); | 27086 | source_instr->source_node, base_ptr, result_type); |
| 26223 | result->value->type = result_type; | | |
| 26224 | result->value->special = ConstValSpecialStatic; | 27087 | result->value->special = ConstValSpecialStatic; |
| 26225 | } else { | 27088 | } else { |
| 26226 | result = ir_const(ira, source_instr, result_type); | 27089 | result = ir_const(ira, source_instr, result_type); |
| ... | @@ -26233,23 +27096,18 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * | ... | @@ -26233,23 +27096,18 @@ static IrInstruction *ir_analyze_unwrap_err_code(IrAnalyze *ira, IrInstruction * |
| 26233 | } | 27096 | } |
| 26234 | } | 27097 | } |
| 26235 | | 27098 | |
| 26236 | IrInstruction *result = ir_build_unwrap_err_code(&ira->new_irb, | 27099 | return ir_build_unwrap_err_code_gen(ira, source_instr->scope, source_instr->source_node, base_ptr, result_type); |
| 26237 | source_instr->scope, source_instr->source_node, base_ptr); | | |
| 26238 | result->value->type = result_type; | | |
| 26239 | return result; | | |
| 26240 | } | 27100 | } |
| 26241 | | 27101 | |
| 26242 | static IrInstruction *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, | 27102 | static IrInstGen *ir_analyze_instruction_unwrap_err_code(IrAnalyze *ira, IrInstSrcUnwrapErrCode *instruction) { |
| 26243 | IrInstructionUnwrapErrCode *instruction) | 27103 | IrInstGen *base_ptr = instruction->err_union_ptr->child; |
| 26244 | { | | |
| 26245 | IrInstruction *base_ptr = instruction->err_union_ptr->child; | | |
| 26246 | if (type_is_invalid(base_ptr->value->type)) | 27104 | if (type_is_invalid(base_ptr->value->type)) |
| 26247 | return ira->codegen->invalid_instruction; | 27105 | return ira->codegen->invalid_inst_gen; |
| 26248 | return ir_analyze_unwrap_err_code(ira, &instruction->base, base_ptr, false); | 27106 | return ir_analyze_unwrap_err_code(ira, &instruction->base.base, base_ptr, false); |
| 26249 | } | 27107 | } |
| 26250 | | 27108 | |
| 26251 | static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruction *source_instr, | 27109 | static IrInstGen *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInst* source_instr, |
| 26252 | IrInstruction *base_ptr, bool safety_check_on, bool initializing) | 27110 | IrInstGen *base_ptr, bool safety_check_on, bool initializing) |
| 26253 | { | 27111 | { |
| 26254 | ZigType *ptr_type = base_ptr->value->type; | 27112 | ZigType *ptr_type = base_ptr->value->type; |
| 26255 | | 27113 | |
| ... | @@ -26258,17 +27116,17 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct | ... | @@ -26258,17 +27116,17 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct |
| 26258 | | 27116 | |
| 26259 | ZigType *type_entry = ptr_type->data.pointer.child_type; | 27117 | ZigType *type_entry = ptr_type->data.pointer.child_type; |
| 26260 | if (type_is_invalid(type_entry)) | 27118 | if (type_is_invalid(type_entry)) |
| 26261 | return ira->codegen->invalid_instruction; | 27119 | return ira->codegen->invalid_inst_gen; |
| 26262 | | 27120 | |
| 26263 | if (type_entry->id != ZigTypeIdErrorUnion) { | 27121 | if (type_entry->id != ZigTypeIdErrorUnion) { |
| 26264 | ir_add_error(ira, base_ptr, | 27122 | ir_add_error(ira, &base_ptr->base, |
| 26265 | buf_sprintf("expected error union type, found '%s'", buf_ptr(&type_entry->name))); | 27123 | buf_sprintf("expected error union type, found '%s'", buf_ptr(&type_entry->name))); |
| 26266 | return ira->codegen->invalid_instruction; | 27124 | return ira->codegen->invalid_inst_gen; |
| 26267 | } | 27125 | } |
| 26268 | | 27126 | |
| 26269 | ZigType *payload_type = type_entry->data.error_union.payload_type; | 27127 | ZigType *payload_type = type_entry->data.error_union.payload_type; |
| 26270 | if (type_is_invalid(payload_type)) | 27128 | if (type_is_invalid(payload_type)) |
| 26271 | return ira->codegen->invalid_instruction; | 27129 | return ira->codegen->invalid_inst_gen; |
| 26272 | | 27130 | |
| 26273 | ZigType *result_type = get_pointer_to_type_extra(ira->codegen, payload_type, | 27131 | ZigType *result_type = get_pointer_to_type_extra(ira->codegen, payload_type, |
| 26274 | ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile, | 27132 | ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile, |
| ... | @@ -26277,11 +27135,11 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct | ... | @@ -26277,11 +27135,11 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct |
| 26277 | if (instr_is_comptime(base_ptr)) { | 27135 | if (instr_is_comptime(base_ptr)) { |
| 26278 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); | 27136 | ZigValue *ptr_val = ir_resolve_const(ira, base_ptr, UndefBad); |
| 26279 | if (!ptr_val) | 27137 | if (!ptr_val) |
| 26280 | return ira->codegen->invalid_instruction; | 27138 | return ira->codegen->invalid_inst_gen; |
| 26281 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 27139 | if (ptr_val->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 26282 | ZigValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); | 27140 | ZigValue *err_union_val = const_ptr_pointee(ira, ira->codegen, ptr_val, source_instr->source_node); |
| 26283 | if (err_union_val == nullptr) | 27141 | if (err_union_val == nullptr) |
| 26284 | return ira->codegen->invalid_instruction; | 27142 | return ira->codegen->invalid_inst_gen; |
| 26285 | if (initializing && err_union_val->special == ConstValSpecialUndef) { | 27143 | if (initializing && err_union_val->special == ConstValSpecialUndef) { |
| 26286 | ZigValue *vals = create_const_vals(2); | 27144 | ZigValue *vals = create_const_vals(2); |
| 26287 | ZigValue *err_set_val = &vals[0]; | 27145 | ZigValue *err_set_val = &vals[0]; |
| ... | @@ -26304,14 +27162,13 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct | ... | @@ -26304,14 +27162,13 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct |
| 26304 | if (err != nullptr) { | 27162 | if (err != nullptr) { |
| 26305 | ir_add_error(ira, source_instr, | 27163 | ir_add_error(ira, source_instr, |
| 26306 | buf_sprintf("caught unexpected error '%s'", buf_ptr(&err->name))); | 27164 | buf_sprintf("caught unexpected error '%s'", buf_ptr(&err->name))); |
| 26307 | return ira->codegen->invalid_instruction; | 27165 | return ira->codegen->invalid_inst_gen; |
| 26308 | } | 27166 | } |
| 26309 | | 27167 | |
| 26310 | IrInstruction *result; | 27168 | IrInstGen *result; |
| 26311 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { | 27169 | if (ptr_val->data.x_ptr.mut == ConstPtrMutInfer) { |
| 26312 | result = ir_build_unwrap_err_payload(&ira->new_irb, source_instr->scope, | 27170 | result = ir_build_unwrap_err_payload_gen(ira, source_instr->scope, |
| 26313 | source_instr->source_node, base_ptr, safety_check_on, initializing); | 27171 | source_instr->source_node, base_ptr, safety_check_on, initializing, result_type); |
| 26314 | result->value->type = result_type; | | |
| 26315 | result->value->special = ConstValSpecialStatic; | 27172 | result->value->special = ConstValSpecialStatic; |
| 26316 | } else { | 27173 | } else { |
| 26317 | result = ir_const(ira, source_instr, result_type); | 27174 | result = ir_const(ira, source_instr, result_type); |
| ... | @@ -26324,28 +27181,26 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct | ... | @@ -26324,28 +27181,26 @@ static IrInstruction *ir_analyze_unwrap_error_payload(IrAnalyze *ira, IrInstruct |
| 26324 | } | 27181 | } |
| 26325 | } | 27182 | } |
| 26326 | | 27183 | |
| 26327 | IrInstruction *result = ir_build_unwrap_err_payload(&ira->new_irb, source_instr->scope, | 27184 | return ir_build_unwrap_err_payload_gen(ira, source_instr->scope, source_instr->source_node, |
| 26328 | source_instr->source_node, base_ptr, safety_check_on, initializing); | 27185 | base_ptr, safety_check_on, initializing, result_type); |
| 26329 | result->value->type = result_type; | | |
| 26330 | return result; | | |
| 26331 | } | 27186 | } |
| 26332 | | 27187 | |
| 26333 | static IrInstruction *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, | 27188 | static IrInstGen *ir_analyze_instruction_unwrap_err_payload(IrAnalyze *ira, |
| 26334 | IrInstructionUnwrapErrPayload *instruction) | 27189 | IrInstSrcUnwrapErrPayload *instruction) |
| 26335 | { | 27190 | { |
| 26336 | assert(instruction->value->child); | 27191 | assert(instruction->value->child); |
| 26337 | IrInstruction *value = instruction->value->child; | 27192 | IrInstGen *value = instruction->value->child; |
| 26338 | if (type_is_invalid(value->value->type)) | 27193 | if (type_is_invalid(value->value->type)) |
| 26339 | return ira->codegen->invalid_instruction; | 27194 | return ira->codegen->invalid_inst_gen; |
| 26340 | | 27195 | |
| 26341 | return ir_analyze_unwrap_error_payload(ira, &instruction->base, value, instruction->safety_check_on, false); | 27196 | return ir_analyze_unwrap_error_payload(ira, &instruction->base.base, value, instruction->safety_check_on, false); |
| 26342 | } | 27197 | } |
| 26343 | | 27198 | |
| 26344 | static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstructionFnProto *instruction) { | 27199 | static IrInstGen *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstSrcFnProto *instruction) { |
| 26345 | AstNode *proto_node = instruction->base.source_node; | 27200 | AstNode *proto_node = instruction->base.base.source_node; |
| 26346 | assert(proto_node->type == NodeTypeFnProto); | 27201 | assert(proto_node->type == NodeTypeFnProto); |
| 26347 | | 27202 | |
| 26348 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); | 27203 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 26349 | result->value->special = ConstValSpecialLazy; | 27204 | result->value->special = ConstValSpecialLazy; |
| 26350 | | 27205 | |
| 26351 | LazyValueFnType *lazy_fn_type = allocate<LazyValueFnType>(1, "LazyValueFnType"); | 27206 | LazyValueFnType *lazy_fn_type = allocate<LazyValueFnType>(1, "LazyValueFnType"); |
| ... | @@ -26354,29 +27209,29 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -26354,29 +27209,29 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 26354 | lazy_fn_type->base.id = LazyValueIdFnType; | 27209 | lazy_fn_type->base.id = LazyValueIdFnType; |
| 26355 | | 27210 | |
| 26356 | if (proto_node->data.fn_proto.auto_err_set) { | 27211 | if (proto_node->data.fn_proto.auto_err_set) { |
| 26357 | ir_add_error(ira, &instruction->base, | 27212 | ir_add_error(ira, &instruction->base.base, |
| 26358 | buf_sprintf("inferring error set of return type valid only for function definitions")); | 27213 | buf_sprintf("inferring error set of return type valid only for function definitions")); |
| 26359 | return ira->codegen->invalid_instruction; | 27214 | return ira->codegen->invalid_inst_gen; |
| 26360 | } | 27215 | } |
| 26361 | | 27216 | |
| 26362 | lazy_fn_type->cc = cc_from_fn_proto(&proto_node->data.fn_proto); | 27217 | lazy_fn_type->cc = cc_from_fn_proto(&proto_node->data.fn_proto); |
| 26363 | if (instruction->callconv_value != nullptr) { | 27218 | if (instruction->callconv_value != nullptr) { |
| 26364 | ZigType *cc_enum_type = get_builtin_type(ira->codegen, "CallingConvention"); | 27219 | ZigType *cc_enum_type = get_builtin_type(ira->codegen, "CallingConvention"); |
| 26365 | | 27220 | |
| 26366 | IrInstruction *casted_value = ir_implicit_cast(ira, instruction->callconv_value, cc_enum_type); | 27221 | IrInstGen *casted_value = ir_implicit_cast(ira, instruction->callconv_value->child, cc_enum_type); |
| 26367 | if (type_is_invalid(casted_value->value->type)) | 27222 | if (type_is_invalid(casted_value->value->type)) |
| 26368 | return ira->codegen->invalid_instruction; | 27223 | return ira->codegen->invalid_inst_gen; |
| 26369 | | 27224 | |
| 26370 | ZigValue *const_value = ir_resolve_const(ira, casted_value, UndefBad); | 27225 | ZigValue *const_value = ir_resolve_const(ira, casted_value, UndefBad); |
| 26371 | if (const_value == nullptr) | 27226 | if (const_value == nullptr) |
| 26372 | return ira->codegen->invalid_instruction; | 27227 | return ira->codegen->invalid_inst_gen; |
| 26373 | | 27228 | |
| 26374 | lazy_fn_type->cc = (CallingConvention)bigint_as_u32(&const_value->data.x_enum_tag); | 27229 | lazy_fn_type->cc = (CallingConvention)bigint_as_u32(&const_value->data.x_enum_tag); |
| 26375 | } | 27230 | } |
| 26376 | | 27231 | |
| 26377 | size_t param_count = proto_node->data.fn_proto.params.length; | 27232 | size_t param_count = proto_node->data.fn_proto.params.length; |
| 26378 | lazy_fn_type->proto_node = proto_node; | 27233 | lazy_fn_type->proto_node = proto_node; |
| 26379 | lazy_fn_type->param_types = allocate<IrInstruction *>(param_count); | 27234 | lazy_fn_type->param_types = allocate<IrInstGen *>(param_count); |
| 26380 | | 27235 | |
| 26381 | for (size_t param_index = 0; param_index < param_count; param_index += 1) { | 27236 | for (size_t param_index = 0; param_index < param_count; param_index += 1) { |
| 26382 | AstNode *param_node = proto_node->data.fn_proto.params.at(param_index); | 27237 | AstNode *param_node = proto_node->data.fn_proto.params.at(param_index); |
| ... | @@ -26401,63 +27256,63 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct | ... | @@ -26401,63 +27256,63 @@ static IrInstruction *ir_analyze_instruction_fn_proto(IrAnalyze *ira, IrInstruct |
| 26401 | return result; | 27256 | return result; |
| 26402 | } | 27257 | } |
| 26403 | | 27258 | |
| 26404 | IrInstruction *param_type_value = instruction->param_types[param_index]->child; | 27259 | IrInstGen *param_type_value = instruction->param_types[param_index]->child; |
| 26405 | if (type_is_invalid(param_type_value->value->type)) | 27260 | if (type_is_invalid(param_type_value->value->type)) |
| 26406 | return ira->codegen->invalid_instruction; | 27261 | return ira->codegen->invalid_inst_gen; |
| 26407 | if (ir_resolve_const(ira, param_type_value, LazyOk) == nullptr) | 27262 | if (ir_resolve_const(ira, param_type_value, LazyOk) == nullptr) |
| 26408 | return ira->codegen->invalid_instruction; | 27263 | return ira->codegen->invalid_inst_gen; |
| 26409 | lazy_fn_type->param_types[param_index] = param_type_value; | 27264 | lazy_fn_type->param_types[param_index] = param_type_value; |
| 26410 | } | 27265 | } |
| 26411 | | 27266 | |
| 26412 | if (instruction->align_value != nullptr) { | 27267 | if (instruction->align_value != nullptr) { |
| 26413 | lazy_fn_type->align_inst = instruction->align_value->child; | 27268 | lazy_fn_type->align_inst = instruction->align_value->child; |
| 26414 | if (ir_resolve_const(ira, lazy_fn_type->align_inst, LazyOk) == nullptr) | 27269 | if (ir_resolve_const(ira, lazy_fn_type->align_inst, LazyOk) == nullptr) |
| 26415 | return ira->codegen->invalid_instruction; | 27270 | return ira->codegen->invalid_inst_gen; |
| 26416 | } | 27271 | } |
| 26417 | | 27272 | |
| 26418 | lazy_fn_type->return_type = instruction->return_type->child; | 27273 | lazy_fn_type->return_type = instruction->return_type->child; |
| 26419 | if (ir_resolve_const(ira, lazy_fn_type->return_type, LazyOk) == nullptr) | 27274 | if (ir_resolve_const(ira, lazy_fn_type->return_type, LazyOk) == nullptr) |
| 26420 | return ira->codegen->invalid_instruction; | 27275 | return ira->codegen->invalid_inst_gen; |
| 26421 | | 27276 | |
| 26422 | return result; | 27277 | return result; |
| 26423 | } | 27278 | } |
| 26424 | | 27279 | |
| 26425 | static IrInstruction *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrInstructionTestComptime *instruction) { | 27280 | static IrInstGen *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrInstSrcTestComptime *instruction) { |
| 26426 | IrInstruction *value = instruction->value->child; | 27281 | IrInstGen *value = instruction->value->child; |
| 26427 | if (type_is_invalid(value->value->type)) | 27282 | if (type_is_invalid(value->value->type)) |
| 26428 | return ira->codegen->invalid_instruction; | 27283 | return ira->codegen->invalid_inst_gen; |
| 26429 | | 27284 | |
| 26430 | return ir_const_bool(ira, &instruction->base, instr_is_comptime(value)); | 27285 | return ir_const_bool(ira, &instruction->base.base, instr_is_comptime(value)); |
| 26431 | } | 27286 | } |
| 26432 | | 27287 | |
| 26433 | static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | 27288 | static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 26434 | IrInstructionCheckSwitchProngs *instruction) | 27289 | IrInstSrcCheckSwitchProngs *instruction) |
| 26435 | { | 27290 | { |
| 26436 | IrInstruction *target_value = instruction->target_value->child; | 27291 | IrInstGen *target_value = instruction->target_value->child; |
| 26437 | ZigType *switch_type = target_value->value->type; | 27292 | ZigType *switch_type = target_value->value->type; |
| 26438 | if (type_is_invalid(switch_type)) | 27293 | if (type_is_invalid(switch_type)) |
| 26439 | return ira->codegen->invalid_instruction; | 27294 | return ira->codegen->invalid_inst_gen; |
| 26440 | | 27295 | |
| 26441 | if (switch_type->id == ZigTypeIdEnum) { | 27296 | if (switch_type->id == ZigTypeIdEnum) { |
| 26442 | HashMap<BigInt, AstNode *, bigint_hash, bigint_eql> field_prev_uses = {}; | 27297 | HashMap<BigInt, AstNode *, bigint_hash, bigint_eql> field_prev_uses = {}; |
| 26443 | field_prev_uses.init(switch_type->data.enumeration.src_field_count); | 27298 | field_prev_uses.init(switch_type->data.enumeration.src_field_count); |
| 26444 | | 27299 | |
| 26445 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { | 27300 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { |
| 26446 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | 27301 | IrInstSrcCheckSwitchProngsRange *range = &instruction->ranges[range_i]; |
| 26447 | | 27302 | |
| 26448 | IrInstruction *start_value_uncasted = range->start->child; | 27303 | IrInstGen *start_value_uncasted = range->start->child; |
| 26449 | if (type_is_invalid(start_value_uncasted->value->type)) | 27304 | if (type_is_invalid(start_value_uncasted->value->type)) |
| 26450 | return ira->codegen->invalid_instruction; | 27305 | return ira->codegen->invalid_inst_gen; |
| 26451 | IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); | 27306 | IrInstGen *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); |
| 26452 | if (type_is_invalid(start_value->value->type)) | 27307 | if (type_is_invalid(start_value->value->type)) |
| 26453 | return ira->codegen->invalid_instruction; | 27308 | return ira->codegen->invalid_inst_gen; |
| 26454 | | 27309 | |
| 26455 | IrInstruction *end_value_uncasted = range->end->child; | 27310 | IrInstGen *end_value_uncasted = range->end->child; |
| 26456 | if (type_is_invalid(end_value_uncasted->value->type)) | 27311 | if (type_is_invalid(end_value_uncasted->value->type)) |
| 26457 | return ira->codegen->invalid_instruction; | 27312 | return ira->codegen->invalid_inst_gen; |
| 26458 | IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); | 27313 | IrInstGen *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); |
| 26459 | if (type_is_invalid(end_value->value->type)) | 27314 | if (type_is_invalid(end_value->value->type)) |
| 26460 | return ira->codegen->invalid_instruction; | 27315 | return ira->codegen->invalid_inst_gen; |
| 26461 | | 27316 | |
| 26462 | assert(start_value->value->type->id == ZigTypeIdEnum); | 27317 | assert(start_value->value->type->id == ZigTypeIdEnum); |
| 26463 | BigInt start_index; | 27318 | BigInt start_index; |
| ... | @@ -26468,7 +27323,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -26468,7 +27323,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 26468 | bigint_init_bigint(&end_index, &end_value->value->data.x_enum_tag); | 27323 | bigint_init_bigint(&end_index, &end_value->value->data.x_enum_tag); |
| 26469 | | 27324 | |
| 26470 | if (bigint_cmp(&start_index, &end_index) == CmpGT) { | 27325 | if (bigint_cmp(&start_index, &end_index) == CmpGT) { |
| 26471 | ir_add_error(ira, start_value, | 27326 | ir_add_error(ira, &start_value->base, |
| 26472 | buf_sprintf("range start value is greater than the end value")); | 27327 | buf_sprintf("range start value is greater than the end value")); |
| 26473 | } | 27328 | } |
| 26474 | | 27329 | |
| ... | @@ -26479,12 +27334,12 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -26479,12 +27334,12 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 26479 | if (cmp == CmpGT) { | 27334 | if (cmp == CmpGT) { |
| 26480 | break; | 27335 | break; |
| 26481 | } | 27336 | } |
| 26482 | auto entry = field_prev_uses.put_unique(field_index, start_value->source_node); | 27337 | auto entry = field_prev_uses.put_unique(field_index, start_value->base.source_node); |
| 26483 | if (entry) { | 27338 | if (entry) { |
| 26484 | AstNode *prev_node = entry->value; | 27339 | AstNode *prev_node = entry->value; |
| 26485 | TypeEnumField *enum_field = find_enum_field_by_tag(switch_type, &field_index); | 27340 | TypeEnumField *enum_field = find_enum_field_by_tag(switch_type, &field_index); |
| 26486 | assert(enum_field != nullptr); | 27341 | assert(enum_field != nullptr); |
| 26487 | ErrorMsg *msg = ir_add_error(ira, start_value, | 27342 | ErrorMsg *msg = ir_add_error(ira, &start_value->base, |
| 26488 | buf_sprintf("duplicate switch value: '%s.%s'", buf_ptr(&switch_type->name), | 27343 | buf_sprintf("duplicate switch value: '%s.%s'", buf_ptr(&switch_type->name), |
| 26489 | buf_ptr(enum_field->name))); | 27344 | buf_ptr(enum_field->name))); |
| 26490 | add_error_note(ira->codegen, msg, prev_node, buf_sprintf("other value is here")); | 27345 | add_error_note(ira->codegen, msg, prev_node, buf_sprintf("other value is here")); |
| ... | @@ -26494,7 +27349,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -26494,7 +27349,7 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 26494 | } | 27349 | } |
| 26495 | if (instruction->have_underscore_prong) { | 27350 | if (instruction->have_underscore_prong) { |
| 26496 | if (!switch_type->data.enumeration.non_exhaustive){ | 27351 | if (!switch_type->data.enumeration.non_exhaustive){ |
| 26497 | ir_add_error(ira, &instruction->base, | 27352 | ir_add_error(ira, &instruction->base.base, |
| 26498 | buf_sprintf("switch on non-exhaustive enum has `_` prong")); | 27353 | buf_sprintf("switch on non-exhaustive enum has `_` prong")); |
| 26499 | } | 27354 | } |
| 26500 | for (uint32_t i = 0; i < switch_type->data.enumeration.src_field_count; i += 1) { | 27355 | for (uint32_t i = 0; i < switch_type->data.enumeration.src_field_count; i += 1) { |
| ... | @@ -26504,14 +27359,14 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -26504,14 +27359,14 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 26504 | | 27359 | |
| 26505 | auto entry = field_prev_uses.maybe_get(enum_field->value); | 27360 | auto entry = field_prev_uses.maybe_get(enum_field->value); |
| 26506 | if (!entry) { | 27361 | if (!entry) { |
| 26507 | ir_add_error(ira, &instruction->base, | 27362 | ir_add_error(ira, &instruction->base.base, |
| 26508 | buf_sprintf("enumeration value '%s.%s' not handled in switch", buf_ptr(&switch_type->name), | 27363 | buf_sprintf("enumeration value '%s.%s' not handled in switch", buf_ptr(&switch_type->name), |
| 26509 | buf_ptr(enum_field->name))); | 27364 | buf_ptr(enum_field->name))); |
| 26510 | } | 27365 | } |
| 26511 | } | 27366 | } |
| 26512 | } else if (!instruction->have_else_prong) { | 27367 | } else if (!instruction->have_else_prong) { |
| 26513 | if (switch_type->data.enumeration.non_exhaustive) { | 27368 | if (switch_type->data.enumeration.non_exhaustive) { |
| 26514 | ir_add_error(ira, &instruction->base, | 27369 | ir_add_error(ira, &instruction->base.base, |
| 26515 | buf_sprintf("switch on non-exhaustive enum must include `else` or `_` prong")); | 27370 | buf_sprintf("switch on non-exhaustive enum must include `else` or `_` prong")); |
| 26516 | } | 27371 | } |
| 26517 | for (uint32_t i = 0; i < switch_type->data.enumeration.src_field_count; i += 1) { | 27372 | for (uint32_t i = 0; i < switch_type->data.enumeration.src_field_count; i += 1) { |
| ... | @@ -26519,69 +27374,69 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -26519,69 +27374,69 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 26519 | | 27374 | |
| 26520 | auto entry = field_prev_uses.maybe_get(enum_field->value); | 27375 | auto entry = field_prev_uses.maybe_get(enum_field->value); |
| 26521 | if (!entry) { | 27376 | if (!entry) { |
| 26522 | ir_add_error(ira, &instruction->base, | 27377 | ir_add_error(ira, &instruction->base.base, |
| 26523 | buf_sprintf("enumeration value '%s.%s' not handled in switch", buf_ptr(&switch_type->name), | 27378 | buf_sprintf("enumeration value '%s.%s' not handled in switch", buf_ptr(&switch_type->name), |
| 26524 | buf_ptr(enum_field->name))); | 27379 | buf_ptr(enum_field->name))); |
| 26525 | } | 27380 | } |
| 26526 | } | 27381 | } |
| 26527 | } | 27382 | } |
| 26528 | } else if (switch_type->id == ZigTypeIdErrorSet) { | 27383 | } else if (switch_type->id == ZigTypeIdErrorSet) { |
| 26529 | if (!resolve_inferred_error_set(ira->codegen, switch_type, target_value->source_node)) { | 27384 | if (!resolve_inferred_error_set(ira->codegen, switch_type, target_value->base.source_node)) { |
| 26530 | return ira->codegen->invalid_instruction; | 27385 | return ira->codegen->invalid_inst_gen; |
| 26531 | } | 27386 | } |
| 26532 | | 27387 | |
| 26533 | size_t field_prev_uses_count = ira->codegen->errors_by_index.length; | 27388 | size_t field_prev_uses_count = ira->codegen->errors_by_index.length; |
| 26534 | AstNode **field_prev_uses = allocate<AstNode *>(field_prev_uses_count, "AstNode *"); | 27389 | AstNode **field_prev_uses = allocate<AstNode *>(field_prev_uses_count, "AstNode *"); |
| 26535 | | 27390 | |
| 26536 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { | 27391 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { |
| 26537 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | 27392 | IrInstSrcCheckSwitchProngsRange *range = &instruction->ranges[range_i]; |
| 26538 | | 27393 | |
| 26539 | IrInstruction *start_value_uncasted = range->start->child; | 27394 | IrInstGen *start_value_uncasted = range->start->child; |
| 26540 | if (type_is_invalid(start_value_uncasted->value->type)) | 27395 | if (type_is_invalid(start_value_uncasted->value->type)) |
| 26541 | return ira->codegen->invalid_instruction; | 27396 | return ira->codegen->invalid_inst_gen; |
| 26542 | IrInstruction *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); | 27397 | IrInstGen *start_value = ir_implicit_cast(ira, start_value_uncasted, switch_type); |
| 26543 | if (type_is_invalid(start_value->value->type)) | 27398 | if (type_is_invalid(start_value->value->type)) |
| 26544 | return ira->codegen->invalid_instruction; | 27399 | return ira->codegen->invalid_inst_gen; |
| 26545 | | 27400 | |
| 26546 | IrInstruction *end_value_uncasted = range->end->child; | 27401 | IrInstGen *end_value_uncasted = range->end->child; |
| 26547 | if (type_is_invalid(end_value_uncasted->value->type)) | 27402 | if (type_is_invalid(end_value_uncasted->value->type)) |
| 26548 | return ira->codegen->invalid_instruction; | 27403 | return ira->codegen->invalid_inst_gen; |
| 26549 | IrInstruction *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); | 27404 | IrInstGen *end_value = ir_implicit_cast(ira, end_value_uncasted, switch_type); |
| 26550 | if (type_is_invalid(end_value->value->type)) | 27405 | if (type_is_invalid(end_value->value->type)) |
| 26551 | return ira->codegen->invalid_instruction; | 27406 | return ira->codegen->invalid_inst_gen; |
| 26552 | | 27407 | |
| 26553 | ir_assert(start_value->value->type->id == ZigTypeIdErrorSet, &instruction->base); | 27408 | ir_assert(start_value->value->type->id == ZigTypeIdErrorSet, &instruction->base.base); |
| 26554 | uint32_t start_index = start_value->value->data.x_err_set->value; | 27409 | uint32_t start_index = start_value->value->data.x_err_set->value; |
| 26555 | | 27410 | |
| 26556 | ir_assert(end_value->value->type->id == ZigTypeIdErrorSet, &instruction->base); | 27411 | ir_assert(end_value->value->type->id == ZigTypeIdErrorSet, &instruction->base.base); |
| 26557 | uint32_t end_index = end_value->value->data.x_err_set->value; | 27412 | uint32_t end_index = end_value->value->data.x_err_set->value; |
| 26558 | | 27413 | |
| 26559 | if (start_index != end_index) { | 27414 | if (start_index != end_index) { |
| 26560 | ir_add_error(ira, end_value, buf_sprintf("ranges not allowed when switching on errors")); | 27415 | ir_add_error(ira, &end_value->base, buf_sprintf("ranges not allowed when switching on errors")); |
| 26561 | return ira->codegen->invalid_instruction; | 27416 | return ira->codegen->invalid_inst_gen; |
| 26562 | } | 27417 | } |
| 26563 | | 27418 | |
| 26564 | AstNode *prev_node = field_prev_uses[start_index]; | 27419 | AstNode *prev_node = field_prev_uses[start_index]; |
| 26565 | if (prev_node != nullptr) { | 27420 | if (prev_node != nullptr) { |
| 26566 | Buf *err_name = &ira->codegen->errors_by_index.at(start_index)->name; | 27421 | Buf *err_name = &ira->codegen->errors_by_index.at(start_index)->name; |
| 26567 | ErrorMsg *msg = ir_add_error(ira, start_value, | 27422 | ErrorMsg *msg = ir_add_error(ira, &start_value->base, |
| 26568 | buf_sprintf("duplicate switch value: '%s.%s'", buf_ptr(&switch_type->name), buf_ptr(err_name))); | 27423 | buf_sprintf("duplicate switch value: '%s.%s'", buf_ptr(&switch_type->name), buf_ptr(err_name))); |
| 26569 | add_error_note(ira->codegen, msg, prev_node, buf_sprintf("other value is here")); | 27424 | add_error_note(ira->codegen, msg, prev_node, buf_sprintf("other value is here")); |
| 26570 | } | 27425 | } |
| 26571 | field_prev_uses[start_index] = start_value->source_node; | 27426 | field_prev_uses[start_index] = start_value->base.source_node; |
| 26572 | } | 27427 | } |
| 26573 | if (!instruction->have_else_prong) { | 27428 | if (!instruction->have_else_prong) { |
| 26574 | if (type_is_global_error_set(switch_type)) { | 27429 | if (type_is_global_error_set(switch_type)) { |
| 26575 | ir_add_error(ira, &instruction->base, | 27430 | ir_add_error(ira, &instruction->base.base, |
| 26576 | buf_sprintf("else prong required when switching on type 'anyerror'")); | 27431 | buf_sprintf("else prong required when switching on type 'anyerror'")); |
| 26577 | return ira->codegen->invalid_instruction; | 27432 | return ira->codegen->invalid_inst_gen; |
| 26578 | } else { | 27433 | } else { |
| 26579 | for (uint32_t i = 0; i < switch_type->data.error_set.err_count; i += 1) { | 27434 | for (uint32_t i = 0; i < switch_type->data.error_set.err_count; i += 1) { |
| 26580 | ErrorTableEntry *err_entry = switch_type->data.error_set.errors[i]; | 27435 | ErrorTableEntry *err_entry = switch_type->data.error_set.errors[i]; |
| 26581 | | 27436 | |
| 26582 | AstNode *prev_node = field_prev_uses[err_entry->value]; | 27437 | AstNode *prev_node = field_prev_uses[err_entry->value]; |
| 26583 | if (prev_node == nullptr) { | 27438 | if (prev_node == nullptr) { |
| 26584 | ir_add_error(ira, &instruction->base, | 27439 | ir_add_error(ira, &instruction->base.base, |
| 26585 | buf_sprintf("error.%s not handled in switch", buf_ptr(&err_entry->name))); | 27440 | buf_sprintf("error.%s not handled in switch", buf_ptr(&err_entry->name))); |
| 26586 | } | 27441 | } |
| 26587 | } | 27442 | } |
| ... | @@ -26592,44 +27447,44 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -26592,44 +27447,44 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 26592 | } else if (switch_type->id == ZigTypeIdInt) { | 27447 | } else if (switch_type->id == ZigTypeIdInt) { |
| 26593 | RangeSet rs = {0}; | 27448 | RangeSet rs = {0}; |
| 26594 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { | 27449 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { |
| 26595 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | 27450 | IrInstSrcCheckSwitchProngsRange *range = &instruction->ranges[range_i]; |
| 26596 | | 27451 | |
| 26597 | IrInstruction *start_value = range->start->child; | 27452 | IrInstGen *start_value = range->start->child; |
| 26598 | if (type_is_invalid(start_value->value->type)) | 27453 | if (type_is_invalid(start_value->value->type)) |
| 26599 | return ira->codegen->invalid_instruction; | 27454 | return ira->codegen->invalid_inst_gen; |
| 26600 | IrInstruction *casted_start_value = ir_implicit_cast(ira, start_value, switch_type); | 27455 | IrInstGen *casted_start_value = ir_implicit_cast(ira, start_value, switch_type); |
| 26601 | if (type_is_invalid(casted_start_value->value->type)) | 27456 | if (type_is_invalid(casted_start_value->value->type)) |
| 26602 | return ira->codegen->invalid_instruction; | 27457 | return ira->codegen->invalid_inst_gen; |
| 26603 | | 27458 | |
| 26604 | IrInstruction *end_value = range->end->child; | 27459 | IrInstGen *end_value = range->end->child; |
| 26605 | if (type_is_invalid(end_value->value->type)) | 27460 | if (type_is_invalid(end_value->value->type)) |
| 26606 | return ira->codegen->invalid_instruction; | 27461 | return ira->codegen->invalid_inst_gen; |
| 26607 | IrInstruction *casted_end_value = ir_implicit_cast(ira, end_value, switch_type); | 27462 | IrInstGen *casted_end_value = ir_implicit_cast(ira, end_value, switch_type); |
| 26608 | if (type_is_invalid(casted_end_value->value->type)) | 27463 | if (type_is_invalid(casted_end_value->value->type)) |
| 26609 | return ira->codegen->invalid_instruction; | 27464 | return ira->codegen->invalid_inst_gen; |
| 26610 | | 27465 | |
| 26611 | ZigValue *start_val = ir_resolve_const(ira, casted_start_value, UndefBad); | 27466 | ZigValue *start_val = ir_resolve_const(ira, casted_start_value, UndefBad); |
| 26612 | if (!start_val) | 27467 | if (!start_val) |
| 26613 | return ira->codegen->invalid_instruction; | 27468 | return ira->codegen->invalid_inst_gen; |
| 26614 | | 27469 | |
| 26615 | ZigValue *end_val = ir_resolve_const(ira, casted_end_value, UndefBad); | 27470 | ZigValue *end_val = ir_resolve_const(ira, casted_end_value, UndefBad); |
| 26616 | if (!end_val) | 27471 | if (!end_val) |
| 26617 | return ira->codegen->invalid_instruction; | 27472 | return ira->codegen->invalid_inst_gen; |
| 26618 | | 27473 | |
| 26619 | assert(start_val->type->id == ZigTypeIdInt || start_val->type->id == ZigTypeIdComptimeInt); | 27474 | assert(start_val->type->id == ZigTypeIdInt || start_val->type->id == ZigTypeIdComptimeInt); |
| 26620 | assert(end_val->type->id == ZigTypeIdInt || end_val->type->id == ZigTypeIdComptimeInt); | 27475 | assert(end_val->type->id == ZigTypeIdInt || end_val->type->id == ZigTypeIdComptimeInt); |
| 26621 | | 27476 | |
| 26622 | if (bigint_cmp(&start_val->data.x_bigint, &end_val->data.x_bigint) == CmpGT) { | 27477 | if (bigint_cmp(&start_val->data.x_bigint, &end_val->data.x_bigint) == CmpGT) { |
| 26623 | ir_add_error(ira, start_value, | 27478 | ir_add_error(ira, &start_value->base, |
| 26624 | buf_sprintf("range start value is greater than the end value")); | 27479 | buf_sprintf("range start value is greater than the end value")); |
| 26625 | } | 27480 | } |
| 26626 | | 27481 | |
| 26627 | AstNode *prev_node = rangeset_add_range(&rs, &start_val->data.x_bigint, &end_val->data.x_bigint, | 27482 | AstNode *prev_node = rangeset_add_range(&rs, &start_val->data.x_bigint, &end_val->data.x_bigint, |
| 26628 | start_value->source_node); | 27483 | start_value->base.source_node); |
| 26629 | if (prev_node != nullptr) { | 27484 | if (prev_node != nullptr) { |
| 26630 | ErrorMsg *msg = ir_add_error(ira, start_value, buf_sprintf("duplicate switch value")); | 27485 | ErrorMsg *msg = ir_add_error(ira, &start_value->base, buf_sprintf("duplicate switch value")); |
| 26631 | add_error_note(ira->codegen, msg, prev_node, buf_sprintf("previous value is here")); | 27486 | add_error_note(ira->codegen, msg, prev_node, buf_sprintf("previous value is here")); |
| 26632 | return ira->codegen->invalid_instruction; | 27487 | return ira->codegen->invalid_inst_gen; |
| 26633 | } | 27488 | } |
| 26634 | } | 27489 | } |
| 26635 | if (!instruction->have_else_prong) { | 27490 | if (!instruction->have_else_prong) { |
| ... | @@ -26638,25 +27493,25 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -26638,25 +27493,25 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 26638 | BigInt max_val; | 27493 | BigInt max_val; |
| 26639 | eval_min_max_value_int(ira->codegen, switch_type, &max_val, true); | 27494 | eval_min_max_value_int(ira->codegen, switch_type, &max_val, true); |
| 26640 | if (!rangeset_spans(&rs, &min_val, &max_val)) { | 27495 | if (!rangeset_spans(&rs, &min_val, &max_val)) { |
| 26641 | ir_add_error(ira, &instruction->base, buf_sprintf("switch must handle all possibilities")); | 27496 | ir_add_error(ira, &instruction->base.base, buf_sprintf("switch must handle all possibilities")); |
| 26642 | return ira->codegen->invalid_instruction; | 27497 | return ira->codegen->invalid_inst_gen; |
| 26643 | } | 27498 | } |
| 26644 | } | 27499 | } |
| 26645 | } else if (switch_type->id == ZigTypeIdBool) { | 27500 | } else if (switch_type->id == ZigTypeIdBool) { |
| 26646 | int seenTrue = 0; | 27501 | int seenTrue = 0; |
| 26647 | int seenFalse = 0; | 27502 | int seenFalse = 0; |
| 26648 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { | 27503 | for (size_t range_i = 0; range_i < instruction->range_count; range_i += 1) { |
| 26649 | IrInstructionCheckSwitchProngsRange *range = &instruction->ranges[range_i]; | 27504 | IrInstSrcCheckSwitchProngsRange *range = &instruction->ranges[range_i]; |
| 26650 | | 27505 | |
| 26651 | IrInstruction *value = range->start->child; | 27506 | IrInstGen *value = range->start->child; |
| 26652 | | 27507 | |
| 26653 | IrInstruction *casted_value = ir_implicit_cast(ira, value, switch_type); | 27508 | IrInstGen *casted_value = ir_implicit_cast(ira, value, switch_type); |
| 26654 | if (type_is_invalid(casted_value->value->type)) | 27509 | if (type_is_invalid(casted_value->value->type)) |
| 26655 | return ira->codegen->invalid_instruction; | 27510 | return ira->codegen->invalid_inst_gen; |
| 26656 | | 27511 | |
| 26657 | ZigValue *const_expr_val = ir_resolve_const(ira, casted_value, UndefBad); | 27512 | ZigValue *const_expr_val = ir_resolve_const(ira, casted_value, UndefBad); |
| 26658 | if (!const_expr_val) | 27513 | if (!const_expr_val) |
| 26659 | return ira->codegen->invalid_instruction; | 27514 | return ira->codegen->invalid_inst_gen; |
| 26660 | | 27515 | |
| 26661 | assert(const_expr_val->type->id == ZigTypeIdBool); | 27516 | assert(const_expr_val->type->id == ZigTypeIdBool); |
| 26662 | | 27517 | |
| ... | @@ -26667,60 +27522,59 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -26667,60 +27522,59 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 26667 | } | 27522 | } |
| 26668 | | 27523 | |
| 26669 | if ((seenTrue > 1) || (seenFalse > 1)) { | 27524 | if ((seenTrue > 1) || (seenFalse > 1)) { |
| 26670 | ir_add_error(ira, value, buf_sprintf("duplicate switch value")); | 27525 | ir_add_error(ira, &value->base, buf_sprintf("duplicate switch value")); |
| 26671 | return ira->codegen->invalid_instruction; | 27526 | return ira->codegen->invalid_inst_gen; |
| 26672 | } | 27527 | } |
| 26673 | } | 27528 | } |
| 26674 | if (((seenTrue < 1) || (seenFalse < 1)) && !instruction->have_else_prong) { | 27529 | if (((seenTrue < 1) || (seenFalse < 1)) && !instruction->have_else_prong) { |
| 26675 | ir_add_error(ira, &instruction->base, buf_sprintf("switch must handle all possibilities")); | 27530 | ir_add_error(ira, &instruction->base.base, buf_sprintf("switch must handle all possibilities")); |
| 26676 | return ira->codegen->invalid_instruction; | 27531 | return ira->codegen->invalid_inst_gen; |
| 26677 | } | 27532 | } |
| 26678 | } else if (!instruction->have_else_prong) { | 27533 | } else if (!instruction->have_else_prong) { |
| 26679 | ir_add_error(ira, &instruction->base, | 27534 | ir_add_error(ira, &instruction->base.base, |
| 26680 | buf_sprintf("else prong required when switching on type '%s'", buf_ptr(&switch_type->name))); | 27535 | buf_sprintf("else prong required when switching on type '%s'", buf_ptr(&switch_type->name))); |
| 26681 | return ira->codegen->invalid_instruction; | 27536 | return ira->codegen->invalid_inst_gen; |
| 26682 | } | 27537 | } |
| 26683 | return ir_const_void(ira, &instruction->base); | 27538 | return ir_const_void(ira, &instruction->base.base); |
| 26684 | } | 27539 | } |
| 26685 | | 27540 | |
| 26686 | static IrInstruction *ir_analyze_instruction_check_statement_is_void(IrAnalyze *ira, | 27541 | static IrInstGen *ir_analyze_instruction_check_statement_is_void(IrAnalyze *ira, |
| 26687 | IrInstructionCheckStatementIsVoid *instruction) | 27542 | IrInstSrcCheckStatementIsVoid *instruction) |
| 26688 | { | 27543 | { |
| 26689 | IrInstruction *statement_value = instruction->statement_value->child; | 27544 | IrInstGen *statement_value = instruction->statement_value->child; |
| 26690 | ZigType *statement_type = statement_value->value->type; | 27545 | ZigType *statement_type = statement_value->value->type; |
| 26691 | if (type_is_invalid(statement_type)) | 27546 | if (type_is_invalid(statement_type)) |
| 26692 | return ira->codegen->invalid_instruction; | 27547 | return ira->codegen->invalid_inst_gen; |
| 26693 | | 27548 | |
| 26694 | if (statement_type->id != ZigTypeIdVoid && statement_type->id != ZigTypeIdUnreachable) { | 27549 | if (statement_type->id != ZigTypeIdVoid && statement_type->id != ZigTypeIdUnreachable) { |
| 26695 | ir_add_error(ira, &instruction->base, buf_sprintf("expression value is ignored")); | 27550 | ir_add_error(ira, &instruction->base.base, buf_sprintf("expression value is ignored")); |
| 26696 | } | 27551 | } |
| 26697 | | 27552 | |
| 26698 | return ir_const_void(ira, &instruction->base); | 27553 | return ir_const_void(ira, &instruction->base.base); |
| 26699 | } | 27554 | } |
| 26700 | | 27555 | |
| 26701 | static IrInstruction *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstructionPanic *instruction) { | 27556 | static IrInstGen *ir_analyze_instruction_panic(IrAnalyze *ira, IrInstSrcPanic *instruction) { |
| 26702 | IrInstruction *msg = instruction->msg->child; | 27557 | IrInstGen *msg = instruction->msg->child; |
| 26703 | if (type_is_invalid(msg->value->type)) | 27558 | if (type_is_invalid(msg->value->type)) |
| 26704 | return ir_unreach_error(ira); | 27559 | return ir_unreach_error(ira); |
| 26705 | | 27560 | |
| 26706 | if (ir_should_inline(ira->new_irb.exec, instruction->base.scope)) { | 27561 | if (ir_should_inline(ira->old_irb.exec, instruction->base.base.scope)) { |
| 26707 | ir_add_error(ira, &instruction->base, buf_sprintf("encountered @panic at compile-time")); | 27562 | ir_add_error(ira, &instruction->base.base, buf_sprintf("encountered @panic at compile-time")); |
| 26708 | return ir_unreach_error(ira); | 27563 | return ir_unreach_error(ira); |
| 26709 | } | 27564 | } |
| 26710 | | 27565 | |
| 26711 | ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, | 27566 | ZigType *u8_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 26712 | true, false, PtrLenUnknown, 0, 0, 0, false); | 27567 | true, false, PtrLenUnknown, 0, 0, 0, false); |
| 26713 | ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); | 27568 | ZigType *str_type = get_slice_type(ira->codegen, u8_ptr_type); |
| 26714 | IrInstruction *casted_msg = ir_implicit_cast(ira, msg, str_type); | 27569 | IrInstGen *casted_msg = ir_implicit_cast(ira, msg, str_type); |
| 26715 | if (type_is_invalid(casted_msg->value->type)) | 27570 | if (type_is_invalid(casted_msg->value->type)) |
| 26716 | return ir_unreach_error(ira); | 27571 | return ir_unreach_error(ira); |
| 26717 | | 27572 | |
| 26718 | IrInstruction *new_instruction = ir_build_panic(&ira->new_irb, instruction->base.scope, | 27573 | IrInstGen *new_instruction = ir_build_panic_gen(ira, &instruction->base.base, casted_msg); |
| 26719 | instruction->base.source_node, casted_msg); | | |
| 26720 | return ir_finish_anal(ira, new_instruction); | 27574 | return ir_finish_anal(ira, new_instruction); |
| 26721 | } | 27575 | } |
| 26722 | | 27576 | |
| 26723 | static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint32_t align_bytes, bool safety_check_on) { | 27577 | static IrInstGen *ir_align_cast(IrAnalyze *ira, IrInstGen *target, uint32_t align_bytes, bool safety_check_on) { |
| 26724 | Error err; | 27578 | Error err; |
| 26725 | | 27579 | |
| 26726 | ZigType *target_type = target->value->type; | 27580 | ZigType *target_type = target->value->type; |
| ... | @@ -26732,7 +27586,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 | ... | @@ -26732,7 +27586,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 |
| 26732 | if (target_type->id == ZigTypeIdPointer) { | 27586 | if (target_type->id == ZigTypeIdPointer) { |
| 26733 | result_type = adjust_ptr_align(ira->codegen, target_type, align_bytes); | 27587 | result_type = adjust_ptr_align(ira->codegen, target_type, align_bytes); |
| 26734 | if ((err = resolve_ptr_align(ira, target_type, &old_align_bytes))) | 27588 | if ((err = resolve_ptr_align(ira, target_type, &old_align_bytes))) |
| 26735 | return ira->codegen->invalid_instruction; | 27589 | return ira->codegen->invalid_inst_gen; |
| 26736 | } else if (target_type->id == ZigTypeIdFn) { | 27590 | } else if (target_type->id == ZigTypeIdFn) { |
| 26737 | FnTypeId fn_type_id = target_type->data.fn.fn_type_id; | 27591 | FnTypeId fn_type_id = target_type->data.fn.fn_type_id; |
| 26738 | old_align_bytes = fn_type_id.alignment; | 27592 | old_align_bytes = fn_type_id.alignment; |
| ... | @@ -26743,7 +27597,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 | ... | @@ -26743,7 +27597,7 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 |
| 26743 | { | 27597 | { |
| 26744 | ZigType *ptr_type = target_type->data.maybe.child_type; | 27598 | ZigType *ptr_type = target_type->data.maybe.child_type; |
| 26745 | if ((err = resolve_ptr_align(ira, ptr_type, &old_align_bytes))) | 27599 | if ((err = resolve_ptr_align(ira, ptr_type, &old_align_bytes))) |
| 26746 | return ira->codegen->invalid_instruction; | 27600 | return ira->codegen->invalid_inst_gen; |
| 26747 | ZigType *better_ptr_type = adjust_ptr_align(ira->codegen, ptr_type, align_bytes); | 27601 | ZigType *better_ptr_type = adjust_ptr_align(ira->codegen, ptr_type, align_bytes); |
| 26748 | | 27602 | |
| 26749 | result_type = get_optional_type(ira->codegen, better_ptr_type); | 27603 | result_type = get_optional_type(ira->codegen, better_ptr_type); |
| ... | @@ -26758,47 +27612,44 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 | ... | @@ -26758,47 +27612,44 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 |
| 26758 | } else if (is_slice(target_type)) { | 27612 | } else if (is_slice(target_type)) { |
| 26759 | ZigType *slice_ptr_type = target_type->data.structure.fields[slice_ptr_index]->type_entry; | 27613 | ZigType *slice_ptr_type = target_type->data.structure.fields[slice_ptr_index]->type_entry; |
| 26760 | if ((err = resolve_ptr_align(ira, slice_ptr_type, &old_align_bytes))) | 27614 | if ((err = resolve_ptr_align(ira, slice_ptr_type, &old_align_bytes))) |
| 26761 | return ira->codegen->invalid_instruction; | 27615 | return ira->codegen->invalid_inst_gen; |
| 26762 | ZigType *result_ptr_type = adjust_ptr_align(ira->codegen, slice_ptr_type, align_bytes); | 27616 | ZigType *result_ptr_type = adjust_ptr_align(ira->codegen, slice_ptr_type, align_bytes); |
| 26763 | result_type = get_slice_type(ira->codegen, result_ptr_type); | 27617 | result_type = get_slice_type(ira->codegen, result_ptr_type); |
| 26764 | } else { | 27618 | } else { |
| 26765 | ir_add_error(ira, target, | 27619 | ir_add_error(ira, &target->base, |
| 26766 | buf_sprintf("expected pointer or slice, found '%s'", buf_ptr(&target_type->name))); | 27620 | buf_sprintf("expected pointer or slice, found '%s'", buf_ptr(&target_type->name))); |
| 26767 | return ira->codegen->invalid_instruction; | 27621 | return ira->codegen->invalid_inst_gen; |
| 26768 | } | 27622 | } |
| 26769 | | 27623 | |
| 26770 | if (instr_is_comptime(target)) { | 27624 | if (instr_is_comptime(target)) { |
| 26771 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 27625 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 26772 | if (!val) | 27626 | if (!val) |
| 26773 | return ira->codegen->invalid_instruction; | 27627 | return ira->codegen->invalid_inst_gen; |
| 26774 | | 27628 | |
| 26775 | if (val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr && | 27629 | if (val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr && |
| 26776 | val->data.x_ptr.data.hard_coded_addr.addr % align_bytes != 0) | 27630 | val->data.x_ptr.data.hard_coded_addr.addr % align_bytes != 0) |
| 26777 | { | 27631 | { |
| 26778 | ir_add_error(ira, target, | 27632 | ir_add_error(ira, &target->base, |
| 26779 | buf_sprintf("pointer address 0x%" ZIG_PRI_x64 " is not aligned to %" PRIu32 " bytes", | 27633 | buf_sprintf("pointer address 0x%" ZIG_PRI_x64 " is not aligned to %" PRIu32 " bytes", |
| 26780 | val->data.x_ptr.data.hard_coded_addr.addr, align_bytes)); | 27634 | val->data.x_ptr.data.hard_coded_addr.addr, align_bytes)); |
| 26781 | return ira->codegen->invalid_instruction; | 27635 | return ira->codegen->invalid_inst_gen; |
| 26782 | } | 27636 | } |
| 26783 | | 27637 | |
| 26784 | IrInstruction *result = ir_const(ira, target, result_type); | 27638 | IrInstGen *result = ir_const(ira, &target->base, result_type); |
| 26785 | copy_const_val(result->value, val); | 27639 | copy_const_val(result->value, val); |
| 26786 | result->value->type = result_type; | 27640 | result->value->type = result_type; |
| 26787 | return result; | 27641 | return result; |
| 26788 | } | 27642 | } |
| 26789 | | 27643 | |
| 26790 | IrInstruction *result; | | |
| 26791 | if (safety_check_on && align_bytes > old_align_bytes && align_bytes != 1) { | 27644 | if (safety_check_on && align_bytes > old_align_bytes && align_bytes != 1) { |
| 26792 | result = ir_build_align_cast(&ira->new_irb, target->scope, target->source_node, nullptr, target); | 27645 | return ir_build_align_cast_gen(ira, target->base.scope, target->base.source_node, target, result_type); |
| 26793 | } else { | 27646 | } else { |
| 26794 | result = ir_build_cast(&ira->new_irb, target->scope, target->source_node, result_type, target, CastOpNoop); | 27647 | return ir_build_cast(ira, &target->base, result_type, target, CastOpNoop); |
| 26795 | } | 27648 | } |
| 26796 | result->value->type = result_type; | | |
| 26797 | return result; | | |
| 26798 | } | 27649 | } |
| 26799 | | 27650 | |
| 26800 | static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *ptr, | 27651 | static IrInstGen *ir_analyze_ptr_cast(IrAnalyze *ira, IrInst* source_instr, IrInstGen *ptr, |
| 26801 | ZigType *dest_type, IrInstruction *dest_type_src, bool safety_check_on) | 27652 | ZigType *dest_type, IrInst *dest_type_src, bool safety_check_on) |
| 26802 | { | 27653 | { |
| 26803 | Error err; | 27654 | Error err; |
| 26804 | | 27655 | |
| ... | @@ -26814,44 +27665,44 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -26814,44 +27665,44 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 26814 | | 27665 | |
| 26815 | ZigType *src_ptr_type = get_src_ptr_type(src_type); | 27666 | ZigType *src_ptr_type = get_src_ptr_type(src_type); |
| 26816 | if (src_ptr_type == nullptr) { | 27667 | if (src_ptr_type == nullptr) { |
| 26817 | ir_add_error(ira, ptr, buf_sprintf("expected pointer, found '%s'", buf_ptr(&src_type->name))); | 27668 | ir_add_error(ira, &ptr->base, buf_sprintf("expected pointer, found '%s'", buf_ptr(&src_type->name))); |
| 26818 | return ira->codegen->invalid_instruction; | 27669 | return ira->codegen->invalid_inst_gen; |
| 26819 | } | 27670 | } |
| 26820 | | 27671 | |
| 26821 | ZigType *dest_ptr_type = get_src_ptr_type(dest_type); | 27672 | ZigType *dest_ptr_type = get_src_ptr_type(dest_type); |
| 26822 | if (dest_ptr_type == nullptr) { | 27673 | if (dest_ptr_type == nullptr) { |
| 26823 | ir_add_error(ira, dest_type_src, | 27674 | ir_add_error(ira, dest_type_src, |
| 26824 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&dest_type->name))); | 27675 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&dest_type->name))); |
| 26825 | return ira->codegen->invalid_instruction; | 27676 | return ira->codegen->invalid_inst_gen; |
| 26826 | } | 27677 | } |
| 26827 | | 27678 | |
| 26828 | if (get_ptr_const(src_type) && !get_ptr_const(dest_type)) { | 27679 | if (get_ptr_const(src_type) && !get_ptr_const(dest_type)) { |
| 26829 | ir_add_error(ira, source_instr, buf_sprintf("cast discards const qualifier")); | 27680 | ir_add_error(ira, source_instr, buf_sprintf("cast discards const qualifier")); |
| 26830 | return ira->codegen->invalid_instruction; | 27681 | return ira->codegen->invalid_inst_gen; |
| 26831 | } | 27682 | } |
| 26832 | uint32_t src_align_bytes; | 27683 | uint32_t src_align_bytes; |
| 26833 | if ((err = resolve_ptr_align(ira, src_type, &src_align_bytes))) | 27684 | if ((err = resolve_ptr_align(ira, src_type, &src_align_bytes))) |
| 26834 | return ira->codegen->invalid_instruction; | 27685 | return ira->codegen->invalid_inst_gen; |
| 26835 | | 27686 | |
| 26836 | uint32_t dest_align_bytes; | 27687 | uint32_t dest_align_bytes; |
| 26837 | if ((err = resolve_ptr_align(ira, dest_type, &dest_align_bytes))) | 27688 | if ((err = resolve_ptr_align(ira, dest_type, &dest_align_bytes))) |
| 26838 | return ira->codegen->invalid_instruction; | 27689 | return ira->codegen->invalid_inst_gen; |
| 26839 | | 27690 | |
| 26840 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) | 27691 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) |
| 26841 | return ira->codegen->invalid_instruction; | 27692 | return ira->codegen->invalid_inst_gen; |
| 26842 | | 27693 | |
| 26843 | if ((err = type_resolve(ira->codegen, src_type, ResolveStatusZeroBitsKnown))) | 27694 | if ((err = type_resolve(ira->codegen, src_type, ResolveStatusZeroBitsKnown))) |
| 26844 | return ira->codegen->invalid_instruction; | 27695 | return ira->codegen->invalid_inst_gen; |
| 26845 | | 27696 | |
| 26846 | if (type_has_bits(dest_type) && !type_has_bits(src_type)) { | 27697 | if (type_has_bits(dest_type) && !type_has_bits(src_type)) { |
| 26847 | ErrorMsg *msg = ir_add_error(ira, source_instr, | 27698 | ErrorMsg *msg = ir_add_error(ira, source_instr, |
| 26848 | buf_sprintf("'%s' and '%s' do not have the same in-memory representation", | 27699 | buf_sprintf("'%s' and '%s' do not have the same in-memory representation", |
| 26849 | buf_ptr(&src_type->name), buf_ptr(&dest_type->name))); | 27700 | buf_ptr(&src_type->name), buf_ptr(&dest_type->name))); |
| 26850 | add_error_note(ira->codegen, msg, ptr->source_node, | 27701 | add_error_note(ira->codegen, msg, ptr->base.source_node, |
| 26851 | buf_sprintf("'%s' has no in-memory bits", buf_ptr(&src_type->name))); | 27702 | buf_sprintf("'%s' has no in-memory bits", buf_ptr(&src_type->name))); |
| 26852 | add_error_note(ira->codegen, msg, dest_type_src->source_node, | 27703 | add_error_note(ira->codegen, msg, dest_type_src->source_node, |
| 26853 | buf_sprintf("'%s' has in-memory bits", buf_ptr(&dest_type->name))); | 27704 | buf_sprintf("'%s' has in-memory bits", buf_ptr(&dest_type->name))); |
| 26854 | return ira->codegen->invalid_instruction; | 27705 | return ira->codegen->invalid_inst_gen; |
| 26855 | } | 27706 | } |
| 26856 | | 27707 | |
| 26857 | if (instr_is_comptime(ptr)) { | 27708 | if (instr_is_comptime(ptr)) { |
| ... | @@ -26859,7 +27710,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -26859,7 +27710,7 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 26859 | UndefAllowed is_undef_allowed = dest_allows_addr_zero ? UndefOk : UndefBad; | 27710 | UndefAllowed is_undef_allowed = dest_allows_addr_zero ? UndefOk : UndefBad; |
| 26860 | ZigValue *val = ir_resolve_const(ira, ptr, is_undef_allowed); | 27711 | ZigValue *val = ir_resolve_const(ira, ptr, is_undef_allowed); |
| 26861 | if (!val) | 27712 | if (!val) |
| 26862 | return ira->codegen->invalid_instruction; | 27713 | return ira->codegen->invalid_inst_gen; |
| 26863 | | 27714 | |
| 26864 | if (value_is_comptime(val) && val->special != ConstValSpecialUndef) { | 27715 | if (value_is_comptime(val) && val->special != ConstValSpecialUndef) { |
| 26865 | bool is_addr_zero = val->data.x_ptr.special == ConstPtrSpecialNull || | 27716 | bool is_addr_zero = val->data.x_ptr.special == ConstPtrSpecialNull || |
| ... | @@ -26868,16 +27719,16 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -26868,16 +27719,16 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 26868 | if (is_addr_zero && !dest_allows_addr_zero) { | 27719 | if (is_addr_zero && !dest_allows_addr_zero) { |
| 26869 | ir_add_error(ira, source_instr, | 27720 | ir_add_error(ira, source_instr, |
| 26870 | buf_sprintf("null pointer casted to type '%s'", buf_ptr(&dest_type->name))); | 27721 | buf_sprintf("null pointer casted to type '%s'", buf_ptr(&dest_type->name))); |
| 26871 | return ira->codegen->invalid_instruction; | 27722 | return ira->codegen->invalid_inst_gen; |
| 26872 | } | 27723 | } |
| 26873 | } | 27724 | } |
| 26874 | | 27725 | |
| 26875 | IrInstruction *result; | 27726 | IrInstGen *result; |
| 26876 | if (ptr->value->data.x_ptr.mut == ConstPtrMutInfer) { | 27727 | if (ptr->value->data.x_ptr.mut == ConstPtrMutInfer) { |
| 26877 | result = ir_build_ptr_cast_gen(ira, source_instr, dest_type, ptr, safety_check_on); | 27728 | result = ir_build_ptr_cast_gen(ira, source_instr, dest_type, ptr, safety_check_on); |
| 26878 | | 27729 | |
| 26879 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) | 27730 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) |
| 26880 | return ira->codegen->invalid_instruction; | 27731 | return ira->codegen->invalid_inst_gen; |
| 26881 | } else { | 27732 | } else { |
| 26882 | result = ir_const(ira, source_instr, dest_type); | 27733 | result = ir_const(ira, source_instr, dest_type); |
| 26883 | } | 27734 | } |
| ... | @@ -26895,40 +27746,40 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -26895,40 +27746,40 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 26895 | | 27746 | |
| 26896 | if (dest_align_bytes > src_align_bytes) { | 27747 | if (dest_align_bytes > src_align_bytes) { |
| 26897 | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("cast increases pointer alignment")); | 27748 | ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("cast increases pointer alignment")); |
| 26898 | add_error_note(ira->codegen, msg, ptr->source_node, | 27749 | add_error_note(ira->codegen, msg, ptr->base.source_node, |
| 26899 | buf_sprintf("'%s' has alignment %" PRIu32, buf_ptr(&src_type->name), src_align_bytes)); | 27750 | buf_sprintf("'%s' has alignment %" PRIu32, buf_ptr(&src_type->name), src_align_bytes)); |
| 26900 | add_error_note(ira->codegen, msg, dest_type_src->source_node, | 27751 | add_error_note(ira->codegen, msg, dest_type_src->source_node, |
| 26901 | buf_sprintf("'%s' has alignment %" PRIu32, buf_ptr(&dest_type->name), dest_align_bytes)); | 27752 | buf_sprintf("'%s' has alignment %" PRIu32, buf_ptr(&dest_type->name), dest_align_bytes)); |
| 26902 | return ira->codegen->invalid_instruction; | 27753 | return ira->codegen->invalid_inst_gen; |
| 26903 | } | 27754 | } |
| 26904 | | 27755 | |
| 26905 | IrInstruction *casted_ptr = ir_build_ptr_cast_gen(ira, source_instr, dest_type, ptr, safety_check_on); | 27756 | IrInstGen *casted_ptr = ir_build_ptr_cast_gen(ira, source_instr, dest_type, ptr, safety_check_on); |
| 26906 | | 27757 | |
| 26907 | // Keep the bigger alignment, it can only help- | 27758 | // Keep the bigger alignment, it can only help- |
| 26908 | // unless the target is zero bits. | 27759 | // unless the target is zero bits. |
| 26909 | IrInstruction *result; | 27760 | IrInstGen *result; |
| 26910 | if (src_align_bytes > dest_align_bytes && type_has_bits(dest_type)) { | 27761 | if (src_align_bytes > dest_align_bytes && type_has_bits(dest_type)) { |
| 26911 | result = ir_align_cast(ira, casted_ptr, src_align_bytes, false); | 27762 | result = ir_align_cast(ira, casted_ptr, src_align_bytes, false); |
| 26912 | if (type_is_invalid(result->value->type)) | 27763 | if (type_is_invalid(result->value->type)) |
| 26913 | return ira->codegen->invalid_instruction; | 27764 | return ira->codegen->invalid_inst_gen; |
| 26914 | } else { | 27765 | } else { |
| 26915 | result = casted_ptr; | 27766 | result = casted_ptr; |
| 26916 | } | 27767 | } |
| 26917 | return result; | 27768 | return result; |
| 26918 | } | 27769 | } |
| 26919 | | 27770 | |
| 26920 | static IrInstruction *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstructionPtrCastSrc *instruction) { | 27771 | static IrInstGen *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstSrcPtrCast *instruction) { |
| 26921 | IrInstruction *dest_type_value = instruction->dest_type->child; | 27772 | IrInstGen *dest_type_value = instruction->dest_type->child; |
| 26922 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); | 27773 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); |
| 26923 | if (type_is_invalid(dest_type)) | 27774 | if (type_is_invalid(dest_type)) |
| 26924 | return ira->codegen->invalid_instruction; | 27775 | return ira->codegen->invalid_inst_gen; |
| 26925 | | 27776 | |
| 26926 | IrInstruction *ptr = instruction->ptr->child; | 27777 | IrInstGen *ptr = instruction->ptr->child; |
| 26927 | ZigType *src_type = ptr->value->type; | 27778 | ZigType *src_type = ptr->value->type; |
| 26928 | if (type_is_invalid(src_type)) | 27779 | if (type_is_invalid(src_type)) |
| 26929 | return ira->codegen->invalid_instruction; | 27780 | return ira->codegen->invalid_inst_gen; |
| 26930 | | 27781 | |
| 26931 | return ir_analyze_ptr_cast(ira, &instruction->base, ptr, dest_type, dest_type_value, | 27782 | return ir_analyze_ptr_cast(ira, &instruction->base.base, ptr, dest_type, &dest_type_value->base, |
| 26932 | instruction->safety_check_on); | 27783 | instruction->safety_check_on); |
| 26933 | } | 27784 | } |
| 26934 | | 27785 | |
| ... | @@ -27259,7 +28110,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou | ... | @@ -27259,7 +28110,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 27259 | zig_unreachable(); | 28110 | zig_unreachable(); |
| 27260 | } | 28111 | } |
| 27261 | | 28112 | |
| 27262 | static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *value, | 28113 | static IrInstGen *ir_analyze_bit_cast(IrAnalyze *ira, IrInst* source_instr, IrInstGen *value, |
| 27263 | ZigType *dest_type) | 28114 | ZigType *dest_type) |
| 27264 | { | 28115 | { |
| 27265 | Error err; | 28116 | Error err; |
| ... | @@ -27275,14 +28126,14 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -27275,14 +28126,14 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 27275 | buf_sprintf("cannot cast a value of type '%s'", buf_ptr(&dest_type->name))); | 28126 | buf_sprintf("cannot cast a value of type '%s'", buf_ptr(&dest_type->name))); |
| 27276 | add_error_note(ira->codegen, msg, source_instr->source_node, | 28127 | add_error_note(ira->codegen, msg, source_instr->source_node, |
| 27277 | buf_sprintf("use @intToEnum for type coercion")); | 28128 | buf_sprintf("use @intToEnum for type coercion")); |
| 27278 | return ira->codegen->invalid_instruction; | 28129 | return ira->codegen->invalid_inst_gen; |
| 27279 | } | 28130 | } |
| 27280 | | 28131 | |
| 27281 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusSizeKnown))) | 28132 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusSizeKnown))) |
| 27282 | return ira->codegen->invalid_instruction; | 28133 | return ira->codegen->invalid_inst_gen; |
| 27283 | | 28134 | |
| 27284 | if ((err = type_resolve(ira->codegen, src_type, ResolveStatusSizeKnown))) | 28135 | if ((err = type_resolve(ira->codegen, src_type, ResolveStatusSizeKnown))) |
| 27285 | return ira->codegen->invalid_instruction; | 28136 | return ira->codegen->invalid_inst_gen; |
| 27286 | | 28137 | |
| 27287 | uint64_t dest_size_bytes = type_size(ira->codegen, dest_type); | 28138 | uint64_t dest_size_bytes = type_size(ira->codegen, dest_type); |
| 27288 | uint64_t src_size_bytes = type_size(ira->codegen, src_type); | 28139 | uint64_t src_size_bytes = type_size(ira->codegen, src_type); |
| ... | @@ -27291,7 +28142,7 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -27291,7 +28142,7 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 27291 | buf_sprintf("destination type '%s' has size %" ZIG_PRI_u64 " but source type '%s' has size %" ZIG_PRI_u64, | 28142 | buf_sprintf("destination type '%s' has size %" ZIG_PRI_u64 " but source type '%s' has size %" ZIG_PRI_u64, |
| 27292 | buf_ptr(&dest_type->name), dest_size_bytes, | 28143 | buf_ptr(&dest_type->name), dest_size_bytes, |
| 27293 | buf_ptr(&src_type->name), src_size_bytes)); | 28144 | buf_ptr(&src_type->name), src_size_bytes)); |
| 27294 | return ira->codegen->invalid_instruction; | 28145 | return ira->codegen->invalid_inst_gen; |
| 27295 | } | 28146 | } |
| 27296 | | 28147 | |
| 27297 | uint64_t dest_size_bits = type_size_bits(ira->codegen, dest_type); | 28148 | uint64_t dest_size_bits = type_size_bits(ira->codegen, dest_type); |
| ... | @@ -27301,26 +28152,26 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ | ... | @@ -27301,26 +28152,26 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 27301 | buf_sprintf("destination type '%s' has %" ZIG_PRI_u64 " bits but source type '%s' has %" ZIG_PRI_u64 " bits", | 28152 | buf_sprintf("destination type '%s' has %" ZIG_PRI_u64 " bits but source type '%s' has %" ZIG_PRI_u64 " bits", |
| 27302 | buf_ptr(&dest_type->name), dest_size_bits, | 28153 | buf_ptr(&dest_type->name), dest_size_bits, |
| 27303 | buf_ptr(&src_type->name), src_size_bits)); | 28154 | buf_ptr(&src_type->name), src_size_bits)); |
| 27304 | return ira->codegen->invalid_instruction; | 28155 | return ira->codegen->invalid_inst_gen; |
| 27305 | } | 28156 | } |
| 27306 | | 28157 | |
| 27307 | if (instr_is_comptime(value)) { | 28158 | if (instr_is_comptime(value)) { |
| 27308 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); | 28159 | ZigValue *val = ir_resolve_const(ira, value, UndefBad); |
| 27309 | if (!val) | 28160 | if (!val) |
| 27310 | return ira->codegen->invalid_instruction; | 28161 | return ira->codegen->invalid_inst_gen; |
| 27311 | | 28162 | |
| 27312 | IrInstruction *result = ir_const(ira, source_instr, dest_type); | 28163 | IrInstGen *result = ir_const(ira, source_instr, dest_type); |
| 27313 | uint8_t *buf = allocate_nonzero<uint8_t>(src_size_bytes); | 28164 | uint8_t *buf = allocate_nonzero<uint8_t>(src_size_bytes); |
| 27314 | buf_write_value_bytes(ira->codegen, buf, val); | 28165 | buf_write_value_bytes(ira->codegen, buf, val); |
| 27315 | if ((err = buf_read_value_bytes(ira, ira->codegen, source_instr->source_node, buf, result->value))) | 28166 | if ((err = buf_read_value_bytes(ira, ira->codegen, source_instr->source_node, buf, result->value))) |
| 27316 | return ira->codegen->invalid_instruction; | 28167 | return ira->codegen->invalid_inst_gen; |
| 27317 | return result; | 28168 | return result; |
| 27318 | } | 28169 | } |
| 27319 | | 28170 | |
| 27320 | return ir_build_bit_cast_gen(ira, source_instr, value, dest_type); | 28171 | return ir_build_bit_cast_gen(ira, source_instr, value, dest_type); |
| 27321 | } | 28172 | } |
| 27322 | | 28173 | |
| 27323 | static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, | 28174 | static IrInstGen *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInst* source_instr, IrInstGen *target, |
| 27324 | ZigType *ptr_type) | 28175 | ZigType *ptr_type) |
| 27325 | { | 28176 | { |
| 27326 | Error err; | 28177 | Error err; |
| ... | @@ -27328,136 +28179,128 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc | ... | @@ -27328,136 +28179,128 @@ static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *sourc |
| 27328 | ir_assert(get_src_ptr_type(ptr_type) != nullptr, source_instr); | 28179 | ir_assert(get_src_ptr_type(ptr_type) != nullptr, source_instr); |
| 27329 | ir_assert(type_has_bits(ptr_type), source_instr); | 28180 | ir_assert(type_has_bits(ptr_type), source_instr); |
| 27330 | | 28181 | |
| 27331 | IrInstruction *casted_int = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_usize); | 28182 | IrInstGen *casted_int = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_usize); |
| 27332 | if (type_is_invalid(casted_int->value->type)) | 28183 | if (type_is_invalid(casted_int->value->type)) |
| 27333 | return ira->codegen->invalid_instruction; | 28184 | return ira->codegen->invalid_inst_gen; |
| 27334 | | 28185 | |
| 27335 | if (instr_is_comptime(casted_int)) { | 28186 | if (instr_is_comptime(casted_int)) { |
| 27336 | ZigValue *val = ir_resolve_const(ira, casted_int, UndefBad); | 28187 | ZigValue *val = ir_resolve_const(ira, casted_int, UndefBad); |
| 27337 | if (!val) | 28188 | if (!val) |
| 27338 | return ira->codegen->invalid_instruction; | 28189 | return ira->codegen->invalid_inst_gen; |
| 27339 | | 28190 | |
| 27340 | uint64_t addr = bigint_as_u64(&val->data.x_bigint); | 28191 | uint64_t addr = bigint_as_u64(&val->data.x_bigint); |
| 27341 | if (!ptr_allows_addr_zero(ptr_type) && addr == 0) { | 28192 | if (!ptr_allows_addr_zero(ptr_type) && addr == 0) { |
| 27342 | ir_add_error(ira, source_instr, | 28193 | ir_add_error(ira, source_instr, |
| 27343 | buf_sprintf("pointer type '%s' does not allow address zero", buf_ptr(&ptr_type->name))); | 28194 | buf_sprintf("pointer type '%s' does not allow address zero", buf_ptr(&ptr_type->name))); |
| 27344 | return ira->codegen->invalid_instruction; | 28195 | return ira->codegen->invalid_inst_gen; |
| 27345 | } | 28196 | } |
| 27346 | | 28197 | |
| 27347 | uint32_t align_bytes; | 28198 | uint32_t align_bytes; |
| 27348 | if ((err = resolve_ptr_align(ira, ptr_type, &align_bytes))) | 28199 | if ((err = resolve_ptr_align(ira, ptr_type, &align_bytes))) |
| 27349 | return ira->codegen->invalid_instruction; | 28200 | return ira->codegen->invalid_inst_gen; |
| 27350 | | 28201 | |
| 27351 | if (addr != 0 && addr % align_bytes != 0) { | 28202 | if (addr != 0 && addr % align_bytes != 0) { |
| 27352 | ir_add_error(ira, source_instr, | 28203 | ir_add_error(ira, source_instr, |
| 27353 | buf_sprintf("pointer type '%s' requires aligned address", | 28204 | buf_sprintf("pointer type '%s' requires aligned address", |
| 27354 | buf_ptr(&ptr_type->name))); | 28205 | buf_ptr(&ptr_type->name))); |
| 27355 | return ira->codegen->invalid_instruction; | 28206 | return ira->codegen->invalid_inst_gen; |
| 27356 | } | 28207 | } |
| 27357 | | 28208 | |
| 27358 | IrInstruction *result = ir_const(ira, source_instr, ptr_type); | 28209 | IrInstGen *result = ir_const(ira, source_instr, ptr_type); |
| 27359 | result->value->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; | 28210 | result->value->data.x_ptr.special = ConstPtrSpecialHardCodedAddr; |
| 27360 | result->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; | 28211 | result->value->data.x_ptr.mut = ConstPtrMutRuntimeVar; |
| 27361 | result->value->data.x_ptr.data.hard_coded_addr.addr = addr; | 28212 | result->value->data.x_ptr.data.hard_coded_addr.addr = addr; |
| 27362 | return result; | 28213 | return result; |
| 27363 | } | 28214 | } |
| 27364 | | 28215 | |
| 27365 | IrInstruction *result = ir_build_int_to_ptr(&ira->new_irb, source_instr->scope, | 28216 | return ir_build_int_to_ptr_gen(ira, source_instr->scope, source_instr->source_node, casted_int, ptr_type); |
| 27366 | source_instr->source_node, nullptr, casted_int); | | |
| 27367 | result->value->type = ptr_type; | | |
| 27368 | return result; | | |
| 27369 | } | 28217 | } |
| 27370 | | 28218 | |
| 27371 | static IrInstruction *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstructionIntToPtr *instruction) { | 28219 | static IrInstGen *ir_analyze_instruction_int_to_ptr(IrAnalyze *ira, IrInstSrcIntToPtr *instruction) { |
| 27372 | Error err; | 28220 | Error err; |
| 27373 | IrInstruction *dest_type_value = instruction->dest_type->child; | 28221 | IrInstGen *dest_type_value = instruction->dest_type->child; |
| 27374 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); | 28222 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); |
| 27375 | if (type_is_invalid(dest_type)) | 28223 | if (type_is_invalid(dest_type)) |
| 27376 | return ira->codegen->invalid_instruction; | 28224 | return ira->codegen->invalid_inst_gen; |
| 27377 | | 28225 | |
| 27378 | // We explicitly check for the size, so we can use get_src_ptr_type | 28226 | // We explicitly check for the size, so we can use get_src_ptr_type |
| 27379 | if (get_src_ptr_type(dest_type) == nullptr) { | 28227 | if (get_src_ptr_type(dest_type) == nullptr) { |
| 27380 | ir_add_error(ira, dest_type_value, buf_sprintf("expected pointer, found '%s'", buf_ptr(&dest_type->name))); | 28228 | ir_add_error(ira, &dest_type_value->base, buf_sprintf("expected pointer, found '%s'", buf_ptr(&dest_type->name))); |
| 27381 | return ira->codegen->invalid_instruction; | 28229 | return ira->codegen->invalid_inst_gen; |
| 27382 | } | 28230 | } |
| 27383 | | 28231 | |
| 27384 | bool has_bits; | 28232 | bool has_bits; |
| 27385 | if ((err = type_has_bits2(ira->codegen, dest_type, &has_bits))) | 28233 | if ((err = type_has_bits2(ira->codegen, dest_type, &has_bits))) |
| 27386 | return ira->codegen->invalid_instruction; | 28234 | return ira->codegen->invalid_inst_gen; |
| 27387 | | 28235 | |
| 27388 | if (!has_bits) { | 28236 | if (!has_bits) { |
| 27389 | ir_add_error(ira, dest_type_value, | 28237 | ir_add_error(ira, &dest_type_value->base, |
| 27390 | buf_sprintf("type '%s' has 0 bits and cannot store information", buf_ptr(&dest_type->name))); | 28238 | buf_sprintf("type '%s' has 0 bits and cannot store information", buf_ptr(&dest_type->name))); |
| 27391 | return ira->codegen->invalid_instruction; | 28239 | return ira->codegen->invalid_inst_gen; |
| 27392 | } | 28240 | } |
| 27393 | | 28241 | |
| 27394 | IrInstruction *target = instruction->target->child; | 28242 | IrInstGen *target = instruction->target->child; |
| 27395 | if (type_is_invalid(target->value->type)) | 28243 | if (type_is_invalid(target->value->type)) |
| 27396 | return ira->codegen->invalid_instruction; | 28244 | return ira->codegen->invalid_inst_gen; |
| 27397 | | 28245 | |
| 27398 | return ir_analyze_int_to_ptr(ira, &instruction->base, target, dest_type); | 28246 | return ir_analyze_int_to_ptr(ira, &instruction->base.base, target, dest_type); |
| 27399 | } | 28247 | } |
| 27400 | | 28248 | |
| 27401 | static IrInstruction *ir_analyze_instruction_decl_ref(IrAnalyze *ira, | 28249 | static IrInstGen *ir_analyze_instruction_decl_ref(IrAnalyze *ira, IrInstSrcDeclRef *instruction) { |
| 27402 | IrInstructionDeclRef *instruction) | 28250 | IrInstGen *ref_instruction = ir_analyze_decl_ref(ira, &instruction->base.base, instruction->tld); |
| 27403 | { | | |
| 27404 | IrInstruction *ref_instruction = ir_analyze_decl_ref(ira, &instruction->base, instruction->tld); | | |
| 27405 | if (type_is_invalid(ref_instruction->value->type)) { | 28251 | if (type_is_invalid(ref_instruction->value->type)) { |
| 27406 | return ira->codegen->invalid_instruction; | 28252 | return ira->codegen->invalid_inst_gen; |
| 27407 | } | 28253 | } |
| 27408 | | 28254 | |
| 27409 | if (instruction->lval == LValPtr) { | 28255 | if (instruction->lval == LValPtr) { |
| 27410 | return ref_instruction; | 28256 | return ref_instruction; |
| 27411 | } else { | 28257 | } else { |
| 27412 | return ir_get_deref(ira, &instruction->base, ref_instruction, nullptr); | 28258 | return ir_get_deref(ira, &instruction->base.base, ref_instruction, nullptr); |
| 27413 | } | 28259 | } |
| 27414 | } | 28260 | } |
| 27415 | | 28261 | |
| 27416 | static IrInstruction *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstructionPtrToInt *instruction) { | 28262 | static IrInstGen *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstSrcPtrToInt *instruction) { |
| 27417 | Error err; | 28263 | Error err; |
| 27418 | IrInstruction *target = instruction->target->child; | 28264 | IrInstGen *target = instruction->target->child; |
| 27419 | if (type_is_invalid(target->value->type)) | 28265 | if (type_is_invalid(target->value->type)) |
| 27420 | return ira->codegen->invalid_instruction; | 28266 | return ira->codegen->invalid_inst_gen; |
| 27421 | | 28267 | |
| 27422 | ZigType *usize = ira->codegen->builtin_types.entry_usize; | 28268 | ZigType *usize = ira->codegen->builtin_types.entry_usize; |
| 27423 | | 28269 | |
| 27424 | // We check size explicitly so we can use get_src_ptr_type here. | 28270 | // We check size explicitly so we can use get_src_ptr_type here. |
| 27425 | if (get_src_ptr_type(target->value->type) == nullptr) { | 28271 | if (get_src_ptr_type(target->value->type) == nullptr) { |
| 27426 | ir_add_error(ira, target, | 28272 | ir_add_error(ira, &target->base, |
| 27427 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&target->value->type->name))); | 28273 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&target->value->type->name))); |
| 27428 | return ira->codegen->invalid_instruction; | 28274 | return ira->codegen->invalid_inst_gen; |
| 27429 | } | 28275 | } |
| 27430 | | 28276 | |
| 27431 | bool has_bits; | 28277 | bool has_bits; |
| 27432 | if ((err = type_has_bits2(ira->codegen, target->value->type, &has_bits))) | 28278 | if ((err = type_has_bits2(ira->codegen, target->value->type, &has_bits))) |
| 27433 | return ira->codegen->invalid_instruction; | 28279 | return ira->codegen->invalid_inst_gen; |
| 27434 | | 28280 | |
| 27435 | if (!has_bits) { | 28281 | if (!has_bits) { |
| 27436 | ir_add_error(ira, target, | 28282 | ir_add_error(ira, &target->base, |
| 27437 | buf_sprintf("pointer to size 0 type has no address")); | 28283 | buf_sprintf("pointer to size 0 type has no address")); |
| 27438 | return ira->codegen->invalid_instruction; | 28284 | return ira->codegen->invalid_inst_gen; |
| 27439 | } | 28285 | } |
| 27440 | | 28286 | |
| 27441 | if (instr_is_comptime(target)) { | 28287 | if (instr_is_comptime(target)) { |
| 27442 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); | 28288 | ZigValue *val = ir_resolve_const(ira, target, UndefBad); |
| 27443 | if (!val) | 28289 | if (!val) |
| 27444 | return ira->codegen->invalid_instruction; | 28290 | return ira->codegen->invalid_inst_gen; |
| 27445 | if (val->type->id == ZigTypeIdPointer && val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { | 28291 | if (val->type->id == ZigTypeIdPointer && val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { |
| 27446 | IrInstruction *result = ir_const(ira, &instruction->base, usize); | 28292 | IrInstGen *result = ir_const(ira, &instruction->base.base, usize); |
| 27447 | bigint_init_unsigned(&result->value->data.x_bigint, val->data.x_ptr.data.hard_coded_addr.addr); | 28293 | bigint_init_unsigned(&result->value->data.x_bigint, val->data.x_ptr.data.hard_coded_addr.addr); |
| 27448 | result->value->type = usize; | 28294 | result->value->type = usize; |
| 27449 | return result; | 28295 | return result; |
| 27450 | } | 28296 | } |
| 27451 | } | 28297 | } |
| 27452 | | 28298 | |
| 27453 | IrInstruction *result = ir_build_ptr_to_int(&ira->new_irb, instruction->base.scope, | 28299 | return ir_build_ptr_to_int_gen(ira, &instruction->base.base, target); |
| 27454 | instruction->base.source_node, target); | | |
| 27455 | result->value->type = usize; | | |
| 27456 | return result; | | |
| 27457 | } | 28300 | } |
| 27458 | | 28301 | |
| 27459 | static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstructionPtrType *instruction) { | 28302 | static IrInstGen *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstSrcPtrType *instruction) { |
| 27460 | IrInstruction *result = ir_const(ira, &instruction->base, ira->codegen->builtin_types.entry_type); | 28303 | IrInstGen *result = ir_const(ira, &instruction->base.base, ira->codegen->builtin_types.entry_type); |
| 27461 | result->value->special = ConstValSpecialLazy; | 28304 | result->value->special = ConstValSpecialLazy; |
| 27462 | | 28305 | |
| 27463 | LazyValuePtrType *lazy_ptr_type = allocate<LazyValuePtrType>(1, "LazyValuePtrType"); | 28306 | LazyValuePtrType *lazy_ptr_type = allocate<LazyValuePtrType>(1, "LazyValuePtrType"); |
| ... | @@ -27468,17 +28311,17 @@ static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruct | ... | @@ -27468,17 +28311,17 @@ static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruct |
| 27468 | if (instruction->sentinel != nullptr) { | 28311 | if (instruction->sentinel != nullptr) { |
| 27469 | lazy_ptr_type->sentinel = instruction->sentinel->child; | 28312 | lazy_ptr_type->sentinel = instruction->sentinel->child; |
| 27470 | if (ir_resolve_const(ira, lazy_ptr_type->sentinel, LazyOk) == nullptr) | 28313 | if (ir_resolve_const(ira, lazy_ptr_type->sentinel, LazyOk) == nullptr) |
| 27471 | return ira->codegen->invalid_instruction; | 28314 | return ira->codegen->invalid_inst_gen; |
| 27472 | } | 28315 | } |
| 27473 | | 28316 | |
| 27474 | lazy_ptr_type->elem_type = instruction->child_type->child; | 28317 | lazy_ptr_type->elem_type = instruction->child_type->child; |
| 27475 | if (ir_resolve_type_lazy(ira, lazy_ptr_type->elem_type) == nullptr) | 28318 | if (ir_resolve_type_lazy(ira, lazy_ptr_type->elem_type) == nullptr) |
| 27476 | return ira->codegen->invalid_instruction; | 28319 | return ira->codegen->invalid_inst_gen; |
| 27477 | | 28320 | |
| 27478 | if (instruction->align_value != nullptr) { | 28321 | if (instruction->align_value != nullptr) { |
| 27479 | lazy_ptr_type->align_inst = instruction->align_value->child; | 28322 | lazy_ptr_type->align_inst = instruction->align_value->child; |
| 27480 | if (ir_resolve_const(ira, lazy_ptr_type->align_inst, LazyOk) == nullptr) | 28323 | if (ir_resolve_const(ira, lazy_ptr_type->align_inst, LazyOk) == nullptr) |
| 27481 | return ira->codegen->invalid_instruction; | 28324 | return ira->codegen->invalid_inst_gen; |
| 27482 | } | 28325 | } |
| 27483 | | 28326 | |
| 27484 | lazy_ptr_type->ptr_len = instruction->ptr_len; | 28327 | lazy_ptr_type->ptr_len = instruction->ptr_len; |
| ... | @@ -27491,10 +28334,10 @@ static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruct | ... | @@ -27491,10 +28334,10 @@ static IrInstruction *ir_analyze_instruction_ptr_type(IrAnalyze *ira, IrInstruct |
| 27491 | return result; | 28334 | return result; |
| 27492 | } | 28335 | } |
| 27493 | | 28336 | |
| 27494 | static IrInstruction *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstructionAlignCast *instruction) { | 28337 | static IrInstGen *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstSrcAlignCast *instruction) { |
| 27495 | IrInstruction *target = instruction->target->child; | 28338 | IrInstGen *target = instruction->target->child; |
| 27496 | if (type_is_invalid(target->value->type)) | 28339 | if (type_is_invalid(target->value->type)) |
| 27497 | return ira->codegen->invalid_instruction; | 28340 | return ira->codegen->invalid_inst_gen; |
| 27498 | | 28341 | |
| 27499 | ZigType *elem_type = nullptr; | 28342 | ZigType *elem_type = nullptr; |
| 27500 | if (is_slice(target->value->type)) { | 28343 | if (is_slice(target->value->type)) { |
| ... | @@ -27505,192 +28348,192 @@ static IrInstruction *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstru | ... | @@ -27505,192 +28348,192 @@ static IrInstruction *ir_analyze_instruction_align_cast(IrAnalyze *ira, IrInstru |
| 27505 | } | 28348 | } |
| 27506 | | 28349 | |
| 27507 | uint32_t align_bytes; | 28350 | uint32_t align_bytes; |
| 27508 | IrInstruction *align_bytes_inst = instruction->align_bytes->child; | 28351 | IrInstGen *align_bytes_inst = instruction->align_bytes->child; |
| 27509 | if (!ir_resolve_align(ira, align_bytes_inst, elem_type, &align_bytes)) | 28352 | if (!ir_resolve_align(ira, align_bytes_inst, elem_type, &align_bytes)) |
| 27510 | return ira->codegen->invalid_instruction; | 28353 | return ira->codegen->invalid_inst_gen; |
| 27511 | | 28354 | |
| 27512 | IrInstruction *result = ir_align_cast(ira, target, align_bytes, true); | 28355 | IrInstGen *result = ir_align_cast(ira, target, align_bytes, true); |
| 27513 | if (type_is_invalid(result->value->type)) | 28356 | if (type_is_invalid(result->value->type)) |
| 27514 | return ira->codegen->invalid_instruction; | 28357 | return ira->codegen->invalid_inst_gen; |
| 27515 | | 28358 | |
| 27516 | return result; | 28359 | return result; |
| 27517 | } | 28360 | } |
| 27518 | | 28361 | |
| 27519 | static IrInstruction *ir_analyze_instruction_opaque_type(IrAnalyze *ira, IrInstructionOpaqueType *instruction) { | 28362 | static IrInstGen *ir_analyze_instruction_opaque_type(IrAnalyze *ira, IrInstSrcOpaqueType *instruction) { |
| 27520 | Buf *bare_name = buf_alloc(); | 28363 | Buf *bare_name = buf_alloc(); |
| 27521 | Buf *full_name = get_anon_type_name(ira->codegen, ira->new_irb.exec, "opaque", | 28364 | Buf *full_name = get_anon_type_name(ira->codegen, ira->old_irb.exec, "opaque", |
| 27522 | instruction->base.scope, instruction->base.source_node, bare_name); | 28365 | instruction->base.base.scope, instruction->base.base.source_node, bare_name); |
| 27523 | ZigType *result_type = get_opaque_type(ira->codegen, instruction->base.scope, instruction->base.source_node, | 28366 | ZigType *result_type = get_opaque_type(ira->codegen, instruction->base.base.scope, |
| 27524 | buf_ptr(full_name), bare_name); | 28367 | instruction->base.base.source_node, buf_ptr(full_name), bare_name); |
| 27525 | return ir_const_type(ira, &instruction->base, result_type); | 28368 | return ir_const_type(ira, &instruction->base.base, result_type); |
| 27526 | } | 28369 | } |
| 27527 | | 28370 | |
| 27528 | static IrInstruction *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstructionSetAlignStack *instruction) { | 28371 | static IrInstGen *ir_analyze_instruction_set_align_stack(IrAnalyze *ira, IrInstSrcSetAlignStack *instruction) { |
| 27529 | uint32_t align_bytes; | 28372 | uint32_t align_bytes; |
| 27530 | IrInstruction *align_bytes_inst = instruction->align_bytes->child; | 28373 | IrInstGen *align_bytes_inst = instruction->align_bytes->child; |
| 27531 | if (!ir_resolve_align(ira, align_bytes_inst, nullptr, &align_bytes)) | 28374 | if (!ir_resolve_align(ira, align_bytes_inst, nullptr, &align_bytes)) |
| 27532 | return ira->codegen->invalid_instruction; | 28375 | return ira->codegen->invalid_inst_gen; |
| 27533 | | 28376 | |
| 27534 | if (align_bytes > 256) { | 28377 | if (align_bytes > 256) { |
| 27535 | ir_add_error(ira, &instruction->base, buf_sprintf("attempt to @setAlignStack(%" PRIu32 "); maximum is 256", align_bytes)); | 28378 | ir_add_error(ira, &instruction->base.base, buf_sprintf("attempt to @setAlignStack(%" PRIu32 "); maximum is 256", align_bytes)); |
| 27536 | return ira->codegen->invalid_instruction; | 28379 | return ira->codegen->invalid_inst_gen; |
| 27537 | } | 28380 | } |
| 27538 | | 28381 | |
| 27539 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 28382 | ZigFn *fn_entry = ira->new_irb.exec->fn_entry; |
| 27540 | if (fn_entry == nullptr) { | 28383 | if (fn_entry == nullptr) { |
| 27541 | ir_add_error(ira, &instruction->base, buf_sprintf("@setAlignStack outside function")); | 28384 | ir_add_error(ira, &instruction->base.base, buf_sprintf("@setAlignStack outside function")); |
| 27542 | return ira->codegen->invalid_instruction; | 28385 | return ira->codegen->invalid_inst_gen; |
| 27543 | } | 28386 | } |
| 27544 | if (fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionNaked) { | 28387 | if (fn_entry->type_entry->data.fn.fn_type_id.cc == CallingConventionNaked) { |
| 27545 | ir_add_error(ira, &instruction->base, buf_sprintf("@setAlignStack in naked function")); | 28388 | ir_add_error(ira, &instruction->base.base, buf_sprintf("@setAlignStack in naked function")); |
| 27546 | return ira->codegen->invalid_instruction; | 28389 | return ira->codegen->invalid_inst_gen; |
| 27547 | } | 28390 | } |
| 27548 | | 28391 | |
| 27549 | if (fn_entry->fn_inline == FnInlineAlways) { | 28392 | if (fn_entry->fn_inline == FnInlineAlways) { |
| 27550 | ir_add_error(ira, &instruction->base, buf_sprintf("@setAlignStack in inline function")); | 28393 | ir_add_error(ira, &instruction->base.base, buf_sprintf("@setAlignStack in inline function")); |
| 27551 | return ira->codegen->invalid_instruction; | 28394 | return ira->codegen->invalid_inst_gen; |
| 27552 | } | 28395 | } |
| 27553 | | 28396 | |
| 27554 | if (fn_entry->set_alignstack_node != nullptr) { | 28397 | if (fn_entry->set_alignstack_node != nullptr) { |
| 27555 | ErrorMsg *msg = ir_add_error_node(ira, instruction->base.source_node, | 28398 | ErrorMsg *msg = ir_add_error(ira, &instruction->base.base, |
| 27556 | buf_sprintf("alignstack set twice")); | 28399 | buf_sprintf("alignstack set twice")); |
| 27557 | add_error_note(ira->codegen, msg, fn_entry->set_alignstack_node, buf_sprintf("first set here")); | 28400 | add_error_note(ira->codegen, msg, fn_entry->set_alignstack_node, buf_sprintf("first set here")); |
| 27558 | return ira->codegen->invalid_instruction; | 28401 | return ira->codegen->invalid_inst_gen; |
| 27559 | } | 28402 | } |
| 27560 | | 28403 | |
| 27561 | fn_entry->set_alignstack_node = instruction->base.source_node; | 28404 | fn_entry->set_alignstack_node = instruction->base.base.source_node; |
| 27562 | fn_entry->alignstack_value = align_bytes; | 28405 | fn_entry->alignstack_value = align_bytes; |
| 27563 | | 28406 | |
| 27564 | return ir_const_void(ira, &instruction->base); | 28407 | return ir_const_void(ira, &instruction->base.base); |
| 27565 | } | 28408 | } |
| 27566 | | 28409 | |
| 27567 | static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstructionArgType *instruction) { | 28410 | static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgType *instruction) { |
| 27568 | IrInstruction *fn_type_inst = instruction->fn_type->child; | 28411 | IrInstGen *fn_type_inst = instruction->fn_type->child; |
| 27569 | ZigType *fn_type = ir_resolve_type(ira, fn_type_inst); | 28412 | ZigType *fn_type = ir_resolve_type(ira, fn_type_inst); |
| 27570 | if (type_is_invalid(fn_type)) | 28413 | if (type_is_invalid(fn_type)) |
| 27571 | return ira->codegen->invalid_instruction; | 28414 | return ira->codegen->invalid_inst_gen; |
| 27572 | | 28415 | |
| 27573 | IrInstruction *arg_index_inst = instruction->arg_index->child; | 28416 | IrInstGen *arg_index_inst = instruction->arg_index->child; |
| 27574 | uint64_t arg_index; | 28417 | uint64_t arg_index; |
| 27575 | if (!ir_resolve_usize(ira, arg_index_inst, &arg_index)) | 28418 | if (!ir_resolve_usize(ira, arg_index_inst, &arg_index)) |
| 27576 | return ira->codegen->invalid_instruction; | 28419 | return ira->codegen->invalid_inst_gen; |
| 27577 | | 28420 | |
| 27578 | if (fn_type->id == ZigTypeIdBoundFn) { | 28421 | if (fn_type->id == ZigTypeIdBoundFn) { |
| 27579 | fn_type = fn_type->data.bound_fn.fn_type; | 28422 | fn_type = fn_type->data.bound_fn.fn_type; |
| 27580 | arg_index += 1; | 28423 | arg_index += 1; |
| 27581 | } | 28424 | } |
| 27582 | if (fn_type->id != ZigTypeIdFn) { | 28425 | if (fn_type->id != ZigTypeIdFn) { |
| 27583 | ir_add_error(ira, fn_type_inst, buf_sprintf("expected function, found '%s'", buf_ptr(&fn_type->name))); | 28426 | ir_add_error(ira, &fn_type_inst->base, buf_sprintf("expected function, found '%s'", buf_ptr(&fn_type->name))); |
| 27584 | return ira->codegen->invalid_instruction; | 28427 | return ira->codegen->invalid_inst_gen; |
| 27585 | } | 28428 | } |
| 27586 | | 28429 | |
| 27587 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; | 28430 | FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; |
| 27588 | if (arg_index >= fn_type_id->param_count) { | 28431 | if (arg_index >= fn_type_id->param_count) { |
| 27589 | if (instruction->allow_var) { | 28432 | if (instruction->allow_var) { |
| 27590 | // TODO remove this with var args | 28433 | // TODO remove this with var args |
| 27591 | return ir_const_type(ira, &instruction->base, ira->codegen->builtin_types.entry_var); | 28434 | return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_var); |
| 27592 | } | 28435 | } |
| 27593 | ir_add_error(ira, arg_index_inst, | 28436 | ir_add_error(ira, &arg_index_inst->base, |
| 27594 | buf_sprintf("arg index %" ZIG_PRI_u64 " out of bounds; '%s' has %" ZIG_PRI_usize " arguments", | 28437 | buf_sprintf("arg index %" ZIG_PRI_u64 " out of bounds; '%s' has %" ZIG_PRI_usize " arguments", |
| 27595 | arg_index, buf_ptr(&fn_type->name), fn_type_id->param_count)); | 28438 | arg_index, buf_ptr(&fn_type->name), fn_type_id->param_count)); |
| 27596 | return ira->codegen->invalid_instruction; | 28439 | return ira->codegen->invalid_inst_gen; |
| 27597 | } | 28440 | } |
| 27598 | | 28441 | |
| 27599 | ZigType *result_type = fn_type_id->param_info[arg_index].type; | 28442 | ZigType *result_type = fn_type_id->param_info[arg_index].type; |
| 27600 | if (result_type == nullptr) { | 28443 | if (result_type == nullptr) { |
| 27601 | // Args are only unresolved if our function is generic. | 28444 | // Args are only unresolved if our function is generic. |
| 27602 | ir_assert(fn_type->data.fn.is_generic, &instruction->base); | 28445 | ir_assert(fn_type->data.fn.is_generic, &instruction->base.base); |
| 27603 | | 28446 | |
| 27604 | if (instruction->allow_var) { | 28447 | if (instruction->allow_var) { |
| 27605 | 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); |
| 27606 | } else { | 28449 | } else { |
| 27607 | ir_add_error(ira, arg_index_inst, | 28450 | ir_add_error(ira, &arg_index_inst->base, |
| 27608 | buf_sprintf("@ArgType could not resolve the type of arg %" ZIG_PRI_u64 " because '%s' is generic", | 28451 | buf_sprintf("@ArgType could not resolve the type of arg %" ZIG_PRI_u64 " because '%s' is generic", |
| 27609 | arg_index, buf_ptr(&fn_type->name))); | 28452 | arg_index, buf_ptr(&fn_type->name))); |
| 27610 | return ira->codegen->invalid_instruction; | 28453 | return ira->codegen->invalid_inst_gen; |
| 27611 | } | 28454 | } |
| 27612 | } | 28455 | } |
| 27613 | return ir_const_type(ira, &instruction->base, result_type); | 28456 | return ir_const_type(ira, &instruction->base.base, result_type); |
| 27614 | } | 28457 | } |
| 27615 | | 28458 | |
| 27616 | static IrInstruction *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstructionTagType *instruction) { | 28459 | static IrInstGen *ir_analyze_instruction_tag_type(IrAnalyze *ira, IrInstSrcTagType *instruction) { |
| 27617 | Error err; | 28460 | Error err; |
| 27618 | IrInstruction *target_inst = instruction->target->child; | 28461 | IrInstGen *target_inst = instruction->target->child; |
| 27619 | ZigType *enum_type = ir_resolve_type(ira, target_inst); | 28462 | ZigType *enum_type = ir_resolve_type(ira, target_inst); |
| 27620 | if (type_is_invalid(enum_type)) | 28463 | if (type_is_invalid(enum_type)) |
| 27621 | return ira->codegen->invalid_instruction; | 28464 | return ira->codegen->invalid_inst_gen; |
| 27622 | | 28465 | |
| 27623 | if (enum_type->id == ZigTypeIdEnum) { | 28466 | if (enum_type->id == ZigTypeIdEnum) { |
| 27624 | if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusSizeKnown))) | 28467 | if ((err = type_resolve(ira->codegen, enum_type, ResolveStatusSizeKnown))) |
| 27625 | return ira->codegen->invalid_instruction; | 28468 | return ira->codegen->invalid_inst_gen; |
| 27626 | | 28469 | |
| 27627 | return ir_const_type(ira, &instruction->base, enum_type->data.enumeration.tag_int_type); | 28470 | return ir_const_type(ira, &instruction->base.base, enum_type->data.enumeration.tag_int_type); |
| 27628 | } else if (enum_type->id == ZigTypeIdUnion) { | 28471 | } else if (enum_type->id == ZigTypeIdUnion) { |
| 27629 | ZigType *tag_type = ir_resolve_union_tag_type(ira, instruction->target, enum_type); | 28472 | ZigType *tag_type = ir_resolve_union_tag_type(ira, instruction->target->base.source_node, enum_type); |
| 27630 | if (type_is_invalid(tag_type)) | 28473 | if (type_is_invalid(tag_type)) |
| 27631 | return ira->codegen->invalid_instruction; | 28474 | return ira->codegen->invalid_inst_gen; |
| 27632 | return ir_const_type(ira, &instruction->base, tag_type); | 28475 | return ir_const_type(ira, &instruction->base.base, tag_type); |
| 27633 | } else { | 28476 | } else { |
| 27634 | ir_add_error(ira, target_inst, buf_sprintf("expected enum or union, found '%s'", | 28477 | ir_add_error(ira, &target_inst->base, buf_sprintf("expected enum or union, found '%s'", |
| 27635 | buf_ptr(&enum_type->name))); | 28478 | buf_ptr(&enum_type->name))); |
| 27636 | return ira->codegen->invalid_instruction; | 28479 | return ira->codegen->invalid_inst_gen; |
| 27637 | } | 28480 | } |
| 27638 | } | 28481 | } |
| 27639 | | 28482 | |
| 27640 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op) { | 28483 | static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstGen *op) { |
| 27641 | ZigType *operand_type = ir_resolve_type(ira, op); | 28484 | ZigType *operand_type = ir_resolve_type(ira, op); |
| 27642 | if (type_is_invalid(operand_type)) | 28485 | if (type_is_invalid(operand_type)) |
| 27643 | return ira->codegen->builtin_types.entry_invalid; | 28486 | return ira->codegen->builtin_types.entry_invalid; |
| 27644 | | 28487 | |
| 27645 | if (operand_type->id == ZigTypeIdInt) { | 28488 | if (operand_type->id == ZigTypeIdInt) { |
| 27646 | if (operand_type->data.integral.bit_count < 8) { | 28489 | if (operand_type->data.integral.bit_count < 8) { |
| 27647 | ir_add_error(ira, op, | 28490 | ir_add_error(ira, &op->base, |
| 27648 | buf_sprintf("expected integer type 8 bits or larger, found %" PRIu32 "-bit integer type", | 28491 | buf_sprintf("expected integer type 8 bits or larger, found %" PRIu32 "-bit integer type", |
| 27649 | operand_type->data.integral.bit_count)); | 28492 | operand_type->data.integral.bit_count)); |
| 27650 | return ira->codegen->builtin_types.entry_invalid; | 28493 | return ira->codegen->builtin_types.entry_invalid; |
| 27651 | } | 28494 | } |
| 27652 | uint32_t max_atomic_bits = target_arch_largest_atomic_bits(ira->codegen->zig_target->arch); | 28495 | uint32_t max_atomic_bits = target_arch_largest_atomic_bits(ira->codegen->zig_target->arch); |
| 27653 | if (operand_type->data.integral.bit_count > max_atomic_bits) { | 28496 | if (operand_type->data.integral.bit_count > max_atomic_bits) { |
| 27654 | ir_add_error(ira, op, | 28497 | ir_add_error(ira, &op->base, |
| 27655 | buf_sprintf("expected %" PRIu32 "-bit integer type or smaller, found %" PRIu32 "-bit integer type", | 28498 | buf_sprintf("expected %" PRIu32 "-bit integer type or smaller, found %" PRIu32 "-bit integer type", |
| 27656 | max_atomic_bits, operand_type->data.integral.bit_count)); | 28499 | max_atomic_bits, operand_type->data.integral.bit_count)); |
| 27657 | return ira->codegen->builtin_types.entry_invalid; | 28500 | return ira->codegen->builtin_types.entry_invalid; |
| 27658 | } | 28501 | } |
| 27659 | if (!is_power_of_2(operand_type->data.integral.bit_count)) { | 28502 | if (!is_power_of_2(operand_type->data.integral.bit_count)) { |
| 27660 | ir_add_error(ira, op, | 28503 | ir_add_error(ira, &op->base, |
| 27661 | buf_sprintf("%" PRIu32 "-bit integer type is not a power of 2", operand_type->data.integral.bit_count)); | 28504 | buf_sprintf("%" PRIu32 "-bit integer type is not a power of 2", operand_type->data.integral.bit_count)); |
| 27662 | return ira->codegen->builtin_types.entry_invalid; | 28505 | return ira->codegen->builtin_types.entry_invalid; |
| 27663 | } | 28506 | } |
| 27664 | } else if (operand_type->id == ZigTypeIdEnum) { | 28507 | } else if (operand_type->id == ZigTypeIdEnum) { |
| 27665 | ZigType *int_type = operand_type->data.enumeration.tag_int_type; | 28508 | ZigType *int_type = operand_type->data.enumeration.tag_int_type; |
| 27666 | if (int_type->data.integral.bit_count < 8) { | 28509 | if (int_type->data.integral.bit_count < 8) { |
| 27667 | ir_add_error(ira, op, | 28510 | ir_add_error(ira, &op->base, |
| 27668 | buf_sprintf("expected enum tag type 8 bits or larger, found %" PRIu32 "-bit tag type", | 28511 | buf_sprintf("expected enum tag type 8 bits or larger, found %" PRIu32 "-bit tag type", |
| 27669 | int_type->data.integral.bit_count)); | 28512 | int_type->data.integral.bit_count)); |
| 27670 | return ira->codegen->builtin_types.entry_invalid; | 28513 | return ira->codegen->builtin_types.entry_invalid; |
| 27671 | } | 28514 | } |
| 27672 | uint32_t max_atomic_bits = target_arch_largest_atomic_bits(ira->codegen->zig_target->arch); | 28515 | uint32_t max_atomic_bits = target_arch_largest_atomic_bits(ira->codegen->zig_target->arch); |
| 27673 | if (int_type->data.integral.bit_count > max_atomic_bits) { | 28516 | if (int_type->data.integral.bit_count > max_atomic_bits) { |
| 27674 | ir_add_error(ira, op, | 28517 | ir_add_error(ira, &op->base, |
| 27675 | buf_sprintf("expected %" PRIu32 "-bit enum tag type or smaller, found %" PRIu32 "-bit tag type", | 28518 | buf_sprintf("expected %" PRIu32 "-bit enum tag type or smaller, found %" PRIu32 "-bit tag type", |
| 27676 | max_atomic_bits, int_type->data.integral.bit_count)); | 28519 | max_atomic_bits, int_type->data.integral.bit_count)); |
| 27677 | return ira->codegen->builtin_types.entry_invalid; | 28520 | return ira->codegen->builtin_types.entry_invalid; |
| 27678 | } | 28521 | } |
| 27679 | if (!is_power_of_2(int_type->data.integral.bit_count)) { | 28522 | if (!is_power_of_2(int_type->data.integral.bit_count)) { |
| 27680 | ir_add_error(ira, op, | 28523 | ir_add_error(ira, &op->base, |
| 27681 | buf_sprintf("%" PRIu32 "-bit enum tag type is not a power of 2", int_type->data.integral.bit_count)); | 28524 | buf_sprintf("%" PRIu32 "-bit enum tag type is not a power of 2", int_type->data.integral.bit_count)); |
| 27682 | return ira->codegen->builtin_types.entry_invalid; | 28525 | return ira->codegen->builtin_types.entry_invalid; |
| 27683 | } | 28526 | } |
| 27684 | } else if (operand_type->id == ZigTypeIdFloat) { | 28527 | } else if (operand_type->id == ZigTypeIdFloat) { |
| 27685 | uint32_t max_atomic_bits = target_arch_largest_atomic_bits(ira->codegen->zig_target->arch); | 28528 | uint32_t max_atomic_bits = target_arch_largest_atomic_bits(ira->codegen->zig_target->arch); |
| 27686 | if (operand_type->data.floating.bit_count > max_atomic_bits) { | 28529 | if (operand_type->data.floating.bit_count > max_atomic_bits) { |
| 27687 | ir_add_error(ira, op, | 28530 | ir_add_error(ira, &op->base, |
| 27688 | buf_sprintf("expected %" PRIu32 "-bit float or smaller, found %" PRIu32 "-bit float", | 28531 | buf_sprintf("expected %" PRIu32 "-bit float or smaller, found %" PRIu32 "-bit float", |
| 27689 | max_atomic_bits, (uint32_t) operand_type->data.floating.bit_count)); | 28532 | max_atomic_bits, (uint32_t) operand_type->data.floating.bit_count)); |
| 27690 | return ira->codegen->builtin_types.entry_invalid; | 28533 | return ira->codegen->builtin_types.entry_invalid; |
| 27691 | } | 28534 | } |
| 27692 | } else if (get_codegen_ptr_type(operand_type) == nullptr) { | 28535 | } else if (get_codegen_ptr_type(operand_type) == nullptr) { |
| 27693 | ir_add_error(ira, op, | 28536 | ir_add_error(ira, &op->base, |
| 27694 | buf_sprintf("expected integer, float, enum or pointer type, found '%s'", buf_ptr(&operand_type->name))); | 28537 | buf_sprintf("expected integer, float, enum or pointer type, found '%s'", buf_ptr(&operand_type->name))); |
| 27695 | return ira->codegen->builtin_types.entry_invalid; | 28538 | return ira->codegen->builtin_types.entry_invalid; |
| 27696 | } | 28539 | } |
| ... | @@ -27698,172 +28541,146 @@ static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op | ... | @@ -27698,172 +28541,146 @@ static ZigType *ir_resolve_atomic_operand_type(IrAnalyze *ira, IrInstruction *op |
| 27698 | return operand_type; | 28541 | return operand_type; |
| 27699 | } | 28542 | } |
| 27700 | | 28543 | |
| 27701 | static IrInstruction *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstructionAtomicRmw *instruction) { | 28544 | static IrInstGen *ir_analyze_instruction_atomic_rmw(IrAnalyze *ira, IrInstSrcAtomicRmw *instruction) { |
| 27702 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->child); | 28545 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->child); |
| 27703 | if (type_is_invalid(operand_type)) | 28546 | if (type_is_invalid(operand_type)) |
| 27704 | return ira->codegen->invalid_instruction; | 28547 | return ira->codegen->invalid_inst_gen; |
| 27705 | | 28548 | |
| 27706 | IrInstruction *ptr_inst = instruction->ptr->child; | 28549 | IrInstGen *ptr_inst = instruction->ptr->child; |
| 27707 | if (type_is_invalid(ptr_inst->value->type)) | 28550 | if (type_is_invalid(ptr_inst->value->type)) |
| 27708 | return ira->codegen->invalid_instruction; | 28551 | return ira->codegen->invalid_inst_gen; |
| 27709 | | 28552 | |
| 27710 | // TODO let this be volatile | 28553 | // TODO let this be volatile |
| 27711 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); | 28554 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 27712 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | 28555 | IrInstGen *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); |
| 27713 | if (type_is_invalid(casted_ptr->value->type)) | 28556 | if (type_is_invalid(casted_ptr->value->type)) |
| 27714 | return ira->codegen->invalid_instruction; | 28557 | return ira->codegen->invalid_inst_gen; |
| 27715 | | 28558 | |
| 27716 | AtomicRmwOp op; | 28559 | AtomicRmwOp op; |
| 27717 | if (instruction->op == nullptr) { | 28560 | if (!ir_resolve_atomic_rmw_op(ira, instruction->op->child, &op)) { |
| 27718 | op = instruction->resolved_op; | 28561 | return ira->codegen->invalid_inst_gen; |
| 27719 | } else { | | |
| 27720 | if (!ir_resolve_atomic_rmw_op(ira, instruction->op->child, &op)) { | | |
| 27721 | return ira->codegen->invalid_instruction; | | |
| 27722 | } | | |
| 27723 | } | 28562 | } |
| 27724 | | 28563 | |
| 27725 | if (operand_type->id == ZigTypeIdEnum && op != AtomicRmwOp_xchg) { | 28564 | if (operand_type->id == ZigTypeIdEnum && op != AtomicRmwOp_xchg) { |
| 27726 | ir_add_error(ira, instruction->op, | 28565 | ir_add_error(ira, &instruction->op->base, |
| 27727 | buf_sprintf("@atomicRmw on enum only works with .Xchg")); | 28566 | buf_sprintf("@atomicRmw on enum only works with .Xchg")); |
| 27728 | return ira->codegen->invalid_instruction; | 28567 | return ira->codegen->invalid_inst_gen; |
| 27729 | } else if (operand_type->id == ZigTypeIdFloat && op > AtomicRmwOp_sub) { | 28568 | } else if (operand_type->id == ZigTypeIdFloat && op > AtomicRmwOp_sub) { |
| 27730 | ir_add_error(ira, instruction->op, | 28569 | ir_add_error(ira, &instruction->op->base, |
| 27731 | buf_sprintf("@atomicRmw with float only works with .Xchg, .Add and .Sub")); | 28570 | buf_sprintf("@atomicRmw with float only works with .Xchg, .Add and .Sub")); |
| 27732 | return ira->codegen->invalid_instruction; | 28571 | return ira->codegen->invalid_inst_gen; |
| 27733 | } | 28572 | } |
| 27734 | | 28573 | |
| 27735 | IrInstruction *operand = instruction->operand->child; | 28574 | IrInstGen *operand = instruction->operand->child; |
| 27736 | if (type_is_invalid(operand->value->type)) | 28575 | if (type_is_invalid(operand->value->type)) |
| 27737 | return ira->codegen->invalid_instruction; | 28576 | return ira->codegen->invalid_inst_gen; |
| 27738 | | 28577 | |
| 27739 | IrInstruction *casted_operand = ir_implicit_cast(ira, operand, operand_type); | 28578 | IrInstGen *casted_operand = ir_implicit_cast(ira, operand, operand_type); |
| 27740 | if (type_is_invalid(casted_operand->value->type)) | 28579 | if (type_is_invalid(casted_operand->value->type)) |
| 27741 | return ira->codegen->invalid_instruction; | 28580 | return ira->codegen->invalid_inst_gen; |
| 27742 | | 28581 | |
| 27743 | AtomicOrder ordering; | 28582 | AtomicOrder ordering; |
| 27744 | if (instruction->ordering == nullptr) { | 28583 | if (!ir_resolve_atomic_order(ira, instruction->ordering->child, &ordering)) |
| 27745 | ordering = instruction->resolved_ordering; | 28584 | return ira->codegen->invalid_inst_gen; |
| 27746 | } else { | 28585 | if (ordering == AtomicOrderUnordered) { |
| 27747 | if (!ir_resolve_atomic_order(ira, instruction->ordering->child, &ordering)) | 28586 | ir_add_error(ira, &instruction->ordering->base, |
| 27748 | return ira->codegen->invalid_instruction; | 28587 | buf_sprintf("@atomicRmw atomic ordering must not be Unordered")); |
| 27749 | if (ordering == AtomicOrderUnordered) { | 28588 | return ira->codegen->invalid_inst_gen; |
| 27750 | ir_add_error(ira, instruction->ordering, | | |
| 27751 | buf_sprintf("@atomicRmw atomic ordering must not be Unordered")); | | |
| 27752 | return ira->codegen->invalid_instruction; | | |
| 27753 | } | | |
| 27754 | } | 28589 | } |
| 27755 | | 28590 | |
| 27756 | if (instr_is_comptime(casted_operand) && instr_is_comptime(casted_ptr) && casted_ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar) | 28591 | if (instr_is_comptime(casted_operand) && instr_is_comptime(casted_ptr) && casted_ptr->value->data.x_ptr.mut == ConstPtrMutComptimeVar) |
| 27757 | { | 28592 | { |
| 27758 | zig_panic("TODO compile-time execution of atomicRmw"); | 28593 | ir_add_error(ira, &instruction->base.base, |
| | 28594 | buf_sprintf("compiler bug: TODO compile-time execution of @atomicRmw")); |
| | 28595 | return ira->codegen->invalid_inst_gen; |
| 27759 | } | 28596 | } |
| 27760 | | 28597 | |
| 27761 | IrInstruction *result = ir_build_atomic_rmw(&ira->new_irb, instruction->base.scope, | 28598 | return ir_build_atomic_rmw_gen(ira, &instruction->base.base, casted_ptr, casted_operand, op, |
| 27762 | instruction->base.source_node, nullptr, casted_ptr, nullptr, casted_operand, nullptr, | 28599 | ordering, operand_type); |
| 27763 | op, ordering); | | |
| 27764 | result->value->type = operand_type; | | |
| 27765 | return result; | | |
| 27766 | } | 28600 | } |
| 27767 | | 28601 | |
| 27768 | static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstructionAtomicLoad *instruction) { | 28602 | static IrInstGen *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstSrcAtomicLoad *instruction) { |
| 27769 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->child); | 28603 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->child); |
| 27770 | if (type_is_invalid(operand_type)) | 28604 | if (type_is_invalid(operand_type)) |
| 27771 | return ira->codegen->invalid_instruction; | 28605 | return ira->codegen->invalid_inst_gen; |
| 27772 | | 28606 | |
| 27773 | IrInstruction *ptr_inst = instruction->ptr->child; | 28607 | IrInstGen *ptr_inst = instruction->ptr->child; |
| 27774 | if (type_is_invalid(ptr_inst->value->type)) | 28608 | if (type_is_invalid(ptr_inst->value->type)) |
| 27775 | return ira->codegen->invalid_instruction; | 28609 | return ira->codegen->invalid_inst_gen; |
| 27776 | | 28610 | |
| 27777 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, true); | 28611 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, true); |
| 27778 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | 28612 | IrInstGen *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); |
| 27779 | if (type_is_invalid(casted_ptr->value->type)) | 28613 | if (type_is_invalid(casted_ptr->value->type)) |
| 27780 | return ira->codegen->invalid_instruction; | 28614 | return ira->codegen->invalid_inst_gen; |
| 27781 | | 28615 | |
| 27782 | AtomicOrder ordering; | 28616 | AtomicOrder ordering; |
| 27783 | if (instruction->ordering == nullptr) { | 28617 | if (!ir_resolve_atomic_order(ira, instruction->ordering->child, &ordering)) |
| 27784 | ordering = instruction->resolved_ordering; | 28618 | return ira->codegen->invalid_inst_gen; |
| 27785 | } else { | | |
| 27786 | if (!ir_resolve_atomic_order(ira, instruction->ordering->child, &ordering)) | | |
| 27787 | return ira->codegen->invalid_instruction; | | |
| 27788 | } | | |
| 27789 | | 28619 | |
| 27790 | if (ordering == AtomicOrderRelease || ordering == AtomicOrderAcqRel) { | 28620 | if (ordering == AtomicOrderRelease || ordering == AtomicOrderAcqRel) { |
| 27791 | ir_assert(instruction->ordering != nullptr, &instruction->base); | 28621 | ir_assert(instruction->ordering != nullptr, &instruction->base.base); |
| 27792 | ir_add_error(ira, instruction->ordering, | 28622 | ir_add_error(ira, &instruction->ordering->base, |
| 27793 | buf_sprintf("@atomicLoad atomic ordering must not be Release or AcqRel")); | 28623 | buf_sprintf("@atomicLoad atomic ordering must not be Release or AcqRel")); |
| 27794 | return ira->codegen->invalid_instruction; | 28624 | return ira->codegen->invalid_inst_gen; |
| 27795 | } | 28625 | } |
| 27796 | | 28626 | |
| 27797 | if (instr_is_comptime(casted_ptr)) { | 28627 | if (instr_is_comptime(casted_ptr)) { |
| 27798 | IrInstruction *result = ir_get_deref(ira, &instruction->base, casted_ptr, nullptr); | 28628 | IrInstGen *result = ir_get_deref(ira, &instruction->base.base, casted_ptr, nullptr); |
| 27799 | ir_assert(result->value->type != nullptr, &instruction->base); | 28629 | ir_assert(result->value->type != nullptr, &instruction->base.base); |
| 27800 | return result; | 28630 | return result; |
| 27801 | } | 28631 | } |
| 27802 | | 28632 | |
| 27803 | IrInstruction *result = ir_build_atomic_load(&ira->new_irb, instruction->base.scope, | 28633 | return ir_build_atomic_load_gen(ira, &instruction->base.base, casted_ptr, ordering, operand_type); |
| 27804 | instruction->base.source_node, nullptr, casted_ptr, nullptr, ordering); | | |
| 27805 | result->value->type = operand_type; | | |
| 27806 | return result; | | |
| 27807 | } | 28634 | } |
| 27808 | | 28635 | |
| 27809 | static IrInstruction *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInstructionAtomicStore *instruction) { | 28636 | static IrInstGen *ir_analyze_instruction_atomic_store(IrAnalyze *ira, IrInstSrcAtomicStore *instruction) { |
| 27810 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->child); | 28637 | ZigType *operand_type = ir_resolve_atomic_operand_type(ira, instruction->operand_type->child); |
| 27811 | if (type_is_invalid(operand_type)) | 28638 | if (type_is_invalid(operand_type)) |
| 27812 | return ira->codegen->invalid_instruction; | 28639 | return ira->codegen->invalid_inst_gen; |
| 27813 | | 28640 | |
| 27814 | IrInstruction *ptr_inst = instruction->ptr->child; | 28641 | IrInstGen *ptr_inst = instruction->ptr->child; |
| 27815 | if (type_is_invalid(ptr_inst->value->type)) | 28642 | if (type_is_invalid(ptr_inst->value->type)) |
| 27816 | return ira->codegen->invalid_instruction; | 28643 | return ira->codegen->invalid_inst_gen; |
| 27817 | | 28644 | |
| 27818 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); | 28645 | ZigType *ptr_type = get_pointer_to_type(ira->codegen, operand_type, false); |
| 27819 | IrInstruction *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); | 28646 | IrInstGen *casted_ptr = ir_implicit_cast(ira, ptr_inst, ptr_type); |
| 27820 | if (type_is_invalid(casted_ptr->value->type)) | 28647 | if (type_is_invalid(casted_ptr->value->type)) |
| 27821 | return ira->codegen->invalid_instruction; | 28648 | return ira->codegen->invalid_inst_gen; |
| 27822 | | 28649 | |
| 27823 | IrInstruction *value = instruction->value->child; | 28650 | IrInstGen *value = instruction->value->child; |
| 27824 | if (type_is_invalid(value->value->type)) | 28651 | if (type_is_invalid(value->value->type)) |
| 27825 | return ira->codegen->invalid_instruction; | 28652 | return ira->codegen->invalid_inst_gen; |
| 27826 | | 28653 | |
| 27827 | IrInstruction *casted_value = ir_implicit_cast(ira, value, operand_type); | 28654 | IrInstGen *casted_value = ir_implicit_cast(ira, value, operand_type); |
| 27828 | if (type_is_invalid(casted_value->value->type)) | 28655 | if (type_is_invalid(casted_value->value->type)) |
| 27829 | return ira->codegen->invalid_instruction; | 28656 | return ira->codegen->invalid_inst_gen; |
| 27830 | | 28657 | |
| 27831 | | 28658 | |
| 27832 | AtomicOrder ordering; | 28659 | AtomicOrder ordering; |
| 27833 | if (instruction->ordering == nullptr) { | 28660 | if (!ir_resolve_atomic_order(ira, instruction->ordering->child, &ordering)) |
| 27834 | ordering = instruction->resolved_ordering; | 28661 | return ira->codegen->invalid_inst_gen; |
| 27835 | } else { | | |
| 27836 | if (!ir_resolve_atomic_order(ira, instruction->ordering->child, &ordering)) | | |
| 27837 | return ira->codegen->invalid_instruction; | | |
| 27838 | } | | |
| 27839 | | 28662 | |
| 27840 | if (ordering == AtomicOrderAcquire || ordering == AtomicOrderAcqRel) { | 28663 | if (ordering == AtomicOrderAcquire || ordering == AtomicOrderAcqRel) { |
| 27841 | ir_assert(instruction->ordering != nullptr, &instruction->base); | 28664 | ir_assert(instruction->ordering != nullptr, &instruction->base.base); |
| 27842 | ir_add_error(ira, instruction->ordering, | 28665 | ir_add_error(ira, &instruction->ordering->base, |
| 27843 | buf_sprintf("@atomicStore atomic ordering must not be Acquire or AcqRel")); | 28666 | buf_sprintf("@atomicStore atomic ordering must not be Acquire or AcqRel")); |
| 27844 | return ira->codegen->invalid_instruction; | 28667 | return ira->codegen->invalid_inst_gen; |
| 27845 | } | 28668 | } |
| 27846 | | 28669 | |
| 27847 | if (instr_is_comptime(casted_value) && instr_is_comptime(casted_ptr)) { | 28670 | if (instr_is_comptime(casted_value) && instr_is_comptime(casted_ptr)) { |
| 27848 | IrInstruction *result = ir_analyze_store_ptr(ira, &instruction->base, casted_ptr, value, false); | 28671 | IrInstGen *result = ir_analyze_store_ptr(ira, &instruction->base.base, casted_ptr, value, false); |
| 27849 | result->value->type = ira->codegen->builtin_types.entry_void; | 28672 | result->value->type = ira->codegen->builtin_types.entry_void; |
| 27850 | return result; | 28673 | return result; |
| 27851 | } | 28674 | } |
| 27852 | | 28675 | |
| 27853 | IrInstruction *result = ir_build_atomic_store(&ira->new_irb, instruction->base.scope, | 28676 | return ir_build_atomic_store_gen(ira, &instruction->base.base, casted_ptr, casted_value, ordering); |
| 27854 | instruction->base.source_node, nullptr, casted_ptr, casted_value, nullptr, ordering); | | |
| 27855 | result->value->type = ira->codegen->builtin_types.entry_void; | | |
| 27856 | return result; | | |
| 27857 | } | 28677 | } |
| 27858 | | 28678 | |
| 27859 | static IrInstruction *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira, IrInstructionSaveErrRetAddr *instruction) { | 28679 | static IrInstGen *ir_analyze_instruction_save_err_ret_addr(IrAnalyze *ira, IrInstSrcSaveErrRetAddr *instruction) { |
| 27860 | IrInstruction *result = ir_build_save_err_ret_addr(&ira->new_irb, instruction->base.scope, | 28680 | return ir_build_save_err_ret_addr_gen(ira, &instruction->base.base); |
| 27861 | instruction->base.source_node); | | |
| 27862 | result->value->type = ira->codegen->builtin_types.entry_void; | | |
| 27863 | return result; | | |
| 27864 | } | 28681 | } |
| 27865 | | 28682 | |
| 27866 | static ErrorMsg *ir_eval_float_op(IrAnalyze *ira, IrInstruction *source_instr, BuiltinFnId fop, ZigType *float_type, | 28683 | static ErrorMsg *ir_eval_float_op(IrAnalyze *ira, IrInst* source_instr, BuiltinFnId fop, ZigType *float_type, |
| 27867 | ZigValue *op, ZigValue *out_val) | 28684 | ZigValue *op, ZigValue *out_val) |
| 27868 | { | 28685 | { |
| 27869 | assert(ira && source_instr && float_type && out_val && op); | 28686 | assert(ira && source_instr && float_type && out_val && op); |
| ... | @@ -28076,30 +28893,30 @@ static ErrorMsg *ir_eval_float_op(IrAnalyze *ira, IrInstruction *source_instr, B | ... | @@ -28076,30 +28893,30 @@ static ErrorMsg *ir_eval_float_op(IrAnalyze *ira, IrInstruction *source_instr, B |
| 28076 | return nullptr; | 28893 | return nullptr; |
| 28077 | } | 28894 | } |
| 28078 | | 28895 | |
| 28079 | static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstructionFloatOp *instruction) { | 28896 | static IrInstGen *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstSrcFloatOp *instruction) { |
| 28080 | IrInstruction *operand = instruction->operand->child; | 28897 | IrInstGen *operand = instruction->operand->child; |
| 28081 | ZigType *operand_type = operand->value->type; | 28898 | ZigType *operand_type = operand->value->type; |
| 28082 | if (type_is_invalid(operand_type)) | 28899 | if (type_is_invalid(operand_type)) |
| 28083 | return ira->codegen->invalid_instruction; | 28900 | return ira->codegen->invalid_inst_gen; |
| 28084 | | 28901 | |
| 28085 | // This instruction accepts floats and vectors of floats. | 28902 | // This instruction accepts floats and vectors of floats. |
| 28086 | ZigType *scalar_type = (operand_type->id == ZigTypeIdVector) ? | 28903 | ZigType *scalar_type = (operand_type->id == ZigTypeIdVector) ? |
| 28087 | operand_type->data.vector.elem_type : operand_type; | 28904 | operand_type->data.vector.elem_type : operand_type; |
| 28088 | | 28905 | |
| 28089 | if (scalar_type->id != ZigTypeIdFloat && scalar_type->id != ZigTypeIdComptimeFloat) { | 28906 | if (scalar_type->id != ZigTypeIdFloat && scalar_type->id != ZigTypeIdComptimeFloat) { |
| 28090 | ir_add_error(ira, operand, | 28907 | ir_add_error(ira, &operand->base, |
| 28091 | buf_sprintf("expected float type, found '%s'", buf_ptr(&scalar_type->name))); | 28908 | buf_sprintf("expected float type, found '%s'", buf_ptr(&scalar_type->name))); |
| 28092 | return ira->codegen->invalid_instruction; | 28909 | return ira->codegen->invalid_inst_gen; |
| 28093 | } | 28910 | } |
| 28094 | | 28911 | |
| 28095 | if (instr_is_comptime(operand)) { | 28912 | if (instr_is_comptime(operand)) { |
| 28096 | ZigValue *operand_val = ir_resolve_const(ira, operand, UndefOk); | 28913 | ZigValue *operand_val = ir_resolve_const(ira, operand, UndefOk); |
| 28097 | if (operand_val == nullptr) | 28914 | if (operand_val == nullptr) |
| 28098 | return ira->codegen->invalid_instruction; | 28915 | return ira->codegen->invalid_inst_gen; |
| 28099 | if (operand_val->special == ConstValSpecialUndef) | 28916 | if (operand_val->special == ConstValSpecialUndef) |
| 28100 | return ir_const_undef(ira, &instruction->base, operand_type); | 28917 | return ir_const_undef(ira, &instruction->base.base, operand_type); |
| 28101 | | 28918 | |
| 28102 | IrInstruction *result = ir_const(ira, &instruction->base, operand_type); | 28919 | IrInstGen *result = ir_const(ira, &instruction->base.base, operand_type); |
| 28103 | ZigValue *out_val = result->value; | 28920 | ZigValue *out_val = result->value; |
| 28104 | | 28921 | |
| 28105 | if (operand_type->id == ZigTypeIdVector) { | 28922 | if (operand_type->id == ZigTypeIdVector) { |
| ... | @@ -28110,47 +28927,44 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct | ... | @@ -28110,47 +28927,44 @@ static IrInstruction *ir_analyze_instruction_float_op(IrAnalyze *ira, IrInstruct |
| 28110 | for (size_t i = 0; i < len; i += 1) { | 28927 | for (size_t i = 0; i < len; i += 1) { |
| 28111 | ZigValue *elem_operand = &operand_val->data.x_array.data.s_none.elements[i]; | 28928 | ZigValue *elem_operand = &operand_val->data.x_array.data.s_none.elements[i]; |
| 28112 | ZigValue *float_out_val = &out_val->data.x_array.data.s_none.elements[i]; | 28929 | ZigValue *float_out_val = &out_val->data.x_array.data.s_none.elements[i]; |
| 28113 | ir_assert(elem_operand->type == scalar_type, &instruction->base); | 28930 | ir_assert(elem_operand->type == scalar_type, &instruction->base.base); |
| 28114 | ir_assert(float_out_val->type == scalar_type, &instruction->base); | 28931 | ir_assert(float_out_val->type == scalar_type, &instruction->base.base); |
| 28115 | ErrorMsg *msg = ir_eval_float_op(ira, &instruction->base, instruction->fn_id, scalar_type, | 28932 | ErrorMsg *msg = ir_eval_float_op(ira, &instruction->base.base, instruction->fn_id, scalar_type, |
| 28116 | elem_operand, float_out_val); | 28933 | elem_operand, float_out_val); |
| 28117 | if (msg != nullptr) { | 28934 | if (msg != nullptr) { |
| 28118 | add_error_note(ira->codegen, msg, instruction->base.source_node, | 28935 | add_error_note(ira->codegen, msg, instruction->base.base.source_node, |
| 28119 | buf_sprintf("when computing vector element at index %" ZIG_PRI_usize, i)); | 28936 | buf_sprintf("when computing vector element at index %" ZIG_PRI_usize, i)); |
| 28120 | return ira->codegen->invalid_instruction; | 28937 | return ira->codegen->invalid_inst_gen; |
| 28121 | } | 28938 | } |
| 28122 | float_out_val->type = scalar_type; | 28939 | float_out_val->type = scalar_type; |
| 28123 | } | 28940 | } |
| 28124 | out_val->type = operand_type; | 28941 | out_val->type = operand_type; |
| 28125 | out_val->special = ConstValSpecialStatic; | 28942 | out_val->special = ConstValSpecialStatic; |
| 28126 | } else { | 28943 | } else { |
| 28127 | if (ir_eval_float_op(ira, &instruction->base, instruction->fn_id, scalar_type, | 28944 | if (ir_eval_float_op(ira, &instruction->base.base, instruction->fn_id, scalar_type, |
| 28128 | operand_val, out_val) != nullptr) | 28945 | operand_val, out_val) != nullptr) |
| 28129 | { | 28946 | { |
| 28130 | return ira->codegen->invalid_instruction; | 28947 | return ira->codegen->invalid_inst_gen; |
| 28131 | } | 28948 | } |
| 28132 | } | 28949 | } |
| 28133 | return result; | 28950 | return result; |
| 28134 | } | 28951 | } |
| 28135 | | 28952 | |
| 28136 | ir_assert(scalar_type->id == ZigTypeIdFloat, &instruction->base); | 28953 | ir_assert(scalar_type->id == ZigTypeIdFloat, &instruction->base.base); |
| 28137 | | 28954 | |
| 28138 | IrInstruction *result = ir_build_float_op(&ira->new_irb, instruction->base.scope, | 28955 | return ir_build_float_op_gen(ira, &instruction->base.base, operand, instruction->fn_id, operand_type); |
| 28139 | instruction->base.source_node, operand, instruction->fn_id); | | |
| 28140 | result->value->type = operand_type; | | |
| 28141 | return result; | | |
| 28142 | } | 28956 | } |
| 28143 | | 28957 | |
| 28144 | static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstructionBswap *instruction) { | 28958 | static IrInstGen *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstSrcBswap *instruction) { |
| 28145 | Error err; | 28959 | Error err; |
| 28146 | | 28960 | |
| 28147 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); | 28961 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); |
| 28148 | if (type_is_invalid(int_type)) | 28962 | if (type_is_invalid(int_type)) |
| 28149 | return ira->codegen->invalid_instruction; | 28963 | return ira->codegen->invalid_inst_gen; |
| 28150 | | 28964 | |
| 28151 | IrInstruction *uncasted_op = instruction->op->child; | 28965 | IrInstGen *uncasted_op = instruction->op->child; |
| 28152 | if (type_is_invalid(uncasted_op->value->type)) | 28966 | if (type_is_invalid(uncasted_op->value->type)) |
| 28153 | return ira->codegen->invalid_instruction; | 28967 | return ira->codegen->invalid_inst_gen; |
| 28154 | | 28968 | |
| 28155 | uint32_t vector_len; // UINT32_MAX means not a vector | 28969 | uint32_t vector_len; // UINT32_MAX means not a vector |
| 28156 | if (uncasted_op->value->type->id == ZigTypeIdArray && | 28970 | if (uncasted_op->value->type->id == ZigTypeIdArray && |
| ... | @@ -28166,28 +28980,28 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -28166,28 +28980,28 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 28166 | bool is_vector = (vector_len != UINT32_MAX); | 28980 | bool is_vector = (vector_len != UINT32_MAX); |
| 28167 | ZigType *op_type = is_vector ? get_vector_type(ira->codegen, vector_len, int_type) : int_type; | 28981 | ZigType *op_type = is_vector ? get_vector_type(ira->codegen, vector_len, int_type) : int_type; |
| 28168 | | 28982 | |
| 28169 | IrInstruction *op = ir_implicit_cast(ira, uncasted_op, op_type); | 28983 | IrInstGen *op = ir_implicit_cast(ira, uncasted_op, op_type); |
| 28170 | if (type_is_invalid(op->value->type)) | 28984 | if (type_is_invalid(op->value->type)) |
| 28171 | return ira->codegen->invalid_instruction; | 28985 | return ira->codegen->invalid_inst_gen; |
| 28172 | | 28986 | |
| 28173 | if (int_type->data.integral.bit_count == 8 || int_type->data.integral.bit_count == 0) | 28987 | if (int_type->data.integral.bit_count == 8 || int_type->data.integral.bit_count == 0) |
| 28174 | return op; | 28988 | return op; |
| 28175 | | 28989 | |
| 28176 | if (int_type->data.integral.bit_count % 8 != 0) { | 28990 | if (int_type->data.integral.bit_count % 8 != 0) { |
| 28177 | ir_add_error(ira, instruction->op, | 28991 | ir_add_error(ira, &instruction->op->base, |
| 28178 | buf_sprintf("@byteSwap integer type '%s' has %" PRIu32 " bits which is not evenly divisible by 8", | 28992 | buf_sprintf("@byteSwap integer type '%s' has %" PRIu32 " bits which is not evenly divisible by 8", |
| 28179 | buf_ptr(&int_type->name), int_type->data.integral.bit_count)); | 28993 | buf_ptr(&int_type->name), int_type->data.integral.bit_count)); |
| 28180 | return ira->codegen->invalid_instruction; | 28994 | return ira->codegen->invalid_inst_gen; |
| 28181 | } | 28995 | } |
| 28182 | | 28996 | |
| 28183 | if (instr_is_comptime(op)) { | 28997 | if (instr_is_comptime(op)) { |
| 28184 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); | 28998 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 28185 | if (val == nullptr) | 28999 | if (val == nullptr) |
| 28186 | return ira->codegen->invalid_instruction; | 29000 | return ira->codegen->invalid_inst_gen; |
| 28187 | if (val->special == ConstValSpecialUndef) | 29001 | if (val->special == ConstValSpecialUndef) |
| 28188 | return ir_const_undef(ira, &instruction->base, op_type); | 29002 | return ir_const_undef(ira, &instruction->base.base, op_type); |
| 28189 | | 29003 | |
| 28190 | IrInstruction *result = ir_const(ira, &instruction->base, op_type); | 29004 | IrInstGen *result = ir_const(ira, &instruction->base.base, op_type); |
| 28191 | size_t buf_size = int_type->data.integral.bit_count / 8; | 29005 | size_t buf_size = int_type->data.integral.bit_count / 8; |
| 28192 | uint8_t *buf = allocate_nonzero<uint8_t>(buf_size); | 29006 | uint8_t *buf = allocate_nonzero<uint8_t>(buf_size); |
| 28193 | if (is_vector) { | 29007 | if (is_vector) { |
| ... | @@ -28195,10 +29009,10 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -28195,10 +29009,10 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 28195 | result->value->data.x_array.data.s_none.elements = create_const_vals(op_type->data.vector.len); | 29009 | result->value->data.x_array.data.s_none.elements = create_const_vals(op_type->data.vector.len); |
| 28196 | for (unsigned i = 0; i < op_type->data.vector.len; i += 1) { | 29010 | for (unsigned i = 0; i < op_type->data.vector.len; i += 1) { |
| 28197 | ZigValue *op_elem_val = &val->data.x_array.data.s_none.elements[i]; | 29011 | ZigValue *op_elem_val = &val->data.x_array.data.s_none.elements[i]; |
| 28198 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, instruction->base.source_node, | 29012 | if ((err = ir_resolve_const_val(ira->codegen, ira->new_irb.exec, instruction->base.base.source_node, |
| 28199 | op_elem_val, UndefOk))) | 29013 | op_elem_val, UndefOk))) |
| 28200 | { | 29014 | { |
| 28201 | return ira->codegen->invalid_instruction; | 29015 | return ira->codegen->invalid_inst_gen; |
| 28202 | } | 29016 | } |
| 28203 | ZigValue *result_elem_val = &result->value->data.x_array.data.s_none.elements[i]; | 29017 | ZigValue *result_elem_val = &result->value->data.x_array.data.s_none.elements[i]; |
| 28204 | result_elem_val->type = int_type; | 29018 | result_elem_val->type = int_type; |
| ... | @@ -28220,23 +29034,20 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction | ... | @@ -28220,23 +29034,20 @@ static IrInstruction *ir_analyze_instruction_bswap(IrAnalyze *ira, IrInstruction |
| 28220 | return result; | 29034 | return result; |
| 28221 | } | 29035 | } |
| 28222 | | 29036 | |
| 28223 | IrInstruction *result = ir_build_bswap(&ira->new_irb, instruction->base.scope, | 29037 | return ir_build_bswap_gen(ira, &instruction->base.base, op_type, op); |
| 28224 | instruction->base.source_node, nullptr, op); | | |
| 28225 | result->value->type = op_type; | | |
| 28226 | return result; | | |
| 28227 | } | 29038 | } |
| 28228 | | 29039 | |
| 28229 | static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstructionBitReverse *instruction) { | 29040 | static IrInstGen *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstSrcBitReverse *instruction) { |
| 28230 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); | 29041 | ZigType *int_type = ir_resolve_int_type(ira, instruction->type->child); |
| 28231 | if (type_is_invalid(int_type)) | 29042 | if (type_is_invalid(int_type)) |
| 28232 | return ira->codegen->invalid_instruction; | 29043 | return ira->codegen->invalid_inst_gen; |
| 28233 | | 29044 | |
| 28234 | IrInstruction *op = ir_implicit_cast(ira, instruction->op->child, int_type); | 29045 | IrInstGen *op = ir_implicit_cast(ira, instruction->op->child, int_type); |
| 28235 | if (type_is_invalid(op->value->type)) | 29046 | if (type_is_invalid(op->value->type)) |
| 28236 | return ira->codegen->invalid_instruction; | 29047 | return ira->codegen->invalid_inst_gen; |
| 28237 | | 29048 | |
| 28238 | if (int_type->data.integral.bit_count == 0) { | 29049 | if (int_type->data.integral.bit_count == 0) { |
| 28239 | IrInstruction *result = ir_const(ira, &instruction->base, int_type); | 29050 | IrInstGen *result = ir_const(ira, &instruction->base.base, int_type); |
| 28240 | bigint_init_unsigned(&result->value->data.x_bigint, 0); | 29051 | bigint_init_unsigned(&result->value->data.x_bigint, 0); |
| 28241 | return result; | 29052 | return result; |
| 28242 | } | 29053 | } |
| ... | @@ -28244,11 +29055,11 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr | ... | @@ -28244,11 +29055,11 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr |
| 28244 | if (instr_is_comptime(op)) { | 29055 | if (instr_is_comptime(op)) { |
| 28245 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); | 29056 | ZigValue *val = ir_resolve_const(ira, op, UndefOk); |
| 28246 | if (val == nullptr) | 29057 | if (val == nullptr) |
| 28247 | return ira->codegen->invalid_instruction; | 29058 | return ira->codegen->invalid_inst_gen; |
| 28248 | if (val->special == ConstValSpecialUndef) | 29059 | if (val->special == ConstValSpecialUndef) |
| 28249 | return ir_const_undef(ira, &instruction->base, int_type); | 29060 | return ir_const_undef(ira, &instruction->base.base, int_type); |
| 28250 | | 29061 | |
| 28251 | IrInstruction *result = ir_const(ira, &instruction->base, int_type); | 29062 | IrInstGen *result = ir_const(ira, &instruction->base.base, int_type); |
| 28252 | size_t num_bits = int_type->data.integral.bit_count; | 29063 | size_t num_bits = int_type->data.integral.bit_count; |
| 28253 | size_t buf_size = (num_bits + 7) / 8; | 29064 | size_t buf_size = (num_bits + 7) / 8; |
| 28254 | uint8_t *comptime_buf = allocate_nonzero<uint8_t>(buf_size); | 29065 | uint8_t *comptime_buf = allocate_nonzero<uint8_t>(buf_size); |
| ... | @@ -28275,128 +29086,125 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr | ... | @@ -28275,128 +29086,125 @@ static IrInstruction *ir_analyze_instruction_bit_reverse(IrAnalyze *ira, IrInstr |
| 28275 | return result; | 29086 | return result; |
| 28276 | } | 29087 | } |
| 28277 | | 29088 | |
| 28278 | IrInstruction *result = ir_build_bit_reverse(&ira->new_irb, instruction->base.scope, | 29089 | return ir_build_bit_reverse_gen(ira, &instruction->base.base, int_type, op); |
| 28279 | instruction->base.source_node, nullptr, op); | | |
| 28280 | result->value->type = int_type; | | |
| 28281 | return result; | | |
| 28282 | } | 29090 | } |
| 28283 | | 29091 | |
| 28284 | | 29092 | |
| 28285 | static IrInstruction *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstructionEnumToInt *instruction) { | 29093 | static IrInstGen *ir_analyze_instruction_enum_to_int(IrAnalyze *ira, IrInstSrcEnumToInt *instruction) { |
| 28286 | IrInstruction *target = instruction->target->child; | 29094 | IrInstGen *target = instruction->target->child; |
| 28287 | if (type_is_invalid(target->value->type)) | 29095 | if (type_is_invalid(target->value->type)) |
| 28288 | return ira->codegen->invalid_instruction; | 29096 | return ira->codegen->invalid_inst_gen; |
| 28289 | | 29097 | |
| 28290 | return ir_analyze_enum_to_int(ira, &instruction->base, target); | 29098 | return ir_analyze_enum_to_int(ira, &instruction->base.base, target); |
| 28291 | } | 29099 | } |
| 28292 | | 29100 | |
| 28293 | static IrInstruction *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstructionIntToEnum *instruction) { | 29101 | static IrInstGen *ir_analyze_instruction_int_to_enum(IrAnalyze *ira, IrInstSrcIntToEnum *instruction) { |
| 28294 | Error err; | 29102 | Error err; |
| 28295 | IrInstruction *dest_type_value = instruction->dest_type->child; | 29103 | IrInstGen *dest_type_value = instruction->dest_type->child; |
| 28296 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); | 29104 | ZigType *dest_type = ir_resolve_type(ira, dest_type_value); |
| 28297 | if (type_is_invalid(dest_type)) | 29105 | if (type_is_invalid(dest_type)) |
| 28298 | return ira->codegen->invalid_instruction; | 29106 | return ira->codegen->invalid_inst_gen; |
| 28299 | | 29107 | |
| 28300 | if (dest_type->id != ZigTypeIdEnum) { | 29108 | if (dest_type->id != ZigTypeIdEnum) { |
| 28301 | ir_add_error(ira, instruction->dest_type, | 29109 | ir_add_error(ira, &instruction->dest_type->base, |
| 28302 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&dest_type->name))); | 29110 | buf_sprintf("expected enum, found type '%s'", buf_ptr(&dest_type->name))); |
| 28303 | return ira->codegen->invalid_instruction; | 29111 | return ira->codegen->invalid_inst_gen; |
| 28304 | } | 29112 | } |
| 28305 | | 29113 | |
| 28306 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) | 29114 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusZeroBitsKnown))) |
| 28307 | return ira->codegen->invalid_instruction; | 29115 | return ira->codegen->invalid_inst_gen; |
| 28308 | | 29116 | |
| 28309 | ZigType *tag_type = dest_type->data.enumeration.tag_int_type; | 29117 | ZigType *tag_type = dest_type->data.enumeration.tag_int_type; |
| 28310 | | 29118 | |
| 28311 | IrInstruction *target = instruction->target->child; | 29119 | IrInstGen *target = instruction->target->child; |
| 28312 | if (type_is_invalid(target->value->type)) | 29120 | if (type_is_invalid(target->value->type)) |
| 28313 | return ira->codegen->invalid_instruction; | 29121 | return ira->codegen->invalid_inst_gen; |
| 28314 | | 29122 | |
| 28315 | IrInstruction *casted_target = ir_implicit_cast(ira, target, tag_type); | 29123 | IrInstGen *casted_target = ir_implicit_cast(ira, target, tag_type); |
| 28316 | if (type_is_invalid(casted_target->value->type)) | 29124 | if (type_is_invalid(casted_target->value->type)) |
| 28317 | return ira->codegen->invalid_instruction; | 29125 | return ira->codegen->invalid_inst_gen; |
| 28318 | | 29126 | |
| 28319 | return ir_analyze_int_to_enum(ira, &instruction->base, casted_target, dest_type); | 29127 | return ir_analyze_int_to_enum(ira, &instruction->base.base, casted_target, dest_type); |
| 28320 | } | 29128 | } |
| 28321 | | 29129 | |
| 28322 | static IrInstruction *ir_analyze_instruction_check_runtime_scope(IrAnalyze *ira, IrInstructionCheckRuntimeScope *instruction) { | 29130 | static IrInstGen *ir_analyze_instruction_check_runtime_scope(IrAnalyze *ira, IrInstSrcCheckRuntimeScope *instruction) { |
| 28323 | IrInstruction *block_comptime_inst = instruction->scope_is_comptime->child; | 29131 | IrInstGen *block_comptime_inst = instruction->scope_is_comptime->child; |
| 28324 | bool scope_is_comptime; | 29132 | bool scope_is_comptime; |
| 28325 | if (!ir_resolve_bool(ira, block_comptime_inst, &scope_is_comptime)) | 29133 | if (!ir_resolve_bool(ira, block_comptime_inst, &scope_is_comptime)) |
| 28326 | return ira->codegen->invalid_instruction; | 29134 | return ira->codegen->invalid_inst_gen; |
| 28327 | | 29135 | |
| 28328 | IrInstruction *is_comptime_inst = instruction->is_comptime->child; | 29136 | IrInstGen *is_comptime_inst = instruction->is_comptime->child; |
| 28329 | bool is_comptime; | 29137 | bool is_comptime; |
| 28330 | if (!ir_resolve_bool(ira, is_comptime_inst, &is_comptime)) | 29138 | if (!ir_resolve_bool(ira, is_comptime_inst, &is_comptime)) |
| 28331 | return ira->codegen->invalid_instruction; | 29139 | return ira->codegen->invalid_inst_gen; |
| 28332 | | 29140 | |
| 28333 | if (!scope_is_comptime && is_comptime) { | 29141 | if (!scope_is_comptime && is_comptime) { |
| 28334 | ErrorMsg *msg = ir_add_error(ira, &instruction->base, | 29142 | ErrorMsg *msg = ir_add_error(ira, &instruction->base.base, |
| 28335 | buf_sprintf("comptime control flow inside runtime block")); | 29143 | buf_sprintf("comptime control flow inside runtime block")); |
| 28336 | add_error_note(ira->codegen, msg, block_comptime_inst->source_node, | 29144 | add_error_note(ira->codegen, msg, block_comptime_inst->base.source_node, |
| 28337 | buf_sprintf("runtime block created here")); | 29145 | buf_sprintf("runtime block created here")); |
| 28338 | return ira->codegen->invalid_instruction; | 29146 | return ira->codegen->invalid_inst_gen; |
| 28339 | } | 29147 | } |
| 28340 | | 29148 | |
| 28341 | return ir_const_void(ira, &instruction->base); | 29149 | return ir_const_void(ira, &instruction->base.base); |
| 28342 | } | 29150 | } |
| 28343 | | 29151 | |
| 28344 | static IrInstruction *ir_analyze_instruction_has_decl(IrAnalyze *ira, IrInstructionHasDecl *instruction) { | 29152 | static IrInstGen *ir_analyze_instruction_has_decl(IrAnalyze *ira, IrInstSrcHasDecl *instruction) { |
| 28345 | ZigType *container_type = ir_resolve_type(ira, instruction->container->child); | 29153 | ZigType *container_type = ir_resolve_type(ira, instruction->container->child); |
| 28346 | if (type_is_invalid(container_type)) | 29154 | if (type_is_invalid(container_type)) |
| 28347 | return ira->codegen->invalid_instruction; | 29155 | return ira->codegen->invalid_inst_gen; |
| 28348 | | 29156 | |
| 28349 | Buf *name = ir_resolve_str(ira, instruction->name->child); | 29157 | Buf *name = ir_resolve_str(ira, instruction->name->child); |
| 28350 | if (name == nullptr) | 29158 | if (name == nullptr) |
| 28351 | return ira->codegen->invalid_instruction; | 29159 | return ira->codegen->invalid_inst_gen; |
| 28352 | | 29160 | |
| 28353 | if (!is_container(container_type)) { | 29161 | if (!is_container(container_type)) { |
| 28354 | ir_add_error(ira, instruction->container, | 29162 | ir_add_error(ira, &instruction->container->base, |
| 28355 | buf_sprintf("expected struct, enum, or union; found '%s'", buf_ptr(&container_type->name))); | 29163 | buf_sprintf("expected struct, enum, or union; found '%s'", buf_ptr(&container_type->name))); |
| 28356 | return ira->codegen->invalid_instruction; | 29164 | return ira->codegen->invalid_inst_gen; |
| 28357 | } | 29165 | } |
| 28358 | | 29166 | |
| 28359 | ScopeDecls *container_scope = get_container_scope(container_type); | 29167 | ScopeDecls *container_scope = get_container_scope(container_type); |
| 28360 | Tld *tld = find_container_decl(ira->codegen, container_scope, name); | 29168 | Tld *tld = find_container_decl(ira->codegen, container_scope, name); |
| 28361 | if (tld == nullptr) | 29169 | if (tld == nullptr) |
| 28362 | return ir_const_bool(ira, &instruction->base, false); | 29170 | return ir_const_bool(ira, &instruction->base.base, false); |
| 28363 | | 29171 | |
| 28364 | if (tld->visib_mod == VisibModPrivate && tld->import != get_scope_import(instruction->base.scope)) { | 29172 | if (tld->visib_mod == VisibModPrivate && tld->import != get_scope_import(instruction->base.base.scope)) { |
| 28365 | return ir_const_bool(ira, &instruction->base, false); | 29173 | return ir_const_bool(ira, &instruction->base.base, false); |
| 28366 | } | 29174 | } |
| 28367 | | 29175 | |
| 28368 | return ir_const_bool(ira, &instruction->base, true); | 29176 | return ir_const_bool(ira, &instruction->base.base, true); |
| 28369 | } | 29177 | } |
| 28370 | | 29178 | |
| 28371 | static IrInstruction *ir_analyze_instruction_undeclared_ident(IrAnalyze *ira, IrInstructionUndeclaredIdent *instruction) { | 29179 | static IrInstGen *ir_analyze_instruction_undeclared_ident(IrAnalyze *ira, IrInstSrcUndeclaredIdent *instruction) { |
| 28372 | // put a variable of same name with invalid type in global scope | 29180 | // put a variable of same name with invalid type in global scope |
| 28373 | // so that future references to this same name will find a variable with an invalid type | 29181 | // so that future references to this same name will find a variable with an invalid type |
| 28374 | populate_invalid_variable_in_scope(ira->codegen, instruction->base.scope, instruction->base.source_node, | 29182 | populate_invalid_variable_in_scope(ira->codegen, instruction->base.base.scope, |
| 28375 | instruction->name); | 29183 | instruction->base.base.source_node, instruction->name); |
| 28376 | ir_add_error(ira, &instruction->base, | 29184 | ir_add_error(ira, &instruction->base.base, |
| 28377 | buf_sprintf("use of undeclared identifier '%s'", buf_ptr(instruction->name))); | 29185 | buf_sprintf("use of undeclared identifier '%s'", buf_ptr(instruction->name))); |
| 28378 | return ira->codegen->invalid_instruction; | 29186 | return ira->codegen->invalid_inst_gen; |
| 28379 | } | 29187 | } |
| 28380 | | 29188 | |
| 28381 | static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstructionEndExpr *instruction) { | 29189 | static IrInstGen *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstSrcEndExpr *instruction) { |
| 28382 | IrInstruction *value = instruction->value->child; | 29190 | IrInstGen *value = instruction->value->child; |
| 28383 | if (type_is_invalid(value->value->type)) | 29191 | if (type_is_invalid(value->value->type)) |
| 28384 | return ira->codegen->invalid_instruction; | 29192 | return ira->codegen->invalid_inst_gen; |
| 28385 | | 29193 | |
| 28386 | bool was_written = instruction->result_loc->written; | 29194 | bool was_written = instruction->result_loc->written; |
| 28387 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 29195 | IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base.base, instruction->result_loc, |
| 28388 | value->value->type, value, false, false, true); | 29196 | value->value->type, value, false, false, true); |
| 28389 | if (result_loc != nullptr) { | 29197 | if (result_loc != nullptr) { |
| 28390 | if (type_is_invalid(result_loc->value->type)) | 29198 | if (type_is_invalid(result_loc->value->type)) |
| 28391 | return ira->codegen->invalid_instruction; | 29199 | return ira->codegen->invalid_inst_gen; |
| 28392 | if (result_loc->value->type->id == ZigTypeIdUnreachable) | 29200 | if (result_loc->value->type->id == ZigTypeIdUnreachable) |
| 28393 | return result_loc; | 29201 | return result_loc; |
| 28394 | | 29202 | |
| 28395 | if (!was_written || instruction->result_loc->id == ResultLocIdPeer) { | 29203 | if (!was_written || instruction->result_loc->id == ResultLocIdPeer) { |
| 28396 | IrInstruction *store_ptr = ir_analyze_store_ptr(ira, &instruction->base, result_loc, value, | 29204 | IrInstGen *store_ptr = ir_analyze_store_ptr(ira, &instruction->base.base, result_loc, value, |
| 28397 | instruction->result_loc->allow_write_through_const); | 29205 | instruction->result_loc->allow_write_through_const); |
| 28398 | if (type_is_invalid(store_ptr->value->type)) { | 29206 | if (type_is_invalid(store_ptr->value->type)) { |
| 28399 | return ira->codegen->invalid_instruction; | 29207 | return ira->codegen->invalid_inst_gen; |
| 28400 | } | 29208 | } |
| 28401 | } | 29209 | } |
| 28402 | | 29210 | |
| ... | @@ -28411,33 +29219,33 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct | ... | @@ -28411,33 +29219,33 @@ static IrInstruction *ir_analyze_instruction_end_expr(IrAnalyze *ira, IrInstruct |
| 28411 | } | 29219 | } |
| 28412 | } | 29220 | } |
| 28413 | | 29221 | |
| 28414 | return ir_const_void(ira, &instruction->base); | 29222 | return ir_const_void(ira, &instruction->base.base); |
| 28415 | } | 29223 | } |
| 28416 | | 29224 | |
| 28417 | static IrInstruction *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrInstructionImplicitCast *instruction) { | 29225 | static IrInstGen *ir_analyze_instruction_implicit_cast(IrAnalyze *ira, IrInstSrcImplicitCast *instruction) { |
| 28418 | IrInstruction *operand = instruction->operand->child; | 29226 | IrInstGen *operand = instruction->operand->child; |
| 28419 | if (type_is_invalid(operand->value->type)) | 29227 | if (type_is_invalid(operand->value->type)) |
| 28420 | return operand; | 29228 | return operand; |
| 28421 | | 29229 | |
| 28422 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, | 29230 | IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base.base, |
| 28423 | &instruction->result_loc_cast->base, operand->value->type, operand, false, false, true); | 29231 | &instruction->result_loc_cast->base, operand->value->type, operand, false, false, true); |
| 28424 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) | 29232 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable)) |
| 28425 | return result_loc; | 29233 | return result_loc; |
| 28426 | | 29234 | |
| 28427 | ZigType *dest_type = ir_resolve_type(ira, instruction->result_loc_cast->base.source_instruction->child); | 29235 | ZigType *dest_type = ir_resolve_type(ira, instruction->result_loc_cast->base.source_instruction->child); |
| 28428 | if (type_is_invalid(dest_type)) | 29236 | if (type_is_invalid(dest_type)) |
| 28429 | return ira->codegen->invalid_instruction; | 29237 | return ira->codegen->invalid_inst_gen; |
| 28430 | return ir_implicit_cast2(ira, &instruction->base, operand, dest_type); | 29238 | return ir_implicit_cast2(ira, &instruction->base.base, operand, dest_type); |
| 28431 | } | 29239 | } |
| 28432 | | 29240 | |
| 28433 | static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInstructionBitCastSrc *instruction) { | 29241 | static IrInstGen *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInstSrcBitCast *instruction) { |
| 28434 | IrInstruction *operand = instruction->operand->child; | 29242 | IrInstGen *operand = instruction->operand->child; |
| 28435 | if (type_is_invalid(operand->value->type)) | 29243 | if (type_is_invalid(operand->value->type)) |
| 28436 | return operand; | 29244 | return operand; |
| 28437 | | 29245 | |
| 28438 | IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, | 29246 | IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base.base, |
| 28439 | &instruction->result_loc_bit_cast->base, operand->value->type, operand, false, false, true); | 29247 | &instruction->result_loc_bit_cast->base, operand->value->type, operand, false, false, true); |
| 28440 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) | 29248 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable)) |
| 28441 | return result_loc; | 29249 | return result_loc; |
| 28442 | | 29250 | |
| 28443 | if (instruction->result_loc_bit_cast->parent->gen_instruction != nullptr) { | 29251 | if (instruction->result_loc_bit_cast->parent->gen_instruction != nullptr) { |
| ... | @@ -28447,70 +29255,66 @@ static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInst | ... | @@ -28447,70 +29255,66 @@ static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInst |
| 28447 | return result_loc; | 29255 | return result_loc; |
| 28448 | } | 29256 | } |
| 28449 | | 29257 | |
| 28450 | static IrInstruction *ir_analyze_instruction_union_init_named_field(IrAnalyze *ira, | 29258 | static IrInstGen *ir_analyze_instruction_union_init_named_field(IrAnalyze *ira, |
| 28451 | IrInstructionUnionInitNamedField *instruction) | 29259 | IrInstSrcUnionInitNamedField *instruction) |
| 28452 | { | 29260 | { |
| 28453 | ZigType *union_type = ir_resolve_type(ira, instruction->union_type->child); | 29261 | ZigType *union_type = ir_resolve_type(ira, instruction->union_type->child); |
| 28454 | if (type_is_invalid(union_type)) | 29262 | if (type_is_invalid(union_type)) |
| 28455 | return ira->codegen->invalid_instruction; | 29263 | return ira->codegen->invalid_inst_gen; |
| 28456 | | 29264 | |
| 28457 | if (union_type->id != ZigTypeIdUnion) { | 29265 | if (union_type->id != ZigTypeIdUnion) { |
| 28458 | ir_add_error(ira, instruction->union_type, | 29266 | ir_add_error(ira, &instruction->union_type->base, |
| 28459 | buf_sprintf("non-union type '%s' passed to @unionInit", buf_ptr(&union_type->name))); | 29267 | buf_sprintf("non-union type '%s' passed to @unionInit", buf_ptr(&union_type->name))); |
| 28460 | return ira->codegen->invalid_instruction; | 29268 | return ira->codegen->invalid_inst_gen; |
| 28461 | } | 29269 | } |
| 28462 | | 29270 | |
| 28463 | Buf *field_name = ir_resolve_str(ira, instruction->field_name->child); | 29271 | Buf *field_name = ir_resolve_str(ira, instruction->field_name->child); |
| 28464 | if (field_name == nullptr) | 29272 | if (field_name == nullptr) |
| 28465 | return ira->codegen->invalid_instruction; | 29273 | return ira->codegen->invalid_inst_gen; |
| 28466 | | 29274 | |
| 28467 | IrInstruction *field_result_loc = instruction->field_result_loc->child; | 29275 | IrInstGen *field_result_loc = instruction->field_result_loc->child; |
| 28468 | if (type_is_invalid(field_result_loc->value->type)) | 29276 | if (type_is_invalid(field_result_loc->value->type)) |
| 28469 | return ira->codegen->invalid_instruction; | 29277 | return ira->codegen->invalid_inst_gen; |
| 28470 | | 29278 | |
| 28471 | IrInstruction *result_loc = instruction->result_loc->child; | 29279 | IrInstGen *result_loc = instruction->result_loc->child; |
| 28472 | if (type_is_invalid(result_loc->value->type)) | 29280 | if (type_is_invalid(result_loc->value->type)) |
| 28473 | return ira->codegen->invalid_instruction; | 29281 | return ira->codegen->invalid_inst_gen; |
| 28474 | | 29282 | |
| 28475 | return ir_analyze_union_init(ira, &instruction->base, instruction->base.source_node, | 29283 | return ir_analyze_union_init(ira, &instruction->base.base, instruction->base.base.source_node, |
| 28476 | union_type, field_name, field_result_loc, result_loc); | 29284 | union_type, field_name, field_result_loc, result_loc); |
| 28477 | } | 29285 | } |
| 28478 | | 29286 | |
| 28479 | static IrInstruction *ir_analyze_instruction_suspend_begin(IrAnalyze *ira, IrInstructionSuspendBegin *instruction) { | 29287 | static IrInstGen *ir_analyze_instruction_suspend_begin(IrAnalyze *ira, IrInstSrcSuspendBegin *instruction) { |
| 28480 | IrInstructionSuspendBegin *result = ir_build_suspend_begin(&ira->new_irb, instruction->base.scope, | 29288 | return ir_build_suspend_begin_gen(ira, &instruction->base.base); |
| 28481 | instruction->base.source_node); | | |
| 28482 | return &result->base; | | |
| 28483 | } | 29289 | } |
| 28484 | | 29290 | |
| 28485 | static IrInstruction *ir_analyze_instruction_suspend_finish(IrAnalyze *ira, | 29291 | static IrInstGen *ir_analyze_instruction_suspend_finish(IrAnalyze *ira, IrInstSrcSuspendFinish *instruction) { |
| 28486 | IrInstructionSuspendFinish *instruction) | 29292 | IrInstGen *begin_base = instruction->begin->base.child; |
| 28487 | { | | |
| 28488 | IrInstruction *begin_base = instruction->begin->base.child; | | |
| 28489 | if (type_is_invalid(begin_base->value->type)) | 29293 | if (type_is_invalid(begin_base->value->type)) |
| 28490 | return ira->codegen->invalid_instruction; | 29294 | return ira->codegen->invalid_inst_gen; |
| 28491 | ir_assert(begin_base->id == IrInstructionIdSuspendBegin, &instruction->base); | 29295 | ir_assert(begin_base->id == IrInstGenIdSuspendBegin, &instruction->base.base); |
| 28492 | IrInstructionSuspendBegin *begin = reinterpret_cast<IrInstructionSuspendBegin *>(begin_base); | 29296 | IrInstGenSuspendBegin *begin = reinterpret_cast<IrInstGenSuspendBegin *>(begin_base); |
| 28493 | | 29297 | |
| 28494 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 29298 | ZigFn *fn_entry = ira->new_irb.exec->fn_entry; |
| 28495 | ir_assert(fn_entry != nullptr, &instruction->base); | 29299 | ir_assert(fn_entry != nullptr, &instruction->base.base); |
| 28496 | | 29300 | |
| 28497 | if (fn_entry->inferred_async_node == nullptr) { | 29301 | if (fn_entry->inferred_async_node == nullptr) { |
| 28498 | fn_entry->inferred_async_node = instruction->base.source_node; | 29302 | fn_entry->inferred_async_node = instruction->base.base.source_node; |
| 28499 | } | 29303 | } |
| 28500 | | 29304 | |
| 28501 | return ir_build_suspend_finish(&ira->new_irb, instruction->base.scope, instruction->base.source_node, begin); | 29305 | return ir_build_suspend_finish_gen(ira, &instruction->base.base, begin); |
| 28502 | } | 29306 | } |
| 28503 | | 29307 | |
| 28504 | static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruction *source_instr, | 29308 | static IrInstGen *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInst* source_instr, |
| 28505 | IrInstruction *frame_ptr, ZigFn **target_fn) | 29309 | IrInstGen *frame_ptr, ZigFn **target_fn) |
| 28506 | { | 29310 | { |
| 28507 | if (type_is_invalid(frame_ptr->value->type)) | 29311 | if (type_is_invalid(frame_ptr->value->type)) |
| 28508 | return ira->codegen->invalid_instruction; | 29312 | return ira->codegen->invalid_inst_gen; |
| 28509 | | 29313 | |
| 28510 | *target_fn = nullptr; | 29314 | *target_fn = nullptr; |
| 28511 | | 29315 | |
| 28512 | ZigType *result_type; | 29316 | ZigType *result_type; |
| 28513 | IrInstruction *frame; | 29317 | IrInstGen *frame; |
| 28514 | if (frame_ptr->value->type->id == ZigTypeIdPointer && | 29318 | if (frame_ptr->value->type->id == ZigTypeIdPointer && |
| 28515 | frame_ptr->value->type->data.pointer.ptr_len == PtrLenSingle && | 29319 | frame_ptr->value->type->data.pointer.ptr_len == PtrLenSingle && |
| 28516 | frame_ptr->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) | 29320 | frame_ptr->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) |
| ... | @@ -28533,38 +29337,38 @@ static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruct | ... | @@ -28533,38 +29337,38 @@ static IrInstruction *analyze_frame_ptr_to_anyframe_T(IrAnalyze *ira, IrInstruct |
| 28533 | { | 29337 | { |
| 28534 | ir_add_error(ira, source_instr, | 29338 | ir_add_error(ira, source_instr, |
| 28535 | buf_sprintf("expected anyframe->T, found '%s'", buf_ptr(&frame->value->type->name))); | 29339 | buf_sprintf("expected anyframe->T, found '%s'", buf_ptr(&frame->value->type->name))); |
| 28536 | return ira->codegen->invalid_instruction; | 29340 | return ira->codegen->invalid_inst_gen; |
| 28537 | } else { | 29341 | } else { |
| 28538 | result_type = frame->value->type->data.any_frame.result_type; | 29342 | result_type = frame->value->type->data.any_frame.result_type; |
| 28539 | } | 29343 | } |
| 28540 | } | 29344 | } |
| 28541 | | 29345 | |
| 28542 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, result_type); | 29346 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, result_type); |
| 28543 | IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); | 29347 | IrInstGen *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); |
| 28544 | if (type_is_invalid(casted_frame->value->type)) | 29348 | if (type_is_invalid(casted_frame->value->type)) |
| 28545 | return ira->codegen->invalid_instruction; | 29349 | return ira->codegen->invalid_inst_gen; |
| 28546 | | 29350 | |
| 28547 | return casted_frame; | 29351 | return casted_frame; |
| 28548 | } | 29352 | } |
| 28549 | | 29353 | |
| 28550 | static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstructionAwaitSrc *instruction) { | 29354 | static IrInstGen *ir_analyze_instruction_await(IrAnalyze *ira, IrInstSrcAwait *instruction) { |
| 28551 | IrInstruction *operand = instruction->frame->child; | 29355 | IrInstGen *operand = instruction->frame->child; |
| 28552 | if (type_is_invalid(operand->value->type)) | 29356 | if (type_is_invalid(operand->value->type)) |
| 28553 | return ira->codegen->invalid_instruction; | 29357 | return ira->codegen->invalid_inst_gen; |
| 28554 | ZigFn *target_fn; | 29358 | ZigFn *target_fn; |
| 28555 | IrInstruction *frame = analyze_frame_ptr_to_anyframe_T(ira, &instruction->base, operand, &target_fn); | 29359 | IrInstGen *frame = analyze_frame_ptr_to_anyframe_T(ira, &instruction->base.base, operand, &target_fn); |
| 28556 | if (type_is_invalid(frame->value->type)) | 29360 | if (type_is_invalid(frame->value->type)) |
| 28557 | return ira->codegen->invalid_instruction; | 29361 | return ira->codegen->invalid_inst_gen; |
| 28558 | | 29362 | |
| 28559 | ZigType *result_type = frame->value->type->data.any_frame.result_type; | 29363 | ZigType *result_type = frame->value->type->data.any_frame.result_type; |
| 28560 | | 29364 | |
| 28561 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); | 29365 | ZigFn *fn_entry = ira->new_irb.exec->fn_entry; |
| 28562 | ir_assert(fn_entry != nullptr, &instruction->base); | 29366 | ir_assert(fn_entry != nullptr, &instruction->base.base); |
| 28563 | | 29367 | |
| 28564 | // If it's not @Frame(func) then it's definitely a suspend point | 29368 | // If it's not @Frame(func) then it's definitely a suspend point |
| 28565 | if (target_fn == nullptr) { | 29369 | if (target_fn == nullptr) { |
| 28566 | if (fn_entry->inferred_async_node == nullptr) { | 29370 | if (fn_entry->inferred_async_node == nullptr) { |
| 28567 | fn_entry->inferred_async_node = instruction->base.source_node; | 29371 | fn_entry->inferred_async_node = instruction->base.base.source_node; |
| 28568 | } | 29372 | } |
| 28569 | } | 29373 | } |
| 28570 | | 29374 | |
| ... | @@ -28572,401 +29376,364 @@ static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstruction | ... | @@ -28572,401 +29376,364 @@ static IrInstruction *ir_analyze_instruction_await(IrAnalyze *ira, IrInstruction |
| 28572 | fn_entry->calls_or_awaits_errorable_fn = true; | 29376 | fn_entry->calls_or_awaits_errorable_fn = true; |
| 28573 | } | 29377 | } |
| 28574 | | 29378 | |
| 28575 | IrInstruction *result_loc; | 29379 | IrInstGen *result_loc; |
| 28576 | if (type_has_bits(result_type)) { | 29380 | if (type_has_bits(result_type)) { |
| 28577 | result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc, | 29381 | result_loc = ir_resolve_result(ira, &instruction->base.base, instruction->result_loc, |
| 28578 | result_type, nullptr, true, true, true); | 29382 | result_type, nullptr, true, true, true); |
| 28579 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc))) | 29383 | if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable)) |
| 28580 | return result_loc; | 29384 | return result_loc; |
| 28581 | } else { | 29385 | } else { |
| 28582 | result_loc = nullptr; | 29386 | result_loc = nullptr; |
| 28583 | } | 29387 | } |
| 28584 | | 29388 | |
| 28585 | IrInstructionAwaitGen *result = ir_build_await_gen(ira, &instruction->base, frame, result_type, result_loc); | 29389 | IrInstGenAwait *result = ir_build_await_gen(ira, &instruction->base.base, frame, result_type, result_loc); |
| 28586 | result->target_fn = target_fn; | 29390 | result->target_fn = target_fn; |
| 28587 | fn_entry->await_list.append(result); | 29391 | fn_entry->await_list.append(result); |
| 28588 | return ir_finish_anal(ira, &result->base); | 29392 | return ir_finish_anal(ira, &result->base); |
| 28589 | } | 29393 | } |
| 28590 | | 29394 | |
| 28591 | static IrInstruction *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstructionResume *instruction) { | 29395 | static IrInstGen *ir_analyze_instruction_resume(IrAnalyze *ira, IrInstSrcResume *instruction) { |
| 28592 | IrInstruction *frame_ptr = instruction->frame->child; | 29396 | IrInstGen *frame_ptr = instruction->frame->child; |
| 28593 | if (type_is_invalid(frame_ptr->value->type)) | 29397 | if (type_is_invalid(frame_ptr->value->type)) |
| 28594 | return ira->codegen->invalid_instruction; | 29398 | return ira->codegen->invalid_inst_gen; |
| 28595 | | 29399 | |
| 28596 | IrInstruction *frame; | 29400 | IrInstGen *frame; |
| 28597 | if (frame_ptr->value->type->id == ZigTypeIdPointer && | 29401 | if (frame_ptr->value->type->id == ZigTypeIdPointer && |
| 28598 | frame_ptr->value->type->data.pointer.ptr_len == PtrLenSingle && | 29402 | frame_ptr->value->type->data.pointer.ptr_len == PtrLenSingle && |
| 28599 | frame_ptr->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) | 29403 | frame_ptr->value->type->data.pointer.child_type->id == ZigTypeIdFnFrame) |
| 28600 | { | 29404 | { |
| 28601 | frame = frame_ptr; | 29405 | frame = frame_ptr; |
| 28602 | } else { | 29406 | } else { |
| 28603 | frame = ir_get_deref(ira, &instruction->base, frame_ptr, nullptr); | 29407 | frame = ir_get_deref(ira, &instruction->base.base, frame_ptr, nullptr); |
| 28604 | } | 29408 | } |
| 28605 | | 29409 | |
| 28606 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, nullptr); | 29410 | ZigType *any_frame_type = get_any_frame_type(ira->codegen, nullptr); |
| 28607 | IrInstruction *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); | 29411 | IrInstGen *casted_frame = ir_implicit_cast(ira, frame, any_frame_type); |
| 28608 | if (type_is_invalid(casted_frame->value->type)) | 29412 | if (type_is_invalid(casted_frame->value->type)) |
| 28609 | return ira->codegen->invalid_instruction; | 29413 | return ira->codegen->invalid_inst_gen; |
| 28610 | | 29414 | |
| 28611 | return ir_build_resume(&ira->new_irb, instruction->base.scope, instruction->base.source_node, casted_frame); | 29415 | return ir_build_resume_gen(ira, &instruction->base.base, casted_frame); |
| 28612 | } | 29416 | } |
| 28613 | | 29417 | |
| 28614 | static IrInstruction *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstructionSpillBegin *instruction) { | 29418 | static IrInstGen *ir_analyze_instruction_spill_begin(IrAnalyze *ira, IrInstSrcSpillBegin *instruction) { |
| 28615 | if (ir_should_inline(ira->new_irb.exec, instruction->base.scope)) | 29419 | if (ir_should_inline(ira->old_irb.exec, instruction->base.base.scope)) |
| 28616 | return ir_const_void(ira, &instruction->base); | 29420 | return ir_const_void(ira, &instruction->base.base); |
| 28617 | | 29421 | |
| 28618 | IrInstruction *operand = instruction->operand->child; | 29422 | IrInstGen *operand = instruction->operand->child; |
| 28619 | if (type_is_invalid(operand->value->type)) | 29423 | if (type_is_invalid(operand->value->type)) |
| 28620 | return ira->codegen->invalid_instruction; | 29424 | return ira->codegen->invalid_inst_gen; |
| 28621 | | 29425 | |
| 28622 | if (!type_has_bits(operand->value->type)) | 29426 | if (!type_has_bits(operand->value->type)) |
| 28623 | return ir_const_void(ira, &instruction->base); | 29427 | return ir_const_void(ira, &instruction->base.base); |
| 28624 | | 29428 | |
| 28625 | ir_assert(instruction->spill_id == SpillIdRetErrCode, &instruction->base); | 29429 | ir_assert(instruction->spill_id == SpillIdRetErrCode, &instruction->base.base); |
| 28626 | ira->new_irb.exec->need_err_code_spill = true; | 29430 | ira->new_irb.exec->need_err_code_spill = true; |
| 28627 | | 29431 | |
| 28628 | IrInstructionSpillBegin *result = ir_build_spill_begin(&ira->new_irb, instruction->base.scope, | 29432 | return ir_build_spill_begin_gen(ira, &instruction->base.base, operand, instruction->spill_id); |
| 28629 | instruction->base.source_node, operand, instruction->spill_id); | | |
| 28630 | return &result->base; | | |
| 28631 | } | 29433 | } |
| 28632 | | 29434 | |
| 28633 | static IrInstruction *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstructionSpillEnd *instruction) { | 29435 | static IrInstGen *ir_analyze_instruction_spill_end(IrAnalyze *ira, IrInstSrcSpillEnd *instruction) { |
| 28634 | IrInstruction *operand = instruction->begin->operand->child; | 29436 | IrInstGen *operand = instruction->begin->operand->child; |
| 28635 | if (type_is_invalid(operand->value->type)) | 29437 | if (type_is_invalid(operand->value->type)) |
| 28636 | return ira->codegen->invalid_instruction; | 29438 | return ira->codegen->invalid_inst_gen; |
| 28637 | | 29439 | |
| 28638 | if (ir_should_inline(ira->new_irb.exec, instruction->base.scope) || !type_has_bits(operand->value->type)) | 29440 | if (ir_should_inline(ira->old_irb.exec, instruction->base.base.scope) || !type_has_bits(operand->value->type)) |
| 28639 | return operand; | 29441 | return operand; |
| 28640 | | 29442 | |
| 28641 | ir_assert(instruction->begin->base.child->id == IrInstructionIdSpillBegin, &instruction->base); | 29443 | ir_assert(instruction->begin->base.child->id == IrInstGenIdSpillBegin, &instruction->base.base); |
| 28642 | IrInstructionSpillBegin *begin = reinterpret_cast<IrInstructionSpillBegin *>(instruction->begin->base.child); | 29444 | IrInstGenSpillBegin *begin = reinterpret_cast<IrInstGenSpillBegin *>(instruction->begin->base.child); |
| 28643 | | 29445 | |
| 28644 | IrInstruction *result = ir_build_spill_end(&ira->new_irb, instruction->base.scope, | 29446 | return ir_build_spill_end_gen(ira, &instruction->base.base, begin, operand->value->type); |
| 28645 | instruction->base.source_node, begin); | | |
| 28646 | result->value->type = operand->value->type; | | |
| 28647 | return result; | | |
| 28648 | } | 29447 | } |
| 28649 | | 29448 | |
| 28650 | static IrInstruction *ir_analyze_instruction_base(IrAnalyze *ira, IrInstruction *instruction) { | 29449 | static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruction) { |
| 28651 | switch (instruction->id) { | 29450 | switch (instruction->id) { |
| 28652 | case IrInstructionIdInvalid: | 29451 | case IrInstSrcIdInvalid: |
| 28653 | case IrInstructionIdWidenOrShorten: | | |
| 28654 | case IrInstructionIdStructFieldPtr: | | |
| 28655 | case IrInstructionIdUnionFieldPtr: | | |
| 28656 | case IrInstructionIdOptionalWrap: | | |
| 28657 | case IrInstructionIdErrWrapCode: | | |
| 28658 | case IrInstructionIdErrWrapPayload: | | |
| 28659 | case IrInstructionIdCast: | | |
| 28660 | case IrInstructionIdDeclVarGen: | | |
| 28661 | case IrInstructionIdPtrCastGen: | | |
| 28662 | case IrInstructionIdCmpxchgGen: | | |
| 28663 | case IrInstructionIdArrayToVector: | | |
| 28664 | case IrInstructionIdVectorToArray: | | |
| 28665 | case IrInstructionIdPtrOfArrayToSlice: | | |
| 28666 | case IrInstructionIdAssertZero: | | |
| 28667 | case IrInstructionIdAssertNonNull: | | |
| 28668 | case IrInstructionIdResizeSlice: | | |
| 28669 | case IrInstructionIdLoadPtrGen: | | |
| 28670 | case IrInstructionIdBitCastGen: | | |
| 28671 | case IrInstructionIdCallGen: | | |
| 28672 | case IrInstructionIdReturnPtr: | | |
| 28673 | case IrInstructionIdAllocaGen: | | |
| 28674 | case IrInstructionIdSliceGen: | | |
| 28675 | case IrInstructionIdRefGen: | | |
| 28676 | case IrInstructionIdTestErrGen: | | |
| 28677 | case IrInstructionIdFrameSizeGen: | | |
| 28678 | case IrInstructionIdAwaitGen: | | |
| 28679 | case IrInstructionIdSplatGen: | | |
| 28680 | case IrInstructionIdVectorExtractElem: | | |
| 28681 | case IrInstructionIdVectorStoreElem: | | |
| 28682 | case IrInstructionIdAsmGen: | | |
| 28683 | zig_unreachable(); | 29452 | zig_unreachable(); |
| 28684 | | 29453 | |
| 28685 | case IrInstructionIdReturn: | 29454 | case IrInstSrcIdReturn: |
| 28686 | return ir_analyze_instruction_return(ira, (IrInstructionReturn *)instruction); | 29455 | return ir_analyze_instruction_return(ira, (IrInstSrcReturn *)instruction); |
| 28687 | case IrInstructionIdConst: | 29456 | case IrInstSrcIdConst: |
| 28688 | return ir_analyze_instruction_const(ira, (IrInstructionConst *)instruction); | 29457 | return ir_analyze_instruction_const(ira, (IrInstSrcConst *)instruction); |
| 28689 | case IrInstructionIdUnOp: | 29458 | case IrInstSrcIdUnOp: |
| 28690 | return ir_analyze_instruction_un_op(ira, (IrInstructionUnOp *)instruction); | 29459 | return ir_analyze_instruction_un_op(ira, (IrInstSrcUnOp *)instruction); |
| 28691 | case IrInstructionIdBinOp: | 29460 | case IrInstSrcIdBinOp: |
| 28692 | return ir_analyze_instruction_bin_op(ira, (IrInstructionBinOp *)instruction); | 29461 | return ir_analyze_instruction_bin_op(ira, (IrInstSrcBinOp *)instruction); |
| 28693 | case IrInstructionIdMergeErrSets: | 29462 | case IrInstSrcIdMergeErrSets: |
| 28694 | return ir_analyze_instruction_merge_err_sets(ira, (IrInstructionMergeErrSets *)instruction); | 29463 | return ir_analyze_instruction_merge_err_sets(ira, (IrInstSrcMergeErrSets *)instruction); |
| 28695 | case IrInstructionIdDeclVarSrc: | 29464 | case IrInstSrcIdDeclVar: |
| 28696 | return ir_analyze_instruction_decl_var(ira, (IrInstructionDeclVarSrc *)instruction); | 29465 | return ir_analyze_instruction_decl_var(ira, (IrInstSrcDeclVar *)instruction); |
| 28697 | case IrInstructionIdLoadPtr: | 29466 | case IrInstSrcIdLoadPtr: |
| 28698 | return ir_analyze_instruction_load_ptr(ira, (IrInstructionLoadPtr *)instruction); | 29467 | return ir_analyze_instruction_load_ptr(ira, (IrInstSrcLoadPtr *)instruction); |
| 28699 | case IrInstructionIdStorePtr: | 29468 | case IrInstSrcIdStorePtr: |
| 28700 | return ir_analyze_instruction_store_ptr(ira, (IrInstructionStorePtr *)instruction); | 29469 | return ir_analyze_instruction_store_ptr(ira, (IrInstSrcStorePtr *)instruction); |
| 28701 | case IrInstructionIdElemPtr: | 29470 | case IrInstSrcIdElemPtr: |
| 28702 | return ir_analyze_instruction_elem_ptr(ira, (IrInstructionElemPtr *)instruction); | 29471 | return ir_analyze_instruction_elem_ptr(ira, (IrInstSrcElemPtr *)instruction); |
| 28703 | case IrInstructionIdVarPtr: | 29472 | case IrInstSrcIdVarPtr: |
| 28704 | return ir_analyze_instruction_var_ptr(ira, (IrInstructionVarPtr *)instruction); | 29473 | return ir_analyze_instruction_var_ptr(ira, (IrInstSrcVarPtr *)instruction); |
| 28705 | case IrInstructionIdFieldPtr: | 29474 | case IrInstSrcIdFieldPtr: |
| 28706 | return ir_analyze_instruction_field_ptr(ira, (IrInstructionFieldPtr *)instruction); | 29475 | return ir_analyze_instruction_field_ptr(ira, (IrInstSrcFieldPtr *)instruction); |
| 28707 | case IrInstructionIdCallSrc: | 29476 | case IrInstSrcIdCall: |
| 28708 | return ir_analyze_instruction_call(ira, (IrInstructionCallSrc *)instruction); | 29477 | return ir_analyze_instruction_call(ira, (IrInstSrcCall *)instruction); |
| 28709 | case IrInstructionIdCallSrcArgs: | 29478 | case IrInstSrcIdCallArgs: |
| 28710 | return ir_analyze_instruction_call_args(ira, (IrInstructionCallSrcArgs *)instruction); | 29479 | return ir_analyze_instruction_call_args(ira, (IrInstSrcCallArgs *)instruction); |
| 28711 | case IrInstructionIdCallExtra: | 29480 | case IrInstSrcIdCallExtra: |
| 28712 | return ir_analyze_instruction_call_extra(ira, (IrInstructionCallExtra *)instruction); | 29481 | return ir_analyze_instruction_call_extra(ira, (IrInstSrcCallExtra *)instruction); |
| 28713 | case IrInstructionIdBr: | 29482 | case IrInstSrcIdBr: |
| 28714 | return ir_analyze_instruction_br(ira, (IrInstructionBr *)instruction); | 29483 | return ir_analyze_instruction_br(ira, (IrInstSrcBr *)instruction); |
| 28715 | case IrInstructionIdCondBr: | 29484 | case IrInstSrcIdCondBr: |
| 28716 | return ir_analyze_instruction_cond_br(ira, (IrInstructionCondBr *)instruction); | 29485 | return ir_analyze_instruction_cond_br(ira, (IrInstSrcCondBr *)instruction); |
| 28717 | case IrInstructionIdUnreachable: | 29486 | case IrInstSrcIdUnreachable: |
| 28718 | return ir_analyze_instruction_unreachable(ira, (IrInstructionUnreachable *)instruction); | 29487 | return ir_analyze_instruction_unreachable(ira, (IrInstSrcUnreachable *)instruction); |
| 28719 | case IrInstructionIdPhi: | 29488 | case IrInstSrcIdPhi: |
| 28720 | return ir_analyze_instruction_phi(ira, (IrInstructionPhi *)instruction); | 29489 | return ir_analyze_instruction_phi(ira, (IrInstSrcPhi *)instruction); |
| 28721 | case IrInstructionIdTypeOf: | 29490 | case IrInstSrcIdTypeOf: |
| 28722 | return ir_analyze_instruction_typeof(ira, (IrInstructionTypeOf *)instruction); | 29491 | return ir_analyze_instruction_typeof(ira, (IrInstSrcTypeOf *)instruction); |
| 28723 | case IrInstructionIdSetCold: | 29492 | case IrInstSrcIdSetCold: |
| 28724 | return ir_analyze_instruction_set_cold(ira, (IrInstructionSetCold *)instruction); | 29493 | return ir_analyze_instruction_set_cold(ira, (IrInstSrcSetCold *)instruction); |
| 28725 | case IrInstructionIdSetRuntimeSafety: | 29494 | case IrInstSrcIdSetRuntimeSafety: |
| 28726 | return ir_analyze_instruction_set_runtime_safety(ira, (IrInstructionSetRuntimeSafety *)instruction); | 29495 | return ir_analyze_instruction_set_runtime_safety(ira, (IrInstSrcSetRuntimeSafety *)instruction); |
| 28727 | case IrInstructionIdSetFloatMode: | 29496 | case IrInstSrcIdSetFloatMode: |
| 28728 | return ir_analyze_instruction_set_float_mode(ira, (IrInstructionSetFloatMode *)instruction); | 29497 | return ir_analyze_instruction_set_float_mode(ira, (IrInstSrcSetFloatMode *)instruction); |
| 28729 | case IrInstructionIdAnyFrameType: | 29498 | case IrInstSrcIdAnyFrameType: |
| 28730 | return ir_analyze_instruction_any_frame_type(ira, (IrInstructionAnyFrameType *)instruction); | 29499 | return ir_analyze_instruction_any_frame_type(ira, (IrInstSrcAnyFrameType *)instruction); |
| 28731 | case IrInstructionIdSliceType: | 29500 | case IrInstSrcIdSliceType: |
| 28732 | return ir_analyze_instruction_slice_type(ira, (IrInstructionSliceType *)instruction); | 29501 | return ir_analyze_instruction_slice_type(ira, (IrInstSrcSliceType *)instruction); |
| 28733 | case IrInstructionIdAsmSrc: | 29502 | case IrInstSrcIdAsm: |
| 28734 | return ir_analyze_instruction_asm(ira, (IrInstructionAsmSrc *)instruction); | 29503 | return ir_analyze_instruction_asm(ira, (IrInstSrcAsm *)instruction); |
| 28735 | case IrInstructionIdArrayType: | 29504 | case IrInstSrcIdArrayType: |
| 28736 | return ir_analyze_instruction_array_type(ira, (IrInstructionArrayType *)instruction); | 29505 | return ir_analyze_instruction_array_type(ira, (IrInstSrcArrayType *)instruction); |
| 28737 | case IrInstructionIdSizeOf: | 29506 | case IrInstSrcIdSizeOf: |
| 28738 | return ir_analyze_instruction_size_of(ira, (IrInstructionSizeOf *)instruction); | 29507 | return ir_analyze_instruction_size_of(ira, (IrInstSrcSizeOf *)instruction); |
| 28739 | case IrInstructionIdTestNonNull: | 29508 | case IrInstSrcIdTestNonNull: |
| 28740 | return ir_analyze_instruction_test_non_null(ira, (IrInstructionTestNonNull *)instruction); | 29509 | return ir_analyze_instruction_test_non_null(ira, (IrInstSrcTestNonNull *)instruction); |
| 28741 | case IrInstructionIdOptionalUnwrapPtr: | 29510 | case IrInstSrcIdOptionalUnwrapPtr: |
| 28742 | return ir_analyze_instruction_optional_unwrap_ptr(ira, (IrInstructionOptionalUnwrapPtr *)instruction); | 29511 | return ir_analyze_instruction_optional_unwrap_ptr(ira, (IrInstSrcOptionalUnwrapPtr *)instruction); |
| 28743 | case IrInstructionIdClz: | 29512 | case IrInstSrcIdClz: |
| 28744 | return ir_analyze_instruction_clz(ira, (IrInstructionClz *)instruction); | 29513 | return ir_analyze_instruction_clz(ira, (IrInstSrcClz *)instruction); |
| 28745 | case IrInstructionIdCtz: | 29514 | case IrInstSrcIdCtz: |
| 28746 | return ir_analyze_instruction_ctz(ira, (IrInstructionCtz *)instruction); | 29515 | return ir_analyze_instruction_ctz(ira, (IrInstSrcCtz *)instruction); |
| 28747 | case IrInstructionIdPopCount: | 29516 | case IrInstSrcIdPopCount: |
| 28748 | return ir_analyze_instruction_pop_count(ira, (IrInstructionPopCount *)instruction); | 29517 | return ir_analyze_instruction_pop_count(ira, (IrInstSrcPopCount *)instruction); |
| 28749 | case IrInstructionIdBswap: | 29518 | case IrInstSrcIdBswap: |
| 28750 | return ir_analyze_instruction_bswap(ira, (IrInstructionBswap *)instruction); | 29519 | return ir_analyze_instruction_bswap(ira, (IrInstSrcBswap *)instruction); |
| 28751 | case IrInstructionIdBitReverse: | 29520 | case IrInstSrcIdBitReverse: |
| 28752 | return ir_analyze_instruction_bit_reverse(ira, (IrInstructionBitReverse *)instruction); | 29521 | return ir_analyze_instruction_bit_reverse(ira, (IrInstSrcBitReverse *)instruction); |
| 28753 | case IrInstructionIdSwitchBr: | 29522 | case IrInstSrcIdSwitchBr: |
| 28754 | return ir_analyze_instruction_switch_br(ira, (IrInstructionSwitchBr *)instruction); | 29523 | return ir_analyze_instruction_switch_br(ira, (IrInstSrcSwitchBr *)instruction); |
| 28755 | case IrInstructionIdSwitchTarget: | 29524 | case IrInstSrcIdSwitchTarget: |
| 28756 | return ir_analyze_instruction_switch_target(ira, (IrInstructionSwitchTarget *)instruction); | 29525 | return ir_analyze_instruction_switch_target(ira, (IrInstSrcSwitchTarget *)instruction); |
| 28757 | case IrInstructionIdSwitchVar: | 29526 | case IrInstSrcIdSwitchVar: |
| 28758 | return ir_analyze_instruction_switch_var(ira, (IrInstructionSwitchVar *)instruction); | 29527 | return ir_analyze_instruction_switch_var(ira, (IrInstSrcSwitchVar *)instruction); |
| 28759 | case IrInstructionIdSwitchElseVar: | 29528 | case IrInstSrcIdSwitchElseVar: |
| 28760 | return ir_analyze_instruction_switch_else_var(ira, (IrInstructionSwitchElseVar *)instruction); | 29529 | return ir_analyze_instruction_switch_else_var(ira, (IrInstSrcSwitchElseVar *)instruction); |
| 28761 | case IrInstructionIdUnionTag: | 29530 | case IrInstSrcIdImport: |
| 28762 | return ir_analyze_instruction_union_tag(ira, (IrInstructionUnionTag *)instruction); | 29531 | return ir_analyze_instruction_import(ira, (IrInstSrcImport *)instruction); |
| 28763 | case IrInstructionIdImport: | 29532 | case IrInstSrcIdRef: |
| 28764 | return ir_analyze_instruction_import(ira, (IrInstructionImport *)instruction); | 29533 | return ir_analyze_instruction_ref(ira, (IrInstSrcRef *)instruction); |
| 28765 | case IrInstructionIdRef: | 29534 | case IrInstSrcIdContainerInitList: |
| 28766 | return ir_analyze_instruction_ref(ira, (IrInstructionRef *)instruction); | 29535 | return ir_analyze_instruction_container_init_list(ira, (IrInstSrcContainerInitList *)instruction); |
| 28767 | case IrInstructionIdContainerInitList: | 29536 | case IrInstSrcIdContainerInitFields: |
| 28768 | return ir_analyze_instruction_container_init_list(ira, (IrInstructionContainerInitList *)instruction); | 29537 | return ir_analyze_instruction_container_init_fields(ira, (IrInstSrcContainerInitFields *)instruction); |
| 28769 | case IrInstructionIdContainerInitFields: | 29538 | case IrInstSrcIdCompileErr: |
| 28770 | return ir_analyze_instruction_container_init_fields(ira, (IrInstructionContainerInitFields *)instruction); | 29539 | return ir_analyze_instruction_compile_err(ira, (IrInstSrcCompileErr *)instruction); |
| 28771 | case IrInstructionIdCompileErr: | 29540 | case IrInstSrcIdCompileLog: |
| 28772 | return ir_analyze_instruction_compile_err(ira, (IrInstructionCompileErr *)instruction); | 29541 | return ir_analyze_instruction_compile_log(ira, (IrInstSrcCompileLog *)instruction); |
| 28773 | case IrInstructionIdCompileLog: | 29542 | case IrInstSrcIdErrName: |
| 28774 | return ir_analyze_instruction_compile_log(ira, (IrInstructionCompileLog *)instruction); | 29543 | return ir_analyze_instruction_err_name(ira, (IrInstSrcErrName *)instruction); |
| 28775 | case IrInstructionIdErrName: | 29544 | case IrInstSrcIdTypeName: |
| 28776 | return ir_analyze_instruction_err_name(ira, (IrInstructionErrName *)instruction); | 29545 | return ir_analyze_instruction_type_name(ira, (IrInstSrcTypeName *)instruction); |
| 28777 | case IrInstructionIdTypeName: | 29546 | case IrInstSrcIdCImport: |
| 28778 | return ir_analyze_instruction_type_name(ira, (IrInstructionTypeName *)instruction); | 29547 | return ir_analyze_instruction_c_import(ira, (IrInstSrcCImport *)instruction); |
| 28779 | case IrInstructionIdCImport: | 29548 | case IrInstSrcIdCInclude: |
| 28780 | return ir_analyze_instruction_c_import(ira, (IrInstructionCImport *)instruction); | 29549 | return ir_analyze_instruction_c_include(ira, (IrInstSrcCInclude *)instruction); |
| 28781 | case IrInstructionIdCInclude: | 29550 | case IrInstSrcIdCDefine: |
| 28782 | return ir_analyze_instruction_c_include(ira, (IrInstructionCInclude *)instruction); | 29551 | return ir_analyze_instruction_c_define(ira, (IrInstSrcCDefine *)instruction); |
| 28783 | case IrInstructionIdCDefine: | 29552 | case IrInstSrcIdCUndef: |
| 28784 | return ir_analyze_instruction_c_define(ira, (IrInstructionCDefine *)instruction); | 29553 | return ir_analyze_instruction_c_undef(ira, (IrInstSrcCUndef *)instruction); |
| 28785 | case IrInstructionIdCUndef: | 29554 | case IrInstSrcIdEmbedFile: |
| 28786 | return ir_analyze_instruction_c_undef(ira, (IrInstructionCUndef *)instruction); | 29555 | return ir_analyze_instruction_embed_file(ira, (IrInstSrcEmbedFile *)instruction); |
| 28787 | case IrInstructionIdEmbedFile: | 29556 | case IrInstSrcIdCmpxchg: |
| 28788 | return ir_analyze_instruction_embed_file(ira, (IrInstructionEmbedFile *)instruction); | 29557 | return ir_analyze_instruction_cmpxchg(ira, (IrInstSrcCmpxchg *)instruction); |
| 28789 | case IrInstructionIdCmpxchgSrc: | 29558 | case IrInstSrcIdFence: |
| 28790 | return ir_analyze_instruction_cmpxchg(ira, (IrInstructionCmpxchgSrc *)instruction); | 29559 | return ir_analyze_instruction_fence(ira, (IrInstSrcFence *)instruction); |
| 28791 | case IrInstructionIdFence: | 29560 | case IrInstSrcIdTruncate: |
| 28792 | return ir_analyze_instruction_fence(ira, (IrInstructionFence *)instruction); | 29561 | return ir_analyze_instruction_truncate(ira, (IrInstSrcTruncate *)instruction); |
| 28793 | case IrInstructionIdTruncate: | 29562 | case IrInstSrcIdIntCast: |
| 28794 | return ir_analyze_instruction_truncate(ira, (IrInstructionTruncate *)instruction); | 29563 | return ir_analyze_instruction_int_cast(ira, (IrInstSrcIntCast *)instruction); |
| 28795 | case IrInstructionIdIntCast: | 29564 | case IrInstSrcIdFloatCast: |
| 28796 | return ir_analyze_instruction_int_cast(ira, (IrInstructionIntCast *)instruction); | 29565 | return ir_analyze_instruction_float_cast(ira, (IrInstSrcFloatCast *)instruction); |
| 28797 | case IrInstructionIdFloatCast: | 29566 | case IrInstSrcIdErrSetCast: |
| 28798 | return ir_analyze_instruction_float_cast(ira, (IrInstructionFloatCast *)instruction); | 29567 | return ir_analyze_instruction_err_set_cast(ira, (IrInstSrcErrSetCast *)instruction); |
| 28799 | case IrInstructionIdErrSetCast: | 29568 | case IrInstSrcIdFromBytes: |
| 28800 | return ir_analyze_instruction_err_set_cast(ira, (IrInstructionErrSetCast *)instruction); | 29569 | return ir_analyze_instruction_from_bytes(ira, (IrInstSrcFromBytes *)instruction); |
| 28801 | case IrInstructionIdFromBytes: | 29570 | case IrInstSrcIdToBytes: |
| 28802 | return ir_analyze_instruction_from_bytes(ira, (IrInstructionFromBytes *)instruction); | 29571 | return ir_analyze_instruction_to_bytes(ira, (IrInstSrcToBytes *)instruction); |
| 28803 | case IrInstructionIdToBytes: | 29572 | case IrInstSrcIdIntToFloat: |
| 28804 | return ir_analyze_instruction_to_bytes(ira, (IrInstructionToBytes *)instruction); | 29573 | return ir_analyze_instruction_int_to_float(ira, (IrInstSrcIntToFloat *)instruction); |
| 28805 | case IrInstructionIdIntToFloat: | 29574 | case IrInstSrcIdFloatToInt: |
| 28806 | return ir_analyze_instruction_int_to_float(ira, (IrInstructionIntToFloat *)instruction); | 29575 | return ir_analyze_instruction_float_to_int(ira, (IrInstSrcFloatToInt *)instruction); |
| 28807 | case IrInstructionIdFloatToInt: | 29576 | case IrInstSrcIdBoolToInt: |
| 28808 | return ir_analyze_instruction_float_to_int(ira, (IrInstructionFloatToInt *)instruction); | 29577 | return ir_analyze_instruction_bool_to_int(ira, (IrInstSrcBoolToInt *)instruction); |
| 28809 | case IrInstructionIdBoolToInt: | 29578 | case IrInstSrcIdIntType: |
| 28810 | return ir_analyze_instruction_bool_to_int(ira, (IrInstructionBoolToInt *)instruction); | 29579 | return ir_analyze_instruction_int_type(ira, (IrInstSrcIntType *)instruction); |
| 28811 | case IrInstructionIdIntType: | 29580 | case IrInstSrcIdVectorType: |
| 28812 | return ir_analyze_instruction_int_type(ira, (IrInstructionIntType *)instruction); | 29581 | return ir_analyze_instruction_vector_type(ira, (IrInstSrcVectorType *)instruction); |
| 28813 | case IrInstructionIdVectorType: | 29582 | case IrInstSrcIdShuffleVector: |
| 28814 | return ir_analyze_instruction_vector_type(ira, (IrInstructionVectorType *)instruction); | 29583 | return ir_analyze_instruction_shuffle_vector(ira, (IrInstSrcShuffleVector *)instruction); |
| 28815 | case IrInstructionIdShuffleVector: | 29584 | case IrInstSrcIdSplat: |
| 28816 | return ir_analyze_instruction_shuffle_vector(ira, (IrInstructionShuffleVector *)instruction); | 29585 | return ir_analyze_instruction_splat(ira, (IrInstSrcSplat *)instruction); |
| 28817 | case IrInstructionIdSplatSrc: | 29586 | case IrInstSrcIdBoolNot: |
| 28818 | return ir_analyze_instruction_splat(ira, (IrInstructionSplatSrc *)instruction); | 29587 | return ir_analyze_instruction_bool_not(ira, (IrInstSrcBoolNot *)instruction); |
| 28819 | case IrInstructionIdBoolNot: | 29588 | case IrInstSrcIdMemset: |
| 28820 | return ir_analyze_instruction_bool_not(ira, (IrInstructionBoolNot *)instruction); | 29589 | return ir_analyze_instruction_memset(ira, (IrInstSrcMemset *)instruction); |
| 28821 | case IrInstructionIdMemset: | 29590 | case IrInstSrcIdMemcpy: |
| 28822 | return ir_analyze_instruction_memset(ira, (IrInstructionMemset *)instruction); | 29591 | return ir_analyze_instruction_memcpy(ira, (IrInstSrcMemcpy *)instruction); |
| 28823 | case IrInstructionIdMemcpy: | 29592 | case IrInstSrcIdSlice: |
| 28824 | return ir_analyze_instruction_memcpy(ira, (IrInstructionMemcpy *)instruction); | 29593 | return ir_analyze_instruction_slice(ira, (IrInstSrcSlice *)instruction); |
| 28825 | case IrInstructionIdSliceSrc: | 29594 | case IrInstSrcIdMemberCount: |
| 28826 | return ir_analyze_instruction_slice(ira, (IrInstructionSliceSrc *)instruction); | 29595 | return ir_analyze_instruction_member_count(ira, (IrInstSrcMemberCount *)instruction); |
| 28827 | case IrInstructionIdMemberCount: | 29596 | case IrInstSrcIdMemberType: |
| 28828 | return ir_analyze_instruction_member_count(ira, (IrInstructionMemberCount *)instruction); | 29597 | return ir_analyze_instruction_member_type(ira, (IrInstSrcMemberType *)instruction); |
| 28829 | case IrInstructionIdMemberType: | 29598 | case IrInstSrcIdMemberName: |
| 28830 | return ir_analyze_instruction_member_type(ira, (IrInstructionMemberType *)instruction); | 29599 | return ir_analyze_instruction_member_name(ira, (IrInstSrcMemberName *)instruction); |
| 28831 | case IrInstructionIdMemberName: | 29600 | case IrInstSrcIdBreakpoint: |
| 28832 | return ir_analyze_instruction_member_name(ira, (IrInstructionMemberName *)instruction); | 29601 | return ir_analyze_instruction_breakpoint(ira, (IrInstSrcBreakpoint *)instruction); |
| 28833 | case IrInstructionIdBreakpoint: | 29602 | case IrInstSrcIdReturnAddress: |
| 28834 | return ir_analyze_instruction_breakpoint(ira, (IrInstructionBreakpoint *)instruction); | 29603 | return ir_analyze_instruction_return_address(ira, (IrInstSrcReturnAddress *)instruction); |
| 28835 | case IrInstructionIdReturnAddress: | 29604 | case IrInstSrcIdFrameAddress: |
| 28836 | return ir_analyze_instruction_return_address(ira, (IrInstructionReturnAddress *)instruction); | 29605 | return ir_analyze_instruction_frame_address(ira, (IrInstSrcFrameAddress *)instruction); |
| 28837 | case IrInstructionIdFrameAddress: | 29606 | case IrInstSrcIdFrameHandle: |
| 28838 | return ir_analyze_instruction_frame_address(ira, (IrInstructionFrameAddress *)instruction); | 29607 | return ir_analyze_instruction_frame_handle(ira, (IrInstSrcFrameHandle *)instruction); |
| 28839 | case IrInstructionIdFrameHandle: | 29608 | case IrInstSrcIdFrameType: |
| 28840 | return ir_analyze_instruction_frame_handle(ira, (IrInstructionFrameHandle *)instruction); | 29609 | return ir_analyze_instruction_frame_type(ira, (IrInstSrcFrameType *)instruction); |
| 28841 | case IrInstructionIdFrameType: | 29610 | case IrInstSrcIdFrameSize: |
| 28842 | return ir_analyze_instruction_frame_type(ira, (IrInstructionFrameType *)instruction); | 29611 | return ir_analyze_instruction_frame_size(ira, (IrInstSrcFrameSize *)instruction); |
| 28843 | case IrInstructionIdFrameSizeSrc: | 29612 | case IrInstSrcIdAlignOf: |
| 28844 | return ir_analyze_instruction_frame_size(ira, (IrInstructionFrameSizeSrc *)instruction); | 29613 | return ir_analyze_instruction_align_of(ira, (IrInstSrcAlignOf *)instruction); |
| 28845 | case IrInstructionIdAlignOf: | 29614 | case IrInstSrcIdOverflowOp: |
| 28846 | return ir_analyze_instruction_align_of(ira, (IrInstructionAlignOf *)instruction); | 29615 | return ir_analyze_instruction_overflow_op(ira, (IrInstSrcOverflowOp *)instruction); |
| 28847 | case IrInstructionIdOverflowOp: | 29616 | case IrInstSrcIdTestErr: |
| 28848 | return ir_analyze_instruction_overflow_op(ira, (IrInstructionOverflowOp *)instruction); | 29617 | return ir_analyze_instruction_test_err(ira, (IrInstSrcTestErr *)instruction); |
| 28849 | case IrInstructionIdTestErrSrc: | 29618 | case IrInstSrcIdUnwrapErrCode: |
| 28850 | return ir_analyze_instruction_test_err(ira, (IrInstructionTestErrSrc *)instruction); | 29619 | return ir_analyze_instruction_unwrap_err_code(ira, (IrInstSrcUnwrapErrCode *)instruction); |
| 28851 | case IrInstructionIdUnwrapErrCode: | 29620 | case IrInstSrcIdUnwrapErrPayload: |
| 28852 | return ir_analyze_instruction_unwrap_err_code(ira, (IrInstructionUnwrapErrCode *)instruction); | 29621 | return ir_analyze_instruction_unwrap_err_payload(ira, (IrInstSrcUnwrapErrPayload *)instruction); |
| 28853 | case IrInstructionIdUnwrapErrPayload: | 29622 | case IrInstSrcIdFnProto: |
| 28854 | return ir_analyze_instruction_unwrap_err_payload(ira, (IrInstructionUnwrapErrPayload *)instruction); | 29623 | return ir_analyze_instruction_fn_proto(ira, (IrInstSrcFnProto *)instruction); |
| 28855 | case IrInstructionIdFnProto: | 29624 | case IrInstSrcIdTestComptime: |
| 28856 | return ir_analyze_instruction_fn_proto(ira, (IrInstructionFnProto *)instruction); | 29625 | return ir_analyze_instruction_test_comptime(ira, (IrInstSrcTestComptime *)instruction); |
| 28857 | case IrInstructionIdTestComptime: | 29626 | case IrInstSrcIdCheckSwitchProngs: |
| 28858 | return ir_analyze_instruction_test_comptime(ira, (IrInstructionTestComptime *)instruction); | 29627 | return ir_analyze_instruction_check_switch_prongs(ira, (IrInstSrcCheckSwitchProngs *)instruction); |
| 28859 | case IrInstructionIdCheckSwitchProngs: | 29628 | case IrInstSrcIdCheckStatementIsVoid: |
| 28860 | return ir_analyze_instruction_check_switch_prongs(ira, (IrInstructionCheckSwitchProngs *)instruction); | 29629 | return ir_analyze_instruction_check_statement_is_void(ira, (IrInstSrcCheckStatementIsVoid *)instruction); |
| 28861 | case IrInstructionIdCheckStatementIsVoid: | 29630 | case IrInstSrcIdDeclRef: |
| 28862 | return ir_analyze_instruction_check_statement_is_void(ira, (IrInstructionCheckStatementIsVoid *)instruction); | 29631 | return ir_analyze_instruction_decl_ref(ira, (IrInstSrcDeclRef *)instruction); |
| 28863 | case IrInstructionIdDeclRef: | 29632 | case IrInstSrcIdPanic: |
| 28864 | return ir_analyze_instruction_decl_ref(ira, (IrInstructionDeclRef *)instruction); | 29633 | return ir_analyze_instruction_panic(ira, (IrInstSrcPanic *)instruction); |
| 28865 | case IrInstructionIdPanic: | 29634 | case IrInstSrcIdPtrCast: |
| 28866 | return ir_analyze_instruction_panic(ira, (IrInstructionPanic *)instruction); | 29635 | return ir_analyze_instruction_ptr_cast(ira, (IrInstSrcPtrCast *)instruction); |
| 28867 | case IrInstructionIdPtrCastSrc: | 29636 | case IrInstSrcIdIntToPtr: |
| 28868 | return ir_analyze_instruction_ptr_cast(ira, (IrInstructionPtrCastSrc *)instruction); | 29637 | return ir_analyze_instruction_int_to_ptr(ira, (IrInstSrcIntToPtr *)instruction); |
| 28869 | case IrInstructionIdIntToPtr: | 29638 | case IrInstSrcIdPtrToInt: |
| 28870 | return ir_analyze_instruction_int_to_ptr(ira, (IrInstructionIntToPtr *)instruction); | 29639 | return ir_analyze_instruction_ptr_to_int(ira, (IrInstSrcPtrToInt *)instruction); |
| 28871 | case IrInstructionIdPtrToInt: | 29640 | case IrInstSrcIdTagName: |
| 28872 | return ir_analyze_instruction_ptr_to_int(ira, (IrInstructionPtrToInt *)instruction); | 29641 | return ir_analyze_instruction_enum_tag_name(ira, (IrInstSrcTagName *)instruction); |
| 28873 | case IrInstructionIdTagName: | 29642 | case IrInstSrcIdFieldParentPtr: |
| 28874 | return ir_analyze_instruction_enum_tag_name(ira, (IrInstructionTagName *)instruction); | 29643 | return ir_analyze_instruction_field_parent_ptr(ira, (IrInstSrcFieldParentPtr *)instruction); |
| 28875 | case IrInstructionIdFieldParentPtr: | 29644 | case IrInstSrcIdByteOffsetOf: |
| 28876 | return ir_analyze_instruction_field_parent_ptr(ira, (IrInstructionFieldParentPtr *)instruction); | 29645 | return ir_analyze_instruction_byte_offset_of(ira, (IrInstSrcByteOffsetOf *)instruction); |
| 28877 | case IrInstructionIdByteOffsetOf: | 29646 | case IrInstSrcIdBitOffsetOf: |
| 28878 | return ir_analyze_instruction_byte_offset_of(ira, (IrInstructionByteOffsetOf *)instruction); | 29647 | return ir_analyze_instruction_bit_offset_of(ira, (IrInstSrcBitOffsetOf *)instruction); |
| 28879 | case IrInstructionIdBitOffsetOf: | 29648 | case IrInstSrcIdTypeInfo: |
| 28880 | return ir_analyze_instruction_bit_offset_of(ira, (IrInstructionBitOffsetOf *)instruction); | 29649 | return ir_analyze_instruction_type_info(ira, (IrInstSrcTypeInfo *) instruction); |
| 28881 | case IrInstructionIdTypeInfo: | 29650 | case IrInstSrcIdType: |
| 28882 | return ir_analyze_instruction_type_info(ira, (IrInstructionTypeInfo *) instruction); | 29651 | return ir_analyze_instruction_type(ira, (IrInstSrcType *)instruction); |
| 28883 | case IrInstructionIdType: | 29652 | case IrInstSrcIdHasField: |
| 28884 | return ir_analyze_instruction_type(ira, (IrInstructionType *)instruction); | 29653 | return ir_analyze_instruction_has_field(ira, (IrInstSrcHasField *) instruction); |
| 28885 | case IrInstructionIdHasField: | 29654 | case IrInstSrcIdTypeId: |
| 28886 | return ir_analyze_instruction_has_field(ira, (IrInstructionHasField *) instruction); | 29655 | return ir_analyze_instruction_type_id(ira, (IrInstSrcTypeId *)instruction); |
| 28887 | case IrInstructionIdTypeId: | 29656 | case IrInstSrcIdSetEvalBranchQuota: |
| 28888 | return ir_analyze_instruction_type_id(ira, (IrInstructionTypeId *)instruction); | 29657 | return ir_analyze_instruction_set_eval_branch_quota(ira, (IrInstSrcSetEvalBranchQuota *)instruction); |
| 28889 | case IrInstructionIdSetEvalBranchQuota: | 29658 | case IrInstSrcIdPtrType: |
| 28890 | return ir_analyze_instruction_set_eval_branch_quota(ira, (IrInstructionSetEvalBranchQuota *)instruction); | 29659 | return ir_analyze_instruction_ptr_type(ira, (IrInstSrcPtrType *)instruction); |
| 28891 | case IrInstructionIdPtrType: | 29660 | case IrInstSrcIdAlignCast: |
| 28892 | return ir_analyze_instruction_ptr_type(ira, (IrInstructionPtrType *)instruction); | 29661 | return ir_analyze_instruction_align_cast(ira, (IrInstSrcAlignCast *)instruction); |
| 28893 | case IrInstructionIdAlignCast: | 29662 | case IrInstSrcIdImplicitCast: |
| 28894 | return ir_analyze_instruction_align_cast(ira, (IrInstructionAlignCast *)instruction); | 29663 | return ir_analyze_instruction_implicit_cast(ira, (IrInstSrcImplicitCast *)instruction); |
| 28895 | case IrInstructionIdImplicitCast: | 29664 | case IrInstSrcIdResolveResult: |
| 28896 | return ir_analyze_instruction_implicit_cast(ira, (IrInstructionImplicitCast *)instruction); | 29665 | return ir_analyze_instruction_resolve_result(ira, (IrInstSrcResolveResult *)instruction); |
| 28897 | case IrInstructionIdResolveResult: | 29666 | case IrInstSrcIdResetResult: |
| 28898 | return ir_analyze_instruction_resolve_result(ira, (IrInstructionResolveResult *)instruction); | 29667 | return ir_analyze_instruction_reset_result(ira, (IrInstSrcResetResult *)instruction); |
| 28899 | case IrInstructionIdResetResult: | 29668 | case IrInstSrcIdOpaqueType: |
| 28900 | return ir_analyze_instruction_reset_result(ira, (IrInstructionResetResult *)instruction); | 29669 | return ir_analyze_instruction_opaque_type(ira, (IrInstSrcOpaqueType *)instruction); |
| 28901 | case IrInstructionIdOpaqueType: | 29670 | case IrInstSrcIdSetAlignStack: |
| 28902 | return ir_analyze_instruction_opaque_type(ira, (IrInstructionOpaqueType *)instruction); | 29671 | return ir_analyze_instruction_set_align_stack(ira, (IrInstSrcSetAlignStack *)instruction); |
| 28903 | case IrInstructionIdSetAlignStack: | 29672 | case IrInstSrcIdArgType: |
| 28904 | return ir_analyze_instruction_set_align_stack(ira, (IrInstructionSetAlignStack *)instruction); | 29673 | return ir_analyze_instruction_arg_type(ira, (IrInstSrcArgType *)instruction); |
| 28905 | case IrInstructionIdArgType: | 29674 | case IrInstSrcIdTagType: |
| 28906 | return ir_analyze_instruction_arg_type(ira, (IrInstructionArgType *)instruction); | 29675 | return ir_analyze_instruction_tag_type(ira, (IrInstSrcTagType *)instruction); |
| 28907 | case IrInstructionIdTagType: | 29676 | case IrInstSrcIdExport: |
| 28908 | return ir_analyze_instruction_tag_type(ira, (IrInstructionTagType *)instruction); | 29677 | return ir_analyze_instruction_export(ira, (IrInstSrcExport *)instruction); |
| 28909 | case IrInstructionIdExport: | 29678 | case IrInstSrcIdErrorReturnTrace: |
| 28910 | return ir_analyze_instruction_export(ira, (IrInstructionExport *)instruction); | 29679 | return ir_analyze_instruction_error_return_trace(ira, (IrInstSrcErrorReturnTrace *)instruction); |
| 28911 | case IrInstructionIdErrorReturnTrace: | 29680 | case IrInstSrcIdErrorUnion: |
| 28912 | return ir_analyze_instruction_error_return_trace(ira, (IrInstructionErrorReturnTrace *)instruction); | 29681 | return ir_analyze_instruction_error_union(ira, (IrInstSrcErrorUnion *)instruction); |
| 28913 | case IrInstructionIdErrorUnion: | 29682 | case IrInstSrcIdAtomicRmw: |
| 28914 | return ir_analyze_instruction_error_union(ira, (IrInstructionErrorUnion *)instruction); | 29683 | return ir_analyze_instruction_atomic_rmw(ira, (IrInstSrcAtomicRmw *)instruction); |
| 28915 | case IrInstructionIdAtomicRmw: | 29684 | case IrInstSrcIdAtomicLoad: |
| 28916 | return ir_analyze_instruction_atomic_rmw(ira, (IrInstructionAtomicRmw *)instruction); | 29685 | return ir_analyze_instruction_atomic_load(ira, (IrInstSrcAtomicLoad *)instruction); |
| 28917 | case IrInstructionIdAtomicLoad: | 29686 | case IrInstSrcIdAtomicStore: |
| 28918 | return ir_analyze_instruction_atomic_load(ira, (IrInstructionAtomicLoad *)instruction); | 29687 | return ir_analyze_instruction_atomic_store(ira, (IrInstSrcAtomicStore *)instruction); |
| 28919 | case IrInstructionIdAtomicStore: | 29688 | case IrInstSrcIdSaveErrRetAddr: |
| 28920 | return ir_analyze_instruction_atomic_store(ira, (IrInstructionAtomicStore *)instruction); | 29689 | return ir_analyze_instruction_save_err_ret_addr(ira, (IrInstSrcSaveErrRetAddr *)instruction); |
| 28921 | case IrInstructionIdSaveErrRetAddr: | 29690 | case IrInstSrcIdAddImplicitReturnType: |
| 28922 | return ir_analyze_instruction_save_err_ret_addr(ira, (IrInstructionSaveErrRetAddr *)instruction); | 29691 | return ir_analyze_instruction_add_implicit_return_type(ira, (IrInstSrcAddImplicitReturnType *)instruction); |
| 28923 | case IrInstructionIdAddImplicitReturnType: | 29692 | case IrInstSrcIdFloatOp: |
| 28924 | return ir_analyze_instruction_add_implicit_return_type(ira, (IrInstructionAddImplicitReturnType *)instruction); | 29693 | return ir_analyze_instruction_float_op(ira, (IrInstSrcFloatOp *)instruction); |
| 28925 | case IrInstructionIdFloatOp: | 29694 | case IrInstSrcIdMulAdd: |
| 28926 | return ir_analyze_instruction_float_op(ira, (IrInstructionFloatOp *)instruction); | 29695 | return ir_analyze_instruction_mul_add(ira, (IrInstSrcMulAdd *)instruction); |
| 28927 | case IrInstructionIdMulAdd: | 29696 | case IrInstSrcIdIntToErr: |
| 28928 | return ir_analyze_instruction_mul_add(ira, (IrInstructionMulAdd *)instruction); | 29697 | return ir_analyze_instruction_int_to_err(ira, (IrInstSrcIntToErr *)instruction); |
| 28929 | case IrInstructionIdIntToErr: | 29698 | case IrInstSrcIdErrToInt: |
| 28930 | return ir_analyze_instruction_int_to_err(ira, (IrInstructionIntToErr *)instruction); | 29699 | return ir_analyze_instruction_err_to_int(ira, (IrInstSrcErrToInt *)instruction); |
| 28931 | case IrInstructionIdErrToInt: | 29700 | case IrInstSrcIdIntToEnum: |
| 28932 | return ir_analyze_instruction_err_to_int(ira, (IrInstructionErrToInt *)instruction); | 29701 | return ir_analyze_instruction_int_to_enum(ira, (IrInstSrcIntToEnum *)instruction); |
| 28933 | case IrInstructionIdIntToEnum: | 29702 | case IrInstSrcIdEnumToInt: |
| 28934 | return ir_analyze_instruction_int_to_enum(ira, (IrInstructionIntToEnum *)instruction); | 29703 | return ir_analyze_instruction_enum_to_int(ira, (IrInstSrcEnumToInt *)instruction); |
| 28935 | case IrInstructionIdEnumToInt: | 29704 | case IrInstSrcIdCheckRuntimeScope: |
| 28936 | return ir_analyze_instruction_enum_to_int(ira, (IrInstructionEnumToInt *)instruction); | 29705 | return ir_analyze_instruction_check_runtime_scope(ira, (IrInstSrcCheckRuntimeScope *)instruction); |
| 28937 | case IrInstructionIdCheckRuntimeScope: | 29706 | case IrInstSrcIdHasDecl: |
| 28938 | return ir_analyze_instruction_check_runtime_scope(ira, (IrInstructionCheckRuntimeScope *)instruction); | 29707 | return ir_analyze_instruction_has_decl(ira, (IrInstSrcHasDecl *)instruction); |
| 28939 | case IrInstructionIdHasDecl: | 29708 | case IrInstSrcIdUndeclaredIdent: |
| 28940 | return ir_analyze_instruction_has_decl(ira, (IrInstructionHasDecl *)instruction); | 29709 | return ir_analyze_instruction_undeclared_ident(ira, (IrInstSrcUndeclaredIdent *)instruction); |
| 28941 | case IrInstructionIdUndeclaredIdent: | 29710 | case IrInstSrcIdAlloca: |
| 28942 | return ir_analyze_instruction_undeclared_ident(ira, (IrInstructionUndeclaredIdent *)instruction); | | |
| 28943 | case IrInstructionIdAllocaSrc: | | |
| 28944 | return nullptr; | 29711 | return nullptr; |
| 28945 | case IrInstructionIdEndExpr: | 29712 | case IrInstSrcIdEndExpr: |
| 28946 | return ir_analyze_instruction_end_expr(ira, (IrInstructionEndExpr *)instruction); | 29713 | return ir_analyze_instruction_end_expr(ira, (IrInstSrcEndExpr *)instruction); |
| 28947 | case IrInstructionIdBitCastSrc: | 29714 | case IrInstSrcIdBitCast: |
| 28948 | return ir_analyze_instruction_bit_cast_src(ira, (IrInstructionBitCastSrc *)instruction); | 29715 | return ir_analyze_instruction_bit_cast_src(ira, (IrInstSrcBitCast *)instruction); |
| 28949 | case IrInstructionIdUnionInitNamedField: | 29716 | case IrInstSrcIdUnionInitNamedField: |
| 28950 | return ir_analyze_instruction_union_init_named_field(ira, (IrInstructionUnionInitNamedField *)instruction); | 29717 | return ir_analyze_instruction_union_init_named_field(ira, (IrInstSrcUnionInitNamedField *)instruction); |
| 28951 | case IrInstructionIdSuspendBegin: | 29718 | case IrInstSrcIdSuspendBegin: |
| 28952 | return ir_analyze_instruction_suspend_begin(ira, (IrInstructionSuspendBegin *)instruction); | 29719 | return ir_analyze_instruction_suspend_begin(ira, (IrInstSrcSuspendBegin *)instruction); |
| 28953 | case IrInstructionIdSuspendFinish: | 29720 | case IrInstSrcIdSuspendFinish: |
| 28954 | return ir_analyze_instruction_suspend_finish(ira, (IrInstructionSuspendFinish *)instruction); | 29721 | return ir_analyze_instruction_suspend_finish(ira, (IrInstSrcSuspendFinish *)instruction); |
| 28955 | case IrInstructionIdResume: | 29722 | case IrInstSrcIdResume: |
| 28956 | return ir_analyze_instruction_resume(ira, (IrInstructionResume *)instruction); | 29723 | return ir_analyze_instruction_resume(ira, (IrInstSrcResume *)instruction); |
| 28957 | case IrInstructionIdAwaitSrc: | 29724 | case IrInstSrcIdAwait: |
| 28958 | return ir_analyze_instruction_await(ira, (IrInstructionAwaitSrc *)instruction); | 29725 | return ir_analyze_instruction_await(ira, (IrInstSrcAwait *)instruction); |
| 28959 | case IrInstructionIdSpillBegin: | 29726 | case IrInstSrcIdSpillBegin: |
| 28960 | return ir_analyze_instruction_spill_begin(ira, (IrInstructionSpillBegin *)instruction); | 29727 | return ir_analyze_instruction_spill_begin(ira, (IrInstSrcSpillBegin *)instruction); |
| 28961 | case IrInstructionIdSpillEnd: | 29728 | case IrInstSrcIdSpillEnd: |
| 28962 | return ir_analyze_instruction_spill_end(ira, (IrInstructionSpillEnd *)instruction); | 29729 | return ir_analyze_instruction_spill_end(ira, (IrInstSrcSpillEnd *)instruction); |
| 28963 | } | 29730 | } |
| 28964 | zig_unreachable(); | 29731 | zig_unreachable(); |
| 28965 | } | 29732 | } |
| 28966 | | 29733 | |
| 28967 | // This function attempts to evaluate IR code while doing type checking and other analysis. | 29734 | // This function attempts to evaluate IR code while doing type checking and other analysis. |
| 28968 | // It emits a new IrExecutable which is partially evaluated IR code. | 29735 | // It emits to a new IrExecutableGen which is partially evaluated IR code. |
| 28969 | ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_exec, | 29736 | ZigType *ir_analyze(CodeGen *codegen, IrExecutableSrc *old_exec, IrExecutableGen *new_exec, |
| 28970 | ZigType *expected_type, AstNode *expected_type_source_node) | 29737 | ZigType *expected_type, AstNode *expected_type_source_node) |
| 28971 | { | 29738 | { |
| 28972 | assert(old_exec->first_err_trace_msg == nullptr); | 29739 | assert(old_exec->first_err_trace_msg == nullptr); |
| ... | @@ -28992,18 +29759,18 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -28992,18 +29759,18 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 28992 | ira->exec_context.mem_slot_list.items[i] = &vals[i]; | 29759 | ira->exec_context.mem_slot_list.items[i] = &vals[i]; |
| 28993 | } | 29760 | } |
| 28994 | | 29761 | |
| 28995 | IrBasicBlock *old_entry_bb = ira->old_irb.exec->basic_block_list.at(0); | 29762 | IrBasicBlockSrc *old_entry_bb = ira->old_irb.exec->basic_block_list.at(0); |
| 28996 | IrBasicBlock *new_entry_bb = ir_get_new_bb(ira, old_entry_bb, nullptr); | 29763 | IrBasicBlockGen *new_entry_bb = ir_get_new_bb(ira, old_entry_bb, nullptr); |
| 28997 | ir_ref_bb(new_entry_bb); | 29764 | ir_ref_bb_gen(new_entry_bb); |
| 28998 | ira->new_irb.current_basic_block = new_entry_bb; | 29765 | ira->new_irb.current_basic_block = new_entry_bb; |
| 28999 | ira->old_bb_index = 0; | 29766 | ira->old_bb_index = 0; |
| 29000 | | 29767 | |
| 29001 | ir_start_bb(ira, old_entry_bb, nullptr); | 29768 | ir_start_bb(ira, old_entry_bb, nullptr); |
| 29002 | | 29769 | |
| 29003 | while (ira->old_bb_index < ira->old_irb.exec->basic_block_list.length) { | 29770 | while (ira->old_bb_index < ira->old_irb.exec->basic_block_list.length) { |
| 29004 | IrInstruction *old_instruction = ira->old_irb.current_basic_block->instruction_list.at(ira->instruction_index); | 29771 | IrInstSrc *old_instruction = ira->old_irb.current_basic_block->instruction_list.at(ira->instruction_index); |
| 29005 | | 29772 | |
| 29006 | if (old_instruction->ref_count == 0 && !ir_has_side_effects(old_instruction)) { | 29773 | if (old_instruction->base.ref_count == 0 && !ir_inst_src_has_side_effects(old_instruction)) { |
| 29007 | ira->instruction_index += 1; | 29774 | ira->instruction_index += 1; |
| 29008 | continue; | 29775 | continue; |
| 29009 | } | 29776 | } |
| ... | @@ -29012,14 +29779,14 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -29012,14 +29779,14 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 29012 | fprintf(stderr, "~ "); | 29779 | fprintf(stderr, "~ "); |
| 29013 | old_instruction->src(); | 29780 | old_instruction->src(); |
| 29014 | fprintf(stderr, "~ "); | 29781 | fprintf(stderr, "~ "); |
| 29015 | ir_print_instruction(codegen, stderr, old_instruction, 0, IrPassSrc); | 29782 | ir_print_inst_src(codegen, stderr, old_instruction, 0); |
| 29016 | bool want_break = false; | 29783 | bool want_break = false; |
| 29017 | if (ira->break_debug_id == old_instruction->debug_id) { | 29784 | if (ira->break_debug_id == old_instruction->base.debug_id) { |
| 29018 | want_break = true; | 29785 | want_break = true; |
| 29019 | } else if (old_instruction->source_node != nullptr) { | 29786 | } else if (old_instruction->base.source_node != nullptr) { |
| 29020 | for (size_t i = 0; i < dbg_ir_breakpoints_count; i += 1) { | 29787 | for (size_t i = 0; i < dbg_ir_breakpoints_count; i += 1) { |
| 29021 | if (dbg_ir_breakpoints_buf[i].line == old_instruction->source_node->line + 1 && | 29788 | if (dbg_ir_breakpoints_buf[i].line == old_instruction->base.source_node->line + 1 && |
| 29022 | buf_ends_with_str(old_instruction->source_node->owner->data.structure.root_struct->path, | 29789 | buf_ends_with_str(old_instruction->base.source_node->owner->data.structure.root_struct->path, |
| 29023 | dbg_ir_breakpoints_buf[i].src_file)) | 29790 | dbg_ir_breakpoints_buf[i].src_file)) |
| 29024 | { | 29791 | { |
| 29025 | want_break = true; | 29792 | want_break = true; |
| ... | @@ -29028,9 +29795,9 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -29028,9 +29795,9 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 29028 | } | 29795 | } |
| 29029 | if (want_break) BREAKPOINT; | 29796 | if (want_break) BREAKPOINT; |
| 29030 | } | 29797 | } |
| 29031 | IrInstruction *new_instruction = ir_analyze_instruction_base(ira, old_instruction); | 29798 | IrInstGen *new_instruction = ir_analyze_instruction_base(ira, old_instruction); |
| 29032 | if (new_instruction != nullptr) { | 29799 | if (new_instruction != nullptr) { |
| 29033 | ir_assert(new_instruction->value->type != nullptr || new_instruction->value->type != nullptr, old_instruction); | 29800 | ir_assert(new_instruction->value->type != nullptr || new_instruction->value->type != nullptr, &old_instruction->base); |
| 29034 | old_instruction->child = new_instruction; | 29801 | old_instruction->child = new_instruction; |
| 29035 | | 29802 | |
| 29036 | if (type_is_invalid(new_instruction->value->type)) { | 29803 | if (type_is_invalid(new_instruction->value->type)) { |
| ... | @@ -29044,19 +29811,19 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -29044,19 +29811,19 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 29044 | new_exec->first_err_trace_msg = ira->codegen->trace_err; | 29811 | new_exec->first_err_trace_msg = ira->codegen->trace_err; |
| 29045 | } | 29812 | } |
| 29046 | if (new_exec->first_err_trace_msg != nullptr && | 29813 | if (new_exec->first_err_trace_msg != nullptr && |
| 29047 | !old_instruction->source_node->already_traced_this_node) | 29814 | !old_instruction->base.source_node->already_traced_this_node) |
| 29048 | { | 29815 | { |
| 29049 | old_instruction->source_node->already_traced_this_node = true; | 29816 | old_instruction->base.source_node->already_traced_this_node = true; |
| 29050 | new_exec->first_err_trace_msg = add_error_note(ira->codegen, new_exec->first_err_trace_msg, | 29817 | new_exec->first_err_trace_msg = add_error_note(ira->codegen, new_exec->first_err_trace_msg, |
| 29051 | old_instruction->source_node, buf_create_from_str("referenced here")); | 29818 | old_instruction->base.source_node, buf_create_from_str("referenced here")); |
| 29052 | } | 29819 | } |
| 29053 | return ira->codegen->builtin_types.entry_invalid; | 29820 | return ira->codegen->builtin_types.entry_invalid; |
| 29054 | } else if (ira->codegen->verbose_ir) { | 29821 | } else if (ira->codegen->verbose_ir) { |
| 29055 | fprintf(stderr, "-> "); | 29822 | fprintf(stderr, "-> "); |
| 29056 | if (instr_is_unreachable(new_instruction)) { | 29823 | if (new_instruction->value->type->id == ZigTypeIdUnreachable) { |
| 29057 | fprintf(stderr, "(noreturn)\n"); | 29824 | fprintf(stderr, "(noreturn)\n"); |
| 29058 | } else { | 29825 | } else { |
| 29059 | ir_print_instruction(codegen, stderr, new_instruction, 0, IrPassGen); | 29826 | ir_print_inst_gen(codegen, stderr, new_instruction, 0); |
| 29060 | } | 29827 | } |
| 29061 | } | 29828 | } |
| 29062 | | 29829 | |
| ... | @@ -29096,204 +29863,279 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ | ... | @@ -29096,204 +29863,279 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ |
| 29096 | return res_type; | 29863 | return res_type; |
| 29097 | } | 29864 | } |
| 29098 | | 29865 | |
| 29099 | bool ir_has_side_effects(IrInstruction *instruction) { | 29866 | bool ir_inst_gen_has_side_effects(IrInstGen *instruction) { |
| 29100 | switch (instruction->id) { | 29867 | switch (instruction->id) { |
| 29101 | case IrInstructionIdInvalid: | 29868 | case IrInstGenIdInvalid: |
| 29102 | zig_unreachable(); | 29869 | zig_unreachable(); |
| 29103 | case IrInstructionIdBr: | 29870 | case IrInstGenIdBr: |
| 29104 | case IrInstructionIdCondBr: | 29871 | case IrInstGenIdCondBr: |
| 29105 | case IrInstructionIdSwitchBr: | 29872 | case IrInstGenIdSwitchBr: |
| 29106 | case IrInstructionIdDeclVarSrc: | 29873 | case IrInstGenIdDeclVar: |
| 29107 | case IrInstructionIdDeclVarGen: | 29874 | case IrInstGenIdStorePtr: |
| 29108 | case IrInstructionIdStorePtr: | 29875 | case IrInstGenIdVectorStoreElem: |
| 29109 | case IrInstructionIdVectorStoreElem: | 29876 | case IrInstGenIdCall: |
| 29110 | case IrInstructionIdCallExtra: | 29877 | case IrInstGenIdReturn: |
| 29111 | case IrInstructionIdCallSrc: | 29878 | case IrInstGenIdUnreachable: |
| 29112 | case IrInstructionIdCallSrcArgs: | 29879 | case IrInstGenIdFence: |
| 29113 | case IrInstructionIdCallGen: | 29880 | case IrInstGenIdMemset: |
| 29114 | case IrInstructionIdReturn: | 29881 | case IrInstGenIdMemcpy: |
| 29115 | case IrInstructionIdUnreachable: | 29882 | case IrInstGenIdBreakpoint: |
| 29116 | case IrInstructionIdSetCold: | 29883 | case IrInstGenIdOverflowOp: // TODO when we support multiple returns this can be side effect free |
| 29117 | case IrInstructionIdSetRuntimeSafety: | 29884 | case IrInstGenIdPanic: |
| 29118 | case IrInstructionIdSetFloatMode: | 29885 | case IrInstGenIdSaveErrRetAddr: |
| 29119 | case IrInstructionIdImport: | 29886 | case IrInstGenIdAtomicRmw: |
| 29120 | case IrInstructionIdCompileErr: | 29887 | case IrInstGenIdAtomicStore: |
| 29121 | case IrInstructionIdCompileLog: | 29888 | case IrInstGenIdCmpxchg: |
| 29122 | case IrInstructionIdCImport: | 29889 | case IrInstGenIdAssertZero: |
| 29123 | case IrInstructionIdCInclude: | 29890 | case IrInstGenIdAssertNonNull: |
| 29124 | case IrInstructionIdCDefine: | 29891 | case IrInstGenIdResizeSlice: |
| 29125 | case IrInstructionIdCUndef: | 29892 | case IrInstGenIdPtrOfArrayToSlice: |
| 29126 | case IrInstructionIdFence: | 29893 | case IrInstGenIdSlice: |
| 29127 | case IrInstructionIdMemset: | 29894 | case IrInstGenIdOptionalWrap: |
| 29128 | case IrInstructionIdMemcpy: | 29895 | case IrInstGenIdVectorToArray: |
| 29129 | case IrInstructionIdBreakpoint: | 29896 | case IrInstGenIdSuspendBegin: |
| 29130 | case IrInstructionIdOverflowOp: // TODO when we support multiple returns this can be side effect free | 29897 | case IrInstGenIdSuspendFinish: |
| 29131 | case IrInstructionIdCheckSwitchProngs: | 29898 | case IrInstGenIdResume: |
| 29132 | case IrInstructionIdCheckStatementIsVoid: | 29899 | case IrInstGenIdAwait: |
| 29133 | case IrInstructionIdCheckRuntimeScope: | 29900 | case IrInstGenIdSpillBegin: |
| 29134 | case IrInstructionIdPanic: | | |
| 29135 | case IrInstructionIdSetEvalBranchQuota: | | |
| 29136 | case IrInstructionIdPtrType: | | |
| 29137 | case IrInstructionIdSetAlignStack: | | |
| 29138 | case IrInstructionIdExport: | | |
| 29139 | case IrInstructionIdSaveErrRetAddr: | | |
| 29140 | case IrInstructionIdAddImplicitReturnType: | | |
| 29141 | case IrInstructionIdAtomicRmw: | | |
| 29142 | case IrInstructionIdAtomicStore: | | |
| 29143 | case IrInstructionIdCmpxchgGen: | | |
| 29144 | case IrInstructionIdCmpxchgSrc: | | |
| 29145 | case IrInstructionIdAssertZero: | | |
| 29146 | case IrInstructionIdAssertNonNull: | | |
| 29147 | case IrInstructionIdResizeSlice: | | |
| 29148 | case IrInstructionIdUndeclaredIdent: | | |
| 29149 | case IrInstructionIdEndExpr: | | |
| 29150 | case IrInstructionIdPtrOfArrayToSlice: | | |
| 29151 | case IrInstructionIdSliceGen: | | |
| 29152 | case IrInstructionIdOptionalWrap: | | |
| 29153 | case IrInstructionIdVectorToArray: | | |
| 29154 | case IrInstructionIdResetResult: | | |
| 29155 | case IrInstructionIdSuspendBegin: | | |
| 29156 | case IrInstructionIdSuspendFinish: | | |
| 29157 | case IrInstructionIdResume: | | |
| 29158 | case IrInstructionIdAwaitSrc: | | |
| 29159 | case IrInstructionIdAwaitGen: | | |
| 29160 | case IrInstructionIdSpillBegin: | | |
| 29161 | return true; | 29901 | return true; |
| 29162 | | 29902 | |
| 29163 | case IrInstructionIdPhi: | 29903 | case IrInstGenIdPhi: |
| 29164 | case IrInstructionIdUnOp: | 29904 | case IrInstGenIdBinOp: |
| 29165 | case IrInstructionIdBinOp: | 29905 | case IrInstGenIdConst: |
| 29166 | case IrInstructionIdMergeErrSets: | 29906 | case IrInstGenIdCast: |
| 29167 | case IrInstructionIdLoadPtr: | 29907 | case IrInstGenIdElemPtr: |
| 29168 | case IrInstructionIdConst: | 29908 | case IrInstGenIdVarPtr: |
| 29169 | case IrInstructionIdCast: | 29909 | case IrInstGenIdReturnPtr: |
| 29170 | case IrInstructionIdContainerInitList: | 29910 | case IrInstGenIdStructFieldPtr: |
| 29171 | case IrInstructionIdContainerInitFields: | 29911 | case IrInstGenIdTestNonNull: |
| 29172 | case IrInstructionIdUnionInitNamedField: | 29912 | case IrInstGenIdOptionalUnwrapPtr: |
| 29173 | case IrInstructionIdFieldPtr: | 29913 | case IrInstGenIdClz: |
| 29174 | case IrInstructionIdElemPtr: | 29914 | case IrInstGenIdCtz: |
| 29175 | case IrInstructionIdVarPtr: | 29915 | case IrInstGenIdPopCount: |
| 29176 | case IrInstructionIdReturnPtr: | 29916 | case IrInstGenIdBswap: |
| 29177 | case IrInstructionIdTypeOf: | 29917 | case IrInstGenIdBitReverse: |
| 29178 | case IrInstructionIdStructFieldPtr: | 29918 | case IrInstGenIdUnionTag: |
| 29179 | case IrInstructionIdArrayType: | 29919 | case IrInstGenIdTruncate: |
| 29180 | case IrInstructionIdSliceType: | 29920 | case IrInstGenIdShuffleVector: |
| 29181 | case IrInstructionIdAnyFrameType: | 29921 | case IrInstGenIdSplat: |
| 29182 | case IrInstructionIdSizeOf: | 29922 | case IrInstGenIdBoolNot: |
| 29183 | case IrInstructionIdTestNonNull: | 29923 | case IrInstGenIdReturnAddress: |
| 29184 | case IrInstructionIdOptionalUnwrapPtr: | 29924 | case IrInstGenIdFrameAddress: |
| 29185 | case IrInstructionIdClz: | 29925 | case IrInstGenIdFrameHandle: |
| 29186 | case IrInstructionIdCtz: | 29926 | case IrInstGenIdFrameSize: |
| 29187 | case IrInstructionIdPopCount: | 29927 | case IrInstGenIdTestErr: |
| 29188 | case IrInstructionIdBswap: | 29928 | case IrInstGenIdPtrCast: |
| 29189 | case IrInstructionIdBitReverse: | 29929 | case IrInstGenIdBitCast: |
| 29190 | case IrInstructionIdSwitchVar: | 29930 | case IrInstGenIdWidenOrShorten: |
| 29191 | case IrInstructionIdSwitchElseVar: | 29931 | case IrInstGenIdPtrToInt: |
| 29192 | case IrInstructionIdSwitchTarget: | 29932 | case IrInstGenIdIntToPtr: |
| 29193 | case IrInstructionIdUnionTag: | 29933 | case IrInstGenIdIntToEnum: |
| 29194 | case IrInstructionIdRef: | 29934 | case IrInstGenIdIntToErr: |
| 29195 | case IrInstructionIdEmbedFile: | 29935 | case IrInstGenIdErrToInt: |
| 29196 | case IrInstructionIdTruncate: | 29936 | case IrInstGenIdErrName: |
| 29197 | case IrInstructionIdIntType: | 29937 | case IrInstGenIdTagName: |
| 29198 | case IrInstructionIdVectorType: | 29938 | case IrInstGenIdFieldParentPtr: |
| 29199 | case IrInstructionIdShuffleVector: | 29939 | case IrInstGenIdAlignCast: |
| 29200 | case IrInstructionIdSplatSrc: | 29940 | case IrInstGenIdErrorReturnTrace: |
| 29201 | case IrInstructionIdSplatGen: | 29941 | case IrInstGenIdFloatOp: |
| 29202 | case IrInstructionIdBoolNot: | 29942 | case IrInstGenIdMulAdd: |
| 29203 | case IrInstructionIdSliceSrc: | 29943 | case IrInstGenIdAtomicLoad: |
| 29204 | case IrInstructionIdMemberCount: | 29944 | case IrInstGenIdArrayToVector: |
| 29205 | case IrInstructionIdMemberType: | 29945 | case IrInstGenIdAlloca: |
| 29206 | case IrInstructionIdMemberName: | 29946 | case IrInstGenIdSpillEnd: |
| 29207 | case IrInstructionIdAlignOf: | 29947 | case IrInstGenIdVectorExtractElem: |
| 29208 | case IrInstructionIdReturnAddress: | 29948 | case IrInstGenIdBinaryNot: |
| 29209 | case IrInstructionIdFrameAddress: | 29949 | case IrInstGenIdNegation: |
| 29210 | case IrInstructionIdFrameHandle: | 29950 | case IrInstGenIdNegationWrapping: |
| 29211 | case IrInstructionIdFrameType: | | |
| 29212 | case IrInstructionIdFrameSizeSrc: | | |
| 29213 | case IrInstructionIdFrameSizeGen: | | |
| 29214 | case IrInstructionIdTestErrSrc: | | |
| 29215 | case IrInstructionIdTestErrGen: | | |
| 29216 | case IrInstructionIdFnProto: | | |
| 29217 | case IrInstructionIdTestComptime: | | |
| 29218 | case IrInstructionIdPtrCastSrc: | | |
| 29219 | case IrInstructionIdPtrCastGen: | | |
| 29220 | case IrInstructionIdBitCastSrc: | | |
| 29221 | case IrInstructionIdBitCastGen: | | |
| 29222 | case IrInstructionIdWidenOrShorten: | | |
| 29223 | case IrInstructionIdPtrToInt: | | |
| 29224 | case IrInstructionIdIntToPtr: | | |
| 29225 | case IrInstructionIdIntToEnum: | | |
| 29226 | case IrInstructionIdIntToErr: | | |
| 29227 | case IrInstructionIdErrToInt: | | |
| 29228 | case IrInstructionIdDeclRef: | | |
| 29229 | case IrInstructionIdErrName: | | |
| 29230 | case IrInstructionIdTypeName: | | |
| 29231 | case IrInstructionIdTagName: | | |
| 29232 | case IrInstructionIdFieldParentPtr: | | |
| 29233 | case IrInstructionIdByteOffsetOf: | | |
| 29234 | case IrInstructionIdBitOffsetOf: | | |
| 29235 | case IrInstructionIdTypeInfo: | | |
| 29236 | case IrInstructionIdType: | | |
| 29237 | case IrInstructionIdHasField: | | |
| 29238 | case IrInstructionIdTypeId: | | |
| 29239 | case IrInstructionIdAlignCast: | | |
| 29240 | case IrInstructionIdImplicitCast: | | |
| 29241 | case IrInstructionIdResolveResult: | | |
| 29242 | case IrInstructionIdOpaqueType: | | |
| 29243 | case IrInstructionIdArgType: | | |
| 29244 | case IrInstructionIdTagType: | | |
| 29245 | case IrInstructionIdErrorReturnTrace: | | |
| 29246 | case IrInstructionIdErrorUnion: | | |
| 29247 | case IrInstructionIdFloatOp: | | |
| 29248 | case IrInstructionIdMulAdd: | | |
| 29249 | case IrInstructionIdAtomicLoad: | | |
| 29250 | case IrInstructionIdIntCast: | | |
| 29251 | case IrInstructionIdFloatCast: | | |
| 29252 | case IrInstructionIdErrSetCast: | | |
| 29253 | case IrInstructionIdIntToFloat: | | |
| 29254 | case IrInstructionIdFloatToInt: | | |
| 29255 | case IrInstructionIdBoolToInt: | | |
| 29256 | case IrInstructionIdFromBytes: | | |
| 29257 | case IrInstructionIdToBytes: | | |
| 29258 | case IrInstructionIdEnumToInt: | | |
| 29259 | case IrInstructionIdArrayToVector: | | |
| 29260 | case IrInstructionIdHasDecl: | | |
| 29261 | case IrInstructionIdAllocaSrc: | | |
| 29262 | case IrInstructionIdAllocaGen: | | |
| 29263 | case IrInstructionIdSpillEnd: | | |
| 29264 | case IrInstructionIdVectorExtractElem: | | |
| 29265 | return false; | 29951 | return false; |
| 29266 | | 29952 | |
| 29267 | case IrInstructionIdAsmSrc: | 29953 | case IrInstGenIdAsm: |
| 29268 | { | 29954 | { |
| 29269 | IrInstructionAsmSrc *asm_instruction = (IrInstructionAsmSrc *)instruction; | 29955 | IrInstGenAsm *asm_instruction = (IrInstGenAsm *)instruction; |
| 29270 | return asm_instruction->has_side_effects; | 29956 | return asm_instruction->has_side_effects; |
| 29271 | } | 29957 | } |
| | 29958 | case IrInstGenIdUnwrapErrPayload: |
| | 29959 | { |
| | 29960 | IrInstGenUnwrapErrPayload *unwrap_err_payload_instruction = |
| | 29961 | (IrInstGenUnwrapErrPayload *)instruction; |
| | 29962 | return unwrap_err_payload_instruction->safety_check_on || |
| | 29963 | unwrap_err_payload_instruction->initializing; |
| | 29964 | } |
| | 29965 | case IrInstGenIdUnwrapErrCode: |
| | 29966 | return reinterpret_cast<IrInstGenUnwrapErrCode *>(instruction)->initializing; |
| | 29967 | case IrInstGenIdUnionFieldPtr: |
| | 29968 | return reinterpret_cast<IrInstGenUnionFieldPtr *>(instruction)->initializing; |
| | 29969 | case IrInstGenIdErrWrapPayload: |
| | 29970 | return reinterpret_cast<IrInstGenErrWrapPayload *>(instruction)->result_loc != nullptr; |
| | 29971 | case IrInstGenIdErrWrapCode: |
| | 29972 | return reinterpret_cast<IrInstGenErrWrapCode *>(instruction)->result_loc != nullptr; |
| | 29973 | case IrInstGenIdLoadPtr: |
| | 29974 | return reinterpret_cast<IrInstGenLoadPtr *>(instruction)->result_loc != nullptr; |
| | 29975 | case IrInstGenIdRef: |
| | 29976 | return reinterpret_cast<IrInstGenRef *>(instruction)->result_loc != nullptr; |
| | 29977 | } |
| | 29978 | zig_unreachable(); |
| | 29979 | } |
| | 29980 | |
| | 29981 | bool ir_inst_src_has_side_effects(IrInstSrc *instruction) { |
| | 29982 | switch (instruction->id) { |
| | 29983 | case IrInstSrcIdInvalid: |
| | 29984 | zig_unreachable(); |
| | 29985 | case IrInstSrcIdBr: |
| | 29986 | case IrInstSrcIdCondBr: |
| | 29987 | case IrInstSrcIdSwitchBr: |
| | 29988 | case IrInstSrcIdDeclVar: |
| | 29989 | case IrInstSrcIdStorePtr: |
| | 29990 | case IrInstSrcIdCallExtra: |
| | 29991 | case IrInstSrcIdCall: |
| | 29992 | case IrInstSrcIdCallArgs: |
| | 29993 | case IrInstSrcIdReturn: |
| | 29994 | case IrInstSrcIdUnreachable: |
| | 29995 | case IrInstSrcIdSetCold: |
| | 29996 | case IrInstSrcIdSetRuntimeSafety: |
| | 29997 | case IrInstSrcIdSetFloatMode: |
| | 29998 | case IrInstSrcIdImport: |
| | 29999 | case IrInstSrcIdCompileErr: |
| | 30000 | case IrInstSrcIdCompileLog: |
| | 30001 | case IrInstSrcIdCImport: |
| | 30002 | case IrInstSrcIdCInclude: |
| | 30003 | case IrInstSrcIdCDefine: |
| | 30004 | case IrInstSrcIdCUndef: |
| | 30005 | case IrInstSrcIdFence: |
| | 30006 | case IrInstSrcIdMemset: |
| | 30007 | case IrInstSrcIdMemcpy: |
| | 30008 | case IrInstSrcIdBreakpoint: |
| | 30009 | case IrInstSrcIdOverflowOp: // TODO when we support multiple returns this can be side effect free |
| | 30010 | case IrInstSrcIdCheckSwitchProngs: |
| | 30011 | case IrInstSrcIdCheckStatementIsVoid: |
| | 30012 | case IrInstSrcIdCheckRuntimeScope: |
| | 30013 | case IrInstSrcIdPanic: |
| | 30014 | case IrInstSrcIdSetEvalBranchQuota: |
| | 30015 | case IrInstSrcIdPtrType: |
| | 30016 | case IrInstSrcIdSetAlignStack: |
| | 30017 | case IrInstSrcIdExport: |
| | 30018 | case IrInstSrcIdSaveErrRetAddr: |
| | 30019 | case IrInstSrcIdAddImplicitReturnType: |
| | 30020 | case IrInstSrcIdAtomicRmw: |
| | 30021 | case IrInstSrcIdAtomicStore: |
| | 30022 | case IrInstSrcIdCmpxchg: |
| | 30023 | case IrInstSrcIdUndeclaredIdent: |
| | 30024 | case IrInstSrcIdEndExpr: |
| | 30025 | case IrInstSrcIdResetResult: |
| | 30026 | case IrInstSrcIdSuspendBegin: |
| | 30027 | case IrInstSrcIdSuspendFinish: |
| | 30028 | case IrInstSrcIdResume: |
| | 30029 | case IrInstSrcIdAwait: |
| | 30030 | case IrInstSrcIdSpillBegin: |
| | 30031 | return true; |
| | 30032 | |
| | 30033 | case IrInstSrcIdPhi: |
| | 30034 | case IrInstSrcIdUnOp: |
| | 30035 | case IrInstSrcIdBinOp: |
| | 30036 | case IrInstSrcIdMergeErrSets: |
| | 30037 | case IrInstSrcIdLoadPtr: |
| | 30038 | case IrInstSrcIdConst: |
| | 30039 | case IrInstSrcIdContainerInitList: |
| | 30040 | case IrInstSrcIdContainerInitFields: |
| | 30041 | case IrInstSrcIdUnionInitNamedField: |
| | 30042 | case IrInstSrcIdFieldPtr: |
| | 30043 | case IrInstSrcIdElemPtr: |
| | 30044 | case IrInstSrcIdVarPtr: |
| | 30045 | case IrInstSrcIdTypeOf: |
| | 30046 | case IrInstSrcIdArrayType: |
| | 30047 | case IrInstSrcIdSliceType: |
| | 30048 | case IrInstSrcIdAnyFrameType: |
| | 30049 | case IrInstSrcIdSizeOf: |
| | 30050 | case IrInstSrcIdTestNonNull: |
| | 30051 | case IrInstSrcIdOptionalUnwrapPtr: |
| | 30052 | case IrInstSrcIdClz: |
| | 30053 | case IrInstSrcIdCtz: |
| | 30054 | case IrInstSrcIdPopCount: |
| | 30055 | case IrInstSrcIdBswap: |
| | 30056 | case IrInstSrcIdBitReverse: |
| | 30057 | case IrInstSrcIdSwitchVar: |
| | 30058 | case IrInstSrcIdSwitchElseVar: |
| | 30059 | case IrInstSrcIdSwitchTarget: |
| | 30060 | case IrInstSrcIdRef: |
| | 30061 | case IrInstSrcIdEmbedFile: |
| | 30062 | case IrInstSrcIdTruncate: |
| | 30063 | case IrInstSrcIdIntType: |
| | 30064 | case IrInstSrcIdVectorType: |
| | 30065 | case IrInstSrcIdShuffleVector: |
| | 30066 | case IrInstSrcIdSplat: |
| | 30067 | case IrInstSrcIdBoolNot: |
| | 30068 | case IrInstSrcIdSlice: |
| | 30069 | case IrInstSrcIdMemberCount: |
| | 30070 | case IrInstSrcIdMemberType: |
| | 30071 | case IrInstSrcIdMemberName: |
| | 30072 | case IrInstSrcIdAlignOf: |
| | 30073 | case IrInstSrcIdReturnAddress: |
| | 30074 | case IrInstSrcIdFrameAddress: |
| | 30075 | case IrInstSrcIdFrameHandle: |
| | 30076 | case IrInstSrcIdFrameType: |
| | 30077 | case IrInstSrcIdFrameSize: |
| | 30078 | case IrInstSrcIdTestErr: |
| | 30079 | case IrInstSrcIdFnProto: |
| | 30080 | case IrInstSrcIdTestComptime: |
| | 30081 | case IrInstSrcIdPtrCast: |
| | 30082 | case IrInstSrcIdBitCast: |
| | 30083 | case IrInstSrcIdPtrToInt: |
| | 30084 | case IrInstSrcIdIntToPtr: |
| | 30085 | case IrInstSrcIdIntToEnum: |
| | 30086 | case IrInstSrcIdIntToErr: |
| | 30087 | case IrInstSrcIdErrToInt: |
| | 30088 | case IrInstSrcIdDeclRef: |
| | 30089 | case IrInstSrcIdErrName: |
| | 30090 | case IrInstSrcIdTypeName: |
| | 30091 | case IrInstSrcIdTagName: |
| | 30092 | case IrInstSrcIdFieldParentPtr: |
| | 30093 | case IrInstSrcIdByteOffsetOf: |
| | 30094 | case IrInstSrcIdBitOffsetOf: |
| | 30095 | case IrInstSrcIdTypeInfo: |
| | 30096 | case IrInstSrcIdType: |
| | 30097 | case IrInstSrcIdHasField: |
| | 30098 | case IrInstSrcIdTypeId: |
| | 30099 | case IrInstSrcIdAlignCast: |
| | 30100 | case IrInstSrcIdImplicitCast: |
| | 30101 | case IrInstSrcIdResolveResult: |
| | 30102 | case IrInstSrcIdOpaqueType: |
| | 30103 | case IrInstSrcIdArgType: |
| | 30104 | case IrInstSrcIdTagType: |
| | 30105 | case IrInstSrcIdErrorReturnTrace: |
| | 30106 | case IrInstSrcIdErrorUnion: |
| | 30107 | case IrInstSrcIdFloatOp: |
| | 30108 | case IrInstSrcIdMulAdd: |
| | 30109 | case IrInstSrcIdAtomicLoad: |
| | 30110 | case IrInstSrcIdIntCast: |
| | 30111 | case IrInstSrcIdFloatCast: |
| | 30112 | case IrInstSrcIdErrSetCast: |
| | 30113 | case IrInstSrcIdIntToFloat: |
| | 30114 | case IrInstSrcIdFloatToInt: |
| | 30115 | case IrInstSrcIdBoolToInt: |
| | 30116 | case IrInstSrcIdFromBytes: |
| | 30117 | case IrInstSrcIdToBytes: |
| | 30118 | case IrInstSrcIdEnumToInt: |
| | 30119 | case IrInstSrcIdHasDecl: |
| | 30120 | case IrInstSrcIdAlloca: |
| | 30121 | case IrInstSrcIdSpillEnd: |
| | 30122 | return false; |
| 29272 | | 30123 | |
| 29273 | case IrInstructionIdAsmGen: | 30124 | case IrInstSrcIdAsm: |
| 29274 | { | 30125 | { |
| 29275 | IrInstructionAsmGen *asm_instruction = (IrInstructionAsmGen *)instruction; | 30126 | IrInstSrcAsm *asm_instruction = (IrInstSrcAsm *)instruction; |
| 29276 | return asm_instruction->has_side_effects; | 30127 | return asm_instruction->has_side_effects; |
| 29277 | } | 30128 | } |
| 29278 | case IrInstructionIdUnwrapErrPayload: | 30129 | |
| | 30130 | case IrInstSrcIdUnwrapErrPayload: |
| 29279 | { | 30131 | { |
| 29280 | IrInstructionUnwrapErrPayload *unwrap_err_payload_instruction = | 30132 | IrInstSrcUnwrapErrPayload *unwrap_err_payload_instruction = |
| 29281 | (IrInstructionUnwrapErrPayload *)instruction; | 30133 | (IrInstSrcUnwrapErrPayload *)instruction; |
| 29282 | return unwrap_err_payload_instruction->safety_check_on || | 30134 | return unwrap_err_payload_instruction->safety_check_on || |
| 29283 | unwrap_err_payload_instruction->initializing; | 30135 | unwrap_err_payload_instruction->initializing; |
| 29284 | } | 30136 | } |
| 29285 | case IrInstructionIdUnwrapErrCode: | 30137 | case IrInstSrcIdUnwrapErrCode: |
| 29286 | return reinterpret_cast<IrInstructionUnwrapErrCode *>(instruction)->initializing; | 30138 | return reinterpret_cast<IrInstSrcUnwrapErrCode *>(instruction)->initializing; |
| 29287 | case IrInstructionIdUnionFieldPtr: | | |
| 29288 | return reinterpret_cast<IrInstructionUnionFieldPtr *>(instruction)->initializing; | | |
| 29289 | case IrInstructionIdErrWrapPayload: | | |
| 29290 | return reinterpret_cast<IrInstructionErrWrapPayload *>(instruction)->result_loc != nullptr; | | |
| 29291 | case IrInstructionIdErrWrapCode: | | |
| 29292 | return reinterpret_cast<IrInstructionErrWrapCode *>(instruction)->result_loc != nullptr; | | |
| 29293 | case IrInstructionIdLoadPtrGen: | | |
| 29294 | return reinterpret_cast<IrInstructionLoadPtrGen *>(instruction)->result_loc != nullptr; | | |
| 29295 | case IrInstructionIdRefGen: | | |
| 29296 | return reinterpret_cast<IrInstructionRefGen *>(instruction)->result_loc != nullptr; | | |
| 29297 | } | 30139 | } |
| 29298 | zig_unreachable(); | 30140 | zig_unreachable(); |
| 29299 | } | 30141 | } |
| ... | @@ -29327,14 +30169,14 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La | ... | @@ -29327,14 +30169,14 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La |
| 29327 | param_info->type = nullptr; | 30169 | param_info->type = nullptr; |
| 29328 | return get_generic_fn_type(ira->codegen, &fn_type_id); | 30170 | return get_generic_fn_type(ira->codegen, &fn_type_id); |
| 29329 | } else { | 30171 | } else { |
| 29330 | IrInstruction *param_type_inst = lazy_fn_type->param_types[fn_type_id.next_param_index]; | 30172 | IrInstGen *param_type_inst = lazy_fn_type->param_types[fn_type_id.next_param_index]; |
| 29331 | ZigType *param_type = ir_resolve_type(ira, param_type_inst); | 30173 | ZigType *param_type = ir_resolve_type(ira, param_type_inst); |
| 29332 | if (type_is_invalid(param_type)) | 30174 | if (type_is_invalid(param_type)) |
| 29333 | return nullptr; | 30175 | return nullptr; |
| 29334 | switch (type_requires_comptime(ira->codegen, param_type)) { | 30176 | switch (type_requires_comptime(ira->codegen, param_type)) { |
| 29335 | case ReqCompTimeYes: | 30177 | case ReqCompTimeYes: |
| 29336 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { | 30178 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { |
| 29337 | ir_add_error(ira, param_type_inst, | 30179 | ir_add_error(ira, &param_type_inst->base, |
| 29338 | buf_sprintf("parameter of type '%s' not allowed in function with calling convention '%s'", | 30180 | buf_sprintf("parameter of type '%s' not allowed in function with calling convention '%s'", |
| 29339 | buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc))); | 30181 | buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc))); |
| 29340 | return nullptr; | 30182 | return nullptr; |
| ... | @@ -29352,7 +30194,7 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La | ... | @@ -29352,7 +30194,7 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La |
| 29352 | if ((err = type_has_bits2(ira->codegen, param_type, &has_bits))) | 30194 | if ((err = type_has_bits2(ira->codegen, param_type, &has_bits))) |
| 29353 | return nullptr; | 30195 | return nullptr; |
| 29354 | if (!has_bits) { | 30196 | if (!has_bits) { |
| 29355 | ir_add_error(ira, param_type_inst, | 30197 | ir_add_error(ira, &param_type_inst->base, |
| 29356 | buf_sprintf("parameter of type '%s' has 0 bits; not allowed in function with calling convention '%s'", | 30198 | buf_sprintf("parameter of type '%s' has 0 bits; not allowed in function with calling convention '%s'", |
| 29357 | buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc))); | 30199 | buf_ptr(&param_type->name), calling_convention_name(fn_type_id.cc))); |
| 29358 | return nullptr; | 30200 | return nullptr; |
| ... | @@ -29371,7 +30213,7 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La | ... | @@ -29371,7 +30213,7 @@ static ZigType *ir_resolve_lazy_fn_type(IrAnalyze *ira, AstNode *source_node, La |
| 29371 | if (type_is_invalid(fn_type_id.return_type)) | 30213 | if (type_is_invalid(fn_type_id.return_type)) |
| 29372 | return nullptr; | 30214 | return nullptr; |
| 29373 | if (fn_type_id.return_type->id == ZigTypeIdOpaque) { | 30215 | if (fn_type_id.return_type->id == ZigTypeIdOpaque) { |
| 29374 | ir_add_error(ira, lazy_fn_type->return_type, buf_create_from_str("return type cannot be opaque")); | 30216 | ir_add_error(ira, &lazy_fn_type->return_type->base, buf_create_from_str("return type cannot be opaque")); |
| 29375 | return nullptr; | 30217 | return nullptr; |
| 29376 | } | 30218 | } |
| 29377 | | 30219 | |
| ... | @@ -29403,7 +30245,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29403,7 +30245,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29403 | case ZigTypeIdBoundFn: | 30245 | case ZigTypeIdBoundFn: |
| 29404 | case ZigTypeIdVoid: | 30246 | case ZigTypeIdVoid: |
| 29405 | case ZigTypeIdOpaque: | 30247 | case ZigTypeIdOpaque: |
| 29406 | ir_add_error(ira, lazy_align_of->target_type, | 30248 | ir_add_error(ira, &lazy_align_of->target_type->base, |
| 29407 | buf_sprintf("no align available for type '%s'", | 30249 | buf_sprintf("no align available for type '%s'", |
| 29408 | buf_ptr(&lazy_align_of->target_type->value->data.x_type->name))); | 30250 | buf_ptr(&lazy_align_of->target_type->value->data.x_type->name))); |
| 29409 | return ErrorSemanticAnalyzeFail; | 30251 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -29453,7 +30295,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29453,7 +30295,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29453 | case ZigTypeIdNull: | 30295 | case ZigTypeIdNull: |
| 29454 | case ZigTypeIdBoundFn: | 30296 | case ZigTypeIdBoundFn: |
| 29455 | case ZigTypeIdOpaque: | 30297 | case ZigTypeIdOpaque: |
| 29456 | ir_add_error(ira, lazy_size_of->target_type, | 30298 | ir_add_error(ira, &lazy_size_of->target_type->base, |
| 29457 | buf_sprintf("no size available for type '%s'", | 30299 | buf_sprintf("no size available for type '%s'", |
| 29458 | buf_ptr(&lazy_size_of->target_type->value->data.x_type->name))); | 30300 | buf_ptr(&lazy_size_of->target_type->value->data.x_type->name))); |
| 29459 | return ErrorSemanticAnalyzeFail; | 30301 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -29511,7 +30353,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29511,7 +30353,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29511 | if (lazy_slice_type->sentinel != nullptr) { | 30353 | if (lazy_slice_type->sentinel != nullptr) { |
| 29512 | if (type_is_invalid(lazy_slice_type->sentinel->value->type)) | 30354 | if (type_is_invalid(lazy_slice_type->sentinel->value->type)) |
| 29513 | return ErrorSemanticAnalyzeFail; | 30355 | return ErrorSemanticAnalyzeFail; |
| 29514 | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_slice_type->sentinel, elem_type); | 30356 | IrInstGen *sentinel = ir_implicit_cast(ira, lazy_slice_type->sentinel, elem_type); |
| 29515 | if (type_is_invalid(sentinel->value->type)) | 30357 | if (type_is_invalid(sentinel->value->type)) |
| 29516 | return ErrorSemanticAnalyzeFail; | 30358 | return ErrorSemanticAnalyzeFail; |
| 29517 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); | 30359 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| ... | @@ -29534,7 +30376,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29534,7 +30376,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29534 | case ZigTypeIdUndefined: | 30376 | case ZigTypeIdUndefined: |
| 29535 | case ZigTypeIdNull: | 30377 | case ZigTypeIdNull: |
| 29536 | case ZigTypeIdOpaque: | 30378 | case ZigTypeIdOpaque: |
| 29537 | ir_add_error(ira, lazy_slice_type->elem_type, | 30379 | ir_add_error(ira, &lazy_slice_type->elem_type->base, |
| 29538 | buf_sprintf("slice of type '%s' not allowed", buf_ptr(&elem_type->name))); | 30380 | buf_sprintf("slice of type '%s' not allowed", buf_ptr(&elem_type->name))); |
| 29539 | return ErrorSemanticAnalyzeFail; | 30381 | return ErrorSemanticAnalyzeFail; |
| 29540 | case ZigTypeIdMetaType: | 30382 | case ZigTypeIdMetaType: |
| ... | @@ -29590,7 +30432,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29590,7 +30432,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29590 | if (lazy_ptr_type->sentinel != nullptr) { | 30432 | if (lazy_ptr_type->sentinel != nullptr) { |
| 29591 | if (type_is_invalid(lazy_ptr_type->sentinel->value->type)) | 30433 | if (type_is_invalid(lazy_ptr_type->sentinel->value->type)) |
| 29592 | return ErrorSemanticAnalyzeFail; | 30434 | return ErrorSemanticAnalyzeFail; |
| 29593 | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_ptr_type->sentinel, elem_type); | 30435 | IrInstGen *sentinel = ir_implicit_cast(ira, lazy_ptr_type->sentinel, elem_type); |
| 29594 | if (type_is_invalid(sentinel->value->type)) | 30436 | if (type_is_invalid(sentinel->value->type)) |
| 29595 | return ErrorSemanticAnalyzeFail; | 30437 | return ErrorSemanticAnalyzeFail; |
| 29596 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); | 30438 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| ... | @@ -29607,11 +30449,11 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29607,11 +30449,11 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29607 | } | 30449 | } |
| 29608 | | 30450 | |
| 29609 | if (elem_type->id == ZigTypeIdUnreachable) { | 30451 | if (elem_type->id == ZigTypeIdUnreachable) { |
| 29610 | ir_add_error(ira, lazy_ptr_type->elem_type, | 30452 | ir_add_error(ira, &lazy_ptr_type->elem_type->base, |
| 29611 | buf_create_from_str("pointer to noreturn not allowed")); | 30453 | buf_create_from_str("pointer to noreturn not allowed")); |
| 29612 | return ErrorSemanticAnalyzeFail; | 30454 | return ErrorSemanticAnalyzeFail; |
| 29613 | } else if (elem_type->id == ZigTypeIdOpaque && lazy_ptr_type->ptr_len == PtrLenUnknown) { | 30455 | } else if (elem_type->id == ZigTypeIdOpaque && lazy_ptr_type->ptr_len == PtrLenUnknown) { |
| 29614 | ir_add_error(ira, lazy_ptr_type->elem_type, | 30456 | ir_add_error(ira, &lazy_ptr_type->elem_type->base, |
| 29615 | buf_create_from_str("unknown-length pointer to opaque")); | 30457 | buf_create_from_str("unknown-length pointer to opaque")); |
| 29616 | return ErrorSemanticAnalyzeFail; | 30458 | return ErrorSemanticAnalyzeFail; |
| 29617 | } else if (lazy_ptr_type->ptr_len == PtrLenC) { | 30459 | } else if (lazy_ptr_type->ptr_len == PtrLenC) { |
| ... | @@ -29619,16 +30461,16 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29619,16 +30461,16 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29619 | if ((err = type_allowed_in_extern(ira->codegen, elem_type, &ok_type))) | 30461 | if ((err = type_allowed_in_extern(ira->codegen, elem_type, &ok_type))) |
| 29620 | return err; | 30462 | return err; |
| 29621 | if (!ok_type) { | 30463 | if (!ok_type) { |
| 29622 | ir_add_error(ira, lazy_ptr_type->elem_type, | 30464 | ir_add_error(ira, &lazy_ptr_type->elem_type->base, |
| 29623 | buf_sprintf("C pointers cannot point to non-C-ABI-compatible type '%s'", | 30465 | buf_sprintf("C pointers cannot point to non-C-ABI-compatible type '%s'", |
| 29624 | buf_ptr(&elem_type->name))); | 30466 | buf_ptr(&elem_type->name))); |
| 29625 | return ErrorSemanticAnalyzeFail; | 30467 | return ErrorSemanticAnalyzeFail; |
| 29626 | } else if (elem_type->id == ZigTypeIdOpaque) { | 30468 | } else if (elem_type->id == ZigTypeIdOpaque) { |
| 29627 | ir_add_error(ira, lazy_ptr_type->elem_type, | 30469 | ir_add_error(ira, &lazy_ptr_type->elem_type->base, |
| 29628 | buf_sprintf("C pointers cannot point opaque types")); | 30470 | buf_sprintf("C pointers cannot point opaque types")); |
| 29629 | return ErrorSemanticAnalyzeFail; | 30471 | return ErrorSemanticAnalyzeFail; |
| 29630 | } else if (lazy_ptr_type->is_allowzero) { | 30472 | } else if (lazy_ptr_type->is_allowzero) { |
| 29631 | ir_add_error(ira, lazy_ptr_type->elem_type, | 30473 | ir_add_error(ira, &lazy_ptr_type->elem_type->base, |
| 29632 | buf_sprintf("C pointers always allow address zero")); | 30474 | buf_sprintf("C pointers always allow address zero")); |
| 29633 | return ErrorSemanticAnalyzeFail; | 30475 | return ErrorSemanticAnalyzeFail; |
| 29634 | } | 30476 | } |
| ... | @@ -29666,7 +30508,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29666,7 +30508,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29666 | case ZigTypeIdUndefined: | 30508 | case ZigTypeIdUndefined: |
| 29667 | case ZigTypeIdNull: | 30509 | case ZigTypeIdNull: |
| 29668 | case ZigTypeIdOpaque: | 30510 | case ZigTypeIdOpaque: |
| 29669 | ir_add_error(ira, lazy_array_type->elem_type, | 30511 | ir_add_error(ira, &lazy_array_type->elem_type->base, |
| 29670 | buf_sprintf("array of type '%s' not allowed", | 30512 | buf_sprintf("array of type '%s' not allowed", |
| 29671 | buf_ptr(&elem_type->name))); | 30513 | buf_ptr(&elem_type->name))); |
| 29672 | return ErrorSemanticAnalyzeFail; | 30514 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -29701,7 +30543,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29701,7 +30543,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29701 | if (lazy_array_type->sentinel != nullptr) { | 30543 | if (lazy_array_type->sentinel != nullptr) { |
| 29702 | if (type_is_invalid(lazy_array_type->sentinel->value->type)) | 30544 | if (type_is_invalid(lazy_array_type->sentinel->value->type)) |
| 29703 | return ErrorSemanticAnalyzeFail; | 30545 | return ErrorSemanticAnalyzeFail; |
| 29704 | IrInstruction *sentinel = ir_implicit_cast(ira, lazy_array_type->sentinel, elem_type); | 30546 | IrInstGen *sentinel = ir_implicit_cast(ira, lazy_array_type->sentinel, elem_type); |
| 29705 | if (type_is_invalid(sentinel->value->type)) | 30547 | if (type_is_invalid(sentinel->value->type)) |
| 29706 | return ErrorSemanticAnalyzeFail; | 30548 | return ErrorSemanticAnalyzeFail; |
| 29707 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); | 30549 | sentinel_val = ir_resolve_const(ira, sentinel, UndefBad); |
| ... | @@ -29725,7 +30567,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29725,7 +30567,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29725 | return ErrorSemanticAnalyzeFail; | 30567 | return ErrorSemanticAnalyzeFail; |
| 29726 | | 30568 | |
| 29727 | if (payload_type->id == ZigTypeIdOpaque || payload_type->id == ZigTypeIdUnreachable) { | 30569 | if (payload_type->id == ZigTypeIdOpaque || payload_type->id == ZigTypeIdUnreachable) { |
| 29728 | ir_add_error(ira, lazy_opt_type->payload_type, | 30570 | ir_add_error(ira, &lazy_opt_type->payload_type->base, |
| 29729 | buf_sprintf("type '%s' cannot be optional", buf_ptr(&payload_type->name))); | 30571 | buf_sprintf("type '%s' cannot be optional", buf_ptr(&payload_type->name))); |
| 29730 | return ErrorSemanticAnalyzeFail; | 30572 | return ErrorSemanticAnalyzeFail; |
| 29731 | } | 30573 | } |
| ... | @@ -29767,7 +30609,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { | ... | @@ -29767,7 +30609,7 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { |
| 29767 | return ErrorSemanticAnalyzeFail; | 30609 | return ErrorSemanticAnalyzeFail; |
| 29768 | | 30610 | |
| 29769 | if (err_set_type->id != ZigTypeIdErrorSet) { | 30611 | if (err_set_type->id != ZigTypeIdErrorSet) { |
| 29770 | ir_add_error(ira, lazy_err_union_type->err_set_type, | 30612 | ir_add_error(ira, &lazy_err_union_type->err_set_type->base, |
| 29771 | buf_sprintf("expected error set type, found type '%s'", | 30613 | buf_sprintf("expected error set type, found type '%s'", |
| 29772 | buf_ptr(&err_set_type->name))); | 30614 | buf_ptr(&err_set_type->name))); |
| 29773 | return ErrorSemanticAnalyzeFail; | 30615 | return ErrorSemanticAnalyzeFail; |
| ... | @@ -29803,8 +30645,8 @@ Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ZigValue *val) { | ... | @@ -29803,8 +30645,8 @@ Error ir_resolve_lazy(CodeGen *codegen, AstNode *source_node, ZigValue *val) { |
| 29803 | return ErrorNone; | 30645 | return ErrorNone; |
| 29804 | } | 30646 | } |
| 29805 | | 30647 | |
| 29806 | void IrInstruction::src() { | 30648 | void IrInst::src() { |
| 29807 | IrInstruction *inst = this; | 30649 | IrInst *inst = this; |
| 29808 | if (inst->source_node != nullptr) { | 30650 | if (inst->source_node != nullptr) { |
| 29809 | inst->source_node->src(); | 30651 | inst->source_node->src(); |
| 29810 | } else { | 30652 | } else { |
| ... | @@ -29812,26 +30654,45 @@ void IrInstruction::src() { | ... | @@ -29812,26 +30654,45 @@ void IrInstruction::src() { |
| 29812 | } | 30654 | } |
| 29813 | } | 30655 | } |
| 29814 | | 30656 | |
| 29815 | void IrInstruction::dump() { | 30657 | void IrInst::dump() { |
| 29816 | IrInstruction *inst = this; | 30658 | this->src(); |
| | 30659 | fprintf(stderr, "IrInst(#%" PRIu32 ")\n", this->debug_id); |
| | 30660 | } |
| | 30661 | |
| | 30662 | void IrInstSrc::src() { |
| | 30663 | this->base.src(); |
| | 30664 | } |
| | 30665 | |
| | 30666 | void IrInstGen::src() { |
| | 30667 | this->base.src(); |
| | 30668 | } |
| | 30669 | |
| | 30670 | void IrInstSrc::dump() { |
| | 30671 | IrInstSrc *inst = this; |
| 29817 | inst->src(); | 30672 | inst->src(); |
| 29818 | IrPass pass = (inst->child == nullptr) ? IrPassGen : IrPassSrc; | 30673 | if (inst->base.scope == nullptr) { |
| 29819 | if (inst->scope == nullptr) { | | |
| 29820 | fprintf(stderr, "(null scope)\n"); | 30674 | fprintf(stderr, "(null scope)\n"); |
| 29821 | } else { | 30675 | } else { |
| 29822 | ir_print_instruction(inst->scope->codegen, stderr, inst, 0, pass); | 30676 | ir_print_inst_src(inst->base.scope->codegen, stderr, inst, 0); |
| 29823 | if (pass == IrPassSrc) { | 30677 | fprintf(stderr, "-> "); |
| 29824 | fprintf(stderr, "-> "); | 30678 | ir_print_inst_gen(inst->base.scope->codegen, stderr, inst->child, 0); |
| 29825 | ir_print_instruction(inst->scope->codegen, stderr, inst->child, 0, IrPassGen); | 30679 | } |
| 29826 | } | 30680 | } |
| | 30681 | void IrInstGen::dump() { |
| | 30682 | IrInstGen *inst = this; |
| | 30683 | inst->src(); |
| | 30684 | if (inst->base.scope == nullptr) { |
| | 30685 | fprintf(stderr, "(null scope)\n"); |
| | 30686 | } else { |
| | 30687 | ir_print_inst_gen(inst->base.scope->codegen, stderr, inst, 0); |
| 29827 | } | 30688 | } |
| 29828 | } | 30689 | } |
| 29829 | | 30690 | |
| 29830 | void IrAnalyze::dump() { | 30691 | void IrAnalyze::dump() { |
| 29831 | ir_print(this->codegen, stderr, this->new_irb.exec, 0, IrPassGen); | 30692 | ir_print_gen(this->codegen, stderr, this->new_irb.exec, 0); |
| 29832 | if (this->new_irb.current_basic_block != nullptr) { | 30693 | if (this->new_irb.current_basic_block != nullptr) { |
| 29833 | fprintf(stderr, "Current basic block:\n"); | 30694 | fprintf(stderr, "Current basic block:\n"); |
| 29834 | ir_print_basic_block(this->codegen, stderr, this->new_irb.current_basic_block, 1, IrPassGen); | 30695 | ir_print_basic_block_gen(this->codegen, stderr, this->new_irb.current_basic_block, 1); |
| 29835 | } | 30696 | } |
| 29836 | } | 30697 | } |
| 29837 | | 30698 | |